@m3ui-vue/electron 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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","_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","menus","m","menusBelow","contains","items","item","i","onMenuSelect","altAlone","onKeydown","onKeyup","bar","hideLater","menubar","onBarKeydown","iconIsImage","win","isMac","ROLE","background","custom","native","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/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 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}\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 }\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","<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'\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 (!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')\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":";;;;AA2CA,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,G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BAAA;KAAyC,MAAMU,MAAC,aAAA,KAAA;;;GAa7J8B,EAAA,MAAW,UAAUG,EAAA,SAAhC/F,EAAA,GAAAC,EAEM,OAFNmF,IAEM,CADJtE,GAA4FX,EAAAuC,CAAA,GAAA;IAAjF,OAAOkD,EAAA;IAAa,QAAQ;IAAK,UAAQQ;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","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,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,CAAA,E,KAC/CxI,EAAA,EAAA,GAAAC,EAeSW,GAAA,MAAAC,GAdK4H,GAAA,QAAL3E,OADT9D,EAAA,GAAAC,EAeS,UAAA;KAbN,KAAK6D;KACN,MAAK;KACJ,OAAK5D,EAAA,CAAA,oBAAA,oBAA2C4D,GAAC,CAAA;KACjD,cAAY+E,GAAA,MAAO/E;KACnB,OAAO+E,GAAA,MAAO/E;KACd,UAAKwG,MAAExB,GAAIhF,CAAC;I,IAEC0E,EAAA,SACdxI,EAAA,GAAAC,EAIM,OAJNiG,IAIM,CAHQpC,MAAC,WAAb9D,EAAA,GAAAC,EAA2D,QAA3DkG,EAA2D,KAC1CrC,MAAC,cAAlB9D,EAAA,GAAAC,EAAgD,QAAhDmG,EAAgD,MAChDpG,EAAA,GAAAC,EAAgC,QAAhCoG,EAAgC,E,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"}
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-BLenUWPr.cjs");var i={color:`#fef7ff`,symbolColor:`#49454f`};function a(e={}){return{controls:e.controls===`custom`?`custom`:`native`,titleBarHeight:Math.max(24,Math.round(e.titleBarHeight??40)),overlay:{...i,...e.overlay},bounds:e.rememberBounds?`m3-window${typeof e.rememberBounds==`string`?`-${e.rememberBounds.replace(/[^\w-]/g,`_`)}`:``}.json`:null,externalLinks:e.externalLinks!==!1}}var o=e=>(0,t.join)(n.app.getPath(`userData`),e);function s(t){try{let n=JSON.parse((0,e.readFileSync)(o(t),`utf8`));return[n.x,n.y,n.width,n.height].every(Number.isFinite)?n:null}catch{return null}}function c(e){let t=s(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 l=new Map,u=!1,d=()=>{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}},f=e=>({maximized:e.isMaximized(),fullscreen:e.isFullScreen(),focused:e.isFocused()});function p(e){return l.get(e.id)}function m(){u||(u=!0,n.ipcMain.handle(r.n.info,e=>{let t=p(e.sender);return t?{controls:t.o.controls,platform:process.platform,titleBarHeight:t.o.titleBarHeight,state:f(t.win),accentColor:d()}:null}),n.ipcMain.on(r.n.action,(e,t)=>{let n=p(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=p(e.sender);if(!n||n.win.isDestroyed()||n.o.controls!==`native`||process.platform===`darwin`||!g(t?.color)||!g(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)=>{p(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=p(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)=>{p(e.sender)&&n.app.setBadgeCount(Math.max(0,Math.floor(Number(t)||0)))}),n.ipcMain.on(r.n.attention,e=>{let t=p(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.systemPreferences.on?.(`accent-color-changed`,()=>{for(let{win:e}of l.values())e.isDestroyed()||e.webContents.send(r.n.accent,d())}))}var h=/^(https?|mailto):/i,g=e=>typeof e==`string`&&/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e);exports.m3WindowOptions=function(e={}){let t=a(e),n={};if(t.bounds){let{x:e,y:r,width:i,height:a}=c(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.setupM3Window=function(t,i={}){m();let c=a(i),u=t.webContents.id;l.set(u,{win:t,o:c,overlay:``});let d=()=>{t.isDestroyed()||t.webContents.send(r.n.state,f(t))},p=[`maximize`,`unmaximize`,`enter-full-screen`,`leave-full-screen`,`focus`,`blur`,`restore`];for(let e of p)t.on(e,d);let g=()=>{},_,v=()=>{clearTimeout(_),_=setTimeout(g,400)};if(c.bounds){let n=c.bounds;s(n)?.maximized&&t.maximize(),g=()=>{if(!(t.isDestroyed()||t.isMinimized()||t.isFullScreen()))try{(0,e.writeFileSync)(o(n),JSON.stringify({...t.getNormalBounds(),maximized:t.isMaximized()}))}catch{}};for(let e of[`resize`,`move`,`maximize`,`unmaximize`])t.on(e,v);t.on(`close`,()=>{clearTimeout(_),g()})}return c.externalLinks&&(t.webContents.setWindowOpenHandler(({url:e})=>(h.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{}h.test(r)&&a&&(e.preventDefault(),n.shell.openExternal(r))})),t.once(`closed`,()=>{l.delete(u),clearTimeout(_)}),()=>{if(l.delete(u),clearTimeout(_),!t.isDestroyed()){for(let e of p)t.off(e,d);for(let e of[`resize`,`move`,`maximize`,`unmaximize`])t.off(e,v)}}};
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("node:fs"),t=require("node:path"),n=require("electron");const r=require("./shared-F3rp76zP.cjs");var i={color:`#fef7ff`,symbolColor:`#49454f`};function a(e={}){return{controls:e.controls===`custom`?`custom`:`native`,titleBarHeight:Math.max(24,Math.round(e.titleBarHeight??40)),overlay:{...i,...e.overlay},bounds:e.rememberBounds?`m3-window${typeof e.rememberBounds==`string`?`-${e.rememberBounds.replace(/[^\w-]/g,`_`)}`:``}.json`:null,externalLinks:e.externalLinks!==!1}}var o=e=>(0,t.join)(n.app.getPath(`userData`),e);function s(t){try{let n=JSON.parse((0,e.readFileSync)(o(t),`utf8`));return[n.x,n.y,n.width,n.height].every(Number.isFinite)?n:null}catch{return null}}function c(e){let t=s(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 l=new Map,u=!1,d=()=>{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}},f=e=>({maximized:e.isMaximized(),fullscreen:e.isFullScreen(),focused:e.isFocused()});function p(e){return l.get(e.id)}function m(){u||(u=!0,n.ipcMain.handle(r.n.info,e=>{let t=p(e.sender);return t?{controls:t.o.controls,platform:process.platform,titleBarHeight:t.o.titleBarHeight,state:f(t.win),accentColor:d()}:null}),n.ipcMain.on(r.n.action,(e,t)=>{let n=p(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=p(e.sender);if(!n||n.win.isDestroyed()||n.o.controls!==`native`||process.platform===`darwin`||!v(t?.color)||!v(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)=>{p(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=p(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)=>{p(e.sender)&&n.app.setBadgeCount(Math.max(0,Math.floor(Number(t)||0)))}),n.ipcMain.on(r.n.attention,e=>{let t=p(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(!p(e.sender)||process.platform!==`darwin`)return;if(_??={menu:n.Menu.getApplicationMenu()},!Array.isArray(t))return n.Menu.setApplicationMenu(_.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=>g.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 l.values())e.isDestroyed()||e.webContents.send(r.n.accent,d())}))}var h=/^(https?|mailto):/i,g=/^(edit|editar|édition|edition|bearbeiten|modifica|編集|编辑|編輯|편집|تحرير|edycja)$/i,_,v=e=>typeof e==`string`&&/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e);exports.m3WindowOptions=function(e={}){let t=a(e),n={};if(t.bounds){let{x:e,y:r,width:i,height:a}=c(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.setupM3Window=function(t,i={}){m();let c=a(i),u=t.webContents.id;l.set(u,{win:t,o:c,overlay:``});let d=()=>{t.isDestroyed()||t.webContents.send(r.n.state,f(t))},p=[`maximize`,`unmaximize`,`enter-full-screen`,`leave-full-screen`,`focus`,`blur`,`restore`];for(let e of p)t.on(e,d);let g=()=>{},_,v=()=>{clearTimeout(_),_=setTimeout(g,400)};if(c.bounds){let n=c.bounds;s(n)?.maximized&&t.maximize(),g=()=>{if(!(t.isDestroyed()||t.isMinimized()||t.isFullScreen()))try{(0,e.writeFileSync)(o(n),JSON.stringify({...t.getNormalBounds(),maximized:t.isMaximized()}))}catch{}};for(let e of[`resize`,`move`,`maximize`,`unmaximize`])t.on(e,v);t.on(`close`,()=>{clearTimeout(_),g()})}return c.externalLinks&&(t.webContents.setWindowOpenHandler(({url:e})=>(h.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{}h.test(r)&&a&&(e.preventDefault(),n.shell.openExternal(r))})),t.once(`closed`,()=>{l.delete(u),clearTimeout(_)}),()=>{if(l.delete(u),clearTimeout(_),!t.isDestroyed()){for(let e of p)t.off(e,d);for(let e of[`resize`,`move`,`maximize`,`unmaximize`])t.off(e,v)}}};
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","writeFileSync","shell","node_fs","node_path","electron","require_shared","BASELINE","resolve","o","boundsFile","name","readBounds","b","restoredBounds","a","windows","registered","accent","c","stateOf","win","entry","sender","register","w","action","colors","isHex","key","theme","value","count","EXTERNAL","options","saved","x","y","width","height","mac","id","send","events","ev","save","timer","later","url","here","other"],"sources":["../src/main.ts"],"sourcesContent":["/**\n * `@m3ui-vue/electron/main`: the main-process half. `m3WindowOptions()` gives the BrowserWindow options for the mode\n * you pick, `setupM3Window()` wires that window to MTitleBar (its state, its buttons, the native overlay's colors) and\n * to `useElectronWindow()` (native theme, accent color, taskbar progress and badge, attention), remembers its bounds\n * and sends outside links to the browser.\n *\n * ```ts\n * const m3 = { controls: 'native' } as const\n * const win = new BrowserWindow({ width: 1100, height: 720, ...m3WindowOptions(m3), webPreferences: { preload } })\n * setupM3Window(win, m3)\n * ```\n */\nimport { readFileSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { app, BrowserWindow, ipcMain, nativeTheme, screen, shell, systemPreferences, type BrowserWindowConstructorOptions, type IpcMainEvent, type IpcMainInvokeEvent, type Rectangle, type WebContents } from 'electron'\nimport { DEFAULT_TITLE_BAR_HEIGHT, IPC, type M3Controls, type M3NativeTheme, type M3OverlayColors, type M3WindowAction, type M3WindowInfo, type M3WindowState } from './shared'\n\nexport type { M3Controls, M3NativeTheme, M3OverlayColors, M3WindowAction, M3WindowInfo, M3WindowState } from './shared'\n\nexport interface M3WindowOptions {\n /** `'native'` (default): the system's buttons, recolored from the theme. `'custom'`: frameless, MTitleBar draws them */\n controls?: M3Controls\n /** Title bar height in px (default 40) */\n titleBarHeight?: number\n /**\n * The native buttons' colors before the page has loaded (MTitleBar sends the real ones from the theme as soon as\n * it mounts). Defaults to the M3 baseline light surface\n */\n overlay?: Partial<M3OverlayColors>\n /**\n * Reopen the window with the size, position and maximized state it closed with (kept in the app's userData\n * folder). `true`, or a name per window when the app has several. Spread `m3WindowOptions()` after your own\n * width/height so the remembered ones win\n */\n rememberBounds?: boolean | string\n /**\n * Open http(s) and mailto links that would leave the app (`target=\"_blank\"`, `window.open`, a link to another\n * site) in the system browser instead of a new Electron window. Default true\n */\n externalLinks?: boolean\n}\n\ninterface Resolved {\n controls: M3Controls\n titleBarHeight: number\n overlay: M3OverlayColors\n bounds: string | null\n externalLinks: boolean\n}\n\nconst BASELINE: M3OverlayColors = { color: '#fef7ff', symbolColor: '#49454f' }\n\nfunction resolve(o: M3WindowOptions = {}): Resolved {\n return {\n controls: o.controls === 'custom' ? 'custom' : 'native',\n titleBarHeight: Math.max(24, Math.round(o.titleBarHeight ?? DEFAULT_TITLE_BAR_HEIGHT)),\n overlay: { ...BASELINE, ...o.overlay },\n bounds: o.rememberBounds ? `m3-window${typeof o.rememberBounds === 'string' ? `-${o.rememberBounds.replace(/[^\\w-]/g, '_')}` : ''}.json` : null,\n externalLinks: o.externalLinks !== false,\n }\n}\n\n// ── Remembered bounds ───────────────────────────────────────────────────────────────────────────────────────────\ninterface Saved extends Rectangle { maximized: boolean }\nconst boundsFile = (name: string) => join(app.getPath('userData'), name)\n\nfunction readBounds(name: string): Saved | null {\n try {\n const b = JSON.parse(readFileSync(boundsFile(name), 'utf8')) as Saved\n if (![b.x, b.y, b.width, b.height].every(Number.isFinite)) return null\n return b\n } catch {\n return null\n }\n}\n\n/** The saved bounds, without the position when no screen shows enough of the window anymore (a monitor unplugged) */\nfunction restoredBounds(name: string): Partial<Rectangle> & { maximized?: boolean } {\n const b = readBounds(name)\n if (!b) return {}\n const visible = screen.getAllDisplays().some(({ workArea: a }) =>\n Math.min(b.x + b.width, a.x + a.width) - Math.max(b.x, a.x) >= 100 && Math.min(b.y + 40, a.y + a.height) - Math.max(b.y, a.y) >= 20)\n return visible ? b : { width: b.width, height: b.height, maximized: b.maximized }\n}\n\n/** The BrowserWindow options for a mode: spread them into `new BrowserWindow({ ... })` */\nexport function m3WindowOptions(options: M3WindowOptions = {}): BrowserWindowConstructorOptions {\n const o = resolve(options)\n let saved: BrowserWindowConstructorOptions = {}\n if (o.bounds) {\n const { x, y, width, height } = restoredBounds(o.bounds)\n saved = { ...(width ? { width, height } : {}), ...(x != null ? { x, y } : {}) }\n }\n if (o.controls === 'custom') return { ...saved, frame: false }\n const mac = process.platform === 'darwin'\n return {\n ...saved,\n titleBarStyle: 'hidden',\n // macOS keeps its traffic lights (`true` only turns on the overlay's CSS env() area); elsewhere the system's\n // buttons are drawn over the page in these colors, at the bar's height\n titleBarOverlay: mac ? true : { ...o.overlay, height: o.titleBarHeight },\n // Traffic lights (12px, 20px apart) centered in the bar\n ...(mac ? { trafficLightPosition: { x: 14, y: Math.round((o.titleBarHeight - 16) / 2) } } : {}),\n }\n}\n\n// One handler per channel for the whole app; each message finds its window's settings by the sender\nconst windows = new Map<number, { win: BrowserWindow; o: Resolved; overlay: string }>()\nlet registered = false\n\nconst accent = (): string | null => {\n try {\n const c = process.platform === 'win32' || process.platform === 'darwin' ? systemPreferences.getAccentColor() : ''\n return /^[0-9a-f]{6}/i.test(c) ? `#${c.slice(0, 6).toLowerCase()}` : null\n } catch {\n return null\n }\n}\n\nconst stateOf = (win: BrowserWindow): M3WindowState => ({\n maximized: win.isMaximized(),\n fullscreen: win.isFullScreen(),\n focused: win.isFocused(),\n})\n\nfunction entry(sender: WebContents) {\n return windows.get(sender.id)\n}\n\nfunction register() {\n if (registered) return\n registered = true\n ipcMain.handle(IPC.info, (e: IpcMainInvokeEvent): M3WindowInfo | null => {\n const w = entry(e.sender)\n if (!w) return null\n return { controls: w.o.controls, platform: process.platform, titleBarHeight: w.o.titleBarHeight, state: stateOf(w.win), accentColor: accent() }\n })\n ipcMain.on(IPC.action, (e: IpcMainEvent, action: M3WindowAction) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed()) return\n if (action === 'minimize') w.win.minimize()\n else if (action === 'toggle-maximize') {\n if (w.win.isFullScreen()) w.win.setFullScreen(false)\n else if (w.win.isMaximized()) w.win.unmaximize()\n else w.win.maximize()\n } else if (action === 'close') w.win.close()\n })\n ipcMain.on(IPC.overlay, (e: IpcMainEvent, colors: M3OverlayColors) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed() || w.o.controls !== 'native' || process.platform === 'darwin') return\n if (!isHex(colors?.color) || !isHex(colors?.symbolColor)) return\n // The renderer sends every frame of a theme transition: skip what wouldn't change anything\n const key = `${colors.color}|${colors.symbolColor}`\n if (key === w.overlay) return\n w.overlay = key\n w.win.setTitleBarOverlay({ color: colors.color, symbolColor: colors.symbolColor, height: w.o.titleBarHeight })\n })\n // The app's theme choice drives the native UI too (dialogs, context menus, scrollbars, macOS's frame). The\n // choice, not the result: 'system' must stay 'system', or prefers-color-scheme would follow the app back\n ipcMain.on(IPC.theme, (e: IpcMainEvent, theme: M3NativeTheme) => {\n if (!entry(e.sender) || !['light', 'dark', 'system'].includes(theme)) return\n if (nativeTheme.themeSource !== theme) nativeTheme.themeSource = theme\n })\n ipcMain.on(IPC.progress, (e: IpcMainEvent, value: number | 'indeterminate' | null) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed()) return\n if (value === 'indeterminate') w.win.setProgressBar(2, { mode: 'indeterminate' })\n else if (typeof value === 'number' && Number.isFinite(value)) w.win.setProgressBar(Math.min(1, Math.max(0, value)))\n else w.win.setProgressBar(-1)\n })\n ipcMain.on(IPC.badge, (e: IpcMainEvent, count: number) => {\n if (!entry(e.sender)) return\n app.setBadgeCount(Math.max(0, Math.floor(Number(count) || 0)))\n })\n ipcMain.on(IPC.attention, (e: IpcMainEvent) => {\n const w = entry(e.sender)\n if (!w || w.win.isDestroyed() || w.win.isFocused()) return\n if (process.platform === 'darwin') app.dock?.bounce('informational')\n else {\n w.win.flashFrame(true)\n w.win.once('focus', () => { if (!w.win.isDestroyed()) w.win.flashFrame(false) })\n }\n })\n // Accent color changes (Windows sends them; macOS asks for a relaunch of most apps anyway)\n const sendAccent = () => { for (const { win } of windows.values()) if (!win.isDestroyed()) win.webContents.send(IPC.accent, accent()) }\n systemPreferences.on?.('accent-color-changed', sendAccent)\n}\n\nconst EXTERNAL = /^(https?|mailto):/i\n\nconst isHex = (c: unknown): c is string => typeof c === 'string' && /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(c)\n\n/**\n * Connects `win` to MTitleBar: answers its questions, runs its buttons, sends it the window's state and recolors the\n * native buttons with the theme. Pass the same options as to `m3WindowOptions()`. Returns a function that undoes it\n * (it's undone on its own when the window closes).\n */\nexport function setupM3Window(win: BrowserWindow, options: M3WindowOptions = {}): () => void {\n register()\n const o = resolve(options)\n const id = win.webContents.id\n windows.set(id, { win, o, overlay: '' })\n const send = () => { if (!win.isDestroyed()) win.webContents.send(IPC.state, stateOf(win)) }\n const events = ['maximize', 'unmaximize', 'enter-full-screen', 'leave-full-screen', 'focus', 'blur', 'restore'] as const\n for (const ev of events) win.on(ev as 'maximize', send)\n\n // Bounds: the size it had before being maximized (getNormalBounds), saved after moves and resizes settle\n let save = () => {}\n let timer: ReturnType<typeof setTimeout> | undefined\n const later = () => { clearTimeout(timer); timer = setTimeout(save, 400) }\n if (o.bounds) {\n const name = o.bounds\n if (readBounds(name)?.maximized) win.maximize()\n save = () => {\n if (win.isDestroyed() || win.isMinimized() || win.isFullScreen()) return\n try {\n writeFileSync(boundsFile(name), JSON.stringify({ ...win.getNormalBounds(), maximized: win.isMaximized() }))\n } catch { /* a read-only profile: nothing to remember */ }\n }\n for (const ev of ['resize', 'move', 'maximize', 'unmaximize'] as const) win.on(ev as 'resize', later)\n win.on('close', () => { clearTimeout(timer); save() })\n }\n\n // Links that leave the app open in the browser\n if (o.externalLinks) {\n win.webContents.setWindowOpenHandler(({ url }) => {\n if (EXTERNAL.test(url)) void shell.openExternal(url)\n return { action: 'deny' }\n })\n win.webContents.on('will-navigate', (e, url) => {\n const here = win.webContents.getURL()\n let other = false\n try { other = new URL(url).origin !== new URL(here).origin } catch { /* about:blank and the like */ }\n if (EXTERNAL.test(url) && other) {\n e.preventDefault()\n void shell.openExternal(url)\n }\n })\n }\n\n const dispose = () => {\n windows.delete(id)\n clearTimeout(timer)\n if (!win.isDestroyed()) {\n for (const ev of events) win.off(ev as 'maximize', send)\n for (const ev of ['resize', 'move', 'maximize', 'unmaximize'] as const) win.off(ev as 'resize', later)\n }\n }\n win.once('closed', () => { windows.delete(id); clearTimeout(timer) })\n return dispose\n}\n"],"mappings":"A,kLAkDA,IAAMc,EAA4B,CAAE,MAAO,UAAW,YAAa,SAAU,EAE7E,SAASC,EAAQC,EAAqB,CAAC,EAAa,CAClD,MAAO,CACL,SAAUA,EAAE,WAAa,SAAW,SAAW,SAC/C,eAAgB,KAAK,IAAI,GAAI,KAAK,MAAMA,EAAE,gBAAA,EAA0C,CAAC,EACrF,QAAS,CAAE,GAAGF,EAAU,GAAGE,EAAE,OAAQ,EACrC,OAAQA,EAAE,eAAiB,YAAY,OAAOA,EAAE,gBAAmB,SAAW,IAAIA,EAAE,eAAe,QAAQ,UAAW,GAAG,IAAM,GAAG,OAAS,KAC3I,cA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CAAC,GAWH3B,EAAI,KAAK,aAAgB,CAAEL,EAAQ,OAAOyB,CAAE,EAAG,aAAaK,CAAK,CAAE,CAAC,MAR9C,CAGpB,GAFA9B,EAAQ,OAAOyB,CAAE,EACjB,aAAaK,CAAK,EACd,CAACzB,EAAI,YAAY,EAAG,CACtB,IAAK,IAAMuB,KAAMD,EAAQtB,EAAI,IAAIuB,EAAkBF,CAAI,EACvD,IAAK,IAAME,IAAM,CAAC,SAAU,OAAQ,WAAY,YAAY,EAAYvB,EAAI,IAAIuB,EAAgBG,CAAK,CACvG,CACF,CAGF"}
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,EAAE,EAAGA,EAAE,EAAGA,EAAE,MAAOA,EAAE,MAAM,CAAC,CAAC,MAAM,OAAO,QAAQ,EACjDA,EAD2D,IAEpE,MAAQ,CACN,OAAO,IACT,CACF,CAGA,SAASC,EAAeH,EAA4D,CAClF,IAAME,EAAID,EAAWD,CAAI,EAIzB,OAHKE,EACWlB,EAAAA,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,WAAY,YAAY,EAAYhC,EAAI,GAAGgC,EAAgBG,CAAK,EACpGnC,EAAI,GAAG,YAAe,CAAE,aAAakC,CAAK,EAAGD,EAAK,CAAE,CAAC,CACvD,CA4BA,OAzBI7C,EAAE,gBACJY,EAAI,YAAY,sBAAsB,CAAEoC,UAClCd,EAAS,KAAKc,CAAG,GAAQvD,EAAAA,MAAM,aAAauD,CAAG,EAC5C,CAAE,OAAQ,MAAO,EACzB,EACDpC,EAAI,YAAY,GAAG,iBAAkB,EAAGoC,IAAQ,CAC9C,IAAMC,EAAOrC,EAAI,YAAY,OAAO,EAChCsC,EAAQ,GACZ,GAAI,CAAEA,EAAQ,IAAI,IAAIF,CAAG,CAAC,CAAC,SAAW,IAAI,IAAIC,CAAI,CAAC,CAAC,MAAO,MAAQ,CAAiC,CAChGf,EAAS,KAAKc,CAAG,GAAKE,IACxB,EAAE,eAAe,EACZzD,EAAAA,MAAM,aAAauD,CAAG,EAE/B,CAAC,GAWHpC,EAAI,KAAK,aAAgB,CAAEL,EAAQ,OAAOoB,CAAE,EAAG,aAAamB,CAAK,CAAE,CAAC,MAR9C,CAGpB,GAFAvC,EAAQ,OAAOoB,CAAE,EACjB,aAAamB,CAAK,EACd,CAAClC,EAAI,YAAY,EAAG,CACtB,IAAK,IAAMgC,KAAMD,EAAQ/B,EAAI,IAAIgC,EAAkBF,CAAI,EACvD,IAAK,IAAME,IAAM,CAAC,SAAU,OAAQ,WAAY,YAAY,EAAYhC,EAAI,IAAIgC,EAAgBG,CAAK,CACvG,CACF,CAGF"}
package/dist/main.js CHANGED
@@ -1,28 +1,28 @@
1
1
  import { readFileSync as e, writeFileSync as t } from "node:fs";
2
2
  import { join as n } from "node:path";
3
- import { app as r, ipcMain as i, nativeTheme as a, screen as o, shell as s, systemPreferences as c } from "electron";
4
- import { n as l } from "./shared-OD5t8cpt.js";
3
+ import { Menu as r, app as i, ipcMain as a, nativeTheme as o, screen as s, shell as c, systemPreferences as l } from "electron";
4
+ import { n as u } from "./shared-CmmPhgMH.js";
5
5
  // src/main.ts
6
- var u = {
6
+ var d = {
7
7
  color: "#fef7ff",
8
8
  symbolColor: "#49454f"
9
9
  };
10
- function d(e = {}) {
10
+ function f(e = {}) {
11
11
  return {
12
12
  controls: e.controls === "custom" ? "custom" : "native",
13
13
  titleBarHeight: Math.max(24, Math.round(e.titleBarHeight ?? 40)),
14
14
  overlay: {
15
- ...u,
15
+ ...d,
16
16
  ...e.overlay
17
17
  },
18
18
  bounds: e.rememberBounds ? `m3-window${typeof e.rememberBounds == "string" ? `-${e.rememberBounds.replace(/[^\w-]/g, "_")}` : ""}.json` : null,
19
19
  externalLinks: e.externalLinks !== !1
20
20
  };
21
21
  }
22
- var f = (e) => n(r.getPath("userData"), e);
23
- function p(t) {
22
+ var p = (e) => n(i.getPath("userData"), e);
23
+ function m(t) {
24
24
  try {
25
- let n = JSON.parse(e(f(t), "utf8"));
25
+ let n = JSON.parse(e(p(t), "utf8"));
26
26
  return [
27
27
  n.x,
28
28
  n.y,
@@ -33,18 +33,18 @@ function p(t) {
33
33
  return null;
34
34
  }
35
35
  }
36
- function m(e) {
37
- let t = p(e);
38
- return t ? o.getAllDisplays().some(({ workArea: e }) => Math.min(t.x + t.width, e.x + e.width) - Math.max(t.x, e.x) >= 100 && Math.min(t.y + 40, e.y + e.height) - Math.max(t.y, e.y) >= 20) ? t : {
36
+ function h(e) {
37
+ let t = m(e);
38
+ return t ? s.getAllDisplays().some(({ workArea: e }) => Math.min(t.x + t.width, e.x + e.width) - Math.max(t.x, e.x) >= 100 && Math.min(t.y + 40, e.y + e.height) - Math.max(t.y, e.y) >= 20) ? t : {
39
39
  width: t.width,
40
40
  height: t.height,
41
41
  maximized: t.maximized
42
42
  } : {};
43
43
  }
44
- function h(e = {}) {
45
- let t = d(e), n = {};
44
+ function g(e = {}) {
45
+ let t = f(e), n = {};
46
46
  if (t.bounds) {
47
- let { x: e, y: r, width: i, height: a } = m(t.bounds);
47
+ let { x: e, y: r, width: i, height: a } = h(t.bounds);
48
48
  n = {
49
49
  ...i ? {
50
50
  width: i,
@@ -74,74 +74,100 @@ function h(e = {}) {
74
74
  } } : {}
75
75
  };
76
76
  }
77
- var g = /* @__PURE__ */ new Map(), _ = !1, v = () => {
77
+ var _ = /* @__PURE__ */ new Map(), v = !1, y = () => {
78
78
  try {
79
- let e = process.platform === "win32" || process.platform === "darwin" ? c.getAccentColor() : "";
79
+ let e = process.platform === "win32" || process.platform === "darwin" ? l.getAccentColor() : "";
80
80
  return /^[0-9a-f]{6}/i.test(e) ? `#${e.slice(0, 6).toLowerCase()}` : null;
81
81
  } catch {
82
82
  return null;
83
83
  }
84
- }, y = (e) => ({
84
+ }, b = (e) => ({
85
85
  maximized: e.isMaximized(),
86
86
  fullscreen: e.isFullScreen(),
87
87
  focused: e.isFocused()
88
88
  });
89
- function b(e) {
90
- return g.get(e.id);
89
+ function x(e) {
90
+ return _.get(e.id);
91
91
  }
92
- function x() {
93
- _ || (_ = !0, i.handle(l.info, (e) => {
94
- let t = b(e.sender);
92
+ function S() {
93
+ v || (v = !0, a.handle(u.info, (e) => {
94
+ let t = x(e.sender);
95
95
  return t ? {
96
96
  controls: t.o.controls,
97
97
  platform: process.platform,
98
98
  titleBarHeight: t.o.titleBarHeight,
99
- state: y(t.win),
100
- accentColor: v()
99
+ state: b(t.win),
100
+ accentColor: y()
101
101
  } : null;
102
- }), i.on(l.action, (e, t) => {
103
- let n = b(e.sender);
102
+ }), a.on(u.action, (e, t) => {
103
+ let n = x(e.sender);
104
104
  n && !n.win.isDestroyed() && (t === "minimize" ? n.win.minimize() : t === "toggle-maximize" ? n.win.isFullScreen() ? n.win.setFullScreen(!1) : n.win.isMaximized() ? n.win.unmaximize() : n.win.maximize() : t === "close" && n.win.close());
105
- }), i.on(l.overlay, (e, t) => {
106
- let n = b(e.sender);
107
- if (!n || n.win.isDestroyed() || n.o.controls !== "native" || process.platform === "darwin" || !C(t?.color) || !C(t?.symbolColor)) return;
105
+ }), a.on(u.overlay, (e, t) => {
106
+ let n = x(e.sender);
107
+ if (!n || n.win.isDestroyed() || n.o.controls !== "native" || process.platform === "darwin" || !E(t?.color) || !E(t?.symbolColor)) return;
108
108
  let r = `${t.color}|${t.symbolColor}`;
109
109
  r !== n.overlay && (n.overlay = r, n.win.setTitleBarOverlay({
110
110
  color: t.color,
111
111
  symbolColor: t.symbolColor,
112
112
  height: n.o.titleBarHeight
113
113
  }));
114
- }), i.on(l.theme, (e, t) => {
115
- b(e.sender) && [
114
+ }), a.on(u.theme, (e, t) => {
115
+ x(e.sender) && [
116
116
  "light",
117
117
  "dark",
118
118
  "system"
119
- ].includes(t) && a.themeSource !== t && (a.themeSource = t);
120
- }), i.on(l.progress, (e, t) => {
121
- let n = b(e.sender);
119
+ ].includes(t) && o.themeSource !== t && (o.themeSource = t);
120
+ }), a.on(u.progress, (e, t) => {
121
+ let n = x(e.sender);
122
122
  n && !n.win.isDestroyed() && (t === "indeterminate" ? n.win.setProgressBar(2, { mode: "indeterminate" }) : typeof t == "number" && Number.isFinite(t) ? n.win.setProgressBar(Math.min(1, Math.max(0, t))) : n.win.setProgressBar(-1));
123
- }), i.on(l.badge, (e, t) => {
124
- b(e.sender) && r.setBadgeCount(Math.max(0, Math.floor(Number(t) || 0)));
125
- }), i.on(l.attention, (e) => {
126
- let t = b(e.sender);
127
- !t || t.win.isDestroyed() || t.win.isFocused() || (process.platform === "darwin" ? r.dock?.bounce("informational") : (t.win.flashFrame(!0), t.win.once("focus", () => {
123
+ }), a.on(u.badge, (e, t) => {
124
+ x(e.sender) && i.setBadgeCount(Math.max(0, Math.floor(Number(t) || 0)));
125
+ }), a.on(u.attention, (e) => {
126
+ let t = x(e.sender);
127
+ !t || t.win.isDestroyed() || t.win.isFocused() || (process.platform === "darwin" ? i.dock?.bounce("informational") : (t.win.flashFrame(!0), t.win.once("focus", () => {
128
128
  t.win.isDestroyed() || t.win.flashFrame(!1);
129
129
  })));
130
- }), c.on?.("accent-color-changed", () => {
131
- for (let { win: e } of g.values()) e.isDestroyed() || e.webContents.send(l.accent, v());
130
+ }), a.on(u.menu, (e, t) => {
131
+ if (!x(e.sender) || process.platform !== "darwin") return;
132
+ if (T ??= { menu: r.getApplicationMenu() }, !Array.isArray(t)) return r.setApplicationMenu(T.menu);
133
+ let n = e.sender, i = (e) => () => {
134
+ n.isDestroyed() || n.send(u.menuClick, e);
135
+ }, a = (e) => e.type === "separator" ? { type: "separator" } : e.type === "submenu" ? {
136
+ label: e.label,
137
+ enabled: e.enabled,
138
+ submenu: e.items.map(a)
139
+ } : {
140
+ type: e.type,
141
+ label: e.label,
142
+ enabled: e.enabled,
143
+ checked: e.checked,
144
+ accelerator: e.accelerator,
145
+ click: i(e.id)
146
+ }, o = t.map((e) => ({
147
+ label: e.label,
148
+ enabled: e.enabled,
149
+ submenu: e.items.map(a)
150
+ })), s = t.some((e) => w.test(e.label.trim())) ? [] : [{ role: "editMenu" }];
151
+ r.setApplicationMenu(r.buildFromTemplate([
152
+ { role: "appMenu" },
153
+ ...s,
154
+ ...o
155
+ ]));
156
+ }), l.on?.("accent-color-changed", () => {
157
+ for (let { win: e } of _.values()) e.isDestroyed() || e.webContents.send(u.accent, y());
132
158
  }));
133
159
  }
134
- var S = /^(https?|mailto):/i, C = (e) => typeof e == "string" && /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e);
135
- function w(e, n = {}) {
136
- x();
137
- let r = d(n), i = e.webContents.id;
138
- g.set(i, {
160
+ var C = /^(https?|mailto):/i, w = /^(edit|editar|édition|edition|bearbeiten|modifica|編集|编辑|編輯|편집|تحرير|edycja)$/i, T, E = (e) => typeof e == "string" && /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e);
161
+ function D(e, n = {}) {
162
+ S();
163
+ let r = f(n), i = e.webContents.id;
164
+ _.set(i, {
139
165
  win: e,
140
166
  o: r,
141
167
  overlay: ""
142
168
  });
143
169
  let a = () => {
144
- e.isDestroyed() || e.webContents.send(l.state, y(e));
170
+ e.isDestroyed() || e.webContents.send(u.state, b(e));
145
171
  }, o = [
146
172
  "maximize",
147
173
  "unmaximize",
@@ -152,14 +178,14 @@ function w(e, n = {}) {
152
178
  "restore"
153
179
  ];
154
180
  for (let t of o) e.on(t, a);
155
- let c = () => {}, u, m = () => {
156
- clearTimeout(u), u = setTimeout(c, 400);
181
+ let s = () => {}, l, d = () => {
182
+ clearTimeout(l), l = setTimeout(s, 400);
157
183
  };
158
184
  if (r.bounds) {
159
185
  let n = r.bounds;
160
- p(n)?.maximized && e.maximize(), c = () => {
186
+ m(n)?.maximized && e.maximize(), s = () => {
161
187
  if (!(e.isDestroyed() || e.isMinimized() || e.isFullScreen())) try {
162
- t(f(n), JSON.stringify({
188
+ t(p(n), JSON.stringify({
163
189
  ...e.getNormalBounds(),
164
190
  maximized: e.isMaximized()
165
191
  }));
@@ -170,31 +196,31 @@ function w(e, n = {}) {
170
196
  "move",
171
197
  "maximize",
172
198
  "unmaximize"
173
- ]) e.on(t, m);
199
+ ]) e.on(t, d);
174
200
  e.on("close", () => {
175
- clearTimeout(u), c();
201
+ clearTimeout(l), s();
176
202
  });
177
203
  }
178
- return r.externalLinks && (e.webContents.setWindowOpenHandler(({ url: e }) => (S.test(e) && s.openExternal(e), { action: "deny" })), e.webContents.on("will-navigate", (t, n) => {
204
+ return r.externalLinks && (e.webContents.setWindowOpenHandler(({ url: e }) => (C.test(e) && c.openExternal(e), { action: "deny" })), e.webContents.on("will-navigate", (t, n) => {
179
205
  let r = e.webContents.getURL(), i = !1;
180
206
  try {
181
207
  i = new URL(n).origin !== new URL(r).origin;
182
208
  } catch {}
183
- S.test(n) && i && (t.preventDefault(), s.openExternal(n));
209
+ C.test(n) && i && (t.preventDefault(), c.openExternal(n));
184
210
  })), e.once("closed", () => {
185
- g.delete(i), clearTimeout(u);
211
+ _.delete(i), clearTimeout(l);
186
212
  }), () => {
187
- if (g.delete(i), clearTimeout(u), !e.isDestroyed()) {
213
+ if (_.delete(i), clearTimeout(l), !e.isDestroyed()) {
188
214
  for (let t of o) e.off(t, a);
189
215
  for (let t of [
190
216
  "resize",
191
217
  "move",
192
218
  "maximize",
193
219
  "unmaximize"
194
- ]) e.off(t, m);
220
+ ]) e.off(t, d);
195
221
  }
196
222
  };
197
223
  }
198
- export { h as m3WindowOptions, w as setupM3Window };
224
+ export { g as m3WindowOptions, D as setupM3Window };
199
225
 
200
226
  //# sourceMappingURL=main.js.map