@yugoo-design/dsh-design-studio-dsh 0.1.2 → 0.2.0
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/README.md +427 -3
- package/lib/authoring/panel-components.json +10790 -0
- package/lib/authoring/studio-creators/material.json +1 -0
- package/lib/authoring-agent-Ci08ifdJ.js +634 -0
- package/lib/authoring-agent.d.ts +24 -0
- package/lib/authoring-agent.js +2 -0
- package/lib/authoring-agent.types-QLa61eE6.d.ts +88 -0
- package/lib/authoring-entry.d.ts +20 -0
- package/lib/authoring-entry.js +77 -0
- package/lib/authoring-host-BlsA6wXz.js +347 -0
- package/lib/authoring-host.d.ts +5 -0
- package/lib/authoring-host.js +2 -0
- package/lib/authoring-host.types-d5UT0WEk.d.ts +77 -0
- package/lib/authoring-reference-store.d.ts +39 -0
- package/lib/authoring-reference-store.js +385 -0
- package/lib/authoring-service-qGEk-IE_.js +342 -0
- package/lib/authoring-service.d.ts +112 -0
- package/lib/authoring-service.js +2 -0
- package/lib/authoring-session.d.ts +5 -0
- package/lib/authoring-session.js +203 -0
- package/lib/authoring-session.types-MHEaEFkO.d.ts +58 -0
- package/lib/authoring-sources-BzRuEuub.d.ts +17 -0
- package/lib/authoring-sources.d.ts +2 -0
- package/lib/authoring-sources.js +85 -0
- package/lib/authoring-workbench.d.ts +15 -0
- package/lib/authoring-workbench.js +782 -0
- package/lib/authoring.page-rpc-Bg6VAT0Z.d.ts +30 -0
- package/lib/authoring.page-rpc.d.ts +2 -0
- package/lib/authoring.page-rpc.js +55 -0
- package/lib/authoring.remote-client.d.ts +2557 -0
- package/lib/authoring.remote-client.js +435 -0
- package/lib/client-adapter-BgD1mpCC.d.ts +65 -0
- package/lib/client-adapter.d.ts +2 -64
- package/lib/client.js +1 -2
- package/lib/css-assets/dsh-design-studio-page/9178281a0695f79ff8bff8eca529231b67f896dc1c12c8dbaaad24b32dd3fc07.eot +0 -0
- package/lib/css-assets/dsh-design-studio-page/b366faf39f6bcc48f10b10f2860e5ebe57091cb2a15beeed8a0977e24560bbba.svg +224 -0
- package/lib/css-assets/dsh-design-studio-page/manifest.json +20 -0
- package/lib/index.js +4 -105
- package/lib/kit-files-DKBlBOG8.js +159 -0
- package/lib/page-client.js +4 -23849
- package/lib/page-path-Bj5jO20L.d.ts +25 -0
- package/lib/page-path.d.ts +2 -2
- package/lib/page-path.js +70 -2
- package/lib/page-rpc-DiazVY00.d.ts +24 -0
- package/lib/page-rpc.d.ts +2 -15
- package/lib/page-rpc.js +9 -4
- package/lib/page.d.ts +5 -3
- package/lib/page.js +219 -2
- package/lib/remote-method-ab_lHwWN.js +16 -0
- package/lib/typert.host.d.ts +827 -2
- package/lib/typert.host.js +2 -1
- package/lib/typert.remote-client-CWz-anTr.d.ts +37 -0
- package/lib/typert.remote-client.d.ts +1 -36
- package/licenses/dsh-distribution.json +8644 -149
- package/package.json +73 -10
- package/lib/page-path-wn8e_fid.d.ts +0 -14
package/lib/index.js
CHANGED
|
@@ -1,104 +1,11 @@
|
|
|
1
|
+
import { n as openInstalledSourceFiles, t as kitFileError } from "./kit-files-DKBlBOG8.js";
|
|
2
|
+
import { t as markStudioRemote } from "./remote-method-ab_lHwWN.js";
|
|
1
3
|
import { createRequire } from "node:module";
|
|
2
4
|
import { Service } from "@deepseek-ai/cordis";
|
|
3
|
-
import {
|
|
5
|
+
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
4
6
|
import { DesignKitVersion } from "@yugoo-design/dsh-design-core";
|
|
5
7
|
import { StudioBinaryContentError, StudioBundleSourceService, StudioManagementService, loadStudioKit, snapshotKit } from "@yugoo-design/dsh-design-studio";
|
|
6
8
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
7
|
-
//#region src/kit-files.ts
|
|
8
|
-
/** Installed source reads share the same DSH filesystem containment boundary. */
|
|
9
|
-
const MAX_TEXT_BYTES = 1048576;
|
|
10
|
-
const excludedDirectory = (name) => /^(?:\.git|node_modules)$/iu.test(name);
|
|
11
|
-
/** A code survives the Remote gateway while the message remains useful in the viewer. */
|
|
12
|
-
function kitFileError(code, message) {
|
|
13
|
-
return Object.assign(/* @__PURE__ */ new Error(`${code}: ${message}`), { code });
|
|
14
|
-
}
|
|
15
|
-
/** One read's installed resource root is the complete filesystem boundary, not its catalog id. */
|
|
16
|
-
async function openInstalledSourceFiles(fs, root, kind = "Bundle") {
|
|
17
|
-
if (!isAbsolute(root)) throw new Error(`design studio dsh: installed ${kind} resource root must be absolute`);
|
|
18
|
-
const base = await fs.resolve(root);
|
|
19
|
-
if ((await fs.stat(base))?.type !== "directory") throw new Error(`design studio dsh: installed ${kind} resource root is not a directory`);
|
|
20
|
-
const target = async (path) => {
|
|
21
|
-
const resolved = await fs.resolve(path);
|
|
22
|
-
if (!fs.contains(base, resolved)) {
|
|
23
|
-
if (kind === "Kit") throw kitFileError("kit_file.path_forbidden", "Path escapes installed Kit resource root.");
|
|
24
|
-
throw new Error(`design studio dsh: path escapes installed ${kind} resource root`);
|
|
25
|
-
}
|
|
26
|
-
return resolved;
|
|
27
|
-
};
|
|
28
|
-
const code = (error) => typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
29
|
-
return {
|
|
30
|
-
async readFile(path) {
|
|
31
|
-
if (typeof path !== "string" || /[\\:\u0000-\u001f\u007f]/u.test(path) || path.split("/").some((part) => !part || part === "." || part === ".." || excludedDirectory(part))) throw kitFileError("kit_file.path_forbidden", "Invalid Kit file path.");
|
|
32
|
-
try {
|
|
33
|
-
const resolved = await target(join(root, path));
|
|
34
|
-
const info = await fs.stat(resolved);
|
|
35
|
-
if (info?.type !== "file") throw kitFileError("kit_file.missing", "Kit file not found or not a regular file.");
|
|
36
|
-
if ((info.size ?? 0) > MAX_TEXT_BYTES) throw kitFileError("kit_file.too_large", "This file exceeds the 1 MiB text viewer limit.");
|
|
37
|
-
const bytes = await fs.readBytes(resolved, void 0, MAX_TEXT_BYTES);
|
|
38
|
-
let content;
|
|
39
|
-
try {
|
|
40
|
-
content = new TextDecoder("utf-8", {
|
|
41
|
-
fatal: true,
|
|
42
|
-
ignoreBOM: true
|
|
43
|
-
}).decode(bytes);
|
|
44
|
-
} catch {
|
|
45
|
-
throw kitFileError("kit_file.binary", "Kit file is binary or invalid UTF-8 text.");
|
|
46
|
-
}
|
|
47
|
-
if (content.includes("\0")) throw kitFileError("kit_file.binary", "Kit file is binary, not UTF-8 text.");
|
|
48
|
-
return { content };
|
|
49
|
-
} catch (error) {
|
|
50
|
-
if (code(error) === "FS_TOO_LARGE") throw kitFileError("kit_file.too_large", "This file exceeds the 1 MiB text viewer limit.");
|
|
51
|
-
if (code(error) === "FS_NOT_FOUND") throw kitFileError("kit_file.missing", "Kit file not found.");
|
|
52
|
-
if (code(error) === "FS_NOT_TEXT") throw kitFileError("kit_file.binary", "Kit file is binary or invalid UTF-8 text.");
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
listKitRoots: async () => [],
|
|
57
|
-
async readText(path) {
|
|
58
|
-
try {
|
|
59
|
-
return await fs.readText(await target(path));
|
|
60
|
-
} catch (error) {
|
|
61
|
-
if (code(error) === "FS_NOT_FOUND") return void 0;
|
|
62
|
-
if (code(error) === "FS_NOT_TEXT") throw new StudioBinaryContentError(path);
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
async listDir(path) {
|
|
67
|
-
try {
|
|
68
|
-
return (await fs.listDir(await target(path))).map((entry) => entry.name);
|
|
69
|
-
} catch (error) {
|
|
70
|
-
if (code(error) === "FS_NOT_FOUND" || code(error) === "FS_NOT_DIRECTORY") return [];
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
async isDirectory(path) {
|
|
75
|
-
try {
|
|
76
|
-
return (await fs.stat(await target(path)))?.type === "directory";
|
|
77
|
-
} catch (error) {
|
|
78
|
-
if (code(error) === "FS_NOT_FOUND") return false;
|
|
79
|
-
throw error;
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
async listFiles(path) {
|
|
83
|
-
const files = [];
|
|
84
|
-
let visited = 0;
|
|
85
|
-
const walk = async (directory, prefix, depth) => {
|
|
86
|
-
if (depth > 32) throw new Error(`design studio dsh: ${kind} file tree exceeds depth limit`);
|
|
87
|
-
for (const entry of await fs.listDir(directory)) {
|
|
88
|
-
if (++visited > 2e4) throw new Error(`design studio dsh: ${kind} file tree exceeds entry limit`);
|
|
89
|
-
if (kind === "Kit" && excludedDirectory(entry.name)) continue;
|
|
90
|
-
if (!fs.contains(base, entry.target)) continue;
|
|
91
|
-
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
92
|
-
if (entry.type === "directory") await walk(entry.target, relative, depth + 1);
|
|
93
|
-
else if (entry.type === "file") files.push(relative);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
await walk(await target(path), "", 0);
|
|
97
|
-
return files.sort();
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
//#endregion
|
|
102
9
|
//#region src/kit-sources.ts
|
|
103
10
|
/** Read-only Kit source access over the DSH host filesystem capability. */
|
|
104
11
|
/**
|
|
@@ -439,15 +346,7 @@ function sourceUnavailable(name, error) {
|
|
|
439
346
|
}] };
|
|
440
347
|
}
|
|
441
348
|
function markRemote(name, method) {
|
|
442
|
-
|
|
443
|
-
kind: "method",
|
|
444
|
-
name,
|
|
445
|
-
static: false,
|
|
446
|
-
private: false,
|
|
447
|
-
addInitializer(initializer) {
|
|
448
|
-
initializer.call(Object.create(DshStudioManagementService.prototype));
|
|
449
|
-
}
|
|
450
|
-
});
|
|
349
|
+
markStudioRemote(DshStudioManagementService.prototype, name, method);
|
|
451
350
|
}
|
|
452
351
|
markRemote("workspace", DshStudioManagementService.prototype.workspace);
|
|
453
352
|
markRemote("readKitWorkspace", DshStudioManagementService.prototype.readKitWorkspace);
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { StudioBinaryContentError } from "@yugoo-design/dsh-design-studio";
|
|
2
|
+
import { isAbsolute, join } from "node:path";
|
|
3
|
+
//#region src/kit-files.ts
|
|
4
|
+
/** Installed source reads share the same DSH filesystem containment boundary. */
|
|
5
|
+
const MAX_TEXT_BYTES = 1048576;
|
|
6
|
+
const excludedDirectory = (name) => /^(?:\.git|node_modules)$/iu.test(name);
|
|
7
|
+
/** A code survives the Remote gateway while the message remains useful in the viewer. */
|
|
8
|
+
function kitFileError(code, message) {
|
|
9
|
+
return Object.assign(/* @__PURE__ */ new Error(`${code}: ${message}`), { code });
|
|
10
|
+
}
|
|
11
|
+
/** One read's installed resource root is the complete filesystem boundary, not its catalog id. */
|
|
12
|
+
async function openInstalledSourceFiles(fs, root, kind = "Bundle") {
|
|
13
|
+
if (!isAbsolute(root)) throw new Error(`design studio dsh: installed ${kind} resource root must be absolute`);
|
|
14
|
+
const base = await fs.resolve(root);
|
|
15
|
+
if ((await fs.stat(base))?.type !== "directory") throw new Error(`design studio dsh: installed ${kind} resource root is not a directory`);
|
|
16
|
+
const target = async (path) => {
|
|
17
|
+
const resolved = await fs.resolve(path);
|
|
18
|
+
if (!fs.contains(base, resolved)) {
|
|
19
|
+
if (kind === "Kit") throw kitFileError("kit_file.path_forbidden", "Path escapes installed Kit resource root.");
|
|
20
|
+
throw new Error(`design studio dsh: path escapes installed ${kind} resource root`);
|
|
21
|
+
}
|
|
22
|
+
return resolved;
|
|
23
|
+
};
|
|
24
|
+
const code = (error) => typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
25
|
+
return {
|
|
26
|
+
async captureTree() {
|
|
27
|
+
const files = [], seen = /* @__PURE__ */ new Set();
|
|
28
|
+
let visited = 0, total = 0;
|
|
29
|
+
const limit = (message) => kitFileError("studio.source_limit", message);
|
|
30
|
+
const invalid = (message) => kitFileError("studio.source_invalid", message);
|
|
31
|
+
const unchanged = async (item, before) => {
|
|
32
|
+
const after = await fs.stat(item);
|
|
33
|
+
if (!before || !after || before.type !== after.type || before.version !== after.version || before.size !== after.size) throw kitFileError("studio.source_changed", "Installed source changed during capture. Retry the exact source.");
|
|
34
|
+
};
|
|
35
|
+
const walk = async (directory, prefix, observed) => {
|
|
36
|
+
if (seen.has(directory.targetKey)) throw invalid("Repeated directory identity in installed source.");
|
|
37
|
+
seen.add(directory.targetKey);
|
|
38
|
+
const info = observed ?? await fs.stat(directory);
|
|
39
|
+
if (info?.type !== "directory") throw invalid("Installed source directory is missing or not a directory.");
|
|
40
|
+
const entries = await fs.listDir(directory);
|
|
41
|
+
visited += entries.length;
|
|
42
|
+
if (visited > 2e4) throw limit("Installed source exceeds 20000 directory entries.");
|
|
43
|
+
const names = /* @__PURE__ */ new Set();
|
|
44
|
+
for (const entry of entries) {
|
|
45
|
+
if (typeof entry.name !== "string" || !entry.name || /[\\/:\u0000-\u001f\u007f]/u.test(entry.name) || [
|
|
46
|
+
".",
|
|
47
|
+
"..",
|
|
48
|
+
"__proto__",
|
|
49
|
+
"constructor",
|
|
50
|
+
"prototype"
|
|
51
|
+
].includes(entry.name) || names.has(entry.name)) throw invalid("Invalid or duplicate installed source entry name.");
|
|
52
|
+
names.add(entry.name);
|
|
53
|
+
}
|
|
54
|
+
for (const entry of [...entries].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
|
|
55
|
+
if (excludedDirectory(entry.name)) continue;
|
|
56
|
+
if (!fs.contains(base, entry.target)) throw kitFileError("studio.source_forbidden", "Capture target escapes installed resource root.");
|
|
57
|
+
const path = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
58
|
+
if (path.length > 1024 || path.split("/").length > 32) throw limit("Installed source exceeds path length or depth limit.");
|
|
59
|
+
const before = await fs.stat(entry.target);
|
|
60
|
+
if (!before || before.type !== entry.type) throw invalid("Installed source entry changed or has invalid metadata.");
|
|
61
|
+
if (entry.version !== void 0 && entry.version !== before.version || entry.size !== void 0 && before.size !== void 0 && entry.size !== before.size) throw kitFileError("studio.source_changed", "Listed source metadata differs from its first stat.");
|
|
62
|
+
if (entry.type === "directory") await walk(entry.target, path, before);
|
|
63
|
+
else if (entry.type === "file") {
|
|
64
|
+
if (files.length >= 4096 || (before.size ?? entry.size ?? 0) > 16777216 - total) throw limit("Installed source exceeds 4096 files or 16 MiB.");
|
|
65
|
+
let bytes;
|
|
66
|
+
try {
|
|
67
|
+
bytes = await fs.readBytes(entry.target, void 0, 16777216 - total);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (code(error) === "FS_TOO_LARGE") throw limit("Installed source exceeds 16 MiB.");
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
if (!(bytes instanceof Uint8Array) || bytes.byteLength > 16777216 - total) throw limit("Installed source exceeds its byte budget.");
|
|
73
|
+
if (before.size !== void 0 && bytes.byteLength !== before.size || entry.size !== void 0 && bytes.byteLength !== entry.size) throw kitFileError("studio.source_changed", "Source byte length differs from its observed metadata.");
|
|
74
|
+
await unchanged(entry.target, before);
|
|
75
|
+
total += bytes.byteLength;
|
|
76
|
+
files.push({
|
|
77
|
+
path,
|
|
78
|
+
base64: Buffer.from(bytes).toString("base64")
|
|
79
|
+
});
|
|
80
|
+
} else throw invalid("Installed source contains a non-regular entry.");
|
|
81
|
+
}
|
|
82
|
+
await unchanged(directory, info);
|
|
83
|
+
};
|
|
84
|
+
await walk(await target(root), "");
|
|
85
|
+
return files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
86
|
+
},
|
|
87
|
+
async readFile(path) {
|
|
88
|
+
if (typeof path !== "string" || /[\\:\u0000-\u001f\u007f]/u.test(path) || path.split("/").some((part) => !part || part === "." || part === ".." || excludedDirectory(part))) throw kitFileError("kit_file.path_forbidden", "Invalid Kit file path.");
|
|
89
|
+
try {
|
|
90
|
+
const resolved = await target(join(root, path));
|
|
91
|
+
const info = await fs.stat(resolved);
|
|
92
|
+
if (info?.type !== "file") throw kitFileError("kit_file.missing", "Kit file not found or not a regular file.");
|
|
93
|
+
if ((info.size ?? 0) > MAX_TEXT_BYTES) throw kitFileError("kit_file.too_large", "This file exceeds the 1 MiB text viewer limit.");
|
|
94
|
+
const bytes = await fs.readBytes(resolved, void 0, MAX_TEXT_BYTES);
|
|
95
|
+
let content;
|
|
96
|
+
try {
|
|
97
|
+
content = new TextDecoder("utf-8", {
|
|
98
|
+
fatal: true,
|
|
99
|
+
ignoreBOM: true
|
|
100
|
+
}).decode(bytes);
|
|
101
|
+
} catch {
|
|
102
|
+
throw kitFileError("kit_file.binary", "Kit file is binary or invalid UTF-8 text.");
|
|
103
|
+
}
|
|
104
|
+
if (content.includes("\0")) throw kitFileError("kit_file.binary", "Kit file is binary, not UTF-8 text.");
|
|
105
|
+
return { content };
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (code(error) === "FS_TOO_LARGE") throw kitFileError("kit_file.too_large", "This file exceeds the 1 MiB text viewer limit.");
|
|
108
|
+
if (code(error) === "FS_NOT_FOUND") throw kitFileError("kit_file.missing", "Kit file not found.");
|
|
109
|
+
if (code(error) === "FS_NOT_TEXT") throw kitFileError("kit_file.binary", "Kit file is binary or invalid UTF-8 text.");
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
listKitRoots: async () => [],
|
|
114
|
+
async readText(path) {
|
|
115
|
+
try {
|
|
116
|
+
return await fs.readText(await target(path));
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (code(error) === "FS_NOT_FOUND") return void 0;
|
|
119
|
+
if (code(error) === "FS_NOT_TEXT") throw new StudioBinaryContentError(path);
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
async listDir(path) {
|
|
124
|
+
try {
|
|
125
|
+
return (await fs.listDir(await target(path))).map((entry) => entry.name);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
if (code(error) === "FS_NOT_FOUND" || code(error) === "FS_NOT_DIRECTORY") return [];
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
async isDirectory(path) {
|
|
132
|
+
try {
|
|
133
|
+
return (await fs.stat(await target(path)))?.type === "directory";
|
|
134
|
+
} catch (error) {
|
|
135
|
+
if (code(error) === "FS_NOT_FOUND") return false;
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
async listFiles(path) {
|
|
140
|
+
const files = [];
|
|
141
|
+
let visited = 0;
|
|
142
|
+
const walk = async (directory, prefix, depth) => {
|
|
143
|
+
if (depth > 32) throw new Error(`design studio dsh: ${kind} file tree exceeds depth limit`);
|
|
144
|
+
for (const entry of await fs.listDir(directory)) {
|
|
145
|
+
if (++visited > 2e4) throw new Error(`design studio dsh: ${kind} file tree exceeds entry limit`);
|
|
146
|
+
if (kind === "Kit" && excludedDirectory(entry.name)) continue;
|
|
147
|
+
if (!fs.contains(base, entry.target)) continue;
|
|
148
|
+
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
149
|
+
if (entry.type === "directory") await walk(entry.target, relative, depth + 1);
|
|
150
|
+
else if (entry.type === "file") files.push(relative);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
await walk(await target(path), "", 0);
|
|
154
|
+
return files.sort();
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
export { openInstalledSourceFiles as n, kitFileError as t };
|