@dooc-dev/dooc 0.0.7 → 0.0.9
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/LICENSE +21 -0
- package/README.md +16 -18
- 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 +306 -306
- 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/schema-graph-global.js +17 -17
- 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} +199 -66
- 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 +35 -20
- 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/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/{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
package/package.json
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooc-dev/dooc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "View and edit source files with dooc.yaml configuration, and share them as source ZIPs or standalone HTML.",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"files": [
|
|
7
8
|
"dist"
|
|
8
9
|
],
|
|
9
10
|
"bin": {
|
|
10
|
-
"dooc": "./dist/cli.js"
|
|
11
|
+
"dooc": "./dist/server/cli.js"
|
|
11
12
|
},
|
|
12
13
|
"exports": {
|
|
13
14
|
"./check": {
|
|
14
|
-
"types": "./dist/compiler/check.d.ts",
|
|
15
|
-
"default": "./dist/compiler/check.js"
|
|
15
|
+
"types": "./dist/engine/compiler/check.d.ts",
|
|
16
|
+
"default": "./dist/engine/compiler/check.js"
|
|
16
17
|
},
|
|
17
18
|
"./viewer-plugins": {
|
|
18
|
-
"types": "./dist/
|
|
19
|
-
"default": "./dist/
|
|
19
|
+
"types": "./dist/server/plugins.d.ts",
|
|
20
|
+
"default": "./dist/server/plugins.js"
|
|
20
21
|
},
|
|
21
22
|
"./plugins": {
|
|
22
23
|
"types": "./dist/plugins/index.d.ts",
|
|
23
24
|
"default": "./dist/plugins/index.js"
|
|
24
25
|
},
|
|
25
26
|
".": {
|
|
26
|
-
"types": "./dist/index.d.ts",
|
|
27
|
-
"default": "./dist/index.js"
|
|
27
|
+
"types": "./dist/server/index.d.ts",
|
|
28
|
+
"default": "./dist/server/index.js"
|
|
28
29
|
},
|
|
29
30
|
"./flow": {
|
|
30
|
-
"types": "./dist/
|
|
31
|
-
"default": "./dist/
|
|
31
|
+
"types": "./dist/frontend/schema-graph-mount.d.ts",
|
|
32
|
+
"default": "./dist/frontend/schema-graph-mount.js"
|
|
32
33
|
},
|
|
33
34
|
"./flow.global.js": "./dist/flow.global.js",
|
|
34
35
|
"./build": {
|
|
35
|
-
"types": "./dist/
|
|
36
|
-
"default": "./dist/
|
|
36
|
+
"types": "./dist/server/build.d.ts",
|
|
37
|
+
"default": "./dist/server/build.js"
|
|
37
38
|
},
|
|
38
39
|
"./export": {
|
|
39
|
-
"types": "./dist/compiler/export.d.ts",
|
|
40
|
-
"default": "./dist/compiler/export.js"
|
|
40
|
+
"types": "./dist/engine/compiler/export.d.ts",
|
|
41
|
+
"default": "./dist/engine/compiler/export.js"
|
|
41
42
|
}
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
@@ -61,20 +62,23 @@
|
|
|
61
62
|
"node": ">=22"
|
|
62
63
|
},
|
|
63
64
|
"scripts": {
|
|
64
|
-
"build:plugin": "
|
|
65
|
+
"build:plugin": "pnpm --dir plugins run build",
|
|
65
66
|
"test:plugin-package": "node --import tsx scripts/test/plugin-package.mjs",
|
|
66
|
-
"build": "node -e \"require('node:fs').rmSync('dist', {recursive:true, force:true})\" && pnpm run build:css && pnpm run build:fonts &&
|
|
67
|
+
"build": "node -e \"require('node:fs').rmSync('dist', {recursive:true, force:true})\" && pnpm run build:css && tsc -p tsconfig.build.json && node scripts/build/flatten-dist.mjs && node scripts/build/self-assets.mjs && pnpm run build:fonts && pnpm run build:flow && pnpm run build:edit && pnpm run build:client",
|
|
67
68
|
"build:binary": "bun scripts/build/binary.mjs",
|
|
68
69
|
"build:css": "node --import tsx scripts/build/flow-css.ts",
|
|
69
|
-
"build:flow": "esbuild src/
|
|
70
|
-
"build:edit": "esbuild src/
|
|
70
|
+
"build:flow": "esbuild packages/frontend/src/schema-graph-global.tsx --bundle --format=iife --target=es2022 --minify --outfile=dist/flow.global.js && esbuild packages/frontend/src/schema-graph-global.tsx --bundle --splitting --format=esm --target=es2022 --minify --outdir=dist/graph",
|
|
71
|
+
"build:edit": "esbuild packages/frontend/src/edit-client.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/edit.global.js && esbuild packages/frontend/src/ui-client.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/ui.global.js && esbuild packages/frontend/src/code-highlight.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/code.global.js && esbuild packages/frontend/src/code-worker.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/code-worker.global.js && esbuild packages/frontend/src/published-plugins.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/plugins.global.js && esbuild packages/frontend/src/published-subformats.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/subformats.global.js",
|
|
72
|
+
"dooc": "cd \"$INIT_CWD\" && node --import tsx \"$PNPM_SCRIPT_SRC_DIR/packages/server/src/cli.ts\"",
|
|
73
|
+
"dev": "tsx watch --clear-screen=false packages/server/src/cli.ts",
|
|
71
74
|
"test": "vitest run",
|
|
72
75
|
"test:binary": "node scripts/test/binary.mjs",
|
|
73
76
|
"test:install": "node scripts/test/install.mjs",
|
|
74
77
|
"check": "biome check . && tsc --noEmit && pnpm run build && vitest run && pnpm run test:install && pnpm run test:plugin-package",
|
|
75
78
|
"fix": "biome check --write .",
|
|
76
|
-
"build:fonts": "node -e \"require('node:fs').cpSync('src/
|
|
77
|
-
"build:sample-extension": "node --import tsx scripts/build/sample-extension.mjs"
|
|
79
|
+
"build:fonts": "node -e \"require('node:fs').cpSync('packages/server/src/fonts', 'dist/server/fonts', {recursive:true})\"",
|
|
80
|
+
"build:sample-extension": "node --import tsx scripts/build/sample-extension.mjs",
|
|
81
|
+
"build:client": "node scripts/build/client.mjs"
|
|
78
82
|
},
|
|
79
83
|
"devDependencies": {
|
|
80
84
|
"@biomejs/biome": "2.4.15",
|
|
@@ -88,18 +92,27 @@
|
|
|
88
92
|
"@codemirror/view": "^6.43.15",
|
|
89
93
|
"@lezer/common": "^1.5.4",
|
|
90
94
|
"@lezer/highlight": "^1.2.5",
|
|
95
|
+
"@noble/hashes": "^2.4.0",
|
|
91
96
|
"@shikijs/themes": "^4.5.0",
|
|
92
97
|
"@types/dxf": "4.6.10",
|
|
93
98
|
"@types/mdast": "^4.0.4",
|
|
94
99
|
"@types/node": "^22.10.0",
|
|
100
|
+
"@types/path-browserify": "^1.0.3",
|
|
95
101
|
"@types/react": "^19.2.17",
|
|
96
102
|
"@types/react-dom": "^19.2.3",
|
|
103
|
+
"@types/ws": "^8.18.2",
|
|
97
104
|
"@xyflow/react": "^12.11.2",
|
|
105
|
+
"buffer": "^6.0.3",
|
|
98
106
|
"diff": "8.0.4",
|
|
99
107
|
"esbuild": "^0.28.1",
|
|
108
|
+
"events": "^3.3.0",
|
|
109
|
+
"isomorphic-git": "^1.44.13",
|
|
110
|
+
"memfs": "^4.80.0",
|
|
100
111
|
"mermaid": "12.3.0",
|
|
112
|
+
"path-browserify": "^1.0.1",
|
|
101
113
|
"react": "^19.2.8",
|
|
102
114
|
"react-dom": "^19.2.8",
|
|
115
|
+
"readable-stream": "^4.8.0",
|
|
103
116
|
"textlint": "^15.8.0",
|
|
104
117
|
"tsx": "^4.19.2",
|
|
105
118
|
"typescript": "^5.8.3",
|
|
@@ -114,6 +127,7 @@
|
|
|
114
127
|
"ajv": "8.20.0",
|
|
115
128
|
"ajv-formats": "3.0.1",
|
|
116
129
|
"dxf": "5.3.1",
|
|
130
|
+
"fflate": "^0.8.3",
|
|
117
131
|
"franc": "^6.2.0",
|
|
118
132
|
"ignore": "^7.0.14",
|
|
119
133
|
"iso-639-3": "^3.0.1",
|
|
@@ -133,6 +147,7 @@
|
|
|
133
147
|
"unist-util-visit": "^5.0.0",
|
|
134
148
|
"vscode-json-languageservice": "5.7.2",
|
|
135
149
|
"vscode-languageserver-textdocument": "1.0.16",
|
|
150
|
+
"ws": "^8.22.2",
|
|
136
151
|
"yaml": "^2.7.0"
|
|
137
152
|
},
|
|
138
153
|
"pnpm": {
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Reads/writes dooc.yaml (node-dependent). Tree validation and manipulation live in
|
|
2
|
-
// core/content-metadata.ts.
|
|
3
|
-
import { existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { basename, dirname, join, resolve } from "node:path";
|
|
5
|
-
import { parse } from "yaml";
|
|
6
|
-
import { MANIFEST_FILE, parseManifest, serializeManifest, } from "../core/content-metadata.js";
|
|
7
|
-
/** CLI paths select a manifest; every project path is relative to its parent. */
|
|
8
|
-
export const projectRoot = (input = MANIFEST_FILE) => {
|
|
9
|
-
const file = resolve(input);
|
|
10
|
-
if (basename(file) !== MANIFEST_FILE || !existsSync(file) || !statSync(file).isFile())
|
|
11
|
-
throw new Error(`Specify an existing dooc.yaml file: ${file}`);
|
|
12
|
-
return dirname(file);
|
|
13
|
-
};
|
|
14
|
-
export const parseManifestText = (raw) => {
|
|
15
|
-
let value;
|
|
16
|
-
try {
|
|
17
|
-
value = parse(raw);
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
return {
|
|
21
|
-
tree: [],
|
|
22
|
-
errors: [`${MANIFEST_FILE}: invalid YAML (${e instanceof Error ? e.message : e})`],
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
return parseManifest(value);
|
|
26
|
-
};
|
|
27
|
-
/** Empty tree if missing (a new docs root with zero docs). */
|
|
28
|
-
export const readManifest = (root) => {
|
|
29
|
-
const path = join(root, MANIFEST_FILE);
|
|
30
|
-
return existsSync(path)
|
|
31
|
-
? parseManifestText(readFileSync(path, "utf8"))
|
|
32
|
-
: { tree: [], errors: [] };
|
|
33
|
-
};
|
|
34
|
-
export const writeManifest = (root, tree, metadata = {}) => {
|
|
35
|
-
writeFileSync(join(root, MANIFEST_FILE), serializeManifest(tree, metadata));
|
|
36
|
-
};
|
|
37
|
-
export { docFile } from "../core/files.js";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// Serializes front-matter in hand-written style (double-quoted scalars / flow sequences). A
|
|
2
|
-
// generic YAML stringify isn't used because it changes quote/sequence style and pollutes git
|
|
3
|
-
// diffs against existing files. Key order is title / lang. The key set is
|
|
4
|
-
// taxonomy's closed set, and a JSON string is a valid YAML double-quoted scalar.
|
|
5
|
-
const serializeFrontmatter = (fm) => {
|
|
6
|
-
const lines = [`title: ${JSON.stringify(fm.title)}`];
|
|
7
|
-
if (fm.lang) {
|
|
8
|
-
lines.push(`lang: ${JSON.stringify(fm.lang)}`);
|
|
9
|
-
}
|
|
10
|
-
return `---\n${lines.join("\n")}\n---\n`;
|
|
11
|
-
};
|
|
12
|
-
/** Form frontmatter + body md → full file text (normalized to one trailing newline). */
|
|
13
|
-
export const assembleDoc = (fm, body) => {
|
|
14
|
-
const b = body.replace(/\n+$/, "");
|
|
15
|
-
return serializeFrontmatter(fm) + (b === "" ? "" : `\n${b}\n`);
|
|
16
|
-
};
|
package/dist/core/icons.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export const FOLDER_ICON_PATH = "M2 5h6l2 2h8v10H2Z";
|
|
2
|
-
export const RELOAD_ICON_PATH = "M17 8a7 7 0 1 0 0 5M17 3v5h-5";
|
|
3
|
-
export const SEARCH_ICON_PATH = "M14 14l4 4M15 9a6 6 0 1 1-12 0 6 6 0 0 1 12 0";
|
|
4
|
-
export const CHECK_ICON = '<svg class="ic-ok" viewBox="0 0 20 20" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4 10 4 4 8-8"/></svg>';
|
|
5
|
-
export const PLUGINS_ICON = '<svg class="nav-icon" viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m10 2 4 2v5l-4 2-4-2V4Zm-4 2 4 2 4-2m-4 2v5M6 9l-4 2v5l4 2 4-2v-5m-8 0 4 2 4-2m-4 2v5m8-9 4 2v5l-4 2-4-2m0-5 4 2 4-2m-4 2v5"/></svg>';
|
package/dist/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from "./core/blocks.js";
|
|
2
|
-
export * from "./core/content-metadata.js";
|
|
3
|
-
export type * from "./core/content-types.js";
|
|
4
|
-
export * from "./core/figure-frame.js";
|
|
5
|
-
export * from "./core/graph.js";
|
|
6
|
-
export * from "./core/graph-common.js";
|
|
7
|
-
export * from "./core/html.js";
|
|
8
|
-
export * from "./core/inline.js";
|
|
9
|
-
export * from "./core/language.js";
|
|
10
|
-
export * from "./core/languages/ja.js";
|
|
11
|
-
export * from "./core/previewers.js";
|
|
12
|
-
export * from "./core/routing.js";
|
|
13
|
-
export * from "./core/schema-graph.js";
|
|
14
|
-
export * from "./core/taxonomy.js";
|
|
15
|
-
export * from "./core/terms-ui.js";
|
|
16
|
-
export { mountThemeVariants, themeVariantFile } from "./core/theme-variants.js";
|
|
17
|
-
export * from "./core/workspace.js";
|
package/dist/viewer/assets.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { FigureEntry } from "../core/content-types.js";
|
|
2
|
-
export declare const deferredFigureHtml: (fig: FigureEntry, cls?: string, label?: string) => string;
|
|
3
|
-
/** Delegated so previews inserted by navigation or HMR use the same loading state. */
|
|
4
|
-
export declare function mountFigurePreviews(): void;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { SubformatCollection } from "../core/subformats.js";
|
|
2
|
-
export declare const gitFileChanges: (root: string) => Map<string, "added" | "modified">;
|
|
3
|
-
/** Compare against HEAD so saving or staging does not clear the editor's changes. */
|
|
4
|
-
export declare const gitBaseText: (root: string, file: string) => string | null;
|
|
5
|
-
export declare const gitBaseBody: (root: string, file: string) => string | null;
|
|
6
|
-
export declare const setSubformatChanges: (root: string, collections: SubformatCollection[]) => void;
|
package/dist/viewer/git.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { GitChange, GitOrigin } from "./git-types.js";
|
|
2
|
-
export declare const parseGitChanges: (status: string) => GitChange[];
|
|
3
|
-
export declare const validateGitOrigin: (value: unknown) => GitOrigin;
|
|
4
|
-
/** Serialize UI operations; Git's own locks still arbitrate with other Git clients. */
|
|
5
|
-
export declare const createGitHandler: (documentRoot: string, getOrigin: () => GitOrigin | undefined) => (input: Record<string, unknown> | undefined) => Promise<unknown>;
|
package/dist/viewer/hmr.js
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
// HMR for the dev server (shared by preview / edit). Funnels changes into a single SSE stream
|
|
2
|
-
// (`/api/hmr`), by source:
|
|
3
|
-
// data side (content/*.md, dooc.yaml, figures/*) = picked up by this module's watcher;
|
|
4
|
-
// preview swaps only the main body + nav (keeping scroll). edit likewise does a partial
|
|
5
|
-
// update of just the body + nav (no reload; keeps CodeMirror cursor/scroll/undo and
|
|
6
|
-
// unsaved content) — only on pages where edit-client.ts registered `onContent`
|
|
7
|
-
// (unregistered, e.g. the new page, reloads).
|
|
8
|
-
// client bundle side (src/viewer/edit-client.ts, src/core/*.tsx = bundle sources of the schema
|
|
9
|
-
// graph interaction layer `/assets/graph.js`) = not imported by the server (esbuild
|
|
10
|
-
// bundles them on demand), so tsx watch doesn't react → the data-side watcher picks
|
|
11
|
-
// them up as "client" and triggers a reload.
|
|
12
|
-
// server side (all other src/*.ts) = tsx watch restarts the whole process, so not watched.
|
|
13
|
-
// The client notices the swap from the bootId difference in `hello` on reconnect and
|
|
14
|
-
// reloads.
|
|
15
|
-
// All content events reach the editor, which compares disk contents with its saved base.
|
|
16
|
-
import { existsSync, readFileSync, realpathSync, unwatchFile, watch, watchFile } from "node:fs";
|
|
17
|
-
import { dirname, join, resolve } from "node:path";
|
|
18
|
-
import { managedFile } from "../compiler/files.js";
|
|
19
|
-
import { textfilePath } from "../compiler/textfile.js";
|
|
20
|
-
import { MANIFEST_FILE } from "../core/content-metadata.js";
|
|
21
|
-
import { isRemoteTextfile } from "../core/textfile.js";
|
|
22
|
-
import { prebuilt } from "./assets.js";
|
|
23
|
-
import { updateNav } from "./nav-update.js";
|
|
24
|
-
import { gitHeadFile } from "./workspace.js";
|
|
25
|
-
/** SSE endpoint. SoT for the server route and the client script's connection target. */
|
|
26
|
-
export const HMR_PATH = "/api/hmr";
|
|
27
|
-
/**
|
|
28
|
-
* Changed path (repo-root relative) → HMR kind. undefined for out-of-scope files
|
|
29
|
-
* (dist output, temp files etc.).
|
|
30
|
-
*/
|
|
31
|
-
export const classifyChange = (rel) => {
|
|
32
|
-
const p = rel.replace(/\\/g, "/");
|
|
33
|
-
// edit's client bundle itself (src/viewer/edit-client.ts) and src/core/*.tsx
|
|
34
|
-
// (schema-graph-*.tsx = bundle sources of `/assets/graph.js`) aren't imported by the server
|
|
35
|
-
// (esbuild bundles them per request), so tsx watch can't pick them up → explicitly classify
|
|
36
|
-
// them as "client" here to trigger a reload. Other src/*.ts (the server itself) stay out of
|
|
37
|
-
// scope (= tsx watch restart → the client picks it up from the bootId difference in hello).
|
|
38
|
-
if (p === "src/viewer/edit-client.ts" ||
|
|
39
|
-
p === "src/viewer/files-ui.ts" ||
|
|
40
|
-
p === "src/viewer/resource-library-ui.ts" ||
|
|
41
|
-
p === "src/viewer/subformats-ui.ts" ||
|
|
42
|
-
p === "src/viewer/edit-code-file.ts" ||
|
|
43
|
-
p === "src/core/code-file.ts" ||
|
|
44
|
-
p === "src/core/files.ts" ||
|
|
45
|
-
p === "src/viewer/edit-schema-completion.ts" ||
|
|
46
|
-
p === "src/viewer/edit-textfile.ts" ||
|
|
47
|
-
p === "src/viewer/file-references.ts" ||
|
|
48
|
-
p === "src/core/markdown.ts" ||
|
|
49
|
-
p === "src/core/mermaid-mount.ts" ||
|
|
50
|
-
p === "src/core/textfile.ts" ||
|
|
51
|
-
p === "src/core/file-embed.ts" ||
|
|
52
|
-
p === "src/core/term-reference.ts" ||
|
|
53
|
-
p === "src/core/taxonomy.ts" ||
|
|
54
|
-
p === "src/core/previewers.ts" ||
|
|
55
|
-
p === "src/viewer/edit-file-preview.ts" ||
|
|
56
|
-
p === "src/viewer/edit-conflict.ts" ||
|
|
57
|
-
p === "src/viewer/edit-code-highlight.ts" ||
|
|
58
|
-
p === "src/viewer/edit-git-diff.ts" ||
|
|
59
|
-
p === "src/viewer/code-tokens.ts" ||
|
|
60
|
-
p === "src/viewer/code-worker.ts" ||
|
|
61
|
-
p === "src/viewer/i18n.ts" ||
|
|
62
|
-
p === "src/viewer/language-picker.ts" ||
|
|
63
|
-
p === "src/viewer/theme-picker.ts" ||
|
|
64
|
-
p === "src/viewer/ui-client.ts" ||
|
|
65
|
-
p === "src/viewer/extensions-ui.ts" ||
|
|
66
|
-
p === "src/viewer/extensions-store.ts" ||
|
|
67
|
-
p === "src/viewer/plugins-ui.ts" ||
|
|
68
|
-
p === "src/viewer/plugin-view.ts" ||
|
|
69
|
-
p === "src/viewer/plugin-resize.ts" ||
|
|
70
|
-
p === "src/viewer/preview-update.ts" ||
|
|
71
|
-
p === "src/plugins/view.ts" ||
|
|
72
|
-
p === "src/viewer/nav-focus.ts" ||
|
|
73
|
-
p === "src/viewer/nav-update.ts" ||
|
|
74
|
-
p === "src/viewer/code-highlight.ts" ||
|
|
75
|
-
(p.startsWith("src/viewer/locales/") && p.endsWith(".json")) ||
|
|
76
|
-
(p.startsWith("src/core/") && p.endsWith(".tsx"))) {
|
|
77
|
-
return "client";
|
|
78
|
-
}
|
|
79
|
-
// content = body text (.md) and dooc.yaml (= SoT for hierarchy and ordering).
|
|
80
|
-
if (p === MANIFEST_FILE || (p.startsWith("content/") && p.endsWith(".md"))) {
|
|
81
|
-
return "content";
|
|
82
|
-
}
|
|
83
|
-
if (p.startsWith("locales/") && p.endsWith(".md"))
|
|
84
|
-
return "content";
|
|
85
|
-
if (p.startsWith("figures/") && /\.(svg|html|png|webp|jpe?g)$/.test(p)) {
|
|
86
|
-
return "content";
|
|
87
|
-
}
|
|
88
|
-
// icons/<id>.svg (doc icons) is data side too = partial update.
|
|
89
|
-
if (p.startsWith("icons/") && p.endsWith(".svg")) {
|
|
90
|
-
return "content";
|
|
91
|
-
}
|
|
92
|
-
return undefined;
|
|
93
|
-
};
|
|
94
|
-
/** One SSE frame (in the format the client's EventSource reads). */
|
|
95
|
-
export const sseFrame = (event, data) => `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`;
|
|
96
|
-
export const createHmrHub = (bootId) => {
|
|
97
|
-
const clients = new Set();
|
|
98
|
-
// Ping periodically to clean up dead sockets, even on localhost without a proxy.
|
|
99
|
-
const ping = setInterval(() => {
|
|
100
|
-
for (const res of clients) {
|
|
101
|
-
res.write(": ping\n\n");
|
|
102
|
-
}
|
|
103
|
-
}, 20_000);
|
|
104
|
-
ping.unref();
|
|
105
|
-
return {
|
|
106
|
-
handle: (res) => {
|
|
107
|
-
res.writeHead(200, {
|
|
108
|
-
"content-type": "text/event-stream; charset=utf-8",
|
|
109
|
-
"cache-control": "no-cache, no-transform",
|
|
110
|
-
connection: "keep-alive",
|
|
111
|
-
});
|
|
112
|
-
// Make clients reconnect quickly right after a restart (tsx watch); the default
|
|
113
|
-
// reconnect interval is browser-dependent.
|
|
114
|
-
res.write("retry: 300\n\n");
|
|
115
|
-
res.write(sseFrame("hello", { bootId }));
|
|
116
|
-
clients.add(res);
|
|
117
|
-
res.on("close", () => clients.delete(res));
|
|
118
|
-
},
|
|
119
|
-
broadcast: (kind, files) => {
|
|
120
|
-
const frame = sseFrame("change", { kind, files });
|
|
121
|
-
for (const res of clients) {
|
|
122
|
-
res.write(frame);
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* Folders to watch. The docs-side ones are relative to docsRoot, src to pkgRoot (only files that
|
|
129
|
-
* classifyChange marks "client" count).
|
|
130
|
-
*/
|
|
131
|
-
/**
|
|
132
|
-
* Notifies data-side changes batched by kind. An editor save fires multiple events
|
|
133
|
-
* (rename + change), so debounce collapses them into one. Referenced text files can be added
|
|
134
|
-
* as drafts are compiled; close() releases all watchers.
|
|
135
|
-
*/
|
|
136
|
-
export const watchProject = (docsRoot, pkgRoot, onChange, debounceMs = 60) => {
|
|
137
|
-
const pending = new Map();
|
|
138
|
-
let timer;
|
|
139
|
-
const flush = () => {
|
|
140
|
-
timer = undefined;
|
|
141
|
-
const byKind = new Map();
|
|
142
|
-
for (const [file, kind] of pending) {
|
|
143
|
-
byKind.set(kind, [...(byKind.get(kind) ?? []), file]);
|
|
144
|
-
}
|
|
145
|
-
pending.clear();
|
|
146
|
-
for (const [kind, files] of byKind) {
|
|
147
|
-
onChange(kind, files);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
const note = (rel, kind = classifyChange(rel)) => {
|
|
151
|
-
if (!kind) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
pending.set(rel, kind);
|
|
155
|
-
if (!timer) {
|
|
156
|
-
timer = setTimeout(flush, debounceMs);
|
|
157
|
-
timer.unref();
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
// Skip missing folders (checkouts / test fixtures without optional asset folders) to avoid ENOENT.
|
|
161
|
-
const dirs = [["src", join(pkgRoot, "src")]];
|
|
162
|
-
const watchers = dirs
|
|
163
|
-
.filter(([, abs]) => !prebuilt && existsSync(abs))
|
|
164
|
-
.map(([dir, abs]) => watch(abs, { recursive: true }, (_event, name) => {
|
|
165
|
-
if (name) {
|
|
166
|
-
note(`${dir}/${String(name)}`);
|
|
167
|
-
}
|
|
168
|
-
}));
|
|
169
|
-
// Watch the directory so atomic replacements of the manifest are detected too.
|
|
170
|
-
watchers.push(watch(docsRoot, { recursive: true }, (_event, name) => {
|
|
171
|
-
if (!name)
|
|
172
|
-
return;
|
|
173
|
-
const path = String(name).replaceAll("\\", "/");
|
|
174
|
-
if (path === MANIFEST_FILE ||
|
|
175
|
-
path.startsWith("locales/") ||
|
|
176
|
-
/(^|\/)\.gitignore$/.test(path))
|
|
177
|
-
note(path, "content");
|
|
178
|
-
else if (managedFile(path) && !path.startsWith("src/") && !/\.(tmp|swp)$/.test(path))
|
|
179
|
-
note(path, "content");
|
|
180
|
-
}));
|
|
181
|
-
const textfiles = new Map();
|
|
182
|
-
const headFile = gitHeadFile(docsRoot);
|
|
183
|
-
if (headFile) {
|
|
184
|
-
for (let parent = realpathSync(docsRoot); !existsSync(join(parent, ".git"));) {
|
|
185
|
-
const next = dirname(parent);
|
|
186
|
-
if (next === parent)
|
|
187
|
-
break;
|
|
188
|
-
parent = next;
|
|
189
|
-
watchers.push(watch(parent, (_event, name) => {
|
|
190
|
-
if (String(name) === ".gitignore")
|
|
191
|
-
note(".gitignore", "content");
|
|
192
|
-
}));
|
|
193
|
-
}
|
|
194
|
-
const directory = dirname(headFile);
|
|
195
|
-
const common = join(directory, "commondir");
|
|
196
|
-
const directories = new Set([
|
|
197
|
-
directory,
|
|
198
|
-
existsSync(common)
|
|
199
|
-
? resolve(directory, readFileSync(common, "utf8").trim())
|
|
200
|
-
: directory,
|
|
201
|
-
]);
|
|
202
|
-
for (const path of directories)
|
|
203
|
-
watchers.push(watch(path, { recursive: true }, (_event, name) => {
|
|
204
|
-
const file = String(name).replaceAll("\\", "/");
|
|
205
|
-
if (file === "HEAD" || file === "packed-refs" || file.startsWith("refs/"))
|
|
206
|
-
note(".git/HEAD", "content");
|
|
207
|
-
else if (file === "index" || file === "info/exclude" || file === "config")
|
|
208
|
-
note(`.git/${file}`, "content");
|
|
209
|
-
}));
|
|
210
|
-
}
|
|
211
|
-
// shortcut: keep encountered file watches until shutdown; prune if sessions collect many removed references.
|
|
212
|
-
const watchTextfiles = (files) => {
|
|
213
|
-
for (const file of files) {
|
|
214
|
-
if (isRemoteTextfile(file))
|
|
215
|
-
continue;
|
|
216
|
-
try {
|
|
217
|
-
textfilePath(docsRoot, file);
|
|
218
|
-
}
|
|
219
|
-
catch {
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
const path = resolve(docsRoot, file);
|
|
223
|
-
if (textfiles.has(path))
|
|
224
|
-
continue;
|
|
225
|
-
const changed = () => note(file.replace(/^(\.\/)+/, ""), "content");
|
|
226
|
-
// Poll referenced paths so atomic saves, deletion and creation are all detected.
|
|
227
|
-
watchFile(path, { persistent: false, interval: 200 }, changed);
|
|
228
|
-
textfiles.set(path, changed);
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
const close = () => {
|
|
232
|
-
if (timer) {
|
|
233
|
-
clearTimeout(timer);
|
|
234
|
-
timer = undefined;
|
|
235
|
-
}
|
|
236
|
-
for (const w of watchers) {
|
|
237
|
-
w.close();
|
|
238
|
-
}
|
|
239
|
-
for (const [path, listener] of textfiles)
|
|
240
|
-
unwatchFile(path, listener);
|
|
241
|
-
};
|
|
242
|
-
return { close, watchTextfiles };
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* Client script injected into page(). How changes are applied depends on mode:
|
|
246
|
-
* preview = swap the main <main> + nav (keeping scroll / sidebar state).
|
|
247
|
-
* edit = delegate content changes to `window.__docsHmr.onContent` (registered by
|
|
248
|
-
* edit-client.ts) without reloading (pages without it, e.g. the new page, reload).
|
|
249
|
-
* Changes to the client bundle (`src/viewer/edit-client.ts` / `src/core/*.tsx`) and
|
|
250
|
-
* a bootId difference in `hello` (= the server itself restarted) reload. While there
|
|
251
|
-
* are unsaved (dirty) changes, the reload is downgraded to a badge and waits.
|
|
252
|
-
*/
|
|
253
|
-
export const hmrClientScript = (mode) => `
|
|
254
|
-
(() => {
|
|
255
|
-
const MODE = ${JSON.stringify(mode)};
|
|
256
|
-
let bootId = null;
|
|
257
|
-
let isDirty = false;
|
|
258
|
-
let pendingReload = false;
|
|
259
|
-
|
|
260
|
-
let badge = null;
|
|
261
|
-
const showBadge = () => {
|
|
262
|
-
pendingReload = true;
|
|
263
|
-
if (badge) return;
|
|
264
|
-
badge = document.createElement("button");
|
|
265
|
-
badge.type = "button";
|
|
266
|
-
badge.textContent = "Updated externally — click to reload";
|
|
267
|
-
badge.style.cssText = "position:fixed;right:14px;bottom:14px;z-index:9999;font:inherit;font-size:12px;padding:6px 10px;border-radius:6px;cursor:pointer;border:1px solid var(--doc-border-2,#c4ccd8);background:var(--doc-panel,#fff);color:var(--doc-fg-2,#2a3140);box-shadow:0 2px 8px rgba(0,0,0,.18)";
|
|
268
|
-
badge.addEventListener("click", () => location.reload());
|
|
269
|
-
document.body.appendChild(badge);
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
// Never silently discard unsaved changes (downgrade to a badge and wait).
|
|
273
|
-
const reload = () => { if (isDirty) { showBadge(); return; } location.reload(); };
|
|
274
|
-
|
|
275
|
-
// preview partial swap — refetch the same URL and replace only the contents of <main> and nav.
|
|
276
|
-
const swap = async () => {
|
|
277
|
-
let next;
|
|
278
|
-
try {
|
|
279
|
-
const res = await fetch(location.href, { headers: { "cache-control": "no-cache" } });
|
|
280
|
-
if (!res.ok) { reload(); return; }
|
|
281
|
-
next = new DOMParser().parseFromString(await res.text(), "text/html");
|
|
282
|
-
} catch { return; } // e.g. server restarting — picked up by the next hello
|
|
283
|
-
const main = document.querySelector("main");
|
|
284
|
-
const nextMain = next.querySelector("main");
|
|
285
|
-
if (!main || !nextMain) { reload(); return; }
|
|
286
|
-
const y = main.scrollTop;
|
|
287
|
-
document.title = next.title;
|
|
288
|
-
const title = document.getElementById("site-title");
|
|
289
|
-
const nextTitle = next.getElementById("site-title");
|
|
290
|
-
if (title && nextTitle) {
|
|
291
|
-
title.textContent = nextTitle.textContent;
|
|
292
|
-
title.title = nextTitle.title;
|
|
293
|
-
}
|
|
294
|
-
const logo = document.getElementById("site-icon");
|
|
295
|
-
const nextLogo = next.getElementById("site-icon");
|
|
296
|
-
if (logo && nextLogo) logo.replaceWith(nextLogo);
|
|
297
|
-
const updatePreview = window.__docsHmr && window.__docsHmr.updatePreview;
|
|
298
|
-
if (updatePreview) updatePreview(main, nextMain);
|
|
299
|
-
else main.innerHTML = nextMain.innerHTML;
|
|
300
|
-
const nav = document.getElementById("nav-groups");
|
|
301
|
-
const nextNav = next.getElementById("nav-groups");
|
|
302
|
-
if (nav && nextNav) {
|
|
303
|
-
(${updateNav.toString()})(nav, nextNav.innerHTML);
|
|
304
|
-
if (window.__docsNavRestore) window.__docsNavRestore();
|
|
305
|
-
}
|
|
306
|
-
main.scrollTo(0, y);
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
// Notification hooks for the edit client (src/viewer/edit-client.ts). edit-client.ts may run
|
|
310
|
-
// first (bootScripts sit near the top of body, this script at the end of body), so merge
|
|
311
|
-
// instead of clobbering what's already there (an earlier onContent registration).
|
|
312
|
-
window.__docsHmr = Object.assign(window.__docsHmr || {}, {
|
|
313
|
-
setDirty: (v) => {
|
|
314
|
-
isDirty = Boolean(v);
|
|
315
|
-
if (!isDirty && pendingReload) location.reload();
|
|
316
|
-
},
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
const es = new EventSource(${JSON.stringify(HMR_PATH)});
|
|
320
|
-
es.addEventListener("hello", (ev) => {
|
|
321
|
-
const id = JSON.parse(ev.data).bootId;
|
|
322
|
-
if (bootId === null) { bootId = id; return; }
|
|
323
|
-
// bootId changed = the server itself (src/*.ts) was replaced and restarted.
|
|
324
|
-
if (id !== bootId) reload();
|
|
325
|
-
});
|
|
326
|
-
es.addEventListener("change", (ev) => {
|
|
327
|
-
const { kind, files } = JSON.parse(ev.data);
|
|
328
|
-
if (MODE === "preview" && kind === "content") { void swap(); return; }
|
|
329
|
-
if (kind === "content") {
|
|
330
|
-
const onContent = window.__docsHmr && window.__docsHmr.onContent;
|
|
331
|
-
// If registered, leave it to the in-place update and don't reload (the editor swaps
|
|
332
|
-
// body/nav itself). Unregistered (pages without an editor, e.g. the empty 0-doc page)
|
|
333
|
-
// → reload.
|
|
334
|
-
if (onContent) { onContent(files); return; }
|
|
335
|
-
reload();
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
// Client bundle (src/viewer/edit-client.ts / src/core/*.tsx) changed — reload to refetch it.
|
|
339
|
-
reload();
|
|
340
|
-
});
|
|
341
|
-
})();`;
|