@m3ui-vue/electron 0.1.0 → 0.2.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/dist/main.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.cjs","names":["ipcMain","IPC","electron","require_shared","BASELINE","resolve","o","windows","registered","stateOf","win","entry","sender","register","w","action","colors","isHex","key","c","options","mac","id","send","events","ev"],"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).\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 { BrowserWindow, ipcMain, type BrowserWindowConstructorOptions, type IpcMainEvent, type IpcMainInvokeEvent, type WebContents } from 'electron'\nimport { DEFAULT_TITLE_BAR_HEIGHT, IPC, type M3Controls, type M3OverlayColors, type M3WindowAction, type M3WindowInfo, type M3WindowState } from './shared'\n\nexport type { M3Controls, 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\ninterface Resolved {\n controls: M3Controls\n titleBarHeight: number\n overlay: M3OverlayColors\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 }\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 if (o.controls === 'custom') return { frame: false }\n const mac = process.platform === 'darwin'\n return {\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 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) }\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}\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 const dispose = () => {\n windows.delete(id)\n if (!win.isDestroyed()) for (const ev of events) win.off(ev as 'maximize', send)\n }\n win.once('closed', () => windows.delete(id))\n return dispose\n}\n"],"mappings":"A,sIAiCA,IAAMI,EAA4B,CAAE,MAAO,UAAW,YAAa,SAAU,EAE7E,SAASC,EAAQC,EAAqB,CAAC,EAAa,CAClD,MAAO,CACL,SAAUA,EAAE,WAAa,SAAW,SAAW,SAC/C,eAAgB,KAAK,IAAI,GAAI,KAAK,MAAMA,EAAE,gBAAA,EAA0C,CAAC,EACrF,QAAS,CAAE,GAAGF,EAAU,GAAGE,EAAE,OAAQ,CACvC,CACF,CAkBA,IAAMC,EAAU,IAAI,IAChBC,EAAa,GAEXC,EAAWC,IAAuC,CACtD,UAAWA,EAAI,YAAY,EAC3B,WAAYA,EAAI,aAAa,EAC7B,QAASA,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A4B,OAAOA,GAAM,UAAY,gCAAgC,KAAKA,CAAC,E,wBA1D1G,SAAgCC,EAA2B,CAAC,EAAoC,CAC9F,IAAMd,EAAID,EAAQe,CAAO,EACzB,GAAId,EAAE,WAAa,SAAU,MAAO,CAAE,MAAO,EAAM,EACnD,IAAMe,EAAM,QAAQ,WAAa,SACjC,MAAO,CACL,cAAe,SAGf,gBAAiBA,EAAM,GAAO,CAAE,GAAGf,EAAE,QAAS,OAAQA,EAAE,cAAe,EAEvE,GAAIe,EAAM,CAAE,qBAAsB,CAAE,EAAG,GAAI,EAAG,KAAK,OAAOf,EAAE,eAAiB,IAAM,CAAC,CAAE,CAAE,EAAI,CAAC,CAC/F,CACF,E,sBAqDA,SAA8BI,EAAoBU,EAA2B,CAAC,EAAe,CAC3FP,EAAS,EACT,IAAMP,EAAID,EAAQe,CAAO,EACnBE,EAAKZ,EAAI,YAAY,GAC3BH,EAAQ,IAAIe,EAAI,CAAEZ,MAAKJ,IAAG,QAAS,EAAG,CAAC,EACvC,IAAMiB,MAAa,CAAOb,EAAI,YAAY,GAAGA,EAAI,YAAY,KAAKT,EAAAA,EAAI,MAAOQ,EAAQC,CAAG,CAAC,CAAE,EACrFc,EAAS,CAAC,WAAY,aAAc,oBAAqB,oBAAqB,QAAS,OAAQ,SAAS,EAC9G,IAAK,IAAMC,KAAMD,EAAQd,EAAI,GAAGe,EAAkBF,CAAI,EAMtD,OADAb,EAAI,KAAK,aAAgBH,EAAQ,OAAOe,CAAE,CAAC,MAJrB,CAEpB,GADAf,EAAQ,OAAOe,CAAE,EACb,CAACZ,EAAI,YAAY,EAAG,IAAK,IAAMe,KAAMD,EAAQd,EAAI,IAAIe,EAAkBF,CAAI,CACjF,CAGF"}
1
+ {"version":3,"file":"main.cjs","names":["join","app","readFileSync","screen","systemPreferences","ipcMain","IPC","nativeTheme","writeFileSync","shell","node_fs","node_path","electron","require_shared","BASELINE","resolve","o","boundsFile","name","readBounds","b","restoredBounds","a","windows","registered","accent","c","stateOf","win","entry","sender","register","w","action","colors","isHex","key","theme","value","count","EXTERNAL","options","saved","x","y","width","height","mac","id","send","events","ev","save","timer","later","url","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":"A,kLAkDA,IAAMc,EAA4B,CAAE,MAAO,UAAW,YAAa,SAAU,EAE7E,SAASC,EAAQC,EAAqB,CAAC,EAAa,CAClD,MAAO,CACL,SAAUA,EAAE,WAAa,SAAW,SAAW,SAC/C,eAAgB,KAAK,IAAI,GAAI,KAAK,MAAMA,EAAE,gBAAA,EAA0C,CAAC,EACrF,QAAS,CAAE,GAAGF,EAAU,GAAGE,EAAE,OAAQ,EACrC,OAAQA,EAAE,eAAiB,YAAY,OAAOA,EAAE,gBAAmB,SAAW,IAAIA,EAAE,eAAe,QAAQ,UAAW,GAAG,IAAM,GAAG,OAAS,KAC3I,cAAeA,EAAE,gBAAkB,EACrC,CACF,CAIA,IAAMC,EAAcC,IAAA,EAAiBlB,EAAAA,KAAAA,CAAKC,EAAAA,IAAI,QAAQ,UAAU,EAAGiB,CAAI,EAEvE,SAASC,EAAWD,EAA4B,CAC9C,GAAI,CACF,IAAME,EAAI,KAAK,OAAA,EAAMlB,EAAAA,aAAAA,CAAae,EAAWC,CAAI,EAAG,MAAM,CAAC,EAE3D,MADK,CAACE,EAAE,EAAGA,EAAE,EAAGA,EAAE,MAAOA,EAAE,MAAM,CAAC,CAAC,MAAM,OAAO,QAAQ,EACjDA,EAD2D,IAEpE,MAAQ,CACN,OAAO,IACT,CACF,CAGA,SAASC,EAAeH,EAA4D,CAClF,IAAME,EAAID,EAAWD,CAAI,EAIzB,OAHKE,EACWjB,EAAAA,OAAO,eAAe,CAAC,CAAC,MAAM,CAAE,SAAUmB,KACxD,KAAK,IAAIF,EAAE,EAAIA,EAAE,MAAOE,EAAE,EAAIA,EAAE,KAAK,EAAI,KAAK,IAAIF,EAAE,EAAGE,EAAE,CAAC,GAAK,KAAO,KAAK,IAAIF,EAAE,EAAI,GAAIE,EAAE,EAAIA,EAAE,MAAM,E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K,EAAGD,EAAK,CAAE,CAAC,CACvD,CA4BA,OAzBIpC,EAAE,gBACJY,EAAI,YAAY,sBAAsB,CAAE2B,UAClCf,EAAS,KAAKe,CAAG,GAAQ9C,EAAAA,MAAM,aAAa8C,CAAG,EAC5C,CAAE,OAAQ,MAAO,EACzB,EACD3B,EAAI,YAAY,GAAG,iBAAkB,EAAG2B,IAAQ,CAC9C,IAAMC,EAAO5B,EAAI,YAAY,OAAO,EAChC6B,EAAQ,GACZ,GAAI,CAAEA,EAAQ,IAAI,IAAIF,CAAG,CAAC,CAAC,SAAW,IAAI,IAAIC,CAAI,CAAC,CAAC,MAAO,MAAQ,CAAiC,CAChGhB,EAAS,KAAKe,CAAG,GAAKE,IACxB,EAAE,eAAe,EACZhD,EAAAA,MAAM,aAAa8C,CAAG,EAE/B,CAAC,GAWH3B,EAAI,KAAK,aAAgB,CAAEL,EAAQ,OAAOyB,CAAE,EAAG,aAAaK,CAAK,CAAE,CAAC,MAR9C,CAGpB,GAFA9B,EAAQ,OAAOyB,CAAE,EACjB,aAAaK,CAAK,EACd,CAACzB,EAAI,YAAY,EAAG,CACtB,IAAK,IAAMuB,KAAMD,EAAQtB,EAAI,IAAIuB,EAAkBF,CAAI,EACvD,IAAK,IAAME,IAAM,CAAC,SAAU,OAAQ,WAAY,YAAY,EAAYvB,EAAI,IAAIuB,EAAgBG,CAAK,CACvG,CACF,CAGF"}
package/dist/main.d.ts CHANGED
@@ -1,16 +1,6 @@
1
- /**
2
- * `@m3ui-vue/electron/main`: the main-process half. `m3WindowOptions()` gives the BrowserWindow options for the mode
3
- * you pick, `setupM3Window()` wires that window to MTitleBar (its state, its buttons, the native overlay's colors).
4
- *
5
- * ```ts
6
- * const m3 = { controls: 'native' } as const
7
- * const win = new BrowserWindow({ width: 1100, height: 720, ...m3WindowOptions(m3), webPreferences: { preload } })
8
- * setupM3Window(win, m3)
9
- * ```
10
- */
11
1
  import { BrowserWindow, type BrowserWindowConstructorOptions } from 'electron';
12
2
  import { type M3Controls, type M3OverlayColors } from './shared';
13
- export type { M3Controls, M3OverlayColors, M3WindowAction, M3WindowInfo, M3WindowState } from './shared';
3
+ export type { M3Controls, M3NativeTheme, M3OverlayColors, M3WindowAction, M3WindowInfo, M3WindowState } from './shared';
14
4
  export interface M3WindowOptions {
15
5
  /** `'native'` (default): the system's buttons, recolored from the theme. `'custom'`: frameless, MTitleBar draws them */
16
6
  controls?: M3Controls;
@@ -21,6 +11,17 @@ export interface M3WindowOptions {
21
11
  * it mounts). Defaults to the M3 baseline light surface
22
12
  */
23
13
  overlay?: Partial<M3OverlayColors>;
14
+ /**
15
+ * Reopen the window with the size, position and maximized state it closed with (kept in the app's userData
16
+ * folder). `true`, or a name per window when the app has several. Spread `m3WindowOptions()` after your own
17
+ * width/height so the remembered ones win
18
+ */
19
+ rememberBounds?: boolean | string;
20
+ /**
21
+ * Open http(s) and mailto links that would leave the app (`target="_blank"`, `window.open`, a link to another
22
+ * site) in the system browser instead of a new Electron window. Default true
23
+ */
24
+ externalLinks?: boolean;
24
25
  }
25
26
  /** The BrowserWindow options for a mode: spread them into `new BrowserWindow({ ... })` */
26
27
  export declare function m3WindowOptions(options?: M3WindowOptions): BrowserWindowConstructorOptions;
package/dist/main.js CHANGED
@@ -1,79 +1,148 @@
1
- import { ipcMain as e } from "electron";
2
- import { n as t } from "./shared-B-ScY3hE.js";
1
+ import { readFileSync as e, writeFileSync as t } from "node:fs";
2
+ import { join as n } from "node:path";
3
+ import { app as r, ipcMain as i, nativeTheme as a, screen as o, shell as s, systemPreferences as c } from "electron";
4
+ import { n as l } from "./shared-OD5t8cpt.js";
3
5
  // src/main.ts
4
- var n = {
6
+ var u = {
5
7
  color: "#fef7ff",
6
8
  symbolColor: "#49454f"
7
9
  };
8
- function r(e = {}) {
10
+ function d(e = {}) {
9
11
  return {
10
12
  controls: e.controls === "custom" ? "custom" : "native",
11
13
  titleBarHeight: Math.max(24, Math.round(e.titleBarHeight ?? 40)),
12
14
  overlay: {
13
- ...n,
15
+ ...u,
14
16
  ...e.overlay
15
- }
17
+ },
18
+ bounds: e.rememberBounds ? `m3-window${typeof e.rememberBounds == "string" ? `-${e.rememberBounds.replace(/[^\w-]/g, "_")}` : ""}.json` : null,
19
+ externalLinks: e.externalLinks !== !1
16
20
  };
17
21
  }
18
- function i(e = {}) {
19
- let t = r(e);
20
- if (t.controls === "custom") return { frame: !1 };
21
- let n = process.platform === "darwin";
22
+ var f = (e) => n(r.getPath("userData"), e);
23
+ function p(t) {
24
+ try {
25
+ let n = JSON.parse(e(f(t), "utf8"));
26
+ return [
27
+ n.x,
28
+ n.y,
29
+ n.width,
30
+ n.height
31
+ ].every(Number.isFinite) ? n : null;
32
+ } catch {
33
+ return null;
34
+ }
35
+ }
36
+ function m(e) {
37
+ let t = p(e);
38
+ return t ? o.getAllDisplays().some(({ workArea: e }) => Math.min(t.x + t.width, e.x + e.width) - Math.max(t.x, e.x) >= 100 && Math.min(t.y + 40, e.y + e.height) - Math.max(t.y, e.y) >= 20) ? t : {
39
+ width: t.width,
40
+ height: t.height,
41
+ maximized: t.maximized
42
+ } : {};
43
+ }
44
+ function h(e = {}) {
45
+ let t = d(e), n = {};
46
+ if (t.bounds) {
47
+ let { x: e, y: r, width: i, height: a } = m(t.bounds);
48
+ n = {
49
+ ...i ? {
50
+ width: i,
51
+ height: a
52
+ } : {},
53
+ ...e == null ? {} : {
54
+ x: e,
55
+ y: r
56
+ }
57
+ };
58
+ }
59
+ if (t.controls === "custom") return {
60
+ ...n,
61
+ frame: !1
62
+ };
63
+ let r = process.platform === "darwin";
22
64
  return {
65
+ ...n,
23
66
  titleBarStyle: "hidden",
24
- titleBarOverlay: n ? !0 : {
67
+ titleBarOverlay: r ? !0 : {
25
68
  ...t.overlay,
26
69
  height: t.titleBarHeight
27
70
  },
28
- ...n ? { trafficLightPosition: {
71
+ ...r ? { trafficLightPosition: {
29
72
  x: 14,
30
73
  y: Math.round((t.titleBarHeight - 16) / 2)
31
74
  } } : {}
32
75
  };
33
76
  }
34
- var a = /* @__PURE__ */ new Map(), o = !1, s = (e) => ({
77
+ var g = /* @__PURE__ */ new Map(), _ = !1, v = () => {
78
+ try {
79
+ let e = process.platform === "win32" || process.platform === "darwin" ? c.getAccentColor() : "";
80
+ return /^[0-9a-f]{6}/i.test(e) ? `#${e.slice(0, 6).toLowerCase()}` : null;
81
+ } catch {
82
+ return null;
83
+ }
84
+ }, y = (e) => ({
35
85
  maximized: e.isMaximized(),
36
86
  fullscreen: e.isFullScreen(),
37
87
  focused: e.isFocused()
38
88
  });
39
- function c(e) {
40
- return a.get(e.id);
89
+ function b(e) {
90
+ return g.get(e.id);
41
91
  }
42
- function l() {
43
- o || (o = !0, e.handle(t.info, (e) => {
44
- let t = c(e.sender);
92
+ function x() {
93
+ _ || (_ = !0, i.handle(l.info, (e) => {
94
+ let t = b(e.sender);
45
95
  return t ? {
46
96
  controls: t.o.controls,
47
97
  platform: process.platform,
48
98
  titleBarHeight: t.o.titleBarHeight,
49
- state: s(t.win)
99
+ state: y(t.win),
100
+ accentColor: v()
50
101
  } : null;
51
- }), e.on(t.action, (e, t) => {
52
- let n = c(e.sender);
102
+ }), i.on(l.action, (e, t) => {
103
+ let n = b(e.sender);
53
104
  n && !n.win.isDestroyed() && (t === "minimize" ? n.win.minimize() : t === "toggle-maximize" ? n.win.isFullScreen() ? n.win.setFullScreen(!1) : n.win.isMaximized() ? n.win.unmaximize() : n.win.maximize() : t === "close" && n.win.close());
54
- }), e.on(t.overlay, (e, t) => {
55
- let n = c(e.sender);
56
- if (!n || n.win.isDestroyed() || n.o.controls !== "native" || process.platform === "darwin" || !u(t?.color) || !u(t?.symbolColor)) return;
105
+ }), i.on(l.overlay, (e, t) => {
106
+ let n = b(e.sender);
107
+ if (!n || n.win.isDestroyed() || n.o.controls !== "native" || process.platform === "darwin" || !C(t?.color) || !C(t?.symbolColor)) return;
57
108
  let r = `${t.color}|${t.symbolColor}`;
58
109
  r !== n.overlay && (n.overlay = r, n.win.setTitleBarOverlay({
59
110
  color: t.color,
60
111
  symbolColor: t.symbolColor,
61
112
  height: n.o.titleBarHeight
62
113
  }));
114
+ }), i.on(l.theme, (e, t) => {
115
+ b(e.sender) && [
116
+ "light",
117
+ "dark",
118
+ "system"
119
+ ].includes(t) && a.themeSource !== t && (a.themeSource = t);
120
+ }), i.on(l.progress, (e, t) => {
121
+ let n = b(e.sender);
122
+ n && !n.win.isDestroyed() && (t === "indeterminate" ? n.win.setProgressBar(2, { mode: "indeterminate" }) : typeof t == "number" && Number.isFinite(t) ? n.win.setProgressBar(Math.min(1, Math.max(0, t))) : n.win.setProgressBar(-1));
123
+ }), i.on(l.badge, (e, t) => {
124
+ b(e.sender) && r.setBadgeCount(Math.max(0, Math.floor(Number(t) || 0)));
125
+ }), i.on(l.attention, (e) => {
126
+ let t = b(e.sender);
127
+ !t || t.win.isDestroyed() || t.win.isFocused() || (process.platform === "darwin" ? r.dock?.bounce("informational") : (t.win.flashFrame(!0), t.win.once("focus", () => {
128
+ t.win.isDestroyed() || t.win.flashFrame(!1);
129
+ })));
130
+ }), c.on?.("accent-color-changed", () => {
131
+ for (let { win: e } of g.values()) e.isDestroyed() || e.webContents.send(l.accent, v());
63
132
  }));
64
133
  }
65
- var u = (e) => typeof e == "string" && /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e);
66
- function d(e, n = {}) {
67
- l();
68
- let i = r(n), o = e.webContents.id;
69
- a.set(o, {
134
+ var S = /^(https?|mailto):/i, C = (e) => typeof e == "string" && /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e);
135
+ function w(e, n = {}) {
136
+ x();
137
+ let r = d(n), i = e.webContents.id;
138
+ g.set(i, {
70
139
  win: e,
71
- o: i,
140
+ o: r,
72
141
  overlay: ""
73
142
  });
74
- let c = () => {
75
- e.isDestroyed() || e.webContents.send(t.state, s(e));
76
- }, u = [
143
+ let a = () => {
144
+ e.isDestroyed() || e.webContents.send(l.state, y(e));
145
+ }, o = [
77
146
  "maximize",
78
147
  "unmaximize",
79
148
  "enter-full-screen",
@@ -82,11 +151,50 @@ function d(e, n = {}) {
82
151
  "blur",
83
152
  "restore"
84
153
  ];
85
- for (let t of u) e.on(t, c);
86
- return e.once("closed", () => a.delete(o)), () => {
87
- if (a.delete(o), !e.isDestroyed()) for (let t of u) e.off(t, c);
154
+ for (let t of o) e.on(t, a);
155
+ let c = () => {}, u, m = () => {
156
+ clearTimeout(u), u = setTimeout(c, 400);
157
+ };
158
+ if (r.bounds) {
159
+ let n = r.bounds;
160
+ p(n)?.maximized && e.maximize(), c = () => {
161
+ if (!(e.isDestroyed() || e.isMinimized() || e.isFullScreen())) try {
162
+ t(f(n), JSON.stringify({
163
+ ...e.getNormalBounds(),
164
+ maximized: e.isMaximized()
165
+ }));
166
+ } catch {}
167
+ };
168
+ for (let t of [
169
+ "resize",
170
+ "move",
171
+ "maximize",
172
+ "unmaximize"
173
+ ]) e.on(t, m);
174
+ e.on("close", () => {
175
+ clearTimeout(u), c();
176
+ });
177
+ }
178
+ return r.externalLinks && (e.webContents.setWindowOpenHandler(({ url: e }) => (S.test(e) && s.openExternal(e), { action: "deny" })), e.webContents.on("will-navigate", (t, n) => {
179
+ let r = e.webContents.getURL(), i = !1;
180
+ try {
181
+ i = new URL(n).origin !== new URL(r).origin;
182
+ } catch {}
183
+ S.test(n) && i && (t.preventDefault(), s.openExternal(n));
184
+ })), e.once("closed", () => {
185
+ g.delete(i), clearTimeout(u);
186
+ }), () => {
187
+ if (g.delete(i), clearTimeout(u), !e.isDestroyed()) {
188
+ for (let t of o) e.off(t, a);
189
+ for (let t of [
190
+ "resize",
191
+ "move",
192
+ "maximize",
193
+ "unmaximize"
194
+ ]) e.off(t, m);
195
+ }
88
196
  };
89
197
  }
90
- export { i as m3WindowOptions, d as setupM3Window };
198
+ export { h as m3WindowOptions, w as setupM3Window };
91
199
 
92
200
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","names":["ipcMain","IPC","BASELINE","resolve","o","m3WindowOptions","options","mac","windows","registered","stateOf","win","entry","sender","register","w","action","colors","isHex","key","c","setupM3Window","id","send","events","ev"],"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).\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 { BrowserWindow, ipcMain, type BrowserWindowConstructorOptions, type IpcMainEvent, type IpcMainInvokeEvent, type WebContents } from 'electron'\nimport { DEFAULT_TITLE_BAR_HEIGHT, IPC, type M3Controls, type M3OverlayColors, type M3WindowAction, type M3WindowInfo, type M3WindowState } from './shared'\n\nexport type { M3Controls, 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\ninterface Resolved {\n controls: M3Controls\n titleBarHeight: number\n overlay: M3OverlayColors\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 }\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 if (o.controls === 'custom') return { frame: false }\n const mac = process.platform === 'darwin'\n return {\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 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) }\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}\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 const dispose = () => {\n windows.delete(id)\n if (!win.isDestroyed()) for (const ev of events) win.off(ev as 'maximize', send)\n }\n win.once('closed', () => windows.delete(id))\n return dispose\n}\n"],"mappings":";;;AAiCA,IAAME,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;CACvC;AACF;AAGA,SAAgBC,EAAgBC,IAA2B,CAAC,GAAoC;CAC9F,IAAMF,IAAID,EAAQG,CAAO;CACzB,IAAIF,EAAE,aAAa,UAAU,OAAO,EAAE,OAAO,GAAM;CACnD,IAAMG,IAAM,QAAQ,aAAa;CACjC,OAAO;EACL,eAAe;EAGf,iBAAiBA,IAAM,KAAO;GAAE,GAAGH,EAAE;GAAS,QAAQA,EAAE;EAAe;EAEvE,GAAIG,IAAM,EAAE,sBAAsB;GAAE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AO;EAClCE,MAAQJ,EAAE,YACdA,EAAE,UAAUI,GACZJ,EAAE,IAAI,mBAAmB;GAAE,OAAOE,EAAO;GAAO,aAAaA,EAAO;GAAa,QAAQF,EAAE,EAAE;EAAe,CAAC;CAC/G,CAAC;AACH;AAEA,IAAMG,KAASE,MAA4B,OAAOA,KAAM,YAAY,gCAAgC,KAAKA,CAAC;AAO1G,SAAgBC,EAAcV,GAAoBL,IAA2B,CAAC,GAAe;CAC3FQ,EAAS;CACT,IAAMV,IAAID,EAAQG,CAAO,GACnBgB,IAAKX,EAAI,YAAY;CAC3BH,EAAQ,IAAIc,GAAI;EAAEX;EAAKP;EAAG,SAAS;CAAG,CAAC;CACvC,IAAMmB,UAAa;EAAOZ,EAAI,YAAY,KAAGA,EAAI,YAAY,KAAKV,EAAI,OAAOS,EAAQC,CAAG,CAAC;CAAE,GACrFa,IAAS;EAAC;EAAY;EAAc;EAAqB;EAAqB;EAAS;EAAQ;CAAS;CAC9G,KAAK,IAAMC,KAAMD,GAAQb,EAAI,GAAGc,GAAkBF,CAAI;CAMtD,OADAZ,EAAI,KAAK,gBAAgBH,EAAQ,OAAOc,CAAE,CAAC,SAJrB;EAEpB,IADAd,EAAQ,OAAOc,CAAE,GACb,CAACX,EAAI,YAAY,GAAG,KAAK,IAAMc,KAAMD,GAAQb,EAAI,IAAIc,GAAkBF,CAAI;CACjF;AAGF"}
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;C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AE,eAAe,GACZ/C,EAAM,aAAa8C,CAAG;CAE/B,CAAC,IAWHrB,EAAI,KAAK,gBAAgB;EAAEL,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"}
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`},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})}}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`},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};
2
2
  //# sourceMappingURL=preload.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"preload.cjs","names":["ipcRenderer","contextBridge","electron","IPC","BRIDGE_KEY","createM3Bridge","listener","handler","_e","state","action","colors","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, 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 = { info: 'm3ui:info', state: 'm3ui:state', action: 'm3ui:action', overlay: 'm3ui:overlay' } 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 }\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,CAAE,KAAM,YAAa,MAAO,aAAc,OAAQ,cAAe,QAAS,cAAe,EAC/FC,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,CACjI,CACF,C,iFAMA,UAAmC,CACjC,IAAMC,EAASP,EAAe,EAC1B,QAAQ,gBAAiBJ,EAAAA,cAAc,kBAAkBG,EAAYQ,CAAM,EACzE,WAAkDR,GAAcQ,CACxE"}
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,aACV,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,CACF,CACF,C,iFAMA,UAAmC,CACjC,IAAMS,EAASX,EAAe,EAC1B,QAAQ,gBAAiBJ,EAAAA,cAAc,kBAAkBG,EAAYY,CAAM,EACzE,WAAkDZ,GAAcY,CACxE"}
package/dist/preload.d.ts CHANGED
@@ -4,6 +4,11 @@ declare const IPC: {
4
4
  readonly state: "m3ui:state";
5
5
  readonly action: "m3ui:action";
6
6
  readonly overlay: "m3ui:overlay";
7
+ readonly theme: "m3ui:theme";
8
+ readonly progress: "m3ui:progress";
9
+ readonly badge: "m3ui:badge";
10
+ readonly attention: "m3ui:attention";
11
+ readonly accent: "m3ui:accent";
7
12
  };
8
13
  declare const BRIDGE_KEY = "m3ui";
9
14
  export { IPC as _IPC, BRIDGE_KEY as _BRIDGE_KEY };
package/dist/preload.js CHANGED
@@ -4,7 +4,12 @@ var n = {
4
4
  info: "m3ui:info",
5
5
  state: "m3ui:state",
6
6
  action: "m3ui:action",
7
- overlay: "m3ui:overlay"
7
+ overlay: "m3ui:overlay",
8
+ theme: "m3ui:theme",
9
+ progress: "m3ui:progress",
10
+ badge: "m3ui:badge",
11
+ attention: "m3ui:attention",
12
+ accent: "m3ui:accent"
8
13
  }, r = "m3ui";
9
14
  function i() {
10
15
  return {
@@ -19,7 +24,17 @@ function i() {
19
24
  setOverlay: (e) => t.send(n.overlay, {
20
25
  color: e.color,
21
26
  symbolColor: e.symbolColor
22
- })
27
+ }),
28
+ setTheme: (e) => t.send(n.theme, e),
29
+ setProgress: (e) => t.send(n.progress, e),
30
+ setBadge: (e) => t.send(n.badge, e),
31
+ attention: () => t.send(n.attention),
32
+ onAccent(e) {
33
+ let r = (t, n) => e(n);
34
+ return t.on(n.accent, r), () => {
35
+ t.removeListener(n.accent, r);
36
+ };
37
+ }
23
38
  };
24
39
  }
25
40
  function a() {
@@ -1 +1 @@
1
- {"version":3,"file":"preload.js","names":["contextBridge","ipcRenderer","IPC","BRIDGE_KEY","createM3Bridge","listener","handler","_e","state","action","colors","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, 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 = { info: 'm3ui:info', state: 'm3ui:state', action: 'm3ui:action', overlay: 'm3ui:overlay' } 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 }\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;CAAE,MAAM;CAAa,OAAO;CAAc,QAAQ;CAAe,SAAS;AAAe,GAC/FC,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;CACjI;AACF;AAMA,SAAgBC,IAAmB;CACjC,IAAMC,IAASR,EAAe;CAC1B,QAAQ,kBAAiBJ,EAAc,kBAAkBG,GAAYS,CAAM,IACzE,WAAkDT,KAAcS;AACxE"}
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;AACV,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;CACF;AACF;AAMA,SAAgBS,IAAmB;CACjC,IAAMC,IAASZ,EAAe;CAC1B,QAAQ,kBAAiBJ,EAAc,kBAAkBG,GAAYa,CAAM,IACzE,WAAkDb,KAAca;AACxE"}
@@ -1,7 +1,22 @@
1
+ import { type MenuBarItem, type MenuBarMenu } from '@m3ui-vue/m3ui-vue';
1
2
  type Button = 'minimize' | 'maximize' | 'close';
2
3
  type __VLS_Props = {
3
4
  /** The window title */
4
5
  title?: string;
6
+ /**
7
+ * The app icon at the start: an image URL (`'/icon.png'`, an import, a data: URL) or a Material Symbol name.
8
+ * Clicking it does nothing (the `#icon` slot takes a button of yours)
9
+ */
10
+ icon?: string;
11
+ /** Menus (File, Edit…) after the icon, as an MMenuBar: items with submenus, dividers, checks, shortcut hints */
12
+ menus?: MenuBarMenu[];
13
+ /** `inline`: the menus sit in the title bar, after the icon. `below`: in a row of their own under it (classic) */
14
+ menusPosition?: 'inline' | 'below';
15
+ /**
16
+ * Like VS Code's "menu bar visibility": `visible`; `compact`, one ☰ button in the bar holding every menu;
17
+ * `toggle`, hidden until Alt is pressed (and hidden again after a pick, Esc or a click elsewhere); `hidden`
18
+ */
19
+ menusVisibility?: 'visible' | 'compact' | 'toggle' | 'hidden';
5
20
  /** Bar color: an M3 role (`'surface-container'`) or any CSS color */
6
21
  color?: string;
7
22
  /** Where the title sits */
@@ -12,9 +27,16 @@ type __VLS_Props = {
12
27
  side?: 'auto' | 'start' | 'end';
13
28
  /** Custom controls only: M3 icon buttons or macOS-style traffic lights; `auto` picks by platform */
14
29
  look?: 'auto' | 'm3' | 'traffic-lights';
30
+ /**
31
+ * Keep the native UI's theme (dialogs, context menus, scrollbars, macOS's frame) on the app's `useTheme()`
32
+ * choice: light, dark or system
33
+ */
34
+ syncNativeTheme?: boolean;
15
35
  };
16
36
  declare const __VLS_template: () => {
17
37
  __VLS_Slots: {
38
+ icon?: (props: {}) => any;
39
+ } & {
18
40
  start?: (props: {}) => any;
19
41
  } & {
20
42
  default?: (props: {}) => any;
@@ -31,12 +53,19 @@ declare const __VLS_template: () => {
31
53
  };
32
54
  };
33
55
  type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
34
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
56
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
57
+ "menu-select": (item: MenuBarItem, menu: number) => any;
58
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
59
+ "onMenu-select"?: ((item: MenuBarItem, menu: number) => any) | undefined;
60
+ }>, {
61
+ menusPosition: "inline" | "below";
62
+ menusVisibility: "visible" | "compact" | "toggle" | "hidden";
35
63
  color: string;
36
64
  titleAlign: "start" | "center";
37
65
  buttons: Button[];
38
66
  side: "start" | "auto" | "end";
39
67
  look: "auto" | "m3" | "traffic-lights";
68
+ syncNativeTheme: boolean;
40
69
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
41
70
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
42
71
  declare const _default: typeof __VLS_export;
@@ -1,5 +1,5 @@
1
1
  import { type ComputedRef, type Ref } from 'vue';
2
- import { type M3Controls, type M3OverlayColors } from '../shared';
2
+ import { 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
@@ -18,11 +18,24 @@ export interface ElectronWindow {
18
18
  maximized: Readonly<Ref<boolean>>;
19
19
  fullscreen: Readonly<Ref<boolean>>;
20
20
  focused: Readonly<Ref<boolean>>;
21
+ /**
22
+ * The system accent color (`#rrggbb`, Windows and macOS; null elsewhere), live. Seed the palette with it:
23
+ * `watchEffect(() => accentColor.value && setSeed(accentColor.value))` with `useColorPalette()`
24
+ */
25
+ accentColor: Readonly<Ref<string | null>>;
21
26
  minimize(): void;
22
27
  toggleMaximize(): void;
23
28
  close(): void;
24
29
  /** Recolors the native buttons (MTitleBar does it from the theme; for a bar of your own) */
25
30
  setOverlay(colors: M3OverlayColors): void;
31
+ /** Native UI theme (MTitleBar keeps it in step with `useTheme()`; for an app without the bar) */
32
+ setTheme(theme: M3NativeTheme): void;
33
+ /** Taskbar / dock progress, 0–1; `null` removes it, `'indeterminate'` for an unknown amount (Windows) */
34
+ setProgress(value: number | 'indeterminate' | null): void;
35
+ /** Badge count on the dock / launcher icon (macOS, Linux Unity launchers); 0 removes it */
36
+ setBadge(count: number): void;
37
+ /** Flashes the taskbar button / bounces the dock icon until the window gets focus */
38
+ requestAttention(): void;
26
39
  }
27
40
  export declare function useElectronWindow(): ElectronWindow;
28
41
  /** For tests: forget the fetched state */
@@ -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`},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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-BLenUWPr.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}\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} 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+DA,IAAaA,EAAM,CACjB,KAAM,YACN,MAAO,aACP,OAAQ,cACR,QAAS,eACT,MAAO,aACP,SAAU,gBACV,MAAO,aACP,UAAW,iBACX,OAAQ,aACV,EAGaC,EAAa,O"}
@@ -0,0 +1,15 @@
1
+ // src/shared.ts
2
+ var e = {
3
+ info: "m3ui:info",
4
+ state: "m3ui:state",
5
+ action: "m3ui:action",
6
+ overlay: "m3ui:overlay",
7
+ theme: "m3ui:theme",
8
+ progress: "m3ui:progress",
9
+ badge: "m3ui:badge",
10
+ attention: "m3ui:attention",
11
+ accent: "m3ui:accent"
12
+ }, t = "m3ui";
13
+ export { e as n, t };
14
+
15
+ //# sourceMappingURL=shared-OD5t8cpt.js.map