@player-ui/player 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.
@@ -6351,13 +6351,13 @@ var Player = function() {
6351
6351
  this.isTransitioning = false;
6352
6352
  this.hooks = {
6353
6353
  beforeStart: new SyncBailHook(),
6354
- /** A callback when the onStart node was present */ onStart: new SyncHook(),
6355
- /** A callback when the onEnd node was present */ onEnd: new SyncHook(),
6356
- /** A hook to intercept and block a transition */ skipTransition: new SyncBailHook(),
6357
- /** A chance to manipulate the flow-node used to calculate the given transition used */ beforeTransition: new SyncWaterfallHook(),
6358
- /** A chance to manipulate the flow-node calculated after a transition */ resolveTransitionNode: new SyncWaterfallHook(),
6359
- /** A callback when a transition from 1 state to another was made */ transition: new SyncHook(),
6360
- /** A callback to run actions after a transition occurs */ afterTransition: new SyncHook()
6354
+ onStart: new SyncHook(),
6355
+ onEnd: new SyncHook(),
6356
+ skipTransition: new SyncBailHook(),
6357
+ beforeTransition: new SyncWaterfallHook(),
6358
+ resolveTransitionNode: new SyncWaterfallHook(),
6359
+ transition: new SyncHook(),
6360
+ afterTransition: new SyncHook()
6361
6361
  };
6362
6362
  this.id = id;
6363
6363
  this.flow = flow;
@@ -8261,95 +8261,41 @@ var Player = function() {
8261
8261
  validationController.reset();
8262
8262
  }
8263
8263
  });
8264
- flow.hooks.afterTransition.tap("player", function(flowInstance) {
8264
+ flow.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
8265
8265
  var _flowInstance_currentState;
8266
8266
  var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
8267
- if (value && value.state_type === "ACTION") {
8267
+ if (value && value.state_type === "ASYNC_ACTION") {
8268
8268
  var exp = value.exp;
8269
- var result = expressionEvaluator.evaluate(exp);
8270
- if (isPromiseLike(result)) {
8269
+ try {
8270
+ var result = expressionEvaluator.evaluateAsync(exp);
8271
+ if (isPromiseLike(result)) {
8272
+ if (value.await) {
8273
+ queueMicrotask(function() {
8274
+ result.then(function(r) {
8275
+ return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
8276
+ }).catch(flowResultDeferred.reject);
8277
+ });
8278
+ } else {
8279
+ _this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
8280
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8281
+ }
8282
+ } else {
8283
+ _this.logger.warn("Non async expression used in async action node");
8284
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8285
+ }
8286
+ } catch (e) {
8287
+ flowResultDeferred.reject(e);
8288
+ }
8289
+ } else if (value && value.state_type === "ACTION") {
8290
+ var exp1 = value.exp;
8291
+ var result1 = expressionEvaluator.evaluate(exp1);
8292
+ if (isPromiseLike(result1)) {
8271
8293
  _this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
8272
8294
  }
8273
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8295
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
8274
8296
  }
8275
8297
  expressionEvaluator.reset();
8276
8298
  });
8277
- var _this1 = _this;
8278
- flow.hooks.afterTransition.tap("player", function() {
8279
- var _ref = _async_to_generator(function(flowInstance) {
8280
- var _flowInstance_currentState, value, exp, result, e;
8281
- return _ts_generator(this, function(_state) {
8282
- switch(_state.label){
8283
- case 0:
8284
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
8285
- if (!(value && value.state_type === "ASYNC_ACTION")) return [
8286
- 3,
8287
- 8
8288
- ];
8289
- exp = value.exp;
8290
- _state.label = 1;
8291
- case 1:
8292
- _state.trys.push([
8293
- 1,
8294
- 7,
8295
- ,
8296
- 8
8297
- ]);
8298
- result = expressionEvaluator.evaluateAsync(exp);
8299
- if (!isPromiseLike(result)) return [
8300
- 3,
8301
- 5
8302
- ];
8303
- if (!value.await) return [
8304
- 3,
8305
- 3
8306
- ];
8307
- return [
8308
- 4,
8309
- result
8310
- ];
8311
- case 2:
8312
- result = _state.sent();
8313
- return [
8314
- 3,
8315
- 4
8316
- ];
8317
- case 3:
8318
- _this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
8319
- _state.label = 4;
8320
- case 4:
8321
- return [
8322
- 3,
8323
- 6
8324
- ];
8325
- case 5:
8326
- _this1.logger.warn("Non async expression used in async action node");
8327
- _state.label = 6;
8328
- case 6:
8329
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8330
- return [
8331
- 3,
8332
- 8
8333
- ];
8334
- case 7:
8335
- e = _state.sent();
8336
- flowResultDeferred.reject(e);
8337
- return [
8338
- 3,
8339
- 8
8340
- ];
8341
- case 8:
8342
- expressionEvaluator.reset();
8343
- return [
8344
- 2
8345
- ];
8346
- }
8347
- });
8348
- });
8349
- return function(flowInstance) {
8350
- return _ref.apply(this, arguments);
8351
- };
8352
- }());
8353
8299
  });
8354
8300
  this.hooks.dataController.call(dataController);
8355
8301
  validationController.setOptions({