@m3ui-vue/electron 0.2.0 → 0.3.0
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/README.md +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +205 -148
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +85 -59
- package/dist/main.js.map +1 -1
- package/dist/preload.cjs +1 -1
- package/dist/preload.cjs.map +1 -1
- package/dist/preload.d.ts +2 -0
- package/dist/preload.js +10 -1
- package/dist/preload.js.map +1 -1
- package/dist/renderer/_nativeMenu.d.ts +15 -0
- package/dist/renderer/useElectronWindow.d.ts +7 -1
- package/dist/{shared-OD5t8cpt.js → shared-CmmPhgMH.js} +4 -2
- package/dist/{shared-OD5t8cpt.js.map → shared-CmmPhgMH.js.map} +1 -1
- package/dist/shared-F3rp76zP.cjs +2 -0
- package/dist/{shared-BLenUWPr.cjs.map → shared-F3rp76zP.cjs.map} +1 -1
- package/dist/shared.d.ts +27 -0
- package/package.json +1 -1
- package/dist/shared-BLenUWPr.cjs +0 -2
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["readFileSync","writeFileSync","join","app","ipcMain","nativeTheme","screen","shell","systemPreferences","IPC","BASELINE","resolve","o","boundsFile","name","readBounds","b","restoredBounds","a","m3WindowOptions","options","saved","x","y","width","height","mac","windows","registered","accent","c","stateOf","win","entry","sender","register","w","action","colors","isHex","key","theme","value","count","EXTERNAL","setupM3Window","id","send","events","ev","save","timer","later","url","e","here","other"],"sources":["../src/main.ts"],"sourcesContent":["/**\n * `@m3ui-vue/electron/main`: the main-process half. `m3WindowOptions()` gives the BrowserWindow options for the mode\n * you pick, `setupM3Window()` wires that window to MTitleBar (its state, its buttons, the native overlay's colors) and\n * to `useElectronWindow()` (native theme, accent color, taskbar progress and badge, attention), remembers its bounds\n * and sends outside links to the browser.\n *\n * ```ts\n * const m3 = { controls: 'native' } as const\n * const win = new BrowserWindow({ width: 1100, height: 720, ...m3WindowOptions(m3), webPreferences: { preload } })\n * setupM3Window(win, m3)\n * ```\n */\nimport { readFileSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { app, BrowserWindow, ipcMain, nativeTheme, screen, shell, systemPreferences, type BrowserWindowConstructorOptions, type IpcMainEvent, type IpcMainInvokeEvent, type Rectangle, type WebContents } from 'electron'\nimport { DEFAULT_TITLE_BAR_HEIGHT, IPC, type M3Controls, type M3NativeTheme, type M3OverlayColors, type M3WindowAction, type M3WindowInfo, type M3WindowState } from './shared'\n\nexport type { M3Controls, M3NativeTheme, M3OverlayColors, M3WindowAction, M3WindowInfo, M3WindowState } from './shared'\n\nexport interface M3WindowOptions {\n /** `'native'` (default): the system's buttons, recolored from the theme. `'custom'`: frameless, MTitleBar draws them */\n controls?: M3Controls\n /** Title bar height in px (default 40) */\n titleBarHeight?: number\n /**\n * The native buttons' colors before the page has loaded (MTitleBar sends the real ones from the theme as soon as\n * it mounts). Defaults to the M3 baseline light surface\n */\n overlay?: Partial<M3OverlayColors>\n /**\n * Reopen the window with the size, position and maximized state it closed with (kept in the app's userData\n * folder). `true`, or a name per window when the app has several. Spread `m3WindowOptions()` after your own\n * width/height so the remembered ones win\n */\n rememberBounds?: boolean | string\n /**\n * Open http(s) and mailto links that would leave the app (`target=\"_blank\"`, `window.open`, a link to another\n * site) in the system browser instead of a new Electron window. Default true\n */\n externalLinks?: boolean\n}\n\ninterface Resolved {\n controls: M3Controls\n titleBarHeight: number\n overlay: M3OverlayColors\n bounds: string | null\n externalLinks: boolean\n}\n\nconst BASELINE: M3OverlayColors = { color: '#fef7ff', symbolColor: '#49454f' }\n\nfunction resolve(o: M3WindowOptions = {}): Resolved {\n return {\n controls: o.controls === 'custom' ? 'custom' : 'native',\n titleBarHeight: Math.max(24, Math.round(o.titleBarHeight ?? DEFAULT_TITLE_BAR_HEIGHT)),\n overlay: { ...BASELINE, ...o.overlay },\n bounds: o.rememberBounds ? `m3-window${typeof o.rememberBounds === 'string' ? `-${o.rememberBounds.replace(/[^\\w-]/g, '_')}` : ''}.json` : null,\n externalLinks: o.externalLinks !== false,\n }\n}\n\n// ── Remembered bounds ───────────────────────────────────────────────────────────────────────────────────────────\ninterface Saved extends Rectangle { maximized: boolean }\nconst boundsFile = (name: string) => join(app.getPath('userData'), name)\n\nfunction readBounds(name: string): Saved | null {\n try {\n const b = JSON.parse(readFileSync(boundsFile(name), 'utf8')) as Saved\n if (![b.x, b.y, b.width, b.height].every(Number.isFinite)) return null\n return b\n } catch {\n return null\n }\n}\n\n/** The saved bounds, without the position when no screen shows enough of the window anymore (a monitor unplugged) */\nfunction restoredBounds(name: string): Partial<Rectangle> & { maximized?: boolean } {\n const b = readBounds(name)\n if (!b) return {}\n const visible = screen.getAllDisplays().some(({ workArea: a }) =>\n Math.min(b.x + b.width, a.x + a.width) - Math.max(b.x, a.x) >= 100 && Math.min(b.y + 40, a.y + a.height) - Math.max(b.y, a.y) >= 20)\n return visible ? b : { width: b.width, height: b.height, maximized: b.maximized }\n}\n\n/** The BrowserWindow options for a mode: spread them into `new BrowserWindow({ ... })` */\nexport function m3WindowOptions(options: M3WindowOptions = {}): BrowserWindowConstructorOptions {\n const o = resolve(options)\n let saved: BrowserWindowConstructorOptions = {}\n if (o.bounds) {\n const { x, y, width, height } = restoredBounds(o.bounds)\n saved = { ...(width ? { width, height } : {}), ...(x != null ? { x, y } : {}) }\n }\n if (o.controls === 'custom') return { ...saved, frame: false }\n const mac = process.platform === 'darwin'\n return {\n ...saved,\n titleBarStyle: 'hidden',\n // macOS keeps its traffic lights (`true` only turns on the overlay's CSS env() area); elsewhere the system's\n // buttons are drawn over the page in these colors, at the bar's height\n titleBarOverlay: mac ? true : { ...o.overlay, height: o.titleBarHeight },\n // Traffic lights (12px, 20px apart) centered in the bar\n ...(mac ? { trafficLightPosition: { x: 14, y: Math.round((o.titleBarHeight - 16) / 2) } } : {}),\n }\n}\n\n// One handler per channel for the whole app; each message finds its window's settings by the sender\nconst windows = new Map<number, { win: BrowserWindow; o: Resolved; overlay: string }>()\nlet registered = false\n\nconst accent = (): string | null => {\n try {\n const c = process.platform === 'win32' || process.platform === 'darwin' ? systemPreferences.getAccentColor() : ''\n return /^[0-9a-f]{6}/i.test(c) ? `#${c.slice(0, 6).toLowerCase()}` : null\n } catch {\n return null\n }\n}\n\nconst stateOf = (win: BrowserWindow): M3WindowState => ({\n maximized: win.isMaximized(),\n fullscreen: win.isFullScreen(),\n focused: win.isFocused(),\n})\n\nfunction entry(sender: WebContents) {\n return windows.get(sender.id)\n}\n\nfunction register() {\n if (registered) return\n registered = true\n ipcMain.handle(IPC.info, (e: IpcMainInvokeEvent): M3WindowInfo | null => {\n const w = entry(e.sender)\n if (!w) return null\n return { controls: w.o.controls, platform: process.platform, titleBarHeight: w.o.titleBarHeight, state: stateOf(w.win), accentColor: accent() }\n })\n ipcMain.on(IPC.action, (e: IpcMainEvent, action: M3WindowAction) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed()) return\n if (action === 'minimize') w.win.minimize()\n else if (action === 'toggle-maximize') {\n if (w.win.isFullScreen()) w.win.setFullScreen(false)\n else if (w.win.isMaximized()) w.win.unmaximize()\n else w.win.maximize()\n } else if (action === 'close') w.win.close()\n })\n ipcMain.on(IPC.overlay, (e: IpcMainEvent, colors: M3OverlayColors) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed() || w.o.controls !== 'native' || process.platform === 'darwin') return\n if (!isHex(colors?.color) || !isHex(colors?.symbolColor)) return\n // The renderer sends every frame of a theme transition: skip what wouldn't change anything\n const key = `${colors.color}|${colors.symbolColor}`\n if (key === w.overlay) return\n w.overlay = key\n w.win.setTitleBarOverlay({ color: colors.color, symbolColor: colors.symbolColor, height: w.o.titleBarHeight })\n })\n // The app's theme choice drives the native UI too (dialogs, context menus, scrollbars, macOS's frame). The\n // choice, not the result: 'system' must stay 'system', or prefers-color-scheme would follow the app back\n ipcMain.on(IPC.theme, (e: IpcMainEvent, theme: M3NativeTheme) => {\n if (!entry(e.sender) || !['light', 'dark', 'system'].includes(theme)) return\n if (nativeTheme.themeSource !== theme) nativeTheme.themeSource = theme\n })\n ipcMain.on(IPC.progress, (e: IpcMainEvent, value: number | 'indeterminate' | null) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed()) return\n if (value === 'indeterminate') w.win.setProgressBar(2, { mode: 'indeterminate' })\n else if (typeof value === 'number' && Number.isFinite(value)) w.win.setProgressBar(Math.min(1, Math.max(0, value)))\n else w.win.setProgressBar(-1)\n })\n ipcMain.on(IPC.badge, (e: IpcMainEvent, count: number) => {\n if (!entry(e.sender)) return\n app.setBadgeCount(Math.max(0, Math.floor(Number(count) || 0)))\n })\n ipcMain.on(IPC.attention, (e: IpcMainEvent) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed() || w.win.isFocused()) return\n if (process.platform === 'darwin') app.dock?.bounce('informational')\n else {\n w.win.flashFrame(true)\n w.win.once('focus', () => { if (!w.win.isDestroyed()) w.win.flashFrame(false) })\n }\n })\n // Accent color changes (Windows sends them; macOS asks for a relaunch of most apps anyway)\n const sendAccent = () => { for (const { win } of windows.values()) if (!win.isDestroyed()) win.webContents.send(IPC.accent, accent()) }\n systemPreferences.on?.('accent-color-changed', sendAccent)\n}\n\nconst EXTERNAL = /^(https?|mailto):/i\n\nconst isHex = (c: unknown): c is string => typeof c === 'string' && /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(c)\n\n/**\n * Connects `win` to MTitleBar: answers its questions, runs its buttons, sends it the window's state and recolors the\n * native buttons with the theme. Pass the same options as to `m3WindowOptions()`. Returns a function that undoes it\n * (it's undone on its own when the window closes).\n */\nexport function setupM3Window(win: BrowserWindow, options: M3WindowOptions = {}): () => void {\n register()\n const o = resolve(options)\n const id = win.webContents.id\n windows.set(id, { win, o, overlay: '' })\n const send = () => { if (!win.isDestroyed()) win.webContents.send(IPC.state, stateOf(win)) }\n const events = ['maximize', 'unmaximize', 'enter-full-screen', 'leave-full-screen', 'focus', 'blur', 'restore'] as const\n for (const ev of events) win.on(ev as 'maximize', send)\n\n // Bounds: the size it had before being maximized (getNormalBounds), saved after moves and resizes settle\n let save = () => {}\n let timer: ReturnType<typeof setTimeout> | undefined\n const later = () => { clearTimeout(timer); timer = setTimeout(save, 400) }\n if (o.bounds) {\n const name = o.bounds\n if (readBounds(name)?.maximized) win.maximize()\n save = () => {\n if (win.isDestroyed() || win.isMinimized() || win.isFullScreen()) return\n try {\n writeFileSync(boundsFile(name), JSON.stringify({ ...win.getNormalBounds(), maximized: win.isMaximized() }))\n } catch { /* a read-only profile: nothing to remember */ }\n }\n for (const ev of ['resize', 'move', 'maximize', 'unmaximize'] as const) win.on(ev as 'resize', later)\n win.on('close', () => { clearTimeout(timer); save() })\n }\n\n // Links that leave the app open in the browser\n if (o.externalLinks) {\n win.webContents.setWindowOpenHandler(({ url }) => {\n if (EXTERNAL.test(url)) void shell.openExternal(url)\n return { action: 'deny' }\n })\n win.webContents.on('will-navigate', (e, url) => {\n const here = win.webContents.getURL()\n let other = false\n try { other = new URL(url).origin !== new URL(here).origin } catch { /* about:blank and the like */ }\n if (EXTERNAL.test(url) && other) {\n e.preventDefault()\n void shell.openExternal(url)\n }\n })\n }\n\n const dispose = () => {\n windows.delete(id)\n clearTimeout(timer)\n if (!win.isDestroyed()) {\n for (const ev of events) win.off(ev as 'maximize', send)\n for (const ev of ['resize', 'move', 'maximize', 'unmaximize'] as const) win.off(ev as 'resize', later)\n }\n }\n win.once('closed', () => { windows.delete(id); clearTimeout(timer) })\n return dispose\n}\n"],"mappings":";;;;;AAkDA,IAAMU,IAA4B;CAAE,OAAO;CAAW,aAAa;AAAU;AAE7E,SAASC,EAAQC,IAAqB,CAAC,GAAa;CAClD,OAAO;EACL,UAAUA,EAAE,aAAa,WAAW,WAAW;EAC/C,gBAAgB,KAAK,IAAI,IAAI,KAAK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L,EAAQ,OAAOmB,CAAE,GAAG,aAAaK,CAAK;CAAE,CAAC,SAR9C;EAGpB,IAFAxB,EAAQ,OAAOmB,CAAE,GACjB,aAAaK,CAAK,GACd,CAACnB,EAAI,YAAY,GAAG;GACtB,KAAK,IAAMiB,KAAMD,GAAQhB,EAAI,IAAIiB,GAAkBF,CAAI;GACvD,KAAK,IAAME,KAAM;IAAC;IAAU;IAAQ;IAAY;GAAY,GAAYjB,EAAI,IAAIiB,GAAgBG,CAAK;EACvG;CACF;AAGF"}
|
|
1
|
+
{"version":3,"file":"main.js","names":["readFileSync","writeFileSync","join","Menu","app","ipcMain","nativeTheme","screen","shell","systemPreferences","IPC","BASELINE","resolve","o","boundsFile","name","readBounds","b","restoredBounds","a","m3WindowOptions","options","saved","x","y","width","height","mac","windows","registered","accent","c","stateOf","win","entry","sender","register","w","action","colors","isHex","key","theme","value","count","menus","original","click","id","item","i","own","m","edit","EDIT","EXTERNAL","setupM3Window","send","events","ev","save","timer","later","url","e","here","other"],"sources":["../src/main.ts"],"sourcesContent":["/**\n * `@m3ui-vue/electron/main`: the main-process half. `m3WindowOptions()` gives the BrowserWindow options for the mode\n * you pick, `setupM3Window()` wires that window to MTitleBar (its state, its buttons, the native overlay's colors) and\n * to `useElectronWindow()` (native theme, accent color, taskbar progress and badge, attention), remembers its bounds\n * and sends outside links to the browser.\n *\n * ```ts\n * const m3 = { controls: 'native' } as const\n * const win = new BrowserWindow({ width: 1100, height: 720, ...m3WindowOptions(m3), webPreferences: { preload } })\n * setupM3Window(win, m3)\n * ```\n */\nimport { readFileSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { app, BrowserWindow, ipcMain, Menu, nativeTheme, screen, shell, systemPreferences, type BrowserWindowConstructorOptions, type IpcMainEvent, type IpcMainInvokeEvent, type MenuItemConstructorOptions, type Rectangle, type WebContents } from 'electron'\nimport { DEFAULT_TITLE_BAR_HEIGHT, IPC, type M3NativeMenu, type M3NativeMenuItem, type M3Controls, type M3NativeTheme, type M3OverlayColors, type M3WindowAction, type M3WindowInfo, type M3WindowState } from './shared'\n\nexport type { M3Controls, M3NativeTheme, M3OverlayColors, M3WindowAction, M3WindowInfo, M3WindowState } from './shared'\n\nexport interface M3WindowOptions {\n /** `'native'` (default): the system's buttons, recolored from the theme. `'custom'`: frameless, MTitleBar draws them */\n controls?: M3Controls\n /** Title bar height in px (default 40) */\n titleBarHeight?: number\n /**\n * The native buttons' colors before the page has loaded (MTitleBar sends the real ones from the theme as soon as\n * it mounts). Defaults to the M3 baseline light surface\n */\n overlay?: Partial<M3OverlayColors>\n /**\n * Reopen the window with the size, position and maximized state it closed with (kept in the app's userData\n * folder). `true`, or a name per window when the app has several. Spread `m3WindowOptions()` after your own\n * width/height so the remembered ones win\n */\n rememberBounds?: boolean | string\n /**\n * Open http(s) and mailto links that would leave the app (`target=\"_blank\"`, `window.open`, a link to another\n * site) in the system browser instead of a new Electron window. Default true\n */\n externalLinks?: boolean\n}\n\ninterface Resolved {\n controls: M3Controls\n titleBarHeight: number\n overlay: M3OverlayColors\n bounds: string | null\n externalLinks: boolean\n}\n\nconst BASELINE: M3OverlayColors = { color: '#fef7ff', symbolColor: '#49454f' }\n\nfunction resolve(o: M3WindowOptions = {}): Resolved {\n return {\n controls: o.controls === 'custom' ? 'custom' : 'native',\n titleBarHeight: Math.max(24, Math.round(o.titleBarHeight ?? DEFAULT_TITLE_BAR_HEIGHT)),\n overlay: { ...BASELINE, ...o.overlay },\n bounds: o.rememberBounds ? `m3-window${typeof o.rememberBounds === 'string' ? `-${o.rememberBounds.replace(/[^\\w-]/g, '_')}` : ''}.json` : null,\n externalLinks: o.externalLinks !== false,\n }\n}\n\n// ── Remembered bounds ───────────────────────────────────────────────────────────────────────────────────────────\ninterface Saved extends Rectangle { maximized: boolean }\nconst boundsFile = (name: string) => join(app.getPath('userData'), name)\n\nfunction readBounds(name: string): Saved | null {\n try {\n const b = JSON.parse(readFileSync(boundsFile(name), 'utf8')) as Saved\n if (![b.x, b.y, b.width, b.height].every(Number.isFinite)) return null\n return b\n } catch {\n return null\n }\n}\n\n/** The saved bounds, without the position when no screen shows enough of the window anymore (a monitor unplugged) */\nfunction restoredBounds(name: string): Partial<Rectangle> & { maximized?: boolean } {\n const b = readBounds(name)\n if (!b) return {}\n const visible = screen.getAllDisplays().some(({ workArea: a }) =>\n Math.min(b.x + b.width, a.x + a.width) - Math.max(b.x, a.x) >= 100 && Math.min(b.y + 40, a.y + a.height) - Math.max(b.y, a.y) >= 20)\n return visible ? b : { width: b.width, height: b.height, maximized: b.maximized }\n}\n\n/** The BrowserWindow options for a mode: spread them into `new BrowserWindow({ ... })` */\nexport function m3WindowOptions(options: M3WindowOptions = {}): BrowserWindowConstructorOptions {\n const o = resolve(options)\n let saved: BrowserWindowConstructorOptions = {}\n if (o.bounds) {\n const { x, y, width, height } = restoredBounds(o.bounds)\n saved = { ...(width ? { width, height } : {}), ...(x != null ? { x, y } : {}) }\n }\n if (o.controls === 'custom') return { ...saved, frame: false }\n const mac = process.platform === 'darwin'\n return {\n ...saved,\n titleBarStyle: 'hidden',\n // macOS keeps its traffic lights (`true` only turns on the overlay's CSS env() area); elsewhere the system's\n // buttons are drawn over the page in these colors, at the bar's height\n titleBarOverlay: mac ? true : { ...o.overlay, height: o.titleBarHeight },\n // Traffic lights (12px, 20px apart) centered in the bar\n ...(mac ? { trafficLightPosition: { x: 14, y: Math.round((o.titleBarHeight - 16) / 2) } } : {}),\n }\n}\n\n// One handler per channel for the whole app; each message finds its window's settings by the sender\nconst windows = new Map<number, { win: BrowserWindow; o: Resolved; overlay: string }>()\nlet registered = false\n\nconst accent = (): string | null => {\n try {\n const c = process.platform === 'win32' || process.platform === 'darwin' ? systemPreferences.getAccentColor() : ''\n return /^[0-9a-f]{6}/i.test(c) ? `#${c.slice(0, 6).toLowerCase()}` : null\n } catch {\n return null\n }\n}\n\nconst stateOf = (win: BrowserWindow): M3WindowState => ({\n maximized: win.isMaximized(),\n fullscreen: win.isFullScreen(),\n focused: win.isFocused(),\n})\n\nfunction entry(sender: WebContents) {\n return windows.get(sender.id)\n}\n\nfunction register() {\n if (registered) return\n registered = true\n ipcMain.handle(IPC.info, (e: IpcMainInvokeEvent): M3WindowInfo | null => {\n const w = entry(e.sender)\n if (!w) return null\n return { controls: w.o.controls, platform: process.platform, titleBarHeight: w.o.titleBarHeight, state: stateOf(w.win), accentColor: accent() }\n })\n ipcMain.on(IPC.action, (e: IpcMainEvent, action: M3WindowAction) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed()) return\n if (action === 'minimize') w.win.minimize()\n else if (action === 'toggle-maximize') {\n if (w.win.isFullScreen()) w.win.setFullScreen(false)\n else if (w.win.isMaximized()) w.win.unmaximize()\n else w.win.maximize()\n } else if (action === 'close') w.win.close()\n })\n ipcMain.on(IPC.overlay, (e: IpcMainEvent, colors: M3OverlayColors) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed() || w.o.controls !== 'native' || process.platform === 'darwin') return\n if (!isHex(colors?.color) || !isHex(colors?.symbolColor)) return\n // The renderer sends every frame of a theme transition: skip what wouldn't change anything\n const key = `${colors.color}|${colors.symbolColor}`\n if (key === w.overlay) return\n w.overlay = key\n w.win.setTitleBarOverlay({ color: colors.color, symbolColor: colors.symbolColor, height: w.o.titleBarHeight })\n })\n // The app's theme choice drives the native UI too (dialogs, context menus, scrollbars, macOS's frame). The\n // choice, not the result: 'system' must stay 'system', or prefers-color-scheme would follow the app back\n ipcMain.on(IPC.theme, (e: IpcMainEvent, theme: M3NativeTheme) => {\n if (!entry(e.sender) || !['light', 'dark', 'system'].includes(theme)) return\n if (nativeTheme.themeSource !== theme) nativeTheme.themeSource = theme\n })\n ipcMain.on(IPC.progress, (e: IpcMainEvent, value: number | 'indeterminate' | null) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed()) return\n if (value === 'indeterminate') w.win.setProgressBar(2, { mode: 'indeterminate' })\n else if (typeof value === 'number' && Number.isFinite(value)) w.win.setProgressBar(Math.min(1, Math.max(0, value)))\n else w.win.setProgressBar(-1)\n })\n ipcMain.on(IPC.badge, (e: IpcMainEvent, count: number) => {\n if (!entry(e.sender)) return\n app.setBadgeCount(Math.max(0, Math.floor(Number(count) || 0)))\n })\n ipcMain.on(IPC.attention, (e: IpcMainEvent) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed() || w.win.isFocused()) return\n if (process.platform === 'darwin') app.dock?.bounce('informational')\n else {\n w.win.flashFrame(true)\n w.win.once('focus', () => { if (!w.win.isDestroyed()) w.win.flashFrame(false) })\n }\n })\n // The page's menus in macOS's menu bar (native controls: the page has no bar of its own for them there). The app\n // menu comes first, and a standard Edit menu unless the page has one: it's what makes ⌘C/⌘V work in the page\n ipcMain.on(IPC.menu, (e: IpcMainEvent, menus: M3NativeMenu[] | null) => {\n if (!entry(e.sender) || process.platform !== 'darwin') return\n original ??= { menu: Menu.getApplicationMenu() }\n if (!Array.isArray(menus)) return Menu.setApplicationMenu(original.menu)\n const sender = e.sender\n const click = (id: number) => () => { if (!sender.isDestroyed()) sender.send(IPC.menuClick, id) }\n const item = (i: M3NativeMenuItem): MenuItemConstructorOptions =>\n i.type === 'separator' ? { type: 'separator' }\n : i.type === 'submenu' ? { label: i.label, enabled: i.enabled, submenu: i.items.map(item) }\n : { type: i.type, label: i.label, enabled: i.enabled, checked: i.checked, accelerator: i.accelerator, click: click(i.id) }\n const own = menus.map((m): MenuItemConstructorOptions => ({ label: m.label, enabled: m.enabled, submenu: m.items.map(item) }))\n const edit = menus.some((m) => EDIT.test(m.label.trim())) ? [] : [{ role: 'editMenu' } as const]\n Menu.setApplicationMenu(Menu.buildFromTemplate([{ role: 'appMenu' }, ...edit, ...own]))\n })\n // Accent color changes (Windows sends them; macOS asks for a relaunch of most apps anyway)\n const sendAccent = () => { for (const { win } of windows.values()) if (!win.isDestroyed()) win.webContents.send(IPC.accent, accent()) }\n systemPreferences.on?.('accent-color-changed', sendAccent)\n}\n\nconst EXTERNAL = /^(https?|mailto):/i\n// An Edit menu of the page's own, in the languages the library ships\nconst EDIT = /^(edit|editar|édition|edition|bearbeiten|modifica|編集|编辑|編輯|편집|تحرير|edycja)$/i\n// The application menu before the page's first menus, put back when they go\nlet original: { menu: Menu | null } | undefined\n\nconst isHex = (c: unknown): c is string => typeof c === 'string' && /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(c)\n\n/**\n * Connects `win` to MTitleBar: answers its questions, runs its buttons, sends it the window's state and recolors the\n * native buttons with the theme. Pass the same options as to `m3WindowOptions()`. Returns a function that undoes it\n * (it's undone on its own when the window closes).\n */\nexport function setupM3Window(win: BrowserWindow, options: M3WindowOptions = {}): () => void {\n register()\n const o = resolve(options)\n const id = win.webContents.id\n windows.set(id, { win, o, overlay: '' })\n const send = () => { if (!win.isDestroyed()) win.webContents.send(IPC.state, stateOf(win)) }\n const events = ['maximize', 'unmaximize', 'enter-full-screen', 'leave-full-screen', 'focus', 'blur', 'restore'] as const\n for (const ev of events) win.on(ev as 'maximize', send)\n\n // Bounds: the size it had before being maximized (getNormalBounds), saved after moves and resizes settle\n let save = () => {}\n let timer: ReturnType<typeof setTimeout> | undefined\n const later = () => { clearTimeout(timer); timer = setTimeout(save, 400) }\n if (o.bounds) {\n const name = o.bounds\n if (readBounds(name)?.maximized) win.maximize()\n save = () => {\n if (win.isDestroyed() || win.isMinimized() || win.isFullScreen()) return\n try {\n writeFileSync(boundsFile(name), JSON.stringify({ ...win.getNormalBounds(), maximized: win.isMaximized() }))\n } catch { /* a read-only profile: nothing to remember */ }\n }\n for (const ev of ['resize', 'move', 'maximize', 'unmaximize'] as const) win.on(ev as 'resize', later)\n win.on('close', () => { clearTimeout(timer); save() })\n }\n\n // Links that leave the app open in the browser\n if (o.externalLinks) {\n win.webContents.setWindowOpenHandler(({ url }) => {\n if (EXTERNAL.test(url)) void shell.openExternal(url)\n return { action: 'deny' }\n })\n win.webContents.on('will-navigate', (e, url) => {\n const here = win.webContents.getURL()\n let other = false\n try { other = new URL(url).origin !== new URL(here).origin } catch { /* about:blank and the like */ }\n if (EXTERNAL.test(url) && other) {\n e.preventDefault()\n void shell.openExternal(url)\n }\n })\n }\n\n const dispose = () => {\n windows.delete(id)\n clearTimeout(timer)\n if (!win.isDestroyed()) {\n for (const ev of events) win.off(ev as 'maximize', send)\n for (const ev of ['resize', 'move', 'maximize', 'unmaximize'] as const) win.off(ev as 'resize', later)\n }\n }\n win.once('closed', () => { windows.delete(id); clearTimeout(timer) })\n return dispose\n}\n"],"mappings":";;;;;AAkDA,IAAMW,IAA4B;CAAE,OAAO;CAAW,aAAa;AAAU;AAE7E,SAASC,EAAQC,IAAqB,CAAC,GAAa;CAClD,OAAO;EACL,UAAUA,EAAE,aAAa,WAAW,WAAW;EAC/C,gBAAgB,KAAK,IAAI,IAAI,KAAK,MAAMA,EAAE,kBAAA,EAA0C,CAAC;EACrF,SAAS;GAAE,GAAGF;GAAU,GAAGE,EAAE;EAAQ;EACrC,QAAQA,EAAE,iBAAiB,YAAY,OAAOA,EAAE,kBAAmB,WAAW,IAAIA,EAAE,eAAe,QAAQ,WAAW,GAAG,MAAM,GAAG,SAAS;EAC3I,eAAeA,EAAE,kBAAkB;CACrC;AACF;AAIA,IAAMC,KAAcC,MAAiBb,EAAKE,EAAI,QAAQ,UAAU,GAAGW,CAAI;AAEvE,SAASC,EAAWD,GAA4B;CAC9C,IAAI;EACF,IAAME,IAAI,KAAK,MAAMjB,EAAac,EAAWC,CAAI,GAAG,MAAM,CAAC;EAE3D,OADK;GAACE,EAAE;GAAGA,EAAE;GAAGA,EAAE;GAAOA,EAAE;EAAM,CAAC,CAAC,MAAM,OAAO,QAAQ,IACjDA,IAD2D;CAEpE,QAAQ;EACN,OAAO;CACT;AACF;AAGA,SAASC,EAAeH,GAA4D;CAClF,IAAME,IAAID,EAAWD,CAAI;CAIzB,OAHKE,IACWV,EAAO,eAAe,CAAC,CAAC,MAAM,EAAE,UAAUY,QACxD,KAAK,IAAIF,EAAE,IAAIA,EAAE,OAAOE,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GD,MAAQ;EAC9C,IAAME,IAAOhC,EAAI,YAAY,OAAO,GAChCiC,IAAQ;EACZ,IAAI;GAAEA,IAAQ,IAAI,IAAIH,CAAG,CAAC,CAAC,WAAW,IAAI,IAAIE,CAAI,CAAC,CAAC;EAAO,QAAQ,CAAiC;EAChGV,EAAS,KAAKQ,CAAG,KAAKG,MACxBF,EAAE,eAAe,GACZxD,EAAM,aAAauD,CAAG;CAE/B,CAAC,IAWH9B,EAAI,KAAK,gBAAgB;EAAEL,EAAQ,OAAOoB,CAAE,GAAG,aAAaa,CAAK;CAAE,CAAC,SAR9C;EAGpB,IAFAjC,EAAQ,OAAOoB,CAAE,GACjB,aAAaa,CAAK,GACd,CAAC5B,EAAI,YAAY,GAAG;GACtB,KAAK,IAAM0B,KAAMD,GAAQzB,EAAI,IAAI0B,GAAkBF,CAAI;GACvD,KAAK,IAAME,KAAM;IAAC;IAAU;IAAQ;IAAY;GAAY,GAAY1B,EAAI,IAAI0B,GAAgBG,CAAK;EACvG;CACF;AAGF"}
|
package/dist/preload.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("electron");var t={info:`m3ui:info`,state:`m3ui:state`,action:`m3ui:action`,overlay:`m3ui:overlay`,theme:`m3ui:theme`,progress:`m3ui:progress`,badge:`m3ui:badge`,attention:`m3ui:attention`,accent:`m3ui:accent`},n=`m3ui`;function r(){return{info:()=>e.ipcRenderer.invoke(t.info),onState(n){let r=(e,t)=>n(t);return e.ipcRenderer.on(t.state,r),()=>{e.ipcRenderer.removeListener(t.state,r)}},action:n=>e.ipcRenderer.send(t.action,n),setOverlay:n=>e.ipcRenderer.send(t.overlay,{color:n.color,symbolColor:n.symbolColor}),setTheme:n=>e.ipcRenderer.send(t.theme,n),setProgress:n=>e.ipcRenderer.send(t.progress,n),setBadge:n=>e.ipcRenderer.send(t.badge,n),attention:()=>e.ipcRenderer.send(t.attention),onAccent(n){let r=(e,t)=>n(t);return e.ipcRenderer.on(t.accent,r),()=>{e.ipcRenderer.removeListener(t.accent,r)}}}}exports._BRIDGE_KEY=n,exports._IPC=t,exports.createM3Bridge=r,exports.exposeM3UI=function(){let t=r();process.contextIsolated?e.contextBridge.exposeInMainWorld(n,t):globalThis[n]=t};
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("electron");var t={info:`m3ui:info`,state:`m3ui:state`,action:`m3ui:action`,overlay:`m3ui:overlay`,theme:`m3ui:theme`,progress:`m3ui:progress`,badge:`m3ui:badge`,attention:`m3ui:attention`,accent:`m3ui:accent`,menu:`m3ui:menu`,menuClick:`m3ui:menu-click`},n=`m3ui`;function r(){return{info:()=>e.ipcRenderer.invoke(t.info),onState(n){let r=(e,t)=>n(t);return e.ipcRenderer.on(t.state,r),()=>{e.ipcRenderer.removeListener(t.state,r)}},action:n=>e.ipcRenderer.send(t.action,n),setOverlay:n=>e.ipcRenderer.send(t.overlay,{color:n.color,symbolColor:n.symbolColor}),setTheme:n=>e.ipcRenderer.send(t.theme,n),setProgress:n=>e.ipcRenderer.send(t.progress,n),setBadge:n=>e.ipcRenderer.send(t.badge,n),attention:()=>e.ipcRenderer.send(t.attention),onAccent(n){let r=(e,t)=>n(t);return e.ipcRenderer.on(t.accent,r),()=>{e.ipcRenderer.removeListener(t.accent,r)}},setMenu:n=>e.ipcRenderer.send(t.menu,n),onMenuClick(n){let r=(e,t)=>n(t);return e.ipcRenderer.on(t.menuClick,r),()=>{e.ipcRenderer.removeListener(t.menuClick,r)}}}}exports._BRIDGE_KEY=n,exports._IPC=t,exports.createM3Bridge=r,exports.exposeM3UI=function(){let t=r();process.contextIsolated?e.contextBridge.exposeInMainWorld(n,t):globalThis[n]=t};
|
|
2
2
|
//# sourceMappingURL=preload.cjs.map
|
package/dist/preload.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preload.cjs","names":["ipcRenderer","contextBridge","electron","IPC","BRIDGE_KEY","createM3Bridge","listener","handler","_e","state","action","colors","theme","value","count","color","bridge"],"sources":["../src/preload.ts"],"sourcesContent":["/**\n * `@m3ui-vue/electron/preload`: exposes the bridge MTitleBar talks through.\n *\n * ```ts\n * // preload.ts (bundled, as electron-vite does)\n * import { exposeM3UI } from '@m3ui-vue/electron/preload'\n * exposeM3UI()\n * ```\n *\n * A sandboxed preload can't `require` npm packages at runtime: bundle it, or paste `createM3Bridge()`'s body (it only\n * needs `ipcRenderer`).\n */\nimport { contextBridge, ipcRenderer, type IpcRendererEvent } from 'electron'\nimport type { M3Bridge, M3NativeTheme, M3OverlayColors, M3WindowAction, M3WindowState } from './shared'\n\n// Copies of shared.ts's constants (a test keeps them equal): with no runtime import, the built preload is one\n// self-contained file, which a sandboxed preload needs (it can only `require('electron')`)\nconst IPC = {\n info: 'm3ui:info',\n state: 'm3ui:state',\n action: 'm3ui:action',\n overlay: 'm3ui:overlay',\n theme: 'm3ui:theme',\n progress: 'm3ui:progress',\n badge: 'm3ui:badge',\n attention: 'm3ui:attention',\n accent: 'm3ui:accent',\n} as const\nconst BRIDGE_KEY = 'm3ui'\nexport { IPC as _IPC, BRIDGE_KEY as _BRIDGE_KEY }\n\nexport type { M3Bridge } from './shared'\n\n/** The bridge itself, to expose it yourself (it must end up as `window.m3ui`) */\nexport function createM3Bridge(): M3Bridge {\n return {\n info: () => ipcRenderer.invoke(IPC.info),\n onState(listener: (state: M3WindowState) => void) {\n const handler = (_e: IpcRendererEvent, state: M3WindowState) => listener(state)\n ipcRenderer.on(IPC.state, handler)\n return () => { ipcRenderer.removeListener(IPC.state, handler) }\n },\n action: (action: M3WindowAction) => ipcRenderer.send(IPC.action, action),\n setOverlay: (colors: M3OverlayColors) => ipcRenderer.send(IPC.overlay, { color: colors.color, symbolColor: colors.symbolColor }),\n setTheme: (theme: M3NativeTheme) => ipcRenderer.send(IPC.theme, theme),\n setProgress: (value: number | 'indeterminate' | null) => ipcRenderer.send(IPC.progress, value),\n setBadge: (count: number) => ipcRenderer.send(IPC.badge, count),\n attention: () => ipcRenderer.send(IPC.attention),\n onAccent(listener: (color: string | null) => void) {\n const handler = (_e: IpcRendererEvent, color: string | null) => listener(color)\n ipcRenderer.on(IPC.accent, handler)\n return () => { ipcRenderer.removeListener(IPC.accent, handler) }\n },\n }\n}\n\n/**\n * Exposes the bridge as `window.m3ui`, where `useElectronWindow()` and MTitleBar look for it. Uses `contextBridge`\n * when context isolation is on (the default), a plain global otherwise.\n */\nexport function exposeM3UI(): void {\n const bridge = createM3Bridge()\n if (process.contextIsolated) contextBridge.exposeInMainWorld(BRIDGE_KEY, bridge)\n else (globalThis as unknown as Record<string, unknown>)[BRIDGE_KEY] = bridge\n}\n"],"mappings":"A,6FAiBA,IAAMG,EAAM,CACV,KAAM,YACN,MAAO,aACP,OAAQ,cACR,QAAS,eACT,MAAO,aACP,SAAU,gBACV,MAAO,aACP,UAAW,iBACX,OAAQ,
|
|
1
|
+
{"version":3,"file":"preload.cjs","names":["ipcRenderer","contextBridge","electron","IPC","BRIDGE_KEY","createM3Bridge","listener","handler","_e","state","action","colors","theme","value","count","color","menus","id","bridge"],"sources":["../src/preload.ts"],"sourcesContent":["/**\n * `@m3ui-vue/electron/preload`: exposes the bridge MTitleBar talks through.\n *\n * ```ts\n * // preload.ts (bundled, as electron-vite does)\n * import { exposeM3UI } from '@m3ui-vue/electron/preload'\n * exposeM3UI()\n * ```\n *\n * A sandboxed preload can't `require` npm packages at runtime: bundle it, or paste `createM3Bridge()`'s body (it only\n * needs `ipcRenderer`).\n */\nimport { contextBridge, ipcRenderer, type IpcRendererEvent } from 'electron'\nimport type { M3Bridge, M3NativeMenu, M3NativeTheme, M3OverlayColors, M3WindowAction, M3WindowState } from './shared'\n\n// Copies of shared.ts's constants (a test keeps them equal): with no runtime import, the built preload is one\n// self-contained file, which a sandboxed preload needs (it can only `require('electron')`)\nconst IPC = {\n info: 'm3ui:info',\n state: 'm3ui:state',\n action: 'm3ui:action',\n overlay: 'm3ui:overlay',\n theme: 'm3ui:theme',\n progress: 'm3ui:progress',\n badge: 'm3ui:badge',\n attention: 'm3ui:attention',\n accent: 'm3ui:accent',\n menu: 'm3ui:menu',\n menuClick: 'm3ui:menu-click',\n} as const\nconst BRIDGE_KEY = 'm3ui'\nexport { IPC as _IPC, BRIDGE_KEY as _BRIDGE_KEY }\n\nexport type { M3Bridge } from './shared'\n\n/** The bridge itself, to expose it yourself (it must end up as `window.m3ui`) */\nexport function createM3Bridge(): M3Bridge {\n return {\n info: () => ipcRenderer.invoke(IPC.info),\n onState(listener: (state: M3WindowState) => void) {\n const handler = (_e: IpcRendererEvent, state: M3WindowState) => listener(state)\n ipcRenderer.on(IPC.state, handler)\n return () => { ipcRenderer.removeListener(IPC.state, handler) }\n },\n action: (action: M3WindowAction) => ipcRenderer.send(IPC.action, action),\n setOverlay: (colors: M3OverlayColors) => ipcRenderer.send(IPC.overlay, { color: colors.color, symbolColor: colors.symbolColor }),\n setTheme: (theme: M3NativeTheme) => ipcRenderer.send(IPC.theme, theme),\n setProgress: (value: number | 'indeterminate' | null) => ipcRenderer.send(IPC.progress, value),\n setBadge: (count: number) => ipcRenderer.send(IPC.badge, count),\n attention: () => ipcRenderer.send(IPC.attention),\n onAccent(listener: (color: string | null) => void) {\n const handler = (_e: IpcRendererEvent, color: string | null) => listener(color)\n ipcRenderer.on(IPC.accent, handler)\n return () => { ipcRenderer.removeListener(IPC.accent, handler) }\n },\n setMenu: (menus: M3NativeMenu[] | null) => ipcRenderer.send(IPC.menu, menus),\n onMenuClick(listener: (id: number) => void) {\n const handler = (_e: IpcRendererEvent, id: number) => listener(id)\n ipcRenderer.on(IPC.menuClick, handler)\n return () => { ipcRenderer.removeListener(IPC.menuClick, handler) }\n },\n }\n}\n\n/**\n * Exposes the bridge as `window.m3ui`, where `useElectronWindow()` and MTitleBar look for it. Uses `contextBridge`\n * when context isolation is on (the default), a plain global otherwise.\n */\nexport function exposeM3UI(): void {\n const bridge = createM3Bridge()\n if (process.contextIsolated) contextBridge.exposeInMainWorld(BRIDGE_KEY, bridge)\n else (globalThis as unknown as Record<string, unknown>)[BRIDGE_KEY] = bridge\n}\n"],"mappings":"A,6FAiBA,IAAMG,EAAM,CACV,KAAM,YACN,MAAO,aACP,OAAQ,cACR,QAAS,eACT,MAAO,aACP,SAAU,gBACV,MAAO,aACP,UAAW,iBACX,OAAQ,cACR,KAAM,YACN,UAAW,iBACb,EACMC,EAAa,OAMnB,SAAgBC,GAA2B,CACzC,MAAO,CACL,SAAYL,EAAAA,YAAY,OAAOG,EAAI,IAAI,EACvC,QAAQG,EAA0C,CAChD,IAAMC,GAAWC,EAAsBC,IAAyBH,EAASG,CAAK,EAE9E,OADAT,EAAAA,YAAY,GAAGG,EAAI,MAAOI,CAAO,MACpB,CAAEP,EAAAA,YAAY,eAAeG,EAAI,MAAOI,CAAO,CAAE,CAChE,EACA,OAASG,GAA2BV,EAAAA,YAAY,KAAKG,EAAI,OAAQO,CAAM,EACvE,WAAaC,GAA4BX,EAAAA,YAAY,KAAKG,EAAI,QAAS,CAAE,MAAOQ,EAAO,MAAO,YAAaA,EAAO,WAAY,CAAC,EAC/H,SAAWC,GAAyBZ,EAAAA,YAAY,KAAKG,EAAI,MAAOS,CAAK,EACrE,YAAcC,GAA2Cb,EAAAA,YAAY,KAAKG,EAAI,SAAUU,CAAK,EAC7F,SAAWC,GAAkBd,EAAAA,YAAY,KAAKG,EAAI,MAAOW,CAAK,EAC9D,cAAiBd,EAAAA,YAAY,KAAKG,EAAI,SAAS,EAC/C,SAASG,EAA0C,CACjD,IAAMC,GAAWC,EAAsBO,IAAyBT,EAASS,CAAK,EAE9E,OADAf,EAAAA,YAAY,GAAGG,EAAI,OAAQI,CAAO,MACrB,CAAEP,EAAAA,YAAY,eAAeG,EAAI,OAAQI,CAAO,CAAE,CACjE,EACA,QAAUS,GAAiChB,EAAAA,YAAY,KAAKG,EAAI,KAAMa,CAAK,EAC3E,YAAYV,EAAgC,CAC1C,IAAMC,GAAWC,EAAsBS,IAAeX,EAASW,CAAE,EAEjE,OADAjB,EAAAA,YAAY,GAAGG,EAAI,UAAWI,CAAO,MACxB,CAAEP,EAAAA,YAAY,eAAeG,EAAI,UAAWI,CAAO,CAAE,CACpE,CACF,CACF,C,iFAMA,UAAmC,CACjC,IAAMW,EAASb,EAAe,EAC1B,QAAQ,gBAAiBJ,EAAAA,cAAc,kBAAkBG,EAAYc,CAAM,EACzE,WAAkDd,GAAcc,CACxE"}
|
package/dist/preload.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ declare const IPC: {
|
|
|
9
9
|
readonly badge: "m3ui:badge";
|
|
10
10
|
readonly attention: "m3ui:attention";
|
|
11
11
|
readonly accent: "m3ui:accent";
|
|
12
|
+
readonly menu: "m3ui:menu";
|
|
13
|
+
readonly menuClick: "m3ui:menu-click";
|
|
12
14
|
};
|
|
13
15
|
declare const BRIDGE_KEY = "m3ui";
|
|
14
16
|
export { IPC as _IPC, BRIDGE_KEY as _BRIDGE_KEY };
|
package/dist/preload.js
CHANGED
|
@@ -9,7 +9,9 @@ var n = {
|
|
|
9
9
|
progress: "m3ui:progress",
|
|
10
10
|
badge: "m3ui:badge",
|
|
11
11
|
attention: "m3ui:attention",
|
|
12
|
-
accent: "m3ui:accent"
|
|
12
|
+
accent: "m3ui:accent",
|
|
13
|
+
menu: "m3ui:menu",
|
|
14
|
+
menuClick: "m3ui:menu-click"
|
|
13
15
|
}, r = "m3ui";
|
|
14
16
|
function i() {
|
|
15
17
|
return {
|
|
@@ -34,6 +36,13 @@ function i() {
|
|
|
34
36
|
return t.on(n.accent, r), () => {
|
|
35
37
|
t.removeListener(n.accent, r);
|
|
36
38
|
};
|
|
39
|
+
},
|
|
40
|
+
setMenu: (e) => t.send(n.menu, e),
|
|
41
|
+
onMenuClick(e) {
|
|
42
|
+
let r = (t, n) => e(n);
|
|
43
|
+
return t.on(n.menuClick, r), () => {
|
|
44
|
+
t.removeListener(n.menuClick, r);
|
|
45
|
+
};
|
|
37
46
|
}
|
|
38
47
|
};
|
|
39
48
|
}
|
package/dist/preload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preload.js","names":["contextBridge","ipcRenderer","IPC","BRIDGE_KEY","createM3Bridge","listener","handler","_e","state","action","colors","theme","value","count","color","exposeM3UI","bridge"],"sources":["../src/preload.ts"],"sourcesContent":["/**\n * `@m3ui-vue/electron/preload`: exposes the bridge MTitleBar talks through.\n *\n * ```ts\n * // preload.ts (bundled, as electron-vite does)\n * import { exposeM3UI } from '@m3ui-vue/electron/preload'\n * exposeM3UI()\n * ```\n *\n * A sandboxed preload can't `require` npm packages at runtime: bundle it, or paste `createM3Bridge()`'s body (it only\n * needs `ipcRenderer`).\n */\nimport { contextBridge, ipcRenderer, type IpcRendererEvent } from 'electron'\nimport type { M3Bridge, M3NativeTheme, M3OverlayColors, M3WindowAction, M3WindowState } from './shared'\n\n// Copies of shared.ts's constants (a test keeps them equal): with no runtime import, the built preload is one\n// self-contained file, which a sandboxed preload needs (it can only `require('electron')`)\nconst IPC = {\n info: 'm3ui:info',\n state: 'm3ui:state',\n action: 'm3ui:action',\n overlay: 'm3ui:overlay',\n theme: 'm3ui:theme',\n progress: 'm3ui:progress',\n badge: 'm3ui:badge',\n attention: 'm3ui:attention',\n accent: 'm3ui:accent',\n} as const\nconst BRIDGE_KEY = 'm3ui'\nexport { IPC as _IPC, BRIDGE_KEY as _BRIDGE_KEY }\n\nexport type { M3Bridge } from './shared'\n\n/** The bridge itself, to expose it yourself (it must end up as `window.m3ui`) */\nexport function createM3Bridge(): M3Bridge {\n return {\n info: () => ipcRenderer.invoke(IPC.info),\n onState(listener: (state: M3WindowState) => void) {\n const handler = (_e: IpcRendererEvent, state: M3WindowState) => listener(state)\n ipcRenderer.on(IPC.state, handler)\n return () => { ipcRenderer.removeListener(IPC.state, handler) }\n },\n action: (action: M3WindowAction) => ipcRenderer.send(IPC.action, action),\n setOverlay: (colors: M3OverlayColors) => ipcRenderer.send(IPC.overlay, { color: colors.color, symbolColor: colors.symbolColor }),\n setTheme: (theme: M3NativeTheme) => ipcRenderer.send(IPC.theme, theme),\n setProgress: (value: number | 'indeterminate' | null) => ipcRenderer.send(IPC.progress, value),\n setBadge: (count: number) => ipcRenderer.send(IPC.badge, count),\n attention: () => ipcRenderer.send(IPC.attention),\n onAccent(listener: (color: string | null) => void) {\n const handler = (_e: IpcRendererEvent, color: string | null) => listener(color)\n ipcRenderer.on(IPC.accent, handler)\n return () => { ipcRenderer.removeListener(IPC.accent, handler) }\n },\n }\n}\n\n/**\n * Exposes the bridge as `window.m3ui`, where `useElectronWindow()` and MTitleBar look for it. Uses `contextBridge`\n * when context isolation is on (the default), a plain global otherwise.\n */\nexport function exposeM3UI(): void {\n const bridge = createM3Bridge()\n if (process.contextIsolated) contextBridge.exposeInMainWorld(BRIDGE_KEY, bridge)\n else (globalThis as unknown as Record<string, unknown>)[BRIDGE_KEY] = bridge\n}\n"],"mappings":";;AAiBA,IAAME,IAAM;CACV,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,OAAO;CACP,UAAU;CACV,OAAO;CACP,WAAW;CACX,QAAQ;
|
|
1
|
+
{"version":3,"file":"preload.js","names":["contextBridge","ipcRenderer","IPC","BRIDGE_KEY","createM3Bridge","listener","handler","_e","state","action","colors","theme","value","count","color","menus","id","exposeM3UI","bridge"],"sources":["../src/preload.ts"],"sourcesContent":["/**\n * `@m3ui-vue/electron/preload`: exposes the bridge MTitleBar talks through.\n *\n * ```ts\n * // preload.ts (bundled, as electron-vite does)\n * import { exposeM3UI } from '@m3ui-vue/electron/preload'\n * exposeM3UI()\n * ```\n *\n * A sandboxed preload can't `require` npm packages at runtime: bundle it, or paste `createM3Bridge()`'s body (it only\n * needs `ipcRenderer`).\n */\nimport { contextBridge, ipcRenderer, type IpcRendererEvent } from 'electron'\nimport type { M3Bridge, M3NativeMenu, M3NativeTheme, M3OverlayColors, M3WindowAction, M3WindowState } from './shared'\n\n// Copies of shared.ts's constants (a test keeps them equal): with no runtime import, the built preload is one\n// self-contained file, which a sandboxed preload needs (it can only `require('electron')`)\nconst IPC = {\n info: 'm3ui:info',\n state: 'm3ui:state',\n action: 'm3ui:action',\n overlay: 'm3ui:overlay',\n theme: 'm3ui:theme',\n progress: 'm3ui:progress',\n badge: 'm3ui:badge',\n attention: 'm3ui:attention',\n accent: 'm3ui:accent',\n menu: 'm3ui:menu',\n menuClick: 'm3ui:menu-click',\n} as const\nconst BRIDGE_KEY = 'm3ui'\nexport { IPC as _IPC, BRIDGE_KEY as _BRIDGE_KEY }\n\nexport type { M3Bridge } from './shared'\n\n/** The bridge itself, to expose it yourself (it must end up as `window.m3ui`) */\nexport function createM3Bridge(): M3Bridge {\n return {\n info: () => ipcRenderer.invoke(IPC.info),\n onState(listener: (state: M3WindowState) => void) {\n const handler = (_e: IpcRendererEvent, state: M3WindowState) => listener(state)\n ipcRenderer.on(IPC.state, handler)\n return () => { ipcRenderer.removeListener(IPC.state, handler) }\n },\n action: (action: M3WindowAction) => ipcRenderer.send(IPC.action, action),\n setOverlay: (colors: M3OverlayColors) => ipcRenderer.send(IPC.overlay, { color: colors.color, symbolColor: colors.symbolColor }),\n setTheme: (theme: M3NativeTheme) => ipcRenderer.send(IPC.theme, theme),\n setProgress: (value: number | 'indeterminate' | null) => ipcRenderer.send(IPC.progress, value),\n setBadge: (count: number) => ipcRenderer.send(IPC.badge, count),\n attention: () => ipcRenderer.send(IPC.attention),\n onAccent(listener: (color: string | null) => void) {\n const handler = (_e: IpcRendererEvent, color: string | null) => listener(color)\n ipcRenderer.on(IPC.accent, handler)\n return () => { ipcRenderer.removeListener(IPC.accent, handler) }\n },\n setMenu: (menus: M3NativeMenu[] | null) => ipcRenderer.send(IPC.menu, menus),\n onMenuClick(listener: (id: number) => void) {\n const handler = (_e: IpcRendererEvent, id: number) => listener(id)\n ipcRenderer.on(IPC.menuClick, handler)\n return () => { ipcRenderer.removeListener(IPC.menuClick, handler) }\n },\n }\n}\n\n/**\n * Exposes the bridge as `window.m3ui`, where `useElectronWindow()` and MTitleBar look for it. Uses `contextBridge`\n * when context isolation is on (the default), a plain global otherwise.\n */\nexport function exposeM3UI(): void {\n const bridge = createM3Bridge()\n if (process.contextIsolated) contextBridge.exposeInMainWorld(BRIDGE_KEY, bridge)\n else (globalThis as unknown as Record<string, unknown>)[BRIDGE_KEY] = bridge\n}\n"],"mappings":";;AAiBA,IAAME,IAAM;CACV,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,OAAO;CACP,UAAU;CACV,OAAO;CACP,WAAW;CACX,QAAQ;CACR,MAAM;CACN,WAAW;AACb,GACMC,IAAa;AAMnB,SAAgBC,IAA2B;CACzC,OAAO;EACL,YAAYH,EAAY,OAAOC,EAAI,IAAI;EACvC,QAAQG,GAA0C;GAChD,IAAMC,KAAWC,GAAsBC,MAAyBH,EAASG,CAAK;GAE9E,OADAP,EAAY,GAAGC,EAAI,OAAOI,CAAO,SACpB;IAAEL,EAAY,eAAeC,EAAI,OAAOI,CAAO;GAAE;EAChE;EACA,SAASG,MAA2BR,EAAY,KAAKC,EAAI,QAAQO,CAAM;EACvE,aAAaC,MAA4BT,EAAY,KAAKC,EAAI,SAAS;GAAE,OAAOQ,EAAO;GAAO,aAAaA,EAAO;EAAY,CAAC;EAC/H,WAAWC,MAAyBV,EAAY,KAAKC,EAAI,OAAOS,CAAK;EACrE,cAAcC,MAA2CX,EAAY,KAAKC,EAAI,UAAUU,CAAK;EAC7F,WAAWC,MAAkBZ,EAAY,KAAKC,EAAI,OAAOW,CAAK;EAC9D,iBAAiBZ,EAAY,KAAKC,EAAI,SAAS;EAC/C,SAASG,GAA0C;GACjD,IAAMC,KAAWC,GAAsBO,MAAyBT,EAASS,CAAK;GAE9E,OADAb,EAAY,GAAGC,EAAI,QAAQI,CAAO,SACrB;IAAEL,EAAY,eAAeC,EAAI,QAAQI,CAAO;GAAE;EACjE;EACA,UAAUS,MAAiCd,EAAY,KAAKC,EAAI,MAAMa,CAAK;EAC3E,YAAYV,GAAgC;GAC1C,IAAMC,KAAWC,GAAsBS,MAAeX,EAASW,CAAE;GAEjE,OADAf,EAAY,GAAGC,EAAI,WAAWI,CAAO,SACxB;IAAEL,EAAY,eAAeC,EAAI,WAAWI,CAAO;GAAE;EACpE;CACF;AACF;AAMA,SAAgBW,IAAmB;CACjC,IAAMC,IAASd,EAAe;CAC1B,QAAQ,kBAAiBJ,EAAc,kBAAkBG,GAAYe,CAAM,IACzE,WAAkDf,KAAce;AACxE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MenuBarItem, MenuBarMenu } from '@m3ui-vue/m3ui-vue';
|
|
2
|
+
import type { M3NativeMenu } from '../shared';
|
|
3
|
+
/**
|
|
4
|
+
* MMenuBar's shortcut hint (`'Ctrl+S'`, `'⌘S'`) as an Electron accelerator: Ctrl and ⌘ become `CmdOrCtrl`. A native
|
|
5
|
+
* menu binds it: the key runs the item's `onSelect`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function acceleratorOf(shortcut?: string): string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* The menus as plain data for the main process, and what each id stands for (the item and its menu's index), to run
|
|
10
|
+
* it when main says it was clicked
|
|
11
|
+
*/
|
|
12
|
+
export declare function serializeMenus(menus: MenuBarMenu[]): {
|
|
13
|
+
data: M3NativeMenu[];
|
|
14
|
+
picks: Map<number, [MenuBarItem, number]>;
|
|
15
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ComputedRef, type Ref } from 'vue';
|
|
2
|
-
import { type M3Controls, type M3NativeTheme, type M3OverlayColors } from '../shared';
|
|
2
|
+
import { type M3NativeMenu, type M3Controls, type M3NativeTheme, type M3OverlayColors } from '../shared';
|
|
3
3
|
/**
|
|
4
4
|
* The window MTitleBar sits in, from the renderer: its mode and state (reactive) and its buttons. Outside Electron (or
|
|
5
5
|
* without the preload's bridge) `isElectron` is false, nothing is ever `ready` and the actions do nothing, so the same
|
|
@@ -36,6 +36,12 @@ export interface ElectronWindow {
|
|
|
36
36
|
setBadge(count: number): void;
|
|
37
37
|
/** Flashes the taskbar button / bounces the dock icon until the window gets focus */
|
|
38
38
|
requestAttention(): void;
|
|
39
|
+
/** The preload can set macOS's menu bar (one built before 0.3.0 can't) */
|
|
40
|
+
canSetNativeMenu: boolean;
|
|
41
|
+
/** macOS's menu bar from MTitleBar's `menus` (it does this itself in native mode); `null` puts the app's back */
|
|
42
|
+
setNativeMenu(menus: M3NativeMenu[] | null): void;
|
|
43
|
+
/** Calls `listener` with the id of a native menu item when chosen; returns the unsubscribe */
|
|
44
|
+
onNativeMenuClick(listener: (id: number) => void): () => void;
|
|
39
45
|
}
|
|
40
46
|
export declare function useElectronWindow(): ElectronWindow;
|
|
41
47
|
/** For tests: forget the fetched state */
|
|
@@ -8,8 +8,10 @@ var e = {
|
|
|
8
8
|
progress: "m3ui:progress",
|
|
9
9
|
badge: "m3ui:badge",
|
|
10
10
|
attention: "m3ui:attention",
|
|
11
|
-
accent: "m3ui:accent"
|
|
11
|
+
accent: "m3ui:accent",
|
|
12
|
+
menu: "m3ui:menu",
|
|
13
|
+
menuClick: "m3ui:menu-click"
|
|
12
14
|
}, t = "m3ui";
|
|
13
15
|
export { e as n, t };
|
|
14
16
|
|
|
15
|
-
//# sourceMappingURL=shared-
|
|
17
|
+
//# sourceMappingURL=shared-CmmPhgMH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-CmmPhgMH.js","names":["IPC","BRIDGE_KEY"],"sources":["../src/shared.ts"],"sourcesContent":["/**\n * The contract between the three sides: main (`@m3ui-vue/electron/main`), preload (`/preload`) and the renderer\n * (`@m3ui-vue/electron`). Types and IPC channel names only, no runtime dependency on either side.\n */\n\n/**\n * Who draws the window buttons.\n * - `native`: the system does (`titleBarStyle: 'hidden'` + `titleBarOverlay`): Windows 11 snap layouts, macOS\n * traffic lights, Linux's own buttons; their colors follow the M3 theme live.\n * - `custom`: a frameless window (`frame: false`) and MTitleBar draws M3 buttons (or traffic lights) itself.\n */\nexport type M3Controls = 'native' | 'custom'\n\n/** What the main process says about the window, once, when the renderer asks */\nexport interface M3WindowInfo {\n controls: M3Controls\n /** `process.platform` of the main process: `'darwin'`, `'win32'`, `'linux'`… */\n platform: string\n /** Height of the title bar in px (also the native overlay's height) */\n titleBarHeight: number\n state: M3WindowState\n /** The system accent color as `#rrggbb` (Windows and macOS), or null where there's none */\n accentColor: string | null\n}\n\n/** The window's state, sent again on every change */\nexport interface M3WindowState {\n maximized: boolean\n fullscreen: boolean\n focused: boolean\n}\n\nexport type M3WindowAction = 'minimize' | 'toggle-maximize' | 'close'\n\n/** Colors of the native buttons (Windows/Linux `titleBarOverlay`), as hex */\nexport interface M3OverlayColors {\n color: string\n symbolColor: string\n}\n\n/** What the preload exposes to the page (`window.m3ui` by default) */\nexport interface M3Bridge {\n /** Resolves with the window's mode and state */\n info(): Promise<M3WindowInfo>\n /** Calls `listener` on every state change; returns the unsubscribe */\n onState(listener: (state: M3WindowState) => void): () => void\n action(action: M3WindowAction): void\n /** Recolors the native buttons (ignored with `custom` controls and on macOS, whose traffic lights are fixed) */\n setOverlay(colors: M3OverlayColors): void\n /** Native UI theme (dialogs, context menus, scrollbars, the frame): `nativeTheme.themeSource` */\n setTheme(theme: M3NativeTheme): void\n /** Taskbar / dock progress, 0–1; `null` removes it, `'indeterminate'` for an unknown amount (Windows) */\n setProgress(value: number | 'indeterminate' | null): void\n /** Badge count on the dock / launcher icon (macOS, Linux Unity launchers); 0 removes it */\n setBadge(count: number): void\n /** Flashes the taskbar button / bounces the dock icon until the window gets focus */\n attention(): void\n /** Calls `listener` when the system accent color changes; returns the unsubscribe */\n onAccent(listener: (color: string | null) => void): () => void\n /** The app's menus in macOS's menu bar (ignored elsewhere); `null` puts back the menu the app had */\n setMenu(menus: M3NativeMenu[] | null): void\n /** Calls `listener` with the `id` of a native menu item when it's chosen; returns the unsubscribe */\n onMenuClick(listener: (id: number) => void): () => void\n}\n\n/** A menu of the native menu bar (macOS), as MTitleBar sends its `menus`: plain data, the clicks come back by id */\nexport interface M3NativeMenu {\n label: string\n enabled: boolean\n items: M3NativeMenuItem[]\n}\n\nexport type M3NativeMenuItem =\n | { type: 'separator' }\n | { type: 'submenu'; label: string; enabled: boolean; items: M3NativeMenuItem[] }\n | { type: 'normal' | 'checkbox'; id: number; label: string; enabled: boolean; checked?: boolean; accelerator?: string }\n\nexport type M3NativeTheme = 'light' | 'dark' | 'system'\n\nexport const IPC = {\n info: 'm3ui:info',\n state: 'm3ui:state',\n action: 'm3ui:action',\n overlay: 'm3ui:overlay',\n theme: 'm3ui:theme',\n progress: 'm3ui:progress',\n badge: 'm3ui:badge',\n attention: 'm3ui:attention',\n accent: 'm3ui:accent',\n menu: 'm3ui:menu',\n menuClick: 'm3ui:menu-click',\n} as const\n\n/** The default key the bridge is exposed under (`window.m3ui`) */\nexport const BRIDGE_KEY = 'm3ui'\n\n/** Default title bar height: Windows 11 caption buttons are 32px, GNOME header bars ~46px; 40 sits between */\nexport const DEFAULT_TITLE_BAR_HEIGHT = 40\n"],"mappings":";AA+EA,IAAaA,IAAM;CACjB,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,OAAO;CACP,UAAU;CACV,OAAO;CACP,WAAW;CACX,QAAQ;CACR,MAAM;CACN,WAAW;AACb,GAGaC,IAAa"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e={info:`m3ui:info`,state:`m3ui:state`,action:`m3ui:action`,overlay:`m3ui:overlay`,theme:`m3ui:theme`,progress:`m3ui:progress`,badge:`m3ui:badge`,attention:`m3ui:attention`,accent:`m3ui:accent`,menu:`m3ui:menu`,menuClick:`m3ui:menu-click`},t=`m3ui`;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|
|
2
|
+
//# sourceMappingURL=shared-F3rp76zP.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-F3rp76zP.cjs","names":["IPC","BRIDGE_KEY"],"sources":["../src/shared.ts"],"sourcesContent":["/**\n * The contract between the three sides: main (`@m3ui-vue/electron/main`), preload (`/preload`) and the renderer\n * (`@m3ui-vue/electron`). Types and IPC channel names only, no runtime dependency on either side.\n */\n\n/**\n * Who draws the window buttons.\n * - `native`: the system does (`titleBarStyle: 'hidden'` + `titleBarOverlay`): Windows 11 snap layouts, macOS\n * traffic lights, Linux's own buttons; their colors follow the M3 theme live.\n * - `custom`: a frameless window (`frame: false`) and MTitleBar draws M3 buttons (or traffic lights) itself.\n */\nexport type M3Controls = 'native' | 'custom'\n\n/** What the main process says about the window, once, when the renderer asks */\nexport interface M3WindowInfo {\n controls: M3Controls\n /** `process.platform` of the main process: `'darwin'`, `'win32'`, `'linux'`… */\n platform: string\n /** Height of the title bar in px (also the native overlay's height) */\n titleBarHeight: number\n state: M3WindowState\n /** The system accent color as `#rrggbb` (Windows and macOS), or null where there's none */\n accentColor: string | null\n}\n\n/** The window's state, sent again on every change */\nexport interface M3WindowState {\n maximized: boolean\n fullscreen: boolean\n focused: boolean\n}\n\nexport type M3WindowAction = 'minimize' | 'toggle-maximize' | 'close'\n\n/** Colors of the native buttons (Windows/Linux `titleBarOverlay`), as hex */\nexport interface M3OverlayColors {\n color: string\n symbolColor: string\n}\n\n/** What the preload exposes to the page (`window.m3ui` by default) */\nexport interface M3Bridge {\n /** Resolves with the window's mode and state */\n info(): Promise<M3WindowInfo>\n /** Calls `listener` on every state change; returns the unsubscribe */\n onState(listener: (state: M3WindowState) => void): () => void\n action(action: M3WindowAction): void\n /** Recolors the native buttons (ignored with `custom` controls and on macOS, whose traffic lights are fixed) */\n setOverlay(colors: M3OverlayColors): void\n /** Native UI theme (dialogs, context menus, scrollbars, the frame): `nativeTheme.themeSource` */\n setTheme(theme: M3NativeTheme): void\n /** Taskbar / dock progress, 0–1; `null` removes it, `'indeterminate'` for an unknown amount (Windows) */\n setProgress(value: number | 'indeterminate' | null): void\n /** Badge count on the dock / launcher icon (macOS, Linux Unity launchers); 0 removes it */\n setBadge(count: number): void\n /** Flashes the taskbar button / bounces the dock icon until the window gets focus */\n attention(): void\n /** Calls `listener` when the system accent color changes; returns the unsubscribe */\n onAccent(listener: (color: string | null) => void): () => void\n /** The app's menus in macOS's menu bar (ignored elsewhere); `null` puts back the menu the app had */\n setMenu(menus: M3NativeMenu[] | null): void\n /** Calls `listener` with the `id` of a native menu item when it's chosen; returns the unsubscribe */\n onMenuClick(listener: (id: number) => void): () => void\n}\n\n/** A menu of the native menu bar (macOS), as MTitleBar sends its `menus`: plain data, the clicks come back by id */\nexport interface M3NativeMenu {\n label: string\n enabled: boolean\n items: M3NativeMenuItem[]\n}\n\nexport type M3NativeMenuItem =\n | { type: 'separator' }\n | { type: 'submenu'; label: string; enabled: boolean; items: M3NativeMenuItem[] }\n | { type: 'normal' | 'checkbox'; id: number; label: string; enabled: boolean; checked?: boolean; accelerator?: string }\n\nexport type M3NativeTheme = 'light' | 'dark' | 'system'\n\nexport const IPC = {\n info: 'm3ui:info',\n state: 'm3ui:state',\n action: 'm3ui:action',\n overlay: 'm3ui:overlay',\n theme: 'm3ui:theme',\n progress: 'm3ui:progress',\n badge: 'm3ui:badge',\n attention: 'm3ui:attention',\n accent: 'm3ui:accent',\n menu: 'm3ui:menu',\n menuClick: 'm3ui:menu-click',\n} as const\n\n/** The default key the bridge is exposed under (`window.m3ui`) */\nexport const BRIDGE_KEY = 'm3ui'\n\n/** Default title bar height: Windows 11 caption buttons are 32px, GNOME header bars ~46px; 40 sits between */\nexport const DEFAULT_TITLE_BAR_HEIGHT = 40\n"],"mappings":"AA+EA,IAAaA,EAAM,CACjB,KAAM,YACN,MAAO,aACP,OAAQ,cACR,QAAS,eACT,MAAO,aACP,SAAU,gBACV,MAAO,aACP,UAAW,iBACX,OAAQ,cACR,KAAM,YACN,UAAW,iBACb,EAGaC,EAAa,O"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -51,7 +51,32 @@ export interface M3Bridge {
|
|
|
51
51
|
attention(): void;
|
|
52
52
|
/** Calls `listener` when the system accent color changes; returns the unsubscribe */
|
|
53
53
|
onAccent(listener: (color: string | null) => void): () => void;
|
|
54
|
+
/** The app's menus in macOS's menu bar (ignored elsewhere); `null` puts back the menu the app had */
|
|
55
|
+
setMenu(menus: M3NativeMenu[] | null): void;
|
|
56
|
+
/** Calls `listener` with the `id` of a native menu item when it's chosen; returns the unsubscribe */
|
|
57
|
+
onMenuClick(listener: (id: number) => void): () => void;
|
|
54
58
|
}
|
|
59
|
+
/** A menu of the native menu bar (macOS), as MTitleBar sends its `menus`: plain data, the clicks come back by id */
|
|
60
|
+
export interface M3NativeMenu {
|
|
61
|
+
label: string;
|
|
62
|
+
enabled: boolean;
|
|
63
|
+
items: M3NativeMenuItem[];
|
|
64
|
+
}
|
|
65
|
+
export type M3NativeMenuItem = {
|
|
66
|
+
type: 'separator';
|
|
67
|
+
} | {
|
|
68
|
+
type: 'submenu';
|
|
69
|
+
label: string;
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
items: M3NativeMenuItem[];
|
|
72
|
+
} | {
|
|
73
|
+
type: 'normal' | 'checkbox';
|
|
74
|
+
id: number;
|
|
75
|
+
label: string;
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
checked?: boolean;
|
|
78
|
+
accelerator?: string;
|
|
79
|
+
};
|
|
55
80
|
export type M3NativeTheme = 'light' | 'dark' | 'system';
|
|
56
81
|
export declare const IPC: {
|
|
57
82
|
readonly info: "m3ui:info";
|
|
@@ -63,6 +88,8 @@ export declare const IPC: {
|
|
|
63
88
|
readonly badge: "m3ui:badge";
|
|
64
89
|
readonly attention: "m3ui:attention";
|
|
65
90
|
readonly accent: "m3ui:accent";
|
|
91
|
+
readonly menu: "m3ui:menu";
|
|
92
|
+
readonly menuClick: "m3ui:menu-click";
|
|
66
93
|
};
|
|
67
94
|
/** The default key the bridge is exposed under (`window.m3ui`) */
|
|
68
95
|
export declare const BRIDGE_KEY = "m3ui";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m3ui-vue/electron",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Electron integration for m3ui-vue: a Material Design 3 title bar with native or custom window controls, themed live from the M3 tokens",
|
|
5
5
|
"keywords": ["electron", "material-design", "material-3", "m3", "vue", "title-bar", "window-controls-overlay", "tailwindcss"],
|
|
6
6
|
"homepage": "https://m3ui.dev",
|
package/dist/shared-BLenUWPr.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e={info:`m3ui:info`,state:`m3ui:state`,action:`m3ui:action`,overlay:`m3ui:overlay`,theme:`m3ui:theme`,progress:`m3ui:progress`,badge:`m3ui:badge`,attention:`m3ui:attention`,accent:`m3ui:accent`},t=`m3ui`;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|
|
2
|
-
//# sourceMappingURL=shared-BLenUWPr.cjs.map
|