@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.
Files changed (134) hide show
  1. package/dist/cjs/index.cjs +2396 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/index.legacy-esm.js +2276 -0
  4. package/dist/index.mjs +2276 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/package.json +38 -0
  7. package/src/core/base-builder/__tests__/fluent-builder-base.test.ts +2423 -0
  8. package/src/core/base-builder/__tests__/fluent-partial.test.ts +179 -0
  9. package/src/core/base-builder/__tests__/id-generator.test.ts +658 -0
  10. package/src/core/base-builder/__tests__/registry.test.ts +534 -0
  11. package/src/core/base-builder/__tests__/resolution-mixed-arrays.test.ts +319 -0
  12. package/src/core/base-builder/__tests__/resolution-pipeline.test.ts +416 -0
  13. package/src/core/base-builder/__tests__/resolution-switches.test.ts +468 -0
  14. package/src/core/base-builder/__tests__/resolution-templates.test.ts +255 -0
  15. package/src/core/base-builder/__tests__/switch.test.ts +815 -0
  16. package/src/core/base-builder/__tests__/template.test.ts +596 -0
  17. package/src/core/base-builder/__tests__/value-extraction.test.ts +200 -0
  18. package/src/core/base-builder/__tests__/value-storage.test.ts +459 -0
  19. package/src/core/base-builder/conditional/index.ts +64 -0
  20. package/src/core/base-builder/context.ts +152 -0
  21. package/src/core/base-builder/errors.ts +69 -0
  22. package/src/core/base-builder/fluent-builder-base.ts +308 -0
  23. package/src/core/base-builder/guards.ts +137 -0
  24. package/src/core/base-builder/id/generator.ts +290 -0
  25. package/src/core/base-builder/id/registry.ts +152 -0
  26. package/src/core/base-builder/index.ts +72 -0
  27. package/src/core/base-builder/resolution/path-resolver.ts +116 -0
  28. package/src/core/base-builder/resolution/pipeline.ts +103 -0
  29. package/src/core/base-builder/resolution/steps/__tests__/nested-asset-wrappers.test.ts +206 -0
  30. package/src/core/base-builder/resolution/steps/asset-id.ts +77 -0
  31. package/src/core/base-builder/resolution/steps/asset-wrappers.ts +64 -0
  32. package/src/core/base-builder/resolution/steps/builders.ts +84 -0
  33. package/src/core/base-builder/resolution/steps/mixed-arrays.ts +95 -0
  34. package/src/core/base-builder/resolution/steps/nested-asset-wrappers.ts +124 -0
  35. package/src/core/base-builder/resolution/steps/static-values.ts +35 -0
  36. package/src/core/base-builder/resolution/steps/switches.ts +71 -0
  37. package/src/core/base-builder/resolution/steps/templates.ts +40 -0
  38. package/src/core/base-builder/resolution/value-resolver.ts +333 -0
  39. package/src/core/base-builder/storage/auxiliary-storage.ts +82 -0
  40. package/src/core/base-builder/storage/value-storage.ts +282 -0
  41. package/src/core/base-builder/types.ts +266 -0
  42. package/src/core/base-builder/utils.ts +10 -0
  43. package/src/core/flow/__tests__/index.test.ts +292 -0
  44. package/src/core/flow/index.ts +118 -0
  45. package/src/core/index.ts +8 -0
  46. package/src/core/mocks/generated/action.builder.ts +92 -0
  47. package/src/core/mocks/generated/choice-item.builder.ts +120 -0
  48. package/src/core/mocks/generated/choice.builder.ts +134 -0
  49. package/src/core/mocks/generated/collection.builder.ts +93 -0
  50. package/src/core/mocks/generated/field-collection.builder.ts +86 -0
  51. package/src/core/mocks/generated/index.ts +10 -0
  52. package/src/core/mocks/generated/info.builder.ts +64 -0
  53. package/src/core/mocks/generated/input.builder.ts +63 -0
  54. package/src/core/mocks/generated/overview-collection.builder.ts +65 -0
  55. package/src/core/mocks/generated/splash-collection.builder.ts +93 -0
  56. package/src/core/mocks/generated/text.builder.ts +47 -0
  57. package/src/core/mocks/index.ts +1 -0
  58. package/src/core/mocks/types/action.ts +92 -0
  59. package/src/core/mocks/types/choice.ts +129 -0
  60. package/src/core/mocks/types/collection.ts +140 -0
  61. package/src/core/mocks/types/info.ts +7 -0
  62. package/src/core/mocks/types/input.ts +7 -0
  63. package/src/core/mocks/types/text.ts +5 -0
  64. package/src/core/schema/__tests__/index.test.ts +127 -0
  65. package/src/core/schema/index.ts +195 -0
  66. package/src/core/schema/types.ts +7 -0
  67. package/src/core/switch/__tests__/index.test.ts +156 -0
  68. package/src/core/switch/index.ts +81 -0
  69. package/src/core/tagged-template/README.md +448 -0
  70. package/src/core/tagged-template/__tests__/extract-bindings-from-schema.test.ts +207 -0
  71. package/src/core/tagged-template/__tests__/index.test.ts +190 -0
  72. package/src/core/tagged-template/__tests__/schema-std-integration.test.ts +580 -0
  73. package/src/core/tagged-template/binding.ts +95 -0
  74. package/src/core/tagged-template/expression.ts +92 -0
  75. package/src/core/tagged-template/extract-bindings-from-schema.ts +120 -0
  76. package/src/core/tagged-template/index.ts +5 -0
  77. package/src/core/tagged-template/std.ts +472 -0
  78. package/src/core/tagged-template/types.ts +123 -0
  79. package/src/core/template/__tests__/index.test.ts +380 -0
  80. package/src/core/template/index.ts +196 -0
  81. package/src/core/utils/index.ts +160 -0
  82. package/src/fp/README.md +411 -0
  83. package/src/fp/__tests__/index.test.ts +1178 -0
  84. package/src/fp/index.ts +386 -0
  85. package/src/gen/common.ts +15 -0
  86. package/src/index.ts +5 -0
  87. package/src/types.ts +203 -0
  88. package/types/core/base-builder/conditional/index.d.ts +21 -0
  89. package/types/core/base-builder/context.d.ts +39 -0
  90. package/types/core/base-builder/errors.d.ts +45 -0
  91. package/types/core/base-builder/fluent-builder-base.d.ts +147 -0
  92. package/types/core/base-builder/guards.d.ts +58 -0
  93. package/types/core/base-builder/id/generator.d.ts +69 -0
  94. package/types/core/base-builder/id/registry.d.ts +93 -0
  95. package/types/core/base-builder/index.d.ts +9 -0
  96. package/types/core/base-builder/resolution/path-resolver.d.ts +15 -0
  97. package/types/core/base-builder/resolution/pipeline.d.ts +27 -0
  98. package/types/core/base-builder/resolution/steps/asset-id.d.ts +14 -0
  99. package/types/core/base-builder/resolution/steps/asset-wrappers.d.ts +14 -0
  100. package/types/core/base-builder/resolution/steps/builders.d.ts +14 -0
  101. package/types/core/base-builder/resolution/steps/mixed-arrays.d.ts +14 -0
  102. package/types/core/base-builder/resolution/steps/nested-asset-wrappers.d.ts +14 -0
  103. package/types/core/base-builder/resolution/steps/static-values.d.ts +14 -0
  104. package/types/core/base-builder/resolution/steps/switches.d.ts +15 -0
  105. package/types/core/base-builder/resolution/steps/templates.d.ts +14 -0
  106. package/types/core/base-builder/resolution/value-resolver.d.ts +62 -0
  107. package/types/core/base-builder/storage/auxiliary-storage.d.ts +50 -0
  108. package/types/core/base-builder/storage/value-storage.d.ts +82 -0
  109. package/types/core/base-builder/types.d.ts +183 -0
  110. package/types/core/base-builder/utils.d.ts +2 -0
  111. package/types/core/flow/index.d.ts +23 -0
  112. package/types/core/index.d.ts +8 -0
  113. package/types/core/mocks/index.d.ts +2 -0
  114. package/types/core/mocks/types/action.d.ts +58 -0
  115. package/types/core/mocks/types/choice.d.ts +95 -0
  116. package/types/core/mocks/types/collection.d.ts +102 -0
  117. package/types/core/mocks/types/info.d.ts +7 -0
  118. package/types/core/mocks/types/input.d.ts +7 -0
  119. package/types/core/mocks/types/text.d.ts +5 -0
  120. package/types/core/schema/index.d.ts +34 -0
  121. package/types/core/schema/types.d.ts +5 -0
  122. package/types/core/switch/index.d.ts +21 -0
  123. package/types/core/tagged-template/binding.d.ts +19 -0
  124. package/types/core/tagged-template/expression.d.ts +11 -0
  125. package/types/core/tagged-template/extract-bindings-from-schema.d.ts +7 -0
  126. package/types/core/tagged-template/index.d.ts +6 -0
  127. package/types/core/tagged-template/std.d.ts +174 -0
  128. package/types/core/tagged-template/types.d.ts +69 -0
  129. package/types/core/template/index.d.ts +97 -0
  130. package/types/core/utils/index.d.ts +47 -0
  131. package/types/fp/index.d.ts +149 -0
  132. package/types/gen/common.d.ts +6 -0
  133. package/types/index.d.ts +3 -0
  134. package/types/types.d.ts +163 -0
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Error codes for fluent builder errors.
3
+ * Use these codes for programmatic error handling.
4
+ */
5
+ export declare const ErrorCodes: {
6
+ /** Context is missing when required */
7
+ readonly MISSING_CONTEXT: "FLUENT_MISSING_CONTEXT";
8
+ /** Invalid branch type in ID generation */
9
+ readonly INVALID_BRANCH: "FLUENT_INVALID_BRANCH";
10
+ /** Template produced no output */
11
+ readonly TEMPLATE_NO_OUTPUT: "FLUENT_TEMPLATE_NO_OUTPUT";
12
+ /** Invalid path in value resolution */
13
+ readonly INVALID_PATH: "FLUENT_INVALID_PATH";
14
+ };
15
+ /**
16
+ * Type for error codes
17
+ */
18
+ export type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
19
+ /**
20
+ * Custom error class for fluent builder errors.
21
+ * Provides structured error information with error codes.
22
+ */
23
+ export declare class FluentError extends Error {
24
+ readonly code: ErrorCode;
25
+ readonly context?: Record<string, unknown>;
26
+ constructor(code: ErrorCode, message: string, context?: Record<string, unknown>);
27
+ }
28
+ /**
29
+ * Creates a FluentError with the given code and message.
30
+ * This is a convenience function for creating errors.
31
+ *
32
+ * @param code - The error code from ErrorCodes
33
+ * @param message - Human-readable error message
34
+ * @param context - Optional context object with additional details
35
+ * @returns A FluentError instance
36
+ *
37
+ * @example
38
+ * throw createFluentError(
39
+ * ErrorCodes.MISSING_CONTEXT,
40
+ * "Context is required for template resolution",
41
+ * { templateCount: 3 }
42
+ * );
43
+ */
44
+ export declare function createFluentError(code: ErrorCode, message: string, context?: Record<string, unknown>): FluentError;
45
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,147 @@
1
+ import type { template as easyDslTemplate } from "..";
2
+ import { type BaseBuildContext, type ConditionalValue, type FluentPartial, FLUENT_BUILDER_SYMBOL } from "./types";
3
+ import { ValueStorage } from "./storage/value-storage";
4
+ import { AuxiliaryStorage } from "./storage/auxiliary-storage";
5
+ import { switch_ } from "../switch";
6
+ /**
7
+ * Base class for all generated builders
8
+ * Provides core functionality for the builder pattern with Player UI-specific features
9
+ *
10
+ * This class delegates to specialized components:
11
+ * - ValueStorage: Manages property values, builders, and mixed arrays
12
+ * - AuxiliaryStorage: Manages metadata (templates, switches)
13
+ * - Build Pipeline: Orchestrates the 8-step build process
14
+ * - Conditional Logic: Handles if/ifElse with auto-wrapping
15
+ */
16
+ export declare abstract class FluentBuilderBase<T, C extends BaseBuildContext = BaseBuildContext> {
17
+ readonly [FLUENT_BUILDER_SYMBOL]: true;
18
+ protected valueStorage: ValueStorage<T>;
19
+ protected auxiliaryStorage: AuxiliaryStorage;
20
+ protected context?: C;
21
+ /**
22
+ * Creates a new builder instance
23
+ * @param initial - Optional initial values (accepts FluentPartial for TaggedTemplateValue support)
24
+ */
25
+ constructor(initial?: FluentPartial<T, C>);
26
+ /**
27
+ * Accessor for generated builders to access values
28
+ * This maintains backward compatibility with generated code
29
+ */
30
+ protected get values(): Partial<T>;
31
+ /**
32
+ * Setter for generated builders to set values in bulk
33
+ * Used by withAdditionalProperties() in generated builders
34
+ */
35
+ protected set values(newValues: Partial<T>);
36
+ /**
37
+ * Sets additional properties in bulk that may not be defined in the type schema
38
+ * Useful for extensibility and forward compatibility
39
+ */
40
+ withAdditionalProperties(values: Partial<T>): this;
41
+ /**
42
+ * Sets a property value, intelligently routing it to the appropriate storage
43
+ * @param key - The property key to set
44
+ * @param value - The value to set
45
+ * @returns This builder instance for chaining
46
+ */
47
+ protected set<K extends keyof T>(key: K, value: unknown): this;
48
+ /**
49
+ * Builds the final object with defaults and nested builder resolution
50
+ * Executes the complete 8-step build pipeline
51
+ *
52
+ * @param defaults - Optional default values
53
+ * @param context - Optional build context
54
+ */
55
+ protected buildWithDefaults(defaults?: Partial<T>, context?: C): T;
56
+ /**
57
+ * Gets array property metadata from the builder class
58
+ * Generated builders include a static __arrayProperties__ set
59
+ */
60
+ private getArrayPropertiesMetadata;
61
+ /**
62
+ * Gets asset wrapper paths metadata from the builder class.
63
+ * Generated builders include a static __assetWrapperPaths__ array of paths.
64
+ * Each path is an array of property names leading to an AssetWrapper.
65
+ */
66
+ protected getAssetWrapperPathsMetadata(): ReadonlyArray<ReadonlyArray<string>>;
67
+ /**
68
+ * Conditionally sets a property based on a predicate
69
+ *
70
+ * Accepts unwrapped Asset builders and automatically wraps them in AssetWrapper format.
71
+ *
72
+ * @param predicate - Function to determine if the property should be set
73
+ * @param property - The property key
74
+ * @param value - The value, builder, or function returning either
75
+ *
76
+ * @example
77
+ * action()
78
+ * .if(() => showLabel, "label", text().withValue("Submit"))
79
+ */
80
+ if<K extends keyof T>(predicate: (builder: this) => boolean, property: K, value: ConditionalValue<T[K], C>): this;
81
+ /**
82
+ * Conditionally sets a property choosing between two values
83
+ *
84
+ * Accepts unwrapped Asset builders and automatically wraps them in AssetWrapper format.
85
+ *
86
+ * @param predicate - Function to determine which value to use
87
+ * @param property - The property key
88
+ * @param trueValue - Value to use if predicate is true
89
+ * @param falseValue - Value to use if predicate is false
90
+ *
91
+ * @example
92
+ * action()
93
+ * .ifElse(
94
+ * () => isActive,
95
+ * "label",
96
+ * text().withValue("Deactivate"),
97
+ * text().withValue("Activate")
98
+ * )
99
+ */
100
+ ifElse<K extends keyof T>(predicate: (builder: this) => boolean, property: K, trueValue: ConditionalValue<T[K], C>, falseValue: ConditionalValue<T[K], C>): this;
101
+ /**
102
+ * Checks if a property has been set
103
+ */
104
+ has<K extends keyof T>(key: K): boolean;
105
+ /**
106
+ * Peeks at a property value without resolving builders
107
+ */
108
+ peek<K extends keyof T>(key: K): T[K] | undefined;
109
+ /**
110
+ * Gets builder for a property if one is set
111
+ */
112
+ peekBuilder<K extends keyof T>(key: K): import("./types").FluentBuilder<T[K], C> | undefined;
113
+ /**
114
+ * Gets the type of value stored for a property
115
+ */
116
+ getValueType<K extends keyof T>(key: K): "static" | "builder" | "mixed-array" | "unset";
117
+ /**
118
+ * Clones the builder, creating an independent copy with the same state.
119
+ *
120
+ * Note: This method requires that the builder class has a constructor that
121
+ * accepts an optional `initial` parameter (like all generated builders do).
122
+ * If your custom builder has required constructor parameters, you must
123
+ * override this method.
124
+ */
125
+ clone(): this;
126
+ /**
127
+ * Unsets a property, removing it from the builder
128
+ */
129
+ unset<K extends keyof T>(key: K): this;
130
+ /**
131
+ * Clears all properties from the builder, resetting it to initial state
132
+ */
133
+ clear(): this;
134
+ /**
135
+ * Adds a template to this builder
136
+ */
137
+ template(templateFn: ReturnType<typeof easyDslTemplate>): this;
138
+ /**
139
+ * Adds a switch to this builder at a specific path
140
+ */
141
+ switch(path: ReadonlyArray<string | number>, switchFnArgs: Parameters<typeof switch_>[0]): this;
142
+ /**
143
+ * Abstract build method to be implemented by generated builders
144
+ */
145
+ abstract build(context?: C): T;
146
+ }
147
+ //# sourceMappingURL=fluent-builder-base.d.ts.map
@@ -0,0 +1,58 @@
1
+ import type { Asset, AssetWrapper } from "@player-ui/types";
2
+ import type { BaseBuildContext, FluentBuilder } from "./types";
3
+ /**
4
+ * Type guard to check if a value is a FluentBuilder instance
5
+ * Checks for the builder symbol and build method
6
+ */
7
+ export declare function isFluentBuilder<T = unknown, C extends BaseBuildContext = BaseBuildContext>(value: unknown): value is FluentBuilder<T, C>;
8
+ /**
9
+ * Type guard to check if a value is an array of FluentBuilders
10
+ */
11
+ export declare function isBuilderArray<T = unknown, C extends BaseBuildContext = BaseBuildContext>(value: unknown): value is Array<FluentBuilder<T, C>>;
12
+ /**
13
+ * Type guard to check if a value is a plain object (not a class instance)
14
+ * Returns true for objects created with {} or Object.create(null)
15
+ */
16
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
17
+ /**
18
+ * Type guard to check if a value is an Asset (has required 'type' property)
19
+ * Assets are the core building blocks in Player UI
20
+ */
21
+ export declare function isAsset(value: unknown): value is Asset;
22
+ /**
23
+ * Type guard to check if a value is an AssetWrapper
24
+ * AssetWrapper has a single 'asset' property containing the wrapped value
25
+ */
26
+ export declare function isAssetWrapper<T extends Asset = Asset>(value: unknown): value is AssetWrapper<T>;
27
+ /**
28
+ * Type guard to check if a value is an AssetWrapper containing an Asset
29
+ * More strict than isAssetWrapper - verifies the wrapped value is actually an Asset
30
+ */
31
+ export declare function isAssetWrapperWithAsset<T extends Asset = Asset>(value: unknown): value is AssetWrapper<T>;
32
+ /**
33
+ * Type guard to check if a value is an AssetWrapper value object
34
+ * This is the internal representation: { asset: unknown }
35
+ * Used to detect values that need special handling during build
36
+ */
37
+ export declare function isAssetWrapperValue(value: unknown): value is {
38
+ asset: unknown;
39
+ };
40
+ /**
41
+ * Determines if a property value needs to be wrapped in AssetWrapper format
42
+ * Used during value storage to decide wrapping strategy
43
+ */
44
+ export declare function needsAssetWrapper(value: unknown): boolean;
45
+ /**
46
+ * Type guard to check if a value is a switch result object
47
+ * Switch results contain staticSwitch or dynamicSwitch arrays
48
+ */
49
+ export declare function isSwitchResult(value: unknown): value is Record<string, unknown> & {
50
+ staticSwitch?: unknown[];
51
+ dynamicSwitch?: unknown[];
52
+ };
53
+ /**
54
+ * Type guard to check if a value is a string or undefined
55
+ * Useful for validating optional string properties
56
+ */
57
+ export declare function isStringOrUndefined(value: unknown): value is string | undefined;
58
+ //# sourceMappingURL=guards.d.ts.map
@@ -0,0 +1,69 @@
1
+ import { type AssetMetadata, type BaseBuildContext } from "../types";
2
+ export { globalIdRegistry, createIdRegistry, IDRegistry } from "./registry";
3
+ /**
4
+ * Resets the global ID registry, clearing all registered IDs.
5
+ * This is useful for testing scenarios where you need a clean slate.
6
+ */
7
+ export declare const resetGlobalIdSet: () => void;
8
+ /**
9
+ * Generates an ID without registering it in the global registry.
10
+ * This is useful for intermediate ID lookups where you don't want to consume the ID.
11
+ *
12
+ * @param context - The context containing parent ID and optional branch information
13
+ * @returns The generated ID (without collision detection or registration)
14
+ *
15
+ * @example
16
+ * // Use this when you need to generate a parent ID for nested context creation
17
+ * const parentId = peekId({ parentId: 'collection' }); // Doesn't register 'collection'
18
+ * const nestedCtx = { parentId, branch: { type: 'slot', name: 'label' } };
19
+ */
20
+ export declare const peekId: (context: BaseBuildContext) => string;
21
+ /**
22
+ * Generates a unique identifier based on the parent ID and branch information.
23
+ *
24
+ * This function creates hierarchical IDs for various element types in a DSL structure,
25
+ * maintaining relationships between parent and child elements through consistent naming patterns.
26
+ * IDs are automatically checked for uniqueness and modified if collisions are detected.
27
+ *
28
+ * @param {BaseBuildContext} context - The context containing parent ID and optional branch information
29
+ * @param {string} context.parentId - The ID of the parent element
30
+ * @param {IdBranch} [context.branch] - Optional branch information to specify the type of child element
31
+ *
32
+ * @returns {string} A generated ID string representing the element's unique identifier
33
+ *
34
+ * @throws {Error} If context is invalid or incomplete
35
+ *
36
+ * @example
37
+ * // Slot branch
38
+ * genId({ parentId: 'parent', branch: { type: 'slot', name: 'header' } })
39
+ * // Returns: 'parent-header'
40
+ *
41
+ * @example
42
+ * // Array item branch
43
+ * genId({ parentId: 'list', branch: { type: 'array-item', index: 2 } })
44
+ * // Returns: 'list-2'
45
+ *
46
+ * @example
47
+ * // Template branch
48
+ * genId({ parentId: 'template', branch: { type: 'template', depth: 1 } })
49
+ * // Returns: 'template-_index1_'
50
+ *
51
+ * @example
52
+ * // Switch branch
53
+ * genId({ parentId: 'condition', branch: { type: 'switch', index: 0, kind: 'static' } })
54
+ * // Returns: 'condition-staticSwitch-0'
55
+ *
56
+ * @example
57
+ * // Custom ID case (no branch)
58
+ * genId({ parentId: 'custom-id' })
59
+ * // Returns: 'custom-id'
60
+ */
61
+ export declare const genId: (context: BaseBuildContext) => string;
62
+ export declare function determineSlotName(parameterName: string, assetMetadata?: AssetMetadata): string;
63
+ export declare function generateAssetId<C extends BaseBuildContext>(params: {
64
+ readonly context?: C;
65
+ readonly parameterName?: string;
66
+ readonly assetMetadata?: AssetMetadata;
67
+ readonly explicitId?: string;
68
+ }): string;
69
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1,93 @@
1
+ /**
2
+ * ID Registry for tracking and ensuring unique IDs across asset generation.
3
+ * This registry maintains a set of used IDs and provides collision resolution
4
+ * by appending numeric suffixes when duplicates are detected.
5
+ *
6
+ * Special handling for template placeholders:
7
+ * - IDs ending with template placeholders like `_index_`, `_row_` are allowed to be duplicated
8
+ * - IDs with placeholders followed by additional segments enforce uniqueness normally
9
+ */
10
+ export declare class IDRegistry {
11
+ private usedIds;
12
+ private isEnabled;
13
+ constructor(enabled?: boolean);
14
+ /**
15
+ * Ensures the given ID is unique, modifying it if necessary.
16
+ * If the ID already exists, appends a numeric suffix (-1, -2, etc.)
17
+ * until a unique ID is found.
18
+ *
19
+ * Special handling for template placeholders:
20
+ * - IDs ending with `_index_`, `_row_`, etc. are allowed as duplicates
21
+ * - IDs with placeholders followed by segments (e.g., `_index_.field`) enforce uniqueness
22
+ *
23
+ * @param baseId - The desired ID
24
+ * @returns A unique ID (either the original or modified with suffix)
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const registry = new IDRegistry();
29
+ * registry.ensureUnique("my-id"); // "my-id"
30
+ * registry.ensureUnique("my-id"); // "my-id-1"
31
+ * registry.ensureUnique("list-_index_"); // "list-_index_" (allowed duplicate)
32
+ * registry.ensureUnique("list-_index_"); // "list-_index_" (allowed duplicate)
33
+ * ```
34
+ */
35
+ ensureUnique(baseId: string): string;
36
+ /**
37
+ * Checks if an ID has already been used.
38
+ *
39
+ * @param id - The ID to check
40
+ * @returns true if the ID has been used, false otherwise
41
+ */
42
+ has(id: string): boolean;
43
+ /**
44
+ * Clears all registered IDs from the registry.
45
+ * Useful for resetting state between test runs or separate flows.
46
+ */
47
+ reset(): void;
48
+ /**
49
+ * Enables or disables the uniqueness checking.
50
+ * When disabled, all IDs pass through unchanged.
51
+ *
52
+ * @param enabled - Whether to enable uniqueness checking
53
+ */
54
+ setEnabled(enabled: boolean): void;
55
+ /**
56
+ * Returns the number of unique IDs currently registered.
57
+ *
58
+ * @returns The count of registered IDs
59
+ */
60
+ size(): number;
61
+ /**
62
+ * Returns a snapshot of all registered IDs.
63
+ * Useful for debugging and testing.
64
+ *
65
+ * @returns An array of all registered IDs
66
+ */
67
+ getRegisteredIds(): string[];
68
+ /**
69
+ * Checks if an ID contains template placeholders that should be exempt from uniqueness checks.
70
+ * Template placeholders are patterns like `_index_`, `_index1_`, `_row_` that are replaced at runtime.
71
+ *
72
+ * IDs ending with just a placeholder (e.g., "parent-_index_") are allowed as duplicates.
73
+ * IDs with placeholders followed by additional segments (e.g., "parent-_index_-field") are not.
74
+ *
75
+ * @param id - The ID to check
76
+ * @returns true if the ID should be exempt from uniqueness checks
77
+ */
78
+ private isTemplatePlaceholderID;
79
+ }
80
+ /**
81
+ * Global singleton instance of the ID registry.
82
+ * This ensures consistent ID tracking across the entire application.
83
+ */
84
+ export declare const globalIdRegistry: IDRegistry;
85
+ /**
86
+ * Creates a new isolated ID registry instance.
87
+ * Useful for testing or when you need separate ID tracking contexts.
88
+ *
89
+ * @param enabled - Whether the registry should be enabled by default
90
+ * @returns A new IDRegistry instance
91
+ */
92
+ export declare function createIdRegistry(enabled?: boolean): IDRegistry;
93
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1,9 @@
1
+ export { FLUENT_BUILDER_SYMBOL, BranchTypes, StorageKeys, PropertyKeys, type NestedContextParams, type NestedContextGenerator, type AssetMetadata, type BaseBuildContext, type FluentBuilder, type AnyAssetBuilder, type MixedArrayMetadata, type TemplateMetadata, type IdBranch, type SlotBranch, type ArrayItemBranch, type TemplateBranch, type SwitchBranch, type CustomBranch, type ValuePath, type SwitchMetadata, type ConditionalValue, type FluentPartial, type FluentPartialValue, } from "./types";
2
+ export { isFluentBuilder, isBuilderArray, isPlainObject, isAsset, isAssetWrapper, isAssetWrapperWithAsset, needsAssetWrapper, isAssetWrapperValue, isSwitchResult, isStringOrUndefined, } from "./guards";
3
+ export { determineSlotName, generateAssetId, genId, peekId, resetGlobalIdSet, globalIdRegistry, createIdRegistry, IDRegistry, } from "./id/generator";
4
+ export { createNestedContext, createTemplateContext, createSwitchContext, } from "./context";
5
+ export { extractValue, resolveValue, resolveAndWrapAsset, } from "./resolution/value-resolver";
6
+ export { FluentBuilderBase } from "./fluent-builder-base";
7
+ export { createInspectMethod } from "./utils";
8
+ export { ErrorCodes, FluentError, createFluentError, type ErrorCode, } from "./errors";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { ValuePath } from "../types";
2
+ /**
3
+ * Sets a value at a nested path in an object
4
+ * Handles nested objects, arrays, and AssetWrapper structures
5
+ *
6
+ * @param obj - The target object to modify
7
+ * @param path - Array of keys/indices representing the path
8
+ * @param value - The value to set at the path
9
+ *
10
+ * @example
11
+ * setValueAtPath(obj, ["actions", 0, "label"], "Click me")
12
+ * // Sets obj.actions[0].label = "Click me"
13
+ */
14
+ export declare function setValueAtPath(obj: Record<string, unknown>, path: ValuePath, value: unknown): void;
15
+ //# sourceMappingURL=path-resolver.d.ts.map
@@ -0,0 +1,27 @@
1
+ import type { BaseBuildContext } from "../types";
2
+ import type { ValueStorage } from "../storage/value-storage";
3
+ import type { AuxiliaryStorage } from "../storage/auxiliary-storage";
4
+ /**
5
+ * Executes the complete build pipeline
6
+ *
7
+ * The pipeline consists of 9 steps that transform builder state into a final object:
8
+ * 1. Resolve static values (extract TaggedTemplateValue, resolve simple builders)
9
+ * 2. Generate asset ID if needed
10
+ * 3. Create nested context for child assets
11
+ * 4. Resolve AssetWrapper values
12
+ * 5. Resolve mixed arrays
13
+ * 6. Resolve builders
14
+ * 7. Resolve nested AssetWrapper paths
15
+ * 8. Resolve switches
16
+ * 9. Resolve templates
17
+ *
18
+ * @param valueStorage - Storage containing property values
19
+ * @param auxiliaryStorage - Storage containing metadata (templates, switches)
20
+ * @param defaults - Optional default values to merge into result
21
+ * @param context - Optional build context
22
+ * @param arrayProperties - Set of property names that are array types
23
+ * @param assetWrapperPaths - Paths to nested AssetWrapper properties
24
+ * @returns The fully built object
25
+ */
26
+ export declare function executeBuildPipeline<T, C extends BaseBuildContext>(valueStorage: ValueStorage<T>, auxiliaryStorage: AuxiliaryStorage, defaults: Partial<T> | undefined, context: C | undefined, arrayProperties: ReadonlySet<string>, assetWrapperPaths?: ReadonlyArray<ReadonlyArray<string>>): T;
27
+ //# sourceMappingURL=pipeline.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { BaseBuildContext } from "../../types";
2
+ import type { ValueStorage } from "../../storage/value-storage";
3
+ /**
4
+ * Step 2: Generates ID for this asset if needed
5
+ *
6
+ * Note: This runs AFTER resolveStaticValues, so we use values from result
7
+ * rather than from storage.
8
+ *
9
+ * @param storage - The value storage (used to check if ID was explicitly set)
10
+ * @param result - The result object being built (contains resolved values)
11
+ * @param context - Optional build context
12
+ */
13
+ export declare function generateAssetIdForBuilder<T, C extends BaseBuildContext>(storage: ValueStorage<T>, result: Record<string, unknown>, context: C | undefined): void;
14
+ //# sourceMappingURL=asset-id.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { BaseBuildContext } from "../../types";
2
+ import type { ValueStorage } from "../../storage/value-storage";
3
+ /**
4
+ * Step 4: Resolves AssetWrapper values in static storage
5
+ *
6
+ * Processes values that were marked as AssetWrapper during value setting.
7
+ * These values contain assets or builders that need special context handling.
8
+ *
9
+ * @param storage - The value storage
10
+ * @param result - The result object being built
11
+ * @param nestedParentContext - Context for nested assets
12
+ */
13
+ export declare function resolveAssetWrappers<T, C extends BaseBuildContext>(storage: ValueStorage<T>, result: Record<string, unknown>, nestedParentContext: C | undefined): void;
14
+ //# sourceMappingURL=asset-wrappers.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { BaseBuildContext } from "../../types";
2
+ import type { ValueStorage } from "../../storage/value-storage";
3
+ /**
4
+ * Step 6: Resolves regular builders (non-array)
5
+ *
6
+ * Processes FluentBuilder instances and objects containing builders.
7
+ * Creates nested contexts for proper ID generation.
8
+ *
9
+ * @param storage - The value storage
10
+ * @param result - The result object being built
11
+ * @param nestedParentContext - Context for nested builders
12
+ */
13
+ export declare function resolveBuilders<T, C extends BaseBuildContext>(storage: ValueStorage<T>, result: Record<string, unknown>, nestedParentContext: C | undefined): void;
14
+ //# sourceMappingURL=builders.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { BaseBuildContext } from "../../types";
2
+ import type { ValueStorage } from "../../storage/value-storage";
3
+ /**
4
+ * Step 5: Resolves mixed arrays
5
+ *
6
+ * Processes arrays containing both builders and static values.
7
+ * Builders are resolved with proper context, static values pass through.
8
+ *
9
+ * @param storage - The value storage
10
+ * @param result - The result object being built
11
+ * @param nestedParentContext - Context for nested builders
12
+ */
13
+ export declare function resolveMixedArrays<T, C extends BaseBuildContext>(storage: ValueStorage<T>, result: Record<string, unknown>, nestedParentContext: C | undefined): void;
14
+ //# sourceMappingURL=mixed-arrays.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { BaseBuildContext } from "../../types";
2
+ /**
3
+ * Step 7: Resolves nested AssetWrapper paths
4
+ *
5
+ * This step handles cases where AssetWrapper properties are nested within
6
+ * interface types. It traverses paths like ["header", "left"] to find and
7
+ * wrap assets that should be in AssetWrapper format.
8
+ *
9
+ * @param result - The result object being built
10
+ * @param context - Context for nested assets
11
+ * @param assetWrapperPaths - Array of paths to AssetWrapper properties
12
+ */
13
+ export declare function resolveNestedAssetWrappers<C extends BaseBuildContext>(result: Record<string, unknown>, context: C | undefined, assetWrapperPaths: ReadonlyArray<ReadonlyArray<string>>): void;
14
+ //# sourceMappingURL=nested-asset-wrappers.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { BaseBuildContext } from "../../types";
2
+ import type { ValueStorage } from "../../storage/value-storage";
3
+ /**
4
+ * Step 1: Resolves static values
5
+ *
6
+ * Converts TaggedTemplateValue to strings and resolves nested FluentBuilders
7
+ * in static storage. AssetWrapper values are preserved for later processing.
8
+ *
9
+ * @param storage - The value storage containing static values
10
+ * @param result - The result object being built
11
+ * @param context - Optional build context
12
+ */
13
+ export declare function resolveStaticValues<T, C extends BaseBuildContext>(storage: ValueStorage<T>, result: Record<string, unknown>, context: C | undefined): void;
14
+ //# sourceMappingURL=static-values.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { type BaseBuildContext } from "../../types";
2
+ import type { AuxiliaryStorage } from "../../storage/auxiliary-storage";
3
+ /**
4
+ * Step 7: Resolves switches
5
+ *
6
+ * Processes switch expressions and injects them at the specified paths.
7
+ * Handles both static and dynamic switches with proper ID generation.
8
+ *
9
+ * @param auxiliaryStorage - Storage containing switch metadata
10
+ * @param result - The result object being built
11
+ * @param nestedParentContext - Context for switch resolution
12
+ * @param arrayProperties - Set of property names that are array types
13
+ */
14
+ export declare function resolveSwitches<C extends BaseBuildContext>(auxiliaryStorage: AuxiliaryStorage, result: Record<string, unknown>, nestedParentContext: C | undefined, arrayProperties: ReadonlySet<string>): void;
15
+ //# sourceMappingURL=switches.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { type BaseBuildContext } from "../../types";
2
+ import type { AuxiliaryStorage } from "../../storage/auxiliary-storage";
3
+ /**
4
+ * Step 8: Resolves templates
5
+ *
6
+ * Processes template functions and adds them to the result.
7
+ * Templates are special constructs that generate dynamic content.
8
+ *
9
+ * @param auxiliaryStorage - Storage containing template functions
10
+ * @param result - The result object being built
11
+ * @param context - Build context for template resolution
12
+ */
13
+ export declare function resolveTemplates<C extends BaseBuildContext>(auxiliaryStorage: AuxiliaryStorage, result: Record<string, unknown>, context: C | undefined): void;
14
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1,62 @@
1
+ import type { Asset, AssetWrapper } from "@player-ui/types";
2
+ import { type BaseBuildContext } from "../types";
3
+ /**
4
+ * Type-safe value extraction utilities for handling TaggedTemplateValue
5
+ * These functions properly unwrap TaggedTemplateValue while preserving structure
6
+ */
7
+ interface ExtractValueOptions {
8
+ readonly propertyKey?: string;
9
+ readonly visited?: WeakSet<object>;
10
+ }
11
+ /**
12
+ * Recursively extracts values from a structure, converting TaggedTemplateValue instances
13
+ * to their string representations while preserving arrays and objects.
14
+ *
15
+ * **Return Type Note**: This function returns `unknown` because the input type is unknown
16
+ * and the transformation can change types (TaggedTemplateValue -> string). Callers should
17
+ * validate the returned value using type guards before using it.
18
+ *
19
+ * **Transformation Behavior**:
20
+ * - `TaggedTemplateValue` → `string` (via toString() or toValue())
21
+ * - Arrays → Arrays (elements recursively transformed)
22
+ * - Plain objects → Objects (properties recursively transformed)
23
+ * - FluentBuilder/AssetWrapper → passed through unchanged (resolved later)
24
+ * - Primitives → passed through unchanged
25
+ *
26
+ * @param value - The value to extract (may contain TaggedTemplateValue instances)
27
+ * @param options - Extraction options (propertyKey for special handling, visited for cycle detection)
28
+ * @returns The extracted value with TaggedTemplateValue instances converted to strings
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const result = extractValue({ name: taggedTemplate`Hello` });
33
+ * // result is { name: "Hello" } but typed as unknown
34
+ *
35
+ * // Caller must validate:
36
+ * if (isPlainObject(result)) {
37
+ * const name = result.name; // Use safely
38
+ * }
39
+ * ```
40
+ */
41
+ export declare function extractValue(value: unknown, options?: ExtractValueOptions): unknown;
42
+ interface ResolveValueOptions<C extends BaseBuildContext = BaseBuildContext> {
43
+ readonly context?: C;
44
+ readonly propertyName?: string;
45
+ readonly visited?: WeakSet<object>;
46
+ }
47
+ /**
48
+ * Resolves a value, handling FluentBuilders, AssetWrappers, and nested structures
49
+ */
50
+ export declare function resolveValue<T, C extends BaseBuildContext>(value: unknown, options?: ResolveValueOptions<C>): unknown;
51
+ interface ResolveAndWrapAssetOptions<C extends BaseBuildContext = BaseBuildContext> {
52
+ readonly context?: C;
53
+ readonly slotName: string;
54
+ readonly visited?: WeakSet<object>;
55
+ }
56
+ /**
57
+ * Resolves and wraps a nested asset value
58
+ * This is used when we know a property should contain an AssetWrapper
59
+ */
60
+ export declare function resolveAndWrapAsset<C extends BaseBuildContext>(value: unknown, options: ResolveAndWrapAssetOptions<C>): AssetWrapper<Asset> | unknown;
61
+ export {};
62
+ //# sourceMappingURL=value-resolver.d.ts.map