allyhub 0.17.0 → 0.18.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 (219) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/commands/render.js +1 -1
  3. package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
  4. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  5. package/dist/node_modules/@allyhub/browser/package.json +1 -1
  6. package/dist/node_modules/@allyhub/build/dist/project-tool.d.ts +7 -4
  7. package/dist/node_modules/@allyhub/build/package.json +1 -1
  8. package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
  9. package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
  10. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  11. package/dist/node_modules/@allyhub/check/package.json +1 -1
  12. package/dist/node_modules/@allyhub/cloud/dist/blobs.d.ts +21 -2
  13. package/dist/node_modules/@allyhub/cloud/dist/blobs.js +1 -1
  14. package/dist/node_modules/@allyhub/cloud/dist/config.d.ts +1 -1
  15. package/dist/node_modules/@allyhub/cloud/dist/index.d.ts +1 -1
  16. package/dist/node_modules/@allyhub/cloud/dist/index.js +1 -1
  17. package/dist/node_modules/@allyhub/cloud/package.json +1 -1
  18. package/dist/node_modules/@allyhub/components/package.json +1 -1
  19. package/dist/node_modules/@allyhub/dev-server/dist/offline-page.js +2 -0
  20. package/dist/node_modules/@allyhub/dev-server/dist/pages.js +1 -1
  21. package/dist/node_modules/@allyhub/dev-server/dist/project.js +1 -1
  22. package/dist/node_modules/@allyhub/dev-server/dist/record.js +1 -1
  23. package/dist/node_modules/@allyhub/dev-server/dist/tools.js +1 -1
  24. package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
  25. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  26. package/dist/node_modules/@allyhub/doc/package.json +1 -1
  27. package/dist/node_modules/@allyhub/doc-extension/package.json +1 -1
  28. package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
  29. package/dist/node_modules/@allyhub/export/package.json +1 -1
  30. package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
  31. package/dist/node_modules/@allyhub/extension-host/dist/host.js +1 -1
  32. package/dist/node_modules/@allyhub/extension-host/dist/points.js +1 -1
  33. package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
  34. package/dist/node_modules/@allyhub/formats/dist/files.d.ts +4 -0
  35. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  36. package/dist/node_modules/@allyhub/html-extension/LICENSE +241 -0
  37. package/dist/node_modules/@allyhub/html-extension/dist/page.js +6 -0
  38. package/dist/node_modules/@allyhub/html-extension/dist/project-tools.js +21 -0
  39. package/dist/node_modules/@allyhub/html-extension/dist/tools.js +2 -0
  40. package/dist/node_modules/@allyhub/html-extension/markup/allyhub.yaml +2 -0
  41. package/dist/node_modules/@allyhub/html-extension/markup/markup.json +15 -0
  42. package/dist/node_modules/@allyhub/html-extension/markup/pages/budget.html +36 -0
  43. package/dist/node_modules/@allyhub/html-extension/package.json +92 -0
  44. package/dist/node_modules/@allyhub/i18n/package.json +1 -1
  45. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  46. package/dist/node_modules/@allyhub/image-extension/package.json +1 -1
  47. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  48. package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
  49. package/dist/node_modules/@allyhub/image-render/package.json +1 -1
  50. package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
  51. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  52. package/dist/node_modules/@allyhub/jobs/dist/show.d.ts +1 -1
  53. package/dist/node_modules/@allyhub/jobs/package.json +1 -1
  54. package/dist/node_modules/@allyhub/linkedin-extension/package.json +1 -1
  55. package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
  56. package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
  57. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  58. package/dist/node_modules/@allyhub/media/package.json +1 -1
  59. package/dist/node_modules/@allyhub/media-extension/package.json +2 -1
  60. package/dist/node_modules/@allyhub/model/package.json +1 -1
  61. package/dist/node_modules/@allyhub/office-extension/package.json +4 -1
  62. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  63. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  64. package/dist/node_modules/@allyhub/project/package.json +1 -1
  65. package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +39 -0
  66. package/dist/node_modules/@allyhub/protocol/dist/events.js +1 -1
  67. package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +3 -2
  68. package/dist/node_modules/@allyhub/protocol/dist/kinds.js +1 -1
  69. package/dist/node_modules/@allyhub/protocol/dist/paywall.d.ts +2 -2
  70. package/dist/node_modules/@allyhub/protocol/dist/shares.d.ts +1 -1
  71. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +11 -4
  72. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  73. package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +0 -7
  74. package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
  75. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  76. package/dist/node_modules/@allyhub/protocol/dist/turns.d.ts +2 -2
  77. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  78. package/dist/node_modules/@allyhub/registry/package.json +1 -1
  79. package/dist/node_modules/@allyhub/render/package.json +1 -1
  80. package/dist/node_modules/@allyhub/runtime/package.json +1 -1
  81. package/dist/node_modules/@allyhub/runtimes/manifest.json +1 -1
  82. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  83. package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
  84. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  85. package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
  86. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  87. package/dist/node_modules/@allyhub/sheet-extension/package.json +1 -1
  88. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  89. package/dist/node_modules/@allyhub/slides-extension/package.json +1 -1
  90. package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
  91. package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
  92. package/dist/node_modules/@allyhub/stage/package.json +1 -1
  93. package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
  94. package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
  95. package/dist/node_modules/@allyhub/telemetry/package.json +1 -1
  96. package/dist/node_modules/@allyhub/text-extension/package.json +2 -1
  97. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  98. package/dist/node_modules/@allyhub/video-extension/package.json +1 -1
  99. package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
  100. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  101. package/dist/node_modules/@allyhub/website/package.json +1 -1
  102. package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
  103. package/dist/node_modules/@allyhub/x-extension/package.json +1 -1
  104. package/dist/node_modules/@allyhub/x-model/package.json +1 -1
  105. package/dist/node_modules/@allyhub/x-view/package.json +1 -1
  106. package/dist/package.json +14 -13
  107. package/editor-web/assets/{abnfDiagram-WEYOIA3C-CHNpVSPv.js → abnfDiagram-WEYOIA3C-Hy4-O0wN.js} +1 -1
  108. package/editor-web/assets/{architecture-WOLXFQ4H-gPsJqQwV.js → architecture-WOLXFQ4H-43JEVxqz.js} +1 -1
  109. package/editor-web/assets/{architectureDiagram-ZHVYKT53-CEIDcC6r.js → architectureDiagram-ZHVYKT53-7bFTl41n.js} +1 -1
  110. package/editor-web/assets/article-CS48wwvk.js +3 -0
  111. package/editor-web/assets/{article-DfELjJ2o.js → article-Cyle57uq.js} +2 -2
  112. package/editor-web/assets/{blockDiagram-RJAE7QA3-CUzEGVet.js → blockDiagram-RJAE7QA3-DcoNo1WH.js} +1 -1
  113. package/editor-web/assets/{c4Diagram-XDPPPE54-CB94NR9s.js → c4Diagram-XDPPPE54-CsMt61gx.js} +1 -1
  114. package/editor-web/assets/channel-HUlo15J7.js +1 -0
  115. package/editor-web/assets/{chunk-2E7WHVMD-DFYo_Boi.js → chunk-2E7WHVMD-fj-TJIRG.js} +1 -1
  116. package/editor-web/assets/{chunk-4EMNKR2T-CLLjmweX.js → chunk-4EMNKR2T-Du5cRy-Y.js} +1 -1
  117. package/editor-web/assets/{chunk-55XCU76K-CkwQ_3m1.js → chunk-55XCU76K-BHXxBBtm.js} +1 -1
  118. package/editor-web/assets/{chunk-7S6XSTFO-V-AvHpAB.js → chunk-7S6XSTFO-R5HW6X5I.js} +1 -1
  119. package/editor-web/assets/{chunk-AQDTSKZB-PjHyYpb8.js → chunk-AQDTSKZB-C98F2BUb.js} +1 -1
  120. package/editor-web/assets/{chunk-DSNLSHJZ-QaczBS3J.js → chunk-DSNLSHJZ-NIGsJ2cK.js} +1 -1
  121. package/editor-web/assets/{chunk-HAGFOTED-aLaQB5Xu.js → chunk-HAGFOTED-BtHxtfW5.js} +1 -1
  122. package/editor-web/assets/{chunk-HNE4Q36P-De3ftDQR.js → chunk-HNE4Q36P-BI8i7Vkk.js} +1 -1
  123. package/editor-web/assets/{chunk-NQOKRVIF-CrhVQyvP.js → chunk-NQOKRVIF-DP_Z_zEA.js} +1 -1
  124. package/editor-web/assets/{chunk-UHW7PFBP-BFmZ5ZLn.js → chunk-UHW7PFBP-C_8bui28.js} +1 -1
  125. package/editor-web/assets/{chunk-VQ5W62QI-CzppUHLA.js → chunk-VQ5W62QI-CKZgzWB2.js} +1 -1
  126. package/editor-web/assets/{chunk-WQQL4CDK-BrAU7V6v.js → chunk-WQQL4CDK-Ff4DgCht.js} +1 -1
  127. package/editor-web/assets/{chunk-YZO67HFG-BSiF71qj.js → chunk-YZO67HFG-Csbx1-pi.js} +1 -1
  128. package/editor-web/assets/{chunk-ZAUX2LTX-BJc4r5b1.js → chunk-ZAUX2LTX-BO1kcV3w.js} +1 -1
  129. package/editor-web/assets/{chunk-ZCHMQSOR-CkGTuehB.js → chunk-ZCHMQSOR-CxeNZYZG.js} +1 -1
  130. package/editor-web/assets/{classDiagram-v2-4MYWR3UA-Byxc7J88.js → classDiagram-v2-4MYWR3UA-D8eHQa5i.js} +1 -1
  131. package/editor-web/assets/{cynefin-EF2NZ3EQ-BSxkVbdf.js → cynefin-EF2NZ3EQ-lIUY3WQQ.js} +1 -1
  132. package/editor-web/assets/{cynefinDiagram-WF24UDRP-IkCgARNs.js → cynefinDiagram-WF24UDRP-CFOOhEEs.js} +1 -1
  133. package/editor-web/assets/{dagre-NK4GIZVX-9PgeH6nY.js → dagre-NK4GIZVX-DdHVup2I.js} +1 -1
  134. package/editor-web/assets/deck-CtEtDHo2.js +1 -0
  135. package/editor-web/assets/{diagram-CBK3MWTC-DRzeg3Ds.js → diagram-CBK3MWTC-CFAD9Y2B.js} +1 -1
  136. package/editor-web/assets/{diagram-I5XIIV2D-B_zeKMN6.js → diagram-I5XIIV2D-DZJAn95A.js} +1 -1
  137. package/editor-web/assets/{diagram-ODIL2UCW-FFm0O8SN.js → diagram-ODIL2UCW-BcIeYTaY.js} +1 -1
  138. package/editor-web/assets/{diagram-PFBEJUXE-DrtCT8OA.js → diagram-PFBEJUXE-CnZmh_fl.js} +1 -1
  139. package/editor-web/assets/{diagram-RJA3I4VV-DtxJ3V0q.js → diagram-RJA3I4VV-DpDd9rGx.js} +1 -1
  140. package/editor-web/assets/{diagram-TYUNFSNR-DmxF_8H_.js → diagram-TYUNFSNR-ouGiUQcR.js} +1 -1
  141. package/editor-web/assets/{dist-C56mWAec.js → dist-BBshIz1Q.js} +2 -2
  142. package/editor-web/assets/dist-BI8QjOsV.js +1 -0
  143. package/editor-web/assets/{dist-CEknsRDd.js → dist-BajH5QfK.js} +3 -3
  144. package/editor-web/assets/{dist-CbZAznNW.js → dist-Bl74xqMW.js} +6 -6
  145. package/editor-web/assets/{dist-BUD4ywMB.js → dist-BrUtQth3.js} +7 -7
  146. package/editor-web/assets/{dist-JLyDtl9X.js → dist-CN5A7Au2.js} +1 -1
  147. package/editor-web/assets/{dist-ZZlQa66J.js → dist-CcL6r6l3.js} +1 -1
  148. package/editor-web/assets/{dist-DDzjbKIg.js → dist-D2E3cgRP.js} +1 -1
  149. package/editor-web/assets/{dist-bQKpw3Zz.js → dist-DGKjn59H.js} +3 -3
  150. package/editor-web/assets/{dist-PBbWAsrV.js → dist-NQNQ5HqZ.js} +3 -3
  151. package/editor-web/assets/{dist-CAb3W9_P.js → dist-SV0sOVIC.js} +1 -1
  152. package/editor-web/assets/{dist-C21CkR7Z.js → dist-Y_XZZa8q.js} +7 -7
  153. package/editor-web/assets/dist-ZrBAbqyJ.js +3 -0
  154. package/editor-web/assets/dist-elglzHMT.js +6 -0
  155. package/editor-web/assets/{dist-Dr3o4vee.js → dist-hHcrvNn9.js} +1 -1
  156. package/editor-web/assets/{docx-draw-9Q_fArBC.js → docx-draw-C4aiB8HI.js} +1 -1
  157. package/editor-web/assets/{ebnfDiagram-V4P3TTPT-DSX1Aoty.js → ebnfDiagram-V4P3TTPT-HRjVlbUf.js} +1 -1
  158. package/editor-web/assets/{elk-QONTBCTQ-C7gy9q56.js → elk-QONTBCTQ-BFmtKyOf.js} +1 -1
  159. package/editor-web/assets/{erDiagram-KYQIGQAA-CKx_HoY4.js → erDiagram-KYQIGQAA-C9gcGEgK.js} +1 -1
  160. package/editor-web/assets/{esm-BZb5QMQf.js → esm-DzxAod8Q.js} +1 -1
  161. package/editor-web/assets/{eventmodeling-K75KTNOO-DL4HvSrd.js → eventmodeling-K75KTNOO-Bpma5Bdb.js} +1 -1
  162. package/editor-web/assets/flowDiagram-IUGLLWBU-tz5ewhC5.js +1 -0
  163. package/editor-web/assets/{ganttDiagram-R7GPNTJY-N-AP4slN.js → ganttDiagram-R7GPNTJY-CE5ut4C3.js} +1 -1
  164. package/editor-web/assets/{gitGraph-VSP46ZUC-BKRGJKWm.js → gitGraph-VSP46ZUC-Dva3iGx2.js} +1 -1
  165. package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-ClwL7w2_.js → gitGraphDiagram-PDYL7XHY-CJXFsAWp.js} +1 -1
  166. package/editor-web/assets/index-Dvh1t1om.css +2 -0
  167. package/editor-web/assets/{index-DG2nHq4D.js → index-q7X6hdHp.js} +3 -3
  168. package/editor-web/assets/{info-OHQRW6UA-DpcY8t23.js → info-OHQRW6UA-BY0AOfex.js} +1 -1
  169. package/editor-web/assets/{infoDiagram-MVDRKAX5-ChtmtWni.js → infoDiagram-MVDRKAX5-4Up1gMvC.js} +1 -1
  170. package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-BZNTuG_F.js → ishikawaDiagram-HPEHV2GE-BkvB9Qbn.js} +1 -1
  171. package/editor-web/assets/{journeyDiagram-BOSHW7O7-C3uVmZbL.js → journeyDiagram-BOSHW7O7-BxV09WdR.js} +1 -1
  172. package/editor-web/assets/{kanban-definition-FNSA4HC5-puEhftGG.js → kanban-definition-FNSA4HC5-zTJtIDPG.js} +1 -1
  173. package/editor-web/assets/{mermaid-parser.core-Bw8re-WE.js → mermaid-parser.core-BWT9UQh_.js} +3 -3
  174. package/editor-web/assets/{mermaid.core-Cc2GIqBr.js → mermaid.core-DFf_Vg5X.js} +4 -4
  175. package/editor-web/assets/{mindmap-definition-6OY57UG3-C6MUl_S_.js → mindmap-definition-6OY57UG3-BYexiugS.js} +1 -1
  176. package/editor-web/assets/{packet-JDAUHWVQ-C75RnvC5.js → packet-JDAUHWVQ-DX_kSrI6.js} +1 -1
  177. package/editor-web/assets/{pegDiagram-ECIUJNBX-ChjmsdV4.js → pegDiagram-ECIUJNBX-I3SrcMLp.js} +1 -1
  178. package/editor-web/assets/{pie-XZMESJXO-BaKxJQpj.js → pie-XZMESJXO-BmAFSw3E.js} +1 -1
  179. package/editor-web/assets/{pieDiagram-GNMPY74T-CT2ez8pr.js → pieDiagram-GNMPY74T-DIZKcme5.js} +1 -1
  180. package/editor-web/assets/{props-form-D5oKHfpk.js → props-form-DUFxM5eb.js} +1 -1
  181. package/editor-web/assets/{quadrantDiagram-D57K4MC3-BJItlTfk.js → quadrantDiagram-D57K4MC3-CO3oSqpQ.js} +1 -1
  182. package/editor-web/assets/{radar-ABXABTNO-DnLzBlTo.js → radar-ABXABTNO-D5CkFrrb.js} +1 -1
  183. package/editor-web/assets/{railroad-I3PHUGI6-D5hj6Yv3.js → railroad-I3PHUGI6-BeKY1p0K.js} +1 -1
  184. package/editor-web/assets/{railroad-abnf-LNEFI6M7-DUZlZoPu.js → railroad-abnf-LNEFI6M7-CIYV9_3-.js} +1 -1
  185. package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-CDyyDC6d.js → railroad-ebnf-DWYD2UWJ-DN0zDl6d.js} +1 -1
  186. package/editor-web/assets/{railroad-peg-JR7BVNR7-CC3ImNnT.js → railroad-peg-JR7BVNR7-Bd_GcO24.js} +1 -1
  187. package/editor-web/assets/{railroadDiagram-Y72NRBL7-Bjw-8Se5.js → railroadDiagram-Y72NRBL7-DlFoiMhb.js} +1 -1
  188. package/editor-web/assets/{requirementDiagram-EQYSW5RA-CDFnuEIO.js → requirementDiagram-EQYSW5RA-LWAEz8Gy.js} +1 -1
  189. package/editor-web/assets/{sankeyDiagram-SY24JHO5-CQPVLY1w.js → sankeyDiagram-SY24JHO5-B_pZGwUK.js} +1 -1
  190. package/editor-web/assets/{sequenceDiagram-BLEHNHQU-BQzuLmBX.js → sequenceDiagram-BLEHNHQU-bNhyCq0C.js} +1 -1
  191. package/editor-web/assets/{session-s1I85rox.js → session-Beijw9EK.js} +1 -1
  192. package/editor-web/assets/snapshots-Dd0Wd_qM.js +1 -0
  193. package/editor-web/assets/{split-7CVjIkSU.js → split-zARio3J8.js} +1 -1
  194. package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-DOuageUf.js → stateDiagram-v2-A6IESKWZ-DI-oM3qz.js} +1 -1
  195. package/editor-web/assets/{swimlanes-B3ENRKFQ-CXKkok7X.js → swimlanes-B3ENRKFQ-awDmoLdW.js} +1 -1
  196. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-X35m3xN6.js +8 -0
  197. package/editor-web/assets/tabs-BHBvbekZ.js +1 -0
  198. package/editor-web/assets/{timeline-definition-JXYKGLGB-DgAjAeZp.js → timeline-definition-JXYKGLGB-CayduPvL.js} +1 -1
  199. package/editor-web/assets/{treeView-D4JQ5SDB-C0Xvnhck.js → treeView-D4JQ5SDB-BVEuNzCO.js} +1 -1
  200. package/editor-web/assets/{treemap-SAJKECNS-aXfKAeSX.js → treemap-SAJKECNS-BOB14HP3.js} +1 -1
  201. package/editor-web/assets/{usecaseDiagram-WPOLBNNX-CvUlBa-L.js → usecaseDiagram-WPOLBNNX-DxT99uaq.js} +1 -1
  202. package/editor-web/assets/{vennDiagram-Q3Y3IDCW-qMJ1iCxs.js → vennDiagram-Q3Y3IDCW-CWUKom-r.js} +1 -1
  203. package/editor-web/assets/{video-DQrjo1TI.js → video-oJ3qa1Qv.js} +1 -1
  204. package/editor-web/assets/{wardley-7MLQ67FV-DEdnH0by.js → wardley-7MLQ67FV-BAQyTneD.js} +1 -1
  205. package/editor-web/assets/{wardleyDiagram-IVAIDKWA-Bt-B2hQ5.js → wardleyDiagram-IVAIDKWA-CiIYz4lZ.js} +1 -1
  206. package/editor-web/assets/{workbook-FSSUiIp9.js → workbook-DznVDqoE.js} +1 -1
  207. package/editor-web/assets/{xychartDiagram-4URNHDU4-DV4bSzTb.js → xychartDiagram-4URNHDU4-D_D5IGmd.js} +1 -1
  208. package/editor-web/index.html +3 -3
  209. package/package.json +2 -2
  210. package/editor-web/assets/article-BHTjq0_Y.js +0 -3
  211. package/editor-web/assets/channel-DCDCx5Es.js +0 -1
  212. package/editor-web/assets/deck-tTzKONci.js +0 -1
  213. package/editor-web/assets/dist-BEpzsYn_.js +0 -6
  214. package/editor-web/assets/dist-DaEbElXI.js +0 -3
  215. package/editor-web/assets/flowDiagram-IUGLLWBU-BUnRtJ8q.js +0 -1
  216. package/editor-web/assets/index-BedbINE5.css +0 -2
  217. package/editor-web/assets/snapshots-BPJKywuN.js +0 -1
  218. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-C3Car2M0.js +0 -8
  219. package/editor-web/assets/tabs-CiF1N-pL.js +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  Feature highlights from each AllyHub release.
4
4
 
5
+ ## 0.18.0
6
+
7
+ - **HTML files open as their page**, at a desktop's, a tablet's or a phone's width, and you can mark them up and share them. Any file can be shared on its own.
8
+ - **Work the agent leaves running is shown.** "N tasks running" over the box you type in says what still runs after the agent's turn, and the agent picks up when it ends.
9
+ - **Cards for what the agent made come at the end of its turn**, and stay there after a reload. It can hand over several items at once.
10
+ - **A project opens on its latest conversation**; New chat is a clean box until you send something.
11
+ - **Turn into is now Express**, the sidebar's rows open their menu from ⋯, and a group can be deleted.
12
+ - **Reports are gone.** Write a page as an HTML file, a doc or a deck.
13
+
14
+ ## 0.17.1
15
+
16
+ - **Projects made by an older AllyHub open in a newer one** at once, with nothing to download for the version they were made with.
17
+ - **A new account starts in AllyHub in the Cloud**, where the agent welcomes you in your language with examples to start from.
18
+
5
19
  ## 0.17.0
6
20
 
7
21
  - **Turn into.** Beside Download, make another kind of what is on show, such as a deck into a video, and say how in your own words before you send it.
@@ -1,3 +1,3 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{join as x,resolve as w}from"node:path";import{z as e}from"zod";import{formatConsole as v,formatProblem as k}from"../text/index.js";import{exportProject as P}from"@allyhub/export";import{GIF_ENCODE as m,SHARE_ENCODE as n}from"@allyhub/render";import{consoleJson as p}from"@allyhub/project";import{OUT_DIR as $}from"@allyhub/formats";import{EXIT as c}from"@allyhub/protocol";import{madeNotes as A}from"@allyhub/build";import{defineCommand as j}from"../command.js";import{parameters as O}from"../parameters.js";import{projectRoot as S}from"../project.js";import{combosOf as F,commandError as D}from"../version.js";import{dir as E,indexing as T}from"../fields.js";import{extensionsAt as h,kindsAt as N}from"./extensions.js";const z={codec:e.enum(["h264","h265"]).default("h264").describe("The mp4's video codec; h265 is smaller"),crf:e.number().int().min(0).max(63).optional().describe(`Quality, lower is better: default ${String(n.crf)} for an mp4, ready to share, 30 for a webm`),maxBitrate:e.number().int().min(0).max(5e5).optional().describe(`An mp4's most video bitrate, kbit/s, 0 for none: default ${String(n.maxKbps)} at 1080p ${String(n.fps)} fps, scaled by the frame's pixels and the frames a second (16000 at 1080p 60, 32000 at 4K 30), so the file is ready to share`),audioBitrate:e.number().int().min(32).max(512).optional().describe("The sound's bitrate, kbit/s: default 192 (AAC in an mp4), 160 (Opus in a webm); a mov keeps PCM"),gifWidth:e.number().int().min(0).max(16384).optional().describe(`A gif's width in pixels, its height in proportion, up to the video's: default ${String(m.width)}; 0 for the video's own`),gifFps:e.number().min(0).max(120).optional().describe(`A gif's frames a second, up to the video's: default ${String(m.fps)}; 0 for the video's own`),steps:e.boolean().default(!1).describe("A deck's pdf, png and pptx: a page, a file or a slide per step of each page (default each page's last step)"),values:e.enum(["data","shown"]).optional().describe("A sheet's csv, json and md: each value as data (a date 2026-01-15, a time 09:30, a duration 36:00, a number to 15 digits; csv's and json's default) or as its format shows it (15 Jan 2026, $1,200.00; md's default)"),bom:e.boolean().default(!0).describe("A sheet's csv starts with a UTF-8 byte-order mark, by which Excel reads its letters right (é, €, 中文); false for a tool that reads plain UTF-8"),quality:e.number().int().min(0).max(100).optional().describe("An image's jpeg and webp, 0–100: default 90 for a jpeg, a webp lossless"),scale:e.number().min(.25).max(4).optional().describe("An image's png, jpeg, webp and zip: each board's picture this many times its size, its layout kept (type and shapes drawn sharp, a picture as many pixels as its file has); default 1"),width:e.number().int().min(1).optional().describe("An image's pictures each this many pixels wide, the height in proportion: a scale for each board"),height:e.number().int().min(1).optional().describe("An image's pictures each this many pixels high, the width in proportion: a scale for each board"),maxKb:e.number().min(1).optional().describe("An image's jpeg and webp: each board's file at most this many KB, at the best quality under it (said); a png is made when it fits under it"),psd:e.enum(["psd","psb"]).default("psd").describe("An image's psd: psd, or psb (Photoshop's large document format); a board is at most 16384 pixels a side, which a psd holds"),pptx:e.enum(["native","picture"]).default("native").describe("A deck's pptx: native, PowerPoint's own model, editable there (the deck's masters, layouts, placeholders, shapes, text, pictures, videos and notes, a component as its picture); or picture, each slide a picture of the page")},C=(s,i)=>`${String(s)} ${i}${s===1?"":"s"}`;export const render=j({name:"render",summary:"The files: a video, its frames, subtitles, cover and mastered mix; a batch's table of ads; a deck's PDF, PPTX and PNGs; a doc's PDF and Markdown; a sheet's Excel workbook with live formulas, PDF, PNG, CSV, Markdown and JSON; an image's pictures, PDF and layered PSDs; a 3D model's GLB",input:e.strictObject({items:e.array(e.string()).optional().describe("Only these items: each an id (its file without its extension) or its file, or a folder of items; default every one"),combo:e.array(e.string()).optional().describe("Only the combos matching name=value pairs joined with commas (lang=zh-cn,hook=b), or a combo's id (c03)"),type:e.array(e.string()).optional().describe("File types: mp4, mov, webm, gif, png, srt, vtt (cues cut as the piece's captions layer cuts them, else by default), cover, wav (the mix, mastered as the render masters it: 48 kHz, 16 bits, the film's length); csv for a piece with slots, its table of ads (<piece>.ads.csv: a row per ad with its combo, picks, length, file, name and generated media); a doc's pdf, docx, png; a sheet's xlsx (every sheet, formulas live with their values cached), pdf, png, csv (a file a sheet); an image's png, jpeg, webp (a file a board), pdf, zip and psd (a layered Photoshop file a board: each layer of its kind, its pixels drawn by Chrome); a deck's pdf, png, pptx; a report's html (one file that runs offline), pdf, png; a LinkedIn or X post's linkedin-post or x-post (its API request, its media beside), txt (its text as written, its media and their alt text beside), png; an article's linkedin-article or x-article, png; a 3D model's glb. Default mp4 for a video, pdf for a deck and a doc, html for a report, xlsx for a sheet, png for an image, glb for a model; each item makes the types it has"),out:e.string().optional().describe("The folder the files go in; default .allyhub/out"),name:e.string().optional().describe("Name a video's or deck's files <name>.<ext> in its folder of the output, with what tells its versions apart before the extension when there are several (<name>.zh-cn.mp4, <name>.c03.mp4); default <output>.<combo>.<ext>"),params:O(z),dir:E}),positional:["items"],output:e.looseObject({out:e.string(),files:e.array(e.looseObject({name:e.string(),path:e.string(),type:e.string()})),failed:e.array(e.looseObject({name:e.string(),code:e.string()}))}),examples:["allyhub render","allyhub render launch/film --type mp4,srt","allyhub render launch/film --type wav","allyhub render ads/tidyform --type csv","allyhub render launch/plan --type pdf,md","allyhub render finance/budget --type xlsx,pdf","allyhub render finance/budget --type csv --param bom=false","allyhub render launch/deck --type pptx --param pptx=picture","allyhub render launch/poster --type psd","allyhub render launch/poster --type jpeg --param scale=2 --param max-kb=2000","allyhub render --combo lang=zh-cn --param crf=16","allyhub render launch/film --name launch-film --param max-bitrate=0"]},async(s,i)=>{const o=await S(i.cwd,s.dir),f=w(i.cwd,s.out??x(o,$)),u=Object.fromEntries(Object.entries(s.params).filter(([,a])=>a!==void 0));let d=0,t;try{t=await P({root:o,kinds:N(o),out:f,...s.items===void 0?{}:{items:s.items},combos:F(s),...s.type===void 0?{}:{types:s.type},...s.name===void 0?{}:{name:s.name},params:u,index:T(i.env),analyses:h(o).mediaAnalyses(),env:i.env,processors:h(o).exportProcessors(),log:a=>{i.progress(a)},onProgress:a=>{const r=Math.floor(a*10);r<=d||r>=10||(d=r,i.progress(`${String(r*10)}%`))},signal:i.signal})}catch(a){throw D(a)}const b=a=>a?` (${a.integrated.toFixed(1)} LUFS, true peak ${a.truePeak===void 0?"–":a.truePeak.toFixed(1)} dBTP)`:"",g=t.problems.filter(a=>a.level==="error"),l=t.files.flatMap(a=>a.files.length>1?a.files.map(r=>` ${r}`):[` ${a.path}${b(a.loudness)}`]),y=[`${C(l.length,"file")} in ${t.out}:`,...l,...t.failed.length>0?["Not made:",...t.failed.map(a=>` ${a.name}: ${a.message}${a.hint?` ${a.hint}`:""}`)]:[],...t.unindexed.map(a=>`Not indexed, drawn the fallback way: ${a.file} (${a.error})`),...A(t.files),...g.map(k),...v(p(t.console))];return{value:{out:t.out,files:t.files.map(a=>({...a})),failed:t.failed.map(a=>({...a})),problems:t.problems,...t.unindexed.length>0?{unindexed:t.unindexed}:{},...p(t.console)},text:y.join(`
2
+ import{join as x,resolve as w}from"node:path";import{z as e}from"zod";import{formatConsole as v,formatProblem as k}from"../text/index.js";import{exportProject as P}from"@allyhub/export";import{GIF_ENCODE as m,SHARE_ENCODE as n}from"@allyhub/render";import{consoleJson as p}from"@allyhub/project";import{OUT_DIR as $}from"@allyhub/formats";import{EXIT as c}from"@allyhub/protocol";import{madeNotes as A}from"@allyhub/build";import{defineCommand as j}from"../command.js";import{parameters as O}from"../parameters.js";import{projectRoot as S}from"../project.js";import{combosOf as F,commandError as D}from"../version.js";import{dir as E,indexing as T}from"../fields.js";import{extensionsAt as h,kindsAt as N}from"./extensions.js";const z={codec:e.enum(["h264","h265"]).default("h264").describe("The mp4's video codec; h265 is smaller"),crf:e.number().int().min(0).max(63).optional().describe(`Quality, lower is better: default ${String(n.crf)} for an mp4, ready to share, 30 for a webm`),maxBitrate:e.number().int().min(0).max(5e5).optional().describe(`An mp4's most video bitrate, kbit/s, 0 for none: default ${String(n.maxKbps)} at 1080p ${String(n.fps)} fps, scaled by the frame's pixels and the frames a second (16000 at 1080p 60, 32000 at 4K 30), so the file is ready to share`),audioBitrate:e.number().int().min(32).max(512).optional().describe("The sound's bitrate, kbit/s: default 192 (AAC in an mp4), 160 (Opus in a webm); a mov keeps PCM"),gifWidth:e.number().int().min(0).max(16384).optional().describe(`A gif's width in pixels, its height in proportion, up to the video's: default ${String(m.width)}; 0 for the video's own`),gifFps:e.number().min(0).max(120).optional().describe(`A gif's frames a second, up to the video's: default ${String(m.fps)}; 0 for the video's own`),steps:e.boolean().default(!1).describe("A deck's pdf, png and pptx: a page, a file or a slide per step of each page (default each page's last step)"),values:e.enum(["data","shown"]).optional().describe("A sheet's csv, json and md: each value as data (a date 2026-01-15, a time 09:30, a duration 36:00, a number to 15 digits; csv's and json's default) or as its format shows it (15 Jan 2026, $1,200.00; md's default)"),bom:e.boolean().default(!0).describe("A sheet's csv starts with a UTF-8 byte-order mark, by which Excel reads its letters right (é, €, 中文); false for a tool that reads plain UTF-8"),quality:e.number().int().min(0).max(100).optional().describe("An image's jpeg and webp, 0–100: default 90 for a jpeg, a webp lossless"),scale:e.number().min(.25).max(4).optional().describe("An image's png, jpeg, webp and zip: each board's picture this many times its size, its layout kept (type and shapes drawn sharp, a picture as many pixels as its file has); default 1"),width:e.number().int().min(1).optional().describe("An image's pictures each this many pixels wide, the height in proportion: a scale for each board"),height:e.number().int().min(1).optional().describe("An image's pictures each this many pixels high, the width in proportion: a scale for each board"),maxKb:e.number().min(1).optional().describe("An image's jpeg and webp: each board's file at most this many KB, at the best quality under it (said); a png is made when it fits under it"),psd:e.enum(["psd","psb"]).default("psd").describe("An image's psd: psd, or psb (Photoshop's large document format); a board is at most 16384 pixels a side, which a psd holds"),pptx:e.enum(["native","picture"]).default("native").describe("A deck's pptx: native, PowerPoint's own model, editable there (the deck's masters, layouts, placeholders, shapes, text, pictures, videos and notes, a component as its picture); or picture, each slide a picture of the page")},C=(s,i)=>`${String(s)} ${i}${s===1?"":"s"}`;export const render=j({name:"render",summary:"The files: a video, its frames, subtitles, cover and mastered mix; a batch's table of ads; a deck's PDF, PPTX and PNGs; a doc's PDF and Markdown; a sheet's Excel workbook with live formulas, PDF, PNG, CSV, Markdown and JSON; an image's pictures, PDF and layered PSDs; a 3D model's GLB",input:e.strictObject({items:e.array(e.string()).optional().describe("Only these items: each an id (its file without its extension) or its file, or a folder of items; default every one"),combo:e.array(e.string()).optional().describe("Only the combos matching name=value pairs joined with commas (lang=zh-cn,hook=b), or a combo's id (c03)"),type:e.array(e.string()).optional().describe("File types: mp4, mov, webm, gif, png, srt, vtt (cues cut as the piece's captions layer cuts them, else by default), cover, wav (the mix, mastered as the render masters it: 48 kHz, 16 bits, the film's length); csv for a piece with slots, its table of ads (<piece>.ads.csv: a row per ad with its combo, picks, length, file, name and generated media); a doc's pdf, docx, png; a sheet's xlsx (every sheet, formulas live with their values cached), pdf, png, csv (a file a sheet); an image's png, jpeg, webp (a file a board), pdf, zip and psd (a layered Photoshop file a board: each layer of its kind, its pixels drawn by Chrome); a deck's pdf, png, pptx; a LinkedIn or X post's linkedin-post or x-post (its API request, its media beside), txt (its text as written, its media and their alt text beside), png; an article's linkedin-article or x-article, png; a 3D model's glb. Default mp4 for a video, pdf for a deck and a doc, xlsx for a sheet, png for an image, glb for a model; each item makes the types it has"),out:e.string().optional().describe("The folder the files go in; default .allyhub/out"),name:e.string().optional().describe("Name a video's or deck's files <name>.<ext> in its folder of the output, with what tells its versions apart before the extension when there are several (<name>.zh-cn.mp4, <name>.c03.mp4); default <output>.<combo>.<ext>"),params:O(z),dir:E}),positional:["items"],output:e.looseObject({out:e.string(),files:e.array(e.looseObject({name:e.string(),path:e.string(),type:e.string()})),failed:e.array(e.looseObject({name:e.string(),code:e.string()}))}),examples:["allyhub render","allyhub render launch/film --type mp4,srt","allyhub render launch/film --type wav","allyhub render ads/tidyform --type csv","allyhub render launch/plan --type pdf,md","allyhub render finance/budget --type xlsx,pdf","allyhub render finance/budget --type csv --param bom=false","allyhub render launch/deck --type pptx --param pptx=picture","allyhub render launch/poster --type psd","allyhub render launch/poster --type jpeg --param scale=2 --param max-kb=2000","allyhub render --combo lang=zh-cn --param crf=16","allyhub render launch/film --name launch-film --param max-bitrate=0"]},async(s,i)=>{const o=await S(i.cwd,s.dir),f=w(i.cwd,s.out??x(o,$)),u=Object.fromEntries(Object.entries(s.params).filter(([,a])=>a!==void 0));let d=0,t;try{t=await P({root:o,kinds:N(o),out:f,...s.items===void 0?{}:{items:s.items},combos:F(s),...s.type===void 0?{}:{types:s.type},...s.name===void 0?{}:{name:s.name},params:u,index:T(i.env),analyses:h(o).mediaAnalyses(),env:i.env,processors:h(o).exportProcessors(),log:a=>{i.progress(a)},onProgress:a=>{const r=Math.floor(a*10);r<=d||r>=10||(d=r,i.progress(`${String(r*10)}%`))},signal:i.signal})}catch(a){throw D(a)}const b=a=>a?` (${a.integrated.toFixed(1)} LUFS, true peak ${a.truePeak===void 0?"–":a.truePeak.toFixed(1)} dBTP)`:"",g=t.problems.filter(a=>a.level==="error"),l=t.files.flatMap(a=>a.files.length>1?a.files.map(r=>` ${r}`):[` ${a.path}${b(a.loudness)}`]),y=[`${C(l.length,"file")} in ${t.out}:`,...l,...t.failed.length>0?["Not made:",...t.failed.map(a=>` ${a.name}: ${a.message}${a.hint?` ${a.hint}`:""}`)]:[],...t.unindexed.map(a=>`Not indexed, drawn the fallback way: ${a.file} (${a.error})`),...A(t.files),...g.map(k),...v(p(t.console))];return{value:{out:t.out,files:t.files.map(a=>({...a})),failed:t.failed.map(a=>({...a})),problems:t.problems,...t.unindexed.length>0?{unindexed:t.unindexed}:{},...p(t.console)},text:y.join(`
3
3
  `),exit:t.failed.length>0?c.failed:c.ok}});
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/3d-extension",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./tools": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/audio",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/browser",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -18,8 +18,9 @@ export interface ToolStylesheet {
18
18
  }
19
19
  /**
20
20
  * Where the process the server runs in makes a port on the loopback
21
- * reachable from the person's page (Studio's Host behind a gateway, as
22
- * Codespaces forwards a port): the shape of the Host's `Ports`.
21
+ * reachable from the person's page (a Studio server behind the gateway, as
22
+ * Codespaces forwards a port): the shape of the Studio server's
23
+ * `ForwardedPorts`.
23
24
  */
24
25
  export interface PortForwarding {
25
26
  add(port: number): void;
@@ -91,7 +92,7 @@ export interface ProjectToolContext {
91
92
  * disposed when the server stops, the last made first.
92
93
  */
93
94
  held<T extends HeldResource>(key: string, make: () => T): T;
94
- /** The jobs of the process the server runs in (Studio's Host's), which list what a tool does that takes a while; none: a tool runs its work alone. */
95
+ /** The jobs of the process the server runs in (a Studio server's), which list what a tool does that takes a while; none: a tool runs its work alone. */
95
96
  readonly jobs: Jobs | undefined;
96
97
  /**
97
98
  * AllyHub's cloud as the person who uses the server's pages is signed in
@@ -108,7 +109,9 @@ export interface ProjectToolContext {
108
109
  * The address of an item's page (`items/page`): `folder` (a project
109
110
  * path, default the project's) served as the root of an origin of its
110
111
  * own, the project's files alone; `file` (default the item's entry) the
111
- * page. What it loads is recorded as the item's inputs.
112
+ * page. `item` may be a file of the project an editor opens by its name
113
+ * (its path), whose page also loads what it names on https. What it
114
+ * loads is recorded as the item's inputs.
112
115
  */
113
116
  pageOf(item: string, o?: {
114
117
  folder?: string;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/build",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/canvas-extension",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/canvas-model",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/chart",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/check",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -4,9 +4,16 @@ export interface BlobSource {
4
4
  sha256: string;
5
5
  size: number;
6
6
  type: string;
7
- /** An absolute file, or the bytes themselves. */
7
+ /** An absolute file, or the bytes themselves; neither, for one that can only be had where storage holds it. */
8
8
  file?: string;
9
9
  bytes?: Uint8Array;
10
+ /** Its file was hashed a while ago, not now: it may have changed since, so its bytes are checked before they are put. */
11
+ checkBytes?: true;
12
+ }
13
+ /** Blobs storage asked for whose bytes are not here: no source, or a file gone or changed since. */
14
+ export declare class BlobsUnavailable extends Error {
15
+ readonly sha256s: readonly string[];
16
+ constructor(sha256s: readonly string[]);
10
17
  }
11
18
  export declare class BlobStore {
12
19
  private readonly cloud;
@@ -14,16 +21,28 @@ export declare class BlobStore {
14
21
  private readonly path;
15
22
  /** Where the digests the organization holds are kept between runs; none, for this run alone. */
16
23
  private readonly file;
24
+ /** The digests held, and whose: the account and organization they were known for. */
17
25
  private known;
18
26
  constructor(cloud: Cloud, o: {
19
27
  path: string;
20
28
  file?: string;
21
29
  });
30
+ /** Whom the digests are known for: the account and the organization the cloud acts in now. */
31
+ private scope;
32
+ /** The digests known for whom the cloud acts for now: none when they were known for another. */
22
33
  private load;
34
+ /** What the file keeps for this scope: nothing when there is none, it is not one, or it was kept for another (a file of before, a list alone, was kept for no one). */
35
+ private read;
23
36
  private save;
37
+ /** A blob's bytes to put; undefined where they are not here (no source, its file gone, or changed since it was hashed). */
38
+ private bytesOf;
24
39
  /** Forgets that these are held (the API said they are missing). */
25
40
  forget(digests: Iterable<string>): Promise<void>;
26
- /** Puts what the organization lacks of these; how many were sent. */
41
+ /**
42
+ * Puts what the organization lacks of these; how many were sent. Those
43
+ * storage lacks whose bytes are not here are thrown, all at once, once
44
+ * the others are put (`BlobsUnavailable`).
45
+ */
27
46
  put(blobs: readonly BlobSource[]): Promise<number>;
28
47
  }
29
48
  //# sourceMappingURL=blobs.d.ts.map
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{mkdir as p,readFile as w,writeFile as S}from"node:fs/promises";import{dirname as b}from"node:path";import{BLOBS_MAX as d,BlobsResponseSchema as y}from"@allyhub/protocol";import{CloudError as g}from"./errors.js";const k=4,A=30*6e4,v=3*6e4;export class BlobStore{cloud;path;file;known;constructor(i,s){this.cloud=i,this.path=s.path,this.file=s.file}async load(){if(this.known)return this.known;if(this.file===void 0)return this.known=new Set;try{this.known=new Set(JSON.parse(await w(this.file,"utf8")))}catch{this.known=new Set}return this.known}async save(){this.file!==void 0&&(await p(b(this.file),{recursive:!0}),await S(this.file,JSON.stringify([...this.known??[]])))}async forget(i){const s=await this.load();for(const n of i)s.delete(n);await this.save()}async put(i){let s=0;const n=await this.load(),o=new Map;for(const e of i)n.has(e.sha256)||o.set(e.sha256,e);const l=[...o.values()];for(let e=0;e<l.length;e+=d){const c=l.slice(e,e+d),{uploads:a}=y.parse(await this.cloud.json(this.path,{method:"POST",signal:AbortSignal.timeout(v),body:{blobs:c.map(t=>({sha256:t.sha256,size:t.size,contentType:t.type}))}}));let f=0;const u=async()=>{for(;f<a.length;){const t=a[f++],r=t&&o.get(t.sha256);if(!t||!r)continue;const m=r.bytes??await w(r.file??""),h=await this.cloud.config.fetch(t.url,{method:"PUT",headers:t.headers,body:new Uint8Array(m),signal:AbortSignal.timeout(A)});if(!h.ok)throw new g("blob-refused",`Storage refused a blob: ${String(h.status)} ${(await h.text()).slice(0,200)}`);s+=1}};await Promise.all(Array.from({length:Math.min(k,a.length)},u));for(const t of c)n.add(t.sha256);await this.save()}return s}}
2
+ import{mkdir as S,readFile as p,writeFile as k}from"node:fs/promises";import{dirname as E}from"node:path";import{BLOBS_MAX as y,BlobsResponseSchema as O}from"@allyhub/protocol";import{z as r}from"zod";import{CloudError as v}from"./errors.js";import{sha256Of as N}from"./hashes.js";export class BlobsUnavailable extends Error{sha256s;constructor(e){super(`${String(e.length)} blob(s) storage lacks cannot be put from here: their bytes are not here any more.`),this.name="BlobsUnavailable",this.sha256s=e}}const A=r.object({scope:r.string(),held:r.array(r.string())}),B=4,x=30*6e4,T=3*6e4;export class BlobStore{cloud;path;file;known;constructor(e,t){this.cloud=e,this.path=t.path,this.file=t.file}async scope(){const e=await this.cloud.requireKey();return JSON.stringify([e.account,e.organization??null])}async load(){const e=await this.scope();return this.known?.scope!==e&&(this.known={scope:e,held:await this.read(e)}),this.known.held}async read(e){if(this.file===void 0)return new Set;let t;try{t=JSON.parse(await p(this.file,"utf8"))}catch(o){if(o instanceof SyntaxError||o instanceof Error&&"code"in o&&o.code==="ENOENT")return new Set;throw o}const s=A.safeParse(t);return s.success&&s.data.scope===e?new Set(s.data.held):new Set}async save(){this.file===void 0||this.known===void 0||(await S(E(this.file),{recursive:!0}),await k(this.file,JSON.stringify({scope:this.known.scope,held:[...this.known.held]})))}async bytesOf(e){if(e.bytes!==void 0)return e.bytes;if(e.file===void 0)return;let t;try{t=await p(e.file)}catch(s){if(s instanceof Error&&"code"in s&&s.code==="ENOENT")return;throw s}return e.checkBytes===!0&&N(t)!==e.sha256?void 0:t}async forget(e){const t=await this.load();for(const s of e)t.delete(s);await this.save()}async put(e){let t=0;const s=await this.load(),o=new Map;for(const i of e)s.has(i.sha256)||o.set(i.sha256,i);const f=[...o.values()],a=[];for(let i=0;i<f.length;i+=y){const d=f.slice(i,i+y),{uploads:c}=O.parse(await this.cloud.json(this.path,{method:"POST",signal:AbortSignal.timeout(T),body:{blobs:d.map(n=>({sha256:n.sha256,size:n.size,contentType:n.type}))}}));let u=0;const b=async()=>{for(;u<c.length;){const n=c[u++],h=n&&o.get(n.sha256);if(!n||!h)continue;const w=await this.bytesOf(h);if(w===void 0){a.push(h.sha256);continue}const l=await this.cloud.config.fetch(n.url,{method:"PUT",headers:n.headers,body:new Uint8Array(w),signal:AbortSignal.timeout(x)});if(!l.ok)throw new v("blob-refused",`Storage refused a blob: ${String(l.status)} ${(await l.text()).slice(0,200)}`);t+=1}};await Promise.all(Array.from({length:Math.min(B,c.length)},b));const g=new Set(a);for(const n of d)g.has(n.sha256)||s.add(n.sha256);await this.save()}if(a.length>0)throw new BlobsUnavailable(a);return t}}
@@ -24,7 +24,7 @@ export interface CloudConfig {
24
24
  */
25
25
  traceparent?: string;
26
26
  /**
27
- * Studio's Host, when an agent in Studio runs this (`ALLYHUB_STUDIO_HOST`,
27
+ * Studio's server, when an agent in Studio runs this (`ALLYHUB_STUDIO_HOST`,
28
28
  * a loopback address with its token): told when a call is refused for
29
29
  * credits, so Studio offers to buy them.
30
30
  */
@@ -7,7 +7,7 @@ export { osKeychain, type Keychain, type KeychainEntry } from "./keychain.js";
7
7
  export { LoopbackError, startLoopback, type Loopback } from "./loopback.js";
8
8
  export { pkcePair, randomState, type PkcePair } from "./pkce.js";
9
9
  export { billingSummary, browserLink, organizations, webLink, } from "./token.js";
10
- export { BlobStore, type BlobSource } from "./blobs.js";
10
+ export { BlobStore, BlobsUnavailable, type BlobSource } from "./blobs.js";
11
11
  export { Hashes, hashFolder, sha256Of, type HashedFile } from "./hashes.js";
12
12
  export { addDeployment, changeSite, createSite, goLive, listSites, removeSite, siteDetail, unpublishSite, } from "./sites.js";
13
13
  export { createMailAlias, mailbox, rawMail, readMail, replyMail, searchMail, sendMail, } from "./mail.js";
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export{cloudConfig,hostsText}from"./config.js";export{CloudError,cloudWork,notSignedIn,SIGN_IN}from"./errors.js";export{Cloud,callsMadeInBackground,scrub}from"./client.js";export{SignedOut,accessOf,accountOf,authServer,chooseOrganization,forgetCredentials,readCredentials,signInWithCode,signInWithDevice,signOut,writeCredentials}from"./credentials.js";export{SIGN_IN_WAIT_MS,openBrowser,signIn,signInByEmail,signInDevice,signInInBackground,signedInAs}from"./signin.js";export{osKeychain}from"./keychain.js";export{LoopbackError,startLoopback}from"./loopback.js";export{pkcePair,randomState}from"./pkce.js";export{billingSummary,browserLink,organizations,webLink}from"./token.js";export{BlobStore}from"./blobs.js";export{Hashes,hashFolder,sha256Of}from"./hashes.js";export{addDeployment,changeSite,createSite,goLive,listSites,removeSite,siteDetail,unpublishSite}from"./sites.js";export{createMailAlias,mailbox,rawMail,readMail,replyMail,searchMail,sendMail}from"./mail.js";export{CATALOG_CACHE_SECONDS,findTool,loadCatalog}from"./catalog.js";export{POLL_SECONDS,READ_SECONDS,RETRY_SECONDS,WAIT_SECONDS,callTool,resumeJob}from"./call.js";export{REUSE_LEFT_MS,UPLOAD_CONCURRENCY,UPLOAD_TYPES,uploadFiles,urlExpiry,withKnownUploads}from"./uploads.js";export{BASE64_FROM,LARGE_FROM,canonical,genRecord,inputHash,isSecretName,namedFile,readGen,recordInput,recordOutput,toolWords,withoutSignature,writeGen,writeWords}from"./records.js";export{makeSay,sayInput}from"./voice.js";
2
+ export{cloudConfig,hostsText}from"./config.js";export{CloudError,cloudWork,notSignedIn,SIGN_IN}from"./errors.js";export{Cloud,callsMadeInBackground,scrub}from"./client.js";export{SignedOut,accessOf,accountOf,authServer,chooseOrganization,forgetCredentials,readCredentials,signInWithCode,signInWithDevice,signOut,writeCredentials}from"./credentials.js";export{SIGN_IN_WAIT_MS,openBrowser,signIn,signInByEmail,signInDevice,signInInBackground,signedInAs}from"./signin.js";export{osKeychain}from"./keychain.js";export{LoopbackError,startLoopback}from"./loopback.js";export{pkcePair,randomState}from"./pkce.js";export{billingSummary,browserLink,organizations,webLink}from"./token.js";export{BlobStore,BlobsUnavailable}from"./blobs.js";export{Hashes,hashFolder,sha256Of}from"./hashes.js";export{addDeployment,changeSite,createSite,goLive,listSites,removeSite,siteDetail,unpublishSite}from"./sites.js";export{createMailAlias,mailbox,rawMail,readMail,replyMail,searchMail,sendMail}from"./mail.js";export{CATALOG_CACHE_SECONDS,findTool,loadCatalog}from"./catalog.js";export{POLL_SECONDS,READ_SECONDS,RETRY_SECONDS,WAIT_SECONDS,callTool,resumeJob}from"./call.js";export{REUSE_LEFT_MS,UPLOAD_CONCURRENCY,UPLOAD_TYPES,uploadFiles,urlExpiry,withKnownUploads}from"./uploads.js";export{BASE64_FROM,LARGE_FROM,canonical,genRecord,inputHash,isSecretName,namedFile,readGen,recordInput,recordOutput,toolWords,withoutSignature,writeGen,writeWords}from"./records.js";export{makeSay,sayInput}from"./voice.js";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/cloud",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/components",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{createHash as h}from"node:crypto";import{posix as c}from"node:path";export const OFFLINE_LIMITS={file:20*1024*1024,page:60*1024*1024};const g={"text/css":".css","text/javascript":".js","application/javascript":".js","application/x-javascript":".js","application/json":".json","font/woff2":".woff2","font/woff":".woff","font/ttf":".ttf","font/otf":".otf","application/font-woff2":".woff2","application/font-woff":".woff","image/png":".png","image/jpeg":".jpg","image/gif":".gif","image/webp":".webp","image/avif":".avif","image/svg+xml":".svg"},d=n=>n.split(";")[0]?.trim().toLowerCase()??"",w=n=>d(n)==="text/css";export function keptPathOf(n,r){let f;try{f=new URL(n)}catch(t){if(t instanceof TypeError)return;throw t}if(f.protocol!=="https:")return;const o=f.pathname.split("/").filter(t=>t!=="").map(t=>t==="."||t===".."?"_":t);let e=o.pop()??"index";f.search!==""&&(e=`${e}-${h("sha256").update(f.search).digest("hex").slice(0,10)}`);const a=g[d(r)];return a!==void 0&&!e.toLowerCase().endsWith(a)&&(e+=a),["_net",f.host,...o,e].join("/")}function u(n,r,f){let o=n;for(const[e,a]of[...f].sort((t,p)=>p[0].length-t[0].length)){const t=c.relative(r,a);o=o.split(e).join(t);const p=e.replaceAll("&","&amp;");p!==e&&(o=o.split(p).join(t))}return o}export function offlinePage(n,r,f){const o=c.dirname(n)==="."?"":c.dirname(n),e=new Map;let a=0;for(const i of f){if(e.has(i.url))continue;const s=keptPathOf(i.url,i.mime);if(s===void 0)continue;const l=i.body.byteLength;l>OFFLINE_LIMITS.file||a+l>OFFLINE_LIMITS.page||(a+=l,e.set(i.url,{path:o===""?s:`${o}/${s}`,file:i}))}if(e.size===0)return[];const t=new Map([...e].map(([i,s])=>[i,s.path])),p=new TextEncoder,m=[{path:n,type:"text/html; charset=utf-8",bytes:p.encode(u(r,o,t))}];for(const{path:i,file:s}of e.values())m.push({path:i,type:s.mime,bytes:w(s.mime)?p.encode(u(new TextDecoder().decode(s.body),c.dirname(i),t)):s.body});return m}
@@ -1,2 +1,2 @@
1
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)))}}}
2
+ import{once as S}from"node:events";import{createServer as v}from"node:http";import{posix as R}from"node:path";import{getRequestListener as P}from"@hono/node-server";import{pathProblem as x}from"./paths.js";import{forwarded as $}from"./ports.js";import{fileResponse as C}from"./respond.js";import{inside as L}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("; "),NETWORK_PAGE_POLICY=["default-src 'self' data: blob: https:","script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: https:","style-src 'self' 'unsafe-inline' https:","img-src 'self' data: blob: https:","font-src 'self' data: https:","connect-src 'self' data: blob:","media-src 'self' data: blob: https:"].join("; "),PAGE_SOURCE="page";export class Pages{o;origins=new Map;constructor(n){this.o=n}async url(n,s,o,l={}){const a=await this.origin(s);a.pages.set(o,n),l.network===!0?a.network.add(o):a.network.delete(o);const d=a.port.url.endsWith("/")?a.port.url:`${a.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,l=new Map,a=new Set,d=new Map;let f=new Set;const g=r=>{let t;try{t=decodeURIComponent(r).replace(/^\/+/u,"")}catch{return}(t===""||t.endsWith("/"))&&(t=`${t}index.html`);const e=n===""?t:`${n}/${t}`;if(x(e)===void 0&&!e.split("/").some(c=>c.startsWith(".")))return R.normalize(e)},b=(r,t)=>{const e=l.get(r);if(e!==void 0){o.set(e,PAGE_SOURCE,[r]);for(const i of d.values())i.delete(e);return new Set([e])}let c;try{const i=t===void 0?void 0:new URL(t);i&&f.has(i.host)&&(c=g(i.pathname))}catch{c=void 0}if(c!==void 0){const i=l.get(c);if(i!==void 0)return new Set([i]);const u=d.get(c);if(u)return new Set(u)}return new Set(l.values())},y=P(async r=>{const t=new URL(r.url),e=g(t.pathname);if(e===void 0)return new Response("not found",{status:404});const c=b(e,r.headers.get("referer")??void 0),i=d.get(e)??new Set;for(const w of c)i.add(w),o.add(w,PAGE_SOURCE,e);d.set(e,i);const u=L(s,e);return u?C(u,r.headers.get("range")??void 0,{"content-security-policy":a.has(e)?NETWORK_PAGE_POLICY:PAGE_POLICY,"cache-control":"no-store","x-content-type-options":"nosniff"}):new Response("not found",{status:404})}),p=v((r,t)=>{if(!f.has(r.headers.host??"")){t.writeHead(403,{"content-type":"text/plain; charset=utf-8"}),t.end("forbidden host");return}y(r,t)});p.listen(0,"127.0.0.1"),await S(p,"listening");const h=p.address().port,m=$(this.o.ports,h);return f=new Set([`127.0.0.1:${String(h)}`,`localhost:${String(h)}`,...m.hosts,new URL(m.url).host]),{server:p,port:m,pages:l,network:a,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(l=>o.server.close(l)))}}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{isListedFile as v,itemNameOf as g,listedWork as T,listsFile as k,projectPath as S}from"@allyhub/formats";import{randomBytes as E}from"node:crypto";import{isAbsolute as y,relative as j,resolve as I,sep as P}from"node:path";import{AGENT_NAME as N,FILE_METHODS as R,HOST_METHODS as x,JSONRPC as c,PRESENCE_METHODS as D,PROJECT_TOOLS as l,RPC_ERROR as d,RequestSchema as M,RpcError as f,answer as p}from"@allyhub/protocol";import{listFiles as _,projectItems as C,readWork as F}from"@allyhub/build";import{Checker as A,Indexer as J}from"./background.js";import{TRASH_KEPT_DAYS as H,movesOfDeletion as L}from"./deletion.js";import{Exports as q}from"./exports.js";import{downloadsFolder as W,hasFileManager as B,revealFile as $}from"./reveal.js";import{Live as K}from"./live.js";import{Inputs as U}from"./inputs.js";import{Pages as Y}from"./pages.js";import{fileIn as O}from"./paths.js";import{kindContext as G}from"./kinds.js";import{Presence as V}from"./presence.js";import{Texts as X}from"./texts.js";import{contributedTool as z,contributedTools as Q,projectToolContext as Z,toolHandlers as ee}from"./tools.js";import{Watcher as te}from"./watcher.js";import{Writer as se}from"./writer.js";export const SERVER_METHODS={...R,"tools/call":x["tools/call"],...D};const ie=5e3,ne="sidebar";export class ProjectServer{root;writer;watcher;live;exports;presence;inputs=new U;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=I(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(!y(t.about.id))return;const s=j(this.root,t.about.id);s===""||s.startsWith("..")||y(s)||this.notify("jobs/changed",{job:t,item:s.split(P).join("/")})})??(()=>{}),this.contributed=Q(e.kinds),this.extensions=e.extensions,this.live=new K(this.root,{kinds:e.kinds,...e.gpu===void 0?{}:{gpu:e.gpu},recordInputs:(t,s,r)=>{const n=[...r];this.listedItems().then(a=>{const h=a.find(u=>u.entry===t);h&&this.inputs.set(h.id,s,n)})}}),this.pages=new Y({root:this.root,ports:e.ports,inputs:this.inputs}),this.presence=new V(t=>{this.notify("presence/changed",{collaborators:t})}),this.texts=new X(this.root),this.watcher=new te(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:N},moved:t=>{this.placing=this.placing.then(()=>this.wroteOutside(t))}}),this.writer=new se(this.root,e.kinds,(t,s)=>{for(const r of t)this.texts.set(r.path,r.text);this.watcher.wrote(t.map(({path:r,version:n})=>({path:r,version:n})),s)},e.writable),this.reveal=e.reveal===!1?void 0:e.reveal??(B()?$:void 0),this.exports=new q(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",{}),r=s.find(n=>n.id===t);return g(r??{id:t})}},{...e.extensions?{processors:e.extensions.exportProcessors(),analyses:e.extensions.mediaAnalyses()}:{},...this.reveal===void 0||e.exportsTo===!1?{}:{saveTo:e.exportsTo??W}});const i=e.index??process.env.ALLYHUB_NO_INDEX!=="1";if(e.check!==!1){const t=i?new J({root:this.root,analyses:e.extensions?.mediaAnalyses()??[],env:e.env??process.env,emit:r=>{this.notify("index/changed",{jobs:r})},made:()=>{this.checker?.schedule(!0)}}):void 0;this.indexer=t;const s=e.extensions?.fileEditors();this.checker=new A({live:this.live,...s===void 0?{}:{files:s},emit:r=>{this.notify("check/changed",r)},...t?{needs:r=>{t.want(r)}}:{},...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:r,lines:n}=await this.texts.changed(s).catch(()=>({changed:!1,lines:void 0}));r&&(i={path:s,...n})}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,r)=>r.dir.length-s.dir.length);return(i.find(s=>s.entry===e)??i.find(s=>s.files!==void 0&&k(s.files,e))??t[0])?.id}async listedItems(){const e=Date.now();return this.listed!==void 0&&e-this.listed.at<ie||(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${E(6).toString("hex")}`;this.clients.set(t,e);const s=this.handlersFor(t,i.origin);return{id:t,receive:async r=>{const n=await this.answerOne(s,r);n&&e(n)},close:()=>{this.clients.delete(t),this.watcher.forget(t);for(const[r,n]of this.owners)n===t&&this.owners.delete(r)}}}channel(){const e=new Set,i=this.connect(t=>{const s=JSON.parse(JSON.stringify(t));queueMicrotask(()=>{for(const r of e)r(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: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=M.safeParse(i);if(!t.success){const r=i?.id;return typeof r!="string"&&typeof r!="number"?void 0:{jsonrpc:c,id:r,error:{code:d.invalidRequest,message:"Not a JSON-RPC request."}}}const s=t.data;return Object.hasOwn(x,s.method)&&s.method!=="tools/call"?{jsonrpc:c,id:s.id,error:{code:d.methodNotFound,message:`${s.method} is answered by the page that hosts the editor, not by allyhub dev's server.`}}:p(SERVER_METHODS,e,s)}handlersFor(e,i){const{writer:t,watcher:s}=this,r=this.toolSet(()=>this.serving?.tree(i));return{"files/read":({path:n})=>t.read(n),"files/write":async({path:n,text:a,over:h})=>({version:await t.write(n,a,h,e)}),"files/upload":async({dir:n,name:a,data:h})=>({path:await t.upload(n,a,Buffer.from(h,"base64"),e)}),"files/url":async({path:n})=>{if(await O(this.root,n),!this.serving)throw new f(d.unavailable,"This server serves no files over HTTP: only allyhub dev's does.");return{url:this.serving.file(i,n)}},"files/list":({dir:n})=>t.list(n),"files/move":async({from:n,to:a})=>({rewritten:await t.move(n,a,e)}),"files/remove":async({path:n})=>({trash:await t.remove(n,e)}),"files/trash":async()=>({entries:await t.trash()}),"files/restore":async({id:n})=>({path:await t.restore(n,e)}),"files/watch":async({paths:n})=>{for(const h of n)await O(this.root,h);const a=await s.watch(e,n);return this.owners.set(a,e),{watch:a}},"files/unwatch":({watch:n})=>(this.owners.get(n)===e&&(s.unwatch(n),this.owners.delete(n)),Promise.resolve({})),"tools/call":async({name:n,arguments:a})=>({result:await this.runTool(r,n,a)}),"presence/get":()=>Promise.resolve({collaborators:this.presence.list()})}}toolSet(e){const i=this.toolContext(e);return{core:ee(i),context:Z(i)}}async runTool(e,i,t){const s={jsonrpc:c,id:0,method:i,params:t},r=Object.hasOwn(l,i)?void 0:this.contributed.get(i);let n;if(r===void 0)n=await p(l,e.core,s);else{const a=await z(r).catch(h=>{throw new f(d.internal,h instanceof Error?h.message:String(h))});n=await p({[i]:a},{[i]:h=>a.run(h,e.context)},s)}if("error"in n)throw new f(n.error.code,n.error.message,n.error.data);return n.result}hasTool(e){return Object.hasOwn(l,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:G(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(l,e)?l[e].result.parse(s):s}async planDeletionOfItem(e){const i=await _(this.root),{listed:t}=await C(this.root,this.live.kinds,i,this.extensions?.fileEditors()??[]),s=t.find(o=>o.id===e);if(s===void 0)throw new f(d.notFound,`There is no item ${e}.`);const r=this.live.latest(),n=new Map((r?.items??[]).map(o=>[o.id,o.files])),a=o=>{const m=!v(o);return{id:o.id,entry:o.entry,ofKind:m,files:m?n.get(o.id):[{path:o.entry}],inputs:[...this.inputs.of(o.id)]}},{work:h}=await F(this.root),{moves:u,stays:b}=L({target:a(s),others:t.filter(o=>o.id!==e).map(a),listed:T(h).map(o=>S(o.file)).filter(o=>o!==s.entry),files:i}),w=r?.pieces.find(o=>o.place===e)?.title;return{item:e,name:g(s,typeof w=="string"?w:void 0),...v(s)?{}:{kind:s.kind},entry:s.entry,moves:u,stays:b}}deleteItemFromSidebar(e,i={}){return this.writer.moveToTrashAndUnlist({planNow:()=>this.planDeletionOfItem(e),keptDays:i.keptDays??H,...i.now===void 0?{}:{now:i.now}},ne)}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()}}
2
+ import{isListedFile as v,itemNameOf as g,listedWork as T,listsFile as k,projectPath as S}from"@allyhub/formats";import{randomBytes as E}from"node:crypto";import{isAbsolute as y,relative as j,resolve as I,sep as P}from"node:path";import{AGENT_NAME as N,FILE_METHODS as R,HOST_METHODS as x,JSONRPC as h,PRESENCE_METHODS as D,PROJECT_TOOLS as l,RPC_ERROR as d,RequestSchema as M,RpcError as f,answer as p}from"@allyhub/protocol";import{listFiles as _,projectItems as C,readWork as F}from"@allyhub/build";import{Checker as A,Indexer as J}from"./background.js";import{TRASH_KEPT_DAYS as H,movesOfDeletion as L}from"./deletion.js";import{Exports as q}from"./exports.js";import{downloadsFolder as W,hasFileManager as B,revealFile as $}from"./reveal.js";import{Live as K}from"./live.js";import{Inputs as U}from"./inputs.js";import{Pages as Y}from"./pages.js";import{fileIn as O}from"./paths.js";import{kindContext as G}from"./kinds.js";import{Presence as V}from"./presence.js";import{Texts as X}from"./texts.js";import{contributedTool as z,contributedTools as Q,projectToolContext as Z,toolHandlers as ee}from"./tools.js";import{Watcher as te}from"./watcher.js";import{Writer as se}from"./writer.js";export const SERVER_METHODS={...R,"tools/call":x["tools/call"],...D};const ie=5e3,ne="sidebar";export class ProjectServer{root;writer;watcher;live;exports;presence;inputs=new U;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=I(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(!y(t.about.id))return;const s=j(this.root,t.about.id);s===""||s.startsWith("..")||y(s)||this.notify("jobs/changed",{job:t,item:s.split(P).join("/")})})??(()=>{}),this.contributed=Q(e.kinds,e.extensions?.projectTools()??[]),this.extensions=e.extensions,this.live=new K(this.root,{kinds:e.kinds,...e.gpu===void 0?{}:{gpu:e.gpu},recordInputs:(t,s,r)=>{const n=[...r];this.listedItems().then(a=>{const c=a.find(u=>u.entry===t);c&&this.inputs.set(c.id,s,n)})}}),this.pages=new Y({root:this.root,ports:e.ports,inputs:this.inputs}),this.presence=new V(t=>{this.notify("presence/changed",{collaborators:t})}),this.texts=new X(this.root),this.watcher=new te(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:N},moved:t=>{this.placing=this.placing.then(()=>this.wroteOutside(t))}}),this.writer=new se(this.root,e.kinds,(t,s)=>{for(const r of t)this.texts.set(r.path,r.text);this.watcher.wrote(t.map(({path:r,version:n})=>({path:r,version:n})),s)},e.writable),this.reveal=e.reveal===!1?void 0:e.reveal??(B()?$:void 0),this.exports=new q(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",{}),r=s.find(n=>n.id===t);return g(r??{id:t})}},{...e.extensions?{processors:e.extensions.exportProcessors(),analyses:e.extensions.mediaAnalyses()}:{},...this.reveal===void 0||e.exportsTo===!1?{}:{saveTo:e.exportsTo??W}});const i=e.index??process.env.ALLYHUB_NO_INDEX!=="1";if(e.check!==!1){const t=i?new J({root:this.root,analyses:e.extensions?.mediaAnalyses()??[],env:e.env??process.env,emit:r=>{this.notify("index/changed",{jobs:r})},made:()=>{this.checker?.schedule(!0)}}):void 0;this.indexer=t;const s=e.extensions?.fileEditors();this.checker=new A({live:this.live,...s===void 0?{}:{files:s},emit:r=>{this.notify("check/changed",r)},...t?{needs:r=>{t.want(r)}}:{},...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:r,lines:n}=await this.texts.changed(s).catch(()=>({changed:!1,lines:void 0}));r&&(i={path:s,...n})}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,r)=>r.dir.length-s.dir.length);return(i.find(s=>s.entry===e)??i.find(s=>s.files!==void 0&&k(s.files,e))??t[0])?.id}async listedItems(){const e=Date.now();return this.listed!==void 0&&e-this.listed.at<ie||(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${E(6).toString("hex")}`;this.clients.set(t,e);const s=this.handlersFor(t,i.origin);return{id:t,receive:async r=>{const n=await this.answerOne(s,r);n&&e(n)},close:()=>{this.clients.delete(t),this.watcher.forget(t);for(const[r,n]of this.owners)n===t&&this.owners.delete(r)}}}channel(){const e=new Set,i=this.connect(t=>{const s=JSON.parse(JSON.stringify(t));queueMicrotask(()=>{for(const r of e)r(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=M.safeParse(i);if(!t.success){const r=i?.id;return typeof r!="string"&&typeof r!="number"?void 0:{jsonrpc:h,id:r,error:{code:d.invalidRequest,message:"Not a JSON-RPC request."}}}const s=t.data;return Object.hasOwn(x,s.method)&&s.method!=="tools/call"?{jsonrpc:h,id:s.id,error:{code:d.methodNotFound,message:`${s.method} is answered by the page that hosts the editor, not by allyhub dev's server.`}}:p(SERVER_METHODS,e,s)}handlersFor(e,i){const{writer:t,watcher:s}=this,r=this.toolSet(()=>this.serving?.tree(i));return{"files/read":({path:n})=>t.read(n),"files/write":async({path:n,text:a,over:c})=>({version:await t.write(n,a,c,e)}),"files/upload":async({dir:n,name:a,data:c})=>({path:await t.upload(n,a,Buffer.from(c,"base64"),e)}),"files/url":async({path:n})=>{if(await O(this.root,n),!this.serving)throw new f(d.unavailable,"This server serves no files over HTTP: only allyhub dev's does.");return{url:this.serving.file(i,n)}},"files/list":({dir:n})=>t.list(n),"files/move":async({from:n,to:a})=>({rewritten:await t.move(n,a,e)}),"files/remove":async({path:n})=>({trash:await t.remove(n,e)}),"files/trash":async()=>({entries:await t.trash()}),"files/restore":async({id:n})=>({path:await t.restore(n,e)}),"files/watch":async({paths:n})=>{for(const c of n)await O(this.root,c);const a=await s.watch(e,n);return this.owners.set(a,e),{watch:a}},"files/unwatch":({watch:n})=>(this.owners.get(n)===e&&(s.unwatch(n),this.owners.delete(n)),Promise.resolve({})),"tools/call":async({name:n,arguments:a})=>({result:await this.runTool(r,n,a)}),"presence/get":()=>Promise.resolve({collaborators:this.presence.list()})}}toolSet(e){const i=this.toolContext(e);return{core:ee(i),context:Z(i)}}async runTool(e,i,t){const s={jsonrpc:h,id:0,method:i,params:t},r=Object.hasOwn(l,i)?void 0:this.contributed.get(i);let n;if(r===void 0)n=await p(l,e.core,s);else{const a=await z(r).catch(c=>{throw new f(d.internal,c instanceof Error?c.message:String(c))});n=await p({[i]:a},{[i]:c=>a.run(c,e.context)},s)}if("error"in n)throw new f(n.error.code,n.error.message,n.error.data);return n.result}hasTool(e){return Object.hasOwn(l,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:G(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(l,e)?l[e].result.parse(s):s}async planDeletionOfItem(e){const i=await _(this.root),{listed:t}=await C(this.root,this.live.kinds,i,this.extensions?.fileEditors()??[]),s=t.find(o=>o.id===e);if(s===void 0)throw new f(d.notFound,`There is no item ${e}.`);const r=this.live.latest(),n=new Map((r?.items??[]).map(o=>[o.id,o.files])),a=o=>{const m=!v(o);return{id:o.id,entry:o.entry,ofKind:m,files:m?n.get(o.id):[{path:o.entry}],inputs:[...this.inputs.of(o.id)]}},{work:c}=await F(this.root),{moves:u,stays:b}=L({target:a(s),others:t.filter(o=>o.id!==e).map(a),listed:T(c).map(o=>S(o.file)).filter(o=>o!==s.entry),files:i}),w=r?.pieces.find(o=>o.place===e)?.title;return{item:e,name:g(s,typeof w=="string"?w:void 0),...v(s)?{}:{kind:s.kind},entry:s.entry,moves:u,stays:b}}deleteItemFromSidebar(e,i={}){return this.writer.moveToTrashAndUnlist({planNow:()=>this.planDeletionOfItem(e),keptDays:i.keptDays??H,...i.now===void 0?{}:{now:i.now}},ne)}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 ee,realpath as te,stat as oe}from"node:fs/promises";import{setTimeout as se}from"node:timers/promises";import{join as S,relative as ie,sep as ne}from"node:path";import{openPage as ae}from"@allyhub/browser";import{KeyedStore as re}from"@allyhub/project";import{NEVER_CANCELLED as ce}from"@allyhub/extension-api";import{COMPONENT_STILLS_MAX as U,KindSnapshotSchema as fe,RpcError as z,SNAPSHOT_TREE as b,pieceSourcePath as de,snapshotAnswerPath as T,snapshotPreviewPath as le,stillPath as H,stillsIndexKey as ue,stillsIndexPath as me}from"@allyhub/protocol";import{runtimeFiles as pe}from"@allyhub/stage-page";import{itemPreview as he}from"./card.js";import{kindContext as we,kindItem as ge}from"./kinds.js";import{USE_FORMS as ye,mediaTypeOf as A}from"@allyhub/formats";import{Reach as be,pieceBundle as $e,pieceNames as Se,reachedCheck as ke,reachedSource as Ee}from"./reach.js";import{matteFile as je}from"./tree.js";const Pe="assets/";export const PAGE_RECORDING={width:1440,height:900,timeout:3e4,settle:1500};const x="https://tree.invalid/";function I(n){return typeof n=="string"?n.startsWith(x)?n.slice(x.length):n:Array.isArray(n)?n.map(I):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([$,r])=>[$,I(r)])):n}const P=n=>new TextEncoder().encode(JSON.stringify(n));async function V(n){return(await ee(n,{recursive:!0,withFileTypes:!0}).catch(()=>[])).filter(r=>r.isFile()).map(r=>ie(n,S(r.parentPath,r.name)).split(ne).join("/"))}const ve=n=>oe(n).then($=>$.isFile(),()=>!1);export async function recordTree(n,$={}){const{project:r}=n,{live:l,root:w}=r;await r.watcher.settled();const g=new Map,m=(e,t,o=A(e))=>{g.set(e,{path:e,type:o,file:t})},N=(e,t)=>{g.set(e,{path:e,type:A(e),file:t,immutable:!0})},k=(e,t,o=A(e))=>{g.set(e,{path:e,type:o,bytes:t})},_=async(e,t)=>{for(const o of await V(t))m(`${e}${o}`,S(t,o))},X=l.revision,c=await l.prepared(),R=new Map;if(n.ui!==void 0)for(const e of await V(n.ui))(e.startsWith(Pe)?N:m)(`${b.editor}${e}`,S(n.ui,e));for(const[e,t]of await pe())m(`${b.runtime}${e}`,t);const O=async(e,t)=>{let o;try{o={result:I(await r.tool(e,t,{tree:x}))}}catch(i){o={error:i instanceof z?{code:i.code,message:i.message}:{code:-32603,message:i instanceof Error?i.message:""}}}const a=T(e,t);k(a,P(o));const f=t.item;return typeof f=="string"&&R.set(f,[...R.get(f)??[],a]),o},q=we(w,e=>r.hasTool(e),async(e,t)=>{const o=await O(e,t);if(o.error)throw new z(o.error.code,o.error.message);return o.result}),Q=async(e,t,o)=>{const a=new Map;for(const s of o)a.set(ue(s),s);if(a.size===0)return;const f=re.of(w,"stills"),i={stills:{}},j=u.of(e),p=[...a];for(let s=0;s<p.length;s+=U){const y=p.slice(s,s+U);(await r.tool("components/stills",{item:e,...t===""?{}:{version:t},components:y.map(([,h])=>h)},{tree:x}).catch(()=>{}))?.stills.forEach((h,Z)=>{const K=y[Z]?.[0];!h||K===void 0||(i.stills[K]=h.key,m(H(h.key),f.path(`${h.key}.webp`),"image/webp"),j?.tree.add(H(h.key)))})}const d=me(e,t);k(d,P(i),"application/json"),j?.tree.add(d)},C=(await O("project/items",{})).result,v=(C?.items??[]).filter(e=>e.kind!==void 0),Y=new Map(c.items.map(e=>[e.id,e.files])),u=new be(v.map(e=>({...e,files:Y.get(e.id)??e.files})),c.files,(c.bundle?.beside??[]).map(e=>`${b.build}${e}`)),E=r.checker?.state,D=E===void 0||E.status==="waiting"||E.status==="running"?{status:"off",revision:l.revision,problems:E?.problems??[],facts:E?.facts??[]}:E;k(T("check/results",{}),P({result:D}));for(const e of u.items){const t=u.of(e),o=new Set(c.pieces.filter(i=>i.place===e).map(i=>i.id)),a=v.find(i=>i.id===e)?.entry,f=i=>i===a||u.itemsOf(i).includes(e);t?.own.push({path:T("project/items",{}),type:"application/json",bytes:P({result:{...C,items:v.filter(i=>i.id===e)}})},{path:T("check/results",{}),type:"application/json",bytes:P({result:ke(D,o,f)})})}for(const e of c.bundle?.chunks.files??[])N(`${b.build}${e}`,S(l.pieceDir,e));for(const e of c.bundle?.beside??[])await _(`${b.build}${e}`,S(l.pieceDir,e));const F=new Set(Object.keys(c.media));for(const e of Object.keys(c.media)){const t=je(w,c.media[e]);t!==void 0&&await ve(t)&&m(`${b.matte}${e}`,t,"video/mp4")}const L=new Map,W=new Map,B=e=>({file:(t,o,a)=>{m(`${e}${t}`,o,a)},folder:(t,o)=>_(`${e}${t}`,o),bytes:(t,o,a)=>{k(`${e}${t}`,o,a)},media:t=>{F.add(t)}});for(const e of v){const t=await r.extensions?.kindProvider(e.kind);if(!t?.snapshot)continue;const o=await Promise.resolve(t.snapshot(ge(e),q,ce)).catch(()=>{}),a=fe.safeParse(o??{});if(!a.success)continue;const{stills:f,shows:i,routes:j,page:p}=a.data;p&&L.set(e.id,{...p.folder===void 0?{}:{folder:p.folder},...p.file===void 0?{}:{file:p.file}}),i&&W.set(e.id,{media:new Set(i.media),data:new Set(i.data)});for(const d of f??[])await O("components/stage",{item:e.id,version:d.version}),d.version===""&&await O("components/stage",{item:e.id}),await Q(e.id,d.version,d.components);for(const[d,s]of Object.entries(j??{})){const y=await l.routes.route(d).catch(()=>{});if(y?.route.recordItem)for(const M of s)await y.route.recordItem(M,B(d),y.context).catch(()=>{})}}for(const e of F)m(`${b.media}${e}`,S(w,e));for(const[e,t]of L){const o=await r.tool("items/page",{item:e,...t}).catch(()=>{});if(!o)continue;const a=new URL(o.url).origin,f=await ae(await l.browser(),{width:PAGE_RECORDING.width,height:PAGE_RECORDING.height,allow:i=>i===a||i.startsWith(`${a}/`)}).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 se(PAGE_RECORDING.settle)}catch{}finally{await f.close()}}for(const e of u.items){const t=u.of(e);if(t)for(const o of r.inputs.of(e))if(o===""||o.endsWith("/"))for(const a of c.files)a.startsWith(o)&&t.files.add(a);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(B(e),t.context).catch(()=>{})}const G=[w,await te(w).catch(()=>w)];for(const e of c.pieces){const t=await l.source(e.id).catch(()=>{});if(!t)continue;const o=[e,...c.pieces.filter(s=>Me(c.items,e.place).has(s.place))],a=o.map(s=>({p:s,bundle:$e(c.bundle?.chunks,s.id)})),f={files:new Set(a.flatMap(s=>[...s.bundle.files])),modules:new Set(a.flatMap(s=>[...s.bundle.modules]))},i={media:new Set,data:new Set};for(const{p:s,bundle:y}of a){const M=Se({prepared:c,piece:s,reach:u,modules:y.modules,roots:G,reads:r.checker?.reads.get(s.id),shows:W.get(s.place)});for(const h of M.media)i.media.add(h);for(const h of M.data)i.data.add(h)}const j=c.pieces.filter(s=>!o.includes(s)&&!G.some(y=>f.modules.has(S(y,s.file)))).map(s=>s.id),p=de(e.id);k(p,P(Ee(t,i,j)));const d=u.of(e.place);if(d){d.tree.add(p);for(const s of f.files)d.tree.add(`${b.build}${s}`);for(const s of i.media)d.tree.add(`${b.media}${s}`),d.tree.add(`${b.matte}${s}`),d.files.add(s)}}for(const[e,t]of R)for(const o of t)u.of(e)?.tree.add(o);for(const e of c.docs)for(const t of e.shows)u.of(e.place)?.files.add(t);for(const e of c.sheets)for(const t of e.files)u.of(e.place)?.files.add(t);const J=$.preview===!1?void 0:$.preview??(e=>he(n,e));if(J)for(const e of v){const t=await J(e).catch(()=>{});if(t===void 0)continue;const o=le(e.id);k(o,Buffer.from(JSON.stringify(t)),"application/json"),u.of(e.id)?.tree.add(o)}return{revision:X,files:[...g.values()],reach:u.done(new Set(g.keys())),routes:l.routes.loads()}}function Me(n,$){const r=new Map(n.map(g=>[g.id,g])),l=new Set,w=g=>{for(const m of r.get(g)?.uses??[])m.type===ye.live&&!l.has(m.item)&&(l.add(m.item),w(m.item))};return w($),l}
2
+ import{readFile as ne,readdir as ie,realpath as re,stat as ae}from"node:fs/promises";import{setTimeout as ce}from"node:timers/promises";import{join as P,relative as de,sep as fe}from"node:path";import{openPage as le}from"@allyhub/browser";import{KeyedStore as ue}from"@allyhub/project";import{NEVER_CANCELLED as pe}from"@allyhub/extension-api";import{COMPONENT_STILLS_MAX as V,KindSnapshotSchema as me,RpcError as X,SNAPSHOT_TREE as b,pieceSourcePath as he,snapshotAnswerPath as T,snapshotPreviewPath as we,stillPath as Q,stillsIndexKey as ge,stillsIndexPath as ye}from"@allyhub/protocol";import{runtimeFiles as be}from"@allyhub/stage-page";import{itemPreview as ke}from"./card.js";import{offlinePage as $e}from"./offline-page.js";import{kindContext as Se,kindItem as Ee}from"./kinds.js";import{USE_FORMS as Pe,mediaTypeOf as F}from"@allyhub/formats";import{Reach as ve,pieceBundle as Me,pieceNames as je,reachedCheck as Ie,reachedSource as Oe}from"./reach.js";import{matteFile as Te}from"./tree.js";const Ne="assets/";export const PAGE_RECORDING={width:1440,height:900,timeout:3e4,settle:1500};const N="https://tree.invalid/";function _(i){return typeof i=="string"?i.startsWith(N)?i.slice(N.length):i:Array.isArray(i)?i.map(_):i!==null&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([S,a])=>[S,_(a)])):i}const j=i=>new TextEncoder().encode(JSON.stringify(i));async function Y(i){return(await ie(i,{recursive:!0,withFileTypes:!0}).catch(()=>[])).filter(a=>a.isFile()).map(a=>de(i,P(a.parentPath,a.name)).split(fe).join("/"))}const xe=i=>ae(i).then(S=>S.isFile(),()=>!1);export async function recordTree(i,S={}){const{project:a}=i,{live:u,root:y}=a;await a.watcher.settled();const k=new Map,g=(e,t,o=F(e))=>{k.set(e,{path:e,type:o,file:t})},L=(e,t)=>{k.set(e,{path:e,type:F(e),file:t,immutable:!0})},v=(e,t,o=F(e))=>{k.set(e,{path:e,type:o,bytes:t})},W=async(e,t)=>{for(const o of await Y(t))g(`${e}${o}`,P(t,o))},Z=u.revision,d=await u.prepared(),x=new Map;if(i.ui!==void 0)for(const e of await Y(i.ui))(e.startsWith(Ne)?L:g)(`${b.editor}${e}`,P(i.ui,e));for(const[e,t]of await be())g(`${b.runtime}${e}`,t);const I=async(e,t)=>{let o;try{o={result:_(await a.tool(e,t,{tree:N}))}}catch(n){o={error:n instanceof X?{code:n.code,message:n.message}:{code:-32603,message:n instanceof Error?n.message:""}}}const r=T(e,t);v(r,j(o));const f=t.item;return typeof f=="string"&&x.set(f,[...x.get(f)??[],r]),o},ee=Se(y,e=>a.hasTool(e),async(e,t)=>{const o=await I(e,t);if(o.error)throw new X(o.error.code,o.error.message);return o.result}),te=async(e,t,o)=>{const r=new Map;for(const s of o)r.set(ge(s),s);if(r.size===0)return;const f=ue.of(y,"stills"),n={stills:{}},$=p.of(e),m=[...r];for(let s=0;s<m.length;s+=V){const l=m.slice(s,s+V);(await a.tool("components/stills",{item:e,...t===""?{}:{version:t},components:l.map(([,w])=>w)},{tree:N}).catch(()=>{}))?.stills.forEach((w,E)=>{const H=l[E]?.[0];!w||H===void 0||(n.stills[H]=w.key,g(Q(w.key),f.path(`${w.key}.webp`),"image/webp"),$?.tree.add(Q(w.key)))})}const c=ye(e,t);v(c,j(n),"application/json"),$?.tree.add(c)},B=(await I("project/items",{})).result,O=B?.items??[],R=O.filter(e=>e.kind!==void 0),C=O.filter(e=>e.kind===void 0&&e.kindInfo?.share===!0),oe=new Map(d.items.map(e=>[e.id,e.files])),p=new ve([...R.map(e=>({...e,files:oe.get(e.id)??e.files})),...C],d.files,(d.bundle?.beside??[]).map(e=>`${b.build}${e}`)),M=a.checker?.state,D=M===void 0||M.status==="waiting"||M.status==="running"?{status:"off",revision:u.revision,problems:M?.problems??[],facts:M?.facts??[]}:M;v(T("check/results",{}),j({result:D}));for(const e of p.items){const t=p.of(e),o=new Set(d.pieces.filter(n=>n.place===e).map(n=>n.id)),r=O.find(n=>n.id===e)?.entry,f=n=>n===r||p.itemsOf(n).includes(e);t?.own.push({path:T("project/items",{}),type:"application/json",bytes:j({result:{...B,items:O.filter(n=>n.id===e)}})},{path:T("check/results",{}),type:"application/json",bytes:j({result:Ie(D,o,f)})})}for(const e of d.bundle?.chunks.files??[])L(`${b.build}${e}`,P(u.pieceDir,e));for(const e of d.bundle?.beside??[])await W(`${b.build}${e}`,P(u.pieceDir,e));const q=new Set(Object.keys(d.media));for(const e of Object.keys(d.media)){const t=Te(y,d.media[e]);t!==void 0&&await xe(t)&&g(`${b.matte}${e}`,t,"video/mp4")}const A=new Map,G=new Map,se=a.extensions?.fileEditors()??[];for(const e of C)se.some(t=>t.id===e.kindInfo?.editor&&t.page)&&(A.set(e.id,{}),G.set(e.id,e.entry));const J=new Map,K=e=>({file:(t,o,r)=>{g(`${e}${t}`,o,r)},folder:(t,o)=>W(`${e}${t}`,o),bytes:(t,o,r)=>{v(`${e}${t}`,o,r)},media:t=>{q.add(t)}});for(const e of R){const t=await a.extensions?.kindProvider(e.kind);if(!t?.snapshot)continue;const o=await Promise.resolve(t.snapshot(Ee(e),ee,pe)).catch(()=>{}),r=me.safeParse(o??{});if(!r.success)continue;const{stills:f,shows:n,routes:$,page:m}=r.data;m&&A.set(e.id,{...m.folder===void 0?{}:{folder:m.folder},...m.file===void 0?{}:{file:m.file}}),n&&J.set(e.id,{media:new Set(n.media),data:new Set(n.data)});for(const c of f??[])await I("components/stage",{item:e.id,version:c.version}),c.version===""&&await I("components/stage",{item:e.id}),await te(e.id,c.version,c.components);for(const[c,s]of Object.entries($??{})){const l=await u.routes.route(c).catch(()=>{});if(l?.route.recordItem)for(const h of s)await l.route.recordItem(h,K(c),l.context).catch(()=>{})}}for(const e of q)g(`${b.media}${e}`,P(y,e));for(const[e,t]of A){const o=await a.tool("items/page",{item:e,...t}).catch(()=>{});if(!o)continue;const r=new URL(o.url).origin,f=G.get(e),n=await le(await u.browser(),{width:PAGE_RECORDING.width,height:PAGE_RECORDING.height,allow:s=>s===r||s.startsWith(`${r}/`)||f!==void 0&&s.startsWith("https://")}).catch(()=>{});if(!n)continue;const $=[],m=[];try{if(f!==void 0){const s=n.session,l=new Map;s.on("Network.responseReceived",h=>{h.response.url.startsWith("https://")&&h.response.status===200&&l.set(h.requestId,{url:h.response.url,mime:h.response.mimeType})}),s.on("Network.loadingFinished",h=>{const w=l.get(h.requestId);w&&m.push(s.send("Network.getResponseBody",{requestId:h.requestId}).then(E=>{$.push({...w,body:E.base64Encoded?Buffer.from(E.body,"base64"):new TextEncoder().encode(E.body)})},E=>{if(!(E instanceof Error))throw E}))}),await s.send("Network.enable",{})}await n.goto(o.url,{timeoutMs:PAGE_RECORDING.timeout}),await n.evaluate("document.fonts.ready.then(() => true)",{timeoutMs:PAGE_RECORDING.timeout}),await ce(PAGE_RECORDING.settle)}catch{}finally{await Promise.allSettled(m),await n.close()}if(f===void 0||$.length===0)continue;const c=await ne(P(y,f),"utf8").catch(()=>{});if(c!==void 0)for(const s of $e(f,c,$)){const l=`${b.pages}${s.path}`;v(l,s.bytes,s.type),p.of(e)?.tree.add(l)}}for(const e of p.items){const t=p.of(e);if(t)for(const o of a.inputs.of(e))if(o===""||o.endsWith("/"))for(const r of d.files)r.startsWith(o)&&t.files.add(r);else d.files.includes(o)&&t.files.add(o)}for(const e of u.routes.specs.keys()){const t=await u.routes.route(e).catch(()=>{});t?.route.record&&await t.route.record(K(e),t.context).catch(()=>{})}const U=[y,await re(y).catch(()=>y)];for(const e of d.pieces){const t=await u.source(e.id).catch(()=>{});if(!t)continue;const o=[e,...d.pieces.filter(s=>Re(d.items,e.place).has(s.place))],r=o.map(s=>({p:s,bundle:Me(d.bundle?.chunks,s.id)})),f={files:new Set(r.flatMap(s=>[...s.bundle.files])),modules:new Set(r.flatMap(s=>[...s.bundle.modules]))},n={media:new Set,data:new Set};for(const{p:s,bundle:l}of r){const h=je({prepared:d,piece:s,reach:p,modules:l.modules,roots:U,reads:a.checker?.reads.get(s.id),shows:J.get(s.place)});for(const w of h.media)n.media.add(w);for(const w of h.data)n.data.add(w)}const $=d.pieces.filter(s=>!o.includes(s)&&!U.some(l=>f.modules.has(P(l,s.file)))).map(s=>s.id),m=he(e.id);v(m,j(Oe(t,n,$)));const c=p.of(e.place);if(c){c.tree.add(m);for(const s of f.files)c.tree.add(`${b.build}${s}`);for(const s of n.media)c.tree.add(`${b.media}${s}`),c.tree.add(`${b.matte}${s}`),c.files.add(s)}}for(const[e,t]of x)for(const o of t)p.of(e)?.tree.add(o);for(const e of d.docs)for(const t of e.shows)p.of(e.place)?.files.add(t);for(const e of d.sheets)for(const t of e.files)p.of(e.place)?.files.add(t);const z=S.preview===!1?void 0:S.preview??(e=>ke(i,e));if(z)for(const e of R){const t=await z(e).catch(()=>{});if(t===void 0)continue;const o=we(e.id);v(o,Buffer.from(JSON.stringify(t)),"application/json"),p.of(e.id)?.tree.add(o)}return{revision:Z,files:[...k.values()],reach:p.done(new Set(k.keys())),routes:u.routes.loads()}}function Re(i,S){const a=new Map(i.map(k=>[k.id,k])),u=new Set,y=k=>{for(const g of a.get(k)?.uses??[])g.type===Pe.live&&!u.has(g.item)&&(u.add(g.item),y(g.item))};return y(S),u}
@@ -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 O}from"node:crypto";import{access as y,stat as C}from"node:fs/promises";import{basename as L,join as g,posix as E}from"node:path";import{pathToFileURL as M}from"node:url";import{inTime as T,listWork as N,projectItems as h,stageId as _}from"@allyhub/build";import{NEVER_CANCELLED as D}from"@allyhub/extension-api";import{OUT_DIR as H,fileEditorIn as W,isListedFile as F,unscanned as U,WORK_FILE as A}from"@allyhub/formats";import{OpenedVersion as K,componentStills as V,itemDigests as q,keyedStills as G,parseCombo as z}from"@allyhub/project";import{runtimeFile as B,stageFiles as J}from"@allyhub/stage-page";import{RPC_ERROR as c,RpcError as f,SNAPSHOT_TREE as j,TREE_PAGES as R,listedFileEditor as b,listedKind as $,stillPath as Q}from"@allyhub/protocol";import{comboKey as X,componentRefText as Y}from"@allyhub/piece";import{providedPreview as Z}from"./card.js";import{kindItem as ee}from"./kinds.js";import{rpcErrorOf as x}from"./live.js";import{forwarded as te}from"./ports.js";const oe=o=>O("sha256").update(o).digest("base64url").slice(0,16);async function S(o,t,n){const e=t.replace(/^\.\//u,""),r=(await h(o.live.root,o.live.kinds)).items.find(l=>l.id===e||l.entry===e);if(!r)throw new f(c.notFound,`There is no item ${t} in the project's list.`);const i=(n.folder??"").replace(/\/+$/u,""),s=n.file??r.entry;if(i!==""&&!s.startsWith(`${i}/`))throw new f(c.invalid,`${s} is not in the folder ${i} the page is served from.`);return o.pages.url(r.id,i,s)}const v=(o,t)=>{const n=o.tree();if(n===void 0)throw new f(c.unavailable,"This server serves no pages: only allyhub dev's does.");return new URL(t,n).href},I=(o,t,n)=>({url:v(o,`${t}?${n.toString()}`),probe:v(o,R.probe)});async function ne(o,t,n){if(t.title!==void 0)return t.title;const e=await o.extensions?.kindProvider(t.kind);if(!e?.title)return(await n()).get(t.id);try{const r=await e.title(ee(t),o.kindContext,D);return typeof r=="string"?r:void 0}catch{return}}export function contributedTools(o){const t=new Map;for(const n of o)for(const e of n.projectTools??[])t.has(e.name)||t.set(e.name,e);return t}const k=new Map;export async function contributedTool(o){let t=k.get(o.module);t||(t=import(M(o.module).href).then(e=>{if(typeof e.default!="object"||e.default===null)throw new Error(`${o.extension}'s project tools (${o.module}) have no default export.`);return e.default}),k.set(o.module,t),t.catch(()=>{k.get(o.module)===t&&k.delete(o.module)}));const n=(await t)[o.name];if(!n)throw new Error(`${o.extension} contributes the project tool "${o.name}" but its module (${o.module}) has none of that name.`);return n}export function projectToolContext(o){const{live:t}=o,n=new Map;return{root:t.root,kinds:t.kinds,prepared:()=>t.prepared(),target:(e,r)=>t.target(e,r),itemCode:e=>t.itemCode(e),items:async()=>(await h(t.root,t.kinds)).items,async version(e,r,i,s){try{return await t.withSession(async l=>{const a=await K.open({root:t.root,item:e,...r===void 0?{}:{combos:[z(r)]},purpose:i,session:l});try{return await s(a)}finally{await a.close()}})}catch(l){throw x(l)}},async componentStills(e,r,i){try{const s=await t.prepared(),{gpu:l}=await t.browser();return await G(r,{prepared:s,item:e,combo:i,gpu:l,withSession:a=>t.withSession(a)})}catch(s){throw x(s)}},served:e=>v(o,e),page:(e,r)=>I(o,e,r),buildDir:t.pieceDir,stageStyles:()=>J().fontCss.flatMap(e=>{const r=B(e);return r===void 0?[]:[{file:r,url:v(o,`${j.runtime}${e}`)}]}),kept(e,r){return n.has(e)||n.set(e,r()),n.get(e)},held(e,r){return o.held.has(e)||o.held.set(e,r()),o.held.get(e)},jobs:o.services.jobs,cloud:o.services.cloud,env:o.services.env??process.env,forward:e=>te(o.services.ports,e),pageOf:(e,r={})=>S(o,e,r),recordInputs:(e,r,i)=>{o.inputs.set(e,r,i)}}}export function toolHandlers(o){const{live:t}=o;return{"project/items":async()=>{const n=await h(t.root,t.kinds,void 0,o.extensions?.fileEditors()??[]);let e;const r=()=>e??=(async()=>{const a=await t.prepared().catch(()=>t.latest()),p=new Map;for(const d of a?.pieces??[]){const u=typeof d.title=="string"?d.title:void 0;u&&p.set(d.place,u)}return p})(),i=new Map((t.latest()?.items??[]).map(a=>[a.id,a.files])),s=o.extensions?.fileEditors()??[];return{items:await Promise.all(n.listed.map(async a=>{const p={id:a.id,dir:a.dir,entry:a.entry,...a.title===void 0?{}:{title:a.title},groups:a.groups};if(F(a)){const w=s.find(P=>P.id===a.editor);return{...p,...w?{kindInfo:b(w)}:{}}}const d=await ne(o,a,r),u=t.kinds.find(w=>w.id===a.kind),m=i.get(a.id);return{...p,kind:a.kind,...d?{title:d}:{},...m?{files:m}:{},...u?{kindInfo:$(u)}:{}}})),kinds:t.kinds.map(a=>({id:a.id,...$(a)})),name:L(t.root),scope:oe(t.root),revision:t.revision}},"project/file":async({path:n})=>{const e=n.replace(/^\.\//u,""),r=o.extensions?.fileEditors()??[],s=(await h(t.root,t.kinds,void 0,r)).listed.find(d=>d.entry===e||d.id===e);if(s){const d={id:s.id,dir:s.dir,entry:s.entry,...s.title===void 0?{}:{title:s.title},groups:s.groups};if(F(s)){const m=r.find(w=>w.id===s.editor);return{item:{...d,...m?{kindInfo:b(m)}:{}}}}const u=t.kinds.find(m=>m.id===s.kind);return{item:{...d,kind:s.kind,...u?{kindInfo:$(u)}:{}}}}const l=!U(e)&&await C(g(t.root,e)).then(d=>d.isFile(),()=>!1),a=l?W(r,e):void 0;if(!a)throw new f(c.notFound,l?`No editor opens ${e} by its name.`:`The project has no file ${e}.`);const p=E.dirname(e);return{item:{id:e,dir:p==="."?"":p,entry:e,groups:[],kindInfo:b(a)}}},"items/preview":async({item:n})=>{const e=n.replace(/^\.\//u,""),r=(await h(t.root,t.kinds)).items.find(s=>s.id===e||s.entry===e);if(!r)throw new f(c.notFound,`There is no item ${n} in the project's list.`);const i=await Z(o.extensions,r,o.kindContext);return i===void 0?{}:{preview:i}},"items/page":async({item:n,folder:e,file:r})=>({url:await S(o,n,{folder:e,file:r})}),"work/add":async({kind:n,file:e,title:r})=>{if(!t.kinds.some(i=>i.id===n))throw new f(c.invalid,`No extension here contributes the kind ${n}.`);return await y(g(t.root,e)).catch(()=>{throw new f(c.notFound,`There is no file ${e} to list in ${A}.`)}),await N(t.root,{kind:n,file:e,...r===void 0?{}:{title:r}}),{}},"components/list":async({item:n})=>{const e=await t.prepared(),r=e.items.find(i=>i.id===n||i.entry===n)?.dir??n;return{components:e.components.map(i=>{const s=E.relative(r,i.file);return{of:Y({path:s.startsWith(".")?s:`./${s}`,name:i.export}),name:i.name,...i.label===void 0?{}:{label:i.label}}})}},"components/stage":async({item:n,version:e})=>{const{prepared:r,host:i,combo:s}=await t.componentHost(n,e);if(!("components"in i)&&T(i,r.kinds))throw new f(c.notFound,`${n} has no components to draw alone: a deck's or a doc's are.`);const{code:l}=await q(r,i),a=new URLSearchParams({piece:_(i),combo:X(s),mode:"component",code:l.slice(0,16)});return I(o,R.stage,a)},"components/stills":async({item:n,version:e,components:r})=>{v(o,j.stills);try{const{prepared:i,host:s,combo:l}=await t.componentHost(n,e);if(!("components"in s)&&T(s,i.kinds))throw new f(c.notFound,`${n} has no components to draw alone: a deck's or a doc's are.`);const{gpu:a}=await t.browser();return{stills:(await V(r,{prepared:i,item:s,combo:l,gpu:a,withSession:d=>t.withSession(d)})).map(({key:d})=>({key:d,url:v(o,Q(d))}))}}catch(i){throw x(i)}},"check/results":()=>Promise.resolve(o.checker?.state??{status:"off",revision:t.revision,problems:[],facts:[]}),"check/run":()=>{if(!o.checker)throw new f(c.unavailable,"This server runs no check.");return o.checker.schedule(!0),Promise.resolve({})},"export/start":async({item:n,versions:e,types:r,options:i})=>{const{items:s}=await h(t.root,t.kinds);if(!s.some(l=>l.id===n))throw new f(c.notFound,`There is no item ${n}.`);return{job:o.exports.start(n,e??[],r??[],i)}},"export/cancel":({job:n})=>{if(!o.exports.cancel(n))throw new f(c.notFound,`No export ${n} is under way.`);return Promise.resolve({})},"export/list":()=>Promise.resolve({jobs:o.exports.list(),reveal:o.reveal!==void 0}),"export/reveal":async({path:n})=>{if(!o.reveal)throw new f(c.unavailable,"This server is not on the person's computer: download the file.");if(!n.startsWith(`${H}/`))throw new f(c.notFound,`${n} is no exported file.`);const e=o.exports.savedOf(n),r=e!==void 0&&await y(e).then(()=>!0,()=>!1)?e:g(t.root,n);return await y(r).catch(()=>{throw new f(c.notFound,`There is no file ${n}.`)}),await o.reveal(r),{}}}}
2
+ import{createHash as M}from"node:crypto";import{access as y,stat as F}from"node:fs/promises";import{basename as N,join as b,posix as E}from"node:path";import{pathToFileURL as _}from"node:url";import{inTime as T,listWork as D,projectItems as h,stageId as H}from"@allyhub/build";import{NEVER_CANCELLED as W}from"@allyhub/extension-api";import{OUT_DIR as U,fileEditorIn as j,isListedFile as R,listedFileIdOf as A,unscanned as S,WORK_FILE as K}from"@allyhub/formats";import{OpenedVersion as V,componentStills as q,itemDigests as G,keyedStills as z,parseCombo as B}from"@allyhub/project";import{runtimeFile as J,stageFiles as Q}from"@allyhub/stage-page";import{RPC_ERROR as f,RpcError as c,SNAPSHOT_TREE as I,TREE_PAGES as P,listedFileEditor as g,listedKind as $,stillPath as X}from"@allyhub/protocol";import{comboKey as Y,componentRefText as Z}from"@allyhub/piece";import{providedPreview as ee}from"./card.js";import{kindItem as te}from"./kinds.js";import{rpcErrorOf as x}from"./live.js";import{pathProblem as ne}from"./paths.js";import{forwarded as oe}from"./ports.js";import{inside as ie}from"./tree.js";const re=n=>M("sha256").update(n).digest("base64url").slice(0,16);async function O(n,t,o){const e=t.replace(/^\.\//u,""),i=(await h(n.live.root,n.live.kinds)).items.find(u=>u.id===e||u.entry===e),s=i?void 0:await se(n,e),r=i?.id??s;if(r===void 0)throw new c(f.notFound,`There is no item ${t} in the project's list, nor a file of the project an editor opens.`);const d=(o.folder??"").replace(/\/+$/u,""),a=o.file??i?.entry??r;if(d!==""&&!a.startsWith(`${d}/`))throw new c(f.invalid,`${a} is not in the folder ${d} the page is served from.`);return n.pages.url(r,d,a,{network:s!==void 0})}async function se(n,t){if(S(t)||ne(t)!==void 0||!j(n.extensions?.fileEditors()??[],t))return;const o=ie(n.live.root,t);return o&&await F(o).then(i=>i.isFile(),()=>!1)?A(t):void 0}const v=(n,t)=>{const o=n.tree();if(o===void 0)throw new c(f.unavailable,"This server serves no pages: only allyhub dev's does.");return new URL(t,o).href},C=(n,t,o)=>({url:v(n,`${t}?${o.toString()}`),probe:v(n,P.probe)});async function ae(n,t,o){if(t.title!==void 0)return t.title;const e=await n.extensions?.kindProvider(t.kind);if(!e?.title)return(await o()).get(t.id);try{const i=await e.title(te(t),n.kindContext,W);return typeof i=="string"?i:void 0}catch{return}}export function contributedTools(n,t=[]){const o=new Map;for(const e of n)for(const i of e.projectTools??[])o.has(i.name)||o.set(i.name,i);for(const e of t)o.has(e.name)||o.set(e.name,e);return o}const k=new Map;export async function contributedTool(n){let t=k.get(n.module);t||(t=import(_(n.module).href).then(e=>{if(typeof e.default!="object"||e.default===null)throw new Error(`${n.extension}'s project tools (${n.module}) have no default export.`);return e.default}),k.set(n.module,t),t.catch(()=>{k.get(n.module)===t&&k.delete(n.module)}));const o=(await t)[n.name];if(!o)throw new Error(`${n.extension} contributes the project tool "${n.name}" but its module (${n.module}) has none of that name.`);return o}export function projectToolContext(n){const{live:t}=n,o=new Map;return{root:t.root,kinds:t.kinds,prepared:()=>t.prepared(),target:(e,i)=>t.target(e,i),itemCode:e=>t.itemCode(e),items:async()=>(await h(t.root,t.kinds)).items,async version(e,i,s,r){try{return await t.withSession(async d=>{const a=await V.open({root:t.root,item:e,...i===void 0?{}:{combos:[B(i)]},purpose:s,session:d});try{return await r(a)}finally{await a.close()}})}catch(d){throw x(d)}},async componentStills(e,i,s){try{const r=await t.prepared(),{gpu:d}=await t.browser();return await z(i,{prepared:r,item:e,combo:s,gpu:d,withSession:a=>t.withSession(a)})}catch(r){throw x(r)}},served:e=>v(n,e),page:(e,i)=>C(n,e,i),buildDir:t.pieceDir,stageStyles:()=>Q().fontCss.flatMap(e=>{const i=J(e);return i===void 0?[]:[{file:i,url:v(n,`${I.runtime}${e}`)}]}),kept(e,i){return o.has(e)||o.set(e,i()),o.get(e)},held(e,i){return n.held.has(e)||n.held.set(e,i()),n.held.get(e)},jobs:n.services.jobs,cloud:n.services.cloud,env:n.services.env??process.env,forward:e=>oe(n.services.ports,e),pageOf:(e,i={})=>O(n,e,i),recordInputs:(e,i,s)=>{n.inputs.set(e,i,s)}}}export function toolHandlers(n){const{live:t}=n;return{"project/items":async()=>{const o=await h(t.root,t.kinds,void 0,n.extensions?.fileEditors()??[]);let e;const i=()=>e??=(async()=>{const a=await t.prepared().catch(()=>t.latest()),u=new Map;for(const l of a?.pieces??[]){const p=typeof l.title=="string"?l.title:void 0;p&&u.set(l.place,p)}return u})(),s=new Map((t.latest()?.items??[]).map(a=>[a.id,a.files])),r=n.extensions?.fileEditors()??[];return{items:await Promise.all(o.listed.map(async a=>{const u={id:a.id,dir:a.dir,entry:a.entry,...a.title===void 0?{}:{title:a.title},groups:a.groups};if(R(a)){const w=r.find(L=>L.id===a.editor);return{...u,...w?{kindInfo:g(w)}:{}}}const l=await ae(n,a,i),p=t.kinds.find(w=>w.id===a.kind),m=s.get(a.id);return{...u,kind:a.kind,...l?{title:l}:{},...m?{files:m}:{},...p?{kindInfo:$(p)}:{}}})),kinds:t.kinds.map(a=>({id:a.id,...$(a)})),name:N(t.root),scope:re(t.root),revision:t.revision}},"project/file":async({path:o})=>{const e=o.replace(/^\.\//u,""),i=n.extensions?.fileEditors()??[],r=(await h(t.root,t.kinds,void 0,i)).listed.find(l=>l.entry===e||l.id===e);if(r){const l={id:r.id,dir:r.dir,entry:r.entry,...r.title===void 0?{}:{title:r.title},groups:r.groups};if(R(r)){const m=i.find(w=>w.id===r.editor);return{item:{...l,...m?{kindInfo:g(m)}:{}}}}const p=t.kinds.find(m=>m.id===r.kind);return{item:{...l,kind:r.kind,...p?{kindInfo:$(p)}:{}}}}const d=!S(e)&&await F(b(t.root,e)).then(l=>l.isFile(),()=>!1),a=d?j(i,e):void 0;if(!a)throw new c(f.notFound,d?`No editor opens ${e} by its name.`:`The project has no file ${e}.`);const u=E.dirname(e);return{item:{id:e,dir:u==="."?"":u,entry:e,groups:[],kindInfo:g(a)}}},"items/preview":async({item:o})=>{const e=o.replace(/^\.\//u,""),i=(await h(t.root,t.kinds)).items.find(r=>r.id===e||r.entry===e);if(!i)throw new c(f.notFound,`There is no item ${o} in the project's list.`);const s=await ee(n.extensions,i,n.kindContext);return s===void 0?{}:{preview:s}},"items/page":async({item:o,folder:e,file:i})=>({url:await O(n,o,{folder:e,file:i})}),"work/add":async({kind:o,file:e,title:i})=>{if(!t.kinds.some(s=>s.id===o))throw new c(f.invalid,`No extension here contributes the kind ${o}.`);return await y(b(t.root,e)).catch(()=>{throw new c(f.notFound,`There is no file ${e} to list in ${K}.`)}),await D(t.root,{kind:o,file:e,...i===void 0?{}:{title:i}}),{}},"components/list":async({item:o})=>{const e=await t.prepared(),i=e.items.find(s=>s.id===o||s.entry===o)?.dir??o;return{components:e.components.map(s=>{const r=E.relative(i,s.file);return{of:Z({path:r.startsWith(".")?r:`./${r}`,name:s.export}),name:s.name,...s.label===void 0?{}:{label:s.label}}})}},"components/stage":async({item:o,version:e})=>{const{prepared:i,host:s,combo:r}=await t.componentHost(o,e);if(!("components"in s)&&T(s,i.kinds))throw new c(f.notFound,`${o} has no components to draw alone: a deck's or a doc's are.`);const{code:d}=await G(i,s),a=new URLSearchParams({piece:H(s),combo:Y(r),mode:"component",code:d.slice(0,16)});return C(n,P.stage,a)},"components/stills":async({item:o,version:e,components:i})=>{v(n,I.stills);try{const{prepared:s,host:r,combo:d}=await t.componentHost(o,e);if(!("components"in r)&&T(r,s.kinds))throw new c(f.notFound,`${o} has no components to draw alone: a deck's or a doc's are.`);const{gpu:a}=await t.browser();return{stills:(await q(i,{prepared:s,item:r,combo:d,gpu:a,withSession:l=>t.withSession(l)})).map(({key:l})=>({key:l,url:v(n,X(l))}))}}catch(s){throw x(s)}},"check/results":()=>Promise.resolve(n.checker?.state??{status:"off",revision:t.revision,problems:[],facts:[]}),"check/run":()=>{if(!n.checker)throw new c(f.unavailable,"This server runs no check.");return n.checker.schedule(!0),Promise.resolve({})},"export/start":async({item:o,versions:e,types:i,options:s})=>{const{items:r}=await h(t.root,t.kinds);if(!r.some(d=>d.id===o))throw new c(f.notFound,`There is no item ${o}.`);return{job:n.exports.start(o,e??[],i??[],s)}},"export/cancel":({job:o})=>{if(!n.exports.cancel(o))throw new c(f.notFound,`No export ${o} is under way.`);return Promise.resolve({})},"export/list":()=>Promise.resolve({jobs:n.exports.list(),reveal:n.reveal!==void 0}),"export/reveal":async({path:o})=>{if(!n.reveal)throw new c(f.unavailable,"This server is not on the person's computer: download the file.");if(!o.startsWith(`${U}/`))throw new c(f.notFound,`${o} is no exported file.`);const e=n.exports.savedOf(o),i=e!==void 0&&await y(e).then(()=>!0,()=>!1)?e:b(t.root,o);return await y(i).catch(()=>{throw new c(f.notFound,`There is no file ${o}.`)}),await n.reveal(i),{}}}}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/dev-server",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/diagnostics",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/doc",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/doc-extension",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./cli": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/doc-print",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/export",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/extension-api",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {