@player-tools/fluent 0.12.1--canary.241.6077
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 +2396 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +2276 -0
- package/dist/index.mjs +2276 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +38 -0
- package/src/core/base-builder/__tests__/fluent-builder-base.test.ts +2423 -0
- package/src/core/base-builder/__tests__/fluent-partial.test.ts +179 -0
- package/src/core/base-builder/__tests__/id-generator.test.ts +658 -0
- package/src/core/base-builder/__tests__/registry.test.ts +534 -0
- package/src/core/base-builder/__tests__/resolution-mixed-arrays.test.ts +319 -0
- package/src/core/base-builder/__tests__/resolution-pipeline.test.ts +416 -0
- package/src/core/base-builder/__tests__/resolution-switches.test.ts +468 -0
- package/src/core/base-builder/__tests__/resolution-templates.test.ts +255 -0
- package/src/core/base-builder/__tests__/switch.test.ts +815 -0
- package/src/core/base-builder/__tests__/template.test.ts +596 -0
- package/src/core/base-builder/__tests__/value-extraction.test.ts +200 -0
- package/src/core/base-builder/__tests__/value-storage.test.ts +459 -0
- package/src/core/base-builder/conditional/index.ts +64 -0
- package/src/core/base-builder/context.ts +152 -0
- package/src/core/base-builder/errors.ts +69 -0
- package/src/core/base-builder/fluent-builder-base.ts +308 -0
- package/src/core/base-builder/guards.ts +137 -0
- package/src/core/base-builder/id/generator.ts +290 -0
- package/src/core/base-builder/id/registry.ts +152 -0
- package/src/core/base-builder/index.ts +72 -0
- package/src/core/base-builder/resolution/path-resolver.ts +116 -0
- package/src/core/base-builder/resolution/pipeline.ts +103 -0
- package/src/core/base-builder/resolution/steps/__tests__/nested-asset-wrappers.test.ts +206 -0
- package/src/core/base-builder/resolution/steps/asset-id.ts +77 -0
- package/src/core/base-builder/resolution/steps/asset-wrappers.ts +64 -0
- package/src/core/base-builder/resolution/steps/builders.ts +84 -0
- package/src/core/base-builder/resolution/steps/mixed-arrays.ts +95 -0
- package/src/core/base-builder/resolution/steps/nested-asset-wrappers.ts +124 -0
- package/src/core/base-builder/resolution/steps/static-values.ts +35 -0
- package/src/core/base-builder/resolution/steps/switches.ts +71 -0
- package/src/core/base-builder/resolution/steps/templates.ts +40 -0
- package/src/core/base-builder/resolution/value-resolver.ts +333 -0
- package/src/core/base-builder/storage/auxiliary-storage.ts +82 -0
- package/src/core/base-builder/storage/value-storage.ts +282 -0
- package/src/core/base-builder/types.ts +266 -0
- package/src/core/base-builder/utils.ts +10 -0
- package/src/core/flow/__tests__/index.test.ts +292 -0
- package/src/core/flow/index.ts +118 -0
- package/src/core/index.ts +8 -0
- package/src/core/mocks/generated/action.builder.ts +92 -0
- package/src/core/mocks/generated/choice-item.builder.ts +120 -0
- package/src/core/mocks/generated/choice.builder.ts +134 -0
- package/src/core/mocks/generated/collection.builder.ts +93 -0
- package/src/core/mocks/generated/field-collection.builder.ts +86 -0
- package/src/core/mocks/generated/index.ts +10 -0
- package/src/core/mocks/generated/info.builder.ts +64 -0
- package/src/core/mocks/generated/input.builder.ts +63 -0
- package/src/core/mocks/generated/overview-collection.builder.ts +65 -0
- package/src/core/mocks/generated/splash-collection.builder.ts +93 -0
- package/src/core/mocks/generated/text.builder.ts +47 -0
- package/src/core/mocks/index.ts +1 -0
- package/src/core/mocks/types/action.ts +92 -0
- package/src/core/mocks/types/choice.ts +129 -0
- package/src/core/mocks/types/collection.ts +140 -0
- package/src/core/mocks/types/info.ts +7 -0
- package/src/core/mocks/types/input.ts +7 -0
- package/src/core/mocks/types/text.ts +5 -0
- package/src/core/schema/__tests__/index.test.ts +127 -0
- package/src/core/schema/index.ts +195 -0
- package/src/core/schema/types.ts +7 -0
- package/src/core/switch/__tests__/index.test.ts +156 -0
- package/src/core/switch/index.ts +81 -0
- package/src/core/tagged-template/README.md +448 -0
- package/src/core/tagged-template/__tests__/extract-bindings-from-schema.test.ts +207 -0
- package/src/core/tagged-template/__tests__/index.test.ts +190 -0
- package/src/core/tagged-template/__tests__/schema-std-integration.test.ts +580 -0
- package/src/core/tagged-template/binding.ts +95 -0
- package/src/core/tagged-template/expression.ts +92 -0
- package/src/core/tagged-template/extract-bindings-from-schema.ts +120 -0
- package/src/core/tagged-template/index.ts +5 -0
- package/src/core/tagged-template/std.ts +472 -0
- package/src/core/tagged-template/types.ts +123 -0
- package/src/core/template/__tests__/index.test.ts +380 -0
- package/src/core/template/index.ts +196 -0
- package/src/core/utils/index.ts +160 -0
- package/src/fp/README.md +411 -0
- package/src/fp/__tests__/index.test.ts +1178 -0
- package/src/fp/index.ts +386 -0
- package/src/gen/common.ts +15 -0
- package/src/index.ts +5 -0
- package/src/types.ts +203 -0
- package/types/core/base-builder/conditional/index.d.ts +21 -0
- package/types/core/base-builder/context.d.ts +39 -0
- package/types/core/base-builder/errors.d.ts +45 -0
- package/types/core/base-builder/fluent-builder-base.d.ts +147 -0
- package/types/core/base-builder/guards.d.ts +58 -0
- package/types/core/base-builder/id/generator.d.ts +69 -0
- package/types/core/base-builder/id/registry.d.ts +93 -0
- package/types/core/base-builder/index.d.ts +9 -0
- package/types/core/base-builder/resolution/path-resolver.d.ts +15 -0
- package/types/core/base-builder/resolution/pipeline.d.ts +27 -0
- package/types/core/base-builder/resolution/steps/asset-id.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/asset-wrappers.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/builders.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/mixed-arrays.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/nested-asset-wrappers.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/static-values.d.ts +14 -0
- package/types/core/base-builder/resolution/steps/switches.d.ts +15 -0
- package/types/core/base-builder/resolution/steps/templates.d.ts +14 -0
- package/types/core/base-builder/resolution/value-resolver.d.ts +62 -0
- package/types/core/base-builder/storage/auxiliary-storage.d.ts +50 -0
- package/types/core/base-builder/storage/value-storage.d.ts +82 -0
- package/types/core/base-builder/types.d.ts +183 -0
- package/types/core/base-builder/utils.d.ts +2 -0
- package/types/core/flow/index.d.ts +23 -0
- package/types/core/index.d.ts +8 -0
- package/types/core/mocks/index.d.ts +2 -0
- package/types/core/mocks/types/action.d.ts +58 -0
- package/types/core/mocks/types/choice.d.ts +95 -0
- package/types/core/mocks/types/collection.d.ts +102 -0
- package/types/core/mocks/types/info.d.ts +7 -0
- package/types/core/mocks/types/input.d.ts +7 -0
- package/types/core/mocks/types/text.d.ts +5 -0
- package/types/core/schema/index.d.ts +34 -0
- package/types/core/schema/types.d.ts +5 -0
- package/types/core/switch/index.d.ts +21 -0
- package/types/core/tagged-template/binding.d.ts +19 -0
- package/types/core/tagged-template/expression.d.ts +11 -0
- package/types/core/tagged-template/extract-bindings-from-schema.d.ts +7 -0
- package/types/core/tagged-template/index.d.ts +6 -0
- package/types/core/tagged-template/std.d.ts +174 -0
- package/types/core/tagged-template/types.d.ts +69 -0
- package/types/core/template/index.d.ts +97 -0
- package/types/core/utils/index.d.ts +47 -0
- package/types/fp/index.d.ts +149 -0
- package/types/gen/common.d.ts +6 -0
- package/types/index.d.ts +3 -0
- package/types/types.d.ts +163 -0
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { Asset } from "@player-ui/types";
|
|
2
|
+
import type { TaggedTemplateValue } from "./core/tagged-template";
|
|
3
|
+
import type { BaseBuildContext, FLUENT_BUILDER_SYMBOL } from "./core/base-builder";
|
|
4
|
+
type AnyAssetBuilder<C extends BaseBuildContext = BaseBuildContext> = {
|
|
5
|
+
readonly [FLUENT_BUILDER_SYMBOL]: true;
|
|
6
|
+
build(context?: C): Asset;
|
|
7
|
+
peek(key: string): unknown;
|
|
8
|
+
has(key: string): boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Options for extracting type information
|
|
12
|
+
*/
|
|
13
|
+
export interface ExtractTypeInfoOptions {
|
|
14
|
+
/** Path to the asset file */
|
|
15
|
+
assetPath: string;
|
|
16
|
+
/** Name of the interface to extract */
|
|
17
|
+
interfaceName: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Enhanced generic parameter information
|
|
21
|
+
*/
|
|
22
|
+
export interface GenericParameter {
|
|
23
|
+
/** Name of the generic parameter */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Type or constraint of the parameter */
|
|
26
|
+
type: string;
|
|
27
|
+
/** Constraint clause (extends X) */
|
|
28
|
+
constraint?: string;
|
|
29
|
+
/** Default type */
|
|
30
|
+
default?: string;
|
|
31
|
+
/** Position in the parameter list */
|
|
32
|
+
position: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Information about a property in a type
|
|
36
|
+
*/
|
|
37
|
+
export interface PropertyInfo {
|
|
38
|
+
/** Name of the property */
|
|
39
|
+
name: string;
|
|
40
|
+
/** Type of the property */
|
|
41
|
+
type: string;
|
|
42
|
+
/** JSDoc comment for the property */
|
|
43
|
+
jsDoc?: string;
|
|
44
|
+
/** Whether the property is optional */
|
|
45
|
+
isOptional?: boolean;
|
|
46
|
+
/** Whether the property is readonly */
|
|
47
|
+
isReadonly?: boolean;
|
|
48
|
+
/** Whether the property is a constant */
|
|
49
|
+
isStringLiteral?: boolean;
|
|
50
|
+
/** Whether the property has generic parameters */
|
|
51
|
+
isGeneric?: boolean;
|
|
52
|
+
/** Generic parameters if any */
|
|
53
|
+
genericParameters?: Array<GenericParameter>;
|
|
54
|
+
/** Nested properties for object types */
|
|
55
|
+
properties?: PropertyInfo[];
|
|
56
|
+
/** Whether the property is an asset wrapper */
|
|
57
|
+
isAssetWrapper?: boolean;
|
|
58
|
+
/** Whether the property is an array type */
|
|
59
|
+
isArrayType?: boolean;
|
|
60
|
+
/** Whether the property is or contains an asset type */
|
|
61
|
+
isAssetType?: boolean;
|
|
62
|
+
/** Name of the parent object when this is a nested property */
|
|
63
|
+
parentName?: string;
|
|
64
|
+
/** Names of required sibling properties in the same parent object */
|
|
65
|
+
requiredSiblings?: string[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Information about an import
|
|
69
|
+
*/
|
|
70
|
+
export interface ImportInfo {
|
|
71
|
+
/** Module path the import is from */
|
|
72
|
+
from: string;
|
|
73
|
+
/** Named imports from the module */
|
|
74
|
+
namedImports: string[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Complete type information extracted from an interface
|
|
78
|
+
*/
|
|
79
|
+
export interface TypeInfo {
|
|
80
|
+
/** The name of the type */
|
|
81
|
+
name: string;
|
|
82
|
+
/** Type reference */
|
|
83
|
+
type: string;
|
|
84
|
+
/** JSDoc comment for the type */
|
|
85
|
+
jsDoc?: string;
|
|
86
|
+
/** Properties of the type */
|
|
87
|
+
properties: PropertyInfo[];
|
|
88
|
+
/** Dependencies of the type */
|
|
89
|
+
dependencies: Set<ImportInfo>;
|
|
90
|
+
/** Whether the type is an asset wrapper */
|
|
91
|
+
isAssetWrapper?: boolean;
|
|
92
|
+
/** Whether the type is or contains an asset type */
|
|
93
|
+
isAssetType?: boolean;
|
|
94
|
+
/** Interface-level generic parameters */
|
|
95
|
+
interfaceGenerics: GenericParameter[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Result type representing either a success or failure
|
|
99
|
+
*/
|
|
100
|
+
export type Result<T, E = Error> = Success<T> | Failure<E>;
|
|
101
|
+
/**
|
|
102
|
+
* Success result with a value
|
|
103
|
+
*/
|
|
104
|
+
export interface Success<T> {
|
|
105
|
+
success: true;
|
|
106
|
+
value: T;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Failure result with an error
|
|
110
|
+
*/
|
|
111
|
+
export interface Failure<E = Error> {
|
|
112
|
+
success: false;
|
|
113
|
+
error: E;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Helper type to check if a type is a literal type vs its general counterpart
|
|
117
|
+
*/
|
|
118
|
+
type IsLiteralType<T, Base> = T extends Base ? Base extends T ? false : true : false;
|
|
119
|
+
/**
|
|
120
|
+
* Type utility to transform Asset types into builder friendly versions
|
|
121
|
+
* - 'foo' | 'bar' → 'foo' | 'bar' | TaggedTemplateValue (preserves literal unions)
|
|
122
|
+
* - string → string | TaggedTemplateValue
|
|
123
|
+
* - true | false → true | false | TaggedTemplateValue (preserves boolean literals)
|
|
124
|
+
* - boolean → boolean | TaggedTemplateValue
|
|
125
|
+
* - 42 | 100 → 42 | 100 | TaggedTemplateValue (preserves number literals)
|
|
126
|
+
* - number → number | TaggedTemplateValue
|
|
127
|
+
* - Asset → Asset | FluentBuilder<Asset, C>
|
|
128
|
+
* - AssetWrapper<T> → T | FluentBuilder<T, C>
|
|
129
|
+
* - Array<T> → Array<TransformType<T>>
|
|
130
|
+
* - Record<K, V> → Record<K, TransformType<V>>
|
|
131
|
+
*
|
|
132
|
+
* Uses a helper type to distinguish between literal and general types.
|
|
133
|
+
* For literal types, we preserve the exact literal and add TaggedTemplateValue.
|
|
134
|
+
* For general types, we use the general type and add TaggedTemplateValue.
|
|
135
|
+
*
|
|
136
|
+
* Order matters: we check for complex types first, then primitives.
|
|
137
|
+
*/
|
|
138
|
+
export type TransformType<T, C extends BaseBuildContext = BaseBuildContext> = T extends Asset & {
|
|
139
|
+
id: unknown;
|
|
140
|
+
} ? T | AnyAssetBuilder<C> : T extends {
|
|
141
|
+
asset: infer A;
|
|
142
|
+
} ? A | AnyAssetBuilder<C> : T extends Array<infer E> ? Array<TransformType<E>> : T extends Record<string, unknown> ? {
|
|
143
|
+
[K in keyof T]: TransformType<T[K], C>;
|
|
144
|
+
} : T extends string ? IsLiteralType<T, string> extends true ? T | TaggedTemplateValue : string | TaggedTemplateValue : T extends boolean ? IsLiteralType<T, boolean> extends true ? T | TaggedTemplateValue : boolean | TaggedTemplateValue : T extends number ? IsLiteralType<T, number> extends true ? T | TaggedTemplateValue : number | TaggedTemplateValue : T extends bigint ? IsLiteralType<T, bigint> extends true ? T | TaggedTemplateValue : bigint | TaggedTemplateValue : T;
|
|
145
|
+
/**
|
|
146
|
+
* Type utility to extract all properties from an Asset type including nested ones
|
|
147
|
+
* Makes all properties non-optional for the builder args
|
|
148
|
+
* Automatically adds applicability property for conditional asset visibility
|
|
149
|
+
*/
|
|
150
|
+
export type ExtractBuilderArgs<T> = {
|
|
151
|
+
[K in keyof T as K extends "type" ? never : K]: K extends "metaData" ? T[K] extends Record<string, unknown> ? {
|
|
152
|
+
[P in keyof T[K]]: TransformType<T[K][P]>;
|
|
153
|
+
} : TransformType<T[K]> : TransformType<T[K]>;
|
|
154
|
+
} & {
|
|
155
|
+
/**
|
|
156
|
+
* Applicability expression that conditionally shows or hides an asset
|
|
157
|
+
* (and all of its children) from the view tree. Dynamically calculated
|
|
158
|
+
* and automatically updates as data changes on the page.
|
|
159
|
+
*/
|
|
160
|
+
applicability?: string | TaggedTemplateValue;
|
|
161
|
+
};
|
|
162
|
+
export {};
|
|
163
|
+
//# sourceMappingURL=types.d.ts.map
|