@player-ui/async-node-plugin 0.13.0-next.1 → 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.
@@ -6079,13 +6079,13 @@ var AsyncNodePlugin = function() {
6079
6079
  this.isTransitioning = false;
6080
6080
  this.hooks = {
6081
6081
  beforeStart: new SyncBailHook(),
6082
- /** A callback when the onStart node was present */ onStart: new SyncHook(),
6083
- /** A callback when the onEnd node was present */ onEnd: new SyncHook(),
6084
- /** A hook to intercept and block a transition */ skipTransition: new SyncBailHook(),
6085
- /** A chance to manipulate the flow-node used to calculate the given transition used */ beforeTransition: new SyncWaterfallHook(),
6086
- /** A chance to manipulate the flow-node calculated after a transition */ resolveTransitionNode: new SyncWaterfallHook(),
6087
- /** A callback when a transition from 1 state to another was made */ transition: new SyncHook(),
6088
- /** A callback to run actions after a transition occurs */ afterTransition: new SyncHook()
6082
+ onStart: new SyncHook(),
6083
+ onEnd: new SyncHook(),
6084
+ skipTransition: new SyncBailHook(),
6085
+ beforeTransition: new SyncWaterfallHook(),
6086
+ resolveTransitionNode: new SyncWaterfallHook(),
6087
+ transition: new SyncHook(),
6088
+ afterTransition: new SyncHook()
6089
6089
  };
6090
6090
  this.id = id;
6091
6091
  this.flow = flow;
@@ -7844,95 +7844,41 @@ var AsyncNodePlugin = function() {
7844
7844
  validationController.reset();
7845
7845
  }
7846
7846
  });
7847
- flow.hooks.afterTransition.tap("player", function(flowInstance) {
7847
+ flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
7848
7848
  var _flowInstance_currentState;
7849
7849
  var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7850
- if (value && value.state_type === "ACTION") {
7850
+ if (value && value.state_type === "ASYNC_ACTION") {
7851
7851
  var exp = value.exp;
7852
- var result = expressionEvaluator.evaluate(exp);
7853
- if (isPromiseLike(result)) {
7852
+ try {
7853
+ var result = expressionEvaluator.evaluateAsync(exp);
7854
+ if (isPromiseLike(result)) {
7855
+ if (value.await) {
7856
+ queueMicrotask(function() {
7857
+ result.then(function(r) {
7858
+ return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
7859
+ }).catch(flowResultDeferred.reject);
7860
+ });
7861
+ } else {
7862
+ _this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
7863
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7864
+ }
7865
+ } else {
7866
+ _this.logger.warn("Non async expression used in async action node");
7867
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7868
+ }
7869
+ } catch (e) {
7870
+ flowResultDeferred.reject(e);
7871
+ }
7872
+ } else if (value && value.state_type === "ACTION") {
7873
+ var exp1 = value.exp;
7874
+ var result1 = expressionEvaluator.evaluate(exp1);
7875
+ if (isPromiseLike(result1)) {
7854
7876
  _this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
7855
7877
  }
7856
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7878
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
7857
7879
  }
7858
7880
  expressionEvaluator.reset();
7859
7881
  });
7860
- var _this1 = _this;
7861
- flow.hooks.afterTransition.tap("player", function() {
7862
- var _ref = _async_to_generator(function(flowInstance) {
7863
- var _flowInstance_currentState, value, exp, result, e;
7864
- return _ts_generator(this, function(_state) {
7865
- switch(_state.label){
7866
- case 0:
7867
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7868
- if (!(value && value.state_type === "ASYNC_ACTION")) return [
7869
- 3,
7870
- 8
7871
- ];
7872
- exp = value.exp;
7873
- _state.label = 1;
7874
- case 1:
7875
- _state.trys.push([
7876
- 1,
7877
- 7,
7878
- ,
7879
- 8
7880
- ]);
7881
- result = expressionEvaluator.evaluateAsync(exp);
7882
- if (!isPromiseLike(result)) return [
7883
- 3,
7884
- 5
7885
- ];
7886
- if (!value.await) return [
7887
- 3,
7888
- 3
7889
- ];
7890
- return [
7891
- 4,
7892
- result
7893
- ];
7894
- case 2:
7895
- result = _state.sent();
7896
- return [
7897
- 3,
7898
- 4
7899
- ];
7900
- case 3:
7901
- _this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
7902
- _state.label = 4;
7903
- case 4:
7904
- return [
7905
- 3,
7906
- 6
7907
- ];
7908
- case 5:
7909
- _this1.logger.warn("Non async expression used in async action node");
7910
- _state.label = 6;
7911
- case 6:
7912
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7913
- return [
7914
- 3,
7915
- 8
7916
- ];
7917
- case 7:
7918
- e = _state.sent();
7919
- flowResultDeferred.reject(e);
7920
- return [
7921
- 3,
7922
- 8
7923
- ];
7924
- case 8:
7925
- expressionEvaluator.reset();
7926
- return [
7927
- 2
7928
- ];
7929
- }
7930
- });
7931
- });
7932
- return function(flowInstance) {
7933
- return _ref.apply(this, arguments);
7934
- };
7935
- }());
7936
7882
  });
7937
7883
  this.hooks.dataController.call(dataController);
7938
7884
  validationController.setOptions({