@player-ui/player 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.
- package/dist/Player.native.js +88 -132
- package/dist/Player.native.js.map +1 -1
- package/dist/cjs/index.cjs +42 -62
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +44 -64
- package/dist/index.mjs +44 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/flow.test.ts +165 -1
- package/src/__tests__/player.test.ts +77 -1
- package/src/controllers/flow/controller.ts +9 -2
- package/src/controllers/flow/flow.ts +54 -16
- package/src/controllers/view/controller.ts +49 -12
- package/src/expressions/__tests__/evaluator.test.ts +10 -0
- package/src/player.ts +24 -29
- package/src/view/plugins/template.ts +1 -0
- package/src/view/view.ts +25 -12
- package/types/controllers/flow/controller.d.ts +4 -3
- package/types/controllers/flow/flow.d.ts +31 -18
- package/types/controllers/view/controller.d.ts +14 -7
- package/types/view/view.d.ts +13 -10
- package/src/plugins/default-view-plugin.ts +0 -37
- package/types/plugins/default-view-plugin.d.ts +0 -9
package/dist/Player.native.js
CHANGED
|
@@ -5396,20 +5396,15 @@ var Player = function() {
|
|
|
5396
5396
|
}();
|
|
5397
5397
|
var ViewInstance = /*#__PURE__*/ function() {
|
|
5398
5398
|
function ViewInstance(initialView, resolverOptions) {
|
|
5399
|
-
var _this = this;
|
|
5400
5399
|
_class_call_check(this, ViewInstance);
|
|
5401
5400
|
this.hooks = {
|
|
5402
5401
|
onUpdate: new SyncHook(),
|
|
5403
5402
|
parser: new SyncHook(),
|
|
5404
5403
|
resolver: new SyncHook(),
|
|
5405
|
-
onTemplatePluginCreated: new SyncHook(),
|
|
5406
5404
|
templatePlugin: new SyncHook()
|
|
5407
5405
|
};
|
|
5408
5406
|
this.initialView = initialView;
|
|
5409
5407
|
this.resolverOptions = resolverOptions;
|
|
5410
|
-
this.hooks.onTemplatePluginCreated.tap("view", function(templatePlugin) {
|
|
5411
|
-
_this.templatePlugin = templatePlugin;
|
|
5412
|
-
});
|
|
5413
5408
|
}
|
|
5414
5409
|
_create_class(ViewInstance, [
|
|
5415
5410
|
{
|
|
@@ -5456,6 +5451,12 @@ var Player = function() {
|
|
|
5456
5451
|
var _this_validationProvider;
|
|
5457
5452
|
return (_this_validationProvider = this.validationProvider) === null || _this_validationProvider === void 0 ? void 0 : _this_validationProvider.getValidationsForBinding(binding);
|
|
5458
5453
|
}
|
|
5454
|
+
},
|
|
5455
|
+
{
|
|
5456
|
+
key: "setTemplatePlugin",
|
|
5457
|
+
value: function setTemplatePlugin(plugin) {
|
|
5458
|
+
this.templatePlugin = plugin;
|
|
5459
|
+
}
|
|
5459
5460
|
}
|
|
5460
5461
|
]);
|
|
5461
5462
|
return ViewInstance;
|
|
@@ -5756,6 +5757,7 @@ var Player = function() {
|
|
|
5756
5757
|
value: function apply(view) {
|
|
5757
5758
|
view.hooks.parser.tap("template", this.applyParser.bind(this));
|
|
5758
5759
|
view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
|
|
5760
|
+
view.setTemplatePlugin(this);
|
|
5759
5761
|
}
|
|
5760
5762
|
}
|
|
5761
5763
|
]);
|
|
@@ -6349,13 +6351,13 @@ var Player = function() {
|
|
|
6349
6351
|
this.isTransitioning = false;
|
|
6350
6352
|
this.hooks = {
|
|
6351
6353
|
beforeStart: new SyncBailHook(),
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6354
|
+
onStart: new SyncHook(),
|
|
6355
|
+
onEnd: new SyncHook(),
|
|
6356
|
+
skipTransition: new SyncBailHook(),
|
|
6357
|
+
beforeTransition: new SyncWaterfallHook(),
|
|
6358
|
+
resolveTransitionNode: new SyncWaterfallHook(),
|
|
6359
|
+
transition: new SyncHook(),
|
|
6360
|
+
afterTransition: new SyncHook()
|
|
6359
6361
|
};
|
|
6360
6362
|
this.id = id;
|
|
6361
6363
|
this.flow = flow;
|
|
@@ -7515,8 +7517,7 @@ var Player = function() {
|
|
|
7515
7517
|
var _this1 = this;
|
|
7516
7518
|
_class_call_check(this, ViewController);
|
|
7517
7519
|
this.hooks = {
|
|
7518
|
-
|
|
7519
|
-
// The hook right before the View starts resolving. Attach anything custom here
|
|
7520
|
+
resolveView: new SyncWaterfallHook(),
|
|
7520
7521
|
view: new SyncHook()
|
|
7521
7522
|
};
|
|
7522
7523
|
this.transformRegistry = new Registry();
|
|
@@ -7564,6 +7565,7 @@ var Player = function() {
|
|
|
7564
7565
|
]));
|
|
7565
7566
|
}
|
|
7566
7567
|
});
|
|
7568
|
+
this.viewPlugins = this.createViewPlugins();
|
|
7567
7569
|
}
|
|
7568
7570
|
_create_class(ViewController, [
|
|
7569
7571
|
{
|
|
@@ -7619,9 +7621,50 @@ var Player = function() {
|
|
|
7619
7621
|
}
|
|
7620
7622
|
var view = new ViewInstance(source, this.viewOptions);
|
|
7621
7623
|
this.currentView = view;
|
|
7624
|
+
this.applyViewPlugins(view);
|
|
7622
7625
|
this.hooks.view.call(view);
|
|
7623
7626
|
view.update();
|
|
7624
7627
|
}
|
|
7628
|
+
},
|
|
7629
|
+
{
|
|
7630
|
+
key: "applyViewPlugins",
|
|
7631
|
+
value: function applyViewPlugins(view) {
|
|
7632
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
7633
|
+
try {
|
|
7634
|
+
for(var _iterator = this.viewPlugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
7635
|
+
var plugin = _step.value;
|
|
7636
|
+
plugin.apply(view);
|
|
7637
|
+
}
|
|
7638
|
+
} catch (err) {
|
|
7639
|
+
_didIteratorError = true;
|
|
7640
|
+
_iteratorError = err;
|
|
7641
|
+
} finally{
|
|
7642
|
+
try {
|
|
7643
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
7644
|
+
_iterator.return();
|
|
7645
|
+
}
|
|
7646
|
+
} finally{
|
|
7647
|
+
if (_didIteratorError) {
|
|
7648
|
+
throw _iteratorError;
|
|
7649
|
+
}
|
|
7650
|
+
}
|
|
7651
|
+
}
|
|
7652
|
+
}
|
|
7653
|
+
},
|
|
7654
|
+
{
|
|
7655
|
+
key: "createViewPlugins",
|
|
7656
|
+
value: function createViewPlugins() {
|
|
7657
|
+
var pluginOptions = toNodeResolveOptions(this.viewOptions);
|
|
7658
|
+
return [
|
|
7659
|
+
new AssetPlugin(),
|
|
7660
|
+
new SwitchPlugin(pluginOptions),
|
|
7661
|
+
new ApplicabilityPlugin(),
|
|
7662
|
+
new AssetTransformCorePlugin(this.transformRegistry),
|
|
7663
|
+
new StringResolverPlugin(),
|
|
7664
|
+
new TemplatePlugin(pluginOptions),
|
|
7665
|
+
new MultiNodePlugin()
|
|
7666
|
+
];
|
|
7667
|
+
}
|
|
7625
7668
|
}
|
|
7626
7669
|
]);
|
|
7627
7670
|
return ViewController;
|
|
@@ -8001,36 +8044,6 @@ var Player = function() {
|
|
|
8001
8044
|
ref: Symbol("not-started"),
|
|
8002
8045
|
status: "not-started"
|
|
8003
8046
|
};
|
|
8004
|
-
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/plugins/default-view-plugin.ts
|
|
8005
|
-
var DefaultViewPlugin = /*#__PURE__*/ function() {
|
|
8006
|
-
function DefaultViewPlugin() {
|
|
8007
|
-
_class_call_check(this, DefaultViewPlugin);
|
|
8008
|
-
this.name = "default-view-plugin";
|
|
8009
|
-
}
|
|
8010
|
-
_create_class(DefaultViewPlugin, [
|
|
8011
|
-
{
|
|
8012
|
-
key: "apply",
|
|
8013
|
-
value: function apply(player) {
|
|
8014
|
-
var _this = this;
|
|
8015
|
-
player.hooks.viewController.tap(this.name, function(viewController) {
|
|
8016
|
-
viewController.hooks.view.tap(_this.name, function(view) {
|
|
8017
|
-
var pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
8018
|
-
new AssetPlugin().apply(view);
|
|
8019
|
-
new SwitchPlugin(pluginOptions).apply(view);
|
|
8020
|
-
new ApplicabilityPlugin().apply(view);
|
|
8021
|
-
new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
|
|
8022
|
-
new StringResolverPlugin().apply(view);
|
|
8023
|
-
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
8024
|
-
templatePlugin.apply(view);
|
|
8025
|
-
view.hooks.onTemplatePluginCreated.call(templatePlugin);
|
|
8026
|
-
new MultiNodePlugin().apply(view);
|
|
8027
|
-
});
|
|
8028
|
-
});
|
|
8029
|
-
}
|
|
8030
|
-
}
|
|
8031
|
-
]);
|
|
8032
|
-
return DefaultViewPlugin;
|
|
8033
|
-
}();
|
|
8034
8047
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/player.ts
|
|
8035
8048
|
var PLAYER_VERSION = "__VERSION__";
|
|
8036
8049
|
var COMMIT = "__GIT_COMMIT__";
|
|
@@ -8061,8 +8074,7 @@ var Player = function() {
|
|
|
8061
8074
|
}
|
|
8062
8075
|
this.config = config || {};
|
|
8063
8076
|
this.config.plugins = [
|
|
8064
|
-
new DefaultExpPlugin()
|
|
8065
|
-
new DefaultViewPlugin()
|
|
8077
|
+
new DefaultExpPlugin()
|
|
8066
8078
|
].concat(_to_consumable_array(this.config.plugins || []), [
|
|
8067
8079
|
new FlowExpPlugin()
|
|
8068
8080
|
]);
|
|
@@ -8249,95 +8261,41 @@ var Player = function() {
|
|
|
8249
8261
|
validationController.reset();
|
|
8250
8262
|
}
|
|
8251
8263
|
});
|
|
8252
|
-
flow.hooks.afterTransition.tap("player", function(flowInstance) {
|
|
8264
|
+
flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
|
|
8253
8265
|
var _flowInstance_currentState;
|
|
8254
8266
|
var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
8255
|
-
if (value && value.state_type === "
|
|
8267
|
+
if (value && value.state_type === "ASYNC_ACTION") {
|
|
8256
8268
|
var exp = value.exp;
|
|
8257
|
-
|
|
8258
|
-
|
|
8269
|
+
try {
|
|
8270
|
+
var result = expressionEvaluator.evaluateAsync(exp);
|
|
8271
|
+
if (isPromiseLike(result)) {
|
|
8272
|
+
if (value.await) {
|
|
8273
|
+
queueMicrotask(function() {
|
|
8274
|
+
result.then(function(r) {
|
|
8275
|
+
return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
|
|
8276
|
+
}).catch(flowResultDeferred.reject);
|
|
8277
|
+
});
|
|
8278
|
+
} else {
|
|
8279
|
+
_this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
|
|
8280
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
8281
|
+
}
|
|
8282
|
+
} else {
|
|
8283
|
+
_this.logger.warn("Non async expression used in async action node");
|
|
8284
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
8285
|
+
}
|
|
8286
|
+
} catch (e) {
|
|
8287
|
+
flowResultDeferred.reject(e);
|
|
8288
|
+
}
|
|
8289
|
+
} else if (value && value.state_type === "ACTION") {
|
|
8290
|
+
var exp1 = value.exp;
|
|
8291
|
+
var result1 = expressionEvaluator.evaluate(exp1);
|
|
8292
|
+
if (isPromiseLike(result1)) {
|
|
8259
8293
|
_this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
|
|
8260
8294
|
}
|
|
8261
|
-
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(
|
|
8295
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
|
|
8262
8296
|
}
|
|
8263
8297
|
expressionEvaluator.reset();
|
|
8264
8298
|
});
|
|
8265
|
-
var _this1 = _this;
|
|
8266
|
-
flow.hooks.afterTransition.tap("player", function() {
|
|
8267
|
-
var _ref = _async_to_generator(function(flowInstance) {
|
|
8268
|
-
var _flowInstance_currentState, value, exp, result, e;
|
|
8269
|
-
return _ts_generator(this, function(_state) {
|
|
8270
|
-
switch(_state.label){
|
|
8271
|
-
case 0:
|
|
8272
|
-
value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
8273
|
-
if (!(value && value.state_type === "ASYNC_ACTION")) return [
|
|
8274
|
-
3,
|
|
8275
|
-
8
|
|
8276
|
-
];
|
|
8277
|
-
exp = value.exp;
|
|
8278
|
-
_state.label = 1;
|
|
8279
|
-
case 1:
|
|
8280
|
-
_state.trys.push([
|
|
8281
|
-
1,
|
|
8282
|
-
7,
|
|
8283
|
-
,
|
|
8284
|
-
8
|
|
8285
|
-
]);
|
|
8286
|
-
result = expressionEvaluator.evaluateAsync(exp);
|
|
8287
|
-
if (!isPromiseLike(result)) return [
|
|
8288
|
-
3,
|
|
8289
|
-
5
|
|
8290
|
-
];
|
|
8291
|
-
if (!value.await) return [
|
|
8292
|
-
3,
|
|
8293
|
-
3
|
|
8294
|
-
];
|
|
8295
|
-
return [
|
|
8296
|
-
4,
|
|
8297
|
-
result
|
|
8298
|
-
];
|
|
8299
|
-
case 2:
|
|
8300
|
-
result = _state.sent();
|
|
8301
|
-
return [
|
|
8302
|
-
3,
|
|
8303
|
-
4
|
|
8304
|
-
];
|
|
8305
|
-
case 3:
|
|
8306
|
-
_this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
|
|
8307
|
-
_state.label = 4;
|
|
8308
|
-
case 4:
|
|
8309
|
-
return [
|
|
8310
|
-
3,
|
|
8311
|
-
6
|
|
8312
|
-
];
|
|
8313
|
-
case 5:
|
|
8314
|
-
_this1.logger.warn("Non async expression used in async action node");
|
|
8315
|
-
_state.label = 6;
|
|
8316
|
-
case 6:
|
|
8317
|
-
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
8318
|
-
return [
|
|
8319
|
-
3,
|
|
8320
|
-
8
|
|
8321
|
-
];
|
|
8322
|
-
case 7:
|
|
8323
|
-
e = _state.sent();
|
|
8324
|
-
flowResultDeferred.reject(e);
|
|
8325
|
-
return [
|
|
8326
|
-
3,
|
|
8327
|
-
8
|
|
8328
|
-
];
|
|
8329
|
-
case 8:
|
|
8330
|
-
expressionEvaluator.reset();
|
|
8331
|
-
return [
|
|
8332
|
-
2
|
|
8333
|
-
];
|
|
8334
|
-
}
|
|
8335
|
-
});
|
|
8336
|
-
});
|
|
8337
|
-
return function(flowInstance) {
|
|
8338
|
-
return _ref.apply(this, arguments);
|
|
8339
|
-
};
|
|
8340
|
-
}());
|
|
8341
8299
|
});
|
|
8342
8300
|
this.hooks.dataController.call(dataController);
|
|
8343
8301
|
validationController.setOptions({
|
|
@@ -8375,11 +8333,9 @@ var Player = function() {
|
|
|
8375
8333
|
}),
|
|
8376
8334
|
constants: this.constantsController
|
|
8377
8335
|
});
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
_this.hooks.view.call(view);
|
|
8382
|
-
});
|
|
8336
|
+
viewController.hooks.view.tap("player", function(view) {
|
|
8337
|
+
validationController.onView(view);
|
|
8338
|
+
_this.hooks.view.call(view);
|
|
8383
8339
|
});
|
|
8384
8340
|
this.hooks.viewController.call(viewController);
|
|
8385
8341
|
return {
|