dsh-bash-terminal-ts 0.9.1 → 0.9.3
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 +214 -205
- package/CHANGELOG.pt.md +151 -151
- package/README.de.md +206 -206
- package/README.en.md +212 -212
- package/README.es.md +206 -206
- package/README.fr.md +206 -206
- package/README.it.md +206 -206
- package/README.md +423 -423
- package/README.pt.md +212 -212
- package/README.ru.md +206 -206
- package/agent-presets/README.md +171 -171
- package/agent-presets/install-presets.mjs +180 -180
- package/agent-presets/standard-win/agent.cordis.yml +271 -271
- package/agent-presets/standard-win/preset.yml +2 -2
- package/agent-presets/standard-win-gitbash/agent.cordis.yml +271 -271
- package/agent-presets/standard-win-gitbash/preset.yml +2 -2
- package/agent-presets/standard-win-msys2/agent.cordis.yml +272 -272
- package/agent-presets/standard-win-msys2/preset.yml +2 -2
- package/agent-presets/standard-win-niu/agent.cordis.yml +270 -270
- package/agent-presets/standard-win-niu/preset.yml +2 -2
- package/agent-presets/standard-win-wsl2/agent.cordis.yml +271 -271
- package/agent-presets/standard-win-wsl2/preset.yml +2 -2
- package/cordis.patch.yml +72 -84
- package/dist/client.core.js +193 -12
- package/dist/client.js +193 -12
- package/docs/niu-backend.md +197 -197
- package/dsh.plugin.json +23 -23
- package/lib/client.js +193 -12
- package/lib/dsh-types.d.ts +0 -2
- package/lib/index.d.ts +2 -23
- package/lib/index.js +4 -34
- package/lib/locales.js +0 -10
- package/lib/shell-id.d.ts +2 -2
- package/lib/shells.d.ts +2 -11
- package/lib/shells.js +4 -14
- package/lib/terminal.js +0 -1
- package/lib/webterminals/catalog.d.ts +0 -2
- package/lib/webterminals/catalog.js +0 -1
- package/lib/webterminals/mount.d.ts +0 -5
- package/lib/webterminals/mount.js +0 -4
- package/locale/de.json +5 -5
- package/locale/en.json +5 -5
- package/locale/es.json +5 -5
- package/locale/fr.json +5 -5
- package/locale/it.json +5 -5
- package/locale/ja.json +5 -5
- package/locale/ko.json +5 -5
- package/locale/pt.json +6 -6
- package/locale/ru.json +5 -5
- package/locale/zh.json +5 -5
- package/package.json +1 -5
- package/scripts/check-artifacts.mjs +96 -96
- package/scripts/link-shells.mjs +0 -21
- package/src/client.tsx +687 -685
- package/src/dsh-types.ts +330 -332
- package/src/index.ts +1267 -1316
- package/src/locales.ts +499 -509
- package/src/shell-id.ts +11 -11
- package/src/shells.ts +263 -279
- package/src/terminal.ts +615 -616
- package/src/webterminals/browser/star-row-copy.ts +256 -0
- package/src/webterminals/catalog.ts +0 -3
- package/src/webterminals/host.ts +361 -361
- package/src/webterminals/mount.ts +228 -237
- package/agent-presets/standard-win-payload/agent.cordis.yml +0 -271
- package/agent-presets/standard-win-payload/preset.yml +0 -2
- package/lib/payload.d.ts +0 -72
- package/lib/payload.js +0 -279
- package/scripts/payload-alias.mjs +0 -97
- package/scripts/provision-payload.mjs +0 -233
- package/src/payload.ts +0 -322
|
@@ -30,11 +30,6 @@ export interface MountInput {
|
|
|
30
30
|
* service instance only exists here, so it is passed back in.
|
|
31
31
|
*/
|
|
32
32
|
persist(svc: unknown, path: readonly string[], value: unknown): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* True when the startup payload gate was vetoed by a detected WSL distro
|
|
35
|
-
* (index.ts owns the answer; the catalog only uses it for the row badge).
|
|
36
|
-
*/
|
|
37
|
-
payloadSuppressed?(): boolean;
|
|
38
33
|
platform?: NodeJS.Platform;
|
|
39
34
|
}
|
|
40
35
|
/** The mount outcome, reported through the routes' `unavailable` field. */
|
|
@@ -62,9 +62,6 @@ export function mountBrowserTerminals(input) {
|
|
|
62
62
|
gitbash: readField("shellGitBash", true),
|
|
63
63
|
msys2: readField("shellMsys2", true),
|
|
64
64
|
wsl: readField("shellWsl", true),
|
|
65
|
-
// Opt-in twice over: enablePosixPayload provisions the runtime, this
|
|
66
|
-
// switch decides whether a provisioned payload may show in pickers.
|
|
67
|
-
payload: readField("shellPayload", false),
|
|
68
65
|
niu: readField("shellNiu", true),
|
|
69
66
|
});
|
|
70
67
|
const wslDistro = () => readField("wslDistro", "").trim();
|
|
@@ -98,7 +95,6 @@ export function mountBrowserTerminals(input) {
|
|
|
98
95
|
paths: () => input.paths,
|
|
99
96
|
switches,
|
|
100
97
|
wslDistro,
|
|
101
|
-
payloadSuppressed: input.payloadSuppressed ?? (() => false),
|
|
102
98
|
distros: () => {
|
|
103
99
|
if (distros === undefined && !probing)
|
|
104
100
|
reprobe();
|
package/locale/de.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "Unteres Terminal",
|
|
4
|
-
"description": "Shell-Werkzeug plus eingebettetes Terminal im unteren Dock (PowerShell / Git Bash / MSYS2 / WSL / Niubash), mit Aktivierung pro Shell und Rückfallkette."
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Unteres Terminal",
|
|
4
|
+
"description": "Shell-Werkzeug plus eingebettetes Terminal im unteren Dock (PowerShell / Git Bash / MSYS2 / WSL / Niubash), mit Aktivierung pro Shell und Rückfallkette."
|
|
5
|
+
}
|
|
6
6
|
}
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "Bottom terminal",
|
|
4
|
-
"description": "The shell tool plus an embedded terminal for the bottom dock (PowerShell / Git Bash / MSYS2 / WSL / Niubash), with per-shell activation switches and a default-shell fallback chain."
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Bottom terminal",
|
|
4
|
+
"description": "The shell tool plus an embedded terminal for the bottom dock (PowerShell / Git Bash / MSYS2 / WSL / Niubash), with per-shell activation switches and a default-shell fallback chain."
|
|
5
|
+
}
|
|
6
6
|
}
|
package/locale/es.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "Terminal inferior",
|
|
4
|
-
"description": "La herramienta shell y un terminal incrustado del panel inferior (PowerShell / Git Bash / MSYS2 / WSL / Niubash), con activación por shell y cadena de sustitución."
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Terminal inferior",
|
|
4
|
+
"description": "La herramienta shell y un terminal incrustado del panel inferior (PowerShell / Git Bash / MSYS2 / WSL / Niubash), con activación por shell y cadena de sustitución."
|
|
5
|
+
}
|
|
6
6
|
}
|
package/locale/fr.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "Terminal inférieur",
|
|
4
|
-
"description": "L'outil shell et un terminal intégré du dock bas (PowerShell / Git Bash / MSYS2 / WSL / Niubash), avec activation par shell et chaîne de repli."
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Terminal inférieur",
|
|
4
|
+
"description": "L'outil shell et un terminal intégré du dock bas (PowerShell / Git Bash / MSYS2 / WSL / Niubash), avec activation par shell et chaîne de repli."
|
|
5
|
+
}
|
|
6
6
|
}
|
package/locale/it.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "Terminale inferiore",
|
|
4
|
-
"description": "Strumento shell e terminale incorporato del dock inferiore (PowerShell / Git Bash / MSYS2 / WSL / Niubash), con attivazione per shell e catena di ripiego."
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Terminale inferiore",
|
|
4
|
+
"description": "Strumento shell e terminale incorporato del dock inferiore (PowerShell / Git Bash / MSYS2 / WSL / Niubash), con attivazione per shell e catena di ripiego."
|
|
5
|
+
}
|
|
6
6
|
}
|
package/locale/ja.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "下部ターミナル",
|
|
4
|
-
"description": "shell ツールと下部ドックの埋め込みターミナル(PowerShell / Git Bash / MSYS2 / WSL / Niubash)。shell 単位の有効化スイッチと既定 shell の代替チェーン付き。"
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "下部ターミナル",
|
|
4
|
+
"description": "shell ツールと下部ドックの埋め込みターミナル(PowerShell / Git Bash / MSYS2 / WSL / Niubash)。shell 単位の有効化スイッチと既定 shell の代替チェーン付き。"
|
|
5
|
+
}
|
|
6
6
|
}
|
package/locale/ko.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "하단 터미널",
|
|
4
|
-
"description": "shell 도구와 하단 독의 내장 터미널(PowerShell / Git Bash / MSYS2 / WSL / Niubash). shell별 활성화 스위치와 기본 shell 대체 체인을 제공합니다."
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "하단 터미널",
|
|
4
|
+
"description": "shell 도구와 하단 독의 내장 터미널(PowerShell / Git Bash / MSYS2 / WSL / Niubash). shell별 활성화 스위치와 기본 shell 대체 체인을 제공합니다."
|
|
5
|
+
}
|
|
6
6
|
}
|
package/locale/pt.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "Terminal inferior",
|
|
4
|
-
"description": "A ferramenta shell e o terminal embutido do painel inferior (PowerShell / Git Bash / MSYS2 / WSL / Niubash), com chaves de ativação por shell e cadeia de fallback do shell padrão."
|
|
5
|
-
}
|
|
6
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Terminal inferior",
|
|
4
|
+
"description": "A ferramenta shell e o terminal embutido do painel inferior (PowerShell / Git Bash / MSYS2 / WSL / Niubash), com chaves de ativação por shell e cadeia de fallback do shell padrão."
|
|
5
|
+
}
|
|
6
|
+
}
|
package/locale/ru.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "Нижний терминал",
|
|
4
|
-
"description": "Инструмент shell и встроенный терминал нижней панели (PowerShell / Git Bash / MSYS2 / WSL / Niubash) с активацией по оболочкам и цепочкой замещения."
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Нижний терминал",
|
|
4
|
+
"description": "Инструмент shell и встроенный терминал нижней панели (PowerShell / Git Bash / MSYS2 / WSL / Niubash) с активацией по оболочкам и цепочкой замещения."
|
|
5
|
+
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta": {
|
|
3
|
-
"title": "底部终端",
|
|
4
|
-
"description": "shell 工具与底部工作台终端(PowerShell / Git Bash / MSYS2 / WSL / Niubash),带激活开关与默认 shell 回落链。"
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "底部终端",
|
|
4
|
+
"description": "shell 工具与底部工作台终端(PowerShell / Git Bash / MSYS2 / WSL / Niubash),带激活开关与默认 shell 回落链。"
|
|
5
|
+
}
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-bash-terminal-ts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org",
|
|
6
6
|
"tag": "latest"
|
|
@@ -82,7 +82,6 @@
|
|
|
82
82
|
"test": "node test-dist/unit.js && node test-dist/apply.js && node test-dist/client.js && node test-dist/terminal.js && node test-dist/shells.js && node test-dist/webterminals.js && node test/browser.mjs",
|
|
83
83
|
"lint": "eslint .",
|
|
84
84
|
"link:shells": "node scripts/link-shells.mjs",
|
|
85
|
-
"payload:provision": "node scripts/provision-payload.mjs",
|
|
86
85
|
"presets:install": "node agent-presets/install-presets.mjs"
|
|
87
86
|
},
|
|
88
87
|
"dsh": {
|
|
@@ -97,9 +96,6 @@
|
|
|
97
96
|
]
|
|
98
97
|
}
|
|
99
98
|
},
|
|
100
|
-
"optionalDependencies": {
|
|
101
|
-
"@drscrewdriver/posix-runtime-win32-x64": "0.1.2"
|
|
102
|
-
},
|
|
103
99
|
"peerDependencies": {
|
|
104
100
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
105
101
|
"@deepseek-ai/dsh-client-locale": ">=0.1.0-rc.2 <0.3.0-0",
|
|
@@ -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
|
-
// ten 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 ten metadata files the host scans, with en as the anchor.
|
|
35
|
-
const langs = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es", "pt"];
|
|
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 ten 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 ten 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`);
|
|
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
|
+
// ten 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 ten metadata files the host scans, with en as the anchor.
|
|
35
|
+
const langs = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es", "pt"];
|
|
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 ten 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 ten 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`);
|
package/scripts/link-shells.mjs
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
|
|
20
20
|
import { existsSync, linkSync, statSync } from "node:fs";
|
|
21
21
|
import { join } from "node:path";
|
|
22
|
-
import { ensurePayloadAlias, findPayloadStoreRoot, payloadAliasPaths } from "./payload-alias.mjs";
|
|
23
22
|
|
|
24
23
|
/** Each alias: the link to create and the shell it must point at. */
|
|
25
24
|
const ALIASES = [
|
|
@@ -68,26 +67,6 @@ for (const alias of ALIASES) {
|
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
// The pinned POSIX payload's menu entry: a hard link inside its own bin\ named
|
|
72
|
-
// bash-terminal.exe plus the stable `payloads\bash-terminal` junction the bundle
|
|
73
|
-
// patch points at. Absent payload = nothing to do (the candidate is skipped by
|
|
74
|
-
// the host per-candidate), so this never counts as blocked.
|
|
75
|
-
{
|
|
76
|
-
const paths = payloadAliasPaths(process.env);
|
|
77
|
-
if (paths === undefined) {
|
|
78
|
-
console.log("skip payload LOCALAPPDATA unset; no payload alias target");
|
|
79
|
-
} else {
|
|
80
|
-
const rootName = findPayloadStoreRoot(paths.store);
|
|
81
|
-
if (rootName === undefined) {
|
|
82
|
-
console.log(`skip payload no provisioned root under ${paths.store} (run scripts/provision-payload.mjs first)`);
|
|
83
|
-
} else {
|
|
84
|
-
const done = ensurePayloadAlias({ root: join(paths.store, rootName), junction: paths.junction });
|
|
85
|
-
if (done.skipped !== undefined) console.log(`BAD payload ${done.skipped}`);
|
|
86
|
-
else console.log(`ok payload ${done.link} + junction`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
70
|
console.log("");
|
|
92
71
|
if (blocked > 0) {
|
|
93
72
|
console.log(`${blocked} alias(es) still missing - the official shell menu will not offer them until they exist.`);
|