@m3ui-vue/electron 0.3.0 → 0.4.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 +65 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +180 -135
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.ts +2 -1
- package/dist/main.js +220 -71
- 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 +3 -0
- package/dist/preload.js +11 -2
- package/dist/preload.js.map +1 -1
- package/dist/renderer/useElectronWindow.d.ts +9 -0
- package/dist/shared-DS-DQqb1.cjs +2 -0
- package/dist/{shared-F3rp76zP.cjs.map → shared-DS-DQqb1.cjs.map} +1 -1
- package/dist/{shared-CmmPhgMH.js → shared-DrrWmxv6.js} +5 -2
- package/dist/{shared-CmmPhgMH.js.map → shared-DrrWmxv6.js.map} +1 -1
- package/dist/shared.d.ts +14 -0
- package/dist/splash-html.cjs +157 -0
- package/dist/splash-html.cjs.map +1 -0
- package/dist/splash-html.js +242 -0
- package/dist/splash-html.js.map +1 -0
- package/dist/splash.d.ts +86 -0
- package/dist/splashHtml.d.ts +78 -0
- package/package.json +6 -1
- package/dist/shared-F3rp76zP.cjs +0 -2
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["$slots","_openBlock","_createElementBlock","_normalizeClass","_unref","_normalizeStyle","_createElementVNode","_renderSlot","_createBlock","_createTextVNode","_toDisplayString","_normalizeProps","_guardReactiveProps","_Fragment","_renderList","_createVNode","Fragment","computed","createBlock","createCommentVNode","createElementBlock","createElementVNode","createTextVNode","createVNode","defineComponent","getCurrentScope","guardReactiveProps","nextTick","normalizeClass","normalizeProps","normalizeStyle","onBeforeUnmount","onMounted","onScopeDispose","openBlock","readonly","ref","renderList","renderSlot","toDisplayString","unref","watch","MIcon","MMenuBar","useLocale","useTheme","BRIDGE_KEY","bridge","ready","controls","platform","titleBarHeight","maximized","fullscreen","focused","accentColor","users","unsubscribe","unsubscribeAccent","started","apply","s","start","b","c","info","stop","useElectronWindow","colors","theme","value","count","menus","listener","acceleratorOf","shortcut","tokens","t","names","serializeMenus","picks","next","items","list","menu","i","label","id","check","m","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","MTitleBar_default","__props","__emit","props","emit","locale","revealed","shownMenus","osMenus","menusBelow","contains","item","onMenuSelect","altAlone","onKeydown","onKeyup","bar","hideLater","menubar","onBarKeydown","iconIsImage","win","isMac","ROLE","background","custom","native","menuSet","offClick","pick","data","p","atStart","lights","order","set","a","maximizeLabel","labels","run","onDblclick","probe","raf","until","observer","media","toHex","css","under","v","pageColor","hex","sendOverlay","color","symbolColor","follow","ms","step","onScheme","startSync","stopSync","_ctx","_cache","$event"],"sources":["../src/renderer/useElectronWindow.ts","../src/renderer/_nativeMenu.ts","../src/renderer/MTitleBar.vue"],"sourcesContent":["import { computed, onScopeDispose, readonly, ref, getCurrentScope, type ComputedRef, type Ref } from 'vue'\nimport { BRIDGE_KEY, DEFAULT_TITLE_BAR_HEIGHT, type M3Bridge, type M3NativeMenu, type M3Controls, type M3NativeTheme, type M3OverlayColors, type M3WindowState } from '../shared'\n\n/**\n * The window MTitleBar sits in, from the renderer: its mode and state (reactive) and its buttons. Outside Electron (or\n * without the preload's bridge) `isElectron` is false, nothing is ever `ready` and the actions do nothing, so the same\n * app also runs in a browser.\n */\nexport interface ElectronWindow {\n /** The preload's bridge is there */\n isElectron: boolean\n /** The main process has answered (mode, platform and state are real from here on) */\n ready: Readonly<Ref<boolean>>\n controls: Readonly<Ref<M3Controls>>\n /** `process.platform` of the main process (`''` until ready) */\n platform: Readonly<Ref<string>>\n isMac: ComputedRef<boolean>\n titleBarHeight: Readonly<Ref<number>>\n maximized: Readonly<Ref<boolean>>\n fullscreen: Readonly<Ref<boolean>>\n focused: Readonly<Ref<boolean>>\n /**\n * The system accent color (`#rrggbb`, Windows and macOS; null elsewhere), live. Seed the palette with it:\n * `watchEffect(() => accentColor.value && setSeed(accentColor.value))` with `useColorPalette()`\n */\n accentColor: Readonly<Ref<string | null>>\n minimize(): void\n toggleMaximize(): void\n close(): void\n /** Recolors the native buttons (MTitleBar does it from the theme; for a bar of your own) */\n setOverlay(colors: M3OverlayColors): void\n /** Native UI theme (MTitleBar keeps it in step with `useTheme()`; for an app without the bar) */\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 requestAttention(): void\n /** The preload can set macOS's menu bar (one built before 0.3.0 can't) */\n canSetNativeMenu: boolean\n /** macOS's menu bar from MTitleBar's `menus` (it does this itself in native mode); `null` puts the app's back */\n setNativeMenu(menus: M3NativeMenu[] | null): void\n /** Calls `listener` with the id of a native menu item when chosen; returns the unsubscribe */\n onNativeMenuClick(listener: (id: number) => void): () => void\n}\n\n// The methods added after 0.1.0 are called with ?.(): a preload bundled from an older version (an app that updated\n// the package but not its preload build) must not break the renderer, it just doesn't get those features\nfunction bridge(): M3Bridge | undefined {\n return typeof window !== 'undefined' ? (window as unknown as Record<string, M3Bridge | undefined>)[BRIDGE_KEY] : undefined\n}\n\n// One window per renderer: the state is shared by every caller, fetched once, and kept while anyone uses it\nconst ready = ref(false)\nconst controls = ref<M3Controls>('native')\nconst platform = ref('')\nconst titleBarHeight = ref(DEFAULT_TITLE_BAR_HEIGHT)\nconst maximized = ref(false)\nconst fullscreen = ref(false)\nconst focused = ref(true)\nconst accentColor = ref<string | null>(null)\nlet users = 0\nlet unsubscribe: (() => void) | null = null\nlet unsubscribeAccent: (() => void) | null = null\nlet started: Promise<void> | null = null\n\nfunction apply(s: M3WindowState) {\n maximized.value = s.maximized\n fullscreen.value = s.fullscreen\n focused.value = s.focused\n}\n\nfunction start(b: M3Bridge) {\n if (!unsubscribe) unsubscribe = b.onState(apply)\n if (!unsubscribeAccent) unsubscribeAccent = b.onAccent?.((c) => { accentColor.value = c }) ?? null\n started ??= b.info().then((info) => {\n if (!info) return\n controls.value = info.controls\n platform.value = info.platform\n titleBarHeight.value = info.titleBarHeight\n accentColor.value = info.accentColor ?? null\n apply(info.state)\n ready.value = true\n }).catch(() => { started = null })\n}\n\nfunction stop() {\n unsubscribe?.()\n unsubscribe = null\n unsubscribeAccent?.()\n unsubscribeAccent = null\n}\n\nexport function useElectronWindow(): ElectronWindow {\n const b = bridge()\n if (b) {\n users++\n start(b)\n if (getCurrentScope()) onScopeDispose(() => { if (--users === 0) stop() })\n }\n return {\n isElectron: !!b,\n ready: readonly(ready),\n controls: readonly(controls),\n platform: readonly(platform),\n isMac: computed(() => platform.value === 'darwin'),\n titleBarHeight: readonly(titleBarHeight),\n maximized: readonly(maximized),\n fullscreen: readonly(fullscreen),\n focused: readonly(focused),\n accentColor: readonly(accentColor),\n minimize: () => b?.action('minimize'),\n toggleMaximize: () => b?.action('toggle-maximize'),\n close: () => b?.action('close'),\n setOverlay: (colors) => b?.setOverlay(colors),\n setTheme: (theme) => b?.setTheme?.(theme),\n setProgress: (value) => b?.setProgress?.(value),\n setBadge: (count) => b?.setBadge?.(count),\n requestAttention: () => b?.attention?.(),\n canSetNativeMenu: typeof b?.setMenu === 'function',\n setNativeMenu: (menus) => b?.setMenu?.(menus),\n onNativeMenuClick: (listener) => b?.onMenuClick?.(listener) ?? (() => {}),\n }\n}\n\n/** For tests: forget the fetched state */\nexport function _resetElectronWindow() {\n stop()\n users = 0\n started = null\n ready.value = false\n controls.value = 'native'\n platform.value = ''\n titleBarHeight.value = DEFAULT_TITLE_BAR_HEIGHT\n maximized.value = false\n fullscreen.value = false\n focused.value = true\n accentColor.value = null\n}\n","import type { MenuBarItem, MenuBarMenu } from '@m3ui-vue/m3ui-vue'\nimport type { M3NativeMenu, M3NativeMenuItem } from '../shared'\n\n/**\n * MMenuBar's shortcut hint (`'Ctrl+S'`, `'⌘S'`) as an Electron accelerator: Ctrl and ⌘ become `CmdOrCtrl`. A native\n * menu binds it: the key runs the item's `onSelect`.\n */\nexport function acceleratorOf(shortcut?: string): string | undefined {\n if (!shortcut) return undefined\n const tokens = shortcut.replace(/([⌘⇧⌥⌃])/g, '$1+').split('+').map((t) => t.trim()).filter(Boolean)\n const names: Record<string, string> = { '⌘': 'CmdOrCtrl', '⌃': 'CmdOrCtrl', '⇧': 'Shift', '⌥': 'Alt' }\n return tokens.map((t) => names[t] ?? (/^(ctrl|control|cmd|command)$/i.test(t) ? 'CmdOrCtrl' : /^option$/i.test(t) ? 'Alt' : t)).join('+')\n}\n\n/**\n * The menus as plain data for the main process, and what each id stands for (the item and its menu's index), to run\n * it when main says it was clicked\n */\nexport function serializeMenus(menus: MenuBarMenu[]): { data: M3NativeMenu[]; picks: Map<number, [MenuBarItem, number]> } {\n const picks = new Map<number, [MenuBarItem, number]>()\n let next = 1\n const items = (list: MenuBarItem[], menu: number): M3NativeMenuItem[] => list.map((i): M3NativeMenuItem => {\n if (i.divider) return { type: 'separator' }\n const label = i.label ?? ''\n if (i.children) return { type: 'submenu', label, enabled: !i.disabled, items: items(i.children, menu) }\n const id = next++\n picks.set(id, [i, menu])\n // A check mark for both: a radio item would make macOS uncheck its neighbors on its own\n const check = i.checked !== undefined || i.selected !== undefined\n return { type: check ? 'checkbox' : 'normal', id, label, enabled: !i.disabled, ...(check ? { checked: !!(i.checked ?? i.selected) } : {}), accelerator: acceleratorOf(i.shortcut) }\n })\n return { data: menus.map((m, i) => ({ label: m.label, enabled: !m.disabled, items: items(m.items, i) })), picks }\n}\n","<script setup lang=\"ts\">\n/**\n * MTitleBar — the window's title bar for an Electron app, in M3: drags the window, double-click maximizes, and holds\n * the title plus anything you put at its start or end. The controls mode comes from the main process\n * (`m3WindowOptions({ controls })`), not a prop, so the two can't disagree:\n * - `native`: the system draws the buttons over the bar (Windows 11 snap layouts, macOS traffic lights) and the bar\n * leaves their room free; their colors follow the bar's background and the theme live, palette changes included.\n * - `custom`: a frameless window; the bar draws M3 buttons (or traffic lights), on the side and with the buttons\n * you choose, or your own through `#controls`.\n * Outside Electron it renders as a plain bar without buttons, so the same app runs in a browser.\n *\n * @slot default The title (replaces `title`)\n * @slot start Content after the icon and the menus (a back button, a breadcrumb…)\n * @slot end Content before the trailing controls (a search field, account button…)\n * @slot controls Replaces the custom controls (`{ minimize, toggleMaximize, close, maximized, focused }`)\n * @slot icon Replaces the app icon\n * @event menu-select Emitted with the menu item chosen (and its menu's index), as MMenuBar's `select`\n */\nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { MIcon, MMenuBar, useLocale, useTheme, type MenuBarItem, type MenuBarMenu } from '@m3ui-vue/m3ui-vue'\nimport { useElectronWindow } from './useElectronWindow'\nimport { serializeMenus } from './_nativeMenu'\n\ntype Button = 'minimize' | 'maximize' | 'close'\n\nconst props = withDefaults(\n defineProps<{\n /** The window title */\n title?: string\n /**\n * The app icon at the start: an image URL (`'/icon.png'`, an import, a data: URL) or a Material Symbol name.\n * Clicking it does nothing (the `#icon` slot takes a button of yours)\n */\n icon?: string\n /** Menus (File, Edit…) after the icon, as an MMenuBar: items with submenus, dividers, checks, shortcut hints */\n menus?: MenuBarMenu[]\n /** `inline`: the menus sit in the title bar, after the icon. `below`: in a row of their own under it (classic) */\n menusPosition?: 'inline' | 'below'\n /**\n * Like VS Code's \"menu bar visibility\": `visible`; `compact`, one ☰ button in the bar holding every menu;\n * `toggle`, hidden until Alt is pressed (and hidden again after a pick, Esc or a click elsewhere); `hidden`\n */\n menusVisibility?: 'visible' | 'compact' | 'toggle' | 'hidden'\n /** Bar color: an M3 role (`'surface-container'`) or any CSS color */\n color?: string\n /** Where the title sits */\n titleAlign?: 'start' | 'center'\n /** Custom controls only: which buttons, in this order on the end side (mirrored on the start side) */\n buttons?: Button[]\n /** Custom controls only: the side they sit on; `auto` is the start on macOS, the end elsewhere */\n side?: 'auto' | 'start' | 'end'\n /** Custom controls only: M3 icon buttons or macOS-style traffic lights; `auto` picks by platform */\n look?: 'auto' | 'm3' | 'traffic-lights'\n /**\n * Keep the native UI's theme (dialogs, context menus, scrollbars, macOS's frame) on the app's `useTheme()`\n * choice: light, dark or system\n */\n syncNativeTheme?: boolean\n }>(),\n { color: 'surface', titleAlign: 'start', buttons: () => ['minimize', 'maximize', 'close'], side: 'auto', look: 'auto', syncNativeTheme: true, menusPosition: 'inline', menusVisibility: 'visible' },\n)\n\nconst emit = defineEmits<{ 'menu-select': [item: MenuBarItem, menu: number] }>()\n\nconst locale = useLocale()\n// ── Menus ─────────────────────────────────────────────────────────────────────────────────────────────────────\nconst revealed = ref(false) // toggle mode: shown by Alt\nconst shownMenus = computed<MenuBarMenu[]>(() => {\n const menus = props.menus ?? []\n if (osMenus.value) return [] // macOS's menu bar has them\n if (!menus.length || props.menusVisibility === 'hidden') return []\n if (props.menusVisibility === 'toggle' && !revealed.value) return []\n if (props.menusVisibility === 'compact') {\n return [{ label: locale.appMenuLabel, icon: 'menu', items: menus.map((m) => ({ label: m.label, disabled: m.disabled, children: m.items })) }]\n }\n return menus\n})\n// The ☰ button always sits in the bar; a row below for it alone would waste a row\nconst menusBelow = computed(() => props.menusPosition === 'below' && props.menusVisibility !== 'compact')\n\nconst contains = (items: MenuBarItem[], item: MenuBarItem): boolean => items.some((i) => i === item || (!!i.children && contains(i.children, item)))\nfunction onMenuSelect(item: MenuBarItem) {\n // The index in `menus`, also from the compact button (where MMenuBar only sees one menu)\n emit('menu-select', item, Math.max(0, (props.menus ?? []).findIndex((m) => contains(m.items, item))))\n if (props.menusVisibility === 'toggle') revealed.value = false\n}\n\n// Alt pressed and released alone shows the menus and focuses the first one, as on Windows and Linux\nlet altAlone = false\nfunction onKeydown(e: KeyboardEvent) {\n altAlone = e.key === 'Alt' && !e.repeat && !e.ctrlKey && !e.shiftKey && !e.metaKey\n}\nfunction onKeyup(e: KeyboardEvent) {\n if (e.key !== 'Alt' || !altAlone || props.menusVisibility !== 'toggle' || !props.menus?.length) return\n altAlone = false\n e.preventDefault()\n revealed.value = !revealed.value\n if (revealed.value) void nextTick(() => bar.value?.querySelector<HTMLElement>('.m3-menu-bar [role=\"menuitem\"]')?.focus())\n}\n// Hidden again once nothing in it is open or focused (a click elsewhere, Esc on a title, Tab away)\nfunction hideLater() {\n if (!revealed.value) return\n setTimeout(() => {\n const menubar = bar.value?.querySelector('.m3-menu-bar')\n if (!menubar) return\n if (menubar.querySelector('[aria-expanded=\"true\"]') || menubar.contains(document.activeElement)) return\n revealed.value = false\n }, 0)\n}\nfunction onBarKeydown(e: KeyboardEvent) {\n if (e.key !== 'Escape' || !revealed.value) return\n const t = e.target as Element\n if (t.closest('.m3-menu-bar') && t.getAttribute('aria-expanded') !== 'true') revealed.value = false\n}\nwatch(() => props.menusVisibility, () => { revealed.value = false })\nonMounted(() => {\n window.addEventListener('keydown', onKeydown, true)\n window.addEventListener('keyup', onKeyup, true)\n document.addEventListener('pointerdown', hideLater, true)\n document.addEventListener('focusin', hideLater)\n})\nonBeforeUnmount(() => {\n window.removeEventListener('keydown', onKeydown, true)\n window.removeEventListener('keyup', onKeyup, true)\n document.removeEventListener('pointerdown', hideLater, true)\n document.removeEventListener('focusin', hideLater)\n})\n\n// An image when it looks like one (a path, a URL, a file name), a Material Symbol otherwise\nconst iconIsImage = computed(() => !!props.icon && /[/.:]/.test(props.icon))\nconst win = useElectronWindow()\nconst { controls, maximized, focused, fullscreen, isMac, titleBarHeight } = win\n\nconst ROLE = /^[a-z]+(-[a-z]+)*$/\nconst background = computed(() => (ROLE.test(props.color) ? `var(--color-${props.color})` : props.color))\nconst custom = computed(() => win.isElectron && controls.value === 'custom')\nconst native = computed(() => win.isElectron && controls.value === 'native')\n\n// ── Native menus (macOS) ─────────────────────────────────────────────────────────────────────────────────────\n// With native controls on macOS the menus go to the menu bar at the top of the screen, like every Mac app's.\n// Elsewhere the native mode has no system title bar to hold a menu, so they stay in this bar as an MMenuBar.\nconst osMenus = computed(() => native.value && isMac.value && win.canSetNativeMenu && !!props.menus?.length)\nlet picks = new Map<number, [MenuBarItem, number]>()\nlet menuSet = false\nconst offClick = win.onNativeMenuClick((id) => {\n const pick = picks.get(id)\n if (!pick) return\n pick[0].onSelect?.()\n emit('menu-select', pick[0], pick[1])\n})\nwatch([osMenus, () => props.menus], () => {\n if (osMenus.value) {\n const { data, picks: p } = serializeMenus(props.menus!)\n picks = p\n win.setNativeMenu(data)\n menuSet = true\n } else if (menuSet) {\n win.setNativeMenu(null)\n menuSet = false\n }\n}, { immediate: true })\nonBeforeUnmount(() => {\n offClick()\n if (menuSet) win.setNativeMenu(null)\n})\nconst atStart = computed(() => (props.side === 'auto' ? isMac.value : props.side === 'start'))\nconst lights = computed(() => (props.look === 'auto' ? isMac.value : props.look === 'traffic-lights'))\nconst order = computed<Button[]>(() => {\n const set = props.buttons.filter((b, i, a) => a.indexOf(b) === i)\n // Traffic lights always read close, minimize, maximize; M3 buttons put close at the outer edge\n if (lights.value) return (['close', 'minimize', 'maximize'] as Button[]).filter((b) => set.includes(b))\n return atStart.value ? [...set].reverse() : set\n})\nconst maximizeLabel = computed(() => (maximized.value || fullscreen.value ? locale.windowRestore : locale.windowMaximize))\nconst labels = computed<Record<Button, string>>(() => ({ minimize: locale.windowMinimize, maximize: maximizeLabel.value, close: locale.close }))\nconst run = (b: Button) => (b === 'minimize' ? win.minimize() : b === 'maximize' ? win.toggleMaximize() : win.close())\n\n// Double-click on the bar itself (not on its content) maximizes, as on every desktop. Native title bars do it on\n// their own over the drag region; frameless ones on Linux don't\nfunction onDblclick(e: MouseEvent) {\n if (!custom.value) return\n if ((e.target as Element).closest('button, a, input, select, textarea, [role=\"button\"], [data-no-drag]')) return\n win.toggleMaximize()\n}\n\n// ── Native buttons follow the theme ────────────────────────────────────────────────────────────────────────────\n// They aren't CSS, so on every theme or palette change (and while its transition runs, ~300ms) the bar's computed\n// colors are sent each frame; main skips the ones that didn't change. macOS's traffic lights have fixed colors.\nconst bar = ref<HTMLElement>()\nconst probe = ref<HTMLElement>()\nlet raf = 0\nlet until = 0\nlet observer: MutationObserver | null = null\nlet media: MediaQueryList | null = null\n\nfunction toHex(css: string, under?: [number, number, number]): string | null {\n const m = /rgba?\\(\\s*([\\d.]+)[\\s,]+([\\d.]+)[\\s,]+([\\d.]+)(?:[\\s,/]+([\\d.]+%?))?/.exec(css)\n if (!m) return null\n let a = m[4] == null ? 1 : m[4].endsWith('%') ? parseFloat(m[4]) / 100 : parseFloat(m[4])\n const c = [+m[1]!, +m[2]!, +m[3]!]\n // A see-through bar: blend it over what's under it (the page), since the overlay can't be translucent\n if (a < 1 && under) c.forEach((v, i) => (c[i] = v * a + under[i]! * (1 - a)))\n else a = 1\n return `#${c.map((v) => Math.round(Math.min(255, Math.max(0, v))).toString(16).padStart(2, '0')).join('')}`\n}\n\nfunction pageColor(): [number, number, number] {\n const hex = toHex(getComputedStyle(document.body).backgroundColor) ?? toHex(getComputedStyle(document.documentElement).backgroundColor) ?? '#ffffff'\n return [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16)) as [number, number, number]\n}\n\nfunction sendOverlay() {\n if (!bar.value || !probe.value) return\n const color = toHex(getComputedStyle(bar.value).backgroundColor, pageColor())\n const symbolColor = toHex(getComputedStyle(probe.value).color)\n if (color && symbolColor) win.setOverlay({ color, symbolColor })\n}\n\nfunction follow(ms = 600) {\n if (!native.value || isMac.value) return\n until = performance.now() + ms\n if (raf) return\n const step = () => {\n sendOverlay()\n raf = performance.now() < until ? requestAnimationFrame(step) : 0\n }\n step()\n}\nconst onScheme = () => follow()\n\nfunction startSync() {\n if (observer || !native.value || isMac.value) return\n follow()\n observer = new MutationObserver(() => follow())\n observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class', 'style', 'data-palette', 'data-theme'] })\n media = window.matchMedia?.('(prefers-color-scheme: dark)') ?? null\n media?.addEventListener?.('change', onScheme)\n}\n\nfunction stopSync() {\n observer?.disconnect()\n observer = null\n media?.removeEventListener?.('change', onScheme)\n media = null\n cancelAnimationFrame(raf)\n raf = 0\n}\n\nonMounted(() => { if (win.ready.value) startSync() })\nwatch([win.ready, native, isMac], () => { stopSync(); if (win.ready.value) startSync() })\nwatch(() => props.color, () => follow())\n\nconst { theme } = useTheme()\nwatch([theme, () => props.syncNativeTheme, win.ready], () => {\n if (props.syncNativeTheme && win.ready.value) win.setTheme(theme.value)\n}, { immediate: true })\nonBeforeUnmount(stopSync)\n</script>\n\n<template>\n <header\n ref=\"bar\"\n class=\"m3-title-bar\"\n :class=\"{ 'm3-title-bar-native': native, 'm3-title-bar-blurred': !focused, 'm3-title-bar-center': titleAlign === 'center' }\"\n :style=\"{ background }\"\n :data-controls=\"win.isElectron ? controls : undefined\"\n >\n <span ref=\"probe\" class=\"m3-title-bar-probe\" aria-hidden=\"true\" />\n <div class=\"m3-title-bar-row\" :style=\"{ height: `${titleBarHeight}px` }\" @dblclick=\"onDblclick\">\n <div class=\"m3-title-bar-area\">\n <div v-if=\"icon || $slots.icon\" class=\"m3-title-bar-icon\">\n <slot name=\"icon\">\n <img v-if=\"iconIsImage\" :src=\"icon\" alt=\"\" draggable=\"false\" />\n <MIcon v-else :name=\"icon!\" :size=\"20\" />\n </slot>\n </div>\n <MMenuBar v-if=\"shownMenus.length && !menusBelow\" :menus=\"shownMenus\" :height=\"Math.min(32, titleBarHeight - 8)\" class=\"m3-title-bar-menus\" @select=\"onMenuSelect\" @keydown=\"onBarKeydown\" />\n <div class=\"m3-title-bar-start\"><slot name=\"start\" /></div>\n <div class=\"m3-title-bar-title\"><span class=\"m3-title-bar-text\"><slot>{{ title }}</slot></span></div>\n <div class=\"m3-title-bar-end\"><slot name=\"end\" /></div>\n\n <!-- One set of controls (yours or ours); on the start side it moves first with `order` -->\n <div v-if=\"custom\" class=\"m3-title-bar-side\" :class=\"atStart && 'm3-title-bar-controls-start'\">\n <slot name=\"controls\" v-bind=\"{ minimize: win.minimize, toggleMaximize: win.toggleMaximize, close: win.close, maximized, focused }\">\n <div class=\"m3-title-bar-controls\" :class=\"lights && 'm3-title-bar-lights'\">\n <button\n v-for=\"b in order\"\n :key=\"b\"\n type=\"button\"\n :class=\"['m3-title-bar-btn', `m3-title-bar-btn-${b}`]\"\n :aria-label=\"labels[b]\"\n :title=\"labels[b]\"\n @click=\"run(b)\"\n >\n <MIcon v-if=\"!lights\" :name=\"b === 'minimize' ? 'minimize' : b === 'close' ? 'close' : maximized || fullscreen ? 'close_fullscreen' : 'open_in_full'\" :size=\"b === 'maximize' ? 16 : 18\" />\n <svg v-else viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <path v-if=\"b === 'close'\" d=\"M3.5 3.5l5 5M8.5 3.5l-5 5\" />\n <path v-else-if=\"b === 'minimize'\" d=\"M3 6h6\" />\n <path v-else d=\"M6 3v6M3 6h6\" />\n </svg>\n </button>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <!-- The classic menu row: not a drag area, like every app's -->\n <div v-if=\"shownMenus.length && menusBelow\" class=\"m3-title-bar-menu-row\">\n <MMenuBar :menus=\"shownMenus\" :height=\"32\" @select=\"onMenuSelect\" @keydown=\"onBarKeydown\" />\n </div>\n </header>\n</template>\n\n<style>\n/* Plain CSS on the M3 tokens: the lib's Tailwind build doesn't scan this package, so no utility classes here */\n@layer base {\n .m3-title-bar {\n position: relative;\n display: block;\n flex-shrink: 0;\n width: 100%;\n color: var(--color-on-surface);\n user-select: none;\n -webkit-user-select: none;\n app-region: drag;\n -webkit-app-region: drag;\n }\n}\n.m3-title-bar :is(button, a, input, select, textarea, [role='button'], [contenteditable], [data-no-drag]) {\n app-region: no-drag;\n -webkit-app-region: no-drag;\n}\n.m3-title-bar-row {\n position: relative;\n}\n.m3-title-bar-menu-row {\n display: flex;\n align-items: center;\n padding: 0 8px 4px;\n app-region: no-drag;\n -webkit-app-region: no-drag;\n}\n.m3-title-bar-area {\n display: flex;\n align-items: center;\n gap: 8px;\n height: 100%;\n padding-inline: 8px;\n box-sizing: border-box;\n}\n/* The system's buttons sit over the bar: keep to the area Window Controls Overlay leaves free */\n.m3-title-bar-native .m3-title-bar-area {\n /* not positioned, so a centered title centers on the whole row, not on this area */\n margin-left: env(titlebar-area-x, 0px);\n width: env(titlebar-area-width, 100%);\n}\n.m3-title-bar-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 28px;\n color: var(--color-primary);\n}\n.m3-title-bar-icon img {\n width: 20px;\n height: 20px;\n object-fit: contain;\n pointer-events: none;\n}\n.m3-title-bar-menus {\n flex-shrink: 0;\n}\n.m3-title-bar-start,\n.m3-title-bar-end {\n display: flex;\n align-items: center;\n gap: 4px;\n min-width: 0;\n}\n.m3-title-bar-start:empty,\n.m3-title-bar-end:empty {\n display: none;\n}\n.m3-title-bar-title {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n padding-inline: 4px;\n white-space: nowrap;\n text-overflow: ellipsis;\n font-size: var(--text-title-small, 0.875rem);\n line-height: var(--text-title-small--line-height, 1.25rem);\n font-weight: 500;\n letter-spacing: 0.006em;\n transition: color 150ms;\n}\n/* Centered on the whole bar, not on the room the menus and controls leave; the empty title box still takes that\n room so the end content stays at the end */\n.m3-title-bar-center .m3-title-bar-text {\n position: absolute;\n inset-inline-start: 50%;\n top: 50%;\n max-width: 40%;\n overflow: hidden;\n text-overflow: ellipsis;\n transform: translate(calc(-50% * var(--m3-dir, 1)), -50%);\n pointer-events: none;\n}\n.m3-title-bar-blurred .m3-title-bar-title {\n color: var(--color-on-surface-variant);\n}\n/* What the native buttons' symbols are colored from */\n.m3-title-bar-probe {\n position: absolute;\n width: 0;\n height: 0;\n overflow: hidden;\n color: var(--color-on-surface-variant);\n}\n\n.m3-title-bar-side {\n display: flex;\n flex-shrink: 0;\n}\n.m3-title-bar-controls-start {\n order: -1;\n}\n.m3-title-bar-controls {\n display: flex;\n align-items: center;\n gap: 4px;\n flex-shrink: 0;\n}\n.m3-title-bar-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n border: 0;\n border-radius: 9999px;\n background: transparent;\n color: var(--color-on-surface-variant);\n cursor: default;\n outline: none;\n transition: background-color 150ms, color 150ms;\n}\n.m3-title-bar-btn:hover {\n background-color: color-mix(in srgb, var(--color-on-surface-variant) 8%, transparent);\n}\n.m3-title-bar-btn:active {\n background-color: color-mix(in srgb, var(--color-on-surface-variant) 10%, transparent);\n}\n.m3-title-bar-btn:focus-visible {\n box-shadow: 0 0 0 2px var(--color-secondary);\n}\n.m3-title-bar-btn-close:hover {\n color: var(--color-error);\n background-color: color-mix(in srgb, var(--color-error) 8%, transparent);\n}\n.m3-title-bar-btn-close:active {\n background-color: color-mix(in srgb, var(--color-error) 10%, transparent);\n}\n\n/* Traffic lights: 12px dots 8px apart, glyphs on hover of the group, gray when the window is in the background */\n.m3-title-bar-lights {\n gap: 8px;\n padding-inline: 6px;\n}\n.m3-title-bar-lights .m3-title-bar-btn {\n width: 12px;\n height: 12px;\n color: rgb(0 0 0 / 0.55);\n box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.18);\n}\n.m3-title-bar-lights .m3-title-bar-btn svg {\n width: 8px;\n height: 8px;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.4;\n stroke-linecap: round;\n opacity: 0;\n}\n.m3-title-bar-lights:hover .m3-title-bar-btn svg,\n.m3-title-bar-lights .m3-title-bar-btn:focus-visible svg {\n opacity: 1;\n}\n.m3-title-bar-lights .m3-title-bar-btn-close { background-color: #ff5f57; }\n.m3-title-bar-lights .m3-title-bar-btn-minimize { background-color: #febc2e; }\n.m3-title-bar-lights .m3-title-bar-btn-maximize { background-color: #28c840; }\n.m3-title-bar-lights .m3-title-bar-btn:hover,\n.m3-title-bar-lights .m3-title-bar-btn-close:hover { color: rgb(0 0 0 / 0.55); filter: brightness(0.94); }\n.m3-title-bar-blurred .m3-title-bar-lights:not(:hover) .m3-title-bar-btn {\n background-color: color-mix(in srgb, var(--color-on-surface) 20%, transparent);\n box-shadow: none;\n}\n</style>\n"],"mappings":";;;;AAiDA,SAAS+C,IAA+B;CACtC,OAAO,OAAO,SAAW,MAAe,OAA2DD,KAAc,KAAA;AACnH;AAGA,IAAME,IAAQZ,EAAI,EAAK,GACjBa,IAAWb,EAAgB,QAAQ,GACnCc,IAAWd,EAAI,EAAE,GACjBe,IAAiBf,EAAA,EAA4B,GAC7CgB,IAAYhB,EAAI,EAAK,GACrBiB,IAAajB,EAAI,EAAK,GACtBkB,IAAUlB,EAAI,EAAI,GAClBmB,IAAcnB,EAAmB,IAAI,GACvCoB,IAAQ,GACRC,IAAmC,MACnCC,IAAyC,MACzCC,IAAgC;AAEpC,SAASC,EAAMC,GAAkB;CAC/BT,EAAU,QAAQS,EAAE,WACpBR,EAAW,QAAQQ,EAAE,YACrBP,EAAQ,QAAQO,EAAE;AACpB;AAEA,SAASC,EAAMC,GAAa;CACRN,MAAcM,EAAE,QAAQH,CAAK,GACvBF,MAAoBK,EAAE,YAAYC,MAAM;EAAET,EAAY,QAAQS;CAAE,CAAC,KAAK,MAC9FL,MAAYI,EAAE,KAAK,CAAC,CAAC,MAAME,MAAS;EAC7BA,MACLhB,EAAS,QAAQgB,EAAK,UACtBf,EAAS,QAAQe,EAAK,UACtBd,EAAe,QAAQc,EAAK,gBAC5BV,EAAY,QAAQU,EAAK,eAAe,MACxCL,EAAMK,EAAK,KAAK,GAChBjB,EAAM,QAAQ;CAChB,CAAC,CAAC,CAAC,YAAY;EAAEW,IAAU;CAAK,CAAC;AACnC;AAEA,SAASO,IAAO;CACdT,IAAc,GACdA,IAAc,MACdC,IAAoB,GACpBA,IAAoB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OAJlCrG,EAAA,GAAAO,EAA2LJ,EAAAsC,EAAA,GAAA;;KAApK,MAAMqB,MAAC,aAAA,aAA+BA,MAAC,UAAA,UAAyB3D,EAAAgD,CAAA,KAAahD,EAAAiD,CAAA,IAAU,qBAAA;KAAyC,MAAMU,MAAC,aAAA,KAAA;;;GAa7JgD,EAAA,MAAW,UAAUE,EAAA,SAAhChH,EAAA,GAAAC,EAEM,OAFNqG,IAEM,CADJxF,EAA4FX,EAAAuC,EAAA,GAAA;IAAjF,OAAOoE,EAAA;IAAa,QAAQ;IAAK,UAAQK;IAAe,WAASO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["$slots","_openBlock","_createElementBlock","_normalizeClass","_unref","_normalizeStyle","_createElementVNode","_renderSlot","_createBlock","_createTextVNode","_toDisplayString","_normalizeProps","_guardReactiveProps","_Fragment","_renderList","_createVNode","Fragment","computed","createBlock","createCommentVNode","createElementBlock","createElementVNode","createTextVNode","createVNode","defineComponent","getCurrentScope","guardReactiveProps","nextTick","normalizeClass","normalizeProps","normalizeStyle","onBeforeUnmount","onMounted","onScopeDispose","openBlock","readonly","ref","renderList","renderSlot","toDisplayString","unref","watch","MIcon","MMenuBar","useLocale","useTheme","SPLASH_TOKENS","BRIDGE_KEY","bridge","ready","controls","platform","titleBarHeight","maximized","fullscreen","focused","accentColor","users","unsubscribe","unsubscribeAccent","started","stopColors","readSplashColors","cs","colors","key","token","v","sendSplashColors","b","read","watchColors","timer","later","observer","media","apply","s","start","c","info","stop","useElectronWindow","theme","value","count","menus","listener","status","acceleratorOf","shortcut","tokens","t","names","serializeMenus","picks","next","items","list","menu","i","label","id","check","m","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","MTitleBar_default","__props","__emit","props","emit","locale","revealed","shownMenus","osMenus","menusBelow","contains","item","onMenuSelect","altAlone","onKeydown","onKeyup","bar","hideLater","menubar","onBarKeydown","iconIsImage","win","isMac","ROLE","background","custom","native","menuSet","offClick","pick","data","p","atStart","lights","order","set","a","maximizeLabel","labels","run","onDblclick","probe","raf","until","toHex","css","under","pageColor","hex","sendOverlay","color","symbolColor","follow","ms","step","onScheme","startSync","stopSync","_ctx","_cache","$event"],"sources":["../src/renderer/useElectronWindow.ts","../src/renderer/_nativeMenu.ts","../src/renderer/MTitleBar.vue"],"sourcesContent":["import { computed, onScopeDispose, readonly, ref, getCurrentScope, type ComputedRef, type Ref } from 'vue'\nimport { SPLASH_TOKENS } from '../splashHtml'\nimport { BRIDGE_KEY, DEFAULT_TITLE_BAR_HEIGHT, type M3Bridge, type M3SplashUpdate, type M3NativeMenu, type M3Controls, type M3NativeTheme, type M3OverlayColors, type M3WindowState } from '../shared'\n\n/**\n * The window MTitleBar sits in, from the renderer: its mode and state (reactive) and its buttons. Outside Electron (or\n * without the preload's bridge) `isElectron` is false, nothing is ever `ready` and the actions do nothing, so the same\n * app also runs in a browser.\n */\nexport interface ElectronWindow {\n /** The preload's bridge is there */\n isElectron: boolean\n /** The main process has answered (mode, platform and state are real from here on) */\n ready: Readonly<Ref<boolean>>\n controls: Readonly<Ref<M3Controls>>\n /** `process.platform` of the main process (`''` until ready) */\n platform: Readonly<Ref<string>>\n isMac: ComputedRef<boolean>\n titleBarHeight: Readonly<Ref<number>>\n maximized: Readonly<Ref<boolean>>\n fullscreen: Readonly<Ref<boolean>>\n focused: Readonly<Ref<boolean>>\n /**\n * The system accent color (`#rrggbb`, Windows and macOS; null elsewhere), live. Seed the palette with it:\n * `watchEffect(() => accentColor.value && setSeed(accentColor.value))` with `useColorPalette()`\n */\n accentColor: Readonly<Ref<string | null>>\n minimize(): void\n toggleMaximize(): void\n close(): void\n /** Recolors the native buttons (MTitleBar does it from the theme; for a bar of your own) */\n setOverlay(colors: M3OverlayColors): void\n /** Native UI theme (MTitleBar keeps it in step with `useTheme()`; for an app without the bar) */\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 requestAttention(): void\n /** The preload can set macOS's menu bar (one built before 0.3.0 can't) */\n canSetNativeMenu: boolean\n /** macOS's menu bar from MTitleBar's `menus` (it does this itself in native mode); `null` puts the app's back */\n setNativeMenu(menus: M3NativeMenu[] | null): void\n /** Calls `listener` with the id of a native menu item when chosen; returns the unsubscribe */\n onNativeMenuClick(listener: (id: number) => void): () => void\n /** Updates the bootsplash (`createSplash()` in the main process): its bar (0–1, null for indeterminate) and status */\n splashProgress(value: number | null, status?: string): void\n /** Tells the bootsplash this window is ready to show (with `splash.handoff(win, { waitForRenderer: true })`) */\n splashDone(): void\n /**\n * Keeps the page's theme colors (light or dark, and the palette) for the next launch's bootsplash. Done on its own\n * whenever the theme or the palette changes; call it after changing the tokens some other way\n */\n rememberSplashColors(): void\n}\n\n// The methods added after 0.1.0 are called with ?.(): a preload bundled from an older version (an app that updated\n// the package but not its preload build) must not break the renderer, it just doesn't get those features\nfunction bridge(): M3Bridge | undefined {\n return typeof window !== 'undefined' ? (window as unknown as Record<string, M3Bridge | undefined>)[BRIDGE_KEY] : undefined\n}\n\n// One window per renderer: the state is shared by every caller, fetched once, and kept while anyone uses it\nconst ready = ref(false)\nconst controls = ref<M3Controls>('native')\nconst platform = ref('')\nconst titleBarHeight = ref(DEFAULT_TITLE_BAR_HEIGHT)\nconst maximized = ref(false)\nconst fullscreen = ref(false)\nconst focused = ref(true)\nconst accentColor = ref<string | null>(null)\nlet users = 0\nlet unsubscribe: (() => void) | null = null\nlet unsubscribeAccent: (() => void) | null = null\nlet started: Promise<void> | null = null\nlet stopColors: (() => void) | null = null\n\n/** The splash colors from the page's tokens, and whether it's dark */\nfunction readSplashColors(): { scheme: 'light' | 'dark'; colors: Record<string, string> } | null {\n if (typeof document === 'undefined') return null\n const cs = getComputedStyle(document.documentElement)\n const colors: Record<string, string> = {}\n for (const [key, token] of Object.entries(SPLASH_TOKENS)) {\n const v = cs.getPropertyValue(token).trim()\n if (v) colors[key] = v\n }\n return Object.keys(colors).length ? { scheme: document.documentElement.classList.contains('dark') ? 'dark' : 'light', colors } : null\n}\n\nfunction sendSplashColors(b: M3Bridge) {\n const read = readSplashColors()\n if (read) b.splashColors?.(read.scheme, read.colors)\n}\n\n// Follows theme and palette changes (the class and data-palette on <html>, the system scheme), once they've settled:\n// the tokens animate for a moment when they change\nfunction watchColors(b: M3Bridge) {\n if (stopColors || !b.splashColors || typeof MutationObserver === 'undefined') return\n let timer: ReturnType<typeof setTimeout> | undefined\n const later = () => { clearTimeout(timer); timer = setTimeout(() => sendSplashColors(b), 800) }\n const observer = new MutationObserver(later)\n observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class', 'style', 'data-palette', 'data-theme', 'data-contrast'] })\n const media = window.matchMedia?.('(prefers-color-scheme: dark)')\n media?.addEventListener?.('change', later)\n later()\n stopColors = () => {\n clearTimeout(timer)\n observer.disconnect()\n media?.removeEventListener?.('change', later)\n }\n}\n\nfunction apply(s: M3WindowState) {\n maximized.value = s.maximized\n fullscreen.value = s.fullscreen\n focused.value = s.focused\n}\n\nfunction start(b: M3Bridge) {\n if (!unsubscribe) unsubscribe = b.onState(apply)\n if (!unsubscribeAccent) unsubscribeAccent = b.onAccent?.((c) => { accentColor.value = c }) ?? null\n watchColors(b)\n started ??= b.info().then((info) => {\n if (!info) return\n controls.value = info.controls\n platform.value = info.platform\n titleBarHeight.value = info.titleBarHeight\n accentColor.value = info.accentColor ?? null\n apply(info.state)\n ready.value = true\n }).catch(() => { started = null })\n}\n\nfunction stop() {\n unsubscribe?.()\n unsubscribe = null\n unsubscribeAccent?.()\n unsubscribeAccent = null\n stopColors?.()\n stopColors = null\n}\n\nexport function useElectronWindow(): ElectronWindow {\n const b = bridge()\n if (b) {\n users++\n start(b)\n if (getCurrentScope()) onScopeDispose(() => { if (--users === 0) stop() })\n }\n return {\n isElectron: !!b,\n ready: readonly(ready),\n controls: readonly(controls),\n platform: readonly(platform),\n isMac: computed(() => platform.value === 'darwin'),\n titleBarHeight: readonly(titleBarHeight),\n maximized: readonly(maximized),\n fullscreen: readonly(fullscreen),\n focused: readonly(focused),\n accentColor: readonly(accentColor),\n minimize: () => b?.action('minimize'),\n toggleMaximize: () => b?.action('toggle-maximize'),\n close: () => b?.action('close'),\n setOverlay: (colors) => b?.setOverlay(colors),\n setTheme: (theme) => b?.setTheme?.(theme),\n setProgress: (value) => b?.setProgress?.(value),\n setBadge: (count) => b?.setBadge?.(count),\n requestAttention: () => b?.attention?.(),\n canSetNativeMenu: typeof b?.setMenu === 'function',\n setNativeMenu: (menus) => b?.setMenu?.(menus),\n onNativeMenuClick: (listener) => b?.onMenuClick?.(listener) ?? (() => {}),\n splashProgress: (value, status) => b?.splash?.(status === undefined ? { progress: value } : { progress: value, status } satisfies M3SplashUpdate),\n splashDone: () => b?.splashDone?.(),\n rememberSplashColors: () => { if (b) sendSplashColors(b) },\n }\n}\n\n/** For tests: forget the fetched state */\nexport function _resetElectronWindow() {\n stop()\n users = 0\n started = null\n ready.value = false\n controls.value = 'native'\n platform.value = ''\n titleBarHeight.value = DEFAULT_TITLE_BAR_HEIGHT\n maximized.value = false\n fullscreen.value = false\n focused.value = true\n accentColor.value = null\n}\n","import type { MenuBarItem, MenuBarMenu } from '@m3ui-vue/m3ui-vue'\nimport type { M3NativeMenu, M3NativeMenuItem } from '../shared'\n\n/**\n * MMenuBar's shortcut hint (`'Ctrl+S'`, `'⌘S'`) as an Electron accelerator: Ctrl and ⌘ become `CmdOrCtrl`. A native\n * menu binds it: the key runs the item's `onSelect`.\n */\nexport function acceleratorOf(shortcut?: string): string | undefined {\n if (!shortcut) return undefined\n const tokens = shortcut.replace(/([⌘⇧⌥⌃])/g, '$1+').split('+').map((t) => t.trim()).filter(Boolean)\n const names: Record<string, string> = { '⌘': 'CmdOrCtrl', '⌃': 'CmdOrCtrl', '⇧': 'Shift', '⌥': 'Alt' }\n return tokens.map((t) => names[t] ?? (/^(ctrl|control|cmd|command)$/i.test(t) ? 'CmdOrCtrl' : /^option$/i.test(t) ? 'Alt' : t)).join('+')\n}\n\n/**\n * The menus as plain data for the main process, and what each id stands for (the item and its menu's index), to run\n * it when main says it was clicked\n */\nexport function serializeMenus(menus: MenuBarMenu[]): { data: M3NativeMenu[]; picks: Map<number, [MenuBarItem, number]> } {\n const picks = new Map<number, [MenuBarItem, number]>()\n let next = 1\n const items = (list: MenuBarItem[], menu: number): M3NativeMenuItem[] => list.map((i): M3NativeMenuItem => {\n if (i.divider) return { type: 'separator' }\n const label = i.label ?? ''\n if (i.children) return { type: 'submenu', label, enabled: !i.disabled, items: items(i.children, menu) }\n const id = next++\n picks.set(id, [i, menu])\n // A check mark for both: a radio item would make macOS uncheck its neighbors on its own\n const check = i.checked !== undefined || i.selected !== undefined\n return { type: check ? 'checkbox' : 'normal', id, label, enabled: !i.disabled, ...(check ? { checked: !!(i.checked ?? i.selected) } : {}), accelerator: acceleratorOf(i.shortcut) }\n })\n return { data: menus.map((m, i) => ({ label: m.label, enabled: !m.disabled, items: items(m.items, i) })), picks }\n}\n","<script setup lang=\"ts\">\n/**\n * MTitleBar — the window's title bar for an Electron app, in M3: drags the window, double-click maximizes, and holds\n * the title plus anything you put at its start or end. The controls mode comes from the main process\n * (`m3WindowOptions({ controls })`), not a prop, so the two can't disagree:\n * - `native`: the system draws the buttons over the bar (Windows 11 snap layouts, macOS traffic lights) and the bar\n * leaves their room free; their colors follow the bar's background and the theme live, palette changes included.\n * - `custom`: a frameless window; the bar draws M3 buttons (or traffic lights), on the side and with the buttons\n * you choose, or your own through `#controls`.\n * Outside Electron it renders as a plain bar without buttons, so the same app runs in a browser.\n *\n * @slot default The title (replaces `title`)\n * @slot start Content after the icon and the menus (a back button, a breadcrumb…)\n * @slot end Content before the trailing controls (a search field, account button…)\n * @slot controls Replaces the custom controls (`{ minimize, toggleMaximize, close, maximized, focused }`)\n * @slot icon Replaces the app icon\n * @event menu-select Emitted with the menu item chosen (and its menu's index), as MMenuBar's `select`\n */\nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { MIcon, MMenuBar, useLocale, useTheme, type MenuBarItem, type MenuBarMenu } from '@m3ui-vue/m3ui-vue'\nimport { useElectronWindow } from './useElectronWindow'\nimport { serializeMenus } from './_nativeMenu'\n\ntype Button = 'minimize' | 'maximize' | 'close'\n\nconst props = withDefaults(\n defineProps<{\n /** The window title */\n title?: string\n /**\n * The app icon at the start: an image URL (`'/icon.png'`, an import, a data: URL) or a Material Symbol name.\n * Clicking it does nothing (the `#icon` slot takes a button of yours)\n */\n icon?: string\n /** Menus (File, Edit…) after the icon, as an MMenuBar: items with submenus, dividers, checks, shortcut hints */\n menus?: MenuBarMenu[]\n /** `inline`: the menus sit in the title bar, after the icon. `below`: in a row of their own under it (classic) */\n menusPosition?: 'inline' | 'below'\n /**\n * Like VS Code's \"menu bar visibility\": `visible`; `compact`, one ☰ button in the bar holding every menu;\n * `toggle`, hidden until Alt is pressed (and hidden again after a pick, Esc or a click elsewhere); `hidden`\n */\n menusVisibility?: 'visible' | 'compact' | 'toggle' | 'hidden'\n /** Bar color: an M3 role (`'surface-container'`) or any CSS color */\n color?: string\n /** Where the title sits */\n titleAlign?: 'start' | 'center'\n /** Custom controls only: which buttons, in this order on the end side (mirrored on the start side) */\n buttons?: Button[]\n /** Custom controls only: the side they sit on; `auto` is the start on macOS, the end elsewhere */\n side?: 'auto' | 'start' | 'end'\n /** Custom controls only: M3 icon buttons or macOS-style traffic lights; `auto` picks by platform */\n look?: 'auto' | 'm3' | 'traffic-lights'\n /**\n * Keep the native UI's theme (dialogs, context menus, scrollbars, macOS's frame) on the app's `useTheme()`\n * choice: light, dark or system\n */\n syncNativeTheme?: boolean\n }>(),\n { color: 'surface', titleAlign: 'start', buttons: () => ['minimize', 'maximize', 'close'], side: 'auto', look: 'auto', syncNativeTheme: true, menusPosition: 'inline', menusVisibility: 'visible' },\n)\n\nconst emit = defineEmits<{ 'menu-select': [item: MenuBarItem, menu: number] }>()\n\nconst locale = useLocale()\n// ── Menus ─────────────────────────────────────────────────────────────────────────────────────────────────────\nconst revealed = ref(false) // toggle mode: shown by Alt\nconst shownMenus = computed<MenuBarMenu[]>(() => {\n const menus = props.menus ?? []\n if (osMenus.value) return [] // macOS's menu bar has them\n if (!menus.length || props.menusVisibility === 'hidden') return []\n if (props.menusVisibility === 'toggle' && !revealed.value) return []\n if (props.menusVisibility === 'compact') {\n return [{ label: locale.appMenuLabel, icon: 'menu', items: menus.map((m) => ({ label: m.label, disabled: m.disabled, children: m.items })) }]\n }\n return menus\n})\n// The ☰ button always sits in the bar; a row below for it alone would waste a row\nconst menusBelow = computed(() => props.menusPosition === 'below' && props.menusVisibility !== 'compact')\n\nconst contains = (items: MenuBarItem[], item: MenuBarItem): boolean => items.some((i) => i === item || (!!i.children && contains(i.children, item)))\nfunction onMenuSelect(item: MenuBarItem) {\n // The index in `menus`, also from the compact button (where MMenuBar only sees one menu)\n emit('menu-select', item, Math.max(0, (props.menus ?? []).findIndex((m) => contains(m.items, item))))\n if (props.menusVisibility === 'toggle') revealed.value = false\n}\n\n// Alt pressed and released alone shows the menus and focuses the first one, as on Windows and Linux\nlet altAlone = false\nfunction onKeydown(e: KeyboardEvent) {\n altAlone = e.key === 'Alt' && !e.repeat && !e.ctrlKey && !e.shiftKey && !e.metaKey\n}\nfunction onKeyup(e: KeyboardEvent) {\n if (e.key !== 'Alt' || !altAlone || props.menusVisibility !== 'toggle' || !props.menus?.length) return\n altAlone = false\n e.preventDefault()\n revealed.value = !revealed.value\n if (revealed.value) void nextTick(() => bar.value?.querySelector<HTMLElement>('.m3-menu-bar [role=\"menuitem\"]')?.focus())\n}\n// Hidden again once nothing in it is open or focused (a click elsewhere, Esc on a title, Tab away)\nfunction hideLater() {\n if (!revealed.value) return\n setTimeout(() => {\n const menubar = bar.value?.querySelector('.m3-menu-bar')\n if (!menubar) return\n if (menubar.querySelector('[aria-expanded=\"true\"]') || menubar.contains(document.activeElement)) return\n revealed.value = false\n }, 0)\n}\nfunction onBarKeydown(e: KeyboardEvent) {\n if (e.key !== 'Escape' || !revealed.value) return\n const t = e.target as Element\n if (t.closest('.m3-menu-bar') && t.getAttribute('aria-expanded') !== 'true') revealed.value = false\n}\nwatch(() => props.menusVisibility, () => { revealed.value = false })\nonMounted(() => {\n window.addEventListener('keydown', onKeydown, true)\n window.addEventListener('keyup', onKeyup, true)\n document.addEventListener('pointerdown', hideLater, true)\n document.addEventListener('focusin', hideLater)\n})\nonBeforeUnmount(() => {\n window.removeEventListener('keydown', onKeydown, true)\n window.removeEventListener('keyup', onKeyup, true)\n document.removeEventListener('pointerdown', hideLater, true)\n document.removeEventListener('focusin', hideLater)\n})\n\n// An image when it looks like one (a path, a URL, a file name), a Material Symbol otherwise\nconst iconIsImage = computed(() => !!props.icon && /[/.:]/.test(props.icon))\nconst win = useElectronWindow()\nconst { controls, maximized, focused, fullscreen, isMac, titleBarHeight } = win\n\nconst ROLE = /^[a-z]+(-[a-z]+)*$/\nconst background = computed(() => (ROLE.test(props.color) ? `var(--color-${props.color})` : props.color))\nconst custom = computed(() => win.isElectron && controls.value === 'custom')\nconst native = computed(() => win.isElectron && controls.value === 'native')\n\n// ── Native menus (macOS) ─────────────────────────────────────────────────────────────────────────────────────\n// With native controls on macOS the menus go to the menu bar at the top of the screen, like every Mac app's.\n// Elsewhere the native mode has no system title bar to hold a menu, so they stay in this bar as an MMenuBar.\nconst osMenus = computed(() => native.value && isMac.value && win.canSetNativeMenu && !!props.menus?.length)\nlet picks = new Map<number, [MenuBarItem, number]>()\nlet menuSet = false\nconst offClick = win.onNativeMenuClick((id) => {\n const pick = picks.get(id)\n if (!pick) return\n pick[0].onSelect?.()\n emit('menu-select', pick[0], pick[1])\n})\nwatch([osMenus, () => props.menus], () => {\n if (osMenus.value) {\n const { data, picks: p } = serializeMenus(props.menus!)\n picks = p\n win.setNativeMenu(data)\n menuSet = true\n } else if (menuSet) {\n win.setNativeMenu(null)\n menuSet = false\n }\n}, { immediate: true })\nonBeforeUnmount(() => {\n offClick()\n if (menuSet) win.setNativeMenu(null)\n})\nconst atStart = computed(() => (props.side === 'auto' ? isMac.value : props.side === 'start'))\nconst lights = computed(() => (props.look === 'auto' ? isMac.value : props.look === 'traffic-lights'))\nconst order = computed<Button[]>(() => {\n const set = props.buttons.filter((b, i, a) => a.indexOf(b) === i)\n // Traffic lights always read close, minimize, maximize; M3 buttons put close at the outer edge\n if (lights.value) return (['close', 'minimize', 'maximize'] as Button[]).filter((b) => set.includes(b))\n return atStart.value ? [...set].reverse() : set\n})\nconst maximizeLabel = computed(() => (maximized.value || fullscreen.value ? locale.windowRestore : locale.windowMaximize))\nconst labels = computed<Record<Button, string>>(() => ({ minimize: locale.windowMinimize, maximize: maximizeLabel.value, close: locale.close }))\nconst run = (b: Button) => (b === 'minimize' ? win.minimize() : b === 'maximize' ? win.toggleMaximize() : win.close())\n\n// Double-click on the bar itself (not on its content) maximizes, as on every desktop. Native title bars do it on\n// their own over the drag region; frameless ones on Linux don't\nfunction onDblclick(e: MouseEvent) {\n if (!custom.value) return\n if ((e.target as Element).closest('button, a, input, select, textarea, [role=\"button\"], [data-no-drag]')) return\n win.toggleMaximize()\n}\n\n// ── Native buttons follow the theme ────────────────────────────────────────────────────────────────────────────\n// They aren't CSS, so on every theme or palette change (and while its transition runs, ~300ms) the bar's computed\n// colors are sent each frame; main skips the ones that didn't change. macOS's traffic lights have fixed colors.\nconst bar = ref<HTMLElement>()\nconst probe = ref<HTMLElement>()\nlet raf = 0\nlet until = 0\nlet observer: MutationObserver | null = null\nlet media: MediaQueryList | null = null\n\nfunction toHex(css: string, under?: [number, number, number]): string | null {\n const m = /rgba?\\(\\s*([\\d.]+)[\\s,]+([\\d.]+)[\\s,]+([\\d.]+)(?:[\\s,/]+([\\d.]+%?))?/.exec(css)\n if (!m) return null\n let a = m[4] == null ? 1 : m[4].endsWith('%') ? parseFloat(m[4]) / 100 : parseFloat(m[4])\n const c = [+m[1]!, +m[2]!, +m[3]!]\n // A see-through bar: blend it over what's under it (the page), since the overlay can't be translucent\n if (a < 1 && under) c.forEach((v, i) => (c[i] = v * a + under[i]! * (1 - a)))\n else a = 1\n return `#${c.map((v) => Math.round(Math.min(255, Math.max(0, v))).toString(16).padStart(2, '0')).join('')}`\n}\n\nfunction pageColor(): [number, number, number] {\n const hex = toHex(getComputedStyle(document.body).backgroundColor) ?? toHex(getComputedStyle(document.documentElement).backgroundColor) ?? '#ffffff'\n return [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16)) as [number, number, number]\n}\n\nfunction sendOverlay() {\n if (!bar.value || !probe.value) return\n const color = toHex(getComputedStyle(bar.value).backgroundColor, pageColor())\n const symbolColor = toHex(getComputedStyle(probe.value).color)\n if (color && symbolColor) win.setOverlay({ color, symbolColor })\n}\n\nfunction follow(ms = 600) {\n if (!native.value || isMac.value) return\n until = performance.now() + ms\n if (raf) return\n const step = () => {\n sendOverlay()\n raf = performance.now() < until ? requestAnimationFrame(step) : 0\n }\n step()\n}\nconst onScheme = () => follow()\n\nfunction startSync() {\n if (observer || !native.value || isMac.value) return\n follow()\n observer = new MutationObserver(() => follow())\n observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class', 'style', 'data-palette', 'data-theme'] })\n media = window.matchMedia?.('(prefers-color-scheme: dark)') ?? null\n media?.addEventListener?.('change', onScheme)\n}\n\nfunction stopSync() {\n observer?.disconnect()\n observer = null\n media?.removeEventListener?.('change', onScheme)\n media = null\n cancelAnimationFrame(raf)\n raf = 0\n}\n\nonMounted(() => { if (win.ready.value) startSync() })\nwatch([win.ready, native, isMac], () => { stopSync(); if (win.ready.value) startSync() })\nwatch(() => props.color, () => follow())\n\nconst { theme } = useTheme()\nwatch([theme, () => props.syncNativeTheme, win.ready], () => {\n if (props.syncNativeTheme && win.ready.value) win.setTheme(theme.value)\n}, { immediate: true })\nonBeforeUnmount(stopSync)\n</script>\n\n<template>\n <header\n ref=\"bar\"\n class=\"m3-title-bar\"\n :class=\"{ 'm3-title-bar-native': native, 'm3-title-bar-blurred': !focused, 'm3-title-bar-center': titleAlign === 'center' }\"\n :style=\"{ background }\"\n :data-controls=\"win.isElectron ? controls : undefined\"\n >\n <span ref=\"probe\" class=\"m3-title-bar-probe\" aria-hidden=\"true\" />\n <div class=\"m3-title-bar-row\" :style=\"{ height: `${titleBarHeight}px` }\" @dblclick=\"onDblclick\">\n <div class=\"m3-title-bar-area\">\n <div v-if=\"icon || $slots.icon\" class=\"m3-title-bar-icon\">\n <slot name=\"icon\">\n <img v-if=\"iconIsImage\" :src=\"icon\" alt=\"\" draggable=\"false\" />\n <MIcon v-else :name=\"icon!\" :size=\"20\" />\n </slot>\n </div>\n <MMenuBar v-if=\"shownMenus.length && !menusBelow\" :menus=\"shownMenus\" :height=\"Math.min(32, titleBarHeight - 8)\" class=\"m3-title-bar-menus\" @select=\"onMenuSelect\" @keydown=\"onBarKeydown\" />\n <div class=\"m3-title-bar-start\"><slot name=\"start\" /></div>\n <div class=\"m3-title-bar-title\"><span class=\"m3-title-bar-text\"><slot>{{ title }}</slot></span></div>\n <div class=\"m3-title-bar-end\"><slot name=\"end\" /></div>\n\n <!-- One set of controls (yours or ours); on the start side it moves first with `order` -->\n <div v-if=\"custom\" class=\"m3-title-bar-side\" :class=\"atStart && 'm3-title-bar-controls-start'\">\n <slot name=\"controls\" v-bind=\"{ minimize: win.minimize, toggleMaximize: win.toggleMaximize, close: win.close, maximized, focused }\">\n <div class=\"m3-title-bar-controls\" :class=\"lights && 'm3-title-bar-lights'\">\n <button\n v-for=\"b in order\"\n :key=\"b\"\n type=\"button\"\n :class=\"['m3-title-bar-btn', `m3-title-bar-btn-${b}`]\"\n :aria-label=\"labels[b]\"\n :title=\"labels[b]\"\n @click=\"run(b)\"\n >\n <MIcon v-if=\"!lights\" :name=\"b === 'minimize' ? 'minimize' : b === 'close' ? 'close' : maximized || fullscreen ? 'close_fullscreen' : 'open_in_full'\" :size=\"b === 'maximize' ? 16 : 18\" />\n <svg v-else viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <path v-if=\"b === 'close'\" d=\"M3.5 3.5l5 5M8.5 3.5l-5 5\" />\n <path v-else-if=\"b === 'minimize'\" d=\"M3 6h6\" />\n <path v-else d=\"M6 3v6M3 6h6\" />\n </svg>\n </button>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <!-- The classic menu row: not a drag area, like every app's -->\n <div v-if=\"shownMenus.length && menusBelow\" class=\"m3-title-bar-menu-row\">\n <MMenuBar :menus=\"shownMenus\" :height=\"32\" @select=\"onMenuSelect\" @keydown=\"onBarKeydown\" />\n </div>\n </header>\n</template>\n\n<style>\n/* Plain CSS on the M3 tokens: the lib's Tailwind build doesn't scan this package, so no utility classes here */\n@layer base {\n .m3-title-bar {\n position: relative;\n display: block;\n flex-shrink: 0;\n width: 100%;\n color: var(--color-on-surface);\n user-select: none;\n -webkit-user-select: none;\n app-region: drag;\n -webkit-app-region: drag;\n }\n}\n.m3-title-bar :is(button, a, input, select, textarea, [role='button'], [contenteditable], [data-no-drag]) {\n app-region: no-drag;\n -webkit-app-region: no-drag;\n}\n.m3-title-bar-row {\n position: relative;\n}\n.m3-title-bar-menu-row {\n display: flex;\n align-items: center;\n padding: 0 8px 4px;\n app-region: no-drag;\n -webkit-app-region: no-drag;\n}\n.m3-title-bar-area {\n display: flex;\n align-items: center;\n gap: 8px;\n height: 100%;\n padding-inline: 8px;\n box-sizing: border-box;\n}\n/* The system's buttons sit over the bar: keep to the area Window Controls Overlay leaves free */\n.m3-title-bar-native .m3-title-bar-area {\n /* not positioned, so a centered title centers on the whole row, not on this area */\n margin-left: env(titlebar-area-x, 0px);\n width: env(titlebar-area-width, 100%);\n}\n.m3-title-bar-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 28px;\n color: var(--color-primary);\n}\n.m3-title-bar-icon img {\n width: 20px;\n height: 20px;\n object-fit: contain;\n pointer-events: none;\n}\n.m3-title-bar-menus {\n flex-shrink: 0;\n}\n.m3-title-bar-start,\n.m3-title-bar-end {\n display: flex;\n align-items: center;\n gap: 4px;\n min-width: 0;\n}\n.m3-title-bar-start:empty,\n.m3-title-bar-end:empty {\n display: none;\n}\n.m3-title-bar-title {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n padding-inline: 4px;\n white-space: nowrap;\n text-overflow: ellipsis;\n font-size: var(--text-title-small, 0.875rem);\n line-height: var(--text-title-small--line-height, 1.25rem);\n font-weight: 500;\n letter-spacing: 0.006em;\n transition: color 150ms;\n}\n/* Centered on the whole bar, not on the room the menus and controls leave; the empty title box still takes that\n room so the end content stays at the end */\n.m3-title-bar-center .m3-title-bar-text {\n position: absolute;\n inset-inline-start: 50%;\n top: 50%;\n max-width: 40%;\n overflow: hidden;\n text-overflow: ellipsis;\n transform: translate(calc(-50% * var(--m3-dir, 1)), -50%);\n pointer-events: none;\n}\n.m3-title-bar-blurred .m3-title-bar-title {\n color: var(--color-on-surface-variant);\n}\n/* What the native buttons' symbols are colored from */\n.m3-title-bar-probe {\n position: absolute;\n width: 0;\n height: 0;\n overflow: hidden;\n color: var(--color-on-surface-variant);\n}\n\n.m3-title-bar-side {\n display: flex;\n flex-shrink: 0;\n}\n.m3-title-bar-controls-start {\n order: -1;\n}\n.m3-title-bar-controls {\n display: flex;\n align-items: center;\n gap: 4px;\n flex-shrink: 0;\n}\n.m3-title-bar-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n border: 0;\n border-radius: 9999px;\n background: transparent;\n color: var(--color-on-surface-variant);\n cursor: default;\n outline: none;\n transition: background-color 150ms, color 150ms;\n}\n.m3-title-bar-btn:hover {\n background-color: color-mix(in srgb, var(--color-on-surface-variant) 8%, transparent);\n}\n.m3-title-bar-btn:active {\n background-color: color-mix(in srgb, var(--color-on-surface-variant) 10%, transparent);\n}\n.m3-title-bar-btn:focus-visible {\n box-shadow: 0 0 0 2px var(--color-secondary);\n}\n.m3-title-bar-btn-close:hover {\n color: var(--color-error);\n background-color: color-mix(in srgb, var(--color-error) 8%, transparent);\n}\n.m3-title-bar-btn-close:active {\n background-color: color-mix(in srgb, var(--color-error) 10%, transparent);\n}\n\n/* Traffic lights: 12px dots 8px apart, glyphs on hover of the group, gray when the window is in the background */\n.m3-title-bar-lights {\n gap: 8px;\n padding-inline: 6px;\n}\n.m3-title-bar-lights .m3-title-bar-btn {\n width: 12px;\n height: 12px;\n color: rgb(0 0 0 / 0.55);\n box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.18);\n}\n.m3-title-bar-lights .m3-title-bar-btn svg {\n width: 8px;\n height: 8px;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.4;\n stroke-linecap: round;\n opacity: 0;\n}\n.m3-title-bar-lights:hover .m3-title-bar-btn svg,\n.m3-title-bar-lights .m3-title-bar-btn:focus-visible svg {\n opacity: 1;\n}\n.m3-title-bar-lights .m3-title-bar-btn-close { background-color: #ff5f57; }\n.m3-title-bar-lights .m3-title-bar-btn-minimize { background-color: #febc2e; }\n.m3-title-bar-lights .m3-title-bar-btn-maximize { background-color: #28c840; }\n.m3-title-bar-lights .m3-title-bar-btn:hover,\n.m3-title-bar-lights .m3-title-bar-btn-close:hover { color: rgb(0 0 0 / 0.55); filter: brightness(0.94); }\n.m3-title-bar-blurred .m3-title-bar-lights:not(:hover) .m3-title-bar-btn {\n background-color: color-mix(in srgb, var(--color-on-surface) 20%, transparent);\n box-shadow: none;\n}\n</style>\n"],"mappings":";;;;;AA2DA,SAASgD,IAA+B;CACtC,OAAO,OAAO,SAAW,MAAe,OAA2DD,KAAc,KAAA;AACnH;AAGA,IAAME,IAAQb,EAAI,EAAK,GACjBc,IAAWd,EAAgB,QAAQ,GACnCe,IAAWf,EAAI,EAAE,GACjB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C,CAAA,GAAA;IAAjF,OAAOmF,EAAA;IAAa,QAAQ;IAAK,UAAQK;IAAe,WAASO"}
|
package/dist/main.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("node:fs"),t=require("node:path"),n=require("electron");const r=require("./shared-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("node:fs"),t=require("node:path"),n=require("electron");const r=require("./shared-DS-DQqb1.cjs"),i=require("./splash-html.cjs");var a=`m3-splash.json`,o=()=>(0,t.join)(n.app.getPath(`userData`),a);function s(){try{return JSON.parse((0,e.readFileSync)(o(),`utf8`))}catch{return{}}}var c=e=>Object.fromEntries(Object.entries(e??{}).filter(([e,t])=>e in i.SPLASH_BASELINE.light&&i.isSafeColor(t)));function l(t,n){let r=s(),i=c(n);if(JSON.stringify(r[t])!==JSON.stringify(i)){r[t]=i;try{(0,e.writeFileSync)(o(),JSON.stringify(r))}catch{}}}var u={".png":`image/png`,".svg":`image/svg+xml`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".webp":`image/webp`,".ico":`image/x-icon`,".gif":`image/gif`};function d(n){if(n){if(/^(data:|https?:)/i.test(n))return n;try{return`data:${u[(0,t.extname)(n).toLowerCase()]??`image/png`};base64,${(0,e.readFileSync)(n).toString(`base64`)}`}catch{return}}}function f(e,t){let n=e===`banner`?t.primaryContainer:e===`immersive`?t.primary:t.surface;return/^#[0-9a-f]{6}$/i.test(n)?n:void 0}var p=null,m=!1;function h(){m||(m=!0,n.ipcMain.on(r.n.splash,(e,t)=>p?.update(t)),n.ipcMain.on(r.n.splashDone,e=>{let t=n.BrowserWindow.fromWebContents(e.sender);t&&p?.done(t)}),n.ipcMain.on(r.n.splashColors,(e,t,n)=>{(t===`light`||t===`dark`)&&n&&typeof n==`object`&&l(t,n)}))}function g(){h()}var _={color:`#fef7ff`,symbolColor:`#49454f`};function v(e={}){return{controls:e.controls===`custom`?`custom`:`native`,titleBarHeight:Math.max(24,Math.round(e.titleBarHeight??40)),overlay:{..._,...e.overlay},bounds:e.rememberBounds?`m3-window${typeof e.rememberBounds==`string`?`-${e.rememberBounds.replace(/[^\w-]/g,`_`)}`:``}.json`:null,externalLinks:e.externalLinks!==!1}}var y=e=>(0,t.join)(n.app.getPath(`userData`),e);function b(t){try{let n=JSON.parse((0,e.readFileSync)(y(t),`utf8`));return[n.x,n.y,n.width,n.height].every(Number.isFinite)?n:null}catch{return null}}function x(e){let t=b(e);return t?n.screen.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:{width:t.width,height:t.height,maximized:t.maximized}:{}}var S=new Map,C=!1,w=()=>{try{let e=process.platform===`win32`||process.platform===`darwin`?n.systemPreferences.getAccentColor():``;return/^[0-9a-f]{6}/i.test(e)?`#${e.slice(0,6).toLowerCase()}`:null}catch{return null}},T=e=>({maximized:e.isMaximized(),fullscreen:e.isFullScreen(),focused:e.isFocused()});function E(e){return S.get(e.id)}function D(){C||(C=!0,n.ipcMain.handle(r.n.info,e=>{let t=E(e.sender);return t?{controls:t.o.controls,platform:process.platform,titleBarHeight:t.o.titleBarHeight,state:T(t.win),accentColor:w()}:null}),n.ipcMain.on(r.n.action,(e,t)=>{let n=E(e.sender);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())}),n.ipcMain.on(r.n.overlay,(e,t)=>{let n=E(e.sender);if(!n||n.win.isDestroyed()||n.o.controls!==`native`||process.platform===`darwin`||!j(t?.color)||!j(t?.symbolColor))return;let r=`${t.color}|${t.symbolColor}`;r!==n.overlay&&(n.overlay=r,n.win.setTitleBarOverlay({color:t.color,symbolColor:t.symbolColor,height:n.o.titleBarHeight}))}),n.ipcMain.on(r.n.theme,(e,t)=>{E(e.sender)&&[`light`,`dark`,`system`].includes(t)&&n.nativeTheme.themeSource!==t&&(n.nativeTheme.themeSource=t)}),n.ipcMain.on(r.n.progress,(e,t)=>{let n=E(e.sender);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))}),n.ipcMain.on(r.n.badge,(e,t)=>{E(e.sender)&&n.app.setBadgeCount(Math.max(0,Math.floor(Number(t)||0)))}),n.ipcMain.on(r.n.attention,e=>{let t=E(e.sender);!t||t.win.isDestroyed()||t.win.isFocused()||(process.platform===`darwin`?n.app.dock?.bounce(`informational`):(t.win.flashFrame(!0),t.win.once(`focus`,()=>{t.win.isDestroyed()||t.win.flashFrame(!1)})))}),n.ipcMain.on(r.n.menu,(e,t)=>{if(!E(e.sender)||process.platform!==`darwin`)return;if(A??={menu:n.Menu.getApplicationMenu()},!Array.isArray(t))return n.Menu.setApplicationMenu(A.menu);let i=e.sender,a=e=>()=>{i.isDestroyed()||i.send(r.n.menuClick,e)},o=e=>e.type===`separator`?{type:`separator`}:e.type===`submenu`?{label:e.label,enabled:e.enabled,submenu:e.items.map(o)}:{type:e.type,label:e.label,enabled:e.enabled,checked:e.checked,accelerator:e.accelerator,click:a(e.id)},s=t.map(e=>({label:e.label,enabled:e.enabled,submenu:e.items.map(o)})),c=t.some(e=>k.test(e.label.trim()))?[]:[{role:`editMenu`}];n.Menu.setApplicationMenu(n.Menu.buildFromTemplate([{role:`appMenu`},...c,...s]))}),n.systemPreferences.on?.(`accent-color-changed`,()=>{for(let{win:e}of S.values())e.isDestroyed()||e.webContents.send(r.n.accent,w())}))}var O=/^(https?|mailto):/i,k=/^(edit|editar|édition|edition|bearbeiten|modifica|編集|编辑|編輯|편집|تحرير|edycja)$/i,A,j=e=>typeof e==`string`&&/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e);exports.createSplash=function(e={}){h();let t=e.theme===`light`||e.theme===`dark`?e.theme:n.nativeTheme.shouldUseDarkColors?`dark`:`light`,r=e.colors??{},a=`light`in r||`dark`in r?r[t]:r,o={...i.SPLASH_BASELINE[t],...c(a),...e.remember===!1?{}:c(s()[t])},l=e.rounded??process.platform!==`linux`,u=i.SPLASH_PRESETS.includes(e.preset)?e.preset:`classic`,m=Math.round(e.width??i.SPLASH_SIZES[u].width),g=Math.round(e.height??i.SPLASH_SIZES[u].height),_=Math.max(0,Math.round(e.duration??0)),v=Math.max(0,e.minDuration??700,_),y=new n.BrowserWindow({width:m,height:g,show:!1,frame:!1,resizable:!1,maximizable:!1,minimizable:!1,fullscreenable:!1,center:!0,title:e.title??n.app.getName(),transparent:l,hasShadow:!l||process.platform===`darwin`,backgroundColor:l?`#00000000`:f(u,o),webPreferences:{sandbox:!0,contextIsolation:!0,nodeIntegration:!1,devTools:!1,backgroundThrottling:!1}});y.setMenu?.(null);let b=0,x,S=new Promise(e=>{x=e});y.once(`ready-to-show`,()=>{y.isDestroyed()||(y.show(),b=Date.now(),x())}),y.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(i.splashHtml({title:e.title??n.app.getName(),logo:d(e.logo),logoSize:Math.max(16,Math.round(e.logoSize??i.SPLASH_LOGO_SIZES[u])),preset:u,indicator:e.indicator===`linear`?`linear`:`wavy`,status:e.status??``,progress:e.progress??null,colors:o,fontFamily:e.fontFamily??`system-ui, sans-serif`,rounded:l,footer:e.footer??``,fill:_}))}`);let C=e=>{if(y.isDestroyed())return;let t=()=>{y.isDestroyed()||y.webContents.executeJavaScript(`window.m3splash&&window.m3splash.set(${JSON.stringify(e)})`).catch(()=>{})};y.webContents.isLoading()?y.webContents.once(`did-finish-load`,t):t()},w=null,T=()=>(w??=(async()=>{if(p===O&&(p=null),!y.isDestroyed()){try{await y.webContents.executeJavaScript(`window.m3splash?window.m3splash.exit():0`)}catch{}y.isDestroyed()||y.destroy()}})(),w),E=new Set,D=null,O={update(e){let t={};e&&`progress`in e&&(t.progress=typeof e.progress==`number`&&Number.isFinite(e.progress)?e.progress:null),e&&typeof e.status==`string`&&(t.status=e.status.slice(0,200)),C(t)},done(e){D?.id===e.id?D.resolve():E.add(e.id)}};return p=O,{window:y,progress:(e,t)=>O.update(t===void 0?{progress:e}:{progress:e,status:t}),status:e=>O.update({status:e}),async handoff(e,t={}){let n=t.waitForRenderer?new Promise(t=>{E.has(e.id)?t():D={id:e.id,resolve:t}}):new Promise(t=>{e.isVisible()?t():e.once(`ready-to-show`,()=>t())}),r=new Promise(t=>e.once(`closed`,()=>t())),i=e=>new Promise(t=>setTimeout(t,e));if(await Promise.race([Promise.all([Promise.race([n,i(t.timeout??2e4)]),Promise.race([S,i(3e3)])]),r]),e.isDestroyed())return T();let a=v-(Date.now()-b);if(a>0&&await new Promise(e=>setTimeout(e,a)),e.isDestroyed())return T();e.show(),e.focus(),await T()},close:T}},exports.m3WindowOptions=function(e={}){let t=v(e),n={};if(t.bounds){let{x:e,y:r,width:i,height:a}=x(t.bounds);n={...i?{width:i,height:a}:{},...e==null?{}:{x:e,y:r}}}if(t.controls===`custom`)return{...n,frame:!1};let r=process.platform===`darwin`;return{...n,titleBarStyle:`hidden`,titleBarOverlay:r?!0:{...t.overlay,height:t.titleBarHeight},...r?{trafficLightPosition:{x:14,y:Math.round((t.titleBarHeight-16)/2)}}:{}}},exports.rememberSplashColors=l,exports.setupM3Window=function(t,i={}){D(),g();let a=v(i),o=t.webContents.id;S.set(o,{win:t,o:a,overlay:``});let s=()=>{t.isDestroyed()||t.webContents.send(r.n.state,T(t))},c=[`maximize`,`unmaximize`,`enter-full-screen`,`leave-full-screen`,`focus`,`blur`,`restore`];for(let e of c)t.on(e,s);let l=()=>{},u,d=()=>{clearTimeout(u),u=setTimeout(l,400)};if(a.bounds){let n=a.bounds;b(n)?.maximized&&t.maximize(),l=()=>{if(!(t.isDestroyed()||t.isMinimized()||t.isFullScreen()))try{(0,e.writeFileSync)(y(n),JSON.stringify({...t.getNormalBounds(),maximized:t.isMaximized()}))}catch{}};for(let e of[`resize`,`move`,`maximize`,`unmaximize`])t.on(e,d);t.on(`close`,()=>{clearTimeout(u),l()})}return a.externalLinks&&(t.webContents.setWindowOpenHandler(({url:e})=>(O.test(e)&&n.shell.openExternal(e),{action:`deny`})),t.webContents.on(`will-navigate`,(e,r)=>{let i=t.webContents.getURL(),a=!1;try{a=new URL(r).origin!==new URL(i).origin}catch{}O.test(r)&&a&&(e.preventDefault(),n.shell.openExternal(r))})),t.once(`closed`,()=>{S.delete(o),clearTimeout(u)}),()=>{if(S.delete(o),clearTimeout(u),!t.isDestroyed()){for(let e of c)t.off(e,s);for(let e of[`resize`,`move`,`maximize`,`unmaximize`])t.off(e,d)}}};
|
|
2
2
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.cjs","names":["join","app","readFileSync","screen","systemPreferences","ipcMain","IPC","nativeTheme","Menu","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","menus","original","click","id","item","i","own","m","edit","EDIT","EXTERNAL","options","saved","x","y","width","height","mac","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, 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":"A,kLAkDA,IAAMe,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,EAAiBnB,EAAAA,KAAAA,CAAKC,EAAAA,IAAI,QAAQ,UAAU,EAAGkB,CAAI,EAEvE,SAASC,EAAWD,EAA4B,CAC9C,GAAI,CACF,IAAME,EAAI,KAAK,OAAA,EAAMnB,EAAAA,aAAAA,CAAagB,EAAWC,CAAI,EAAG,MAAM,CAAC,EAE3D,MADK,CAACE,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H_BASELINE","isSafeColor","writeFileSync","extname","registered","register","ipcMain","IPC","BrowserWindow","nativeTheme","SPLASH_PRESETS","SPLASH_SIZES","splashHtml","SPLASH_LOGO_SIZES","join","app","readFileSync","screen","systemPreferences","ipcMain","IPC","nativeTheme","Menu","writeFileSync","shell","node_fs","node_path","electron","require_shared","require_splash_html","COLORS_FILE","colorsFile","readRemembered","clean","c","k","v","rememberSplashColors","scheme","colors","all","next","MIME","logoUrl","logo","windowColor","preset","bg","current","registered$1","register$1","_e","u","win","registerSplashIpc","BASELINE","resolve","o","boundsFile","name","readBounds","b","restoredBounds","a","windows","registered","accent","stateOf","entry","sender","register","w","action","isHex","key","theme","value","count","menus","original","click","id","item","i","own","m","edit","EDIT","EXTERNAL","options","given","perScheme","rounded","width","height","duration","minDuration","shownAt","shown","onScreen","r","send","run","closing","close","controller","readyFrom","waiting","out","from","status","text","target","ready","gone","late","ms","left","saved","x","y","mac","events","ev","save","timer","later","url","here","other"],"sources":["../src/splash.ts","../src/main.ts"],"sourcesContent":["/**\n * The bootsplash, main-process side: a small frameless window shown at once while the app starts (a loading bar and a\n * status line, as Discord's launcher), handing over to the app's window when it's ready.\n *\n * ```ts\n * const splash = createSplash({ title: 'Acme', logo: join(__dirname, 'icon.png') })\n * const win = new BrowserWindow({ show: false, ...m3WindowOptions(m3), webPreferences: { preload } })\n * splash.progress(0.3, 'Loading your workspace…')\n * win.loadURL(url)\n * splash.handoff(win) // shows `win` when it's ready, then the splash fades out\n * ```\n */\nimport { readFileSync, writeFileSync } from 'node:fs'\nimport { extname, join } from 'node:path'\nimport { app, BrowserWindow, ipcMain, nativeTheme, type IpcMainEvent } from 'electron'\nimport { IPC, type M3SplashUpdate } from './shared'\nimport { SPLASH_BASELINE, SPLASH_LOGO_SIZES, SPLASH_PRESETS, SPLASH_SIZES, isSafeColor, splashHtml, type M3SplashColors, type M3SplashIndicator, type M3SplashPreset } from './splashHtml'\n\nexport type { M3SplashColors, M3SplashIndicator, M3SplashPreset } from './splashHtml'\n\nexport interface M3SplashOptions {\n /**\n * The layout: `'classic'` (default: logo, name, bar, status on the surface), `'banner'` (landscape on the primary\n * container, logo beside a large name), `'minimal'` (the logo and a short bar) or `'immersive'` (the whole window in\n * the primary color). Each has its own window and logo size; `width`, `height` and `logoSize` change them\n */\n preset?: M3SplashPreset\n /** `'wavy'` (default: M3 Expressive's wavy indicator) or `'linear'` (the flat one) */\n indicator?: M3SplashIndicator\n /** The app's name (under the logo; the accessible label in `minimal`) */\n title?: string\n /**\n * The logo: a file path (png, svg, jpg, webp, ico), a data: URL, or an http(s) URL. Without one, the title's\n * initial in a circle\n */\n logo?: string\n /** The logo's size in px. Default per preset (96 classic, 72 banner, 112 minimal and immersive) */\n logoSize?: number\n /** The first status line. Default empty */\n status?: string\n /** The first progress, 0–1, or null (default) for an indeterminate bar */\n progress?: number | null\n /** A line under everything, e.g. the version: `` `v${app.getVersion()}` `` */\n footer?: string\n /** Light or dark: default `'system'` (`nativeTheme.shouldUseDarkColors`) */\n theme?: 'light' | 'dark' | 'system'\n /**\n * The colors for the first launch, per scheme or for both. Default the M3 baseline (purple). Later launches use the\n * user's own theme and palette, which the renderer remembers (see `remember`)\n */\n colors?: Partial<M3SplashColors> | { light?: Partial<M3SplashColors>; dark?: Partial<M3SplashColors> }\n /**\n * Paint later launches with the theme and palette the app last showed (MTitleBar, or `useElectronWindow()\n * .rememberSplashColors()`, keep them in the userData folder). Default true\n */\n remember?: boolean\n /** Window size. Default per preset: classic 300 × 340, banner 520 × 280, minimal 240 × 240, immersive 360 × 420 */\n width?: number\n height?: number\n /**\n * Rounded corners on a transparent window. Default true on Windows and macOS; false on Linux, where a window manager\n * without a compositor paints the transparent corners black\n */\n rounded?: boolean\n /** Default `system-ui, sans-serif`: the app's fonts aren't loaded in the splash */\n fontFamily?: string\n /** Stays at least this long (ms) once shown, so a fast start doesn't flash it. Default 700 */\n minDuration?: number\n /**\n * A set time (ms): the bar fills by itself over it and the splash stays that long, or until the app is ready if that\n * takes longer. Leave it out to go as soon as the app is ready, driving the bar with `progress()` (or leaving it\n * indeterminate)\n */\n duration?: number\n}\n\nexport interface M3Splash {\n /** The splash's BrowserWindow */\n window: BrowserWindow\n /** Sets the bar (0–1; null for indeterminate) and, if given, the status line */\n progress(value: number | null, status?: string): void\n /** Sets the status line */\n status(text: string): void\n /**\n * Shows `win` once it's ready, then fades the splash out and closes it. Ready is its `ready-to-show` by default;\n * with `{ waitForRenderer: true }`, when the page calls `useElectronWindow().splashDone()` (after its first data\n * loads, say). `timeout` (ms, default 20000) shows it anyway if that never comes. Resolves once the splash is gone\n */\n handoff(win: BrowserWindow, options?: { waitForRenderer?: boolean; timeout?: number }): Promise<void>\n /** Fades the splash out and closes it, without showing any window */\n close(): Promise<void>\n}\n\nconst COLORS_FILE = 'm3-splash.json'\nconst colorsFile = () => join(app.getPath('userData'), COLORS_FILE)\ntype Remembered = Partial<Record<'light' | 'dark', Partial<M3SplashColors>>>\n\nfunction readRemembered(): Remembered {\n try {\n return JSON.parse(readFileSync(colorsFile(), 'utf8')) as Remembered\n } catch {\n return {}\n }\n}\n\nconst clean = (c: Partial<M3SplashColors> | undefined): Partial<M3SplashColors> =>\n Object.fromEntries(Object.entries(c ?? {}).filter(([k, v]) => k in SPLASH_BASELINE.light && isSafeColor(v))) as Partial<M3SplashColors>\n\n/** Keeps the colors the page showed, per scheme, for the next launch's splash */\nexport function rememberSplashColors(scheme: 'light' | 'dark', colors: Partial<M3SplashColors>): void {\n const all = readRemembered()\n const next = clean(colors)\n if (JSON.stringify(all[scheme]) === JSON.stringify(next)) return\n all[scheme] = next\n try {\n writeFileSync(colorsFile(), JSON.stringify(all))\n } catch { /* a read-only userData: the next splash uses the defaults */ }\n}\n\nconst MIME: Record<string, string> = { '.png': 'image/png', '.svg': 'image/svg+xml', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.ico': 'image/x-icon', '.gif': 'image/gif' }\n\nfunction logoUrl(logo: string | undefined): string | undefined {\n if (!logo) return undefined\n if (/^(data:|https?:)/i.test(logo)) return logo\n try {\n return `data:${MIME[extname(logo).toLowerCase()] ?? 'image/png'};base64,${readFileSync(logo).toString('base64')}`\n } catch {\n return undefined\n }\n}\n\n/** The window's own color behind the page (no white flash), when it's a hex: the preset's background */\nfunction windowColor(preset: M3SplashPreset, c: M3SplashColors): string | undefined {\n const bg = preset === 'banner' ? c.primaryContainer : preset === 'immersive' ? c.primary : c.surface\n return /^#[0-9a-f]{6}$/i.test(bg) ? bg : undefined\n}\n\nlet current: { update(u: M3SplashUpdate): void; done(win: BrowserWindow): void } | null = null\nlet registered = false\n\nfunction register() {\n if (registered) return\n registered = true\n // From the page of the app's window (useElectronWindow): the bar, the status, its first launch's colors, \"ready\"\n ipcMain.on(IPC.splash, (_e: IpcMainEvent, u: M3SplashUpdate) => current?.update(u))\n ipcMain.on(IPC.splashDone, (e: IpcMainEvent) => {\n const win = BrowserWindow.fromWebContents(e.sender)\n if (win) current?.done(win)\n })\n ipcMain.on(IPC.splashColors, (_e: IpcMainEvent, scheme: unknown, colors: unknown) => {\n if ((scheme === 'light' || scheme === 'dark') && colors && typeof colors === 'object') rememberSplashColors(scheme, colors as Partial<M3SplashColors>)\n })\n}\n\n/** Registers the renderer's splash messages (remembering its colors) without opening a splash: `setupM3Window` calls it */\nexport function registerSplashIpc(): void {\n register()\n}\n\n/** Opens the bootsplash now. Call it as soon as the app is ready (`app.whenReady()`), before creating the main window */\nexport function createSplash(options: M3SplashOptions = {}): M3Splash {\n register()\n const scheme = options.theme === 'light' || options.theme === 'dark' ? options.theme : nativeTheme.shouldUseDarkColors ? 'dark' : 'light'\n const given = options.colors ?? {}\n const perScheme = 'light' in given || 'dark' in given\n ? (given as { light?: Partial<M3SplashColors>; dark?: Partial<M3SplashColors> })[scheme]\n : (given as Partial<M3SplashColors>)\n const colors: M3SplashColors = {\n ...SPLASH_BASELINE[scheme],\n ...clean(perScheme),\n ...(options.remember === false ? {} : clean(readRemembered()[scheme])),\n }\n const rounded = options.rounded ?? process.platform !== 'linux'\n const preset: M3SplashPreset = SPLASH_PRESETS.includes(options.preset as M3SplashPreset) ? options.preset! : 'classic'\n const width = Math.round(options.width ?? SPLASH_SIZES[preset].width)\n const height = Math.round(options.height ?? SPLASH_SIZES[preset].height)\n const duration = Math.max(0, Math.round(options.duration ?? 0))\n const minDuration = Math.max(0, options.minDuration ?? 700, duration)\n\n const win = new BrowserWindow({\n width,\n height,\n show: false,\n frame: false,\n resizable: false,\n maximizable: false,\n minimizable: false,\n fullscreenable: false,\n center: true,\n title: options.title ?? app.getName(),\n transparent: rounded,\n hasShadow: !rounded || process.platform === 'darwin',\n backgroundColor: rounded ? '#00000000' : windowColor(preset, colors),\n // Keeps painting (the bar moving) while another window covers it\n webPreferences: { sandbox: true, contextIsolation: true, nodeIntegration: false, devTools: false, backgroundThrottling: false },\n })\n win.setMenu?.(null)\n\n let shownAt = 0\n let shown: () => void\n const onScreen = new Promise<void>((r) => { shown = r })\n win.once('ready-to-show', () => {\n if (win.isDestroyed()) return\n win.show()\n shownAt = Date.now()\n shown()\n })\n void win.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(splashHtml({\n title: options.title ?? app.getName(),\n logo: logoUrl(options.logo),\n logoSize: Math.max(16, Math.round(options.logoSize ?? SPLASH_LOGO_SIZES[preset])),\n preset,\n indicator: options.indicator === 'linear' ? 'linear' : 'wavy',\n status: options.status ?? '',\n progress: options.progress ?? null,\n colors,\n fontFamily: options.fontFamily ?? 'system-ui, sans-serif',\n rounded,\n footer: options.footer ?? '',\n fill: duration,\n }))}`)\n\n const send = (u: M3SplashUpdate) => {\n if (win.isDestroyed()) return\n const run = () => { if (!win.isDestroyed()) void win.webContents.executeJavaScript(`window.m3splash&&window.m3splash.set(${JSON.stringify(u)})`).catch(() => {}) }\n if (win.webContents.isLoading()) win.webContents.once('did-finish-load', run)\n else run()\n }\n\n let closing: Promise<void> | null = null\n const close = (): Promise<void> => {\n closing ??= (async () => {\n if (current === controller) current = null\n if (win.isDestroyed()) return\n try {\n await win.webContents.executeJavaScript('window.m3splash?window.m3splash.exit():0')\n } catch { /* closing anyway */ }\n if (!win.isDestroyed()) win.destroy()\n })()\n return closing\n }\n\n // A renderer's \"ready\" that came before handoff() waits for it\n const readyFrom = new Set<number>()\n let waiting: { id: number; resolve: () => void } | null = null\n const controller = {\n update(u: M3SplashUpdate) {\n const out: M3SplashUpdate = {}\n if (u && 'progress' in u) out.progress = typeof u.progress === 'number' && Number.isFinite(u.progress) ? u.progress : null\n if (u && typeof u.status === 'string') out.status = u.status.slice(0, 200)\n send(out)\n },\n done(from: BrowserWindow) {\n if (waiting?.id === from.id) waiting.resolve()\n else readyFrom.add(from.id)\n },\n }\n current = controller\n\n return {\n window: win,\n progress: (value, status) => controller.update(status === undefined ? { progress: value } : { progress: value, status }),\n status: (text) => controller.update({ status: text }),\n async handoff(target, o = {}) {\n const ready = o.waitForRenderer\n ? new Promise<void>((resolve) => {\n if (readyFrom.has(target.id)) resolve()\n else waiting = { id: target.id, resolve }\n })\n : new Promise<void>((resolve) => {\n if (target.isVisible()) resolve()\n else target.once('ready-to-show', () => resolve())\n })\n // The app's window closed before it was ever ready: don't leave the splash behind\n const gone = new Promise<void>((resolve) => target.once('closed', () => resolve()))\n const late = (ms: number) => new Promise<void>((r) => setTimeout(r, ms))\n // Never stuck: a splash that can't paint (3s) or a page that never says it's ready (`timeout`) don't hold the app\n await Promise.race([Promise.all([Promise.race([ready, late(o.timeout ?? 20000)]), Promise.race([onScreen, late(3000)])]), gone])\n if (target.isDestroyed()) return close()\n const left = minDuration - (Date.now() - shownAt)\n if (left > 0) await new Promise((r) => setTimeout(r, left))\n if (target.isDestroyed()) return close()\n target.show()\n target.focus()\n await close()\n },\n close,\n }\n}\n","/**\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'\nimport { registerSplashIpc } from './splash'\n\nexport type { M3Controls, M3NativeTheme, M3OverlayColors, M3SplashUpdate, M3WindowAction, M3WindowInfo, M3WindowState } from './shared'\nexport { createSplash, rememberSplashColors, type M3Splash, type M3SplashColors, type M3SplashIndicator, type M3SplashOptions, type M3SplashPreset } from './splash'\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 // The page remembers its theme's colors for the next launch's bootsplash, splash or not this time\n registerSplashIpc()\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,iNA6FA,IAAMiC,EAAc,iBACdC,OAAA,EAAmBlC,EAAAA,KAAAA,CAAKC,EAAAA,IAAI,QAAQ,UAAU,EAAGgC,CAAW,EAGlE,SAASE,GAA6B,CACpC,GAAI,CACF,OAAO,KAAK,OAAA,EAAMjC,EAAAA,aAAAA,CAAagC,EAAW,EAAG,MAAM,CAAC,CACtD,MAAQ,CACN,MAAO,CAAC,CACV,CACF,CAEA,IAAME,EAASC,GACb,OAAO,YAAY,OAAO,QAAQA,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IAAM,CAAC,SAAU,OAAQ,WAAY,YAAY,EAAYtE,EAAI,IAAIsE,EAAgBG,CAAK,CACvG,CACF,CAGF"}
|
package/dist/main.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BrowserWindow, type BrowserWindowConstructorOptions } from 'electron';
|
|
2
2
|
import { type M3Controls, type M3OverlayColors } from './shared';
|
|
3
|
-
export type { M3Controls, M3NativeTheme, M3OverlayColors, M3WindowAction, M3WindowInfo, M3WindowState } from './shared';
|
|
3
|
+
export type { M3Controls, M3NativeTheme, M3OverlayColors, M3SplashUpdate, M3WindowAction, M3WindowInfo, M3WindowState } from './shared';
|
|
4
|
+
export { createSplash, rememberSplashColors, type M3Splash, type M3SplashColors, type M3SplashIndicator, type M3SplashOptions, type M3SplashPreset } from './splash';
|
|
4
5
|
export interface M3WindowOptions {
|
|
5
6
|
/** `'native'` (default): the system's buttons, recolored from the theme. `'custom'`: frameless, MTitleBar draws them */
|
|
6
7
|
controls?: M3Controls;
|