@m3ui-vue/electron 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,8 +6,11 @@
6
6
  </p>
7
7
 
8
8
  Electron integration for [m3ui-vue](https://m3ui.dev), the Material Design 3 component library for Vue 3 + Tailwind
9
- CSS v4: a Material 3 title bar for your window, with the system's own window buttons or M3 ones, themed live from the
10
- M3 tokens (dark mode and palette changes included).
9
+ CSS v4: a Material 3 title bar for your window (app icon, menus, the system's own window buttons or M3 ones, themed
10
+ live from the M3 tokens), plus the desktop details users expect: remembered window size, outside links in the browser,
11
+ the app's theme in native dialogs, taskbar progress, badges and the system accent color.
12
+
13
+ **Full guide: [m3ui.dev/integrations/electron](https://m3ui.dev/integrations/electron).**
11
14
 
12
15
  > **0.x.** The API may still change between minor versions.
13
16
 
@@ -26,13 +29,13 @@ import { app, BrowserWindow } from 'electron'
26
29
  import { join } from 'node:path'
27
30
  import { m3WindowOptions, setupM3Window, type M3WindowOptions } from '@m3ui-vue/electron/main'
28
31
 
29
- const m3: M3WindowOptions = { controls: 'native' } // or 'custom'
32
+ const m3: M3WindowOptions = { controls: 'native', rememberBounds: true } // or controls: 'custom'
30
33
 
31
34
  app.whenReady().then(() => {
32
35
  const win = new BrowserWindow({
33
- width: 1100,
36
+ width: 1100, // first launch; the remembered size wins after that
34
37
  height: 720,
35
- ...m3WindowOptions(m3),
38
+ ...m3WindowOptions(m3), // after width/height
36
39
  webPreferences: { preload: join(import.meta.dirname, '../preload/index.mjs') },
37
40
  })
38
41
  setupM3Window(win, m3)
@@ -45,6 +48,8 @@ app.whenReady().then(() => {
45
48
  | `controls` | `'native'` | `'native'`: the system draws the window buttons over the bar (Windows 11 snap layouts, macOS traffic lights, your Linux desktop's buttons) and they're recolored with the theme. `'custom'`: a frameless window, MTitleBar draws the buttons |
46
49
  | `titleBarHeight` | `40` | Height of the bar (and of the native buttons) |
47
50
  | `overlay` | baseline light | Native button colors before the page loads; the bar sends the real ones once it mounts |
51
+ | `rememberBounds` | `false` | Reopen with the size, position and maximized state it closed with (JSON in `userData`). A string names the file, for apps with several windows. A position on a monitor that's gone is dropped, the size kept |
52
+ | `externalLinks` | `true` | `http(s)`/`mailto` links that would open a new window or leave your origin open in the system browser |
48
53
 
49
54
  ### 2. Preload
50
55
 
@@ -72,8 +77,7 @@ import { MTitleBar } from '@m3ui-vue/electron'
72
77
 
73
78
  <template>
74
79
  <div class="flex h-screen flex-col">
75
- <MTitleBar title="My app" color="surface-container">
76
- <template #start><MIcon name="deployed_code" /></template>
80
+ <MTitleBar title="My app" :icon="icon" :menus="menus" color="surface-container" @menu-select="onMenu">
77
81
  <template #end><MIconButton icon="search" size="xs" /></template>
78
82
  </MTitleBar>
79
83
  <main class="min-h-0 flex-1 overflow-auto"><!-- … --></main>
@@ -87,13 +91,17 @@ anything else that should be with `data-no-drag`.
87
91
  | Prop | Default | |
88
92
  |---|---|---|
89
93
  | `title` | | Window title (or the default slot) |
94
+ | `icon` | | App icon: an image (path, import, URL, data: URL; shown at 20px) or a Material Symbol name |
95
+ | `menus` | | `MenuBarMenu[]` (File, Edit…), rendered by the library's `MMenuBar`: icons, shortcut hints, checks, dividers, submenus. Each item's `onSelect` runs, and `menu-select` gets every chosen item |
96
+ | `menusPosition` | `'inline'` | `'inline'`: menus in the bar after the icon. `'below'`: a row of their own under it (classic) |
97
+ | `syncNativeTheme` | `true` | Keep Electron's `nativeTheme` (dialogs, context menus, scrollbars, macOS frame) on the app's `useTheme()` choice |
90
98
  | `color` | `'surface'` | An M3 role or any CSS color |
91
99
  | `titleAlign` | `'start'` | `'start'` or `'center'` |
92
100
  | `buttons` | all three | `custom` only: which of `'minimize'`, `'maximize'`, `'close'` |
93
101
  | `side` | `'auto'` | `custom` only: `'start'`, `'end'`, or `'auto'` (start on macOS) |
94
102
  | `look` | `'auto'` | `custom` only: `'m3'` icon buttons, `'traffic-lights'`, or `'auto'` (by platform) |
95
103
 
96
- Slots: `default` (title), `start`, `end`, and `controls` to draw the buttons yourself
104
+ Slots: `default` (title), `icon`, `start` (after the icon and menus), `end`, and `controls` to draw the buttons yourself
97
105
  (`{ minimize, toggleMaximize, close, maximized, focused }`).
98
106
 
99
107
  Outside Electron the bar renders without buttons, so the same app also runs in a browser.
@@ -103,9 +111,33 @@ Outside Electron the bar renders without buttons, so the same app also runs in a
103
111
  The window's mode and state, reactive, and its actions, for anything besides the bar:
104
112
 
105
113
  ```ts
106
- const { isElectron, ready, controls, platform, isMac, maximized, fullscreen, focused, minimize, toggleMaximize, close } = useElectronWindow()
114
+ const win = useElectronWindow()
115
+ // refs: isElectron, ready, controls, platform, isMac, titleBarHeight, maximized, fullscreen, focused, accentColor
116
+ win.minimize(); win.toggleMaximize(); win.close()
117
+ win.setProgress(0.4) // taskbar / dock progress, 0–1; 'indeterminate'; null removes it
118
+ win.setBadge(3) // dock / launcher badge (macOS, Linux Unity launchers); 0 clears it
119
+ win.requestAttention() // flash the taskbar / bounce the dock while unfocused
120
+ win.setTheme('dark') // nativeTheme by hand (MTitleBar already follows useTheme())
121
+ win.setOverlay({ color, symbolColor }) // recolor the native buttons, for a bar of your own
122
+ ```
123
+
124
+ **The system accent color is opt-in.** `accentColor` (Windows and macOS; `null` on Linux) is only exposed: your
125
+ palette stays yours unless you seed it yourself:
126
+
127
+ ```ts
128
+ const { setSeed } = useColorPalette()
129
+ watchEffect(() => win.accentColor.value && setSeed(win.accentColor.value))
107
130
  ```
108
131
 
132
+ | Feature | Platforms |
133
+ |---|---|
134
+ | Native buttons recolored | Windows, Linux (macOS traffic lights have fixed colors) |
135
+ | Native theme | all |
136
+ | Accent color | Windows (live), macOS |
137
+ | Taskbar progress | Windows, macOS, Linux Unity launchers |
138
+ | Badge | macOS, Linux Unity launchers |
139
+ | Attention | all |
140
+
109
141
  ## Playground
110
142
 
111
143
  ```bash
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue"),t=require("@m3ui-vue/m3ui-vue");const n=require("./shared-CWEPeNW8.cjs");function r(){return typeof window<`u`?window[n.t]:void 0}var i=(0,e.ref)(!1),a=(0,e.ref)(`native`),o=(0,e.ref)(``),s=(0,e.ref)(40),c=(0,e.ref)(!1),l=(0,e.ref)(!1),u=(0,e.ref)(!0),d=0,f=null,p=null;function m(e){c.value=e.maximized,l.value=e.fullscreen,u.value=e.focused}function h(e){f||=e.onState(m),p??=e.info().then(e=>{e&&(a.value=e.controls,o.value=e.platform,s.value=e.titleBarHeight,m(e.state),i.value=!0)}).catch(()=>{p=null})}function g(){f?.(),f=null}function _(){let t=r();return t&&(d++,h(t),(0,e.getCurrentScope)()&&(0,e.onScopeDispose)(()=>{--d===0&&g()})),{isElectron:!!t,ready:(0,e.readonly)(i),controls:(0,e.readonly)(a),platform:(0,e.readonly)(o),isMac:(0,e.computed)(()=>o.value===`darwin`),titleBarHeight:(0,e.readonly)(s),maximized:(0,e.readonly)(c),fullscreen:(0,e.readonly)(l),focused:(0,e.readonly)(u),minimize:()=>t?.action(`minimize`),toggleMaximize:()=>t?.action(`toggle-maximize`),close:()=>t?.action(`close`),setOverlay:e=>t?.setOverlay(e)}}var v=[`data-controls`],y={class:`m3-title-bar-area`},b={class:`m3-title-bar-start`},x={class:`m3-title-bar-title`},S={class:`m3-title-bar-end`},C=[`aria-label`,`title`,`onClick`],w={key:1,viewBox:`0 0 12 12`,"aria-hidden":`true`},T={key:0,d:`M3.5 3.5l5 5M8.5 3.5l-5 5`},E={key:1,d:`M3 6h6`},D={key:2,d:`M6 3v6M3 6h6`},O=(0,e.defineComponent)({__name:`MTitleBar`,props:{title:{},color:{default:`surface`},titleAlign:{default:`start`},buttons:{default:()=>[`minimize`,`maximize`,`close`]},side:{default:`auto`},look:{default:`auto`}},setup(n){let r=n,i=(0,t.useLocale)(),a=_(),{controls:o,maximized:s,focused:c,fullscreen:l,isMac:u,titleBarHeight:d}=a,f=/^[a-z]+(-[a-z]+)*$/,p=(0,e.computed)(()=>f.test(r.color)?`var(--color-${r.color})`:r.color),m=(0,e.computed)(()=>a.isElectron&&o.value===`custom`),h=(0,e.computed)(()=>a.isElectron&&o.value===`native`),g=(0,e.computed)(()=>r.side===`auto`?u.value:r.side===`start`),O=(0,e.computed)(()=>r.look===`auto`?u.value:r.look===`traffic-lights`),k=(0,e.computed)(()=>{let e=r.buttons.filter((e,t,n)=>n.indexOf(e)===t);return O.value?[`close`,`minimize`,`maximize`].filter(t=>e.includes(t)):g.value?[...e].reverse():e}),A=(0,e.computed)(()=>s.value||l.value?i.windowRestore:i.windowMaximize),j=(0,e.computed)(()=>({minimize:i.windowMinimize,maximize:A.value,close:i.close})),M=e=>e===`minimize`?a.minimize():e===`maximize`?a.toggleMaximize():a.close();function N(e){m.value&&(e.target.closest(`button, a, input, select, textarea, [role="button"], [data-no-drag]`)||a.toggleMaximize())}let P=(0,e.ref)(),F=(0,e.ref)(),I=0,L=0,R=null,z=null;function B(e,t){let n=/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:[\s,/]+([\d.]+%?))?/.exec(e);if(!n)return null;let r=n[4]==null?1:n[4].endsWith(`%`)?parseFloat(n[4])/100:parseFloat(n[4]),i=[+n[1],+n[2],+n[3]];return r<1&&t?i.forEach((e,n)=>i[n]=e*r+t[n]*(1-r)):r=1,`#${i.map(e=>Math.round(Math.min(255,Math.max(0,e))).toString(16).padStart(2,`0`)).join(``)}`}function V(){let e=B(getComputedStyle(document.body).backgroundColor)??B(getComputedStyle(document.documentElement).backgroundColor)??`#ffffff`;return[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))}function H(){if(!P.value||!F.value)return;let e=B(getComputedStyle(P.value).backgroundColor,V()),t=B(getComputedStyle(F.value).color);e&&t&&a.setOverlay({color:e,symbolColor:t})}function U(e=600){if(!h.value||u.value||(L=performance.now()+e,I))return;let t=()=>{H(),I=performance.now()<L?requestAnimationFrame(t):0};t()}let W=()=>U();function G(){R||!h.value||u.value||(U(),R=new MutationObserver(()=>U()),R.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-palette`,`data-theme`]}),z=window.matchMedia?.(`(prefers-color-scheme: dark)`)??null,z?.addEventListener?.(`change`,W))}function K(){R?.disconnect(),R=null,z?.removeEventListener?.(`change`,W),z=null,cancelAnimationFrame(I),I=0}return(0,e.onMounted)(()=>{a.ready.value&&G()}),(0,e.watch)([a.ready,h,u],()=>{K(),a.ready.value&&G()}),(0,e.watch)(()=>r.color,()=>U()),(0,e.onBeforeUnmount)(K),(r,i)=>((0,e.openBlock)(),(0,e.createElementBlock)(`header`,{ref_key:`bar`,ref:P,class:(0,e.normalizeClass)([`m3-title-bar`,{"m3-title-bar-native":h.value,"m3-title-bar-blurred":!(0,e.unref)(c),"m3-title-bar-center":n.titleAlign===`center`}]),style:(0,e.normalizeStyle)({height:`${(0,e.unref)(d)}px`,background:p.value}),"data-controls":(0,e.unref)(a).isElectron?(0,e.unref)(o):void 0,onDblclick:N},[(0,e.createElementVNode)(`span`,{ref_key:`probe`,ref:F,class:`m3-title-bar-probe`,"aria-hidden":`true`},null,512),(0,e.createElementVNode)(`div`,y,[(0,e.createElementVNode)(`div`,b,[(0,e.renderSlot)(r.$slots,`start`)]),(0,e.createElementVNode)(`div`,x,[(0,e.renderSlot)(r.$slots,`default`,{},()=>[(0,e.createTextVNode)((0,e.toDisplayString)(n.title),1)])]),(0,e.createElementVNode)(`div`,S,[(0,e.renderSlot)(r.$slots,`end`)]),m.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:(0,e.normalizeClass)([`m3-title-bar-side`,g.value&&`m3-title-bar-controls-start`])},[(0,e.renderSlot)(r.$slots,`controls`,(0,e.normalizeProps)((0,e.guardReactiveProps)({minimize:(0,e.unref)(a).minimize,toggleMaximize:(0,e.unref)(a).toggleMaximize,close:(0,e.unref)(a).close,maximized:(0,e.unref)(s),focused:(0,e.unref)(c)})),()=>[(0,e.createElementVNode)(`div`,{class:(0,e.normalizeClass)([`m3-title-bar-controls`,O.value&&`m3-title-bar-lights`])},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(k.value,n=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:n,type:`button`,class:(0,e.normalizeClass)([`m3-title-bar-btn`,`m3-title-bar-btn-${n}`]),"aria-label":j.value[n],title:j.value[n],onClick:e=>M(n)},[O.value?((0,e.openBlock)(),(0,e.createElementBlock)(`svg`,w,[n===`close`?((0,e.openBlock)(),(0,e.createElementBlock)(`path`,T)):n===`minimize`?((0,e.openBlock)(),(0,e.createElementBlock)(`path`,E)):((0,e.openBlock)(),(0,e.createElementBlock)(`path`,D))])):((0,e.openBlock)(),(0,e.createBlock)((0,e.unref)(t.MIcon),{key:0,name:n===`minimize`?`minimize`:n===`close`?`close`:(0,e.unref)(s)||(0,e.unref)(l)?`close_fullscreen`:`open_in_full`,size:n===`maximize`?16:18},null,8,[`name`,`size`]))],10,C))),128))],2)])],2)):(0,e.createCommentVNode)(``,!0)])],46,v))}});exports.MTitleBar=O,exports.useElectronWindow=_;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue"),t=require("@m3ui-vue/m3ui-vue");const n=require("./shared-BLenUWPr.cjs");function r(){return typeof window<`u`?window[n.t]:void 0}var i=(0,e.ref)(!1),a=(0,e.ref)(`native`),o=(0,e.ref)(``),s=(0,e.ref)(40),c=(0,e.ref)(!1),l=(0,e.ref)(!1),u=(0,e.ref)(!0),d=(0,e.ref)(null),f=0,p=null,m=null,h=null;function g(e){c.value=e.maximized,l.value=e.fullscreen,u.value=e.focused}function _(e){p||=e.onState(g),m||=e.onAccent?.(e=>{d.value=e})??null,h??=e.info().then(e=>{e&&(a.value=e.controls,o.value=e.platform,s.value=e.titleBarHeight,d.value=e.accentColor??null,g(e.state),i.value=!0)}).catch(()=>{h=null})}function v(){p?.(),p=null,m?.(),m=null}function y(){let t=r();return t&&(f++,_(t),(0,e.getCurrentScope)()&&(0,e.onScopeDispose)(()=>{--f===0&&v()})),{isElectron:!!t,ready:(0,e.readonly)(i),controls:(0,e.readonly)(a),platform:(0,e.readonly)(o),isMac:(0,e.computed)(()=>o.value===`darwin`),titleBarHeight:(0,e.readonly)(s),maximized:(0,e.readonly)(c),fullscreen:(0,e.readonly)(l),focused:(0,e.readonly)(u),accentColor:(0,e.readonly)(d),minimize:()=>t?.action(`minimize`),toggleMaximize:()=>t?.action(`toggle-maximize`),close:()=>t?.action(`close`),setOverlay:e=>t?.setOverlay(e),setTheme:e=>t?.setTheme?.(e),setProgress:e=>t?.setProgress?.(e),setBadge:e=>t?.setBadge?.(e),requestAttention:()=>t?.attention?.()}}var ee=[`data-controls`],te={class:`m3-title-bar-area`},b={key:0,class:`m3-title-bar-icon`},x=[`src`],ne={class:`m3-title-bar-start`},re={class:`m3-title-bar-title`},ie={class:`m3-title-bar-text`},S={class:`m3-title-bar-end`},ae=[`aria-label`,`title`,`onClick`],C={key:1,viewBox:`0 0 12 12`,"aria-hidden":`true`},w={key:0,d:`M3.5 3.5l5 5M8.5 3.5l-5 5`},T={key:1,d:`M3 6h6`},E={key:2,d:`M6 3v6M3 6h6`},oe={key:0,class:`m3-title-bar-menu-row`},D=(0,e.defineComponent)({__name:`MTitleBar`,props:{title:{},icon:{},menus:{},menusPosition:{default:`inline`},menusVisibility:{default:`visible`},color:{default:`surface`},titleAlign:{default:`start`},buttons:{default:()=>[`minimize`,`maximize`,`close`]},side:{default:`auto`},look:{default:`auto`},syncNativeTheme:{type:Boolean,default:!0}},emits:[`menu-select`],setup(n,{emit:r}){let i=n,a=r,o=(0,t.useLocale)(),s=(0,e.ref)(!1),c=(0,e.computed)(()=>{let e=i.menus??[];return!e.length||i.menusVisibility===`hidden`||i.menusVisibility===`toggle`&&!s.value?[]:i.menusVisibility===`compact`?[{label:o.appMenuLabel,icon:`menu`,items:e.map(e=>({label:e.label,disabled:e.disabled,children:e.items}))}]:e}),l=(0,e.computed)(()=>i.menusPosition===`below`&&i.menusVisibility!==`compact`),u=(e,t)=>e.some(e=>e===t||!!e.children&&u(e.children,t));function d(e){a(`menu-select`,e,Math.max(0,(i.menus??[]).findIndex(t=>u(t.items,e)))),i.menusVisibility===`toggle`&&(s.value=!1)}let f=!1;function p(e){f=e.key===`Alt`&&!e.repeat&&!e.ctrlKey&&!e.shiftKey&&!e.metaKey}function m(t){t.key===`Alt`&&f&&i.menusVisibility===`toggle`&&i.menus?.length&&(f=!1,t.preventDefault(),s.value=!s.value,s.value&&(0,e.nextTick)(()=>H.value?.querySelector(`.m3-menu-bar [role="menuitem"]`)?.focus()))}function h(){s.value&&setTimeout(()=>{let e=H.value?.querySelector(`.m3-menu-bar`);e&&(e.querySelector(`[aria-expanded="true"]`)||e.contains(document.activeElement)||(s.value=!1))},0)}function g(e){if(e.key!==`Escape`||!s.value)return;let t=e.target;t.closest(`.m3-menu-bar`)&&t.getAttribute(`aria-expanded`)!==`true`&&(s.value=!1)}(0,e.watch)(()=>i.menusVisibility,()=>{s.value=!1}),(0,e.onMounted)(()=>{window.addEventListener(`keydown`,p,!0),window.addEventListener(`keyup`,m,!0),document.addEventListener(`pointerdown`,h,!0),document.addEventListener(`focusin`,h)}),(0,e.onBeforeUnmount)(()=>{window.removeEventListener(`keydown`,p,!0),window.removeEventListener(`keyup`,m,!0),document.removeEventListener(`pointerdown`,h,!0),document.removeEventListener(`focusin`,h)});let _=(0,e.computed)(()=>!!i.icon&&/[/.:]/.test(i.icon)),v=y(),{controls:D,maximized:O,focused:k,fullscreen:A,isMac:j,titleBarHeight:M}=v,se=/^[a-z]+(-[a-z]+)*$/,ce=(0,e.computed)(()=>se.test(i.color)?`var(--color-${i.color})`:i.color),N=(0,e.computed)(()=>v.isElectron&&D.value===`custom`),P=(0,e.computed)(()=>v.isElectron&&D.value===`native`),F=(0,e.computed)(()=>i.side===`auto`?j.value:i.side===`start`),I=(0,e.computed)(()=>i.look===`auto`?j.value:i.look===`traffic-lights`),L=(0,e.computed)(()=>{let e=i.buttons.filter((e,t,n)=>n.indexOf(e)===t);return I.value?[`close`,`minimize`,`maximize`].filter(t=>e.includes(t)):F.value?[...e].reverse():e}),R=(0,e.computed)(()=>O.value||A.value?o.windowRestore:o.windowMaximize),z=(0,e.computed)(()=>({minimize:o.windowMinimize,maximize:R.value,close:o.close})),B=e=>e===`minimize`?v.minimize():e===`maximize`?v.toggleMaximize():v.close();function V(e){N.value&&(e.target.closest(`button, a, input, select, textarea, [role="button"], [data-no-drag]`)||v.toggleMaximize())}let H=(0,e.ref)(),U=(0,e.ref)(),W=0,G=0,K=null,q=null;function J(e,t){let n=/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:[\s,/]+([\d.]+%?))?/.exec(e);if(!n)return null;let r=n[4]==null?1:n[4].endsWith(`%`)?parseFloat(n[4])/100:parseFloat(n[4]),i=[+n[1],+n[2],+n[3]];return r<1&&t?i.forEach((e,n)=>i[n]=e*r+t[n]*(1-r)):r=1,`#${i.map(e=>Math.round(Math.min(255,Math.max(0,e))).toString(16).padStart(2,`0`)).join(``)}`}function le(){let e=J(getComputedStyle(document.body).backgroundColor)??J(getComputedStyle(document.documentElement).backgroundColor)??`#ffffff`;return[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))}function ue(){if(!H.value||!U.value)return;let e=J(getComputedStyle(H.value).backgroundColor,le()),t=J(getComputedStyle(U.value).color);e&&t&&v.setOverlay({color:e,symbolColor:t})}function Y(e=600){if(!P.value||j.value||(G=performance.now()+e,W))return;let t=()=>{ue(),W=performance.now()<G?requestAnimationFrame(t):0};t()}let X=()=>Y();function Z(){K||!P.value||j.value||(Y(),K=new MutationObserver(()=>Y()),K.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-palette`,`data-theme`]}),q=window.matchMedia?.(`(prefers-color-scheme: dark)`)??null,q?.addEventListener?.(`change`,X))}function Q(){K?.disconnect(),K=null,q?.removeEventListener?.(`change`,X),q=null,cancelAnimationFrame(W),W=0}(0,e.onMounted)(()=>{v.ready.value&&Z()}),(0,e.watch)([v.ready,P,j],()=>{Q(),v.ready.value&&Z()}),(0,e.watch)(()=>i.color,()=>Y());let{theme:$}=(0,t.useTheme)();return(0,e.watch)([$,()=>i.syncNativeTheme,v.ready],()=>{i.syncNativeTheme&&v.ready.value&&v.setTheme($.value)},{immediate:!0}),(0,e.onBeforeUnmount)(Q),(r,i)=>((0,e.openBlock)(),(0,e.createElementBlock)(`header`,{ref_key:`bar`,ref:H,class:(0,e.normalizeClass)([`m3-title-bar`,{"m3-title-bar-native":P.value,"m3-title-bar-blurred":!(0,e.unref)(k),"m3-title-bar-center":n.titleAlign===`center`}]),style:(0,e.normalizeStyle)({background:ce.value}),"data-controls":(0,e.unref)(v).isElectron?(0,e.unref)(D):void 0},[(0,e.createElementVNode)(`span`,{ref_key:`probe`,ref:U,class:`m3-title-bar-probe`,"aria-hidden":`true`},null,512),(0,e.createElementVNode)(`div`,{class:`m3-title-bar-row`,style:(0,e.normalizeStyle)({height:`${(0,e.unref)(M)}px`}),onDblclick:V},[(0,e.createElementVNode)(`div`,te,[n.icon||r.$slots.icon?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,b,[(0,e.renderSlot)(r.$slots,`icon`,{},()=>[_.value?((0,e.openBlock)(),(0,e.createElementBlock)(`img`,{key:0,src:n.icon,alt:``,draggable:`false`},null,8,x)):((0,e.openBlock)(),(0,e.createBlock)((0,e.unref)(t.MIcon),{key:1,name:n.icon,size:20},null,8,[`name`]))])])):(0,e.createCommentVNode)(``,!0),c.value.length&&!l.value?((0,e.openBlock)(),(0,e.createBlock)((0,e.unref)(t.MMenuBar),{key:1,menus:c.value,height:Math.min(32,(0,e.unref)(M)-8),class:`m3-title-bar-menus`,onSelect:d,onKeydown:g},null,8,[`menus`,`height`])):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`div`,ne,[(0,e.renderSlot)(r.$slots,`start`)]),(0,e.createElementVNode)(`div`,re,[(0,e.createElementVNode)(`span`,ie,[(0,e.renderSlot)(r.$slots,`default`,{},()=>[(0,e.createTextVNode)((0,e.toDisplayString)(n.title),1)])])]),(0,e.createElementVNode)(`div`,S,[(0,e.renderSlot)(r.$slots,`end`)]),N.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:2,class:(0,e.normalizeClass)([`m3-title-bar-side`,F.value&&`m3-title-bar-controls-start`])},[(0,e.renderSlot)(r.$slots,`controls`,(0,e.normalizeProps)((0,e.guardReactiveProps)({minimize:(0,e.unref)(v).minimize,toggleMaximize:(0,e.unref)(v).toggleMaximize,close:(0,e.unref)(v).close,maximized:(0,e.unref)(O),focused:(0,e.unref)(k)})),()=>[(0,e.createElementVNode)(`div`,{class:(0,e.normalizeClass)([`m3-title-bar-controls`,I.value&&`m3-title-bar-lights`])},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(L.value,n=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:n,type:`button`,class:(0,e.normalizeClass)([`m3-title-bar-btn`,`m3-title-bar-btn-${n}`]),"aria-label":z.value[n],title:z.value[n],onClick:e=>B(n)},[I.value?((0,e.openBlock)(),(0,e.createElementBlock)(`svg`,C,[n===`close`?((0,e.openBlock)(),(0,e.createElementBlock)(`path`,w)):n===`minimize`?((0,e.openBlock)(),(0,e.createElementBlock)(`path`,T)):((0,e.openBlock)(),(0,e.createElementBlock)(`path`,E))])):((0,e.openBlock)(),(0,e.createBlock)((0,e.unref)(t.MIcon),{key:0,name:n===`minimize`?`minimize`:n===`close`?`close`:(0,e.unref)(O)||(0,e.unref)(A)?`close_fullscreen`:`open_in_full`,size:n===`maximize`?16:18},null,8,[`name`,`size`]))],10,ae))),128))],2)])],2)):(0,e.createCommentVNode)(``,!0)])],36),c.value.length&&l.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,oe,[(0,e.createVNode)((0,e.unref)(t.MMenuBar),{menus:c.value,height:32,onSelect:d,onKeydown:g},null,8,[`menus`])])):(0,e.createCommentVNode)(``,!0)],14,ee))}});exports.MTitleBar=D,exports.useElectronWindow=y;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["BRIDGE_KEY","ref","getCurrentScope","onScopeDispose","readonly","computed","useLocale","computed","ref","onMounted","watch","onBeforeUnmount","_openBlock","_createElementBlock","_normalizeClass","_unref","_normalizeStyle","_createElementVNode","_renderSlot","_createTextVNode","_toDisplayString","_normalizeProps","_guardReactiveProps","_Fragment","_renderList","_createBlock","MIcon","vue","_m3ui_vue_m3ui_vue","require_shared","bridge","ready","controls","platform","titleBarHeight","maximized","fullscreen","focused","users","unsubscribe","started","apply","s","start","b","info","stop","useElectronWindow","colors","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","MTitleBar_default","__props","props","locale","win","isMac","ROLE","background","custom","native","atStart","lights","order","set","i","a","maximizeLabel","labels","run","onDblclick","bar","probe","raf","until","observer","media","toHex","css","under","m","c","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 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 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}\n\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)\nlet users = 0\nlet unsubscribe: (() => 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 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 apply(info.state)\n ready.value = true\n }).catch(() => { started = null })\n}\n\nfunction stop() {\n unsubscribe?.()\n unsubscribe = 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 minimize: () => b?.action('minimize'),\n toggleMaximize: () => b?.action('toggle-maximize'),\n close: () => b?.action('close'),\n setOverlay: (colors) => b?.setOverlay(colors),\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}\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 leading controls (an app icon, a menu button…)\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 */\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { MIcon, useLocale } 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 /** 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 { color: 'surface', titleAlign: 'start', buttons: () => ['minimize', 'maximize', 'close'], side: 'auto', look: 'auto' },\n)\n\nconst locale = useLocale()\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())\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=\"{ height: `${titleBarHeight}px`, background }\"\n :data-controls=\"win.isElectron ? controls : undefined\"\n @dblclick=\"onDblclick\"\n >\n <span ref=\"probe\" class=\"m3-title-bar-probe\" aria-hidden=\"true\" />\n <div class=\"m3-title-bar-area\">\n <div class=\"m3-title-bar-start\"><slot name=\"start\" /></div>\n <div class=\"m3-title-bar-title\"><slot>{{ title }}</slot></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 </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-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 position: absolute;\n inset-block: 0;\n left: env(titlebar-area-x, 0px);\n width: env(titlebar-area-width, 100%);\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.m3-title-bar-center .m3-title-bar-title {\n text-align: center;\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}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ref","computed","nextTick","watch","onMounted","onBeforeUnmount","useTheme","_openBlock","_createElementBlock","_normalizeClass","_unref","_normalizeStyle","_createElementVNode","_renderSlot","_createBlock","MIcon","MMenuBar","_createTextVNode","_toDisplayString","_normalizeProps","_guardReactiveProps","_Fragment","_renderList","_createVNode","vue","_m3ui_vue_m3ui_vue","require_shared","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","e","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":"A,iKA2CA,SAASmC,GAA+B,CACtC,OAAO,OAAO,OAAW,IAAe,OAA2DnC,EAAAA,GAAc,IAAA,EACnH,CAGA,IAAMoC,GAAA,EAAQnC,EAAAA,IAAAA,CAAI,EAAK,EACjBoC,GAAA,EAAWpC,EAAAA,IAAAA,CAAgB,QAAQ,EACnCqC,GAAA,EAAWrC,EAAAA,IAAAA,CAAI,EAAE,EACjBsC,GAAA,EAAiBtC,EAAAA,IAAAA,CAAAA,EAA4B,EAC7CuC,GAAA,EAAYvC,EAAAA,IAAAA,CAAI,EAAK,EACrBwC,GAAA,EAAaxC,EAAAA,IAAAA,CAAI,EAAK,EACtByC,GAAA,EAAUzC,EAAAA,IAAAA,CAAI,EAAI,EAClB0C,GAAA,EAAc1C,EAAAA,IAAAA,CAAmB,IAAI,EACvC2C,EAAQ,EACRC,EAAmC,KACnCC,EAAyC,KACzCC,EAAgC,KAEpC,SAASC,EAAMC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,MAAO4D,EAAA,MAAO5D,GACd,QAAKqF,GAAExB,EAAI7D,CAAC,C,GAECuD,EAAA,Q,EACd3F,EAAAA,UAAAA,CAAA,GAAA,EAAAC,EAAAA,mBAAAA,CAIM,MAJNqD,EAIM,CAHQlB,IAAC,UAAA,EAAbpC,EAAAA,UAAAA,CAAA,GAAA,EAAAC,EAAAA,mBAAAA,CAA2D,OAA3DsD,CAA2D,GAC1CnB,IAAC,aAAA,EAAlBpC,EAAAA,UAAAA,CAAA,GAAA,EAAAC,EAAAA,mBAAAA,CAAgD,OAAhDuD,CAAgD,KAAA,EAChDxD,EAAAA,UAAAA,CAAA,GAAA,EAAAC,EAAAA,mBAAAA,CAAgC,OAAhCwD,CAAgC,E,MAJpB,EAAdzD,EAAAA,UAAAA,CAAA,GAAA,EAAAO,EAAAA,YAAAA,EAAAA,EAA2LJ,EAAAA,MAAAA,CAAAK,EAAAA,KAAA,EAAA,C,MAApK,KAAM4B,IAAC,WAAA,WAA+BA,IAAC,QAAA,SAAA,EAAyBjC,EAAAA,MAAAA,CAAAsB,CAAA,IAAA,EAAatB,EAAAA,MAAAA,CAAAuB,CAAA,EAAU,mBAAA,eAAyC,KAAMU,IAAC,WAAA,GAAA,E,6FAa7J8B,EAAA,MAAW,QAAUG,EAAA,QAAA,EAAhCrE,EAAAA,UAAAA,CAAA,GAAA,EAAAC,EAAAA,mBAAAA,CAEM,MAFNyD,GAEM,EAAA,EADJ1C,EAAAA,YAAAA,EAAAA,EAA4Fb,EAAAA,MAAAA,CAAAM,EAAAA,QAAA,EAAA,CAAjF,MAAOyD,EAAA,MAAa,OAAQ,GAAK,SAAQQ,EAAe,UAASQ,C"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { default as MTitleBar } from './renderer/MTitleBar.vue';
2
2
  export { useElectronWindow } from './renderer/useElectronWindow';
3
3
  export type { ElectronWindow } from './renderer/useElectronWindow';
4
- export type { M3Bridge, M3Controls, M3OverlayColors, M3WindowAction, M3WindowInfo, M3WindowState } from './shared';
4
+ export type { M3Bridge, M3Controls, M3NativeTheme, M3OverlayColors, M3WindowAction, M3WindowInfo, M3WindowState } from './shared';