dsh-mobile-access 1.0.0 → 1.0.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.
Files changed (3) hide show
  1. package/README.md +26 -6
  2. package/client.js +44 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -30,20 +30,38 @@ dsh web authentication required; reopen the URL printed by dsh web.
30
30
 
31
31
  ## 安装
32
32
 
33
- 本目录就是可安装的 bundle 目录。构建并验证后,由 DSH 插件管理器安装:
33
+ 推荐使用官方 DSH CLI 一次安装。已发布到 npm;下面是**可复现**的精确版本命令:
34
+
35
+ ```bash
36
+ dsh plugin --profile web add dsh-mobile-access@1.0.2
37
+ ```
38
+
39
+ 也可以使用 `@latest`,但 pnpm 的元数据缓存/镜像可能暂时仍解析到旧版;需要最新版时优先使用上面的精确版本,或显式指定官方 registry:
40
+
41
+ ```bash
42
+ dsh plugin --profile web add dsh-mobile-access@latest --registry=https://registry.npmjs.org/
43
+ ```
44
+
45
+ 本机 2026-10-24 的实测结果:默认 registry 下 `@latest` 仍解析到 `1.0.0`,精确版本可正确安装;指定 npmjs 后 `@latest` 也解析到最新版。`1.0.0` 已包含 Safari 配对修复;`1.0.1` 只增加安装文档和发布元数据;`1.0.2` 增加 iPhone 自带键盘换行。
46
+
47
+ `dsh plugin` 会在 profile 目录执行 pnpm 安装,并自动把声明了 `dsh.bundle.patch` 的包追加到 `dsh.profile.bundles`;不需要手工编辑 `cordis.patch.yml` 或 bundle 列表。
48
+
49
+ 从本目录安装(开发机、未发布版本或离线环境):
34
50
 
35
51
  ```bash
36
52
  cd /Users/open/Documents/Stocks/plugins/dsh-mobile-access
37
53
  npm run verify
54
+ dsh plugin --profile web add /Users/open/Documents/Stocks/plugins/dsh-mobile-access
38
55
  ```
39
56
 
40
- 安装目录(绝对路径):
57
+ 也可以使用 `npm pack` 生成 tgz 后安装:
41
58
 
42
- ```text
43
- /Users/open/Documents/Stocks/plugins/dsh-mobile-access
59
+ ```bash
60
+ npm pack
61
+ dsh plugin --profile web add /absolute/path/to/dsh-mobile-access-1.0.2.tgz
44
62
  ```
45
63
 
46
- 在 DSH 的插件管理入口执行 `install_bundle`,目标为上面的绝对路径。新 bundle 通常可以 HMR 生效;如果插件管理器提示 `restart-required`,**不要自行重启**,按项目约定通知用户手工重启 DSH,用户确认「已重启」后再继续。
64
+ 如果 DSH 正在运行,安装后的 host bundle 可能需要重启才能加载;插件管理器提示 `restart-required` 时,**不要自行重启**,按项目约定通知用户手工重启 DSH,用户确认「已重启」后再继续。已有环境也可以继续使用 DSH 插件管理入口的 `install_bundle`,目标为本目录的绝对路径;两种方式等价。
47
65
 
48
66
  ## 使用
49
67
 
@@ -66,7 +84,8 @@ npm run verify
66
84
  4. 成功后进入完整 DSH Web。建议:
67
85
  - 点 Safari 分享按钮 → 「添加到主屏幕」。
68
86
  - 以后从主屏幕图标进入;如果登录过期,重新打开一次 `/m` 配对即可。
69
- 5. 若面板显示 `window.isSecureContext === false`,这是 HTTP 局域网的正常现象;本插件只对 iOS/iPadOS 安装一个窄范围的剪贴板回退,其他平台不会改动全局对象。
87
+ 5. **iPhone 自带键盘换行**:在输入框内按 Return 是换行,不会直接发送;发送请点输入框右侧的发送按钮。Mac 上保持 Enter 发送、Shift+Enter 换行;外接键盘可用 Cmd+Enter 发送。
88
+ 6. 若面板显示 `window.isSecureContext === false`,这是 HTTP 局域网的正常现象;本插件只对 iOS/iPadOS 安装一个窄范围的剪贴板回退,其他平台不会改动全局对象。
70
89
 
71
90
  ## 路由与权限
72
91
 
@@ -100,6 +119,7 @@ npm run verify
100
119
  - 不注册 Service Worker,不缓存或改写现有请求。
101
120
  - 不启动后台轮询;面板只在挂载、窗口聚焦、页面可见时读取一次状态。
102
121
  - 全局剪贴板回退只在 **iOS/iPadOS 且非安全上下文** 时安装,并在插件销毁时恢复原 descriptor。
122
+ - Return 换行监听只在 **iOS/iPadOS** 上安装,只作用于带有 `data-composer-input` 的官方输入框;Mac 和非 Apple 平台不会安装该监听。
103
123
  - 插件注册失败只影响本插件自身;所有路由、slot、监听器和定时器都有清理路径。
104
124
 
105
125
  ## 开发与验证
package/client.js CHANGED
@@ -54,6 +54,44 @@ async function copyText(value) {
54
54
  }
55
55
  return legacyCopy(value);
56
56
  }
57
+ /**
58
+ * On iPhone/iPad the software keyboard has no Shift+Return. The official
59
+ * composer treats a plain Enter as "send", so a narrow capture-phase listener
60
+ * makes the event look like Shift+Enter to Lexical: the composer then keeps
61
+ * its native line break and does not submit. Mac and non-Apple platforms are
62
+ * never touched. The visible send button remains the send path.
63
+ */
64
+ function installIOSReturnNewline() {
65
+ if (!isAppleMobile())
66
+ return () => undefined;
67
+ const doc = document;
68
+ const onKeyDown = (event) => {
69
+ if (event.key !== 'Enter' || event.defaultPrevented)
70
+ return;
71
+ if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey)
72
+ return;
73
+ if (event.isComposing || event.keyCode === 229)
74
+ return;
75
+ const target = event.target;
76
+ if (target === null || typeof target.closest !== 'function')
77
+ return;
78
+ if (target.closest('[data-composer-input]') === null)
79
+ return;
80
+ if (doc.querySelector('[data-composer-overlay] [role="listbox"]') !== null)
81
+ return;
82
+ try {
83
+ Object.defineProperty(event, 'shiftKey', { configurable: true, value: true });
84
+ }
85
+ catch {
86
+ event.preventDefault();
87
+ event.stopImmediatePropagation();
88
+ if (!doc.execCommand('insertLineBreak'))
89
+ doc.execCommand('insertText', false, '\n');
90
+ }
91
+ };
92
+ doc.addEventListener('keydown', onKeyDown, true);
93
+ return () => doc.removeEventListener('keydown', onKeyDown, true);
94
+ }
57
95
  /**
58
96
  * On iOS an HTTP LAN page has no `navigator.clipboard`. A few existing DSH
59
97
  * controls call it directly, so install a narrowly scoped fallback there only.
@@ -358,6 +396,12 @@ function factory(require) {
358
396
  catch (error) {
359
397
  ctx.logger?.warn?.(`[mobile-access] clipboard fallback unavailable: ${String(error)}`);
360
398
  }
399
+ try {
400
+ cleanups.push(installIOSReturnNewline());
401
+ }
402
+ catch (error) {
403
+ ctx.logger?.warn?.(`[mobile-access] iOS Return newline unavailable: ${String(error)}`);
404
+ }
361
405
  return () => {
362
406
  for (const cleanup of cleanups.reverse()) {
363
407
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mobile-access",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Independent DSH bundle that pairs iPhones and iPads with the official DeepSeek Harness Web GUI over the local network.",
5
5
  "type": "module",
6
6
  "license": "MIT",