@player-ui/stage-revert-data-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.
@@ -5060,20 +5060,15 @@ var StageRevertDataPlugin = function() {
5060
5060
  }();
5061
5061
  var ViewInstance = /*#__PURE__*/ function() {
5062
5062
  function ViewInstance(initialView, resolverOptions) {
5063
- var _this = this;
5064
5063
  _class_call_check(this, ViewInstance);
5065
5064
  this.hooks = {
5066
5065
  onUpdate: new SyncHook(),
5067
5066
  parser: new SyncHook(),
5068
5067
  resolver: new SyncHook(),
5069
- onTemplatePluginCreated: new SyncHook(),
5070
5068
  templatePlugin: new SyncHook()
5071
5069
  };
5072
5070
  this.initialView = initialView;
5073
5071
  this.resolverOptions = resolverOptions;
5074
- this.hooks.onTemplatePluginCreated.tap("view", function(templatePlugin) {
5075
- _this.templatePlugin = templatePlugin;
5076
- });
5077
5072
  }
5078
5073
  _create_class(ViewInstance, [
5079
5074
  {
@@ -5120,6 +5115,12 @@ var StageRevertDataPlugin = function() {
5120
5115
  var _this_validationProvider;
5121
5116
  return (_this_validationProvider = this.validationProvider) === null || _this_validationProvider === void 0 ? void 0 : _this_validationProvider.getValidationsForBinding(binding);
5122
5117
  }
5118
+ },
5119
+ {
5120
+ key: "setTemplatePlugin",
5121
+ value: function setTemplatePlugin(plugin) {
5122
+ this.templatePlugin = plugin;
5123
+ }
5123
5124
  }
5124
5125
  ]);
5125
5126
  return ViewInstance;
@@ -5291,6 +5292,7 @@ var StageRevertDataPlugin = function() {
5291
5292
  value: function apply(view) {
5292
5293
  view.hooks.parser.tap("template", this.applyParser.bind(this));
5293
5294
  view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
5295
+ view.setTemplatePlugin(this);
5294
5296
  }
5295
5297
  }
5296
5298
  ]);
@@ -5870,13 +5872,13 @@ var StageRevertDataPlugin = function() {
5870
5872
  this.isTransitioning = false;
5871
5873
  this.hooks = {
5872
5874
  beforeStart: new SyncBailHook(),
5873
- /** A callback when the onStart node was present */ onStart: new SyncHook(),
5874
- /** A callback when the onEnd node was present */ onEnd: new SyncHook(),
5875
- /** A hook to intercept and block a transition */ skipTransition: new SyncBailHook(),
5876
- /** A chance to manipulate the flow-node used to calculate the given transition used */ beforeTransition: new SyncWaterfallHook(),
5877
- /** A chance to manipulate the flow-node calculated after a transition */ resolveTransitionNode: new SyncWaterfallHook(),
5878
- /** A callback when a transition from 1 state to another was made */ transition: new SyncHook(),
5879
- /** A callback to run actions after a transition occurs */ afterTransition: new SyncHook()
5875
+ onStart: new SyncHook(),
5876
+ onEnd: new SyncHook(),
5877
+ skipTransition: new SyncBailHook(),
5878
+ beforeTransition: new SyncWaterfallHook(),
5879
+ resolveTransitionNode: new SyncWaterfallHook(),
5880
+ transition: new SyncHook(),
5881
+ afterTransition: new SyncHook()
5880
5882
  };
5881
5883
  this.id = id;
5882
5884
  this.flow = flow;
@@ -6899,8 +6901,7 @@ var StageRevertDataPlugin = function() {
6899
6901
  var _this1 = this;
6900
6902
  _class_call_check(this, ViewController);
6901
6903
  this.hooks = {
6902
- /** Do any processing before the `View` instance is created */ resolveView: new SyncWaterfallHook(),
6903
- // The hook right before the View starts resolving. Attach anything custom here
6904
+ resolveView: new SyncWaterfallHook(),
6904
6905
  view: new SyncHook()
6905
6906
  };
6906
6907
  this.transformRegistry = new Registry();
@@ -6948,6 +6949,7 @@ var StageRevertDataPlugin = function() {
6948
6949
  ]));
6949
6950
  }
6950
6951
  });
6952
+ this.viewPlugins = this.createViewPlugins();
6951
6953
  }
6952
6954
  _create_class(ViewController, [
6953
6955
  {
@@ -7003,9 +7005,50 @@ var StageRevertDataPlugin = function() {
7003
7005
  }
7004
7006
  var view = new ViewInstance(source, this.viewOptions);
7005
7007
  this.currentView = view;
7008
+ this.applyViewPlugins(view);
7006
7009
  this.hooks.view.call(view);
7007
7010
  view.update();
7008
7011
  }
7012
+ },
7013
+ {
7014
+ key: "applyViewPlugins",
7015
+ value: function applyViewPlugins(view) {
7016
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
7017
+ try {
7018
+ for(var _iterator = this.viewPlugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
7019
+ var plugin = _step.value;
7020
+ plugin.apply(view);
7021
+ }
7022
+ } catch (err) {
7023
+ _didIteratorError = true;
7024
+ _iteratorError = err;
7025
+ } finally{
7026
+ try {
7027
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
7028
+ _iterator.return();
7029
+ }
7030
+ } finally{
7031
+ if (_didIteratorError) {
7032
+ throw _iteratorError;
7033
+ }
7034
+ }
7035
+ }
7036
+ }
7037
+ },
7038
+ {
7039
+ key: "createViewPlugins",
7040
+ value: function createViewPlugins() {
7041
+ var pluginOptions = toNodeResolveOptions(this.viewOptions);
7042
+ return [
7043
+ new AssetPlugin(),
7044
+ new SwitchPlugin(pluginOptions),
7045
+ new ApplicabilityPlugin(),
7046
+ new AssetTransformCorePlugin(this.transformRegistry),
7047
+ new StringResolverPlugin(),
7048
+ new TemplatePlugin(pluginOptions),
7049
+ new MultiNodePlugin()
7050
+ ];
7051
+ }
7009
7052
  }
7010
7053
  ]);
7011
7054
  return ViewController;
@@ -7378,35 +7421,6 @@ var StageRevertDataPlugin = function() {
7378
7421
  ref: Symbol("not-started"),
7379
7422
  status: "not-started"
7380
7423
  };
7381
- var DefaultViewPlugin = /*#__PURE__*/ function() {
7382
- function DefaultViewPlugin() {
7383
- _class_call_check(this, DefaultViewPlugin);
7384
- this.name = "default-view-plugin";
7385
- }
7386
- _create_class(DefaultViewPlugin, [
7387
- {
7388
- key: "apply",
7389
- value: function apply(player) {
7390
- var _this = this;
7391
- player.hooks.viewController.tap(this.name, function(viewController) {
7392
- viewController.hooks.view.tap(_this.name, function(view) {
7393
- var pluginOptions = toNodeResolveOptions(view.resolverOptions);
7394
- new AssetPlugin().apply(view);
7395
- new SwitchPlugin(pluginOptions).apply(view);
7396
- new ApplicabilityPlugin().apply(view);
7397
- new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
7398
- new StringResolverPlugin().apply(view);
7399
- var templatePlugin = new TemplatePlugin(pluginOptions);
7400
- templatePlugin.apply(view);
7401
- view.hooks.onTemplatePluginCreated.call(templatePlugin);
7402
- new MultiNodePlugin().apply(view);
7403
- });
7404
- });
7405
- }
7406
- }
7407
- ]);
7408
- return DefaultViewPlugin;
7409
- }();
7410
7424
  var PLAYER_VERSION = "__VERSION__";
7411
7425
  var COMMIT = "__GIT_COMMIT__";
7412
7426
  var _Player = /*#__PURE__*/ function() {
@@ -7436,8 +7450,7 @@ var StageRevertDataPlugin = function() {
7436
7450
  }
7437
7451
  this.config = config || {};
7438
7452
  this.config.plugins = [
7439
- new DefaultExpPlugin(),
7440
- new DefaultViewPlugin()
7453
+ new DefaultExpPlugin()
7441
7454
  ].concat(_to_consumable_array(this.config.plugins || []), [
7442
7455
  new FlowExpPlugin()
7443
7456
  ]);
@@ -7624,95 +7637,41 @@ var StageRevertDataPlugin = function() {
7624
7637
  validationController.reset();
7625
7638
  }
7626
7639
  });
7627
- flow.hooks.afterTransition.tap("player", function(flowInstance) {
7640
+ flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
7628
7641
  var _flowInstance_currentState;
7629
7642
  var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7630
- if (value && value.state_type === "ACTION") {
7643
+ if (value && value.state_type === "ASYNC_ACTION") {
7631
7644
  var exp = value.exp;
7632
- var result = expressionEvaluator.evaluate(exp);
7633
- if (isPromiseLike(result)) {
7645
+ try {
7646
+ var result = expressionEvaluator.evaluateAsync(exp);
7647
+ if (isPromiseLike(result)) {
7648
+ if (value.await) {
7649
+ queueMicrotask(function() {
7650
+ result.then(function(r) {
7651
+ return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
7652
+ }).catch(flowResultDeferred.reject);
7653
+ });
7654
+ } else {
7655
+ _this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
7656
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7657
+ }
7658
+ } else {
7659
+ _this.logger.warn("Non async expression used in async action node");
7660
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7661
+ }
7662
+ } catch (e) {
7663
+ flowResultDeferred.reject(e);
7664
+ }
7665
+ } else if (value && value.state_type === "ACTION") {
7666
+ var exp1 = value.exp;
7667
+ var result1 = expressionEvaluator.evaluate(exp1);
7668
+ if (isPromiseLike(result1)) {
7634
7669
  _this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
7635
7670
  }
7636
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7671
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
7637
7672
  }
7638
7673
  expressionEvaluator.reset();
7639
7674
  });
7640
- var _this1 = _this;
7641
- flow.hooks.afterTransition.tap("player", function() {
7642
- var _ref = _async_to_generator(function(flowInstance) {
7643
- var _flowInstance_currentState, value, exp, result, e;
7644
- return _ts_generator(this, function(_state) {
7645
- switch(_state.label){
7646
- case 0:
7647
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7648
- if (!(value && value.state_type === "ASYNC_ACTION")) return [
7649
- 3,
7650
- 8
7651
- ];
7652
- exp = value.exp;
7653
- _state.label = 1;
7654
- case 1:
7655
- _state.trys.push([
7656
- 1,
7657
- 7,
7658
- ,
7659
- 8
7660
- ]);
7661
- result = expressionEvaluator.evaluateAsync(exp);
7662
- if (!isPromiseLike(result)) return [
7663
- 3,
7664
- 5
7665
- ];
7666
- if (!value.await) return [
7667
- 3,
7668
- 3
7669
- ];
7670
- return [
7671
- 4,
7672
- result
7673
- ];
7674
- case 2:
7675
- result = _state.sent();
7676
- return [
7677
- 3,
7678
- 4
7679
- ];
7680
- case 3:
7681
- _this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
7682
- _state.label = 4;
7683
- case 4:
7684
- return [
7685
- 3,
7686
- 6
7687
- ];
7688
- case 5:
7689
- _this1.logger.warn("Non async expression used in async action node");
7690
- _state.label = 6;
7691
- case 6:
7692
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7693
- return [
7694
- 3,
7695
- 8
7696
- ];
7697
- case 7:
7698
- e = _state.sent();
7699
- flowResultDeferred.reject(e);
7700
- return [
7701
- 3,
7702
- 8
7703
- ];
7704
- case 8:
7705
- expressionEvaluator.reset();
7706
- return [
7707
- 2
7708
- ];
7709
- }
7710
- });
7711
- });
7712
- return function(flowInstance) {
7713
- return _ref.apply(this, arguments);
7714
- };
7715
- }());
7716
7675
  });
7717
7676
  this.hooks.dataController.call(dataController);
7718
7677
  validationController.setOptions({
@@ -7750,11 +7709,9 @@ var StageRevertDataPlugin = function() {
7750
7709
  }),
7751
7710
  constants: this.constantsController
7752
7711
  });
7753
- this.hooks.viewController.tap("player", function(vc) {
7754
- vc.hooks.view.tap("player", function(view) {
7755
- validationController.onView(view);
7756
- _this.hooks.view.call(view);
7757
- });
7712
+ viewController.hooks.view.tap("player", function(view) {
7713
+ validationController.onView(view);
7714
+ _this.hooks.view.call(view);
7758
7715
  });
7759
7716
  this.hooks.viewController.call(viewController);
7760
7717
  return {