@player-tools/dsl 0.5.0--canary.62.1176 → 0.5.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/cjs/index.cjs +973 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +910 -0
- package/dist/index.mjs +910 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +27 -33
- package/src/__tests__/asset-api.test.tsx +354 -0
- package/src/__tests__/edge-cases.test.tsx +81 -0
- package/src/__tests__/helpers/asset-library.tsx +371 -0
- package/src/__tests__/helpers/mock-data-refs.ts +21 -0
- package/src/__tests__/json.test.ts +12 -0
- package/src/__tests__/jsx.test.tsx +138 -0
- package/src/__tests__/schema.test.tsx +378 -0
- package/src/__tests__/switch.test.tsx +251 -0
- package/src/__tests__/template.test.tsx +294 -0
- package/src/__tests__/view-api.test.tsx +46 -0
- package/src/auto-id.tsx +10 -10
- package/src/compiler/__tests__/compiler.test.tsx +264 -0
- package/src/compiler/__tests__/schema.test.ts +127 -0
- package/src/compiler/compiler.ts +50 -46
- package/src/compiler/index.ts +3 -3
- package/src/compiler/schema.ts +29 -25
- package/src/compiler/types.ts +15 -12
- package/src/compiler/utils.ts +7 -7
- package/src/components.tsx +17 -12
- package/src/index.ts +11 -11
- package/src/string-templates/__tests__/binding.test.ts +87 -0
- package/src/string-templates/__tests__/edge-cases.test.ts +6 -0
- package/src/string-templates/__tests__/expression.test.ts +9 -0
- package/src/string-templates/__tests__/react.test.tsx +75 -0
- package/src/string-templates/index.ts +40 -22
- package/src/switch.tsx +12 -12
- package/src/template.tsx +38 -34
- package/src/types.ts +5 -5
- package/src/utils.tsx +8 -8
- package/types/auto-id.d.ts +33 -0
- package/types/compiler/compiler.d.ts +27 -0
- package/types/compiler/index.d.ts +4 -0
- package/types/compiler/schema.d.ts +61 -0
- package/types/compiler/types.d.ts +55 -0
- package/types/compiler/utils.d.ts +4 -0
- package/types/components.d.ts +90 -0
- package/types/index.d.ts +12 -0
- package/types/string-templates/index.d.ts +50 -0
- package/types/switch.d.ts +19 -0
- package/types/template.d.ts +20 -0
- package/types/types.d.ts +42 -0
- package/types/utils.d.ts +33 -0
- package/README.md +0 -9
- package/dist/index.cjs.js +0 -990
- package/dist/index.d.ts +0 -404
- package/dist/index.esm.js +0 -923
package/dist/index.d.ts
DELETED
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
import * as _player_ui_types from '@player-ui/types';
|
|
2
|
-
import { Asset as Asset$1, Navigation as Navigation$1, Expression, Schema, NavigationFlowViewState, NavigationFlowState, NavigationFlow, ExpressionObject, Flow } from '@player-ui/types';
|
|
3
|
-
import * as React$1 from 'react';
|
|
4
|
-
import React__default, { PropsWithChildren } from 'react';
|
|
5
|
-
import { PropertyNode, ObjectNode, JsonNode, JsonType } from 'react-json-reconciler';
|
|
6
|
-
export * from 'react-json-reconciler';
|
|
7
|
-
import { SyncWaterfallHook, SyncHook, AsyncSeriesWaterfallHook, AsyncSeriesHook } from 'tapable-ts';
|
|
8
|
-
|
|
9
|
-
declare type TemplateInstanceRefStringContext = 'binding' | 'expression';
|
|
10
|
-
interface TemplateRefStringOptions {
|
|
11
|
-
/** If this template string is inside of another binding or expression */
|
|
12
|
-
nestedContext?: TemplateInstanceRefStringContext;
|
|
13
|
-
}
|
|
14
|
-
interface TemplateInstanceRefStringOptions {
|
|
15
|
-
/** The array of strings for the template */
|
|
16
|
-
strings: TemplateStringsArray;
|
|
17
|
-
/** the other data that's present in the template */
|
|
18
|
-
other: Array<string | TemplateStringType>;
|
|
19
|
-
/** If this template string is inside of another binding or expression */
|
|
20
|
-
nestedContext?: TemplateInstanceRefStringContext;
|
|
21
|
-
/** Convert the value to a reference nested in the given context */
|
|
22
|
-
toRefString: (options: TemplateRefStringOptions | undefined, value: string) => string;
|
|
23
|
-
}
|
|
24
|
-
declare const OpaqueIdentifier: unique symbol;
|
|
25
|
-
declare type TemplateStringType = React$1.ReactElement & {
|
|
26
|
-
/** An identifier to show that this is a template type */
|
|
27
|
-
[OpaqueIdentifier]: true;
|
|
28
|
-
/** The value of the template string when in another string */
|
|
29
|
-
toString: () => string;
|
|
30
|
-
/** the raw value of the template string */
|
|
31
|
-
toValue: () => string;
|
|
32
|
-
/** the dereferenced value when used in another */
|
|
33
|
-
toRefString: (options?: TemplateRefStringOptions) => string;
|
|
34
|
-
};
|
|
35
|
-
declare type BindingTemplateInstance = TemplateStringType & {
|
|
36
|
-
/** An identifier for a binding instance */
|
|
37
|
-
__type: 'binding';
|
|
38
|
-
};
|
|
39
|
-
declare type ExpressionTemplateInstance = TemplateStringType & {
|
|
40
|
-
/** The identifier for an expression instance */
|
|
41
|
-
__type: 'expression';
|
|
42
|
-
};
|
|
43
|
-
/** A react component for rendering a template string type */
|
|
44
|
-
declare const TemplateStringComponent: (props: {
|
|
45
|
-
/** The string value of the child template string */
|
|
46
|
-
value: string;
|
|
47
|
-
}) => React$1.ReactElement<{
|
|
48
|
-
value: string;
|
|
49
|
-
}, string | React$1.JSXElementConstructor<any>>;
|
|
50
|
-
/** A tagged-template constructor for a binding */
|
|
51
|
-
declare const binding: (strings: TemplateStringsArray, ...nested: Array<TemplateStringType | string>) => BindingTemplateInstance;
|
|
52
|
-
/** A tagged-template constructor for an expression */
|
|
53
|
-
declare const expression: (strings: TemplateStringsArray, ...nested: Array<ExpressionTemplateInstance | BindingTemplateInstance | string>) => ExpressionTemplateInstance;
|
|
54
|
-
/** Check if a value is a template string */
|
|
55
|
-
declare const isTemplateStringInstance: (val: unknown) => val is BindingTemplateInstance | ExpressionTemplateInstance;
|
|
56
|
-
|
|
57
|
-
declare type WithChildren<T = Record<string, unknown>> = T & {
|
|
58
|
-
/** child nodes */
|
|
59
|
-
children?: React.ReactNode;
|
|
60
|
-
};
|
|
61
|
-
declare type RemoveUnknownIndex<T> = {
|
|
62
|
-
[P in keyof T as T[P] extends unknown ? unknown extends T[P] ? never : P : P]: T[P];
|
|
63
|
-
};
|
|
64
|
-
declare type AddUnknownIndex<T> = T & {
|
|
65
|
-
[key: string]: unknown;
|
|
66
|
-
};
|
|
67
|
-
/** Make an ID prop optional an a type */
|
|
68
|
-
declare type OmitProp<T, K extends string> = {
|
|
69
|
-
[P in keyof T as P extends K ? never : P]: T[P];
|
|
70
|
-
};
|
|
71
|
-
interface PlayerApplicability {
|
|
72
|
-
/** An expression to evaluate to determine if this node should appear in a view or not */
|
|
73
|
-
applicability?: BindingTemplateInstance | ExpressionTemplateInstance | boolean;
|
|
74
|
-
}
|
|
75
|
-
declare type AssetPropsWithChildren<T extends Asset$1> = WithChildren<WithTemplateTypes<OmitProp<RemoveUnknownIndex<T>, 'id' | 'type'> & Partial<Pick<Asset$1, 'id'>>> & PlayerApplicability>;
|
|
76
|
-
declare type SwapKeysToType<T, K extends keyof T, NewType> = {
|
|
77
|
-
[P in keyof T]: P extends K ? NewType : T[P];
|
|
78
|
-
};
|
|
79
|
-
declare type WithTemplateTypes<T> = T extends Record<any, any> ? {
|
|
80
|
-
[P in keyof T]: WithTemplateTypes<T[P]>;
|
|
81
|
-
} : T | BindingTemplateInstance | ExpressionTemplateInstance;
|
|
82
|
-
declare type ValidKeys = 'exp' | 'onStart' | 'onEnd';
|
|
83
|
-
declare type DeepReplace<T, Old, New> = {
|
|
84
|
-
[P in keyof T]: T[P] extends Old ? P extends ValidKeys ? New : DeepReplace<T[P], Old, New> : T[P] extends (infer R)[] ? DeepReplace<R, Old, New>[] : T[P] extends object ? DeepReplace<T[P], Old, New> : Extract<T[P], Old> extends Old ? DeepReplace<Extract<T[P], object>, Old, New> | Exclude<T[P], Old | object> | New : T[P];
|
|
85
|
-
};
|
|
86
|
-
declare type Navigation = DeepReplace<Navigation$1, Expression, ExpressionTemplateInstance | ExpressionTemplateInstance[] | Expression>;
|
|
87
|
-
interface toJsonOptions {
|
|
88
|
-
/**
|
|
89
|
-
* List of string keys that should not be parsed in a special way
|
|
90
|
-
* default is 'applicability'
|
|
91
|
-
*/
|
|
92
|
-
propertiesToSkip?: string[];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
declare type AssetProps = PlayerApplicability & {
|
|
96
|
-
/** id of the asset */
|
|
97
|
-
id?: string;
|
|
98
|
-
/** the asset type */
|
|
99
|
-
type: string;
|
|
100
|
-
/** Any other properties on the asset */
|
|
101
|
-
children?: React__default.ReactNode;
|
|
102
|
-
/** other things that we don't know about */
|
|
103
|
-
[key: string]: unknown;
|
|
104
|
-
};
|
|
105
|
-
declare const SlotContext: React__default.Context<{
|
|
106
|
-
/** The property name for the slot */
|
|
107
|
-
propertyName: string;
|
|
108
|
-
/** If the slot represents an array */
|
|
109
|
-
isArray: boolean;
|
|
110
|
-
/** If the items in the slot should be wrapped in an "asset" object */
|
|
111
|
-
wrapInAsset: boolean;
|
|
112
|
-
/** Other props to add to the slot */
|
|
113
|
-
additionalProperties?: any;
|
|
114
|
-
/** The ref to the property node */
|
|
115
|
-
ref: React__default.RefObject<PropertyNode>;
|
|
116
|
-
/** A text component if we hit a string but expect an asset */
|
|
117
|
-
TextComp?: React__default.ComponentType<{}> | undefined;
|
|
118
|
-
/** A component to create a collection asset is we get an array but need a single element */
|
|
119
|
-
CollectionComp?: React__default.ComponentType<{}> | undefined;
|
|
120
|
-
} | undefined>;
|
|
121
|
-
/**
|
|
122
|
-
* Wraps the children in an `asset` object.
|
|
123
|
-
* Additional props are added to the top level object
|
|
124
|
-
*/
|
|
125
|
-
declare const AssetWrapper: React__default.ForwardRefExoticComponent<Omit<WithChildren<{
|
|
126
|
-
[key: string]: any;
|
|
127
|
-
}>, "ref"> & React__default.RefAttributes<ObjectNode>>;
|
|
128
|
-
/** Create a ID property for a node */
|
|
129
|
-
declare const GeneratedIDProperty: (props: {
|
|
130
|
-
/** the id to use if supplied by the user */
|
|
131
|
-
id?: string;
|
|
132
|
-
}) => React__default.JSX.Element;
|
|
133
|
-
/** An asset */
|
|
134
|
-
declare const Asset: React__default.ForwardRefExoticComponent<Omit<AssetProps, "ref"> & React__default.RefAttributes<ObjectNode>>;
|
|
135
|
-
declare const View: React__default.ForwardRefExoticComponent<Omit<PlayerApplicability & {
|
|
136
|
-
[key: string]: unknown;
|
|
137
|
-
/** id of the asset */
|
|
138
|
-
id?: string | undefined;
|
|
139
|
-
/** the asset type */
|
|
140
|
-
type: string;
|
|
141
|
-
/** Any other properties on the asset */
|
|
142
|
-
children?: React__default.ReactNode;
|
|
143
|
-
} & _player_ui_types.Asset<string> & {
|
|
144
|
-
validation?: _player_ui_types.Validation.CrossfieldReference[] | undefined;
|
|
145
|
-
}, "ref"> & React__default.RefAttributes<ObjectNode>>;
|
|
146
|
-
/** A component to generate a named property slot */
|
|
147
|
-
declare const Slot: (props: {
|
|
148
|
-
/** The name of the slot */
|
|
149
|
-
name: string;
|
|
150
|
-
/** if the slot is an array or single object */
|
|
151
|
-
isArray?: boolean;
|
|
152
|
-
/** if each item should be wrapped in an asset */
|
|
153
|
-
wrapInAsset?: boolean;
|
|
154
|
-
/** Any children to render in the slot */
|
|
155
|
-
children?: React__default.ReactNode;
|
|
156
|
-
/** Other properties to add to the slot */
|
|
157
|
-
additionalProperties?: any;
|
|
158
|
-
/** A text component if we hit a string but expect an asset */
|
|
159
|
-
TextComp?: React__default.ComponentType;
|
|
160
|
-
/** A component to create a collection asset is we get an array but need a single element */
|
|
161
|
-
CollectionComp?: React__default.ComponentType;
|
|
162
|
-
}) => React__default.JSX.Element;
|
|
163
|
-
/** Create a slot for a given property */
|
|
164
|
-
declare function createSlot<SlotProps = unknown>(options: {
|
|
165
|
-
/** The name of the slot */
|
|
166
|
-
name: string;
|
|
167
|
-
/** if the slot is an array or single object */
|
|
168
|
-
isArray?: boolean;
|
|
169
|
-
/** if each item should be wrapped in an asset */
|
|
170
|
-
wrapInAsset?: boolean;
|
|
171
|
-
/** Any children to render in the slot */
|
|
172
|
-
children?: React__default.ReactNode;
|
|
173
|
-
/** A text component if we hit a string but expect an asset */
|
|
174
|
-
TextComp?: React__default.ComponentType;
|
|
175
|
-
/** A component to create a collection asset is we get an array but need a single element */
|
|
176
|
-
CollectionComp?: React__default.ComponentType;
|
|
177
|
-
}): (props: {
|
|
178
|
-
/** An object to include in this property */
|
|
179
|
-
children?: React__default.ReactNode;
|
|
180
|
-
} & SlotProps) => React__default.JSX.Element;
|
|
181
|
-
|
|
182
|
-
declare const IndexSuffixStopContext: React__default.Context<boolean>;
|
|
183
|
-
/** Get the generated id */
|
|
184
|
-
declare const useGetIdPrefix: () => string;
|
|
185
|
-
/** Add a suffix to a generated id */
|
|
186
|
-
declare const IDSuffixProvider: (props: WithChildren<{
|
|
187
|
-
/** The suffix to append */
|
|
188
|
-
suffix: string;
|
|
189
|
-
}>) => React__default.JSX.Element;
|
|
190
|
-
/** Override the generated id with the supplied one */
|
|
191
|
-
declare const IDProvider: (props: WithChildren<{
|
|
192
|
-
/** The new id to use */
|
|
193
|
-
id?: string;
|
|
194
|
-
}>) => React__default.JSX.Element;
|
|
195
|
-
/** Get the index of an item in a slot */
|
|
196
|
-
declare const useIndexInSlot: (ref: React__default.RefObject<JsonNode>) => number;
|
|
197
|
-
/** Add the index to the id path when in an array slot */
|
|
198
|
-
declare const IDSuffixIndexProvider: (props: WithChildren<{
|
|
199
|
-
/** The ref to use */
|
|
200
|
-
wrapperRef: React__default.RefObject<JsonNode>;
|
|
201
|
-
/** if the suffix is in a template, the id to use */
|
|
202
|
-
templateIndex?: string;
|
|
203
|
-
}>) => React__default.JSX.Element;
|
|
204
|
-
/** Wrap a slot with the index if in an array slot */
|
|
205
|
-
declare const OptionalIDSuffixProvider: (props: WithChildren<{
|
|
206
|
-
/** The ref to walk upwards and use as an index */
|
|
207
|
-
wrapperRef: React__default.RefObject<JsonNode>;
|
|
208
|
-
/** if the suffix is in a template, the id to use */
|
|
209
|
-
templateIndex?: string;
|
|
210
|
-
}>) => React__default.JSX.Element;
|
|
211
|
-
|
|
212
|
-
/** Get an array version of the value */
|
|
213
|
-
declare function toArray<T>(val: T | Array<T>): Array<T>;
|
|
214
|
-
/** Create a component version */
|
|
215
|
-
declare function toJsonElement(value: any, indexOrKey?: number | string, options?: toJsonOptions): React$1.ReactElement;
|
|
216
|
-
/** Create a fragment for the properties */
|
|
217
|
-
declare function toJsonProperties(value: Record<string, any>, options?: toJsonOptions): React$1.JSX.Element[];
|
|
218
|
-
/** Create a text asset if needed */
|
|
219
|
-
declare function normalizeText(options: {
|
|
220
|
-
/** The current node */
|
|
221
|
-
node: React$1.ReactNode;
|
|
222
|
-
/** A component to render a text asset */
|
|
223
|
-
TextComp?: React$1.ComponentType<any>;
|
|
224
|
-
}): React$1.ReactNode;
|
|
225
|
-
/** Create a collection if needed */
|
|
226
|
-
declare function normalizeToCollection(options: {
|
|
227
|
-
/** the node to look at */
|
|
228
|
-
node: React$1.ReactNode;
|
|
229
|
-
/** A Text asset */
|
|
230
|
-
TextComp?: React$1.ComponentType;
|
|
231
|
-
/** A collection asset */
|
|
232
|
-
CollectionComp?: React$1.ComponentType<any>;
|
|
233
|
-
}): string | number | boolean | Iterable<React$1.ReactNode> | React$1.JSX.Element | null | undefined;
|
|
234
|
-
declare type ReactChildArray = ReturnType<typeof React$1.Children.toArray>;
|
|
235
|
-
/**
|
|
236
|
-
*
|
|
237
|
-
* Hoisted from https://github.com/gregberge/react-flatten-children/blob/master/src/index.tsx
|
|
238
|
-
* Peer dependencies were wrong and can't be reasonably patch it everywhere
|
|
239
|
-
*/
|
|
240
|
-
declare function flattenChildren(children: React$1.ReactNode): ReactChildArray;
|
|
241
|
-
|
|
242
|
-
interface SwitchProps {
|
|
243
|
-
/** defaults to a staticSwitch */
|
|
244
|
-
isDynamic?: boolean;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Switches allow users to fork content between 1 or more assets
|
|
248
|
-
*/
|
|
249
|
-
declare const Switch: {
|
|
250
|
-
(props: PropsWithChildren<SwitchProps>): React__default.JSX.Element;
|
|
251
|
-
Case: (props: PropsWithChildren<CaseProps>) => React__default.JSX.Element;
|
|
252
|
-
};
|
|
253
|
-
interface CaseProps {
|
|
254
|
-
/** the test for this case statement */
|
|
255
|
-
exp?: ExpressionTemplateInstance | BindingTemplateInstance | boolean;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
interface TemplateContextType {
|
|
259
|
-
/** The number of nested templates */
|
|
260
|
-
depth: number;
|
|
261
|
-
}
|
|
262
|
-
declare const TemplateContext: React__default.Context<TemplateContextType>;
|
|
263
|
-
interface TemplateProps {
|
|
264
|
-
/** The source binding */
|
|
265
|
-
data: BindingTemplateInstance;
|
|
266
|
-
/** The target property */
|
|
267
|
-
output?: string;
|
|
268
|
-
/** The template value */
|
|
269
|
-
children: React__default.ReactNode;
|
|
270
|
-
/** boolean that specifies whether template should recompute when data changes */
|
|
271
|
-
dynamic?: boolean;
|
|
272
|
-
}
|
|
273
|
-
/** A template allows users to dynamically map over an array of data */
|
|
274
|
-
declare const Template: (props: TemplateProps) => React__default.JSX.Element;
|
|
275
|
-
|
|
276
|
-
declare const SchemaTypeName: unique symbol;
|
|
277
|
-
/**
|
|
278
|
-
* Generator for `Schema.Schema` Objects
|
|
279
|
-
*/
|
|
280
|
-
declare class SchemaGenerator {
|
|
281
|
-
private children;
|
|
282
|
-
private generatedDataTypes;
|
|
283
|
-
private logger;
|
|
284
|
-
hooks: {
|
|
285
|
-
createSchemaNode: SyncWaterfallHook<[node: Schema.DataType<unknown>, originalProperty: Record<string | symbol, unknown>], Record<string, any>>;
|
|
286
|
-
};
|
|
287
|
-
constructor(logger?: LoggingInterface);
|
|
288
|
-
/**
|
|
289
|
-
* Converts an object to a `Schema.Schema` representation
|
|
290
|
-
* Note: uses iteration to prevent potentially very deep recursion on large objects
|
|
291
|
-
*/
|
|
292
|
-
toSchema: (schema: any) => Schema.Schema;
|
|
293
|
-
/**
|
|
294
|
-
* Processes the children of an object Node
|
|
295
|
-
* Newly discovered children get added to the provided array
|
|
296
|
-
*/
|
|
297
|
-
private processChild;
|
|
298
|
-
/**
|
|
299
|
-
* Make an intermediate `Schema.DataType` object given a name
|
|
300
|
-
*/
|
|
301
|
-
private makePlaceholderType;
|
|
302
|
-
/**
|
|
303
|
-
* Make an intermediate `Schema.DataType` object with array support given a name
|
|
304
|
-
*/
|
|
305
|
-
private makePlaceholderArrayType;
|
|
306
|
-
}
|
|
307
|
-
declare type MakeArrayIntoIndexRef<T extends any[]> = {
|
|
308
|
-
[key: number]: MakeBindingRefable<T[0]>;
|
|
309
|
-
/** Used when referencing bindings from within a template */
|
|
310
|
-
_index_: MakeBindingRefable<T[0]>;
|
|
311
|
-
} & BindingTemplateInstance;
|
|
312
|
-
declare type MakeBindingRefable<T> = {
|
|
313
|
-
[P in keyof T]: T[P] extends object[] ? MakeArrayIntoIndexRef<T[P]> : T[P] extends unknown[] ? T[P] : MakeBindingRefable<T[P]>;
|
|
314
|
-
} & BindingTemplateInstance;
|
|
315
|
-
/**
|
|
316
|
-
* Adds bindings to an object so that the object can be directly used in JSX
|
|
317
|
-
*/
|
|
318
|
-
declare function makeBindingsForObject<Type>(obj: Type, arrayAccessorKeys?: string[]): MakeBindingRefable<Type>;
|
|
319
|
-
/**
|
|
320
|
-
* Generates binding for an object property
|
|
321
|
-
*/
|
|
322
|
-
declare const getBindingFromObject: (obj: any) => BindingTemplateInstance;
|
|
323
|
-
/**
|
|
324
|
-
* Returns the binding string from an object path
|
|
325
|
-
*/
|
|
326
|
-
declare const getBindingStringFromObject: (obj: any) => string;
|
|
327
|
-
/**
|
|
328
|
-
* Returns the ref string from an object path
|
|
329
|
-
*/
|
|
330
|
-
declare const getRefStringFromObject: (obj: any) => string;
|
|
331
|
-
|
|
332
|
-
declare type NavigationFlowReactViewState = Omit<NavigationFlowViewState, 'ref'> & {
|
|
333
|
-
/** The view element */
|
|
334
|
-
ref: React.ReactElement | string;
|
|
335
|
-
};
|
|
336
|
-
declare type NavFlowState = Exclude<NavigationFlowState, NavigationFlowViewState> | NavigationFlowReactViewState;
|
|
337
|
-
declare type NavigationFlowWithReactView = Pick<NavigationFlow, 'startState' | 'onStart' | 'onEnd'> & {
|
|
338
|
-
[key: string]: undefined | string | Expression | ExpressionObject | NavFlowState;
|
|
339
|
-
};
|
|
340
|
-
declare type NavigationWithReactViews = Pick<Navigation$1, 'BEGIN'> & Record<string, string | NavigationFlowWithReactView>;
|
|
341
|
-
declare type FlowWithoutUnknown = RemoveUnknownIndex<Flow>;
|
|
342
|
-
declare type FlowWithReactViews = AddUnknownIndex<Omit<FlowWithoutUnknown, 'views' | 'navigation'> & {
|
|
343
|
-
/** An array of JSX view elements */
|
|
344
|
-
views?: Array<React.ReactElement>;
|
|
345
|
-
/** The navigation element */
|
|
346
|
-
navigation?: NavigationWithReactViews;
|
|
347
|
-
}>;
|
|
348
|
-
declare type DSLFlow = FlowWithReactViews;
|
|
349
|
-
interface DSLSchema {
|
|
350
|
-
[key: string]: Schema.DataType | DSLSchema;
|
|
351
|
-
}
|
|
352
|
-
declare type SerializeType = 'view' | 'flow' | 'schema' | 'navigation';
|
|
353
|
-
declare type SerializablePlayerExportTypes = React.ReactElement | FlowWithReactViews | Schema.Schema | Navigation$1;
|
|
354
|
-
declare type LoggingInterface = Pick<Console, 'warn' | 'error' | 'log'>;
|
|
355
|
-
declare type CompilationResult = {
|
|
356
|
-
/** What type of file is generated */
|
|
357
|
-
contentType: string;
|
|
358
|
-
/** The output path */
|
|
359
|
-
outputFile: string;
|
|
360
|
-
/** the input file */
|
|
361
|
-
inputFile: string;
|
|
362
|
-
};
|
|
363
|
-
declare type CompilerReturn = {
|
|
364
|
-
/** the JSON value of the source */
|
|
365
|
-
value: JsonType | undefined;
|
|
366
|
-
/** The sourcemap of the content */
|
|
367
|
-
sourceMap?: string;
|
|
368
|
-
};
|
|
369
|
-
/** The different type of default content items the compiler handles */
|
|
370
|
-
declare const DefaultCompilerContentTypes: readonly ["view", "flow", "schema"];
|
|
371
|
-
declare type DefaultCompilerContentType = typeof DefaultCompilerContentTypes[number];
|
|
372
|
-
/** Helper function to determine whether a content type is compiler default */
|
|
373
|
-
declare function isDefaultCompilerContentType(t: string): t is DefaultCompilerContentType;
|
|
374
|
-
interface SerializeContext {
|
|
375
|
-
/** The type of the content being compiled */
|
|
376
|
-
type: DefaultCompilerContentType;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Argument passed to the DSLCompiler onEnd hook
|
|
381
|
-
* Defined as an object so additional fields can be added later without breaking API
|
|
382
|
-
* */
|
|
383
|
-
interface OnEndArg {
|
|
384
|
-
/** target output directory **/
|
|
385
|
-
output: string;
|
|
386
|
-
}
|
|
387
|
-
/** A compiler for transforming DSL content into JSON */
|
|
388
|
-
declare class DSLCompiler {
|
|
389
|
-
readonly logger: LoggingInterface;
|
|
390
|
-
hooks: {
|
|
391
|
-
schemaGenerator: SyncHook<[SchemaGenerator], Record<string, any>>;
|
|
392
|
-
preProcessFlow: AsyncSeriesWaterfallHook<[object], Record<string, any>>;
|
|
393
|
-
postProcessFlow: AsyncSeriesWaterfallHook<[Flow<_player_ui_types.Asset<string>>], Record<string, any>>;
|
|
394
|
-
onEnd: AsyncSeriesHook<[OnEndArg], Record<string, any>>;
|
|
395
|
-
};
|
|
396
|
-
constructor(logger?: LoggingInterface);
|
|
397
|
-
/** Convert an object (flow, view, schema, etc) into it's JSON representation */
|
|
398
|
-
serialize(value: unknown, context?: SerializeContext): Promise<CompilerReturn | undefined>;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/** Basic way of identifying the type of file based on the default content export */
|
|
402
|
-
declare const fingerprintContent: (content: unknown, filename?: string) => DefaultCompilerContentType | undefined;
|
|
403
|
-
|
|
404
|
-
export { AddUnknownIndex, Asset, AssetProps, AssetPropsWithChildren, AssetWrapper, BindingTemplateInstance, CaseProps, CompilationResult, CompilerReturn, DSLCompiler, DSLFlow, DSLSchema, DefaultCompilerContentType, ExpressionTemplateInstance, FlowWithReactViews, FlowWithoutUnknown, GeneratedIDProperty, IDProvider, IDSuffixIndexProvider, IDSuffixProvider, IndexSuffixStopContext, LoggingInterface, MakeArrayIntoIndexRef, MakeBindingRefable, NavFlowState, Navigation, NavigationFlowReactViewState, NavigationFlowWithReactView, NavigationWithReactViews, OmitProp, OnEndArg, OptionalIDSuffixProvider, PlayerApplicability, RemoveUnknownIndex, SchemaGenerator, SchemaTypeName, SerializablePlayerExportTypes, SerializeContext, SerializeType, Slot, SlotContext, SwapKeysToType, Switch, SwitchProps, Template, TemplateContext, TemplateContextType, TemplateInstanceRefStringContext, TemplateInstanceRefStringOptions, TemplateProps, TemplateRefStringOptions, TemplateStringComponent, TemplateStringType, View, WithChildren, WithTemplateTypes, binding, createSlot, expression, fingerprintContent, flattenChildren, getBindingFromObject, getBindingStringFromObject, getRefStringFromObject, isDefaultCompilerContentType, isTemplateStringInstance, makeBindingsForObject, normalizeText, normalizeToCollection, toArray, toJsonElement, toJsonOptions, toJsonProperties, useGetIdPrefix, useIndexInSlot };
|