dsh-opencode-palette 2.0.3 → 2.0.4

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.
Files changed (2) hide show
  1. package/lib/client.js +54 -14
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * dsh-opencode-palette v2.0.3 — 浏览器半(构建产物,勿手改)
2
+ * dsh-opencode-palette v2.0.4 — 浏览器半(构建产物,勿手改)
3
3
  * 数据驱动管线:opencode v1.18.12 官方主题 JSON → 颜色解析 → DSH 适配注入
4
4
  * 面板「检查更新」:dsh-plugin-update 客户端入口经构建期内联(vendor)
5
5
  * 源:src/engine/* + runtime/*.mjs + npm 包 dsh-log / dsh-plugin-update 的客户端入口
@@ -9707,10 +9707,11 @@ __mods["channel"] = { CHANNEL, ENDPOINT, ROUTE_PATH, PLUGIN_ID, PHONE_PREFIX, TA
9707
9707
  /**
9708
9708
  * runtime/update-panel.mjs — 面板「检查更新」的状态机(纯逻辑:不碰 React、不碰 DOM、不碰全局宿主)
9709
9709
  *
9710
- * 三条口径(沿用更新包 README 与规格):
9710
+ * 三条口径(沿用更新包 README 与规格,#41 起进面板自动查一次):
9711
9711
  * 1. 「待重启」只认宿主当场算出的原因码 pending-restart,不自己比较版本号;
9712
- * 2. 打开面板只静默读一次本地状态(只读、不联网);联网只在用户亲手点「检查更新」时发生一次;
9713
- * 3. 有新版才开弹窗;无新版只回一句「已是最新」,不弹窗、不打扰。
9712
+ * 2. 打开面板自动联网检查一次(静默:只变按钮,不自动弹窗);失败/无新版静默保持原样;
9713
+ * 用户亲手点「检查更新」/红色「有新版本」时才允许弹窗;
9714
+ * 3. 有新版只变按钮(红字“有新版本”),点按钮才开弹窗;无新版只回一句「已是最新」,不弹窗、不打扰。
9714
9715
  *
9715
9716
  * 电话名与轮询间隔由调用方从更新包的客户端入口派生后传进来(本文件不写字面量)。
9716
9717
  */
@@ -9736,12 +9737,13 @@ function readSnapshot(res) {
9736
9737
  }
9737
9738
  }
9738
9739
 
9739
- /** 按钮状态:UI 据此选词条,不在渲染里堆条件。 */
9740
+ /** 按钮状态:UI 据此选词条,不在渲染里堆条件。
9741
+ * 优先级(#41 用户拍板):正在升级 > 待重启 > 有新版本 > 检查中 > 空闲。 */
9740
9742
  function buttonState(state) {
9741
9743
  if (state.installing) return 'installing'
9742
- if (state.checking) return 'checking'
9743
9744
  if (state.pending) return 'pending'
9744
9745
  if (state.hasNew) return 'hasNew'
9746
+ if (state.checking) return 'checking'
9745
9747
  return 'idle'
9746
9748
  }
9747
9749
 
@@ -9907,6 +9909,39 @@ function createUpdateController(deps) {
9907
9909
  }
9908
9910
  }
9909
9911
 
9912
+ /** 进面板时的静默检查(联网一次,但只变按钮、不自动弹窗)。
9913
+ * 回 'new' | 'latest' | 'failed' | 'busy'。失败静默:不弹窗、不置 failure 文案。 */
9914
+ async function checkSilently() {
9915
+ if (!state.available) return 'failed'
9916
+ if (state.checking || state.installing) return 'busy'
9917
+ // 磁盘已有新版(待重启)无需再联网;已有新版凭证也无需重复联网
9918
+ if (state.pending) return 'latest'
9919
+ if (state.hasNew && state.checkId) return 'new'
9920
+ patch({ checking: true, failure: null })
9921
+ try {
9922
+ const res = await invoke(phones.updateCheck, {})
9923
+ patch({ checking: false })
9924
+ if (!res || res.ok !== true) return 'failed'
9925
+ const facts = absorb(res)
9926
+ if (facts.canInstall) return 'new'
9927
+ return 'latest'
9928
+ } catch (e) {
9929
+ patch({ checking: false })
9930
+ transportFail(phones.updateCheck, 'throw', e)
9931
+ return 'failed'
9932
+ }
9933
+ }
9934
+
9935
+ /** 打开面板时调用:先本地读一次,再静默联网查一次(#41)。
9936
+ * 待重启/安装中/检查中时跳过联网,避免打扰。 */
9937
+ async function autoCheckOnOpen() {
9938
+ await readStatus()
9939
+ if (!state.available) return null
9940
+ if (state.pending || state.installing || state.checking) return null
9941
+ if (state.hasNew && state.checkId) return 'new'
9942
+ return checkSilently()
9943
+ }
9944
+
9910
9945
  /** 弹窗里的「立即升级」。 */
9911
9946
  async function install() {
9912
9947
  if (!state.available || state.installing) return false
@@ -9944,6 +9979,8 @@ function createUpdateController(deps) {
9944
9979
  },
9945
9980
  readStatus: readStatus,
9946
9981
  check: check,
9982
+ checkSilently: checkSilently,
9983
+ autoCheckOnOpen: autoCheckOnOpen,
9947
9984
  install: install,
9948
9985
  openDialog: function () { patch({ dialogOpen: true }) },
9949
9986
  closeDialog: function () { patch({ dialogOpen: false, failure: null }) },
@@ -9986,7 +10023,7 @@ const STORAGE_KEY = 'dsh.opencode-palette.v2'
9986
10023
  const LEGACY_STORAGE_KEY = 'dsh.opencode-tui-theme.v2'
9987
10024
  const DEFAULT_STATE = { enabled: true, theme: 'opencode', mode: 'mono', size: 13, fontKey: 'JetBrains Mono' }
9988
10025
  // 构建时由 scripts/build-client.mjs 替换为 package.json 版本(面板底部署小字)
9989
- const PALETTE_VERSION = '2.0.3'
10026
+ const PALETTE_VERSION = '2.0.4'
9990
10027
 
9991
10028
  function getReact() {
9992
10029
  if (typeof require === 'function') { try { return require('react') } catch (e) { /* 动态版无 require */ } }
@@ -10098,6 +10135,7 @@ const I18N = {
10098
10135
  'authorPlugin.imCompanion': { zh: 'dsh-im 的增强插件,在原插件基础上提供了超过你想象力的能力', en: "Supercharges dsh-im with more than you'd expect" },
10099
10136
  // ── 检查更新(面板头行按钮 + 升级弹窗 + 待重启横幅)──
10100
10137
  updateCheck: { zh: '检查更新', en: 'Check for updates' },
10138
+ updateHasNew: { zh: '有新版本', en: 'New version' },
10101
10139
  updateChecking: { zh: '检查中…', en: 'Checking…' },
10102
10140
  updateInstalling: { zh: '正在升级…', en: 'Updating…' },
10103
10141
  updateToVersion: { zh: '更新至 v{v}', en: 'Update to v{v}' },
@@ -10686,8 +10724,10 @@ function createClient(slotTarget) {
10686
10724
  if (!props.update) return undefined
10687
10725
  setUpd(props.update.getState())
10688
10726
  const unsub = props.update.subscribe(function () { setUpd(props.update.getState()) })
10689
- // 打开面板静默读一次本地状态:只读、不联网(联网只在用户点按钮时发生)
10690
- props.update.readStatus()
10727
+ // 打开面板自动联网检查一次(静默:只变按钮,不自动弹窗;失败静默保持原样)
10728
+ // 待重启/安装中时控制器内部会跳过联网
10729
+ if (typeof props.update.autoCheckOnOpen === 'function') props.update.autoCheckOnOpen()
10730
+ else props.update.readStatus()
10691
10731
  return unsub
10692
10732
  }, [])
10693
10733
  const updState = upd
@@ -10700,9 +10740,9 @@ function createClient(slotTarget) {
10700
10740
  const updLabel = function (s) {
10701
10741
  const which = buttonState(s)
10702
10742
  if (which === 'installing') return tr('updateInstalling')
10703
- if (which === 'checking') return tr('updateChecking')
10704
10743
  if (which === 'pending') return tr('updateRestart')
10705
- if (which === 'hasNew') return trf('updateToVersion', { v: s.latest })
10744
+ if (which === 'hasNew') return tr('updateHasNew')
10745
+ if (which === 'checking') return tr('updateChecking')
10706
10746
  return tr('updateCheck')
10707
10747
  }
10708
10748
  const copyManual = function () {
@@ -10718,10 +10758,10 @@ function createClient(slotTarget) {
10718
10758
  disabled: !!(updState.checking || updState.installing),
10719
10759
  title: tr('updateCheck'),
10720
10760
  style: {
10721
- border: '1px solid ' + (updState.hasNew ? 'var(--dsw-alias-brand-primary)' : 'var(--dsw-alias-border-l1)'),
10761
+ border: '1px solid ' + (updState.hasNew ? 'var(--dsw-alias-state-error-primary)' : 'var(--dsw-alias-border-l1)'),
10722
10762
  borderRadius: 6, padding: '3px 9px', fontSize: 11, cursor: 'pointer',
10723
- background: updState.hasNew ? segOnBg : 'transparent',
10724
- color: updState.hasNew ? 'var(--dsw-alias-brand-primary)' : muted,
10763
+ background: 'transparent',
10764
+ color: updState.hasNew ? 'var(--dsw-alias-state-error-primary)' : muted,
10725
10765
  fontFamily: 'var(--dsw-font-family)', whiteSpace: 'nowrap',
10726
10766
  },
10727
10767
  }, updLabel(updState))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-opencode-palette",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "让 DeepSeek Harness 穿上 38 款经典皮肤——东京的霓虹夜色、德古拉的暗红月光、复古工坊的暖黄灯火、黑客帝国的数字雨、玫瑰松林间的风……一键换肤,即点即换,重启不丢。38 legendary skins for DeepSeek Harness — tokyonight's neon dusk, dracula's crimson moon, gruvbox's retro glow, the matrix's digital rain, rose-pine's rosewood calm… one click, instant, persisted.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",