@player-ui/async-node-plugin 0.15.0-next.4 → 0.15.0-next.6
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 +119 -113
- package/dist/AsyncNodePlugin.native.js.map +1 -1
- package/dist/cjs/index.cjs +34 -19
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +34 -19
- package/dist/index.mjs +34 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/index.test.ts +143 -0
- package/src/index.ts +48 -22
- package/types/index.d.ts +10 -2
|
@@ -4821,7 +4821,6 @@ var AsyncNodePlugin = function() {
|
|
|
4821
4821
|
this.ASTMap = /* @__PURE__ */ new Map();
|
|
4822
4822
|
this.logger = options.logger;
|
|
4823
4823
|
this.idCache = /* @__PURE__ */ new Set();
|
|
4824
|
-
this.AsyncIdMap = /* @__PURE__ */ new Map();
|
|
4825
4824
|
}
|
|
4826
4825
|
_create_class(Resolver, [
|
|
4827
4826
|
{
|
|
@@ -4832,27 +4831,44 @@ var AsyncNodePlugin = function() {
|
|
|
4832
4831
|
},
|
|
4833
4832
|
{
|
|
4834
4833
|
key: "update",
|
|
4835
|
-
value: function update(
|
|
4836
|
-
|
|
4837
|
-
this.hooks.beforeUpdate.call(changes);
|
|
4834
|
+
value: function update(dataChanges, nodeChanges) {
|
|
4835
|
+
this.hooks.beforeUpdate.call(dataChanges);
|
|
4838
4836
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
4839
4837
|
this.idCache.clear();
|
|
4840
4838
|
var prevASTMap = new Map(this.ASTMap);
|
|
4841
4839
|
this.ASTMap.clear();
|
|
4842
|
-
var
|
|
4843
|
-
var
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
var
|
|
4848
|
-
|
|
4849
|
-
|
|
4840
|
+
var realNodeChanges = /* @__PURE__ */ new Set();
|
|
4841
|
+
var _nodeChanges_values;
|
|
4842
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4843
|
+
try {
|
|
4844
|
+
for(var _iterator = ((_nodeChanges_values = nodeChanges === null || nodeChanges === void 0 ? void 0 : nodeChanges.values()) !== null && _nodeChanges_values !== void 0 ? _nodeChanges_values : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
4845
|
+
var node = _step.value;
|
|
4846
|
+
var current = node;
|
|
4847
|
+
while(current){
|
|
4848
|
+
var _prevASTMap_get;
|
|
4849
|
+
var original = (_prevASTMap_get = prevASTMap.get(current)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : current;
|
|
4850
|
+
if (realNodeChanges.has(original)) {
|
|
4851
|
+
break;
|
|
4852
|
+
}
|
|
4853
|
+
realNodeChanges.add(original);
|
|
4854
|
+
current = current.parent;
|
|
4850
4855
|
}
|
|
4851
|
-
current = current.parent;
|
|
4852
4856
|
}
|
|
4853
|
-
})
|
|
4854
|
-
|
|
4855
|
-
|
|
4857
|
+
} catch (err) {
|
|
4858
|
+
_didIteratorError = true;
|
|
4859
|
+
_iteratorError = err;
|
|
4860
|
+
} finally{
|
|
4861
|
+
try {
|
|
4862
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4863
|
+
_iterator.return();
|
|
4864
|
+
}
|
|
4865
|
+
} finally{
|
|
4866
|
+
if (_didIteratorError) {
|
|
4867
|
+
throw _iteratorError;
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4871
|
+
var updated = this.computeTree(this.root, void 0, dataChanges, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, realNodeChanges);
|
|
4856
4872
|
this.resolveCache = resolveCache;
|
|
4857
4873
|
this.hooks.afterUpdate.call(updated.value);
|
|
4858
4874
|
return updated.value;
|
|
@@ -4906,7 +4922,7 @@ var AsyncNodePlugin = function() {
|
|
|
4906
4922
|
},
|
|
4907
4923
|
{
|
|
4908
4924
|
key: "computeTree",
|
|
4909
|
-
value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap,
|
|
4925
|
+
value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nodeChanges) {
|
|
4910
4926
|
var _this = this;
|
|
4911
4927
|
var dependencyModel = new DependencyModel(options.data.model);
|
|
4912
4928
|
dependencyModel.trackSubset("core");
|
|
@@ -4924,8 +4940,9 @@ var AsyncNodePlugin = function() {
|
|
|
4924
4940
|
}), node);
|
|
4925
4941
|
var previousResult = this.getPreviousResult(node);
|
|
4926
4942
|
var previousDeps = previousResult === null || previousResult === void 0 ? void 0 : previousResult.dependencies;
|
|
4943
|
+
var isChanged = nodeChanges.has(node);
|
|
4927
4944
|
var dataChanged = caresAboutDataChanges(dataChanges, previousDeps);
|
|
4928
|
-
var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged, node, resolveOptions);
|
|
4945
|
+
var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged && !isChanged, node, resolveOptions);
|
|
4929
4946
|
if (previousResult && shouldUseLastValue) {
|
|
4930
4947
|
var update2 = _object_spread_props(_object_spread({}, previousResult), {
|
|
4931
4948
|
updated: false
|
|
@@ -4937,30 +4954,6 @@ var AsyncNodePlugin = function() {
|
|
|
4937
4954
|
updated: false
|
|
4938
4955
|
});
|
|
4939
4956
|
cacheUpdate.set(AST, resolvedUpdate);
|
|
4940
|
-
if (resolvedUpdate.node.type === "async") {
|
|
4941
|
-
nextAsyncIdMap.set(resolvedUpdate.node.id, resolvedUpdate.node);
|
|
4942
|
-
}
|
|
4943
|
-
var _resolvedUpdate_node_asyncNodesResolved;
|
|
4944
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4945
|
-
try {
|
|
4946
|
-
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){
|
|
4947
|
-
var key = _step.value;
|
|
4948
|
-
nextAsyncIdMap.set(key, resolvedUpdate.node);
|
|
4949
|
-
}
|
|
4950
|
-
} catch (err) {
|
|
4951
|
-
_didIteratorError = true;
|
|
4952
|
-
_iteratorError = err;
|
|
4953
|
-
} finally{
|
|
4954
|
-
try {
|
|
4955
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4956
|
-
_iterator.return();
|
|
4957
|
-
}
|
|
4958
|
-
} finally{
|
|
4959
|
-
if (_didIteratorError) {
|
|
4960
|
-
throw _iteratorError;
|
|
4961
|
-
}
|
|
4962
|
-
}
|
|
4963
|
-
}
|
|
4964
4957
|
var handleChildNode = function(childNode) {
|
|
4965
4958
|
var _prevASTMap_get;
|
|
4966
4959
|
var originalChildNode = (_prevASTMap_get = prevASTMap.get(childNode)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : childNode;
|
|
@@ -4991,30 +4984,6 @@ var AsyncNodePlugin = function() {
|
|
|
4991
4984
|
type: "empty"
|
|
4992
4985
|
};
|
|
4993
4986
|
resolvedAST.parent = partiallyResolvedParent;
|
|
4994
|
-
if (resolvedAST.type === "async") {
|
|
4995
|
-
nextAsyncIdMap.set(resolvedAST.id, resolvedAST);
|
|
4996
|
-
}
|
|
4997
|
-
var _resolvedAST_asyncNodesResolved;
|
|
4998
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4999
|
-
try {
|
|
5000
|
-
for(var _iterator = ((_resolvedAST_asyncNodesResolved = resolvedAST.asyncNodesResolved) !== null && _resolvedAST_asyncNodesResolved !== void 0 ? _resolvedAST_asyncNodesResolved : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5001
|
-
var id = _step.value;
|
|
5002
|
-
nextAsyncIdMap.set(id, resolvedAST);
|
|
5003
|
-
}
|
|
5004
|
-
} catch (err) {
|
|
5005
|
-
_didIteratorError = true;
|
|
5006
|
-
_iteratorError = err;
|
|
5007
|
-
} finally{
|
|
5008
|
-
try {
|
|
5009
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5010
|
-
_iterator.return();
|
|
5011
|
-
}
|
|
5012
|
-
} finally{
|
|
5013
|
-
if (_didIteratorError) {
|
|
5014
|
-
throw _iteratorError;
|
|
5015
|
-
}
|
|
5016
|
-
}
|
|
5017
|
-
}
|
|
5018
4987
|
resolveOptions.node = resolvedAST;
|
|
5019
4988
|
this.ASTMap.set(resolvedAST, node);
|
|
5020
4989
|
var resolved = this.hooks.resolve.call(void 0, resolvedAST, resolveOptions);
|
|
@@ -5027,7 +4996,7 @@ var AsyncNodePlugin = function() {
|
|
|
5027
4996
|
if ("children" in resolvedAST) {
|
|
5028
4997
|
var _resolvedAST_children;
|
|
5029
4998
|
var newChildren = (_resolvedAST_children = resolvedAST.children) === null || _resolvedAST_children === void 0 ? void 0 : _resolvedAST_children.map(function(child) {
|
|
5030
|
-
var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap,
|
|
4999
|
+
var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
|
|
5031
5000
|
var childTreeDeps = computedChildTree.dependencies, childNode = computedChildTree.node, childUpdated = computedChildTree.updated, childValue = computedChildTree.value;
|
|
5032
5001
|
childTreeDeps.forEach(function(binding) {
|
|
5033
5002
|
return childDependencies.add(binding);
|
|
@@ -5050,7 +5019,7 @@ var AsyncNodePlugin = function() {
|
|
|
5050
5019
|
var childValue = [];
|
|
5051
5020
|
var rawParentToPassIn = node;
|
|
5052
5021
|
resolvedAST.values = resolvedAST.values.map(function(mValue) {
|
|
5053
|
-
var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap,
|
|
5022
|
+
var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
|
|
5054
5023
|
if (mTree.value !== void 0 && mTree.value !== null) {
|
|
5055
5024
|
mTree.dependencies.forEach(function(bindingDep) {
|
|
5056
5025
|
return childDependencies.add(bindingDep);
|
|
@@ -5154,19 +5123,17 @@ var AsyncNodePlugin = function() {
|
|
|
5154
5123
|
}
|
|
5155
5124
|
_create_class(ViewInstance, [
|
|
5156
5125
|
{
|
|
5157
|
-
key: "updateAsync",
|
|
5126
|
+
/** @deprecated use ViewController.updateViewAST */ key: "updateAsync",
|
|
5158
5127
|
value: function updateAsync(asyncNode) {
|
|
5159
5128
|
var _this_resolver;
|
|
5160
|
-
var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(
|
|
5161
|
-
asyncNode
|
|
5162
|
-
]));
|
|
5129
|
+
var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update();
|
|
5163
5130
|
this.lastUpdate = update;
|
|
5164
5131
|
this.hooks.onUpdate.call(update);
|
|
5165
5132
|
}
|
|
5166
5133
|
},
|
|
5167
5134
|
{
|
|
5168
5135
|
key: "update",
|
|
5169
|
-
value: function update(changes) {
|
|
5136
|
+
value: function update(changes, nodeChanges) {
|
|
5170
5137
|
var _this_resolver;
|
|
5171
5138
|
if (this.rootNode === void 0) {
|
|
5172
5139
|
this.validationProvider = new CrossfieldProvider(this.initialView, this.resolverOptions.parseBinding, this.resolverOptions.logger);
|
|
@@ -5184,7 +5151,7 @@ var AsyncNodePlugin = function() {
|
|
|
5184
5151
|
}));
|
|
5185
5152
|
this.hooks.resolver.call(this.resolver);
|
|
5186
5153
|
}
|
|
5187
|
-
var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes);
|
|
5154
|
+
var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes, nodeChanges);
|
|
5188
5155
|
if (this.lastUpdate === update) {
|
|
5189
5156
|
return this.lastUpdate;
|
|
5190
5157
|
}
|
|
@@ -7102,6 +7069,10 @@ var AsyncNodePlugin = function() {
|
|
|
7102
7069
|
]);
|
|
7103
7070
|
return ValidationController;
|
|
7104
7071
|
}();
|
|
7072
|
+
var mergeSets = function(setA, setB) {
|
|
7073
|
+
var _setA_values, _setB_values;
|
|
7074
|
+
return /* @__PURE__ */ new Set(_to_consumable_array((_setA_values = setA === null || setA === void 0 ? void 0 : setA.values()) !== null && _setA_values !== void 0 ? _setA_values : []).concat(_to_consumable_array((_setB_values = setB === null || setB === void 0 ? void 0 : setB.values()) !== null && _setB_values !== void 0 ? _setB_values : [])));
|
|
7075
|
+
};
|
|
7105
7076
|
var ViewController = /*#__PURE__*/ function() {
|
|
7106
7077
|
function ViewController(initialViews, options) {
|
|
7107
7078
|
var _this = this;
|
|
@@ -7131,7 +7102,7 @@ var AsyncNodePlugin = function() {
|
|
|
7131
7102
|
var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
7132
7103
|
if (_this1.currentView) {
|
|
7133
7104
|
if (_this1.optimizeUpdates) {
|
|
7134
|
-
_this1.queueUpdate(updates, silent);
|
|
7105
|
+
_this1.queueUpdate(updates, void 0, silent);
|
|
7135
7106
|
} else {
|
|
7136
7107
|
_this1.currentView.update();
|
|
7137
7108
|
}
|
|
@@ -7161,25 +7132,26 @@ var AsyncNodePlugin = function() {
|
|
|
7161
7132
|
_create_class(ViewController, [
|
|
7162
7133
|
{
|
|
7163
7134
|
key: "queueUpdate",
|
|
7164
|
-
value: function queueUpdate(bindings) {
|
|
7135
|
+
value: function queueUpdate(bindings, nodes) {
|
|
7165
7136
|
var _this = this;
|
|
7166
|
-
var silent = arguments.length >
|
|
7167
|
-
|
|
7168
|
-
if ((_this_pendingUpdate = this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings) {
|
|
7169
|
-
this.pendingUpdate.changedBindings = /* @__PURE__ */ new Set(_to_consumable_array(this.pendingUpdate.changedBindings).concat(_to_consumable_array(bindings)));
|
|
7170
|
-
} else {
|
|
7137
|
+
var silent = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
7138
|
+
if (!this.pendingUpdate) {
|
|
7171
7139
|
this.pendingUpdate = {
|
|
7172
|
-
changedBindings: bindings,
|
|
7173
7140
|
scheduled: false
|
|
7174
7141
|
};
|
|
7175
7142
|
}
|
|
7143
|
+
this.pendingUpdate = _object_spread_props(_object_spread({}, this.pendingUpdate), {
|
|
7144
|
+
changedBindings: mergeSets(this.pendingUpdate.changedBindings, bindings),
|
|
7145
|
+
changedNodes: mergeSets(this.pendingUpdate.changedNodes, nodes)
|
|
7146
|
+
});
|
|
7176
7147
|
if (!this.pendingUpdate.scheduled && !silent) {
|
|
7177
7148
|
this.pendingUpdate.scheduled = true;
|
|
7178
7149
|
(0, import_queue_microtask2.default)(function() {
|
|
7179
|
-
var
|
|
7180
|
-
var
|
|
7150
|
+
var _this_currentView;
|
|
7151
|
+
var _this_pendingUpdate;
|
|
7152
|
+
var _ref = (_this_pendingUpdate = _this.pendingUpdate) !== null && _this_pendingUpdate !== void 0 ? _this_pendingUpdate : {}, changedBindings = _ref.changedBindings, changedNodes = _ref.changedNodes;
|
|
7181
7153
|
_this.pendingUpdate = void 0;
|
|
7182
|
-
(_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(
|
|
7154
|
+
(_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(changedBindings, changedNodes);
|
|
7183
7155
|
});
|
|
7184
7156
|
}
|
|
7185
7157
|
}
|
|
@@ -7256,6 +7228,15 @@ var AsyncNodePlugin = function() {
|
|
|
7256
7228
|
new MultiNodePlugin()
|
|
7257
7229
|
];
|
|
7258
7230
|
}
|
|
7231
|
+
},
|
|
7232
|
+
{
|
|
7233
|
+
/** Marks all AST nodes in `nodes` as changed, triggering the view to update and re-resolve these nodes. View updates are triggered asynchronously and many calls to this in a short time will batch into a single update.
|
|
7234
|
+
*
|
|
7235
|
+
* NOTE: In most cases view updates are handled automatically by changes to data or any other built-in functionality that would require a view update. Only call this function if absolutely necessary.
|
|
7236
|
+
*/ key: "updateViewAST",
|
|
7237
|
+
value: function updateViewAST(nodes) {
|
|
7238
|
+
this.queueUpdate(void 0, nodes);
|
|
7239
|
+
}
|
|
7259
7240
|
}
|
|
7260
7241
|
]);
|
|
7261
7242
|
return ViewController;
|
|
@@ -7628,8 +7609,8 @@ var AsyncNodePlugin = function() {
|
|
|
7628
7609
|
ref: Symbol("not-started"),
|
|
7629
7610
|
status: "not-started"
|
|
7630
7611
|
};
|
|
7631
|
-
var PLAYER_VERSION = true ? "0.15.0-next.
|
|
7632
|
-
var COMMIT = true ? "
|
|
7612
|
+
var PLAYER_VERSION = true ? "0.15.0-next.6" : "unknown";
|
|
7613
|
+
var COMMIT = true ? "9b22cee7078ed75d77b3c31bc306c758ea07da8b" : "unknown";
|
|
7633
7614
|
var _Player = /*#__PURE__*/ function() {
|
|
7634
7615
|
function _Player2(config) {
|
|
7635
7616
|
var _this = this;
|
|
@@ -8274,7 +8255,12 @@ var AsyncNodePlugin = function() {
|
|
|
8274
8255
|
key: "apply",
|
|
8275
8256
|
value: function apply(player) {
|
|
8276
8257
|
var _this = this;
|
|
8258
|
+
var _this_plugins;
|
|
8277
8259
|
this.playerInstance = player;
|
|
8260
|
+
(_this_plugins = this.plugins) === null || _this_plugins === void 0 ? void 0 : _this_plugins.forEach(function(plugin) {
|
|
8261
|
+
var _plugin_applyPlayer;
|
|
8262
|
+
(_plugin_applyPlayer = plugin.applyPlayer) === null || _plugin_applyPlayer === void 0 ? void 0 : _plugin_applyPlayer.call(plugin, player);
|
|
8263
|
+
});
|
|
8278
8264
|
player.hooks.viewController.tap(this.name, function(viewController) {
|
|
8279
8265
|
viewController.hooks.view.tap(_this.name, function(view) {
|
|
8280
8266
|
var _this_plugins;
|
|
@@ -8323,10 +8309,14 @@ var AsyncNodePlugin = function() {
|
|
|
8323
8309
|
* @param view The view instance where the node resides. This can be undefined if the view is not currently active.
|
|
8324
8310
|
*/ key: "handleAsyncUpdate",
|
|
8325
8311
|
value: function handleAsyncUpdate(node, context, newNode) {
|
|
8326
|
-
var nodeResolveCache = context.nodeResolveCache,
|
|
8312
|
+
var nodeResolveCache = context.nodeResolveCache, viewController = context.viewController, originalNodeCache = context.originalNodeCache;
|
|
8327
8313
|
if (nodeResolveCache.get(node.id) !== newNode) {
|
|
8328
8314
|
nodeResolveCache.set(node.id, newNode ? newNode : node);
|
|
8329
|
-
|
|
8315
|
+
var _originalNodeCache_get;
|
|
8316
|
+
var originalNode = (_originalNodeCache_get = originalNodeCache.get(node.id)) !== null && _originalNodeCache_get !== void 0 ? _originalNodeCache_get : /* @__PURE__ */ new Set([
|
|
8317
|
+
node
|
|
8318
|
+
]);
|
|
8319
|
+
viewController.updateViewAST(originalNode);
|
|
8330
8320
|
}
|
|
8331
8321
|
}
|
|
8332
8322
|
},
|
|
@@ -8350,12 +8340,13 @@ var AsyncNodePlugin = function() {
|
|
|
8350
8340
|
if (!_this.isAsync(node)) {
|
|
8351
8341
|
return node === null ? node : _this.resolveAsyncChildren(node, context);
|
|
8352
8342
|
}
|
|
8343
|
+
if (options.node) {
|
|
8344
|
+
context.originalNodeCache.set(node.id, /* @__PURE__ */ new Set([
|
|
8345
|
+
options.node
|
|
8346
|
+
]));
|
|
8347
|
+
}
|
|
8353
8348
|
var resolvedNode = context.nodeResolveCache.get(node.id);
|
|
8354
8349
|
if (resolvedNode !== void 0) {
|
|
8355
|
-
if (resolvedNode.asyncNodesResolved === void 0) {
|
|
8356
|
-
resolvedNode.asyncNodesResolved = [];
|
|
8357
|
-
}
|
|
8358
|
-
resolvedNode.asyncNodesResolved.push(node.id);
|
|
8359
8350
|
return _this.resolveAsyncChildren(resolvedNode, context);
|
|
8360
8351
|
}
|
|
8361
8352
|
if (context.inProgressNodes.has(node.id)) {
|
|
@@ -8379,35 +8370,39 @@ var AsyncNodePlugin = function() {
|
|
|
8379
8370
|
*/ key: "resolveAsyncChildren",
|
|
8380
8371
|
value: function resolveAsyncChildren(node, context) {
|
|
8381
8372
|
var _this = this;
|
|
8382
|
-
var _node_asyncNodesResolved;
|
|
8383
|
-
var asyncNodesResolved = (_node_asyncNodesResolved = node.asyncNodesResolved) !== null && _node_asyncNodesResolved !== void 0 ? _node_asyncNodesResolved : [];
|
|
8384
|
-
node.asyncNodesResolved = asyncNodesResolved;
|
|
8385
8373
|
if (node.type === NodeType.MultiNode) {
|
|
8386
|
-
var
|
|
8387
|
-
while(index < node.values.length){
|
|
8374
|
+
var _this1, _loop = function() {
|
|
8388
8375
|
var childNode = node.values[index];
|
|
8389
|
-
if ((childNode === null || childNode === void 0 ? void 0 : childNode.type) !== NodeType.Async || !
|
|
8376
|
+
if ((childNode === null || childNode === void 0 ? void 0 : childNode.type) !== NodeType.Async || !_this1.hasValidMapping(childNode, context)) {
|
|
8390
8377
|
index++;
|
|
8391
|
-
continue;
|
|
8378
|
+
return "continue";
|
|
8392
8379
|
}
|
|
8393
8380
|
var mappedNode = context.nodeResolveCache.get(childNode.id);
|
|
8394
|
-
|
|
8381
|
+
var nodeSet = /* @__PURE__ */ new Set();
|
|
8395
8382
|
if (mappedNode.type === NodeType.MultiNode && childNode.flatten) {
|
|
8396
8383
|
mappedNode.values.forEach(function(v) {
|
|
8397
|
-
|
|
8384
|
+
v.parent = node;
|
|
8385
|
+
nodeSet.add(v);
|
|
8398
8386
|
});
|
|
8399
8387
|
node.values = _to_consumable_array(node.values.slice(0, index)).concat(_to_consumable_array(mappedNode.values), _to_consumable_array(node.values.slice(index + 1)));
|
|
8400
8388
|
} else {
|
|
8401
8389
|
node.values[index] = mappedNode;
|
|
8402
8390
|
mappedNode.parent = node;
|
|
8391
|
+
nodeSet.add(mappedNode);
|
|
8403
8392
|
}
|
|
8404
|
-
|
|
8393
|
+
context.originalNodeCache.set(childNode.id, nodeSet);
|
|
8394
|
+
};
|
|
8395
|
+
var index = 0;
|
|
8396
|
+
while(index < node.values.length)_this1 = this, _loop();
|
|
8405
8397
|
} else if ("children" in node) {
|
|
8406
8398
|
var _node_children;
|
|
8407
8399
|
(_node_children = node.children) === null || _node_children === void 0 ? void 0 : _node_children.forEach(function(c) {
|
|
8408
8400
|
while(c.value.type === NodeType.Async && _this.hasValidMapping(c.value, context)){
|
|
8409
|
-
|
|
8410
|
-
|
|
8401
|
+
var mappedNode = context.nodeResolveCache.get(c.value.id);
|
|
8402
|
+
context.originalNodeCache.set(c.value.id, /* @__PURE__ */ new Set([
|
|
8403
|
+
mappedNode
|
|
8404
|
+
]));
|
|
8405
|
+
c.value = mappedNode;
|
|
8411
8406
|
c.value.parent = node;
|
|
8412
8407
|
}
|
|
8413
8408
|
});
|
|
@@ -8527,15 +8522,26 @@ var AsyncNodePlugin = function() {
|
|
|
8527
8522
|
{
|
|
8528
8523
|
key: "apply",
|
|
8529
8524
|
value: function apply(view) {
|
|
8530
|
-
var _this = this;
|
|
8531
|
-
var context = {
|
|
8532
|
-
nodeResolveCache: /* @__PURE__ */ new Map(),
|
|
8533
|
-
inProgressNodes: /* @__PURE__ */ new Set(),
|
|
8534
|
-
view: view
|
|
8535
|
-
};
|
|
8536
8525
|
view.hooks.parser.tap("async", this.applyParser.bind(this));
|
|
8537
|
-
|
|
8538
|
-
|
|
8526
|
+
}
|
|
8527
|
+
},
|
|
8528
|
+
{
|
|
8529
|
+
key: "applyPlayer",
|
|
8530
|
+
value: function applyPlayer(player) {
|
|
8531
|
+
var _this = this;
|
|
8532
|
+
player.hooks.viewController.tap("async", function(viewController) {
|
|
8533
|
+
viewController.hooks.view.tap("async", function(view) {
|
|
8534
|
+
var context = {
|
|
8535
|
+
nodeResolveCache: /* @__PURE__ */ new Map(),
|
|
8536
|
+
inProgressNodes: /* @__PURE__ */ new Set(),
|
|
8537
|
+
view: view,
|
|
8538
|
+
viewController: viewController,
|
|
8539
|
+
originalNodeCache: /* @__PURE__ */ new Map()
|
|
8540
|
+
};
|
|
8541
|
+
view.hooks.resolver.tap("async", function(resolver) {
|
|
8542
|
+
_this.applyResolver(resolver, context);
|
|
8543
|
+
});
|
|
8544
|
+
});
|
|
8539
8545
|
});
|
|
8540
8546
|
}
|
|
8541
8547
|
},
|