@player-ui/metrics-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.
|
@@ -5156,20 +5156,15 @@ var MetricsPlugin = function() {
|
|
|
5156
5156
|
}();
|
|
5157
5157
|
var ViewInstance = /*#__PURE__*/ function() {
|
|
5158
5158
|
function ViewInstance(initialView, resolverOptions) {
|
|
5159
|
-
var _this = this;
|
|
5160
5159
|
_class_call_check(this, ViewInstance);
|
|
5161
5160
|
this.hooks = {
|
|
5162
5161
|
onUpdate: new SyncHook(),
|
|
5163
5162
|
parser: new SyncHook(),
|
|
5164
5163
|
resolver: new SyncHook(),
|
|
5165
|
-
onTemplatePluginCreated: new SyncHook(),
|
|
5166
5164
|
templatePlugin: new SyncHook()
|
|
5167
5165
|
};
|
|
5168
5166
|
this.initialView = initialView;
|
|
5169
5167
|
this.resolverOptions = resolverOptions;
|
|
5170
|
-
this.hooks.onTemplatePluginCreated.tap("view", function(templatePlugin) {
|
|
5171
|
-
_this.templatePlugin = templatePlugin;
|
|
5172
|
-
});
|
|
5173
5168
|
}
|
|
5174
5169
|
_create_class(ViewInstance, [
|
|
5175
5170
|
{
|
|
@@ -5216,6 +5211,12 @@ var MetricsPlugin = function() {
|
|
|
5216
5211
|
var _this_validationProvider;
|
|
5217
5212
|
return (_this_validationProvider = this.validationProvider) === null || _this_validationProvider === void 0 ? void 0 : _this_validationProvider.getValidationsForBinding(binding);
|
|
5218
5213
|
}
|
|
5214
|
+
},
|
|
5215
|
+
{
|
|
5216
|
+
key: "setTemplatePlugin",
|
|
5217
|
+
value: function setTemplatePlugin(plugin) {
|
|
5218
|
+
this.templatePlugin = plugin;
|
|
5219
|
+
}
|
|
5219
5220
|
}
|
|
5220
5221
|
]);
|
|
5221
5222
|
return ViewInstance;
|
|
@@ -5387,6 +5388,7 @@ var MetricsPlugin = function() {
|
|
|
5387
5388
|
value: function apply(view) {
|
|
5388
5389
|
view.hooks.parser.tap("template", this.applyParser.bind(this));
|
|
5389
5390
|
view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
|
|
5391
|
+
view.setTemplatePlugin(this);
|
|
5390
5392
|
}
|
|
5391
5393
|
}
|
|
5392
5394
|
]);
|
|
@@ -5966,13 +5968,13 @@ var MetricsPlugin = function() {
|
|
|
5966
5968
|
this.isTransitioning = false;
|
|
5967
5969
|
this.hooks = {
|
|
5968
5970
|
beforeStart: new SyncBailHook(),
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5971
|
+
onStart: new SyncHook(),
|
|
5972
|
+
onEnd: new SyncHook(),
|
|
5973
|
+
skipTransition: new SyncBailHook(),
|
|
5974
|
+
beforeTransition: new SyncWaterfallHook(),
|
|
5975
|
+
resolveTransitionNode: new SyncWaterfallHook(),
|
|
5976
|
+
transition: new SyncHook(),
|
|
5977
|
+
afterTransition: new SyncHook()
|
|
5976
5978
|
};
|
|
5977
5979
|
this.id = id;
|
|
5978
5980
|
this.flow = flow;
|
|
@@ -6995,8 +6997,7 @@ var MetricsPlugin = function() {
|
|
|
6995
6997
|
var _this1 = this;
|
|
6996
6998
|
_class_call_check(this, ViewController);
|
|
6997
6999
|
this.hooks = {
|
|
6998
|
-
|
|
6999
|
-
// The hook right before the View starts resolving. Attach anything custom here
|
|
7000
|
+
resolveView: new SyncWaterfallHook(),
|
|
7000
7001
|
view: new SyncHook()
|
|
7001
7002
|
};
|
|
7002
7003
|
this.transformRegistry = new Registry();
|
|
@@ -7044,6 +7045,7 @@ var MetricsPlugin = function() {
|
|
|
7044
7045
|
]));
|
|
7045
7046
|
}
|
|
7046
7047
|
});
|
|
7048
|
+
this.viewPlugins = this.createViewPlugins();
|
|
7047
7049
|
}
|
|
7048
7050
|
_create_class(ViewController, [
|
|
7049
7051
|
{
|
|
@@ -7099,9 +7101,50 @@ var MetricsPlugin = function() {
|
|
|
7099
7101
|
}
|
|
7100
7102
|
var view = new ViewInstance(source, this.viewOptions);
|
|
7101
7103
|
this.currentView = view;
|
|
7104
|
+
this.applyViewPlugins(view);
|
|
7102
7105
|
this.hooks.view.call(view);
|
|
7103
7106
|
view.update();
|
|
7104
7107
|
}
|
|
7108
|
+
},
|
|
7109
|
+
{
|
|
7110
|
+
key: "applyViewPlugins",
|
|
7111
|
+
value: function applyViewPlugins(view) {
|
|
7112
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
7113
|
+
try {
|
|
7114
|
+
for(var _iterator = this.viewPlugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
7115
|
+
var plugin = _step.value;
|
|
7116
|
+
plugin.apply(view);
|
|
7117
|
+
}
|
|
7118
|
+
} catch (err) {
|
|
7119
|
+
_didIteratorError = true;
|
|
7120
|
+
_iteratorError = err;
|
|
7121
|
+
} finally{
|
|
7122
|
+
try {
|
|
7123
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
7124
|
+
_iterator.return();
|
|
7125
|
+
}
|
|
7126
|
+
} finally{
|
|
7127
|
+
if (_didIteratorError) {
|
|
7128
|
+
throw _iteratorError;
|
|
7129
|
+
}
|
|
7130
|
+
}
|
|
7131
|
+
}
|
|
7132
|
+
}
|
|
7133
|
+
},
|
|
7134
|
+
{
|
|
7135
|
+
key: "createViewPlugins",
|
|
7136
|
+
value: function createViewPlugins() {
|
|
7137
|
+
var pluginOptions = toNodeResolveOptions(this.viewOptions);
|
|
7138
|
+
return [
|
|
7139
|
+
new AssetPlugin(),
|
|
7140
|
+
new SwitchPlugin(pluginOptions),
|
|
7141
|
+
new ApplicabilityPlugin(),
|
|
7142
|
+
new AssetTransformCorePlugin(this.transformRegistry),
|
|
7143
|
+
new StringResolverPlugin(),
|
|
7144
|
+
new TemplatePlugin(pluginOptions),
|
|
7145
|
+
new MultiNodePlugin()
|
|
7146
|
+
];
|
|
7147
|
+
}
|
|
7105
7148
|
}
|
|
7106
7149
|
]);
|
|
7107
7150
|
return ViewController;
|
|
@@ -7474,35 +7517,6 @@ var MetricsPlugin = function() {
|
|
|
7474
7517
|
ref: Symbol("not-started"),
|
|
7475
7518
|
status: "not-started"
|
|
7476
7519
|
};
|
|
7477
|
-
var DefaultViewPlugin = /*#__PURE__*/ function() {
|
|
7478
|
-
function DefaultViewPlugin() {
|
|
7479
|
-
_class_call_check(this, DefaultViewPlugin);
|
|
7480
|
-
this.name = "default-view-plugin";
|
|
7481
|
-
}
|
|
7482
|
-
_create_class(DefaultViewPlugin, [
|
|
7483
|
-
{
|
|
7484
|
-
key: "apply",
|
|
7485
|
-
value: function apply(player) {
|
|
7486
|
-
var _this = this;
|
|
7487
|
-
player.hooks.viewController.tap(this.name, function(viewController) {
|
|
7488
|
-
viewController.hooks.view.tap(_this.name, function(view) {
|
|
7489
|
-
var pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
7490
|
-
new AssetPlugin().apply(view);
|
|
7491
|
-
new SwitchPlugin(pluginOptions).apply(view);
|
|
7492
|
-
new ApplicabilityPlugin().apply(view);
|
|
7493
|
-
new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
|
|
7494
|
-
new StringResolverPlugin().apply(view);
|
|
7495
|
-
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
7496
|
-
templatePlugin.apply(view);
|
|
7497
|
-
view.hooks.onTemplatePluginCreated.call(templatePlugin);
|
|
7498
|
-
new MultiNodePlugin().apply(view);
|
|
7499
|
-
});
|
|
7500
|
-
});
|
|
7501
|
-
}
|
|
7502
|
-
}
|
|
7503
|
-
]);
|
|
7504
|
-
return DefaultViewPlugin;
|
|
7505
|
-
}();
|
|
7506
7520
|
var PLAYER_VERSION = "__VERSION__";
|
|
7507
7521
|
var COMMIT = "__GIT_COMMIT__";
|
|
7508
7522
|
var _Player = /*#__PURE__*/ function() {
|
|
@@ -7532,8 +7546,7 @@ var MetricsPlugin = function() {
|
|
|
7532
7546
|
}
|
|
7533
7547
|
this.config = config || {};
|
|
7534
7548
|
this.config.plugins = [
|
|
7535
|
-
new DefaultExpPlugin()
|
|
7536
|
-
new DefaultViewPlugin()
|
|
7549
|
+
new DefaultExpPlugin()
|
|
7537
7550
|
].concat(_to_consumable_array(this.config.plugins || []), [
|
|
7538
7551
|
new FlowExpPlugin()
|
|
7539
7552
|
]);
|
|
@@ -7720,95 +7733,41 @@ var MetricsPlugin = function() {
|
|
|
7720
7733
|
validationController.reset();
|
|
7721
7734
|
}
|
|
7722
7735
|
});
|
|
7723
|
-
flow.hooks.afterTransition.tap("player", function(flowInstance) {
|
|
7736
|
+
flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
|
|
7724
7737
|
var _flowInstance_currentState;
|
|
7725
7738
|
var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
7726
|
-
if (value && value.state_type === "
|
|
7739
|
+
if (value && value.state_type === "ASYNC_ACTION") {
|
|
7727
7740
|
var exp = value.exp;
|
|
7728
|
-
|
|
7729
|
-
|
|
7741
|
+
try {
|
|
7742
|
+
var result = expressionEvaluator.evaluateAsync(exp);
|
|
7743
|
+
if (isPromiseLike(result)) {
|
|
7744
|
+
if (value.await) {
|
|
7745
|
+
queueMicrotask(function() {
|
|
7746
|
+
result.then(function(r) {
|
|
7747
|
+
return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
|
|
7748
|
+
}).catch(flowResultDeferred.reject);
|
|
7749
|
+
});
|
|
7750
|
+
} else {
|
|
7751
|
+
_this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
|
|
7752
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7753
|
+
}
|
|
7754
|
+
} else {
|
|
7755
|
+
_this.logger.warn("Non async expression used in async action node");
|
|
7756
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7757
|
+
}
|
|
7758
|
+
} catch (e) {
|
|
7759
|
+
flowResultDeferred.reject(e);
|
|
7760
|
+
}
|
|
7761
|
+
} else if (value && value.state_type === "ACTION") {
|
|
7762
|
+
var exp1 = value.exp;
|
|
7763
|
+
var result1 = expressionEvaluator.evaluate(exp1);
|
|
7764
|
+
if (isPromiseLike(result1)) {
|
|
7730
7765
|
_this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
|
|
7731
7766
|
}
|
|
7732
|
-
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(
|
|
7767
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
|
|
7733
7768
|
}
|
|
7734
7769
|
expressionEvaluator.reset();
|
|
7735
7770
|
});
|
|
7736
|
-
var _this1 = _this;
|
|
7737
|
-
flow.hooks.afterTransition.tap("player", function() {
|
|
7738
|
-
var _ref = _async_to_generator(function(flowInstance) {
|
|
7739
|
-
var _flowInstance_currentState, value, exp, result, e;
|
|
7740
|
-
return _ts_generator(this, function(_state) {
|
|
7741
|
-
switch(_state.label){
|
|
7742
|
-
case 0:
|
|
7743
|
-
value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
7744
|
-
if (!(value && value.state_type === "ASYNC_ACTION")) return [
|
|
7745
|
-
3,
|
|
7746
|
-
8
|
|
7747
|
-
];
|
|
7748
|
-
exp = value.exp;
|
|
7749
|
-
_state.label = 1;
|
|
7750
|
-
case 1:
|
|
7751
|
-
_state.trys.push([
|
|
7752
|
-
1,
|
|
7753
|
-
7,
|
|
7754
|
-
,
|
|
7755
|
-
8
|
|
7756
|
-
]);
|
|
7757
|
-
result = expressionEvaluator.evaluateAsync(exp);
|
|
7758
|
-
if (!isPromiseLike(result)) return [
|
|
7759
|
-
3,
|
|
7760
|
-
5
|
|
7761
|
-
];
|
|
7762
|
-
if (!value.await) return [
|
|
7763
|
-
3,
|
|
7764
|
-
3
|
|
7765
|
-
];
|
|
7766
|
-
return [
|
|
7767
|
-
4,
|
|
7768
|
-
result
|
|
7769
|
-
];
|
|
7770
|
-
case 2:
|
|
7771
|
-
result = _state.sent();
|
|
7772
|
-
return [
|
|
7773
|
-
3,
|
|
7774
|
-
4
|
|
7775
|
-
];
|
|
7776
|
-
case 3:
|
|
7777
|
-
_this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
|
|
7778
|
-
_state.label = 4;
|
|
7779
|
-
case 4:
|
|
7780
|
-
return [
|
|
7781
|
-
3,
|
|
7782
|
-
6
|
|
7783
|
-
];
|
|
7784
|
-
case 5:
|
|
7785
|
-
_this1.logger.warn("Non async expression used in async action node");
|
|
7786
|
-
_state.label = 6;
|
|
7787
|
-
case 6:
|
|
7788
|
-
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7789
|
-
return [
|
|
7790
|
-
3,
|
|
7791
|
-
8
|
|
7792
|
-
];
|
|
7793
|
-
case 7:
|
|
7794
|
-
e = _state.sent();
|
|
7795
|
-
flowResultDeferred.reject(e);
|
|
7796
|
-
return [
|
|
7797
|
-
3,
|
|
7798
|
-
8
|
|
7799
|
-
];
|
|
7800
|
-
case 8:
|
|
7801
|
-
expressionEvaluator.reset();
|
|
7802
|
-
return [
|
|
7803
|
-
2
|
|
7804
|
-
];
|
|
7805
|
-
}
|
|
7806
|
-
});
|
|
7807
|
-
});
|
|
7808
|
-
return function(flowInstance) {
|
|
7809
|
-
return _ref.apply(this, arguments);
|
|
7810
|
-
};
|
|
7811
|
-
}());
|
|
7812
7771
|
});
|
|
7813
7772
|
this.hooks.dataController.call(dataController);
|
|
7814
7773
|
validationController.setOptions({
|
|
@@ -7846,11 +7805,9 @@ var MetricsPlugin = function() {
|
|
|
7846
7805
|
}),
|
|
7847
7806
|
constants: this.constantsController
|
|
7848
7807
|
});
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
_this.hooks.view.call(view);
|
|
7853
|
-
});
|
|
7808
|
+
viewController.hooks.view.tap("player", function(view) {
|
|
7809
|
+
validationController.onView(view);
|
|
7810
|
+
_this.hooks.view.call(view);
|
|
7854
7811
|
});
|
|
7855
7812
|
this.hooks.viewController.call(viewController);
|
|
7856
7813
|
return {
|