UNPKG

@laserware/hoverboard

Version:

Better context menus for Electron.

1 lines 50.8 kB
{"version":3,"sources":["../src/renderer/ContextMenuItem.ts","../src/renderer/NormalMenuItem.ts","../src/renderer/CheckboxMenuItem.ts","../src/renderer/RadioMenuItem.ts","../src/renderer/RoleMenuItem.ts","../src/renderer/SeparatorMenuItem.ts","../src/renderer/ShareMenuItem.ts","../src/renderer/MenuBuilder.ts","../src/renderer/SubmenuMenuItem.ts","../src/sandbox/globals.ts","../src/renderer/ContextMenuEvent.ts","../src/renderer/ContextMenu.ts","../src/renderer/index.ts"],"names":["submenu","menuItem","items"],"mappings":";AAMA,IAAM,8BAAqB,CAAA,MAAA;AACzB,EAAA,IAAI,KAAQ,GAAA,CAAA;AAEZ,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,MAAM,CAAc,UAAA,EAAA,CAAA,KAAA,EAAA,EAAS,UAAU,CAAA;AAAA,GAC/C;AACF,CAAG,GAAA;AA2DI,IAAM,kBAAN,MAAsB;AAAA,EAC3B,WACE,CAAA,OAAA,GAAkC,EAAC,EACnC,OAA4B,MAC5B,EAAA;AACA,IAAA,IAAA,CAAK,EAAK,GAAA,OAAA,CAAQ,EAAM,IAAA,WAAA,CAAY,IAAK,EAAA;AACzC,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA;AACZ,IAAA,IAAA,CAAK,UAAU,OAAQ,CAAA,OAAA;AACvB,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA;AACtB,IAAA,IAAA,CAAK,QAAQ,OAAQ,CAAA,KAAA;AACrB,IAAA,IAAA,CAAK,wBAAwB,OAAQ,CAAA,qBAAA;AACrC,IAAA,IAAA,CAAK,uBAAuB,OAAQ,CAAA,oBAAA;AAAA;AACtC;AAAA;AAAA;AAAA;AAAA,EAiDO,UAAyC,GAAA;AAC9C,IAAA,MAAM,QAAuC,GAAA,EAAE,EAAI,EAAA,IAAA,CAAK,EAAG,EAAA;AAE3D,IAAI,IAAA,IAAA,CAAK,SAAS,M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AA;AAEhC,IAAA,IAAA,CAAK,cAAc,KAAK,CAAA;AAExB,IAAI,IAAA,WAAA,CAAY,QAAQ,CAAG,EAAA;AACzB,MAAS,QAAA,CAAA,KAAA,CAAM,UAAU,KAAK,CAAA;AAAA;AAGhC,IAAkB,iBAAA,CAAA,QAAA,EAAU,QAAS,CAAA,KAAA,CAAM,sBAAsB,CAAA;AAEjE,IAAO,OAAA,QAAA;AAAA;AAEX;AAMA,SAAS,YAAY,KAAgC,EAAA;AACnD,EAAO,OAAA,OAAA,IAAW,KAAS,IAAA,KAAA,CAAM,KAAU,KAAA,MAAA;AAC7C;AAEA,UAAU,gBACR,IACwC,EAAA;AACxC,EAAA,UAAU,QACRC,MACwC,EAAA;AACxC,IAAA,KAAA,MAAW,QAAQA,MAAO,EAAA;AACxB,MAAM,MAAA,IAAA;AAEN,MAAA,IAAI,gBAAgB,eAAiB,EAAA;AACnC,QAAO,OAAA,OAAA,CAAQ,KAAK,KAAK,CAAA;AAAA;AAC3B;AACF;AAGF,EAAO,OAAA,OAAA,CAAQ,KAAK,KAAK,CAAA;AAC3B;;;AClSO,IAAM,KAAQ,GAAA;AAAA,EACnB,QAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF","file":"renderer.mjs","sourcesContent":["import type { MenuItemConstructorOptions } from \"electron\";\n\nimport type { ContextMenuEvent } from \"./ContextMenuEvent.js\";\nimport type { SubmenuMenuItem } from \"./SubmenuMenuItem.js\";\nimport type { ContextMenuItemType } from \"./types.js\";\n\nconst idGenerator = (() => {\n let value = 1;\n\n return {\n next: () => `menu-item-${(value++).toString()}`,\n };\n})();\n\n/**\n * This is the click event fired in the _renderer_ process when a context menu\n * item is clicked. It has a different signature than the [`click` property](https://www.electronjs.org/docs/latest/api/menu-item#menuitemclick)\n * of the `MenuItemConstructorOptions`.\n */\nexport type OnContextMenuItemClick = (\n menuItem: ContextMenuItem,\n event: ContextMenuEvent,\n) => void | Promise<void>;\n\n/**\n * Options for creating a base context menu item.\n *\n * @internal\n */\nexport interface ContextMenuItemOptions {\n /**\n * ID of the menu item. Not all menu items require an ID (i.e. separator and\n * role), but all other menu items will need an ID to capture the click event,\n * so we set it here.\n */\n id?: string;\n\n /**\n * Sets the visibility of the menu item.\n */\n visible?: boolean;\n\n /**\n * Inserts this item before the item with the specified ID. If the referenced item\n * doesn't exist the item will be inserted at the end of the menu. Also implies\n * that the menu item in question should be placed in the same \"group\" as the item.\n */\n before?: string[];\n\n /**\n * Inserts this item after the item with the specified ID. If the referenced item\n * doesn't exist the item will be inserted at the end of the menu.\n */\n after?: string[];\n\n /**\n * Provides a means for a single context menu to declare the placement of their\n * containing group before the containing group of the item with the specified ID.\n */\n beforeGroupContaining?: string[];\n\n /**\n * Provides a means for a single context menu to declare the placement of their\n * containing group after the containing group of the item with the specified ID.\n */\n afterGroupContaining?: string[];\n}\n\n/**\n * Base context menu item from which other context menu items are derived.\n */\nexport class ContextMenuItem {\n constructor(\n options: ContextMenuItemOptions = {},\n type: ContextMenuItemType = undefined,\n ) {\n this.id = options.id ?? idGenerator.next();\n this.type = type;\n this.visible = options.visible;\n this.before = options.before;\n this.after = options.after;\n this.beforeGroupContaining = options.beforeGroupContaining;\n this.afterGroupContaining = options.afterGroupContaining;\n }\n\n /** ID of the menu item. */\n public id: string;\n\n /**\n * Type of the context menu item. See the [Electron documentation](https://www.electronjs.org/docs/latest/api/menu-item#menuitemtype)\n * for additional information.\n */\n public type: ContextMenuItemType;\n\n /** Indicates if the menu item is visible. */\n public visible: boolean | undefined;\n\n /**\n * Inserts this item before the item with the specified ID. If the referenced item\n * doesn't exist the item will be inserted at the end of the menu. Also implies\n * that the menu item in question should be placed in the same \"group\" as the item.\n */\n public before: string[] | undefined;\n\n /**\n * Inserts this item after the item with the specified ID. If the referenced item\n * doesn't exist the item will be inserted at the end of the menu.\n */\n public after: string[] | undefined;\n\n /**\n * Provides a means for a single context menu to declare the placement of their\n * containing group before the containing group of the item with the specified ID.\n */\n public beforeGroupContaining: string[] | undefined;\n\n /**\n * Provides a means for a single context menu to declare the placement of their\n * containing group after the containing group of the item with the specified ID.\n */\n public afterGroupContaining: string[] | undefined;\n\n /**\n * Parent submenu of the menu item. If the menu item is not part of a submenu,\n * this is undefined.\n */\n public parent: SubmenuMenuItem | undefined;\n\n /**\n * Converts the properties of this menu item to a template that can be sent\n * to the main process to build the menu.\n */\n public toTemplate(): MenuItemConstructorOptions {\n const template: MenuItemConstructorOptions = { id: this.id };\n\n if (this.type !== undefined) {\n template.type = this.type;\n }\n\n if (this.visible !== undefined) {\n template.visible = this.visible;\n }\n\n if (this.before !== undefined) {\n template.before = this.before;\n }\n\n if (this.after !== undefined) {\n template.after = this.after;\n }\n\n if (this.beforeGroupContaining !== undefined) {\n template.beforeGroupContaining = this.beforeGroupContaining;\n }\n\n if (this.afterGroupContaining !== undefined) {\n template.afterGroupContaining = this.afterGroupContaining;\n }\n\n return template;\n }\n}\n","import type { MenuItemConstructorOptions } from \"electron\";\n\nimport {\n ContextMenuItem,\n type ContextMenuItemOptions,\n type OnContextMenuItemClick,\n} from \"./ContextMenuItem.js\";\nimport type { ContextMenuItemType } from \"./types.js\";\n\nexport interface NormalMenuItemOptions extends ContextMenuItemOptions {\n accelerator?: string | undefined;\n acceleratorWorksWhenHidden?: boolean | undefined;\n enabled?: boolean | undefined;\n icon?: string | undefined;\n label: string | undefined;\n registerAccelerator?: boolean | undefined;\n toolTip?: string | undefined;\n click?: OnContextMenuItemClick;\n}\n\nexport function normal(options: NormalMenuItemOptions): NormalMenuItem {\n return new NormalMenuItem(options);\n}\n\nexport class NormalMenuItem<\n Options extends NormalMenuItemOptions = NormalMenuItemOptions,\n> extends ContextMenuItem {\n constructor(options: Options, type: ContextMenuItemType = \"normal\") {\n super(options, type);\n\n this.accelerator = options.accelerator;\n this.acceleratorWorksWhenHidden = options.acceleratorWorksWhenHidden;\n this.click = options.click;\n this.enabled = options.enabled;\n this.icon = options.icon;\n this.label = options.label;\n this.registerAccelerator = options.registerAccelerator;\n this.toolTip = options.toolTip;\n }\n\n public accelerator: string | undefined;\n public acceleratorWorksWhenHidden: boolean | undefined;\n public click: OnContextMenuItemClick | undefined;\n public enabled: boolean | undefined;\n public icon: string | undefined;\n public label: string | undefined;\n public registerAccelerator: boolean | undefined;\n public toolTip: string | undefined;\n\n public toTemplate(): MenuItemConstructorOptions {\n const template = super.toTemplate();\n\n if (this.accelerator !== undefined) {\n template.accelerator = this.accelerator;\n }\n\n if (this.acceleratorWorksWhenHidden !== undefined) {\n template.acceleratorWorksWhenHidden = this.acceleratorWorksWhenHidden;\n }\n\n if (this.enabled !== undefined) {\n template.enabled = this.enabled;\n }\n\n if (this.icon !== undefined) {\n template.icon = this.icon;\n }\n\n if (this.label !== undefined) {\n template.label = this.label;\n }\n\n if (this.registerAccelerator !== undefined) {\n template.registerAccelerator = this.registerAccelerator;\n }\n\n if (this.toolTip !== undefined) {\n template.toolTip = this.toolTip;\n }\n\n return template;\n }\n}\n","import type { MenuItemConstructorOptions } from \"electron\";\n\nimport {\n NormalMenuItem,\n type NormalMenuItemOptions,\n} from \"./NormalMenuItem.js\";\n\n/**\n * Options for creating a checkbox menu item.\n */\nexport interface CheckboxMenuItemOptions extends NormalMenuItemOptions {\n /** Indicates if checkbox is currently checked. */\n checked?: boolean | undefined;\n}\n\n/**\n * Returns a new {@linkcode CheckboxMenuItem} that can be added to a context\n * menu.\n *\n * @param options Options for creating the checkbox menu item.\n */\nexport function checkbox(options: CheckboxMenuItemOptions): CheckboxMenuItem {\n return new CheckboxMenuItem(options);\n}\n\n/**\n * Checkbox menu item in a context menu. This behaves similarly to a\n * {@linkcode NormalMenuItem} with the addition of a checked state. Multiple\n * items in the same submenu can be checked. If you need only one item checked\n * at a time, use the {@linkcode RadioMenuItem} instead.\n */\nexport class CheckboxMenuItem extends NormalMenuItem<CheckboxMenuItemOptions> {\n constructor(options: CheckboxMenuItemOptions) {\n super(options, \"checkbox\");\n\n this.checked = options.checked;\n }\n\n /** Indicates if checkbox is currently checked. */\n public checked: boolean | undefined;\n\n public toTemplate(): MenuItemConstructorOptions {\n const template = super.toTemplate();\n\n if (this.checked !== undefined) {\n template.checked = this.checked;\n }\n\n return template;\n }\n}\n","import type { MenuItemConstructorOptions } from \"electron\";\n\nimport {\n NormalMenuItem,\n type NormalMenuItemOptions,\n} from \"./NormalMenuItem.js\";\n\nexport interface RadioMenuItemOptions extends NormalMenuItemOptions {\n checked?: boolean | undefined;\n}\n\nexport function radio(options: RadioMenuItemOptions): RadioMenuItem {\n return new RadioMenuItem(options);\n}\n\nexport class RadioMenuItem extends NormalMenuItem<RadioMenuItemOptions> {\n constructor(options: RadioMenuItemOptions) {\n super(options, \"radio\");\n\n this.checked = options.checked;\n }\n\n public checked: boolean | undefined;\n\n public select(): void {\n this.checked = true;\n\n if (this.parent !== undefined) {\n for (const item of this.parent) {\n if (item instanceof RadioMenuItem && item !== this) {\n item.checked = false;\n }\n }\n }\n }\n\n public toTemplate(): MenuItemConstructorOptions {\n const template = super.toTemplate();\n\n if (this.checked !== undefined) {\n template.checked = this.checked;\n }\n\n return template;\n }\n}\n","import type { MenuItemConstructorOptions } from \"electron\";\n\nimport {\n ContextMenuItem,\n type ContextMenuItemOptions,\n} from \"./ContextMenuItem.js\";\nimport type { ContextMenuItemRole } from \"./types.js\";\n\nexport interface RoleMenuItemOptions extends ContextMenuItemOptions {\n accelerator?: string | undefined;\n acceleratorWorksWhenHidden?: boolean | undefined;\n enabled?: boolean | undefined;\n icon?: string | undefined;\n role: ContextMenuItemRole;\n registerAccelerator?: boolean | undefined;\n tooltip?: string | undefined;\n}\n\nexport function role(role: ContextMenuItemRole): RoleMenuItem;\n\nexport function role(options: RoleMenuItemOptions): RoleMenuItem;\n\nexport function role(\n init: ContextMenuItemRole | RoleMenuItemOptions,\n): RoleMenuItem {\n return new RoleMenuItem(init as any);\n}\n\nexport class RoleMenuItem extends ContextMenuItem {\n constructor(role: ContextMenuItemRole);\n constructor(options: RoleMenuItemOptions);\n constructor(init: ContextMenuItemRole | RoleMenuItemOptions) {\n super(typeof init === \"string\" ? { role: init } : init, undefined);\n\n if (typeof init === \"string\") {\n this.role = init;\n } else {\n const options = (init ?? {}) as RoleMenuItemOptions;\n\n if (options.role === undefined) {\n throw new Error(\"Role is required for a role menu item\");\n }\n\n this.accelerator = options.accelerator;\n this.acceleratorWorksWhenHidden = options.acceleratorWorksWhenHidden;\n this.enabled = options.enabled;\n this.icon = options.icon;\n this.registerAccelerator = options.registerAccelerator;\n this.role = options.role;\n this.tooltip = options.tooltip;\n }\n }\n\n public accelerator: string | undefined;\n public acceleratorWorksWhenHidden: boolean | undefined;\n public enabled: boolean | undefined;\n public icon: string | undefined;\n public registerAccelerator: boolean | undefined;\n public role: ContextMenuItemRole;\n public tooltip: string | undefined;\n\n public toTemplate(): MenuItemConstructorOptions {\n const template = super.toTemplate();\n\n template.role = this.role;\n\n if (this.accelerator !== undefined) {\n template.accelerator = this.accelerator;\n }\n\n if (this.acceleratorWorksWhenHidden !== undefined) {\n template.acceleratorWorksWhenHidden = this.acceleratorWorksWhenHidden;\n }\n\n if (this.enabled !== undefined) {\n template.enabled = this.enabled;\n }\n\n if (this.icon !== undefined) {\n template.icon = this.icon;\n }\n\n if (this.registerAccelerator !== undefined) {\n template.registerAccelerator = this.registerAccelerator;\n }\n\n if (this.tooltip !== undefined) {\n template.toolTip = this.tooltip;\n }\n\n return template;\n }\n}\n","import type { MenuItemConstructorOptions } from \"electron\";\n\nimport {\n ContextMenuItem,\n type ContextMenuItemOptions,\n} from \"./ContextMenuItem.js\";\n\nexport type SeparatorMenuItemOptions = ContextMenuItemOptions;\n\nexport function separator(\n options?: SeparatorMenuItemOptions,\n): SeparatorMenuItem {\n return new SeparatorMenuItem(options);\n}\n\nexport class SeparatorMenuItem extends ContextMenuItem {\n constructor(options?: SeparatorMenuItemOptions) {\n super(options, \"separator\");\n }\n\n public toTemplate(): MenuItemConstructorOptions {\n return super.toTemplate();\n }\n}\n","import type { MenuItemConstructorOptions, SharingItem } from \"electron\";\n\nimport {\n ContextMenuItem,\n type ContextMenuItemOptions,\n} from \"./ContextMenuItem.js\";\n\n/**\n * Options for creating a Share menu item.\n */\nexport interface ShareMenuItemOptions extends ContextMenuItemOptions {\n /** Array of file paths to share. */\n filePaths?: string[];\n\n /** Array of text values to share. */\n texts?: string[];\n\n /** Array of URLs to share. */\n urls?: string[];\n}\n\n/**\n * Creates a new Share menu for sharing items on macOS.\n *\n * @param options Options for the share menu item.\n */\nexport function shareMenu(options: ShareMenuItemOptions): ShareMenuItem {\n return new ShareMenuItem(options);\n}\n\n/**\n * Share menu for sharing items on macOS.\n */\nexport class ShareMenuItem extends ContextMenuItem {\n constructor(options: ShareMenuItemOptions) {\n super(options, undefined);\n\n this.filePaths = options.filePaths;\n this.texts = options.texts;\n this.urls = options.urls;\n }\n\n public filePaths: string[] | undefined;\n public texts: string[] | undefined;\n public urls: string[] | undefined;\n\n public toTemplate(): MenuItemConstructorOptions {\n this.validate();\n\n const template = super.toTemplate();\n\n const sharingItem: SharingItem = {};\n\n if (this.filePaths !== undefined) {\n sharingItem.filePaths = this.filePaths;\n }\n\n if (this.texts !== undefined) {\n sharingItem.texts = this.texts;\n }\n\n if (this.urls !== undefined) {\n sharingItem.urls = this.urls;\n }\n\n template.role = \"shareMenu\";\n\n template.sharingItem = sharingItem;\n\n return template;\n }\n\n /**\n * Ensures the share menu has at least 1 sharing item.\n *\n * @throws Error If nothing is being shared.\n */\n public validate(): void {\n for (const entry of [this.filePaths, this.texts, this.urls]) {\n if ((entry ?? []).length !== 0) {\n return;\n }\n }\n\n // biome-ignore format:\n throw new Error(\"A share menu must have at least 1 file path, text, or URL\");\n }\n}\n","import {\n CheckboxMenuItem,\n type CheckboxMenuItemOptions,\n} from \"./CheckboxMenuItem.js\";\nimport type { ContextMenuItem } from \"./ContextMenuItem.js\";\nimport {\n NormalMenuItem,\n type NormalMenuItemOptions,\n} from \"./NormalMenuItem.js\";\nimport { RadioMenuItem, type RadioMenuItemOptions } from \"./RadioMenuItem.js\";\nimport { RoleMenuItem, type RoleMenuItemOptions } from \"./RoleMenuItem.js\";\nimport {\n SeparatorMenuItem,\n type SeparatorMenuItemOptions,\n} from \"./SeparatorMenuItem.js\";\nimport { ShareMenuItem, type ShareMenuItemOptions } from \"./ShareMenuItem.js\";\nimport {\n SubmenuMenuItem,\n type SubmenuMenuItemOptions,\n} from \"./SubmenuMenuItem.js\";\n\nexport type MenuBuilderFunction = (builder: MenuBuilder) => MenuBuilder;\n\n/**\n * Used to build a context menu with a builder function, rather than specifying\n * an array of menu items.\n *\n * @internal\n */\nexport class MenuBuilder {\n readonly #items: ContextMenuItem[] = [];\n\n /** Items in the context menu. */\n public get items(): ContextMenuItem[] {\n return this.#items;\n }\n\n /**\n * Adds the specified `item` to the context menu.\n *\n * @param item Context menu item to add.\n */\n public add(item: ContextMenuItem): this {\n this.#items.push(item);\n return this;\n }\n\n /**\n * Iterates over the specified `values` and calls the `onValue` callback to\n * add menu items to the menu.\n *\n * This is useful for adding multiple submenu items in a builder function.\n *\n * @param values Array of values of any type to iterate over.\n * @param onValue Callback called for each value.\n *\n * @example\n * const menu = contextMenu((builder) =>\n * builder.submenu(\n * {\n * id: \"submenu\",\n * label: \"Radio Options\",\n * sublabel: \"This is a sublabel\",\n * },\n * (builder) =>\n * builder.map([\"1\", \"2\", \"3\"], (value) =>\n * builder.radio({\n * label: `Option ${value}`,\n * checked: activeOption === value,\n * click() {\n * console.log(`Clicked ${value}`);\n * },\n * }),\n * ),\n * ),\n * );\n */\n public map<T>(values: T[], onValue: (value: T) => any): this {\n for (const value of values) {\n onValue(value);\n }\n\n return this;\n }\n\n /** Adds a checkbox menu item to the menu with the specified options. */\n public checkbox(options: CheckboxMenuItemOptions): this {\n this.#items.push(new CheckboxMenuItem(options));\n return this;\n }\n\n /** Adds a normal menu item to the menu with the specified options. */\n public normal(options: NormalMenuItemOptions): this {\n this.#items.push(new NormalMenuItem(options));\n return this;\n }\n\n /** Adds a radio menu item to the menu with the specified options. */\n public radio(options: RadioMenuItemOptions): this {\n this.#items.push(new RadioMenuItem(options));\n return this;\n }\n\n /** Adds a role menu item to the menu with the specified options. */\n public role(options: RoleMenuItemOptions): this {\n this.#items.push(new RoleMenuItem(options));\n return this;\n }\n\n /** Adds a separator menu item to the menu. */\n public separator(options?: SeparatorMenuItemOptions): this {\n this.#items.push(new SeparatorMenuItem(options));\n return this;\n }\n\n /**\n * Adds a Share Menu item to the menu.\n *\n * @platforms macOS\n */\n public shareMenu(options: ShareMenuItemOptions): this {\n this.#items.push(new ShareMenuItem(options));\n return this;\n }\n\n /**\n * Adds a submenu menu item to the context menu with the specified `options`\n * and containing the specified `items`.\n */\n public submenu(\n options: SubmenuMenuItemOptions,\n items: ContextMenuItem[],\n ): this;\n\n /**\n * Adds a submenu menu item to the context menu with the specified `options`\n * and items added with the specified `build` function.\n */\n public submenu(\n options: SubmenuMenuItemOptions,\n build: MenuBuilderFunction,\n ): this;\n\n public submenu(\n options: SubmenuMenuItemOptions,\n init: ContextMenuItem[] | MenuBuilderFunction,\n ): this {\n this.#items.push(new SubmenuMenuItem(options, init as any));\n return this;\n }\n}\n","import type { MenuItemConstructorOptions } from \"electron\";\n\nimport {\n ContextMenuItem,\n type ContextMenuItemOptions,\n} from \"./ContextMenuItem.js\";\nimport { MenuBuilder, type MenuBuilderFunction } from \"./MenuBuilder.js\";\n\nexport interface SubmenuMenuItemOptions extends ContextMenuItemOptions {\n enabled?: boolean | undefined;\n icon?: string | undefined;\n label: string | undefined;\n toolTip?: string | undefined;\n}\n\nexport function submenu(\n options: SubmenuMenuItemOptions,\n items: ContextMenuItem[],\n): SubmenuMenuItem;\n\nexport function submenu(\n options: SubmenuMenuItemOptions,\n build: MenuBuilderFunction,\n): SubmenuMenuItem;\n\nexport function submenu(\n options: SubmenuMenuItemOptions,\n init: ContextMenuItem[] | MenuBuilderFunction,\n): SubmenuMenuItem {\n return new SubmenuMenuItem(options, init as any);\n}\n\nexport class SubmenuMenuItem extends ContextMenuItem {\n constructor(options: SubmenuMenuItemOptions, build: MenuBuilderFunction);\n constructor(options: SubmenuMenuItemOptions, items: ContextMenuItem[]);\n constructor(\n options: SubmenuMenuItemOptions,\n init: ContextMenuItem[] | MenuBuilderFunction,\n ) {\n super(options, \"submenu\");\n\n this.enabled = options.enabled;\n this.icon = options.icon;\n this.items = Array.isArray(init) ? init : init(new MenuBuilder()).items;\n this.label = options.label;\n this.toolTip = options.toolTip;\n }\n\n public enabled: boolean | undefined;\n public icon: string | undefined;\n public items: ContextMenuItem[];\n public label: string | undefined;\n public toolTip: string | undefined;\n\n *[Symbol.iterator]() {\n for (const item of this.items) {\n yield item;\n }\n }\n\n public toTemplate(): MenuItemConstructorOptions {\n const template = super.toTemplate();\n\n if (this.enabled !== undefined) {\n template.enabled = this.enabled;\n }\n\n if (this.icon !== undefined) {\n template.icon = this.icon;\n }\n\n if (this.label !== undefined) {\n template.label = this.label;\n }\n\n if (this.toolTip !== undefined) {\n template.toolTip = this.toolTip;\n }\n\n const submenu: MenuItemConstructorOptions[] = [];\n\n for (const item of this.items) {\n item.parent = this;\n\n submenu.push(item.toTemplate());\n }\n\n return { ...template, submenu };\n }\n}\n","import type {\n KeyboardEvent,\n MenuItemConstructorOptions,\n Point,\n} from \"electron\";\n\nexport const hoverboardApiKey = \"__laserware_hoverboard__\";\n\ndeclare global {\n interface Window {\n [hoverboardApiKey]: HoverboardGlobals;\n }\n}\n\n// biome-ignore lint/suspicious/noConstEnum: Swapped out with value in build process.\nexport const enum IpcChannel {\n ForShowContextMenu = \"hoverboard/contextMenu/show\",\n ForHideContextMenu = \"hoverboard/contextMenu/hide\",\n}\n\nexport interface ShowContextMenuRequest {\n menuId: string;\n position: Point;\n linkURL?: string;\n template: MenuItemConstructorOptions[];\n}\n\nexport interface ShowContextMenuResponse {\n menuId: string;\n menuItemId: string | null;\n event: KeyboardEvent;\n}\n\nexport interface HoverboardGlobals {\n showContextMenu(\n request: ShowContextMenuRequest,\n ): Promise<ShowContextMenuResponse>;\n hideContextMenu(menuId: string): Promise<void>;\n}\n\nexport function getHoverboardGlobals(): HoverboardGlobals {\n const windowGlobals = window[hoverboardApiKey];\n\n if (windowGlobals === undefined) {\n throw new Error(\"Globals not found, need to use preload\");\n }\n\n return {\n showContextMenu(\n request: ShowContextMenuRequest,\n ): Promise<ShowContextMenuResponse> {\n return windowGlobals.showContextMenu(request);\n },\n hideContextMenu(menuId: string): Promise<void> {\n return windowGlobals.hideContextMenu(menuId);\n },\n };\n}\n","import type { ContextMenuItem } from \"./ContextMenuItem.js\";\n\nexport type ContextMenuEventType = \"click\" | \"hide\" | \"show\";\n\nexport interface ContextMenuEventInit extends EventModifierInit {\n clientX?: number;\n clientY?: number;\n menuItem: ContextMenuItem | null;\n triggeredByAccelerator?: boolean;\n}\n\ntype ContextMenuEventListener = (event: ContextMenuEvent) => void;\n\ninterface ContextMenuEventListenerObject {\n handleEvent(object: ContextMenuEvent): void;\n}\n\nexport type ContextMenuEventListenerOrEventListenerObject =\n | ContextMenuEventListener\n | ContextMenuEventListenerObject;\n\nexport class ContextMenuEvent extends Event {\n public clientX: number;\n public clientY: number;\n public menuItem: ContextMenuItem | null;\n public triggeredByAccelerator: boolean;\n\n constructor(type: ContextMenuEventType, eventInitDict: ContextMenuEventInit) {\n const { clientX, clientY, menuItem, triggeredByAccelerator, ...rest } =\n eventInitDict;\n\n super(type, rest);\n\n this.clientX = clientX ?? 0;\n this.clientY = clientY ?? 0;\n this.menuItem = menuItem;\n this.triggeredByAccelerator = triggeredByAccelerator ?? false;\n }\n}\n","import type { MenuItemConstructorOptions } from \"electron\";\n\nimport { getHoverboardGlobals } from \"../sandbox/globals.js\";\nimport {\n ContextMenuEvent,\n type ContextMenuEventInit,\n type ContextMenuEventListenerOrEventListenerObject,\n type ContextMenuEventType,\n} from \"./ContextMenuEvent.js\";\nimport type {\n ContextMenuItem,\n OnContextMenuItemClick,\n} from \"./ContextMenuItem.js\";\nimport { MenuBuilder, type MenuBuilderFunction } from \"./MenuBuilder.js\";\nimport { NormalMenuItem } from \"./NormalMenuItem.js\";\nimport { SubmenuMenuItem } from \"./SubmenuMenuItem.js\";\n\n/**\n * Creates a new context menu with the specified `items`.\n *\n * @param items Context menu items to add to context menu.\n *\n * @returns Context menu with specified items.\n */\nexport function contextMenu(items: ContextMenuItem[]): ContextMenu;\n\n/**\n * Builds a new context menu using the specified `build` function.\n *\n * @param build Function with menu builder to assign items to menu.\n *\n * @returns Context menu with items added from build function.\n */\nexport function contextMenu(build: MenuBuilderFunction): ContextMenu;\n\nexport function contextMenu(\n init: ContextMenuItem[] | MenuBuilderFunction,\n): ContextMenu {\n return new ContextMenu(init as any);\n}\n\n/**\n * Provides the means to create and show custom context menus.\n */\nexport class ContextMenu extends EventTarget {\n /**\n * Creates a new context menu with the specified `items`.\n *\n * @param items Context menu items to add to context menu.\n */\n constructor(items: ContextMenuItem[]);\n\n /**\n * Builds a new context menu using the specified `build` function.\n *\n * @param build Function with menu builder to assign items to menu.\n */\n constructor(build: MenuBuilderFunction);\n constructor(init: ContextMenuItem[] | MenuBuilderFunction) {\n super();\n\n this.id = window.crypto.randomUUID().substring(0, 6);\n\n this.items = Array.isArray(init) ? init : init(new MenuBuilder()).items;\n }\n\n *[Symbol.iterator]() {\n for (const item of this.items) {\n yield item;\n }\n }\n\n public id: string;\n public items: ContextMenuItem[];\n\n /**\n * Appends the specified `item` to the context menu.\n *\n * @param item Menu item to append to context menu.\n */\n public append(item: ContextMenuItem): void {\n this.items.push(item);\n }\n\n /**\n * Inserts the specified `item` in the specified position of the context\n * menu.\n *\n * @param position Position in the menu to add the item.\n * @param item Item to insert into the context menu.\n */\n public insert(position: number, item: ContextMenuItem): void {\n this.items = [\n ...this.items.slice(0, position),\n item,\n ...this.items.slice(position),\n ];\n }\n\n /**\n * Removes the specified `item` from the context menu.\n *\n * @param item Menu item to remove from context menu.\n */\n public remove(item: ContextMenuItem): void {\n this.items = this.items.filter((existingItem) => existingItem !== item);\n }\n\n /**\n * Returns the menu item associated with the specified `id`. If the menu\n * item doesn't exist, returns null.\n *\n * @param id ID of the menu item to find.\n *\n * @returns The menu item if found, otherwise null.\n */\n public getMenuItemById(id: string): ContextMenuItem | null {\n for (const item of walkContextMenu(this)) {\n if (item.id === id) {\n return item;\n }\n }\n\n return null;\n }\n\n /**\n * Converts the contents of the context menu item to a serializable template\n * that is sent to the main process to build the context menu.\n */\n public toTemplate(): MenuItemConstructorOptions[] {\n const template: MenuItemConstructorOptions[] = [];\n\n for (const item of this.items) {\n template.push(item.toTemplate());\n }\n\n return template;\n }\n\n /**\n * Adds an event listener for the click event of a context menu item. This\n * event is fired when any context menu item is clicked. This is dispatched\n * *after* the `click` property of a menu item.\n */\n public addEventListener(\n type: \"click\",\n callback: ContextMenuEventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n\n /**\n * Adds an event listener for the hide event of a context menu. This event\n * is dispatched immediately after the menu is hidden.\n */\n public addEventListener(\n type: \"hide\",\n callback: ContextMenuEventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n\n /**\n * Adds an event listener for the show event of a context menu. This event\n * is dispatched immediately before the menu is shown.\n */\n public addEventListener(\n type: \"show\",\n callback: ContextMenuEventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n public addEventListener(\n type: ContextMenuEventType,\n callback: ContextMenuEventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void {\n // biome-ignore format:\n super.addEventListener(type, callback as EventListenerOrEventListenerObject, options);\n }\n\n public removeEventListener(\n type: \"click\",\n callback: ContextMenuEventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n public removeEventListener(\n type: \"hide\",\n callback: ContextMenuEventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n public removeEventListener(\n type: \"show\",\n callback: ContextMenuEventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n public removeEventListener(\n type: ContextMenuEventType,\n callback: ContextMenuEventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void {\n // biome-ignore format:\n super.removeEventListener(type, callback as EventListenerOrEventListenerObject, options);\n }\n\n /**\n * Hides the context menu (if it is open).\n */\n public async hide(): Promise<void> {\n const globals = getHoverboardGlobals();\n\n await globals.hideContextMenu(this.id);\n\n this.dispatchEvent(new ContextMenuEvent(\"hide\", { menuItem: null }));\n }\n\n /**\n * Shows the context menu in the specified `x` and `y` coordinates.\n *\n * @param x X location to display the context menu.\n * @param y Y location to display the context menu.\n *\n * @returns Promise resolving with the menu item that was clicked. If no menu\n * item was clicked, resolves to `null`.\n */\n public async show(x: number, y: number): Promise<ContextMenuItem | null> {\n const template = this.toTemplate();\n\n const globals = getHoverboardGlobals();\n\n const dispatchHideEvent = (\n menuItem: ContextMenuItem | null,\n triggeredByAccelerator?: boolean,\n ): void => {\n this.dispatchEvent(\n new ContextMenuEvent(\"hide\", {\n clientX: x,\n clientY: y,\n menuItem,\n triggeredByAccelerator,\n }),\n );\n };\n\n let linkURL: string | undefined;\n\n // If any of the elements in the clicked point are an anchor with an\n // `href` property, send that to the context menu builder in the main\n // process so we can add the appropriate link actions to the menu:\n for (const element of document.elementsFromPoint(x, y)) {\n if (element instanceof HTMLAnchorElement) {\n linkURL = element.href || undefined;\n }\n\n if (linkURL !== undefined) {\n break;\n }\n }\n\n const promise = globals.showContextMenu({\n menuId: this.id,\n position: { x, y },\n template,\n linkURL,\n });\n\n this.dispatchEvent(\n new ContextMenuEvent(\"show\", {\n clientX: x,\n clientY: y,\n menuItem: null,\n } satisfies ContextMenuEventInit),\n );\n\n const response = await promise;\n\n if (response.menuId !== this.id) {\n return null;\n }\n\n if (response.menuItemId === null) {\n dispatchHideEvent(null);\n\n return null;\n }\n\n let menuItem: ContextMenuItem | null = null;\n\n for (const item of walkContextMenu(this)) {\n if (item.id === response.menuItemId) {\n menuItem = item;\n break;\n }\n }\n\n if (menuItem === null) {\n dispatchHideEvent(null);\n\n return null;\n }\n\n const event = new ContextMenuEvent(\"click\", {\n ...response.event,\n clientX: x,\n clientY: y,\n menuItem,\n } satisfies ContextMenuEventInit);\n\n this.dispatchEvent(event);\n\n if (isClickable(menuItem)) {\n menuItem.click(menuItem, event);\n }\n\n dispatchHideEvent(menuItem, response.event.triggeredByAccelerator);\n\n return menuItem;\n }\n}\n\ninterface Clickable {\n click: OnContextMenuItemClick;\n}\n\nfunction isClickable(value: any): value is Clickable {\n return \"click\" in value && value.click !== undefined;\n}\n\nfunction* walkContextMenu(\n menu: ContextMenu,\n): Generator<ContextMenuItem, void, void> {\n function* recurse(\n items: ContextMenuItem[],\n ): Generator<ContextMenuItem, void, void> {\n for (const item of items) {\n yield item;\n\n if (item instanceof SubmenuMenuItem) {\n yield* recurse(item.items);\n }\n }\n }\n\n yield* recurse(menu.items);\n}\n","import { checkbox } from \"./CheckboxMenuItem.js\";\nimport { normal } from \"./NormalMenuItem.js\";\nimport { radio } from \"./RadioMenuItem.js\";\nimport { role } from \"./RoleMenuItem.js\";\nimport { separator } from \"./SeparatorMenuItem.js\";\nimport { shareMenu } from \"./ShareMenuItem.js\";\nimport { submenu } from \"./SubmenuMenuItem.js\";\n\nexport { contextMenu, ContextMenu } from \"./ContextMenu.js\";\nexport {\n ContextMenuEvent,\n type ContextMenuEventInit,\n type ContextMenuEventType,\n type ContextMenuEventListenerOrEventListenerObject,\n} from \"./ContextMenuEvent.js\";\nexport type { ContextMenuItem } from \"./ContextMenuItem.js\";\nexport {\n checkbox,\n CheckboxMenuItem,\n type CheckboxMe