@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.
- package/dist/Player.native.js +71 -49
- package/dist/Player.native.js.map +1 -1
- package/dist/cjs/index.cjs +67 -45
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +68 -46
- package/dist/index.mjs +68 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/player.test.ts +173 -0
- package/src/__tests__/transform-content.test.ts +131 -0
- package/src/controllers/data/utils.ts +1 -1
- package/src/controllers/validation/controller.ts +53 -47
- package/src/player.ts +28 -5
- package/src/types.ts +41 -1
- package/src/validator/validation-middleware.ts +5 -0
- package/types/controllers/validation/controller.d.ts +1 -0
- package/types/player.d.ts +2 -3
- package/types/types.d.ts +39 -1
- package/types/validator/validation-middleware.d.ts +2 -0
package/dist/Player.native.js
CHANGED
|
@@ -4692,6 +4692,12 @@ var Player = function() {
|
|
|
4692
4692
|
this.shadowModelPaths = removeBindingAndChildrenFromMap(this.shadowModelPaths, binding);
|
|
4693
4693
|
return next === null || next === void 0 ? void 0 : next.delete(binding, options);
|
|
4694
4694
|
}
|
|
4695
|
+
},
|
|
4696
|
+
{
|
|
4697
|
+
/** Clears any invalid values staged in the shadow model */ key: "reset",
|
|
4698
|
+
value: function reset() {
|
|
4699
|
+
this.shadowModelPaths.clear();
|
|
4700
|
+
}
|
|
4695
4701
|
}
|
|
4696
4702
|
]);
|
|
4697
4703
|
return ValidationMiddleware;
|
|
@@ -5687,6 +5693,47 @@ var Player = function() {
|
|
|
5687
5693
|
/** Return the middleware for the data-model to stop propagation of invalid data */ key: "getDataMiddleware",
|
|
5688
5694
|
value: function getDataMiddleware() {
|
|
5689
5695
|
var _this = this;
|
|
5696
|
+
var validationMiddleware = new ValidationMiddleware(function(binding) {
|
|
5697
|
+
var _strongValidation_get;
|
|
5698
|
+
if (!_this.options) {
|
|
5699
|
+
return;
|
|
5700
|
+
}
|
|
5701
|
+
_this.updateValidationsForBinding(binding, "change", _this.options);
|
|
5702
|
+
var strongValidation = _this.getValidationForBinding(binding);
|
|
5703
|
+
if ((strongValidation === null || strongValidation === void 0 ? void 0 : (_strongValidation_get = strongValidation.get()) === null || _strongValidation_get === void 0 ? void 0 : _strongValidation_get.severity) === "error") {
|
|
5704
|
+
return strongValidation.get();
|
|
5705
|
+
}
|
|
5706
|
+
var newInvalidBindings = /* @__PURE__ */ new Set();
|
|
5707
|
+
_this.validations.forEach(function(weakValidation, strongBinding) {
|
|
5708
|
+
var _weakValidation_get;
|
|
5709
|
+
if (caresAboutDataChanges(/* @__PURE__ */ new Set([
|
|
5710
|
+
binding
|
|
5711
|
+
]), weakValidation.weakBindings) && (weakValidation === null || weakValidation === void 0 ? void 0 : (_weakValidation_get = weakValidation.get()) === null || _weakValidation_get === void 0 ? void 0 : _weakValidation_get.severity) === "error") {
|
|
5712
|
+
weakValidation === null || weakValidation === void 0 ? void 0 : weakValidation.weakBindings.forEach(function(weakBinding) {
|
|
5713
|
+
if (weakBinding === strongBinding) {
|
|
5714
|
+
newInvalidBindings.add({
|
|
5715
|
+
binding: weakBinding,
|
|
5716
|
+
isStrong: true
|
|
5717
|
+
});
|
|
5718
|
+
} else {
|
|
5719
|
+
newInvalidBindings.add({
|
|
5720
|
+
binding: weakBinding,
|
|
5721
|
+
isStrong: false
|
|
5722
|
+
});
|
|
5723
|
+
}
|
|
5724
|
+
});
|
|
5725
|
+
}
|
|
5726
|
+
});
|
|
5727
|
+
if (newInvalidBindings.size > 0) {
|
|
5728
|
+
return newInvalidBindings;
|
|
5729
|
+
}
|
|
5730
|
+
}, {
|
|
5731
|
+
logger: new ProxyLogger(function() {
|
|
5732
|
+
var _this_options;
|
|
5733
|
+
return (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.logger;
|
|
5734
|
+
})
|
|
5735
|
+
});
|
|
5736
|
+
this.validationMiddleware = validationMiddleware;
|
|
5690
5737
|
return [
|
|
5691
5738
|
{
|
|
5692
5739
|
set: function(transaction, options, next) {
|
|
@@ -5701,46 +5748,7 @@ var Player = function() {
|
|
|
5701
5748
|
return next === null || next === void 0 ? void 0 : next.delete(binding, options);
|
|
5702
5749
|
}
|
|
5703
5750
|
},
|
|
5704
|
-
|
|
5705
|
-
var _strongValidation_get;
|
|
5706
|
-
if (!_this.options) {
|
|
5707
|
-
return;
|
|
5708
|
-
}
|
|
5709
|
-
_this.updateValidationsForBinding(binding, "change", _this.options);
|
|
5710
|
-
var strongValidation = _this.getValidationForBinding(binding);
|
|
5711
|
-
if ((strongValidation === null || strongValidation === void 0 ? void 0 : (_strongValidation_get = strongValidation.get()) === null || _strongValidation_get === void 0 ? void 0 : _strongValidation_get.severity) === "error") {
|
|
5712
|
-
return strongValidation.get();
|
|
5713
|
-
}
|
|
5714
|
-
var newInvalidBindings = /* @__PURE__ */ new Set();
|
|
5715
|
-
_this.validations.forEach(function(weakValidation, strongBinding) {
|
|
5716
|
-
var _weakValidation_get;
|
|
5717
|
-
if (caresAboutDataChanges(/* @__PURE__ */ new Set([
|
|
5718
|
-
binding
|
|
5719
|
-
]), weakValidation.weakBindings) && (weakValidation === null || weakValidation === void 0 ? void 0 : (_weakValidation_get = weakValidation.get()) === null || _weakValidation_get === void 0 ? void 0 : _weakValidation_get.severity) === "error") {
|
|
5720
|
-
weakValidation === null || weakValidation === void 0 ? void 0 : weakValidation.weakBindings.forEach(function(weakBinding) {
|
|
5721
|
-
if (weakBinding === strongBinding) {
|
|
5722
|
-
newInvalidBindings.add({
|
|
5723
|
-
binding: weakBinding,
|
|
5724
|
-
isStrong: true
|
|
5725
|
-
});
|
|
5726
|
-
} else {
|
|
5727
|
-
newInvalidBindings.add({
|
|
5728
|
-
binding: weakBinding,
|
|
5729
|
-
isStrong: false
|
|
5730
|
-
});
|
|
5731
|
-
}
|
|
5732
|
-
});
|
|
5733
|
-
}
|
|
5734
|
-
});
|
|
5735
|
-
if (newInvalidBindings.size > 0) {
|
|
5736
|
-
return newInvalidBindings;
|
|
5737
|
-
}
|
|
5738
|
-
}, {
|
|
5739
|
-
logger: new ProxyLogger(function() {
|
|
5740
|
-
var _this_options;
|
|
5741
|
-
return (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.logger;
|
|
5742
|
-
})
|
|
5743
|
-
})
|
|
5751
|
+
validationMiddleware
|
|
5744
5752
|
];
|
|
5745
5753
|
}
|
|
5746
5754
|
},
|
|
@@ -5776,15 +5784,17 @@ var Player = function() {
|
|
|
5776
5784
|
{
|
|
5777
5785
|
key: "reset",
|
|
5778
5786
|
value: function reset() {
|
|
5787
|
+
var _this_validationMiddleware;
|
|
5779
5788
|
this.validations.clear();
|
|
5780
5789
|
this.tracker = void 0;
|
|
5790
|
+
(_this_validationMiddleware = this.validationMiddleware) === null || _this_validationMiddleware === void 0 ? void 0 : _this_validationMiddleware.reset();
|
|
5781
5791
|
}
|
|
5782
5792
|
},
|
|
5783
5793
|
{
|
|
5784
5794
|
key: "onView",
|
|
5785
5795
|
value: function onView(view) {
|
|
5786
5796
|
var _this = this;
|
|
5787
|
-
this.
|
|
5797
|
+
this.reset();
|
|
5788
5798
|
if (!this.options) {
|
|
5789
5799
|
return;
|
|
5790
5800
|
}
|
|
@@ -8495,8 +8505,8 @@ var Player = function() {
|
|
|
8495
8505
|
status: "not-started"
|
|
8496
8506
|
};
|
|
8497
8507
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/player.ts
|
|
8498
|
-
var PLAYER_VERSION = true ? "1.1.0-next.
|
|
8499
|
-
var COMMIT = true ? "
|
|
8508
|
+
var PLAYER_VERSION = true ? "1.1.0-next.3" : "unknown";
|
|
8509
|
+
var COMMIT = true ? "234b74972b29ff0fa11655411dc3cd9d8a98de2a" : "unknown";
|
|
8500
8510
|
var _Player = /*#__PURE__*/ function() {
|
|
8501
8511
|
function _Player(config) {
|
|
8502
8512
|
var _this = this;
|
|
@@ -8518,7 +8528,8 @@ var Player = function() {
|
|
|
8518
8528
|
state: new SyncHook(),
|
|
8519
8529
|
onStart: new SyncHook(),
|
|
8520
8530
|
onEnd: new SyncHook(),
|
|
8521
|
-
resolveFlowContent: new SyncWaterfallHook()
|
|
8531
|
+
resolveFlowContent: new SyncWaterfallHook(),
|
|
8532
|
+
transformContent: new SyncBailHook()
|
|
8522
8533
|
};
|
|
8523
8534
|
if (config === null || config === void 0 ? void 0 : config.logger) {
|
|
8524
8535
|
this.logger.addHandler(config.logger);
|
|
@@ -8532,6 +8543,9 @@ var Player = function() {
|
|
|
8532
8543
|
(_this_config_plugins = this.config.plugins) === null || _this_config_plugins === void 0 ? void 0 : _this_config_plugins.forEach(function(plugin) {
|
|
8533
8544
|
plugin.apply(_this);
|
|
8534
8545
|
});
|
|
8546
|
+
this.hooks.transformContent.tap("player", function(payload, meta) {
|
|
8547
|
+
return meta.format === "player" ? payload : void 0;
|
|
8548
|
+
});
|
|
8535
8549
|
}
|
|
8536
8550
|
_create_class(_Player, [
|
|
8537
8551
|
{
|
|
@@ -8838,14 +8852,22 @@ var Player = function() {
|
|
|
8838
8852
|
},
|
|
8839
8853
|
{
|
|
8840
8854
|
key: "start",
|
|
8841
|
-
value: function start(payload) {
|
|
8855
|
+
value: function start(payload, options) {
|
|
8842
8856
|
return _async_to_generator(function() {
|
|
8843
|
-
var _this,
|
|
8857
|
+
var _this, _options_format, meta, flow, _flow_id, ref, maybeUpdateState, _this_setupFlow, state, start, endProps, _tmp, error, errorState;
|
|
8844
8858
|
return _ts_generator(this, function(_state) {
|
|
8845
8859
|
switch(_state.label){
|
|
8846
8860
|
case 0:
|
|
8847
8861
|
_this = this;
|
|
8848
|
-
|
|
8862
|
+
meta = {
|
|
8863
|
+
format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "player",
|
|
8864
|
+
version: options === null || options === void 0 ? void 0 : options.version
|
|
8865
|
+
};
|
|
8866
|
+
flow = this.hooks.transformContent.call(payload, meta);
|
|
8867
|
+
if (!flow) {
|
|
8868
|
+
throw new Error('Player.start received content with format "'.concat(meta.format, '" that no plugin transformed into a Flow.'));
|
|
8869
|
+
}
|
|
8870
|
+
ref = Symbol((_flow_id = flow.id) !== null && _flow_id !== void 0 ? _flow_id : "payload");
|
|
8849
8871
|
maybeUpdateState = function(newState) {
|
|
8850
8872
|
if (_this.state.ref !== ref) {
|
|
8851
8873
|
_this.logger.warn("Received update for a flow that's not the current one");
|
|
@@ -8866,7 +8888,7 @@ var Player = function() {
|
|
|
8866
8888
|
,
|
|
8867
8889
|
4
|
|
8868
8890
|
]);
|
|
8869
|
-
_this_setupFlow = this.setupFlow(
|
|
8891
|
+
_this_setupFlow = this.setupFlow(flow), state = _this_setupFlow.state, start = _this_setupFlow.start;
|
|
8870
8892
|
this.setState(_object_spread({
|
|
8871
8893
|
ref: ref
|
|
8872
8894
|
}, state));
|
|
@@ -8901,7 +8923,7 @@ var Player = function() {
|
|
|
8901
8923
|
errorState = {
|
|
8902
8924
|
status: "error",
|
|
8903
8925
|
ref: ref,
|
|
8904
|
-
flow:
|
|
8926
|
+
flow: flow,
|
|
8905
8927
|
error: error
|
|
8906
8928
|
};
|
|
8907
8929
|
maybeUpdateState(errorState);
|