@player-ui/reference-assets-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.
@@ -6294,13 +6294,13 @@ var ReferenceAssetsPlugin = function() {
6294
6294
  this.isTransitioning = false;
6295
6295
  this.hooks = {
6296
6296
  beforeStart: new SyncBailHook(),
6297
- /** A callback when the onStart node was present */ onStart: new SyncHook(),
6298
- /** A callback when the onEnd node was present */ onEnd: new SyncHook(),
6299
- /** A hook to intercept and block a transition */ skipTransition: new SyncBailHook(),
6300
- /** A chance to manipulate the flow-node used to calculate the given transition used */ beforeTransition: new SyncWaterfallHook(),
6301
- /** A chance to manipulate the flow-node calculated after a transition */ resolveTransitionNode: new SyncWaterfallHook(),
6302
- /** A callback when a transition from 1 state to another was made */ transition: new SyncHook(),
6303
- /** 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()
6304
6304
  };
6305
6305
  this.id = id;
6306
6306
  this.flow = flow;
@@ -8059,95 +8059,41 @@ var ReferenceAssetsPlugin = function() {
8059
8059
  validationController.reset();
8060
8060
  }
8061
8061
  });
8062
- flow.hooks.afterTransition.tap("player", function(flowInstance) {
8062
+ flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
8063
8063
  var _flowInstance_currentState;
8064
8064
  var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
8065
- if (value && value.state_type === "ACTION") {
8065
+ if (value && value.state_type === "ASYNC_ACTION") {
8066
8066
  var exp = value.exp;
8067
- var result = expressionEvaluator.evaluate(exp);
8068
- 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)) {
8069
8091
  _this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
8070
8092
  }
8071
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8093
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
8072
8094
  }
8073
8095
  expressionEvaluator.reset();
8074
8096
  });
8075
- var _this1 = _this;
8076
- flow.hooks.afterTransition.tap("player", function() {
8077
- var _ref = _async_to_generator(function(flowInstance) {
8078
- var _flowInstance_currentState, value, exp, result, e;
8079
- return _ts_generator(this, function(_state) {
8080
- switch(_state.label){
8081
- case 0:
8082
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
8083
- if (!(value && value.state_type === "ASYNC_ACTION")) return [
8084
- 3,
8085
- 8
8086
- ];
8087
- exp = value.exp;
8088
- _state.label = 1;
8089
- case 1:
8090
- _state.trys.push([
8091
- 1,
8092
- 7,
8093
- ,
8094
- 8
8095
- ]);
8096
- result = expressionEvaluator.evaluateAsync(exp);
8097
- if (!isPromiseLike(result)) return [
8098
- 3,
8099
- 5
8100
- ];
8101
- if (!value.await) return [
8102
- 3,
8103
- 3
8104
- ];
8105
- return [
8106
- 4,
8107
- result
8108
- ];
8109
- case 2:
8110
- result = _state.sent();
8111
- return [
8112
- 3,
8113
- 4
8114
- ];
8115
- case 3:
8116
- _this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
8117
- _state.label = 4;
8118
- case 4:
8119
- return [
8120
- 3,
8121
- 6
8122
- ];
8123
- case 5:
8124
- _this1.logger.warn("Non async expression used in async action node");
8125
- _state.label = 6;
8126
- case 6:
8127
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8128
- return [
8129
- 3,
8130
- 8
8131
- ];
8132
- case 7:
8133
- e = _state.sent();
8134
- flowResultDeferred.reject(e);
8135
- return [
8136
- 3,
8137
- 8
8138
- ];
8139
- case 8:
8140
- expressionEvaluator.reset();
8141
- return [
8142
- 2
8143
- ];
8144
- }
8145
- });
8146
- });
8147
- return function(flowInstance) {
8148
- return _ref.apply(this, arguments);
8149
- };
8150
- }());
8151
8097
  });
8152
8098
  this.hooks.dataController.call(dataController);
8153
8099
  validationController.setOptions({