@player-ui/external-state-plugin 1.0.0--canary.865.36694
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/ExternalStatePlugin.native.js +756 -0
- package/dist/ExternalStatePlugin.native.js.map +1 -0
- package/dist/cjs/index.cjs +135 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +110 -0
- package/dist/index.mjs +110 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +30 -0
- package/src/__tests__/index.test.ts +538 -0
- package/src/index.ts +176 -0
- package/src/symbols.ts +4 -0
- package/types/index.d.ts +52 -0
- package/types/symbols.d.ts +2 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Player, PlayerPlugin, InProgressState, NavigationFlowExternalState } from "@player-ui/player";
|
|
2
|
+
export type ExternalStateHandlerMatch = Record<string, unknown>;
|
|
3
|
+
export type ExternalStateHandlerFunction = (state: NavigationFlowExternalState, options: InProgressState["controllers"]) => string | undefined | Promise<string | undefined>;
|
|
4
|
+
export type ExternalStateHandler = {
|
|
5
|
+
/** The name of the external state. This will appear as it's "ref" property in the DSL. */
|
|
6
|
+
ref: string;
|
|
7
|
+
/** Additional properties to match against the external state. */
|
|
8
|
+
match?: ExternalStateHandlerMatch;
|
|
9
|
+
/** The function to run when the external state is transitioned to. This should return the `ref` of the next state to transition to. */
|
|
10
|
+
handlerFunction: ExternalStateHandlerFunction;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A plugin to handle external states
|
|
14
|
+
*
|
|
15
|
+
* This plugin uses a registry-based approach to match external states to handler functions.
|
|
16
|
+
* Multiple plugins can be registered, and handlers are matched using partial object matching
|
|
17
|
+
* with specificity ordering (more specific matches take precedence).
|
|
18
|
+
*/
|
|
19
|
+
export declare class ExternalStatePlugin implements PlayerPlugin {
|
|
20
|
+
name: string;
|
|
21
|
+
/** Symbol used to identify and find existing instances of this plugin */
|
|
22
|
+
static Symbol: symbol;
|
|
23
|
+
readonly symbol: symbol;
|
|
24
|
+
/**
|
|
25
|
+
* The shared registry that maps external states to handlers.
|
|
26
|
+
* All plugin instances use the same registry.
|
|
27
|
+
*/
|
|
28
|
+
private registry?;
|
|
29
|
+
/**
|
|
30
|
+
* The handlers for this plugin instance.
|
|
31
|
+
*/
|
|
32
|
+
private readonly handlers;
|
|
33
|
+
/** Creates a new ExternalStatePlugin */
|
|
34
|
+
constructor(handlers: ExternalStateHandler[]);
|
|
35
|
+
apply(player: Player): void;
|
|
36
|
+
/**
|
|
37
|
+
* Create or share the registry for this plugin instance.
|
|
38
|
+
*
|
|
39
|
+
* Uses the Player's plugin registry to find if another instance of ExternalStatePlugin
|
|
40
|
+
* has already been registered. If found, this instance will share that plugin's registry.
|
|
41
|
+
* Otherwise, this instance creates a new registry.
|
|
42
|
+
*/
|
|
43
|
+
private createRegistry;
|
|
44
|
+
/**
|
|
45
|
+
* Register this plugin's handlers to the shared registry.
|
|
46
|
+
*
|
|
47
|
+
* If a handler with the same specificity already exists, it will be replaced
|
|
48
|
+
* and a debug log will be emitted (accessible via player.logger.debug).
|
|
49
|
+
*/
|
|
50
|
+
private registerHandlers;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|