@czap/core 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.
Files changed (372) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/dist/addressed-digest.d.ts +15 -0
  4. package/dist/addressed-digest.d.ts.map +1 -0
  5. package/dist/addressed-digest.js +35 -0
  6. package/dist/addressed-digest.js.map +1 -0
  7. package/dist/animation.d.ts +46 -0
  8. package/dist/animation.d.ts.map +1 -0
  9. package/dist/animation.js +70 -0
  10. package/dist/animation.js.map +1 -0
  11. package/dist/assembly.d.ts +25 -0
  12. package/dist/assembly.d.ts.map +1 -0
  13. package/dist/assembly.js +58 -0
  14. package/dist/assembly.js.map +1 -0
  15. package/dist/av-bridge.d.ts +74 -0
  16. package/dist/av-bridge.d.ts.map +1 -0
  17. package/dist/av-bridge.js +107 -0
  18. package/dist/av-bridge.js.map +1 -0
  19. package/dist/av-renderer.d.ts +56 -0
  20. package/dist/av-renderer.d.ts.map +1 -0
  21. package/dist/av-renderer.js +65 -0
  22. package/dist/av-renderer.js.map +1 -0
  23. package/dist/blend.d.ts +61 -0
  24. package/dist/blend.d.ts.map +1 -0
  25. package/dist/blend.js +100 -0
  26. package/dist/blend.js.map +1 -0
  27. package/dist/boundary.d.ts +154 -0
  28. package/dist/boundary.d.ts.map +1 -0
  29. package/dist/boundary.js +269 -0
  30. package/dist/boundary.js.map +1 -0
  31. package/dist/brands.d.ts +63 -0
  32. package/dist/brands.d.ts.map +1 -0
  33. package/dist/brands.js +31 -0
  34. package/dist/brands.js.map +1 -0
  35. package/dist/caps.d.ts +49 -0
  36. package/dist/caps.d.ts.map +1 -0
  37. package/dist/caps.js +73 -0
  38. package/dist/caps.js.map +1 -0
  39. package/dist/capsule.d.ts +77 -0
  40. package/dist/capsule.d.ts.map +1 -0
  41. package/dist/capsule.js +18 -0
  42. package/dist/capsule.js.map +1 -0
  43. package/dist/capsules/boundary-evaluate.d.ts +28 -0
  44. package/dist/capsules/boundary-evaluate.d.ts.map +1 -0
  45. package/dist/capsules/boundary-evaluate.js +117 -0
  46. package/dist/capsules/boundary-evaluate.js.map +1 -0
  47. package/dist/capsules/canonical-cbor.d.ts +13 -0
  48. package/dist/capsules/canonical-cbor.d.ts.map +1 -0
  49. package/dist/capsules/canonical-cbor.js +60 -0
  50. package/dist/capsules/canonical-cbor.js.map +1 -0
  51. package/dist/capsules/token-buffer.d.ts +24 -0
  52. package/dist/capsules/token-buffer.d.ts.map +1 -0
  53. package/dist/capsules/token-buffer.js +53 -0
  54. package/dist/capsules/token-buffer.js.map +1 -0
  55. package/dist/capture.d.ts +40 -0
  56. package/dist/capture.d.ts.map +1 -0
  57. package/dist/capture.js +10 -0
  58. package/dist/capture.js.map +1 -0
  59. package/dist/cbor.d.ts +33 -0
  60. package/dist/cbor.d.ts.map +1 -0
  61. package/dist/cbor.js +179 -0
  62. package/dist/cbor.js.map +1 -0
  63. package/dist/cell.d.ts +53 -0
  64. package/dist/cell.d.ts.map +1 -0
  65. package/dist/cell.js +83 -0
  66. package/dist/cell.js.map +1 -0
  67. package/dist/codec.d.ts +30 -0
  68. package/dist/codec.d.ts.map +1 -0
  69. package/dist/codec.js +25 -0
  70. package/dist/codec.js.map +1 -0
  71. package/dist/component.d.ts +52 -0
  72. package/dist/component.d.ts.map +1 -0
  73. package/dist/component.js +44 -0
  74. package/dist/component.js.map +1 -0
  75. package/dist/composable.d.ts +76 -0
  76. package/dist/composable.d.ts.map +1 -0
  77. package/dist/composable.js +221 -0
  78. package/dist/composable.js.map +1 -0
  79. package/dist/compositor-pool.d.ts +74 -0
  80. package/dist/compositor-pool.d.ts.map +1 -0
  81. package/dist/compositor-pool.js +119 -0
  82. package/dist/compositor-pool.js.map +1 -0
  83. package/dist/compositor.d.ts +90 -0
  84. package/dist/compositor.d.ts.map +1 -0
  85. package/dist/compositor.js +278 -0
  86. package/dist/compositor.js.map +1 -0
  87. package/dist/config.d.ts +72 -0
  88. package/dist/config.d.ts.map +1 -0
  89. package/dist/config.js +97 -0
  90. package/dist/config.js.map +1 -0
  91. package/dist/dag.d.ts +251 -0
  92. package/dist/dag.d.ts.map +1 -0
  93. package/dist/dag.js +450 -0
  94. package/dist/dag.js.map +1 -0
  95. package/dist/defaults.d.ts +45 -0
  96. package/dist/defaults.d.ts.map +1 -0
  97. package/dist/defaults.js +45 -0
  98. package/dist/defaults.js.map +1 -0
  99. package/dist/derived.d.ts +34 -0
  100. package/dist/derived.d.ts.map +1 -0
  101. package/dist/derived.js +101 -0
  102. package/dist/derived.js.map +1 -0
  103. package/dist/diagnostics.d.ts +77 -0
  104. package/dist/diagnostics.d.ts.map +1 -0
  105. package/dist/diagnostics.js +122 -0
  106. package/dist/diagnostics.js.map +1 -0
  107. package/dist/dirty.d.ts +55 -0
  108. package/dist/dirty.d.ts.map +1 -0
  109. package/dist/dirty.js +80 -0
  110. package/dist/dirty.js.map +1 -0
  111. package/dist/easing.d.ts +55 -0
  112. package/dist/easing.d.ts.map +1 -0
  113. package/dist/easing.js +291 -0
  114. package/dist/easing.js.map +1 -0
  115. package/dist/ecs.d.ts +105 -0
  116. package/dist/ecs.d.ts.map +1 -0
  117. package/dist/ecs.js +245 -0
  118. package/dist/ecs.js.map +1 -0
  119. package/dist/fnv.d.ts +14 -0
  120. package/dist/fnv.d.ts.map +1 -0
  121. package/dist/fnv.js +28 -0
  122. package/dist/fnv.js.map +1 -0
  123. package/dist/frame-budget.d.ts +73 -0
  124. package/dist/frame-budget.d.ts.map +1 -0
  125. package/dist/frame-budget.js +114 -0
  126. package/dist/frame-budget.js.map +1 -0
  127. package/dist/gen-frame.d.ts +102 -0
  128. package/dist/gen-frame.d.ts.map +1 -0
  129. package/dist/gen-frame.js +121 -0
  130. package/dist/gen-frame.js.map +1 -0
  131. package/dist/harness/arbitrary-from-schema.d.ts +28 -0
  132. package/dist/harness/arbitrary-from-schema.d.ts.map +1 -0
  133. package/dist/harness/arbitrary-from-schema.js +262 -0
  134. package/dist/harness/arbitrary-from-schema.js.map +1 -0
  135. package/dist/harness/cached-projection.d.ts +19 -0
  136. package/dist/harness/cached-projection.d.ts.map +1 -0
  137. package/dist/harness/cached-projection.js +39 -0
  138. package/dist/harness/cached-projection.js.map +1 -0
  139. package/dist/harness/index.d.ts +16 -0
  140. package/dist/harness/index.d.ts.map +1 -0
  141. package/dist/harness/index.js +15 -0
  142. package/dist/harness/index.js.map +1 -0
  143. package/dist/harness/policy-gate.d.ts +18 -0
  144. package/dist/harness/policy-gate.d.ts.map +1 -0
  145. package/dist/harness/policy-gate.js +46 -0
  146. package/dist/harness/policy-gate.js.map +1 -0
  147. package/dist/harness/pure-transform.d.ts +42 -0
  148. package/dist/harness/pure-transform.d.ts.map +1 -0
  149. package/dist/harness/pure-transform.js +76 -0
  150. package/dist/harness/pure-transform.js.map +1 -0
  151. package/dist/harness/receipted-mutation.d.ts +23 -0
  152. package/dist/harness/receipted-mutation.d.ts.map +1 -0
  153. package/dist/harness/receipted-mutation.js +52 -0
  154. package/dist/harness/receipted-mutation.js.map +1 -0
  155. package/dist/harness/scene-composition.d.ts +19 -0
  156. package/dist/harness/scene-composition.d.ts.map +1 -0
  157. package/dist/harness/scene-composition.js +47 -0
  158. package/dist/harness/scene-composition.js.map +1 -0
  159. package/dist/harness/site-adapter.d.ts +18 -0
  160. package/dist/harness/site-adapter.d.ts.map +1 -0
  161. package/dist/harness/site-adapter.js +38 -0
  162. package/dist/harness/site-adapter.js.map +1 -0
  163. package/dist/harness/state-machine.d.ts +19 -0
  164. package/dist/harness/state-machine.d.ts.map +1 -0
  165. package/dist/harness/state-machine.js +44 -0
  166. package/dist/harness/state-machine.js.map +1 -0
  167. package/dist/hlc.d.ts +99 -0
  168. package/dist/hlc.d.ts.map +1 -0
  169. package/dist/hlc.js +219 -0
  170. package/dist/hlc.js.map +1 -0
  171. package/dist/index.d.ts +104 -0
  172. package/dist/index.d.ts.map +1 -0
  173. package/dist/index.js +137 -0
  174. package/dist/index.js.map +1 -0
  175. package/dist/interpolate.d.ts +14 -0
  176. package/dist/interpolate.d.ts.map +1 -0
  177. package/dist/interpolate.js +31 -0
  178. package/dist/interpolate.js.map +1 -0
  179. package/dist/live-cell.d.ts +46 -0
  180. package/dist/live-cell.d.ts.map +1 -0
  181. package/dist/live-cell.js +154 -0
  182. package/dist/live-cell.js.map +1 -0
  183. package/dist/op.d.ts +58 -0
  184. package/dist/op.d.ts.map +1 -0
  185. package/dist/op.js +171 -0
  186. package/dist/op.js.map +1 -0
  187. package/dist/plan.d.ts +195 -0
  188. package/dist/plan.d.ts.map +1 -0
  189. package/dist/plan.js +211 -0
  190. package/dist/plan.js.map +1 -0
  191. package/dist/protocol.d.ts +33 -0
  192. package/dist/protocol.d.ts.map +1 -0
  193. package/dist/protocol.js +10 -0
  194. package/dist/protocol.js.map +1 -0
  195. package/dist/quantizer-types.d.ts +28 -0
  196. package/dist/quantizer-types.d.ts.map +1 -0
  197. package/dist/quantizer-types.js +9 -0
  198. package/dist/quantizer-types.js.map +1 -0
  199. package/dist/receipt.d.ts +294 -0
  200. package/dist/receipt.d.ts.map +1 -0
  201. package/dist/receipt.js +352 -0
  202. package/dist/receipt.js.map +1 -0
  203. package/dist/runtime-coordinator.d.ts +75 -0
  204. package/dist/runtime-coordinator.d.ts.map +1 -0
  205. package/dist/runtime-coordinator.js +149 -0
  206. package/dist/runtime-coordinator.js.map +1 -0
  207. package/dist/scheduler.d.ts +58 -0
  208. package/dist/scheduler.d.ts.map +1 -0
  209. package/dist/scheduler.js +109 -0
  210. package/dist/scheduler.js.map +1 -0
  211. package/dist/ship-capsule.d.ts +54 -0
  212. package/dist/ship-capsule.d.ts.map +1 -0
  213. package/dist/ship-capsule.js +142 -0
  214. package/dist/ship-capsule.js.map +1 -0
  215. package/dist/ship-manifest.d.ts +45 -0
  216. package/dist/ship-manifest.d.ts.map +1 -0
  217. package/dist/ship-manifest.js +175 -0
  218. package/dist/ship-manifest.js.map +1 -0
  219. package/dist/signal.d.ts +149 -0
  220. package/dist/signal.d.ts.map +1 -0
  221. package/dist/signal.js +277 -0
  222. package/dist/signal.js.map +1 -0
  223. package/dist/speculative.d.ts +67 -0
  224. package/dist/speculative.d.ts.map +1 -0
  225. package/dist/speculative.js +139 -0
  226. package/dist/speculative.js.map +1 -0
  227. package/dist/store.d.ts +39 -0
  228. package/dist/store.d.ts.map +1 -0
  229. package/dist/store.js +42 -0
  230. package/dist/store.js.map +1 -0
  231. package/dist/style.d.ts +119 -0
  232. package/dist/style.d.ts.map +1 -0
  233. package/dist/style.js +168 -0
  234. package/dist/style.js.map +1 -0
  235. package/dist/testing.d.ts +14 -0
  236. package/dist/testing.d.ts.map +1 -0
  237. package/dist/testing.js +14 -0
  238. package/dist/testing.js.map +1 -0
  239. package/dist/theme.d.ts +78 -0
  240. package/dist/theme.d.ts.map +1 -0
  241. package/dist/theme.js +109 -0
  242. package/dist/theme.js.map +1 -0
  243. package/dist/timeline.d.ts +45 -0
  244. package/dist/timeline.d.ts.map +1 -0
  245. package/dist/timeline.js +101 -0
  246. package/dist/timeline.js.map +1 -0
  247. package/dist/token-buffer.d.ts +43 -0
  248. package/dist/token-buffer.d.ts.map +1 -0
  249. package/dist/token-buffer.js +112 -0
  250. package/dist/token-buffer.js.map +1 -0
  251. package/dist/token.d.ts +107 -0
  252. package/dist/token.d.ts.map +1 -0
  253. package/dist/token.js +143 -0
  254. package/dist/token.js.map +1 -0
  255. package/dist/tuple.d.ts +16 -0
  256. package/dist/tuple.d.ts.map +1 -0
  257. package/dist/tuple.js +16 -0
  258. package/dist/tuple.js.map +1 -0
  259. package/dist/type-utils.d.ts +41 -0
  260. package/dist/type-utils.d.ts.map +1 -0
  261. package/dist/type-utils.js +10 -0
  262. package/dist/type-utils.js.map +1 -0
  263. package/dist/typed-ref.d.ts +50 -0
  264. package/dist/typed-ref.d.ts.map +1 -0
  265. package/dist/typed-ref.js +59 -0
  266. package/dist/typed-ref.js.map +1 -0
  267. package/dist/ui-quality.d.ts +50 -0
  268. package/dist/ui-quality.d.ts.map +1 -0
  269. package/dist/ui-quality.js +64 -0
  270. package/dist/ui-quality.js.map +1 -0
  271. package/dist/validation-error.d.ts +25 -0
  272. package/dist/validation-error.d.ts.map +1 -0
  273. package/dist/validation-error.js +32 -0
  274. package/dist/validation-error.js.map +1 -0
  275. package/dist/vector-clock.d.ts +46 -0
  276. package/dist/vector-clock.d.ts.map +1 -0
  277. package/dist/vector-clock.js +91 -0
  278. package/dist/vector-clock.js.map +1 -0
  279. package/dist/video.d.ts +62 -0
  280. package/dist/video.d.ts.map +1 -0
  281. package/dist/video.js +59 -0
  282. package/dist/video.js.map +1 -0
  283. package/dist/wasm-dispatch.d.ts +52 -0
  284. package/dist/wasm-dispatch.d.ts.map +1 -0
  285. package/dist/wasm-dispatch.js +204 -0
  286. package/dist/wasm-dispatch.js.map +1 -0
  287. package/dist/wasm-fallback.d.ts +19 -0
  288. package/dist/wasm-fallback.d.ts.map +1 -0
  289. package/dist/wasm-fallback.js +93 -0
  290. package/dist/wasm-fallback.js.map +1 -0
  291. package/dist/wire.d.ts +49 -0
  292. package/dist/wire.d.ts.map +1 -0
  293. package/dist/wire.js +201 -0
  294. package/dist/wire.js.map +1 -0
  295. package/dist/zap.d.ts +42 -0
  296. package/dist/zap.d.ts.map +1 -0
  297. package/dist/zap.js +172 -0
  298. package/dist/zap.js.map +1 -0
  299. package/package.json +71 -0
  300. package/src/addressed-digest.ts +48 -0
  301. package/src/animation.ts +103 -0
  302. package/src/assembly.ts +76 -0
  303. package/src/av-bridge.ts +161 -0
  304. package/src/av-renderer.ts +118 -0
  305. package/src/blend.ts +135 -0
  306. package/src/boundary.ts +363 -0
  307. package/src/brands.ts +86 -0
  308. package/src/caps.ts +100 -0
  309. package/src/capsule.ts +95 -0
  310. package/src/capsules/boundary-evaluate.ts +128 -0
  311. package/src/capsules/canonical-cbor.ts +60 -0
  312. package/src/capsules/token-buffer.ts +57 -0
  313. package/src/capture.ts +48 -0
  314. package/src/cbor.ts +199 -0
  315. package/src/cell.ts +130 -0
  316. package/src/codec.ts +39 -0
  317. package/src/component.ts +102 -0
  318. package/src/composable.ts +328 -0
  319. package/src/compositor-pool.ts +162 -0
  320. package/src/compositor.ts +387 -0
  321. package/src/config.ts +157 -0
  322. package/src/dag.ts +527 -0
  323. package/src/defaults.ts +60 -0
  324. package/src/derived.ts +164 -0
  325. package/src/diagnostics.ts +186 -0
  326. package/src/dirty.ts +101 -0
  327. package/src/easing.ts +334 -0
  328. package/src/ecs.ts +382 -0
  329. package/src/fnv.ts +31 -0
  330. package/src/frame-budget.ts +149 -0
  331. package/src/gen-frame.ts +229 -0
  332. package/src/harness/arbitrary-from-schema.ts +270 -0
  333. package/src/harness/cached-projection.ts +46 -0
  334. package/src/harness/index.ts +16 -0
  335. package/src/harness/policy-gate.ts +51 -0
  336. package/src/harness/pure-transform.ts +121 -0
  337. package/src/harness/receipted-mutation.ts +59 -0
  338. package/src/harness/scene-composition.ts +54 -0
  339. package/src/harness/site-adapter.ts +43 -0
  340. package/src/harness/state-machine.ts +49 -0
  341. package/src/hlc.ts +238 -0
  342. package/src/index.ts +274 -0
  343. package/src/interpolate.ts +37 -0
  344. package/src/live-cell.ts +199 -0
  345. package/src/op.ts +233 -0
  346. package/src/plan.ts +317 -0
  347. package/src/protocol.ts +49 -0
  348. package/src/quantizer-types.ts +29 -0
  349. package/src/receipt.ts +444 -0
  350. package/src/runtime-coordinator.ts +230 -0
  351. package/src/scheduler.ts +161 -0
  352. package/src/ship-capsule.ts +191 -0
  353. package/src/signal.ts +345 -0
  354. package/src/speculative.ts +186 -0
  355. package/src/store.ts +77 -0
  356. package/src/style.ts +249 -0
  357. package/src/testing.ts +14 -0
  358. package/src/theme.ts +153 -0
  359. package/src/timeline.ts +146 -0
  360. package/src/token-buffer.ts +151 -0
  361. package/src/token.ts +197 -0
  362. package/src/tuple.ts +19 -0
  363. package/src/type-utils.ts +48 -0
  364. package/src/typed-ref.ts +79 -0
  365. package/src/ui-quality.ts +105 -0
  366. package/src/validation-error.ts +34 -0
  367. package/src/vector-clock.ts +111 -0
  368. package/src/video.ts +106 -0
  369. package/src/wasm-dispatch.ts +300 -0
  370. package/src/wasm-fallback.ts +102 -0
  371. package/src/wire.ts +274 -0
  372. package/src/zap.ts +241 -0
package/src/index.ts ADDED
@@ -0,0 +1,274 @@
1
+ /**
2
+ * `@czap/core` — **LiteShip** primitives for the **CZAP** engine: boundaries,
3
+ * tokens, styles, themes, signals, and working-deck coordination (compositor,
4
+ * plan graph, ECS, capsule factory).
5
+ * @module
6
+ */
7
+
8
+ // Brands — sanctioned constructors. The lower-level `brand` factory is
9
+ // intentionally NOT re-exported here; it is the unsafe escape-hatch used
10
+ // by `brands.ts` itself to define the sanctioned set, and exposing it on
11
+ // the public surface would let consumers forge any brand. Code that
12
+ // genuinely needs to mint a new brand should import from `@czap/core/brands`
13
+ // directly and document the use site.
14
+ export { SignalInput, ThresholdValue, StateName, ContentAddress, IntegrityDigest, TokenRef, Millis } from './brands.js';
15
+ export type { HLC as HLCBrand } from './brands.js';
16
+
17
+ // FNV-1a hash utility
18
+ export { fnv1a, fnv1aBytes } from './fnv.js';
19
+
20
+ // Canonical CBOR encoder (RFC 8949 §4.2.1) — content-address kernel
21
+ export { CanonicalCbor } from './cbor.js';
22
+
23
+ // Type utilities
24
+ export type {
25
+ Prettify,
26
+ StateUnion,
27
+ OutputsFor,
28
+ BoundaryCrossing,
29
+ EffectValue,
30
+ EffectError,
31
+ RequireAtLeastOne,
32
+ DeepReadonly,
33
+ } from './type-utils.js';
34
+
35
+ // Tuple utilities
36
+ export { tupleMap } from './tuple.js';
37
+
38
+ // Boundary. `BoundarySpec` is exported as a value+type pair (see the
39
+ // namespace-object pattern in ADR-0001); consumers who want only the type
40
+ // can `import type { BoundarySpec } from '@czap/core'`.
41
+ export { Boundary, BoundarySpec } from './boundary.js';
42
+
43
+ // Token
44
+ export { Token } from './token.js';
45
+ export type { TokenCategory } from './token.js';
46
+
47
+ // Style
48
+ export { Style } from './style.js';
49
+ export type { StyleLayer, ShadowLayer } from './style.js';
50
+
51
+ // Theme
52
+ export { Theme } from './theme.js';
53
+
54
+ // Component
55
+ export { Component } from './component.js';
56
+ export type { SlotConfig } from './component.js';
57
+
58
+ // Signal
59
+ export { Signal } from './signal.js';
60
+ export type { SignalSourceType, SignalSource } from './signal.js';
61
+
62
+ // Easing
63
+ export { Easing } from './easing.js';
64
+
65
+ // Animation
66
+ export { Animation } from './animation.js';
67
+
68
+ // Timeline
69
+ export { Timeline } from './timeline.js';
70
+
71
+ // Quantizer types
72
+ export type { Quantizer } from './quantizer-types.js';
73
+
74
+ // Scheduler
75
+ export { Scheduler } from './scheduler.js';
76
+
77
+ // Compositor
78
+ export { Compositor } from './compositor.js';
79
+ export type { CompositeState, CompositorConfig } from './compositor.js';
80
+
81
+ // Compositor State Pool
82
+ export { CompositorStatePool } from './compositor-pool.js';
83
+
84
+ // Speculative Evaluation
85
+ export { SpeculativeEvaluator } from './speculative.js';
86
+
87
+ // Token Buffer
88
+ export { TokenBuffer } from './token-buffer.js';
89
+
90
+ // UI Quality
91
+ export { UIQuality } from './ui-quality.js';
92
+ export type { UIQualityTier, MotionTier } from './ui-quality.js';
93
+
94
+ // Generative UI Frames
95
+ export { GenFrame } from './gen-frame.js';
96
+ export type { UIFrame, FrameType, MorphStrategy, GapStrategy } from './gen-frame.js';
97
+
98
+ // Video
99
+ export { VideoRenderer } from './video.js';
100
+ export type { VideoConfig, VideoFrameOutput } from './video.js';
101
+
102
+ // Capture
103
+ export type { CaptureConfig, CaptureFrame, FrameCapture, CaptureResult } from './capture.js';
104
+
105
+ // Blend
106
+ export { BlendTree } from './blend.js';
107
+
108
+ // Frame budget
109
+ export { FrameBudget } from './frame-budget.js';
110
+ export type { Priority } from './frame-budget.js';
111
+
112
+ // Dirty tracking
113
+ export { DirtyFlags } from './dirty.js';
114
+
115
+ // Protocol
116
+ export type { CellKind, CellMeta, CellEnvelope } from './protocol.js';
117
+
118
+ // ECS
119
+ export type { Entity, System, DenseSystem, DenseStore } from './ecs.js';
120
+ export { Part, World, EntityId } from './ecs.js';
121
+
122
+ // Composable
123
+ export { Composable, ComposableWorld } from './composable.js';
124
+ export type { EntityComponents, ComposableEntity, ComposableWorldShape } from './composable.js';
125
+
126
+ // Cell
127
+ export { Cell } from './cell.js';
128
+
129
+ // Derived
130
+ export { Derived } from './derived.js';
131
+
132
+ // Zap
133
+ export { Zap } from './zap.js';
134
+
135
+ // Store
136
+ export { Store } from './store.js';
137
+
138
+ // Wire
139
+ export { Wire } from './wire.js';
140
+
141
+ // Op
142
+ export { Op } from './op.js';
143
+
144
+ // Cap
145
+ export type { CapLevel, CapSet } from './caps.js';
146
+ export { Cap } from './caps.js';
147
+
148
+ // HLC
149
+ export { HLC } from './hlc.js';
150
+
151
+ // VectorClock
152
+ export { VectorClock } from './vector-clock.js';
153
+
154
+ // TypedRef
155
+ export { TypedRef } from './typed-ref.js';
156
+
157
+ // Receipt
158
+ export type { ReceiptSubject, ReceiptEnvelope, ChainValidationError } from './receipt.js';
159
+ export { Receipt } from './receipt.js';
160
+
161
+ // DAG
162
+ export type { DAGNode, ReceiptDAG, MergeResult, ForkViolation } from './dag.js';
163
+ export { DAG } from './dag.js';
164
+
165
+ // Plan
166
+ export { Plan } from './plan.js';
167
+ export type { OpType, EdgeType } from './plan.js';
168
+
169
+ // Runtime coordination
170
+ export { RuntimeCoordinator } from './runtime-coordinator.js';
171
+ export type { RuntimePhase, RuntimeCoordinatorConfig } from './runtime-coordinator.js';
172
+
173
+ // Codec
174
+ export { Codec } from './codec.js';
175
+ // `SchemaError` / `isSchemaError` removed from the main entry — they were
176
+ // orphan re-exports from `effect/Schema` with no consumers in the repo
177
+ // and added implicit coupling to an Effect internal sub-path. Consumers
178
+ // who need them should import directly from `effect/Schema`.
179
+
180
+ // LiveCell
181
+ export { LiveCell } from './live-cell.js';
182
+
183
+ // WASM Dispatch
184
+ export { WASMDispatch } from './wasm-dispatch.js';
185
+ export type { WASMKernels, WASMDispatchAPI } from './wasm-dispatch.js';
186
+ export { fallbackKernels } from './wasm-fallback.js';
187
+
188
+ // AVBridge
189
+ export { AVBridge } from './av-bridge.js';
190
+
191
+ // AVRenderer
192
+ export { AVRenderer } from './av-renderer.js';
193
+
194
+ // Defaults (centralized constants)
195
+ export {
196
+ DEFAULT_TARGET_FPS,
197
+ MS_PER_SEC,
198
+ SSE_BUFFER_SIZE,
199
+ SSE_HEARTBEAT_MS,
200
+ SSE_RECONNECT_INITIAL_MS,
201
+ SSE_RECONNECT_MAX_MS,
202
+ COMPOSITOR_POOL_CAP,
203
+ DIRTY_FLAGS_MAX,
204
+ WASM_SCRATCH_BASE,
205
+ CAPTURE_KEYFRAME_INTERVAL,
206
+ EASING_SPRING_STEPS,
207
+ THEME_TRANSITION_DURATION_MS,
208
+ THEME_TRANSITION_EASING,
209
+ CANVAS_FALLBACK_WIDTH,
210
+ CANVAS_FALLBACK_HEIGHT,
211
+ VIEWPORT,
212
+ } from './defaults.js';
213
+
214
+ // Validation error
215
+ export { CzapValidationError, isValidationError } from './validation-error.js';
216
+
217
+ // Diagnostics
218
+ export { Diagnostics } from './diagnostics.js';
219
+ export type { DiagnosticEvent, DiagnosticLevel, DiagnosticPayload, DiagnosticsSink } from './diagnostics.js';
220
+
221
+ // AddressedDigest + ShipCapsule (ADR-0011)
222
+ // Browser-bundleable: pure type + crypto.subtle hashing. The Node-only
223
+ // release-input manifest helpers (gzip/tar/yaml) live in @czap/cli.
224
+ export { AddressedDigest } from './addressed-digest.js';
225
+ export { ShipCapsule } from './ship-capsule.js';
226
+
227
+ // Type guards
228
+ import type { Cell as _Cell } from './cell.js';
229
+ import type { Derived as _Derived } from './derived.js';
230
+ import type { Zap as _Zap } from './zap.js';
231
+ import type { Wire as _Wire } from './wire.js';
232
+
233
+ /** Union of the four reactive primitives the CZAP graph exposes to user code. */
234
+ export type Primitive<T> = _Cell.Shape<T> | _Derived.Shape<T> | _Zap.Shape<T> | _Wire.Shape<T>;
235
+
236
+ /** Narrow a {@link Primitive} to a {@link Cell}. */
237
+ export const isCell = <T>(p: Primitive<T>): p is _Cell.Shape<T> => p._tag === 'Cell';
238
+ /** Narrow a {@link Primitive} to a {@link Derived}. */
239
+ export const isDerived = <T>(p: Primitive<T>): p is _Derived.Shape<T> => p._tag === 'Derived';
240
+ /** Narrow a {@link Primitive} to a {@link Zap}. */
241
+ export const isZap = <T>(p: Primitive<T>): p is _Zap.Shape<T> => p._tag === 'Zap';
242
+ /** Narrow a {@link Primitive} to a {@link Wire}. */
243
+ export const isWire = <T>(p: Primitive<T>): p is _Wire.Shape<T> => p._tag === 'Wire';
244
+
245
+ // Config hub
246
+ export { Config, defineConfig } from './config.js';
247
+ export type { PrimitiveKind, PluginConfig as CorePluginConfig, AstroConfig as CoreAstroConfig } from './config.js';
248
+
249
+ // Capsule factory base types
250
+ export type {
251
+ AssemblyKind,
252
+ Site,
253
+ CapabilityDecl,
254
+ BudgetDecl,
255
+ Invariant,
256
+ AttributionDecl,
257
+ CapsuleContract,
258
+ } from './capsule.js';
259
+
260
+ export { TypeValidator } from './capsule.js';
261
+
262
+ export { defineCapsule, getCapsuleCatalog } from './assembly.js';
263
+ export type { CapsuleDef } from './assembly.js';
264
+ // `resetCapsuleCatalog` is intentionally NOT re-exported here — it mutates
265
+ // global registry state and ships from `@czap/core/testing` only.
266
+
267
+ // Capsule declarations — concrete instances of the 7-arm factory
268
+ export { boundaryEvaluateCapsule } from './capsules/boundary-evaluate.js';
269
+ export { tokenBufferCapsule } from './capsules/token-buffer.js';
270
+ export { canonicalCborCapsule } from './capsules/canonical-cbor.js';
271
+
272
+ // Harness lives at `@czap/core/harness` — per-arm test + bench template
273
+ // generators. Not re-exported here so consumers don't pull fast-check and
274
+ // the code-gen surface into every bundle.
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Value lerping between output states.
3
+ *
4
+ * Linearly interpolates all numeric properties of a record
5
+ * from one state to another, controlled by an eased progress value.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ /**
11
+ * Interpolate between two numeric records using an eased value [0..1].
12
+ * Returns a new record with each property lerped: from[k] + (to[k] - from[k]) * eased.
13
+ */
14
+ export function interpolate<T extends Record<string, number>>(
15
+ from: T,
16
+ to: T,
17
+ eased: number,
18
+ defaults?: Partial<Record<string, number>>,
19
+ ): T {
20
+ const result: Record<string, number> = {};
21
+ for (const [key, a] of Object.entries(from)) {
22
+ const b = to[key] ?? a;
23
+ result[key] = a + (b - a) * eased;
24
+ }
25
+ // Second pass: keys only in `to` (interpolate from implicit 0)
26
+ for (const [key, b] of Object.entries(to)) {
27
+ if (key in result) {
28
+ continue;
29
+ }
30
+
31
+ const base = defaults?.[key] ?? 0;
32
+ result[key] = base + (b - base) * eased;
33
+ }
34
+ // `result` has every key present in `from`/`to`, both of which are T. The
35
+ // output is structurally a T but TS can't infer that through Object.entries.
36
+ return result as unknown as T;
37
+ }
@@ -0,0 +1,199 @@
1
+ /**
2
+ * `LiveCell<K, T>` — bridge between protocol envelope and reactive runtime.
3
+ *
4
+ * A LiveCell is a Cell that also carries a CellEnvelope, tracking
5
+ * its kind, content address, metadata (HLC timestamps, version),
6
+ * and boundary crossings.
7
+ *
8
+ * @module
9
+ */
10
+
11
+ import type { Scope } from 'effect';
12
+ import { Effect, Stream, PubSub, Ref } from 'effect';
13
+ import { Cell } from './cell.js';
14
+ import type { CellKind, CellMeta, CellEnvelope } from './protocol.js';
15
+ import type { ContentAddress, HLC as HLCBrand } from './brands.js';
16
+ import { ContentAddress as mkContentAddress, StateName as mkStateName } from './brands.js';
17
+ import type { BoundaryCrossing } from './type-utils.js';
18
+ import { HLC } from './hlc.js';
19
+ import { canonicalize, hash } from './typed-ref.js';
20
+ import { Boundary } from './boundary.js';
21
+
22
+ interface LiveCellShape<K extends CellKind, T> extends Omit<Cell.Shape<T>, '_tag'> {
23
+ readonly _tag: 'LiveCell';
24
+ readonly envelope: Effect.Effect<CellEnvelope<K, T>>;
25
+ readonly crossings: Stream.Stream<BoundaryCrossing<string>>;
26
+ readonly kind: K;
27
+ publishCrossing(crossing: BoundaryCrossing<string>): Effect.Effect<void>;
28
+ }
29
+
30
+ function _make<K extends CellKind, T>(kind: K, initial: T): Effect.Effect<LiveCellShape<K, T>, never, Scope.Scope> {
31
+ return Effect.gen(function* () {
32
+ const cell = yield* Cell.make(initial);
33
+ const clockRef = yield* HLC.makeClock(`live-cell-${kind}`);
34
+ const createdHlc = yield* HLC.tick(clockRef);
35
+ const versionRef = yield* Ref.make(1);
36
+ const crossingPub = yield* PubSub.unbounded<BoundaryCrossing<string>>();
37
+ const createdRef = yield* Ref.make<HLCBrand>(createdHlc);
38
+ const updatedRef = yield* Ref.make<HLCBrand>(createdHlc);
39
+
40
+ const computeId = (value: T): Effect.Effect<ContentAddress> =>
41
+ Effect.gen(function* () {
42
+ const h = yield* hash(canonicalize({ kind, value }));
43
+ return mkContentAddress(h);
44
+ });
45
+
46
+ const initialId = yield* computeId(initial);
47
+ const idRef = yield* Ref.make<ContentAddress>(initialId);
48
+
49
+ const recordMutation = (value: T): Effect.Effect<void> =>
50
+ Effect.gen(function* () {
51
+ const hlc = yield* HLC.tick(clockRef);
52
+ yield* Ref.set(updatedRef, hlc);
53
+ yield* Ref.update(versionRef, (v) => v + 1);
54
+ const newId = yield* computeId(value);
55
+ yield* Ref.set(idRef, newId);
56
+ });
57
+
58
+ const liveCell: LiveCellShape<K, T> = {
59
+ _tag: 'LiveCell' as const,
60
+ ref: cell.ref,
61
+ changes: cell.changes,
62
+ get: cell.get,
63
+ set: (value: T) =>
64
+ Effect.gen(function* () {
65
+ yield* cell.set(value);
66
+ yield* recordMutation(value);
67
+ }),
68
+ update: (f: (current: T) => T) =>
69
+ Effect.gen(function* () {
70
+ const current = yield* cell.get;
71
+ const next = f(current);
72
+ yield* cell.set(next);
73
+ yield* recordMutation(next);
74
+ }),
75
+ kind,
76
+ crossings: Stream.fromPubSub(crossingPub),
77
+ publishCrossing: (crossing: BoundaryCrossing<string>) => PubSub.publish(crossingPub, crossing),
78
+ envelope: Effect.gen(function* () {
79
+ const value = yield* cell.get;
80
+ const created = yield* Ref.get(createdRef);
81
+ const updated = yield* Ref.get(updatedRef);
82
+ const version = yield* Ref.get(versionRef);
83
+ const id = yield* Ref.get(idRef);
84
+
85
+ const meta: CellMeta = { created, updated, version };
86
+ const envelope: CellEnvelope<K, T> = { kind, id, meta, value };
87
+ return envelope;
88
+ }),
89
+ };
90
+
91
+ return liveCell;
92
+ });
93
+ }
94
+
95
+ /**
96
+ * Create a boundary-kind LiveCell that automatically publishes crossings
97
+ * when the numeric value transitions between boundary states.
98
+ */
99
+ function _makeBoundary<I extends string, S extends readonly [string, ...string[]]>(
100
+ boundary: Boundary.Shape<I, S>,
101
+ initial: number,
102
+ ): Effect.Effect<LiveCellShape<'boundary', number>, never, Scope.Scope> {
103
+ return Effect.gen(function* () {
104
+ const cell = yield* Cell.make(initial);
105
+ const clockRef = yield* HLC.makeClock(`live-cell-boundary`);
106
+ const createdHlc = yield* HLC.tick(clockRef);
107
+ const versionRef = yield* Ref.make(1);
108
+ const crossingPub = yield* PubSub.unbounded<BoundaryCrossing<string>>();
109
+ const createdRef = yield* Ref.make<HLCBrand>(createdHlc);
110
+ const updatedRef = yield* Ref.make<HLCBrand>(createdHlc);
111
+ const kind = 'boundary' as const;
112
+
113
+ const computeId = (value: number): Effect.Effect<ContentAddress> =>
114
+ Effect.gen(function* () {
115
+ const h = yield* hash(canonicalize({ kind, value }));
116
+ return mkContentAddress(h);
117
+ });
118
+
119
+ const initialId = yield* computeId(initial);
120
+ const idRef = yield* Ref.make<ContentAddress>(initialId);
121
+
122
+ const initialState: string = Boundary.evaluate(boundary, initial);
123
+ const prevStateRef = yield* Ref.make(initialState);
124
+
125
+ const recordMutation = (value: number): Effect.Effect<void> =>
126
+ Effect.gen(function* () {
127
+ const hlc = yield* HLC.tick(clockRef);
128
+ yield* Ref.set(updatedRef, hlc);
129
+ yield* Ref.update(versionRef, (v) => v + 1);
130
+ const newId = yield* computeId(value);
131
+ yield* Ref.set(idRef, newId);
132
+
133
+ const prevState = yield* Ref.get(prevStateRef);
134
+ const nextState: string = Boundary.evaluateWithHysteresis(boundary, value, prevState);
135
+ if (nextState !== prevState) {
136
+ yield* Ref.set(prevStateRef, nextState);
137
+ yield* PubSub.publish(crossingPub, {
138
+ from: mkStateName(prevState),
139
+ to: mkStateName(nextState),
140
+ timestamp: hlc,
141
+ value,
142
+ });
143
+ }
144
+ });
145
+
146
+ const liveCell: LiveCellShape<'boundary', number> = {
147
+ _tag: 'LiveCell' as const,
148
+ ref: cell.ref,
149
+ changes: cell.changes,
150
+ get: cell.get,
151
+ set: (value: number) =>
152
+ Effect.gen(function* () {
153
+ yield* cell.set(value);
154
+ yield* recordMutation(value);
155
+ }),
156
+ update: (f: (current: number) => number) =>
157
+ Effect.gen(function* () {
158
+ const current = yield* cell.get;
159
+ const next = f(current);
160
+ yield* cell.set(next);
161
+ yield* recordMutation(next);
162
+ }),
163
+ kind,
164
+ crossings: Stream.fromPubSub(crossingPub),
165
+ publishCrossing: (crossing: BoundaryCrossing<string>) => PubSub.publish(crossingPub, crossing),
166
+ envelope: Effect.gen(function* () {
167
+ const value = yield* cell.get;
168
+ const created = yield* Ref.get(createdRef);
169
+ const updated = yield* Ref.get(updatedRef);
170
+ const version = yield* Ref.get(versionRef);
171
+ const id = yield* Ref.get(idRef);
172
+
173
+ const meta: CellMeta = { created, updated, version };
174
+ const envelope: CellEnvelope<'boundary', number> = { kind, id, meta, value };
175
+ return envelope;
176
+ }),
177
+ };
178
+
179
+ return liveCell;
180
+ });
181
+ }
182
+
183
+ /**
184
+ * LiveCell — bridge between the {@link Cell} reactive graph and the wire
185
+ * protocol. A `LiveCell` wraps a `Cell` with a typed {@link CellEnvelope} —
186
+ * kind, content address, HLC, boundary crossings — so primitives can travel
187
+ * between peers as self-describing messages.
188
+ */
189
+ export const LiveCell = {
190
+ /** Wrap an arbitrary value in a {@link LiveCell} with freshly minted identity + HLC. */
191
+ make: _make,
192
+ /** Specialized factory for boundary crossings so the envelope captures crossing metadata. */
193
+ makeBoundary: _makeBoundary,
194
+ };
195
+
196
+ export declare namespace LiveCell {
197
+ /** Structural shape of a {@link LiveCell} parameterized by cell kind `K` and value type `T`. */
198
+ export type Shape<K extends CellKind, T> = LiveCellShape<K, T>;
199
+ }