@karoy/dsh-wsl-desktop 0.1.1 → 0.1.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 +13 -11
- package/bin/auto.mjs +5 -4
- package/client.js +143 -29
- package/index.js +21 -0
- package/lib/merge-patch.js +1 -1
- package/lib/setup.js +20 -11
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
启用的 → 安装并启用;禁用的 → 安装但保持禁用;配置行(id/name/enabled/config)同步;
|
|
14
14
|
3. **不启动应用**。
|
|
15
15
|
- **点左下角「从WSL打开」**:启动 proxy 版桌面窗口(环境已就绪,秒级)。
|
|
16
|
-
-
|
|
16
|
+
- **副本已在运行时**:入口显示「WSL 窗口运行中」,仍可点击——点击会把已打开的 WSL 窗口带到前台
|
|
17
|
+
(副本再次启动触发 Electron 单实例聚焦)。当前窗口本身不会变成 WSL,切换只发生在副本里。
|
|
17
18
|
- 之后每次启动都不再同步,**WSL 侧手动启停的插件一直保持**。
|
|
18
19
|
|
|
19
20
|
命令只作兜底:
|
|
@@ -26,7 +27,10 @@
|
|
|
26
27
|
| `/wsl-desktop-setup` | 手动重建副本 |
|
|
27
28
|
| `/wsl-desktop-remove` | 删除副本与独立 Electron profile |
|
|
28
29
|
|
|
29
|
-
##
|
|
30
|
+
## 配置
|
|
31
|
+
|
|
32
|
+
安装后可在 Web 侧栏 **Plugins → `@karoy/dsh-wsl-desktop` → 行 `wsl-desktop` 的「配置」** 里改;保存会写回
|
|
33
|
+
profile 的 `cordis.patch.yml`,改动会重启插件。也可以直接写 profile patch 的 `config`(留空按默认)。
|
|
30
34
|
|
|
31
35
|
- `mode`: `"proxy"`(默认,保留桌面外壳)|`"direct"`(主窗口直接加载 WSL 页面)
|
|
32
36
|
- `installDir`:可选覆盖;默认 `%LOCALAPPDATA%\DeepSeek Harness WSL Desktop`(不写死盘符)
|
|
@@ -61,6 +65,9 @@
|
|
|
61
65
|
|
|
62
66
|
## 限制
|
|
63
67
|
|
|
68
|
+
- 「从WSL打开」不会把当前窗口切换成 WSL:原窗口的 Host 地址在启动时就固定了(`app.asar/lib/main.js`
|
|
69
|
+
的模块作用域变量),插件改不了它;只有另起的补丁副本是 WSL 的。副本运行后入口显示
|
|
70
|
+
「WSL 窗口运行中」,点击只负责把它带到前台。
|
|
64
71
|
- proxy 模式的工作区选择等目录操作走 WSL Host 的 browse 选择器(外壳的原生目录对话框
|
|
65
72
|
未接到 WSL 侧);「应用/编辑」菜单与窗口外壳保留。
|
|
66
73
|
- 会话、凭据、工作区都是 WSL 自己的;WSL 的 `~/.dsh` 与 Windows 的互不相干。
|
|
@@ -68,17 +75,12 @@
|
|
|
68
75
|
|
|
69
76
|
## 发布
|
|
70
77
|
|
|
71
|
-
仓库的 `NPM_TOKEN`
|
|
78
|
+
仓库的 `NPM_TOKEN` 具备直接发布权限:
|
|
72
79
|
|
|
73
80
|
1. 改 `package.json` 的 `version`,提交并 push;
|
|
74
|
-
2. 在 GitHub 创建 **Release**(发布)→ `
|
|
75
|
-
`npm
|
|
76
|
-
3.
|
|
77
|
-
`npm stage approve <uuid>`,或在 npmjs.com 的包页面批准;
|
|
78
|
-
4. 审批后验证:`npm view @karoy/dsh-wsl-desktop version`。
|
|
79
|
-
|
|
80
|
-
若要 CI 直接发布(不经暂存),把 `NPM_TOKEN` 换成具备
|
|
81
|
-
「Read and write (publish and stage)」权限的令牌,并把工作流改回 `npm publish`。
|
|
81
|
+
2. 在 GitHub 创建 **Release**(发布)→ `Publish to npm` 工作流先跑 CI,再执行
|
|
82
|
+
`npm publish --access public`;
|
|
83
|
+
3. 验证:`npm view @karoy/dsh-wsl-desktop version`(当前 `0.1.1`)。
|
|
82
84
|
## 回滚
|
|
83
85
|
|
|
84
86
|
`/wsl-desktop-remove`,或关闭窗口后删除 `installDir` 与 `%APPDATA%\DeepSeek Harness WSL`。
|
package/bin/auto.mjs
CHANGED
|
@@ -106,11 +106,12 @@ try {
|
|
|
106
106
|
steps.push('environment already initialized (no sync)')
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
if (config.autoLaunch !== false
|
|
109
|
+
if (config.autoLaunch !== false) {
|
|
110
|
+
// Launching while the copy already runs hits its single-instance lock and
|
|
111
|
+
// focuses the existing window; that is how the footer brings an open WSL
|
|
112
|
+
// window back to the foreground.
|
|
110
113
|
const pid = spawnCopy(config)
|
|
111
|
-
steps.push('launched pid=' + String(pid))
|
|
112
|
-
} else if (config.autoLaunch !== false && running) {
|
|
113
|
-
steps.push('launch skipped: copy is running')
|
|
114
|
+
steps.push((running ? 'focused existing copy pid=' : 'launched pid=') + String(pid))
|
|
114
115
|
} else {
|
|
115
116
|
steps.push('copy not started (start it from the button or /wsl-desktop-launch)')
|
|
116
117
|
}
|
package/client.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* Client half: a bottom-left footer entry (above Settings) that asks the Host to
|
|
3
3
|
* build/refresh the WSL Desktop proxy copy and launch it.
|
|
4
4
|
*
|
|
5
|
-
* Once the copy
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Once the copy is actually running, the entry shows "WSL 窗口运行中" and stays
|
|
6
|
+
* clickable: a second launch of the copy hits its single-instance lock and
|
|
7
|
+
* brings the open WSL window to the front. The current window never becomes the
|
|
8
|
+
* WSL one — its Host address is fixed at startup — so the entry must not claim
|
|
9
|
+
* "WSL mode" for it.
|
|
8
10
|
*
|
|
9
11
|
* @module @karoy/dsh-wsl-desktop/client
|
|
10
12
|
*/
|
|
@@ -20,8 +22,7 @@ window.__ModuleLoader__.load({
|
|
|
20
22
|
cursor:pointer;opacity:.85;white-space:nowrap;transition:opacity .12s,background .12s}
|
|
21
23
|
.dsh-wsl-desktop-footer[data-wide=true]{justify-content:flex-start;padding:0 10px}
|
|
22
24
|
.dsh-wsl-desktop-footer:hover{opacity:1;background:color-mix(in srgb,currentColor 10%,transparent)}
|
|
23
|
-
.dsh-wsl-desktop-footer[data-state=
|
|
24
|
-
.dsh-wsl-desktop-footer[data-state=starting]{opacity:.6;cursor:default;background:transparent}
|
|
25
|
+
.dsh-wsl-desktop-footer[data-state=running]{opacity:.9}
|
|
25
26
|
.dsh-wsl-desktop-footer:focus-visible{outline:2px solid color-mix(in srgb,currentColor 45%,transparent);outline-offset:2px}
|
|
26
27
|
.dsh-wsl-desktop-footer:disabled{opacity:.45;cursor:default}
|
|
27
28
|
.dsh-wsl-desktop-footer[data-state=error]{color:#e5534b}
|
|
@@ -37,14 +38,11 @@ window.__ModuleLoader__.load({
|
|
|
37
38
|
h('path', { d: 'M4.4 5.2l1.8 1.5-1.8 1.5M7.8 8.2h2.6' }))
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
/** Host state: `running` = copy process alive
|
|
41
|
+
/** Host state: `running` = the copy process is alive (a separate WSL window). */
|
|
41
42
|
async function readState() {
|
|
42
43
|
const res = await fetch('/wsl-desktop/state', { headers: { accept: 'application/json' } })
|
|
43
44
|
const data = await res.json().catch(() => null)
|
|
44
|
-
return {
|
|
45
|
-
running: data?.ok === true && data.running === true,
|
|
46
|
-
wslMode: data?.ok === true && data.wslMode === true,
|
|
47
|
-
}
|
|
45
|
+
return { running: data?.ok === true && data.running === true }
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
async function openDesktop() {
|
|
@@ -65,10 +63,10 @@ window.__ModuleLoader__.load({
|
|
|
65
63
|
function WslDesktopFooter({ wide }) {
|
|
66
64
|
const [state, setState] = React.useState('idle')
|
|
67
65
|
const [detail, setDetail] = React.useState('')
|
|
68
|
-
const [copy, setCopy] = React.useState({ running: false
|
|
66
|
+
const [copy, setCopy] = React.useState({ running: false })
|
|
69
67
|
|
|
70
68
|
const reveal = () => {
|
|
71
|
-
readState().then(setCopy, () => setCopy({ running: false
|
|
69
|
+
readState().then(setCopy, () => setCopy({ running: false }))
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
React.useEffect(() => {
|
|
@@ -82,7 +80,7 @@ window.__ModuleLoader__.load({
|
|
|
82
80
|
}
|
|
83
81
|
}, [])
|
|
84
82
|
|
|
85
|
-
const busy = state === 'busy'
|
|
83
|
+
const busy = state === 'busy'
|
|
86
84
|
const onClick = () => {
|
|
87
85
|
if (busy) return
|
|
88
86
|
setState('busy')
|
|
@@ -101,23 +99,19 @@ window.__ModuleLoader__.load({
|
|
|
101
99
|
)
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
const label = copy.
|
|
105
|
-
? 'WSL
|
|
106
|
-
:
|
|
107
|
-
? '
|
|
108
|
-
: state === 'busy'
|
|
109
|
-
? '准备中'
|
|
110
|
-
: state === 'error'
|
|
111
|
-
? '启动失败'
|
|
112
|
-
: '从WSL打开'
|
|
113
|
-
const title = copy.wslMode
|
|
114
|
-
? '当前 WSL 桌面已在运行(WSL 模式)'
|
|
115
|
-
: copy.running
|
|
116
|
-
? 'WSL 桌面正在启动…'
|
|
102
|
+
const label = copy.running
|
|
103
|
+
? 'WSL 窗口运行中'
|
|
104
|
+
: state === 'busy'
|
|
105
|
+
? '准备中'
|
|
117
106
|
: state === 'error'
|
|
118
|
-
?
|
|
119
|
-
: '
|
|
120
|
-
const
|
|
107
|
+
? '启动失败'
|
|
108
|
+
: '从WSL打开'
|
|
109
|
+
const title = copy.running
|
|
110
|
+
? 'WSL 窗口已在运行,点击把它带到前台'
|
|
111
|
+
: state === 'error'
|
|
112
|
+
? `启动失败:${detail}`
|
|
113
|
+
: '在 WSL 中打开 DSH 桌面窗口(另起副本;当前窗口不会切换)'
|
|
114
|
+
const buttonState = copy.running ? 'running' : state === 'error' ? 'error' : state
|
|
121
115
|
|
|
122
116
|
return h(React.Fragment, null,
|
|
123
117
|
h('style', null, CSS),
|
|
@@ -133,6 +127,122 @@ window.__ModuleLoader__.load({
|
|
|
133
127
|
}, h(DesktopIcon, { size: 15 }), wide ? h('span', null, label) : null))
|
|
134
128
|
}
|
|
135
129
|
|
|
130
|
+
const SETTINGS_CSS = `
|
|
131
|
+
.dsh-wsl-settings{display:flex;flex-direction:column;gap:14px;font-size:13px}
|
|
132
|
+
.dsh-wsl-settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}
|
|
133
|
+
.dsh-wsl-settings-label{display:flex;flex-direction:column;gap:2px}
|
|
134
|
+
.dsh-wsl-settings-label small{color:color-mix(in srgb,currentColor 60%,transparent);font-size:12px}
|
|
135
|
+
.dsh-wsl-settings input[type=text],.dsh-wsl-settings input[type=number],.dsh-wsl-settings select{width:220px;padding:4px 8px;border-radius:6px;border:1px solid color-mix(in srgb,currentColor 25%,transparent);background:transparent;color:inherit;font:inherit}
|
|
136
|
+
.dsh-wsl-settings-actions{display:flex;gap:8px;justify-content:flex-end}
|
|
137
|
+
.dsh-wsl-settings button{padding:4px 12px;border-radius:6px;border:1px solid color-mix(in srgb,currentColor 25%,transparent);background:transparent;color:inherit;font:inherit;cursor:pointer}
|
|
138
|
+
.dsh-wsl-settings button[data-primary=true]{background:color-mix(in srgb,currentColor 12%,transparent)}
|
|
139
|
+
.dsh-wsl-settings button:disabled{opacity:.45;cursor:default}
|
|
140
|
+
.dsh-wsl-settings .dsh-wsl-settings-note{color:#e5534b;font-size:12px;margin:0}
|
|
141
|
+
`
|
|
142
|
+
|
|
143
|
+
const SETTINGS_FIELDS = [
|
|
144
|
+
{ key: 'mode', label: '模式', help: 'proxy 保留桌面外壳;direct 主窗口直接加载 WSL 页面', kind: 'select', options: [['proxy', 'proxy'], ['direct', 'direct']] },
|
|
145
|
+
{ key: 'port', label: '端口', help: 'WSL 内 DSH Host 的端口', kind: 'number', min: 1, max: 65535 },
|
|
146
|
+
{ key: 'distro', label: '发行版', help: '留空使用 WSL 默认发行版', kind: 'text' },
|
|
147
|
+
{ key: 'autoInstall', label: '自动安装运行时', help: 'WSL 缺少 Node/DSH 时自动安装', kind: 'boolean' },
|
|
148
|
+
{ key: 'autoSetup', label: '自动准备副本', help: '副本缺失、模式变化或 Desktop 升级时重建', kind: 'boolean' },
|
|
149
|
+
{ key: 'autoRun', label: '启动时自动准备', help: 'DSH 启动后自动跑一次准备(不启动窗口)', kind: 'boolean' },
|
|
150
|
+
{ key: 'autoLaunch', label: '准备后自动启动', help: '准备完成后直接打开 WSL 窗口', kind: 'boolean' },
|
|
151
|
+
{ key: 'syncWslPlugins', label: '同步插件', help: '首次初始化时把 Windows 插件镜像到 WSL', kind: 'boolean' },
|
|
152
|
+
{ key: 'syncLinked', label: '同步 link 插件', help: '包含 link: 安装的插件(默认跳过)', kind: 'boolean' },
|
|
153
|
+
{ key: 'autoDelayMs', label: '准备延迟 (ms)', help: 'DSH 启动后等待多久开始准备', kind: 'number', min: 0 },
|
|
154
|
+
{ key: 'installDir', label: '副本目录', help: '留空使用 %LOCALAPPDATA%\\DeepSeek Harness WSL Desktop', kind: 'text' },
|
|
155
|
+
{ key: 'userDataDirName', label: 'Electron profile 名', help: '副本使用的独立 userData 目录名', kind: 'text' },
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
const SETTINGS_ROW_KEY = '@karoy/dsh-wsl-desktop#wsl-desktop'
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The row's configuration page on the Plugins page: the Host owns the values
|
|
162
|
+
* and writes them into the profile patch through the form it hands over.
|
|
163
|
+
*/
|
|
164
|
+
function WslDesktopSettings(props) {
|
|
165
|
+
const form = props.form
|
|
166
|
+
const state = form?.state
|
|
167
|
+
const value = state?.value
|
|
168
|
+
const [draft, setDraft] = React.useState(null)
|
|
169
|
+
const [saving, setSaving] = React.useState(false)
|
|
170
|
+
const [error, setError] = React.useState('')
|
|
171
|
+
|
|
172
|
+
React.useEffect(() => {
|
|
173
|
+
if (value !== undefined) setDraft({ ...value })
|
|
174
|
+
}, [value])
|
|
175
|
+
|
|
176
|
+
if (props.view === 'summary') return 'WSL 桌面配置:模式、端口、自动准备与插件同步'
|
|
177
|
+
|
|
178
|
+
if (form === undefined || state === undefined) {
|
|
179
|
+
return h('p', { className: 'dsh-wsl-settings-note' }, '配置暂不可用:Host 没有提供 wsl-desktop 命名空间')
|
|
180
|
+
}
|
|
181
|
+
if (state.status === 'loading' || draft === null || value === undefined) return h('p', null, '读取配置…')
|
|
182
|
+
|
|
183
|
+
const writable = state.writable
|
|
184
|
+
const dirty = JSON.stringify(draft) !== JSON.stringify(value)
|
|
185
|
+
const disabled = !writable || saving
|
|
186
|
+
const ops = []
|
|
187
|
+
for (const key of Object.keys(value)) {
|
|
188
|
+
if (JSON.stringify(draft[key]) !== JSON.stringify(value[key])) ops.push({ op: 'set', path: [key], value: draft[key] })
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const save = async () => {
|
|
192
|
+
if (ops.length === 0) return
|
|
193
|
+
setSaving(true)
|
|
194
|
+
setError('')
|
|
195
|
+
try {
|
|
196
|
+
const accepted = await form.mutate(ops, state.revision)
|
|
197
|
+
if (!accepted) setError('保存被宿主拒绝:值未通过校验,或配置在读取后被改动')
|
|
198
|
+
} catch (thrown) {
|
|
199
|
+
setError(thrown instanceof Error ? thrown.message : String(thrown))
|
|
200
|
+
} finally {
|
|
201
|
+
setSaving(false)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const rows = SETTINGS_FIELDS.map((field) => {
|
|
206
|
+
const current = draft[field.key]
|
|
207
|
+
const id = 'wsl-desktop-' + field.key
|
|
208
|
+
let control
|
|
209
|
+
if (field.kind === 'boolean') {
|
|
210
|
+
control = h('input', {
|
|
211
|
+
id, type: 'checkbox', checked: current === true, disabled,
|
|
212
|
+
onChange: (event) => setDraft({ ...draft, [field.key]: event.target.checked }),
|
|
213
|
+
})
|
|
214
|
+
} else if (field.kind === 'select') {
|
|
215
|
+
control = h('select', {
|
|
216
|
+
id, value: current ?? '', disabled,
|
|
217
|
+
onChange: (event) => setDraft({ ...draft, [field.key]: event.target.value }),
|
|
218
|
+
}, field.options.map(([option, label]) => h('option', { key: option, value: option }, label)))
|
|
219
|
+
} else {
|
|
220
|
+
control = h('input', {
|
|
221
|
+
id, type: field.kind === 'number' ? 'number' : 'text',
|
|
222
|
+
value: current ?? '', disabled, min: field.min, max: field.max,
|
|
223
|
+
onChange: (event) => setDraft({
|
|
224
|
+
...draft,
|
|
225
|
+
[field.key]: field.kind === 'number' ? Number(event.target.value) : event.target.value,
|
|
226
|
+
}),
|
|
227
|
+
})
|
|
228
|
+
}
|
|
229
|
+
return h('div', { className: 'dsh-wsl-settings-row', key: field.key },
|
|
230
|
+
h('label', { className: 'dsh-wsl-settings-label', htmlFor: id },
|
|
231
|
+
h('span', null, field.label),
|
|
232
|
+
field.help ? h('small', null, field.help) : null),
|
|
233
|
+
control)
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
return h('div', { className: 'dsh-wsl-settings' },
|
|
237
|
+
h('style', null, SETTINGS_CSS),
|
|
238
|
+
...rows,
|
|
239
|
+
error === '' ? null : h('p', { className: 'dsh-wsl-settings-note' }, error),
|
|
240
|
+
writable ? null : h('p', { className: 'dsh-wsl-settings-note' }, '当前 profile 的配置是只读的'),
|
|
241
|
+
h('div', { className: 'dsh-wsl-settings-actions' },
|
|
242
|
+
h('button', { type: 'button', disabled: disabled || !dirty, onClick: () => setDraft({ ...value }) }, '还原'),
|
|
243
|
+
h('button', { type: 'button', 'data-primary': 'true', disabled: disabled || !dirty, onClick: save }, saving ? '保存中…' : '保存')))
|
|
244
|
+
}
|
|
245
|
+
|
|
136
246
|
return {
|
|
137
247
|
inject: ['slots'],
|
|
138
248
|
apply(ctx) {
|
|
@@ -141,6 +251,10 @@ window.__ModuleLoader__.load({
|
|
|
141
251
|
id: 'wsl-desktop',
|
|
142
252
|
order: 4,
|
|
143
253
|
}, WslDesktopFooter))
|
|
254
|
+
ctx.slots.inject('plugins.row.config', () => ctx.slots.register({
|
|
255
|
+
name: 'plugins.row.config',
|
|
256
|
+
key: SETTINGS_ROW_KEY,
|
|
257
|
+
}, WslDesktopSettings))
|
|
144
258
|
},
|
|
145
259
|
}
|
|
146
260
|
},
|
package/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import fs from 'node:fs'
|
|
|
12
12
|
import os from 'node:os'
|
|
13
13
|
import path from 'node:path'
|
|
14
14
|
import { fileURLToPath } from 'node:url'
|
|
15
|
+
import z from '@deepseek-ai/schemastery'
|
|
15
16
|
import { remove, resolveConfig, setup, status } from './lib/setup.js'
|
|
16
17
|
import { needsBuild, readStatus } from './lib/state.js'
|
|
17
18
|
import { spawnCopy } from './lib/launch.js'
|
|
@@ -20,6 +21,26 @@ import { syncPlugins } from './lib/sync.js'
|
|
|
20
21
|
|
|
21
22
|
export const inject = ['commands', 'webServer']
|
|
22
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Row configuration, editable from the Plugins page (settings namespace
|
|
26
|
+
* `wsl-desktop`). The profile patch supplies the defaults below; a saved edit
|
|
27
|
+
* restarts this plugin, so `apply` re-reads the new values.
|
|
28
|
+
*/
|
|
29
|
+
export const Config = z.object({
|
|
30
|
+
mode: z.union([z.const('proxy'), z.const('direct')]).default('proxy'),
|
|
31
|
+
port: z.number().default(3080),
|
|
32
|
+
distro: z.string().default(''),
|
|
33
|
+
autoInstall: z.boolean().default(true),
|
|
34
|
+
autoRun: z.boolean().default(true),
|
|
35
|
+
autoSetup: z.boolean().default(true),
|
|
36
|
+
autoLaunch: z.boolean().default(false),
|
|
37
|
+
syncWslPlugins: z.boolean().default(true),
|
|
38
|
+
syncLinked: z.boolean().default(false),
|
|
39
|
+
autoDelayMs: z.number().default(4000),
|
|
40
|
+
installDir: z.string().default(''),
|
|
41
|
+
userDataDirName: z.string().default('DeepSeek Harness WSL'),
|
|
42
|
+
})
|
|
43
|
+
|
|
23
44
|
let scheduled = false
|
|
24
45
|
let runningCache = { at: 0, value: false }
|
|
25
46
|
|
package/lib/merge-patch.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from 'node:path'
|
|
|
4
4
|
import { createRequire } from 'node:module'
|
|
5
5
|
import { spawnSync } from 'node:child_process'
|
|
6
6
|
|
|
7
|
-
const require$ = createRequire(
|
|
7
|
+
const require$ = createRequire(import.meta.url)
|
|
8
8
|
const yaml = require$('yaml')
|
|
9
9
|
|
|
10
10
|
/** Windows temp file path spoken in WSL terms (`C:\...` → `/mnt/c/...`). */
|
package/lib/setup.js
CHANGED
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { spawnSync } from 'node:child_process'
|
|
15
15
|
import fs from 'node:fs'
|
|
16
|
+
import { createRequire } from 'node:module'
|
|
16
17
|
import os from 'node:os'
|
|
17
18
|
import path from 'node:path'
|
|
18
19
|
import { writeStamp } from './state.js'
|
|
19
20
|
|
|
21
|
+
const require$ = createRequire(import.meta.url)
|
|
22
|
+
|
|
20
23
|
const MARKER = 'wsl-desktop patch'
|
|
21
24
|
const HELPER_MARKER = 'wslDesktopRequire'
|
|
22
25
|
|
|
@@ -78,21 +81,27 @@ function copyInstall(sourceDir, installDir) {
|
|
|
78
81
|
fs.rmSync(installDir, { recursive: true, force: true })
|
|
79
82
|
}
|
|
80
83
|
fs.mkdirSync(installDir, { recursive: true })
|
|
81
|
-
|
|
84
|
+
// Skip what the copy does not need: app.asar (extracted straight from the
|
|
85
|
+
// installed app) and its unpacked payload (extractAll pulls those files from
|
|
86
|
+
// the source's app.asar.unpacked). Together they are ~450 MB of the ~1 GB
|
|
87
|
+
// install, and skipping the archive also avoids racing its rename (EBUSY).
|
|
88
|
+
const status = run('robocopy', [
|
|
89
|
+
sourceDir, installDir, '/E', '/NFL', '/NDL', '/NJH', '/NP',
|
|
90
|
+
'/XF', 'app.asar', '/XD', 'app.asar.unpacked',
|
|
91
|
+
])
|
|
82
92
|
if (status > 7) throw new Error('wsl-desktop: robocopy failed with ' + String(status))
|
|
83
93
|
}
|
|
84
94
|
|
|
85
|
-
function extractAsar(resourcesDir) {
|
|
86
|
-
const
|
|
95
|
+
function extractAsar(sourceDir, resourcesDir) {
|
|
96
|
+
const sourceAsar = path.join(sourceDir, 'resources', 'app.asar')
|
|
97
|
+
if (!fs.existsSync(sourceAsar)) throw new Error('wsl-desktop: source resources/app.asar is missing')
|
|
87
98
|
const app = path.join(resourcesDir, 'app')
|
|
88
|
-
const
|
|
89
|
-
if (!fs.existsSync(
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
const mainPath = path.join(app, 'lib', 'main.js')
|
|
100
|
+
if (!fs.existsSync(mainPath)) {
|
|
101
|
+
fs.rmSync(app, { recursive: true, force: true })
|
|
102
|
+
require$('@electron/asar').extractAll(sourceAsar, app)
|
|
92
103
|
}
|
|
93
|
-
|
|
94
|
-
if (!fs.existsSync(path.join(app, 'lib', 'main.js'))) throw new Error('wsl-desktop: asar extraction produced no app/lib/main.js')
|
|
95
|
-
fs.renameSync(asar, backup)
|
|
104
|
+
if (!fs.existsSync(mainPath)) throw new Error('wsl-desktop: asar extraction produced no app/lib/main.js')
|
|
96
105
|
}
|
|
97
106
|
|
|
98
107
|
export function patchMain(mainPath, config) {
|
|
@@ -246,7 +255,7 @@ export function setup(pluginConfig = {}) {
|
|
|
246
255
|
|
|
247
256
|
copyInstall(sourceDir, installDir)
|
|
248
257
|
const resourcesDir = path.join(installDir, 'resources')
|
|
249
|
-
extractAsar(resourcesDir)
|
|
258
|
+
extractAsar(sourceDir, resourcesDir)
|
|
250
259
|
const mainPath = path.join(resourcesDir, 'app', 'lib', 'main.js')
|
|
251
260
|
patchMain(mainPath, config)
|
|
252
261
|
installHelper(resourcesDir)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karoy/dsh-wsl-desktop",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Install and launch a DSH Desktop copy whose Electron shell proxies its Host connection to a DSH Host running inside WSL",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -59,5 +59,10 @@
|
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@deepseek-ai/cordis": "*"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@deepseek-ai/schemastery": "^3.19.0",
|
|
65
|
+
"@electron/asar": "^4.0.1",
|
|
66
|
+
"yaml": "^2.8.1"
|
|
62
67
|
}
|
|
63
68
|
}
|