@player-ui/beacon-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.
@@ -2593,9 +2593,10 @@ var BeaconPlugin = function() {
2593
2593
  var import_timm7 = __toESM(require_timm(), 1);
2594
2594
  var import_timm8 = __toESM(require_timm(), 1);
2595
2595
  var import_p_defer = __toESM(require_p_defer(), 1);
2596
+ var import_queue_microtask = __toESM(require_queue_microtask(), 1);
2596
2597
  var import_p_defer2 = __toESM(require_p_defer(), 1);
2597
2598
  var import_timm9 = __toESM(require_timm(), 1);
2598
- var import_queue_microtask = __toESM(require_queue_microtask(), 1);
2599
+ var import_queue_microtask2 = __toESM(require_queue_microtask(), 1);
2599
2600
  // ../../../../../../../../../../../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
2600
2601
  var import_sorted_array = __toESM(require_sorted_array(), 1);
2601
2602
  function traverseObj(object) {
@@ -5956,13 +5957,13 @@ var BeaconPlugin = function() {
5956
5957
  this.isTransitioning = false;
5957
5958
  this.hooks = {
5958
5959
  beforeStart: new SyncBailHook(),
5959
- /** A callback when the onStart node was present */ onStart: new SyncHook(),
5960
- /** A callback when the onEnd node was present */ onEnd: new SyncHook(),
5961
- /** A hook to intercept and block a transition */ skipTransition: new SyncBailHook(),
5962
- /** A chance to manipulate the flow-node used to calculate the given transition used */ beforeTransition: new SyncWaterfallHook(),
5963
- /** A chance to manipulate the flow-node calculated after a transition */ resolveTransitionNode: new SyncWaterfallHook(),
5964
- /** A callback when a transition from 1 state to another was made */ transition: new SyncHook(),
5965
- /** A callback to run actions after a transition occurs */ afterTransition: new SyncHook()
5960
+ onStart: new SyncHook(),
5961
+ onEnd: new SyncHook(),
5962
+ skipTransition: new SyncBailHook(),
5963
+ beforeTransition: new SyncWaterfallHook(),
5964
+ resolveTransitionNode: new SyncWaterfallHook(),
5965
+ transition: new SyncHook(),
5966
+ afterTransition: new SyncHook()
5966
5967
  };
5967
5968
  this.id = id;
5968
5969
  this.flow = flow;
@@ -7052,7 +7053,7 @@ var BeaconPlugin = function() {
7052
7053
  }
7053
7054
  if (!this.pendingUpdate.scheduled && !silent) {
7054
7055
  this.pendingUpdate.scheduled = true;
7055
- (0, import_queue_microtask.default)(function() {
7056
+ (0, import_queue_microtask2.default)(function() {
7056
7057
  var _this_pendingUpdate, _this_currentView;
7057
7058
  var updates = (_this_pendingUpdate = _this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings;
7058
7059
  _this.pendingUpdate = void 0;
@@ -7721,95 +7722,41 @@ var BeaconPlugin = function() {
7721
7722
  validationController.reset();
7722
7723
  }
7723
7724
  });
7724
- flow.hooks.afterTransition.tap("player", function(flowInstance) {
7725
+ flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
7725
7726
  var _flowInstance_currentState;
7726
7727
  var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7727
- if (value && value.state_type === "ACTION") {
7728
+ if (value && value.state_type === "ASYNC_ACTION") {
7728
7729
  var exp = value.exp;
7729
- var result = expressionEvaluator.evaluate(exp);
7730
- if (isPromiseLike(result)) {
7730
+ try {
7731
+ var result = expressionEvaluator.evaluateAsync(exp);
7732
+ if (isPromiseLike(result)) {
7733
+ if (value.await) {
7734
+ (0, import_queue_microtask.default)(function() {
7735
+ result.then(function(r) {
7736
+ return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
7737
+ }).catch(flowResultDeferred.reject);
7738
+ });
7739
+ } else {
7740
+ _this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
7741
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7742
+ }
7743
+ } else {
7744
+ _this.logger.warn("Non async expression used in async action node");
7745
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7746
+ }
7747
+ } catch (e) {
7748
+ flowResultDeferred.reject(e);
7749
+ }
7750
+ } else if (value && value.state_type === "ACTION") {
7751
+ var exp1 = value.exp;
7752
+ var result1 = expressionEvaluator.evaluate(exp1);
7753
+ if (isPromiseLike(result1)) {
7731
7754
  _this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
7732
7755
  }
7733
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7756
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
7734
7757
  }
7735
7758
  expressionEvaluator.reset();
7736
7759
  });
7737
- var _this1 = _this;
7738
- flow.hooks.afterTransition.tap("player", function() {
7739
- var _ref = _async_to_generator(function(flowInstance) {
7740
- var _flowInstance_currentState, value, exp, result, e;
7741
- return _ts_generator(this, function(_state) {
7742
- switch(_state.label){
7743
- case 0:
7744
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7745
- if (!(value && value.state_type === "ASYNC_ACTION")) return [
7746
- 3,
7747
- 8
7748
- ];
7749
- exp = value.exp;
7750
- _state.label = 1;
7751
- case 1:
7752
- _state.trys.push([
7753
- 1,
7754
- 7,
7755
- ,
7756
- 8
7757
- ]);
7758
- result = expressionEvaluator.evaluateAsync(exp);
7759
- if (!isPromiseLike(result)) return [
7760
- 3,
7761
- 5
7762
- ];
7763
- if (!value.await) return [
7764
- 3,
7765
- 3
7766
- ];
7767
- return [
7768
- 4,
7769
- result
7770
- ];
7771
- case 2:
7772
- result = _state.sent();
7773
- return [
7774
- 3,
7775
- 4
7776
- ];
7777
- case 3:
7778
- _this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
7779
- _state.label = 4;
7780
- case 4:
7781
- return [
7782
- 3,
7783
- 6
7784
- ];
7785
- case 5:
7786
- _this1.logger.warn("Non async expression used in async action node");
7787
- _state.label = 6;
7788
- case 6:
7789
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7790
- return [
7791
- 3,
7792
- 8
7793
- ];
7794
- case 7:
7795
- e = _state.sent();
7796
- flowResultDeferred.reject(e);
7797
- return [
7798
- 3,
7799
- 8
7800
- ];
7801
- case 8:
7802
- expressionEvaluator.reset();
7803
- return [
7804
- 2
7805
- ];
7806
- }
7807
- });
7808
- });
7809
- return function(flowInstance) {
7810
- return _ref.apply(this, arguments);
7811
- };
7812
- }());
7813
7760
  });
7814
7761
  this.hooks.dataController.call(dataController);
7815
7762
  validationController.setOptions({