@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.
- package/dist/index.bundle.js +48 -4
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +47 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/types/track.d.ts +7 -0
- package/package.json +3 -3
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
|
|
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
|
|
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
|
|
|
@@ -19538,9 +19541,48 @@ function track(raw, trackText, variableName) {
|
|
|
19538
19541
|
}
|
|
19539
19542
|
return false;
|
|
19540
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
|
+
}
|
|
19541
19582
|
function beforeVisitContextFactory(usage, variableName) {
|
|
19583
|
+
var rememberObjectName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
19542
19584
|
return function beforeVisitContext(node, parent) {
|
|
19543
|
-
if (node.name === variableName) {
|
|
19585
|
+
if (typeof variableName === "string" ? node.name === variableName : variableName.includes(node.name)) {
|
|
19544
19586
|
var memberParent = parent[parent.length - 1];
|
|
19545
19587
|
if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
|
|
19546
19588
|
var memberNode = memberParent.node;
|
|
@@ -19553,7 +19595,7 @@ function beforeVisitContextFactory(usage, variableName) {
|
|
|
19553
19595
|
usage.includesComputed = true;
|
|
19554
19596
|
}
|
|
19555
19597
|
if (used !== undefined && !usage.usedContexts.includes(used)) {
|
|
19556
|
-
usage.usedContexts.push(used);
|
|
19598
|
+
usage.usedContexts.push(rememberObjectName ? "".concat(node.name, ".").concat(used) : used);
|
|
19557
19599
|
}
|
|
19558
19600
|
}
|
|
19559
19601
|
}
|
|
@@ -20344,5 +20386,5 @@ function isConstantLogical(node, expect, options) {
|
|
|
20344
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);
|
|
20345
20387
|
}
|
|
20346
20388
|
|
|
20347
|
-
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 };
|
|
20348
20390
|
//# sourceMappingURL=index.esm.js.map
|