@stacksjs/desktop 0.2.794 → 0.2.798
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -16
- package/dist/packaging.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -419,7 +419,7 @@ export {
|
|
|
419
419
|
// =============================================================================
|
|
420
420
|
// Packaging & Code Signing (re-exported from Craft)
|
|
421
421
|
// =============================================================================
|
|
422
|
-
export { craftBinaryNotFoundMessage, macOSRuntimeExecutablePath, pack, packageApp, resolveCraftBinary, resolveCraftExecutablePath } from './packaging';
|
|
422
|
+
export { craftBinaryNotFoundMessage, createDiskImage, macOSRuntimeExecutablePath, pack, packageApp, resolveCraftBinary, resolveCraftExecutablePath } from './packaging';
|
|
423
423
|
// =============================================================================
|
|
424
424
|
// Self-Update (re-exported from Craft, plus GitHub Releases helpers)
|
|
425
425
|
// =============================================================================
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,12 @@ import{e}from"./chunk-qnxb6ss0.js";function Yt(){if(typeof Notification<"u"&&Not
|
|
|
3
3
|
<div class="stx-toast ${o}" data-alert-id="${t.id}" role="alert" aria-live="polite">
|
|
4
4
|
<div class="stx-toast-icon">${n}</div>
|
|
5
5
|
<div class="stx-toast-content">
|
|
6
|
-
${r.title?`<div class="stx-toast-title">${
|
|
7
|
-
<div class="stx-toast-message">${
|
|
6
|
+
${r.title?`<div class="stx-toast-title">${ze(r.title)}</div>`:""}
|
|
7
|
+
<div class="stx-toast-message">${ze(r.message)}</div>
|
|
8
8
|
</div>
|
|
9
9
|
${i?'<button class="stx-toast-close" aria-label="Close">×</button>':""}
|
|
10
10
|
</div>
|
|
11
|
-
`}function
|
|
11
|
+
`}function ze(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ne(t){if(t.timeout)clearTimeout(t.timeout);if(F.delete(t.id),t.element&&ge())t.element.classList.add("dismissing"),setTimeout(()=>{t.element?.remove()},200)}async function he(t){let r=Jt(),n=Yt(),o=t.duration??5000,i={id:r,options:t};if(F.set(r,i),n&&t.type!=="error")try{let s=new Notification(t.title||"Notification",{body:t.message,icon:t.type==="success"?"\u2713":t.type==="warning"?"\u26A0":"\u2139",tag:r});if(s.onclick=()=>{if(t.onClick)t.onClick();s.close()},o>0)i.timeout=setTimeout(()=>{s.close(),F.delete(r)},o);return}catch{}if(ge())try{let s=Zt(t.position),c=document.createElement("div");c.innerHTML=er(i);let l=c.firstElementChild;if(!l){let d=(t.type||"info").toUpperCase();console.log(`[stx-alert] ${d}: ${t.title||""}`),console.log(`[stx-alert] ${t.message}`);return}i.element=l;try{s.appendChild(l)}catch{let d=(t.type||"info").toUpperCase();console.log(`[stx-alert] ${d}: ${t.title||""}`),console.log(`[stx-alert] ${t.message}`);return}if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>{try{l.classList.add("visible")}catch{}});try{l.addEventListener("click",(d)=>{if(d.target.classList?.contains("stx-toast-close")){ne(i);return}if(t.onClick)t.onClick()})}catch{}if(o>0)i.timeout=setTimeout(()=>{ne(i)},o)}catch{let s=(t.type||"info").toUpperCase();console.log(`[stx-alert] ${s}: ${t.title||""}`),console.log(`[stx-alert] ${t.message}`)}else{let s=(t.type||"info").toUpperCase();if(console.log(`[stx-alert] ${s}: ${t.title||""}`),console.log(`[stx-alert] ${t.message}`),o>0)i.timeout=setTimeout(()=>{F.delete(r)},o)}}async function Y(t){return he({...t,position:t.position||"top-right"})}async function tr(t,r=3000){return Y({message:t,type:"info",duration:r})}async function rr(t,r=3000){return Y({message:t,type:"success",duration:r})}async function nr(t,r=3000){return Y({message:t,type:"warning",duration:r})}async function or(t,r=5000){return Y({message:t,type:"error",duration:r})}async function ir(t,r,n="info"){return he({title:t,message:r,type:n})}function ar(t){let r=F.get(t);if(r)ne(r)}function sr(){for(let t of F.values())ne(t)}function cr(){return F.size}var lr=`
|
|
12
12
|
.stx-toast-container {
|
|
13
13
|
position: fixed;
|
|
14
14
|
z-index: 10001;
|
|
@@ -165,7 +165,7 @@ import{e}from"./chunk-qnxb6ss0.js";function Yt(){if(typeof Notification<"u"&&Not
|
|
|
165
165
|
</div>
|
|
166
166
|
</div>`,m<r.length-1)u+='<div class="stx-step-connector"></div>'}),`<div id="${i}" class="${l}" ${d?`style='${d}'`:""}>${u}</div>`}function Or(t){let{open:r=!1,title:n,size:o="medium",closable:i=!0,children:s,footer:c,id:l=P("modal"),className:d,style:u}=t,p=v("stx-modal-component",`stx-modal-component--${o}`,d),m=y(u);if(!r)return`<div id="${l}" class="${p} stx-modal-component--hidden" ${m?`style='${m}'`:""}></div>`;let f='<div class="stx-modal-component-overlay">';if(f+='<div class="stx-modal-component-dialog">',n||i){if(f+='<div class="stx-modal-component-header">',n)f+=`<h3 class="stx-modal-component-title">${h(n)}</h3>`;if(i)f+='<button class="stx-modal-component-close">×</button>';f+="</div>"}if(f+=`<div class="stx-modal-component-body">${s}</div>`,c)f+=`<div class="stx-modal-component-footer">${c}</div>`;return f+="</div></div>",`<div id="${l}" class="${p}" ${m?`style='${m}'`:""}>${f}</div>`}function Rr(t){let{items:r,selectable:n=!1,multiSelect:o=!1,emptyMessage:i="No items",id:s=P("list"),className:c,style:l}=t,d=v("stx-list-view",n&&"stx-list-view--selectable",o&&"stx-list-view--multi",c),u=y(l);if(r.length===0)return`<div id="${s}" class="${d}" ${u?`style="${u}"`:""}>
|
|
167
167
|
<div class="stx-list-view-empty">${h(i)}</div>
|
|
168
|
-
</div>`;let p='<ul class="stx-list-view-items">';for(let m of r){let f=v("stx-list-view-item",m.selected&&"stx-list-view-item--selected");p+=`<li class="${f}" data-id="${h(m.id)}" ${n?'tabindex="0"':""}>${m.content}</li>`}return p+="</ul>",`<div id="${s}" class="${d}" ${u?`style='${u}'`:""}>${p}</div>`}function Lr(t){let{columns:r,data:n,striped:o=!1,bordered:i=!1,hoverable:s=!0,sortBy:c,sortOrder:l,id:d=P("table"),className:u,style:p}=t,m=v("stx-table",o&&"stx-table--striped",i&&"stx-table--bordered",s&&"stx-table--hoverable",u),f=y(p),w="<table>";w+="<thead><tr>";for(let b of r){let k=b.key===c?`stx-table-sorted stx-table-sorted--${l}`:"",A=b.sortable?'data-sortable="true"':"",B=b.width?`style="width: ${b.width}"`:"";w+=`<th class="${k}" ${A} ${B} data-key="${h(b.key)}">${h(b.label)}${b.sortable?'<span class="stx-table-sort-icon"></span>':""}</th>`}w+="</tr></thead>",w+="<tbody>";for(let b of n){w+="<tr>";for(let S of r){let k=b[S.key];w+=`<td>${k!=null?h(String(k)):""}</td>`}w+="</tr>"}return w+="</tbody></table>",`<div id="${d}" class="${m}" ${f?`style='${f}'`:""}>${w}</div>`}function
|
|
168
|
+
</div>`;let p='<ul class="stx-list-view-items">';for(let m of r){let f=v("stx-list-view-item",m.selected&&"stx-list-view-item--selected");p+=`<li class="${f}" data-id="${h(m.id)}" ${n?'tabindex="0"':""}>${m.content}</li>`}return p+="</ul>",`<div id="${s}" class="${d}" ${u?`style='${u}'`:""}>${p}</div>`}function Lr(t){let{columns:r,data:n,striped:o=!1,bordered:i=!1,hoverable:s=!0,sortBy:c,sortOrder:l,id:d=P("table"),className:u,style:p}=t,m=v("stx-table",o&&"stx-table--striped",i&&"stx-table--bordered",s&&"stx-table--hoverable",u),f=y(p),w="<table>";w+="<thead><tr>";for(let b of r){let k=b.key===c?`stx-table-sorted stx-table-sorted--${l}`:"",A=b.sortable?'data-sortable="true"':"",B=b.width?`style="width: ${b.width}"`:"";w+=`<th class="${k}" ${A} ${B} data-key="${h(b.key)}">${h(b.label)}${b.sortable?'<span class="stx-table-sort-icon"></span>':""}</th>`}w+="</tr></thead>",w+="<tbody>";for(let b of n){w+="<tr>";for(let S of r){let k=b[S.key];w+=`<td>${k!=null?h(String(k)):""}</td>`}w+="</tr>"}return w+="</tbody></table>",`<div id="${d}" class="${m}" ${f?`style='${f}'`:""}>${w}</div>`}function We(t,r,n,o){let i=r.includes(t.key),s=n.includes(t.key),c=t.children&&t.children.length>0,d=`<div class="${v("stx-tree-node",s&&"stx-tree-node--selected",t.disabled&&"stx-tree-node--disabled")}" data-key="${h(t.key)}">`;if(d+='<div class="stx-tree-node-content">',c)d+=`<span class="stx-tree-toggle ${i?"stx-tree-toggle--expanded":""}">\u25B6</span>`;else d+='<span class="stx-tree-toggle-placeholder"></span>';if(o)d+=`<input type="checkbox" class="stx-tree-checkbox" ${s?"checked":""} ${t.disabled?"disabled":""} />`;if(t.icon)d+=`<span class="stx-tree-icon">${t.icon}</span>`;if(d+=`<span class="stx-tree-label">${h(t.label)}</span>`,d+="</div>",c&&i){d+='<div class="stx-tree-children">';for(let u of t.children)d+=We(u,r,n,o);d+="</div>"}return d+="</div>",d}function _r(t){let{nodes:r,expandedKeys:n=[],selectedKeys:o=[],checkable:i=!1,id:s=P("tree"),className:c,style:l}=t,d=v("stx-tree-view",i&&"stx-tree-view--checkable",c),u=y(l),p="";for(let m of r)p+=We(m,n,o,i);return`<div id="${s}" class="${d}" role="tree" ${u?`style='${u}'`:""}>${p}</div>`}function Nr(t){let{columns:r,data:n,pagination:o,selectable:i=!1,id:s=P("datagrid"),className:c,style:l}=t,d=v("stx-data-grid",i&&"stx-data-grid--selectable",c),u=y(l),p='<div class="stx-data-grid-table-wrapper">';if(p+='<table class="stx-data-grid-table">',p+="<thead><tr>",i)p+='<th class="stx-data-grid-select-all"><input type="checkbox" /></th>';for(let m of r){let f=m.width?`style="width: ${m.width}"`:"";p+=`<th ${f}>
|
|
169
169
|
<div class="stx-data-grid-header-cell">
|
|
170
170
|
<span>${h(m.label)}</span>
|
|
171
171
|
${m.sortable?'<button class="stx-data-grid-sort">\u21C5</button>':""}
|
|
@@ -183,8 +183,8 @@ import{e}from"./chunk-qnxb6ss0.js";function Yt(){if(typeof Notification<"u"&&Not
|
|
|
183
183
|
<div class="stx-chart-type">${r.charAt(0).toUpperCase()+r.slice(1)} Chart</div>
|
|
184
184
|
<div class="stx-chart-info">${n.datasets.length} dataset(s), ${n.labels.length} labels</div>
|
|
185
185
|
</div>
|
|
186
|
-
</div>`}function
|
|
187
|
-
`),k="";if(i){k+='<div class="stx-code-editor-gutter">';for(let A=1;A<=S.length;A++)k+=`<div class="stx-code-editor-line-number">${A}</div>`;k+="</div>"}return k+=`<pre class="stx-code-editor-content"><code class="language-${h(n)}">${h(r)}</code></pre>`,`<div id="${u}" class="${f}" style="${b}" data-language="${h(n)}" data-tab-size="${l}">${k}</div>`}function
|
|
186
|
+
</div>`}function zr(t){let{value:r="",language:n="plaintext",theme:o="dark",lineNumbers:i=!0,readOnly:s=!1,height:c=300,tabSize:l=2,wordWrap:d=!1,id:u=P("code"),className:p,style:m}=t,f=v("stx-code-editor",`stx-code-editor--${o}`,i&&"stx-code-editor--line-numbers",s&&"stx-code-editor--readonly",d&&"stx-code-editor--wrap",p),w={height:typeof c==="number"?`${c}px`:c},b=[y(w),y(m)].filter(Boolean).join("; "),S=r.split(`
|
|
187
|
+
`),k="";if(i){k+='<div class="stx-code-editor-gutter">';for(let A=1;A<=S.length;A++)k+=`<div class="stx-code-editor-line-number">${A}</div>`;k+="</div>"}return k+=`<pre class="stx-code-editor-content"><code class="language-${h(n)}">${h(r)}</code></pre>`,`<div id="${u}" class="${f}" style="${b}" data-language="${h(n)}" data-tab-size="${l}">${k}</div>`}function Wr(t){let{src:r,type:n="video",poster:o,autoplay:i=!1,loop:s=!1,muted:c=!1,controls:l=!0,width:d,height:u,id:p=P("media"),className:m,style:f}=t,w=v("stx-media-player",`stx-media-player--${n}`,m),b={};if(d)b.width=typeof d==="number"?`${d}px`:d;if(u)b.height=typeof u==="number"?`${u}px`:u;let S=[y(b),y(f)].filter(Boolean).join("; "),k=[`id="${p}-media"`,`src="${h(r)}"`,l&&"controls",i&&"autoplay",s&&"loop",c&&"muted",n==="video"&&o&&`poster="${h(o)}"`].filter(Boolean).join(" "),A=n==="video"?`<video ${k}>Your browser does not support the video tag.</video>`:`<audio ${k}>Your browser does not support the audio tag.</audio>`;return`<div id="${p}" class="${w}" ${S?`style='${S}'`:""}>${A}</div>`}function Ur(t){if(t===void 0)return"";let r=["B","KB","MB","GB"],n=t,o=0;while(n>=1024&&o<r.length-1)n/=1024,o++;return`${n.toFixed(1)} ${r[o]}`}function Hr(t){let{files:r,viewMode:n="list",showHidden:o=!1,selectable:i=!0,id:s=P("files"),className:c,style:l}=t,d=v("stx-file-explorer",`stx-file-explorer--${n}`,c),u=y(l),p=o?r:r.filter((f)=>!f.name.startsWith(".")),m="";if(n==="list"){m='<table class="stx-file-explorer-list"><thead><tr><th>Name</th><th>Size</th><th>Modified</th></tr></thead><tbody>';for(let f of p){let w=f.icon||(f.type==="folder"?"\uD83D\uDCC1":"\uD83D\uDCC4"),b=f.type==="file"?Ur(f.size):"",S=f.modified?f.modified.toLocaleDateString():"";m+=`<tr class="stx-file-explorer-item ${i?"stx-file-explorer-item--selectable":""}" data-path="${h(f.path)}" data-type="${f.type}">
|
|
188
188
|
<td><span class="stx-file-explorer-icon">${w}</span>${h(f.name)}</td>
|
|
189
189
|
<td>${b}</td>
|
|
190
190
|
<td>${S}</td>
|
|
@@ -548,7 +548,7 @@ import{e}from"./chunk-qnxb6ss0.js";function Yt(){if(typeof Notification<"u"&&Not
|
|
|
548
548
|
.stx-chip--warning { background: #3a2a1a; }
|
|
549
549
|
.stx-chip--error { background: #3a1a1a; }
|
|
550
550
|
}
|
|
551
|
-
`;function Kr(){return!1}function we(){return typeof window<"u"&&typeof document<"u"}var
|
|
551
|
+
`;function Kr(){return!1}function we(){return typeof window<"u"&&typeof document<"u"}var z=[];function Gr(){return`modal-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function Yr(t){switch(t){case"info":return"ℹ";case"warning":return"⚠";case"error":return"✖";case"success":return"✔";case"question":return"❓";default:return"ℹ"}}function oe(t){if(t==="question")return[{label:"No",style:"default"},{label:"Yes",style:"primary"}];return[{label:"OK",style:"primary"}]}function Xr(t){let{options:r}=t,n=Yr(r.type),o=r.buttons||oe(r.type),i=r.type||"info",s="";return o.forEach((c,l)=>{let d=c.style==="destructive"?"destructive":c.style==="primary"?"primary":"default",u=l===(r.defaultButton??o.length-1)?"autofocus":"";s+=`<button class="stx-modal-btn ${d}" data-index="${l}" ${u}>${c.label}</button>`}),`
|
|
552
552
|
<div class="stx-modal-overlay" data-modal-id="${t.id}">
|
|
553
553
|
<div class="stx-modal ${i}" role="dialog" aria-modal="true" aria-labelledby="${t.id}-title">
|
|
554
554
|
<div class="stx-modal-icon">${n}</div>
|
|
@@ -559,7 +559,7 @@ import{e}from"./chunk-qnxb6ss0.js";function Yt(){if(typeof Notification<"u"&&Not
|
|
|
559
559
|
<div class="stx-modal-buttons">${s}</div>
|
|
560
560
|
</div>
|
|
561
561
|
</div>
|
|
562
|
-
`}function Ue(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function M(t,r,n=!1){let o=
|
|
562
|
+
`}function Ue(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function M(t,r,n=!1){let o=z.indexOf(t);if(o>-1)z.splice(o,1);if(t.element&&we())t.element.remove();let s=(t.options.buttons||oe(t.options.type))[r];if(s?.action)s.action();t.resolve({buttonIndex:r,cancelled:n})}async function H(t){let r=Kr(),n=Gr();return new Promise((o)=>{let i={id:n,options:t,resolve:o};if(z.push(i),r)console.log(`[stx-modal] Showing native modal: ${t.title||"Modal"}`),setTimeout(()=>{M(i,t.defaultButton??0,!1)},0);else if(we())try{let s=document.createElement("div");s.innerHTML=Xr(i);let c=s.firstElementChild;if(!c){console.log(`[stx-modal] ${t.type?.toUpperCase()||"INFO"}: ${t.title||"Modal"}`),console.log(`[stx-modal] ${t.message}`),setTimeout(()=>{M(i,t.defaultButton??0,!1)},0);return}i.element=c;try{document.body.appendChild(c)}catch{console.log(`[stx-modal] ${t.type?.toUpperCase()||"INFO"}: ${t.title||"Modal"}`),console.log(`[stx-modal] ${t.message}`),setTimeout(()=>{M(i,t.defaultButton??0,!1)},0);return}try{c.querySelectorAll(".stx-modal-btn").forEach((l)=>{l.addEventListener("click",()=>{let d=Number.parseInt(l.dataset.index||"0",10);M(i,d,!1)})})}catch{}try{c.addEventListener("click",(l)=>{if(l.target===c){let d=t.cancelButton??0;M(i,d,!0)}})}catch{}try{let l=(d)=>{if(d.key==="Escape"){let u=t.cancelButton??0;M(i,u,!0),document.removeEventListener("keydown",l)}else if(d.key==="Enter"){let u=t.defaultButton??(t.buttons||oe(t.type)).length-1;M(i,u,!1),document.removeEventListener("keydown",l)}};document.addEventListener("keydown",l)}catch{}try{let l=c.querySelector(".stx-modal-btn[autofocus]");if(l)l.focus()}catch{}if(typeof process<"u"&&process.env.BUN_TEST)setTimeout(()=>{M(i,t.defaultButton??0,!1)},0)}catch{console.log(`[stx-modal] ${t.type?.toUpperCase()||"INFO"}: ${t.title||"Modal"}`),console.log(`[stx-modal] ${t.message}`),setTimeout(()=>{M(i,t.defaultButton??0,!1)},0)}else{console.log(`[stx-modal] ${t.type?.toUpperCase()||"INFO"}: ${t.title||"Modal"}`),console.log(`[stx-modal] ${t.message}`);let s=t.buttons||oe(t.type);console.log(`[stx-modal] Buttons: ${s.map((c)=>c.label).join(", ")}`),setTimeout(()=>{M(i,t.defaultButton??0,!1)},0)}})}async function He(t,r){return H({title:t,message:r,type:"info"})}async function Jr(t,r){return H({title:t,message:r,type:"warning"})}async function Qr(t,r){return H({title:t,message:r,type:"error"})}async function Zr(t,r){return H({title:t,message:r,type:"success"})}async function qe(t,r){return H({title:t,message:r,type:"question",buttons:[{label:"No",style:"default"},{label:"Yes",style:"primary"}],defaultButton:1,cancelButton:0})}async function en(t,r="Confirm"){return(await qe(r,t)).buttonIndex===1}async function tn(t,r="Alert"){await He(r,t)}async function rn(t,r="",n="Input"){if(we()&&typeof window.prompt==="function")return window.prompt(t,r);return console.log(`[stx-modal] PROMPT: ${n}`),console.log(`[stx-modal] ${t}`),console.log(`[stx-modal] Default: ${r}`),r}function nn(){return z.length}function on(){while(z.length>0){let t=z[z.length-1];M(t,0,!0)}}var an=`
|
|
563
563
|
.stx-modal-overlay {
|
|
564
564
|
position: fixed;
|
|
565
565
|
inset: 0;
|
|
@@ -853,7 +853,7 @@ window.stxDialog = {
|
|
|
853
853
|
// Check if dialog is available
|
|
854
854
|
isAvailable: () => typeof window.craft?.dialog !== 'undefined',
|
|
855
855
|
};
|
|
856
|
-
`}import _ from"process";import{existsSync as Ze}from"fs";import{basename as et,dirname as ye}from"path";import{craftBinaryNotFoundMessage as tt,macOSRuntimeExecutablePath as Tn,resolveCraftBinary as En}from"craft-native";var q={};function Mn(t){q={...q,...t}}function Dn(){return{...q}}function Bn(){q={}}function ve(t){if(!t.sidebarConfig)return;let r={...t.sidebarConfig};if(r.variant==="desktop")r.material=r.material??"sidebar",r.backgroundEffect=r.backgroundEffect??"shimmer",r.allowsVibrancy=r.allowsVibrancy??!0;return r}function ie(){let t=ye(_.execPath),r=ye(t),n=ye(r),o=et(t)==="MacOS"&&et(r)==="Contents"&&n.endsWith(".app"),i=[_.env.CRAFT_BINARY_PATH,q.craftBinaryPath,...q.additionalSearchPaths||[]];for(let s of i)if(s&&Ze(s))return s;if(o){let s=Tn(n);if(!Ze(s))throw Error("Packaged native runtime is missing. Build with packageApp({ macos: { nativeRuntimePath } }).");return s}return En()}var T=new Map;function Pe(t){let r=T.get(t);if(!r||r.closed)return;r.closed=!0;for(let n of r.closeListeners??[])try{n()}catch(o){console.warn(`[stx/desktop] window ${t} close listener threw:`,o)}r.closeListeners?.clear()}var On=50;async function Se(t,r){let n=r.show().then(()=>({failed:!1}),(i)=>({failed:!0,error:i})),o=await Promise.race([n,new Promise((i)=>setTimeout(()=>i(null),On))]);if(o?.failed)throw o.error;n.then(()=>Pe(t))}function Rn(){return Array.from(T.keys())}function Ln(t){let r=T.get(t);if(!r)return null;return ae(t,r.app)}function _n(){for(let[t,r]of T)try{r.app?.close?.()}catch(n){console.warn(`Failed to close window ${t}:`,n)}T.clear()}function ae(t,r){return{id:t,show:()=>{console.log(`[stx/desktop] Window ${t} shown`)},hide:()=>{console.log("[stx/desktop] To hide window, use window.craft.window.hide() from inside the webview")},close:()=>{let n=T.get(t);if(n?.app)n.app.close(),Pe(t),T.delete(t),console.log(`[stx/desktop] Window ${t} closed`)},onClosed:(n)=>{let o=T.get(t);if(!o||o.closed)return queueMicrotask(n),()=>{};return o.closeListeners??=new Set,o.closeListeners.add(n),()=>o.closeListeners?.delete(n)},focus:()=>{console.log("[stx/desktop] To focus window, use window.craft.window.focus() from inside the webview")},minimize:()=>{console.log("[stx/desktop] To minimize window, use window.craft.window.minimize() from inside the webview")},maximize:()=>{console.log("[stx/desktop] To maximize window, use window.craft.window.maximize() from inside the webview")},restore:()=>{console.log("[stx/desktop] To restore window, use window.craft.window.show() from inside the webview")},setTitle:(n)=>{console.log(`[stx/desktop] To set title, use window.craft.window.setTitle({ title: "${n}" }) from inside the webview`)},loadURL:(n)=>{console.log(`[stx/desktop] To navigate, use window.location.href = "${n}" from inside the webview`)},reload:()=>{console.log("[stx/desktop] To reload, use window.craft.window.reload() from inside the webview")}}}function ke(t,r={}){let n=["--url",t,"--title",r.title||"stx Desktop","--width",String(r.width??1200),"--height",String(r.height??800)];if(r.headless)n.push("--headless");if(r.darkMode)n.push("--dark");if(r.hotReload)n.push("--hot-reload");if(r.resizable===!1)n.push("--no-resize");if(r.frameless)n.push("--frameless");if(r.alwaysOnTop)n.push("--always-on-top");if(r.titlebarHidden)n.push("--titlebar-hidden");if(r.systemTray)n.push("--system-tray");if(r.hideDockIcon)n.push("--hide-dock-icon");if(r.devTools===!1)n.push("--no-devtools");if(r.nativeSidebar)n.push("--native-sidebar");if(r.sidebarWidth!==void 0)n.push("--sidebar-width",String(r.sidebarWidth));let o=ve(r);if(o)n.push("--sidebar-config",JSON.stringify(o));return n}async function Nn(t,r={}){let n=`craft-window-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,o=ie();try{let{createApp:i}=await import("craft-native"),s=i({url:t,craftPath:o,window:{title:r.title||"stx Desktop",headless:r.headless??!1,width:r.width??1200,height:r.height??800,darkMode:r.darkMode??!1,hotReload:r.hotReload??!1,resizable:r.resizable??!0,frameless:r.frameless??!1,alwaysOnTop:r.alwaysOnTop??!1,titlebarHidden:r.titlebarHidden??!1,systemTray:r.systemTray??!1,hideDockIcon:r.hideDockIcon??!1,devTools:r.devTools??!1,nativeSidebar:r.nativeSidebar??!1,sidebarWidth:r.sidebarWidth,sidebarConfig:ve(r)}});return T.set(n,{app:s,url:t,options:r}),await Se(n,s),ae(n,s)}catch{try{let{spawn:i}=await import("child_process"),s=i(o,ke(t,r),{stdio:"inherit"});s.on("error",(l)=>{console.error(l.code==="ENOENT"?tt(o):`craft child error: ${l.message}`)});let c={close:()=>s.kill()};return T.set(n,{app:c,url:t,options:r}),s.on("exit",()=>Pe(n)),ae(n,c)}catch(i){return console.error("Failed to spawn craft binary:",i.message),null}}}async function Fn(t,r={}){let n=`http://localhost:${t}/`;if(_.env.NODE_ENV==="test"||_.env.BUN_TEST)return console.warn("\u26A0 Skipping native window in test environment"),console.log("(Skipping browser fallback in test environment)"),!1;try{let{createApp:i}=await import("craft-native");console.log("\u26A1 Opening native window via craft-native\u2026");let s=!r.nativeSidebar,c=ve(r),l=i({url:n,craftPath:ie(),window:{title:r.title||"stx Development",width:r.width||1400,height:r.height||900,resizable:!0,systemTray:s,darkMode:r.darkMode??!0,hotReload:r.hotReload??!0,headless:r.headless??!1,devTools:!0,titlebarHidden:r.titlebarHidden??!1,nativeSidebar:r.nativeSidebar??!1,sidebarWidth:r.sidebarWidth??260,sidebarConfig:c}}),d=`dev-window-${t}`;return T.set(d,{app:l,url:n,options:r}),await Se(d,l),console.log(`\u2713 Native window opened at ${n}`),!0}catch{let i=ie();try{console.log(`\u26A1 Opening native window via craft binary (${i})\u2026`);let{spawn:s}=await import("child_process"),c=s(i,ke(n,{title:"stx Development",width:1400,height:900,hotReload:!0,...r}),{stdio:"inherit"});c.on("exit",()=>_.exit(0)),c.on("error",(d)=>{console.warn(d.code==="ENOENT"?tt(i):`craft child error: ${d.message}`)});let l=`dev-window-${t}`;return T.set(l,{app:{close:()=>c.kill()},url:n,options:r}),console.log(`\u2713 Native window opened at ${n}`),!0}catch(s){console.warn("\u26A0 Could not spawn craft binary:",s.message)}if(_.env.NODE_ENV==="test"||_.env.BUN_TEST)return console.log("(Skipping browser fallback in test environment)"),!1;console.log("\uD83D\uDCF1 Opening in browser instead\u2026");try{let{spawn:s}=await import("child_process"),c=_.platform;return s(c==="darwin"?"open":c==="win32"?"cmd":"xdg-open",c==="win32"?["/c","start",n]:[n],{detached:!0,stdio:"ignore"}).unref(),console.log(`\u2713 Browser opened at ${n}`),!0}catch(s){return console.error("Could not open browser:",s),console.log(`Please open manually: ${n}`),!1}}}async function
|
|
856
|
+
`}import _ from"process";import{existsSync as Ze}from"fs";import{basename as et,dirname as ye}from"path";import{craftBinaryNotFoundMessage as tt,macOSRuntimeExecutablePath as Tn,resolveCraftBinary as En}from"craft-native";var q={};function Mn(t){q={...q,...t}}function Dn(){return{...q}}function Bn(){q={}}function ve(t){if(!t.sidebarConfig)return;let r={...t.sidebarConfig};if(r.variant==="desktop")r.material=r.material??"sidebar",r.backgroundEffect=r.backgroundEffect??"shimmer",r.allowsVibrancy=r.allowsVibrancy??!0;return r}function ie(){let t=ye(_.execPath),r=ye(t),n=ye(r),o=et(t)==="MacOS"&&et(r)==="Contents"&&n.endsWith(".app"),i=[_.env.CRAFT_BINARY_PATH,q.craftBinaryPath,...q.additionalSearchPaths||[]];for(let s of i)if(s&&Ze(s))return s;if(o){let s=Tn(n);if(!Ze(s))throw Error("Packaged native runtime is missing. Build with packageApp({ macos: { nativeRuntimePath } }).");return s}return En()}var T=new Map;function Pe(t){let r=T.get(t);if(!r||r.closed)return;r.closed=!0;for(let n of r.closeListeners??[])try{n()}catch(o){console.warn(`[stx/desktop] window ${t} close listener threw:`,o)}r.closeListeners?.clear()}var On=50;async function Se(t,r){let n=r.show().then(()=>({failed:!1}),(i)=>({failed:!0,error:i})),o=await Promise.race([n,new Promise((i)=>setTimeout(()=>i(null),On))]);if(o?.failed)throw o.error;n.then(()=>Pe(t))}function Rn(){return Array.from(T.keys())}function Ln(t){let r=T.get(t);if(!r)return null;return ae(t,r.app)}function _n(){for(let[t,r]of T)try{r.app?.close?.()}catch(n){console.warn(`Failed to close window ${t}:`,n)}T.clear()}function ae(t,r){return{id:t,show:()=>{console.log(`[stx/desktop] Window ${t} shown`)},hide:()=>{console.log("[stx/desktop] To hide window, use window.craft.window.hide() from inside the webview")},close:()=>{let n=T.get(t);if(n?.app)n.app.close(),Pe(t),T.delete(t),console.log(`[stx/desktop] Window ${t} closed`)},onClosed:(n)=>{let o=T.get(t);if(!o||o.closed)return queueMicrotask(n),()=>{};return o.closeListeners??=new Set,o.closeListeners.add(n),()=>o.closeListeners?.delete(n)},focus:()=>{console.log("[stx/desktop] To focus window, use window.craft.window.focus() from inside the webview")},minimize:()=>{console.log("[stx/desktop] To minimize window, use window.craft.window.minimize() from inside the webview")},maximize:()=>{console.log("[stx/desktop] To maximize window, use window.craft.window.maximize() from inside the webview")},restore:()=>{console.log("[stx/desktop] To restore window, use window.craft.window.show() from inside the webview")},setTitle:(n)=>{console.log(`[stx/desktop] To set title, use window.craft.window.setTitle({ title: "${n}" }) from inside the webview`)},loadURL:(n)=>{console.log(`[stx/desktop] To navigate, use window.location.href = "${n}" from inside the webview`)},reload:()=>{console.log("[stx/desktop] To reload, use window.craft.window.reload() from inside the webview")}}}function ke(t,r={}){let n=["--url",t,"--title",r.title||"stx Desktop","--width",String(r.width??1200),"--height",String(r.height??800)];if(r.headless)n.push("--headless");if(r.darkMode)n.push("--dark");if(r.hotReload)n.push("--hot-reload");if(r.resizable===!1)n.push("--no-resize");if(r.frameless)n.push("--frameless");if(r.alwaysOnTop)n.push("--always-on-top");if(r.titlebarHidden)n.push("--titlebar-hidden");if(r.systemTray)n.push("--system-tray");if(r.hideDockIcon)n.push("--hide-dock-icon");if(r.devTools===!1)n.push("--no-devtools");if(r.nativeSidebar)n.push("--native-sidebar");if(r.sidebarWidth!==void 0)n.push("--sidebar-width",String(r.sidebarWidth));let o=ve(r);if(o)n.push("--sidebar-config",JSON.stringify(o));return n}async function Nn(t,r={}){let n=`craft-window-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,o=ie();try{let{createApp:i}=await import("craft-native"),s=i({url:t,craftPath:o,window:{title:r.title||"stx Desktop",headless:r.headless??!1,width:r.width??1200,height:r.height??800,darkMode:r.darkMode??!1,hotReload:r.hotReload??!1,resizable:r.resizable??!0,frameless:r.frameless??!1,alwaysOnTop:r.alwaysOnTop??!1,titlebarHidden:r.titlebarHidden??!1,systemTray:r.systemTray??!1,hideDockIcon:r.hideDockIcon??!1,devTools:r.devTools??!1,nativeSidebar:r.nativeSidebar??!1,sidebarWidth:r.sidebarWidth,sidebarConfig:ve(r)}});return T.set(n,{app:s,url:t,options:r}),await Se(n,s),ae(n,s)}catch{try{let{spawn:i}=await import("child_process"),s=i(o,ke(t,r),{stdio:"inherit"});s.on("error",(l)=>{console.error(l.code==="ENOENT"?tt(o):`craft child error: ${l.message}`)});let c={close:()=>s.kill()};return T.set(n,{app:c,url:t,options:r}),s.on("exit",()=>Pe(n)),ae(n,c)}catch(i){return console.error("Failed to spawn craft binary:",i.message),null}}}async function Fn(t,r={}){let n=`http://localhost:${t}/`;if(_.env.NODE_ENV==="test"||_.env.BUN_TEST)return console.warn("\u26A0 Skipping native window in test environment"),console.log("(Skipping browser fallback in test environment)"),!1;try{let{createApp:i}=await import("craft-native");console.log("\u26A1 Opening native window via craft-native\u2026");let s=!r.nativeSidebar,c=ve(r),l=i({url:n,craftPath:ie(),window:{title:r.title||"stx Development",width:r.width||1400,height:r.height||900,resizable:!0,systemTray:s,darkMode:r.darkMode??!0,hotReload:r.hotReload??!0,headless:r.headless??!1,devTools:!0,titlebarHidden:r.titlebarHidden??!1,nativeSidebar:r.nativeSidebar??!1,sidebarWidth:r.sidebarWidth??260,sidebarConfig:c}}),d=`dev-window-${t}`;return T.set(d,{app:l,url:n,options:r}),await Se(d,l),console.log(`\u2713 Native window opened at ${n}`),!0}catch{let i=ie();try{console.log(`\u26A1 Opening native window via craft binary (${i})\u2026`);let{spawn:s}=await import("child_process"),c=s(i,ke(n,{title:"stx Development",width:1400,height:900,hotReload:!0,...r}),{stdio:"inherit"});c.on("exit",()=>_.exit(0)),c.on("error",(d)=>{console.warn(d.code==="ENOENT"?tt(i):`craft child error: ${d.message}`)});let l=`dev-window-${t}`;return T.set(l,{app:{close:()=>c.kill()},url:n,options:r}),console.log(`\u2713 Native window opened at ${n}`),!0}catch(s){console.warn("\u26A0 Could not spawn craft binary:",s.message)}if(_.env.NODE_ENV==="test"||_.env.BUN_TEST)return console.log("(Skipping browser fallback in test environment)"),!1;console.log("\uD83D\uDCF1 Opening in browser instead\u2026");try{let{spawn:s}=await import("child_process"),c=_.platform;return s(c==="darwin"?"open":c==="win32"?"cmd":"xdg-open",c==="win32"?["/c","start",n]:[n],{detached:!0,stdio:"ignore"}).unref(),console.log(`\u2713 Browser opened at ${n}`),!0}catch(s){return console.error("Could not open browser:",s),console.log(`Please open manually: ${n}`),!1}}}async function zn(t,r={}){let{title:n="stx Desktop",width:o=1200,height:i=800,darkMode:s=!1,hotReload:c=!1,resizable:l=!0,frameless:d=!1,alwaysOnTop:u=!1}=r;try{let{createApp:p}=await import("craft-native"),m=ie(),f=p({html:t,craftPath:m,window:{title:n,headless:r.headless??!1,width:o,height:i,darkMode:s,hotReload:c,resizable:l,frameless:d,alwaysOnTop:u}}),w=`craft-window-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return T.set(w,{app:f,url:"html-content",options:r}),await Se(w,f),ae(w,f)}catch(p){return console.error("Failed to create window with HTML:",p),null}}function Wn(){try{return e.resolve("craft-native"),!0}catch{return!1}}function Un(){return`
|
|
857
857
|
// STX Desktop Window Bridge
|
|
858
858
|
// Provides convenient wrappers around window.craft APIs
|
|
859
859
|
window.stxWindow = {
|
|
@@ -894,7 +894,7 @@ window.stxWindow = {
|
|
|
894
894
|
|
|
895
895
|
// Expose as global for backwards compatibility
|
|
896
896
|
window.desktop = window.stxWindow;
|
|
897
|
-
`}import{accessSync as Hn,closeSync as qn,constants as Vn,openSync as jn,readSync as Kn,realpathSync as Gn}from"fs";import{resolveCraftBinary as Yn}from"craft-native";import{macOSRuntimeExecutablePath as Jn,pack as Qn,packageApp as Zn}from"craft-native";import{craftBinaryNotFoundMessage as eo,resolveCraftBinary as to}from"craft-native";function Xn(t,r="full"){let n=Yn(t,r),o=n;if(n==="craft"||n==="craft-webview"){let u=Bun.spawnSync(["pantry","which",n,"--resolve"]);if(u.exitCode!==0){let p=`${u.stderr}${u.stdout}`.trim();throw Error(`Cannot locate Craft's native executable. Install Craft through Pantry and use Pantry 0.11.114 or newer.${p?` ${p}`:""}`)}o=u.stdout.toString().trim()}let i=Gn(o);Hn(i,Vn.X_OK);let s=jn(i,"r"),c=Buffer.alloc(4);try{Kn(s,c,0,c.length,0)}finally{qn(s)}let l=c.readUInt32BE(0);if(!(process.platform==="darwin"?[4277009102,3472551422,4277009103,3489328638,3405691582,3199925962,3405691583,3216703178].includes(l):process.platform==="win32"?c[0]===77&&c[1]===90:l===2135247942))throw Error(`Craft packaging requires a native executable, received: ${i}`);return i}import V from"process";import{spawn as rt}from"child_process";import{AutoUpdater as nt,canReplaceBundle as ro,clearQuarantine as no,extractBundle as oo,generateUpdateManifest as ot,readBundleIdentity as Ae,swapBundle as io,verifyBundleTrust as ao}from"craft-native";var it="update.json";function at(t,r){return`https://github.com/${t}/releases/latest/download/${r}`}function se(t,r,n){return`https://github.com/${t}/releases/download/${r}/${n}`}function st(t){let{repository:r,manifestAsset:n=it,...o}=t;return new nt({...o,updateUrl:at(r,n)})}function so(t){let r=t.tag??`v${t.version}`,n={};for(let[o,i]of Object.entries(t.artifacts)){if(!i)continue;n[o]={path:i,url:se(t.repository,r,i.split("/").pop())}}return ot({version:t.version,releaseNotes:t.releaseNotes,platforms:n})}function j(t=V.execPath){let r=t.split("/");for(let n=0;n<r.length;n++)if(r[n].endsWith(".app"))return r.slice(0,n+1).join("/");return null}async function co(){let t=j();if(!t)return null;return(await Ae(t)).teamId}function ct(){let t=V.ppid;if(t>1)try{V.kill(t,"SIGTERM");return}catch{}V.exit(0)}function lt(t={}){let r=t.appPath??j(),n=t.quit??(()=>V.exit(0));if(r)(t.waitForPid&&Number.isSafeInteger(t.waitForPid)&&t.waitForPid>1?rt("/bin/sh",["-c",'attempt=0; while kill -0 "$1" 2>/dev/null; do attempt=$((attempt + 1)); [ "$attempt" -lt 200 ] || exit 1; sleep 0.1; done; exec /usr/bin/open -n "$2"',"stx-relaunch",String(t.waitForPid),r],{detached:!0,stdio:"ignore"}):rt("/usr/bin/open",["-n",r],{detached:!0,stdio:"ignore"})).unref();let o=t.quitDelayMs??0;if(o>0){setTimeout(n,o).unref?.();return}n()}async function Ce(t){let{appPath:r,requireSameTeam:n=!0,macos:o,...i}=t,s=r??j();if(!s)throw Error("createSelfUpdater: this process is not running from an .app bundle, so there is nothing to update. Pass `appPath` explicitly, or skip the updater in development.");let c=await Ae(s),l=o?.teamId??(n?c.teamId??void 0:void 0),d=o?.bundleIdentifier??c.identifier??void 0;return st({...i,appPath:s,macos:{...o,teamId:l,bundleIdentifier:d},relaunch:t.relaunch??((u)=>lt({appPath:u,quit:ct,quitDelayMs:250,waitForPid:V.ppid}))})}function dt(t){if(typeof process>"u"||process.platform!=="darwin")throw Error("Caffeinate requires macOS");let{dlopen:r,ptr:n}=e("bun:ffi"),o=r("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation",{CFStringCreateWithCString:{args:["ptr","ptr","u32"],returns:"ptr"},CFRelease:{args:["ptr"],returns:"void"}}),i=r("/System/Library/Frameworks/IOKit.framework/IOKit",{IOPMAssertionCreateWithName:{args:["ptr","u32","ptr","ptr"],returns:"i32"},IOPMAssertionRelease:{args:["u32"],returns:"i32"},IOPMAssertionDeclareUserActivity:{args:["ptr","u32","ptr"],returns:"i32"}}),s=[],c=!1;function l(){if(c)return;c=!0;for(let u of s)i.symbols.IOPMAssertionRelease(u);i.close(),o.close()}function d(u){let p=Buffer.from(`${u}\x00`),m=o.symbols.CFStringCreateWithCString(null,n(p),134217984);if(!m)throw Error("Could not create power assertion name");return m}try{let u=[[t.preventDisplaySleep??!0,"PreventUserIdleDisplaySleep"],[t.preventIdleSleep??!0,"PreventUserIdleSystemSleep"],[t.preventSystemSleep??!0,"PreventSystemSleep"],[t.preventDiskSleep??!1,"PreventDiskIdle"]];for(let[p,m]of u){if(!p)continue;let f=d(t.reason||"stx: keeping your Mac awake"),w=d(m),b=new Uint32Array(1);try{let S=i.symbols.IOPMAssertionCreateWithName(w,255,f,n(b));if(S!==0)throw Error(`Could not acquire ${m} (${S})`);s.push(b[0])}finally{o.symbols.CFRelease(f),o.symbols.CFRelease(w)}}if(!s.length)throw Error("At least one sleep prevention option must be enabled");if(t.assertUserActivity??!0){let p=d("stx: user activity"),m=new Uint32Array(1);try{let f=i.symbols.IOPMAssertionDeclareUserActivity(p,0,n(m));if(f!==0)throw Error(`Could not declare user activity (${f})`);s.push(m[0])}finally{o.symbols.CFRelease(p)}}return l}catch(u){throw l(),u}}var C=null;class ut{_release;_startedAt;_endsAt;_options;_expireHandlers=[];_expireTimer=null;_stopped=!1;constructor(t,r){this._release=t,this._options={...r},this._startedAt=new Date;let n=r.duration;if(n&&n>0){let o=n*60*1000;this._endsAt=new Date(this._startedAt.getTime()+o),this._expireTimer=setTimeout(()=>{this.stop();for(let i of this._expireHandlers)try{i()}catch{}},o)}else this._endsAt=null}get pid(){return process.pid}get startedAt(){return this._startedAt}get endsAt(){return this._endsAt}get options(){return{...this._options}}get isActive(){return!this._stopped}get remainingMs(){if(!this._endsAt)return null;let t=this._endsAt.getTime()-Date.now();return Math.max(0,t)}get elapsedMs(){return Date.now()-this._startedAt.getTime()}stop(){if(this._stopped)return;if(this._stopped=!0,this._expireTimer)clearTimeout(this._expireTimer),this._expireTimer=null;this._release()}onExpire(t){this._expireHandlers.push(t)}}function lo(t={}){if(t.duration!==void 0&&t.duration!==-1&&(!Number.isFinite(t.duration)||t.duration<=0))throw RangeError("duration must be positive minutes or -1 for indefinitely");let r=dt(t),n=new ut(r,t);return Ie(),C=n,n}function Ie(t){if(t){if(t.stop(),C===t)C=null;return}if(C)C.stop();C=null}function uo(){return C!==null&&C.isActive}function po(){if(!C||!C.isActive)return{active:!1,instance:null,startedAt:null,endsAt:null,durationMinutes:null};let r=C.options.duration;return{active:!0,instance:C,startedAt:C.startedAt,endsAt:C.endsAt,durationMinutes:r&&r>0?r:-1}}function fo(t){let r=t||C;if(!r||!r.isActive)return"0:00";let n=r.remainingMs;if(n===null)return"\u221E";let o=Math.ceil(n/1000),i=Math.floor(o/3600),s=Math.floor(o%3600/60),c=o%60;if(i>0)return`${i}:${String(s).padStart(2,"0")}:${String(c).padStart(2,"0")}`;return`${s}:${String(c).padStart(2,"0")}`}function mo(t){if(t<=0||t===-1)return"Indefinitely";if(t<60)return`${t} minutes`;if(t===60)return"1 hour";if(t%60===0)return`${t/60} hours`;let r=Math.floor(t/60),n=t%60;return`${r}h ${n}m`}if(typeof process<"u")process.once("exit",()=>Ie());import{existsSync as $e,mkdirSync as go,readFileSync as ho,watch as wo,writeFileSync as bo}from"fs";import{homedir as xo,platform as yo}from"os";import{dirname as vo,join as J}from"path";function Po(t){let r=yo(),n=xo();switch(r){case"darwin":return J(n,"Library","Application Support",t);case"win32":return J(process.env.APPDATA||J(n,"AppData","Roaming"),t);default:return J(n,".config",t)}}class pt{_defaults;_data;_path;_changeHandlers=new Map;_anyChangeHandlers=new Set;_watcher=null;_writeTimer=null;_writing=!1;constructor(t){this._defaults={...t.defaults};let r=t.path?vo(t.path):Po(t.name);if(this._path=t.path||J(r,"preferences.json"),!$e(r))go(r,{recursive:!0});if(this._data=this._load(),t.watch!==!1)this._setupWatcher()}get path(){return this._path}get(t){if(t in this._data)return this._data[t];return this._defaults[t]}set(t,r){let n=this.get(t);if(JSON.stringify(n)===JSON.stringify(r))return;this._data[t]=r,this._scheduleSave(),this._notifyChange(t,r,n)}getAll(){return{...this._defaults,...this._data}}has(t){return t in this._data}delete(t){if(!(t in this._data))return;let r=this._data[t];delete this._data[t],this._scheduleSave(),this._notifyChange(t,this._defaults[t],r)}reset(){let t={...this._data};this._data={},this._save();for(let r of Object.keys(t)){let n=this._defaults[r];this._notifyChange(r,n,t[r])}}onChange(t,r){let n=t;if(!this._changeHandlers.has(n))this._changeHandlers.set(n,new Set);return this._changeHandlers.get(n).add(r),()=>{this._changeHandlers.get(n)?.delete(r)}}onAnyChange(t){return this._anyChangeHandlers.add(t),()=>{this._anyChangeHandlers.delete(t)}}close(){if(this._watcher)this._watcher.close(),this._watcher=null;if(this._writeTimer)clearTimeout(this._writeTimer),this._writeTimer=null,this._save()}_load(){try{if($e(this._path)){let t=ho(this._path,"utf-8");return JSON.parse(t)}}catch{}return{}}_save(){this._writing=!0;try{let t=JSON.stringify({...this._defaults,...this._data},null,2);bo(this._path,t,"utf-8")}catch(t){console.error(`Failed to save preferences to ${this._path}:`,t)}finally{setTimeout(()=>{this._writing=!1},100)}}_scheduleSave(){if(this._writeTimer)clearTimeout(this._writeTimer);this._writeTimer=setTimeout(()=>{this._writeTimer=null,this._save()},50)}_setupWatcher(){try{if(!$e(this._path))this._save();this._watcher=wo(this._path,()=>{if(this._writing)return;let t=this._load(),r={...this._data};this._data=t;let n=new Set([...Object.keys(r),...Object.keys(t)]);for(let o of n){let i=o in r?r[o]:this._defaults[o],s=o in t?t[o]:this._defaults[o];if(JSON.stringify(i)!==JSON.stringify(s))this._notifyChange(o,s,i)}})}catch{}}_notifyChange(t,r,n){let o=this._changeHandlers.get(t);if(o)for(let i of o)try{i(r,n)}catch{}for(let i of this._anyChangeHandlers)try{i(t,r,n)}catch{}}}function So(t){return new pt(t)}import{existsSync as K,mkdirSync as ft,readFileSync as ko,unlinkSync as mt,writeFileSync as gt}from"fs";import{homedir as ce,platform as ht}from"os";import{join as G}from"path";function wt(t){let r=t.toLowerCase().replace(/[^a-z0-9]/g,"-");return G(ce(),"Library","LaunchAgents",`com.${r}.plist`)}function bt(t){let r=process.env.XDG_CONFIG_HOME||G(ce(),".config");return G(r,"autostart",`${t.toLowerCase()}.desktop`)}async function Ao(t,r){let n=r.appName||"StxApp",o=wt(n),i=G(ce(),"Library","LaunchAgents");if(t){let s=r.appPath||process.execPath,c=r.args||[],l=[s,...c],d=`<?xml version="1.0" encoding="UTF-8"?>
|
|
897
|
+
`}import{accessSync as Hn,closeSync as qn,constants as Vn,openSync as jn,readSync as Kn,realpathSync as Gn}from"fs";import{resolveCraftBinary as Yn}from"craft-native";import{createDiskImage as Jn,macOSRuntimeExecutablePath as Qn,pack as Zn,packageApp as eo}from"craft-native";import{craftBinaryNotFoundMessage as to,resolveCraftBinary as ro}from"craft-native";function Xn(t,r="full"){let n=Yn(t,r),o=n;if(n==="craft"||n==="craft-webview"){let u=Bun.spawnSync(["pantry","which",n,"--resolve"]);if(u.exitCode!==0){let p=`${u.stderr}${u.stdout}`.trim();throw Error(`Cannot locate Craft's native executable. Install Craft through Pantry and use Pantry 0.11.114 or newer.${p?` ${p}`:""}`)}o=u.stdout.toString().trim()}let i=Gn(o);Hn(i,Vn.X_OK);let s=jn(i,"r"),c=Buffer.alloc(4);try{Kn(s,c,0,c.length,0)}finally{qn(s)}let l=c.readUInt32BE(0);if(!(process.platform==="darwin"?[4277009102,3472551422,4277009103,3489328638,3405691582,3199925962,3405691583,3216703178].includes(l):process.platform==="win32"?c[0]===77&&c[1]===90:l===2135247942))throw Error(`Craft packaging requires a native executable, received: ${i}`);return i}import V from"process";import{spawn as rt}from"child_process";import{AutoUpdater as nt,canReplaceBundle as no,clearQuarantine as oo,extractBundle as io,generateUpdateManifest as ot,readBundleIdentity as Ae,swapBundle as ao,verifyBundleTrust as so}from"craft-native";var it="update.json";function at(t,r){return`https://github.com/${t}/releases/latest/download/${r}`}function se(t,r,n){return`https://github.com/${t}/releases/download/${r}/${n}`}function st(t){let{repository:r,manifestAsset:n=it,...o}=t;return new nt({...o,updateUrl:at(r,n)})}function co(t){let r=t.tag??`v${t.version}`,n={};for(let[o,i]of Object.entries(t.artifacts)){if(!i)continue;n[o]={path:i,url:se(t.repository,r,i.split("/").pop())}}return ot({version:t.version,releaseNotes:t.releaseNotes,platforms:n})}function j(t=V.execPath){let r=t.split("/");for(let n=0;n<r.length;n++)if(r[n].endsWith(".app"))return r.slice(0,n+1).join("/");return null}async function lo(){let t=j();if(!t)return null;return(await Ae(t)).teamId}function ct(){let t=V.ppid;if(t>1)try{V.kill(t,"SIGTERM");return}catch{}V.exit(0)}function lt(t={}){let r=t.appPath??j(),n=t.quit??(()=>V.exit(0));if(r)(t.waitForPid&&Number.isSafeInteger(t.waitForPid)&&t.waitForPid>1?rt("/bin/sh",["-c",'attempt=0; while kill -0 "$1" 2>/dev/null; do attempt=$((attempt + 1)); [ "$attempt" -lt 200 ] || exit 1; sleep 0.1; done; exec /usr/bin/open -n "$2"',"stx-relaunch",String(t.waitForPid),r],{detached:!0,stdio:"ignore"}):rt("/usr/bin/open",["-n",r],{detached:!0,stdio:"ignore"})).unref();let o=t.quitDelayMs??0;if(o>0){setTimeout(n,o).unref?.();return}n()}async function Ce(t){let{appPath:r,requireSameTeam:n=!0,macos:o,...i}=t,s=r??j();if(!s)throw Error("createSelfUpdater: this process is not running from an .app bundle, so there is nothing to update. Pass `appPath` explicitly, or skip the updater in development.");let c=await Ae(s),l=o?.teamId??(n?c.teamId??void 0:void 0),d=o?.bundleIdentifier??c.identifier??void 0;return st({...i,appPath:s,macos:{...o,teamId:l,bundleIdentifier:d},relaunch:t.relaunch??((u)=>lt({appPath:u,quit:ct,quitDelayMs:250,waitForPid:V.ppid}))})}function dt(t){if(typeof process>"u"||process.platform!=="darwin")throw Error("Caffeinate requires macOS");let{dlopen:r,ptr:n}=e("bun:ffi"),o=r("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation",{CFStringCreateWithCString:{args:["ptr","ptr","u32"],returns:"ptr"},CFRelease:{args:["ptr"],returns:"void"}}),i=r("/System/Library/Frameworks/IOKit.framework/IOKit",{IOPMAssertionCreateWithName:{args:["ptr","u32","ptr","ptr"],returns:"i32"},IOPMAssertionRelease:{args:["u32"],returns:"i32"},IOPMAssertionDeclareUserActivity:{args:["ptr","u32","ptr"],returns:"i32"}}),s=[],c=!1;function l(){if(c)return;c=!0;for(let u of s)i.symbols.IOPMAssertionRelease(u);i.close(),o.close()}function d(u){let p=Buffer.from(`${u}\x00`),m=o.symbols.CFStringCreateWithCString(null,n(p),134217984);if(!m)throw Error("Could not create power assertion name");return m}try{let u=[[t.preventDisplaySleep??!0,"PreventUserIdleDisplaySleep"],[t.preventIdleSleep??!0,"PreventUserIdleSystemSleep"],[t.preventSystemSleep??!0,"PreventSystemSleep"],[t.preventDiskSleep??!1,"PreventDiskIdle"]];for(let[p,m]of u){if(!p)continue;let f=d(t.reason||"stx: keeping your Mac awake"),w=d(m),b=new Uint32Array(1);try{let S=i.symbols.IOPMAssertionCreateWithName(w,255,f,n(b));if(S!==0)throw Error(`Could not acquire ${m} (${S})`);s.push(b[0])}finally{o.symbols.CFRelease(f),o.symbols.CFRelease(w)}}if(!s.length)throw Error("At least one sleep prevention option must be enabled");if(t.assertUserActivity??!0){let p=d("stx: user activity"),m=new Uint32Array(1);try{let f=i.symbols.IOPMAssertionDeclareUserActivity(p,0,n(m));if(f!==0)throw Error(`Could not declare user activity (${f})`);s.push(m[0])}finally{o.symbols.CFRelease(p)}}return l}catch(u){throw l(),u}}var C=null;class ut{_release;_startedAt;_endsAt;_options;_expireHandlers=[];_expireTimer=null;_stopped=!1;constructor(t,r){this._release=t,this._options={...r},this._startedAt=new Date;let n=r.duration;if(n&&n>0){let o=n*60*1000;this._endsAt=new Date(this._startedAt.getTime()+o),this._expireTimer=setTimeout(()=>{this.stop();for(let i of this._expireHandlers)try{i()}catch{}},o)}else this._endsAt=null}get pid(){return process.pid}get startedAt(){return this._startedAt}get endsAt(){return this._endsAt}get options(){return{...this._options}}get isActive(){return!this._stopped}get remainingMs(){if(!this._endsAt)return null;let t=this._endsAt.getTime()-Date.now();return Math.max(0,t)}get elapsedMs(){return Date.now()-this._startedAt.getTime()}stop(){if(this._stopped)return;if(this._stopped=!0,this._expireTimer)clearTimeout(this._expireTimer),this._expireTimer=null;this._release()}onExpire(t){this._expireHandlers.push(t)}}function uo(t={}){if(t.duration!==void 0&&t.duration!==-1&&(!Number.isFinite(t.duration)||t.duration<=0))throw RangeError("duration must be positive minutes or -1 for indefinitely");let r=dt(t),n=new ut(r,t);return Ie(),C=n,n}function Ie(t){if(t){if(t.stop(),C===t)C=null;return}if(C)C.stop();C=null}function po(){return C!==null&&C.isActive}function fo(){if(!C||!C.isActive)return{active:!1,instance:null,startedAt:null,endsAt:null,durationMinutes:null};let r=C.options.duration;return{active:!0,instance:C,startedAt:C.startedAt,endsAt:C.endsAt,durationMinutes:r&&r>0?r:-1}}function mo(t){let r=t||C;if(!r||!r.isActive)return"0:00";let n=r.remainingMs;if(n===null)return"\u221E";let o=Math.ceil(n/1000),i=Math.floor(o/3600),s=Math.floor(o%3600/60),c=o%60;if(i>0)return`${i}:${String(s).padStart(2,"0")}:${String(c).padStart(2,"0")}`;return`${s}:${String(c).padStart(2,"0")}`}function go(t){if(t<=0||t===-1)return"Indefinitely";if(t<60)return`${t} minutes`;if(t===60)return"1 hour";if(t%60===0)return`${t/60} hours`;let r=Math.floor(t/60),n=t%60;return`${r}h ${n}m`}if(typeof process<"u")process.once("exit",()=>Ie());import{existsSync as $e,mkdirSync as ho,readFileSync as wo,watch as bo,writeFileSync as xo}from"fs";import{homedir as yo,platform as vo}from"os";import{dirname as Po,join as J}from"path";function So(t){let r=vo(),n=yo();switch(r){case"darwin":return J(n,"Library","Application Support",t);case"win32":return J(process.env.APPDATA||J(n,"AppData","Roaming"),t);default:return J(n,".config",t)}}class pt{_defaults;_data;_path;_changeHandlers=new Map;_anyChangeHandlers=new Set;_watcher=null;_writeTimer=null;_writing=!1;constructor(t){this._defaults={...t.defaults};let r=t.path?Po(t.path):So(t.name);if(this._path=t.path||J(r,"preferences.json"),!$e(r))ho(r,{recursive:!0});if(this._data=this._load(),t.watch!==!1)this._setupWatcher()}get path(){return this._path}get(t){if(t in this._data)return this._data[t];return this._defaults[t]}set(t,r){let n=this.get(t);if(JSON.stringify(n)===JSON.stringify(r))return;this._data[t]=r,this._scheduleSave(),this._notifyChange(t,r,n)}getAll(){return{...this._defaults,...this._data}}has(t){return t in this._data}delete(t){if(!(t in this._data))return;let r=this._data[t];delete this._data[t],this._scheduleSave(),this._notifyChange(t,this._defaults[t],r)}reset(){let t={...this._data};this._data={},this._save();for(let r of Object.keys(t)){let n=this._defaults[r];this._notifyChange(r,n,t[r])}}onChange(t,r){let n=t;if(!this._changeHandlers.has(n))this._changeHandlers.set(n,new Set);return this._changeHandlers.get(n).add(r),()=>{this._changeHandlers.get(n)?.delete(r)}}onAnyChange(t){return this._anyChangeHandlers.add(t),()=>{this._anyChangeHandlers.delete(t)}}close(){if(this._watcher)this._watcher.close(),this._watcher=null;if(this._writeTimer)clearTimeout(this._writeTimer),this._writeTimer=null,this._save()}_load(){try{if($e(this._path)){let t=wo(this._path,"utf-8");return JSON.parse(t)}}catch{}return{}}_save(){this._writing=!0;try{let t=JSON.stringify({...this._defaults,...this._data},null,2);xo(this._path,t,"utf-8")}catch(t){console.error(`Failed to save preferences to ${this._path}:`,t)}finally{setTimeout(()=>{this._writing=!1},100)}}_scheduleSave(){if(this._writeTimer)clearTimeout(this._writeTimer);this._writeTimer=setTimeout(()=>{this._writeTimer=null,this._save()},50)}_setupWatcher(){try{if(!$e(this._path))this._save();this._watcher=bo(this._path,()=>{if(this._writing)return;let t=this._load(),r={...this._data};this._data=t;let n=new Set([...Object.keys(r),...Object.keys(t)]);for(let o of n){let i=o in r?r[o]:this._defaults[o],s=o in t?t[o]:this._defaults[o];if(JSON.stringify(i)!==JSON.stringify(s))this._notifyChange(o,s,i)}})}catch{}}_notifyChange(t,r,n){let o=this._changeHandlers.get(t);if(o)for(let i of o)try{i(r,n)}catch{}for(let i of this._anyChangeHandlers)try{i(t,r,n)}catch{}}}function ko(t){return new pt(t)}import{existsSync as K,mkdirSync as ft,readFileSync as Ao,unlinkSync as mt,writeFileSync as gt}from"fs";import{homedir as ce,platform as ht}from"os";import{join as G}from"path";function wt(t){let r=t.toLowerCase().replace(/[^a-z0-9]/g,"-");return G(ce(),"Library","LaunchAgents",`com.${r}.plist`)}function bt(t){let r=process.env.XDG_CONFIG_HOME||G(ce(),".config");return G(r,"autostart",`${t.toLowerCase()}.desktop`)}async function Co(t,r){let n=r.appName||"StxApp",o=wt(n),i=G(ce(),"Library","LaunchAgents");if(t){let s=r.appPath||process.execPath,c=r.args||[],l=[s,...c],d=`<?xml version="1.0" encoding="UTF-8"?>
|
|
898
898
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
899
899
|
<plist version="1.0">
|
|
900
900
|
<dict>
|
|
@@ -902,7 +902,7 @@ window.desktop = window.stxWindow;
|
|
|
902
902
|
<string>com.${n.toLowerCase().replace(/[^a-z0-9]/g,"-")}</string>
|
|
903
903
|
<key>ProgramArguments</key>
|
|
904
904
|
<array>
|
|
905
|
-
${l.map((u)=>` <string>${
|
|
905
|
+
${l.map((u)=>` <string>${Eo(u)}</string>`).join(`
|
|
906
906
|
`)}
|
|
907
907
|
</array>
|
|
908
908
|
<key>RunAtLoad</key>
|
|
@@ -912,7 +912,7 @@ ${l.map((u)=>` <string>${To(u)}</string>`).join(`
|
|
|
912
912
|
${r.isHidden?` <key>ProcessType</key>
|
|
913
913
|
<string>Background</string>`:""}
|
|
914
914
|
</dict>
|
|
915
|
-
</plist>`;if(!K(i))ft(i,{recursive:!0});gt(o,d,"utf-8")}else if(K(o))mt(o)}async function
|
|
915
|
+
</plist>`;if(!K(i))ft(i,{recursive:!0});gt(o,d,"utf-8")}else if(K(o))mt(o)}async function Io(t,r){let n=r.appName||"StxApp",o=bt(n),i=G(process.env.XDG_CONFIG_HOME||G(ce(),".config"),"autostart");if(t){let s=r.appPath||process.execPath,c=r.args||[],l=[s,...c].join(" "),d=`[Desktop Entry]
|
|
916
916
|
Type=Application
|
|
917
917
|
Name=${n}
|
|
918
918
|
Exec=${l}
|
|
@@ -920,11 +920,11 @@ Terminal=false
|
|
|
920
920
|
StartupNotify=false
|
|
921
921
|
${r.isHidden?`X-GNOME-Autostart-enabled=true
|
|
922
922
|
NoDisplay=true`:""}
|
|
923
|
-
`;if(!K(i))ft(i,{recursive:!0});gt(o,d,"utf-8")}else if(K(o))mt(o)}async function
|
|
923
|
+
`;if(!K(i))ft(i,{recursive:!0});gt(o,d,"utf-8")}else if(K(o))mt(o)}async function $o(t){return K(wt(t))}async function To(t){let r=bt(t);if(!K(r))return!1;try{let n=Ao(r,"utf-8");if(n.includes("X-GNOME-Autostart-enabled=false"))return!1;if(n.includes("Hidden=true"))return!1;return!0}catch{return!1}}function Eo(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function Mo(t,r={}){let n=ht();switch(n){case"darwin":return Co(t,r);case"linux":return Io(t,r);default:throw Error(`Auto-launch is not yet supported on ${n}`)}}async function Do(t){let r=t||"StxApp";switch(ht()){case"darwin":return $o(r);case"linux":return To(r);default:return!1}}var R=new Map,Bo=0,le=!1;function xt(t){let r=t.split("+").map((o)=>o.trim()),n={key:"",meta:!1,ctrl:!1,shift:!1,alt:!1};for(let o of r){let i=o.toLowerCase();switch(i){case"cmd":case"command":case"meta":case"\u2318":n.meta=!0;break;case"ctrl":case"control":case"\u2303":n.ctrl=!0;break;case"shift":case"\u21E7":n.shift=!0;break;case"alt":case"option":case"opt":case"\u2325":n.alt=!0;break;case"cmdorctrl":case"commandorcontrol":if(typeof process<"u"&&process.platform==="darwin")n.meta=!0;else n.ctrl=!0;break;default:n.key=i}}return n}function Oo(t){let r=[];if(t.ctrl)r.push("\u2303");if(t.alt)r.push("\u2325");if(t.shift)r.push("\u21E7");if(t.meta)r.push("\u2318");return r.push(t.key.toUpperCase()),r.join("")}function Ro(t,r){if(r.meta!==t.metaKey)return!1;if(r.ctrl!==t.ctrlKey)return!1;if(r.shift!==t.shiftKey)return!1;if(r.alt!==t.altKey)return!1;return t.key.toLowerCase()===r.key||t.code.toLowerCase()===`key${r.key}`}function yt(t){for(let[,r]of R)if(Ro(t,r.parsed)){t.preventDefault(),t.stopPropagation();try{r.handler()}catch{}break}}function Lo(){if(le)return;if(typeof document>"u")return;document.addEventListener("keydown",yt,!0),le=!0}function Te(){if(!le)return;if(typeof document>"u")return;document.removeEventListener("keydown",yt,!0),le=!1}async function _o(t,r){if(typeof window>"u")return!1;let n=window.craft;if(!n?.hotkeys?.register)return!1;try{return await n.hotkeys.register(t,r),!0}catch{return!1}}async function Ee(t){if(typeof window>"u")return;let r=window.craft;if(!r?.hotkeys?.unregister)return;try{await r.hotkeys.unregister(t)}catch{}}function No(t,r){let n=`hotkey_${++Bo}_${Date.now()}`,o=xt(t);R.set(n,{shortcut:t,handler:r,parsed:o}),_o(n,t),Lo();let i={shortcut:t,id:n,unregister(){vt(i)}};return i}function vt(t){if(R.delete(t.id),Ee(t.id),R.size===0)Te()}function Fo(){for(let[t]of R)Ee(t);R.clear(),Te()}function zo(){return Array.from(R.entries()).map(([t,r])=>({shortcut:r.shortcut,id:t,unregister(){if(R.delete(t),Ee(t),R.size===0)Te()}}))}class Pt{_duration;_tickInterval;_remaining;_running=!1;_paused=!1;_complete=!1;_intervalId=null;_lastTick=0;_completionHandlers=new Set;_tickHandlers=new Set;constructor(t){if(this._duration=t.duration,this._tickInterval=t.tickInterval||1000,this._remaining=t.duration,t.onComplete)this._completionHandlers.add(t.onComplete);if(t.onTick)this._tickHandlers.add(t.onTick);if(t.autoStart)this.start()}get isRunning(){return this._running&&!this._paused}get isPaused(){return this._paused}get isComplete(){return this._complete}get remaining(){if(this._running&&!this._paused){let t=Date.now()-this._lastTick;return Math.max(0,this._remaining-t)}return Math.max(0,this._remaining)}get elapsed(){return this._duration-this.remaining}get duration(){return this._duration}get progress(){if(this._duration===0)return 1;return Math.min(1,this.elapsed/this._duration)}start(){if(this._running)return;this._running=!0,this._paused=!1,this._complete=!1,this._lastTick=Date.now(),this._startInterval()}stop(){this._clearInterval(),this._running=!1,this._paused=!1,this._remaining=this._duration}pause(){if(!this._running||this._paused)return;let t=Date.now()-this._lastTick;this._remaining=Math.max(0,this._remaining-t),this._clearInterval(),this._paused=!0}resume(){if(!this._paused)return;this._paused=!1,this._lastTick=Date.now(),this._startInterval()}reset(){this._clearInterval(),this._running=!1,this._paused=!1,this._complete=!1,this._remaining=this._duration}onComplete(t){return this._completionHandlers.add(t),()=>{this._completionHandlers.delete(t)}}onTick(t){return this._tickHandlers.add(t),()=>{this._tickHandlers.delete(t)}}_startInterval(){this._clearInterval(),this._intervalId=setInterval(()=>{let t=Date.now(),r=t-this._lastTick;this._lastTick=t,this._remaining=Math.max(0,this._remaining-r);for(let n of this._tickHandlers)try{n(this._remaining)}catch{}if(this._remaining<=0){this._clearInterval(),this._running=!1,this._complete=!0;for(let n of this._completionHandlers)try{n()}catch{}}},this._tickInterval)}_clearInterval(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null}}class St{_interval;_handler;_immediate;_running=!1;_intervalId=null;constructor(t){if(this._interval=t.interval,this._handler=t.handler,this._immediate=t.immediate!==!1,this._immediate)this.start()}get isRunning(){return this._running}start(){if(this._running)return;this._running=!0,this._intervalId=setInterval(()=>{try{this._handler()}catch{}},this._interval)}stop(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null;this._running=!1}}function Wo(t){return new Pt(t)}function Uo(t){return new St(t)}function Ho(t){return new Promise((r)=>setTimeout(r,t))}function qo(t){let r=Math.ceil(t/1000),n=Math.floor(r/3600),o=Math.floor(r%3600/60),i=r%60;if(n>0)return`${n}:${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`;return`${o}:${String(i).padStart(2,"0")}`}function Vo(t){let r=Math.ceil(t/1000),n=Math.floor(r/3600),o=Math.floor(r%3600/60),i=r%60;if(n>0){if(o>0)return`${n}h ${o}m`;return`${n}h`}if(o>0){if(i>0)return`${o}m ${i}s`;return`${o}m`}return`${i}s`}function a(t){if(typeof window>"u")return!1;let r=window.craft;return!!(r&&r[t])}function x(t){if(!a(t))throw Error(`craft.${t} is not available \u2014 this API requires a Craft native window`);return window.craft[t]}function g(t,r){if(typeof window>"u")return()=>{};let n=(o)=>r(o.detail??{});return window.addEventListener(t,n),()=>window.removeEventListener(t,n)}var jo={async historySnapshot(t=-1){if(!Number.isSafeInteger(t))throw Error("Clipboard history requires an integer change cursor.");let r=x("clipboard");if(!r.historySnapshot)throw Error("This Craft runtime does not support protected clipboard history.");return r.historySnapshot(t)},async writeText(t){if(a("clipboard")){await window.craft.clipboard.writeText(t);return}if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(t)},async readText(){if(a("clipboard")){let t=await window.craft.clipboard.readText();return typeof t==="string"?t:""}if(typeof navigator<"u"&&navigator.clipboard?.readText)try{return await navigator.clipboard.readText()}catch{return""}return""},async writeHTML(t){if(a("clipboard")){await window.craft.clipboard.writeHTML(t);return}if(typeof navigator<"u"&&navigator.clipboard?.write)try{let r=new window.ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([Ko(t)],{type:"text/plain"})});await navigator.clipboard.write([r])}catch{}},async readHTML(){if(a("clipboard")){let t=await window.craft.clipboard.readHTML();return typeof t==="string"?t:""}if(typeof navigator<"u"&&navigator.clipboard?.read)try{let t=await navigator.clipboard.read();for(let r of t)if(r.types.includes("text/html"))return await(await r.getType("text/html")).text()}catch{}return""},async clear(){if(a("clipboard")){await window.craft.clipboard.clear();return}if(typeof navigator<"u"&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText("")}catch{}},async hasText(){if(a("clipboard"))return await window.craft.clipboard.hasText();return(await this.readText()).length>0},async hasHTML(){if(a("clipboard"))return await window.craft.clipboard.hasHTML();return(await this.readHTML()).length>0},async hasImage(){if(a("clipboard"))return await window.craft.clipboard.hasImage();return!1}};function Ko(t){return t.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<\/?(br|p|div|li|h[1-6])\b[^>]*>/gi,`
|
|
924
924
|
`).replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/\n{3,}/g,`
|
|
925
925
|
|
|
926
|
-
`).trim()}var Ko={async show(t){if(!t.title)throw Error("notification title is required");if(a("notifications")){await window.craft.notifications.show(t);return}if(typeof window<"u"&&"Notification"in window){let r=window.Notification;if(r.permission==="granted")new r(t.title,{body:t.body,icon:t.icon});else if(r.permission==="default"){if(await r.requestPermission()==="granted")new r(t.title,{body:t.body,icon:t.icon})}}},async schedule(t){if(a("notifications")){let o={...t};if(o.triggerAt instanceof Date)o.triggerAt=o.triggerAt.toISOString();await window.craft.notifications.schedule(o);return}let r=Go(t.triggerAt),n=Math.max(0,r-Date.now());setTimeout(()=>{this.show(t).catch(()=>{})},n)},async cancel(t){if(a("notifications"))await window.craft.notifications.cancel(t)},async cancelAll(){if(a("notifications"))await window.craft.notifications.cancelAll()},async setBadge(t){let r=Math.max(0,Math.round(Number.isFinite(t)?t:0));if(a("notifications")){await window.craft.notifications.setBadge(r);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(r)}catch{}},async clearBadge(){if(a("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(a("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let t=window.Notification;if(t.permission==="granted")return!0;if(t.permission==="denied")return!1;return await t.requestPermission()==="granted"}return!1},async registerCategories(t){if(!Array.isArray(t)||t.length===0)return;if(a("notifications")){let r=window.craft.notifications.registerCategories;if(typeof r==="function")await r(t)}},onActionClicked(t){return g("craft:notification:actionClicked",t)},onReply(t){return g("craft:notification:reply",t)}};function Go(t){if(t==null)return Date.now();if(t instanceof Date)return t.getTime();if(typeof t==="number")return t;let r=Date.parse(t);return Number.isNaN(r)?Date.now():r}var Yo={async readFile(t){let r=await x("fs").readFile(t);return r&&r.data||""},async readBuffer(t){let r=await x("fs").readFile(t),n=r&&r.data||"";if(r&&r.base64===!0)return Jo(n);return new TextEncoder().encode(n)},async writeFile(t,r){await x("fs").writeFile(t,r)},async writeBuffer(t,r){let n=Xo(r),o=x("fs");if(typeof o.writeFileBytes==="function")await o.writeFileBytes(t,n);else await o.writeFile(t,n)},async copy(t,r){if(t===r)throw Error("fs.copy: source and destination must differ");await x("fs").copy(t,r)},async move(t,r){if(t===r)throw Error("fs.move: source and destination must differ");await x("fs").move(t,r)},async appendFile(t,r){await x("fs").appendFile(t,r)},async deleteFile(t){await x("fs").deleteFile(t)},async exists(t){return await x("fs").exists(t)},async stat(t){return Qo(await x("fs").stat(t))},async readDir(t){let r=await x("fs").readDir(t),n=r&&r.entries||[],o=t.endsWith("/")?t.slice(0,-1):t;return n.map((i)=>({name:i.name,path:`${o}/${i.name}`,isDirectory:!!i.isDirectory}))},async mkdir(t,r){await x("fs").mkdir(t,r)},async rmdir(t,r){await x("fs").rmdir(t,r)},async watch(t,r){await x("fs").watch(t,r)},async unwatch(t){await x("fs").unwatch(t)},onChange(t){return g("craft:fs:change",t)},async watchTree(t,r,n){let o=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,i=x("fs");await i.watch(t,o,{recursive:!!r.recursive});let s=r.kinds&&r.kinds.length>0?new Set(r.kinds):null,c=Math.max(0,Math.floor(r.coalesceMs??0)),l=[],d=null,u=!1,p=()=>{if(d=null,l.length===0)return;let f=l;l=[];try{n(f)}catch{}},m=g("craft:fs:change",(f)=>{if(u)return;if(f.id!==o)return;if(s&&f.kind&&!s.has(f.kind))return;if(l.push(f),c===0){p();return}if(d==null)d=setTimeout(p,c)});return{id:o,async stop(){if(u)return;if(u=!0,m(),d)clearTimeout(d),d=null;if(l.length>0)p();try{await i.unwatch(o)}catch{}}}},async homeDir(){return await x("fs").homeDir()},async tempDir(){return await x("fs").tempDir()},async appDataDir(){return await x("fs").appDataDir()}};function Xo(t){let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return typeof btoa==="function"?btoa(r):Buffer.from(t).toString("base64")}function Jo(t){let r=typeof atob==="function"?atob(t):Buffer.from(t,"base64").toString("binary"),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);return n}function Qo(t){return{isFile:!!t.isFile,isDirectory:!!t.isDirectory,isSymlink:!!t.isSymlink,size:Number(t.size)||0,modifiedAt:t.modifiedAt!=null?t.modifiedAt<1000000000000?t.modifiedAt*1000:t.modifiedAt:0}}var Q=new Set,kt=!1;function Zo(){if(kt)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(t)=>{let r=t.detail;if(r?.id)Q.delete(r.id)}),kt=!0}var ei=new Set(["javascript:","data:","file:","vbscript:"]),ti={async openExternal(t){let r=t.trim().toLowerCase();for(let n of ei)if(r.startsWith(n))throw Error(`shell.openExternal: ${n} URLs are blocked for safety`);if(a("shell")){await window.craft.shell.openExternal(t);return}if(typeof window<"u"&&typeof window.open==="function")window.open(t,"_blank","noopener,noreferrer")},async openPath(t){await x("shell").openPath(t)},async showInFinder(t){await x("shell").showInFinder(t)},async spawn(t,r,n=[],o={}){if(Zo(),!t||typeof t!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!r||typeof r!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(n))throw Error("shell.spawn: args must be an array");for(let i of n)if(typeof i!=="string")throw Error("shell.spawn: args entries must be strings");if(Q.has(t))throw Error(`shell.spawn: id "${t}" is already in use \u2014 call kill(id) first or pick a different id`);Q.add(t);try{await x("shell").spawn(t,r,n,o)}catch(i){throw Q.delete(t),i}},async kill(t){await x("shell").kill(t),Q.delete(t)},async getEnv(t){if(a("shell")){let r=await window.craft.shell.getEnv(t);return r==null?void 0:String(r)}return},async setEnv(t,r){await x("shell").setEnv(t,r)},onStdout(t){return g("craft:shell:stdout",t)},onStderr(t){return g("craft:shell:stderr",t)},onExit(t){return g("craft:shell:exit",t)}};function z(){return window.craft.shortcuts}var ri={async register(t,r,n){if(!a("shortcuts"))return;await z().register(t,r,n)},async unregister(t){if(!a("shortcuts"))return;await z().unregister(t)},async unregisterAll(){if(!a("shortcuts"))return;await z().unregisterAll()},async enable(t){if(!a("shortcuts"))return;await z().enable(t)},async disable(t){if(!a("shortcuts"))return;await z().disable(t)},async isRegistered(t){if(!a("shortcuts"))return!1;return await z().isRegistered(t)},async list(){if(!a("shortcuts"))return[];return await z().list()},on(t){return g("craft:shortcut",t)}};var ni={get(){if(a("theme"))try{return window.craft.theme.get()}catch{}return{appearance:oi()}},onChange(t){if(t(this.get()),a("theme"))return g("craft:theme",t);if(typeof window<"u"&&window.matchMedia){let r=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>t({appearance:r.matches?"dark":"light"});return r.addEventListener("change",n),()=>r.removeEventListener("change",n)}return()=>{}},async current(){return this.get()}};function oi(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function ii(t,r={}){if(!a("dragOut"))throw Error("dragOut requires a Craft native window");let n=Array.isArray(t)?t:[t];if(n.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start(n,r)}function ai(){return a("dragOut")}var si={onUrl(t){if(!a("deepLink"))return()=>{};return g("craft:deepLink",t)},getInitialUrl(){if(typeof window>"u")return null;if(a("deepLink"))try{return window.craft.deepLink.getInitialUrl()}catch{return null}return window.__craftPendingDeepLink||null},consumeInitialUrl(){let t=this.getInitialUrl();if(typeof window<"u")window.__craftPendingDeepLink=void 0;return t},isAvailable(){return a("deepLink")}};var ci={async isCharging(){if(a("power"))return await window.craft.power.isCharging();let t=await de();return t?!!t.charging:!1},async isPluggedIn(){if(a("power"))return await window.craft.power.isPluggedIn();let t=await de();return t?!!t.charging||t.level>=0.999:!1},async isLowPowerMode(){if(a("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(a("power")){let r=await window.craft.power.batteryLevel();return typeof r==="number"?r:null}let t=await de();return t?t.level:null},async timeRemaining(){if(a("power")){let n=await window.craft.power.timeRemaining();return typeof n==="number"?n:null}let t=await de();if(!t)return null;let r=t.charging?t.chargingTime:t.dischargingTime;return Number.isFinite(r)?Math.round(r/60):null},async thermalState(){if(a("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(a("power"))return await window.craft.power.uptimeSeconds();if(typeof performance<"u"&&typeof performance.now==="function")return Math.round(performance.now()/1000);return 0},async preventSleep(t="app is busy"){if(a("power")){await window.craft.power.preventSleep(t);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let r=window;if(r.__craftWebWakeLock?.release){try{await r.__craftWebWakeLock.release()}catch{}r.__craftWebWakeLock=null}try{let n=await navigator.wakeLock.request("screen");r.__craftWebWakeLock=n}catch{}},async allowSleep(){if(a("power")){await window.craft.power.allowSleep();return}let t=window.__craftWebWakeLock;if(t&&typeof t.release==="function"){try{await t.release()}catch{}window.__craftWebWakeLock=null}},onSleep(t){return g("craft:powerSleep",t)},onWake(t){return g("craft:powerWake",t)}};async function de(){if(typeof navigator>"u")return null;let t=navigator;if(typeof t.getBattery!=="function")return null;try{return await t.getBattery()}catch{return null}}var li={async connectionType(){if(a("network"))return await window.craft.network.connectionType();return At()},async wifiSSID(){if(a("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(a("network")){let t=await window.craft.network.wifiSignalStrength();return typeof t==="number"?t:void 0}return},async ipAddress(){if(a("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(a("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(a("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(a("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(a("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(a("network"))await window.craft.network.openPreferences()},onChange(t){if(a("network"))return g("craft:networkChange",t);if(typeof window>"u")return()=>{};let r=()=>t({type:At(),online:!0}),n=()=>t({type:"none",online:!1});return window.addEventListener("online",r),window.addEventListener("offline",n),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}};function At(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let t=navigator.connection;if(!t)return"unknown";let r=String(t.type||t.effectiveType||"unknown").toLowerCase();if(r==="wifi"||r==="cellular"||r==="ethernet"||r==="bluetooth"||r==="none")return r;return"unknown"}var di={async checkForUpdates(){if(!a("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!a("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(t){if(!a("updater"))return;await window.craft.updater.setAutomaticChecks(t)},async setCheckInterval(t){if(!a("updater"))return;if(!Number.isFinite(t))throw Error("setCheckInterval: must be a finite number");let r=t<=0?0:Math.max(60,Math.round(t));await window.craft.updater.setCheckInterval(r)},async setFeedURL(t){if(!a("updater"))return;await window.craft.updater.setFeedURL(t)},async getLastUpdateCheckDate(){if(!a("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!a("updater"))return null;let t=await window.craft.updater.getUpdateInfo();if(!t||typeof t.version!=="string"||t.version.length===0)return null;return t},onAvailable(t){return g("craft:updateAvailable",t)},onDownloaded(t){return g("craft:updateDownloaded",t)},async verifySignature({payload:t,signatureB64:r,publicKeyB64:n}){let o=Ct(t),i;try{i=await crypto.subtle.importKey("raw",ue(n),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",i,ue(r),o)}catch{return!1}},async verifyDownload({url:t,signatureB64:r,publicKeyB64:n,fetchInit:o}){let i;try{i=await fetch(t,o)}catch{return{ok:!1,reason:"fetch-failed"}}if(!i.ok)return{ok:!1,reason:"http-error",status:i.status};let s=new Uint8Array(await i.arrayBuffer()),c;try{c=await crypto.subtle.importKey("raw",ue(n),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let l=!1;try{l=await crypto.subtle.verify("Ed25519",c,ue(r),Ct(s))}catch{l=!1}if(!l)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:s}}};function Ct(t){if(t instanceof ArrayBuffer)return new Uint8Array(t);let r=new ArrayBuffer(t.byteLength),n=new Uint8Array(r);return n.set(t),n}function ue(t){if(typeof atob==="function"){let o=atob(t),i=new ArrayBuffer(o.length),s=new Uint8Array(i);for(let c=0;c<o.length;c++)s[c]=o.charCodeAt(c);return s}let r=Buffer.from(t,"base64"),n=new ArrayBuffer(r.length);return new Uint8Array(n).set(r),new Uint8Array(n)}var ui={onFocus(t){if(a("window"))return g("craft:window:focus",()=>t());return Me("focus",t)},onBlur(t){if(a("window"))return g("craft:window:blur",()=>t());return Me("blur",t)},onResize(t){if(a("window"))return g("craft:window:resize",t);if(typeof window>"u")return()=>{};let r=()=>t({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},onMove(t){if(a("window"))return g("craft:window:move",t);return()=>{}},onClose(t){if(a("window"))return g("craft:window:close",()=>t());return Me("beforeunload",t)},onMinimize(t){if(a("window"))return g("craft:window:minimize",()=>t());if(typeof document>"u")return()=>{};let r=()=>{if(document.visibilityState==="hidden")t()};return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)},onRestore(t){if(a("window"))return g("craft:window:restore",()=>t());if(typeof document>"u")return()=>{};let r=()=>{if(document.visibilityState==="visible")t()};return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)}};function Me(t,r){if(typeof window>"u")return()=>{};let n=()=>r();return window.addEventListener(t,n),()=>window.removeEventListener(t,n)}var It={name:"",version:"0.0.0"},pi={async icon(t){if(!t.startsWith("/")||!t.endsWith(".app")||t.includes("\x00"))throw Error("Application icons require an absolute .app path.");let r=x("app");if(!r.icon)throw Error("This Craft runtime does not support native application icons.");return r.icon(t)},async hideDockIcon(){if(a("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(a("app"))await window.craft.app.showDockIcon()},async quit(){if(a("app"))await window.craft.app.quit()},async getInfo(){if(!a("app"))return It;let t=await window.craft.app.getInfo();return{...It,...t||{}}},async notify(t){if(!t.title)throw Error("notify: title is required");if(a("app"))await window.craft.app.notify(t)},async setBadge(t){if(a("app"))await window.craft.app.setBadge(t)},async bounce(t="informational"){if(a("app"))await window.craft.app.bounce(t)}};var fi={app(t,r={}){return{label:t,items:[{label:`About ${t}`,role:"about"},{separator:!0},...r.settings?[{id:"stx.menu.settings",label:"Settings\u2026",shortcut:"cmd+,",onClick:r.settings},{separator:!0}]:[],{label:`Hide ${t}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${t}`,role:"quit",shortcut:"cmd+q"}]}},edit(){return{label:"Edit",items:[{label:"Undo",role:"undo",shortcut:"cmd+z"},{label:"Redo",role:"redo",shortcut:"cmd+shift+z"},{separator:!0},{label:"Cut",role:"cut",shortcut:"cmd+x"},{label:"Copy",role:"copy",shortcut:"cmd+c"},{label:"Paste",role:"paste",shortcut:"cmd+v"},{label:"Select All",role:"selectAll",shortcut:"cmd+a"}]}},window(){return{label:"Window",items:[{label:"Minimize",role:"minimize",shortcut:"cmd+m"},{label:"Zoom",role:"zoom"},{separator:!0},{label:"Close Window",role:"close",shortcut:"cmd+w"}]}},leading(t,r={}){return[this.app(t,r),this.edit()]}},mi=0;function gi(t){let r=new Map;return{payload:{menus:t.menus.map((o)=>({label:o.label,items:o.items.map((i)=>{let{onClick:s,...c}=i;if(c.separator)return c;let l=c.id??`stx.menu.${mi++}`;if(s)r.set(l,s);return{...c,id:l}})}))},handlers:r}}var De=null,hi={async set(t){if(!a("menu"))return!1;let{payload:r,handlers:n}=gi(t);if(De?.(),De=null,n.size>0)De=g("craft:menu:action",(o)=>{n.get(o.id)?.()});return await window.craft.menu.set(r),!0},async setDock(t){if(a("menu"))await window.craft.menu.setDock(t)},async addItem(t,r){if(a("menu"))await window.craft.menu.addItem(t,r)},async removeItem(t){if(a("menu"))await window.craft.menu.removeItem(t)},async enableItem(t){if(a("menu"))await window.craft.menu.enableItem(t)},async disableItem(t){if(a("menu"))await window.craft.menu.disableItem(t)},async checkItem(t){if(a("menu"))await window.craft.menu.checkItem(t)},async uncheckItem(t){if(a("menu"))await window.craft.menu.uncheckItem(t)},async setItemLabel(t,r){if(a("menu"))await window.craft.menu.setItemLabel(t,r)},async clearDock(){if(a("menu"))await window.craft.menu.clearDock()},onAction(t){return g("craft:menu:action",t)}};function Tt(t){if(t.separator)return{id:t.id||"",title:"",type:"separator"};return{id:t.id||"",title:t.title||"",icon:t.icon,shortcut:t.shortcut,enabled:t.disabled?!1:void 0,checked:t.checked?!0:void 0,type:t.submenu?"submenu":void 0,submenu:t.submenu?.map(Tt)}}async function $t(t){if(!t.items||t.items.length===0)throw Error("contextMenu.show requires at least one item");if(!a("nativeUI"))return null;let r=window.craft?.nativeUI;if(!r)return null;let n=await r.showContextMenu({targetId:t.targetId||"",targetType:"general",x:Math.round(t.x),y:Math.round(t.y),items:t.items.map(Tt)});return{id:typeof n?.id==="string"?n.id:null,targetId:n?.targetId}}var wi={available(){return a("nativeUI")},async show(t){return await $t(t)!==null},async pick(t){return(await $t(t))?.id??null},onAction(t){return g("craft:contextmenu:action",(r)=>{if(typeof r.id==="string")t({id:r.id,targetId:r.targetId??""})})}};function Be(t){if(t===null||t===void 0||t===0)return"";return String(t)}function Et(t){return t.map((r)=>({id:r.id,header:r.header,items:r.items.map((n)=>({id:n.id,label:n.label,icon:n.icon,badge:Be(n.badge)||void 0}))}))}function Mt(t){return JSON.stringify(t.map((r)=>[r.id,r.header??"",r.items.map((n)=>[n.id,n.label,n.icon??""])]))}function Dt(t){return new Map(t.flatMap((r)=>r.items.map((n)=>[n.id,Be(n.badge)])))}var Bt={available(){return a("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(t){if(!Bt.available())return null;let r=window.craft?.nativeUI;if(!r)return null;let n=r.createSidebar({id:t.id,sections:Et(t.sections),selected:t.selected}),o=t.sections,i=new Set;return n.onSelect((s)=>{for(let c of[...i])c(s)}),{id:n.id,update(s){if(Mt(s)===Mt(o)){let c=Dt(o);for(let[l,d]of Dt(s))if(c.get(l)!==d)n.updateItem(l,{badge:d})}else n.setSections(Et(s));o=s},updateItem(s,c){n.updateItem(s,{...c.label!==void 0?{label:c.label}:{},...c.icon!==void 0?{icon:c.icon}:{},..."badge"in c?{badge:Be(c.badge)}:{}}),o=o.map((l)=>({...l,items:l.items.map((d)=>d.id===s?{...d,...c}:d)}))},select(s){n.setSelectedItem(s)},onSelect(s){return i.add(s),()=>i.delete(s)},destroy(){i.clear(),n.destroy()}}}};var bi={accentColor:()=>E("system","accentColor",()=>""),highlightColor:()=>E("system","highlightColor",()=>""),language:()=>E("system","language",()=>{if(typeof navigator>"u")return"";return navigator.language?.split("-")[0]||""}),locale:()=>E("system","locale",()=>{if(typeof navigator>"u")return"";return navigator.language||""}),timezone:()=>E("system","timezone",()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||""}catch{return""}}),is24HourTime:()=>E("system","is24HourTime",()=>{try{let t=new Intl.DateTimeFormat([],{hour:"numeric"}).resolvedOptions();return t.hourCycle==="h23"||t.hourCycle==="h24"}catch{return!1}}),reduceMotion:()=>E("system","reduceMotion",()=>Oe("(prefers-reduced-motion: reduce)")),reduceTransparency:()=>E("system","reduceTransparency",()=>Oe("(prefers-reduced-transparency: reduce)")),increaseContrast:()=>E("system","increaseContrast",()=>Oe("(prefers-contrast: more)")),systemVersion:()=>E("system","systemVersion",()=>""),hostname:()=>E("system","hostname",()=>""),username:()=>E("system","username",()=>""),async openPreferences(){if(a("system"))await window.craft.system.openPreferences()}};async function E(t,r,n){if(a(t))return await window.craft[t][r]();return await n()}function Oe(t){if(typeof window>"u"||!window.matchMedia)return!1;return window.matchMedia(t).matches}var xi={async getDisplays(){if(a("screen"))return await window.craft.screen.getDisplays();return Ot()},async getPrimary(){if(a("screen")){let t=await window.craft.screen.getPrimary();return t&&typeof t.width==="number"?t:null}return Ot()[0]??null},onChange(t){if(a("screen"))return g("craft:screen:change",()=>t());if(typeof window>"u")return()=>{};let r=()=>t();return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)}};function Ot(){if(typeof window>"u"||!window.screen)return[];let t=window.screen;return[{id:0,x:t.left??0,y:t.top??0,width:t.width||0,height:t.height||0,workX:t.availLeft??0,workY:t.availTop??0,workWidth:t.availWidth??t.width??0,workHeight:t.availHeight??t.height??0,scaleFactor:window.devicePixelRatio||1}]}var yi={async set(t,r,n){if(!t)throw Error("keychain.set: service is required");if(!r)throw Error("keychain.set: account is required");await x("keychain").set(t,r,n)},async get(t,r){if(!t)throw Error("keychain.get: service is required");if(!r)throw Error("keychain.get: account is required");let n=await x("keychain").get(t,r);return typeof n==="string"?n:null},async delete(t,r){if(!t)throw Error("keychain.delete: service is required");if(!r)throw Error("keychain.delete: account is required");await x("keychain").delete(t,r)},async has(t,r){if(!t)throw Error("keychain.has: service is required");if(!r)throw Error("keychain.has: account is required");return await x("keychain").has(t,r)}};var vi={async check(t){if(a("permissions"))return await window.craft.permissions.check(t);return await Rt(t)},async request(t){if(a("permissions"))return await window.craft.permissions.request(t);return await Pi(t)},async openSettings(t){if(a("permissions"))await window.craft.permissions.openSettings(t)}};async function Rt(t){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let r=await navigator.permissions.query({name:t});return Si(r.state)}catch{return"not-supported"}}async function Pi(t){if(t==="notifications"&&typeof window<"u"&&"Notification"in window){let r=await window.Notification.requestPermission();return r==="granted"?"granted":r==="denied"?"denied":"undetermined"}return await Rt(t)}function Si(t){if(t==="granted")return"granted";if(t==="denied")return"denied";if(t==="prompt")return"undetermined";return"undetermined"}var ki={async print(){if(a("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(t){if(!t)throw Error("printToPDF: path is required");let r=t.startsWith("/"),n=/^[a-zA-Z]:[\\/]/.test(t)||t.startsWith("\\\\");if(!r&&!n)throw Error("printToPDF: path must be absolute");let o=await x("printing").printToPDF(t);return{ok:!!(o&&o.ok),path:o?.path}}};var Ai={async enable(){if(!a("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!a("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!a("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};async function pe(t){if(!a("tray"))return;let r=window.craft.tray;await t(r)}var Ci={setIcon:(t)=>pe((r)=>r.setIcon(t)),setTitle:(t)=>pe((r)=>r.setTitle(t)),setTooltip:(t)=>pe((r)=>r.setTooltip(t)),setMenu:(t)=>pe((r)=>r.setMenu(t)),onClick:(t)=>g("craft:tray:click",t),onMenuAction:(t)=>g("craft:tray:menuAction",t)};function Re(){if(!a("window"))return null;return window.craft.window}function D(t){let r=Re();if(!r)return Promise.resolve();try{return Promise.resolve(t(r)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var Ii={get available(){return Re()!==null},open(t){let r=()=>{if(typeof window<"u"&&t.url)window.open(t.url,t.name);return{name:t.name}},n=Re();if(!n?.open)return Promise.resolve(r());return n.open(t).then((o)=>({name:o?.name||t.name})).catch(r)},close:()=>D((t)=>t.close?.()),show:()=>D((t)=>t.show?.()),hide:()=>D((t)=>t.hide?.()),focus:()=>D((t)=>t.focus?.()),minimize:()=>D((t)=>t.minimize?.()),maximize:()=>D((t)=>t.maximize?.()),center:()=>D((t)=>t.center?.()),startDrag:()=>D((t)=>t.startDrag?.()),setTitle:(t)=>D((r)=>r.setTitle?.(t)),setSize:(t,r)=>D((n)=>n.setSize?.(t,r)),setAppearance:(t)=>D((r)=>r.setAppearance?.(t))};var $i={async addItem(t){if(a("touchbar"))await window.craft.touchbar.addItem(t)},async removeItem(t){if(a("touchbar"))await window.craft.touchbar.removeItem(t)},async updateItem(t,r){if(a("touchbar"))await window.craft.touchbar.updateItem(t,r)},async setLabel(t,r){if(a("touchbar"))await window.craft.touchbar.setLabel(t,r)},async setIcon(t,r){if(a("touchbar"))await window.craft.touchbar.setIcon(t,r)},async setEnabled(t,r){if(a("touchbar"))await window.craft.touchbar.setEnabled(t,r)},async setSliderValue(t,r){if(a("touchbar"))await window.craft.touchbar.setSliderValue(t,r)},async clear(){if(a("touchbar"))await window.craft.touchbar.clear()},async show(){if(a("touchbar"))await window.craft.touchbar.show()},async hide(){if(a("touchbar"))await window.craft.touchbar.hide()},onAction(t){return g("craft:touchbar:action",t)}};var Ti=/^[\da-f]*$/i;function Ei(t,r){if(typeof r!=="string"||!Ti.test(r)||r.length%2!==0)throw Error(`${t}: must be a hex string with even length, got ${JSON.stringify(r)}`)}var Mi={async isEnabled(){return a("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return a("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return a("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return a("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(a("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(a("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return a("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(t){if(a("bluetooth"))await window.craft.bluetooth.connect(t)},async disconnect(t){if(a("bluetooth"))await window.craft.bluetooth.disconnect(t)},async openPreferences(){if(a("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(t){if(!t)throw Error("bluetooth.discoverServices: deviceId is required");if(!a("bluetooth"))return[];let r=await window.craft.bluetooth.discoverServices(t);return Array.isArray(r)?r:[]},async discoverCharacteristics(t,r){if(!t||!r)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!a("bluetooth"))return[];let n=await window.craft.bluetooth.discoverCharacteristics(t,r);return Array.isArray(n)?n:[]},async readCharacteristic(t,r,n){if(!t||!r||!n)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!a("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(t,r,n)},async writeCharacteristic(t,r,n,o,i="with-response"){if(!t||!r||!n)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(Ei("bluetooth.writeCharacteristic.valueHex",o),!a("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(t,r,n,o,i)},async setCharacteristicNotify(t,r,n,o){if(!t||!r||!n)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!a("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(t,r,n,o)},onDeviceFound(t){return g("craft:bluetooth:deviceFound",t)},onDeviceConnected(t){return g("craft:bluetooth:deviceConnected",t)},onDeviceDisconnected(t){return g("craft:bluetooth:deviceDisconnected",t)},onCharacteristicValue(t){return g("craft:bluetooth:characteristicValue",t)}};var Di={async speak(t,r){if(!t)throw Error("speech.speak: text is required");if(a("speech")){await window.craft.speech.speak(t,r);return}if(typeof window<"u"&&window.speechSynthesis){let n=new window.SpeechSynthesisUtterance(t);if(r){if(r.rate!=null)n.rate=r.rate;if(r.pitch!=null)n.pitch=r.pitch;if(r.volume!=null)n.volume=r.volume;if(r.voice){let i=window.speechSynthesis.getVoices().find((s)=>s.voiceURI===r.voice||s.name===r.voice||s.lang===r.voice);if(i)n.voice=i}}window.speechSynthesis.speak(n)}},async stop(){if(a("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(a("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(a("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(a("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(a("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map((r)=>({id:r.voiceURI||r.name,name:r.name,language:r.lang||"",quality:"default"}));return[]}};var Z=[],Le=!0,_e,Ne,ee={async report(t){if(a("crashReporter")){await window.craft.crashReporter.report(t);return}if(!Le)return;let r=t instanceof Error?{timestamp:Date.now(),severity:"error",message:t.message,source:"js",stack:t.stack||"",userId:_e,appVersion:Ne}:{timestamp:Date.now(),severity:t.severity||"error",message:t.message||"",source:t.source||"js",stack:t.stack||"",userId:_e,appVersion:Ne};if(Z.length>=64)Z.shift();Z.push(r)},async flush(){if(a("crashReporter"))return await window.craft.crashReporter.flush();return[...Z]},async clear(){if(a("crashReporter")){await window.craft.crashReporter.clear();return}Z.length=0},async setEnabled(t){if(a("crashReporter")){await window.craft.crashReporter.setEnabled(t);return}Le=t},async isEnabled(){if(a("crashReporter"))return await window.craft.crashReporter.isEnabled();return Le},async setUser(t){if(a("crashReporter")){await window.craft.crashReporter.setUser(t);return}_e=t||void 0},async setAppVersion(t){if(a("crashReporter")){await window.craft.crashReporter.setAppVersion(t);return}Ne=t||void 0},attachGlobalHandlers(){if(a("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let t=(n)=>{ee.report({severity:"error",message:n.message,source:"js",stack:n.error?.stack||`${n.message}
|
|
927
|
-
at ${n.filename}:${n.lineno}:${n.colno}`}).catch(()=>{})},r=(n)=>{let o=n.reason;ee.report({severity:"error",message:o?.message||String(o),source:"js",stack:o?.stack||""}).catch(()=>{})};return window.addEventListener("error",t),window.addEventListener("unhandledrejection",r),()=>{window.removeEventListener("error",t),window.removeEventListener("unhandledrejection",r)}},forwardTo(t){return
|
|
926
|
+
`).trim()}var Go={async show(t){if(!t.title)throw Error("notification title is required");if(a("notifications")){await window.craft.notifications.show(t);return}if(typeof window<"u"&&"Notification"in window){let r=window.Notification;if(r.permission==="granted")new r(t.title,{body:t.body,icon:t.icon});else if(r.permission==="default"){if(await r.requestPermission()==="granted")new r(t.title,{body:t.body,icon:t.icon})}}},async schedule(t){if(a("notifications")){let o={...t};if(o.triggerAt instanceof Date)o.triggerAt=o.triggerAt.toISOString();await window.craft.notifications.schedule(o);return}let r=Yo(t.triggerAt),n=Math.max(0,r-Date.now());setTimeout(()=>{this.show(t).catch(()=>{})},n)},async cancel(t){if(a("notifications"))await window.craft.notifications.cancel(t)},async cancelAll(){if(a("notifications"))await window.craft.notifications.cancelAll()},async setBadge(t){let r=Math.max(0,Math.round(Number.isFinite(t)?t:0));if(a("notifications")){await window.craft.notifications.setBadge(r);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(r)}catch{}},async clearBadge(){if(a("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(a("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let t=window.Notification;if(t.permission==="granted")return!0;if(t.permission==="denied")return!1;return await t.requestPermission()==="granted"}return!1},async registerCategories(t){if(!Array.isArray(t)||t.length===0)return;if(a("notifications")){let r=window.craft.notifications.registerCategories;if(typeof r==="function")await r(t)}},onActionClicked(t){return g("craft:notification:actionClicked",t)},onReply(t){return g("craft:notification:reply",t)}};function Yo(t){if(t==null)return Date.now();if(t instanceof Date)return t.getTime();if(typeof t==="number")return t;let r=Date.parse(t);return Number.isNaN(r)?Date.now():r}var Xo={async readFile(t){let r=await x("fs").readFile(t);return r&&r.data||""},async readBuffer(t){let r=await x("fs").readFile(t),n=r&&r.data||"";if(r&&r.base64===!0)return Qo(n);return new TextEncoder().encode(n)},async writeFile(t,r){await x("fs").writeFile(t,r)},async writeBuffer(t,r){let n=Jo(r),o=x("fs");if(typeof o.writeFileBytes==="function")await o.writeFileBytes(t,n);else await o.writeFile(t,n)},async copy(t,r){if(t===r)throw Error("fs.copy: source and destination must differ");await x("fs").copy(t,r)},async move(t,r){if(t===r)throw Error("fs.move: source and destination must differ");await x("fs").move(t,r)},async appendFile(t,r){await x("fs").appendFile(t,r)},async deleteFile(t){await x("fs").deleteFile(t)},async exists(t){return await x("fs").exists(t)},async stat(t){return Zo(await x("fs").stat(t))},async readDir(t){let r=await x("fs").readDir(t),n=r&&r.entries||[],o=t.endsWith("/")?t.slice(0,-1):t;return n.map((i)=>({name:i.name,path:`${o}/${i.name}`,isDirectory:!!i.isDirectory}))},async mkdir(t,r){await x("fs").mkdir(t,r)},async rmdir(t,r){await x("fs").rmdir(t,r)},async watch(t,r){await x("fs").watch(t,r)},async unwatch(t){await x("fs").unwatch(t)},onChange(t){return g("craft:fs:change",t)},async watchTree(t,r,n){let o=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,i=x("fs");await i.watch(t,o,{recursive:!!r.recursive});let s=r.kinds&&r.kinds.length>0?new Set(r.kinds):null,c=Math.max(0,Math.floor(r.coalesceMs??0)),l=[],d=null,u=!1,p=()=>{if(d=null,l.length===0)return;let f=l;l=[];try{n(f)}catch{}},m=g("craft:fs:change",(f)=>{if(u)return;if(f.id!==o)return;if(s&&f.kind&&!s.has(f.kind))return;if(l.push(f),c===0){p();return}if(d==null)d=setTimeout(p,c)});return{id:o,async stop(){if(u)return;if(u=!0,m(),d)clearTimeout(d),d=null;if(l.length>0)p();try{await i.unwatch(o)}catch{}}}},async homeDir(){return await x("fs").homeDir()},async tempDir(){return await x("fs").tempDir()},async appDataDir(){return await x("fs").appDataDir()}};function Jo(t){let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return typeof btoa==="function"?btoa(r):Buffer.from(t).toString("base64")}function Qo(t){let r=typeof atob==="function"?atob(t):Buffer.from(t,"base64").toString("binary"),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);return n}function Zo(t){return{isFile:!!t.isFile,isDirectory:!!t.isDirectory,isSymlink:!!t.isSymlink,size:Number(t.size)||0,modifiedAt:t.modifiedAt!=null?t.modifiedAt<1000000000000?t.modifiedAt*1000:t.modifiedAt:0}}var Q=new Set,kt=!1;function ei(){if(kt)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(t)=>{let r=t.detail;if(r?.id)Q.delete(r.id)}),kt=!0}var ti=new Set(["javascript:","data:","file:","vbscript:"]),ri={async openExternal(t){let r=t.trim().toLowerCase();for(let n of ti)if(r.startsWith(n))throw Error(`shell.openExternal: ${n} URLs are blocked for safety`);if(a("shell")){await window.craft.shell.openExternal(t);return}if(typeof window<"u"&&typeof window.open==="function")window.open(t,"_blank","noopener,noreferrer")},async openPath(t){await x("shell").openPath(t)},async showInFinder(t){await x("shell").showInFinder(t)},async spawn(t,r,n=[],o={}){if(ei(),!t||typeof t!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!r||typeof r!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(n))throw Error("shell.spawn: args must be an array");for(let i of n)if(typeof i!=="string")throw Error("shell.spawn: args entries must be strings");if(Q.has(t))throw Error(`shell.spawn: id "${t}" is already in use \u2014 call kill(id) first or pick a different id`);Q.add(t);try{await x("shell").spawn(t,r,n,o)}catch(i){throw Q.delete(t),i}},async kill(t){await x("shell").kill(t),Q.delete(t)},async getEnv(t){if(a("shell")){let r=await window.craft.shell.getEnv(t);return r==null?void 0:String(r)}return},async setEnv(t,r){await x("shell").setEnv(t,r)},onStdout(t){return g("craft:shell:stdout",t)},onStderr(t){return g("craft:shell:stderr",t)},onExit(t){return g("craft:shell:exit",t)}};function W(){return window.craft.shortcuts}var ni={async register(t,r,n){if(!a("shortcuts"))return;await W().register(t,r,n)},async unregister(t){if(!a("shortcuts"))return;await W().unregister(t)},async unregisterAll(){if(!a("shortcuts"))return;await W().unregisterAll()},async enable(t){if(!a("shortcuts"))return;await W().enable(t)},async disable(t){if(!a("shortcuts"))return;await W().disable(t)},async isRegistered(t){if(!a("shortcuts"))return!1;return await W().isRegistered(t)},async list(){if(!a("shortcuts"))return[];return await W().list()},on(t){return g("craft:shortcut",t)}};var oi={get(){if(a("theme"))try{return window.craft.theme.get()}catch{}return{appearance:ii()}},onChange(t){if(t(this.get()),a("theme"))return g("craft:theme",t);if(typeof window<"u"&&window.matchMedia){let r=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>t({appearance:r.matches?"dark":"light"});return r.addEventListener("change",n),()=>r.removeEventListener("change",n)}return()=>{}},async current(){return this.get()}};function ii(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function ai(t,r={}){if(!a("dragOut"))throw Error("dragOut requires a Craft native window");let n=Array.isArray(t)?t:[t];if(n.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start(n,r)}function si(){return a("dragOut")}var ci={onUrl(t){if(!a("deepLink"))return()=>{};return g("craft:deepLink",t)},getInitialUrl(){if(typeof window>"u")return null;if(a("deepLink"))try{return window.craft.deepLink.getInitialUrl()}catch{return null}return window.__craftPendingDeepLink||null},consumeInitialUrl(){let t=this.getInitialUrl();if(typeof window<"u")window.__craftPendingDeepLink=void 0;return t},isAvailable(){return a("deepLink")}};var li={async isCharging(){if(a("power"))return await window.craft.power.isCharging();let t=await de();return t?!!t.charging:!1},async isPluggedIn(){if(a("power"))return await window.craft.power.isPluggedIn();let t=await de();return t?!!t.charging||t.level>=0.999:!1},async isLowPowerMode(){if(a("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(a("power")){let r=await window.craft.power.batteryLevel();return typeof r==="number"?r:null}let t=await de();return t?t.level:null},async timeRemaining(){if(a("power")){let n=await window.craft.power.timeRemaining();return typeof n==="number"?n:null}let t=await de();if(!t)return null;let r=t.charging?t.chargingTime:t.dischargingTime;return Number.isFinite(r)?Math.round(r/60):null},async thermalState(){if(a("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(a("power"))return await window.craft.power.uptimeSeconds();if(typeof performance<"u"&&typeof performance.now==="function")return Math.round(performance.now()/1000);return 0},async preventSleep(t="app is busy"){if(a("power")){await window.craft.power.preventSleep(t);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let r=window;if(r.__craftWebWakeLock?.release){try{await r.__craftWebWakeLock.release()}catch{}r.__craftWebWakeLock=null}try{let n=await navigator.wakeLock.request("screen");r.__craftWebWakeLock=n}catch{}},async allowSleep(){if(a("power")){await window.craft.power.allowSleep();return}let t=window.__craftWebWakeLock;if(t&&typeof t.release==="function"){try{await t.release()}catch{}window.__craftWebWakeLock=null}},onSleep(t){return g("craft:powerSleep",t)},onWake(t){return g("craft:powerWake",t)}};async function de(){if(typeof navigator>"u")return null;let t=navigator;if(typeof t.getBattery!=="function")return null;try{return await t.getBattery()}catch{return null}}var di={async connectionType(){if(a("network"))return await window.craft.network.connectionType();return At()},async wifiSSID(){if(a("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(a("network")){let t=await window.craft.network.wifiSignalStrength();return typeof t==="number"?t:void 0}return},async ipAddress(){if(a("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(a("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(a("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(a("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(a("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(a("network"))await window.craft.network.openPreferences()},onChange(t){if(a("network"))return g("craft:networkChange",t);if(typeof window>"u")return()=>{};let r=()=>t({type:At(),online:!0}),n=()=>t({type:"none",online:!1});return window.addEventListener("online",r),window.addEventListener("offline",n),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}};function At(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let t=navigator.connection;if(!t)return"unknown";let r=String(t.type||t.effectiveType||"unknown").toLowerCase();if(r==="wifi"||r==="cellular"||r==="ethernet"||r==="bluetooth"||r==="none")return r;return"unknown"}var ui={async checkForUpdates(){if(!a("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!a("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(t){if(!a("updater"))return;await window.craft.updater.setAutomaticChecks(t)},async setCheckInterval(t){if(!a("updater"))return;if(!Number.isFinite(t))throw Error("setCheckInterval: must be a finite number");let r=t<=0?0:Math.max(60,Math.round(t));await window.craft.updater.setCheckInterval(r)},async setFeedURL(t){if(!a("updater"))return;await window.craft.updater.setFeedURL(t)},async getLastUpdateCheckDate(){if(!a("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!a("updater"))return null;let t=await window.craft.updater.getUpdateInfo();if(!t||typeof t.version!=="string"||t.version.length===0)return null;return t},onAvailable(t){return g("craft:updateAvailable",t)},onDownloaded(t){return g("craft:updateDownloaded",t)},async verifySignature({payload:t,signatureB64:r,publicKeyB64:n}){let o=Ct(t),i;try{i=await crypto.subtle.importKey("raw",ue(n),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",i,ue(r),o)}catch{return!1}},async verifyDownload({url:t,signatureB64:r,publicKeyB64:n,fetchInit:o}){let i;try{i=await fetch(t,o)}catch{return{ok:!1,reason:"fetch-failed"}}if(!i.ok)return{ok:!1,reason:"http-error",status:i.status};let s=new Uint8Array(await i.arrayBuffer()),c;try{c=await crypto.subtle.importKey("raw",ue(n),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let l=!1;try{l=await crypto.subtle.verify("Ed25519",c,ue(r),Ct(s))}catch{l=!1}if(!l)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:s}}};function Ct(t){if(t instanceof ArrayBuffer)return new Uint8Array(t);let r=new ArrayBuffer(t.byteLength),n=new Uint8Array(r);return n.set(t),n}function ue(t){if(typeof atob==="function"){let o=atob(t),i=new ArrayBuffer(o.length),s=new Uint8Array(i);for(let c=0;c<o.length;c++)s[c]=o.charCodeAt(c);return s}let r=Buffer.from(t,"base64"),n=new ArrayBuffer(r.length);return new Uint8Array(n).set(r),new Uint8Array(n)}var pi={onFocus(t){if(a("window"))return g("craft:window:focus",()=>t());return Me("focus",t)},onBlur(t){if(a("window"))return g("craft:window:blur",()=>t());return Me("blur",t)},onResize(t){if(a("window"))return g("craft:window:resize",t);if(typeof window>"u")return()=>{};let r=()=>t({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},onMove(t){if(a("window"))return g("craft:window:move",t);return()=>{}},onClose(t){if(a("window"))return g("craft:window:close",()=>t());return Me("beforeunload",t)},onMinimize(t){if(a("window"))return g("craft:window:minimize",()=>t());if(typeof document>"u")return()=>{};let r=()=>{if(document.visibilityState==="hidden")t()};return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)},onRestore(t){if(a("window"))return g("craft:window:restore",()=>t());if(typeof document>"u")return()=>{};let r=()=>{if(document.visibilityState==="visible")t()};return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)}};function Me(t,r){if(typeof window>"u")return()=>{};let n=()=>r();return window.addEventListener(t,n),()=>window.removeEventListener(t,n)}var It={name:"",version:"0.0.0"},fi={async icon(t){if(!t.startsWith("/")||!t.endsWith(".app")||t.includes("\x00"))throw Error("Application icons require an absolute .app path.");let r=x("app");if(!r.icon)throw Error("This Craft runtime does not support native application icons.");return r.icon(t)},async hideDockIcon(){if(a("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(a("app"))await window.craft.app.showDockIcon()},async quit(){if(a("app"))await window.craft.app.quit()},async getInfo(){if(!a("app"))return It;let t=await window.craft.app.getInfo();return{...It,...t||{}}},async notify(t){if(!t.title)throw Error("notify: title is required");if(a("app"))await window.craft.app.notify(t)},async setBadge(t){if(a("app"))await window.craft.app.setBadge(t)},async bounce(t="informational"){if(a("app"))await window.craft.app.bounce(t)}};var mi={app(t,r={}){return{label:t,items:[{label:`About ${t}`,role:"about"},{separator:!0},...r.settings?[{id:"stx.menu.settings",label:"Settings\u2026",shortcut:"cmd+,",onClick:r.settings},{separator:!0}]:[],{label:`Hide ${t}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${t}`,role:"quit",shortcut:"cmd+q"}]}},edit(){return{label:"Edit",items:[{label:"Undo",role:"undo",shortcut:"cmd+z"},{label:"Redo",role:"redo",shortcut:"cmd+shift+z"},{separator:!0},{label:"Cut",role:"cut",shortcut:"cmd+x"},{label:"Copy",role:"copy",shortcut:"cmd+c"},{label:"Paste",role:"paste",shortcut:"cmd+v"},{label:"Select All",role:"selectAll",shortcut:"cmd+a"}]}},window(){return{label:"Window",items:[{label:"Minimize",role:"minimize",shortcut:"cmd+m"},{label:"Zoom",role:"zoom"},{separator:!0},{label:"Close Window",role:"close",shortcut:"cmd+w"}]}},leading(t,r={}){return[this.app(t,r),this.edit()]}},gi=0;function hi(t){let r=new Map;return{payload:{menus:t.menus.map((o)=>({label:o.label,items:o.items.map((i)=>{let{onClick:s,...c}=i;if(c.separator)return c;let l=c.id??`stx.menu.${gi++}`;if(s)r.set(l,s);return{...c,id:l}})}))},handlers:r}}var De=null,wi={async set(t){if(!a("menu"))return!1;let{payload:r,handlers:n}=hi(t);if(De?.(),De=null,n.size>0)De=g("craft:menu:action",(o)=>{n.get(o.id)?.()});return await window.craft.menu.set(r),!0},async setDock(t){if(a("menu"))await window.craft.menu.setDock(t)},async addItem(t,r){if(a("menu"))await window.craft.menu.addItem(t,r)},async removeItem(t){if(a("menu"))await window.craft.menu.removeItem(t)},async enableItem(t){if(a("menu"))await window.craft.menu.enableItem(t)},async disableItem(t){if(a("menu"))await window.craft.menu.disableItem(t)},async checkItem(t){if(a("menu"))await window.craft.menu.checkItem(t)},async uncheckItem(t){if(a("menu"))await window.craft.menu.uncheckItem(t)},async setItemLabel(t,r){if(a("menu"))await window.craft.menu.setItemLabel(t,r)},async clearDock(){if(a("menu"))await window.craft.menu.clearDock()},onAction(t){return g("craft:menu:action",t)}};function Tt(t){if(t.separator)return{id:t.id||"",title:"",type:"separator"};return{id:t.id||"",title:t.title||"",icon:t.icon,shortcut:t.shortcut,enabled:t.disabled?!1:void 0,checked:t.checked?!0:void 0,type:t.submenu?"submenu":void 0,submenu:t.submenu?.map(Tt)}}async function $t(t){if(!t.items||t.items.length===0)throw Error("contextMenu.show requires at least one item");if(!a("nativeUI"))return null;let r=window.craft?.nativeUI;if(!r)return null;let n=await r.showContextMenu({targetId:t.targetId||"",targetType:"general",x:Math.round(t.x),y:Math.round(t.y),items:t.items.map(Tt)});return{id:typeof n?.id==="string"?n.id:null,targetId:n?.targetId}}var bi={available(){return a("nativeUI")},async show(t){return await $t(t)!==null},async pick(t){return(await $t(t))?.id??null},onAction(t){return g("craft:contextmenu:action",(r)=>{if(typeof r.id==="string")t({id:r.id,targetId:r.targetId??""})})}};function Be(t){if(t===null||t===void 0||t===0)return"";return String(t)}function Et(t){return t.map((r)=>({id:r.id,header:r.header,items:r.items.map((n)=>({id:n.id,label:n.label,icon:n.icon,badge:Be(n.badge)||void 0}))}))}function Mt(t){return JSON.stringify(t.map((r)=>[r.id,r.header??"",r.items.map((n)=>[n.id,n.label,n.icon??""])]))}function Dt(t){return new Map(t.flatMap((r)=>r.items.map((n)=>[n.id,Be(n.badge)])))}var Bt={available(){return a("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(t){if(!Bt.available())return null;let r=window.craft?.nativeUI;if(!r)return null;let n=r.createSidebar({id:t.id,sections:Et(t.sections),selected:t.selected}),o=t.sections,i=new Set;return n.onSelect((s)=>{for(let c of[...i])c(s)}),{id:n.id,update(s){if(Mt(s)===Mt(o)){let c=Dt(o);for(let[l,d]of Dt(s))if(c.get(l)!==d)n.updateItem(l,{badge:d})}else n.setSections(Et(s));o=s},updateItem(s,c){n.updateItem(s,{...c.label!==void 0?{label:c.label}:{},...c.icon!==void 0?{icon:c.icon}:{},..."badge"in c?{badge:Be(c.badge)}:{}}),o=o.map((l)=>({...l,items:l.items.map((d)=>d.id===s?{...d,...c}:d)}))},select(s){n.setSelectedItem(s)},onSelect(s){return i.add(s),()=>i.delete(s)},destroy(){i.clear(),n.destroy()}}}};var xi={accentColor:()=>E("system","accentColor",()=>""),highlightColor:()=>E("system","highlightColor",()=>""),language:()=>E("system","language",()=>{if(typeof navigator>"u")return"";return navigator.language?.split("-")[0]||""}),locale:()=>E("system","locale",()=>{if(typeof navigator>"u")return"";return navigator.language||""}),timezone:()=>E("system","timezone",()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||""}catch{return""}}),is24HourTime:()=>E("system","is24HourTime",()=>{try{let t=new Intl.DateTimeFormat([],{hour:"numeric"}).resolvedOptions();return t.hourCycle==="h23"||t.hourCycle==="h24"}catch{return!1}}),reduceMotion:()=>E("system","reduceMotion",()=>Oe("(prefers-reduced-motion: reduce)")),reduceTransparency:()=>E("system","reduceTransparency",()=>Oe("(prefers-reduced-transparency: reduce)")),increaseContrast:()=>E("system","increaseContrast",()=>Oe("(prefers-contrast: more)")),systemVersion:()=>E("system","systemVersion",()=>""),hostname:()=>E("system","hostname",()=>""),username:()=>E("system","username",()=>""),async openPreferences(){if(a("system"))await window.craft.system.openPreferences()}};async function E(t,r,n){if(a(t))return await window.craft[t][r]();return await n()}function Oe(t){if(typeof window>"u"||!window.matchMedia)return!1;return window.matchMedia(t).matches}var yi={async getDisplays(){if(a("screen"))return await window.craft.screen.getDisplays();return Ot()},async getPrimary(){if(a("screen")){let t=await window.craft.screen.getPrimary();return t&&typeof t.width==="number"?t:null}return Ot()[0]??null},onChange(t){if(a("screen"))return g("craft:screen:change",()=>t());if(typeof window>"u")return()=>{};let r=()=>t();return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)}};function Ot(){if(typeof window>"u"||!window.screen)return[];let t=window.screen;return[{id:0,x:t.left??0,y:t.top??0,width:t.width||0,height:t.height||0,workX:t.availLeft??0,workY:t.availTop??0,workWidth:t.availWidth??t.width??0,workHeight:t.availHeight??t.height??0,scaleFactor:window.devicePixelRatio||1}]}var vi={async set(t,r,n){if(!t)throw Error("keychain.set: service is required");if(!r)throw Error("keychain.set: account is required");await x("keychain").set(t,r,n)},async get(t,r){if(!t)throw Error("keychain.get: service is required");if(!r)throw Error("keychain.get: account is required");let n=await x("keychain").get(t,r);return typeof n==="string"?n:null},async delete(t,r){if(!t)throw Error("keychain.delete: service is required");if(!r)throw Error("keychain.delete: account is required");await x("keychain").delete(t,r)},async has(t,r){if(!t)throw Error("keychain.has: service is required");if(!r)throw Error("keychain.has: account is required");return await x("keychain").has(t,r)}};var Pi={async check(t){if(a("permissions"))return await window.craft.permissions.check(t);return await Rt(t)},async request(t){if(a("permissions"))return await window.craft.permissions.request(t);return await Si(t)},async openSettings(t){if(a("permissions"))await window.craft.permissions.openSettings(t)}};async function Rt(t){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let r=await navigator.permissions.query({name:t});return ki(r.state)}catch{return"not-supported"}}async function Si(t){if(t==="notifications"&&typeof window<"u"&&"Notification"in window){let r=await window.Notification.requestPermission();return r==="granted"?"granted":r==="denied"?"denied":"undetermined"}return await Rt(t)}function ki(t){if(t==="granted")return"granted";if(t==="denied")return"denied";if(t==="prompt")return"undetermined";return"undetermined"}var Ai={async print(){if(a("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(t){if(!t)throw Error("printToPDF: path is required");let r=t.startsWith("/"),n=/^[a-zA-Z]:[\\/]/.test(t)||t.startsWith("\\\\");if(!r&&!n)throw Error("printToPDF: path must be absolute");let o=await x("printing").printToPDF(t);return{ok:!!(o&&o.ok),path:o?.path}}};var Ci={async enable(){if(!a("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!a("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!a("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};async function pe(t){if(!a("tray"))return;let r=window.craft.tray;await t(r)}var Ii={setIcon:(t)=>pe((r)=>r.setIcon(t)),setTitle:(t)=>pe((r)=>r.setTitle(t)),setTooltip:(t)=>pe((r)=>r.setTooltip(t)),setMenu:(t)=>pe((r)=>r.setMenu(t)),onClick:(t)=>g("craft:tray:click",t),onMenuAction:(t)=>g("craft:tray:menuAction",t)};function Re(){if(!a("window"))return null;return window.craft.window}function D(t){let r=Re();if(!r)return Promise.resolve();try{return Promise.resolve(t(r)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var $i={get available(){return Re()!==null},open(t){let r=()=>{if(typeof window<"u"&&t.url)window.open(t.url,t.name);return{name:t.name}},n=Re();if(!n?.open)return Promise.resolve(r());return n.open(t).then((o)=>({name:o?.name||t.name})).catch(r)},close:()=>D((t)=>t.close?.()),show:()=>D((t)=>t.show?.()),hide:()=>D((t)=>t.hide?.()),focus:()=>D((t)=>t.focus?.()),minimize:()=>D((t)=>t.minimize?.()),maximize:()=>D((t)=>t.maximize?.()),center:()=>D((t)=>t.center?.()),startDrag:()=>D((t)=>t.startDrag?.()),setTitle:(t)=>D((r)=>r.setTitle?.(t)),setSize:(t,r)=>D((n)=>n.setSize?.(t,r)),setAppearance:(t)=>D((r)=>r.setAppearance?.(t))};var Ti={async addItem(t){if(a("touchbar"))await window.craft.touchbar.addItem(t)},async removeItem(t){if(a("touchbar"))await window.craft.touchbar.removeItem(t)},async updateItem(t,r){if(a("touchbar"))await window.craft.touchbar.updateItem(t,r)},async setLabel(t,r){if(a("touchbar"))await window.craft.touchbar.setLabel(t,r)},async setIcon(t,r){if(a("touchbar"))await window.craft.touchbar.setIcon(t,r)},async setEnabled(t,r){if(a("touchbar"))await window.craft.touchbar.setEnabled(t,r)},async setSliderValue(t,r){if(a("touchbar"))await window.craft.touchbar.setSliderValue(t,r)},async clear(){if(a("touchbar"))await window.craft.touchbar.clear()},async show(){if(a("touchbar"))await window.craft.touchbar.show()},async hide(){if(a("touchbar"))await window.craft.touchbar.hide()},onAction(t){return g("craft:touchbar:action",t)}};var Ei=/^[\da-f]*$/i;function Mi(t,r){if(typeof r!=="string"||!Ei.test(r)||r.length%2!==0)throw Error(`${t}: must be a hex string with even length, got ${JSON.stringify(r)}`)}var Di={async isEnabled(){return a("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return a("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return a("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return a("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(a("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(a("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return a("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(t){if(a("bluetooth"))await window.craft.bluetooth.connect(t)},async disconnect(t){if(a("bluetooth"))await window.craft.bluetooth.disconnect(t)},async openPreferences(){if(a("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(t){if(!t)throw Error("bluetooth.discoverServices: deviceId is required");if(!a("bluetooth"))return[];let r=await window.craft.bluetooth.discoverServices(t);return Array.isArray(r)?r:[]},async discoverCharacteristics(t,r){if(!t||!r)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!a("bluetooth"))return[];let n=await window.craft.bluetooth.discoverCharacteristics(t,r);return Array.isArray(n)?n:[]},async readCharacteristic(t,r,n){if(!t||!r||!n)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!a("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(t,r,n)},async writeCharacteristic(t,r,n,o,i="with-response"){if(!t||!r||!n)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(Mi("bluetooth.writeCharacteristic.valueHex",o),!a("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(t,r,n,o,i)},async setCharacteristicNotify(t,r,n,o){if(!t||!r||!n)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!a("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(t,r,n,o)},onDeviceFound(t){return g("craft:bluetooth:deviceFound",t)},onDeviceConnected(t){return g("craft:bluetooth:deviceConnected",t)},onDeviceDisconnected(t){return g("craft:bluetooth:deviceDisconnected",t)},onCharacteristicValue(t){return g("craft:bluetooth:characteristicValue",t)}};var Bi={async speak(t,r){if(!t)throw Error("speech.speak: text is required");if(a("speech")){await window.craft.speech.speak(t,r);return}if(typeof window<"u"&&window.speechSynthesis){let n=new window.SpeechSynthesisUtterance(t);if(r){if(r.rate!=null)n.rate=r.rate;if(r.pitch!=null)n.pitch=r.pitch;if(r.volume!=null)n.volume=r.volume;if(r.voice){let i=window.speechSynthesis.getVoices().find((s)=>s.voiceURI===r.voice||s.name===r.voice||s.lang===r.voice);if(i)n.voice=i}}window.speechSynthesis.speak(n)}},async stop(){if(a("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(a("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(a("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(a("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(a("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map((r)=>({id:r.voiceURI||r.name,name:r.name,language:r.lang||"",quality:"default"}));return[]}};var Z=[],Le=!0,_e,Ne,ee={async report(t){if(a("crashReporter")){await window.craft.crashReporter.report(t);return}if(!Le)return;let r=t instanceof Error?{timestamp:Date.now(),severity:"error",message:t.message,source:"js",stack:t.stack||"",userId:_e,appVersion:Ne}:{timestamp:Date.now(),severity:t.severity||"error",message:t.message||"",source:t.source||"js",stack:t.stack||"",userId:_e,appVersion:Ne};if(Z.length>=64)Z.shift();Z.push(r)},async flush(){if(a("crashReporter"))return await window.craft.crashReporter.flush();return[...Z]},async clear(){if(a("crashReporter")){await window.craft.crashReporter.clear();return}Z.length=0},async setEnabled(t){if(a("crashReporter")){await window.craft.crashReporter.setEnabled(t);return}Le=t},async isEnabled(){if(a("crashReporter"))return await window.craft.crashReporter.isEnabled();return Le},async setUser(t){if(a("crashReporter")){await window.craft.crashReporter.setUser(t);return}_e=t||void 0},async setAppVersion(t){if(a("crashReporter")){await window.craft.crashReporter.setAppVersion(t);return}Ne=t||void 0},attachGlobalHandlers(){if(a("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let t=(n)=>{ee.report({severity:"error",message:n.message,source:"js",stack:n.error?.stack||`${n.message}
|
|
927
|
+
at ${n.filename}:${n.lineno}:${n.colno}`}).catch(()=>{})},r=(n)=>{let o=n.reason;ee.report({severity:"error",message:o?.message||String(o),source:"js",stack:o?.stack||""}).catch(()=>{})};return window.addEventListener("error",t),window.addEventListener("unhandledrejection",r),()=>{window.removeEventListener("error",t),window.removeEventListener("unhandledrejection",r)}},forwardTo(t){return Fi(t)}},Oi="craft:crashReporter:pending",Ri=/[\w.+-]+@[\w-]+\.[\w.-]+/g,Li=/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,_i=/\/(?:Users|home)\/[^\s/'"`]+/g;function _t(t){let r=(n)=>n.replace(Ri,"<email>").replace(Li,"<ip>").replace(_i,"/<home>");return{...t,message:r(t.message),stack:r(t.stack)}}async function Nt(t,r){let n=new TextEncoder,o=await crypto.subtle.importKey("raw",n.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),i=await crypto.subtle.sign("HMAC",o,n.encode(r));return[...new Uint8Array(i)].map((s)=>s.toString(16).padStart(2,"0")).join("")}function Ni(t){if(!t||typeof localStorage>"u")return[];try{let r=localStorage.getItem(t);if(!r)return[];let n=JSON.parse(r);return Array.isArray(n)?n:[]}catch{return[]}}function Lt(t,r){if(!t||typeof localStorage>"u")return;try{if(r.length===0)localStorage.removeItem(t);else localStorage.setItem(t,JSON.stringify(r))}catch{}}function Fi(t){let{endpoint:r,intervalMs:n=60000,signingSecret:o,redact:i=!0,headers:s={},maxRetries:c=5,persistKey:l}=t,d=l===null?null:l??Oi,u=Ni(d),p=!1,m=null,f=null,w=typeof i==="function"?i:i===!1?(k)=>k:_t;async function b(k){let A=JSON.stringify({entries:k}),B={"Content-Type":"application/json",...s};if(o)B["X-Craft-Signature"]=await Nt(o,A);let re=0,O=1000;while(!p)try{let U=await fetch(r,{method:"POST",headers:B,body:A});if(U.ok)return;if(U.status>=400&&U.status<500)return;throw Error(`HTTP ${U.status}`)}catch(U){if(re+=1,re>c)throw u=[...k,...u],Lt(d,u),U;await new Promise((Gt)=>{setTimeout(Gt,O)}),O=Math.min(O*2,60000)}}async function S(){if(p||f)return f??void 0;let k=await ee.flush();if(k.length>0)await ee.clear();if(u=[...u,...k.map((B)=>w(B))],u.length===0)return;let A=u;return u=[],Lt(d,u),f=b(A).catch(()=>{}).finally(()=>{f=null}),f}if(n>0)m=setInterval(()=>{S().catch(()=>{})},n);return{async flushNow(){await S()},stop(){if(p=!0,m)clearInterval(m);m=null},pending(){return[...u]}}}var zi={async isAvailable(){if(!a("iap"))return!1;return await window.craft.iap.isAvailable()},async getProducts(t){if(!a("iap"))return[];let r=Array.isArray(t)?t:[String(t)];return await window.craft.iap.getProducts(r)},async purchase(t){if(!a("iap"))return{queued:!1,productId:t,reason:"IAP bridge not available"};let r=await window.craft.iap.purchase(t);return{queued:!!(r&&r.queued),productId:r?.productId,reason:r?.reason}},async restorePurchases(){if(!a("iap"))return{ok:!1};let t=await window.craft.iap.restorePurchases();return{ok:!!(t&&t.ok)}},async finishTransaction(t){if(!a("iap"))return;await window.craft.iap.finishTransaction(t)},async getReceiptData(){if(!a("iap"))return null;let t=await window.craft.iap.getReceiptData();return t?String(t):null},onPurchased(t){return g("craft:iap:purchased",t)},onFailed(t){return g("craft:iap:failed",t)},onRestored(t){return g("craft:iap:restored",t)},onProductsLoaded(t){return g("craft:iap:productsLoaded",(r)=>t(r.products||[]))},onRefunded(t){return g("craft:iap:refunded",t)},onSubscriptionStatusChanged(t){return g("craft:iap:subscriptionStatusChanged",t)},async getActiveSubscriptions(){if(!a("iap"))return[];let t=window.craft.iap.getActiveSubscriptions;if(typeof t!=="function")return[];let r=await t();return Array.isArray(r)?r:[]},async isEligibleForIntroOffer(t){if(!a("iap"))return!1;let r=window.craft.iap.isEligibleForIntroOffer;if(typeof r!=="function")return!1;return!!await r(t)}};var te={async startActivity(t,r){if(!t)throw Error("handoff.startActivity: type is required");if(!a("handoff"))return!1;let n=await window.craft.handoff.startActivity(t,r);return typeof n==="boolean"?n:!!(n&&n.ok)},async updateActivity(t){if(!a("handoff"))return!1;let r=await window.craft.handoff.updateActivity(t);return typeof r==="boolean"?r:!!(r&&r.ok)},async stopActivity(){if(!a("handoff"))return;await window.craft.handoff.stopActivity()},async getCurrentActivity(){if(!a("handoff"))return null;let t=await window.craft.handoff.getCurrentActivity();return t&&typeof t.type==="string"?t:null},onIncoming(t){return g("craft:handoff:incoming",t)}};var Wi={async start(t,r){return te.startActivity(t,{title:r?.title,webpageURL:r?.webpageURL,userInfo:r?.state})},async update(t){return te.updateActivity({title:t.title,webpageURL:t.webpageURL,userInfo:t.state})},async stop(){await te.stopActivity()}};var Ui={async requestPermission(t="whenInUse"){if(a("location"))return await window.craft.location.requestPermission(t);if(typeof navigator<"u"&&navigator.geolocation)return"undetermined";return"not-supported"},async getAuthorization(){if(a("location"))return await window.craft.location.getAuthorization();return"unknown"},async getCurrentLocation(){if(a("location"))return await window.craft.location.getCurrentLocation();if(typeof navigator<"u"&&navigator.geolocation)return navigator.geolocation.getCurrentPosition((t)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:t.coords.latitude,longitude:t.coords.longitude,altitude:t.coords.altitude,horizontalAccuracy:t.coords.accuracy,verticalAccuracy:t.coords.altitudeAccuracy,speed:t.coords.speed}}))},(t)=>{window.dispatchEvent(new CustomEvent("craft:location:error",{detail:{message:t.message||String(t)}}))}),{requested:!0};return{requested:!1}},async startWatching(t){if(a("location"))return await window.craft.location.startWatching(t);if(typeof navigator<"u"&&navigator.geolocation){let r=navigator.geolocation.watchPosition((n)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:n.coords.latitude,longitude:n.coords.longitude,altitude:n.coords.altitude,horizontalAccuracy:n.coords.accuracy,verticalAccuracy:n.coords.altitudeAccuracy,speed:n.coords.speed}}))});return window.__craftWebLocationWatchId=r,!0}return!1},async stopWatching(){if(a("location")){await window.craft.location.stopWatching();return}if(typeof navigator<"u"&&navigator.geolocation){let t=window.__craftWebLocationWatchId;if(t!=null)navigator.geolocation.clearWatch(t),window.__craftWebLocationWatchId=null}},onUpdate(t){return g("craft:location:update",t)},onError(t){return g("craft:location:error",t)},onAuthChanged(t){return g("craft:location:authChanged",t)}};var Hi={async captureScreen(){if(!a("screenCapture"))return null;let t=await window.craft.screenCapture.captureScreen();return t?String(t):null},async captureWindow(t){if(!a("screenCapture"))return null;if(!Number.isFinite(t)||t<=0)throw Error("captureWindow: id must be a positive number");let r=await window.craft.screenCapture.captureWindow(t);return r?String(r):null},async listWindows(){if(!a("screenCapture"))return[];return await window.craft.screenCapture.listWindows()}};var zt=250,Wt=60000,me=2000,Ft={sharing:!1,signals:{systemScreenShare:!1,remoteSession:!1,conferenceSharing:!1,screenRecording:!1},sources:[]};function qi(){return{...Ft,signals:{...Ft.signals},sources:[]}}var fe={async getState(){if(!a("screenSharing"))return qi();return await window.craft.screenSharing.getState()},async watch(t=me){let r=Number.isFinite(t)?Math.min(Wt,Math.max(zt,Math.round(t))):me;if(!a("screenSharing"))return r;let n=await window.craft.screenSharing.watch(r);return n&&n.intervalMs||r},async stop(){if(!a("screenSharing"))return;await window.craft.screenSharing.unwatch()},onChange(t){return g("craft:screenSharing:change",t)}};async function Vi(t,r=me){let n=fe.onChange(t);try{await fe.watch(r)}catch(i){throw n(),i}let o;return()=>{if(!o)n(),o=fe.stop();return o}}var ji={supported:!1,isFocused:null,authorization:"unsupported"};function Ut(){return{ok:!1,error:"Focus control is only available in a Craft window on macOS"}}var Fe={async getStatus(){if(!a("focus"))return{...ji};return await window.craft.focus.getStatus()},async requestAuthorization(){if(!a("focus"))return"unsupported";return await window.craft.focus.requestAuthorization()},async setEnabled(t,r={}){if(!a("focus"))return Ut();if(!(t?r.onShortcut:r.offShortcut))return{ok:!1,error:`focus.setEnabled: no ${t?"onShortcut":"offShortcut"} configured`};return await window.craft.focus.setEnabled(t,r)},async runShortcut(t){if(!a("focus"))return Ut();if(!t)throw Error("focus.runShortcut: name is required");return await window.craft.focus.runShortcut(t)},async listShortcuts(){if(!a("focus"))return[];return await window.craft.focus.listShortcuts()},async listShortcutsResult(){if(!a("focus"))return{canList:!1,shortcuts:[]};let r=await window.craft.focus.listShortcutsResult?.();return{canList:Boolean(r?.canList),shortcuts:r?.shortcuts??[]}}};async function Ki(...t){if(t.length===0)return!1;let r=new Set(await Fe.listShortcuts());return t.every((n)=>r.has(n))}async function Gi(...t){if(t.length===0)return!1;let{canList:r,shortcuts:n}=await Fe.listShortcutsResult();if(!r)return"unknown";let o=new Set(n);return t.every((i)=>o.has(i))}var Yi={async start(t=0,r="127.0.0.1"){if(!a("localServer"))return{port:0,started:!1,reason:"bridge unavailable"};return await window.craft.localServer.start(t,r)},async stop(){if(!a("localServer"))return;await window.craft.localServer.stop()},async respond(t){if(!a("localServer"))return;await window.craft.localServer.respond(t||{status:200,body:"OK"})},onRequest(t){return g("craft:localServer:request",t)},async awaitOAuthCallback(t={}){x("localServer");let{port:r=0,host:n="127.0.0.1",timeoutMs:o=300000,successHTML:i}=t,s=await this.start(r,n);if(!s.started)throw Error(`localServer: start failed${s.reason?` \u2014 ${s.reason}`:""}`);return new Promise((c,l)=>{let d=setTimeout(()=>{u(),this.stop().catch(()=>{}),l(Error("localServer: OAuth callback timed out"))},o),u=this.onRequest(({url:p})=>{clearTimeout(d),u();let m=i??`<!doctype html><meta charset="utf-8"><title>Done</title>
|
|
928
928
|
<style>body{font-family:-apple-system,BlinkMacSystemFont,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7}</style>
|
|
929
929
|
<div><h1>You can close this tab.</h1><p>Returning to the app\u2026</p></div>
|
|
930
|
-
<script>setTimeout(()=>window.close(),1500)</script>`;this.respond({status:200,body:m,contentType:"text/html; charset=utf-8"}).catch(()=>{}).finally(()=>this.stop().catch(()=>{})),c({url:p,port:s.port})})})}};var Yi={async isAvailable(){if(!a("biometric"))return!1;return await window.craft.biometric.isAvailable()},async getBiometryType(){if(!a("biometric"))return"none";return await window.craft.biometric.getBiometryType()},async evaluate(t,r){if(!t)throw Error("biometric.evaluate: reason is required");if(!a("biometric"))return{success:!1,errorCode:-1};return await window.craft.biometric.evaluate(t,r)}};var I=null,Xi={async play(t,r){if(a("audio"))return await window.craft.audio.play(t,r);if(typeof window>"u"||typeof Audio>"u")return!1;if(I)I.pause(),I=null;if(I=new Audio(t),r?.volume!=null)I.volume=r.volume;if(r?.loops)I.loop=!0;try{return await I.play(),!0}catch{return!1}},async playSystemSound(t){if(a("audio"))return await window.craft.audio.playSystemSound(t);if(typeof window>"u"||typeof Audio>"u")return!1;try{return I=new Audio(`/System/Library/Sounds/${t}.aiff`),await I.play(),!0}catch{return!1}},async stop(){if(a("audio")){await window.craft.audio.stop();return}if(I)I.pause(),I.currentTime=0,I=null},async isPlaying(){if(a("audio"))return await window.craft.audio.isPlaying();return!!(I&&!I.paused)},async startRecording(t,r){if(a("audio"))return await window.craft.audio.startRecording(t,r);return!1},async stopRecording(){if(a("audio"))await window.craft.audio.stopRecording()},async isRecording(){if(a("audio"))return await window.craft.audio.isRecording();return!1}};var Ji={async execute(t){if(!t)throw Error("appleScript.execute: source is required");if(!a("appleScript"))return{ok:!1};return await window.craft.appleScript.execute(t)}};var Qi={async getDefault(t){if(!t)throw Error("fileAssociations.getDefault: uti is required");if(!a("fileAssociations"))return null;let r=await window.craft.fileAssociations.getDefault(t);return r?String(r):null},async setDefault(t,r){if(!t||!r)throw Error("fileAssociations.setDefault: uti and bundleId are required");if(!a("fileAssociations"))return!1;return await window.craft.fileAssociations.setDefault(t,r)}};var Zi={async get(t){if(!t)throw Error("tags.get: path is required");if(!a("tags"))return[];return await window.craft.tags.get(t)},async set(t,r){if(!t)throw Error("tags.set: path is required");if(!a("tags"))return!1;let n=Array.isArray(r)?r:[String(r)];return await window.craft.tags.set(t,n)},async clear(t){if(!t)throw Error("tags.clear: path is required");if(!a("tags"))return!1;return await window.craft.tags.clear(t)}};var ea={async countPages(t){if(!t)throw Error("pdf.countPages: path is required");if(!a("pdf"))return 0;return await window.craft.pdf.countPages(t)},async extractText(t){if(!t)throw Error("pdf.extractText: path is required");if(!a("pdf"))return"";return await window.craft.pdf.extractText(t)}};var ta={async debug(t){if(a("log"))await window.craft.log.debug(t);else console.debug(t)},async info(t){if(a("log"))await window.craft.log.info(t);else console.info(t)},async warn(t){if(a("log"))await window.craft.log.warn(t);else console.warn(t)},async error(t){if(a("log"))await window.craft.log.error(t);else console.error(t)}};var ra={async browse(t){if(!a("bonjour"))return{started:!1,reason:"bridge unavailable"};return await window.craft.bonjour.browse(t)},async stop(){if(a("bonjour"))await window.craft.bonjour.stop()},onFound(t){return g("craft:bonjour:found",t)},onLost(t){return g("craft:bonjour:lost",t)}};var na={async index(t){if(!a("spotlight"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.spotlight.index(t)},async remove(t){if(!a("spotlight"))return{ok:!1};return await window.craft.spotlight.remove(t)},async removeAll(){if(!a("spotlight"))return{ok:!1};return await window.craft.spotlight.removeAll()}};var oa={async isAvailable(){if(!a("speechRecognition"))return!1;return await window.craft.speechRecognition.isAvailable()},async start(t){if(!a("speechRecognition"))return{started:!1,reason:"bridge unavailable"};return await window.craft.speechRecognition.start(t)},async stop(){if(a("speechRecognition"))await window.craft.speechRecognition.stop()},onPartial(t){return g("craft:speechRecognition:partial",t)},onFinal(t){return g("craft:speechRecognition:final",t)}};var ia={async recognizeText(t){if(!t)throw Error("vision.recognizeText: path is required");if(!a("vision"))return[];return await window.craft.vision.recognizeText(t)},async detectFaces(t){if(!t)throw Error("vision.detectFaces: path is required");if(!a("vision"))return[];return await window.craft.vision.detectFaces(t)},async detectBarcodes(t){if(!t)throw Error("vision.detectBarcodes: path is required");if(!a("vision"))return[];return await window.craft.vision.detectBarcodes(t)}};var aa={async listSources(){if(!a("midi"))return[];return await window.craft.midi.listSources()},async listDestinations(){if(!a("midi"))return[];return await window.craft.midi.listDestinations()},async send(t,r){if(!a("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.send(t,r)},async subscribe(t){if(!a("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.subscribe(t)},async unsubscribe(t){if(!a("midi"))return{ok:!1};return await window.craft.midi.unsubscribe(t)},onMessage(t){return g("craft:midi:message",t)}};var sa={async loadModel(t,r){if(!t||!r)throw Error("coreml.loadModel: id and path are required");if(!a("coreml"))return!1;return await window.craft.coreml.loadModel(t,r)},async unloadModel(t){if(!a("coreml"))return;await window.craft.coreml.unloadModel(t)},async predict(t,r){if(!t)throw Error("coreml.predict: id is required");if(!a("coreml"))return null;return await window.craft.coreml.predict(t,r)}};var ca={async listCameras(){if(!a("continuityCamera"))return[];return await window.craft.continuityCamera.listCameras()}};var la={async register(t){if(!t)throw Error("serviceMenu.register: name is required");if(!a("serviceMenu"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serviceMenu.register(t)},async unregister(t){if(!t)throw Error("serviceMenu.unregister: name is required");if(!a("serviceMenu"))return;await window.craft.serviceMenu.unregister(t)},onInvoked(t){return g("craft:serviceMenu:invoked",t)}};var da={async list(){if(!a("serial"))return[];return await window.craft.serial.list()},async open(t,r=9600){if(!t)throw Error("serial.open: path is required");if(!a("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.open(t,r)},async write(t,r){if(!t)throw Error("serial.write: id is required");if(!a("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.write(t,r)},async close(t){if(!a("serial"))return;await window.craft.serial.close(t)},onData(t){return g("craft:serial:data",t)}};var Ht=[{name:"fs",support:"native"},{name:"shell",support:"native"},{name:"system",support:"all"},{name:"clipboard",support:"all"},{name:"dialog",support:"all"},{name:"window",support:"native"},{name:"tray",support:"native"},{name:"menu",support:"native"},{name:"theme",support:"all"},{name:"screen",support:"all"},{name:"network",support:"all"},{name:"power",support:"all"},{name:"battery",support:"all"},{name:"notifications",support:"all"},{name:"globalShortcuts",support:"native"},{name:"autolaunch",support:"native"},{name:"appInfo",support:"all"},{name:"localServer",support:"native"},{name:"bluetooth",support:"native"},{name:"crashReporter",support:"all"},{name:"updater",support:"native"},{name:"iap",support:"macos"},{name:"keychain",support:"native"},{name:"log",support:"all"},{name:"biometric",support:"macos"},{name:"location",support:"macos"},{name:"audio",support:"macos"},{name:"deepLink",support:"native"},{name:"handoff",support:"macos"},{name:"liveActivities",support:"macos"},{name:"touchbar",support:"macos"},{name:"dragOut",support:"macos"},{name:"appleScript",support:"macos"},{name:"fileAssociations",support:"native"},{name:"tags",support:"macos"},{name:"pdf",support:"macos"},{name:"bonjour",support:"macos"},{name:"spotlight",support:"macos"},{name:"speechRecognition",support:"macos"},{name:"vision",support:"macos"},{name:"midi",support:"macos"},{name:"coreml",support:"macos"},{name:"continuityCamera",support:"macos"},{name:"serviceMenu",support:"macos"},{name:"serial",support:"native"}];function ua(){return Ht.map(({name:t,support:r})=>({name:t,support:r,available:a(t)}))}function qt(t){let r=Ht.find((n)=>n.name===t);if(!r)return;return{...r,available:a(t)}}function pa(t){let r=qt(t);return!!r&&r.available}function fa(t,r={}){if(!Number.isInteger(t)||t<0||t>86400000)return Promise.reject(RangeError("delayMs must be an integer between 0 and 86400000"));let{signal:n}=r,o=()=>new DOMException("Background delay aborted","AbortError");if(n?.aborted)return Promise.reject(o());if(a("timers"))return x("timers").sleep(t,r);if(typeof window<"u"&&window.craft)return Promise.reject(Error("Native background deadlines require a Craft runtime with timers.sleep support"));return new Promise((i,s)=>{let c=setTimeout(()=>{n?.removeEventListener("abort",l),i()},t);function l(){clearTimeout(c),n?.removeEventListener("abort",l),s(o())}n?.addEventListener("abort",l,{once:!0})})}import Vt from"process";import{existsSync as ma}from"fs";import{join as ga}from"path";function jt(t,r,n=Vt.arch){let o=t;if(!/^[\w.-]+\/[\w.-]+$/.test(r)||!o||o.schemaVersion!==1||o.repository!==r||typeof o.tag!=="string"||!/^v\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(o.tag)||!o.generatedAt||!Number.isFinite(Date.parse(o.generatedAt))||!Array.isArray(o.assets))throw Error("Invalid Pantry release manifest");let i=o.assets.filter((d)=>typeof d?.name==="string"&&/-darwin-(arm64|x64)\.tar\.gz$/.test(d.name));if(i.length&&!i.some((d)=>d.name.endsWith(`-darwin-${n}.tar.gz`)))throw Error(`This release does not support ${n} Macs`);let s=o.assets.filter((d)=>typeof d?.name==="string"&&d.name.endsWith(".dmg")),c=s.length>1?s.filter((d)=>d.name.includes(`-${n}.`)):s,l=c[0];if(c.length!==1||!l||!l.name||/[/\\]/.test(l.name)||!Number.isSafeInteger(l.size)||l.size<=0||!/^[a-f\d]{64}$/i.test(l.sha256))throw Error("Release must contain one compatible disk image with a SHA-256 checksum");return{version:o.tag.slice(1),releaseDate:o.generatedAt,platforms:{darwin:{url:se(r,encodeURIComponent(o.tag),encodeURIComponent(l.name)),size:l.size,sha256:l.sha256}}}}async function Kt(t){return Ce({...t,manifestAsset:"release-manifest.json",parseManifest:(r)=>jt(r,t.repository),autoDownload:!1,autoInstall:!1})}function ha(t,r=Kt){let n={currentVersion:t.currentVersion,phase:"idle"},o,i,s=t.appPath??j();if(!s||Vt.platform!=="darwin")n={...n,phase:"unavailable",error:"Updates are available in the installed Mac app."};else if(ma(ga(s,"Contents/_MASReceipt/receipt")))n={...n,phase:"unavailable",error:"Use the App Store to update this copy."};let c=(l=200)=>Response.json(n,{status:l,headers:{"cache-control":"no-store"}});return async(l)=>{let d=new URL(l.url).pathname;if(d!=="/api/updates"&&!d.startsWith("/api/updates/"))return null;if(d==="/api/updates"&&l.method==="GET")return c();let u=d.slice(13);if(l.method!=="POST"||!["check","download","install"].includes(u))return c(405);if(n.phase==="unavailable")return c(409);if(i)return c(409);if(u==="download"&&n.phase!=="available")return c(409);if(u==="install"&&n.phase!=="ready")return c(409);return n={...n,phase:u==="check"?"checking":u==="download"?"downloading":"installing",error:void 0,percent:void 0},i=Promise.resolve().then(async()=>{if(!o)o=await r(t),o.on("error",()=>{}),o.on("download-progress",(p)=>{n={...n,percent:p.percent}});if(u==="check"){let p=await o.checkForUpdates();if(o.getLastError())throw o.getLastError();n={currentVersion:t.currentVersion,phase:p?"available":"current",version:p?.version}}else if(u==="download"){if(!await o.downloadUpdate())throw o.getLastError()??Error("Download failed");n={...n,phase:"ready",percent:100}}else await o.installUpdate(!0),n={...n,phase:"installed",percent:100}}).catch((p)=>{n={...n,phase:"error",error:p instanceof Error?p.message:String(p)}}).finally(()=>{i=void 0}),c(202)}}import{existsSync as wa}from"fs";import{homedir as ba}from"os";import{isAbsolute as xa,join as N}from"path";function ya(t,r={}){if(!t||t==="."||t===".."||/[/\\\0]/.test(t))throw Error("Application data requires an application name");let n=r.dataRoot??process.env.STX_DATA_HOME;if(n){if(!xa(n)||n.includes("\x00"))throw Error("Application data root must be an absolute directory");return N(n,t)}let o=r.home??ba(),i=r.platform??process.platform;if(i==="darwin"){let s=r.bundleIdentifier;if(s){if(!/^[\w-]+(?:\.[\w-]+)+$/.test(s))throw Error("Invalid application bundle identifier");let c=N(o,"Library/Containers",s);if(wa(c))return N(c,"Data/Library/Application Support",t)}return N(o,"Library/Application Support",t)}if(i==="win32")return N(process.env.LOCALAPPDATA||N(o,"AppData/Local"),t);return N(process.env.XDG_DATA_HOME||N(o,".local/share"),t)}export{Vr as AVAILABLE_COMPONENTS,nt as AutoUpdater,jr as COMPONENT_STYLES,me as DEFAULT_WATCH_INTERVAL_MS,zt as MAX_WATCH_INTERVAL_MS,Wt as MIN_WATCH_INTERVAL_MS,an as MODAL_STYLES,lr as TOAST_STYLES,wn as TRAY_MENU_STYLES,it as UPDATE_MANIFEST_ASSET,tn as alert,pi as appInfo,Ji as appleScript,ya as applicationDataDirectory,Xi as audio,fa as backgroundDelay,ci as battery,Yi as biometric,Mi as bluetooth,ra as bonjour,j as bundlePathForExecutable,lo as caffeinate,ro as canReplaceBundle,no as clearQuarantine,Vo as clipboard,on as closeAllModals,_n as closeAllWindows,en as confirm,wi as contextMenu,ca as continuityCamera,sa as coreml,eo as craftBinaryNotFoundMessage,ke as craftWindowArguments,ee as crashReporter,Dr as createAccordion,Ar as createAutocomplete,hr as createAvatar,gr as createBadge,dr as createButton,wr as createCard,Fr as createChart,pr as createCheckbox,$r as createChip,Wr as createCodeEditor,Pr as createColorPicker,Nr as createDataGrid,Sr as createDatePicker,xr as createDropdown,Hr as createFileExplorer,so as createGitHubUpdateManifest,st as createGitHubUpdater,Ir as createImageView,zo as createInterval,Cr as createLabel,Rr as createListView,zr as createMediaPlayer,un as createMenubar,Or as createModalComponent,ha as createNativeUpdateApi,Kt as createPantrySelfUpdater,So as createPreferences,mr as createProgressBar,vr as createRadioButton,yr as createRating,Er as createScrollView,Ce as createSelfUpdater,fr as createSlider,Mr as createSplitView,Br as createStepper,Xe as createSystemTray,Lr as createTable,br as createTabs,ur as createTextInput,kr as createTimePicker,Wo as createTimer,Tr as createTooltip,_r as createTreeView,qr as createWebView,Nn as createWindow,Wn as createWindowWithHTML,Ie as decaffeinate,si as deepLinks,Uo as delay,ar as dismissAlertById,sr as dismissAllAlerts,ii as dragOut,oo as extractBundle,Qi as fileAssociations,Fe as focus,Ki as focusShortcutsReady,qo as formatCompact,mo as formatDuration,fo as formatRemainingTime,Bo as formatShortcut,Ho as formatTime,Yo as fs,ot as generateUpdateManifest,cr as getActiveAlertCount,nn as getActiveModalCount,pn as getActiveTrayInstances,Rn as getActiveWindowIds,po as getCaffeinateStatus,ua as getCapabilities,qt as getCapability,Dn as getDesktopConfig,$n as getDialogBridgeScript,Fo as getRegisteredHotkeys,gn as getSimulatedTrayHTML,hn as getTrayBridgeScript,fn as getTrayInstance,Ln as getWindow,Un as getWindowBridgeScript,at as githubLatestAssetUrl,se as githubReleaseAssetUrl,ri as globalShortcuts,te as handoff,ji as hasFocusShortcuts,Fi as iap,Mo as isAutoLaunchEnabled,pa as isAvailable,uo as isCaffeinated,ai as isDragOutAvailable,zn as isWebviewAvailable,yi as keychain,Wi as liveActivities,Gi as localServer,zi as location,ta as log,Jn as macOSRuntimeExecutablePath,hi as menu,aa as midi,Ai as nativeAutoLaunch,Ci as nativeTray,Ii as nativeWindow,li as network,Ko as notifications,ir as notify,Fn as openDevWindow,Qn as pack,Zn as packageApp,jt as parsePantryUpdateManifest,xt as parseShortcut,ea as pdf,vi as permissions,ki as printing,rn as prompt,ct as quitLauncher,Ae as readBundleIdentity,_t as redactPII,_o as registerHotkey,lt as relaunchBundle,Xt as requestNotificationPermission,Bn as resetDesktopConfig,to as resolveCraftBinary,Xn as resolveCraftExecutablePath,co as runningBundleTeamId,xi as screen,Ui as screenCapture,fe as screenSharing,da as serial,la as serviceMenu,Eo as setAutoLaunch,Mn as setDesktopConfig,ti as shell,he as showAlert,kn as showAlertDialog,Sn as showColorPicker,An as showConfirmDialog,Cn as showErrorDialog,Qr as showErrorModal,or as showErrorToast,He as showInfoModal,tr as showInfoToast,X as showMessageBox,H as showModal,vn as showOpenDialog,qe as showQuestionModal,Pn as showSaveDialog,Zr as showSuccessModal,rr as showSuccessToast,Y as showToast,In as showWarningDialog,Jr as showWarningModal,nr as showWarningToast,Bt as sidebar,Nt as signPayload,Di as speech,oa as speechRecognition,na as spotlight,fi as standardMenus,io as swapBundle,bi as system,Zi as tags,ni as theme,$i as touchbar,mn as triggerTrayAction,No as unregisterAllHotkeys,vt as unregisterHotkey,di as updater,ao as verifyBundleTrust,ia as vision,qi as watchScreenSharing,ui as windowEvents};
|
|
930
|
+
<script>setTimeout(()=>window.close(),1500)</script>`;this.respond({status:200,body:m,contentType:"text/html; charset=utf-8"}).catch(()=>{}).finally(()=>this.stop().catch(()=>{})),c({url:p,port:s.port})})})}};var Xi={async isAvailable(){if(!a("biometric"))return!1;return await window.craft.biometric.isAvailable()},async getBiometryType(){if(!a("biometric"))return"none";return await window.craft.biometric.getBiometryType()},async evaluate(t,r){if(!t)throw Error("biometric.evaluate: reason is required");if(!a("biometric"))return{success:!1,errorCode:-1};return await window.craft.biometric.evaluate(t,r)}};var I=null,Ji={async play(t,r){if(a("audio"))return await window.craft.audio.play(t,r);if(typeof window>"u"||typeof Audio>"u")return!1;if(I)I.pause(),I=null;if(I=new Audio(t),r?.volume!=null)I.volume=r.volume;if(r?.loops)I.loop=!0;try{return await I.play(),!0}catch{return!1}},async playSystemSound(t){if(a("audio"))return await window.craft.audio.playSystemSound(t);if(typeof window>"u"||typeof Audio>"u")return!1;try{return I=new Audio(`/System/Library/Sounds/${t}.aiff`),await I.play(),!0}catch{return!1}},async stop(){if(a("audio")){await window.craft.audio.stop();return}if(I)I.pause(),I.currentTime=0,I=null},async isPlaying(){if(a("audio"))return await window.craft.audio.isPlaying();return!!(I&&!I.paused)},async startRecording(t,r){if(a("audio"))return await window.craft.audio.startRecording(t,r);return!1},async stopRecording(){if(a("audio"))await window.craft.audio.stopRecording()},async isRecording(){if(a("audio"))return await window.craft.audio.isRecording();return!1}};var Qi={async execute(t){if(!t)throw Error("appleScript.execute: source is required");if(!a("appleScript"))return{ok:!1};return await window.craft.appleScript.execute(t)}};var Zi={async getDefault(t){if(!t)throw Error("fileAssociations.getDefault: uti is required");if(!a("fileAssociations"))return null;let r=await window.craft.fileAssociations.getDefault(t);return r?String(r):null},async setDefault(t,r){if(!t||!r)throw Error("fileAssociations.setDefault: uti and bundleId are required");if(!a("fileAssociations"))return!1;return await window.craft.fileAssociations.setDefault(t,r)}};var ea={async get(t){if(!t)throw Error("tags.get: path is required");if(!a("tags"))return[];return await window.craft.tags.get(t)},async set(t,r){if(!t)throw Error("tags.set: path is required");if(!a("tags"))return!1;let n=Array.isArray(r)?r:[String(r)];return await window.craft.tags.set(t,n)},async clear(t){if(!t)throw Error("tags.clear: path is required");if(!a("tags"))return!1;return await window.craft.tags.clear(t)}};var ta={async countPages(t){if(!t)throw Error("pdf.countPages: path is required");if(!a("pdf"))return 0;return await window.craft.pdf.countPages(t)},async extractText(t){if(!t)throw Error("pdf.extractText: path is required");if(!a("pdf"))return"";return await window.craft.pdf.extractText(t)}};var ra={async debug(t){if(a("log"))await window.craft.log.debug(t);else console.debug(t)},async info(t){if(a("log"))await window.craft.log.info(t);else console.info(t)},async warn(t){if(a("log"))await window.craft.log.warn(t);else console.warn(t)},async error(t){if(a("log"))await window.craft.log.error(t);else console.error(t)}};var na={async browse(t){if(!a("bonjour"))return{started:!1,reason:"bridge unavailable"};return await window.craft.bonjour.browse(t)},async stop(){if(a("bonjour"))await window.craft.bonjour.stop()},onFound(t){return g("craft:bonjour:found",t)},onLost(t){return g("craft:bonjour:lost",t)}};var oa={async index(t){if(!a("spotlight"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.spotlight.index(t)},async remove(t){if(!a("spotlight"))return{ok:!1};return await window.craft.spotlight.remove(t)},async removeAll(){if(!a("spotlight"))return{ok:!1};return await window.craft.spotlight.removeAll()}};var ia={async isAvailable(){if(!a("speechRecognition"))return!1;return await window.craft.speechRecognition.isAvailable()},async start(t){if(!a("speechRecognition"))return{started:!1,reason:"bridge unavailable"};return await window.craft.speechRecognition.start(t)},async stop(){if(a("speechRecognition"))await window.craft.speechRecognition.stop()},onPartial(t){return g("craft:speechRecognition:partial",t)},onFinal(t){return g("craft:speechRecognition:final",t)}};var aa={async recognizeText(t){if(!t)throw Error("vision.recognizeText: path is required");if(!a("vision"))return[];return await window.craft.vision.recognizeText(t)},async detectFaces(t){if(!t)throw Error("vision.detectFaces: path is required");if(!a("vision"))return[];return await window.craft.vision.detectFaces(t)},async detectBarcodes(t){if(!t)throw Error("vision.detectBarcodes: path is required");if(!a("vision"))return[];return await window.craft.vision.detectBarcodes(t)}};var sa={async listSources(){if(!a("midi"))return[];return await window.craft.midi.listSources()},async listDestinations(){if(!a("midi"))return[];return await window.craft.midi.listDestinations()},async send(t,r){if(!a("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.send(t,r)},async subscribe(t){if(!a("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.subscribe(t)},async unsubscribe(t){if(!a("midi"))return{ok:!1};return await window.craft.midi.unsubscribe(t)},onMessage(t){return g("craft:midi:message",t)}};var ca={async loadModel(t,r){if(!t||!r)throw Error("coreml.loadModel: id and path are required");if(!a("coreml"))return!1;return await window.craft.coreml.loadModel(t,r)},async unloadModel(t){if(!a("coreml"))return;await window.craft.coreml.unloadModel(t)},async predict(t,r){if(!t)throw Error("coreml.predict: id is required");if(!a("coreml"))return null;return await window.craft.coreml.predict(t,r)}};var la={async listCameras(){if(!a("continuityCamera"))return[];return await window.craft.continuityCamera.listCameras()}};var da={async register(t){if(!t)throw Error("serviceMenu.register: name is required");if(!a("serviceMenu"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serviceMenu.register(t)},async unregister(t){if(!t)throw Error("serviceMenu.unregister: name is required");if(!a("serviceMenu"))return;await window.craft.serviceMenu.unregister(t)},onInvoked(t){return g("craft:serviceMenu:invoked",t)}};var ua={async list(){if(!a("serial"))return[];return await window.craft.serial.list()},async open(t,r=9600){if(!t)throw Error("serial.open: path is required");if(!a("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.open(t,r)},async write(t,r){if(!t)throw Error("serial.write: id is required");if(!a("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.write(t,r)},async close(t){if(!a("serial"))return;await window.craft.serial.close(t)},onData(t){return g("craft:serial:data",t)}};var Ht=[{name:"fs",support:"native"},{name:"shell",support:"native"},{name:"system",support:"all"},{name:"clipboard",support:"all"},{name:"dialog",support:"all"},{name:"window",support:"native"},{name:"tray",support:"native"},{name:"menu",support:"native"},{name:"theme",support:"all"},{name:"screen",support:"all"},{name:"network",support:"all"},{name:"power",support:"all"},{name:"battery",support:"all"},{name:"notifications",support:"all"},{name:"globalShortcuts",support:"native"},{name:"autolaunch",support:"native"},{name:"appInfo",support:"all"},{name:"localServer",support:"native"},{name:"bluetooth",support:"native"},{name:"crashReporter",support:"all"},{name:"updater",support:"native"},{name:"iap",support:"macos"},{name:"keychain",support:"native"},{name:"log",support:"all"},{name:"biometric",support:"macos"},{name:"location",support:"macos"},{name:"audio",support:"macos"},{name:"deepLink",support:"native"},{name:"handoff",support:"macos"},{name:"liveActivities",support:"macos"},{name:"touchbar",support:"macos"},{name:"dragOut",support:"macos"},{name:"appleScript",support:"macos"},{name:"fileAssociations",support:"native"},{name:"tags",support:"macos"},{name:"pdf",support:"macos"},{name:"bonjour",support:"macos"},{name:"spotlight",support:"macos"},{name:"speechRecognition",support:"macos"},{name:"vision",support:"macos"},{name:"midi",support:"macos"},{name:"coreml",support:"macos"},{name:"continuityCamera",support:"macos"},{name:"serviceMenu",support:"macos"},{name:"serial",support:"native"}];function pa(){return Ht.map(({name:t,support:r})=>({name:t,support:r,available:a(t)}))}function qt(t){let r=Ht.find((n)=>n.name===t);if(!r)return;return{...r,available:a(t)}}function fa(t){let r=qt(t);return!!r&&r.available}function ma(t,r={}){if(!Number.isInteger(t)||t<0||t>86400000)return Promise.reject(RangeError("delayMs must be an integer between 0 and 86400000"));let{signal:n}=r,o=()=>new DOMException("Background delay aborted","AbortError");if(n?.aborted)return Promise.reject(o());if(a("timers"))return x("timers").sleep(t,r);if(typeof window<"u"&&window.craft)return Promise.reject(Error("Native background deadlines require a Craft runtime with timers.sleep support"));return new Promise((i,s)=>{let c=setTimeout(()=>{n?.removeEventListener("abort",l),i()},t);function l(){clearTimeout(c),n?.removeEventListener("abort",l),s(o())}n?.addEventListener("abort",l,{once:!0})})}import Vt from"process";import{existsSync as ga}from"fs";import{join as ha}from"path";function jt(t,r,n=Vt.arch){let o=t;if(!/^[\w.-]+\/[\w.-]+$/.test(r)||!o||o.schemaVersion!==1||o.repository!==r||typeof o.tag!=="string"||!/^v\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(o.tag)||!o.generatedAt||!Number.isFinite(Date.parse(o.generatedAt))||!Array.isArray(o.assets))throw Error("Invalid Pantry release manifest");let i=o.assets.filter((d)=>typeof d?.name==="string"&&/-darwin-(arm64|x64)\.tar\.gz$/.test(d.name));if(i.length&&!i.some((d)=>d.name.endsWith(`-darwin-${n}.tar.gz`)))throw Error(`This release does not support ${n} Macs`);let s=o.assets.filter((d)=>typeof d?.name==="string"&&/\.dmg(?:\.zip)?$/.test(d.name)),c=s.length>1?s.filter((d)=>d.name.includes(`-${n}.`)):s,l=c[0];if(c.length!==1||!l||!l.name||/[/\\]/.test(l.name)||!Number.isSafeInteger(l.size)||l.size<=0||!/^[a-f\d]{64}$/i.test(l.sha256))throw Error("Release must contain one compatible disk image with a SHA-256 checksum");return{version:o.tag.slice(1),releaseDate:o.generatedAt,platforms:{darwin:{url:se(r,encodeURIComponent(o.tag),encodeURIComponent(l.name)),size:l.size,sha256:l.sha256}}}}async function Kt(t){return Ce({...t,manifestAsset:"release-manifest.json",parseManifest:(r)=>jt(r,t.repository),autoDownload:!1,autoInstall:!1})}function wa(t,r=Kt){let n={currentVersion:t.currentVersion,phase:"idle"},o,i,s=t.appPath??j();if(!s||Vt.platform!=="darwin")n={...n,phase:"unavailable",error:"Updates are available in the installed Mac app."};else if(ga(ha(s,"Contents/_MASReceipt/receipt")))n={...n,phase:"unavailable",error:"Use the App Store to update this copy."};let c=(l=200)=>Response.json(n,{status:l,headers:{"cache-control":"no-store"}});return async(l)=>{let d=new URL(l.url).pathname;if(d!=="/api/updates"&&!d.startsWith("/api/updates/"))return null;if(d==="/api/updates"&&l.method==="GET")return c();let u=d.slice(13);if(l.method!=="POST"||!["check","download","install"].includes(u))return c(405);if(n.phase==="unavailable")return c(409);if(i)return c(409);if(u==="download"&&n.phase!=="available")return c(409);if(u==="install"&&n.phase!=="ready")return c(409);return n={...n,phase:u==="check"?"checking":u==="download"?"downloading":"installing",error:void 0,percent:void 0},i=Promise.resolve().then(async()=>{if(!o)o=await r(t),o.on("error",()=>{}),o.on("download-progress",(p)=>{n={...n,percent:p.percent}});if(u==="check"){let p=await o.checkForUpdates();if(o.getLastError())throw o.getLastError();n={currentVersion:t.currentVersion,phase:p?"available":"current",version:p?.version}}else if(u==="download"){if(!await o.downloadUpdate())throw o.getLastError()??Error("Download failed");n={...n,phase:"ready",percent:100}}else await o.installUpdate(!0),n={...n,phase:"installed",percent:100}}).catch((p)=>{n={...n,phase:"error",error:p instanceof Error?p.message:String(p)}}).finally(()=>{i=void 0}),c(202)}}import{existsSync as ba}from"fs";import{homedir as xa}from"os";import{isAbsolute as ya,join as N}from"path";function va(t,r={}){if(!t||t==="."||t===".."||/[/\\\0]/.test(t))throw Error("Application data requires an application name");let n=r.dataRoot??process.env.STX_DATA_HOME;if(n){if(!ya(n)||n.includes("\x00"))throw Error("Application data root must be an absolute directory");return N(n,t)}let o=r.home??xa(),i=r.platform??process.platform;if(i==="darwin"){let s=r.bundleIdentifier;if(s){if(!/^[\w-]+(?:\.[\w-]+)+$/.test(s))throw Error("Invalid application bundle identifier");let c=N(o,"Library/Containers",s);if(ba(c))return N(c,"Data/Library/Application Support",t)}return N(o,"Library/Application Support",t)}if(i==="win32")return N(process.env.LOCALAPPDATA||N(o,"AppData/Local"),t);return N(process.env.XDG_DATA_HOME||N(o,".local/share"),t)}export{Vr as AVAILABLE_COMPONENTS,nt as AutoUpdater,jr as COMPONENT_STYLES,me as DEFAULT_WATCH_INTERVAL_MS,Wt as MAX_WATCH_INTERVAL_MS,zt as MIN_WATCH_INTERVAL_MS,an as MODAL_STYLES,lr as TOAST_STYLES,wn as TRAY_MENU_STYLES,it as UPDATE_MANIFEST_ASSET,tn as alert,fi as appInfo,Qi as appleScript,va as applicationDataDirectory,Ji as audio,ma as backgroundDelay,li as battery,Xi as biometric,Di as bluetooth,na as bonjour,j as bundlePathForExecutable,uo as caffeinate,no as canReplaceBundle,oo as clearQuarantine,jo as clipboard,on as closeAllModals,_n as closeAllWindows,en as confirm,bi as contextMenu,la as continuityCamera,ca as coreml,to as craftBinaryNotFoundMessage,ke as craftWindowArguments,ee as crashReporter,Dr as createAccordion,Ar as createAutocomplete,hr as createAvatar,gr as createBadge,dr as createButton,wr as createCard,Fr as createChart,pr as createCheckbox,$r as createChip,zr as createCodeEditor,Pr as createColorPicker,Nr as createDataGrid,Sr as createDatePicker,Jn as createDiskImage,xr as createDropdown,Hr as createFileExplorer,co as createGitHubUpdateManifest,st as createGitHubUpdater,Ir as createImageView,Uo as createInterval,Cr as createLabel,Rr as createListView,Wr as createMediaPlayer,un as createMenubar,Or as createModalComponent,wa as createNativeUpdateApi,Kt as createPantrySelfUpdater,ko as createPreferences,mr as createProgressBar,vr as createRadioButton,yr as createRating,Er as createScrollView,Ce as createSelfUpdater,fr as createSlider,Mr as createSplitView,Br as createStepper,Xe as createSystemTray,Lr as createTable,br as createTabs,ur as createTextInput,kr as createTimePicker,Wo as createTimer,Tr as createTooltip,_r as createTreeView,qr as createWebView,Nn as createWindow,zn as createWindowWithHTML,Ie as decaffeinate,ci as deepLinks,Ho as delay,ar as dismissAlertById,sr as dismissAllAlerts,ai as dragOut,io as extractBundle,Zi as fileAssociations,Fe as focus,Gi as focusShortcutsReady,Vo as formatCompact,go as formatDuration,mo as formatRemainingTime,Oo as formatShortcut,qo as formatTime,Xo as fs,ot as generateUpdateManifest,cr as getActiveAlertCount,nn as getActiveModalCount,pn as getActiveTrayInstances,Rn as getActiveWindowIds,fo as getCaffeinateStatus,pa as getCapabilities,qt as getCapability,Dn as getDesktopConfig,$n as getDialogBridgeScript,zo as getRegisteredHotkeys,gn as getSimulatedTrayHTML,hn as getTrayBridgeScript,fn as getTrayInstance,Ln as getWindow,Un as getWindowBridgeScript,at as githubLatestAssetUrl,se as githubReleaseAssetUrl,ni as globalShortcuts,te as handoff,Ki as hasFocusShortcuts,zi as iap,Do as isAutoLaunchEnabled,fa as isAvailable,po as isCaffeinated,si as isDragOutAvailable,Wn as isWebviewAvailable,vi as keychain,Wi as liveActivities,Yi as localServer,Ui as location,ra as log,Qn as macOSRuntimeExecutablePath,wi as menu,sa as midi,Ci as nativeAutoLaunch,Ii as nativeTray,$i as nativeWindow,di as network,Go as notifications,ir as notify,Fn as openDevWindow,Zn as pack,eo as packageApp,jt as parsePantryUpdateManifest,xt as parseShortcut,ta as pdf,Pi as permissions,Ai as printing,rn as prompt,ct as quitLauncher,Ae as readBundleIdentity,_t as redactPII,No as registerHotkey,lt as relaunchBundle,Xt as requestNotificationPermission,Bn as resetDesktopConfig,ro as resolveCraftBinary,Xn as resolveCraftExecutablePath,lo as runningBundleTeamId,yi as screen,Hi as screenCapture,fe as screenSharing,ua as serial,da as serviceMenu,Mo as setAutoLaunch,Mn as setDesktopConfig,ri as shell,he as showAlert,kn as showAlertDialog,Sn as showColorPicker,An as showConfirmDialog,Cn as showErrorDialog,Qr as showErrorModal,or as showErrorToast,He as showInfoModal,tr as showInfoToast,X as showMessageBox,H as showModal,vn as showOpenDialog,qe as showQuestionModal,Pn as showSaveDialog,Zr as showSuccessModal,rr as showSuccessToast,Y as showToast,In as showWarningDialog,Jr as showWarningModal,nr as showWarningToast,Bt as sidebar,Nt as signPayload,Bi as speech,ia as speechRecognition,oa as spotlight,mi as standardMenus,ao as swapBundle,xi as system,ea as tags,oi as theme,Ti as touchbar,mn as triggerTrayAction,Fo as unregisterAllHotkeys,vt as unregisterHotkey,ui as updater,so as verifyBundleTrust,aa as vision,Vi as watchScreenSharing,pi as windowEvents};
|
package/dist/packaging.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type { PackageConfig, PackageResult } from 'craft-native';
|
|
|
7
7
|
* source builds can supply a native executable through CRAFT_BIN or `explicit`.
|
|
8
8
|
*/
|
|
9
9
|
export declare function resolveCraftExecutablePath(explicit?: string, profile?: 'full' | 'webview'): string;
|
|
10
|
-
export { macOSRuntimeExecutablePath, pack, packageApp } from 'craft-native';
|
|
10
|
+
export { createDiskImage, macOSRuntimeExecutablePath, pack, packageApp } from 'craft-native';
|
|
11
11
|
/**
|
|
12
12
|
* Craft's binary resolution contract — PATH (craft installs via pantry), with
|
|
13
13
|
* `CRAFT_BIN` for local builds. Re-exported so a build script bundling the
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/desktop",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.798",
|
|
5
5
|
"description": "Native desktop application framework for stx (powered by Craft)",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -63,6 +63,6 @@
|
|
|
63
63
|
"typecheck": "bun tsc --noEmit"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"craft-native": ">=0.0.
|
|
66
|
+
"craft-native": ">=0.0.442"
|
|
67
67
|
}
|
|
68
68
|
}
|