@player-ui/async-node-plugin 0.7.5--canary.452.15858 → 0.7.42--canary.443.15975
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 +78 -67
- package/dist/AsyncNodePlugin.native.js.map +1 -1
- package/dist/cjs/index.cjs +51 -53
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +51 -53
- package/dist/index.mjs +51 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/index.test.ts +9 -105
- package/src/index.ts +67 -74
- package/types/index.d.ts +4 -21
|
@@ -2622,12 +2622,6 @@ var AsyncNodePlugin = function() {
|
|
|
2622
2622
|
value: function clear() {
|
|
2623
2623
|
this.store = createSortedArray();
|
|
2624
2624
|
}
|
|
2625
|
-
},
|
|
2626
|
-
{
|
|
2627
|
-
/** Check if the registry is empty*/ key: "isRegistryEmpty",
|
|
2628
|
-
value: function isRegistryEmpty() {
|
|
2629
|
-
return this.store.array.length === 0;
|
|
2630
|
-
}
|
|
2631
2625
|
}
|
|
2632
2626
|
]);
|
|
2633
2627
|
return Registry;
|
|
@@ -7563,32 +7557,38 @@ var AsyncNodePlugin = function() {
|
|
|
7563
7557
|
}
|
|
7564
7558
|
_create_class(AsyncNodePluginPlugin, [
|
|
7565
7559
|
{
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
* It checks if the node needs to be updated based on the new result and updates the mapping accordingly.
|
|
7570
|
-
* If an update is necessary, it triggers an asynchronous update on the view.
|
|
7571
|
-
* @param node The asynchronous node that might be updated.
|
|
7572
|
-
* @param result The result obtained from resolving the async node. This could be any data structure or value.
|
|
7573
|
-
* @param options Options provided for node resolution, including a potential parseNode function to process the result.
|
|
7574
|
-
* @param view The view instance where the node resides. This can be undefined if the view is not currently active.
|
|
7575
|
-
*/ key: "handleAsyncUpdate",
|
|
7576
|
-
value: function handleAsyncUpdate(node, result, options, view) {
|
|
7577
|
-
var parsedNode = options.parseNode && result ? options.parseNode(result) : void 0;
|
|
7578
|
-
if (this.resolvedMapping.get(node.id) !== parsedNode) {
|
|
7579
|
-
this.resolvedMapping.set(node.id, parsedNode ? parsedNode : node);
|
|
7580
|
-
view === null || view === void 0 ? void 0 : view.updateAsync();
|
|
7581
|
-
}
|
|
7560
|
+
key: "isAsync",
|
|
7561
|
+
value: function isAsync(node) {
|
|
7562
|
+
return (node === null || node === void 0 ? void 0 : node.type) === NodeType.Async;
|
|
7582
7563
|
}
|
|
7583
7564
|
},
|
|
7584
7565
|
{
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7566
|
+
key: "applyParser",
|
|
7567
|
+
value: function applyParser(parser) {
|
|
7568
|
+
parser.hooks.determineNodeType.tap(this.name, function(obj) {
|
|
7569
|
+
if (Object.prototype.hasOwnProperty.call(obj, "async")) {
|
|
7570
|
+
return NodeType.Async;
|
|
7571
|
+
}
|
|
7572
|
+
});
|
|
7573
|
+
parser.hooks.parseNode.tap(this.name, function(obj, nodeType, options, determinedNodeType) {
|
|
7574
|
+
if (determinedNodeType === NodeType.Async) {
|
|
7575
|
+
var parsedAsync = parser.parseObject((0, import_timm10.omit)(obj, "async"), nodeType, options);
|
|
7576
|
+
var parsedNodeId = getNodeID(parsedAsync);
|
|
7577
|
+
if (parsedAsync !== null && parsedNodeId) {
|
|
7578
|
+
return parser.createASTNode({
|
|
7579
|
+
id: parsedNodeId,
|
|
7580
|
+
type: NodeType.Async,
|
|
7581
|
+
value: parsedAsync
|
|
7582
|
+
}, obj);
|
|
7583
|
+
}
|
|
7584
|
+
return null;
|
|
7585
|
+
}
|
|
7586
|
+
});
|
|
7587
|
+
}
|
|
7588
|
+
},
|
|
7589
|
+
{
|
|
7590
|
+
key: "applyResolverHooks",
|
|
7591
|
+
value: function applyResolverHooks(resolver) {
|
|
7592
7592
|
var _this = this;
|
|
7593
7593
|
resolver.hooks.beforeResolve.tap(this.name, function(node, options) {
|
|
7594
7594
|
var resolvedNode;
|
|
@@ -7604,19 +7604,22 @@ var AsyncNodePlugin = function() {
|
|
|
7604
7604
|
if (!resolvedNode && (node === null || node === void 0 ? void 0 : node.type) === NodeType.Async) {
|
|
7605
7605
|
var _this1 = _this;
|
|
7606
7606
|
(0, import_queue_microtask2.default)(/*#__PURE__*/ _async_to_generator(function() {
|
|
7607
|
-
var _this_basePlugin, result;
|
|
7607
|
+
var _this_basePlugin, result, parsedNode, _this_currentView;
|
|
7608
7608
|
return _ts_generator(this, function(_state) {
|
|
7609
7609
|
switch(_state.label){
|
|
7610
7610
|
case 0:
|
|
7611
7611
|
return [
|
|
7612
7612
|
4,
|
|
7613
|
-
(_this_basePlugin = _this1.basePlugin) === null || _this_basePlugin === void 0 ? void 0 : _this_basePlugin.hooks.onAsyncNode.call(node
|
|
7614
|
-
_this1.handleAsyncUpdate(node, result2, options, _this1.currentView);
|
|
7615
|
-
})
|
|
7613
|
+
(_this_basePlugin = _this1.basePlugin) === null || _this_basePlugin === void 0 ? void 0 : _this_basePlugin.hooks.onAsyncNode.call(node)
|
|
7616
7614
|
];
|
|
7617
7615
|
case 1:
|
|
7618
7616
|
result = _state.sent();
|
|
7619
|
-
|
|
7617
|
+
parsedNode = options.parseNode && result ? options.parseNode(result) : void 0;
|
|
7618
|
+
if (parsedNode) {
|
|
7619
|
+
;
|
|
7620
|
+
_this1.resolvedMapping.set(node.id, parsedNode);
|
|
7621
|
+
(_this_currentView = _this1.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.updateAsync();
|
|
7622
|
+
}
|
|
7620
7623
|
return [
|
|
7621
7624
|
2
|
|
7622
7625
|
];
|
|
@@ -7629,42 +7632,50 @@ var AsyncNodePlugin = function() {
|
|
|
7629
7632
|
});
|
|
7630
7633
|
}
|
|
7631
7634
|
},
|
|
7632
|
-
{
|
|
7633
|
-
key: "isAsync",
|
|
7634
|
-
value: function isAsync(node) {
|
|
7635
|
-
return (node === null || node === void 0 ? void 0 : node.type) === NodeType.Async;
|
|
7636
|
-
}
|
|
7637
|
-
},
|
|
7638
|
-
{
|
|
7639
|
-
key: "applyParser",
|
|
7640
|
-
value: function applyParser(parser) {
|
|
7641
|
-
parser.hooks.determineNodeType.tap(this.name, function(obj) {
|
|
7642
|
-
if (Object.prototype.hasOwnProperty.call(obj, "async")) {
|
|
7643
|
-
return NodeType.Async;
|
|
7644
|
-
}
|
|
7645
|
-
});
|
|
7646
|
-
parser.hooks.parseNode.tap(this.name, function(obj, nodeType, options, determinedNodeType) {
|
|
7647
|
-
if (determinedNodeType === NodeType.Async) {
|
|
7648
|
-
var parsedAsync = parser.parseObject((0, import_timm10.omit)(obj, "async"), nodeType, options);
|
|
7649
|
-
var parsedNodeId = getNodeID(parsedAsync);
|
|
7650
|
-
if (parsedAsync !== null && parsedNodeId) {
|
|
7651
|
-
return parser.createASTNode({
|
|
7652
|
-
id: parsedNodeId,
|
|
7653
|
-
type: NodeType.Async,
|
|
7654
|
-
value: parsedAsync
|
|
7655
|
-
}, obj);
|
|
7656
|
-
}
|
|
7657
|
-
return null;
|
|
7658
|
-
}
|
|
7659
|
-
});
|
|
7660
|
-
}
|
|
7661
|
-
},
|
|
7662
7635
|
{
|
|
7663
7636
|
key: "apply",
|
|
7664
7637
|
value: function apply(view) {
|
|
7665
|
-
|
|
7666
|
-
view.hooks.parser.tap("
|
|
7667
|
-
view.hooks.resolver.tap("
|
|
7638
|
+
var _this = this;
|
|
7639
|
+
view.hooks.parser.tap("template", this.applyParser.bind(this));
|
|
7640
|
+
view.hooks.resolver.tap("template", function(resolver) {
|
|
7641
|
+
resolver.hooks.beforeResolve.tap(_this.name, function(node, options) {
|
|
7642
|
+
var resolvedNode;
|
|
7643
|
+
if (_this.isAsync(node)) {
|
|
7644
|
+
var mappedValue = _this.resolvedMapping.get(node.id);
|
|
7645
|
+
if (mappedValue) {
|
|
7646
|
+
resolvedNode = mappedValue;
|
|
7647
|
+
}
|
|
7648
|
+
} else {
|
|
7649
|
+
resolvedNode = null;
|
|
7650
|
+
}
|
|
7651
|
+
var newNode = resolvedNode || node;
|
|
7652
|
+
if (!resolvedNode && (node === null || node === void 0 ? void 0 : node.type) === NodeType.Async) {
|
|
7653
|
+
var _this1 = _this;
|
|
7654
|
+
(0, import_queue_microtask2.default)(/*#__PURE__*/ _async_to_generator(function() {
|
|
7655
|
+
var _this_basePlugin, result, parsedNode;
|
|
7656
|
+
return _ts_generator(this, function(_state) {
|
|
7657
|
+
switch(_state.label){
|
|
7658
|
+
case 0:
|
|
7659
|
+
return [
|
|
7660
|
+
4,
|
|
7661
|
+
(_this_basePlugin = _this1.basePlugin) === null || _this_basePlugin === void 0 ? void 0 : _this_basePlugin.hooks.onAsyncNode.call(node)
|
|
7662
|
+
];
|
|
7663
|
+
case 1:
|
|
7664
|
+
result = _state.sent();
|
|
7665
|
+
parsedNode = options.parseNode && result ? options.parseNode(result) : void 0;
|
|
7666
|
+
_this1.resolvedMapping.set(node.id, parsedNode ? parsedNode : node);
|
|
7667
|
+
view.updateAsync();
|
|
7668
|
+
return [
|
|
7669
|
+
2
|
|
7670
|
+
];
|
|
7671
|
+
}
|
|
7672
|
+
});
|
|
7673
|
+
}));
|
|
7674
|
+
return node;
|
|
7675
|
+
}
|
|
7676
|
+
return newNode;
|
|
7677
|
+
});
|
|
7678
|
+
});
|
|
7668
7679
|
}
|
|
7669
7680
|
},
|
|
7670
7681
|
{
|