@wailsio/runtime 3.0.0-alpha.13 → 3.0.0-alpha.14
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/package.json +7 -2
- package/src/calls.js +38 -2
- package/src/dialogs.js +69 -8
- package/src/event_types.js +183 -0
- package/src/events.js +4 -1
- package/src/index.js +4 -27
- package/src/screens.js +12 -1
- package/src/window.js +242 -21
- package/src/wml.js +22 -1
- package/types/calls.d.ts +0 -2
- package/types/dialogs.d.ts +184 -28
- package/types/event_types.d.ts +183 -0
- package/types/events.d.ts +191 -1
- package/types/index.d.ts +12 -49
- package/types/screens.d.ts +38 -1
- package/types/window.d.ts +43 -8
- package/types/wml.d.ts +6 -6
- package/src/index.d.ts +0 -136
package/src/window.js
CHANGED
|
@@ -10,12 +10,38 @@ The electron alternative for Go
|
|
|
10
10
|
|
|
11
11
|
/* jshint esversion: 9 */
|
|
12
12
|
|
|
13
|
+
// Import screen jsdoc definition from ./screens.js
|
|
13
14
|
/**
|
|
14
|
-
* @typedef {import("
|
|
15
|
-
* @typedef {import("../api/types").Position} Position
|
|
16
|
-
* @typedef {import("../api/types").Screen} Screen
|
|
15
|
+
* @typedef {import("./screens").Screen} Screen
|
|
17
16
|
*/
|
|
18
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} Position
|
|
20
|
+
* @property {number} X - The X coordinate.
|
|
21
|
+
* @property {number} Y - The Y coordinate.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {Object} Size
|
|
26
|
+
* @property {number} X - The width.
|
|
27
|
+
* @property {number} Y - The height.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {Object} Rect
|
|
33
|
+
* @property {number} X - The X coordinate of the top-left corner.
|
|
34
|
+
* @property {number} Y - The Y coordinate of the top-left corner.
|
|
35
|
+
* @property {number} Width - The width of the rectangle.
|
|
36
|
+
* @property {number} Height - The height of the rectangle.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {('Zero'|'Ninety'|'OneEighty'|'TwoSeventy')} Rotation
|
|
41
|
+
* The rotation of the screen. Can be one of 'Zero', 'Ninety', 'OneEighty', 'TwoSeventy'.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
|
|
19
45
|
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
20
46
|
|
|
21
47
|
const center = 0;
|
|
@@ -49,7 +75,7 @@ const zoomReset = 27;
|
|
|
49
75
|
const getZoomLevel = 28;
|
|
50
76
|
const setZoomLevel = 29;
|
|
51
77
|
|
|
52
|
-
const thisWindow =
|
|
78
|
+
const thisWindow = Get('');
|
|
53
79
|
|
|
54
80
|
function createWindow(call) {
|
|
55
81
|
return {
|
|
@@ -98,25 +124,220 @@ export function Get(windowName) {
|
|
|
98
124
|
}
|
|
99
125
|
|
|
100
126
|
/**
|
|
101
|
-
*
|
|
102
|
-
|
|
127
|
+
* Centers the window on the screen.
|
|
128
|
+
*/
|
|
129
|
+
export function Center() {
|
|
130
|
+
thisWindow.Center();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Sets the title of the window.
|
|
135
|
+
* @param {string} title - The title to set.
|
|
136
|
+
*/
|
|
137
|
+
export function SetTitle(title) {
|
|
138
|
+
thisWindow.SetTitle(title);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Sets the window to fullscreen.
|
|
143
|
+
*/
|
|
144
|
+
export function Fullscreen() {
|
|
145
|
+
thisWindow.Fullscreen();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Sets the size of the window.
|
|
150
|
+
* @param {number} width - The width of the window.
|
|
151
|
+
* @param {number} height - The height of the window.
|
|
152
|
+
*/
|
|
153
|
+
export function SetSize(width, height) {
|
|
154
|
+
thisWindow.SetSize(width, height);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Gets the size of the window.
|
|
159
|
+
*/
|
|
160
|
+
export function Size() {
|
|
161
|
+
return thisWindow.Size();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Sets the maximum size of the window.
|
|
166
|
+
* @param {number} width - The maximum width of the window.
|
|
167
|
+
* @param {number} height - The maximum height of the window.
|
|
168
|
+
*/
|
|
169
|
+
export function SetMaxSize(width, height) {
|
|
170
|
+
thisWindow.SetMaxSize(width, height);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sets the minimum size of the window.
|
|
175
|
+
* @param {number} width - The minimum width of the window.
|
|
176
|
+
* @param {number} height - The minimum height of the window.
|
|
103
177
|
*/
|
|
104
|
-
export function
|
|
105
|
-
|
|
106
|
-
|
|
178
|
+
export function SetMinSize(width, height) {
|
|
179
|
+
thisWindow.SetMinSize(width, height);
|
|
180
|
+
}
|
|
107
181
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Sets the window to always be on top.
|
|
184
|
+
* @param {boolean} onTop - Whether the window should always be on top.
|
|
185
|
+
*/
|
|
186
|
+
export function SetAlwaysOnTop(onTop) {
|
|
187
|
+
thisWindow.SetAlwaysOnTop(onTop);
|
|
188
|
+
}
|
|
115
189
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Sets the relative position of the window.
|
|
192
|
+
* @param {number} x - The x-coordinate of the window's position.
|
|
193
|
+
* @param {number} y - The y-coordinate of the window's position.
|
|
194
|
+
*/
|
|
195
|
+
export function SetRelativePosition(x, y) {
|
|
196
|
+
thisWindow.SetRelativePosition(x, y);
|
|
119
197
|
}
|
|
120
|
-
|
|
121
|
-
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Gets the relative position of the window.
|
|
201
|
+
*/
|
|
202
|
+
export function RelativePosition() {
|
|
203
|
+
return thisWindow.RelativePosition();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Gets the screen that the window is on.
|
|
208
|
+
*/
|
|
209
|
+
export function Screen() {
|
|
210
|
+
return thisWindow.Screen();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Hides the window.
|
|
215
|
+
*/
|
|
216
|
+
export function Hide() {
|
|
217
|
+
thisWindow.Hide();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Maximises the window.
|
|
222
|
+
*/
|
|
223
|
+
export function Maximise() {
|
|
224
|
+
thisWindow.Maximise();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Un-maximises the window.
|
|
229
|
+
*/
|
|
230
|
+
export function UnMaximise() {
|
|
231
|
+
thisWindow.UnMaximise();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Toggles the maximisation of the window.
|
|
236
|
+
*/
|
|
237
|
+
export function ToggleMaximise() {
|
|
238
|
+
thisWindow.ToggleMaximise();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Minimises the window.
|
|
243
|
+
*/
|
|
244
|
+
export function Minimise() {
|
|
245
|
+
thisWindow.Minimise();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Un-minimises the window.
|
|
250
|
+
*/
|
|
251
|
+
export function UnMinimise() {
|
|
252
|
+
thisWindow.UnMinimise();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Restores the window.
|
|
257
|
+
*/
|
|
258
|
+
export function Restore() {
|
|
259
|
+
thisWindow.Restore();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Shows the window.
|
|
264
|
+
*/
|
|
265
|
+
export function Show() {
|
|
266
|
+
thisWindow.Show();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Closes the window.
|
|
271
|
+
*/
|
|
272
|
+
export function Close() {
|
|
273
|
+
thisWindow.Close();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Sets the background colour of the window.
|
|
278
|
+
* @param {number} r - The red component of the colour.
|
|
279
|
+
* @param {number} g - The green component of the colour.
|
|
280
|
+
* @param {number} b - The blue component of the colour.
|
|
281
|
+
* @param {number} a - The alpha component of the colour.
|
|
282
|
+
*/
|
|
283
|
+
export function SetBackgroundColour(r, g, b, a) {
|
|
284
|
+
thisWindow.SetBackgroundColour(r, g, b, a);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Sets whether the window is resizable.
|
|
289
|
+
* @param {boolean} resizable - Whether the window should be resizable.
|
|
290
|
+
*/
|
|
291
|
+
export function SetResizable(resizable) {
|
|
292
|
+
thisWindow.SetResizable(resizable);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Gets the width of the window.
|
|
297
|
+
*/
|
|
298
|
+
export function Width() {
|
|
299
|
+
return thisWindow.Width();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Gets the height of the window.
|
|
304
|
+
*/
|
|
305
|
+
export function Height() {
|
|
306
|
+
return thisWindow.Height();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Zooms in the window.
|
|
311
|
+
*/
|
|
312
|
+
export function ZoomIn() {
|
|
313
|
+
thisWindow.ZoomIn();
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Zooms out the window.
|
|
318
|
+
*/
|
|
319
|
+
export function ZoomOut() {
|
|
320
|
+
thisWindow.ZoomOut();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Resets the zoom of the window.
|
|
325
|
+
*/
|
|
326
|
+
export function ZoomReset() {
|
|
327
|
+
thisWindow.ZoomReset();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Gets the zoom level of the window.
|
|
332
|
+
*/
|
|
333
|
+
export function GetZoomLevel() {
|
|
334
|
+
return thisWindow.GetZoomLevel();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Sets the zoom level of the window.
|
|
339
|
+
* @param {number} zoomLevel - The zoom level to set.
|
|
340
|
+
*/
|
|
341
|
+
export function SetZoomLevel(zoomLevel) {
|
|
342
|
+
thisWindow.SetZoomLevel(zoomLevel);
|
|
122
343
|
}
|
package/src/wml.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import {Emit, WailsEvent} from "./events";
|
|
3
3
|
import {Question} from "./dialogs";
|
|
4
|
-
import {
|
|
4
|
+
import {Get} from "./window";
|
|
5
5
|
import {OpenURL} from "./browser";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -149,3 +149,24 @@ export function Reload() {
|
|
|
149
149
|
addWMLWindowListeners();
|
|
150
150
|
addWMLOpenBrowserListener();
|
|
151
151
|
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Returns a map of all methods in the current window.
|
|
155
|
+
* @returns {Map} - A map of window methods.
|
|
156
|
+
*/
|
|
157
|
+
function WindowMethods(targetWindow) {
|
|
158
|
+
// Create a new map to store methods
|
|
159
|
+
let result = new Map();
|
|
160
|
+
|
|
161
|
+
// Iterate over all properties of the window object
|
|
162
|
+
for (let method in targetWindow) {
|
|
163
|
+
// Check if the property is indeed a method (function)
|
|
164
|
+
if(typeof targetWindow[method] === 'function') {
|
|
165
|
+
// Add the method to the map
|
|
166
|
+
result.set(method, targetWindow[method]);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
// Return the map of window methods
|
|
171
|
+
return result;
|
|
172
|
+
}
|
package/types/calls.d.ts
CHANGED
package/types/dialogs.d.ts
CHANGED
|
@@ -1,28 +1,184 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
export function Info(options: MessageDialogOptions): Promise<string>;
|
|
2
|
+
export function Warning(options: MessageDialogOptions): Promise<string>;
|
|
3
|
+
export function Error(options: MessageDialogOptions): Promise<string>;
|
|
4
|
+
export function Question(options: MessageDialogOptions): Promise<string>;
|
|
5
|
+
export function OpenFile(options: OpenFileDialogOptions): Promise<string[] | string>;
|
|
6
|
+
export function SaveFile(options: SaveFileDialogOptions): Promise<string>;
|
|
7
|
+
export type OpenFileDialogOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* - Indicates if directories can be chosen.
|
|
10
|
+
*/
|
|
11
|
+
CanChooseDirectories?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* - Indicates if files can be chosen.
|
|
14
|
+
*/
|
|
15
|
+
CanChooseFiles?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* - Indicates if directories can be created.
|
|
18
|
+
*/
|
|
19
|
+
CanCreateDirectories?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* - Indicates if hidden files should be shown.
|
|
22
|
+
*/
|
|
23
|
+
ShowHiddenFiles?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* - Indicates if aliases should be resolved.
|
|
26
|
+
*/
|
|
27
|
+
ResolvesAliases?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* - Indicates if multiple selection is allowed.
|
|
30
|
+
*/
|
|
31
|
+
AllowsMultipleSelection?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* - Indicates if the extension should be hidden.
|
|
34
|
+
*/
|
|
35
|
+
HideExtension?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* - Indicates if hidden extensions can be selected.
|
|
38
|
+
*/
|
|
39
|
+
CanSelectHiddenExtension?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* - Indicates if file packages should be treated as directories.
|
|
42
|
+
*/
|
|
43
|
+
TreatsFilePackagesAsDirectories?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* - Indicates if other file types are allowed.
|
|
46
|
+
*/
|
|
47
|
+
AllowsOtherFiletypes?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* - Array of file filters.
|
|
50
|
+
*/
|
|
51
|
+
Filters?: FileFilter[];
|
|
52
|
+
/**
|
|
53
|
+
* - Title of the dialog.
|
|
54
|
+
*/
|
|
55
|
+
Title?: string;
|
|
56
|
+
/**
|
|
57
|
+
* - Message to show in the dialog.
|
|
58
|
+
*/
|
|
59
|
+
Message?: string;
|
|
60
|
+
/**
|
|
61
|
+
* - Text to display on the button.
|
|
62
|
+
*/
|
|
63
|
+
ButtonText?: string;
|
|
64
|
+
/**
|
|
65
|
+
* - Directory to open in the dialog.
|
|
66
|
+
*/
|
|
67
|
+
Directory?: string;
|
|
68
|
+
/**
|
|
69
|
+
* - Indicates if the dialog should appear detached from the main window.
|
|
70
|
+
*/
|
|
71
|
+
Detached?: boolean;
|
|
72
|
+
};
|
|
73
|
+
export type SaveFileDialogOptions = {
|
|
74
|
+
/**
|
|
75
|
+
* - Default filename to use in the dialog.
|
|
76
|
+
*/
|
|
77
|
+
Filename?: string;
|
|
78
|
+
/**
|
|
79
|
+
* - Indicates if directories can be chosen.
|
|
80
|
+
*/
|
|
81
|
+
CanChooseDirectories?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* - Indicates if files can be chosen.
|
|
84
|
+
*/
|
|
85
|
+
CanChooseFiles?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* - Indicates if directories can be created.
|
|
88
|
+
*/
|
|
89
|
+
CanCreateDirectories?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* - Indicates if hidden files should be shown.
|
|
92
|
+
*/
|
|
93
|
+
ShowHiddenFiles?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* - Indicates if aliases should be resolved.
|
|
96
|
+
*/
|
|
97
|
+
ResolvesAliases?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* - Indicates if multiple selection is allowed.
|
|
100
|
+
*/
|
|
101
|
+
AllowsMultipleSelection?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* - Indicates if the extension should be hidden.
|
|
104
|
+
*/
|
|
105
|
+
HideExtension?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* - Indicates if hidden extensions can be selected.
|
|
108
|
+
*/
|
|
109
|
+
CanSelectHiddenExtension?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* - Indicates if file packages should be treated as directories.
|
|
112
|
+
*/
|
|
113
|
+
TreatsFilePackagesAsDirectories?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* - Indicates if other file types are allowed.
|
|
116
|
+
*/
|
|
117
|
+
AllowsOtherFiletypes?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* - Array of file filters.
|
|
120
|
+
*/
|
|
121
|
+
Filters?: FileFilter[];
|
|
122
|
+
/**
|
|
123
|
+
* - Title of the dialog.
|
|
124
|
+
*/
|
|
125
|
+
Title?: string;
|
|
126
|
+
/**
|
|
127
|
+
* - Message to show in the dialog.
|
|
128
|
+
*/
|
|
129
|
+
Message?: string;
|
|
130
|
+
/**
|
|
131
|
+
* - Text to display on the button.
|
|
132
|
+
*/
|
|
133
|
+
ButtonText?: string;
|
|
134
|
+
/**
|
|
135
|
+
* - Directory to open in the dialog.
|
|
136
|
+
*/
|
|
137
|
+
Directory?: string;
|
|
138
|
+
/**
|
|
139
|
+
* - Indicates if the dialog should appear detached from the main window.
|
|
140
|
+
*/
|
|
141
|
+
Detached?: boolean;
|
|
142
|
+
};
|
|
143
|
+
export type MessageDialogOptions = {
|
|
144
|
+
/**
|
|
145
|
+
* - The title of the dialog window.
|
|
146
|
+
*/
|
|
147
|
+
Title?: string;
|
|
148
|
+
/**
|
|
149
|
+
* - The main message to show in the dialog.
|
|
150
|
+
*/
|
|
151
|
+
Message?: string;
|
|
152
|
+
/**
|
|
153
|
+
* - Array of button options to show in the dialog.
|
|
154
|
+
*/
|
|
155
|
+
Buttons?: Button[];
|
|
156
|
+
/**
|
|
157
|
+
* - True if the dialog should appear detached from the main window (if applicable).
|
|
158
|
+
*/
|
|
159
|
+
Detached?: boolean;
|
|
160
|
+
};
|
|
161
|
+
export type Button = {
|
|
162
|
+
/**
|
|
163
|
+
* - Text that appears within the button.
|
|
164
|
+
*/
|
|
165
|
+
Label?: string;
|
|
166
|
+
/**
|
|
167
|
+
* - True if the button should cancel an operation when clicked.
|
|
168
|
+
*/
|
|
169
|
+
IsCancel?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* - True if the button should be the default action when the user presses enter.
|
|
172
|
+
*/
|
|
173
|
+
IsDefault?: boolean;
|
|
174
|
+
};
|
|
175
|
+
export type FileFilter = {
|
|
176
|
+
/**
|
|
177
|
+
* - Display name for the filter, it could be "Text Files", "Images" etc.
|
|
178
|
+
*/
|
|
179
|
+
DisplayName?: string;
|
|
180
|
+
/**
|
|
181
|
+
* - Pattern to match for the filter, e.g. "*.txt;*.md" for text markdown files.
|
|
182
|
+
*/
|
|
183
|
+
Pattern?: string;
|
|
184
|
+
};
|