@procedures/client 0.2.0 → 0.2.2

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 (241) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +4 -4
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/browser.d.ts +1 -1
  5. package/dist/browser.d.ts.map +1 -1
  6. package/dist/browser.js.map +1 -1
  7. package/dist/procedures/invoke.d.ts +6 -1
  8. package/dist/procedures/invoke.d.ts.map +1 -1
  9. package/dist/procedures/invoke.js +2 -2
  10. package/dist/procedures/invoke.js.map +1 -1
  11. package/dist/procedures/schema.d.ts +4 -1
  12. package/dist/procedures/schema.d.ts.map +1 -1
  13. package/dist/procedures/schema.js +27 -2
  14. package/dist/procedures/schema.js.map +1 -1
  15. package/dist/server/host-policy.d.ts +3 -3
  16. package/dist/server/host-policy.d.ts.map +1 -1
  17. package/dist/server/procedure-server.d.ts +2 -2
  18. package/dist/server/procedure-server.d.ts.map +1 -1
  19. package/dist/server/procedure-server.js.map +1 -1
  20. package/package.json +1 -1
  21. package/src/browser.ts +1 -0
  22. package/src/procedures/invoke.ts +10 -4
  23. package/src/procedures/schema.ts +27 -2
  24. package/src/server/host-policy.ts +3 -3
  25. package/src/server/procedure-server.ts +2 -2
  26. package/dist/client/middleware/batching.d.ts +0 -102
  27. package/dist/client/middleware/batching.d.ts.map +0 -1
  28. package/dist/client/middleware/batching.js +0 -245
  29. package/dist/client/middleware/batching.js.map +0 -1
  30. package/dist/collections/async/async-queue.d.ts +0 -144
  31. package/dist/collections/async/async-queue.d.ts.map +0 -1
  32. package/dist/collections/async/async-queue.js +0 -347
  33. package/dist/collections/async/async-queue.js.map +0 -1
  34. package/dist/collections/async/channels.d.ts +0 -188
  35. package/dist/collections/async/channels.d.ts.map +0 -1
  36. package/dist/collections/async/channels.js +0 -312
  37. package/dist/collections/async/channels.js.map +0 -1
  38. package/dist/collections/behaviors/bounded.d.ts +0 -79
  39. package/dist/collections/behaviors/bounded.d.ts.map +0 -1
  40. package/dist/collections/behaviors/bounded.js +0 -384
  41. package/dist/collections/behaviors/bounded.js.map +0 -1
  42. package/dist/collections/behaviors/evented.d.ts +0 -154
  43. package/dist/collections/behaviors/evented.d.ts.map +0 -1
  44. package/dist/collections/behaviors/evented.js +0 -299
  45. package/dist/collections/behaviors/evented.js.map +0 -1
  46. package/dist/collections/behaviors/lru.d.ts +0 -84
  47. package/dist/collections/behaviors/lru.d.ts.map +0 -1
  48. package/dist/collections/behaviors/lru.js +0 -330
  49. package/dist/collections/behaviors/lru.js.map +0 -1
  50. package/dist/collections/behaviors/readonly.d.ts +0 -73
  51. package/dist/collections/behaviors/readonly.d.ts.map +0 -1
  52. package/dist/collections/behaviors/readonly.js +0 -158
  53. package/dist/collections/behaviors/readonly.js.map +0 -1
  54. package/dist/collections/behaviors/safe.d.ts +0 -163
  55. package/dist/collections/behaviors/safe.d.ts.map +0 -1
  56. package/dist/collections/behaviors/safe.js +0 -172
  57. package/dist/collections/behaviors/safe.js.map +0 -1
  58. package/dist/collections/behaviors/synchronized.d.ts +0 -88
  59. package/dist/collections/behaviors/synchronized.d.ts.map +0 -1
  60. package/dist/collections/behaviors/synchronized.js +0 -294
  61. package/dist/collections/behaviors/synchronized.js.map +0 -1
  62. package/dist/collections/behaviors/ttl.d.ts +0 -118
  63. package/dist/collections/behaviors/ttl.d.ts.map +0 -1
  64. package/dist/collections/behaviors/ttl.js +0 -338
  65. package/dist/collections/behaviors/ttl.js.map +0 -1
  66. package/dist/collections/core/effects.d.ts +0 -176
  67. package/dist/collections/core/effects.d.ts.map +0 -1
  68. package/dist/collections/core/effects.js +0 -180
  69. package/dist/collections/core/effects.js.map +0 -1
  70. package/dist/collections/core/events.d.ts +0 -192
  71. package/dist/collections/core/events.d.ts.map +0 -1
  72. package/dist/collections/core/events.js +0 -291
  73. package/dist/collections/core/events.js.map +0 -1
  74. package/dist/collections/core/middleware.d.ts +0 -231
  75. package/dist/collections/core/middleware.d.ts.map +0 -1
  76. package/dist/collections/core/middleware.js +0 -161
  77. package/dist/collections/core/middleware.js.map +0 -1
  78. package/dist/collections/core/policies.d.ts +0 -220
  79. package/dist/collections/core/policies.d.ts.map +0 -1
  80. package/dist/collections/core/policies.js +0 -48
  81. package/dist/collections/core/policies.js.map +0 -1
  82. package/dist/collections/core/traits.d.ts +0 -142
  83. package/dist/collections/core/traits.d.ts.map +0 -1
  84. package/dist/collections/core/traits.js +0 -8
  85. package/dist/collections/core/traits.js.map +0 -1
  86. package/dist/collections/examples.d.ts +0 -13
  87. package/dist/collections/examples.d.ts.map +0 -1
  88. package/dist/collections/examples.js +0 -302
  89. package/dist/collections/examples.js.map +0 -1
  90. package/dist/collections/fx/collectors.d.ts +0 -190
  91. package/dist/collections/fx/collectors.d.ts.map +0 -1
  92. package/dist/collections/fx/collectors.js +0 -369
  93. package/dist/collections/fx/collectors.js.map +0 -1
  94. package/dist/collections/fx/iter.d.ts +0 -166
  95. package/dist/collections/fx/iter.d.ts.map +0 -1
  96. package/dist/collections/fx/iter.js +0 -421
  97. package/dist/collections/fx/iter.js.map +0 -1
  98. package/dist/collections/impl/array-deque.d.ts +0 -107
  99. package/dist/collections/impl/array-deque.d.ts.map +0 -1
  100. package/dist/collections/impl/array-deque.js +0 -381
  101. package/dist/collections/impl/array-deque.js.map +0 -1
  102. package/dist/collections/impl/array-list.d.ts +0 -101
  103. package/dist/collections/impl/array-list.d.ts.map +0 -1
  104. package/dist/collections/impl/array-list.js +0 -387
  105. package/dist/collections/impl/array-list.js.map +0 -1
  106. package/dist/collections/impl/hash-map.d.ts +0 -141
  107. package/dist/collections/impl/hash-map.d.ts.map +0 -1
  108. package/dist/collections/impl/hash-map.js +0 -450
  109. package/dist/collections/impl/hash-map.js.map +0 -1
  110. package/dist/collections/impl/hash-set.d.ts +0 -125
  111. package/dist/collections/impl/hash-set.d.ts.map +0 -1
  112. package/dist/collections/impl/hash-set.js +0 -264
  113. package/dist/collections/impl/hash-set.js.map +0 -1
  114. package/dist/collections/impl/linked-hash-map.d.ts +0 -141
  115. package/dist/collections/impl/linked-hash-map.d.ts.map +0 -1
  116. package/dist/collections/impl/linked-hash-map.js +0 -472
  117. package/dist/collections/impl/linked-hash-map.js.map +0 -1
  118. package/dist/collections/impl/linked-list.d.ts +0 -109
  119. package/dist/collections/impl/linked-list.d.ts.map +0 -1
  120. package/dist/collections/impl/linked-list.js +0 -491
  121. package/dist/collections/impl/linked-list.js.map +0 -1
  122. package/dist/collections/impl/priority-queue.d.ts +0 -134
  123. package/dist/collections/impl/priority-queue.d.ts.map +0 -1
  124. package/dist/collections/impl/priority-queue.js +0 -336
  125. package/dist/collections/impl/priority-queue.js.map +0 -1
  126. package/dist/collections/impl/tree-map.d.ts +0 -146
  127. package/dist/collections/impl/tree-map.d.ts.map +0 -1
  128. package/dist/collections/impl/tree-map.js +0 -781
  129. package/dist/collections/impl/tree-map.js.map +0 -1
  130. package/dist/collections/impl/tree-set.d.ts +0 -112
  131. package/dist/collections/impl/tree-set.d.ts.map +0 -1
  132. package/dist/collections/impl/tree-set.js +0 -374
  133. package/dist/collections/impl/tree-set.js.map +0 -1
  134. package/dist/collections/index.d.ts +0 -105
  135. package/dist/collections/index.d.ts.map +0 -1
  136. package/dist/collections/index.js +0 -135
  137. package/dist/collections/index.js.map +0 -1
  138. package/dist/collections/interfaces/collection.d.ts +0 -119
  139. package/dist/collections/interfaces/collection.d.ts.map +0 -1
  140. package/dist/collections/interfaces/collection.js +0 -8
  141. package/dist/collections/interfaces/collection.js.map +0 -1
  142. package/dist/collections/interfaces/list.d.ts +0 -247
  143. package/dist/collections/interfaces/list.d.ts.map +0 -1
  144. package/dist/collections/interfaces/list.js +0 -8
  145. package/dist/collections/interfaces/list.js.map +0 -1
  146. package/dist/collections/interfaces/map.d.ts +0 -344
  147. package/dist/collections/interfaces/map.d.ts.map +0 -1
  148. package/dist/collections/interfaces/map.js +0 -8
  149. package/dist/collections/interfaces/map.js.map +0 -1
  150. package/dist/collections/interfaces/queue.d.ts +0 -304
  151. package/dist/collections/interfaces/queue.d.ts.map +0 -1
  152. package/dist/collections/interfaces/queue.js +0 -8
  153. package/dist/collections/interfaces/queue.js.map +0 -1
  154. package/dist/collections/interfaces/set.d.ts +0 -137
  155. package/dist/collections/interfaces/set.d.ts.map +0 -1
  156. package/dist/collections/interfaces/set.js +0 -8
  157. package/dist/collections/interfaces/set.js.map +0 -1
  158. package/dist/collections/storage/api.d.ts +0 -109
  159. package/dist/collections/storage/api.d.ts.map +0 -1
  160. package/dist/collections/storage/api.js +0 -182
  161. package/dist/collections/storage/api.js.map +0 -1
  162. package/dist/collections/storage/hybrid.d.ts +0 -164
  163. package/dist/collections/storage/hybrid.d.ts.map +0 -1
  164. package/dist/collections/storage/hybrid.js +0 -416
  165. package/dist/collections/storage/hybrid.js.map +0 -1
  166. package/dist/collections/storage/index.d.ts +0 -16
  167. package/dist/collections/storage/index.d.ts.map +0 -1
  168. package/dist/collections/storage/index.js +0 -13
  169. package/dist/collections/storage/index.js.map +0 -1
  170. package/dist/collections/storage/interface.d.ts +0 -141
  171. package/dist/collections/storage/interface.d.ts.map +0 -1
  172. package/dist/collections/storage/interface.js +0 -23
  173. package/dist/collections/storage/interface.js.map +0 -1
  174. package/dist/collections/storage/memory.d.ts +0 -68
  175. package/dist/collections/storage/memory.d.ts.map +0 -1
  176. package/dist/collections/storage/memory.js +0 -154
  177. package/dist/collections/storage/memory.js.map +0 -1
  178. package/dist/collections/utils/defaults.d.ts +0 -135
  179. package/dist/collections/utils/defaults.d.ts.map +0 -1
  180. package/dist/collections/utils/defaults.js +0 -322
  181. package/dist/collections/utils/defaults.js.map +0 -1
  182. package/dist/collections/utils/factories.d.ts +0 -144
  183. package/dist/collections/utils/factories.d.ts.map +0 -1
  184. package/dist/collections/utils/factories.js +0 -293
  185. package/dist/collections/utils/factories.js.map +0 -1
  186. package/dist/collections/utils/helpers.d.ts +0 -137
  187. package/dist/collections/utils/helpers.d.ts.map +0 -1
  188. package/dist/collections/utils/helpers.js +0 -221
  189. package/dist/collections/utils/helpers.js.map +0 -1
  190. package/dist/collections.d.ts +0 -12
  191. package/dist/collections.d.ts.map +0 -1
  192. package/dist/collections.js +0 -10
  193. package/dist/collections.js.map +0 -1
  194. package/dist/components/define.d.ts +0 -134
  195. package/dist/components/define.d.ts.map +0 -1
  196. package/dist/components/define.js +0 -486
  197. package/dist/components/define.js.map +0 -1
  198. package/dist/components/index.d.ts +0 -39
  199. package/dist/components/index.d.ts.map +0 -1
  200. package/dist/components/index.js +0 -38
  201. package/dist/components/index.js.map +0 -1
  202. package/dist/components/types.d.ts +0 -264
  203. package/dist/components/types.d.ts.map +0 -1
  204. package/dist/components/types.js +0 -46
  205. package/dist/components/types.js.map +0 -1
  206. package/dist/procedures/storage/adapter.d.ts +0 -148
  207. package/dist/procedures/storage/adapter.d.ts.map +0 -1
  208. package/dist/procedures/storage/adapter.js +0 -214
  209. package/dist/procedures/storage/adapter.js.map +0 -1
  210. package/dist/procedures/storage/api.d.ts +0 -125
  211. package/dist/procedures/storage/api.d.ts.map +0 -1
  212. package/dist/procedures/storage/api.js +0 -220
  213. package/dist/procedures/storage/api.js.map +0 -1
  214. package/dist/procedures/storage/factory.d.ts +0 -134
  215. package/dist/procedures/storage/factory.d.ts.map +0 -1
  216. package/dist/procedures/storage/factory.js +0 -166
  217. package/dist/procedures/storage/factory.js.map +0 -1
  218. package/dist/procedures/storage/hybrid.d.ts +0 -193
  219. package/dist/procedures/storage/hybrid.d.ts.map +0 -1
  220. package/dist/procedures/storage/hybrid.js +0 -519
  221. package/dist/procedures/storage/hybrid.js.map +0 -1
  222. package/dist/procedures/storage/index.d.ts +0 -17
  223. package/dist/procedures/storage/index.d.ts.map +0 -1
  224. package/dist/procedures/storage/index.js +0 -17
  225. package/dist/procedures/storage/index.js.map +0 -1
  226. package/dist/procedures/storage/procedures.d.ts +0 -39
  227. package/dist/procedures/storage/procedures.d.ts.map +0 -1
  228. package/dist/procedures/storage/procedures.js +0 -261
  229. package/dist/procedures/storage/procedures.js.map +0 -1
  230. package/dist/procedures/storage/serialization.d.ts +0 -123
  231. package/dist/procedures/storage/serialization.d.ts.map +0 -1
  232. package/dist/procedures/storage/serialization.js +0 -216
  233. package/dist/procedures/storage/serialization.js.map +0 -1
  234. package/dist/procedures/storage/synced-registry.d.ts +0 -246
  235. package/dist/procedures/storage/synced-registry.d.ts.map +0 -1
  236. package/dist/procedures/storage/synced-registry.js +0 -575
  237. package/dist/procedures/storage/synced-registry.js.map +0 -1
  238. package/dist/procedures/storage/types.d.ts +0 -130
  239. package/dist/procedures/storage/types.d.ts.map +0 -1
  240. package/dist/procedures/storage/types.js +0 -8
  241. package/dist/procedures/storage/types.js.map +0 -1
@@ -1,486 +0,0 @@
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/registry.js";
8
- import { invokeProcedure, isAsyncIterable } from "../procedures/invoke.js";
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/components/define.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,kBAAkB,EAA0B,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAW3E,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,KAAK,QAAQ,EAAE,CAAC;YACxC,OAAO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AC,UAAU,EAAE,CAAC;QAC1C,uDAAuD;QACvD,MAAM,aAAa,GAA2B;YAC5C,GAAG,SAAS;YACZ,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS;SACnD,CAAC;QAEF,eAAe,CAAC,aAAa,CAAC,CAAC;QAC/B,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,SAAiB,EACjB,UAAoC,EACpC,QAAsC;IAEtC,MAAM,MAAM,GAAoB,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;IAC1D,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,OAA0D;IAE1D,OAAO,eAAe,CAAC;QACrB,IAAI;QACJ,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,IAAY,EACZ,OAA0D;IAE1D,OAAO,eAAe,CAAC;QACrB,IAAI;QACJ,SAAS;QACT,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAY,EACZ,OAAyF;IAEzF,OAAO,eAAe,CAAC;QACrB,IAAI;QACJ,SAAS,EAAE,IAAI;QACf,OAAO;KACR,CAAC,CAAC;AACL,CAAC"}
@@ -1,39 +0,0 @@
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 "client/components";
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
@@ -1 +0,0 @@
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"}
@@ -1,38 +0,0 @@
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 "client/components";
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
@@ -1 +0,0 @@
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"}