MCPcopy Index your code
hub / github.com/npmx-dev/npmx.dev / useCommandPaletteCommands

Function useCommandPaletteCommands

app/composables/useCommandPaletteCommands.ts:23–222  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21]
22
23export function useCommandPaletteCommands() {
24 const { t } = useI18n()
25 const {
26 close,
27 packageContext,
28 query,
29 view,
30 contextCommands,
31 queryOverrides,
32 resolveContextCommandAction,
33 resolveQueryOverride,
34 } = useCommandPalette()
35
36 function closeThen(run: () => void | Promise<void>) {
37 return async () => {
38 close()
39 await run()
40 }
41 }
42
43 function groupLabel(group: CommandPaletteGroup): string {
44 const packageName = packageContext.value?.packageName
45
46 switch (group) {
47 case 'actions':
48 return t('command_palette.groups.actions')
49 case 'help':
50 return t('command_palette.groups.help')
51 case 'language':
52 return t('command_palette.groups.language')
53 case 'package':
54 return packageName
55 ? t('command_palette.groups.package_with_name', { name: packageName })
56 : t('command_palette.groups.package')
57 case 'navigation':
58 return t('command_palette.groups.navigation')
59 case 'connections':
60 return t('command_palette.groups.connections')
61 case 'links':
62 return t('command_palette.groups.links')
63 case 'settings':
64 return t('nav.settings')
65 case 'npmx':
66 return t('command_palette.groups.npmx')
67 case 'versions':
68 return packageName
69 ? t('command_palette.groups.versions_with_name', { name: packageName })
70 : t('command_palette.groups.versions')
71 }
72 }
73
74 async function submitSearchQuery() {
75 const trimmedQuery = query.value.trim()
76 if (!trimmedQuery) return
77
78 close()
79 await navigateTo({
80 name: 'search',

Callers 1

setupFunction · 0.85

Calls 6

useCommandPaletteFunction · 0.85
groupLabelFunction · 0.85
resolveQueryOverrideFunction · 0.85
closeThenFunction · 0.70

Tested by 1

setupFunction · 0.68