@next-core/brick-utils 2.52.2 → 2.52.4
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 +90 -31
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +89 -32
- package/dist/index.esm.js.map +1 -1
- package/dist/types/visitStoryboard.d.ts +4 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1143,6 +1143,8 @@ function cook(rootAst, codeSource) {
|
|
|
1143
1143
|
// Currently unicode flag is not fully supported across major browsers.
|
|
1144
1144
|
throw new SyntaxError("Unsupported unicode flag in regular expression: ".concat(node.raw));
|
|
1145
1145
|
}
|
|
1146
|
+
// Always create a new RegExp, because the AST will be reused.
|
|
1147
|
+
return NormalCompletion(new RegExp(node.regex.pattern, node.regex.flags));
|
|
1146
1148
|
}
|
|
1147
1149
|
return NormalCompletion(node.value);
|
|
1148
1150
|
}
|
|
@@ -2124,8 +2126,8 @@ function cook(rootAst, codeSource) {
|
|
|
2124
2126
|
}
|
|
2125
2127
|
|
|
2126
2128
|
// https://tc39.es/ecma262/#sec-runtime-semantics-instantiatefunctionobject
|
|
2127
|
-
function InstantiateFunctionObject(func, scope) {
|
|
2128
|
-
return OrdinaryFunctionCreate(func, scope, true);
|
|
2129
|
+
function InstantiateFunctionObject(func, scope, isRoot) {
|
|
2130
|
+
return OrdinaryFunctionCreate(func, scope, true, isRoot);
|
|
2129
2131
|
}
|
|
2130
2132
|
|
|
2131
2133
|
// https://tc39.es/ecma262/#sec-runtime-semantics-instantiateordinaryfunctionexpression
|
|
@@ -2152,10 +2154,19 @@ function cook(rootAst, codeSource) {
|
|
|
2152
2154
|
}
|
|
2153
2155
|
|
|
2154
2156
|
// https://tc39.es/ecma262/#sec-ordinaryfunctioncreate
|
|
2155
|
-
function OrdinaryFunctionCreate(sourceNode, scope, isConstructor) {
|
|
2157
|
+
function OrdinaryFunctionCreate(sourceNode, scope, isConstructor, isRoot) {
|
|
2156
2158
|
var F = function () {
|
|
2159
|
+
var perf = isRoot && hooks.perfCall;
|
|
2160
|
+
var start;
|
|
2161
|
+
if (perf) {
|
|
2162
|
+
start = performance.now();
|
|
2163
|
+
}
|
|
2157
2164
|
// eslint-disable-next-line prefer-rest-params
|
|
2158
|
-
|
|
2165
|
+
var result = CallFunction(F, arguments);
|
|
2166
|
+
if (perf) {
|
|
2167
|
+
perf(performance.now() - start);
|
|
2168
|
+
}
|
|
2169
|
+
return result;
|
|
2159
2170
|
};
|
|
2160
2171
|
Object.defineProperties(F, {
|
|
2161
2172
|
[SourceNode]: {
|
|
@@ -2371,7 +2382,7 @@ function cook(rootAst, codeSource) {
|
|
|
2371
2382
|
var [fn] = collectBoundNames(rootAst);
|
|
2372
2383
|
// Create an immutable binding for the root function.
|
|
2373
2384
|
rootEnv.CreateImmutableBinding(fn, true);
|
|
2374
|
-
var fo = InstantiateFunctionObject(rootAst, rootEnv);
|
|
2385
|
+
var fo = InstantiateFunctionObject(rootAst, rootEnv, true);
|
|
2375
2386
|
rootEnv.InitializeBinding(fn, fo);
|
|
2376
2387
|
return fo;
|
|
2377
2388
|
}
|
|
@@ -2830,13 +2841,13 @@ var PipelineOperatorErrors = {
|
|
|
2830
2841
|
PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
|
|
2831
2842
|
PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
|
|
2832
2843
|
};
|
|
2833
|
-
var _excluded$1 = ["toMessage"],
|
|
2844
|
+
var _excluded$1$1 = ["toMessage"],
|
|
2834
2845
|
_excluded2$1 = ["message"];
|
|
2835
2846
|
function toParseErrorConstructor(_ref) {
|
|
2836
2847
|
var {
|
|
2837
2848
|
toMessage
|
|
2838
2849
|
} = _ref,
|
|
2839
|
-
properties = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
2850
|
+
properties = _objectWithoutPropertiesLoose(_ref, _excluded$1$1);
|
|
2840
2851
|
return function constructor(_ref39) {
|
|
2841
2852
|
var {
|
|
2842
2853
|
loc,
|
|
@@ -17458,32 +17469,56 @@ function lint(source) {
|
|
|
17458
17469
|
return errors;
|
|
17459
17470
|
}
|
|
17460
17471
|
|
|
17461
|
-
var _excluded = ["typescript"];
|
|
17472
|
+
var _excluded$1 = ["typescript", "cacheKey"];
|
|
17473
|
+
var ASTCache$1 = new WeakMap();
|
|
17462
17474
|
function precookFunction(source) {
|
|
17463
17475
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
17464
17476
|
{
|
|
17465
|
-
typescript
|
|
17477
|
+
typescript,
|
|
17478
|
+
cacheKey
|
|
17466
17479
|
} = _ref,
|
|
17467
|
-
restOptions = _objectWithoutProperties(_ref, _excluded);
|
|
17468
|
-
var func =
|
|
17469
|
-
|
|
17470
|
-
|
|
17480
|
+
restOptions = _objectWithoutProperties(_ref, _excluded$1);
|
|
17481
|
+
var func = cacheKey ? ASTCache$1.get(cacheKey) : undefined;
|
|
17482
|
+
if (!func) {
|
|
17483
|
+
func = parseAsEstree(source, {
|
|
17484
|
+
typescript
|
|
17485
|
+
});
|
|
17486
|
+
if (cacheKey) {
|
|
17487
|
+
ASTCache$1.set(cacheKey, func);
|
|
17488
|
+
}
|
|
17489
|
+
}
|
|
17471
17490
|
var attemptToVisitGlobals = precook(func, restOptions);
|
|
17472
17491
|
return {
|
|
17473
17492
|
function: func,
|
|
17474
17493
|
attemptToVisitGlobals
|
|
17475
17494
|
};
|
|
17476
17495
|
}
|
|
17496
|
+
function clearFunctionASTCache() {
|
|
17497
|
+
ASTCache$1 = new WeakMap();
|
|
17498
|
+
}
|
|
17477
17499
|
|
|
17500
|
+
var _excluded = ["cache"];
|
|
17501
|
+
var ASTCache = new Map();
|
|
17478
17502
|
// `raw` should always be asserted by `isEvaluable`.
|
|
17479
|
-
function preevaluate(raw
|
|
17503
|
+
function preevaluate(raw) {
|
|
17504
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
17505
|
+
{
|
|
17506
|
+
cache
|
|
17507
|
+
} = _ref,
|
|
17508
|
+
restOptions = _objectWithoutProperties(_ref, _excluded);
|
|
17480
17509
|
var fixes = [];
|
|
17481
17510
|
var source = raw.replace(/^\s*<%[~=!]?\s|\s%>\s*$/g, m => {
|
|
17482
17511
|
fixes.push(m);
|
|
17483
17512
|
return "";
|
|
17484
17513
|
});
|
|
17485
|
-
var expression =
|
|
17486
|
-
|
|
17514
|
+
var expression = cache ? ASTCache.get(source) : undefined;
|
|
17515
|
+
if (!expression) {
|
|
17516
|
+
expression = parseAsEstreeExpression(source);
|
|
17517
|
+
if (cache) {
|
|
17518
|
+
ASTCache.set(source, expression);
|
|
17519
|
+
}
|
|
17520
|
+
}
|
|
17521
|
+
var attemptToVisitGlobals = precook(expression, _objectSpread(_objectSpread({}, restOptions), {}, {
|
|
17487
17522
|
expressionOnly: true
|
|
17488
17523
|
}));
|
|
17489
17524
|
return {
|
|
@@ -17506,6 +17541,9 @@ function isSnippetEvaluation(raw) {
|
|
|
17506
17541
|
function isTrackAll(raw) {
|
|
17507
17542
|
return /^\s*<%=\s/.test(raw) && /\s%>\s*$/.test(raw);
|
|
17508
17543
|
}
|
|
17544
|
+
function clearExpressionASTCache() {
|
|
17545
|
+
ASTCache.clear();
|
|
17546
|
+
}
|
|
17509
17547
|
|
|
17510
17548
|
// istanbul ignore file
|
|
17511
17549
|
|
|
@@ -17532,11 +17570,15 @@ function isObject$1(value) {
|
|
|
17532
17570
|
return value != null && (type == "object" || type == "function");
|
|
17533
17571
|
}
|
|
17534
17572
|
|
|
17535
|
-
function visitStoryboardFunctions(functions, beforeVisitGlobal) {
|
|
17573
|
+
function visitStoryboardFunctions(functions, beforeVisitGlobal, options) {
|
|
17536
17574
|
if (Array.isArray(functions)) {
|
|
17537
17575
|
for (var fn of functions) {
|
|
17576
|
+
if (options !== null && options !== void 0 && options.matchSource && !options.matchSource(fn.source)) {
|
|
17577
|
+
continue;
|
|
17578
|
+
}
|
|
17538
17579
|
try {
|
|
17539
17580
|
precookFunction(fn.source, {
|
|
17581
|
+
cacheKey: fn,
|
|
17540
17582
|
typescript: fn.typescript,
|
|
17541
17583
|
withParent: true,
|
|
17542
17584
|
hooks: {
|
|
@@ -17567,6 +17609,7 @@ options) {
|
|
|
17567
17609
|
if (matchExpressionString(value) && customIsEvaluable(value)) {
|
|
17568
17610
|
try {
|
|
17569
17611
|
preevaluate(value, {
|
|
17612
|
+
cache: true,
|
|
17570
17613
|
withParent: true,
|
|
17571
17614
|
hooks: {
|
|
17572
17615
|
beforeVisitGlobal
|
|
@@ -18928,7 +18971,9 @@ function scanPermissionActionsInStoryboard(storyboard) {
|
|
|
18928
18971
|
functions
|
|
18929
18972
|
} = (_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 ? _storyboard$meta : {};
|
|
18930
18973
|
visitStoryboardExpressions([storyboard.routes, customTemplates], beforeVisitPermissions, PERMISSIONS);
|
|
18931
|
-
visitStoryboardFunctions(functions, beforeVisitPermissions
|
|
18974
|
+
visitStoryboardFunctions(functions, beforeVisitPermissions, {
|
|
18975
|
+
matchSource: source => source.includes(PERMISSIONS)
|
|
18976
|
+
});
|
|
18932
18977
|
return Array.from(collection);
|
|
18933
18978
|
}
|
|
18934
18979
|
function scanPermissionActionsInAny(data) {
|
|
@@ -19017,30 +19062,36 @@ function beforeVisitI18nFactory(collection) {
|
|
|
19017
19062
|
}
|
|
19018
19063
|
|
|
19019
19064
|
var APP = "APP";
|
|
19020
|
-
var
|
|
19065
|
+
var GET_MENU = "getMenu";
|
|
19021
19066
|
function scanAppGetMenuInStoryboard(storyboard) {
|
|
19022
19067
|
var _storyboard$meta;
|
|
19023
19068
|
var collection = new Set();
|
|
19024
|
-
var
|
|
19069
|
+
var beforeVisitApp = beforeVisitAppFactory(collection);
|
|
19025
19070
|
var {
|
|
19026
|
-
customTemplates
|
|
19027
|
-
functions
|
|
19071
|
+
customTemplates
|
|
19028
19072
|
} = (_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 ? _storyboard$meta : {};
|
|
19029
|
-
visitStoryboardExpressions([storyboard.routes, customTemplates],
|
|
19030
|
-
|
|
19073
|
+
visitStoryboardExpressions([storyboard.routes, customTemplates], beforeVisitApp, {
|
|
19074
|
+
matchExpressionString: matchAppGetMenu
|
|
19075
|
+
});
|
|
19076
|
+
// `APP` is not available in storyboard functions
|
|
19031
19077
|
return Array.from(collection);
|
|
19032
19078
|
}
|
|
19033
19079
|
function scanAppGetMenuInAny(data) {
|
|
19034
19080
|
var collection = new Set();
|
|
19035
|
-
visitStoryboardExpressions(data, beforeVisitAppFactory(collection),
|
|
19081
|
+
visitStoryboardExpressions(data, beforeVisitAppFactory(collection), {
|
|
19082
|
+
matchExpressionString: matchAppGetMenu
|
|
19083
|
+
});
|
|
19036
19084
|
return Array.from(collection);
|
|
19037
19085
|
}
|
|
19086
|
+
function matchAppGetMenu(source) {
|
|
19087
|
+
return source.includes(APP) && source.includes(GET_MENU);
|
|
19088
|
+
}
|
|
19038
19089
|
function beforeVisitAppFactory(collection) {
|
|
19039
19090
|
return function beforeVisitAPP(node, parent) {
|
|
19040
19091
|
if (node.name === APP) {
|
|
19041
19092
|
var memberParent = parent[parent.length - 1];
|
|
19042
19093
|
var callParent = parent[parent.length - 2];
|
|
19043
|
-
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 ===
|
|
19094
|
+
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) {
|
|
19044
19095
|
if (callParent.node.arguments.length === 1) {
|
|
19045
19096
|
var menuId = callParent.node.arguments[0];
|
|
19046
19097
|
if (menuId.type === "Literal" && typeof menuId.value === "string") {
|
|
@@ -19548,6 +19599,8 @@ var {
|
|
|
19548
19599
|
convertUnitValueByPrecision: convertValueByPrecision
|
|
19549
19600
|
} = utils;
|
|
19550
19601
|
|
|
19602
|
+
var TRACK_NAMES = ["CTX", "STATE", "FORM_STATE"];
|
|
19603
|
+
|
|
19551
19604
|
/**
|
|
19552
19605
|
* Get tracking CTX for an evaluable expression in `track context` mode.
|
|
19553
19606
|
*
|
|
@@ -19602,6 +19655,7 @@ function track(raw, trackText, variableName) {
|
|
|
19602
19655
|
var {
|
|
19603
19656
|
expression
|
|
19604
19657
|
} = preevaluate(raw, {
|
|
19658
|
+
cache: true,
|
|
19605
19659
|
withParent: true,
|
|
19606
19660
|
hooks: {
|
|
19607
19661
|
beforeVisitGlobal: beforeVisitContextFactory(usage, variableName)
|
|
@@ -19621,15 +19675,17 @@ function track(raw, trackText, variableName) {
|
|
|
19621
19675
|
return false;
|
|
19622
19676
|
}
|
|
19623
19677
|
function trackAll(raw) {
|
|
19624
|
-
if
|
|
19678
|
+
// Do not pre-evaluate a string if it doesn't include track names.
|
|
19679
|
+
if (TRACK_NAMES.some(name => raw.includes(name))) {
|
|
19625
19680
|
var usage = {
|
|
19626
19681
|
usedContexts: [],
|
|
19627
19682
|
includesComputed: false
|
|
19628
19683
|
};
|
|
19629
19684
|
preevaluate(raw, {
|
|
19685
|
+
cache: true,
|
|
19630
19686
|
withParent: true,
|
|
19631
19687
|
hooks: {
|
|
19632
|
-
beforeVisitGlobal: beforeVisitContextFactory(usage,
|
|
19688
|
+
beforeVisitGlobal: beforeVisitContextFactory(usage, TRACK_NAMES, true)
|
|
19633
19689
|
}
|
|
19634
19690
|
});
|
|
19635
19691
|
if (usage.usedContexts.length > 0) {
|
|
@@ -20202,11 +20258,10 @@ function scanInstalledAppsInStoryboard(storyboard) {
|
|
|
20202
20258
|
var beforeVisitInstalledApps = beforeVisitInstalledAppsFactory(collection);
|
|
20203
20259
|
var {
|
|
20204
20260
|
customTemplates,
|
|
20205
|
-
functions,
|
|
20206
20261
|
menus
|
|
20207
20262
|
} = (_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 ? _storyboard$meta : {};
|
|
20208
20263
|
visitStoryboardExpressions([storyboard.routes, customTemplates, menus], beforeVisitInstalledApps, INSTALLED_APPS);
|
|
20209
|
-
|
|
20264
|
+
// `INSTALLED_APPS` is not available in storyboard functions
|
|
20210
20265
|
return Array.from(collection);
|
|
20211
20266
|
}
|
|
20212
20267
|
function beforeVisitInstalledAppsFactory(collection) {
|
|
@@ -20425,7 +20480,9 @@ function computeConstantCondition(ifContainer) {
|
|
|
20425
20480
|
expression,
|
|
20426
20481
|
attemptToVisitGlobals,
|
|
20427
20482
|
source
|
|
20428
|
-
} = preevaluate(ifContainer.if
|
|
20483
|
+
} = preevaluate(ifContainer.if, {
|
|
20484
|
+
cache: true
|
|
20485
|
+
});
|
|
20429
20486
|
var {
|
|
20430
20487
|
constantFeatureFlags,
|
|
20431
20488
|
featureFlags
|
|
@@ -20715,5 +20772,5 @@ function snippetEvaluate(brickConf, context) {
|
|
|
20715
20772
|
return result;
|
|
20716
20773
|
}
|
|
20717
20774
|
|
|
20718
|
-
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, isSnippetEvaluation, 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, snippetEvaluate, syncResolveContextConcurrently, toPath, tokTypes_1 as tokTypes, trackAll, trackContext, trackFormState, trackState, trackUsedContext, trackUsedFormState, trackUsedState, transform, transformAndInject, traverse, traverseStoryboard, visitStoryboardExpressions, visitStoryboardFunctions };
|
|
20775
|
+
export { JsonStorage, PrecookFunctionVisitor, PrecookVisitor, asyncProcessBrick, asyncProcessStoryboard, clearExpressionASTCache, clearFunctionASTCache, 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, isSnippetEvaluation, 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, snippetEvaluate, syncResolveContextConcurrently, toPath, tokTypes_1 as tokTypes, trackAll, trackContext, trackFormState, trackState, trackUsedContext, trackUsedFormState, trackUsedState, transform, transformAndInject, traverse, traverseStoryboard, visitStoryboardExpressions, visitStoryboardFunctions };
|
|
20719
20776
|
//# sourceMappingURL=index.esm.js.map
|