5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 18:42:23 +08:00
wails/v3/internal/runtime/runtime_production_desktop_windows.js
2023-01-30 19:21:49 +11:00

2 lines
3.5 KiB
JavaScript

(()=>{var M=Object.defineProperty;var D=(t,e)=>{for(var n in e)M(t,n,{get:e[n],enumerable:!0})};var c=null;(function(){let t=function(o){let i=window[o.shift()];for(;i&&o.length;)i=i[o.shift()];return i},e=t(["chrome","webview","postMessage"]),n=t(["webkit","messageHandlers","external","postMessage"]);if(!e&&!n){console.error("Unsupported Platform");return}e&&(c=o=>window.chrome.webview.postMessage(o)),n&&(c=o=>window.webkit.messageHandlers.external.postMessage(o))})();function u(t,e){c(e&&e!==-1?"WINDOWID:"+e+":"+t:t)}var m={};function T(){let t=new Uint32Array(1);return window.crypto.getRandomValues(t)[0]}function W(){return Math.random()*9007199254740991}var w;window.crypto?w=T:w=W;window.ObfuscatedCall=(t,e,n)=>(n==null&&(n=0),new Promise(function(o,i){let r;do r=t+"-"+w();while(m[r]);let p;n>0&&(p=setTimeout(function(){i(Error("Call to method "+t+" timed out. Request ID: "+r))},n)),m[r]={timeoutHandle:p,reject:i,resolve:o};try{let f={id:t,args:e,callbackID:r,windowID:window.wails.window.ID()};window.WailsInvoke("c"+JSON.stringify(f))}catch(f){console.error(f)}}));window.go={};var F=window.location.origin+"/wails/runtime";function h(t,e){let n=new URL(F);return n.searchParams.append("method",t),n.searchParams.append("args",JSON.stringify(e)),new Promise((o,i)=>{fetch(n).then(r=>{if(r.ok)return r.headers.get("content-type")&&r.headers.get("content-type").indexOf("application/json")!==-1?r.json():r.text();i(Error(r.statusText))}).then(r=>o(r)).catch(r=>i(r))})}function s(t,e){return!e||e===-1?function(n,o){return o=o||{},h(t+"."+n,o)}:function(n,o){return o=o||{},o.windowID=e,h(t+"."+n,o)}}var H="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var x=(t=21)=>{let e="",n=t;for(;n--;)e+=H[Math.random()*64|0];return e};var P=s("dialog"),l=new Map;function U(){let t;do t=x();while(l.has(t));return t}function g(t,e,n){let o=l.get(t);o&&(n?o.resolve(JSON.parse(e)):o.resolve(e),l.delete(t))}function S(t,e){let n=l.get(t);n&&(n.reject(e),l.delete(t))}function a(t,e){return new Promise((n,o)=>{let i=U();e=e||{},e["dialog-id"]=i,l.set(i,{resolve:n,reject:o}),P(t,e).catch(r=>{o(r),l.delete(i)})})}function b(t){return a("Info",t)}function y(t){return a("Warning",t)}function v(t){return a("Error",t)}function C(t){return a("Question",t)}function k(t){return a("OpenFile",t)}function E(t){return a("SaveFile",t)}var d={};D(d,{SetText:()=>J,Text:()=>L});var O=s("clipboard");function J(t){return O("SetText",{text:t})}function L(){return O("Text")}function I(t){let e=s("window",t);return{Center:()=>e("Center"),SetTitle:n=>e("SetTitle",{title:n}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(n,o)=>e("SetSize",{width:n,height:o}),Size:()=>e("Size"),SetMaxSize:(n,o)=>e("SetMaxSize",{width:n,height:o}),SetMinSize:(n,o)=>e("SetMinSize",{width:n,height:o}),SetAlwaysOnTop:n=>e("SetAlwaysOnTop",{alwaysOnTop:n}),SetPosition:(n,o)=>e("SetPosition",{x:n,y:o}),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,o,i,r)=>e("SetBackgroundColour",{R,G,B,A})}}window.wails={...z(-1)};window._wails={dialogCallback:g,dialogErrorCallback:S};function z(t){return{Clipboard:{...d},Dialog:{Info:b,Warning:y,Error:v,Question:C,OpenFile:k,SaveFile:E},Window:I(t),Application:{Show:()=>u("S"),Hide:()=>u("H"),Quit:()=>u("Q")}}}console.log("Wails v3.0.0 Debug Mode Enabled");})();