@player-ui/check-path-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.
@@ -4605,6 +4605,12 @@ var CheckPathPlugin = function() {
4605
4605
  this.shadowModelPaths = removeBindingAndChildrenFromMap(this.shadowModelPaths, binding);
4606
4606
  return next === null || next === void 0 ? void 0 : next.delete(binding, options);
4607
4607
  }
4608
+ },
4609
+ {
4610
+ /** Clears any invalid values staged in the shadow model */ key: "reset",
4611
+ value: function reset() {
4612
+ this.shadowModelPaths.clear();
4613
+ }
4608
4614
  }
4609
4615
  ]);
4610
4616
  return ValidationMiddleware;
@@ -5471,6 +5477,47 @@ var CheckPathPlugin = function() {
5471
5477
  /** Return the middleware for the data-model to stop propagation of invalid data */ key: "getDataMiddleware",
5472
5478
  value: function getDataMiddleware() {
5473
5479
  var _this = this;
5480
+ var validationMiddleware = new ValidationMiddleware(function(binding) {
5481
+ var _strongValidation_get;
5482
+ if (!_this.options) {
5483
+ return;
5484
+ }
5485
+ _this.updateValidationsForBinding(binding, "change", _this.options);
5486
+ var strongValidation = _this.getValidationForBinding(binding);
5487
+ if ((strongValidation === null || strongValidation === void 0 ? void 0 : (_strongValidation_get = strongValidation.get()) === null || _strongValidation_get === void 0 ? void 0 : _strongValidation_get.severity) === "error") {
5488
+ return strongValidation.get();
5489
+ }
5490
+ var newInvalidBindings = /* @__PURE__ */ new Set();
5491
+ _this.validations.forEach(function(weakValidation, strongBinding) {
5492
+ var _weakValidation_get;
5493
+ if (caresAboutDataChanges(/* @__PURE__ */ new Set([
5494
+ binding
5495
+ ]), weakValidation.weakBindings) && (weakValidation === null || weakValidation === void 0 ? void 0 : (_weakValidation_get = weakValidation.get()) === null || _weakValidation_get === void 0 ? void 0 : _weakValidation_get.severity) === "error") {
5496
+ weakValidation === null || weakValidation === void 0 ? void 0 : weakValidation.weakBindings.forEach(function(weakBinding) {
5497
+ if (weakBinding === strongBinding) {
5498
+ newInvalidBindings.add({
5499
+ binding: weakBinding,
5500
+ isStrong: true
5501
+ });
5502
+ } else {
5503
+ newInvalidBindings.add({
5504
+ binding: weakBinding,
5505
+ isStrong: false
5506
+ });
5507
+ }
5508
+ });
5509
+ }
5510
+ });
5511
+ if (newInvalidBindings.size > 0) {
5512
+ return newInvalidBindings;
5513
+ }
5514
+ }, {
5515
+ logger: new ProxyLogger(function() {
5516
+ var _this_options;
5517
+ return (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.logger;
5518
+ })
5519
+ });
5520
+ this.validationMiddleware = validationMiddleware;
5474
5521
  return [
5475
5522
  {
5476
5523
  set: function(transaction, options, next) {
@@ -5485,46 +5532,7 @@ var CheckPathPlugin = function() {
5485
5532
  return next === null || next === void 0 ? void 0 : next.delete(binding, options);
5486
5533
  }
5487
5534
  },
5488
- new ValidationMiddleware(function(binding) {
5489
- var _strongValidation_get;
5490
- if (!_this.options) {
5491
- return;
5492
- }
5493
- _this.updateValidationsForBinding(binding, "change", _this.options);
5494
- var strongValidation = _this.getValidationForBinding(binding);
5495
- if ((strongValidation === null || strongValidation === void 0 ? void 0 : (_strongValidation_get = strongValidation.get()) === null || _strongValidation_get === void 0 ? void 0 : _strongValidation_get.severity) === "error") {
5496
- return strongValidation.get();
5497
- }
5498
- var newInvalidBindings = /* @__PURE__ */ new Set();
5499
- _this.validations.forEach(function(weakValidation, strongBinding) {
5500
- var _weakValidation_get;
5501
- if (caresAboutDataChanges(/* @__PURE__ */ new Set([
5502
- binding
5503
- ]), weakValidation.weakBindings) && (weakValidation === null || weakValidation === void 0 ? void 0 : (_weakValidation_get = weakValidation.get()) === null || _weakValidation_get === void 0 ? void 0 : _weakValidation_get.severity) === "error") {
5504
- weakValidation === null || weakValidation === void 0 ? void 0 : weakValidation.weakBindings.forEach(function(weakBinding) {
5505
- if (weakBinding === strongBinding) {
5506
- newInvalidBindings.add({
5507
- binding: weakBinding,
5508
- isStrong: true
5509
- });
5510
- } else {
5511
- newInvalidBindings.add({
5512
- binding: weakBinding,
5513
- isStrong: false
5514
- });
5515
- }
5516
- });
5517
- }
5518
- });
5519
- if (newInvalidBindings.size > 0) {
5520
- return newInvalidBindings;
5521
- }
5522
- }, {
5523
- logger: new ProxyLogger(function() {
5524
- var _this_options;
5525
- return (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.logger;
5526
- })
5527
- })
5535
+ validationMiddleware
5528
5536
  ];
5529
5537
  }
5530
5538
  },
@@ -5560,15 +5568,17 @@ var CheckPathPlugin = function() {
5560
5568
  {
5561
5569
  key: "reset",
5562
5570
  value: function reset() {
5571
+ var _this_validationMiddleware;
5563
5572
  this.validations.clear();
5564
5573
  this.tracker = void 0;
5574
+ (_this_validationMiddleware = this.validationMiddleware) === null || _this_validationMiddleware === void 0 ? void 0 : _this_validationMiddleware.reset();
5565
5575
  }
5566
5576
  },
5567
5577
  {
5568
5578
  key: "onView",
5569
5579
  value: function onView(view) {
5570
5580
  var _this = this;
5571
- this.validations.clear();
5581
+ this.reset();
5572
5582
  if (!this.options) {
5573
5583
  return;
5574
5584
  }
@@ -7865,8 +7875,8 @@ var CheckPathPlugin = function() {
7865
7875
  ref: Symbol("not-started"),
7866
7876
  status: "not-started"
7867
7877
  };
7868
- var PLAYER_VERSION = true ? "1.1.0-next.1" : "unknown";
7869
- var COMMIT = true ? "8d1e44b77769e923785e6218de2d9f99342b9b1a" : "unknown";
7878
+ var PLAYER_VERSION = true ? "1.1.0-next.3" : "unknown";
7879
+ var COMMIT = true ? "234b74972b29ff0fa11655411dc3cd9d8a98de2a" : "unknown";
7870
7880
  var _Player = /*#__PURE__*/ function() {
7871
7881
  function _Player2(config) {
7872
7882
  var _this = this;
@@ -7888,7 +7898,8 @@ var CheckPathPlugin = function() {
7888
7898
  state: new SyncHook(),
7889
7899
  onStart: new SyncHook(),
7890
7900
  onEnd: new SyncHook(),
7891
- resolveFlowContent: new SyncWaterfallHook()
7901
+ resolveFlowContent: new SyncWaterfallHook(),
7902
+ transformContent: new SyncBailHook()
7892
7903
  };
7893
7904
  if (config === null || config === void 0 ? void 0 : config.logger) {
7894
7905
  this.logger.addHandler(config.logger);
@@ -7902,6 +7913,9 @@ var CheckPathPlugin = function() {
7902
7913
  (_this_config_plugins = this.config.plugins) === null || _this_config_plugins === void 0 ? void 0 : _this_config_plugins.forEach(function(plugin) {
7903
7914
  plugin.apply(_this);
7904
7915
  });
7916
+ this.hooks.transformContent.tap("player", function(payload, meta) {
7917
+ return meta.format === "player" ? payload : void 0;
7918
+ });
7905
7919
  }
7906
7920
  _create_class(_Player2, [
7907
7921
  {
@@ -8208,14 +8222,22 @@ var CheckPathPlugin = function() {
8208
8222
  },
8209
8223
  {
8210
8224
  key: "start",
8211
- value: function start(payload) {
8225
+ value: function start(payload, options) {
8212
8226
  return _async_to_generator(function() {
8213
- var _this, _payload_id, ref, maybeUpdateState, _this_setupFlow, state, start, endProps, _tmp, error, errorState;
8227
+ var _this, _options_format, meta, flow, _flow_id, ref, maybeUpdateState, _this_setupFlow, state, start, endProps, _tmp, error, errorState;
8214
8228
  return _ts_generator(this, function(_state) {
8215
8229
  switch(_state.label){
8216
8230
  case 0:
8217
8231
  _this = this;
8218
- ref = Symbol((_payload_id = payload === null || payload === void 0 ? void 0 : payload.id) !== null && _payload_id !== void 0 ? _payload_id : "payload");
8232
+ meta = {
8233
+ format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "player",
8234
+ version: options === null || options === void 0 ? void 0 : options.version
8235
+ };
8236
+ flow = this.hooks.transformContent.call(payload, meta);
8237
+ if (!flow) {
8238
+ throw new Error('Player.start received content with format "'.concat(meta.format, '" that no plugin transformed into a Flow.'));
8239
+ }
8240
+ ref = Symbol((_flow_id = flow.id) !== null && _flow_id !== void 0 ? _flow_id : "payload");
8219
8241
  maybeUpdateState = function(newState) {
8220
8242
  if (_this.state.ref !== ref) {
8221
8243
  _this.logger.warn("Received update for a flow that's not the current one");
@@ -8236,7 +8258,7 @@ var CheckPathPlugin = function() {
8236
8258
  ,
8237
8259
  4
8238
8260
  ]);
8239
- _this_setupFlow = this.setupFlow(payload), state = _this_setupFlow.state, start = _this_setupFlow.start;
8261
+ _this_setupFlow = this.setupFlow(flow), state = _this_setupFlow.state, start = _this_setupFlow.start;
8240
8262
  this.setState(_object_spread({
8241
8263
  ref: ref
8242
8264
  }, state));
@@ -8271,7 +8293,7 @@ var CheckPathPlugin = function() {
8271
8293
  errorState = {
8272
8294
  status: "error",
8273
8295
  ref: ref,
8274
- flow: payload,
8296
+ flow: flow,
8275
8297
  error: error
8276
8298
  };
8277
8299
  maybeUpdateState(errorState);