@next-core/brick-utils 2.38.2 → 2.39.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/dist/index.esm.js CHANGED
@@ -22628,7 +22628,7 @@ function getDependencyMapOfContext(contextConfs) {
22628
22628
  };
22629
22629
 
22630
22630
  if (!_contextConf2.property) {
22631
- visitStoryboardExpressions([_contextConf2.if, _contextConf2.value, _contextConf2.resolve], beforeVisitContextFactory(stats, keyword), keyword);
22631
+ visitStoryboardExpressions([_contextConf2.if, _contextConf2.value, _contextConf2.resolve], beforeVisitContextFactory$1(stats, keyword), keyword);
22632
22632
  }
22633
22633
 
22634
22634
  depsMap.set(_contextConf2, stats);
@@ -22637,7 +22637,7 @@ function getDependencyMapOfContext(contextConfs) {
22637
22637
  return depsMap;
22638
22638
  }
22639
22639
 
22640
- function beforeVisitContextFactory(stats, keyword) {
22640
+ function beforeVisitContextFactory$1(stats, keyword) {
22641
22641
  return function beforeVisitContext(node, parent) {
22642
22642
  if (node.name === keyword) {
22643
22643
  var memberParent = parent[parent.length - 1];
@@ -22965,6 +22965,12 @@ function trackContext(raw) {
22965
22965
  function trackState(raw) {
22966
22966
  return track(raw, "track state", "STATE");
22967
22967
  }
22968
+ function trackUsedContext(data) {
22969
+ return trackUsed(data, "CTX");
22970
+ }
22971
+ function trackUsedState(data) {
22972
+ return trackUsed(data, "STATE");
22973
+ }
22968
22974
 
22969
22975
  function track(raw, trackText, variableName) {
22970
22976
  if (raw.includes(trackText)) {
@@ -22974,22 +22980,7 @@ function track(raw, trackText, variableName) {
22974
22980
  } = preevaluate(raw, {
22975
22981
  withParent: true,
22976
22982
  hooks: {
22977
- beforeVisitGlobal(node, parent) {
22978
- if (node.name === variableName) {
22979
- var memberParent = parent[parent.length - 1];
22980
-
22981
- if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
22982
- var memberNode = memberParent.node;
22983
-
22984
- if (!memberNode.computed && memberNode.property.type === "Identifier") {
22985
- contexts.add(memberNode.property.name);
22986
- } else if (memberNode.computed && memberNode.property.type === "Literal" && typeof memberNode.property.value === "string") {
22987
- contexts.add(memberNode.property.value);
22988
- }
22989
- }
22990
- }
22991
- }
22992
-
22983
+ beforeVisitGlobal: beforeVisitContextFactory(contexts, variableName)
22993
22984
  }
22994
22985
  });
22995
22986
  var trackCtxExp;
@@ -23007,6 +22998,30 @@ function track(raw, trackText, variableName) {
23007
22998
  return false;
23008
22999
  }
23009
23000
 
23001
+ function trackUsed(data, variableName) {
23002
+ var contexts = new Set();
23003
+ visitStoryboardExpressions(data, beforeVisitContextFactory(contexts, variableName), variableName);
23004
+ return Array.from(contexts);
23005
+ }
23006
+
23007
+ function beforeVisitContextFactory(contexts, variableName) {
23008
+ return function beforeVisitContext(node, parent) {
23009
+ if (node.name === variableName) {
23010
+ var memberParent = parent[parent.length - 1];
23011
+
23012
+ if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
23013
+ var memberNode = memberParent.node;
23014
+
23015
+ if (!memberNode.computed && memberNode.property.type === "Identifier") {
23016
+ contexts.add(memberNode.property.name);
23017
+ } else if (memberNode.computed && memberNode.property.type === "Literal" && typeof memberNode.property.value === "string") {
23018
+ contexts.add(memberNode.property.value);
23019
+ }
23020
+ }
23021
+ }
23022
+ };
23023
+ }
23024
+
23010
23025
  // The debounce function receives our function as a parameter
23011
23026
  function debounceByAnimationFrame(fn) {
23012
23027
  // This holds the requestAnimationFrame reference, so we can cancel it if we wish
@@ -23063,5 +23078,5 @@ function beforeVisitInstalledAppsFactory(collection) {
23063
23078
  };
23064
23079
  }
23065
23080
 
23066
- export { JsonStorage, PrecookFunctionVisitor, PrecookVisitor, asyncProcessBrick, asyncProcessStoryboard, computeRealRoutePath, convertValueByPrecision, cook, createProviderClass, debounceByAnimationFrame, deepFreeze, formatValue, getDependencyMapOfContext, getDepsOfTemplates, getDllAndDepsByResource, getDllAndDepsOfBricks, getDllAndDepsOfStoryboard, getTemplateDepsOfStoryboard, hasOwnProperty$1 as hasOwnProperty, inject, isBrickNode, isCustomTemplateNode, isEvaluable, isObject, isRouteNode, isSnippetNode, lint, loadScript, mapCustomApisToNameAndNamespace, matchPath, normalizeBuilderNode, normalizeMenu, parseForAnalysis, precook, precookFunction, preevaluate, prefetchScript, resolveContextConcurrently, restoreDynamicTemplates, scanAppGetMenuInAny, scanAppGetMenuInStoryboard, scanBricksInBrickConf, scanBricksInStoryboard, scanCustomApisInStoryboard, scanI18NInAny, scanI18NInStoryboard, scanInstalledAppsInStoryboard, scanPermissionActionsInAny, scanPermissionActionsInStoryboard, scanProcessorsInAny, scanProcessorsInStoryboard, scanRouteAliasInStoryboard, scanStoryboard, scanTemplatesInBrick, scanTemplatesInStoryboard, shouldAllowRecursiveEvaluations, smartDisplayForEvaluableString, syncResolveContextConcurrently, toPath, tokTypes_1 as tokTypes, trackContext, trackState, transform, transformAndInject, visitStoryboardExpressions, visitStoryboardFunctions };
23081
+ export { JsonStorage, PrecookFunctionVisitor, PrecookVisitor, asyncProcessBrick, asyncProcessStoryboard, computeRealRoutePath, convertValueByPrecision, cook, createProviderClass, debounceByAnimationFrame, deepFreeze, formatValue, getDependencyMapOfContext, getDepsOfTemplates, getDllAndDepsByResource, getDllAndDepsOfBricks, getDllAndDepsOfStoryboard, getTemplateDepsOfStoryboard, hasOwnProperty$1 as hasOwnProperty, inject, isBrickNode, isCustomTemplateNode, isEvaluable, isObject, isRouteNode, isSnippetNode, lint, loadScript, mapCustomApisToNameAndNamespace, matchPath, normalizeBuilderNode, normalizeMenu, parseForAnalysis, precook, precookFunction, preevaluate, prefetchScript, resolveContextConcurrently, restoreDynamicTemplates, scanAppGetMenuInAny, scanAppGetMenuInStoryboard, scanBricksInBrickConf, scanBricksInStoryboard, scanCustomApisInStoryboard, scanI18NInAny, scanI18NInStoryboard, scanInstalledAppsInStoryboard, scanPermissionActionsInAny, scanPermissionActionsInStoryboard, scanProcessorsInAny, scanProcessorsInStoryboard, scanRouteAliasInStoryboard, scanStoryboard, scanTemplatesInBrick, scanTemplatesInStoryboard, shouldAllowRecursiveEvaluations, smartDisplayForEvaluableString, syncResolveContextConcurrently, toPath, tokTypes_1 as tokTypes, trackContext, trackState, trackUsedContext, trackUsedState, transform, transformAndInject, visitStoryboardExpressions, visitStoryboardFunctions };
23067
23082
  //# sourceMappingURL=index.esm.js.map