@dooc-dev/dooc 0.0.6 → 0.0.8

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 (395) hide show
  1. package/dist/client.global.js +1 -0
  2. package/dist/code-worker.global.js +11 -11
  3. package/dist/code.global.js +75 -75
  4. package/dist/edit.global.js +234 -231
  5. package/dist/{compiler → engine/compiler}/bundle-urls.js +1 -4
  6. package/dist/{compiler → engine/compiler}/check-prose.d.ts +1 -1
  7. package/dist/{compiler → engine/compiler}/check-prose.js +1 -1
  8. package/dist/{compiler → engine/compiler}/check.js +15 -27
  9. package/dist/{compiler → engine/compiler}/code-blocks.js +3 -1
  10. package/dist/{compiler → engine/compiler}/code-languages.js +1 -2
  11. package/dist/{compiler → engine/compiler}/compile.d.ts +5 -4
  12. package/dist/{compiler → engine/compiler}/compile.js +91 -32
  13. package/dist/{compiler → engine/compiler}/config.js +1 -3
  14. package/dist/{compiler → engine/compiler}/dialect.d.ts +1 -3
  15. package/dist/{compiler → engine/compiler}/dialect.js +8 -52
  16. package/dist/{compiler → engine/compiler}/dxf.js +1 -1
  17. package/dist/{compiler → engine/compiler}/export.js +15 -8
  18. package/dist/{compiler → engine/compiler}/figures.js +26 -22
  19. package/dist/{compiler → engine/compiler}/file-cache.d.ts +1 -2
  20. package/dist/{compiler → engine/compiler}/file-cache.js +8 -15
  21. package/dist/{compiler → engine/compiler}/files.js +49 -38
  22. package/dist/{compiler → engine/compiler}/fonts.js +1 -3
  23. package/dist/{compiler → engine/compiler}/from-mdast.js +1 -1
  24. package/dist/engine/compiler/host.d.ts +10 -0
  25. package/dist/engine/compiler/host.js +16 -0
  26. package/dist/{compiler → engine/compiler}/icons.d.ts +3 -0
  27. package/dist/{compiler → engine/compiler}/icons.js +28 -10
  28. package/dist/{compiler → engine/compiler}/ignored-files.d.ts +2 -0
  29. package/dist/{compiler → engine/compiler}/ignored-files.js +12 -3
  30. package/dist/{compiler → engine/compiler}/locales.js +2 -8
  31. package/dist/{compiler → engine/compiler}/manifest.d.ts +3 -2
  32. package/dist/engine/compiler/manifest.js +46 -0
  33. package/dist/{compiler → engine/compiler}/ops.d.ts +4 -1
  34. package/dist/{compiler → engine/compiler}/ops.js +36 -21
  35. package/dist/engine/compiler/schema-file-references.d.ts +2 -0
  36. package/dist/engine/compiler/schema-file-references.js +82 -0
  37. package/dist/engine/compiler/serialize.d.ts +2 -0
  38. package/dist/engine/compiler/serialize.js +5 -0
  39. package/dist/{compiler → engine/compiler}/subformat-schema.js +1 -3
  40. package/dist/{compiler → engine/compiler}/subformats.d.ts +10 -0
  41. package/dist/{compiler → engine/compiler}/subformats.js +122 -18
  42. package/dist/{compiler → engine/compiler}/textfile-remote.js +1 -2
  43. package/dist/{compiler → engine/compiler}/textfile.js +4 -6
  44. package/dist/{compiler → engine/compiler}/theme-variants.js +1 -1
  45. package/dist/{compiler → engine/compiler}/zip.js +1 -1
  46. package/dist/{core → engine/core}/blocks.d.ts +6 -4
  47. package/dist/{core → engine/core}/content-metadata.d.ts +6 -1
  48. package/dist/{core → engine/core}/content-metadata.js +84 -18
  49. package/dist/{core → engine/core}/content-types.d.ts +4 -2
  50. package/dist/{core → engine/core}/html.d.ts +7 -0
  51. package/dist/{core → engine/core}/html.js +44 -3
  52. package/dist/{core → engine/core}/icons.d.ts +3 -0
  53. package/dist/engine/core/icons.js +20 -0
  54. package/dist/{core → engine/core}/routing.d.ts +2 -0
  55. package/dist/{core → engine/core}/routing.js +9 -0
  56. package/dist/{core → engine/core}/schema-refs.d.ts +1 -1
  57. package/dist/{core → engine/core}/schema-refs.js +3 -1
  58. package/dist/engine/core/subformat-references.d.ts +5 -0
  59. package/dist/engine/core/subformat-references.js +33 -0
  60. package/dist/{core → engine/core}/subformats.d.ts +7 -0
  61. package/dist/{core → engine/core}/subformats.js +5 -1
  62. package/dist/{core → engine/core}/taxonomy.d.ts +2 -3
  63. package/dist/{core → engine/core}/taxonomy.js +1 -5
  64. package/dist/flow.global.js +1031 -1057
  65. package/dist/frontend/application-request.d.ts +14 -0
  66. package/dist/frontend/application-request.js +36 -0
  67. package/dist/frontend/document-application.d.ts +200 -0
  68. package/dist/{viewer/serve.js → frontend/document-application.js} +1611 -1670
  69. package/dist/frontend/figure-preview.d.ts +4 -0
  70. package/dist/{viewer → frontend}/figure-preview.js +4 -4
  71. package/dist/{viewer → frontend}/file-references.d.ts +1 -1
  72. package/dist/{viewer → frontend}/file-references.js +3 -3
  73. package/dist/{viewer → frontend}/font-picker.d.ts +1 -1
  74. package/dist/{viewer → frontend}/font-settings.d.ts +1 -1
  75. package/dist/{viewer → frontend}/language-picker.js +112 -18
  76. package/dist/{viewer → frontend}/locales/eng.json +16 -2
  77. package/dist/{viewer → frontend}/locales/jpn.json +16 -2
  78. package/dist/{viewer → frontend}/locales/zho.json +16 -2
  79. package/dist/{viewer → frontend}/nav-focus.js +2 -0
  80. package/dist/{viewer → frontend}/plugin-blocks.js +2 -2
  81. package/dist/{viewer → frontend}/resize.js +14 -2
  82. package/dist/frontend/resource-download.d.ts +2 -0
  83. package/dist/frontend/resource-download.js +43 -0
  84. package/dist/{viewer → frontend}/resource-library.d.ts +9 -2
  85. package/dist/{viewer → frontend}/resource-library.js +133 -37
  86. package/dist/{core → frontend}/schema-graph-flow.d.ts +1 -1
  87. package/dist/{core → frontend}/schema-graph-flow.js +1 -1
  88. package/dist/{viewer → frontend}/search.d.ts +2 -2
  89. package/dist/{viewer → frontend}/search.js +26 -8
  90. package/dist/graph/{abnfDiagram-S7VZAUFO-ASBULSKE.js → abnfDiagram-S7VZAUFO-GAGCW2J5.js} +1 -1
  91. package/dist/graph/{architecture-WOLXFQ4H-V57EDXXY.js → architecture-WOLXFQ4H-AWAC3VBS.js} +1 -1
  92. package/dist/graph/{architectureDiagram-YGSQEFNW-GIMP347N.js → architectureDiagram-YGSQEFNW-WQ7QKSUJ.js} +1 -1
  93. package/dist/graph/{blockDiagram-APKKGZFW-RDL2T4JW.js → blockDiagram-APKKGZFW-H7ZNJMOM.js} +1 -1
  94. package/dist/graph/{bpmnIcons-APHXDYXF-TWOSQNUQ.js → bpmnIcons-APHXDYXF-EAVPNTFE.js} +1 -1
  95. package/dist/graph/{c4Diagram-KJ2TOQU5-75LIUC4F.js → c4Diagram-KJ2TOQU5-3IYS34YL.js} +1 -1
  96. package/dist/graph/{chunk-KU6GTEMS.js → chunk-3CJU2RDX.js} +1 -1
  97. package/dist/graph/{chunk-ISO77HML.js → chunk-5N2X2DXU.js} +1 -1
  98. package/dist/graph/{chunk-YCRLJT2S.js → chunk-67BPVAXC.js} +1 -1
  99. package/dist/graph/{chunk-26TUJSYJ.js → chunk-6CDZONCA.js} +1 -1
  100. package/dist/graph/{chunk-I3DMZIHV.js → chunk-7ASYMKN2.js} +1 -1
  101. package/dist/graph/{chunk-K2KLZU7M.js → chunk-7JQUFVT4.js} +2 -2
  102. package/dist/graph/{chunk-BBD5CEDC.js → chunk-7LSMJ4VU.js} +1 -1
  103. package/dist/graph/{chunk-EG5UVNOC.js → chunk-7UKJADAE.js} +1 -1
  104. package/dist/graph/{chunk-BZAMCJ6B.js → chunk-AARGNXTW.js} +1 -1
  105. package/dist/graph/{chunk-HOPPTA6H.js → chunk-BOXAA5AP.js} +2 -2
  106. package/dist/graph/{chunk-N3OHKGRZ.js → chunk-BTMPKSGF.js} +1 -1
  107. package/dist/graph/{chunk-QCJUF4YA.js → chunk-DIDARDST.js} +1 -1
  108. package/dist/graph/{chunk-R63JUMUK.js → chunk-EWYECPNJ.js} +1 -1
  109. package/dist/graph/{chunk-3YJHMOOA.js → chunk-FD7ZFC7R.js} +1 -1
  110. package/dist/graph/chunk-GWYODWCE.js +1 -0
  111. package/dist/graph/{chunk-IC23EEF6.js → chunk-HKRJKXEE.js} +1 -1
  112. package/dist/graph/{chunk-PW2RGZ3O.js → chunk-I5LEUF24.js} +1 -1
  113. package/dist/graph/{chunk-OFZLK5G4.js → chunk-ICJPOOXG.js} +1 -1
  114. package/dist/graph/{chunk-KT4VPQD5.js → chunk-IVZHB6RS.js} +2 -2
  115. package/dist/graph/{chunk-VM2H7G2R.js → chunk-JZGXHT3J.js} +1 -1
  116. package/dist/graph/{chunk-HJG2HUYJ.js → chunk-LSRL537V.js} +1 -1
  117. package/dist/graph/{chunk-C6J4A356.js → chunk-N44XPVUD.js} +1 -1
  118. package/dist/graph/{chunk-JD7ZBJD2.js → chunk-NDAMZVXQ.js} +1 -1
  119. package/dist/graph/{chunk-QEEA3KYY.js → chunk-QLS7NIYR.js} +1 -1
  120. package/dist/graph/{chunk-JRSH5GNS.js → chunk-QQIGL7OP.js} +1 -1
  121. package/dist/graph/chunk-SQE76S5B.js +1 -0
  122. package/dist/graph/{chunk-ZMCB7VP2.js → chunk-WQHTQAFY.js} +1 -1
  123. package/dist/graph/{classDiagram-v2-L25IHNXF-JL7LVDZH.js → classDiagram-v2-L25IHNXF-HNTCDTNK.js} +1 -1
  124. package/dist/graph/{cose-bilkent-JH36ORCC-PNM3EYPB.js → cose-bilkent-JH36ORCC-2GVA7XKO.js} +1 -1
  125. package/dist/graph/{cynefin-EF2NZ3EQ-PSXP3DXL.js → cynefin-EF2NZ3EQ-TCI65RAQ.js} +1 -1
  126. package/dist/graph/{cynefinDiagram-L36ESFBY-QVY54CXO.js → cynefinDiagram-L36ESFBY-OKQ5BLVF.js} +1 -1
  127. package/dist/graph/{dagre-SPEB5RXH-HPGQXBZJ.js → dagre-SPEB5RXH-KZEBD52K.js} +1 -1
  128. package/dist/graph/{diagram-3B7GL73J-DWH5WS2P.js → diagram-3B7GL73J-ESCBJM3O.js} +1 -1
  129. package/dist/graph/{diagram-DNEMPZML-TEGH2U5I.js → diagram-DNEMPZML-ZIBUSQZI.js} +1 -1
  130. package/dist/graph/{diagram-L3MUGCDN-X4MREUWR.js → diagram-L3MUGCDN-IGK62IPN.js} +1 -1
  131. package/dist/graph/{diagram-LA4NIPWU-NXT746HG.js → diagram-LA4NIPWU-2KZCOFJ5.js} +1 -1
  132. package/dist/graph/{diagram-MHCOC4E2-JGHXSAGS.js → diagram-MHCOC4E2-EYAAB236.js} +1 -1
  133. package/dist/graph/{diagram-XPFHEONP-ZHZPBLT4.js → diagram-XPFHEONP-OZ5ARGMG.js} +1 -1
  134. package/dist/graph/{ebnfDiagram-UZSYDL2S-SMF6KJ43.js → ebnfDiagram-UZSYDL2S-M3XJHARD.js} +1 -1
  135. package/dist/graph/{erDiagram-EYBAPDEH-B3JNJ357.js → erDiagram-EYBAPDEH-Y7KUBH7A.js} +1 -1
  136. package/dist/graph/{eventmodeling-K75KTNOO-WG6DDYMC.js → eventmodeling-K75KTNOO-ROLYRDEP.js} +1 -1
  137. package/dist/graph/flowDiagram-MALGAFMO-AAUEIPCR.js +1 -0
  138. package/dist/graph/{ganttDiagram-23REXITY-YXBYWFOJ.js → ganttDiagram-23REXITY-JSBTFSSJ.js} +1 -1
  139. package/dist/graph/{gitGraph-VSP46ZUC-VBFWJBBT.js → gitGraph-VSP46ZUC-ZCBCDVNF.js} +1 -1
  140. package/dist/graph/{gitGraphDiagram-STJD7YCW-4FZDCFGV.js → gitGraphDiagram-STJD7YCW-3ZA5FT3G.js} +1 -1
  141. package/dist/graph/{info-OHQRW6UA-ALVDUVYV.js → info-OHQRW6UA-JKJGOQNY.js} +1 -1
  142. package/dist/graph/infoDiagram-KBXO4MBG-6LFMPP2O.js +2 -0
  143. package/dist/graph/{ishikawaDiagram-M35NCXHK-FRZD2PWQ.js → ishikawaDiagram-M35NCXHK-YLEU44DY.js} +1 -1
  144. package/dist/graph/{journeyDiagram-OPLOXDXO-7Z66JCPR.js → journeyDiagram-OPLOXDXO-ZHJV66ZT.js} +1 -1
  145. package/dist/graph/{kanban-definition-BZKZHSQY-NN5AIKTE.js → kanban-definition-BZKZHSQY-SDU25WUM.js} +1 -1
  146. package/dist/graph/{katex-DXDNVO6V.js → katex-WSLZOTY7.js} +1 -1
  147. package/dist/graph/{mindmap-definition-I2QAS2VK-HDPCABN2.js → mindmap-definition-I2QAS2VK-XQNBCYHN.js} +1 -1
  148. package/dist/graph/{packet-JDAUHWVQ-5MQIBWAH.js → packet-JDAUHWVQ-Y3H77ERD.js} +1 -1
  149. package/dist/graph/{pegDiagram-FD4XPPHP-H2BFNCKT.js → pegDiagram-FD4XPPHP-YO4VWH6V.js} +1 -1
  150. package/dist/graph/{pie-XZMESJXO-T5VRKHVT.js → pie-XZMESJXO-PRER4XL5.js} +1 -1
  151. package/dist/graph/{pieDiagram-J4AKIIQI-O3NJSVD3.js → pieDiagram-J4AKIIQI-TJ5WOOSV.js} +1 -1
  152. package/dist/graph/{quadrantDiagram-XTYBLID2-TMTZJI3P.js → quadrantDiagram-XTYBLID2-G6MSSZLW.js} +1 -1
  153. package/dist/graph/{radar-ABXABTNO-C6FXIBYW.js → radar-ABXABTNO-M6MV34GM.js} +1 -1
  154. package/dist/graph/{railroad-I3PHUGI6-ZSO5JXB3.js → railroad-I3PHUGI6-YIWPGN6Q.js} +1 -1
  155. package/dist/graph/{railroad-abnf-LNEFI6M7-CI4GQRHB.js → railroad-abnf-LNEFI6M7-7JHLZ2R7.js} +1 -1
  156. package/dist/graph/{railroad-ebnf-DWYD2UWJ-MUENNCGK.js → railroad-ebnf-DWYD2UWJ-V55BXEWY.js} +1 -1
  157. package/dist/graph/{railroad-peg-JR7BVNR7-N3X5GGIX.js → railroad-peg-JR7BVNR7-XCGKDRMK.js} +1 -1
  158. package/dist/graph/{railroadDiagram-MRQ6NCDL-JHWS23UO.js → railroadDiagram-MRQ6NCDL-RACSFXC4.js} +1 -1
  159. package/dist/graph/{requirementDiagram-Y7LWUY3S-7DVLPO4B.js → requirementDiagram-Y7LWUY3S-4LQIQWHQ.js} +1 -1
  160. package/dist/graph/{sankeyDiagram-WGJFYUXA-Z5L4R5TR.js → sankeyDiagram-WGJFYUXA-K3RXG5FB.js} +1 -1
  161. package/dist/graph/schema-graph-global.js +17 -17
  162. package/dist/graph/{sequenceDiagram-5NDRBG5M-RCTU25NT.js → sequenceDiagram-5NDRBG5M-Y6RBHRS3.js} +1 -1
  163. package/dist/graph/{sizeCapture-INFHLROL-RROY32P5.js → sizeCapture-INFHLROL-TJW3VUGH.js} +1 -1
  164. package/dist/graph/{stateDiagram-v2-FJ4FJNEA-BXUSPWDK.js → stateDiagram-v2-FJ4FJNEA-4M5WZORG.js} +1 -1
  165. package/dist/graph/swimlanes-UMQ2AFYF-O4W6U4RO.js +1 -0
  166. package/dist/graph/swimlanesDiagram-OMPLPG4O-HZAKM45N.js +8 -0
  167. package/dist/graph/{timeline-definition-SEUHKTQE-ZQSMIVAS.js → timeline-definition-SEUHKTQE-IHISQ4Q7.js} +1 -1
  168. package/dist/graph/{treeView-D4JQ5SDB-42S7U73N.js → treeView-D4JQ5SDB-EVGY4VYS.js} +1 -1
  169. package/dist/graph/{treemap-SAJKECNS-RUBYQ7XF.js → treemap-SAJKECNS-LN3SMFRX.js} +1 -1
  170. package/dist/graph/{usecaseDiagram-AFA6YXN4-57RDRYXF.js → usecaseDiagram-AFA6YXN4-B645A3J6.js} +1 -1
  171. package/dist/graph/{vennDiagram-NNMJR3RB-5C3LVAV6.js → vennDiagram-NNMJR3RB-K3HWMON6.js} +1 -1
  172. package/dist/graph/{wardley-7MLQ67FV-NV5HXTTC.js → wardley-7MLQ67FV-RRWOELC6.js} +1 -1
  173. package/dist/graph/{wardleyDiagram-S7YFUSEH-6D5BKXHM.js → wardleyDiagram-S7YFUSEH-DMMWKJEK.js} +1 -1
  174. package/dist/graph/{xychartDiagram-GGNKY7IX-6ET3ZM67.js → xychartDiagram-GGNKY7IX-K6MUQVXR.js} +1 -1
  175. package/dist/install.sh +68 -0
  176. package/dist/plugins.global.js +62 -62
  177. package/dist/{viewer → server}/assets.d.ts +2 -0
  178. package/dist/server/assets.js +7 -0
  179. package/dist/{viewer → server}/build-plugins.js +4 -4
  180. package/dist/{viewer → server}/build.d.ts +2 -1
  181. package/dist/{viewer → server}/build.js +31 -15
  182. package/dist/{cli.js → server/cli.js} +223 -56
  183. package/dist/server/editor-tools.d.ts +1 -0
  184. package/dist/server/editor-tools.js +1 -0
  185. package/dist/{viewer → server}/extension-pack.js +2 -2
  186. package/dist/{viewer → server}/extensions.d.ts +1 -1
  187. package/dist/{viewer → server}/extensions.js +3 -3
  188. package/dist/server/git-diff.d.ts +10 -0
  189. package/dist/{viewer → server}/git-diff.js +45 -10
  190. package/dist/server/git-origin.d.ts +4 -0
  191. package/dist/server/git-origin.js +103 -0
  192. package/dist/server/git.d.ts +9 -0
  193. package/dist/{viewer → server}/git.js +50 -6
  194. package/dist/server/history.d.ts +14 -0
  195. package/dist/server/history.js +205 -0
  196. package/dist/{viewer → server}/hmr.d.ts +0 -22
  197. package/dist/server/hmr.js +168 -0
  198. package/dist/server/index.d.ts +17 -0
  199. package/dist/{index.js → server/index.js} +16 -16
  200. package/dist/{viewer → server}/ja-lint.d.ts +1 -1
  201. package/dist/{viewer → server}/languages.d.ts +1 -1
  202. package/dist/{viewer → server}/languages.js +3 -3
  203. package/dist/{mcp.d.ts → server/mcp.d.ts} +2 -2
  204. package/dist/{mcp.js → server/mcp.js} +60 -21
  205. package/dist/{viewer → server}/plugin-config.d.ts +2 -2
  206. package/dist/{viewer → server}/plugin-config.js +2 -2
  207. package/dist/{plugins → server/plugins}/local-storage.d.ts +1 -1
  208. package/dist/{plugins → server/plugins}/local-storage.js +1 -1
  209. package/dist/{plugins → server/plugins}/runtime.d.ts +4 -4
  210. package/dist/{plugins → server/plugins}/runtime.js +4 -4
  211. package/dist/{viewer → server}/plugins.d.ts +3 -3
  212. package/dist/{viewer → server}/plugins.js +14 -13
  213. package/dist/server/resource-library.d.ts +1 -0
  214. package/dist/server/resource-library.js +1 -0
  215. package/dist/server/self.d.ts +5 -0
  216. package/dist/server/self.js +98 -0
  217. package/dist/server/serve.d.ts +61 -0
  218. package/dist/server/serve.js +503 -0
  219. package/dist/server/static-client.d.ts +4 -0
  220. package/dist/server/static-client.js +117 -0
  221. package/dist/server/workspace-server.d.ts +16 -0
  222. package/dist/server/workspace-server.js +266 -0
  223. package/dist/{viewer → server}/workspace.d.ts +6 -1
  224. package/dist/{viewer → server}/workspace.js +46 -0
  225. package/dist/subformats.global.js +92 -6
  226. package/dist/ui.global.js +85 -72
  227. package/dist/workspace/client.d.ts +13 -0
  228. package/dist/workspace/client.js +114 -0
  229. package/dist/{viewer → workspace}/code-file.d.ts +1 -1
  230. package/dist/{viewer → workspace}/code-file.js +7 -7
  231. package/dist/workspace/connection.d.ts +27 -0
  232. package/dist/workspace/connection.js +38 -0
  233. package/dist/{viewer → workspace}/editor-tools.d.ts +7 -1
  234. package/dist/{viewer → workspace}/editor-tools.js +12 -9
  235. package/dist/{viewer → workspace}/git-types.d.ts +7 -0
  236. package/dist/workspace/github.d.ts +4 -0
  237. package/dist/workspace/github.js +99 -0
  238. package/dist/workspace/history.d.ts +46 -0
  239. package/dist/workspace/history.js +86 -0
  240. package/dist/workspace/protocol.d.ts +38 -0
  241. package/dist/workspace/protocol.js +20 -0
  242. package/dist/workspace/resource-download.d.ts +1 -0
  243. package/dist/workspace/resource-download.js +8 -0
  244. package/dist/workspace/server.d.ts +9 -0
  245. package/dist/workspace/server.js +48 -0
  246. package/dist/{viewer → workspace}/site-icon.js +9 -10
  247. package/dist/{viewer → workspace}/site-title.js +6 -7
  248. package/dist/{viewer → workspace}/textfile.d.ts +1 -1
  249. package/dist/{viewer → workspace}/textfile.js +5 -5
  250. package/dist/workspace-worker.global.js +2859 -0
  251. package/package.json +43 -21
  252. package/dist/compiler/manifest.js +0 -37
  253. package/dist/compiler/serialize.d.ts +0 -3
  254. package/dist/compiler/serialize.js +0 -16
  255. package/dist/core/icons.js +0 -5
  256. package/dist/graph/chunk-3RNHDNP5.js +0 -1
  257. package/dist/graph/chunk-5UUEAHTN.js +0 -1
  258. package/dist/graph/chunk-6T55RVVR.js +0 -1
  259. package/dist/graph/elk-XV6XMXQE-AZ4HLCWI.js +0 -27
  260. package/dist/graph/flowDiagram-MALGAFMO-2R7EYAQI.js +0 -1
  261. package/dist/graph/infoDiagram-KBXO4MBG-7EHX2GQG.js +0 -2
  262. package/dist/graph/swimlanes-UMQ2AFYF-LDD74Q2S.js +0 -1
  263. package/dist/graph/swimlanesDiagram-OMPLPG4O-ZYULLJSU.js +0 -8
  264. package/dist/index.d.ts +0 -17
  265. package/dist/viewer/assets.js +0 -3
  266. package/dist/viewer/figure-preview.d.ts +0 -4
  267. package/dist/viewer/git-diff.d.ts +0 -6
  268. package/dist/viewer/git.d.ts +0 -5
  269. package/dist/viewer/hmr.js +0 -341
  270. package/dist/viewer/serve.d.ts +0 -216
  271. /package/dist/{compiler → engine/compiler}/asset-references.d.ts +0 -0
  272. /package/dist/{compiler → engine/compiler}/asset-references.js +0 -0
  273. /package/dist/{compiler → engine/compiler}/bundle-urls.d.ts +0 -0
  274. /package/dist/{compiler → engine/compiler}/check-types.d.ts +0 -0
  275. /package/dist/{compiler → engine/compiler}/check-types.js +0 -0
  276. /package/dist/{compiler → engine/compiler}/check.d.ts +0 -0
  277. /package/dist/{compiler → engine/compiler}/code-blocks.d.ts +0 -0
  278. /package/dist/{compiler → engine/compiler}/code-languages.d.ts +0 -0
  279. /package/dist/{compiler → engine/compiler}/config.d.ts +0 -0
  280. /package/dist/{compiler → engine/compiler}/drawio.d.ts +0 -0
  281. /package/dist/{compiler → engine/compiler}/drawio.js +0 -0
  282. /package/dist/{compiler → engine/compiler}/dxf.d.ts +0 -0
  283. /package/dist/{compiler → engine/compiler}/export.d.ts +0 -0
  284. /package/dist/{compiler → engine/compiler}/figures.d.ts +0 -0
  285. /package/dist/{compiler → engine/compiler}/files.d.ts +0 -0
  286. /package/dist/{compiler → engine/compiler}/fonts.d.ts +0 -0
  287. /package/dist/{compiler → engine/compiler}/format.d.ts +0 -0
  288. /package/dist/{compiler → engine/compiler}/format.js +0 -0
  289. /package/dist/{compiler → engine/compiler}/from-mdast.d.ts +0 -0
  290. /package/dist/{compiler → engine/compiler}/language-codes.d.ts +0 -0
  291. /package/dist/{compiler → engine/compiler}/language-codes.js +0 -0
  292. /package/dist/{compiler → engine/compiler}/locales.d.ts +0 -0
  293. /package/dist/{compiler → engine/compiler}/public-file.d.ts +0 -0
  294. /package/dist/{compiler → engine/compiler}/public-file.js +0 -0
  295. /package/dist/{compiler → engine/compiler}/subformat-schema.d.ts +0 -0
  296. /package/dist/{compiler → engine/compiler}/terms.d.ts +0 -0
  297. /package/dist/{compiler → engine/compiler}/terms.js +0 -0
  298. /package/dist/{compiler → engine/compiler}/textfile-remote.d.ts +0 -0
  299. /package/dist/{compiler → engine/compiler}/textfile.d.ts +0 -0
  300. /package/dist/{compiler → engine/compiler}/theme-variants.d.ts +0 -0
  301. /package/dist/{compiler → engine/compiler}/zip.d.ts +0 -0
  302. /package/dist/{core → engine/core}/blocks.js +0 -0
  303. /package/dist/{core → engine/core}/code-file.d.ts +0 -0
  304. /package/dist/{core → engine/core}/code-file.js +0 -0
  305. /package/dist/{core → engine/core}/code-grammars.d.ts +0 -0
  306. /package/dist/{core → engine/core}/code-grammars.js +0 -0
  307. /package/dist/{core → engine/core}/content-types.js +0 -0
  308. /package/dist/{core → engine/core}/escape-html.d.ts +0 -0
  309. /package/dist/{core → engine/core}/escape-html.js +0 -0
  310. /package/dist/{core → engine/core}/extension-package.d.ts +0 -0
  311. /package/dist/{core → engine/core}/extension-package.js +0 -0
  312. /package/dist/{core → engine/core}/figure-frame.d.ts +0 -0
  313. /package/dist/{core → engine/core}/figure-frame.js +0 -0
  314. /package/dist/{core → engine/core}/file-embed.d.ts +0 -0
  315. /package/dist/{core → engine/core}/file-embed.js +0 -0
  316. /package/dist/{core → engine/core}/files.d.ts +0 -0
  317. /package/dist/{core → engine/core}/files.js +0 -0
  318. /package/dist/{core → engine/core}/graph-common.d.ts +0 -0
  319. /package/dist/{core → engine/core}/graph-common.js +0 -0
  320. /package/dist/{core → engine/core}/graph.d.ts +0 -0
  321. /package/dist/{core → engine/core}/graph.js +0 -0
  322. /package/dist/{core → engine/core}/inline.d.ts +0 -0
  323. /package/dist/{core → engine/core}/inline.js +0 -0
  324. /package/dist/{core → engine/core}/json-tools.d.ts +0 -0
  325. /package/dist/{core → engine/core}/json-tools.js +0 -0
  326. /package/dist/{core → engine/core}/language.d.ts +0 -0
  327. /package/dist/{core → engine/core}/language.js +0 -0
  328. /package/dist/{core → engine/core}/languages/ja.d.ts +0 -0
  329. /package/dist/{core → engine/core}/languages/ja.js +0 -0
  330. /package/dist/{core → engine/core}/markdown.d.ts +0 -0
  331. /package/dist/{core → engine/core}/markdown.js +0 -0
  332. /package/dist/{core → engine/core}/previewers.d.ts +0 -0
  333. /package/dist/{core → engine/core}/previewers.js +0 -0
  334. /package/dist/{core → engine/core}/schema-comments.d.ts +0 -0
  335. /package/dist/{core → engine/core}/schema-comments.js +0 -0
  336. /package/dist/{core → engine/core}/schema-fields.d.ts +0 -0
  337. /package/dist/{core → engine/core}/schema-fields.js +0 -0
  338. /package/dist/{core → engine/core}/schema-graph.d.ts +0 -0
  339. /package/dist/{core → engine/core}/schema-graph.js +0 -0
  340. /package/dist/{core → engine/core}/subformat-record.d.ts +0 -0
  341. /package/dist/{core → engine/core}/subformat-record.js +0 -0
  342. /package/dist/{core → engine/core}/term-reference.d.ts +0 -0
  343. /package/dist/{core → engine/core}/term-reference.js +0 -0
  344. /package/dist/{core → engine/core}/textfile.d.ts +0 -0
  345. /package/dist/{core → engine/core}/textfile.js +0 -0
  346. /package/dist/{core → engine/core}/theme-variants.d.ts +0 -0
  347. /package/dist/{core → engine/core}/theme-variants.js +0 -0
  348. /package/dist/{core → engine/core}/workspace.d.ts +0 -0
  349. /package/dist/{core → engine/core}/workspace.js +0 -0
  350. /package/dist/{viewer → frontend}/bundle-network.d.ts +0 -0
  351. /package/dist/{viewer → frontend}/bundle-network.js +0 -0
  352. /package/dist/{core → frontend}/flow-base-css.generated.d.ts +0 -0
  353. /package/dist/{core → frontend}/flow-base-css.generated.js +0 -0
  354. /package/dist/{core → frontend}/flow-css.d.ts +0 -0
  355. /package/dist/{core → frontend}/flow-css.js +0 -0
  356. /package/dist/{viewer → frontend}/font-picker.js +0 -0
  357. /package/dist/{viewer → frontend}/font-settings.js +0 -0
  358. /package/dist/{viewer → frontend}/i18n.d.ts +0 -0
  359. /package/dist/{viewer → frontend}/i18n.js +0 -0
  360. /package/dist/{viewer → frontend}/language-picker.d.ts +0 -0
  361. /package/dist/{viewer → frontend}/lazy-preview.d.ts +0 -0
  362. /package/dist/{viewer → frontend}/lazy-preview.js +0 -0
  363. /package/dist/{viewer → frontend}/nav-focus.d.ts +0 -0
  364. /package/dist/{viewer → frontend}/nav-update.d.ts +0 -0
  365. /package/dist/{viewer → frontend}/nav-update.js +0 -0
  366. /package/dist/{viewer → frontend}/plugin-blocks.d.ts +0 -0
  367. /package/dist/{viewer → frontend}/plugin-style.d.ts +0 -0
  368. /package/dist/{viewer → frontend}/plugin-style.js +0 -0
  369. /package/dist/{viewer → frontend}/plugin-view.d.ts +0 -0
  370. /package/dist/{viewer → frontend}/plugin-view.js +0 -0
  371. /package/dist/{viewer → frontend}/resize.d.ts +0 -0
  372. /package/dist/{core → frontend}/schema-graph-mount.d.ts +0 -0
  373. /package/dist/{core → frontend}/schema-graph-mount.js +0 -0
  374. /package/dist/{core → frontend}/table-ui.d.ts +0 -0
  375. /package/dist/{core → frontend}/table-ui.js +0 -0
  376. /package/dist/{core → frontend}/terms-ui.d.ts +0 -0
  377. /package/dist/{core → frontend}/terms-ui.js +0 -0
  378. /package/dist/{viewer → frontend}/theme-picker.d.ts +0 -0
  379. /package/dist/{viewer → frontend}/theme-picker.js +0 -0
  380. /package/dist/{core → frontend}/toc-ui.d.ts +0 -0
  381. /package/dist/{core → frontend}/toc-ui.js +0 -0
  382. /package/dist/{core → frontend}/video-ui.d.ts +0 -0
  383. /package/dist/{core → frontend}/video-ui.js +0 -0
  384. /package/dist/graph/{chunk-GYT4IYBZ.js → chunk-RJFVWYCA.js} +0 -0
  385. /package/dist/{viewer → server}/build-plugins.d.ts +0 -0
  386. /package/dist/{cli.d.ts → server/cli.d.ts} +0 -0
  387. /package/dist/{viewer → server}/extension-pack.d.ts +0 -0
  388. /package/dist/{viewer → server}/fonts/LICENSE.txt +0 -0
  389. /package/dist/{viewer → server}/fonts/udev-gothic-regular.woff2 +0 -0
  390. /package/dist/{viewer → server}/fonts.d.ts +0 -0
  391. /package/dist/{viewer → server}/fonts.js +0 -0
  392. /package/dist/{viewer → server}/ja-lint.js +0 -0
  393. /package/dist/{viewer → workspace}/git-types.js +0 -0
  394. /package/dist/{viewer → workspace}/site-icon.d.ts +0 -0
  395. /package/dist/{viewer → workspace}/site-title.d.ts +0 -0
@@ -0,0 +1,13 @@
1
+ import { type WorkspacePort } from "./protocol.js";
2
+ export interface WorkspaceClient {
3
+ request<T = unknown>(op: string, args?: Record<string, unknown>): Promise<T>;
4
+ /** Returns the function that stops listening. */
5
+ on(event: string, handler: (data: unknown) => void): () => void;
6
+ /** Runs on every (re)connection; right away on a channel that is always connected. */
7
+ opened(handler: () => void): void;
8
+ }
9
+ export declare const createWorkspaceClient: (port: WorkspacePort) => WorkspaceClient;
10
+ /** JSON over a WebSocket that is kept open: a dropped connection is retried until it returns. */
11
+ export declare const webSocketPort: (url: string) => WorkspacePort;
12
+ /** The workspace this page was served from. */
13
+ export declare const pageWorkspace: (id?: string) => WorkspaceClient;
@@ -0,0 +1,114 @@
1
+ // Browser side of the workspace protocol. The UI calls request()/on() and never learns whether
2
+ // the server is behind a WebSocket or in a Worker.
3
+ import { workspaceConnection } from "./connection.js";
4
+ import { WORKSPACE_PATH } from "./protocol.js";
5
+ export const createWorkspaceClient = (port) => {
6
+ let next = 0;
7
+ const pending = new Map();
8
+ const listeners = new Map();
9
+ port.receive((message) => {
10
+ if (typeof message !== "object" || message === null)
11
+ return;
12
+ const { id, value, error, event, data } = message;
13
+ if (typeof event === "string") {
14
+ for (const handler of listeners.get(event) ?? [])
15
+ handler(data);
16
+ return;
17
+ }
18
+ const request = typeof id === "number" ? pending.get(id) : undefined;
19
+ if (!request)
20
+ return;
21
+ pending.delete(id);
22
+ if (typeof error === "string")
23
+ request.reject(new Error(error));
24
+ else
25
+ request.resolve(value);
26
+ });
27
+ port.closed?.(() => {
28
+ for (const request of pending.values())
29
+ request.reject(new Error("Workspace connection closed"));
30
+ pending.clear();
31
+ });
32
+ return {
33
+ request: (op, args) => new Promise((resolve, reject) => {
34
+ const id = ++next;
35
+ pending.set(id, { resolve: resolve, reject });
36
+ try {
37
+ port.send({ id, op, args });
38
+ }
39
+ catch (error) {
40
+ pending.delete(id);
41
+ reject(error instanceof Error ? error : new Error(String(error)));
42
+ }
43
+ }),
44
+ on(event, handler) {
45
+ const set = listeners.get(event) ?? new Set();
46
+ listeners.set(event, set);
47
+ set.add(handler);
48
+ return () => set.delete(handler);
49
+ },
50
+ opened(handler) {
51
+ if (port.opened)
52
+ port.opened(handler);
53
+ else
54
+ handler();
55
+ },
56
+ };
57
+ };
58
+ /** JSON over a WebSocket that is kept open: a dropped connection is retried until it returns. */
59
+ export const webSocketPort = (url) => {
60
+ let receive = () => { };
61
+ let closed = () => { };
62
+ let opened = () => { };
63
+ let socket;
64
+ const connect = () => {
65
+ const current = new WebSocket(url);
66
+ socket = current;
67
+ current.addEventListener("open", () => opened());
68
+ current.addEventListener("message", (event) => {
69
+ if (typeof event.data === "string")
70
+ receive(JSON.parse(event.data));
71
+ });
72
+ current.addEventListener("close", () => {
73
+ closed();
74
+ // Short, so a restarted dev server is noticed quickly.
75
+ setTimeout(connect, 300);
76
+ });
77
+ };
78
+ connect();
79
+ return {
80
+ send(message) {
81
+ const text = JSON.stringify(message);
82
+ const current = socket;
83
+ if (current.readyState === WebSocket.OPEN)
84
+ current.send(text);
85
+ // If this connection fails instead, `closed` rejects the request that was waiting.
86
+ else if (current.readyState === WebSocket.CONNECTING)
87
+ current.addEventListener("open", () => current.send(text), { once: true });
88
+ else
89
+ throw new Error("Workspace connection closed");
90
+ },
91
+ receive(handler) {
92
+ receive = handler;
93
+ },
94
+ closed(handler) {
95
+ closed = handler;
96
+ },
97
+ opened(handler) {
98
+ opened = handler;
99
+ if (socket.readyState === WebSocket.OPEN)
100
+ handler();
101
+ },
102
+ };
103
+ };
104
+ let page;
105
+ /** The workspace this page was served from. */
106
+ export const pageWorkspace = (id) => {
107
+ const connection = workspaceConnection(id);
108
+ if (connection)
109
+ return connection.client;
110
+ if (id && id !== "local")
111
+ throw new Error("Workspace is not open");
112
+ page ??= createWorkspaceClient(webSocketPort(`${location.protocol === "https:" ? "wss" : "ws"}://${location.host}${WORKSPACE_PATH}`));
113
+ return page;
114
+ };
@@ -1,4 +1,4 @@
1
- import type { PreviewSettings } from "../core/previewers.js";
1
+ import type { PreviewSettings } from "../engine/core/previewers.js";
2
2
  export declare const codeFileResponse: (root: string, input: Record<string, unknown> | undefined, previews?: PreviewSettings) => {
3
3
  status: number;
4
4
  body: {
@@ -1,10 +1,10 @@
1
- import { existsSync } from "node:fs";
2
- import { readManifest } from "../compiler/manifest.js";
3
- import { validateSubformatFile } from "../compiler/subformats.js";
4
- import { textfilePath, writeTextfile } from "../compiler/textfile.js";
5
- import { codeFileName, codeFilePlan } from "../core/code-file.js";
6
- import { isDocId } from "../core/content-metadata.js";
7
- import { defaultFilePath } from "../core/files.js";
1
+ import { existsSync } from "../engine/compiler/host.js";
2
+ import { readManifest } from "../engine/compiler/manifest.js";
3
+ import { validateSubformatFile } from "../engine/compiler/subformats.js";
4
+ import { textfilePath, writeTextfile } from "../engine/compiler/textfile.js";
5
+ import { codeFileName, codeFilePlan } from "../engine/core/code-file.js";
6
+ import { isDocId } from "../engine/core/content-metadata.js";
7
+ import { defaultFilePath } from "../engine/core/files.js";
8
8
  export const codeFileResponse = (root, input, previews) => {
9
9
  if (typeof input?.body !== "string" || typeof input.position !== "number")
10
10
  return { status: 400, body: { error: "Invalid code file request" } };
@@ -0,0 +1,27 @@
1
+ import type { WorkspaceClient } from "./client.js";
2
+ export interface WorkspaceConnection {
3
+ id: string;
4
+ label: string;
5
+ family?: string;
6
+ branch?: string;
7
+ readonly branches?: readonly string[];
8
+ client: WorkspaceClient;
9
+ fetch(input: string | URL, init?: RequestInit): Promise<Response>;
10
+ openBranch?(branch: string, create?: boolean): Promise<WorkspaceConnection>;
11
+ close?(): void;
12
+ }
13
+ declare global {
14
+ var __doocConnections: {
15
+ active: string;
16
+ items: Map<string, WorkspaceConnection>;
17
+ } | undefined;
18
+ }
19
+ export declare const workspaceId: () => string;
20
+ export declare const workspaceConnections: () => WorkspaceConnection[];
21
+ export declare const workspaceConnection: (id?: string) => WorkspaceConnection | undefined;
22
+ export declare const registerWorkspace: (connection: WorkspaceConnection) => void;
23
+ /** Reuse the branch's storage and drafts, including local folders that are never saved in the chooser. */
24
+ export declare const openBranchWorkspace: (family: string, branch: string, create: boolean, open: () => Promise<WorkspaceConnection>) => Promise<WorkspaceConnection>;
25
+ export declare const selectWorkspace: (id: string) => void;
26
+ /** Self-contained because the page renderer also embeds this in inline event handlers. */
27
+ export declare function workspaceFetch(input: string | URL, init?: RequestInit, id?: string): Promise<Response>;
@@ -0,0 +1,38 @@
1
+ const connections = () => (globalThis.__doocConnections ??= { active: "local", items: new Map() });
2
+ export const workspaceId = () => connections().active;
3
+ export const workspaceConnections = () => [...connections().items.values()];
4
+ export const workspaceConnection = (id = workspaceId()) => connections().items.get(id);
5
+ export const registerWorkspace = (connection) => {
6
+ if (connections().items.has(connection.id))
7
+ throw new Error("Workspace is already open");
8
+ connections().items.set(connection.id, connection);
9
+ };
10
+ const openingBranches = new Map();
11
+ /** Reuse the branch's storage and drafts, including local folders that are never saved in the chooser. */
12
+ export const openBranchWorkspace = async (family, branch, create, open) => {
13
+ const existing = workspaceConnections().find((connection) => connection.family === family && connection.branch === branch);
14
+ const key = JSON.stringify([family, branch]);
15
+ const pending = openingBranches.get(key);
16
+ if (create && (existing || pending))
17
+ throw new Error("Branch already has a workspace");
18
+ if (existing)
19
+ return existing;
20
+ if (pending)
21
+ return pending;
22
+ const next = Promise.resolve()
23
+ .then(open)
24
+ .finally(() => openingBranches.delete(key));
25
+ openingBranches.set(key, next);
26
+ return next;
27
+ };
28
+ export const selectWorkspace = (id) => {
29
+ if (id !== "local" && !connections().items.has(id))
30
+ throw new Error("Workspace is not open");
31
+ connections().active = id;
32
+ };
33
+ /** Self-contained because the page renderer also embeds this in inline event handlers. */
34
+ export function workspaceFetch(input, init, id) {
35
+ const state = globalThis.__doocConnections;
36
+ const connection = state?.items.get(id ?? state.active);
37
+ return connection ? connection.fetch(input, init) : fetch(input, init);
38
+ }
@@ -1,4 +1,10 @@
1
- export { codeBlockAt } from "../core/markdown.js";
1
+ export { codeBlockAt } from "../engine/core/markdown.js";
2
+ /** A loopback Host header; a rebound DNS name fails this even though it reaches the socket. */
3
+ export declare const isLocalHost: (host: string) => boolean;
4
+ /** The scheme the browser used to reach this listener (TLS sockets are marked `encrypted`). */
5
+ export declare const requestScheme: (req: {
6
+ socket: object;
7
+ }) => "http" | "https";
2
8
  export declare function isLocalToolRequest(host: string, origin: string | undefined, contentType: string | undefined): boolean;
3
9
  export declare function runCodeTool(root: string, body: string, position: number, action: "format" | "lint"): Promise<{
4
10
  findings: {
@@ -1,14 +1,17 @@
1
- import { execFile } from "node:child_process";
2
- import { readFile } from "node:fs/promises";
3
- import { join } from "node:path";
4
1
  import { visit } from "unist-util-visit";
5
- import { formatJson } from "../core/json-tools.js";
6
- import { codeBlockAt, offsetAt, parseMdast } from "../core/markdown.js";
7
- export { codeBlockAt } from "../core/markdown.js";
8
- import { formatMarkdown } from "../compiler/format.js";
2
+ import { execFile, join, readFile } from "../engine/compiler/host.js";
3
+ import { formatJson } from "../engine/core/json-tools.js";
4
+ import { codeBlockAt, offsetAt, parseMdast } from "../engine/core/markdown.js";
5
+ export { codeBlockAt } from "../engine/core/markdown.js";
6
+ import { formatMarkdown } from "../engine/compiler/format.js";
7
+ /** A loopback Host header; a rebound DNS name fails this even though it reaches the socket. */
8
+ export const isLocalHost = (host) => ["localhost", "127.0.0.1", "[::1]"].includes(host.replace(/:\d+$/, ""));
9
+ /** The scheme the browser used to reach this listener (TLS sockets are marked `encrypted`). */
10
+ export const requestScheme = (req) => "encrypted" in req.socket && req.socket.encrypted ? "https" : "http";
9
11
  export function isLocalToolRequest(host, origin, contentType) {
10
- return (["localhost", "127.0.0.1", "[::1]"].includes(host.replace(/:\d+$/, "")) &&
11
- origin === `http://${host}` &&
12
+ return (isLocalHost(host) &&
13
+ // The page and this server share one listener, so either scheme means same origin.
14
+ (origin === `http://${host}` || origin === `https://${host}`) &&
12
15
  contentType?.split(";")[0]?.trim() === "application/json");
13
16
  }
14
17
  function command(value) {
@@ -13,6 +13,7 @@ export interface GitPullRequest {
13
13
  headCommit: string;
14
14
  draft: boolean;
15
15
  status: string;
16
+ state?: "open" | "closed" | "merged";
16
17
  }
17
18
  export interface GitOriginState {
18
19
  url: string;
@@ -57,7 +58,13 @@ export interface GitState {
57
58
  head: string;
58
59
  version: string;
59
60
  branches: string[];
61
+ branchWorkspaces?: {
62
+ manifest: string;
63
+ unavailable: string[];
64
+ canCreate: boolean;
65
+ };
60
66
  changes: GitChange[];
67
+ localCapabilities?: string[];
61
68
  stash?: {
62
69
  id: string;
63
70
  label: string;
@@ -0,0 +1,4 @@
1
+ import type { GitContext, GitOrigin } from "./git-types.js";
2
+ export declare const githubRepository: (url: string) => string | undefined;
3
+ export declare const createGithubOrigin: (repository: string, request: <T>(path: string, method?: string, body?: unknown) => Promise<T>, sync: (action: "fetch" | "pull" | "push", context: GitContext) => Promise<void>) => GitOrigin;
4
+ export declare const githubFetch: (token: () => string | undefined) => <T>(path: string, method?: string, body?: unknown) => Promise<T>;
@@ -0,0 +1,99 @@
1
+ export const githubRepository = (url) => /^(?:https:\/\/github\.com\/|git@github\.com:)([\w.-]+\/[\w.-]+?)(?:\.git)?\/?$/.exec(url)?.[1];
2
+ const pullRequest = (pr) => ({
3
+ number: pr.number,
4
+ title: pr.title,
5
+ body: pr.body ?? "",
6
+ url: pr.html_url,
7
+ head: pr.head.ref,
8
+ headCommit: pr.head.sha,
9
+ base: pr.base.ref,
10
+ draft: pr.draft,
11
+ status: [
12
+ pr.merged_at ? "Merged" : pr.state === "closed" ? "Closed" : "Open",
13
+ pr.mergeable_state,
14
+ ]
15
+ .filter(Boolean)
16
+ .join(" · "),
17
+ state: pr.merged_at ? "merged" : pr.state === "closed" ? "closed" : "open",
18
+ });
19
+ export const createGithubOrigin = (repository, request, sync) => {
20
+ if (!/^[\w.-]+\/[\w.-]+$/.test(repository))
21
+ throw new Error("Invalid GitHub repository");
22
+ const prefix = `repos/${repository}`;
23
+ return {
24
+ name: "GitHub",
25
+ capabilities: ["fetch", "pull", "push", "createPr", "updatePr", "mergePr"],
26
+ async read() {
27
+ const info = await request(prefix);
28
+ const pullRequests = [];
29
+ for (let page = 1;; page++) {
30
+ const items = await request(`${prefix}/pulls?state=all&sort=updated&direction=desc&per_page=100&page=${page}`);
31
+ pullRequests.push(...items.map(pullRequest));
32
+ if (items.length < 100)
33
+ break;
34
+ }
35
+ return { url: info.html_url, defaultBranch: info.default_branch, pullRequests };
36
+ },
37
+ async execute(context, input) {
38
+ if (input.action === "fetch" || input.action === "pull" || input.action === "push")
39
+ return sync(input.action, context);
40
+ if (input.action === "createPr") {
41
+ const remote = await request(`${prefix}/git/ref/heads/${encodeURIComponent(context.branch)}`);
42
+ if (remote.object.sha !== context.head)
43
+ throw new Error("Push this branch before creating a pull request");
44
+ await request(`${prefix}/pulls`, "POST", {
45
+ title: input.title,
46
+ body: input.body,
47
+ head: context.branch,
48
+ base: input.base,
49
+ draft: input.draft,
50
+ });
51
+ return;
52
+ }
53
+ if (input.action !== "updatePr" && input.action !== "mergePr")
54
+ throw new Error("Unsupported pull request operation");
55
+ const current = pullRequest(await request(`${prefix}/pulls/${input.number}`));
56
+ if (current.headCommit !== input.previous.headCommit ||
57
+ current.title !== input.previous.title ||
58
+ current.body !== input.previous.body ||
59
+ current.state !== "open")
60
+ throw new Error("Pull request changed. Reload before continuing.");
61
+ if (input.action === "updatePr")
62
+ await request(`${prefix}/pulls/${input.number}`, "PATCH", {
63
+ title: input.title,
64
+ body: input.body,
65
+ });
66
+ else {
67
+ if (current.draft)
68
+ throw new Error("Draft pull requests cannot be merged");
69
+ const result = await request(`${prefix}/pulls/${input.number}/merge`, "PUT", { sha: current.headCommit, merge_method: input.method });
70
+ if (!result.merged)
71
+ throw new Error(result.message || "Pull request could not be merged");
72
+ }
73
+ },
74
+ };
75
+ };
76
+ export const githubFetch = (token) => async (path, method = "GET", body) => {
77
+ if (!path.startsWith("repos/") || path.includes("..") || path.startsWith("//"))
78
+ throw new Error("Invalid GitHub API path");
79
+ const secret = token();
80
+ const response = await fetch(`https://api.github.com/${path}`, {
81
+ method,
82
+ credentials: "omit",
83
+ redirect: "error",
84
+ referrerPolicy: "no-referrer",
85
+ signal: AbortSignal.timeout(30000),
86
+ headers: {
87
+ accept: "application/vnd.github+json",
88
+ ...(secret ? { authorization: `Bearer ${secret}` } : {}),
89
+ ...(body === undefined ? {} : { "content-type": "application/json" }),
90
+ },
91
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
92
+ });
93
+ const result = await response.json();
94
+ if (!response.ok)
95
+ throw new Error(typeof result.message === "string"
96
+ ? result.message
97
+ : `GitHub request failed (${response.status})`);
98
+ return result;
99
+ };
@@ -0,0 +1,46 @@
1
+ export interface Person {
2
+ name: string;
3
+ email?: string;
4
+ }
5
+ export interface Snapshot {
6
+ id: string;
7
+ /** ISO 8601. */
8
+ time: string;
9
+ message: string;
10
+ author?: string;
11
+ /** Names of everyone else credited with edits in this snapshot. */
12
+ coAuthors?: string[];
13
+ }
14
+ export interface History {
15
+ /** Newest first. */
16
+ list(): Promise<Snapshot[]>;
17
+ /** Without an author the driver records its own default (Git's configured user). */
18
+ snapshot(message: string, by?: {
19
+ author?: Person;
20
+ coAuthors?: Person[];
21
+ }): Promise<Snapshot>;
22
+ /** Brings the files back to a snapshot without discarding anything recorded after it. */
23
+ restore(id: string): Promise<void>;
24
+ }
25
+ /** One line of display text, safe inside a Git author field or trailer. */
26
+ export declare const parsePerson: (input: Record<string, unknown>) => Person;
27
+ /**
28
+ * The `history` operation. Requests run one at a time so two snapshots never interleave.
29
+ * Everyone who reported an edit (`contribute`) since the last snapshot is credited on the next
30
+ * one, whoever takes it. Edits that nobody snapshots are recorded on their authors' behalf:
31
+ * `idleMs` after the last edit, or `leaveMs` after an editor's connection is gone (the grace
32
+ * period lets a reload or a brief network drop come back without a commit).
33
+ */
34
+ export declare const createHistoryOp: (history: () => History, auto?: {
35
+ idleMs?: number;
36
+ leaveMs?: number;
37
+ }) => {
38
+ flush: () => Promise<Snapshot | undefined>;
39
+ /** The host calls this when a connection closes or stops answering heartbeats. */
40
+ left: (session: {
41
+ user?: Person;
42
+ }) => void;
43
+ op: (input: Record<string, unknown>, session: {
44
+ user?: Person;
45
+ }) => Promise<unknown>;
46
+ };
@@ -0,0 +1,86 @@
1
+ // The history group of the workspace protocol: whole-workspace snapshots. The driver decides where
2
+ // they live (Git commits, or copies kept beside the workspace); the UI only sees this shape.
3
+ /** One line of display text, safe inside a Git author field or trailer. */
4
+ export const parsePerson = (input) => {
5
+ const clean = (value) => typeof value === "string"
6
+ ? value
7
+ .replace(/[<>\r\n\0]/g, "")
8
+ .trim()
9
+ .slice(0, 100)
10
+ : "";
11
+ const name = clean(input.name);
12
+ if (!name)
13
+ throw new Error("A name is required");
14
+ const email = clean(input.email);
15
+ return email ? { name, email } : { name };
16
+ };
17
+ /**
18
+ * The `history` operation. Requests run one at a time so two snapshots never interleave.
19
+ * Everyone who reported an edit (`contribute`) since the last snapshot is credited on the next
20
+ * one, whoever takes it. Edits that nobody snapshots are recorded on their authors' behalf:
21
+ * `idleMs` after the last edit, or `leaveMs` after an editor's connection is gone (the grace
22
+ * period lets a reload or a brief network drop come back without a commit).
23
+ */
24
+ export const createHistoryOp = (history, auto = {}) => {
25
+ let queue = Promise.resolve();
26
+ let idle;
27
+ const contributors = new Map();
28
+ const serial = (run) => {
29
+ const result = queue.then(run, run);
30
+ queue = result.catch(() => { });
31
+ return result;
32
+ };
33
+ const snapshot = async (message, author) => {
34
+ const coAuthors = [...contributors.values()].filter((p) => p.name !== author?.name);
35
+ const taken = await history().snapshot(message, { author, coAuthors });
36
+ contributors.clear();
37
+ return taken;
38
+ };
39
+ const later = (ms) => {
40
+ if (ms === undefined)
41
+ return;
42
+ clearTimeout(idle);
43
+ idle = setTimeout(() => void flush(), ms);
44
+ // A pending snapshot must not keep a Node process alive.
45
+ idle.unref?.();
46
+ };
47
+ /** Records pending edits, if any; having nothing to record is not an error here. */
48
+ const flush = () => serial(async () => {
49
+ if (!contributors.size)
50
+ return undefined;
51
+ // No author: the driver's default stands for the workspace itself.
52
+ return snapshot("Auto snapshot").catch(() => undefined);
53
+ });
54
+ return {
55
+ flush,
56
+ /** The host calls this when a connection closes or stops answering heartbeats. */
57
+ left: (session) => {
58
+ if (session.user && contributors.has(session.user.name))
59
+ later(auto.leaveMs);
60
+ },
61
+ op: (input, session) => {
62
+ if (input.action === "contribute") {
63
+ if (session.user) {
64
+ contributors.set(session.user.name, session.user);
65
+ later(auto.idleMs);
66
+ }
67
+ return Promise.resolve({ ok: true });
68
+ }
69
+ return serial(async () => {
70
+ if (input.action === "list")
71
+ return history().list();
72
+ if (input.action === "snapshot") {
73
+ const message = typeof input.message === "string" ? input.message.trim() : "";
74
+ if (!message)
75
+ throw new Error("A snapshot needs a message");
76
+ return snapshot(message, session.user);
77
+ }
78
+ if (input.action === "restore" && typeof input.id === "string") {
79
+ await history().restore(input.id);
80
+ return { ok: true };
81
+ }
82
+ throw new Error("Unknown history action");
83
+ });
84
+ },
85
+ };
86
+ };
@@ -0,0 +1,38 @@
1
+ export declare const WORKSPACE_PROTOCOL = 1;
2
+ export declare const WORKSPACE_PATH = "/api/workspace";
3
+ export interface WorkspaceRequest {
4
+ id: number;
5
+ op: string;
6
+ args?: Record<string, unknown>;
7
+ }
8
+ export type WorkspaceResponse = {
9
+ id: number;
10
+ value: unknown;
11
+ } | {
12
+ id: number;
13
+ error: string;
14
+ };
15
+ export interface WorkspaceEvent {
16
+ event: string;
17
+ data: unknown;
18
+ }
19
+ /** One end of a message channel. */
20
+ export interface WorkspacePort {
21
+ send(message: unknown): void;
22
+ receive(handler: (message: unknown) => void): void;
23
+ /** Called when the channel drops; requests in flight can never be answered after it. */
24
+ closed?(handler: () => void): void;
25
+ /** Called each time the channel (re)connects; absent on channels that never drop. */
26
+ opened?(handler: () => void): void;
27
+ }
28
+ export interface WorkspaceHello {
29
+ protocol: number;
30
+ /** Operation groups this server offers; the UI hides what is missing. */
31
+ ops: string[];
32
+ /** Identifies the server process; a different value after a reconnect means it restarted. */
33
+ boot?: string;
34
+ /** Several people edit this workspace at once, so each connection should identify itself. */
35
+ shared?: boolean;
36
+ }
37
+ /** Two connected ports in one thread (tests, and a server hosted next to its client). */
38
+ export declare const portPair: () => [WorkspacePort, WorkspacePort];
@@ -0,0 +1,20 @@
1
+ // The workspace protocol: every file, history and collaboration request the UI makes goes through
2
+ // these messages, so the same UI talks to a server in Node (WebSocket) or in a browser Worker.
3
+ // Messages are plain structured values; each transport picks its own encoding.
4
+ export const WORKSPACE_PROTOCOL = 1;
5
+ export const WORKSPACE_PATH = "/api/workspace";
6
+ /** Two connected ports in one thread (tests, and a server hosted next to its client). */
7
+ export const portPair = () => {
8
+ const handlers = [undefined, undefined];
9
+ const end = (self) => ({
10
+ // Delivered asynchronously and as a copy, like a real channel.
11
+ send: (message) => {
12
+ const copy = structuredClone(message);
13
+ queueMicrotask(() => handlers[1 - self]?.(copy));
14
+ },
15
+ receive: (handler) => {
16
+ handlers[self] = handler;
17
+ },
18
+ });
19
+ return [end(0), end(1)];
20
+ };
@@ -0,0 +1 @@
1
+ export declare const readDownloadFile: (root: string, file: unknown) => Buffer;
@@ -0,0 +1,8 @@
1
+ import { filesSnapshot } from "../engine/compiler/files.js";
2
+ import { readFileSync } from "../engine/compiler/host.js";
3
+ import { textfilePath } from "../engine/compiler/textfile.js";
4
+ export const readDownloadFile = (root, file) => {
5
+ if (typeof file !== "string" || !filesSnapshot(root).files.some((item) => item.path === file))
6
+ throw new Error("File is not available for download");
7
+ return readFileSync(textfilePath(root, file));
8
+ };
@@ -0,0 +1,9 @@
1
+ import { type WorkspaceHello, type WorkspacePort } from "./protocol.js";
2
+ /** `session` is whatever the host attached to the connection (who is asking, how far to trust). */
3
+ export type WorkspaceOps<Session> = Record<string, (args: Record<string, unknown>, session: Session) => unknown>;
4
+ export interface WorkspaceServer<Session> {
5
+ /** Returns the function that detaches the port. */
6
+ connect(port: WorkspacePort, session: Session): () => void;
7
+ broadcast(event: string, data: unknown): void;
8
+ }
9
+ export declare const createWorkspaceServer: <Session>(ops: WorkspaceOps<Session>, info?: Pick<WorkspaceHello, "boot" | "shared">) => WorkspaceServer<Session>;
@@ -0,0 +1,48 @@
1
+ // Host-neutral workspace server: routes protocol requests to operations and pushes events to every
2
+ // connected port. It knows nothing about Node or the browser; the host supplies the operations.
3
+ import { WORKSPACE_PROTOCOL, } from "./protocol.js";
4
+ export const createWorkspaceServer = (ops, info = {}) => {
5
+ const ports = new Set();
6
+ const hello = {
7
+ protocol: WORKSPACE_PROTOCOL,
8
+ ops: Object.keys(ops),
9
+ ...info,
10
+ };
11
+ return {
12
+ connect(port, session) {
13
+ ports.add(port);
14
+ port.receive((message) => {
15
+ if (!ports.has(port) || typeof message !== "object" || message === null)
16
+ return;
17
+ const { id, op, args } = message;
18
+ // Without an id there is nothing to answer.
19
+ if (typeof id !== "number")
20
+ return;
21
+ const reply = (response) => {
22
+ if (ports.has(port))
23
+ port.send(response);
24
+ };
25
+ void (async () => {
26
+ if (op === "hello")
27
+ return hello;
28
+ if (typeof op !== "string" || !Object.hasOwn(ops, op))
29
+ throw new Error(`Unknown workspace operation: ${String(op)}`);
30
+ return ops[op]?.(typeof args === "object" && args !== null && !Array.isArray(args)
31
+ ? args
32
+ : {}, session);
33
+ })().then((value) => reply({ id, value }), (error) => reply({
34
+ id,
35
+ error: error instanceof Error ? error.message : String(error),
36
+ }));
37
+ });
38
+ return () => {
39
+ ports.delete(port);
40
+ };
41
+ },
42
+ broadcast(event, data) {
43
+ const message = { event, data };
44
+ for (const port of ports)
45
+ port.send(message);
46
+ },
47
+ };
48
+ };