@powerhousedao/shared 6.2.3-dev.9 → 6.2.3-dev.90

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 (351) hide show
  1. package/dist/action-id-DON1WCeY.d.ts +19 -0
  2. package/dist/action-id-DON1WCeY.d.ts.map +1 -0
  3. package/dist/analytics/index.d.ts +4 -4
  4. package/dist/analytics/index.d.ts.map +1 -1
  5. package/dist/analytics/index.js +25 -24
  6. package/dist/analytics/index.js.map +1 -1
  7. package/dist/clis/args/access-token.d.mts +15 -2
  8. package/dist/clis/args/access-token.d.mts.map +1 -0
  9. package/dist/clis/args/access-token.mjs +21 -1
  10. package/dist/clis/args/access-token.mjs.map +1 -0
  11. package/dist/clis/args/common-BpLj4peE.d.mts +186 -0
  12. package/dist/clis/args/common-BpLj4peE.d.mts.map +1 -0
  13. package/dist/clis/args/{common-CcYbXrBx.mjs → common-CBLen_yt.mjs} +58 -12
  14. package/dist/clis/args/common-CBLen_yt.mjs.map +1 -0
  15. package/dist/clis/args/common.d.mts +3 -2
  16. package/dist/clis/args/common.mjs +1 -1
  17. package/dist/clis/args/connect.d.mts +449 -2
  18. package/dist/clis/args/connect.d.mts.map +1 -0
  19. package/dist/clis/args/connect.mjs +202 -1
  20. package/dist/clis/args/connect.mjs.map +1 -0
  21. package/dist/clis/args/{generate-CA916Fvj.mjs → generate-a36SaAn4.mjs} +40 -2
  22. package/dist/clis/args/generate-a36SaAn4.mjs.map +1 -0
  23. package/dist/clis/args/generate.d.mts +102 -2
  24. package/dist/clis/args/generate.d.mts.map +1 -0
  25. package/dist/clis/args/generate.mjs +1 -1
  26. package/dist/clis/args/help-Cgh3krcq.d.mts +239 -0
  27. package/dist/clis/args/help-Cgh3krcq.d.mts.map +1 -0
  28. package/dist/clis/args/{help-Bqbgbalu.mjs → help-DnOa5Gr-.mjs} +67 -16
  29. package/dist/clis/args/help-DnOa5Gr-.mjs.map +1 -0
  30. package/dist/clis/args/help.d.mts +3 -2
  31. package/dist/clis/args/help.mjs +15 -1
  32. package/dist/clis/args/host.d.mts +23 -0
  33. package/dist/clis/args/host.d.mts.map +1 -0
  34. package/dist/clis/args/host.mjs +35 -0
  35. package/dist/clis/args/host.mjs.map +1 -0
  36. package/dist/clis/args/index.d.mts +23 -19
  37. package/dist/clis/args/index.mjs +22 -19
  38. package/dist/clis/args/init.d.mts +54 -2
  39. package/dist/clis/args/init.d.mts.map +1 -0
  40. package/dist/clis/args/init.mjs +71 -1
  41. package/dist/clis/args/init.mjs.map +1 -0
  42. package/dist/clis/args/inspect.d.mts +12 -2
  43. package/dist/clis/args/inspect.d.mts.map +1 -0
  44. package/dist/clis/args/inspect.mjs +14 -1
  45. package/dist/clis/args/inspect.mjs.map +1 -0
  46. package/dist/clis/args/install.d.mts +36 -2
  47. package/dist/clis/args/install.d.mts.map +1 -0
  48. package/dist/clis/args/install.mjs +31 -1
  49. package/dist/clis/args/install.mjs.map +1 -0
  50. package/dist/clis/args/keyframes.d.mts +25 -0
  51. package/dist/clis/args/keyframes.d.mts.map +1 -0
  52. package/dist/clis/args/keyframes.mjs +42 -0
  53. package/dist/clis/args/keyframes.mjs.map +1 -0
  54. package/dist/clis/args/list.d.mts +9 -2
  55. package/dist/clis/args/list.d.mts.map +1 -0
  56. package/dist/clis/args/list.mjs +6 -1
  57. package/dist/clis/args/list.mjs.map +1 -0
  58. package/dist/clis/args/login.d.mts +24 -2
  59. package/dist/clis/args/login.d.mts.map +1 -0
  60. package/dist/clis/args/login.mjs +39 -1
  61. package/dist/clis/args/login.mjs.map +1 -0
  62. package/dist/clis/args/mcp.d.mts +15 -0
  63. package/dist/clis/args/mcp.d.mts.map +1 -0
  64. package/dist/clis/args/mcp.mjs +22 -0
  65. package/dist/clis/args/mcp.mjs.map +1 -0
  66. package/dist/clis/args/migrate.d.mts +18 -2
  67. package/dist/clis/args/migrate.d.mts.map +1 -0
  68. package/dist/clis/args/migrate.mjs +27 -1
  69. package/dist/clis/args/migrate.mjs.map +1 -0
  70. package/dist/clis/args/publish.d.mts +15 -2
  71. package/dist/clis/args/publish.d.mts.map +1 -0
  72. package/dist/clis/args/publish.mjs +18 -1
  73. package/dist/clis/args/publish.mjs.map +1 -0
  74. package/dist/clis/args/registry.d.mts +16 -2
  75. package/dist/clis/args/registry.d.mts.map +1 -0
  76. package/dist/clis/args/registry.mjs +22 -1
  77. package/dist/clis/args/registry.mjs.map +1 -0
  78. package/dist/clis/args/run.d.mts +18 -0
  79. package/dist/clis/args/run.d.mts.map +1 -0
  80. package/dist/clis/args/run.mjs +28 -0
  81. package/dist/clis/args/run.mjs.map +1 -0
  82. package/dist/clis/args/service-IZ0Aq58z.d.mts +27 -0
  83. package/dist/clis/args/service-IZ0Aq58z.d.mts.map +1 -0
  84. package/dist/clis/args/service.d.mts +3 -2
  85. package/dist/clis/args/service.mjs +10 -1
  86. package/dist/clis/args/service.mjs.map +1 -0
  87. package/dist/clis/args/switchboard.d.mts +69 -2
  88. package/dist/clis/args/switchboard.d.mts.map +1 -0
  89. package/dist/clis/args/switchboard.mjs +84 -1
  90. package/dist/clis/args/switchboard.mjs.map +1 -0
  91. package/dist/clis/args/uninstall.d.mts +27 -2
  92. package/dist/clis/args/uninstall.d.mts.map +1 -0
  93. package/dist/clis/args/uninstall.mjs +15 -1
  94. package/dist/clis/args/uninstall.mjs.map +1 -0
  95. package/dist/clis/args/unpublish.d.mts +21 -2
  96. package/dist/clis/args/unpublish.d.mts.map +1 -0
  97. package/dist/clis/args/unpublish.mjs +29 -1
  98. package/dist/clis/args/unpublish.mjs.map +1 -0
  99. package/dist/clis/args/{vetra-b4KUu1Ax.mjs → vetra-DlAEC_Mv.mjs} +18 -2
  100. package/dist/clis/args/vetra-DlAEC_Mv.mjs.map +1 -0
  101. package/dist/clis/args/vetra.d.mts +113 -2
  102. package/dist/clis/args/vetra.d.mts.map +1 -0
  103. package/dist/clis/args/vetra.mjs +1 -1
  104. package/dist/clis/build-config-BM1RL4u_.mjs +309 -0
  105. package/dist/clis/build-config-BM1RL4u_.mjs.map +1 -0
  106. package/dist/clis/build-config.d.mts +71 -10616
  107. package/dist/clis/build-config.d.mts.map +1 -1
  108. package/dist/clis/build-config.mjs +2 -93
  109. package/dist/clis/build-pieces.d.mts +160 -0
  110. package/dist/clis/build-pieces.d.mts.map +1 -0
  111. package/dist/clis/build-pieces.mjs +549 -0
  112. package/dist/clis/build-pieces.mjs.map +1 -0
  113. package/dist/clis/command-names.d.mts +6 -2
  114. package/dist/clis/command-names.d.mts.map +1 -1
  115. package/dist/clis/command-names.mjs +9 -1
  116. package/dist/clis/command-names.mjs.map +1 -1
  117. package/dist/clis/constants.d.mts +3 -475
  118. package/dist/clis/constants.mjs +79 -21
  119. package/dist/clis/constants.mjs.map +1 -1
  120. package/dist/clis/feature-flags.d.mts +17 -0
  121. package/dist/clis/feature-flags.d.mts.map +1 -0
  122. package/dist/clis/feature-flags.mjs +21 -0
  123. package/dist/clis/feature-flags.mjs.map +1 -0
  124. package/dist/clis/index-DnZYG-8g.d.mts +11154 -0
  125. package/dist/clis/index-DnZYG-8g.d.mts.map +1 -0
  126. package/dist/clis/index.d.mts +3677 -1967
  127. package/dist/clis/index.d.mts.map +1 -1
  128. package/dist/clis/index.mjs +1317 -871
  129. package/dist/clis/index.mjs.map +1 -1
  130. package/dist/clis/package-style.d.mts +32 -0
  131. package/dist/clis/package-style.d.mts.map +1 -0
  132. package/dist/clis/package-style.mjs +102 -0
  133. package/dist/clis/package-style.mjs.map +1 -0
  134. package/dist/clis/ph-dir.d.mts +26 -0
  135. package/dist/clis/ph-dir.d.mts.map +1 -0
  136. package/dist/clis/ph-dir.mjs +37 -0
  137. package/dist/clis/ph-dir.mjs.map +1 -0
  138. package/dist/clis/project-env.d.mts +10 -4
  139. package/dist/clis/project-env.d.mts.map +1 -1
  140. package/dist/clis/project-env.mjs +16 -1
  141. package/dist/clis/project-env.mjs.map +1 -1
  142. package/dist/clis/project-ports.d.mts +5 -5
  143. package/dist/clis/project-ports.d.mts.map +1 -1
  144. package/dist/clis/project-ports.mjs +1 -1
  145. package/dist/clis/project-ports.mjs.map +1 -1
  146. package/dist/clis/rolldown-runtime-B4iAMlE-.mjs +35 -0
  147. package/dist/clis/services/telemetry.d.mts +7 -7
  148. package/dist/clis/services/telemetry.d.mts.map +1 -1
  149. package/dist/clis/services/telemetry.mjs.map +1 -1
  150. package/dist/clis/types-CqwqhwOG.d.mts +2484 -0
  151. package/dist/clis/types-CqwqhwOG.d.mts.map +1 -0
  152. package/dist/clis/utils.d.mts +4 -4
  153. package/dist/clis/utils.d.mts.map +1 -1
  154. package/dist/clis/utils.mjs.map +1 -1
  155. package/dist/{config-loader-B845Hidf.js → config-loader-B7SqNz8z.js} +50 -12
  156. package/dist/config-loader-B7SqNz8z.js.map +1 -0
  157. package/dist/connect/app-shell.d.ts +48 -0
  158. package/dist/connect/app-shell.d.ts.map +1 -0
  159. package/dist/connect/app-shell.js +90 -0
  160. package/dist/connect/app-shell.js.map +1 -0
  161. package/dist/connect/config-loader.d.ts +21 -8
  162. package/dist/connect/config-loader.d.ts.map +1 -1
  163. package/dist/connect/config-loader.js +2 -2
  164. package/dist/connect/connect-config-schema.d.ts +3 -0
  165. package/dist/connect/connect-config-schema.js +484 -0
  166. package/dist/connect/connect-config-schema.js.map +1 -0
  167. package/dist/connect/image-ref.d.ts +32 -0
  168. package/dist/connect/image-ref.d.ts.map +1 -0
  169. package/dist/connect/image-ref.js +80 -0
  170. package/dist/connect/image-ref.js.map +1 -0
  171. package/dist/connect/index.d.ts +226 -643
  172. package/dist/connect/index.d.ts.map +1 -1
  173. package/dist/connect/index.js +443 -507
  174. package/dist/connect/index.js.map +1 -1
  175. package/dist/connect/json-adapter.d.ts +3 -4
  176. package/dist/connect/json-adapter.d.ts.map +1 -1
  177. package/dist/connect/json-adapter.js.map +1 -1
  178. package/dist/connect/origin-placeholder.d.ts +52 -0
  179. package/dist/connect/origin-placeholder.d.ts.map +1 -0
  180. package/dist/connect/origin-placeholder.js +101 -0
  181. package/dist/connect/origin-placeholder.js.map +1 -0
  182. package/dist/connect-config-schema-LzQbfZHm.d.ts +1858 -0
  183. package/dist/connect-config-schema-LzQbfZHm.d.ts.map +1 -0
  184. package/dist/constants-5UFY_rXh.d.ts +9 -0
  185. package/dist/constants-5UFY_rXh.d.ts.map +1 -0
  186. package/dist/constants.d.ts +3 -2
  187. package/dist/constants.js +22 -6
  188. package/dist/constants.js.map +1 -1
  189. package/dist/document-drive/index.d.ts +103 -101
  190. package/dist/document-drive/index.d.ts.map +1 -1
  191. package/dist/document-drive/index.js +41 -32
  192. package/dist/document-drive/index.js.map +1 -1
  193. package/dist/document-model/action-id.d.ts +3 -0
  194. package/dist/document-model/action-id.js +59 -0
  195. package/dist/document-model/action-id.js.map +1 -0
  196. package/dist/document-model/dispatch.d.ts +25 -0
  197. package/dist/document-model/dispatch.d.ts.map +1 -0
  198. package/dist/document-model/dispatch.js +0 -0
  199. package/dist/document-model/errors.d.ts +3 -0
  200. package/dist/document-model/errors.js +200 -0
  201. package/dist/document-model/errors.js.map +1 -0
  202. package/dist/document-model/index.d.ts +6 -4
  203. package/dist/document-model/index.js +7 -5144
  204. package/dist/document-model/mock.d.ts +2 -3
  205. package/dist/document-model/mock.d.ts.map +1 -1
  206. package/dist/document-model/mock.js +2 -1
  207. package/dist/document-model/mock.js.map +1 -1
  208. package/dist/document-model/utils.d.ts +4 -2
  209. package/dist/document-model/utils.js +3 -2
  210. package/dist/document-model/version.d.ts +3 -0
  211. package/dist/document-model/version.js +8 -0
  212. package/dist/document-model/version.js.map +1 -0
  213. package/dist/document-model-D6OQX6ZP.js +5765 -0
  214. package/dist/document-model-D6OQX6ZP.js.map +1 -0
  215. package/dist/host-tokens/index.d.ts +3 -0
  216. package/dist/host-tokens/index.js +2 -0
  217. package/dist/host-tokens-DOeyxqLi.js +322 -0
  218. package/dist/host-tokens-DOeyxqLi.js.map +1 -0
  219. package/dist/index-B6uMqLt2.d.ts +36 -0
  220. package/dist/index-B6uMqLt2.d.ts.map +1 -0
  221. package/dist/index-D58WVj_E.d.ts +246 -0
  222. package/dist/index-D58WVj_E.d.ts.map +1 -0
  223. package/dist/index.d.ts +7 -6
  224. package/dist/index.js.map +1 -1
  225. package/dist/processors/index.d.ts +3 -2
  226. package/dist/processors/index.js +180 -67
  227. package/dist/processors/index.js.map +1 -1
  228. package/dist/processors/testing.d.ts +22 -0
  229. package/dist/processors/testing.d.ts.map +1 -0
  230. package/dist/processors/testing.js +77 -0
  231. package/dist/processors/testing.js.map +1 -0
  232. package/dist/purge-BOqSpe4O.js +620 -0
  233. package/dist/purge-BOqSpe4O.js.map +1 -0
  234. package/dist/registry/index.d.ts +15 -15
  235. package/dist/registry/index.d.ts.map +1 -1
  236. package/dist/registry/index.js +64 -12
  237. package/dist/registry/index.js.map +1 -1
  238. package/dist/registry/manifest-slim.d.ts +4 -3
  239. package/dist/registry/manifest-slim.d.ts.map +1 -1
  240. package/dist/registry/manifest-slim.js +22 -2
  241. package/dist/registry/manifest-slim.js.map +1 -1
  242. package/dist/registry/updates.d.ts +3 -3
  243. package/dist/registry/updates.d.ts.map +1 -1
  244. package/dist/registry/updates.js.map +1 -1
  245. package/dist/registry/urls.d.ts +2 -2
  246. package/dist/registry/urls.d.ts.map +1 -1
  247. package/dist/registry/urls.js.map +1 -1
  248. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  249. package/dist/{types-C1in4fl3.d.ts → types-Bsp8VL2y.d.ts} +2 -2
  250. package/dist/types-Bsp8VL2y.d.ts.map +1 -0
  251. package/dist/types-D2IwhfT4.d.ts +5688 -0
  252. package/dist/types-D2IwhfT4.d.ts.map +1 -0
  253. package/dist/{types-DDpRvBK_.d.ts → types-ZkfQLcTZ.d.ts} +39 -43
  254. package/dist/types-ZkfQLcTZ.d.ts.map +1 -0
  255. package/dist/{utils-aaTmfxFW.js → utils-DiV32YIj.js} +53 -3
  256. package/dist/utils-DiV32YIj.js.map +1 -0
  257. package/dist/utils-MrLmLEVr.js +78 -0
  258. package/dist/utils-MrLmLEVr.js.map +1 -0
  259. package/dist/version-BxLITo9P.d.ts +6 -0
  260. package/dist/version-BxLITo9P.d.ts.map +1 -0
  261. package/package.json +34 -7
  262. package/dist/clis/args/access-token--9H57y8J.d.mts +0 -18
  263. package/dist/clis/args/access-token--9H57y8J.d.mts.map +0 -1
  264. package/dist/clis/args/access-token-To5LaIfL.mjs +0 -22
  265. package/dist/clis/args/access-token-To5LaIfL.mjs.map +0 -1
  266. package/dist/clis/args/common-CcYbXrBx.mjs.map +0 -1
  267. package/dist/clis/args/common-Dsf1vpHV.d.mts +0 -183
  268. package/dist/clis/args/common-Dsf1vpHV.d.mts.map +0 -1
  269. package/dist/clis/args/connect-BVVvCmL9.mjs +0 -198
  270. package/dist/clis/args/connect-BVVvCmL9.mjs.map +0 -1
  271. package/dist/clis/args/connect-DetTnI8g.d.mts +0 -443
  272. package/dist/clis/args/connect-DetTnI8g.d.mts.map +0 -1
  273. package/dist/clis/args/generate-CA916Fvj.mjs.map +0 -1
  274. package/dist/clis/args/generate-DnV-bfXt.d.mts +0 -87
  275. package/dist/clis/args/generate-DnV-bfXt.d.mts.map +0 -1
  276. package/dist/clis/args/help-Bqbgbalu.mjs.map +0 -1
  277. package/dist/clis/args/help-CjAsudUn.d.mts +0 -193
  278. package/dist/clis/args/help-CjAsudUn.d.mts.map +0 -1
  279. package/dist/clis/args/init-CUXyfquF.d.mts +0 -55
  280. package/dist/clis/args/init-CUXyfquF.d.mts.map +0 -1
  281. package/dist/clis/args/init-rz9Ei7nq.mjs +0 -67
  282. package/dist/clis/args/init-rz9Ei7nq.mjs.map +0 -1
  283. package/dist/clis/args/inspect-DtZeoA5c.d.mts +0 -15
  284. package/dist/clis/args/inspect-DtZeoA5c.d.mts.map +0 -1
  285. package/dist/clis/args/inspect-tckH8mSw.mjs +0 -15
  286. package/dist/clis/args/inspect-tckH8mSw.mjs.map +0 -1
  287. package/dist/clis/args/install-CkP8zcHb.d.mts +0 -40
  288. package/dist/clis/args/install-CkP8zcHb.d.mts.map +0 -1
  289. package/dist/clis/args/install-Sz2DlCHh.mjs +0 -32
  290. package/dist/clis/args/install-Sz2DlCHh.mjs.map +0 -1
  291. package/dist/clis/args/list-BGf8s_gj.d.mts +0 -12
  292. package/dist/clis/args/list-BGf8s_gj.d.mts.map +0 -1
  293. package/dist/clis/args/list-DM2d6f1m.mjs +0 -7
  294. package/dist/clis/args/list-DM2d6f1m.mjs.map +0 -1
  295. package/dist/clis/args/login-DNsHwvqk.d.mts +0 -27
  296. package/dist/clis/args/login-DNsHwvqk.d.mts.map +0 -1
  297. package/dist/clis/args/login-DiKT5Jfu.mjs +0 -40
  298. package/dist/clis/args/login-DiKT5Jfu.mjs.map +0 -1
  299. package/dist/clis/args/magic-string.es-h_0HDQBQ.mjs +0 -1013
  300. package/dist/clis/args/magic-string.es-h_0HDQBQ.mjs.map +0 -1
  301. package/dist/clis/args/migrate-CG_gWc4k.mjs +0 -29
  302. package/dist/clis/args/migrate-CG_gWc4k.mjs.map +0 -1
  303. package/dist/clis/args/migrate-sixkWhxm.d.mts +0 -21
  304. package/dist/clis/args/migrate-sixkWhxm.d.mts.map +0 -1
  305. package/dist/clis/args/publish-DDZYsUfV.mjs +0 -19
  306. package/dist/clis/args/publish-DDZYsUfV.mjs.map +0 -1
  307. package/dist/clis/args/publish-Dqe5DUst.d.mts +0 -18
  308. package/dist/clis/args/publish-Dqe5DUst.d.mts.map +0 -1
  309. package/dist/clis/args/registry-C_OVFQmI.mjs +0 -23
  310. package/dist/clis/args/registry-C_OVFQmI.mjs.map +0 -1
  311. package/dist/clis/args/registry-C_RfTsKB.d.mts +0 -19
  312. package/dist/clis/args/registry-C_RfTsKB.d.mts.map +0 -1
  313. package/dist/clis/args/service-CHOOr0Gg.mjs +0 -11
  314. package/dist/clis/args/service-CHOOr0Gg.mjs.map +0 -1
  315. package/dist/clis/args/service-DhIkf8-O.d.mts +0 -22
  316. package/dist/clis/args/service-DhIkf8-O.d.mts.map +0 -1
  317. package/dist/clis/args/switchboard-BlPaq2at.d.mts +0 -72
  318. package/dist/clis/args/switchboard-BlPaq2at.d.mts.map +0 -1
  319. package/dist/clis/args/switchboard-Dsp7nosi.mjs +0 -85
  320. package/dist/clis/args/switchboard-Dsp7nosi.mjs.map +0 -1
  321. package/dist/clis/args/uninstall-BpA3YYbw.d.mts +0 -31
  322. package/dist/clis/args/uninstall-BpA3YYbw.d.mts.map +0 -1
  323. package/dist/clis/args/uninstall-CTwTX0u_.mjs +0 -16
  324. package/dist/clis/args/uninstall-CTwTX0u_.mjs.map +0 -1
  325. package/dist/clis/args/unpublish-BPMkGEg5.mjs +0 -30
  326. package/dist/clis/args/unpublish-BPMkGEg5.mjs.map +0 -1
  327. package/dist/clis/args/unpublish-CvwaIimG.d.mts +0 -24
  328. package/dist/clis/args/unpublish-CvwaIimG.d.mts.map +0 -1
  329. package/dist/clis/args/vetra-DLQ6lhLl.d.mts +0 -113
  330. package/dist/clis/args/vetra-DLQ6lhLl.d.mts.map +0 -1
  331. package/dist/clis/args/vetra-b4KUu1Ax.mjs.map +0 -1
  332. package/dist/clis/args/vetra-ports.test.d.mts +0 -1
  333. package/dist/clis/args/vetra-ports.test.mjs +0 -13249
  334. package/dist/clis/args/vetra-ports.test.mjs.map +0 -1
  335. package/dist/clis/build-config.mjs.map +0 -1
  336. package/dist/clis/constants.d.mts.map +0 -1
  337. package/dist/config-loader-B845Hidf.js.map +0 -1
  338. package/dist/constants-BP_gjn8g.d.ts +0 -8
  339. package/dist/constants-BP_gjn8g.d.ts.map +0 -1
  340. package/dist/document-model/index.js.map +0 -1
  341. package/dist/index-C_iVZe7f.d.ts +0 -7
  342. package/dist/index-C_iVZe7f.d.ts.map +0 -1
  343. package/dist/index-DP3QgHTq.d.ts +0 -836
  344. package/dist/index-DP3QgHTq.d.ts.map +0 -1
  345. package/dist/types-BIoOWpOT.d.ts +0 -3172
  346. package/dist/types-BIoOWpOT.d.ts.map +0 -1
  347. package/dist/types-C1in4fl3.d.ts.map +0 -1
  348. package/dist/types-DDpRvBK_.d.ts.map +0 -1
  349. package/dist/utils-DP122OSS.d.ts +0 -18
  350. package/dist/utils-DP122OSS.d.ts.map +0 -1
  351. package/dist/utils-aaTmfxFW.js.map +0 -1
@@ -0,0 +1,620 @@
1
+ import { g as buildOperationSignatureMessage, t as deriveOperationId, v as bytesToBase64Url$1 } from "./utils-DiV32YIj.js";
2
+ import { generateActionId } from "./document-model/action-id.js";
3
+ import { stringify } from "safe-stable-stringify";
4
+ import { sha256 } from "@noble/hashes/sha2.js";
5
+ //#region document-model/action-signature.ts
6
+ const ACTION_SIGNATURE_V2_PREFIX = "v2:";
7
+ const V2_HASH = /^v2:[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
8
+ const V2_TIMESTAMP = /^[0-9]+$/;
9
+ const V2_SIGNATURE = /^0x[0-9a-f]{128}$/;
10
+ const LONE_SURROGATE = /\p{Cs}/u;
11
+ const PREIMAGE_FIELDS = [
12
+ "version",
13
+ "documentId",
14
+ "branch",
15
+ "scope",
16
+ "type",
17
+ "id",
18
+ "timestampUtcMs",
19
+ "input",
20
+ "signer.user.address",
21
+ "signer.user.networkId",
22
+ "signer.user.chainId",
23
+ "signer.app.key"
24
+ ];
25
+ /** A value that would not survive a JSON store round trip unchanged. */
26
+ var CanonicalJsonError = class extends Error {
27
+ constructor(path, detail) {
28
+ super(`Cannot canonicalize ${path}: ${detail}`);
29
+ this.name = "CanonicalJsonError";
30
+ }
31
+ };
32
+ /** Sorted-key JSON, as the state hash encodes; drops `undefined` properties. */
33
+ function canonicalJson(value, label = "value") {
34
+ assertCanonical(value, label, /* @__PURE__ */ new Set());
35
+ return stringify(value);
36
+ }
37
+ /** Actions the reactor reduces itself, onto the document scope. */
38
+ const DOCUMENT_SCOPE_ACTION_TYPES = /* @__PURE__ */ new Set([
39
+ "CREATE_DOCUMENT",
40
+ "DELETE_DOCUMENT",
41
+ "UPGRADE_DOCUMENT",
42
+ "ADD_RELATIONSHIP",
43
+ "REMOVE_RELATIONSHIP",
44
+ "UPDATE_RELATIONSHIP",
45
+ "PURGE_DOCUMENT"
46
+ ]);
47
+ /** Where a document-scope action writes: `sourceId` or `documentId`. */
48
+ function targetDocumentId(action, fallback) {
49
+ const input = action.input;
50
+ if (action.type === "ADD_RELATIONSHIP" || action.type === "REMOVE_RELATIONSHIP" || action.type === "UPDATE_RELATIONSHIP") return typeof input?.sourceId === "string" && input.sourceId.length > 0 ? input.sourceId : fallback;
51
+ return typeof input?.documentId === "string" && input.documentId.length > 0 ? input.documentId : fallback;
52
+ }
53
+ /** The log an action submitted to a job on `documentId` is stored in. */
54
+ function actionSigningTarget(action, documentId, branch) {
55
+ return {
56
+ documentId: DOCUMENT_SCOPE_ACTION_TYPES.has(action.type) ? targetDocumentId(action, documentId) : documentId,
57
+ branch
58
+ };
59
+ }
60
+ /** The identity a signer writes into `context.signer`, and signs over. */
61
+ function actionSignerIdentity(signer) {
62
+ return {
63
+ user: {
64
+ address: signer.user?.address ?? "",
65
+ networkId: signer.user?.networkId ?? "",
66
+ chainId: signer.user?.chainId ?? 0
67
+ },
68
+ app: {
69
+ name: signer.app?.name ?? "",
70
+ key: signer.app?.key ?? ""
71
+ }
72
+ };
73
+ }
74
+ /** The v2 preimage; throws `CanonicalJsonError` on an unsignable action. */
75
+ function actionPreimageV2(action, target, signer) {
76
+ if (!target.documentId) throw new CanonicalJsonError("documentId", "must not be empty");
77
+ if (!target.branch) throw new CanonicalJsonError("branch", "must not be empty");
78
+ if (action.input === void 0) throw new CanonicalJsonError("input", `action ${action.id} (${action.type}) has no input`);
79
+ const fields = [
80
+ "v2",
81
+ target.documentId,
82
+ target.branch,
83
+ action.scope,
84
+ action.type,
85
+ action.id,
86
+ action.timestampUtcMs,
87
+ action.input,
88
+ signer.user.address,
89
+ signer.user.networkId,
90
+ signer.user.chainId,
91
+ signer.app.key
92
+ ];
93
+ fields.forEach((field, i) => {
94
+ assertCanonical(field, PREIMAGE_FIELDS[i], /* @__PURE__ */ new Set());
95
+ });
96
+ return stringify(fields);
97
+ }
98
+ /** `"v2:" + base64url(sha256(preimage))`, unpadded. */
99
+ async function hashActionV2(action, target, signer) {
100
+ const preimage = actionPreimageV2(action, target, signer);
101
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(preimage));
102
+ return "v2:" + bytesToBase64Url(new Uint8Array(digest));
103
+ }
104
+ /** Signs `action` as a v2 tuple; the message layout is the legacy one. */
105
+ async function signActionV2(params) {
106
+ const { action, target, signer, sign } = params;
107
+ const previousStateHash = params.previousStateHash ?? "";
108
+ if (previousStateHash.includes(", ")) throw new Error(`Cannot sign action ${action.id}: the previous state hash contains ", "`);
109
+ const tuple = [
110
+ (Date.now() / 1e3).toFixed(0),
111
+ signer.app.key,
112
+ await hashActionV2(action, target, signer),
113
+ previousStateHash
114
+ ];
115
+ const signature = await sign(buildOperationSignatureMessage(tuple));
116
+ if (signature.length !== 64) throw new Error(`Cannot sign action ${action.id}: expected a 64-byte P-256 signature, got ${signature.length} bytes`);
117
+ return [...tuple, `0x${bytesToHex(signature)}`];
118
+ }
119
+ /** Element [2] carries the v2 prefix, whether or not it is well formed. */
120
+ function isV2ActionHash(hash) {
121
+ return hash.startsWith("v2:");
122
+ }
123
+ /** The strict shape of a v2 tuple, apart from what its hash covers. */
124
+ function v2TupleProblem(tuple) {
125
+ if (!V2_TIMESTAMP.test(tuple[0])) return "signing time is not decimal seconds";
126
+ if (!V2_HASH.test(tuple[2])) return "hash is not v2: and 43 base64url characters";
127
+ if (!V2_SIGNATURE.test(tuple[4])) return "signature is not 0x and 128 lowercase hex digits";
128
+ }
129
+ function assertCanonical(value, path, ancestors) {
130
+ switch (typeof value) {
131
+ case "string":
132
+ if (LONE_SURROGATE.test(value)) throw new CanonicalJsonError(path, "string holds a lone surrogate");
133
+ return;
134
+ case "boolean": return;
135
+ case "number":
136
+ if (!Number.isFinite(value)) throw new CanonicalJsonError(path, `${value} is not a JSON number`);
137
+ return;
138
+ case "undefined": throw new CanonicalJsonError(path, "undefined is not a JSON value");
139
+ case "bigint": throw new CanonicalJsonError(path, "BigInt is not a JSON value");
140
+ case "function":
141
+ case "symbol": throw new CanonicalJsonError(path, `${typeof value} is not a JSON value`);
142
+ }
143
+ if (value === null) return;
144
+ const object = value;
145
+ if (ancestors.has(object)) throw new CanonicalJsonError(path, "value is circular");
146
+ const toJSON = object.toJSON;
147
+ if (typeof toJSON === "function") {
148
+ assertCanonical(toJSON.call(object), path, new Set(ancestors).add(object));
149
+ return;
150
+ }
151
+ ancestors.add(object);
152
+ if (Array.isArray(object)) for (let i = 0; i < object.length; i++) {
153
+ if (!(i in object)) throw new CanonicalJsonError(`${path}[${i}]`, "array is sparse");
154
+ assertCanonical(object[i], `${path}[${i}]`, ancestors);
155
+ }
156
+ else for (const [key, child] of Object.entries(object)) {
157
+ if (LONE_SURROGATE.test(key)) throw new CanonicalJsonError(path, "key holds a lone surrogate");
158
+ if (child === void 0) continue;
159
+ assertCanonical(child, `${path}.${key}`, ancestors);
160
+ }
161
+ ancestors.delete(object);
162
+ }
163
+ function bytesToBase64Url(bytes) {
164
+ let binary = "";
165
+ for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
166
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
167
+ }
168
+ function bytesToHex(bytes) {
169
+ return Array.from(bytes).map((byte) => byte.toString(16).padStart(2, "0")).join("");
170
+ }
171
+ //#endregion
172
+ //#region document-model/state-reducer.ts
173
+ const STATE_REDUCER = Symbol.for("powerhouse.stateReducer");
174
+ function tagStateReducer(reducer, stateReducer) {
175
+ return Object.assign(reducer, { [STATE_REDUCER]: stateReducer });
176
+ }
177
+ /** The state reducer a `createReducer` reducer wraps, for base-reducer 3 derivation. */
178
+ function stateReducerOf(reducer) {
179
+ return reducer[STATE_REDUCER];
180
+ }
181
+ //#endregion
182
+ //#region document-model/base-reducer-protocol.ts
183
+ const BASE_REDUCER_VERSIONS = [
184
+ 1,
185
+ 2,
186
+ 3
187
+ ];
188
+ const CAPABILITIES = {
189
+ 1: {
190
+ version: 1,
191
+ undo: "skip",
192
+ derivation: "replay",
193
+ skip: "undo-or-rewind",
194
+ tieOrder: "rank-locale",
195
+ synthesizedId: "hashed",
196
+ replayHash: "sender",
197
+ reducerContract: "any",
198
+ gatedBy: null
199
+ },
200
+ 2: {
201
+ version: 2,
202
+ undo: "noop-chain",
203
+ derivation: "replay",
204
+ skip: "undo-or-rewind",
205
+ tieOrder: "rank-locale",
206
+ synthesizedId: "hashed",
207
+ replayHash: "sender",
208
+ reducerContract: "any",
209
+ gatedBy: null
210
+ },
211
+ 3: {
212
+ version: 3,
213
+ undo: "retraction",
214
+ derivation: "retraction-rule",
215
+ skip: "rewind",
216
+ tieOrder: "canonical",
217
+ synthesizedId: "none",
218
+ replayHash: "receiver",
219
+ reducerContract: "state-reducer",
220
+ gatedBy: "undoV3"
221
+ }
222
+ };
223
+ /** The versions a reactor running `flags` supports. */
224
+ function baseReducerVersionsFor(flags) {
225
+ return BASE_REDUCER_VERSIONS.filter((version) => {
226
+ const gate = CAPABILITIES[version].gatedBy;
227
+ return gate === null || flags[gate] === true;
228
+ });
229
+ }
230
+ /** Flags under which this build runs every version it knows. */
231
+ const FLAGS_FOR_EVERY_VERSION = Object.fromEntries(BASE_REDUCER_VERSIONS.flatMap((version) => {
232
+ const gate = CAPABILITIES[version].gatedBy;
233
+ return gate === null ? [] : [[gate, true]];
234
+ }));
235
+ /** Scopes the retraction rule never derives. */
236
+ const RULE_EXEMPT_SCOPES = /* @__PURE__ */ new Set(["auth", "document"]);
237
+ function assertNever(value, what) {
238
+ throw new Error(`Unhandled ${what}: ${String(value)}`);
239
+ }
240
+ function isBaseReducerVersion(value) {
241
+ return BASE_REDUCER_VERSIONS.includes(value);
242
+ }
243
+ function capabilitiesOf(version) {
244
+ return CAPABILITIES[version];
245
+ }
246
+ /** Throws on a missing version: defaulting one would replay through the wrong reducer. */
247
+ function baseReducerVersion(header) {
248
+ const version = header.protocolVersions?.["base-reducer"];
249
+ if (typeof version !== "number") throw new Error(`Document ${header.id} carries no base-reducer protocol version`);
250
+ if (!isBaseReducerVersion(version)) throw new Error(`Document ${header.id} carries unknown base-reducer protocol version ${version}`);
251
+ return version;
252
+ }
253
+ /** Throws on a missing or unknown version. */
254
+ function baseReducerCapabilities(header) {
255
+ return capabilitiesOf(baseReducerVersion(header));
256
+ }
257
+ /** Undefined only for a header without a version; throws on an unknown one. */
258
+ function optionalBaseReducerCapabilities(header) {
259
+ if (header.protocolVersions?.["base-reducer"] === void 0) return;
260
+ return baseReducerCapabilities(header);
261
+ }
262
+ /** Undefined when `versions` names no known base-reducer version. */
263
+ function capabilitiesFor(versions) {
264
+ const version = versions?.["base-reducer"];
265
+ return isBaseReducerVersion(version) ? capabilitiesOf(version) : void 0;
266
+ }
267
+ /** From CREATE_DOCUMENT input; undefined when it names no known version. */
268
+ function createdCapabilities(input) {
269
+ return capabilitiesFor(input?.protocolVersions);
270
+ }
271
+ /**
272
+ * Every decision a consumer may take on a capability axis. Outside this module
273
+ * and the other protocol owners, an axis is read only through these or through
274
+ * an exhaustive switch.
275
+ */
276
+ const CAPABILITY_DECISIONS = {
277
+ usesRetractionRule: {
278
+ replay: false,
279
+ "retraction-rule": true
280
+ },
281
+ needsTaggedModel: {
282
+ any: false,
283
+ "state-reducer": true
284
+ },
285
+ sortsJobsCanonically: {
286
+ "rank-locale": false,
287
+ canonical: true
288
+ },
289
+ conflictWindowMovesEveryRow: {
290
+ "rank-locale": false,
291
+ canonical: true
292
+ },
293
+ skipMayUndo: {
294
+ "undo-or-rewind": true,
295
+ rewind: false
296
+ }
297
+ };
298
+ const UNVERSIONED = CAPABILITIES[1];
299
+ /** Whether the version derives scopes by the retraction rule; a versionless header does not. */
300
+ function usesRetractionRule(caps) {
301
+ return CAPABILITY_DECISIONS.usesRetractionRule[(caps ?? UNVERSIONED).derivation];
302
+ }
303
+ /** Whether the retraction rule derives `scope`. */
304
+ function derivesByRule(caps, scope) {
305
+ return usesRetractionRule(caps) && !RULE_EXEMPT_SCOPES.has(scope);
306
+ }
307
+ /** Whether the retraction rule derives `scope` of the document `header` heads. */
308
+ function documentDerivesByRule(header, scope) {
309
+ return derivesByRule(optionalBaseReducerCapabilities(header), scope);
310
+ }
311
+ /** Whether the version runs only models whose every reducer is tagged. */
312
+ function needsTaggedModel(caps) {
313
+ return CAPABILITY_DECISIONS.needsTaggedModel[(caps ?? UNVERSIONED).reducerContract];
314
+ }
315
+ /** How same-timestamp actions are ordered; a versionless header ranks and compares by locale. */
316
+ function tieOrderOf(caps) {
317
+ return (caps ?? UNVERSIONED).tieOrder;
318
+ }
319
+ /** Whether a job's actions are stored in canonical order rather than as submitted. */
320
+ function sortsJobsCanonically(caps) {
321
+ return CAPABILITY_DECISIONS.sortsJobsCanonically[tieOrderOf(caps)];
322
+ }
323
+ /** Whether every conflicting row of a load moves, rather than only those past the predecessor bound. */
324
+ function conflictWindowMovesEveryRow(caps) {
325
+ return CAPABILITY_DECISIONS.conflictWindowMovesEveryRow[tieOrderOf(caps)];
326
+ }
327
+ /** Whether a stored skip may be an undo, not only a replica's rewind. */
328
+ function skipMayUndo(caps) {
329
+ return CAPABILITY_DECISIONS.skipMayUndo[(caps ?? UNVERSIONED).skip];
330
+ }
331
+ /** Whether a stored skip in `scope` is a rewind the reducer applies. */
332
+ function appliesRewind(caps, scope) {
333
+ return !derivesByRule(caps, scope);
334
+ }
335
+ /** Whether a submitted RETRACT is this version's undo. */
336
+ function acceptsSubmittedRetract(caps) {
337
+ switch (caps.undo) {
338
+ case "retraction": return true;
339
+ case "skip":
340
+ case "noop-chain": return false;
341
+ default: return assertNever(caps.undo, "undo model");
342
+ }
343
+ }
344
+ /** Whether a submitted UNDO or REDO is this version's undo; on retraction a client submits RETRACT. */
345
+ function acceptsSubmittedUndoRedo(caps) {
346
+ switch (caps.undo) {
347
+ case "skip":
348
+ case "noop-chain": return true;
349
+ case "retraction": return false;
350
+ default: return assertNever(caps.undo, "undo model");
351
+ }
352
+ }
353
+ /** Whether every registered version of `documentType` runs under `caps`; undefined when none is. */
354
+ function modelRunsBaseReducer(caps, documentType, modules) {
355
+ const registered = modules.filter((module) => module.documentModel.global.id === documentType);
356
+ if (registered.length === 0) return void 0;
357
+ if (!needsTaggedModel(caps)) return true;
358
+ return registered.every((module) => stateReducerOf(module.reducer) !== void 0);
359
+ }
360
+ /** Why `versions` cannot run here; unregistered protocols and types are admitted. */
361
+ function refusalFor(documentType, versions, support, modules) {
362
+ for (const [protocol, version] of Object.entries(versions ?? {})) {
363
+ const supported = support[protocol];
364
+ if (supported === void 0 || supported.includes(version)) continue;
365
+ return {
366
+ protocol,
367
+ version
368
+ };
369
+ }
370
+ const version = versions?.["base-reducer"];
371
+ if (documentType === void 0 || !isBaseReducerVersion(version)) return;
372
+ if (modelRunsBaseReducer(capabilitiesOf(version), documentType, modules) === false) return {
373
+ protocol: "base-reducer",
374
+ version,
375
+ documentType
376
+ };
377
+ }
378
+ //#endregion
379
+ //#region document-model/peer-agreement.ts
380
+ /** A purged document's protocol; never preferred, so creation never selects it. */
381
+ const DOCUMENT_PURGE_PROTOCOL = "document-purge";
382
+ /** A peer that takes refusals of polled purge markers on the poll. */
383
+ const MARKER_REFUSAL_FEATURE = "marker-refusal";
384
+ const PEER_CAPABILITIES = [
385
+ {
386
+ kind: "protocol",
387
+ name: "base-reducer",
388
+ baseline: [1, 2],
389
+ supported: baseReducerVersionsFor,
390
+ preferred: (flags) => Math.max(...baseReducerVersionsFor(flags)),
391
+ selection: (preferred) => isBaseReducerVersion(preferred) && capabilitiesOf(preferred).gatedBy !== null ? "creator" : "agreed",
392
+ optional: false
393
+ },
394
+ {
395
+ kind: "protocol",
396
+ name: "signature",
397
+ baseline: [2],
398
+ supported: () => [2],
399
+ optional: true
400
+ },
401
+ {
402
+ kind: "protocol",
403
+ name: DOCUMENT_PURGE_PROTOCOL,
404
+ baseline: [],
405
+ supported: () => [1],
406
+ optional: true
407
+ },
408
+ {
409
+ kind: "feature",
410
+ name: MARKER_REFUSAL_FEATURE,
411
+ baseline: [],
412
+ supported: () => [1]
413
+ }
414
+ ];
415
+ /** `base-reducer`'s preference with no reactor flags, which shared never holds. */
416
+ const FLAGLESS_BASE_REDUCER_VERSION = PEER_CAPABILITIES.find((capability) => capability.kind === "protocol" && capability.name === "base-reducer").preferred({});
417
+ /** `base` plus `extra`; an extra replaces a base entry of the same name. */
418
+ function mergePeerCapabilities(base, extra) {
419
+ const key = (capability) => `${capability.kind}:${capability.name}`;
420
+ const replaced = new Set(extra.map(key));
421
+ return [...base.filter((capability) => !replaced.has(key(capability))), ...extra];
422
+ }
423
+ const PEER_MANIFEST_FORMAT = 1;
424
+ function versionSet(values) {
425
+ return [...new Set(values)].sort((a, b) => a - b);
426
+ }
427
+ function supportsFrom(capabilities, values) {
428
+ const supports = {
429
+ protocols: {},
430
+ features: {}
431
+ };
432
+ for (const capability of capabilities) {
433
+ const target = capability.kind === "protocol" ? supports.protocols : supports.features;
434
+ target[capability.name] = versionSet(values(capability));
435
+ }
436
+ return supports;
437
+ }
438
+ /** What this reactor supports, for every capability it registers. */
439
+ function localSupports(capabilities, flags) {
440
+ return supportsFrom(capabilities, (capability) => capability.supported(flags));
441
+ }
442
+ /** What a peer that announces nothing supports. */
443
+ function legacySupports(capabilities) {
444
+ return supportsFrom(capabilities, (capability) => capability.baseline);
445
+ }
446
+ function manifestRevision(supports, sequence = 0) {
447
+ const preimage = canonicalJson({
448
+ protocols: supports.protocols,
449
+ features: supports.features,
450
+ sequence
451
+ }, "peer manifest");
452
+ return bytesToBase64Url$1(sha256(new TextEncoder().encode(preimage)));
453
+ }
454
+ function localPeerManifest(capabilities, flags, appKey, sequence = 0) {
455
+ const supports = localSupports(capabilities, flags);
456
+ return {
457
+ format: 1,
458
+ ...appKey !== void 0 ? { appKey } : {},
459
+ sequence,
460
+ revision: manifestRevision(supports, sequence),
461
+ protocols: supports.protocols,
462
+ features: supports.features
463
+ };
464
+ }
465
+ /** A manifest sent before the one already held; silence carries no sequence. */
466
+ function isOlderManifest(next, held) {
467
+ return next !== null && held != null && next.sequence < held.sequence;
468
+ }
469
+ /** A peer's manifest, or the baselines for a peer that announced none. */
470
+ function peerSupports(manifest, capabilities) {
471
+ return manifest ?? legacySupports(capabilities);
472
+ }
473
+ function readVersionMap(value) {
474
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return;
475
+ const map = {};
476
+ for (const [name, versions] of Object.entries(value)) {
477
+ if (!Array.isArray(versions) || !versions.every((v) => Number.isInteger(v))) return;
478
+ map[name] = versionSet(versions);
479
+ }
480
+ return map;
481
+ }
482
+ /**
483
+ * A manifest as received from a peer, or null when it is not one. Formats only
484
+ * add fields, so one of an unknown format is read as its two maps.
485
+ */
486
+ function readPeerManifest(value) {
487
+ if (typeof value !== "object" || value === null) return null;
488
+ const raw = value;
489
+ const protocols = readVersionMap(raw.protocols);
490
+ const features = readVersionMap(raw.features ?? {});
491
+ if (!protocols || !features) return null;
492
+ const sequence = Number.isSafeInteger(raw.sequence) ? raw.sequence : 0;
493
+ return {
494
+ format: 1,
495
+ ...typeof raw.appKey === "string" ? { appKey: raw.appKey } : {},
496
+ sequence,
497
+ revision: typeof raw.revision === "string" ? raw.revision : manifestRevision({
498
+ protocols,
499
+ features
500
+ }, sequence),
501
+ protocols,
502
+ features
503
+ };
504
+ }
505
+ /** Only keys this reactor registers are judged; an absent key agrees. */
506
+ function holdReason(peer, versions, capabilities) {
507
+ for (const capability of capabilities) {
508
+ if (capability.kind !== "protocol") continue;
509
+ const version = versions[capability.name];
510
+ if (version === void 0) continue;
511
+ const supported = peer.protocols[capability.name] ?? [];
512
+ if (!supported.includes(version)) return {
513
+ protocol: capability.name,
514
+ version,
515
+ peerSupports: supported
516
+ };
517
+ }
518
+ }
519
+ /** Whether a peer runs every version this reactor does, so nothing is held. */
520
+ function coversLocal(peer, local, capabilities) {
521
+ for (const capability of capabilities) {
522
+ if (capability.kind !== "protocol") continue;
523
+ const theirs = peer.protocols[capability.name] ?? [];
524
+ if (!(local.protocols[capability.name] ?? []).every((version) => theirs.includes(version))) return false;
525
+ }
526
+ return true;
527
+ }
528
+ /**
529
+ * protocolVersions for a new document: per negotiated protocol, the highest
530
+ * version up to the local preference that every member supports, else the
531
+ * lowest local one. `requested` wins over what is selected.
532
+ */
533
+ function selectProtocolVersions(input) {
534
+ const members = [...input.members];
535
+ const selected = {};
536
+ for (const capability of input.capabilities) {
537
+ if (capability.kind !== "protocol" || !capability.preferred) continue;
538
+ const preferred = capability.preferred(input.flags);
539
+ const supported = capability.supported(input.flags);
540
+ let agreed = supported.filter((version) => version <= preferred);
541
+ for (const member of narrowedBy(capability, preferred, members)) {
542
+ const theirs = member.protocols[capability.name] ?? [];
543
+ agreed = agreed.filter((version) => theirs.includes(version));
544
+ }
545
+ selected[capability.name] = agreed.length > 0 ? Math.max(...agreed) : Math.min(...supported);
546
+ }
547
+ return {
548
+ ...selected,
549
+ ...input.requested
550
+ };
551
+ }
552
+ function narrowedBy(capability, preferred, members) {
553
+ const rule = typeof capability.selection === "function" ? capability.selection(preferred) : capability.selection ?? "agreed";
554
+ switch (rule) {
555
+ case "agreed": return members;
556
+ case "creator": return [];
557
+ default: return assertNever(rule, "protocol selection rule");
558
+ }
559
+ }
560
+ /**
561
+ * Another reactor's selection for a new document, within `supports`: a
562
+ * negotiated protocol drops to the highest supported version at or below it,
563
+ * or takes its baseline when absent; another known protocol must be
564
+ * supported; an unknown one passes, as refusalFor admits it.
565
+ */
566
+ function capSelection(selected, capabilities, supports) {
567
+ const capped = { ...selected };
568
+ for (const capability of capabilities) {
569
+ if (capability.kind !== "protocol") continue;
570
+ const runs = supports.protocols[capability.name] ?? [];
571
+ const version = capped[capability.name];
572
+ if (capability.preferred) {
573
+ const fits = version === void 0 ? capability.baseline.filter((v) => runs.includes(v)) : runs.filter((v) => v <= version);
574
+ if (fits.length === 0) throw new Error(`Cannot create at ${capability.name} ${version ?? "baseline"}: this client runs ${runs.join(", ") || "none"}`);
575
+ capped[capability.name] = Math.max(...fits);
576
+ } else if (version !== void 0 && !runs.includes(version)) throw new Error(`Cannot create at ${capability.name} ${version}: this client runs ${runs.join(", ") || "none"}`);
577
+ }
578
+ return capped;
579
+ }
580
+ //#endregion
581
+ //#region document-model/purge.ts
582
+ const PURGE_DOCUMENT = "PURGE_DOCUMENT";
583
+ function isPurgeMarker(value) {
584
+ return ("operation" in value ? value.operation.action : "action" in value ? value.action : value)?.type === PURGE_DOCUMENT;
585
+ }
586
+ /** An unsigned marker; `purgedAtUtcIso` is the action's own timestamp. */
587
+ function purgeDocumentAction(input, options = {}) {
588
+ const timestampUtcMs = options.timestampUtcMs ?? (/* @__PURE__ */ new Date()).toISOString();
589
+ return {
590
+ id: options.id ?? generateActionId(),
591
+ type: PURGE_DOCUMENT,
592
+ scope: "document",
593
+ timestampUtcMs,
594
+ input: {
595
+ documentId: input.documentId,
596
+ documentType: input.documentType,
597
+ purgedAtUtcIso: timestampUtcMs,
598
+ requestId: input.requestId
599
+ }
600
+ };
601
+ }
602
+ /** The sole row of a purged stream: document/main, index 0, skip 0, hash "". */
603
+ function purgeMarkerOperation(action) {
604
+ return {
605
+ id: deriveOperationId(action.input.documentId, "document", "main", action.id),
606
+ index: 0,
607
+ skip: 0,
608
+ timestampUtcMs: action.timestampUtcMs,
609
+ hash: "",
610
+ action
611
+ };
612
+ }
613
+ /** Protocol versions of a purged id; derived, never stored. */
614
+ function purgedProtocolVersions() {
615
+ return { [DOCUMENT_PURGE_PROTOCOL]: 1 };
616
+ }
617
+ //#endregion
618
+ export { DOCUMENT_SCOPE_ACTION_TYPES as $, assertNever as A, isBaseReducerVersion as B, BASE_REDUCER_VERSIONS as C, acceptsSubmittedRetract as D, RULE_EXEMPT_SCOPES as E, capabilitiesOf as F, skipMayUndo as G, needsTaggedModel as H, conflictWindowMovesEveryRow as I, usesRetractionRule as J, sortsJobsCanonically as K, createdCapabilities as L, baseReducerVersion as M, baseReducerVersionsFor as N, acceptsSubmittedUndoRedo as O, capabilitiesFor as P, CanonicalJsonError as Q, derivesByRule as R, selectProtocolVersions as S, FLAGS_FOR_EVERY_VERSION as T, optionalBaseReducerCapabilities as U, modelRunsBaseReducer as V, refusalFor as W, tagStateReducer as X, stateReducerOf as Y, ACTION_SIGNATURE_V2_PREFIX as Z, localSupports as _, purgedProtocolVersions as a, isV2ActionHash as at, peerSupports as b, MARKER_REFUSAL_FEATURE as c, v2TupleProblem as ct, capSelection as d, actionPreimageV2 as et, coversLocal as f, localPeerManifest as g, legacySupports as h, purgeMarkerOperation as i, hashActionV2 as it, baseReducerCapabilities as j, appliesRewind as k, PEER_CAPABILITIES as l, isOlderManifest as m, isPurgeMarker as n, actionSigningTarget as nt, DOCUMENT_PURGE_PROTOCOL as o, signActionV2 as ot, holdReason as p, tieOrderOf as q, purgeDocumentAction as r, canonicalJson as rt, FLAGLESS_BASE_REDUCER_VERSION as s, targetDocumentId as st, PURGE_DOCUMENT as t, actionSignerIdentity as tt, PEER_MANIFEST_FORMAT as u, manifestRevision as v, CAPABILITY_DECISIONS as w, readPeerManifest as x, mergePeerCapabilities as y, documentDerivesByRule as z };
619
+
620
+ //# sourceMappingURL=purge-BOqSpe4O.js.map