@next-core/brick-utils 2.46.0 → 2.47.0

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.
@@ -17482,7 +17482,7 @@
17482
17482
  // `raw` should always be asserted by `isEvaluable`.
17483
17483
  function preevaluate(raw, options) {
17484
17484
  var fixes = [];
17485
- var source = raw.replace(/^\s*<%~?\s|\s%>\s*$/g, m => {
17485
+ var source = raw.replace(/^\s*<%[~=]?\s|\s%>\s*$/g, m => {
17486
17486
  fixes.push(m);
17487
17487
  return "";
17488
17488
  });
@@ -17499,11 +17499,14 @@
17499
17499
  };
17500
17500
  }
17501
17501
  function isEvaluable(raw) {
17502
- return /^\s*<%~?\s/.test(raw) && /\s%>\s*$/.test(raw);
17502
+ return /^\s*<%[~=]?\s/.test(raw) && /\s%>\s*$/.test(raw);
17503
17503
  }
17504
17504
  function shouldAllowRecursiveEvaluations(raw) {
17505
17505
  return /^\s*<%~\s/.test(raw);
17506
17506
  }
17507
+ function isTrackAll(raw) {
17508
+ return /^\s*<%=\s.*\s%>\s*$/.test(raw);
17509
+ }
17507
17510
 
17508
17511
  // istanbul ignore file
17509
17512
 
@@ -19543,9 +19546,48 @@
19543
19546
  }
19544
19547
  return false;
19545
19548
  }
19549
+ function trackAll(raw) {
19550
+ if (raw) {
19551
+ var usage = {
19552
+ usedContexts: [],
19553
+ includesComputed: false
19554
+ };
19555
+ preevaluate(raw, {
19556
+ withParent: true,
19557
+ hooks: {
19558
+ beforeVisitGlobal: beforeVisitContextFactory(usage, ["CTX", "STATE", "FORM_STATE"], true)
19559
+ }
19560
+ });
19561
+ if (usage.usedContexts.length > 0) {
19562
+ var result = {
19563
+ context: false,
19564
+ state: false,
19565
+ formState: false
19566
+ };
19567
+ var keyMap = {
19568
+ CTX: "context",
19569
+ STATE: "state",
19570
+ FORM_STATE: "formState"
19571
+ };
19572
+ usage.usedContexts.forEach(item => {
19573
+ var [key, name] = item.split(".");
19574
+ if (!result[keyMap[key]]) {
19575
+ result[keyMap[key]] = [];
19576
+ }
19577
+ result[keyMap[key]].push(name);
19578
+ });
19579
+ return result;
19580
+ } else {
19581
+ // eslint-disable-next-line no-console
19582
+ console.warn("You are using track all but no \"CTX\" or \"STATE\" or \"FORM_STATE\" usage found in your expression: ".concat(JSON.stringify(raw)));
19583
+ }
19584
+ }
19585
+ return false;
19586
+ }
19546
19587
  function beforeVisitContextFactory(usage, variableName) {
19588
+ var rememberObjectName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
19547
19589
  return function beforeVisitContext(node, parent) {
19548
- if (node.name === variableName) {
19590
+ if (typeof variableName === "string" ? node.name === variableName : variableName.includes(node.name)) {
19549
19591
  var memberParent = parent[parent.length - 1];
19550
19592
  if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
19551
19593
  var memberNode = memberParent.node;
@@ -19558,7 +19600,7 @@
19558
19600
  usage.includesComputed = true;
19559
19601
  }
19560
19602
  if (used !== undefined && !usage.usedContexts.includes(used)) {
19561
- usage.usedContexts.push(used);
19603
+ usage.usedContexts.push(rememberObjectName ? "".concat(node.name, ".").concat(used) : used);
19562
19604
  }
19563
19605
  }
19564
19606
  }
@@ -20383,6 +20425,7 @@
20383
20425
  exports.isObject = isObject$1;
20384
20426
  exports.isRouteNode = isRouteNode;
20385
20427
  exports.isSnippetNode = isSnippetNode;
20428
+ exports.isTrackAll = isTrackAll;
20386
20429
  exports.lint = lint;
20387
20430
  exports.loadScript = loadScript;
20388
20431
  exports.makeThrottledAggregation = makeThrottledAggregation;
@@ -20426,6 +20469,7 @@
20426
20469
  exports.syncResolveContextConcurrently = syncResolveContextConcurrently;
20427
20470
  exports.toPath = toPath;
20428
20471
  exports.tokTypes = tokTypes_1;
20472
+ exports.trackAll = trackAll;
20429
20473
  exports.trackContext = trackContext;
20430
20474
  exports.trackFormState = trackFormState;
20431
20475
  exports.trackState = trackState;