@player-ui/common-types-plugin 0.13.0-next.1 → 0.13.0-next.3

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.
@@ -2623,9 +2623,10 @@ var CommonTypesPlugin = function() {
2623
2623
  var import_timm7 = __toESM(require_timm(), 1);
2624
2624
  var import_timm8 = __toESM(require_timm(), 1);
2625
2625
  var import_p_defer = __toESM(require_p_defer(), 1);
2626
+ var import_queue_microtask = __toESM(require_queue_microtask(), 1);
2626
2627
  var import_p_defer2 = __toESM(require_p_defer(), 1);
2627
2628
  var import_timm9 = __toESM(require_timm(), 1);
2628
- var import_queue_microtask = __toESM(require_queue_microtask(), 1);
2629
+ var import_queue_microtask2 = __toESM(require_queue_microtask(), 1);
2629
2630
  // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+partial-match-registry@0.0.0/node_modules/@player-ui/partial-match-registry/dist/index.mjs
2630
2631
  var import_sorted_array = __toESM(require_sorted_array(), 1);
2631
2632
  function traverseObj(object) {
@@ -5986,13 +5987,13 @@ var CommonTypesPlugin = function() {
5986
5987
  this.isTransitioning = false;
5987
5988
  this.hooks = {
5988
5989
  beforeStart: new SyncBailHook(),
5989
- /** A callback when the onStart node was present */ onStart: new SyncHook(),
5990
- /** A callback when the onEnd node was present */ onEnd: new SyncHook(),
5991
- /** A hook to intercept and block a transition */ skipTransition: new SyncBailHook(),
5992
- /** A chance to manipulate the flow-node used to calculate the given transition used */ beforeTransition: new SyncWaterfallHook(),
5993
- /** A chance to manipulate the flow-node calculated after a transition */ resolveTransitionNode: new SyncWaterfallHook(),
5994
- /** A callback when a transition from 1 state to another was made */ transition: new SyncHook(),
5995
- /** A callback to run actions after a transition occurs */ afterTransition: new SyncHook()
5990
+ onStart: new SyncHook(),
5991
+ onEnd: new SyncHook(),
5992
+ skipTransition: new SyncBailHook(),
5993
+ beforeTransition: new SyncWaterfallHook(),
5994
+ resolveTransitionNode: new SyncWaterfallHook(),
5995
+ transition: new SyncHook(),
5996
+ afterTransition: new SyncHook()
5996
5997
  };
5997
5998
  this.id = id;
5998
5999
  this.flow = flow;
@@ -7082,7 +7083,7 @@ var CommonTypesPlugin = function() {
7082
7083
  }
7083
7084
  if (!this.pendingUpdate.scheduled && !silent) {
7084
7085
  this.pendingUpdate.scheduled = true;
7085
- (0, import_queue_microtask.default)(function() {
7086
+ (0, import_queue_microtask2.default)(function() {
7086
7087
  var _this_pendingUpdate, _this_currentView;
7087
7088
  var updates = (_this_pendingUpdate = _this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings;
7088
7089
  _this.pendingUpdate = void 0;
@@ -7751,95 +7752,41 @@ var CommonTypesPlugin = function() {
7751
7752
  validationController.reset();
7752
7753
  }
7753
7754
  });
7754
- flow.hooks.afterTransition.tap("player", function(flowInstance) {
7755
+ flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
7755
7756
  var _flowInstance_currentState;
7756
7757
  var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7757
- if (value && value.state_type === "ACTION") {
7758
+ if (value && value.state_type === "ASYNC_ACTION") {
7758
7759
  var exp = value.exp;
7759
- var result = expressionEvaluator.evaluate(exp);
7760
- if (isPromiseLike(result)) {
7760
+ try {
7761
+ var result = expressionEvaluator.evaluateAsync(exp);
7762
+ if (isPromiseLike(result)) {
7763
+ if (value.await) {
7764
+ (0, import_queue_microtask.default)(function() {
7765
+ result.then(function(r) {
7766
+ return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
7767
+ }).catch(flowResultDeferred.reject);
7768
+ });
7769
+ } else {
7770
+ _this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
7771
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7772
+ }
7773
+ } else {
7774
+ _this.logger.warn("Non async expression used in async action node");
7775
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7776
+ }
7777
+ } catch (e) {
7778
+ flowResultDeferred.reject(e);
7779
+ }
7780
+ } else if (value && value.state_type === "ACTION") {
7781
+ var exp1 = value.exp;
7782
+ var result1 = expressionEvaluator.evaluate(exp1);
7783
+ if (isPromiseLike(result1)) {
7761
7784
  _this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
7762
7785
  }
7763
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7786
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
7764
7787
  }
7765
7788
  expressionEvaluator.reset();
7766
7789
  });
7767
- var _this1 = _this;
7768
- flow.hooks.afterTransition.tap("player", function() {
7769
- var _ref = _async_to_generator(function(flowInstance) {
7770
- var _flowInstance_currentState, value, exp, result, e;
7771
- return _ts_generator(this, function(_state) {
7772
- switch(_state.label){
7773
- case 0:
7774
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7775
- if (!(value && value.state_type === "ASYNC_ACTION")) return [
7776
- 3,
7777
- 8
7778
- ];
7779
- exp = value.exp;
7780
- _state.label = 1;
7781
- case 1:
7782
- _state.trys.push([
7783
- 1,
7784
- 7,
7785
- ,
7786
- 8
7787
- ]);
7788
- result = expressionEvaluator.evaluateAsync(exp);
7789
- if (!isPromiseLike(result)) return [
7790
- 3,
7791
- 5
7792
- ];
7793
- if (!value.await) return [
7794
- 3,
7795
- 3
7796
- ];
7797
- return [
7798
- 4,
7799
- result
7800
- ];
7801
- case 2:
7802
- result = _state.sent();
7803
- return [
7804
- 3,
7805
- 4
7806
- ];
7807
- case 3:
7808
- _this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
7809
- _state.label = 4;
7810
- case 4:
7811
- return [
7812
- 3,
7813
- 6
7814
- ];
7815
- case 5:
7816
- _this1.logger.warn("Non async expression used in async action node");
7817
- _state.label = 6;
7818
- case 6:
7819
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7820
- return [
7821
- 3,
7822
- 8
7823
- ];
7824
- case 7:
7825
- e = _state.sent();
7826
- flowResultDeferred.reject(e);
7827
- return [
7828
- 3,
7829
- 8
7830
- ];
7831
- case 8:
7832
- expressionEvaluator.reset();
7833
- return [
7834
- 2
7835
- ];
7836
- }
7837
- });
7838
- });
7839
- return function(flowInstance) {
7840
- return _ref.apply(this, arguments);
7841
- };
7842
- }());
7843
7790
  });
7844
7791
  this.hooks.dataController.call(dataController);
7845
7792
  validationController.setOptions({