@xi-ix/dsh-multi-sync 0.0.0-stage → 0.1.1

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 CHANGED
@@ -1,3 +1,63 @@
1
- # Temporary Holding Version
1
+ # Multi-machine plugin sync
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Carries the plugin set from one machine to another as a single pinned list, without
4
+ moving `node_modules`, a lockfile, or a credentials file between them.
5
+
6
+ ## What it does
7
+
8
+ The plugin state that actually travels is small: which packages are installed and
9
+ which exact version each one has. This plugin reads that from the running profile
10
+ and writes it to one portable JSON document.
11
+
12
+ - **Scan** reads the profile's direct `dependencies`, keeps every entry that a
13
+ registry can serve, and asks the installed package on disk for its real version —
14
+ not the `^0.4.2` range in `package.json`. Entries that cannot be fetched
15
+ (`file:`, `link:`, `workspace:`, `git+`, `http:`) are listed separately as
16
+ skipped, with the reason, so a difference between two machines is visible
17
+ instead of silent.
18
+ - **Export** writes the scan as `dsh-plugins.json`. Each entry carries its exact
19
+ version and, when the profile lockfile records one, the tarball's `integrity`
20
+ hash — the value that makes "same plugin" mean the same bytes rather than the
21
+ same version number.
22
+ - **Import** reads a list back (file, drag-and-drop, or pasted text), compares each
23
+ entry with what this machine already has, and shows one row per plugin with the
24
+ action it would take: new, upgrade, already installed, or unavailable.
25
+ - **Install** sends the selected `name@version` specifications to
26
+ `dsh plugin --profile <name> add …` in one call. The DSH plugin manager installs
27
+ them, registers new bundles in `dsh.profile.bundles`, runs its compatibility
28
+ checks, and writes the lockfile.
29
+
30
+ ## Usage
31
+
32
+ 1. Open **Settings → Multi-sync**.
33
+ 2. On the machine that already has the plugins, choose **Source**, press
34
+ **Scan installed plugins**, then **Export** (or copy the text).
35
+ 3. Move the file to the other machine however you like.
36
+ 4. There, choose **Follower**, drop the file in, pick the entries to install, and
37
+ press **Install selected**.
38
+ 5. Restart DeepSeek Harness so the newly installed plugins load.
39
+
40
+ The first time, the follower has no copy of this plugin yet, so install it by hand
41
+ once: `dsh plugin --profile desktop add @xi-ix/dsh-multi-sync@<version>`.
42
+
43
+ ## What it deliberately does not do
44
+
45
+ - **It does not restart the harness.** Restarting belongs to the desktop shell, and a
46
+ plugin cannot reach it: the shell accepts no restart request from a host, and every
47
+ process this plugin starts is reaped with the app. Restart with the tray icon on
48
+ Windows (right-click → Quit DeepSeek Harness, then reopen) or the menu on macOS.
49
+ - **It does not touch enable/disable state or per-plugin configuration.** Those
50
+ live in `cordis.patch.yml` and the plugin market's `state.json`, which the market
51
+ owns and rewrites; a second writer there gets reverted. A plugin installed here
52
+ keeps its own default on/off state on the follower.
53
+ - **It does not mirror deletions.** Installing never removes a plugin that the list
54
+ does not mention.
55
+ - **It does not pin transitive dependencies.** Each listed plugin's own
56
+ `dependencies` still resolve at install time, so two machines can differ below
57
+ the top level if a plugin dependency allows a range.
58
+
59
+ ## Requirements
60
+
61
+ DeepSeek Harness with its bundled `dsh` CLI available either through
62
+ `DSH_NODE_EXECUTABLE`/`DSH_INSTALL_DIR` or on `PATH`, and network access to the
63
+ registry that serves the listed packages.
package/client.js ADDED
@@ -0,0 +1,576 @@
1
+ window.__ModuleLoader__.load({
2
+ id: '@xi-ix/dsh-multi-sync',
3
+ factory(require) {
4
+ const React = require('react')
5
+ const h = React.createElement
6
+ const { useState, useEffect, useCallback, useRef } = React
7
+
8
+ const BASE = '/dsh-multi-sync'
9
+
10
+ const zh =
11
+ (typeof navigator !== 'undefined' && /^zh/i.test(navigator.language || '')) ||
12
+ (typeof document !== 'undefined' && /^zh/i.test(document.documentElement.lang || ''))
13
+
14
+ const L = zh
15
+ ? {
16
+ title: '多端插件同步',
17
+ subtitle: '把这台机器装好的插件,按精确版本带到另一台机器。',
18
+ role: '这台机器的角色',
19
+ source: '源机',
20
+ follower: '从属机',
21
+ sourceHint: '扫描本机插件,导出一份清单,用任意方式传到另一台机器。',
22
+ followerHint: '载入清单,勾选要装的插件,一次性安装。',
23
+ scan: '扫描本机插件',
24
+ scanning: '扫描中…',
25
+ export: '导出 dsh-plugins.json',
26
+ copy: '复制清单',
27
+ copied: '已复制',
28
+ profile: 'profile',
29
+ version: 'DSH',
30
+ plugins: '插件',
31
+ skipped: '跳过',
32
+ name: '包名',
33
+ pinned: '版本',
34
+ kind: '类型',
35
+ drop: '把清单文件拖到这里,或',
36
+ choose: '选择文件',
37
+ orPaste: '也可以直接粘贴内容',
38
+ parse: '解析清单',
39
+ install: '安装选中的',
40
+ installing: '安装中…',
41
+ cancel: '取消',
42
+ selectAll: '全选可安装',
43
+ empty: '还没有扫描结果。',
44
+ noRows: '清单里没有可安装的 npm 插件。',
45
+ nothingSelected: '没有选中任何插件(「已装」的行不会重复安装)。',
46
+ cliMissing: '找不到 dsh 命令行。试过:',
47
+ from: '清单来源',
48
+ generatedAt: '生成时间',
49
+ mismatch: '清单来自另一台机器,DSH 版本不同,安装前请留意。',
50
+ localConflict: '本机是本地挂载',
51
+ done: '完成',
52
+ failed: '失败',
53
+ same: '已装',
54
+ upgrade: '升级',
55
+ downgrade: '降级',
56
+ linked: '本地挂载',
57
+ added: '新增',
58
+ local: '本地',
59
+ remote: '非 registry',
60
+ unknown: '未知',
61
+ alreadyTitle: '这些已经装过,不会重复处理',
62
+ linkedHint: '本机是本地挂载(file:/link:),装上会用 registry 里的包替换它。',
63
+ downgradeHint: '本机版本比清单里的新,勾选会降级。',
64
+ restartHintWindows: '装完或更新完插件后需要重启:右下角托盘图标 → 右键 → 退出 DeepSeek Harness,再重新打开。',
65
+ restartHintMac: '装完或更新完插件后需要重启:菜单栏 DeepSeek Harness → 重启应用与 Host。',
66
+ restartHintWeb: '装完插件后需要重启:退出当前进程,重新运行 dsh web。',
67
+ restartAfterInstall: '安装完成,重启后生效。',
68
+ }
69
+ : {
70
+ title: 'Multi-machine plugin sync',
71
+ subtitle: 'Carry the plugins installed here to the other machine, pinned to exact versions.',
72
+ role: 'Role of this machine',
73
+ source: 'Source',
74
+ follower: 'Follower',
75
+ sourceHint: 'Scan this machine, export one list, move it however you like.',
76
+ followerHint: 'Load a list, pick what to install, install once.',
77
+ scan: 'Scan installed plugins',
78
+ scanning: 'Scanning…',
79
+ export: 'Export dsh-plugins.json',
80
+ copy: 'Copy list',
81
+ copied: 'Copied',
82
+ profile: 'profile',
83
+ version: 'DSH',
84
+ plugins: 'plugins',
85
+ skipped: 'skipped',
86
+ name: 'Package',
87
+ pinned: 'Version',
88
+ kind: 'Kind',
89
+ drop: 'Drop the list file here, or',
90
+ choose: 'choose a file',
91
+ orPaste: 'or paste it',
92
+ parse: 'Read list',
93
+ install: 'Install selected',
94
+ installing: 'Installing…',
95
+ cancel: 'Cancel',
96
+ selectAll: 'Select installable',
97
+ empty: 'Nothing scanned yet.',
98
+ noRows: 'The list has no installable npm plugin.',
99
+ nothingSelected: 'Nothing is selected ("installed" rows are not reinstalled).',
100
+ cliMissing: 'Cannot find the dsh CLI. Tried:',
101
+ from: 'List from',
102
+ generatedAt: 'Generated',
103
+ mismatch: 'This list came from a machine running a different DSH version — check before installing.',
104
+ localConflict: 'locally linked here',
105
+ done: 'done',
106
+ failed: 'failed',
107
+ same: 'installed',
108
+ upgrade: 'upgrade',
109
+ downgrade: 'downgrade',
110
+ linked: 'local link',
111
+ added: 'new',
112
+ local: 'local',
113
+ remote: 'non-registry',
114
+ unknown: 'unknown',
115
+ alreadyTitle: 'Already installed — left untouched',
116
+ linkedHint: 'This machine links it locally (file:/link:); installing replaces that mount with the registry package.',
117
+ downgradeHint: 'This machine has a newer version; selecting it would downgrade.',
118
+ restartHintWindows: 'After installing or updating plugins, restart: right-click the tray icon and choose Quit DeepSeek Harness, then reopen it.',
119
+ restartHintMac: 'After installing or updating plugins, restart from the menu bar: DeepSeek Harness → Restart App and Host.',
120
+ restartHintWeb: 'After installing plugins, restart by stopping this process and running dsh web again.',
121
+ restartAfterInstall: 'Installed — takes effect after a restart.',
122
+ }
123
+
124
+ const CSS = `
125
+ .dms { display: flex; flex-direction: column; gap: 14px; color: var(--dsw-alias-label-primary); }
126
+ .dms h2 { margin: 0; font-size: 15px; font-weight: 600; }
127
+ .dms .sub { font-size: 12px; opacity: .7; margin: 0; }
128
+ .dms .card { border: 1px solid var(--dsw-alias-border-l2, #ddd); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
129
+ .dms .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
130
+ .dms .grow { flex: 1; }
131
+ .dms button { padding: 5px 11px; border: 1px solid var(--dsw-alias-border-l2, #ddd); border-radius: 7px; background: transparent; color: inherit; cursor: pointer; font-size: 13px; }
132
+ .dms button:hover:not(:disabled) { background: var(--dsw-alias-bg-layer-2, #f3f3f3); }
133
+ .dms button.primary { background: var(--dsw-alias-brand-primary, #4f46e5); border-color: transparent; color: #fff; }
134
+ /* Keep the filled button filled on hover: the generic rule above would swap its
135
+ background for a light layer while the label stays white. */
136
+ .dms button.primary:hover:not(:disabled) { background: var(--dsw-alias-brand-primary, #4f46e5); filter: brightness(1.12); }
137
+ .dms button.active { background: var(--dsw-alias-interactive-bg, #ececf5); font-weight: 600; }
138
+ .dms button:disabled { opacity: .5; cursor: default; }
139
+ .dms table { width: 100%; border-collapse: collapse; font-size: 12px; }
140
+ .dms th, .dms td { text-align: left; padding: 5px 7px; border-bottom: 1px solid var(--dsw-alias-border-l1, #eee); }
141
+ .dms th { font-weight: 600; opacity: .7; }
142
+ .dms .muted { opacity: .65; font-size: 11px; }
143
+ .dms .msg { font-size: 12px; padding: 8px 10px; border-radius: 7px; background: var(--dsw-alias-bg-layer-2, #f5f5f5); white-space: pre-wrap; word-break: break-word; }
144
+ .dms .msg.err { background: var(--dsw-alias-state-error-soft, #fdecec); }
145
+ .dms .msg.ok { background: var(--dsw-alias-state-success-soft, #eaf7ee); }
146
+ .dms textarea { width: 100%; min-height: 120px; font-family: ui-monospace, monospace; font-size: 12px; padding: 8px; border-radius: 8px; border: 1px solid var(--dsw-alias-border-l2, #ddd); background: var(--dsw-alias-bg-layer-1, #fff); color: inherit; }
147
+ .dms .drop { border: 1px dashed var(--dsw-alias-border-l2, #ccc); border-radius: 9px; padding: 14px; text-align: center; font-size: 12px; }
148
+ .dms .overlay { position: fixed; inset: 0; background: rgba(0,0,0,.42); display: flex; align-items: center; justify-content: center; z-index: 60; }
149
+ .dms .modal { background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-primary, #111); border-radius: 14px; padding: 16px; width: min(680px, 92vw); max-height: 84vh; overflow: auto; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
150
+ .dms .badge { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px; background: var(--dsw-alias-bg-layer-2, #f0f0f0); }
151
+ .dms .badge.new { background: var(--dsw-alias-state-success-soft, #e7f6ec); }
152
+ .dms .badge.upgrade { background: var(--dsw-alias-state-info-soft, #e8f0fe); }
153
+ .dms .file { display: inline-block; }
154
+ .dms .file input { display: none; }
155
+ `
156
+
157
+ async function api(path, options) {
158
+ const response = await fetch(BASE + path, {
159
+ cache: 'no-store',
160
+ credentials: 'same-origin',
161
+ ...options,
162
+ })
163
+ const body = await response.json().catch(() => null)
164
+ if (!response.ok || body === null || body.ok === false) {
165
+ throw new Error((body && body.error) || `HTTP ${response.status}`)
166
+ }
167
+ return body
168
+ }
169
+
170
+ function post(path, value) {
171
+ return api(path, {
172
+ method: 'POST',
173
+ headers: { 'content-type': 'application/json' },
174
+ body: JSON.stringify(value),
175
+ })
176
+ }
177
+
178
+ function download(text, filename) {
179
+ try {
180
+ const blob = new Blob([text], { type: 'application/json' })
181
+ const href = URL.createObjectURL(blob)
182
+ const anchor = document.createElement('a')
183
+ anchor.href = href
184
+ anchor.download = filename
185
+ document.body.appendChild(anchor)
186
+ anchor.click()
187
+ anchor.remove()
188
+ setTimeout(() => URL.revokeObjectURL(href), 4000)
189
+ return true
190
+ } catch {
191
+ return false
192
+ }
193
+ }
194
+
195
+ function Panel() {
196
+ const [info, setInfo] = useState(null)
197
+ const [role, setRole] = useState('source')
198
+ const [list, setList] = useState(null)
199
+ const [text, setText] = useState('')
200
+ const [rows, setRows] = useState(null)
201
+ const [header, setHeader] = useState(null)
202
+ const [selected, setSelected] = useState({})
203
+ const [busy, setBusy] = useState('')
204
+ const [message, setMessage] = useState(null)
205
+ const [result, setResult] = useState(null)
206
+ const fileInput = useRef(null)
207
+
208
+ useEffect(() => {
209
+ let alive = true
210
+ api('/state')
211
+ .then((body) => {
212
+ if (!alive) return
213
+ setInfo(body)
214
+ setRole(body.role)
215
+ })
216
+ .catch((error) => alive && setMessage({ kind: 'err', text: String(error.message || error) }))
217
+ return () => {
218
+ alive = false
219
+ }
220
+ }, [])
221
+
222
+ const asJson = useCallback(() => {
223
+ if (list === null) return ''
224
+ return JSON.stringify(list, undefined, 2) + '\n'
225
+ }, [list])
226
+
227
+ const changeRole = useCallback(async (next) => {
228
+ setBusy('role')
229
+ try {
230
+ const body = await post('/role', { role: next })
231
+ setRole(body.role)
232
+ } catch (error) {
233
+ setMessage({ kind: 'err', text: String(error.message || error) })
234
+ } finally {
235
+ setBusy('')
236
+ }
237
+ }, [])
238
+
239
+ const runScan = useCallback(async () => {
240
+ setBusy('scan')
241
+ setMessage(null)
242
+ try {
243
+ const body = await api('/scan')
244
+ setList(body.list)
245
+ setText(JSON.stringify(body.list, undefined, 2) + '\n')
246
+ } catch (error) {
247
+ setMessage({ kind: 'err', text: String(error.message || error) })
248
+ } finally {
249
+ setBusy('')
250
+ }
251
+ }, [])
252
+
253
+ const doExport = useCallback(() => {
254
+ const json = asJson()
255
+ if (json === '') return
256
+ const saved = download(json, 'dsh-plugins.json')
257
+ setMessage(
258
+ saved
259
+ ? { kind: 'ok', text: zh ? '已开始下载 dsh-plugins.json(也可以复制下面的内容)' : 'Download started (you can also copy the text below)' }
260
+ : { kind: 'ok', text: zh ? '无法下载,请复制下面的内容' : 'Download unavailable — copy the text below' },
261
+ )
262
+ }, [asJson])
263
+
264
+ const doCopy = useCallback(async () => {
265
+ const json = asJson()
266
+ if (json === '') return
267
+ try {
268
+ await navigator.clipboard.writeText(json)
269
+ setMessage({ kind: 'ok', text: L.copied })
270
+ } catch {
271
+ setMessage({ kind: 'err', text: zh ? '复制失败,请手动选中复制' : 'Copy failed — select the text manually' })
272
+ }
273
+ }, [asJson])
274
+
275
+ const readList = useCallback(async (value) => {
276
+ setBusy('parse')
277
+ setMessage(null)
278
+ try {
279
+ const body = await post('/parse', { text: value })
280
+ const next = {}
281
+ for (const row of body.rows) {
282
+ if (row.state === 'new' || row.state === 'upgrade') next[row.name] = true
283
+ }
284
+ setRows(body.rows)
285
+ setHeader(body.header)
286
+ setSelected(next)
287
+ } catch (error) {
288
+ setMessage({ kind: 'err', text: String(error.message || error) })
289
+ } finally {
290
+ setBusy('')
291
+ }
292
+ }, [])
293
+
294
+ const onFile = useCallback(
295
+ (file) => {
296
+ if (!file) return
297
+ const reader = new FileReader()
298
+ reader.onload = () => {
299
+ const value = String(reader.result || '')
300
+ setText(value)
301
+ void readList(value)
302
+ }
303
+ reader.readAsText(file)
304
+ },
305
+ [readList],
306
+ )
307
+
308
+ const install = useCallback(async () => {
309
+ const items = (rows || []).filter((row) => selected[row.name]).map((row) => ({ name: row.name, version: row.version }))
310
+ if (items.length === 0) {
311
+ setMessage({ kind: 'err', text: L.nothingSelected })
312
+ return
313
+ }
314
+ setBusy('install')
315
+ setMessage(null)
316
+ try {
317
+ const body = await post('/apply', { items })
318
+ setResult(body.result)
319
+ setRows(null)
320
+ if (body.result.ok) {
321
+ setMessage({ kind: 'ok', text: L.restartAfterInstall })
322
+ const state = await api('/scan').catch(() => null)
323
+ if (state) setList(state.list)
324
+ } else {
325
+ const detail = body.result.stderr || body.result.message || 'install failed'
326
+ const tried = Array.isArray(body.result.tried) && body.result.tried.length > 0 ? `\n\n${L.cliMissing}\n${body.result.tried.join('\n')}` : ''
327
+ setMessage({ kind: 'err', text: detail + tried })
328
+ }
329
+ } catch (error) {
330
+ setMessage({ kind: 'err', text: String(error.message || error) })
331
+ } finally {
332
+ setBusy('')
333
+ }
334
+ }, [rows, selected])
335
+
336
+ const checkbox = (row) =>
337
+ h('input', {
338
+ type: 'checkbox',
339
+ checked: selected[row.name] === true,
340
+ disabled: row.state === 'same',
341
+ onChange: (event) => setSelected((current) => ({ ...current, [row.name]: event.target.checked })),
342
+ })
343
+
344
+ const counts = { new: 0, upgrade: 0, same: 0, downgrade: 0, linked: 0 }
345
+ for (const row of rows || []) counts[row.state] = (counts[row.state] || 0) + 1
346
+
347
+ const modal =
348
+ rows === null
349
+ ? null
350
+ : h(
351
+ 'div',
352
+ { className: 'overlay', onClick: (event) => event.target === event.currentTarget && busy !== 'install' && setRows(null) },
353
+ h(
354
+ 'div',
355
+ { className: 'modal' },
356
+ h('h2', null, zh ? '选择要安装的插件' : 'Choose plugins to install'),
357
+ header && (header.dsh || header.generatedAt)
358
+ ? h(
359
+ 'div',
360
+ { className: 'muted' },
361
+ `${L.from}: ${header.profile || '—'} / ${L.generatedAt}: ${header.generatedAt || '—'} / ${L.version}: ${header.dsh || '—'}`,
362
+ )
363
+ : null,
364
+ header && info && header.dsh && info.dsh && header.dsh !== info.dsh
365
+ ? h('div', { className: 'msg err' }, L.mismatch)
366
+ : null,
367
+ rows.length === 0
368
+ ? h('div', { className: 'muted' }, L.noRows)
369
+ : h(
370
+ 'table',
371
+ null,
372
+ h(
373
+ 'thead',
374
+ null,
375
+ h('tr', null, h('th', null, ''), h('th', null, L.name), h('th', null, L.pinned), h('th', null, 'now'), h('th', null, '')),
376
+ ),
377
+ h(
378
+ 'tbody',
379
+ null,
380
+ rows.map((row) =>
381
+ h(
382
+ 'tr',
383
+ { key: row.name },
384
+ h('td', null, checkbox(row)),
385
+ h('td', null, row.name),
386
+ h('td', null, row.version),
387
+ h('td', null, row.installed || '—'),
388
+ h(
389
+ 'td',
390
+ null,
391
+ h('span', { className: 'badge ' + row.state }, L[row.state] || row.state),
392
+ ),
393
+ ),
394
+ ),
395
+ ),
396
+ ),
397
+ h(
398
+ 'div',
399
+ { className: 'muted' },
400
+ [
401
+ counts.new ? `${counts.new} ${L.added}` : '',
402
+ counts.upgrade ? `${counts.upgrade} ${L.upgrade}` : '',
403
+ counts.same ? `${counts.same} ${L.same}` : '',
404
+ counts.downgrade ? `${counts.downgrade} ${L.downgrade}` : '',
405
+ counts.linked ? `${counts.linked} ${L.linked}` : '',
406
+ ]
407
+ .filter(Boolean)
408
+ .join(' · '),
409
+ ),
410
+ counts.same ? h('div', { className: 'muted' }, `${L.alreadyTitle}: ${rows.filter((row) => row.state === 'same').map((row) => row.name).join(', ')}`) : null,
411
+ counts.linked ? h('div', { className: 'msg' }, L.linkedHint) : null,
412
+ counts.downgrade ? h('div', { className: 'msg' }, L.downgradeHint) : null,
413
+ h(
414
+ 'div',
415
+ { className: 'row' },
416
+ h(
417
+ 'button',
418
+ {
419
+ onClick: () => {
420
+ const next = {}
421
+ for (const row of rows) if (row.state === 'new' || row.state === 'upgrade') next[row.name] = true
422
+ setSelected(next)
423
+ },
424
+ },
425
+ L.selectAll,
426
+ ),
427
+ h('span', { className: 'grow' }),
428
+ h('button', { onClick: () => setRows(null), disabled: busy === 'install' }, L.cancel),
429
+ h(
430
+ 'button',
431
+ { className: 'primary', onClick: install, disabled: busy === 'install' },
432
+ busy === 'install' ? L.installing : L.install,
433
+ ),
434
+ ),
435
+ ),
436
+ )
437
+
438
+ const sourceBody = h(
439
+ React.Fragment,
440
+ null,
441
+ h(
442
+ 'div',
443
+ { className: 'card' },
444
+ h('p', { className: 'sub' }, L.sourceHint),
445
+ h(
446
+ 'div',
447
+ { className: 'row' },
448
+ h('button', { className: 'primary', onClick: runScan, disabled: busy !== '' }, busy === 'scan' ? L.scanning : L.scan),
449
+ h('button', { onClick: doExport, disabled: list === null }, L.export),
450
+ h('button', { onClick: doCopy, disabled: list === null }, L.copy),
451
+ ),
452
+ list === null
453
+ ? h('div', { className: 'muted' }, L.empty)
454
+ : h(
455
+ React.Fragment,
456
+ null,
457
+ h('div', { className: 'muted' }, `${L.plugins}: ${list.plugins.length} · ${L.skipped}: ${list.skipped.length} · ${L.profile}: ${list.profile} · ${L.version}: ${list.dsh || '—'}`),
458
+ h(
459
+ 'table',
460
+ null,
461
+ h('thead', null, h('tr', null, h('th', null, L.name), h('th', null, L.pinned), h('th', null, L.kind))),
462
+ h(
463
+ 'tbody',
464
+ null,
465
+ list.plugins.map((row) =>
466
+ h(
467
+ 'tr',
468
+ { key: row.name },
469
+ h('td', null, row.name),
470
+ h('td', null, row.version || '—'),
471
+ h('td', null, row.bundle ? 'bundle' : 'dep'),
472
+ ),
473
+ ),
474
+ list.skipped.map((row) =>
475
+ h(
476
+ 'tr',
477
+ { key: row.name },
478
+ h('td', null, row.name),
479
+ h('td', { className: 'muted' }, row.spec),
480
+ h('td', null, h('span', { className: 'badge' }, L[row.reason] || row.reason)),
481
+ ),
482
+ ),
483
+ ),
484
+ ),
485
+ ),
486
+ ),
487
+ list === null
488
+ ? null
489
+ : h('textarea', {
490
+ value: asJson(),
491
+ readOnly: true,
492
+ spellCheck: false,
493
+ onFocus: (event) => event.target.select(),
494
+ }),
495
+ )
496
+
497
+ const followerBody = h(
498
+ React.Fragment,
499
+ null,
500
+ h(
501
+ 'div',
502
+ { className: 'card' },
503
+ h('p', { className: 'sub' }, L.followerHint),
504
+ h(
505
+ 'div',
506
+ {
507
+ className: 'drop',
508
+ onDragOver: (event) => event.preventDefault(),
509
+ onDrop: (event) => {
510
+ event.preventDefault()
511
+ onFile(event.dataTransfer.files && event.dataTransfer.files[0])
512
+ },
513
+ },
514
+ L.drop,
515
+ ' ',
516
+ h('label', { className: 'file' }, h('input', { type: 'file', accept: '.json,.txt', onChange: (event) => onFile(event.target.files && event.target.files[0]) }), h('u', null, L.choose)),
517
+ ),
518
+ h('div', { className: 'muted' }, L.orPaste),
519
+ h('textarea', { value: text, spellCheck: false, placeholder: '[\n { "name": "dsh-webpage", "version": "0.1.1" }\n]', onChange: (event) => setText(event.target.value) }),
520
+ h(
521
+ 'div',
522
+ { className: 'row' },
523
+ h('button', { className: 'primary', onClick: () => readList(text), disabled: text.trim() === '' || busy !== '' }, busy === 'parse' ? '…' : L.parse),
524
+ ),
525
+ ),
526
+ )
527
+
528
+ // Windows has no application menu at all (the shell registers only hidden
529
+ // devtools accelerators there), so the documented restart route differs by
530
+ // platform instead of pretending one label exists everywhere.
531
+ const restartHint =
532
+ info && info.platform === 'darwin'
533
+ ? L.restartHintMac
534
+ : info && info.desktop === false
535
+ ? L.restartHintWeb
536
+ : L.restartHintWindows
537
+
538
+ return h(
539
+ 'div',
540
+ { className: 'dms' },
541
+ h('style', null, CSS),
542
+ h('h2', null, L.title),
543
+ h('p', { className: 'sub' }, L.subtitle),
544
+ h(
545
+ 'div',
546
+ { className: 'card' },
547
+ h(
548
+ 'div',
549
+ { className: 'row' },
550
+ h('span', { className: 'muted' }, L.role),
551
+ h('button', { className: role === 'source' ? 'active' : '', onClick: () => changeRole('source'), disabled: busy === 'role' }, L.source),
552
+ h('button', { className: role === 'follower' ? 'active' : '', onClick: () => changeRole('follower'), disabled: busy === 'role' }, L.follower),
553
+ h('span', { className: 'grow' }),
554
+ h('span', { className: 'muted' }, info ? `${info.profile} · ${info.dsh || ''}` : ''),
555
+ ),
556
+ h('div', { className: 'muted' }, restartHint),
557
+ ),
558
+ role === 'source' ? sourceBody : followerBody,
559
+ message === null ? null : h('div', { className: 'msg ' + (message.kind === 'ok' ? 'ok' : 'err') }, message.text),
560
+ result && result.stdout ? h('div', { className: 'msg' }, result.stdout) : null,
561
+ modal,
562
+ )
563
+ }
564
+
565
+ function apply(ctx) {
566
+ ctx.slots.inject('settings.section', () =>
567
+ ctx.slots.register(
568
+ { name: 'settings.section', id: 'dsh-multi-sync', order: 70, label: zh ? '多端同步' : 'Multi-sync' },
569
+ Panel,
570
+ ),
571
+ )
572
+ }
573
+
574
+ return { inject: ['slots'], apply }
575
+ },
576
+ })
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: '@xi-ix/dsh-multi-sync'
3
+ name: '@xi-ix/dsh-multi-sync'