@hao0311/dsh-toolbox 0.5.1 → 0.5.2

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 ADDED
@@ -0,0 +1,11 @@
1
+ # 更新记录
2
+
3
+ ## 0.5.2 (2026-11-24)
4
+
5
+ 修复:
6
+
7
+ - jsonGet 没有超时,上游卡住时请求一直挂着;现在 15 秒超时。
8
+ - 下载流不可中断;改为 AbortSignal.any([中断, 120s])。
9
+ - install.ps1 增加包名规范化,并重新同步安装副本。
10
+
11
+ 更早版本的记录见仓库 git 历史。
package/client.js CHANGED
@@ -127,8 +127,30 @@
127
127
  return t.length > max ? `${t.slice(0, max - 1)}…` : t;
128
128
  }
129
129
 
130
+ /**
131
+ * 兜底超时信号(2026-11-23)。优先用 AbortSignal.timeout(Edge 103+ 支持),
132
+ * 老浏览器退回 setTimeout + abort。用于那些「本来没有超时」的前端请求:
133
+ * 服务端挂死时,没有超时就会一直挂着、界面停在「进行中」。
134
+ */
135
+ function timeoutSignal(ms) {
136
+ if (typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function') return AbortSignal.timeout(ms);
137
+ const controller = new AbortController();
138
+ setTimeout(() => {
139
+ try {
140
+ controller.abort(new DOMException('timeout', 'TimeoutError'));
141
+ } catch {
142
+ controller.abort();
143
+ }
144
+ }, ms);
145
+ return controller.signal;
146
+ }
147
+
130
148
  function jsonGet(path) {
131
- return fetch(`${API}${path}`, { cache: 'no-store', credentials: 'same-origin' }).then((res) => {
149
+ return fetch(`${API}${path}`, {
150
+ cache: 'no-store',
151
+ credentials: 'same-origin',
152
+ signal: timeoutSignal(15000),
153
+ }).then((res) => {
132
154
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
133
155
  return res.json();
134
156
  });
@@ -325,10 +347,16 @@
325
347
 
326
348
  /** 一条并发下载流:流式读取只计数不落内存(500MB 也不会吃爆手机内存)。 */
327
349
  async function downloadStream(job, query, sid, idx, loaded, onFirstByte) {
350
+ // 2026-11-23:除了用户「停止」的 job.abort,再加 120 秒兜底超时。
351
+ // 只有 job.abort 时,服务端挂死且已进入 reader.read() 的情况会一直等下去。
352
+ const signal =
353
+ typeof AbortSignal !== 'undefined' && typeof AbortSignal.any === 'function'
354
+ ? AbortSignal.any([job.abort.signal, timeoutSignal(120000)])
355
+ : job.abort.signal;
328
356
  const res = await fetch(`${API}/net/download?${query}&sid=${sid}&s=${idx}&t=${Date.now()}`, {
329
357
  cache: 'no-store',
330
358
  credentials: 'same-origin',
331
- signal: job.abort.signal,
359
+ signal,
332
360
  });
333
361
  if (!res.ok) throw new Error(`下载 HTTP ${res.status}`);
334
362
  if (!res.body) throw new Error('浏览器不支持流式读取');
package/install.ps1 CHANGED
@@ -89,6 +89,16 @@ if ($bytes.Length -ge 3 -and $bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $by
89
89
  [System.IO.File]::WriteAllText($pkg, $t, (New-Object System.Text.UTF8Encoding($false)))
90
90
  Write-Host 'stripped BOM from package.json'
91
91
  }
92
+ # Normalize the installed package name (2026-11-23): the source package.json now carries the
93
+ # public release name (@hao0311/dsh-toolbox), while the patch entry in cordis.patch.yml says
94
+ # 'dsh-toolbox'. Keep the installed module name identical to the patch entry so DSH plugin
95
+ # validation cannot silently disable it on a name mismatch.
96
+ $pkgText = [System.IO.File]::ReadAllText($pkg, [System.Text.Encoding]::UTF8)
97
+ $pkgNext = [regex]::Replace($pkgText, '"name"\s*:\s*"[^"]*"', '"name": "dsh-toolbox"', 1)
98
+ if ($pkgNext -ne $pkgText) {
99
+ [System.IO.File]::WriteAllText($pkg, $pkgNext, (New-Object System.Text.UTF8Encoding($false)))
100
+ Write-Host 'normalized package.json name -> dsh-toolbox'
101
+ }
92
102
  Write-Host "synced $($files.Count) files -> $Dest"
93
103
 
94
104
  # 2) patch entry (idempotent)
package/package.json CHANGED
@@ -1,11 +1,19 @@
1
1
  {
2
2
  "name": "@hao0311/dsh-toolbox",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
7
7
  ".": "./index.js"
8
8
  },
9
+ "files": [
10
+ "index.js",
11
+ "client.js",
12
+ "client.css",
13
+ "install.ps1",
14
+ "README.md",
15
+ "CHANGELOG.md"
16
+ ],
9
17
  "description": "Toolbox panel for the DeepSeek Harness Web GUI: a right-side drawer (full screen on phones) with connection information, one-click diagnostics, a speed test, a quality monitor, history and auto patrol.",
10
18
  "keywords": [
11
19
  "dsh",