@player-ui/markdown-plugin 1.1.0-next.1 → 1.1.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.
@@ -8936,6 +8936,12 @@ var MarkdownPlugin = function() {
8936
8936
  this.shadowModelPaths = removeBindingAndChildrenFromMap(this.shadowModelPaths, binding);
8937
8937
  return next === null || next === void 0 ? void 0 : next.delete(binding, options);
8938
8938
  }
8939
+ },
8940
+ {
8941
+ /** Clears any invalid values staged in the shadow model */ key: "reset",
8942
+ value: function reset() {
8943
+ this.shadowModelPaths.clear();
8944
+ }
8939
8945
  }
8940
8946
  ]);
8941
8947
  return ValidationMiddleware;
@@ -9802,6 +9808,47 @@ var MarkdownPlugin = function() {
9802
9808
  /** Return the middleware for the data-model to stop propagation of invalid data */ key: "getDataMiddleware",
9803
9809
  value: function getDataMiddleware() {
9804
9810
  var _this = this;
9811
+ var validationMiddleware = new ValidationMiddleware(function(binding) {
9812
+ var _strongValidation_get;
9813
+ if (!_this.options) {
9814
+ return;
9815
+ }
9816
+ _this.updateValidationsForBinding(binding, "change", _this.options);
9817
+ var strongValidation = _this.getValidationForBinding(binding);
9818
+ if ((strongValidation === null || strongValidation === void 0 ? void 0 : (_strongValidation_get = strongValidation.get()) === null || _strongValidation_get === void 0 ? void 0 : _strongValidation_get.severity) === "error") {
9819
+ return strongValidation.get();
9820
+ }
9821
+ var newInvalidBindings = /* @__PURE__ */ new Set();
9822
+ _this.validations.forEach(function(weakValidation, strongBinding) {
9823
+ var _weakValidation_get;
9824
+ if (caresAboutDataChanges(/* @__PURE__ */ new Set([
9825
+ binding
9826
+ ]), weakValidation.weakBindings) && (weakValidation === null || weakValidation === void 0 ? void 0 : (_weakValidation_get = weakValidation.get()) === null || _weakValidation_get === void 0 ? void 0 : _weakValidation_get.severity) === "error") {
9827
+ weakValidation === null || weakValidation === void 0 ? void 0 : weakValidation.weakBindings.forEach(function(weakBinding) {
9828
+ if (weakBinding === strongBinding) {
9829
+ newInvalidBindings.add({
9830
+ binding: weakBinding,
9831
+ isStrong: true
9832
+ });
9833
+ } else {
9834
+ newInvalidBindings.add({
9835
+ binding: weakBinding,
9836
+ isStrong: false
9837
+ });
9838
+ }
9839
+ });
9840
+ }
9841
+ });
9842
+ if (newInvalidBindings.size > 0) {
9843
+ return newInvalidBindings;
9844
+ }
9845
+ }, {
9846
+ logger: new ProxyLogger(function() {
9847
+ var _this_options;
9848
+ return (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.logger;
9849
+ })
9850
+ });
9851
+ this.validationMiddleware = validationMiddleware;
9805
9852
  return [
9806
9853
  {
9807
9854
  set: function(transaction, options, next) {
@@ -9816,46 +9863,7 @@ var MarkdownPlugin = function() {
9816
9863
  return next === null || next === void 0 ? void 0 : next.delete(binding, options);
9817
9864
  }
9818
9865
  },
9819
- new ValidationMiddleware(function(binding) {
9820
- var _strongValidation_get;
9821
- if (!_this.options) {
9822
- return;
9823
- }
9824
- _this.updateValidationsForBinding(binding, "change", _this.options);
9825
- var strongValidation = _this.getValidationForBinding(binding);
9826
- if ((strongValidation === null || strongValidation === void 0 ? void 0 : (_strongValidation_get = strongValidation.get()) === null || _strongValidation_get === void 0 ? void 0 : _strongValidation_get.severity) === "error") {
9827
- return strongValidation.get();
9828
- }
9829
- var newInvalidBindings = /* @__PURE__ */ new Set();
9830
- _this.validations.forEach(function(weakValidation, strongBinding) {
9831
- var _weakValidation_get;
9832
- if (caresAboutDataChanges(/* @__PURE__ */ new Set([
9833
- binding
9834
- ]), weakValidation.weakBindings) && (weakValidation === null || weakValidation === void 0 ? void 0 : (_weakValidation_get = weakValidation.get()) === null || _weakValidation_get === void 0 ? void 0 : _weakValidation_get.severity) === "error") {
9835
- weakValidation === null || weakValidation === void 0 ? void 0 : weakValidation.weakBindings.forEach(function(weakBinding) {
9836
- if (weakBinding === strongBinding) {
9837
- newInvalidBindings.add({
9838
- binding: weakBinding,
9839
- isStrong: true
9840
- });
9841
- } else {
9842
- newInvalidBindings.add({
9843
- binding: weakBinding,
9844
- isStrong: false
9845
- });
9846
- }
9847
- });
9848
- }
9849
- });
9850
- if (newInvalidBindings.size > 0) {
9851
- return newInvalidBindings;
9852
- }
9853
- }, {
9854
- logger: new ProxyLogger(function() {
9855
- var _this_options;
9856
- return (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.logger;
9857
- })
9858
- })
9866
+ validationMiddleware
9859
9867
  ];
9860
9868
  }
9861
9869
  },
@@ -9891,15 +9899,17 @@ var MarkdownPlugin = function() {
9891
9899
  {
9892
9900
  key: "reset",
9893
9901
  value: function reset() {
9902
+ var _this_validationMiddleware;
9894
9903
  this.validations.clear();
9895
9904
  this.tracker = void 0;
9905
+ (_this_validationMiddleware = this.validationMiddleware) === null || _this_validationMiddleware === void 0 ? void 0 : _this_validationMiddleware.reset();
9896
9906
  }
9897
9907
  },
9898
9908
  {
9899
9909
  key: "onView",
9900
9910
  value: function onView(view) {
9901
9911
  var _this = this;
9902
- this.validations.clear();
9912
+ this.reset();
9903
9913
  if (!this.options) {
9904
9914
  return;
9905
9915
  }
@@ -12196,8 +12206,8 @@ var MarkdownPlugin = function() {
12196
12206
  ref: Symbol("not-started"),
12197
12207
  status: "not-started"
12198
12208
  };
12199
- var PLAYER_VERSION = true ? "1.1.0-next.1" : "unknown";
12200
- var COMMIT = true ? "8d1e44b77769e923785e6218de2d9f99342b9b1a" : "unknown";
12209
+ var PLAYER_VERSION = true ? "1.1.0-next.3" : "unknown";
12210
+ var COMMIT = true ? "234b74972b29ff0fa11655411dc3cd9d8a98de2a" : "unknown";
12201
12211
  var _Player = /*#__PURE__*/ function() {
12202
12212
  function _Player2(config) {
12203
12213
  var _this = this;
@@ -12219,7 +12229,8 @@ var MarkdownPlugin = function() {
12219
12229
  state: new SyncHook(),
12220
12230
  onStart: new SyncHook(),
12221
12231
  onEnd: new SyncHook(),
12222
- resolveFlowContent: new SyncWaterfallHook()
12232
+ resolveFlowContent: new SyncWaterfallHook(),
12233
+ transformContent: new SyncBailHook()
12223
12234
  };
12224
12235
  if (config === null || config === void 0 ? void 0 : config.logger) {
12225
12236
  this.logger.addHandler(config.logger);
@@ -12233,6 +12244,9 @@ var MarkdownPlugin = function() {
12233
12244
  (_this_config_plugins = this.config.plugins) === null || _this_config_plugins === void 0 ? void 0 : _this_config_plugins.forEach(function(plugin) {
12234
12245
  plugin.apply(_this);
12235
12246
  });
12247
+ this.hooks.transformContent.tap("player", function(payload, meta) {
12248
+ return meta.format === "player" ? payload : void 0;
12249
+ });
12236
12250
  }
12237
12251
  _create_class(_Player2, [
12238
12252
  {
@@ -12539,14 +12553,22 @@ var MarkdownPlugin = function() {
12539
12553
  },
12540
12554
  {
12541
12555
  key: "start",
12542
- value: function start(payload) {
12556
+ value: function start(payload, options) {
12543
12557
  return _async_to_generator(function() {
12544
- var _this, _payload_id, ref, maybeUpdateState, _this_setupFlow, state, start, endProps, _tmp, error, errorState;
12558
+ var _this, _options_format, meta, flow3, _flow3_id, ref, maybeUpdateState, _this_setupFlow, state, start, endProps, _tmp, error, errorState;
12545
12559
  return _ts_generator(this, function(_state) {
12546
12560
  switch(_state.label){
12547
12561
  case 0:
12548
12562
  _this = this;
12549
- ref = Symbol((_payload_id = payload === null || payload === void 0 ? void 0 : payload.id) !== null && _payload_id !== void 0 ? _payload_id : "payload");
12563
+ meta = {
12564
+ format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "player",
12565
+ version: options === null || options === void 0 ? void 0 : options.version
12566
+ };
12567
+ flow3 = this.hooks.transformContent.call(payload, meta);
12568
+ if (!flow3) {
12569
+ throw new Error('Player.start received content with format "'.concat(meta.format, '" that no plugin transformed into a Flow.'));
12570
+ }
12571
+ ref = Symbol((_flow3_id = flow3.id) !== null && _flow3_id !== void 0 ? _flow3_id : "payload");
12550
12572
  maybeUpdateState = function(newState) {
12551
12573
  if (_this.state.ref !== ref) {
12552
12574
  _this.logger.warn("Received update for a flow that's not the current one");
@@ -12567,7 +12589,7 @@ var MarkdownPlugin = function() {
12567
12589
  ,
12568
12590
  4
12569
12591
  ]);
12570
- _this_setupFlow = this.setupFlow(payload), state = _this_setupFlow.state, start = _this_setupFlow.start;
12592
+ _this_setupFlow = this.setupFlow(flow3), state = _this_setupFlow.state, start = _this_setupFlow.start;
12571
12593
  this.setState(_object_spread({
12572
12594
  ref: ref
12573
12595
  }, state));
@@ -12602,7 +12624,7 @@ var MarkdownPlugin = function() {
12602
12624
  errorState = {
12603
12625
  status: "error",
12604
12626
  ref: ref,
12605
- flow: payload,
12627
+ flow: flow3,
12606
12628
  error: error
12607
12629
  };
12608
12630
  maybeUpdateState(errorState);