MCPcopy Create free account
hub / github.com/anomalyco/opencode / nativeItem

Function nativeItem

packages/desktop/src/main/menu.ts:35–63  ·  view source on GitHub ↗
(entry: DesktopMenuEntry, deps: Deps)

Source from the content-addressed store, hash-verified

33}
34
35function nativeItem(entry: DesktopMenuEntry, deps: Deps): MenuItemConstructorOptions {
36 if (entry.type === "separator") return { type: "separator" }
37 if (entry.role) return { role: nativeRole(entry.role) }
38
39 const item: MenuItemConstructorOptions = {
40 label: entry.label,
41 accelerator: entry.accelerator?.macos,
42 enabled: entry.enabled === "updater" ? UPDATER_ENABLED : undefined,
43 }
44
45 if (entry.command) {
46 const command = entry.command
47 item.click = () => deps.trigger(command)
48 }
49 if (entry.action) {
50 const action = entry.action
51 item.click = () =>
52 runDesktopMenuAction(BrowserWindow.getFocusedWindow(), action, {
53 checkForUpdates: deps.checkForUpdates,
54 relaunch: deps.relaunch,
55 })
56 }
57 if (entry.href) {
58 const href = entry.href
59 item.click = () => shell.openExternal(href)
60 }
61
62 return item
63}
64
65function nativeRole(role: DesktopMenuRole) {
66 return role as NonNullable<MenuItemConstructorOptions["role"]>

Callers 1

createMenuFunction · 0.85

Calls 2

runDesktopMenuActionFunction · 0.90
nativeRoleFunction · 0.85

Tested by

no test coverage detected