dsh-pocket 2.1.1 → 2.1.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/lib/index.js CHANGED
@@ -20,7 +20,7 @@ import { randomBytes } from 'node:crypto';
20
20
  import { createPocketService } from './service.mjs';
21
21
  import { installPocketRpc } from './web-rpc.js';
22
22
  import { restartHost } from './restart.js';
23
- import { desktopEnvPatchScript, advancedNoticeScript, DEFAULT_INJECT, classifyHost } from './proxy.mjs';
23
+ import { advancedNoticeScript, DEFAULT_INJECT, classifyHost } from './proxy.mjs';
24
24
  import { lanEnabled, setLanEnabled, lanAuthEnabled, setLanAuthEnabled, lanIpOverride, setLanIpOverride, pinCustom, setPinCustom, tunnelMode, setTunnelMode, tunnelToken, setTunnelToken, tunnelHostname, setTunnelHostname, resetSettings } from './settings.mjs';
25
25
 
26
26
  const name = 'dsh-pocket';
@@ -251,12 +251,18 @@ export function apply(ctx, config = {}, internals = {}) {
251
251
  internals,
252
252
  getLanIpOverride: () => lanIpOverride(),
253
253
  getLanEnabled: () => lanEnabled(),
254
- // 桌面端:手机扫码访问的页面缺 dsh-desktop-mode/platform 参数会让 dsh-plugin-desktop
255
- // client 崩溃(issue #3/#4)。给代理注入「桌面参数补丁」(history.replaceState 补齐参数,
256
- // 无跳转;compatibility 模式不套桌面布局,避免移动端按钮叠加)。保留默认 polyfill。
257
- // advanced 模式再加警告覆盖层(issue #19)。
254
+ // 桌面端**不再**注入 dsh-desktop-* 标记(issue #76):
255
+ // - 旧版 dsh-plugin-desktop 缺 mode/platform 会抛错,当初正是为此加了补丁(issue #3/#4);
256
+ // - 2.0.3 起,mode 与 platform **同时缺失**时 parseDesktopClientEnvironment 直接返回
257
+ // undefined(视作非桌面外壳,跳过全部桌面逻辑),正是手机页需要的效果;
258
+ // - 反之只要 URL 上出现任一 dsh-desktop-* 标记,客户端就会强制校验整组
259
+ // (material + semver version + mica),只补两个必然抛 "invalid or missing
260
+ // dsh-desktop-material" → 插件树加载失败 → 页面变成「打开恢复模式」;
261
+ // - 更糟的是 decideDesktopBrowserAccess 见到 dsh-desktop-* 前缀就把没有渲染器 token 的
262
+ // 普通浏览器判为 denied(403),刷新后直接打不开。
263
+ // 结论:手机/浏览器访问一律不带这些标记,advanced 模式另加警告覆盖层(issue #19)。
258
264
  injectHtml: isDesktop
259
- ? DEFAULT_INJECT + desktopEnvPatchScript(process.platform) + (desktopAdvanced ? advancedNoticeScript() : '')
265
+ ? DEFAULT_INJECT + (desktopAdvanced ? advancedNoticeScript() : '')
260
266
  : undefined,
261
267
  // 访问密码(issue #13 + #18 + #24 + #33 + #66):公网永远要密码(默认每次开启变新,
262
268
  // 用户自定义后不再轮换);局域网按开关(默认开启;关闭后局域网扫码直连)。
package/lib/proxy.mjs CHANGED
@@ -38,15 +38,23 @@ export const RANDOM_UUID_POLYFILL = `<script data-dsh-pocket-polyfill="1">!funct
38
38
  const INJECT_MARK = 'data-dsh-pocket-polyfill="1"';
39
39
 
40
40
  /**
41
- * DSH Desktop(桌面版)渲染进程兼容补丁。
41
+ * DSH Desktop(桌面版)渲染进程兼容补丁(issue #3/#4,已于 issue #76 停用)。
42
42
  *
43
- * 桌面版 profile 里的 dsh-plugin-desktop client 会在页面加载时从 URL query 读
43
+ * 历史:旧版 dsh-plugin-desktop client 在页面加载时从 URL query 读
44
44
  * `dsh-desktop-mode` 与 `dsh-desktop-platform`,缺失即抛
45
- * "invalid or missing dsh-desktop-mode null" → 页面崩(手机扫码访问桌面版时正是如此,
46
- * issue #3/#4)。本脚本在页面加载前用 history.replaceState 把这两个参数补上
47
- * (无跳转、不重载),取最轻的 `compatibility` 模式——不激活桌面布局,避免与
48
- * 移动端适配叠加。
49
- * 仅宿主在桌面版(isDesktop)时由 lib/index.js 追加进 injectHtml。
45
+ * "invalid or missing dsh-desktop-mode null" → 页面崩(手机扫码访问桌面版时正是如此)。
46
+ * 本脚本用 history.replaceState 补上这两个参数(无跳转、不重载),取最轻的
47
+ * `compatibility` 模式——不激活桌面布局,避免与移动端适配叠加。
48
+ *
49
+ * @deprecated 不要再注入(issue #76,DSH Desktop 2.0.3 起):
50
+ * ① mode 与 platform **同时缺失**时,parseDesktopClientEnvironment 直接返回 undefined
51
+ * (视作非桌面外壳,跳过全部桌面逻辑),正是手机/浏览器页面需要的效果;
52
+ * ② 只要 URL 上出现任一 dsh-desktop-* 标记,客户端就强制校验整组(material +
53
+ * semver version + mica),只补两个必然抛 "invalid or missing
54
+ * dsh-desktop-material" → 插件树加载失败 → 页面变成「打开恢复模式」;
55
+ * ③ 更糟:decideDesktopBrowserAccess 见到 dsh-desktop-* 前缀就把没有渲染器 token 的
56
+ * 普通浏览器判为 denied(403),刷新后直接打不开。
57
+ * lib/index.js 已不再注入本脚本;保留导出仅为兼容旧版本桌面端与既有测试。
50
58
  */
51
59
  export function desktopEnvPatchScript(platform) {
52
60
  const p = ['darwin', 'win32', 'linux'].includes(platform) ? platform : 'linux';
package/package.json CHANGED
@@ -80,5 +80,5 @@
80
80
  "access": "public",
81
81
  "registry": "https://registry.npmjs.org/"
82
82
  },
83
- "version": "2.1.1"
83
+ "version": "2.1.2"
84
84
  }