@player-ui/player 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.
@@ -2739,6 +2739,10 @@ var ValidationMiddleware = class {
2739
2739
  );
2740
2740
  return next?.delete(binding, options);
2741
2741
  }
2742
+ /** Clears any invalid values staged in the shadow model */
2743
+ reset() {
2744
+ this.shadowModelPaths.clear();
2745
+ }
2742
2746
  };
2743
2747
 
2744
2748
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/validator/registry.ts
@@ -3578,6 +3582,44 @@ var ValidationController = class {
3578
3582
  }
3579
3583
  /** Return the middleware for the data-model to stop propagation of invalid data */
3580
3584
  getDataMiddleware() {
3585
+ const validationMiddleware = new ValidationMiddleware(
3586
+ (binding) => {
3587
+ if (!this.options) {
3588
+ return;
3589
+ }
3590
+ this.updateValidationsForBinding(binding, "change", this.options);
3591
+ const strongValidation = this.getValidationForBinding(binding);
3592
+ if (strongValidation?.get()?.severity === "error") {
3593
+ return strongValidation.get();
3594
+ }
3595
+ const newInvalidBindings = /* @__PURE__ */ new Set();
3596
+ this.validations.forEach((weakValidation, strongBinding) => {
3597
+ if (caresAboutDataChanges(
3598
+ /* @__PURE__ */ new Set([binding]),
3599
+ weakValidation.weakBindings
3600
+ ) && weakValidation?.get()?.severity === "error") {
3601
+ weakValidation?.weakBindings.forEach((weakBinding) => {
3602
+ if (weakBinding === strongBinding) {
3603
+ newInvalidBindings.add({
3604
+ binding: weakBinding,
3605
+ isStrong: true
3606
+ });
3607
+ } else {
3608
+ newInvalidBindings.add({
3609
+ binding: weakBinding,
3610
+ isStrong: false
3611
+ });
3612
+ }
3613
+ });
3614
+ }
3615
+ });
3616
+ if (newInvalidBindings.size > 0) {
3617
+ return newInvalidBindings;
3618
+ }
3619
+ },
3620
+ { logger: new ProxyLogger(() => this.options?.logger) }
3621
+ );
3622
+ this.validationMiddleware = validationMiddleware;
3581
3623
  return [
3582
3624
  {
3583
3625
  set: (transaction, options, next) => {
@@ -3594,43 +3636,7 @@ var ValidationController = class {
3594
3636
  return next?.delete(binding, options);
3595
3637
  }
3596
3638
  },
3597
- new ValidationMiddleware(
3598
- (binding) => {
3599
- if (!this.options) {
3600
- return;
3601
- }
3602
- this.updateValidationsForBinding(binding, "change", this.options);
3603
- const strongValidation = this.getValidationForBinding(binding);
3604
- if (strongValidation?.get()?.severity === "error") {
3605
- return strongValidation.get();
3606
- }
3607
- const newInvalidBindings = /* @__PURE__ */ new Set();
3608
- this.validations.forEach((weakValidation, strongBinding) => {
3609
- if (caresAboutDataChanges(
3610
- /* @__PURE__ */ new Set([binding]),
3611
- weakValidation.weakBindings
3612
- ) && weakValidation?.get()?.severity === "error") {
3613
- weakValidation?.weakBindings.forEach((weakBinding) => {
3614
- if (weakBinding === strongBinding) {
3615
- newInvalidBindings.add({
3616
- binding: weakBinding,
3617
- isStrong: true
3618
- });
3619
- } else {
3620
- newInvalidBindings.add({
3621
- binding: weakBinding,
3622
- isStrong: false
3623
- });
3624
- }
3625
- });
3626
- }
3627
- });
3628
- if (newInvalidBindings.size > 0) {
3629
- return newInvalidBindings;
3630
- }
3631
- },
3632
- { logger: new ProxyLogger(() => this.options?.logger) }
3633
- )
3639
+ validationMiddleware
3634
3640
  ];
3635
3641
  }
3636
3642
  getValidationProviders() {
@@ -3661,9 +3667,10 @@ var ValidationController = class {
3661
3667
  reset() {
3662
3668
  this.validations.clear();
3663
3669
  this.tracker = void 0;
3670
+ this.validationMiddleware?.reset();
3664
3671
  }
3665
3672
  onView(view) {
3666
- this.validations.clear();
3673
+ this.reset();
3667
3674
  if (!this.options) {
3668
3675
  return;
3669
3676
  }
@@ -5825,8 +5832,8 @@ var NOT_STARTED_STATE = {
5825
5832
  };
5826
5833
 
5827
5834
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/player.ts
5828
- var PLAYER_VERSION = true ? "1.1.0-next.1" : "unknown";
5829
- var COMMIT = true ? "8d1e44b77769e923785e6218de2d9f99342b9b1a" : "unknown";
5835
+ var PLAYER_VERSION = true ? "1.1.0-next.3" : "unknown";
5836
+ var COMMIT = true ? "234b74972b29ff0fa11655411dc3cd9d8a98de2a" : "unknown";
5830
5837
  var _Player = class _Player {
5831
5838
  constructor(config) {
5832
5839
  this.logger = new TapableLogger();
@@ -5845,7 +5852,8 @@ var _Player = class _Player {
5845
5852
  state: new import_tapable_ts16.SyncHook(),
5846
5853
  onStart: new import_tapable_ts16.SyncHook(),
5847
5854
  onEnd: new import_tapable_ts16.SyncHook(),
5848
- resolveFlowContent: new import_tapable_ts16.SyncWaterfallHook()
5855
+ resolveFlowContent: new import_tapable_ts16.SyncWaterfallHook(),
5856
+ transformContent: new import_tapable_ts16.SyncBailHook()
5849
5857
  };
5850
5858
  if (config?.logger) {
5851
5859
  this.logger.addHandler(config.logger);
@@ -5859,6 +5867,10 @@ var _Player = class _Player {
5859
5867
  this.config.plugins?.forEach((plugin) => {
5860
5868
  plugin.apply(this);
5861
5869
  });
5870
+ this.hooks.transformContent.tap(
5871
+ "player",
5872
+ (payload, meta) => meta.format === "player" ? payload : void 0
5873
+ );
5862
5874
  }
5863
5875
  /** Returns currently registered plugins */
5864
5876
  getPlugins() {
@@ -6139,8 +6151,18 @@ var _Player = class _Player {
6139
6151
  }
6140
6152
  };
6141
6153
  }
6142
- async start(payload) {
6143
- const ref = Symbol(payload?.id ?? "payload");
6154
+ async start(payload, options) {
6155
+ const meta = {
6156
+ format: options?.format ?? "player",
6157
+ version: options?.version
6158
+ };
6159
+ const flow = this.hooks.transformContent.call(payload, meta);
6160
+ if (!flow) {
6161
+ throw new Error(
6162
+ `Player.start received content with format "${meta.format}" that no plugin transformed into a Flow.`
6163
+ );
6164
+ }
6165
+ const ref = Symbol(flow.id ?? "payload");
6144
6166
  const maybeUpdateState = (newState) => {
6145
6167
  if (this.state.ref !== ref) {
6146
6168
  this.logger.warn(
@@ -6156,7 +6178,7 @@ var _Player = class _Player {
6156
6178
  ref
6157
6179
  });
6158
6180
  try {
6159
- const { state, start } = this.setupFlow(payload);
6181
+ const { state, start } = this.setupFlow(flow);
6160
6182
  this.setState({
6161
6183
  ref,
6162
6184
  ...state
@@ -6178,7 +6200,7 @@ var _Player = class _Player {
6178
6200
  const errorState = {
6179
6201
  status: "error",
6180
6202
  ref,
6181
- flow: payload,
6203
+ flow,
6182
6204
  error
6183
6205
  };
6184
6206
  maybeUpdateState(errorState);