@player-ui/async-node-plugin 0.13.0-next.0 → 0.13.0-next.2
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.
|
@@ -5140,20 +5140,15 @@ var AsyncNodePlugin = function() {
|
|
|
5140
5140
|
}();
|
|
5141
5141
|
var ViewInstance = /*#__PURE__*/ function() {
|
|
5142
5142
|
function ViewInstance(initialView, resolverOptions) {
|
|
5143
|
-
var _this = this;
|
|
5144
5143
|
_class_call_check(this, ViewInstance);
|
|
5145
5144
|
this.hooks = {
|
|
5146
5145
|
onUpdate: new SyncHook(),
|
|
5147
5146
|
parser: new SyncHook(),
|
|
5148
5147
|
resolver: new SyncHook(),
|
|
5149
|
-
onTemplatePluginCreated: new SyncHook(),
|
|
5150
5148
|
templatePlugin: new SyncHook()
|
|
5151
5149
|
};
|
|
5152
5150
|
this.initialView = initialView;
|
|
5153
5151
|
this.resolverOptions = resolverOptions;
|
|
5154
|
-
this.hooks.onTemplatePluginCreated.tap("view", function(templatePlugin) {
|
|
5155
|
-
_this.templatePlugin = templatePlugin;
|
|
5156
|
-
});
|
|
5157
5152
|
}
|
|
5158
5153
|
_create_class(ViewInstance, [
|
|
5159
5154
|
{
|
|
@@ -5200,6 +5195,12 @@ var AsyncNodePlugin = function() {
|
|
|
5200
5195
|
var _this_validationProvider;
|
|
5201
5196
|
return (_this_validationProvider = this.validationProvider) === null || _this_validationProvider === void 0 ? void 0 : _this_validationProvider.getValidationsForBinding(binding);
|
|
5202
5197
|
}
|
|
5198
|
+
},
|
|
5199
|
+
{
|
|
5200
|
+
key: "setTemplatePlugin",
|
|
5201
|
+
value: function setTemplatePlugin(plugin) {
|
|
5202
|
+
this.templatePlugin = plugin;
|
|
5203
|
+
}
|
|
5203
5204
|
}
|
|
5204
5205
|
]);
|
|
5205
5206
|
return ViewInstance;
|
|
@@ -5498,6 +5499,7 @@ var AsyncNodePlugin = function() {
|
|
|
5498
5499
|
value: function apply(view) {
|
|
5499
5500
|
view.hooks.parser.tap("template", this.applyParser.bind(this));
|
|
5500
5501
|
view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
|
|
5502
|
+
view.setTemplatePlugin(this);
|
|
5501
5503
|
}
|
|
5502
5504
|
}
|
|
5503
5505
|
]);
|
|
@@ -6077,13 +6079,13 @@ var AsyncNodePlugin = function() {
|
|
|
6077
6079
|
this.isTransitioning = false;
|
|
6078
6080
|
this.hooks = {
|
|
6079
6081
|
beforeStart: new SyncBailHook(),
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6082
|
+
onStart: new SyncHook(),
|
|
6083
|
+
onEnd: new SyncHook(),
|
|
6084
|
+
skipTransition: new SyncBailHook(),
|
|
6085
|
+
beforeTransition: new SyncWaterfallHook(),
|
|
6086
|
+
resolveTransitionNode: new SyncWaterfallHook(),
|
|
6087
|
+
transition: new SyncHook(),
|
|
6088
|
+
afterTransition: new SyncHook()
|
|
6087
6089
|
};
|
|
6088
6090
|
this.id = id;
|
|
6089
6091
|
this.flow = flow;
|
|
@@ -7106,8 +7108,7 @@ var AsyncNodePlugin = function() {
|
|
|
7106
7108
|
var _this1 = this;
|
|
7107
7109
|
_class_call_check(this, ViewController);
|
|
7108
7110
|
this.hooks = {
|
|
7109
|
-
|
|
7110
|
-
// The hook right before the View starts resolving. Attach anything custom here
|
|
7111
|
+
resolveView: new SyncWaterfallHook(),
|
|
7111
7112
|
view: new SyncHook()
|
|
7112
7113
|
};
|
|
7113
7114
|
this.transformRegistry = new Registry();
|
|
@@ -7155,6 +7156,7 @@ var AsyncNodePlugin = function() {
|
|
|
7155
7156
|
]));
|
|
7156
7157
|
}
|
|
7157
7158
|
});
|
|
7159
|
+
this.viewPlugins = this.createViewPlugins();
|
|
7158
7160
|
}
|
|
7159
7161
|
_create_class(ViewController, [
|
|
7160
7162
|
{
|
|
@@ -7210,9 +7212,50 @@ var AsyncNodePlugin = function() {
|
|
|
7210
7212
|
}
|
|
7211
7213
|
var view = new ViewInstance(source, this.viewOptions);
|
|
7212
7214
|
this.currentView = view;
|
|
7215
|
+
this.applyViewPlugins(view);
|
|
7213
7216
|
this.hooks.view.call(view);
|
|
7214
7217
|
view.update();
|
|
7215
7218
|
}
|
|
7219
|
+
},
|
|
7220
|
+
{
|
|
7221
|
+
key: "applyViewPlugins",
|
|
7222
|
+
value: function applyViewPlugins(view) {
|
|
7223
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
7224
|
+
try {
|
|
7225
|
+
for(var _iterator = this.viewPlugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
7226
|
+
var plugin = _step.value;
|
|
7227
|
+
plugin.apply(view);
|
|
7228
|
+
}
|
|
7229
|
+
} catch (err) {
|
|
7230
|
+
_didIteratorError = true;
|
|
7231
|
+
_iteratorError = err;
|
|
7232
|
+
} finally{
|
|
7233
|
+
try {
|
|
7234
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
7235
|
+
_iterator.return();
|
|
7236
|
+
}
|
|
7237
|
+
} finally{
|
|
7238
|
+
if (_didIteratorError) {
|
|
7239
|
+
throw _iteratorError;
|
|
7240
|
+
}
|
|
7241
|
+
}
|
|
7242
|
+
}
|
|
7243
|
+
}
|
|
7244
|
+
},
|
|
7245
|
+
{
|
|
7246
|
+
key: "createViewPlugins",
|
|
7247
|
+
value: function createViewPlugins() {
|
|
7248
|
+
var pluginOptions = toNodeResolveOptions(this.viewOptions);
|
|
7249
|
+
return [
|
|
7250
|
+
new AssetPlugin(),
|
|
7251
|
+
new SwitchPlugin(pluginOptions),
|
|
7252
|
+
new ApplicabilityPlugin(),
|
|
7253
|
+
new AssetTransformCorePlugin(this.transformRegistry),
|
|
7254
|
+
new StringResolverPlugin(),
|
|
7255
|
+
new TemplatePlugin(pluginOptions),
|
|
7256
|
+
new MultiNodePlugin()
|
|
7257
|
+
];
|
|
7258
|
+
}
|
|
7216
7259
|
}
|
|
7217
7260
|
]);
|
|
7218
7261
|
return ViewController;
|
|
@@ -7585,35 +7628,6 @@ var AsyncNodePlugin = function() {
|
|
|
7585
7628
|
ref: Symbol("not-started"),
|
|
7586
7629
|
status: "not-started"
|
|
7587
7630
|
};
|
|
7588
|
-
var DefaultViewPlugin = /*#__PURE__*/ function() {
|
|
7589
|
-
function DefaultViewPlugin() {
|
|
7590
|
-
_class_call_check(this, DefaultViewPlugin);
|
|
7591
|
-
this.name = "default-view-plugin";
|
|
7592
|
-
}
|
|
7593
|
-
_create_class(DefaultViewPlugin, [
|
|
7594
|
-
{
|
|
7595
|
-
key: "apply",
|
|
7596
|
-
value: function apply(player) {
|
|
7597
|
-
var _this = this;
|
|
7598
|
-
player.hooks.viewController.tap(this.name, function(viewController) {
|
|
7599
|
-
viewController.hooks.view.tap(_this.name, function(view) {
|
|
7600
|
-
var pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
7601
|
-
new AssetPlugin().apply(view);
|
|
7602
|
-
new SwitchPlugin(pluginOptions).apply(view);
|
|
7603
|
-
new ApplicabilityPlugin().apply(view);
|
|
7604
|
-
new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
|
|
7605
|
-
new StringResolverPlugin().apply(view);
|
|
7606
|
-
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
7607
|
-
templatePlugin.apply(view);
|
|
7608
|
-
view.hooks.onTemplatePluginCreated.call(templatePlugin);
|
|
7609
|
-
new MultiNodePlugin().apply(view);
|
|
7610
|
-
});
|
|
7611
|
-
});
|
|
7612
|
-
}
|
|
7613
|
-
}
|
|
7614
|
-
]);
|
|
7615
|
-
return DefaultViewPlugin;
|
|
7616
|
-
}();
|
|
7617
7631
|
var PLAYER_VERSION = "__VERSION__";
|
|
7618
7632
|
var COMMIT = "__GIT_COMMIT__";
|
|
7619
7633
|
var _Player = /*#__PURE__*/ function() {
|
|
@@ -7643,8 +7657,7 @@ var AsyncNodePlugin = function() {
|
|
|
7643
7657
|
}
|
|
7644
7658
|
this.config = config || {};
|
|
7645
7659
|
this.config.plugins = [
|
|
7646
|
-
new DefaultExpPlugin()
|
|
7647
|
-
new DefaultViewPlugin()
|
|
7660
|
+
new DefaultExpPlugin()
|
|
7648
7661
|
].concat(_to_consumable_array(this.config.plugins || []), [
|
|
7649
7662
|
new FlowExpPlugin()
|
|
7650
7663
|
]);
|
|
@@ -7831,95 +7844,41 @@ var AsyncNodePlugin = function() {
|
|
|
7831
7844
|
validationController.reset();
|
|
7832
7845
|
}
|
|
7833
7846
|
});
|
|
7834
|
-
flow.hooks.afterTransition.tap("player", function(flowInstance) {
|
|
7847
|
+
flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
|
|
7835
7848
|
var _flowInstance_currentState;
|
|
7836
7849
|
var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
7837
|
-
if (value && value.state_type === "
|
|
7850
|
+
if (value && value.state_type === "ASYNC_ACTION") {
|
|
7838
7851
|
var exp = value.exp;
|
|
7839
|
-
|
|
7840
|
-
|
|
7852
|
+
try {
|
|
7853
|
+
var result = expressionEvaluator.evaluateAsync(exp);
|
|
7854
|
+
if (isPromiseLike(result)) {
|
|
7855
|
+
if (value.await) {
|
|
7856
|
+
queueMicrotask(function() {
|
|
7857
|
+
result.then(function(r) {
|
|
7858
|
+
return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
|
|
7859
|
+
}).catch(flowResultDeferred.reject);
|
|
7860
|
+
});
|
|
7861
|
+
} else {
|
|
7862
|
+
_this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
|
|
7863
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7864
|
+
}
|
|
7865
|
+
} else {
|
|
7866
|
+
_this.logger.warn("Non async expression used in async action node");
|
|
7867
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7868
|
+
}
|
|
7869
|
+
} catch (e) {
|
|
7870
|
+
flowResultDeferred.reject(e);
|
|
7871
|
+
}
|
|
7872
|
+
} else if (value && value.state_type === "ACTION") {
|
|
7873
|
+
var exp1 = value.exp;
|
|
7874
|
+
var result1 = expressionEvaluator.evaluate(exp1);
|
|
7875
|
+
if (isPromiseLike(result1)) {
|
|
7841
7876
|
_this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
|
|
7842
7877
|
}
|
|
7843
|
-
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(
|
|
7878
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
|
|
7844
7879
|
}
|
|
7845
7880
|
expressionEvaluator.reset();
|
|
7846
7881
|
});
|
|
7847
|
-
var _this1 = _this;
|
|
7848
|
-
flow.hooks.afterTransition.tap("player", function() {
|
|
7849
|
-
var _ref = _async_to_generator(function(flowInstance) {
|
|
7850
|
-
var _flowInstance_currentState, value, exp, result, e;
|
|
7851
|
-
return _ts_generator(this, function(_state) {
|
|
7852
|
-
switch(_state.label){
|
|
7853
|
-
case 0:
|
|
7854
|
-
value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
7855
|
-
if (!(value && value.state_type === "ASYNC_ACTION")) return [
|
|
7856
|
-
3,
|
|
7857
|
-
8
|
|
7858
|
-
];
|
|
7859
|
-
exp = value.exp;
|
|
7860
|
-
_state.label = 1;
|
|
7861
|
-
case 1:
|
|
7862
|
-
_state.trys.push([
|
|
7863
|
-
1,
|
|
7864
|
-
7,
|
|
7865
|
-
,
|
|
7866
|
-
8
|
|
7867
|
-
]);
|
|
7868
|
-
result = expressionEvaluator.evaluateAsync(exp);
|
|
7869
|
-
if (!isPromiseLike(result)) return [
|
|
7870
|
-
3,
|
|
7871
|
-
5
|
|
7872
|
-
];
|
|
7873
|
-
if (!value.await) return [
|
|
7874
|
-
3,
|
|
7875
|
-
3
|
|
7876
|
-
];
|
|
7877
|
-
return [
|
|
7878
|
-
4,
|
|
7879
|
-
result
|
|
7880
|
-
];
|
|
7881
|
-
case 2:
|
|
7882
|
-
result = _state.sent();
|
|
7883
|
-
return [
|
|
7884
|
-
3,
|
|
7885
|
-
4
|
|
7886
|
-
];
|
|
7887
|
-
case 3:
|
|
7888
|
-
_this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
|
|
7889
|
-
_state.label = 4;
|
|
7890
|
-
case 4:
|
|
7891
|
-
return [
|
|
7892
|
-
3,
|
|
7893
|
-
6
|
|
7894
|
-
];
|
|
7895
|
-
case 5:
|
|
7896
|
-
_this1.logger.warn("Non async expression used in async action node");
|
|
7897
|
-
_state.label = 6;
|
|
7898
|
-
case 6:
|
|
7899
|
-
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7900
|
-
return [
|
|
7901
|
-
3,
|
|
7902
|
-
8
|
|
7903
|
-
];
|
|
7904
|
-
case 7:
|
|
7905
|
-
e = _state.sent();
|
|
7906
|
-
flowResultDeferred.reject(e);
|
|
7907
|
-
return [
|
|
7908
|
-
3,
|
|
7909
|
-
8
|
|
7910
|
-
];
|
|
7911
|
-
case 8:
|
|
7912
|
-
expressionEvaluator.reset();
|
|
7913
|
-
return [
|
|
7914
|
-
2
|
|
7915
|
-
];
|
|
7916
|
-
}
|
|
7917
|
-
});
|
|
7918
|
-
});
|
|
7919
|
-
return function(flowInstance) {
|
|
7920
|
-
return _ref.apply(this, arguments);
|
|
7921
|
-
};
|
|
7922
|
-
}());
|
|
7923
7882
|
});
|
|
7924
7883
|
this.hooks.dataController.call(dataController);
|
|
7925
7884
|
validationController.setOptions({
|
|
@@ -7957,11 +7916,9 @@ var AsyncNodePlugin = function() {
|
|
|
7957
7916
|
}),
|
|
7958
7917
|
constants: this.constantsController
|
|
7959
7918
|
});
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
_this.hooks.view.call(view);
|
|
7964
|
-
});
|
|
7919
|
+
viewController.hooks.view.tap("player", function(view) {
|
|
7920
|
+
validationController.onView(view);
|
|
7921
|
+
_this.hooks.view.call(view);
|
|
7965
7922
|
});
|
|
7966
7923
|
this.hooks.viewController.call(viewController);
|
|
7967
7924
|
return {
|