@player-ui/async-node-plugin 0.11.3--canary.666.24070 → 0.11.3--canary.666.24188
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 +20 -14
- package/dist/AsyncNodePlugin.native.js.map +1 -1
- package/dist/cjs/index.cjs +25 -14
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +25 -14
- package/dist/index.mjs +25 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/index.test.ts +128 -8
- package/src/index.ts +31 -12
- package/types/index.d.ts +5 -2
|
@@ -7793,7 +7793,6 @@ var AsyncNodePlugin = function() {
|
|
|
7793
7793
|
_class_call_check(this, AsyncNodePluginPlugin);
|
|
7794
7794
|
this.asyncNode = new AsyncParallelBailHook();
|
|
7795
7795
|
this.name = "AsyncNode";
|
|
7796
|
-
this.resolvedMapping = /* @__PURE__ */ new Map();
|
|
7797
7796
|
}
|
|
7798
7797
|
_create_class(AsyncNodePluginPlugin, [
|
|
7799
7798
|
{
|
|
@@ -7804,9 +7803,9 @@ var AsyncNodePlugin = function() {
|
|
|
7804
7803
|
* @param options Options provided for node resolution, including a potential parseNode function to process the result.
|
|
7805
7804
|
* @param view The view instance where the node resides. This can be undefined if the view is not currently active.
|
|
7806
7805
|
*/ key: "parseNodeAndUpdate",
|
|
7807
|
-
value: function parseNodeAndUpdate(node, result, options, view) {
|
|
7806
|
+
value: function parseNodeAndUpdate(node, context, result, options, view) {
|
|
7808
7807
|
var parsedNode = options.parseNode && result ? options.parseNode(result) : void 0;
|
|
7809
|
-
this.handleAsyncUpdate(node, parsedNode, view);
|
|
7808
|
+
this.handleAsyncUpdate(node, context, parsedNode, view);
|
|
7810
7809
|
}
|
|
7811
7810
|
},
|
|
7812
7811
|
{
|
|
@@ -7819,9 +7818,10 @@ var AsyncNodePlugin = function() {
|
|
|
7819
7818
|
* @param newNode The new node to replace the async node.
|
|
7820
7819
|
* @param view The view instance where the node resides. This can be undefined if the view is not currently active.
|
|
7821
7820
|
*/ key: "handleAsyncUpdate",
|
|
7822
|
-
value: function handleAsyncUpdate(node, newNode, view) {
|
|
7823
|
-
|
|
7824
|
-
|
|
7821
|
+
value: function handleAsyncUpdate(node, context, newNode, view) {
|
|
7822
|
+
var nodeResolveCache = context.nodeResolveCache;
|
|
7823
|
+
if (nodeResolveCache.get(node.id) !== newNode) {
|
|
7824
|
+
nodeResolveCache.set(node.id, newNode ? newNode : node);
|
|
7825
7825
|
view === null || view === void 0 ? void 0 : view.updateAsync();
|
|
7826
7826
|
}
|
|
7827
7827
|
}
|
|
@@ -7833,18 +7833,18 @@ var AsyncNodePlugin = function() {
|
|
|
7833
7833
|
* @param resolver The resolver instance to attach the hook to.
|
|
7834
7834
|
* @param view
|
|
7835
7835
|
*/ key: "applyResolver",
|
|
7836
|
-
value: function applyResolver(resolver) {
|
|
7836
|
+
value: function applyResolver(resolver, context) {
|
|
7837
7837
|
var _this = this;
|
|
7838
7838
|
resolver.hooks.beforeResolve.tap(this.name, function(node, options) {
|
|
7839
7839
|
if (!_this.isAsync(node)) {
|
|
7840
7840
|
return node;
|
|
7841
7841
|
}
|
|
7842
|
-
var resolvedNode =
|
|
7842
|
+
var resolvedNode = context.nodeResolveCache.get(node.id);
|
|
7843
7843
|
if (resolvedNode !== void 0) {
|
|
7844
7844
|
return resolvedNode;
|
|
7845
7845
|
}
|
|
7846
7846
|
(0, import_queue_microtask2.default)(function() {
|
|
7847
|
-
return _this.runAsyncNode(node, options);
|
|
7847
|
+
return _this.runAsyncNode(node, context, options);
|
|
7848
7848
|
});
|
|
7849
7849
|
return node;
|
|
7850
7850
|
});
|
|
@@ -7852,7 +7852,7 @@ var AsyncNodePlugin = function() {
|
|
|
7852
7852
|
},
|
|
7853
7853
|
{
|
|
7854
7854
|
key: "runAsyncNode",
|
|
7855
|
-
value: function runAsyncNode(node, options) {
|
|
7855
|
+
value: function runAsyncNode(node, context, options) {
|
|
7856
7856
|
var _this = this;
|
|
7857
7857
|
return _async_to_generator(function() {
|
|
7858
7858
|
var _this_basePlugin, result, e, _this_basePlugin1, _options_logger, error, result1, _this_basePlugin_getPlayerInstance, _this_basePlugin2, playerState;
|
|
@@ -7868,12 +7868,12 @@ var AsyncNodePlugin = function() {
|
|
|
7868
7868
|
return [
|
|
7869
7869
|
4,
|
|
7870
7870
|
(_this_basePlugin = _this.basePlugin) === null || _this_basePlugin === void 0 ? void 0 : _this_basePlugin.hooks.onAsyncNode.call(node, function(result2) {
|
|
7871
|
-
_this.parseNodeAndUpdate(node, result2, options, _this.currentView);
|
|
7871
|
+
_this.parseNodeAndUpdate(node, context, result2, options, _this.currentView);
|
|
7872
7872
|
})
|
|
7873
7873
|
];
|
|
7874
7874
|
case 1:
|
|
7875
7875
|
result = _state.sent();
|
|
7876
|
-
_this.parseNodeAndUpdate(node, result, options, _this.currentView);
|
|
7876
|
+
_this.parseNodeAndUpdate(node, context, result, options, _this.currentView);
|
|
7877
7877
|
return [
|
|
7878
7878
|
3,
|
|
7879
7879
|
3
|
|
@@ -7893,7 +7893,7 @@ var AsyncNodePlugin = function() {
|
|
|
7893
7893
|
];
|
|
7894
7894
|
}
|
|
7895
7895
|
(_options_logger = options.logger) === null || _options_logger === void 0 ? void 0 : _options_logger.error("Async node handling failed and resolved with a fallback. Error:", error);
|
|
7896
|
-
_this.parseNodeAndUpdate(node, result1, options, _this.currentView);
|
|
7896
|
+
_this.parseNodeAndUpdate(node, context, result1, options, _this.currentView);
|
|
7897
7897
|
return [
|
|
7898
7898
|
3,
|
|
7899
7899
|
3
|
|
@@ -7953,9 +7953,15 @@ var AsyncNodePlugin = function() {
|
|
|
7953
7953
|
{
|
|
7954
7954
|
key: "apply",
|
|
7955
7955
|
value: function apply(view) {
|
|
7956
|
+
var _this = this;
|
|
7956
7957
|
this.currentView = view;
|
|
7958
|
+
var context = {
|
|
7959
|
+
nodeResolveCache: /* @__PURE__ */ new Map()
|
|
7960
|
+
};
|
|
7957
7961
|
view.hooks.parser.tap("async", this.applyParser.bind(this));
|
|
7958
|
-
view.hooks.resolver.tap("async",
|
|
7962
|
+
view.hooks.resolver.tap("async", function(resolver) {
|
|
7963
|
+
_this.applyResolver(resolver, context);
|
|
7964
|
+
});
|
|
7959
7965
|
}
|
|
7960
7966
|
},
|
|
7961
7967
|
{
|