dsh-command-palette 0.1.2 → 0.1.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/client.js +12 -5
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -11,6 +11,13 @@ window.__ModuleLoader__.load({
11
11
  const GROUP_LABELS = { features: '功能', settings: '设置', browser: '浏览器', workspaces: '工作区', sessions: '会话', recent: '最近会话' }
12
12
  const SUPPORTED_GROUPS = new Set(GROUP_ORDER)
13
13
 
14
+ function useStore(store) {
15
+ return React.useSyncExternalStore(
16
+ React.useCallback((listener) => store.subscribe(listener), [store]),
17
+ React.useCallback(() => store.getSnapshot(), [store])
18
+ )
19
+ }
20
+
14
21
  function normalizeCustomCommand(value) {
15
22
  if (!value || typeof value !== 'object') return null
16
23
  const name = typeof value.name === 'string' ? value.name.trim() : ''
@@ -248,9 +255,9 @@ window.__ModuleLoader__.load({
248
255
  }
249
256
 
250
257
  function Palette({ useSessions, useWorkspaces, useCommandSettings, saveCustomCommands, openSession, startSession, runCustomCommand, paletteService }) {
251
- const sessions = useSessions((value) => value)
252
- const workspaces = useWorkspaces((value) => value)
253
- const commandSettings = useCommandSettings((value) => value)
258
+ const sessions = useStore(useSessions)
259
+ const workspaces = useStore(useWorkspaces)
260
+ const commandSettings = useStore(useCommandSettings)
254
261
  const customCommands = normalizeCustomCommands(commandSettings.value?.commands)
255
262
  const [open, setOpen] = React.useState(paletteService.isOpen())
256
263
  const [query, setQuery] = React.useState('')
@@ -368,9 +375,9 @@ window.__ModuleLoader__.load({
368
375
  }
369
376
 
370
377
  function ShortcutSettings({ useWorkspaces, useCommandSettings, saveCustomCommands }) {
371
- const commandSettings = useCommandSettings((value) => value)
378
+ const commandSettings = useStore(useCommandSettings)
372
379
  const commands = normalizeCustomCommands(commandSettings.value?.commands)
373
- const workspaceState = typeof useWorkspaces === 'function' ? useWorkspaces((value) => value) : { items: [] }
380
+ const workspaceState = useStore(useWorkspaces)
374
381
  const workspaces = workspaceState?.items || []
375
382
  const emptyDraft = { name: '', prompt: '', sticky: true, workspaceId: '' }
376
383
  const [draft, setDraft] = React.useState(emptyDraft)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-command-palette",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "A keyboard-first command palette for DeepSeek Harness sessions, workspaces, settings, features, and reusable custom commands.",
5
5
  "license": "MIT",
6
6
  "author": "chenyangcun",