@player-ui/beacon-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.
@@ -4665,6 +4665,12 @@ var BeaconPlugin = function() {
4665
4665
  this.shadowModelPaths = removeBindingAndChildrenFromMap(this.shadowModelPaths, binding);
4666
4666
  return next === null || next === void 0 ? void 0 : next.delete(binding, options);
4667
4667
  }
4668
+ },
4669
+ {
4670
+ /** Clears any invalid values staged in the shadow model */ key: "reset",
4671
+ value: function reset() {
4672
+ this.shadowModelPaths.clear();
4673
+ }
4668
4674
  }
4669
4675
  ]);
4670
4676
  return ValidationMiddleware;
@@ -5518,6 +5524,47 @@ var BeaconPlugin = function() {
5518
5524
  /** Return the middleware for the data-model to stop propagation of invalid data */ key: "getDataMiddleware",
5519
5525
  value: function getDataMiddleware() {
5520
5526
  var _this = this;
5527
+ var validationMiddleware = new ValidationMiddleware(function(binding) {
5528
+ var _strongValidation_get;
5529
+ if (!_this.options) {
5530
+ return;
5531
+ }
5532
+ _this.updateValidationsForBinding(binding, "change", _this.options);
5533
+ var strongValidation = _this.getValidationForBinding(binding);
5534
+ if ((strongValidation === null || strongValidation === void 0 ? void 0 : (_strongValidation_get = strongValidation.get()) === null || _strongValidation_get === void 0 ? void 0 : _strongValidation_get.severity) === "error") {
5535
+ return strongValidation.get();
5536
+ }
5537
+ var newInvalidBindings = /* @__PURE__ */ new Set();
5538
+ _this.validations.forEach(function(weakValidation, strongBinding) {
5539
+ var _weakValidation_get;
5540
+ if (caresAboutDataChanges(/* @__PURE__ */ new Set([
5541
+ binding
5542
+ ]), weakValidation.weakBindings) && (weakValidation === null || weakValidation === void 0 ? void 0 : (_weakValidation_get = weakValidation.get()) === null || _weakValidation_get === void 0 ? void 0 : _weakValidation_get.severity) === "error") {
5543
+ weakValidation === null || weakValidation === void 0 ? void 0 : weakValidation.weakBindings.forEach(function(weakBinding) {
5544
+ if (weakBinding === strongBinding) {
5545
+ newInvalidBindings.add({
5546
+ binding: weakBinding,
5547
+ isStrong: true
5548
+ });
5549
+ } else {
5550
+ newInvalidBindings.add({
5551
+ binding: weakBinding,
5552
+ isStrong: false
5553
+ });
5554
+ }
5555
+ });
5556
+ }
5557
+ });
5558
+ if (newInvalidBindings.size > 0) {
5559
+ return newInvalidBindings;
5560
+ }
5561
+ }, {
5562
+ logger: new ProxyLogger(function() {
5563
+ var _this_options;
5564
+ return (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.logger;
5565
+ })
5566
+ });
5567
+ this.validationMiddleware = validationMiddleware;
5521
5568
  return [
5522
5569
  {
5523
5570
  set: function(transaction, options, next) {
@@ -5532,46 +5579,7 @@ var BeaconPlugin = function() {
5532
5579
  return next === null || next === void 0 ? void 0 : next.delete(binding, options);
5533
5580
  }
5534
5581
  },
5535
- new ValidationMiddleware(function(binding) {
5536
- var _strongValidation_get;
5537
- if (!_this.options) {
5538
- return;
5539
- }
5540
- _this.updateValidationsForBinding(binding, "change", _this.options);
5541
- var strongValidation = _this.getValidationForBinding(binding);
5542
- if ((strongValidation === null || strongValidation === void 0 ? void 0 : (_strongValidation_get = strongValidation.get()) === null || _strongValidation_get === void 0 ? void 0 : _strongValidation_get.severity) === "error") {
5543
- return strongValidation.get();
5544
- }
5545
- var newInvalidBindings = /* @__PURE__ */ new Set();
5546
- _this.validations.forEach(function(weakValidation, strongBinding) {
5547
- var _weakValidation_get;
5548
- if (caresAboutDataChanges(/* @__PURE__ */ new Set([
5549
- binding
5550
- ]), weakValidation.weakBindings) && (weakValidation === null || weakValidation === void 0 ? void 0 : (_weakValidation_get = weakValidation.get()) === null || _weakValidation_get === void 0 ? void 0 : _weakValidation_get.severity) === "error") {
5551
- weakValidation === null || weakValidation === void 0 ? void 0 : weakValidation.weakBindings.forEach(function(weakBinding) {
5552
- if (weakBinding === strongBinding) {
5553
- newInvalidBindings.add({
5554
- binding: weakBinding,
5555
- isStrong: true
5556
- });
5557
- } else {
5558
- newInvalidBindings.add({
5559
- binding: weakBinding,
5560
- isStrong: false
5561
- });
5562
- }
5563
- });
5564
- }
5565
- });
5566
- if (newInvalidBindings.size > 0) {
5567
- return newInvalidBindings;
5568
- }
5569
- }, {
5570
- logger: new ProxyLogger(function() {
5571
- var _this_options;
5572
- return (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.logger;
5573
- })
5574
- })
5582
+ validationMiddleware
5575
5583
  ];
5576
5584
  }
5577
5585
  },
@@ -5607,15 +5615,17 @@ var BeaconPlugin = function() {
5607
5615
  {
5608
5616
  key: "reset",
5609
5617
  value: function reset() {
5618
+ var _this_validationMiddleware;
5610
5619
  this.validations.clear();
5611
5620
  this.tracker = void 0;
5621
+ (_this_validationMiddleware = this.validationMiddleware) === null || _this_validationMiddleware === void 0 ? void 0 : _this_validationMiddleware.reset();
5612
5622
  }
5613
5623
  },
5614
5624
  {
5615
5625
  key: "onView",
5616
5626
  value: function onView(view) {
5617
5627
  var _this = this;
5618
- this.validations.clear();
5628
+ this.reset();
5619
5629
  if (!this.options) {
5620
5630
  return;
5621
5631
  }
@@ -7912,8 +7922,8 @@ var BeaconPlugin = function() {
7912
7922
  ref: Symbol("not-started"),
7913
7923
  status: "not-started"
7914
7924
  };
7915
- var PLAYER_VERSION = true ? "1.1.0-next.1" : "unknown";
7916
- var COMMIT = true ? "8d1e44b77769e923785e6218de2d9f99342b9b1a" : "unknown";
7925
+ var PLAYER_VERSION = true ? "1.1.0-next.3" : "unknown";
7926
+ var COMMIT = true ? "234b74972b29ff0fa11655411dc3cd9d8a98de2a" : "unknown";
7917
7927
  var _Player = /*#__PURE__*/ function() {
7918
7928
  function _Player2(config) {
7919
7929
  var _this = this;
@@ -7935,7 +7945,8 @@ var BeaconPlugin = function() {
7935
7945
  state: new SyncHook(),
7936
7946
  onStart: new SyncHook(),
7937
7947
  onEnd: new SyncHook(),
7938
- resolveFlowContent: new SyncWaterfallHook()
7948
+ resolveFlowContent: new SyncWaterfallHook(),
7949
+ transformContent: new SyncBailHook()
7939
7950
  };
7940
7951
  if (config === null || config === void 0 ? void 0 : config.logger) {
7941
7952
  this.logger.addHandler(config.logger);
@@ -7949,6 +7960,9 @@ var BeaconPlugin = function() {
7949
7960
  (_this_config_plugins = this.config.plugins) === null || _this_config_plugins === void 0 ? void 0 : _this_config_plugins.forEach(function(plugin) {
7950
7961
  plugin.apply(_this);
7951
7962
  });
7963
+ this.hooks.transformContent.tap("player", function(payload, meta) {
7964
+ return meta.format === "player" ? payload : void 0;
7965
+ });
7952
7966
  }
7953
7967
  _create_class(_Player2, [
7954
7968
  {
@@ -8255,14 +8269,22 @@ var BeaconPlugin = function() {
8255
8269
  },
8256
8270
  {
8257
8271
  key: "start",
8258
- value: function start(payload) {
8272
+ value: function start(payload, options) {
8259
8273
  return _async_to_generator(function() {
8260
- var _this, _payload_id, ref, maybeUpdateState, _this_setupFlow, state, start, endProps, _tmp, error, errorState;
8274
+ var _this, _options_format, meta, flow, _flow_id, ref, maybeUpdateState, _this_setupFlow, state, start, endProps, _tmp, error, errorState;
8261
8275
  return _ts_generator(this, function(_state) {
8262
8276
  switch(_state.label){
8263
8277
  case 0:
8264
8278
  _this = this;
8265
- ref = Symbol((_payload_id = payload === null || payload === void 0 ? void 0 : payload.id) !== null && _payload_id !== void 0 ? _payload_id : "payload");
8279
+ meta = {
8280
+ format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "player",
8281
+ version: options === null || options === void 0 ? void 0 : options.version
8282
+ };
8283
+ flow = this.hooks.transformContent.call(payload, meta);
8284
+ if (!flow) {
8285
+ throw new Error('Player.start received content with format "'.concat(meta.format, '" that no plugin transformed into a Flow.'));
8286
+ }
8287
+ ref = Symbol((_flow_id = flow.id) !== null && _flow_id !== void 0 ? _flow_id : "payload");
8266
8288
  maybeUpdateState = function(newState) {
8267
8289
  if (_this.state.ref !== ref) {
8268
8290
  _this.logger.warn("Received update for a flow that's not the current one");
@@ -8283,7 +8305,7 @@ var BeaconPlugin = function() {
8283
8305
  ,
8284
8306
  4
8285
8307
  ]);
8286
- _this_setupFlow = this.setupFlow(payload), state = _this_setupFlow.state, start = _this_setupFlow.start;
8308
+ _this_setupFlow = this.setupFlow(flow), state = _this_setupFlow.state, start = _this_setupFlow.start;
8287
8309
  this.setState(_object_spread({
8288
8310
  ref: ref
8289
8311
  }, state));
@@ -8318,7 +8340,7 @@ var BeaconPlugin = function() {
8318
8340
  errorState = {
8319
8341
  status: "error",
8320
8342
  ref: ref,
8321
- flow: payload,
8343
+ flow: flow,
8322
8344
  error: error
8323
8345
  };
8324
8346
  maybeUpdateState(errorState);