allyhub 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (582) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/commands/auth.js +4 -4
  3. package/dist/commands/cloud-tools.js +11 -11
  4. package/dist/commands/dev.js +2 -2
  5. package/dist/commands/frames/compare.js +2 -2
  6. package/dist/commands/frames/piece.js +1 -1
  7. package/dist/commands/frames/report.js +2 -0
  8. package/dist/commands/frames.js +11 -9
  9. package/dist/commands/index.js +1 -1
  10. package/dist/commands/inspect/common.js +4 -2
  11. package/dist/commands/inspect/facts.js +3 -3
  12. package/dist/commands/inspect/layout.js +1 -1
  13. package/dist/commands/orgs.js +2 -2
  14. package/dist/commands/render.js +2 -2
  15. package/dist/help.js +4 -4
  16. package/dist/main.js +8 -7
  17. package/dist/node_modules/@allyhub/3d-extension/dist/stage-routes.js +1 -1
  18. package/dist/node_modules/@allyhub/3d-extension/package.json +34 -2
  19. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  20. package/dist/node_modules/@allyhub/browser/dist/emoji.d.ts +29 -0
  21. package/dist/node_modules/@allyhub/browser/dist/emoji.js +57 -0
  22. package/dist/node_modules/@allyhub/browser/dist/picture.d.ts +18 -0
  23. package/dist/node_modules/@allyhub/browser/dist/picture.js +2 -0
  24. package/dist/node_modules/@allyhub/browser/package.json +9 -1
  25. package/dist/node_modules/@allyhub/build/dist/index.d.ts +1 -0
  26. package/dist/node_modules/@allyhub/build/dist/index.js +1 -1
  27. package/dist/node_modules/@allyhub/build/dist/kind-build.d.ts +7 -0
  28. package/dist/node_modules/@allyhub/build/dist/made-notes.d.ts +9 -0
  29. package/dist/node_modules/@allyhub/build/dist/made-notes.js +2 -0
  30. package/dist/node_modules/@allyhub/build/dist/project-tool.d.ts +17 -0
  31. package/dist/node_modules/@allyhub/build/dist/stage-route.d.ts +7 -0
  32. package/dist/node_modules/@allyhub/build/package.json +1 -1
  33. package/dist/node_modules/@allyhub/canvas-extension/package.json +2 -1
  34. package/dist/node_modules/@allyhub/canvas-extension/skills/allyhub/references/canvas.md +4 -24
  35. package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
  36. package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +2 -2
  37. package/dist/node_modules/@allyhub/chart/dist/chart.js +1 -1
  38. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  39. package/dist/node_modules/@allyhub/check/package.json +1 -1
  40. package/dist/node_modules/@allyhub/cloud/dist/client.d.ts +10 -0
  41. package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
  42. package/dist/node_modules/@allyhub/cloud/dist/config.d.ts +9 -0
  43. package/dist/node_modules/@allyhub/cloud/dist/config.js +1 -1
  44. package/dist/node_modules/@allyhub/cloud/dist/credentials.d.ts +4 -4
  45. package/dist/node_modules/@allyhub/cloud/dist/credentials.js +2 -2
  46. package/dist/node_modules/@allyhub/cloud/dist/device.d.ts +12 -0
  47. package/dist/node_modules/@allyhub/cloud/dist/device.js +2 -0
  48. package/dist/node_modules/@allyhub/cloud/package.json +1 -1
  49. package/dist/node_modules/@allyhub/components/package.json +1 -1
  50. package/dist/node_modules/@allyhub/components/r/callout.json +1 -1
  51. package/dist/node_modules/@allyhub/components/src/callout.ts +98 -13
  52. package/dist/node_modules/@allyhub/dev-server/dist/exports.js +1 -1
  53. package/dist/node_modules/@allyhub/dev-server/dist/index.js +1 -1
  54. package/dist/node_modules/@allyhub/dev-server/dist/inputs.js +2 -0
  55. package/dist/node_modules/@allyhub/dev-server/dist/live.js +1 -1
  56. package/dist/node_modules/@allyhub/dev-server/dist/pages.js +2 -0
  57. package/dist/node_modules/@allyhub/dev-server/dist/ports.js +2 -0
  58. package/dist/node_modules/@allyhub/dev-server/dist/project.js +1 -1
  59. package/dist/node_modules/@allyhub/dev-server/dist/record.js +1 -1
  60. package/dist/node_modules/@allyhub/dev-server/dist/respond.js +2 -0
  61. package/dist/node_modules/@allyhub/dev-server/dist/reveal.js +1 -1
  62. package/dist/node_modules/@allyhub/dev-server/dist/routes.js +1 -1
  63. package/dist/node_modules/@allyhub/dev-server/dist/server.js +2 -2
  64. package/dist/node_modules/@allyhub/dev-server/dist/tools.js +1 -1
  65. package/dist/node_modules/@allyhub/dev-server/dist/watcher.js +1 -1
  66. package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
  67. package/dist/node_modules/@allyhub/diagnostics/dist/problem.d.ts +7 -0
  68. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  69. package/dist/node_modules/@allyhub/doc/dist/captions.js +1 -1
  70. package/dist/node_modules/@allyhub/doc/dist/docx.js +4 -4
  71. package/dist/node_modules/@allyhub/doc/dist/html.js +51 -92
  72. package/dist/node_modules/@allyhub/doc/dist/model.js +1 -1
  73. package/dist/node_modules/@allyhub/doc/dist/page.js +1 -1
  74. package/dist/node_modules/@allyhub/doc/dist/paper.js +1 -1
  75. package/dist/node_modules/@allyhub/doc/dist/table.js +1 -1
  76. package/dist/node_modules/@allyhub/doc/dist/write.js +22 -22
  77. package/dist/node_modules/@allyhub/doc/package.json +1 -1
  78. package/dist/node_modules/@allyhub/doc-extension/dist/export.js +1 -1
  79. package/dist/node_modules/@allyhub/doc-extension/package.json +19 -6
  80. package/dist/node_modules/@allyhub/doc-print/dist/pages.js +5 -5
  81. package/dist/node_modules/@allyhub/doc-print/dist/print.js +10 -10
  82. package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
  83. package/dist/node_modules/@allyhub/export/dist/export.js +1 -1
  84. package/dist/node_modules/@allyhub/export/package.json +1 -1
  85. package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
  86. package/dist/node_modules/@allyhub/extension-host/dist/points.js +1 -1
  87. package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
  88. package/dist/node_modules/@allyhub/formats/dist/data/faces.d.ts +1 -1
  89. package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +87 -1
  90. package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
  91. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +89 -0
  92. package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
  93. package/dist/node_modules/@allyhub/formats/dist/note-shape.d.ts +20 -0
  94. package/dist/node_modules/@allyhub/formats/dist/note-shape.js +1 -1
  95. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +50 -0
  96. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  97. package/dist/node_modules/@allyhub/i18n/package.json +1 -1
  98. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  99. package/dist/node_modules/@allyhub/image-extension/dist/export.js +4 -1
  100. package/dist/node_modules/@allyhub/image-extension/package.json +16 -6
  101. package/dist/node_modules/@allyhub/image-extension/skills/allyhub/references/images.md +7 -39
  102. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  103. package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
  104. package/dist/node_modules/@allyhub/image-render/package.json +1 -1
  105. package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
  106. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  107. package/dist/node_modules/@allyhub/jobs/package.json +1 -1
  108. package/dist/node_modules/@allyhub/linkedin-extension/LICENSE +241 -0
  109. package/dist/node_modules/@allyhub/linkedin-extension/dist/article-build.js +2 -0
  110. package/dist/node_modules/@allyhub/linkedin-extension/dist/article-kind.js +2 -0
  111. package/dist/node_modules/@allyhub/linkedin-extension/dist/build-plugins.js +2 -0
  112. package/dist/node_modules/@allyhub/linkedin-extension/dist/build.js +5 -0
  113. package/dist/node_modules/@allyhub/linkedin-extension/dist/media.js +2 -0
  114. package/dist/node_modules/@allyhub/linkedin-extension/dist/stage-module.js +82 -0
  115. package/dist/node_modules/@allyhub/linkedin-extension/dist/stage.js +2 -0
  116. package/dist/node_modules/@allyhub/linkedin-extension/dist/workspace.js +2 -0
  117. package/dist/node_modules/@allyhub/linkedin-extension/package.json +287 -0
  118. package/dist/node_modules/@allyhub/linkedin-extension/skills/allyhub/references/linkedin.md +12 -0
  119. package/dist/node_modules/@allyhub/linkedin-model/LICENSE +241 -0
  120. package/dist/node_modules/@allyhub/linkedin-model/dist/article-check.js +5 -0
  121. package/dist/node_modules/@allyhub/linkedin-model/dist/article.js +3 -0
  122. package/dist/node_modules/@allyhub/linkedin-model/dist/check.js +2 -0
  123. package/dist/node_modules/@allyhub/linkedin-model/dist/count.js +3 -0
  124. package/dist/node_modules/@allyhub/linkedin-model/dist/edit.js +3 -0
  125. package/dist/node_modules/@allyhub/linkedin-model/dist/html.js +19 -0
  126. package/dist/node_modules/@allyhub/linkedin-model/dist/index.js +2 -0
  127. package/dist/node_modules/@allyhub/linkedin-model/dist/limits.js +2 -0
  128. package/dist/node_modules/@allyhub/linkedin-model/dist/little.js +2 -0
  129. package/dist/node_modules/@allyhub/linkedin-model/dist/post.js +2 -0
  130. package/dist/node_modules/@allyhub/linkedin-model/dist/requests.js +2 -0
  131. package/dist/node_modules/@allyhub/linkedin-model/package.json +14 -0
  132. package/dist/node_modules/@allyhub/linkedin-view/LICENSE +241 -0
  133. package/dist/node_modules/@allyhub/linkedin-view/dist/article.js +2 -0
  134. package/dist/node_modules/@allyhub/linkedin-view/dist/fold.js +3 -0
  135. package/dist/node_modules/@allyhub/linkedin-view/dist/index.js +2 -0
  136. package/dist/node_modules/@allyhub/linkedin-view/dist/post.js +2 -0
  137. package/dist/node_modules/@allyhub/linkedin-view/dist/stage.js +2 -0
  138. package/dist/node_modules/@allyhub/linkedin-view/dist/text.js +2 -0
  139. package/dist/node_modules/@allyhub/linkedin-view/package.json +21 -0
  140. package/dist/node_modules/@allyhub/linkedin-view/src/style.css +600 -0
  141. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  142. package/dist/node_modules/@allyhub/media/package.json +1 -1
  143. package/dist/node_modules/@allyhub/media-extension/dist/vision/faces.js +1 -1
  144. package/dist/node_modules/@allyhub/media-extension/package.json +7 -4
  145. package/dist/node_modules/@allyhub/model/package.json +1 -1
  146. package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.js +1 -1
  147. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  148. package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +2 -0
  149. package/dist/node_modules/@allyhub/piece/dist/layout.d.ts +16 -0
  150. package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +1 -1
  151. package/dist/node_modules/@allyhub/piece/dist/page/index.js +1 -1
  152. package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +14 -1
  153. package/dist/node_modules/@allyhub/piece/dist/page/locate.js +1 -1
  154. package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +18 -0
  155. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  156. package/dist/node_modules/@allyhub/project/dist/version.js +1 -1
  157. package/dist/node_modules/@allyhub/project/package.json +1 -1
  158. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +140 -0
  159. package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
  160. package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +19 -1
  161. package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
  162. package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +157 -0
  163. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  164. package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +10 -2
  165. package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
  166. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +101 -186
  167. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  168. package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +1 -0
  169. package/dist/node_modules/@allyhub/protocol/dist/mail.js +1 -1
  170. package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +92 -94
  171. package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
  172. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +17 -0
  173. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  174. package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +7 -0
  175. package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
  176. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +15 -3
  177. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  178. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  179. package/dist/node_modules/@allyhub/registry/package.json +1 -1
  180. package/dist/node_modules/@allyhub/render/dist/encode.js +1 -1
  181. package/dist/node_modules/@allyhub/render/dist/index.js +1 -1
  182. package/dist/node_modules/@allyhub/render/dist/look.js +1 -1
  183. package/dist/node_modules/@allyhub/render/dist/render.js +2 -2
  184. package/dist/node_modules/@allyhub/render/package.json +1 -1
  185. package/dist/node_modules/@allyhub/report-extension/LICENSE +241 -0
  186. package/dist/node_modules/@allyhub/report-extension/dist/build.js +2 -0
  187. package/dist/node_modules/@allyhub/report-extension/dist/check.js +3 -0
  188. package/dist/node_modules/@allyhub/report-extension/dist/cli/find.js +2 -0
  189. package/dist/node_modules/@allyhub/report-extension/dist/cli/index.js +5 -0
  190. package/dist/node_modules/@allyhub/report-extension/dist/cli/picture.js +2 -0
  191. package/dist/node_modules/@allyhub/report-extension/dist/export.js +2 -0
  192. package/dist/node_modules/@allyhub/report-extension/dist/inline.js +58 -0
  193. package/dist/node_modules/@allyhub/report-extension/dist/page.js +21 -0
  194. package/dist/node_modules/@allyhub/report-extension/dist/project-tools.js +21 -0
  195. package/dist/node_modules/@allyhub/report-extension/dist/styles.js +5 -0
  196. package/dist/node_modules/@allyhub/report-extension/dist/theme.js +2 -0
  197. package/dist/node_modules/@allyhub/report-extension/dist/tools.js +2 -0
  198. package/dist/node_modules/@allyhub/report-extension/dist/workspace.js +2 -0
  199. package/dist/node_modules/@allyhub/report-extension/package.json +182 -0
  200. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/STYLE.md +132 -0
  201. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.css +105 -0
  202. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.json +17 -0
  203. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/tokens.js +38 -0
  204. package/dist/node_modules/@allyhub/runtime/dist/compose.js +1 -1
  205. package/dist/node_modules/@allyhub/runtime/dist/embed.js +1 -1
  206. package/dist/node_modules/@allyhub/runtime/dist/player/clips.js +1 -1
  207. package/dist/node_modules/@allyhub/runtime/dist/player/player.js +1 -1
  208. package/dist/node_modules/@allyhub/runtime/package.json +1 -1
  209. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  210. package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
  211. package/dist/node_modules/@allyhub/scenery/dist/index.d.ts +2 -2
  212. package/dist/node_modules/@allyhub/scenery/dist/index.js +1 -1
  213. package/dist/node_modules/@allyhub/scenery/dist/moire.d.ts +45 -5
  214. package/dist/node_modules/@allyhub/scenery/dist/moire.js +2 -2
  215. package/dist/node_modules/@allyhub/scenery/dist/phone.d.ts +4 -3
  216. package/dist/node_modules/@allyhub/scenery/dist/phone.js +1 -1
  217. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  218. package/dist/node_modules/@allyhub/scenery-host/dist/layer/grade.d.ts +7 -0
  219. package/dist/node_modules/@allyhub/scenery-host/dist/layer/grade.js +2 -0
  220. package/dist/node_modules/@allyhub/scenery-host/dist/layer/index.d.ts +4 -3
  221. package/dist/node_modules/@allyhub/scenery-host/dist/layer/index.js +1 -1
  222. package/dist/node_modules/@allyhub/scenery-host/dist/layer/screens.d.ts +1 -1
  223. package/dist/node_modules/@allyhub/scenery-host/dist/layer/screens.js +1 -1
  224. package/dist/node_modules/@allyhub/scenery-host/dist/measure/facts.js +1 -1
  225. package/dist/node_modules/@allyhub/scenery-host/dist/page/screens.d.ts +8 -0
  226. package/dist/node_modules/@allyhub/scenery-host/dist/page/screens.js +1 -1
  227. package/dist/node_modules/@allyhub/scenery-host/dist/viewer.d.ts +6 -0
  228. package/dist/node_modules/@allyhub/scenery-host/dist/viewer.js +1 -1
  229. package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
  230. package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
  231. package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
  232. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.js +1 -1
  233. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/date.js +1 -1
  234. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/define.js +1 -1
  235. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/info.js +1 -1
  236. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/kernels.js +1 -1
  237. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/lookup.js +1 -1
  238. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/maths.js +1 -1
  239. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
  240. package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.js +1 -1
  241. package/dist/node_modules/@allyhub/sheet/dist/calc/types.js +1 -1
  242. package/dist/node_modules/@allyhub/sheet/dist/chart.js +1 -1
  243. package/dist/node_modules/@allyhub/sheet/dist/export.js +2 -4
  244. package/dist/node_modules/@allyhub/sheet/dist/formula/move.js +1 -1
  245. package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
  246. package/dist/node_modules/@allyhub/sheet/dist/formula/print.js +1 -1
  247. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  248. package/dist/node_modules/@allyhub/sheet/dist/inspect.js +1 -1
  249. package/dist/node_modules/@allyhub/sheet/dist/printed.js +2 -0
  250. package/dist/node_modules/@allyhub/sheet/dist/values.js +1 -1
  251. package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
  252. package/dist/node_modules/@allyhub/sheet/dist/write.js +15 -15
  253. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
  254. package/dist/node_modules/@allyhub/sheet/dist/xlsx/formula.js +2 -2
  255. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
  256. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
  257. package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.js +3 -1
  258. package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
  259. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
  260. package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.js +3 -2
  261. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  262. package/dist/node_modules/@allyhub/sheet-extension/dist/export.js +2 -6
  263. package/dist/node_modules/@allyhub/sheet-extension/package.json +24 -9
  264. package/dist/node_modules/@allyhub/slides-core/dist/api.js +2 -2
  265. package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
  266. package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
  267. package/dist/node_modules/@allyhub/slides-core/dist/measure.js +1 -1
  268. package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
  269. package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +1 -1
  270. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  271. package/dist/node_modules/@allyhub/slides-extension/dist/export.js +1 -1
  272. package/dist/node_modules/@allyhub/slides-extension/package.json +22 -16
  273. package/dist/node_modules/@allyhub/slides-pptx/dist/import/code.js +2 -2
  274. package/dist/node_modules/@allyhub/slides-pptx/dist/import/index.js +2 -2
  275. package/dist/node_modules/@allyhub/slides-pptx/dist/read/common.js +1 -1
  276. package/dist/node_modules/@allyhub/slides-pptx/dist/read/shapes.js +1 -1
  277. package/dist/node_modules/@allyhub/slides-pptx/dist/read/text.js +1 -1
  278. package/dist/node_modules/@allyhub/slides-pptx/dist/shapes.js +1 -1
  279. package/dist/node_modules/@allyhub/slides-pptx/dist/text.js +1 -1
  280. package/dist/node_modules/@allyhub/slides-pptx/dist/write.js +2 -2
  281. package/dist/node_modules/@allyhub/slides-pptx/dist/xml.js +1 -1
  282. package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
  283. package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +2 -2
  284. package/dist/node_modules/@allyhub/slides-runtime/dist/load.js +5 -5
  285. package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
  286. package/dist/node_modules/@allyhub/stage/package.json +1 -1
  287. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/400-italic.css +19 -0
  288. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/400.css +19 -0
  289. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/700-italic.css +19 -0
  290. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/700.css +19 -0
  291. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/LICENSE +93 -0
  292. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/cambria.css +76 -0
  293. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-400-italic.woff2 +0 -0
  294. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-400-normal.woff2 +0 -0
  295. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-700-italic.woff2 +0 -0
  296. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-700-normal.woff2 +0 -0
  297. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-400-italic.woff2 +0 -0
  298. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-400-normal.woff2 +0 -0
  299. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-700-italic.woff2 +0 -0
  300. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-700-normal.woff2 +0 -0
  301. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/400-italic.css +79 -0
  302. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/400.css +79 -0
  303. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/700-italic.css +79 -0
  304. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/700.css +79 -0
  305. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/LICENSE +93 -0
  306. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/courier-new.css +316 -0
  307. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-400-italic.woff2 +0 -0
  308. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-400-normal.woff2 +0 -0
  309. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-700-italic.woff2 +0 -0
  310. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-700-normal.woff2 +0 -0
  311. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-400-italic.woff2 +0 -0
  312. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-400-normal.woff2 +0 -0
  313. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-700-italic.woff2 +0 -0
  314. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-700-normal.woff2 +0 -0
  315. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-400-italic.woff2 +0 -0
  316. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-400-normal.woff2 +0 -0
  317. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-700-italic.woff2 +0 -0
  318. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-700-normal.woff2 +0 -0
  319. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-400-italic.woff2 +0 -0
  320. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-400-normal.woff2 +0 -0
  321. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-700-italic.woff2 +0 -0
  322. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-700-normal.woff2 +0 -0
  323. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-400-italic.woff2 +0 -0
  324. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-400-normal.woff2 +0 -0
  325. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-700-italic.woff2 +0 -0
  326. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-700-normal.woff2 +0 -0
  327. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-400-italic.woff2 +0 -0
  328. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-400-normal.woff2 +0 -0
  329. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-700-italic.woff2 +0 -0
  330. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-700-normal.woff2 +0 -0
  331. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-400-italic.woff2 +0 -0
  332. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-400-normal.woff2 +0 -0
  333. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-700-italic.woff2 +0 -0
  334. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-700-normal.woff2 +0 -0
  335. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-400-italic.woff2 +0 -0
  336. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-400-normal.woff2 +0 -0
  337. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-700-italic.woff2 +0 -0
  338. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-700-normal.woff2 +0 -0
  339. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/400-italic.css +79 -0
  340. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/400.css +79 -0
  341. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/700-italic.css +79 -0
  342. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/700.css +79 -0
  343. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/LICENSE +93 -0
  344. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-400-italic.woff2 +0 -0
  345. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-400-normal.woff2 +0 -0
  346. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-700-italic.woff2 +0 -0
  347. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-700-normal.woff2 +0 -0
  348. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-400-italic.woff2 +0 -0
  349. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-400-normal.woff2 +0 -0
  350. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-700-italic.woff2 +0 -0
  351. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-700-normal.woff2 +0 -0
  352. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-400-italic.woff2 +0 -0
  353. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-400-normal.woff2 +0 -0
  354. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-700-italic.woff2 +0 -0
  355. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-700-normal.woff2 +0 -0
  356. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-400-italic.woff2 +0 -0
  357. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-400-normal.woff2 +0 -0
  358. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-700-italic.woff2 +0 -0
  359. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-700-normal.woff2 +0 -0
  360. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-400-italic.woff2 +0 -0
  361. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-400-normal.woff2 +0 -0
  362. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-700-italic.woff2 +0 -0
  363. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-700-normal.woff2 +0 -0
  364. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-400-italic.woff2 +0 -0
  365. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-400-normal.woff2 +0 -0
  366. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-700-italic.woff2 +0 -0
  367. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-700-normal.woff2 +0 -0
  368. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-400-italic.woff2 +0 -0
  369. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-400-normal.woff2 +0 -0
  370. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-700-italic.woff2 +0 -0
  371. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-700-normal.woff2 +0 -0
  372. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-400-italic.woff2 +0 -0
  373. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-400-normal.woff2 +0 -0
  374. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-700-italic.woff2 +0 -0
  375. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-700-normal.woff2 +0 -0
  376. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/times-new-roman.css +316 -0
  377. package/dist/node_modules/@allyhub/stage-page/dist/host.js +1 -1
  378. package/dist/node_modules/@allyhub/stage-page/dist/install.js +1 -1
  379. package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.html +3 -0
  380. package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.js +1 -1
  381. package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
  382. package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +18 -18
  383. package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
  384. package/dist/node_modules/@allyhub/video-core/dist/schema.js +1 -1
  385. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  386. package/dist/node_modules/@allyhub/video-extension/dist/export.js +1 -1
  387. package/dist/node_modules/@allyhub/video-extension/package.json +17 -4
  388. package/dist/node_modules/@allyhub/video-measure/dist/version.js +1 -1
  389. package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
  390. package/dist/node_modules/@allyhub/video-sdk/dist/phone.js +1 -1
  391. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  392. package/dist/node_modules/@allyhub/website/package.json +1 -1
  393. package/dist/node_modules/@allyhub/website-extension/dist/held.js +2 -0
  394. package/dist/node_modules/@allyhub/website-extension/dist/preview.js +5 -5
  395. package/dist/node_modules/@allyhub/website-extension/dist/project-tools.js +24 -1
  396. package/dist/node_modules/@allyhub/website-extension/dist/tools.js +1 -1
  397. package/dist/node_modules/@allyhub/website-extension/package.json +49 -2
  398. package/dist/node_modules/@allyhub/x-extension/dist/build.js +4 -3
  399. package/dist/node_modules/@allyhub/x-extension/package.json +43 -15
  400. package/dist/node_modules/@allyhub/x-extension/skills/allyhub/references/x.md +7 -62
  401. package/dist/node_modules/@allyhub/x-model/package.json +1 -1
  402. package/dist/node_modules/@allyhub/x-view/dist/article.js +1 -1
  403. package/dist/node_modules/@allyhub/x-view/dist/index.js +1 -1
  404. package/dist/node_modules/@allyhub/x-view/dist/post.js +2 -2
  405. package/dist/node_modules/@allyhub/x-view/package.json +1 -1
  406. package/dist/package.json +12 -10
  407. package/dist/text/facts-text.js +5 -5
  408. package/dist/text/index.js +1 -1
  409. package/dist/text/long-text.js +4 -0
  410. package/dist/works.js +1 -1
  411. package/editor-web/assets/{abnfDiagram-WEYOIA3C-CN5PiJYY.js → abnfDiagram-WEYOIA3C-BKmMA6gn.js} +1 -1
  412. package/editor-web/assets/{architecture-WOLXFQ4H-BnvZtQYk.js → architecture-WOLXFQ4H-BEFBgb4k.js} +1 -1
  413. package/editor-web/assets/{architectureDiagram-ZHVYKT53-tkcEcFQ8.js → architectureDiagram-ZHVYKT53-_u5YfCjY.js} +1 -1
  414. package/editor-web/assets/{arrow-up-DTP2yVSU.js → arrow-up-B5rJbBv0.js} +1 -1
  415. package/editor-web/assets/article-BUmD3xtR.js +8 -0
  416. package/editor-web/assets/article-DNioBb3p.js +7 -0
  417. package/editor-web/assets/{audio-lines-Ti8-m7H2.js → audio-lines-CzuzsGjI.js} +1 -1
  418. package/editor-web/assets/{blockDiagram-RJAE7QA3-DhqEIpie.js → blockDiagram-RJAE7QA3-DybfaO3Z.js} +1 -1
  419. package/editor-web/assets/bookmark-Dsd3kHJJ.js +1 -0
  420. package/editor-web/assets/button-eGxLxbv9.js +41 -0
  421. package/editor-web/assets/{c4Diagram-XDPPPE54-Bg9G95tl.js → c4Diagram-XDPPPE54-BfqLHB5i.js} +1 -1
  422. package/editor-web/assets/calc-worker-D2pGis6e.js +45 -0
  423. package/editor-web/assets/channel-TNPgFDrw.js +1 -0
  424. package/editor-web/assets/chart-C37xvZT2.js +1 -0
  425. package/editor-web/assets/chart-no-axes-column-BVkeF_Mr.js +1 -0
  426. package/editor-web/assets/{chunk-2E7WHVMD-C8Ve9lAa.js → chunk-2E7WHVMD-BVp1I_d0.js} +1 -1
  427. package/editor-web/assets/{chunk-4EMNKR2T-BDWwPUnT.js → chunk-4EMNKR2T-CTdgWEMr.js} +1 -1
  428. package/editor-web/assets/{chunk-55XCU76K-BQiNPKgx.js → chunk-55XCU76K-7pnsxeaP.js} +1 -1
  429. package/editor-web/assets/{chunk-7S6XSTFO-QoEt-6jf.js → chunk-7S6XSTFO-Dc0Dvkq7.js} +1 -1
  430. package/editor-web/assets/{chunk-AQDTSKZB-BeuwIv0-.js → chunk-AQDTSKZB-VAILIsfx.js} +1 -1
  431. package/editor-web/assets/{chunk-DSNLSHJZ-BHW7sLAz.js → chunk-DSNLSHJZ-CUDx1Rv5.js} +1 -1
  432. package/editor-web/assets/{chunk-HAGFOTED-bbGED0hu.js → chunk-HAGFOTED-DAoEe-dJ.js} +1 -1
  433. package/editor-web/assets/{chunk-HNE4Q36P-FltWp8yo.js → chunk-HNE4Q36P-g0akya12.js} +1 -1
  434. package/editor-web/assets/{chunk-NQOKRVIF-NeQzr6kH.js → chunk-NQOKRVIF-hTGjzXdJ.js} +1 -1
  435. package/editor-web/assets/{chunk-UHW7PFBP-eA4-WUhn.js → chunk-UHW7PFBP-BgLV8BIJ.js} +1 -1
  436. package/editor-web/assets/{chunk-VQ5W62QI-BPPv325z.js → chunk-VQ5W62QI-Bw19OOSD.js} +1 -1
  437. package/editor-web/assets/{chunk-WQQL4CDK-DOCIz7Te.js → chunk-WQQL4CDK-CMST9dyE.js} +1 -1
  438. package/editor-web/assets/{chunk-YZO67HFG-Dc_ihQJi.js → chunk-YZO67HFG-Bbpu36XF.js} +1 -1
  439. package/editor-web/assets/{chunk-ZAUX2LTX-CoqwCPSm.js → chunk-ZAUX2LTX-C48Ri0Gs.js} +1 -1
  440. package/editor-web/assets/{chunk-ZCHMQSOR-CZUQPkJx.js → chunk-ZCHMQSOR-DN1g01Oe.js} +1 -1
  441. package/editor-web/assets/{classDiagram-v2-4MYWR3UA-DUh9c50k.js → classDiagram-v2-4MYWR3UA-U6jbPr2d.js} +1 -1
  442. package/editor-web/assets/collaborator-B1u2td9m.js +1 -0
  443. package/editor-web/assets/createLucideIcon-GFZ_fxLc.js +1 -0
  444. package/editor-web/assets/{cynefin-EF2NZ3EQ-DUTZiog0.js → cynefin-EF2NZ3EQ-gzkai_7-.js} +1 -1
  445. package/editor-web/assets/{cynefinDiagram-WF24UDRP-oAjpfbrU.js → cynefinDiagram-WF24UDRP-DtSekSr6.js} +1 -1
  446. package/editor-web/assets/{dagre-NK4GIZVX-BrKvKCvb.js → dagre-NK4GIZVX-CiUwYVT6.js} +1 -1
  447. package/editor-web/assets/{diagram-CBK3MWTC-GekVRnmm.js → diagram-CBK3MWTC-r9XHCV-k.js} +1 -1
  448. package/editor-web/assets/{diagram-I5XIIV2D-CDd1VFRT.js → diagram-I5XIIV2D-DxVsDZ34.js} +1 -1
  449. package/editor-web/assets/{diagram-ODIL2UCW-535RISTn.js → diagram-ODIL2UCW-B0eNQoHV.js} +1 -1
  450. package/editor-web/assets/{diagram-PFBEJUXE-MXzzKCGG.js → diagram-PFBEJUXE-C7f2MfJT.js} +1 -1
  451. package/editor-web/assets/{diagram-RJA3I4VV-vKVwkQxY.js → diagram-RJA3I4VV-CSXcnvct.js} +1 -1
  452. package/editor-web/assets/{diagram-TYUNFSNR-UwGAiQLx.js → diagram-TYUNFSNR-DXzOD_ii.js} +1 -1
  453. package/editor-web/assets/dist-BGRwhCQO.js +1 -0
  454. package/editor-web/assets/{dist-9ymlIMhr.js → dist-BW4X7BrF.js} +1 -1
  455. package/editor-web/assets/dist-BgDRE85b.js +2 -0
  456. package/editor-web/assets/dist-Blq5nJnU.js +24 -0
  457. package/editor-web/assets/dist-BuWaZ3Y4.js +274 -0
  458. package/editor-web/assets/dist-C1emZ9wX.js +37 -0
  459. package/editor-web/assets/dist-CC7OeU1e.js +6 -0
  460. package/editor-web/assets/dist-CX-fiPSn.js +38 -0
  461. package/editor-web/assets/dist-C_VvG-_9.js +5 -0
  462. package/editor-web/assets/dist-Ce7HrBxv.js +3 -0
  463. package/editor-web/assets/dist-D2k6w-_a.js +1 -0
  464. package/editor-web/assets/dist-DDv_SbKw.js +84 -0
  465. package/editor-web/assets/dist-DEoEO4zs.js +1 -0
  466. package/editor-web/assets/dist-DlDxxPIP.js +16 -0
  467. package/editor-web/assets/dist-Gz6NDS0J.js +4 -0
  468. package/editor-web/assets/{ebnfDiagram-V4P3TTPT-73yGokYa.js → ebnfDiagram-V4P3TTPT-Cs4YRvDD.js} +1 -1
  469. package/editor-web/assets/{elk-QONTBCTQ-BW6V9y6a.js → elk-QONTBCTQ-Bh3LZ9WI.js} +1 -1
  470. package/editor-web/assets/{erDiagram-KYQIGQAA-BPqIJ22h.js → erDiagram-KYQIGQAA-C4vYTYXp.js} +1 -1
  471. package/editor-web/assets/{eventmodeling-K75KTNOO-_VZ8jvuy.js → eventmodeling-K75KTNOO-BN1kkHWS.js} +1 -1
  472. package/editor-web/assets/flowDiagram-IUGLLWBU-B04NGsyi.js +1 -0
  473. package/editor-web/assets/{ganttDiagram-R7GPNTJY-DZ157JN2.js → ganttDiagram-R7GPNTJY-CA1LkkC5.js} +1 -1
  474. package/editor-web/assets/{gitGraph-VSP46ZUC-fmcNL9bq.js → gitGraph-VSP46ZUC-Dy5tA7dG.js} +1 -1
  475. package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-DiZDyksR.js → gitGraphDiagram-PDYL7XHY-hJIB8EkH.js} +1 -1
  476. package/editor-web/assets/hint-B8JpEypy.js +1 -0
  477. package/editor-web/assets/index-CgB5osVc.js +28 -0
  478. package/editor-web/assets/index-Daytem9N.css +2 -0
  479. package/editor-web/assets/{info-OHQRW6UA-V06620kN.js → info-OHQRW6UA-DvzSf7rQ.js} +1 -1
  480. package/editor-web/assets/{infoDiagram-MVDRKAX5-CbIgheWX.js → infoDiagram-MVDRKAX5-BjIMm4Af.js} +1 -1
  481. package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-D5oJQPkG.js → ishikawaDiagram-HPEHV2GE-Bpz71S40.js} +1 -1
  482. package/editor-web/assets/{italic-CDhZKo_q.js → italic-D10w8n6C.js} +1 -1
  483. package/editor-web/assets/{journeyDiagram-BOSHW7O7-BZEv6JI4.js → journeyDiagram-BOSHW7O7-DAB-pZjD.js} +1 -1
  484. package/editor-web/assets/{kanban-definition-FNSA4HC5-CLG1R8y_.js → kanban-definition-FNSA4HC5-cYeyh3P6.js} +1 -1
  485. package/editor-web/assets/katex-5Z2zF-9g.js +257 -0
  486. package/editor-web/assets/link-BC5xK1-1.js +1 -0
  487. package/editor-web/assets/{mermaid-parser.core-DxDwXM7z.js → mermaid-parser.core-req5LE0X.js} +3 -3
  488. package/editor-web/assets/{mermaid.core-tU55ZwVG.js → mermaid.core-zFwZug4C.js} +4 -4
  489. package/editor-web/assets/{mindmap-definition-6OY57UG3-CYf4zzAh.js → mindmap-definition-6OY57UG3-TStWb7DG.js} +1 -1
  490. package/editor-web/assets/minus-DaWs5i8B.js +1 -0
  491. package/editor-web/assets/{packet-JDAUHWVQ-DsHeKYNL.js → packet-JDAUHWVQ-smFhVKcB.js} +1 -1
  492. package/editor-web/assets/palette-BIOudGkm.js +1 -0
  493. package/editor-web/assets/{pegDiagram-ECIUJNBX-CQyh6TTa.js → pegDiagram-ECIUJNBX-DvSNRv0-.js} +1 -1
  494. package/editor-web/assets/{pie-XZMESJXO-3vCIvpNB.js → pie-XZMESJXO-qjaGsBZG.js} +1 -1
  495. package/editor-web/assets/{pieDiagram-GNMPY74T-DF5yGBLn.js → pieDiagram-GNMPY74T-Dd9P-Pdc.js} +1 -1
  496. package/editor-web/assets/play-CrMmPghG.js +1 -0
  497. package/editor-web/assets/progress-DE4C5_3x.js +6 -0
  498. package/editor-web/assets/props-form-CsmDBqzy.js +1 -0
  499. package/editor-web/assets/{quadrantDiagram-D57K4MC3-B7pxlDYP.js → quadrantDiagram-D57K4MC3-h2IIKUUA.js} +1 -1
  500. package/editor-web/assets/{radar-ABXABTNO-cpEA41mL.js → radar-ABXABTNO-DlVrSA1d.js} +1 -1
  501. package/editor-web/assets/{railroad-I3PHUGI6-BLyy5R2c.js → railroad-I3PHUGI6-nFbuLAtc.js} +1 -1
  502. package/editor-web/assets/{railroad-abnf-LNEFI6M7-Y-oyol19.js → railroad-abnf-LNEFI6M7-Daj8h2iV.js} +1 -1
  503. package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-o58wHZsr.js → railroad-ebnf-DWYD2UWJ-eYJyl5PH.js} +1 -1
  504. package/editor-web/assets/{railroad-peg-JR7BVNR7-CcD3PXZ8.js → railroad-peg-JR7BVNR7-BTRhKZQq.js} +1 -1
  505. package/editor-web/assets/{railroadDiagram-Y72NRBL7-BuCC4eyy.js → railroadDiagram-Y72NRBL7-CeLGUjdp.js} +1 -1
  506. package/editor-web/assets/react-WA6wlt8S.js +1 -0
  507. package/editor-web/assets/{repeat-2-C5PCbNsg.js → repeat-2-VQP1EVOZ.js} +1 -1
  508. package/editor-web/assets/{requirementDiagram-EQYSW5RA-Dp-JFGn4.js → requirementDiagram-EQYSW5RA-Dmk9XRM5.js} +1 -1
  509. package/editor-web/assets/row-BRlEWRrK.js +1 -0
  510. package/editor-web/assets/{sankeyDiagram-SY24JHO5-rYuCqEvw.js → sankeyDiagram-SY24JHO5-Yn4zlrAM.js} +1 -1
  511. package/editor-web/assets/schemas-VikZYZIK.js +1 -0
  512. package/editor-web/assets/{sequenceDiagram-BLEHNHQU-DryW8x6d.js → sequenceDiagram-BLEHNHQU-BTRnp_PW.js} +1 -1
  513. package/editor-web/assets/session-Do9AqS38.js +1 -0
  514. package/editor-web/assets/slides-diTEQ3C5.js +1 -0
  515. package/editor-web/assets/snapshots-BUGlKQIB.js +56 -0
  516. package/editor-web/assets/sound-Bj3o9_Fa.js +1 -0
  517. package/editor-web/assets/split-CNU1RHcX.js +3 -0
  518. package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-Bnp0XfpT.js → stateDiagram-v2-A6IESKWZ-kstrRKv2.js} +1 -1
  519. package/editor-web/assets/{strikethrough-DJckA35o.js → strikethrough-CfXx6IYH.js} +1 -1
  520. package/editor-web/assets/{svg-BjM9RazX.js → svg-Cx50MpxK.js} +1 -1
  521. package/editor-web/assets/swatch-WeJD41aW.js +1 -0
  522. package/editor-web/assets/{swimlanes-B3ENRKFQ-BiRRhhbd.js → swimlanes-B3ENRKFQ-DaZsZkeP.js} +1 -1
  523. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-CBZAujYY.js +8 -0
  524. package/editor-web/assets/switch-N0G_sbqt.js +1 -0
  525. package/editor-web/assets/syntax-BVsgRJ4I.js +66 -0
  526. package/editor-web/assets/syntax-oWsKBWFw.js +1 -0
  527. package/editor-web/assets/table-B6hVZAMi.js +1 -0
  528. package/editor-web/assets/tabs-DIFDqj-l.js +1 -0
  529. package/editor-web/assets/{textarea-BGtPqZdB.js → textarea-tEWvBY9p.js} +1 -1
  530. package/editor-web/assets/{timeline-definition-JXYKGLGB-D-Q5ZtDF.js → timeline-definition-JXYKGLGB-CLCvY-Yf.js} +1 -1
  531. package/editor-web/assets/{trash-2-Bjj6cWzP.js → trash-2-BP6nqpg2.js} +1 -1
  532. package/editor-web/assets/{treeView-D4JQ5SDB-B6DDatXq.js → treeView-D4JQ5SDB-BmN0gwdC.js} +1 -1
  533. package/editor-web/assets/{treemap-SAJKECNS-D7j5ZhiI.js → treemap-SAJKECNS-DN29G_E_.js} +1 -1
  534. package/editor-web/assets/{undo-2-yOSG766T.js → undo-2-CHR0nvWL.js} +1 -1
  535. package/editor-web/assets/{usecaseDiagram-WPOLBNNX-tkrdKUJB.js → usecaseDiagram-WPOLBNNX-DTRS54cB.js} +1 -1
  536. package/editor-web/assets/{vennDiagram-Q3Y3IDCW-Ch4XbSnD.js → vennDiagram-Q3Y3IDCW-DAAc11Hx.js} +1 -1
  537. package/editor-web/assets/video-BlvmR8BK.js +1 -0
  538. package/editor-web/assets/{wardley-7MLQ67FV-Bynt7qNQ.js → wardley-7MLQ67FV-B-UYkmdB.js} +1 -1
  539. package/editor-web/assets/{wardleyDiagram-IVAIDKWA-DRuSgm_L.js → wardleyDiagram-IVAIDKWA-BmbwCaky.js} +1 -1
  540. package/editor-web/assets/words-D_4T9Adq.js +3 -0
  541. package/editor-web/assets/words-WgdEQdYP.js +2 -0
  542. package/editor-web/assets/{xychartDiagram-4URNHDU4-DctpvfkL.js → xychartDiagram-4URNHDU4-ChAfAq1U.js} +1 -1
  543. package/editor-web/index.html +6 -5
  544. package/package.json +8 -2
  545. package/editor-web/assets/alt-BOVao_9S.js +0 -4
  546. package/editor-web/assets/article-B6YCzhj8.js +0 -73
  547. package/editor-web/assets/calc-worker-B5-fDWnb.js +0 -45
  548. package/editor-web/assets/channel-C26aBI4o.js +0 -1
  549. package/editor-web/assets/chart-BOnxneyw.js +0 -1
  550. package/editor-web/assets/choice-O5nwc2N0.js +0 -1
  551. package/editor-web/assets/collaborator-BJU5qwHd.js +0 -1
  552. package/editor-web/assets/createLucideIcon-B3B95oX5.js +0 -1
  553. package/editor-web/assets/dist-C6NqUEG4.js +0 -16
  554. package/editor-web/assets/dist-C9UGmCG9.js +0 -6
  555. package/editor-web/assets/dist-CAk5bjBm.js +0 -1
  556. package/editor-web/assets/dist-CKyfo5RM.js +0 -340
  557. package/editor-web/assets/dist-CRaWqNwq.js +0 -37
  558. package/editor-web/assets/dist-CwIBc7HQ.js +0 -1
  559. package/editor-web/assets/dist-DXRmkezB.js +0 -38
  560. package/editor-web/assets/dist-EKK5i0dG.js +0 -219
  561. package/editor-web/assets/dist-hHJlpLWo.js +0 -5
  562. package/editor-web/assets/dist-oYKcwWUj.js +0 -4
  563. package/editor-web/assets/dist-shKo7XVN.js +0 -2
  564. package/editor-web/assets/dist-wrKxBrVu.js +0 -24
  565. package/editor-web/assets/flowDiagram-IUGLLWBU-ouDQYiTr.js +0 -1
  566. package/editor-web/assets/hint-_AQWCDMj.js +0 -1
  567. package/editor-web/assets/index-BsstP-cI.js +0 -28
  568. package/editor-web/assets/index-DQRcmxBO.css +0 -2
  569. package/editor-web/assets/minus-Cgmm6ncD.js +0 -1
  570. package/editor-web/assets/progress-0B_TVsPi.js +0 -6
  571. package/editor-web/assets/react-BP46yLMB.js +0 -1
  572. package/editor-web/assets/react-pgBZqVxJ.js +0 -96
  573. package/editor-web/assets/schemas-Ewwjtbf4.js +0 -1
  574. package/editor-web/assets/session-DiI9KYRI.js +0 -1
  575. package/editor-web/assets/slides-CCwgBcGH.js +0 -1
  576. package/editor-web/assets/sound-CqryteNl.js +0 -1
  577. package/editor-web/assets/swatch-DL3HqIjW.js +0 -1
  578. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-BkOls8Tv.js +0 -8
  579. package/editor-web/assets/switch-DltnKqN-.js +0 -1
  580. package/editor-web/assets/syntax-CC6QYhCz.js +0 -1
  581. package/editor-web/assets/tabs-C-re0Kxn.js +0 -1
  582. package/editor-web/assets/video-DXFiCNGc.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{itemNameOf as m,listsFile as v}from"@allyhub/formats";import{randomBytes as g}from"node:crypto";import{isAbsolute as u,relative as x,resolve as y,sep as O}from"node:path";import{AGENT_NAME as b,FILE_METHODS as T,HOST_METHODS as w,JSONRPC as c,PRESENCE_METHODS as S,PROJECT_TOOLS as h,RPC_ERROR as d,RequestSchema as E,RpcError as l,answer as f}from"@allyhub/protocol";import{Checker as j,Indexer as k}from"./background.js";import{Exports as P}from"./exports.js";import{hasFileManager as N,revealFile as R}from"./reveal.js";import{Live as M}from"./live.js";import{fileIn as p}from"./paths.js";import{kindContext as C}from"./kinds.js";import{Presence as J}from"./presence.js";import{Texts as _}from"./texts.js";import{contributedTool as H,contributedTools as F,projectToolContext as q,toolHandlers as A}from"./tools.js";import{Watcher as D}from"./watcher.js";import{Writer as I}from"./writer.js";export const SERVER_METHODS={...T,"tools/call":w["tools/call"],...S};const L=5e3;export class ProjectServer{root;writer;watcher;live;exports;presence;texts;placing=Promise.resolve();listed;extensions;reveal;checker;serving;indexer;clients=new Map;contributed;services;held=new Map;unhearJobs;constructor(e){this.root=y(e.root),this.services={...e.jobs===void 0?{}:{jobs:e.jobs},...e.cloud===void 0?{}:{cloud:e.cloud},...e.env===void 0?{}:{env:e.env},...e.ports===void 0?{}:{ports:e.ports}},this.unhearJobs=e.jobs?.on(t=>{if(!u(t.about.id))return;const r=x(this.root,t.about.id);r===""||r.startsWith("..")||u(r)||this.notify("jobs/changed",{job:t,item:r.split(O).join("/")})})??(()=>{}),this.contributed=F(e.kinds),this.extensions=e.extensions,this.live=new M(this.root,{kinds:e.kinds,...e.gpu===void 0?{}:{gpu:e.gpu}}),this.presence=new J(t=>{this.notify("presence/changed",{collaborators:t})}),this.texts=new _(this.root),this.watcher=new D(this.root,(t,r)=>{this.sendTo(this.watchOwner(t),"files/changed",{watch:t,changes:r})},t=>{this.live.moved(t),this.notify("project/changed",{revision:t}),this.checker?.schedule()},{by:{kind:"agent",name:b},moved:t=>{this.placing=this.placing.then(()=>this.wroteOutside(t))}}),this.writer=new I(this.root,e.kinds,(t,r)=>{for(const n of t)this.texts.set(n.path,n.text);this.watcher.wrote(t.map(({path:n,version:s})=>({path:n,version:s})),r)},e.writable),this.reveal=e.reveal===!1?void 0:e.reveal??(N()?R:void 0),this.exports=new P(this.root,e.kinds,t=>{this.notify("export/changed",{job:t})},e.jobs===void 0?void 0:{jobs:e.jobs,nameOf:async t=>{const{items:r}=await this.tool("project/items",{}),n=r.find(s=>s.id===t);return m(n??{id:t})}},{...e.extensions?{processors:e.extensions.exportProcessors(),analyses:e.extensions.mediaAnalyses()}:{}});const i=e.index??process.env.ALLYHUB_NO_INDEX!=="1";if(e.check!==!1){const t=i?new k({root:this.root,analyses:e.extensions?.mediaAnalyses()??[],env:e.env??process.env,emit:n=>{this.notify("index/changed",{jobs:n})},made:()=>{this.checker?.schedule(!0)}}):void 0;this.indexer=t;const r=e.extensions?.fileEditors();this.checker=new j({live:this.live,...r===void 0?{}:{files:r},emit:n=>{this.notify("check/changed",n)},...t?{needs:n=>{t.want(n)}}:{},...e.settle===void 0?{}:{settle:e.settle}})}}static open(e){const i=new ProjectServer(e);return i.watcher.start(),i.checker?.schedule(),i.texts.warm(),Promise.resolve(i)}async settled(){await this.watcher.settled(),await this.placing}async wroteOutside(e){let i;for(const r of e){const{changed:n,lines:s}=await this.texts.changed(r).catch(()=>({changed:!1,lines:void 0}));n&&(i={path:r,...s})}if(i===void 0)return;const t=await this.itemOf(i.path);this.presence.agent({doing:"editing",...t===void 0?{}:{item:t},source:i})}async itemOf(e){const i=Date.now();this.listed!==void 0&&i-this.listed.at<L||(this.listed={at:i,items:this.tool("project/items",{}).then(s=>s.items,()=>[])});const r=await this.listed?.items??[],n=r.filter(s=>s.dir!==""&&e.startsWith(`${s.dir}/`)).sort((s,o)=>o.dir.length-s.dir.length);return(r.find(s=>s.entry===e)??r.find(s=>s.files!==void 0&&v(s.files,e))??n[0])?.id}owners=new Map;watchOwner(e){return this.owners.get(e)}connect(e,i={}){const t=`c${g(6).toString("hex")}`;this.clients.set(t,e);const r=this.handlersFor(t,i.origin);return{id:t,receive:async n=>{const s=await this.answerOne(r,n);s&&e(s)},close:()=>{this.clients.delete(t),this.watcher.forget(t);for(const[n,s]of this.owners)s===t&&this.owners.delete(n)}}}channel(){const e=new Set,i=this.connect(t=>{const r=JSON.parse(JSON.stringify(t));queueMicrotask(()=>{for(const n of e)n(r)})});return{send:t=>{i.receive(JSON.parse(JSON.stringify(t)))},listen:t=>(e.add(t),()=>e.delete(t)),close:()=>{i.close()}}}notify(e,i){for(const t of this.clients.values())t({jsonrpc:c,method:e,params:i})}sendTo(e,i,t){e!==void 0&&this.clients.get(e)?.({jsonrpc:c,method:i,params:t})}async answerOne(e,i){const t=E.safeParse(i);if(!t.success){const n=i?.id;return typeof n!="string"&&typeof n!="number"?void 0:{jsonrpc:c,id:n,error:{code:d.invalidRequest,message:"Not a JSON-RPC request."}}}const r=t.data;return Object.hasOwn(w,r.method)&&r.method!=="tools/call"?{jsonrpc:c,id:r.id,error:{code:d.methodNotFound,message:`${r.method} is answered by the page that hosts the editor, not by allyhub dev's server.`}}:f(SERVER_METHODS,e,r)}handlersFor(e,i){const{writer:t,watcher:r}=this,n=this.toolSet(()=>this.serving?.tree(i));return{"files/read":({path:s})=>t.read(s),"files/write":async({path:s,text:o,over:a})=>({version:await t.write(s,o,a,e)}),"files/upload":async({dir:s,name:o,data:a})=>({path:await t.upload(s,o,Buffer.from(a,"base64"),e)}),"files/url":async({path:s})=>{if(await p(this.root,s),!this.serving)throw new l(d.unavailable,"This server serves no files over HTTP: only allyhub dev's does.");return{url:this.serving.file(i,s)}},"files/list":({dir:s})=>t.list(s),"files/move":async({from:s,to:o})=>({rewritten:await t.move(s,o,e)}),"files/remove":async({path:s})=>({trash:await t.remove(s,e)}),"files/trash":async()=>({entries:await t.trash()}),"files/restore":async({id:s})=>({path:await t.restore(s,e)}),"files/watch":async({paths:s})=>{for(const a of s)await p(this.root,a);const o=await r.watch(e,s);return this.owners.set(o,e),{watch:o}},"files/unwatch":({watch:s})=>(this.owners.get(s)===e&&(r.unwatch(s),this.owners.delete(s)),Promise.resolve({})),"tools/call":async({name:s,arguments:o})=>({result:await this.runTool(n,s,o)}),"presence/get":()=>Promise.resolve({collaborators:this.presence.list()})}}toolSet(e){const i=this.toolContext(e);return{core:A(i),context:q(i)}}async runTool(e,i,t){const r={jsonrpc:c,id:0,method:i,params:t},n=Object.hasOwn(h,i)?void 0:this.contributed.get(i);let s;if(n===void 0)s=await f(h,e.core,r);else{const o=await H(n).catch(a=>{throw new l(d.internal,a instanceof Error?a.message:String(a))});s=await f({[i]:o},{[i]:a=>o.run(a,e.context)},r)}if("error"in s)throw new l(s.error.code,s.error.message,s.error.data);return s.result}hasTool(e){return Object.hasOwn(h,e)||this.contributed.has(e)}toolContext(e){return{live:this.live,checker:this.checker,exports:this.exports,reveal:this.reveal,tree:e,extensions:this.extensions,services:this.services,held:this.held,kindContext:C(this.root,i=>this.hasTool(i),(i,t)=>this.tool(i,t))}}async tool(e,i,t={}){const r=await this.runTool(this.toolSet(()=>t.tree??this.serving?.tree(void 0)),e,i);return Object.hasOwn(h,e)?h[e].result.parse(r):r}async close(){this.unhearJobs(),this.presence.close(),this.watcher.close(),this.clients.clear();for(const e of[...this.held.values()].reverse())await Promise.resolve(e.dispose()).catch(()=>{});this.held.clear(),await this.checker?.close(),await this.indexer?.close(),await this.exports.close(),await this.live.close()}}
2
+ import{itemNameOf as v,listsFile as g}from"@allyhub/formats";import{randomBytes as y}from"node:crypto";import{isAbsolute as u,relative as x,resolve as O,sep as b}from"node:path";import{AGENT_NAME as T,FILE_METHODS as S,HOST_METHODS as p,JSONRPC as h,PRESENCE_METHODS as k,PROJECT_TOOLS as c,RPC_ERROR as l,RequestSchema as E,RpcError as d,answer as f}from"@allyhub/protocol";import{Checker as j,Indexer as P}from"./background.js";import{Exports as N}from"./exports.js";import{downloadsFolder as I,hasFileManager as R,revealFile as M}from"./reveal.js";import{Live as C}from"./live.js";import{Inputs as J}from"./inputs.js";import{Pages as _}from"./pages.js";import{fileIn as w}from"./paths.js";import{kindContext as F}from"./kinds.js";import{Presence as H}from"./presence.js";import{Texts as q}from"./texts.js";import{contributedTool as A,contributedTools as D,projectToolContext as L,toolHandlers as W}from"./tools.js";import{Watcher as B}from"./watcher.js";import{Writer as $}from"./writer.js";export const SERVER_METHODS={...S,"tools/call":p["tools/call"],...k};const G=5e3;export class ProjectServer{root;writer;watcher;live;exports;presence;inputs=new J;pages;texts;placing=Promise.resolve();telling=Promise.resolve();listed;extensions;reveal;checker;serving;indexer;clients=new Map;contributed;services;held=new Map;unhearJobs;constructor(e){this.root=O(e.root),this.services={...e.jobs===void 0?{}:{jobs:e.jobs},...e.cloud===void 0?{}:{cloud:e.cloud},...e.env===void 0?{}:{env:e.env},...e.ports===void 0?{}:{ports:e.ports}},this.unhearJobs=e.jobs?.on(t=>{if(!u(t.about.id))return;const s=x(this.root,t.about.id);s===""||s.startsWith("..")||u(s)||this.notify("jobs/changed",{job:t,item:s.split(b).join("/")})})??(()=>{}),this.contributed=D(e.kinds),this.extensions=e.extensions,this.live=new C(this.root,{kinds:e.kinds,...e.gpu===void 0?{}:{gpu:e.gpu},recordInputs:(t,s,n)=>{const r=[...n];this.listedItems().then(o=>{const a=o.find(m=>m.entry===t);a&&this.inputs.set(a.id,s,r)})}}),this.pages=new _({root:this.root,ports:e.ports,inputs:this.inputs}),this.presence=new H(t=>{this.notify("presence/changed",{collaborators:t})}),this.texts=new q(this.root),this.watcher=new B(this.root,(t,s)=>{this.sendTo(this.watchOwner(t),"files/changed",{watch:t,changes:s})},(t,s)=>{this.live.moved(t),this.notify("project/changed",{revision:t}),this.checker?.schedule(),this.telling=this.telling.then(()=>this.tellItems(s))},{by:{kind:"agent",name:T},moved:t=>{this.placing=this.placing.then(()=>this.wroteOutside(t))}}),this.writer=new $(this.root,e.kinds,(t,s)=>{for(const n of t)this.texts.set(n.path,n.text);this.watcher.wrote(t.map(({path:n,version:r})=>({path:n,version:r})),s)},e.writable),this.reveal=e.reveal===!1?void 0:e.reveal??(R()?M:void 0),this.exports=new N(this.root,e.kinds,t=>{this.notify("export/changed",{job:t})},e.jobs===void 0?void 0:{jobs:e.jobs,nameOf:async t=>{const{items:s}=await this.tool("project/items",{}),n=s.find(r=>r.id===t);return v(n??{id:t})}},{...e.extensions?{processors:e.extensions.exportProcessors(),analyses:e.extensions.mediaAnalyses()}:{},...this.reveal===void 0||e.exportsTo===!1?{}:{saveTo:e.exportsTo??I}});const i=e.index??process.env.ALLYHUB_NO_INDEX!=="1";if(e.check!==!1){const t=i?new P({root:this.root,analyses:e.extensions?.mediaAnalyses()??[],env:e.env??process.env,emit:n=>{this.notify("index/changed",{jobs:n})},made:()=>{this.checker?.schedule(!0)}}):void 0;this.indexer=t;const s=e.extensions?.fileEditors();this.checker=new j({live:this.live,...s===void 0?{}:{files:s},emit:n=>{this.notify("check/changed",n)},...t?{needs:n=>{t.want(n)}}:{},...e.settle===void 0?{}:{settle:e.settle}})}}static open(e){const i=new ProjectServer(e);return i.watcher.start(),i.checker?.schedule(),i.texts.warm(),Promise.resolve(i)}async settled(){await this.watcher.settled(),await this.placing,await this.telling}async tellItems(e){if(e.length===0)return;const i=await this.listedItems();for(const[t,s]of this.inputs.affected(i,e))this.notify("items/changed",{item:t,paths:s})}async wroteOutside(e){let i;for(const s of e){const{changed:n,lines:r}=await this.texts.changed(s).catch(()=>({changed:!1,lines:void 0}));n&&(i={path:s,...r})}if(i===void 0)return;const t=await this.itemOf(i.path);this.presence.agent({doing:"editing",...t===void 0?{}:{item:t},source:i})}async itemOf(e){const i=await this.listedItems(),t=i.filter(s=>s.dir!==""&&e.startsWith(`${s.dir}/`)).sort((s,n)=>n.dir.length-s.dir.length);return(i.find(s=>s.entry===e)??i.find(s=>s.files!==void 0&&g(s.files,e))??t[0])?.id}async listedItems(){const e=Date.now();return this.listed!==void 0&&e-this.listed.at<G||(this.listed={at:e,items:this.tool("project/items",{}).then(t=>t.items,()=>[])}),await this.listed?.items??[]}owners=new Map;watchOwner(e){return this.owners.get(e)}connect(e,i={}){const t=`c${y(6).toString("hex")}`;this.clients.set(t,e);const s=this.handlersFor(t,i.origin);return{id:t,receive:async n=>{const r=await this.answerOne(s,n);r&&e(r)},close:()=>{this.clients.delete(t),this.watcher.forget(t);for(const[n,r]of this.owners)r===t&&this.owners.delete(n)}}}channel(){const e=new Set,i=this.connect(t=>{const s=JSON.parse(JSON.stringify(t));queueMicrotask(()=>{for(const n of e)n(s)})});return{send:t=>{i.receive(JSON.parse(JSON.stringify(t)))},listen:t=>(e.add(t),()=>e.delete(t)),close:()=>{i.close()}}}notify(e,i){for(const t of this.clients.values())t({jsonrpc:h,method:e,params:i})}sendTo(e,i,t){e!==void 0&&this.clients.get(e)?.({jsonrpc:h,method:i,params:t})}async answerOne(e,i){const t=E.safeParse(i);if(!t.success){const n=i?.id;return typeof n!="string"&&typeof n!="number"?void 0:{jsonrpc:h,id:n,error:{code:l.invalidRequest,message:"Not a JSON-RPC request."}}}const s=t.data;return Object.hasOwn(p,s.method)&&s.method!=="tools/call"?{jsonrpc:h,id:s.id,error:{code:l.methodNotFound,message:`${s.method} is answered by the page that hosts the editor, not by allyhub dev's server.`}}:f(SERVER_METHODS,e,s)}handlersFor(e,i){const{writer:t,watcher:s}=this,n=this.toolSet(()=>this.serving?.tree(i));return{"files/read":({path:r})=>t.read(r),"files/write":async({path:r,text:o,over:a})=>({version:await t.write(r,o,a,e)}),"files/upload":async({dir:r,name:o,data:a})=>({path:await t.upload(r,o,Buffer.from(a,"base64"),e)}),"files/url":async({path:r})=>{if(await w(this.root,r),!this.serving)throw new d(l.unavailable,"This server serves no files over HTTP: only allyhub dev's does.");return{url:this.serving.file(i,r)}},"files/list":({dir:r})=>t.list(r),"files/move":async({from:r,to:o})=>({rewritten:await t.move(r,o,e)}),"files/remove":async({path:r})=>({trash:await t.remove(r,e)}),"files/trash":async()=>({entries:await t.trash()}),"files/restore":async({id:r})=>({path:await t.restore(r,e)}),"files/watch":async({paths:r})=>{for(const a of r)await w(this.root,a);const o=await s.watch(e,r);return this.owners.set(o,e),{watch:o}},"files/unwatch":({watch:r})=>(this.owners.get(r)===e&&(s.unwatch(r),this.owners.delete(r)),Promise.resolve({})),"tools/call":async({name:r,arguments:o})=>({result:await this.runTool(n,r,o)}),"presence/get":()=>Promise.resolve({collaborators:this.presence.list()})}}toolSet(e){const i=this.toolContext(e);return{core:W(i),context:L(i)}}async runTool(e,i,t){const s={jsonrpc:h,id:0,method:i,params:t},n=Object.hasOwn(c,i)?void 0:this.contributed.get(i);let r;if(n===void 0)r=await f(c,e.core,s);else{const o=await A(n).catch(a=>{throw new d(l.internal,a instanceof Error?a.message:String(a))});r=await f({[i]:o},{[i]:a=>o.run(a,e.context)},s)}if("error"in r)throw new d(r.error.code,r.error.message,r.error.data);return r.result}hasTool(e){return Object.hasOwn(c,e)||this.contributed.has(e)}toolContext(e){return{live:this.live,checker:this.checker,exports:this.exports,reveal:this.reveal,tree:e,extensions:this.extensions,services:this.services,held:this.held,kindContext:F(this.root,i=>this.hasTool(i),(i,t)=>this.tool(i,t)),inputs:this.inputs,pages:this.pages}}async tool(e,i,t={}){const s=await this.runTool(this.toolSet(()=>t.tree??this.serving?.tree(void 0)),e,i);return Object.hasOwn(c,e)?c[e].result.parse(s):s}async close(){this.unhearJobs(),this.presence.close(),this.watcher.close(),this.clients.clear();for(const e of[...this.held.values()].reverse())await Promise.resolve(e.dispose()).catch(()=>{});this.held.clear(),await this.pages.close(),await this.checker?.close(),await this.indexer?.close(),await this.exports.close(),await this.live.close()}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{readdir as U,realpath as Y,stat as Z}from"node:fs/promises";import{join as g,relative as ee,sep as te}from"node:path";import{KeyedStore as oe}from"@allyhub/project";import{NEVER_CANCELLED as se}from"@allyhub/extension-api";import{COMPONENT_STILLS_MAX as J,KindSnapshotSchema as ne,RpcError as K,SNAPSHOT_TREE as m,pieceSourcePath as ie,snapshotAnswerPath as x,snapshotPreviewPath as re,stillPath as z,stillsIndexKey as ce,stillsIndexPath as ae}from"@allyhub/protocol";import{runtimeFiles as fe}from"@allyhub/stage-page";import{itemPreview as de}from"./card.js";import{kindContext as le,kindItem as pe}from"./kinds.js";import{mediaTypeOf as H}from"@allyhub/formats";import{Reach as ue,pieceBundle as me,pieceNames as he,reachedCheck as we,reachedSource as ye}from"./reach.js";import{matteFile as $e}from"./tree.js";const T="https://tree.invalid/";function M(n){return typeof n=="string"?n.startsWith(T)?n.slice(T.length):n:Array.isArray(n)?n.map(M):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([w,c])=>[w,M(c)])):n}const j=n=>new TextEncoder().encode(JSON.stringify(n));async function V(n){return(await U(n,{recursive:!0,withFileTypes:!0}).catch(()=>[])).filter(c=>c.isFile()).map(c=>ee(n,g(c.parentPath,c.name)).split(te).join("/"))}const ge=n=>Z(n).then(w=>w.isFile(),()=>!1);export async function recordTree(n,w={}){const{project:c}=n,{live:u,root:y}=c;await c.watcher.settled();const P=new Map,h=(e,t,o=H(e))=>{P.set(e,{path:e,type:o,file:t})},b=(e,t,o=H(e))=>{P.set(e,{path:e,type:o,bytes:t})},N=async(e,t)=>{for(const o of await V(t))h(`${e}${o}`,g(t,o))},W=u.revision,a=await u.prepared(),v=new Map;if(n.ui!==void 0)for(const e of await V(n.ui))h(`${m.editor}${e}`,g(n.ui,e));for(const[e,t]of await fe())h(`${m.runtime}${e}`,t);const A=async(e,t)=>{let o;try{o={result:M(await c.tool(e,t,{tree:T}))}}catch(s){o={error:s instanceof K?{code:s.code,message:s.message}:{code:-32603,message:s instanceof Error?s.message:""}}}const r=x(e,t);b(r,j(o));const d=t.item;return typeof d=="string"&&v.set(d,[...v.get(d)??[],r]),o},X=le(y,e=>c.hasTool(e),async(e,t)=>{const o=await A(e,t);if(o.error)throw new K(o.error.code,o.error.message);return o.result}),q=async(e,t,o)=>{const r=new Map;for(const p of o)r.set(ce(p),p);if(r.size===0)return;const d=oe.of(y,"stills"),s={stills:{}},l=f.of(e),i=[...r];for(let p=0;p<i.length;p+=J){const O=i.slice(p,p+J);(await c.tool("components/stills",{item:e,...t===""?{}:{version:t},components:O.map(([,$])=>$)},{tree:T}).catch(()=>{}))?.stills.forEach(($,Q)=>{const B=O[Q]?.[0];!$||B===void 0||(s.stills[B]=$.key,h(z($.key),d.path(`${$.key}.webp`),"image/webp"),l?.tree.add(z($.key)))})}const S=ae(e,t);b(S,j(s),"application/json"),l?.tree.add(S)},I=(await A("project/items",{})).result,E=(I?.items??[]).filter(e=>e.kind!==void 0),G=new Map(a.items.map(e=>[e.id,e.files])),f=new ue(E.map(e=>({...e,files:G.get(e.id)??e.files})),a.files,(a.bundle?.beside??[]).map(e=>`${m.build}${e}`)),k=c.checker?.state,R=k===void 0||k.status==="waiting"||k.status==="running"?{status:"off",revision:u.revision,problems:k?.problems??[],facts:k?.facts??[]}:k;b(x("check/results",{}),j({result:R}));for(const e of f.items){const t=f.of(e),o=new Set(a.pieces.filter(s=>s.place===e).map(s=>s.id)),r=E.find(s=>s.id===e)?.entry,d=s=>s===r||f.itemsOf(s).includes(e);t?.own.push({path:x("project/items",{}),type:"application/json",bytes:j({result:{...I,items:E.filter(s=>s.id===e)}})},{path:x("check/results",{}),type:"application/json",bytes:j({result:we(R,o,d)})})}for(const e of a.bundle?.chunks.files??[])h(`${m.build}${e}`,g(u.pieceDir,e));for(const e of a.bundle?.beside??[])await N(`${m.build}${e}`,g(u.pieceDir,e));const C=new Set(Object.keys(a.media));for(const e of Object.keys(a.media)){const t=$e(y,a.media[e]);t!==void 0&&await ge(t)&&h(`${m.matte}${e}`,t,"video/mp4")}const F=new Map,_=e=>({file:(t,o,r)=>{h(`${e}${t}`,o,r)},folder:(t,o)=>N(`${e}${t}`,o),bytes:(t,o,r)=>{b(`${e}${t}`,o,r)},media:t=>{C.add(t)}});for(const e of E){const t=await c.extensions?.kindProvider(e.kind);if(!t?.snapshot)continue;const o=await Promise.resolve(t.snapshot(pe(e),X,se)).catch(()=>{}),r=ne.safeParse(o??{});if(!r.success)continue;const{stills:d,shows:s,routes:l}=r.data;s&&F.set(e.id,{media:new Set(s.media),data:new Set(s.data)});for(const i of d??[])await q(e.id,i.version,i.components);for(const[i,S]of Object.entries(l??{})){const p=await u.routes.route(i).catch(()=>{});if(p?.route.recordItem)for(const O of S)await p.route.recordItem(O,_(i),p.context).catch(()=>{})}}for(const e of C)h(`${m.media}${e}`,g(y,e));for(const e of u.routes.specs.keys()){const t=await u.routes.route(e).catch(()=>{});t?.route.record&&await t.route.record(_(e),t.context).catch(()=>{})}const D=[y,await Y(y).catch(()=>y)];for(const e of a.pieces){const t=await u.source(e.id).catch(()=>{});if(!t)continue;const o=me(a.bundle?.chunks,e.id),r=he({prepared:a,piece:e,reach:f,modules:o.modules,roots:D,reads:c.checker?.reads.get(e.id),shows:F.get(e.place)}),d=a.pieces.filter(i=>i.id!==e.id&&!D.some(S=>o.modules.has(g(S,i.file)))).map(i=>i.id),s=ie(e.id);b(s,j(ye(t,r,d)));const l=f.of(e.place);if(l){l.tree.add(s);for(const i of o.files)l.tree.add(`${m.build}${i}`);for(const i of r.media)l.tree.add(`${m.media}${i}`),l.tree.add(`${m.matte}${i}`),l.files.add(i)}}for(const[e,t]of v)for(const o of t)f.of(e)?.tree.add(o);for(const e of a.docs)for(const t of e.shows)f.of(e.place)?.files.add(t);for(const e of a.sheets)for(const t of e.files)f.of(e.place)?.files.add(t);const L=w.preview===!1?void 0:w.preview??(e=>de(n,e));if(L)for(const e of E){const t=await L(e).catch(()=>{});if(t===void 0)continue;const o=re(e.id);b(o,Buffer.from(JSON.stringify(t)),"application/json"),f.of(e.id)?.tree.add(o)}return{revision:W,files:[...P.values()],reach:f.done(new Set(P.keys())),routes:u.routes.loads()}}
2
+ import{readdir as Z,realpath as ee,stat as te}from"node:fs/promises";import{setTimeout as oe}from"node:timers/promises";import{join as b,relative as se,sep as ie}from"node:path";import{openPage as ne}from"@allyhub/browser";import{KeyedStore as re}from"@allyhub/project";import{NEVER_CANCELLED as ae}from"@allyhub/extension-api";import{COMPONENT_STILLS_MAX as J,KindSnapshotSchema as ce,RpcError as K,SNAPSHOT_TREE as m,pieceSourcePath as fe,snapshotAnswerPath as x,snapshotPreviewPath as de,stillPath as z,stillsIndexKey as le,stillsIndexPath as ue}from"@allyhub/protocol";import{runtimeFiles as pe}from"@allyhub/stage-page";import{itemPreview as me}from"./card.js";import{kindContext as he,kindItem as we}from"./kinds.js";import{mediaTypeOf as H}from"@allyhub/formats";import{Reach as ge,pieceBundle as ye,pieceNames as $e,reachedCheck as be,reachedSource as ke}from"./reach.js";import{matteFile as Se}from"./tree.js";export const PAGE_RECORDING={width:1440,height:900,timeout:3e4,settle:1500};const M="https://tree.invalid/";function v(n){return typeof n=="string"?n.startsWith(M)?n.slice(M.length):n:Array.isArray(n)?n.map(v):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([g,a])=>[g,v(a)])):n}const E=n=>new TextEncoder().encode(JSON.stringify(n));async function U(n){return(await Z(n,{recursive:!0,withFileTypes:!0}).catch(()=>[])).filter(a=>a.isFile()).map(a=>se(n,b(a.parentPath,a.name)).split(ie).join("/"))}const je=n=>te(n).then(g=>g.isFile(),()=>!1);export async function recordTree(n,g={}){const{project:a}=n,{live:l,root:y}=a;await a.watcher.settled();const O=new Map,w=(e,t,o=H(e))=>{O.set(e,{path:e,type:o,file:t})},k=(e,t,o=H(e))=>{O.set(e,{path:e,type:o,bytes:t})},N=async(e,t)=>{for(const o of await U(t))w(`${e}${o}`,b(t,o))},V=l.revision,c=await l.prepared(),T=new Map;if(n.ui!==void 0)for(const e of await U(n.ui))w(`${m.editor}${e}`,b(n.ui,e));for(const[e,t]of await pe())w(`${m.runtime}${e}`,t);const R=async(e,t)=>{let o;try{o={result:v(await a.tool(e,t,{tree:M}))}}catch(s){o={error:s instanceof K?{code:s.code,message:s.message}:{code:-32603,message:s instanceof Error?s.message:""}}}const i=x(e,t);k(i,E(o));const f=t.item;return typeof f=="string"&&T.set(f,[...T.get(f)??[],i]),o},X=he(y,e=>a.hasTool(e),async(e,t)=>{const o=await R(e,t);if(o.error)throw new K(o.error.code,o.error.message);return o.result}),q=async(e,t,o)=>{const i=new Map;for(const h of o)i.set(le(h),h);if(i.size===0)return;const f=re.of(y,"stills"),s={stills:{}},u=d.of(e),r=[...i];for(let h=0;h<r.length;h+=J){const j=r.slice(h,h+J);(await a.tool("components/stills",{item:e,...t===""?{}:{version:t},components:j.map(([,$])=>$)},{tree:M}).catch(()=>{}))?.stills.forEach(($,Y)=>{const G=j[Y]?.[0];!$||G===void 0||(s.stills[G]=$.key,w(z($.key),f.path(`${$.key}.webp`),"image/webp"),u?.tree.add(z($.key)))})}const p=ue(e,t);k(p,E(s),"application/json"),u?.tree.add(p)},A=(await R("project/items",{})).result,P=(A?.items??[]).filter(e=>e.kind!==void 0),Q=new Map(c.items.map(e=>[e.id,e.files])),d=new ge(P.map(e=>({...e,files:Q.get(e.id)??e.files})),c.files,(c.bundle?.beside??[]).map(e=>`${m.build}${e}`)),S=a.checker?.state,I=S===void 0||S.status==="waiting"||S.status==="running"?{status:"off",revision:l.revision,problems:S?.problems??[],facts:S?.facts??[]}:S;k(x("check/results",{}),E({result:I}));for(const e of d.items){const t=d.of(e),o=new Set(c.pieces.filter(s=>s.place===e).map(s=>s.id)),i=P.find(s=>s.id===e)?.entry,f=s=>s===i||d.itemsOf(s).includes(e);t?.own.push({path:x("project/items",{}),type:"application/json",bytes:E({result:{...A,items:P.filter(s=>s.id===e)}})},{path:x("check/results",{}),type:"application/json",bytes:E({result:be(I,o,f)})})}for(const e of c.bundle?.chunks.files??[])w(`${m.build}${e}`,b(l.pieceDir,e));for(const e of c.bundle?.beside??[])await N(`${m.build}${e}`,b(l.pieceDir,e));const _=new Set(Object.keys(c.media));for(const e of Object.keys(c.media)){const t=Se(y,c.media[e]);t!==void 0&&await je(t)&&w(`${m.matte}${e}`,t,"video/mp4")}const C=new Map,D=new Map,F=e=>({file:(t,o,i)=>{w(`${e}${t}`,o,i)},folder:(t,o)=>N(`${e}${t}`,o),bytes:(t,o,i)=>{k(`${e}${t}`,o,i)},media:t=>{_.add(t)}});for(const e of P){const t=await a.extensions?.kindProvider(e.kind);if(!t?.snapshot)continue;const o=await Promise.resolve(t.snapshot(we(e),X,ae)).catch(()=>{}),i=ce.safeParse(o??{});if(!i.success)continue;const{stills:f,shows:s,routes:u,page:r}=i.data;r&&C.set(e.id,{...r.folder===void 0?{}:{folder:r.folder},...r.file===void 0?{}:{file:r.file}}),s&&D.set(e.id,{media:new Set(s.media),data:new Set(s.data)});for(const p of f??[])await q(e.id,p.version,p.components);for(const[p,h]of Object.entries(u??{})){const j=await l.routes.route(p).catch(()=>{});if(j?.route.recordItem)for(const B of h)await j.route.recordItem(B,F(p),j.context).catch(()=>{})}}for(const e of _)w(`${m.media}${e}`,b(y,e));for(const[e,t]of C){const o=await a.tool("items/page",{item:e,...t}).catch(()=>{});if(!o)continue;const i=new URL(o.url).origin,f=await ne(await l.browser(),{width:PAGE_RECORDING.width,height:PAGE_RECORDING.height,allow:s=>s===i||s.startsWith(`${i}/`)}).catch(()=>{});if(f)try{await f.goto(o.url,{timeoutMs:PAGE_RECORDING.timeout}),await f.evaluate("document.fonts.ready.then(() => true)",{timeoutMs:PAGE_RECORDING.timeout}),await oe(PAGE_RECORDING.settle)}catch{}finally{await f.close()}}for(const e of d.items){const t=d.of(e);if(t)for(const o of a.inputs.of(e))if(o===""||o.endsWith("/"))for(const i of c.files)i.startsWith(o)&&t.files.add(i);else c.files.includes(o)&&t.files.add(o)}for(const e of l.routes.specs.keys()){const t=await l.routes.route(e).catch(()=>{});t?.route.record&&await t.route.record(F(e),t.context).catch(()=>{})}const L=[y,await ee(y).catch(()=>y)];for(const e of c.pieces){const t=await l.source(e.id).catch(()=>{});if(!t)continue;const o=ye(c.bundle?.chunks,e.id),i=$e({prepared:c,piece:e,reach:d,modules:o.modules,roots:L,reads:a.checker?.reads.get(e.id),shows:D.get(e.place)}),f=c.pieces.filter(r=>r.id!==e.id&&!L.some(p=>o.modules.has(b(p,r.file)))).map(r=>r.id),s=fe(e.id);k(s,E(ke(t,i,f)));const u=d.of(e.place);if(u){u.tree.add(s);for(const r of o.files)u.tree.add(`${m.build}${r}`);for(const r of i.media)u.tree.add(`${m.media}${r}`),u.tree.add(`${m.matte}${r}`),u.files.add(r)}}for(const[e,t]of T)for(const o of t)d.of(e)?.tree.add(o);for(const e of c.docs)for(const t of e.shows)d.of(e.place)?.files.add(t);for(const e of c.sheets)for(const t of e.files)d.of(e.place)?.files.add(t);const W=g.preview===!1?void 0:g.preview??(e=>me(n,e));if(W)for(const e of P){const t=await W(e).catch(()=>{});if(t===void 0)continue;const o=de(e.id);k(o,Buffer.from(JSON.stringify(t)),"application/json"),d.of(e.id)?.tree.add(o)}return{revision:V,files:[...O.values()],reach:d.done(new Set(O.keys())),routes:l.routes.loads()}}
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{createReadStream as f}from"node:fs";import{stat as p}from"node:fs/promises";import{Readable as d}from"node:stream";import{mediaTypeOf as g}from"@allyhub/formats";export async function fileResponse(r,a,i){const c=await p(r).catch(()=>{});if(!c?.isFile())return new Response("not found",{status:404,headers:{...i}});const o={"content-type":g(r),"cache-control":"no-cache","accept-ranges":"bytes",...i},e=c.size,t=a?/^bytes=(\d*)-(\d*)$/u.exec(a.trim()):null,m=(u,l)=>d.toWeb(f(r,{start:u,end:l}));if(!t||t[1]===""&&t[2]===""||e===0)return new Response(e===0?null:m(0,e-1),{status:200,headers:{...o,"content-length":String(e)}});let n,s;return t[1]===""?(n=Math.max(0,e-Number(t[2])),s=e-1):(n=Number(t[1]),s=t[2]===""?e-1:Math.min(Number(t[2]),e-1)),n>=e||n>s?new Response(null,{status:416,headers:{...o,"content-range":`bytes */${String(e)}`}}):new Response(m(n,s),{status:206,headers:{...o,"content-length":String(s-n+1),"content-range":`bytes ${String(n)}-${String(s)}/${String(e)}`}})}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{execFile as s}from"node:child_process";import{dirname as a}from"node:path";export function hasFileManager(r=process.env,e=process.platform){return r.SSH_CONNECTION||r.SSH_TTY||r.CI?!1:e==="darwin"||e==="win32"?!0:[r.DISPLAY,r.WAYLAND_DISPLAY].some(Boolean)}export function revealCommand(r,e=process.platform){return e==="darwin"?["open",["-R",r]]:e==="win32"?["explorer",[`/select,${r}`]]:["xdg-open",[a(r)]]}export function revealFile(r){const[e,n]=revealCommand(r);return new Promise((t,i)=>{s(e,n,o=>{o&&!(process.platform==="win32"&&o.code===1)?i(new Error(o.message)):t()})})}
2
+ import{execFile as s}from"node:child_process";import{homedir as a}from"node:os";import{dirname as m,join as p}from"node:path";export function hasFileManager(r=process.env,e=process.platform){return r.SSH_CONNECTION||r.SSH_TTY||r.CI?!1:e==="darwin"||e==="win32"?!0:[r.DISPLAY,r.WAYLAND_DISPLAY].some(Boolean)}export function downloadsFolder(){return p(a(),"Downloads")}export function revealCommand(r,e=process.platform){return e==="darwin"?["open",["-R",r]]:e==="win32"?["explorer",[`/select,${r}`]]:["xdg-open",[m(r)]]}export function revealFile(r){const[e,n]=revealCommand(r);return new Promise((t,i)=>{s(e,n,o=>{o&&!(process.platform==="win32"&&o.code===1)?i(new Error(o.message)):t()})})}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{join as f}from"node:path";import{pathToFileURL as c}from"node:url";import{pathProblem as l}from"./paths.js";import{inside as h}from"./tree.js";export function contributedRoutes(r){const t=new Map;for(const o of r)for(const e of o.stageRoutes??[])t.has(e.folder)||t.set(e.folder,e);return t}const u=new Map;async function m(r){let t=u.get(r.module);t||(t=import(c(r.module).href).then(e=>{if(typeof e.default!="object"||e.default===null)throw new Error(`${r.extension}'s stage routes (${r.module}) have no default export.`);return e.default}),u.set(r.module,t),t.catch(()=>{u.get(r.module)===t&&u.delete(r.module)}));const o=(await t)[r.folder];if(!o)throw new Error(`${r.extension} serves the stage's ${r.folder} but its module (${r.module}) has no route for it.`);return o}export class Routes{specs;kept=new Map;media=new Set;contexts=new Map;o;constructor(t){this.o=t,this.specs=contributedRoutes(t.kinds)}loads(){return Object.fromEntries([...this.specs].map(([t,o])=>[t,[...o.loads]]))}allowed(t){return this.media.has(t)}async route(t){const o=this.specs.get(t);if(o)return{route:await m(o),context:this.of(t)}}async mediaOf(t,o){let e=o;for(const i of this.specs.keys()){const s=await this.route(i).catch(()=>{}),n=s?.route.media?await s.route.media(t,e,s.context).catch(()=>{}):void 0;n!==void 0&&(e=n)}return e}of(t){let o=this.contexts.get(t);if(o)return o;const{o:e,kept:i,media:s}=this;return o={root:e.root,kinds:e.kinds,get revision(){return e.revision()},prepared:()=>e.prepared(),latest:()=>e.latest(),dir:f(e.buildDir,t.slice(0,-1)),kept(n,d){const a=`${t}\0${n}`;return i.has(a)||i.set(a,d()),i.get(a)},allowMedia(n){for(const d of n)s.add(d)},inProject:n=>l(n)===void 0?h(e.root,n):void 0,view:(n,d)=>e.view(n,d)},this.contexts.set(t,o),o}}
2
+ import{join as f}from"node:path";import{pathToFileURL as c}from"node:url";import{pathProblem as l}from"./paths.js";import{inside as h}from"./tree.js";export function contributedRoutes(r){const t=new Map;for(const o of r)for(const e of o.stageRoutes??[])t.has(e.folder)||t.set(e.folder,e);return t}const a=new Map;async function m(r){let t=a.get(r.module);t||(t=import(c(r.module).href).then(e=>{if(typeof e.default!="object"||e.default===null)throw new Error(`${r.extension}'s stage routes (${r.module}) have no default export.`);return e.default}),a.set(r.module,t),t.catch(()=>{a.get(r.module)===t&&a.delete(r.module)}));const o=(await t)[r.folder];if(!o)throw new Error(`${r.extension} serves the stage's ${r.folder} but its module (${r.module}) has no route for it.`);return o}export class Routes{specs;kept=new Map;media=new Set;contexts=new Map;o;constructor(t){this.o=t,this.specs=contributedRoutes(t.kinds)}loads(){return Object.fromEntries([...this.specs].map(([t,o])=>[t,[...o.loads]]))}allowed(t){return this.media.has(t)}async route(t){const o=this.specs.get(t);if(o)return{route:await m(o),context:this.of(t)}}async mediaOf(t,o){let e=o;for(const s of this.specs.keys()){const d=await this.route(s).catch(()=>{}),n=d?.route.media?await d.route.media(t,e,d.context).catch(()=>{}):void 0;n!==void 0&&(e=n)}return e}of(t){let o=this.contexts.get(t);if(o)return o;const{o:e,kept:s,media:d}=this;return o={root:e.root,kinds:e.kinds,get revision(){return e.revision()},prepared:()=>e.prepared(),latest:()=>e.latest(),dir:f(e.buildDir,t.slice(0,-1)),kept(n,i){const u=`${t}\0${n}`;return s.has(u)||s.set(u,i()),s.get(u)},allowMedia(n){for(const i of n)d.add(i)},recordInputs:(n,i,u)=>{e.recordInputs(n,i,u)},inProject:n=>l(n)===void 0?h(e.root,n):void 0,view:(n,i)=>e.view(n,i)},this.contexts.set(t,o),o}}
@@ -1,6 +1,6 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{randomBytes as E}from"node:crypto";import{createReadStream as B}from"node:fs";import{readFile as M,stat as W}from"node:fs/promises";import{createServer as D}from"node:http";import{Readable as J}from"node:stream";import{join as G,resolve as C}from"node:path";import{getRequestListener as K}from"@hono/node-server";import{Hono as Y}from"hono";import{WebSocketServer as Q}from"ws";import{KeyedStore as V}from"@allyhub/project";import{CollaboratorStateSchema as X,PRESENCE_PATH as Z,SNAPSHOT_TREE as O,TREE_PAGES as ee,stageCsp as te}from"@allyhub/protocol";import{runtimeFile as ne}from"@allyhub/stage-page";import{mediaTypeOf as re}from"@allyhub/formats";import{pathProblem as oe}from"./paths.js";import{ProjectServer as se}from"./project.js";import{STILL_NAME as ie,inside as F,matteFile as ae,sourceName as ce}from"./tree.js";export const RPC_PATH="/rpc",RAW_PATH="/files/raw/";const h={"access-control-allow-origin":"*"};async function y(n,c,a){const g=await W(n).catch(()=>{});if(!g?.isFile())return new Response("not found",{status:404,headers:{...a}});const u={"content-type":re(n),"cache-control":"no-cache","accept-ranges":"bytes",...a},r=g.size,s=c?/^bytes=(\d*)-(\d*)$/u.exec(c.trim()):null,x=(R,N)=>J.toWeb(B(n,{start:R,end:N}));if(!s||s[1]===""&&s[2]===""||r===0)return new Response(r===0?null:x(0,r-1),{status:200,headers:{...u,"content-length":String(r)}});let p,m;return s[1]===""?(p=Math.max(0,r-Number(s[2])),m=r-1):(p=Number(s[1]),m=s[2]===""?r-1:Math.min(Number(s[2]),r-1)),p>=r||p>m?new Response(null,{status:416,headers:{...u,"content-range":`bytes */${String(r)}`}}):new Response(x(p,m),{status:206,headers:{...u,"content-length":String(m-p+1),"content-range":`bytes ${String(p)}-${String(m)}/${String(r)}`}})}const U=/^[a-z][a-z0-9+.-]*:\/\/[a-z0-9.-]+(:\d{1,5})?$/u;export const PING_MS=3e4,ALLYHUB_FORWARDED="allyhub-forwarded";export function forwardedHost(n){const c=n[ALLYHUB_FORWARDED],g=(n.forwarded??(Array.isArray(c)?c[0]:c))?.split(",")[0]?.split(";").map(r=>r.trim().split("=")).find(([r])=>r?.toLowerCase()==="host")?.[1];if(g!==void 0)return g.replace(/^"(.*)"$/u,"$1");const u=n["x-forwarded-host"];return(Array.isArray(u)?u[0]:u)?.split(",")[0]?.trim()}export function frameSources(n){const c=["'self'","http://127.0.0.1:*","http://localhost:*"];if(n===void 0)return c;const a=new URL(n.replace("{port}","1")),g=new URL(n.replace("{port}","2"));if(a.port!==g.port)return[...c,`${a.protocol}//${a.hostname}:*`];const u=a.hostname.slice(a.hostname.indexOf(".")+1);return[...c,`${a.protocol}//*.${u}`]}export async function startDevServer(n){const c=C(n.root);if(n.embedder!==void 0&&!U.test(n.embedder))throw new Error(`Not an origin: ${n.embedder}`);if(n.publicOrigin!==void 0&&!U.test(n.publicOrigin.replace("{port}","1")))throw new Error(`Not an origin: ${n.publicOrigin}`);const a=n.token??E(18).toString("base64url"),u=`/s/${E(18).toString("base64url")}/`,r=await se.open({...n,root:c,...n.publicOrigin===void 0?{}:{reveal:!1}});let s=0;const x=()=>s===0?void 0:n.publicOrigin?.replace("{port}",String(s)),p=()=>{const e=x();return e===void 0?void 0:new URL(e).host},m=()=>{const e=p();return new Set([`127.0.0.1:${String(s)}`,`localhost:${String(s)}`,...e===void 0?[]:[e]])},R=e=>e===p()?x()??"":`http://${e}`,N=e=>R(e.req.header("host")??""),A=e=>{const t=p();t!==void 0&&forwardedHost(e.headers)===t&&(e.headers.host=t)},T=e=>e??`http://127.0.0.1:${String(s)}`;r.serving={file:(e,t)=>`${T(e)}${RAW_PATH}${t.split("/").map(encodeURIComponent).join("/")}?token=${encodeURIComponent(a)}`,tree:e=>`${T(e)}${u}`};const{routes:P}=r.live,S=new Y,I=async e=>{if(!n.ui)return e.text("allyhub dev serves its editors here.",200);const t=await M(G(n.ui,"index.html"),"utf8").catch(()=>{});if(t===void 0)return e.text("The page's files are missing: build them first (pnpm --filter @allyhub/editor-web build).",500);const l=E(16).toString("base64");return e.html(t.replace(/<script/gu,`<script nonce="${l}"`).replace("</head>",`<meta name="allyhub-token" content="${a}"></head>`),200,{"content-security-policy":["default-src 'self'",`script-src 'self' 'nonce-${l}'`,"style-src 'self' 'unsafe-inline'","img-src 'self' data: blob:","media-src 'self' blob:","font-src 'self' data:",`connect-src 'self' ws://${e.req.header("host")??""}`,`frame-src ${frameSources(n.publicOrigin).join(" ")}`,`frame-ancestors ${n.embedder??"'none'"}`].join("; "),"cache-control":"no-store"})};S.get("/",I),S.post(Z,async e=>{if(e.req.header("authorization")!==`Bearer ${a}`)return e.text("forbidden",403);const t=X.safeParse(await e.req.json().catch(()=>{}));return t.success?(r.presence.agent(t.data),e.body(null,204)):e.text(t.error.message,400)}),S.get(`${RAW_PATH}*`,async e=>{if(e.req.query("token")!==a)return e.text("forbidden",403);const t=decodeURIComponent(e.req.path.slice(RAW_PATH.length));if(oe(t)!==void 0)return e.text("forbidden",403);const l=F(c,t);return l?y(l,e.req.header("range"),{"x-content-type-options":"nosniff","content-security-policy":"sandbox; default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'"}):e.text("forbidden",403)}),S.get(`${u}*`,async e=>{let t;try{t=decodeURIComponent(e.req.path.slice(u.length))}catch{return e.notFound()}const l=e.req.header("range"),b=N(e),f=t.slice(0,t.indexOf("/")+1),d=t.slice(f.length);switch(f){case O.runtime:{const o=ne(d);if(!o)return e.notFound();const i=Object.values(ee).includes(t);return y(o,void 0,{...h,...i?{"content-security-policy":te(`${b}${u}`,[b,...n.embedder?[n.embedder]:[]],P.loads())}:{}})}case O.build:{const o=ce(d);if(o===void 0){const i=F(r.live.pieceDir,d);return i?y(i,void 0,h):e.notFound()}try{return e.json(await r.live.source(o),200,{...h,"cache-control":"no-store"})}catch(i){return e.json({error:{message:i instanceof Error?i.message:String(i)}},404,h)}}case O.media:{const i=Object.hasOwn(r.live.latest()?.media??{},d)||P.allowed(d)?F(c,d):void 0;return i?y(i,l,h):e.notFound()}case O.matte:{const o=ae(c,r.live.latest()?.media[d]);return o?y(o,l,{...h,"content-type":"video/mp4"}):e.notFound()}case O.stills:return ie.test(d)?y(V.of(c,"stills").path(d),void 0,{...h,"cache-control":"public, max-age=31536000, immutable"}):e.notFound();default:try{const o=await P.route(f);if(!o)return await e.notFound();const i=new WeakSet,w=await o.route.serve({path:d,query:new URL(e.req.url).searchParams,file:async(_,q,z)=>{const j=F(_,q);if(!j)return;const k=await y(j,l,{...h,...z});return i.add(k),k}},o.context);return w?(!i.has(w)&&!w.headers.has("access-control-allow-origin")&&w.headers.set("access-control-allow-origin","*"),w):await e.notFound()}catch(o){return e.text(o instanceof Error?o.message:String(o),500,{...h})}}}),S.get("/*",async e=>{if(!n.ui)return e.notFound();const t=F(C(n.ui),decodeURIComponent(e.req.path.slice(1)));return t?y(t,void 0,{"cache-control":"public, max-age=3600"}):e.notFound()});const v=new Q({noServer:!0,maxPayload:512*1024*1024});v.on("connection",(e,t)=>{const l=r.connect(o=>{e.readyState===e.OPEN&&e.send(JSON.stringify(o))},{origin:R(t.headers.host??"")});e.on("message",(o,i)=>{if(i||!Buffer.isBuffer(o))return;let w;try{w=JSON.parse(o.toString("utf8"))}catch{e.send(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Not JSON."}}));return}l.receive(w)});const b=n.pingMs??PING_MS;let f=!0;e.on("pong",()=>{f=!0});const d=b>0?setInterval(()=>{if(!f){e.terminate();return}f=!1,e.ping()},b):void 0;d?.unref(),e.on("close",()=>{clearInterval(d),l.close()})});const L=K(S.fetch),H=(e,t)=>{e.writeHead(403,{"content-type":"text/plain; charset=utf-8"}),e.end(t)},$=D((e,t)=>{if(A(e),!m().has(e.headers.host??"")){H(t,"forbidden host");return}L(e,t)});$.on("upgrade",(e,t,l)=>{const b=new URL(e.url??"/","http://x"),f=(o,i)=>{t.end(`HTTP/1.1 ${String(o)} ${i}\r
2
+ import{randomBytes as F}from"node:crypto";import{readFile as z}from"node:fs/promises";import{createServer as D}from"node:http";import{join as J,resolve as C}from"node:path";import{getRequestListener as M}from"@hono/node-server";import{Hono as W}from"hono";import{WebSocketServer as G}from"ws";import{KeyedStore as K}from"@allyhub/project";import{CollaboratorStateSchema as Y,PRESENCE_PATH as Q,SNAPSHOT_TREE as $,TREE_PAGES as V,stageCsp as X}from"@allyhub/protocol";import{runtimeFile as Z}from"@allyhub/stage-page";import{pathProblem as ee}from"./paths.js";import{fileResponse as g}from"./respond.js";import{ProjectServer as te}from"./project.js";import{STILL_NAME as ne,inside as x,matteFile as re,sourceName as oe}from"./tree.js";export const RPC_PATH="/rpc",RAW_PATH="/files/raw/";const p={"access-control-allow-origin":"*"},T=/^[a-z][a-z0-9+.-]*:\/\/[a-z0-9.-]+(:\d{1,5})?$/u;export const PING_MS=3e4,ALLYHUB_FORWARDED="allyhub-forwarded";export function forwardedHost(n){const d=n[ALLYHUB_FORWARDED],y=(n.forwarded??(Array.isArray(d)?d[0]:d))?.split(",")[0]?.split(";").map(i=>i.trim().split("=")).find(([i])=>i?.toLowerCase()==="host")?.[1];if(y!==void 0)return y.replace(/^"(.*)"$/u,"$1");const u=n["x-forwarded-host"];return(Array.isArray(u)?u[0]:u)?.split(",")[0]?.trim()}export function frameSources(n){const d=["'self'","http://127.0.0.1:*","http://localhost:*"];if(n===void 0)return d;const a=new URL(n.replace("{port}","1")),y=new URL(n.replace("{port}","2"));if(a.port!==y.port)return[...d,`${a.protocol}//${a.hostname}:*`];const u=a.hostname.slice(a.hostname.indexOf(".")+1);return[...d,`${a.protocol}//*.${u}`]}export async function startDevServer(n){const d=C(n.root);if(n.embedder!==void 0&&!T.test(n.embedder))throw new Error(`Not an origin: ${n.embedder}`);if(n.publicOrigin!==void 0&&!T.test(n.publicOrigin.replace("{port}","1")))throw new Error(`Not an origin: ${n.publicOrigin}`);const a=n.token??F(18).toString("base64url"),u=`/s/${F(18).toString("base64url")}/`,i=await te.open({...n,root:d,...n.publicOrigin===void 0?{}:{reveal:!1}});let f=0;const P=()=>f===0?void 0:n.publicOrigin?.replace("{port}",String(f)),v=()=>{const e=P();return e===void 0?void 0:new URL(e).host},E=()=>{const e=v();return new Set([`127.0.0.1:${String(f)}`,`localhost:${String(f)}`,...e===void 0?[]:[e]])},R=e=>e===v()?P()??"":`http://${e}`,U=e=>R(e.req.header("host")??""),N=e=>{const t=v();t!==void 0&&forwardedHost(e.headers)===t&&(e.headers.host=t)},A=e=>e??`http://127.0.0.1:${String(f)}`;i.serving={file:(e,t)=>`${A(e)}${RAW_PATH}${t.split("/").map(encodeURIComponent).join("/")}?token=${encodeURIComponent(a)}`,tree:e=>`${A(e)}${u}`};const{routes:O}=i.live,b=new W,I=async e=>{if(!n.ui)return e.text("allyhub dev serves its editors here.",200);const t=await z(J(n.ui,"index.html"),"utf8").catch(()=>{});if(t===void 0)return e.text("The page's files are missing: build them first (pnpm --filter @allyhub/editor-web build).",500);const c=F(16).toString("base64");return e.html(t.replace(/<script/gu,`<script nonce="${c}"`).replace("</head>",`<meta name="allyhub-token" content="${a}"></head>`),200,{"content-security-policy":["default-src 'self'",`script-src 'self' 'nonce-${c}'`,"style-src 'self' 'unsafe-inline'","img-src 'self' data: blob:","media-src 'self' blob:","font-src 'self' data:",`connect-src 'self' ws://${e.req.header("host")??""}`,`frame-src ${frameSources(n.publicOrigin).join(" ")}`,`frame-ancestors ${n.embedder??"'none'"}`].join("; "),"cache-control":"no-store"})};b.get("/",I),b.post(Q,async e=>{if(e.req.header("authorization")!==`Bearer ${a}`)return e.text("forbidden",403);const t=Y.safeParse(await e.req.json().catch(()=>{}));return t.success?(i.presence.agent(t.data),e.body(null,204)):e.text(t.error.message,400)}),b.get(`${RAW_PATH}*`,async e=>{if(e.req.query("token")!==a)return e.text("forbidden",403);const t=decodeURIComponent(e.req.path.slice(RAW_PATH.length));if(ee(t)!==void 0)return e.text("forbidden",403);const c=x(d,t);return c?g(c,e.req.header("range"),{"x-content-type-options":"nosniff","content-security-policy":"sandbox; default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'"}):e.text("forbidden",403)}),b.get(`${u}*`,async e=>{let t;try{t=decodeURIComponent(e.req.path.slice(u.length))}catch{return e.notFound()}const c=e.req.header("range"),m=U(e),l=t.slice(0,t.indexOf("/")+1),s=t.slice(l.length);switch(l){case $.runtime:{const r=Z(s);if(!r)return e.notFound();const o=Object.values(V).includes(t);return g(r,void 0,{...p,...o?{"content-security-policy":X(`${m}${u}`,[m,...n.embedder?[n.embedder]:[]],O.loads())}:{}})}case $.build:{const r=oe(s);if(r===void 0){const o=x(i.live.pieceDir,s);return o?g(o,void 0,p):e.notFound()}try{return e.json(await i.live.source(r),200,{...p,"cache-control":"no-store"})}catch(o){return e.json({error:{message:o instanceof Error?o.message:String(o)}},404,p)}}case $.media:{const o=Object.hasOwn(i.live.latest()?.media??{},s)||O.allowed(s)?x(d,s):void 0;return o?g(o,c,p):e.notFound()}case $.matte:{const r=re(d,i.live.latest()?.media[s]);return r?g(r,c,{...p,"content-type":"video/mp4"}):e.notFound()}case $.stills:return ne.test(s)?g(K.of(d,"stills").path(s),void 0,{...p,"cache-control":"public, max-age=31536000, immutable"}):e.notFound();default:try{const r=await O.route(l);if(!r)return await e.notFound();const o=new WeakSet,h=await r.route.serve({path:s,query:new URL(e.req.url).searchParams,file:async(_,q,B)=>{const j=x(_,q);if(!j)return;const k=await g(j,c,{...p,...B});return o.add(k),k}},r.context);return h?(!o.has(h)&&!h.headers.has("access-control-allow-origin")&&h.headers.set("access-control-allow-origin","*"),h):await e.notFound()}catch(r){return e.text(r instanceof Error?r.message:String(r),500,{...p})}}}),b.get("/*",async e=>{if(!n.ui)return e.notFound();const t=x(C(n.ui),decodeURIComponent(e.req.path.slice(1)));return t?g(t,void 0,{"cache-control":"public, max-age=3600"}):e.notFound()});const S=new G({noServer:!0,maxPayload:512*1024*1024});S.on("connection",(e,t)=>{const c=i.connect(r=>{e.readyState===e.OPEN&&e.send(JSON.stringify(r))},{origin:R(t.headers.host??"")});e.on("message",(r,o)=>{if(o||!Buffer.isBuffer(r))return;let h;try{h=JSON.parse(r.toString("utf8"))}catch{e.send(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Not JSON."}}));return}c.receive(h)});const m=n.pingMs??PING_MS;let l=!0;e.on("pong",()=>{l=!0});const s=m>0?setInterval(()=>{if(!l){e.terminate();return}l=!1,e.ping()},m):void 0;s?.unref(),e.on("close",()=>{clearInterval(s),c.close()})});const L=M(b.fetch),H=(e,t)=>{e.writeHead(403,{"content-type":"text/plain; charset=utf-8"}),e.end(t)},w=D((e,t)=>{if(N(e),!E().has(e.headers.host??"")){H(t,"forbidden host");return}L(e,t)});w.on("upgrade",(e,t,c)=>{const m=new URL(e.url??"/","http://x"),l=(r,o)=>{t.end(`HTTP/1.1 ${String(r)} ${o}\r
3
3
  connection: close\r
4
4
  content-length: 0\r
5
5
  \r
6
- `)};A(e);const d=e.headers.host??"";if(!m().has(d)){f(403,"Forbidden");return}if(b.pathname!==RPC_PATH){f(404,"Not Found");return}if(e.headers.origin!==R(d)){f(403,"Forbidden");return}if(b.searchParams.get("token")!==a){f(403,"Forbidden");return}v.handleUpgrade(e,t,l,o=>{v.emit("connection",o,e)})});try{await new Promise((e,t)=>{$.once("error",t),$.listen(n.port??0,"127.0.0.1",()=>{e()})})}catch(e){throw await r.close(),e}return s=$.address().port,{url:`http://127.0.0.1:${String(s)}/`,port:s,token:a,tree:`http://127.0.0.1:${String(s)}${u}`,ui:n.ui,project:r,async close(){for(const e of v.clients)e.terminate();v.close(),await new Promise(e=>{$.closeAllConnections(),$.close(()=>{e()})}),await r.close()}}}
6
+ `)};N(e);const s=e.headers.host??"";if(!E().has(s)){l(403,"Forbidden");return}if(m.pathname!==RPC_PATH){l(404,"Not Found");return}if(e.headers.origin!==R(s)){l(403,"Forbidden");return}if(m.searchParams.get("token")!==a){l(403,"Forbidden");return}S.handleUpgrade(e,t,c,r=>{S.emit("connection",r,e)})});try{await new Promise((e,t)=>{w.once("error",t),w.listen(n.port??0,"127.0.0.1",()=>{e()})})}catch(e){throw await i.close(),e}return f=w.address().port,{url:`http://127.0.0.1:${String(f)}/`,port:f,token:a,tree:`http://127.0.0.1:${String(f)}${u}`,ui:n.ui,project:i,async close(){for(const e of S.clients)e.terminate();S.close(),await new Promise(e=>{w.closeAllConnections(),w.close(()=>{e()})}),await i.close()}}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{createHash as R}from"node:crypto";import{access as y}from"node:fs/promises";import{basename as j,join as g,posix as P}from"node:path";import{pathToFileURL as C}from"node:url";import{inTime as x,listWork as O,projectItems as h,stageId as I}from"@allyhub/build";import{NEVER_CANCELLED as L}from"@allyhub/extension-api";import{OUT_DIR as M,isListedFile as _,WORK_FILE as D}from"@allyhub/formats";import{OpenedVersion as H,componentStills as N,itemDigests as U,keyedStills as W,parseCombo as A}from"@allyhub/project";import{runtimeFile as K,stageFiles as V}from"@allyhub/stage-page";import{RPC_ERROR as l,RpcError as c,SNAPSHOT_TREE as $,TREE_PAGES as E,listedFileEditor as q,listedKind as T,stillPath as G}from"@allyhub/protocol";import{comboKey as z,componentRefText as B}from"@allyhub/piece";import{providedPreview as J}from"./card.js";import{kindItem as Q}from"./kinds.js";import{rpcErrorOf as b}from"./live.js";const X=t=>R("sha256").update(t).digest("base64url").slice(0,16),f=(t,e)=>{const n=t.tree();if(n===void 0)throw new c(l.unavailable,"This server serves no pages: only allyhub dev's does.");return new URL(e,n).href},F=(t,e,n)=>({url:f(t,`${e}?${n.toString()}`),probe:f(t,E.probe)});async function Y(t,e,n){if(e.title!==void 0)return e.title;const o=await t.extensions?.kindProvider(e.kind);if(!o?.title)return(await n()).get(e.id);try{const r=await o.title(Q(e),t.kindContext,L);return typeof r=="string"?r:void 0}catch{return}}export function contributedTools(t){const e=new Map;for(const n of t)for(const o of n.projectTools??[])e.has(o.name)||e.set(o.name,o);return e}const v=new Map;export async function contributedTool(t){let e=v.get(t.module);e||(e=import(C(t.module).href).then(o=>{if(typeof o.default!="object"||o.default===null)throw new Error(`${t.extension}'s project tools (${t.module}) have no default export.`);return o.default}),v.set(t.module,e),e.catch(()=>{v.get(t.module)===e&&v.delete(t.module)}));const n=(await e)[t.name];if(!n)throw new Error(`${t.extension} contributes the project tool "${t.name}" but its module (${t.module}) has none of that name.`);return n}export function projectToolContext(t){const{live:e}=t,n=new Map;return{root:e.root,kinds:e.kinds,prepared:()=>e.prepared(),target:(o,r)=>e.target(o,r),itemCode:o=>e.itemCode(o),items:async()=>(await h(e.root,e.kinds)).items,async version(o,r,s,a){try{return await e.withSession(async d=>{const i=await H.open({root:e.root,item:o,...r===void 0?{}:{combos:[A(r)]},purpose:s,session:d});try{return await a(i)}finally{await i.close()}})}catch(d){throw b(d)}},async componentStills(o,r,s){try{const a=await e.prepared(),{gpu:d}=await e.browser();return await W(r,{prepared:a,item:o,combo:s,gpu:d,withSession:i=>e.withSession(i)})}catch(a){throw b(a)}},served:o=>f(t,o),page:(o,r)=>F(t,o,r),buildDir:e.pieceDir,stageStyles:()=>V().fontCss.flatMap(o=>{const r=K(o);return r===void 0?[]:[{file:r,url:f(t,`${$.runtime}${o}`)}]}),kept(o,r){return n.has(o)||n.set(o,r()),n.get(o)},held(o,r){return t.held.has(o)||t.held.set(o,r()),t.held.get(o)},jobs:t.services.jobs,cloud:t.services.cloud,env:t.services.env??process.env,forward:o=>Z(t.services.ports,o)}}function Z(t,e){const n=`http://127.0.0.1:${String(e)}/`;return t===void 0?{url:n,hosts:[],dispose:()=>{}}:(t.add(e),{url:t.public(n),hosts:t.hosts(e),dispose:()=>{t.remove(e)}})}export function toolHandlers(t){const{live:e}=t;return{"project/items":async()=>{const n=await h(e.root,e.kinds,void 0,t.extensions?.fileEditors()??[]);let o;const r=()=>o??=(async()=>{const i=await e.prepared().catch(()=>e.latest()),p=new Map;for(const u of i?.pieces??[]){const m=typeof u.title=="string"?u.title:void 0;m&&p.set(u.place,m)}return p})(),s=new Map((e.latest()?.items??[]).map(i=>[i.id,i.files])),a=t.extensions?.fileEditors()??[];return{items:await Promise.all(n.listed.map(async i=>{const p={id:i.id,dir:i.dir,entry:i.entry,...i.title===void 0?{}:{title:i.title},groups:i.groups};if(_(i)){const w=a.find(S=>S.id===i.editor);return{...p,...w?{kindInfo:q(w)}:{}}}const u=await Y(t,i,r),m=e.kinds.find(w=>w.id===i.kind),k=s.get(i.id);return{...p,kind:i.kind,...u?{title:u}:{},...k?{files:k}:{},...m?{kindInfo:T(m)}:{}}})),kinds:e.kinds.map(i=>({id:i.id,...T(i)})),name:j(e.root),scope:X(e.root),revision:e.revision}},"items/preview":async({item:n})=>{const o=n.replace(/^\.\//u,""),r=(await h(e.root,e.kinds)).items.find(a=>a.id===o||a.entry===o);if(!r)throw new c(l.notFound,`There is no item ${n} in the project's list.`);const s=await J(t.extensions,r,t.kindContext);return s===void 0?{}:{preview:s}},"work/add":async({kind:n,file:o,title:r})=>{if(!e.kinds.some(s=>s.id===n))throw new c(l.invalid,`No extension here contributes the kind ${n}.`);return await y(g(e.root,o)).catch(()=>{throw new c(l.notFound,`There is no file ${o} to list in ${D}.`)}),await O(e.root,{kind:n,file:o,...r===void 0?{}:{title:r}}),{}},"components/list":async({item:n})=>{const o=await e.prepared(),r=o.items.find(s=>s.id===n||s.entry===n)?.dir??n;return{components:o.components.map(s=>{const a=P.relative(r,s.file);return{of:B({path:a.startsWith(".")?a:`./${a}`,name:s.export}),name:s.name,...s.label===void 0?{}:{label:s.label}}})}},"components/stage":async({item:n,version:o})=>{const{prepared:r,host:s,combo:a}=await e.componentHost(n,o);if(!("components"in s)&&x(s,r.kinds))throw new c(l.notFound,`${n} has no components to draw alone: a deck's or a doc's are.`);const{code:d}=await U(r,s),i=new URLSearchParams({piece:I(s),combo:z(a),mode:"component",code:d.slice(0,16)});return F(t,E.stage,i)},"components/stills":async({item:n,version:o,components:r})=>{f(t,$.stills);try{const{prepared:s,host:a,combo:d}=await e.componentHost(n,o);if(!("components"in a)&&x(a,s.kinds))throw new c(l.notFound,`${n} has no components to draw alone: a deck's or a doc's are.`);const{gpu:i}=await e.browser();return{stills:(await N(r,{prepared:s,item:a,combo:d,gpu:i,withSession:u=>e.withSession(u)})).map(({key:u})=>({key:u,url:f(t,G(u))}))}}catch(s){throw b(s)}},"check/results":()=>Promise.resolve(t.checker?.state??{status:"off",revision:e.revision,problems:[],facts:[]}),"check/run":()=>{if(!t.checker)throw new c(l.unavailable,"This server runs no check.");return t.checker.schedule(!0),Promise.resolve({})},"export/start":async({item:n,versions:o,types:r,options:s})=>{const{items:a}=await h(e.root,e.kinds);if(!a.some(d=>d.id===n))throw new c(l.notFound,`There is no item ${n}.`);return{job:t.exports.start(n,o??[],r??[],s)}},"export/cancel":({job:n})=>{if(!t.exports.cancel(n))throw new c(l.notFound,`No export ${n} is under way.`);return Promise.resolve({})},"export/list":()=>Promise.resolve({jobs:t.exports.list(),reveal:t.reveal!==void 0}),"export/reveal":async({path:n})=>{if(!t.reveal)throw new c(l.unavailable,"This server is not on the person's computer: download the file.");if(!n.startsWith(`${M}/`))throw new c(l.notFound,`${n} is no exported file.`);const o=g(e.root,n);return await y(o).catch(()=>{throw new c(l.notFound,`There is no file ${n}.`)}),await t.reveal(o),{}}}}
2
+ import{createHash as j}from"node:crypto";import{access as y}from"node:fs/promises";import{basename as P,join as g,posix as O}from"node:path";import{pathToFileURL as C}from"node:url";import{inTime as $,listWork as I,projectItems as w,stageId as L}from"@allyhub/build";import{NEVER_CANCELLED as M}from"@allyhub/extension-api";import{OUT_DIR as _,isListedFile as D,WORK_FILE as H}from"@allyhub/formats";import{OpenedVersion as N,componentStills as W,itemDigests as U,keyedStills as A,parseCombo as K}from"@allyhub/project";import{runtimeFile as V,stageFiles as q}from"@allyhub/stage-page";import{RPC_ERROR as l,RpcError as c,SNAPSHOT_TREE as x,TREE_PAGES as T,listedFileEditor as G,listedKind as E,stillPath as z}from"@allyhub/protocol";import{comboKey as B,componentRefText as J}from"@allyhub/piece";import{providedPreview as Q}from"./card.js";import{kindItem as X}from"./kinds.js";import{rpcErrorOf as b}from"./live.js";import{forwarded as Y}from"./ports.js";const Z=t=>j("sha256").update(t).digest("base64url").slice(0,16);async function F(t,o,n){const e=o.replace(/^\.\//u,""),r=(await w(t.live.root,t.live.kinds)).items.find(d=>d.id===e||d.entry===e);if(!r)throw new c(l.notFound,`There is no item ${o} in the project's list.`);const s=(n.folder??"").replace(/\/+$/u,""),a=n.file??r.entry;if(s!==""&&!a.startsWith(`${s}/`))throw new c(l.invalid,`${a} is not in the folder ${s} the page is served from.`);return t.pages.url(r.id,s,a)}const u=(t,o)=>{const n=t.tree();if(n===void 0)throw new c(l.unavailable,"This server serves no pages: only allyhub dev's does.");return new URL(o,n).href},R=(t,o,n)=>({url:u(t,`${o}?${n.toString()}`),probe:u(t,T.probe)});async function ee(t,o,n){if(o.title!==void 0)return o.title;const e=await t.extensions?.kindProvider(o.kind);if(!e?.title)return(await n()).get(o.id);try{const r=await e.title(X(o),t.kindContext,M);return typeof r=="string"?r:void 0}catch{return}}export function contributedTools(t){const o=new Map;for(const n of t)for(const e of n.projectTools??[])o.has(e.name)||o.set(e.name,e);return o}const v=new Map;export async function contributedTool(t){let o=v.get(t.module);o||(o=import(C(t.module).href).then(e=>{if(typeof e.default!="object"||e.default===null)throw new Error(`${t.extension}'s project tools (${t.module}) have no default export.`);return e.default}),v.set(t.module,o),o.catch(()=>{v.get(t.module)===o&&v.delete(t.module)}));const n=(await o)[t.name];if(!n)throw new Error(`${t.extension} contributes the project tool "${t.name}" but its module (${t.module}) has none of that name.`);return n}export function projectToolContext(t){const{live:o}=t,n=new Map;return{root:o.root,kinds:o.kinds,prepared:()=>o.prepared(),target:(e,r)=>o.target(e,r),itemCode:e=>o.itemCode(e),items:async()=>(await w(o.root,o.kinds)).items,async version(e,r,s,a){try{return await o.withSession(async d=>{const i=await N.open({root:o.root,item:e,...r===void 0?{}:{combos:[K(r)]},purpose:s,session:d});try{return await a(i)}finally{await i.close()}})}catch(d){throw b(d)}},async componentStills(e,r,s){try{const a=await o.prepared(),{gpu:d}=await o.browser();return await A(r,{prepared:a,item:e,combo:s,gpu:d,withSession:i=>o.withSession(i)})}catch(a){throw b(a)}},served:e=>u(t,e),page:(e,r)=>R(t,e,r),buildDir:o.pieceDir,stageStyles:()=>q().fontCss.flatMap(e=>{const r=V(e);return r===void 0?[]:[{file:r,url:u(t,`${x.runtime}${e}`)}]}),kept(e,r){return n.has(e)||n.set(e,r()),n.get(e)},held(e,r){return t.held.has(e)||t.held.set(e,r()),t.held.get(e)},jobs:t.services.jobs,cloud:t.services.cloud,env:t.services.env??process.env,forward:e=>Y(t.services.ports,e),pageOf:(e,r={})=>F(t,e,r),recordInputs:(e,r,s)=>{t.inputs.set(e,r,s)}}}export function toolHandlers(t){const{live:o}=t;return{"project/items":async()=>{const n=await w(o.root,o.kinds,void 0,t.extensions?.fileEditors()??[]);let e;const r=()=>e??=(async()=>{const i=await o.prepared().catch(()=>o.latest()),f=new Map;for(const p of i?.pieces??[]){const m=typeof p.title=="string"?p.title:void 0;m&&f.set(p.place,m)}return f})(),s=new Map((o.latest()?.items??[]).map(i=>[i.id,i.files])),a=t.extensions?.fileEditors()??[];return{items:await Promise.all(n.listed.map(async i=>{const f={id:i.id,dir:i.dir,entry:i.entry,...i.title===void 0?{}:{title:i.title},groups:i.groups};if(D(i)){const h=a.find(S=>S.id===i.editor);return{...f,...h?{kindInfo:G(h)}:{}}}const p=await ee(t,i,r),m=o.kinds.find(h=>h.id===i.kind),k=s.get(i.id);return{...f,kind:i.kind,...p?{title:p}:{},...k?{files:k}:{},...m?{kindInfo:E(m)}:{}}})),kinds:o.kinds.map(i=>({id:i.id,...E(i)})),name:P(o.root),scope:Z(o.root),revision:o.revision}},"items/preview":async({item:n})=>{const e=n.replace(/^\.\//u,""),r=(await w(o.root,o.kinds)).items.find(a=>a.id===e||a.entry===e);if(!r)throw new c(l.notFound,`There is no item ${n} in the project's list.`);const s=await Q(t.extensions,r,t.kindContext);return s===void 0?{}:{preview:s}},"items/page":async({item:n,folder:e,file:r})=>({url:await F(t,n,{folder:e,file:r})}),"work/add":async({kind:n,file:e,title:r})=>{if(!o.kinds.some(s=>s.id===n))throw new c(l.invalid,`No extension here contributes the kind ${n}.`);return await y(g(o.root,e)).catch(()=>{throw new c(l.notFound,`There is no file ${e} to list in ${H}.`)}),await I(o.root,{kind:n,file:e,...r===void 0?{}:{title:r}}),{}},"components/list":async({item:n})=>{const e=await o.prepared(),r=e.items.find(s=>s.id===n||s.entry===n)?.dir??n;return{components:e.components.map(s=>{const a=O.relative(r,s.file);return{of:J({path:a.startsWith(".")?a:`./${a}`,name:s.export}),name:s.name,...s.label===void 0?{}:{label:s.label}}})}},"components/stage":async({item:n,version:e})=>{const{prepared:r,host:s,combo:a}=await o.componentHost(n,e);if(!("components"in s)&&$(s,r.kinds))throw new c(l.notFound,`${n} has no components to draw alone: a deck's or a doc's are.`);const{code:d}=await U(r,s),i=new URLSearchParams({piece:L(s),combo:B(a),mode:"component",code:d.slice(0,16)});return R(t,T.stage,i)},"components/stills":async({item:n,version:e,components:r})=>{u(t,x.stills);try{const{prepared:s,host:a,combo:d}=await o.componentHost(n,e);if(!("components"in a)&&$(a,s.kinds))throw new c(l.notFound,`${n} has no components to draw alone: a deck's or a doc's are.`);const{gpu:i}=await o.browser();return{stills:(await W(r,{prepared:s,item:a,combo:d,gpu:i,withSession:p=>o.withSession(p)})).map(({key:p})=>({key:p,url:u(t,z(p))}))}}catch(s){throw b(s)}},"check/results":()=>Promise.resolve(t.checker?.state??{status:"off",revision:o.revision,problems:[],facts:[]}),"check/run":()=>{if(!t.checker)throw new c(l.unavailable,"This server runs no check.");return t.checker.schedule(!0),Promise.resolve({})},"export/start":async({item:n,versions:e,types:r,options:s})=>{const{items:a}=await w(o.root,o.kinds);if(!a.some(d=>d.id===n))throw new c(l.notFound,`There is no item ${n}.`);return{job:t.exports.start(n,e??[],r??[],s)}},"export/cancel":({job:n})=>{if(!t.exports.cancel(n))throw new c(l.notFound,`No export ${n} is under way.`);return Promise.resolve({})},"export/list":()=>Promise.resolve({jobs:t.exports.list(),reveal:t.reveal!==void 0}),"export/reveal":async({path:n})=>{if(!t.reveal)throw new c(l.unavailable,"This server is not on the person's computer: download the file.");if(!n.startsWith(`${_}/`))throw new c(l.notFound,`${n} is no exported file.`);const e=t.exports.savedOf(n),r=e!==void 0&&await y(e).then(()=>!0,()=>!1)?e:g(o.root,n);return await y(r).catch(()=>{throw new c(l.notFound,`There is no file ${n}.`)}),await t.reveal(r),{}}}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{watch as y}from"node:fs";import{readdir as T,stat as d}from"node:fs/promises";import{join as a,posix as l}from"node:path";import{LOCAL_DIR as w,within as u}from"@allyhub/formats";import{current as m,pathProblem as k}from"./paths.js";const p=40,v=2e3,O=c=>/^(.+)\.\d+$/u.exec(c)?.[1],b=["node_modules",".git"],g=c=>c===w||c.startsWith(`${w}/`)||c.split("/").some(t=>b.includes(t));export class Watcher{revision=0;root;tell;moved;outside;watches=new Map;known=new Map;written=new Map;saved=new Map;fs;pending=new Set;timer;next=1;running=Promise.resolve();constructor(t,s,e=()=>{},i={}){this.root=t,this.tell=s,this.moved=e,this.outside=i}start(){this.fs=y(this.root,{recursive:!0},(t,s)=>{if(s===null)return;const e=s.split("\\").join("/");this.pending.add(e),clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush()},p)}),this.fs.on("error",()=>{})}async watch(t,s){const e=`w${String(this.next++)}`;this.watches.set(e,{client:t,paths:[...s]});for(const i of s)await this.hash(i,!0);return e}unwatch(t){this.watches.delete(t)}forget(t){for(const[s,e]of this.watches)e.client===t&&this.watches.delete(s)}wrote(t,s){const e=Date.now();for(const[i,r]of this.saved)e-r>v&&this.saved.delete(i);for(const i of t)this.known.set(i.path,i.version),this.written.set(i.path,i.version),this.saved.set(i.path,e);this.fanOut(t,s),this.bump()}async settled(){await new Promise(t=>setTimeout(t,p*2)),await this.running}close(){clearTimeout(this.timer),this.fs?.close(),this.watches.clear()}bump(){this.revision++,this.moved(this.revision)}covered(t){for(const s of this.watches.values())if(s.paths.some(e=>u(t,e)||u(e,t)))return!0;return!1}flush(){const t=[...this.pending];this.pending=new Set,this.running=this.running.then(async()=>{const s=t.filter(n=>!g(n)),e=[];for(const n of s){if(!this.written.has(n)){await this.temporary(n)||e.push(n);continue}((await m(a(this.root,n)))?.version??null)!==this.written.get(n)&&e.push(n),this.written.delete(n)}e.length>0&&this.bump();const i=this.outside.by,r=[];for(const n of s)if(this.covered(n))for(const o of await this.hash(n,!1))r.push(i===void 0?o:{...o,by:i});r.length>0&&this.fanOut(r,void 0),e.length>0&&this.outside.moved?.(e)})}async temporary(t){const s=O(t);if(s===void 0)return!1;const e=this.saved.get(s);return e===void 0||Date.now()-e>v?!1:await d(a(this.root,t)).catch(()=>{})===void 0}async hash(t,s){const e=[],i=async o=>{const h=(await m(a(this.root,o)))?.version??null,f=this.known.get(o);f===h&&this.known.has(o)||(this.known.set(o,h),!s&&!(f===void 0&&h===null)&&e.push({path:o,version:h}))},r=await d(a(this.root,t)).catch(()=>{}),n=new Set;if(r?.isDirectory()){const o=await T(a(this.root,t),{recursive:!0,withFileTypes:!0}).catch(()=>[]);for(const h of o){if(!h.isFile())continue;const f=l.join(t,l.relative(a(this.root,t).split("\\").join("/"),a(h.parentPath,h.name).split("\\").join("/")));k(f)===void 0&&!g(f)&&n.add(f)}}else n.add(t);for(const o of this.known.keys())u(o,t)&&n.add(o);for(const o of n)await i(o);return e}fanOut(t,s){for(const[e,i]of this.watches){if(i.client===s)continue;const r=t.filter(n=>i.paths.some(o=>u(n.path,o)));r.length>0&&this.tell(e,r)}}}
2
+ import{watch as y}from"node:fs";import{readdir as T,stat as d}from"node:fs/promises";import{join as a,posix as l}from"node:path";import{LOCAL_DIR as w,within as u}from"@allyhub/formats";import{current as m,pathProblem as k}from"./paths.js";const p=40,v=2e3,O=c=>/^(.+)\.\d+$/u.exec(c)?.[1],b=["node_modules",".git"],g=c=>c===w||c.startsWith(`${w}/`)||c.split("/").some(t=>b.includes(t));export class Watcher{revision=0;root;tell;moved;outside;watches=new Map;known=new Map;written=new Map;saved=new Map;fs;pending=new Set;timer;next=1;running=Promise.resolve();constructor(t,s,e=()=>{},i={}){this.root=t,this.tell=s,this.moved=e,this.outside=i}start(){this.fs=y(this.root,{recursive:!0},(t,s)=>{if(s===null)return;const e=s.split("\\").join("/");this.pending.add(e),clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush()},p)}),this.fs.on("error",()=>{})}async watch(t,s){const e=`w${String(this.next++)}`;this.watches.set(e,{client:t,paths:[...s]});for(const i of s)await this.hash(i,!0);return e}unwatch(t){this.watches.delete(t)}forget(t){for(const[s,e]of this.watches)e.client===t&&this.watches.delete(s)}wrote(t,s){const e=Date.now();for(const[i,r]of this.saved)e-r>v&&this.saved.delete(i);for(const i of t)this.known.set(i.path,i.version),this.written.set(i.path,i.version),this.saved.set(i.path,e);this.fanOut(t,s),this.bump(t.map(i=>i.path))}async settled(){await new Promise(t=>setTimeout(t,p*2)),await this.running}close(){clearTimeout(this.timer),this.fs?.close(),this.watches.clear()}bump(t){this.revision++,this.moved(this.revision,t)}covered(t){for(const s of this.watches.values())if(s.paths.some(e=>u(t,e)||u(e,t)))return!0;return!1}flush(){const t=[...this.pending];this.pending=new Set,this.running=this.running.then(async()=>{const s=t.filter(n=>!g(n)),e=[];for(const n of s){if(!this.written.has(n)){await this.temporary(n)||e.push(n);continue}((await m(a(this.root,n)))?.version??null)!==this.written.get(n)&&e.push(n),this.written.delete(n)}e.length>0&&this.bump(e);const i=this.outside.by,r=[];for(const n of s)if(this.covered(n))for(const o of await this.hash(n,!1))r.push(i===void 0?o:{...o,by:i});r.length>0&&this.fanOut(r,void 0),e.length>0&&this.outside.moved?.(e)})}async temporary(t){const s=O(t);if(s===void 0)return!1;const e=this.saved.get(s);return e===void 0||Date.now()-e>v?!1:await d(a(this.root,t)).catch(()=>{})===void 0}async hash(t,s){const e=[],i=async o=>{const h=(await m(a(this.root,o)))?.version??null,f=this.known.get(o);f===h&&this.known.has(o)||(this.known.set(o,h),!s&&!(f===void 0&&h===null)&&e.push({path:o,version:h}))},r=await d(a(this.root,t)).catch(()=>{}),n=new Set;if(r?.isDirectory()){const o=await T(a(this.root,t),{recursive:!0,withFileTypes:!0}).catch(()=>[]);for(const h of o){if(!h.isFile())continue;const f=l.join(t,l.relative(a(this.root,t).split("\\").join("/"),a(h.parentPath,h.name).split("\\").join("/")));k(f)===void 0&&!g(f)&&n.add(f)}}else n.add(t);for(const o of this.known.keys())u(o,t)&&n.add(o);for(const o of n)await i(o);return e}fanOut(t,s){for(const[e,i]of this.watches){if(i.client===s)continue;const r=t.filter(n=>i.paths.some(o=>u(n.path,o)));r.length>0&&this.tell(e,r)}}}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/dev-server",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -26,6 +26,13 @@ export interface Problem {
26
26
  selector?: string;
27
27
  bbox?: Box;
28
28
  };
29
+ /**
30
+ * A fact of the page that drew it (its browser), not of the piece: where
31
+ * that page renders (frames, check, an export) it is the export's; where
32
+ * it is an editor's preview, the export is not affected, so it is not a
33
+ * problem of the version (allykit#502).
34
+ */
35
+ ofPage?: true;
29
36
  }
30
37
  /** A code no rule this process knows has: a mistake in the code that reports it, or in its extension's manifest. */
31
38
  export declare class UnknownRuleError extends Error {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/diagnostics",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{everyBlock as c}from"./model.js";import{effectiveLook as f}from"./page.js";export function captionWords(t){return t?{figure:"图",table:"表"}:{figure:"Figure",table:"Table"}}export function contentsTitle(t,e){return t.title??(e?"目录":"Contents")}export function captionOf(t){switch(t.type){case"image":case"component":case"table":return t.caption;case"chart":return t.title;default:return}}export function blockId(t){return t.type==="image"||t.type==="component"||t.type==="table"||t.type==="chart"?t.id:void 0}export function writtenInChinese(t){let e=0,n=0;for(const i of c(t))if("content"in i)for(const r of i.content)e+=(r.text.match(/[㐀-鿿぀-ヿ]/gu)??[]).length,n+=(r.text.match(/[A-Za-z]+/gu)??[]).length;return e>n}export function captionNumbers(t,e={}){const n=new Map;if(f(e).captions!=="numbered")return n;const i=captionWords(writtenInChinese(t)),r={figure:0,table:0};for(const u of c(t)){if(captionOf(u)===void 0)continue;const o=u.type==="table"?"table":"figure";r[o]+=1,n.set(u,{kind:o,n:r[o],label:`${i[o]} ${String(r[o])}`})}return n}export function numberedCaption(t,e){return e===void 0?t:/^[图表]/u.test(e.label)?`${e.label} ${t}`:`${e.label}. ${t}`}
2
+ import{everyBlock as c}from"./model.js";import{effectiveLook as a}from"./page.js";export function captionWords(t){return t?{figure:"图",table:"表"}:{figure:"Figure",table:"Table"}}export function contentsTitle(t,e){return t.title??(e?"目录":"Contents")}export function captionOf(t){switch(t.type){case"image":case"component":case"table":return t.caption;case"chart":return t.title;default:return}}export function blockId(t){return t.type==="image"||t.type==="component"||t.type==="table"||t.type==="chart"?t.id:void 0}export function writtenInChinese(t){let e=0,n=0;for(const i of c(t))if("content"in i)for(const r of i.content)e+=(r.text.match(/[㐀-鿿぀-ヿ]/gu)??[]).length,n+=(r.text.match(/[A-Za-z]+/gu)??[]).length;return e>n}export function captionNumbers(t,e={}){const n=new Map;if(a(e).captions==="plain")return n;const i=captionWords(writtenInChinese(t)),r={figure:0,table:0};for(const u of c(t)){if(captionOf(u)===void 0)continue;const o=u.type==="table"?"table":"figure";r[o]+=1,n.set(u,{kind:o,n:r[o],label:`${i[o]} ${String(r[o])}`})}return n}export function numberedCaption(t,e){return e===void 0?t:/^[图表]/u.test(e.label)?`${e.label} ${t}`:`${e.label}. ${t}`}export const withoutTitle=t=>{const e={...t};return delete e.title,e};
@@ -1,5 +1,5 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{chartBook as qe,embeddedChartXml as Ye}from"@allyhub/chart";import{chartFrame as Ve,chartWords as Ze,docChart as Qe}from"./chart.js";import{BACKGROUNDS as Le,TEXT_COLORS as Te,hex as te}from"./color.js";import{columnWidths as Je}from"./columns.js";import{COMPONENT_WIDTH as et,componentName as tt}from"./component.js";import{blockId as Oe,captionNumbers as nt,contentsTitle as it,numberedCaption as ve,writtenInChinese as rt}from"./captions.js";import{sourceList as ot,withSources as st}from"./cite.js";import{HEADING_RULE_SPACE as at,cardKept as dt,columnsKept as ct,docParts as lt,headingAnchors as ht,pageAccent as ut,trendSvg as pt}from"./html.js";import{effectiveLook as Pe,LIST_STEP as ft,lineHeightPt as gt,resolvePage as mt,sizePt as _e}from"./page.js";import{splitTitle as wt}from"./title.js";import{markdownOf as yt}from"./markdown.js";import{columnShares as At,numberColumns as Tt}from"./table.js";import{DRAWN_CODE as Me}from"./math.js";import{PAPER as ie,TONE_COLORS as $e,tagColors as Et}from"./paper.js";import{COVER_ASPECT as Rt,everyBlock as Ee,noteNumbers as St,statTone as zt}from"./model.js";const Re=15,bt=1440/25.4,K=n=>Math.round(n*bt),Fe="ListParagraph",He="bullets",Ct=1.8,fe=ft*20,Xe={sans:{latin:"Calibri"},serif:{latin:"Cambria"},mono:{latin:"Courier New"},times:{latin:"Times New Roman"},song:{latin:"Times New Roman",eastAsia:"宋体"},hei:{latin:"Arial",eastAsia:"黑体"},fangsong:{latin:"Times New Roman",eastAsia:"仿宋"},kai:{latin:"Times New Roman",eastAsia:"楷体"},xiaobiaosong:{latin:"Times New Roman",eastAsia:"方正小标宋简体"}},Ne="Courier New",k=n=>n.slice(1).toUpperCase(),de=k(ie.ink),ce=k(ie.lead),Lt=Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=","base64"),ge=k(ie.rule),De=k(ie.ruleStrong),xe=k(ie.ruleMid),Se=k(ie.stone),re=k(ie.leadSoft),Ue="ALLYHUB-CHART-";function Mt(n){return/[\u3040-\u30ff]/u.test(n)?"Yu Gothic":/[\uac00-\ud7af]/u.test(n)?"Malgun Gothic":"Microsoft YaHei"}const Nt=/^(https?:|mailto:)/i,ze=n=>({indent:0,level:0,room:n,frame:et}),Ge=n=>({...n,indent:n.indent+fe,level:Math.min(n.level+1,8)}),Dt=400,xt=n=>n.type==="bullet"||n.type==="numbered"||n.type==="check";function It(n,p,w){const c=w/Re,S=Math.floor(Math.min(p??n.width,c));return{width:S,height:Math.round(S*n.height/n.width)}}const Be="TOCHeading";function Ot(n,p,w,c,S,r){const{AlignmentType:f,BorderStyle:m,ExternalHyperlink:N,ImageRun:a,Paragraph:o,ShadingType:W,Table:P,TableCell:_,TableLayoutType:H,TableRow:X,TextRun:C,WidthType:z}=n,D=e=>{const t=e.filter(i=>!(i instanceof n.TableOfContents));return t.at(-1)instanceof o?t:[...t,le(0)]},L={ascii:Ne,hAnsi:Ne,cs:Ne,eastAsia:w},U=new Set([1]);let q=0;const Y=[],G=e=>({type:W.CLEAR,color:"auto",fill:e}),oe=(e,t,i=4)=>({style:e,color:t,size:i,space:4}),l=r.page.spacing,y=e=>Math.round(e*20),le=e=>new o({spacing:{before:0,after:y(e),line:14,lineRule:n.LineRuleType.EXACT}}),V=()=>l.after>0?[le(l.after)]:[],se=e=>e==="center"?f.CENTER:e==="right"?f.RIGHT:e==="justify"?f.JUSTIFIED:void 0,B=(e,t,i,u={})=>{if(t.tag!==void 0){const s=Et(t.tag),A={...u,color:k(s.fg),size:Math.round((i.size??r.page.size*2)*.85),shading:G(k(s.bg)),...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{}};return[new C({...A,text:` ${e.replace(/\n/gu," ")} `})]}const g=te(t.color,Te)??i.color,h=te(t.background,Le),d={...u,...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{},...t.underline?{underline:{}}:{},...t.strike?{strike:!0}:{},...g===void 0?{}:{color:g},...i.size===void 0?{}:{size:i.size},...t.code?{font:L,shading:G(h??Se)}:h===void 0?{}:{shading:G(h)}};return e.split(`
3
- `).map((s,A)=>new C({...d,text:s,...A>0?{break:1}:{}}))},$=(e,t={})=>e.flatMap(i=>i.note!==void 0?S.has(i.note.toLowerCase())?[new n.FootnoteReferenceRun(S.get(i.note.toLowerCase())??1)]:[]:i.text===""&&i.href?.startsWith("#")===!0?Ce(i.href.slice(1),i.styles,t):i.href!==void 0&&Nt.test(i.href)?[new N({link:i.href,children:B(i.text,i.styles,t,{style:"Hyperlink"})})]:B(i.text,i.styles,t)),Ce=(e,t,i)=>{const u=decodeURIComponent(e),g=r.refs.get(u)??"",h=r.bookmarks.get(u);return g===""?[]:h===void 0?B(g,t,i):[new n.InternalHyperlink({anchor:h,children:B(g,t,i,{style:"Hyperlink"})})]},he=(e,t)=>{const i=e===void 0?void 0:r.bookmarks.get(e);return i===void 0?t:[new n.Bookmark({id:i,children:t})]},T=e=>{const t=se(e?.align),i=te(e?.background,Le);return{...t===void 0?{}:{alignment:t},...i===void 0?{}:{shading:G(i)}}},R=e=>e.indent===0?{}:{indent:{left:e.indent}},O=e=>{const t={style:m.SINGLE,color:e,size:4};return{top:t,bottom:t,left:t,right:t}},me=(e,t)=>{const i=te(e.look?.background,Le)??Se,u=te(e.look?.color,Te),g=t.room-t.indent,h=y(r.page.size*Ct)+y(l.box.side),d=g-h,s=(A,b)=>({top:y(l.box.top),bottom:y(Math.max(l.box.top-l.after,0)),left:A,right:b,marginUnitType:z.DXA});return new P({layout:H.FIXED,width:{size:g,type:z.DXA},columnWidths:[h,d],...t.indent===0?{}:{indent:{size:t.indent,type:z.DXA}},rows:[new X({cantSplit:!0,children:[new _({width:{size:h,type:z.DXA},shading:G(i),borders:O(i),margins:s(y(l.box.side),0),children:[new o({children:[new C({text:e.icon??"💡"})]})]}),new _({width:{size:d,type:z.DXA},shading:G(i),borders:O(i),margins:s(0,y(l.box.side)),children:[new o({children:$(e.content,{color:u})}),...D(Q(e.children??[],ze(d-y(l.box.side))))]})]})]})},we=(e,t)=>{const i=t.room-t.indent,u=y(l.card.side),g=[...e.title===void 0?[]:[new o({spacing:{after:e.subtitle===void 0?y(l.after):0},children:$([{text:e.title,styles:{bold:!0}}])})],...e.subtitle===void 0?[]:[new o({spacing:{after:y(l.after)},children:[new C({text:e.subtitle,color:ce,size:l.small*2})]})]];return new P({layout:H.FIXED,width:{size:i,type:z.DXA},columnWidths:[i],...t.indent===0?{}:{indent:{size:t.indent,type:z.DXA}},rows:[new X({cantSplit:dt(e,r.page),children:[new _({width:{size:i,type:z.DXA},borders:O(ge),margins:{top:y(l.card.top),bottom:y(Math.max(l.card.top-l.after,0)),left:u,right:u,marginUnitType:z.DXA},children:D([...g,...Q(e.children??[],ze(i-2*u))])})]})]})},ye=(e,t)=>{const i=t.room-t.indent,u=y(l.gap),g=e.stats.length,h=Math.floor((i-u*(g-1))/g),d=e.stats.flatMap((M,F)=>F===0?[h]:[u,h]),s={style:m.NONE,size:0,color:"auto"},A={top:s,bottom:s,left:s,right:s},b=y(l.card.side),E=l.small*2,v=e.stats.flatMap((M,F)=>{const J=zt(M),ae=[...M.delta===void 0?[]:[new C({text:M.delta,color:k($e[J]),size:E})],...M.note===void 0?[]:[new C({text:`${M.delta===void 0?"":" "}${M.note}`,color:ce,size:E})]],x=h-2*b,I=M.trend===void 0?[]:[new o({spacing:{before:60,after:0,line:240},children:[new a({type:"svg",data:Buffer.from(pt(M.trend,$e[J]).replace("<svg ",`<svg xmlns="http://www.w3.org/2000/svg" width="${String(Math.round(x/15))}" height="24" `)),fallback:{type:"png",data:Lt},transformation:{width:Math.round(x/15),height:24}})]})],pe=new _({width:{size:h,type:z.DXA},borders:O(ge),margins:{top:y(l.card.top),bottom:y(l.card.top),left:b,right:b,marginUnitType:z.DXA},children:[new o({spacing:{after:0},children:[new C({text:M.label,color:ce,size:E})]}),new o({spacing:{after:0,line:240,lineRule:n.LineRuleType.AUTO},children:$([{text:M.value,styles:{bold:!0}}],{size:l.figure*2})}),...ae.length===0?[]:[new o({spacing:{after:0},children:ae})],...I]}),ee=new _({width:{size:u,type:z.DXA},borders:A,children:[new o({children:[]})]});return F===0?[pe]:[ee,pe]});return new P({layout:H.FIXED,width:{size:i,type:z.DXA},columnWidths:d,...t.indent===0?{}:{indent:{size:t.indent,type:z.DXA}},rows:[new X({cantSplit:!0,children:v})]})},ne=(e,t)=>{const i=t.room-t.indent,u=Math.max(1,...e.rows.map(x=>x.length)),g=Array.from({length:u},(x,I)=>e.widths?.[I]?(e.widths[I]??0)*Re:void 0),h=g.reduce((x,I)=>x+(I??0),0),d=At(e),s=g.reduce((x,I,pe)=>x+(I===void 0?d[pe]??1:0),0)||1,A=Math.max(i-h,0),b=g.map((x,I)=>x??A*(d[I]??1)/s),E=b.reduce((x,I)=>x+I,0)||1,v=Math.min(1,i/E),M=b.map(x=>Math.round(x*v)),F=e.head===void 0||e.head==="both",J=e.head==="column"||e.head==="both",ae=Tt(e);return new P({layout:H.FIXED,width:{size:M.reduce((x,I)=>x+I,0),type:z.DXA},columnWidths:M,...t.indent===0?{}:{indent:{size:t.indent,type:z.DXA}},rows:e.rows.map((x,I)=>new X({tableHeader:F&&I===0,cantSplit:!0,children:Array.from({length:u},(pe,ee)=>{const Ie=F&&I===0,ke=J&&ee===0&&!Ie;return new _({width:{size:M[ee]??0,type:z.DXA},borders:{top:{style:m.NONE,size:0,color:"auto"},left:{style:m.NONE,size:0,color:"auto"},right:{style:m.NONE,size:0,color:"auto"},bottom:{style:m.SINGLE,size:4,color:F&&I===0?De:ge}},margins:{top:y(l.cell.top),bottom:y(l.cell.top),left:ee===0?0:y(l.cell.side),right:ee===u-1?0:y(l.cell.side),marginUnitType:z.DXA},children:[new o({spacing:{after:0},...ae.has(ee)?{alignment:f.RIGHT}:{},children:$(x[ee]??[],{bold:ke,...Ie?{color:ce}:{},size:l.small*2})})]})})}))})},Z=(e,t,i,u,g,h)=>{const d=se(e.align),s={...R(t),...d===void 0?{}:{alignment:d}},A=i===void 0?void 0:e.caption,b=A!==void 0,E=[new o({...s,keepNext:b,...i?{spacing:{line:240,lineRule:n.LineRuleType.AUTO,...b?{after:y(l.caption)}:{}}}:{},children:i?[new a({type:i.type,data:i.data,transformation:It(i,e.width,t.room-t.indent),altText:{name:e.alt??"",title:e.caption??e.alt??"",description:e.alt??""}})]:[new C({text:u,color:re})]})];return A!==void 0&&E.push(new o({...s,style:"Caption",children:he(h,[new C({text:ve(A,g)})])})),E},ue=(e,t)=>{const i=t.room-t.indent,u=e.columns.map(E=>E.width??1),g=u.reduce((E,v)=>E+v,0)||1,h=u.map(E=>Math.round(i*E/g)),d=Je(e,t.frame),s={style:m.NONE,size:0,color:"auto"},A={top:s,bottom:s,left:s,right:s,insideHorizontal:s,insideVertical:s},b=Dt/2;return new P({layout:H.FIXED,width:{size:i,type:z.DXA},columnWidths:h,borders:A,...t.indent===0?{}:{indent:{size:t.indent,type:z.DXA}},rows:[new X({cantSplit:ct(e,r.page),children:e.columns.map((E,v)=>{const M=h[v]??0,F=v===0?0:b,J=v===e.columns.length-1?0:b,ae=D(Q(E.blocks,{indent:0,level:0,room:M-F-J,frame:d[v]??t.frame}));return new _({width:{size:M,type:z.DXA},borders:A,margins:{top:0,bottom:0,left:F,right:J,marginUnitType:z.DXA},children:ae})})})]})},Ae=(e,t,i)=>{const u=te(e.look?.color,Te),g=Q(e.children??[],Ge(t)),h=T(e.look),d=Fe;return e.type==="check"?[new o({...h,...R(t),style:d,children:[new C({text:e.checked?"☑ ":"☐ "}),...$(e.content,{color:u})]}),...g]:[new o({...h,style:d,numbering:e.type==="bullet"?{reference:He,level:t.level}:{reference:`start-${String(i.start)}`,level:t.level,instance:i.id},children:$(e.content,{color:u})}),...g]},j=(e,t)=>{const i="look"in e?e.look:void 0,u=te(i?.color,Te),g=T(i),h=()=>"children"in e?Q(e.children??[],Ge(t)):[];switch(e.type){case"paragraph":case"toggle":return[new o({...r.sets.align&&e.look?.align===void 0?{alignment:f.JUSTIFIED}:{},...g,...r.sets.indent&&e.type==="paragraph"?{indent:{left:t.indent,firstLine:Math.round(r.page.textIndent*r.page.size*20)}}:R(t),children:$(e.content,{color:u})}),...h()];case"heading":return[new o({...g,...R(t),...e===r.title?{heading:n.HeadingLevel.TITLE}:{heading:n.HeadingLevel[`HEADING_${String(e.level)}`]},children:he(r.anchors.get(e),$(e.content,{color:u}))}),...h()];case"quote":return[new o({...g,indent:{left:t.indent+y(l.quote)},border:{left:{style:m.SINGLE,color:c??De,size:c?12:6,space:Math.floor(l.quote-(c?1.5:.75))}},children:$(e.content,{color:u??ce})}),...h()];case"callout":return[me(e,t),...V()];case"card":return[we(e,t),...V()];case"stats":return[ye(e,t),...V()];case"code":{if(e.language===Me.math||e.language===Me.mermaid){const A=p.drawn?.(e);if(A)return Z({...e.language===Me.math?{}:{align:"center"}},t,A,"")}const d=A=>({style:m.SINGLE,color:Se,size:4,space:A}),s=y(l.box.side+.5);return[new o({indent:{left:t.indent+s,right:s},shading:G(Se),border:{top:d(l.box.top),bottom:d(l.box.top),left:d(l.box.side),right:d(l.box.side)},keepLines:!0,children:e.code.split(`
4
- `).map((A,b)=>new C({text:A,font:L,size:l.small*2,...b>0?{break:1}:{}}))})]}case"columns":return[ue(e,t)];case"chart":{const{chart:d,problems:s}=Qe(e,p),A=oe(m.DASHED,xe);if(!d)return[new o({...R(t),alignment:f.CENTER,border:{top:A,bottom:A,left:A,right:A},children:[new C({text:[e.title??"Chart",...s].join(": "),color:re})]})];const b=Ve(e,t.frame),E=(t.room-t.indent)/Re,v=Math.min(1,E/b.width);return Y.push({chart:d,width:Math.round(b.width*v),height:Math.round(b.height*v),words:Ze(e,d)}),[new o({...R(t),alignment:f.CENTER,spacing:{line:240,lineRule:n.LineRuleType.AUTO},children:[new C({text:`${Ue}${String(Y.length)}`})]})]}case"image":return Z(e,t,p.picture?.(e.src),e.alt??e.caption??e.src,r.numbers.get(e),e.id);case"component":{const d=p.component?.(e);if(d)return Z(e,t,d,"",r.numbers.get(e),e.id);const s=oe(m.DASHED,xe);return[new o({...R(t),alignment:f.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new C({text:tt(e),color:re})]})]}case"table":return[...e.caption===void 0?[]:[new o({...R(t),style:"Caption",keepNext:!0,spacing:{after:y(l.caption)},children:he(e.id,[new C({text:ve(e.caption,r.numbers.get(e))})])})],ne(e,t),...V()];case"pagebreak":return[new o({spacing:{before:0,after:0,line:20,lineRule:n.LineRuleType.EXACT},children:[new n.PageBreak]})];case"bibliography":{const{page:d}=r,s=d.textIndent>0?Math.round(d.textIndent*d.size*20):480;return r.sources.map(A=>new o({...R(t),alignment:f.LEFT,indent:{left:t.indent+s,hanging:s},spacing:{after:y(l.after)},children:A.pieces.map(b=>{const E=b.italic?{italics:!0}:{};return new C({text:b.text,...E})})}))}case"toc":{const d=e.levels??3,s=r.headings.filter(E=>E.level<=d).map(E=>{const v=r.anchors.get(E)??"",M=p.headingPage?.(v),F=r.bookmarks.get(v);return{title:E.content.map(J=>J.text).join(""),level:E.level,...M===void 0?{}:{page:M},...F===void 0?{}:{href:F}}}),A=Math.min(...s.map(E=>E.level)),b=it(e,r.chinese);return[...b===""?[]:[new o({style:Be,text:b})],new n.TableOfContents(void 0,{hyperlink:!0,headingStyleRange:`1-${String(d)}`,beginDirty:!1,cachedEntries:s.map(E=>({...E,level:E.level-A+1}))})]}case"note":return[];case"divider":return[new o({...R(t),spacing:{before:y(l.divider),after:y(l.divider),line:20,lineRule:n.LineRuleType.EXACT},border:{bottom:{style:m.SINGLE,color:ge,size:4,space:0}}})];case"embed":{const d=/^<\s*([A-Za-z][\w.]*)/.exec(e.source.trim())?.[1],s=oe(m.DASHED,xe);return[new o({...R(t),alignment:f.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new C({text:d??"",color:re})]})]}case"source":return[];case"bullet":case"numbered":case"check":return[]}};function Q(e,t){const i=[];let u,g;for(const h of e){if(!xt(h)){u=void 0,g=void 0,i.push(...j(h,t));continue}if(u===void 0||g===void 0||g.type==="numbered"!=(h.type==="numbered")){const d=h.type==="numbered"?h.start??1:1;U.add(d),u={id:++q,start:d}}g=h,i.push(...Ae(h,t,u))}return i.flatMap((h,d)=>h instanceof P&&i[d+1]instanceof P?[h,le(0)]:[h])}return{charts:Y,body:(e,t)=>Q(e,ze(t)),footnotes:e=>Object.fromEntries([...Ee(e)].flatMap(t=>{if(t.type!=="note")return[];const i=S.get(t.label.toLowerCase());if(i===void 0)return[];const u=Q(t.children??[],ze(K(r.page.width)-K(r.page.margins.left+r.page.margins.right))).filter(g=>g instanceof o);return[[String(i),{children:[new o({spacing:{after:40},children:$(t.content,{size:18,color:ce})}),...u]}]]})),numbering:()=>[{reference:He,levels:Array.from({length:9},(e,t)=>({level:t,format:n.LevelFormat.BULLET,text:["•","◦","▪"][t%3]??"•",alignment:f.LEFT,style:{paragraph:{indent:{left:(t+1)*fe,hanging:fe}}}}))},...[...U].sort((e,t)=>e-t).map(e=>({reference:`start-${String(e)}`,levels:Array.from({length:9},(t,i)=>({level:i,format:[n.LevelFormat.DECIMAL,n.LevelFormat.LOWER_LETTER,n.LevelFormat.LOWER_ROMAN][i%3]??n.LevelFormat.DECIMAL,text:`%${String(i+1)}.`,alignment:f.LEFT,...i===0?{start:e}:{},style:{paragraph:{indent:{left:(i+1)*fe,hanging:fe}}}}))}))]}}const vt="1980-01-01T00:00:00Z",We=9525,je="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Pt=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function _t(n,p,w,c,S){return n.forEach((r,f)=>{const m=String(f+1),N=`rIdChart${m}`,a=`Microsoft_Excel_Worksheet${m}.xlsx`;S(`word/charts/chart${m}.xml`,Ye(r.chart,{width:r.width*.75,height:r.height*.75},"rId1",{frameless:!0})),S(`word/charts/_rels/chart${m}.xml.rels`,`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${je}/package" Target="../embeddings/${a}"/></Relationships>`),S(`word/embeddings/${a}`,qe(r.chart)),w=w.replace("</Relationships>",`<Relationship Id="${N}" Type="${je}/chart" Target="charts/chart${m}.xml"/></Relationships>`),c=c.replace("</Types>",`<Override ContentType="application/vnd.openxmlformats-officedocument.drawingml.chart+xml" PartName="/word/charts/chart${m}.xml"/></Types>`);const o=String(r.width*We),W=String(r.height*We),P=`<w:r><w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${o}" cy="${W}"/><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="0" name="Chart ${m}" descr="${Pt(r.words)}"/><wp:cNvGraphicFramePr/><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" r:id="${N}"/></a:graphicData></a:graphic></wp:inline></w:drawing></w:r>`;p=p.replace(new RegExp(`<w:r>(?:(?!<w:r>).)*?<w:t[^>]*>${Ue}${m}</w:t></w:r>`,"su"),P)}),n.length>0&&!c.includes('Extension="xlsx"')&&(c=c.replace("</Types>",'<Default ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" Extension="xlsx"/></Types>')),{document:p,rels:w,types:c}}function $t(n,p,w){const c=p.unzipSync(n),S=D=>{const L=c[D];return L&&new TextDecoder().decode(L)},r=(D,L)=>{c[D]=typeof L=="string"?new TextEncoder().encode(L):L},f="word/document.xml",m="word/_rels/document.xml.rels",N="[Content_Types].xml",a=_t(w,S(f)??"",S(m)??"",S(N)??"",r);r(N,a.types);let o=a.document,W=a.rels;[...new Set([...o.matchAll(/w:hyperlink [^>]*r:id="([^"]+)"/g)].map(D=>D[1]??""))].forEach((D,L)=>{const U=`rIdLink${String(L+1)}`;o=o.split(`"${D}"`).join(`"${U}"`),W=W.split(`"${D}"`).join(`"${U}"`)});let _=0;o=o.replace(/<wp:docPr id="\d+"/g,()=>`<wp:docPr id="${String(++_)}"`);const H=new Map;o=o.replace(/<w:bookmarkStart w:name="([^"]*)" w:id="(\d+)"/g,(D,L,U)=>{const q=String(H.size+1);return H.set(U,q),`<w:bookmarkStart w:name="${L}" w:id="${q}"`}),o=o.replace(/<w:bookmarkEnd w:id="(\d+)"/g,(D,L)=>{const U=H.get(L);return U===void 0?D:`<w:bookmarkEnd w:id="${U}"`}),r(f,o),r(m,W);const X="docProps/core.xml",C=S(X);C!==void 0&&r(X,C.replace(/(<dcterms:(?:created|modified)[^>]*>)[^<]*/g,`$1${vt}`));const z=Object.fromEntries(Object.entries(c).sort(([D],[L])=>D<L?-1:1));return p.zipSync(z,{mtime:new Date(1980,0,1)})}const be=(n,p)=>{const w=Xe[n];return{ascii:w.latin,hAnsi:w.latin,cs:w.latin,eastAsia:w.eastAsia??p}};function Ft(n,p,w){const c={left:[],center:[],right:[]};p.left!==void 0&&c.left.push(p.left),p.center!==void 0&&c.center.push(p.center),p.right!==void 0&&c.right.push(p.right),p.outside!==void 0&&c[w.odd?"right":"left"].push(p.outside),p.inside!==void 0&&c[w.odd?"left":"right"].push(p.inside);const S={size:Math.round(w.size*2),color:w.color,font:be(w.face,w.eastAsia)},r=f=>f.split(/(\{title\}|\{section\}|\{page\}|\{pages\})/u).filter(m=>m!=="").map(m=>m==="{page}"?new n.TextRun({...S,children:[n.PageNumber.CURRENT]}):m==="{pages}"?new n.TextRun({...S,children:[n.PageNumber.TOTAL_PAGES]}):m==="{section}"?new n.SimpleField(`STYLEREF "heading ${String(w.section)}"`,""):new n.TextRun({...S,text:m==="{title}"?w.title:m}));return new n.Paragraph({style:w.style,tabStops:[{type:n.TabStopType.CENTER,position:Math.round(w.width/2)},{type:n.TabStopType.RIGHT,position:w.width}],children:[...r(c.left.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...r(c.center.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...r(c.right.join(" "))]})}const Ke=(n,p,w,c)=>({run:{...p?.font===void 0?{}:{font:be(n.font,w)},...p?.size===void 0?{}:{size:Math.round(n.size*2)},...p?.weight===void 0?{}:{bold:n.weight==="bold"},...p?.italic===void 0?{}:{italics:n.italic}},paragraph:p?.align===void 0?{}:{alignment:n.align==="center"?c.AlignmentType.CENTER:n.align==="right"?c.AlignmentType.RIGHT:c.AlignmentType.LEFT}});function Ht(n){const p=new Map,w=new Set;return n.forEach((c,S)=>{const r=c.replace(/[^A-Za-z0-9_]/gu,"_").replace(/^[^A-Za-z]+/u,"");let f=`b_${r}`.slice(0,32);(w.has(f)||r==="")&&(f=`b_${String(S)}_${r}`.slice(0,40)),w.add(f),p.set(c,f)}),p}export async function docxOf(n,p,w,c={}){const S=c.page??{},r=Pe(S).citationStyle??"apa",f=st(w,c.sources??[],r,"block"),m=ot(w,c.sources??[],r),N=Pe(S),a=mt(S),o=Xe[a.font].eastAsia??Mt(yt(f)),W=be(a.font,o),P=te(ut(c.page),{}),_=ht(f),H=nt(f,S),X=new Map;for(const T of Ee(f)){const R=Oe(T),O=H.get(T);R!==void 0&&O!==void 0&&X.set(R,O.label)}for(const[T,R]of _)T.type==="heading"&&X.set(R,T.content.map(O=>O.text).join(""));const{title:C}=wt(f),z=[...Ee(f)].filter(T=>T.type==="heading"&&T!==C),D=Ht([..._.values(),...[...Ee(f)].flatMap(T=>{const R=Oe(T);return R===void 0?[]:[R]})]),L=Ot(n,c,o,P,St(f),{page:a,sets:{indent:N.textIndent!==void 0&&N.textIndent>0,align:N.textAlign==="justify"},numbers:H,refs:X,bookmarks:D,anchors:_,title:C,headings:z,chinese:rt(f),sources:m}),U=lt(f),q={width:K(a.width),height:K(a.height)},Y={top:K(a.margins.top),bottom:K(a.margins.bottom),left:K(a.margins.left),right:K(a.margins.right)},G=c.cover,oe=[a.header,a.footer].some(T=>T!==void 0&&(T.outside!==void 0||T.inside!==void 0)),l=U.map((T,R)=>{const O=T.landscape?q.height:q.width,me=O-Y.left-Y.right,we=L.body(T.blocks,me);if(R===0&&G){const j=Math.round(O/Re);we.unshift(new n.Paragraph({spacing:{before:0,after:0},children:[new n.ImageRun({type:G.type,data:G.data,transformation:{width:j,height:Math.round(j*Rt)},floating:{horizontalPosition:{relative:n.HorizontalPositionRelativeFrom.PAGE,offset:0},verticalPosition:{relative:n.VerticalPositionRelativeFrom.PAGE,offset:0},allowOverlap:!1,margins:{bottom:324e3},wrap:{type:n.TextWrappingType.TOP_AND_BOTTOM}},altText:{name:"Cover",title:"Cover",description:""}})]}))}const ye=(j,Q,e)=>{if(j===void 0)return;const t=i=>Ft(n,j,{style:e,odd:i,width:me,title:c.title??"",section:Math.min(...z.map(u=>u.level),6),face:j.font??a.font,eastAsia:o,size:j.size===void 0?Math.max(7.5,a.size*.75):_e(j.size),color:Q?re:de});return{default:t(!0),...oe?{even:t(!1)}:{}}},ne=ye(a.header,N.header===void 0,"Header"),Z=ye(a.footer,N.footer===void 0,"Footer"),ue=R===0&&G!==void 0&&ne!==void 0,Ae=N.grid===void 0?void 0:{type:n.DocumentGridType.LINES_AND_CHARS,linePitch:Math.round(gt(a)*20),charSpace:Math.round(a.textWidth/25.4*72/N.grid.chars-a.size)*4096};return{properties:{page:{size:{width:q.width,height:q.height,...T.landscape?{orientation:n.PageOrientation.LANDSCAPE}:{}},margin:{...Y,header:Math.max(0,Y.top-K(7)-Math.round(a.size*20*1.2)),footer:Math.max(0,Y.bottom-K(7)-Math.round(a.size*20*1.2))}},...Ae===void 0?{}:{grid:Ae},...ue?{titlePage:!0}:{}},...ne===void 0?{}:{headers:{default:new n.Header({children:[ne.default]}),...ne.even?{even:new n.Header({children:[ne.even]})}:{},...ue?{first:new n.Header({children:[]})}:{}}},...Z===void 0?{}:{footers:{default:new n.Footer({children:[Z.default]}),...Z.even?{even:new n.Footer({children:[Z.even]})}:{},...ue?{first:new n.Footer({children:[Z.default]})}:{}}},children:we}}),y=a.lineHeight,le={spacing:{after:Math.round(a.paragraphSpacing*a.size*20),..."pt"in y?{line:Math.round(y.pt*20),lineRule:n.LineRuleType.EXACT}:{line:Math.round(y.multiple*240),lineRule:n.LineRuleType.AUTO}}},V=a.spacing,se=T=>Math.round(T*20),B=T=>{const R=N.headings?.[T],O=Ke(a.headings[T],R,o,n);return{run:{size:Math.round(a.headings[T].size*2),bold:!0,font:W,color:de,...O.run},paragraph:{spacing:{before:se(V.heading.before),after:se(V.heading.after)},keepNext:!0,keepLines:!0,...a.headings[T].rule?{border:{bottom:{style:n.BorderStyle.SINGLE,size:4,color:ge,space:at}}}:{},...O.paragraph}}},$=Ke(a.title,N.title,o,n),Ce=new n.Document({creator:"AllyHub",lastModifiedBy:"AllyHub",...c.title===void 0?{}:{title:c.title},...oe?{evenAndOddHeaderAndFooters:!0}:{},numbering:{config:L.numbering()},styles:{default:{document:{run:{font:W,size:Math.round(a.size*2),color:de},paragraph:le},hyperlink:{run:{color:P??de,underline:{color:P??De}}},title:{run:{size:Math.round(a.title.size*2),bold:!0,font:W,color:de,...$.run},paragraph:{spacing:{before:0,after:se(V.title)},keepNext:!0,...$.paragraph}},heading1:B(1),heading2:B(2),heading3:B(3),heading4:B(4),heading5:B(5),heading6:B(6)},paragraphStyles:[{id:Be,name:"TOC Heading",basedOn:"Normal",next:"Normal",quickFormat:!0,...B(1)},{id:"Caption",name:"caption",basedOn:"Normal",next:"Normal",quickFormat:!0,run:{size:V.small*2,color:re},paragraph:{spacing:{before:0}}},{id:Fe,name:"List Paragraph",basedOn:"Normal",quickFormat:!0,paragraph:{contextualSpacing:!0}},...[["Header",a.header,N.header===void 0],["Footer",a.footer,N.footer===void 0]].flatMap(([T,R,O])=>R===void 0?[]:[{id:T,name:T.toLowerCase(),basedOn:"Normal",run:{size:Math.round((R.size===void 0?Math.max(7.5,a.size*.75):_e(R.size))*2),color:O?re:de,font:be(R.font??a.font,o)},paragraph:{spacing:{before:0,after:0,line:240}}}])]},sections:l,footnotes:L.footnotes(f)}),he=await n.Packer.toBuffer(Ce);return $t(new Uint8Array(he),p,L.charts)}
2
+ import{chartBook as Qe,embeddedChartXml as Je}from"@allyhub/chart";import{chartFrame as et,chartWords as tt,docChart as nt}from"./chart.js";import{BACKGROUNDS as Ie,TEXT_COLORS as Se,hex as ee}from"./color.js";import{columnWidths as it}from"./columns.js";import{COMPONENT_WIDTH as rt,componentName as ot}from"./component.js";import{blockId as $e,captionNumbers as st,contentsTitle as at,numberedCaption as Oe,writtenInChinese as dt,withoutTitle as ct}from"./captions.js";import{sourceList as lt,withSources as ht}from"./cite.js";import{HEADING_RULE_SPACE as ut,cardKept as pt,columnsKept as ft,docParts as gt,headingAnchors as mt,pageAccent as wt,trendSvg as yt}from"./html.js";import{effectiveLook as Fe,LIST_STEP as At,lineHeightPt as Tt,resolvePage as Et,sizePt as He}from"./page.js";import{splitTitle as Rt}from"./title.js";import{markdownOf as St}from"./markdown.js";import{charsAcross as Xe,columnShares as zt,emptyHead as Lt,numberColumns as Mt}from"./table.js";import{DRAWN_CODE as ve}from"./math.js";import{PAPER as te,TONE_COLORS as Ue,tagColors as Ct}from"./paper.js";import{COVER_ASPECT as Nt,everyBlock as ze,firstNoteMarks as bt,noteNumbers as xt,statTone as Dt}from"./model.js";const ue=15,It=1440/25.4,Y=n=>Math.round(n*It),Ge="ListParagraph",Be="bullets",Ot=1.8,pe=At*20,We={sans:{latin:"Calibri"},serif:{latin:"Cambria"},mono:{latin:"Courier New"},times:{latin:"Times New Roman"},song:{latin:"Times New Roman",eastAsia:"宋体"},hei:{latin:"Arial",eastAsia:"黑体"},fangsong:{latin:"Times New Roman",eastAsia:"仿宋"},kai:{latin:"Times New Roman",eastAsia:"楷体"},xiaobiaosong:{latin:"Times New Roman",eastAsia:"方正小标宋简体"}},Pe="Courier New",W=n=>n.slice(1).toUpperCase(),le=W(te.ink),fe=W(te.lead),vt=Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=","base64"),Le=W(te.rule),ge=W(te.ruleStrong),Me=W(te.ruleMid),Ce=W(te.stone),Pt=W(te.stone3),de=W(te.leadSoft),je="ALLYHUB-CHART-";function _t(n){return/[\u3040-\u30ff]/u.test(n)?"Yu Gothic":/[\uac00-\ud7af]/u.test(n)?"Malgun Gothic":"Microsoft YaHei"}const $t=/^(https?:|mailto:)/i,Ne=n=>({indent:0,level:0,room:n,frame:rt}),Ke=n=>({...n,indent:n.indent+pe,level:Math.min(n.level+1,8)}),Ft=400,Ht=n=>n.type==="bullet"||n.type==="numbered"||n.type==="check";function Xt(n,u,w){const l=w/ue,S=Math.floor(Math.min(u??n.width,l));return{width:S,height:Math.round(S*n.height/n.width)}}const qe="TOCHeading";function Ut(n,u,w,l,S,z,r){const{AlignmentType:m,BorderStyle:y,ExternalHyperlink:c,ImageRun:x,Paragraph:h,ShadingType:Z,Table:F,TableCell:_,TableLayoutType:H,TableRow:G,TextRun:M,WidthType:p}=n,N=e=>{const t=e.filter(i=>!(i instanceof n.TableOfContents));return t.at(-1)instanceof h?t:[...t,Q(0)]},X={ascii:Pe,hAnsi:Pe,cs:Pe,eastAsia:w},$=new Set([1]);let ne=0;const k=[],B=e=>({type:Z.CLEAR,color:"auto",fill:e}),he=(e,t,i=4)=>({style:e,color:t,size:i,space:4}),o=r.page.spacing,E=e=>Math.round(e*20),Q=e=>new h({spacing:{before:0,after:E(e),line:14,lineRule:n.LineRuleType.EXACT}}),J=()=>o.after>0?[Q(o.after)]:[],j=e=>e==="center"?m.CENTER:e==="right"?m.RIGHT:e==="justify"?m.JUSTIFIED:void 0,ie=(e,t,i,f={})=>{if(t.tag!==void 0){const s=Ct(t.tag),R={...f,color:W(s.fg),size:Math.round((i.size??r.page.size*2)*.85),shading:B(W(s.bg)),...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{}};return[new M({...R,text:` ${e.replace(/\n/gu," ")} `})]}const g=ee(t.color,Se)??i.color,a=ee(t.background,Ie),d={...f,...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{},...t.underline?{underline:{}}:{},...t.strike?{strike:!0}:{},...g===void 0?{}:{color:g},...i.size===void 0?{}:{size:i.size},...t.code?{font:X,shading:B(a??Ce)}:a===void 0?{}:{shading:B(a)}};return e.split(`
3
+ `).map((s,R)=>new M({...d,text:s,...R>0?{break:1}:{}}))},U=(e,t={})=>e.flatMap(i=>i.note!==void 0?S.has(i.note.toLowerCase())?z.has(i)?[new n.FootnoteReferenceRun(S.get(i.note.toLowerCase())??1)]:[new M({text:String(S.get(i.note.toLowerCase())??1),style:"FootnoteReference"})]:[]:i.text===""&&i.href?.startsWith("#")===!0?xe(i.href.slice(1),i.styles,t):i.href!==void 0&&$t.test(i.href)?[new c({link:i.href,children:ie(i.text,i.styles,t,{style:"Hyperlink"})})]:ie(i.text,i.styles,t)),xe=(e,t,i)=>{const f=decodeURIComponent(e),g=r.refs.get(f)??"",a=r.bookmarks.get(f);return g===""?[]:a===void 0?ie(g,t,i):[new n.InternalHyperlink({anchor:a,children:ie(g,t,i,{style:"Hyperlink"})})]},T=(e,t)=>{const i=e===void 0?void 0:r.bookmarks.get(e);return i===void 0?t:[new n.Bookmark({id:i,children:t})]},D=e=>{const t=j(e?.align),i=ee(e?.background,Ie);return{...t===void 0?{}:{alignment:t},...i===void 0?{}:{shading:B(i)}}},L=e=>e.indent===0?{}:{indent:{left:e.indent}},re=e=>{const t={style:y.SINGLE,color:e,size:4};return{top:t,bottom:t,left:t,right:t}},me=(e,t)=>{const i=ee(e.look?.background,Ie)??Ce,f=ee(e.look?.color,Se),g=t.room-t.indent,a=e.icon===void 0?0:E(r.page.size*Ot)+E(o.box.side),d=g-a,s=(R,C)=>({top:E(o.box.top),bottom:E(Math.max(o.box.top-o.after,0)),left:R,right:C,marginUnitType:p.DXA});return new F({layout:H.FIXED,width:{size:g,type:p.DXA},columnWidths:a===0?[d]:[a,d],...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:!0,children:[...e.icon===void 0?[]:[new _({width:{size:a,type:p.DXA},shading:B(i),borders:re(i),margins:s(E(o.box.side),0),children:[new h({children:[new M({text:e.icon})]})]})],new _({width:{size:d,type:p.DXA},shading:B(i),borders:re(i),margins:s(a===0?E(o.box.side):0,E(o.box.side)),children:[new h({children:U(e.content,{color:f})}),...N(V(e.children??[],Ne(d-E(o.box.side))))]})]})]})},we=(e,t)=>{const i=t.room-t.indent,f=E(o.card.side),g=[...e.title===void 0?[]:[new h({spacing:{after:e.subtitle===void 0?E(o.after):0},children:U([{text:e.title,styles:{bold:!0}}])})],...e.subtitle===void 0?[]:[new h({spacing:{after:E(o.after)},children:[new M({text:e.subtitle,color:fe,size:o.small*2})]})]];return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:[i],...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:pt(e,r.page),children:[new _({width:{size:i,type:p.DXA},borders:re(Le),margins:{top:E(o.card.top),bottom:E(Math.max(o.card.top-o.after,0)),left:f,right:f,marginUnitType:p.DXA},children:N([...g,...V(e.children??[],Ne(i-2*f))])})]})]})},oe=(e,t)=>{const i=t.room-t.indent,f=E(o.gap),g=e.stats.length,a=Math.floor((i-f*(g-1))/g),d=e.stats.flatMap((b,P)=>P===0?[a]:[f,a]),s={style:y.NONE,size:0,color:"auto"},R={top:s,bottom:s,left:s,right:s},C=E(o.card.side),A=o.small*2,v=e.stats.flatMap((b,P)=>{const q=Dt(b),ce=[...b.delta===void 0?[]:[new M({text:b.delta,color:W(Ue[q]),size:A})],...b.note===void 0?[]:[new M({text:`${b.delta===void 0?"":" "}${b.note}`,color:fe,size:A})]],Ae=a-2*C,Te=b.trend===void 0?[]:[new h({spacing:{before:60,after:0,line:240},children:[new x({type:"svg",data:Buffer.from(yt(b.trend,Ue[q]).replace("<svg ",`<svg xmlns="http://www.w3.org/2000/svg" width="${String(Math.round(Ae/15))}" height="24" `)),fallback:{type:"png",data:vt},transformation:{width:Math.round(Ae/15),height:24}})]})],I=new _({width:{size:a,type:p.DXA},borders:re(Le),margins:{top:E(o.card.top),bottom:E(o.card.top),left:C,right:C,marginUnitType:p.DXA},children:[new h({spacing:{after:0},children:[new M({text:b.label,color:fe,size:A})]}),new h({spacing:{after:0,line:240,lineRule:n.LineRuleType.AUTO},children:U([{text:b.value,styles:{bold:!0}}],{size:o.figure*2})}),...ce.length===0?[]:[new h({spacing:{after:0},children:ce})],...Te]}),O=new _({width:{size:f,type:p.DXA},borders:R,children:[new h({children:[]})]});return P===0?[I]:[O,I]});return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:d,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:!0,children:v})]})},se=(e,t)=>{const i=t.room-t.indent,f=Math.max(1,...e.rows.map(I=>I.length)),g=Array.from({length:f},(I,O)=>e.widths?.[O]?(e.widths[O]??0)*ue:void 0),a=g.reduce((I,O)=>I+(O??0),0),d=zt(e,{across:Xe(Math.max(i-a,0)/ue,o.small),margins:Xe(2*o.cell.side*96/72,o.small)}),s=g.reduce((I,O,_e)=>I+(O===void 0?d[_e]??1:0),0)||1,R=Math.max(i-a,0),C=g.map((I,O)=>I??R*(d[O]??1)/s),A=C.reduce((I,O)=>I+O,0)||1,v=Math.min(1,i/A),b=C.map(I=>Math.round(I*v)),P=Lt(e),q=(e.head===void 0||e.head==="both")&&!P,ce=e.head==="column"||e.head==="both",Ae=Mt(e),Te=P?e.rows.slice(1):e.rows;return new F({layout:H.FIXED,width:{size:b.reduce((I,O)=>I+O,0),type:p.DXA},columnWidths:b,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:Te.map((I,O)=>new G({tableHeader:q&&O===0,cantSplit:!0,children:Array.from({length:f},(_e,Ee)=>{const Re=q&&O===0,ke=ce&&Ee===0&&!Re;return new _({width:{size:b[Ee]??0,type:p.DXA},...Re?{shading:B(Pt)}:{},borders:{top:O===0?{style:y.SINGLE,size:8,color:ge}:{style:y.NONE,size:0,color:"auto"},left:{style:y.NONE,size:0,color:"auto"},right:{style:y.NONE,size:0,color:"auto"},bottom:O===Te.length-1?{style:y.SINGLE,size:8,color:ge}:Re?{style:y.SINGLE,size:6,color:ge}:{style:y.SINGLE,size:4,color:Me}},margins:{top:E(o.cell.top),bottom:E(o.cell.top),left:E(o.cell.side),right:E(o.cell.side),marginUnitType:p.DXA},children:[new h({spacing:{after:0},...Ae.has(Ee)?{alignment:m.RIGHT}:{},children:U(I[Ee]??[],{bold:ke||Re,size:o.small*2})})]})})}))})},ae=(e,t,i,f,g,a)=>{const d=j(e.align),s={...L(t),...d===void 0?{}:{alignment:d}},R=i===void 0?void 0:e.caption,C=R!==void 0,A=[new h({...s,keepNext:C,...i?{spacing:{line:240,lineRule:n.LineRuleType.AUTO,...C?{after:E(o.caption)}:{}}}:{},children:i?[new x({type:i.type,data:i.data,transformation:Xt(i,e.width,t.room-t.indent),altText:{name:e.alt??"",title:e.caption??e.alt??"",description:e.alt??""}})]:[new M({text:f,color:de})]})];return R!==void 0&&A.push(new h({...s,style:"Caption",children:T(a,[new M({text:Oe(R,g)})])})),A},ye=(e,t)=>{const i=t.room-t.indent,f=e.columns.map(A=>A.width??1),g=f.reduce((A,v)=>A+v,0)||1,a=f.map(A=>Math.round(i*A/g)),d=it(e,t.frame),s={style:y.NONE,size:0,color:"auto"},R={top:s,bottom:s,left:s,right:s,insideHorizontal:s,insideVertical:s},C=Ft/2;return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:a,borders:R,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:ft(e,r.page),children:e.columns.map((A,v)=>{const b=a[v]??0,P=v===0?0:C,q=v===e.columns.length-1?0:C,ce=N(V(A.blocks,{indent:0,level:0,room:b-P-q,frame:d[v]??t.frame}));return new _({width:{size:b,type:p.DXA},borders:R,margins:{top:0,bottom:0,left:P,right:q,marginUnitType:p.DXA},children:ce})})})]})},K=(e,t,i)=>{const f=ee(e.look?.color,Se),g=V(e.children??[],Ke(t)),a=D(e.look),d=Ge;return e.type==="check"?[new h({...a,...L(t),style:d,children:[new M({text:e.checked?"☑ ":"☐ "}),...U(e.content,{color:f})]}),...g]:[new h({...a,style:d,numbering:e.type==="bullet"?{reference:Be,level:t.level}:{reference:`start-${String(i.start)}`,level:t.level,instance:i.id},children:U(e.content,{color:f})}),...g]},De=(e,t)=>{const i="look"in e?e.look:void 0,f=ee(i?.color,Se),g=D(i),a=()=>"children"in e?V(e.children??[],Ke(t)):[];switch(e.type){case"paragraph":case"toggle":return[new h({...r.sets.align&&e.look?.align===void 0?{alignment:m.JUSTIFIED}:{},...g,...r.sets.indent&&e.type==="paragraph"?{indent:{left:t.indent,firstLine:Math.round(r.page.textIndent*r.page.size*20)}}:L(t),children:U(e.content,{color:f})}),...a()];case"heading":return[new h({...g,...L(t),...e===r.title?{heading:n.HeadingLevel.TITLE}:{heading:n.HeadingLevel[`HEADING_${String(e.level)}`]},children:T(r.anchors.get(e),U(e.content,{color:f}))}),...a()];case"quote":return[new h({...g,indent:{left:t.indent+E(o.quote)},border:{left:{style:y.SINGLE,color:l??ge,size:l?12:6,space:Math.floor(o.quote-(l?1.5:.75))}},children:U(e.content,{color:f??fe})}),...a()];case"callout":return[me(e,t),...J()];case"card":return[we(e,t),...J()];case"stats":return[oe(e,t),...J()];case"code":{if(e.language===ve.math||e.language===ve.mermaid){const R=u.drawn?.(e);if(R)return ae({...e.language===ve.math?{}:{align:"center"}},t,R,"")}const d=R=>({style:y.SINGLE,color:Ce,size:4,space:R}),s=E(o.box.side+.5);return[new h({indent:{left:t.indent+s,right:s},shading:B(Ce),border:{top:d(o.box.top),bottom:d(o.box.top),left:d(o.box.side),right:d(o.box.side)},keepLines:!0,children:e.code.split(`
4
+ `).map((R,C)=>new M({text:R,font:X,size:o.small*2,...C>0?{break:1}:{}}))})]}case"columns":return[ye(e,t)];case"chart":{const d=r.numbers.get(e),s=d===void 0?void 0:e.title,{chart:R,problems:C}=nt(s===void 0?e:ct(e),u),A=he(y.DASHED,Me);if(!R)return[new h({...L(t),alignment:m.CENTER,border:{top:A,bottom:A,left:A,right:A},children:[new M({text:[e.title??"Chart",...C].join(": "),color:de})]})];const v=et(e,t.frame),b=(t.room-t.indent)/ue,P=Math.min(1,b/v.width);return k.push({chart:R,width:Math.round(v.width*P),height:Math.round(v.height*P),words:tt(e,R)}),[new h({...L(t),alignment:m.CENTER,keepNext:s!==void 0,spacing:{line:240,lineRule:n.LineRuleType.AUTO},children:[new M({text:`${je}${String(k.length)}`})]}),...s===void 0?[]:[new h({...L(t),alignment:m.CENTER,style:"Caption",children:T(e.id,[new M({text:Oe(s,d)})])})]]}case"image":return ae(e,t,u.picture?.(e.src),e.alt??e.caption??e.src,r.numbers.get(e),e.id);case"component":{const d=u.component?.(e);if(d)return ae(e,t,d,"",r.numbers.get(e),e.id);const s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:ot(e),color:de})]})]}case"table":return[...e.caption===void 0?[]:[new h({...L(t),style:"Caption",keepNext:!0,spacing:{after:E(o.caption)},children:T(e.id,[new M({text:Oe(e.caption,r.numbers.get(e))})])})],se(e,t),...J()];case"pagebreak":return[new h({spacing:{before:0,after:0,line:20,lineRule:n.LineRuleType.EXACT},children:[new n.PageBreak]})];case"bibliography":{const{page:d}=r,s=d.textIndent>0?Math.round(d.textIndent*d.size*20):480;return r.sources.map(R=>new h({...L(t),alignment:m.LEFT,indent:{left:t.indent+s,hanging:s},spacing:{after:E(o.after)},children:R.pieces.map(C=>{const A=C.italic?{italics:!0}:{};return new M({text:C.text,...A})})}))}case"toc":{const d=e.levels??3,s=r.headings.filter(A=>A.level<=d).map(A=>{const v=r.anchors.get(A)??"",b=u.headingPage?.(v),P=r.bookmarks.get(v);return{title:A.content.map(q=>q.text).join(""),level:A.level,...b===void 0?{}:{page:b},...P===void 0?{}:{href:P}}}),R=Math.min(...s.map(A=>A.level)),C=at(e,r.chinese);return[...C===""?[]:[new h({style:qe,text:C})],new n.TableOfContents(void 0,{hyperlink:!0,headingStyleRange:`1-${String(d)}`,beginDirty:!1,cachedEntries:s.map(A=>({...A,level:A.level-R+1}))})]}case"note":return[];case"divider":return[new h({...L(t),spacing:{before:E(o.divider),after:E(o.divider),line:20,lineRule:n.LineRuleType.EXACT},border:{bottom:{style:y.SINGLE,color:Le,size:4,space:0}}})];case"embed":{const d=/^<\s*([A-Za-z][\w.]*)/.exec(e.source.trim())?.[1],s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:d??"",color:de})]})]}case"source":return[];case"bullet":case"numbered":case"check":return[]}};function V(e,t){const i=[];let f,g;for(const a of e){if(!Ht(a)){f=void 0,g=void 0,i.push(...De(a,t));continue}if(f===void 0||g===void 0||g.type==="numbered"!=(a.type==="numbered")){const d=a.type==="numbered"?a.start??1:1;$.add(d),f={id:++ne,start:d}}g=a,i.push(...K(a,t,f))}return i.flatMap((a,d)=>a instanceof F&&i[d+1]instanceof F?[a,Q(0)]:[a])}return{charts:k,body:(e,t)=>V(e,Ne(t)),footnotes:e=>Object.fromEntries([...ze(e)].flatMap(t=>{if(t.type!=="note")return[];const i=S.get(t.label.toLowerCase());if(i===void 0)return[];const f=V(t.children??[],Ne(Y(r.page.width)-Y(r.page.margins.left+r.page.margins.right))).filter(g=>g instanceof h);return[[String(i),{children:[new h({spacing:{after:40},children:U(t.content,{size:18,color:fe})}),...f]}]]})),numbering:()=>[{reference:Be,levels:Array.from({length:9},(e,t)=>({level:t,format:n.LevelFormat.BULLET,text:["•","◦","▪"][t%3]??"•",alignment:m.LEFT,style:{paragraph:{indent:{left:(t+1)*pe,hanging:pe}}}}))},...[...$].sort((e,t)=>e-t).map(e=>({reference:`start-${String(e)}`,levels:Array.from({length:9},(t,i)=>({level:i,format:[n.LevelFormat.DECIMAL,n.LevelFormat.LOWER_LETTER,n.LevelFormat.LOWER_ROMAN][i%3]??n.LevelFormat.DECIMAL,text:`%${String(i+1)}.`,alignment:m.LEFT,...i===0?{start:e}:{},style:{paragraph:{indent:{left:(i+1)*pe,hanging:pe}}}}))}))]}}const Gt="1980-01-01T00:00:00Z",Ye=9525,Ve="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Bt=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Wt(n,u,w,l,S){return n.forEach((z,r)=>{const m=String(r+1),y=`rIdChart${m}`,c=`Microsoft_Excel_Worksheet${m}.xlsx`;S(`word/charts/chart${m}.xml`,Je(z.chart,{width:z.width*.75,height:z.height*.75},"rId1",{frameless:!0})),S(`word/charts/_rels/chart${m}.xml.rels`,`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${Ve}/package" Target="../embeddings/${c}"/></Relationships>`),S(`word/embeddings/${c}`,Qe(z.chart)),w=w.replace("</Relationships>",`<Relationship Id="${y}" Type="${Ve}/chart" Target="charts/chart${m}.xml"/></Relationships>`),l=l.replace("</Types>",`<Override ContentType="application/vnd.openxmlformats-officedocument.drawingml.chart+xml" PartName="/word/charts/chart${m}.xml"/></Types>`);const x=String(z.width*Ye),h=String(z.height*Ye),Z=`<w:r><w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${x}" cy="${h}"/><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="0" name="Chart ${m}" descr="${Bt(z.words)}"/><wp:cNvGraphicFramePr/><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" r:id="${y}"/></a:graphicData></a:graphic></wp:inline></w:drawing></w:r>`;u=u.replace(new RegExp(`<w:r>(?:(?!<w:r>).)*?<w:t[^>]*>${je}${m}</w:t></w:r>`,"su"),Z)}),n.length>0&&!l.includes('Extension="xlsx"')&&(l=l.replace("</Types>",'<Default ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" Extension="xlsx"/></Types>')),{document:u,rels:w,types:l}}function jt(n,u,w){const l=u.unzipSync(n),S=p=>{const N=l[p];return N&&new TextDecoder().decode(N)},z=(p,N)=>{l[p]=typeof N=="string"?new TextEncoder().encode(N):N},r="word/document.xml",m="word/_rels/document.xml.rels",y="[Content_Types].xml",c=Wt(w,S(r)??"",S(m)??"",S(y)??"",z);z(y,c.types);let x=c.document,h=c.rels;[...new Set([...x.matchAll(/w:hyperlink [^>]*r:id="([^"]+)"/g)].map(p=>p[1]??""))].forEach((p,N)=>{const X=`rIdLink${String(N+1)}`;x=x.split(`"${p}"`).join(`"${X}"`),h=h.split(`"${p}"`).join(`"${X}"`)});let F=0;x=x.replace(/<wp:docPr id="\d+"/g,()=>`<wp:docPr id="${String(++F)}"`);const _=new Map;x=x.replace(/<w:bookmarkStart w:name="([^"]*)" w:id="(\d+)"/g,(p,N,X)=>{const $=String(_.size+1);return _.set(X,$),`<w:bookmarkStart w:name="${N}" w:id="${$}"`}),x=x.replace(/<w:bookmarkEnd w:id="(\d+)"/g,(p,N)=>{const X=_.get(N);return X===void 0?p:`<w:bookmarkEnd w:id="${X}"`}),z(r,x),z(m,h);const H="docProps/core.xml",G=S(H);G!==void 0&&z(H,G.replace(/(<dcterms:(?:created|modified)[^>]*>)[^<]*/g,`$1${Gt}`));const M=Object.fromEntries(Object.entries(l).sort(([p],[N])=>p<N?-1:1));return u.zipSync(M,{mtime:new Date(1980,0,1)})}const be=(n,u)=>{const w=We[n];return{ascii:w.latin,hAnsi:w.latin,cs:w.latin,eastAsia:w.eastAsia??u}};function Kt(n,u,w){const l={left:[],center:[],right:[]};u.left!==void 0&&l.left.push(u.left),u.center!==void 0&&l.center.push(u.center),u.right!==void 0&&l.right.push(u.right),u.outside!==void 0&&l[w.odd?"right":"left"].push(u.outside),u.inside!==void 0&&l[w.odd?"left":"right"].push(u.inside);const S={size:Math.round(w.size*2),color:w.color,font:be(w.face,w.eastAsia)},z=r=>r.split(/(\{title\}|\{section\}|\{page\}|\{pages\})/u).filter(m=>m!=="").map(m=>m==="{page}"?new n.TextRun({...S,children:[n.PageNumber.CURRENT]}):m==="{pages}"?new n.TextRun({...S,children:[n.PageNumber.TOTAL_PAGES]}):m==="{section}"?new n.SimpleField(`STYLEREF "heading ${String(w.section)}"`,""):new n.TextRun({...S,text:m==="{title}"?w.title:m}));return new n.Paragraph({style:w.style,tabStops:[{type:n.TabStopType.CENTER,position:Math.round(w.width/2)},{type:n.TabStopType.RIGHT,position:w.width}],children:[...z(l.left.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...z(l.center.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...z(l.right.join(" "))]})}const Ze=(n,u,w,l)=>({run:{...u?.font===void 0?{}:{font:be(n.font,w)},...u?.size===void 0?{}:{size:Math.round(n.size*2)},...u?.weight===void 0?{}:{bold:n.weight==="bold"},...u?.italic===void 0?{}:{italics:n.italic}},paragraph:u?.align===void 0?{}:{alignment:n.align==="center"?l.AlignmentType.CENTER:n.align==="right"?l.AlignmentType.RIGHT:l.AlignmentType.LEFT}});function qt(n){const u=new Map,w=new Set;return n.forEach((l,S)=>{const z=l.replace(/[^A-Za-z0-9_]/gu,"_").replace(/^[^A-Za-z]+/u,"");let r=`b_${z}`.slice(0,32);(w.has(r)||z==="")&&(r=`b_${String(S)}_${z}`.slice(0,40)),w.add(r),u.set(l,r)}),u}export async function docxOf(n,u,w,l={}){const S=l.page??{},z=Fe(S).citationStyle??"apa",r=ht(w,l.sources??[],z,"block"),m=lt(w,l.sources??[],z),y=Fe(S),c=Et(S),x=We[c.font].eastAsia??_t(St(r)),h=be(c.font,x),Z=ee(wt(l.page),{}),F=mt(r),_=st(r,S),H=new Map;for(const T of ze(r)){const D=$e(T),L=_.get(T);D!==void 0&&L!==void 0&&H.set(D,L.label)}for(const[T,D]of F)T.type==="heading"&&H.set(D,T.content.map(L=>L.text).join(""));const{title:G}=Rt(r),M=[...ze(r)].filter(T=>T.type==="heading"&&T!==G),p=qt([...F.values(),...[...ze(r)].flatMap(T=>{const D=$e(T);return D===void 0?[]:[D]})]),N=Ut(n,l,x,Z,xt(r),bt(r),{page:c,sets:{indent:y.textIndent!==void 0&&y.textIndent>0,align:y.textAlign==="justify"},numbers:_,refs:H,bookmarks:p,anchors:F,title:G,headings:M,chinese:dt(r),sources:m}),X=gt(r),$={width:Y(c.width),height:Y(c.height)},ne={top:Y(c.margins.top),bottom:Y(c.margins.bottom),left:Y(c.margins.left),right:Y(c.margins.right)},k=l.cover,B=[c.header,c.footer].some(T=>T!==void 0&&(T.outside!==void 0||T.inside!==void 0)),he=X.map((T,D)=>{const L=T.landscape?$.height:$.width,re=L-ne.left-ne.right,me=N.body(T.blocks,re);if(D===0&&k){const K=Math.round(L/ue);me.unshift(new n.Paragraph({spacing:{before:0,after:0},children:[new n.ImageRun({type:k.type,data:k.data,transformation:{width:K,height:Math.round(K*Nt)},floating:{horizontalPosition:{relative:n.HorizontalPositionRelativeFrom.PAGE,offset:0},verticalPosition:{relative:n.VerticalPositionRelativeFrom.PAGE,offset:0},allowOverlap:!1,margins:{bottom:324e3},wrap:{type:n.TextWrappingType.TOP_AND_BOTTOM}},altText:{name:"Cover",title:"Cover",description:""}})]}))}const we=(K,De,V)=>{if(K===void 0)return;const e=t=>Kt(n,K,{style:V,odd:t,width:re,title:l.title??"",section:Math.min(...M.map(i=>i.level),6),face:K.font??c.font,eastAsia:x,size:K.size===void 0?Math.max(7.5,c.size*.75):He(K.size),color:De?de:le});return{default:e(!0),...B?{even:e(!1)}:{}}},oe=we(c.header,y.header===void 0,"Header"),se=we(c.footer,y.footer===void 0,"Footer"),ae=D===0&&k!==void 0&&oe!==void 0,ye=y.grid===void 0?void 0:{type:n.DocumentGridType.LINES_AND_CHARS,linePitch:Math.round(Tt(c)*20),charSpace:Math.round(c.textWidth/25.4*72/y.grid.chars-c.size)*4096};return{properties:{page:{size:{width:Math.min($.width,$.height),height:Math.max($.width,$.height),...T.landscape||$.width>$.height?{orientation:n.PageOrientation.LANDSCAPE}:{}},margin:{...ne,header:Math.max(0,ne.top-Y(7)-Math.round(c.size*20*1.2)),footer:Math.max(0,ne.bottom-Y(7)-Math.round(c.size*20*1.2))}},...ye===void 0?{}:{grid:ye},...ae?{titlePage:!0}:{}},...oe===void 0?{}:{headers:{default:new n.Header({children:[oe.default]}),...oe.even?{even:new n.Header({children:[oe.even]})}:{},...ae?{first:new n.Header({children:[]})}:{}}},...se===void 0?{}:{footers:{default:new n.Footer({children:[se.default]}),...se.even?{even:new n.Footer({children:[se.even]})}:{},...ae?{first:new n.Footer({children:[se.default]})}:{}}},children:me}}),o=c.lineHeight,E={spacing:{after:Math.round(c.paragraphSpacing*c.size*20),..."pt"in o?{line:Math.round(o.pt*20),lineRule:n.LineRuleType.EXACT}:{line:Math.round(o.multiple*240),lineRule:n.LineRuleType.AUTO}}},Q=c.spacing,J=T=>Math.round(T*20),j=T=>{const D=y.headings?.[T],L=Ze(c.headings[T],D,x,n);return{run:{size:Math.round(c.headings[T].size*2),bold:!0,font:h,color:le,...L.run},paragraph:{spacing:{before:J(Q.heading.before),after:J(Q.heading.after)},keepNext:!0,keepLines:!0,...c.headings[T].rule?{border:{bottom:{style:n.BorderStyle.SINGLE,size:4,color:Le,space:ut}}}:{},...L.paragraph}}},ie=Ze(c.title,y.title,x,n),U=new n.Document({creator:"AllyHub",lastModifiedBy:"AllyHub",...l.title===void 0?{}:{title:l.title},...B?{evenAndOddHeaderAndFooters:!0}:{},numbering:{config:N.numbering()},styles:{default:{document:{run:{font:h,size:Math.round(c.size*2),color:le},paragraph:E},hyperlink:{run:{color:Z??le,underline:{color:Z??ge}}},title:{run:{size:Math.round(c.title.size*2),bold:!0,font:h,color:le,...ie.run},paragraph:{spacing:{before:0,after:J(Q.title)},keepNext:!0,...ie.paragraph}},heading1:j(1),heading2:j(2),heading3:j(3),heading4:j(4),heading5:j(5),heading6:j(6)},paragraphStyles:[{id:qe,name:"TOC Heading",basedOn:"Normal",next:"Normal",quickFormat:!0,...j(1)},{id:"Caption",name:"caption",basedOn:"Normal",next:"Normal",quickFormat:!0,run:{size:Q.small*2,color:de},paragraph:{spacing:{before:0}}},{id:Ge,name:"List Paragraph",basedOn:"Normal",quickFormat:!0,paragraph:{contextualSpacing:!0}},...[["Header",c.header,y.header===void 0],["Footer",c.footer,y.footer===void 0]].flatMap(([T,D,L])=>D===void 0?[]:[{id:T,name:T.toLowerCase(),basedOn:"Normal",run:{size:Math.round((D.size===void 0?Math.max(7.5,c.size*.75):He(D.size))*2),color:L?de:le,font:be(D.font??c.font,x)},paragraph:{spacing:{before:0,after:0,line:240}}}])]},sections:he,footnotes:N.footnotes(r)}),xe=await n.Packer.toBuffer(U);return jt(new Uint8Array(xe),u,N.charts)}