dsh-open-in-dsh 0.2.0 → 0.3.0
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 +2 -2
- package/client/globals.d.ts +43 -0
- package/client/{index.js → index.ts} +2 -2
- package/lib/client.js +488 -512
- package/lib/index.js +752 -770
- package/lib/types/index.d.ts +461 -0
- package/package.json +11 -3
- package/scripts/{build-client.mjs → build-client.mts} +8 -7
- package/scripts/macos/open-in-dsh +2 -2
- package/scripts/open-in-dsh.ps1 +1 -1
- package/scripts/open-in-dsh.vbs +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ dsh plugin --profile <profile> add dsh-open-in-dsh
|
|
|
33
33
|
把 `<profile>` 换成目标 profile(桌面版 `desktop`、`dsh web` 用 `web`)。
|
|
34
34
|
从源码安装时把最后一项换成 checkout 里的 `packages/dsh-open-in-dsh` 路径。
|
|
35
35
|
|
|
36
|
-
装完刷新页面;**改宿主半边(`
|
|
36
|
+
装完刷新页面;**改宿主半边(`src/index.ts`,重新 `npm run build` 后)必须重启宿主**——桌面版要完全退出应用再打开
|
|
37
37
|
(关窗口只是缩进托盘),否则运行中的进程还在用模块缓存里的旧代码。
|
|
38
38
|
|
|
39
39
|
### 2. 注册系统右键菜单
|
|
@@ -202,7 +202,7 @@ Chrome 会把后台页面的定时器节流到每分钟一次,而刚点完右
|
|
|
202
202
|
|
|
203
203
|
```sh
|
|
204
204
|
npm test # 82 个测试(含客户端构建与语法检查)
|
|
205
|
-
node --test test/macos.test.
|
|
205
|
+
node --test test/macos.test.ts # macOS 启动器/安装器 17 个测试
|
|
206
206
|
```
|
|
207
207
|
|
|
208
208
|
`npm test` 覆盖宿主路由与回放、`%V` 的各种形态、脚本镜像(路由路径/端口/`-Probe` 一致)、
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient browser globals for the DSH client bundle.
|
|
3
|
+
*
|
|
4
|
+
* `client/index.ts` is a classic script, not a module: it has no import/export,
|
|
5
|
+
* so `tsc` emits it as-is and `scripts/build-client.mts` splices the emitted
|
|
6
|
+
* text into the body of the factory `window.__ModuleLoader__.load({ id,
|
|
7
|
+
* factory })` registers. This file only describes the globals that contract
|
|
8
|
+
* itself puts on `window`; DOM types come from the `DOM` lib.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** One lazy module registration accepted by `window.__ModuleLoader__.load`. */
|
|
12
|
+
interface DshModuleLoaderRegistration {
|
|
13
|
+
/** Package name the bundle registers under (`dsh-open-in-dsh`). */
|
|
14
|
+
id: string
|
|
15
|
+
/** Runs once on first require; its return value is the module's exports. */
|
|
16
|
+
factory: (require: (id: string) => unknown) => unknown
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The devtools/console surface the browser half exposes for troubleshooting. */
|
|
20
|
+
interface DshOpenInDebug {
|
|
21
|
+
/** The Host route the stream follows. */
|
|
22
|
+
route: string
|
|
23
|
+
/** Make one folder the current Workspace (and land in a blank Session). */
|
|
24
|
+
open: (path: string) => Promise<void>
|
|
25
|
+
/** Ask the Host to launch one allowlisted app on a path. */
|
|
26
|
+
openWith: (app: string, path: string) => Promise<void>
|
|
27
|
+
/** A snapshot of the stream state, for `console.log(__dshOpenIn.status())`. */
|
|
28
|
+
status: () => {
|
|
29
|
+
lastSeq: number
|
|
30
|
+
settings: { alwaysNewSession: boolean }
|
|
31
|
+
uiWorkspace: boolean
|
|
32
|
+
readyState: number | null
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface Window {
|
|
37
|
+
/** The DSH client module system: executes plugin bundles as classic scripts. */
|
|
38
|
+
__ModuleLoader__: {
|
|
39
|
+
load(registration: DshModuleLoaderRegistration): void
|
|
40
|
+
}
|
|
41
|
+
/** Troubleshooting hook, callable from the devtools console. */
|
|
42
|
+
__dshOpenIn: DshOpenInDebug
|
|
43
|
+
}
|
|
@@ -41,7 +41,7 @@ function parseFrame(text) {
|
|
|
41
41
|
const NS = 'dsh-open-in-dsh'
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Menu labels. scripts/build-client.
|
|
44
|
+
* Menu labels. scripts/build-client.mts replaces the marker below with the
|
|
45
45
|
* "menu" objects from locale/zh.json and locale/en.json, so the shipped bundle
|
|
46
46
|
* and the package's locale files cannot drift.
|
|
47
47
|
*/
|
|
@@ -186,7 +186,7 @@ const QSPACE_BUTTON_STYLE = Object.freeze({
|
|
|
186
186
|
function createAvailability(read) {
|
|
187
187
|
let state = null
|
|
188
188
|
let loading = null
|
|
189
|
-
const listeners = new Set()
|
|
189
|
+
const listeners = new Set<() => void>()
|
|
190
190
|
const publish = (next) => {
|
|
191
191
|
if (next === state) return
|
|
192
192
|
state = next
|