@player-ui/beacon-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.
|
@@ -5144,20 +5144,15 @@ var BeaconPlugin = function() {
|
|
|
5144
5144
|
}();
|
|
5145
5145
|
var ViewInstance = /*#__PURE__*/ function() {
|
|
5146
5146
|
function ViewInstance(initialView, resolverOptions) {
|
|
5147
|
-
var _this = this;
|
|
5148
5147
|
_class_call_check(this, ViewInstance);
|
|
5149
5148
|
this.hooks = {
|
|
5150
5149
|
onUpdate: new SyncHook(),
|
|
5151
5150
|
parser: new SyncHook(),
|
|
5152
5151
|
resolver: new SyncHook(),
|
|
5153
|
-
onTemplatePluginCreated: new SyncHook(),
|
|
5154
5152
|
templatePlugin: new SyncHook()
|
|
5155
5153
|
};
|
|
5156
5154
|
this.initialView = initialView;
|
|
5157
5155
|
this.resolverOptions = resolverOptions;
|
|
5158
|
-
this.hooks.onTemplatePluginCreated.tap("view", function(templatePlugin) {
|
|
5159
|
-
_this.templatePlugin = templatePlugin;
|
|
5160
|
-
});
|
|
5161
5156
|
}
|
|
5162
5157
|
_create_class(ViewInstance, [
|
|
5163
5158
|
{
|
|
@@ -5204,6 +5199,12 @@ var BeaconPlugin = function() {
|
|
|
5204
5199
|
var _this_validationProvider;
|
|
5205
5200
|
return (_this_validationProvider = this.validationProvider) === null || _this_validationProvider === void 0 ? void 0 : _this_validationProvider.getValidationsForBinding(binding);
|
|
5206
5201
|
}
|
|
5202
|
+
},
|
|
5203
|
+
{
|
|
5204
|
+
key: "setTemplatePlugin",
|
|
5205
|
+
value: function setTemplatePlugin(plugin) {
|
|
5206
|
+
this.templatePlugin = plugin;
|
|
5207
|
+
}
|
|
5207
5208
|
}
|
|
5208
5209
|
]);
|
|
5209
5210
|
return ViewInstance;
|
|
@@ -5375,6 +5376,7 @@ var BeaconPlugin = function() {
|
|
|
5375
5376
|
value: function apply(view) {
|
|
5376
5377
|
view.hooks.parser.tap("template", this.applyParser.bind(this));
|
|
5377
5378
|
view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
|
|
5379
|
+
view.setTemplatePlugin(this);
|
|
5378
5380
|
}
|
|
5379
5381
|
}
|
|
5380
5382
|
]);
|
|
@@ -5954,13 +5956,13 @@ var BeaconPlugin = function() {
|
|
|
5954
5956
|
this.isTransitioning = false;
|
|
5955
5957
|
this.hooks = {
|
|
5956
5958
|
beforeStart: new SyncBailHook(),
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5959
|
+
onStart: new SyncHook(),
|
|
5960
|
+
onEnd: new SyncHook(),
|
|
5961
|
+
skipTransition: new SyncBailHook(),
|
|
5962
|
+
beforeTransition: new SyncWaterfallHook(),
|
|
5963
|
+
resolveTransitionNode: new SyncWaterfallHook(),
|
|
5964
|
+
transition: new SyncHook(),
|
|
5965
|
+
afterTransition: new SyncHook()
|
|
5964
5966
|
};
|
|
5965
5967
|
this.id = id;
|
|
5966
5968
|
this.flow = flow;
|
|
@@ -6983,8 +6985,7 @@ var BeaconPlugin = function() {
|
|
|
6983
6985
|
var _this1 = this;
|
|
6984
6986
|
_class_call_check(this, ViewController);
|
|
6985
6987
|
this.hooks = {
|
|
6986
|
-
|
|
6987
|
-
// The hook right before the View starts resolving. Attach anything custom here
|
|
6988
|
+
resolveView: new SyncWaterfallHook(),
|
|
6988
6989
|
view: new SyncHook()
|
|
6989
6990
|
};
|
|
6990
6991
|
this.transformRegistry = new Registry();
|
|
@@ -7032,6 +7033,7 @@ var BeaconPlugin = function() {
|
|
|
7032
7033
|
]));
|
|
7033
7034
|
}
|
|
7034
7035
|
});
|
|
7036
|
+
this.viewPlugins = this.createViewPlugins();
|
|
7035
7037
|
}
|
|
7036
7038
|
_create_class(ViewController, [
|
|
7037
7039
|
{
|
|
@@ -7087,9 +7089,50 @@ var BeaconPlugin = function() {
|
|
|
7087
7089
|
}
|
|
7088
7090
|
var view = new ViewInstance(source, this.viewOptions);
|
|
7089
7091
|
this.currentView = view;
|
|
7092
|
+
this.applyViewPlugins(view);
|
|
7090
7093
|
this.hooks.view.call(view);
|
|
7091
7094
|
view.update();
|
|
7092
7095
|
}
|
|
7096
|
+
},
|
|
7097
|
+
{
|
|
7098
|
+
key: "applyViewPlugins",
|
|
7099
|
+
value: function applyViewPlugins(view) {
|
|
7100
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
7101
|
+
try {
|
|
7102
|
+
for(var _iterator = this.viewPlugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
7103
|
+
var plugin = _step.value;
|
|
7104
|
+
plugin.apply(view);
|
|
7105
|
+
}
|
|
7106
|
+
} catch (err) {
|
|
7107
|
+
_didIteratorError = true;
|
|
7108
|
+
_iteratorError = err;
|
|
7109
|
+
} finally{
|
|
7110
|
+
try {
|
|
7111
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
7112
|
+
_iterator.return();
|
|
7113
|
+
}
|
|
7114
|
+
} finally{
|
|
7115
|
+
if (_didIteratorError) {
|
|
7116
|
+
throw _iteratorError;
|
|
7117
|
+
}
|
|
7118
|
+
}
|
|
7119
|
+
}
|
|
7120
|
+
}
|
|
7121
|
+
},
|
|
7122
|
+
{
|
|
7123
|
+
key: "createViewPlugins",
|
|
7124
|
+
value: function createViewPlugins() {
|
|
7125
|
+
var pluginOptions = toNodeResolveOptions(this.viewOptions);
|
|
7126
|
+
return [
|
|
7127
|
+
new AssetPlugin(),
|
|
7128
|
+
new SwitchPlugin(pluginOptions),
|
|
7129
|
+
new ApplicabilityPlugin(),
|
|
7130
|
+
new AssetTransformCorePlugin(this.transformRegistry),
|
|
7131
|
+
new StringResolverPlugin(),
|
|
7132
|
+
new TemplatePlugin(pluginOptions),
|
|
7133
|
+
new MultiNodePlugin()
|
|
7134
|
+
];
|
|
7135
|
+
}
|
|
7093
7136
|
}
|
|
7094
7137
|
]);
|
|
7095
7138
|
return ViewController;
|
|
@@ -7462,35 +7505,6 @@ var BeaconPlugin = function() {
|
|
|
7462
7505
|
ref: Symbol("not-started"),
|
|
7463
7506
|
status: "not-started"
|
|
7464
7507
|
};
|
|
7465
|
-
var DefaultViewPlugin = /*#__PURE__*/ function() {
|
|
7466
|
-
function DefaultViewPlugin() {
|
|
7467
|
-
_class_call_check(this, DefaultViewPlugin);
|
|
7468
|
-
this.name = "default-view-plugin";
|
|
7469
|
-
}
|
|
7470
|
-
_create_class(DefaultViewPlugin, [
|
|
7471
|
-
{
|
|
7472
|
-
key: "apply",
|
|
7473
|
-
value: function apply(player) {
|
|
7474
|
-
var _this = this;
|
|
7475
|
-
player.hooks.viewController.tap(this.name, function(viewController) {
|
|
7476
|
-
viewController.hooks.view.tap(_this.name, function(view) {
|
|
7477
|
-
var pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
7478
|
-
new AssetPlugin().apply(view);
|
|
7479
|
-
new SwitchPlugin(pluginOptions).apply(view);
|
|
7480
|
-
new ApplicabilityPlugin().apply(view);
|
|
7481
|
-
new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
|
|
7482
|
-
new StringResolverPlugin().apply(view);
|
|
7483
|
-
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
7484
|
-
templatePlugin.apply(view);
|
|
7485
|
-
view.hooks.onTemplatePluginCreated.call(templatePlugin);
|
|
7486
|
-
new MultiNodePlugin().apply(view);
|
|
7487
|
-
});
|
|
7488
|
-
});
|
|
7489
|
-
}
|
|
7490
|
-
}
|
|
7491
|
-
]);
|
|
7492
|
-
return DefaultViewPlugin;
|
|
7493
|
-
}();
|
|
7494
7508
|
var PLAYER_VERSION = "__VERSION__";
|
|
7495
7509
|
var COMMIT = "__GIT_COMMIT__";
|
|
7496
7510
|
var _Player = /*#__PURE__*/ function() {
|
|
@@ -7520,8 +7534,7 @@ var BeaconPlugin = function() {
|
|
|
7520
7534
|
}
|
|
7521
7535
|
this.config = config || {};
|
|
7522
7536
|
this.config.plugins = [
|
|
7523
|
-
new DefaultExpPlugin()
|
|
7524
|
-
new DefaultViewPlugin()
|
|
7537
|
+
new DefaultExpPlugin()
|
|
7525
7538
|
].concat(_to_consumable_array(this.config.plugins || []), [
|
|
7526
7539
|
new FlowExpPlugin()
|
|
7527
7540
|
]);
|
|
@@ -7708,95 +7721,41 @@ var BeaconPlugin = function() {
|
|
|
7708
7721
|
validationController.reset();
|
|
7709
7722
|
}
|
|
7710
7723
|
});
|
|
7711
|
-
flow.hooks.afterTransition.tap("player", function(flowInstance) {
|
|
7724
|
+
flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
|
|
7712
7725
|
var _flowInstance_currentState;
|
|
7713
7726
|
var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
7714
|
-
if (value && value.state_type === "
|
|
7727
|
+
if (value && value.state_type === "ASYNC_ACTION") {
|
|
7715
7728
|
var exp = value.exp;
|
|
7716
|
-
|
|
7717
|
-
|
|
7729
|
+
try {
|
|
7730
|
+
var result = expressionEvaluator.evaluateAsync(exp);
|
|
7731
|
+
if (isPromiseLike(result)) {
|
|
7732
|
+
if (value.await) {
|
|
7733
|
+
queueMicrotask(function() {
|
|
7734
|
+
result.then(function(r) {
|
|
7735
|
+
return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
|
|
7736
|
+
}).catch(flowResultDeferred.reject);
|
|
7737
|
+
});
|
|
7738
|
+
} else {
|
|
7739
|
+
_this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
|
|
7740
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7741
|
+
}
|
|
7742
|
+
} else {
|
|
7743
|
+
_this.logger.warn("Non async expression used in async action node");
|
|
7744
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7745
|
+
}
|
|
7746
|
+
} catch (e) {
|
|
7747
|
+
flowResultDeferred.reject(e);
|
|
7748
|
+
}
|
|
7749
|
+
} else if (value && value.state_type === "ACTION") {
|
|
7750
|
+
var exp1 = value.exp;
|
|
7751
|
+
var result1 = expressionEvaluator.evaluate(exp1);
|
|
7752
|
+
if (isPromiseLike(result1)) {
|
|
7718
7753
|
_this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
|
|
7719
7754
|
}
|
|
7720
|
-
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(
|
|
7755
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
|
|
7721
7756
|
}
|
|
7722
7757
|
expressionEvaluator.reset();
|
|
7723
7758
|
});
|
|
7724
|
-
var _this1 = _this;
|
|
7725
|
-
flow.hooks.afterTransition.tap("player", function() {
|
|
7726
|
-
var _ref = _async_to_generator(function(flowInstance) {
|
|
7727
|
-
var _flowInstance_currentState, value, exp, result, e;
|
|
7728
|
-
return _ts_generator(this, function(_state) {
|
|
7729
|
-
switch(_state.label){
|
|
7730
|
-
case 0:
|
|
7731
|
-
value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
7732
|
-
if (!(value && value.state_type === "ASYNC_ACTION")) return [
|
|
7733
|
-
3,
|
|
7734
|
-
8
|
|
7735
|
-
];
|
|
7736
|
-
exp = value.exp;
|
|
7737
|
-
_state.label = 1;
|
|
7738
|
-
case 1:
|
|
7739
|
-
_state.trys.push([
|
|
7740
|
-
1,
|
|
7741
|
-
7,
|
|
7742
|
-
,
|
|
7743
|
-
8
|
|
7744
|
-
]);
|
|
7745
|
-
result = expressionEvaluator.evaluateAsync(exp);
|
|
7746
|
-
if (!isPromiseLike(result)) return [
|
|
7747
|
-
3,
|
|
7748
|
-
5
|
|
7749
|
-
];
|
|
7750
|
-
if (!value.await) return [
|
|
7751
|
-
3,
|
|
7752
|
-
3
|
|
7753
|
-
];
|
|
7754
|
-
return [
|
|
7755
|
-
4,
|
|
7756
|
-
result
|
|
7757
|
-
];
|
|
7758
|
-
case 2:
|
|
7759
|
-
result = _state.sent();
|
|
7760
|
-
return [
|
|
7761
|
-
3,
|
|
7762
|
-
4
|
|
7763
|
-
];
|
|
7764
|
-
case 3:
|
|
7765
|
-
_this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
|
|
7766
|
-
_state.label = 4;
|
|
7767
|
-
case 4:
|
|
7768
|
-
return [
|
|
7769
|
-
3,
|
|
7770
|
-
6
|
|
7771
|
-
];
|
|
7772
|
-
case 5:
|
|
7773
|
-
_this1.logger.warn("Non async expression used in async action node");
|
|
7774
|
-
_state.label = 6;
|
|
7775
|
-
case 6:
|
|
7776
|
-
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7777
|
-
return [
|
|
7778
|
-
3,
|
|
7779
|
-
8
|
|
7780
|
-
];
|
|
7781
|
-
case 7:
|
|
7782
|
-
e = _state.sent();
|
|
7783
|
-
flowResultDeferred.reject(e);
|
|
7784
|
-
return [
|
|
7785
|
-
3,
|
|
7786
|
-
8
|
|
7787
|
-
];
|
|
7788
|
-
case 8:
|
|
7789
|
-
expressionEvaluator.reset();
|
|
7790
|
-
return [
|
|
7791
|
-
2
|
|
7792
|
-
];
|
|
7793
|
-
}
|
|
7794
|
-
});
|
|
7795
|
-
});
|
|
7796
|
-
return function(flowInstance) {
|
|
7797
|
-
return _ref.apply(this, arguments);
|
|
7798
|
-
};
|
|
7799
|
-
}());
|
|
7800
7759
|
});
|
|
7801
7760
|
this.hooks.dataController.call(dataController);
|
|
7802
7761
|
validationController.setOptions({
|
|
@@ -7834,11 +7793,9 @@ var BeaconPlugin = function() {
|
|
|
7834
7793
|
}),
|
|
7835
7794
|
constants: this.constantsController
|
|
7836
7795
|
});
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
_this.hooks.view.call(view);
|
|
7841
|
-
});
|
|
7796
|
+
viewController.hooks.view.tap("player", function(view) {
|
|
7797
|
+
validationController.onView(view);
|
|
7798
|
+
_this.hooks.view.call(view);
|
|
7842
7799
|
});
|
|
7843
7800
|
this.hooks.viewController.call(viewController);
|
|
7844
7801
|
return {
|