@player-ui/player 1.1.0-next.2 → 1.1.0-next.4
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 +20 -8
- package/dist/Player.native.js.map +1 -1
- package/dist/cjs/index.cjs +22 -7
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +23 -8
- package/dist/index.mjs +23 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/transform-content.test.ts +131 -0
- package/src/controllers/data/utils.ts +1 -1
- package/src/player.ts +28 -5
- package/src/types.ts +41 -1
- package/types/player.d.ts +2 -3
- package/types/types.d.ts +39 -1
package/dist/Player.native.js
CHANGED
|
@@ -8505,8 +8505,8 @@ var Player = function() {
|
|
|
8505
8505
|
status: "not-started"
|
|
8506
8506
|
};
|
|
8507
8507
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/player.ts
|
|
8508
|
-
var PLAYER_VERSION = true ? "1.1.0-next.
|
|
8509
|
-
var COMMIT = true ? "
|
|
8508
|
+
var PLAYER_VERSION = true ? "1.1.0-next.4" : "unknown";
|
|
8509
|
+
var COMMIT = true ? "c00a0bc3257d918e21b7244a770ae462017f0fae" : "unknown";
|
|
8510
8510
|
var _Player = /*#__PURE__*/ function() {
|
|
8511
8511
|
function _Player(config) {
|
|
8512
8512
|
var _this = this;
|
|
@@ -8528,7 +8528,8 @@ var Player = function() {
|
|
|
8528
8528
|
state: new SyncHook(),
|
|
8529
8529
|
onStart: new SyncHook(),
|
|
8530
8530
|
onEnd: new SyncHook(),
|
|
8531
|
-
resolveFlowContent: new SyncWaterfallHook()
|
|
8531
|
+
resolveFlowContent: new SyncWaterfallHook(),
|
|
8532
|
+
transformContent: new SyncBailHook()
|
|
8532
8533
|
};
|
|
8533
8534
|
if (config === null || config === void 0 ? void 0 : config.logger) {
|
|
8534
8535
|
this.logger.addHandler(config.logger);
|
|
@@ -8542,6 +8543,9 @@ var Player = function() {
|
|
|
8542
8543
|
(_this_config_plugins = this.config.plugins) === null || _this_config_plugins === void 0 ? void 0 : _this_config_plugins.forEach(function(plugin) {
|
|
8543
8544
|
plugin.apply(_this);
|
|
8544
8545
|
});
|
|
8546
|
+
this.hooks.transformContent.tap("player", function(payload, meta) {
|
|
8547
|
+
return meta.format === "player" ? payload : void 0;
|
|
8548
|
+
});
|
|
8545
8549
|
}
|
|
8546
8550
|
_create_class(_Player, [
|
|
8547
8551
|
{
|
|
@@ -8848,14 +8852,22 @@ var Player = function() {
|
|
|
8848
8852
|
},
|
|
8849
8853
|
{
|
|
8850
8854
|
key: "start",
|
|
8851
|
-
value: function start(payload) {
|
|
8855
|
+
value: function start(payload, options) {
|
|
8852
8856
|
return _async_to_generator(function() {
|
|
8853
|
-
var _this,
|
|
8857
|
+
var _this, _options_format, meta, flow, _flow_id, ref, maybeUpdateState, _this_setupFlow, state, start, endProps, _tmp, error, errorState;
|
|
8854
8858
|
return _ts_generator(this, function(_state) {
|
|
8855
8859
|
switch(_state.label){
|
|
8856
8860
|
case 0:
|
|
8857
8861
|
_this = this;
|
|
8858
|
-
|
|
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");
|
|
8859
8871
|
maybeUpdateState = function(newState) {
|
|
8860
8872
|
if (_this.state.ref !== ref) {
|
|
8861
8873
|
_this.logger.warn("Received update for a flow that's not the current one");
|
|
@@ -8876,7 +8888,7 @@ var Player = function() {
|
|
|
8876
8888
|
,
|
|
8877
8889
|
4
|
|
8878
8890
|
]);
|
|
8879
|
-
_this_setupFlow = this.setupFlow(
|
|
8891
|
+
_this_setupFlow = this.setupFlow(flow), state = _this_setupFlow.state, start = _this_setupFlow.start;
|
|
8880
8892
|
this.setState(_object_spread({
|
|
8881
8893
|
ref: ref
|
|
8882
8894
|
}, state));
|
|
@@ -8911,7 +8923,7 @@ var Player = function() {
|
|
|
8911
8923
|
errorState = {
|
|
8912
8924
|
status: "error",
|
|
8913
8925
|
ref: ref,
|
|
8914
|
-
flow:
|
|
8926
|
+
flow: flow,
|
|
8915
8927
|
error: error
|
|
8916
8928
|
};
|
|
8917
8929
|
maybeUpdateState(errorState);
|