@wailsio/runtime 3.0.0-alpha.7 → 3.0.0-alpha.72
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/{application.js → dist/application.js} +32 -46
- package/dist/browser.js +20 -0
- package/dist/callable.js +144 -0
- package/dist/calls.js +194 -0
- package/dist/cancellable.js +792 -0
- package/dist/clipboard.js +30 -0
- package/dist/contextmenu.js +80 -0
- package/dist/create.js +94 -0
- package/dist/dialogs.js +134 -0
- package/dist/drag.js +222 -0
- package/dist/event_types.js +232 -0
- package/dist/events.js +114 -0
- package/dist/flags.js +23 -0
- package/dist/index.js +42 -0
- package/dist/listener.js +44 -0
- package/dist/nanoid.js +38 -0
- package/dist/runtime.js +63 -0
- package/{screens.js → dist/screens.js} +38 -45
- package/dist/system.js +146 -0
- package/dist/utils.js +95 -0
- package/dist/window.js +570 -0
- package/dist/wml.js +179 -0
- package/package.json +62 -18
- package/types/application.d.ts +12 -0
- package/types/browser.d.ts +6 -0
- package/types/callable.d.ts +3 -0
- package/types/calls.d.ts +63 -0
- package/types/cancellable.d.ts +434 -0
- package/types/clipboard.d.ts +13 -0
- package/types/contextmenu.d.ts +1 -0
- package/types/create.d.ts +31 -0
- package/types/dialogs.d.ts +140 -0
- package/types/drag.d.ts +1 -0
- package/types/event_types.d.ts +221 -0
- package/types/events.d.ts +67 -0
- package/types/flags.d.ts +7 -0
- package/types/index.d.ts +16 -0
- package/types/listener.d.ts +9 -0
- package/types/nanoid.d.ts +1 -0
- package/types/runtime.d.ts +22 -0
- package/types/screens.d.ts +60 -0
- package/types/system.d.ts +92 -0
- package/types/utils.d.ts +21 -0
- package/types/window.d.ts +306 -0
- package/types/wml.d.ts +8 -0
- package/browser.js +0 -24
- package/calls.js +0 -123
- package/clipboard.js +0 -35
- package/contextmenu.js +0 -98
- package/dialogs.js +0 -138
- package/drag.js +0 -125
- package/events.js +0 -134
- package/flags.js +0 -63
- package/index.js +0 -56
- package/runtime.js +0 -122
- package/system.js +0 -122
- package/types.d.ts +0 -135
- package/window.js +0 -122
- package/wml.js +0 -151
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import type { Screen } from "./screens.js";
|
|
2
|
+
/**
|
|
3
|
+
* A record describing the position of a window.
|
|
4
|
+
*/
|
|
5
|
+
interface Position {
|
|
6
|
+
/** The horizontal position of the window. */
|
|
7
|
+
x: number;
|
|
8
|
+
/** The vertical position of the window. */
|
|
9
|
+
y: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A record describing the size of a window.
|
|
13
|
+
*/
|
|
14
|
+
interface Size {
|
|
15
|
+
/** The width of the window. */
|
|
16
|
+
width: number;
|
|
17
|
+
/** The height of the window. */
|
|
18
|
+
height: number;
|
|
19
|
+
}
|
|
20
|
+
declare const callerSym: unique symbol;
|
|
21
|
+
declare class Window {
|
|
22
|
+
private [callerSym];
|
|
23
|
+
/**
|
|
24
|
+
* Initialises a window object with the specified name.
|
|
25
|
+
*
|
|
26
|
+
* @private
|
|
27
|
+
* @param name - The name of the target window.
|
|
28
|
+
*/
|
|
29
|
+
constructor(name?: string);
|
|
30
|
+
/**
|
|
31
|
+
* Gets the specified window.
|
|
32
|
+
*
|
|
33
|
+
* @param name - The name of the window to get.
|
|
34
|
+
* @returns The corresponding window object.
|
|
35
|
+
*/
|
|
36
|
+
Get(name: string): Window;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the absolute position of the window.
|
|
39
|
+
*
|
|
40
|
+
* @returns The current absolute position of the window.
|
|
41
|
+
*/
|
|
42
|
+
Position(): Promise<Position>;
|
|
43
|
+
/**
|
|
44
|
+
* Centers the window on the screen.
|
|
45
|
+
*/
|
|
46
|
+
Center(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Closes the window.
|
|
49
|
+
*/
|
|
50
|
+
Close(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Disables min/max size constraints.
|
|
53
|
+
*/
|
|
54
|
+
DisableSizeConstraints(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Enables min/max size constraints.
|
|
57
|
+
*/
|
|
58
|
+
EnableSizeConstraints(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Focuses the window.
|
|
61
|
+
*/
|
|
62
|
+
Focus(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Forces the window to reload the page assets.
|
|
65
|
+
*/
|
|
66
|
+
ForceReload(): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Switches the window to fullscreen mode.
|
|
69
|
+
*/
|
|
70
|
+
Fullscreen(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the screen that the window is on.
|
|
73
|
+
*
|
|
74
|
+
* @returns The screen the window is currently on.
|
|
75
|
+
*/
|
|
76
|
+
GetScreen(): Promise<Screen>;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the current zoom level of the window.
|
|
79
|
+
*
|
|
80
|
+
* @returns The current zoom level.
|
|
81
|
+
*/
|
|
82
|
+
GetZoom(): Promise<number>;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the height of the window.
|
|
85
|
+
*
|
|
86
|
+
* @returns The current height of the window.
|
|
87
|
+
*/
|
|
88
|
+
Height(): Promise<number>;
|
|
89
|
+
/**
|
|
90
|
+
* Hides the window.
|
|
91
|
+
*/
|
|
92
|
+
Hide(): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Returns true if the window is focused.
|
|
95
|
+
*
|
|
96
|
+
* @returns Whether the window is currently focused.
|
|
97
|
+
*/
|
|
98
|
+
IsFocused(): Promise<boolean>;
|
|
99
|
+
/**
|
|
100
|
+
* Returns true if the window is fullscreen.
|
|
101
|
+
*
|
|
102
|
+
* @returns Whether the window is currently fullscreen.
|
|
103
|
+
*/
|
|
104
|
+
IsFullscreen(): Promise<boolean>;
|
|
105
|
+
/**
|
|
106
|
+
* Returns true if the window is maximised.
|
|
107
|
+
*
|
|
108
|
+
* @returns Whether the window is currently maximised.
|
|
109
|
+
*/
|
|
110
|
+
IsMaximised(): Promise<boolean>;
|
|
111
|
+
/**
|
|
112
|
+
* Returns true if the window is minimised.
|
|
113
|
+
*
|
|
114
|
+
* @returns Whether the window is currently minimised.
|
|
115
|
+
*/
|
|
116
|
+
IsMinimised(): Promise<boolean>;
|
|
117
|
+
/**
|
|
118
|
+
* Maximises the window.
|
|
119
|
+
*/
|
|
120
|
+
Maximise(): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Minimises the window.
|
|
123
|
+
*/
|
|
124
|
+
Minimise(): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Returns the name of the window.
|
|
127
|
+
*
|
|
128
|
+
* @returns The name of the window.
|
|
129
|
+
*/
|
|
130
|
+
Name(): Promise<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Opens the development tools pane.
|
|
133
|
+
*/
|
|
134
|
+
OpenDevTools(): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Returns the relative position of the window to the screen.
|
|
137
|
+
*
|
|
138
|
+
* @returns The current relative position of the window.
|
|
139
|
+
*/
|
|
140
|
+
RelativePosition(): Promise<Position>;
|
|
141
|
+
/**
|
|
142
|
+
* Reloads the page assets.
|
|
143
|
+
*/
|
|
144
|
+
Reload(): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Returns true if the window is resizable.
|
|
147
|
+
*
|
|
148
|
+
* @returns Whether the window is currently resizable.
|
|
149
|
+
*/
|
|
150
|
+
Resizable(): Promise<boolean>;
|
|
151
|
+
/**
|
|
152
|
+
* Restores the window to its previous state if it was previously minimised, maximised or fullscreen.
|
|
153
|
+
*/
|
|
154
|
+
Restore(): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Sets the absolute position of the window.
|
|
157
|
+
*
|
|
158
|
+
* @param x - The desired horizontal absolute position of the window.
|
|
159
|
+
* @param y - The desired vertical absolute position of the window.
|
|
160
|
+
*/
|
|
161
|
+
SetPosition(x: number, y: number): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Sets the window to be always on top.
|
|
164
|
+
*
|
|
165
|
+
* @param alwaysOnTop - Whether the window should stay on top.
|
|
166
|
+
*/
|
|
167
|
+
SetAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
|
|
168
|
+
/**
|
|
169
|
+
* Sets the background colour of the window.
|
|
170
|
+
*
|
|
171
|
+
* @param r - The desired red component of the window background.
|
|
172
|
+
* @param g - The desired green component of the window background.
|
|
173
|
+
* @param b - The desired blue component of the window background.
|
|
174
|
+
* @param a - The desired alpha component of the window background.
|
|
175
|
+
*/
|
|
176
|
+
SetBackgroundColour(r: number, g: number, b: number, a: number): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Removes the window frame and title bar.
|
|
179
|
+
*
|
|
180
|
+
* @param frameless - Whether the window should be frameless.
|
|
181
|
+
*/
|
|
182
|
+
SetFrameless(frameless: boolean): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Disables the system fullscreen button.
|
|
185
|
+
*
|
|
186
|
+
* @param enabled - Whether the fullscreen button should be enabled.
|
|
187
|
+
*/
|
|
188
|
+
SetFullscreenButtonEnabled(enabled: boolean): Promise<void>;
|
|
189
|
+
/**
|
|
190
|
+
* Sets the maximum size of the window.
|
|
191
|
+
*
|
|
192
|
+
* @param width - The desired maximum width of the window.
|
|
193
|
+
* @param height - The desired maximum height of the window.
|
|
194
|
+
*/
|
|
195
|
+
SetMaxSize(width: number, height: number): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Sets the minimum size of the window.
|
|
198
|
+
*
|
|
199
|
+
* @param width - The desired minimum width of the window.
|
|
200
|
+
* @param height - The desired minimum height of the window.
|
|
201
|
+
*/
|
|
202
|
+
SetMinSize(width: number, height: number): Promise<void>;
|
|
203
|
+
/**
|
|
204
|
+
* Sets the relative position of the window to the screen.
|
|
205
|
+
*
|
|
206
|
+
* @param x - The desired horizontal relative position of the window.
|
|
207
|
+
* @param y - The desired vertical relative position of the window.
|
|
208
|
+
*/
|
|
209
|
+
SetRelativePosition(x: number, y: number): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Sets whether the window is resizable.
|
|
212
|
+
*
|
|
213
|
+
* @param resizable - Whether the window should be resizable.
|
|
214
|
+
*/
|
|
215
|
+
SetResizable(resizable: boolean): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Sets the size of the window.
|
|
218
|
+
*
|
|
219
|
+
* @param width - The desired width of the window.
|
|
220
|
+
* @param height - The desired height of the window.
|
|
221
|
+
*/
|
|
222
|
+
SetSize(width: number, height: number): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Sets the title of the window.
|
|
225
|
+
*
|
|
226
|
+
* @param title - The desired title of the window.
|
|
227
|
+
*/
|
|
228
|
+
SetTitle(title: string): Promise<void>;
|
|
229
|
+
/**
|
|
230
|
+
* Sets the zoom level of the window.
|
|
231
|
+
*
|
|
232
|
+
* @param zoom - The desired zoom level.
|
|
233
|
+
*/
|
|
234
|
+
SetZoom(zoom: number): Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* Shows the window.
|
|
237
|
+
*/
|
|
238
|
+
Show(): Promise<void>;
|
|
239
|
+
/**
|
|
240
|
+
* Returns the size of the window.
|
|
241
|
+
*
|
|
242
|
+
* @returns The current size of the window.
|
|
243
|
+
*/
|
|
244
|
+
Size(): Promise<Size>;
|
|
245
|
+
/**
|
|
246
|
+
* Toggles the window between fullscreen and normal.
|
|
247
|
+
*/
|
|
248
|
+
ToggleFullscreen(): Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* Toggles the window between maximised and normal.
|
|
251
|
+
*/
|
|
252
|
+
ToggleMaximise(): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* Toggles the window between frameless and normal.
|
|
255
|
+
*/
|
|
256
|
+
ToggleFrameless(): Promise<void>;
|
|
257
|
+
/**
|
|
258
|
+
* Un-fullscreens the window.
|
|
259
|
+
*/
|
|
260
|
+
UnFullscreen(): Promise<void>;
|
|
261
|
+
/**
|
|
262
|
+
* Un-maximises the window.
|
|
263
|
+
*/
|
|
264
|
+
UnMaximise(): Promise<void>;
|
|
265
|
+
/**
|
|
266
|
+
* Un-minimises the window.
|
|
267
|
+
*/
|
|
268
|
+
UnMinimise(): Promise<void>;
|
|
269
|
+
/**
|
|
270
|
+
* Returns the width of the window.
|
|
271
|
+
*
|
|
272
|
+
* @returns The current width of the window.
|
|
273
|
+
*/
|
|
274
|
+
Width(): Promise<number>;
|
|
275
|
+
/**
|
|
276
|
+
* Zooms the window.
|
|
277
|
+
*/
|
|
278
|
+
Zoom(): Promise<void>;
|
|
279
|
+
/**
|
|
280
|
+
* Increases the zoom level of the webview content.
|
|
281
|
+
*/
|
|
282
|
+
ZoomIn(): Promise<void>;
|
|
283
|
+
/**
|
|
284
|
+
* Decreases the zoom level of the webview content.
|
|
285
|
+
*/
|
|
286
|
+
ZoomOut(): Promise<void>;
|
|
287
|
+
/**
|
|
288
|
+
* Resets the zoom level of the webview content.
|
|
289
|
+
*/
|
|
290
|
+
ZoomReset(): Promise<void>;
|
|
291
|
+
/**
|
|
292
|
+
* Handles file drops originating from platform-specific code (e.g., macOS native drag-and-drop).
|
|
293
|
+
* Gathers information about the drop target element and sends it back to the Go backend.
|
|
294
|
+
*
|
|
295
|
+
* @param filenames - An array of file paths (strings) that were dropped.
|
|
296
|
+
* @param x - The x-coordinate of the drop event.
|
|
297
|
+
* @param y - The y-coordinate of the drop event.
|
|
298
|
+
*/
|
|
299
|
+
HandlePlatformFileDrop(filenames: string[], x: number, y: number): void;
|
|
300
|
+
SnapAssist(): Promise<void>;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* The window within which the script is running.
|
|
304
|
+
*/
|
|
305
|
+
declare const thisWindow: Window;
|
|
306
|
+
export default thisWindow;
|
package/types/wml.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schedules an automatic reload of WML to be performed as soon as the document is fully loaded.
|
|
3
|
+
*/
|
|
4
|
+
export declare function Enable(): void;
|
|
5
|
+
/**
|
|
6
|
+
* Reloads the WML page by adding necessary event listeners and browser listeners.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Reload(): void;
|
package/browser.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
13
|
-
|
|
14
|
-
const call = newRuntimeCallerWithID(objectNames.Browser, '');
|
|
15
|
-
const BrowserOpenURL = 0;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Open a browser window to the given URL
|
|
19
|
-
* @param {string} url - The URL to open
|
|
20
|
-
* @returns {Promise<string>}
|
|
21
|
-
*/
|
|
22
|
-
export function OpenURL(url) {
|
|
23
|
-
return call(BrowserOpenURL, {url});
|
|
24
|
-
}
|
package/calls.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
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
|
-
import { newRuntimeCallerWithID, objectNames } from "./runtime";
|
|
13
|
-
import { nanoid } from 'nanoid/non-secure';
|
|
14
|
-
|
|
15
|
-
const CallBinding = 0;
|
|
16
|
-
const call = newRuntimeCallerWithID(objectNames.Call, '');
|
|
17
|
-
let callResponses = new Map();
|
|
18
|
-
|
|
19
|
-
window._wails = window._wails || {};
|
|
20
|
-
window._wails.callCallback = resultHandler;
|
|
21
|
-
window._wails.callErrorCallback = errorHandler;
|
|
22
|
-
|
|
23
|
-
function generateID() {
|
|
24
|
-
let result;
|
|
25
|
-
do {
|
|
26
|
-
result = nanoid();
|
|
27
|
-
} while (callResponses.has(result));
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function resultHandler(id, data, isJSON) {
|
|
32
|
-
const promiseHandler = getAndDeleteResponse(id);
|
|
33
|
-
if (promiseHandler) {
|
|
34
|
-
promiseHandler.resolve(isJSON ? JSON.parse(data) : data);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function errorHandler(id, message) {
|
|
39
|
-
const promiseHandler = getAndDeleteResponse(id);
|
|
40
|
-
if (promiseHandler) {
|
|
41
|
-
promiseHandler.reject(message);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function getAndDeleteResponse(id) {
|
|
46
|
-
const response = callResponses.get(id);
|
|
47
|
-
callResponses.delete(id);
|
|
48
|
-
return response;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function callBinding(type, options = {}) {
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
const id = generateID();
|
|
54
|
-
options["call-id"] = id;
|
|
55
|
-
callResponses.set(id, { resolve, reject });
|
|
56
|
-
call(type, options).catch((error) => {
|
|
57
|
-
reject(error);
|
|
58
|
-
callResponses.delete(id);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Call method.
|
|
65
|
-
*
|
|
66
|
-
* @param {Object} options - The options for the method.
|
|
67
|
-
* @returns {Object} - The result of the call.
|
|
68
|
-
*/
|
|
69
|
-
export function Call(options) {
|
|
70
|
-
return callBinding(CallBinding, options);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Executes a method by name.
|
|
75
|
-
*
|
|
76
|
-
* @param {string} name - The name of the method in the format 'package.struct.method'.
|
|
77
|
-
* @param {...*} args - The arguments to pass to the method.
|
|
78
|
-
* @throws {Error} If the name is not a string or is not in the correct format.
|
|
79
|
-
* @returns {*} The result of the method execution.
|
|
80
|
-
*/
|
|
81
|
-
export function ByName(name, ...args) {
|
|
82
|
-
if (typeof name !== "string" || name.split(".").length !== 3) {
|
|
83
|
-
throw new Error("CallByName requires a string in the format 'package.struct.method'");
|
|
84
|
-
}
|
|
85
|
-
let [packageName, structName, methodName] = name.split(".");
|
|
86
|
-
return callBinding(CallBinding, {
|
|
87
|
-
packageName,
|
|
88
|
-
structName,
|
|
89
|
-
methodName,
|
|
90
|
-
args
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Calls a method by its ID with the specified arguments.
|
|
96
|
-
*
|
|
97
|
-
* @param {string} methodID - The ID of the method to call.
|
|
98
|
-
* @param {...*} args - The arguments to pass to the method.
|
|
99
|
-
* @return {*} - The result of the method call.
|
|
100
|
-
*/
|
|
101
|
-
export function ByID(methodID, ...args) {
|
|
102
|
-
return callBinding(CallBinding, {
|
|
103
|
-
methodID,
|
|
104
|
-
args
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Calls a method on a plugin.
|
|
110
|
-
*
|
|
111
|
-
* @param {string} pluginName - The name of the plugin.
|
|
112
|
-
* @param {string} methodName - The name of the method to call.
|
|
113
|
-
* @param {...*} args - The arguments to pass to the method.
|
|
114
|
-
* @returns {*} - The result of the method call.
|
|
115
|
-
*/
|
|
116
|
-
export function Plugin(pluginName, methodName, ...args) {
|
|
117
|
-
return callBinding(CallBinding, {
|
|
118
|
-
packageName: "wails-plugins",
|
|
119
|
-
structName: pluginName,
|
|
120
|
-
methodName,
|
|
121
|
-
args
|
|
122
|
-
});
|
|
123
|
-
}
|
package/clipboard.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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 {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
14
|
-
|
|
15
|
-
const call = newRuntimeCallerWithID(objectNames.Clipboard, '');
|
|
16
|
-
const ClipboardSetText = 0;
|
|
17
|
-
const ClipboardText = 1;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Sets the text to the Clipboard.
|
|
21
|
-
*
|
|
22
|
-
* @param {string} text - The text to be set to the Clipboard.
|
|
23
|
-
* @return {Promise} - A Promise that resolves when the operation is successful.
|
|
24
|
-
*/
|
|
25
|
-
export function SetText(text) {
|
|
26
|
-
return call(ClipboardSetText, {text});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Get the Clipboard text
|
|
31
|
-
* @returns {Promise<string>} A promise that resolves with the text from the Clipboard.
|
|
32
|
-
*/
|
|
33
|
-
export function Text() {
|
|
34
|
-
return call(ClipboardText);
|
|
35
|
-
}
|
package/contextmenu.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
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 {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
14
|
-
import {IsDebug} from "./system";
|
|
15
|
-
|
|
16
|
-
const call = newRuntimeCallerWithID(objectNames.ContextMenu, '');
|
|
17
|
-
const ContextMenuOpen = 0;
|
|
18
|
-
|
|
19
|
-
function openContextMenu(id, x, y, data) {
|
|
20
|
-
void call(ContextMenuOpen, {id, x, y, data});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function setupContextMenus() {
|
|
24
|
-
window.addEventListener('contextmenu', contextMenuHandler);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function contextMenuHandler(event) {
|
|
28
|
-
// Check for custom context menu
|
|
29
|
-
let element = event.target;
|
|
30
|
-
let customContextMenu = window.getComputedStyle(element).getPropertyValue("--custom-contextmenu");
|
|
31
|
-
customContextMenu = customContextMenu ? customContextMenu.trim() : "";
|
|
32
|
-
if (customContextMenu) {
|
|
33
|
-
event.preventDefault();
|
|
34
|
-
let customContextMenuData = window.getComputedStyle(element).getPropertyValue("--custom-contextmenu-data");
|
|
35
|
-
openContextMenu(customContextMenu, event.clientX, event.clientY, customContextMenuData);
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
processDefaultContextMenu(event);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/*
|
|
44
|
-
--default-contextmenu: auto; (default) will show the default context menu if contentEditable is true OR text has been selected OR element is input or textarea
|
|
45
|
-
--default-contextmenu: show; will always show the default context menu
|
|
46
|
-
--default-contextmenu: hide; will always hide the default context menu
|
|
47
|
-
|
|
48
|
-
This rule is inherited like normal CSS rules, so nesting works as expected
|
|
49
|
-
*/
|
|
50
|
-
function processDefaultContextMenu(event) {
|
|
51
|
-
|
|
52
|
-
// Debug builds always show the menu
|
|
53
|
-
if (IsDebug()) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Process default context menu
|
|
58
|
-
const element = event.target;
|
|
59
|
-
const computedStyle = window.getComputedStyle(element);
|
|
60
|
-
const defaultContextMenuAction = computedStyle.getPropertyValue("--default-contextmenu").trim();
|
|
61
|
-
switch (defaultContextMenuAction) {
|
|
62
|
-
case "show":
|
|
63
|
-
return;
|
|
64
|
-
case "hide":
|
|
65
|
-
event.preventDefault();
|
|
66
|
-
return;
|
|
67
|
-
default:
|
|
68
|
-
// Check if contentEditable is true
|
|
69
|
-
if (element.isContentEditable) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Check if text has been selected
|
|
74
|
-
const selection = window.getSelection();
|
|
75
|
-
const hasSelection = (selection.toString().length > 0)
|
|
76
|
-
if (hasSelection) {
|
|
77
|
-
for (let i = 0; i < selection.rangeCount; i++) {
|
|
78
|
-
const range = selection.getRangeAt(i);
|
|
79
|
-
const rects = range.getClientRects();
|
|
80
|
-
for (let j = 0; j < rects.length; j++) {
|
|
81
|
-
const rect = rects[j];
|
|
82
|
-
if (document.elementFromPoint(rect.left, rect.top) === element) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// Check if tagname is input or textarea
|
|
89
|
-
if (element.tagName === "INPUT" || element.tagName === "TEXTAREA") {
|
|
90
|
-
if (hasSelection || (!element.readOnly && !element.disabled)) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// hide default context menu
|
|
96
|
-
event.preventDefault();
|
|
97
|
-
}
|
|
98
|
-
}
|