5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 11:10:47 +08:00
wails/v3/internal/runtime/runtime_production_desktop_darwin.js
Lea Anthony f951b51c11
Context menu WIP
options refactor
2023-02-09 18:35:26 +11:00

2 lines
5.1 KiB
JavaScript

(()=>{var Q=Object.defineProperty;var m=(t,e)=>{for(var n in e)Q(t,n,{get:e[n],enumerable:!0})};var y={};m(y,{SetText:()=>X,Text:()=>Y});var J=window.location.origin+"/wails/runtime";function v(t,e){let n=new URL(J);return n.searchParams.append("method",t),e&&n.searchParams.append("args",JSON.stringify(e)),new Promise((i,r)=>{fetch(n).then(o=>{if(o.ok)return o.headers.get("content-type")&&o.headers.get("content-type").indexOf("application/json")!==-1?o.json():o.text();r(Error(o.statusText))}).then(o=>i(o)).catch(o=>r(o))})}function s(t,e){return!e||e===-1?function(n,i){return v(t+"."+n,i)}:function(n,i){return i=i||{},i.windowID=e,v(t+"."+n,i)}}var S=s("clipboard");function X(t){return S("SetText",{text:t})}function Y(){return S("Text")}var b={};m(b,{Hide:()=>V,Quit:()=>Z,Show:()=>K});var g=s("application");function V(){return g("Hide")}function K(){return g("Show")}function Z(){return g("Quit")}var w={};m(w,{Log:()=>et});var tt=s("log");function et(t){return tt("Log",t)}function E(t){let e=s("window",t);return{Center:()=>e("Center"),SetTitle:n=>e("SetTitle",{title:n}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(n,i)=>e("SetSize",{width:n,height:i}),Size:()=>e("Size"),SetMaxSize:(n,i)=>e("SetMaxSize",{width:n,height:i}),SetMinSize:(n,i)=>e("SetMinSize",{width:n,height:i}),SetAlwaysOnTop:n=>e("SetAlwaysOnTop",{alwaysOnTop:n}),SetPosition:(n,i)=>e("SetPosition",{x:n,y:i}),Position:()=>e("Position"),Screen:()=>e("Screen"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(n,i,r,o)=>e("SetBackgroundColour",{r:n,g:i,b:r,a:o})}}var nt=s("events"),x=class{constructor(e,n,i){this.eventName=e,this.maxCallbacks=i||-1,this.Callback=r=>(n(r),this.maxCallbacks===-1?!1:(this.maxCallbacks-=1,this.maxCallbacks===0))}};var l=new Map;function h(t,e,n){let i=l.get(t)||[],r=new x(t,e,n);return i.push(r),l.set(t,i),()=>it(r)}function k(t,e){return h(t,e,-1)}function C(t,e){return h(t,e,1)}function it(t){let e=t.eventName,n=l.get(e).filter(i=>i!==t);n.length===0?l.delete(e):l.set(e,n)}function O(t){console.log("dispatching event: ",{event:t});let e=l.get(t.name);if(e){let n=[];e.forEach(i=>{i.Callback(t)&&n.push(i)}),n.length>0&&(e=e.filter(i=>!n.includes(i)),e.length===0?l.delete(t.name):l.set(t.name,e))}}function M(t,...e){[t,...e].forEach(i=>{l.delete(i)})}function A(){l.clear()}function D(t){return nt("Emit",t)}var rt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var T=(t=21)=>{let e="",n=t;for(;n--;)e+=rt[Math.random()*64|0];return e};var ot=s("dialog"),a=new Map;function st(){let t;do t=T();while(a.has(t));return t}function R(t,e,n){let i=a.get(t);i&&(n?i.resolve(JSON.parse(e)):i.resolve(e),a.delete(t))}function N(t,e){let n=a.get(t);n&&(n.reject(e),a.delete(t))}function f(t,e){return new Promise((n,i)=>{let r=st();e=e||{},e["dialog-id"]=r,a.set(r,{resolve:n,reject:i}),ot(t,e).catch(o=>{i(o),a.delete(r)})})}function j(t){return f("Info",t)}function L(t){return f("Warning",t)}function P(t){return f("Error",t)}function z(t){return f("Question",t)}function q(t){return f("OpenFile",t)}function I(t){return f("SaveFile",t)}function d(){}function B(t){return t()}function $(t){t.forEach(B)}function F(t){return typeof t=="function"}function W(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function ct(t){return Object.keys(t).length===0}var Et=Promise.resolve();var kt=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function lt(t,e){let n=t.$$;n.fragment!==null&&($(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}var ut;typeof HTMLElement=="function"&&(ut=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){let{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(B).filter(F);for(let e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){$(this.$$.on_disconnect)}$destroy(){lt(this,1),this.$destroy=d}$on(t,e){if(!F(e))return d;let n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,1)}}$set(t){this.$$set&&!ct(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});var _=[];function U(t,e=d){let n,i=new Set;function r(u){if(W(t,u)&&(t=u,n)){let p=!_.length;for(let c of i)c[1](),_.push(c,t);if(p){for(let c=0;c<_.length;c+=2)_[c][0](_[c+1]);_.length=0}}}function o(u){r(u(t))}function G(u,p=d){let c=[u,p];return i.add(c),i.size===1&&(n=e(r)||d),u(t),()=>{i.delete(c),i.size===0&&(n(),n=null)}}return{set:r,update:o,subscribe:G}}var at=U(0),ft=s("state");function H(){ft("ReloadState").then(t=>{at.set(t)})}window.wails={...dt(-1)};window._wails={dialogCallback:R,dialogErrorCallback:N,dispatchCustomEvent:O};function dt(t){return{Clipboard:{...y},Application:{...b},Log:w,Dialog:{Info:j,Warning:L,Error:P,Question:z,OpenFile:q,SaveFile:I},Events:{Emit:D,On:k,Once:C,OnMultiple:h,Off:M,OffAll:A},Window:E(t)}}console.log("Wails v3.0.0 Debug Mode Enabled");H();})();