@m3ui-vue/electron 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -92,7 +92,7 @@ anything else that should be with `data-no-drag`.
92
92
  |---|---|---|
93
93
  | `title` | | Window title (or the default slot) |
94
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 |
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. With `native` controls on macOS they go to the menu bar at the top of the screen instead (after the app menu, and a standard Edit menu unless yours is called Edit); there the shortcuts are bound, so don't bind those keys yourself. Elsewhere native mode has no system title bar to hold a menu, so they stay in the bar |
96
96
  | `menusPosition` | `'inline'` | `'inline'`: menus in the bar after the icon. `'below'`: a row of their own under it (classic) |
97
97
  | `syncNativeTheme` | `true` | Keep Electron's `nativeTheme` (dialogs, context menus, scrollbars, macOS frame) on the app's `useTheme()` choice |
98
98
  | `color` | `'surface'` | An M3 role or any CSS color |
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-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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue"),t=require("@m3ui-vue/m3ui-vue");const n=require("./shared-F3rp76zP.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?.(),canSetNativeMenu:typeof t?.setMenu==`function`,setNativeMenu:e=>t?.setMenu?.(e),onNativeMenuClick:e=>t?.onMenuClick?.(e)??(()=>{})}}function b(e){if(!e)return;let t=e.replace(/([⌘⇧⌥⌃])/g,`$1+`).split(`+`).map(e=>e.trim()).filter(Boolean),n={"⌘":`CmdOrCtrl`,"⌃":`CmdOrCtrl`,"⇧":`Shift`,"⌥":`Alt`};return t.map(e=>n[e]??(/^(ctrl|control|cmd|command)$/i.test(e)?`CmdOrCtrl`:/^option$/i.test(e)?`Alt`:e)).join(`+`)}function x(e){let t=new Map,n=1,r=(e,i)=>e.map(e=>{if(e.divider)return{type:`separator`};let a=e.label??``;if(e.children)return{type:`submenu`,label:a,enabled:!e.disabled,items:r(e.children,i)};let o=n++;t.set(o,[e,i]);let s=e.checked!==void 0||e.selected!==void 0;return{type:s?`checkbox`:`normal`,id:o,label:a,enabled:!e.disabled,...s?{checked:!!(e.checked??e.selected)}:{},accelerator:b(e.shortcut)}});return{data:e.map((e,t)=>({label:e.label,enabled:!e.disabled,items:r(e.items,t)})),picks:t}}var ee=[`data-controls`],S={class:`m3-title-bar-area`},te={key:0,class:`m3-title-bar-icon`},ne=[`src`],re={class:`m3-title-bar-start`},ie={class:`m3-title-bar-title`},ae={class:`m3-title-bar-text`},C={class:`m3-title-bar-end`},w=[`aria-label`,`title`,`onClick`],T={key:1,viewBox:`0 0 12 12`,"aria-hidden":`true`},oe={key:0,d:`M3.5 3.5l5 5M8.5 3.5l-5 5`},se={key:1,d:`M3 6h6`},ce={key:2,d:`M6 3v6M3 6h6`},le={key:0,class:`m3-title-bar-menu-row`},E=(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 N.value||!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:b,maximized:E,focused:D,fullscreen:O,isMac:k,titleBarHeight:A}=v,ue=/^[a-z]+(-[a-z]+)*$/,de=(0,e.computed)(()=>ue.test(i.color)?`var(--color-${i.color})`:i.color),j=(0,e.computed)(()=>v.isElectron&&b.value===`custom`),M=(0,e.computed)(()=>v.isElectron&&b.value===`native`),N=(0,e.computed)(()=>M.value&&k.value&&v.canSetNativeMenu&&!!i.menus?.length),P=new Map,F=!1,I=v.onNativeMenuClick(e=>{let t=P.get(e);t&&(t[0].onSelect?.(),a(`menu-select`,t[0],t[1]))});(0,e.watch)([N,()=>i.menus],()=>{if(N.value){let{data:e,picks:t}=x(i.menus);P=t,v.setNativeMenu(e),F=!0}else F&&=(v.setNativeMenu(null),!1)},{immediate:!0}),(0,e.onBeforeUnmount)(()=>{I(),F&&v.setNativeMenu(null)});let L=(0,e.computed)(()=>i.side===`auto`?k.value:i.side===`start`),R=(0,e.computed)(()=>i.look===`auto`?k.value:i.look===`traffic-lights`),z=(0,e.computed)(()=>{let e=i.buttons.filter((e,t,n)=>n.indexOf(e)===t);return R.value?[`close`,`minimize`,`maximize`].filter(t=>e.includes(t)):L.value?[...e].reverse():e}),B=(0,e.computed)(()=>E.value||O.value?o.windowRestore:o.windowMaximize),V=(0,e.computed)(()=>({minimize:o.windowMinimize,maximize:B.value,close:o.close})),fe=e=>e===`minimize`?v.minimize():e===`maximize`?v.toggleMaximize():v.close();function pe(e){j.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 me(){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 he(){if(!H.value||!U.value)return;let e=J(getComputedStyle(H.value).backgroundColor,me()),t=J(getComputedStyle(U.value).color);e&&t&&v.setOverlay({color:e,symbolColor:t})}function Y(e=600){if(!M.value||k.value||(G=performance.now()+e,W))return;let t=()=>{he(),W=performance.now()<G?requestAnimationFrame(t):0};t()}let X=()=>Y();function Z(){K||!M.value||k.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,M,k],()=>{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":M.value,"m3-title-bar-blurred":!(0,e.unref)(D),"m3-title-bar-center":n.titleAlign===`center`}]),style:(0,e.normalizeStyle)({background:de.value}),"data-controls":(0,e.unref)(v).isElectron?(0,e.unref)(b):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)(A)}px`}),onDblclick:pe},[(0,e.createElementVNode)(`div`,S,[n.icon||r.$slots.icon?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,te,[(0,e.renderSlot)(r.$slots,`icon`,{},()=>[_.value?((0,e.openBlock)(),(0,e.createElementBlock)(`img`,{key:0,src:n.icon,alt:``,draggable:`false`},null,8,ne)):((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)(A)-8),class:`m3-title-bar-menus`,onSelect:d,onKeydown:g},null,8,[`menus`,`height`])):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`div`,re,[(0,e.renderSlot)(r.$slots,`start`)]),(0,e.createElementVNode)(`div`,ie,[(0,e.createElementVNode)(`span`,ae,[(0,e.renderSlot)(r.$slots,`default`,{},()=>[(0,e.createTextVNode)((0,e.toDisplayString)(n.title),1)])])]),(0,e.createElementVNode)(`div`,C,[(0,e.renderSlot)(r.$slots,`end`)]),j.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:2,class:(0,e.normalizeClass)([`m3-title-bar-side`,L.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)(E),focused:(0,e.unref)(D)})),()=>[(0,e.createElementVNode)(`div`,{class:(0,e.normalizeClass)([`m3-title-bar-controls`,R.value&&`m3-title-bar-lights`])},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(z.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":V.value[n],title:V.value[n],onClick:e=>fe(n)},[R.value?((0,e.openBlock)(),(0,e.createElementBlock)(`svg`,T,[n===`close`?((0,e.openBlock)(),(0,e.createElementBlock)(`path`,oe)):n===`minimize`?((0,e.openBlock)(),(0,e.createElementBlock)(`path`,se)):((0,e.openBlock)(),(0,e.createElementBlock)(`path`,ce))])):((0,e.openBlock)(),(0,e.createBlock)((0,e.unref)(t.MIcon),{key:0,name:n===`minimize`?`minimize`:n===`close`?`close`:(0,e.unref)(E)||(0,e.unref)(O)?`close_fullscreen`:`open_in_full`,size:n===`maximize`?16:18},null,8,[`name`,`size`]))],10,w))),128))],2)])],2)):(0,e.createCommentVNode)(``,!0)])],36),c.value.length&&l.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,le,[(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=E,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","$slots","useLocale","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,EAAkB,CAC/BT,EAAU,MAAQS,EAAE,UACpBR,EAAW,MAAQQ,EAAE,WACrBP,EAAQ,MAAQO,EAAE,OACpB,CAEA,SAASC,EAAMC,EAAa,CACRN,IAAcM,EAAE,QAAQH,CAAK,EACvBF,IAAoBK,EAAE,WAAYC,GAAM,CAAET,EAAY,MAAQS,CAAE,CAAC,GAAK,KAC9FL,IAAYI,EAAE,KAAK,CAAC,CAAC,KAAME,GAAS,CAC7BA,IACLhB,EAAS,MAAQgB,EAAK,SACtBf,EAAS,MAAQe,EAAK,SACtBd,EAAe,MAAQc,EAAK,eAC5BV,EAAY,MAAQU,EAAK,aAAe,KACxCL,EAAMK,EAAK,KAAK,EAChBjB,EAAM,MAAQ,GAChB,CAAC,CAAC,CAAC,UAAY,CAAEW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A,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"}
1
+ {"version":3,"file":"index.cjs","names":["BRIDGE_KEY","ref","getCurrentScope","onScopeDispose","readonly","computed","$slots","useLocale","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","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","e","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":"A,iKAiDA,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,EA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