@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,65 @@
1
+ import { ChordError, type FailureCause } from "../data/index.ts";
2
+ import type { RegistryValueSource } from "../registries/internal.ts";
3
+ import type { ChordObject } from "./object.ts";
4
+ import { type Failed, type RefState } from "./ref-state.ts";
5
+ import type { Binding } from "./reference.ts";
6
+ /** One declared dependency: a reference (`self.get`) or a registry's value (`self.registry`). */
7
+ export type Dependency = {
8
+ readonly kind: "reference";
9
+ readonly binding: Binding;
10
+ } | {
11
+ readonly kind: "registry";
12
+ readonly value: RegistryValueSource;
13
+ };
14
+ /** A blocker as `parked_long` names it: a reference's label or `registry <name>`, and whether it loads or failed. */
15
+ export type Blocker = {
16
+ readonly label: string;
17
+ readonly state: "loading" | "failed";
18
+ };
19
+ /**
20
+ * What the dependencies say. `live`: every one is live (hydrated: a reference's members have values). `parked`: what
21
+ * the attempt shows (`loading`, or `failed { waiting }` naming its first failed blocker), whether its first pass is
22
+ * over (`firstPass`: no blocker, loading or failed, is an object here still without its first outcome), and its first
23
+ * blocker in declaration order (`parked_long` names it). `broken`: one failed for a cycle (`invalid/cycle`), for
24
+ * authority (`forbidden`) or ended: it never comes back by itself.
25
+ */
26
+ export type Check = {
27
+ readonly kind: "live";
28
+ } | {
29
+ readonly kind: "parked";
30
+ readonly shown: RefState;
31
+ readonly firstPass: boolean;
32
+ readonly blocker: Blocker;
33
+ /** The first blocker in declaration order that is only loading (a reload's report names it). */
34
+ readonly loadingOn: string | undefined;
35
+ } | {
36
+ readonly kind: "broken";
37
+ readonly error: ChordError;
38
+ };
39
+ /** Checks `dependencies` in declaration order (the first failed one is the one the attempt names). */
40
+ export declare function checkDependencies(dependencies: readonly Dependency[]): Check;
41
+ /**
42
+ * What a reload reports for a parked attempt (slice 7b §4): its failure's cause, or for a blocker that is only
43
+ * loading a `waiting` cause naming it.
44
+ */
45
+ export declare function parkedCause(check: Extract<Check, {
46
+ readonly kind: "parked";
47
+ }>): FailureCause;
48
+ /** A parked attempt's state for a blocker `label` that failed with `error`. */
49
+ export declare function waitingOn(label: string, error: ChordError): Failed;
50
+ /**
51
+ * The `parked_long` report of one parking episode (dependency model §7, audit A11): once, when the attempt has been
52
+ * parked longer than `readyTimeout`, whatever its blocker (a ring across hosts started at the same moment stays parked
53
+ * so, and so does a long wait; nothing fails or retries). The clock and the report's `since` start when the episode
54
+ * does (its pinned keys' loading included); the report names the blocker of the latest check. Its one timer runs until
55
+ * the report or the episode's end (`stop`).
56
+ */
57
+ export declare class ParkedLong {
58
+ #private;
59
+ constructor(object: ChordObject);
60
+ /** What the latest check found blocking. */
61
+ blockedBy(blocker: Blocker): void;
62
+ /** The episode ended: no report from now on. */
63
+ stop(): void;
64
+ }
65
+ //# sourceMappingURL=dependencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../src/next/host/dependencies.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAgB,MAAM,kBAAkB,CAAC;AAE/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,MAAM,EAAW,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,iGAAiG;AACjG,MAAM,MAAM,UAAU,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;C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D;IAChD,IAAI,IAAI,IAAI,CAEX;CACD"}
@@ -0,0 +1,115 @@
1
+ // Parked attempts (dependency model §3, §7): the dependency check, what an attempt's declared dependencies (`self.get`
2
+ // references and `self.registry` values) say at one moment: all live, or what the parked attempt shows while one is not
3
+ // (`loading`, `failed { waiting }` naming the nearest blocker and the root cause, or `broken` for a cycle, authority or
4
+ // an ended dependency), whether this host's first pass can count it (no blocker here still without its first outcome,
5
+ // decision (a)), and its first blocker; and the `parked_long` report of a long parking episode.
6
+ import { ChordError, isChordError } from "../data/index.js";
7
+ import { asChordError, waitingFor } from "../data/internal.js";
8
+ import { LOADING } from "./ref-state.js";
9
+ const LIVE = { kind: "live" };
10
+ /** Checks `dependencies` in declaration order (the first failed one is the one the attempt names). */
11
+ export function checkDependencies(dependencies) {
12
+ let failed;
13
+ let firstPass = true;
14
+ let blocker;
15
+ let loadingOn;
16
+ for (const dependency of dependencies) {
17
+ if (dependency.kind === "registry") {
18
+ const { value } = dependency;
19
+ const start = value.start();
20
+ if (start.kind === "value" || start.last !== undefined)
21
+ continue;
22
+ const label = `registry ${value.name}`;
23
+ failed ??= waitingOn(label, asChordError(start.error, label));
24
+ blocker ??= { label, state: "failed" };
25
+ continue;
26
+ }
27
+ const { binding } = dependency;
28
+ const state = binding.refState;
29
+ switch (state.kind) {
30
+ case "live":
31
+ continue;
32
+ case "ended":
33
+ return { kind: "broken", error: state.error };
34
+ case "failed": {
35
+ const { error } = state.cause;
36
+ if (healsNever(error))
37
+ return { kind: "broken", error };
38
+ failed ??= waitingOn(binding.label, error);
39
+ blocker ??= { label: binding.label, state: "failed" };
40
+ // Parked `waiting` on something here still in its first attempt: no first outcome yet (fix round 1).
41
+ if (binding.target?.blocksFirstPass === true)
42
+ firstPass = false;
43
+ continue;
44
+ }
45
+ case "loading":
46
+ loadingOn ??= binding.label;
47
+ blocker ??= { label: binding.label, state: "loading" };
48
+ if (binding.target?.blocksFirstPass === true)
49
+ firstPass = false;
50
+ }
51
+ }
52
+ if (blocker === undefined)
53
+ return LIVE;
54
+ return { kind: "parked", shown: failed ?? LOADING, firstPass, blocker, loadingOn };
55
+ }
56
+ /**
57
+ * Whether a dependency failed with `error` never heals by itself, so its dependent breaks too: a cycle
58
+ * (`invalid/cycle`: it would wait on a ring) or authority (`forbidden`: an `authorize` that refused, M§3.6; only
59
+ * `retry()` or a reload helps).
60
+ */
61
+ function healsNever(error) {
62
+ return (isChordError(error, "invalid") && error.reason === "cycle") || isChordError(error, "forbidden");
63
+ }
64
+ /**
65
+ * What a reload reports for a parked attempt (slice 7b §4): its failure's cause, or for a blocker that is only
66
+ * loading a `waiting` cause naming it.
67
+ */
68
+ export function parkedCause(check) {
69
+ const { shown } = check;
70
+ if (shown.kind === "failed")
71
+ return shown.cause;
72
+ const label = check.loadingOn ?? "a dependency";
73
+ return waitingFor(label, new ChordError({ code: "unavailable", message: `${label} is loading` }));
74
+ }
75
+ /** A parked attempt's state for a blocker `label` that failed with `error`. */
76
+ export function waitingOn(label, error) {
77
+ return { kind: "failed", cause: waitingFor(label, error), retryAt: undefined };
78
+ }
79
+ /**
80
+ * The `parked_long` report of one parking episode (dependency model §7, audit A11): once, when the attempt has been
81
+ * parked longer than `readyTimeout`, whatever its blocker (a ring across hosts started at the same moment stays parked
82
+ * so, and so does a long wait; nothing fails or retries). The clock and the report's `since` start when the episode
83
+ * does (its pinned keys' loading included); the report names the blocker of the latest check. Its one timer runs until
84
+ * the report or the episode's end (`stop`).
85
+ */
86
+ export class ParkedLong {
87
+ #since = Date.now();
88
+ #timer;
89
+ /** The blocker the latest check found. */
90
+ #blocker;
91
+ constructor(object) {
92
+ this.#timer = setTimeout(() => {
93
+ const blocker = this.#blocker;
94
+ if (blocker === undefined)
95
+ return;
96
+ const { label, state } = blocker;
97
+ object.host.report({
98
+ kind: "parked_long",
99
+ object: object.label,
100
+ waitingFor: label,
101
+ state,
102
+ since: this.#since,
103
+ });
104
+ }, object.host.timeouts.ready);
105
+ }
106
+ /** What the latest check found blocking. */
107
+ blockedBy(blocker) {
108
+ this.#blocker = blocker;
109
+ }
110
+ /** The episode ended: no report from now on. */
111
+ stop() {
112
+ clearTimeout(this.#timer);
113
+ }
114
+ }
115
+ //# sourceMappingURL=dependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../src/next/host/dependencies.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,wHAAwH;AACxH,wHAAwH;AACxH,sHAAsH;AACtH,gGAAgG;AAEhG,OAAO,EAAE,UAAU,EAAqB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG/D,OAAO,EAAe,OAAO,EAAiB,MAAM,gBAAgB,CAAC;AA8BrE,MAAM,IAAI,GAAU,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAErC,sGAAsG;AACtG,MAAM,UAAU,iBAAiB,CAAC,YAAmC;IACpE,IAAI,MAA0B,CAAC;IAC/B,IAAI,SAAS,GAAG,IAAI,CAAC;IACrB,IAAI,OAA4B,CAAC;IACjC,IAAI,SAA6B,CAAC;IAClC,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;QACvC,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACpC,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;YAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;YAC5B,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;gBAAE,SAAS;YACjE,MAAM,KAAK,GAAG,YAAY,KAAK,CAAC,IAAI,EAAE,CAAC;YACvC,MAAM,KAAK,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;YAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE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AClB,IAAI,EAAE,aAAa;gBACnB,MAAM,EAAE,MAAM,CAAC,KAAK;gBACpB,UAAU,EAAE,KAAK;gBACjB,KAAK;gBACL,KAAK,EAAE,IAAI,CAAC,MAAM;aAClB,CAAC,CAAC;QACJ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,4CAA4C;IAC5C,SAAS,CAAC,OAAgB;QACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,gDAAgD;IAChD,IAAI;QACH,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;CACD","sourcesContent":["// Parked attempts (dependency model §3, §7): the dependency check, what an attempt's declared dependencies (`self.get`\n// references and `self.registry` values) say at one moment: all live, or what the parked attempt shows while one is not\n// (`loading`, `failed { waiting }` naming the nearest blocker and the root cause, or `broken` for a cycle, authority or\n// an ended dependency), whether this host's first pass can count it (no blocker here still without its first outcome,\n// decision (a)), and its first blocker; and the `parked_long` report of a long parking episode.\n\nimport { ChordError, type FailureCause, isChordError } from \"../data/index.ts\";\nimport { asChordError, waitingFor } from \"../data/internal.ts\";\nimport type { RegistryValueSource } from \"../registries/internal.ts\";\nimport type { ChordObject } from \"./object.ts\";\nimport { type Failed, LOADING, type RefState } from \"./ref-state.ts\";\nimport type { Binding } from \"./reference.ts\";\n\n/** One declared dependency: a reference (`self.get`) or a registry's value (`self.registry`). */\nexport type Dependency =\n\t| { readonly kind: \"reference\"; readonly binding: Binding }\n\t| { readonly kind: \"registry\"; readonly value: RegistryValueSource };\n\n/** A blocker as `parked_long` names it: a reference's label or `registry <name>`, and whether it loads or failed. */\nexport type Blocker = { readonly label: string; readonly state: \"loading\" | \"failed\" };\n\n/**\n * What the dependencies say. `live`: every one is live (hydrated: a reference's members have values). `parked`: what\n * the attempt shows (`loading`, or `failed { waiting }` naming its first failed blocker), whether its first pass is\n * over (`firstPass`: no blocker, loading or failed, is an object here still without its first outcome), and its first\n * blocker in declaration order (`parked_long` names it). `broken`: one failed for a cycle (`invalid/cycle`), for\n * authority (`forbidden`) or ended: it never comes back by itself.\n */\nexport type Check =\n\t| { readonly kind: \"live\" }\n\t| {\n\t\t\treadonly kind: \"parked\";\n\t\t\treadonly shown: RefState;\n\t\t\treadonly firstPass: boolean;\n\t\t\treadonly blocker: Blocker;\n\t\t\t/** The first blocker in declaration order that is only loading (a reload's report names it). */\n\t\t\treadonly loadingOn: string | undefined;\n\t }\n\t| { readonly kind: \"broken\"; readonly error: ChordError };\n\nconst LIVE: Check = { kind: \"live\" };\n\n/** Checks `dependencies` in declaration order (the first failed one is the one the attempt names). */\nexport function checkDependencies(dependencies: readonly Dependency[]): Check {\n\tlet failed: Failed | undefined;\n\tlet firstPass = true;\n\tlet blocker: Blocker | undefined;\n\tlet loadingOn: string | undefined;\n\tfor (const dependency of dependencies) {\n\t\tif (dependency.kind === \"registry\") {\n\t\t\tconst { value } = dependency;\n\t\t\tconst start = value.start();\n\t\t\tif (start.kind === \"value\" || start.last !== undefined) continue;\n\t\t\tconst label = `registry ${value.name}`;\n\t\t\tfailed ??= waitingOn(label, asChordError(start.error, label));\n\t\t\tblocker ??= { label, state: \"failed\" };\n\t\t\tcontinue;\n\t\t}\n\t\tconst { binding } = dependency;\n\t\tconst state = binding.refState;\n\t\tswitch (state.kind) {\n\t\t\tcase \"live\":\n\t\t\t\tcontinue;\n\t\t\tcase \"ended\":\n\t\t\t\treturn { kind: \"broken\", error: state.error };\n\t\t\tcase \"failed\": {\n\t\t\t\tconst { error } = state.cause;\n\t\t\t\tif (healsNever(error)) return { kind: \"broken\", error };\n\t\t\t\tfailed ??= waitingOn(binding.label, error);\n\t\t\t\tblocker ??= { label: binding.label, state: \"failed\" };\n\t\t\t\t// Parked `waiting` on something here still in its first attempt: no first outcome yet (fix round 1).\n\t\t\t\tif (binding.target?.blocksFirstPass === true) firstPass = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcase \"loading\":\n\t\t\t\tloadingOn ??= binding.label;\n\t\t\t\tblocker ??= { label: binding.label, state: \"loading\" };\n\t\t\t\tif (binding.target?.blocksFirstPass === true) firstPass = false;\n\t\t}\n\t}\n\tif (blocker === undefined) return LIVE;\n\treturn { kind: \"parked\", shown: failed ?? LOADING, firstPass, blocker, loadingOn };\n}\n\n/**\n * Whether a dependency failed with `error` never heals by itself, so its dependent breaks too: a cycle\n * (`invalid/cycle`: it would wait on a ring) or authority (`forbidden`: an `authorize` that refused, M§3.6; only\n * `retry()` or a reload helps).\n */\nfunction healsNever(error: ChordError): boolean {\n\treturn (isChordError(error, \"invalid\") && error.reason === \"cycle\") || isChordError(error, \"forbidden\");\n}\n\n/**\n * What a reload reports for a parked attempt (slice 7b §4): its failure's cause, or for a blocker that is only\n * loading a `waiting` cause naming it.\n */\nexport function parkedCause(check: Extract<Check, { readonly kind: \"parked\" }>): FailureCause {\n\tconst { shown } = check;\n\tif (shown.kind === \"failed\") return shown.cause;\n\tconst label = check.loadingOn ?? \"a dependency\";\n\treturn waitingFor(label, new ChordError({ code: \"unavailable\", message: `${label} is loading` }));\n}\n\n/** A parked attempt's state for a blocker `label` that failed with `error`. */\nexport function waitingOn(label: string, error: ChordError): Failed {\n\treturn { kind: \"failed\", cause: waitingFor(label, error), retryAt: undefined };\n}\n\n/**\n * The `parked_long` report of one parking episode (dependency model §7, audit A11): once, when the attempt has been\n * parked longer than `readyTimeout`, whatever its blocker (a ring across hosts started at the same moment stays parked\n * so, and so does a long wait; nothing fails or retries). The clock and the report's `since` start when the episode\n * does (its pinned keys' loading included); the report names the blocker of the latest check. Its one timer runs until\n * the report or the episode's end (`stop`).\n */\nexport class ParkedLong {\n\treadonly #since = Date.now();\n\treadonly #timer: ReturnType<typeof setTimeout>;\n\t/** The blocker the latest check found. */\n\t#blocker: Blocker | undefined;\n\n\tconstructor(object: ChordObject) {\n\t\tthis.#timer = setTimeout(() => {\n\t\t\tconst blocker = this.#blocker;\n\t\t\tif (blocker === undefined) return;\n\t\t\tconst { label, state } = blocker;\n\t\t\tobject.host.report({\n\t\t\t\tkind: \"parked_long\",\n\t\t\t\tobject: object.label,\n\t\t\t\twaitingFor: label,\n\t\t\t\tstate,\n\t\t\t\tsince: this.#since,\n\t\t\t});\n\t\t}, object.host.timeouts.ready);\n\t}\n\n\t/** What the latest check found blocking. */\n\tblockedBy(blocker: Blocker): void {\n\t\tthis.#blocker = blocker;\n\t}\n\n\t/** The episode ended: no report from now on. */\n\tstop(): void {\n\t\tclearTimeout(this.#timer);\n\t}\n}\n"]}
@@ -0,0 +1,48 @@
1
+ import type { Context } from "../../context/index.ts";
2
+ import type { Address, Contract, ParamsOf } from "../contracts/index.ts";
3
+ import { ChordError, type Principal } from "../data/index.ts";
4
+ import type { WireAddress } from "../link/internal.ts";
5
+ import type { HoldRequest, HostLink, Path } from "../remote/internal.ts";
6
+ import type { Route } from "./route.ts";
7
+ /** Where something is placed: here, or over a path (with the host address it was computed or named with). */
8
+ export type Placed = {
9
+ readonly kind: "here";
10
+ } | {
11
+ readonly kind: "path";
12
+ readonly path: Path;
13
+ readonly address: WireAddress;
14
+ };
15
+ /** A host's destinations: its address, its routes and its parent path, as the host keeps them. */
16
+ export declare class Destination {
17
+ #private;
18
+ constructor(address: Address | undefined, routes: ReadonlyMap<string, Route>, parent: Path);
19
+ /**
20
+ * Where a reference to `Type` with `params` made as `principal` goes: here for a local type, and for a remote type
21
+ * whose host address is this host's, served here or not (the check against what is served is the host's); otherwise
22
+ * over the route of its host address's kind, or over the parent link (the host address decides where an object
23
+ * lives: a worker reaches another worker's object of a type it serves too). Throws `invalid/host_address` for a host
24
+ * address whose params do not fit its kind, `forbidden` when the route refuses, and what a `hostAddress` or
25
+ * `authorize` throws.
26
+ */
27
+ reference(Type: Contract, params: ParamsOf<Contract>, principal: Principal | undefined, context: Context): Placed;
28
+ /**
29
+ * Whether a reference to `Type` with `params` goes here: a local type, or a remote one whose host address is this
30
+ * host's. A `hostAddress` that throws, throws.
31
+ */
32
+ placedHere(Type: Contract, params: ParamsOf<Contract>): boolean;
33
+ /**
34
+ * Where a hold arriving on `link` acting as `principal` goes, by the address it names: here when it is this host's
35
+ * (a relay never captures a hold for serving the same name); over the route of its kind; else over the parent link
36
+ * (waiting for it while it is down), unless it came on the parent link or this host never had one (`unavailable`).
37
+ * Throws as `reference` does.
38
+ */
39
+ hold(request: HoldRequest, link: HostLink, principal: Principal | undefined, context: Context): Placed;
40
+ /**
41
+ * The provider's own check of a request placed here for the remote `Type` it serves, with `params` (checked):
42
+ * `invalid/host_address` when its `hostAddress` puts the object on another host (code skew: the consumer computed
43
+ * this host), `undefined` when it lives here. A `hostAddress` that throws throws (the provider's own code). The
44
+ * address a request names only routes it.
45
+ */
46
+ misplaced(Type: Contract, params: ParamsOf<Contract>): ChordError | undefined;
47
+ }
48
+ //# sourceMappingURL=destination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destination.d.ts","sourceRoot":"","sources":["../../../src/next/host/destination.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,6GAA6G;AAC7G,MAAM,MAAM,MAAM,GACf;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAEjF,kGAAkG;AAClG,qBAAa,WAAW;;IAKvB,YAAY,OAAO,EAAE,OAAO,GAAG,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,EAIzF;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAKhH;IAED;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,OAAO,CAE9D;IAED;;;;;OAKG;IACH,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CASrG;IAED;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,UAAU,GAAG,SAAS,CAK5E;CAeD"}
@@ -0,0 +1,101 @@
1
+ // Destination (§3, section 1's table; dependency model §1): where a reference made on a host, or a hold arriving on one
2
+ // of its links, goes, by address alone: here when the address is this host's (served here or not), else over the
3
+ // route of its host address's kind, or over the parent link; and the check that an object served here lives here.
4
+ import { contractData } from "../contracts/internal.js";
5
+ import { ChordError } from "../data/index.js";
6
+ import { invalid } from "../data/internal.js";
7
+ /** A host's destinations: its address, its routes and its parent path, as the host keeps them. */
8
+ export class Destination {
9
+ #address;
10
+ #routes;
11
+ #parent;
12
+ constructor(address, routes, parent) {
13
+ this.#address = address;
14
+ this.#routes = routes;
15
+ this.#parent = parent;
16
+ }
17
+ /**
18
+ * Where a reference to `Type` with `params` made as `principal` goes: here for a local type, and for a remote type
19
+ * whose host address is this host's, served here or not (the check against what is served is the host's); otherwise
20
+ * over the route of its host address's kind, or over the parent link (the host address decides where an object
21
+ * lives: a worker reaches another worker's object of a type it serves too). Throws `invalid/host_address` for a host
22
+ * address whose params do not fit its kind, `forbidden` when the route refuses, and what a `hostAddress` or
23
+ * `authorize` throws.
24
+ */
25
+ reference(Type, params, principal, context) {
26
+ if (Type.kind === "local")
27
+ return HERE;
28
+ const address = hostAddressOf(Type, params);
29
+ if (this.#isHere(address))
30
+ return HERE;
31
+ return { kind: "path", path: this.#pathTo(address, principal, context) ?? this.#parent, address };
32
+ }
33
+ /**
34
+ * Whether a reference to `Type` with `params` goes here: a local type, or a remote one whose host address is this
35
+ * host's. A `hostAddress` that throws, throws.
36
+ */
37
+ placedHere(Type, params) {
38
+ return Type.kind === "local" || this.#isHere(hostAddressOf(Type, params));
39
+ }
40
+ /**
41
+ * Where a hold arriving on `link` acting as `principal` goes, by the address it names: here when it is this host's
42
+ * (a relay never captures a hold for serving the same name); over the route of its kind; else over the parent link
43
+ * (waiting for it while it is down), unless it came on the parent link or this host never had one (`unavailable`).
44
+ * Throws as `reference` does.
45
+ */
46
+ hold(request, link, principal, context) {
47
+ const { address } = request;
48
+ if (this.#isHere(address))
49
+ return HERE;
50
+ const routed = this.#pathTo(address, principal, context);
51
+ if (routed !== undefined)
52
+ return { kind: "path", path: routed, address };
53
+ if (link.role === "parent" || !this.#parent.linked) {
54
+ throw new ChordError({ code: "unavailable", message: `${request.type} is not served here` });
55
+ }
56
+ return { kind: "path", path: this.#parent, address };
57
+ }
58
+ /**
59
+ * The provider's own check of a request placed here for the remote `Type` it serves, with `params` (checked):
60
+ * `invalid/host_address` when its `hostAddress` puts the object on another host (code skew: the consumer computed
61
+ * this host), `undefined` when it lives here. A `hostAddress` that throws throws (the provider's own code). The
62
+ * address a request names only routes it.
63
+ */
64
+ misplaced(Type, params) {
65
+ const address = hostAddressOf(Type, params);
66
+ if (this.#isHere(address))
67
+ return undefined;
68
+ // A host serving a remote type has an address (`serve` refuses one without).
69
+ return invalid("host_address", `${Type.name}: placed on ${address.kind}, this host is ${this.#address.key}`);
70
+ }
71
+ /**
72
+ * The path to `address` when this host routes its kind (its params checked, `authorize` run for `principal`);
73
+ * `undefined` without a route for its kind.
74
+ */
75
+ #pathTo(address, principal, context) {
76
+ return this.#routes.get(address.kind)?.path(address.params, principal, context);
77
+ }
78
+ /** Whether an object whose host address is `address` lives here: this host has that address. */
79
+ #isHere(address) {
80
+ const own = this.#address;
81
+ return own !== undefined && sameAddress(own, address);
82
+ }
83
+ }
84
+ const HERE = { kind: "here" };
85
+ /** The address a remote `Type`'s `hostAddress` computes for `params`. */
86
+ function hostAddressOf(Type, params) {
87
+ // Every remote contract has one (declaration policy, `remote`).
88
+ const hostAddress = contractData(Type).hostAddress;
89
+ // Plugin code: what it returns is checked where it is routed or served.
90
+ const { kind, params: values } = hostAddress(params);
91
+ return { kind, params: values };
92
+ }
93
+ /** Whether `address` names the host at `own`: the same kind and the same value for each of its params. */
94
+ function sameAddress(own, address) {
95
+ if (own.kind !== address.kind || typeof address.params !== "object" || address.params === null)
96
+ return false;
97
+ const values = address.params;
98
+ const fields = Object.keys(own.params);
99
+ return Object.keys(values).length === fields.length && fields.every((field) => values[field] === own.params[field]);
100
+ }
101
+ //# sourceMappingURL=destination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destination.js","sourceRoot":"","sources":["../../../src/next/host/destination.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,iHAAiH;AACjH,kHAAkH;AAIlH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAkB,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAU9C,kGAAkG;AAClG,MAAM,OAAO,WAAW;IACd,QAAQ,CAAsB;IAC9B,OAAO,CAA6B;IACpC,OAAO,CAAO;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ChE,gEAAgE;IAChE,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,WAAY,CAAC;IACpD,wEAAwE;IACxE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC,MAAM,CAAwD,CAAC;IAC5G,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACjC,CAAC;AAED,0GAA0G;AAC1G,SAAS,WAAW,CAAC,GAAY,EAAE,OAAoB;IACtD,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC7G,MAAM,MAAM,GAAG,OAAO,CAAC,MAA+C,CAAC;IACvE,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACrH,CAAC","sourcesContent":["// Destination (§3, section 1's table; dependency model §1): where a reference made on a host, or a hold arriving on one\n// of its links, goes, by address alone: here when the address is this host's (served here or not), else over the\n// route of its host address's kind, or over the parent link; and the check that an object served here lives here.\n\nimport type { Context } from \"../../context/index.ts\";\nimport type { Address, Contract, ParamsOf } from \"../contracts/index.ts\";\nimport { contractData } from \"../contracts/internal.ts\";\nimport { ChordError, type Principal } from \"../data/index.ts\";\nimport { invalid } from \"../data/internal.ts\";\nimport type { WireAddress } from \"../link/internal.ts\";\nimport type { HoldRequest, HostLink, Path } from \"../remote/internal.ts\";\nimport type { Route } from \"./route.ts\";\n\n/** Where something is placed: here, or over a path (with the host address it was computed or named with). */\nexport type Placed =\n\t| { readonly kind: \"here\" }\n\t| { readonly kind: \"path\"; readonly path: Path; readonly address: WireAddress };\n\n/** A host's destinations: its address, its routes and its parent path, as the host keeps them. */\nexport class Destination {\n\treadonly #address: Address | undefined;\n\treadonly #routes: ReadonlyMap<string, Route>;\n\treadonly #parent: Path;\n\n\tconstructor(address: Address | undefined, routes: ReadonlyMap<string, Route>, parent: Path) {\n\t\tthis.#address = address;\n\t\tthis.#routes = routes;\n\t\tthis.#parent = parent;\n\t}\n\n\t/**\n\t * Where a reference to `Type` with `params` made as `principal` goes: here for a local type, and for a remote type\n\t * whose host address is this host's, served here or not (the check against what is served is the host's); otherwise\n\t * over the route of its host address's kind, or over the parent link (the host address decides where an object\n\t * lives: a worker reaches another worker's object of a type it serves too). Throws `invalid/host_address` for a host\n\t * address whose params do not fit its kind, `forbidden` when the route refuses, and what a `hostAddress` or\n\t * `authorize` throws.\n\t */\n\treference(Type: Contract, params: ParamsOf<Contract>, principal: Principal | undefined, context: Context): Placed {\n\t\tif (Type.kind === \"local\") return HERE;\n\t\tconst address = hostAddressOf(Type, params);\n\t\tif (this.#isHere(address)) return HERE;\n\t\treturn { kind: \"path\", path: this.#pathTo(address, principal, context) ?? this.#parent, address };\n\t}\n\n\t/**\n\t * Whether a reference to `Type` with `params` goes here: a local type, or a remote one whose host address is this\n\t * host's. A `hostAddress` that throws, throws.\n\t */\n\tplacedHere(Type: Contract, params: ParamsOf<Contract>): boolean {\n\t\treturn Type.kind === \"local\" || this.#isHere(hostAddressOf(Type, params));\n\t}\n\n\t/**\n\t * Where a hold arriving on `link` acting as `principal` goes, by the address it names: here when it is this host's\n\t * (a relay never captures a hold for serving the same name); over the route of its kind; else over the parent link\n\t * (waiting for it while it is down), unless it came on the parent link or this host never had one (`unavailable`).\n\t * Throws as `reference` does.\n\t */\n\thold(request: HoldRequest, link: HostLink, principal: Principal | undefined, context: Context): Placed {\n\t\tconst { address } = request;\n\t\tif (this.#isHere(address)) return HERE;\n\t\tconst routed = this.#pathTo(address, principal, context);\n\t\tif (routed !== undefined) return { kind: \"path\", path: routed, address };\n\t\tif (link.role === \"parent\" || !this.#parent.linked) {\n\t\t\tthrow new ChordError({ code: \"unavailable\", message: `${request.type} is not served here` });\n\t\t}\n\t\treturn { kind: \"path\", path: this.#parent, address };\n\t}\n\n\t/**\n\t * The provider's own check of a request placed here for the remote `Type` it serves, with `params` (checked):\n\t * `invalid/host_address` when its `hostAddress` puts the object on another host (code skew: the consumer computed\n\t * this host), `undefined` when it lives here. A `hostAddress` that throws throws (the provider's own code). The\n\t * address a request names only routes it.\n\t */\n\tmisplaced(Type: Contract, params: ParamsOf<Contract>): ChordError | undefined {\n\t\tconst address = hostAddressOf(Type, params);\n\t\tif (this.#isHere(address)) return undefined;\n\t\t// A host serving a remote type has an address (`serve` refuses one without).\n\t\treturn invalid(\"host_address\", `${Type.name}: placed on ${address.kind}, this host is ${this.#address!.key}`);\n\t}\n\n\t/**\n\t * The path to `address` when this host routes its kind (its params checked, `authorize` run for `principal`);\n\t * `undefined` without a route for its kind.\n\t */\n\t#pathTo(address: WireAddress, principal: Principal | undefined, context: Context): Path | undefined {\n\t\treturn this.#routes.get(address.kind)?.path(address.params, principal, context);\n\t}\n\n\t/** Whether an object whose host address is `address` lives here: this host has that address. */\n\t#isHere(address: WireAddress): boolean {\n\t\tconst own = this.#address;\n\t\treturn own !== undefined && sameAddress(own, address);\n\t}\n}\n\nconst HERE: Placed = { kind: \"here\" };\n\n/** The address a remote `Type`'s `hostAddress` computes for `params`. */\nfunction hostAddressOf(Type: Contract, params: ParamsOf<Contract>): WireAddress {\n\t// Every remote contract has one (declaration policy, `remote`).\n\tconst hostAddress = contractData(Type).hostAddress!;\n\t// Plugin code: what it returns is checked where it is routed or served.\n\tconst { kind, params: values } = hostAddress(params) as { readonly kind: string; readonly params: unknown };\n\treturn { kind, params: values };\n}\n\n/** Whether `address` names the host at `own`: the same kind and the same value for each of its params. */\nfunction sameAddress(own: Address, address: WireAddress): boolean {\n\tif (own.kind !== address.kind || typeof address.params !== \"object\" || address.params === null) return false;\n\tconst values = address.params as { readonly [field: string]: unknown };\n\tconst fields = Object.keys(own.params);\n\treturn Object.keys(values).length === fields.length && fields.every((field) => values[field] === own.params[field]);\n}\n"]}
@@ -0,0 +1,79 @@
1
+ import type { Watchable } from "../../watch.ts";
2
+ import type { AcceptsTable, Contract } from "../contracts/index.ts";
3
+ import type { Principal } from "../data/index.ts";
4
+ import type { Contribution, Registry, RegistryProvider } from "../registries/index.ts";
5
+ import type { Factory } from "./attempt.ts";
6
+ import type { Presence } from "./presence.ts";
7
+ /** What a setup serves types and registries with (valid only while the setup runs), and the host's presence lists. */
8
+ export interface FacetHost<P extends Principal = Principal> {
9
+ /**
10
+ * Serves a type on this host with `factory`; a remote type's factory gets the principal its object is for.
11
+ * `options.accepts` maps the older versions it still serves (checked here: a declaration error rejects the load or
12
+ * the reload).
13
+ */
14
+ serve<C extends Contract>(Type: C, factory: Factory<C, P>, options?: ServeOptions<C>): void;
15
+ /**
16
+ * Serves registry `R` on this host (its defining plugin's facet, the one provider, D1): `compose` builds the value
17
+ * from the table, `accepts` adapts older versions. A second serve of a registry is refused at `load`.
18
+ */
19
+ serve<C, V>(R: Registry<C, V>, provider: RegistryProvider<C, V>): void;
20
+ /** `host.references(Type)`: the references to objects of `Type` on this host (§19), for factories to derive from. */
21
+ references<C extends Contract>(Type: C): Watchable<readonly Presence<C, P>[]>;
22
+ }
23
+ /** What `host.serve` takes besides the type and the factory. */
24
+ export type ServeOptions<C extends Contract = Contract> = {
25
+ /**
26
+ * The older versions of `C` this provider still binds, with the mappings their edits need (Q10, `checkAccepts`):
27
+ * an older consumer's state members mapped per binding, its calls' arguments and results mapped.
28
+ */
29
+ readonly accepts?: AcceptsTable<C>;
30
+ /**
31
+ * How long, in milliseconds, a live object with params stays live after its last reference is released (0 by
32
+ * default): a reference within that time reuses it, with its documents and dependencies.
33
+ */
34
+ readonly linger?: number;
35
+ };
36
+ /** What a facet's setup declares with besides the host: its contributions to registries (R21). */
37
+ export interface FacetSelf {
38
+ /**
39
+ * Contributes `value` to registry `R` while this plugin is loaded: a plain value, or a Chord watchable of one
40
+ * (followed: its change recomposes). At most one per registry.
41
+ */
42
+ contribute<C>(R: Registry<C, unknown>, value: Contribution<C>): void;
43
+ }
44
+ /** What a setup served, by kind: a type (its contract, factory and options), or a registry (its provider). */
45
+ export type ServedEntry = {
46
+ readonly kind: "type";
47
+ readonly contract: Contract;
48
+ readonly factory: ServedFactory;
49
+ readonly options: ServeOptions;
50
+ } | {
51
+ readonly kind: "registry";
52
+ readonly registry: Registry<unknown, unknown>;
53
+ readonly provider: RegistryProvider<unknown, unknown>;
54
+ };
55
+ /** A contribution a setup declared. */
56
+ export type FacetContribution = {
57
+ readonly registry: Registry<unknown, unknown>;
58
+ readonly value: unknown;
59
+ };
60
+ /** A factory as a setup served it, of either kind (the host dispatches on its contract's kind). */
61
+ type ServedFactory = (params: never, principalOrSelf: never, self: never) => unknown;
62
+ /** A plugin's facet for hosts of the app's principal type `P` (type only: nothing is checked at runtime). */
63
+ export type Facet<P extends Principal> = {
64
+ readonly setup: (host: FacetHost<P>, self: FacetSelf) => void;
65
+ /** Type only: the principal type, invariant, so a host takes only facets typed for exactly its `P`. */
66
+ readonly "~principal"?: (principal: P) => P;
67
+ };
68
+ /** Defines a facet; base code binds `P` once, next to its principal type. */
69
+ export declare function defineFacet<P extends Principal>(setup: (host: FacetHost<P>, self: FacetSelf) => void): Facet<P>;
70
+ /**
71
+ * Runs a facet's setup and returns the types and registries it served and its contributions, in order; `references`
72
+ * is the host's.
73
+ */
74
+ export declare function setUp<P extends Principal>(name: string, facet: Facet<P>, references: <C extends Contract>(Type: C) => Watchable<readonly Presence<C, P>[]>): {
75
+ readonly served: readonly ServedEntry[];
76
+ readonly contributions: readonly FacetContribution[];
77
+ };
78
+ export {};
79
+ //# sourceMappingURL=facet.d.ts.map
@@ -0,0 +1 @@
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,CAAC,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC;CAC5C,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAE/G;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,SAAS,EACxC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,UAAU,EAAE,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,CAAC,KAAK,SAAS,CAAC,SAAS,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAC/E;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAA;CAAE,CAuCnG"}
@@ -0,0 +1,55 @@
1
+ // Facets (§16): a plugin's setup for one host, typed by the app's principal type. A setup only declares: the types and
2
+ // registries it serves, its contributions to registries (slice 8) and the host's presence lists; it has no documents,
3
+ // routines or natives, so a facet cannot fail after `load`.
4
+ /** Defines a facet; base code binds `P` once, next to its principal type. */
5
+ export function defineFacet(setup) {
6
+ return { setup };
7
+ }
8
+ /**
9
+ * Runs a facet's setup and returns the types and registries it served and its contributions, in order; `references`
10
+ * is the host's.
11
+ */
12
+ export function setUp(name, facet, references) {
13
+ const served = [];
14
+ const contributions = [];
15
+ let open = true;
16
+ const assertOpen = (what) => {
17
+ if (!open)
18
+ throw new Error(`${name}: ${what} is valid only in the facet's setup`);
19
+ };
20
+ const host = {
21
+ serve: (Type, implementation, options = {}) => {
22
+ assertOpen("host.serve");
23
+ // Served types and registries are dispatched by their kind; a factory matches its own contract, a provider
24
+ // its own registry.
25
+ if (Type.kind === "registry") {
26
+ served.push({
27
+ kind: "registry",
28
+ registry: Type,
29
+ provider: implementation,
30
+ });
31
+ }
32
+ else {
33
+ served.push({ kind: "type", contract: Type, factory: implementation, options });
34
+ }
35
+ },
36
+ references,
37
+ };
38
+ const self = {
39
+ contribute: (registry, value) => {
40
+ assertOpen("self.contribute");
41
+ if (contributions.some((each) => each.registry.name === registry.name)) {
42
+ throw new Error(`${name}: registry ${registry.name} is contributed to twice`);
43
+ }
44
+ contributions.push({ registry: registry, value });
45
+ },
46
+ };
47
+ try {
48
+ facet.setup(host, self);
49
+ }
50
+ finally {
51
+ open = false;
52
+ }
53
+ return { served, contributions };
54
+ }
55
+ //# sourceMappingURL=facet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facet.js","sourceRoot":"","sources":["../../../src/next/host/facet.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,sHAAsH;AACtH,4DAA4D;AA4E5D,6EAA6E;AAC7E,MAAM,UAAU,WAAW,CAAsB,KAAoD;IACpG,OAAO,EAAE,KAAK,EAAE,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CACpB,IAAY,EACZ,KAAe,EACf,UAAiF;IAEjF,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,MAAM,aAAa,GAAwB,EAAE,CAAC;IAC9C,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,MAAM,UAAU,GAAG,CAAC,IAAY,EAAQ,EAAE;QACzC,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,IAAI,qCAAqC,CAAC,CAAC;IACnF,CAAC,CAAC;IACF,MAAM,IAAI,GAAiB;QAC1B,KAAK,EAAE,CAAC,IAA2C,EAAE,cAAuB,EAAE,OAAO,GAAiB,EAAE,EAAE,EAAE;YAC3G,UAAU,CAAC,YAAY,CAAC,CAAC;YACzB,2GAA2G;YAC3G,oBAAoB;YACpB,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBAC9B,MAAM,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,UAAU;oBAChB,QAAQ,EAAE,IAAI;oBACd,QAAQ,EAAE,cAAoD;iBAC9D,CAAC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACP,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,cAA+B,EAAE,OAAO,EAAE,CAAC,CAAC;YAClG,CAAC;QACF,CAAC;QACD,UAAU;KACV,CAAC;IACF,MAAM,IAAI,GAAc;QACvB,UAAU,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;YAC/B,UAAU,CAAC,iBAAiB,CAAC,CAAC;YAC9B,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,cAAc,QAAQ,CAAC,IAAI,0BAA0B,CAAC,CAAC;YAC/E,CAAC;YACD,aAAa,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAsC,EAAE,KAAK,EAAE,CAAC,CAAC;QACjF,CAAC;KACD,CAAC;IACF,IAAI,CAAC;QACJ,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;YAAS,CAAC;QACV,IAAI,GAAG,KAAK,CAAC;IACd,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;AAClC,CAAC","sourcesContent":["// Facets (§16): a plugin's setup for one host, typed by the app's principal type. A setup only declares: the types and\n// registries it serves, its contributions to registries (slice 8) and the host's presence lists; it has no documents,\n// routines or natives, so a facet cannot fail after `load`.\n\nimport type { Watchable } from \"../../watch.ts\";\nimport type { AcceptsTable, Contract } from \"../contracts/index.ts\";\nimport type { Principal } from \"../data/index.ts\";\nimport type { Contribution, Registry, RegistryProvider } from \"../registries/index.ts\";\nimport type { Factory } from \"./attempt.ts\";\nimport type { Presence } from \"./presence.ts\";\n\n/** What a setup serves types and registries with (valid only while the setup runs), and the host's presence lists. */\nexport interface FacetHost<P extends Principal = Principal> {\n\t/**\n\t * Serves a type on this host with `factory`; a remote type's factory gets the principal its object is for.\n\t * `options.accepts` maps the older versions it still serves (checked here: a declaration error rejects the load or\n\t * the reload).\n\t */\n\tserve<C extends Contract>(Type: C, factory: Factory<C, P>, options?: ServeOptions<C>): void;\n\t/**\n\t * Serves registry `R` on this host (its defining plugin's facet, the one provider, D1): `compose` builds the value\n\t * from the table, `accepts` adapts older versions. A second serve of a registry is refused at `load`.\n\t */\n\tserve<C, V>(R: Registry<C, V>, provider: RegistryProvider<C, V>): void;\n\t/** `host.references(Type)`: the references to objects of `Type` on this host (§19), for factories to derive from. */\n\treferences<C extends Contract>(Type: C): Watchable<readonly Presence<C, P>[]>;\n}\n\n/** What `host.serve` takes besides the type and the factory. */\nexport type ServeOptions<C extends Contract = Contract> = {\n\t/**\n\t * The older versions of `C` this provider still binds, with the mappings their edits need (Q10, `checkAccepts`):\n\t * an older consumer's state members mapped per binding, its calls' arguments and results mapped.\n\t */\n\treadonly accepts?: AcceptsTable<C>;\n\t/**\n\t * How long, in milliseconds, a live object with params stays live after its last reference is released (0 by\n\t * default): a reference within that time reuses it, with its documents and dependencies.\n\t */\n\treadonly linger?: number;\n};\n\n/** What a facet's setup declares with besides the host: its contributions to registries (R21). */\nexport interface FacetSelf {\n\t/**\n\t * Contributes `value` to registry `R` while this plugin is loaded: a plain value, or a Chord watchable of one\n\t * (followed: its change recomposes). At most one per registry.\n\t */\n\tcontribute<C>(R: Registry<C, unknown>, value: Contribution<C>): void;\n}\n\n/** What a setup served, by kind: a type (its contract, factory and options), or a registry (its provider). */\nexport type ServedEntry =\n\t| {\n\t\t\treadonly kind: \"type\";\n\t\t\treadonly contract: Contract;\n\t\t\treadonly factory: ServedFactory;\n\t\t\treadonly options: ServeOptions;\n\t }\n\t| {\n\t\t\treadonly kind: \"registry\";\n\t\t\treadonly registry: Registry<unknown, unknown>;\n\t\t\treadonly provider: RegistryProvider<unknown, unknown>;\n\t };\n\n/** A contribution a setup declared. */\nexport type FacetContribution = { readonly registry: Registry<unknown, unknown>; readonly value: unknown };\n\n/** A factory as a setup served it, of either kind (the host dispatches on its contract's kind). */\ntype ServedFactory = (params: never, principalOrSelf: never, self: never) => unknown;\n\n/** A plugin's facet for hosts of the app's principal type `P` (type only: nothing is checked at runtime). */\nexport type Facet<P extends Principal> = {\n\treadonly setup: (host: FacetHost<P>, self: FacetSelf) => void;\n\t/** Type only: the principal type, invariant, so a host takes only facets typed for exactly its `P`. */\n\treadonly \"~principal\"?: (principal: P) => P;\n};\n\n/** Defines a facet; base code binds `P` once, next to its principal type. */\nexport function defineFacet<P extends Principal>(setup: (host: FacetHost<P>, self: FacetSelf) => void): Facet<P> {\n\treturn { setup };\n}\n\n/**\n * Runs a facet's setup and returns the types and registries it served and its contributions, in order; `references`\n * is the host's.\n */\nexport function setUp<P extends Principal>(\n\tname: string,\n\tfacet: Facet<P>,\n\treferences: <C extends Contract>(Type: C) => Watchable<readonly Presence<C, P>[]>,\n): { readonly served: readonly ServedEntry[]; readonly contributions: readonly FacetContribution[] } {\n\tconst served: ServedEntry[] = [];\n\tconst contributions: FacetContribution[] = [];\n\tlet open = true;\n\tconst assertOpen = (what: string): void => {\n\t\tif (!open) throw new Error(`${name}: ${what} is valid only in the facet's setup`);\n\t};\n\tconst host: FacetHost<P> = {\n\t\tserve: (Type: Contract | Registry<unknown, unknown>, implementation: unknown, options: ServeOptions = {}) => {\n\t\t\tassertOpen(\"host.serve\");\n\t\t\t// Served types and registries are dispatched by their kind; a factory matches its own contract, a provider\n\t\t\t// its own registry.\n\t\t\tif (Type.kind === \"registry\") {\n\t\t\t\tserved.push({\n\t\t\t\t\tkind: \"registry\",\n\t\t\t\t\tregistry: Type,\n\t\t\t\t\tprovider: implementation as RegistryProvider<unknown, unknown>,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tserved.push({ kind: \"type\", contract: Type, factory: implementation as ServedFactory, options });\n\t\t\t}\n\t\t},\n\t\treferences,\n\t};\n\tconst self: FacetSelf = {\n\t\tcontribute: (registry, value) => {\n\t\t\tassertOpen(\"self.contribute\");\n\t\t\tif (contributions.some((each) => each.registry.name === registry.name)) {\n\t\t\t\tthrow new Error(`${name}: registry ${registry.name} is contributed to twice`);\n\t\t\t}\n\t\t\tcontributions.push({ registry: registry as Registry<unknown, unknown>, value });\n\t\t},\n\t};\n\ttry {\n\t\tfacet.setup(host, self);\n\t} finally {\n\t\topen = false;\n\t}\n\treturn { served, contributions };\n}\n"]}
@@ -0,0 +1,52 @@
1
+ import type { Context } from "../../context/index.ts";
2
+ import type { JsonValue } from "../../json.ts";
3
+ import type { Watch, WatchCall, WatchEnd } from "../../watch.ts";
4
+ import { type Batch, Source, type Subscriber } from "../state/internal.ts";
5
+ /** The observer a followed runtime is given: Chord's watch shapes (Durable's `Observer`). */
6
+ export type FollowObserver<T> = {
7
+ /** One change, synchronously and quickly: Chord only records it. */
8
+ advance(call: WatchCall<T>, context: Context): void;
9
+ /** The followed source ended: `failed` (its runtime failed), or `ended` for good. */
10
+ end(end: WatchEnd): void;
11
+ };
12
+ /** What attaching gives: the value every later call starts from, and how to detach (Durable's `Observation`). */
13
+ export type FollowAttachment<T> = {
14
+ readonly value: T;
15
+ detach(): void;
16
+ };
17
+ /**
18
+ * What `self.follow` takes: attaches `observer`, resolving with the attachment, `undefined` for an absent address.
19
+ * The observer takes calls of any value (it only records them), so `T` is inferred from the attachment alone.
20
+ */
21
+ export type FollowAttach<T> = (observer: FollowObserver<unknown>, context: Context) => Promise<FollowAttachment<T> | undefined>;
22
+ /** Who a followed source belongs to: its attempt (R4) and its context. */
23
+ export type FollowOwner = {
24
+ readonly label: string;
25
+ readonly context: Context;
26
+ /**
27
+ * The followed runtime ended its observer: `failed` fails the attempt `transient` (live or activating, its retry
28
+ * attaches again); `ended` while the attempt activates fails it `transient` too (it would go live on a source that
29
+ * ended); `ended` while live is final for the source only.
30
+ */
31
+ ended(end: WatchEnd): void;
32
+ };
33
+ /** A followed source: the runtime's value, its calls applied in order, its frames delivered in the host's batch. */
34
+ export declare class FollowSource extends Source {
35
+ #private;
36
+ constructor(attach: FollowAttach<JsonValue>, owner: FollowOwner, batch: Batch);
37
+ get value(): JsonValue;
38
+ /**
39
+ * Attaches (activation, after the natives opened): the calls that came meanwhile apply on the attachment's value,
40
+ * and an end that came meanwhile takes effect then (the value stays). A rejected attachment, or `undefined` (an
41
+ * absent address), throws; an attachment arriving after its attempt detached the source is detached at once.
42
+ */
43
+ attach(context: Context): Promise<void>;
44
+ /** Its attempt ended: the observer is detached (also after the runtime ended it) and its watches end `ended`. */
45
+ detach(): void;
46
+ /** A watch of an ended source opens at its value and ends `ended` at once. */
47
+ openWatch(context: Context): Watch<JsonValue>;
48
+ /** A subscriber of an ended source (a reference's watch through its member) ends `ended` at once. */
49
+ subscribe(subscriber: Subscriber): void;
50
+ deliver(context: Context): void;
51
+ }
52
+ //# sourceMappingURL=follow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../../../src/next/host/follow.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE3E,6FAA6F;AAC7F,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC/B,oEAAoE;IACpE,OAAO,CAAC,IAAI,E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