@earendil-works/chord 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (841) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +129 -10
  3. package/dist/cell.d.ts +7 -7
  4. package/dist/cell.d.ts.map +1 -1
  5. package/dist/cell.js.map +1 -1
  6. package/dist/context/index.d.ts +8 -0
  7. package/dist/context/index.d.ts.map +1 -1
  8. package/dist/context/index.js +15 -0
  9. package/dist/context/index.js.map +1 -1
  10. package/dist/contract.d.ts +51 -52
  11. package/dist/contract.d.ts.map +1 -1
  12. package/dist/contract.js +19 -24
  13. package/dist/contract.js.map +1 -1
  14. package/dist/delta/apply-immutable-trusted.js +3 -4
  15. package/dist/delta/apply-immutable-trusted.js.map +1 -1
  16. package/dist/delta/diff.d.ts.map +1 -1
  17. package/dist/delta/diff.js +5 -3
  18. package/dist/delta/diff.js.map +1 -1
  19. package/dist/delta/index.d.ts +9 -1
  20. package/dist/delta/index.d.ts.map +1 -1
  21. package/dist/delta/index.js +15 -11
  22. package/dist/delta/index.js.map +1 -1
  23. package/dist/delta/pending.d.ts +36 -0
  24. package/dist/delta/pending.d.ts.map +1 -0
  25. package/dist/delta/pending.js +143 -0
  26. package/dist/delta/pending.js.map +1 -0
  27. package/dist/delta/tracker.d.ts +12 -0
  28. package/dist/delta/tracker.d.ts.map +1 -1
  29. package/dist/delta/tracker.js +109 -39
  30. package/dist/delta/tracker.js.map +1 -1
  31. package/dist/host.d.ts.map +1 -1
  32. package/dist/host.js +9 -7
  33. package/dist/host.js.map +1 -1
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +1 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/next/contracts/accepts.d.ts +81 -0
  39. package/dist/next/contracts/accepts.d.ts.map +1 -0
  40. package/dist/next/contracts/accepts.js +123 -0
  41. package/dist/next/contracts/accepts.js.map +1 -0
  42. package/dist/next/contracts/contract.d.ts +121 -0
  43. package/dist/next/contracts/contract.d.ts.map +1 -0
  44. package/dist/next/contracts/contract.js +50 -0
  45. package/dist/next/contracts/contract.js.map +1 -0
  46. package/dist/next/contracts/declare.d.ts +107 -0
  47. package/dist/next/contracts/declare.d.ts.map +1 -0
  48. package/dist/next/contracts/declare.js +136 -0
  49. package/dist/next/contracts/declare.js.map +1 -0
  50. package/dist/next/contracts/evolve.d.ts +92 -0
  51. package/dist/next/contracts/evolve.d.ts.map +1 -0
  52. package/dist/next/contracts/evolve.js +179 -0
  53. package/dist/next/contracts/evolve.js.map +1 -0
  54. package/dist/next/contracts/fingerprint.d.ts +16 -0
  55. package/dist/next/contracts/fingerprint.d.ts.map +1 -0
  56. package/dist/next/contracts/fingerprint.js +50 -0
  57. package/dist/next/contracts/fingerprint.js.map +1 -0
  58. package/dist/next/contracts/history.d.ts +71 -0
  59. package/dist/next/contracts/history.d.ts.map +1 -0
  60. package/dist/next/contracts/history.js +3 -0
  61. package/dist/next/contracts/history.js.map +1 -0
  62. package/dist/next/contracts/host-kind.d.ts +40 -0
  63. package/dist/next/contracts/host-kind.d.ts.map +1 -0
  64. package/dist/next/contracts/host-kind.js +37 -0
  65. package/dist/next/contracts/host-kind.js.map +1 -0
  66. package/dist/next/contracts/index.d.ts +7 -0
  67. package/dist/next/contracts/index.d.ts.map +1 -0
  68. package/dist/next/contracts/index.js +6 -0
  69. package/dist/next/contracts/index.js.map +1 -0
  70. package/dist/next/contracts/internal.d.ts +10 -0
  71. package/dist/next/contracts/internal.d.ts.map +1 -0
  72. package/dist/next/contracts/internal.js +9 -0
  73. package/dist/next/contracts/internal.js.map +1 -0
  74. package/dist/next/contracts/names.d.ts +3 -0
  75. package/dist/next/contracts/names.d.ts.map +1 -0
  76. package/dist/next/contracts/names.js +13 -0
  77. package/dist/next/contracts/names.js.map +1 -0
  78. package/dist/next/contracts/params.d.ts +28 -0
  79. package/dist/next/contracts/params.d.ts.map +1 -0
  80. package/dist/next/contracts/params.js +50 -0
  81. package/dist/next/contracts/params.js.map +1 -0
  82. package/dist/next/contracts/schema.d.ts +102 -0
  83. package/dist/next/contracts/schema.d.ts.map +1 -0
  84. package/dist/next/contracts/schema.js +103 -0
  85. package/dist/next/contracts/schema.js.map +1 -0
  86. package/dist/next/contracts/snapshot.d.ts +16 -0
  87. package/dist/next/contracts/snapshot.d.ts.map +1 -0
  88. package/dist/next/contracts/snapshot.js +167 -0
  89. package/dist/next/contracts/snapshot.js.map +1 -0
  90. package/dist/next/data/args.d.ts +50 -0
  91. package/dist/next/data/args.d.ts.map +1 -0
  92. package/dist/next/data/args.js +83 -0
  93. package/dist/next/data/args.js.map +1 -0
  94. package/dist/next/data/errors.d.ts +73 -0
  95. package/dist/next/data/errors.d.ts.map +1 -0
  96. package/dist/next/data/errors.js +107 -0
  97. package/dist/next/data/errors.js.map +1 -0
  98. package/dist/next/data/failure.d.ts +26 -0
  99. package/dist/next/data/failure.d.ts.map +1 -0
  100. package/dist/next/data/failure.js +72 -0
  101. package/dist/next/data/failure.js.map +1 -0
  102. package/dist/next/data/index.d.ts +4 -0
  103. package/dist/next/data/index.d.ts.map +1 -0
  104. package/dist/next/data/index.js +4 -0
  105. package/dist/next/data/index.js.map +1 -0
  106. package/dist/next/data/internal.d.ts +7 -0
  107. package/dist/next/data/internal.d.ts.map +1 -0
  108. package/dist/next/data/internal.js +8 -0
  109. package/dist/next/data/internal.js.map +1 -0
  110. package/dist/next/data/params.d.ts +20 -0
  111. package/dist/next/data/params.d.ts.map +1 -0
  112. package/dist/next/data/params.js +31 -0
  113. package/dist/next/data/params.js.map +1 -0
  114. package/dist/next/data/principal.d.ts +17 -0
  115. package/dist/next/data/principal.d.ts.map +1 -0
  116. package/dist/next/data/principal.js +41 -0
  117. package/dist/next/data/principal.js.map +1 -0
  118. package/dist/next/data/validator.d.ts +12 -0
  119. package/dist/next/data/validator.d.ts.map +1 -0
  120. package/dist/next/data/validator.js +34 -0
  121. package/dist/next/data/validator.js.map +1 -0
  122. package/dist/next/documents/address-source.d.ts +20 -0
  123. package/dist/next/documents/address-source.d.ts.map +1 -0
  124. package/dist/next/documents/address-source.js +44 -0
  125. package/dist/next/documents/address-source.js.map +1 -0
  126. package/dist/next/documents/definition.d.ts +84 -0
  127. package/dist/next/documents/definition.d.ts.map +1 -0
  128. package/dist/next/documents/definition.js +73 -0
  129. package/dist/next/documents/definition.js.map +1 -0
  130. package/dist/next/documents/documents.d.ts +106 -0
  131. package/dist/next/documents/documents.d.ts.map +1 -0
  132. package/dist/next/documents/documents.js +224 -0
  133. package/dist/next/documents/documents.js.map +1 -0
  134. package/dist/next/documents/fence.d.ts +9 -0
  135. package/dist/next/documents/fence.d.ts.map +1 -0
  136. package/dist/next/documents/fence.js +15 -0
  137. package/dist/next/documents/fence.js.map +1 -0
  138. package/dist/next/documents/handles.d.ts +76 -0
  139. package/dist/next/documents/handles.d.ts.map +1 -0
  140. package/dist/next/documents/handles.js +66 -0
  141. package/dist/next/documents/handles.js.map +1 -0
  142. package/dist/next/documents/index.d.ts +4 -0
  143. package/dist/next/documents/index.d.ts.map +1 -0
  144. package/dist/next/documents/index.js +3 -0
  145. package/dist/next/documents/index.js.map +1 -0
  146. package/dist/next/documents/internal.d.ts +9 -0
  147. package/dist/next/documents/internal.d.ts.map +1 -0
  148. package/dist/next/documents/internal.js +9 -0
  149. package/dist/next/documents/internal.js.map +1 -0
  150. package/dist/next/documents/keyed-slot.d.ts +103 -0
  151. package/dist/next/documents/keyed-slot.d.ts.map +1 -0
  152. package/dist/next/documents/keyed-slot.js +395 -0
  153. package/dist/next/documents/keyed-slot.js.map +1 -0
  154. package/dist/next/documents/line.d.ts +7 -0
  155. package/dist/next/documents/line.d.ts.map +1 -0
  156. package/dist/next/documents/line.js +14 -0
  157. package/dist/next/documents/line.js.map +1 -0
  158. package/dist/next/documents/persistence.d.ts +104 -0
  159. package/dist/next/documents/persistence.d.ts.map +1 -0
  160. package/dist/next/documents/persistence.js +128 -0
  161. package/dist/next/documents/persistence.js.map +1 -0
  162. package/dist/next/documents/residency.d.ts +31 -0
  163. package/dist/next/documents/residency.d.ts.map +1 -0
  164. package/dist/next/documents/residency.js +93 -0
  165. package/dist/next/documents/residency.js.map +1 -0
  166. package/dist/next/documents/slot.d.ts +109 -0
  167. package/dist/next/documents/slot.d.ts.map +1 -0
  168. package/dist/next/documents/slot.js +181 -0
  169. package/dist/next/documents/slot.js.map +1 -0
  170. package/dist/next/documents/transaction.d.ts +133 -0
  171. package/dist/next/documents/transaction.d.ts.map +1 -0
  172. package/dist/next/documents/transaction.js +409 -0
  173. package/dist/next/documents/transaction.js.map +1 -0
  174. package/dist/next/host/activity.d.ts +31 -0
  175. package/dist/next/host/activity.d.ts.map +1 -0
  176. package/dist/next/host/activity.js +40 -0
  177. package/dist/next/host/activity.js.map +1 -0
  178. package/dist/next/host/adapted.d.ts +49 -0
  179. package/dist/next/host/adapted.d.ts.map +1 -0
  180. package/dist/next/host/adapted.js +214 -0
  181. package/dist/next/host/adapted.js.map +1 -0
  182. package/dist/next/host/attempt.d.ts +278 -0
  183. package/dist/next/host/attempt.d.ts.map +1 -0
  184. package/dist/next/host/attempt.js +1072 -0
  185. package/dist/next/host/attempt.js.map +1 -0
  186. package/dist/next/host/backoff.d.ts +29 -0
  187. package/dist/next/host/backoff.d.ts.map +1 -0
  188. package/dist/next/host/backoff.js +69 -0
  189. package/dist/next/host/backoff.js.map +1 -0
  190. package/dist/next/host/ctx.d.ts +47 -0
  191. package/dist/next/host/ctx.d.ts.map +1 -0
  192. package/dist/next/host/ctx.js +108 -0
  193. package/dist/next/host/ctx.js.map +1 -0
  194. package/dist/next/host/deadline.d.ts +12 -0
  195. package/dist/next/host/deadline.d.ts.map +1 -0
  196. package/dist/next/host/deadline.js +40 -0
  197. package/dist/next/host/deadline.js.map +1 -0
  198. package/dist/next/host/dependencies.d.ts +65 -0
  199. package/dist/next/host/dependencies.d.ts.map +1 -0
  200. package/dist/next/host/dependencies.js +115 -0
  201. package/dist/next/host/dependencies.js.map +1 -0
  202. package/dist/next/host/destination.d.ts +48 -0
  203. package/dist/next/host/destination.d.ts.map +1 -0
  204. package/dist/next/host/destination.js +101 -0
  205. package/dist/next/host/destination.js.map +1 -0
  206. package/dist/next/host/facet.d.ts +79 -0
  207. package/dist/next/host/facet.d.ts.map +1 -0
  208. package/dist/next/host/facet.js +55 -0
  209. package/dist/next/host/facet.js.map +1 -0
  210. package/dist/next/host/follow.d.ts +52 -0
  211. package/dist/next/host/follow.d.ts.map +1 -0
  212. package/dist/next/host/follow.js +207 -0
  213. package/dist/next/host/follow.js.map +1 -0
  214. package/dist/next/host/host.d.ts +495 -0
  215. package/dist/next/host/host.d.ts.map +1 -0
  216. package/dist/next/host/host.js +1075 -0
  217. package/dist/next/host/host.js.map +1 -0
  218. package/dist/next/host/index.d.ts +17 -0
  219. package/dist/next/host/index.d.ts.map +1 -0
  220. package/dist/next/host/index.js +6 -0
  221. package/dist/next/host/index.js.map +1 -0
  222. package/dist/next/host/internal.d.ts +10 -0
  223. package/dist/next/host/internal.d.ts.map +1 -0
  224. package/dist/next/host/internal.js +8 -0
  225. package/dist/next/host/internal.js.map +1 -0
  226. package/dist/next/host/members.d.ts +50 -0
  227. package/dist/next/host/members.d.ts.map +1 -0
  228. package/dist/next/host/members.js +107 -0
  229. package/dist/next/host/members.js.map +1 -0
  230. package/dist/next/host/native.d.ts +55 -0
  231. package/dist/next/host/native.d.ts.map +1 -0
  232. package/dist/next/host/native.js +92 -0
  233. package/dist/next/host/native.js.map +1 -0
  234. package/dist/next/host/object.d.ts +290 -0
  235. package/dist/next/host/object.d.ts.map +1 -0
  236. package/dist/next/host/object.js +1127 -0
  237. package/dist/next/host/object.js.map +1 -0
  238. package/dist/next/host/parked.d.ts +23 -0
  239. package/dist/next/host/parked.d.ts.map +1 -0
  240. package/dist/next/host/parked.js +79 -0
  241. package/dist/next/host/parked.js.map +1 -0
  242. package/dist/next/host/presence.d.ts +34 -0
  243. package/dist/next/host/presence.d.ts.map +1 -0
  244. package/dist/next/host/presence.js +117 -0
  245. package/dist/next/host/presence.js.map +1 -0
  246. package/dist/next/host/ref-state.d.ts +53 -0
  247. package/dist/next/host/ref-state.d.ts.map +1 -0
  248. package/dist/next/host/ref-state.js +83 -0
  249. package/dist/next/host/ref-state.js.map +1 -0
  250. package/dist/next/host/reference-keys.d.ts +36 -0
  251. package/dist/next/host/reference-keys.d.ts.map +1 -0
  252. package/dist/next/host/reference-keys.js +168 -0
  253. package/dist/next/host/reference-keys.js.map +1 -0
  254. package/dist/next/host/reference-source.d.ts +65 -0
  255. package/dist/next/host/reference-source.d.ts.map +1 -0
  256. package/dist/next/host/reference-source.js +285 -0
  257. package/dist/next/host/reference-source.js.map +1 -0
  258. package/dist/next/host/reference.d.ts +308 -0
  259. package/dist/next/host/reference.d.ts.map +1 -0
  260. package/dist/next/host/reference.js +775 -0
  261. package/dist/next/host/reference.js.map +1 -0
  262. package/dist/next/host/retry-on.d.ts +28 -0
  263. package/dist/next/host/retry-on.d.ts.map +1 -0
  264. package/dist/next/host/retry-on.js +52 -0
  265. package/dist/next/host/retry-on.js.map +1 -0
  266. package/dist/next/host/revocation.d.ts +16 -0
  267. package/dist/next/host/revocation.d.ts.map +1 -0
  268. package/dist/next/host/revocation.js +27 -0
  269. package/dist/next/host/revocation.js.map +1 -0
  270. package/dist/next/host/root.d.ts +27 -0
  271. package/dist/next/host/root.d.ts.map +1 -0
  272. package/dist/next/host/root.js +68 -0
  273. package/dist/next/host/root.js.map +1 -0
  274. package/dist/next/host/route.d.ts +64 -0
  275. package/dist/next/host/route.d.ts.map +1 -0
  276. package/dist/next/host/route.js +190 -0
  277. package/dist/next/host/route.js.map +1 -0
  278. package/dist/next/host/routines.d.ts +76 -0
  279. package/dist/next/host/routines.d.ts.map +1 -0
  280. package/dist/next/host/routines.js +350 -0
  281. package/dist/next/host/routines.js.map +1 -0
  282. package/dist/next/host/sleep.d.ts +9 -0
  283. package/dist/next/host/sleep.d.ts.map +1 -0
  284. package/dist/next/host/sleep.js +40 -0
  285. package/dist/next/host/sleep.js.map +1 -0
  286. package/dist/next/host/staging.d.ts +94 -0
  287. package/dist/next/host/staging.d.ts.map +1 -0
  288. package/dist/next/host/staging.js +302 -0
  289. package/dist/next/host/staging.js.map +1 -0
  290. package/dist/next/host/unbound.d.ts +30 -0
  291. package/dist/next/host/unbound.d.ts.map +1 -0
  292. package/dist/next/host/unbound.js +67 -0
  293. package/dist/next/host/unbound.js.map +1 -0
  294. package/dist/next/host/uuid.d.ts +3 -0
  295. package/dist/next/host/uuid.d.ts.map +1 -0
  296. package/dist/next/host/uuid.js +38 -0
  297. package/dist/next/host/uuid.js.map +1 -0
  298. package/dist/next/index.d.ts +28 -0
  299. package/dist/next/index.d.ts.map +1 -0
  300. package/dist/next/index.js +18 -0
  301. package/dist/next/index.js.map +1 -0
  302. package/dist/next/jobs/definition.d.ts +96 -0
  303. package/dist/next/jobs/definition.d.ts.map +1 -0
  304. package/dist/next/jobs/definition.js +83 -0
  305. package/dist/next/jobs/definition.js.map +1 -0
  306. package/dist/next/jobs/index.d.ts +5 -0
  307. package/dist/next/jobs/index.d.ts.map +1 -0
  308. package/dist/next/jobs/index.js +3 -0
  309. package/dist/next/jobs/index.js.map +1 -0
  310. package/dist/next/jobs/internal.d.ts +3 -0
  311. package/dist/next/jobs/internal.d.ts.map +1 -0
  312. package/dist/next/jobs/internal.js +4 -0
  313. package/dist/next/jobs/internal.js.map +1 -0
  314. package/dist/next/jobs/job.d.ts +152 -0
  315. package/dist/next/jobs/job.d.ts.map +1 -0
  316. package/dist/next/jobs/job.js +320 -0
  317. package/dist/next/jobs/job.js.map +1 -0
  318. package/dist/next/jobs/persisted.d.ts +38 -0
  319. package/dist/next/jobs/persisted.d.ts.map +1 -0
  320. package/dist/next/jobs/persisted.js +95 -0
  321. package/dist/next/jobs/persisted.js.map +1 -0
  322. package/dist/next/jobs/records.d.ts +231 -0
  323. package/dist/next/jobs/records.d.ts.map +1 -0
  324. package/dist/next/jobs/records.js +869 -0
  325. package/dist/next/jobs/records.js.map +1 -0
  326. package/dist/next/jobs/run-states.d.ts +69 -0
  327. package/dist/next/jobs/run-states.d.ts.map +1 -0
  328. package/dist/next/jobs/run-states.js +228 -0
  329. package/dist/next/jobs/run-states.js.map +1 -0
  330. package/dist/next/jobs/run.d.ts +113 -0
  331. package/dist/next/jobs/run.d.ts.map +1 -0
  332. package/dist/next/jobs/run.js +200 -0
  333. package/dist/next/jobs/run.js.map +1 -0
  334. package/dist/next/jobs/running.d.ts +44 -0
  335. package/dist/next/jobs/running.d.ts.map +1 -0
  336. package/dist/next/jobs/running.js +117 -0
  337. package/dist/next/jobs/running.js.map +1 -0
  338. package/dist/next/jobs/stored.d.ts +63 -0
  339. package/dist/next/jobs/stored.d.ts.map +1 -0
  340. package/dist/next/jobs/stored.js +55 -0
  341. package/dist/next/jobs/stored.js.map +1 -0
  342. package/dist/next/link/binary.d.ts +4 -0
  343. package/dist/next/link/binary.d.ts.map +1 -0
  344. package/dist/next/link/binary.js +534 -0
  345. package/dist/next/link/binary.js.map +1 -0
  346. package/dist/next/link/channel.d.ts +63 -0
  347. package/dist/next/link/channel.d.ts.map +1 -0
  348. package/dist/next/link/channel.js +202 -0
  349. package/dist/next/link/channel.js.map +1 -0
  350. package/dist/next/link/errors.d.ts +7 -0
  351. package/dist/next/link/errors.d.ts.map +1 -0
  352. package/dist/next/link/errors.js +21 -0
  353. package/dist/next/link/errors.js.map +1 -0
  354. package/dist/next/link/index.d.ts +8 -0
  355. package/dist/next/link/index.d.ts.map +1 -0
  356. package/dist/next/link/index.js +8 -0
  357. package/dist/next/link/index.js.map +1 -0
  358. package/dist/next/link/internal.d.ts +9 -0
  359. package/dist/next/link/internal.d.ts.map +1 -0
  360. package/dist/next/link/internal.js +10 -0
  361. package/dist/next/link/internal.js.map +1 -0
  362. package/dist/next/link/ipc.d.ts +22 -0
  363. package/dist/next/link/ipc.d.ts.map +1 -0
  364. package/dist/next/link/ipc.js +64 -0
  365. package/dist/next/link/ipc.js.map +1 -0
  366. package/dist/next/link/link.d.ts +34 -0
  367. package/dist/next/link/link.d.ts.map +1 -0
  368. package/dist/next/link/link.js +87 -0
  369. package/dist/next/link/link.js.map +1 -0
  370. package/dist/next/link/message.d.ts +249 -0
  371. package/dist/next/link/message.d.ts.map +1 -0
  372. package/dist/next/link/message.js +123 -0
  373. package/dist/next/link/message.js.map +1 -0
  374. package/dist/next/link/part.d.ts +80 -0
  375. package/dist/next/link/part.d.ts.map +1 -0
  376. package/dist/next/link/part.js +164 -0
  377. package/dist/next/link/part.js.map +1 -0
  378. package/dist/next/link/text.d.ts +6 -0
  379. package/dist/next/link/text.d.ts.map +1 -0
  380. package/dist/next/link/text.js +335 -0
  381. package/dist/next/link/text.js.map +1 -0
  382. package/dist/next/link/values.d.ts +40 -0
  383. package/dist/next/link/values.d.ts.map +1 -0
  384. package/dist/next/link/values.js +117 -0
  385. package/dist/next/link/values.js.map +1 -0
  386. package/dist/next/link/websocket.d.ts +26 -0
  387. package/dist/next/link/websocket.d.ts.map +1 -0
  388. package/dist/next/link/websocket.js +91 -0
  389. package/dist/next/link/websocket.js.map +1 -0
  390. package/dist/next/registries/contribution.d.ts +50 -0
  391. package/dist/next/registries/contribution.d.ts.map +1 -0
  392. package/dist/next/registries/contribution.js +129 -0
  393. package/dist/next/registries/contribution.js.map +1 -0
  394. package/dist/next/registries/entries.d.ts +18 -0
  395. package/dist/next/registries/entries.d.ts.map +1 -0
  396. package/dist/next/registries/entries.js +42 -0
  397. package/dist/next/registries/entries.js.map +1 -0
  398. package/dist/next/registries/index.d.ts +3 -0
  399. package/dist/next/registries/index.d.ts.map +1 -0
  400. package/dist/next/registries/index.js +5 -0
  401. package/dist/next/registries/index.js.map +1 -0
  402. package/dist/next/registries/internal.d.ts +4 -0
  403. package/dist/next/registries/internal.d.ts.map +1 -0
  404. package/dist/next/registries/internal.js +5 -0
  405. package/dist/next/registries/internal.js.map +1 -0
  406. package/dist/next/registries/record.d.ts +94 -0
  407. package/dist/next/registries/record.d.ts.map +1 -0
  408. package/dist/next/registries/record.js +253 -0
  409. package/dist/next/registries/record.js.map +1 -0
  410. package/dist/next/registries/registry.d.ts +74 -0
  411. package/dist/next/registries/registry.d.ts.map +1 -0
  412. package/dist/next/registries/registry.js +14 -0
  413. package/dist/next/registries/registry.js.map +1 -0
  414. package/dist/next/registries/value.d.ts +48 -0
  415. package/dist/next/registries/value.d.ts.map +1 -0
  416. package/dist/next/registries/value.js +199 -0
  417. package/dist/next/registries/value.js.map +1 -0
  418. package/dist/next/remote/calls.d.ts +25 -0
  419. package/dist/next/remote/calls.d.ts.map +1 -0
  420. package/dist/next/remote/calls.js +62 -0
  421. package/dist/next/remote/calls.js.map +1 -0
  422. package/dist/next/remote/consumer.d.ts +42 -0
  423. package/dist/next/remote/consumer.d.ts.map +1 -0
  424. package/dist/next/remote/consumer.js +343 -0
  425. package/dist/next/remote/consumer.js.map +1 -0
  426. package/dist/next/remote/hold.d.ts +130 -0
  427. package/dist/next/remote/hold.d.ts.map +1 -0
  428. package/dist/next/remote/hold.js +537 -0
  429. package/dist/next/remote/hold.js.map +1 -0
  430. package/dist/next/remote/host-link.d.ts +77 -0
  431. package/dist/next/remote/host-link.d.ts.map +1 -0
  432. package/dist/next/remote/host-link.js +182 -0
  433. package/dist/next/remote/host-link.js.map +1 -0
  434. package/dist/next/remote/internal.d.ts +6 -0
  435. package/dist/next/remote/internal.d.ts.map +1 -0
  436. package/dist/next/remote/internal.js +6 -0
  437. package/dist/next/remote/internal.js.map +1 -0
  438. package/dist/next/remote/path.d.ts +46 -0
  439. package/dist/next/remote/path.d.ts.map +1 -0
  440. package/dist/next/remote/path.js +73 -0
  441. package/dist/next/remote/path.js.map +1 -0
  442. package/dist/next/remote/provider.d.ts +76 -0
  443. package/dist/next/remote/provider.d.ts.map +1 -0
  444. package/dist/next/remote/provider.js +506 -0
  445. package/dist/next/remote/provider.js.map +1 -0
  446. package/dist/next/remote/relay.d.ts +58 -0
  447. package/dist/next/remote/relay.d.ts.map +1 -0
  448. package/dist/next/remote/relay.js +117 -0
  449. package/dist/next/remote/relay.js.map +1 -0
  450. package/dist/next/remote/remote-object.d.ts +133 -0
  451. package/dist/next/remote/remote-object.d.ts.map +1 -0
  452. package/dist/next/remote/remote-object.js +411 -0
  453. package/dist/next/remote/remote-object.js.map +1 -0
  454. package/dist/next/remote/replica.d.ts +59 -0
  455. package/dist/next/remote/replica.d.ts.map +1 -0
  456. package/dist/next/remote/replica.js +125 -0
  457. package/dist/next/remote/replica.js.map +1 -0
  458. package/dist/next/state/batch.d.ts +64 -0
  459. package/dist/next/state/batch.d.ts.map +1 -0
  460. package/dist/next/state/batch.js +163 -0
  461. package/dist/next/state/batch.js.map +1 -0
  462. package/dist/next/state/derive.d.ts +52 -0
  463. package/dist/next/state/derive.d.ts.map +1 -0
  464. package/dist/next/state/derive.js +182 -0
  465. package/dist/next/state/derive.js.map +1 -0
  466. package/dist/next/state/index.d.ts +6 -0
  467. package/dist/next/state/index.d.ts.map +1 -0
  468. package/dist/next/state/index.js +4 -0
  469. package/dist/next/state/index.js.map +1 -0
  470. package/dist/next/state/internal.d.ts +6 -0
  471. package/dist/next/state/internal.d.ts.map +1 -0
  472. package/dist/next/state/internal.js +8 -0
  473. package/dist/next/state/internal.js.map +1 -0
  474. package/dist/next/state/native-source.d.ts +106 -0
  475. package/dist/next/state/native-source.d.ts.map +1 -0
  476. package/dist/next/state/native-source.js +240 -0
  477. package/dist/next/state/native-source.js.map +1 -0
  478. package/dist/next/state/watchable.d.ts +114 -0
  479. package/dist/next/state/watchable.d.ts.map +1 -0
  480. package/dist/next/state/watchable.js +156 -0
  481. package/dist/next/state/watchable.js.map +1 -0
  482. package/dist/next/state/writable.d.ts +32 -0
  483. package/dist/next/state/writable.d.ts.map +1 -0
  484. package/dist/next/state/writable.js +49 -0
  485. package/dist/next/state/writable.js.map +1 -0
  486. package/dist/next/store/adapter.d.ts +67 -0
  487. package/dist/next/store/adapter.d.ts.map +1 -0
  488. package/dist/next/store/adapter.js +118 -0
  489. package/dist/next/store/adapter.js.map +1 -0
  490. package/dist/next/store/allocator.d.ts +17 -0
  491. package/dist/next/store/allocator.d.ts.map +1 -0
  492. package/dist/next/store/allocator.js +30 -0
  493. package/dist/next/store/allocator.js.map +1 -0
  494. package/dist/next/store/applier.d.ts +8 -0
  495. package/dist/next/store/applier.d.ts.map +1 -0
  496. package/dist/next/store/applier.js +375 -0
  497. package/dist/next/store/applier.js.map +1 -0
  498. package/dist/next/store/apply-batch.d.ts +12 -0
  499. package/dist/next/store/apply-batch.d.ts.map +1 -0
  500. package/dist/next/store/apply-batch.js +83 -0
  501. package/dist/next/store/apply-batch.js.map +1 -0
  502. package/dist/next/store/archive.d.ts +32 -0
  503. package/dist/next/store/archive.d.ts.map +1 -0
  504. package/dist/next/store/archive.js +129 -0
  505. package/dist/next/store/archive.js.map +1 -0
  506. package/dist/next/store/backend.d.ts +10 -0
  507. package/dist/next/store/backend.d.ts.map +1 -0
  508. package/dist/next/store/backend.js +15 -0
  509. package/dist/next/store/backend.js.map +1 -0
  510. package/dist/next/store/catalog.d.ts +24 -0
  511. package/dist/next/store/catalog.d.ts.map +1 -0
  512. package/dist/next/store/catalog.js +17 -0
  513. package/dist/next/store/catalog.js.map +1 -0
  514. package/dist/next/store/claims.d.ts +23 -0
  515. package/dist/next/store/claims.d.ts.map +1 -0
  516. package/dist/next/store/claims.js +65 -0
  517. package/dist/next/store/claims.js.map +1 -0
  518. package/dist/next/store/columns.d.ts +77 -0
  519. package/dist/next/store/columns.d.ts.map +1 -0
  520. package/dist/next/store/columns.js +77 -0
  521. package/dist/next/store/columns.js.map +1 -0
  522. package/dist/next/store/engine.d.ts +176 -0
  523. package/dist/next/store/engine.d.ts.map +1 -0
  524. package/dist/next/store/engine.js +283 -0
  525. package/dist/next/store/engine.js.map +1 -0
  526. package/dist/next/store/evaluate.d.ts +17 -0
  527. package/dist/next/store/evaluate.d.ts.map +1 -0
  528. package/dist/next/store/evaluate.js +128 -0
  529. package/dist/next/store/evaluate.js.map +1 -0
  530. package/dist/next/store/export.d.ts +17 -0
  531. package/dist/next/store/export.d.ts.map +1 -0
  532. package/dist/next/store/export.js +200 -0
  533. package/dist/next/store/export.js.map +1 -0
  534. package/dist/next/store/expression.d.ts +150 -0
  535. package/dist/next/store/expression.d.ts.map +1 -0
  536. package/dist/next/store/expression.js +268 -0
  537. package/dist/next/store/expression.js.map +1 -0
  538. package/dist/next/store/import.d.ts +10 -0
  539. package/dist/next/store/import.d.ts.map +1 -0
  540. package/dist/next/store/import.js +276 -0
  541. package/dist/next/store/import.js.map +1 -0
  542. package/dist/next/store/index.d.ts +16 -0
  543. package/dist/next/store/index.d.ts.map +1 -0
  544. package/dist/next/store/index.js +13 -0
  545. package/dist/next/store/index.js.map +1 -0
  546. package/dist/next/store/json-column.d.ts +33 -0
  547. package/dist/next/store/json-column.d.ts.map +1 -0
  548. package/dist/next/store/json-column.js +61 -0
  549. package/dist/next/store/json-column.js.map +1 -0
  550. package/dist/next/store/jsonl.d.ts +9 -0
  551. package/dist/next/store/jsonl.d.ts.map +1 -0
  552. package/dist/next/store/jsonl.js +61 -0
  553. package/dist/next/store/jsonl.js.map +1 -0
  554. package/dist/next/store/outbox.d.ts +26 -0
  555. package/dist/next/store/outbox.d.ts.map +1 -0
  556. package/dist/next/store/outbox.js +80 -0
  557. package/dist/next/store/outbox.js.map +1 -0
  558. package/dist/next/store/query.d.ts +39 -0
  559. package/dist/next/store/query.d.ts.map +1 -0
  560. package/dist/next/store/query.js +97 -0
  561. package/dist/next/store/query.js.map +1 -0
  562. package/dist/next/store/refusal.d.ts +15 -0
  563. package/dist/next/store/refusal.d.ts.map +1 -0
  564. package/dist/next/store/refusal.js +36 -0
  565. package/dist/next/store/refusal.js.map +1 -0
  566. package/dist/next/store/rows.d.ts +80 -0
  567. package/dist/next/store/rows.d.ts.map +1 -0
  568. package/dist/next/store/rows.js +183 -0
  569. package/dist/next/store/rows.js.map +1 -0
  570. package/dist/next/store/schema.d.ts +25 -0
  571. package/dist/next/store/schema.d.ts.map +1 -0
  572. package/dist/next/store/schema.js +115 -0
  573. package/dist/next/store/schema.js.map +1 -0
  574. package/dist/next/store/sql.d.ts +73 -0
  575. package/dist/next/store/sql.d.ts.map +1 -0
  576. package/dist/next/store/sql.js +234 -0
  577. package/dist/next/store/sql.js.map +1 -0
  578. package/dist/next/store/step.d.ts +48 -0
  579. package/dist/next/store/step.d.ts.map +1 -0
  580. package/dist/next/store/step.js +50 -0
  581. package/dist/next/store/step.js.map +1 -0
  582. package/dist/next/store/store.d.ts +161 -0
  583. package/dist/next/store/store.d.ts.map +1 -0
  584. package/dist/next/store/store.js +627 -0
  585. package/dist/next/store/store.js.map +1 -0
  586. package/dist/next/store/table-changes.d.ts +29 -0
  587. package/dist/next/store/table-changes.d.ts.map +1 -0
  588. package/dist/next/store/table-changes.js +102 -0
  589. package/dist/next/store/table-changes.js.map +1 -0
  590. package/dist/next/store/table-evolve.d.ts +74 -0
  591. package/dist/next/store/table-evolve.d.ts.map +1 -0
  592. package/dist/next/store/table-evolve.js +201 -0
  593. package/dist/next/store/table-evolve.js.map +1 -0
  594. package/dist/next/store/table-handle.d.ts +67 -0
  595. package/dist/next/store/table-handle.d.ts.map +1 -0
  596. package/dist/next/store/table-handle.js +101 -0
  597. package/dist/next/store/table-handle.js.map +1 -0
  598. package/dist/next/store/table-history.d.ts +75 -0
  599. package/dist/next/store/table-history.d.ts.map +1 -0
  600. package/dist/next/store/table-history.js +42 -0
  601. package/dist/next/store/table-history.js.map +1 -0
  602. package/dist/next/store/table-migration.d.ts +16 -0
  603. package/dist/next/store/table-migration.d.ts.map +1 -0
  604. package/dist/next/store/table-migration.js +202 -0
  605. package/dist/next/store/table-migration.js.map +1 -0
  606. package/dist/next/store/table-writes.d.ts +125 -0
  607. package/dist/next/store/table-writes.d.ts.map +1 -0
  608. package/dist/next/store/table-writes.js +165 -0
  609. package/dist/next/store/table-writes.js.map +1 -0
  610. package/dist/next/store/table.d.ts +80 -0
  611. package/dist/next/store/table.d.ts.map +1 -0
  612. package/dist/next/store/table.js +103 -0
  613. package/dist/next/store/table.js.map +1 -0
  614. package/dist/next/store/text.d.ts +14 -0
  615. package/dist/next/store/text.d.ts.map +1 -0
  616. package/dist/next/store/text.js +51 -0
  617. package/dist/next/store/text.js.map +1 -0
  618. package/dist/next/store/writes.d.ts +5 -0
  619. package/dist/next/store/writes.d.ts.map +1 -0
  620. package/dist/next/store/writes.js +4 -0
  621. package/dist/next/store/writes.js.map +1 -0
  622. package/dist/next-node/compression.d.ts +7 -0
  623. package/dist/next-node/compression.d.ts.map +1 -0
  624. package/dist/next-node/compression.js +24 -0
  625. package/dist/next-node/compression.js.map +1 -0
  626. package/dist/next-node/http/admission.d.ts +63 -0
  627. package/dist/next-node/http/admission.d.ts.map +1 -0
  628. package/dist/next-node/http/admission.js +134 -0
  629. package/dist/next-node/http/admission.js.map +1 -0
  630. package/dist/next-node/http/authenticate.d.ts +21 -0
  631. package/dist/next-node/http/authenticate.d.ts.map +1 -0
  632. package/dist/next-node/http/authenticate.js +34 -0
  633. package/dist/next-node/http/authenticate.js.map +1 -0
  634. package/dist/next-node/http/cookies.d.ts +24 -0
  635. package/dist/next-node/http/cookies.d.ts.map +1 -0
  636. package/dist/next-node/http/cookies.js +62 -0
  637. package/dist/next-node/http/cookies.js.map +1 -0
  638. package/dist/next-node/http/file.d.ts +23 -0
  639. package/dist/next-node/http/file.d.ts.map +1 -0
  640. package/dist/next-node/http/file.js +94 -0
  641. package/dist/next-node/http/file.js.map +1 -0
  642. package/dist/next-node/http/headers.d.ts +37 -0
  643. package/dist/next-node/http/headers.d.ts.map +1 -0
  644. package/dist/next-node/http/headers.js +129 -0
  645. package/dist/next-node/http/headers.js.map +1 -0
  646. package/dist/next-node/http/http.d.ts +100 -0
  647. package/dist/next-node/http/http.d.ts.map +1 -0
  648. package/dist/next-node/http/http.js +462 -0
  649. package/dist/next-node/http/http.js.map +1 -0
  650. package/dist/next-node/http/incoming.d.ts +19 -0
  651. package/dist/next-node/http/incoming.d.ts.map +1 -0
  652. package/dist/next-node/http/incoming.js +31 -0
  653. package/dist/next-node/http/incoming.js.map +1 -0
  654. package/dist/next-node/http/index.d.ts +11 -0
  655. package/dist/next-node/http/index.d.ts.map +1 -0
  656. package/dist/next-node/http/index.js +12 -0
  657. package/dist/next-node/http/index.js.map +1 -0
  658. package/dist/next-node/http/node.d.ts +78 -0
  659. package/dist/next-node/http/node.d.ts.map +1 -0
  660. package/dist/next-node/http/node.js +291 -0
  661. package/dist/next-node/http/node.js.map +1 -0
  662. package/dist/next-node/http/request.d.ts +54 -0
  663. package/dist/next-node/http/request.d.ts.map +1 -0
  664. package/dist/next-node/http/request.js +116 -0
  665. package/dist/next-node/http/request.js.map +1 -0
  666. package/dist/next-node/http/response.d.ts +63 -0
  667. package/dist/next-node/http/response.d.ts.map +1 -0
  668. package/dist/next-node/http/response.js +202 -0
  669. package/dist/next-node/http/response.js.map +1 -0
  670. package/dist/next-node/http/router.d.ts +114 -0
  671. package/dist/next-node/http/router.d.ts.map +1 -0
  672. package/dist/next-node/http/router.js +261 -0
  673. package/dist/next-node/http/router.js.map +1 -0
  674. package/dist/next-node/http/upgrades.d.ts +58 -0
  675. package/dist/next-node/http/upgrades.d.ts.map +1 -0
  676. package/dist/next-node/http/upgrades.js +184 -0
  677. package/dist/next-node/http/upgrades.js.map +1 -0
  678. package/dist/next-node/plugins/build.d.ts +57 -0
  679. package/dist/next-node/plugins/build.d.ts.map +1 -0
  680. package/dist/next-node/plugins/build.js +334 -0
  681. package/dist/next-node/plugins/build.js.map +1 -0
  682. package/dist/next-node/plugins/discover.d.ts +36 -0
  683. package/dist/next-node/plugins/discover.d.ts.map +1 -0
  684. package/dist/next-node/plugins/discover.js +91 -0
  685. package/dist/next-node/plugins/discover.js.map +1 -0
  686. package/dist/next-node/plugins/evaluate.d.ts +33 -0
  687. package/dist/next-node/plugins/evaluate.d.ts.map +1 -0
  688. package/dist/next-node/plugins/evaluate.js +98 -0
  689. package/dist/next-node/plugins/evaluate.js.map +1 -0
  690. package/dist/next-node/plugins/index.d.ts +9 -0
  691. package/dist/next-node/plugins/index.d.ts.map +1 -0
  692. package/dist/next-node/plugins/index.js +11 -0
  693. package/dist/next-node/plugins/index.js.map +1 -0
  694. package/dist/next-node/plugins/install.d.ts +13 -0
  695. package/dist/next-node/plugins/install.d.ts.map +1 -0
  696. package/dist/next-node/plugins/install.js +37 -0
  697. package/dist/next-node/plugins/install.js.map +1 -0
  698. package/dist/next-node/plugins/plugins.d.ts +135 -0
  699. package/dist/next-node/plugins/plugins.d.ts.map +1 -0
  700. package/dist/next-node/plugins/plugins.js +206 -0
  701. package/dist/next-node/plugins/plugins.js.map +1 -0
  702. package/dist/next-node/plugins/runtime.d.ts +41 -0
  703. package/dist/next-node/plugins/runtime.d.ts.map +1 -0
  704. package/dist/next-node/plugins/runtime.js +136 -0
  705. package/dist/next-node/plugins/runtime.js.map +1 -0
  706. package/dist/next-node/plugins/stack.d.ts +16 -0
  707. package/dist/next-node/plugins/stack.d.ts.map +1 -0
  708. package/dist/next-node/plugins/stack.js +61 -0
  709. package/dist/next-node/plugins/stack.js.map +1 -0
  710. package/dist/next-node/plugins/watcher.d.ts +58 -0
  711. package/dist/next-node/plugins/watcher.d.ts.map +1 -0
  712. package/dist/next-node/plugins/watcher.js +281 -0
  713. package/dist/next-node/plugins/watcher.js.map +1 -0
  714. package/dist/next-node/workers/control.d.ts +83 -0
  715. package/dist/next-node/workers/control.d.ts.map +1 -0
  716. package/dist/next-node/workers/control.js +77 -0
  717. package/dist/next-node/workers/control.js.map +1 -0
  718. package/dist/next-node/workers/index.d.ts +5 -0
  719. package/dist/next-node/workers/index.d.ts.map +1 -0
  720. package/dist/next-node/workers/index.js +7 -0
  721. package/dist/next-node/workers/index.js.map +1 -0
  722. package/dist/next-node/workers/lock.d.ts +21 -0
  723. package/dist/next-node/workers/lock.d.ts.map +1 -0
  724. package/dist/next-node/workers/lock.js +137 -0
  725. package/dist/next-node/workers/lock.js.map +1 -0
  726. package/dist/next-node/workers/main.d.ts +46 -0
  727. package/dist/next-node/workers/main.d.ts.map +1 -0
  728. package/dist/next-node/workers/main.js +230 -0
  729. package/dist/next-node/workers/main.js.map +1 -0
  730. package/dist/next-node/workers/process.d.ts +42 -0
  731. package/dist/next-node/workers/process.d.ts.map +1 -0
  732. package/dist/next-node/workers/process.js +125 -0
  733. package/dist/next-node/workers/process.js.map +1 -0
  734. package/dist/next-node/workers/workers.d.ts +80 -0
  735. package/dist/next-node/workers/workers.d.ts.map +1 -0
  736. package/dist/next-node/workers/workers.js +572 -0
  737. package/dist/next-node/workers/workers.js.map +1 -0
  738. package/dist/object.d.ts +4 -4
  739. package/dist/object.d.ts.map +1 -1
  740. package/dist/object.js +3 -4
  741. package/dist/object.js.map +1 -1
  742. package/dist/output.d.ts +9 -3
  743. package/dist/output.d.ts.map +1 -1
  744. package/dist/output.js +21 -9
  745. package/dist/output.js.map +1 -1
  746. package/dist/remote.d.ts.map +1 -1
  747. package/dist/remote.js +2 -2
  748. package/dist/remote.js.map +1 -1
  749. package/dist/schema.d.ts +8 -4
  750. package/dist/schema.d.ts.map +1 -1
  751. package/dist/schema.js +180 -5
  752. package/dist/schema.js.map +1 -1
  753. package/dist/sqlite/cloudflare.d.ts +54 -0
  754. package/dist/sqlite/cloudflare.d.ts.map +1 -0
  755. package/dist/sqlite/cloudflare.js +144 -0
  756. package/dist/sqlite/cloudflare.js.map +1 -0
  757. package/dist/sqlite/database.d.ts +40 -0
  758. package/dist/sqlite/database.d.ts.map +1 -0
  759. package/dist/sqlite/database.js +2 -0
  760. package/dist/sqlite/database.js.map +1 -0
  761. package/dist/sqlite/index.d.ts +4 -0
  762. package/dist/sqlite/index.d.ts.map +1 -0
  763. package/dist/sqlite/index.js +3 -0
  764. package/dist/sqlite/index.js.map +1 -0
  765. package/dist/sqlite/migrations.d.ts +10 -0
  766. package/dist/sqlite/migrations.d.ts.map +1 -0
  767. package/dist/sqlite/migrations.js +33 -0
  768. package/dist/sqlite/migrations.js.map +1 -0
  769. package/dist/sqlite/node.d.ts +41 -0
  770. package/dist/sqlite/node.d.ts.map +1 -0
  771. package/dist/sqlite/node.js +191 -0
  772. package/dist/sqlite/node.js.map +1 -0
  773. package/dist/sqlite/schema.d.ts +3 -0
  774. package/dist/sqlite/schema.d.ts.map +1 -0
  775. package/dist/sqlite/schema.js +10 -0
  776. package/dist/sqlite/schema.js.map +1 -0
  777. package/dist/telemetry-sqlite/index.d.ts +24 -0
  778. package/dist/telemetry-sqlite/index.d.ts.map +1 -0
  779. package/dist/telemetry-sqlite/index.js +273 -0
  780. package/dist/telemetry-sqlite/index.js.map +1 -0
  781. package/dist/telemetry-sqlite/store.d.ts +9 -0
  782. package/dist/telemetry-sqlite/store.d.ts.map +1 -0
  783. package/dist/telemetry-sqlite/store.js +110 -0
  784. package/dist/telemetry-sqlite/store.js.map +1 -0
  785. package/dist/watch.d.ts +194 -0
  786. package/dist/watch.d.ts.map +1 -0
  787. package/dist/watch.js +383 -0
  788. package/dist/watch.js.map +1 -0
  789. package/dist/wire.d.ts +174 -193
  790. package/dist/wire.d.ts.map +1 -1
  791. package/dist/wire.js +81 -80
  792. package/dist/wire.js.map +1 -1
  793. package/docs/guide.md +15 -15
  794. package/docs/next/benchmarks.md +959 -0
  795. package/docs/next/decisions.md +2957 -0
  796. package/docs/next/dependencies/book.md +1671 -0
  797. package/docs/next/dependencies/index.html +2641 -0
  798. package/docs/next/dependencies/model.md +330 -0
  799. package/docs/next/design.md +2554 -0
  800. package/docs/next/durable-observers/book.md +432 -0
  801. package/docs/next/durable-observers/index.html +517 -0
  802. package/docs/next/flow-control/book.md +333 -0
  803. package/docs/next/flow-control/fold/index.html +265 -0
  804. package/docs/next/flow-control/index.html +548 -0
  805. package/docs/next/flow-control/window/index.html +228 -0
  806. package/docs/next/guide-plugins-hosts/book.md +607 -0
  807. package/docs/next/guide-plugins-hosts/index.html +652 -0
  808. package/docs/next/http-workers/book.md +378 -0
  809. package/docs/next/http-workers/index.html +515 -0
  810. package/docs/next/layer-1.md +311 -0
  811. package/docs/next/layer-2.md +216 -0
  812. package/docs/next/plugin-model/book.md +186 -0
  813. package/docs/next/plugin-model/index.html +310 -0
  814. package/docs/next/plugin-primer/book.md +273 -0
  815. package/docs/next/plugin-primer/index.html +430 -0
  816. package/docs/next/slice-1.md +236 -0
  817. package/docs/next/slice-10.md +285 -0
  818. package/docs/next/slice-11.md +93 -0
  819. package/docs/next/slice-2.md +174 -0
  820. package/docs/next/slice-3a.md +296 -0
  821. package/docs/next/slice-3b.md +197 -0
  822. package/docs/next/slice-4.md +146 -0
  823. package/docs/next/slice-4a.md +418 -0
  824. package/docs/next/slice-4b.md +208 -0
  825. package/docs/next/slice-5.md +281 -0
  826. package/docs/next/slice-6a.md +676 -0
  827. package/docs/next/slice-6b.md +332 -0
  828. package/docs/next/slice-7a.md +130 -0
  829. package/docs/next/slice-7b/book.md +608 -0
  830. package/docs/next/slice-7b/index.html +842 -0
  831. package/docs/next/slice-7b.md +255 -0
  832. package/docs/next/slice-7c.md +165 -0
  833. package/docs/next/slice-8.md +194 -0
  834. package/docs/next/slices.md +230 -0
  835. package/docs/next/store/book.md +665 -0
  836. package/docs/next/store/index.html +861 -0
  837. package/docs/next/store/walkthrough.md +193 -0
  838. package/docs/spec.md +9 -9
  839. package/docs/tutorial.md +26 -25
  840. package/package.json +42 -5
  841. package/src/delta/README.md +69 -0
@@ -0,0 +1,33 @@
1
+ import type { Principal } from "../../next/data/index.ts";
2
+ import type { Facet } from "../../next/host/index.ts";
3
+ import type { BuiltFacet } from "./build.ts";
4
+ import type { Plugin } from "./discover.ts";
5
+ /**
6
+ * The host packages by specifier, each what Node's `require` would give: a CommonJS package's exports, an ESM
7
+ * package's namespace (`import * as`), wrapped once so default and named imports both work.
8
+ */
9
+ export type HostPackages = Readonly<Record<string, unknown>>;
10
+ /** What `evaluateFacet` takes besides the script: the host packages and the plugin it was built from. */
11
+ export type EvaluateOptions = {
12
+ readonly hostPackages: HostPackages;
13
+ readonly plugin: Plugin;
14
+ };
15
+ /** A built script, as evaluation takes it. */
16
+ export type BuiltScript = Extract<BuiltFacet, {
17
+ readonly kind: "script";
18
+ }>;
19
+ /**
20
+ * Evaluates `built` and returns its facet (its default export). Throws what the script throws while it is evaluated,
21
+ * an import its `require` does not answer, or a declaration error when its default export is not a facet.
22
+ */
23
+ export declare function evaluateFacet<P extends Principal = Principal>(built: BuiltScript, options: EvaluateOptions): Facet<P>;
24
+ /**
25
+ * Inside a facet script, the absolute path of `path`, a file of the facet's own plugin (`..` out of its directory
26
+ * refused); evaluation gives each facet its own. Imported anywhere else, it throws.
27
+ */
28
+ export declare function pluginFile(path: string): string;
29
+ /** The one specifier of this component a script imports (`pluginFile`): external always, answered per facet. */
30
+ export declare const PLUGINS_SPECIFIER = "@earendil-works/chord/next/plugins";
31
+ /** The package a bare specifier names: `@scope/name` or `name`, without a subpath. */
32
+ export declare function packageName(specifier: string): string;
33
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../../src/next-node/plugins/evaluate.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG5C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE7D,yGAAyG;AACzG,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/F,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAE3E;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC,CA2BrH;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,gHAAgH;AAChH,eAAO,MAAM,iBAAiB,uCAAuC,CAAC;AAsBtE,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGrD"}
@@ -0,0 +1,98 @@
1
+ // Evaluating (slice 7c §3): a built script run with `vm.Script` in this context under a stable filename per (plugin,
2
+ // kind, digest), given the `require` that answers its external imports: the host packages (one instance per process),
3
+ // this component's `pluginFile` bound to the plugin's directory, and `chord.external` packages and Node builtins from
4
+ // the plugin's own `node_modules`. No module map and no cache: an old facet's closures are collected once nothing holds
5
+ // them.
6
+ import { createRequire, isBuiltin } from "node:module";
7
+ import { basename, isAbsolute, join, relative, resolve } from "node:path";
8
+ import { Script } from "node:vm";
9
+ import { registerScript } from "./stack.js";
10
+ /**
11
+ * Evaluates `built` and returns its facet (its default export). Throws what the script throws while it is evaluated,
12
+ * an import its `require` does not answer, or a declaration error when its default export is not a facet.
13
+ */
14
+ export function evaluateFacet(built, options) {
15
+ const { plugin, hostPackages } = options;
16
+ const where = `plugin "${plugin.name}" (${built.facet})`;
17
+ const file = plugin.facets[built.facet] ?? `${built.facet}.js`;
18
+ const filename = `/chord-plugins/${plugin.name}/${basename(file)}?${built.digest}`;
19
+ // The script is one function expression: its value when run.
20
+ const wrapper = new Script(built.source, { filename }).runInThisContext();
21
+ const module = { exports: {} };
22
+ let facet;
23
+ try {
24
+ wrapper(requireFor(plugin, hostPackages, where), module, module.exports);
25
+ // A trust boundary: plugin code; its default export is checked to be a facet (a getter of it may throw too).
26
+ facet = module.exports?.default;
27
+ if (typeof facet !== "object" || facet === null || typeof facet.setup !== "function") {
28
+ throw new Error(`${where}: its default export is not a facet (defineFacet)`);
29
+ }
30
+ }
31
+ catch (error) {
32
+ // Its stack maps while the error lives (an import-time throw names the plugin's line).
33
+ if (typeof error === "object" && error !== null)
34
+ registerScript(filename, built.source, plugin.dir, error);
35
+ throw error;
36
+ }
37
+ registerScript(filename, built.source, plugin.dir, facet);
38
+ return facet;
39
+ }
40
+ /**
41
+ * Inside a facet script, the absolute path of `path`, a file of the facet's own plugin (`..` out of its directory
42
+ * refused); evaluation gives each facet its own. Imported anywhere else, it throws.
43
+ */
44
+ export function pluginFile(path) {
45
+ throw new Error(`pluginFile("${path}"): only a plugin's facet script, evaluated by the plugins component, has one`);
46
+ }
47
+ /** The one specifier of this component a script imports (`pluginFile`): external always, answered per facet. */
48
+ export const PLUGINS_SPECIFIER = "@earendil-works/chord/next/plugins";
49
+ /** The `require` a facet script of `plugin` takes (`where` names the facet in its errors). */
50
+ function requireFor(plugin, hostPackages, where) {
51
+ let fromPlugin;
52
+ let plugins;
53
+ return (specifier) => {
54
+ if (Object.hasOwn(hostPackages, specifier))
55
+ return interop(hostPackages[specifier]);
56
+ if (specifier === PLUGINS_SPECIFIER) {
57
+ plugins ??= { pluginFile: (path) => fileOf(plugin, path) };
58
+ return plugins;
59
+ }
60
+ if (isBuiltin(specifier) || plugin.external.includes(packageName(specifier))) {
61
+ fromPlugin ??= createRequire(join(plugin.dir, "package.json"));
62
+ return fromPlugin(specifier);
63
+ }
64
+ throw new Error(`${where}: "${specifier}" is not a host package, a Node builtin or one of its chord.external packages`);
65
+ };
66
+ }
67
+ /** The package a bare specifier names: `@scope/name` or `name`, without a subpath. */
68
+ export function packageName(specifier) {
69
+ const parts = specifier.split("/");
70
+ return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
71
+ }
72
+ /** The absolute path of `path` inside `plugin`'s directory; one out of it is refused. */
73
+ function fileOf(plugin, path) {
74
+ const file = resolve(plugin.dir, path);
75
+ const rest = relative(plugin.dir, file);
76
+ if (rest.startsWith("..") || isAbsolute(rest)) {
77
+ throw new Error(`pluginFile("${path}"): outside the directory of plugin "${plugin.name}"`);
78
+ }
79
+ return file;
80
+ }
81
+ /** ESM namespaces wrapped for a CommonJS script, by namespace: one wrapper per namespace, held as long as it is. */
82
+ const wrapped = new WeakMap();
83
+ /**
84
+ * A host package as a CommonJS script imports it: an ESM namespace wrapped once with `__esModule` (so esbuild's interop
85
+ * reads its `default` for a default import, its names for named ones), any other value as it is.
86
+ */
87
+ function interop(value) {
88
+ if (typeof value !== "object" || value === null || Object.prototype.toString.call(value) !== "[object Module]") {
89
+ return value;
90
+ }
91
+ let made = wrapped.get(value);
92
+ if (made === undefined) {
93
+ made = { ...value, __esModule: true };
94
+ wrapped.set(value, made);
95
+ }
96
+ return made;
97
+ }
98
+ //# sourceMappingURL=evaluate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../../src/next-node/plugins/evaluate.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,sHAAsH;AACtH,sHAAsH;AACtH,wHAAwH;AACxH,QAAQ;AAER,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAKjC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAc5C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAkC,KAAkB,EAAE,OAAwB;IAC1G,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACzC,MA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AAC","sourcesContent":["// Evaluating (slice 7c §3): a built script run with `vm.Script` in this context under a stable filename per (plugin,\n// kind, digest), given the `require` that answers its external imports: the host packages (one instance per process),\n// this component's `pluginFile` bound to the plugin's directory, and `chord.external` packages and Node builtins from\n// the plugin's own `node_modules`. No module map and no cache: an old facet's closures are collected once nothing holds\n// them.\n\nimport { createRequire, isBuiltin } from \"node:module\";\nimport { basename, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { Script } from \"node:vm\";\nimport type { Principal } from \"../../next/data/index.ts\";\nimport type { Facet } from \"../../next/host/index.ts\";\nimport type { BuiltFacet } from \"./build.ts\";\nimport type { Plugin } from \"./discover.ts\";\nimport { registerScript } from \"./stack.ts\";\n\n/**\n * The host packages by specifier, each what Node's `require` would give: a CommonJS package's exports, an ESM\n * package's namespace (`import * as`), wrapped once so default and named imports both work.\n */\nexport type HostPackages = Readonly<Record<string, unknown>>;\n\n/** What `evaluateFacet` takes besides the script: the host packages and the plugin it was built from. */\nexport type EvaluateOptions = { readonly hostPackages: HostPackages; readonly plugin: Plugin };\n\n/** A built script, as evaluation takes it. */\nexport type BuiltScript = Extract<BuiltFacet, { readonly kind: \"script\" }>;\n\n/**\n * Evaluates `built` and returns its facet (its default export). Throws what the script throws while it is evaluated,\n * an import its `require` does not answer, or a declaration error when its default export is not a facet.\n */\nexport function evaluateFacet<P extends Principal = Principal>(built: BuiltScript, options: EvaluateOptions): Facet<P> {\n\tconst { plugin, hostPackages } = options;\n\tconst where = `plugin \"${plugin.name}\" (${built.facet})`;\n\tconst file = plugin.facets[built.facet] ?? `${built.facet}.js`;\n\tconst filename = `/chord-plugins/${plugin.name}/${basename(file)}?${built.digest}`;\n\t// The script is one function expression: its value when run.\n\tconst wrapper = new Script(built.source, { filename }).runInThisContext() as (\n\t\trequire: (specifier: string) => unknown,\n\t\tmodule: { exports: unknown },\n\t\texports: unknown,\n\t) => void;\n\tconst module = { exports: {} as unknown };\n\tlet facet: unknown;\n\ttry {\n\t\twrapper(requireFor(plugin, hostPackages, where), module, module.exports);\n\t\t// A trust boundary: plugin code; its default export is checked to be a facet (a getter of it may throw too).\n\t\tfacet = (module.exports as { readonly default?: unknown } | null)?.default;\n\t\tif (typeof facet !== \"object\" || facet === null || typeof (facet as { setup?: unknown }).setup !== \"function\") {\n\t\t\tthrow new Error(`${where}: its default export is not a facet (defineFacet)`);\n\t\t}\n\t} catch (error) {\n\t\t// Its stack maps while the error lives (an import-time throw names the plugin's line).\n\t\tif (typeof error === \"object\" && error !== null) registerScript(filename, built.source, plugin.dir, error);\n\t\tthrow error;\n\t}\n\tregisterScript(filename, built.source, plugin.dir, facet);\n\treturn facet as Facet<P>;\n}\n\n/**\n * Inside a facet script, the absolute path of `path`, a file of the facet's own plugin (`..` out of its directory\n * refused); evaluation gives each facet its own. Imported anywhere else, it throws.\n */\nexport function pluginFile(path: string): string {\n\tthrow new Error(`pluginFile(\"${path}\"): only a plugin's facet script, evaluated by the plugins component, has one`);\n}\n\n/** The one specifier of this component a script imports (`pluginFile`): external always, answered per facet. */\nexport const PLUGINS_SPECIFIER = \"@earendil-works/chord/next/plugins\";\n\n/** The `require` a facet script of `plugin` takes (`where` names the facet in its errors). */\nfunction requireFor(plugin: Plugin, hostPackages: HostPackages, where: string): (specifier: string) => unknown {\n\tlet fromPlugin: NodeJS.Require | undefined;\n\tlet plugins: { readonly pluginFile: (path: string) => string } | undefined;\n\treturn (specifier) => {\n\t\tif (Object.hasOwn(hostPackages, specifier)) return interop(hostPackages[specifier]);\n\t\tif (specifier === PLUGINS_SPECIFIER) {\n\t\t\tplugins ??= { pluginFile: (path) => fileOf(plugin, path) };\n\t\t\treturn plugins;\n\t\t}\n\t\tif (isBuiltin(specifier) || plugin.external.includes(packageName(specifier))) {\n\t\t\tfromPlugin ??= createRequire(join(plugin.dir, \"package.json\"));\n\t\t\treturn fromPlugin(specifier);\n\t\t}\n\t\tthrow new Error(\n\t\t\t`${where}: \"${specifier}\" is not a host package, a Node builtin or one of its chord.external packages`,\n\t\t);\n\t};\n}\n\n/** The package a bare specifier names: `@scope/name` or `name`, without a subpath. */\nexport function packageName(specifier: string): string {\n\tconst parts = specifier.split(\"/\");\n\treturn specifier.startsWith(\"@\") ? parts.slice(0, 2).join(\"/\") : parts[0]!;\n}\n\n/** The absolute path of `path` inside `plugin`'s directory; one out of it is refused. */\nfunction fileOf(plugin: Plugin, path: string): string {\n\tconst file = resolve(plugin.dir, path);\n\tconst rest = relative(plugin.dir, file);\n\tif (rest.startsWith(\"..\") || isAbsolute(rest)) {\n\t\tthrow new Error(`pluginFile(\"${path}\"): outside the directory of plugin \"${plugin.name}\"`);\n\t}\n\treturn file;\n}\n\n/** ESM namespaces wrapped for a CommonJS script, by namespace: one wrapper per namespace, held as long as it is. */\nconst wrapped = new WeakMap<object, object>();\n\n/**\n * A host package as a CommonJS script imports it: an ESM namespace wrapped once with `__esModule` (so esbuild's interop\n * reads its `default` for a default import, its names for named ones), any other value as it is.\n */\nfunction interop(value: unknown): unknown {\n\tif (typeof value !== \"object\" || value === null || Object.prototype.toString.call(value) !== \"[object Module]\") {\n\t\treturn value;\n\t}\n\tlet made = wrapped.get(value);\n\tif (made === undefined) {\n\t\tmade = { ...value, __esModule: true };\n\t\twrapped.set(value, made);\n\t}\n\treturn made;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export { type BuildInput, type BuildOptions, type BuiltFacet, buildFacet } from "./build.ts";
2
+ export { type Discovery, type DiscoveryOptions, type DiscoveryProblem, discoverPlugins, type Plugin, } from "./discover.ts";
3
+ export { type BuiltScript, type EvaluateOptions, evaluateFacet, type HostPackages, pluginFile } from "./evaluate.ts";
4
+ export { type InstallOptions, installDependencies } from "./install.ts";
5
+ export { type Built, createPlugins, type KindDefinition, type Plugins, type PluginsError, type PluginsOptions, type RolloutHost, type RolloutResult, type RolloutStep, } from "./plugins.ts";
6
+ export { createPluginRuntime, type PluginRuntime, type PluginScript, type RuntimeLoad } from "./runtime.ts";
7
+ export { mapStack } from "./stack.ts";
8
+ export type { PluginsState } from "./watcher.ts";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/next-node/plugins/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EACN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,eAAe,EACf,KAAK,MAAM,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrH,OAAO,EAAE,KAAK,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EACN,KAAK,KAAK,EACV,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,WAAW,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,11 @@
1
+ // Chord v2's plugins component (`@earendil-works/chord/next/plugins` once v2 has its entry point; slice 7c): plugin
2
+ // directories found, built into scripts, evaluated, loaded and reloaded per plugin, watched and rolled out. Node-only
3
+ // (`fs`, esbuild, `vm`); esbuild is an optional peer dependency, imported only here.
4
+ export { buildFacet } from "./build.js";
5
+ export { discoverPlugins, } from "./discover.js";
6
+ export { evaluateFacet, pluginFile } from "./evaluate.js";
7
+ export { installDependencies } from "./install.js";
8
+ export { createPlugins, } from "./plugins.js";
9
+ export { createPluginRuntime } from "./runtime.js";
10
+ export { mapStack } from "./stack.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/next-node/plugins/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,sHAAsH;AACtH,qFAAqF;AAErF,OAAO,EAAuD,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EAIN,eAAe,GAEf,MAAM,eAAe,CAAC;AACvB,OAAO,EAA0C,aAAa,EAAqB,UAAU,EAAE,MAAM,eAAe,CAAC;AACrH,OAAO,EAAuB,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAEN,aAAa,GAQb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAA2D,MAAM,cAAc,CAAC;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC","sourcesContent":["// Chord v2's plugins component (`@earendil-works/chord/next/plugins` once v2 has its entry point; slice 7c): plugin\n// directories found, built into scripts, evaluated, loaded and reloaded per plugin, watched and rolled out. Node-only\n// (`fs`, esbuild, `vm`); esbuild is an optional peer dependency, imported only here.\n\nexport { type BuildInput, type BuildOptions, type BuiltFacet, buildFacet } from \"./build.ts\";\nexport {\n\ttype Discovery,\n\ttype DiscoveryOptions,\n\ttype DiscoveryProblem,\n\tdiscoverPlugins,\n\ttype Plugin,\n} from \"./discover.ts\";\nexport { type BuiltScript, type EvaluateOptions, evaluateFacet, type HostPackages, pluginFile } from \"./evaluate.ts\";\nexport { type InstallOptions, installDependencies } from \"./install.ts\";\nexport {\n\ttype Built,\n\tcreatePlugins,\n\ttype KindDefinition,\n\ttype Plugins,\n\ttype PluginsError,\n\ttype PluginsOptions,\n\ttype RolloutHost,\n\ttype RolloutResult,\n\ttype RolloutStep,\n} from \"./plugins.ts\";\nexport { createPluginRuntime, type PluginRuntime, type PluginScript, type RuntimeLoad } from \"./runtime.ts\";\nexport { mapStack } from \"./stack.ts\";\nexport type { PluginsState } from \"./watcher.ts\";\n"]}
@@ -0,0 +1,13 @@
1
+ import type { Context } from "../../context/index.ts";
2
+ import type { Plugin } from "./discover.ts";
3
+ /** What `installDependencies` takes besides the plugin: the npm command (`["npm"]` by default, e.g. `["pnpm"]`). */
4
+ export type InstallOptions = {
5
+ readonly npmCommand?: readonly string[];
6
+ };
7
+ /**
8
+ * Installs `plugin`'s `dependencies` into its own `node_modules` (`npm install --omit=dev --legacy-peer-deps
9
+ * --ignore-scripts --no-audit --no-fund` in its real directory). Rejects with the command's output when it fails, and
10
+ * when `context` aborts (the command is killed).
11
+ */
12
+ export declare function installDependencies(plugin: Plugin, context: Context, options?: InstallOptions): Promise<void>;
13
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/next-node/plugins/install.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,oHAAoH;AACpH,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAKzE;;;;GAIG;AACH,wBAAsB,mBAAmB,CACxC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,cAAmB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAuBf"}
@@ -0,0 +1,37 @@
1
+ // Installing a plugin's npm dependencies (slice 7c §5, decision "Slice 7c's points" (3)): as coding-agent installs a
2
+ // package's dependencies, `npm install` in the plugin's real directory without dev dependencies, host peers or
3
+ // lifecycle scripts; the command overridable.
4
+ import { spawn } from "node:child_process";
5
+ /** The install's arguments: production dependencies only, no host peers, no scripts, no audit or funding notes. */
6
+ const INSTALL_ARGS = ["install", "--omit=dev", "--legacy-peer-deps", "--ignore-scripts", "--no-audit", "--no-fund"];
7
+ /**
8
+ * Installs `plugin`'s `dependencies` into its own `node_modules` (`npm install --omit=dev --legacy-peer-deps
9
+ * --ignore-scripts --no-audit --no-fund` in its real directory). Rejects with the command's output when it fails, and
10
+ * when `context` aborts (the command is killed).
11
+ */
12
+ export async function installDependencies(plugin, context, options = {}) {
13
+ const [command, ...prefix] = options.npmCommand ?? ["npm"];
14
+ if (command === undefined)
15
+ throw new Error("installDependencies: npmCommand is empty");
16
+ context.abortSignal?.throwIfAborted();
17
+ const child = spawn(command, [...prefix, ...INSTALL_ARGS], {
18
+ cwd: plugin.dir,
19
+ stdio: ["ignore", "pipe", "pipe"],
20
+ signal: context.abortSignal,
21
+ });
22
+ let output = "";
23
+ child.stdout.on("data", (chunk) => {
24
+ output += chunk.toString();
25
+ });
26
+ child.stderr.on("data", (chunk) => {
27
+ output += chunk.toString();
28
+ });
29
+ const code = await new Promise((resolve, reject) => {
30
+ child.on("error", reject);
31
+ child.on("close", resolve);
32
+ });
33
+ if (code !== 0) {
34
+ throw new Error(`plugin "${plugin.name}": ${command} install failed (exit ${code}): ${output.trim()}`);
35
+ }
36
+ }
37
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/next-node/plugins/install.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,+GAA+G;AAC/G,8CAA8C;AAE9C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAO3C,mHAAmH;AACnH,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;AAEpH;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,MAAc,EACd,OAAgB,EAChB,OAAO,GAAmB,EAAE;IAE5B,MAAM,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sourcesContent":["// Installing a plugin's npm dependencies (slice 7c §5, decision \"Slice 7c's points\" (3)): as coding-agent installs a\n// package's dependencies, `npm install` in the plugin's real directory without dev dependencies, host peers or\n// lifecycle scripts; the command overridable.\n\nimport { spawn } from \"node:child_process\";\nimport type { Context } from \"../../context/index.ts\";\nimport type { Plugin } from \"./discover.ts\";\n\n/** What `installDependencies` takes besides the plugin: the npm command (`[\"npm\"]` by default, e.g. `[\"pnpm\"]`). */\nexport type InstallOptions = { readonly npmCommand?: readonly string[] };\n\n/** The install's arguments: production dependencies only, no host peers, no scripts, no audit or funding notes. */\nconst INSTALL_ARGS = [\"install\", \"--omit=dev\", \"--legacy-peer-deps\", \"--ignore-scripts\", \"--no-audit\", \"--no-fund\"];\n\n/**\n * Installs `plugin`'s `dependencies` into its own `node_modules` (`npm install --omit=dev --legacy-peer-deps\n * --ignore-scripts --no-audit --no-fund` in its real directory). Rejects with the command's output when it fails, and\n * when `context` aborts (the command is killed).\n */\nexport async function installDependencies(\n\tplugin: Plugin,\n\tcontext: Context,\n\toptions: InstallOptions = {},\n): Promise<void> {\n\tconst [command, ...prefix] = options.npmCommand ?? [\"npm\"];\n\tif (command === undefined) throw new Error(\"installDependencies: npmCommand is empty\");\n\tcontext.abortSignal?.throwIfAborted();\n\tconst child = spawn(command, [...prefix, ...INSTALL_ARGS], {\n\t\tcwd: plugin.dir,\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\tsignal: context.abortSignal,\n\t});\n\tlet output = \"\";\n\tchild.stdout.on(\"data\", (chunk: Buffer) => {\n\t\toutput += chunk.toString();\n\t});\n\tchild.stderr.on(\"data\", (chunk: Buffer) => {\n\t\toutput += chunk.toString();\n\t});\n\tconst code = await new Promise<number | null>((resolve, reject) => {\n\t\tchild.on(\"error\", reject);\n\t\tchild.on(\"close\", resolve);\n\t});\n\tif (code !== 0) {\n\t\tthrow new Error(`plugin \"${plugin.name}\": ${command} install failed (exit ${code}): ${output.trim()}`);\n\t}\n}\n"]}
@@ -0,0 +1,135 @@
1
+ import type { Context } from "../../context/index.ts";
2
+ import type { Principal } from "../../next/data/index.ts";
3
+ import type { Host, LoadReport, PluginFacet, ReloadReport } from "../../next/host/index.ts";
4
+ import { type BatchError } from "../../next/state/internal.ts";
5
+ import type { Watchable } from "../../watch.ts";
6
+ import { type BuiltFacet } from "./build.ts";
7
+ import { type Discovery, type Plugin } from "./discover.ts";
8
+ import type { HostPackages } from "./evaluate.ts";
9
+ import { type InstallOptions } from "./install.ts";
10
+ import { type PluginScript } from "./runtime.ts";
11
+ import { type PluginsState } from "./watcher.ts";
12
+ /** What `createPlugins` takes. */
13
+ export type PluginsOptions = {
14
+ /** The directories plugins are listed in, in order: the first root's plugin wins a duplicate name. */
15
+ readonly roots: readonly string[];
16
+ /**
17
+ * The app's facet kinds (one file per kind in a plugin), each with where its builds run and the host packages they
18
+ * keep external: `{ server: { platform: "node", hostPackages: ["@earendil-works/chord/next", "@app/core"] }, … }`.
19
+ */
20
+ readonly kinds: Readonly<Record<string, KindDefinition>>;
21
+ /** The app's base code: a change sets `base` (the app restarts its hosts; Chord restarts nothing). */
22
+ readonly base?: readonly string[];
23
+ /** Where the app serves browser builds' assets: the URL prefix their imports evaluate to. */
24
+ readonly publicPath?: string;
25
+ /** How `installDependencies` runs npm. */
26
+ readonly install?: InstallOptions;
27
+ /** The watcher cannot watch (reported once), and the marks' watch listeners that threw. */
28
+ readonly onError: (error: PluginsError) => void;
29
+ };
30
+ /** One facet kind: Node or browser builds, and the host packages (by specifier) its builds keep external. */
31
+ export type KindDefinition = {
32
+ readonly platform: "node" | "browser";
33
+ readonly hostPackages: readonly string[];
34
+ };
35
+ /** What the component reports. */
36
+ export type PluginsError = BatchError | {
37
+ readonly kind: "watch_failed";
38
+ readonly error: unknown;
39
+ };
40
+ /**
41
+ * A build of some plugins, plain data (a clone of it reloads the same): every facet of each, the plugins as its
42
+ * discovery saw them by name (what a reload evaluates with), and the plugins no longer discovered.
43
+ */
44
+ export type Built = {
45
+ readonly facets: readonly BuiltFacet[];
46
+ readonly plugins: Readonly<Record<string, Plugin>>;
47
+ readonly removed: readonly string[];
48
+ };
49
+ /**
50
+ * What a rollout step did on one of its hosts (`host` named by the step): its reload's report; `stopped` when the host
51
+ * stopped cleanly during the step (it gets the current set at its next start); `error` when it crashed or its reload
52
+ * failed (every plugin of the step's kinds in the build counts as failed there).
53
+ */
54
+ export type RolloutHost = {
55
+ readonly host: string;
56
+ readonly report: ReloadReport;
57
+ } | {
58
+ readonly host: string;
59
+ readonly stopped: true;
60
+ } | {
61
+ readonly host: string;
62
+ readonly error: unknown;
63
+ };
64
+ /** What a rollout step does: reloads its hosts with the facets of its kinds, one result per host (D12). */
65
+ export type RolloutStep = {
66
+ readonly name: string;
67
+ readonly kinds: readonly string[];
68
+ reload(built: Built, context: Context): Promise<{
69
+ readonly hosts: readonly RolloutHost[];
70
+ }>;
71
+ };
72
+ /** What a rollout did: each step's hosts in order, and the step it stopped at (rejected), if it stopped. */
73
+ export type RolloutResult = {
74
+ readonly steps: readonly {
75
+ readonly name: string;
76
+ readonly hosts: readonly RolloutHost[];
77
+ }[];
78
+ readonly stopped: {
79
+ readonly step: string;
80
+ readonly error: unknown;
81
+ } | undefined;
82
+ };
83
+ /** The plugins component. */
84
+ export interface Plugins {
85
+ /** The marks: `{ dirty, install, set, base }`, a JSON watchable. */
86
+ readonly state: Watchable<PluginsState>;
87
+ /** The plugins of the last discovery. */
88
+ readonly discovery: Discovery;
89
+ /**
90
+ * Builds every facet of `names` (and of plugins discovered since the last build; discovery runs again first when
91
+ * the plugin set changed): plain data. It changes no current set: a rollout ships it.
92
+ */
93
+ build(names: readonly string[], context: Context): Promise<Built>;
94
+ /**
95
+ * The complete current set of `kind`: every discovered plugin's facet of it (built on first use), as the last
96
+ * rollout or reload shipping `kind` left it; what a worker starts with.
97
+ */
98
+ scripts(kind: string, context: Context): Promise<readonly PluginScript[]>;
99
+ /**
100
+ * `kind`'s current set now, synchronously (`undefined` before its first use): a rollout step reads it as the rollout
101
+ * applied its build, before another rollout can change it.
102
+ */
103
+ current(kind: string): readonly PluginScript[] | undefined;
104
+ /**
105
+ * Loads `host` with `kind`'s current set, evaluated with `modules` (the host packages, this process's instances, by
106
+ * specifier; kept for the host's reloads), and `core` (the app's own facets): a plugin whose build or evaluation
107
+ * fails is left out and reported with the host's report.
108
+ */
109
+ load<P extends Principal>(host: Host<P>, options: {
110
+ readonly kind: string;
111
+ readonly core: readonly PluginFacet<P>[];
112
+ readonly modules: HostPackages;
113
+ }, context: Context): Promise<LoadReport>;
114
+ /**
115
+ * Applies `built` to the current set of `host`'s kind (loaded by `load`) and reloads `host` with that complete set,
116
+ * after its earlier reloads (`PluginRuntime.reload`). The host's report.
117
+ */
118
+ reload<P extends Principal>(host: Host<P>, built: Built, context: Context): Promise<ReloadReport>;
119
+ /** An in-process rollout step named `name`: `reload(host, built)`, one host named `name`. */
120
+ step<P extends Principal>(name: string, host: Host<P>): RolloutStep;
121
+ /**
122
+ * Runs `steps` in order with `built`, applying it to the current set of each step's kinds right before that step,
123
+ * and stops at one that rejects; failed plugins and hosts do not stop it. Clears the dirty marks of the built
124
+ * plugins applied on every host of every step (not failed on any, every built kind of theirs shipped by a step)
125
+ * that did not change since the build.
126
+ */
127
+ rollout(steps: readonly RolloutStep[], built: Built, context: Context): Promise<RolloutResult>;
128
+ /** Installs plugin `name`'s dependencies (`installDependencies`): its install mark clears, and it is dirty. */
129
+ installDependencies(name: string, context: Context): Promise<void>;
130
+ /** Stops the watcher. */
131
+ close(): void;
132
+ }
133
+ /** Creates the plugins component (and its plugin runtime) and starts the watcher. Discovery runs at first use. */
134
+ export declare function createPlugins(options: PluginsOptions, _context: Context): Plugins;
135
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../../src/next-node/plugins/plugins.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,w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,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAClG,6FAA6F;IAC7F,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;IACpE;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/F,+GAA+G;IAC/G,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,yBAAyB;IACzB,KAAK,IAAI,IAAI,CAAC;CACd;AAED,kHAAkH;AAClH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAEjF"}
@@ -0,0 +1,206 @@
1
+ // The plugins component (slice 7c §4, §5; decision "Slice 7c's points"; slice 10 D11, D12): discovery, builds and the
2
+ // watcher, and per kind the complete current set of scripts (built on first use, updated by every rollout that ships
3
+ // the kind), which its plugin runtime loads and reloads hosts with: unchanged plugins as the same facet objects, removed
4
+ // ones left out, a failed build or evaluation keeping the plugin's loaded facet. `rollout` runs the app's steps in order
5
+ // (one result per host) and clears the marks of plugins applied on every host of every step.
6
+ import { Batch } from "../../next/state/internal.js";
7
+ import { buildFacet } from "./build.js";
8
+ import { discoverPlugins } from "./discover.js";
9
+ import { installDependencies } from "./install.js";
10
+ import { createPluginRuntime } from "./runtime.js";
11
+ import { PluginWatcher } from "./watcher.js";
12
+ /** Creates the plugins component (and its plugin runtime) and starts the watcher. Discovery runs at first use. */
13
+ export function createPlugins(options, _context) {
14
+ return new PluginsComponent(options);
15
+ }
16
+ class PluginsComponent {
17
+ #options;
18
+ #watcher;
19
+ #runtime;
20
+ #discovery = { plugins: [], problems: [] };
21
+ #discovered = false;
22
+ /** The latest build of every (plugin, kind) built so far, by `plugin\u0000kind`. */
23
+ #built = new Map();
24
+ /** The current set of each kind used so far, by plugin name. */
25
+ #current = new Map();
26
+ /** The kind each loaded host was loaded with, held as long as the host is. */
27
+ #kinds = new WeakMap();
28
+ /** The marks each build started from, held as long as its result is (a rollout given a copy clears none). */
29
+ #snapshots = new WeakMap();
30
+ constructor(options) {
31
+ this.#options = options;
32
+ this.#runtime = createPluginRuntime();
33
+ const batch = new Batch((error) => options.onError(error), undefined);
34
+ this.#watcher = new PluginWatcher({
35
+ roots: options.roots,
36
+ base: options.base ?? [],
37
+ kinds: Object.keys(options.kinds),
38
+ failed: (error) => options.onError({ kind: "watch_failed", error }),
39
+ }, batch);
40
+ }
41
+ get state() {
42
+ // Its value is a `PluginsState`.
43
+ return this.#watcher;
44
+ }
45
+ get discovery() {
46
+ return this.#discovery;
47
+ }
48
+ async build(names, context) {
49
+ const before = new Set(this.#discovery.plugins.map(({ name }) => name));
50
+ if (!this.#discovered || this.#watcher.needsDiscovery)
51
+ await this.#discover(context);
52
+ const now = this.#discovery.plugins;
53
+ const removed = [...before].filter((name) => !now.some((plugin) => plugin.name === name));
54
+ const wanted = now.filter(({ name }) => names.includes(name) || !before.has(name));
55
+ const snapshot = this.#watcher.snapshot([...wanted.map(({ name }) => name), ...removed]);
56
+ const facets = await Promise.all(wanted.flatMap((plugin) => Object.keys(plugin.facets).map((kind) => this.#buildOne(plugin, kind, context))));
57
+ const plugins = Object.fromEntries(wanted.map((plugin) => [plugin.name, plugin]));
58
+ const built = { facets, plugins, removed };
59
+ this.#snapshots.set(built, snapshot);
60
+ return built;
61
+ }
62
+ async scripts(kind, context) {
63
+ return [...(await this.#set(kind, context)).values()];
64
+ }
65
+ current(kind) {
66
+ const set = this.#current.get(kind);
67
+ return set === undefined ? undefined : [...set.values()];
68
+ }
69
+ async load(host, options, context) {
70
+ const { kind, core, modules } = options;
71
+ const scripts = await this.scripts(kind, context);
72
+ this.#kinds.set(host, kind);
73
+ return this.#runtime.load(host, { kind, core, scripts, modules }, context);
74
+ }
75
+ async reload(host, built, context) {
76
+ const kind = this.#kinds.get(host);
77
+ if (kind === undefined)
78
+ throw new Error("plugins.reload: the host was not loaded by this component");
79
+ const set = await this.#set(kind, context);
80
+ // Applied and read in one step: two reloads started together each pass the set their own build made.
81
+ ship(set, kind, built);
82
+ return this.#runtime.reload(host, [...set.values()], context);
83
+ }
84
+ step(name, host) {
85
+ const kind = this.#kinds.get(host);
86
+ if (kind === undefined)
87
+ throw new Error("plugins.step: the host was not loaded by this component");
88
+ return {
89
+ name,
90
+ kinds: [kind],
91
+ reload: async (built, context) => ({
92
+ hosts: [{ host: name, report: await this.reload(host, built, context) }],
93
+ }),
94
+ };
95
+ }
96
+ async rollout(steps, built, context) {
97
+ const done = [];
98
+ const failed = new Set();
99
+ const shipped = new Set();
100
+ for (const step of steps) {
101
+ let hosts;
102
+ try {
103
+ for (const kind of step.kinds)
104
+ ship(await this.#set(kind, context), kind, built);
105
+ hosts = (await step.reload(built, context)).hosts;
106
+ }
107
+ catch (error) {
108
+ return { steps: done, stopped: { step: step.name, error } };
109
+ }
110
+ for (const kind of step.kinds)
111
+ shipped.add(kind);
112
+ for (const entry of hosts) {
113
+ if ("report" in entry)
114
+ for (const { plugin } of entry.report.failed)
115
+ failed.add(plugin);
116
+ else if ("error" in entry)
117
+ for (const plugin of builtOf(built, step.kinds))
118
+ failed.add(plugin);
119
+ }
120
+ done.push({ name: step.name, hosts });
121
+ }
122
+ // A plugin with a built kind no step shipped is not applied everywhere it runs: it stays dirty.
123
+ for (const { plugin, facet } of built.facets)
124
+ if (!shipped.has(facet))
125
+ failed.add(plugin);
126
+ const snapshot = this.#snapshots.get(built);
127
+ if (snapshot !== undefined) {
128
+ this.#watcher.applied([...snapshot.plugins.keys()].filter((name) => !failed.has(name)), snapshot);
129
+ }
130
+ return { steps: done, stopped: undefined };
131
+ }
132
+ async installDependencies(name, context) {
133
+ if (!this.#discovered)
134
+ await this.#discover(context);
135
+ const plugin = this.#discovery.plugins.find((each) => each.name === name);
136
+ if (plugin === undefined)
137
+ throw new Error(`plugins.installDependencies: no plugin "${name}"`);
138
+ await installDependencies(plugin, context, this.#options.install);
139
+ this.#watcher.installed(name);
140
+ }
141
+ close() {
142
+ this.#watcher.close();
143
+ }
144
+ /** Discovers the plugins again; the changes of the plugin set and of `package.json`s seen until now clear. */
145
+ async #discover(context) {
146
+ const seen = this.#watcher.discoverySnapshot();
147
+ this.#discovery = await discoverPlugins(this.#options.roots, { kinds: Object.keys(this.#options.kinds) }, context);
148
+ this.#discovered = true;
149
+ this.#watcher.know(this.#discovery, seen);
150
+ }
151
+ /** `kind`'s current set, made at its first use from every discovered plugin's facet of it (built if needed). */
152
+ async #set(kind, context) {
153
+ let set = this.#current.get(kind);
154
+ if (set !== undefined)
155
+ return set;
156
+ if (!this.#discovered)
157
+ await this.#discover(context);
158
+ const plugins = this.#discovery.plugins.filter((plugin) => plugin.facets[kind] !== undefined);
159
+ const scripts = await Promise.all(plugins.map(async (plugin) => {
160
+ const built = this.#built.get(`${plugin.name}\u0000${kind}`) ?? (await this.#buildOne(plugin, kind, context));
161
+ return { plugin, built };
162
+ }));
163
+ // Built concurrently: a set made meanwhile (by a concurrent first use) wins.
164
+ set = this.#current.get(kind) ?? new Map(scripts.map((script) => [script.plugin.name, script]));
165
+ this.#current.set(kind, set);
166
+ return set;
167
+ }
168
+ /** Builds `plugin`'s facet of `kind` and keeps it as the latest; the watcher learns what it read. */
169
+ async #buildOne(plugin, kind, context) {
170
+ const { kinds, publicPath } = this.#options;
171
+ // Discovery finds facet files of the app's kinds only.
172
+ const { platform, hostPackages } = kinds[kind];
173
+ const options = {
174
+ hostPackages,
175
+ platform,
176
+ plugins: this.#discovery.plugins,
177
+ ...(publicPath === undefined ? {} : { publicPath }),
178
+ };
179
+ const built = await buildFacet(plugin, kind, options, context);
180
+ this.#built.set(`${plugin.name}\u0000${kind}`, built);
181
+ this.#watcher.used([built]);
182
+ return built;
183
+ }
184
+ }
185
+ /**
186
+ * Applies `built` to `set`, `kind`'s current set: its removed plugins and those rebuilt without a facet of `kind` leave
187
+ * it, its facets of `kind` replace theirs.
188
+ */
189
+ function ship(set, kind, built) {
190
+ for (const name of built.removed)
191
+ set.delete(name);
192
+ for (const [name, plugin] of Object.entries(built.plugins))
193
+ if (plugin.facets[kind] === undefined)
194
+ set.delete(name);
195
+ for (const facet of built.facets) {
196
+ // Own properties only: a plugin may be named like one of `Object.prototype`'s (`constructor`).
197
+ if (facet.facet === kind && Object.hasOwn(built.plugins, facet.plugin)) {
198
+ set.set(facet.plugin, { plugin: built.plugins[facet.plugin], built: facet });
199
+ }
200
+ }
201
+ }
202
+ /** The plugins of `built` with a facet of one of `kinds`. */
203
+ function builtOf(built, kinds) {
204
+ return built.facets.filter(({ facet }) => kinds.includes(facet)).map(({ plugin }) => plugin);
205
+ }
206
+ //# sourceMappingURL=plugins.js.map