@earendil-works/chord 1.3.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 (841) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +129 -10
  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 +8 -0
  7. package/dist/context/index.d.ts.map +1 -1
  8. package/dist/context/index.js +15 -0
  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 +9 -3
  743. package/dist/output.d.ts.map +1 -1
  744. package/dist/output.js +21 -9
  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 +54 -0
  754. package/dist/sqlite/cloudflare.d.ts.map +1 -0
  755. package/dist/sqlite/cloudflare.js +144 -0
  756. package/dist/sqlite/cloudflare.js.map +1 -0
  757. package/dist/sqlite/database.d.ts +40 -0
  758. package/dist/sqlite/database.d.ts.map +1 -0
  759. package/dist/sqlite/database.js +2 -0
  760. package/dist/sqlite/database.js.map +1 -0
  761. package/dist/sqlite/index.d.ts +4 -0
  762. package/dist/sqlite/index.d.ts.map +1 -0
  763. package/dist/sqlite/index.js +3 -0
  764. package/dist/sqlite/index.js.map +1 -0
  765. package/dist/sqlite/migrations.d.ts +10 -0
  766. package/dist/sqlite/migrations.d.ts.map +1 -0
  767. package/dist/sqlite/migrations.js +33 -0
  768. package/dist/sqlite/migrations.js.map +1 -0
  769. package/dist/sqlite/node.d.ts +41 -0
  770. package/dist/sqlite/node.d.ts.map +1 -0
  771. package/dist/sqlite/node.js +191 -0
  772. package/dist/sqlite/node.js.map +1 -0
  773. package/dist/sqlite/schema.d.ts +3 -0
  774. package/dist/sqlite/schema.d.ts.map +1 -0
  775. package/dist/sqlite/schema.js +10 -0
  776. package/dist/sqlite/schema.js.map +1 -0
  777. package/dist/telemetry-sqlite/index.d.ts +24 -0
  778. package/dist/telemetry-sqlite/index.d.ts.map +1 -0
  779. package/dist/telemetry-sqlite/index.js +273 -0
  780. package/dist/telemetry-sqlite/index.js.map +1 -0
  781. package/dist/telemetry-sqlite/store.d.ts +9 -0
  782. package/dist/telemetry-sqlite/store.d.ts.map +1 -0
  783. package/dist/telemetry-sqlite/store.js +110 -0
  784. package/dist/telemetry-sqlite/store.js.map +1 -0
  785. package/dist/watch.d.ts +194 -0
  786. package/dist/watch.d.ts.map +1 -0
  787. package/dist/watch.js +383 -0
  788. package/dist/watch.js.map +1 -0
  789. package/dist/wire.d.ts +174 -193
  790. package/dist/wire.d.ts.map +1 -1
  791. package/dist/wire.js +81 -80
  792. package/dist/wire.js.map +1 -1
  793. package/docs/guide.md +15 -15
  794. package/docs/next/benchmarks.md +959 -0
  795. package/docs/next/decisions.md +2957 -0
  796. package/docs/next/dependencies/book.md +1671 -0
  797. package/docs/next/dependencies/index.html +2641 -0
  798. package/docs/next/dependencies/model.md +330 -0
  799. package/docs/next/design.md +2554 -0
  800. package/docs/next/durable-observers/book.md +432 -0
  801. package/docs/next/durable-observers/index.html +517 -0
  802. package/docs/next/flow-control/book.md +333 -0
  803. package/docs/next/flow-control/fold/index.html +265 -0
  804. package/docs/next/flow-control/index.html +548 -0
  805. package/docs/next/flow-control/window/index.html +228 -0
  806. package/docs/next/guide-plugins-hosts/book.md +607 -0
  807. package/docs/next/guide-plugins-hosts/index.html +652 -0
  808. package/docs/next/http-workers/book.md +378 -0
  809. package/docs/next/http-workers/index.html +515 -0
  810. package/docs/next/layer-1.md +311 -0
  811. package/docs/next/layer-2.md +216 -0
  812. package/docs/next/plugin-model/book.md +186 -0
  813. package/docs/next/plugin-model/index.html +310 -0
  814. package/docs/next/plugin-primer/book.md +273 -0
  815. package/docs/next/plugin-primer/index.html +430 -0
  816. package/docs/next/slice-1.md +236 -0
  817. package/docs/next/slice-10.md +285 -0
  818. package/docs/next/slice-11.md +93 -0
  819. package/docs/next/slice-2.md +174 -0
  820. package/docs/next/slice-3a.md +296 -0
  821. package/docs/next/slice-3b.md +197 -0
  822. package/docs/next/slice-4.md +146 -0
  823. package/docs/next/slice-4a.md +418 -0
  824. package/docs/next/slice-4b.md +208 -0
  825. package/docs/next/slice-5.md +281 -0
  826. package/docs/next/slice-6a.md +676 -0
  827. package/docs/next/slice-6b.md +332 -0
  828. package/docs/next/slice-7a.md +130 -0
  829. package/docs/next/slice-7b/book.md +608 -0
  830. package/docs/next/slice-7b/index.html +842 -0
  831. package/docs/next/slice-7b.md +255 -0
  832. package/docs/next/slice-7c.md +165 -0
  833. package/docs/next/slice-8.md +194 -0
  834. package/docs/next/slices.md +230 -0
  835. package/docs/next/store/book.md +665 -0
  836. package/docs/next/store/index.html +861 -0
  837. package/docs/next/store/walkthrough.md +193 -0
  838. package/docs/spec.md +9 -9
  839. package/docs/tutorial.md +26 -25
  840. package/package.json +42 -5
  841. package/src/delta/README.md +69 -0
@@ -0,0 +1,66 @@
1
+ // Document handles (slice 6a §1.2): what `self.state` returns, one per attempt and definition, a thin view of its
2
+ // object's slot bound to the attempt's seal token and the definition's version.
3
+ /**
4
+ * A singleton's handle. Reads go to the slot (allowed after the seal); `change` and `retire` take the line under the
5
+ * attempt's token. Exposed as a member or read by a derive, it resolves to the slot itself.
6
+ */
7
+ export class Singleton {
8
+ slot;
9
+ token;
10
+ /** The version of the definition it was declared with: the slot refuses it once its values are newer (R15). */
11
+ version;
12
+ constructor(slot, token, version) {
13
+ this.slot = slot;
14
+ this.token = token;
15
+ this.version = version;
16
+ }
17
+ get value() {
18
+ this.slot.definition.assertVersion(this.version);
19
+ return this.slot.value;
20
+ }
21
+ async watch(context) {
22
+ this.slot.definition.assertVersion(this.version);
23
+ // The slot's values are this handle's documents.
24
+ return this.slot.openWatch(context);
25
+ }
26
+ change(fn, context) {
27
+ return this.slot.owner.tx(async (tx) => fn(await tx.draft(this)), this.token, context);
28
+ }
29
+ retire(context) {
30
+ return this.slot.owner.tx((tx) => tx.retire(this), this.token, context);
31
+ }
32
+ }
33
+ /** A keyed handle: reads go to the slot; `change`, `retire` and cold reads take the line under the attempt's token. */
34
+ export class Keyed {
35
+ slot;
36
+ token;
37
+ /** As `Singleton.version`. */
38
+ version;
39
+ #declarer;
40
+ constructor(slot, token, version, declarer) {
41
+ this.slot = slot;
42
+ this.token = token;
43
+ this.version = version;
44
+ this.#declarer = declarer;
45
+ }
46
+ get(key, context) {
47
+ return this.slot.get(key, this, context);
48
+ }
49
+ keys(context) {
50
+ return this.slot.keys(this, context);
51
+ }
52
+ watch(key, context) {
53
+ return this.slot.watch(key, this, context);
54
+ }
55
+ at(key) {
56
+ // The source's values are this slot's documents.
57
+ return this.#declarer.at(this.slot, key);
58
+ }
59
+ change(key, fn, context) {
60
+ return this.slot.owner.tx(async (tx) => fn(await tx.draft(this, key)), this.token, context);
61
+ }
62
+ retire(key, context) {
63
+ return this.slot.owner.tx((tx) => tx.retire(this, key), this.token, context);
64
+ }
65
+ }
66
+ //# sourceMappingURL=handles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handles.js","sourceRoot":"","sources":["../../../src/next/documents/handles.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,gFAAgF;AAkDhF;;;GAGG;AACH,MAAM,OAAO,SAAS;IACZ,IAAI,CAAgB;IACpB,KAAK,CAAY;IAC1B,+GAA+G;IACtG,OAAO,CAAS;IAEzB,YAAY,IAAmB,EAAE,KAAgB,EAAE,OAAe;QACjE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,IAAI,KAAK;QACR,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAgB;QAC3B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,iDAAiD;QACjD,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAsB,CAAC;IAC1D,CAAC;IAED,MAAM,CAAI,EAAmC,EAAE,OAAgB;QAC9D,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,CAAC,OAAgB;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;CACD;AAQD,uHAAuH;AACvH,MAAM,OAAO,KAAK;IACR,IAAI,CAAY;IAChB,KAAK,CAAY;IAC1B,8BAA8B;IACrB,OAAO,CAAS;IAChB,SAAS,CAAc;IAEhC,YAAY,IAAe,EAAE,KAAgB,EAAE,OAAe,EAAE,QAAqB;QACpF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,OAAgB;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,CAAC,OAAgB;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,OAAgB;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,EAAE,CAAC,GAAW;QACb,iDAAiD;QACjD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAqC,CAAC;IAC9E,CAAC;IAED,MAAM,CAAI,GAAW,EAAE,EAAmC,EAAE,OAAgB;QAC3E,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7F,CAAC;IAED,MAAM,CAAC,GAAW,EAAE,OAAgB;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;CACD","sourcesContent":["// Document handles (slice 6a §1.2): what `self.state` returns, one per attempt and definition, a thin view of its\n// object's slot bound to the attempt's seal token and the definition's version.\n\nimport type { Context } from \"../../context/index.ts\";\nimport type { Draft } from \"../../delta/index.ts\";\nimport type { Watch, Watchable, WatchHandle } from \"../../watch.ts\";\nimport type { JsonObject, StateDefinition } from \"./definition.ts\";\nimport type { SealToken } from \"./fence.ts\";\nimport type { KeyedSlot, KeySource } from \"./keyed-slot.ts\";\nimport type { SingletonSlot } from \"./slot.ts\";\n\n/** A singleton document: a watchable that always has a value (`initial()` until written, and after a retire). */\nexport interface SingletonHandle<T extends JsonObject> extends Watchable<T> {\n\t/** One transaction that drafts this document and passes the draft to `fn`. */\n\tchange<R>(fn: (draft: Draft<T>) => R, context: Context): Promise<R>;\n\t/** One transaction that retires this document: back to `initial()`. */\n\tretire(context: Context): Promise<void>;\n}\n\n/**\n * Keyed documents: many per object, by string key. Not a watchable itself: each key is, through `watch(key)` and\n * `at(key)`; a live collection is a singleton holding it.\n */\nexport interface KeyedHandle<T extends JsonObject> {\n\t/** The document's value, `undefined` when absent (persisted and not in memory: loaded on the object's line). */\n\tget(key: string, context: Context): Promise<T | undefined>;\n\t/** The keys of the present documents, in code point order. */\n\tkeys(context: Context): AsyncIterable<string>;\n\t/**\n\t * A watch of the document at `key`, `undefined` when absent. It follows the address: a retirement is one frame with\n\t * `retired: true` and `initial()`, a later creation a root replacement; it ends with the object.\n\t */\n\twatch(key: string, context: Context): Promise<WatchHandle<T> | undefined>;\n\t/**\n\t * In the factory only: the document at `key` as a watchable (a state member, a derive source, an `on` source),\n\t * `initial()` while absent, loaded before the object goes live and pinned while this attempt lives.\n\t */\n\tat(key: string): Watchable<T>;\n\t/** One transaction that drafts the document at `key` and passes the draft to `fn`. */\n\tchange<R>(key: string, fn: (draft: Draft<T>) => R, context: Context): Promise<R>;\n\t/** One transaction that retires the document at `key` (a no-op when absent). */\n\tretire(key: string, context: Context): Promise<void>;\n}\n\n/** The handle `self.state(definition)` returns. */\nexport type HandleOf<D> = D extends StateDefinition<infer T, infer K, boolean>\n\t? K extends true\n\t\t? KeyedHandle<T>\n\t\t: SingletonHandle<T>\n\t: never;\n\n/**\n * A singleton's handle. Reads go to the slot (allowed after the seal); `change` and `retire` take the line under the\n * attempt's token. Exposed as a member or read by a derive, it resolves to the slot itself.\n */\nexport class Singleton implements SingletonHandle<JsonObject> {\n\treadonly slot: SingletonSlot;\n\treadonly token: SealToken;\n\t/** The version of the definition it was declared with: the slot refuses it once its values are newer (R15). */\n\treadonly version: number;\n\n\tconstructor(slot: SingletonSlot, token: SealToken, version: number) {\n\t\tthis.slot = slot;\n\t\tthis.token = token;\n\t\tthis.version = version;\n\t}\n\n\tget value(): JsonObject {\n\t\tthis.slot.definition.assertVersion(this.version);\n\t\treturn this.slot.value;\n\t}\n\n\tasync watch(context: Context): Promise<Watch<JsonObject>> {\n\t\tthis.slot.definition.assertVersion(this.version);\n\t\t// The slot's values are this handle's documents.\n\t\treturn this.slot.openWatch(context) as Watch<JsonObject>;\n\t}\n\n\tchange<R>(fn: (draft: Draft<JsonObject>) => R, context: Context): Promise<R> {\n\t\treturn this.slot.owner.tx(async (tx) => fn(await tx.draft(this)), this.token, context);\n\t}\n\n\tretire(context: Context): Promise<void> {\n\t\treturn this.slot.owner.tx((tx) => tx.retire(this), this.token, context);\n\t}\n}\n\n/** Who declares an attempt's `at(key)` pins: its factory, which alone may (the attempt). */\nexport interface KeyDeclarer {\n\t/** Pins `key` of `slot` for the attempt and returns its source; throws outside the factory. */\n\tat(slot: KeyedSlot, key: string): KeySource;\n}\n\n/** A keyed handle: reads go to the slot; `change`, `retire` and cold reads take the line under the attempt's token. */\nexport class Keyed implements KeyedHandle<JsonObject> {\n\treadonly slot: KeyedSlot;\n\treadonly token: SealToken;\n\t/** As `Singleton.version`. */\n\treadonly version: number;\n\treadonly #declarer: KeyDeclarer;\n\n\tconstructor(slot: KeyedSlot, token: SealToken, version: number, declarer: KeyDeclarer) {\n\t\tthis.slot = slot;\n\t\tthis.token = token;\n\t\tthis.version = version;\n\t\tthis.#declarer = declarer;\n\t}\n\n\tget(key: string, context: Context): Promise<JsonObject | undefined> {\n\t\treturn this.slot.get(key, this, context);\n\t}\n\n\tkeys(context: Context): AsyncIterable<string> {\n\t\treturn this.slot.keys(this, context);\n\t}\n\n\twatch(key: string, context: Context): Promise<Watch<JsonObject> | undefined> {\n\t\treturn this.slot.watch(key, this, context);\n\t}\n\n\tat(key: string): Watchable<JsonObject> {\n\t\t// The source's values are this slot's documents.\n\t\treturn this.#declarer.at(this.slot, key) as unknown as Watchable<JsonObject>;\n\t}\n\n\tchange<R>(key: string, fn: (draft: Draft<JsonObject>) => R, context: Context): Promise<R> {\n\t\treturn this.slot.owner.tx(async (tx) => fn(await tx.draft(this, key)), this.token, context);\n\t}\n\n\tretire(key: string, context: Context): Promise<void> {\n\t\treturn this.slot.owner.tx((tx) => tx.retire(this, key), this.token, context);\n\t}\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export { type CommitPersistence, defineState, type JsonObject, type StateDefinition } from "./definition.ts";
2
+ export type { HandleOf, KeyedHandle, SingletonHandle } from "./handles.ts";
3
+ export type { Tx } from "./transaction.ts";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/next/documents/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,iBAAiB,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC7G,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3E,YAAY,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Documents for apps: definitions, handles and transactions.
2
+ export { defineState } from "./definition.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/next/documents/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EAA0B,WAAW,EAAyC,MAAM,iBAAiB,CAAC","sourcesContent":["// Documents for apps: definitions, handles and transactions.\n\nexport { type CommitPersistence, defineState, type JsonObject, type StateDefinition } from \"./definition.ts\";\nexport type { HandleOf, KeyedHandle, SingletonHandle } from \"./handles.ts\";\nexport type { Tx } from \"./transaction.ts\";\n"]}
@@ -0,0 +1,9 @@
1
+ export { AddressSource } from "./address-source.ts";
2
+ export { Documents, type DocumentsOwner } from "./documents.ts";
3
+ export { SealToken } from "./fence.ts";
4
+ export { type KeyDeclarer, Keyed, Singleton } from "./handles.ts";
5
+ export { type KeyedSlot, KeySource } from "./keyed-slot.ts";
6
+ export { type DocumentChange, type Held, Persistence, type Stored, type StoredChange, storedAfter, } from "./persistence.ts";
7
+ export { type AnyDefinition, type DocumentSlot, type PersistedSlot, SlotDefinition } from "./slot.ts";
8
+ export type { Staged, Transaction } from "./transaction.ts";
9
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/next/documents/internal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,WAAW,EACX,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,WAAW,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACtG,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,9 @@
1
+ // Documents for Chord's layers: an object's documents and slots, the handles' classes, the seal token, transactions.
2
+ export { AddressSource } from "./address-source.js";
3
+ export { Documents } from "./documents.js";
4
+ export { SealToken } from "./fence.js";
5
+ export { Keyed, Singleton } from "./handles.js";
6
+ export { KeySource } from "./keyed-slot.js";
7
+ export { Persistence, storedAfter, } from "./persistence.js";
8
+ export { SlotDefinition } from "./slot.js";
9
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/next/documents/internal.ts"],"names":[],"mappings":"AAAA,qHAAqH;AAErH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAoB,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAkB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAGN,WAAW,EAGX,WAAW,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA6D,cAAc,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// Documents for Chord's layers: an object's documents and slots, the handles' classes, the seal token, transactions.\n\nexport { AddressSource } from \"./address-source.ts\";\nexport { Documents, type DocumentsOwner } from \"./documents.ts\";\nexport { SealToken } from \"./fence.ts\";\nexport { type KeyDeclarer, Keyed, Singleton } from \"./handles.ts\";\nexport { type KeyedSlot, KeySource } from \"./keyed-slot.ts\";\nexport {\n\ttype DocumentChange,\n\ttype Held,\n\tPersistence,\n\ttype Stored,\n\ttype StoredChange,\n\tstoredAfter,\n} from \"./persistence.ts\";\nexport { type AnyDefinition, type DocumentSlot, type PersistedSlot, SlotDefinition } from \"./slot.ts\";\nexport type { Staged, Transaction } from \"./transaction.ts\";\n"]}
@@ -0,0 +1,103 @@
1
+ import { type Context } from "../../context/index.ts";
2
+ import { type Prepared, type Tracker } from "../../delta/index.ts";
3
+ import type { Watch } from "../../watch.ts";
4
+ import type { StagedWrite } from "../store/step.ts";
5
+ import { AddressSource } from "./address-source.ts";
6
+ import type { JsonObject } from "./definition.ts";
7
+ import type { Documents } from "./documents.ts";
8
+ import type { SealToken } from "./fence.ts";
9
+ import { type DocumentChange, type Persistence, type Stored, type StoredChange } from "./persistence.ts";
10
+ import { Resident } from "./residency.ts";
11
+ import { type AnyDefinition, type DocumentSlot, type PersistedSlot, SlotDefinition } from "./slot.ts";
12
+ /** Whom a read is for: a handle's seal token and the version it was declared with (R15). */
13
+ export type Access = {
14
+ readonly token: SealToken;
15
+ readonly version: number;
16
+ };
17
+ /** A keyed slot: one resident per document in memory, one source per pinned key. */
18
+ export declare class KeyedSlot implements DocumentSlot, PersistedSlot {
19
+ #private;
20
+ readonly owner: Documents;
21
+ readonly definition: SlotDefinition;
22
+ readonly persisted: PersistedSlot | undefined;
23
+ constructor(owner: Documents, definition: AnyDefinition, persistence: Persistence | undefined);
24
+ get persistence(): Persistence;
25
+ /**
26
+ * The value at `key`, `undefined` when absent. A document in memory is read at once (also through a sealed
27
+ * handle); a cold persisted one is loaded on the line (refused `released` once the access's token is sealed), and
28
+ * `context` ends only this caller's wait. An absent key is not cached (rule 20).
29
+ */
30
+ get(raw: string, access: Access, context: Context): Promise<JsonObject | undefined>;
31
+ /** The present keys in code point order: in memory, the residents; persisted, the store's, a page per line job. */
32
+ keys(access: Access, context: Context): AsyncIterable<string>;
33
+ /**
34
+ * A watch of the document at `key`, `undefined` when absent (after a cold load); it follows the address (a
35
+ * retirement is a frame with the `retired` flag) and pins the key until it ends.
36
+ */
37
+ watch(raw: string, access: Access, context: Context): Promise<Watch<JsonObject> | undefined>;
38
+ /**
39
+ * Pins `key`: its source (made by the first pin) and its document stay in memory until the returned release
40
+ * (idempotent) runs; a persisted key not in memory is loaded by the next activation load (`loadDeclared`).
41
+ */
42
+ pin(raw: string, context: Context): () => void;
43
+ /** Loads pinned `key` on the line unless it was loaded since it was pinned (a consumer's `at(key)`, slice 6a §12). */
44
+ ensure(raw: string, context: Context): Promise<void>;
45
+ /** The source of pinned `key`. */
46
+ source(key: string): KeySource;
47
+ /**
48
+ * `key` as the slot and the store keep it: the `str()` text rules (slice 6a §8), a lone surrogate replaced by
49
+ * U+FFFD, NUL refused `invalid/args`. Plugin keys are a trust boundary; every entry point takes them through here,
50
+ * so memory and the store agree on one key.
51
+ */
52
+ key(key: string): string;
53
+ /** Loads every pinned key not loaded since it was pinned (activation, holding the line). */
54
+ loadDeclared(context: Context): Promise<void>;
55
+ /**
56
+ * Loads the document at `key` (the caller holds the line) and installs it while it is still absent from memory (a
57
+ * commit's `adopt` always wins). A stored version newer than the code's, another fingerprint or a failing `migrate`
58
+ * fails the owner (slice 6a §1.4) and rejects with the cause.
59
+ */
60
+ load(key: string, context: Context, token?: SealToken): Promise<void>;
61
+ cold(key: string): boolean;
62
+ stored(key: string): Stored | undefined;
63
+ stage(key: string, change: DocumentChange, was: Stored | undefined, writes: StagedWrite[]): StoredChange;
64
+ /**
65
+ * Takes the attempt's declaration: a newer version migrates each document in memory on its next access (persisted
66
+ * ones store a base with their next change); the pinned keys are watched, so they migrate now, all or none, and
67
+ * take `initial()` again.
68
+ */
69
+ hydrate(definition: AnyDefinition, context: Context): void;
70
+ current(key: string): Tracker<JsonObject> | undefined;
71
+ /** The value a draft of an absent document starts from: a fresh `initial()`. */
72
+ initial(context: Context): JsonObject;
73
+ adopt(key: string, tracker: Tracker<JsonObject>, prepared: Prepared<JsonObject>, change: StoredChange | undefined): void;
74
+ /** Retires the document at `key` (inside the batch): out of memory, its source reads `initial()` with the flag. */
75
+ retire(key: string): void;
76
+ /** The sweep found `resident` idle past the retention: it leaves memory. */
77
+ evict(resident: Resident): void;
78
+ /** Its object ended or no attempt declares it any more: the documents go and the keys' watches end. */
79
+ drop(): void;
80
+ }
81
+ /**
82
+ * One pinned key of a keyed slot as a source (`handle.at(key)`, a keyed member's `at(key)`, `watch(key)`): the
83
+ * document's value, `initial()` while it is absent; retirements arrive with the `retired` flag.
84
+ */
85
+ export declare class KeySource extends AddressSource {
86
+ #private;
87
+ readonly key: string;
88
+ /** Its pins: at 0 the slot forgets it. */
89
+ pins: number;
90
+ /** Whether the key was loaded since it was pinned (always, in memory): its value is known. */
91
+ ready: boolean;
92
+ constructor(slot: KeyedSlot, key: string, initial: JsonObject, ready: boolean);
93
+ get value(): JsonObject;
94
+ /** The value without the checks (inside its slot's commits). */
95
+ peek(): JsonObject;
96
+ /** The document was retired: `initial()` from now, with the flag. */
97
+ retire(): void;
98
+ /** A new definition took over (inside a batch): `initial()` again, the value as a root replacement. */
99
+ retake(initial: JsonObject): void;
100
+ /** Its slot was dropped: the watches end. */
101
+ end(): void;
102
+ }
103
+ //# sourceMappingURL=keyed-slot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed-slot.d.ts","sourceRoot":"","sources":["../../../src/next/documents/keyed-slot.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,395 @@
1
+ // Keyed slots (slice 6a §1.2, §4, §10, §11): the documents of one keyed name on one object, by key. In memory, every
2
+ // present document stays; persisted, a document is loaded on demand (a cold read is a job on the object's line, one
3
+ // load in flight per key, shared) and leaves memory when unpinned and idle for the retention (`residency.ts`). A key
4
+ // read through `at(key)` or a watch has its own source, which exists while the key is pinned.
5
+ import { awaitWithContext } from "../../context/index.js";
6
+ import { track } from "../../delta/index.js";
7
+ import { ChordError } from "../data/index.js";
8
+ import { asChordError } from "../data/internal.js";
9
+ import { compareText, storedText } from "../store/text.js";
10
+ import { AddressSource } from "./address-source.js";
11
+ import { storedAfter, } from "./persistence.js";
12
+ import { Resident } from "./residency.js";
13
+ import { SlotDefinition } from "./slot.js";
14
+ /** The keys `keys(ctx)` reads per page from the store. */
15
+ const KEYS_PAGE = 100;
16
+ /** A keyed slot: one resident per document in memory, one source per pinned key. */
17
+ export class KeyedSlot {
18
+ owner;
19
+ definition;
20
+ persisted;
21
+ #persistence;
22
+ #residents = new Map();
23
+ /** The sources of pinned keys: a key is pinned while it has one. */
24
+ #sources = new Map();
25
+ /** Cold loads in flight, by key: shared by every reader of the key. */
26
+ #loads = new Map();
27
+ /** Names a refused key (the slot's name is the same at every version): made once, not per key check. */
28
+ #keyWhat;
29
+ constructor(owner, definition, persistence) {
30
+ this.owner = owner;
31
+ this.definition = new SlotDefinition(definition);
32
+ this.#keyWhat = `${definition.name}: key`;
33
+ this.#persistence = persistence;
34
+ this.persisted = persistence === undefined ? undefined : this;
35
+ }
36
+ get persistence() {
37
+ // Only reached through `persisted`, which a persisted slot alone has.
38
+ return this.#persistence;
39
+ }
40
+ /**
41
+ * The value at `key`, `undefined` when absent. A document in memory is read at once (also through a sealed
42
+ * handle); a cold persisted one is loaded on the line (refused `released` once the access's token is sealed), and
43
+ * `context` ends only this caller's wait. An absent key is not cached (rule 20).
44
+ */
45
+ get(raw, access, context) {
46
+ // Not `async`: `#get` is the one async layer; a refused key still reaches the caller as a rejection.
47
+ try {
48
+ return this.#get(this.key(raw), access, context);
49
+ }
50
+ catch (error) {
51
+ return Promise.reject(error);
52
+ }
53
+ }
54
+ /** `get` of a key that went through `key` already. */
55
+ async #get(key, access, context) {
56
+ this.owner.assertLive();
57
+ this.definition.assertVersion(access.version);
58
+ const resident = this.#resident(key);
59
+ if (resident !== undefined) {
60
+ this.#touch(resident);
61
+ return resident.tracker.value;
62
+ }
63
+ if (this.#persistence === undefined)
64
+ return undefined;
65
+ await this.#loadShared(key, access.token, context);
66
+ return this.#residents.get(key)?.tracker.value;
67
+ }
68
+ /** The present keys in code point order: in memory, the residents; persisted, the store's, a page per line job. */
69
+ async *keys(access, context) {
70
+ this.owner.assertLive();
71
+ this.definition.assertVersion(access.version);
72
+ const persistence = this.#persistence;
73
+ if (persistence === undefined) {
74
+ yield* [...this.#residents.keys()].sort(compareText);
75
+ return;
76
+ }
77
+ let after;
78
+ for (;;) {
79
+ const page = await this.owner.onLine(() => persistence.keys(after, KEYS_PAGE, context), access.token);
80
+ yield* page;
81
+ if (page.length < KEYS_PAGE)
82
+ return;
83
+ after = page.at(-1);
84
+ }
85
+ }
86
+ /**
87
+ * A watch of the document at `key`, `undefined` when absent (after a cold load); it follows the address (a
88
+ * retirement is a frame with the `retired` flag) and pins the key until it ends.
89
+ */
90
+ async watch(raw, access, context) {
91
+ const key = this.key(raw);
92
+ if ((await this.#get(key, access, context)) === undefined)
93
+ return undefined;
94
+ const release = this.pin(key, context);
95
+ // Retired between the load and now: absent.
96
+ if (!this.#residents.has(key)) {
97
+ release();
98
+ return undefined;
99
+ }
100
+ let watch;
101
+ try {
102
+ // The source's values are this slot's documents.
103
+ watch = this.#sources.get(key).openWatch(context);
104
+ }
105
+ catch (error) {
106
+ release();
107
+ throw error;
108
+ }
109
+ void watch.closed.then(release);
110
+ return watch;
111
+ }
112
+ /**
113
+ * Pins `key`: its source (made by the first pin) and its document stay in memory until the returned release
114
+ * (idempotent) runs; a persisted key not in memory is loaded by the next activation load (`loadDeclared`).
115
+ */
116
+ pin(raw, context) {
117
+ const key = this.key(raw);
118
+ let source = this.#sources.get(key);
119
+ if (source === undefined) {
120
+ const ready = this.#persistence === undefined || this.#residents.has(key);
121
+ source = new KeySource(this, key, this.definition.current.initial(context), ready);
122
+ this.#sources.set(key, source);
123
+ }
124
+ source.pins++;
125
+ const resident = this.#residents.get(key);
126
+ if (resident !== undefined)
127
+ this.owner.residency.forget(resident);
128
+ const pinned = source;
129
+ let released = false;
130
+ return () => {
131
+ if (released)
132
+ return;
133
+ released = true;
134
+ if (--pinned.pins > 0 || this.#sources.get(key) !== pinned)
135
+ return;
136
+ this.#sources.delete(key);
137
+ const idle = this.#residents.get(key);
138
+ if (idle !== undefined)
139
+ this.#touch(idle);
140
+ };
141
+ }
142
+ /** Loads pinned `key` on the line unless it was loaded since it was pinned (a consumer's `at(key)`, slice 6a §12). */
143
+ async ensure(raw, context) {
144
+ const key = this.key(raw);
145
+ if (this.#sources.get(key)?.ready !== false)
146
+ return;
147
+ await this.owner.onLine(() => this.load(key, context));
148
+ }
149
+ /** The source of pinned `key`. */
150
+ source(key) {
151
+ return this.#sources.get(this.key(key));
152
+ }
153
+ /**
154
+ * `key` as the slot and the store keep it: the `str()` text rules (slice 6a §8), a lone surrogate replaced by
155
+ * U+FFFD, NUL refused `invalid/args`. Plugin keys are a trust boundary; every entry point takes them through here,
156
+ * so memory and the store agree on one key.
157
+ */
158
+ key(key) {
159
+ return storedText(key, this.#keyWhat);
160
+ }
161
+ /** Loads every pinned key not loaded since it was pinned (activation, holding the line). */
162
+ async loadDeclared(context) {
163
+ for (const [key, source] of this.#sources)
164
+ if (!source.ready)
165
+ await this.load(key, context);
166
+ }
167
+ /**
168
+ * Loads the document at `key` (the caller holds the line) and installs it while it is still absent from memory (a
169
+ * commit's `adopt` always wins). A stored version newer than the code's, another fingerprint or a failing `migrate`
170
+ * fails the owner (slice 6a §1.4) and rejects with the cause.
171
+ */
172
+ async load(key, context, token) {
173
+ if (this.#residents.has(key))
174
+ return;
175
+ // A store error rejects as the store's (`storage_failed`, `aborted`).
176
+ const document = await this.persistence.read(key, context);
177
+ // The transaction was cut meanwhile: what it read may be stale already.
178
+ if (token?.sealed === true)
179
+ return;
180
+ let loaded;
181
+ try {
182
+ loaded =
183
+ document === undefined ? undefined : this.persistence.decode(document, this.definition.current, context);
184
+ }
185
+ catch (error) {
186
+ // What the code cannot read (a failing `migrate`, whatever it throws) fails the owner.
187
+ const failure = asChordError(error, this.owner.label);
188
+ this.owner.fail(failure);
189
+ throw failure;
190
+ }
191
+ if (loaded !== undefined && !this.#residents.has(key)) {
192
+ const resident = new Resident(this, key, track(loaded.value), loaded.stored, this.definition.current.version);
193
+ this.#residents.set(key, resident);
194
+ this.#touch(resident);
195
+ }
196
+ const source = this.#sources.get(key);
197
+ if (source !== undefined)
198
+ source.ready = true;
199
+ }
200
+ cold(key) {
201
+ return this.#persistence !== undefined && !this.#residents.has(key);
202
+ }
203
+ stored(key) {
204
+ return this.#residents.get(key)?.stored;
205
+ }
206
+ stage(key, change, was, writes) {
207
+ return this.persistence.stage(key, this.definition.current, was, change, writes);
208
+ }
209
+ /**
210
+ * Takes the attempt's declaration: a newer version migrates each document in memory on its next access (persisted
211
+ * ones store a base with their next change); the pinned keys are watched, so they migrate now, all or none, and
212
+ * take `initial()` again.
213
+ */
214
+ hydrate(definition, context) {
215
+ const from = this.definition.hydrated;
216
+ this.definition.hydrate(definition);
217
+ if (from === undefined || from.version === definition.version)
218
+ return;
219
+ const pinned = [...this.#sources.keys()].flatMap((key) => this.#residents.get(key) ?? []);
220
+ const migrated = pinned.map((resident) => [resident, this.#migrated(resident, context)]);
221
+ for (const [resident, tracker] of migrated) {
222
+ resident.tracker = tracker;
223
+ resident.version = definition.version;
224
+ }
225
+ this.owner.batch.commit(() => {
226
+ for (const source of this.#sources.values())
227
+ source.retake(definition.initial(context));
228
+ }, context);
229
+ }
230
+ current(key) {
231
+ return this.#resident(key)?.tracker;
232
+ }
233
+ /** The value a draft of an absent document starts from: a fresh `initial()`. */
234
+ initial(context) {
235
+ return this.definition.current.initial(context);
236
+ }
237
+ adopt(key, tracker, prepared, change) {
238
+ const stored = change === undefined ? undefined : storedAfter(change);
239
+ const source = this.#sources.get(key);
240
+ const before = source?.peek();
241
+ tracker.adopt(prepared);
242
+ let resident = this.#residents.get(key);
243
+ const { version } = this.definition.current;
244
+ if (resident === undefined) {
245
+ resident = new Resident(this, key, tracker, stored, version);
246
+ this.#residents.set(key, resident);
247
+ }
248
+ else {
249
+ resident.tracker = tracker;
250
+ resident.stored = stored;
251
+ resident.version = version;
252
+ }
253
+ if (source === undefined)
254
+ this.#touch(resident);
255
+ else
256
+ source.written(before, prepared);
257
+ }
258
+ /** Retires the document at `key` (inside the batch): out of memory, its source reads `initial()` with the flag. */
259
+ retire(key) {
260
+ const resident = this.#residents.get(key);
261
+ if (resident !== undefined) {
262
+ this.#residents.delete(key);
263
+ this.owner.residency.forget(resident);
264
+ }
265
+ this.#sources.get(key)?.retire();
266
+ }
267
+ /** The sweep found `resident` idle past the retention: it leaves memory. */
268
+ evict(resident) {
269
+ if (this.#residents.get(resident.key) === resident)
270
+ this.#residents.delete(resident.key);
271
+ }
272
+ /** Its object ended or no attempt declares it any more: the documents go and the keys' watches end. */
273
+ drop() {
274
+ for (const resident of this.#residents.values())
275
+ this.owner.residency.forget(resident);
276
+ this.#residents.clear();
277
+ for (const source of this.#sources.values())
278
+ source.end();
279
+ this.#sources.clear();
280
+ }
281
+ /**
282
+ * A cold persisted key's load, one in flight per key, on the line under the owner's context (rule 11). The load is
283
+ * every waiter's: when it takes the line, a waiter whose handle was sealed meanwhile (its attempt failed live, the
284
+ * object still open) is refused `released`, and with no other waiter the load does not run (rule 4).
285
+ */
286
+ async #loadShared(key, token, context) {
287
+ // Also when a load is in flight: a sealed handle's cold read is refused (rule 4).
288
+ this.owner.assertAdmitted(token);
289
+ let load = this.#loads.get(key);
290
+ if (load === undefined)
291
+ load = this.#startLoad(key);
292
+ load.tokens.add(token);
293
+ await awaitWithContext(load.done, context);
294
+ if (load.refused?.has(token))
295
+ throw this.owner.released();
296
+ }
297
+ /** Starts the shared load of `key`; it leaves `#loads` when it settles. */
298
+ #startLoad(key) {
299
+ const tokens = new Set();
300
+ const load = {
301
+ tokens,
302
+ refused: undefined,
303
+ // The job runs once the line is taken, after `load` is assigned.
304
+ done: this.owner.onLine(async () => {
305
+ const refused = new Set([...tokens].filter(({ sealed }) => sealed));
306
+ load.refused = refused;
307
+ if (refused.size === tokens.size)
308
+ throw this.owner.released();
309
+ await this.load(key, this.owner.context);
310
+ }),
311
+ };
312
+ this.#loads.set(key, load);
313
+ const settled = () => {
314
+ this.#loads.delete(key);
315
+ };
316
+ load.done.then(settled, settled);
317
+ return load;
318
+ }
319
+ /** The resident at `key`, migrated to the slot's version first when it is older (migration on access). */
320
+ #resident(key) {
321
+ const resident = this.#residents.get(key);
322
+ if (resident === undefined || resident.version === this.definition.current.version)
323
+ return resident;
324
+ const tracker = this.#migrated(resident, this.owner.context);
325
+ resident.tracker = tracker;
326
+ resident.version = this.definition.current.version;
327
+ return resident;
328
+ }
329
+ /**
330
+ * `resident`'s value migrated from its version to the slot's (checked, R8). A throwing `migrate` fails the live
331
+ * owner `broken` (slice 6a §1.4) and throws the failure (an activation fails with it).
332
+ */
333
+ #migrated(resident, context) {
334
+ try {
335
+ return track(this.definition.current.migrate(resident.tracker.value, resident.version, context));
336
+ }
337
+ catch (error) {
338
+ const failure = asChordError(error, this.owner.label);
339
+ this.owner.fail(failure);
340
+ throw failure;
341
+ }
342
+ }
343
+ /** A use of `resident` while unpinned: persisted, it is idle from now (Durable's granule rule). */
344
+ #touch(resident) {
345
+ if (this.#persistence !== undefined && !this.#sources.has(resident.key))
346
+ this.owner.residency.touch(resident);
347
+ }
348
+ }
349
+ /**
350
+ * One pinned key of a keyed slot as a source (`handle.at(key)`, a keyed member's `at(key)`, `watch(key)`): the
351
+ * document's value, `initial()` while it is absent; retirements arrive with the `retired` flag.
352
+ */
353
+ export class KeySource extends AddressSource {
354
+ #slot;
355
+ key;
356
+ /** Its pins: at 0 the slot forgets it. */
357
+ pins = 0;
358
+ /** Whether the key was loaded since it was pinned (always, in memory): its value is known. */
359
+ ready;
360
+ #initial;
361
+ constructor(slot, key, initial, ready) {
362
+ super(slot.owner.batch);
363
+ this.#slot = slot;
364
+ this.key = key;
365
+ this.#initial = initial;
366
+ this.ready = ready;
367
+ }
368
+ get value() {
369
+ this.#slot.owner.assertLive();
370
+ if (!this.ready) {
371
+ const message = `${this.#slot.definition.current.name}(${this.key}): read before it was loaded`;
372
+ throw new ChordError({ code: "not_ready", message });
373
+ }
374
+ return this.peek();
375
+ }
376
+ /** The value without the checks (inside its slot's commits). */
377
+ peek() {
378
+ return this.#slot.current(this.key)?.value ?? this.#initial;
379
+ }
380
+ /** The document was retired: `initial()` from now, with the flag. */
381
+ retire() {
382
+ this.retired(this.#initial);
383
+ }
384
+ /** A new definition took over (inside a batch): `initial()` again, the value as a root replacement. */
385
+ retake(initial) {
386
+ this.#initial = initial;
387
+ if (this.ready)
388
+ this.replaced();
389
+ }
390
+ /** Its slot was dropped: the watches end. */
391
+ end() {
392
+ this.endWatches();
393
+ }
394
+ }
395
+ //# sourceMappingURL=keyed-slot.js.map