dsh-mobile-access 1.0.1 → 1.0.3
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.md +14 -4
- package/client.js +48 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,12 +30,20 @@ dsh web authentication required; reopen the URL printed by dsh web.
|
|
|
30
30
|
|
|
31
31
|
## 安装
|
|
32
32
|
|
|
33
|
-
推荐使用官方 DSH CLI 一次安装。已发布到 npm
|
|
33
|
+
推荐使用官方 DSH CLI 一次安装。已发布到 npm;下面是**可复现**的精确版本命令:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
dsh plugin --profile web add dsh-mobile-access@
|
|
36
|
+
dsh plugin --profile web add dsh-mobile-access@1.0.3
|
|
37
37
|
```
|
|
38
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`/`1.0.3` 增加 iPhone 自带键盘换行(`1.0.3` 额外加入 Safari 不支持改写键盘事件时的编辑回退)。
|
|
46
|
+
|
|
39
47
|
`dsh plugin` 会在 profile 目录执行 pnpm 安装,并自动把声明了 `dsh.bundle.patch` 的包追加到 `dsh.profile.bundles`;不需要手工编辑 `cordis.patch.yml` 或 bundle 列表。
|
|
40
48
|
|
|
41
49
|
从本目录安装(开发机、未发布版本或离线环境):
|
|
@@ -50,7 +58,7 @@ dsh plugin --profile web add /Users/open/Documents/Stocks/plugins/dsh-mobile-acc
|
|
|
50
58
|
|
|
51
59
|
```bash
|
|
52
60
|
npm pack
|
|
53
|
-
dsh plugin --profile web add /absolute/path/to/dsh-mobile-access-1.0.
|
|
61
|
+
dsh plugin --profile web add /absolute/path/to/dsh-mobile-access-1.0.3.tgz
|
|
54
62
|
```
|
|
55
63
|
|
|
56
64
|
如果 DSH 正在运行,安装后的 host bundle 可能需要重启才能加载;插件管理器提示 `restart-required` 时,**不要自行重启**,按项目约定通知用户手工重启 DSH,用户确认「已重启」后再继续。已有环境也可以继续使用 DSH 插件管理入口的 `install_bundle`,目标为本目录的绝对路径;两种方式等价。
|
|
@@ -76,7 +84,8 @@ dsh plugin --profile web add /absolute/path/to/dsh-mobile-access-1.0.1.tgz
|
|
|
76
84
|
4. 成功后进入完整 DSH Web。建议:
|
|
77
85
|
- 点 Safari 分享按钮 → 「添加到主屏幕」。
|
|
78
86
|
- 以后从主屏幕图标进入;如果登录过期,重新打开一次 `/m` 配对即可。
|
|
79
|
-
5.
|
|
87
|
+
5. **iPhone 自带键盘换行**:在输入框内按 Return 是换行,不会直接发送;发送请点输入框右侧的发送按钮。Mac 上保持 Enter 发送、Shift+Enter 换行;外接键盘可用 Cmd+Enter 发送。
|
|
88
|
+
6. 若面板显示 `window.isSecureContext === false`,这是 HTTP 局域网的正常现象;本插件只对 iOS/iPadOS 安装一个窄范围的剪贴板回退,其他平台不会改动全局对象。
|
|
80
89
|
|
|
81
90
|
## 路由与权限
|
|
82
91
|
|
|
@@ -110,6 +119,7 @@ dsh plugin --profile web add /absolute/path/to/dsh-mobile-access-1.0.1.tgz
|
|
|
110
119
|
- 不注册 Service Worker,不缓存或改写现有请求。
|
|
111
120
|
- 不启动后台轮询;面板只在挂载、窗口聚焦、页面可见时读取一次状态。
|
|
112
121
|
- 全局剪贴板回退只在 **iOS/iPadOS 且非安全上下文** 时安装,并在插件销毁时恢复原 descriptor。
|
|
122
|
+
- Return 换行监听只在 **iOS/iPadOS** 上安装,只作用于带有 `data-composer-input` 的官方输入框;Mac 和非 Apple 平台不会安装该监听。
|
|
113
123
|
- 插件注册失败只影响本插件自身;所有路由、slot、监听器和定时器都有清理路径。
|
|
114
124
|
|
|
115
125
|
## 开发与验证
|
package/client.js
CHANGED
|
@@ -54,6 +54,48 @@ 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
|
+
// Fall through to the explicit edit fallback.
|
|
87
|
+
}
|
|
88
|
+
const currentShift = event.shiftKey;
|
|
89
|
+
if (currentShift !== true) {
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
event.stopImmediatePropagation();
|
|
92
|
+
if (!doc.execCommand('insertLineBreak'))
|
|
93
|
+
doc.execCommand('insertText', false, '\n');
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
doc.addEventListener('keydown', onKeyDown, true);
|
|
97
|
+
return () => doc.removeEventListener('keydown', onKeyDown, true);
|
|
98
|
+
}
|
|
57
99
|
/**
|
|
58
100
|
* On iOS an HTTP LAN page has no `navigator.clipboard`. A few existing DSH
|
|
59
101
|
* controls call it directly, so install a narrowly scoped fallback there only.
|
|
@@ -358,6 +400,12 @@ function factory(require) {
|
|
|
358
400
|
catch (error) {
|
|
359
401
|
ctx.logger?.warn?.(`[mobile-access] clipboard fallback unavailable: ${String(error)}`);
|
|
360
402
|
}
|
|
403
|
+
try {
|
|
404
|
+
cleanups.push(installIOSReturnNewline());
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
ctx.logger?.warn?.(`[mobile-access] iOS Return newline unavailable: ${String(error)}`);
|
|
408
|
+
}
|
|
361
409
|
return () => {
|
|
362
410
|
for (const cleanup of cleanups.reverse()) {
|
|
363
411
|
try {
|
package/package.json
CHANGED