@player-ui/markdown-plugin 0.13.0-next.0 → 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.
@@ -9392,20 +9392,15 @@ var MarkdownPlugin = function() {
9392
9392
  }();
9393
9393
  var ViewInstance = /*#__PURE__*/ function() {
9394
9394
  function ViewInstance(initialView, resolverOptions) {
9395
- var _this = this;
9396
9395
  _class_call_check(this, ViewInstance);
9397
9396
  this.hooks = {
9398
9397
  onUpdate: new SyncHook(),
9399
9398
  parser: new SyncHook(),
9400
9399
  resolver: new SyncHook(),
9401
- onTemplatePluginCreated: new SyncHook(),
9402
9400
  templatePlugin: new SyncHook()
9403
9401
  };
9404
9402
  this.initialView = initialView;
9405
9403
  this.resolverOptions = resolverOptions;
9406
- this.hooks.onTemplatePluginCreated.tap("view", function(templatePlugin) {
9407
- _this.templatePlugin = templatePlugin;
9408
- });
9409
9404
  }
9410
9405
  _create_class(ViewInstance, [
9411
9406
  {
@@ -9452,6 +9447,12 @@ var MarkdownPlugin = function() {
9452
9447
  var _this_validationProvider;
9453
9448
  return (_this_validationProvider = this.validationProvider) === null || _this_validationProvider === void 0 ? void 0 : _this_validationProvider.getValidationsForBinding(binding);
9454
9449
  }
9450
+ },
9451
+ {
9452
+ key: "setTemplatePlugin",
9453
+ value: function setTemplatePlugin(plugin) {
9454
+ this.templatePlugin = plugin;
9455
+ }
9455
9456
  }
9456
9457
  ]);
9457
9458
  return ViewInstance;
@@ -9623,6 +9624,7 @@ var MarkdownPlugin = function() {
9623
9624
  value: function apply(view) {
9624
9625
  view.hooks.parser.tap("template", this.applyParser.bind(this));
9625
9626
  view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
9627
+ view.setTemplatePlugin(this);
9626
9628
  }
9627
9629
  }
9628
9630
  ]);
@@ -10202,13 +10204,13 @@ var MarkdownPlugin = function() {
10202
10204
  this.isTransitioning = false;
10203
10205
  this.hooks = {
10204
10206
  beforeStart: new SyncBailHook(),
10205
- /** A callback when the onStart node was present */ onStart: new SyncHook(),
10206
- /** A callback when the onEnd node was present */ onEnd: new SyncHook(),
10207
- /** A hook to intercept and block a transition */ skipTransition: new SyncBailHook(),
10208
- /** A chance to manipulate the flow-node used to calculate the given transition used */ beforeTransition: new SyncWaterfallHook(),
10209
- /** A chance to manipulate the flow-node calculated after a transition */ resolveTransitionNode: new SyncWaterfallHook(),
10210
- /** A callback when a transition from 1 state to another was made */ transition: new SyncHook(),
10211
- /** A callback to run actions after a transition occurs */ afterTransition: new SyncHook()
10207
+ onStart: new SyncHook(),
10208
+ onEnd: new SyncHook(),
10209
+ skipTransition: new SyncBailHook(),
10210
+ beforeTransition: new SyncWaterfallHook(),
10211
+ resolveTransitionNode: new SyncWaterfallHook(),
10212
+ transition: new SyncHook(),
10213
+ afterTransition: new SyncHook()
10212
10214
  };
10213
10215
  this.id = id;
10214
10216
  this.flow = flow3;
@@ -11231,8 +11233,7 @@ var MarkdownPlugin = function() {
11231
11233
  var _this1 = this;
11232
11234
  _class_call_check(this, ViewController);
11233
11235
  this.hooks = {
11234
- /** Do any processing before the `View` instance is created */ resolveView: new SyncWaterfallHook(),
11235
- // The hook right before the View starts resolving. Attach anything custom here
11236
+ resolveView: new SyncWaterfallHook(),
11236
11237
  view: new SyncHook()
11237
11238
  };
11238
11239
  this.transformRegistry = new Registry();
@@ -11280,6 +11281,7 @@ var MarkdownPlugin = function() {
11280
11281
  ]));
11281
11282
  }
11282
11283
  });
11284
+ this.viewPlugins = this.createViewPlugins();
11283
11285
  }
11284
11286
  _create_class(ViewController, [
11285
11287
  {
@@ -11335,9 +11337,50 @@ var MarkdownPlugin = function() {
11335
11337
  }
11336
11338
  var view = new ViewInstance(source, this.viewOptions);
11337
11339
  this.currentView = view;
11340
+ this.applyViewPlugins(view);
11338
11341
  this.hooks.view.call(view);
11339
11342
  view.update();
11340
11343
  }
11344
+ },
11345
+ {
11346
+ key: "applyViewPlugins",
11347
+ value: function applyViewPlugins(view) {
11348
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
11349
+ try {
11350
+ for(var _iterator = this.viewPlugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
11351
+ var plugin = _step.value;
11352
+ plugin.apply(view);
11353
+ }
11354
+ } catch (err) {
11355
+ _didIteratorError = true;
11356
+ _iteratorError = err;
11357
+ } finally{
11358
+ try {
11359
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
11360
+ _iterator.return();
11361
+ }
11362
+ } finally{
11363
+ if (_didIteratorError) {
11364
+ throw _iteratorError;
11365
+ }
11366
+ }
11367
+ }
11368
+ }
11369
+ },
11370
+ {
11371
+ key: "createViewPlugins",
11372
+ value: function createViewPlugins() {
11373
+ var pluginOptions = toNodeResolveOptions(this.viewOptions);
11374
+ return [
11375
+ new AssetPlugin(),
11376
+ new SwitchPlugin(pluginOptions),
11377
+ new ApplicabilityPlugin(),
11378
+ new AssetTransformCorePlugin(this.transformRegistry),
11379
+ new StringResolverPlugin(),
11380
+ new TemplatePlugin(pluginOptions),
11381
+ new MultiNodePlugin()
11382
+ ];
11383
+ }
11341
11384
  }
11342
11385
  ]);
11343
11386
  return ViewController;
@@ -11710,35 +11753,6 @@ var MarkdownPlugin = function() {
11710
11753
  ref: Symbol("not-started"),
11711
11754
  status: "not-started"
11712
11755
  };
11713
- var DefaultViewPlugin = /*#__PURE__*/ function() {
11714
- function DefaultViewPlugin() {
11715
- _class_call_check(this, DefaultViewPlugin);
11716
- this.name = "default-view-plugin";
11717
- }
11718
- _create_class(DefaultViewPlugin, [
11719
- {
11720
- key: "apply",
11721
- value: function apply(player) {
11722
- var _this = this;
11723
- player.hooks.viewController.tap(this.name, function(viewController) {
11724
- viewController.hooks.view.tap(_this.name, function(view) {
11725
- var pluginOptions = toNodeResolveOptions(view.resolverOptions);
11726
- new AssetPlugin().apply(view);
11727
- new SwitchPlugin(pluginOptions).apply(view);
11728
- new ApplicabilityPlugin().apply(view);
11729
- new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
11730
- new StringResolverPlugin().apply(view);
11731
- var templatePlugin = new TemplatePlugin(pluginOptions);
11732
- templatePlugin.apply(view);
11733
- view.hooks.onTemplatePluginCreated.call(templatePlugin);
11734
- new MultiNodePlugin().apply(view);
11735
- });
11736
- });
11737
- }
11738
- }
11739
- ]);
11740
- return DefaultViewPlugin;
11741
- }();
11742
11756
  var PLAYER_VERSION = "__VERSION__";
11743
11757
  var COMMIT = "__GIT_COMMIT__";
11744
11758
  var _Player = /*#__PURE__*/ function() {
@@ -11768,8 +11782,7 @@ var MarkdownPlugin = function() {
11768
11782
  }
11769
11783
  this.config = config || {};
11770
11784
  this.config.plugins = [
11771
- new DefaultExpPlugin(),
11772
- new DefaultViewPlugin()
11785
+ new DefaultExpPlugin()
11773
11786
  ].concat(_to_consumable_array(this.config.plugins || []), [
11774
11787
  new FlowExpPlugin()
11775
11788
  ]);
@@ -11956,95 +11969,41 @@ var MarkdownPlugin = function() {
11956
11969
  validationController.reset();
11957
11970
  }
11958
11971
  });
11959
- flow3.hooks.afterTransition.tap("player", function(flowInstance) {
11972
+ flow3.hooks.afterTransition.tap("player-action-states", function(flowInstance) {
11960
11973
  var _flowInstance_currentState;
11961
11974
  var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
11962
- if (value && value.state_type === "ACTION") {
11975
+ if (value && value.state_type === "ASYNC_ACTION") {
11963
11976
  var exp = value.exp;
11964
- var result = expressionEvaluator.evaluate(exp);
11965
- if (isPromiseLike(result)) {
11977
+ try {
11978
+ var result = expressionEvaluator.evaluateAsync(exp);
11979
+ if (isPromiseLike(result)) {
11980
+ if (value.await) {
11981
+ queueMicrotask(function() {
11982
+ result.then(function(r) {
11983
+ return flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(r));
11984
+ }).catch(flowResultDeferred.reject);
11985
+ });
11986
+ } else {
11987
+ _this.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
11988
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
11989
+ }
11990
+ } else {
11991
+ _this.logger.warn("Non async expression used in async action node");
11992
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
11993
+ }
11994
+ } catch (e) {
11995
+ flowResultDeferred.reject(e);
11996
+ }
11997
+ } else if (value && value.state_type === "ACTION") {
11998
+ var exp1 = value.exp;
11999
+ var result1 = expressionEvaluator.evaluate(exp1);
12000
+ if (isPromiseLike(result1)) {
11966
12001
  _this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
11967
12002
  }
11968
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
12003
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result1));
11969
12004
  }
11970
12005
  expressionEvaluator.reset();
11971
12006
  });
11972
- var _this1 = _this;
11973
- flow3.hooks.afterTransition.tap("player", function() {
11974
- var _ref = _async_to_generator(function(flowInstance) {
11975
- var _flowInstance_currentState, value, exp, result, e;
11976
- return _ts_generator(this, function(_state) {
11977
- switch(_state.label){
11978
- case 0:
11979
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
11980
- if (!(value && value.state_type === "ASYNC_ACTION")) return [
11981
- 3,
11982
- 8
11983
- ];
11984
- exp = value.exp;
11985
- _state.label = 1;
11986
- case 1:
11987
- _state.trys.push([
11988
- 1,
11989
- 7,
11990
- ,
11991
- 8
11992
- ]);
11993
- result = expressionEvaluator.evaluateAsync(exp);
11994
- if (!isPromiseLike(result)) return [
11995
- 3,
11996
- 5
11997
- ];
11998
- if (!value.await) return [
11999
- 3,
12000
- 3
12001
- ];
12002
- return [
12003
- 4,
12004
- result
12005
- ];
12006
- case 2:
12007
- result = _state.sent();
12008
- return [
12009
- 3,
12010
- 4
12011
- ];
12012
- case 3:
12013
- _this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
12014
- _state.label = 4;
12015
- case 4:
12016
- return [
12017
- 3,
12018
- 6
12019
- ];
12020
- case 5:
12021
- _this1.logger.warn("Non async expression used in async action node");
12022
- _state.label = 6;
12023
- case 6:
12024
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
12025
- return [
12026
- 3,
12027
- 8
12028
- ];
12029
- case 7:
12030
- e = _state.sent();
12031
- flowResultDeferred.reject(e);
12032
- return [
12033
- 3,
12034
- 8
12035
- ];
12036
- case 8:
12037
- expressionEvaluator.reset();
12038
- return [
12039
- 2
12040
- ];
12041
- }
12042
- });
12043
- });
12044
- return function(flowInstance) {
12045
- return _ref.apply(this, arguments);
12046
- };
12047
- }());
12048
12007
  });
12049
12008
  this.hooks.dataController.call(dataController);
12050
12009
  validationController.setOptions({
@@ -12082,11 +12041,9 @@ var MarkdownPlugin = function() {
12082
12041
  }),
12083
12042
  constants: this.constantsController
12084
12043
  });
12085
- this.hooks.viewController.tap("player", function(vc) {
12086
- vc.hooks.view.tap("player", function(view) {
12087
- validationController.onView(view);
12088
- _this.hooks.view.call(view);
12089
- });
12044
+ viewController.hooks.view.tap("player", function(view) {
12045
+ validationController.onView(view);
12046
+ _this.hooks.view.call(view);
12090
12047
  });
12091
12048
  this.hooks.viewController.call(viewController);
12092
12049
  return {