@@ -138,6 +138,7 @@ func extractVisibilityRulesFromJS(js string) ([]types.WidgetVisibilityRule, edit
138138 var stats editorConfigExtractStats
139139 var pending []ternaryThenCandidate // resolved after the loop
140140 seen := map [string ]bool {} // dedupe propertyKey+condition
141+ consts := stringArrayConsts (js ) // module-level arrays, for `[…].concat(N)`
141142
142143 for _ , loc := range hideCallRE .FindAllStringIndex (js , - 1 ) {
143144 stats .TotalHideCalls ++
@@ -147,7 +148,7 @@ func extractVisibilityRulesFromJS(js string) ([]types.WidgetVisibilityRule, edit
147148 stats .SkippedComplex ++
148149 continue
149150 }
150- listKey , keys , condKeys , ok := hideTargetKeys (args )
151+ listKey , keys , condKeys , ok := hideTargetKeys (args , consts )
151152 if ! ok || (len (keys ) == 0 && len (condKeys ) == 0 ) {
152153 stats .SkippedComplex ++
153154 continue
@@ -387,15 +388,28 @@ func negate(c types.WidgetVisibilityCondition) (types.WidgetVisibilityCondition,
387388//
388389// ok is false for a shape it does not recognize; the caller counts it as skipped
389390// and emits no rule, which degrades to "not hidden".
390- func hideTargetKeys (args string ) (listKey string , keys []string , condKeys []ternaryKey , ok bool ) {
391+ func hideTargetKeys (args string , consts map [ string ][] string ) (listKey string , keys []string , condKeys []ternaryKey , ok bool ) {
391392 parts := splitTopLevelCommas (args )
392393 // Collect string-literal positional args and any array literal.
393394 var stringArgs []string
394395 var arrayKeys []string
395396 for _ , p := range parts {
396397 p = strings .TrimSpace (p )
397398 if strings .HasPrefix (p , "[" ) {
398- for _ , el := range splitTopLevelCommas (strings .TrimSuffix (strings .TrimPrefix (strings .TrimSpace (p ), "[" ), "]" )) {
399+ // The argument may be `[…].concat(N, W)`, so read the literal with a
400+ // balanced scan and resolve the concatenated arrays separately —
401+ // trimming a trailing "]" would stop at the first element and drop
402+ // everything after it.
403+ body , bodyOK := balancedArgs (p , 1 )
404+ if ! bodyOK {
405+ body = strings .TrimSuffix (strings .TrimPrefix (p , "[" ), "]" )
406+ }
407+ if bodyOK {
408+ if extra , extraOK := concatMembers (p [len (body )+ 2 :], consts ); extraOK {
409+ arrayKeys = append (arrayKeys , extra ... )
410+ }
411+ }
412+ for _ , el := range splitTopLevelCommas (body ) {
399413 if tk , ok := ternaryElement (el ); ok {
400414 // `cond ? "a" : "b"` as an array ELEMENT. Harvesting its string
401415 // literals would invent a key from the comparison value and mark
@@ -433,6 +447,119 @@ func hideTargetKeys(args string) (listKey string, keys []string, condKeys []tern
433447 }
434448}
435449
450+ // arrayDeclRE finds a module-level array binding — `z=["lazyLoading",…]` in the
451+ // minified bundle. Combo box's biggest hide lists are built by concatenating
452+ // three such arrays onto a literal one, so without resolving them the call is
453+ // counted as recognized while most of its properties are silently dropped.
454+ var arrayDeclRE = regexp .MustCompile (`(?:^|[,;({=\s])([A-Za-z_$][\w$]*)\s*=\s*\[` )
455+
456+ // concatCallRE matches the `.concat(` that follows a hide call's array argument.
457+ var concatCallRE = regexp .MustCompile (`^\s*\.concat\(` )
458+
459+ // stringArrayConsts maps each identifier bound to an array of STRING LITERALS to
460+ // its members. An identifier bound more than once is dropped rather than
461+ // guessed at: the minifier reuses short names across scopes, and resolving one
462+ // to the wrong array would invent hide rules for properties the editor shows.
463+ // Arrays holding anything but string literals (an element list, a data URI
464+ // built by a call) are skipped for the same reason.
465+ func stringArrayConsts (js string ) map [string ][]string {
466+ out := map [string ][]string {}
467+ ambiguous := map [string ]bool {}
468+ for _ , loc := range arrayDeclRE .FindAllStringSubmatchIndex (js , - 1 ) {
469+ name := js [loc [2 ]:loc [3 ]]
470+ if ambiguous [name ] {
471+ continue
472+ }
473+ body , ok := balancedArgs (js , loc [1 ]) // loc[1] is just past the '['
474+ if ! ok {
475+ continue
476+ }
477+ members , ok := stringArrayMembers (body )
478+ if ! ok {
479+ continue
480+ }
481+ if prev , seen := out [name ]; seen && ! sameStrings (prev , members ) {
482+ delete (out , name )
483+ ambiguous [name ] = true
484+ continue
485+ }
486+ out [name ] = members
487+ }
488+ return out
489+ }
490+
491+ // stringArrayMembers reads an array literal's body as a list of string literals.
492+ // ok is false if ANY element is something else — a partial read would drop
493+ // members without saying so, which is the defect this exists to fix.
494+ func stringArrayMembers (body string ) ([]string , bool ) {
495+ if strings .TrimSpace (body ) == "" {
496+ return nil , false
497+ }
498+ var out []string
499+ for _ , el := range splitTopLevelCommas (body ) {
500+ el = strings .TrimSpace (el )
501+ m := stringLitRE .FindStringSubmatch (el )
502+ if m == nil || ! strings .HasPrefix (el , `"` ) || len (m [0 ]) != len (el ) {
503+ return nil , false
504+ }
505+ out = append (out , m [1 ])
506+ }
507+ return out , true
508+ }
509+
510+ func sameStrings (a , b []string ) bool {
511+ if len (a ) != len (b ) {
512+ return false
513+ }
514+ for i := range a {
515+ if a [i ] != b [i ] {
516+ return false
517+ }
518+ }
519+ return true
520+ }
521+
522+ // concatMembers reads the `.concat(a, b)` chain trailing an array literal and
523+ // returns the members its arguments contribute. Each argument must be either an
524+ // inline string array or an identifier in consts; anything else (a call such as
525+ // `.concat(i(a))`) yields ok=false, and the caller keeps the literal keys alone
526+ // rather than emitting a list it knows to be short.
527+ func concatMembers (tail string , consts map [string ][]string ) ([]string , bool ) {
528+ var out []string
529+ for {
530+ m := concatCallRE .FindStringIndex (tail )
531+ if m == nil {
532+ return out , true
533+ }
534+ args , ok := balancedArgs (tail , m [1 ])
535+ if ! ok {
536+ return out , false
537+ }
538+ for _ , a := range splitTopLevelCommas (args ) {
539+ a = strings .TrimSpace (a )
540+ switch {
541+ case strings .HasPrefix (a , "[" ):
542+ body , ok := balancedArgs (a , 1 )
543+ if ! ok {
544+ return out , false
545+ }
546+ members , ok := stringArrayMembers (body )
547+ if ! ok {
548+ return out , false
549+ }
550+ out = append (out , members ... )
551+ default :
552+ members , ok := consts [a ]
553+ if ! ok {
554+ return out , false
555+ }
556+ out = append (out , members ... )
557+ }
558+ }
559+ tail = tail [m [1 ]+ len (args )+ 1 :] // past the closing ')', for a chained .concat
560+ }
561+ }
562+
436563// ternaryKey is an array element of the form `cond ? "a" : "b"` — a hide whose
437564// TARGET depends on a condition, rather than the whole call being guarded. Each
438565// branch becomes its own rule carrying that condition (the then-branch when the
0 commit comments