@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/index.legacy-esm.js
CHANGED
|
@@ -5641,7 +5641,7 @@ var AssetTransformCorePlugin = class {
|
|
|
5641
5641
|
import { setIn as setIn7 } from "timm";
|
|
5642
5642
|
import deferred from "p-defer";
|
|
5643
5643
|
import queueMicrotask2 from "queue-microtask";
|
|
5644
|
-
import { SyncHook as SyncHook10, SyncWaterfallHook as SyncWaterfallHook11 } from "tapable-ts";
|
|
5644
|
+
import { SyncBailHook as SyncBailHook7, SyncHook as SyncHook10, SyncWaterfallHook as SyncWaterfallHook11 } from "tapable-ts";
|
|
5645
5645
|
|
|
5646
5646
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/plugins/flow-exp-plugin.ts
|
|
5647
5647
|
var FlowExpPlugin = class {
|
|
@@ -5721,8 +5721,8 @@ var NOT_STARTED_STATE = {
|
|
|
5721
5721
|
};
|
|
5722
5722
|
|
|
5723
5723
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/player.ts
|
|
5724
|
-
var PLAYER_VERSION = true ? "1.1.0-next.
|
|
5725
|
-
var COMMIT = true ? "
|
|
5724
|
+
var PLAYER_VERSION = true ? "1.1.0-next.4" : "unknown";
|
|
5725
|
+
var COMMIT = true ? "c00a0bc3257d918e21b7244a770ae462017f0fae" : "unknown";
|
|
5726
5726
|
var _Player = class _Player {
|
|
5727
5727
|
constructor(config) {
|
|
5728
5728
|
this.logger = new TapableLogger();
|
|
@@ -5741,7 +5741,8 @@ var _Player = class _Player {
|
|
|
5741
5741
|
state: new SyncHook10(),
|
|
5742
5742
|
onStart: new SyncHook10(),
|
|
5743
5743
|
onEnd: new SyncHook10(),
|
|
5744
|
-
resolveFlowContent: new SyncWaterfallHook11()
|
|
5744
|
+
resolveFlowContent: new SyncWaterfallHook11(),
|
|
5745
|
+
transformContent: new SyncBailHook7()
|
|
5745
5746
|
};
|
|
5746
5747
|
if (config?.logger) {
|
|
5747
5748
|
this.logger.addHandler(config.logger);
|
|
@@ -5755,6 +5756,10 @@ var _Player = class _Player {
|
|
|
5755
5756
|
this.config.plugins?.forEach((plugin) => {
|
|
5756
5757
|
plugin.apply(this);
|
|
5757
5758
|
});
|
|
5759
|
+
this.hooks.transformContent.tap(
|
|
5760
|
+
"player",
|
|
5761
|
+
(payload, meta) => meta.format === "player" ? payload : void 0
|
|
5762
|
+
);
|
|
5758
5763
|
}
|
|
5759
5764
|
/** Returns currently registered plugins */
|
|
5760
5765
|
getPlugins() {
|
|
@@ -6035,8 +6040,18 @@ var _Player = class _Player {
|
|
|
6035
6040
|
}
|
|
6036
6041
|
};
|
|
6037
6042
|
}
|
|
6038
|
-
async start(payload) {
|
|
6039
|
-
const
|
|
6043
|
+
async start(payload, options) {
|
|
6044
|
+
const meta = {
|
|
6045
|
+
format: options?.format ?? "player",
|
|
6046
|
+
version: options?.version
|
|
6047
|
+
};
|
|
6048
|
+
const flow = this.hooks.transformContent.call(payload, meta);
|
|
6049
|
+
if (!flow) {
|
|
6050
|
+
throw new Error(
|
|
6051
|
+
`Player.start received content with format "${meta.format}" that no plugin transformed into a Flow.`
|
|
6052
|
+
);
|
|
6053
|
+
}
|
|
6054
|
+
const ref = Symbol(flow.id ?? "payload");
|
|
6040
6055
|
const maybeUpdateState = (newState) => {
|
|
6041
6056
|
if (this.state.ref !== ref) {
|
|
6042
6057
|
this.logger.warn(
|
|
@@ -6052,7 +6067,7 @@ var _Player = class _Player {
|
|
|
6052
6067
|
ref
|
|
6053
6068
|
});
|
|
6054
6069
|
try {
|
|
6055
|
-
const { state, start } = this.setupFlow(
|
|
6070
|
+
const { state, start } = this.setupFlow(flow);
|
|
6056
6071
|
this.setState({
|
|
6057
6072
|
ref,
|
|
6058
6073
|
...state
|
|
@@ -6074,7 +6089,7 @@ var _Player = class _Player {
|
|
|
6074
6089
|
const errorState = {
|
|
6075
6090
|
status: "error",
|
|
6076
6091
|
ref,
|
|
6077
|
-
flow
|
|
6092
|
+
flow,
|
|
6078
6093
|
error
|
|
6079
6094
|
};
|
|
6080
6095
|
maybeUpdateState(errorState);
|
package/dist/index.mjs
CHANGED
|
@@ -5641,7 +5641,7 @@ var AssetTransformCorePlugin = class {
|
|
|
5641
5641
|
import { setIn as setIn7 } from "timm";
|
|
5642
5642
|
import deferred from "p-defer";
|
|
5643
5643
|
import queueMicrotask2 from "queue-microtask";
|
|
5644
|
-
import { SyncHook as SyncHook10, SyncWaterfallHook as SyncWaterfallHook11 } from "tapable-ts";
|
|
5644
|
+
import { SyncBailHook as SyncBailHook7, SyncHook as SyncHook10, SyncWaterfallHook as SyncWaterfallHook11 } from "tapable-ts";
|
|
5645
5645
|
|
|
5646
5646
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/plugins/flow-exp-plugin.ts
|
|
5647
5647
|
var FlowExpPlugin = class {
|
|
@@ -5721,8 +5721,8 @@ var NOT_STARTED_STATE = {
|
|
|
5721
5721
|
};
|
|
5722
5722
|
|
|
5723
5723
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/player.ts
|
|
5724
|
-
var PLAYER_VERSION = true ? "1.1.0-next.
|
|
5725
|
-
var COMMIT = true ? "
|
|
5724
|
+
var PLAYER_VERSION = true ? "1.1.0-next.4" : "unknown";
|
|
5725
|
+
var COMMIT = true ? "c00a0bc3257d918e21b7244a770ae462017f0fae" : "unknown";
|
|
5726
5726
|
var _Player = class _Player {
|
|
5727
5727
|
constructor(config) {
|
|
5728
5728
|
this.logger = new TapableLogger();
|
|
@@ -5741,7 +5741,8 @@ var _Player = class _Player {
|
|
|
5741
5741
|
state: new SyncHook10(),
|
|
5742
5742
|
onStart: new SyncHook10(),
|
|
5743
5743
|
onEnd: new SyncHook10(),
|
|
5744
|
-
resolveFlowContent: new SyncWaterfallHook11()
|
|
5744
|
+
resolveFlowContent: new SyncWaterfallHook11(),
|
|
5745
|
+
transformContent: new SyncBailHook7()
|
|
5745
5746
|
};
|
|
5746
5747
|
if (config?.logger) {
|
|
5747
5748
|
this.logger.addHandler(config.logger);
|
|
@@ -5755,6 +5756,10 @@ var _Player = class _Player {
|
|
|
5755
5756
|
this.config.plugins?.forEach((plugin) => {
|
|
5756
5757
|
plugin.apply(this);
|
|
5757
5758
|
});
|
|
5759
|
+
this.hooks.transformContent.tap(
|
|
5760
|
+
"player",
|
|
5761
|
+
(payload, meta) => meta.format === "player" ? payload : void 0
|
|
5762
|
+
);
|
|
5758
5763
|
}
|
|
5759
5764
|
/** Returns currently registered plugins */
|
|
5760
5765
|
getPlugins() {
|
|
@@ -6035,8 +6040,18 @@ var _Player = class _Player {
|
|
|
6035
6040
|
}
|
|
6036
6041
|
};
|
|
6037
6042
|
}
|
|
6038
|
-
async start(payload) {
|
|
6039
|
-
const
|
|
6043
|
+
async start(payload, options) {
|
|
6044
|
+
const meta = {
|
|
6045
|
+
format: options?.format ?? "player",
|
|
6046
|
+
version: options?.version
|
|
6047
|
+
};
|
|
6048
|
+
const flow = this.hooks.transformContent.call(payload, meta);
|
|
6049
|
+
if (!flow) {
|
|
6050
|
+
throw new Error(
|
|
6051
|
+
`Player.start received content with format "${meta.format}" that no plugin transformed into a Flow.`
|
|
6052
|
+
);
|
|
6053
|
+
}
|
|
6054
|
+
const ref = Symbol(flow.id ?? "payload");
|
|
6040
6055
|
const maybeUpdateState = (newState) => {
|
|
6041
6056
|
if (this.state.ref !== ref) {
|
|
6042
6057
|
this.logger.warn(
|
|
@@ -6052,7 +6067,7 @@ var _Player = class _Player {
|
|
|
6052
6067
|
ref
|
|
6053
6068
|
});
|
|
6054
6069
|
try {
|
|
6055
|
-
const { state, start } = this.setupFlow(
|
|
6070
|
+
const { state, start } = this.setupFlow(flow);
|
|
6056
6071
|
this.setState({
|
|
6057
6072
|
ref,
|
|
6058
6073
|
...state
|
|
@@ -6074,7 +6089,7 @@ var _Player = class _Player {
|
|
|
6074
6089
|
const errorState = {
|
|
6075
6090
|
status: "error",
|
|
6076
6091
|
ref,
|
|
6077
|
-
flow
|
|
6092
|
+
flow,
|
|
6078
6093
|
error
|
|
6079
6094
|
};
|
|
6080
6095
|
maybeUpdateState(errorState);
|