@player-ui/player 0.8.0--canary.307.9621 → 0.8.0-next.0
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 +11630 -0
- package/dist/Player.native.js.map +1 -0
- package/dist/cjs/index.cjs +5626 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/{index.esm.js → index.legacy-esm.js} +2044 -1667
- package/dist/{index.cjs.js → index.mjs} +2052 -1761
- package/dist/index.mjs.map +1 -0
- package/package.json +29 -63
- package/src/__tests__/data.test.ts +498 -0
- package/src/__tests__/flow.test.ts +312 -0
- package/src/__tests__/helpers/action-exp.plugin.ts +22 -0
- package/src/__tests__/helpers/actions.flow.ts +67 -0
- package/src/__tests__/helpers/binding.plugin.ts +125 -0
- package/src/__tests__/helpers/expression.plugin.ts +88 -0
- package/src/__tests__/helpers/transform-plugin.ts +19 -0
- package/src/__tests__/helpers/validation.flow.ts +56 -0
- package/src/__tests__/player.test.ts +597 -0
- package/src/__tests__/string-resolver.test.ts +186 -0
- package/src/__tests__/validation.test.ts +3555 -0
- package/src/__tests__/view.test.ts +715 -0
- package/src/binding/__tests__/binding.test.ts +113 -0
- package/src/binding/__tests__/index.test.ts +208 -0
- package/src/binding/__tests__/resolver.test.ts +83 -0
- package/src/binding/binding.ts +6 -6
- package/src/binding/index.ts +34 -34
- package/src/binding/resolver.ts +19 -19
- package/src/binding/utils.ts +7 -7
- package/src/binding-grammar/__tests__/parser.test.ts +64 -0
- package/src/binding-grammar/__tests__/test-utils/ast-cases.ts +198 -0
- package/src/binding-grammar/__tests__/test-utils/perf-test.ts +66 -0
- package/src/binding-grammar/ast.ts +11 -11
- package/src/binding-grammar/custom/index.ts +19 -22
- package/src/binding-grammar/ebnf/index.ts +20 -21
- package/src/binding-grammar/ebnf/types.ts +13 -13
- package/src/binding-grammar/index.ts +4 -4
- package/src/binding-grammar/parsimmon/index.ts +14 -14
- package/src/controllers/constants/__tests__/index.test.ts +106 -0
- package/src/controllers/constants/index.ts +3 -3
- package/src/controllers/constants/utils.ts +4 -4
- package/src/controllers/data/controller.ts +22 -22
- package/src/controllers/data/index.ts +1 -1
- package/src/controllers/data/utils.ts +7 -7
- package/src/controllers/flow/__tests__/controller.test.ts +195 -0
- package/src/controllers/flow/__tests__/flow.test.ts +381 -0
- package/src/controllers/flow/controller.ts +13 -13
- package/src/controllers/flow/flow.ts +23 -23
- package/src/controllers/flow/index.ts +2 -2
- package/src/controllers/index.ts +5 -5
- package/src/controllers/validation/binding-tracker.ts +71 -59
- package/src/controllers/validation/controller.ts +104 -104
- package/src/controllers/validation/index.ts +2 -2
- package/src/controllers/view/asset-transform.ts +20 -20
- package/src/controllers/view/controller.ts +27 -27
- package/src/controllers/view/index.ts +4 -4
- package/src/controllers/view/store.ts +3 -3
- package/src/controllers/view/types.ts +7 -7
- package/src/data/__tests__/__snapshots__/dependency-tracker.test.ts.snap +64 -0
- package/src/data/__tests__/dependency-tracker.test.ts +146 -0
- package/src/data/__tests__/local-model.test.ts +46 -0
- package/src/data/__tests__/model.test.ts +78 -0
- package/src/data/dependency-tracker.ts +16 -16
- package/src/data/index.ts +4 -4
- package/src/data/local-model.ts +6 -6
- package/src/data/model.ts +17 -17
- package/src/data/noop-model.ts +1 -1
- package/src/expressions/__tests__/__snapshots__/parser.test.ts.snap +854 -0
- package/src/expressions/__tests__/evaluator-functions.test.ts +47 -0
- package/src/expressions/__tests__/evaluator.test.ts +410 -0
- package/src/expressions/__tests__/parser.test.ts +115 -0
- package/src/expressions/__tests__/utils.test.ts +44 -0
- package/src/expressions/evaluator-functions.ts +6 -6
- package/src/expressions/evaluator.ts +71 -67
- package/src/expressions/index.ts +4 -4
- package/src/expressions/parser.ts +102 -105
- package/src/expressions/types.ts +29 -21
- package/src/expressions/utils.ts +32 -21
- package/src/index.ts +13 -13
- package/src/logger/__tests__/consoleLogger.test.ts +46 -0
- package/src/logger/__tests__/noopLogger.test.ts +13 -0
- package/src/logger/__tests__/proxyLogger.test.ts +31 -0
- package/src/logger/__tests__/tapableLogger.test.ts +41 -0
- package/src/logger/consoleLogger.ts +9 -9
- package/src/logger/index.ts +5 -5
- package/src/logger/noopLogger.ts +1 -1
- package/src/logger/proxyLogger.ts +6 -6
- package/src/logger/tapableLogger.ts +7 -7
- package/src/logger/types.ts +2 -2
- package/src/player.ts +60 -58
- package/src/plugins/default-exp-plugin.ts +10 -10
- package/src/plugins/default-view-plugin.ts +29 -0
- package/src/plugins/flow-exp-plugin.ts +6 -6
- package/src/schema/__tests__/schema.test.ts +243 -0
- package/src/schema/index.ts +2 -2
- package/src/schema/schema.ts +24 -24
- package/src/schema/types.ts +4 -4
- package/src/string-resolver/__tests__/index.test.ts +361 -0
- package/src/string-resolver/index.ts +17 -17
- package/src/types.ts +17 -17
- package/src/utils/__tests__/replaceParams.test.ts +33 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/replaceParams.ts +1 -1
- package/src/validator/__tests__/binding-map-splice.test.ts +53 -0
- package/src/validator/__tests__/validation-middleware.test.ts +127 -0
- package/src/validator/binding-map-splice.ts +5 -5
- package/src/validator/index.ts +4 -4
- package/src/validator/registry.ts +1 -1
- package/src/validator/types.ts +13 -13
- package/src/validator/validation-middleware.ts +15 -15
- package/src/view/__tests__/view.immutable.test.ts +269 -0
- package/src/view/__tests__/view.test.ts +959 -0
- package/src/view/builder/index.test.ts +69 -0
- package/src/view/builder/index.ts +3 -3
- package/src/view/index.ts +5 -5
- package/src/view/parser/__tests__/__snapshots__/parser.test.ts.snap +394 -0
- package/src/view/parser/__tests__/parser.test.ts +264 -0
- package/src/view/parser/index.ts +43 -33
- package/src/view/parser/types.ts +11 -11
- package/src/view/parser/utils.ts +5 -5
- package/src/view/plugins/__tests__/__snapshots__/template.test.ts.snap +278 -0
- package/src/view/plugins/__tests__/applicability.test.ts +265 -0
- package/src/view/plugins/__tests__/string.test.ts +122 -0
- package/src/view/plugins/__tests__/template.test.ts +724 -0
- package/src/view/plugins/applicability.ts +19 -19
- package/src/view/plugins/index.ts +4 -5
- package/src/view/plugins/options.ts +1 -1
- package/src/view/plugins/string-resolver.ts +22 -22
- package/src/view/plugins/switch.ts +22 -23
- package/src/view/plugins/template-plugin.ts +26 -27
- package/src/view/resolver/__tests__/dependencies.test.ts +321 -0
- package/src/view/resolver/__tests__/edgecases.test.ts +626 -0
- package/src/view/resolver/index.ts +42 -42
- package/src/view/resolver/types.ts +21 -20
- package/src/view/resolver/utils.ts +9 -9
- package/src/view/view.ts +32 -22
- package/types/binding/binding.d.ts +50 -0
- package/types/binding/index.d.ts +29 -0
- package/types/binding/resolver.d.ts +26 -0
- package/types/binding/utils.d.ts +12 -0
- package/types/binding-grammar/ast.d.ts +67 -0
- package/types/binding-grammar/custom/index.d.ts +4 -0
- package/types/binding-grammar/ebnf/index.d.ts +4 -0
- package/types/binding-grammar/ebnf/types.d.ts +75 -0
- package/types/binding-grammar/index.d.ts +5 -0
- package/types/binding-grammar/parsimmon/index.d.ts +4 -0
- package/types/controllers/constants/index.d.ts +45 -0
- package/types/controllers/constants/utils.d.ts +6 -0
- package/types/controllers/data/controller.d.ts +45 -0
- package/types/controllers/data/index.d.ts +2 -0
- package/types/controllers/data/utils.d.ts +14 -0
- package/types/controllers/flow/controller.d.ts +25 -0
- package/types/controllers/flow/flow.d.ts +50 -0
- package/types/controllers/flow/index.d.ts +3 -0
- package/types/controllers/index.d.ts +6 -0
- package/types/controllers/validation/binding-tracker.d.ts +32 -0
- package/types/controllers/validation/controller.d.ts +151 -0
- package/types/controllers/validation/index.d.ts +3 -0
- package/types/controllers/view/asset-transform.d.ts +19 -0
- package/types/controllers/view/controller.d.ts +37 -0
- package/types/controllers/view/index.d.ts +5 -0
- package/types/controllers/view/store.d.ts +20 -0
- package/types/controllers/view/types.d.ts +16 -0
- package/types/data/dependency-tracker.d.ts +49 -0
- package/types/data/index.d.ts +5 -0
- package/types/data/local-model.d.ts +16 -0
- package/types/data/model.d.ts +86 -0
- package/types/data/noop-model.d.ts +13 -0
- package/types/expressions/evaluator-functions.d.ts +15 -0
- package/types/expressions/evaluator.d.ts +52 -0
- package/types/expressions/index.d.ts +5 -0
- package/types/expressions/parser.d.ts +10 -0
- package/types/expressions/types.d.ts +144 -0
- package/types/expressions/utils.d.ts +12 -0
- package/types/index.d.ts +14 -0
- package/types/logger/consoleLogger.d.ts +17 -0
- package/types/logger/index.d.ts +6 -0
- package/types/logger/noopLogger.d.ts +10 -0
- package/types/logger/proxyLogger.d.ts +15 -0
- package/types/logger/tapableLogger.d.ts +23 -0
- package/types/logger/types.d.ts +6 -0
- package/types/player.d.ts +101 -0
- package/types/plugins/default-exp-plugin.d.ts +9 -0
- package/types/plugins/default-view-plugin.d.ts +9 -0
- package/types/plugins/flow-exp-plugin.d.ts +11 -0
- package/types/schema/index.d.ts +3 -0
- package/types/schema/schema.d.ts +36 -0
- package/types/schema/types.d.ts +38 -0
- package/types/string-resolver/index.d.ts +30 -0
- package/types/types.d.ts +73 -0
- package/types/utils/index.d.ts +2 -0
- package/types/utils/replaceParams.d.ts +9 -0
- package/types/validator/binding-map-splice.d.ts +10 -0
- package/types/validator/index.d.ts +5 -0
- package/types/validator/registry.d.ts +11 -0
- package/types/validator/types.d.ts +53 -0
- package/types/validator/validation-middleware.d.ts +36 -0
- package/types/view/builder/index.d.ts +35 -0
- package/types/view/index.d.ts +6 -0
- package/types/view/parser/index.d.ts +52 -0
- package/types/view/parser/types.d.ts +109 -0
- package/types/view/parser/utils.d.ts +6 -0
- package/types/view/plugins/applicability.d.ts +10 -0
- package/types/view/plugins/index.d.ts +5 -0
- package/types/view/plugins/options.d.ts +4 -0
- package/types/view/plugins/string-resolver.d.ts +13 -0
- package/types/view/plugins/switch.d.ts +14 -0
- package/types/view/plugins/template-plugin.d.ts +33 -0
- package/types/view/resolver/index.d.ts +73 -0
- package/types/view/resolver/types.d.ts +129 -0
- package/types/view/resolver/utils.d.ts +11 -0
- package/types/view/view.d.ts +37 -0
- package/dist/index.d.ts +0 -1814
- package/dist/player.dev.js +0 -11472
- package/dist/player.prod.js +0 -2
- package/src/view/plugins/plugin.ts +0 -21
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Asset } from "@player-ui/types";
|
|
2
|
+
import type { Registry } from "@player-ui/partial-match-registry";
|
|
3
|
+
import type { Resolve, Node } from "../../view";
|
|
4
|
+
import type { Store } from "./store";
|
|
5
|
+
/** Transform function that is ran on the Asset before it's resolved */
|
|
6
|
+
export type BeforeTransformFunction<AuthoredAsset extends Asset = Asset> = (asset: Node.Asset<AuthoredAsset> | Node.View<AuthoredAsset>, options: Resolve.NodeResolveOptions, store: Store) => Node.Node;
|
|
7
|
+
/** Transform function that is ran on the Asset after it's resolved */
|
|
8
|
+
export type TransformFunction<AuthoredAsset extends Asset = Asset, TransformedAsset extends Asset = AuthoredAsset> = (asset: AuthoredAsset, options: Resolve.NodeResolveOptions, store: Store) => TransformedAsset;
|
|
9
|
+
export interface TransformFunctions {
|
|
10
|
+
/** A function that is executed as an AST -> AST transform before resolving the node to a value */
|
|
11
|
+
beforeResolve?: BeforeTransformFunction<any>;
|
|
12
|
+
/** A function to resolve an AST to a value */
|
|
13
|
+
resolve?: TransformFunction<any>;
|
|
14
|
+
}
|
|
15
|
+
export type TransformRegistry = Registry<TransformFunctions>;
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { BindingInstance } from "../binding";
|
|
2
|
+
import type { BatchSetTransaction, DataModelImpl, DataModelMiddleware, DataModelOptions, Updates } from "./model";
|
|
3
|
+
export type DependencySets = "core" | "children";
|
|
4
|
+
/** A class to track usage of read/writes to/from a data model */
|
|
5
|
+
export declare class DependencyTracker {
|
|
6
|
+
protected readDeps: Set<BindingInstance>;
|
|
7
|
+
protected writeDeps: Set<BindingInstance>;
|
|
8
|
+
protected namedSet: DependencySets;
|
|
9
|
+
private namedDependencySets;
|
|
10
|
+
constructor();
|
|
11
|
+
protected createSubset(name: DependencySets, force?: boolean): void;
|
|
12
|
+
/** Grab all of the bindings that this depended on */
|
|
13
|
+
getDependencies(name?: DependencySets): Set<BindingInstance>;
|
|
14
|
+
trackSubset(name: DependencySets): void;
|
|
15
|
+
trackDefault(): void;
|
|
16
|
+
/** Grab all of the bindings this wrote to */
|
|
17
|
+
getModified(name?: DependencySets): Set<BindingInstance>;
|
|
18
|
+
/**
|
|
19
|
+
* Check to see if the dataModel has read the value at the given binding
|
|
20
|
+
*
|
|
21
|
+
* @param binding - The binding you want to check for
|
|
22
|
+
*/
|
|
23
|
+
readsBinding(binding: BindingInstance): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Check to see if the dataModel has written to the binding
|
|
26
|
+
*/
|
|
27
|
+
writesBinding(binding: BindingInstance): boolean;
|
|
28
|
+
/** Reset all tracking of dependencies */
|
|
29
|
+
reset(): void;
|
|
30
|
+
protected addReadDep(binding: BindingInstance, namedSet?: DependencySets): void;
|
|
31
|
+
protected addWriteDep(binding: BindingInstance, namedSet?: DependencySets): void;
|
|
32
|
+
addChildReadDep(binding: BindingInstance): void;
|
|
33
|
+
}
|
|
34
|
+
/** Middleware that tracks dependencies of read/written data */
|
|
35
|
+
export declare class DependencyMiddleware extends DependencyTracker implements DataModelMiddleware {
|
|
36
|
+
constructor();
|
|
37
|
+
set(transaction: BatchSetTransaction, options?: DataModelOptions, next?: DataModelImpl | undefined): Updates;
|
|
38
|
+
get(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl | undefined): any;
|
|
39
|
+
delete(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl | undefined): void | undefined;
|
|
40
|
+
}
|
|
41
|
+
/** A data-model that tracks dependencies of read/written data */
|
|
42
|
+
export declare class DependencyModel<Options = DataModelOptions> extends DependencyTracker implements DataModelImpl<Options> {
|
|
43
|
+
private readonly rootModel;
|
|
44
|
+
constructor(rootModel: DataModelImpl<Options>);
|
|
45
|
+
set(transaction: BatchSetTransaction, options?: Options): Updates;
|
|
46
|
+
get(binding: BindingInstance, options?: Options): any;
|
|
47
|
+
delete(binding: BindingInstance, options?: Options): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=dependency-tracker.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BindingInstance } from "../binding";
|
|
2
|
+
import type { BatchSetTransaction, DataModelImpl, Updates } from "./model";
|
|
3
|
+
/**
|
|
4
|
+
* A data model that stores data in an in-memory JS object
|
|
5
|
+
*/
|
|
6
|
+
export declare class LocalModel implements DataModelImpl {
|
|
7
|
+
model: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
constructor(model?: {});
|
|
11
|
+
reset(model?: {}): void;
|
|
12
|
+
get(binding?: BindingInstance): any;
|
|
13
|
+
set(transaction: BatchSetTransaction): Updates;
|
|
14
|
+
delete(binding: BindingInstance): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=local-model.d.ts.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { SyncHook } from "tapable-ts";
|
|
2
|
+
import type { BindingLike, BindingFactory } from "../binding";
|
|
3
|
+
import { BindingInstance } from "../binding";
|
|
4
|
+
export declare const ROOT_BINDING: BindingInstance;
|
|
5
|
+
export type BatchSetTransaction = [BindingInstance, any][];
|
|
6
|
+
export type Updates = Array<{
|
|
7
|
+
/** The updated binding */
|
|
8
|
+
binding: BindingInstance;
|
|
9
|
+
/** The old value */
|
|
10
|
+
oldValue: any;
|
|
11
|
+
/** The new value */
|
|
12
|
+
newValue: any;
|
|
13
|
+
/** Force the Update to be included even if no data changed */
|
|
14
|
+
force?: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
/** Options to use when getting or setting data */
|
|
17
|
+
export interface DataModelOptions {
|
|
18
|
+
/**
|
|
19
|
+
* The data (either to set or get) should represent a formatted value
|
|
20
|
+
* For setting data, the data will be de-formatted before continuing in the pipeline
|
|
21
|
+
* For getting data, the data will be formatted before returning
|
|
22
|
+
*/
|
|
23
|
+
formatted?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* By default, fetching data will ignore any invalid data.
|
|
26
|
+
* You can choose to grab the queued invalid data if you'd like
|
|
27
|
+
* This is usually the case for user-inputs
|
|
28
|
+
*/
|
|
29
|
+
includeInvalid?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* A flag to set to ignore any default value in the schema, and just use the raw value
|
|
32
|
+
*/
|
|
33
|
+
ignoreDefaultValue?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* A flag to indicate that this update should happen silently
|
|
36
|
+
*/
|
|
37
|
+
silent?: boolean;
|
|
38
|
+
/** Other context associated with this request */
|
|
39
|
+
context?: {
|
|
40
|
+
/** The data model to use when getting other data from the context of this request */
|
|
41
|
+
model: DataModelWithParser;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export interface DataModelWithParser<Options = DataModelOptions> {
|
|
45
|
+
get(binding: BindingLike, options?: Options): any;
|
|
46
|
+
set(transaction: [BindingLike, any][], options?: Options): Updates;
|
|
47
|
+
delete(binding: BindingLike, options?: Options): void;
|
|
48
|
+
}
|
|
49
|
+
export interface DataModelImpl<Options = DataModelOptions> {
|
|
50
|
+
get(binding: BindingInstance, options?: Options): any;
|
|
51
|
+
set(transaction: BatchSetTransaction, options?: Options): Updates;
|
|
52
|
+
delete(binding: BindingInstance, options?: Options): void;
|
|
53
|
+
}
|
|
54
|
+
export interface DataModelMiddleware {
|
|
55
|
+
/** The name of the middleware */
|
|
56
|
+
name?: string;
|
|
57
|
+
set(transaction: BatchSetTransaction, options?: DataModelOptions, next?: DataModelImpl): Updates;
|
|
58
|
+
get(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl): any;
|
|
59
|
+
delete?(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl): void;
|
|
60
|
+
reset?(): void;
|
|
61
|
+
}
|
|
62
|
+
/** Wrap the inputs of the DataModel with calls to parse raw binding inputs */
|
|
63
|
+
export declare function withParser<Options = unknown>(model: DataModelImpl<Options>, parseBinding: BindingFactory): DataModelWithParser<Options>;
|
|
64
|
+
/** Wrap a middleware instance in a DataModel compliant API */
|
|
65
|
+
export declare function toModel(middleware: DataModelMiddleware, defaultOptions?: DataModelOptions, next?: DataModelImpl): DataModelImpl;
|
|
66
|
+
export type DataPipeline = Array<DataModelMiddleware | DataModelImpl>;
|
|
67
|
+
/**
|
|
68
|
+
* Given a set of steps in a pipeline, create the effective data-model
|
|
69
|
+
*/
|
|
70
|
+
export declare function constructModelForPipeline(pipeline: DataPipeline): DataModelImpl;
|
|
71
|
+
/** A DataModel that manages middleware data handlers */
|
|
72
|
+
export declare class PipelinedDataModel implements DataModelImpl {
|
|
73
|
+
private pipeline;
|
|
74
|
+
private effectiveDataModel;
|
|
75
|
+
readonly hooks: {
|
|
76
|
+
onSet: SyncHook<[BatchSetTransaction], Record<string, any>>;
|
|
77
|
+
};
|
|
78
|
+
constructor(pipeline?: DataPipeline);
|
|
79
|
+
setMiddleware(handlers: DataPipeline): void;
|
|
80
|
+
addMiddleware(handler: DataModelMiddleware): void;
|
|
81
|
+
reset(model?: {}): void;
|
|
82
|
+
set(transaction: BatchSetTransaction, options?: DataModelOptions): Updates;
|
|
83
|
+
get(binding: BindingInstance, options?: DataModelOptions): any;
|
|
84
|
+
delete(binding: BindingInstance, options?: DataModelOptions): void;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DataModelImpl } from "./model";
|
|
2
|
+
/**
|
|
3
|
+
* A model that does nothing
|
|
4
|
+
* Helpful for testing and other default DataModel applications
|
|
5
|
+
*/
|
|
6
|
+
export declare class NOOPDataModel implements DataModelImpl {
|
|
7
|
+
get(): undefined;
|
|
8
|
+
set(): never[];
|
|
9
|
+
delete(): void;
|
|
10
|
+
}
|
|
11
|
+
/** You only really need 1 instance of the NOOP model */
|
|
12
|
+
export declare const NOOP_MODEL: NOOPDataModel;
|
|
13
|
+
//# sourceMappingURL=noop-model.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Binding } from "@player-ui/types";
|
|
2
|
+
import type { ExpressionHandler, ExpressionNode } from "./types";
|
|
3
|
+
/** Sets a value to the data-model */
|
|
4
|
+
export declare const setDataVal: ExpressionHandler<[Binding, any], any>;
|
|
5
|
+
/** Fetches a valid from the data-model */
|
|
6
|
+
export declare const getDataVal: ExpressionHandler<[Binding], unknown>;
|
|
7
|
+
/** Deletes a value from the model */
|
|
8
|
+
export declare const deleteDataVal: ExpressionHandler<[Binding], void>;
|
|
9
|
+
/** Conditional expression handler */
|
|
10
|
+
export declare const conditional: ExpressionHandler<[
|
|
11
|
+
ExpressionNode,
|
|
12
|
+
ExpressionNode,
|
|
13
|
+
ExpressionNode?
|
|
14
|
+
]>;
|
|
15
|
+
//# sourceMappingURL=evaluator-functions.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SyncWaterfallHook, SyncBailHook } from "tapable-ts";
|
|
2
|
+
import type { ExpressionNode, BinaryOperator, UnaryOperator, ExpressionType, ExpressionContext, ExpressionHandler } from "./types";
|
|
3
|
+
export interface HookOptions extends ExpressionContext {
|
|
4
|
+
/** Given an expression node */
|
|
5
|
+
resolveNode: (node: ExpressionNode) => any;
|
|
6
|
+
/** Enabling this flag skips calling the onError hook, and just throws errors back to the caller.
|
|
7
|
+
* The caller is responsible for handling the error.
|
|
8
|
+
*/
|
|
9
|
+
throwErrors?: boolean;
|
|
10
|
+
/** Whether expressions should be parsed strictly or not */
|
|
11
|
+
strict?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export type ExpressionEvaluatorOptions = Omit<HookOptions, "resolveNode" | "evaluate">;
|
|
14
|
+
export type ExpressionEvaluatorFunction = (exp: ExpressionType, options?: ExpressionEvaluatorOptions) => any;
|
|
15
|
+
/**
|
|
16
|
+
* The expression evaluator is responsible for parsing and executing anything in the custom expression language
|
|
17
|
+
* */
|
|
18
|
+
export declare class ExpressionEvaluator {
|
|
19
|
+
private readonly vars;
|
|
20
|
+
readonly hooks: {
|
|
21
|
+
/** Resolve an AST node for an expression to a value */
|
|
22
|
+
resolve: SyncWaterfallHook<[any, ExpressionNode, HookOptions], Record<string, any>>;
|
|
23
|
+
/** Gets the options that will be passed in calls to the resolve hook */
|
|
24
|
+
resolveOptions: SyncWaterfallHook<[HookOptions], Record<string, any>>;
|
|
25
|
+
/** Allows users to change the expression to be evaluated before processing */
|
|
26
|
+
beforeEvaluate: SyncWaterfallHook<[ExpressionType, HookOptions], Record<string, any>>;
|
|
27
|
+
/**
|
|
28
|
+
* An optional means of handling an error in the expression execution
|
|
29
|
+
* Return true if handled, to stop propagation of the error
|
|
30
|
+
*/
|
|
31
|
+
onError: SyncBailHook<[Error], true, Record<string, any>>;
|
|
32
|
+
};
|
|
33
|
+
private readonly expressionsCache;
|
|
34
|
+
private readonly defaultHookOptions;
|
|
35
|
+
readonly operators: {
|
|
36
|
+
binary: Map<string, BinaryOperator>;
|
|
37
|
+
unary: Map<string, UnaryOperator>;
|
|
38
|
+
expressions: Map<string, ExpressionHandler<any, any>>;
|
|
39
|
+
};
|
|
40
|
+
reset(): void;
|
|
41
|
+
constructor(defaultOptions: ExpressionEvaluatorOptions);
|
|
42
|
+
evaluate(expr: ExpressionType, options?: ExpressionEvaluatorOptions): any;
|
|
43
|
+
addExpressionFunction<T extends readonly unknown[], R>(name: string, handler: ExpressionHandler<T, R>): void;
|
|
44
|
+
addBinaryOperator(operator: string, handler: BinaryOperator): void;
|
|
45
|
+
addUnaryOperator(operator: string, handler: UnaryOperator): void;
|
|
46
|
+
setExpressionVariable(name: string, value: unknown): void;
|
|
47
|
+
getExpressionVariable(name: string): unknown;
|
|
48
|
+
private _execAST;
|
|
49
|
+
private _execString;
|
|
50
|
+
private _resolveNode;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=evaluator.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An expression to AST parser based on JSEP: http://jsep.from.so/
|
|
3
|
+
*/
|
|
4
|
+
import type { ExpressionNode } from "./types";
|
|
5
|
+
/** Parse out an expression from the string */
|
|
6
|
+
export declare function parseExpression(expr: string, options?: {
|
|
7
|
+
/** If true (the default), will throw on invalid expressions */
|
|
8
|
+
strict?: boolean;
|
|
9
|
+
}): ExpressionNode;
|
|
10
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { DataModelWithParser } from "../data";
|
|
2
|
+
import type { Logger } from "../logger";
|
|
3
|
+
export type ExpressionObjectType = {
|
|
4
|
+
/** The expression to eval */
|
|
5
|
+
value: BasicExpressionTypes;
|
|
6
|
+
};
|
|
7
|
+
export type ExpressionLiteralType = string | number | boolean | undefined | null;
|
|
8
|
+
export type BasicExpressionTypes = ExpressionLiteralType | ExpressionObjectType | Array<ExpressionLiteralType | ExpressionObjectType>;
|
|
9
|
+
export type ExpressionType = BasicExpressionTypes | ExpressionNode;
|
|
10
|
+
export interface OperatorProcessingOptions {
|
|
11
|
+
/**
|
|
12
|
+
* When set to a falsy value, the arguments passed to the handler will be raw AST Nodes
|
|
13
|
+
* This enables lazy evaluation of arguments
|
|
14
|
+
*/
|
|
15
|
+
resolveParams: boolean;
|
|
16
|
+
}
|
|
17
|
+
export type BinaryOperatorBasic = (left: any, right: any) => unknown;
|
|
18
|
+
export type BinaryOperatorAdvanced = OperatorProcessingOptions & ((ctx: ExpressionContext, left: any, right: any) => unknown);
|
|
19
|
+
export type BinaryOperator = BinaryOperatorAdvanced | BinaryOperatorBasic;
|
|
20
|
+
export type UnaryOperator = ((arg: any) => unknown) | (((ctx: ExpressionContext, arg: any) => unknown) & OperatorProcessingOptions);
|
|
21
|
+
export interface ExpressionContext {
|
|
22
|
+
/** A means of executing an expression */
|
|
23
|
+
evaluate: (expr: ExpressionType) => unknown;
|
|
24
|
+
/** The data model that expression handlers can use when fetching data */
|
|
25
|
+
model: DataModelWithParser;
|
|
26
|
+
/** A logger to use */
|
|
27
|
+
logger?: Logger;
|
|
28
|
+
}
|
|
29
|
+
export type ExpressionHandler<T extends readonly unknown[] = unknown[], R = void> = ((context: ExpressionContext, ...args: T) => R) & Partial<OperatorProcessingOptions>;
|
|
30
|
+
export declare const ExpNodeOpaqueIdentifier: unique symbol;
|
|
31
|
+
/** Checks if the input is an already processed Expression node */
|
|
32
|
+
export declare function isExpressionNode(x: any): x is ExpressionNode;
|
|
33
|
+
export interface NodePosition {
|
|
34
|
+
/** The character location */
|
|
35
|
+
character: number;
|
|
36
|
+
}
|
|
37
|
+
export interface NodeLocation {
|
|
38
|
+
/** The start of the node */
|
|
39
|
+
start: NodePosition;
|
|
40
|
+
/** The end of the node */
|
|
41
|
+
end: NodePosition;
|
|
42
|
+
}
|
|
43
|
+
export interface BaseNode<T> {
|
|
44
|
+
/** The thing to discriminate the AST type on */
|
|
45
|
+
type: T;
|
|
46
|
+
/** How to tell this apart from other objects */
|
|
47
|
+
__id: typeof ExpNodeOpaqueIdentifier;
|
|
48
|
+
/** The location of the node in the source expression string */
|
|
49
|
+
location?: NodeLocation;
|
|
50
|
+
/**
|
|
51
|
+
* The error that occurred while parsing this node
|
|
52
|
+
* This is only set if the parsing mode is set to non-strict
|
|
53
|
+
*/
|
|
54
|
+
error?: Error;
|
|
55
|
+
}
|
|
56
|
+
/** A helper interface for nodes that container left and right children */
|
|
57
|
+
export interface DirectionalNode {
|
|
58
|
+
/** The left node. Often for the left hand side of an expression */
|
|
59
|
+
left: ExpressionNode;
|
|
60
|
+
/** The right child. Often for the right hand side of an expression */
|
|
61
|
+
right: ExpressionNode;
|
|
62
|
+
}
|
|
63
|
+
export interface LiteralNode extends BaseNode<"Literal"> {
|
|
64
|
+
/** A node that holds a literal value */
|
|
65
|
+
value: string | number;
|
|
66
|
+
/** The unprocessed value */
|
|
67
|
+
raw?: any;
|
|
68
|
+
}
|
|
69
|
+
export interface BinaryNode extends BaseNode<"BinaryExpression">, DirectionalNode {
|
|
70
|
+
/** The operation to perform on the nodes */
|
|
71
|
+
operator: string;
|
|
72
|
+
}
|
|
73
|
+
export interface LogicalNode extends BaseNode<"LogicalExpression">, DirectionalNode {
|
|
74
|
+
/** The logical operation to perform on the nodes */
|
|
75
|
+
operator: string;
|
|
76
|
+
}
|
|
77
|
+
export interface UnaryNode extends BaseNode<"UnaryExpression"> {
|
|
78
|
+
/** The operation to perform on the node */
|
|
79
|
+
operator: string;
|
|
80
|
+
/** The single argument that the operation should be performed on */
|
|
81
|
+
argument: ExpressionNode;
|
|
82
|
+
}
|
|
83
|
+
export type ThisNode = BaseNode<"ThisExpression">;
|
|
84
|
+
export interface ModelRefNode extends BaseNode<"ModelRef"> {
|
|
85
|
+
/** The binding that the model reference points to */
|
|
86
|
+
ref: string;
|
|
87
|
+
}
|
|
88
|
+
export interface ObjectNode extends BaseNode<"Object"> {
|
|
89
|
+
/** */
|
|
90
|
+
attributes: Array<{
|
|
91
|
+
/** The property name of the object */
|
|
92
|
+
key: ExpressionNode;
|
|
93
|
+
/** the associated value */
|
|
94
|
+
value: ExpressionNode;
|
|
95
|
+
}>;
|
|
96
|
+
}
|
|
97
|
+
export interface MemberExpressionNode extends BaseNode<"MemberExpression"> {
|
|
98
|
+
/** The object to be introspected */
|
|
99
|
+
object: ExpressionNode;
|
|
100
|
+
/** If the property uses . or open-bracket */
|
|
101
|
+
computed: boolean;
|
|
102
|
+
/** The property to access on the object */
|
|
103
|
+
property: ExpressionNode;
|
|
104
|
+
}
|
|
105
|
+
export interface ConditionalExpressionNode extends BaseNode<"ConditionalExpression"> {
|
|
106
|
+
/** The test for the ternary */
|
|
107
|
+
test: ExpressionNode;
|
|
108
|
+
/** The truthy case for the ternary */
|
|
109
|
+
consequent: ExpressionNode;
|
|
110
|
+
/** The falsy case for the ternary */
|
|
111
|
+
alternate: ExpressionNode;
|
|
112
|
+
}
|
|
113
|
+
export interface CompoundNode extends BaseNode<"Compound"> {
|
|
114
|
+
/** The contents of the compound expression */
|
|
115
|
+
body: ExpressionNode[];
|
|
116
|
+
}
|
|
117
|
+
export interface CallExpressionNode extends BaseNode<"CallExpression"> {
|
|
118
|
+
/** The arguments to the function */
|
|
119
|
+
args: ExpressionNode[];
|
|
120
|
+
/** The function name */
|
|
121
|
+
callTarget: IdentifierNode;
|
|
122
|
+
}
|
|
123
|
+
export interface ArrayExpressionNode extends BaseNode<"ArrayExpression"> {
|
|
124
|
+
/** The items in an array */
|
|
125
|
+
elements: ExpressionNode[];
|
|
126
|
+
}
|
|
127
|
+
export interface IdentifierNode extends BaseNode<"Identifier"> {
|
|
128
|
+
/** The variable name */
|
|
129
|
+
name: string;
|
|
130
|
+
}
|
|
131
|
+
export type AssignmentNode = BaseNode<"Assignment"> & DirectionalNode;
|
|
132
|
+
export interface ModificationNode extends BaseNode<"Modification">, DirectionalNode {
|
|
133
|
+
/** The operator for the modification */
|
|
134
|
+
operator: string;
|
|
135
|
+
}
|
|
136
|
+
export type ExpressionNode = LiteralNode | BinaryNode | LogicalNode | UnaryNode | ThisNode | ModelRefNode | MemberExpressionNode | ConditionalExpressionNode | CompoundNode | CallExpressionNode | ArrayExpressionNode | IdentifierNode | AssignmentNode | ModificationNode | ObjectNode;
|
|
137
|
+
export type ExpressionNodeType = ExpressionNode["type"];
|
|
138
|
+
export interface ErrorWithLocation extends Error {
|
|
139
|
+
/** The place in the string where the error occurs */
|
|
140
|
+
index: number;
|
|
141
|
+
/** a helpful description */
|
|
142
|
+
description: string;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ErrorWithLocation, ExpressionHandler, ExpressionNode, ExpressionObjectType, ExpressionType, NodePosition } from "./types";
|
|
2
|
+
/** Generates a function by removing the first context argument */
|
|
3
|
+
export declare function withoutContext<T extends unknown[], Return>(fn: (...args: T) => Return): ExpressionHandler<T, Return>;
|
|
4
|
+
/** Get the node in the expression that's closest to the desired position */
|
|
5
|
+
export declare function findClosestNodeAtPosition(node: ExpressionNode, position: NodePosition): ExpressionNode | undefined;
|
|
6
|
+
/** Checks if the expression is a simple type */
|
|
7
|
+
export declare function isObjectExpression(expr: ExpressionType): expr is ExpressionObjectType;
|
|
8
|
+
/**
|
|
9
|
+
* Type guard for ErrorWithLocation
|
|
10
|
+
*/
|
|
11
|
+
export declare function isErrorWithLocation(error: Error): error is ErrorWithLocation;
|
|
12
|
+
//# sourceMappingURL=utils.d.ts.map
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "@player-ui/types";
|
|
2
|
+
export * from "./binding/index";
|
|
3
|
+
export * from "./data/index";
|
|
4
|
+
export * from "./expressions/index";
|
|
5
|
+
export * from "./logger/index";
|
|
6
|
+
export * from "./schema/index";
|
|
7
|
+
export * from "./string-resolver/index";
|
|
8
|
+
export * from "./validator/index";
|
|
9
|
+
export * from "./view/index";
|
|
10
|
+
export * from "./player";
|
|
11
|
+
export * from "./controllers/index";
|
|
12
|
+
export * from "./types";
|
|
13
|
+
export * from "./plugins/flow-exp-plugin";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Logger, Severity } from "./types";
|
|
2
|
+
export type ConsoleHandler = Pick<typeof console, "log" | "warn" | "error">;
|
|
3
|
+
/** A Logger implementation that uses console */
|
|
4
|
+
export default class ConsoleLogger implements Logger {
|
|
5
|
+
private severity;
|
|
6
|
+
private _console;
|
|
7
|
+
constructor(severity?: Severity, _console?: ConsoleHandler);
|
|
8
|
+
setSeverity(severity: Severity): void;
|
|
9
|
+
private getConsoleFn;
|
|
10
|
+
private createHandler;
|
|
11
|
+
readonly trace: (...args: any[]) => void;
|
|
12
|
+
readonly debug: (...args: any[]) => void;
|
|
13
|
+
readonly info: (...args: any[]) => void;
|
|
14
|
+
readonly warn: (...args: any[]) => void;
|
|
15
|
+
readonly error: (...args: any[]) => void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=consoleLogger.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export { default as ConsoleLogger } from "./consoleLogger";
|
|
3
|
+
export { default as NoopLogger } from "./noopLogger";
|
|
4
|
+
export { default as TapableLogger } from "./tapableLogger";
|
|
5
|
+
export { default as ProxyLogger } from "./proxyLogger";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Logger } from "./types";
|
|
2
|
+
/** A logger implementation that goes nowhere */
|
|
3
|
+
export default class NoopLogger implements Logger {
|
|
4
|
+
readonly trace: () => void;
|
|
5
|
+
readonly debug: () => void;
|
|
6
|
+
readonly info: () => void;
|
|
7
|
+
readonly warn: () => void;
|
|
8
|
+
readonly error: () => void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=noopLogger.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Logger, LoggerProvider } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* The ProxyLogger allows a user to log to another Logger instance that may not exist yet
|
|
4
|
+
*/
|
|
5
|
+
export default class ProxyLogger implements Logger {
|
|
6
|
+
private proxiedLoggerProvider;
|
|
7
|
+
constructor(loggerProvider: LoggerProvider);
|
|
8
|
+
private createHandler;
|
|
9
|
+
readonly trace: (...args: any[]) => void;
|
|
10
|
+
readonly debug: (...args: any[]) => void;
|
|
11
|
+
readonly info: (...args: any[]) => void;
|
|
12
|
+
readonly warn: (...args: any[]) => void;
|
|
13
|
+
readonly error: (...args: any[]) => void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=proxyLogger.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SyncHook } from "tapable-ts";
|
|
2
|
+
import type { Logger } from "./types";
|
|
3
|
+
/** A logger that has a tapable subscriptions to callbacks */
|
|
4
|
+
export default class TapableLogger implements Logger {
|
|
5
|
+
readonly hooks: {
|
|
6
|
+
trace: SyncHook<[any[]], Record<string, any>>;
|
|
7
|
+
debug: SyncHook<[any[]], Record<string, any>>;
|
|
8
|
+
info: SyncHook<[any[]], Record<string, any>>;
|
|
9
|
+
warn: SyncHook<[any[]], Record<string, any>>;
|
|
10
|
+
error: SyncHook<[any[]], Record<string, any>>;
|
|
11
|
+
log: SyncHook<["error" | "trace" | "debug" | "info" | "warn", any[]], Record<string, any>>;
|
|
12
|
+
};
|
|
13
|
+
private logHandlers;
|
|
14
|
+
private createHandler;
|
|
15
|
+
addHandler(logHandler: Logger): void;
|
|
16
|
+
removeHandler(logHandler: Logger): void;
|
|
17
|
+
readonly trace: (...args: any[]) => void;
|
|
18
|
+
readonly debug: (...args: any[]) => void;
|
|
19
|
+
readonly info: (...args: any[]) => void;
|
|
20
|
+
readonly warn: (...args: any[]) => void;
|
|
21
|
+
readonly error: (...args: any[]) => void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=tapableLogger.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type LogFn = (...args: Array<any>) => void;
|
|
2
|
+
export declare const severities: readonly ["trace", "debug", "info", "warn", "error"];
|
|
3
|
+
export type Severity = (typeof severities)[number];
|
|
4
|
+
export type Logger = Record<Severity, LogFn>;
|
|
5
|
+
export type LoggerProvider = () => Logger | undefined;
|
|
6
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Flow as FlowType } from "@player-ui/types";
|
|
2
|
+
import { SyncHook, SyncWaterfallHook } from "tapable-ts";
|
|
3
|
+
import type { Logger } from "./logger";
|
|
4
|
+
import { TapableLogger } from "./logger";
|
|
5
|
+
import { ExpressionEvaluator } from "./expressions";
|
|
6
|
+
import { SchemaController } from "./schema";
|
|
7
|
+
import { BindingParser } from "./binding";
|
|
8
|
+
import type { ViewInstance } from "./view";
|
|
9
|
+
import { ConstantsController, ViewController, DataController, ValidationController, FlowController } from "./controllers";
|
|
10
|
+
import type { PlayerFlowState, CompletedState } from "./types";
|
|
11
|
+
export interface PlayerPlugin {
|
|
12
|
+
/**
|
|
13
|
+
* Unique identifier of the plugin.
|
|
14
|
+
* Enables the plugin to be retrievable from Player.
|
|
15
|
+
*/
|
|
16
|
+
symbol?: symbol;
|
|
17
|
+
/** The name of the plugin */
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* Use this to tap into Player hooks
|
|
21
|
+
*/
|
|
22
|
+
apply: (player: Player) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface ExtendedPlayerPlugin<Assets = void, Views = void, Expressions = void, DataTypes = void> {
|
|
25
|
+
}
|
|
26
|
+
export interface PlayerConfigOptions {
|
|
27
|
+
/** A set of plugins to load */
|
|
28
|
+
plugins?: PlayerPlugin[];
|
|
29
|
+
/** A logger to use */
|
|
30
|
+
logger?: Logger;
|
|
31
|
+
}
|
|
32
|
+
export interface PlayerInfo {
|
|
33
|
+
/** Version of the running player */
|
|
34
|
+
version: string;
|
|
35
|
+
/** Hash of the HEAD commit used to build the current version */
|
|
36
|
+
commit: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* This is it.
|
|
40
|
+
*/
|
|
41
|
+
export declare class Player {
|
|
42
|
+
static readonly info: PlayerInfo;
|
|
43
|
+
readonly logger: TapableLogger;
|
|
44
|
+
readonly constantsController: ConstantsController;
|
|
45
|
+
private config;
|
|
46
|
+
private state;
|
|
47
|
+
readonly hooks: {
|
|
48
|
+
/** The hook that fires every time we create a new flowController (a new Content blob is passed in) */
|
|
49
|
+
flowController: SyncHook<[FlowController], Record<string, any>>;
|
|
50
|
+
/** The hook that updates/handles views */
|
|
51
|
+
viewController: SyncHook<[ViewController], Record<string, any>>;
|
|
52
|
+
/** A hook called every-time there's a new view. This is equivalent to the view hook on the view-controller */
|
|
53
|
+
view: SyncHook<[ViewInstance], Record<string, any>>;
|
|
54
|
+
/** Called when an expression evaluator was created */
|
|
55
|
+
expressionEvaluator: SyncHook<[ExpressionEvaluator], Record<string, any>>;
|
|
56
|
+
/** The hook that creates and manages data */
|
|
57
|
+
dataController: SyncHook<[DataController], Record<string, any>>;
|
|
58
|
+
/** Called after the schema is created for a flow */
|
|
59
|
+
schema: SyncHook<[SchemaController], Record<string, any>>;
|
|
60
|
+
/** Manages validations (schema and x-field ) */
|
|
61
|
+
validationController: SyncHook<[ValidationController], Record<string, any>>;
|
|
62
|
+
/** Manages parsing binding */
|
|
63
|
+
bindingParser: SyncHook<[BindingParser], Record<string, any>>;
|
|
64
|
+
/** A that's called for state changes in the flow execution */
|
|
65
|
+
state: SyncHook<[PlayerFlowState], Record<string, any>>;
|
|
66
|
+
/** A hook to access the current flow */
|
|
67
|
+
onStart: SyncHook<[FlowType<import("@player-ui/types").Asset<string>>], Record<string, any>>;
|
|
68
|
+
/** A hook for when the flow ends either in success or failure */
|
|
69
|
+
onEnd: SyncHook<[], Record<string, any>>;
|
|
70
|
+
/** Mutate the Content flow before starting */
|
|
71
|
+
resolveFlowContent: SyncWaterfallHook<[FlowType<import("@player-ui/types").Asset<string>>], Record<string, any>>;
|
|
72
|
+
};
|
|
73
|
+
constructor(config?: PlayerConfigOptions);
|
|
74
|
+
/** Returns currently registered plugins */
|
|
75
|
+
getPlugins(): PlayerPlugin[];
|
|
76
|
+
/** Find instance of [Plugin] that has been registered to Player */
|
|
77
|
+
findPlugin<Plugin extends PlayerPlugin>(symbol: symbol): Plugin | undefined;
|
|
78
|
+
/** Retrieve an instance of [Plugin] and conditionally invoke [apply] if it exists */
|
|
79
|
+
applyTo<Plugin extends PlayerPlugin>(symbol: symbol, apply: (plugin: Plugin) => void): void;
|
|
80
|
+
/** Register and apply [Plugin] if one with the same symbol is not already registered. */
|
|
81
|
+
registerPlugin(plugin: PlayerPlugin): void;
|
|
82
|
+
/** Returns the current version of the running player */
|
|
83
|
+
getVersion(): string;
|
|
84
|
+
/** Returns the git commit used to build Player version */
|
|
85
|
+
getCommit(): string;
|
|
86
|
+
/**
|
|
87
|
+
* Fetch the current state of Player.
|
|
88
|
+
* It will return either `not-started`, `in-progress`, `completed`
|
|
89
|
+
* with some extra data in each
|
|
90
|
+
*/
|
|
91
|
+
getState(): PlayerFlowState;
|
|
92
|
+
/**
|
|
93
|
+
* A private means of setting the state of Player
|
|
94
|
+
* Calls the hooks for subscribers to listen for this event
|
|
95
|
+
*/
|
|
96
|
+
private setState;
|
|
97
|
+
/** Start Player with the given flow */
|
|
98
|
+
private setupFlow;
|
|
99
|
+
start(payload: FlowType): Promise<CompletedState>;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=player.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Player, PlayerPlugin } from "../player";
|
|
2
|
+
/**
|
|
3
|
+
* A plugin that provides the out-of-the-box expressions for player
|
|
4
|
+
*/
|
|
5
|
+
export declare class DefaultExpPlugin implements PlayerPlugin {
|
|
6
|
+
name: string;
|
|
7
|
+
apply(player: Player): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=default-exp-plugin.d.ts.map
|