@procedures/splay 0.0.0-stage → 0.2.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE +21 -0
  3. package/README.md +408 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/components/define.d.ts +134 -0
  6. package/dist/components/define.d.ts.map +1 -0
  7. package/dist/components/define.js +486 -0
  8. package/dist/components/define.js.map +1 -0
  9. package/dist/components/index.d.ts +39 -0
  10. package/dist/components/index.d.ts.map +1 -0
  11. package/dist/components/index.js +38 -0
  12. package/dist/components/index.js.map +1 -0
  13. package/dist/components/types.d.ts +264 -0
  14. package/dist/components/types.d.ts.map +1 -0
  15. package/dist/components/types.js +46 -0
  16. package/dist/components/types.js.map +1 -0
  17. package/dist/hydrate.d.ts +126 -0
  18. package/dist/hydrate.d.ts.map +1 -0
  19. package/dist/hydrate.js +226 -0
  20. package/dist/hydrate.js.map +1 -0
  21. package/dist/index.d.ts +40 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +53 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/module.d.ts +24 -0
  26. package/dist/module.d.ts.map +1 -0
  27. package/dist/module.js +68 -0
  28. package/dist/module.js.map +1 -0
  29. package/dist/register.d.ts +7 -0
  30. package/dist/register.d.ts.map +1 -0
  31. package/dist/register.js +9 -0
  32. package/dist/register.js.map +1 -0
  33. package/dist/registry.d.ts +60 -0
  34. package/dist/registry.d.ts.map +1 -0
  35. package/dist/registry.js +191 -0
  36. package/dist/registry.js.map +1 -0
  37. package/dist/streaming.d.ts +94 -0
  38. package/dist/streaming.d.ts.map +1 -0
  39. package/dist/streaming.js +422 -0
  40. package/dist/streaming.js.map +1 -0
  41. package/dist/types.d.ts +85 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +7 -0
  44. package/dist/types.js.map +1 -0
  45. package/package.json +76 -3
  46. package/src/components/define.ts +600 -0
  47. package/src/components/index.ts +78 -0
  48. package/src/components/types.ts +357 -0
  49. package/src/hydrate.ts +355 -0
  50. package/src/index.ts +110 -0
  51. package/src/module.ts +93 -0
  52. package/src/register.ts +11 -0
  53. package/src/registry.ts +257 -0
  54. package/src/streaming.ts +554 -0
  55. package/src/types.ts +114 -0
@@ -0,0 +1,264 @@
1
+ /**
2
+ * Component Types
3
+ *
4
+ * Components are procedures that return serializable UI descriptors.
5
+ * This enables SSR, caching, and transport over wire.
6
+ *
7
+ * Components integrate with splay's rendering model where a renderer
8
+ * produces output based on data, size, and path context.
9
+ */
10
+ import type { ZodLike } from "@procedures/client/client";
11
+ import type { ProcedureMetadata, ProcedurePath } from "@procedures/client";
12
+ import type { IEventBus as EventBus } from "@procedures/client";
13
+ /**
14
+ * Serializable component output descriptor.
15
+ * Can be transported over wire, cached, and hydrated by any framework.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const descriptor: ComponentOutput = {
20
+ * type: "user-card",
21
+ * props: {
22
+ * name: "John Doe",
23
+ * avatar: "/images/john.png",
24
+ * },
25
+ * children: [
26
+ * { type: "badge", props: { label: "Admin" } },
27
+ * ],
28
+ * };
29
+ * ```
30
+ */
31
+ export interface ComponentOutput {
32
+ /** Component type identifier (maps to registered component) */
33
+ type: string;
34
+ /** Serializable props for the component */
35
+ props: Record<string, unknown>;
36
+ /** Nested child descriptors (optional) */
37
+ children?: ComponentOutput[];
38
+ /** Component key for reconciliation (optional) */
39
+ key?: string;
40
+ }
41
+ /**
42
+ * Fragment output - multiple components without wrapper.
43
+ */
44
+ export interface FragmentOutput {
45
+ type: "__fragment__";
46
+ children: ComponentOutput[];
47
+ }
48
+ /**
49
+ * Null output - render nothing.
50
+ */
51
+ export interface NullOutput {
52
+ type: "__null__";
53
+ }
54
+ /**
55
+ * Any valid component output.
56
+ */
57
+ export type AnyComponentOutput = ComponentOutput | FragmentOutput | NullOutput;
58
+ /**
59
+ * Size information for responsive rendering.
60
+ */
61
+ export interface Size {
62
+ width: number;
63
+ height: number;
64
+ }
65
+ /**
66
+ * Context passed to component factories.
67
+ * Compatible with splay's RenderContext.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * factory: (ctx) => ({
72
+ * type: "user-card",
73
+ * props: {
74
+ * user: ctx.data,
75
+ * compact: ctx.size.width < 400,
76
+ * },
77
+ * children: ctx.data.posts?.map((post, i) =>
78
+ * ctx.render(post, ctx.size, `${ctx.path}.posts[${i}]`)
79
+ * ),
80
+ * })
81
+ * ```
82
+ */
83
+ export interface ComponentContext<TData = unknown> {
84
+ /** Input data for the component */
85
+ data: TData;
86
+ /** Available rendering size */
87
+ size: Size;
88
+ /** Path in the render tree (for debugging and keys) */
89
+ path: string;
90
+ /** Current depth in the render tree */
91
+ depth: number;
92
+ /**
93
+ * Render a child component.
94
+ * Delegates to the renderer to produce a ComponentOutput.
95
+ *
96
+ * @param data - Data for the child component
97
+ * @param size - Size available for the child
98
+ * @param path - Path for the child (for keys and debugging)
99
+ * @returns ComponentOutput from the child render
100
+ */
101
+ render: (data: unknown, size: Size, path: string) => ComponentOutput | Promise<ComponentOutput>;
102
+ /**
103
+ * Event bus for streaming coordination.
104
+ * Available when executing in a procedure context.
105
+ */
106
+ bus?: EventBus;
107
+ /**
108
+ * Additional metadata from the procedure context.
109
+ */
110
+ metadata?: Record<string, unknown>;
111
+ }
112
+ /**
113
+ * Component factory function (single output).
114
+ * Returns a serializable component descriptor.
115
+ */
116
+ export type ComponentFactory<TData = unknown> = (ctx: ComponentContext<TData>) => ComponentOutput | Promise<ComponentOutput>;
117
+ /**
118
+ * Streaming component factory (multi-yield).
119
+ * Yields descriptors over time for live updates.
120
+ */
121
+ export type StreamingComponentFactory<TData = unknown> = (ctx: ComponentContext<TData>) => AsyncGenerator<ComponentOutput, void, unknown>;
122
+ /**
123
+ * Any component factory (single or streaming).
124
+ */
125
+ export type AnyComponentFactory<TData = unknown> = ComponentFactory<TData> | StreamingComponentFactory<TData>;
126
+ /**
127
+ * Component metadata (extends ProcedureMetadata).
128
+ */
129
+ export interface ComponentMetadata extends ProcedureMetadata {
130
+ /** Component category for organization */
131
+ category?: string;
132
+ /** Whether the component supports streaming updates */
133
+ streaming?: boolean;
134
+ /** Default size constraints */
135
+ defaultSize?: Size;
136
+ /** Minimum size constraints */
137
+ minSize?: Size;
138
+ /** Maximum size constraints */
139
+ maxSize?: Size;
140
+ }
141
+ /**
142
+ * Component definition.
143
+ * Wraps a factory function with type information and metadata.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const userCard: ComponentDefinition<User> = {
148
+ * type: "user-card",
149
+ * namespace: "ui",
150
+ * input: userSchema,
151
+ * metadata: {
152
+ * description: "Displays user information",
153
+ * category: "profile",
154
+ * },
155
+ * factory: (ctx) => ({
156
+ * type: "user-card",
157
+ * props: { user: ctx.data },
158
+ * }),
159
+ * };
160
+ * ```
161
+ */
162
+ export interface ComponentDefinition<TData = unknown> {
163
+ /** Component type identifier */
164
+ type: string;
165
+ /**
166
+ * Namespace for the component (optional).
167
+ * Results in path: ["components", namespace, type]
168
+ *
169
+ * @example
170
+ * namespace: "ui" → ["components", "ui", "user-card"]
171
+ */
172
+ namespace?: string;
173
+ /**
174
+ * Input schema for validating component data.
175
+ * Optional - if not provided, accepts any data.
176
+ */
177
+ input?: ZodLike<TData>;
178
+ /**
179
+ * Component metadata for documentation and tooling.
180
+ */
181
+ metadata?: ComponentMetadata;
182
+ /**
183
+ * Whether this component streams updates.
184
+ * When true, factory is expected to be a generator.
185
+ */
186
+ streaming?: boolean;
187
+ /**
188
+ * Component factory function.
189
+ * Can be a regular function (single output) or generator (streaming).
190
+ */
191
+ factory: AnyComponentFactory<TData>;
192
+ }
193
+ /**
194
+ * Any component definition (type-erased for storage).
195
+ */
196
+ export type AnyComponentDefinition = ComponentDefinition<unknown>;
197
+ /**
198
+ * Registered component with resolved path.
199
+ */
200
+ export interface RegisteredComponent<TData = unknown> {
201
+ /** Full procedure path */
202
+ path: ProcedurePath;
203
+ /** Original component definition */
204
+ definition: ComponentDefinition<TData>;
205
+ }
206
+ /**
207
+ * Component bundle - collection of components with shared namespace.
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * const uiComponents: ComponentBundle = {
212
+ * namespace: "ui",
213
+ * components: [
214
+ * buttonComponent,
215
+ * cardComponent,
216
+ * modalComponent,
217
+ * ],
218
+ * };
219
+ * ```
220
+ */
221
+ export interface ComponentBundle {
222
+ /** Shared namespace for all components in bundle */
223
+ namespace: string;
224
+ /** Component definitions */
225
+ components: AnyComponentDefinition[];
226
+ /** Bundle metadata */
227
+ metadata?: {
228
+ /** Bundle name */
229
+ name?: string;
230
+ /** Bundle description */
231
+ description?: string;
232
+ /** Bundle version */
233
+ version?: string;
234
+ };
235
+ }
236
+ /**
237
+ * Infer input type from a component definition.
238
+ */
239
+ export type InferComponentInput<T> = T extends ComponentDefinition<infer TData> ? TData : unknown;
240
+ /**
241
+ * Infer whether a component is streaming.
242
+ */
243
+ export type IsStreamingComponent<T> = T extends ComponentDefinition<unknown> ? T["streaming"] extends true ? true : false : false;
244
+ /**
245
+ * Create a null output (render nothing).
246
+ */
247
+ export declare function nullOutput(): NullOutput;
248
+ /**
249
+ * Create a fragment output (multiple children without wrapper).
250
+ */
251
+ export declare function fragment(...children: ComponentOutput[]): FragmentOutput;
252
+ /**
253
+ * Check if output is a fragment.
254
+ */
255
+ export declare function isFragment(output: AnyComponentOutput): output is FragmentOutput;
256
+ /**
257
+ * Check if output is null.
258
+ */
259
+ export declare function isNullOutput(output: AnyComponentOutput): output is NullOutput;
260
+ /**
261
+ * Check if a factory is a streaming generator.
262
+ */
263
+ export declare function isStreamingFactory<TData>(factory: AnyComponentFactory<TData>): factory is StreamingComponentFactory<TData>;
264
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/components/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE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BAAgB,UAAU,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,IAAI,cAAc,CAE/E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,IAAI,UAAU,CAE7E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EACtC,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,GAClC,OAAO,IAAI,yBAAyB,CAAC,KAAK,CAAC,CAK7C"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Component Types
3
+ *
4
+ * Components are procedures that return serializable UI descriptors.
5
+ * This enables SSR, caching, and transport over wire.
6
+ *
7
+ * Components integrate with splay's rendering model where a renderer
8
+ * produces output based on data, size, and path context.
9
+ */
10
+ // =============================================================================
11
+ // Output Helpers
12
+ // =============================================================================
13
+ /**
14
+ * Create a null output (render nothing).
15
+ */
16
+ export function nullOutput() {
17
+ return { type: "__null__" };
18
+ }
19
+ /**
20
+ * Create a fragment output (multiple children without wrapper).
21
+ */
22
+ export function fragment(...children) {
23
+ return { type: "__fragment__", children };
24
+ }
25
+ /**
26
+ * Check if output is a fragment.
27
+ */
28
+ export function isFragment(output) {
29
+ return output.type === "__fragment__";
30
+ }
31
+ /**
32
+ * Check if output is null.
33
+ */
34
+ export function isNullOutput(output) {
35
+ return output.type === "__null__";
36
+ }
37
+ /**
38
+ * Check if a factory is a streaming generator.
39
+ */
40
+ export function isStreamingFactory(factory) {
41
+ // The tag of the prototype, not `constructor.name`: an own `constructor` property, or a
42
+ // bundler that renames classes, does not change it. A plain function that returns a
43
+ // generator is not detected here: the handler of a component streams its result anyway.
44
+ return Object.prototype.toString.call(factory) === "[object AsyncGeneratorFunction]";
45
+ }
46
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/components/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkTH,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,QAA2B;IACrD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAA0B;IACnD,OAAO,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAmC;IAEnC,wFAAwF;IACxF,oFAAoF;IACpF,wFAAwF;IACxF,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,iCAAiC,CAAC;AACvF,CAAC"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Hydration
3
+ *
4
+ * Converts serializable ComponentOutput descriptors into framework-specific
5
+ * components (React, Vue, Svelte, etc.).
6
+ *
7
+ * This enables the following flow:
8
+ * 1. Server renders ComponentOutput (serializable)
9
+ * 2. Output is sent over wire (JSON)
10
+ * 3. Client hydrates to React/Vue/Svelte components
11
+ */
12
+ import type { ComponentOutput } from "./components/index.js";
13
+ import type { ComponentMap, HydrateOptions } from "./types.js";
14
+ /**
15
+ * Create a hydrate function for a specific framework.
16
+ *
17
+ * @param options - Hydration options including component map
18
+ * @returns Hydrate function that converts descriptors to framework components
19
+ *
20
+ * @example React:
21
+ * ```typescript
22
+ * import { createElement } from "react";
23
+ * import { createHydrate } from "@procedures/splay";
24
+ *
25
+ * const hydrate = createHydrate({
26
+ * components: {
27
+ * "user-card": UserCard,
28
+ * "badge": Badge,
29
+ * },
30
+ * fallback: UnknownComponent,
31
+ * });
32
+ *
33
+ * // Use with React
34
+ * function App({ descriptor }) {
35
+ * return hydrate(descriptor, createElement);
36
+ * }
37
+ * ```
38
+ */
39
+ export declare function createHydrate<TComponent>(options: HydrateOptions<TComponent>): (descriptor: ComponentOutput | null, createElement: CreateElement<TComponent>) => TComponent | null;
40
+ /**
41
+ * createElement function signature (React-compatible).
42
+ */
43
+ export type CreateElement<TComponent> = (type: TComponent, props: Record<string, unknown> | null, children?: (TComponent | null)[]) => TComponent;
44
+ /**
45
+ * Generic React-like component type (works with any framework that has createElement).
46
+ */
47
+ type ReactLikeComponent = (props: Record<string, unknown>) => unknown;
48
+ /**
49
+ * React-specific hydration options.
50
+ */
51
+ export interface ReactHydrateOptions {
52
+ /** Map of component types to React components */
53
+ components: ComponentMap<ReactLikeComponent>;
54
+ /** Fallback component for unknown types */
55
+ fallback?: ReactLikeComponent;
56
+ }
57
+ /**
58
+ * React-like module interface.
59
+ */
60
+ interface ReactLike {
61
+ createElement(type: ReactLikeComponent | symbol, props: Record<string, unknown> | null, ...children: unknown[]): unknown;
62
+ Fragment: symbol;
63
+ }
64
+ /**
65
+ * Create a React-specific hydrate function.
66
+ *
67
+ * @param react - React module (import * as React from "react")
68
+ * @param options - Hydration options
69
+ * @returns Hydrate function for React
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * import * as React from "react";
74
+ * import { createReactHydrate } from "@procedures/splay";
75
+ *
76
+ * const hydrate = createReactHydrate(React, {
77
+ * components: {
78
+ * "user-card": UserCard,
79
+ * "badge": Badge,
80
+ * },
81
+ * });
82
+ *
83
+ * function App({ descriptor }) {
84
+ * return hydrate(descriptor);
85
+ * }
86
+ * ```
87
+ */
88
+ export declare function createReactHydrate(react: ReactLike, options: ReactHydrateOptions): (descriptor: ComponentOutput | null) => unknown;
89
+ /**
90
+ * Walk a descriptor tree and apply a visitor to each node.
91
+ */
92
+ export declare function walkDescriptor(descriptor: ComponentOutput, visitor: (node: ComponentOutput, path: string[]) => void, path?: string[]): void;
93
+ /**
94
+ * Transform a descriptor tree.
95
+ */
96
+ export declare function transformDescriptor(descriptor: ComponentOutput, transform: (node: ComponentOutput) => ComponentOutput): ComponentOutput;
97
+ /**
98
+ * Find all nodes in a descriptor tree matching a predicate.
99
+ */
100
+ export declare function findInDescriptor(descriptor: ComponentOutput, predicate: (node: ComponentOutput) => boolean): ComponentOutput[];
101
+ /**
102
+ * Get all component types used in a descriptor tree.
103
+ */
104
+ export declare function getUsedTypes(descriptor: ComponentOutput): Set<string>;
105
+ /**
106
+ * Validate that all component types in a descriptor are known.
107
+ */
108
+ export declare function validateDescriptor(descriptor: ComponentOutput, knownTypes: Set<string> | string[]): {
109
+ valid: boolean;
110
+ unknownTypes: string[];
111
+ };
112
+ /**
113
+ * Serialize a descriptor to JSON string.
114
+ */
115
+ export declare function serializeDescriptor(descriptor: ComponentOutput): string;
116
+ /**
117
+ * Parse a descriptor from JSON string.
118
+ */
119
+ export declare function parseDescriptor(json: string): ComponentOutput;
120
+ /**
121
+ * Create a compact representation of a descriptor.
122
+ * Removes undefined values and empty arrays.
123
+ */
124
+ export declare function compactDescriptor(descriptor: ComponentOutput): ComponentOutput;
125
+ export {};
126
+ //# sourceMappingURL=hydrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../src/hydrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAc/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,UAAU,EACtC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,GAClC,CACD,UAAU,EAAE,eAAe,GAAG,IAAI,EAClC,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC,KACrC,UAAU,GAAG,IAAI,CAmDrB;A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ajB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,eAAe,EAC3B,SAAS,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,OAAO,GAC5C,eAAe,EAAE,CAUnB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,CAUrE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,eAAe,EAC3B,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,GACjC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAe5C;AAMD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,eAAe,GAAG,MAAM,CAEvE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAE7D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,eAAe,GAAG,eAAe,CAe9E"}
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Hydration
3
+ *
4
+ * Converts serializable ComponentOutput descriptors into framework-specific
5
+ * components (React, Vue, Svelte, etc.).
6
+ *
7
+ * This enables the following flow:
8
+ * 1. Server renders ComponentOutput (serializable)
9
+ * 2. Output is sent over wire (JSON)
10
+ * 3. Client hydrates to React/Vue/Svelte components
11
+ */
12
+ const log = globalThis.console;
13
+ // =============================================================================
14
+ // Hydration Core
15
+ // =============================================================================
16
+ /**
17
+ * Create a hydrate function for a specific framework.
18
+ *
19
+ * @param options - Hydration options including component map
20
+ * @returns Hydrate function that converts descriptors to framework components
21
+ *
22
+ * @example React:
23
+ * ```typescript
24
+ * import { createElement } from "react";
25
+ * import { createHydrate } from "@procedures/splay";
26
+ *
27
+ * const hydrate = createHydrate({
28
+ * components: {
29
+ * "user-card": UserCard,
30
+ * "badge": Badge,
31
+ * },
32
+ * fallback: UnknownComponent,
33
+ * });
34
+ *
35
+ * // Use with React
36
+ * function App({ descriptor }) {
37
+ * return hydrate(descriptor, createElement);
38
+ * }
39
+ * ```
40
+ */
41
+ export function createHydrate(options) {
42
+ const { components, fallback, onNull, onFragment } = options;
43
+ return function hydrate(descriptor, createElement) {
44
+ // Handle null
45
+ if (descriptor === null) {
46
+ return onNull?.() ?? null;
47
+ }
48
+ // Handle null output type
49
+ if (descriptor.type === "__null__") {
50
+ return onNull?.() ?? null;
51
+ }
52
+ // Handle fragment
53
+ if (descriptor.type === "__fragment__") {
54
+ const children = (descriptor.children ?? []).map((child) => hydrate(child, createElement));
55
+ if (onFragment) {
56
+ return onFragment(children.filter((c) => c !== null));
57
+ }
58
+ // Default: return first child or null
59
+ return children[0] ?? null;
60
+ }
61
+ // Look up component
62
+ const Component = components[descriptor.type] ?? fallback;
63
+ if (!Component) {
64
+ log.warn(`Unknown component type: ${descriptor.type}`);
65
+ return null;
66
+ }
67
+ // Hydrate children recursively
68
+ const hydratedChildren = descriptor.children?.map((child) => hydrate(child, createElement));
69
+ // Create the component
70
+ return createElement(Component, { ...descriptor.props, key: descriptor.key }, hydratedChildren);
71
+ };
72
+ }
73
+ /**
74
+ * Create a React-specific hydrate function.
75
+ *
76
+ * @param react - React module (import * as React from "react")
77
+ * @param options - Hydration options
78
+ * @returns Hydrate function for React
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * import * as React from "react";
83
+ * import { createReactHydrate } from "@procedures/splay";
84
+ *
85
+ * const hydrate = createReactHydrate(React, {
86
+ * components: {
87
+ * "user-card": UserCard,
88
+ * "badge": Badge,
89
+ * },
90
+ * });
91
+ *
92
+ * function App({ descriptor }) {
93
+ * return hydrate(descriptor);
94
+ * }
95
+ * ```
96
+ */
97
+ export function createReactHydrate(react, options) {
98
+ const { components, fallback } = options;
99
+ function hydrate(descriptor) {
100
+ if (descriptor === null) {
101
+ return null;
102
+ }
103
+ if (descriptor.type === "__null__") {
104
+ return null;
105
+ }
106
+ if (descriptor.type === "__fragment__") {
107
+ const children = (descriptor.children ?? []).map((child) => hydrate(child));
108
+ return react.createElement(react.Fragment, null, ...children);
109
+ }
110
+ const Component = components[descriptor.type];
111
+ if (!Component) {
112
+ if (fallback) {
113
+ return react.createElement(fallback, {
114
+ type: descriptor.type,
115
+ props: descriptor.props,
116
+ });
117
+ }
118
+ log.warn(`Unknown component type: ${descriptor.type}`);
119
+ return null;
120
+ }
121
+ const hydratedChildren = descriptor.children?.map((child) => hydrate(child));
122
+ return react.createElement(Component, { ...descriptor.props, key: descriptor.key }, ...(hydratedChildren ?? []));
123
+ }
124
+ return hydrate;
125
+ }
126
+ // =============================================================================
127
+ // Descriptor Utilities
128
+ // =============================================================================
129
+ /**
130
+ * Walk a descriptor tree and apply a visitor to each node.
131
+ */
132
+ export function walkDescriptor(descriptor, visitor, path = []) {
133
+ visitor(descriptor, path);
134
+ if (descriptor.children) {
135
+ descriptor.children.forEach((child, index) => {
136
+ walkDescriptor(child, visitor, [...path, `children[${index}]`]);
137
+ });
138
+ }
139
+ }
140
+ /**
141
+ * Transform a descriptor tree.
142
+ */
143
+ export function transformDescriptor(descriptor, transform) {
144
+ const transformed = transform(descriptor);
145
+ if (transformed.children) {
146
+ return {
147
+ ...transformed,
148
+ children: transformed.children.map((child) => transformDescriptor(child, transform)),
149
+ };
150
+ }
151
+ return transformed;
152
+ }
153
+ /**
154
+ * Find all nodes in a descriptor tree matching a predicate.
155
+ */
156
+ export function findInDescriptor(descriptor, predicate) {
157
+ const results = [];
158
+ walkDescriptor(descriptor, (node) => {
159
+ if (predicate(node)) {
160
+ results.push(node);
161
+ }
162
+ });
163
+ return results;
164
+ }
165
+ /**
166
+ * Get all component types used in a descriptor tree.
167
+ */
168
+ export function getUsedTypes(descriptor) {
169
+ const types = new Set();
170
+ walkDescriptor(descriptor, (node) => {
171
+ if (node.type !== "__null__" && node.type !== "__fragment__") {
172
+ types.add(node.type);
173
+ }
174
+ });
175
+ return types;
176
+ }
177
+ /**
178
+ * Validate that all component types in a descriptor are known.
179
+ */
180
+ export function validateDescriptor(descriptor, knownTypes) {
181
+ const known = knownTypes instanceof Set ? knownTypes : new Set(knownTypes);
182
+ const used = getUsedTypes(descriptor);
183
+ const unknownTypes = [];
184
+ for (const type of used) {
185
+ if (!known.has(type)) {
186
+ unknownTypes.push(type);
187
+ }
188
+ }
189
+ return {
190
+ valid: unknownTypes.length === 0,
191
+ unknownTypes,
192
+ };
193
+ }
194
+ // =============================================================================
195
+ // Serialization Helpers
196
+ // =============================================================================
197
+ /**
198
+ * Serialize a descriptor to JSON string.
199
+ */
200
+ export function serializeDescriptor(descriptor) {
201
+ return JSON.stringify(descriptor);
202
+ }
203
+ /**
204
+ * Parse a descriptor from JSON string.
205
+ */
206
+ export function parseDescriptor(json) {
207
+ return JSON.parse(json);
208
+ }
209
+ /**
210
+ * Create a compact representation of a descriptor.
211
+ * Removes undefined values and empty arrays.
212
+ */
213
+ export function compactDescriptor(descriptor) {
214
+ const result = {
215
+ type: descriptor.type,
216
+ props: descriptor.props,
217
+ };
218
+ if (descriptor.children && descriptor.children.length > 0) {
219
+ result.children = descriptor.children.map(compactDescriptor);
220
+ }
221
+ if (descriptor.key !== undefined) {
222
+ result.key = descriptor.key;
223
+ }
224
+ return result;
225
+ }
226
+ //# sourceMappingURL=hydrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydrate.js","sourceRoot":"","sources":["../src/hydrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,MAAM,GAAG,GAAI,UAAkD,CAAC,OAAO,CAAC;AAExE,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAmC;IAKnC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE7D,OAAO,SAAS,OAAO,CACrB,UAAkC,E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