@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.bundle.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
|
@@ -18225,25 +18228,30 @@
|
|
|
18225
18228
|
} = _ref;
|
|
18226
18229
|
var dll = new Set();
|
|
18227
18230
|
var deps = new Set();
|
|
18231
|
+
var v3Bricks = new Set();
|
|
18232
|
+
var v3Processors = new Set();
|
|
18228
18233
|
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) {
|
|
18229
18234
|
var brickMap = getBrickToPackageMap(brickPackages);
|
|
18230
|
-
[...(bricks !== null && bricks !== void 0 ? bricks : []), ...(processors !== null && processors !== void 0 ? processors : [])].forEach(
|
|
18235
|
+
[...(bricks !== null && bricks !== void 0 ? bricks : []).map(n => [n]), ...(processors !== null && processors !== void 0 ? processors : []).map(n => [n, true])].forEach(_ref2 => {
|
|
18236
|
+
var [name, isProcessor] = _ref2;
|
|
18231
18237
|
// ignore custom template
|
|
18232
18238
|
// istanbul ignore else
|
|
18233
18239
|
if (name.includes(".")) {
|
|
18234
18240
|
var namespace = name.split(".")[0];
|
|
18235
|
-
var isProcessor = processors === null || processors === void 0 ? void 0 : processors.includes(name);
|
|
18236
|
-
|
|
18237
18241
|
// processor 是 camelCase 格式,转成 brick 的 param-case 格式,统一去判断
|
|
18238
18242
|
if (isProcessor) {
|
|
18239
18243
|
namespace = paramCase(namespace);
|
|
18240
18244
|
}
|
|
18241
18245
|
var find = brickMap.get(namespace);
|
|
18242
18246
|
if (find) {
|
|
18243
|
-
|
|
18244
|
-
|
|
18245
|
-
|
|
18246
|
-
|
|
18247
|
+
if (find.id) {
|
|
18248
|
+
(isProcessor ? v3Processors : v3Bricks).add(name);
|
|
18249
|
+
} else {
|
|
18250
|
+
deps.add(find.filePath);
|
|
18251
|
+
if (find.dll) {
|
|
18252
|
+
for (var dllName of find.dll) {
|
|
18253
|
+
dll.add(dllName);
|
|
18254
|
+
}
|
|
18247
18255
|
}
|
|
18248
18256
|
}
|
|
18249
18257
|
} else {
|
|
@@ -18274,7 +18282,9 @@
|
|
|
18274
18282
|
var dllPath = window.DLL_PATH;
|
|
18275
18283
|
return {
|
|
18276
18284
|
dll: Array.from(dll).map(dllName => dllPath[dllName]),
|
|
18277
|
-
deps: Array.from(deps)
|
|
18285
|
+
deps: Array.from(deps),
|
|
18286
|
+
v3Bricks: Array.from(v3Bricks),
|
|
18287
|
+
v3Processors: Array.from(v3Processors)
|
|
18278
18288
|
};
|
|
18279
18289
|
}
|
|
18280
18290
|
|
|
@@ -19536,9 +19546,48 @@
|
|
|
19536
19546
|
}
|
|
19537
19547
|
return false;
|
|
19538
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
|
+
}
|
|
19539
19587
|
function beforeVisitContextFactory(usage, variableName) {
|
|
19588
|
+
var rememberObjectName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
19540
19589
|
return function beforeVisitContext(node, parent) {
|
|
19541
|
-
if (node.name === variableName) {
|
|
19590
|
+
if (typeof variableName === "string" ? node.name === variableName : variableName.includes(node.name)) {
|
|
19542
19591
|
var memberParent = parent[parent.length - 1];
|
|
19543
19592
|
if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
|
|
19544
19593
|
var memberNode = memberParent.node;
|
|
@@ -19551,7 +19600,7 @@
|
|
|
19551
19600
|
usage.includesComputed = true;
|
|
19552
19601
|
}
|
|
19553
19602
|
if (used !== undefined && !usage.usedContexts.includes(used)) {
|
|
19554
|
-
usage.usedContexts.push(used);
|
|
19603
|
+
usage.usedContexts.push(rememberObjectName ? "".concat(node.name, ".").concat(used) : used);
|
|
19555
19604
|
}
|
|
19556
19605
|
}
|
|
19557
19606
|
}
|
|
@@ -20376,6 +20425,7 @@
|
|
|
20376
20425
|
exports.isObject = isObject$1;
|
|
20377
20426
|
exports.isRouteNode = isRouteNode;
|
|
20378
20427
|
exports.isSnippetNode = isSnippetNode;
|
|
20428
|
+
exports.isTrackAll = isTrackAll;
|
|
20379
20429
|
exports.lint = lint;
|
|
20380
20430
|
exports.loadScript = loadScript;
|
|
20381
20431
|
exports.makeThrottledAggregation = makeThrottledAggregation;
|
|
@@ -20419,6 +20469,7 @@
|
|
|
20419
20469
|
exports.syncResolveContextConcurrently = syncResolveContextConcurrently;
|
|
20420
20470
|
exports.toPath = toPath;
|
|
20421
20471
|
exports.tokTypes = tokTypes_1;
|
|
20472
|
+
exports.trackAll = trackAll;
|
|
20422
20473
|
exports.trackContext = trackContext;
|
|
20423
20474
|
exports.trackFormState = trackFormState;
|
|
20424
20475
|
exports.trackState = trackState;
|