@player-ui/reference-assets-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.
@@ -5355,20 +5355,15 @@ var ReferenceAssetsPlugin = function() {
5355
5355
  }();
5356
5356
  var ViewInstance = /*#__PURE__*/ function() {
5357
5357
  function ViewInstance(initialView, resolverOptions) {
5358
- var _this = this;
5359
5358
  _class_call_check(this, ViewInstance);
5360
5359
  this.hooks = {
5361
5360
  onUpdate: new SyncHook(),
5362
5361
  parser: new SyncHook(),
5363
5362
  resolver: new SyncHook(),
5364
- onTemplatePluginCreated: new SyncHook(),
5365
5363
  templatePlugin: new SyncHook()
5366
5364
  };
5367
5365
  this.initialView = initialView;
5368
5366
  this.resolverOptions = resolverOptions;
5369
- this.hooks.onTemplatePluginCreated.tap("view", function(templatePlugin) {
5370
- _this.templatePlugin = templatePlugin;
5371
- });
5372
5367
  }
5373
5368
  _create_class(ViewInstance, [
5374
5369
  {
@@ -5415,6 +5410,12 @@ var ReferenceAssetsPlugin = function() {
5415
5410
  var _this_validationProvider;
5416
5411
  return (_this_validationProvider = this.validationProvider) === null || _this_validationProvider === void 0 ? void 0 : _this_validationProvider.getValidationsForBinding(binding);
5417
5412
  }
5413
+ },
5414
+ {
5415
+ key: "setTemplatePlugin",
5416
+ value: function setTemplatePlugin(plugin) {
5417
+ this.templatePlugin = plugin;
5418
+ }
5418
5419
  }
5419
5420
  ]);
5420
5421
  return ViewInstance;
@@ -5713,6 +5714,7 @@ var ReferenceAssetsPlugin = function() {
5713
5714
  value: function apply(view) {
5714
5715
  view.hooks.parser.tap("template", this.applyParser.bind(this));
5715
5716
  view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
5717
+ view.setTemplatePlugin(this);
5716
5718
  }
5717
5719
  }
5718
5720
  ]);
@@ -6292,13 +6294,13 @@ var ReferenceAssetsPlugin = function() {
6292
6294
  this.isTransitioning = false;
6293
6295
  this.hooks = {
6294
6296
  beforeStart: new SyncBailHook(),
6295
- /** A callback when the onStart node was present */ onStart: new SyncHook(),
6296
- /** A callback when the onEnd node was present */ onEnd: new SyncHook(),
6297
- /** A hook to intercept and block a transition */ skipTransition: new SyncBailHook(),
6298
- /** A chance to manipulate the flow-node used to calculate the given transition used */ beforeTransition: new SyncWaterfallHook(),
6299
- /** A chance to manipulate the flow-node calculated after a transition */ resolveTransitionNode: new SyncWaterfallHook(),
6300
- /** A callback when a transition from 1 state to another was made */ transition: new SyncHook(),
6301
- /** A callback to run actions after a transition occurs */ afterTransition: new SyncHook()
6297
+ onStart: new SyncHook(),
6298
+ onEnd: new SyncHook(),
6299
+ skipTransition: new SyncBailHook(),
6300
+ beforeTransition: new SyncWaterfallHook(),
6301
+ resolveTransitionNode: new SyncWaterfallHook(),
6302
+ transition: new SyncHook(),
6303
+ afterTransition: new SyncHook()
6302
6304
  };
6303
6305
  this.id = id;
6304
6306
  this.flow = flow;
@@ -7321,8 +7323,7 @@ var ReferenceAssetsPlugin = function() {
7321
7323
  var _this1 = this;
7322
7324
  _class_call_check(this, ViewController);
7323
7325
  this.hooks = {
7324
- /** Do any processing before the `View` instance is created */ resolveView: new SyncWaterfallHook(),
7325
- // The hook right before the View starts resolving. Attach anything custom here
7326
+ resolveView: new SyncWaterfallHook(),
7326
7327
  view: new SyncHook()
7327
7328
  };
7328
7329
  this.transformRegistry = new Registry();
@@ -7370,6 +7371,7 @@ var ReferenceAssetsPlugin = function() {
7370
7371
  ]));
7371
7372
  }
7372
7373
  });
7374
+ this.viewPlugins = this.createViewPlugins();
7373
7375
  }
7374
7376
  _create_class(ViewController, [
7375
7377
  {
@@ -7425,9 +7427,50 @@ var ReferenceAssetsPlugin = function() {
7425
7427
  }
7426
7428
  var view = new ViewInstance(source, this.viewOptions);
7427
7429
  this.currentView = view;
7430
+ this.applyViewPlugins(view);
7428
7431
  this.hooks.view.call(view);
7429
7432
  view.update();
7430
7433
  }
7434
+ },
7435
+ {
7436
+ key: "applyViewPlugins",
7437
+ value: function applyViewPlugins(view) {
7438
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
7439
+ try {
7440
+ for(var _iterator = this.viewPlugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
7441
+ var plugin = _step.value;
7442
+ plugin.apply(view);
7443
+ }
7444
+ } catch (err) {
7445
+ _didIteratorError = true;
7446
+ _iteratorError = err;
7447
+ } finally{
7448
+ try {
7449
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
7450
+ _iterator.return();
7451
+ }
7452
+ } finally{
7453
+ if (_didIteratorError) {
7454
+ throw _iteratorError;
7455
+ }
7456
+ }
7457
+ }
7458
+ }
7459
+ },
7460
+ {
7461
+ key: "createViewPlugins",
7462
+ value: function createViewPlugins() {
7463
+ var pluginOptions = toNodeResolveOptions(this.viewOptions);
7464
+ return [
7465
+ new AssetPlugin(),
7466
+ new SwitchPlugin(pluginOptions),
7467
+ new ApplicabilityPlugin(),
7468
+ new AssetTransformCorePlugin(this.transformRegistry),
7469
+ new StringResolverPlugin(),
7470
+ new TemplatePlugin(pluginOptions),
7471
+ new MultiNodePlugin()
7472
+ ];
7473
+ }
7431
7474
  }
7432
7475
  ]);
7433
7476
  return ViewController;
@@ -7800,35 +7843,6 @@ var ReferenceAssetsPlugin = function() {
7800
7843
  ref: Symbol("not-started"),
7801
7844
  status: "not-started"
7802
7845
  };
7803
- var DefaultViewPlugin = /*#__PURE__*/ function() {
7804
- function DefaultViewPlugin() {
7805
- _class_call_check(this, DefaultViewPlugin);
7806
- this.name = "default-view-plugin";
7807
- }
7808
- _create_class(DefaultViewPlugin, [
7809
- {
7810
- key: "apply",
7811
- value: function apply(player) {
7812
- var _this = this;
7813
- player.hooks.viewController.tap(this.name, function(viewController) {
7814
- viewController.hooks.view.tap(_this.name, function(view) {
7815
- var pluginOptions = toNodeResolveOptions(view.resolverOptions);
7816
- new AssetPlugin().apply(view);
7817
- new SwitchPlugin(pluginOptions).apply(view);
7818
- new ApplicabilityPlugin().apply(view);
7819
- new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
7820
- new StringResolverPlugin().apply(view);
7821
- var templatePlugin = new TemplatePlugin(pluginOptions);
7822
- templatePlugin.apply(view);
7823
- view.hooks.onTemplatePluginCreated.call(templatePlugin);
7824
- new MultiNodePlugin().apply(view);
7825
- });
7826
- });
7827
- }
7828
- }
7829
- ]);
7830
- return DefaultViewPlugin;
7831
- }();
7832
7846
  var PLAYER_VERSION = "__VERSION__";
7833
7847
  var COMMIT = "__GIT_COMMIT__";
7834
7848
  var _Player = /*#__PURE__*/ function() {
@@ -7858,8 +7872,7 @@ var ReferenceAssetsPlugin = function() {
7858
7872
  }
7859
7873
  this.config = config || {};
7860
7874
  this.config.plugins = [
7861
- new DefaultExpPlugin(),
7862
- new DefaultViewPlugin()
7875
+ new DefaultExpPlugin()
7863
7876
  ].concat(_to_consumable_array(this.config.plugins || []), [
7864
7877
  new FlowExpPlugin()
7865
7878
  ]);
@@ -8046,95 +8059,41 @@ var ReferenceAssetsPlugin = function() {
8046
8059
  validationController.reset();
8047
8060
  }
8048
8061
  });
8049
- flow.hooks.afterTransition.tap("player", function(flowInstance) {
8062
+ flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
8050
8063
  var _flowInstance_currentState;
8051
8064
  var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
8052
- if (value && value.state_type === "ACTION") {
8065
+ if (value && value.state_type === "ASYNC_ACTION") {
8053
8066
  var exp = value.exp;
8054
- var result = expressionEvaluator.evaluate(exp);
8055
- if (isPromiseLike(result)) {
8067
+ try {
8068
+ var result = expressionEvaluator.evaluateAsync(exp);
8069
+ if (isPromiseLike(result)) {
8070
+ if (value.await) {
8071
+ queueMicrotask(function() {
8072
+ result.then(function(r) {
8073
+ return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
8074
+ }).catch(flowResultDeferred.reject);
8075
+ });
8076
+ } else {
8077
+ _this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
8078
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8079
+ }
8080
+ } else {
8081
+ _this.logger.warn("Non async expression used in async action node");
8082
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8083
+ }
8084
+ } catch (e) {
8085
+ flowResultDeferred.reject(e);
8086
+ }
8087
+ } else if (value && value.state_type === "ACTION") {
8088
+ var exp1 = value.exp;
8089
+ var result1 = expressionEvaluator.evaluate(exp1);
8090
+ if (isPromiseLike(result1)) {
8056
8091
  _this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
8057
8092
  }
8058
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8093
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
8059
8094
  }
8060
8095
  expressionEvaluator.reset();
8061
8096
  });
8062
- var _this1 = _this;
8063
- flow.hooks.afterTransition.tap("player", function() {
8064
- var _ref = _async_to_generator(function(flowInstance) {
8065
- var _flowInstance_currentState, value, exp, result, e;
8066
- return _ts_generator(this, function(_state) {
8067
- switch(_state.label){
8068
- case 0:
8069
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
8070
- if (!(value && value.state_type === "ASYNC_ACTION")) return [
8071
- 3,
8072
- 8
8073
- ];
8074
- exp = value.exp;
8075
- _state.label = 1;
8076
- case 1:
8077
- _state.trys.push([
8078
- 1,
8079
- 7,
8080
- ,
8081
- 8
8082
- ]);
8083
- result = expressionEvaluator.evaluateAsync(exp);
8084
- if (!isPromiseLike(result)) return [
8085
- 3,
8086
- 5
8087
- ];
8088
- if (!value.await) return [
8089
- 3,
8090
- 3
8091
- ];
8092
- return [
8093
- 4,
8094
- result
8095
- ];
8096
- case 2:
8097
- result = _state.sent();
8098
- return [
8099
- 3,
8100
- 4
8101
- ];
8102
- case 3:
8103
- _this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
8104
- _state.label = 4;
8105
- case 4:
8106
- return [
8107
- 3,
8108
- 6
8109
- ];
8110
- case 5:
8111
- _this1.logger.warn("Non async expression used in async action node");
8112
- _state.label = 6;
8113
- case 6:
8114
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8115
- return [
8116
- 3,
8117
- 8
8118
- ];
8119
- case 7:
8120
- e = _state.sent();
8121
- flowResultDeferred.reject(e);
8122
- return [
8123
- 3,
8124
- 8
8125
- ];
8126
- case 8:
8127
- expressionEvaluator.reset();
8128
- return [
8129
- 2
8130
- ];
8131
- }
8132
- });
8133
- });
8134
- return function(flowInstance) {
8135
- return _ref.apply(this, arguments);
8136
- };
8137
- }());
8138
8097
  });
8139
8098
  this.hooks.dataController.call(dataController);
8140
8099
  validationController.setOptions({
@@ -8172,11 +8131,9 @@ var ReferenceAssetsPlugin = function() {
8172
8131
  }),
8173
8132
  constants: this.constantsController
8174
8133
  });
8175
- this.hooks.viewController.tap("player", function(vc) {
8176
- vc.hooks.view.tap("player", function(view) {
8177
- validationController.onView(view);
8178
- _this.hooks.view.call(view);
8179
- });
8134
+ viewController.hooks.view.tap("player", function(view) {
8135
+ validationController.onView(view);
8136
+ _this.hooks.view.call(view);
8180
8137
  });
8181
8138
  this.hooks.viewController.call(viewController);
8182
8139
  return {