@procedures/splay 0.0.0-stage → 0.1.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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +408 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/components/define.d.ts +134 -0
- package/dist/components/define.d.ts.map +1 -0
- package/dist/components/define.js +486 -0
- package/dist/components/define.js.map +1 -0
- package/dist/components/index.d.ts +39 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +38 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/types.d.ts +264 -0
- package/dist/components/types.d.ts.map +1 -0
- package/dist/components/types.js +46 -0
- package/dist/components/types.js.map +1 -0
- package/dist/hydrate.d.ts +126 -0
- package/dist/hydrate.d.ts.map +1 -0
- package/dist/hydrate.js +226 -0
- package/dist/hydrate.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/module.d.ts +16 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +58 -0
- package/dist/module.js.map +1 -0
- package/dist/register.d.ts +8 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +15 -0
- package/dist/register.js.map +1 -0
- package/dist/registry.d.ts +60 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +191 -0
- package/dist/registry.js.map +1 -0
- package/dist/streaming.d.ts +94 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +422 -0
- package/dist/streaming.js.map +1 -0
- package/dist/types.d.ts +85 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +73 -3
- package/src/components/define.ts +600 -0
- package/src/components/index.ts +78 -0
- package/src/components/types.ts +357 -0
- package/src/hydrate.ts +355 -0
- package/src/index.ts +111 -0
- package/src/module.ts +81 -0
- package/src/register.ts +18 -0
- package/src/registry.ts +257 -0
- package/src/streaming.ts +554 -0
- package/src/types.ts +114 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Definition Helpers
|
|
3
|
+
*
|
|
4
|
+
* Utilities for defining components as procedures.
|
|
5
|
+
* Components are procedures with special handling for UI rendering.
|
|
6
|
+
*/
|
|
7
|
+
import { PROCEDURE_REGISTRY } from "@procedures/client";
|
|
8
|
+
import { invokeProcedure, isAsyncIterable } from "@procedures/client";
|
|
9
|
+
import { isStreamingFactory } from "./types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Default component input schema.
|
|
12
|
+
* Validates the standard { data, size, path } structure.
|
|
13
|
+
*/
|
|
14
|
+
export const componentInputSchema = {
|
|
15
|
+
parse(value) {
|
|
16
|
+
const result = this.safeParse(value);
|
|
17
|
+
if (!result.success) {
|
|
18
|
+
throw new Error(result.error.message);
|
|
19
|
+
}
|
|
20
|
+
return result.data;
|
|
21
|
+
},
|
|
22
|
+
safeParse(value) {
|
|
23
|
+
if (!value || typeof value !== "object") {
|
|
24
|
+
return {
|
|
25
|
+
success: false,
|
|
26
|
+
error: { message: "Expected object", errors: [{ path: [], message: "Expected object" }] },
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const input = value;
|
|
30
|
+
if (!("data" in input)) {
|
|
31
|
+
return {
|
|
32
|
+
success: false,
|
|
33
|
+
error: { message: "Missing required field: data", errors: [{ path: ["data"], message: "Missing required field: data" }] },
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (!("size" in input) || typeof input["size"] !== "object") {
|
|
37
|
+
return {
|
|
38
|
+
success: false,
|
|
39
|
+
error: { message: "Missing or invalid field: size", errors: [{ path: ["size"], message: "Missing or invalid field: size" }] },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const size = input["size"];
|
|
43
|
+
if (typeof size["width"] !== "number" || typeof size["height"] !== "number") {
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
error: { message: "Size must have numeric width and height", errors: [{ path: ["size"], message: "Size must have numeric width and height" }] },
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!("path" in input) || typeof input["path"] !== "string") {
|
|
50
|
+
return {
|
|
51
|
+
success: false,
|
|
52
|
+
error: { message: "Missing or invalid field: path", errors: [{ path: ["path"], message: "Missing or invalid field: path" }] },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
success: true,
|
|
57
|
+
data: input,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Component output schema.
|
|
63
|
+
* Validates that output is a serializable ComponentOutput.
|
|
64
|
+
*/
|
|
65
|
+
export const componentOutputSchema = {
|
|
66
|
+
parse(value) {
|
|
67
|
+
const result = this.safeParse(value);
|
|
68
|
+
if (!result.success) {
|
|
69
|
+
throw new Error(result.error.message);
|
|
70
|
+
}
|
|
71
|
+
return result.data;
|
|
72
|
+
},
|
|
73
|
+
safeParse(value) {
|
|
74
|
+
if (!value || typeof value !== "object") {
|
|
75
|
+
return {
|
|
76
|
+
success: false,
|
|
77
|
+
error: { message: "Expected object", errors: [{ path: [], message: "Expected object" }] },
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const output = value;
|
|
81
|
+
if (typeof output["type"] !== "string") {
|
|
82
|
+
return {
|
|
83
|
+
success: false,
|
|
84
|
+
error: { message: "Missing or invalid field: type", errors: [{ path: ["type"], message: "Missing or invalid field: type" }] },
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (!("props" in output) || typeof output["props"] !== "object") {
|
|
88
|
+
return {
|
|
89
|
+
success: false,
|
|
90
|
+
error: { message: "Missing or invalid field: props", errors: [{ path: ["props"], message: "Missing or invalid field: props" }] },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
success: true,
|
|
95
|
+
data: output,
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
// =============================================================================
|
|
100
|
+
// defineComponent
|
|
101
|
+
// =============================================================================
|
|
102
|
+
/**
|
|
103
|
+
* Define a component and convert it to a procedure.
|
|
104
|
+
*
|
|
105
|
+
* Components are registered under ["components", namespace?, type].
|
|
106
|
+
*
|
|
107
|
+
* @param definition - Component definition
|
|
108
|
+
* @returns The component definition (for chaining)
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // Simple component
|
|
113
|
+
* const userCard = defineComponent({
|
|
114
|
+
* type: "user-card",
|
|
115
|
+
* namespace: "ui",
|
|
116
|
+
* input: userSchema,
|
|
117
|
+
* factory: (ctx) => ({
|
|
118
|
+
* type: "user-card",
|
|
119
|
+
* props: { user: ctx.data },
|
|
120
|
+
* }),
|
|
121
|
+
* });
|
|
122
|
+
*
|
|
123
|
+
* // Streaming component
|
|
124
|
+
* const liveDashboard = defineComponent({
|
|
125
|
+
* type: "live-dashboard",
|
|
126
|
+
* streaming: true,
|
|
127
|
+
* factory: async function* (ctx) {
|
|
128
|
+
* yield { type: "dashboard", props: { loading: true } };
|
|
129
|
+
* for await (const data of ctx.bus.stream("updates")) {
|
|
130
|
+
* yield { type: "dashboard", props: { data } };
|
|
131
|
+
* }
|
|
132
|
+
* },
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export function defineComponent(definition) {
|
|
137
|
+
// Build the procedure path
|
|
138
|
+
const path = definition.namespace
|
|
139
|
+
? ["components", definition.namespace, definition.type]
|
|
140
|
+
: ["components", definition.type];
|
|
141
|
+
// Create the procedure from the component
|
|
142
|
+
const procedure = componentToProcedure(definition, path);
|
|
143
|
+
// Register the procedure
|
|
144
|
+
PROCEDURE_REGISTRY.register(procedure);
|
|
145
|
+
return definition;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Convert a component definition to a procedure.
|
|
149
|
+
*
|
|
150
|
+
* @param definition - Component definition
|
|
151
|
+
* @param path - Procedure path
|
|
152
|
+
* @returns Procedure that wraps the component
|
|
153
|
+
*/
|
|
154
|
+
export function componentToProcedure(definition, path) {
|
|
155
|
+
const { factory, streaming, metadata } = definition;
|
|
156
|
+
// Build procedure metadata
|
|
157
|
+
const procedureMetadata = {
|
|
158
|
+
...metadata,
|
|
159
|
+
streaming: streaming ?? isStreamingFactory(factory),
|
|
160
|
+
tags: [...(metadata?.tags ?? []), "component"],
|
|
161
|
+
};
|
|
162
|
+
// Create handler based on factory type. With no `streaming` flag and a plain function, the
|
|
163
|
+
// handler gives the factory's result: one output, or the items of a generator that it returns.
|
|
164
|
+
const handler = streaming === true || (streaming === undefined && isStreamingFactory(factory))
|
|
165
|
+
? createStreamingHandler(factory)
|
|
166
|
+
: streaming === false
|
|
167
|
+
? createStandardHandler(factory)
|
|
168
|
+
: createAdaptiveHandler(factory);
|
|
169
|
+
return {
|
|
170
|
+
path,
|
|
171
|
+
input: definition.input
|
|
172
|
+
? createWrappedInputSchema(definition.input)
|
|
173
|
+
: componentInputSchema,
|
|
174
|
+
output: componentOutputSchema,
|
|
175
|
+
metadata: procedureMetadata,
|
|
176
|
+
streaming: procedureMetadata.streaming ?? false,
|
|
177
|
+
handler,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Create a wrapped input schema that validates both structure and data.
|
|
182
|
+
*/
|
|
183
|
+
function createWrappedInputSchema(dataSchema) {
|
|
184
|
+
return {
|
|
185
|
+
parse(value) {
|
|
186
|
+
const result = this.safeParse(value);
|
|
187
|
+
if (!result.success) {
|
|
188
|
+
throw new Error(result.error.message);
|
|
189
|
+
}
|
|
190
|
+
return result.data;
|
|
191
|
+
},
|
|
192
|
+
safeParse(value) {
|
|
193
|
+
// First validate the structure
|
|
194
|
+
const structureResult = componentInputSchema.safeParse(value);
|
|
195
|
+
if (!structureResult.success) {
|
|
196
|
+
return structureResult;
|
|
197
|
+
}
|
|
198
|
+
// Then validate the data field
|
|
199
|
+
const input = structureResult.data;
|
|
200
|
+
const dataResult = dataSchema.safeParse(input.data);
|
|
201
|
+
if (!dataResult.success) {
|
|
202
|
+
return {
|
|
203
|
+
success: false,
|
|
204
|
+
error: {
|
|
205
|
+
message: `Invalid data: ${dataResult.error.message}`,
|
|
206
|
+
errors: (dataResult.error.issues ?? dataResult.error.errors ?? []).map((e) => ({
|
|
207
|
+
path: ["data", ...(e.path ?? [])],
|
|
208
|
+
message: e.message,
|
|
209
|
+
})),
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
success: true,
|
|
215
|
+
data: { ...input, data: dataResult.data },
|
|
216
|
+
};
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Create a standard (non-streaming) handler from a component factory.
|
|
222
|
+
*/
|
|
223
|
+
function createStandardHandler(factory) {
|
|
224
|
+
return async (input, ctx) => {
|
|
225
|
+
const componentCtx = procedureToComponentContext(input, ctx);
|
|
226
|
+
const result = factory(componentCtx);
|
|
227
|
+
// Handle both sync and async returns
|
|
228
|
+
if (result instanceof Promise) {
|
|
229
|
+
return await result;
|
|
230
|
+
}
|
|
231
|
+
// Handle generator (shouldn't happen for standard, but just in case)
|
|
232
|
+
if (isAsyncGenerator(result)) {
|
|
233
|
+
// Take only the first yield, then end the generator so its finally blocks run
|
|
234
|
+
// (BUGS-2026-07 L3: it was left suspended)
|
|
235
|
+
try {
|
|
236
|
+
const { value, done } = await result.next();
|
|
237
|
+
if (done || value === undefined) {
|
|
238
|
+
throw new Error("Component factory yielded no output");
|
|
239
|
+
}
|
|
240
|
+
return value;
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
await result.return?.(undefined);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return result;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Create a handler that gives what the factory gives: one output, or a stream when the factory
|
|
251
|
+
* returns an async generator. `invokeProcedure` reads a returned generator as a stream.
|
|
252
|
+
*/
|
|
253
|
+
function createAdaptiveHandler(factory) {
|
|
254
|
+
return async (input, ctx) => {
|
|
255
|
+
const result = factory(procedureToComponentContext(input, ctx));
|
|
256
|
+
if (isAsyncIterable(result)) {
|
|
257
|
+
// The handler type has no "maybe a stream" form: invokeProcedure tests the result
|
|
258
|
+
return result;
|
|
259
|
+
}
|
|
260
|
+
return await result;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Create a streaming handler from a component factory.
|
|
265
|
+
*/
|
|
266
|
+
function createStreamingHandler(factory) {
|
|
267
|
+
return async function* (input, ctx) {
|
|
268
|
+
const componentCtx = procedureToComponentContext(input, ctx);
|
|
269
|
+
const result = factory(componentCtx);
|
|
270
|
+
if (isAsyncGenerator(result)) {
|
|
271
|
+
yield* result;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
// Convert single result to single yield
|
|
275
|
+
const output = result instanceof Promise ? await result : result;
|
|
276
|
+
yield output;
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Convert procedure context to component context.
|
|
282
|
+
*/
|
|
283
|
+
function procedureToComponentContext(input, ctx) {
|
|
284
|
+
const result = {
|
|
285
|
+
data: input.data,
|
|
286
|
+
size: input.size,
|
|
287
|
+
path: input.path,
|
|
288
|
+
depth: input.depth ?? 0,
|
|
289
|
+
metadata: ctx.metadata,
|
|
290
|
+
render: createRenderFunction(ctx),
|
|
291
|
+
};
|
|
292
|
+
if (ctx.bus) {
|
|
293
|
+
result.bus = ctx.bus;
|
|
294
|
+
}
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Create a render function for child components.
|
|
299
|
+
* This delegates to the procedure registry.
|
|
300
|
+
*/
|
|
301
|
+
function createRenderFunction(ctx) {
|
|
302
|
+
return async (data, size, path) => {
|
|
303
|
+
// Determine component type from data
|
|
304
|
+
// This is a simple heuristic - in practice, the renderer would decide
|
|
305
|
+
const type = inferComponentType(data);
|
|
306
|
+
if (!type) {
|
|
307
|
+
// Return a passthrough if we can't determine the type
|
|
308
|
+
return {
|
|
309
|
+
type: "raw",
|
|
310
|
+
props: { data },
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
// Find the component procedure: in the namespace of the component that renders, then
|
|
314
|
+
// the global one (BUGS-2026-07 L3: namespaced components were never found). A context
|
|
315
|
+
// that names its registry is searched first.
|
|
316
|
+
const registry = ctx.registry ?? PROCEDURE_REGISTRY;
|
|
317
|
+
const namespace = ctx.path?.length === 3 ? ctx.path[1] : undefined;
|
|
318
|
+
const procedure = (namespace !== undefined ? registry.get(["components", namespace, type]) : undefined) ??
|
|
319
|
+
registry.get(["components", type]);
|
|
320
|
+
if (!procedure || !procedure.handler) {
|
|
321
|
+
return {
|
|
322
|
+
type: "unknown",
|
|
323
|
+
props: { type, data },
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
// Call the procedure
|
|
327
|
+
const input = {
|
|
328
|
+
data,
|
|
329
|
+
size,
|
|
330
|
+
path,
|
|
331
|
+
depth: (path.match(/\./g) || []).length,
|
|
332
|
+
};
|
|
333
|
+
// The child runs through the invocation path: its input and output are validated, and its
|
|
334
|
+
// context has its own path. (Before, the parent called the handler directly, with no
|
|
335
|
+
// validation and with the parent's context.)
|
|
336
|
+
const options = { metadata: ctx.metadata, client: ctx.client };
|
|
337
|
+
if (ctx.signal)
|
|
338
|
+
options.signal = ctx.signal;
|
|
339
|
+
if (ctx.bus)
|
|
340
|
+
options.bus = ctx.bus;
|
|
341
|
+
if (ctx.repository)
|
|
342
|
+
options.repository = ctx.repository;
|
|
343
|
+
const output = await invokeProcedure(procedure, input, options);
|
|
344
|
+
if (output.kind === "value") {
|
|
345
|
+
return output.value;
|
|
346
|
+
}
|
|
347
|
+
// A streaming child: take the first output, then end the stream so its finally blocks run
|
|
348
|
+
try {
|
|
349
|
+
const { value, done } = await output.items.next();
|
|
350
|
+
if (done || value === undefined) {
|
|
351
|
+
throw new Error("Child component yielded no output");
|
|
352
|
+
}
|
|
353
|
+
return value;
|
|
354
|
+
}
|
|
355
|
+
finally {
|
|
356
|
+
await output.items.return(undefined);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Infer component type from data.
|
|
362
|
+
* This is a placeholder - real apps would use a type field or registry lookup.
|
|
363
|
+
*/
|
|
364
|
+
function inferComponentType(data) {
|
|
365
|
+
if (!data || typeof data !== "object") {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
const obj = data;
|
|
369
|
+
// Check for explicit __component field
|
|
370
|
+
if (typeof obj["__component"] === "string") {
|
|
371
|
+
return obj["__component"];
|
|
372
|
+
}
|
|
373
|
+
// Check for type field
|
|
374
|
+
if (typeof obj["type"] === "string") {
|
|
375
|
+
return obj["type"];
|
|
376
|
+
}
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Check if a value is an async generator.
|
|
381
|
+
*/
|
|
382
|
+
function isAsyncGenerator(value) {
|
|
383
|
+
return (value !== null &&
|
|
384
|
+
typeof value === "object" &&
|
|
385
|
+
Symbol.asyncIterator in value &&
|
|
386
|
+
typeof value.next === "function");
|
|
387
|
+
}
|
|
388
|
+
// =============================================================================
|
|
389
|
+
// Bundle Registration
|
|
390
|
+
// =============================================================================
|
|
391
|
+
/**
|
|
392
|
+
* Register a bundle of components.
|
|
393
|
+
*
|
|
394
|
+
* @param bundle - Component bundle
|
|
395
|
+
* @returns The registered components
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```typescript
|
|
399
|
+
* const registered = registerBundle({
|
|
400
|
+
* namespace: "ui",
|
|
401
|
+
* components: [buttonComponent, cardComponent],
|
|
402
|
+
* });
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
export function registerBundle(bundle) {
|
|
406
|
+
const registered = [];
|
|
407
|
+
for (const component of bundle.components) {
|
|
408
|
+
// Apply bundle namespace if component doesn't have one
|
|
409
|
+
const withNamespace = {
|
|
410
|
+
...component,
|
|
411
|
+
namespace: component.namespace ?? bundle.namespace,
|
|
412
|
+
};
|
|
413
|
+
defineComponent(withNamespace);
|
|
414
|
+
registered.push(withNamespace);
|
|
415
|
+
}
|
|
416
|
+
return registered;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Create a component bundle.
|
|
420
|
+
*
|
|
421
|
+
* @param namespace - Shared namespace
|
|
422
|
+
* @param components - Component definitions
|
|
423
|
+
* @param metadata - Optional bundle metadata
|
|
424
|
+
* @returns ComponentBundle
|
|
425
|
+
*/
|
|
426
|
+
export function createBundle(namespace, components, metadata) {
|
|
427
|
+
const result = { namespace, components };
|
|
428
|
+
if (metadata) {
|
|
429
|
+
result.metadata = metadata;
|
|
430
|
+
}
|
|
431
|
+
return result;
|
|
432
|
+
}
|
|
433
|
+
// =============================================================================
|
|
434
|
+
// Quick Define Helpers
|
|
435
|
+
// =============================================================================
|
|
436
|
+
/**
|
|
437
|
+
* Define a simple component with minimal boilerplate.
|
|
438
|
+
*
|
|
439
|
+
* @param type - Component type
|
|
440
|
+
* @param factory - Factory function
|
|
441
|
+
* @returns ComponentDefinition
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* ```typescript
|
|
445
|
+
* const badge = simpleComponent("badge", (ctx) => ({
|
|
446
|
+
* type: "badge",
|
|
447
|
+
* props: { label: ctx.data.label },
|
|
448
|
+
* }));
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
export function simpleComponent(type, factory) {
|
|
452
|
+
return defineComponent({
|
|
453
|
+
type,
|
|
454
|
+
factory,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Define a namespaced component with minimal boilerplate.
|
|
459
|
+
*
|
|
460
|
+
* @param namespace - Component namespace
|
|
461
|
+
* @param type - Component type
|
|
462
|
+
* @param factory - Factory function
|
|
463
|
+
* @returns ComponentDefinition
|
|
464
|
+
*/
|
|
465
|
+
export function namespacedComponent(namespace, type, factory) {
|
|
466
|
+
return defineComponent({
|
|
467
|
+
type,
|
|
468
|
+
namespace,
|
|
469
|
+
factory,
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Define a streaming component.
|
|
474
|
+
*
|
|
475
|
+
* @param type - Component type
|
|
476
|
+
* @param factory - Generator factory function
|
|
477
|
+
* @returns ComponentDefinition
|
|
478
|
+
*/
|
|
479
|
+
export function streamingComponent(type, factory) {
|
|
480
|
+
return defineComponent({
|
|
481
|
+
type,
|
|
482
|
+
streaming: true,
|
|
483
|
+
factory,
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/components/define.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,kBAAkB,EAA0B,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAWtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAqBhD;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA4B;IAC3D,KAAK,CAAC,KAAc;QAClB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,SAAS,CAAC,KAAc;QACtB,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,K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riptors.
|
|
5
|
+
* This enables SSR, caching, and transport over wire.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineComponent, simpleComponent, registerBundle } from "@procedures/splay";
|
|
10
|
+
*
|
|
11
|
+
* // Define a component
|
|
12
|
+
* const userCard = defineComponent({
|
|
13
|
+
* type: "user-card",
|
|
14
|
+
* namespace: "ui",
|
|
15
|
+
* input: userSchema,
|
|
16
|
+
* factory: (ctx) => ({
|
|
17
|
+
* type: "user-card",
|
|
18
|
+
* props: { user: ctx.data },
|
|
19
|
+
* }),
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Simple shorthand
|
|
23
|
+
* const badge = simpleComponent("badge", (ctx) => ({
|
|
24
|
+
* type: "badge",
|
|
25
|
+
* props: { label: ctx.data.label },
|
|
26
|
+
* }));
|
|
27
|
+
*
|
|
28
|
+
* // Register a bundle
|
|
29
|
+
* registerBundle({
|
|
30
|
+
* namespace: "ui",
|
|
31
|
+
* components: [buttonComponent, cardComponent],
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export type { ComponentOutput, FragmentOutput, NullOutput, AnyComponentOutput, Size, ComponentContext, ComponentFactory, StreamingComponentFactory, AnyComponentFactory, ComponentMetadata, ComponentDefinition, AnyComponentDefinition, RegisteredComponent, ComponentBundle, InferComponentInput, IsStreamingComponent, } from "./types.js";
|
|
36
|
+
export { nullOutput, fragment, isFragment, isNullOutput, isStreamingFactory, } from "./types.js";
|
|
37
|
+
export type { ComponentInput } from "./define.js";
|
|
38
|
+
export { defineComponent, componentToProcedure, registerBundle, createBundle, simpleComponent, namespacedComponent, streamingComponent, componentInputSchema, componentOutputSchema, } from "./define.js";
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,YAAY,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,UAAU,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Components Module
|
|
3
|
+
*
|
|
4
|
+
* Components are procedures that return serializable UI descriptors.
|
|
5
|
+
* This enables SSR, caching, and transport over wire.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineComponent, simpleComponent, registerBundle } from "@procedures/splay";
|
|
10
|
+
*
|
|
11
|
+
* // Define a component
|
|
12
|
+
* const userCard = defineComponent({
|
|
13
|
+
* type: "user-card",
|
|
14
|
+
* namespace: "ui",
|
|
15
|
+
* input: userSchema,
|
|
16
|
+
* factory: (ctx) => ({
|
|
17
|
+
* type: "user-card",
|
|
18
|
+
* props: { user: ctx.data },
|
|
19
|
+
* }),
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Simple shorthand
|
|
23
|
+
* const badge = simpleComponent("badge", (ctx) => ({
|
|
24
|
+
* type: "badge",
|
|
25
|
+
* props: { label: ctx.data.label },
|
|
26
|
+
* }));
|
|
27
|
+
*
|
|
28
|
+
* // Register a bundle
|
|
29
|
+
* registerBundle({
|
|
30
|
+
* namespace: "ui",
|
|
31
|
+
* components: [buttonComponent, cardComponent],
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
// Type utilities
|
|
36
|
+
export { nullOutput, fragment, isFragment, isNullOutput, isStreamingFactory, } from "./types.js";
|
|
37
|
+
export { defineComponent, componentToProcedure, registerBundle, createBundle, simpleComponent, namespacedComponent, streamingComponent, componentInputSchema, componentOutputSchema, } from "./define.js";
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAsBH,iBAAiB;AACjB,OAAO,EACL,UAAU,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
|