@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
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Type-level utilities for `@czap/core`.
3
+ *
4
+ * Mapped types, conditional helpers, and structural utilities
5
+ * used across boundary definitions and compositor outputs.
6
+ *
7
+ * @module
8
+ */
9
+ import type { Boundary } from './boundary.js';
10
+ import type { StateName, HLC } from './brands.js';
11
+ import type { Effect as EffectType } from 'effect';
12
+ /** Flatten branded intersections for clean IDE hints */
13
+ export type Prettify<T> = {
14
+ [K in keyof T]: T[K];
15
+ } & {};
16
+ /** Extract literal union of state names from a Boundary.Shape */
17
+ export type StateUnion<B extends Boundary.Shape> = B['states'][number];
18
+ /** Generate valid output shapes per state */
19
+ export type OutputsFor<B extends Boundary.Shape, T> = {
20
+ readonly [S in StateUnion<B>]: T;
21
+ };
22
+ /** Discriminated union of boundary crossings */
23
+ export type BoundaryCrossing<S extends string = string> = {
24
+ readonly from: StateName<S>;
25
+ readonly to: StateName<S>;
26
+ readonly timestamp: HLC;
27
+ readonly value: number;
28
+ };
29
+ /** Extract the value type from an Effect */
30
+ export type EffectValue<T> = T extends EffectType.Effect<infer A, unknown, unknown> ? A : never;
31
+ /** Extract the error type from an Effect */
32
+ export type EffectError<T> = T extends EffectType.Effect<unknown, infer E, unknown> ? E : never;
33
+ /** Require at least one key of T */
34
+ export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
35
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
36
+ }[Keys];
37
+ /** Deep readonly */
38
+ export type DeepReadonly<T> = T extends (infer U)[] ? ReadonlyArray<DeepReadonly<U>> : T extends Record<string, unknown> ? {
39
+ readonly [K in keyof T]: DeepReadonly<T[K]>;
40
+ } : T;
41
+ //# sourceMappingURL=type-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../src/type-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEnD,wDAAwD;AACxD,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAC;AAExD,iEAAiE;AACjE,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE,6CAA6C;AAC7C,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI;IACpD,QAAQ,EAAE,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;CACjC,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IACxD,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEhG,4CAA4C;AAC5C,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEhG,oCAAoC;AACpC,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,IAAI,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,GAChG;KAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,IAAI,CAAC,CAAC;AAErF,oBAAoB;AACpB,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC/C,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAC9B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC/C,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Type-level utilities for `@czap/core`.
3
+ *
4
+ * Mapped types, conditional helpers, and structural utilities
5
+ * used across boundary definitions and compositor outputs.
6
+ *
7
+ * @module
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=type-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-utils.js","sourceRoot":"","sources":["../src/type-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * TypedRef -- content-addressed payload references.
3
+ *
4
+ * Uses CBOR canonical encoding (cborg) and SHA-256 via crypto.subtle.
5
+ *
6
+ * @module
7
+ */
8
+ import { Effect } from 'effect';
9
+ interface TypedRefShape {
10
+ readonly schema_hash: string;
11
+ readonly content_hash: string;
12
+ }
13
+ /** Canonicalize value to CBOR bytes using canonical (deterministic) encoding. */
14
+ export declare const canonicalize: (value: unknown) => Uint8Array;
15
+ /**
16
+ * Hash data using SHA-256. Returns "sha256:hex" formatted hash.
17
+ *
18
+ * The `bytes as BufferSource` assertion is the single sanctioned cast in this
19
+ * file. `Uint8Array` is structurally a BufferSource, but TS's DOM lib types
20
+ * `bytes.buffer` as potentially-SharedArrayBuffer, preventing direct assignment.
21
+ * Safe: cborg encodes into fresh ArrayBuffer and TextEncoder.encode returns
22
+ * ArrayBuffer-backed views. No data copy.
23
+ *
24
+ * Hash-primitive failures are unrecoverable in practice (crypto.subtle errors
25
+ * are environment-level, not user-recoverable), so we `Effect.orDie` to fold
26
+ * the Error channel into a defect and keep the `Effect<string>` signature that
27
+ * the content-addressing pipeline relies on.
28
+ */
29
+ export declare const hash: (data: string | Uint8Array) => Effect.Effect<string>;
30
+ /**
31
+ * TypedRef — schema-plus-content-hash pointer used by the receipt pipeline.
32
+ * Lets a receipt reference a payload by its content address without embedding
33
+ * the payload itself, while still binding it to a schema identity.
34
+ */
35
+ export declare const TypedRef: {
36
+ /** Build a {@link TypedRef} from a schema hash and an arbitrary payload. */
37
+ create: (schemaHash: string, payload: unknown) => Effect.Effect<TypedRefShape>;
38
+ /** Structural equality over schema + content hashes. */
39
+ equals: (a: TypedRefShape, b: TypedRefShape) => boolean;
40
+ /** Canonical-CBOR-ish serialization used to compute the content hash. */
41
+ canonicalize: (value: unknown) => Uint8Array;
42
+ /** Hash a canonicalized payload to its content address. */
43
+ hash: (data: string | Uint8Array) => Effect.Effect<string>;
44
+ };
45
+ export declare namespace TypedRef {
46
+ /** Structural shape of a typed reference: schema hash + content hash. */
47
+ type Shape = TypedRefShape;
48
+ }
49
+ export {};
50
+ //# sourceMappingURL=typed-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-ref.d.ts","sourceRoot":"","sources":["../src/typed-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,UAAU,aAAa;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,iFAAiF;AACjF,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,UAA2B,CAAC;AAE1E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,GAAG,UAAU,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAW9C,CAAC;AAaxB;;;;GAIG;AACH,eAAO,MAAM,QAAQ;IACnB,4EAA4E;yBAhBjD,MAAM,WAAW,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;IAkBlF,wDAAwD;gBAXtC,aAAa,KAAK,aAAa,KAAG,OAAO;IAa3D,yEAAyE;0BAlDvC,OAAO,KAAG,UAAU;IAoDtD,2DAA2D;iBApClC,MAAM,GAAG,UAAU,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;CAsCrE,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,yEAAyE;IACzE,KAAY,KAAK,GAAG,aAAa,CAAC;CACnC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * TypedRef -- content-addressed payload references.
3
+ *
4
+ * Uses CBOR canonical encoding (cborg) and SHA-256 via crypto.subtle.
5
+ *
6
+ * @module
7
+ */
8
+ import { Effect } from 'effect';
9
+ import { encode } from 'cborg';
10
+ /** Canonicalize value to CBOR bytes using canonical (deterministic) encoding. */
11
+ export const canonicalize = (value) => encode(value);
12
+ /**
13
+ * Hash data using SHA-256. Returns "sha256:hex" formatted hash.
14
+ *
15
+ * The `bytes as BufferSource` assertion is the single sanctioned cast in this
16
+ * file. `Uint8Array` is structurally a BufferSource, but TS's DOM lib types
17
+ * `bytes.buffer` as potentially-SharedArrayBuffer, preventing direct assignment.
18
+ * Safe: cborg encodes into fresh ArrayBuffer and TextEncoder.encode returns
19
+ * ArrayBuffer-backed views. No data copy.
20
+ *
21
+ * Hash-primitive failures are unrecoverable in practice (crypto.subtle errors
22
+ * are environment-level, not user-recoverable), so we `Effect.orDie` to fold
23
+ * the Error channel into a defect and keep the `Effect<string>` signature that
24
+ * the content-addressing pipeline relies on.
25
+ */
26
+ export const hash = (data) => Effect.tryPromise({
27
+ try: async () => {
28
+ const bytes = typeof data === 'string' ? new TextEncoder().encode(data) : data;
29
+ const buffer = await crypto.subtle.digest('SHA-256', bytes);
30
+ const hashHex = Array.from(new Uint8Array(buffer))
31
+ .map((b) => b.toString(16).padStart(2, '0'))
32
+ .join('');
33
+ return `sha256:${hashHex}`;
34
+ },
35
+ catch: (error) => new Error(`SHA-256 hash failed: ${error instanceof Error ? error.message : String(error)}`),
36
+ }).pipe(Effect.orDie);
37
+ /** Create a TypedRef from schema hash and payload. */
38
+ const _create = (schemaHash, payload) => Effect.gen(function* () {
39
+ const contentHash = yield* hash(canonicalize(payload));
40
+ return { schema_hash: schemaHash, content_hash: contentHash };
41
+ });
42
+ /** Compare two TypedRefs for structural equality. */
43
+ const _equals = (a, b) => a.schema_hash === b.schema_hash && a.content_hash === b.content_hash;
44
+ /**
45
+ * TypedRef — schema-plus-content-hash pointer used by the receipt pipeline.
46
+ * Lets a receipt reference a payload by its content address without embedding
47
+ * the payload itself, while still binding it to a schema identity.
48
+ */
49
+ export const TypedRef = {
50
+ /** Build a {@link TypedRef} from a schema hash and an arbitrary payload. */
51
+ create: _create,
52
+ /** Structural equality over schema + content hashes. */
53
+ equals: _equals,
54
+ /** Canonical-CBOR-ish serialization used to compute the content hash. */
55
+ canonicalize,
56
+ /** Hash a canonicalized payload to its content address. */
57
+ hash,
58
+ };
59
+ //# sourceMappingURL=typed-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-ref.js","sourceRoot":"","sources":["../src/typed-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAS/B,iFAAiF;AACjF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAc,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAE1E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAyB,EAAyB,EAAE,CACvE,MAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,KAAK,IAAI,EAAE;QACd,MAAM,KAAK,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/E,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAqB,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;aAC/C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;aAC3C,IAAI,CAAC,EAAE,CAAC,CAAC;QACZ,OAAO,UAAU,OAAO,EAAE,CAAC;IAC7B,CAAC;IACD,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,wBAAwB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;CAC9G,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAExB,sDAAsD;AACtD,MAAM,OAAO,GAAG,CAAC,UAAkB,EAAE,OAAgB,EAAgC,EAAE,CACrF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;AAChE,CAAC,CAAC,CAAC;AAEL,qDAAqD;AACrD,MAAM,OAAO,GAAG,CAAC,CAAgB,EAAE,CAAgB,EAAW,EAAE,CAC9D,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY,CAAC;AAEvE;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,4EAA4E;IAC5E,MAAM,EAAE,OAAO;IACf,wDAAwD;IACxD,MAAM,EAAE,OAAO;IACf,yEAAyE;IACzE,YAAY;IACZ,2DAA2D;IAC3D,IAAI;CACL,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * UIQuality -- maps buffer occupancy + device capability to UI complexity tier.
3
+ *
4
+ * Same pattern as video ABR (Adaptive Bitrate). Composite signal from
5
+ * buffer occupancy and device tier determines rendering fidelity.
6
+ *
7
+ * @module
8
+ */
9
+ import type { MotionTier as _MotionTier } from '@czap/_spine';
10
+ import { Boundary } from './boundary.js';
11
+ /**
12
+ * Motion tier — re-anchored from `@czap/_spine` (the canonical declaration
13
+ * per ADR-0010). The ladder runs from lowest capability (`none`, forced by
14
+ * `prefers-reduced-motion: reduce` regardless of GPU tier) to highest
15
+ * (`compute`, which unlocks the Rust/WASM kernels).
16
+ */
17
+ export type MotionTier = _MotionTier;
18
+ /**
19
+ * Coarse UI-complexity ladder, in increasing fidelity: `skeleton` (placeholder
20
+ * blocks only) up through `rich` (full interactive styled content).
21
+ */
22
+ export type UIQualityTier = 'skeleton' | 'text-only' | 'styled' | 'interactive' | 'rich';
23
+ /** {@link Boundary.Shape} instantiation used by {@link UIQuality} — input = `buffer-occupancy`, states = the {@link UIQualityTier} ladder. */
24
+ export type UIQualityBoundary = Boundary.Shape<'buffer-occupancy', readonly ['skeleton', 'text-only', 'styled', 'interactive', 'rich']>;
25
+ interface UIQualityEvaluatorShape {
26
+ evaluate(bufferOccupancy: number, deviceTier?: MotionTier): UIQualityTier;
27
+ readonly boundary: UIQualityBoundary;
28
+ }
29
+ declare function _make(): UIQualityEvaluatorShape;
30
+ /**
31
+ * UIQuality — adaptive-bitrate-style UI fidelity gate.
32
+ *
33
+ * Combines buffer occupancy (how far ahead the generator is) and device
34
+ * {@link MotionTier} into a composite score and maps it via {@link Boundary}
35
+ * with hysteresis to a {@link UIQualityTier}.
36
+ */
37
+ export declare const UIQuality: {
38
+ /** Build a stateful evaluator that remembers the previous tier for hysteresis. */
39
+ make: typeof _make;
40
+ /** The pre-built boundary — exposed so callers can compile it to CSS/GLSL directly. */
41
+ boundary: UIQualityBoundary;
42
+ };
43
+ export declare namespace UIQuality {
44
+ /** Structural shape of a UIQuality evaluator. */
45
+ type Shape = UIQualityEvaluatorShape;
46
+ /** Alias for {@link UIQualityTier}. */
47
+ type Tier = UIQualityTier;
48
+ }
49
+ export {};
50
+ //# sourceMappingURL=ui-quality.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-quality.d.ts","sourceRoot":"","sources":["../src/ui-quality.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,aAAa,GAAG,MAAM,CAAC;AAEzF,8IAA8I;AAC9I,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,KAAK,CAC5C,kBAAkB,EAClB,SAAS,CAAC,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,CAAC,CACpE,CAAC;AA6BF,UAAU,uBAAuB;IAC/B,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,aAAa,CAAC;IAC1E,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;CACtC;AAED,iBAAS,KAAK,IAAI,uBAAuB,CAmBxC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;IACpB,kFAAkF;;IAElF,uFAAuF;;CAExF,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC,iDAAiD;IACjD,KAAY,KAAK,GAAG,uBAAuB,CAAC;IAC5C,uCAAuC;IACvC,KAAY,IAAI,GAAG,aAAa,CAAC;CAClC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * UIQuality -- maps buffer occupancy + device capability to UI complexity tier.
3
+ *
4
+ * Same pattern as video ABR (Adaptive Bitrate). Composite signal from
5
+ * buffer occupancy and device tier determines rendering fidelity.
6
+ *
7
+ * @module
8
+ */
9
+ import { Boundary } from './boundary.js';
10
+ /**
11
+ * Pre-built boundary for UI quality based on buffer occupancy signal.
12
+ * Thresholds tuned for streaming UI: aggressive degradation when buffer low.
13
+ */
14
+ const uiQualityBoundary = Boundary.make({
15
+ input: 'buffer-occupancy',
16
+ at: [
17
+ [0.0, 'skeleton'],
18
+ [0.15, 'text-only'],
19
+ [0.35, 'styled'],
20
+ [0.6, 'interactive'],
21
+ [0.85, 'rich'],
22
+ ],
23
+ hysteresis: 0.1,
24
+ });
25
+ /**
26
+ * Motion tier to normalized device capability score (0-1).
27
+ */
28
+ const DEVICE_CAPABILITY_SCORES = {
29
+ none: 0.0,
30
+ transitions: 0.25,
31
+ animations: 0.5,
32
+ physics: 0.75,
33
+ compute: 1.0,
34
+ };
35
+ function _make() {
36
+ let previousTier = 'skeleton';
37
+ return {
38
+ evaluate(bufferOccupancy, deviceTier) {
39
+ // Composite signal: buffer occupancy weighted more heavily
40
+ const deviceScore = deviceTier ? DEVICE_CAPABILITY_SCORES[deviceTier] : 0.5;
41
+ const composite = bufferOccupancy * 0.7 + deviceScore * 0.3;
42
+ // Boundary.evaluateWithHysteresis now returns the exact state literal union ('skeleton' | ... | 'rich')
43
+ // because uiQualityBoundary's S parameter is narrowed via `as const`.
44
+ const result = Boundary.evaluateWithHysteresis(uiQualityBoundary, composite, previousTier);
45
+ previousTier = result;
46
+ return result;
47
+ },
48
+ boundary: uiQualityBoundary,
49
+ };
50
+ }
51
+ /**
52
+ * UIQuality — adaptive-bitrate-style UI fidelity gate.
53
+ *
54
+ * Combines buffer occupancy (how far ahead the generator is) and device
55
+ * {@link MotionTier} into a composite score and maps it via {@link Boundary}
56
+ * with hysteresis to a {@link UIQualityTier}.
57
+ */
58
+ export const UIQuality = {
59
+ /** Build a stateful evaluator that remembers the previous tier for hysteresis. */
60
+ make: _make,
61
+ /** The pre-built boundary — exposed so callers can compile it to CSS/GLSL directly. */
62
+ boundary: uiQualityBoundary,
63
+ };
64
+ //# sourceMappingURL=ui-quality.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-quality.js","sourceRoot":"","sources":["../src/ui-quality.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAsBzC;;;GAGG;AACH,MAAM,iBAAiB,GAAsB,QAAQ,CAAC,IAAI,CAAC;IACzD,KAAK,EAAE,kBAAkB;IACzB,EAAE,EAAE;QACF,CAAC,GAAG,EAAE,UAAU,CAAC;QACjB,CAAC,IAAI,EAAE,WAAW,CAAC;QACnB,CAAC,IAAI,EAAE,QAAQ,CAAC;QAChB,CAAC,GAAG,EAAE,aAAa,CAAC;QACpB,CAAC,IAAI,EAAE,MAAM,CAAC;KACN;IACV,UAAU,EAAE,GAAG;CAChB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,wBAAwB,GAA+B;IAC3D,IAAI,EAAE,GAAG;IACT,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,GAAG;IACf,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,GAAG;CACb,CAAC;AAOF,SAAS,KAAK;IACZ,IAAI,YAAY,GAAkB,UAAU,CAAC;IAE7C,OAAO;QACL,QAAQ,CAAC,eAAuB,EAAE,UAAuB;YACvD,2DAA2D;YAC3D,MAAM,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YAC5E,MAAM,SAAS,GAAG,eAAe,GAAG,GAAG,GAAG,WAAW,GAAG,GAAG,CAAC;YAE5D,wGAAwG;YACxG,sEAAsE;YACtE,MAAM,MAAM,GAAG,QAAQ,CAAC,sBAAsB,CAAC,iBAAiB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;YAE3F,YAAY,GAAG,MAAM,CAAC;YACtB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,QAAQ,EAAE,iBAAiB;KAC5B,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,kFAAkF;IAClF,IAAI,EAAE,KAAK;IACX,uFAAuF;IACvF,QAAQ,EAAE,iBAAiB;CAC5B,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Structured validation error for factory/constructor failures.
3
+ *
4
+ * Thrown (not Effect.fail'd) because all factory functions are synchronous.
5
+ * Callers can catch and `instanceof CzapValidationError` to distinguish
6
+ * czap validation failures from other errors.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Structured validation error thrown by czap factory/constructor functions.
12
+ *
13
+ * Carries a `module` identifier (e.g. `'Boundary.make'`) and a human-readable
14
+ * `detail` message. Synchronous factories throw this directly so callers can
15
+ * `catch` and branch via {@link isValidationError} without Effect plumbing.
16
+ */
17
+ export declare class CzapValidationError extends Error {
18
+ readonly _tag: "CzapValidationError";
19
+ readonly module: string;
20
+ readonly detail: string;
21
+ constructor(module: string, detail: string);
22
+ }
23
+ /** Type guard for CzapValidationError */
24
+ export declare function isValidationError(error: unknown): error is CzapValidationError;
25
+ //# sourceMappingURL=validation-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-error.d.ts","sourceRoot":"","sources":["../src/validation-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAG,qBAAqB,CAAU;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAM3C;AAED,yCAAyC;AACzC,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAE9E"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Structured validation error for factory/constructor failures.
3
+ *
4
+ * Thrown (not Effect.fail'd) because all factory functions are synchronous.
5
+ * Callers can catch and `instanceof CzapValidationError` to distinguish
6
+ * czap validation failures from other errors.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Structured validation error thrown by czap factory/constructor functions.
12
+ *
13
+ * Carries a `module` identifier (e.g. `'Boundary.make'`) and a human-readable
14
+ * `detail` message. Synchronous factories throw this directly so callers can
15
+ * `catch` and branch via {@link isValidationError} without Effect plumbing.
16
+ */
17
+ export class CzapValidationError extends Error {
18
+ _tag = 'CzapValidationError';
19
+ module;
20
+ detail;
21
+ constructor(module, detail) {
22
+ super(`${module}: ${detail}`);
23
+ this.name = 'CzapValidationError';
24
+ this.module = module;
25
+ this.detail = detail;
26
+ }
27
+ }
28
+ /** Type guard for CzapValidationError */
29
+ export function isValidationError(error) {
30
+ return error instanceof CzapValidationError;
31
+ }
32
+ //# sourceMappingURL=validation-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-error.js","sourceRoot":"","sources":["../src/validation-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,GAAG,qBAA8B,CAAC;IACtC,MAAM,CAAS;IACf,MAAM,CAAS;IAExB,YAAY,MAAc,EAAE,MAAc;QACxC,KAAK,CAAC,GAAG,MAAM,KAAK,MAAM,EAAE,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,yCAAyC;AACzC,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,KAAK,YAAY,mBAAmB,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * VectorClock -- causality tracking for distributed systems.
3
+ *
4
+ * @module
5
+ */
6
+ interface VectorClockShape {
7
+ readonly _tag: 'VectorClock';
8
+ readonly entries: ReadonlyMap<string, number>;
9
+ }
10
+ /**
11
+ * VectorClock — per-peer counter algebra for causal ordering.
12
+ * Pairs with {@link HLC} when you need exact happens-before rather than HLC's
13
+ * hybrid ordering.
14
+ */
15
+ export declare const VectorClock: {
16
+ /** Build an empty vector clock. */
17
+ make: () => VectorClockShape;
18
+ /** Build a vector clock from an existing `Record<peer, counter>`. */
19
+ from: (entries: Record<string, number>) => VectorClockShape;
20
+ /** Read the counter for a single peer. */
21
+ get: (vc: VectorClockShape, peerId: string) => number;
22
+ /** Increment the counter for the given peer, returning a new clock. */
23
+ tick: (vc: VectorClockShape, peerId: string) => VectorClockShape;
24
+ /** Pointwise-max merge of two clocks. */
25
+ merge: (a: VectorClockShape, b: VectorClockShape) => VectorClockShape;
26
+ /** `true` iff `a` strictly happens-before `b`. */
27
+ happensBefore: (a: VectorClockShape, b: VectorClockShape) => boolean;
28
+ /** `true` iff `a` and `b` are causally concurrent. */
29
+ concurrent: (a: VectorClockShape, b: VectorClockShape) => boolean;
30
+ /** Exact structural equality. */
31
+ equals: (a: VectorClockShape, b: VectorClockShape) => boolean;
32
+ /** `-1 | 0 | 1` comparator suitable for `sort`; `0` when concurrent. */
33
+ compare: (a: VectorClockShape, b: VectorClockShape) => -1 | 0 | 1;
34
+ /** Convert to a plain `Record<peer, counter>`. */
35
+ toObject: (vc: VectorClockShape) => Record<string, number>;
36
+ /** List peers known to the clock. */
37
+ peers: (vc: VectorClockShape) => string[];
38
+ /** Number of peers. */
39
+ size: (vc: VectorClockShape) => number;
40
+ };
41
+ export declare namespace VectorClock {
42
+ /** Structural shape of a vector clock: a `Map<peer, counter>` wrapper. */
43
+ type Shape = VectorClockShape;
44
+ }
45
+ export {};
46
+ //# sourceMappingURL=vector-clock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector-clock.d.ts","sourceRoot":"","sources":["../src/vector-clock.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,UAAU,gBAAgB;IACxB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/C;AAkED;;;;GAIG;AACH,eAAO,MAAM,WAAW;IACtB,mCAAmC;gBAtEnB,gBAAgB;IAwEhC,qEAAqE;oBAnE/C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,gBAAgB;IAqE/D,0CAA0C;cAhE1B,gBAAgB,UAAU,MAAM,KAAG,MAAM;IAkEzD,uEAAuE;eAhEtD,gBAAgB,UAAU,MAAM,KAAG,gBAAgB;IAkEpE,yCAAyC;eA5DxB,gBAAgB,KAAK,gBAAgB,KAAG,gBAAgB;IA8DzE,kDAAkD;uBArDzB,gBAAgB,KAAK,gBAAgB,KAAG,OAAO;IAuDxE,sDAAsD;oBAjChC,gBAAgB,KAAK,gBAAgB,KAAG,OAAO;IAmCrE,iCAAiC;gBA3Cf,gBAAgB,KAAK,gBAAgB,KAAG,OAAO;IA6CjE,wEAAwE;iBAlCrD,gBAAgB,KAAK,gBAAgB,KAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAoCrE,kDAAkD;mBA9B7B,gBAAgB,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAgC9D,qCAAqC;gBA9BnB,gBAAgB,KAAG,MAAM,EAAE;IAgC7C,uBAAuB;eA9BN,gBAAgB,KAAG,MAAM;CAgC3C,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,0EAA0E;IAC1E,KAAY,KAAK,GAAG,gBAAgB,CAAC;CACtC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * VectorClock -- causality tracking for distributed systems.
3
+ *
4
+ * @module
5
+ */
6
+ const _make = () => ({
7
+ _tag: 'VectorClock',
8
+ entries: new Map(),
9
+ });
10
+ const _from = (entries) => ({
11
+ _tag: 'VectorClock',
12
+ entries: new Map(Object.entries(entries)),
13
+ });
14
+ const _get = (vc, peerId) => vc.entries.get(peerId) ?? 0;
15
+ const _tick = (vc, peerId) => {
16
+ const newEntries = new Map(vc.entries);
17
+ newEntries.set(peerId, _get(vc, peerId) + 1);
18
+ return { _tag: 'VectorClock', entries: newEntries };
19
+ };
20
+ const _merge = (a, b) => {
21
+ const newEntries = new Map(a.entries);
22
+ for (const [peerId, counter] of b.entries) {
23
+ const existing = newEntries.get(peerId) ?? 0;
24
+ newEntries.set(peerId, Math.max(existing, counter));
25
+ }
26
+ return { _tag: 'VectorClock', entries: newEntries };
27
+ };
28
+ const _happensBefore = (a, b) => {
29
+ const allPeers = new Set([...a.entries.keys(), ...b.entries.keys()]);
30
+ let hasStrictlyLess = false;
31
+ for (const peerId of allPeers) {
32
+ const aValue = _get(a, peerId);
33
+ const bValue = _get(b, peerId);
34
+ if (aValue > bValue)
35
+ return false;
36
+ if (aValue < bValue)
37
+ hasStrictlyLess = true;
38
+ }
39
+ return hasStrictlyLess;
40
+ };
41
+ const _equals = (a, b) => {
42
+ const allPeers = new Set([...a.entries.keys(), ...b.entries.keys()]);
43
+ for (const peerId of allPeers) {
44
+ if (_get(a, peerId) !== _get(b, peerId))
45
+ return false;
46
+ }
47
+ return true;
48
+ };
49
+ const _concurrent = (a, b) => !_happensBefore(a, b) && !_happensBefore(b, a) && !_equals(a, b);
50
+ const _compare = (a, b) => {
51
+ if (_happensBefore(a, b))
52
+ return -1;
53
+ if (_happensBefore(b, a))
54
+ return 1;
55
+ return 0;
56
+ };
57
+ const _toObject = (vc) => Object.fromEntries(vc.entries);
58
+ const _peers = (vc) => [...vc.entries.keys()];
59
+ const _size = (vc) => vc.entries.size;
60
+ /**
61
+ * VectorClock — per-peer counter algebra for causal ordering.
62
+ * Pairs with {@link HLC} when you need exact happens-before rather than HLC's
63
+ * hybrid ordering.
64
+ */
65
+ export const VectorClock = {
66
+ /** Build an empty vector clock. */
67
+ make: _make,
68
+ /** Build a vector clock from an existing `Record<peer, counter>`. */
69
+ from: _from,
70
+ /** Read the counter for a single peer. */
71
+ get: _get,
72
+ /** Increment the counter for the given peer, returning a new clock. */
73
+ tick: _tick,
74
+ /** Pointwise-max merge of two clocks. */
75
+ merge: _merge,
76
+ /** `true` iff `a` strictly happens-before `b`. */
77
+ happensBefore: _happensBefore,
78
+ /** `true` iff `a` and `b` are causally concurrent. */
79
+ concurrent: _concurrent,
80
+ /** Exact structural equality. */
81
+ equals: _equals,
82
+ /** `-1 | 0 | 1` comparator suitable for `sort`; `0` when concurrent. */
83
+ compare: _compare,
84
+ /** Convert to a plain `Record<peer, counter>`. */
85
+ toObject: _toObject,
86
+ /** List peers known to the clock. */
87
+ peers: _peers,
88
+ /** Number of peers. */
89
+ size: _size,
90
+ };
91
+ //# sourceMappingURL=vector-clock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector-clock.js","sourceRoot":"","sources":["../src/vector-clock.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * VideoRenderer -- fixed-step frame generator for deterministic video rendering.
3
+ *
4
+ * Same compositor, same state pipeline -- different clock. The VideoRenderer
5
+ * drives a FixedStepScheduler at target fps, producing VideoFrameOutput
6
+ * per frame with the full CompositeState snapshot.
7
+ *
8
+ * @module
9
+ */
10
+ import type { Scheduler } from './scheduler.js';
11
+ import type { CompositeState, Compositor } from './compositor.js';
12
+ import type { Signal } from './signal.js';
13
+ import type { Millis } from './brands.js';
14
+ /** Configuration for a {@link VideoRenderer}: resolution, target fps, and total duration. */
15
+ export interface VideoConfig {
16
+ readonly fps: number;
17
+ readonly width: number;
18
+ readonly height: number;
19
+ readonly durationMs: Millis;
20
+ }
21
+ /**
22
+ * Single frame yielded by `VideoRenderer.frames()`: frame index, timestamp,
23
+ * normalized progress, and the {@link CompositeState} snapshot captured at that tick.
24
+ */
25
+ export interface VideoFrameOutput {
26
+ readonly frame: number;
27
+ readonly timestamp: number;
28
+ readonly progress: number;
29
+ readonly state: CompositeState;
30
+ }
31
+ interface VideoRendererShape {
32
+ readonly config: VideoConfig;
33
+ readonly totalFrames: number;
34
+ readonly scheduler: Scheduler.FixedStep;
35
+ frames(): AsyncGenerator<VideoFrameOutput>;
36
+ }
37
+ /**
38
+ * Create a video renderer that produces deterministic frames from a Compositor.
39
+ *
40
+ * Each call to `frames()` returns an async generator yielding one
41
+ * `VideoFrameOutput` per frame at the configured fps/duration.
42
+ *
43
+ * When a `signal` is provided it is seeked to each frame's timestamp before
44
+ * the compositor evaluates, so quantizers that read from that signal advance
45
+ * deterministically with the render clock.
46
+ */
47
+ declare function _make(config: VideoConfig, compositor: Compositor.Shape, signal?: Signal.Controllable<number>): VideoRendererShape;
48
+ /**
49
+ * VideoRenderer — fixed-step frame generator for deterministic offline rendering.
50
+ * Drives a {@link Compositor} at the configured fps and optionally seeks a
51
+ * controllable time {@link Signal} so every frame is reproducible.
52
+ */
53
+ export declare const VideoRenderer: {
54
+ /** Create a renderer bound to the given compositor and optional seekable time signal. */
55
+ make: typeof _make;
56
+ };
57
+ export declare namespace VideoRenderer {
58
+ /** Structural shape of a renderer instance returned by {@link VideoRenderer.make}. */
59
+ type Shape = VideoRendererShape;
60
+ }
61
+ export {};
62
+ //# sourceMappingURL=video.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../src/video.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAO1C,6FAA6F;AAC7F,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC;AAED,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC;IACxC,MAAM,IAAI,cAAc,CAAC,gBAAgB,CAAC,CAAC;CAC5C;AAMD;;;;;;;;;GASG;AACH,iBAAS,KAAK,CACZ,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE,UAAU,CAAC,KAAK,EAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,GACnC,kBAAkB,CAyBpB;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa;IACxB,yFAAyF;;CAE1F,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,aAAa,CAAC;IACrC,sFAAsF;IACtF,KAAY,KAAK,GAAG,kBAAkB,CAAC;CACxC"}
package/dist/video.js ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * VideoRenderer -- fixed-step frame generator for deterministic video rendering.
3
+ *
4
+ * Same compositor, same state pipeline -- different clock. The VideoRenderer
5
+ * drives a FixedStepScheduler at target fps, producing VideoFrameOutput
6
+ * per frame with the full CompositeState snapshot.
7
+ *
8
+ * @module
9
+ */
10
+ import { Scheduler as SchedulerImpl } from './scheduler.js';
11
+ import { Effect } from 'effect';
12
+ // ---------------------------------------------------------------------------
13
+ // Factory
14
+ // ---------------------------------------------------------------------------
15
+ /**
16
+ * Create a video renderer that produces deterministic frames from a Compositor.
17
+ *
18
+ * Each call to `frames()` returns an async generator yielding one
19
+ * `VideoFrameOutput` per frame at the configured fps/duration.
20
+ *
21
+ * When a `signal` is provided it is seeked to each frame's timestamp before
22
+ * the compositor evaluates, so quantizers that read from that signal advance
23
+ * deterministically with the render clock.
24
+ */
25
+ function _make(config, compositor, signal) {
26
+ const totalFrames = Math.ceil((config.durationMs / 1000) * config.fps);
27
+ const scheduler = SchedulerImpl.fixedStep(config.fps);
28
+ return {
29
+ config,
30
+ totalFrames,
31
+ scheduler,
32
+ async *frames() {
33
+ for (let i = 0; i < totalFrames; i++) {
34
+ scheduler.step();
35
+ const timestamp = (i * 1000) / config.fps;
36
+ if (signal) {
37
+ Effect.runSync(signal.seek(timestamp));
38
+ }
39
+ const state = Effect.runSync(compositor.compute());
40
+ yield {
41
+ frame: i,
42
+ timestamp,
43
+ progress: totalFrames > 1 ? i / (totalFrames - 1) : 1,
44
+ state,
45
+ };
46
+ }
47
+ },
48
+ };
49
+ }
50
+ /**
51
+ * VideoRenderer — fixed-step frame generator for deterministic offline rendering.
52
+ * Drives a {@link Compositor} at the configured fps and optionally seeks a
53
+ * controllable time {@link Signal} so every frame is reproducible.
54
+ */
55
+ export const VideoRenderer = {
56
+ /** Create a renderer bound to the given compositor and optional seekable time signal. */
57
+ make: _make,
58
+ };
59
+ //# sourceMappingURL=video.js.map