@next-core/brick-utils 2.45.22 → 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.
package/dist/index.esm.js CHANGED
@@ -17477,7 +17477,7 @@ function precookFunction(source) {
17477
17477
  // `raw` should always be asserted by `isEvaluable`.
17478
17478
  function preevaluate(raw, options) {
17479
17479
  var fixes = [];
17480
- var source = raw.replace(/^\s*<%~?\s|\s%>\s*$/g, m => {
17480
+ var source = raw.replace(/^\s*<%[~=]?\s|\s%>\s*$/g, m => {
17481
17481
  fixes.push(m);
17482
17482
  return "";
17483
17483
  });
@@ -17494,11 +17494,14 @@ function preevaluate(raw, options) {
17494
17494
  };
17495
17495
  }
17496
17496
  function isEvaluable(raw) {
17497
- return /^\s*<%~?\s/.test(raw) && /\s%>\s*$/.test(raw);
17497
+ return /^\s*<%[~=]?\s/.test(raw) && /\s%>\s*$/.test(raw);
17498
17498
  }
17499
17499
  function shouldAllowRecursiveEvaluations(raw) {
17500
17500
  return /^\s*<%~\s/.test(raw);
17501
17501
  }
17502
+ function isTrackAll(raw) {
17503
+ return /^\s*<%=\s.*\s%>\s*$/.test(raw);
17504
+ }
17502
17505
 
17503
17506
  // istanbul ignore file
17504
17507
 
@@ -18220,25 +18223,30 @@ function getDllAndDepsByResource(_ref, brickPackages) {
18220
18223
  } = _ref;
18221
18224
  var dll = new Set();
18222
18225
  var deps = new Set();
18226
+ var v3Bricks = new Set();
18227
+ var v3Processors = new Set();
18223
18228
  if ((bricks === null || bricks === void 0 ? void 0 : bricks.length) > 0 || (processors === null || processors === void 0 ? void 0 : processors.length) > 0 || (editorBricks === null || editorBricks === void 0 ? void 0 : editorBricks.length) > 0) {
18224
18229
  var brickMap = getBrickToPackageMap(brickPackages);
18225
- [...(bricks !== null && bricks !== void 0 ? bricks : []), ...(processors !== null && processors !== void 0 ? processors : [])].forEach(name => {
18230
+ [...(bricks !== null && bricks !== void 0 ? bricks : []).map(n => [n]), ...(processors !== null && processors !== void 0 ? processors : []).map(n => [n, true])].forEach(_ref2 => {
18231
+ var [name, isProcessor] = _ref2;
18226
18232
  // ignore custom template
18227
18233
  // istanbul ignore else
18228
18234
  if (name.includes(".")) {
18229
18235
  var namespace = name.split(".")[0];
18230
- var isProcessor = processors === null || processors === void 0 ? void 0 : processors.includes(name);
18231
-
18232
18236
  // processor 是 camelCase 格式,转成 brick 的 param-case 格式,统一去判断
18233
18237
  if (isProcessor) {
18234
18238
  namespace = paramCase(namespace);
18235
18239
  }
18236
18240
  var find = brickMap.get(namespace);
18237
18241
  if (find) {
18238
- deps.add(find.filePath);
18239
- if (find.dll) {
18240
- for (var dllName of find.dll) {
18241
- dll.add(dllName);
18242
+ if (find.id) {
18243
+ (isProcessor ? v3Processors : v3Bricks).add(name);
18244
+ } else {
18245
+ deps.add(find.filePath);
18246
+ if (find.dll) {
18247
+ for (var dllName of find.dll) {
18248
+ dll.add(dllName);
18249
+ }
18242
18250
  }
18243
18251
  }
18244
18252
  } else {
@@ -18269,7 +18277,9 @@ function getDllAndDepsByResource(_ref, brickPackages) {
18269
18277
  var dllPath = window.DLL_PATH;
18270
18278
  return {
18271
18279
  dll: Array.from(dll).map(dllName => dllPath[dllName]),
18272
- deps: Array.from(deps)
18280
+ deps: Array.from(deps),
18281
+ v3Bricks: Array.from(v3Bricks),
18282
+ v3Processors: Array.from(v3Processors)
18273
18283
  };
18274
18284
  }
18275
18285
 
@@ -19531,9 +19541,48 @@ function track(raw, trackText, variableName) {
19531
19541
  }
19532
19542
  return false;
19533
19543
  }
19544
+ function trackAll(raw) {
19545
+ if (raw) {
19546
+ var usage = {
19547
+ usedContexts: [],
19548
+ includesComputed: false
19549
+ };
19550
+ preevaluate(raw, {
19551
+ withParent: true,
19552
+ hooks: {
19553
+ beforeVisitGlobal: beforeVisitContextFactory(usage, ["CTX", "STATE", "FORM_STATE"], true)
19554
+ }
19555
+ });
19556
+ if (usage.usedContexts.length > 0) {
19557
+ var result = {
19558
+ context: false,
19559
+ state: false,
19560
+ formState: false
19561
+ };
19562
+ var keyMap = {
19563
+ CTX: "context",
19564
+ STATE: "state",
19565
+ FORM_STATE: "formState"
19566
+ };
19567
+ usage.usedContexts.forEach(item => {
19568
+ var [key, name] = item.split(".");
19569
+ if (!result[keyMap[key]]) {
19570
+ result[keyMap[key]] = [];
19571
+ }
19572
+ result[keyMap[key]].push(name);
19573
+ });
19574
+ return result;
19575
+ } else {
19576
+ // eslint-disable-next-line no-console
19577
+ console.warn("You are using track all but no \"CTX\" or \"STATE\" or \"FORM_STATE\" usage found in your expression: ".concat(JSON.stringify(raw)));
19578
+ }
19579
+ }
19580
+ return false;
19581
+ }
19534
19582
  function beforeVisitContextFactory(usage, variableName) {
19583
+ var rememberObjectName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
19535
19584
  return function beforeVisitContext(node, parent) {
19536
- if (node.name === variableName) {
19585
+ if (typeof variableName === "string" ? node.name === variableName : variableName.includes(node.name)) {
19537
19586
  var memberParent = parent[parent.length - 1];
19538
19587
  if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
19539
19588
  var memberNode = memberParent.node;
@@ -19546,7 +19595,7 @@ function beforeVisitContextFactory(usage, variableName) {
19546
19595
  usage.includesComputed = true;
19547
19596
  }
19548
19597
  if (used !== undefined && !usage.usedContexts.includes(used)) {
19549
- usage.usedContexts.push(used);
19598
+ usage.usedContexts.push(rememberObjectName ? "".concat(node.name, ".").concat(used) : used);
19550
19599
  }
19551
19600
  }
19552
19601
  }
@@ -20337,5 +20386,5 @@ function isConstantLogical(node, expect, options) {
20337
20386
  return node.type === "LogicalExpression" ? node.operator === (expect ? "||" : "&&") && [node.left, node.right].some(item => isConstantLogical(item, expect, options)) : node.type === "UnaryExpression" ? node.operator === "!" && isConstantLogical(node.argument, !expect, options) : node.type === "Literal" ? !!node.value === expect : node.type === "Identifier" ? node.name === "undefined" ? !expect : false : constantFeatureFlags && node.type === "MemberExpression" && node.object.type === "Identifier" && node.object.name === "FLAGS" && (node.computed ? node.property.type === "Literal" && typeof node.property.value === "string" && !!featureFlags[node.property.value] === expect : node.property.type === "Identifier" && !!featureFlags[node.property.name] === expect);
20338
20387
  }
20339
20388
 
20340
- export { JsonStorage, PrecookFunctionVisitor, PrecookVisitor, asyncProcessBrick, asyncProcessStoryboard, collectBricksByCustomTemplates, collectContextUsage, computeConstantCondition, computeRealRoutePath, convertValueByPrecision, cook, createProviderClass, debounceByAnimationFrame, deepFreeze, deferResolveContextConcurrently, formatValue, getDependencyMapOfContext, getDepsOfTemplates, getDllAndDepsByResource, getDllAndDepsOfBricks, getDllAndDepsOfStoryboard, getTemplateDepsOfStoryboard, hasOwnProperty$1 as hasOwnProperty, inject, isBrickNode, isCustomTemplateNode, isEvaluable, isObject$1 as isObject, isRouteNode, isSnippetNode, lint, loadScript, makeThrottledAggregation, mapCustomApisToNameAndNamespace, matchPath, normalizeBuilderNode, normalizeMenu, parseBrick, parseForAnalysis, parseRoutes, parseStoryboard, parseTemplate, parseTemplates, precook, precookFunction, preevaluate, prefetchScript, removeDeadConditions, removeDeadConditionsInTpl, resolveContextConcurrently, restoreDynamicTemplates, scanAppGetMenuInAny, scanAppGetMenuInStoryboard, scanBricksInBrickConf, scanBricksInStoryboard, scanCustomApisInStoryboard, scanI18NInAny, scanI18NInStoryboard, scanInstalledAppsInStoryboard, scanPermissionActionsInAny, scanPermissionActionsInStoryboard, scanProcessorsInAny, scanProcessorsInStoryboard, scanRouteAliasInStoryboard, scanStoryboard, scanStoryboardAst, scanTemplatesInBrick, scanTemplatesInStoryboard, shouldAllowRecursiveEvaluations, smartDisplayForEvaluableString, syncResolveContextConcurrently, toPath, tokTypes_1 as tokTypes, trackContext, trackFormState, trackState, trackUsedContext, trackUsedFormState, trackUsedState, transform, transformAndInject, traverse, traverseStoryboard, visitStoryboardExpressions, visitStoryboardFunctions };
20389
+ export { JsonStorage, PrecookFunctionVisitor, PrecookVisitor, asyncProcessBrick, asyncProcessStoryboard, collectBricksByCustomTemplates, collectContextUsage, computeConstantCondition, computeRealRoutePath, convertValueByPrecision, cook, createProviderClass, debounceByAnimationFrame, deepFreeze, deferResolveContextConcurrently, formatValue, getDependencyMapOfContext, getDepsOfTemplates, getDllAndDepsByResource, getDllAndDepsOfBricks, getDllAndDepsOfStoryboard, getTemplateDepsOfStoryboard, hasOwnProperty$1 as hasOwnProperty, inject, isBrickNode, isCustomTemplateNode, isEvaluable, isObject$1 as isObject, isRouteNode, isSnippetNode, isTrackAll, lint, loadScript, makeThrottledAggregation, mapCustomApisToNameAndNamespace, matchPath, normalizeBuilderNode, normalizeMenu, parseBrick, parseForAnalysis, parseRoutes, parseStoryboard, parseTemplate, parseTemplates, precook, precookFunction, preevaluate, prefetchScript, removeDeadConditions, removeDeadConditionsInTpl, resolveContextConcurrently, restoreDynamicTemplates, scanAppGetMenuInAny, scanAppGetMenuInStoryboard, scanBricksInBrickConf, scanBricksInStoryboard, scanCustomApisInStoryboard, scanI18NInAny, scanI18NInStoryboard, scanInstalledAppsInStoryboard, scanPermissionActionsInAny, scanPermissionActionsInStoryboard, scanProcessorsInAny, scanProcessorsInStoryboard, scanRouteAliasInStoryboard, scanStoryboard, scanStoryboardAst, scanTemplatesInBrick, scanTemplatesInStoryboard, shouldAllowRecursiveEvaluations, smartDisplayForEvaluableString, syncResolveContextConcurrently, toPath, tokTypes_1 as tokTypes, trackAll, trackContext, trackFormState, trackState, trackUsedContext, trackUsedFormState, trackUsedState, transform, transformAndInject, traverse, traverseStoryboard, visitStoryboardExpressions, visitStoryboardFunctions };
20341
20390
  //# sourceMappingURL=index.esm.js.map