dsh-bash-terminal-ts 0.8.8 → 0.9.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/CHANGELOG.md +201 -190
- package/README.en.md +2 -1
- package/README.md +3 -2
- package/agent-presets/README.md +171 -170
- package/agent-presets/install-presets.mjs +180 -179
- package/agent-presets/standard-win-niu/agent.cordis.yml +271 -0
- package/agent-presets/standard-win-niu/preset.yml +2 -0
- package/cordis.patch.yml +84 -83
- package/dist/client.core.js +10 -1
- package/dist/client.js +10 -1
- package/docs/dsh-plugin-development.md +169 -0
- package/docs/niu-backend.md +197 -0
- package/dsh.plugin.json +3 -3
- package/lib/client.js +10 -1
- package/lib/dsh-types.d.ts +14 -2
- package/lib/index.d.ts +15 -2
- package/lib/index.js +43 -5
- package/lib/locales.js +9 -0
- package/lib/shell-id.d.ts +1 -1
- package/lib/shells.d.ts +1 -0
- package/lib/shells.js +8 -2
- package/lib/terminal.js +4 -0
- package/lib/webterminals/host.js +2 -2
- package/lib/webterminals/mount.js +1 -0
- package/locale/de.json +6 -6
- package/locale/en.json +6 -6
- package/locale/es.json +6 -6
- package/locale/fr.json +6 -6
- package/locale/it.json +6 -6
- package/locale/ja.json +6 -6
- package/locale/ko.json +6 -6
- package/locale/ru.json +6 -6
- package/locale/zh.json +6 -6
- package/package.json +151 -149
- package/scripts/check-artifacts.mjs +96 -96
- package/src/client.tsx +685 -685
- package/src/dsh-types.ts +332 -320
- package/src/index.ts +1316 -1275
- package/src/locales.ts +461 -452
- package/src/shell-id.ts +11 -11
- package/src/shells.ts +279 -272
- package/src/terminal.ts +616 -612
- package/src/webterminals/host.ts +361 -361
- package/src/webterminals/mount.ts +237 -236
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
// Artifact gates: the checks that only make sense against the BUILT bundle.
|
|
2
|
-
//
|
|
3
|
-
// Unit tests cannot see these. Every one of them is a failure mode that ships
|
|
4
|
-
// green through `tsc` and then dies silently in the browser:
|
|
5
|
-
//
|
|
6
|
-
// - `__ModuleLoader__.load({ id })` must equal the package name, or the host never
|
|
7
|
-
// binds the client half and the whole UI side goes dark without an error;
|
|
8
|
-
// - the client bundle must carry no Node builtins (the browser has none, and a
|
|
9
|
-
// leaked `node:` import is a runtime `require is not defined`);
|
|
10
|
-
// - `ws` must stay an EXTERNAL import in the host bundle: bundling it pulls
|
|
11
|
-
// `buffer`/`net` into a browser-shaped artifact and breaks the PTY socket;
|
|
12
|
-
// - `locale/en.json` is the anchor the host's package-meta scan insists on, so all
|
|
13
|
-
// nine files have to be present in the tarball list.
|
|
14
|
-
|
|
15
|
-
import { readdirSync, readFileSync } from "node:fs";
|
|
16
|
-
import assert from "node:assert";
|
|
17
|
-
|
|
18
|
-
const pkg = JSON.parse(readFileSync("package.json", "utf8"));
|
|
19
|
-
const bundle = readFileSync("lib/client.js", "utf8");
|
|
20
|
-
const host = readFileSync("lib/webterminals/ws.js", "utf8");
|
|
21
|
-
|
|
22
|
-
// 1) the loader identity.
|
|
23
|
-
const idMatch = /id:\s*"([^"]+)"/.exec(bundle);
|
|
24
|
-
assert.ok(idMatch, "the client bundle wraps itself in __ModuleLoader__.load({ id })");
|
|
25
|
-
assert.strictEqual(idMatch[1], pkg.name, "the client bundle id equals the package name");
|
|
26
|
-
|
|
27
|
-
// 2) client purity.
|
|
28
|
-
const leaks = ["node:crypto", "node:stream", "node:http", "node:fs", "node:path", "node:os", "string_decoder", "WebSocketServer"].filter((needle) => bundle.includes(needle));
|
|
29
|
-
assert.deepStrictEqual(leaks, [], `the client bundle must carry no Node-only module: ${leaks.join(", ")}`);
|
|
30
|
-
|
|
31
|
-
// 3) ws stays external on the host side.
|
|
32
|
-
assert.ok(/from "ws"/.test(host) || /require\("ws"\)/.test(host), "the host socket module imports ws as an external dependency");
|
|
33
|
-
|
|
34
|
-
// 4) the nine metadata files the host scans, with en as the anchor.
|
|
35
|
-
const langs = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es"];
|
|
36
|
-
for (const lang of langs) {
|
|
37
|
-
const parsed = JSON.parse(readFileSync(`locale/${lang}.json`, "utf8"));
|
|
38
|
-
// locale 元数据落成 `{ meta: { title, description } }`(gen-locale-meta 的产物形状);
|
|
39
|
-
// 兼容旧的根级平铺形状,避免误报。
|
|
40
|
-
const meta = parsed.meta ?? parsed;
|
|
41
|
-
assert.ok(typeof meta.title === "string" && meta.title.length > 0, `locale/${lang}.json needs a title`);
|
|
42
|
-
assert.ok(typeof meta.description === "string" && meta.description.length > 0, `locale/${lang}.json needs a description`);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// 5) the client dictionary really ships nine languages, keyed identically to zh.
|
|
46
|
-
const locales = readFileSync("lib/locales.js", "utf8");
|
|
47
|
-
const registered = /dictionaries\s*=\s*\{([^}]*)\}/.exec(locales)?.[1] ?? "";
|
|
48
|
-
for (const lang of langs) {
|
|
49
|
-
assert.ok(new RegExp(`\\b${lang}\\b`).test(registered), `lib/locales.js registers ${lang}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// 6) the multi-shell bottom tab ships, and xterm is INSIDE the bundle.
|
|
53
|
-
//
|
|
54
|
-
// Three failure modes worth a gate each. Registering the tab without `bottomOnly`
|
|
55
|
-
// turns it into a second "Terminal" capsule in DSH's native right sidebar, shadowing
|
|
56
|
-
// the host's. Leaving xterm EXTERNAL cannot work at all - the client module table
|
|
57
|
-
// resolves only seed words, shell-owned modules, registered factories and boot
|
|
58
|
-
// modules, and a live desktop host answered `require("@xterm/xterm")` with "missed the
|
|
59
|
-
// module table" - so the gate now asserts the opposite of what it did, with the
|
|
60
|
-
// emulator's own DOM marker as the witness. And the ceiling catches the reverse drift:
|
|
61
|
-
// a second heavyweight dependency creeping in unannounced.
|
|
62
|
-
assert.ok(bundle.includes("dsh-bash-terminal-ts:multi"), "the multi-shell tab id is in the client bundle");
|
|
63
|
-
assert.ok(bundle.includes("bottomOnly"), "the tab declares itself bottom-workbench only");
|
|
64
|
-
assert.ok(bundle.includes("xterm-helper-textarea"), "xterm is bundled (an external require cannot resolve in the client module table)");
|
|
65
|
-
assert.ok(!/require\("@xterm\/xterm"\)/.test(bundle), "no external @xterm require survives in the bundle");
|
|
66
|
-
assert.ok(bundle.includes("xterm-screen"), "xterm's stylesheet is inlined as text");
|
|
67
|
-
assert.ok(bundle.length < 900_000, `the client bundle did not grow unexpectedly: ${bundle.length} bytes`);
|
|
68
|
-
|
|
69
|
-
// 7) no dead copy: every dictionary key must be referenced by something that renders.
|
|
70
|
-
//
|
|
71
|
-
// A key defined in nine languages and read by nobody is not a spare string - it is a
|
|
72
|
-
// feature that was planned, translated, and never wired (this family shipped exactly
|
|
73
|
-
// that once: a `notice.standsDown` key with no renderer, and here a seven-language
|
|
74
|
-
// dictionary the component bypassed by reading `zh[...]` directly).
|
|
75
|
-
//
|
|
76
|
-
// Checked against the SOURCES, not the bundle: the dictionary itself is bundled, so a
|
|
77
|
-
// bundle substring test would match every key against its own definition and pass
|
|
78
|
-
// forever. Concatenated keys (`"shell." + id`) are covered by the prefix below.
|
|
79
|
-
//
|
|
80
|
-
// The consumer set walks the browser directory rather than listing files: a key moved
|
|
81
|
-
// into a new component used to read as dead copy here, which is the wrong lesson to
|
|
82
|
-
// teach whoever split the file up.
|
|
83
|
-
const consumerFiles = [
|
|
84
|
-
"src/client.tsx",
|
|
85
|
-
"src/browser-i18n.ts",
|
|
86
|
-
...readdirSync("src/webterminals/browser", { recursive: true }).map((rel) => `src/webterminals/browser/${String(rel)}`),
|
|
87
|
-
];
|
|
88
|
-
const consumers = consumerFiles.map((rel) => readFileSync(rel, "utf8"));
|
|
89
|
-
const zhKeys = [...new Set([...locales.matchAll(/"((?:shell|dock|tab)\.[A-Za-z0-9.]+)"\s*:/g)].map((match) => match[1]))];
|
|
90
|
-
assert.ok(zhKeys.length >= 30, `expected the full key set in lib/locales.js, found ${zhKeys.length}`);
|
|
91
|
-
const unusedKeys = zhKeys.filter((key) => !consumers.some((text) => text.includes(`"${key}"`)));
|
|
92
|
-
// `shell.<id>` is built by concatenation in the preference row, so those are wired.
|
|
93
|
-
const trulyUnused = unusedKeys.filter((key) => !/^shell\.(powershell|gitbash|msys2|wsl|payload)$/.test(key));
|
|
94
|
-
assert.deepStrictEqual(trulyUnused, [], `dictionary keys rendered by nothing: ${trulyUnused.join(", ")}`);
|
|
95
|
-
|
|
96
|
-
console.log(`ARTIFACT GATES PASS: id=${idMatch[1]} | client ${(bundle.length / 1024).toFixed(0)}KB, no node leaks, xterm bundled, css inlined | ws external | ${langs.length} locale files | ${zhKeys.length} dictionary keys, none dead`);
|
|
1
|
+
// Artifact gates: the checks that only make sense against the BUILT bundle.
|
|
2
|
+
//
|
|
3
|
+
// Unit tests cannot see these. Every one of them is a failure mode that ships
|
|
4
|
+
// green through `tsc` and then dies silently in the browser:
|
|
5
|
+
//
|
|
6
|
+
// - `__ModuleLoader__.load({ id })` must equal the package name, or the host never
|
|
7
|
+
// binds the client half and the whole UI side goes dark without an error;
|
|
8
|
+
// - the client bundle must carry no Node builtins (the browser has none, and a
|
|
9
|
+
// leaked `node:` import is a runtime `require is not defined`);
|
|
10
|
+
// - `ws` must stay an EXTERNAL import in the host bundle: bundling it pulls
|
|
11
|
+
// `buffer`/`net` into a browser-shaped artifact and breaks the PTY socket;
|
|
12
|
+
// - `locale/en.json` is the anchor the host's package-meta scan insists on, so all
|
|
13
|
+
// nine files have to be present in the tarball list.
|
|
14
|
+
|
|
15
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
16
|
+
import assert from "node:assert";
|
|
17
|
+
|
|
18
|
+
const pkg = JSON.parse(readFileSync("package.json", "utf8"));
|
|
19
|
+
const bundle = readFileSync("lib/client.js", "utf8");
|
|
20
|
+
const host = readFileSync("lib/webterminals/ws.js", "utf8");
|
|
21
|
+
|
|
22
|
+
// 1) the loader identity.
|
|
23
|
+
const idMatch = /id:\s*"([^"]+)"/.exec(bundle);
|
|
24
|
+
assert.ok(idMatch, "the client bundle wraps itself in __ModuleLoader__.load({ id })");
|
|
25
|
+
assert.strictEqual(idMatch[1], pkg.name, "the client bundle id equals the package name");
|
|
26
|
+
|
|
27
|
+
// 2) client purity.
|
|
28
|
+
const leaks = ["node:crypto", "node:stream", "node:http", "node:fs", "node:path", "node:os", "string_decoder", "WebSocketServer"].filter((needle) => bundle.includes(needle));
|
|
29
|
+
assert.deepStrictEqual(leaks, [], `the client bundle must carry no Node-only module: ${leaks.join(", ")}`);
|
|
30
|
+
|
|
31
|
+
// 3) ws stays external on the host side.
|
|
32
|
+
assert.ok(/from "ws"/.test(host) || /require\("ws"\)/.test(host), "the host socket module imports ws as an external dependency");
|
|
33
|
+
|
|
34
|
+
// 4) the nine metadata files the host scans, with en as the anchor.
|
|
35
|
+
const langs = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es"];
|
|
36
|
+
for (const lang of langs) {
|
|
37
|
+
const parsed = JSON.parse(readFileSync(`locale/${lang}.json`, "utf8"));
|
|
38
|
+
// locale 元数据落成 `{ meta: { title, description } }`(gen-locale-meta 的产物形状);
|
|
39
|
+
// 兼容旧的根级平铺形状,避免误报。
|
|
40
|
+
const meta = parsed.meta ?? parsed;
|
|
41
|
+
assert.ok(typeof meta.title === "string" && meta.title.length > 0, `locale/${lang}.json needs a title`);
|
|
42
|
+
assert.ok(typeof meta.description === "string" && meta.description.length > 0, `locale/${lang}.json needs a description`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 5) the client dictionary really ships nine languages, keyed identically to zh.
|
|
46
|
+
const locales = readFileSync("lib/locales.js", "utf8");
|
|
47
|
+
const registered = /dictionaries\s*=\s*\{([^}]*)\}/.exec(locales)?.[1] ?? "";
|
|
48
|
+
for (const lang of langs) {
|
|
49
|
+
assert.ok(new RegExp(`\\b${lang}\\b`).test(registered), `lib/locales.js registers ${lang}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 6) the multi-shell bottom tab ships, and xterm is INSIDE the bundle.
|
|
53
|
+
//
|
|
54
|
+
// Three failure modes worth a gate each. Registering the tab without `bottomOnly`
|
|
55
|
+
// turns it into a second "Terminal" capsule in DSH's native right sidebar, shadowing
|
|
56
|
+
// the host's. Leaving xterm EXTERNAL cannot work at all - the client module table
|
|
57
|
+
// resolves only seed words, shell-owned modules, registered factories and boot
|
|
58
|
+
// modules, and a live desktop host answered `require("@xterm/xterm")` with "missed the
|
|
59
|
+
// module table" - so the gate now asserts the opposite of what it did, with the
|
|
60
|
+
// emulator's own DOM marker as the witness. And the ceiling catches the reverse drift:
|
|
61
|
+
// a second heavyweight dependency creeping in unannounced.
|
|
62
|
+
assert.ok(bundle.includes("dsh-bash-terminal-ts:multi"), "the multi-shell tab id is in the client bundle");
|
|
63
|
+
assert.ok(bundle.includes("bottomOnly"), "the tab declares itself bottom-workbench only");
|
|
64
|
+
assert.ok(bundle.includes("xterm-helper-textarea"), "xterm is bundled (an external require cannot resolve in the client module table)");
|
|
65
|
+
assert.ok(!/require\("@xterm\/xterm"\)/.test(bundle), "no external @xterm require survives in the bundle");
|
|
66
|
+
assert.ok(bundle.includes("xterm-screen"), "xterm's stylesheet is inlined as text");
|
|
67
|
+
assert.ok(bundle.length < 900_000, `the client bundle did not grow unexpectedly: ${bundle.length} bytes`);
|
|
68
|
+
|
|
69
|
+
// 7) no dead copy: every dictionary key must be referenced by something that renders.
|
|
70
|
+
//
|
|
71
|
+
// A key defined in nine languages and read by nobody is not a spare string - it is a
|
|
72
|
+
// feature that was planned, translated, and never wired (this family shipped exactly
|
|
73
|
+
// that once: a `notice.standsDown` key with no renderer, and here a seven-language
|
|
74
|
+
// dictionary the component bypassed by reading `zh[...]` directly).
|
|
75
|
+
//
|
|
76
|
+
// Checked against the SOURCES, not the bundle: the dictionary itself is bundled, so a
|
|
77
|
+
// bundle substring test would match every key against its own definition and pass
|
|
78
|
+
// forever. Concatenated keys (`"shell." + id`) are covered by the prefix below.
|
|
79
|
+
//
|
|
80
|
+
// The consumer set walks the browser directory rather than listing files: a key moved
|
|
81
|
+
// into a new component used to read as dead copy here, which is the wrong lesson to
|
|
82
|
+
// teach whoever split the file up.
|
|
83
|
+
const consumerFiles = [
|
|
84
|
+
"src/client.tsx",
|
|
85
|
+
"src/browser-i18n.ts",
|
|
86
|
+
...readdirSync("src/webterminals/browser", { recursive: true }).map((rel) => `src/webterminals/browser/${String(rel)}`),
|
|
87
|
+
];
|
|
88
|
+
const consumers = consumerFiles.map((rel) => readFileSync(rel, "utf8"));
|
|
89
|
+
const zhKeys = [...new Set([...locales.matchAll(/"((?:shell|dock|tab)\.[A-Za-z0-9.]+)"\s*:/g)].map((match) => match[1]))];
|
|
90
|
+
assert.ok(zhKeys.length >= 30, `expected the full key set in lib/locales.js, found ${zhKeys.length}`);
|
|
91
|
+
const unusedKeys = zhKeys.filter((key) => !consumers.some((text) => text.includes(`"${key}"`)));
|
|
92
|
+
// `shell.<id>` is built by concatenation in the preference row, so those are wired.
|
|
93
|
+
const trulyUnused = unusedKeys.filter((key) => !/^shell\.(powershell|gitbash|msys2|wsl|payload|niu)$/.test(key));
|
|
94
|
+
assert.deepStrictEqual(trulyUnused, [], `dictionary keys rendered by nothing: ${trulyUnused.join(", ")}`);
|
|
95
|
+
|
|
96
|
+
console.log(`ARTIFACT GATES PASS: id=${idMatch[1]} | client ${(bundle.length / 1024).toFixed(0)}KB, no node leaks, xterm bundled, css inlined | ws external | ${langs.length} locale files | ${zhKeys.length} dictionary keys, none dead`);
|