dsh-opencode-palette 1.6.2 → 1.6.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.
package/lib/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * dsh-opencode-palette v1.6.2 — 浏览器半(构建产物,勿手改)
2
+ * dsh-opencode-palette v1.6.4 — 浏览器半(构建产物,勿手改)
3
3
  * 数据驱动管线:opencode v1.18.12 官方主题 JSON → 颜色解析 → DSH 适配注入
4
4
  * 源:src/engine/* + runtime/client.mjs(npm run build 重新生成)
5
5
  */
@@ -216,6 +216,11 @@ const DERIVED_TOKENS = [
216
216
  ['--dsw-alias-scrollbar-bg-l2', (c) => withAlpha(c.text, 0.08)],
217
217
  ['--dsw-alias-scrollbar-hover-l1', (c) => c.borderActive],
218
218
  ['--dsw-alias-scrollbar-hover-l2', (c) => c.borderActive],
219
+ // 侧边栏/设置面板导航项悬停与选中:DSH 默认随明暗模式取浅/深两套值,
220
+ // 调色板未覆盖时在浅色系统(无 data-ds-dark-theme)下会白字撞浅底
221
+ ['--dsw-specific-sidebar-nav-item-hover', (c) => withAlpha(c.text, 0.08)],
222
+ ['--dsw-specific-sidebar-nav-item-active', (c) => withAlpha(c.text, 0.14)],
223
+ ['--dsw-specific-sidebar-nav-item-active-accent', (c) => withAlpha(c.primary, 0.35)],
219
224
  ]
220
225
 
221
226
  // ── 3. shiki 语法高亮变量(DSH 只认 10 个,opencode 9 色位做角色合并)──
@@ -8022,7 +8027,7 @@ function saveState(state) {
8022
8027
  if (globalThis.localStorage) localStorage.setItem(STORAGE_KEY, JSON.stringify(state))
8023
8028
  } catch (e) { /* 忽略持久化失败 */ }
8024
8029
  }
8025
- // ── i18n:面板文案双语表(跟随 DSH 界面语言,html[lang] 为信号源)──
8030
+ // ── i18n:面板文案双语表(跟随 DSH 界面语言,官方 locale 服务为信号源)──
8026
8031
  const I18N = {
8027
8032
  panelName: { zh: 'opencode调色板', en: 'Opencode Palette' },
8028
8033
  subtitle: { zh: '34 款 opencode 官方配色主题,点击即切换', en: '34 official opencode themes — click to switch' },
@@ -8053,7 +8058,7 @@ const I18N = {
8053
8058
  'group.special': { zh: '特殊', en: 'Special' },
8054
8059
  }
8055
8060
 
8056
- // 语言检测:html[lang] 优先,回退浏览器语言
8061
+ // 语言检测(回退):html[lang] 优先,回退浏览器语言
8057
8062
  function getLang() {
8058
8063
  try {
8059
8064
  const l = (document.documentElement && document.documentElement.lang) || (navigator.language || 'en')
@@ -8061,6 +8066,18 @@ function getLang() {
8061
8066
  } catch (e) { return 'en' }
8062
8067
  }
8063
8068
 
8069
+ // 把 key → {zh,en} 表转成 locale 服务注册形态 {zh: {...}, en: {...}}
8070
+ function toLocaleDicts(i18n) {
8071
+ const zh = {}
8072
+ const en = {}
8073
+ for (const key in i18n) {
8074
+ const pair = i18n[key]
8075
+ zh[key] = pair.zh
8076
+ en[key] = pair.en
8077
+ }
8078
+ return { zh, en }
8079
+ }
8080
+
8064
8081
 
8065
8082
  // 生成注入物并注入:token 层 + <style> 层;幂等(先清后注入)
8066
8083
  function createClient(slotTarget) {
@@ -8072,21 +8089,36 @@ function createClient(slotTarget) {
8072
8089
  let tokenDispose = null
8073
8090
  let styleTag = null
8074
8091
 
8075
- // ── i18n 运行时:语言跟随 DSH(html[lang] 变化即通知面板重渲染)──
8076
- let currentLang = getLang()
8092
+ // ── i18n 运行时:语言跟随 DSH(官方 locale 服务为信号源,html[lang] 仅作回退)──
8093
+ const localeSvc = ctx.get('locale') || ctx.locale || null
8094
+ const LOCALE_NS = 'opencode-palette'
8095
+ let dictDispose = null
8096
+ let localeUnsub = null
8097
+ let currentLang = localeSvc ? localeSvc.getLocale().active : getLang()
8077
8098
  const localeListeners = []
8078
- function tr(key) { const e = I18N[key]; return e ? e[currentLang] : key }
8099
+ function currentLocale() { return localeSvc ? localeSvc.getLocale().active : getLang() }
8100
+ function tr(key) {
8101
+ const entry = I18N[key]
8102
+ return entry ? (entry[currentLang] !== undefined ? entry[currentLang] : key) : key
8103
+ }
8079
8104
  function notifyLocale() {
8080
- const next = getLang()
8105
+ const next = currentLocale()
8081
8106
  if (next === currentLang) return
8082
8107
  currentLang = next
8083
8108
  for (const fn of localeListeners) { try { fn() } catch (e) { /* 忽略 */ } }
8084
8109
  }
8110
+ // 监听语言变化:官方 locale 服务优先;无该服务的环境(如旧版 DSH/测试沙箱)回退监听 html[lang]
8085
8111
  let localeObserver = null
8086
- if (typeof MutationObserver !== 'undefined' && typeof document !== 'undefined' && document.documentElement) {
8112
+ if (localeSvc && typeof localeSvc.subscribe === 'function') {
8113
+ localeUnsub = localeSvc.subscribe(notifyLocale)
8114
+ } else if (typeof MutationObserver !== 'undefined' && typeof document !== 'undefined' && document.documentElement) {
8087
8115
  localeObserver = new MutationObserver(notifyLocale)
8088
8116
  localeObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['lang'] })
8089
8117
  }
8118
+ // 把面板双语表注册进 locale 服务:标题/文案随 DSH 语言实时切换(disposer 交给清理器)
8119
+ if (localeSvc && typeof localeSvc.register === 'function') {
8120
+ try { dictDispose = localeSvc.register(LOCALE_NS, toLocaleDicts(I18N)) } catch (e) { /* 忽略 */ }
8121
+ }
8090
8122
 
8091
8123
  function safeThemeName(name) {
8092
8124
  const names = themeNames()
@@ -8430,6 +8462,8 @@ function createClient(slotTarget) {
8430
8462
  try { if (disposePanel) disposePanel() } catch (e) { /* 忽略 */ }
8431
8463
  try { if (disposeSection) disposeSection() } catch (e) { /* 忽略 */ }
8432
8464
  try { if (globalThis.__opencodePalette) delete globalThis.__opencodePalette } catch (e) { /* 忽略 */ }
8465
+ try { if (dictDispose) dictDispose() } catch (e) { /* 忽略 */ }
8466
+ try { if (localeUnsub) localeUnsub() } catch (e) { /* 忽略 */ }
8433
8467
  try { if (localeObserver) localeObserver.disconnect() } catch (e) { /* 忽略 */ }
8434
8468
  }
8435
8469
  }, 'dsh-opencode-palette: styles')
@@ -8438,7 +8472,7 @@ function createClient(slotTarget) {
8438
8472
 
8439
8473
  __mods["client"] = { createClient }
8440
8474
  })();
8441
- exports.inject = ["theme","slots"]
8475
+ exports.inject = ["theme","slots","locale"]
8442
8476
  exports.apply = __mods["client"].createClient("settings.plugins.tab")
8443
8477
  return module.exports
8444
8478
  },
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * dsh-opencode-palette v1.6.2 — 宿主半(no-op)
2
+ * dsh-opencode-palette v1.6.4 — 宿主半(no-op)
3
3
  *
4
4
  * 主题的全部工作在浏览器端(./client.js)完成:
5
5
  * - 34 个 opencode 主题(33 内置 JSON + system)经数据驱动管线解析
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-opencode-palette",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "让 DeepSeek Harness 穿上 34 款经典皮肤——东京的霓虹夜色、德古拉的暗红月光、复古工坊的暖黄灯火、黑客帝国的数字雨、玫瑰松林间的风……一键换肤,即点即换,重启不丢。34 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",