@wailsio/runtime 3.0.0-alpha.4 → 3.0.0-alpha.40
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/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +22 -0
- package/docs/assets/icons.js +15 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +59 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1415 -0
- package/docs/classes/Events.WailsEvent.html +4 -0
- package/docs/functions/Application.Hide.html +2 -0
- package/docs/functions/Application.Quit.html +2 -0
- package/docs/functions/Application.Show.html +2 -0
- package/docs/functions/Browser.OpenURL.html +3 -0
- package/docs/functions/Call.ByID.html +7 -0
- package/docs/functions/Call.ByName.html +6 -0
- package/docs/functions/Call.Call.html +6 -0
- package/docs/functions/Call.Plugin.html +8 -0
- package/docs/functions/Clipboard.SetText.html +6 -0
- package/docs/functions/Clipboard.Text.html +3 -0
- package/docs/functions/Dialogs.Error.html +5 -0
- package/docs/functions/Dialogs.Info.html +5 -0
- package/docs/functions/Dialogs.OpenFile.html +3 -0
- package/docs/functions/Dialogs.Question.html +5 -0
- package/docs/functions/Dialogs.SaveFile.html +3 -0
- package/docs/functions/Dialogs.Warning.html +5 -0
- package/docs/functions/Events.Emit.html +6 -0
- package/docs/functions/Events.Off.html +4 -0
- package/docs/functions/Events.OffAll.html +3 -0
- package/docs/functions/Events.On.html +7 -0
- package/docs/functions/Events.OnMultiple.html +8 -0
- package/docs/functions/Events.Once.html +7 -0
- package/docs/functions/Events.setup.html +1 -0
- package/docs/functions/Flags.GetFlag.html +6 -0
- package/docs/functions/Screens.GetAll.html +3 -0
- package/docs/functions/Screens.GetCurrent.html +3 -0
- package/docs/functions/Screens.GetPrimary.html +3 -0
- package/docs/functions/System.Capabilities.html +4 -0
- package/docs/functions/System.Environment.html +5 -0
- package/docs/functions/System.IsAMD64.html +3 -0
- package/docs/functions/System.IsARM.html +3 -0
- package/docs/functions/System.IsARM64.html +5 -0
- package/docs/functions/System.IsDarkMode.html +5 -0
- package/docs/functions/System.IsDebug.html +1 -0
- package/docs/functions/System.IsLinux.html +3 -0
- package/docs/functions/System.IsMac.html +3 -0
- package/docs/functions/System.IsWindows.html +3 -0
- package/docs/functions/System.invoke.html +1 -0
- package/docs/functions/WML.Enable.html +2 -0
- package/docs/functions/WML.Reload.html +2 -0
- package/docs/index.html +5 -0
- package/docs/interfaces/Dialogs.Button.html +7 -0
- package/docs/interfaces/Dialogs.FileFilter.html +5 -0
- package/docs/interfaces/Dialogs.MessageDialogOptions.html +9 -0
- package/docs/interfaces/Dialogs.OpenFileDialogOptions.html +33 -0
- package/docs/interfaces/Dialogs.SaveFileDialogOptions.html +35 -0
- package/docs/interfaces/Screens.Position.html +5 -0
- package/docs/interfaces/Screens.Rect.html +9 -0
- package/docs/interfaces/Screens.Screen.html +19 -0
- package/docs/interfaces/Screens.Size.html +5 -0
- package/docs/interfaces/System.EnvironmentInfo.html +11 -0
- package/docs/interfaces/System.OSInfo.html +9 -0
- package/docs/modules/Application.html +4 -0
- package/docs/modules/Browser.html +2 -0
- package/docs/modules/Call.html +5 -0
- package/docs/modules/Clipboard.html +3 -0
- package/docs/modules/Dialogs.html +12 -0
- package/docs/modules/Events.html +10 -0
- package/docs/modules/Flags.html +2 -0
- package/docs/modules/Screens.html +8 -0
- package/docs/modules/System.html +14 -0
- package/docs/modules/WML.html +3 -0
- package/docs/modules.html +12 -0
- package/docs/variables/Events.Types.html +1 -0
- package/docs/variables/Window.html +2 -0
- package/package.json +38 -17
- package/{application.js → src/application.js} +46 -46
- package/{browser.js → src/browser.js} +24 -24
- package/src/calls.js +174 -0
- package/{clipboard.js → src/clipboard.js} +35 -35
- package/{contextmenu.js → src/contextmenu.js} +97 -96
- package/src/create.js +125 -0
- package/src/dialogs.js +200 -0
- package/{drag.js → src/drag.js} +119 -125
- package/src/event_types.js +217 -0
- package/{events.js → src/events.js} +140 -134
- package/src/flags.js +25 -0
- package/src/index.js +60 -0
- package/src/nanoid.js +42 -0
- package/{runtime.js → src/runtime.js} +123 -122
- package/src/screens.js +71 -0
- package/{system.js → src/system.js} +143 -118
- package/src/utils.js +86 -0
- package/src/window.js +638 -0
- package/src/wml.js +250 -0
- package/tsconfig.json +20 -0
- package/types/application.d.ts +19 -0
- package/types/browser.d.ts +6 -0
- package/types/calls.d.ts +33 -0
- package/types/clipboard.d.ts +12 -0
- package/types/create.d.ts +45 -0
- package/types/dialogs.d.ts +184 -0
- package/types/event_types.d.ts +217 -0
- package/types/events.d.ts +239 -0
- package/types/flags.d.ts +7 -0
- package/types/index.d.ts +13 -0
- package/types/runtime.d.ts +30 -0
- package/types/screens.d.ts +94 -0
- package/types/system.d.ts +112 -0
- package/types/utils.d.ts +14 -0
- package/types/window.d.ts +407 -0
- package/types/wml.d.ts +12 -0
- package/calls.js +0 -123
- package/dialogs.js +0 -138
- package/flags.js +0 -63
- package/index.js +0 -56
- package/screens.js +0 -45
- package/types.d.ts +0 -130
- package/window.js +0 -122
- package/wml.js +0 -148
package/src/utils.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
_ __ _ __
|
|
3
|
+
| | / /___ _(_) /____
|
|
4
|
+
| | /| / / __ `/ / / ___/
|
|
5
|
+
| |/ |/ / /_/ / / (__ )
|
|
6
|
+
|__/|__/\__,_/_/_/____/
|
|
7
|
+
The electron alternative for Go
|
|
8
|
+
(c) Lea Anthony 2019-present
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Logs a message to the console with custom formatting.
|
|
13
|
+
* @param {string} message - The message to be logged.
|
|
14
|
+
* @return {void}
|
|
15
|
+
*/
|
|
16
|
+
export function debugLog(message) {
|
|
17
|
+
// eslint-disable-next-line
|
|
18
|
+
console.log(
|
|
19
|
+
'%c wails3 %c ' + message + ' ',
|
|
20
|
+
'background: #aa0000; color: #fff; border-radius: 3px 0px 0px 3px; padding: 1px; font-size: 0.7rem',
|
|
21
|
+
'background: #009900; color: #fff; border-radius: 0px 3px 3px 0px; padding: 1px; font-size: 0.7rem'
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Checks whether the browser supports removing listeners by triggering an AbortSignal
|
|
27
|
+
* (see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#signal)
|
|
28
|
+
*
|
|
29
|
+
* @return {boolean}
|
|
30
|
+
*/
|
|
31
|
+
export function canAbortListeners() {
|
|
32
|
+
if (!EventTarget || !AbortSignal || !AbortController)
|
|
33
|
+
return false;
|
|
34
|
+
|
|
35
|
+
let result = true;
|
|
36
|
+
|
|
37
|
+
const target = new EventTarget();
|
|
38
|
+
const controller = new AbortController();
|
|
39
|
+
target.addEventListener('test', () => { result = false; }, { signal: controller.signal });
|
|
40
|
+
controller.abort();
|
|
41
|
+
target.dispatchEvent(new CustomEvent('test'));
|
|
42
|
+
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/***
|
|
47
|
+
This technique for proper load detection is taken from HTMX:
|
|
48
|
+
|
|
49
|
+
BSD 2-Clause License
|
|
50
|
+
|
|
51
|
+
Copyright (c) 2020, Big Sky Software
|
|
52
|
+
All rights reserved.
|
|
53
|
+
|
|
54
|
+
Redistribution and use in source and binary forms, with or without
|
|
55
|
+
modification, are permitted provided that the following conditions are met:
|
|
56
|
+
|
|
57
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
58
|
+
list of conditions and the following disclaimer.
|
|
59
|
+
|
|
60
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
61
|
+
this list of conditions and the following disclaimer in the documentation
|
|
62
|
+
and/or other materials provided with the distribution.
|
|
63
|
+
|
|
64
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
65
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
66
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
67
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
68
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
69
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
70
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
71
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
72
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
73
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
74
|
+
|
|
75
|
+
***/
|
|
76
|
+
|
|
77
|
+
let isReady = false;
|
|
78
|
+
document.addEventListener('DOMContentLoaded', () => isReady = true);
|
|
79
|
+
|
|
80
|
+
export function whenReady(callback) {
|
|
81
|
+
if (isReady || document.readyState === 'complete') {
|
|
82
|
+
callback();
|
|
83
|
+
} else {
|
|
84
|
+
document.addEventListener('DOMContentLoaded', callback);
|
|
85
|
+
}
|
|
86
|
+
}
|
package/src/window.js
ADDED
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
/*
|
|
2
|
+
_ __ _ __
|
|
3
|
+
| | / /___ _(_) /____
|
|
4
|
+
| | /| / / __ `/ / / ___/
|
|
5
|
+
| |/ |/ / /_/ / / (__ )
|
|
6
|
+
|__/|__/\__,_/_/_/____/
|
|
7
|
+
The electron alternative for Go
|
|
8
|
+
(c) Lea Anthony 2019-present
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* jshint esversion: 9 */
|
|
12
|
+
|
|
13
|
+
// Import screen jsdoc definition from ./screens.js
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {import("./screens").Screen} Screen
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A record describing the position of a window.
|
|
21
|
+
*
|
|
22
|
+
* @typedef {Object} Position
|
|
23
|
+
* @property {number} x - The horizontal position of the window
|
|
24
|
+
* @property {number} y - The vertical position of the window
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A record describing the size of a window.
|
|
30
|
+
*
|
|
31
|
+
* @typedef {Object} Size
|
|
32
|
+
* @property {number} width - The width of the window
|
|
33
|
+
* @property {number} height - The height of the window
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
38
|
+
|
|
39
|
+
const PositionMethod = 0;
|
|
40
|
+
const CenterMethod = 1;
|
|
41
|
+
const CloseMethod = 2;
|
|
42
|
+
const DisableSizeConstraintsMethod = 3;
|
|
43
|
+
const EnableSizeConstraintsMethod = 4;
|
|
44
|
+
const FocusMethod = 5;
|
|
45
|
+
const ForceReloadMethod = 6;
|
|
46
|
+
const FullscreenMethod = 7;
|
|
47
|
+
const GetScreenMethod = 8;
|
|
48
|
+
const GetZoomMethod = 9;
|
|
49
|
+
const HeightMethod = 10;
|
|
50
|
+
const HideMethod = 11;
|
|
51
|
+
const IsFocusedMethod = 12;
|
|
52
|
+
const IsFullscreenMethod = 13;
|
|
53
|
+
const IsMaximisedMethod = 14;
|
|
54
|
+
const IsMinimisedMethod = 15;
|
|
55
|
+
const MaximiseMethod = 16;
|
|
56
|
+
const MinimiseMethod = 17;
|
|
57
|
+
const NameMethod = 18;
|
|
58
|
+
const OpenDevToolsMethod = 19;
|
|
59
|
+
const RelativePositionMethod = 20;
|
|
60
|
+
const ReloadMethod = 21;
|
|
61
|
+
const ResizableMethod = 22;
|
|
62
|
+
const RestoreMethod = 23;
|
|
63
|
+
const SetPositionMethod = 24;
|
|
64
|
+
const SetAlwaysOnTopMethod = 25;
|
|
65
|
+
const SetBackgroundColourMethod = 26;
|
|
66
|
+
const SetFramelessMethod = 27;
|
|
67
|
+
const SetFullscreenButtonEnabledMethod = 28;
|
|
68
|
+
const SetMaxSizeMethod = 29;
|
|
69
|
+
const SetMinSizeMethod = 30;
|
|
70
|
+
const SetRelativePositionMethod = 31;
|
|
71
|
+
const SetResizableMethod = 32;
|
|
72
|
+
const SetSizeMethod = 33;
|
|
73
|
+
const SetTitleMethod = 34;
|
|
74
|
+
const SetZoomMethod = 35;
|
|
75
|
+
const ShowMethod = 36;
|
|
76
|
+
const SizeMethod = 37;
|
|
77
|
+
const ToggleFullscreenMethod = 38;
|
|
78
|
+
const ToggleMaximiseMethod = 39;
|
|
79
|
+
const UnFullscreenMethod = 40;
|
|
80
|
+
const UnMaximiseMethod = 41;
|
|
81
|
+
const UnMinimiseMethod = 42;
|
|
82
|
+
const WidthMethod = 43;
|
|
83
|
+
const ZoomMethod = 44;
|
|
84
|
+
const ZoomInMethod = 45;
|
|
85
|
+
const ZoomOutMethod = 46;
|
|
86
|
+
const ZoomResetMethod = 47;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @type {symbol}
|
|
90
|
+
*/
|
|
91
|
+
const caller = Symbol();
|
|
92
|
+
|
|
93
|
+
export class Window {
|
|
94
|
+
/**
|
|
95
|
+
* Initialises a window object with the specified name.
|
|
96
|
+
*
|
|
97
|
+
* @private
|
|
98
|
+
* @param {string} name - The name of the target window.
|
|
99
|
+
*/
|
|
100
|
+
constructor(name = '') {
|
|
101
|
+
/**
|
|
102
|
+
* @private
|
|
103
|
+
* @name {@link caller}
|
|
104
|
+
* @type {(...args: any[]) => any}
|
|
105
|
+
*/
|
|
106
|
+
this[caller] = newRuntimeCallerWithID(objectNames.Window, name)
|
|
107
|
+
|
|
108
|
+
// bind instance method to make them easily usable in event handlers
|
|
109
|
+
for (const method of Object.getOwnPropertyNames(Window.prototype)) {
|
|
110
|
+
if (
|
|
111
|
+
method !== "constructor"
|
|
112
|
+
&& typeof this[method] === "function"
|
|
113
|
+
) {
|
|
114
|
+
this[method] = this[method].bind(this);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Gets the specified window.
|
|
121
|
+
*
|
|
122
|
+
* @public
|
|
123
|
+
* @param {string} name - The name of the window to get.
|
|
124
|
+
* @return {Window} - The corresponding window object.
|
|
125
|
+
*/
|
|
126
|
+
Get(name) {
|
|
127
|
+
return new Window(name);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Returns the absolute position of the window.
|
|
132
|
+
*
|
|
133
|
+
* @public
|
|
134
|
+
* @return {Promise<Position>} - The current absolute position of the window.
|
|
135
|
+
*/
|
|
136
|
+
Position() {
|
|
137
|
+
return this[caller](PositionMethod);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Centers the window on the screen.
|
|
142
|
+
*
|
|
143
|
+
* @public
|
|
144
|
+
* @return {Promise<void>}
|
|
145
|
+
*/
|
|
146
|
+
Center() {
|
|
147
|
+
return this[caller](CenterMethod);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Closes the window.
|
|
152
|
+
*
|
|
153
|
+
* @public
|
|
154
|
+
* @return {Promise<void>}
|
|
155
|
+
*/
|
|
156
|
+
Close() {
|
|
157
|
+
return this[caller](CloseMethod);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Disables min/max size constraints.
|
|
162
|
+
*
|
|
163
|
+
* @public
|
|
164
|
+
* @return {Promise<void>}
|
|
165
|
+
*/
|
|
166
|
+
DisableSizeConstraints() {
|
|
167
|
+
return this[caller](DisableSizeConstraintsMethod);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Enables min/max size constraints.
|
|
172
|
+
*
|
|
173
|
+
* @public
|
|
174
|
+
* @return {Promise<void>}
|
|
175
|
+
*/
|
|
176
|
+
EnableSizeConstraints() {
|
|
177
|
+
return this[caller](EnableSizeConstraintsMethod);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Focuses the window.
|
|
182
|
+
*
|
|
183
|
+
* @public
|
|
184
|
+
* @return {Promise<void>}
|
|
185
|
+
*/
|
|
186
|
+
Focus() {
|
|
187
|
+
return this[caller](FocusMethod);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Forces the window to reload the page assets.
|
|
192
|
+
*
|
|
193
|
+
* @public
|
|
194
|
+
* @return {Promise<void>}
|
|
195
|
+
*/
|
|
196
|
+
ForceReload() {
|
|
197
|
+
return this[caller](ForceReloadMethod);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Doc.
|
|
202
|
+
*
|
|
203
|
+
* @public
|
|
204
|
+
* @return {Promise<void>}
|
|
205
|
+
*/
|
|
206
|
+
Fullscreen() {
|
|
207
|
+
return this[caller](FullscreenMethod);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Returns the screen that the window is on.
|
|
212
|
+
*
|
|
213
|
+
* @public
|
|
214
|
+
* @return {Promise<Screen>} - The screen the window is currently on
|
|
215
|
+
*/
|
|
216
|
+
GetScreen() {
|
|
217
|
+
return this[caller](GetScreenMethod);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Returns the current zoom level of the window.
|
|
222
|
+
*
|
|
223
|
+
* @public
|
|
224
|
+
* @return {Promise<number>} - The current zoom level
|
|
225
|
+
*/
|
|
226
|
+
GetZoom() {
|
|
227
|
+
return this[caller](GetZoomMethod);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Returns the height of the window.
|
|
232
|
+
*
|
|
233
|
+
* @public
|
|
234
|
+
* @return {Promise<number>} - The current height of the window
|
|
235
|
+
*/
|
|
236
|
+
Height() {
|
|
237
|
+
return this[caller](HeightMethod);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Hides the window.
|
|
242
|
+
*
|
|
243
|
+
* @public
|
|
244
|
+
* @return {Promise<void>}
|
|
245
|
+
*/
|
|
246
|
+
Hide() {
|
|
247
|
+
return this[caller](HideMethod);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Returns true if the window is focused.
|
|
252
|
+
*
|
|
253
|
+
* @public
|
|
254
|
+
* @return {Promise<boolean>} - Whether the window is currently focused
|
|
255
|
+
*/
|
|
256
|
+
IsFocused() {
|
|
257
|
+
return this[caller](IsFocusedMethod);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Returns true if the window is fullscreen.
|
|
262
|
+
*
|
|
263
|
+
* @public
|
|
264
|
+
* @return {Promise<boolean>} - Whether the window is currently fullscreen
|
|
265
|
+
*/
|
|
266
|
+
IsFullscreen() {
|
|
267
|
+
return this[caller](IsFullscreenMethod);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Returns true if the window is maximised.
|
|
272
|
+
*
|
|
273
|
+
* @public
|
|
274
|
+
* @return {Promise<boolean>} - Whether the window is currently maximised
|
|
275
|
+
*/
|
|
276
|
+
IsMaximised() {
|
|
277
|
+
return this[caller](IsMaximisedMethod);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Returns true if the window is minimised.
|
|
282
|
+
*
|
|
283
|
+
* @public
|
|
284
|
+
* @return {Promise<boolean>} - Whether the window is currently minimised
|
|
285
|
+
*/
|
|
286
|
+
IsMinimised() {
|
|
287
|
+
return this[caller](IsMinimisedMethod);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Maximises the window.
|
|
292
|
+
*
|
|
293
|
+
* @public
|
|
294
|
+
* @return {Promise<void>}
|
|
295
|
+
*/
|
|
296
|
+
Maximise() {
|
|
297
|
+
return this[caller](MaximiseMethod);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Minimises the window.
|
|
302
|
+
*
|
|
303
|
+
* @public
|
|
304
|
+
* @return {Promise<void>}
|
|
305
|
+
*/
|
|
306
|
+
Minimise() {
|
|
307
|
+
return this[caller](MinimiseMethod);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Returns the name of the window.
|
|
312
|
+
*
|
|
313
|
+
* @public
|
|
314
|
+
* @return {Promise<string>} - The name of the window
|
|
315
|
+
*/
|
|
316
|
+
Name() {
|
|
317
|
+
return this[caller](NameMethod);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Opens the development tools pane.
|
|
322
|
+
*
|
|
323
|
+
* @public
|
|
324
|
+
* @return {Promise<void>}
|
|
325
|
+
*/
|
|
326
|
+
OpenDevTools() {
|
|
327
|
+
return this[caller](OpenDevToolsMethod);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Returns the relative position of the window to the screen.
|
|
332
|
+
*
|
|
333
|
+
* @public
|
|
334
|
+
* @return {Promise<Position>} - The current relative position of the window
|
|
335
|
+
*/
|
|
336
|
+
RelativePosition() {
|
|
337
|
+
return this[caller](RelativePositionMethod);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Reloads the page assets.
|
|
342
|
+
*
|
|
343
|
+
* @public
|
|
344
|
+
* @return {Promise<void>}
|
|
345
|
+
*/
|
|
346
|
+
Reload() {
|
|
347
|
+
return this[caller](ReloadMethod);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Returns true if the window is resizable.
|
|
352
|
+
*
|
|
353
|
+
* @public
|
|
354
|
+
* @return {Promise<boolean>} - Whether the window is currently resizable
|
|
355
|
+
*/
|
|
356
|
+
Resizable() {
|
|
357
|
+
return this[caller](ResizableMethod);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Restores the window to its previous state if it was previously minimised, maximised or fullscreen.
|
|
362
|
+
*
|
|
363
|
+
* @public
|
|
364
|
+
* @return {Promise<void>}
|
|
365
|
+
*/
|
|
366
|
+
Restore() {
|
|
367
|
+
return this[caller](RestoreMethod);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Sets the absolute position of the window.
|
|
372
|
+
*
|
|
373
|
+
* @public
|
|
374
|
+
* @param {number} x - The desired horizontal absolute position of the window
|
|
375
|
+
* @param {number} y - The desired vertical absolute position of the window
|
|
376
|
+
* @return {Promise<void>}
|
|
377
|
+
*/
|
|
378
|
+
SetPosition(x, y) {
|
|
379
|
+
return this[caller](SetPositionMethod, { x, y });
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Sets the window to be always on top.
|
|
384
|
+
*
|
|
385
|
+
* @public
|
|
386
|
+
* @param {boolean} alwaysOnTop - Whether the window should stay on top
|
|
387
|
+
* @return {Promise<void>}
|
|
388
|
+
*/
|
|
389
|
+
SetAlwaysOnTop(alwaysOnTop) {
|
|
390
|
+
return this[caller](SetAlwaysOnTopMethod, { alwaysOnTop });
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Sets the background colour of the window.
|
|
395
|
+
*
|
|
396
|
+
* @public
|
|
397
|
+
* @param {number} r - The desired red component of the window background
|
|
398
|
+
* @param {number} g - The desired green component of the window background
|
|
399
|
+
* @param {number} b - The desired blue component of the window background
|
|
400
|
+
* @param {number} a - The desired alpha component of the window background
|
|
401
|
+
* @return {Promise<void>}
|
|
402
|
+
*/
|
|
403
|
+
SetBackgroundColour(r, g, b, a) {
|
|
404
|
+
return this[caller](SetBackgroundColourMethod, { r, g, b, a });
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Removes the window frame and title bar.
|
|
409
|
+
*
|
|
410
|
+
* @public
|
|
411
|
+
* @param {boolean} frameless - Whether the window should be frameless
|
|
412
|
+
* @return {Promise<void>}
|
|
413
|
+
*/
|
|
414
|
+
SetFrameless(frameless) {
|
|
415
|
+
return this[caller](SetFramelessMethod, { frameless });
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Disables the system fullscreen button.
|
|
420
|
+
*
|
|
421
|
+
* @public
|
|
422
|
+
* @param {boolean} enabled - Whether the fullscreen button should be enabled
|
|
423
|
+
* @return {Promise<void>}
|
|
424
|
+
*/
|
|
425
|
+
SetFullscreenButtonEnabled(enabled) {
|
|
426
|
+
return this[caller](SetFullscreenButtonEnabledMethod, { enabled });
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Sets the maximum size of the window.
|
|
431
|
+
*
|
|
432
|
+
* @public
|
|
433
|
+
* @param {number} width - The desired maximum width of the window
|
|
434
|
+
* @param {number} height - The desired maximum height of the window
|
|
435
|
+
* @return {Promise<void>}
|
|
436
|
+
*/
|
|
437
|
+
SetMaxSize(width, height) {
|
|
438
|
+
return this[caller](SetMaxSizeMethod, { width, height });
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Sets the minimum size of the window.
|
|
443
|
+
*
|
|
444
|
+
* @public
|
|
445
|
+
* @param {number} width - The desired minimum width of the window
|
|
446
|
+
* @param {number} height - The desired minimum height of the window
|
|
447
|
+
* @return {Promise<void>}
|
|
448
|
+
*/
|
|
449
|
+
SetMinSize(width, height) {
|
|
450
|
+
return this[caller](SetMinSizeMethod, { width, height });
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Sets the relative position of the window to the screen.
|
|
455
|
+
*
|
|
456
|
+
* @public
|
|
457
|
+
* @param {number} x - The desired horizontal relative position of the window
|
|
458
|
+
* @param {number} y - The desired vertical relative position of the window
|
|
459
|
+
* @return {Promise<void>}
|
|
460
|
+
*/
|
|
461
|
+
SetRelativePosition(x, y) {
|
|
462
|
+
return this[caller](SetRelativePositionMethod, { x, y });
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Sets whether the window is resizable.
|
|
467
|
+
*
|
|
468
|
+
* @public
|
|
469
|
+
* @param {boolean} resizable - Whether the window should be resizable
|
|
470
|
+
* @return {Promise<void>}
|
|
471
|
+
*/
|
|
472
|
+
SetResizable(resizable) {
|
|
473
|
+
return this[caller](SetResizableMethod, { resizable });
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Sets the size of the window.
|
|
478
|
+
*
|
|
479
|
+
* @public
|
|
480
|
+
* @param {number} width - The desired width of the window
|
|
481
|
+
* @param {number} height - The desired height of the window
|
|
482
|
+
* @return {Promise<void>}
|
|
483
|
+
*/
|
|
484
|
+
SetSize(width, height) {
|
|
485
|
+
return this[caller](SetSizeMethod, { width, height });
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Sets the title of the window.
|
|
490
|
+
*
|
|
491
|
+
* @public
|
|
492
|
+
* @param {string} title - The desired title of the window
|
|
493
|
+
* @return {Promise<void>}
|
|
494
|
+
*/
|
|
495
|
+
SetTitle(title) {
|
|
496
|
+
return this[caller](SetTitleMethod, { title });
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Sets the zoom level of the window.
|
|
501
|
+
*
|
|
502
|
+
* @public
|
|
503
|
+
* @param {number} zoom - The desired zoom level
|
|
504
|
+
* @return {Promise<void>}
|
|
505
|
+
*/
|
|
506
|
+
SetZoom(zoom) {
|
|
507
|
+
return this[caller](SetZoomMethod, { zoom });
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Shows the window.
|
|
512
|
+
*
|
|
513
|
+
* @public
|
|
514
|
+
* @return {Promise<void>}
|
|
515
|
+
*/
|
|
516
|
+
Show() {
|
|
517
|
+
return this[caller](ShowMethod);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Returns the size of the window.
|
|
522
|
+
*
|
|
523
|
+
* @public
|
|
524
|
+
* @return {Promise<Size>} - The current size of the window
|
|
525
|
+
*/
|
|
526
|
+
Size() {
|
|
527
|
+
return this[caller](SizeMethod);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Toggles the window between fullscreen and normal.
|
|
532
|
+
*
|
|
533
|
+
* @public
|
|
534
|
+
* @return {Promise<void>}
|
|
535
|
+
*/
|
|
536
|
+
ToggleFullscreen() {
|
|
537
|
+
return this[caller](ToggleFullscreenMethod);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Toggles the window between maximised and normal.
|
|
542
|
+
*
|
|
543
|
+
* @public
|
|
544
|
+
* @return {Promise<void>}
|
|
545
|
+
*/
|
|
546
|
+
ToggleMaximise() {
|
|
547
|
+
return this[caller](ToggleMaximiseMethod);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Un-fullscreens the window.
|
|
552
|
+
*
|
|
553
|
+
* @public
|
|
554
|
+
* @return {Promise<void>}
|
|
555
|
+
*/
|
|
556
|
+
UnFullscreen() {
|
|
557
|
+
return this[caller](UnFullscreenMethod);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Un-maximises the window.
|
|
562
|
+
*
|
|
563
|
+
* @public
|
|
564
|
+
* @return {Promise<void>}
|
|
565
|
+
*/
|
|
566
|
+
UnMaximise() {
|
|
567
|
+
return this[caller](UnMaximiseMethod);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Un-minimises the window.
|
|
572
|
+
*
|
|
573
|
+
* @public
|
|
574
|
+
* @return {Promise<void>}
|
|
575
|
+
*/
|
|
576
|
+
UnMinimise() {
|
|
577
|
+
return this[caller](UnMinimiseMethod);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Returns the width of the window.
|
|
582
|
+
*
|
|
583
|
+
* @public
|
|
584
|
+
* @return {Promise<number>} - The current width of the window
|
|
585
|
+
*/
|
|
586
|
+
Width() {
|
|
587
|
+
return this[caller](WidthMethod);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Zooms the window.
|
|
592
|
+
*
|
|
593
|
+
* @public
|
|
594
|
+
* @return {Promise<void>}
|
|
595
|
+
*/
|
|
596
|
+
Zoom() {
|
|
597
|
+
return this[caller](ZoomMethod);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Increases the zoom level of the webview content.
|
|
602
|
+
*
|
|
603
|
+
* @public
|
|
604
|
+
* @return {Promise<void>}
|
|
605
|
+
*/
|
|
606
|
+
ZoomIn() {
|
|
607
|
+
return this[caller](ZoomInMethod);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Decreases the zoom level of the webview content.
|
|
612
|
+
*
|
|
613
|
+
* @public
|
|
614
|
+
* @return {Promise<void>}
|
|
615
|
+
*/
|
|
616
|
+
ZoomOut() {
|
|
617
|
+
return this[caller](ZoomOutMethod);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Resets the zoom level of the webview content.
|
|
622
|
+
*
|
|
623
|
+
* @public
|
|
624
|
+
* @return {Promise<void>}
|
|
625
|
+
*/
|
|
626
|
+
ZoomReset() {
|
|
627
|
+
return this[caller](ZoomResetMethod);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* The window within which the script is running.
|
|
633
|
+
*
|
|
634
|
+
* @type {Window}
|
|
635
|
+
*/
|
|
636
|
+
const thisWindow = new Window('');
|
|
637
|
+
|
|
638
|
+
export default thisWindow;
|