@next-core/brick-utils 2.52.2 → 2.52.3

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.
@@ -2130,8 +2130,8 @@
2130
2130
  }
2131
2131
 
2132
2132
  // https://tc39.es/ecma262/#sec-runtime-semantics-instantiatefunctionobject
2133
- function InstantiateFunctionObject(func, scope) {
2134
- return OrdinaryFunctionCreate(func, scope, true);
2133
+ function InstantiateFunctionObject(func, scope, isRoot) {
2134
+ return OrdinaryFunctionCreate(func, scope, true, isRoot);
2135
2135
  }
2136
2136
 
2137
2137
  // https://tc39.es/ecma262/#sec-runtime-semantics-instantiateordinaryfunctionexpression
@@ -2158,10 +2158,19 @@
2158
2158
  }
2159
2159
 
2160
2160
  // https://tc39.es/ecma262/#sec-ordinaryfunctioncreate
2161
- function OrdinaryFunctionCreate(sourceNode, scope, isConstructor) {
2161
+ function OrdinaryFunctionCreate(sourceNode, scope, isConstructor, isRoot) {
2162
2162
  var F = function () {
2163
+ var perf = isRoot && hooks.perfCall;
2164
+ var start;
2165
+ if (perf) {
2166
+ start = performance.now();
2167
+ }
2163
2168
  // eslint-disable-next-line prefer-rest-params
2164
- return CallFunction(F, arguments);
2169
+ var result = CallFunction(F, arguments);
2170
+ if (perf) {
2171
+ perf(performance.now() - start);
2172
+ }
2173
+ return result;
2165
2174
  };
2166
2175
  Object.defineProperties(F, {
2167
2176
  [SourceNode]: {
@@ -2377,7 +2386,7 @@
2377
2386
  var [fn] = collectBoundNames(rootAst);
2378
2387
  // Create an immutable binding for the root function.
2379
2388
  rootEnv.CreateImmutableBinding(fn, true);
2380
- var fo = InstantiateFunctionObject(rootAst, rootEnv);
2389
+ var fo = InstantiateFunctionObject(rootAst, rootEnv, true);
2381
2390
  rootEnv.InitializeBinding(fn, fo);
2382
2391
  return fo;
2383
2392
  }
@@ -17538,9 +17547,12 @@
17538
17547
  return value != null && (type == "object" || type == "function");
17539
17548
  }
17540
17549
 
17541
- function visitStoryboardFunctions(functions, beforeVisitGlobal) {
17550
+ function visitStoryboardFunctions(functions, beforeVisitGlobal, options) {
17542
17551
  if (Array.isArray(functions)) {
17543
17552
  for (var fn of functions) {
17553
+ if (options !== null && options !== void 0 && options.matchSource && !options.matchSource(fn.source)) {
17554
+ continue;
17555
+ }
17544
17556
  try {
17545
17557
  precookFunction(fn.source, {
17546
17558
  typescript: fn.typescript,
@@ -18934,7 +18946,9 @@
18934
18946
  functions
18935
18947
  } = (_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 ? _storyboard$meta : {};
18936
18948
  visitStoryboardExpressions([storyboard.routes, customTemplates], beforeVisitPermissions, PERMISSIONS);
18937
- visitStoryboardFunctions(functions, beforeVisitPermissions);
18949
+ visitStoryboardFunctions(functions, beforeVisitPermissions, {
18950
+ matchSource: source => source.includes(PERMISSIONS)
18951
+ });
18938
18952
  return Array.from(collection);
18939
18953
  }
18940
18954
  function scanPermissionActionsInAny(data) {
@@ -19023,30 +19037,36 @@
19023
19037
  }
19024
19038
 
19025
19039
  var APP = "APP";
19026
- var GET_MENUS = "getMenu";
19040
+ var GET_MENU = "getMenu";
19027
19041
  function scanAppGetMenuInStoryboard(storyboard) {
19028
19042
  var _storyboard$meta;
19029
19043
  var collection = new Set();
19030
- var beforeVisitPermissions = beforeVisitAppFactory(collection);
19044
+ var beforeVisitApp = beforeVisitAppFactory(collection);
19031
19045
  var {
19032
- customTemplates,
19033
- functions
19046
+ customTemplates
19034
19047
  } = (_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 ? _storyboard$meta : {};
19035
- visitStoryboardExpressions([storyboard.routes, customTemplates], beforeVisitPermissions, APP);
19036
- visitStoryboardFunctions(functions, beforeVisitPermissions);
19048
+ visitStoryboardExpressions([storyboard.routes, customTemplates], beforeVisitApp, {
19049
+ matchExpressionString: matchAppGetMenu
19050
+ });
19051
+ // `APP` is not available in storyboard functions
19037
19052
  return Array.from(collection);
19038
19053
  }
19039
19054
  function scanAppGetMenuInAny(data) {
19040
19055
  var collection = new Set();
19041
- visitStoryboardExpressions(data, beforeVisitAppFactory(collection), APP);
19056
+ visitStoryboardExpressions(data, beforeVisitAppFactory(collection), {
19057
+ matchExpressionString: matchAppGetMenu
19058
+ });
19042
19059
  return Array.from(collection);
19043
19060
  }
19061
+ function matchAppGetMenu(source) {
19062
+ return source.includes(APP) && source.includes(GET_MENU);
19063
+ }
19044
19064
  function beforeVisitAppFactory(collection) {
19045
19065
  return function beforeVisitAPP(node, parent) {
19046
19066
  if (node.name === APP) {
19047
19067
  var memberParent = parent[parent.length - 1];
19048
19068
  var callParent = parent[parent.length - 2];
19049
- 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 === GET_MENUS) {
19069
+ 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 === GET_MENU) {
19050
19070
  if (callParent.node.arguments.length === 1) {
19051
19071
  var menuId = callParent.node.arguments[0];
19052
19072
  if (menuId.type === "Literal" && typeof menuId.value === "string") {
@@ -19554,6 +19574,8 @@
19554
19574
  convertUnitValueByPrecision: convertValueByPrecision
19555
19575
  } = pipes.utils;
19556
19576
 
19577
+ var TRACK_NAMES = ["CTX", "STATE", "FORM_STATE"];
19578
+
19557
19579
  /**
19558
19580
  * Get tracking CTX for an evaluable expression in `track context` mode.
19559
19581
  *
@@ -19627,7 +19649,8 @@
19627
19649
  return false;
19628
19650
  }
19629
19651
  function trackAll(raw) {
19630
- if (raw) {
19652
+ // Do not pre-evaluate a string if it doesn't include track names.
19653
+ if (TRACK_NAMES.some(name => raw.includes(name))) {
19631
19654
  var usage = {
19632
19655
  usedContexts: [],
19633
19656
  includesComputed: false
@@ -19635,7 +19658,7 @@
19635
19658
  preevaluate(raw, {
19636
19659
  withParent: true,
19637
19660
  hooks: {
19638
- beforeVisitGlobal: beforeVisitContextFactory(usage, ["CTX", "STATE", "FORM_STATE"], true)
19661
+ beforeVisitGlobal: beforeVisitContextFactory(usage, TRACK_NAMES, true)
19639
19662
  }
19640
19663
  });
19641
19664
  if (usage.usedContexts.length > 0) {
@@ -20208,11 +20231,10 @@
20208
20231
  var beforeVisitInstalledApps = beforeVisitInstalledAppsFactory(collection);
20209
20232
  var {
20210
20233
  customTemplates,
20211
- functions,
20212
20234
  menus
20213
20235
  } = (_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 ? _storyboard$meta : {};
20214
20236
  visitStoryboardExpressions([storyboard.routes, customTemplates, menus], beforeVisitInstalledApps, INSTALLED_APPS);
20215
- visitStoryboardFunctions(functions, beforeVisitInstalledApps);
20237
+ // `INSTALLED_APPS` is not available in storyboard functions
20216
20238
  return Array.from(collection);
20217
20239
  }
20218
20240
  function beforeVisitInstalledAppsFactory(collection) {