@dooc-dev/dooc 0.0.22 → 0.0.23
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 +269 -263
- package/dist/engine/compiler/check.js +17 -0
- package/dist/engine/compiler/export.js +18 -1
- package/dist/engine/compiler/files.js +13 -2
- package/dist/engine/compiler/manifest.js +4 -0
- package/dist/engine/compiler/skills.d.ts +10 -0
- package/dist/engine/compiler/skills.js +95 -0
- package/dist/engine/core/content-metadata.d.ts +7 -1
- package/dist/engine/core/content-metadata.js +52 -18
- package/dist/engine/core/files.d.ts +1 -0
- package/dist/engine/core/files.js +3 -0
- package/dist/frontend/document-application.d.ts +11 -2
- package/dist/frontend/document-application.js +356 -130
- package/dist/frontend/language-picker.js +1 -0
- package/dist/frontend/locales/eng.json +17 -1
- package/dist/frontend/locales/jpn.json +17 -1
- package/dist/frontend/locales/zho.json +17 -1
- package/dist/frontend/mcp-operations.js +57 -1
- package/dist/frontend/nav-focus.d.ts +1 -1
- package/dist/frontend/nav-focus.js +25 -2
- package/dist/frontend/nav-update.js +12 -0
- package/dist/frontend/page-jump.d.ts +3 -0
- package/dist/frontend/page-jump.js +130 -0
- package/dist/frontend/resource-download.d.ts +1 -1
- package/dist/frontend/resource-download.js +118 -28
- package/dist/frontend/resource-library.js +16 -7
- package/dist/frontend/search.js +18 -5
- package/dist/frontend/theme-picker.js +11 -0
- package/dist/manifest.global.js +349 -0
- package/dist/mcp-relay.mjs +71 -1
- package/dist/plugins.global.js +4 -4
- package/dist/server/assets.d.ts +1 -0
- package/dist/server/assets.js +4 -1
- package/dist/server/build-media.d.ts +6 -0
- package/dist/server/build-media.js +136 -0
- package/dist/server/build-output.d.ts +2 -1
- package/dist/server/build-output.js +32 -2
- package/dist/server/build-split.d.ts +15 -0
- package/dist/server/build-split.js +160 -0
- package/dist/server/build.d.ts +6 -1
- package/dist/server/build.js +37 -10
- package/dist/server/cli.js +20 -2
- package/dist/server/mcp.js +14 -1
- package/dist/server/serve.d.ts +21 -2
- package/dist/server/serve.js +26 -20
- package/dist/server/static-client.js +2 -1
- package/dist/server/workspace-server.d.ts +1 -1
- package/dist/server/workspace-server.js +24 -4
- package/dist/subformats.global.js +38 -38
- package/dist/ui.global.js +68 -68
- package/dist/workspace/client.d.ts +1 -1
- package/dist/workspace/client.js +22 -3
- package/dist/workspace/mcp-tools.js +32 -0
- package/dist/workspace/mcp.js +50 -1
- package/dist/workspace/protocol.d.ts +3 -0
- package/dist/workspace/server.d.ts +1 -1
- package/dist/workspace/server.js +14 -3
- package/dist/workspace/site-icon.js +17 -12
- package/dist/workspace/textfile.js +16 -4
- package/dist/workspace-mcp-worker.global.js +234 -119
- package/dist/workspace-reader-mcp-worker.global.js +234 -119
- package/dist/workspace-reader-worker.global.js +234 -119
- package/dist/workspace-worker.global.js +234 -119
- package/package.json +2 -2
package/dist/server/serve.js
CHANGED
|
@@ -19,7 +19,7 @@ import { createDocumentApplication, } from "../frontend/document-application.js"
|
|
|
19
19
|
import { createHistoryOp, parsePerson } from "../workspace/history.js";
|
|
20
20
|
import { WORKSPACE_PATH } from "../workspace/protocol.js";
|
|
21
21
|
import { createWorkspaceServer } from "../workspace/server.js";
|
|
22
|
-
import { readReaderAsset, prebuilt as usePrebuiltAssets } from "./assets.js";
|
|
22
|
+
import { readGraphAssets, readReaderAsset, prebuilt as usePrebuiltAssets } from "./assets.js";
|
|
23
23
|
import { isLocalHost, isLocalToolRequest, runCodeTool, validateCodeTools, validateTextfileCode, } from "./editor-tools.js";
|
|
24
24
|
import { createExtensionManager } from "./extensions.js";
|
|
25
25
|
import { fontCss, readFont } from "./fonts.js";
|
|
@@ -84,6 +84,7 @@ export const createBundleCache = () => {
|
|
|
84
84
|
const PREBUILT = {
|
|
85
85
|
"schema-graph-global.tsx": "flow.global.js",
|
|
86
86
|
"edit-client.ts": "edit.global.js",
|
|
87
|
+
"manifest-client.ts": "manifest.global.js",
|
|
87
88
|
"client-entry.ts": "client.global.js",
|
|
88
89
|
"workspace-worker.ts": "workspace-worker.global.js",
|
|
89
90
|
"ui-client.ts": "ui.global.js",
|
|
@@ -115,6 +116,23 @@ export const bundleClient = async (entry) => {
|
|
|
115
116
|
});
|
|
116
117
|
return out.outputFiles?.[0]?.text ?? "";
|
|
117
118
|
};
|
|
119
|
+
/** Shared ESM diagram chunks for local readers and split publications. */
|
|
120
|
+
export const bundleGraph = async () => {
|
|
121
|
+
if (usePrebuiltAssets)
|
|
122
|
+
return readGraphAssets();
|
|
123
|
+
const esbuild = await import("esbuild");
|
|
124
|
+
const output = await esbuild.build({
|
|
125
|
+
entryPoints: [join(frontendRoot, "schema-graph-global.tsx")],
|
|
126
|
+
bundle: true,
|
|
127
|
+
splitting: true,
|
|
128
|
+
format: "esm",
|
|
129
|
+
target: "es2022",
|
|
130
|
+
outdir: join(pkgRoot, "dist/graph"),
|
|
131
|
+
write: false,
|
|
132
|
+
minify: true,
|
|
133
|
+
});
|
|
134
|
+
return new Map(output.outputFiles.map((file) => [basename(file.path), Buffer.from(file.contents)]));
|
|
135
|
+
};
|
|
118
136
|
export const startServer = async (mode, port = 5179, pluginModule, startup) => {
|
|
119
137
|
// Language adapters are read once; the manifest is re-read by the compiler.
|
|
120
138
|
const siteLanguages = await loadSiteLanguages(root);
|
|
@@ -201,28 +219,14 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
|
|
|
201
219
|
const graphAsset = async (name) => {
|
|
202
220
|
if (usePrebuiltAssets)
|
|
203
221
|
return readReaderAsset(`graph/${name}`).toString("utf8");
|
|
204
|
-
graphChunks ??=
|
|
205
|
-
.then(async (esbuild) => {
|
|
206
|
-
const output = await esbuild.build({
|
|
207
|
-
entryPoints: [join(frontendRoot, "schema-graph-global.tsx")],
|
|
208
|
-
bundle: true,
|
|
209
|
-
splitting: true,
|
|
210
|
-
format: "esm",
|
|
211
|
-
target: "es2022",
|
|
212
|
-
outdir: join(pkgRoot, "dist/graph"),
|
|
213
|
-
write: false,
|
|
214
|
-
minify: true,
|
|
215
|
-
});
|
|
216
|
-
return new Map(output.outputFiles.map((file) => [basename(file.path), file.text]));
|
|
217
|
-
})
|
|
218
|
-
.catch((error) => {
|
|
222
|
+
graphChunks ??= bundleGraph().catch((error) => {
|
|
219
223
|
graphChunks = undefined;
|
|
220
224
|
throw error;
|
|
221
225
|
});
|
|
222
226
|
const js = (await graphChunks).get(name);
|
|
223
227
|
if (js === undefined)
|
|
224
228
|
throw new Error("Diagram asset not found");
|
|
225
|
-
return js;
|
|
229
|
+
return js.toString("utf8");
|
|
226
230
|
};
|
|
227
231
|
const reader = {
|
|
228
232
|
register: handlePlugins.register,
|
|
@@ -330,9 +334,11 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
|
|
|
330
334
|
? "code-worker.ts"
|
|
331
335
|
: mode === "edit" && path === "/assets/edit.js"
|
|
332
336
|
? "edit-client.ts"
|
|
333
|
-
: path === "/assets/
|
|
334
|
-
? "
|
|
335
|
-
:
|
|
337
|
+
: mode === "edit" && path === "/assets/manifest.js"
|
|
338
|
+
? "manifest-client.ts"
|
|
339
|
+
: path === "/assets/ui.js"
|
|
340
|
+
? "ui-client.ts"
|
|
341
|
+
: undefined;
|
|
336
342
|
const graphName = path === "/assets/graph.js"
|
|
337
343
|
? "schema-graph-global.js"
|
|
338
344
|
: /^\/assets\/graph\/([\w-]+\.js)$/.exec(path)?.[1];
|
|
@@ -67,13 +67,14 @@ export const clientAssets = async (server, options = {}) => {
|
|
|
67
67
|
files.set(file, data);
|
|
68
68
|
const entries = {
|
|
69
69
|
edit: "edit-client.ts",
|
|
70
|
+
manifest: "manifest-client.ts",
|
|
70
71
|
ui: "ui-client.ts",
|
|
71
72
|
code: "code-highlight.ts",
|
|
72
73
|
"code-worker": "code-worker.ts",
|
|
73
74
|
graph: "schema-graph-global.tsx",
|
|
74
75
|
};
|
|
75
76
|
for (const [name, entry] of Object.entries(entries)) {
|
|
76
|
-
if (name === "edit" && options.readOnly)
|
|
77
|
+
if ((name === "edit" || name === "manifest") && options.readOnly)
|
|
77
78
|
continue;
|
|
78
79
|
files.set(`assets/${name}.js`, Buffer.from(await bundleClient(entry)));
|
|
79
80
|
}
|
|
@@ -18,7 +18,7 @@ export declare const nodeWorkspaceOperations: (manifest: string, pluginModule?:
|
|
|
18
18
|
user?: Person;
|
|
19
19
|
origin?: string;
|
|
20
20
|
pluginSession?: string;
|
|
21
|
-
}) => Promise<unknown>;
|
|
21
|
+
}, signal?: AbortSignal) => Promise<unknown>;
|
|
22
22
|
};
|
|
23
23
|
plugins: ((req: import("http").IncomingMessage, res: import("http").ServerResponse) => Promise<boolean>) & import("./plugin-config.js").ReaderPluginRegistry & {
|
|
24
24
|
loginLink: (plugin: string, origin: string, session?: string) => string;
|
|
@@ -349,13 +349,16 @@ export const nodeWorkspaceOperations = async (manifest, pluginModule, notify = (
|
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
351
|
const queues = new Map();
|
|
352
|
+
const reads = new Map();
|
|
353
|
+
const gitReads = new Map();
|
|
352
354
|
const serial = Object.fromEntries(Object.entries(ops).map(([name, operation]) => [
|
|
353
355
|
name,
|
|
354
|
-
(input, session) => {
|
|
356
|
+
(input, session, signal) => {
|
|
355
357
|
if (readOnly || session.readOnly)
|
|
356
358
|
assertReadOnlyOperation(name, input);
|
|
357
359
|
const id = typeof input.workspace === "string" ? input.workspace : "main";
|
|
358
360
|
const run = async () => {
|
|
361
|
+
signal?.throwIfAborted();
|
|
359
362
|
let target = entry(input);
|
|
360
363
|
if (readOnly &&
|
|
361
364
|
target.description.revision &&
|
|
@@ -375,10 +378,27 @@ export const nodeWorkspaceOperations = async (manifest, pluginModule, notify = (
|
|
|
375
378
|
if (name !== "http" || input.method !== "GET")
|
|
376
379
|
assertReadOnlyOperation(name, input, !readOnly);
|
|
377
380
|
}
|
|
378
|
-
|
|
381
|
+
signal?.throwIfAborted();
|
|
382
|
+
return operation({ ...input, workspace: target.description.id }, session, signal);
|
|
379
383
|
};
|
|
380
|
-
const
|
|
381
|
-
|
|
384
|
+
const reading = (name === "http" && input.method === "GET") ||
|
|
385
|
+
(name === "files" && ["read", "complete"].includes(String(input.action))) ||
|
|
386
|
+
(name === "git" && ["read", "branches", "diff"].includes(String(input.action)));
|
|
387
|
+
const active = reads.get(id) ?? new Set();
|
|
388
|
+
reads.set(id, active);
|
|
389
|
+
// Reads share a snapshot between writes; slow remote Git reads do not hold up navigation.
|
|
390
|
+
const before = reading
|
|
391
|
+
? [queues.get(id), ...(name === "git" ? [gitReads.get(id)] : [])]
|
|
392
|
+
: [queues.get(id), ...active];
|
|
393
|
+
const next = Promise.allSettled(before).then(run);
|
|
394
|
+
if (reading) {
|
|
395
|
+
active.add(next);
|
|
396
|
+
void next.then(() => active.delete(next), () => active.delete(next));
|
|
397
|
+
if (name === "git")
|
|
398
|
+
gitReads.set(id, next.catch(() => { }));
|
|
399
|
+
}
|
|
400
|
+
else
|
|
401
|
+
queues.set(id, next.catch(() => { }));
|
|
382
402
|
return next;
|
|
383
403
|
},
|
|
384
404
|
]));
|