@procedures/client 0.1.0 → 0.2.1

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 (334) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +5 -5
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/adapters/http/server/transport.d.ts.map +1 -1
  5. package/dist/adapters/http/server/transport.js +1 -0
  6. package/dist/adapters/http/server/transport.js.map +1 -1
  7. package/dist/browser.d.ts +6 -3
  8. package/dist/browser.d.ts.map +1 -1
  9. package/dist/browser.js +4 -1
  10. package/dist/browser.js.map +1 -1
  11. package/dist/client/client.d.ts +9 -1
  12. package/dist/client/client.d.ts.map +1 -1
  13. package/dist/client/client.js +27 -6
  14. package/dist/client/client.js.map +1 -1
  15. package/dist/client/types.d.ts +9 -0
  16. package/dist/client/types.d.ts.map +1 -1
  17. package/dist/client/types.js.map +1 -1
  18. package/dist/procedures/capability.d.ts +111 -0
  19. package/dist/procedures/capability.d.ts.map +1 -0
  20. package/dist/procedures/capability.js +269 -0
  21. package/dist/procedures/capability.js.map +1 -0
  22. package/dist/procedures/cli/discover.d.ts +3 -3
  23. package/dist/procedures/cli/discover.js +3 -3
  24. package/dist/procedures/cli/index.js +5 -3
  25. package/dist/procedures/cli/index.js.map +1 -1
  26. package/dist/procedures/cli/init.js +1 -1
  27. package/dist/procedures/collection/procedures.d.ts.map +1 -1
  28. package/dist/procedures/collection/procedures.js +12 -0
  29. package/dist/procedures/collection/procedures.js.map +1 -1
  30. package/dist/procedures/core/array.d.ts.map +1 -1
  31. package/dist/procedures/core/array.js +3 -1
  32. package/dist/procedures/core/array.js.map +1 -1
  33. package/dist/procedures/core/comparison.d.ts.map +1 -1
  34. package/dist/procedures/core/comparison.js +3 -1
  35. package/dist/procedures/core/comparison.js.map +1 -1
  36. package/dist/procedures/core/index.d.ts.map +1 -1
  37. package/dist/procedures/core/index.js +5 -2
  38. package/dist/procedures/core/index.js.map +1 -1
  39. package/dist/procedures/core/math.d.ts.map +1 -1
  40. package/dist/procedures/core/math.js +3 -1
  41. package/dist/procedures/core/math.js.map +1 -1
  42. package/dist/procedures/core/meta.d.ts.map +1 -1
  43. package/dist/procedures/core/meta.js +11 -6
  44. package/dist/procedures/core/meta.js.map +1 -1
  45. package/dist/procedures/core/object.d.ts.map +1 -1
  46. package/dist/procedures/core/object.js +3 -1
  47. package/dist/procedures/core/object.js.map +1 -1
  48. package/dist/procedures/core/string.d.ts.map +1 -1
  49. package/dist/procedures/core/string.js +3 -1
  50. package/dist/procedures/core/string.js.map +1 -1
  51. package/dist/procedures/core/type.d.ts.map +1 -1
  52. package/dist/procedures/core/type.js +3 -1
  53. package/dist/procedures/core/type.js.map +1 -1
  54. package/dist/procedures/define-procedure.d.ts.map +1 -1
  55. package/dist/procedures/define-procedure.js +5 -4
  56. package/dist/procedures/define-procedure.js.map +1 -1
  57. package/dist/procedures/effects.d.ts +15 -0
  58. package/dist/procedures/effects.d.ts.map +1 -0
  59. package/dist/procedures/effects.js +18 -0
  60. package/dist/procedures/effects.js.map +1 -0
  61. package/dist/procedures/index.d.ts +5 -2
  62. package/dist/procedures/index.d.ts.map +1 -1
  63. package/dist/procedures/index.js +8 -23
  64. package/dist/procedures/index.js.map +1 -1
  65. package/dist/procedures/interceptors.d.ts.map +1 -1
  66. package/dist/procedures/interceptors.js +2 -1
  67. package/dist/procedures/interceptors.js.map +1 -1
  68. package/dist/procedures/invoke.d.ts +36 -3
  69. package/dist/procedures/invoke.d.ts.map +1 -1
  70. package/dist/procedures/invoke.js +78 -12
  71. package/dist/procedures/invoke.js.map +1 -1
  72. package/dist/procedures/module.d.ts +13 -8
  73. package/dist/procedures/module.d.ts.map +1 -1
  74. package/dist/procedures/module.js +19 -9
  75. package/dist/procedures/module.js.map +1 -1
  76. package/dist/procedures/types.d.ts +100 -2
  77. package/dist/procedures/types.d.ts.map +1 -1
  78. package/dist/procedures/types.js.map +1 -1
  79. package/dist/register.d.ts +8 -0
  80. package/dist/register.d.ts.map +1 -0
  81. package/dist/register.js +9 -0
  82. package/dist/register.js.map +1 -0
  83. package/dist/server/host-policy.d.ts +24 -2
  84. package/dist/server/host-policy.d.ts.map +1 -1
  85. package/dist/server/host-policy.js +22 -0
  86. package/dist/server/host-policy.js.map +1 -1
  87. package/dist/server/procedure-server.d.ts +16 -2
  88. package/dist/server/procedure-server.d.ts.map +1 -1
  89. package/dist/server/procedure-server.js +26 -1
  90. package/dist/server/procedure-server.js.map +1 -1
  91. package/package.json +6 -4
  92. package/src/adapters/http/server/transport.ts +1 -0
  93. package/src/browser.ts +29 -0
  94. package/src/client/client.ts +33 -6
  95. package/src/client/types.ts +11 -0
  96. package/src/procedures/capability.ts +333 -0
  97. package/src/procedures/cli/discover.ts +3 -3
  98. package/src/procedures/cli/index.ts +5 -3
  99. package/src/procedures/cli/init.ts +1 -1
  100. package/src/procedures/collection/procedures.ts +12 -0
  101. package/src/procedures/core/array.ts +3 -1
  102. package/src/procedures/core/comparison.ts +3 -1
  103. package/src/procedures/core/index.ts +5 -2
  104. package/src/procedures/core/math.ts +3 -1
  105. package/src/procedures/core/meta.ts +11 -6
  106. package/src/procedures/core/object.ts +3 -1
  107. package/src/procedures/core/string.ts +3 -1
  108. package/src/procedures/core/type.ts +3 -1
  109. package/src/procedures/define-procedure.ts +5 -4
  110. package/src/procedures/effects.ts +24 -0
  111. package/src/procedures/index.ts +33 -22
  112. package/src/procedures/interceptors.ts +2 -1
  113. package/src/procedures/invoke.ts +112 -13
  114. package/src/procedures/module.ts +19 -9
  115. package/src/procedures/types.ts +113 -2
  116. package/src/register.ts +10 -0
  117. package/src/server/host-policy.ts +44 -2
  118. package/src/server/procedure-server.ts +44 -2
  119. package/dist/client/middleware/batching.d.ts +0 -102
  120. package/dist/client/middleware/batching.d.ts.map +0 -1
  121. package/dist/client/middleware/batching.js +0 -245
  122. package/dist/client/middleware/batching.js.map +0 -1
  123. package/dist/collections/async/async-queue.d.ts +0 -144
  124. package/dist/collections/async/async-queue.d.ts.map +0 -1
  125. package/dist/collections/async/async-queue.js +0 -347
  126. package/dist/collections/async/async-queue.js.map +0 -1
  127. package/dist/collections/async/channels.d.ts +0 -188
  128. package/dist/collections/async/channels.d.ts.map +0 -1
  129. package/dist/collections/async/channels.js +0 -312
  130. package/dist/collections/async/channels.js.map +0 -1
  131. package/dist/collections/behaviors/bounded.d.ts +0 -79
  132. package/dist/collections/behaviors/bounded.d.ts.map +0 -1
  133. package/dist/collections/behaviors/bounded.js +0 -384
  134. package/dist/collections/behaviors/bounded.js.map +0 -1
  135. package/dist/collections/behaviors/evented.d.ts +0 -154
  136. package/dist/collections/behaviors/evented.d.ts.map +0 -1
  137. package/dist/collections/behaviors/evented.js +0 -299
  138. package/dist/collections/behaviors/evented.js.map +0 -1
  139. package/dist/collections/behaviors/lru.d.ts +0 -84
  140. package/dist/collections/behaviors/lru.d.ts.map +0 -1
  141. package/dist/collections/behaviors/lru.js +0 -330
  142. package/dist/collections/behaviors/lru.js.map +0 -1
  143. package/dist/collections/behaviors/readonly.d.ts +0 -73
  144. package/dist/collections/behaviors/readonly.d.ts.map +0 -1
  145. package/dist/collections/behaviors/readonly.js +0 -158
  146. package/dist/collections/behaviors/readonly.js.map +0 -1
  147. package/dist/collections/behaviors/safe.d.ts +0 -163
  148. package/dist/collections/behaviors/safe.d.ts.map +0 -1
  149. package/dist/collections/behaviors/safe.js +0 -172
  150. package/dist/collections/behaviors/safe.js.map +0 -1
  151. package/dist/collections/behaviors/synchronized.d.ts +0 -88
  152. package/dist/collections/behaviors/synchronized.d.ts.map +0 -1
  153. package/dist/collections/behaviors/synchronized.js +0 -294
  154. package/dist/collections/behaviors/synchronized.js.map +0 -1
  155. package/dist/collections/behaviors/ttl.d.ts +0 -118
  156. package/dist/collections/behaviors/ttl.d.ts.map +0 -1
  157. package/dist/collections/behaviors/ttl.js +0 -338
  158. package/dist/collections/behaviors/ttl.js.map +0 -1
  159. package/dist/collections/core/effects.d.ts +0 -176
  160. package/dist/collections/core/effects.d.ts.map +0 -1
  161. package/dist/collections/core/effects.js +0 -180
  162. package/dist/collections/core/effects.js.map +0 -1
  163. package/dist/collections/core/events.d.ts +0 -192
  164. package/dist/collections/core/events.d.ts.map +0 -1
  165. package/dist/collections/core/events.js +0 -291
  166. package/dist/collections/core/events.js.map +0 -1
  167. package/dist/collections/core/middleware.d.ts +0 -231
  168. package/dist/collections/core/middleware.d.ts.map +0 -1
  169. package/dist/collections/core/middleware.js +0 -161
  170. package/dist/collections/core/middleware.js.map +0 -1
  171. package/dist/collections/core/policies.d.ts +0 -220
  172. package/dist/collections/core/policies.d.ts.map +0 -1
  173. package/dist/collections/core/policies.js +0 -48
  174. package/dist/collections/core/policies.js.map +0 -1
  175. package/dist/collections/core/traits.d.ts +0 -142
  176. package/dist/collections/core/traits.d.ts.map +0 -1
  177. package/dist/collections/core/traits.js +0 -8
  178. package/dist/collections/core/traits.js.map +0 -1
  179. package/dist/collections/examples.d.ts +0 -13
  180. package/dist/collections/examples.d.ts.map +0 -1
  181. package/dist/collections/examples.js +0 -302
  182. package/dist/collections/examples.js.map +0 -1
  183. package/dist/collections/fx/collectors.d.ts +0 -190
  184. package/dist/collections/fx/collectors.d.ts.map +0 -1
  185. package/dist/collections/fx/collectors.js +0 -369
  186. package/dist/collections/fx/collectors.js.map +0 -1
  187. package/dist/collections/fx/iter.d.ts +0 -166
  188. package/dist/collections/fx/iter.d.ts.map +0 -1
  189. package/dist/collections/fx/iter.js +0 -421
  190. package/dist/collections/fx/iter.js.map +0 -1
  191. package/dist/collections/impl/array-deque.d.ts +0 -107
  192. package/dist/collections/impl/array-deque.d.ts.map +0 -1
  193. package/dist/collections/impl/array-deque.js +0 -381
  194. package/dist/collections/impl/array-deque.js.map +0 -1
  195. package/dist/collections/impl/array-list.d.ts +0 -101
  196. package/dist/collections/impl/array-list.d.ts.map +0 -1
  197. package/dist/collections/impl/array-list.js +0 -387
  198. package/dist/collections/impl/array-list.js.map +0 -1
  199. package/dist/collections/impl/hash-map.d.ts +0 -141
  200. package/dist/collections/impl/hash-map.d.ts.map +0 -1
  201. package/dist/collections/impl/hash-map.js +0 -450
  202. package/dist/collections/impl/hash-map.js.map +0 -1
  203. package/dist/collections/impl/hash-set.d.ts +0 -125
  204. package/dist/collections/impl/hash-set.d.ts.map +0 -1
  205. package/dist/collections/impl/hash-set.js +0 -264
  206. package/dist/collections/impl/hash-set.js.map +0 -1
  207. package/dist/collections/impl/linked-hash-map.d.ts +0 -141
  208. package/dist/collections/impl/linked-hash-map.d.ts.map +0 -1
  209. package/dist/collections/impl/linked-hash-map.js +0 -472
  210. package/dist/collections/impl/linked-hash-map.js.map +0 -1
  211. package/dist/collections/impl/linked-list.d.ts +0 -109
  212. package/dist/collections/impl/linked-list.d.ts.map +0 -1
  213. package/dist/collections/impl/linked-list.js +0 -491
  214. package/dist/collections/impl/linked-list.js.map +0 -1
  215. package/dist/collections/impl/priority-queue.d.ts +0 -134
  216. package/dist/collections/impl/priority-queue.d.ts.map +0 -1
  217. package/dist/collections/impl/priority-queue.js +0 -336
  218. package/dist/collections/impl/priority-queue.js.map +0 -1
  219. package/dist/collections/impl/tree-map.d.ts +0 -146
  220. package/dist/collections/impl/tree-map.d.ts.map +0 -1
  221. package/dist/collections/impl/tree-map.js +0 -781
  222. package/dist/collections/impl/tree-map.js.map +0 -1
  223. package/dist/collections/impl/tree-set.d.ts +0 -112
  224. package/dist/collections/impl/tree-set.d.ts.map +0 -1
  225. package/dist/collections/impl/tree-set.js +0 -374
  226. package/dist/collections/impl/tree-set.js.map +0 -1
  227. package/dist/collections/index.d.ts +0 -105
  228. package/dist/collections/index.d.ts.map +0 -1
  229. package/dist/collections/index.js +0 -135
  230. package/dist/collections/index.js.map +0 -1
  231. package/dist/collections/interfaces/collection.d.ts +0 -119
  232. package/dist/collections/interfaces/collection.d.ts.map +0 -1
  233. package/dist/collections/interfaces/collection.js +0 -8
  234. package/dist/collections/interfaces/collection.js.map +0 -1
  235. package/dist/collections/interfaces/list.d.ts +0 -247
  236. package/dist/collections/interfaces/list.d.ts.map +0 -1
  237. package/dist/collections/interfaces/list.js +0 -8
  238. package/dist/collections/interfaces/list.js.map +0 -1
  239. package/dist/collections/interfaces/map.d.ts +0 -344
  240. package/dist/collections/interfaces/map.d.ts.map +0 -1
  241. package/dist/collections/interfaces/map.js +0 -8
  242. package/dist/collections/interfaces/map.js.map +0 -1
  243. package/dist/collections/interfaces/queue.d.ts +0 -304
  244. package/dist/collections/interfaces/queue.d.ts.map +0 -1
  245. package/dist/collections/interfaces/queue.js +0 -8
  246. package/dist/collections/interfaces/queue.js.map +0 -1
  247. package/dist/collections/interfaces/set.d.ts +0 -137
  248. package/dist/collections/interfaces/set.d.ts.map +0 -1
  249. package/dist/collections/interfaces/set.js +0 -8
  250. package/dist/collections/interfaces/set.js.map +0 -1
  251. package/dist/collections/storage/api.d.ts +0 -109
  252. package/dist/collections/storage/api.d.ts.map +0 -1
  253. package/dist/collections/storage/api.js +0 -182
  254. package/dist/collections/storage/api.js.map +0 -1
  255. package/dist/collections/storage/hybrid.d.ts +0 -164
  256. package/dist/collections/storage/hybrid.d.ts.map +0 -1
  257. package/dist/collections/storage/hybrid.js +0 -416
  258. package/dist/collections/storage/hybrid.js.map +0 -1
  259. package/dist/collections/storage/index.d.ts +0 -16
  260. package/dist/collections/storage/index.d.ts.map +0 -1
  261. package/dist/collections/storage/index.js +0 -13
  262. package/dist/collections/storage/index.js.map +0 -1
  263. package/dist/collections/storage/interface.d.ts +0 -141
  264. package/dist/collections/storage/interface.d.ts.map +0 -1
  265. package/dist/collections/storage/interface.js +0 -23
  266. package/dist/collections/storage/interface.js.map +0 -1
  267. package/dist/collections/storage/memory.d.ts +0 -68
  268. package/dist/collections/storage/memory.d.ts.map +0 -1
  269. package/dist/collections/storage/memory.js +0 -154
  270. package/dist/collections/storage/memory.js.map +0 -1
  271. package/dist/collections/utils/defaults.d.ts +0 -135
  272. package/dist/collections/utils/defaults.d.ts.map +0 -1
  273. package/dist/collections/utils/defaults.js +0 -322
  274. package/dist/collections/utils/defaults.js.map +0 -1
  275. package/dist/collections/utils/factories.d.ts +0 -144
  276. package/dist/collections/utils/factories.d.ts.map +0 -1
  277. package/dist/collections/utils/factories.js +0 -293
  278. package/dist/collections/utils/factories.js.map +0 -1
  279. package/dist/collections/utils/helpers.d.ts +0 -137
  280. package/dist/collections/utils/helpers.d.ts.map +0 -1
  281. package/dist/collections/utils/helpers.js +0 -221
  282. package/dist/collections/utils/helpers.js.map +0 -1
  283. package/dist/collections.d.ts +0 -12
  284. package/dist/collections.d.ts.map +0 -1
  285. package/dist/collections.js +0 -10
  286. package/dist/collections.js.map +0 -1
  287. package/dist/components/define.d.ts +0 -134
  288. package/dist/components/define.d.ts.map +0 -1
  289. package/dist/components/define.js +0 -486
  290. package/dist/components/define.js.map +0 -1
  291. package/dist/components/index.d.ts +0 -39
  292. package/dist/components/index.d.ts.map +0 -1
  293. package/dist/components/index.js +0 -38
  294. package/dist/components/index.js.map +0 -1
  295. package/dist/components/types.d.ts +0 -264
  296. package/dist/components/types.d.ts.map +0 -1
  297. package/dist/components/types.js +0 -46
  298. package/dist/components/types.js.map +0 -1
  299. package/dist/procedures/storage/adapter.d.ts +0 -148
  300. package/dist/procedures/storage/adapter.d.ts.map +0 -1
  301. package/dist/procedures/storage/adapter.js +0 -214
  302. package/dist/procedures/storage/adapter.js.map +0 -1
  303. package/dist/procedures/storage/api.d.ts +0 -125
  304. package/dist/procedures/storage/api.d.ts.map +0 -1
  305. package/dist/procedures/storage/api.js +0 -220
  306. package/dist/procedures/storage/api.js.map +0 -1
  307. package/dist/procedures/storage/factory.d.ts +0 -134
  308. package/dist/procedures/storage/factory.d.ts.map +0 -1
  309. package/dist/procedures/storage/factory.js +0 -166
  310. package/dist/procedures/storage/factory.js.map +0 -1
  311. package/dist/procedures/storage/hybrid.d.ts +0 -193
  312. package/dist/procedures/storage/hybrid.d.ts.map +0 -1
  313. package/dist/procedures/storage/hybrid.js +0 -519
  314. package/dist/procedures/storage/hybrid.js.map +0 -1
  315. package/dist/procedures/storage/index.d.ts +0 -17
  316. package/dist/procedures/storage/index.d.ts.map +0 -1
  317. package/dist/procedures/storage/index.js +0 -17
  318. package/dist/procedures/storage/index.js.map +0 -1
  319. package/dist/procedures/storage/procedures.d.ts +0 -39
  320. package/dist/procedures/storage/procedures.d.ts.map +0 -1
  321. package/dist/procedures/storage/procedures.js +0 -261
  322. package/dist/procedures/storage/procedures.js.map +0 -1
  323. package/dist/procedures/storage/serialization.d.ts +0 -123
  324. package/dist/procedures/storage/serialization.d.ts.map +0 -1
  325. package/dist/procedures/storage/serialization.js +0 -216
  326. package/dist/procedures/storage/serialization.js.map +0 -1
  327. package/dist/procedures/storage/synced-registry.d.ts +0 -246
  328. package/dist/procedures/storage/synced-registry.d.ts.map +0 -1
  329. package/dist/procedures/storage/synced-registry.js +0 -575
  330. package/dist/procedures/storage/synced-registry.js.map +0 -1
  331. package/dist/procedures/storage/types.d.ts +0 -130
  332. package/dist/procedures/storage/types.d.ts.map +0 -1
  333. package/dist/procedures/storage/types.js +0 -8
  334. 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,OAA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yF;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"}