@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.
- package/dist/client.global.js +1 -0
- package/dist/code-worker.global.js +11 -11
- package/dist/code.global.js +75 -75
- package/dist/edit.global.js +234 -231
- package/dist/{compiler → engine/compiler}/bundle-urls.js +1 -4
- package/dist/{compiler → engine/compiler}/check-prose.d.ts +1 -1
- package/dist/{compiler → engine/compiler}/check-prose.js +1 -1
- package/dist/{compiler → engine/compiler}/check.js +15 -27
- package/dist/{compiler → engine/compiler}/code-blocks.js +3 -1
- package/dist/{compiler → engine/compiler}/code-languages.js +1 -2
- package/dist/{compiler → engine/compiler}/compile.d.ts +5 -4
- package/dist/{compiler → engine/compiler}/compile.js +91 -32
- package/dist/{compiler → engine/compiler}/config.js +1 -3
- package/dist/{compiler → engine/compiler}/dialect.d.ts +1 -3
- package/dist/{compiler → engine/compiler}/dialect.js +8 -52
- package/dist/{compiler → engine/compiler}/dxf.js +1 -1
- package/dist/{compiler → engine/compiler}/export.js +15 -8
- package/dist/{compiler → engine/compiler}/figures.js +26 -22
- package/dist/{compiler → engine/compiler}/file-cache.d.ts +1 -2
- package/dist/{compiler → engine/compiler}/file-cache.js +8 -15
- package/dist/{compiler → engine/compiler}/files.js +49 -38
- package/dist/{compiler → engine/compiler}/fonts.js +1 -3
- package/dist/{compiler → engine/compiler}/from-mdast.js +1 -1
- package/dist/engine/compiler/host.d.ts +10 -0
- package/dist/engine/compiler/host.js +16 -0
- package/dist/{compiler → engine/compiler}/icons.d.ts +3 -0
- package/dist/{compiler → engine/compiler}/icons.js +28 -10
- package/dist/{compiler → engine/compiler}/ignored-files.d.ts +2 -0
- package/dist/{compiler → engine/compiler}/ignored-files.js +12 -3
- package/dist/{compiler → engine/compiler}/locales.js +2 -8
- package/dist/{compiler → engine/compiler}/manifest.d.ts +3 -2
- package/dist/engine/compiler/manifest.js +46 -0
- package/dist/{compiler → engine/compiler}/ops.d.ts +4 -1
- package/dist/{compiler → engine/compiler}/ops.js +36 -21
- package/dist/engine/compiler/schema-file-references.d.ts +2 -0
- package/dist/engine/compiler/schema-file-references.js +82 -0
- package/dist/engine/compiler/serialize.d.ts +2 -0
- package/dist/engine/compiler/serialize.js +5 -0
- package/dist/{compiler → engine/compiler}/subformat-schema.js +1 -3
- package/dist/{compiler → engine/compiler}/subformats.d.ts +10 -0
- package/dist/{compiler → engine/compiler}/subformats.js +122 -18
- package/dist/{compiler → engine/compiler}/textfile-remote.js +1 -2
- package/dist/{compiler → engine/compiler}/textfile.js +4 -6
- package/dist/{compiler → engine/compiler}/theme-variants.js +1 -1
- package/dist/{compiler → engine/compiler}/zip.js +1 -1
- package/dist/{core → engine/core}/blocks.d.ts +6 -4
- package/dist/{core → engine/core}/content-metadata.d.ts +6 -1
- package/dist/{core → engine/core}/content-metadata.js +84 -18
- package/dist/{core → engine/core}/content-types.d.ts +4 -2
- package/dist/{core → engine/core}/html.d.ts +7 -0
- package/dist/{core → engine/core}/html.js +44 -3
- package/dist/{core → engine/core}/icons.d.ts +3 -0
- package/dist/engine/core/icons.js +20 -0
- package/dist/{core → engine/core}/routing.d.ts +2 -0
- package/dist/{core → engine/core}/routing.js +9 -0
- package/dist/{core → engine/core}/schema-refs.d.ts +1 -1
- package/dist/{core → engine/core}/schema-refs.js +3 -1
- package/dist/engine/core/subformat-references.d.ts +5 -0
- package/dist/engine/core/subformat-references.js +33 -0
- package/dist/{core → engine/core}/subformats.d.ts +7 -0
- package/dist/{core → engine/core}/subformats.js +5 -1
- package/dist/{core → engine/core}/taxonomy.d.ts +2 -3
- package/dist/{core → engine/core}/taxonomy.js +1 -5
- package/dist/flow.global.js +1031 -1057
- package/dist/frontend/application-request.d.ts +14 -0
- package/dist/frontend/application-request.js +36 -0
- package/dist/frontend/document-application.d.ts +200 -0
- package/dist/{viewer/serve.js → frontend/document-application.js} +1611 -1670
- package/dist/frontend/figure-preview.d.ts +4 -0
- package/dist/{viewer → frontend}/figure-preview.js +4 -4
- package/dist/{viewer → frontend}/file-references.d.ts +1 -1
- package/dist/{viewer → frontend}/file-references.js +3 -3
- package/dist/{viewer → frontend}/font-picker.d.ts +1 -1
- package/dist/{viewer → frontend}/font-settings.d.ts +1 -1
- package/dist/{viewer → frontend}/language-picker.js +112 -18
- package/dist/{viewer → frontend}/locales/eng.json +16 -2
- package/dist/{viewer → frontend}/locales/jpn.json +16 -2
- package/dist/{viewer → frontend}/locales/zho.json +16 -2
- package/dist/{viewer → frontend}/nav-focus.js +2 -0
- package/dist/{viewer → frontend}/plugin-blocks.js +2 -2
- package/dist/{viewer → frontend}/resize.js +14 -2
- package/dist/frontend/resource-download.d.ts +2 -0
- package/dist/frontend/resource-download.js +43 -0
- package/dist/{viewer → frontend}/resource-library.d.ts +9 -2
- package/dist/{viewer → frontend}/resource-library.js +133 -37
- package/dist/{core → frontend}/schema-graph-flow.d.ts +1 -1
- package/dist/{core → frontend}/schema-graph-flow.js +1 -1
- package/dist/{viewer → frontend}/search.d.ts +2 -2
- package/dist/{viewer → frontend}/search.js +26 -8
- package/dist/graph/{abnfDiagram-S7VZAUFO-ASBULSKE.js → abnfDiagram-S7VZAUFO-GAGCW2J5.js} +1 -1
- package/dist/graph/{architecture-WOLXFQ4H-V57EDXXY.js → architecture-WOLXFQ4H-AWAC3VBS.js} +1 -1
- package/dist/graph/{architectureDiagram-YGSQEFNW-GIMP347N.js → architectureDiagram-YGSQEFNW-WQ7QKSUJ.js} +1 -1
- package/dist/graph/{blockDiagram-APKKGZFW-RDL2T4JW.js → blockDiagram-APKKGZFW-H7ZNJMOM.js} +1 -1
- package/dist/graph/{bpmnIcons-APHXDYXF-TWOSQNUQ.js → bpmnIcons-APHXDYXF-EAVPNTFE.js} +1 -1
- package/dist/graph/{c4Diagram-KJ2TOQU5-75LIUC4F.js → c4Diagram-KJ2TOQU5-3IYS34YL.js} +1 -1
- package/dist/graph/{chunk-KU6GTEMS.js → chunk-3CJU2RDX.js} +1 -1
- package/dist/graph/{chunk-ISO77HML.js → chunk-5N2X2DXU.js} +1 -1
- package/dist/graph/{chunk-YCRLJT2S.js → chunk-67BPVAXC.js} +1 -1
- package/dist/graph/{chunk-26TUJSYJ.js → chunk-6CDZONCA.js} +1 -1
- package/dist/graph/{chunk-I3DMZIHV.js → chunk-7ASYMKN2.js} +1 -1
- package/dist/graph/{chunk-K2KLZU7M.js → chunk-7JQUFVT4.js} +2 -2
- package/dist/graph/{chunk-BBD5CEDC.js → chunk-7LSMJ4VU.js} +1 -1
- package/dist/graph/{chunk-EG5UVNOC.js → chunk-7UKJADAE.js} +1 -1
- package/dist/graph/{chunk-BZAMCJ6B.js → chunk-AARGNXTW.js} +1 -1
- package/dist/graph/{chunk-HOPPTA6H.js → chunk-BOXAA5AP.js} +2 -2
- package/dist/graph/{chunk-N3OHKGRZ.js → chunk-BTMPKSGF.js} +1 -1
- package/dist/graph/{chunk-QCJUF4YA.js → chunk-DIDARDST.js} +1 -1
- package/dist/graph/{chunk-R63JUMUK.js → chunk-EWYECPNJ.js} +1 -1
- package/dist/graph/{chunk-3YJHMOOA.js → chunk-FD7ZFC7R.js} +1 -1
- package/dist/graph/chunk-GWYODWCE.js +1 -0
- package/dist/graph/{chunk-IC23EEF6.js → chunk-HKRJKXEE.js} +1 -1
- package/dist/graph/{chunk-PW2RGZ3O.js → chunk-I5LEUF24.js} +1 -1
- package/dist/graph/{chunk-OFZLK5G4.js → chunk-ICJPOOXG.js} +1 -1
- package/dist/graph/{chunk-KT4VPQD5.js → chunk-IVZHB6RS.js} +2 -2
- package/dist/graph/{chunk-VM2H7G2R.js → chunk-JZGXHT3J.js} +1 -1
- package/dist/graph/{chunk-HJG2HUYJ.js → chunk-LSRL537V.js} +1 -1
- package/dist/graph/{chunk-C6J4A356.js → chunk-N44XPVUD.js} +1 -1
- package/dist/graph/{chunk-JD7ZBJD2.js → chunk-NDAMZVXQ.js} +1 -1
- package/dist/graph/{chunk-QEEA3KYY.js → chunk-QLS7NIYR.js} +1 -1
- package/dist/graph/{chunk-JRSH5GNS.js → chunk-QQIGL7OP.js} +1 -1
- package/dist/graph/chunk-SQE76S5B.js +1 -0
- package/dist/graph/{chunk-ZMCB7VP2.js → chunk-WQHTQAFY.js} +1 -1
- package/dist/graph/{classDiagram-v2-L25IHNXF-JL7LVDZH.js → classDiagram-v2-L25IHNXF-HNTCDTNK.js} +1 -1
- package/dist/graph/{cose-bilkent-JH36ORCC-PNM3EYPB.js → cose-bilkent-JH36ORCC-2GVA7XKO.js} +1 -1
- package/dist/graph/{cynefin-EF2NZ3EQ-PSXP3DXL.js → cynefin-EF2NZ3EQ-TCI65RAQ.js} +1 -1
- package/dist/graph/{cynefinDiagram-L36ESFBY-QVY54CXO.js → cynefinDiagram-L36ESFBY-OKQ5BLVF.js} +1 -1
- package/dist/graph/{dagre-SPEB5RXH-HPGQXBZJ.js → dagre-SPEB5RXH-KZEBD52K.js} +1 -1
- package/dist/graph/{diagram-3B7GL73J-DWH5WS2P.js → diagram-3B7GL73J-ESCBJM3O.js} +1 -1
- package/dist/graph/{diagram-DNEMPZML-TEGH2U5I.js → diagram-DNEMPZML-ZIBUSQZI.js} +1 -1
- package/dist/graph/{diagram-L3MUGCDN-X4MREUWR.js → diagram-L3MUGCDN-IGK62IPN.js} +1 -1
- package/dist/graph/{diagram-LA4NIPWU-NXT746HG.js → diagram-LA4NIPWU-2KZCOFJ5.js} +1 -1
- package/dist/graph/{diagram-MHCOC4E2-JGHXSAGS.js → diagram-MHCOC4E2-EYAAB236.js} +1 -1
- package/dist/graph/{diagram-XPFHEONP-ZHZPBLT4.js → diagram-XPFHEONP-OZ5ARGMG.js} +1 -1
- package/dist/graph/{ebnfDiagram-UZSYDL2S-SMF6KJ43.js → ebnfDiagram-UZSYDL2S-M3XJHARD.js} +1 -1
- package/dist/graph/{erDiagram-EYBAPDEH-B3JNJ357.js → erDiagram-EYBAPDEH-Y7KUBH7A.js} +1 -1
- package/dist/graph/{eventmodeling-K75KTNOO-WG6DDYMC.js → eventmodeling-K75KTNOO-ROLYRDEP.js} +1 -1
- package/dist/graph/flowDiagram-MALGAFMO-AAUEIPCR.js +1 -0
- package/dist/graph/{ganttDiagram-23REXITY-YXBYWFOJ.js → ganttDiagram-23REXITY-JSBTFSSJ.js} +1 -1
- package/dist/graph/{gitGraph-VSP46ZUC-VBFWJBBT.js → gitGraph-VSP46ZUC-ZCBCDVNF.js} +1 -1
- package/dist/graph/{gitGraphDiagram-STJD7YCW-4FZDCFGV.js → gitGraphDiagram-STJD7YCW-3ZA5FT3G.js} +1 -1
- package/dist/graph/{info-OHQRW6UA-ALVDUVYV.js → info-OHQRW6UA-JKJGOQNY.js} +1 -1
- package/dist/graph/infoDiagram-KBXO4MBG-6LFMPP2O.js +2 -0
- package/dist/graph/{ishikawaDiagram-M35NCXHK-FRZD2PWQ.js → ishikawaDiagram-M35NCXHK-YLEU44DY.js} +1 -1
- package/dist/graph/{journeyDiagram-OPLOXDXO-7Z66JCPR.js → journeyDiagram-OPLOXDXO-ZHJV66ZT.js} +1 -1
- package/dist/graph/{kanban-definition-BZKZHSQY-NN5AIKTE.js → kanban-definition-BZKZHSQY-SDU25WUM.js} +1 -1
- package/dist/graph/{katex-DXDNVO6V.js → katex-WSLZOTY7.js} +1 -1
- package/dist/graph/{mindmap-definition-I2QAS2VK-HDPCABN2.js → mindmap-definition-I2QAS2VK-XQNBCYHN.js} +1 -1
- package/dist/graph/{packet-JDAUHWVQ-5MQIBWAH.js → packet-JDAUHWVQ-Y3H77ERD.js} +1 -1
- package/dist/graph/{pegDiagram-FD4XPPHP-H2BFNCKT.js → pegDiagram-FD4XPPHP-YO4VWH6V.js} +1 -1
- package/dist/graph/{pie-XZMESJXO-T5VRKHVT.js → pie-XZMESJXO-PRER4XL5.js} +1 -1
- package/dist/graph/{pieDiagram-J4AKIIQI-O3NJSVD3.js → pieDiagram-J4AKIIQI-TJ5WOOSV.js} +1 -1
- package/dist/graph/{quadrantDiagram-XTYBLID2-TMTZJI3P.js → quadrantDiagram-XTYBLID2-G6MSSZLW.js} +1 -1
- package/dist/graph/{radar-ABXABTNO-C6FXIBYW.js → radar-ABXABTNO-M6MV34GM.js} +1 -1
- package/dist/graph/{railroad-I3PHUGI6-ZSO5JXB3.js → railroad-I3PHUGI6-YIWPGN6Q.js} +1 -1
- package/dist/graph/{railroad-abnf-LNEFI6M7-CI4GQRHB.js → railroad-abnf-LNEFI6M7-7JHLZ2R7.js} +1 -1
- package/dist/graph/{railroad-ebnf-DWYD2UWJ-MUENNCGK.js → railroad-ebnf-DWYD2UWJ-V55BXEWY.js} +1 -1
- package/dist/graph/{railroad-peg-JR7BVNR7-N3X5GGIX.js → railroad-peg-JR7BVNR7-XCGKDRMK.js} +1 -1
- package/dist/graph/{railroadDiagram-MRQ6NCDL-JHWS23UO.js → railroadDiagram-MRQ6NCDL-RACSFXC4.js} +1 -1
- package/dist/graph/{requirementDiagram-Y7LWUY3S-7DVLPO4B.js → requirementDiagram-Y7LWUY3S-4LQIQWHQ.js} +1 -1
- package/dist/graph/{sankeyDiagram-WGJFYUXA-Z5L4R5TR.js → sankeyDiagram-WGJFYUXA-K3RXG5FB.js} +1 -1
- package/dist/graph/schema-graph-global.js +17 -17
- package/dist/graph/{sequenceDiagram-5NDRBG5M-RCTU25NT.js → sequenceDiagram-5NDRBG5M-Y6RBHRS3.js} +1 -1
- package/dist/graph/{sizeCapture-INFHLROL-RROY32P5.js → sizeCapture-INFHLROL-TJW3VUGH.js} +1 -1
- package/dist/graph/{stateDiagram-v2-FJ4FJNEA-BXUSPWDK.js → stateDiagram-v2-FJ4FJNEA-4M5WZORG.js} +1 -1
- package/dist/graph/swimlanes-UMQ2AFYF-O4W6U4RO.js +1 -0
- package/dist/graph/swimlanesDiagram-OMPLPG4O-HZAKM45N.js +8 -0
- package/dist/graph/{timeline-definition-SEUHKTQE-ZQSMIVAS.js → timeline-definition-SEUHKTQE-IHISQ4Q7.js} +1 -1
- package/dist/graph/{treeView-D4JQ5SDB-42S7U73N.js → treeView-D4JQ5SDB-EVGY4VYS.js} +1 -1
- package/dist/graph/{treemap-SAJKECNS-RUBYQ7XF.js → treemap-SAJKECNS-LN3SMFRX.js} +1 -1
- package/dist/graph/{usecaseDiagram-AFA6YXN4-57RDRYXF.js → usecaseDiagram-AFA6YXN4-B645A3J6.js} +1 -1
- package/dist/graph/{vennDiagram-NNMJR3RB-5C3LVAV6.js → vennDiagram-NNMJR3RB-K3HWMON6.js} +1 -1
- package/dist/graph/{wardley-7MLQ67FV-NV5HXTTC.js → wardley-7MLQ67FV-RRWOELC6.js} +1 -1
- package/dist/graph/{wardleyDiagram-S7YFUSEH-6D5BKXHM.js → wardleyDiagram-S7YFUSEH-DMMWKJEK.js} +1 -1
- package/dist/graph/{xychartDiagram-GGNKY7IX-6ET3ZM67.js → xychartDiagram-GGNKY7IX-K6MUQVXR.js} +1 -1
- package/dist/install.sh +68 -0
- package/dist/plugins.global.js +62 -62
- package/dist/{viewer → server}/assets.d.ts +2 -0
- package/dist/server/assets.js +7 -0
- package/dist/{viewer → server}/build-plugins.js +4 -4
- package/dist/{viewer → server}/build.d.ts +2 -1
- package/dist/{viewer → server}/build.js +31 -15
- package/dist/{cli.js → server/cli.js} +223 -56
- package/dist/server/editor-tools.d.ts +1 -0
- package/dist/server/editor-tools.js +1 -0
- package/dist/{viewer → server}/extension-pack.js +2 -2
- package/dist/{viewer → server}/extensions.d.ts +1 -1
- package/dist/{viewer → server}/extensions.js +3 -3
- package/dist/server/git-diff.d.ts +10 -0
- package/dist/{viewer → server}/git-diff.js +45 -10
- package/dist/server/git-origin.d.ts +4 -0
- package/dist/server/git-origin.js +103 -0
- package/dist/server/git.d.ts +9 -0
- package/dist/{viewer → server}/git.js +50 -6
- package/dist/server/history.d.ts +14 -0
- package/dist/server/history.js +205 -0
- package/dist/{viewer → server}/hmr.d.ts +0 -22
- package/dist/server/hmr.js +168 -0
- package/dist/server/index.d.ts +17 -0
- package/dist/{index.js → server/index.js} +16 -16
- package/dist/{viewer → server}/ja-lint.d.ts +1 -1
- package/dist/{viewer → server}/languages.d.ts +1 -1
- package/dist/{viewer → server}/languages.js +3 -3
- package/dist/{mcp.d.ts → server/mcp.d.ts} +2 -2
- package/dist/{mcp.js → server/mcp.js} +60 -21
- package/dist/{viewer → server}/plugin-config.d.ts +2 -2
- package/dist/{viewer → server}/plugin-config.js +2 -2
- package/dist/{plugins → server/plugins}/local-storage.d.ts +1 -1
- package/dist/{plugins → server/plugins}/local-storage.js +1 -1
- package/dist/{plugins → server/plugins}/runtime.d.ts +4 -4
- package/dist/{plugins → server/plugins}/runtime.js +4 -4
- package/dist/{viewer → server}/plugins.d.ts +3 -3
- package/dist/{viewer → server}/plugins.js +14 -13
- package/dist/server/resource-library.d.ts +1 -0
- package/dist/server/resource-library.js +1 -0
- package/dist/server/self.d.ts +5 -0
- package/dist/server/self.js +98 -0
- package/dist/server/serve.d.ts +61 -0
- package/dist/server/serve.js +503 -0
- package/dist/server/static-client.d.ts +4 -0
- package/dist/server/static-client.js +117 -0
- package/dist/server/workspace-server.d.ts +16 -0
- package/dist/server/workspace-server.js +266 -0
- package/dist/{viewer → server}/workspace.d.ts +6 -1
- package/dist/{viewer → server}/workspace.js +46 -0
- package/dist/subformats.global.js +92 -6
- package/dist/ui.global.js +85 -72
- package/dist/workspace/client.d.ts +13 -0
- package/dist/workspace/client.js +114 -0
- package/dist/{viewer → workspace}/code-file.d.ts +1 -1
- package/dist/{viewer → workspace}/code-file.js +7 -7
- package/dist/workspace/connection.d.ts +27 -0
- package/dist/workspace/connection.js +38 -0
- package/dist/{viewer → workspace}/editor-tools.d.ts +7 -1
- package/dist/{viewer → workspace}/editor-tools.js +12 -9
- package/dist/{viewer → workspace}/git-types.d.ts +7 -0
- package/dist/workspace/github.d.ts +4 -0
- package/dist/workspace/github.js +99 -0
- package/dist/workspace/history.d.ts +46 -0
- package/dist/workspace/history.js +86 -0
- package/dist/workspace/protocol.d.ts +38 -0
- package/dist/workspace/protocol.js +20 -0
- package/dist/workspace/resource-download.d.ts +1 -0
- package/dist/workspace/resource-download.js +8 -0
- package/dist/workspace/server.d.ts +9 -0
- package/dist/workspace/server.js +48 -0
- package/dist/{viewer → workspace}/site-icon.js +9 -10
- package/dist/{viewer → workspace}/site-title.js +6 -7
- package/dist/{viewer → workspace}/textfile.d.ts +1 -1
- package/dist/{viewer → workspace}/textfile.js +5 -5
- package/dist/workspace-worker.global.js +2859 -0
- package/package.json +43 -21
- package/dist/compiler/manifest.js +0 -37
- package/dist/compiler/serialize.d.ts +0 -3
- package/dist/compiler/serialize.js +0 -16
- package/dist/core/icons.js +0 -5
- package/dist/graph/chunk-3RNHDNP5.js +0 -1
- package/dist/graph/chunk-5UUEAHTN.js +0 -1
- package/dist/graph/chunk-6T55RVVR.js +0 -1
- package/dist/graph/elk-XV6XMXQE-AZ4HLCWI.js +0 -27
- package/dist/graph/flowDiagram-MALGAFMO-2R7EYAQI.js +0 -1
- package/dist/graph/infoDiagram-KBXO4MBG-7EHX2GQG.js +0 -2
- package/dist/graph/swimlanes-UMQ2AFYF-LDD74Q2S.js +0 -1
- package/dist/graph/swimlanesDiagram-OMPLPG4O-ZYULLJSU.js +0 -8
- package/dist/index.d.ts +0 -17
- package/dist/viewer/assets.js +0 -3
- package/dist/viewer/figure-preview.d.ts +0 -4
- package/dist/viewer/git-diff.d.ts +0 -6
- package/dist/viewer/git.d.ts +0 -5
- package/dist/viewer/hmr.js +0 -341
- package/dist/viewer/serve.d.ts +0 -216
- /package/dist/{compiler → engine/compiler}/asset-references.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/asset-references.js +0 -0
- /package/dist/{compiler → engine/compiler}/bundle-urls.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/check-types.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/check-types.js +0 -0
- /package/dist/{compiler → engine/compiler}/check.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/code-blocks.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/code-languages.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/config.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/drawio.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/drawio.js +0 -0
- /package/dist/{compiler → engine/compiler}/dxf.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/export.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/figures.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/files.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/fonts.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/format.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/format.js +0 -0
- /package/dist/{compiler → engine/compiler}/from-mdast.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/language-codes.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/language-codes.js +0 -0
- /package/dist/{compiler → engine/compiler}/locales.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/public-file.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/public-file.js +0 -0
- /package/dist/{compiler → engine/compiler}/subformat-schema.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/terms.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/terms.js +0 -0
- /package/dist/{compiler → engine/compiler}/textfile-remote.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/textfile.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/theme-variants.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/zip.d.ts +0 -0
- /package/dist/{core → engine/core}/blocks.js +0 -0
- /package/dist/{core → engine/core}/code-file.d.ts +0 -0
- /package/dist/{core → engine/core}/code-file.js +0 -0
- /package/dist/{core → engine/core}/code-grammars.d.ts +0 -0
- /package/dist/{core → engine/core}/code-grammars.js +0 -0
- /package/dist/{core → engine/core}/content-types.js +0 -0
- /package/dist/{core → engine/core}/escape-html.d.ts +0 -0
- /package/dist/{core → engine/core}/escape-html.js +0 -0
- /package/dist/{core → engine/core}/extension-package.d.ts +0 -0
- /package/dist/{core → engine/core}/extension-package.js +0 -0
- /package/dist/{core → engine/core}/figure-frame.d.ts +0 -0
- /package/dist/{core → engine/core}/figure-frame.js +0 -0
- /package/dist/{core → engine/core}/file-embed.d.ts +0 -0
- /package/dist/{core → engine/core}/file-embed.js +0 -0
- /package/dist/{core → engine/core}/files.d.ts +0 -0
- /package/dist/{core → engine/core}/files.js +0 -0
- /package/dist/{core → engine/core}/graph-common.d.ts +0 -0
- /package/dist/{core → engine/core}/graph-common.js +0 -0
- /package/dist/{core → engine/core}/graph.d.ts +0 -0
- /package/dist/{core → engine/core}/graph.js +0 -0
- /package/dist/{core → engine/core}/inline.d.ts +0 -0
- /package/dist/{core → engine/core}/inline.js +0 -0
- /package/dist/{core → engine/core}/json-tools.d.ts +0 -0
- /package/dist/{core → engine/core}/json-tools.js +0 -0
- /package/dist/{core → engine/core}/language.d.ts +0 -0
- /package/dist/{core → engine/core}/language.js +0 -0
- /package/dist/{core → engine/core}/languages/ja.d.ts +0 -0
- /package/dist/{core → engine/core}/languages/ja.js +0 -0
- /package/dist/{core → engine/core}/markdown.d.ts +0 -0
- /package/dist/{core → engine/core}/markdown.js +0 -0
- /package/dist/{core → engine/core}/previewers.d.ts +0 -0
- /package/dist/{core → engine/core}/previewers.js +0 -0
- /package/dist/{core → engine/core}/schema-comments.d.ts +0 -0
- /package/dist/{core → engine/core}/schema-comments.js +0 -0
- /package/dist/{core → engine/core}/schema-fields.d.ts +0 -0
- /package/dist/{core → engine/core}/schema-fields.js +0 -0
- /package/dist/{core → engine/core}/schema-graph.d.ts +0 -0
- /package/dist/{core → engine/core}/schema-graph.js +0 -0
- /package/dist/{core → engine/core}/subformat-record.d.ts +0 -0
- /package/dist/{core → engine/core}/subformat-record.js +0 -0
- /package/dist/{core → engine/core}/term-reference.d.ts +0 -0
- /package/dist/{core → engine/core}/term-reference.js +0 -0
- /package/dist/{core → engine/core}/textfile.d.ts +0 -0
- /package/dist/{core → engine/core}/textfile.js +0 -0
- /package/dist/{core → engine/core}/theme-variants.d.ts +0 -0
- /package/dist/{core → engine/core}/theme-variants.js +0 -0
- /package/dist/{core → engine/core}/workspace.d.ts +0 -0
- /package/dist/{core → engine/core}/workspace.js +0 -0
- /package/dist/{viewer → frontend}/bundle-network.d.ts +0 -0
- /package/dist/{viewer → frontend}/bundle-network.js +0 -0
- /package/dist/{core → frontend}/flow-base-css.generated.d.ts +0 -0
- /package/dist/{core → frontend}/flow-base-css.generated.js +0 -0
- /package/dist/{core → frontend}/flow-css.d.ts +0 -0
- /package/dist/{core → frontend}/flow-css.js +0 -0
- /package/dist/{viewer → frontend}/font-picker.js +0 -0
- /package/dist/{viewer → frontend}/font-settings.js +0 -0
- /package/dist/{viewer → frontend}/i18n.d.ts +0 -0
- /package/dist/{viewer → frontend}/i18n.js +0 -0
- /package/dist/{viewer → frontend}/language-picker.d.ts +0 -0
- /package/dist/{viewer → frontend}/lazy-preview.d.ts +0 -0
- /package/dist/{viewer → frontend}/lazy-preview.js +0 -0
- /package/dist/{viewer → frontend}/nav-focus.d.ts +0 -0
- /package/dist/{viewer → frontend}/nav-update.d.ts +0 -0
- /package/dist/{viewer → frontend}/nav-update.js +0 -0
- /package/dist/{viewer → frontend}/plugin-blocks.d.ts +0 -0
- /package/dist/{viewer → frontend}/plugin-style.d.ts +0 -0
- /package/dist/{viewer → frontend}/plugin-style.js +0 -0
- /package/dist/{viewer → frontend}/plugin-view.d.ts +0 -0
- /package/dist/{viewer → frontend}/plugin-view.js +0 -0
- /package/dist/{viewer → frontend}/resize.d.ts +0 -0
- /package/dist/{core → frontend}/schema-graph-mount.d.ts +0 -0
- /package/dist/{core → frontend}/schema-graph-mount.js +0 -0
- /package/dist/{core → frontend}/table-ui.d.ts +0 -0
- /package/dist/{core → frontend}/table-ui.js +0 -0
- /package/dist/{core → frontend}/terms-ui.d.ts +0 -0
- /package/dist/{core → frontend}/terms-ui.js +0 -0
- /package/dist/{viewer → frontend}/theme-picker.d.ts +0 -0
- /package/dist/{viewer → frontend}/theme-picker.js +0 -0
- /package/dist/{core → frontend}/toc-ui.d.ts +0 -0
- /package/dist/{core → frontend}/toc-ui.js +0 -0
- /package/dist/{core → frontend}/video-ui.d.ts +0 -0
- /package/dist/{core → frontend}/video-ui.js +0 -0
- /package/dist/graph/{chunk-GYT4IYBZ.js → chunk-RJFVWYCA.js} +0 -0
- /package/dist/{viewer → server}/build-plugins.d.ts +0 -0
- /package/dist/{cli.d.ts → server/cli.d.ts} +0 -0
- /package/dist/{viewer → server}/extension-pack.d.ts +0 -0
- /package/dist/{viewer → server}/fonts/LICENSE.txt +0 -0
- /package/dist/{viewer → server}/fonts/udev-gothic-regular.woff2 +0 -0
- /package/dist/{viewer → server}/fonts.d.ts +0 -0
- /package/dist/{viewer → server}/fonts.js +0 -0
- /package/dist/{viewer → server}/ja-lint.js +0 -0
- /package/dist/{viewer → workspace}/git-types.js +0 -0
- /package/dist/{viewer → workspace}/site-icon.d.ts +0 -0
- /package/dist/{viewer → workspace}/site-title.d.ts +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { createServer } from "node:http";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { prebuilt, readViewerAsset } from "./assets.js";
|
|
5
|
+
import { bundleClient } from "./serve.js";
|
|
6
|
+
export const validateServerUrl = (value) => {
|
|
7
|
+
const url = new URL(value);
|
|
8
|
+
if (url.protocol === "http:")
|
|
9
|
+
url.protocol = "ws:";
|
|
10
|
+
if (url.protocol === "https:")
|
|
11
|
+
url.protocol = "wss:";
|
|
12
|
+
if (!["ws:", "wss:"].includes(url.protocol) ||
|
|
13
|
+
url.username ||
|
|
14
|
+
url.password ||
|
|
15
|
+
url.search ||
|
|
16
|
+
url.hash)
|
|
17
|
+
throw new Error("Server must be a ws:// or wss:// URL without credentials, query or fragment");
|
|
18
|
+
if (url.pathname === "/")
|
|
19
|
+
url.pathname = "/api/workspace";
|
|
20
|
+
return url.href;
|
|
21
|
+
};
|
|
22
|
+
const shell = `<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>dooc — Workspaces</title><style>body{margin:0;background:#fafaf8;color:#272727;font:15px/1.6 system-ui}main{max-width:600px;margin:15vh auto;padding:24px}h1{font-size:26px;font-weight:600}button{font:inherit;padding:9px 16px;border:1px solid #aaa;border-radius:4px;background:transparent;cursor:pointer}button:focus-visible{outline:2px solid #444;outline-offset:3px}</style><main><h1>dooc</h1><p>Edit documents in a local folder, browser storage, or a connected workspace.</p><button id="open-workspace" type="button">Open a workspace</button></main><script src="/assets/client.js"></script></html>`;
|
|
23
|
+
export const clientAssets = async (server) => {
|
|
24
|
+
const files = new Map([
|
|
25
|
+
["index.html", Buffer.from(shell)],
|
|
26
|
+
[
|
|
27
|
+
"dooc-client.json",
|
|
28
|
+
Buffer.from(JSON.stringify({ server: server ? validateServerUrl(server) : "" })),
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
"assets/fonts/udev-gothic-regular.woff2",
|
|
32
|
+
readViewerAsset("fonts/udev-gothic-regular.woff2"),
|
|
33
|
+
],
|
|
34
|
+
["assets/fonts/LICENSE.txt", readViewerAsset("fonts/LICENSE.txt")],
|
|
35
|
+
]);
|
|
36
|
+
const entries = {
|
|
37
|
+
edit: "edit-client.ts",
|
|
38
|
+
ui: "ui-client.ts",
|
|
39
|
+
code: "code-highlight.ts",
|
|
40
|
+
"code-worker": "code-worker.ts",
|
|
41
|
+
graph: "schema-graph-global.tsx",
|
|
42
|
+
};
|
|
43
|
+
for (const [name, entry] of Object.entries(entries))
|
|
44
|
+
files.set(`assets/${name}.js`, Buffer.from(await bundleClient(entry)));
|
|
45
|
+
if (prebuilt) {
|
|
46
|
+
for (const name of ["client", "workspace-worker"])
|
|
47
|
+
files.set(`assets/${name}.js`, readViewerAsset(`${name}.global.js`));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const buildScript = new URL("../../../scripts/build/client.mjs", import.meta.url).href;
|
|
51
|
+
const { buildBrowserWorkspace, buildClientEntry } = await import(buildScript);
|
|
52
|
+
const [worker, client] = await Promise.all([
|
|
53
|
+
buildBrowserWorkspace({ write: false }),
|
|
54
|
+
buildClientEntry({ write: false }),
|
|
55
|
+
]);
|
|
56
|
+
files.set("assets/workspace-worker.js", Buffer.from(worker.outputFiles[0].contents));
|
|
57
|
+
files.set("assets/client.js", Buffer.from(client.outputFiles[0].contents));
|
|
58
|
+
}
|
|
59
|
+
return files;
|
|
60
|
+
};
|
|
61
|
+
export const buildStaticClient = async (directory, server) => {
|
|
62
|
+
const assets = await clientAssets(server);
|
|
63
|
+
for (const [file, bytes] of assets) {
|
|
64
|
+
const target = join(directory, file);
|
|
65
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
66
|
+
writeFileSync(target, bytes);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export const startStaticClient = async (port = 5180, socket) => {
|
|
70
|
+
const files = await clientAssets(socket);
|
|
71
|
+
const server = createServer((req, res) => {
|
|
72
|
+
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
73
|
+
res.writeHead(405, { Allow: "GET, HEAD" });
|
|
74
|
+
res.end();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let path;
|
|
78
|
+
try {
|
|
79
|
+
path = decodeURIComponent(new URL(req.url ?? "/", "http://localhost").pathname).slice(1);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
res.writeHead(400);
|
|
83
|
+
res.end();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const fallback = !path.startsWith("assets/") && !path.startsWith("api/") && !path.includes(".");
|
|
87
|
+
const file = files.has(path) ? path : fallback ? "index.html" : "";
|
|
88
|
+
const data = files.get(file);
|
|
89
|
+
if (!data) {
|
|
90
|
+
res.writeHead(404);
|
|
91
|
+
res.end("Not found");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const type = file.endsWith(".js")
|
|
95
|
+
? "text/javascript"
|
|
96
|
+
: file.endsWith(".html")
|
|
97
|
+
? "text/html"
|
|
98
|
+
: file.endsWith(".json")
|
|
99
|
+
? "application/json"
|
|
100
|
+
: file.endsWith(".woff2")
|
|
101
|
+
? "font/woff2"
|
|
102
|
+
: "text/plain";
|
|
103
|
+
res.writeHead(200, {
|
|
104
|
+
"Content-Type": `${type}${type.startsWith("text/") ? "; charset=utf-8" : ""}`,
|
|
105
|
+
"X-Content-Type-Options": "nosniff",
|
|
106
|
+
"Cache-Control": "no-cache",
|
|
107
|
+
});
|
|
108
|
+
res.end(req.method === "HEAD" ? undefined : data);
|
|
109
|
+
});
|
|
110
|
+
await new Promise((resolve, reject) => {
|
|
111
|
+
server.once("error", reject);
|
|
112
|
+
server.listen(port, "127.0.0.1", resolve);
|
|
113
|
+
});
|
|
114
|
+
const address = server.address();
|
|
115
|
+
console.log(`dooc client: http://localhost:${typeof address === "object" && address ? address.port : port}`);
|
|
116
|
+
return server;
|
|
117
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface WorkspaceDescription {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
branch?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const clientOrigin: (value: string) => string;
|
|
7
|
+
export declare const nodeWorkspaceOperations: (manifest: string, pluginModule?: string, notify?: (event: string, data: unknown) => void) => Promise<{
|
|
8
|
+
ops: {
|
|
9
|
+
[k: string]: (input: Record<string, unknown>, session: {
|
|
10
|
+
local: boolean;
|
|
11
|
+
user?: import("../workspace/history.js").Person;
|
|
12
|
+
}) => Promise<unknown>;
|
|
13
|
+
};
|
|
14
|
+
close: () => void;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const startWorkspaceServer: (manifest: string, port?: number, origin?: string, pluginModule?: string) => Promise<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>>;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
3
|
+
import { createServer } from "node:http";
|
|
4
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
5
|
+
import { WebSocketServer } from "ws";
|
|
6
|
+
import { completeFilePaths, filesSnapshot, updateFiles, uploadFile, } from "../engine/compiler/files.js";
|
|
7
|
+
import { manifestFile, projectRoot } from "../engine/compiler/manifest.js";
|
|
8
|
+
import { MAX_FILE_UPLOAD_BYTES } from "../engine/core/files.js";
|
|
9
|
+
import { defaultPreviewSettings } from "../engine/core/previewers.js";
|
|
10
|
+
import { applicationRequest, } from "../frontend/application-request.js";
|
|
11
|
+
import { createDocumentApplication } from "../frontend/document-application.js";
|
|
12
|
+
import { createHistoryOp } from "../workspace/history.js";
|
|
13
|
+
import { WORKSPACE_PATH } from "../workspace/protocol.js";
|
|
14
|
+
import { createWorkspaceServer } from "../workspace/server.js";
|
|
15
|
+
import { isLocalHost, runCodeTool, validateCodeTools, validateTextfileCode, } from "./editor-tools.js";
|
|
16
|
+
import { fontCss } from "./fonts.js";
|
|
17
|
+
import { createGitHandler, git, gitManifestPath, gitWorktrees, hasGitManifest } from "./git.js";
|
|
18
|
+
import { gitBaseBody, gitBaseText, setSubformatChanges } from "./git-diff.js";
|
|
19
|
+
import { workspaceHistory } from "./history.js";
|
|
20
|
+
import { watchProject } from "./hmr.js";
|
|
21
|
+
import { loadSiteLanguages } from "./languages.js";
|
|
22
|
+
import { loadViewerPlugins } from "./plugin-config.js";
|
|
23
|
+
import { readWorkspaceSource, sourceFileBase } from "./workspace.js";
|
|
24
|
+
export const clientOrigin = (value) => {
|
|
25
|
+
const url = new URL(value);
|
|
26
|
+
if (!/^https?:$/.test(url.protocol) ||
|
|
27
|
+
url.username ||
|
|
28
|
+
url.password ||
|
|
29
|
+
url.pathname !== "/" ||
|
|
30
|
+
url.search ||
|
|
31
|
+
url.hash)
|
|
32
|
+
throw new Error("Client origin must be an HTTP(S) origin without a path or credentials");
|
|
33
|
+
return url.origin;
|
|
34
|
+
};
|
|
35
|
+
export const nodeWorkspaceOperations = async (manifest, pluginModule, notify = () => { }) => {
|
|
36
|
+
const primary = projectRoot(manifest);
|
|
37
|
+
const entries = new Map();
|
|
38
|
+
const closes = [];
|
|
39
|
+
const add = async (root, id) => {
|
|
40
|
+
const existing = entries.get(id);
|
|
41
|
+
if (existing)
|
|
42
|
+
return existing;
|
|
43
|
+
const source = readWorkspaceSource(root);
|
|
44
|
+
const plugins = await loadViewerPlugins(pluginModule);
|
|
45
|
+
const app = createDocumentApplication(root, {
|
|
46
|
+
fontCss,
|
|
47
|
+
readWorkspaceSource,
|
|
48
|
+
sourceFileBase,
|
|
49
|
+
gitBaseBody,
|
|
50
|
+
gitBaseText,
|
|
51
|
+
setSubformatChanges,
|
|
52
|
+
runCodeTool,
|
|
53
|
+
validateCodeTools,
|
|
54
|
+
validateTextfileCode,
|
|
55
|
+
});
|
|
56
|
+
const description = {
|
|
57
|
+
id,
|
|
58
|
+
label: source.protocol === "git"
|
|
59
|
+
? `${source.branch}/${source.repo ?? basename(root)}`
|
|
60
|
+
: basename(root),
|
|
61
|
+
...(source.protocol === "git" ? { branch: source.branch } : {}),
|
|
62
|
+
};
|
|
63
|
+
const entry = {
|
|
64
|
+
description,
|
|
65
|
+
root,
|
|
66
|
+
app,
|
|
67
|
+
git: createGitHandler(root, () => plugins.gitOrigin),
|
|
68
|
+
history: createHistoryOp(() => workspaceHistory(root)),
|
|
69
|
+
};
|
|
70
|
+
entries.set(id, entry);
|
|
71
|
+
const watcher = watchProject(root, "", (kind, files) => notify("change", { kind, files, workspace: id }));
|
|
72
|
+
closes.push(watcher.close);
|
|
73
|
+
app.configure({
|
|
74
|
+
languages: await loadSiteLanguages(root),
|
|
75
|
+
workspace: source,
|
|
76
|
+
previews: defaultPreviewSettings(),
|
|
77
|
+
downloads: true,
|
|
78
|
+
watch: watcher.watchTextfiles,
|
|
79
|
+
});
|
|
80
|
+
return entry;
|
|
81
|
+
};
|
|
82
|
+
const entry = (input) => {
|
|
83
|
+
const value = entries.get(typeof input.workspace === "string" ? input.workspace : "main");
|
|
84
|
+
if (!value)
|
|
85
|
+
throw new Error("Workspace is not open");
|
|
86
|
+
return value;
|
|
87
|
+
};
|
|
88
|
+
let opening = false;
|
|
89
|
+
const ops = {
|
|
90
|
+
workspaces: async (input) => {
|
|
91
|
+
if (input.action === "list")
|
|
92
|
+
return [...entries.values()].map(({ description }) => description);
|
|
93
|
+
if (input.action !== "branch" ||
|
|
94
|
+
typeof input.branch !== "string" ||
|
|
95
|
+
!input.branch.trim())
|
|
96
|
+
throw new Error("Choose a branch");
|
|
97
|
+
if (opening)
|
|
98
|
+
throw new Error("A workspace is opening. Try again when it finishes.");
|
|
99
|
+
opening = true;
|
|
100
|
+
try {
|
|
101
|
+
const current = entry(input);
|
|
102
|
+
const repository = (await git(current.root, ["rev-parse", "--show-toplevel"])).trim();
|
|
103
|
+
await git(repository, ["check-ref-format", "--branch", input.branch]);
|
|
104
|
+
const manifest = gitManifestPath(current.root, repository);
|
|
105
|
+
const missingManifest = () => new Error(input.create
|
|
106
|
+
? `Cannot create a branch workspace: "${manifest}" is not committed in HEAD. Commit this manifest before creating a branch.`
|
|
107
|
+
: `Branch "${input.branch}" does not contain "${manifest}". Choose a branch containing this manifest.`);
|
|
108
|
+
const existing = [...entries.values()].find((e) => e.description.branch === input.branch);
|
|
109
|
+
if (existing && !input.create) {
|
|
110
|
+
if (!(await hasGitManifest(existing.root, manifestFile(existing.root))))
|
|
111
|
+
throw missingManifest();
|
|
112
|
+
return existing.description;
|
|
113
|
+
}
|
|
114
|
+
const common = resolve(repository, (await git(repository, ["rev-parse", "--git-common-dir"])).trim());
|
|
115
|
+
const id = createHash("sha256")
|
|
116
|
+
.update(`${common}\0${input.branch}`)
|
|
117
|
+
.digest("hex")
|
|
118
|
+
.slice(0, 20);
|
|
119
|
+
const checkedOut = !input.create && (await gitWorktrees(repository)).get(input.branch);
|
|
120
|
+
const target = checkedOut || join(common, "dooc-worktrees", id);
|
|
121
|
+
if (!existsSync(target)) {
|
|
122
|
+
if (!(await hasGitManifest(repository, manifest, input.create ? "HEAD" : `refs/heads/${input.branch}`)))
|
|
123
|
+
throw missingManifest();
|
|
124
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
125
|
+
await git(repository, [
|
|
126
|
+
"worktree",
|
|
127
|
+
"add",
|
|
128
|
+
...(input.create ? ["-b", input.branch] : []),
|
|
129
|
+
target,
|
|
130
|
+
input.create ? "HEAD" : input.branch,
|
|
131
|
+
]);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
if (input.create)
|
|
135
|
+
throw new Error("Branch already has a workspace");
|
|
136
|
+
if ((await git(target, ["symbolic-ref", "--short", "HEAD"])).trim() !==
|
|
137
|
+
input.branch)
|
|
138
|
+
throw new Error("Saved worktree now belongs to a different branch");
|
|
139
|
+
if (!(await hasGitManifest(target, manifest)))
|
|
140
|
+
throw missingManifest();
|
|
141
|
+
}
|
|
142
|
+
const next = projectRoot(join(target, manifest));
|
|
143
|
+
return (await add(next, id)).description;
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
opening = false;
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
http: async (input) => {
|
|
150
|
+
if (typeof input.url !== "string" ||
|
|
151
|
+
!input.url.startsWith("/") ||
|
|
152
|
+
input.url.startsWith("//") ||
|
|
153
|
+
!["GET", "POST"].includes(String(input.method)) ||
|
|
154
|
+
typeof input.body !== "string")
|
|
155
|
+
throw new Error("Invalid document request");
|
|
156
|
+
const result = await applicationRequest(entry(input).app, "edit", {
|
|
157
|
+
url: input.url,
|
|
158
|
+
method: String(input.method),
|
|
159
|
+
body: input.body,
|
|
160
|
+
headers: input.headers && typeof input.headers === "object"
|
|
161
|
+
? input.headers
|
|
162
|
+
: {},
|
|
163
|
+
});
|
|
164
|
+
return {
|
|
165
|
+
...result,
|
|
166
|
+
body: typeof result.body === "string" ? result.body : Array.from(result.body),
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
files: (input) => {
|
|
170
|
+
const { root } = entry(input);
|
|
171
|
+
return input.action === "read"
|
|
172
|
+
? filesSnapshot(root)
|
|
173
|
+
: input.action === "complete"
|
|
174
|
+
? completeFilePaths(root, input.prefix)
|
|
175
|
+
: input.action === "upload"
|
|
176
|
+
? uploadFile(root, input)
|
|
177
|
+
: updateFiles(root, input);
|
|
178
|
+
},
|
|
179
|
+
git: (input) => {
|
|
180
|
+
if (input.action === "switch" || input.action === "branch")
|
|
181
|
+
throw new Error("Open the branch in a separate workspace");
|
|
182
|
+
return entry(input).git(input);
|
|
183
|
+
},
|
|
184
|
+
history: (input, session) => entry(input).history.op(input, session),
|
|
185
|
+
};
|
|
186
|
+
const queues = new Map();
|
|
187
|
+
const serial = Object.fromEntries(Object.entries(ops).map(([name, operation]) => [
|
|
188
|
+
name,
|
|
189
|
+
(input, session) => {
|
|
190
|
+
const id = typeof input.workspace === "string" ? input.workspace : "main";
|
|
191
|
+
const run = () => operation(input, session);
|
|
192
|
+
const next = (queues.get(id) ?? Promise.resolve()).then(run, run);
|
|
193
|
+
queues.set(id, next.catch(() => { }));
|
|
194
|
+
return next;
|
|
195
|
+
},
|
|
196
|
+
]));
|
|
197
|
+
await add(primary, "main");
|
|
198
|
+
return {
|
|
199
|
+
ops: serial,
|
|
200
|
+
close: () => {
|
|
201
|
+
for (const close of closes)
|
|
202
|
+
close();
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
export const startWorkspaceServer = async (manifest, port = 5179, origin = "http://localhost:5180", pluginModule) => {
|
|
207
|
+
const allowed = clientOrigin(origin);
|
|
208
|
+
let channel;
|
|
209
|
+
const manager = await nodeWorkspaceOperations(manifest, pluginModule, (event, data) => channel?.broadcast(event, data));
|
|
210
|
+
const activeChannel = createWorkspaceServer(manager.ops, { boot: crypto.randomUUID() });
|
|
211
|
+
channel = activeChannel;
|
|
212
|
+
const server = createServer((_req, res) => {
|
|
213
|
+
res.writeHead(404);
|
|
214
|
+
res.end("Connect using the dooc workspace socket");
|
|
215
|
+
});
|
|
216
|
+
const sockets = new WebSocketServer({
|
|
217
|
+
noServer: true,
|
|
218
|
+
maxPayload: Math.ceil((MAX_FILE_UPLOAD_BYTES * 4) / 3) + 16_384,
|
|
219
|
+
});
|
|
220
|
+
server.on("upgrade", (req, socket, head) => {
|
|
221
|
+
if (!isLocalHost(req.headers.host ?? "") ||
|
|
222
|
+
req.headers.origin !== allowed ||
|
|
223
|
+
req.url !== WORKSPACE_PATH) {
|
|
224
|
+
socket.destroy();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
sockets.handleUpgrade(req, socket, head, (ws) => {
|
|
228
|
+
const detach = activeChannel.connect({
|
|
229
|
+
send: (message) => {
|
|
230
|
+
if (ws.readyState === ws.OPEN)
|
|
231
|
+
ws.send(JSON.stringify(message));
|
|
232
|
+
},
|
|
233
|
+
receive: (handler) => ws.on("message", (data) => {
|
|
234
|
+
try {
|
|
235
|
+
handler(JSON.parse(data.toString()));
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
ws.close(1007, "Invalid JSON");
|
|
239
|
+
}
|
|
240
|
+
}),
|
|
241
|
+
}, { local: true });
|
|
242
|
+
ws.on("close", detach);
|
|
243
|
+
ws.on("error", detach);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
server.on("close", () => {
|
|
247
|
+
manager.close();
|
|
248
|
+
for (const ws of sockets.clients)
|
|
249
|
+
ws.terminate();
|
|
250
|
+
sockets.close();
|
|
251
|
+
});
|
|
252
|
+
try {
|
|
253
|
+
await new Promise((resolve, reject) => {
|
|
254
|
+
server.once("error", reject);
|
|
255
|
+
server.listen(port, "127.0.0.1", resolve);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
manager.close();
|
|
260
|
+
sockets.close();
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
const address = server.address();
|
|
264
|
+
console.log(`dooc server: ws://localhost:${typeof address === "object" && address ? address.port : port}${WORKSPACE_PATH} (client: ${allowed})`);
|
|
265
|
+
return server;
|
|
266
|
+
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import type { WorkspaceSource } from "../core/workspace.js";
|
|
1
|
+
import type { WorkspaceSource } from "../engine/core/workspace.js";
|
|
2
2
|
export declare const gitHeadFile: (root: string) => string | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Changes whenever HEAD, a ref or the repository config changes (and the index when asked), so Git
|
|
5
|
+
* answers can be reused between requests. Reads metadata files only; undefined outside Git.
|
|
6
|
+
*/
|
|
7
|
+
export declare const gitSignature: (root: string, index?: boolean) => string | undefined;
|
|
3
8
|
/** Read only local metadata; no Git commands, credentials or network access are needed. */
|
|
4
9
|
export declare const readWorkspaceSource: (root: string) => WorkspaceSource;
|
|
5
10
|
/** Resolve source links locally; published HTML must not depend on Git or the build directory. */
|
|
@@ -24,6 +24,42 @@ const gitMetadata = (root) => {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
export const gitHeadFile = (root) => gitMetadata(root)?.head;
|
|
27
|
+
/**
|
|
28
|
+
* Changes whenever HEAD, a ref or the repository config changes (and the index when asked), so Git
|
|
29
|
+
* answers can be reused between requests. Reads metadata files only; undefined outside Git.
|
|
30
|
+
*/
|
|
31
|
+
export const gitSignature = (root, index = false) => {
|
|
32
|
+
try {
|
|
33
|
+
const git = gitMetadata(root);
|
|
34
|
+
if (!git)
|
|
35
|
+
return undefined;
|
|
36
|
+
const directory = dirname(git.head);
|
|
37
|
+
const commondir = join(directory, "commondir");
|
|
38
|
+
const common = existsSync(commondir)
|
|
39
|
+
? resolve(directory, readFileSync(commondir, "utf8").trim())
|
|
40
|
+
: directory;
|
|
41
|
+
const head = readFileSync(git.head, "utf8").trim();
|
|
42
|
+
const ref = /^ref: (.+)$/.exec(head)?.[1];
|
|
43
|
+
const sig = (path) => {
|
|
44
|
+
const stat = statSync(path, { throwIfNoEntry: false });
|
|
45
|
+
return stat ? `${stat.mtimeMs}:${stat.size}` : "";
|
|
46
|
+
};
|
|
47
|
+
return [
|
|
48
|
+
head,
|
|
49
|
+
// A loose ref keeps its size across commits, so its content is the signature.
|
|
50
|
+
...(ref
|
|
51
|
+
? [directory, common].map((base) => existsSync(join(base, ref)) ? readFileSync(join(base, ref), "utf8") : "")
|
|
52
|
+
: []),
|
|
53
|
+
sig(join(common, "packed-refs")),
|
|
54
|
+
sig(join(common, "reftable", "tables.list")),
|
|
55
|
+
sig(join(common, "config")),
|
|
56
|
+
index ? sig(join(directory, "index")) : "",
|
|
57
|
+
].join("|");
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
27
63
|
/** Read only local metadata; no Git commands, credentials or network access are needed. */
|
|
28
64
|
export const readWorkspaceSource = (root) => {
|
|
29
65
|
const git = gitMetadata(root);
|
|
@@ -60,6 +96,16 @@ export const sourceFileBase = (root, sourceUrl) => {
|
|
|
60
96
|
return url.href;
|
|
61
97
|
}
|
|
62
98
|
const directory = realpathSync(root);
|
|
99
|
+
const signature = gitSignature(directory);
|
|
100
|
+
if (signature !== undefined && sourceBase?.key === `${directory}|${signature}`)
|
|
101
|
+
return sourceBase.value;
|
|
102
|
+
const value = readSourceFileBase(directory);
|
|
103
|
+
if (signature !== undefined)
|
|
104
|
+
sourceBase = { key: `${directory}|${signature}`, value };
|
|
105
|
+
return value;
|
|
106
|
+
};
|
|
107
|
+
let sourceBase;
|
|
108
|
+
const readSourceFileBase = (directory) => {
|
|
63
109
|
const metadata = gitMetadata(directory);
|
|
64
110
|
const workspace = readWorkspaceSource(directory);
|
|
65
111
|
const prefix = metadata ? relative(metadata.directory, directory).split(sep).join("/") : "";
|