@dooc-dev/dooc 0.0.27 → 0.0.29
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 -1
- package/dist/edit.global.js +220 -221
- package/dist/engine/compiler/check.js +5 -3
- package/dist/engine/compiler/compile.d.ts +5 -0
- package/dist/engine/compiler/compile.js +44 -23
- package/dist/engine/compiler/dialect.js +1 -1
- package/dist/engine/compiler/document-diff.d.ts +53 -0
- package/dist/engine/compiler/document-diff.js +92 -0
- package/dist/engine/compiler/export.js +11 -3
- package/dist/engine/compiler/files.d.ts +1 -0
- package/dist/engine/compiler/files.js +75 -14
- package/dist/engine/compiler/format-collections.js +8 -2
- package/dist/engine/compiler/from-mdast.js +12 -1
- package/dist/engine/compiler/icons.d.ts +7 -7
- package/dist/engine/compiler/icons.js +35 -37
- package/dist/engine/compiler/manifest.d.ts +1 -0
- package/dist/engine/compiler/manifest.js +25 -0
- package/dist/engine/compiler/ops.d.ts +2 -2
- package/dist/engine/compiler/ops.js +55 -112
- package/dist/engine/compiler/resource-index.js +4 -4
- package/dist/engine/compiler/root-page.d.ts +13 -0
- package/dist/engine/compiler/root-page.js +96 -0
- package/dist/engine/compiler/sidebar-removal.d.ts +63 -0
- package/dist/engine/compiler/sidebar-removal.js +317 -0
- package/dist/engine/compiler/subformats.d.ts +3 -0
- package/dist/engine/compiler/subformats.js +126 -32
- package/dist/engine/core/blocks.d.ts +5 -0
- package/dist/engine/core/content-metadata.d.ts +9 -4
- package/dist/engine/core/content-metadata.js +100 -16
- package/dist/engine/core/file-embed.d.ts +2 -1
- package/dist/engine/core/file-embed.js +4 -0
- package/dist/engine/core/files.d.ts +1 -0
- package/dist/engine/core/files.js +6 -1
- package/dist/engine/core/format-collections.js +2 -2
- package/dist/engine/core/formats.d.ts +1 -1
- package/dist/engine/core/formats.js +1 -1
- package/dist/engine/core/html.d.ts +1 -0
- package/dist/engine/core/html.js +9 -5
- package/dist/engine/core/icons.d.ts +7 -0
- package/dist/engine/core/icons.js +38 -0
- package/dist/engine/core/subformats.d.ts +2 -1
- package/dist/engine/core/subformats.js +6 -1
- package/dist/engine/core/toc-library.d.ts +5 -0
- package/dist/engine/core/toc-library.js +27 -0
- package/dist/frontend/document-application.d.ts +5 -2
- package/dist/frontend/document-application.js +403 -189
- package/dist/frontend/edit-dialog.d.ts +1 -0
- package/dist/frontend/edit-dialog.js +12 -8
- package/dist/frontend/file-references.js +1 -1
- package/dist/frontend/locales/eng.json +62 -1
- package/dist/frontend/locales/jpn.json +62 -1
- package/dist/frontend/locales/zho.json +62 -1
- package/dist/frontend/page-jump.js +17 -10
- package/dist/frontend/resize.js +38 -12
- package/dist/frontend/resource-library.js +1 -0
- package/dist/frontend/search.js +2 -0
- package/dist/frontend/theme-picker.d.ts +2 -2
- package/dist/frontend/theme-picker.js +2 -2
- package/dist/manifest.global.js +193 -192
- package/dist/mcp-relay.mjs +8 -4
- package/dist/plugins.global.js +49 -49
- package/dist/server/build.js +11 -8
- package/dist/server/cli.js +18 -1
- package/dist/server/document-diff-cli.d.ts +1 -0
- package/dist/server/document-diff-cli.js +193 -0
- package/dist/server/document-diff-report.d.ts +3 -0
- package/dist/server/document-diff-report.js +124 -0
- package/dist/server/document-diff-sources.d.ts +40 -0
- package/dist/server/document-diff-sources.js +128 -0
- package/dist/server/document-versions.d.ts +3 -1
- package/dist/server/document-versions.js +19 -70
- package/dist/server/git-diff.d.ts +1 -0
- package/dist/server/git-diff.js +22 -2
- package/dist/server/git-document-snapshot.d.ts +2 -0
- package/dist/server/git-document-snapshot.js +63 -0
- package/dist/server/operation-log.js +2 -0
- package/dist/server/serve.d.ts +2 -2
- package/dist/server/serve.js +4 -9
- package/dist/server/workspace-server.js +6 -10
- package/dist/subformats.global.js +478 -74
- package/dist/ui.global.js +435 -80
- package/dist/workspace/file-operation.d.ts +10 -0
- package/dist/workspace/file-operation.js +47 -0
- package/dist/workspace/mcp-tools.js +8 -4
- package/dist/workspace/site-icon.js +30 -23
- package/dist/workspace/textfile.js +8 -8
- package/dist/workspace-worker.global.js +241 -197
- package/package.json +2 -2
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
1
|
+
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
2
|
import { tmpdir } from "node:os";
|
|
4
|
-
import {
|
|
5
|
-
import { promisify } from "node:util";
|
|
6
|
-
import { unzipSync } from "fflate";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
7
4
|
import { exportEntries } from "../engine/compiler/export.js";
|
|
8
5
|
import { manifestFile, projectRoot, readManifest } from "../engine/compiler/manifest.js";
|
|
9
6
|
import { storedDocumentVersions, storedVersionRoot, } from "../engine/compiler/stored-versions.js";
|
|
@@ -11,70 +8,29 @@ import { textfilePath } from "../engine/compiler/textfile.js";
|
|
|
11
8
|
import { versionInput } from "../engine/compiler/version-input.js";
|
|
12
9
|
import { advanceVersion, parseVersionConfig, parseVersionSelection, selectVersions, } from "../engine/core/document-version.js";
|
|
13
10
|
import { git } from "./git.js";
|
|
11
|
+
import { gitDocumentSnapshot } from "./git-document-snapshot.js";
|
|
14
12
|
import { prepareDocumentSources } from "./remote-manifests.js";
|
|
15
13
|
import { gitHeadFile } from "./workspace.js";
|
|
16
14
|
/** Historical sources live in disposable folders; viewing never changes a checkout. */
|
|
17
|
-
export const createDocumentVersions = (root, name = manifestFile(root)) => {
|
|
15
|
+
export const createDocumentVersions = (root, name = manifestFile(root), prepareSources = prepareDocumentSources) => {
|
|
18
16
|
let temporary;
|
|
19
17
|
let cachedHead = "";
|
|
20
18
|
let pending;
|
|
21
19
|
const snapshots = new Map();
|
|
22
20
|
const revisionVersions = new Map();
|
|
23
21
|
const folder = () => (temporary ??= mkdtempSync(join(tmpdir(), "dooc-versions-")));
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
`${revision}${prefix ? `:${prefix}` : ""}`,
|
|
35
|
-
], { encoding: "buffer", maxBuffer: 256 * 1024 * 1024, timeout: 30_000 });
|
|
36
|
-
mkdirSync(destination, { recursive: true });
|
|
37
|
-
let total = 0;
|
|
38
|
-
const files = unzipSync(stdout, {
|
|
39
|
-
filter(file) {
|
|
40
|
-
total += file.originalSize;
|
|
41
|
-
if (total > 256 * 1024 * 1024)
|
|
42
|
-
throw new Error("Historical document exceeds 256 MiB");
|
|
43
|
-
return !file.name.endsWith("/");
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
for (const [name, data] of Object.entries(files)) {
|
|
47
|
-
// Git already selected tracked files; snapshot folders must not reapply ignore rules.
|
|
48
|
-
if (basename(name) === ".gitignore" || name.split("/").includes(".git"))
|
|
49
|
-
continue;
|
|
50
|
-
const path = textfilePath(destination, name);
|
|
51
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
52
|
-
writeFileSync(path, data);
|
|
53
|
-
}
|
|
54
|
-
const tree = await git(repository, [
|
|
55
|
-
"ls-tree",
|
|
56
|
-
"-r",
|
|
57
|
-
"-z",
|
|
58
|
-
`${revision}${prefix ? `:${prefix}` : ""}`,
|
|
59
|
-
]);
|
|
60
|
-
for (const item of tree.split("\0")) {
|
|
61
|
-
if (!item.startsWith("120000 "))
|
|
62
|
-
continue;
|
|
63
|
-
const name = item.slice(item.indexOf("\t") + 1);
|
|
64
|
-
if (!files[name] || basename(name) === ".gitignore" || name.split("/").includes(".git"))
|
|
65
|
-
continue;
|
|
66
|
-
const target = Buffer.from(files[name]).toString("utf8");
|
|
67
|
-
const resolved = relative(destination, resolve(destination, dirname(name), target));
|
|
68
|
-
if (isAbsolute(target) ||
|
|
69
|
-
resolved === ".." ||
|
|
70
|
-
resolved.startsWith("../") ||
|
|
71
|
-
isAbsolute(resolved))
|
|
72
|
-
throw new Error("Historical symlink points outside the document root");
|
|
73
|
-
const path = textfilePath(destination, name);
|
|
74
|
-
unlinkSync(path);
|
|
75
|
-
symlinkSync(target, path);
|
|
22
|
+
const openCommit = (revision) => {
|
|
23
|
+
let snapshot = snapshots.get(revision);
|
|
24
|
+
if (!snapshot) {
|
|
25
|
+
const destination = mkdtempSync(join(folder(), "commit-"));
|
|
26
|
+
snapshot = gitDocumentSnapshot(root, name, revision, destination).catch((error) => {
|
|
27
|
+
snapshots.delete(revision);
|
|
28
|
+
rmSync(destination, { recursive: true, force: true });
|
|
29
|
+
throw error;
|
|
30
|
+
});
|
|
31
|
+
snapshots.set(revision, snapshot);
|
|
76
32
|
}
|
|
77
|
-
return
|
|
33
|
+
return snapshot;
|
|
78
34
|
};
|
|
79
35
|
const load = async (head) => {
|
|
80
36
|
revisionVersions.clear();
|
|
@@ -94,8 +50,8 @@ export const createDocumentVersions = (root, name = manifestFile(root)) => {
|
|
|
94
50
|
continue;
|
|
95
51
|
}
|
|
96
52
|
try {
|
|
97
|
-
const snapshot = await
|
|
98
|
-
await
|
|
53
|
+
const snapshot = await gitDocumentSnapshot(root, name, revision, scratch);
|
|
54
|
+
await prepareSources?.(snapshot);
|
|
99
55
|
const manifest = readManifest(snapshot);
|
|
100
56
|
if (manifest.errors.length)
|
|
101
57
|
throw new Error(manifest.errors.join("\n"));
|
|
@@ -162,6 +118,7 @@ export const createDocumentVersions = (root, name = manifestFile(root)) => {
|
|
|
162
118
|
return {
|
|
163
119
|
enabled: () => !!gitHeadFile(root) || !!readManifest(root, name).version,
|
|
164
120
|
list,
|
|
121
|
+
openCommit,
|
|
165
122
|
async versionAt(revision) {
|
|
166
123
|
const rows = await list();
|
|
167
124
|
const exact = revisionVersions.get(revision) ??
|
|
@@ -186,15 +143,7 @@ export const createDocumentVersions = (root, name = manifestFile(root)) => {
|
|
|
186
143
|
}
|
|
187
144
|
if (revision.startsWith("hash-"))
|
|
188
145
|
return storedVersionRoot(root, revision, name);
|
|
189
|
-
|
|
190
|
-
if (!snapshot) {
|
|
191
|
-
snapshot = archive(revision, join(folder(), revision)).catch((error) => {
|
|
192
|
-
snapshots.delete(revision);
|
|
193
|
-
throw error;
|
|
194
|
-
});
|
|
195
|
-
snapshots.set(revision, snapshot);
|
|
196
|
-
}
|
|
197
|
-
return snapshot;
|
|
146
|
+
return openCommit(revision);
|
|
198
147
|
},
|
|
199
148
|
close() {
|
|
200
149
|
if (temporary && existsSync(temporary))
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SubformatCollection } from "../engine/core/subformats.js";
|
|
2
|
+
export declare function changedTrackedFiles(root: string): Promise<Set<string>>;
|
|
2
3
|
/**
|
|
3
4
|
* `revision` identifies the working tree contents (filesSnapshot); with it the status is reused
|
|
4
5
|
* until the files, the index or HEAD change.
|
package/dist/server/git-diff.js
CHANGED
|
@@ -3,8 +3,28 @@ import { isDeepStrictEqual } from "node:util";
|
|
|
3
3
|
import { parseDoc } from "../engine/compiler/dialect.js";
|
|
4
4
|
import { manifestFile, parseManifestText } from "../engine/compiler/manifest.js";
|
|
5
5
|
import { textfilePath } from "../engine/compiler/textfile.js";
|
|
6
|
-
import { parseGitChanges } from "./git.js";
|
|
7
|
-
import { gitSignature } from "./workspace.js";
|
|
6
|
+
import { git, parseGitChanges } from "./git.js";
|
|
7
|
+
import { gitHeadFile, gitSignature } from "./workspace.js";
|
|
8
|
+
export async function changedTrackedFiles(root) {
|
|
9
|
+
if (!gitHeadFile(root))
|
|
10
|
+
return new Set();
|
|
11
|
+
const head = (await git(root, ["rev-parse", "--revs-only", "HEAD"])).trim();
|
|
12
|
+
if (!head)
|
|
13
|
+
return new Set();
|
|
14
|
+
const paths = await git(root, [
|
|
15
|
+
"diff",
|
|
16
|
+
"--relative",
|
|
17
|
+
"--name-only",
|
|
18
|
+
"-z",
|
|
19
|
+
"--no-renames",
|
|
20
|
+
"--no-ext-diff",
|
|
21
|
+
"--diff-filter=MTU",
|
|
22
|
+
head,
|
|
23
|
+
"--",
|
|
24
|
+
".",
|
|
25
|
+
]);
|
|
26
|
+
return new Set(paths.split("\0").filter(Boolean));
|
|
27
|
+
}
|
|
8
28
|
// Git answers are reused until the metadata they were read from changes (see gitSignature).
|
|
9
29
|
const memo = new Map();
|
|
10
30
|
const remember = (scope, signature, key, read) => {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { mkdirSync, symlinkSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { projectRoot } from "../engine/compiler/manifest.js";
|
|
6
|
+
import { textfilePath } from "../engine/compiler/textfile.js";
|
|
7
|
+
import { git } from "./git.js";
|
|
8
|
+
/** Read exact blobs and modes. Git archives can omit or rewrite sources through .gitattributes. */
|
|
9
|
+
export const gitDocumentSnapshot = async (root, manifest, revision, destination) => {
|
|
10
|
+
if (!/^[a-f\d]{40}(?:[a-f\d]{24})?$/.test(revision))
|
|
11
|
+
throw new Error("Invalid document revision");
|
|
12
|
+
const tree = await git(root, ["ls-tree", "-rlz", revision, "--", "."]);
|
|
13
|
+
const entries = [];
|
|
14
|
+
let bytes = 0;
|
|
15
|
+
for (const record of tree.split("\0")) {
|
|
16
|
+
const tab = record.indexOf("\t");
|
|
17
|
+
const [mode, type, id, length] = record.slice(0, tab).split(/\s+/);
|
|
18
|
+
const name = record.slice(tab + 1);
|
|
19
|
+
// The tree contains tracked files only. Reapplying its ignore rules would hide tracked inputs.
|
|
20
|
+
if (type !== "blob" ||
|
|
21
|
+
!id ||
|
|
22
|
+
basename(name) === ".gitignore" ||
|
|
23
|
+
name.split("/").includes(".git"))
|
|
24
|
+
continue;
|
|
25
|
+
const size = Number(length);
|
|
26
|
+
bytes += size;
|
|
27
|
+
if (bytes > 256 * 1024 * 1024)
|
|
28
|
+
throw new Error("Historical document exceeds 256 MiB");
|
|
29
|
+
entries.push({ name, id, mode, size });
|
|
30
|
+
}
|
|
31
|
+
const batch = promisify(execFile)("git", ["-C", root, "cat-file", "--batch"], {
|
|
32
|
+
encoding: "buffer",
|
|
33
|
+
timeout: 30_000,
|
|
34
|
+
maxBuffer: bytes + entries.length * 128 + 1024,
|
|
35
|
+
});
|
|
36
|
+
batch.child.stdin?.on("error", () => {
|
|
37
|
+
/* execFile reports process failures. */
|
|
38
|
+
});
|
|
39
|
+
batch.child.stdin?.end(entries.map((entry) => entry.id).join("\n") + (entries.length ? "\n" : ""));
|
|
40
|
+
const { stdout } = await batch;
|
|
41
|
+
mkdirSync(destination, { recursive: true });
|
|
42
|
+
let offset = 0;
|
|
43
|
+
for (const { name, id, mode, size } of entries) {
|
|
44
|
+
const end = stdout.indexOf(10, offset);
|
|
45
|
+
if (stdout.toString("ascii", offset, end) !== `${id} blob ${size}` ||
|
|
46
|
+
stdout[end + size + 1] !== 10)
|
|
47
|
+
throw new Error(`Incomplete historical blob: ${name}`);
|
|
48
|
+
const data = stdout.subarray(end + 1, end + 1 + size);
|
|
49
|
+
offset = end + size + 2;
|
|
50
|
+
const path = textfilePath(destination, name);
|
|
51
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
52
|
+
if (mode === "120000") {
|
|
53
|
+
const target = data.toString("utf8");
|
|
54
|
+
const rel = relative(destination, resolve(dirname(path), target));
|
|
55
|
+
if (isAbsolute(target) || rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel))
|
|
56
|
+
throw new Error("Historical symlink points outside the document root");
|
|
57
|
+
symlinkSync(target, path);
|
|
58
|
+
}
|
|
59
|
+
else
|
|
60
|
+
writeFileSync(path, data, { mode: mode === "100755" ? 0o755 : 0o644 });
|
|
61
|
+
}
|
|
62
|
+
return projectRoot(join(destination, manifest));
|
|
63
|
+
};
|
package/dist/server/serve.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type ServeMode } from "../frontend/document-application.js";
|
|
|
3
3
|
import { type ReaderRuntime } from "./plugin-config.js";
|
|
4
4
|
export type { EditorBoot, Entry, ServeMode, Site, } from "../frontend/document-application.js";
|
|
5
5
|
export { assembleDoc };
|
|
6
|
-
export declare const clientShell: (readOnly?: boolean) => string, siteFrom: ({ title, icon, iconVariants, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, subformats, }: import("../engine/compiler/compile.js").Compiled, languages?: readonly import("./index.js").LanguageAdapter[], code?: Pick<import("./languages.js").SiteLanguages, "codeLanguages" | "codeGrammars">) => import("../frontend/document-application.js").Site, filePreviewResults: (entry: import("../frontend/document-application.js").Entry, site: import("../frontend/document-application.js").Site) => import("../frontend/file-references.js").FilePreviewResults, renderEntryHtml: (site: import("../frontend/document-application.js").Site, entry: import("../frontend/document-application.js").Entry) => {
|
|
6
|
+
export declare const clientShell: (readOnly?: boolean) => string, siteFrom: ({ title, icon, iconVariants, accentColor, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, subformats, }: import("../engine/compiler/compile.js").Compiled, languages?: readonly import("./index.js").LanguageAdapter[], code?: Pick<import("./languages.js").SiteLanguages, "codeLanguages" | "codeGrammars">) => import("../frontend/document-application.js").Site, filePreviewResults: (entry: import("../frontend/document-application.js").Entry, site: import("../frontend/document-application.js").Site) => import("../frontend/file-references.js").FilePreviewResults, renderEntryHtml: (site: import("../frontend/document-application.js").Site, entry: import("../frontend/document-application.js").Entry) => {
|
|
7
7
|
html: string;
|
|
8
8
|
errors: string[];
|
|
9
9
|
}, renderDocFile: (site: import("../frontend/document-application.js").Site, file: string, raw: string) => {
|
|
@@ -26,7 +26,7 @@ export declare const clientShell: (readOnly?: boolean) => string, siteFrom: ({ t
|
|
|
26
26
|
id: string;
|
|
27
27
|
name: string;
|
|
28
28
|
abs: string;
|
|
29
|
-
} | undefined, navGroupsHtml: (mode: ServeMode, site: Pick<import("../frontend/document-application.js").Site, "title" | "icon" | "themes" | "subformats" | "workspace" | "contentLanguage"> & {
|
|
29
|
+
} | undefined, navGroupsHtml: (mode: ServeMode, site: Pick<import("../frontend/document-application.js").Site, "uploadDirectory" | "title" | "icon" | "themes" | "accentColor" | "subformats" | "iconVariants" | "workspace" | "contentLanguage"> & {
|
|
30
30
|
entries: {
|
|
31
31
|
id: string;
|
|
32
32
|
file: string;
|
package/dist/server/serve.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { completeFilePaths, filesSnapshot, updateFiles, uploadFile, } from "../engine/compiler/files.js";
|
|
2
1
|
import { MAX_FILE_UPLOAD_BYTES } from "../engine/core/files.js";
|
|
2
|
+
import { fileOperation } from "../workspace/file-operation.js";
|
|
3
3
|
// Combined Node reader: serves frontend assets and the shared document application.
|
|
4
4
|
// Workspace requests and change notifications travel over a same-origin WebSocket.
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
@@ -25,7 +25,7 @@ import { createExtensionManager } from "./extensions.js";
|
|
|
25
25
|
import { fontCss, readFont } from "./fonts.js";
|
|
26
26
|
import { frameBlocked } from "./frame-policy.js";
|
|
27
27
|
import { createGitHandler, validateGitOrigin } from "./git.js";
|
|
28
|
-
import { gitBaseBody, gitBaseText, setSubformatChanges } from "./git-diff.js";
|
|
28
|
+
import { changedTrackedFiles, gitBaseBody, gitBaseText, setSubformatChanges } from "./git-diff.js";
|
|
29
29
|
import { workspaceHistory } from "./history.js";
|
|
30
30
|
import { watchProject } from "./hmr.js";
|
|
31
31
|
import { loadSiteLanguages } from "./languages.js";
|
|
@@ -51,6 +51,7 @@ const application = createDocumentApplication(root, {
|
|
|
51
51
|
sourceFileBase,
|
|
52
52
|
gitBaseBody,
|
|
53
53
|
gitBaseText,
|
|
54
|
+
changedTrackedFiles,
|
|
54
55
|
setSubformatChanges,
|
|
55
56
|
runCodeTool,
|
|
56
57
|
validateCodeTools,
|
|
@@ -163,13 +164,7 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
|
|
|
163
164
|
session.user = parsePerson(input);
|
|
164
165
|
return session.user;
|
|
165
166
|
},
|
|
166
|
-
files: (input) => input
|
|
167
|
-
? completeFilePaths(root, input.prefix)
|
|
168
|
-
: input.action === "read"
|
|
169
|
-
? filesSnapshot(root)
|
|
170
|
-
: input.action === "upload"
|
|
171
|
-
? uploadFile(root, input)
|
|
172
|
-
: updateFiles(root, input),
|
|
167
|
+
files: (input) => fileOperation(root, input),
|
|
173
168
|
git: async (input, session) => {
|
|
174
169
|
if (!session.local)
|
|
175
170
|
throw new Error("Git requires a same-origin local editor request");
|
|
@@ -2,7 +2,6 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { existsSync, mkdirSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, join, resolve } from "node:path";
|
|
4
4
|
import { WebSocketServer } from "ws";
|
|
5
|
-
import { completeFilePaths, filesSnapshot, updateFiles, uploadFile, } from "../engine/compiler/files.js";
|
|
6
5
|
import { manifestFile, projectRoot, readManifest, sectionManifest, } from "../engine/compiler/manifest.js";
|
|
7
6
|
import { flattenTree } from "../engine/core/content-metadata.js";
|
|
8
7
|
import { latestVersionOnly, parseVersionSelection, selectVersions, } from "../engine/core/document-version.js";
|
|
@@ -12,6 +11,7 @@ import { docPath } from "../engine/core/routing.js";
|
|
|
12
11
|
import { parseWorkspaceSource } from "../engine/core/workspace.js";
|
|
13
12
|
import { applicationRequest, } from "../frontend/application-request.js";
|
|
14
13
|
import { createDocumentApplication } from "../frontend/document-application.js";
|
|
14
|
+
import { fileOperation } from "../workspace/file-operation.js";
|
|
15
15
|
import { createHistoryOp, parsePerson } from "../workspace/history.js";
|
|
16
16
|
import { assertReadOnlyOperation } from "../workspace/read-only.js";
|
|
17
17
|
import { createWorkspaceServer } from "../workspace/server.js";
|
|
@@ -21,7 +21,7 @@ import { createExtensionManager } from "./extensions.js";
|
|
|
21
21
|
import { fontCss } from "./fonts.js";
|
|
22
22
|
import { frameBlocked } from "./frame-policy.js";
|
|
23
23
|
import { createGitHandler, git, gitManifestPath, gitWorktrees, hasGitManifest, validateGitOrigin, } from "./git.js";
|
|
24
|
-
import { gitBaseBody, gitBaseText, setSubformatChanges } from "./git-diff.js";
|
|
24
|
+
import { changedTrackedFiles, gitBaseBody, gitBaseText, setSubformatChanges } from "./git-diff.js";
|
|
25
25
|
import { workspaceHistory } from "./history.js";
|
|
26
26
|
import { watchProject } from "./hmr.js";
|
|
27
27
|
import { DEFAULT_SITE_LANGUAGES, loadSiteLanguages } from "./languages.js";
|
|
@@ -97,6 +97,7 @@ export const nodeWorkspaceOperations = async (manifest, pluginModule, notify = (
|
|
|
97
97
|
sourceFileBase,
|
|
98
98
|
gitBaseBody,
|
|
99
99
|
gitBaseText,
|
|
100
|
+
changedTrackedFiles,
|
|
100
101
|
setSubformatChanges,
|
|
101
102
|
runCodeTool,
|
|
102
103
|
validateCodeTools,
|
|
@@ -305,13 +306,7 @@ export const nodeWorkspaceOperations = async (manifest, pluginModule, notify = (
|
|
|
305
306
|
},
|
|
306
307
|
files: (input) => {
|
|
307
308
|
const { root } = entry(input);
|
|
308
|
-
return input
|
|
309
|
-
? filesSnapshot(root)
|
|
310
|
-
: input.action === "complete"
|
|
311
|
-
? completeFilePaths(root, input.prefix)
|
|
312
|
-
: input.action === "upload"
|
|
313
|
-
? uploadFile(root, input)
|
|
314
|
-
: updateFiles(root, input);
|
|
309
|
+
return fileOperation(root, input);
|
|
315
310
|
},
|
|
316
311
|
git: (input, session) => {
|
|
317
312
|
if (!session.local)
|
|
@@ -382,7 +377,8 @@ export const nodeWorkspaceOperations = async (manifest, pluginModule, notify = (
|
|
|
382
377
|
return operation({ ...input, workspace: target.description.id }, session, signal);
|
|
383
378
|
};
|
|
384
379
|
const reading = (name === "http" && input.method === "GET") ||
|
|
385
|
-
(name === "files" &&
|
|
380
|
+
(name === "files" &&
|
|
381
|
+
["read", "complete", "hashes", "icon-preview"].includes(String(input.action))) ||
|
|
386
382
|
(name === "git" &&
|
|
387
383
|
["read", "branches", "diff", "prFiles"].includes(String(input.action)));
|
|
388
384
|
const active = reads.get(id) ?? new Set();
|