allyhub 0.20.0 → 0.22.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 (323) hide show
  1. package/dist/commands/cloud-tools.js +5 -5
  2. package/dist/commands/export.js +1 -1
  3. package/dist/commands/frames.js +8 -8
  4. package/dist/commands/index.js +1 -1
  5. package/dist/commands/run.js +2 -0
  6. package/dist/commands.json +1 -1
  7. package/dist/help.js +3 -3
  8. package/dist/main.js +4 -4
  9. package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
  10. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  11. package/dist/node_modules/@allyhub/blocks/dist/elements.js +1 -1
  12. package/dist/node_modules/@allyhub/blocks/dist/layout.js +1 -1
  13. package/dist/node_modules/@allyhub/blocks/dist/palette.js +1 -1
  14. package/dist/node_modules/@allyhub/blocks/dist/resolve.js +1 -1
  15. package/dist/node_modules/@allyhub/blocks/package.json +1 -1
  16. package/dist/node_modules/@allyhub/browser/package.json +1 -1
  17. package/dist/node_modules/@allyhub/build/dist/migrate.js +1 -1
  18. package/dist/node_modules/@allyhub/build/dist/prepare.js +3 -3
  19. package/dist/node_modules/@allyhub/build/dist/project-root.js +1 -1
  20. package/dist/node_modules/@allyhub/build/dist/work.js +3 -3
  21. package/dist/node_modules/@allyhub/build/package.json +1 -1
  22. package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
  23. package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
  24. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  25. package/dist/node_modules/@allyhub/check/package.json +1 -1
  26. package/dist/node_modules/@allyhub/cloud/dist/call.js +2 -2
  27. package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
  28. package/dist/node_modules/@allyhub/cloud/package.json +1 -1
  29. package/dist/node_modules/@allyhub/components/package.json +1 -1
  30. package/dist/node_modules/@allyhub/dev-server/dist/index.js +1 -1
  31. package/dist/node_modules/@allyhub/dev-server/dist/record.js +2 -1
  32. package/dist/node_modules/@allyhub/dev-server/dist/validate.js +2 -2
  33. package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
  34. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  35. package/dist/node_modules/@allyhub/doc/dist/block-shapes.js +2 -0
  36. package/dist/node_modules/@allyhub/doc/dist/blocks.js +1 -1
  37. package/dist/node_modules/@allyhub/doc/dist/docx.js +5 -5
  38. package/dist/node_modules/@allyhub/doc/dist/shapes.js +2 -2
  39. package/dist/node_modules/@allyhub/doc/package.json +1 -1
  40. package/dist/node_modules/@allyhub/doc-extension/dist/cli/import.js +1 -1
  41. package/dist/node_modules/@allyhub/doc-extension/dist/export.js +1 -1
  42. package/dist/node_modules/@allyhub/doc-extension/package.json +1 -1
  43. package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
  44. package/dist/node_modules/@allyhub/export/package.json +1 -1
  45. package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
  46. package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
  47. package/dist/node_modules/@allyhub/formats/dist/data/deck-code.d.ts +3 -3
  48. package/dist/node_modules/@allyhub/formats/dist/data/page-data.d.ts +9 -1
  49. package/dist/node_modules/@allyhub/formats/dist/data/page-data.js +1 -1
  50. package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +151 -151
  51. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +173 -173
  52. package/dist/node_modules/@allyhub/formats/dist/data/work.d.ts +1 -2
  53. package/dist/node_modules/@allyhub/formats/dist/data/work.js +1 -1
  54. package/dist/node_modules/@allyhub/formats/dist/index.d.ts +1 -1
  55. package/dist/node_modules/@allyhub/formats/dist/index.js +1 -1
  56. package/dist/node_modules/@allyhub/formats/dist/layout.d.ts +2 -0
  57. package/dist/node_modules/@allyhub/formats/dist/layout.js +1 -1
  58. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +106 -101
  59. package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
  60. package/dist/node_modules/@allyhub/formats/dist/tolerant.d.ts +26 -1
  61. package/dist/node_modules/@allyhub/formats/dist/tolerant.js +1 -1
  62. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  63. package/dist/node_modules/@allyhub/html-extension/package.json +1 -1
  64. package/dist/node_modules/@allyhub/i18n/package.json +1 -1
  65. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  66. package/dist/node_modules/@allyhub/image-extension/package.json +1 -1
  67. package/dist/node_modules/@allyhub/image-extension/skills/allyhub/references/images.md +1 -1
  68. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  69. package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
  70. package/dist/node_modules/@allyhub/image-render/package.json +1 -1
  71. package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
  72. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  73. package/dist/node_modules/@allyhub/jobs/package.json +1 -1
  74. package/dist/node_modules/@allyhub/linkedin-extension/package.json +1 -1
  75. package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
  76. package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
  77. package/dist/node_modules/@allyhub/linkedin-view/src/style.css +1 -1
  78. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  79. package/dist/node_modules/@allyhub/media/package.json +1 -1
  80. package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
  81. package/dist/node_modules/@allyhub/model/package.json +1 -1
  82. package/dist/node_modules/@allyhub/office-extension/package.json +1 -1
  83. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  84. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  85. package/dist/node_modules/@allyhub/project/package.json +1 -1
  86. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  87. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  88. package/dist/node_modules/@allyhub/registry/package.json +1 -1
  89. package/dist/node_modules/@allyhub/render/package.json +1 -1
  90. package/dist/node_modules/@allyhub/report-extension/LICENSE +241 -0
  91. package/dist/node_modules/@allyhub/report-extension/dist/build.js +3 -0
  92. package/dist/node_modules/@allyhub/report-extension/dist/check.js +37 -0
  93. package/dist/node_modules/@allyhub/report-extension/dist/cli/index.js +4 -0
  94. package/dist/node_modules/@allyhub/report-extension/dist/export.js +2 -0
  95. package/dist/node_modules/@allyhub/report-extension/dist/inline.js +58 -0
  96. package/dist/node_modules/@allyhub/report-extension/dist/page.js +23 -0
  97. package/dist/node_modules/@allyhub/report-extension/dist/project-tools.js +33 -0
  98. package/dist/node_modules/@allyhub/report-extension/dist/styles.js +2 -0
  99. package/dist/node_modules/@allyhub/report-extension/dist/theme.js +2 -0
  100. package/dist/node_modules/@allyhub/report-extension/dist/tools.js +2 -0
  101. package/dist/node_modules/@allyhub/report-extension/dist/workspace.js +2 -0
  102. package/dist/node_modules/@allyhub/report-extension/package.json +185 -0
  103. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/STYLE.md +180 -0
  104. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.json +15 -0
  105. package/dist/node_modules/@allyhub/runtime/package.json +1 -1
  106. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  107. package/dist/node_modules/@allyhub/scaffold/dist/index.js +8 -8
  108. package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
  109. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  110. package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
  111. package/dist/node_modules/@allyhub/sheet/dist/file.js +2 -2
  112. package/dist/node_modules/@allyhub/sheet/dist/html.js +10 -10
  113. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  114. package/dist/node_modules/@allyhub/sheet/dist/table-style.js +1 -1
  115. package/dist/node_modules/@allyhub/sheet/dist/theme.js +1 -1
  116. package/dist/node_modules/@allyhub/sheet/dist/tiles.js +1 -1
  117. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
  118. package/dist/node_modules/@allyhub/sheet/dist/xlsx/tile-shapes.js +2 -0
  119. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
  120. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  121. package/dist/node_modules/@allyhub/sheet-extension/dist/build.js +1 -1
  122. package/dist/node_modules/@allyhub/sheet-extension/dist/cli/sheet.js +1 -1
  123. package/dist/node_modules/@allyhub/sheet-extension/package.json +1 -1
  124. package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
  125. package/dist/node_modules/@allyhub/slides-core/dist/file.js +3 -3
  126. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  127. package/dist/node_modules/@allyhub/slides-extension/dist/build.js +2 -2
  128. package/dist/node_modules/@allyhub/slides-extension/dist/cli/slides.js +1 -1
  129. package/dist/node_modules/@allyhub/slides-extension/package.json +1 -1
  130. package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
  131. package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
  132. package/dist/node_modules/@allyhub/stage/package.json +1 -1
  133. package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
  134. package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +2 -2
  135. package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
  136. package/dist/node_modules/@allyhub/telemetry/package.json +1 -1
  137. package/dist/node_modules/@allyhub/text-extension/package.json +1 -1
  138. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  139. package/dist/node_modules/@allyhub/video-extension/package.json +1 -1
  140. package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
  141. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  142. package/dist/node_modules/@allyhub/website/package.json +1 -1
  143. package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
  144. package/dist/node_modules/@allyhub/x-extension/package.json +1 -1
  145. package/dist/node_modules/@allyhub/x-model/package.json +1 -1
  146. package/dist/node_modules/@allyhub/x-view/package.json +1 -1
  147. package/dist/package.json +15 -14
  148. package/dist/run-register.js +2 -0
  149. package/dist/works.js +1 -1
  150. package/editor-web/assets/{abnfDiagram-WEYOIA3C-BkVJMd53.js → abnfDiagram-WEYOIA3C-D6qI3rai.js} +1 -1
  151. package/editor-web/assets/{architecture-WOLXFQ4H-C6rnaynZ.js → architecture-WOLXFQ4H-B3V6ggq8.js} +1 -1
  152. package/editor-web/assets/{architectureDiagram-ZHVYKT53-D3vrh8LK.js → architectureDiagram-ZHVYKT53-IauNyxXn.js} +1 -1
  153. package/editor-web/assets/article-BHjKp5We.js +3 -0
  154. package/editor-web/assets/article-BlNKv1Cn.js +7 -0
  155. package/editor-web/assets/bar-button-CJmpgNg4.js +1 -0
  156. package/editor-web/assets/{blockDiagram-RJAE7QA3-BKngt8H7.js → blockDiagram-RJAE7QA3-yXhlfxbH.js} +1 -1
  157. package/editor-web/assets/{c4Diagram-XDPPPE54-j7sUELqF.js → c4Diagram-XDPPPE54-B-anrhvt.js} +1 -1
  158. package/editor-web/assets/{calc-worker-Cr4a0xmt.js → calc-worker-BpAgQE9E.js} +3 -3
  159. package/editor-web/assets/channel-Bhb-_8v6.js +1 -0
  160. package/editor-web/assets/chip-pNQlYa2W.js +1 -0
  161. package/editor-web/assets/{chunk-2E7WHVMD-BXa-uRSi.js → chunk-2E7WHVMD-QPOni4XB.js} +1 -1
  162. package/editor-web/assets/{chunk-4EMNKR2T-B3ntcsZN.js → chunk-4EMNKR2T-DG1FCRRI.js} +1 -1
  163. package/editor-web/assets/{chunk-55XCU76K-AMvnFwUg.js → chunk-55XCU76K-mKuMXpnC.js} +1 -1
  164. package/editor-web/assets/{chunk-7S6XSTFO-BA6esfFu.js → chunk-7S6XSTFO-CgZAazgt.js} +1 -1
  165. package/editor-web/assets/{chunk-AQDTSKZB-BT_vANXs.js → chunk-AQDTSKZB-BRU84phF.js} +1 -1
  166. package/editor-web/assets/{chunk-DSNLSHJZ-DoUgmzGB.js → chunk-DSNLSHJZ-zku9oeG3.js} +1 -1
  167. package/editor-web/assets/{chunk-HAGFOTED-DtnIrCZb.js → chunk-HAGFOTED-CaUkBv_0.js} +1 -1
  168. package/editor-web/assets/{chunk-HNE4Q36P-BlPwQx3_.js → chunk-HNE4Q36P-BQz4ZCJf.js} +1 -1
  169. package/editor-web/assets/{chunk-NQOKRVIF-D2r7jp2r.js → chunk-NQOKRVIF-CHVBEDkg.js} +1 -1
  170. package/editor-web/assets/{chunk-UHW7PFBP-Cmc0_F5o.js → chunk-UHW7PFBP-DrYeJo1e.js} +1 -1
  171. package/editor-web/assets/{chunk-VQ5W62QI-nJSMqAr0.js → chunk-VQ5W62QI-D8ToVCUe.js} +1 -1
  172. package/editor-web/assets/{chunk-WQQL4CDK-Btq2nbF6.js → chunk-WQQL4CDK-DZ0tyi9F.js} +1 -1
  173. package/editor-web/assets/{chunk-YZO67HFG-DTbcCoGt.js → chunk-YZO67HFG-BLe7PXER.js} +1 -1
  174. package/editor-web/assets/{chunk-ZAUX2LTX-DVwkg-2N.js → chunk-ZAUX2LTX-ByaeSIre.js} +1 -1
  175. package/editor-web/assets/{chunk-ZCHMQSOR-BV39jOOE.js → chunk-ZCHMQSOR-DdMJr_t5.js} +1 -1
  176. package/editor-web/assets/{classDiagram-v2-4MYWR3UA-Cj74-fhM.js → classDiagram-v2-4MYWR3UA-DDpq7fFC.js} +1 -1
  177. package/editor-web/assets/collaborator-CbTacvkB.js +1 -0
  178. package/editor-web/assets/color-picker-CDeICDN5.js +1 -0
  179. package/editor-web/assets/{cynefin-EF2NZ3EQ-C0CkiipV.js → cynefin-EF2NZ3EQ-CMivy2fr.js} +1 -1
  180. package/editor-web/assets/{cynefinDiagram-WF24UDRP-hdsnJ4cI.js → cynefinDiagram-WF24UDRP-GtxT_9wW.js} +1 -1
  181. package/editor-web/assets/{dagre-NK4GIZVX-CC7WSgaK.js → dagre-NK4GIZVX-Bn1O2Hjl.js} +1 -1
  182. package/editor-web/assets/deck-Cohd-G5m.js +1 -0
  183. package/editor-web/assets/{diagram-CBK3MWTC-DmaVm13J.js → diagram-CBK3MWTC-W715PWZw.js} +1 -1
  184. package/editor-web/assets/{diagram-I5XIIV2D-De8jqp7b.js → diagram-I5XIIV2D-BKObZPn2.js} +1 -1
  185. package/editor-web/assets/{diagram-ODIL2UCW-B5pBTulX.js → diagram-ODIL2UCW-UtQxEPoW.js} +1 -1
  186. package/editor-web/assets/{diagram-PFBEJUXE-BYsXg5_w.js → diagram-PFBEJUXE-CpLGEK-k.js} +1 -1
  187. package/editor-web/assets/{diagram-RJA3I4VV-DZ8f6bYe.js → diagram-RJA3I4VV-DGyMXoHb.js} +1 -1
  188. package/editor-web/assets/{diagram-TYUNFSNR-qXHUsauD.js → diagram-TYUNFSNR-Dy_Ewr8V.js} +1 -1
  189. package/editor-web/assets/dist-0I0Obj60.js +19 -0
  190. package/editor-web/assets/dist-6ugUm4dS.js +6 -0
  191. package/editor-web/assets/dist-B0rUvCi2.js +1 -0
  192. package/editor-web/assets/{dist-DAhe-kFC.js → dist-B8_6sJ_V.js} +1 -1
  193. package/editor-web/assets/dist-CKD_paj_.js +1 -0
  194. package/editor-web/assets/dist-CKUW5NzS.js +3 -0
  195. package/editor-web/assets/dist-Ca9Gsuu0.js +24 -0
  196. package/editor-web/assets/dist-Cc8v9lfc.js +1 -0
  197. package/editor-web/assets/dist-CynBNzYv.js +1 -0
  198. package/editor-web/assets/{dist-9kuRjUTN.js → dist-D7M5YTq2.js} +6 -6
  199. package/editor-web/assets/dist-D9tsFc2N.js +16 -0
  200. package/editor-web/assets/dist-DNMKDcLg.js +35 -0
  201. package/editor-web/assets/dist-Doj7_HUI.js +547 -0
  202. package/editor-web/assets/dist-DptBQzJR.js +1 -0
  203. package/editor-web/assets/dist-DzKB210A.js +5 -0
  204. package/editor-web/assets/{dist-B3rd02Cg.js → dist-H9rTuNhb.js} +6 -6
  205. package/editor-web/assets/{dist-DA72-4WB.js → dist-QLXI7XGS.js} +1 -1
  206. package/editor-web/assets/dist-RyGsFHE0.js +4 -0
  207. package/editor-web/assets/dist-oeSWr2LE.js +19 -0
  208. package/editor-web/assets/dist-wD_hHJ8_.js +19 -0
  209. package/editor-web/assets/{docx-draw-L54blreB.js → docx-draw-B5cM77hc.js} +1 -1
  210. package/editor-web/assets/{ebnfDiagram-V4P3TTPT-B7-IfVI-.js → ebnfDiagram-V4P3TTPT-GPYcx6dU.js} +1 -1
  211. package/editor-web/assets/{elk-QONTBCTQ-Gj_WaeBn.js → elk-QONTBCTQ-Bi0r4UFM.js} +1 -1
  212. package/editor-web/assets/{erDiagram-KYQIGQAA-BDF6Qoqx.js → erDiagram-KYQIGQAA-DrOSrnci.js} +1 -1
  213. package/editor-web/assets/esm-jIPnpbBD.js +21 -0
  214. package/editor-web/assets/{eventmodeling-K75KTNOO-elxVXXEe.js → eventmodeling-K75KTNOO-Dw-MjgUb.js} +1 -1
  215. package/editor-web/assets/eye-DwfE1USj.js +1 -0
  216. package/editor-web/assets/flowDiagram-IUGLLWBU-DbZTfPEP.js +1 -0
  217. package/editor-web/assets/{ganttDiagram-R7GPNTJY-CEogW3jW.js → ganttDiagram-R7GPNTJY-Bwe8cQqi.js} +1 -1
  218. package/editor-web/assets/{gitGraph-VSP46ZUC-Bh9cRWFa.js → gitGraph-VSP46ZUC-DsAcAKP0.js} +1 -1
  219. package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-BQAvdM_V.js → gitGraphDiagram-PDYL7XHY-aObRwdru.js} +1 -1
  220. package/editor-web/assets/hint-F4fIBnVU.js +1 -0
  221. package/editor-web/assets/index-Cah2zchD.css +2 -0
  222. package/editor-web/assets/index-D-MNVykg.js +28 -0
  223. package/editor-web/assets/{info-OHQRW6UA-CdPrqere.js → info-OHQRW6UA-DBPN8JFr.js} +1 -1
  224. package/editor-web/assets/{infoDiagram-MVDRKAX5-uwIMeP44.js → infoDiagram-MVDRKAX5-Bx26Hq7M.js} +1 -1
  225. package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-rtfvqK7E.js → ishikawaDiagram-HPEHV2GE-BJ_MCDwA.js} +1 -1
  226. package/editor-web/assets/{journeyDiagram-BOSHW7O7-mmhfIyVG.js → journeyDiagram-BOSHW7O7-B5g4W2Dx.js} +1 -1
  227. package/editor-web/assets/{kanban-definition-FNSA4HC5-Fe7jBsi-.js → kanban-definition-FNSA4HC5-U8YNlxN7.js} +1 -1
  228. package/editor-web/assets/layout-CuWN7_3k.js +1 -0
  229. package/editor-web/assets/{mermaid-parser.core-BxOSjBH9.js → mermaid-parser.core-DYLQlYDo.js} +3 -3
  230. package/editor-web/assets/{mermaid.core-BOln9YdH.js → mermaid.core-qNJmZ0b4.js} +4 -4
  231. package/editor-web/assets/{mindmap-definition-6OY57UG3-M3Q1LOtO.js → mindmap-definition-6OY57UG3-CI5aBWbK.js} +1 -1
  232. package/editor-web/assets/{packet-JDAUHWVQ-Dbb0TUG6.js → packet-JDAUHWVQ-BBclMGlJ.js} +1 -1
  233. package/editor-web/assets/palette-DchDLJj6.js +1 -0
  234. package/editor-web/assets/panes-BShVq38A.js +3 -0
  235. package/editor-web/assets/{pegDiagram-ECIUJNBX-BZMRpSFC.js → pegDiagram-ECIUJNBX-B3pljPTu.js} +1 -1
  236. package/editor-web/assets/{pie-XZMESJXO-Ctm9XdKp.js → pie-XZMESJXO-B7WzimHm.js} +1 -1
  237. package/editor-web/assets/{pieDiagram-GNMPY74T-cGbs5ZTl.js → pieDiagram-GNMPY74T-tM1Da50-.js} +1 -1
  238. package/editor-web/assets/progress-D1Uv3d1b.js +6 -0
  239. package/editor-web/assets/{quadrantDiagram-D57K4MC3-BUe_zsxT.js → quadrantDiagram-D57K4MC3-BEq_Shj9.js} +1 -1
  240. package/editor-web/assets/{radar-ABXABTNO-CCmKtqLs.js → radar-ABXABTNO-v2jJSW5T.js} +1 -1
  241. package/editor-web/assets/{railroad-I3PHUGI6-k-yhjhjA.js → railroad-I3PHUGI6-6W3Z4F8Y.js} +1 -1
  242. package/editor-web/assets/{railroad-abnf-LNEFI6M7-B-PvntB3.js → railroad-abnf-LNEFI6M7-DxIN7Zrt.js} +1 -1
  243. package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-Ds2rua1h.js → railroad-ebnf-DWYD2UWJ-Bb5O7tAx.js} +1 -1
  244. package/editor-web/assets/{railroad-peg-JR7BVNR7-jNZ2wEp2.js → railroad-peg-JR7BVNR7-i2LjEP5t.js} +1 -1
  245. package/editor-web/assets/{railroadDiagram-Y72NRBL7-CTqSQ15w.js → railroadDiagram-Y72NRBL7-DhsyVKbG.js} +1 -1
  246. package/editor-web/assets/{requirementDiagram-EQYSW5RA-CUblhR5M.js → requirementDiagram-EQYSW5RA-Du2k7i1E.js} +1 -1
  247. package/editor-web/assets/ribbon-tabs-Bxuj_hct.js +1 -0
  248. package/editor-web/assets/row-DqS4-5b1.js +1 -0
  249. package/editor-web/assets/{sankeyDiagram-SY24JHO5-nSz6zDX3.js → sankeyDiagram-SY24JHO5-CDnRMu7J.js} +1 -1
  250. package/editor-web/assets/schemas-CnlOL0u4.js +1 -0
  251. package/editor-web/assets/{sequenceDiagram-BLEHNHQU-DxTpOYuo.js → sequenceDiagram-BLEHNHQU-BUXBhWYW.js} +1 -1
  252. package/editor-web/assets/{session-BhClkDyr.js → session--OJYv_B7.js} +1 -1
  253. package/editor-web/assets/{snapshots-DwGHDN3t.js → snapshots-DYooVfOx.js} +1 -1
  254. package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-C3e14iHY.js → stateDiagram-v2-A6IESKWZ-Enb8LZUA.js} +1 -1
  255. package/editor-web/assets/surface-BUoi7cmR.js +1 -0
  256. package/editor-web/assets/swatch-DCmD1gZl.js +1 -0
  257. package/editor-web/assets/{swimlanes-B3ENRKFQ-DPPdzNzu.js → swimlanes-B3ENRKFQ-pnpjgTrl.js} +1 -1
  258. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-B-B2Eoc8.js +8 -0
  259. package/editor-web/assets/switch-b6GCy_ix.js +1 -0
  260. package/editor-web/assets/syntax-Bqyhj0dw.js +1 -0
  261. package/editor-web/assets/tablet-C6oePHEW.js +1 -0
  262. package/editor-web/assets/textarea-Bu6uPEqT.js +1 -0
  263. package/editor-web/assets/themes-D_ISkWVz.js +1 -0
  264. package/editor-web/assets/{timeline-definition-JXYKGLGB-DRTJ1_Er.js → timeline-definition-JXYKGLGB-C4pR18kd.js} +1 -1
  265. package/editor-web/assets/trash-2-SFReAxVM.js +1 -0
  266. package/editor-web/assets/{treeView-D4JQ5SDB-BYJ_m-i5.js → treeView-D4JQ5SDB-kzNGeAv6.js} +1 -1
  267. package/editor-web/assets/{treemap-SAJKECNS-BcU6I6Rg.js → treemap-SAJKECNS-Buhb5wzt.js} +1 -1
  268. package/editor-web/assets/updating-Cbxw83_O.js +1 -0
  269. package/editor-web/assets/{usecaseDiagram-WPOLBNNX-YV92pS4o.js → usecaseDiagram-WPOLBNNX-CL-xLQWl.js} +1 -1
  270. package/editor-web/assets/{vennDiagram-Q3Y3IDCW-oAvfHZtf.js → vennDiagram-Q3Y3IDCW-bwsyCcdK.js} +1 -1
  271. package/editor-web/assets/{video-SJvDRCJK.js → video-8MxWX9f5.js} +1 -1
  272. package/editor-web/assets/{wardley-7MLQ67FV-BLNiqxtt.js → wardley-7MLQ67FV-DXsLgedI.js} +1 -1
  273. package/editor-web/assets/{wardleyDiagram-IVAIDKWA-SppgC6xW.js → wardleyDiagram-IVAIDKWA-Cn0ph953.js} +1 -1
  274. package/editor-web/assets/{words-BUlNNuH2.js → words-B2jQwWpp.js} +1 -1
  275. package/editor-web/assets/{words-zMedmPWc.js → words-DgMuEmDO.js} +1 -1
  276. package/editor-web/assets/workbook-BDWkQ149.js +41 -0
  277. package/editor-web/assets/x-BAJilkKD.js +41 -0
  278. package/editor-web/assets/{xychartDiagram-4URNHDU4-BHMn_jwJ.js → xychartDiagram-4URNHDU4-CfXnqGWZ.js} +1 -1
  279. package/editor-web/index.html +6 -6
  280. package/package.json +5 -2
  281. package/editor-web/assets/article-DHf6mOY_.js +0 -7
  282. package/editor-web/assets/article-Dns1-Xh-.js +0 -3
  283. package/editor-web/assets/bar-button-CKPfx2AB.js +0 -1
  284. package/editor-web/assets/channel-CVWSV3su.js +0 -1
  285. package/editor-web/assets/chip-Bn_9JRRG.js +0 -1
  286. package/editor-web/assets/collaborator-XiHOxwGM.js +0 -1
  287. package/editor-web/assets/deck-DQpNIS2p.js +0 -1
  288. package/editor-web/assets/dist--z0ZHp4T.js +0 -16
  289. package/editor-web/assets/dist-B5GOGGEe.js +0 -1
  290. package/editor-web/assets/dist-Bx6q9kCu.js +0 -1
  291. package/editor-web/assets/dist-C4hHtrJr.js +0 -1
  292. package/editor-web/assets/dist-CCXJewsi.js +0 -19
  293. package/editor-web/assets/dist-CfK2BLl8.js +0 -4
  294. package/editor-web/assets/dist-Cmux3oJ_.js +0 -1
  295. package/editor-web/assets/dist-Cspf85KV.js +0 -6
  296. package/editor-web/assets/dist-DOrGo1GD.js +0 -19
  297. package/editor-web/assets/dist-DjiCHlSu.js +0 -35
  298. package/editor-web/assets/dist-Do4a40Wn.js +0 -19
  299. package/editor-web/assets/dist-FKEWS3Co.js +0 -547
  300. package/editor-web/assets/dist-QKd2i6kG.js +0 -5
  301. package/editor-web/assets/dist-SGnOfLhx.js +0 -24
  302. package/editor-web/assets/dist-VmVB7tl4.js +0 -3
  303. package/editor-web/assets/esm-PQD5Pn8a.js +0 -21
  304. package/editor-web/assets/flowDiagram-IUGLLWBU-B-25n8zE.js +0 -1
  305. package/editor-web/assets/hint-CbwoSBMw.js +0 -1
  306. package/editor-web/assets/index-CXisi0Cj.css +0 -2
  307. package/editor-web/assets/index-wMlfx8aT.js +0 -28
  308. package/editor-web/assets/layout-SWqqA0yV.js +0 -1
  309. package/editor-web/assets/progress-DZQTiRLv.js +0 -6
  310. package/editor-web/assets/ribbon-DajdQ_Ya.js +0 -1
  311. package/editor-web/assets/row-Bei9HNEe.js +0 -1
  312. package/editor-web/assets/schemas-C21MyseF.js +0 -1
  313. package/editor-web/assets/split-DBAbwPZ5.js +0 -3
  314. package/editor-web/assets/surface-CIF0Ae0z.js +0 -1
  315. package/editor-web/assets/swatch-BUzr_XmH.js +0 -1
  316. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-B8n3zOw_.js +0 -8
  317. package/editor-web/assets/switch-DrZxoPQS.js +0 -1
  318. package/editor-web/assets/syntax-emXV4DnN.js +0 -1
  319. package/editor-web/assets/tabs-BwU2E7bU.js +0 -1
  320. package/editor-web/assets/textarea-BX_ax3X8.js +0 -1
  321. package/editor-web/assets/tolerant-DM9s0Mt1.js +0 -1
  322. package/editor-web/assets/type-CvZ0HZsV.js +0 -41
  323. package/editor-web/assets/workbook-BZKYx4WB.js +0 -41
@@ -1,4 +1,4 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{mkdir as oe,readFile as ae,readdir as re,writeFile as ce}from"node:fs/promises";import{join as y}from"node:path";import{BAKE_DIR as q,CACHE_DIR as le,CONFIG_FILES as fe,ConfigSchema as F,TEXT_DIR as j,USE_FORMS as de,itemsOf as me,kindsUsed as ue,pointEntriesIn as he,WORK_FILE as h}from"@allyhub/formats";import{problem as p}from"@allyhub/diagnostics";import{looksOf as G,resolveDims as pe}from"@allyhub/piece";import{readData as ge}from"./data.js";import{dependenciesOf as we,listFiles as be}from"./files.js";import{projectTheme as V,readWork as ke}from"./work.js";import{behindIn as $e}from"./migrate.js";import{fontStyles as ye}from"./fonts.js";import{kindBuildOf as X}from"./kind-build.js";import{readMedia as xe}from"./media.js";import{readMessages as Se}from"./messages.js";import{MetaLoader as Oe}from"./meta.js";import{allyhubPlugin as je,mediaHref as z}from"./plugin.js";import{buildPluginModules as Me,stageAdditions as Ae}from"./build-plugins.js";import{checkImports as Ee,discover as ve,parse as Te}from"./scan.js";import{writeMessageTypes as De}from"./types.js";import{resolveUses as Fe}from"./uses.js";import{bundleForStage as Ke,loadUserVite as Ie}from"./vite.js";import{nodeStackPlace as Re}from"./places.js";export const inTime=(e,n)=>n.find(s=>s.id===e.kind)?.pages!==!0;export function itemProblem(e){switch(e.code){case"unknown-kind":return p("AK-M002",`${h} lists ${e.file} as a ${e.kind}, a kind no extension here contributes.`,{where:{file:h}});case"no-editor":return p("AK-M002",`${h} lists ${e.file} with no kind, and no editor here opens a file of its name. Name its kind, or take it out of the list.`,{where:{file:h}});case"missing":return p("AK-M002",`${h} lists ${e.file}, which is not in the project. Write it, or take it out of the list.`,{where:{file:h}});case"same-id":return p("AK-M003",`${h} lists ${e.files.join(" and ")}, one id (${e.id}) for two pieces, so only the first is shown: rename one, or list it once.`,{where:{file:h}})}}export function loadFailure(e,n,s){const a=s?`${n} (at ${s.file}:${String(s.line)}:${String(s.column)})`:n,f=/\b(window|document|navigator|self|HTMLElement|customElements) is not defined/u.test(n);return p("AK-R001",f?`${e} uses something at its top level that only exists in the browser (${a}). The top level of a piece module must load in Node: move it into the output's function, or import it inside a component.`:`Failed to load ${e}: ${a}`,{where:s?{file:s.file,line:s.line}:{file:e}})}export const issuesText=e=>e.issues.map(n=>`${n.path.map(String).join(".")||"(root)"}: ${n.message}`).join("; ");async function _e(e){return(await re(y(e,q)).catch(()=>[])).filter(s=>/^[0-9a-f]+\.[\w-]+\.bin$/u.test(s)).map(s=>`${q}/${s}`)}async function Pe(e,n,s){const a=o=>typeof s=="object"&&s!==null&&Object.hasOwn(s,o),f=[],i=new Set,l=new Set(ue(e,n));for(const o of e){if(!l.has(o)&&!(o.config??[]).some(a))continue;const r=await X(o)?.catch(()=>{});!r?.config||i.has(r)||(i.add(r),f.push(r.config))}return f}export async function prepare(e,n){const s=[],a=await be(e),f=await ke(e);for(const m of f.problems)s.push(p("AK-M002",m,{where:{file:h}}));if(a.includes(h)&&f.problems.length===0&&f.work.versions===void 0)s.push(p("AK-M002",`${h} records no versions (the format each kind's files are in), so its files are taken as each kind's first: allyhub migrate brings them to AllyHub's formats and records them, as Studio does when it opens the project.`,{where:{file:h}}));else for(const m of await $e(e,n.kinds))s.push(p("AK-M002",`The project's ${m.kind} files are in format ${String(m.at)}, and AllyHub's are in ${String(m.now)}: allyhub migrate brings them to it, as Studio does when it opens the project.`,{where:{file:h}}));const i=me(f.work,n.kinds,new Set(a));for(const m of i.problems)s.push(itemProblem(m));const l=await we(e),o=await xe(e,[...a,...await _e(e)]),r=await Ae(n.kinds,e,(m,w)=>{s.push(p("AK-R001",`The build plugins module ${m} did not load, so the stage's bundles go without it: ${w instanceof Error?w.message:String(w)}`,{}))}),b=new Oe({root:e,media:o,dependencies:[...l],user:!0,lent:{...r.lent},sdk:{...r.sdk},bound:{...r.bound},parts:{...r.parts},buildPlugins:Me(n.kinds)},n.metaTimeout);try{let m=F.parse({});const w=fe.find(t=>a.includes(t));if(w){const t=await b.request({type:"config",file:w});if(s.push(...t.problems),!t.ok)s.push(loadFailure(w,t.error??"",Re(t.stack,e)));else{const c=t.value??{},d=await Pe(n.kinds,i.items,c),u=new Set(d.flatMap(g=>Object.keys(g.shape??{}))),$=F.safeParse(Object.fromEntries(Object.entries(c).filter(([g])=>!u.has(g)||Object.hasOwn(F.shape,g)))),J=d.map(g=>g.safeParse(c)),W=[...$.success?[]:[issuesText($.error)],...J.flatMap(g=>g.success?[]:[issuesText(g.error)])];if($.success&&W.length===0){m=$.data;for(const g of J)g.success&&(m={...m,...g.data})}else s.push(p("AK-M001",`${w} is not valid: ${W.join("; ")}.`,{where:{file:w}}))}}const I=m.defaults?.format,R=typeof I=="string"?I:"16x9",M=ye(e,m);for(const t of M.missing)s.push(p("AK-A001",`allyhub.config's fonts name ${t}, which is not in the project or its packages.`,{where:{file:w??"allyhub.config.ts"}}));const x=await Se(e,a,{...m.locales?{locales:m.locales}:{},text:m.text??j});s.push(...x.problems);const Y=a.filter(t=>/\.(ts|tsx|js|jsx|mts|mjs)$/u.test(t)&&!t.endsWith(".d.ts")),A=new Map;for(const t of Y){const c=Te(t,await ae(y(e,t),"utf8"));A.set(t,c),s.push(...Ee(t,c,l,new Set(Object.keys(r.lent)),new Set(Object.keys(r.sdk))))}const _=[];for(const[t,c]of A){if(!ve(t,c).components)continue;const d=await b.request({type:"components",file:t});if(s.push(...d.problems),!!d.ok)for(const u of d.value??[])typeof u.name=="string"&&typeof u.export=="string"&&_.push({name:u.name,file:t,export:u.export,...typeof u.label=="string"||typeof u.label=="object"&&u.label!==null?{label:u.label}:{}})}const E=await Le(i.items,n.kinds,s),P=new Map,N=(t,c)=>({root:e,files:a,meta:b,media:o,messages:x,defaultFormat:R,config:m,lent:t,data:c,parsed:d=>A.get(d),items:i.items,claim:(d,u)=>{const $=P.get(d);return $===void 0&&P.set(d,u),$},contributionsTo:()=>[]}),L=(t,c)=>({...t,contributionsTo:d=>he(n.kinds,c.kind,d)}),k=[];let S={};const Z=N({},{}),v=new Map,T=new Map,B=(t,c)=>{v.set(t,[...v.get(t)??[],...c.files??[]]),c.uses&&c.uses.length>0&&T.set(t,[...T.get(t)??[],...c.uses])};for(const t of i.items){const c=await E.get(t)?.lend?.(t,L(Z,t));c&&(k.push(c),B(t,c),S={...S,...c.data})}const C={...await ge(e,a.filter(t=>!i.items.some(c=>c.entry===t)),m.text??j),...S},ee=N(S,C);for(const t of i.items){const c=await E.get(t)?.read?.(t,L(ee,t));c&&(k.push(c),B(t,c));const d=new Set([t.entry]);t.files=[{path:t.entry,role:"entry"},...(v.get(t)??[]).filter(u=>!d.has(u.path)&&!!d.add(u.path))]}for(const t of k)s.push(...t.problems??[]);const te=new Set(i.items.flatMap(t=>E.get(t)?.onStage?[t.kind]:[]));s.push(...Fe(i.items,n.kinds,T,{live:t=>te.has(t),lent:new Set(Object.keys(S))}));const se=k.flatMap(t=>t.piece?[t.piece]:[]),ne=k.flatMap(t=>t.doc?[t.doc]:[]),ie=k.flatMap(t=>t.sheet?[t.sheet]:[]),H=[...k.filter(t=>t.piece),...k.filter(t=>!t.piece)].flatMap(t=>t.stage?[t.stage]:[]),O=x.locales[0];await De(e,O===void 0?{}:x.messages[O]??{},O===void 0?void 0:x.files[O]);let D;if(n.buildDir&&H.length>0){const t=Object.fromEntries(await Promise.all(H.map(async d=>[d.name,await Ne(e,d)]))),c=await Ie(e);try{const d=await Ke({root:e,entries:t,outDir:n.buildDir,plugins:[je({root:e,media:o,dependencies:l,fonts:()=>M.styles,stageEntries:new Set(Object.values(t)),lent:r.lent,sdk:r.sdk,bound:r.bound,parts:r.parts}),...r.plugins],...c?{user:c}:{}}),u=await r.written(n.buildDir);D={dir:n.buildDir,chunks:d,beside:u}}catch(d){s.push(p("AK-R001",`The pieces could not be bundled for the stage: ${d.message.split(`
3
- `).slice(0,3).join(" ")}`,{}))}}const U=new Set;return{root:e,kinds:n.kinds,files:a,items:i.items,config:m,defaultFormat:R,dependencies:[...l].sort(),messages:x,media:o,data:C,docs:ne,sheets:ie,pieces:se,components:_,fonts:M.styles,...D?{bundle:D}:{},problems:s.filter(t=>{const c=`${t.code}|${t.message}|${t.where?.file??""}|${String(t.where?.line??"")}`;return U.has(c)?!1:(U.add(c),!0)})}}finally{await b.close()}}export const BUILD_FOLDER="build/",stageName=e=>e.replaceAll("/","__"),stageId=e=>"components"in e?e.place:e.id;export function stageItem(e,n){return e.pieces.find(s=>s.id===n)??e.docs.find(s=>s.place===n&&s.components.length>0)}async function Ne(e,n){const s=(n.components??[]).filter(o=>o.item!==!0);if(s.length===0&&n.module!==void 0)return y(e,n.module);const a=y(e,le,"stage-entries");await oe(a,{recursive:!0});const f=y(a,`${n.name}.ts`),i=[...new Set(s.map(o=>o.module))],l=[`// The components ${n.of??n.module??n.name} shows by their module (generated by the build).`,...n.module===void 0?[]:[`export { default } from ${JSON.stringify(y(e,n.module))};`],...i.map((o,r)=>`import * as m${String(r)} from ${JSON.stringify(y(e,o))};`),"export const components = {",...s.map(o=>` ${JSON.stringify(o.of)}: m${String(i.indexOf(o.module))}[${JSON.stringify(o.name)}],`),"};",""];return await ce(f,l.join(`
4
- `)),f}async function Le(e,n,s){const a=new Map,f=new Map;for(const i of e){if(!a.has(i.kind)){const o=n.find(r=>r.id===i.kind);a.set(i.kind,await X(o)?.catch(r=>{s.push(p("AK-R001",`The ${o?.extension??i.kind} extension's build module did not load, so its items are not read: ${r instanceof Error?r.message:String(r)}`,{}))}))}const l=a.get(i.kind);l&&f.set(i,l)}return f}function K(e,n){const s=[],a=new Set,f=new Set,i=l=>{if(f.has(l))return;f.add(l);const o=e.bundle?.chunks.chunks[l];if(o){l!==n&&s.push(`${BUILD_FOLDER}${l}`);for(const r of o.css)a.add(`${BUILD_FOLDER}${r}`);for(const r of o.imports)i(r)}};return i(n),{imports:s,styles:[...a]}}export function sourceOf(e,n){if("components"in n)return Ce(e,n);const s=n,a=BUILD_FOLDER,f=stageName(s.id),i=e.bundle?.chunks.entries[f];if(!i)throw new Error(`${s.id} was not bundled for the stage.`);const{imports:l,styles:o}=K(e,i.file);return{piece:s.id,file:s.file,module:`${a}${i.file}`,imports:l,styles:o,dims:s.dims,...s.matrix?{matrix:{space:s.matrix.space,rules:s.matrix.rules}}:{},format:s.format,locales:e.messages.locales,messages:e.messages.messages,anchors:e.messages.anchors,text:e.config.text??j,...s.script===void 0?{}:{script:s.script},media:Object.fromEntries(Object.entries(e.media).map(([r,b])=>[r,{...b,url:z(r)}])),data:e.data,kind:s.kind,...s.loads,...G(e.config,V(e.root)),pieces:Q(e,s.place)}}function Q(e,n){const s=new Map(e.items.map(i=>[i.id,i])),a=new Set,f=i=>{for(const l of s.get(i)?.uses??[])l.type!==de.live||a.has(l.item)||(a.add(l.item),f(l.item))};return f(n),Object.fromEntries(e.pieces.map(i=>{const l={file:i.file,dims:i.dims,format:i.format,...i.matrix?{matrix:{space:i.matrix.space,rules:i.matrix.rules}}:{}},o=e.bundle?.chunks.entries[stageName(i.id)];if(!a.has(i.place)||i.place===n||!o)return[i.id,l];const{imports:r,styles:b}=K(e,o.file);return[i.id,{...l,kind:i.kind,module:`${BUILD_FOLDER}${o.file}`,imports:r,styles:b,...i.script===void 0?{}:{script:i.script},...i.loads?.kindData===void 0?{}:{kindData:i.loads.kindData}}]}))}const Be="1920x1080";function Ce(e,n){const s=stageName(n.place),a=e.bundle?.chunks.entries[s];if(!a)throw new Error(`${n.place} shows no component: it has no stage bundle.`);const{imports:f,styles:i}=K(e,a.file);return{kind:"doc",piece:n.place,file:n.file,module:`${BUILD_FOLDER}${a.file}`,imports:f,styles:i,dims:pe(void 0,{locales:e.messages.locales}),format:Be,locales:e.messages.locales,messages:e.messages.messages,anchors:e.messages.anchors,text:e.config.text??j,media:Object.fromEntries(Object.entries(e.media).map(([l,o])=>[l,{...o,url:z(l)}])),data:e.data,...G(e.config,V(e.root)),pieces:Q(e,n.place)}}
2
+ import{mkdir as ce,readFile as G,readdir as le,writeFile as fe}from"node:fs/promises";import{join as $}from"node:path";import{BAKE_DIR as V,CACHE_DIR as de,CONFIG_FILES as me,ConfigSchema as F,PACKAGE_FILE as X,TEXT_DIR as j,USE_FORMS as ue,itemsOf as he,kindsUsed as pe,pointEntriesIn as ge,WORK_FILE as p}from"@allyhub/formats";import{problem as h}from"@allyhub/diagnostics";import{looksOf as z,resolveDims as we}from"@allyhub/piece";import{readData as be}from"./data.js";import{dependenciesOf as ke,listFiles as $e}from"./files.js";import{projectTheme as Q,readWork as ye}from"./work.js";import{behindIn as Se}from"./migrate.js";import{fontStyles as xe}from"./fonts.js";import{kindBuildOf as Y}from"./kind-build.js";import{readMedia as Oe}from"./media.js";import{readMessages as je}from"./messages.js";import{MetaLoader as Me}from"./meta.js";import{allyhubPlugin as Ee,mediaHref as Z}from"./plugin.js";import{buildPluginModules as Ae,stageAdditions as ve}from"./build-plugins.js";import{SDK as M}from"./project-root.js";import{checkImports as Ke,discover as Te,parse as De}from"./scan.js";import{writeMessageTypes as Fe}from"./types.js";import{resolveUses as Ie}from"./uses.js";import{bundleForStage as Re,loadUserVite as _e}from"./vite.js";import{nodeStackPlace as Ne}from"./places.js";export const inTime=(e,n)=>n.find(s=>s.id===e.kind)?.pages!==!0;export function itemProblem(e){switch(e.code){case"unknown-kind":return h("AK-M002",`${p} lists ${e.file} as a ${e.kind}, a kind no extension here contributes.`,{where:{file:p}});case"no-editor":return h("AK-M002",`${p} lists ${e.file} with no kind, and no editor here opens a file of its name. Name its kind, or take it out of the list.`,{where:{file:p}});case"missing":return h("AK-M002",`${p} lists ${e.file}, which is not in the project. Write it, or take it out of the list.`,{where:{file:p}});case"same-id":return h("AK-M003",`${p} lists ${e.files.join(" and ")}, one id (${e.id}) for two pieces, so only the first is shown: rename one, or list it once.`,{where:{file:p}})}}export function loadFailure(e,n,s){const a=s?`${n} (at ${s.file}:${String(s.line)}:${String(s.column)})`:n,f=/\b(window|document|navigator|self|HTMLElement|customElements) is not defined/u.test(n);return h("AK-R001",f?`${e} uses something at its top level that only exists in the browser (${a}). The top level of a piece module must load in Node: move it into the output's function, or import it inside a component.`:`Failed to load ${e}: ${a}`,{where:s?{file:s.file,line:s.line}:{file:e}})}export const issuesText=e=>e.issues.map(n=>`${n.path.map(String).join(".")||"(root)"}: ${n.message}`).join("; ");async function Pe(e){return(await le($(e,V)).catch(()=>[])).filter(s=>/^[0-9a-f]+\.[\w-]+\.bin$/u.test(s)).map(s=>`${V}/${s}`)}async function Le(e,n,s){const a=o=>typeof s=="object"&&s!==null&&Object.hasOwn(s,o),f=[],i=new Set,l=new Set(pe(e,n));for(const o of e){if(!l.has(o)&&!(o.config??[]).some(a))continue;const r=await Y(o)?.catch(()=>{});!r?.config||i.has(r)||(i.add(r),f.push(r.config))}return f}const Be=(e,n)=>G($(e,"node_modules",n,X),"utf8").then(()=>!0,s=>{if(s instanceof Error&&"code"in s&&(s.code==="ENOENT"||s.code==="ENOTDIR"))return!1;throw s});export async function prepare(e,n){const s=[],a=await $e(e),f=await ye(e);for(const m of f.problems)s.push(h("AK-M002",m,{where:{file:p}}));if(a.includes(p)&&f.problems.length===0&&f.work.versions===void 0)s.push(h("AK-M002",`${p} records no versions (the format each kind's files are in), so its files are taken as each kind's first: allyhub migrate brings them to AllyHub's formats and records them, as Studio does when it opens the project.`,{where:{file:p}}));else for(const m of await Se(e,n.kinds))s.push(h("AK-M002",`The project's ${m.kind} files are in format ${String(m.at)}, and AllyHub's are in ${String(m.now)}: allyhub migrate brings them to it, as Studio does when it opens the project.`,{where:{file:p}}));const i=he(f.work,n.kinds,new Set(a));for(const m of i.problems)s.push(itemProblem(m));const l=await ke(e);l.has(M)&&!await Be(e,M)&&s.push(h("AK-B009",`package.json declares ${M}, which is not installed, so its imports are refused: npm install installs it. A project that declares no ${M} is lent the one allyhub brings.`,{where:{file:X}}));const o=await Oe(e,[...a,...await Pe(e)]),r=await ve(n.kinds,e,(m,w)=>{s.push(h("AK-R001",`The build plugins module ${m} did not load, so the stage's bundles go without it: ${w instanceof Error?w.message:String(w)}`,{}))}),b=new Me({root:e,media:o,dependencies:[...l],user:!0,lent:{...r.lent},sdk:{...r.sdk},bound:{...r.bound},parts:{...r.parts},buildPlugins:Ae(n.kinds)},n.metaTimeout);try{let m=F.parse({});const w=me.find(t=>a.includes(t));if(w){const t=await b.request({type:"config",file:w});if(s.push(...t.problems),!t.ok)s.push(loadFailure(w,t.error??"",Ne(t.stack,e)));else{const c=t.value??{},d=await Le(n.kinds,i.items,c),u=new Set(d.flatMap(g=>Object.keys(g.shape??{}))),y=F.safeParse(Object.fromEntries(Object.entries(c).filter(([g])=>!u.has(g)||Object.hasOwn(F.shape,g)))),W=d.map(g=>g.safeParse(c)),q=[...y.success?[]:[issuesText(y.error)],...W.flatMap(g=>g.success?[]:[issuesText(g.error)])];if(y.success&&q.length===0){m=y.data;for(const g of W)g.success&&(m={...m,...g.data})}else s.push(h("AK-M001",`${w} is not valid: ${q.join("; ")}.`,{where:{file:w}}))}}const R=m.defaults?.format,_=typeof R=="string"?R:"16x9",E=xe(e,m);for(const t of E.missing)s.push(h("AK-A001",`allyhub.config's fonts name ${t}, which is not in the project or its packages.`,{where:{file:w??"allyhub.config.ts"}}));const S=await je(e,a,{...m.locales?{locales:m.locales}:{},text:m.text??j});s.push(...S.problems);const te=a.filter(t=>/\.(ts|tsx|js|jsx|mts|mjs)$/u.test(t)&&!t.endsWith(".d.ts")),A=new Map;for(const t of te){const c=De(t,await G($(e,t),"utf8"));A.set(t,c),s.push(...Ke(t,c,l,new Set(Object.keys(r.lent)),new Set(Object.keys(r.sdk))))}const N=[];for(const[t,c]of A){if(!Te(t,c).components)continue;const d=await b.request({type:"components",file:t});if(s.push(...d.problems),!!d.ok)for(const u of d.value??[])typeof u.name=="string"&&typeof u.export=="string"&&N.push({name:u.name,file:t,export:u.export,...typeof u.label=="string"||typeof u.label=="object"&&u.label!==null?{label:u.label}:{}})}const v=await He(i.items,n.kinds,s),P=new Map,L=(t,c)=>({root:e,files:a,meta:b,media:o,messages:S,defaultFormat:_,config:m,lent:t,data:c,parsed:d=>A.get(d),items:i.items,claim:(d,u)=>{const y=P.get(d);return y===void 0&&P.set(d,u),y},contributionsTo:()=>[]}),B=(t,c)=>({...t,contributionsTo:d=>ge(n.kinds,c.kind,d)}),k=[];let x={};const se=L({},{}),K=new Map,T=new Map,C=(t,c)=>{K.set(t,[...K.get(t)??[],...c.files??[]]),c.uses&&c.uses.length>0&&T.set(t,[...T.get(t)??[],...c.uses])};for(const t of i.items){const c=await v.get(t)?.lend?.(t,B(se,t));c&&(k.push(c),C(t,c),x={...x,...c.data})}const H={...await be(e,a.filter(t=>!i.items.some(c=>c.entry===t)),m.text??j),...x},ne=L(x,H);for(const t of i.items){const c=await v.get(t)?.read?.(t,B(ne,t));c&&(k.push(c),C(t,c));const d=new Set([t.entry]);t.files=[{path:t.entry,role:"entry"},...(K.get(t)??[]).filter(u=>!d.has(u.path)&&!!d.add(u.path))]}for(const t of k)s.push(...t.problems??[]);const ie=new Set(i.items.flatMap(t=>v.get(t)?.onStage?[t.kind]:[]));s.push(...Ie(i.items,n.kinds,T,{live:t=>ie.has(t),lent:new Set(Object.keys(x))}));const oe=k.flatMap(t=>t.piece?[t.piece]:[]),ae=k.flatMap(t=>t.doc?[t.doc]:[]),re=k.flatMap(t=>t.sheet?[t.sheet]:[]),U=[...k.filter(t=>t.piece),...k.filter(t=>!t.piece)].flatMap(t=>t.stage?[t.stage]:[]),O=S.locales[0];await Fe(e,O===void 0?{}:S.messages[O]??{},O===void 0?void 0:S.files[O]);let D;if(n.buildDir&&U.length>0){const t=Object.fromEntries(await Promise.all(U.map(async d=>[d.name,await Ce(e,d)]))),c=await _e(e);try{const d=await Re({root:e,entries:t,outDir:n.buildDir,plugins:[Ee({root:e,media:o,dependencies:l,fonts:()=>E.styles,stageEntries:new Set(Object.values(t)),lent:r.lent,sdk:r.sdk,bound:r.bound,parts:r.parts}),...r.plugins],...c?{user:c}:{}}),u=await r.written(n.buildDir);D={dir:n.buildDir,chunks:d,beside:u}}catch(d){s.push(h("AK-R001",`The pieces could not be bundled for the stage: ${d.message.split(`
3
+ `).slice(0,3).join(" ")}`,{}))}}const J=new Set;return{root:e,kinds:n.kinds,files:a,items:i.items,config:m,defaultFormat:_,dependencies:[...l].sort(),messages:S,media:o,data:H,docs:ae,sheets:re,pieces:oe,components:N,fonts:E.styles,...D?{bundle:D}:{},problems:s.filter(t=>{const c=`${t.code}|${t.message}|${t.where?.file??""}|${String(t.where?.line??"")}`;return J.has(c)?!1:(J.add(c),!0)})}}finally{await b.close()}}export const BUILD_FOLDER="build/",stageName=e=>e.replaceAll("/","__"),stageId=e=>"components"in e?e.place:e.id;export function stageItem(e,n){return e.pieces.find(s=>s.id===n)??e.docs.find(s=>s.place===n&&s.components.length>0)}async function Ce(e,n){const s=(n.components??[]).filter(o=>o.item!==!0);if(s.length===0&&n.module!==void 0)return $(e,n.module);const a=$(e,de,"stage-entries");await ce(a,{recursive:!0});const f=$(a,`${n.name}.ts`),i=[...new Set(s.map(o=>o.module))],l=[`// The components ${n.of??n.module??n.name} shows by their module (generated by the build).`,...n.module===void 0?[]:[`export { default } from ${JSON.stringify($(e,n.module))};`],...i.map((o,r)=>`import * as m${String(r)} from ${JSON.stringify($(e,o))};`),"export const components = {",...s.map(o=>` ${JSON.stringify(o.of)}: m${String(i.indexOf(o.module))}[${JSON.stringify(o.name)}],`),"};",""];return await fe(f,l.join(`
4
+ `)),f}async function He(e,n,s){const a=new Map,f=new Map;for(const i of e){if(!a.has(i.kind)){const o=n.find(r=>r.id===i.kind);a.set(i.kind,await Y(o)?.catch(r=>{s.push(h("AK-R001",`The ${o?.extension??i.kind} extension's build module did not load, so its items are not read: ${r instanceof Error?r.message:String(r)}`,{}))}))}const l=a.get(i.kind);l&&f.set(i,l)}return f}function I(e,n){const s=[],a=new Set,f=new Set,i=l=>{if(f.has(l))return;f.add(l);const o=e.bundle?.chunks.chunks[l];if(o){l!==n&&s.push(`${BUILD_FOLDER}${l}`);for(const r of o.css)a.add(`${BUILD_FOLDER}${r}`);for(const r of o.imports)i(r)}};return i(n),{imports:s,styles:[...a]}}export function sourceOf(e,n){if("components"in n)return Je(e,n);const s=n,a=BUILD_FOLDER,f=stageName(s.id),i=e.bundle?.chunks.entries[f];if(!i)throw new Error(`${s.id} was not bundled for the stage.`);const{imports:l,styles:o}=I(e,i.file);return{piece:s.id,file:s.file,module:`${a}${i.file}`,imports:l,styles:o,dims:s.dims,...s.matrix?{matrix:{space:s.matrix.space,rules:s.matrix.rules}}:{},format:s.format,locales:e.messages.locales,messages:e.messages.messages,anchors:e.messages.anchors,text:e.config.text??j,...s.script===void 0?{}:{script:s.script},media:Object.fromEntries(Object.entries(e.media).map(([r,b])=>[r,{...b,url:Z(r)}])),data:e.data,kind:s.kind,...s.loads,...z(e.config,Q(e.root)),pieces:ee(e,s.place)}}function ee(e,n){const s=new Map(e.items.map(i=>[i.id,i])),a=new Set,f=i=>{for(const l of s.get(i)?.uses??[])l.type!==ue.live||a.has(l.item)||(a.add(l.item),f(l.item))};return f(n),Object.fromEntries(e.pieces.map(i=>{const l={file:i.file,dims:i.dims,format:i.format,...i.matrix?{matrix:{space:i.matrix.space,rules:i.matrix.rules}}:{}},o=e.bundle?.chunks.entries[stageName(i.id)];if(!a.has(i.place)||i.place===n||!o)return[i.id,l];const{imports:r,styles:b}=I(e,o.file);return[i.id,{...l,kind:i.kind,module:`${BUILD_FOLDER}${o.file}`,imports:r,styles:b,...i.script===void 0?{}:{script:i.script},...i.loads?.kindData===void 0?{}:{kindData:i.loads.kindData}}]}))}const Ue="1920x1080";function Je(e,n){const s=stageName(n.place),a=e.bundle?.chunks.entries[s];if(!a)throw new Error(`${n.place} shows no component: it has no stage bundle.`);const{imports:f,styles:i}=I(e,a.file);return{kind:"doc",piece:n.place,file:n.file,module:`${BUILD_FOLDER}${a.file}`,imports:f,styles:i,dims:we(void 0,{locales:e.messages.locales}),format:Ue,locales:e.messages.locales,messages:e.messages.messages,anchors:e.messages.anchors,text:e.config.text??j,media:Object.fromEntries(Object.entries(e.media).map(([l,o])=>[l,{...o,url:Z(l)}])),data:e.data,...z(e.config,Q(e.root)),pieces:ee(e,n.place)}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{readFile as c,realpath as s,stat as d}from"node:fs/promises";import{dirname as a,join as u,resolve as i}from"node:path";import{CONFIG_FILES as p,PACKAGE_FILE as l}from"@allyhub/formats/layout";export const SDK="@allyhub/sdk";const h=["allyhub",SDK];async function y(t){const e=await c(u(t,l),"utf8").catch(()=>{});if(e!==void 0)try{const r=JSON.parse(e);for(const o of["dependencies","devDependencies"]){const n=r[o];if(typeof n=="object"&&n!==null&&h.some(f=>f in n))return!0}}catch{}for(const r of p)if(await d(u(t,r)).then(()=>!0,()=>!1))return!0;return!1}export async function projectRoot(t,e){const r=i(t,e??".");return await projectAt(r)??r}export async function projectAt(t){for(let e=i(t);;e=a(e)){if(await y(e))return e;if(a(e)===e)return}}export async function projectOfFile(t,e,r){if(r!==void 0)return{root:i(e,r),foundBy:"dir"};const o=await projectAt(e),n=await projectAt(a(i(e,t)));return n!==void 0?o!==void 0&&await s(n).catch(()=>n)===await s(o).catch(()=>o)?{root:n,foundBy:"file"}:{root:n,foundBy:"file",warning:`${t} is in the project ${n}, ${o===void 0?"and the current folder is in none":`not the current folder's (${o})`}: what is measured of it is kept there.`}:o!==void 0?{root:o,foundBy:"cwd"}:{root:i(e),foundBy:"none",warning:`No project above ${t} or the current folder: what is measured is kept in ${i(e)}.`}}
2
+ import{readFile as c,realpath as s,stat as d}from"node:fs/promises";import{dirname as a,join as u,resolve as i}from"node:path";import{CONFIG_FILES as p,PACKAGE_FILE as l,WORK_FILE as h}from"@allyhub/formats/layout";export const SDK="@allyhub/sdk";const y=["allyhub",SDK];async function m(t){const e=await c(u(t,l),"utf8").catch(()=>{});if(e!==void 0)try{const r=JSON.parse(e);for(const o of["dependencies","devDependencies"]){const n=r[o];if(typeof n=="object"&&n!==null&&y.some(f=>f in n))return!0}}catch{}for(const r of[h,...p])if(await d(u(t,r)).then(()=>!0,()=>!1))return!0;return!1}export async function projectRoot(t,e){const r=i(t,e??".");return await projectAt(r)??r}export async function projectAt(t){for(let e=i(t);;e=a(e)){if(await m(e))return e;if(a(e)===e)return}}export async function projectOfFile(t,e,r){if(r!==void 0)return{root:i(e,r),foundBy:"dir"};const o=await projectAt(e),n=await projectAt(a(i(e,t)));return n!==void 0?o!==void 0&&await s(n).catch(()=>n)===await s(o).catch(()=>o)?{root:n,foundBy:"file"}:{root:n,foundBy:"file",warning:`${t} is in the project ${n}, ${o===void 0?"and the current folder is in none":`not the current folder's (${o})`}: what is measured of it is kept there.`}:o!==void 0?{root:o,foundBy:"cwd"}:{root:i(e),foundBy:"none",warning:`No project above ${t} or the current folder: what is measured is kept in ${i(e)}.`}}
@@ -1,4 +1,4 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{readFileSync as O,statSync as W}from"node:fs";import{readFile as k,writeFile as F}from"node:fs/promises";import{join as f}from"node:path";import{itemsOf as $,parseWork as h,WORK_FILE as c,WorkItemSchema as j}from"@allyhub/formats";import{isMap as g,isScalar as y,isSeq as E,parseDocument as S,parse as x,visit as v}from"yaml";import{listFiles as I}from"./files.js";export async function readWork(r){const t=await k(f(r,c),"utf8").catch(()=>{});if(t===void 0)return{work:{work:[]},problems:[]};let o;try{o=x(t)}catch(e){return{work:{work:[]},problems:[`${c} is not valid YAML: ${e.message.split(`
3
- `)[0]??""}`]}}const n=h(o);return n.ok?{work:n.value,problems:[]}:{work:{work:[]},problems:n.problems.map(e=>`${c}: ${e}`)}}const M=new Map;export function projectTheme(r){const t=f(r,c);let o;try{o=W(t).mtimeMs}catch{return}const n=M.get(r);if(n?.at===o)return n.theme;let e;try{const s=h(x(O(t,"utf8")));e=s.ok?s.value.theme:void 0}catch{e=void 0}return M.set(r,{at:o,theme:e}),e}export async function projectItems(r,t,o,n){const{work:e,problems:s}=await readWork(r);return{...$(e,t,new Set(o??await I(r)),n),listProblems:s}}export function currentFormats(r){return Object.fromEntries(r.flatMap(t=>t.migrations===void 0?[]:[[t.id,t.migrations.format]]))}export async function listWork(r,t,o){const n=f(r,c),e=await k(n,"utf8").catch(()=>{}),s=S(e??`work: []
4
- `);e===void 0&&s.set("versions",currentFormats(o));const i=s.toJS()?.work;if(JSON.stringify(i??[]).includes(JSON.stringify(t.file)))return;Array.isArray(i)||s.set("work",s.createNode([]));const a=s.get("work",!0);E(a)&&(a.flow=!1),s.addIn(["work"],t),await F(n,s.toString())}export function unlistedWork(r,t){const o=S(r),n=[],e=[];return v(o,{Map(s,i,p){if(!g(i))return;const a=i.get("file",!0);if(!y(a)||typeof a.value!="string")return;const d=a.value.replace(/^\.\//u,"");if(d!==t&&!d.startsWith(`${t}/`))return;const l=i.toJSON(),m=j.safeParse(l);m.success&&n.push(m.data);const b=p.flatMap(w=>{if(!g(w))return[];const u=w.get("group",!0);return y(u)&&typeof u.value=="string"?[u.value]:[]});return e.push({entry:l,groups:b}),v.REMOVE}}),e.length>0?{text:o.toString(),items:n,entries:e}:void 0}
2
+ import{readFileSync as b,statSync as F}from"node:fs";import{readFile as k,writeFile as W}from"node:fs/promises";import{join as f}from"node:path";import{itemsOf as $,parseWork as g,readLeavingOutUnknownFields as j,WORK_FILE as c,WorkItemSchema as E}from"@allyhub/formats";import{isMap as h,isScalar as y,isSeq as I,parseDocument as S,parse as v,visit as x}from"yaml";import{listFiles as J}from"./files.js";export async function readWork(r){const t=await k(f(r,c),"utf8").catch(()=>{});if(t===void 0)return{work:{work:[]},problems:[]};let o;try{o=v(t)}catch(e){return{work:{work:[]},problems:[`${c} is not valid YAML: ${e.message.split(`
3
+ `)[0]??""}`]}}const n=g(o);return n.ok?{work:n.value,problems:[]}:{work:{work:[]},problems:n.problems.map(e=>`${c}: ${e}`)}}const M=new Map;export function projectTheme(r){const t=f(r,c);let o;try{o=F(t).mtimeMs}catch{return}const n=M.get(r);if(n?.at===o)return n.theme;let e;try{const i=g(v(b(t,"utf8")));e=i.ok?i.value.theme:void 0}catch{e=void 0}return M.set(r,{at:o,theme:e}),e}export async function projectItems(r,t,o,n){const{work:e,problems:i}=await readWork(r);return{...$(e,t,new Set(o??await J(r)),n),listProblems:i}}export function currentFormats(r){return Object.fromEntries(r.flatMap(t=>t.migrations===void 0?[]:[[t.id,t.migrations.format]]))}export async function listWork(r,t,o){const n=f(r,c),e=await k(n,"utf8").catch(()=>{}),i=S(e??`work: []
4
+ `);e===void 0&&i.set("versions",currentFormats(o));const s=i.toJS()?.work;if(JSON.stringify(s??[]).includes(JSON.stringify(t.file)))return;Array.isArray(s)||i.set("work",i.createNode([]));const a=i.get("work",!0);I(a)&&(a.flow=!1),i.addIn(["work"],t),await W(n,i.toString())}export function unlistedWork(r,t){const o=S(r),n=[],e=[];return x(o,{Map(i,s,d){if(!h(s))return;const a=s.get("file",!0);if(!y(a)||typeof a.value!="string")return;const p=a.value.replace(/^\.\//u,"");if(p!==t&&!p.startsWith(`${t}/`))return;const l=s.toJSON(),m=j(E,l);m.success&&n.push(m.data);const O=d.flatMap(w=>{if(!h(w))return[];const u=w.get("group",!0);return y(u)&&typeof u.value=="string"?[u.value]:[]});return e.push({entry:l,groups:O}),x.REMOVE}}),e.length>0?{text:o.toString(),items:n,entries:e}:void 0}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/build",
3
- "version": "0.20.0",
3
+ "version": "0.22.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.20.0",
3
+ "version": "0.22.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.20.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/chart",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/check",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,5 +1,5 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{randomUUID as X}from"node:crypto";import{mkdir as A,readdir as Y,readFile as T,rm as q,writeFile as D}from"node:fs/promises";import{basename as $,dirname as k,extname as S,join as j}from"node:path";import{EXIT as p}from"@allyhub/protocol/cli";import{FileContentResponseSchema as Q,ToolCallSchema as R,callPath as V,fileContentPath as tt,parseAllyFilePath as I,toolCallsPath as et}from"@allyhub/protocol/cloud";import{genFileFor as U}from"@allyhub/formats/data/gen";import{CloudError as d}from"./errors.js";import{genRecord as H,inputHash as nt,namedFile as it,readGen as at,toolWords as ot,writeGen as M,writeWords as rt}from"./records.js";import{TRANSIENT_STATUSES as st}from"./storage.js";import{withKnownUploads as lt}from"./uploads.js";export const WAIT_SECONDS=900,POLL_SECONDS={least:1,most:60},RETRY_SECONDS={least:1,most:30},READ_SECONDS=120;const ft=t=>t instanceof d&&(t.code==="network"||t.status!==void 0&&st.has(t.status));function ut(t){if(!/^https?:\/\//iu.test(t))return t;let e;try{e=new URL(t)}catch{return t}if(e.search==="")return t.replace(/^https?:\/\//iu,"");const i=/filename\*?=(?:UTF-8'')?"?([^";]+)/iu.exec(e.searchParams.get("response-content-disposition")??"")?.[1];return i===void 0?void 0:decodeURIComponent(i)}export function inputSlug(t){return Object.values(t).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e=="string").flatMap(e=>ut(e)??[]).join("-").replace(/[^\p{L}\p{N}._]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,40).replace(/-+$/u,"")}const L=t=>t.replace(/[^A-Za-z0-9_-]/gu,"_").slice(0,8),W=(t,e)=>{const i=S(t);return`${$(t,i)}-${L(e)}${i}`};async function ct(t,e,i,n,o){await A(t,{recursive:!0});const s=[e,inputSlug(i),L(n)].filter(Boolean).join("-"),r=j(t,`${s}.output.json`);return await D(r,`${JSON.stringify(o,null,2)}
2
+ import{randomUUID as X}from"node:crypto";import{mkdir as A,readdir as Y,readFile as T,rm as q,writeFile as D}from"node:fs/promises";import{basename as $,dirname as k,extname as S,join as j}from"node:path";import{EXIT as p}from"@allyhub/protocol/cli";import{FileContentResponseSchema as Q,ToolCallSchema as R,callPath as V,fileContentPath as tt,parseAllyFilePath as I,toolCallsPath as et}from"@allyhub/protocol/cloud";import{genFileFor as L}from"@allyhub/formats/data/gen";import{CloudError as d}from"./errors.js";import{genRecord as U,inputHash as nt,namedFile as it,readGen as at,toolWords as ot,writeGen as H,writeWords as rt}from"./records.js";import{TRANSIENT_STATUSES as st}from"./storage.js";import{withKnownUploads as lt}from"./uploads.js";export const WAIT_SECONDS=900,POLL_SECONDS={least:1,most:60},RETRY_SECONDS={least:1,most:30},READ_SECONDS=120;const ft=t=>t instanceof d&&(t.code==="network"||t.status!==void 0&&st.has(t.status));function ut(t){if(!/^https?:\/\//iu.test(t))return t;let e;try{e=new URL(t)}catch{return t}if(e.search==="")return t.replace(/^https?:\/\//iu,"");const i=/filename\*?=(?:UTF-8'')?"?([^";]+)/iu.exec(e.searchParams.get("response-content-disposition")??"")?.[1];return i===void 0?void 0:decodeURIComponent(i)}export function inputSlug(t){return Object.values(t).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e=="string").flatMap(e=>ut(e)??[]).join("-").replace(/[^\p{L}\p{N}._]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,40).replace(/-+$/u,"")}const M=t=>t.replace(/[^A-Za-z0-9_-]/gu,"_").slice(0,8),W=(t,e)=>{const i=S(t);return`${$(t,i)}-${M(e)}${i}`};async function ct(t,e,i,n,o){await A(t,{recursive:!0});const s=[e,inputSlug(i),M(n)].filter(Boolean).join("-"),r=j(t,`${s}.output.json`);return await D(r,`${JSON.stringify(o,null,2)}
3
3
  `),r}async function dt(t,e){const i=S(t)===""?`${t}.json`:t;return await A(k(i),{recursive:!0}),await D(i,`${JSON.stringify(e,null,2)}
4
4
  `),i}const E=t=>j(t.config.cacheDir,"jobs"),C=(t,e)=>j(E(t),`${e.replace(/[^A-Za-z0-9_-]/gu,"_")}.json`);async function wt(t,e,i){await A(k(C(t,e)),{recursive:!0}),await D(C(t,e),`${JSON.stringify(i,null,2)}
5
- `)}const P=(t,e)=>q(C(t,e),{force:!0});async function ht(t,e,i){const n=await Y(E(t)).catch(()=>[]);for(const o of n.filter(s=>s.endsWith(".json")).sort()){const s=await T(j(E(t),o),"utf8").then(r=>JSON.parse(r)).catch(()=>{});if(s?.jobId!==void 0&&s.file===e&&s.inputHash===i)return s.jobId}}async function pt(t,e){try{return JSON.parse(await T(C(t,e),"utf8"))}catch{throw new d("unknown-job",`No job ${e} was started on this computer.`,{exit:p.notFound,hint:"Call the tool again: that is a new call."})}}async function B(t,e,i,n,o){const{url:s}=Q.parse(await t.json(tt(e,"attachment"),{signal:v(o)}));let r;try{const u=await t.config.fetch(s,o?{signal:o}:{});if(!u.ok)throw new d("download-failed",`Downloading ${i} answered ${String(u.status)}.`,{exit:p.platform,status:u.status});r=Buffer.from(await u.arrayBuffer())}catch(u){throw u instanceof d||o?.aborted===!0?u:new d("network",`Downloading ${i} failed: ${u instanceof Error?u.message:String(u)}`,{exit:p.platform,cause:u})}const w="dir"in n?j(n.dir,$(n.name??i)):S(n.file)?n.file:`${n.file}${S(i)}`;return await A(k(w),{recursive:!0}),await D(w,r),w}const v=t=>t?AbortSignal.any([t,AbortSignal.timeout(READ_SECONDS*1e3)]):AbortSignal.timeout(READ_SECONDS*1e3),z=(t,e)=>new Promise((i,n)=>{const o=setTimeout(i,t*1e3);e?.addEventListener("abort",()=>{clearTimeout(o),n(e.reason instanceof Error?e.reason:new Error("Stopped."))},{once:!0})});export async function callTool(t,e,i,n){const o=n.file,s=await lt(t,i,n.base),r=nt(e,s);let w=n.jobId,u=!1;if(o!==void 0&&w===void 0){w=await ht(t,o,r);const f=w===void 0?await it(o):void 0,l=f?await at(f):void 0;if(n.force===!0)u=l!==void 0;else{if(f&&!l)throw new d("file-exists",`${f} is there, without a record (${$(U(f))}) saying a tool call made it.`,{exit:p.conflict,hint:"Choose another --file, or pass --force to replace it."});if(f&&l){if(l.tool===e&&l.inputHash===r)return{tool:e,output:typeof l.output?.allyFilePath=="string"?l.output:JSON.parse(await T(f,"utf8")),file:f,gen:U(f),kept:{at:l.at}};throw new d("file-exists",`${f} was made by ${l.tool??"another tool"} from another input on ${l.at}.`,{exit:p.conflict,hint:"Choose another --file to keep it, or pass --force to make it again over it (charged again)."})}}}const m=Date.now()+(n.timeoutSeconds??WAIT_SECONDS)*1e3,g=n.signal;let a=w===void 0?R.parse(await t.json(et(e),{method:"POST",body:{input:i},idempotencyKey:X(),...g?{signal:g}:{}})):await G(t,w,m,n);a.status==="working"&&w===void 0&&await wt(t,a.id,{jobId:a.id,tool:e,input:{...i},inputHash:r,outDir:n.outDir,...o===void 0?{}:{file:o}});const K=()=>({tool:e,jobId:a.id,status:"running",elapsedSeconds:(Date.now()-Date.parse(a.createdAt))/1e3,...o===void 0?{}:{file:o}});for(;a.status==="working";){if(n.wait===!1||Date.now()>m)return K();n.onRunning?.(a),await z(Math.min(Math.max((a.pollAfterMs??0)/1e3,POLL_SECONDS.least),POLL_SECONDS.most),g),a=await G(t,a.id,m,n)}if(a.status==="failed")throw await P(t,a.id),new d(`tool-${(a.error?.kind??"failed").replaceAll("_","-")}`,a.error?.message??"The tool failed.",{exit:a.error?.kind==="input"?p.usage:p.platform,hint:a.error?.kind==="input"||a.error?.kind==="not_found"?"A failed call is not charged. Change the input and call again.":a.error?.kind==="unavailable"?"A failed call is not charged. Calling it again will not help until AllyHub sets it up or fixes it.":"A failed call is not charged. Call it again; a supplier's failure often passes."});if(a.status!=="completed")throw new d("tool-state",`The call ${a.id} is ${a.status}, a state this version of allyhub does not know.`,{exit:p.platform,hint:"Update allyhub in the project (npm install allyhub@latest) and call it again."});const h=typeof a.output=="object"&&a.output!==null?a.output:{value:a.output},J=h.allyFilePath,y=typeof J=="string"?I(J):void 0,b=!y&&o!==void 0?await dt(o,h):void 0,c={tool:e,output:h,outputFile:b??await ct(n.outputDir??n.outDir,e,i,a.id,h),...a.credits===void 0?{}:{credits:a.credits}};if(y){const f=a.id,l=await _(f,()=>B(t,y.id,y.name,o!==void 0?{file:o}:{dir:n.outDir,name:W(y.name,f)},g),m,n);c.file=l,c.gen=await M(l,await H(l,{tool:e,input:s,output:h,credits:a.credits}));const x=ot(h),N=h.durationSeconds;x&&(c.words=await rt(l,x,typeof N=="number"&&N>=0?N:void 0)),u&&(c.replaced=!0)}else b!==void 0&&(c.file=b,c.gen=await M(b,await H(b,{tool:e,input:s,output:h,credits:a.credits})),u&&(c.replaced=!0));const O={},Z=c.file===void 0?n.outDir:k(c.file),F=c.file;for(const f of mt(h)){const l=I(f);if(!l)continue;const x=F===void 0?W(l.name,a.id):`${$(F,S(F))}.${$(l.name)}`;O[f]=await _(a.id,()=>B(t,l.id,l.name,{dir:Z,name:x},g),m,n)}return Object.keys(O).length>0&&(c.more=O),await P(t,a.id),c}function mt(t){const e=[],i=(n,o)=>{if(Array.isArray(n))for(const s of n)i(s,!1);else if(typeof n=="object"&&n!==null)for(const[s,r]of Object.entries(n))s==="allyFilePath"&&!o&&typeof r=="string"?e.push(r):i(r,!1)};return i(t,!0),e}async function G(t,e,i,n){try{return await _(e,async()=>R.parse(await t.json(V(e),{signal:v(n.signal)})),i,n)}catch(o){throw o instanceof d&&o.status===404&&await P(t,e),o}}async function _(t,e,i,n){const o=n.retrySeconds??RETRY_SECONDS;for(let s=o.least;;)try{return await e()}catch(r){if(!ft(r)||n.signal?.aborted===!0)throw r;if(Date.now()+s*1e3>i)throw new d(r.code,r.message,{exit:r.exit,...r.status===void 0?{}:{status:r.status},hint:`Call ${t} goes on at AllyHub, charged once when it works: --resume ${t} waits for it again (so does the same call to the same --file).`,cause:r});n.onRetry?.(t,r,s),await z(s,n.signal),s=Math.min(s*2,o.most)}}export async function resumeJob(t,e,i){const n=await pt(t,e);if(i.tool!==void 0&&i.tool!==n.tool)throw new d("wrong-job",`Job ${e} is ${n.tool}'s, not ${i.tool}'s.`,{exit:p.usage,hint:`Resume it with ${n.tool}.`});return await callTool(t,n.tool,n.input,{...i,outDir:n.outDir,...n.file===void 0?{}:{file:n.file},jobId:e})}
5
+ `)}const P=(t,e)=>q(C(t,e),{force:!0});async function ht(t,e,i){const n=await Y(E(t)).catch(()=>[]);for(const o of n.filter(s=>s.endsWith(".json")).sort()){const s=await T(j(E(t),o),"utf8").then(r=>JSON.parse(r)).catch(()=>{});if(s?.jobId!==void 0&&s.file===e&&s.inputHash===i)return s.jobId}}async function pt(t,e){try{return JSON.parse(await T(C(t,e),"utf8"))}catch{throw new d("unknown-job",`No job ${e} was started on this computer.`,{exit:p.notFound,hint:"Call the tool again: that is a new call."})}}async function B(t,e,i,n,o){const{url:s}=Q.parse(await t.json(tt(e,"attachment"),{signal:v(o)}));let r;try{const u=await t.config.fetch(s,o?{signal:o}:{});if(!u.ok)throw new d("download-failed",`Downloading ${i} answered ${String(u.status)}.`,{exit:p.platform,status:u.status});r=Buffer.from(await u.arrayBuffer())}catch(u){throw u instanceof d||o?.aborted===!0?u:new d("network",`Downloading ${i} failed: ${u instanceof Error?u.message:String(u)}`,{exit:p.platform,cause:u})}const w="dir"in n?j(n.dir,$(n.name??i)):S(n.file)?n.file:`${n.file}${S(i)}`;return await A(k(w),{recursive:!0}),await D(w,r),w}const v=t=>t?AbortSignal.any([t,AbortSignal.timeout(READ_SECONDS*1e3)]):AbortSignal.timeout(READ_SECONDS*1e3),z=(t,e)=>new Promise((i,n)=>{const o=setTimeout(i,t*1e3);e?.addEventListener("abort",()=>{clearTimeout(o),n(e.reason instanceof Error?e.reason:new Error("Stopped."))},{once:!0})});export async function callTool(t,e,i,n){const o=n.file,s=await lt(t,i,n.base),r=nt(e,s);let w=n.jobId,u=!1;if(o!==void 0&&w===void 0){w=await ht(t,o,r);const f=w===void 0?await it(o):void 0,l=f?await at(f):void 0;if(n.force===!0)u=l!==void 0;else{if(f&&!l)throw new d("file-exists",`${f} is there, without a record (${$(L(f))}) saying a tool call made it.`,{exit:p.conflict,hint:"Choose another --file, or pass --force to replace it."});if(f&&l){if(l.tool===e&&l.inputHash===r)return{tool:e,output:typeof l.output?.allyFilePath=="string"?l.output:JSON.parse(await T(f,"utf8")),file:f,gen:L(f),kept:{at:l.at}};throw new d("file-exists",`${f} was made by ${l.tool??"another tool"} from another input on ${l.at}.`,{exit:p.conflict,hint:"Choose another --file to keep it, or pass --force to make it again over it (charged again)."})}}}const m=Date.now()+(n.timeoutSeconds??WAIT_SECONDS)*1e3,g=n.signal;let a=w===void 0?R.parse(await t.json(et(e),{method:"POST",body:{input:i},idempotencyKey:X(),...g?{signal:g}:{}})):await G(t,w,m,n);a.status==="working"&&w===void 0&&await wt(t,a.id,{jobId:a.id,tool:e,input:{...i},inputHash:r,outDir:n.outDir,...o===void 0?{}:{file:o}});const K=()=>({tool:e,jobId:a.id,status:"running",elapsedSeconds:(Date.now()-Date.parse(a.createdAt))/1e3,...o===void 0?{}:{file:o}});for(;a.status==="working";){if(n.wait===!1||Date.now()>m)return K();n.onRunning?.(a),await z(Math.min(Math.max((a.pollAfterMs??0)/1e3,POLL_SECONDS.least),POLL_SECONDS.most),g),a=await G(t,a.id,m,n)}if(a.status==="failed")throw await P(t,a.id),new d(`tool-${(a.error?.kind??"failed").replaceAll("_","-")}`,a.error?.message??"The tool failed.",{exit:a.error?.kind==="input"?p.usage:p.platform,hint:a.error?.kind==="input"||a.error?.kind==="not_found"?"A failed call is not charged. Change the input and call again.":a.error?.kind==="unavailable"?"A failed call is not charged. Calling it again will not help until AllyHub sets it up or fixes it.":"A failed call is not charged."});if(a.status!=="completed")throw new d("tool-state",`The call ${a.id} is ${a.status}, a state this version of allyhub does not know.`,{exit:p.platform,hint:"Update allyhub in the project (npm install allyhub@latest) and call it again."});const h=typeof a.output=="object"&&a.output!==null?a.output:{value:a.output},J=h.allyFilePath,y=typeof J=="string"?I(J):void 0,b=!y&&o!==void 0?await dt(o,h):void 0,c={tool:e,output:h,outputFile:b??await ct(n.outputDir??n.outDir,e,i,a.id,h),...a.credits===void 0?{}:{credits:a.credits},...a.creditsLeft===void 0?{}:{creditsLeft:a.creditsLeft}};if(y){const f=a.id,l=await _(f,()=>B(t,y.id,y.name,o!==void 0?{file:o}:{dir:n.outDir,name:W(y.name,f)},g),m,n);c.file=l,c.gen=await H(l,await U(l,{tool:e,input:s,output:h,credits:a.credits}));const x=ot(h),N=h.durationSeconds;x&&(c.words=await rt(l,x,typeof N=="number"&&N>=0?N:void 0)),u&&(c.replaced=!0)}else b!==void 0&&(c.file=b,c.gen=await H(b,await U(b,{tool:e,input:s,output:h,credits:a.credits})),u&&(c.replaced=!0));const O={},Z=c.file===void 0?n.outDir:k(c.file),F=c.file;for(const f of mt(h)){const l=I(f);if(!l)continue;const x=F===void 0?W(l.name,a.id):`${$(F,S(F))}.${$(l.name)}`;O[f]=await _(a.id,()=>B(t,l.id,l.name,{dir:Z,name:x},g),m,n)}return Object.keys(O).length>0&&(c.more=O),await P(t,a.id),c}function mt(t){const e=[],i=(n,o)=>{if(Array.isArray(n))for(const s of n)i(s,!1);else if(typeof n=="object"&&n!==null)for(const[s,r]of Object.entries(n))s==="allyFilePath"&&!o&&typeof r=="string"?e.push(r):i(r,!1)};return i(t,!0),e}async function G(t,e,i,n){try{return await _(e,async()=>R.parse(await t.json(V(e),{signal:v(n.signal)})),i,n)}catch(o){throw o instanceof d&&o.status===404&&await P(t,e),o}}async function _(t,e,i,n){const o=n.retrySeconds??RETRY_SECONDS;for(let s=o.least;;)try{return await e()}catch(r){if(!ft(r)||n.signal?.aborted===!0)throw r;if(Date.now()+s*1e3>i)throw new d(r.code,r.message,{exit:r.exit,...r.status===void 0?{}:{status:r.status},hint:`Call ${t} goes on at AllyHub, charged once when it works: --resume ${t} waits for it again (so does the same call to the same --file).`,cause:r});n.onRetry?.(t,r,s),await z(s,n.signal),s=Math.min(s*2,o.most)}}export async function resumeJob(t,e,i){const n=await pt(t,e);if(i.tool!==void 0&&i.tool!==n.tool)throw new d("wrong-job",`Job ${e} is ${n.tool}'s, not ${i.tool}'s.`,{exit:p.usage,hint:`Resume it with ${n.tool}.`});return await callTool(t,n.tool,n.input,{...i,outDir:n.outDir,...n.file===void 0?{}:{file:n.file},jobId:e})}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{AsyncLocalStorage as _}from"node:async_hooks";import{createHash as b}from"node:crypto";import{BACKGROUND_HEADER as A,DEVICE_HEADER as E,ORGANIZATION_HEADER as g}from"@allyhub/protocol/auth";import{COMMAND_LINE_PAYWALL_MET as O,paywallNumbersOfData as k,paywallReasonOfCode as S}from"@allyhub/protocol/paywall";import{EXIT as r}from"@allyhub/protocol/cli";import{IDEMPOTENCY_KEY_HEADER as $,planPageAddress as p}from"@allyhub/protocol/cloud";import{accessOf as N,SignedOut as x}from"./credentials.js";import{userAgent as z}from"./device.js";import{CloudError as l,notSignedIn as y,unreachable as m}from"./errors.js";export function scrub(u,n){let t=u.replace(/(authorization)\s*[:=]\s*[^\r\n]+/giu,"$1: <redacted>");return t=t.replace(/\bahk_[A-Za-z0-9_-]+/gu,"<api-key>"),t=t.replace(/\beyJ[\w-]+\.[\w-]+\.[\w-]+/gu,"<token>"),n&&(t=t.split(n).join("<key>")),t}const I="/api/tools",w=new _;export function callsMadeInBackground(u){return w.run(!0,u)}export class Cloud{config;constructor(n){this.config=n}async tellStudio(n,t,i){const s=this.config.studioHost;if(s===void 0)return;const c={reason:n,what:t.startsWith(I)?"tool":"command",numbers:k(i)},e=(d,o)=>fetch(`${s}/${d}`,{method:"POST",signal:AbortSignal.timeout(1e3),...o===void 0?{}:{headers:{"content-type":"application/json"},body:o}}).then(async f=>(await f.body?.cancel(),f.status),()=>{});await e(O,JSON.stringify(c))===404&&n==="insufficient_credits"&&await e("out-of-credits")}get url(){return this.config.url}async key(n={}){const t=this.config.apiKey;if(t)return{key:t,source:"env",account:b("sha256").update(t).digest("hex")};try{const i=await N(this.config,n);if(!i)return;const s=i.credentials.account.organization?.id,c=i.credentials.device;return{key:i.token,source:"oauth",account:i.credentials.account.id,expiresAt:i.expiresAt,...s===void 0?{}:{organization:s},...c===void 0?{}:{device:c}}}catch(i){if(i instanceof x)return;throw m(this.url,i)}}async requireKey(){const n=await this.key();if(!n)throw y();return n}keyedFetch=async(n,t)=>{const i=this.config.client===void 0?void 0:await z(this.config.client),s=d=>{const o=new Headers(t?.headers);return o.set("authorization",`Bearer ${d.key}`),i!==void 0&&!o.has("user-agent")&&o.set("user-agent",i),this.config.traceparent!==void 0&&!o.has("traceparent")&&o.set("traceparent",this.config.traceparent),d.organization!==void 0&&!o.has(g)&&o.set(g,d.organization),d.device!==void 0&&o.set(E,d.device),w.getStore()===!0&&o.set(A,"1"),this.config.fetch(n,{...t,headers:o})},c=await this.requireKey(),e=await s(c);if(e.status!==401||c.source!=="oauth"||t?.body instanceof ReadableStream||n instanceof Request)return e;const a=await this.key({refused:c.key});return a===void 0?e:(await e.body?.cancel(),s(a))};async json(n,t={}){const i=t.auth!==!1,s=i?await this.requireKey():void 0,c=s?.key,e=t.organization??s?.organization;let a;try{a=await(i?this.keyedFetch:this.config.fetch)(`${this.url}${n}`,{redirect:"error",signal:t.signal??AbortSignal.timeout(3e4),method:t.method??"GET",headers:{accept:"application/json",...t.body===void 0?{}:{"content-type":"application/json"},...t.organization===void 0?{}:{[g]:t.organization},...t.idempotencyKey===void 0?{}:{[$]:t.idempotencyKey}},...t.body===void 0?{}:{body:JSON.stringify(t.body)}})}catch(h){throw h instanceof l?h:m(this.url,h)}const d=await a.text(),o=a.ok?void 0:T(d,a.status,c,this.url,e),f=S(o?.code);if(f!==void 0&&await this.tellStudio(f,n,o?.data),o&&a.status!==401)throw o;if(a.status===403)throw new l("forbidden","This AllyHub account does not have access to this operation.",{exit:r.auth,status:403});if(a.status===401)throw y(i?"This computer's AllyHub sign-in is not valid any more.":void 0);if(!a.ok)throw new l("api-error",`${this.url}${n} answered ${String(a.status)}: ${scrub(d.slice(0,300),c)}`,{exit:a.status>=500?r.platform:r.usage,status:a.status});if(a.status!==204)try{return JSON.parse(d)}catch{throw new l("api-error",`${this.url}${n} did not answer JSON.`,{exit:r.platform,status:a.status})}}}const R={bad_input:r.usage,insufficient_credits:r.auth,plan_required:r.auth,tool_off:r.auth,storage_full:r.auth,limit_reached:r.auth,forbidden:r.auth,not_found:r.notFound,conflict:r.conflict,cli_outdated:r.platform};function T(u,n,t,i,s){let c;try{c=JSON.parse(u)}catch{return}const e=c?.error;if(typeof e?.code!="string"||typeof e.message!="string")return;const a=e.code==="insufficient_credits"?`Buy credits at ${p(i,{organization:s,open:"credits"})}, or ask an owner or admin of the team to.`:e.code==="plan_required"?`Subscribe at ${p(i,{organization:s,open:"plans"})}, or ask an owner or admin of the team to.`:e.code==="tool_off"?`Turn it on in Capabilities at ${i}/, or ask an owner or admin of the team to.`:typeof e.hint=="string"?e.hint:void 0;return new l(e.code.replaceAll("_","-"),scrub(e.message,t),{exit:R[e.code]??r.platform,status:n,...a===void 0?{}:{hint:a},...typeof e.data=="object"&&e.data!==null?{data:e.data}:{}})}
2
+ import{AsyncLocalStorage as _}from"node:async_hooks";import{createHash as b}from"node:crypto";import{BACKGROUND_HEADER as A,DEVICE_HEADER as E,ORGANIZATION_HEADER as g}from"@allyhub/protocol/auth";import{COMMAND_LINE_PAYWALL_MET as O,paywallNumbersOfData as k,paywallReasonOfCode as S}from"@allyhub/protocol/paywall";import{EXIT as r}from"@allyhub/protocol/cli";import{IDEMPOTENCY_KEY_HEADER as $,planPageAddress as p}from"@allyhub/protocol/cloud";import{accessOf as N,SignedOut as x}from"./credentials.js";import{userAgent as z}from"./device.js";import{CloudError as l,notSignedIn as y,unreachable as m}from"./errors.js";export function scrub(d,i){let t=d.replace(/(authorization)\s*[:=]\s*[^\r\n]+/giu,"$1: <redacted>");return t=t.replace(/\bahk_[A-Za-z0-9_-]+/gu,"<api-key>"),t=t.replace(/\beyJ[\w-]+\.[\w-]+\.[\w-]+/gu,"<token>"),i&&(t=t.split(i).join("<key>")),t}const I="/api/tools",w=new _;export function callsMadeInBackground(d){return w.run(!0,d)}export class Cloud{config;constructor(i){this.config=i}async tellStudio(i,t,n){const s=this.config.studioHost;if(s===void 0)return;const c={reason:i,what:t.startsWith(I)?"tool":"command",numbers:k(n)},e=(u,o)=>fetch(`${s}/${u}`,{method:"POST",signal:AbortSignal.timeout(1e3),...o===void 0?{}:{headers:{"content-type":"application/json"},body:o}}).then(async f=>(await f.body?.cancel(),f.status),()=>{});await e(O,JSON.stringify(c))===404&&i==="insufficient_credits"&&await e("out-of-credits")}get url(){return this.config.url}async key(i={}){const t=this.config.apiKey;if(t)return{key:t,source:"env",account:b("sha256").update(t).digest("hex")};try{const n=await N(this.config,i);if(!n)return;const s=n.credentials.account.organization?.id,c=n.credentials.device;return{key:n.token,source:"oauth",account:n.credentials.account.id,expiresAt:n.expiresAt,...s===void 0?{}:{organization:s},...c===void 0?{}:{device:c}}}catch(n){if(n instanceof x)return;throw m(this.url,n)}}async requireKey(){const i=await this.key();if(!i)throw y();return i}keyedFetch=async(i,t)=>{const n=this.config.client===void 0?void 0:await z(this.config.client),s=u=>{const o=new Headers(t?.headers);return o.set("authorization",`Bearer ${u.key}`),n!==void 0&&!o.has("user-agent")&&o.set("user-agent",n),this.config.traceparent!==void 0&&!o.has("traceparent")&&o.set("traceparent",this.config.traceparent),u.organization!==void 0&&!o.has(g)&&o.set(g,u.organization),u.device!==void 0&&o.set(E,u.device),w.getStore()===!0&&o.set(A,"1"),this.config.fetch(i,{...t,headers:o})},c=await this.requireKey(),e=await s(c);if(e.status!==401||c.source!=="oauth"||t?.body instanceof ReadableStream||i instanceof Request)return e;const a=await this.key({refused:c.key});return a===void 0?e:(await e.body?.cancel(),s(a))};async json(i,t={}){const n=t.auth!==!1,s=n?await this.requireKey():void 0,c=s?.key,e=t.organization??s?.organization;let a;try{a=await(n?this.keyedFetch:this.config.fetch)(`${this.url}${i}`,{redirect:"error",signal:t.signal??AbortSignal.timeout(3e4),method:t.method??"GET",headers:{accept:"application/json",...t.body===void 0?{}:{"content-type":"application/json"},...t.organization===void 0?{}:{[g]:t.organization},...t.idempotencyKey===void 0?{}:{[$]:t.idempotencyKey}},...t.body===void 0?{}:{body:JSON.stringify(t.body)}})}catch(h){throw h instanceof l?h:m(this.url,h)}const u=await a.text(),o=a.ok?void 0:D(u,a.status,c,this.url,e),f=S(o?.code);if(f!==void 0&&await this.tellStudio(f,i,o?.data),o&&a.status!==401)throw o;if(a.status===403)throw new l("forbidden","This AllyHub account does not have access to this operation.",{exit:r.auth,status:403});if(a.status===401)throw y(n?"This computer's AllyHub sign-in is not valid any more.":void 0);if(!a.ok)throw new l("api-error",`${this.url}${i} answered ${String(a.status)}: ${scrub(u.slice(0,300),c)}`,{exit:a.status>=500?r.platform:r.usage,status:a.status});if(a.status!==204)try{return JSON.parse(u)}catch{throw new l("api-error",`${this.url}${i} did not answer JSON.`,{exit:r.platform,status:a.status})}}}const R={bad_input:r.usage,insufficient_credits:r.auth,plan_required:r.auth,tool_off:r.auth,storage_full:r.auth,limit_reached:r.auth,forbidden:r.auth,not_found:r.notFound,conflict:r.conflict,cli_outdated:r.platform},T=d=>d.code==="limit_reached"&&typeof d.data=="object"&&d.data!==null&&d.data.reason==="calls_an_hour";function D(d,i,t,n,s){let c;try{c=JSON.parse(d)}catch{return}const e=c?.error;if(typeof e?.code!="string"||typeof e.message!="string")return;const a=e.code==="insufficient_credits"?`Buy credits at ${p(n,{organization:s,open:"credits"})}, or ask an owner or admin of the team to.`:e.code==="plan_required"?`Subscribe at ${p(n,{organization:s,open:"plans"})}, or ask an owner or admin of the team to.`:e.code==="tool_off"?`Turn it on in Capabilities at ${n}/, or ask an owner or admin of the team to.`:typeof e.hint=="string"?T(e)?`${e.hint.replace(/\.$/u,"")} (${n}/).`:e.hint:void 0;return new l(e.code.replaceAll("_","-"),scrub(e.message,t),{exit:R[e.code]??r.platform,status:i,...a===void 0?{}:{hint:a},...typeof e.data=="object"&&e.data!==null?{data:e.data}:{}})}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/cloud",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/components",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export{PING_MS,RAW_PATH,RPC_PATH,forwardedHost,startDevServer}from"./server.js";export{ProjectServer,SERVER_METHODS}from"./project.js";export{Writer,LIST_LIMIT,UPLOAD_MAX_BYTES}from"./writer.js";export{DELETED_FILE,TRASH_KEPT_DAYS,movesOfDeletion}from"./deletion.js";export{Watcher}from"./watcher.js";export{Presence}from"./presence.js";export{changedLines}from"./texts.js";export{writeProblems,dataFileOf}from"./validate.js";export{pathProblem,versionOf}from"./paths.js";export{SETTLE_MS}from"./background.js";export{recordTree}from"./record.js";export{itemPreview,projectName}from"./card.js";export{downloadsFolder,hasFileManager,revealFile}from"./reveal.js";
2
+ export{PING_MS,RAW_PATH,RPC_PATH,forwardedHost,startDevServer}from"./server.js";export{ProjectServer,SERVER_METHODS}from"./project.js";export{Writer,LIST_LIMIT,UPLOAD_MAX_BYTES}from"./writer.js";export{DELETED_FILE,TRASH_KEPT_DAYS,emptyTrashOlderThan,movesOfDeletion,utcStampOf}from"./deletion.js";export{Watcher}from"./watcher.js";export{Presence}from"./presence.js";export{changedLines}from"./texts.js";export{writeProblems,dataFileOf}from"./validate.js";export{pathProblem,versionOf}from"./paths.js";export{SETTLE_MS}from"./background.js";export{PageNotRecordedWholeError,recordTree}from"./record.js";export{itemPreview,projectName}from"./card.js";export{downloadsFolder,hasFileManager,revealFile}from"./reveal.js";
@@ -1,2 +1,3 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{readFile as ie,readdir as re,realpath as ae,stat as ce}from"node:fs/promises";import{setTimeout as de}from"node:timers/promises";import{join as P,relative as fe,sep as le}from"node:path";import{openPage as ue}from"@allyhub/browser";import{KeyedStore as pe}from"@allyhub/project";import{NEVER_CANCELLED as me}from"@allyhub/extension-api";import{COMPONENT_STILLS_MAX as X,KindSnapshotSchema as he,RpcError as Q,SNAPSHOT_TREE as b,pieceSourcePath as we,snapshotAnswerPath as N,snapshotPreviewPath as ge,stillPath as Y,stillsIndexKey as ye,stillsIndexPath as be}from"@allyhub/protocol";import{runtimeFiles as ke}from"@allyhub/stage-page";import{itemPreview as $e}from"./card.js";import{offlinePage as Se}from"./offline-page.js";import{kindContext as Ee,kindItem as Pe}from"./kinds.js";import{USE_FORMS as ve,mediaTypeOf as W,servedPage as Me}from"@allyhub/formats";import{Reach as je,pieceBundle as Te,pieceNames as xe,reachedCheck as Ie,reachedSource as Oe}from"./reach.js";import{matteFile as Ne}from"./tree.js";const Re="assets/";export const PAGE_RECORDING={width:1440,height:900,timeout:3e4,settle:1500};const R="https://tree.invalid/";function B(i){return typeof i=="string"?i.startsWith(R)?i.slice(R.length):i:Array.isArray(i)?i.map(B):i!==null&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([S,c])=>[S,B(c)])):i}const T=i=>new TextEncoder().encode(JSON.stringify(i));async function Z(i){return(await re(i,{recursive:!0,withFileTypes:!0}).catch(()=>[])).filter(c=>c.isFile()).map(c=>fe(i,P(c.parentPath,c.name)).split(le).join("/"))}const Ae=i=>ce(i).then(S=>S.isFile(),()=>!1);export async function recordTree(i,S={}){const{project:c}=i,{live:p,root:y}=c;await c.watcher.settled();const k=new Map,g=(e,t,o=W(e))=>{k.set(e,{path:e,type:o,file:t})},C=(e,t)=>{k.set(e,{path:e,type:W(e),file:t,immutable:!0})},v=(e,t,o=W(e))=>{k.set(e,{path:e,type:o,bytes:t})},D=async(e,t)=>{for(const o of await Z(t))g(`${e}${o}`,P(t,o))},ee=p.revision,d=await p.prepared(),A=new Map;if(i.ui!==void 0)for(const e of await Z(i.ui))(e.startsWith(Re)?C:g)(`${b.editor}${e}`,P(i.ui,e));for(const[e,t]of await ke())g(`${b.runtime}${e}`,t);const I=async(e,t)=>{let o;try{o={result:B(await c.tool(e,t,{tree:R}))}}catch(n){o={error:n instanceof Q?{code:n.code,message:n.message}:{code:-32603,message:n instanceof Error?n.message:""}}}const r=N(e,t);v(r,T(o));const f=t.item;return typeof f=="string"&&A.set(f,[...A.get(f)??[],r]),o},te=Ee(y,e=>c.hasTool(e),async(e,t)=>{const o=await I(e,t);if(o.error)throw new Q(o.error.code,o.error.message);return o.result}),oe=async(e,t,o)=>{const r=new Map;for(const s of o)r.set(ye(s),s);if(r.size===0)return;const f=pe.of(y,"stills"),n={stills:{}},E=h.of(e),m=[...r];for(let s=0;s<m.length;s+=X){const w=m.slice(s,s+X);(await c.tool("components/stills",{item:e,...t===""?{}:{version:t},components:w.map(([,u])=>u)},{tree:R}).catch(()=>{}))?.stills.forEach((u,$)=>{const x=w[$]?.[0];!u||x===void 0||(n.stills[x]=u.key,g(Y(u.key),f.path(`${u.key}.webp`),"image/webp"),E?.tree.add(Y(u.key)))})}const a=be(e,t);v(a,T(n),"application/json"),E?.tree.add(a)},q=(await I("project/items",{})).result,O=q?.items??[],F=O.filter(e=>e.kind!==void 0),G=O.filter(e=>e.kind===void 0&&e.kindInfo?.share===!0),se=new Map(d.items.map(e=>[e.id,e.files])),h=new je([...F.map(e=>({...e,files:se.get(e.id)??e.files})),...G],d.files,(d.bundle?.beside??[]).map(e=>`${b.build}${e}`)),M=c.checker?.state,J=M===void 0||M.status==="waiting"||M.status==="running"?{status:"off",revision:p.revision,problems:M?.problems??[],facts:M?.facts??[]}:M;v(N("check/results",{}),T({result:J}));for(const e of h.items){const t=h.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||h.itemsOf(n).includes(e);t?.own.push({path:N("project/items",{}),type:"application/json",bytes:T({result:{...q,items:O.filter(n=>n.id===e)}})},{path:N("check/results",{}),type:"application/json",bytes:T({result:Ie(J,o,f)})})}for(const e of d.bundle?.chunks.files??[])C(`${b.build}${e}`,P(p.pieceDir,e));for(const e of d.bundle?.beside??[])await D(`${b.build}${e}`,P(p.pieceDir,e));const K=new Set(Object.keys(d.media));for(const e of Object.keys(d.media)){const t=Ne(y,d.media[e]);t!==void 0&&await Ae(t)&&g(`${b.matte}${e}`,t,"video/mp4")}const _=new Map,L=new Map,ne=c.extensions?.fileEditors()??[];for(const e of G)ne.some(t=>t.id===e.kindInfo?.editor&&t.page)&&(_.set(e.id,{}),L.set(e.id,e.entry));const U=new Map,z=e=>({file:(t,o,r)=>{g(`${e}${t}`,o,r)},folder:(t,o)=>D(`${e}${t}`,o),bytes:(t,o,r)=>{v(`${e}${t}`,o,r)},media:t=>{K.add(t)}});for(const e of F){const t=await c.extensions?.kindProvider(e.kind);if(!t?.snapshot)continue;const o=await Promise.resolve(t.snapshot(Pe(e),te,me)).catch(()=>{}),r=he.safeParse(o??{});if(!r.success)continue;const{stills:f,shows:n,routes:E,page:m}=r.data;m&&(_.set(e.id,{...m.folder===void 0?{}:{folder:m.folder},...m.file===void 0?{}:{file:m.file}}),p.kinds.some(a=>a.id===e.kind&&a.network===!0)&&L.set(e.id,m.file??e.entry)),n&&U.set(e.id,{media:new Set(n.media),data:new Set(n.data)});for(const a of f??[])await I("components/stage",{item:e.id,version:a.version}),a.version===""&&await I("components/stage",{item:e.id}),await oe(e.id,a.version,a.components);for(const[a,s]of Object.entries(E??{})){const w=await p.routes.route(a).catch(()=>{});if(w?.route.recordItem)for(const l of s)await w.route.recordItem(l,z(a),w.context).catch(()=>{})}}for(const e of K)g(`${b.media}${e}`,P(y,e));for(const[e,t]of _){const o=await c.tool("items/page",{item:e,...t}).catch(()=>{});if(!o)continue;const r=new URL(o.url).origin,f=L.get(e),n=await ue(await p.browser(),{width:PAGE_RECORDING.width,height:PAGE_RECORDING.height,allow:l=>l===r||l.startsWith(`${r}/`)||f!==void 0&&l.startsWith("https://")}).catch(()=>{});if(!n)continue;const E=[],m=[];try{if(f!==void 0){const l=n.session,u=new Map;l.on("Network.responseReceived",$=>{$.response.url.startsWith("https://")&&$.response.status===200&&u.set($.requestId,{url:$.response.url,mime:$.response.mimeType})}),l.on("Network.loadingFinished",$=>{const x=u.get($.requestId);x&&m.push(l.send("Network.getResponseBody",{requestId:$.requestId}).then(j=>{E.push({...x,body:j.base64Encoded?Buffer.from(j.body,"base64"):new TextEncoder().encode(j.body)})},j=>{if(!(j instanceof Error))throw j}))}),await l.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 de(PAGE_RECORDING.settle)}catch{}finally{await Promise.allSettled(m),await n.close()}if(f===void 0)continue;const a=await ie(P(y,f),"utf8").catch(()=>{});if(a===void 0)continue;const s=Me(a,f,d.data).html;let w=Se(f,s,E);w.length===0&&s!==a&&(w=[{path:f,type:"text/html; charset=utf-8",bytes:new TextEncoder().encode(s)}]);for(const l of w){const u=`${b.pages}${l.path}`;v(u,l.bytes,l.type),h.of(e)?.tree.add(u)}}for(const e of h.items){const t=h.of(e);if(t)for(const o of c.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 p.routes.specs.keys()){const t=await p.routes.route(e).catch(()=>{});t?.route.record&&await t.route.record(z(e),t.context).catch(()=>{})}const H=[y,await ae(y).catch(()=>y)];for(const e of d.pieces){const t=await p.source(e.id).catch(()=>{});if(!t)continue;const o=[e,...d.pieces.filter(s=>Fe(d.items,e.place).has(s.place))],r=o.map(s=>({p:s,bundle:Te(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:w}of r){const l=xe({prepared:d,piece:s,reach:h,modules:w.modules,roots:H,reads:c.checker?.reads.get(s.id),shows:U.get(s.place)});for(const u of l.media)n.media.add(u);for(const u of l.data)n.data.add(u)}const E=d.pieces.filter(s=>!o.includes(s)&&!H.some(w=>f.modules.has(P(w,s.file)))).map(s=>s.id),m=we(e.id);v(m,T(Oe(t,n,E)));const a=h.of(e.place);if(a){a.tree.add(m);for(const s of f.files)a.tree.add(`${b.build}${s}`);for(const s of n.media)a.tree.add(`${b.media}${s}`),a.tree.add(`${b.matte}${s}`),a.files.add(s)}}for(const[e,t]of A)for(const o of t)h.of(e)?.tree.add(o);for(const e of d.docs)for(const t of e.shows)h.of(e.place)?.files.add(t);for(const e of d.sheets)for(const t of e.files)h.of(e.place)?.files.add(t);const V=S.preview===!1?void 0:S.preview??(e=>$e(i,e));if(V)for(const e of F){const t=await V(e).catch(()=>{});if(t===void 0)continue;const o=ge(e.id);v(o,Buffer.from(JSON.stringify(t)),"application/json"),h.of(e.id)?.tree.add(o)}return{revision:ee,files:[...k.values()],reach:h.done(new Set(k.keys())),routes:p.routes.loads()}}function Fe(i,S){const c=new Map(i.map(k=>[k.id,k])),p=new Set,y=k=>{for(const g of c.get(k)?.uses??[])g.type===ve.live&&!p.has(g.item)&&(p.add(g.item),y(g.item))};return y(S),p}
2
+ import{readFile as le,readdir as ue,realpath as pe,stat as me}from"node:fs/promises";import{setTimeout as he}from"node:timers/promises";import{join as N,relative as we,sep as ge}from"node:path";import{openPage as ye}from"@allyhub/browser";import{KeyedStore as be}from"@allyhub/project";import{NEVER_CANCELLED as $e}from"@allyhub/extension-api";import{COMPONENT_STILLS_MAX as te,KindSnapshotSchema as ke,RpcError as oe,SNAPSHOT_TREE as E,pieceSourcePath as Se,snapshotAnswerPath as F,snapshotPreviewPath as Ee,stillPath as se,stillsIndexKey as Pe,stillsIndexPath as ve}from"@allyhub/protocol";import{runtimeFiles as xe}from"@allyhub/stage-page";import{itemPreview as Me}from"./card.js";import{offlinePage as Ne}from"./offline-page.js";import{kindContext as Te,kindItem as je}from"./kinds.js";import{USE_FORMS as Ie,mediaTypeOf as L,servedPage as Oe}from"@allyhub/formats";import{Reach as Re,pieceBundle as Ae,pieceNames as Fe,reachedCheck as We,reachedSource as _e}from"./reach.js";import{matteFile as qe}from"./tree.js";const De="assets/";export class PageNotRecordedWholeError extends Error{name="PageNotRecordedWholeError"}const C=i=>i.replace(/[?#].*$/su,""),Be=(i,u)=>{process.stderr.write(`${i} failed: ${u instanceof Error?u.stack??u.message:String(u)}
3
+ `)};export const PAGE_RECORDING={width:1440,height:900,timeout:3e4,settle:1500};const W="https://tree.invalid/";function G(i){return typeof i=="string"?i.startsWith(W)?i.slice(W.length):i:Array.isArray(i)?i.map(G):i!==null&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([u,d])=>[u,G(d)])):i}const I=i=>new TextEncoder().encode(JSON.stringify(i));async function ne(i){return(await ue(i,{recursive:!0,withFileTypes:!0}).catch(()=>[])).filter(d=>d.isFile()).map(d=>we(i,N(d.parentPath,d.name)).split(ge).join("/"))}const Le=i=>me(i).then(u=>u.isFile(),()=>!1);export async function recordTree(i,u={}){const{project:d}=i,{live:l,root:k}=d;await d.watcher.settled();const P=new Map,b=(e,t,o=L(e))=>{P.set(e,{path:e,type:o,file:t})},J=(e,t)=>{P.set(e,{path:e,type:L(e),file:t,immutable:!0})},T=(e,t,o=L(e))=>{P.set(e,{path:e,type:o,bytes:t})},K=async(e,t)=>{for(const o of await ne(t))b(`${e}${o}`,N(t,o))},ie=l.revision,f=await l.prepared(),_=new Map;if(i.ui!==void 0)for(const e of await ne(i.ui))(e.startsWith(De)?J:b)(`${E.editor}${e}`,N(i.ui,e));for(const[e,t]of await xe())b(`${E.runtime}${e}`,t);const O=async(e,t)=>{let o;try{o={result:G(await d.tool(e,t,{tree:W}))}}catch(n){o={error:n instanceof oe?{code:n.code,message:n.message}:{code:-32603,message:n instanceof Error?n.message:""}}}const r=F(e,t);T(r,I(o));const p=t.item;return typeof p=="string"&&_.set(p,[..._.get(p)??[],r]),o},re=Te(k,e=>d.hasTool(e),async(e,t)=>{const o=await O(e,t);if(o.error)throw new oe(o.error.code,o.error.message);return o.result}),ae=async(e,t,o)=>{const r=new Map;for(const s of o)r.set(Pe(s),s);if(r.size===0)return;const p=be.of(k,"stills"),n={stills:{}},$=w.of(e),m=[...r];for(let s=0;s<m.length;s+=te){const g=m.slice(s,s+te);(await d.tool("components/stills",{item:e,...t===""?{}:{version:t},components:g.map(([,h])=>h)},{tree:W}).catch(()=>{}))?.stills.forEach((h,a)=>{const M=g[a]?.[0];!h||M===void 0||(n.stills[M]=h.key,b(se(h.key),p.path(`${h.key}.webp`),"image/webp"),$?.tree.add(se(h.key)))})}const c=ve(e,t);T(c,I(n),"application/json"),$?.tree.add(c)},U=(await O("project/items",{})).result,R=U?.items??[],q=R.filter(e=>e.kind!==void 0),z=R.filter(e=>e.kind===void 0&&e.kindInfo?.share===!0),ce=new Map(f.items.map(e=>[e.id,e.files])),w=new Re([...q.map(e=>({...e,files:ce.get(e.id)??e.files})),...z],f.files,(f.bundle?.beside??[]).map(e=>`${E.build}${e}`)),j=d.checker?.state,H=j===void 0||j.status==="waiting"||j.status==="running"?{status:"off",revision:l.revision,problems:j?.problems??[],facts:j?.facts??[]}:j;T(F("check/results",{}),I({result:H}));for(const e of w.items){const t=w.of(e),o=new Set(f.pieces.filter(n=>n.place===e).map(n=>n.id)),r=R.find(n=>n.id===e)?.entry,p=n=>n===r||w.itemsOf(n).includes(e);t?.own.push({path:F("project/items",{}),type:"application/json",bytes:I({result:{...U,items:R.filter(n=>n.id===e)}})},{path:F("check/results",{}),type:"application/json",bytes:I({result:We(H,o,p)})})}for(const e of f.bundle?.chunks.files??[])J(`${E.build}${e}`,N(l.pieceDir,e));for(const e of f.bundle?.beside??[])await K(`${E.build}${e}`,N(l.pieceDir,e));const V=new Set(Object.keys(f.media));for(const e of Object.keys(f.media)){const t=qe(k,f.media[e]);t!==void 0&&await Le(t)&&b(`${E.matte}${e}`,t,"video/mp4")}const D=new Map,B=new Map,de=d.extensions?.fileEditors()??[];for(const e of z)de.some(t=>t.id===e.kindInfo?.editor&&t.page)&&(D.set(e.id,{}),B.set(e.id,e.entry));const X=new Map,Q=e=>({file:(t,o,r)=>{b(`${e}${t}`,o,r)},folder:(t,o)=>K(`${e}${t}`,o),bytes:(t,o,r)=>{T(`${e}${t}`,o,r)},media:t=>{V.add(t)}});for(const e of q){const t=await d.extensions?.kindProvider(e.kind);if(!t?.snapshot)continue;const o=await Promise.resolve(t.snapshot(je(e),re,$e)).catch(()=>{}),r=ke.safeParse(o??{});if(!r.success)continue;const{stills:p,shows:n,routes:$,page:m}=r.data;m&&(D.set(e.id,{...m.folder===void 0?{}:{folder:m.folder},...m.file===void 0?{}:{file:m.file}}),l.kinds.some(c=>c.id===e.kind&&c.network===!0)&&B.set(e.id,m.file??e.entry)),n&&X.set(e.id,{media:new Set(n.media),data:new Set(n.data)});for(const c of p??[])await O("components/stage",{item:e.id,version:c.version}),c.version===""&&await O("components/stage",{item:e.id}),await ae(e.id,c.version,c.components);for(const[c,s]of Object.entries($??{})){const g=await l.routes.route(c).catch(()=>{});if(g?.route.recordItem)for(const x of s)await g.route.recordItem(x,Q(c),g.context).catch(()=>{})}}for(const e of V)b(`${E.media}${e}`,N(k,e));const A=u.report??Be;for(const[e,t]of D){const o=`Recording the page of ${e}`,r=await d.tool("items/page",{item:e,...t}).then(a=>a,a=>{A(o,a)});if(!r)continue;const p=new URL(r.url).origin,n=B.get(e),$=await ye(await l.browser(),{width:PAGE_RECORDING.width,height:PAGE_RECORDING.height,allow:a=>a===p||a.startsWith(`${p}/`)||n!==void 0&&a.startsWith("https://")}).then(a=>a,a=>{A(o,a)});if(!$)continue;const m=[],c=[],s=[];try{if(n!==void 0){const a=$.session,M=new Map,ee=new Map;a.on("Network.requestWillBeSent",y=>{M.set(y.requestId,y.request.url)}),a.on("Network.responseReceived",y=>{const{url:v,status:S,mimeType:fe}=y.response;S===200&&v.startsWith("https://")?ee.set(y.requestId,{url:v,mime:fe}):S>=400&&s.push(`${y.type==="Document"?"the page":C(v)} answered ${String(S)}`)}),a.on("Network.loadingFailed",y=>{const v=M.get(y.requestId);s.push(`${y.type==="Document"||v===void 0?"the page":C(v)}: ${y.errorText}`)}),a.on("Network.loadingFinished",y=>{const v=ee.get(y.requestId);v&&c.push(a.send("Network.getResponseBody",{requestId:y.requestId}).then(S=>{m.push({...v,body:S.base64Encoded?Buffer.from(S.body,"base64"):new TextEncoder().encode(S.body)})},S=>{if(!(S instanceof Error))throw S;s.push(`${C(v.url)}: ${S.message}`)}))}),await a.send("Network.enable",{})}await $.goto(r.url,{timeoutMs:PAGE_RECORDING.timeout}),await $.evaluate("document.fonts.ready.then(() => true)",{timeoutMs:PAGE_RECORDING.timeout}),await he(PAGE_RECORDING.settle)}catch(a){A(o,a)}finally{await Promise.allSettled(c),await $.close()}if(s.length>0&&A(o,new PageNotRecordedWholeError(`The page of ${e} did not load whole, so what failed is kept online: ${s.join("; ")}.`)),n===void 0)continue;const g=await le(N(k,n),"utf8").catch(()=>{});if(g===void 0)continue;const x=Oe(g,n,f.data).html;let h=Ne(n,x,m);h.length===0&&x!==g&&(h=[{path:n,type:"text/html; charset=utf-8",bytes:new TextEncoder().encode(x)}]);for(const a of h){const M=`${E.pages}${a.path}`;T(M,a.bytes,a.type),w.of(e)?.tree.add(M)}}for(const e of w.items){const t=w.of(e);if(t)for(const o of d.inputs.of(e))if(o===""||o.endsWith("/"))for(const r of f.files)r.startsWith(o)&&t.files.add(r);else f.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(Q(e),t.context).catch(()=>{})}const Y=[k,await pe(k).catch(()=>k)];for(const e of f.pieces){const t=await l.source(e.id).catch(()=>{});if(!t)continue;const o=[e,...f.pieces.filter(s=>Ce(f.items,e.place).has(s.place))],r=o.map(s=>({p:s,bundle:Ae(f.bundle?.chunks,s.id)})),p={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:g}of r){const x=Fe({prepared:f,piece:s,reach:w,modules:g.modules,roots:Y,reads:d.checker?.reads.get(s.id),shows:X.get(s.place)});for(const h of x.media)n.media.add(h);for(const h of x.data)n.data.add(h)}const $=f.pieces.filter(s=>!o.includes(s)&&!Y.some(g=>p.modules.has(N(g,s.file)))).map(s=>s.id),m=Se(e.id);T(m,I(_e(t,n,$)));const c=w.of(e.place);if(c){c.tree.add(m);for(const s of p.files)c.tree.add(`${E.build}${s}`);for(const s of n.media)c.tree.add(`${E.media}${s}`),c.tree.add(`${E.matte}${s}`),c.files.add(s)}}for(const[e,t]of _)for(const o of t)w.of(e)?.tree.add(o);for(const e of f.docs)for(const t of e.shows)w.of(e.place)?.files.add(t);for(const e of f.sheets)for(const t of e.files)w.of(e.place)?.files.add(t);const Z=u.preview===!1?void 0:u.preview??(e=>Me(i,e));if(Z)for(const e of q){const t=await Z(e).catch(()=>{});if(t===void 0)continue;const o=Ee(e.id);T(o,Buffer.from(JSON.stringify(t)),"application/json"),w.of(e.id)?.tree.add(o)}return{revision:ie,files:[...P.values()],reach:w.done(new Set(P.keys())),routes:l.routes.loads()}}function Ce(i,u){const d=new Map(i.map(P=>[P.id,P])),l=new Set,k=P=>{for(const b of d.get(P)?.uses??[])b.type===Ie.live&&!l.has(b.item)&&(l.add(b.item),k(b.item))};return k(u),l}
@@ -1,3 +1,3 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{parse as m}from"yaml";import{kindBuildOf as p,readWork as $}from"@allyhub/build";import{DATA_FILES as f,baseOf as b,listedWork as g}from"@allyhub/formats";const k=r=>new RegExp(`^${r.split("**/").map(a=>a.replace(/[.+?^${}()|[\]\\]/gu,"\\$&").replaceAll("*","[^/]*")).join("(?:.*/)?")}$`,"u"),w=Object.entries(f).flatMap(([r,a])=>a.files.map(n=>({name:r,re:k(n)})));export function dataFileOf(r){return w.find(a=>a.re.test(r))?.name}export async function writeProblems(r,a,n,u,s){const i=b(r),t=g((await $(u)).work).find(e=>e.file.replace(/^\.\//u,"")===r)?.kind;if(t!==void 0&&s){const e=await s(t,a);if(e)return[...e]}else{const e=await p(n.find(d=>d.id===t))?.catch(()=>{});if(e?.unreadable)return[...e.unreadable(a)]}const o=dataFileOf(r);if(o===void 0)return[];let l;try{l=/\.ya?ml$/u.test(i)?m(a):JSON.parse(a)}catch(e){return[`not ${/\.ya?ml$/u.test(i)?"YAML":"JSON"}: ${e.message.split(`
3
- `)[0]??""}`]}const c=f[o].schema.safeParse(l);return c.success?[]:c.error.issues.map(e=>`${e.path.length?`${e.path.join(".")}: `:""}${e.message}`)}
2
+ import{parse as m}from"yaml";import{kindBuildOf as p,readWork as $}from"@allyhub/build";import{DATA_FILES as u,baseOf as g,listedWork as k,readLeavingOutUnknownFields as w}from"@allyhub/formats";const O=a=>new RegExp(`^${a.split("**/").map(n=>n.replace(/[.+?^${}()|[\]\\]/gu,"\\$&").replaceAll("*","[^/]*")).join("(?:.*/)?")}$`,"u"),b=Object.entries(u).flatMap(([a,n])=>n.files.map(r=>({name:a,re:O(r)})));export function dataFileOf(a){return b.find(n=>n.re.test(a))?.name}export async function writeProblems(a,n,r,c,s){const i=g(a),t=k((await $(c)).work).find(e=>e.file.replace(/^\.\//u,"")===a)?.kind;if(t!==void 0&&s){const e=await s(t,n);if(e)return[...e]}else{const e=await p(r.find(f=>f.id===t))?.catch(()=>{});if(e?.unreadable)return[...e.unreadable(n)]}const o=dataFileOf(a);if(o===void 0)return[];let l;try{l=/\.ya?ml$/u.test(i)?m(n):JSON.parse(n)}catch(e){return[`not ${/\.ya?ml$/u.test(i)?"YAML":"JSON"}: ${e.message.split(`
3
+ `)[0]??""}`]}const d=w(u[o].schema,l);return d.success?[]:d.error.issues.map(e=>`${e.path.length?`${e.path.join(".")}: `:""}${e.message}`)}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/dev-server",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/diagnostics",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{absolutePath as R,connectorPath as W,paintRgb as M,pathTip as O,segsD as j}from"@allyhub/blocks";const P=4/3,v=new Set(["rect","ellipse","line","text","poly","path","trend","connector","icon","arc"]),w=t=>t*P;function $(t,o,e=1){const s=M(t,o);if(!s)return"none";const i=(s.alpha??1)*e;return i<1?{color:s.hex,transparency:Math.round((1-i)*100)}:s.hex}function d(t,o,e,s={}){const i=M(t,e);return o<=0||!i?"none":{color:i.hex,width:o,...i.alpha===void 0||i.alpha>=1?{}:{transparency:Math.round((1-i.alpha)*100)},...s.dash===!0?{dash:"dash"}:{},...s.round===!0?{cap:"round",join:"round"}:{},...s.arrow===!0?{endArrow:"triangle"}:{}}}const p=(t,o,e,s)=>({offset:{left:w(t),top:w(o)},width:w(Math.max(0,e)),height:w(Math.max(0,s))});function y(t,o,e,s,i){return{type:"custom",transformation:p(o.x,o.y,o.w,o.h),paths:[{path:`M0 0L${String(o.w)} ${String(o.h)}`,fill:!1,line:!1},...e.map(n=>({path:n}))],fill:s,line:i,altText:{name:t}}}function z(t,o){const e=[o.x,o.x+o.w],s=[o.y,o.y+o.h];for(const r of t)if(r[0]!=="Z")for(let a=1;a+1<r.length;a+=2)e.push(r[a]),s.push(r[a+1]);const i=Math.min(...e),n=Math.min(...s);return{x:i,y:n,w:Math.max(...e)-i,h:Math.max(...s)-n}}function k(t,o,e){const s=t.match(/[MLHVCAZ]|-?[\d.]+(?:e-?\d+)?/giu)??[];let i="",n=0;const r=[];for(const a of s){if(/^[A-Z]$/iu.test(a)){i=a.toUpperCase(),n=0,r.push(i);continue}const h=Number(a),c=i==="H"?"x":i==="V"?"y":i==="A"?n%7===5?"x":n%7===6?"y":"":n%2===0?"x":"y";r.push(String(c==="x"?h-o:c==="y"?h-e:h)),n+=1}return r.join(" ")}function C(t,o,e){const s=t.align==="center"?e.AlignmentType.CENTER:t.align==="right"?e.AlignmentType.RIGHT:e.AlignmentType.LEFT;return t.lines.map(i=>new e.Paragraph({alignment:s,spacing:{before:0,after:0,line:Math.round(t.lineHeight*20),lineRule:"exact"},children:i.runs.map(n=>{const r={text:n.text,size:Math.round(t.size*2),bold:n.bold===!0||(n.weight??t.weight)>=600,...n.italic===!0?{italics:!0}:{},color:M(n.color??t.color,o)?.hex??"000000",...t.caps===!0?{allCaps:!0}:{},...t.tracking===void 0?{}:{characterSpacing:Math.round(t.tracking*t.size*20)}};return new e.TextRun(r)})}))}function H(t,o,e,s){const i=t.part===""?`Shape ${String(o+1)}`:t.part;switch(t.type){case"rect":{const n=M(t.line,e)&&t.lineWidth>0?t.lineWidth/2:0,r=Math.max(0,t.w-2*n),a=Math.max(0,t.h-2*n),h=Math.min(t.r,r/2,a/2),c={transformation:p(t.x+n,t.y+n,r,a),fill:$(t.fill,e),line:d(t.line,t.lineWidth,e),altText:{name:i}};return[h>0?{type:"roundedRectangle",adjustments:{cornerRadius:h/Math.max(.01,Math.min(r,a))*100},...c}:{type:"rectangle",...c}]}case"ellipse":return[{type:"ellipse",transformation:p(t.x,t.y,t.w,t.h),fill:$(t.fill,e),line:d(t.line,t.lineWidth,e),altText:{name:i}}];case"line":{const n=Math.min(t.x1,t.x2),r=Math.min(t.y1,t.y2);return[y(i,{x:n,y:r,w:Math.abs(t.x2-t.x1),h:Math.abs(t.y2-t.y1)},[`M${String(t.x1-n)} ${String(t.y1-r)}L${String(t.x2-n)} ${String(t.y2-r)}`],"none",d(t.color,t.width,e,{dash:t.dash,round:!0}))]}case"connector":{const n=Math.min(t.x1,t.x2),r=Math.min(t.y1,t.y2);return[y(i,{x:n,y:r,w:Math.abs(t.x2-t.x1),h:Math.abs(t.y2-t.y1)},[k(W(t),n,r)],"none",d(t.color,t.width,e))]}case"text":return[{type:"rectangle",transformation:p(t.x,t.y,t.w,t.lines.length*t.lineHeight),fill:"none",line:"none",children:C(t,e,s),textOptions:{verticalAlignment:"top",margins:{top:0,right:0,bottom:0,left:0},wrap:!1},altText:{name:i}}];case"poly":{if(t.points.length===0)return;const n=`${t.points.map(([r,a],h)=>`${h===0?"M":"L"}${String(r)} ${String(a)}`).join("")}Z`;return[y(i,{x:t.x,y:t.y,w:t.w,h:t.h},[n],$(t.fill,e),d(t.line,t.lineWidth,e))]}case"path":{const n=z(t.segs,t),r=M(t.fill,e)!==void 0,a=[y(i,n,[k(j(t.segs,String),n.x,n.y)],r?$(t.fill,e,t.opacity??1):"none",d(t.line,t.lineWidth,e,{round:!0}))],h=t.arrow===!0?O(t.segs):void 0;if(h&&M(t.line,e)){const c=Math.max(3,t.lineWidth*3.5),x=h.x-h.dx*c,S=h.y-h.dy*c,b=-h.dy*c*.55,T=h.dx*c*.55,f=[[h.x,h.y],[x+b,S+T],[x-b,S-T]],g=Math.min(...f.map(l=>l[0])),u=Math.min(...f.map(l=>l[1]));a.push(y(`${i} arrowhead`,{x:g,y:u,w:Math.max(...f.map(l=>l[0]))-g,h:Math.max(...f.map(l=>l[1]))-u},[`${f.map(([l,A],L)=>`${L===0?"M":"L"}${String(l-g)} ${String(A-u)}`).join("")}Z`],$(t.line,e),"none"))}return a}case"trend":{const n=t.values;if(n.length<2)return;const r=t.target===void 0?n:[...n,t.target],a=Math.min(...r),c=Math.max(...r)-a||1,x=u=>t.h-(u-a)/c*t.h,S=u=>u/(n.length-1)*t.w,b=n.map((u,l)=>`${l===0?"M":"L"}${String(S(l))} ${String(x(u))}`).join(""),T=n.length-1,f=t.width*1.4,g=[];if(t.target!==void 0){const u=t.y+x(t.target);g.push(y(`${i} target`,{x:t.x,y:u,w:t.w,h:0},[`M0 0L${String(t.w)} 0`],"none",d("rule-strong",t.width/2,e,{dash:!0})))}return g.push(y(i,{x:t.x,y:t.y,w:t.w,h:t.h},[b],"none",d(t.color,t.width,e,{round:!0})),{type:"ellipse",transformation:p(t.x+S(T)-f,t.y+x(n[T]??0)-f,2*f,2*f),fill:$(t.color,e),line:"none",altText:{name:`${i} last`}}),g}case"icon":return[{type:"custom",transformation:p(t.x,t.y,t.size,t.size),paths:[{path:"M0 0L24 24",fill:!1,line:!1},...t.paths.map(n=>({path:R(n),fill:!1}))],fill:"none",line:d(t.color,t.stroke,e,{round:!0}),altText:{name:i}}];case"arc":{const n=Math.max(0,Math.min(1,t.share));if(n<=0)return[];const r={x:t.cx-t.r,y:t.cy-t.r,w:2*t.r,h:2*t.r},a=d(t.color,t.width,e,{round:!0});if(n>=.9999)return[{type:"ellipse",transformation:p(r.x,r.y,r.w,r.h),fill:"none",line:a,altText:{name:i}}];const h=2*Math.PI*n-Math.PI/2,c=t.r+t.r*Math.cos(h),x=t.r+t.r*Math.sin(h);return[y(i,r,[`M${String(t.r)} 0A${String(t.r)} ${String(t.r)} 0 ${n>.5?"1":"0"} 1 ${String(c)} ${String(x)}`],"none",a)]}default:return}}export function blockShapeGroup(t,o,e,s,i){if(t.marks.some(a=>!v.has(a.type)))return;const n=[{type:"rectangle",transformation:p(0,0,t.width,t.height),fill:"none",line:"none",altText:{name:"Frame"}}];for(const[a,h]of t.marks.entries()){const c=H(h,a,o,e);if(c===void 0)return;n.push(...c)}const r=i.width/w(t.width);return new s.ShapeGroupRun({children:n,transformation:{width:i.width,height:w(t.height)*r},altText:{name:i.name,title:i.name,description:i.description}})}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{blockAlt as f,blockDataTable as m,blockFromFile as s,blockSvg as l,iconPaths as p,paletteOf as g}from"@allyhub/blocks";import{shownPath as u,TONE_COLORS as k,toneOf as h}from"@allyhub/formats";import{chartTheme as c}from"./chart.js";import{PAPER as o,tint as b}from"./paper.js";export const LIBRARY_TAGS={Icon:{kind:"icon"},Progress:{kind:"progress"},Timeline:{kind:"timeline",item:"Milestone"},Steps:{kind:"steps",item:"Step"},Person:{kind:"person"},People:{kind:"people",item:"Person"},RiskMatrix:{kind:"risk_matrix",item:"Entry"},Sankey:{kind:"sankey",item:"Flow"},Gantt:{kind:"gantt",item:"Task"},OrgChart:{kind:"org_chart"},IssueTree:{kind:"issue_tree"},DecisionTree:{kind:"decision_tree"},Fishbone:{kind:"fishbone"},Matrix:{kind:"matrix"},Marimekko:{kind:"marimekko"},Heatmap:{kind:"heatmap"},SmallMultiples:{kind:"small_multiples"}};export function libraryBlockTable(i,r={}){const{def:e}=libraryDef(i,r),t=e===void 0?void 0:m(e,r.lang);if(!(t===void 0||t.rows.length===0))return{type:"table",rows:[t.columns,...t.rows].map(n=>n.map(d=>[{text:d,styles:{}}]))}}export const DOC_BLOCK_SCALE=.75;export function docBlockPalette(i={}){return g({text:o.ink,body:o.ink,muted:o.lead,ground:o.sheet,surface:o.sheet,well:o.stone,rule:o.rule,"rule-strong":o.ruleStrong},{theme:c(i),font:"Carlito, Calibri, Arial, sans-serif"})}export function libraryFields(i){return i.items===void 0?{...i.props}:{...i.props,items:i.items.map(r=>({...r.props}))}}export function libraryDef(i,r={}){const e=LIBRARY_TAGS[i.tag];if(e===void 0)return{problems:[`<${i.tag}> is not a block`]};const t=r.data,n=s(e.kind,libraryFields(i),{...t===void 0?{}:{data:t,shown:a=>t(u(a))},...r.base===void 0?{}:{base:r.base}}),d=n.problems.map(a=>`${a.path.length>0?`${a.path.join(".")}: `:""}${a.message}`);return n.block===void 0?{problems:d}:{def:n.block,problems:d}}export function libraryBlockSvg(i,r,e={}){const{def:t,problems:n}=libraryDef(i,e);if(t===void 0)return{problems:n};const d=f(t,e.lang);return{svg:l(t,{width:r*.75},docBlockPalette(e.page),{flow:!0,scale:DOC_BLOCK_SCALE,label:d,...e.id===void 0?{}:{id:e.id},...e.lang===void 0?{}:{lang:e.lang}}),alt:d,problems:n}}export function docStatsDef(i,r={}){const e=i.stats.map(n=>({value:n.value,label:n.label,...n.delta===void 0?{}:{delta:n.delta},...n.note===void 0?{}:{note:n.note},...n.downIsGood===!0?{good:"down"}:{},...n.status===void 0?{}:{status:n.status},...n.target===void 0?{}:{target:n.target},...n.trend===void 0?{}:{trend:n.trend},...n.icon===void 0?{}:{icon:n.icon}})),t=r.data;return s("stats",e,{...t===void 0?{}:{data:t,shown:n=>t(u(n))}}).block}export function docStatsSvg(i,r,e={}){const t=docStatsDef(i,e);if(t!==void 0)return l(t,{width:r*.75},docBlockPalette(e.page),{flow:!0,scale:DOC_BLOCK_SCALE,...e.id===void 0?{}:{id:e.id},...e.lang===void 0?{}:{lang:e.lang}})}export function inlineIconSvg(i,r){if(!/^[a-z][a-z0-9-]*$/iu.test(i))return;const e=p(i);if(e!==void 0)return`<svg class="icon" viewBox="0 0 24 24" width="1.15em" height="1.15em" fill="none" stroke="${r}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e.map(t=>`<path d="${t}"/>`).join("")}</svg>`}export function calloutTone(i,r={}){if(i===void 0)return;const e=h(i,"callout");if(e===void 0)return;if(e==="accent1"){const d=c(r).accent1;return{bg:b(d,.14),fg:o.ink,mark:d,icon:"message-square-warning"}}const t=k[e],n={info:"info",good:"circle-check",warning:"triangle-alert",bad:"octagon-alert"};return{bg:t.tint,fg:t.ink,mark:t.mark,...n[e]===void 0?{}:{icon:n[e]}}}
2
+ import{blockAlt as s,blockDataTable as g,blockFromFile as l,blockLayout as p,blockSvg as u,iconPaths as m,paletteOf as k}from"@allyhub/blocks";import{shownPath as c,TONE_COLORS as b,toneOf as h}from"@allyhub/formats";import{chartTheme as f}from"./chart.js";import{PAPER as o,tint as w}from"./paper.js";export const LIBRARY_TAGS={Icon:{kind:"icon"},Progress:{kind:"progress"},Timeline:{kind:"timeline",item:"Milestone"},Steps:{kind:"steps",item:"Step"},Person:{kind:"person"},People:{kind:"people",item:"Person"},RiskMatrix:{kind:"risk_matrix",item:"Entry"},Sankey:{kind:"sankey",item:"Flow"},Gantt:{kind:"gantt",item:"Task"},OrgChart:{kind:"org_chart"},IssueTree:{kind:"issue_tree"},DecisionTree:{kind:"decision_tree"},Fishbone:{kind:"fishbone"},Matrix:{kind:"matrix"},Marimekko:{kind:"marimekko"},Heatmap:{kind:"heatmap"},SmallMultiples:{kind:"small_multiples"}};export function libraryBlockTable(i,r={}){const{def:e}=libraryDef(i,r),t=e===void 0?void 0:g(e,r.lang);if(!(t===void 0||t.rows.length===0))return{type:"table",rows:[t.columns,...t.rows].map(n=>n.map(d=>[{text:d,styles:{}}]))}}export const DOC_BLOCK_SCALE=.75;export function docBlockPalette(i={}){return k({text:o.ink,body:o.ink,muted:o.lead,ground:o.sheet,surface:o.sheet,well:o.stone,rule:o.rule,"rule-strong":o.ruleStrong},{theme:f(i),font:"Carlito, Calibri, Arial, sans-serif"})}export function libraryFields(i){return i.items===void 0?{...i.props}:{...i.props,items:i.items.map(r=>({...r.props}))}}export function libraryDef(i,r={}){const e=LIBRARY_TAGS[i.tag];if(e===void 0)return{problems:[`<${i.tag}> is not a block`]};const t=r.data,n=l(e.kind,libraryFields(i),{...t===void 0?{}:{data:t,shown:a=>t(c(a))},...r.base===void 0?{}:{base:r.base}}),d=n.problems.map(a=>`${a.path.length>0?`${a.path.join(".")}: `:""}${a.message}`);return n.block===void 0?{problems:d}:{def:n.block,problems:d}}export function libraryBlockDrawing(i,r,e={}){const{def:t,problems:n}=libraryDef(i,e);return t===void 0?{problems:n}:{drawing:p(t,{width:r*.75},{flow:!0,scale:DOC_BLOCK_SCALE,...e.lang===void 0?{}:{lang:e.lang}}),alt:s(t,e.lang),problems:n}}export function libraryBlockSvg(i,r,e={}){const{def:t,problems:n}=libraryDef(i,e);if(t===void 0)return{problems:n};const d=s(t,e.lang);return{svg:u(t,{width:r*.75},docBlockPalette(e.page),{flow:!0,scale:DOC_BLOCK_SCALE,label:d,...e.id===void 0?{}:{id:e.id},...e.lang===void 0?{}:{lang:e.lang}}),alt:d,problems:n}}export function docStatsDef(i,r={}){const e=i.stats.map(n=>({value:n.value,label:n.label,...n.delta===void 0?{}:{delta:n.delta},...n.note===void 0?{}:{note:n.note},...n.downIsGood===!0?{good:"down"}:{},...n.status===void 0?{}:{status:n.status},...n.target===void 0?{}:{target:n.target},...n.trend===void 0?{}:{trend:n.trend},...n.icon===void 0?{}:{icon:n.icon}})),t=r.data;return l("stats",e,{...t===void 0?{}:{data:t,shown:n=>t(c(n))}}).block}export function docStatsSvg(i,r,e={}){const t=docStatsDef(i,e);if(t!==void 0)return u(t,{width:r*.75},docBlockPalette(e.page),{flow:!0,scale:DOC_BLOCK_SCALE,...e.id===void 0?{}:{id:e.id},...e.lang===void 0?{}:{lang:e.lang}})}export function inlineIconSvg(i,r){if(!/^[a-z][a-z0-9-]*$/iu.test(i))return;const e=m(i);if(e!==void 0)return`<svg class="icon" viewBox="0 0 24 24" width="1.15em" height="1.15em" fill="none" stroke="${r}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e.map(t=>`<path d="${t}"/>`).join("")}</svg>`}export function calloutTone(i,r={}){if(i===void 0)return;const e=h(i,"callout");if(e===void 0)return;if(e==="accent1"){const d=f(r).accent1;return{bg:w(d,.14),fg:o.ink,mark:d,icon:"message-square-warning"}}const t=b[e],n={info:"info",good:"circle-check",warning:"triangle-alert",bad:"octagon-alert"};return{bg:t.tint,fg:t.ink,mark:t.mark,...n[e]===void 0?{}:{icon:n[e]}}}