@next-core/brick-utils 2.45.15 → 2.45.17
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 +233 -127
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +232 -128
- package/dist/index.esm.js.map +1 -1
- package/dist/types/resolveContextConcurrently.d.ts +10 -6
- package/dist/types/track.d.ts +5 -0
- package/package.json +2 -2
package/dist/index.bundle.js
CHANGED
|
@@ -19461,42 +19461,244 @@
|
|
|
19461
19461
|
convertUnitValueByPrecision: convertValueByPrecision
|
|
19462
19462
|
} = pipes.utils;
|
|
19463
19463
|
|
|
19464
|
-
|
|
19464
|
+
/**
|
|
19465
|
+
* Get tracking CTX for an evaluable expression in `track context` mode.
|
|
19466
|
+
*
|
|
19467
|
+
* A `track context` mode is an evaluable expression which is a sequence expression
|
|
19468
|
+
* starting with the exact literal string expression of "track context".
|
|
19469
|
+
*
|
|
19470
|
+
* @param raw - A raw string, which must be checked by `isEvaluable` first.
|
|
19471
|
+
*
|
|
19472
|
+
* @returns
|
|
19473
|
+
*
|
|
19474
|
+
* Returns used CTXs if `track context` mode is enabled, or returns false if not enabled or
|
|
19475
|
+
* no CTX found.
|
|
19476
|
+
*
|
|
19477
|
+
* @example
|
|
19478
|
+
*
|
|
19479
|
+
* ```js
|
|
19480
|
+
* trackContext('<% "track context", [CTX.hello, CTX.world] %>');
|
|
19481
|
+
* // => ["hello", "world"]
|
|
19482
|
+
*
|
|
19483
|
+
* trackContext('<% [CTX.hello, CTX.world] %>');
|
|
19484
|
+
* // => false
|
|
19485
|
+
*
|
|
19486
|
+
* trackContext('<% "track context", DATA.any %>');
|
|
19487
|
+
* // => false
|
|
19488
|
+
* ```
|
|
19489
|
+
*/
|
|
19490
|
+
function trackContext(raw) {
|
|
19491
|
+
return track(raw, "track context", "CTX");
|
|
19492
|
+
}
|
|
19493
|
+
function trackState(raw) {
|
|
19494
|
+
return track(raw, "track state", "STATE");
|
|
19495
|
+
}
|
|
19496
|
+
function trackFormState(raw) {
|
|
19497
|
+
return track(raw, "track formstate", "FORM_STATE");
|
|
19498
|
+
}
|
|
19499
|
+
function trackUsedContext(data) {
|
|
19500
|
+
return collectContextUsage(data, "CTX").usedContexts;
|
|
19501
|
+
}
|
|
19502
|
+
function trackUsedState(data) {
|
|
19503
|
+
return collectContextUsage(data, "STATE").usedContexts;
|
|
19504
|
+
}
|
|
19505
|
+
function track(raw, trackText, variableName) {
|
|
19506
|
+
if (raw.includes(trackText)) {
|
|
19507
|
+
// const contexts = new Set<string>();
|
|
19508
|
+
var usage = {
|
|
19509
|
+
usedContexts: [],
|
|
19510
|
+
includesComputed: false
|
|
19511
|
+
};
|
|
19512
|
+
var {
|
|
19513
|
+
expression
|
|
19514
|
+
} = preevaluate(raw, {
|
|
19515
|
+
withParent: true,
|
|
19516
|
+
hooks: {
|
|
19517
|
+
beforeVisitGlobal: beforeVisitContextFactory(usage, variableName)
|
|
19518
|
+
}
|
|
19519
|
+
});
|
|
19520
|
+
// const contexts = usage
|
|
19521
|
+
var trackCtxExp;
|
|
19522
|
+
if (expression.type === "SequenceExpression" && (trackCtxExp = expression.expressions[0]) && trackCtxExp.type === "Literal" && trackCtxExp.value === trackText) {
|
|
19523
|
+
if (usage.usedContexts.length > 0) {
|
|
19524
|
+
return usage.usedContexts;
|
|
19525
|
+
} else {
|
|
19526
|
+
// eslint-disable-next-line no-console
|
|
19527
|
+
console.warn("You are using \"".concat(trackText, "\" but no `").concat(variableName, "` usage found in your expression: ").concat(JSON.stringify(raw)));
|
|
19528
|
+
}
|
|
19529
|
+
}
|
|
19530
|
+
}
|
|
19531
|
+
return false;
|
|
19532
|
+
}
|
|
19533
|
+
function beforeVisitContextFactory(usage, variableName) {
|
|
19534
|
+
return function beforeVisitContext(node, parent) {
|
|
19535
|
+
if (node.name === variableName) {
|
|
19536
|
+
var memberParent = parent[parent.length - 1];
|
|
19537
|
+
if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
|
|
19538
|
+
var memberNode = memberParent.node;
|
|
19539
|
+
var used;
|
|
19540
|
+
if (!memberNode.computed && memberNode.property.type === "Identifier") {
|
|
19541
|
+
used = memberNode.property.name;
|
|
19542
|
+
} else if (memberNode.computed && memberNode.property.type === "Literal" && typeof memberNode.property.value === "string") {
|
|
19543
|
+
used = memberNode.property.value;
|
|
19544
|
+
} else {
|
|
19545
|
+
usage.includesComputed = true;
|
|
19546
|
+
}
|
|
19547
|
+
if (used !== undefined && !usage.usedContexts.includes(used)) {
|
|
19548
|
+
usage.usedContexts.push(used);
|
|
19549
|
+
}
|
|
19550
|
+
}
|
|
19551
|
+
}
|
|
19552
|
+
};
|
|
19553
|
+
}
|
|
19554
|
+
function collectContextUsage(data, variableName) {
|
|
19555
|
+
var usage = {
|
|
19556
|
+
usedContexts: [],
|
|
19557
|
+
includesComputed: false
|
|
19558
|
+
};
|
|
19559
|
+
visitStoryboardExpressions(data, beforeVisitContextFactory(usage, variableName), variableName);
|
|
19560
|
+
return usage;
|
|
19561
|
+
}
|
|
19562
|
+
|
|
19563
|
+
function deferResolveContextConcurrently(contextConfs, resolveContext) {
|
|
19564
|
+
var keyword = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "CTX";
|
|
19565
|
+
var dependencyMap = getDependencyMapOfContext(contextConfs, keyword);
|
|
19566
|
+
// There maybe multiple context confs for a specific name, since there are conditional contexts.
|
|
19567
|
+
// This is a map of how many pending context confs for each context name.
|
|
19568
|
+
var pendingDeps = new Map();
|
|
19569
|
+
for (var contextName of Array.from(dependencyMap.keys()).map(contextConf => contextConf.name)) {
|
|
19570
|
+
var _pendingDeps$get;
|
|
19571
|
+
pendingDeps.set(contextName, ((_pendingDeps$get = pendingDeps.get(contextName)) !== null && _pendingDeps$get !== void 0 ? _pendingDeps$get : 0) + 1);
|
|
19572
|
+
}
|
|
19573
|
+
var includesComputed = Array.from(dependencyMap.values()).some(stats => stats.includesComputed);
|
|
19574
|
+
var processed = new WeakSet();
|
|
19575
|
+
var deferredContexts = new Map();
|
|
19576
|
+
var pendingContexts = new Map([...new Set(contextConfs.map(contextConf => contextConf.name))].map(contextName => [contextName, new Promise((resolve, reject) => {
|
|
19577
|
+
deferredContexts.set(contextName, {
|
|
19578
|
+
resolve,
|
|
19579
|
+
reject
|
|
19580
|
+
});
|
|
19581
|
+
})]));
|
|
19582
|
+
var wrapResolve = /*#__PURE__*/function () {
|
|
19583
|
+
var _ref = _asyncToGenerator__default["default"](function* (contextConf) {
|
|
19584
|
+
var _pendingDeps$get2;
|
|
19585
|
+
processed.add(contextConf);
|
|
19586
|
+
var resolved = yield resolveContext(contextConf);
|
|
19587
|
+
dependencyMap.delete(contextConf);
|
|
19588
|
+
var left = (_pendingDeps$get2 = pendingDeps.get(contextConf.name)) !== null && _pendingDeps$get2 !== void 0 ? _pendingDeps$get2 : 0;
|
|
19589
|
+
if (resolved) {
|
|
19590
|
+
deferredContexts.get(contextConf.name).resolve();
|
|
19591
|
+
pendingDeps.delete(contextConf.name);
|
|
19592
|
+
if (left === 0) {
|
|
19593
|
+
throw new Error("Duplicated context defined: ".concat(contextConf.name));
|
|
19594
|
+
}
|
|
19595
|
+
} else {
|
|
19596
|
+
// Assert: left >= 1
|
|
19597
|
+
if (left === 1) {
|
|
19598
|
+
deferredContexts.get(contextConf.name).resolve();
|
|
19599
|
+
pendingDeps.delete(contextConf.name);
|
|
19600
|
+
} else {
|
|
19601
|
+
pendingDeps.set(contextConf.name, left - 1);
|
|
19602
|
+
}
|
|
19603
|
+
}
|
|
19604
|
+
yield scheduleNext();
|
|
19605
|
+
});
|
|
19606
|
+
return function wrapResolve(_x) {
|
|
19607
|
+
return _ref.apply(this, arguments);
|
|
19608
|
+
};
|
|
19609
|
+
}();
|
|
19610
|
+
var scheduleAsSerial = includesComputed;
|
|
19611
|
+
function scheduleNext() {
|
|
19612
|
+
return _scheduleNext.apply(this, arguments);
|
|
19613
|
+
}
|
|
19614
|
+
function _scheduleNext() {
|
|
19615
|
+
_scheduleNext = _asyncToGenerator__default["default"](function* () {
|
|
19616
|
+
var readyContexts = Array.from(dependencyMap.entries()).filter(predicateNextResolveFactory(pendingDeps, scheduleAsSerial)).map(entry => entry[0]).filter(contextConf => !processed.has(contextConf));
|
|
19617
|
+
yield Promise.all(readyContexts.map(wrapResolve));
|
|
19618
|
+
});
|
|
19619
|
+
return _scheduleNext.apply(this, arguments);
|
|
19620
|
+
}
|
|
19621
|
+
var pendingResult = scheduleNext().then( /*#__PURE__*/_asyncToGenerator__default["default"](function* () {
|
|
19622
|
+
// If there are still contexts left, it implies one of these situations:
|
|
19623
|
+
// - Circular contexts.
|
|
19624
|
+
// Such as: a depends on b, while b depends on a.
|
|
19625
|
+
// - Related contexts are all ignored.
|
|
19626
|
+
// Such as: a depends on b,
|
|
19627
|
+
// while both them are ignore by a falsy result of `if`.
|
|
19628
|
+
if (dependencyMap.size > 0) {
|
|
19629
|
+
// This will throw if circular contexts detected.
|
|
19630
|
+
detectCircularContexts(dependencyMap, keyword);
|
|
19631
|
+
scheduleAsSerial = true;
|
|
19632
|
+
yield scheduleNext();
|
|
19633
|
+
}
|
|
19634
|
+
// There maybe ignored contexts which are still not fulfilled.
|
|
19635
|
+
// We treat them as RESOLVED.
|
|
19636
|
+
for (var deferred of deferredContexts.values()) {
|
|
19637
|
+
deferred.resolve();
|
|
19638
|
+
}
|
|
19639
|
+
})).catch(error => {
|
|
19640
|
+
// There maybe contexts left not fulfilled, when an error occurred.
|
|
19641
|
+
// We treat them as REJECTED.
|
|
19642
|
+
for (var deferred of deferredContexts.values()) {
|
|
19643
|
+
deferred.reject(error);
|
|
19644
|
+
}
|
|
19645
|
+
throw error;
|
|
19646
|
+
});
|
|
19647
|
+
return {
|
|
19648
|
+
pendingResult,
|
|
19649
|
+
pendingContexts
|
|
19650
|
+
};
|
|
19651
|
+
}
|
|
19652
|
+
function resolveContextConcurrently(_x2, _x3) {
|
|
19465
19653
|
return _resolveContextConcurrently.apply(this, arguments);
|
|
19466
19654
|
}
|
|
19467
19655
|
function _resolveContextConcurrently() {
|
|
19468
19656
|
_resolveContextConcurrently = _asyncToGenerator__default["default"](function* (contextConfs, resolveContext) {
|
|
19469
19657
|
var keyword = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "CTX";
|
|
19470
19658
|
var dependencyMap = getDependencyMapOfContext(contextConfs, keyword);
|
|
19471
|
-
var pendingDeps = new
|
|
19659
|
+
var pendingDeps = new Map();
|
|
19660
|
+
for (var contextName of Array.from(dependencyMap.keys()).map(contextConf => contextConf.name)) {
|
|
19661
|
+
var _pendingDeps$get5;
|
|
19662
|
+
pendingDeps.set(contextName, ((_pendingDeps$get5 = pendingDeps.get(contextName)) !== null && _pendingDeps$get5 !== void 0 ? _pendingDeps$get5 : 0) + 1);
|
|
19663
|
+
}
|
|
19472
19664
|
var includesComputed = Array.from(dependencyMap.values()).some(stats => stats.includesComputed);
|
|
19473
19665
|
var processed = new WeakSet();
|
|
19474
19666
|
var wrapResolve = /*#__PURE__*/function () {
|
|
19475
|
-
var
|
|
19667
|
+
var _ref3 = _asyncToGenerator__default["default"](function* (contextConf) {
|
|
19668
|
+
var _pendingDeps$get6;
|
|
19476
19669
|
processed.add(contextConf);
|
|
19477
19670
|
var resolved = yield resolveContext(contextConf);
|
|
19478
19671
|
dependencyMap.delete(contextConf);
|
|
19672
|
+
var left = (_pendingDeps$get6 = pendingDeps.get(contextConf.name)) !== null && _pendingDeps$get6 !== void 0 ? _pendingDeps$get6 : 0;
|
|
19479
19673
|
if (resolved) {
|
|
19480
|
-
|
|
19674
|
+
pendingDeps.delete(contextConf.name);
|
|
19675
|
+
if (left === 0) {
|
|
19481
19676
|
throw new Error("Duplicated context defined: ".concat(contextConf.name));
|
|
19482
19677
|
}
|
|
19678
|
+
} else {
|
|
19679
|
+
// Assert: left >= 1
|
|
19680
|
+
if (left === 1) {
|
|
19681
|
+
pendingDeps.delete(contextConf.name);
|
|
19682
|
+
} else {
|
|
19683
|
+
pendingDeps.set(contextConf.name, left - 1);
|
|
19684
|
+
}
|
|
19483
19685
|
}
|
|
19484
19686
|
yield scheduleNext();
|
|
19485
19687
|
});
|
|
19486
|
-
return function wrapResolve(
|
|
19487
|
-
return
|
|
19688
|
+
return function wrapResolve(_x4) {
|
|
19689
|
+
return _ref3.apply(this, arguments);
|
|
19488
19690
|
};
|
|
19489
19691
|
}();
|
|
19490
19692
|
var scheduleAsSerial = includesComputed;
|
|
19491
19693
|
function scheduleNext() {
|
|
19492
|
-
return
|
|
19694
|
+
return _scheduleNext2.apply(this, arguments);
|
|
19493
19695
|
}
|
|
19494
|
-
function
|
|
19495
|
-
|
|
19696
|
+
function _scheduleNext2() {
|
|
19697
|
+
_scheduleNext2 = _asyncToGenerator__default["default"](function* () {
|
|
19496
19698
|
var readyContexts = Array.from(dependencyMap.entries()).filter(predicateNextResolveFactory(pendingDeps, scheduleAsSerial)).map(entry => entry[0]).filter(contextConf => !processed.has(contextConf));
|
|
19497
19699
|
yield Promise.all(readyContexts.map(wrapResolve));
|
|
19498
19700
|
});
|
|
19499
|
-
return
|
|
19701
|
+
return _scheduleNext2.apply(this, arguments);
|
|
19500
19702
|
}
|
|
19501
19703
|
yield scheduleNext();
|
|
19502
19704
|
|
|
@@ -19518,19 +19720,33 @@
|
|
|
19518
19720
|
function syncResolveContextConcurrently(contextConfs, resolveContext) {
|
|
19519
19721
|
var keyword = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "CTX";
|
|
19520
19722
|
var dependencyMap = getDependencyMapOfContext(contextConfs, keyword);
|
|
19521
|
-
var pendingDeps = new
|
|
19723
|
+
var pendingDeps = new Map();
|
|
19724
|
+
for (var contextName of Array.from(dependencyMap.keys()).map(contextConf => contextConf.name)) {
|
|
19725
|
+
var _pendingDeps$get3;
|
|
19726
|
+
pendingDeps.set(contextName, ((_pendingDeps$get3 = pendingDeps.get(contextName)) !== null && _pendingDeps$get3 !== void 0 ? _pendingDeps$get3 : 0) + 1);
|
|
19727
|
+
}
|
|
19522
19728
|
var includesComputed = Array.from(dependencyMap.values()).some(stats => stats.includesComputed);
|
|
19523
19729
|
var scheduleAsSerial = includesComputed;
|
|
19524
19730
|
function scheduleNext() {
|
|
19525
19731
|
var dep = Array.from(dependencyMap.entries()).find(predicateNextResolveFactory(pendingDeps, scheduleAsSerial));
|
|
19526
19732
|
if (dep) {
|
|
19733
|
+
var _pendingDeps$get4;
|
|
19527
19734
|
var [_contextConf] = dep;
|
|
19528
19735
|
var resolved = resolveContext(_contextConf);
|
|
19529
19736
|
dependencyMap.delete(_contextConf);
|
|
19737
|
+
var left = (_pendingDeps$get4 = pendingDeps.get(_contextConf.name)) !== null && _pendingDeps$get4 !== void 0 ? _pendingDeps$get4 : 0;
|
|
19530
19738
|
if (resolved) {
|
|
19531
|
-
|
|
19739
|
+
pendingDeps.delete(_contextConf.name);
|
|
19740
|
+
if (left === 0) {
|
|
19532
19741
|
throw new Error("Duplicated context defined: ".concat(_contextConf.name));
|
|
19533
19742
|
}
|
|
19743
|
+
} else {
|
|
19744
|
+
// Assert: left >= 1
|
|
19745
|
+
if (left === 1) {
|
|
19746
|
+
pendingDeps.delete(_contextConf.name);
|
|
19747
|
+
} else {
|
|
19748
|
+
pendingDeps.set(_contextConf.name, left - 1);
|
|
19749
|
+
}
|
|
19534
19750
|
}
|
|
19535
19751
|
scheduleNext();
|
|
19536
19752
|
}
|
|
@@ -19556,51 +19772,24 @@
|
|
|
19556
19772
|
// So make them process sequentially, keep the same behavior as before.
|
|
19557
19773
|
scheduleAsSerial ? index === 0 :
|
|
19558
19774
|
// A context is ready when it has no pending dependencies.
|
|
19559
|
-
!entry[1].
|
|
19775
|
+
!entry[1].usedContexts.some(dep => pendingDeps.has(dep));
|
|
19560
19776
|
}
|
|
19561
19777
|
function getDependencyMapOfContext(contextConfs) {
|
|
19562
19778
|
var keyword = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "CTX";
|
|
19563
19779
|
var depsMap = new Map();
|
|
19564
19780
|
for (var _contextConf2 of contextConfs) {
|
|
19565
|
-
var stats =
|
|
19566
|
-
dependencies: [],
|
|
19567
|
-
includesComputed: false
|
|
19568
|
-
};
|
|
19569
|
-
if (!_contextConf2.property) {
|
|
19570
|
-
visitStoryboardExpressions([_contextConf2.if, _contextConf2.value, _contextConf2.resolve], beforeVisitContextFactory$1(stats, keyword), keyword);
|
|
19571
|
-
}
|
|
19781
|
+
var stats = collectContextUsage(_contextConf2.property ? null : [_contextConf2.if, _contextConf2.value, _contextConf2.resolve], keyword);
|
|
19572
19782
|
depsMap.set(_contextConf2, stats);
|
|
19573
19783
|
}
|
|
19574
19784
|
return depsMap;
|
|
19575
19785
|
}
|
|
19576
|
-
function beforeVisitContextFactory$1(stats, keyword) {
|
|
19577
|
-
return function beforeVisitContext(node, parent) {
|
|
19578
|
-
if (node.name === keyword) {
|
|
19579
|
-
var memberParent = parent[parent.length - 1];
|
|
19580
|
-
if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
|
|
19581
|
-
var memberNode = memberParent.node;
|
|
19582
|
-
var dep;
|
|
19583
|
-
if (!memberNode.computed && memberNode.property.type === "Identifier") {
|
|
19584
|
-
dep = memberNode.property.name;
|
|
19585
|
-
} else if (memberNode.computed && memberNode.property.type === "Literal" && typeof memberNode.property.value === "string") {
|
|
19586
|
-
dep = memberNode.property.value;
|
|
19587
|
-
} else {
|
|
19588
|
-
stats.includesComputed = true;
|
|
19589
|
-
}
|
|
19590
|
-
if (dep !== undefined && !stats.dependencies.includes(dep)) {
|
|
19591
|
-
stats.dependencies.push(dep);
|
|
19592
|
-
}
|
|
19593
|
-
}
|
|
19594
|
-
}
|
|
19595
|
-
};
|
|
19596
|
-
}
|
|
19597
19786
|
function detectCircularContexts(dependencyMap, keyword) {
|
|
19598
19787
|
var duplicatedMap = new Map(dependencyMap);
|
|
19599
19788
|
var pendingDeps = new Set(Array.from(duplicatedMap.keys()).map(contextConf => contextConf.name));
|
|
19600
19789
|
var next = () => {
|
|
19601
19790
|
var processedAtLeastOne = false;
|
|
19602
19791
|
for (var [_contextConf3, stats] of duplicatedMap.entries()) {
|
|
19603
|
-
if (!stats.
|
|
19792
|
+
if (!stats.usedContexts.some(dep => pendingDeps.has(dep))) {
|
|
19604
19793
|
duplicatedMap.delete(_contextConf3);
|
|
19605
19794
|
pendingDeps.delete(_contextConf3.name);
|
|
19606
19795
|
processedAtLeastOne = true;
|
|
@@ -19843,91 +20032,6 @@
|
|
|
19843
20032
|
return Object.freeze(object);
|
|
19844
20033
|
}
|
|
19845
20034
|
|
|
19846
|
-
/**
|
|
19847
|
-
* Get tracking CTX for an evaluable expression in `track context` mode.
|
|
19848
|
-
*
|
|
19849
|
-
* A `track context` mode is an evaluable expression which is a sequence expression
|
|
19850
|
-
* starting with the exact literal string expression of "track context".
|
|
19851
|
-
*
|
|
19852
|
-
* @param raw - A raw string, which must be checked by `isEvaluable` first.
|
|
19853
|
-
*
|
|
19854
|
-
* @returns
|
|
19855
|
-
*
|
|
19856
|
-
* Returns used CTXs if `track context` mode is enabled, or returns false if not enabled or
|
|
19857
|
-
* no CTX found.
|
|
19858
|
-
*
|
|
19859
|
-
* @example
|
|
19860
|
-
*
|
|
19861
|
-
* ```js
|
|
19862
|
-
* trackContext('<% "track context", [CTX.hello, CTX.world] %>');
|
|
19863
|
-
* // => ["hello", "world"]
|
|
19864
|
-
*
|
|
19865
|
-
* trackContext('<% [CTX.hello, CTX.world] %>');
|
|
19866
|
-
* // => false
|
|
19867
|
-
*
|
|
19868
|
-
* trackContext('<% "track context", DATA.any %>');
|
|
19869
|
-
* // => false
|
|
19870
|
-
* ```
|
|
19871
|
-
*/
|
|
19872
|
-
function trackContext(raw) {
|
|
19873
|
-
return track(raw, "track context", "CTX");
|
|
19874
|
-
}
|
|
19875
|
-
function trackState(raw) {
|
|
19876
|
-
return track(raw, "track state", "STATE");
|
|
19877
|
-
}
|
|
19878
|
-
function trackFormState(raw) {
|
|
19879
|
-
return track(raw, "track formstate", "FORM_STATE");
|
|
19880
|
-
}
|
|
19881
|
-
function trackUsedContext(data) {
|
|
19882
|
-
return trackUsed(data, "CTX");
|
|
19883
|
-
}
|
|
19884
|
-
function trackUsedState(data) {
|
|
19885
|
-
return trackUsed(data, "STATE");
|
|
19886
|
-
}
|
|
19887
|
-
function track(raw, trackText, variableName) {
|
|
19888
|
-
if (raw.includes(trackText)) {
|
|
19889
|
-
var contexts = new Set();
|
|
19890
|
-
var {
|
|
19891
|
-
expression
|
|
19892
|
-
} = preevaluate(raw, {
|
|
19893
|
-
withParent: true,
|
|
19894
|
-
hooks: {
|
|
19895
|
-
beforeVisitGlobal: beforeVisitContextFactory(contexts, variableName)
|
|
19896
|
-
}
|
|
19897
|
-
});
|
|
19898
|
-
var trackCtxExp;
|
|
19899
|
-
if (expression.type === "SequenceExpression" && (trackCtxExp = expression.expressions[0]) && trackCtxExp.type === "Literal" && trackCtxExp.value === trackText) {
|
|
19900
|
-
if (contexts.size > 0) {
|
|
19901
|
-
return Array.from(contexts);
|
|
19902
|
-
} else {
|
|
19903
|
-
// eslint-disable-next-line no-console
|
|
19904
|
-
console.warn("You are using \"".concat(trackText, "\" but no `").concat(variableName, "` usage found in your expression: ").concat(JSON.stringify(raw)));
|
|
19905
|
-
}
|
|
19906
|
-
}
|
|
19907
|
-
}
|
|
19908
|
-
return false;
|
|
19909
|
-
}
|
|
19910
|
-
function trackUsed(data, variableName) {
|
|
19911
|
-
var contexts = new Set();
|
|
19912
|
-
visitStoryboardExpressions(data, beforeVisitContextFactory(contexts, variableName), variableName);
|
|
19913
|
-
return Array.from(contexts);
|
|
19914
|
-
}
|
|
19915
|
-
function beforeVisitContextFactory(contexts, variableName) {
|
|
19916
|
-
return function beforeVisitContext(node, parent) {
|
|
19917
|
-
if (node.name === variableName) {
|
|
19918
|
-
var memberParent = parent[parent.length - 1];
|
|
19919
|
-
if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
|
|
19920
|
-
var memberNode = memberParent.node;
|
|
19921
|
-
if (!memberNode.computed && memberNode.property.type === "Identifier") {
|
|
19922
|
-
contexts.add(memberNode.property.name);
|
|
19923
|
-
} else if (memberNode.computed && memberNode.property.type === "Literal" && typeof memberNode.property.value === "string") {
|
|
19924
|
-
contexts.add(memberNode.property.value);
|
|
19925
|
-
}
|
|
19926
|
-
}
|
|
19927
|
-
}
|
|
19928
|
-
};
|
|
19929
|
-
}
|
|
19930
|
-
|
|
19931
20035
|
// The debounce function receives our function as a parameter
|
|
19932
20036
|
function debounceByAnimationFrame(fn) {
|
|
19933
20037
|
// This holds the requestAnimationFrame reference, so we can cancel it if we wish
|
|
@@ -20242,6 +20346,7 @@
|
|
|
20242
20346
|
exports.asyncProcessBrick = asyncProcessBrick;
|
|
20243
20347
|
exports.asyncProcessStoryboard = asyncProcessStoryboard;
|
|
20244
20348
|
exports.collectBricksByCustomTemplates = collectBricksByCustomTemplates;
|
|
20349
|
+
exports.collectContextUsage = collectContextUsage;
|
|
20245
20350
|
exports.computeConstantCondition = computeConstantCondition;
|
|
20246
20351
|
exports.computeRealRoutePath = computeRealRoutePath;
|
|
20247
20352
|
exports.convertValueByPrecision = convertValueByPrecision;
|
|
@@ -20249,6 +20354,7 @@
|
|
|
20249
20354
|
exports.createProviderClass = createProviderClass;
|
|
20250
20355
|
exports.debounceByAnimationFrame = debounceByAnimationFrame;
|
|
20251
20356
|
exports.deepFreeze = deepFreeze;
|
|
20357
|
+
exports.deferResolveContextConcurrently = deferResolveContextConcurrently;
|
|
20252
20358
|
exports.formatValue = formatValue;
|
|
20253
20359
|
exports.getDependencyMapOfContext = getDependencyMapOfContext;
|
|
20254
20360
|
exports.getDepsOfTemplates = getDepsOfTemplates;
|