dsh-pocket 1.8.3 → 1.8.4

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.en.md CHANGED
@@ -46,7 +46,7 @@ What it looks like — the phone shows the exact same UI as your computer, live:
46
46
  | 🔐 Access PIN | Public links require an **8-digit PIN** (rotated every time the tunnel starts — old links die instantly); LAN has its own separate **8-digit PIN** (refresh it manually in Settings) |
47
47
  | ⚡ Real-time sync | Streaming output passes through WebSocket untouched — what the computer renders, the phone renders live; fully interactive both ways |
48
48
  | 📱 Mobile-adaptive layout | Narrow screens get a drawer layout automatically (ported from dsh-web-mobile, MIT): sidebar drawer, full-width conversation, safe-area insets, touch optimizations |
49
- | 🗜️ Transfer compression | Large JSON responses are gzip/brotli'd on the fly (17MB session history → ~1.3MB) — faster loads, less mobile data |
49
+ | 🗜️ Transfer compression | Large JSON responses are gzip/brotli'd on the fly (17MB session history → ~1MB; brotli quality 6: fast and bandwidth-friendly) — faster loads, less mobile data |
50
50
  | 🔁 Tunnel auto-restore | After a DSH restart the previously-running public tunnel comes back automatically |
51
51
  | 🧩 Zero-dependency install | One npm package, one settings tab — no core/adapter split, no account, no server |
52
52
 
package/README.md CHANGED
@@ -46,7 +46,7 @@ DSH Pocket 就是干这个的:**装上它,手机扫个码,就能实时看
46
46
  | 🔐 访问密码 | 公网链接需输入 **8 位数字密码**(每次开启公网自动换新,旧链接立即作废);局域网同样有独立 **8 位数字密码**(设置页可手动刷新) |
47
47
  | ⚡ 实时同步 | 流式输出走 WebSocket 全透传——**电脑上在输出,手机上同步在滚**,可双向操作 |
48
48
  | 📱 移动端适配 | 窄屏自动变抽屉布局(移植 dsh-web-mobile,MIT):侧栏抽屉、会话全宽、状态栏安全区、触控优化 |
49
- | 🗜️ 传输压缩 | 大 JSON 响应自动 gzip/brotli(长会话 17MB → ~1.3MB),手机加载更快、更省流量 |
49
+ | 🗜️ 传输压缩 | 大 JSON 响应自动 gzip/brotli(长会话 17MB → ~1MB,brotli 质量 6:快且省流量),手机加载更快、更省流量 |
50
50
  | 🔁 隧道自动恢复 | DSH 重启后自动重新拉起之前开着的公网隧道,无需手动重开 |
51
51
  | 🧩 零依赖安装 | 一个 npm 包、一个设置页,没有核心/适配器要分开装;无需账号、无需服务器 |
52
52
 
package/lib/proxy.mjs CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  import { createServer } from 'node:http';
15
15
  import { request as httpRequest } from 'node:http';
16
- import { createGzip, createBrotliCompress } from 'node:zlib';
16
+ import { createGzip, createBrotliCompress, constants as zlibConstants } from 'node:zlib';
17
17
 
18
18
  const DEFAULT_UPSTREAM = { host: '127.0.0.1', port: 3080 };
19
19
 
@@ -211,8 +211,10 @@ export function createPocketProxy({ port = 3081, host = '0.0.0.0', upstream = DE
211
211
  return;
212
212
  }
213
213
  // 大 JSON/text 响应**流式压缩**(issue #12):长会话历史一次返回 17MB+,
214
- // 局域网直连与隧道段都吃满带宽;压缩到 ~1.3MB。跳过已压缩、SSE 流
214
+ // 局域网直连与隧道段都吃满带宽;压缩到 ~1MB。跳过已压缩、SSE 流
215
215
  // (/api/events.* 原样透传)、HTML(走上面的注入分支)。
216
+ // brotli 质量选 6(issue #25):zlib 默认 q11 压 17MB 要 40s+,手机直接超时;
217
+ // q6 实测 128ms(比 gzip 的 88ms 略慢但同档)且输出更小(1.00MB vs 1.20MB)。
216
218
  const acceptEncoding = String(req.headers['accept-encoding'] ?? '');
217
219
  const canGzip = /\bgzip\b/.test(acceptEncoding);
218
220
  const canBr = /\bbr\b/.test(acceptEncoding);
@@ -230,7 +232,9 @@ export function createPocketProxy({ port = 3081, host = '0.0.0.0', upstream = DE
230
232
  delete outHeaders['transfer-encoding'];
231
233
  outHeaders['content-encoding'] = enc;
232
234
  res.writeHead(proxyRes.statusCode ?? 200, outHeaders);
233
- const z = enc === 'br' ? createBrotliCompress() : createGzip();
235
+ const z = enc === 'br'
236
+ ? createBrotliCompress({ params: { [zlibConstants.BROTLI_PARAM_QUALITY]: 6 } })
237
+ : createGzip();
234
238
  proxyRes.pipe(z).pipe(res);
235
239
  // 任一端断开都要清理(含压缩流)。注意:不能用 proxyRes 的 'close'
236
240
  // 来掐 res——正常结束后 close 也会触发,此时压缩流可能还没写完,
package/package.json CHANGED
@@ -76,5 +76,5 @@
76
76
  "access": "public",
77
77
  "registry": "https://registry.npmjs.org/"
78
78
  },
79
- "version": "1.8.3"
79
+ "version": "1.8.4"
80
80
  }