5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 00:41:59 +08:00

[v2] Support Window runtime in JS

This commit is contained in:
Lea Anthony 2021-09-09 20:10:18 +10:00
parent 414b0149f2
commit cae9827841
13 changed files with 618 additions and 28 deletions

View File

@ -3,6 +3,8 @@ package dispatcher
import (
"encoding/json"
"fmt"
"github.com/wailsapp/wails/v2/internal/frontend"
"strings"
)
type callMessage struct {
@ -11,29 +13,38 @@ type callMessage struct {
CallbackID string `json:"callbackID"`
}
func (d *Dispatcher) processCallMessage(message string) (string, error) {
func (d *Dispatcher) processCallMessage(message string, sender frontend.Frontend) (string, error) {
var payload callMessage
err := json.Unmarshal([]byte(message[1:]), &payload)
if err != nil {
return "", err
}
// Lookup method
registeredMethod := d.bindingsDB.GetMethod(payload.Name)
// Check we have it
if registeredMethod == nil {
return "", fmt.Errorf("method '%s' not registered", payload.Name)
var result interface{}
// Handle different calls
switch true {
case strings.HasPrefix(payload.Name, systemCallPrefix):
result, err = d.processSystemCall(payload, sender)
default:
// Lookup method
registeredMethod := d.bindingsDB.GetMethod(payload.Name)
// Check we have it
if registeredMethod == nil {
return "", fmt.Errorf("method '%s' not registered", payload.Name)
}
args, err2 := registeredMethod.ParseArgs(payload.Args)
if err2 != nil {
errmsg := fmt.Errorf("error parsing arguments: %s", err2.Error())
result, _ := d.NewErrorCallback(errmsg.Error(), payload.CallbackID)
return result, errmsg
}
result, err = registeredMethod.Call(args)
}
args, err := registeredMethod.ParseArgs(payload.Args)
if err != nil {
errmsg := fmt.Errorf("error parsing arguments: %s", err.Error())
result, _ := d.NewErrorCallback(errmsg.Error(), payload.CallbackID)
return result, errmsg
}
result, err := registeredMethod.Call(args)
callbackMessage := &CallbackMessage{
CallbackID: payload.CallbackID,
}

View File

@ -33,7 +33,9 @@ func (d *Dispatcher) ProcessMessage(message string, sender frontend.Frontend) (s
case 'E':
return d.processEventMessage(message, sender)
case 'C':
return d.processCallMessage(message)
return d.processCallMessage(message, sender)
case 'W':
return d.processWindowMessage(message, sender)
default:
return "", errors.New("Unknown message from front end: " + message)
}

View File

@ -0,0 +1,37 @@
package dispatcher
import (
"fmt"
"github.com/wailsapp/wails/v2/internal/frontend"
"strings"
)
const systemCallPrefix = ":wails:"
type position struct {
X int `json:"x"`
Y int `json:"y"`
}
type size struct {
W int `json:"w"`
H int `json:"h"`
}
func (d *Dispatcher) processSystemCall(payload callMessage, sender frontend.Frontend) (interface{}, error) {
// Strip prefix
name := strings.TrimPrefix(payload.Name, systemCallPrefix)
switch name {
case "WindowGetPos":
x, y := sender.WindowGetPos()
return &position{x, y}, nil
case "WindowGetSize":
w, h := sender.WindowGetSize()
return &position{w, h}, nil
default:
return nil, fmt.Errorf("unknown systemcall message: %s", payload.Name)
}
}

View File

@ -0,0 +1,72 @@
package dispatcher
import (
"errors"
"github.com/wailsapp/wails/v2/internal/frontend"
"strconv"
"strings"
)
func (d *Dispatcher) mustAtoI(input string) int {
result, err := strconv.Atoi(input)
if err != nil {
d.log.Error("cannot convert %s to integer!", input)
}
return result
}
func (d *Dispatcher) processWindowMessage(message string, sender frontend.Frontend) (string, error) {
if len(message) < 2 {
return "", errors.New("Invalid Event Message: " + message)
}
switch message[1] {
case 'c':
go sender.WindowCenter()
case 'T':
title := message[2:]
go sender.WindowSetTitle(title)
case 'F':
go sender.WindowFullscreen()
case 'f':
go sender.WindowUnFullscreen()
case 's':
parts := strings.Split(message[3:], ":")
w := d.mustAtoI(parts[0])
h := d.mustAtoI(parts[1])
go sender.WindowSetSize(w, h)
case 'p':
parts := strings.Split(message[3:], ":")
x := d.mustAtoI(parts[0])
y := d.mustAtoI(parts[1])
go sender.WindowSetPos(x, y)
case 'H':
go sender.WindowHide()
case 'S':
go sender.WindowShow()
case 'M':
go sender.WindowMaximise()
case 'U':
go sender.WindowUnmaximise()
case 'm':
go sender.WindowMinimise()
case 'u':
go sender.WindowUnminimise()
case 'Z':
parts := strings.Split(message[3:], ":")
w := d.mustAtoI(parts[0])
h := d.mustAtoI(parts[1])
go sender.WindowSetMaxSize(w, h)
case 'z':
parts := strings.Split(message[3:], ":")
w := d.mustAtoI(parts[0])
h := d.mustAtoI(parts[1])
go sender.WindowSetMinSize(w, h)
case 'C':
sender.Quit()
default:
d.log.Error("unknown Window message: %s", message)
}
return "", nil
}

View File

@ -11,6 +11,7 @@ The electron alternative for Go
import {Call} from './calls';
// This is where we bind go method wrappers
window.go = {};
export function SetBindings(bindingsMap) {

View File

@ -50,7 +50,7 @@ if (window.crypto) {
*
* @export
* @param {string} name
* @param {string} args
* @param {any=} args
* @param {number=} timeout
* @returns
*/

View File

@ -12,22 +12,20 @@ import * as Log from './log';
import {eventListeners, EventsEmit, EventsNotify, EventsOff, EventsOn, EventsOnce, EventsOnMultiple} from './events';
import {Callback, callbacks} from './calls';
import {SetBindings} from "./bindings";
import {WindowReload} from "./window";
// Backend is where the Go struct wrappers get bound to
window.backend = {};
import * as Window from "./window";
// The JS runtime
window.runtime = {
...Log,
...Window,
EventsOn,
EventsOnce,
EventsOnMultiple,
EventsEmit,
EventsOff,
WindowReload,
};
// Initialise global if not already
// Internal wails endpoints
window.wails = {
Callback,
EventsNotify,
@ -36,6 +34,7 @@ window.wails = {
callbacks
};
// Set the bindings
window.wails.SetBindings(window.wailsbindings);
delete window.wails.SetBindings;

View File

@ -10,6 +10,174 @@ The electron alternative for Go
/* jshint esversion: 9 */
import {Call} from "./calls";
export function WindowReload() {
window.location.reload();
}
/**
* Place the window in the center of the screen
*
* @export
*/
export function WindowCenter() {
window.WailsInvoke('Wc');
}
/**
* Sets the window title
*
* @param {string} title
* @export
*/
export function WindowSetTitle(title) {
window.WailsInvoke('WT' + title);
}
/**
* Makes the window go fullscreen
*
* @export
*/
export function WindowFullscreen() {
window.WailsInvoke('WF');
}
/**
* Reverts the window from fullscreen
*
* @export
*/
export function WindowUnFullscreen() {
window.WailsInvoke('Wf');
}
/**
* Set the Size of the window
*
* @export
* @param {number} width
* @param {number} height
*/
export function WindowSetSize(width, height) {
window.WailsInvoke('Ws:' + width + ':' + height);
}
/**
* Get the Size of the window
*
* @export
* @return {Promise<{w: number, h: number}>} The size of the window
*/
export function WindowGetSize() {
return Call(":wails:WindowGetSize");
}
/**
* Set the maximum size of the window
*
* @export
* @param {number} width
* @param {number} height
*/
export function WindowSetMaxSize(width, height) {
window.WailsInvoke('WZ:' + width + ':' + height);
}
/**
* Set the minimum size of the window
*
* @export
* @param {number} width
* @param {number} height
*/
export function WindowSetMinSize(width, height) {
window.WailsInvoke('Wz:' + width + ':' + height);
}
/**
* Set the Position of the window
*
* @export
* @param {number} x
* @param {number} y
*/
export function WindowSetPosition(x, y) {
window.WailsInvoke('Wp:' + x + ':' + y);
}
/**
* Get the Position of the window
*
* @export
* @return {Promise<{x: number, y: number}>} The position of the window
*/
export function WindowGetPosition() {
return Call(":wails:WindowGetPos");
}
/**
* Hide the Window
*
* @export
*/
export function WindowHide() {
window.WailsInvoke('WH');
}
/**
* Show the Window
*
* @export
*/
export function WindowShow() {
window.WailsInvoke('WS');
}
/**
* Maximise the Window
*
* @export
*/
export function WindowMaximise() {
window.WailsInvoke('WM');
}
/**
* Unmaximise the Window
*
* @export
*/
export function WindowUnmaximise() {
window.WailsInvoke('WU');
}
/**
* Minimise the Window
*
* @export
*/
export function WindowMinimise() {
window.WailsInvoke('Wm');
}
/**
* Unminimise the Window
*
* @export
*/
export function WindowUnminimise() {
window.WailsInvoke('Wu');
}
/**
* Close the Window
*
* @export
*/
export function WindowClose() {
window.WailsInvoke('WC');
}

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(()=>{var p=Object.defineProperty;var S=o=>p(o,"__esModule",{value:!0});var k=(o,n)=>{S(o);for(var t in n)p(o,t,{get:n[t],enumerable:!0})};var f={};k(f,{LogDebug:()=>D,LogError:()=>C,LogFatal:()=>j,LogInfo:()=>J,LogLevel:()=>B,LogPrint:()=>W,LogTrace:()=>R,LogWarning:()=>T,SetLogLevel:()=>A});function l(o,n){window.WailsInvoke("L"+o+n)}function R(o){l("T",o)}function W(o){l("P",o)}function D(o){l("D",o)}function J(o){l("I",o)}function T(o){l("W",o)}function C(o){l("E",o)}function j(o){l("F",o)}function A(o){l("S",o)}var B={TRACE:1,DEBUG:2,INFO:3,WARNING:4,ERROR:5};var g=class{constructor(n,t){t=t||-1,this.Callback=e=>(n.apply(null,e),t===-1?!1:(t-=1,t===0))}},s={};function w(o,n,t){s[o]=s[o]||[];let e=new g(n,t);s[o].push(e)}function E(o,n){w(o,n,-1)}function v(o,n){w(o,n,1)}function y(o){let n=o.name;if(s[n]){let t=s[n].slice();for(let e=0;e<s[n].length;e+=1){let i=s[n][e],r=o.data;i.Callback(r)&&t.splice(e,1)}s[n]=t}}function L(o){let n;try{n=JSON.parse(o)}catch(t){let e="Invalid JSON passed to Notify: "+o;throw new Error(e)}y(n)}function O(o){let n={name:o,data:[].slice.apply(arguments).slice(1)};y(n),window.WailsInvoke("EE"+JSON.stringify(n))}function b(o){s.delete(o),window.WailsInvoke("EX"+o)}var a={};function F(){var o=new Uint32Array(1);return window.crypto.getRandomValues(o)[0]}function H(){return Math.random()*9007199254740991}var u;window.crypto?u=F:u=H;function h(o,n,t){return t==null&&(t=0),new Promise(function(e,i){var r;do r=o+"-"+u();while(a[r]);var c;t>0&&(c=setTimeout(function(){i(Error("Call to "+o+" timed out. Request ID: "+r))},t)),a[r]={timeoutHandle:c,reject:i,resolve:e};try{let d={name:o,args:n,callbackID:r};window.WailsInvoke("C"+JSON.stringify(d))}catch(d){console.error(d)}})}function x(o){var n;try{n=JSON.parse(o)}catch(i){let r=`Invalid JSON passed to callback: ${i.message}. Message: ${o}`;throw wails.LogDebug(r),new Error(r)}var t=n.callbackid,e=a[t];if(!e){let i=`Callback '${t}' not registered!!!`;throw console.error(i),new Error(i)}clearTimeout(e.timeoutHandle),delete a[t],n.error?e.reject(n.error):e.resolve(n.result)}window.go={};function m(o){try{o=JSON.parse(o)}catch(n){console.error(n)}window.go=window.go||{},Object.keys(o).forEach(n=>{window.go[n]=window.go[n]||{},Object.keys(o[n]).forEach(t=>{window.go[n][t]=window.go[n][t]||{},Object.keys(o[n][t]).forEach(e=>{window.go[n][t][e]=function(){let i=0;function r(){let c=[].slice.call(arguments);return h([n,t,e].join("."),c,i)}return r.setTimeout=function(c){i=c},r.getTimeout=function(){return i},r}()})})})}function I(){window.location.reload()}window.backend={};window.runtime={...f,EventsOn:E,EventsOnce:v,EventsOnMultiple:w,EventsEmit:O,EventsOff:b,WindowReload:I};window.wails={Callback:x,EventsNotify:L,SetBindings:m,eventListeners:s,callbacks:a};window.wails.SetBindings(window.wailsbindings);delete window.wails.SetBindings;delete window.wailsbindings;window.addEventListener("mousedown",o=>{let n=o.target;for(;n!=null&&!n.hasAttribute("data-wails-no-drag");){if(n.hasAttribute("data-wails-drag")){window.WailsInvoke("drag");break}n=n.parentElement}});})();
(()=>{var v=Object.defineProperty;var h=o=>v(o,"__esModule",{value:!0});var x=(o,n)=>{h(o);for(var e in n)v(o,e,{get:n[e],enumerable:!0})};var f={};x(f,{LogDebug:()=>R,LogError:()=>F,LogFatal:()=>J,LogInfo:()=>T,LogLevel:()=>G,LogPrint:()=>C,LogTrace:()=>b,LogWarning:()=>D,SetLogLevel:()=>z});function l(o,n){window.WailsInvoke("L"+o+n)}function b(o){l("T",o)}function C(o){l("P",o)}function R(o){l("D",o)}function T(o){l("I",o)}function D(o){l("W",o)}function F(o){l("E",o)}function J(o){l("F",o)}function z(o){l("S",o)}var G={TRACE:1,DEBUG:2,INFO:3,WARNING:4,ERROR:5};var g=class{constructor(n,e){e=e||-1,this.Callback=t=>(n.apply(null,t),e===-1?!1:(e-=1,e===0))}},s={};function a(o,n,e){s[o]=s[o]||[];let t=new g(n,e);s[o].push(t)}function E(o,n){a(o,n,-1)}function I(o,n){a(o,n,1)}function k(o){let n=o.name;if(s[n]){let e=s[n].slice();for(let t=0;t<s[n].length;t+=1){let r=s[n][t],i=o.data;r.Callback(i)&&e.splice(t,1)}s[n]=e}}function m(o){let n;try{n=JSON.parse(o)}catch(e){let t="Invalid JSON passed to Notify: "+o;throw new Error(t)}k(n)}function S(o){let n={name:o,data:[].slice.apply(arguments).slice(1)};k(n),window.WailsInvoke("EE"+JSON.stringify(n))}function y(o){s.delete(o),window.WailsInvoke("EX"+o)}var c={};function P(){var o=new Uint32Array(1);return window.crypto.getRandomValues(o)[0]}function U(){return Math.random()*9007199254740991}var W;window.crypto?W=P:W=U;function d(o,n,e){return e==null&&(e=0),new Promise(function(t,r){var i;do i=o+"-"+W();while(c[i]);var w;e>0&&(w=setTimeout(function(){r(Error("Call to "+o+" timed out. Request ID: "+i))},e)),c[i]={timeoutHandle:w,reject:r,resolve:t};try{let u={name:o,args:n,callbackID:i};window.WailsInvoke("C"+JSON.stringify(u))}catch(u){console.error(u)}})}function L(o){var n;try{n=JSON.parse(o)}catch(r){let i=`Invalid JSON passed to callback: ${r.message}. Message: ${o}`;throw wails.LogDebug(i),new Error(i)}var e=n.callbackid,t=c[e];if(!t){let r=`Callback '${e}' not registered!!!`;throw console.error(r),new Error(r)}clearTimeout(t.timeoutHandle),delete c[e],n.error?t.reject(n.error):t.resolve(n.result)}window.go={};function O(o){try{o=JSON.parse(o)}catch(n){console.error(n)}window.go=window.go||{},Object.keys(o).forEach(n=>{window.go[n]=window.go[n]||{},Object.keys(o[n]).forEach(e=>{window.go[n][e]=window.go[n][e]||{},Object.keys(o[n][e]).forEach(t=>{window.go[n][e][t]=function(){let r=0;function i(){let w=[].slice.call(arguments);return d([n,e,t].join("."),w,r)}return i.setTimeout=function(w){r=w},i.getTimeout=function(){return r},i}()})})})}var p={};x(p,{WindowCenter:()=>A,WindowClose:()=>eo,WindowFullscreen:()=>H,WindowGetPosition:()=>K,WindowGetSize:()=>V,WindowHide:()=>N,WindowMaximise:()=>Y,WindowMinimise:()=>oo,WindowReload:()=>j,WindowSetMaxSize:()=>q,WindowSetMinSize:()=>X,WindowSetPosition:()=>Z,WindowSetSize:()=>$,WindowSetTitle:()=>B,WindowShow:()=>Q,WindowUnFullscreen:()=>M,WindowUnmaximise:()=>_,WindowUnminimise:()=>no});function j(){window.location.reload()}function A(){window.WailsInvoke("Wc")}function B(o){window.WailsInvoke("WT"+o)}function H(){window.WailsInvoke("WF")}function M(){window.WailsInvoke("Wf")}function $(o,n){window.WailsInvoke("Ws:"+o+":"+n)}function V(){return d(":wails:WindowGetSize")}function q(o,n){window.WailsInvoke("WZ:"+o+":"+n)}function X(o,n){window.WailsInvoke("Wz:"+o+":"+n)}function Z(o,n){window.WailsInvoke("Wp:"+o+":"+n)}function K(){return d(":wails:WindowGetPos")}function N(){window.WailsInvoke("WH")}function Q(){window.WailsInvoke("WS")}function Y(){window.WailsInvoke("WM")}function _(){window.WailsInvoke("WU")}function oo(){window.WailsInvoke("Wm")}function no(){window.WailsInvoke("Wu")}function eo(){window.WailsInvoke("WC")}window.runtime={...f,...p,EventsOn:E,EventsOnce:I,EventsOnMultiple:a,EventsEmit:S,EventsOff:y};window.wails={Callback:L,EventsNotify:m,SetBindings:O,eventListeners:s,callbacks:c};window.wails.SetBindings(window.wailsbindings);delete window.wails.SetBindings;delete window.wailsbindings;window.addEventListener("mousedown",o=>{let n=o.target;for(;n!=null&&!n.hasAttribute("data-wails-no-drag");){if(n.hasAttribute("data-wails-drag")){window.WailsInvoke("drag");break}n=n.parentElement}});})();

View File

@ -1,3 +1,14 @@
interface Position {
x: number;
y: number;
}
interface Size {
w: number;
h: number;
}
interface runtime {
EventsEmit(eventName: string, data?: any): void;
@ -20,6 +31,40 @@ interface runtime {
LogWarning(message: string): void;
WindowReload(): void;
WindowCenter(): void
WindowSetTitle(title: string): void
WindowFullscreen(): void
WindowUnFullscreen(): void
WindowSetSize(width: number, height: number): Promise<Size>
WindowGetSize(): Promise<Size>
WindowSetMaxSize(width: number, height: number): void
WindowSetMinSize(width: number, height: number): void
WindowSetPosition(x: number, y: number): void
WindowGetPosition(): Promise<Position>
WindowHide(): void
WindowShow(): void
WindowMaximise(): void
WindowUnmaximise(): void
WindowMinimise(): void
WindowUnminimise(): void
WindowClose(): void
}
declare global {

View File

@ -1 +1 @@
(()=>{var w=Object.defineProperty;var l=n=>w(n,"__esModule",{value:!0});var e=(n,o)=>{l(n);for(var t in o)w(n,t,{get:o[t],enumerable:!0})};var i={};e(i,{LogDebug:()=>g,LogError:()=>f,LogFatal:()=>c,LogInfo:()=>a,LogTrace:()=>p,LogWarning:()=>m});function p(n){window.runtime.LogTrace(n)}function g(n){window.runtime.LogDebug(n)}function a(n){window.runtime.LogInfo(n)}function m(n){window.runtime.LogWarning(n)}function f(n){window.runtime.LogError(n)}function c(n){window.runtime.LogFatal(n)}var r={};e(r,{EventsEmit:()=>x,EventsOn:()=>s,EventsOnMultiple:()=>d,EventsOnce:()=>L});function d(n,o,t){window.runtime.EventsOnMultiple(n,o,t)}function s(n,o){OnMultiple(n,o,-1)}function L(n,o){OnMultiple(n,o,1)}function x(n){let o=[n].slice.call(arguments);return window.runtime.EventsEmit.apply(null,o)}var u={};e(u,{WindowReload:()=>E});function E(){window.runtime.WindowReload()}var O={...i,...r,...u};})();
(()=>{var d=Object.defineProperty;var u=n=>d(n,"__esModule",{value:!0});var e=(n,i)=>{u(n);for(var o in i)d(n,o,{get:i[o],enumerable:!0})};var t={};e(t,{LogDebug:()=>W,LogError:()=>x,LogFatal:()=>f,LogInfo:()=>p,LogTrace:()=>m,LogWarning:()=>c});function m(n){window.runtime.LogTrace(n)}function W(n){window.runtime.LogDebug(n)}function p(n){window.runtime.LogInfo(n)}function c(n){window.runtime.LogWarning(n)}function x(n){window.runtime.LogError(n)}function f(n){window.runtime.LogFatal(n)}var w={};e(w,{EventsEmit:()=>g,EventsOn:()=>s,EventsOnMultiple:()=>l,EventsOnce:()=>a});function l(n,i,o){window.runtime.EventsOnMultiple(n,i,o)}function s(n,i){OnMultiple(n,i,-1)}function a(n,i){OnMultiple(n,i,1)}function g(n){let i=[n].slice.call(arguments);return window.runtime.EventsEmit.apply(null,i)}var r={};e(r,{WindowCenter:()=>L,WindowClose:()=>I,WindowFullscreen:()=>E,WindowGetPosition:()=>G,WindowGetSize:()=>z,WindowHide:()=>P,WindowMaximise:()=>b,WindowMinimise:()=>D,WindowReload:()=>S,WindowSetMaxSize:()=>O,WindowSetMinSize:()=>U,WindowSetPosition:()=>C,WindowSetSize:()=>F,WindowSetTitle:()=>M,WindowShow:()=>T,WindowUnFullscreen:()=>v,WindowUnmaximise:()=>h,WindowUnminimise:()=>H});function S(){window.runtime.WindowReload()}function L(){window.runtime.WindowCenter()}function M(n){window.runtime.WindowSetTitle(n)}function E(){window.runtime.WindowFullscreen()}function v(){window.runtime.WindowUnFullscreen()}function z(){window.runtime.WindowGetSize()}function F(n,i){window.runtime.WindowSetSize(n,i)}function O(n,i){window.runtime.WindowSetMaxSize(n,i)}function U(n,i){window.runtime.WindowSetMinSize(n,i)}function C(n,i){window.runtime.WindowSetPosition(n,i)}function G(){window.runtime.WindowGetPosition()}function P(){window.runtime.WindowHide()}function T(){window.runtime.WindowShow()}function b(){window.runtime.WindowMaximise()}function h(){window.runtime.WindowUnmaximise()}function D(){window.runtime.WindowMinimise()}function H(){window.runtime.WindowUnminimise()}function I(){window.runtime.WindowClose()}var y={...t,...w,...r};})();

View File

@ -18,3 +18,169 @@ The electron alternative for Go
export function WindowReload() {
window.runtime.WindowReload();
}
/**
* Place the window in the center of the screen
*
* @export
*/
export function WindowCenter() {
window.runtime.WindowCenter();
}
/**
* Sets the window title
*
* @param {string} title
* @export
*/
export function WindowSetTitle(title) {
window.runtime.WindowSetTitle(title);
}
/**
* Makes the window go fullscreen
*
* @export
*/
export function WindowFullscreen() {
window.runtime.WindowFullscreen();
}
/**
* Reverts the window from fullscreen
*
* @export
*/
export function WindowUnFullscreen() {
window.runtime.WindowUnFullscreen();
}
/**
* Get the Size of the window
*
* @export
* @return {Promise<{w: number, h: number}>} The size of the window
*/
export function WindowGetSize() {
window.runtime.WindowGetSize();
}
/**
* Set the Size of the window
*
* @export
* @param {number} width
* @param {number} height
*/
export function WindowSetSize(width, height) {
window.runtime.WindowSetSize(width, height);
}
/**
* Set the maximum size of the window
*
* @export
* @param {number} width
* @param {number} height
*/
export function WindowSetMaxSize(width, height) {
window.runtime.WindowSetMaxSize(width, height);
}
/**
* Set the minimum size of the window
*
* @export
* @param {number} width
* @param {number} height
*/
export function WindowSetMinSize(width, height) {
window.runtime.WindowSetMinSize(width, height);
}
/**
* Set the Position of the window
*
* @export
* @param {number} x
* @param {number} y
*/
export function WindowSetPosition(x, y) {
window.runtime.WindowSetPosition(x, y);
}
/**
* Get the Position of the window
*
* @export
* @return {Promise<{x: number, y: number}>} The position of the window
*/
export function WindowGetPosition() {
window.runtime.WindowGetPosition();
}
/**
* Hide the Window
*
* @export
*/
export function WindowHide() {
window.runtime.WindowHide();
}
/**
* Show the Window
*
* @export
*/
export function WindowShow() {
window.runtime.WindowShow();
}
/**
* Maximise the Window
*
* @export
*/
export function WindowMaximise() {
window.runtime.WindowMaximise();
}
/**
* Unmaximise the Window
*
* @export
*/
export function WindowUnmaximise() {
window.runtime.WindowUnmaximise();
}
/**
* Minimise the Window
*
* @export
*/
export function WindowMinimise() {
window.runtime.WindowMinimise();
}
/**
* Unminimise the Window
*
* @export
*/
export function WindowUnminimise() {
window.runtime.WindowUnminimise();
}
/**
* Close the Window
*
* @export
*/
export function WindowClose() {
window.runtime.WindowClose();
}