@earendil-works/chord 1.4.0 → 1.5.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 (820) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +79 -14
  3. package/dist/cell.d.ts +7 -7
  4. package/dist/cell.d.ts.map +1 -1
  5. package/dist/cell.js.map +1 -1
  6. package/dist/context/index.d.ts +1 -1
  7. package/dist/context/index.d.ts.map +1 -1
  8. package/dist/context/index.js +1 -1
  9. package/dist/context/index.js.map +1 -1
  10. package/dist/contract.d.ts +51 -52
  11. package/dist/contract.d.ts.map +1 -1
  12. package/dist/contract.js +19 -24
  13. package/dist/contract.js.map +1 -1
  14. package/dist/delta/apply-immutable-trusted.js +3 -4
  15. package/dist/delta/apply-immutable-trusted.js.map +1 -1
  16. package/dist/delta/diff.d.ts.map +1 -1
  17. package/dist/delta/diff.js +5 -3
  18. package/dist/delta/diff.js.map +1 -1
  19. package/dist/delta/index.d.ts +9 -1
  20. package/dist/delta/index.d.ts.map +1 -1
  21. package/dist/delta/index.js +15 -11
  22. package/dist/delta/index.js.map +1 -1
  23. package/dist/delta/pending.d.ts +36 -0
  24. package/dist/delta/pending.d.ts.map +1 -0
  25. package/dist/delta/pending.js +143 -0
  26. package/dist/delta/pending.js.map +1 -0
  27. package/dist/delta/tracker.d.ts +12 -0
  28. package/dist/delta/tracker.d.ts.map +1 -1
  29. package/dist/delta/tracker.js +109 -39
  30. package/dist/delta/tracker.js.map +1 -1
  31. package/dist/host.d.ts.map +1 -1
  32. package/dist/host.js +9 -7
  33. package/dist/host.js.map +1 -1
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +1 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/next/contracts/accepts.d.ts +81 -0
  39. package/dist/next/contracts/accepts.d.ts.map +1 -0
  40. package/dist/next/contracts/accepts.js +123 -0
  41. package/dist/next/contracts/accepts.js.map +1 -0
  42. package/dist/next/contracts/contract.d.ts +121 -0
  43. package/dist/next/contracts/contract.d.ts.map +1 -0
  44. package/dist/next/contracts/contract.js +50 -0
  45. package/dist/next/contracts/contract.js.map +1 -0
  46. package/dist/next/contracts/declare.d.ts +107 -0
  47. package/dist/next/contracts/declare.d.ts.map +1 -0
  48. package/dist/next/contracts/declare.js +136 -0
  49. package/dist/next/contracts/declare.js.map +1 -0
  50. package/dist/next/contracts/evolve.d.ts +92 -0
  51. package/dist/next/contracts/evolve.d.ts.map +1 -0
  52. package/dist/next/contracts/evolve.js +179 -0
  53. package/dist/next/contracts/evolve.js.map +1 -0
  54. package/dist/next/contracts/fingerprint.d.ts +16 -0
  55. package/dist/next/contracts/fingerprint.d.ts.map +1 -0
  56. package/dist/next/contracts/fingerprint.js +50 -0
  57. package/dist/next/contracts/fingerprint.js.map +1 -0
  58. package/dist/next/contracts/history.d.ts +71 -0
  59. package/dist/next/contracts/history.d.ts.map +1 -0
  60. package/dist/next/contracts/history.js +3 -0
  61. package/dist/next/contracts/history.js.map +1 -0
  62. package/dist/next/contracts/host-kind.d.ts +40 -0
  63. package/dist/next/contracts/host-kind.d.ts.map +1 -0
  64. package/dist/next/contracts/host-kind.js +37 -0
  65. package/dist/next/contracts/host-kind.js.map +1 -0
  66. package/dist/next/contracts/index.d.ts +7 -0
  67. package/dist/next/contracts/index.d.ts.map +1 -0
  68. package/dist/next/contracts/index.js +6 -0
  69. package/dist/next/contracts/index.js.map +1 -0
  70. package/dist/next/contracts/internal.d.ts +10 -0
  71. package/dist/next/contracts/internal.d.ts.map +1 -0
  72. package/dist/next/contracts/internal.js +9 -0
  73. package/dist/next/contracts/internal.js.map +1 -0
  74. package/dist/next/contracts/names.d.ts +3 -0
  75. package/dist/next/contracts/names.d.ts.map +1 -0
  76. package/dist/next/contracts/names.js +13 -0
  77. package/dist/next/contracts/names.js.map +1 -0
  78. package/dist/next/contracts/params.d.ts +28 -0
  79. package/dist/next/contracts/params.d.ts.map +1 -0
  80. package/dist/next/contracts/params.js +50 -0
  81. package/dist/next/contracts/params.js.map +1 -0
  82. package/dist/next/contracts/schema.d.ts +102 -0
  83. package/dist/next/contracts/schema.d.ts.map +1 -0
  84. package/dist/next/contracts/schema.js +103 -0
  85. package/dist/next/contracts/schema.js.map +1 -0
  86. package/dist/next/contracts/snapshot.d.ts +16 -0
  87. package/dist/next/contracts/snapshot.d.ts.map +1 -0
  88. package/dist/next/contracts/snapshot.js +167 -0
  89. package/dist/next/contracts/snapshot.js.map +1 -0
  90. package/dist/next/data/args.d.ts +50 -0
  91. package/dist/next/data/args.d.ts.map +1 -0
  92. package/dist/next/data/args.js +83 -0
  93. package/dist/next/data/args.js.map +1 -0
  94. package/dist/next/data/errors.d.ts +73 -0
  95. package/dist/next/data/errors.d.ts.map +1 -0
  96. package/dist/next/data/errors.js +107 -0
  97. package/dist/next/data/errors.js.map +1 -0
  98. package/dist/next/data/failure.d.ts +26 -0
  99. package/dist/next/data/failure.d.ts.map +1 -0
  100. package/dist/next/data/failure.js +72 -0
  101. package/dist/next/data/failure.js.map +1 -0
  102. package/dist/next/data/index.d.ts +4 -0
  103. package/dist/next/data/index.d.ts.map +1 -0
  104. package/dist/next/data/index.js +4 -0
  105. package/dist/next/data/index.js.map +1 -0
  106. package/dist/next/data/internal.d.ts +7 -0
  107. package/dist/next/data/internal.d.ts.map +1 -0
  108. package/dist/next/data/internal.js +8 -0
  109. package/dist/next/data/internal.js.map +1 -0
  110. package/dist/next/data/params.d.ts +20 -0
  111. package/dist/next/data/params.d.ts.map +1 -0
  112. package/dist/next/data/params.js +31 -0
  113. package/dist/next/data/params.js.map +1 -0
  114. package/dist/next/data/principal.d.ts +17 -0
  115. package/dist/next/data/principal.d.ts.map +1 -0
  116. package/dist/next/data/principal.js +41 -0
  117. package/dist/next/data/principal.js.map +1 -0
  118. package/dist/next/data/validator.d.ts +12 -0
  119. package/dist/next/data/validator.d.ts.map +1 -0
  120. package/dist/next/data/validator.js +34 -0
  121. package/dist/next/data/validator.js.map +1 -0
  122. package/dist/next/documents/address-source.d.ts +20 -0
  123. package/dist/next/documents/address-source.d.ts.map +1 -0
  124. package/dist/next/documents/address-source.js +44 -0
  125. package/dist/next/documents/address-source.js.map +1 -0
  126. package/dist/next/documents/definition.d.ts +84 -0
  127. package/dist/next/documents/definition.d.ts.map +1 -0
  128. package/dist/next/documents/definition.js +73 -0
  129. package/dist/next/documents/definition.js.map +1 -0
  130. package/dist/next/documents/documents.d.ts +106 -0
  131. package/dist/next/documents/documents.d.ts.map +1 -0
  132. package/dist/next/documents/documents.js +224 -0
  133. package/dist/next/documents/documents.js.map +1 -0
  134. package/dist/next/documents/fence.d.ts +9 -0
  135. package/dist/next/documents/fence.d.ts.map +1 -0
  136. package/dist/next/documents/fence.js +15 -0
  137. package/dist/next/documents/fence.js.map +1 -0
  138. package/dist/next/documents/handles.d.ts +76 -0
  139. package/dist/next/documents/handles.d.ts.map +1 -0
  140. package/dist/next/documents/handles.js +66 -0
  141. package/dist/next/documents/handles.js.map +1 -0
  142. package/dist/next/documents/index.d.ts +4 -0
  143. package/dist/next/documents/index.d.ts.map +1 -0
  144. package/dist/next/documents/index.js +3 -0
  145. package/dist/next/documents/index.js.map +1 -0
  146. package/dist/next/documents/internal.d.ts +9 -0
  147. package/dist/next/documents/internal.d.ts.map +1 -0
  148. package/dist/next/documents/internal.js +9 -0
  149. package/dist/next/documents/internal.js.map +1 -0
  150. package/dist/next/documents/keyed-slot.d.ts +103 -0
  151. package/dist/next/documents/keyed-slot.d.ts.map +1 -0
  152. package/dist/next/documents/keyed-slot.js +395 -0
  153. package/dist/next/documents/keyed-slot.js.map +1 -0
  154. package/dist/next/documents/line.d.ts +7 -0
  155. package/dist/next/documents/line.d.ts.map +1 -0
  156. package/dist/next/documents/line.js +14 -0
  157. package/dist/next/documents/line.js.map +1 -0
  158. package/dist/next/documents/persistence.d.ts +104 -0
  159. package/dist/next/documents/persistence.d.ts.map +1 -0
  160. package/dist/next/documents/persistence.js +128 -0
  161. package/dist/next/documents/persistence.js.map +1 -0
  162. package/dist/next/documents/residency.d.ts +31 -0
  163. package/dist/next/documents/residency.d.ts.map +1 -0
  164. package/dist/next/documents/residency.js +93 -0
  165. package/dist/next/documents/residency.js.map +1 -0
  166. package/dist/next/documents/slot.d.ts +109 -0
  167. package/dist/next/documents/slot.d.ts.map +1 -0
  168. package/dist/next/documents/slot.js +181 -0
  169. package/dist/next/documents/slot.js.map +1 -0
  170. package/dist/next/documents/transaction.d.ts +133 -0
  171. package/dist/next/documents/transaction.d.ts.map +1 -0
  172. package/dist/next/documents/transaction.js +409 -0
  173. package/dist/next/documents/transaction.js.map +1 -0
  174. package/dist/next/host/activity.d.ts +31 -0
  175. package/dist/next/host/activity.d.ts.map +1 -0
  176. package/dist/next/host/activity.js +40 -0
  177. package/dist/next/host/activity.js.map +1 -0
  178. package/dist/next/host/adapted.d.ts +49 -0
  179. package/dist/next/host/adapted.d.ts.map +1 -0
  180. package/dist/next/host/adapted.js +214 -0
  181. package/dist/next/host/adapted.js.map +1 -0
  182. package/dist/next/host/attempt.d.ts +278 -0
  183. package/dist/next/host/attempt.d.ts.map +1 -0
  184. package/dist/next/host/attempt.js +1072 -0
  185. package/dist/next/host/attempt.js.map +1 -0
  186. package/dist/next/host/backoff.d.ts +29 -0
  187. package/dist/next/host/backoff.d.ts.map +1 -0
  188. package/dist/next/host/backoff.js +69 -0
  189. package/dist/next/host/backoff.js.map +1 -0
  190. package/dist/next/host/ctx.d.ts +47 -0
  191. package/dist/next/host/ctx.d.ts.map +1 -0
  192. package/dist/next/host/ctx.js +108 -0
  193. package/dist/next/host/ctx.js.map +1 -0
  194. package/dist/next/host/deadline.d.ts +12 -0
  195. package/dist/next/host/deadline.d.ts.map +1 -0
  196. package/dist/next/host/deadline.js +40 -0
  197. package/dist/next/host/deadline.js.map +1 -0
  198. package/dist/next/host/dependencies.d.ts +65 -0
  199. package/dist/next/host/dependencies.d.ts.map +1 -0
  200. package/dist/next/host/dependencies.js +115 -0
  201. package/dist/next/host/dependencies.js.map +1 -0
  202. package/dist/next/host/destination.d.ts +48 -0
  203. package/dist/next/host/destination.d.ts.map +1 -0
  204. package/dist/next/host/destination.js +101 -0
  205. package/dist/next/host/destination.js.map +1 -0
  206. package/dist/next/host/facet.d.ts +79 -0
  207. package/dist/next/host/facet.d.ts.map +1 -0
  208. package/dist/next/host/facet.js +55 -0
  209. package/dist/next/host/facet.js.map +1 -0
  210. package/dist/next/host/follow.d.ts +52 -0
  211. package/dist/next/host/follow.d.ts.map +1 -0
  212. package/dist/next/host/follow.js +207 -0
  213. package/dist/next/host/follow.js.map +1 -0
  214. package/dist/next/host/host.d.ts +495 -0
  215. package/dist/next/host/host.d.ts.map +1 -0
  216. package/dist/next/host/host.js +1075 -0
  217. package/dist/next/host/host.js.map +1 -0
  218. package/dist/next/host/index.d.ts +17 -0
  219. package/dist/next/host/index.d.ts.map +1 -0
  220. package/dist/next/host/index.js +6 -0
  221. package/dist/next/host/index.js.map +1 -0
  222. package/dist/next/host/internal.d.ts +10 -0
  223. package/dist/next/host/internal.d.ts.map +1 -0
  224. package/dist/next/host/internal.js +8 -0
  225. package/dist/next/host/internal.js.map +1 -0
  226. package/dist/next/host/members.d.ts +50 -0
  227. package/dist/next/host/members.d.ts.map +1 -0
  228. package/dist/next/host/members.js +107 -0
  229. package/dist/next/host/members.js.map +1 -0
  230. package/dist/next/host/native.d.ts +55 -0
  231. package/dist/next/host/native.d.ts.map +1 -0
  232. package/dist/next/host/native.js +92 -0
  233. package/dist/next/host/native.js.map +1 -0
  234. package/dist/next/host/object.d.ts +290 -0
  235. package/dist/next/host/object.d.ts.map +1 -0
  236. package/dist/next/host/object.js +1127 -0
  237. package/dist/next/host/object.js.map +1 -0
  238. package/dist/next/host/parked.d.ts +23 -0
  239. package/dist/next/host/parked.d.ts.map +1 -0
  240. package/dist/next/host/parked.js +79 -0
  241. package/dist/next/host/parked.js.map +1 -0
  242. package/dist/next/host/presence.d.ts +34 -0
  243. package/dist/next/host/presence.d.ts.map +1 -0
  244. package/dist/next/host/presence.js +117 -0
  245. package/dist/next/host/presence.js.map +1 -0
  246. package/dist/next/host/ref-state.d.ts +53 -0
  247. package/dist/next/host/ref-state.d.ts.map +1 -0
  248. package/dist/next/host/ref-state.js +83 -0
  249. package/dist/next/host/ref-state.js.map +1 -0
  250. package/dist/next/host/reference-keys.d.ts +36 -0
  251. package/dist/next/host/reference-keys.d.ts.map +1 -0
  252. package/dist/next/host/reference-keys.js +168 -0
  253. package/dist/next/host/reference-keys.js.map +1 -0
  254. package/dist/next/host/reference-source.d.ts +65 -0
  255. package/dist/next/host/reference-source.d.ts.map +1 -0
  256. package/dist/next/host/reference-source.js +285 -0
  257. package/dist/next/host/reference-source.js.map +1 -0
  258. package/dist/next/host/reference.d.ts +308 -0
  259. package/dist/next/host/reference.d.ts.map +1 -0
  260. package/dist/next/host/reference.js +775 -0
  261. package/dist/next/host/reference.js.map +1 -0
  262. package/dist/next/host/retry-on.d.ts +28 -0
  263. package/dist/next/host/retry-on.d.ts.map +1 -0
  264. package/dist/next/host/retry-on.js +52 -0
  265. package/dist/next/host/retry-on.js.map +1 -0
  266. package/dist/next/host/revocation.d.ts +16 -0
  267. package/dist/next/host/revocation.d.ts.map +1 -0
  268. package/dist/next/host/revocation.js +27 -0
  269. package/dist/next/host/revocation.js.map +1 -0
  270. package/dist/next/host/root.d.ts +27 -0
  271. package/dist/next/host/root.d.ts.map +1 -0
  272. package/dist/next/host/root.js +68 -0
  273. package/dist/next/host/root.js.map +1 -0
  274. package/dist/next/host/route.d.ts +64 -0
  275. package/dist/next/host/route.d.ts.map +1 -0
  276. package/dist/next/host/route.js +190 -0
  277. package/dist/next/host/route.js.map +1 -0
  278. package/dist/next/host/routines.d.ts +76 -0
  279. package/dist/next/host/routines.d.ts.map +1 -0
  280. package/dist/next/host/routines.js +350 -0
  281. package/dist/next/host/routines.js.map +1 -0
  282. package/dist/next/host/sleep.d.ts +9 -0
  283. package/dist/next/host/sleep.d.ts.map +1 -0
  284. package/dist/next/host/sleep.js +40 -0
  285. package/dist/next/host/sleep.js.map +1 -0
  286. package/dist/next/host/staging.d.ts +94 -0
  287. package/dist/next/host/staging.d.ts.map +1 -0
  288. package/dist/next/host/staging.js +302 -0
  289. package/dist/next/host/staging.js.map +1 -0
  290. package/dist/next/host/unbound.d.ts +30 -0
  291. package/dist/next/host/unbound.d.ts.map +1 -0
  292. package/dist/next/host/unbound.js +67 -0
  293. package/dist/next/host/unbound.js.map +1 -0
  294. package/dist/next/host/uuid.d.ts +3 -0
  295. package/dist/next/host/uuid.d.ts.map +1 -0
  296. package/dist/next/host/uuid.js +38 -0
  297. package/dist/next/host/uuid.js.map +1 -0
  298. package/dist/next/index.d.ts +28 -0
  299. package/dist/next/index.d.ts.map +1 -0
  300. package/dist/next/index.js +18 -0
  301. package/dist/next/index.js.map +1 -0
  302. package/dist/next/jobs/definition.d.ts +96 -0
  303. package/dist/next/jobs/definition.d.ts.map +1 -0
  304. package/dist/next/jobs/definition.js +83 -0
  305. package/dist/next/jobs/definition.js.map +1 -0
  306. package/dist/next/jobs/index.d.ts +5 -0
  307. package/dist/next/jobs/index.d.ts.map +1 -0
  308. package/dist/next/jobs/index.js +3 -0
  309. package/dist/next/jobs/index.js.map +1 -0
  310. package/dist/next/jobs/internal.d.ts +3 -0
  311. package/dist/next/jobs/internal.d.ts.map +1 -0
  312. package/dist/next/jobs/internal.js +4 -0
  313. package/dist/next/jobs/internal.js.map +1 -0
  314. package/dist/next/jobs/job.d.ts +152 -0
  315. package/dist/next/jobs/job.d.ts.map +1 -0
  316. package/dist/next/jobs/job.js +320 -0
  317. package/dist/next/jobs/job.js.map +1 -0
  318. package/dist/next/jobs/persisted.d.ts +38 -0
  319. package/dist/next/jobs/persisted.d.ts.map +1 -0
  320. package/dist/next/jobs/persisted.js +95 -0
  321. package/dist/next/jobs/persisted.js.map +1 -0
  322. package/dist/next/jobs/records.d.ts +231 -0
  323. package/dist/next/jobs/records.d.ts.map +1 -0
  324. package/dist/next/jobs/records.js +869 -0
  325. package/dist/next/jobs/records.js.map +1 -0
  326. package/dist/next/jobs/run-states.d.ts +69 -0
  327. package/dist/next/jobs/run-states.d.ts.map +1 -0
  328. package/dist/next/jobs/run-states.js +228 -0
  329. package/dist/next/jobs/run-states.js.map +1 -0
  330. package/dist/next/jobs/run.d.ts +113 -0
  331. package/dist/next/jobs/run.d.ts.map +1 -0
  332. package/dist/next/jobs/run.js +200 -0
  333. package/dist/next/jobs/run.js.map +1 -0
  334. package/dist/next/jobs/running.d.ts +44 -0
  335. package/dist/next/jobs/running.d.ts.map +1 -0
  336. package/dist/next/jobs/running.js +117 -0
  337. package/dist/next/jobs/running.js.map +1 -0
  338. package/dist/next/jobs/stored.d.ts +63 -0
  339. package/dist/next/jobs/stored.d.ts.map +1 -0
  340. package/dist/next/jobs/stored.js +55 -0
  341. package/dist/next/jobs/stored.js.map +1 -0
  342. package/dist/next/link/binary.d.ts +4 -0
  343. package/dist/next/link/binary.d.ts.map +1 -0
  344. package/dist/next/link/binary.js +534 -0
  345. package/dist/next/link/binary.js.map +1 -0
  346. package/dist/next/link/channel.d.ts +63 -0
  347. package/dist/next/link/channel.d.ts.map +1 -0
  348. package/dist/next/link/channel.js +202 -0
  349. package/dist/next/link/channel.js.map +1 -0
  350. package/dist/next/link/errors.d.ts +7 -0
  351. package/dist/next/link/errors.d.ts.map +1 -0
  352. package/dist/next/link/errors.js +21 -0
  353. package/dist/next/link/errors.js.map +1 -0
  354. package/dist/next/link/index.d.ts +8 -0
  355. package/dist/next/link/index.d.ts.map +1 -0
  356. package/dist/next/link/index.js +8 -0
  357. package/dist/next/link/index.js.map +1 -0
  358. package/dist/next/link/internal.d.ts +9 -0
  359. package/dist/next/link/internal.d.ts.map +1 -0
  360. package/dist/next/link/internal.js +10 -0
  361. package/dist/next/link/internal.js.map +1 -0
  362. package/dist/next/link/ipc.d.ts +22 -0
  363. package/dist/next/link/ipc.d.ts.map +1 -0
  364. package/dist/next/link/ipc.js +64 -0
  365. package/dist/next/link/ipc.js.map +1 -0
  366. package/dist/next/link/link.d.ts +34 -0
  367. package/dist/next/link/link.d.ts.map +1 -0
  368. package/dist/next/link/link.js +87 -0
  369. package/dist/next/link/link.js.map +1 -0
  370. package/dist/next/link/message.d.ts +249 -0
  371. package/dist/next/link/message.d.ts.map +1 -0
  372. package/dist/next/link/message.js +123 -0
  373. package/dist/next/link/message.js.map +1 -0
  374. package/dist/next/link/part.d.ts +80 -0
  375. package/dist/next/link/part.d.ts.map +1 -0
  376. package/dist/next/link/part.js +164 -0
  377. package/dist/next/link/part.js.map +1 -0
  378. package/dist/next/link/text.d.ts +6 -0
  379. package/dist/next/link/text.d.ts.map +1 -0
  380. package/dist/next/link/text.js +335 -0
  381. package/dist/next/link/text.js.map +1 -0
  382. package/dist/next/link/values.d.ts +40 -0
  383. package/dist/next/link/values.d.ts.map +1 -0
  384. package/dist/next/link/values.js +117 -0
  385. package/dist/next/link/values.js.map +1 -0
  386. package/dist/next/link/websocket.d.ts +26 -0
  387. package/dist/next/link/websocket.d.ts.map +1 -0
  388. package/dist/next/link/websocket.js +91 -0
  389. package/dist/next/link/websocket.js.map +1 -0
  390. package/dist/next/registries/contribution.d.ts +50 -0
  391. package/dist/next/registries/contribution.d.ts.map +1 -0
  392. package/dist/next/registries/contribution.js +129 -0
  393. package/dist/next/registries/contribution.js.map +1 -0
  394. package/dist/next/registries/entries.d.ts +18 -0
  395. package/dist/next/registries/entries.d.ts.map +1 -0
  396. package/dist/next/registries/entries.js +42 -0
  397. package/dist/next/registries/entries.js.map +1 -0
  398. package/dist/next/registries/index.d.ts +3 -0
  399. package/dist/next/registries/index.d.ts.map +1 -0
  400. package/dist/next/registries/index.js +5 -0
  401. package/dist/next/registries/index.js.map +1 -0
  402. package/dist/next/registries/internal.d.ts +4 -0
  403. package/dist/next/registries/internal.d.ts.map +1 -0
  404. package/dist/next/registries/internal.js +5 -0
  405. package/dist/next/registries/internal.js.map +1 -0
  406. package/dist/next/registries/record.d.ts +94 -0
  407. package/dist/next/registries/record.d.ts.map +1 -0
  408. package/dist/next/registries/record.js +253 -0
  409. package/dist/next/registries/record.js.map +1 -0
  410. package/dist/next/registries/registry.d.ts +74 -0
  411. package/dist/next/registries/registry.d.ts.map +1 -0
  412. package/dist/next/registries/registry.js +14 -0
  413. package/dist/next/registries/registry.js.map +1 -0
  414. package/dist/next/registries/value.d.ts +48 -0
  415. package/dist/next/registries/value.d.ts.map +1 -0
  416. package/dist/next/registries/value.js +199 -0
  417. package/dist/next/registries/value.js.map +1 -0
  418. package/dist/next/remote/calls.d.ts +25 -0
  419. package/dist/next/remote/calls.d.ts.map +1 -0
  420. package/dist/next/remote/calls.js +62 -0
  421. package/dist/next/remote/calls.js.map +1 -0
  422. package/dist/next/remote/consumer.d.ts +42 -0
  423. package/dist/next/remote/consumer.d.ts.map +1 -0
  424. package/dist/next/remote/consumer.js +343 -0
  425. package/dist/next/remote/consumer.js.map +1 -0
  426. package/dist/next/remote/hold.d.ts +130 -0
  427. package/dist/next/remote/hold.d.ts.map +1 -0
  428. package/dist/next/remote/hold.js +537 -0
  429. package/dist/next/remote/hold.js.map +1 -0
  430. package/dist/next/remote/host-link.d.ts +77 -0
  431. package/dist/next/remote/host-link.d.ts.map +1 -0
  432. package/dist/next/remote/host-link.js +182 -0
  433. package/dist/next/remote/host-link.js.map +1 -0
  434. package/dist/next/remote/internal.d.ts +6 -0
  435. package/dist/next/remote/internal.d.ts.map +1 -0
  436. package/dist/next/remote/internal.js +6 -0
  437. package/dist/next/remote/internal.js.map +1 -0
  438. package/dist/next/remote/path.d.ts +46 -0
  439. package/dist/next/remote/path.d.ts.map +1 -0
  440. package/dist/next/remote/path.js +73 -0
  441. package/dist/next/remote/path.js.map +1 -0
  442. package/dist/next/remote/provider.d.ts +76 -0
  443. package/dist/next/remote/provider.d.ts.map +1 -0
  444. package/dist/next/remote/provider.js +506 -0
  445. package/dist/next/remote/provider.js.map +1 -0
  446. package/dist/next/remote/relay.d.ts +58 -0
  447. package/dist/next/remote/relay.d.ts.map +1 -0
  448. package/dist/next/remote/relay.js +117 -0
  449. package/dist/next/remote/relay.js.map +1 -0
  450. package/dist/next/remote/remote-object.d.ts +133 -0
  451. package/dist/next/remote/remote-object.d.ts.map +1 -0
  452. package/dist/next/remote/remote-object.js +411 -0
  453. package/dist/next/remote/remote-object.js.map +1 -0
  454. package/dist/next/remote/replica.d.ts +59 -0
  455. package/dist/next/remote/replica.d.ts.map +1 -0
  456. package/dist/next/remote/replica.js +125 -0
  457. package/dist/next/remote/replica.js.map +1 -0
  458. package/dist/next/state/batch.d.ts +64 -0
  459. package/dist/next/state/batch.d.ts.map +1 -0
  460. package/dist/next/state/batch.js +163 -0
  461. package/dist/next/state/batch.js.map +1 -0
  462. package/dist/next/state/derive.d.ts +52 -0
  463. package/dist/next/state/derive.d.ts.map +1 -0
  464. package/dist/next/state/derive.js +182 -0
  465. package/dist/next/state/derive.js.map +1 -0
  466. package/dist/next/state/index.d.ts +6 -0
  467. package/dist/next/state/index.d.ts.map +1 -0
  468. package/dist/next/state/index.js +4 -0
  469. package/dist/next/state/index.js.map +1 -0
  470. package/dist/next/state/internal.d.ts +6 -0
  471. package/dist/next/state/internal.d.ts.map +1 -0
  472. package/dist/next/state/internal.js +8 -0
  473. package/dist/next/state/internal.js.map +1 -0
  474. package/dist/next/state/native-source.d.ts +106 -0
  475. package/dist/next/state/native-source.d.ts.map +1 -0
  476. package/dist/next/state/native-source.js +240 -0
  477. package/dist/next/state/native-source.js.map +1 -0
  478. package/dist/next/state/watchable.d.ts +114 -0
  479. package/dist/next/state/watchable.d.ts.map +1 -0
  480. package/dist/next/state/watchable.js +156 -0
  481. package/dist/next/state/watchable.js.map +1 -0
  482. package/dist/next/state/writable.d.ts +32 -0
  483. package/dist/next/state/writable.d.ts.map +1 -0
  484. package/dist/next/state/writable.js +49 -0
  485. package/dist/next/state/writable.js.map +1 -0
  486. package/dist/next/store/adapter.d.ts +67 -0
  487. package/dist/next/store/adapter.d.ts.map +1 -0
  488. package/dist/next/store/adapter.js +118 -0
  489. package/dist/next/store/adapter.js.map +1 -0
  490. package/dist/next/store/allocator.d.ts +17 -0
  491. package/dist/next/store/allocator.d.ts.map +1 -0
  492. package/dist/next/store/allocator.js +30 -0
  493. package/dist/next/store/allocator.js.map +1 -0
  494. package/dist/next/store/applier.d.ts +8 -0
  495. package/dist/next/store/applier.d.ts.map +1 -0
  496. package/dist/next/store/applier.js +375 -0
  497. package/dist/next/store/applier.js.map +1 -0
  498. package/dist/next/store/apply-batch.d.ts +12 -0
  499. package/dist/next/store/apply-batch.d.ts.map +1 -0
  500. package/dist/next/store/apply-batch.js +83 -0
  501. package/dist/next/store/apply-batch.js.map +1 -0
  502. package/dist/next/store/archive.d.ts +32 -0
  503. package/dist/next/store/archive.d.ts.map +1 -0
  504. package/dist/next/store/archive.js +129 -0
  505. package/dist/next/store/archive.js.map +1 -0
  506. package/dist/next/store/backend.d.ts +10 -0
  507. package/dist/next/store/backend.d.ts.map +1 -0
  508. package/dist/next/store/backend.js +15 -0
  509. package/dist/next/store/backend.js.map +1 -0
  510. package/dist/next/store/catalog.d.ts +24 -0
  511. package/dist/next/store/catalog.d.ts.map +1 -0
  512. package/dist/next/store/catalog.js +17 -0
  513. package/dist/next/store/catalog.js.map +1 -0
  514. package/dist/next/store/claims.d.ts +23 -0
  515. package/dist/next/store/claims.d.ts.map +1 -0
  516. package/dist/next/store/claims.js +65 -0
  517. package/dist/next/store/claims.js.map +1 -0
  518. package/dist/next/store/columns.d.ts +77 -0
  519. package/dist/next/store/columns.d.ts.map +1 -0
  520. package/dist/next/store/columns.js +77 -0
  521. package/dist/next/store/columns.js.map +1 -0
  522. package/dist/next/store/engine.d.ts +176 -0
  523. package/dist/next/store/engine.d.ts.map +1 -0
  524. package/dist/next/store/engine.js +283 -0
  525. package/dist/next/store/engine.js.map +1 -0
  526. package/dist/next/store/evaluate.d.ts +17 -0
  527. package/dist/next/store/evaluate.d.ts.map +1 -0
  528. package/dist/next/store/evaluate.js +128 -0
  529. package/dist/next/store/evaluate.js.map +1 -0
  530. package/dist/next/store/export.d.ts +17 -0
  531. package/dist/next/store/export.d.ts.map +1 -0
  532. package/dist/next/store/export.js +200 -0
  533. package/dist/next/store/export.js.map +1 -0
  534. package/dist/next/store/expression.d.ts +150 -0
  535. package/dist/next/store/expression.d.ts.map +1 -0
  536. package/dist/next/store/expression.js +268 -0
  537. package/dist/next/store/expression.js.map +1 -0
  538. package/dist/next/store/import.d.ts +10 -0
  539. package/dist/next/store/import.d.ts.map +1 -0
  540. package/dist/next/store/import.js +276 -0
  541. package/dist/next/store/import.js.map +1 -0
  542. package/dist/next/store/index.d.ts +16 -0
  543. package/dist/next/store/index.d.ts.map +1 -0
  544. package/dist/next/store/index.js +13 -0
  545. package/dist/next/store/index.js.map +1 -0
  546. package/dist/next/store/json-column.d.ts +33 -0
  547. package/dist/next/store/json-column.d.ts.map +1 -0
  548. package/dist/next/store/json-column.js +61 -0
  549. package/dist/next/store/json-column.js.map +1 -0
  550. package/dist/next/store/jsonl.d.ts +9 -0
  551. package/dist/next/store/jsonl.d.ts.map +1 -0
  552. package/dist/next/store/jsonl.js +61 -0
  553. package/dist/next/store/jsonl.js.map +1 -0
  554. package/dist/next/store/outbox.d.ts +26 -0
  555. package/dist/next/store/outbox.d.ts.map +1 -0
  556. package/dist/next/store/outbox.js +80 -0
  557. package/dist/next/store/outbox.js.map +1 -0
  558. package/dist/next/store/query.d.ts +39 -0
  559. package/dist/next/store/query.d.ts.map +1 -0
  560. package/dist/next/store/query.js +97 -0
  561. package/dist/next/store/query.js.map +1 -0
  562. package/dist/next/store/refusal.d.ts +15 -0
  563. package/dist/next/store/refusal.d.ts.map +1 -0
  564. package/dist/next/store/refusal.js +36 -0
  565. package/dist/next/store/refusal.js.map +1 -0
  566. package/dist/next/store/rows.d.ts +80 -0
  567. package/dist/next/store/rows.d.ts.map +1 -0
  568. package/dist/next/store/rows.js +183 -0
  569. package/dist/next/store/rows.js.map +1 -0
  570. package/dist/next/store/schema.d.ts +25 -0
  571. package/dist/next/store/schema.d.ts.map +1 -0
  572. package/dist/next/store/schema.js +115 -0
  573. package/dist/next/store/schema.js.map +1 -0
  574. package/dist/next/store/sql.d.ts +73 -0
  575. package/dist/next/store/sql.d.ts.map +1 -0
  576. package/dist/next/store/sql.js +234 -0
  577. package/dist/next/store/sql.js.map +1 -0
  578. package/dist/next/store/step.d.ts +48 -0
  579. package/dist/next/store/step.d.ts.map +1 -0
  580. package/dist/next/store/step.js +50 -0
  581. package/dist/next/store/step.js.map +1 -0
  582. package/dist/next/store/store.d.ts +161 -0
  583. package/dist/next/store/store.d.ts.map +1 -0
  584. package/dist/next/store/store.js +627 -0
  585. package/dist/next/store/store.js.map +1 -0
  586. package/dist/next/store/table-changes.d.ts +29 -0
  587. package/dist/next/store/table-changes.d.ts.map +1 -0
  588. package/dist/next/store/table-changes.js +102 -0
  589. package/dist/next/store/table-changes.js.map +1 -0
  590. package/dist/next/store/table-evolve.d.ts +74 -0
  591. package/dist/next/store/table-evolve.d.ts.map +1 -0
  592. package/dist/next/store/table-evolve.js +201 -0
  593. package/dist/next/store/table-evolve.js.map +1 -0
  594. package/dist/next/store/table-handle.d.ts +67 -0
  595. package/dist/next/store/table-handle.d.ts.map +1 -0
  596. package/dist/next/store/table-handle.js +101 -0
  597. package/dist/next/store/table-handle.js.map +1 -0
  598. package/dist/next/store/table-history.d.ts +75 -0
  599. package/dist/next/store/table-history.d.ts.map +1 -0
  600. package/dist/next/store/table-history.js +42 -0
  601. package/dist/next/store/table-history.js.map +1 -0
  602. package/dist/next/store/table-migration.d.ts +16 -0
  603. package/dist/next/store/table-migration.d.ts.map +1 -0
  604. package/dist/next/store/table-migration.js +202 -0
  605. package/dist/next/store/table-migration.js.map +1 -0
  606. package/dist/next/store/table-writes.d.ts +125 -0
  607. package/dist/next/store/table-writes.d.ts.map +1 -0
  608. package/dist/next/store/table-writes.js +165 -0
  609. package/dist/next/store/table-writes.js.map +1 -0
  610. package/dist/next/store/table.d.ts +80 -0
  611. package/dist/next/store/table.d.ts.map +1 -0
  612. package/dist/next/store/table.js +103 -0
  613. package/dist/next/store/table.js.map +1 -0
  614. package/dist/next/store/text.d.ts +14 -0
  615. package/dist/next/store/text.d.ts.map +1 -0
  616. package/dist/next/store/text.js +51 -0
  617. package/dist/next/store/text.js.map +1 -0
  618. package/dist/next/store/writes.d.ts +5 -0
  619. package/dist/next/store/writes.d.ts.map +1 -0
  620. package/dist/next/store/writes.js +4 -0
  621. package/dist/next/store/writes.js.map +1 -0
  622. package/dist/next-node/compression.d.ts +7 -0
  623. package/dist/next-node/compression.d.ts.map +1 -0
  624. package/dist/next-node/compression.js +24 -0
  625. package/dist/next-node/compression.js.map +1 -0
  626. package/dist/next-node/http/admission.d.ts +63 -0
  627. package/dist/next-node/http/admission.d.ts.map +1 -0
  628. package/dist/next-node/http/admission.js +134 -0
  629. package/dist/next-node/http/admission.js.map +1 -0
  630. package/dist/next-node/http/authenticate.d.ts +21 -0
  631. package/dist/next-node/http/authenticate.d.ts.map +1 -0
  632. package/dist/next-node/http/authenticate.js +34 -0
  633. package/dist/next-node/http/authenticate.js.map +1 -0
  634. package/dist/next-node/http/cookies.d.ts +24 -0
  635. package/dist/next-node/http/cookies.d.ts.map +1 -0
  636. package/dist/next-node/http/cookies.js +62 -0
  637. package/dist/next-node/http/cookies.js.map +1 -0
  638. package/dist/next-node/http/file.d.ts +23 -0
  639. package/dist/next-node/http/file.d.ts.map +1 -0
  640. package/dist/next-node/http/file.js +94 -0
  641. package/dist/next-node/http/file.js.map +1 -0
  642. package/dist/next-node/http/headers.d.ts +37 -0
  643. package/dist/next-node/http/headers.d.ts.map +1 -0
  644. package/dist/next-node/http/headers.js +129 -0
  645. package/dist/next-node/http/headers.js.map +1 -0
  646. package/dist/next-node/http/http.d.ts +100 -0
  647. package/dist/next-node/http/http.d.ts.map +1 -0
  648. package/dist/next-node/http/http.js +462 -0
  649. package/dist/next-node/http/http.js.map +1 -0
  650. package/dist/next-node/http/incoming.d.ts +19 -0
  651. package/dist/next-node/http/incoming.d.ts.map +1 -0
  652. package/dist/next-node/http/incoming.js +31 -0
  653. package/dist/next-node/http/incoming.js.map +1 -0
  654. package/dist/next-node/http/index.d.ts +11 -0
  655. package/dist/next-node/http/index.d.ts.map +1 -0
  656. package/dist/next-node/http/index.js +12 -0
  657. package/dist/next-node/http/index.js.map +1 -0
  658. package/dist/next-node/http/node.d.ts +78 -0
  659. package/dist/next-node/http/node.d.ts.map +1 -0
  660. package/dist/next-node/http/node.js +291 -0
  661. package/dist/next-node/http/node.js.map +1 -0
  662. package/dist/next-node/http/request.d.ts +54 -0
  663. package/dist/next-node/http/request.d.ts.map +1 -0
  664. package/dist/next-node/http/request.js +116 -0
  665. package/dist/next-node/http/request.js.map +1 -0
  666. package/dist/next-node/http/response.d.ts +63 -0
  667. package/dist/next-node/http/response.d.ts.map +1 -0
  668. package/dist/next-node/http/response.js +202 -0
  669. package/dist/next-node/http/response.js.map +1 -0
  670. package/dist/next-node/http/router.d.ts +114 -0
  671. package/dist/next-node/http/router.d.ts.map +1 -0
  672. package/dist/next-node/http/router.js +261 -0
  673. package/dist/next-node/http/router.js.map +1 -0
  674. package/dist/next-node/http/upgrades.d.ts +58 -0
  675. package/dist/next-node/http/upgrades.d.ts.map +1 -0
  676. package/dist/next-node/http/upgrades.js +184 -0
  677. package/dist/next-node/http/upgrades.js.map +1 -0
  678. package/dist/next-node/plugins/build.d.ts +57 -0
  679. package/dist/next-node/plugins/build.d.ts.map +1 -0
  680. package/dist/next-node/plugins/build.js +334 -0
  681. package/dist/next-node/plugins/build.js.map +1 -0
  682. package/dist/next-node/plugins/discover.d.ts +36 -0
  683. package/dist/next-node/plugins/discover.d.ts.map +1 -0
  684. package/dist/next-node/plugins/discover.js +91 -0
  685. package/dist/next-node/plugins/discover.js.map +1 -0
  686. package/dist/next-node/plugins/evaluate.d.ts +33 -0
  687. package/dist/next-node/plugins/evaluate.d.ts.map +1 -0
  688. package/dist/next-node/plugins/evaluate.js +98 -0
  689. package/dist/next-node/plugins/evaluate.js.map +1 -0
  690. package/dist/next-node/plugins/index.d.ts +9 -0
  691. package/dist/next-node/plugins/index.d.ts.map +1 -0
  692. package/dist/next-node/plugins/index.js +11 -0
  693. package/dist/next-node/plugins/index.js.map +1 -0
  694. package/dist/next-node/plugins/install.d.ts +13 -0
  695. package/dist/next-node/plugins/install.d.ts.map +1 -0
  696. package/dist/next-node/plugins/install.js +37 -0
  697. package/dist/next-node/plugins/install.js.map +1 -0
  698. package/dist/next-node/plugins/plugins.d.ts +135 -0
  699. package/dist/next-node/plugins/plugins.d.ts.map +1 -0
  700. package/dist/next-node/plugins/plugins.js +206 -0
  701. package/dist/next-node/plugins/plugins.js.map +1 -0
  702. package/dist/next-node/plugins/runtime.d.ts +41 -0
  703. package/dist/next-node/plugins/runtime.d.ts.map +1 -0
  704. package/dist/next-node/plugins/runtime.js +136 -0
  705. package/dist/next-node/plugins/runtime.js.map +1 -0
  706. package/dist/next-node/plugins/stack.d.ts +16 -0
  707. package/dist/next-node/plugins/stack.d.ts.map +1 -0
  708. package/dist/next-node/plugins/stack.js +61 -0
  709. package/dist/next-node/plugins/stack.js.map +1 -0
  710. package/dist/next-node/plugins/watcher.d.ts +58 -0
  711. package/dist/next-node/plugins/watcher.d.ts.map +1 -0
  712. package/dist/next-node/plugins/watcher.js +281 -0
  713. package/dist/next-node/plugins/watcher.js.map +1 -0
  714. package/dist/next-node/workers/control.d.ts +83 -0
  715. package/dist/next-node/workers/control.d.ts.map +1 -0
  716. package/dist/next-node/workers/control.js +77 -0
  717. package/dist/next-node/workers/control.js.map +1 -0
  718. package/dist/next-node/workers/index.d.ts +5 -0
  719. package/dist/next-node/workers/index.d.ts.map +1 -0
  720. package/dist/next-node/workers/index.js +7 -0
  721. package/dist/next-node/workers/index.js.map +1 -0
  722. package/dist/next-node/workers/lock.d.ts +21 -0
  723. package/dist/next-node/workers/lock.d.ts.map +1 -0
  724. package/dist/next-node/workers/lock.js +137 -0
  725. package/dist/next-node/workers/lock.js.map +1 -0
  726. package/dist/next-node/workers/main.d.ts +46 -0
  727. package/dist/next-node/workers/main.d.ts.map +1 -0
  728. package/dist/next-node/workers/main.js +230 -0
  729. package/dist/next-node/workers/main.js.map +1 -0
  730. package/dist/next-node/workers/process.d.ts +42 -0
  731. package/dist/next-node/workers/process.d.ts.map +1 -0
  732. package/dist/next-node/workers/process.js +125 -0
  733. package/dist/next-node/workers/process.js.map +1 -0
  734. package/dist/next-node/workers/workers.d.ts +80 -0
  735. package/dist/next-node/workers/workers.d.ts.map +1 -0
  736. package/dist/next-node/workers/workers.js +572 -0
  737. package/dist/next-node/workers/workers.js.map +1 -0
  738. package/dist/object.d.ts +4 -4
  739. package/dist/object.d.ts.map +1 -1
  740. package/dist/object.js +3 -4
  741. package/dist/object.js.map +1 -1
  742. package/dist/output.d.ts +1 -1
  743. package/dist/output.d.ts.map +1 -1
  744. package/dist/output.js +4 -2
  745. package/dist/output.js.map +1 -1
  746. package/dist/remote.d.ts.map +1 -1
  747. package/dist/remote.js +2 -2
  748. package/dist/remote.js.map +1 -1
  749. package/dist/schema.d.ts +8 -4
  750. package/dist/schema.d.ts.map +1 -1
  751. package/dist/schema.js +180 -5
  752. package/dist/schema.js.map +1 -1
  753. package/dist/sqlite/cloudflare.d.ts +2 -0
  754. package/dist/sqlite/cloudflare.d.ts.map +1 -1
  755. package/dist/sqlite/cloudflare.js +10 -0
  756. package/dist/sqlite/cloudflare.js.map +1 -1
  757. package/dist/sqlite/database.d.ts +5 -2
  758. package/dist/sqlite/database.d.ts.map +1 -1
  759. package/dist/sqlite/database.js.map +1 -1
  760. package/dist/sqlite/node.d.ts +4 -1
  761. package/dist/sqlite/node.d.ts.map +1 -1
  762. package/dist/sqlite/node.js +22 -5
  763. package/dist/sqlite/node.js.map +1 -1
  764. package/dist/watch.d.ts +194 -0
  765. package/dist/watch.d.ts.map +1 -0
  766. package/dist/watch.js +383 -0
  767. package/dist/watch.js.map +1 -0
  768. package/dist/wire.d.ts +174 -193
  769. package/dist/wire.d.ts.map +1 -1
  770. package/dist/wire.js +81 -80
  771. package/dist/wire.js.map +1 -1
  772. package/docs/guide.md +15 -15
  773. package/docs/next/benchmarks.md +959 -0
  774. package/docs/next/decisions.md +2957 -0
  775. package/docs/next/dependencies/book.md +1671 -0
  776. package/docs/next/dependencies/index.html +2641 -0
  777. package/docs/next/dependencies/model.md +330 -0
  778. package/docs/next/design.md +2554 -0
  779. package/docs/next/durable-observers/book.md +432 -0
  780. package/docs/next/durable-observers/index.html +517 -0
  781. package/docs/next/flow-control/book.md +333 -0
  782. package/docs/next/flow-control/fold/index.html +265 -0
  783. package/docs/next/flow-control/index.html +548 -0
  784. package/docs/next/flow-control/window/index.html +228 -0
  785. package/docs/next/guide-plugins-hosts/book.md +607 -0
  786. package/docs/next/guide-plugins-hosts/index.html +652 -0
  787. package/docs/next/http-workers/book.md +378 -0
  788. package/docs/next/http-workers/index.html +515 -0
  789. package/docs/next/layer-1.md +311 -0
  790. package/docs/next/layer-2.md +216 -0
  791. package/docs/next/plugin-model/book.md +186 -0
  792. package/docs/next/plugin-model/index.html +310 -0
  793. package/docs/next/plugin-primer/book.md +273 -0
  794. package/docs/next/plugin-primer/index.html +430 -0
  795. package/docs/next/slice-1.md +236 -0
  796. package/docs/next/slice-10.md +285 -0
  797. package/docs/next/slice-11.md +93 -0
  798. package/docs/next/slice-2.md +174 -0
  799. package/docs/next/slice-3a.md +296 -0
  800. package/docs/next/slice-3b.md +197 -0
  801. package/docs/next/slice-4.md +146 -0
  802. package/docs/next/slice-4a.md +418 -0
  803. package/docs/next/slice-4b.md +208 -0
  804. package/docs/next/slice-5.md +281 -0
  805. package/docs/next/slice-6a.md +676 -0
  806. package/docs/next/slice-6b.md +332 -0
  807. package/docs/next/slice-7a.md +130 -0
  808. package/docs/next/slice-7b/book.md +608 -0
  809. package/docs/next/slice-7b/index.html +842 -0
  810. package/docs/next/slice-7b.md +255 -0
  811. package/docs/next/slice-7c.md +165 -0
  812. package/docs/next/slice-8.md +194 -0
  813. package/docs/next/slices.md +230 -0
  814. package/docs/next/store/book.md +665 -0
  815. package/docs/next/store/index.html +861 -0
  816. package/docs/next/store/walkthrough.md +193 -0
  817. package/docs/spec.md +9 -9
  818. package/docs/tutorial.md +26 -25
  819. package/package.json +22 -6
  820. package/src/delta/README.md +69 -0
@@ -0,0 +1,285 @@
1
+ // A reference's member as consumers follow it (decision "References are the only indirection", §7): a consumer's
2
+ // watches and derives over `ref.member` (or a key of a keyed member) attach here, and this passes them straight through
3
+ // to the object instance's own document or derive (its watches and subscribers subscribe there: no extra hop on
4
+ // commits, the commit's value and ops by reference). When the reference's target moves to a new instance (or a new
5
+ // object of its identity), it moves them and sends one frame, a diff from the last value; while it points at nothing it
6
+ // keeps the last value (a pointer, no copy), with one `failed` call when its target failed (none while it loads).
7
+ import { diffRevisions } from "../../delta/index.js";
8
+ import { Watch } from "../../watch.js";
9
+ import { handedOut, Source, } from "../state/internal.js";
10
+ const ENDED = { kind: "ended" };
11
+ /** No failure told: a held value's `failure` while its target loads. */
12
+ const NO_FAILURE = undefined;
13
+ /**
14
+ * One member (or key) of one reference. Bound, it is a dependent of the instance's member (its own dependents are
15
+ * marked with it); its watches and subscribers subscribe to that member itself, so the member's frames reach them as
16
+ * they are, and a derive member stays lazy while nothing follows it; holding or moving moves them.
17
+ */
18
+ export class ReferenceSource extends Source {
19
+ #state = { kind: "unbound" };
20
+ /**
21
+ * Its watches and subscribers, each subscribed to the bound member while bound; held, they get nothing. Made by the
22
+ * first.
23
+ */
24
+ #passed;
25
+ /** What its watches had at a re-bind (`undefined` for no value: they had a failure), until the re-bind's frame. */
26
+ #framed;
27
+ /** Its reference: what a read throws while it never had a value (its failure, `not_ready`, or `released`). */
28
+ #owner;
29
+ constructor(batch, owner) {
30
+ super(batch);
31
+ this.#owner = owner;
32
+ }
33
+ /** Whether it never had a value (a watch waits for its reference's values first). */
34
+ get unbound() {
35
+ return this.#state.kind === "unbound";
36
+ }
37
+ get value() {
38
+ const state = this.#state;
39
+ switch (state.kind) {
40
+ case "bound":
41
+ return state.source.value;
42
+ case "held":
43
+ // A derive over a failed reference's member computes on its last value too (owner, G2: A).
44
+ return state.value;
45
+ case "unbound":
46
+ throw this.#owner.none();
47
+ default:
48
+ throw state.error;
49
+ }
50
+ }
51
+ /** What a new watch starts at: the bound member's start, the held value (after its failure), or the failure. */
52
+ start() {
53
+ const state = this.#state;
54
+ switch (state.kind) {
55
+ case "bound":
56
+ return state.source instanceof Source ? state.source.start() : { kind: "value", value: state.source.value };
57
+ case "held":
58
+ return state.failure === NO_FAILURE
59
+ ? { kind: "value", value: state.value }
60
+ : { kind: "failed", error: state.failure, last: state.value };
61
+ case "failed":
62
+ return { kind: "failed", error: state.error, last: state.last };
63
+ case "unbound":
64
+ throw this.#owner.none();
65
+ case "ended":
66
+ throw state.error;
67
+ }
68
+ }
69
+ /**
70
+ * A watch subscribed to the bound member itself (as `Source.openWatch` starts one: on a failed member at its last
71
+ * good value, the failure first).
72
+ */
73
+ openWatch(context) {
74
+ this.batch.assertOutside("watch");
75
+ const start = this.start();
76
+ if (start.kind === "failed" && start.last === undefined)
77
+ throw start.error;
78
+ const value = start.kind === "value" ? start.value : start.last;
79
+ const watch = new Watch(value, () => this.unsubscribe(watch), this.batch.reportListener);
80
+ this.subscribe(watch);
81
+ if (context.abortSignal !== undefined)
82
+ watch.observeAbort(context.abortSignal);
83
+ if (start.kind === "failed")
84
+ watch.fail(handedOut(start.error), context);
85
+ return watch;
86
+ }
87
+ /** Whether anything follows it: a watch, a subscriber or a derive (moving or ending it then needs a batch). */
88
+ get inUse() {
89
+ return this.watched || this.dependents.size > 0;
90
+ }
91
+ /** Whether a watch or a subscriber follows it (through the bound member). */
92
+ get watched() {
93
+ return (this.#passed?.size ?? 0) > 0;
94
+ }
95
+ /** Feeds `subscriber` the bound member's frames (it subscribes there) and the moves' frames. */
96
+ subscribe(subscriber) {
97
+ this.#passed ??= new Set();
98
+ this.#passed.add(subscriber);
99
+ const state = this.#state;
100
+ if (state.kind === "bound" && state.source instanceof Source)
101
+ state.source.subscribe(subscriber);
102
+ }
103
+ /** As `Source.unsubscribe`. */
104
+ unsubscribe(subscriber) {
105
+ this.#passed?.delete(subscriber);
106
+ const state = this.#state;
107
+ if (state.kind === "bound" && state.source instanceof Source)
108
+ state.source.unsubscribe(subscriber);
109
+ }
110
+ /** The bound member changed: its dependents are marked (its frames reach the subscribers directly). */
111
+ invalidate() {
112
+ for (const dependent of this.dependents)
113
+ dependent.invalidate();
114
+ }
115
+ /** The bound member's document was retired: its dependents carry the flag on. */
116
+ sourceRetired(visited) {
117
+ for (const dependent of this.dependents)
118
+ dependent.sourceRetired(visited);
119
+ }
120
+ /**
121
+ * Follows `source`, an instance's member, inside a batch: watches get one frame from the last value (a full one
122
+ * after a failure); derives downstream are marked and recompute, a failed one included (self-healing).
123
+ */
124
+ bind(source) {
125
+ const state = this.#state;
126
+ if (state.kind === "ended" || (state.kind === "bound" && state.source === source))
127
+ return;
128
+ this.#leave();
129
+ if (this.watched)
130
+ this.#framed = { value: this.#shown() };
131
+ this.#state = { kind: "bound", source };
132
+ this.#hook(source);
133
+ // Marks the derives downstream: a failed one recomputes too (self-healing).
134
+ this.changed();
135
+ }
136
+ /** Its target loads (a restart, a retry, a new object not live yet): it keeps its last value, and tells nothing. */
137
+ hold() {
138
+ const state = this.#state;
139
+ if (state.kind === "held") {
140
+ // Its watches had the failure: the next value stays whole (`told`).
141
+ if (state.failure !== NO_FAILURE)
142
+ this.#state = { ...state, failure: NO_FAILURE };
143
+ return;
144
+ }
145
+ if (state.kind === "bound")
146
+ this.#keep(NO_FAILURE);
147
+ }
148
+ /**
149
+ * Its target failed (`error`: its cause's, a refused version's, a removed type's), inside a batch: it keeps its last
150
+ * value, its watches and subscribers get one failure call (once per failure) and stay open.
151
+ */
152
+ fail(error, context) {
153
+ // Kept: its stack made text now, so it keeps none of the failed instance's frames.
154
+ handedOut(error);
155
+ const state = this.#state;
156
+ if (state.kind === "held") {
157
+ if (state.failure !== NO_FAILURE)
158
+ return;
159
+ this.#state = { kind: "held", value: state.value, failure: error, told: true };
160
+ }
161
+ else if (state.kind === "bound") {
162
+ if (!this.#keep(error))
163
+ return;
164
+ }
165
+ else {
166
+ return;
167
+ }
168
+ this.#call({ kind: "failed", error }, context);
169
+ }
170
+ /**
171
+ * Its target's live variant lacks the member, inside a batch: reads throw `error`; watches and subscribers get one
172
+ * failure call and stay open (a later instance may bring the member back, as `[["r", value]]`).
173
+ */
174
+ vanish(error, context) {
175
+ const state = this.#state;
176
+ if (state.kind === "ended")
177
+ return;
178
+ const last = state.kind === "unbound" ? undefined : this.#lastGood();
179
+ this.#leave();
180
+ this.#state = { kind: "failed", error: handedOut(error), last };
181
+ this.#call({ kind: "failed", error }, context);
182
+ this.changed();
183
+ }
184
+ /**
185
+ * Its reference ended, inside a batch: reads throw `error`, watches end `ended`, and derives over it are marked
186
+ * (their next read throws it, no cached value stays).
187
+ */
188
+ end(error) {
189
+ this.#leave();
190
+ this.#state = { kind: "ended", error };
191
+ this.#framed = undefined;
192
+ // A copy: an ending watch unsubscribes itself.
193
+ const passed = this.#passed;
194
+ this.#passed = undefined;
195
+ if (passed !== undefined)
196
+ for (const subscriber of [...passed])
197
+ subscriber.end(ENDED);
198
+ for (const dependent of this.dependents)
199
+ dependent.invalidate();
200
+ }
201
+ /** Delivers a move's frame: the diff from the watches' value to the new member's. */
202
+ deliver(context) {
203
+ const framed = this.#framed;
204
+ this.#framed = undefined;
205
+ if (framed === undefined)
206
+ return;
207
+ let after;
208
+ try {
209
+ after = this.value;
210
+ }
211
+ catch (error) {
212
+ if (framed.value !== undefined)
213
+ this.#call({ kind: "failed", error: handedOut(error) }, context);
214
+ return;
215
+ }
216
+ const before = framed.value;
217
+ if (after === before)
218
+ return;
219
+ // After a failure (no value framed): whole, even when unchanged.
220
+ const ops = before === undefined ? [["r", after]] : diffRevisions(before, after);
221
+ if (ops.length > 0)
222
+ this.#call({ kind: "value", value: after, ops, retired: false }, context);
223
+ }
224
+ /**
225
+ * Stops following the bound member and keeps its value (`failure`: the failure it is held with); a member whose value
226
+ * throws becomes failed. Whether it holds a value.
227
+ */
228
+ #keep(failure) {
229
+ const state = this.#state;
230
+ const start = state.source instanceof Source ? state.source.start() : undefined;
231
+ this.#leave();
232
+ if (start === undefined || start.kind === "value") {
233
+ const value = start === undefined ? state.source.value : start.value;
234
+ this.#state = { kind: "held", value, failure, told: failure !== NO_FAILURE };
235
+ return true;
236
+ }
237
+ this.#state = { kind: "failed", error: handedOut(start.error), last: start.last };
238
+ return false;
239
+ }
240
+ /** A call of its own (a move's frame, a failure) to its watches and subscribers. */
241
+ #call(call, context) {
242
+ if (this.#passed !== undefined)
243
+ for (const subscriber of this.#passed)
244
+ subscriber.advance(call, context);
245
+ }
246
+ /**
247
+ * The value its watches have before a move; `undefined` when they had a failure since it (their next value is whole,
248
+ * `[["r", value]]`, even when unchanged).
249
+ */
250
+ #shown() {
251
+ const state = this.#state;
252
+ if (state.kind === "unbound" || (state.kind === "held" && state.told))
253
+ return undefined;
254
+ const start = this.start();
255
+ return start.kind === "value" ? start.value : undefined;
256
+ }
257
+ /** Its last good value, which watches opened while it is failed start at; `undefined` when it never had one. */
258
+ #lastGood() {
259
+ const start = this.start();
260
+ return start.kind === "value" ? start.value : start.last;
261
+ }
262
+ /** Starts reading `source`: its changes mark this source's dependents, its frames reach the subscribers. */
263
+ #hook(source) {
264
+ if (!(source instanceof Source))
265
+ return;
266
+ source.dependents.add(this);
267
+ if (this.#passed !== undefined)
268
+ for (const subscriber of this.#passed)
269
+ source.subscribe(subscriber);
270
+ }
271
+ /** Stops following the bound source, when bound: no more marks or frames from it. */
272
+ #leave() {
273
+ const state = this.#state;
274
+ if (state.kind !== "bound")
275
+ return;
276
+ const { source } = state;
277
+ if (!(source instanceof Source))
278
+ return;
279
+ source.dependents.delete(this);
280
+ if (this.#passed !== undefined)
281
+ for (const subscriber of this.#passed)
282
+ source.unsubscribe(subscriber);
283
+ }
284
+ }
285
+ //# sourceMappingURL=reference-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference-source.js","sourceRoot":"","sources":["../../../src/next/host/reference-source.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,wHAAwH;AACxH,gHAAgH;AAChH,mHAAmH;AACnH,wHAAwH;AACxH,kHAAkH;AAGlH,OAAO,EAAE,aAAa,EAAW,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAiC,MAAM,gBAAgB,CAAC;AAEtE,OAAO,EAIN,SAAS,EACT,MAAM,GAGN,MAAM,sBAAsB,CAAC;AAqB9B,MAAM,KAAK,GAAa,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAE1C,wEAAwE;AACxE,MAAM,UAAU,GAAG,SAAS,CAAC;AAE7B;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,MAAM;IAC1C,MAAM,GAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC1C;;;OAGG;IACH,OAAO,CAA8B;IACrC,mHAAmH;IACnH,OAAO,CAAwD;IAC/D,8GAA8G;IACrG,MAAM,CAAc;IAE7B,YAAY,KAAY,EAAE,KAAkB;QAC3C,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,qFAAqF;IACrF,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;IACvC,CAAC;IAED,IAAI,KAAK;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,OAAO;gBACX,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;YAC3B,KAAK,MAAM;gBACV,2FAA2F;gBAC3F,OAAO,KAAK,CAAC,KAAK,CAAC;YACpB,KAAK,SAAS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5B,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAAE,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,OAAO;gBAAE,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACrG,CAAC;IAED,qFAAqF;IACrF,MAAM;QACL,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;YAAE,OAAO;QACnC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,CAAC,MAAM,YAAY,MAAM,CAAC;YAAE,OAAO;QACxC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAAE,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,OAAO;gBAAE,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACvG,CAAC;CACD","sourcesContent":["// A reference's member as consumers follow it (decision \"References are the only indirection\", §7): a consumer's\n// watches and derives over `ref.member` (or a key of a keyed member) attach here, and this passes them straight through\n// to the object instance's own document or derive (its watches and subscribers subscribe there: no extra hop on\n// commits, the commit's value and ops by reference). When the reference's target moves to a new instance (or a new\n// object of its identity), it moves them and sends one frame, a diff from the last value; while it points at nothing it\n// keeps the last value (a pointer, no copy), with one `failed` call when its target failed (none while it loads).\n\nimport type { Context } from \"../../context/index.ts\";\nimport { diffRevisions, type Op } from \"../../delta/index.ts\";\nimport type { JsonValue } from \"../../json.ts\";\nimport { Watch, type WatchCall, type WatchEnd } from \"../../watch.ts\";\nimport type { ChordError } from \"../data/index.ts\";\nimport {\n\ttype Batch,\n\ttype Dependent,\n\ttype DeriveSource,\n\thandedOut,\n\tSource,\n\ttype Subscriber,\n\ttype WatchStart,\n} from \"../state/internal.ts\";\n\n/**\n * Where a reference's source stands: never had a value (`unbound`: reads throw what its reference has instead),\n * following an instance's member, holding its last value while pointing at nothing (`failure` while its target is\n * failed: new watches start with it; `told`: its watches got a failure since that value, so the next is whole), failed\n * (a member its target's live variant lacks, or its compute threw when it was held: reads throw, `last` is the last\n * good value) or ended with its reference (nothing kept).\n */\ntype SourceState =\n\t| { readonly kind: \"unbound\" }\n\t| { readonly kind: \"bound\"; readonly source: DeriveSource }\n\t| { readonly kind: \"held\"; readonly value: JsonValue; readonly failure: unknown; readonly told: boolean }\n\t| { readonly kind: \"failed\"; readonly error: unknown; readonly last: JsonValue | undefined }\n\t| { readonly kind: \"ended\"; readonly error: ChordError };\n\n/** A reference owning its sources: what a read of one that never had a value throws. */\nexport interface SourceOwner {\n\tnone(): ChordError;\n}\n\nconst ENDED: WatchEnd = { kind: \"ended\" };\n\n/** No failure told: a held value's `failure` while its target loads. */\nconst NO_FAILURE = undefined;\n\n/**\n * One member (or key) of one reference. Bound, it is a dependent of the instance's member (its own dependents are\n * marked with it); its watches and subscribers subscribe to that member itself, so the member's frames reach them as\n * they are, and a derive member stays lazy while nothing follows it; holding or moving moves them.\n */\nexport class ReferenceSource extends Source implements Dependent {\n\t#state: SourceState = { kind: \"unbound\" };\n\t/**\n\t * Its watches and subscribers, each subscribed to the bound member while bound; held, they get nothing. Made by the\n\t * first.\n\t */\n\t#passed: Set<Subscriber> | undefined;\n\t/** What its watches had at a re-bind (`undefined` for no value: they had a failure), until the re-bind's frame. */\n\t#framed: { readonly value: JsonValue | undefined } | undefined;\n\t/** Its reference: what a read throws while it never had a value (its failure, `not_ready`, or `released`). */\n\treadonly #owner: SourceOwner;\n\n\tconstructor(batch: Batch, owner: SourceOwner) {\n\t\tsuper(batch);\n\t\tthis.#owner = owner;\n\t}\n\n\t/** Whether it never had a value (a watch waits for its reference's values first). */\n\tget unbound(): boolean {\n\t\treturn this.#state.kind === \"unbound\";\n\t}\n\n\tget value(): JsonValue {\n\t\tconst state = this.#state;\n\t\tswitch (state.kind) {\n\t\t\tcase \"bound\":\n\t\t\t\treturn state.source.value;\n\t\t\tcase \"held\":\n\t\t\t\t// A derive over a failed reference's member computes on its last value too (owner, G2: A).\n\t\t\t\treturn state.value;\n\t\t\tcase \"unbound\":\n\t\t\t\tthrow this.#owner.none();\n\t\t\tdefault:\n\t\t\t\tthrow state.error;\n\t\t}\n\t}\n\n\t/** What a new watch starts at: the bound member's start, the held value (after its failure), or the failure. */\n\tstart(): WatchStart {\n\t\tconst state = this.#state;\n\t\tswitch (state.kind) {\n\t\t\tcase \"bound\":\n\t\t\t\treturn state.source instanceof Source ? state.source.start() : { kind: \"value\", value: state.source.value };\n\t\t\tcase \"held\":\n\t\t\t\treturn state.failure === NO_FAILURE\n\t\t\t\t\t? { kind: \"value\", value: state.value }\n\t\t\t\t\t: { kind: \"failed\", error: state.failure, last: state.value };\n\t\t\tcase \"failed\":\n\t\t\t\treturn { kind: \"failed\", error: state.error, last: state.last };\n\t\t\tcase \"unbound\":\n\t\t\t\tthrow this.#owner.none();\n\t\t\tcase \"ended\":\n\t\t\t\tthrow state.error;\n\t\t}\n\t}\n\n\t/**\n\t * A watch subscribed to the bound member itself (as `Source.openWatch` starts one: on a failed member at its last\n\t * good value, the failure first).\n\t */\n\topenWatch(context: Context): Watch<JsonValue> {\n\t\tthis.batch.assertOutside(\"watch\");\n\t\tconst start = this.start();\n\t\tif (start.kind === \"failed\" && start.last === undefined) throw start.error;\n\t\tconst value = start.kind === \"value\" ? start.value : start.last!;\n\t\tconst watch: Watch<JsonValue> = new Watch(value, () => this.unsubscribe(watch), this.batch.reportListener);\n\t\tthis.subscribe(watch);\n\t\tif (context.abortSignal !== undefined) watch.observeAbort(context.abortSignal);\n\t\tif (start.kind === \"failed\") watch.fail(handedOut(start.error), context);\n\t\treturn watch;\n\t}\n\n\t/** Whether anything follows it: a watch, a subscriber or a derive (moving or ending it then needs a batch). */\n\tget inUse(): boolean {\n\t\treturn this.watched || this.dependents.size > 0;\n\t}\n\n\t/** Whether a watch or a subscriber follows it (through the bound member). */\n\tget watched(): boolean {\n\t\treturn (this.#passed?.size ?? 0) > 0;\n\t}\n\n\t/** Feeds `subscriber` the bound member's frames (it subscribes there) and the moves' frames. */\n\tsubscribe(subscriber: Subscriber): void {\n\t\tthis.#passed ??= new Set();\n\t\tthis.#passed.add(subscriber);\n\t\tconst state = this.#state;\n\t\tif (state.kind === \"bound\" && state.source instanceof Source) state.source.subscribe(subscriber);\n\t}\n\n\t/** As `Source.unsubscribe`. */\n\tunsubscribe(subscriber: Subscriber): void {\n\t\tthis.#passed?.delete(subscriber);\n\t\tconst state = this.#state;\n\t\tif (state.kind === \"bound\" && state.source instanceof Source) state.source.unsubscribe(subscriber);\n\t}\n\n\t/** The bound member changed: its dependents are marked (its frames reach the subscribers directly). */\n\tinvalidate(): void {\n\t\tfor (const dependent of this.dependents) dependent.invalidate();\n\t}\n\n\t/** The bound member's document was retired: its dependents carry the flag on. */\n\tsourceRetired(visited: Set<Dependent>): void {\n\t\tfor (const dependent of this.dependents) dependent.sourceRetired(visited);\n\t}\n\n\t/**\n\t * Follows `source`, an instance's member, inside a batch: watches get one frame from the last value (a full one\n\t * after a failure); derives downstream are marked and recompute, a failed one included (self-healing).\n\t */\n\tbind(source: DeriveSource): void {\n\t\tconst state = this.#state;\n\t\tif (state.kind === \"ended\" || (state.kind === \"bound\" && state.source === source)) return;\n\t\tthis.#leave();\n\t\tif (this.watched) this.#framed = { value: this.#shown() };\n\t\tthis.#state = { kind: \"bound\", source };\n\t\tthis.#hook(source);\n\t\t// Marks the derives downstream: a failed one recomputes too (self-healing).\n\t\tthis.changed();\n\t}\n\n\t/** Its target loads (a restart, a retry, a new object not live yet): it keeps its last value, and tells nothing. */\n\thold(): void {\n\t\tconst state = this.#state;\n\t\tif (state.kind === \"held\") {\n\t\t\t// Its watches had the failure: the next value stays whole (`told`).\n\t\t\tif (state.failure !== NO_FAILURE) this.#state = { ...state, failure: NO_FAILURE };\n\t\t\treturn;\n\t\t}\n\t\tif (state.kind === \"bound\") this.#keep(NO_FAILURE);\n\t}\n\n\t/**\n\t * Its target failed (`error`: its cause's, a refused version's, a removed type's), inside a batch: it keeps its last\n\t * value, its watches and subscribers get one failure call (once per failure) and stay open.\n\t */\n\tfail(error: ChordError, context: Context): void {\n\t\t// Kept: its stack made text now, so it keeps none of the failed instance's frames.\n\t\thandedOut(error);\n\t\tconst state = this.#state;\n\t\tif (state.kind === \"held\") {\n\t\t\tif (state.failure !== NO_FAILURE) return;\n\t\t\tthis.#state = { kind: \"held\", value: state.value, failure: error, told: true };\n\t\t} else if (state.kind === \"bound\") {\n\t\t\tif (!this.#keep(error)) return;\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t\tthis.#call({ kind: \"failed\", error }, context);\n\t}\n\n\t/**\n\t * Its target's live variant lacks the member, inside a batch: reads throw `error`; watches and subscribers get one\n\t * failure call and stay open (a later instance may bring the member back, as `[[\"r\", value]]`).\n\t */\n\tvanish(error: ChordError, context: Context): void {\n\t\tconst state = this.#state;\n\t\tif (state.kind === \"ended\") return;\n\t\tconst last = state.kind === \"unbound\" ? undefined : this.#lastGood();\n\t\tthis.#leave();\n\t\tthis.#state = { kind: \"failed\", error: handedOut(error), last };\n\t\tthis.#call({ kind: \"failed\", error }, context);\n\t\tthis.changed();\n\t}\n\n\t/**\n\t * Its reference ended, inside a batch: reads throw `error`, watches end `ended`, and derives over it are marked\n\t * (their next read throws it, no cached value stays).\n\t */\n\tend(error: ChordError): void {\n\t\tthis.#leave();\n\t\tthis.#state = { kind: \"ended\", error };\n\t\tthis.#framed = undefined;\n\t\t// A copy: an ending watch unsubscribes itself.\n\t\tconst passed = this.#passed;\n\t\tthis.#passed = undefined;\n\t\tif (passed !== undefined) for (const subscriber of [...passed]) subscriber.end(ENDED);\n\t\tfor (const dependent of this.dependents) dependent.invalidate();\n\t}\n\n\t/** Delivers a move's frame: the diff from the watches' value to the new member's. */\n\tdeliver(context: Context): void {\n\t\tconst framed = this.#framed;\n\t\tthis.#framed = undefined;\n\t\tif (framed === undefined) return;\n\t\tlet after: JsonValue;\n\t\ttry {\n\t\t\tafter = this.value;\n\t\t} catch (error) {\n\t\t\tif (framed.value !== undefined) this.#call({ kind: \"failed\", error: handedOut(error) }, context);\n\t\t\treturn;\n\t\t}\n\t\tconst before = framed.value;\n\t\tif (after === before) return;\n\t\t// After a failure (no value framed): whole, even when unchanged.\n\t\tconst ops: readonly Op[] = before === undefined ? [[\"r\", after]] : diffRevisions(before, after);\n\t\tif (ops.length > 0) this.#call({ kind: \"value\", value: after, ops, retired: false }, context);\n\t}\n\n\t/**\n\t * Stops following the bound member and keeps its value (`failure`: the failure it is held with); a member whose value\n\t * throws becomes failed. Whether it holds a value.\n\t */\n\t#keep(failure: unknown): boolean {\n\t\tconst state = this.#state as Extract<SourceState, { readonly kind: \"bound\" }>;\n\t\tconst start = state.source instanceof Source ? state.source.start() : undefined;\n\t\tthis.#leave();\n\t\tif (start === undefined || start.kind === \"value\") {\n\t\t\tconst value = start === undefined ? state.source.value : start.value;\n\t\t\tthis.#state = { kind: \"held\", value, failure, told: failure !== NO_FAILURE };\n\t\t\treturn true;\n\t\t}\n\t\tthis.#state = { kind: \"failed\", error: handedOut(start.error), last: start.last };\n\t\treturn false;\n\t}\n\n\t/** A call of its own (a move's frame, a failure) to its watches and subscribers. */\n\t#call(call: WatchCall<JsonValue>, context: Context): void {\n\t\tif (this.#passed !== undefined) for (const subscriber of this.#passed) subscriber.advance(call, context);\n\t}\n\n\t/**\n\t * The value its watches have before a move; `undefined` when they had a failure since it (their next value is whole,\n\t * `[[\"r\", value]]`, even when unchanged).\n\t */\n\t#shown(): JsonValue | undefined {\n\t\tconst state = this.#state;\n\t\tif (state.kind === \"unbound\" || (state.kind === \"held\" && state.told)) return undefined;\n\t\tconst start = this.start();\n\t\treturn start.kind === \"value\" ? start.value : undefined;\n\t}\n\n\t/** Its last good value, which watches opened while it is failed start at; `undefined` when it never had one. */\n\t#lastGood(): JsonValue | undefined {\n\t\tconst start = this.start();\n\t\treturn start.kind === \"value\" ? start.value : start.last;\n\t}\n\n\t/** Starts reading `source`: its changes mark this source's dependents, its frames reach the subscribers. */\n\t#hook(source: DeriveSource): void {\n\t\tif (!(source instanceof Source)) return;\n\t\tsource.dependents.add(this);\n\t\tif (this.#passed !== undefined) for (const subscriber of this.#passed) source.subscribe(subscriber);\n\t}\n\n\t/** Stops following the bound source, when bound: no more marks or frames from it. */\n\t#leave(): void {\n\t\tconst state = this.#state;\n\t\tif (state.kind !== \"bound\") return;\n\t\tconst { source } = state;\n\t\tif (!(source instanceof Source)) return;\n\t\tsource.dependents.delete(this);\n\t\tif (this.#passed !== undefined) for (const subscriber of this.#passed) source.unsubscribe(subscriber);\n\t}\n}\n"]}
@@ -0,0 +1,308 @@
1
+ import { type Context } from "../../context/index.ts";
2
+ import type { JsonValue } from "../../json.ts";
3
+ import type { NativeWatchable, Watch } from "../../watch.ts";
4
+ import type { Contract, Implementation, ParamsOf } from "../contracts/index.ts";
5
+ import { type CurrentVariants, type ShapeOf, type VariantImplementation } from "../contracts/internal.ts";
6
+ import { ChordError, type FailureCause, type Principal } from "../data/index.ts";
7
+ import { type KeyedSlot } from "../documents/internal.ts";
8
+ import { type Batch, type DeriveSource } from "../state/internal.ts";
9
+ import type { PinnedKey } from "./attempt.ts";
10
+ import { type Caller } from "./ctx.ts";
11
+ import type { KeyedBinding } from "./members.ts";
12
+ import type { ChordObject, Holder, Removal } from "./object.ts";
13
+ import { type RefState } from "./ref-state.ts";
14
+ import type { UnboundRequest } from "./unbound.ts";
15
+ /**
16
+ * A reference: a local contract's members, or for a remote contract the members of the variant its object chose,
17
+ * narrowed by `variant`; and its state, `retry()` and `release()`. Every use after release throws.
18
+ */
19
+ export type Reference<C extends Contract> = ShapeOf<C>["kind"] extends "local" ? Implementation<C> & Lifecycle : InVariants<C, never>;
20
+ /** What `host.hold` returns: a reference whose `variant` is `undefined` until its first binding. */
21
+ export type Held<C extends Contract> = ShapeOf<C>["kind"] extends "local" ? Implementation<C> & Lifecycle : InVariants<C, undefined>;
22
+ /** A remote reference narrowed to some of its variants. */
23
+ export type RefIn<C extends Contract, V extends string> = Extract<Reference<C>, {
24
+ readonly variant: V;
25
+ }>;
26
+ /** One member of a remote reference's union per variant; `Unbound` is what `variant` may also be. */
27
+ type InVariants<C extends Contract, Unbound> = {
28
+ [V in keyof CurrentVariants<C>]: {
29
+ readonly variant: V | Unbound;
30
+ } & VariantImplementation<CurrentVariants<C>[V]> & Lifecycle;
31
+ }[keyof CurrentVariants<C>];
32
+ /** What every reference has besides its members. */
33
+ type Lifecycle = {
34
+ /** The reference's state: loading, live, failed or released; watches get every change. */
35
+ readonly state: NativeWatchable<RefState>;
36
+ /**
37
+ * Asks a failed object for an attempt now (the backoff skipped, a broken one renewed); an object parked on failed
38
+ * dependencies passes it on to them, once; otherwise nothing.
39
+ */
40
+ retry(): void;
41
+ release(): void;
42
+ };
43
+ /**
44
+ * What a binding is bound to: an object on this host (`ChordObject`), or an object held over a path, the parent link
45
+ * or a route address (`RemoteObject`). It tells its holders of each change of `state`.
46
+ */
47
+ export interface Target {
48
+ /** The object in errors: its type, and its params key when it has params. */
49
+ readonly label: string;
50
+ /** Its state as its references show it. */
51
+ readonly state: RefState;
52
+ /** Whether its state members have values: live once, for a remote object bound once. */
53
+ readonly hydrated: boolean;
54
+ /** The variant bound last; `undefined` for a local object and before the first binding. */
55
+ readonly variant: string | undefined;
56
+ /** The error of its last failure (an attempt's, or the dependencies it is parked on) while none went live since. */
57
+ readonly lastFailure: ChordError | undefined;
58
+ /** Its instance id while it activates on this host (Q5); `undefined` otherwise and over a link. */
59
+ readonly activationId: string | undefined;
60
+ /**
61
+ * Whether it holds up this host's start barrier: an object here without its first outcome (decision (a)); a remote
62
+ * object never does.
63
+ */
64
+ readonly blocksFirstPass: boolean;
65
+ /** Counts `binding` as a reference; the binding reads `state` itself. */
66
+ hold(binding: Binding): void;
67
+ /** `binding` was released. */
68
+ unhold(binding: Binding): void;
69
+ /** Calls a method of the live object for `caller`, bound at `version` (an older one is mapped, Q10). */
70
+ call(method: string, args: unknown, context: Context, caller: Caller, version: number): Promise<unknown>;
71
+ /**
72
+ * What a reference of `version` follows for state member `member` now (decision "References are the only
73
+ * indirection"): the live instance's member (a replica over a link), or nothing (`loading`, or `failed` with the
74
+ * cause's error), with the member a reference takes its last value from.
75
+ */
76
+ followed(member: string, version: number): Followed;
77
+ /** The instance its references follow now (they attach to it); `undefined` once it stopped changing. */
78
+ readonly attachable: Attachable | undefined;
79
+ /** Its live instance (a reference's keys pin there; a new one, they pin again); `undefined` when not live. */
80
+ readonly instance: unknown;
81
+ /** The keyed member `member` of the live object: its ultimate slot (slice 6a §12; only local objects have any). */
82
+ keyedMember(member: string): KeyedSlot;
83
+ /**
84
+ * How a consumer of `version` reads keyed member `member`'s documents: mapped back to its version when older
85
+ * (slice 7b §7), `undefined` when as they are; `contract_mismatch` when the provider refuses it.
86
+ */
87
+ keyedMapping(member: string, version: number): ((current: JsonValue) => JsonValue) | undefined;
88
+ /**
89
+ * Pins `key` of keyed member `member` on the live instance, loaded, as a consumer of `version` reads it (mapped when
90
+ * older); only a live local object has keyed members.
91
+ */
92
+ pinKey(member: string, key: string, version: number, context: Context): Promise<PinnedKey>;
93
+ /**
94
+ * `ref.retry()`, as one step of `walk`: an attempt now if failed; an object parked on failed dependencies passes it
95
+ * on; ignored otherwise.
96
+ */
97
+ retry(walk: RetryWalk): void;
98
+ /**
99
+ * The chain of activation waits from this object to `target`, both included (Q5); `undefined` when there is none.
100
+ * `visited` keeps a search over shared dependencies linear in the waits.
101
+ */
102
+ pathTo(target: ChordObject, visited: Set<Target>): ChordObject[] | undefined;
103
+ }
104
+ /** An instance a reference attaches to (`Target.attachable`): it keeps last values in that instance's variant. */
105
+ export type Attachable = {
106
+ readonly variant: string | undefined;
107
+ };
108
+ /**
109
+ * What a reference follows of its target for one state member (`Target.followed`): the member of the instance it
110
+ * follows (`instance`, still changing), a member its live variant lacks (`invalid/member`), or nothing: its target loads
111
+ * (no call) or failed (one `failed` call with the cause's error); `last` is the member of `instance`, which stopped
112
+ * changing, that a reference attached to it takes a last value from (never one it never attached to).
113
+ */
114
+ export type Followed = {
115
+ readonly kind: "live";
116
+ readonly source: DeriveSource;
117
+ readonly instance: unknown;
118
+ } | {
119
+ readonly kind: "lacking";
120
+ readonly error: ChordError;
121
+ } | {
122
+ readonly kind: "loading";
123
+ readonly last: DeriveSource | undefined;
124
+ readonly instance: unknown;
125
+ } | {
126
+ readonly kind: "failed";
127
+ readonly error: ChordError;
128
+ readonly last: DeriveSource | undefined;
129
+ readonly instance: unknown;
130
+ };
131
+ /**
132
+ * One retry's walk through parked objects on this host (dependency model §3.7, audit A5): the objects it reached (one
133
+ * reached again, through a diamond, ignores it) and the hop budget a `retry` message to another host carries (none is
134
+ * sent at 0, so a waiting ring of hosts stops).
135
+ */
136
+ export type RetryWalk = {
137
+ readonly visited: Set<ChordObject>;
138
+ readonly hops: number;
139
+ };
140
+ /** A walk starting here: `ref.retry()`'s, with the first host's budget, or a `retry` message's, with one hop less. */
141
+ export declare function retryWalk(hops?: number): RetryWalk;
142
+ /** A reference's params as L1 checked them, with their identity key. */
143
+ export type CheckedParams = {
144
+ readonly params: ParamsOf<Contract>;
145
+ readonly key: string;
146
+ };
147
+ /**
148
+ * A reference's binding to its object: counted by the object as one of its references while bound, and told of each
149
+ * change of its state. Calls run while live, park while loading (sent in order once live) and reject while failed.
150
+ * Released, or ended with its object, it ends the watches taken through it and rejects the calls made through it.
151
+ */
152
+ export declare class Binding implements Holder, UnboundRequest {
153
+ #private;
154
+ readonly reference: Reference<Contract>;
155
+ /** Who calls through this reference: the principal it was got as, and this host's incarnation. */
156
+ readonly caller: Caller;
157
+ constructor(contract: Contract, batch: Batch, dependent: ChordObject | undefined, caller: Caller, parkTimeout: number);
158
+ /** The consumer's contract: its version is the binding's. Only an unreleased binding is asked. */
159
+ get contract(): Contract;
160
+ /** The object whose attempt declared this reference, until it is released. */
161
+ get dependent(): ChordObject | undefined;
162
+ /** Whom it acts for (the unbound index's revocation). */
163
+ get principal(): Principal | undefined;
164
+ /** The reference's state. */
165
+ get refState(): RefState;
166
+ /** The object it is bound to; `undefined` while it is not bound. */
167
+ get target(): Target | undefined;
168
+ /** The object in errors: its label once bound, else the contract's name. */
169
+ get label(): string;
170
+ /** The error of the object's last failure while none went live since, or of the check that left it unbound. */
171
+ get lastFailure(): ChordError | undefined;
172
+ /**
173
+ * Binds to `target`, which counts this binding as a reference; its members and keys follow what `target` shows now
174
+ * (one frame from their last values), and the reference takes its state.
175
+ */
176
+ bind(target: Target): void;
177
+ /** Whether its members or keys were used: `retarget` moves them (in a batch). */
178
+ get following(): boolean;
179
+ /**
180
+ * Inside a batch when `following`: its members and keys follow what its object shows now (`Target.followed`): the live instance's
181
+ * members (moved there, one frame each), or their last values (one `failed` call for a failure). The first time it
182
+ * points at nothing, every member of its version gets its last value, read or not.
183
+ */
184
+ retarget(): void;
185
+ /**
186
+ * Its object left it (slice 7b §6): its type was removed, or its provider no longer binds its version. The request
187
+ * waits unbound with `removal.cause` in the host's index, its members and keys keeping their last values (taken from
188
+ * the instance it leaves; one `failed` call), and binds again, by name, when a publication serves it: its members
189
+ * move to the next object's instance and its keys pin there again (one frame each); parked calls flush or reject;
190
+ * presence lists it again.
191
+ */
192
+ removed(removal: Removal): void;
193
+ /**
194
+ * Leaves the reference unbound in the host's unbound index (`leave` takes it out): `loading` before the publication
195
+ * (no `cause`), else `failed` with `cause` (`waiting`); `place` checks it again when the index wakes it.
196
+ */
197
+ wait(cause: FailureCause | undefined, place: () => void, leave: () => void): void;
198
+ /** Woken by the unbound index (out of it already): checked again where it goes. */
199
+ wake(): void;
200
+ /**
201
+ * A reference that cannot be bound (where it goes refused it): failed broken with `cause` until `ref.retry()` runs
202
+ * `bind` again (a route's `authorize` may admit it later).
203
+ */
204
+ refuse(cause: FailureCause, bind: () => void): void;
205
+ /**
206
+ * The state may have changed: `ref.state`'s watches are told; live sends the parked calls in order, failed
207
+ * rejects them with the cause; waits for a state decide; the object whose attempt declared it re-evaluates.
208
+ */
209
+ moved(): void;
210
+ /** Resolves when the reference is live; rejects with a broken failure's error, or its end. Getters wait for it. */
211
+ live(context: Context): Promise<void>;
212
+ /**
213
+ * The state member behind `member`, as consumers follow it (`ReferenceSource`): the instance's member while its
214
+ * object is live, its last value while it points at nothing; reads throw `released`, the failure's error, or
215
+ * `not_ready` when it never had a value.
216
+ */
217
+ member(member: string): DeriveSource;
218
+ /** What a read of a member that never had a value throws: `released`, the failure's error, or `not_ready`. */
219
+ none(): ChordError;
220
+ /** The keyed member `member`'s slot (slice 6a §12), as `member` resolves a state member. */
221
+ keyedSlot(member: string): KeyedSlot;
222
+ /** How this reference reads keyed member `member`'s documents (`Target.keyedMapping`), as `keyedSlot` resolves. */
223
+ keyedMapping(member: string): ((current: JsonValue) => JsonValue) | undefined;
224
+ /**
225
+ * Holds `key` of keyed member `member` (a key watch, a factory's `at(key)`, an object re-exposing this member): its
226
+ * source, pinned on the live instance and following its object's instances (`ReferenceKeys`); `release` once.
227
+ */
228
+ pinKey(member: string, key: string, context: Context): Promise<PinnedKey>;
229
+ /**
230
+ * A watch of `member` that ends when this reference is released, through its member (`ReferenceSource`): opened at
231
+ * once once it has a value (its last one while its object is not live, frames again when it is); before its first
232
+ * value it waits for its object's (`firstValues`: through failures, until the reference ends or `context` aborts).
233
+ */
234
+ watch(member: string, context: Context): Promise<Watch<JsonValue>>;
235
+ /**
236
+ * Resolves once its object's members have values (its first binding, for a watch on a reference that never had any);
237
+ * rejects only when the reference ends (released, revoked, its host closed) or `context` aborts: a failure is waited
238
+ * through (Opus G3).
239
+ */
240
+ firstValues(context: Context): Promise<void>;
241
+ /** Resolves once the object's members have values; rejects when the reference fails or is released first. */
242
+ hydrated(context: Context): Promise<void>;
243
+ /**
244
+ * Ends `watch` when this reference is released; returns it. A watch opened while the reference was released (an
245
+ * async keyed watch racing `release`) is ended at once, its pin with it, and the caller gets `released`.
246
+ */
247
+ follow<W extends Watch<JsonValue>>(watch: W): W;
248
+ /**
249
+ * `ref.member.at(key)`: only while its object's factory runs (the reference not yet bound); pinned once bound
250
+ * (`pinKeys`), released with the reference.
251
+ */
252
+ at(member: string, key: string): KeyedMemberAt;
253
+ /** Whether its object's factory pinned keys on it (`at(key)`). */
254
+ get pinsKeys(): boolean;
255
+ /**
256
+ * Pins the keys of `at(key)` on the live object's keyed members and loads those not in memory, before the
257
+ * dependent goes live (slice 6a §12); `undefined` when there are none. A failed load rejects.
258
+ */
259
+ pinKeys(context: Context): Promise<void> | undefined;
260
+ /**
261
+ * `ref.retry()`, as a step of `walk` (a new one for `ref.retry()`, passed on through parked objects): the object is
262
+ * asked for an attempt now (ignored unless failed; a parked one passes it on); a refused reference is placed again;
263
+ * one waiting in the index is left as it is (an event wakes it).
264
+ */
265
+ retry(walk?: RetryWalk): void;
266
+ /** Releases the reference (idempotent); the object may end when it was its last. */
267
+ release(): void;
268
+ /**
269
+ * Ends the reference without releasing it from its object (it ended): watches end, calls (running and parked)
270
+ * reject with `error`, `ref.state` is `ended` with it; the object whose attempt declared it checks again.
271
+ */
272
+ end(error: ChordError): void;
273
+ }
274
+ /**
275
+ * `ref.member.at(key)`: the key's source across the object's attempts once the reference is bound and the key held
276
+ * (`pin`), until the reference ends (`release`, exactly once): then it drops the source (a retained reference keeps no
277
+ * provider).
278
+ */
279
+ declare class KeyedMemberAt {
280
+ #private;
281
+ readonly member: string;
282
+ readonly key: string;
283
+ constructor(binding: Binding, member: string, key: string);
284
+ /** The key's source; `not_ready` before it is held, `released` after. */
285
+ get source(): DeriveSource;
286
+ get value(): JsonValue;
287
+ watch(context: Context): Promise<Watch<JsonValue>>;
288
+ /**
289
+ * Holds the key through `binding` (once), loaded, mapped to an older binding's version (slice 7b §7); nothing once
290
+ * released (a hold that lands then is released).
291
+ */
292
+ pin(binding: Binding, context: Context): Promise<void>;
293
+ /** Releases the pin and drops the source (once). */
294
+ release(): void;
295
+ }
296
+ /**
297
+ * What a keyed member's value is (slice 6a §12): a keyed document handle's slot, or a reference's keyed member
298
+ * (re-exposed); `undefined` for anything else.
299
+ */
300
+ export declare function resolveKeyed(value: unknown): KeyedBinding | undefined;
301
+ /**
302
+ * The watchable Chord follows behind a state member or a derive source (Q14): a source or a constant itself, a
303
+ * singleton handle's slot, a reference member's provider member, a keyed member's pinned key (a key source itself for
304
+ * `handle.at(key)`); `undefined` for anything else, a native watchable included.
305
+ */
306
+ export declare function resolveWatchable(value: unknown): DeriveSource | undefined;
307
+ export {};
308
+ //# sourceMappingURL=reference.d.ts.map