@next-core/brick-utils 2.45.16 → 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.esm.js CHANGED
@@ -19558,7 +19558,13 @@ function collectContextUsage(data, variableName) {
19558
19558
  function deferResolveContextConcurrently(contextConfs, resolveContext) {
19559
19559
  var keyword = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "CTX";
19560
19560
  var dependencyMap = getDependencyMapOfContext(contextConfs, keyword);
19561
- var pendingDeps = new Set(Array.from(dependencyMap.keys()).map(contextConf => contextConf.name));
19561
+ // There maybe multiple context confs for a specific name, since there are conditional contexts.
19562
+ // This is a map of how many pending context confs for each context name.
19563
+ var pendingDeps = new Map();
19564
+ for (var contextName of Array.from(dependencyMap.keys()).map(contextConf => contextConf.name)) {
19565
+ var _pendingDeps$get;
19566
+ pendingDeps.set(contextName, ((_pendingDeps$get = pendingDeps.get(contextName)) !== null && _pendingDeps$get !== void 0 ? _pendingDeps$get : 0) + 1);
19567
+ }
19562
19568
  var includesComputed = Array.from(dependencyMap.values()).some(stats => stats.includesComputed);
19563
19569
  var processed = new WeakSet();
19564
19570
  var deferredContexts = new Map();
@@ -19570,14 +19576,25 @@ function deferResolveContextConcurrently(contextConfs, resolveContext) {
19570
19576
  })]));
19571
19577
  var wrapResolve = /*#__PURE__*/function () {
19572
19578
  var _ref = _asyncToGenerator(function* (contextConf) {
19579
+ var _pendingDeps$get2;
19573
19580
  processed.add(contextConf);
19574
19581
  var resolved = yield resolveContext(contextConf);
19575
19582
  dependencyMap.delete(contextConf);
19583
+ var left = (_pendingDeps$get2 = pendingDeps.get(contextConf.name)) !== null && _pendingDeps$get2 !== void 0 ? _pendingDeps$get2 : 0;
19576
19584
  if (resolved) {
19577
19585
  deferredContexts.get(contextConf.name).resolve();
19578
- if (!pendingDeps.delete(contextConf.name)) {
19586
+ pendingDeps.delete(contextConf.name);
19587
+ if (left === 0) {
19579
19588
  throw new Error("Duplicated context defined: ".concat(contextConf.name));
19580
19589
  }
19590
+ } else {
19591
+ // Assert: left >= 1
19592
+ if (left === 1) {
19593
+ deferredContexts.get(contextConf.name).resolve();
19594
+ pendingDeps.delete(contextConf.name);
19595
+ } else {
19596
+ pendingDeps.set(contextConf.name, left - 1);
19597
+ }
19581
19598
  }
19582
19599
  yield scheduleNext();
19583
19600
  });
@@ -19634,18 +19651,32 @@ function _resolveContextConcurrently() {
19634
19651
  _resolveContextConcurrently = _asyncToGenerator(function* (contextConfs, resolveContext) {
19635
19652
  var keyword = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "CTX";
19636
19653
  var dependencyMap = getDependencyMapOfContext(contextConfs, keyword);
19637
- var pendingDeps = new Set(Array.from(dependencyMap.keys()).map(contextConf => contextConf.name));
19654
+ var pendingDeps = new Map();
19655
+ for (var contextName of Array.from(dependencyMap.keys()).map(contextConf => contextConf.name)) {
19656
+ var _pendingDeps$get5;
19657
+ pendingDeps.set(contextName, ((_pendingDeps$get5 = pendingDeps.get(contextName)) !== null && _pendingDeps$get5 !== void 0 ? _pendingDeps$get5 : 0) + 1);
19658
+ }
19638
19659
  var includesComputed = Array.from(dependencyMap.values()).some(stats => stats.includesComputed);
19639
19660
  var processed = new WeakSet();
19640
19661
  var wrapResolve = /*#__PURE__*/function () {
19641
19662
  var _ref3 = _asyncToGenerator(function* (contextConf) {
19663
+ var _pendingDeps$get6;
19642
19664
  processed.add(contextConf);
19643
19665
  var resolved = yield resolveContext(contextConf);
19644
19666
  dependencyMap.delete(contextConf);
19667
+ var left = (_pendingDeps$get6 = pendingDeps.get(contextConf.name)) !== null && _pendingDeps$get6 !== void 0 ? _pendingDeps$get6 : 0;
19645
19668
  if (resolved) {
19646
- if (!pendingDeps.delete(contextConf.name)) {
19669
+ pendingDeps.delete(contextConf.name);
19670
+ if (left === 0) {
19647
19671
  throw new Error("Duplicated context defined: ".concat(contextConf.name));
19648
19672
  }
19673
+ } else {
19674
+ // Assert: left >= 1
19675
+ if (left === 1) {
19676
+ pendingDeps.delete(contextConf.name);
19677
+ } else {
19678
+ pendingDeps.set(contextConf.name, left - 1);
19679
+ }
19649
19680
  }
19650
19681
  yield scheduleNext();
19651
19682
  });
@@ -19684,19 +19715,33 @@ function _resolveContextConcurrently() {
19684
19715
  function syncResolveContextConcurrently(contextConfs, resolveContext) {
19685
19716
  var keyword = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "CTX";
19686
19717
  var dependencyMap = getDependencyMapOfContext(contextConfs, keyword);
19687
- var pendingDeps = new Set(Array.from(dependencyMap.keys()).map(contextConf => contextConf.name));
19718
+ var pendingDeps = new Map();
19719
+ for (var contextName of Array.from(dependencyMap.keys()).map(contextConf => contextConf.name)) {
19720
+ var _pendingDeps$get3;
19721
+ pendingDeps.set(contextName, ((_pendingDeps$get3 = pendingDeps.get(contextName)) !== null && _pendingDeps$get3 !== void 0 ? _pendingDeps$get3 : 0) + 1);
19722
+ }
19688
19723
  var includesComputed = Array.from(dependencyMap.values()).some(stats => stats.includesComputed);
19689
19724
  var scheduleAsSerial = includesComputed;
19690
19725
  function scheduleNext() {
19691
19726
  var dep = Array.from(dependencyMap.entries()).find(predicateNextResolveFactory(pendingDeps, scheduleAsSerial));
19692
19727
  if (dep) {
19728
+ var _pendingDeps$get4;
19693
19729
  var [_contextConf] = dep;
19694
19730
  var resolved = resolveContext(_contextConf);
19695
19731
  dependencyMap.delete(_contextConf);
19732
+ var left = (_pendingDeps$get4 = pendingDeps.get(_contextConf.name)) !== null && _pendingDeps$get4 !== void 0 ? _pendingDeps$get4 : 0;
19696
19733
  if (resolved) {
19697
- if (!pendingDeps.delete(_contextConf.name)) {
19734
+ pendingDeps.delete(_contextConf.name);
19735
+ if (left === 0) {
19698
19736
  throw new Error("Duplicated context defined: ".concat(_contextConf.name));
19699
19737
  }
19738
+ } else {
19739
+ // Assert: left >= 1
19740
+ if (left === 1) {
19741
+ pendingDeps.delete(_contextConf.name);
19742
+ } else {
19743
+ pendingDeps.set(_contextConf.name, left - 1);
19744
+ }
19700
19745
  }
19701
19746
  scheduleNext();
19702
19747
  }