@next-core/brick-utils 2.31.0 → 2.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.31.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.31.0...@next-core/brick-utils@2.31.1) (2021-11-29)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * refine scanning global usage in expressions and functions ([1808401](https://github.com/easyops-cn/next-core/commit/1808401383ac2c7db8fc2335b4600b00b13c97bf))
12
+
13
+
14
+
15
+
16
+
6
17
  # [2.31.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.30.3...@next-core/brick-utils@2.31.0) (2021-11-26)
7
18
 
8
19
 
@@ -18502,6 +18502,7 @@
18502
18502
  var {
18503
18503
  expressionOnly,
18504
18504
  visitors,
18505
+ withParent,
18505
18506
  hooks = {}
18506
18507
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
18507
18508
  var attemptToVisitGlobals = new Set();
@@ -18522,16 +18523,27 @@
18522
18523
  }
18523
18524
  }
18524
18525
 
18525
- function Evaluate(node) {
18526
+ function EvaluateChildren(node, keys, parent) {
18527
+ for (var key of keys) {
18528
+ Evaluate(node[key], parent === null || parent === void 0 ? void 0 : parent.concat({
18529
+ node,
18530
+ key
18531
+ }));
18532
+ }
18533
+ }
18534
+
18535
+ function Evaluate(node, parent) {
18526
18536
  if (Array.isArray(node)) {
18527
- for (var n of node) {
18528
- Evaluate(n);
18529
- }
18537
+ node.forEach((n, index) => {
18538
+ Evaluate(n, parent ? parent.slice(0, -1).concat(_objectSpread__default["default"](_objectSpread__default["default"]({}, parent[parent.length - 1]), {}, {
18539
+ index
18540
+ })) : parent);
18541
+ });
18530
18542
  } else if (node) {
18531
18543
  var _hooks$beforeVisit, _hooks$beforeVisitUnk; // `node` maybe `null` in some cases.
18532
18544
 
18533
18545
 
18534
- (_hooks$beforeVisit = hooks.beforeVisit) === null || _hooks$beforeVisit === void 0 ? void 0 : _hooks$beforeVisit.call(hooks, node);
18546
+ (_hooks$beforeVisit = hooks.beforeVisit) === null || _hooks$beforeVisit === void 0 ? void 0 : _hooks$beforeVisit.call(hooks, node, parent);
18535
18547
  visitors && visit(node); // Expressions:
18536
18548
 
18537
18549
  switch (node.type) {
@@ -18539,7 +18551,7 @@
18539
18551
  if (!ResolveBinding(node.name)) {
18540
18552
  var _hooks$beforeVisitGlo;
18541
18553
 
18542
- (_hooks$beforeVisitGlo = hooks.beforeVisitGlobal) === null || _hooks$beforeVisitGlo === void 0 ? void 0 : _hooks$beforeVisitGlo.call(hooks, node);
18554
+ (_hooks$beforeVisitGlo = hooks.beforeVisitGlobal) === null || _hooks$beforeVisitGlo === void 0 ? void 0 : _hooks$beforeVisitGlo.call(hooks, node, parent);
18543
18555
  attemptToVisitGlobals.add(node.name);
18544
18556
  }
18545
18557
 
@@ -18547,76 +18559,71 @@
18547
18559
 
18548
18560
  case "ArrayExpression":
18549
18561
  case "ArrayPattern":
18550
- Evaluate(node.elements);
18562
+ EvaluateChildren(node, ["elements"], parent);
18551
18563
  return;
18552
18564
 
18553
18565
  case "ArrowFunctionExpression":
18554
18566
  {
18555
18567
  var env = getRunningContext().LexicalEnvironment;
18556
18568
  var closure = OrdinaryFunctionCreate(node, env);
18557
- CallFunction(closure);
18569
+ CallFunction(closure, parent);
18558
18570
  return;
18559
18571
  }
18560
18572
 
18561
18573
  case "AssignmentPattern":
18562
18574
  case "BinaryExpression":
18563
18575
  case "LogicalExpression":
18564
- Evaluate(node.left);
18565
- Evaluate(node.right);
18576
+ EvaluateChildren(node, ["left", "right"], parent);
18566
18577
  return;
18567
18578
 
18568
18579
  case "CallExpression":
18569
18580
  case "NewExpression":
18570
- Evaluate(node.callee);
18571
- Evaluate(node.arguments);
18581
+ EvaluateChildren(node, ["callee", "arguments"], parent);
18572
18582
  return;
18573
18583
 
18574
18584
  case "ChainExpression":
18575
- Evaluate(node.expression);
18585
+ EvaluateChildren(node, ["expression"], parent);
18576
18586
  return;
18577
18587
 
18578
18588
  case "ConditionalExpression":
18579
- Evaluate(node.test);
18580
- Evaluate(node.consequent);
18581
- Evaluate(node.alternate);
18589
+ EvaluateChildren(node, ["test", "consequent", "alternate"], parent);
18582
18590
  return;
18583
18591
 
18584
18592
  case "MemberExpression":
18585
- Evaluate(node.object);
18593
+ EvaluateChildren(node, ["object"], parent);
18586
18594
 
18587
18595
  if (node.computed) {
18588
- Evaluate(node.property);
18596
+ EvaluateChildren(node, ["property"], parent);
18589
18597
  }
18590
18598
 
18591
18599
  return;
18592
18600
 
18593
18601
  case "ObjectExpression":
18594
18602
  case "ObjectPattern":
18595
- Evaluate(node.properties);
18603
+ EvaluateChildren(node, ["properties"], parent);
18596
18604
  return;
18597
18605
 
18598
18606
  case "Property":
18599
18607
  if (node.computed) {
18600
- Evaluate(node.key);
18608
+ EvaluateChildren(node, ["key"], parent);
18601
18609
  }
18602
18610
 
18603
- Evaluate(node.value);
18611
+ EvaluateChildren(node, ["value"], parent);
18604
18612
  return;
18605
18613
 
18606
18614
  case "RestElement":
18607
18615
  case "SpreadElement":
18608
18616
  case "UnaryExpression":
18609
- Evaluate(node.argument);
18617
+ EvaluateChildren(node, ["argument"], parent);
18610
18618
  return;
18611
18619
 
18612
18620
  case "SequenceExpression":
18613
18621
  case "TemplateLiteral":
18614
- Evaluate(node.expressions);
18622
+ EvaluateChildren(node, ["expressions"], parent);
18615
18623
  return;
18616
18624
 
18617
18625
  case "TaggedTemplateExpression":
18618
- Evaluate(node.tag);
18619
- Evaluate(node.quasi);
18626
+ EvaluateChildren(node, ["tag", "quasi"], parent);
18620
18627
  return;
18621
18628
 
18622
18629
  case "Literal":
@@ -18627,8 +18634,7 @@
18627
18634
  // Statements and assignments:
18628
18635
  switch (node.type) {
18629
18636
  case "AssignmentExpression":
18630
- Evaluate(node.right);
18631
- Evaluate(node.left);
18637
+ EvaluateChildren(node, ["right", "left"], parent);
18632
18638
  return;
18633
18639
 
18634
18640
  case "BlockStatement":
@@ -18642,7 +18648,7 @@
18642
18648
  var blockEnv = new AnalysisEnvironment(oldEnv);
18643
18649
  BlockDeclarationInstantiation(node.body, blockEnv);
18644
18650
  runningContext.LexicalEnvironment = blockEnv;
18645
- Evaluate(node.body);
18651
+ EvaluateChildren(node, ["body"], parent);
18646
18652
  runningContext.LexicalEnvironment = oldEnv;
18647
18653
  return;
18648
18654
  }
@@ -18660,20 +18666,18 @@
18660
18666
  var catchEnv = new AnalysisEnvironment(_oldEnv);
18661
18667
  BoundNamesInstantiation(node.param, catchEnv);
18662
18668
  _runningContext.LexicalEnvironment = catchEnv;
18663
- Evaluate(node.param);
18664
- Evaluate(node.body);
18669
+ EvaluateChildren(node, ["param", "body"], parent);
18665
18670
  _runningContext.LexicalEnvironment = _oldEnv;
18666
18671
  return;
18667
18672
  }
18668
18673
 
18669
18674
  case "DoWhileStatement":
18670
- Evaluate(node.body);
18671
- Evaluate(node.test);
18675
+ EvaluateChildren(node, ["body", "test"], parent);
18672
18676
  return;
18673
18677
 
18674
18678
  case "ExpressionStatement":
18675
18679
  case "TSAsExpression":
18676
- Evaluate(node.expression);
18680
+ EvaluateChildren(node, ["expression"], parent);
18677
18681
  return;
18678
18682
 
18679
18683
  case "ForInStatement":
@@ -18692,7 +18696,7 @@
18692
18696
  _runningContext2.LexicalEnvironment = newEnv;
18693
18697
  }
18694
18698
 
18695
- Evaluate(node.right);
18699
+ EvaluateChildren(node, ["right"], parent);
18696
18700
  _runningContext2.LexicalEnvironment = _oldEnv2; // ForIn/OfBodyEvaluation
18697
18701
 
18698
18702
  if (lexicalBinding) {
@@ -18701,8 +18705,7 @@
18701
18705
  _runningContext2.LexicalEnvironment = iterationEnv;
18702
18706
  }
18703
18707
 
18704
- Evaluate(node.left);
18705
- Evaluate(node.body);
18708
+ EvaluateChildren(node, ["left", "body"], parent);
18706
18709
  _runningContext2.LexicalEnvironment = _oldEnv2;
18707
18710
  return;
18708
18711
  }
@@ -18723,10 +18726,7 @@
18723
18726
  _runningContext3.LexicalEnvironment = loopEnv;
18724
18727
  }
18725
18728
 
18726
- Evaluate(node.init);
18727
- Evaluate(node.test);
18728
- Evaluate(node.body);
18729
- Evaluate(node.update);
18729
+ EvaluateChildren(node, ["init", "test", "body", "update"], parent);
18730
18730
  _runningContext3.LexicalEnvironment = _oldEnv3;
18731
18731
  return;
18732
18732
  }
@@ -18739,7 +18739,7 @@
18739
18739
 
18740
18740
  _env.CreateBinding(fn);
18741
18741
 
18742
- CallFunction(fo);
18742
+ CallFunction(fo, parent);
18743
18743
  return;
18744
18744
  }
18745
18745
 
@@ -18747,30 +18747,27 @@
18747
18747
  {
18748
18748
  var _closure = InstantiateOrdinaryFunctionExpression(node);
18749
18749
 
18750
- CallFunction(_closure);
18750
+ CallFunction(_closure, parent);
18751
18751
  return;
18752
18752
  }
18753
18753
 
18754
18754
  case "IfStatement":
18755
- Evaluate(node.test);
18756
- Evaluate(node.consequent);
18757
- Evaluate(node.alternate);
18755
+ EvaluateChildren(node, ["test", "consequent", "alternate"], parent);
18758
18756
  return;
18759
18757
 
18760
18758
  case "ReturnStatement":
18761
18759
  case "ThrowStatement":
18762
18760
  case "UpdateExpression":
18763
- Evaluate(node.argument);
18761
+ EvaluateChildren(node, ["argument"], parent);
18764
18762
  return;
18765
18763
 
18766
18764
  case "SwitchCase":
18767
- Evaluate(node.test);
18768
- Evaluate(node.consequent);
18765
+ EvaluateChildren(node, ["test", "consequent"], parent);
18769
18766
  return;
18770
18767
 
18771
18768
  case "SwitchStatement":
18772
18769
  {
18773
- Evaluate(node.discriminant);
18770
+ EvaluateChildren(node, ["discriminant"], parent);
18774
18771
 
18775
18772
  var _runningContext4 = getRunningContext();
18776
18773
 
@@ -18780,34 +18777,30 @@
18780
18777
 
18781
18778
  BlockDeclarationInstantiation(node.cases, _blockEnv);
18782
18779
  _runningContext4.LexicalEnvironment = _blockEnv;
18783
- Evaluate(node.cases);
18780
+ EvaluateChildren(node, ["cases"], parent);
18784
18781
  _runningContext4.LexicalEnvironment = _oldEnv4;
18785
18782
  return;
18786
18783
  }
18787
18784
 
18788
18785
  case "TryStatement":
18789
- Evaluate(node.block);
18790
- Evaluate(node.handler);
18791
- Evaluate(node.finalizer);
18786
+ EvaluateChildren(node, ["block", "handler", "finalizer"], parent);
18792
18787
  return;
18793
18788
 
18794
18789
  case "VariableDeclaration":
18795
- Evaluate(node.declarations);
18790
+ EvaluateChildren(node, ["declarations"], parent);
18796
18791
  return;
18797
18792
 
18798
18793
  case "VariableDeclarator":
18799
- Evaluate(node.id);
18800
- Evaluate(node.init);
18794
+ EvaluateChildren(node, ["id", "init"], parent);
18801
18795
  return;
18802
18796
 
18803
18797
  case "WhileStatement":
18804
- Evaluate(node.test);
18805
- Evaluate(node.body);
18798
+ EvaluateChildren(node, ["test", "body"], parent);
18806
18799
  return;
18807
18800
  }
18808
18801
  }
18809
18802
 
18810
- var silent = (_hooks$beforeVisitUnk = hooks.beforeVisitUnknown) === null || _hooks$beforeVisitUnk === void 0 ? void 0 : _hooks$beforeVisitUnk.call(hooks, node);
18803
+ var silent = (_hooks$beforeVisitUnk = hooks.beforeVisitUnknown) === null || _hooks$beforeVisitUnk === void 0 ? void 0 : _hooks$beforeVisitUnk.call(hooks, node, parent);
18811
18804
 
18812
18805
  if (!silent) {
18813
18806
  // eslint-disable-next-line no-console
@@ -18839,10 +18832,16 @@
18839
18832
  BoundNamesInstantiation(declarations, env);
18840
18833
  }
18841
18834
 
18842
- function CallFunction(closure) {
18835
+ function CallFunction(closure, parent) {
18843
18836
  PrepareOrdinaryCall(closure);
18844
- FunctionDeclarationInstantiation(closure);
18845
- Evaluate(closure.ECMAScriptCode);
18837
+ FunctionDeclarationInstantiation(closure, parent);
18838
+ Evaluate(closure.ECMAScriptCode, parent === null || parent === void 0 ? void 0 : parent.concat({
18839
+ node: closure.Function,
18840
+ key: "body"
18841
+ }).concat(closure.Function.body.type === "BlockStatement" ? {
18842
+ node: closure.Function.body,
18843
+ key: "body"
18844
+ } : []));
18846
18845
  analysisContextStack.pop();
18847
18846
  }
18848
18847
 
@@ -18854,7 +18853,7 @@
18854
18853
  analysisContextStack.push(calleeContext);
18855
18854
  }
18856
18855
 
18857
- function FunctionDeclarationInstantiation(func) {
18856
+ function FunctionDeclarationInstantiation(func, parent) {
18858
18857
  var calleeContext = getRunningContext();
18859
18858
  var code = func.ECMAScriptCode;
18860
18859
  var formals = func.FormalParameters;
@@ -18866,7 +18865,10 @@
18866
18865
  var varNames = collectBoundNames(varDeclarations);
18867
18866
  var env = calleeContext.LexicalEnvironment;
18868
18867
  BoundNamesInstantiation(formals, env);
18869
- Evaluate(formals);
18868
+ Evaluate(formals, parent === null || parent === void 0 ? void 0 : parent.concat({
18869
+ node: func.Function,
18870
+ key: "params"
18871
+ }));
18870
18872
  var varEnv;
18871
18873
 
18872
18874
  if (!hasParameterExpressions) {
@@ -18911,19 +18913,16 @@
18911
18913
  return OrdinaryFunctionCreate(functionExpression, funcEnv);
18912
18914
  }
18913
18915
 
18914
- function OrdinaryFunctionCreate(_ref, scope) {
18915
- var {
18916
- params,
18917
- body
18918
- } = _ref;
18916
+ function OrdinaryFunctionCreate(func, scope) {
18919
18917
  return {
18920
- FormalParameters: params,
18921
- ECMAScriptCode: body.type === "BlockStatement" ? body.body : body,
18918
+ Function: func,
18919
+ FormalParameters: func.params,
18920
+ ECMAScriptCode: func.body.type === "BlockStatement" ? func.body.body : func.body,
18922
18921
  Environment: scope
18923
18922
  };
18924
18923
  }
18925
18924
 
18926
- Evaluate(rootAst);
18925
+ Evaluate(rootAst, withParent ? [] : undefined);
18927
18926
  return attemptToVisitGlobals;
18928
18927
  }
18929
18928
 
@@ -19183,12 +19182,16 @@
19183
19182
  if (typeof data === "string") {
19184
19183
  if (data.includes(PROCESSORS) && isEvaluable(data)) {
19185
19184
  preevaluate(data, {
19186
- visitors: {
19187
- MemberExpression(node) {
19188
- var accessNamespace = node.object;
19185
+ withParent: true,
19186
+ hooks: {
19187
+ beforeVisitGlobal(node, parent) {
19188
+ if (node.name === PROCESSORS) {
19189
+ var memberParent = parent[parent.length - 1];
19190
+ var outerMemberParent = parent[parent.length - 2];
19189
19191
 
19190
- if (!node.computed && node.property.type === "Identifier" && accessNamespace.type === "MemberExpression" && !accessNamespace.computed && accessNamespace.object.type === "Identifier" && accessNamespace.object.name === PROCESSORS && accessNamespace.property.type === "Identifier") {
19191
- collection.push("".concat(accessNamespace.property.name, ".").concat(node.property.name));
19192
+ if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object" && !memberParent.node.computed && memberParent.node.property.type === "Identifier" && (outerMemberParent === null || outerMemberParent === void 0 ? void 0 : outerMemberParent.node.type) === "MemberExpression" && outerMemberParent.key === "object" && !outerMemberParent.node.computed && outerMemberParent.node.property.type === "Identifier") {
19193
+ collection.push("".concat(memberParent.node.property.name, ".").concat(outerMemberParent.node.property.name));
19194
+ }
19192
19195
  }
19193
19196
  }
19194
19197
 
@@ -19979,12 +19982,18 @@
19979
19982
  if (typeof data === "string") {
19980
19983
  if (data.includes(PERMISSIONS) && isEvaluable(data)) {
19981
19984
  preevaluate(data, {
19982
- visitors: {
19983
- CallExpression(node) {
19984
- if (node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier" && node.callee.object.name === PERMISSIONS && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === check) {
19985
- for (var arg of node.arguments) {
19986
- if (arg.type === "Literal" && typeof arg.value === "string") {
19987
- collection.add(arg.value);
19985
+ withParent: true,
19986
+ hooks: {
19987
+ beforeVisitGlobal(node, parent) {
19988
+ if (node.name === PERMISSIONS) {
19989
+ var memberParent = parent[parent.length - 1];
19990
+ var callParent = parent[parent.length - 2];
19991
+
19992
+ if ((callParent === null || callParent === void 0 ? void 0 : callParent.node.type) === "CallExpression" && (callParent === null || callParent === void 0 ? void 0 : callParent.key) === "callee" && (memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object" && !memberParent.node.computed && memberParent.node.property.type === "Identifier" && memberParent.node.property.name === check) {
19993
+ for (var arg of callParent.node.arguments) {
19994
+ if (arg.type === "Literal" && typeof arg.value === "string") {
19995
+ collection.add(arg.value);
19996
+ }
19988
19997
  }
19989
19998
  }
19990
19999
  }
@@ -20070,21 +20079,22 @@
20070
20079
  var _storyboard$meta;
20071
20080
 
20072
20081
  var collection = new Map();
20073
- var beforeVisit = beforeVisitFactory(collection); // Notice: `menus` may contain evaluations of I18N too.
20082
+ var beforeVisitGlobal = beforeVisitGlobalFactory(collection); // Notice: `menus` may contain evaluations of I18N too.
20074
20083
 
20075
20084
  var {
20076
20085
  customTemplates,
20077
20086
  menus,
20078
20087
  functions
20079
20088
  } = (_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 ? _storyboard$meta : {};
20080
- collectI18N([storyboard.routes, customTemplates, menus], beforeVisit);
20089
+ collectI18N([storyboard.routes, customTemplates, menus], beforeVisitGlobal);
20081
20090
 
20082
20091
  if (Array.isArray(functions)) {
20083
20092
  for (var fn of functions) {
20084
20093
  precookFunction(fn.source, {
20085
20094
  typescript: fn.typescript,
20095
+ withParent: true,
20086
20096
  hooks: {
20087
- beforeVisit
20097
+ beforeVisitGlobal
20088
20098
  }
20089
20099
  });
20090
20100
  }
@@ -20094,18 +20104,19 @@
20094
20104
  }
20095
20105
  function scanI18NInAny(data) {
20096
20106
  var collection = new Map();
20097
- collectI18N(data, beforeVisitFactory(collection));
20107
+ collectI18N(data, beforeVisitGlobalFactory(collection));
20098
20108
  return collection;
20099
20109
  }
20100
20110
 
20101
- function collectI18N(data, beforeVisit) {
20111
+ function collectI18N(data, beforeVisitGlobal) {
20102
20112
  var memo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new WeakSet();
20103
20113
 
20104
20114
  if (typeof data === "string") {
20105
20115
  if (data.includes(I18N) && isEvaluable(data)) {
20106
20116
  preevaluate(data, {
20117
+ withParent: true,
20107
20118
  hooks: {
20108
- beforeVisit
20119
+ beforeVisitGlobal
20109
20120
  }
20110
20121
  });
20111
20122
  }
@@ -20119,31 +20130,35 @@
20119
20130
 
20120
20131
  if (Array.isArray(data)) {
20121
20132
  for (var item of data) {
20122
- collectI18N(item, beforeVisit, memo);
20133
+ collectI18N(item, beforeVisitGlobal, memo);
20123
20134
  }
20124
20135
  } else {
20125
20136
  for (var _item of Object.values(data)) {
20126
- collectI18N(_item, beforeVisit, memo);
20137
+ collectI18N(_item, beforeVisitGlobal, memo);
20127
20138
  }
20128
20139
  }
20129
20140
  }
20130
20141
  }
20131
20142
 
20132
- function beforeVisitFactory(collection) {
20133
- return function beforeVisit(node) {
20134
- if (node.type === "CallExpression") {
20135
- var [keyNode, defaultNode] = node.arguments;
20143
+ function beforeVisitGlobalFactory(collection) {
20144
+ return function beforeVisitGlobal(node, parent) {
20145
+ if (node.name === I18N) {
20146
+ var callParent = parent[parent.length - 1];
20136
20147
 
20137
- if (node.callee.type === "Identifier" && node.callee.name === I18N && keyNode && keyNode.type === "Literal" && typeof keyNode.value === "string") {
20138
- var valueSet = collection.get(keyNode.value);
20148
+ if ((callParent === null || callParent === void 0 ? void 0 : callParent.node.type) === "CallExpression" && callParent.key === "callee") {
20149
+ var [keyNode, defaultNode] = callParent.node.arguments;
20139
20150
 
20140
- if (!valueSet) {
20141
- valueSet = new Set();
20142
- collection.set(keyNode.value, valueSet);
20143
- }
20151
+ if (keyNode && keyNode.type === "Literal" && typeof keyNode.value === "string") {
20152
+ var valueSet = collection.get(keyNode.value);
20153
+
20154
+ if (!valueSet) {
20155
+ valueSet = new Set();
20156
+ collection.set(keyNode.value, valueSet);
20157
+ }
20144
20158
 
20145
- if (defaultNode && defaultNode.type === "Literal" && typeof defaultNode.value === "string") {
20146
- valueSet.add(defaultNode.value);
20159
+ if (defaultNode && defaultNode.type === "Literal" && typeof defaultNode.value === "string") {
20160
+ valueSet.add(defaultNode.value);
20161
+ }
20147
20162
  }
20148
20163
  }
20149
20164
  }
@@ -20820,23 +20835,35 @@
20820
20835
 
20821
20836
  return depsMap;
20822
20837
  }
20823
- var CTX = "CTX";
20838
+ var CTX$1 = "CTX";
20824
20839
 
20825
20840
  function collectContexts(data, stats) {
20826
20841
  var memo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new WeakSet();
20827
20842
 
20828
20843
  if (typeof data === "string") {
20829
- if (data.includes(CTX) && isEvaluable(data)) {
20844
+ if (data.includes(CTX$1) && isEvaluable(data)) {
20830
20845
  preevaluate(data, {
20831
- visitors: {
20832
- MemberExpression(node) {
20833
- if (node.object.type === "Identifier" && node.object.name === CTX) {
20834
- if (!node.computed && node.property.type === "Identifier") {
20835
- if (!stats.dependencies.includes(node.property.name)) {
20836
- stats.dependencies.push(node.property.name);
20846
+ withParent: true,
20847
+ hooks: {
20848
+ beforeVisitGlobal(node, parent) {
20849
+ if (node.name === CTX$1) {
20850
+ var memberParent = parent[parent.length - 1];
20851
+
20852
+ if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
20853
+ var memberNode = memberParent.node;
20854
+ var dep;
20855
+
20856
+ if (!memberNode.computed && memberNode.property.type === "Identifier") {
20857
+ dep = memberNode.property.name;
20858
+ } else if (memberNode.computed && memberNode.property.type === "Literal" && typeof memberNode.property.value === "string") {
20859
+ dep = memberNode.property.value;
20860
+ } else {
20861
+ stats.includesComputed = true;
20862
+ }
20863
+
20864
+ if (dep !== undefined && !stats.dependencies.includes(dep)) {
20865
+ stats.dependencies.push(dep);
20837
20866
  }
20838
- } else {
20839
- stats.includesComputed = true;
20840
20867
  }
20841
20868
  }
20842
20869
  }
@@ -21134,6 +21161,7 @@
21134
21161
  }
21135
21162
 
21136
21163
  var TRACK_CONTEXT = "track context";
21164
+ var CTX = "CTX";
21137
21165
  /**
21138
21166
  * Get tracking CTX for an evaluable expression in `track context` mode.
21139
21167
  *
@@ -21167,13 +21195,20 @@
21167
21195
  var {
21168
21196
  expression
21169
21197
  } = preevaluate(raw, {
21170
- visitors: {
21171
- MemberExpression(node) {
21172
- if (node.object.type === "Identifier" && node.object.name === "CTX") {
21173
- if (!node.computed && node.property.type === "Identifier") {
21174
- contexts.add(node.property.name);
21175
- } else if (node.computed && node.property.type === "Literal" && typeof node.property.value === "string") {
21176
- contexts.add(node.property.value);
21198
+ withParent: true,
21199
+ hooks: {
21200
+ beforeVisitGlobal(node, parent) {
21201
+ if (node.name === CTX) {
21202
+ var memberParent = parent[parent.length - 1];
21203
+
21204
+ if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
21205
+ var memberNode = memberParent.node;
21206
+
21207
+ if (!memberNode.computed && memberNode.property.type === "Identifier") {
21208
+ contexts.add(memberNode.property.name);
21209
+ } else if (memberNode.computed && memberNode.property.type === "Literal" && typeof memberNode.property.value === "string") {
21210
+ contexts.add(memberNode.property.value);
21211
+ }
21177
21212
  }
21178
21213
  }
21179
21214
  }