@linxin666/dsh-client-ui-plugin-manager 0.3.22 → 0.3.24
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.i18n.yaml +2 -2
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/client.js +1 -1
- package/lib/index.js +123 -21
- package/lib/types/host/console-output.d.ts +40 -0
- package/package.json +1 -1
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# node scripts/verify-docs.mjs --write <dir>
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 64a6f487e8bb6b20d64e4ab6d339ba692c5a3d90
|
|
6
|
+
README.zh.md: 497dbe49a464a3f6174c2c10a9aead62a8522c4d
|
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ The contract source of truth is `src/core/service.ts` (`PluginManagerService`).
|
|
|
61
61
|
## Known limitations
|
|
62
62
|
|
|
63
63
|
- Loopback-only: on a LAN or remote browser the tab renders a local-only notice (the same boundary the official installer tab enforces; the gateway refuses non-loopback requests with 403).
|
|
64
|
-
- On the npm-published web runtime, gateway writes go through the official CLI. The gateway resolves `dsh` from the host process PATH first
|
|
64
|
+
- On the npm-published web runtime, gateway writes go through the official CLI. The gateway resolves `dsh` from the host process PATH first, then from `node_modules/.bin` project roots above the running host entry, and finally from the running host package's own `lib/bin.js` — which covers local-wrapper and npx launches and the packaged desktop runtime, where the CLI ships beside the host process and every `.bin` shim directory is stripped from the installer. A resolved `bin.js` runs under the host's own Node interpreter. If no source contains the CLI, writes remain unavailable. CLI output is decoded as bytes in one pass, so a Windows console's code page (CP936/GBK) renders as readable text instead of replacement characters. Installs of git sources can take minutes and run as background jobs. Gateway updates apply only to npm registry sources, resolve the latest version on the host, and succeed only after the same installed package reports that exact version.
|
|
65
65
|
- Compatibility gating applies only when the target manifest declares a minimum DSH version; packages without `dsh.engines.dsh` update unchecked, and official-installer runtimes (DSHCode and the checkout web) are not gated here because their updates go through the official installer.
|
|
66
66
|
- On the npm-published web runtime there is no boot-failure ring and no safe mode: those surfaces degrade to empty, and only install errors offer the repair handoff.
|
|
67
67
|
- Enablement on the npm runtime reports the effective next-start value: a profile override row wins where present, otherwise the installed bundle's own `disabled` rows decide (the aggregate's inactive-by-default families), and rows no layer mentions are enabled. Enabling a row the bundle disables writes an explicit `disabled: false` override, because deleting the user row would only restore the bundle default; the runtime's loader honors these rows at the next start, but this path is less exercised than the official desktop writer's.
|
package/README.zh.md
CHANGED
|
@@ -61,7 +61,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-plugin-manager
|
|
|
61
61
|
## 已知限制
|
|
62
62
|
|
|
63
63
|
- 仅限本机:LAN 或远程浏览器只显示「仅限本机操作」提示(与官方安装器 Tab 同一边界;网关对非 loopback 请求返回 403)。
|
|
64
|
-
- npm 发布的官方 web 上,网关写入经官方 CLI 执行。网关先从 host 进程 PATH 解析 `dsh`,再从运行中 host 入口上层各项目根的 `node_modules/.bin`
|
|
64
|
+
- npm 发布的官方 web 上,网关写入经官方 CLI 执行。网关先从 host 进程 PATH 解析 `dsh`,再从运行中 host 入口上层各项目根的 `node_modules/.bin` 回退查找,最后回退到运行中 host 包自身的 `lib/bin.js`——覆盖本地包装器与 npx 启动,以及桌面安装包运行时(CLI 与 host 进程同处一树,且安装包会剥除所有 `.bin` shim 目录);解析到的 `bin.js` 由 host 自身的 Node 解释器执行。全部来源都没有 CLI 时才不可写。CLI 输出按字节一次性解码,Windows 中文控制台(CP936/GBK)的报错文本可读而不再是替换字符。git 源安装可能耗时数分钟,以后台任务运行。网关更新只适用于 npm registry 源,由 host 解析最新版本,且仅当同一已装包报告该精确版本时才算成功。
|
|
65
65
|
- 兼容性门禁只在目标清单声明了最低 DSH 版本时生效;未声明 `dsh.engines.dsh` 的包更新不被检查,官方安装器运行时(DSHCode 与 checkout 版 web)不经过本门禁(其更新走官方安装器)。
|
|
66
66
|
- npm 发布的官方 web 没有启动失败环与安全模式:这两处界面降级为空,只有安装错误提供修复转交。
|
|
67
67
|
- npm 运行时上的启停显示下次启动的真实生效值:profile 覆盖行优先,其次由所装 bundle 自带的 `disabled` 行决定(聚合包的按需开启家族),两层都未提及的行视为启用。开启一个被 bundle 停用的行会写入显式 `disabled: false` 覆盖行——只删除用户行只会退回 bundle 默认值;该运行时 loader 在下次启动时认读这些行,但这条路径不如官方桌面写入器经过充分锻炼。
|
package/lib/client.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -324,15 +324,30 @@ function setRowEnabled(text, filename, id, name, enabled, baseEnabled = true) {
|
|
|
324
324
|
insertRow.set("disabled", document.createNode(!enabled));
|
|
325
325
|
return document.toString({ lineWidth: 0 }) + "\n";
|
|
326
326
|
}
|
|
327
|
-
|
|
327
|
+
let found = findBareRow(root, id);
|
|
328
|
+
let effBase = baseEnabled;
|
|
329
|
+
if (found === void 0 && name !== void 0) {
|
|
330
|
+
const byName = [];
|
|
331
|
+
root.items.forEach((item, index) => {
|
|
332
|
+
if (!isBareRow(item) || bareRowName(item) !== name || bareRowId(item) === void 0) return;
|
|
333
|
+
if (isMap(item)) byName.push({
|
|
334
|
+
row: item,
|
|
335
|
+
index
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
if (byName.length === 1) {
|
|
339
|
+
found = byName[0];
|
|
340
|
+
effBase = false;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
328
343
|
if (enabled) if (found === void 0) {
|
|
329
|
-
if (
|
|
344
|
+
if (effBase) return text;
|
|
330
345
|
root.items.push(document.createNode({
|
|
331
346
|
id,
|
|
332
347
|
name,
|
|
333
348
|
disabled: false
|
|
334
349
|
}));
|
|
335
|
-
} else if (
|
|
350
|
+
} else if (effBase) root.items.splice(found.index, 1);
|
|
336
351
|
else found.row.set("disabled", document.createNode(false));
|
|
337
352
|
else if (found !== void 0) found.row.set("disabled", document.createNode(true));
|
|
338
353
|
else root.items.push(document.createNode({
|
|
@@ -775,6 +790,74 @@ async function snapshotGateway(facts, patchText) {
|
|
|
775
790
|
};
|
|
776
791
|
}
|
|
777
792
|
//#endregion
|
|
793
|
+
//#region src/host/console-output.ts
|
|
794
|
+
/** Count the U+FFFD replacement characters one candidate decode produced. */
|
|
795
|
+
function replacementCount(text) {
|
|
796
|
+
let count = 0;
|
|
797
|
+
for (const character of text) if (character === "�") count += 1;
|
|
798
|
+
return count;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Decode one console byte buffer. Strict UTF-8 wins whenever it is valid;
|
|
802
|
+
* otherwise the bytes are not UTF-8 at all and the console wrote its own code
|
|
803
|
+
* page, so the candidate that loses the least text is taken.
|
|
804
|
+
* @param bytes - the captured bytes.
|
|
805
|
+
* @returns the decoded text.
|
|
806
|
+
*/
|
|
807
|
+
function decodeConsoleBytes(bytes) {
|
|
808
|
+
try {
|
|
809
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
810
|
+
} catch {
|
|
811
|
+
let best;
|
|
812
|
+
let bestLoss = Number.POSITIVE_INFINITY;
|
|
813
|
+
for (const label of ["gbk", "utf-8"]) {
|
|
814
|
+
let text;
|
|
815
|
+
try {
|
|
816
|
+
text = new TextDecoder(label).decode(bytes);
|
|
817
|
+
} catch {
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
const loss = replacementCount(text);
|
|
821
|
+
if (loss < bestLoss) {
|
|
822
|
+
best = text;
|
|
823
|
+
bestLoss = loss;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
/* v8 ignore next 3 -- reachable only without the legacy code page AND without the lenient pass */
|
|
827
|
+
if (best === void 0) return Buffer.from(bytes).toString("utf8");
|
|
828
|
+
return best;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Create a capture bounded to a byte budget. Overflow drops from the FRONT
|
|
833
|
+
* (the tail is what carries a failure reason), and the cut never lands inside
|
|
834
|
+
* a character: leading UTF-8 continuation bytes are dropped with it, and a
|
|
835
|
+
* legacy code page's dangling lead byte — indistinguishable from a real byte
|
|
836
|
+
* without knowing the encoding until the whole buffer is decoded — is removed
|
|
837
|
+
* with the one replacement character it produced, so an over-long stream still
|
|
838
|
+
* reads cleanly at the seam.
|
|
839
|
+
* @param maxBytes - maximum retained bytes.
|
|
840
|
+
* @returns the capture.
|
|
841
|
+
*/
|
|
842
|
+
function createOutputCapture(maxBytes) {
|
|
843
|
+
let buffer = Buffer.alloc(0);
|
|
844
|
+
let trimmed = false;
|
|
845
|
+
return {
|
|
846
|
+
push(chunk) {
|
|
847
|
+
buffer = buffer.length === 0 ? Buffer.from(chunk) : Buffer.concat([buffer, Buffer.from(chunk)]);
|
|
848
|
+
if (buffer.length <= maxBytes) return;
|
|
849
|
+
let start = buffer.length - maxBytes;
|
|
850
|
+
while (start < buffer.length && (buffer[start] & 192) === 128) start += 1;
|
|
851
|
+
buffer = Buffer.from(buffer.subarray(start));
|
|
852
|
+
trimmed = true;
|
|
853
|
+
},
|
|
854
|
+
read() {
|
|
855
|
+
const text = decodeConsoleBytes(buffer);
|
|
856
|
+
return trimmed && text.startsWith("�") ? text.slice(1) : text;
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
//#endregion
|
|
778
861
|
//#region src/host/gateway.ts
|
|
779
862
|
/**
|
|
780
863
|
* The CLI gateway: installs and removals executed by spawning the official
|
|
@@ -790,6 +873,8 @@ async function snapshotGateway(facts, patchText) {
|
|
|
790
873
|
const ADD_TIMEOUT_MS = 6 * 6e4;
|
|
791
874
|
/** Hard deadline for one CLI remove. */
|
|
792
875
|
const REMOVE_TIMEOUT_MS = 2 * 6e4;
|
|
876
|
+
/** Bounded capture of the CLI output (the tail survives), counted in bytes. */
|
|
877
|
+
const MAX_OUTPUT_BYTES = 32e3;
|
|
793
878
|
/** Ring cap on finished jobs: the newest 100 settled jobs stay queryable; the oldest finished job is evicted beyond the cap so the job table cannot grow without bound. In-progress jobs are never evicted. */
|
|
794
879
|
const MAX_FINISHED_JOBS = 100;
|
|
795
880
|
/**
|
|
@@ -829,12 +914,23 @@ function findDshBinary(env = process.env, platform = process.platform, exists =
|
|
|
829
914
|
}
|
|
830
915
|
}
|
|
831
916
|
if (platform === "darwin") candidates.push("/opt/homebrew/bin/dsh", "/usr/local/bin/dsh");
|
|
917
|
+
if (hostEntryPath !== void 0 && hostEntryPath !== "") {
|
|
918
|
+
const entryDir = pathApi.dirname(hostEntryPath);
|
|
919
|
+
const packageRoot = pathApi.dirname(entryDir);
|
|
920
|
+
candidates.push(pathApi.join(packageRoot, "lib", "bin.js"));
|
|
921
|
+
}
|
|
832
922
|
for (const candidate of candidates) if (exists(candidate)) return candidate;
|
|
833
923
|
return null;
|
|
834
924
|
}
|
|
835
|
-
/**
|
|
925
|
+
/**
|
|
926
|
+
* Append bounded CLI output (stdout + stderr interleaved is not preserved;
|
|
927
|
+
* tail wins). Bytes are accumulated and decoded once at read time: a Windows
|
|
928
|
+
* console writes its OEM code page (CP936/GBK on zh-CN), so per-chunk
|
|
929
|
+
* `toString()` both mis-decodes the encoding and splits characters that
|
|
930
|
+
* straddle two reads into replacement characters (issue #1600).
|
|
931
|
+
*/
|
|
836
932
|
function capture(chunk, buffer) {
|
|
837
|
-
buffer.
|
|
933
|
+
buffer.push(chunk);
|
|
838
934
|
}
|
|
839
935
|
/**
|
|
840
936
|
* The spawn command for the dsh CLI on this platform. Windows runs the
|
|
@@ -854,6 +950,10 @@ function dshSpawnCommand(binary, platform = process.platform, localNodeExists =
|
|
|
854
950
|
};
|
|
855
951
|
const dir = win32.dirname(binary);
|
|
856
952
|
const localNode = win32.join(dir, "node.exe");
|
|
953
|
+
if (win32.basename(binary).toLowerCase() === "bin.js") return {
|
|
954
|
+
command: process.execPath,
|
|
955
|
+
argsPrefix: [binary]
|
|
956
|
+
};
|
|
857
957
|
const binJs = [win32.join(dir, "node_modules", "@deepseek-ai", "dsh", "lib", "bin.js"), win32.join(dir, "..", "@deepseek-ai", "dsh", "lib", "bin.js")].find((candidate) => binJsExists(candidate));
|
|
858
958
|
if (binJs === void 0) return {
|
|
859
959
|
command: binary,
|
|
@@ -918,22 +1018,22 @@ const OFFICIAL_INSTALLER_PATTERN = /^\s*-?\s*id:\s*['"]?plugin-(?:installer|cont
|
|
|
918
1018
|
* @returns true when the dump names the official installer channels.
|
|
919
1019
|
*/
|
|
920
1020
|
async function detectOfficialChannels(binary, profileName, env = process.env, spawnImpl = spawnDsh) {
|
|
921
|
-
const output =
|
|
1021
|
+
const output = createOutputCapture(MAX_OUTPUT_BYTES);
|
|
922
1022
|
const child = spawnImpl(binary, [
|
|
923
1023
|
"--profile",
|
|
924
1024
|
profileName,
|
|
925
1025
|
"--dump-config"
|
|
926
1026
|
], env);
|
|
927
1027
|
child.stdout?.on("data", (chunk) => {
|
|
928
|
-
|
|
1028
|
+
capture(chunk, output);
|
|
929
1029
|
});
|
|
930
1030
|
child.stderr?.on("data", (chunk) => {
|
|
931
|
-
|
|
1031
|
+
capture(chunk, output);
|
|
932
1032
|
});
|
|
933
1033
|
if (await new Promise((resolve) => {
|
|
934
1034
|
child.on("close", resolve);
|
|
935
1035
|
}) !== 0) return false;
|
|
936
|
-
return OFFICIAL_INSTALLER_PATTERN.test(output.
|
|
1036
|
+
return OFFICIAL_INSTALLER_PATTERN.test(output.read());
|
|
937
1037
|
}
|
|
938
1038
|
/** The gateway: serializes CLI operations through one job table and one mutation queue. */
|
|
939
1039
|
var CliGateway = class {
|
|
@@ -986,7 +1086,7 @@ var CliGateway = class {
|
|
|
986
1086
|
}
|
|
987
1087
|
/** Run one CLI command to completion and return the bounded output. */
|
|
988
1088
|
async runCli(binary, args, timeoutMs) {
|
|
989
|
-
const output =
|
|
1089
|
+
const output = createOutputCapture(MAX_OUTPUT_BYTES);
|
|
990
1090
|
const child = this.spawnCli(binary, args);
|
|
991
1091
|
child.stdout?.on("data", (chunk) => {
|
|
992
1092
|
capture(chunk, output);
|
|
@@ -1003,7 +1103,7 @@ var CliGateway = class {
|
|
|
1003
1103
|
clearTimeout(timer);
|
|
1004
1104
|
return {
|
|
1005
1105
|
code,
|
|
1006
|
-
output: output.
|
|
1106
|
+
output: output.read().trim()
|
|
1007
1107
|
};
|
|
1008
1108
|
}
|
|
1009
1109
|
/** Full package spec used when restoring a legacy dependency. */
|
|
@@ -1350,7 +1450,7 @@ var CliGateway = class {
|
|
|
1350
1450
|
return;
|
|
1351
1451
|
}
|
|
1352
1452
|
const before = await this.capture();
|
|
1353
|
-
const output =
|
|
1453
|
+
const output = createOutputCapture(MAX_OUTPUT_BYTES);
|
|
1354
1454
|
const child = this.spawnCli(binary, args);
|
|
1355
1455
|
child.stdout?.on("data", (chunk) => {
|
|
1356
1456
|
capture(chunk, output);
|
|
@@ -1367,7 +1467,7 @@ var CliGateway = class {
|
|
|
1367
1467
|
clearTimeout(timer);
|
|
1368
1468
|
if (code !== 0) {
|
|
1369
1469
|
job.phase = "error";
|
|
1370
|
-
const tail = output.
|
|
1470
|
+
const tail = output.read().trim();
|
|
1371
1471
|
job.error = tail === "" ? `plugin-manager: dsh plugin ${job.action} exited with code ${String(code)}` : tail;
|
|
1372
1472
|
return;
|
|
1373
1473
|
}
|
|
@@ -1475,7 +1575,7 @@ var CliGateway = class {
|
|
|
1475
1575
|
let tail = "";
|
|
1476
1576
|
const binary = this.binary();
|
|
1477
1577
|
if (binary !== null) {
|
|
1478
|
-
const output =
|
|
1578
|
+
const output = createOutputCapture(MAX_OUTPUT_BYTES);
|
|
1479
1579
|
const child = this.spawnCli(binary, [
|
|
1480
1580
|
"plugin",
|
|
1481
1581
|
"--profile",
|
|
@@ -1497,7 +1597,7 @@ var CliGateway = class {
|
|
|
1497
1597
|
});
|
|
1498
1598
|
clearTimeout(timer);
|
|
1499
1599
|
rolledBack = code === 0;
|
|
1500
|
-
tail = output.
|
|
1600
|
+
tail = output.read().trim();
|
|
1501
1601
|
}
|
|
1502
1602
|
job.phase = "error";
|
|
1503
1603
|
job.error = rolledBack ? `plugin-manager: ${reason},已自动回滚 ${name}` : `plugin-manager: ${reason};自动回滚失败,请手动执行 dsh plugin --profile ${this.facts.profileName} remove ${name}${tail === "" ? "" : `:\n${tail}`}`;
|
|
@@ -1575,7 +1675,7 @@ var CliGateway = class {
|
|
|
1575
1675
|
const binary = this.binary();
|
|
1576
1676
|
if (binary === null) return;
|
|
1577
1677
|
const name = this.newDependency(before, after);
|
|
1578
|
-
const verifyOutput =
|
|
1678
|
+
const verifyOutput = createOutputCapture(MAX_OUTPUT_BYTES);
|
|
1579
1679
|
const child = this.spawnCli(binary, [
|
|
1580
1680
|
"--profile",
|
|
1581
1681
|
this.facts.profileName,
|
|
@@ -1595,7 +1695,7 @@ var CliGateway = class {
|
|
|
1595
1695
|
});
|
|
1596
1696
|
clearTimeout(timer);
|
|
1597
1697
|
if (code === 0) return;
|
|
1598
|
-
const tail = verifyOutput.
|
|
1698
|
+
const tail = verifyOutput.read().trim();
|
|
1599
1699
|
if (name === void 0) {
|
|
1600
1700
|
job.phase = "error";
|
|
1601
1701
|
job.error = tail === "" ? "plugin-manager: boot preflight failed" : tail;
|
|
@@ -1855,6 +1955,8 @@ const GATEWAY_PREFIX = "/api/plugin-manager";
|
|
|
1855
1955
|
const REGISTRY_TIMEOUT_MS = 3e4;
|
|
1856
1956
|
/** Deadline for one dsh --version probe. */
|
|
1857
1957
|
const VERSION_TIMEOUT_MS = 1e4;
|
|
1958
|
+
/** Bounded capture of the version probe output, counted in bytes. */
|
|
1959
|
+
const VERSION_MAX_OUTPUT_BYTES = 4096;
|
|
1858
1960
|
/** Grace period after SIGTERM before a stuck probe child is SIGKILLed. */
|
|
1859
1961
|
const VERSION_ESCALATION_TIMEOUT_MS = 5e3;
|
|
1860
1962
|
/** Successful probe freshness window before the host version is re-read. */
|
|
@@ -1865,9 +1967,9 @@ const VERSION_PROBE_COOLDOWN_MS = 6e4;
|
|
|
1865
1967
|
function messageOf(error) {
|
|
1866
1968
|
return error instanceof Error ? error.message : String(error);
|
|
1867
1969
|
}
|
|
1868
|
-
/** Append bounded probe output. */
|
|
1970
|
+
/** Append bounded probe output (bytes accumulate; one decode at read time). */
|
|
1869
1971
|
function captureProbe(chunk, buffer) {
|
|
1870
|
-
buffer.
|
|
1972
|
+
buffer.push(chunk);
|
|
1871
1973
|
}
|
|
1872
1974
|
/**
|
|
1873
1975
|
* Default registry manifest probe for npm packages: `/<name>/latest` returns
|
|
@@ -1897,7 +1999,7 @@ async function probeDshVersion(cliAvailable) {
|
|
|
1897
1999
|
if (!cliAvailable()) return void 0;
|
|
1898
2000
|
const binary = findDshBinary();
|
|
1899
2001
|
if (binary === null) return void 0;
|
|
1900
|
-
const output =
|
|
2002
|
+
const output = createOutputCapture(VERSION_MAX_OUTPUT_BYTES);
|
|
1901
2003
|
const child = spawnDsh(binary, ["--version"], process.env);
|
|
1902
2004
|
child.stdout?.on("data", (chunk) => {
|
|
1903
2005
|
captureProbe(chunk, output);
|
|
@@ -1924,7 +2026,7 @@ async function probeDshVersion(cliAvailable) {
|
|
|
1924
2026
|
child.once("error", () => finish(null));
|
|
1925
2027
|
child.once("close", finish);
|
|
1926
2028
|
}) !== 0) return void 0;
|
|
1927
|
-
const version = output.
|
|
2029
|
+
const version = output.read().trim().split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
1928
2030
|
return parseDshVersion(version) === void 0 ? void 0 : version;
|
|
1929
2031
|
}
|
|
1930
2032
|
/** Whether a dependency spec is a direct npm-registry selector, not an alias or external source. */
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Console-output capture shared by the family's Host halves.
|
|
3
|
+
*
|
|
4
|
+
* A child process's stdout/stderr are raw bytes, and on Windows a console
|
|
5
|
+
* program writes the OEM code page (CP936/GBK on a zh-CN system), not UTF-8.
|
|
6
|
+
* Decoding each chunk on its own corrupts the text twice over: the
|
|
7
|
+
* encoding is guessed wrong, and a multi-byte character split across two reads
|
|
8
|
+
* decodes into two replacement characters. This capture accumulates raw bytes
|
|
9
|
+
* under a byte budget and decodes exactly once, at read time.
|
|
10
|
+
*/
|
|
11
|
+
/** Bounded byte accumulator for one child process's interleaved stdout/stderr. */
|
|
12
|
+
export interface OutputCapture {
|
|
13
|
+
/** Append one raw chunk (the bytes are copied into the budget). */
|
|
14
|
+
push(chunk: Uint8Array): void;
|
|
15
|
+
/**
|
|
16
|
+
* Decode everything captured so far. Idempotent, so a caller may read the
|
|
17
|
+
* tail both after a failure branch and at settlement.
|
|
18
|
+
*/
|
|
19
|
+
read(): string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Decode one console byte buffer. Strict UTF-8 wins whenever it is valid;
|
|
23
|
+
* otherwise the bytes are not UTF-8 at all and the console wrote its own code
|
|
24
|
+
* page, so the candidate that loses the least text is taken.
|
|
25
|
+
* @param bytes - the captured bytes.
|
|
26
|
+
* @returns the decoded text.
|
|
27
|
+
*/
|
|
28
|
+
export declare function decodeConsoleBytes(bytes: Uint8Array): string;
|
|
29
|
+
/**
|
|
30
|
+
* Create a capture bounded to a byte budget. Overflow drops from the FRONT
|
|
31
|
+
* (the tail is what carries a failure reason), and the cut never lands inside
|
|
32
|
+
* a character: leading UTF-8 continuation bytes are dropped with it, and a
|
|
33
|
+
* legacy code page's dangling lead byte — indistinguishable from a real byte
|
|
34
|
+
* without knowing the encoding until the whole buffer is decoded — is removed
|
|
35
|
+
* with the one replacement character it produced, so an over-long stream still
|
|
36
|
+
* reads cleanly at the seam.
|
|
37
|
+
* @param maxBytes - maximum retained bytes.
|
|
38
|
+
* @returns the capture.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createOutputCapture(maxBytes: number): OutputCapture;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-client-ui-plugin-manager",
|
|
3
3
|
"description": "Plugin manager tab for the dsh web GUI Plugins settings section: installs plugins from npm or git through the official host channels, lists installed plugins with next-start enablement switches, surfaces install-time conflict actions with undo, and hands failures off to repair conversations.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.24",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/types/index.d.ts",
|