@player-ui/async-node-plugin 0.13.0-next.7 → 0.14.0-next.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/AsyncNodePlugin.native.js +327 -128
- package/dist/AsyncNodePlugin.native.js.map +1 -1
- package/dist/cjs/index.cjs +199 -20
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +199 -18
- package/dist/index.mjs +199 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/transform.test.ts.snap +1 -0
- package/src/__tests__/createAsyncTransform.test.ts +215 -0
- package/src/__tests__/index.test.ts +94 -13
- package/src/__tests__/transform.bench.ts +177 -0
- package/src/createAsyncTransform.ts +91 -0
- package/src/index.ts +93 -13
- package/src/transform.ts +5 -2
- package/src/types.ts +1 -0
- package/src/utils/__tests__/extractNodeFromPath.test.ts +181 -0
- package/src/utils/__tests__/traverseAndReplace.test.ts +182 -0
- package/src/utils/__tests__/unwrapAsset.test.ts +65 -0
- package/src/utils/extractNodeFromPath.ts +56 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/traverseAndReplace.ts +34 -0
- package/src/utils/unwrapAsset.ts +16 -0
- package/types/createAsyncTransform.d.ts +24 -0
- package/types/index.d.ts +16 -1
- package/types/transform.d.ts +2 -1
- package/types/types.d.ts +1 -1
- package/types/utils/extractNodeFromPath.d.ts +4 -0
- package/types/utils/index.d.ts +4 -0
- package/types/utils/traverseAndReplace.d.ts +4 -0
- package/types/utils/unwrapAsset.d.ts +3 -0
|
@@ -1454,22 +1454,6 @@ var AsyncNodePlugin = function() {
|
|
|
1454
1454
|
}
|
|
1455
1455
|
});
|
|
1456
1456
|
};
|
|
1457
|
-
var unpackNode = function unpackNode(item) {
|
|
1458
|
-
var _item_children_, _item_children, _item_children_1, _item_children1;
|
|
1459
|
-
var unpacked = [];
|
|
1460
|
-
if ("children" in item && ((_item_children = item.children) === null || _item_children === void 0 ? void 0 : (_item_children_ = _item_children[0]) === null || _item_children_ === void 0 ? void 0 : _item_children_.value.type) === "asset" && ((_item_children1 = item.children) === null || _item_children1 === void 0 ? void 0 : (_item_children_1 = _item_children1[0]) === null || _item_children_1 === void 0 ? void 0 : _item_children_1.value).children) {
|
|
1461
|
-
var _item_children__value_children_, _item_children__value_children, _item_children_2, _item_children2;
|
|
1462
|
-
if (((_item_children__value_children = ((_item_children2 = item.children) === null || _item_children2 === void 0 ? void 0 : (_item_children_2 = _item_children2[0]) === null || _item_children_2 === void 0 ? void 0 : _item_children_2.value).children) === null || _item_children__value_children === void 0 ? void 0 : (_item_children__value_children_ = _item_children__value_children[0]) === null || _item_children__value_children_ === void 0 ? void 0 : _item_children__value_children_.value.type) === "multi-node") {
|
|
1463
|
-
var _item_children__value_children_1, _item_children__value_children1, _item_children_3, _item_children3;
|
|
1464
|
-
((_item_children__value_children1 = ((_item_children3 = item.children) === null || _item_children3 === void 0 ? void 0 : (_item_children_3 = _item_children3[0]) === null || _item_children_3 === void 0 ? void 0 : _item_children_3.value).children) === null || _item_children__value_children1 === void 0 ? void 0 : (_item_children__value_children_1 = _item_children__value_children1[0]) === null || _item_children__value_children_1 === void 0 ? void 0 : _item_children__value_children_1.value).values.forEach(function(value) {
|
|
1465
|
-
unpacked.push(value);
|
|
1466
|
-
});
|
|
1467
|
-
}
|
|
1468
|
-
} else {
|
|
1469
|
-
unpacked.push(item);
|
|
1470
|
-
}
|
|
1471
|
-
return unpacked;
|
|
1472
|
-
};
|
|
1473
1457
|
var hasSomethingToResolve = function hasSomethingToResolve(str) {
|
|
1474
1458
|
return bindingResolveLookup(str) || expressionResolveLookup(str);
|
|
1475
1459
|
};
|
|
@@ -1718,7 +1702,7 @@ var AsyncNodePlugin = function() {
|
|
|
1718
1702
|
exports.merge = merge;
|
|
1719
1703
|
exports.mergeDeep = mergeDeep;
|
|
1720
1704
|
exports.mergeIn = mergeIn;
|
|
1721
|
-
exports.omit =
|
|
1705
|
+
exports.omit = omit3;
|
|
1722
1706
|
exports.addDefaults = addDefaults;
|
|
1723
1707
|
exports.default = void 0;
|
|
1724
1708
|
var INVALID_ARGS = "INVALID_ARGS";
|
|
@@ -1892,7 +1876,7 @@ var AsyncNodePlugin = function() {
|
|
|
1892
1876
|
}
|
|
1893
1877
|
return setIn8(a, path, nextVal);
|
|
1894
1878
|
}
|
|
1895
|
-
function
|
|
1879
|
+
function omit3(obj, attrs) {
|
|
1896
1880
|
var omitList = Array.isArray(attrs) ? attrs : [
|
|
1897
1881
|
attrs
|
|
1898
1882
|
];
|
|
@@ -1978,7 +1962,7 @@ var AsyncNodePlugin = function() {
|
|
|
1978
1962
|
merge: merge,
|
|
1979
1963
|
mergeDeep: mergeDeep,
|
|
1980
1964
|
mergeIn: mergeIn,
|
|
1981
|
-
omit:
|
|
1965
|
+
omit: omit3,
|
|
1982
1966
|
addDefaults: addDefaults
|
|
1983
1967
|
};
|
|
1984
1968
|
var _default = timm;
|
|
@@ -2109,6 +2093,9 @@ var AsyncNodePlugin = function() {
|
|
|
2109
2093
|
},
|
|
2110
2094
|
asyncTransform: function() {
|
|
2111
2095
|
return asyncTransform;
|
|
2096
|
+
},
|
|
2097
|
+
createAsyncTransform: function() {
|
|
2098
|
+
return createAsyncTransform;
|
|
2112
2099
|
}
|
|
2113
2100
|
});
|
|
2114
2101
|
var InterceptionManager = /*#__PURE__*/ function() {
|
|
@@ -2799,6 +2786,7 @@ var AsyncNodePlugin = function() {
|
|
|
2799
2786
|
}
|
|
2800
2787
|
};
|
|
2801
2788
|
var identifier = function() {
|
|
2789
|
+
var allowBoolValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
2802
2790
|
if (!isIdentifierChar(ch)) {
|
|
2803
2791
|
return;
|
|
2804
2792
|
}
|
|
@@ -2809,6 +2797,14 @@ var AsyncNodePlugin = function() {
|
|
|
2809
2797
|
}
|
|
2810
2798
|
value += ch;
|
|
2811
2799
|
}
|
|
2800
|
+
if (allowBoolValue) {
|
|
2801
|
+
if (value === "true") {
|
|
2802
|
+
return toValue(true);
|
|
2803
|
+
}
|
|
2804
|
+
if (value === "false") {
|
|
2805
|
+
return toValue(false);
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2812
2808
|
if (value) {
|
|
2813
2809
|
var maybeNumber = Number(value);
|
|
2814
2810
|
value = isNaN(maybeNumber) ? value : maybeNumber;
|
|
@@ -2857,8 +2853,9 @@ var AsyncNodePlugin = function() {
|
|
|
2857
2853
|
}
|
|
2858
2854
|
};
|
|
2859
2855
|
var simpleSegment = function() {
|
|
2856
|
+
var allowBoolValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
2860
2857
|
var _nestedPath, _ref;
|
|
2861
|
-
return (_ref = (_nestedPath = nestedPath()) !== null && _nestedPath !== void 0 ? _nestedPath : expression()) !== null && _ref !== void 0 ? _ref : identifier();
|
|
2858
|
+
return (_ref = (_nestedPath = nestedPath()) !== null && _nestedPath !== void 0 ? _nestedPath : expression()) !== null && _ref !== void 0 ? _ref : identifier(allowBoolValue);
|
|
2862
2859
|
};
|
|
2863
2860
|
var segment = function() {
|
|
2864
2861
|
var segments = [];
|
|
@@ -2873,6 +2870,7 @@ var AsyncNodePlugin = function() {
|
|
|
2873
2870
|
return toConcatenatedNode(segments);
|
|
2874
2871
|
};
|
|
2875
2872
|
var optionallyQuotedSegment = function() {
|
|
2873
|
+
var allowBoolValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
2876
2874
|
whitespace();
|
|
2877
2875
|
if (ch === SINGLE_QUOTE || ch === DOUBLE_QUOTE) {
|
|
2878
2876
|
var singleQuote = ch === SINGLE_QUOTE;
|
|
@@ -2881,7 +2879,7 @@ var AsyncNodePlugin = function() {
|
|
|
2881
2879
|
next(singleQuote ? SINGLE_QUOTE : DOUBLE_QUOTE);
|
|
2882
2880
|
return id;
|
|
2883
2881
|
}
|
|
2884
|
-
return simpleSegment();
|
|
2882
|
+
return simpleSegment(allowBoolValue);
|
|
2885
2883
|
};
|
|
2886
2884
|
var equals = function() {
|
|
2887
2885
|
if (ch !== EQUALS) {
|
|
@@ -2901,7 +2899,7 @@ var AsyncNodePlugin = function() {
|
|
|
2901
2899
|
whitespace();
|
|
2902
2900
|
if (equals()) {
|
|
2903
2901
|
whitespace();
|
|
2904
|
-
var second = optionallyQuotedSegment();
|
|
2902
|
+
var second = optionallyQuotedSegment(true);
|
|
2905
2903
|
value = toQuery(value, second);
|
|
2906
2904
|
whitespace();
|
|
2907
2905
|
}
|
|
@@ -3089,7 +3087,7 @@ var AsyncNodePlugin = function() {
|
|
|
3089
3087
|
appendPathSegments(getValueForNode(resolvedNode));
|
|
3090
3088
|
break;
|
|
3091
3089
|
case "Value":
|
|
3092
|
-
appendPathSegments(resolvedNode.value);
|
|
3090
|
+
appendPathSegments(typeof resolvedNode.value === "boolean" ? String(resolvedNode.value) : resolvedNode.value);
|
|
3093
3091
|
break;
|
|
3094
3092
|
case "Query":
|
|
3095
3093
|
{
|
|
@@ -4669,23 +4667,8 @@ var AsyncNodePlugin = function() {
|
|
|
4669
4667
|
function Parser() {
|
|
4670
4668
|
_class_call_check(this, Parser);
|
|
4671
4669
|
this.hooks = {
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
*
|
|
4675
|
-
* @param value - The object we're are about to parse
|
|
4676
|
-
* @returns - A new value to parse.
|
|
4677
|
-
* If undefined, the original value is used.
|
|
4678
|
-
* If null, we stop parsing this node.
|
|
4679
|
-
*/ onParseObject: new SyncWaterfallHook(),
|
|
4680
|
-
/**
|
|
4681
|
-
* A callback to interact with an AST _after_ we parse it into the AST
|
|
4682
|
-
*
|
|
4683
|
-
* @param value - The object we parsed
|
|
4684
|
-
* @param node - The AST node we generated
|
|
4685
|
-
* @returns - A new AST node to use
|
|
4686
|
-
* If undefined, the original value is used.
|
|
4687
|
-
* If null, we ignore this node all together
|
|
4688
|
-
*/ onCreateASTNode: new SyncWaterfallHook(),
|
|
4670
|
+
onParseObject: new SyncWaterfallHook(),
|
|
4671
|
+
onCreateASTNode: new SyncWaterfallHook(),
|
|
4689
4672
|
parseNode: new SyncBailHook()
|
|
4690
4673
|
};
|
|
4691
4674
|
}
|
|
@@ -4827,20 +4810,14 @@ var AsyncNodePlugin = function() {
|
|
|
4827
4810
|
function Resolver(root, options) {
|
|
4828
4811
|
_class_call_check(this, Resolver);
|
|
4829
4812
|
this.hooks = {
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
*/ resolve: new SyncWaterfallHook(),
|
|
4839
|
-
/**
|
|
4840
|
-
* A hook to transform the resolved value of an AST node.
|
|
4841
|
-
* This runs _after_ all children nodes are resolved
|
|
4842
|
-
*/ afterResolve: new SyncWaterfallHook(),
|
|
4843
|
-
/** Called at the very end of a node's tree being updated */ afterNodeUpdate: new SyncHook()
|
|
4813
|
+
skipResolve: new SyncWaterfallHook(),
|
|
4814
|
+
beforeUpdate: new SyncHook(),
|
|
4815
|
+
afterUpdate: new SyncHook(),
|
|
4816
|
+
resolveOptions: new SyncWaterfallHook(),
|
|
4817
|
+
beforeResolve: new SyncWaterfallHook(),
|
|
4818
|
+
resolve: new SyncWaterfallHook(),
|
|
4819
|
+
afterResolve: new SyncWaterfallHook(),
|
|
4820
|
+
afterNodeUpdate: new SyncHook()
|
|
4844
4821
|
};
|
|
4845
4822
|
this.root = root;
|
|
4846
4823
|
this.options = options;
|
|
@@ -4848,6 +4825,7 @@ var AsyncNodePlugin = function() {
|
|
|
4848
4825
|
this.ASTMap = /* @__PURE__ */ new Map();
|
|
4849
4826
|
this.logger = options.logger;
|
|
4850
4827
|
this.idCache = /* @__PURE__ */ new Set();
|
|
4828
|
+
this.AsyncIdMap = /* @__PURE__ */ new Map();
|
|
4851
4829
|
}
|
|
4852
4830
|
_create_class(Resolver, [
|
|
4853
4831
|
{
|
|
@@ -4858,13 +4836,27 @@ var AsyncNodePlugin = function() {
|
|
|
4858
4836
|
},
|
|
4859
4837
|
{
|
|
4860
4838
|
key: "update",
|
|
4861
|
-
value: function update(changes) {
|
|
4839
|
+
value: function update(changes, asyncChanges) {
|
|
4840
|
+
var _this = this;
|
|
4862
4841
|
this.hooks.beforeUpdate.call(changes);
|
|
4863
4842
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
4864
4843
|
this.idCache.clear();
|
|
4865
4844
|
var prevASTMap = new Map(this.ASTMap);
|
|
4866
4845
|
this.ASTMap.clear();
|
|
4867
|
-
var
|
|
4846
|
+
var prevAsyncIdMap = new Map(this.AsyncIdMap);
|
|
4847
|
+
var nextAsyncIdMap = /* @__PURE__ */ new Map();
|
|
4848
|
+
asyncChanges === null || asyncChanges === void 0 ? void 0 : asyncChanges.forEach(function(id) {
|
|
4849
|
+
var current = prevAsyncIdMap.get(id);
|
|
4850
|
+
while(current && prevASTMap.has(current)){
|
|
4851
|
+
var next = prevASTMap.get(current);
|
|
4852
|
+
if (next && _this.resolveCache.has(next)) {
|
|
4853
|
+
_this.resolveCache.delete(next);
|
|
4854
|
+
}
|
|
4855
|
+
current = current.parent;
|
|
4856
|
+
}
|
|
4857
|
+
});
|
|
4858
|
+
var updated = this.computeTree(this.root, void 0, changes, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, nextAsyncIdMap);
|
|
4859
|
+
this.AsyncIdMap = nextAsyncIdMap;
|
|
4868
4860
|
this.resolveCache = resolveCache;
|
|
4869
4861
|
this.hooks.afterUpdate.call(updated.value);
|
|
4870
4862
|
return updated.value;
|
|
@@ -4918,9 +4910,8 @@ var AsyncNodePlugin = function() {
|
|
|
4918
4910
|
},
|
|
4919
4911
|
{
|
|
4920
4912
|
key: "computeTree",
|
|
4921
|
-
value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap) {
|
|
4913
|
+
value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nextAsyncIdMap) {
|
|
4922
4914
|
var _this = this;
|
|
4923
|
-
var _partiallyResolvedParent_parent_parent, _partiallyResolvedParent_parent, _resolvedAST_parent, _partiallyResolvedParent_parent1;
|
|
4924
4915
|
var dependencyModel = new DependencyModel(options.data.model);
|
|
4925
4916
|
dependencyModel.trackSubset("core");
|
|
4926
4917
|
var depModelWithParser = withContext(withParser(dependencyModel, this.options.parseBinding));
|
|
@@ -4939,15 +4930,6 @@ var AsyncNodePlugin = function() {
|
|
|
4939
4930
|
var previousDeps = previousResult === null || previousResult === void 0 ? void 0 : previousResult.dependencies;
|
|
4940
4931
|
var dataChanged = caresAboutDataChanges(dataChanges, previousDeps);
|
|
4941
4932
|
var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged, node, resolveOptions);
|
|
4942
|
-
var clonedNode = _object_spread_props(_object_spread({}, this.cloneNode(node)), {
|
|
4943
|
-
parent: partiallyResolvedParent
|
|
4944
|
-
});
|
|
4945
|
-
var _this_hooks_beforeResolve_call;
|
|
4946
|
-
var resolvedAST = (_this_hooks_beforeResolve_call = this.hooks.beforeResolve.call(clonedNode, resolveOptions)) !== null && _this_hooks_beforeResolve_call !== void 0 ? _this_hooks_beforeResolve_call : {
|
|
4947
|
-
type: "empty"
|
|
4948
|
-
};
|
|
4949
|
-
var isNestedMultiNodeWithAsync = resolvedAST.type === "multi-node" && (partiallyResolvedParent === null || partiallyResolvedParent === void 0 ? void 0 : (_partiallyResolvedParent_parent = partiallyResolvedParent.parent) === null || _partiallyResolvedParent_parent === void 0 ? void 0 : (_partiallyResolvedParent_parent_parent = _partiallyResolvedParent_parent.parent) === null || _partiallyResolvedParent_parent_parent === void 0 ? void 0 : _partiallyResolvedParent_parent_parent.type) === "multi-node" && partiallyResolvedParent.parent.type === "value" && ((_resolvedAST_parent = resolvedAST.parent) === null || _resolvedAST_parent === void 0 ? void 0 : _resolvedAST_parent.type) === "asset" && resolvedAST.parent.value.id.includes("async");
|
|
4950
|
-
var isNestedMultiNode = resolvedAST.type === "multi-node" && (partiallyResolvedParent === null || partiallyResolvedParent === void 0 ? void 0 : (_partiallyResolvedParent_parent1 = partiallyResolvedParent.parent) === null || _partiallyResolvedParent_parent1 === void 0 ? void 0 : _partiallyResolvedParent_parent1.type) === "multi-node" && partiallyResolvedParent.type === "value";
|
|
4951
4933
|
if (previousResult && shouldUseLastValue) {
|
|
4952
4934
|
var update2 = _object_spread_props(_object_spread({}, previousResult), {
|
|
4953
4935
|
updated: false
|
|
@@ -4959,6 +4941,30 @@ var AsyncNodePlugin = function() {
|
|
|
4959
4941
|
updated: false
|
|
4960
4942
|
});
|
|
4961
4943
|
cacheUpdate.set(AST, resolvedUpdate);
|
|
4944
|
+
if (resolvedUpdate.node.type === "async") {
|
|
4945
|
+
nextAsyncIdMap.set(resolvedUpdate.node.id, resolvedUpdate.node);
|
|
4946
|
+
}
|
|
4947
|
+
var _resolvedUpdate_node_asyncNodesResolved;
|
|
4948
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4949
|
+
try {
|
|
4950
|
+
for(var _iterator = ((_resolvedUpdate_node_asyncNodesResolved = resolvedUpdate.node.asyncNodesResolved) !== null && _resolvedUpdate_node_asyncNodesResolved !== void 0 ? _resolvedUpdate_node_asyncNodesResolved : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
4951
|
+
var key = _step.value;
|
|
4952
|
+
nextAsyncIdMap.set(key, resolvedUpdate.node);
|
|
4953
|
+
}
|
|
4954
|
+
} catch (err) {
|
|
4955
|
+
_didIteratorError = true;
|
|
4956
|
+
_iteratorError = err;
|
|
4957
|
+
} finally{
|
|
4958
|
+
try {
|
|
4959
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4960
|
+
_iterator.return();
|
|
4961
|
+
}
|
|
4962
|
+
} finally{
|
|
4963
|
+
if (_didIteratorError) {
|
|
4964
|
+
throw _iteratorError;
|
|
4965
|
+
}
|
|
4966
|
+
}
|
|
4967
|
+
}
|
|
4962
4968
|
var handleChildNode = function(childNode) {
|
|
4963
4969
|
var _prevASTMap_get;
|
|
4964
4970
|
var originalChildNode = (_prevASTMap_get = prevASTMap.get(childNode)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : childNode;
|
|
@@ -4981,10 +4987,37 @@ var AsyncNodePlugin = function() {
|
|
|
4981
4987
|
repopulateASTMapFromCache(previousResult, node, rawParent);
|
|
4982
4988
|
return update2;
|
|
4983
4989
|
}
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
}
|
|
4987
|
-
|
|
4990
|
+
var clonedNode = _object_spread_props(_object_spread({}, this.cloneNode(node)), {
|
|
4991
|
+
parent: partiallyResolvedParent
|
|
4992
|
+
});
|
|
4993
|
+
var _this_hooks_beforeResolve_call;
|
|
4994
|
+
var resolvedAST = (_this_hooks_beforeResolve_call = this.hooks.beforeResolve.call(clonedNode, resolveOptions)) !== null && _this_hooks_beforeResolve_call !== void 0 ? _this_hooks_beforeResolve_call : {
|
|
4995
|
+
type: "empty"
|
|
4996
|
+
};
|
|
4997
|
+
resolvedAST.parent = partiallyResolvedParent;
|
|
4998
|
+
if (resolvedAST.type === "async") {
|
|
4999
|
+
nextAsyncIdMap.set(resolvedAST.id, resolvedAST);
|
|
5000
|
+
}
|
|
5001
|
+
var _resolvedAST_asyncNodesResolved;
|
|
5002
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5003
|
+
try {
|
|
5004
|
+
for(var _iterator = ((_resolvedAST_asyncNodesResolved = resolvedAST.asyncNodesResolved) !== null && _resolvedAST_asyncNodesResolved !== void 0 ? _resolvedAST_asyncNodesResolved : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5005
|
+
var id = _step.value;
|
|
5006
|
+
nextAsyncIdMap.set(id, resolvedAST);
|
|
5007
|
+
}
|
|
5008
|
+
} catch (err) {
|
|
5009
|
+
_didIteratorError = true;
|
|
5010
|
+
_iteratorError = err;
|
|
5011
|
+
} finally{
|
|
5012
|
+
try {
|
|
5013
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5014
|
+
_iterator.return();
|
|
5015
|
+
}
|
|
5016
|
+
} finally{
|
|
5017
|
+
if (_didIteratorError) {
|
|
5018
|
+
throw _iteratorError;
|
|
5019
|
+
}
|
|
5020
|
+
}
|
|
4988
5021
|
}
|
|
4989
5022
|
resolveOptions.node = resolvedAST;
|
|
4990
5023
|
this.ASTMap.set(resolvedAST, node);
|
|
@@ -4998,7 +5031,7 @@ var AsyncNodePlugin = function() {
|
|
|
4998
5031
|
if ("children" in resolvedAST) {
|
|
4999
5032
|
var _resolvedAST_children;
|
|
5000
5033
|
var newChildren = (_resolvedAST_children = resolvedAST.children) === null || _resolvedAST_children === void 0 ? void 0 : _resolvedAST_children.map(function(child) {
|
|
5001
|
-
var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap);
|
|
5034
|
+
var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
|
|
5002
5035
|
var childTreeDeps = computedChildTree.dependencies, childNode = computedChildTree.node, childUpdated = computedChildTree.updated, childValue = computedChildTree.value;
|
|
5003
5036
|
childTreeDeps.forEach(function(binding) {
|
|
5004
5037
|
return childDependencies.add(binding);
|
|
@@ -5019,40 +5052,18 @@ var AsyncNodePlugin = function() {
|
|
|
5019
5052
|
resolvedAST.children = newChildren;
|
|
5020
5053
|
} else if (resolvedAST.type === "multi-node") {
|
|
5021
5054
|
var childValue = [];
|
|
5022
|
-
var rawParentToPassIn =
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
}).filter(function(index) {
|
|
5026
|
-
return index !== -1;
|
|
5027
|
-
});
|
|
5028
|
-
var newValues = resolvedAST.values.map(function(mValue) {
|
|
5029
|
-
var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap);
|
|
5055
|
+
var rawParentToPassIn = node;
|
|
5056
|
+
resolvedAST.values = resolvedAST.values.map(function(mValue) {
|
|
5057
|
+
var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
|
|
5030
5058
|
if (mTree.value !== void 0 && mTree.value !== null) {
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
}
|
|
5034
|
-
|
|
5035
|
-
|
|
5059
|
+
mTree.dependencies.forEach(function(bindingDep) {
|
|
5060
|
+
return childDependencies.add(bindingDep);
|
|
5061
|
+
});
|
|
5062
|
+
updated = updated || mTree.updated;
|
|
5063
|
+
childValue.push(mTree.value);
|
|
5036
5064
|
}
|
|
5037
|
-
mTree.dependencies.forEach(function(bindingDep) {
|
|
5038
|
-
return childDependencies.add(bindingDep);
|
|
5039
|
-
});
|
|
5040
|
-
updated = updated || mTree.updated;
|
|
5041
5065
|
return mTree.node;
|
|
5042
5066
|
});
|
|
5043
|
-
if (hasAsync.length > 0) {
|
|
5044
|
-
var copy = newValues;
|
|
5045
|
-
hasAsync.forEach(function(index) {
|
|
5046
|
-
var _copy;
|
|
5047
|
-
if (copy[index]) (_copy = copy).splice.apply(_copy, [
|
|
5048
|
-
index,
|
|
5049
|
-
1
|
|
5050
|
-
].concat(_to_consumable_array(unpackNode(copy[index]))));
|
|
5051
|
-
});
|
|
5052
|
-
resolvedAST.values = copy;
|
|
5053
|
-
} else {
|
|
5054
|
-
resolvedAST.values = newValues;
|
|
5055
|
-
}
|
|
5056
5067
|
resolved = childValue;
|
|
5057
5068
|
}
|
|
5058
5069
|
childDependencies.forEach(function(bindingDep) {
|
|
@@ -5073,7 +5084,7 @@ var AsyncNodePlugin = function() {
|
|
|
5073
5084
|
value: resolved,
|
|
5074
5085
|
dependencies: /* @__PURE__ */ new Set(_to_consumable_array(dependencyModel.getDependencies()).concat(_to_consumable_array(childDependencies)))
|
|
5075
5086
|
};
|
|
5076
|
-
this.hooks.afterNodeUpdate.call(node,
|
|
5087
|
+
this.hooks.afterNodeUpdate.call(node, rawParent, update);
|
|
5077
5088
|
cacheUpdate.set(node, update);
|
|
5078
5089
|
return update;
|
|
5079
5090
|
}
|
|
@@ -5081,15 +5092,6 @@ var AsyncNodePlugin = function() {
|
|
|
5081
5092
|
]);
|
|
5082
5093
|
return Resolver;
|
|
5083
5094
|
}();
|
|
5084
|
-
function unpackAndPush(item, initial) {
|
|
5085
|
-
if (item.asset.values && Array.isArray(item.asset.values)) {
|
|
5086
|
-
item.asset.values.forEach(function(i) {
|
|
5087
|
-
unpackAndPush(i, initial);
|
|
5088
|
-
});
|
|
5089
|
-
} else {
|
|
5090
|
-
initial.push(item);
|
|
5091
|
-
}
|
|
5092
|
-
}
|
|
5093
5095
|
var CrossfieldProvider = /*#__PURE__*/ function() {
|
|
5094
5096
|
function CrossfieldProvider(initialView, parser, logger) {
|
|
5095
5097
|
_class_call_check(this, CrossfieldProvider);
|
|
@@ -5157,9 +5159,11 @@ var AsyncNodePlugin = function() {
|
|
|
5157
5159
|
_create_class(ViewInstance, [
|
|
5158
5160
|
{
|
|
5159
5161
|
key: "updateAsync",
|
|
5160
|
-
value: function updateAsync() {
|
|
5162
|
+
value: function updateAsync(asyncNode) {
|
|
5161
5163
|
var _this_resolver;
|
|
5162
|
-
var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update()
|
|
5164
|
+
var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set([
|
|
5165
|
+
asyncNode
|
|
5166
|
+
]));
|
|
5163
5167
|
this.lastUpdate = update;
|
|
5164
5168
|
this.hooks.onUpdate.call(update);
|
|
5165
5169
|
}
|
|
@@ -5277,11 +5281,12 @@ var AsyncNodePlugin = function() {
|
|
|
5277
5281
|
*
|
|
5278
5282
|
* @param id - the id of async node. It should be identical for each async node
|
|
5279
5283
|
*/ function asyncNode(id) {
|
|
5280
|
-
var flatten2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
5284
|
+
var flatten2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true, onValueReceived = arguments.length > 2 ? arguments[2] : void 0;
|
|
5281
5285
|
return {
|
|
5282
5286
|
id: id,
|
|
5283
5287
|
type: "async",
|
|
5284
5288
|
flatten: flatten2,
|
|
5289
|
+
onValueReceived: onValueReceived,
|
|
5285
5290
|
value: {
|
|
5286
5291
|
type: "value",
|
|
5287
5292
|
value: {
|
|
@@ -5827,7 +5832,7 @@ var AsyncNodePlugin = function() {
|
|
|
5827
5832
|
key: "applyParser",
|
|
5828
5833
|
value: function applyParser(parser) {
|
|
5829
5834
|
parser.hooks.parseNode.tap("multi-node", function(obj, nodeType, options, childOptions) {
|
|
5830
|
-
if (childOptions
|
|
5835
|
+
if ((childOptions === void 0 || !hasTemplateKey(childOptions.key)) && Array.isArray(obj)) {
|
|
5831
5836
|
var values = obj.map(function(childVal) {
|
|
5832
5837
|
return parser.parseObject(childVal, "value", options);
|
|
5833
5838
|
}).filter(function(child) {
|
|
@@ -5838,7 +5843,7 @@ var AsyncNodePlugin = function() {
|
|
|
5838
5843
|
}
|
|
5839
5844
|
var multiNode = parser.createASTNode({
|
|
5840
5845
|
type: "multi-node",
|
|
5841
|
-
override: !hasTemplateValues(childOptions.parentObj, childOptions.key),
|
|
5846
|
+
override: childOptions !== void 0 && !hasTemplateValues(childOptions.parentObj, childOptions.key),
|
|
5842
5847
|
values: values
|
|
5843
5848
|
}, obj);
|
|
5844
5849
|
if (!multiNode) {
|
|
@@ -5849,7 +5854,7 @@ var AsyncNodePlugin = function() {
|
|
|
5849
5854
|
v.parent = multiNode;
|
|
5850
5855
|
});
|
|
5851
5856
|
}
|
|
5852
|
-
return [
|
|
5857
|
+
return childOptions === void 0 ? multiNode : [
|
|
5853
5858
|
{
|
|
5854
5859
|
path: _to_consumable_array(childOptions.path).concat([
|
|
5855
5860
|
childOptions.key
|
|
@@ -8047,9 +8052,11 @@ var AsyncNodePlugin = function() {
|
|
|
8047
8052
|
};
|
|
8048
8053
|
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/index.ts
|
|
8049
8054
|
var import_queue_microtask3 = __toESM(require_queue_microtask());
|
|
8050
|
-
var import_timm10 = __toESM(require_timm());
|
|
8051
8055
|
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/transform.ts
|
|
8052
8056
|
var asyncTransform = function(assetId, wrapperAssetType, asset, flatten2) {
|
|
8057
|
+
var path = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : [
|
|
8058
|
+
"values"
|
|
8059
|
+
];
|
|
8053
8060
|
var id = "async-" + assetId;
|
|
8054
8061
|
var asyncNode = Builder.asyncNode(id, flatten2);
|
|
8055
8062
|
var multiNode;
|
|
@@ -8064,11 +8071,142 @@ var AsyncNodePlugin = function() {
|
|
|
8064
8071
|
id: wrapperAssetType + "-" + id,
|
|
8065
8072
|
type: wrapperAssetType
|
|
8066
8073
|
});
|
|
8067
|
-
Builder.addChild(wrapperAsset,
|
|
8068
|
-
"values"
|
|
8069
|
-
], multiNode);
|
|
8074
|
+
Builder.addChild(wrapperAsset, path, multiNode);
|
|
8070
8075
|
return wrapperAsset;
|
|
8071
8076
|
};
|
|
8077
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/extractNodeFromPath.ts
|
|
8078
|
+
var getMatchValue = function(pathA, pathB) {
|
|
8079
|
+
if (pathA.length > pathB.length) {
|
|
8080
|
+
return 0;
|
|
8081
|
+
}
|
|
8082
|
+
var matchCount = 0;
|
|
8083
|
+
for(var i = 0; i < pathA.length; i++){
|
|
8084
|
+
if (pathA[i] === pathB[i]) {
|
|
8085
|
+
matchCount++;
|
|
8086
|
+
} else {
|
|
8087
|
+
return 0;
|
|
8088
|
+
}
|
|
8089
|
+
}
|
|
8090
|
+
return matchCount;
|
|
8091
|
+
};
|
|
8092
|
+
var extractNodeFromPath = function(node, path) {
|
|
8093
|
+
if (path === void 0 || path.length === 0) {
|
|
8094
|
+
return node;
|
|
8095
|
+
}
|
|
8096
|
+
if (!("children" in node && node.children)) {
|
|
8097
|
+
return void 0;
|
|
8098
|
+
}
|
|
8099
|
+
var matchResult = 0;
|
|
8100
|
+
var bestMatch;
|
|
8101
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
8102
|
+
try {
|
|
8103
|
+
for(var _iterator = node.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
8104
|
+
var child = _step.value;
|
|
8105
|
+
var matchValue = getMatchValue(child.path, path);
|
|
8106
|
+
if (matchValue > matchResult) {
|
|
8107
|
+
matchResult = matchValue;
|
|
8108
|
+
bestMatch = child;
|
|
8109
|
+
}
|
|
8110
|
+
}
|
|
8111
|
+
} catch (err) {
|
|
8112
|
+
_didIteratorError = true;
|
|
8113
|
+
_iteratorError = err;
|
|
8114
|
+
} finally{
|
|
8115
|
+
try {
|
|
8116
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
8117
|
+
_iterator.return();
|
|
8118
|
+
}
|
|
8119
|
+
} finally{
|
|
8120
|
+
if (_didIteratorError) {
|
|
8121
|
+
throw _iteratorError;
|
|
8122
|
+
}
|
|
8123
|
+
}
|
|
8124
|
+
}
|
|
8125
|
+
if (!bestMatch) {
|
|
8126
|
+
return void 0;
|
|
8127
|
+
}
|
|
8128
|
+
if (matchResult >= path.length) {
|
|
8129
|
+
return bestMatch.value;
|
|
8130
|
+
}
|
|
8131
|
+
return extractNodeFromPath(bestMatch.value, path.slice(matchResult));
|
|
8132
|
+
};
|
|
8133
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/traverseAndReplace.ts
|
|
8134
|
+
var traverseAndReplace = function(node, replaceFn) {
|
|
8135
|
+
if (node.type === NodeType.MultiNode) {
|
|
8136
|
+
var index = 0;
|
|
8137
|
+
while(index < node.values.length){
|
|
8138
|
+
var child = node.values[index];
|
|
8139
|
+
if (!child) {
|
|
8140
|
+
index++;
|
|
8141
|
+
continue;
|
|
8142
|
+
}
|
|
8143
|
+
var result = replaceFn(child);
|
|
8144
|
+
if (result.type === NodeType.MultiNode) {
|
|
8145
|
+
node.values = _to_consumable_array(node.values.slice(0, index)).concat(_to_consumable_array(result.values), _to_consumable_array(node.values.slice(index + 1)));
|
|
8146
|
+
} else {
|
|
8147
|
+
node.values[index] = result;
|
|
8148
|
+
index++;
|
|
8149
|
+
}
|
|
8150
|
+
}
|
|
8151
|
+
return node;
|
|
8152
|
+
}
|
|
8153
|
+
return replaceFn(node);
|
|
8154
|
+
};
|
|
8155
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/utils/unwrapAsset.ts
|
|
8156
|
+
var unwrapAsset = function(node) {
|
|
8157
|
+
var _node_children;
|
|
8158
|
+
if (node.type !== NodeType.Value) {
|
|
8159
|
+
return node;
|
|
8160
|
+
}
|
|
8161
|
+
var child = (_node_children = node.children) === null || _node_children === void 0 ? void 0 : _node_children.find(function(x) {
|
|
8162
|
+
return x.path.length === 1 && x.path[0] === "asset";
|
|
8163
|
+
});
|
|
8164
|
+
if (!child) {
|
|
8165
|
+
return node;
|
|
8166
|
+
}
|
|
8167
|
+
return child.value;
|
|
8168
|
+
};
|
|
8169
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/createAsyncTransform.ts
|
|
8170
|
+
var defaultGetNodeId = function(node) {
|
|
8171
|
+
return "async-".concat(node.value.id);
|
|
8172
|
+
};
|
|
8173
|
+
var createAsyncTransform = function(options) {
|
|
8174
|
+
var transformAssetType = options.transformAssetType, wrapperAssetType = options.wrapperAssetType, getNestedAsset = options.getNestedAsset, _options_getAsyncNodeId = options.getAsyncNodeId, getAsyncNodeId = _options_getAsyncNodeId === void 0 ? defaultGetNodeId : _options_getAsyncNodeId, _options_path = options.path, path = _options_path === void 0 ? [
|
|
8175
|
+
"values"
|
|
8176
|
+
] : _options_path, tmp = options.flatten, flatten2 = tmp === void 0 ? true : tmp;
|
|
8177
|
+
var replaceNode = function(node) {
|
|
8178
|
+
var unwrapped = unwrapAsset(node);
|
|
8179
|
+
if (unwrapped.type !== NodeType.Asset || unwrapped.value.type !== transformAssetType) {
|
|
8180
|
+
return node;
|
|
8181
|
+
}
|
|
8182
|
+
var transformed = asyncTransform2(unwrapped);
|
|
8183
|
+
var _extractNodeFromPath;
|
|
8184
|
+
return (_extractNodeFromPath = extractNodeFromPath(transformed, path)) !== null && _extractNodeFromPath !== void 0 ? _extractNodeFromPath : node;
|
|
8185
|
+
};
|
|
8186
|
+
var replacer = function(node) {
|
|
8187
|
+
return traverseAndReplace(node, replaceNode);
|
|
8188
|
+
};
|
|
8189
|
+
var asyncTransform2 = function(node) {
|
|
8190
|
+
var id = getAsyncNodeId(node);
|
|
8191
|
+
var asset = getNestedAsset === null || getNestedAsset === void 0 ? void 0 : getNestedAsset(node);
|
|
8192
|
+
var replaceFunction = flatten2 ? replacer : void 0;
|
|
8193
|
+
var asyncNode = Builder.asyncNode(id, flatten2, replaceFunction);
|
|
8194
|
+
var multiNode;
|
|
8195
|
+
if (asset) {
|
|
8196
|
+
var assetNode = Builder.assetWrapper(asset);
|
|
8197
|
+
multiNode = Builder.multiNode(assetNode, asyncNode);
|
|
8198
|
+
} else {
|
|
8199
|
+
multiNode = Builder.multiNode(asyncNode);
|
|
8200
|
+
}
|
|
8201
|
+
var wrapperAsset = Builder.asset({
|
|
8202
|
+
id: wrapperAssetType + "-" + id,
|
|
8203
|
+
type: wrapperAssetType
|
|
8204
|
+
});
|
|
8205
|
+
Builder.addChild(wrapperAsset, path, multiNode);
|
|
8206
|
+
return wrapperAsset;
|
|
8207
|
+
};
|
|
8208
|
+
return asyncTransform2;
|
|
8209
|
+
};
|
|
8072
8210
|
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/async-node/core/src/index.ts
|
|
8073
8211
|
var AsyncNodePluginSymbol = Symbol.for("AsyncNodePlugin");
|
|
8074
8212
|
var _AsyncNodePlugin = /*#__PURE__*/ function() {
|
|
@@ -8155,6 +8293,9 @@ var AsyncNodePlugin = function() {
|
|
|
8155
8293
|
*/ key: "parseNodeAndUpdate",
|
|
8156
8294
|
value: function parseNodeAndUpdate(node, context, result, options) {
|
|
8157
8295
|
var parsedNode = options.parseNode && result ? options.parseNode(result) : void 0;
|
|
8296
|
+
if (parsedNode && node.onValueReceived) {
|
|
8297
|
+
parsedNode = node.onValueReceived(parsedNode);
|
|
8298
|
+
}
|
|
8158
8299
|
this.handleAsyncUpdate(node, context, parsedNode);
|
|
8159
8300
|
}
|
|
8160
8301
|
},
|
|
@@ -8172,10 +8313,17 @@ var AsyncNodePlugin = function() {
|
|
|
8172
8313
|
var nodeResolveCache = context.nodeResolveCache, view = context.view;
|
|
8173
8314
|
if (nodeResolveCache.get(node.id) !== newNode) {
|
|
8174
8315
|
nodeResolveCache.set(node.id, newNode ? newNode : node);
|
|
8175
|
-
view.updateAsync();
|
|
8316
|
+
view.updateAsync(node.id);
|
|
8176
8317
|
}
|
|
8177
8318
|
}
|
|
8178
8319
|
},
|
|
8320
|
+
{
|
|
8321
|
+
key: "hasValidMapping",
|
|
8322
|
+
value: function hasValidMapping(node, context) {
|
|
8323
|
+
var nodeResolveCache = context.nodeResolveCache;
|
|
8324
|
+
return nodeResolveCache.has(node.id) && nodeResolveCache.get(node.id) !== node;
|
|
8325
|
+
}
|
|
8326
|
+
},
|
|
8179
8327
|
{
|
|
8180
8328
|
/**
|
|
8181
8329
|
* Handles the asynchronous API integration for resolving nodes.
|
|
@@ -8187,11 +8335,11 @@ var AsyncNodePlugin = function() {
|
|
|
8187
8335
|
var _this = this;
|
|
8188
8336
|
resolver.hooks.beforeResolve.tap(this.name, function(node, options) {
|
|
8189
8337
|
if (!_this.isAsync(node)) {
|
|
8190
|
-
return node;
|
|
8338
|
+
return node === null ? node : _this.resolveAsyncChildren(node, context);
|
|
8191
8339
|
}
|
|
8192
8340
|
var resolvedNode = context.nodeResolveCache.get(node.id);
|
|
8193
8341
|
if (resolvedNode !== void 0) {
|
|
8194
|
-
return resolvedNode;
|
|
8342
|
+
return _this.resolveAsyncChildren(resolvedNode, context);
|
|
8195
8343
|
}
|
|
8196
8344
|
if (context.inProgressNodes.has(node.id)) {
|
|
8197
8345
|
return node;
|
|
@@ -8204,6 +8352,52 @@ var AsyncNodePlugin = function() {
|
|
|
8204
8352
|
});
|
|
8205
8353
|
}
|
|
8206
8354
|
},
|
|
8355
|
+
{
|
|
8356
|
+
/**
|
|
8357
|
+
* Replaces child async nodes with their resolved content and flattens when necessary. Resolving the children directly helps manage the `parent` reference without needing as much work within the resolver itself.
|
|
8358
|
+
* Handles async node chains as well to make sure all applicable nodes can get flattened.
|
|
8359
|
+
* @param node - The node whose children need to be resolved.
|
|
8360
|
+
* @param context - the async plugin context needed to reach into the cache
|
|
8361
|
+
* @returns The same node but with async node children mapped to their resolved AST.
|
|
8362
|
+
*/ key: "resolveAsyncChildren",
|
|
8363
|
+
value: function resolveAsyncChildren(node, context) {
|
|
8364
|
+
var _this = this;
|
|
8365
|
+
var _node_asyncNodesResolved;
|
|
8366
|
+
var asyncNodesResolved = (_node_asyncNodesResolved = node.asyncNodesResolved) !== null && _node_asyncNodesResolved !== void 0 ? _node_asyncNodesResolved : [];
|
|
8367
|
+
node.asyncNodesResolved = asyncNodesResolved;
|
|
8368
|
+
if (node.type === NodeType.MultiNode) {
|
|
8369
|
+
var index = 0;
|
|
8370
|
+
while(index < node.values.length){
|
|
8371
|
+
var childNode = node.values[index];
|
|
8372
|
+
if ((childNode === null || childNode === void 0 ? void 0 : childNode.type) !== NodeType.Async || !this.hasValidMapping(childNode, context)) {
|
|
8373
|
+
index++;
|
|
8374
|
+
continue;
|
|
8375
|
+
}
|
|
8376
|
+
var mappedNode = context.nodeResolveCache.get(childNode.id);
|
|
8377
|
+
asyncNodesResolved.push(childNode.id);
|
|
8378
|
+
if (mappedNode.type === NodeType.MultiNode && childNode.flatten) {
|
|
8379
|
+
mappedNode.values.forEach(function(v) {
|
|
8380
|
+
return v.parent = node;
|
|
8381
|
+
});
|
|
8382
|
+
node.values = _to_consumable_array(node.values.slice(0, index)).concat(_to_consumable_array(mappedNode.values), _to_consumable_array(node.values.slice(index + 1)));
|
|
8383
|
+
} else {
|
|
8384
|
+
node.values[index] = mappedNode;
|
|
8385
|
+
mappedNode.parent = node;
|
|
8386
|
+
}
|
|
8387
|
+
}
|
|
8388
|
+
} else if ("children" in node) {
|
|
8389
|
+
var _node_children;
|
|
8390
|
+
(_node_children = node.children) === null || _node_children === void 0 ? void 0 : _node_children.forEach(function(c) {
|
|
8391
|
+
while(c.value.type === NodeType.Async && _this.hasValidMapping(c.value, context)){
|
|
8392
|
+
asyncNodesResolved.push(c.value.id);
|
|
8393
|
+
c.value = context.nodeResolveCache.get(c.value.id);
|
|
8394
|
+
c.value.parent = node;
|
|
8395
|
+
}
|
|
8396
|
+
});
|
|
8397
|
+
}
|
|
8398
|
+
return node;
|
|
8399
|
+
}
|
|
8400
|
+
},
|
|
8207
8401
|
{
|
|
8208
8402
|
key: "runAsyncNode",
|
|
8209
8403
|
value: function runAsyncNode(node, context, options) {
|
|
@@ -8272,7 +8466,7 @@ var AsyncNodePlugin = function() {
|
|
|
8272
8466
|
{
|
|
8273
8467
|
key: "isDeterminedAsync",
|
|
8274
8468
|
value: function isDeterminedAsync(obj) {
|
|
8275
|
-
return obj && Object.prototype.hasOwnProperty.call(obj, "async");
|
|
8469
|
+
return typeof obj === "object" && obj !== null && Object.prototype.hasOwnProperty.call(obj, "async");
|
|
8276
8470
|
}
|
|
8277
8471
|
},
|
|
8278
8472
|
{
|
|
@@ -8281,7 +8475,11 @@ var AsyncNodePlugin = function() {
|
|
|
8281
8475
|
var _this = this;
|
|
8282
8476
|
parser.hooks.parseNode.tap(this.name, function(obj, nodeType, options, childOptions) {
|
|
8283
8477
|
if (_this.isDeterminedAsync(obj)) {
|
|
8284
|
-
var
|
|
8478
|
+
var async = obj.async, flatten2 = obj.flatten, rest = _object_without_properties(obj, [
|
|
8479
|
+
"async",
|
|
8480
|
+
"flatten"
|
|
8481
|
+
]);
|
|
8482
|
+
var parsedAsync = parser.parseObject(rest, nodeType, options);
|
|
8285
8483
|
var parsedNodeId = getNodeID(parsedAsync);
|
|
8286
8484
|
if (parsedAsync === null || !parsedNodeId) {
|
|
8287
8485
|
return childOptions ? [] : null;
|
|
@@ -8289,7 +8487,8 @@ var AsyncNodePlugin = function() {
|
|
|
8289
8487
|
var asyncAST = parser.createASTNode({
|
|
8290
8488
|
id: parsedNodeId,
|
|
8291
8489
|
type: NodeType.Async,
|
|
8292
|
-
value: parsedAsync
|
|
8490
|
+
value: parsedAsync,
|
|
8491
|
+
flatten: flatten2
|
|
8293
8492
|
}, obj);
|
|
8294
8493
|
if (childOptions) {
|
|
8295
8494
|
return asyncAST ? [
|