dsh-go-plugin-sync 0.4.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1 — 2026-12-04
4
+
5
+ ### 改进
6
+ - 导入同步码 / 清单文件 / 拉取中转或 SSH 后,只自动选中“双端兼容(kind=both)且本机还没装”的插件,其余保持不选
7
+ - 每个插件的兼容与状态提示缩短,例如「1.2.3 · 可安装」「1.2.3 · npm 安装」
8
+ - 冲突项以本机为准:不再提示更新,更新交给 DSH 本体处理;电脑端与 dsh-go 面板文案同步
9
+
3
10
  ## 0.4.0 — 2026-12-04
4
11
 
5
12
  0.3.10 之后的功能合并发布(npm 从 0.3.6 直接到本版)。
package/lib/client.js CHANGED
@@ -111,11 +111,11 @@ window.__ModuleLoader__.load({
111
111
  }, [])
112
112
 
113
113
  const kindLabel = (kind) => kind === 'native'
114
- ? T('手机原生', 'Phone native')
114
+ ? T('手机端', 'Phone')
115
115
  : kind === 'both'
116
- ? T('两端可用', 'Both')
116
+ ? T('双端', 'Both')
117
117
  : kind === 'bundle'
118
- ? T('电脑/网页', 'Desktop/web')
118
+ ? T('电脑端', 'Desktop')
119
119
  : ''
120
120
  const toggle = (name, checked) => setPicked((previous) => ({ ...previous, [name]: checked }))
121
121
  const installedRows = rows.filter((row) => row.status === 'same')
@@ -261,7 +261,7 @@ window.__ModuleLoader__.load({
261
261
 
262
262
  return h('div', { style: { display: 'flex', flexDirection: 'column', gap: '14px', maxWidth: '760px' } },
263
263
  h('div', { style: { fontSize: '13px', opacity: 0.7 } },
264
- T('从同步码安装缺少的插件;只增不删,冲突只提示。', 'Install missing plugins from a sync code. Add-only: conflicts are warnings.')),
264
+ T('从同步码安装缺少的插件;已有版本不动,冲突以本机为准,更新交给 DSH 本体。', 'Install missing plugins from a sync code; conflicts keep the local copy and updates are left to DSH.')),
265
265
 
266
266
  h('div', { style: { display: 'flex', flexDirection: 'column', gap: '8px' } },
267
267
  h('div', { style: { fontWeight: 600 } }, T('同步码', 'Sync code')),
package/lib/index.js CHANGED
@@ -267,7 +267,7 @@ function codeFromSubmit(value) {
267
267
  return ''
268
268
  }
269
269
 
270
- /** Decode a sync code, materialize files, and preselect every row (all by default). */
270
+ /** Decode a sync code, materialize files, and preselect double-end plugins missing here. */
271
271
  function applySyncCode(scope, text, sourceName, host = {}) {
272
272
  const decoded = decodeSyncCode(text)
273
273
  if (decoded.error) return { error: decoded.error }
@@ -281,16 +281,7 @@ function applySyncCode(scope, text, sourceName, host = {}) {
281
281
  resetUiState()
282
282
  writeCodeFiles(decoded)
283
283
  const rows = diffRows(localPlugins(), state.manifest, state.manifestSource, host)
284
- const manifestNames = new Set(decoded.manifest.plugins.map((plugin) => plugin.name))
285
- state.selected.clear()
286
- let selected = 0
287
- for (const row of rows) {
288
- if (!manifestNames.has(row.name)) continue
289
- if (!row.action) continue
290
- if (host.dshGo === true && row.kind === 'bundle') continue
291
- state.selected.add(row.name)
292
- selected++
293
- }
284
+ const selected = preselectRows(state, host)
294
285
  return {
295
286
  count: decoded.manifest.plugins.length,
296
287
  selected,
@@ -620,6 +611,21 @@ function diffRows(local, manifest, source, host = {}) {
620
611
  return rows
621
612
  }
622
613
 
614
+ /** Auto-select only double-end plugins (kind=both) that this host does not have yet. */
615
+ function preselectRows(state, host = {}) {
616
+ const rows = diffRows(localPlugins(), state.manifest, state.manifestSource, host)
617
+ const names = new Set((state.manifest?.plugins ?? []).map((plugin) => plugin.name))
618
+ state.selected.clear()
619
+ for (const row of rows) {
620
+ if (!names.has(row.name)) continue
621
+ if (row.kind !== 'both') continue
622
+ if (row.status !== 'installable') continue
623
+ if (!row.action) continue
624
+ state.selected.add(row.name)
625
+ }
626
+ return state.selected.size
627
+ }
628
+
623
629
  // ---------------------------------------------------------------- state
624
630
 
625
631
  function stateKey(scope) {
@@ -675,7 +681,7 @@ function loadManifestFrom(path, kind, pluginsDir) {
675
681
  }
676
682
 
677
683
  /** Refresh the state manifest from relay / ssh results when those files are newer. */
678
- function refreshManifests(state, cfg) {
684
+ function refreshManifests(state, cfg, host = {}) {
679
685
  const relay = loadManifestFrom(relayManifestFile(), 'relay', join(relayWorkDir(), cfg.relay.dir, 'plugins'))
680
686
  if (relay?.manifest && relay.manifest.plugins.length > 0 && relay.mtime > state.relayLoadedAt) {
681
687
  state.manifest = relay.manifest
@@ -684,7 +690,7 @@ function refreshManifests(state, cfg) {
684
690
  state.sourceName = 'Git 中转'
685
691
  state.showAll = false
686
692
  state.relayLoadedAt = relay.mtime
687
- state.selected.clear()
693
+ preselectRows(state, host)
688
694
  }
689
695
  const ssh = loadManifestFrom(sshManifestFile(), 'ssh', null)
690
696
  if (ssh?.manifest && ssh.manifest.plugins.length > 0 && ssh.mtime > state.sshLoadedAt) {
@@ -694,7 +700,7 @@ function refreshManifests(state, cfg) {
694
700
  state.sourceName = 'SSH 远端'
695
701
  state.showAll = false
696
702
  state.sshLoadedAt = ssh.mtime
697
- state.selected.clear()
703
+ preselectRows(state, host)
698
704
  }
699
705
  }
700
706
 
@@ -1330,20 +1336,20 @@ function enableText(caps) {
1330
1336
  function statusLine(row, en) {
1331
1337
  let text = {
1332
1338
  same: en ? 'same' : '一致',
1333
- conflict: en ? 'conflict: local vs manifest differ' : '冲突:本机与清单不同',
1334
- install: en ? 'not installed yet' : '本机未安装',
1335
- installable: en ? 'can install from this manifest' : '可从这份清单安装',
1336
- missing: en ? 'files not on this host' : '本机缺少文件,需手动拷贝',
1337
- extra: en ? 'not in manifest' : '清单里没有',
1338
- push: en ? 'remote lacks it; can push' : '远端没有,可推送',
1339
- 'native-only': en ? 'phone-only native plugin; not supported here' : '手机端原生插件,电脑端不支持',
1340
- 'web-only': en ? 'desktop/web plugin; no native UI on the phone' : '电脑/网页端插件,手机无原生界面',
1339
+ conflict: en ? 'local wins' : '本机优先',
1340
+ install: en ? 'not installed' : '未安装',
1341
+ installable: en ? 'ready' : '可安装',
1342
+ missing: en ? 'no files' : '缺文件',
1343
+ extra: en ? 'not listed' : '清单外',
1344
+ push: en ? 'pushable' : '可推送',
1345
+ 'native-only': en ? 'phone-only' : '手机专用',
1346
+ 'web-only': en ? 'web-only' : '电脑/网页专用',
1341
1347
  }[row.status] || row.status
1342
1348
  if (row.status !== 'web-only' && row.status !== 'native-only') {
1343
- if (row.action === 'install' && row.registrySpec) text = en ? 'install from npm' : '可从 npm 安装'
1344
- else if (row.action === 'install' && row.localDir) text = en ? 'install from files' : '可从文件安装'
1345
- else if (row.action === 'pull') text = en ? 'pull from remote' : '可从远端拉取'
1346
- else if (row.action === 'push-npm') text = en ? 'remote installs it from npm' : '远端从 npm 安装'
1349
+ if (row.action === 'install' && row.registrySpec) text = en ? 'via npm' : 'npm 安装'
1350
+ else if (row.action === 'install' && row.localDir) text = en ? 'via files' : '文件安装'
1351
+ else if (row.action === 'pull') text = en ? 'from remote' : '远端拉取'
1352
+ else if (row.action === 'push-npm') text = en ? 'remote via npm' : '远端 npm'
1347
1353
  }
1348
1354
  const version = row.status === 'conflict' && row.remoteVersion && row.remoteVersion !== row.version
1349
1355
  ? `${row.version} → ${row.remoteVersion}`
@@ -1374,7 +1380,7 @@ function buildView(scope, caps, ctx) {
1374
1380
  const en = enableText(caps)
1375
1381
  const cfg = loadConfig(ctx, scope)
1376
1382
  const state = stateFor(scope)
1377
- refreshManifests(state, cfg)
1383
+ refreshManifests(state, cfg, { dshGo: true })
1378
1384
  const local = localPluginsCached()
1379
1385
  const rows = diffRows(local, state.manifest, state.manifestSource, { dshGo: true })
1380
1386
  const components = Array.isArray(caps?.components) ? caps.components : []
@@ -1382,8 +1388,8 @@ function buildView(scope, caps, ctx) {
1382
1388
  const children = []
1383
1389
 
1384
1390
  children.push({ type: 'text', text: en
1385
- ? 'Copy a sync code (all or selected), or paste one below. Sync only installs missing plugins; it never touches what you already have.'
1386
- : '复制同步码(全部或选中),或在下面粘贴导入。同步只安装缺少的插件,不会动已有的。' })
1391
+ ? 'Copy a sync code (all or selected), or paste one below. Sync only installs missing plugins; conflicts keep the local copy, updates are left to DSH.'
1392
+ : '复制同步码(全部或选中),或在下面粘贴导入。同步只安装缺少的插件,已有版本不动;冲突以本机为准,更新交给 DSH 本体。' })
1387
1393
 
1388
1394
  if (canForm) {
1389
1395
  children.push({ type: 'form', submit: 'import-code', submitLabel: en ? 'Import code' : '导入同步码', children: [
@@ -1660,7 +1666,7 @@ function webSnapshot(ctx) {
1660
1666
  const scope = { sessionId: 'web-ui' }
1661
1667
  const state = stateFor(scope)
1662
1668
  const cfg = loadConfig(ctx, scope)
1663
- refreshManifests(state, cfg)
1669
+ refreshManifests(state, cfg, { dshGo: Boolean(ctx.get?.('dshGo')) })
1664
1670
  const local = localPlugins()
1665
1671
  const cleared = uiCleared()
1666
1672
  const rows = cleared
@@ -1995,6 +2001,7 @@ export function apply(ctx) {
1995
2001
  state.selected.clear()
1996
2002
  persistImported(state)
1997
2003
  resetUiState()
2004
+ preselectRows(state, { dshGo: true })
1998
2005
  return [{ toast: `已导入 ${manifest.plugins.length} 个插件` }, { refresh: true }]
1999
2006
  }
2000
2007
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-go-plugin-sync",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "dsh": {