allyhub 0.10.0 → 0.11.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 (357) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/commands/dev.js +2 -2
  3. package/dist/commands/frames/report.js +2 -0
  4. package/dist/commands/frames.js +11 -9
  5. package/dist/commands/render.js +2 -2
  6. package/dist/node_modules/@allyhub/3d-extension/dist/stage-routes.js +1 -1
  7. package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
  8. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  9. package/dist/node_modules/@allyhub/browser/dist/emoji.d.ts +29 -0
  10. package/dist/node_modules/@allyhub/browser/dist/emoji.js +57 -0
  11. package/dist/node_modules/@allyhub/browser/dist/picture.d.ts +18 -0
  12. package/dist/node_modules/@allyhub/browser/dist/picture.js +2 -0
  13. package/dist/node_modules/@allyhub/browser/package.json +9 -1
  14. package/dist/node_modules/@allyhub/build/dist/index.d.ts +1 -0
  15. package/dist/node_modules/@allyhub/build/dist/index.js +1 -1
  16. package/dist/node_modules/@allyhub/build/dist/kind-build.d.ts +7 -0
  17. package/dist/node_modules/@allyhub/build/dist/made-notes.d.ts +9 -0
  18. package/dist/node_modules/@allyhub/build/dist/made-notes.js +2 -0
  19. package/dist/node_modules/@allyhub/build/dist/project-tool.d.ts +17 -0
  20. package/dist/node_modules/@allyhub/build/dist/stage-route.d.ts +7 -0
  21. package/dist/node_modules/@allyhub/build/package.json +1 -1
  22. package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
  23. package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
  24. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  25. package/dist/node_modules/@allyhub/check/package.json +1 -1
  26. package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
  27. package/dist/node_modules/@allyhub/cloud/package.json +1 -1
  28. package/dist/node_modules/@allyhub/components/package.json +1 -1
  29. package/dist/node_modules/@allyhub/dev-server/dist/exports.js +1 -1
  30. package/dist/node_modules/@allyhub/dev-server/dist/index.js +1 -1
  31. package/dist/node_modules/@allyhub/dev-server/dist/inputs.js +2 -0
  32. package/dist/node_modules/@allyhub/dev-server/dist/live.js +1 -1
  33. package/dist/node_modules/@allyhub/dev-server/dist/pages.js +2 -0
  34. package/dist/node_modules/@allyhub/dev-server/dist/ports.js +2 -0
  35. package/dist/node_modules/@allyhub/dev-server/dist/project.js +1 -1
  36. package/dist/node_modules/@allyhub/dev-server/dist/record.js +1 -1
  37. package/dist/node_modules/@allyhub/dev-server/dist/respond.js +2 -0
  38. package/dist/node_modules/@allyhub/dev-server/dist/reveal.js +1 -1
  39. package/dist/node_modules/@allyhub/dev-server/dist/routes.js +1 -1
  40. package/dist/node_modules/@allyhub/dev-server/dist/server.js +2 -2
  41. package/dist/node_modules/@allyhub/dev-server/dist/tools.js +1 -1
  42. package/dist/node_modules/@allyhub/dev-server/dist/watcher.js +1 -1
  43. package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
  44. package/dist/node_modules/@allyhub/diagnostics/dist/problem.d.ts +7 -0
  45. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  46. package/dist/node_modules/@allyhub/doc/dist/html.js +15 -59
  47. package/dist/node_modules/@allyhub/doc/dist/page.js +1 -1
  48. package/dist/node_modules/@allyhub/doc/package.json +1 -1
  49. package/dist/node_modules/@allyhub/doc-extension/dist/export.js +1 -1
  50. package/dist/node_modules/@allyhub/doc-extension/package.json +12 -14
  51. package/dist/node_modules/@allyhub/doc-print/dist/pages.js +5 -5
  52. package/dist/node_modules/@allyhub/doc-print/dist/print.js +10 -10
  53. package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
  54. package/dist/node_modules/@allyhub/export/package.json +1 -1
  55. package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
  56. package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
  57. package/dist/node_modules/@allyhub/formats/dist/note-shape.d.ts +20 -0
  58. package/dist/node_modules/@allyhub/formats/dist/note-shape.js +1 -1
  59. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  60. package/dist/node_modules/@allyhub/i18n/package.json +1 -1
  61. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  62. package/dist/node_modules/@allyhub/image-extension/dist/export.js +4 -1
  63. package/dist/node_modules/@allyhub/image-extension/package.json +1 -6
  64. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  65. package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
  66. package/dist/node_modules/@allyhub/image-render/package.json +1 -1
  67. package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
  68. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  69. package/dist/node_modules/@allyhub/jobs/package.json +1 -1
  70. package/dist/node_modules/@allyhub/linkedin-extension/LICENSE +241 -0
  71. package/dist/node_modules/@allyhub/linkedin-extension/dist/article-build.js +2 -0
  72. package/dist/node_modules/@allyhub/linkedin-extension/dist/article-kind.js +2 -0
  73. package/dist/node_modules/@allyhub/linkedin-extension/dist/build-plugins.js +2 -0
  74. package/dist/node_modules/@allyhub/linkedin-extension/dist/build.js +5 -0
  75. package/dist/node_modules/@allyhub/linkedin-extension/dist/media.js +2 -0
  76. package/dist/node_modules/@allyhub/linkedin-extension/dist/stage-module.js +82 -0
  77. package/dist/node_modules/@allyhub/linkedin-extension/dist/stage.js +2 -0
  78. package/dist/node_modules/@allyhub/linkedin-extension/dist/workspace.js +2 -0
  79. package/dist/node_modules/@allyhub/linkedin-extension/package.json +287 -0
  80. package/dist/node_modules/@allyhub/linkedin-extension/skills/allyhub/references/linkedin.md +12 -0
  81. package/dist/node_modules/@allyhub/linkedin-model/LICENSE +241 -0
  82. package/dist/node_modules/@allyhub/linkedin-model/dist/article-check.js +5 -0
  83. package/dist/node_modules/@allyhub/linkedin-model/dist/article.js +3 -0
  84. package/dist/node_modules/@allyhub/linkedin-model/dist/check.js +2 -0
  85. package/dist/node_modules/@allyhub/linkedin-model/dist/count.js +3 -0
  86. package/dist/node_modules/@allyhub/linkedin-model/dist/edit.js +3 -0
  87. package/dist/node_modules/@allyhub/linkedin-model/dist/html.js +19 -0
  88. package/dist/node_modules/@allyhub/linkedin-model/dist/index.js +2 -0
  89. package/dist/node_modules/@allyhub/linkedin-model/dist/limits.js +2 -0
  90. package/dist/node_modules/@allyhub/linkedin-model/dist/little.js +2 -0
  91. package/dist/node_modules/@allyhub/linkedin-model/dist/post.js +2 -0
  92. package/dist/node_modules/@allyhub/linkedin-model/dist/requests.js +2 -0
  93. package/dist/node_modules/@allyhub/linkedin-model/package.json +14 -0
  94. package/dist/node_modules/@allyhub/linkedin-view/LICENSE +241 -0
  95. package/dist/node_modules/@allyhub/linkedin-view/dist/article.js +2 -0
  96. package/dist/node_modules/@allyhub/linkedin-view/dist/fold.js +3 -0
  97. package/dist/node_modules/@allyhub/linkedin-view/dist/index.js +2 -0
  98. package/dist/node_modules/@allyhub/linkedin-view/dist/post.js +2 -0
  99. package/dist/node_modules/@allyhub/linkedin-view/dist/stage.js +2 -0
  100. package/dist/node_modules/@allyhub/linkedin-view/dist/text.js +2 -0
  101. package/dist/node_modules/@allyhub/linkedin-view/package.json +21 -0
  102. package/dist/node_modules/@allyhub/linkedin-view/src/style.css +600 -0
  103. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  104. package/dist/node_modules/@allyhub/media/package.json +1 -1
  105. package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
  106. package/dist/node_modules/@allyhub/model/package.json +1 -1
  107. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  108. package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +2 -0
  109. package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +1 -1
  110. package/dist/node_modules/@allyhub/piece/dist/page/index.js +1 -1
  111. package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +14 -1
  112. package/dist/node_modules/@allyhub/piece/dist/page/locate.js +1 -1
  113. package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +12 -0
  114. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  115. package/dist/node_modules/@allyhub/project/package.json +1 -1
  116. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +8 -0
  117. package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +4 -0
  118. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  119. package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +6 -0
  120. package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
  121. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +61 -1
  122. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  123. package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +0 -1
  124. package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
  125. package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +41 -3
  126. package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
  127. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +17 -0
  128. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  129. package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +7 -0
  130. package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
  131. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +12 -0
  132. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  133. package/dist/node_modules/@allyhub/protocol/package.json +1 -5
  134. package/dist/node_modules/@allyhub/registry/package.json +1 -1
  135. package/dist/node_modules/@allyhub/render/dist/encode.js +1 -1
  136. package/dist/node_modules/@allyhub/render/dist/index.js +1 -1
  137. package/dist/node_modules/@allyhub/render/dist/render.js +2 -2
  138. package/dist/node_modules/@allyhub/render/package.json +1 -1
  139. package/dist/node_modules/@allyhub/report-extension/LICENSE +241 -0
  140. package/dist/node_modules/@allyhub/report-extension/dist/build.js +2 -0
  141. package/dist/node_modules/@allyhub/report-extension/dist/check.js +3 -0
  142. package/dist/node_modules/@allyhub/report-extension/dist/cli/find.js +2 -0
  143. package/dist/node_modules/@allyhub/report-extension/dist/cli/index.js +5 -0
  144. package/dist/node_modules/@allyhub/report-extension/dist/cli/picture.js +2 -0
  145. package/dist/node_modules/@allyhub/report-extension/dist/export.js +2 -0
  146. package/dist/node_modules/@allyhub/report-extension/dist/inline.js +58 -0
  147. package/dist/node_modules/@allyhub/report-extension/dist/page.js +21 -0
  148. package/dist/node_modules/@allyhub/report-extension/dist/project-tools.js +21 -0
  149. package/dist/node_modules/@allyhub/report-extension/dist/styles.js +5 -0
  150. package/dist/node_modules/@allyhub/report-extension/dist/theme.js +2 -0
  151. package/dist/node_modules/@allyhub/report-extension/dist/tools.js +2 -0
  152. package/dist/node_modules/@allyhub/report-extension/dist/workspace.js +2 -0
  153. package/dist/node_modules/@allyhub/report-extension/package.json +182 -0
  154. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/STYLE.md +132 -0
  155. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.css +105 -0
  156. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.json +17 -0
  157. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/tokens.js +38 -0
  158. package/dist/node_modules/@allyhub/runtime/dist/compose.js +1 -1
  159. package/dist/node_modules/@allyhub/runtime/dist/player/player.js +1 -1
  160. package/dist/node_modules/@allyhub/runtime/package.json +1 -1
  161. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  162. package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
  163. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  164. package/dist/node_modules/@allyhub/scenery-host/dist/layer/index.js +1 -1
  165. package/dist/node_modules/@allyhub/scenery-host/dist/viewer.d.ts +6 -0
  166. package/dist/node_modules/@allyhub/scenery-host/dist/viewer.js +1 -1
  167. package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
  168. package/dist/node_modules/@allyhub/sheet/dist/export.js +2 -4
  169. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  170. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  171. package/dist/node_modules/@allyhub/sheet-extension/dist/export.js +2 -6
  172. package/dist/node_modules/@allyhub/sheet-extension/package.json +3 -7
  173. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  174. package/dist/node_modules/@allyhub/slides-extension/dist/export.js +1 -1
  175. package/dist/node_modules/@allyhub/slides-extension/package.json +3 -16
  176. package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
  177. package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +1 -1
  178. package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
  179. package/dist/node_modules/@allyhub/stage/package.json +1 -1
  180. package/dist/node_modules/@allyhub/stage-page/dist/install.js +1 -1
  181. package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.js +1 -1
  182. package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
  183. package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +14 -14
  184. package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
  185. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  186. package/dist/node_modules/@allyhub/video-extension/dist/export.js +1 -1
  187. package/dist/node_modules/@allyhub/video-extension/package.json +2 -4
  188. package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
  189. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  190. package/dist/node_modules/@allyhub/website/package.json +1 -1
  191. package/dist/node_modules/@allyhub/website-extension/dist/preview.js +5 -5
  192. package/dist/node_modules/@allyhub/website-extension/dist/project-tools.js +2 -2
  193. package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
  194. package/dist/node_modules/@allyhub/x-extension/dist/build.js +4 -3
  195. package/dist/node_modules/@allyhub/x-extension/package.json +10 -12
  196. package/dist/node_modules/@allyhub/x-model/package.json +1 -1
  197. package/dist/node_modules/@allyhub/x-view/package.json +1 -1
  198. package/dist/package.json +12 -10
  199. package/dist/works.js +1 -1
  200. package/editor-web/assets/{abnfDiagram-WEYOIA3C-CjAmWsNR.js → abnfDiagram-WEYOIA3C-BKmMA6gn.js} +1 -1
  201. package/editor-web/assets/{architecture-WOLXFQ4H-DeeKhyhZ.js → architecture-WOLXFQ4H-BEFBgb4k.js} +1 -1
  202. package/editor-web/assets/{architectureDiagram-ZHVYKT53-b32qTaJg.js → architectureDiagram-ZHVYKT53-_u5YfCjY.js} +1 -1
  203. package/editor-web/assets/{arrow-up-L4YV_65f.js → arrow-up-B5rJbBv0.js} +1 -1
  204. package/editor-web/assets/article-BUmD3xtR.js +8 -0
  205. package/editor-web/assets/article-DNioBb3p.js +7 -0
  206. package/editor-web/assets/{audio-lines-BFcM7G2L.js → audio-lines-CzuzsGjI.js} +1 -1
  207. package/editor-web/assets/{blockDiagram-RJAE7QA3-BNbnMNmw.js → blockDiagram-RJAE7QA3-DybfaO3Z.js} +1 -1
  208. package/editor-web/assets/bookmark-Dsd3kHJJ.js +1 -0
  209. package/editor-web/assets/button-eGxLxbv9.js +41 -0
  210. package/editor-web/assets/{c4Diagram-XDPPPE54-BEuemvMw.js → c4Diagram-XDPPPE54-BfqLHB5i.js} +1 -1
  211. package/editor-web/assets/channel-TNPgFDrw.js +1 -0
  212. package/editor-web/assets/chart-C37xvZT2.js +1 -0
  213. package/editor-web/assets/chart-no-axes-column-BVkeF_Mr.js +1 -0
  214. package/editor-web/assets/{chunk-2E7WHVMD-Zb5nPx_e.js → chunk-2E7WHVMD-BVp1I_d0.js} +1 -1
  215. package/editor-web/assets/{chunk-4EMNKR2T-DSEM2reX.js → chunk-4EMNKR2T-CTdgWEMr.js} +1 -1
  216. package/editor-web/assets/{chunk-55XCU76K-BOZa_65H.js → chunk-55XCU76K-7pnsxeaP.js} +1 -1
  217. package/editor-web/assets/{chunk-7S6XSTFO-DeiGeVpB.js → chunk-7S6XSTFO-Dc0Dvkq7.js} +1 -1
  218. package/editor-web/assets/{chunk-AQDTSKZB-fPuQFBJc.js → chunk-AQDTSKZB-VAILIsfx.js} +1 -1
  219. package/editor-web/assets/{chunk-DSNLSHJZ-5vdnoak2.js → chunk-DSNLSHJZ-CUDx1Rv5.js} +1 -1
  220. package/editor-web/assets/{chunk-HAGFOTED-DFF2mZJ1.js → chunk-HAGFOTED-DAoEe-dJ.js} +1 -1
  221. package/editor-web/assets/{chunk-HNE4Q36P-g6-ZLbTg.js → chunk-HNE4Q36P-g0akya12.js} +1 -1
  222. package/editor-web/assets/{chunk-NQOKRVIF-o3hNcHMJ.js → chunk-NQOKRVIF-hTGjzXdJ.js} +1 -1
  223. package/editor-web/assets/{chunk-UHW7PFBP-BQiDI9dK.js → chunk-UHW7PFBP-BgLV8BIJ.js} +1 -1
  224. package/editor-web/assets/{chunk-VQ5W62QI-CJlMXWWz.js → chunk-VQ5W62QI-Bw19OOSD.js} +1 -1
  225. package/editor-web/assets/{chunk-WQQL4CDK-pNBU8dXv.js → chunk-WQQL4CDK-CMST9dyE.js} +1 -1
  226. package/editor-web/assets/{chunk-YZO67HFG-2x-BiWd-.js → chunk-YZO67HFG-Bbpu36XF.js} +1 -1
  227. package/editor-web/assets/{chunk-ZAUX2LTX-etFStEM8.js → chunk-ZAUX2LTX-C48Ri0Gs.js} +1 -1
  228. package/editor-web/assets/{chunk-ZCHMQSOR-B3AYRhIY.js → chunk-ZCHMQSOR-DN1g01Oe.js} +1 -1
  229. package/editor-web/assets/{classDiagram-v2-4MYWR3UA-6y2yX0oq.js → classDiagram-v2-4MYWR3UA-U6jbPr2d.js} +1 -1
  230. package/editor-web/assets/{collaborator-LRd0hELn.js → collaborator-B1u2td9m.js} +1 -1
  231. package/editor-web/assets/{createLucideIcon-CPS-TrJJ.js → createLucideIcon-GFZ_fxLc.js} +1 -1
  232. package/editor-web/assets/{cynefin-EF2NZ3EQ-CX4BTQQe.js → cynefin-EF2NZ3EQ-gzkai_7-.js} +1 -1
  233. package/editor-web/assets/{cynefinDiagram-WF24UDRP-LbDkOTy3.js → cynefinDiagram-WF24UDRP-DtSekSr6.js} +1 -1
  234. package/editor-web/assets/{dagre-NK4GIZVX-wCKQk7hi.js → dagre-NK4GIZVX-CiUwYVT6.js} +1 -1
  235. package/editor-web/assets/{diagram-CBK3MWTC-a9fofQwk.js → diagram-CBK3MWTC-r9XHCV-k.js} +1 -1
  236. package/editor-web/assets/{diagram-I5XIIV2D-UCLZWch5.js → diagram-I5XIIV2D-DxVsDZ34.js} +1 -1
  237. package/editor-web/assets/{diagram-ODIL2UCW-CAEe88Lp.js → diagram-ODIL2UCW-B0eNQoHV.js} +1 -1
  238. package/editor-web/assets/{diagram-PFBEJUXE-Cp1o45bs.js → diagram-PFBEJUXE-C7f2MfJT.js} +1 -1
  239. package/editor-web/assets/{diagram-RJA3I4VV-c6OVxDyq.js → diagram-RJA3I4VV-CSXcnvct.js} +1 -1
  240. package/editor-web/assets/{diagram-TYUNFSNR-BVRWslDM.js → diagram-TYUNFSNR-DXzOD_ii.js} +1 -1
  241. package/editor-web/assets/dist-BGRwhCQO.js +1 -0
  242. package/editor-web/assets/{dist-DwGhfliS.js → dist-BW4X7BrF.js} +1 -1
  243. package/editor-web/assets/dist-BgDRE85b.js +2 -0
  244. package/editor-web/assets/dist-Blq5nJnU.js +24 -0
  245. package/editor-web/assets/dist-BuWaZ3Y4.js +274 -0
  246. package/editor-web/assets/dist-C1emZ9wX.js +37 -0
  247. package/editor-web/assets/dist-CC7OeU1e.js +6 -0
  248. package/editor-web/assets/{dist-j6ZLVcgf.js → dist-CX-fiPSn.js} +16 -16
  249. package/editor-web/assets/dist-C_VvG-_9.js +5 -0
  250. package/editor-web/assets/dist-Ce7HrBxv.js +3 -0
  251. package/editor-web/assets/dist-D2k6w-_a.js +1 -0
  252. package/editor-web/assets/dist-DDv_SbKw.js +84 -0
  253. package/editor-web/assets/dist-DEoEO4zs.js +1 -0
  254. package/editor-web/assets/dist-DlDxxPIP.js +16 -0
  255. package/editor-web/assets/dist-Gz6NDS0J.js +4 -0
  256. package/editor-web/assets/{ebnfDiagram-V4P3TTPT-KdOTJgFu.js → ebnfDiagram-V4P3TTPT-Cs4YRvDD.js} +1 -1
  257. package/editor-web/assets/{elk-QONTBCTQ-Cmlrp7qB.js → elk-QONTBCTQ-Bh3LZ9WI.js} +1 -1
  258. package/editor-web/assets/{erDiagram-KYQIGQAA-CBM7-aQm.js → erDiagram-KYQIGQAA-C4vYTYXp.js} +1 -1
  259. package/editor-web/assets/{eventmodeling-K75KTNOO-CEoJkbuW.js → eventmodeling-K75KTNOO-BN1kkHWS.js} +1 -1
  260. package/editor-web/assets/flowDiagram-IUGLLWBU-B04NGsyi.js +1 -0
  261. package/editor-web/assets/{ganttDiagram-R7GPNTJY-D4S6ZSYD.js → ganttDiagram-R7GPNTJY-CA1LkkC5.js} +1 -1
  262. package/editor-web/assets/{gitGraph-VSP46ZUC-BvkL6RSh.js → gitGraph-VSP46ZUC-Dy5tA7dG.js} +1 -1
  263. package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-lTGguloH.js → gitGraphDiagram-PDYL7XHY-hJIB8EkH.js} +1 -1
  264. package/editor-web/assets/{hint-BimUgJms.js → hint-B8JpEypy.js} +1 -1
  265. package/editor-web/assets/index-CgB5osVc.js +28 -0
  266. package/editor-web/assets/index-Daytem9N.css +2 -0
  267. package/editor-web/assets/{info-OHQRW6UA-DvKzqNvp.js → info-OHQRW6UA-DvzSf7rQ.js} +1 -1
  268. package/editor-web/assets/{infoDiagram-MVDRKAX5-D7hCpehs.js → infoDiagram-MVDRKAX5-BjIMm4Af.js} +1 -1
  269. package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-Bg93sZQe.js → ishikawaDiagram-HPEHV2GE-Bpz71S40.js} +1 -1
  270. package/editor-web/assets/{italic-BQBwRTe8.js → italic-D10w8n6C.js} +1 -1
  271. package/editor-web/assets/{journeyDiagram-BOSHW7O7-CKm_KONJ.js → journeyDiagram-BOSHW7O7-DAB-pZjD.js} +1 -1
  272. package/editor-web/assets/{kanban-definition-FNSA4HC5-BKknnpTR.js → kanban-definition-FNSA4HC5-cYeyh3P6.js} +1 -1
  273. package/editor-web/assets/katex-5Z2zF-9g.js +257 -0
  274. package/editor-web/assets/link-BC5xK1-1.js +1 -0
  275. package/editor-web/assets/{mermaid-parser.core-BzqkDnqL.js → mermaid-parser.core-req5LE0X.js} +3 -3
  276. package/editor-web/assets/{mermaid.core-CEpvTOAe.js → mermaid.core-zFwZug4C.js} +4 -4
  277. package/editor-web/assets/{mindmap-definition-6OY57UG3-BJ0qG8Wi.js → mindmap-definition-6OY57UG3-TStWb7DG.js} +1 -1
  278. package/editor-web/assets/minus-DaWs5i8B.js +1 -0
  279. package/editor-web/assets/{packet-JDAUHWVQ-ew3kvyFm.js → packet-JDAUHWVQ-smFhVKcB.js} +1 -1
  280. package/editor-web/assets/palette-BIOudGkm.js +1 -0
  281. package/editor-web/assets/{pegDiagram-ECIUJNBX-DqUS2xit.js → pegDiagram-ECIUJNBX-DvSNRv0-.js} +1 -1
  282. package/editor-web/assets/{pie-XZMESJXO-DTIAMPGm.js → pie-XZMESJXO-qjaGsBZG.js} +1 -1
  283. package/editor-web/assets/{pieDiagram-GNMPY74T-DoKOE02-.js → pieDiagram-GNMPY74T-Dd9P-Pdc.js} +1 -1
  284. package/editor-web/assets/play-CrMmPghG.js +1 -0
  285. package/editor-web/assets/{progress-CPEbDOoN.js → progress-DE4C5_3x.js} +1 -1
  286. package/editor-web/assets/props-form-CsmDBqzy.js +1 -0
  287. package/editor-web/assets/{quadrantDiagram-D57K4MC3-DauOpYun.js → quadrantDiagram-D57K4MC3-h2IIKUUA.js} +1 -1
  288. package/editor-web/assets/{radar-ABXABTNO-BvMJXUU-.js → radar-ABXABTNO-DlVrSA1d.js} +1 -1
  289. package/editor-web/assets/{railroad-I3PHUGI6-D3jdJmhM.js → railroad-I3PHUGI6-nFbuLAtc.js} +1 -1
  290. package/editor-web/assets/{railroad-abnf-LNEFI6M7-Dm8ZpmPj.js → railroad-abnf-LNEFI6M7-Daj8h2iV.js} +1 -1
  291. package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-oc0Du7Ag.js → railroad-ebnf-DWYD2UWJ-eYJyl5PH.js} +1 -1
  292. package/editor-web/assets/{railroad-peg-JR7BVNR7-CMrQL_7U.js → railroad-peg-JR7BVNR7-BTRhKZQq.js} +1 -1
  293. package/editor-web/assets/{railroadDiagram-Y72NRBL7-y99z0C7i.js → railroadDiagram-Y72NRBL7-CeLGUjdp.js} +1 -1
  294. package/editor-web/assets/{react-DztDSW4P.js → react-WA6wlt8S.js} +1 -1
  295. package/editor-web/assets/{repeat-2-DJi4LW5C.js → repeat-2-VQP1EVOZ.js} +1 -1
  296. package/editor-web/assets/{requirementDiagram-EQYSW5RA-jMr_uoF6.js → requirementDiagram-EQYSW5RA-Dmk9XRM5.js} +1 -1
  297. package/editor-web/assets/{row-ClBisiBs.js → row-BRlEWRrK.js} +1 -1
  298. package/editor-web/assets/{sankeyDiagram-SY24JHO5-DcUyx03Q.js → sankeyDiagram-SY24JHO5-Yn4zlrAM.js} +1 -1
  299. package/editor-web/assets/{schemas-68mjUjP5.js → schemas-VikZYZIK.js} +1 -1
  300. package/editor-web/assets/{sequenceDiagram-BLEHNHQU-R4X8wRCd.js → sequenceDiagram-BLEHNHQU-BTRnp_PW.js} +1 -1
  301. package/editor-web/assets/{session-2u9U7koW.js → session-Do9AqS38.js} +1 -1
  302. package/editor-web/assets/{slides-BByblSSR.js → slides-diTEQ3C5.js} +1 -1
  303. package/editor-web/assets/{snapshots-C9KV-Y2_.js → snapshots-BUGlKQIB.js} +1 -1
  304. package/editor-web/assets/{sound-DExlNJbb.js → sound-Bj3o9_Fa.js} +1 -1
  305. package/editor-web/assets/split-CNU1RHcX.js +3 -0
  306. package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-BqvXKbCA.js → stateDiagram-v2-A6IESKWZ-kstrRKv2.js} +1 -1
  307. package/editor-web/assets/{strikethrough-CyUBnGTl.js → strikethrough-CfXx6IYH.js} +1 -1
  308. package/editor-web/assets/{svg-lBRT-uhy.js → svg-Cx50MpxK.js} +1 -1
  309. package/editor-web/assets/{swatch-1c1uVn1z.js → swatch-WeJD41aW.js} +1 -1
  310. package/editor-web/assets/{swimlanes-B3ENRKFQ-hjTXIc6M.js → swimlanes-B3ENRKFQ-DaZsZkeP.js} +1 -1
  311. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-CBZAujYY.js +8 -0
  312. package/editor-web/assets/{switch-D0K-K8-C.js → switch-N0G_sbqt.js} +1 -1
  313. package/editor-web/assets/syntax-BVsgRJ4I.js +66 -0
  314. package/editor-web/assets/syntax-oWsKBWFw.js +1 -0
  315. package/editor-web/assets/table-B6hVZAMi.js +1 -0
  316. package/editor-web/assets/{tabs-CxxOnGLR.js → tabs-DIFDqj-l.js} +1 -1
  317. package/editor-web/assets/{textarea-Fu93tFO3.js → textarea-tEWvBY9p.js} +1 -1
  318. package/editor-web/assets/{timeline-definition-JXYKGLGB-BcSoN4Dq.js → timeline-definition-JXYKGLGB-CLCvY-Yf.js} +1 -1
  319. package/editor-web/assets/{trash-2-BAKAeziW.js → trash-2-BP6nqpg2.js} +1 -1
  320. package/editor-web/assets/{treeView-D4JQ5SDB-CsFN2jrc.js → treeView-D4JQ5SDB-BmN0gwdC.js} +1 -1
  321. package/editor-web/assets/{treemap-SAJKECNS-DP1eqXJ2.js → treemap-SAJKECNS-DN29G_E_.js} +1 -1
  322. package/editor-web/assets/{undo-2-DQ5CBmki.js → undo-2-CHR0nvWL.js} +1 -1
  323. package/editor-web/assets/{usecaseDiagram-WPOLBNNX-BGxa0osF.js → usecaseDiagram-WPOLBNNX-DTRS54cB.js} +1 -1
  324. package/editor-web/assets/{vennDiagram-Q3Y3IDCW-D2XhTF49.js → vennDiagram-Q3Y3IDCW-DAAc11Hx.js} +1 -1
  325. package/editor-web/assets/{video-CDbPX4Cr.js → video-BlvmR8BK.js} +1 -1
  326. package/editor-web/assets/{wardley-7MLQ67FV-DM3jMAbZ.js → wardley-7MLQ67FV-B-UYkmdB.js} +1 -1
  327. package/editor-web/assets/{wardleyDiagram-IVAIDKWA-Bf-DaZEg.js → wardleyDiagram-IVAIDKWA-BmbwCaky.js} +1 -1
  328. package/editor-web/assets/words-D_4T9Adq.js +3 -0
  329. package/editor-web/assets/words-WgdEQdYP.js +2 -0
  330. package/editor-web/assets/{xychartDiagram-4URNHDU4-dp-mdcWd.js → xychartDiagram-4URNHDU4-ChAfAq1U.js} +1 -1
  331. package/editor-web/index.html +6 -6
  332. package/package.json +8 -2
  333. package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.d.ts +0 -337
  334. package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.js +0 -2
  335. package/editor-web/assets/alt-DnBZJzEh.js +0 -4
  336. package/editor-web/assets/article-DLMjAdbP.js +0 -73
  337. package/editor-web/assets/button-Chk675Xu.js +0 -41
  338. package/editor-web/assets/channel-EzYq4r0d.js +0 -1
  339. package/editor-web/assets/chart-Be9Hj5GL.js +0 -1
  340. package/editor-web/assets/choice-BgmBh4yu.js +0 -1
  341. package/editor-web/assets/dist--KKyT5zP.js +0 -340
  342. package/editor-web/assets/dist-1k0MHB3i.js +0 -1
  343. package/editor-web/assets/dist-B9KHJqL5.js +0 -4
  344. package/editor-web/assets/dist-BbJyrhIY.js +0 -1
  345. package/editor-web/assets/dist-CJXCQxQM.js +0 -37
  346. package/editor-web/assets/dist-D9xQGwe9.js +0 -5
  347. package/editor-web/assets/dist-DFiLzbx8.js +0 -219
  348. package/editor-web/assets/dist-DIPV6xfF.js +0 -2
  349. package/editor-web/assets/dist-Dp-fQMtx.js +0 -6
  350. package/editor-web/assets/dist-Duw28VxJ.js +0 -16
  351. package/editor-web/assets/dist-OBE2IIYP.js +0 -24
  352. package/editor-web/assets/flowDiagram-IUGLLWBU-Xm2E2ib_.js +0 -1
  353. package/editor-web/assets/index-C-i_iuxN.js +0 -28
  354. package/editor-web/assets/index-Cxh_Shkm.css +0 -2
  355. package/editor-web/assets/minus-oPj1GxwA.js +0 -1
  356. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-BLfytmPY.js +0 -8
  357. package/editor-web/assets/syntax-Bih_jv7W.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{randomBytes as d}from"node:crypto";import{basename as f,join as n}from"node:path";import{exportProject as m}from"@allyhub/export";import{JobFailure as p}from"@allyhub/jobs";import{OUT_DIR as u}from"@allyhub/formats";import{parseCombo as w}from"@allyhub/project";import{projectPathOf as g}from"./paths.js";export class Exports{root;changed;jobs=[];aborts=new Map;queue=Promise.resolve();asJobs;kinds;processors;analyses;constructor(t,r,s,a,e={}){this.root=t,this.kinds=r,this.processors=e.processors??[],this.analyses=e.analyses??[],this.changed=s,this.asJobs=a}list(){return this.jobs.map(t=>({...t}))}start(t,r,s,a){const e={id:`x${d(4).toString("hex")}`,item:t,versions:r,types:s,...a?{options:a}:{},state:"queued",progress:0,files:[]};this.jobs.push(e);const o=new AbortController;return this.aborts.set(e.id,o),this.changed({...e}),this.queue=this.queue.then(()=>this.run(e,o.signal)),{...e}}cancel(t){const r=this.jobs.find(s=>s.id===t);return!r||r.state==="done"||r.state==="failed"?!1:(this.aborts.get(t)?.abort(),this.set(r,{state:"cancelled"}),!0)}idle(){return this.queue}async close(){for(const t of this.aborts.values())t.abort();await this.queue}watchers=new Set;set(t,r){Object.assign(t,r),this.changed({...t});for(const s of this.watchers)s(t)}async run(t,r){if(t.state==="cancelled")return;const s=this.asJobs;if(s===void 0)return this.make(t,r);const a=await s.nameOf(t.item).catch(()=>f(t.item));let e=0;const o=async()=>{await this.queue;const i=new AbortController;return this.aborts.set(t.id,i),delete t.error,this.set(t,{state:"queued",progress:0,files:[]}),i.signal};await s.jobs.run({about:{kind:"piece",id:n(this.root,t.item)},what:"export",name:a,unit:"share",total:1},async i=>{i.signal.addEventListener("abort",()=>{this.cancel(t.id)});const h=l=>{l.id===t.id&&i.report(l.progress,1)};this.watchers.add(h);try{await this.make(t,e++===0?r:await o())}finally{this.watchers.delete(h)}if(t.state==="cancelled")throw new DOMException("The export was cancelled.","AbortError");if(t.state==="failed")throw new p("other",t.error??"The export failed.");const[c]=t.files;c!==void 0&&i.made(n(this.root,c))}).catch(()=>{})}async make(t,r){this.set(t,{state:"running"});try{const s=await m({root:this.root,kinds:this.kinds,processors:this.processors,analyses:this.analyses,items:[t.item],...t.versions.length?{combos:t.versions.map(e=>w(e))}:{},...t.types.length?{types:t.types}:{},...t.options?{params:t.options}:{},out:n(this.root,u),signal:r,onProgress:e=>{r.aborted||this.set(t,{progress:Math.max(t.progress,Math.min(1,e))})}}),a=s.files.flatMap(e=>e.files).map(e=>g(this.root,e)).filter(e=>e!==void 0);r.aborted?this.set(t,{state:"cancelled",files:a}):s.failed.length>0&&a.length===0?this.set(t,{state:"failed",error:s.failed.map(e=>e.message).join(" ")}):this.set(t,{state:"done",progress:1,files:a,...s.failed.length>0?{error:[...new Map(s.failed.map(e=>[e.code,e.message])).values()].join(" ")}:{}})}catch(s){this.set(t,{state:r.aborted?"cancelled":"failed",...r.aborted?{}:{error:s instanceof Error?s.message:String(s)}})}finally{this.aborts.delete(t.id)}}}
2
+ import{randomBytes as u}from"node:crypto";import{constants as m}from"node:fs";import{copyFile as p,link as w,mkdir as g,rm as y}from"node:fs/promises";import{basename as f,extname as v,join as c}from"node:path";import{exportProject as x}from"@allyhub/export";import{JobFailure as E}from"@allyhub/jobs";import{OUT_DIR as k}from"@allyhub/formats";import{parseCombo as T}from"@allyhub/project";import{projectPathOf as q}from"./paths.js";export class Exports{root;changed;jobs=[];aborts=new Map;queue=Promise.resolve();asJobs;kinds;processors;analyses;saveTo;saved=new Map;constructor(t,r,e,a,s={}){this.root=t,this.kinds=r,this.processors=s.processors??[],this.analyses=s.analyses??[],this.saveTo=s.saveTo,this.changed=e,this.asJobs=a}list(){return this.jobs.map(t=>({...t}))}start(t,r,e,a){const s={id:`x${u(4).toString("hex")}`,item:t,versions:r,types:e,...a?{options:a}:{},state:"queued",progress:0,files:[]};this.jobs.push(s);const i=new AbortController;return this.aborts.set(s.id,i),this.changed({...s}),this.queue=this.queue.then(()=>this.run(s,i.signal)),{...s}}cancel(t){const r=this.jobs.find(e=>e.id===t);return!r||r.state==="done"||r.state==="failed"?!1:(this.aborts.get(t)?.abort(),this.set(r,{state:"cancelled"}),!0)}savedOf(t){return this.saved.get(t)}idle(){return this.queue}async close(){for(const t of this.aborts.values())t.abort();await this.queue}watchers=new Set;set(t,r){Object.assign(t,r),this.changed({...t});for(const e of this.watchers)e(t)}async run(t,r){if(t.state==="cancelled")return;const e=this.asJobs;if(e===void 0)return this.make(t,r);const a=await e.nameOf(t.item).catch(()=>f(t.item));let s=0;const i=async()=>{await this.queue;const n=new AbortController;return this.aborts.set(t.id,n),delete t.error,this.set(t,{state:"queued",progress:0,files:[]}),n.signal};await e.jobs.run({about:{kind:"piece",id:c(this.root,t.item)},what:"export",name:a,unit:"share",total:1},async n=>{n.signal.addEventListener("abort",()=>{this.cancel(t.id)});const d=l=>{l.id===t.id&&n.report(l.progress,1)};this.watchers.add(d);try{await this.make(t,s++===0?r:await i())}finally{this.watchers.delete(d)}if(t.state==="cancelled")throw new DOMException("The export was cancelled.","AbortError");if(t.state==="failed")throw new E("other",t.error??"The export failed.");const[h]=t.files;h!==void 0&&n.made(this.saved.get(h)??c(this.root,h))}).catch(()=>{})}async save(t){const r=this.saveTo?.();if(r===void 0)return[];try{await g(r,{recursive:!0});for(const e of t)this.saved.set(e,await $(c(this.root,e),r));return[]}catch(e){return[`Not saved in ${r}: ${e instanceof Error?e.message:String(e)}`]}}async make(t,r){this.set(t,{state:"running"});try{const e=await x({root:this.root,kinds:this.kinds,processors:this.processors,analyses:this.analyses,items:[t.item],...t.versions.length?{combos:t.versions.map(s=>T(s))}:{},...t.types.length?{types:t.types}:{},...t.options?{params:t.options}:{},out:c(this.root,k),signal:r,onProgress:s=>{r.aborted||this.set(t,{progress:Math.max(t.progress,Math.min(1,s))})}}),a=e.files.flatMap(s=>s.files).map(s=>q(this.root,s)).filter(s=>s!==void 0);if(r.aborted)this.set(t,{state:"cancelled",files:a});else if(e.failed.length>0&&a.length===0)this.set(t,{state:"failed",error:e.failed.map(s=>s.message).join(" ")});else{const s=[...new Map(e.failed.map(i=>[i.code,i.message])).values(),...await this.save(a)];this.set(t,{state:"done",progress:1,files:a,...s.length>0?{error:s.join(" ")}:{}})}}catch(e){this.set(t,{state:r.aborted?"cancelled":"failed",...r.aborted?{}:{error:e instanceof Error?e.message:String(e)}})}finally{this.aborts.delete(t.id)}}}async function $(o,t){const r=v(o),e=f(o,r);for(let a=0;;a++){const s=c(t,a===0?`${e}${r}`:`${e} (${String(a)})${r}`);try{await w(o,s).catch(i=>{if(i.code==="EEXIST")throw i;return p(o,s,m.COPYFILE_EXCL)})}catch(i){if(i.code==="EEXIST")continue;throw i}return await y(o,{force:!0}),s}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export{PING_MS,RAW_PATH,RPC_PATH,forwardedHost,startDevServer}from"./server.js";export{ProjectServer,SERVER_METHODS}from"./project.js";export{Writer,LIST_LIMIT,UPLOAD_MAX_BYTES}from"./writer.js";export{Watcher}from"./watcher.js";export{Presence}from"./presence.js";export{changedLines}from"./texts.js";export{writeProblems,dataFileOf}from"./validate.js";export{pathProblem,versionOf}from"./paths.js";export{SETTLE_MS}from"./background.js";export{recordTree}from"./record.js";export{itemPreview,projectName}from"./card.js";export{hasFileManager,revealFile}from"./reveal.js";
2
+ export{PING_MS,RAW_PATH,RPC_PATH,forwardedHost,startDevServer}from"./server.js";export{ProjectServer,SERVER_METHODS}from"./project.js";export{Writer,LIST_LIMIT,UPLOAD_MAX_BYTES}from"./writer.js";export{Watcher}from"./watcher.js";export{Presence}from"./presence.js";export{changedLines}from"./texts.js";export{writeProblems,dataFileOf}from"./validate.js";export{pathProblem,versionOf}from"./paths.js";export{SETTLE_MS}from"./background.js";export{recordTree}from"./record.js";export{itemPreview,projectName}from"./card.js";export{downloadsFolder,hasFileManager,revealFile}from"./reveal.js";
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{listsFile as c}from"@allyhub/formats";const l=(d,t)=>d===""||d.endsWith("/")?t.startsWith(d):d===t;export class Inputs{recorded=new Map;set(t,s,o){let e=this.recorded.get(t);e||(e=new Map,this.recorded.set(t,e)),e.set(s,new Set(o))}add(t,s,o){const e=this.recorded.get(t)?.get(s);e?e.add(o):this.set(t,s,[o])}of(t){const s=new Set;for(const o of this.recorded.get(t)?.values()??[])for(const e of o)s.add(e);return s}affected(t,s){const o=new Map;for(const e of t){const f=[...this.of(e.id)],n=s.filter(r=>r===e.entry||e.files!==void 0&&c(e.files,r)||f.some(i=>l(i,r)));n.length>0&&o.set(e.id,n)}return o}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{rm as f}from"node:fs/promises";import{join as u}from"node:path";import{startBrowser as m}from"@allyhub/browser";import{kindBuildOf as w,mediaHref as v,nodeLending as b,projectItems as g,sourceOf as k,stageItem as S}from"@allyhub/build";import{CACHE_DIR as y}from"@allyhub/formats";import{CheckSession as D,ProjectError as R,pickTarget as E,parseCombo as O}from"@allyhub/project";import{RPC_ERROR as h,RpcError as c,SNAPSHOT_TREE as l}from"@allyhub/protocol";import{prepareStage as $,viewStage as C}from"@allyhub/stage";import{Routes as P}from"./routes.js";export function rpcErrorOf(o){return o instanceof R?new c(o.kind==="not-found"?h.notFound:h.invalid,o.hint?`${o.message} ${o.hint}`:o.message):o}export class Live{root;buildDir;revision=0;prep;last;lease;old=new Set;browserStarted;gpu;building=Promise.resolve();closed=!1;codes=new Map;kinds;routes;constructor(e,i){this.root=e,this.kinds=i.kinds,this.buildDir=u(e,y,"build",`dev-${String(process.pid)}`),this.gpu=i.gpu,this.routes=new P({root:e,kinds:i.kinds,buildDir:this.buildDir,revision:()=>this.revision,prepared:()=>this.prepared(),latest:()=>this.latest(),view:(t,s)=>C(e,t,s,i.kinds)})}moved(e){this.revision=e,this.lease&&this.lease.revision!==e&&this.retire(this.lease)}prepared(){const e=this.revision;if(this.prep?.revision===e)return this.prep.promise;const i=this.building.then(()=>e===this.revision?this.build():void 0);this.building=i.catch(()=>{});const t=i.then(s=>s??this.prepared());return this.prep={revision:e,promise:t},t.catch(()=>{this.prep?.promise===t&&(this.prep=void 0)}),t}async build(){const e=await $(this.root,this.pieceDir,this.kinds);return this.last=e,e}async itemCode(e){const i=await this.item(e),t=i?await w(this.kinds.find(r=>r.id===i.kind))?.catch(()=>{}):void 0,s=t?.code?.bind(t);if(!i||!s)return{failed:!1};const n=this.codes.get(e),d=n?.revision===this.revision?n.promise:b(this.kinds,this.root).then(r=>s(i,{root:this.root,lend:r})).catch(()=>{});return this.codes.set(e,{revision:this.revision,promise:d}),await d??{failed:!0}}async item(e){const{items:i}=await g(this.root,this.kinds);return i.find(t=>t.id===e)}get pieceDir(){return u(this.buildDir,"stage")}latest(){return this.last}async target(e,i){const t=await this.prepared();try{const{piece:s,target:n}=E(t,e,i===void 0?void 0:[O(i)]);return{prepared:t,piece:s,combo:n.combo}}catch(s){throw rpcErrorOf(s)}}async componentHost(e,i){const t=await this.prepared(),s=t.docs.find(r=>r.place===e||r.file===e);if(s){if(s.components.length===0)throw new c(h.notFound,`${s.place} shows no component.`);const r=t.messages.locales[0];return{prepared:t,host:s,combo:r===void 0?{}:{lang:r}}}const{piece:n,combo:d}=await this.target(e,i);return{prepared:t,host:n,combo:d}}async source(e){const i=await this.prepared(),t=S(i,e);if(!t)throw new c(h.notFound,`No piece ${e}.`);const s=k(i,t),n={...s.media},d=(r,a)=>`${r}${v(a).slice(l.media.length)}`;return await Promise.all(Object.entries(n).map(async([r,a])=>{let p=a;a.kind==="video"&&a.matte===!0&&(p={...p,matteUrl:d(l.matte,r)}),n[r]=await this.routes.mediaOf(r,p)})),{...s,media:n}}browser(){return this.browserStarted??=m(this.gpu===void 0?{}:{gpu:this.gpu}),this.browserStarted}async withSession(e){this.refuseStopped();let i=this.lease;if(i?.revision!==this.revision){i&&this.retire(i);const t=await this.browser();if(this.refuseStopped(),i=this.lease,i?.revision!==this.revision){i&&this.retire(i);const s={revision:this.revision,session:this.prepared().then(n=>D.open({root:this.root,kinds:this.kinds,browser:t,prepared:n})),users:0,retired:!1};i=s,this.lease=s,s.session.catch(()=>{this.lease===s&&(this.lease=void 0)})}}i.users++;try{return await e(await i.session)}finally{i.users--,i.retired&&i.users===0&&this.end(i)}}refuseStopped(){if(this.closed)throw new c(h.unavailable,"allyhub dev is stopping.")}retire(e){e.retired=!0,this.lease===e&&(this.lease=void 0),this.old.add(e),e.users===0&&this.end(e)}end(e){return e.ended??=(async()=>{this.old.delete(e),await e.session.then(i=>i.close()).catch(()=>{})})(),e.ended}async close(){this.closed=!0;const e=[...this.old,...this.lease?[this.lease]:[]];this.lease&&this.retire(this.lease),await Promise.all(e.map(i=>this.end(i))),await this.browserStarted?.then(i=>i.close()).catch(()=>{}),await f(this.buildDir,{recursive:!0,force:!0})}}
2
+ import{rm as f}from"node:fs/promises";import{join as u}from"node:path";import{startBrowser as m}from"@allyhub/browser";import{kindBuildOf as w,mediaHref as v,nodeLending as b,projectItems as g,sourceOf as k,stageItem as S}from"@allyhub/build";import{CACHE_DIR as y}from"@allyhub/formats";import{CheckSession as D,ProjectError as R,pickTarget as E,parseCombo as O}from"@allyhub/project";import{RPC_ERROR as h,RpcError as c,SNAPSHOT_TREE as l}from"@allyhub/protocol";import{prepareStage as $,viewStage as C}from"@allyhub/stage";import{Routes as P}from"./routes.js";export function rpcErrorOf(o){return o instanceof R?new c(o.kind==="not-found"?h.notFound:h.invalid,o.hint?`${o.message} ${o.hint}`:o.message):o}export class Live{root;buildDir;revision=0;prep;last;lease;old=new Set;browserStarted;gpu;building=Promise.resolve();closed=!1;codes=new Map;kinds;routes;constructor(e,i){this.root=e,this.kinds=i.kinds,this.buildDir=u(e,y,"build",`dev-${String(process.pid)}`),this.gpu=i.gpu,this.routes=new P({root:e,kinds:i.kinds,buildDir:this.buildDir,revision:()=>this.revision,prepared:()=>this.prepared(),latest:()=>this.latest(),view:(t,s)=>C(e,t,s,i.kinds),recordInputs:(t,s,n)=>{i.recordInputs?.(t,s,n)}})}moved(e){this.revision=e,this.lease&&this.lease.revision!==e&&this.retire(this.lease)}prepared(){const e=this.revision;if(this.prep?.revision===e)return this.prep.promise;const i=this.building.then(()=>e===this.revision?this.build():void 0);this.building=i.catch(()=>{});const t=i.then(s=>s??this.prepared());return this.prep={revision:e,promise:t},t.catch(()=>{this.prep?.promise===t&&(this.prep=void 0)}),t}async build(){const e=await $(this.root,this.pieceDir,this.kinds);return this.last=e,e}async itemCode(e){const i=await this.item(e),t=i?await w(this.kinds.find(r=>r.id===i.kind))?.catch(()=>{}):void 0,s=t?.code?.bind(t);if(!i||!s)return{failed:!1};const n=this.codes.get(e),d=n?.revision===this.revision?n.promise:b(this.kinds,this.root).then(r=>s(i,{root:this.root,lend:r})).catch(()=>{});return this.codes.set(e,{revision:this.revision,promise:d}),await d??{failed:!0}}async item(e){const{items:i}=await g(this.root,this.kinds);return i.find(t=>t.id===e)}get pieceDir(){return u(this.buildDir,"stage")}latest(){return this.last}async target(e,i){const t=await this.prepared();try{const{piece:s,target:n}=E(t,e,i===void 0?void 0:[O(i)]);return{prepared:t,piece:s,combo:n.combo}}catch(s){throw rpcErrorOf(s)}}async componentHost(e,i){const t=await this.prepared(),s=t.docs.find(r=>r.place===e||r.file===e);if(s){if(s.components.length===0)throw new c(h.notFound,`${s.place} shows no component.`);const r=t.messages.locales[0];return{prepared:t,host:s,combo:r===void 0?{}:{lang:r}}}const{piece:n,combo:d}=await this.target(e,i);return{prepared:t,host:n,combo:d}}async source(e){const i=await this.prepared(),t=S(i,e);if(!t)throw new c(h.notFound,`No piece ${e}.`);const s=k(i,t),n={...s.media},d=(r,a)=>`${r}${v(a).slice(l.media.length)}`;return await Promise.all(Object.entries(n).map(async([r,a])=>{let p=a;a.kind==="video"&&a.matte===!0&&(p={...p,matteUrl:d(l.matte,r)}),n[r]=await this.routes.mediaOf(r,p)})),{...s,media:n}}browser(){return this.browserStarted??=m(this.gpu===void 0?{}:{gpu:this.gpu}),this.browserStarted}async withSession(e){this.refuseStopped();let i=this.lease;if(i?.revision!==this.revision){i&&this.retire(i);const t=await this.browser();if(this.refuseStopped(),i=this.lease,i?.revision!==this.revision){i&&this.retire(i);const s={revision:this.revision,session:this.prepared().then(n=>D.open({root:this.root,kinds:this.kinds,browser:t,prepared:n})),users:0,retired:!1};i=s,this.lease=s,s.session.catch(()=>{this.lease===s&&(this.lease=void 0)})}}i.users++;try{return await e(await i.session)}finally{i.users--,i.retired&&i.users===0&&this.end(i)}}refuseStopped(){if(this.closed)throw new c(h.unavailable,"allyhub dev is stopping.")}retire(e){e.retired=!0,this.lease===e&&(this.lease=void 0),this.old.add(e),e.users===0&&this.end(e)}end(e){return e.ended??=(async()=>{this.old.delete(e),await e.session.then(i=>i.close()).catch(()=>{})})(),e.ended}async close(){this.closed=!0;const e=[...this.old,...this.lease?[this.lease]:[]];this.lease&&this.retire(this.lease),await Promise.all(e.map(i=>this.end(i))),await this.browserStarted?.then(i=>i.close()).catch(()=>{}),await f(this.buildDir,{recursive:!0,force:!0})}}
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{once as y}from"node:events";import{createServer as S}from"node:http";import{posix as v}from"node:path";import{getRequestListener as R}from"@hono/node-server";import{pathProblem as $}from"./paths.js";import{forwarded as x}from"./ports.js";import{fileResponse as P}from"./respond.js";import{inside as U}from"./tree.js";export const PAGE_POLICY=["default-src 'self' data: blob:","script-src 'self' 'unsafe-inline' 'unsafe-eval' blob:","style-src 'self' 'unsafe-inline'","img-src 'self' data: blob:","font-src 'self' data:","connect-src 'self' data: blob:","media-src 'self' data: blob:"].join("; "),PAGE_SOURCE="page";export class Pages{o;origins=new Map;constructor(n){this.o=n}async url(n,s,o){const r=await this.origin(s);r.pages.set(o,n);const d=r.port.url.endsWith("/")?r.port.url:`${r.port.url}/`,f=s===""?o:o.slice(s.length+1);return`${d}${f.split("/").map(encodeURIComponent).join("/")}`}origin(n){let s=this.origins.get(n);return s||(s=this.start(n),this.origins.set(n,s),s.catch(()=>{this.origins.get(n)===s&&this.origins.delete(n)})),s}async start(n){const{root:s,inputs:o}=this.o,r=new Map,d=new Map;let f=new Set;const m=i=>{let e;try{e=decodeURIComponent(i).replace(/^\/+/u,"")}catch{return}(e===""||e.endsWith("/"))&&(e=`${e}index.html`);const t=n===""?e:`${n}/${e}`;if($(t)===void 0&&!t.split("/").some(c=>c.startsWith(".")))return v.normalize(t)},w=(i,e)=>{const t=r.get(i);if(t!==void 0){o.set(t,PAGE_SOURCE,[i]);for(const a of d.values())a.delete(t);return new Set([t])}let c;try{const a=e===void 0?void 0:new URL(e);a&&f.has(a.host)&&(c=m(a.pathname))}catch{c=void 0}if(c!==void 0){const a=r.get(c);if(a!==void 0)return new Set([a]);const u=d.get(c);if(u)return new Set(u)}return new Set(r.values())},b=R(async i=>{const e=new URL(i.url),t=m(e.pathname);if(t===void 0)return new Response("not found",{status:404});const c=w(t,i.headers.get("referer")??void 0),a=d.get(t)??new Set;for(const g of c)a.add(g),o.add(g,PAGE_SOURCE,t);d.set(t,a);const u=U(s,t);return u?P(u,i.headers.get("range")??void 0,{"content-security-policy":PAGE_POLICY,"cache-control":"no-store","x-content-type-options":"nosniff"}):new Response("not found",{status:404})}),l=S((i,e)=>{if(!f.has(i.headers.host??"")){e.writeHead(403,{"content-type":"text/plain; charset=utf-8"}),e.end("forbidden host");return}b(i,e)});l.listen(0,"127.0.0.1"),await y(l,"listening");const p=l.address().port,h=x(this.o.ports,p);return f=new Set([`127.0.0.1:${String(p)}`,`localhost:${String(p)}`,...h.hosts,new URL(h.url).host]),{server:l,port:h,pages:r,loads:d}}async close(){const n=[...this.origins.values()];this.origins.clear();for(const s of n){const o=await s.catch(()=>{});o&&(o.port.dispose(),o.server.closeAllConnections(),await new Promise(r=>o.server.close(r)))}}}
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ export function forwarded(e,d){const n=`http://127.0.0.1:${String(d)}/`;return e===void 0?{url:n,hosts:[],dispose:()=>{}}:(e.add(d),{url:e.public(n),hosts:e.hosts(d),dispose:()=>{e.remove(d)}})}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{itemNameOf as m,listsFile as v}from"@allyhub/formats";import{randomBytes as g}from"node:crypto";import{isAbsolute as u,relative as x,resolve as y,sep as O}from"node:path";import{AGENT_NAME as b,FILE_METHODS as T,HOST_METHODS as w,JSONRPC as c,PRESENCE_METHODS as S,PROJECT_TOOLS as h,RPC_ERROR as d,RequestSchema as E,RpcError as l,answer as f}from"@allyhub/protocol";import{Checker as j,Indexer as k}from"./background.js";import{Exports as P}from"./exports.js";import{hasFileManager as N,revealFile as R}from"./reveal.js";import{Live as M}from"./live.js";import{fileIn as p}from"./paths.js";import{kindContext as C}from"./kinds.js";import{Presence as J}from"./presence.js";import{Texts as _}from"./texts.js";import{contributedTool as H,contributedTools as F,projectToolContext as q,toolHandlers as A}from"./tools.js";import{Watcher as D}from"./watcher.js";import{Writer as I}from"./writer.js";export const SERVER_METHODS={...T,"tools/call":w["tools/call"],...S};const L=5e3;export class ProjectServer{root;writer;watcher;live;exports;presence;texts;placing=Promise.resolve();listed;extensions;reveal;checker;serving;indexer;clients=new Map;contributed;services;held=new Map;unhearJobs;constructor(e){this.root=y(e.root),this.services={...e.jobs===void 0?{}:{jobs:e.jobs},...e.cloud===void 0?{}:{cloud:e.cloud},...e.env===void 0?{}:{env:e.env},...e.ports===void 0?{}:{ports:e.ports}},this.unhearJobs=e.jobs?.on(t=>{if(!u(t.about.id))return;const r=x(this.root,t.about.id);r===""||r.startsWith("..")||u(r)||this.notify("jobs/changed",{job:t,item:r.split(O).join("/")})})??(()=>{}),this.contributed=F(e.kinds),this.extensions=e.extensions,this.live=new M(this.root,{kinds:e.kinds,...e.gpu===void 0?{}:{gpu:e.gpu}}),this.presence=new J(t=>{this.notify("presence/changed",{collaborators:t})}),this.texts=new _(this.root),this.watcher=new D(this.root,(t,r)=>{this.sendTo(this.watchOwner(t),"files/changed",{watch:t,changes:r})},t=>{this.live.moved(t),this.notify("project/changed",{revision:t}),this.checker?.schedule()},{by:{kind:"agent",name:b},moved:t=>{this.placing=this.placing.then(()=>this.wroteOutside(t))}}),this.writer=new I(this.root,e.kinds,(t,r)=>{for(const n of t)this.texts.set(n.path,n.text);this.watcher.wrote(t.map(({path:n,version:s})=>({path:n,version:s})),r)},e.writable),this.reveal=e.reveal===!1?void 0:e.reveal??(N()?R:void 0),this.exports=new P(this.root,e.kinds,t=>{this.notify("export/changed",{job:t})},e.jobs===void 0?void 0:{jobs:e.jobs,nameOf:async t=>{const{items:r}=await this.tool("project/items",{}),n=r.find(s=>s.id===t);return m(n??{id:t})}},{...e.extensions?{processors:e.extensions.exportProcessors(),analyses:e.extensions.mediaAnalyses()}:{}});const i=e.index??process.env.ALLYHUB_NO_INDEX!=="1";if(e.check!==!1){const t=i?new k({root:this.root,analyses:e.extensions?.mediaAnalyses()??[],env:e.env??process.env,emit:n=>{this.notify("index/changed",{jobs:n})},made:()=>{this.checker?.schedule(!0)}}):void 0;this.indexer=t;const r=e.extensions?.fileEditors();this.checker=new j({live:this.live,...r===void 0?{}:{files:r},emit:n=>{this.notify("check/changed",n)},...t?{needs:n=>{t.want(n)}}:{},...e.settle===void 0?{}:{settle:e.settle}})}}static open(e){const i=new ProjectServer(e);return i.watcher.start(),i.checker?.schedule(),i.texts.warm(),Promise.resolve(i)}async settled(){await this.watcher.settled(),await this.placing}async wroteOutside(e){let i;for(const r of e){const{changed:n,lines:s}=await this.texts.changed(r).catch(()=>({changed:!1,lines:void 0}));n&&(i={path:r,...s})}if(i===void 0)return;const t=await this.itemOf(i.path);this.presence.agent({doing:"editing",...t===void 0?{}:{item:t},source:i})}async itemOf(e){const i=Date.now();this.listed!==void 0&&i-this.listed.at<L||(this.listed={at:i,items:this.tool("project/items",{}).then(s=>s.items,()=>[])});const r=await this.listed?.items??[],n=r.filter(s=>s.dir!==""&&e.startsWith(`${s.dir}/`)).sort((s,o)=>o.dir.length-s.dir.length);return(r.find(s=>s.entry===e)??r.find(s=>s.files!==void 0&&v(s.files,e))??n[0])?.id}owners=new Map;watchOwner(e){return this.owners.get(e)}connect(e,i={}){const t=`c${g(6).toString("hex")}`;this.clients.set(t,e);const r=this.handlersFor(t,i.origin);return{id:t,receive:async n=>{const s=await this.answerOne(r,n);s&&e(s)},close:()=>{this.clients.delete(t),this.watcher.forget(t);for(const[n,s]of this.owners)s===t&&this.owners.delete(n)}}}channel(){const e=new Set,i=this.connect(t=>{const r=JSON.parse(JSON.stringify(t));queueMicrotask(()=>{for(const n of e)n(r)})});return{send:t=>{i.receive(JSON.parse(JSON.stringify(t)))},listen:t=>(e.add(t),()=>e.delete(t)),close:()=>{i.close()}}}notify(e,i){for(const t of this.clients.values())t({jsonrpc:c,method:e,params:i})}sendTo(e,i,t){e!==void 0&&this.clients.get(e)?.({jsonrpc:c,method:i,params:t})}async answerOne(e,i){const t=E.safeParse(i);if(!t.success){const n=i?.id;return typeof n!="string"&&typeof n!="number"?void 0:{jsonrpc:c,id:n,error:{code:d.invalidRequest,message:"Not a JSON-RPC request."}}}const r=t.data;return Object.hasOwn(w,r.method)&&r.method!=="tools/call"?{jsonrpc:c,id:r.id,error:{code:d.methodNotFound,message:`${r.method} is answered by the page that hosts the editor, not by allyhub dev's server.`}}:f(SERVER_METHODS,e,r)}handlersFor(e,i){const{writer:t,watcher:r}=this,n=this.toolSet(()=>this.serving?.tree(i));return{"files/read":({path:s})=>t.read(s),"files/write":async({path:s,text:o,over:a})=>({version:await t.write(s,o,a,e)}),"files/upload":async({dir:s,name:o,data:a})=>({path:await t.upload(s,o,Buffer.from(a,"base64"),e)}),"files/url":async({path:s})=>{if(await p(this.root,s),!this.serving)throw new l(d.unavailable,"This server serves no files over HTTP: only allyhub dev's does.");return{url:this.serving.file(i,s)}},"files/list":({dir:s})=>t.list(s),"files/move":async({from:s,to:o})=>({rewritten:await t.move(s,o,e)}),"files/remove":async({path:s})=>({trash:await t.remove(s,e)}),"files/trash":async()=>({entries:await t.trash()}),"files/restore":async({id:s})=>({path:await t.restore(s,e)}),"files/watch":async({paths:s})=>{for(const a of s)await p(this.root,a);const o=await r.watch(e,s);return this.owners.set(o,e),{watch:o}},"files/unwatch":({watch:s})=>(this.owners.get(s)===e&&(r.unwatch(s),this.owners.delete(s)),Promise.resolve({})),"tools/call":async({name:s,arguments:o})=>({result:await this.runTool(n,s,o)}),"presence/get":()=>Promise.resolve({collaborators:this.presence.list()})}}toolSet(e){const i=this.toolContext(e);return{core:A(i),context:q(i)}}async runTool(e,i,t){const r={jsonrpc:c,id:0,method:i,params:t},n=Object.hasOwn(h,i)?void 0:this.contributed.get(i);let s;if(n===void 0)s=await f(h,e.core,r);else{const o=await H(n).catch(a=>{throw new l(d.internal,a instanceof Error?a.message:String(a))});s=await f({[i]:o},{[i]:a=>o.run(a,e.context)},r)}if("error"in s)throw new l(s.error.code,s.error.message,s.error.data);return s.result}hasTool(e){return Object.hasOwn(h,e)||this.contributed.has(e)}toolContext(e){return{live:this.live,checker:this.checker,exports:this.exports,reveal:this.reveal,tree:e,extensions:this.extensions,services:this.services,held:this.held,kindContext:C(this.root,i=>this.hasTool(i),(i,t)=>this.tool(i,t))}}async tool(e,i,t={}){const r=await this.runTool(this.toolSet(()=>t.tree??this.serving?.tree(void 0)),e,i);return Object.hasOwn(h,e)?h[e].result.parse(r):r}async close(){this.unhearJobs(),this.presence.close(),this.watcher.close(),this.clients.clear();for(const e of[...this.held.values()].reverse())await Promise.resolve(e.dispose()).catch(()=>{});this.held.clear(),await this.checker?.close(),await this.indexer?.close(),await this.exports.close(),await this.live.close()}}
2
+ import{itemNameOf as v,listsFile as g}from"@allyhub/formats";import{randomBytes as y}from"node:crypto";import{isAbsolute as u,relative as x,resolve as O,sep as b}from"node:path";import{AGENT_NAME as T,FILE_METHODS as S,HOST_METHODS as p,JSONRPC as h,PRESENCE_METHODS as k,PROJECT_TOOLS as c,RPC_ERROR as l,RequestSchema as E,RpcError as d,answer as f}from"@allyhub/protocol";import{Checker as j,Indexer as P}from"./background.js";import{Exports as N}from"./exports.js";import{downloadsFolder as I,hasFileManager as R,revealFile as M}from"./reveal.js";import{Live as C}from"./live.js";import{Inputs as J}from"./inputs.js";import{Pages as _}from"./pages.js";import{fileIn as w}from"./paths.js";import{kindContext as F}from"./kinds.js";import{Presence as H}from"./presence.js";import{Texts as q}from"./texts.js";import{contributedTool as A,contributedTools as D,projectToolContext as L,toolHandlers as W}from"./tools.js";import{Watcher as B}from"./watcher.js";import{Writer as $}from"./writer.js";export const SERVER_METHODS={...S,"tools/call":p["tools/call"],...k};const G=5e3;export class ProjectServer{root;writer;watcher;live;exports;presence;inputs=new J;pages;texts;placing=Promise.resolve();telling=Promise.resolve();listed;extensions;reveal;checker;serving;indexer;clients=new Map;contributed;services;held=new Map;unhearJobs;constructor(e){this.root=O(e.root),this.services={...e.jobs===void 0?{}:{jobs:e.jobs},...e.cloud===void 0?{}:{cloud:e.cloud},...e.env===void 0?{}:{env:e.env},...e.ports===void 0?{}:{ports:e.ports}},this.unhearJobs=e.jobs?.on(t=>{if(!u(t.about.id))return;const s=x(this.root,t.about.id);s===""||s.startsWith("..")||u(s)||this.notify("jobs/changed",{job:t,item:s.split(b).join("/")})})??(()=>{}),this.contributed=D(e.kinds),this.extensions=e.extensions,this.live=new C(this.root,{kinds:e.kinds,...e.gpu===void 0?{}:{gpu:e.gpu},recordInputs:(t,s,n)=>{const r=[...n];this.listedItems().then(o=>{const a=o.find(m=>m.entry===t);a&&this.inputs.set(a.id,s,r)})}}),this.pages=new _({root:this.root,ports:e.ports,inputs:this.inputs}),this.presence=new H(t=>{this.notify("presence/changed",{collaborators:t})}),this.texts=new q(this.root),this.watcher=new B(this.root,(t,s)=>{this.sendTo(this.watchOwner(t),"files/changed",{watch:t,changes:s})},(t,s)=>{this.live.moved(t),this.notify("project/changed",{revision:t}),this.checker?.schedule(),this.telling=this.telling.then(()=>this.tellItems(s))},{by:{kind:"agent",name:T},moved:t=>{this.placing=this.placing.then(()=>this.wroteOutside(t))}}),this.writer=new $(this.root,e.kinds,(t,s)=>{for(const n of t)this.texts.set(n.path,n.text);this.watcher.wrote(t.map(({path:n,version:r})=>({path:n,version:r})),s)},e.writable),this.reveal=e.reveal===!1?void 0:e.reveal??(R()?M:void 0),this.exports=new N(this.root,e.kinds,t=>{this.notify("export/changed",{job:t})},e.jobs===void 0?void 0:{jobs:e.jobs,nameOf:async t=>{const{items:s}=await this.tool("project/items",{}),n=s.find(r=>r.id===t);return v(n??{id:t})}},{...e.extensions?{processors:e.extensions.exportProcessors(),analyses:e.extensions.mediaAnalyses()}:{},...this.reveal===void 0||e.exportsTo===!1?{}:{saveTo:e.exportsTo??I}});const i=e.index??process.env.ALLYHUB_NO_INDEX!=="1";if(e.check!==!1){const t=i?new P({root:this.root,analyses:e.extensions?.mediaAnalyses()??[],env:e.env??process.env,emit:n=>{this.notify("index/changed",{jobs:n})},made:()=>{this.checker?.schedule(!0)}}):void 0;this.indexer=t;const s=e.extensions?.fileEditors();this.checker=new j({live:this.live,...s===void 0?{}:{files:s},emit:n=>{this.notify("check/changed",n)},...t?{needs:n=>{t.want(n)}}:{},...e.settle===void 0?{}:{settle:e.settle}})}}static open(e){const i=new ProjectServer(e);return i.watcher.start(),i.checker?.schedule(),i.texts.warm(),Promise.resolve(i)}async settled(){await this.watcher.settled(),await this.placing,await this.telling}async tellItems(e){if(e.length===0)return;const i=await this.listedItems();for(const[t,s]of this.inputs.affected(i,e))this.notify("items/changed",{item:t,paths:s})}async wroteOutside(e){let i;for(const s of e){const{changed:n,lines:r}=await this.texts.changed(s).catch(()=>({changed:!1,lines:void 0}));n&&(i={path:s,...r})}if(i===void 0)return;const t=await this.itemOf(i.path);this.presence.agent({doing:"editing",...t===void 0?{}:{item:t},source:i})}async itemOf(e){const i=await this.listedItems(),t=i.filter(s=>s.dir!==""&&e.startsWith(`${s.dir}/`)).sort((s,n)=>n.dir.length-s.dir.length);return(i.find(s=>s.entry===e)??i.find(s=>s.files!==void 0&&g(s.files,e))??t[0])?.id}async listedItems(){const e=Date.now();return this.listed!==void 0&&e-this.listed.at<G||(this.listed={at:e,items:this.tool("project/items",{}).then(t=>t.items,()=>[])}),await this.listed?.items??[]}owners=new Map;watchOwner(e){return this.owners.get(e)}connect(e,i={}){const t=`c${y(6).toString("hex")}`;this.clients.set(t,e);const s=this.handlersFor(t,i.origin);return{id:t,receive:async n=>{const r=await this.answerOne(s,n);r&&e(r)},close:()=>{this.clients.delete(t),this.watcher.forget(t);for(const[n,r]of this.owners)r===t&&this.owners.delete(n)}}}channel(){const e=new Set,i=this.connect(t=>{const s=JSON.parse(JSON.stringify(t));queueMicrotask(()=>{for(const n of e)n(s)})});return{send:t=>{i.receive(JSON.parse(JSON.stringify(t)))},listen:t=>(e.add(t),()=>e.delete(t)),close:()=>{i.close()}}}notify(e,i){for(const t of this.clients.values())t({jsonrpc:h,method:e,params:i})}sendTo(e,i,t){e!==void 0&&this.clients.get(e)?.({jsonrpc:h,method:i,params:t})}async answerOne(e,i){const t=E.safeParse(i);if(!t.success){const n=i?.id;return typeof n!="string"&&typeof n!="number"?void 0:{jsonrpc:h,id:n,error:{code:l.invalidRequest,message:"Not a JSON-RPC request."}}}const s=t.data;return Object.hasOwn(p,s.method)&&s.method!=="tools/call"?{jsonrpc:h,id:s.id,error:{code:l.methodNotFound,message:`${s.method} is answered by the page that hosts the editor, not by allyhub dev's server.`}}:f(SERVER_METHODS,e,s)}handlersFor(e,i){const{writer:t,watcher:s}=this,n=this.toolSet(()=>this.serving?.tree(i));return{"files/read":({path:r})=>t.read(r),"files/write":async({path:r,text:o,over:a})=>({version:await t.write(r,o,a,e)}),"files/upload":async({dir:r,name:o,data:a})=>({path:await t.upload(r,o,Buffer.from(a,"base64"),e)}),"files/url":async({path:r})=>{if(await w(this.root,r),!this.serving)throw new d(l.unavailable,"This server serves no files over HTTP: only allyhub dev's does.");return{url:this.serving.file(i,r)}},"files/list":({dir:r})=>t.list(r),"files/move":async({from:r,to:o})=>({rewritten:await t.move(r,o,e)}),"files/remove":async({path:r})=>({trash:await t.remove(r,e)}),"files/trash":async()=>({entries:await t.trash()}),"files/restore":async({id:r})=>({path:await t.restore(r,e)}),"files/watch":async({paths:r})=>{for(const a of r)await w(this.root,a);const o=await s.watch(e,r);return this.owners.set(o,e),{watch:o}},"files/unwatch":({watch:r})=>(this.owners.get(r)===e&&(s.unwatch(r),this.owners.delete(r)),Promise.resolve({})),"tools/call":async({name:r,arguments:o})=>({result:await this.runTool(n,r,o)}),"presence/get":()=>Promise.resolve({collaborators:this.presence.list()})}}toolSet(e){const i=this.toolContext(e);return{core:W(i),context:L(i)}}async runTool(e,i,t){const s={jsonrpc:h,id:0,method:i,params:t},n=Object.hasOwn(c,i)?void 0:this.contributed.get(i);let r;if(n===void 0)r=await f(c,e.core,s);else{const o=await A(n).catch(a=>{throw new d(l.internal,a instanceof Error?a.message:String(a))});r=await f({[i]:o},{[i]:a=>o.run(a,e.context)},s)}if("error"in r)throw new d(r.error.code,r.error.message,r.error.data);return r.result}hasTool(e){return Object.hasOwn(c,e)||this.contributed.has(e)}toolContext(e){return{live:this.live,checker:this.checker,exports:this.exports,reveal:this.reveal,tree:e,extensions:this.extensions,services:this.services,held:this.held,kindContext:F(this.root,i=>this.hasTool(i),(i,t)=>this.tool(i,t)),inputs:this.inputs,pages:this.pages}}async tool(e,i,t={}){const s=await this.runTool(this.toolSet(()=>t.tree??this.serving?.tree(void 0)),e,i);return Object.hasOwn(c,e)?c[e].result.parse(s):s}async close(){this.unhearJobs(),this.presence.close(),this.watcher.close(),this.clients.clear();for(const e of[...this.held.values()].reverse())await Promise.resolve(e.dispose()).catch(()=>{});this.held.clear(),await this.pages.close(),await this.checker?.close(),await this.indexer?.close(),await this.exports.close(),await this.live.close()}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{readdir as U,realpath as Y,stat as Z}from"node:fs/promises";import{join as g,relative as ee,sep as te}from"node:path";import{KeyedStore as oe}from"@allyhub/project";import{NEVER_CANCELLED as se}from"@allyhub/extension-api";import{COMPONENT_STILLS_MAX as J,KindSnapshotSchema as ne,RpcError as K,SNAPSHOT_TREE as m,pieceSourcePath as ie,snapshotAnswerPath as x,snapshotPreviewPath as re,stillPath as z,stillsIndexKey as ce,stillsIndexPath as ae}from"@allyhub/protocol";import{runtimeFiles as fe}from"@allyhub/stage-page";import{itemPreview as de}from"./card.js";import{kindContext as le,kindItem as pe}from"./kinds.js";import{mediaTypeOf as H}from"@allyhub/formats";import{Reach as ue,pieceBundle as me,pieceNames as he,reachedCheck as we,reachedSource as ye}from"./reach.js";import{matteFile as $e}from"./tree.js";const T="https://tree.invalid/";function M(n){return typeof n=="string"?n.startsWith(T)?n.slice(T.length):n:Array.isArray(n)?n.map(M):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([w,c])=>[w,M(c)])):n}const j=n=>new TextEncoder().encode(JSON.stringify(n));async function V(n){return(await U(n,{recursive:!0,withFileTypes:!0}).catch(()=>[])).filter(c=>c.isFile()).map(c=>ee(n,g(c.parentPath,c.name)).split(te).join("/"))}const ge=n=>Z(n).then(w=>w.isFile(),()=>!1);export async function recordTree(n,w={}){const{project:c}=n,{live:u,root:y}=c;await c.watcher.settled();const P=new Map,h=(e,t,o=H(e))=>{P.set(e,{path:e,type:o,file:t})},b=(e,t,o=H(e))=>{P.set(e,{path:e,type:o,bytes:t})},N=async(e,t)=>{for(const o of await V(t))h(`${e}${o}`,g(t,o))},W=u.revision,a=await u.prepared(),v=new Map;if(n.ui!==void 0)for(const e of await V(n.ui))h(`${m.editor}${e}`,g(n.ui,e));for(const[e,t]of await fe())h(`${m.runtime}${e}`,t);const A=async(e,t)=>{let o;try{o={result:M(await c.tool(e,t,{tree:T}))}}catch(s){o={error:s instanceof K?{code:s.code,message:s.message}:{code:-32603,message:s instanceof Error?s.message:""}}}const r=x(e,t);b(r,j(o));const d=t.item;return typeof d=="string"&&v.set(d,[...v.get(d)??[],r]),o},X=le(y,e=>c.hasTool(e),async(e,t)=>{const o=await A(e,t);if(o.error)throw new K(o.error.code,o.error.message);return o.result}),q=async(e,t,o)=>{const r=new Map;for(const p of o)r.set(ce(p),p);if(r.size===0)return;const d=oe.of(y,"stills"),s={stills:{}},l=f.of(e),i=[...r];for(let p=0;p<i.length;p+=J){const O=i.slice(p,p+J);(await c.tool("components/stills",{item:e,...t===""?{}:{version:t},components:O.map(([,$])=>$)},{tree:T}).catch(()=>{}))?.stills.forEach(($,Q)=>{const B=O[Q]?.[0];!$||B===void 0||(s.stills[B]=$.key,h(z($.key),d.path(`${$.key}.webp`),"image/webp"),l?.tree.add(z($.key)))})}const S=ae(e,t);b(S,j(s),"application/json"),l?.tree.add(S)},I=(await A("project/items",{})).result,E=(I?.items??[]).filter(e=>e.kind!==void 0),G=new Map(a.items.map(e=>[e.id,e.files])),f=new ue(E.map(e=>({...e,files:G.get(e.id)??e.files})),a.files,(a.bundle?.beside??[]).map(e=>`${m.build}${e}`)),k=c.checker?.state,R=k===void 0||k.status==="waiting"||k.status==="running"?{status:"off",revision:u.revision,problems:k?.problems??[],facts:k?.facts??[]}:k;b(x("check/results",{}),j({result:R}));for(const e of f.items){const t=f.of(e),o=new Set(a.pieces.filter(s=>s.place===e).map(s=>s.id)),r=E.find(s=>s.id===e)?.entry,d=s=>s===r||f.itemsOf(s).includes(e);t?.own.push({path:x("project/items",{}),type:"application/json",bytes:j({result:{...I,items:E.filter(s=>s.id===e)}})},{path:x("check/results",{}),type:"application/json",bytes:j({result:we(R,o,d)})})}for(const e of a.bundle?.chunks.files??[])h(`${m.build}${e}`,g(u.pieceDir,e));for(const e of a.bundle?.beside??[])await N(`${m.build}${e}`,g(u.pieceDir,e));const C=new Set(Object.keys(a.media));for(const e of Object.keys(a.media)){const t=$e(y,a.media[e]);t!==void 0&&await ge(t)&&h(`${m.matte}${e}`,t,"video/mp4")}const F=new Map,_=e=>({file:(t,o,r)=>{h(`${e}${t}`,o,r)},folder:(t,o)=>N(`${e}${t}`,o),bytes:(t,o,r)=>{b(`${e}${t}`,o,r)},media:t=>{C.add(t)}});for(const e of E){const t=await c.extensions?.kindProvider(e.kind);if(!t?.snapshot)continue;const o=await Promise.resolve(t.snapshot(pe(e),X,se)).catch(()=>{}),r=ne.safeParse(o??{});if(!r.success)continue;const{stills:d,shows:s,routes:l}=r.data;s&&F.set(e.id,{media:new Set(s.media),data:new Set(s.data)});for(const i of d??[])await q(e.id,i.version,i.components);for(const[i,S]of Object.entries(l??{})){const p=await u.routes.route(i).catch(()=>{});if(p?.route.recordItem)for(const O of S)await p.route.recordItem(O,_(i),p.context).catch(()=>{})}}for(const e of C)h(`${m.media}${e}`,g(y,e));for(const e of u.routes.specs.keys()){const t=await u.routes.route(e).catch(()=>{});t?.route.record&&await t.route.record(_(e),t.context).catch(()=>{})}const D=[y,await Y(y).catch(()=>y)];for(const e of a.pieces){const t=await u.source(e.id).catch(()=>{});if(!t)continue;const o=me(a.bundle?.chunks,e.id),r=he({prepared:a,piece:e,reach:f,modules:o.modules,roots:D,reads:c.checker?.reads.get(e.id),shows:F.get(e.place)}),d=a.pieces.filter(i=>i.id!==e.id&&!D.some(S=>o.modules.has(g(S,i.file)))).map(i=>i.id),s=ie(e.id);b(s,j(ye(t,r,d)));const l=f.of(e.place);if(l){l.tree.add(s);for(const i of o.files)l.tree.add(`${m.build}${i}`);for(const i of r.media)l.tree.add(`${m.media}${i}`),l.tree.add(`${m.matte}${i}`),l.files.add(i)}}for(const[e,t]of v)for(const o of t)f.of(e)?.tree.add(o);for(const e of a.docs)for(const t of e.shows)f.of(e.place)?.files.add(t);for(const e of a.sheets)for(const t of e.files)f.of(e.place)?.files.add(t);const L=w.preview===!1?void 0:w.preview??(e=>de(n,e));if(L)for(const e of E){const t=await L(e).catch(()=>{});if(t===void 0)continue;const o=re(e.id);b(o,Buffer.from(JSON.stringify(t)),"application/json"),f.of(e.id)?.tree.add(o)}return{revision:W,files:[...P.values()],reach:f.done(new Set(P.keys())),routes:u.routes.loads()}}
2
+ import{readdir as Z,realpath as ee,stat as te}from"node:fs/promises";import{setTimeout as oe}from"node:timers/promises";import{join as b,relative as se,sep as ie}from"node:path";import{openPage as ne}from"@allyhub/browser";import{KeyedStore as re}from"@allyhub/project";import{NEVER_CANCELLED as ae}from"@allyhub/extension-api";import{COMPONENT_STILLS_MAX as J,KindSnapshotSchema as ce,RpcError as K,SNAPSHOT_TREE as m,pieceSourcePath as fe,snapshotAnswerPath as x,snapshotPreviewPath as de,stillPath as z,stillsIndexKey as le,stillsIndexPath as ue}from"@allyhub/protocol";import{runtimeFiles as pe}from"@allyhub/stage-page";import{itemPreview as me}from"./card.js";import{kindContext as he,kindItem as we}from"./kinds.js";import{mediaTypeOf as H}from"@allyhub/formats";import{Reach as ge,pieceBundle as ye,pieceNames as $e,reachedCheck as be,reachedSource as ke}from"./reach.js";import{matteFile as Se}from"./tree.js";export const PAGE_RECORDING={width:1440,height:900,timeout:3e4,settle:1500};const M="https://tree.invalid/";function v(n){return typeof n=="string"?n.startsWith(M)?n.slice(M.length):n:Array.isArray(n)?n.map(v):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([g,a])=>[g,v(a)])):n}const E=n=>new TextEncoder().encode(JSON.stringify(n));async function U(n){return(await Z(n,{recursive:!0,withFileTypes:!0}).catch(()=>[])).filter(a=>a.isFile()).map(a=>se(n,b(a.parentPath,a.name)).split(ie).join("/"))}const je=n=>te(n).then(g=>g.isFile(),()=>!1);export async function recordTree(n,g={}){const{project:a}=n,{live:l,root:y}=a;await a.watcher.settled();const O=new Map,w=(e,t,o=H(e))=>{O.set(e,{path:e,type:o,file:t})},k=(e,t,o=H(e))=>{O.set(e,{path:e,type:o,bytes:t})},N=async(e,t)=>{for(const o of await U(t))w(`${e}${o}`,b(t,o))},V=l.revision,c=await l.prepared(),T=new Map;if(n.ui!==void 0)for(const e of await U(n.ui))w(`${m.editor}${e}`,b(n.ui,e));for(const[e,t]of await pe())w(`${m.runtime}${e}`,t);const R=async(e,t)=>{let o;try{o={result:v(await a.tool(e,t,{tree:M}))}}catch(s){o={error:s instanceof K?{code:s.code,message:s.message}:{code:-32603,message:s instanceof Error?s.message:""}}}const i=x(e,t);k(i,E(o));const f=t.item;return typeof f=="string"&&T.set(f,[...T.get(f)??[],i]),o},X=he(y,e=>a.hasTool(e),async(e,t)=>{const o=await R(e,t);if(o.error)throw new K(o.error.code,o.error.message);return o.result}),q=async(e,t,o)=>{const i=new Map;for(const h of o)i.set(le(h),h);if(i.size===0)return;const f=re.of(y,"stills"),s={stills:{}},u=d.of(e),r=[...i];for(let h=0;h<r.length;h+=J){const j=r.slice(h,h+J);(await a.tool("components/stills",{item:e,...t===""?{}:{version:t},components:j.map(([,$])=>$)},{tree:M}).catch(()=>{}))?.stills.forEach(($,Y)=>{const G=j[Y]?.[0];!$||G===void 0||(s.stills[G]=$.key,w(z($.key),f.path(`${$.key}.webp`),"image/webp"),u?.tree.add(z($.key)))})}const p=ue(e,t);k(p,E(s),"application/json"),u?.tree.add(p)},A=(await R("project/items",{})).result,P=(A?.items??[]).filter(e=>e.kind!==void 0),Q=new Map(c.items.map(e=>[e.id,e.files])),d=new ge(P.map(e=>({...e,files:Q.get(e.id)??e.files})),c.files,(c.bundle?.beside??[]).map(e=>`${m.build}${e}`)),S=a.checker?.state,I=S===void 0||S.status==="waiting"||S.status==="running"?{status:"off",revision:l.revision,problems:S?.problems??[],facts:S?.facts??[]}:S;k(x("check/results",{}),E({result:I}));for(const e of d.items){const t=d.of(e),o=new Set(c.pieces.filter(s=>s.place===e).map(s=>s.id)),i=P.find(s=>s.id===e)?.entry,f=s=>s===i||d.itemsOf(s).includes(e);t?.own.push({path:x("project/items",{}),type:"application/json",bytes:E({result:{...A,items:P.filter(s=>s.id===e)}})},{path:x("check/results",{}),type:"application/json",bytes:E({result:be(I,o,f)})})}for(const e of c.bundle?.chunks.files??[])w(`${m.build}${e}`,b(l.pieceDir,e));for(const e of c.bundle?.beside??[])await N(`${m.build}${e}`,b(l.pieceDir,e));const _=new Set(Object.keys(c.media));for(const e of Object.keys(c.media)){const t=Se(y,c.media[e]);t!==void 0&&await je(t)&&w(`${m.matte}${e}`,t,"video/mp4")}const C=new Map,D=new Map,F=e=>({file:(t,o,i)=>{w(`${e}${t}`,o,i)},folder:(t,o)=>N(`${e}${t}`,o),bytes:(t,o,i)=>{k(`${e}${t}`,o,i)},media:t=>{_.add(t)}});for(const e of P){const t=await a.extensions?.kindProvider(e.kind);if(!t?.snapshot)continue;const o=await Promise.resolve(t.snapshot(we(e),X,ae)).catch(()=>{}),i=ce.safeParse(o??{});if(!i.success)continue;const{stills:f,shows:s,routes:u,page:r}=i.data;r&&C.set(e.id,{...r.folder===void 0?{}:{folder:r.folder},...r.file===void 0?{}:{file:r.file}}),s&&D.set(e.id,{media:new Set(s.media),data:new Set(s.data)});for(const p of f??[])await q(e.id,p.version,p.components);for(const[p,h]of Object.entries(u??{})){const j=await l.routes.route(p).catch(()=>{});if(j?.route.recordItem)for(const B of h)await j.route.recordItem(B,F(p),j.context).catch(()=>{})}}for(const e of _)w(`${m.media}${e}`,b(y,e));for(const[e,t]of C){const o=await a.tool("items/page",{item:e,...t}).catch(()=>{});if(!o)continue;const i=new URL(o.url).origin,f=await ne(await l.browser(),{width:PAGE_RECORDING.width,height:PAGE_RECORDING.height,allow:s=>s===i||s.startsWith(`${i}/`)}).catch(()=>{});if(f)try{await f.goto(o.url,{timeoutMs:PAGE_RECORDING.timeout}),await f.evaluate("document.fonts.ready.then(() => true)",{timeoutMs:PAGE_RECORDING.timeout}),await oe(PAGE_RECORDING.settle)}catch{}finally{await f.close()}}for(const e of d.items){const t=d.of(e);if(t)for(const o of a.inputs.of(e))if(o===""||o.endsWith("/"))for(const i of c.files)i.startsWith(o)&&t.files.add(i);else c.files.includes(o)&&t.files.add(o)}for(const e of l.routes.specs.keys()){const t=await l.routes.route(e).catch(()=>{});t?.route.record&&await t.route.record(F(e),t.context).catch(()=>{})}const L=[y,await ee(y).catch(()=>y)];for(const e of c.pieces){const t=await l.source(e.id).catch(()=>{});if(!t)continue;const o=ye(c.bundle?.chunks,e.id),i=$e({prepared:c,piece:e,reach:d,modules:o.modules,roots:L,reads:a.checker?.reads.get(e.id),shows:D.get(e.place)}),f=c.pieces.filter(r=>r.id!==e.id&&!L.some(p=>o.modules.has(b(p,r.file)))).map(r=>r.id),s=fe(e.id);k(s,E(ke(t,i,f)));const u=d.of(e.place);if(u){u.tree.add(s);for(const r of o.files)u.tree.add(`${m.build}${r}`);for(const r of i.media)u.tree.add(`${m.media}${r}`),u.tree.add(`${m.matte}${r}`),u.files.add(r)}}for(const[e,t]of T)for(const o of t)d.of(e)?.tree.add(o);for(const e of c.docs)for(const t of e.shows)d.of(e.place)?.files.add(t);for(const e of c.sheets)for(const t of e.files)d.of(e.place)?.files.add(t);const W=g.preview===!1?void 0:g.preview??(e=>me(n,e));if(W)for(const e of P){const t=await W(e).catch(()=>{});if(t===void 0)continue;const o=de(e.id);k(o,Buffer.from(JSON.stringify(t)),"application/json"),d.of(e.id)?.tree.add(o)}return{revision:V,files:[...O.values()],reach:d.done(new Set(O.keys())),routes:l.routes.loads()}}
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{createReadStream as f}from"node:fs";import{stat as p}from"node:fs/promises";import{Readable as d}from"node:stream";import{mediaTypeOf as g}from"@allyhub/formats";export async function fileResponse(r,a,i){const c=await p(r).catch(()=>{});if(!c?.isFile())return new Response("not found",{status:404,headers:{...i}});const o={"content-type":g(r),"cache-control":"no-cache","accept-ranges":"bytes",...i},e=c.size,t=a?/^bytes=(\d*)-(\d*)$/u.exec(a.trim()):null,m=(u,l)=>d.toWeb(f(r,{start:u,end:l}));if(!t||t[1]===""&&t[2]===""||e===0)return new Response(e===0?null:m(0,e-1),{status:200,headers:{...o,"content-length":String(e)}});let n,s;return t[1]===""?(n=Math.max(0,e-Number(t[2])),s=e-1):(n=Number(t[1]),s=t[2]===""?e-1:Math.min(Number(t[2]),e-1)),n>=e||n>s?new Response(null,{status:416,headers:{...o,"content-range":`bytes */${String(e)}`}}):new Response(m(n,s),{status:206,headers:{...o,"content-length":String(s-n+1),"content-range":`bytes ${String(n)}-${String(s)}/${String(e)}`}})}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{execFile as s}from"node:child_process";import{dirname as a}from"node:path";export function hasFileManager(r=process.env,e=process.platform){return r.SSH_CONNECTION||r.SSH_TTY||r.CI?!1:e==="darwin"||e==="win32"?!0:[r.DISPLAY,r.WAYLAND_DISPLAY].some(Boolean)}export function revealCommand(r,e=process.platform){return e==="darwin"?["open",["-R",r]]:e==="win32"?["explorer",[`/select,${r}`]]:["xdg-open",[a(r)]]}export function revealFile(r){const[e,n]=revealCommand(r);return new Promise((t,i)=>{s(e,n,o=>{o&&!(process.platform==="win32"&&o.code===1)?i(new Error(o.message)):t()})})}
2
+ import{execFile as s}from"node:child_process";import{homedir as a}from"node:os";import{dirname as m,join as p}from"node:path";export function hasFileManager(r=process.env,e=process.platform){return r.SSH_CONNECTION||r.SSH_TTY||r.CI?!1:e==="darwin"||e==="win32"?!0:[r.DISPLAY,r.WAYLAND_DISPLAY].some(Boolean)}export function downloadsFolder(){return p(a(),"Downloads")}export function revealCommand(r,e=process.platform){return e==="darwin"?["open",["-R",r]]:e==="win32"?["explorer",[`/select,${r}`]]:["xdg-open",[m(r)]]}export function revealFile(r){const[e,n]=revealCommand(r);return new Promise((t,i)=>{s(e,n,o=>{o&&!(process.platform==="win32"&&o.code===1)?i(new Error(o.message)):t()})})}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{join as f}from"node:path";import{pathToFileURL as c}from"node:url";import{pathProblem as l}from"./paths.js";import{inside as h}from"./tree.js";export function contributedRoutes(r){const t=new Map;for(const o of r)for(const e of o.stageRoutes??[])t.has(e.folder)||t.set(e.folder,e);return t}const u=new Map;async function m(r){let t=u.get(r.module);t||(t=import(c(r.module).href).then(e=>{if(typeof e.default!="object"||e.default===null)throw new Error(`${r.extension}'s stage routes (${r.module}) have no default export.`);return e.default}),u.set(r.module,t),t.catch(()=>{u.get(r.module)===t&&u.delete(r.module)}));const o=(await t)[r.folder];if(!o)throw new Error(`${r.extension} serves the stage's ${r.folder} but its module (${r.module}) has no route for it.`);return o}export class Routes{specs;kept=new Map;media=new Set;contexts=new Map;o;constructor(t){this.o=t,this.specs=contributedRoutes(t.kinds)}loads(){return Object.fromEntries([...this.specs].map(([t,o])=>[t,[...o.loads]]))}allowed(t){return this.media.has(t)}async route(t){const o=this.specs.get(t);if(o)return{route:await m(o),context:this.of(t)}}async mediaOf(t,o){let e=o;for(const i of this.specs.keys()){const s=await this.route(i).catch(()=>{}),n=s?.route.media?await s.route.media(t,e,s.context).catch(()=>{}):void 0;n!==void 0&&(e=n)}return e}of(t){let o=this.contexts.get(t);if(o)return o;const{o:e,kept:i,media:s}=this;return o={root:e.root,kinds:e.kinds,get revision(){return e.revision()},prepared:()=>e.prepared(),latest:()=>e.latest(),dir:f(e.buildDir,t.slice(0,-1)),kept(n,d){const a=`${t}\0${n}`;return i.has(a)||i.set(a,d()),i.get(a)},allowMedia(n){for(const d of n)s.add(d)},inProject:n=>l(n)===void 0?h(e.root,n):void 0,view:(n,d)=>e.view(n,d)},this.contexts.set(t,o),o}}
2
+ import{join as f}from"node:path";import{pathToFileURL as c}from"node:url";import{pathProblem as l}from"./paths.js";import{inside as h}from"./tree.js";export function contributedRoutes(r){const t=new Map;for(const o of r)for(const e of o.stageRoutes??[])t.has(e.folder)||t.set(e.folder,e);return t}const a=new Map;async function m(r){let t=a.get(r.module);t||(t=import(c(r.module).href).then(e=>{if(typeof e.default!="object"||e.default===null)throw new Error(`${r.extension}'s stage routes (${r.module}) have no default export.`);return e.default}),a.set(r.module,t),t.catch(()=>{a.get(r.module)===t&&a.delete(r.module)}));const o=(await t)[r.folder];if(!o)throw new Error(`${r.extension} serves the stage's ${r.folder} but its module (${r.module}) has no route for it.`);return o}export class Routes{specs;kept=new Map;media=new Set;contexts=new Map;o;constructor(t){this.o=t,this.specs=contributedRoutes(t.kinds)}loads(){return Object.fromEntries([...this.specs].map(([t,o])=>[t,[...o.loads]]))}allowed(t){return this.media.has(t)}async route(t){const o=this.specs.get(t);if(o)return{route:await m(o),context:this.of(t)}}async mediaOf(t,o){let e=o;for(const s of this.specs.keys()){const d=await this.route(s).catch(()=>{}),n=d?.route.media?await d.route.media(t,e,d.context).catch(()=>{}):void 0;n!==void 0&&(e=n)}return e}of(t){let o=this.contexts.get(t);if(o)return o;const{o:e,kept:s,media:d}=this;return o={root:e.root,kinds:e.kinds,get revision(){return e.revision()},prepared:()=>e.prepared(),latest:()=>e.latest(),dir:f(e.buildDir,t.slice(0,-1)),kept(n,i){const u=`${t}\0${n}`;return s.has(u)||s.set(u,i()),s.get(u)},allowMedia(n){for(const i of n)d.add(i)},recordInputs:(n,i,u)=>{e.recordInputs(n,i,u)},inProject:n=>l(n)===void 0?h(e.root,n):void 0,view:(n,i)=>e.view(n,i)},this.contexts.set(t,o),o}}
@@ -1,6 +1,6 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{randomBytes as E}from"node:crypto";import{createReadStream as B}from"node:fs";import{readFile as M,stat as W}from"node:fs/promises";import{createServer as D}from"node:http";import{Readable as J}from"node:stream";import{join as G,resolve as C}from"node:path";import{getRequestListener as K}from"@hono/node-server";import{Hono as Y}from"hono";import{WebSocketServer as Q}from"ws";import{KeyedStore as V}from"@allyhub/project";import{CollaboratorStateSchema as X,PRESENCE_PATH as Z,SNAPSHOT_TREE as O,TREE_PAGES as ee,stageCsp as te}from"@allyhub/protocol";import{runtimeFile as ne}from"@allyhub/stage-page";import{mediaTypeOf as re}from"@allyhub/formats";import{pathProblem as oe}from"./paths.js";import{ProjectServer as se}from"./project.js";import{STILL_NAME as ie,inside as F,matteFile as ae,sourceName as ce}from"./tree.js";export const RPC_PATH="/rpc",RAW_PATH="/files/raw/";const h={"access-control-allow-origin":"*"};async function y(n,c,a){const g=await W(n).catch(()=>{});if(!g?.isFile())return new Response("not found",{status:404,headers:{...a}});const u={"content-type":re(n),"cache-control":"no-cache","accept-ranges":"bytes",...a},r=g.size,s=c?/^bytes=(\d*)-(\d*)$/u.exec(c.trim()):null,x=(R,N)=>J.toWeb(B(n,{start:R,end:N}));if(!s||s[1]===""&&s[2]===""||r===0)return new Response(r===0?null:x(0,r-1),{status:200,headers:{...u,"content-length":String(r)}});let p,m;return s[1]===""?(p=Math.max(0,r-Number(s[2])),m=r-1):(p=Number(s[1]),m=s[2]===""?r-1:Math.min(Number(s[2]),r-1)),p>=r||p>m?new Response(null,{status:416,headers:{...u,"content-range":`bytes */${String(r)}`}}):new Response(x(p,m),{status:206,headers:{...u,"content-length":String(m-p+1),"content-range":`bytes ${String(p)}-${String(m)}/${String(r)}`}})}const U=/^[a-z][a-z0-9+.-]*:\/\/[a-z0-9.-]+(:\d{1,5})?$/u;export const PING_MS=3e4,ALLYHUB_FORWARDED="allyhub-forwarded";export function forwardedHost(n){const c=n[ALLYHUB_FORWARDED],g=(n.forwarded??(Array.isArray(c)?c[0]:c))?.split(",")[0]?.split(";").map(r=>r.trim().split("=")).find(([r])=>r?.toLowerCase()==="host")?.[1];if(g!==void 0)return g.replace(/^"(.*)"$/u,"$1");const u=n["x-forwarded-host"];return(Array.isArray(u)?u[0]:u)?.split(",")[0]?.trim()}export function frameSources(n){const c=["'self'","http://127.0.0.1:*","http://localhost:*"];if(n===void 0)return c;const a=new URL(n.replace("{port}","1")),g=new URL(n.replace("{port}","2"));if(a.port!==g.port)return[...c,`${a.protocol}//${a.hostname}:*`];const u=a.hostname.slice(a.hostname.indexOf(".")+1);return[...c,`${a.protocol}//*.${u}`]}export async function startDevServer(n){const c=C(n.root);if(n.embedder!==void 0&&!U.test(n.embedder))throw new Error(`Not an origin: ${n.embedder}`);if(n.publicOrigin!==void 0&&!U.test(n.publicOrigin.replace("{port}","1")))throw new Error(`Not an origin: ${n.publicOrigin}`);const a=n.token??E(18).toString("base64url"),u=`/s/${E(18).toString("base64url")}/`,r=await se.open({...n,root:c,...n.publicOrigin===void 0?{}:{reveal:!1}});let s=0;const x=()=>s===0?void 0:n.publicOrigin?.replace("{port}",String(s)),p=()=>{const e=x();return e===void 0?void 0:new URL(e).host},m=()=>{const e=p();return new Set([`127.0.0.1:${String(s)}`,`localhost:${String(s)}`,...e===void 0?[]:[e]])},R=e=>e===p()?x()??"":`http://${e}`,N=e=>R(e.req.header("host")??""),A=e=>{const t=p();t!==void 0&&forwardedHost(e.headers)===t&&(e.headers.host=t)},T=e=>e??`http://127.0.0.1:${String(s)}`;r.serving={file:(e,t)=>`${T(e)}${RAW_PATH}${t.split("/").map(encodeURIComponent).join("/")}?token=${encodeURIComponent(a)}`,tree:e=>`${T(e)}${u}`};const{routes:P}=r.live,S=new Y,I=async e=>{if(!n.ui)return e.text("allyhub dev serves its editors here.",200);const t=await M(G(n.ui,"index.html"),"utf8").catch(()=>{});if(t===void 0)return e.text("The page's files are missing: build them first (pnpm --filter @allyhub/editor-web build).",500);const l=E(16).toString("base64");return e.html(t.replace(/<script/gu,`<script nonce="${l}"`).replace("</head>",`<meta name="allyhub-token" content="${a}"></head>`),200,{"content-security-policy":["default-src 'self'",`script-src 'self' 'nonce-${l}'`,"style-src 'self' 'unsafe-inline'","img-src 'self' data: blob:","media-src 'self' blob:","font-src 'self' data:",`connect-src 'self' ws://${e.req.header("host")??""}`,`frame-src ${frameSources(n.publicOrigin).join(" ")}`,`frame-ancestors ${n.embedder??"'none'"}`].join("; "),"cache-control":"no-store"})};S.get("/",I),S.post(Z,async e=>{if(e.req.header("authorization")!==`Bearer ${a}`)return e.text("forbidden",403);const t=X.safeParse(await e.req.json().catch(()=>{}));return t.success?(r.presence.agent(t.data),e.body(null,204)):e.text(t.error.message,400)}),S.get(`${RAW_PATH}*`,async e=>{if(e.req.query("token")!==a)return e.text("forbidden",403);const t=decodeURIComponent(e.req.path.slice(RAW_PATH.length));if(oe(t)!==void 0)return e.text("forbidden",403);const l=F(c,t);return l?y(l,e.req.header("range"),{"x-content-type-options":"nosniff","content-security-policy":"sandbox; default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'"}):e.text("forbidden",403)}),S.get(`${u}*`,async e=>{let t;try{t=decodeURIComponent(e.req.path.slice(u.length))}catch{return e.notFound()}const l=e.req.header("range"),b=N(e),f=t.slice(0,t.indexOf("/")+1),d=t.slice(f.length);switch(f){case O.runtime:{const o=ne(d);if(!o)return e.notFound();const i=Object.values(ee).includes(t);return y(o,void 0,{...h,...i?{"content-security-policy":te(`${b}${u}`,[b,...n.embedder?[n.embedder]:[]],P.loads())}:{}})}case O.build:{const o=ce(d);if(o===void 0){const i=F(r.live.pieceDir,d);return i?y(i,void 0,h):e.notFound()}try{return e.json(await r.live.source(o),200,{...h,"cache-control":"no-store"})}catch(i){return e.json({error:{message:i instanceof Error?i.message:String(i)}},404,h)}}case O.media:{const i=Object.hasOwn(r.live.latest()?.media??{},d)||P.allowed(d)?F(c,d):void 0;return i?y(i,l,h):e.notFound()}case O.matte:{const o=ae(c,r.live.latest()?.media[d]);return o?y(o,l,{...h,"content-type":"video/mp4"}):e.notFound()}case O.stills:return ie.test(d)?y(V.of(c,"stills").path(d),void 0,{...h,"cache-control":"public, max-age=31536000, immutable"}):e.notFound();default:try{const o=await P.route(f);if(!o)return await e.notFound();const i=new WeakSet,w=await o.route.serve({path:d,query:new URL(e.req.url).searchParams,file:async(_,q,z)=>{const j=F(_,q);if(!j)return;const k=await y(j,l,{...h,...z});return i.add(k),k}},o.context);return w?(!i.has(w)&&!w.headers.has("access-control-allow-origin")&&w.headers.set("access-control-allow-origin","*"),w):await e.notFound()}catch(o){return e.text(o instanceof Error?o.message:String(o),500,{...h})}}}),S.get("/*",async e=>{if(!n.ui)return e.notFound();const t=F(C(n.ui),decodeURIComponent(e.req.path.slice(1)));return t?y(t,void 0,{"cache-control":"public, max-age=3600"}):e.notFound()});const v=new Q({noServer:!0,maxPayload:512*1024*1024});v.on("connection",(e,t)=>{const l=r.connect(o=>{e.readyState===e.OPEN&&e.send(JSON.stringify(o))},{origin:R(t.headers.host??"")});e.on("message",(o,i)=>{if(i||!Buffer.isBuffer(o))return;let w;try{w=JSON.parse(o.toString("utf8"))}catch{e.send(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Not JSON."}}));return}l.receive(w)});const b=n.pingMs??PING_MS;let f=!0;e.on("pong",()=>{f=!0});const d=b>0?setInterval(()=>{if(!f){e.terminate();return}f=!1,e.ping()},b):void 0;d?.unref(),e.on("close",()=>{clearInterval(d),l.close()})});const L=K(S.fetch),H=(e,t)=>{e.writeHead(403,{"content-type":"text/plain; charset=utf-8"}),e.end(t)},$=D((e,t)=>{if(A(e),!m().has(e.headers.host??"")){H(t,"forbidden host");return}L(e,t)});$.on("upgrade",(e,t,l)=>{const b=new URL(e.url??"/","http://x"),f=(o,i)=>{t.end(`HTTP/1.1 ${String(o)} ${i}\r
2
+ import{randomBytes as F}from"node:crypto";import{readFile as z}from"node:fs/promises";import{createServer as D}from"node:http";import{join as J,resolve as C}from"node:path";import{getRequestListener as M}from"@hono/node-server";import{Hono as W}from"hono";import{WebSocketServer as G}from"ws";import{KeyedStore as K}from"@allyhub/project";import{CollaboratorStateSchema as Y,PRESENCE_PATH as Q,SNAPSHOT_TREE as $,TREE_PAGES as V,stageCsp as X}from"@allyhub/protocol";import{runtimeFile as Z}from"@allyhub/stage-page";import{pathProblem as ee}from"./paths.js";import{fileResponse as g}from"./respond.js";import{ProjectServer as te}from"./project.js";import{STILL_NAME as ne,inside as x,matteFile as re,sourceName as oe}from"./tree.js";export const RPC_PATH="/rpc",RAW_PATH="/files/raw/";const p={"access-control-allow-origin":"*"},T=/^[a-z][a-z0-9+.-]*:\/\/[a-z0-9.-]+(:\d{1,5})?$/u;export const PING_MS=3e4,ALLYHUB_FORWARDED="allyhub-forwarded";export function forwardedHost(n){const d=n[ALLYHUB_FORWARDED],y=(n.forwarded??(Array.isArray(d)?d[0]:d))?.split(",")[0]?.split(";").map(i=>i.trim().split("=")).find(([i])=>i?.toLowerCase()==="host")?.[1];if(y!==void 0)return y.replace(/^"(.*)"$/u,"$1");const u=n["x-forwarded-host"];return(Array.isArray(u)?u[0]:u)?.split(",")[0]?.trim()}export function frameSources(n){const d=["'self'","http://127.0.0.1:*","http://localhost:*"];if(n===void 0)return d;const a=new URL(n.replace("{port}","1")),y=new URL(n.replace("{port}","2"));if(a.port!==y.port)return[...d,`${a.protocol}//${a.hostname}:*`];const u=a.hostname.slice(a.hostname.indexOf(".")+1);return[...d,`${a.protocol}//*.${u}`]}export async function startDevServer(n){const d=C(n.root);if(n.embedder!==void 0&&!T.test(n.embedder))throw new Error(`Not an origin: ${n.embedder}`);if(n.publicOrigin!==void 0&&!T.test(n.publicOrigin.replace("{port}","1")))throw new Error(`Not an origin: ${n.publicOrigin}`);const a=n.token??F(18).toString("base64url"),u=`/s/${F(18).toString("base64url")}/`,i=await te.open({...n,root:d,...n.publicOrigin===void 0?{}:{reveal:!1}});let f=0;const P=()=>f===0?void 0:n.publicOrigin?.replace("{port}",String(f)),v=()=>{const e=P();return e===void 0?void 0:new URL(e).host},E=()=>{const e=v();return new Set([`127.0.0.1:${String(f)}`,`localhost:${String(f)}`,...e===void 0?[]:[e]])},R=e=>e===v()?P()??"":`http://${e}`,U=e=>R(e.req.header("host")??""),N=e=>{const t=v();t!==void 0&&forwardedHost(e.headers)===t&&(e.headers.host=t)},A=e=>e??`http://127.0.0.1:${String(f)}`;i.serving={file:(e,t)=>`${A(e)}${RAW_PATH}${t.split("/").map(encodeURIComponent).join("/")}?token=${encodeURIComponent(a)}`,tree:e=>`${A(e)}${u}`};const{routes:O}=i.live,b=new W,I=async e=>{if(!n.ui)return e.text("allyhub dev serves its editors here.",200);const t=await z(J(n.ui,"index.html"),"utf8").catch(()=>{});if(t===void 0)return e.text("The page's files are missing: build them first (pnpm --filter @allyhub/editor-web build).",500);const c=F(16).toString("base64");return e.html(t.replace(/<script/gu,`<script nonce="${c}"`).replace("</head>",`<meta name="allyhub-token" content="${a}"></head>`),200,{"content-security-policy":["default-src 'self'",`script-src 'self' 'nonce-${c}'`,"style-src 'self' 'unsafe-inline'","img-src 'self' data: blob:","media-src 'self' blob:","font-src 'self' data:",`connect-src 'self' ws://${e.req.header("host")??""}`,`frame-src ${frameSources(n.publicOrigin).join(" ")}`,`frame-ancestors ${n.embedder??"'none'"}`].join("; "),"cache-control":"no-store"})};b.get("/",I),b.post(Q,async e=>{if(e.req.header("authorization")!==`Bearer ${a}`)return e.text("forbidden",403);const t=Y.safeParse(await e.req.json().catch(()=>{}));return t.success?(i.presence.agent(t.data),e.body(null,204)):e.text(t.error.message,400)}),b.get(`${RAW_PATH}*`,async e=>{if(e.req.query("token")!==a)return e.text("forbidden",403);const t=decodeURIComponent(e.req.path.slice(RAW_PATH.length));if(ee(t)!==void 0)return e.text("forbidden",403);const c=x(d,t);return c?g(c,e.req.header("range"),{"x-content-type-options":"nosniff","content-security-policy":"sandbox; default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'"}):e.text("forbidden",403)}),b.get(`${u}*`,async e=>{let t;try{t=decodeURIComponent(e.req.path.slice(u.length))}catch{return e.notFound()}const c=e.req.header("range"),m=U(e),l=t.slice(0,t.indexOf("/")+1),s=t.slice(l.length);switch(l){case $.runtime:{const r=Z(s);if(!r)return e.notFound();const o=Object.values(V).includes(t);return g(r,void 0,{...p,...o?{"content-security-policy":X(`${m}${u}`,[m,...n.embedder?[n.embedder]:[]],O.loads())}:{}})}case $.build:{const r=oe(s);if(r===void 0){const o=x(i.live.pieceDir,s);return o?g(o,void 0,p):e.notFound()}try{return e.json(await i.live.source(r),200,{...p,"cache-control":"no-store"})}catch(o){return e.json({error:{message:o instanceof Error?o.message:String(o)}},404,p)}}case $.media:{const o=Object.hasOwn(i.live.latest()?.media??{},s)||O.allowed(s)?x(d,s):void 0;return o?g(o,c,p):e.notFound()}case $.matte:{const r=re(d,i.live.latest()?.media[s]);return r?g(r,c,{...p,"content-type":"video/mp4"}):e.notFound()}case $.stills:return ne.test(s)?g(K.of(d,"stills").path(s),void 0,{...p,"cache-control":"public, max-age=31536000, immutable"}):e.notFound();default:try{const r=await O.route(l);if(!r)return await e.notFound();const o=new WeakSet,h=await r.route.serve({path:s,query:new URL(e.req.url).searchParams,file:async(_,q,B)=>{const j=x(_,q);if(!j)return;const k=await g(j,c,{...p,...B});return o.add(k),k}},r.context);return h?(!o.has(h)&&!h.headers.has("access-control-allow-origin")&&h.headers.set("access-control-allow-origin","*"),h):await e.notFound()}catch(r){return e.text(r instanceof Error?r.message:String(r),500,{...p})}}}),b.get("/*",async e=>{if(!n.ui)return e.notFound();const t=x(C(n.ui),decodeURIComponent(e.req.path.slice(1)));return t?g(t,void 0,{"cache-control":"public, max-age=3600"}):e.notFound()});const S=new G({noServer:!0,maxPayload:512*1024*1024});S.on("connection",(e,t)=>{const c=i.connect(r=>{e.readyState===e.OPEN&&e.send(JSON.stringify(r))},{origin:R(t.headers.host??"")});e.on("message",(r,o)=>{if(o||!Buffer.isBuffer(r))return;let h;try{h=JSON.parse(r.toString("utf8"))}catch{e.send(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Not JSON."}}));return}c.receive(h)});const m=n.pingMs??PING_MS;let l=!0;e.on("pong",()=>{l=!0});const s=m>0?setInterval(()=>{if(!l){e.terminate();return}l=!1,e.ping()},m):void 0;s?.unref(),e.on("close",()=>{clearInterval(s),c.close()})});const L=M(b.fetch),H=(e,t)=>{e.writeHead(403,{"content-type":"text/plain; charset=utf-8"}),e.end(t)},w=D((e,t)=>{if(N(e),!E().has(e.headers.host??"")){H(t,"forbidden host");return}L(e,t)});w.on("upgrade",(e,t,c)=>{const m=new URL(e.url??"/","http://x"),l=(r,o)=>{t.end(`HTTP/1.1 ${String(r)} ${o}\r
3
3
  connection: close\r
4
4
  content-length: 0\r
5
5
  \r
6
- `)};A(e);const d=e.headers.host??"";if(!m().has(d)){f(403,"Forbidden");return}if(b.pathname!==RPC_PATH){f(404,"Not Found");return}if(e.headers.origin!==R(d)){f(403,"Forbidden");return}if(b.searchParams.get("token")!==a){f(403,"Forbidden");return}v.handleUpgrade(e,t,l,o=>{v.emit("connection",o,e)})});try{await new Promise((e,t)=>{$.once("error",t),$.listen(n.port??0,"127.0.0.1",()=>{e()})})}catch(e){throw await r.close(),e}return s=$.address().port,{url:`http://127.0.0.1:${String(s)}/`,port:s,token:a,tree:`http://127.0.0.1:${String(s)}${u}`,ui:n.ui,project:r,async close(){for(const e of v.clients)e.terminate();v.close(),await new Promise(e=>{$.closeAllConnections(),$.close(()=>{e()})}),await r.close()}}}
6
+ `)};N(e);const s=e.headers.host??"";if(!E().has(s)){l(403,"Forbidden");return}if(m.pathname!==RPC_PATH){l(404,"Not Found");return}if(e.headers.origin!==R(s)){l(403,"Forbidden");return}if(m.searchParams.get("token")!==a){l(403,"Forbidden");return}S.handleUpgrade(e,t,c,r=>{S.emit("connection",r,e)})});try{await new Promise((e,t)=>{w.once("error",t),w.listen(n.port??0,"127.0.0.1",()=>{e()})})}catch(e){throw await i.close(),e}return f=w.address().port,{url:`http://127.0.0.1:${String(f)}/`,port:f,token:a,tree:`http://127.0.0.1:${String(f)}${u}`,ui:n.ui,project:i,async close(){for(const e of S.clients)e.terminate();S.close(),await new Promise(e=>{w.closeAllConnections(),w.close(()=>{e()})}),await i.close()}}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{createHash as R}from"node:crypto";import{access as y}from"node:fs/promises";import{basename as j,join as g,posix as P}from"node:path";import{pathToFileURL as C}from"node:url";import{inTime as x,listWork as O,projectItems as h,stageId as I}from"@allyhub/build";import{NEVER_CANCELLED as L}from"@allyhub/extension-api";import{OUT_DIR as M,isListedFile as _,WORK_FILE as D}from"@allyhub/formats";import{OpenedVersion as H,componentStills as N,itemDigests as U,keyedStills as W,parseCombo as A}from"@allyhub/project";import{runtimeFile as K,stageFiles as V}from"@allyhub/stage-page";import{RPC_ERROR as l,RpcError as c,SNAPSHOT_TREE as $,TREE_PAGES as E,listedFileEditor as q,listedKind as T,stillPath as G}from"@allyhub/protocol";import{comboKey as z,componentRefText as B}from"@allyhub/piece";import{providedPreview as J}from"./card.js";import{kindItem as Q}from"./kinds.js";import{rpcErrorOf as b}from"./live.js";const X=t=>R("sha256").update(t).digest("base64url").slice(0,16),f=(t,e)=>{const n=t.tree();if(n===void 0)throw new c(l.unavailable,"This server serves no pages: only allyhub dev's does.");return new URL(e,n).href},F=(t,e,n)=>({url:f(t,`${e}?${n.toString()}`),probe:f(t,E.probe)});async function Y(t,e,n){if(e.title!==void 0)return e.title;const o=await t.extensions?.kindProvider(e.kind);if(!o?.title)return(await n()).get(e.id);try{const r=await o.title(Q(e),t.kindContext,L);return typeof r=="string"?r:void 0}catch{return}}export function contributedTools(t){const e=new Map;for(const n of t)for(const o of n.projectTools??[])e.has(o.name)||e.set(o.name,o);return e}const v=new Map;export async function contributedTool(t){let e=v.get(t.module);e||(e=import(C(t.module).href).then(o=>{if(typeof o.default!="object"||o.default===null)throw new Error(`${t.extension}'s project tools (${t.module}) have no default export.`);return o.default}),v.set(t.module,e),e.catch(()=>{v.get(t.module)===e&&v.delete(t.module)}));const n=(await e)[t.name];if(!n)throw new Error(`${t.extension} contributes the project tool "${t.name}" but its module (${t.module}) has none of that name.`);return n}export function projectToolContext(t){const{live:e}=t,n=new Map;return{root:e.root,kinds:e.kinds,prepared:()=>e.prepared(),target:(o,r)=>e.target(o,r),itemCode:o=>e.itemCode(o),items:async()=>(await h(e.root,e.kinds)).items,async version(o,r,s,a){try{return await e.withSession(async d=>{const i=await H.open({root:e.root,item:o,...r===void 0?{}:{combos:[A(r)]},purpose:s,session:d});try{return await a(i)}finally{await i.close()}})}catch(d){throw b(d)}},async componentStills(o,r,s){try{const a=await e.prepared(),{gpu:d}=await e.browser();return await W(r,{prepared:a,item:o,combo:s,gpu:d,withSession:i=>e.withSession(i)})}catch(a){throw b(a)}},served:o=>f(t,o),page:(o,r)=>F(t,o,r),buildDir:e.pieceDir,stageStyles:()=>V().fontCss.flatMap(o=>{const r=K(o);return r===void 0?[]:[{file:r,url:f(t,`${$.runtime}${o}`)}]}),kept(o,r){return n.has(o)||n.set(o,r()),n.get(o)},held(o,r){return t.held.has(o)||t.held.set(o,r()),t.held.get(o)},jobs:t.services.jobs,cloud:t.services.cloud,env:t.services.env??process.env,forward:o=>Z(t.services.ports,o)}}function Z(t,e){const n=`http://127.0.0.1:${String(e)}/`;return t===void 0?{url:n,hosts:[],dispose:()=>{}}:(t.add(e),{url:t.public(n),hosts:t.hosts(e),dispose:()=>{t.remove(e)}})}export function toolHandlers(t){const{live:e}=t;return{"project/items":async()=>{const n=await h(e.root,e.kinds,void 0,t.extensions?.fileEditors()??[]);let o;const r=()=>o??=(async()=>{const i=await e.prepared().catch(()=>e.latest()),p=new Map;for(const u of i?.pieces??[]){const m=typeof u.title=="string"?u.title:void 0;m&&p.set(u.place,m)}return p})(),s=new Map((e.latest()?.items??[]).map(i=>[i.id,i.files])),a=t.extensions?.fileEditors()??[];return{items:await Promise.all(n.listed.map(async i=>{const p={id:i.id,dir:i.dir,entry:i.entry,...i.title===void 0?{}:{title:i.title},groups:i.groups};if(_(i)){const w=a.find(S=>S.id===i.editor);return{...p,...w?{kindInfo:q(w)}:{}}}const u=await Y(t,i,r),m=e.kinds.find(w=>w.id===i.kind),k=s.get(i.id);return{...p,kind:i.kind,...u?{title:u}:{},...k?{files:k}:{},...m?{kindInfo:T(m)}:{}}})),kinds:e.kinds.map(i=>({id:i.id,...T(i)})),name:j(e.root),scope:X(e.root),revision:e.revision}},"items/preview":async({item:n})=>{const o=n.replace(/^\.\//u,""),r=(await h(e.root,e.kinds)).items.find(a=>a.id===o||a.entry===o);if(!r)throw new c(l.notFound,`There is no item ${n} in the project's list.`);const s=await J(t.extensions,r,t.kindContext);return s===void 0?{}:{preview:s}},"work/add":async({kind:n,file:o,title:r})=>{if(!e.kinds.some(s=>s.id===n))throw new c(l.invalid,`No extension here contributes the kind ${n}.`);return await y(g(e.root,o)).catch(()=>{throw new c(l.notFound,`There is no file ${o} to list in ${D}.`)}),await O(e.root,{kind:n,file:o,...r===void 0?{}:{title:r}}),{}},"components/list":async({item:n})=>{const o=await e.prepared(),r=o.items.find(s=>s.id===n||s.entry===n)?.dir??n;return{components:o.components.map(s=>{const a=P.relative(r,s.file);return{of:B({path:a.startsWith(".")?a:`./${a}`,name:s.export}),name:s.name,...s.label===void 0?{}:{label:s.label}}})}},"components/stage":async({item:n,version:o})=>{const{prepared:r,host:s,combo:a}=await e.componentHost(n,o);if(!("components"in s)&&x(s,r.kinds))throw new c(l.notFound,`${n} has no components to draw alone: a deck's or a doc's are.`);const{code:d}=await U(r,s),i=new URLSearchParams({piece:I(s),combo:z(a),mode:"component",code:d.slice(0,16)});return F(t,E.stage,i)},"components/stills":async({item:n,version:o,components:r})=>{f(t,$.stills);try{const{prepared:s,host:a,combo:d}=await e.componentHost(n,o);if(!("components"in a)&&x(a,s.kinds))throw new c(l.notFound,`${n} has no components to draw alone: a deck's or a doc's are.`);const{gpu:i}=await e.browser();return{stills:(await N(r,{prepared:s,item:a,combo:d,gpu:i,withSession:u=>e.withSession(u)})).map(({key:u})=>({key:u,url:f(t,G(u))}))}}catch(s){throw b(s)}},"check/results":()=>Promise.resolve(t.checker?.state??{status:"off",revision:e.revision,problems:[],facts:[]}),"check/run":()=>{if(!t.checker)throw new c(l.unavailable,"This server runs no check.");return t.checker.schedule(!0),Promise.resolve({})},"export/start":async({item:n,versions:o,types:r,options:s})=>{const{items:a}=await h(e.root,e.kinds);if(!a.some(d=>d.id===n))throw new c(l.notFound,`There is no item ${n}.`);return{job:t.exports.start(n,o??[],r??[],s)}},"export/cancel":({job:n})=>{if(!t.exports.cancel(n))throw new c(l.notFound,`No export ${n} is under way.`);return Promise.resolve({})},"export/list":()=>Promise.resolve({jobs:t.exports.list(),reveal:t.reveal!==void 0}),"export/reveal":async({path:n})=>{if(!t.reveal)throw new c(l.unavailable,"This server is not on the person's computer: download the file.");if(!n.startsWith(`${M}/`))throw new c(l.notFound,`${n} is no exported file.`);const o=g(e.root,n);return await y(o).catch(()=>{throw new c(l.notFound,`There is no file ${n}.`)}),await t.reveal(o),{}}}}
2
+ import{createHash as j}from"node:crypto";import{access as y}from"node:fs/promises";import{basename as P,join as g,posix as O}from"node:path";import{pathToFileURL as C}from"node:url";import{inTime as $,listWork as I,projectItems as w,stageId as L}from"@allyhub/build";import{NEVER_CANCELLED as M}from"@allyhub/extension-api";import{OUT_DIR as _,isListedFile as D,WORK_FILE as H}from"@allyhub/formats";import{OpenedVersion as N,componentStills as W,itemDigests as U,keyedStills as A,parseCombo as K}from"@allyhub/project";import{runtimeFile as V,stageFiles as q}from"@allyhub/stage-page";import{RPC_ERROR as l,RpcError as c,SNAPSHOT_TREE as x,TREE_PAGES as T,listedFileEditor as G,listedKind as E,stillPath as z}from"@allyhub/protocol";import{comboKey as B,componentRefText as J}from"@allyhub/piece";import{providedPreview as Q}from"./card.js";import{kindItem as X}from"./kinds.js";import{rpcErrorOf as b}from"./live.js";import{forwarded as Y}from"./ports.js";const Z=t=>j("sha256").update(t).digest("base64url").slice(0,16);async function F(t,o,n){const e=o.replace(/^\.\//u,""),r=(await w(t.live.root,t.live.kinds)).items.find(d=>d.id===e||d.entry===e);if(!r)throw new c(l.notFound,`There is no item ${o} in the project's list.`);const s=(n.folder??"").replace(/\/+$/u,""),a=n.file??r.entry;if(s!==""&&!a.startsWith(`${s}/`))throw new c(l.invalid,`${a} is not in the folder ${s} the page is served from.`);return t.pages.url(r.id,s,a)}const u=(t,o)=>{const n=t.tree();if(n===void 0)throw new c(l.unavailable,"This server serves no pages: only allyhub dev's does.");return new URL(o,n).href},R=(t,o,n)=>({url:u(t,`${o}?${n.toString()}`),probe:u(t,T.probe)});async function ee(t,o,n){if(o.title!==void 0)return o.title;const e=await t.extensions?.kindProvider(o.kind);if(!e?.title)return(await n()).get(o.id);try{const r=await e.title(X(o),t.kindContext,M);return typeof r=="string"?r:void 0}catch{return}}export function contributedTools(t){const o=new Map;for(const n of t)for(const e of n.projectTools??[])o.has(e.name)||o.set(e.name,e);return o}const v=new Map;export async function contributedTool(t){let o=v.get(t.module);o||(o=import(C(t.module).href).then(e=>{if(typeof e.default!="object"||e.default===null)throw new Error(`${t.extension}'s project tools (${t.module}) have no default export.`);return e.default}),v.set(t.module,o),o.catch(()=>{v.get(t.module)===o&&v.delete(t.module)}));const n=(await o)[t.name];if(!n)throw new Error(`${t.extension} contributes the project tool "${t.name}" but its module (${t.module}) has none of that name.`);return n}export function projectToolContext(t){const{live:o}=t,n=new Map;return{root:o.root,kinds:o.kinds,prepared:()=>o.prepared(),target:(e,r)=>o.target(e,r),itemCode:e=>o.itemCode(e),items:async()=>(await w(o.root,o.kinds)).items,async version(e,r,s,a){try{return await o.withSession(async d=>{const i=await N.open({root:o.root,item:e,...r===void 0?{}:{combos:[K(r)]},purpose:s,session:d});try{return await a(i)}finally{await i.close()}})}catch(d){throw b(d)}},async componentStills(e,r,s){try{const a=await o.prepared(),{gpu:d}=await o.browser();return await A(r,{prepared:a,item:e,combo:s,gpu:d,withSession:i=>o.withSession(i)})}catch(a){throw b(a)}},served:e=>u(t,e),page:(e,r)=>R(t,e,r),buildDir:o.pieceDir,stageStyles:()=>q().fontCss.flatMap(e=>{const r=V(e);return r===void 0?[]:[{file:r,url:u(t,`${x.runtime}${e}`)}]}),kept(e,r){return n.has(e)||n.set(e,r()),n.get(e)},held(e,r){return t.held.has(e)||t.held.set(e,r()),t.held.get(e)},jobs:t.services.jobs,cloud:t.services.cloud,env:t.services.env??process.env,forward:e=>Y(t.services.ports,e),pageOf:(e,r={})=>F(t,e,r),recordInputs:(e,r,s)=>{t.inputs.set(e,r,s)}}}export function toolHandlers(t){const{live:o}=t;return{"project/items":async()=>{const n=await w(o.root,o.kinds,void 0,t.extensions?.fileEditors()??[]);let e;const r=()=>e??=(async()=>{const i=await o.prepared().catch(()=>o.latest()),f=new Map;for(const p of i?.pieces??[]){const m=typeof p.title=="string"?p.title:void 0;m&&f.set(p.place,m)}return f})(),s=new Map((o.latest()?.items??[]).map(i=>[i.id,i.files])),a=t.extensions?.fileEditors()??[];return{items:await Promise.all(n.listed.map(async i=>{const f={id:i.id,dir:i.dir,entry:i.entry,...i.title===void 0?{}:{title:i.title},groups:i.groups};if(D(i)){const h=a.find(S=>S.id===i.editor);return{...f,...h?{kindInfo:G(h)}:{}}}const p=await ee(t,i,r),m=o.kinds.find(h=>h.id===i.kind),k=s.get(i.id);return{...f,kind:i.kind,...p?{title:p}:{},...k?{files:k}:{},...m?{kindInfo:E(m)}:{}}})),kinds:o.kinds.map(i=>({id:i.id,...E(i)})),name:P(o.root),scope:Z(o.root),revision:o.revision}},"items/preview":async({item:n})=>{const e=n.replace(/^\.\//u,""),r=(await w(o.root,o.kinds)).items.find(a=>a.id===e||a.entry===e);if(!r)throw new c(l.notFound,`There is no item ${n} in the project's list.`);const s=await Q(t.extensions,r,t.kindContext);return s===void 0?{}:{preview:s}},"items/page":async({item:n,folder:e,file:r})=>({url:await F(t,n,{folder:e,file:r})}),"work/add":async({kind:n,file:e,title:r})=>{if(!o.kinds.some(s=>s.id===n))throw new c(l.invalid,`No extension here contributes the kind ${n}.`);return await y(g(o.root,e)).catch(()=>{throw new c(l.notFound,`There is no file ${e} to list in ${H}.`)}),await I(o.root,{kind:n,file:e,...r===void 0?{}:{title:r}}),{}},"components/list":async({item:n})=>{const e=await o.prepared(),r=e.items.find(s=>s.id===n||s.entry===n)?.dir??n;return{components:e.components.map(s=>{const a=O.relative(r,s.file);return{of:J({path:a.startsWith(".")?a:`./${a}`,name:s.export}),name:s.name,...s.label===void 0?{}:{label:s.label}}})}},"components/stage":async({item:n,version:e})=>{const{prepared:r,host:s,combo:a}=await o.componentHost(n,e);if(!("components"in s)&&$(s,r.kinds))throw new c(l.notFound,`${n} has no components to draw alone: a deck's or a doc's are.`);const{code:d}=await U(r,s),i=new URLSearchParams({piece:L(s),combo:B(a),mode:"component",code:d.slice(0,16)});return R(t,T.stage,i)},"components/stills":async({item:n,version:e,components:r})=>{u(t,x.stills);try{const{prepared:s,host:a,combo:d}=await o.componentHost(n,e);if(!("components"in a)&&$(a,s.kinds))throw new c(l.notFound,`${n} has no components to draw alone: a deck's or a doc's are.`);const{gpu:i}=await o.browser();return{stills:(await W(r,{prepared:s,item:a,combo:d,gpu:i,withSession:p=>o.withSession(p)})).map(({key:p})=>({key:p,url:u(t,z(p))}))}}catch(s){throw b(s)}},"check/results":()=>Promise.resolve(t.checker?.state??{status:"off",revision:o.revision,problems:[],facts:[]}),"check/run":()=>{if(!t.checker)throw new c(l.unavailable,"This server runs no check.");return t.checker.schedule(!0),Promise.resolve({})},"export/start":async({item:n,versions:e,types:r,options:s})=>{const{items:a}=await w(o.root,o.kinds);if(!a.some(d=>d.id===n))throw new c(l.notFound,`There is no item ${n}.`);return{job:t.exports.start(n,e??[],r??[],s)}},"export/cancel":({job:n})=>{if(!t.exports.cancel(n))throw new c(l.notFound,`No export ${n} is under way.`);return Promise.resolve({})},"export/list":()=>Promise.resolve({jobs:t.exports.list(),reveal:t.reveal!==void 0}),"export/reveal":async({path:n})=>{if(!t.reveal)throw new c(l.unavailable,"This server is not on the person's computer: download the file.");if(!n.startsWith(`${_}/`))throw new c(l.notFound,`${n} is no exported file.`);const e=t.exports.savedOf(n),r=e!==void 0&&await y(e).then(()=>!0,()=>!1)?e:g(o.root,n);return await y(r).catch(()=>{throw new c(l.notFound,`There is no file ${n}.`)}),await t.reveal(r),{}}}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{watch as y}from"node:fs";import{readdir as T,stat as d}from"node:fs/promises";import{join as a,posix as l}from"node:path";import{LOCAL_DIR as w,within as u}from"@allyhub/formats";import{current as m,pathProblem as k}from"./paths.js";const p=40,v=2e3,O=c=>/^(.+)\.\d+$/u.exec(c)?.[1],b=["node_modules",".git"],g=c=>c===w||c.startsWith(`${w}/`)||c.split("/").some(t=>b.includes(t));export class Watcher{revision=0;root;tell;moved;outside;watches=new Map;known=new Map;written=new Map;saved=new Map;fs;pending=new Set;timer;next=1;running=Promise.resolve();constructor(t,s,e=()=>{},i={}){this.root=t,this.tell=s,this.moved=e,this.outside=i}start(){this.fs=y(this.root,{recursive:!0},(t,s)=>{if(s===null)return;const e=s.split("\\").join("/");this.pending.add(e),clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush()},p)}),this.fs.on("error",()=>{})}async watch(t,s){const e=`w${String(this.next++)}`;this.watches.set(e,{client:t,paths:[...s]});for(const i of s)await this.hash(i,!0);return e}unwatch(t){this.watches.delete(t)}forget(t){for(const[s,e]of this.watches)e.client===t&&this.watches.delete(s)}wrote(t,s){const e=Date.now();for(const[i,r]of this.saved)e-r>v&&this.saved.delete(i);for(const i of t)this.known.set(i.path,i.version),this.written.set(i.path,i.version),this.saved.set(i.path,e);this.fanOut(t,s),this.bump()}async settled(){await new Promise(t=>setTimeout(t,p*2)),await this.running}close(){clearTimeout(this.timer),this.fs?.close(),this.watches.clear()}bump(){this.revision++,this.moved(this.revision)}covered(t){for(const s of this.watches.values())if(s.paths.some(e=>u(t,e)||u(e,t)))return!0;return!1}flush(){const t=[...this.pending];this.pending=new Set,this.running=this.running.then(async()=>{const s=t.filter(n=>!g(n)),e=[];for(const n of s){if(!this.written.has(n)){await this.temporary(n)||e.push(n);continue}((await m(a(this.root,n)))?.version??null)!==this.written.get(n)&&e.push(n),this.written.delete(n)}e.length>0&&this.bump();const i=this.outside.by,r=[];for(const n of s)if(this.covered(n))for(const o of await this.hash(n,!1))r.push(i===void 0?o:{...o,by:i});r.length>0&&this.fanOut(r,void 0),e.length>0&&this.outside.moved?.(e)})}async temporary(t){const s=O(t);if(s===void 0)return!1;const e=this.saved.get(s);return e===void 0||Date.now()-e>v?!1:await d(a(this.root,t)).catch(()=>{})===void 0}async hash(t,s){const e=[],i=async o=>{const h=(await m(a(this.root,o)))?.version??null,f=this.known.get(o);f===h&&this.known.has(o)||(this.known.set(o,h),!s&&!(f===void 0&&h===null)&&e.push({path:o,version:h}))},r=await d(a(this.root,t)).catch(()=>{}),n=new Set;if(r?.isDirectory()){const o=await T(a(this.root,t),{recursive:!0,withFileTypes:!0}).catch(()=>[]);for(const h of o){if(!h.isFile())continue;const f=l.join(t,l.relative(a(this.root,t).split("\\").join("/"),a(h.parentPath,h.name).split("\\").join("/")));k(f)===void 0&&!g(f)&&n.add(f)}}else n.add(t);for(const o of this.known.keys())u(o,t)&&n.add(o);for(const o of n)await i(o);return e}fanOut(t,s){for(const[e,i]of this.watches){if(i.client===s)continue;const r=t.filter(n=>i.paths.some(o=>u(n.path,o)));r.length>0&&this.tell(e,r)}}}
2
+ import{watch as y}from"node:fs";import{readdir as T,stat as d}from"node:fs/promises";import{join as a,posix as l}from"node:path";import{LOCAL_DIR as w,within as u}from"@allyhub/formats";import{current as m,pathProblem as k}from"./paths.js";const p=40,v=2e3,O=c=>/^(.+)\.\d+$/u.exec(c)?.[1],b=["node_modules",".git"],g=c=>c===w||c.startsWith(`${w}/`)||c.split("/").some(t=>b.includes(t));export class Watcher{revision=0;root;tell;moved;outside;watches=new Map;known=new Map;written=new Map;saved=new Map;fs;pending=new Set;timer;next=1;running=Promise.resolve();constructor(t,s,e=()=>{},i={}){this.root=t,this.tell=s,this.moved=e,this.outside=i}start(){this.fs=y(this.root,{recursive:!0},(t,s)=>{if(s===null)return;const e=s.split("\\").join("/");this.pending.add(e),clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush()},p)}),this.fs.on("error",()=>{})}async watch(t,s){const e=`w${String(this.next++)}`;this.watches.set(e,{client:t,paths:[...s]});for(const i of s)await this.hash(i,!0);return e}unwatch(t){this.watches.delete(t)}forget(t){for(const[s,e]of this.watches)e.client===t&&this.watches.delete(s)}wrote(t,s){const e=Date.now();for(const[i,r]of this.saved)e-r>v&&this.saved.delete(i);for(const i of t)this.known.set(i.path,i.version),this.written.set(i.path,i.version),this.saved.set(i.path,e);this.fanOut(t,s),this.bump(t.map(i=>i.path))}async settled(){await new Promise(t=>setTimeout(t,p*2)),await this.running}close(){clearTimeout(this.timer),this.fs?.close(),this.watches.clear()}bump(t){this.revision++,this.moved(this.revision,t)}covered(t){for(const s of this.watches.values())if(s.paths.some(e=>u(t,e)||u(e,t)))return!0;return!1}flush(){const t=[...this.pending];this.pending=new Set,this.running=this.running.then(async()=>{const s=t.filter(n=>!g(n)),e=[];for(const n of s){if(!this.written.has(n)){await this.temporary(n)||e.push(n);continue}((await m(a(this.root,n)))?.version??null)!==this.written.get(n)&&e.push(n),this.written.delete(n)}e.length>0&&this.bump(e);const i=this.outside.by,r=[];for(const n of s)if(this.covered(n))for(const o of await this.hash(n,!1))r.push(i===void 0?o:{...o,by:i});r.length>0&&this.fanOut(r,void 0),e.length>0&&this.outside.moved?.(e)})}async temporary(t){const s=O(t);if(s===void 0)return!1;const e=this.saved.get(s);return e===void 0||Date.now()-e>v?!1:await d(a(this.root,t)).catch(()=>{})===void 0}async hash(t,s){const e=[],i=async o=>{const h=(await m(a(this.root,o)))?.version??null,f=this.known.get(o);f===h&&this.known.has(o)||(this.known.set(o,h),!s&&!(f===void 0&&h===null)&&e.push({path:o,version:h}))},r=await d(a(this.root,t)).catch(()=>{}),n=new Set;if(r?.isDirectory()){const o=await T(a(this.root,t),{recursive:!0,withFileTypes:!0}).catch(()=>[]);for(const h of o){if(!h.isFile())continue;const f=l.join(t,l.relative(a(this.root,t).split("\\").join("/"),a(h.parentPath,h.name).split("\\").join("/")));k(f)===void 0&&!g(f)&&n.add(f)}}else n.add(t);for(const o of this.known.keys())u(o,t)&&n.add(o);for(const o of n)await i(o);return e}fanOut(t,s){for(const[e,i]of this.watches){if(i.client===s)continue;const r=t.filter(n=>i.paths.some(o=>u(n.path,o)));r.length>0&&this.tell(e,r)}}}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/dev-server",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -26,6 +26,13 @@ export interface Problem {
26
26
  selector?: string;
27
27
  bbox?: Box;
28
28
  };
29
+ /**
30
+ * A fact of the page that drew it (its browser), not of the piece: where
31
+ * that page renders (frames, check, an export) it is the export's; where
32
+ * it is an editor's preview, the export is not affected, so it is not a
33
+ * problem of the version (allykit#502).
34
+ */
35
+ ofPage?: true;
29
36
  }
30
37
  /** A code no rule this process knows has: a mistake in the code that reports it, or in its extension's manifest. */
31
38
  export declare class UnknownRuleError extends Error {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/diagnostics",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {