@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/types/types.d.ts
CHANGED
|
@@ -5,8 +5,36 @@ import type { ExpressionEvaluator } from "./expressions";
|
|
|
5
5
|
import type { Logger } from "./logger";
|
|
6
6
|
import type { ViewController, DataController, ValidationController, FlowController, ErrorController } from "./controllers";
|
|
7
7
|
import type { ReadOnlyDataController } from "./controllers/data/utils";
|
|
8
|
-
import { SyncHook, SyncWaterfallHook } from "tapable-ts";
|
|
8
|
+
import { SyncBailHook, SyncHook, SyncWaterfallHook } from "tapable-ts";
|
|
9
9
|
import { ViewInstance } from "./view";
|
|
10
|
+
/**
|
|
11
|
+
* Metadata describing the incoming content to `Player.start()`. Passed
|
|
12
|
+
* alongside the raw payload through the `transformContent` hook so plugins
|
|
13
|
+
* can decide whether to claim/convert it.
|
|
14
|
+
*/
|
|
15
|
+
export interface ContentMeta {
|
|
16
|
+
/**
|
|
17
|
+
* Content format identifier. `"player"` (default) means the input is
|
|
18
|
+
* already a `Flow` and needs no conversion. Anything else is a free-form
|
|
19
|
+
* string a plugin can recognize.
|
|
20
|
+
*/
|
|
21
|
+
format: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional format version (e.g., `"0.9"`). Free-form — plugins decide the
|
|
24
|
+
* convention. Lets a single format plugin dispatch across major/minor
|
|
25
|
+
* versions without the caller picking a different `format` string.
|
|
26
|
+
*/
|
|
27
|
+
version?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Options passed to `Player.start()` alongside the payload.
|
|
31
|
+
*/
|
|
32
|
+
export interface StartOptions {
|
|
33
|
+
/** Identifier of the input content's format. Default: `"player"`. */
|
|
34
|
+
format?: string;
|
|
35
|
+
/** Optional content-format version. See `ContentMeta.version`. */
|
|
36
|
+
version?: string;
|
|
37
|
+
}
|
|
10
38
|
/**
|
|
11
39
|
* Public Player Hooks
|
|
12
40
|
*/
|
|
@@ -39,6 +67,16 @@ export interface PlayerHooks {
|
|
|
39
67
|
resolveFlowContent: SyncWaterfallHook<[
|
|
40
68
|
Flow<Asset<string>>
|
|
41
69
|
], Record<string, any>>;
|
|
70
|
+
/**
|
|
71
|
+
* Transform raw input content into a Player `Flow` before any state is set
|
|
72
|
+
* up. Fires at the top of `Player.start()` — after plugins are applied,
|
|
73
|
+
* before `resolveFlowContent`. Being a bail hook, taps inspect `meta.format`
|
|
74
|
+
* (and optionally `meta.version`) and return a `Flow` to claim the content;
|
|
75
|
+
* returning `undefined` passes to the next tap. Player registers a default
|
|
76
|
+
* tap for the `"player"` format that returns the payload as-is, so the hook
|
|
77
|
+
* is guaranteed to yield a `Flow` and `start()` needs no type-casting.
|
|
78
|
+
*/
|
|
79
|
+
transformContent: SyncBailHook<[unknown, ContentMeta], Flow<Asset<string>>>;
|
|
42
80
|
}
|
|
43
81
|
/** The status for a flow's execution state */
|
|
44
82
|
export type PlayerFlowStatus = "not-started" | "in-progress" | "completed" | "error";
|
|
@@ -32,5 +32,7 @@ export declare class ValidationMiddleware implements DataModelMiddleware {
|
|
|
32
32
|
set(transaction: BatchSetTransaction, options?: DataModelOptions, next?: DataModelImpl): Updates;
|
|
33
33
|
get(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl): any;
|
|
34
34
|
delete(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl): void | undefined;
|
|
35
|
+
/** Clears any invalid values staged in the shadow model */
|
|
36
|
+
reset(): void;
|
|
35
37
|
}
|
|
36
38
|
//# sourceMappingURL=validation-middleware.d.ts.map
|