@player-ui/check-path-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.
@@ -5095,20 +5095,15 @@ var CheckPathPlugin = function() {
5095
5095
  }();
5096
5096
  var ViewInstance = /*#__PURE__*/ function() {
5097
5097
  function ViewInstance(initialView, resolverOptions) {
5098
- var _this = this;
5099
5098
  _class_call_check(this, ViewInstance);
5100
5099
  this.hooks = {
5101
5100
  onUpdate: new SyncHook(),
5102
5101
  parser: new SyncHook(),
5103
5102
  resolver: new SyncHook(),
5104
- onTemplatePluginCreated: new SyncHook(),
5105
5103
  templatePlugin: new SyncHook()
5106
5104
  };
5107
5105
  this.initialView = initialView;
5108
5106
  this.resolverOptions = resolverOptions;
5109
- this.hooks.onTemplatePluginCreated.tap("view", function(templatePlugin) {
5110
- _this.templatePlugin = templatePlugin;
5111
- });
5112
5107
  }
5113
5108
  _create_class(ViewInstance, [
5114
5109
  {
@@ -5155,6 +5150,12 @@ var CheckPathPlugin = function() {
5155
5150
  var _this_validationProvider;
5156
5151
  return (_this_validationProvider = this.validationProvider) === null || _this_validationProvider === void 0 ? void 0 : _this_validationProvider.getValidationsForBinding(binding);
5157
5152
  }
5153
+ },
5154
+ {
5155
+ key: "setTemplatePlugin",
5156
+ value: function setTemplatePlugin(plugin) {
5157
+ this.templatePlugin = plugin;
5158
+ }
5158
5159
  }
5159
5160
  ]);
5160
5161
  return ViewInstance;
@@ -5326,6 +5327,7 @@ var CheckPathPlugin = function() {
5326
5327
  value: function apply(view) {
5327
5328
  view.hooks.parser.tap("template", this.applyParser.bind(this));
5328
5329
  view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
5330
+ view.setTemplatePlugin(this);
5329
5331
  }
5330
5332
  }
5331
5333
  ]);
@@ -5905,13 +5907,13 @@ var CheckPathPlugin = function() {
5905
5907
  this.isTransitioning = false;
5906
5908
  this.hooks = {
5907
5909
  beforeStart: new SyncBailHook(),
5908
- /** A callback when the onStart node was present */ onStart: new SyncHook(),
5909
- /** A callback when the onEnd node was present */ onEnd: new SyncHook(),
5910
- /** A hook to intercept and block a transition */ skipTransition: new SyncBailHook(),
5911
- /** A chance to manipulate the flow-node used to calculate the given transition used */ beforeTransition: new SyncWaterfallHook(),
5912
- /** A chance to manipulate the flow-node calculated after a transition */ resolveTransitionNode: new SyncWaterfallHook(),
5913
- /** A callback when a transition from 1 state to another was made */ transition: new SyncHook(),
5914
- /** A callback to run actions after a transition occurs */ afterTransition: new SyncHook()
5910
+ onStart: new SyncHook(),
5911
+ onEnd: new SyncHook(),
5912
+ skipTransition: new SyncBailHook(),
5913
+ beforeTransition: new SyncWaterfallHook(),
5914
+ resolveTransitionNode: new SyncWaterfallHook(),
5915
+ transition: new SyncHook(),
5916
+ afterTransition: new SyncHook()
5915
5917
  };
5916
5918
  this.id = id;
5917
5919
  this.flow = flow;
@@ -6934,8 +6936,7 @@ var CheckPathPlugin = function() {
6934
6936
  var _this1 = this;
6935
6937
  _class_call_check(this, ViewController);
6936
6938
  this.hooks = {
6937
- /** Do any processing before the `View` instance is created */ resolveView: new SyncWaterfallHook(),
6938
- // The hook right before the View starts resolving. Attach anything custom here
6939
+ resolveView: new SyncWaterfallHook(),
6939
6940
  view: new SyncHook()
6940
6941
  };
6941
6942
  this.transformRegistry = new Registry();
@@ -6983,6 +6984,7 @@ var CheckPathPlugin = function() {
6983
6984
  ]));
6984
6985
  }
6985
6986
  });
6987
+ this.viewPlugins = this.createViewPlugins();
6986
6988
  }
6987
6989
  _create_class(ViewController, [
6988
6990
  {
@@ -7038,9 +7040,50 @@ var CheckPathPlugin = function() {
7038
7040
  }
7039
7041
  var view = new ViewInstance(source, this.viewOptions);
7040
7042
  this.currentView = view;
7043
+ this.applyViewPlugins(view);
7041
7044
  this.hooks.view.call(view);
7042
7045
  view.update();
7043
7046
  }
7047
+ },
7048
+ {
7049
+ key: "applyViewPlugins",
7050
+ value: function applyViewPlugins(view) {
7051
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
7052
+ try {
7053
+ for(var _iterator = this.viewPlugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
7054
+ var plugin = _step.value;
7055
+ plugin.apply(view);
7056
+ }
7057
+ } catch (err) {
7058
+ _didIteratorError = true;
7059
+ _iteratorError = err;
7060
+ } finally{
7061
+ try {
7062
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
7063
+ _iterator.return();
7064
+ }
7065
+ } finally{
7066
+ if (_didIteratorError) {
7067
+ throw _iteratorError;
7068
+ }
7069
+ }
7070
+ }
7071
+ }
7072
+ },
7073
+ {
7074
+ key: "createViewPlugins",
7075
+ value: function createViewPlugins() {
7076
+ var pluginOptions = toNodeResolveOptions(this.viewOptions);
7077
+ return [
7078
+ new AssetPlugin(),
7079
+ new SwitchPlugin(pluginOptions),
7080
+ new ApplicabilityPlugin(),
7081
+ new AssetTransformCorePlugin(this.transformRegistry),
7082
+ new StringResolverPlugin(),
7083
+ new TemplatePlugin(pluginOptions),
7084
+ new MultiNodePlugin()
7085
+ ];
7086
+ }
7044
7087
  }
7045
7088
  ]);
7046
7089
  return ViewController;
@@ -7413,35 +7456,6 @@ var CheckPathPlugin = function() {
7413
7456
  ref: Symbol("not-started"),
7414
7457
  status: "not-started"
7415
7458
  };
7416
- var DefaultViewPlugin = /*#__PURE__*/ function() {
7417
- function DefaultViewPlugin() {
7418
- _class_call_check(this, DefaultViewPlugin);
7419
- this.name = "default-view-plugin";
7420
- }
7421
- _create_class(DefaultViewPlugin, [
7422
- {
7423
- key: "apply",
7424
- value: function apply(player) {
7425
- var _this = this;
7426
- player.hooks.viewController.tap(this.name, function(viewController) {
7427
- viewController.hooks.view.tap(_this.name, function(view) {
7428
- var pluginOptions = toNodeResolveOptions(view.resolverOptions);
7429
- new AssetPlugin().apply(view);
7430
- new SwitchPlugin(pluginOptions).apply(view);
7431
- new ApplicabilityPlugin().apply(view);
7432
- new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
7433
- new StringResolverPlugin().apply(view);
7434
- var templatePlugin = new TemplatePlugin(pluginOptions);
7435
- templatePlugin.apply(view);
7436
- view.hooks.onTemplatePluginCreated.call(templatePlugin);
7437
- new MultiNodePlugin().apply(view);
7438
- });
7439
- });
7440
- }
7441
- }
7442
- ]);
7443
- return DefaultViewPlugin;
7444
- }();
7445
7459
  var PLAYER_VERSION = "__VERSION__";
7446
7460
  var COMMIT = "__GIT_COMMIT__";
7447
7461
  var _Player = /*#__PURE__*/ function() {
@@ -7471,8 +7485,7 @@ var CheckPathPlugin = function() {
7471
7485
  }
7472
7486
  this.config = config || {};
7473
7487
  this.config.plugins = [
7474
- new DefaultExpPlugin(),
7475
- new DefaultViewPlugin()
7488
+ new DefaultExpPlugin()
7476
7489
  ].concat(_to_consumable_array(this.config.plugins || []), [
7477
7490
  new FlowExpPlugin()
7478
7491
  ]);
@@ -7659,95 +7672,41 @@ var CheckPathPlugin = function() {
7659
7672
  validationController.reset();
7660
7673
  }
7661
7674
  });
7662
- flow.hooks.afterTransition.tap("player", function(flowInstance) {
7675
+ flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
7663
7676
  var _flowInstance_currentState;
7664
7677
  var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7665
- if (value && value.state_type === "ACTION") {
7678
+ if (value && value.state_type === "ASYNC_ACTION") {
7666
7679
  var exp = value.exp;
7667
- var result = expressionEvaluator.evaluate(exp);
7668
- if (isPromiseLike(result)) {
7680
+ try {
7681
+ var result = expressionEvaluator.evaluateAsync(exp);
7682
+ if (isPromiseLike(result)) {
7683
+ if (value.await) {
7684
+ queueMicrotask(function() {
7685
+ result.then(function(r) {
7686
+ return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
7687
+ }).catch(flowResultDeferred.reject);
7688
+ });
7689
+ } else {
7690
+ _this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
7691
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7692
+ }
7693
+ } else {
7694
+ _this.logger.warn("Non async expression used in async action node");
7695
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7696
+ }
7697
+ } catch (e) {
7698
+ flowResultDeferred.reject(e);
7699
+ }
7700
+ } else if (value && value.state_type === "ACTION") {
7701
+ var exp1 = value.exp;
7702
+ var result1 = expressionEvaluator.evaluate(exp1);
7703
+ if (isPromiseLike(result1)) {
7669
7704
  _this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
7670
7705
  }
7671
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7706
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
7672
7707
  }
7673
7708
  expressionEvaluator.reset();
7674
7709
  });
7675
- var _this1 = _this;
7676
- flow.hooks.afterTransition.tap("player", function() {
7677
- var _ref = _async_to_generator(function(flowInstance) {
7678
- var _flowInstance_currentState, value, exp, result, e;
7679
- return _ts_generator(this, function(_state) {
7680
- switch(_state.label){
7681
- case 0:
7682
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7683
- if (!(value && value.state_type === "ASYNC_ACTION")) return [
7684
- 3,
7685
- 8
7686
- ];
7687
- exp = value.exp;
7688
- _state.label = 1;
7689
- case 1:
7690
- _state.trys.push([
7691
- 1,
7692
- 7,
7693
- ,
7694
- 8
7695
- ]);
7696
- result = expressionEvaluator.evaluateAsync(exp);
7697
- if (!isPromiseLike(result)) return [
7698
- 3,
7699
- 5
7700
- ];
7701
- if (!value.await) return [
7702
- 3,
7703
- 3
7704
- ];
7705
- return [
7706
- 4,
7707
- result
7708
- ];
7709
- case 2:
7710
- result = _state.sent();
7711
- return [
7712
- 3,
7713
- 4
7714
- ];
7715
- case 3:
7716
- _this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
7717
- _state.label = 4;
7718
- case 4:
7719
- return [
7720
- 3,
7721
- 6
7722
- ];
7723
- case 5:
7724
- _this1.logger.warn("Non async expression used in async action node");
7725
- _state.label = 6;
7726
- case 6:
7727
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7728
- return [
7729
- 3,
7730
- 8
7731
- ];
7732
- case 7:
7733
- e = _state.sent();
7734
- flowResultDeferred.reject(e);
7735
- return [
7736
- 3,
7737
- 8
7738
- ];
7739
- case 8:
7740
- expressionEvaluator.reset();
7741
- return [
7742
- 2
7743
- ];
7744
- }
7745
- });
7746
- });
7747
- return function(flowInstance) {
7748
- return _ref.apply(this, arguments);
7749
- };
7750
- }());
7751
7710
  });
7752
7711
  this.hooks.dataController.call(dataController);
7753
7712
  validationController.setOptions({
@@ -7785,11 +7744,9 @@ var CheckPathPlugin = function() {
7785
7744
  }),
7786
7745
  constants: this.constantsController
7787
7746
  });
7788
- this.hooks.viewController.tap("player", function(vc) {
7789
- vc.hooks.view.tap("player", function(view) {
7790
- validationController.onView(view);
7791
- _this.hooks.view.call(view);
7792
- });
7747
+ viewController.hooks.view.tap("player", function(view) {
7748
+ validationController.onView(view);
7749
+ _this.hooks.view.call(view);
7793
7750
  });
7794
7751
  this.hooks.viewController.call(viewController);
7795
7752
  return {