mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 03:20:09 +08:00
Support Clipboard.
Message Processor refactor.
This commit is contained in:
parent
c0ec5af18a
commit
25577b7655
@ -19,10 +19,11 @@ Informal and incomplete list of things needed in v3.
|
||||
- [ ] Implement alias for `window` in JS
|
||||
- [ ] Implement runtime dispatcher
|
||||
- [ ] Log
|
||||
- [ ] Same Window
|
||||
- [x] Same Window
|
||||
- [ ] Other Window
|
||||
- [ ] Dialogs
|
||||
- [ ] Events
|
||||
- [x] Clipboard
|
||||
|
||||
## Templates
|
||||
|
||||
|
23
v3/internal/runtime/desktop/clipboard.js
Normal file
23
v3/internal/runtime/desktop/clipboard.js
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
/* jshint esversion: 9 */
|
||||
|
||||
import {newRuntimeCaller} from "./runtime";
|
||||
|
||||
let call = newRuntimeCaller("clipboard");
|
||||
|
||||
export function SetText(text) {
|
||||
return call("SetText", {text});
|
||||
}
|
||||
|
||||
export function GetText() {
|
||||
return call("GetText");
|
||||
}
|
@ -14,6 +14,8 @@ import {Callback, callbacks} from './calls';
|
||||
import {EventsNotify, eventListeners} from "./events";
|
||||
import {SetBindings} from "./bindings";
|
||||
|
||||
|
||||
import * as Clipboard from './clipboard';
|
||||
import {newWindow} from "./window";
|
||||
|
||||
// export function Environment() {
|
||||
@ -36,6 +38,9 @@ export function newRuntime(id) {
|
||||
// Browser: newBrowser(id),
|
||||
// Screen: newScreen(id),
|
||||
// Events: newEvents(id),
|
||||
Clipboard: {
|
||||
...Clipboard
|
||||
},
|
||||
Window: newWindow(id),
|
||||
Show: () => invoke("S"),
|
||||
Hide: () => invoke("H"),
|
||||
|
52
v3/internal/runtime/desktop/runtime.js
Normal file
52
v3/internal/runtime/desktop/runtime.js
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
/* jshint esversion: 9 */
|
||||
|
||||
const runtimeURL = window.location.origin + "/wails/runtime";
|
||||
|
||||
function runtimeCall(method, args) {
|
||||
let url = new URL(runtimeURL);
|
||||
url.searchParams.append("method", method);
|
||||
if (args) {
|
||||
for (let key in args) {
|
||||
url.searchParams.append(key, args[key]);
|
||||
}
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
// check content type
|
||||
if (response.headers.get("content-type") && response.headers.get("content-type").indexOf("application/json") !== -1) {
|
||||
return response.json();
|
||||
} else {
|
||||
return response.text();
|
||||
}
|
||||
}
|
||||
reject(Error(response.statusText));
|
||||
})
|
||||
.then(data => resolve(data))
|
||||
.catch(error => reject(error));
|
||||
});
|
||||
}
|
||||
|
||||
export function newRuntimeCaller(object, id) {
|
||||
if (!id || id === -1) {
|
||||
return function (method, args) {
|
||||
return runtimeCall(object + "." + method, args);
|
||||
};
|
||||
}
|
||||
return function (method, args) {
|
||||
args = args || {};
|
||||
args["windowID"] = id;
|
||||
return runtimeCall(object + "." + method, args);
|
||||
}
|
||||
}
|
@ -10,36 +10,10 @@ The electron alternative for Go
|
||||
|
||||
/* jshint esversion: 9 */
|
||||
|
||||
const runtimeURL = window.location.origin + "/wails/runtime";
|
||||
|
||||
function runtimeCall(method, args) {
|
||||
let url = new URL(runtimeURL);
|
||||
url.searchParams.append("method", method);
|
||||
if (args) {
|
||||
for (let key in args) {
|
||||
url.searchParams.append(key, args[key]);
|
||||
}
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
reject(Error(response.statusText));
|
||||
})
|
||||
.then(data => resolve(data))
|
||||
.catch(error => reject(error));
|
||||
});
|
||||
}
|
||||
import {newRuntimeCaller} from "./runtime";
|
||||
|
||||
export function newWindow(id) {
|
||||
let call = function(method, args) {
|
||||
if (id !== -1) {
|
||||
args["windowID"] = id;
|
||||
}
|
||||
return runtimeCall("window." + method, args);
|
||||
}
|
||||
let call = newRuntimeCaller("window", id);
|
||||
return {
|
||||
// Reload: () => call('WR'),
|
||||
// ReloadApp: () => call('WR'),
|
||||
@ -51,12 +25,12 @@ export function newWindow(id) {
|
||||
Fullscreen: () => call('Fullscreen'),
|
||||
UnFullscreen: () => call('UnFullscreen'),
|
||||
SetSize: (width, height) => call('SetSize', {width,height}),
|
||||
GetSize: () => { return call('GetSize') },
|
||||
Size: () => { return call('Size') },
|
||||
SetMaxSize: (width, height) => call('SetMaxSize', {width,height}),
|
||||
SetMinSize: (width, height) => call('SetMinSize', {width,height}),
|
||||
SetAlwaysOnTop: (b) => call('SetAlwaysOnTop', {alwaysOnTop:b}),
|
||||
SetPosition: (x, y) => call('SetPosition', {x,y}),
|
||||
GetPosition: () => { return call('GetPosition') },
|
||||
Position: () => { return call('Position') },
|
||||
Hide: () => call('Hide'),
|
||||
Maximise: () => call('Maximise'),
|
||||
Show: () => call('Show'),
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
(()=>{var w=null;(function(){let o=function(n){let r=window[n.shift()];for(;r&&n.length;)r=r[n.shift()];return r},e=o(["chrome","webview","postMessage"]),t=o(["webkit","messageHandlers","external","postMessage"]);if(!e&&!t){console.error("Unsupported Platform");return}e&&(w=n=>window.chrome.webview.postMessage(n)),t&&(w=n=>window.webkit.messageHandlers.external.postMessage(n))})();function u(o,e){w(e&&e!==-1?"WINDOWID:"+e+":"+o:o)}var s={};function x(){let o=new Uint32Array(1);return window.crypto.getRandomValues(o)[0]}function g(){return Math.random()*9007199254740991}var f;window.crypto?f=x:f=g;function m(o,e,t){t==null&&(t=0);let n=window.wails.window.ID();return new Promise(function(r,i){let l;do l=o+"-"+f();while(s[l]);let a;t>0&&(a=setTimeout(function(){i(Error("Call to "+o+" timed out. Request ID: "+l))},t)),s[l]={timeoutHandle:a,reject:i,resolve:r};try{let d={name:o,args:e,callbackID:l,windowID:n};window.WailsInvoke("C"+JSON.stringify(d))}catch(d){console.error(d)}})}window.ObfuscatedCall=(o,e,t)=>(t==null&&(t=0),new Promise(function(n,r){let i;do i=o+"-"+f();while(s[i]);let l;t>0&&(l=setTimeout(function(){r(Error("Call to method "+o+" timed out. Request ID: "+i))},t)),s[i]={timeoutHandle:l,reject:r,resolve:n};try{let a={id:o,args:e,callbackID:i,windowID:window.wails.window.ID()};window.WailsInvoke("c"+JSON.stringify(a))}catch(a){console.error(a)}}));function h(o){let e;try{e=JSON.parse(o)}catch(r){let i=`Invalid JSON passed to callback: ${r.message}. Message: ${o}`;throw runtime.LogDebug(i),new Error(i)}let t=e.callbackid,n=s[t];if(!n){let r=`Callback '${t}' not registered!!!`;throw console.error(r),new Error(r)}clearTimeout(n.timeoutHandle),delete s[t],e.error?n.reject(e.error):n.resolve(e.result)}var c={};function b(o){let e=o.name;if(c[e]){let t=c[e].slice();for(let n=0;n<c[e].length;n+=1){let r=c[e][n],i=o.data;r.Callback(i)&&t.splice(n,1)}t.length===0?k(e):c[e]=t}}function p(o){let e;try{e=JSON.parse(o)}catch{let n="Invalid JSON passed to Notify: "+o;throw new Error(n)}b(e)}function k(o){delete c[o],window.WailsInvoke("EX"+o)}window.go={};function S(o){try{o=JSON.parse(o)}catch(e){console.error(e)}window.go=window.go||{},Object.keys(o).forEach(e=>{window.go[e]=window.go[e]||{},Object.keys(o[e]).forEach(t=>{window.go[e][t]=window.go[e][t]||{},Object.keys(o[e][t]).forEach(n=>{window.go[e][t][n]=function(){let r=0;function i(){let l=[].slice.call(arguments);return m([e,t,n].join("."),l,r)}return i.setTimeout=function(l){r=l},i.getTimeout=function(){return r},i}()})})})}var v=window.location.origin+"/wails/runtime";function E(o,e){let t=new URL(v);if(t.searchParams.append("method",o),e)for(let n in e)t.searchParams.append(n,e[n]);return new Promise((n,r)=>{fetch(t).then(i=>{if(i.ok)return i.json();r(Error(i.statusText))}).then(i=>n(i)).catch(i=>r(i))})}function y(o){let e=function(t,n){return o!==-1&&(n.windowID=o),E("window."+t,n)};return{Center:()=>e("Center"),SetTitle:t=>e("SetTitle",{title:t}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(t,n)=>e("SetSize",{width:t,height:n}),GetSize:()=>e("GetSize"),SetMaxSize:(t,n)=>e("SetMaxSize",{width:t,height:n}),SetMinSize:(t,n)=>e("SetMinSize",{width:t,height:n}),SetAlwaysOnTop:t=>e("SetAlwaysOnTop",{alwaysOnTop:t}),SetPosition:(t,n)=>e("SetPosition",{x:t,y:n}),GetPosition:()=>e("GetPosition"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(t,n,r,i)=>e("SetBackgroundColour",{R,G,B,A})}}window.wails={Callback:h,callbacks:s,EventsNotify:p,eventListeners:c,SetBindings:S};function O(o){return{Window:y(o),Show:()=>u("S"),Hide:()=>u("H"),Quit:()=>u("Q")}}window.runtime=O(-1);console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
(()=>{var v=Object.defineProperty;var C=(o,e)=>{for(var t in e)v(o,t,{get:e[t],enumerable:!0})};var u=null;(function(){let o=function(n){let r=window[n.shift()];for(;r&&n.length;)r=r[n.shift()];return r},e=o(["chrome","webview","postMessage"]),t=o(["webkit","messageHandlers","external","postMessage"]);if(!e&&!t){console.error("Unsupported Platform");return}e&&(u=n=>window.chrome.webview.postMessage(n)),t&&(u=n=>window.webkit.messageHandlers.external.postMessage(n))})();function w(o,e){u(e&&e!==-1?"WINDOWID:"+e+":"+o:o)}var s={};function E(){let o=new Uint32Array(1);return window.crypto.getRandomValues(o)[0]}function O(){return Math.random()*9007199254740991}var f;window.crypto?f=E:f=O;function h(o,e,t){t==null&&(t=0);let n=window.wails.window.ID();return new Promise(function(r,i){let l;do l=o+"-"+f();while(s[l]);let a;t>0&&(a=setTimeout(function(){i(Error("Call to "+o+" timed out. Request ID: "+l))},t)),s[l]={timeoutHandle:a,reject:i,resolve:r};try{let m={name:o,args:e,callbackID:l,windowID:n};window.WailsInvoke("C"+JSON.stringify(m))}catch(m){console.error(m)}})}window.ObfuscatedCall=(o,e,t)=>(t==null&&(t=0),new Promise(function(n,r){let i;do i=o+"-"+f();while(s[i]);let l;t>0&&(l=setTimeout(function(){r(Error("Call to method "+o+" timed out. Request ID: "+i))},t)),s[i]={timeoutHandle:l,reject:r,resolve:n};try{let a={id:o,args:e,callbackID:i,windowID:window.wails.window.ID()};window.WailsInvoke("c"+JSON.stringify(a))}catch(a){console.error(a)}}));function x(o){let e;try{e=JSON.parse(o)}catch(r){let i=`Invalid JSON passed to callback: ${r.message}. Message: ${o}`;throw runtime.LogDebug(i),new Error(i)}let t=e.callbackid,n=s[t];if(!n){let r=`Callback '${t}' not registered!!!`;throw console.error(r),new Error(r)}clearTimeout(n.timeoutHandle),delete s[t],e.error?n.reject(e.error):n.resolve(e.result)}var c={};function I(o){let e=o.name;if(c[e]){let t=c[e].slice();for(let n=0;n<c[e].length;n+=1){let r=c[e][n],i=o.data;r.Callback(i)&&t.splice(n,1)}t.length===0?M(e):c[e]=t}}function S(o){let e;try{e=JSON.parse(o)}catch{let n="Invalid JSON passed to Notify: "+o;throw new Error(n)}I(e)}function M(o){delete c[o],window.WailsInvoke("EX"+o)}window.go={};function y(o){try{o=JSON.parse(o)}catch(e){console.error(e)}window.go=window.go||{},Object.keys(o).forEach(e=>{window.go[e]=window.go[e]||{},Object.keys(o[e]).forEach(t=>{window.go[e][t]=window.go[e][t]||{},Object.keys(o[e][t]).forEach(n=>{window.go[e][t][n]=function(){let r=0;function i(){let l=[].slice.call(arguments);return h([e,t,n].join("."),l,r)}return i.setTimeout=function(l){r=l},i.getTimeout=function(){return r},i}()})})})}var p={};C(p,{GetText:()=>H,SetText:()=>D});var T=window.location.origin+"/wails/runtime";function b(o,e){let t=new URL(T);if(t.searchParams.append("method",o),e)for(let n in e)t.searchParams.append(n,e[n]);return new Promise((n,r)=>{fetch(t).then(i=>{if(i.ok)return i.headers.get("content-type")&&i.headers.get("content-type").indexOf("application/json")!==-1?i.json():i.text();r(Error(i.statusText))}).then(i=>n(i)).catch(i=>r(i))})}function d(o,e){return!e||e===-1?function(t,n){return b(o+"."+t,n)}:function(t,n){return n=n||{},n.windowID=e,b(o+"."+t,n)}}var g=d("clipboard");function D(o){return g("SetText",{text:o})}function H(){return g("GetText")}function k(o){let e=d("window",o);return{Center:()=>e("Center"),SetTitle:t=>e("SetTitle",{title:t}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(t,n)=>e("SetSize",{width:t,height:n}),Size:()=>e("Size"),SetMaxSize:(t,n)=>e("SetMaxSize",{width:t,height:n}),SetMinSize:(t,n)=>e("SetMinSize",{width:t,height:n}),SetAlwaysOnTop:t=>e("SetAlwaysOnTop",{alwaysOnTop:t}),SetPosition:(t,n)=>e("SetPosition",{x:t,y:n}),Position:()=>e("Position"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(t,n,r,i)=>e("SetBackgroundColour",{R,G,B,A})}}window.wails={Callback:x,callbacks:s,EventsNotify:S,eventListeners:c,SetBindings:y};function U(o){return{Clipboard:{...p},Window:k(o),Show:()=>w("S"),Hide:()=>w("H"),Quit:()=>w("Q")}}window.runtime=U(-1);console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
|
@ -1 +1 @@
|
||||
(()=>{var w=null;(function(){let o=function(n){let r=window[n.shift()];for(;r&&n.length;)r=r[n.shift()];return r},e=o(["chrome","webview","postMessage"]),t=o(["webkit","messageHandlers","external","postMessage"]);if(!e&&!t){console.error("Unsupported Platform");return}e&&(w=n=>window.chrome.webview.postMessage(n)),t&&(w=n=>window.webkit.messageHandlers.external.postMessage(n))})();function u(o,e){w(e&&e!==-1?"WINDOWID:"+e+":"+o:o)}var s={};function x(){let o=new Uint32Array(1);return window.crypto.getRandomValues(o)[0]}function g(){return Math.random()*9007199254740991}var f;window.crypto?f=x:f=g;function m(o,e,t){t==null&&(t=0);let n=window.wails.window.ID();return new Promise(function(r,i){let l;do l=o+"-"+f();while(s[l]);let a;t>0&&(a=setTimeout(function(){i(Error("Call to "+o+" timed out. Request ID: "+l))},t)),s[l]={timeoutHandle:a,reject:i,resolve:r};try{let d={name:o,args:e,callbackID:l,windowID:n};window.WailsInvoke("C"+JSON.stringify(d))}catch(d){console.error(d)}})}window.ObfuscatedCall=(o,e,t)=>(t==null&&(t=0),new Promise(function(n,r){let i;do i=o+"-"+f();while(s[i]);let l;t>0&&(l=setTimeout(function(){r(Error("Call to method "+o+" timed out. Request ID: "+i))},t)),s[i]={timeoutHandle:l,reject:r,resolve:n};try{let a={id:o,args:e,callbackID:i,windowID:window.wails.window.ID()};window.WailsInvoke("c"+JSON.stringify(a))}catch(a){console.error(a)}}));function h(o){let e;try{e=JSON.parse(o)}catch(r){let i=`Invalid JSON passed to callback: ${r.message}. Message: ${o}`;throw runtime.LogDebug(i),new Error(i)}let t=e.callbackid,n=s[t];if(!n){let r=`Callback '${t}' not registered!!!`;throw console.error(r),new Error(r)}clearTimeout(n.timeoutHandle),delete s[t],e.error?n.reject(e.error):n.resolve(e.result)}var c={};function b(o){let e=o.name;if(c[e]){let t=c[e].slice();for(let n=0;n<c[e].length;n+=1){let r=c[e][n],i=o.data;r.Callback(i)&&t.splice(n,1)}t.length===0?k(e):c[e]=t}}function p(o){let e;try{e=JSON.parse(o)}catch{let n="Invalid JSON passed to Notify: "+o;throw new Error(n)}b(e)}function k(o){delete c[o],window.WailsInvoke("EX"+o)}window.go={};function S(o){try{o=JSON.parse(o)}catch(e){console.error(e)}window.go=window.go||{},Object.keys(o).forEach(e=>{window.go[e]=window.go[e]||{},Object.keys(o[e]).forEach(t=>{window.go[e][t]=window.go[e][t]||{},Object.keys(o[e][t]).forEach(n=>{window.go[e][t][n]=function(){let r=0;function i(){let l=[].slice.call(arguments);return m([e,t,n].join("."),l,r)}return i.setTimeout=function(l){r=l},i.getTimeout=function(){return r},i}()})})})}var v=window.location.origin+"/wails/runtime";function E(o,e){let t=new URL(v);if(t.searchParams.append("method",o),e)for(let n in e)t.searchParams.append(n,e[n]);return new Promise((n,r)=>{fetch(t).then(i=>{if(i.ok)return i.json();r(Error(i.statusText))}).then(i=>n(i)).catch(i=>r(i))})}function y(o){let e=function(t,n){return o!==-1&&(n.windowID=o),E("window."+t,n)};return{Center:()=>e("Center"),SetTitle:t=>e("SetTitle",{title:t}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(t,n)=>e("SetSize",{width:t,height:n}),GetSize:()=>e("GetSize"),SetMaxSize:(t,n)=>e("SetMaxSize",{width:t,height:n}),SetMinSize:(t,n)=>e("SetMinSize",{width:t,height:n}),SetAlwaysOnTop:t=>e("SetAlwaysOnTop",{alwaysOnTop:t}),SetPosition:(t,n)=>e("SetPosition",{x:t,y:n}),GetPosition:()=>e("GetPosition"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(t,n,r,i)=>e("SetBackgroundColour",{R,G,B,A})}}window.wails={Callback:h,callbacks:s,EventsNotify:p,eventListeners:c,SetBindings:S};function O(o){return{Window:y(o),Show:()=>u("S"),Hide:()=>u("H"),Quit:()=>u("Q")}}window.runtime=O(-1);console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
(()=>{var v=Object.defineProperty;var C=(o,e)=>{for(var t in e)v(o,t,{get:e[t],enumerable:!0})};var u=null;(function(){let o=function(n){let r=window[n.shift()];for(;r&&n.length;)r=r[n.shift()];return r},e=o(["chrome","webview","postMessage"]),t=o(["webkit","messageHandlers","external","postMessage"]);if(!e&&!t){console.error("Unsupported Platform");return}e&&(u=n=>window.chrome.webview.postMessage(n)),t&&(u=n=>window.webkit.messageHandlers.external.postMessage(n))})();function w(o,e){u(e&&e!==-1?"WINDOWID:"+e+":"+o:o)}var s={};function E(){let o=new Uint32Array(1);return window.crypto.getRandomValues(o)[0]}function O(){return Math.random()*9007199254740991}var f;window.crypto?f=E:f=O;function h(o,e,t){t==null&&(t=0);let n=window.wails.window.ID();return new Promise(function(r,i){let l;do l=o+"-"+f();while(s[l]);let a;t>0&&(a=setTimeout(function(){i(Error("Call to "+o+" timed out. Request ID: "+l))},t)),s[l]={timeoutHandle:a,reject:i,resolve:r};try{let m={name:o,args:e,callbackID:l,windowID:n};window.WailsInvoke("C"+JSON.stringify(m))}catch(m){console.error(m)}})}window.ObfuscatedCall=(o,e,t)=>(t==null&&(t=0),new Promise(function(n,r){let i;do i=o+"-"+f();while(s[i]);let l;t>0&&(l=setTimeout(function(){r(Error("Call to method "+o+" timed out. Request ID: "+i))},t)),s[i]={timeoutHandle:l,reject:r,resolve:n};try{let a={id:o,args:e,callbackID:i,windowID:window.wails.window.ID()};window.WailsInvoke("c"+JSON.stringify(a))}catch(a){console.error(a)}}));function x(o){let e;try{e=JSON.parse(o)}catch(r){let i=`Invalid JSON passed to callback: ${r.message}. Message: ${o}`;throw runtime.LogDebug(i),new Error(i)}let t=e.callbackid,n=s[t];if(!n){let r=`Callback '${t}' not registered!!!`;throw console.error(r),new Error(r)}clearTimeout(n.timeoutHandle),delete s[t],e.error?n.reject(e.error):n.resolve(e.result)}var c={};function I(o){let e=o.name;if(c[e]){let t=c[e].slice();for(let n=0;n<c[e].length;n+=1){let r=c[e][n],i=o.data;r.Callback(i)&&t.splice(n,1)}t.length===0?M(e):c[e]=t}}function S(o){let e;try{e=JSON.parse(o)}catch{let n="Invalid JSON passed to Notify: "+o;throw new Error(n)}I(e)}function M(o){delete c[o],window.WailsInvoke("EX"+o)}window.go={};function y(o){try{o=JSON.parse(o)}catch(e){console.error(e)}window.go=window.go||{},Object.keys(o).forEach(e=>{window.go[e]=window.go[e]||{},Object.keys(o[e]).forEach(t=>{window.go[e][t]=window.go[e][t]||{},Object.keys(o[e][t]).forEach(n=>{window.go[e][t][n]=function(){let r=0;function i(){let l=[].slice.call(arguments);return h([e,t,n].join("."),l,r)}return i.setTimeout=function(l){r=l},i.getTimeout=function(){return r},i}()})})})}var p={};C(p,{GetText:()=>H,SetText:()=>D});var T=window.location.origin+"/wails/runtime";function b(o,e){let t=new URL(T);if(t.searchParams.append("method",o),e)for(let n in e)t.searchParams.append(n,e[n]);return new Promise((n,r)=>{fetch(t).then(i=>{if(i.ok)return i.headers.get("content-type")&&i.headers.get("content-type").indexOf("application/json")!==-1?i.json():i.text();r(Error(i.statusText))}).then(i=>n(i)).catch(i=>r(i))})}function d(o,e){return!e||e===-1?function(t,n){return b(o+"."+t,n)}:function(t,n){return n=n||{},n.windowID=e,b(o+"."+t,n)}}var g=d("clipboard");function D(o){return g("SetText",{text:o})}function H(){return g("GetText")}function k(o){let e=d("window",o);return{Center:()=>e("Center"),SetTitle:t=>e("SetTitle",{title:t}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(t,n)=>e("SetSize",{width:t,height:n}),Size:()=>e("Size"),SetMaxSize:(t,n)=>e("SetMaxSize",{width:t,height:n}),SetMinSize:(t,n)=>e("SetMinSize",{width:t,height:n}),SetAlwaysOnTop:t=>e("SetAlwaysOnTop",{alwaysOnTop:t}),SetPosition:(t,n)=>e("SetPosition",{x:t,y:n}),Position:()=>e("Position"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(t,n,r,i)=>e("SetBackgroundColour",{R,G,B,A})}}window.wails={Callback:x,callbacks:s,EventsNotify:S,eventListeners:c,SetBindings:y};function U(o){return{Clipboard:{...p},Window:k(o),Show:()=>w("S"),Hide:()=>w("H"),Quit:()=>w("Q")}}window.runtime=U(-1);console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
|
@ -1 +1 @@
|
||||
(()=>{var w=null;(function(){let o=function(n){let r=window[n.shift()];for(;r&&n.length;)r=r[n.shift()];return r},e=o(["chrome","webview","postMessage"]),t=o(["webkit","messageHandlers","external","postMessage"]);if(!e&&!t){console.error("Unsupported Platform");return}e&&(w=n=>window.chrome.webview.postMessage(n)),t&&(w=n=>window.webkit.messageHandlers.external.postMessage(n))})();function u(o,e){w(e&&e!==-1?"WINDOWID:"+e+":"+o:o)}var s={};function x(){let o=new Uint32Array(1);return window.crypto.getRandomValues(o)[0]}function g(){return Math.random()*9007199254740991}var f;window.crypto?f=x:f=g;function m(o,e,t){t==null&&(t=0);let n=window.wails.window.ID();return new Promise(function(r,i){let l;do l=o+"-"+f();while(s[l]);let a;t>0&&(a=setTimeout(function(){i(Error("Call to "+o+" timed out. Request ID: "+l))},t)),s[l]={timeoutHandle:a,reject:i,resolve:r};try{let d={name:o,args:e,callbackID:l,windowID:n};window.WailsInvoke("C"+JSON.stringify(d))}catch(d){console.error(d)}})}window.ObfuscatedCall=(o,e,t)=>(t==null&&(t=0),new Promise(function(n,r){let i;do i=o+"-"+f();while(s[i]);let l;t>0&&(l=setTimeout(function(){r(Error("Call to method "+o+" timed out. Request ID: "+i))},t)),s[i]={timeoutHandle:l,reject:r,resolve:n};try{let a={id:o,args:e,callbackID:i,windowID:window.wails.window.ID()};window.WailsInvoke("c"+JSON.stringify(a))}catch(a){console.error(a)}}));function h(o){let e;try{e=JSON.parse(o)}catch(r){let i=`Invalid JSON passed to callback: ${r.message}. Message: ${o}`;throw runtime.LogDebug(i),new Error(i)}let t=e.callbackid,n=s[t];if(!n){let r=`Callback '${t}' not registered!!!`;throw console.error(r),new Error(r)}clearTimeout(n.timeoutHandle),delete s[t],e.error?n.reject(e.error):n.resolve(e.result)}var c={};function b(o){let e=o.name;if(c[e]){let t=c[e].slice();for(let n=0;n<c[e].length;n+=1){let r=c[e][n],i=o.data;r.Callback(i)&&t.splice(n,1)}t.length===0?k(e):c[e]=t}}function p(o){let e;try{e=JSON.parse(o)}catch{let n="Invalid JSON passed to Notify: "+o;throw new Error(n)}b(e)}function k(o){delete c[o],window.WailsInvoke("EX"+o)}window.go={};function S(o){try{o=JSON.parse(o)}catch(e){console.error(e)}window.go=window.go||{},Object.keys(o).forEach(e=>{window.go[e]=window.go[e]||{},Object.keys(o[e]).forEach(t=>{window.go[e][t]=window.go[e][t]||{},Object.keys(o[e][t]).forEach(n=>{window.go[e][t][n]=function(){let r=0;function i(){let l=[].slice.call(arguments);return m([e,t,n].join("."),l,r)}return i.setTimeout=function(l){r=l},i.getTimeout=function(){return r},i}()})})})}var v=window.location.origin+"/wails/runtime";function E(o,e){let t=new URL(v);if(t.searchParams.append("method",o),e)for(let n in e)t.searchParams.append(n,e[n]);return new Promise((n,r)=>{fetch(t).then(i=>{if(i.ok)return i.json();r(Error(i.statusText))}).then(i=>n(i)).catch(i=>r(i))})}function y(o){let e=function(t,n){return o!==-1&&(n.windowID=o),E("window."+t,n)};return{Center:()=>e("Center"),SetTitle:t=>e("SetTitle",{title:t}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(t,n)=>e("SetSize",{width:t,height:n}),GetSize:()=>e("GetSize"),SetMaxSize:(t,n)=>e("SetMaxSize",{width:t,height:n}),SetMinSize:(t,n)=>e("SetMinSize",{width:t,height:n}),SetAlwaysOnTop:t=>e("SetAlwaysOnTop",{alwaysOnTop:t}),SetPosition:(t,n)=>e("SetPosition",{x:t,y:n}),GetPosition:()=>e("GetPosition"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(t,n,r,i)=>e("SetBackgroundColour",{R,G,B,A})}}window.wails={Callback:h,callbacks:s,EventsNotify:p,eventListeners:c,SetBindings:S};function O(o){return{Window:y(o),Show:()=>u("S"),Hide:()=>u("H"),Quit:()=>u("Q")}}window.runtime=O(-1);console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
(()=>{var v=Object.defineProperty;var C=(o,e)=>{for(var t in e)v(o,t,{get:e[t],enumerable:!0})};var u=null;(function(){let o=function(n){let r=window[n.shift()];for(;r&&n.length;)r=r[n.shift()];return r},e=o(["chrome","webview","postMessage"]),t=o(["webkit","messageHandlers","external","postMessage"]);if(!e&&!t){console.error("Unsupported Platform");return}e&&(u=n=>window.chrome.webview.postMessage(n)),t&&(u=n=>window.webkit.messageHandlers.external.postMessage(n))})();function w(o,e){u(e&&e!==-1?"WINDOWID:"+e+":"+o:o)}var s={};function E(){let o=new Uint32Array(1);return window.crypto.getRandomValues(o)[0]}function O(){return Math.random()*9007199254740991}var f;window.crypto?f=E:f=O;function h(o,e,t){t==null&&(t=0);let n=window.wails.window.ID();return new Promise(function(r,i){let l;do l=o+"-"+f();while(s[l]);let a;t>0&&(a=setTimeout(function(){i(Error("Call to "+o+" timed out. Request ID: "+l))},t)),s[l]={timeoutHandle:a,reject:i,resolve:r};try{let m={name:o,args:e,callbackID:l,windowID:n};window.WailsInvoke("C"+JSON.stringify(m))}catch(m){console.error(m)}})}window.ObfuscatedCall=(o,e,t)=>(t==null&&(t=0),new Promise(function(n,r){let i;do i=o+"-"+f();while(s[i]);let l;t>0&&(l=setTimeout(function(){r(Error("Call to method "+o+" timed out. Request ID: "+i))},t)),s[i]={timeoutHandle:l,reject:r,resolve:n};try{let a={id:o,args:e,callbackID:i,windowID:window.wails.window.ID()};window.WailsInvoke("c"+JSON.stringify(a))}catch(a){console.error(a)}}));function x(o){let e;try{e=JSON.parse(o)}catch(r){let i=`Invalid JSON passed to callback: ${r.message}. Message: ${o}`;throw runtime.LogDebug(i),new Error(i)}let t=e.callbackid,n=s[t];if(!n){let r=`Callback '${t}' not registered!!!`;throw console.error(r),new Error(r)}clearTimeout(n.timeoutHandle),delete s[t],e.error?n.reject(e.error):n.resolve(e.result)}var c={};function I(o){let e=o.name;if(c[e]){let t=c[e].slice();for(let n=0;n<c[e].length;n+=1){let r=c[e][n],i=o.data;r.Callback(i)&&t.splice(n,1)}t.length===0?M(e):c[e]=t}}function S(o){let e;try{e=JSON.parse(o)}catch{let n="Invalid JSON passed to Notify: "+o;throw new Error(n)}I(e)}function M(o){delete c[o],window.WailsInvoke("EX"+o)}window.go={};function y(o){try{o=JSON.parse(o)}catch(e){console.error(e)}window.go=window.go||{},Object.keys(o).forEach(e=>{window.go[e]=window.go[e]||{},Object.keys(o[e]).forEach(t=>{window.go[e][t]=window.go[e][t]||{},Object.keys(o[e][t]).forEach(n=>{window.go[e][t][n]=function(){let r=0;function i(){let l=[].slice.call(arguments);return h([e,t,n].join("."),l,r)}return i.setTimeout=function(l){r=l},i.getTimeout=function(){return r},i}()})})})}var p={};C(p,{GetText:()=>H,SetText:()=>D});var T=window.location.origin+"/wails/runtime";function b(o,e){let t=new URL(T);if(t.searchParams.append("method",o),e)for(let n in e)t.searchParams.append(n,e[n]);return new Promise((n,r)=>{fetch(t).then(i=>{if(i.ok)return i.headers.get("content-type")&&i.headers.get("content-type").indexOf("application/json")!==-1?i.json():i.text();r(Error(i.statusText))}).then(i=>n(i)).catch(i=>r(i))})}function d(o,e){return!e||e===-1?function(t,n){return b(o+"."+t,n)}:function(t,n){return n=n||{},n.windowID=e,b(o+"."+t,n)}}var g=d("clipboard");function D(o){return g("SetText",{text:o})}function H(){return g("GetText")}function k(o){let e=d("window",o);return{Center:()=>e("Center"),SetTitle:t=>e("SetTitle",{title:t}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(t,n)=>e("SetSize",{width:t,height:n}),Size:()=>e("Size"),SetMaxSize:(t,n)=>e("SetMaxSize",{width:t,height:n}),SetMinSize:(t,n)=>e("SetMinSize",{width:t,height:n}),SetAlwaysOnTop:t=>e("SetAlwaysOnTop",{alwaysOnTop:t}),SetPosition:(t,n)=>e("SetPosition",{x:t,y:n}),Position:()=>e("Position"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(t,n,r,i)=>e("SetBackgroundColour",{R,G,B,A})}}window.wails={Callback:x,callbacks:s,EventsNotify:S,eventListeners:c,SetBindings:y};function U(o){return{Clipboard:{...p},Window:k(o),Show:()=>w("S"),Hide:()=>w("H"),Quit:()=>w("Q")}}window.runtime=U(-1);console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
|
@ -25,7 +25,6 @@ func (m *MessageProcessor) httpError(rw http.ResponseWriter, message string, arg
|
||||
}
|
||||
|
||||
func (m *MessageProcessor) HandleRuntimeCall(rw http.ResponseWriter, r *http.Request) {
|
||||
m.Info("Processing runtime call")
|
||||
// Read "method" from query string
|
||||
method := r.URL.Query().Get("method")
|
||||
if method == "" {
|
||||
@ -42,9 +41,24 @@ func (m *MessageProcessor) HandleRuntimeCall(rw http.ResponseWriter, r *http.Req
|
||||
// Get the method
|
||||
method = splitMethod[1]
|
||||
|
||||
params := QueryParams(r.URL.Query())
|
||||
|
||||
var targetWindow = m.window
|
||||
windowID := params.UInt("windowID")
|
||||
if windowID != nil {
|
||||
// Get window for ID
|
||||
targetWindow = globalApplication.getWindowForID(*windowID)
|
||||
if targetWindow == nil {
|
||||
m.Error("Window ID %s not found", *windowID)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
switch object {
|
||||
case "window":
|
||||
m.processWindowMethod(method, rw, r)
|
||||
m.processWindowMethod(method, rw, r, targetWindow, params)
|
||||
case "clipboard":
|
||||
m.processClipboardMethod(method, rw, r, targetWindow, params)
|
||||
default:
|
||||
m.httpError(rw, "Unknown runtime call: %s", object)
|
||||
}
|
||||
@ -79,6 +93,20 @@ func (m *MessageProcessor) json(rw http.ResponseWriter, data any) {
|
||||
m.Error("Unable to write json payload. Please report this to the Wails team! Error: %s", err)
|
||||
return
|
||||
}
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
m.ok(rw)
|
||||
}
|
||||
|
||||
func (m *MessageProcessor) text(rw http.ResponseWriter, data string) {
|
||||
_, err := rw.Write([]byte(data))
|
||||
if err != nil {
|
||||
m.Error("Unable to write json payload. Please report this to the Wails team! Error: %s", err)
|
||||
return
|
||||
}
|
||||
rw.Header().Set("Content-Type", "text/plain")
|
||||
m.ok(rw)
|
||||
}
|
||||
|
||||
func (m *MessageProcessor) ok(rw http.ResponseWriter) {
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
25
v3/pkg/application/messageprocessor_clipboard.go
Normal file
25
v3/pkg/application/messageprocessor_clipboard.go
Normal file
@ -0,0 +1,25 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (m *MessageProcessor) processClipboardMethod(method string, rw http.ResponseWriter, r *http.Request, window *WebviewWindow, params QueryParams) {
|
||||
|
||||
switch method {
|
||||
case "SetText":
|
||||
title := params.String("text")
|
||||
if title == nil {
|
||||
m.Error("SetText: text is required")
|
||||
return
|
||||
}
|
||||
globalApplication.Clipboard().SetText(*title)
|
||||
m.ok(rw)
|
||||
case "GetText":
|
||||
text := globalApplication.Clipboard().Text()
|
||||
m.text(rw, text)
|
||||
default:
|
||||
m.httpError(rw, "Unknown clipboard method: %s", method)
|
||||
}
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package application
|
||||
|
||||
//
|
||||
//import "errors"
|
||||
//
|
||||
////var logLevelMap = map[byte]logger.LogLevel{
|
||||
//// '1': pkgLogger.TRACE,
|
||||
//// '2': pkgLogger.DEBUG,
|
||||
//// '3': pkgLogger.INFO,
|
||||
//// '4': pkgLogger.WARNING,
|
||||
//// '5': pkgLogger.ERROR,
|
||||
////}
|
||||
//
|
||||
//func (m *MessageProcessor) processLogMessage(message string) {
|
||||
// if len(message) < 3 {
|
||||
// m.Error("Invalid Log Message: " + message)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// messageText := message[2:]
|
||||
//
|
||||
// switch message[1] {
|
||||
// case 'T':
|
||||
// d.log.Trace(messageText)
|
||||
// case 'P':
|
||||
// d.log.Print(messageText)
|
||||
// case 'D':
|
||||
// d.log.Debug(messageText)
|
||||
// case 'I':
|
||||
// d.log.Info(messageText)
|
||||
// case 'W':
|
||||
// d.log.Warning(messageText)
|
||||
// case 'E':
|
||||
// d.log.Error(messageText)
|
||||
// case 'F':
|
||||
// d.log.Fatal(messageText)
|
||||
// case 'S':
|
||||
// loglevel, exists := logLevelMap[message[2]]
|
||||
// if !exists {
|
||||
// return "", errors.New("Invalid Set Log Level Message: " + message)
|
||||
// }
|
||||
// d.log.SetLogLevel(loglevel)
|
||||
// default:
|
||||
// return "", errors.New("Invalid Log Message: " + message)
|
||||
// }
|
||||
// return "", nil
|
||||
//}
|
@ -6,20 +6,7 @@ import (
|
||||
"github.com/wailsapp/wails/v3/pkg/options"
|
||||
)
|
||||
|
||||
func (m *MessageProcessor) processWindowMethod(method string, rw http.ResponseWriter, r *http.Request) {
|
||||
|
||||
params := QueryParams(r.URL.Query())
|
||||
|
||||
var targetWindow = m.window
|
||||
windowID := params.UInt("windowID")
|
||||
if windowID != nil {
|
||||
// Get window for ID
|
||||
targetWindow = globalApplication.getWindowForID(*windowID)
|
||||
if targetWindow == nil {
|
||||
m.Error("Window ID %s not found", *windowID)
|
||||
return
|
||||
}
|
||||
}
|
||||
func (m *MessageProcessor) processWindowMethod(method string, rw http.ResponseWriter, r *http.Request, window *WebviewWindow, params QueryParams) {
|
||||
|
||||
switch method {
|
||||
case "SetTitle":
|
||||
@ -28,8 +15,8 @@ func (m *MessageProcessor) processWindowMethod(method string, rw http.ResponseWr
|
||||
m.Error("SetTitle: title is required")
|
||||
return
|
||||
}
|
||||
targetWindow.SetTitle(*title)
|
||||
m.json(rw, nil)
|
||||
window.SetTitle(*title)
|
||||
m.ok(rw)
|
||||
case "SetSize":
|
||||
width := params.Int("width")
|
||||
height := params.Int("height")
|
||||
@ -37,8 +24,8 @@ func (m *MessageProcessor) processWindowMethod(method string, rw http.ResponseWr
|
||||
m.Error("Invalid SetSize message")
|
||||
return
|
||||
}
|
||||
targetWindow.SetSize(*width, *height)
|
||||
m.json(rw, nil)
|
||||
window.SetSize(*width, *height)
|
||||
m.ok(rw)
|
||||
case "SetPosition":
|
||||
x := params.Int("x")
|
||||
y := params.Int("y")
|
||||
@ -46,46 +33,46 @@ func (m *MessageProcessor) processWindowMethod(method string, rw http.ResponseWr
|
||||
m.Error("Invalid SetPosition message")
|
||||
return
|
||||
}
|
||||
targetWindow.SetPosition(*x, *y)
|
||||
m.json(rw, nil)
|
||||
window.SetPosition(*x, *y)
|
||||
m.ok(rw)
|
||||
case "Fullscreen":
|
||||
targetWindow.Fullscreen()
|
||||
m.json(rw, nil)
|
||||
window.Fullscreen()
|
||||
m.ok(rw)
|
||||
case "UnFullscreen":
|
||||
targetWindow.UnFullscreen()
|
||||
m.json(rw, nil)
|
||||
window.UnFullscreen()
|
||||
m.ok(rw)
|
||||
case "Minimise":
|
||||
targetWindow.Minimize()
|
||||
m.json(rw, nil)
|
||||
window.Minimize()
|
||||
m.ok(rw)
|
||||
case "UnMinimise":
|
||||
targetWindow.UnMinimise()
|
||||
m.json(rw, nil)
|
||||
window.UnMinimise()
|
||||
m.ok(rw)
|
||||
case "Maximise":
|
||||
targetWindow.Maximise()
|
||||
m.json(rw, nil)
|
||||
window.Maximise()
|
||||
m.ok(rw)
|
||||
case "UnMaximise":
|
||||
targetWindow.UnMaximise()
|
||||
m.json(rw, nil)
|
||||
window.UnMaximise()
|
||||
m.ok(rw)
|
||||
case "Show":
|
||||
targetWindow.Show()
|
||||
m.json(rw, nil)
|
||||
window.Show()
|
||||
m.ok(rw)
|
||||
case "Hide":
|
||||
targetWindow.Hide()
|
||||
m.json(rw, nil)
|
||||
window.Hide()
|
||||
m.ok(rw)
|
||||
case "Close":
|
||||
targetWindow.Close()
|
||||
m.json(rw, nil)
|
||||
window.Close()
|
||||
m.ok(rw)
|
||||
case "Center":
|
||||
targetWindow.Center()
|
||||
m.json(rw, nil)
|
||||
window.Center()
|
||||
m.ok(rw)
|
||||
case "Size":
|
||||
width, height := targetWindow.Size()
|
||||
width, height := window.Size()
|
||||
m.json(rw, map[string]interface{}{
|
||||
"width": width,
|
||||
"height": height,
|
||||
})
|
||||
case "Position":
|
||||
x, y := targetWindow.Position()
|
||||
x, y := window.Position()
|
||||
m.json(rw, map[string]interface{}{
|
||||
"x": x,
|
||||
"y": y,
|
||||
@ -111,29 +98,29 @@ func (m *MessageProcessor) processWindowMethod(method string, rw http.ResponseWr
|
||||
m.Error("Invalid SetBackgroundColour message: 'a' value required")
|
||||
return
|
||||
}
|
||||
targetWindow.SetBackgroundColour(&options.RGBA{
|
||||
window.SetBackgroundColour(&options.RGBA{
|
||||
Red: *r,
|
||||
Green: *g,
|
||||
Blue: *b,
|
||||
Alpha: *a,
|
||||
})
|
||||
m.json(rw, nil)
|
||||
m.ok(rw)
|
||||
case "SetAlwaysOnTop":
|
||||
alwaysOnTop := params.Bool("alwaysOnTop")
|
||||
if alwaysOnTop == nil {
|
||||
m.Error("Invalid SetAlwaysOnTop message: 'alwaysOnTop' value required")
|
||||
return
|
||||
}
|
||||
targetWindow.SetAlwaysOnTop(*alwaysOnTop)
|
||||
m.json(rw, nil)
|
||||
window.SetAlwaysOnTop(*alwaysOnTop)
|
||||
m.ok(rw)
|
||||
case "SetResizable":
|
||||
resizable := params.Bool("resizable")
|
||||
if resizable == nil {
|
||||
m.Error("Invalid SetResizable message: 'resizable' value required")
|
||||
return
|
||||
}
|
||||
targetWindow.SetResizable(*resizable)
|
||||
m.json(rw, nil)
|
||||
window.SetResizable(*resizable)
|
||||
m.ok(rw)
|
||||
case "SetMinSize":
|
||||
width := params.Int("width")
|
||||
height := params.Int("height")
|
||||
@ -141,8 +128,8 @@ func (m *MessageProcessor) processWindowMethod(method string, rw http.ResponseWr
|
||||
m.Error("Invalid SetMinSize message")
|
||||
return
|
||||
}
|
||||
targetWindow.SetMinSize(*width, *height)
|
||||
m.json(rw, nil)
|
||||
window.SetMinSize(*width, *height)
|
||||
m.ok(rw)
|
||||
case "SetMaxSize":
|
||||
width := params.Int("width")
|
||||
height := params.Int("height")
|
||||
@ -150,29 +137,29 @@ func (m *MessageProcessor) processWindowMethod(method string, rw http.ResponseWr
|
||||
m.Error("Invalid SetMaxSize message")
|
||||
return
|
||||
}
|
||||
targetWindow.SetMaxSize(*width, *height)
|
||||
m.json(rw, nil)
|
||||
window.SetMaxSize(*width, *height)
|
||||
m.ok(rw)
|
||||
case "Width":
|
||||
width := targetWindow.Width()
|
||||
width := window.Width()
|
||||
m.json(rw, map[string]interface{}{
|
||||
"width": width,
|
||||
})
|
||||
case "Height":
|
||||
height := targetWindow.Height()
|
||||
height := window.Height()
|
||||
m.json(rw, map[string]interface{}{
|
||||
"height": height,
|
||||
})
|
||||
case "ZoomIn":
|
||||
targetWindow.ZoomIn()
|
||||
m.json(rw, nil)
|
||||
window.ZoomIn()
|
||||
m.ok(rw)
|
||||
case "ZoomOut":
|
||||
targetWindow.ZoomOut()
|
||||
m.json(rw, nil)
|
||||
window.ZoomOut()
|
||||
m.ok(rw)
|
||||
case "ZoomReset":
|
||||
targetWindow.ZoomReset()
|
||||
m.json(rw, nil)
|
||||
window.ZoomReset()
|
||||
m.ok(rw)
|
||||
case "GetZoom":
|
||||
zoomLevel := targetWindow.GetZoom()
|
||||
zoomLevel := window.GetZoom()
|
||||
m.json(rw, map[string]interface{}{
|
||||
"zoomLevel": zoomLevel,
|
||||
})
|
||||
@ -182,8 +169,8 @@ func (m *MessageProcessor) processWindowMethod(method string, rw http.ResponseWr
|
||||
m.Error("Invalid SetZoom message: invalid 'zoomLevel' value")
|
||||
return
|
||||
}
|
||||
targetWindow.SetZoom(*zoomLevel)
|
||||
m.json(rw, nil)
|
||||
window.SetZoom(*zoomLevel)
|
||||
m.ok(rw)
|
||||
default:
|
||||
m.httpError(rw, "Unknown window method: %s", method)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user