@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.
@@ -19563,7 +19563,13 @@
19563
19563
  function deferResolveContextConcurrently(contextConfs, resolveContext) {
19564
19564
  var keyword = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "CTX";
19565
19565
  var dependencyMap = getDependencyMapOfContext(contextConfs, keyword);
19566
- var pendingDeps = new Set(Array.from(dependencyMap.keys()).map(contextConf => contextConf.name));
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
+ }
19567
19573
  var includesComputed = Array.from(dependencyMap.values()).some(stats => stats.includesComputed);
19568
19574
  var processed = new WeakSet();
19569
19575
  var deferredContexts = new Map();
@@ -19575,14 +19581,25 @@
19575
19581
  })]));
19576
19582
  var wrapResolve = /*#__PURE__*/function () {
19577
19583
  var _ref = _asyncToGenerator__default["default"](function* (contextConf) {
19584
+ var _pendingDeps$get2;
19578
19585
  processed.add(contextConf);
19579
19586
  var resolved = yield resolveContext(contextConf);
19580
19587
  dependencyMap.delete(contextConf);
19588
+ var left = (_pendingDeps$get2 = pendingDeps.get(contextConf.name)) !== null && _pendingDeps$get2 !== void 0 ? _pendingDeps$get2 : 0;
19581
19589
  if (resolved) {
19582
19590
  deferredContexts.get(contextConf.name).resolve();
19583
- if (!pendingDeps.delete(contextConf.name)) {
19591
+ pendingDeps.delete(contextConf.name);
19592
+ if (left === 0) {
19584
19593
  throw new Error("Duplicated context defined: ".concat(contextConf.name));
19585
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
+ }
19586
19603
  }
19587
19604
  yield scheduleNext();
19588
19605
  });
@@ -19639,18 +19656,32 @@
19639
19656
  _resolveContextConcurrently = _asyncToGenerator__default["default"](function* (contextConfs, resolveContext) {
19640
19657
  var keyword = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "CTX";
19641
19658
  var dependencyMap = getDependencyMapOfContext(contextConfs, keyword);
19642
- var pendingDeps = new Set(Array.from(dependencyMap.keys()).map(contextConf => contextConf.name));
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
+ }
19643
19664
  var includesComputed = Array.from(dependencyMap.values()).some(stats => stats.includesComputed);
19644
19665
  var processed = new WeakSet();
19645
19666
  var wrapResolve = /*#__PURE__*/function () {
19646
19667
  var _ref3 = _asyncToGenerator__default["default"](function* (contextConf) {
19668
+ var _pendingDeps$get6;
19647
19669
  processed.add(contextConf);
19648
19670
  var resolved = yield resolveContext(contextConf);
19649
19671
  dependencyMap.delete(contextConf);
19672
+ var left = (_pendingDeps$get6 = pendingDeps.get(contextConf.name)) !== null && _pendingDeps$get6 !== void 0 ? _pendingDeps$get6 : 0;
19650
19673
  if (resolved) {
19651
- if (!pendingDeps.delete(contextConf.name)) {
19674
+ pendingDeps.delete(contextConf.name);
19675
+ if (left === 0) {
19652
19676
  throw new Error("Duplicated context defined: ".concat(contextConf.name));
19653
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
+ }
19654
19685
  }
19655
19686
  yield scheduleNext();
19656
19687
  });
@@ -19689,19 +19720,33 @@
19689
19720
  function syncResolveContextConcurrently(contextConfs, resolveContext) {
19690
19721
  var keyword = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "CTX";
19691
19722
  var dependencyMap = getDependencyMapOfContext(contextConfs, keyword);
19692
- var pendingDeps = new Set(Array.from(dependencyMap.keys()).map(contextConf => contextConf.name));
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
+ }
19693
19728
  var includesComputed = Array.from(dependencyMap.values()).some(stats => stats.includesComputed);
19694
19729
  var scheduleAsSerial = includesComputed;
19695
19730
  function scheduleNext() {
19696
19731
  var dep = Array.from(dependencyMap.entries()).find(predicateNextResolveFactory(pendingDeps, scheduleAsSerial));
19697
19732
  if (dep) {
19733
+ var _pendingDeps$get4;
19698
19734
  var [_contextConf] = dep;
19699
19735
  var resolved = resolveContext(_contextConf);
19700
19736
  dependencyMap.delete(_contextConf);
19737
+ var left = (_pendingDeps$get4 = pendingDeps.get(_contextConf.name)) !== null && _pendingDeps$get4 !== void 0 ? _pendingDeps$get4 : 0;
19701
19738
  if (resolved) {
19702
- if (!pendingDeps.delete(_contextConf.name)) {
19739
+ pendingDeps.delete(_contextConf.name);
19740
+ if (left === 0) {
19703
19741
  throw new Error("Duplicated context defined: ".concat(_contextConf.name));
19704
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
+ }
19705
19750
  }
19706
19751
  scheduleNext();
19707
19752
  }