@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.
Files changed (59) hide show
  1. package/{application.js → dist/application.js} +32 -46
  2. package/dist/browser.js +20 -0
  3. package/dist/callable.js +144 -0
  4. package/dist/calls.js +194 -0
  5. package/dist/cancellable.js +792 -0
  6. package/dist/clipboard.js +30 -0
  7. package/dist/contextmenu.js +80 -0
  8. package/dist/create.js +94 -0
  9. package/dist/dialogs.js +134 -0
  10. package/dist/drag.js +222 -0
  11. package/dist/event_types.js +232 -0
  12. package/dist/events.js +114 -0
  13. package/dist/flags.js +23 -0
  14. package/dist/index.js +42 -0
  15. package/dist/listener.js +44 -0
  16. package/dist/nanoid.js +38 -0
  17. package/dist/runtime.js +63 -0
  18. package/{screens.js → dist/screens.js} +38 -45
  19. package/dist/system.js +146 -0
  20. package/dist/utils.js +95 -0
  21. package/dist/window.js +570 -0
  22. package/dist/wml.js +179 -0
  23. package/package.json +62 -18
  24. package/types/application.d.ts +12 -0
  25. package/types/browser.d.ts +6 -0
  26. package/types/callable.d.ts +3 -0
  27. package/types/calls.d.ts +63 -0
  28. package/types/cancellable.d.ts +434 -0
  29. package/types/clipboard.d.ts +13 -0
  30. package/types/contextmenu.d.ts +1 -0
  31. package/types/create.d.ts +31 -0
  32. package/types/dialogs.d.ts +140 -0
  33. package/types/drag.d.ts +1 -0
  34. package/types/event_types.d.ts +221 -0
  35. package/types/events.d.ts +67 -0
  36. package/types/flags.d.ts +7 -0
  37. package/types/index.d.ts +16 -0
  38. package/types/listener.d.ts +9 -0
  39. package/types/nanoid.d.ts +1 -0
  40. package/types/runtime.d.ts +22 -0
  41. package/types/screens.d.ts +60 -0
  42. package/types/system.d.ts +92 -0
  43. package/types/utils.d.ts +21 -0
  44. package/types/window.d.ts +306 -0
  45. package/types/wml.d.ts +8 -0
  46. package/browser.js +0 -24
  47. package/calls.js +0 -123
  48. package/clipboard.js +0 -35
  49. package/contextmenu.js +0 -98
  50. package/dialogs.js +0 -138
  51. package/drag.js +0 -125
  52. package/events.js +0 -134
  53. package/flags.js +0 -63
  54. package/index.js +0 -56
  55. package/runtime.js +0 -122
  56. package/system.js +0 -122
  57. package/types.d.ts +0 -135
  58. package/window.js +0 -122
  59. package/wml.js +0 -151
@@ -0,0 +1,232 @@
1
+ /*
2
+ _ __ _ __
3
+ | | / /___ _(_) /____
4
+ | | /| / / __ `/ / / ___/
5
+ | |/ |/ / /_/ / / (__ )
6
+ |__/|__/\__,_/_/_/____/
7
+ The electron alternative for Go
8
+ (c) Lea Anthony 2019-present
9
+ */
10
+ // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
11
+ // This file is automatically generated. DO NOT EDIT
12
+ export const Types = Object.freeze({
13
+ Windows: Object.freeze({
14
+ APMPowerSettingChange: "windows:APMPowerSettingChange",
15
+ APMPowerStatusChange: "windows:APMPowerStatusChange",
16
+ APMResumeAutomatic: "windows:APMResumeAutomatic",
17
+ APMResumeSuspend: "windows:APMResumeSuspend",
18
+ APMSuspend: "windows:APMSuspend",
19
+ ApplicationStarted: "windows:ApplicationStarted",
20
+ SystemThemeChanged: "windows:SystemThemeChanged",
21
+ WebViewNavigationCompleted: "windows:WebViewNavigationCompleted",
22
+ WindowActive: "windows:WindowActive",
23
+ WindowBackgroundErase: "windows:WindowBackgroundErase",
24
+ WindowClickActive: "windows:WindowClickActive",
25
+ WindowClosing: "windows:WindowClosing",
26
+ WindowDidMove: "windows:WindowDidMove",
27
+ WindowDidResize: "windows:WindowDidResize",
28
+ WindowDPIChanged: "windows:WindowDPIChanged",
29
+ WindowDragDrop: "windows:WindowDragDrop",
30
+ WindowDragEnter: "windows:WindowDragEnter",
31
+ WindowDragLeave: "windows:WindowDragLeave",
32
+ WindowDragOver: "windows:WindowDragOver",
33
+ WindowEndMove: "windows:WindowEndMove",
34
+ WindowEndResize: "windows:WindowEndResize",
35
+ WindowFullscreen: "windows:WindowFullscreen",
36
+ WindowHide: "windows:WindowHide",
37
+ WindowInactive: "windows:WindowInactive",
38
+ WindowKeyDown: "windows:WindowKeyDown",
39
+ WindowKeyUp: "windows:WindowKeyUp",
40
+ WindowKillFocus: "windows:WindowKillFocus",
41
+ WindowNonClientHit: "windows:WindowNonClientHit",
42
+ WindowNonClientMouseDown: "windows:WindowNonClientMouseDown",
43
+ WindowNonClientMouseLeave: "windows:WindowNonClientMouseLeave",
44
+ WindowNonClientMouseMove: "windows:WindowNonClientMouseMove",
45
+ WindowNonClientMouseUp: "windows:WindowNonClientMouseUp",
46
+ WindowPaint: "windows:WindowPaint",
47
+ WindowRestore: "windows:WindowRestore",
48
+ WindowSetFocus: "windows:WindowSetFocus",
49
+ WindowShow: "windows:WindowShow",
50
+ WindowStartMove: "windows:WindowStartMove",
51
+ WindowStartResize: "windows:WindowStartResize",
52
+ WindowUnFullscreen: "windows:WindowUnFullscreen",
53
+ WindowZOrderChanged: "windows:WindowZOrderChanged",
54
+ WindowMinimise: "windows:WindowMinimise",
55
+ WindowUnMinimise: "windows:WindowUnMinimise",
56
+ WindowMaximise: "windows:WindowMaximise",
57
+ WindowUnMaximise: "windows:WindowUnMaximise",
58
+ }),
59
+ Mac: Object.freeze({
60
+ ApplicationDidBecomeActive: "mac:ApplicationDidBecomeActive",
61
+ ApplicationDidChangeBackingProperties: "mac:ApplicationDidChangeBackingProperties",
62
+ ApplicationDidChangeEffectiveAppearance: "mac:ApplicationDidChangeEffectiveAppearance",
63
+ ApplicationDidChangeIcon: "mac:ApplicationDidChangeIcon",
64
+ ApplicationDidChangeOcclusionState: "mac:ApplicationDidChangeOcclusionState",
65
+ ApplicationDidChangeScreenParameters: "mac:ApplicationDidChangeScreenParameters",
66
+ ApplicationDidChangeStatusBarFrame: "mac:ApplicationDidChangeStatusBarFrame",
67
+ ApplicationDidChangeStatusBarOrientation: "mac:ApplicationDidChangeStatusBarOrientation",
68
+ ApplicationDidChangeTheme: "mac:ApplicationDidChangeTheme",
69
+ ApplicationDidFinishLaunching: "mac:ApplicationDidFinishLaunching",
70
+ ApplicationDidHide: "mac:ApplicationDidHide",
71
+ ApplicationDidResignActive: "mac:ApplicationDidResignActive",
72
+ ApplicationDidUnhide: "mac:ApplicationDidUnhide",
73
+ ApplicationDidUpdate: "mac:ApplicationDidUpdate",
74
+ ApplicationShouldHandleReopen: "mac:ApplicationShouldHandleReopen",
75
+ ApplicationWillBecomeActive: "mac:ApplicationWillBecomeActive",
76
+ ApplicationWillFinishLaunching: "mac:ApplicationWillFinishLaunching",
77
+ ApplicationWillHide: "mac:ApplicationWillHide",
78
+ ApplicationWillResignActive: "mac:ApplicationWillResignActive",
79
+ ApplicationWillTerminate: "mac:ApplicationWillTerminate",
80
+ ApplicationWillUnhide: "mac:ApplicationWillUnhide",
81
+ ApplicationWillUpdate: "mac:ApplicationWillUpdate",
82
+ MenuDidAddItem: "mac:MenuDidAddItem",
83
+ MenuDidBeginTracking: "mac:MenuDidBeginTracking",
84
+ MenuDidClose: "mac:MenuDidClose",
85
+ MenuDidDisplayItem: "mac:MenuDidDisplayItem",
86
+ MenuDidEndTracking: "mac:MenuDidEndTracking",
87
+ MenuDidHighlightItem: "mac:MenuDidHighlightItem",
88
+ MenuDidOpen: "mac:MenuDidOpen",
89
+ MenuDidPopUp: "mac:MenuDidPopUp",
90
+ MenuDidRemoveItem: "mac:MenuDidRemoveItem",
91
+ MenuDidSendAction: "mac:MenuDidSendAction",
92
+ MenuDidSendActionToItem: "mac:MenuDidSendActionToItem",
93
+ MenuDidUpdate: "mac:MenuDidUpdate",
94
+ MenuWillAddItem: "mac:MenuWillAddItem",
95
+ MenuWillBeginTracking: "mac:MenuWillBeginTracking",
96
+ MenuWillDisplayItem: "mac:MenuWillDisplayItem",
97
+ MenuWillEndTracking: "mac:MenuWillEndTracking",
98
+ MenuWillHighlightItem: "mac:MenuWillHighlightItem",
99
+ MenuWillOpen: "mac:MenuWillOpen",
100
+ MenuWillPopUp: "mac:MenuWillPopUp",
101
+ MenuWillRemoveItem: "mac:MenuWillRemoveItem",
102
+ MenuWillSendAction: "mac:MenuWillSendAction",
103
+ MenuWillSendActionToItem: "mac:MenuWillSendActionToItem",
104
+ MenuWillUpdate: "mac:MenuWillUpdate",
105
+ WebViewDidCommitNavigation: "mac:WebViewDidCommitNavigation",
106
+ WebViewDidFinishNavigation: "mac:WebViewDidFinishNavigation",
107
+ WebViewDidReceiveServerRedirectForProvisionalNavigation: "mac:WebViewDidReceiveServerRedirectForProvisionalNavigation",
108
+ WebViewDidStartProvisionalNavigation: "mac:WebViewDidStartProvisionalNavigation",
109
+ WindowDidBecomeKey: "mac:WindowDidBecomeKey",
110
+ WindowDidBecomeMain: "mac:WindowDidBecomeMain",
111
+ WindowDidBeginSheet: "mac:WindowDidBeginSheet",
112
+ WindowDidChangeAlpha: "mac:WindowDidChangeAlpha",
113
+ WindowDidChangeBackingLocation: "mac:WindowDidChangeBackingLocation",
114
+ WindowDidChangeBackingProperties: "mac:WindowDidChangeBackingProperties",
115
+ WindowDidChangeCollectionBehavior: "mac:WindowDidChangeCollectionBehavior",
116
+ WindowDidChangeEffectiveAppearance: "mac:WindowDidChangeEffectiveAppearance",
117
+ WindowDidChangeOcclusionState: "mac:WindowDidChangeOcclusionState",
118
+ WindowDidChangeOrderingMode: "mac:WindowDidChangeOrderingMode",
119
+ WindowDidChangeScreen: "mac:WindowDidChangeScreen",
120
+ WindowDidChangeScreenParameters: "mac:WindowDidChangeScreenParameters",
121
+ WindowDidChangeScreenProfile: "mac:WindowDidChangeScreenProfile",
122
+ WindowDidChangeScreenSpace: "mac:WindowDidChangeScreenSpace",
123
+ WindowDidChangeScreenSpaceProperties: "mac:WindowDidChangeScreenSpaceProperties",
124
+ WindowDidChangeSharingType: "mac:WindowDidChangeSharingType",
125
+ WindowDidChangeSpace: "mac:WindowDidChangeSpace",
126
+ WindowDidChangeSpaceOrderingMode: "mac:WindowDidChangeSpaceOrderingMode",
127
+ WindowDidChangeTitle: "mac:WindowDidChangeTitle",
128
+ WindowDidChangeToolbar: "mac:WindowDidChangeToolbar",
129
+ WindowDidDeminiaturize: "mac:WindowDidDeminiaturize",
130
+ WindowDidEndSheet: "mac:WindowDidEndSheet",
131
+ WindowDidEnterFullScreen: "mac:WindowDidEnterFullScreen",
132
+ WindowDidEnterVersionBrowser: "mac:WindowDidEnterVersionBrowser",
133
+ WindowDidExitFullScreen: "mac:WindowDidExitFullScreen",
134
+ WindowDidExitVersionBrowser: "mac:WindowDidExitVersionBrowser",
135
+ WindowDidExpose: "mac:WindowDidExpose",
136
+ WindowDidFocus: "mac:WindowDidFocus",
137
+ WindowDidMiniaturize: "mac:WindowDidMiniaturize",
138
+ WindowDidMove: "mac:WindowDidMove",
139
+ WindowDidOrderOffScreen: "mac:WindowDidOrderOffScreen",
140
+ WindowDidOrderOnScreen: "mac:WindowDidOrderOnScreen",
141
+ WindowDidResignKey: "mac:WindowDidResignKey",
142
+ WindowDidResignMain: "mac:WindowDidResignMain",
143
+ WindowDidResize: "mac:WindowDidResize",
144
+ WindowDidUpdate: "mac:WindowDidUpdate",
145
+ WindowDidUpdateAlpha: "mac:WindowDidUpdateAlpha",
146
+ WindowDidUpdateCollectionBehavior: "mac:WindowDidUpdateCollectionBehavior",
147
+ WindowDidUpdateCollectionProperties: "mac:WindowDidUpdateCollectionProperties",
148
+ WindowDidUpdateShadow: "mac:WindowDidUpdateShadow",
149
+ WindowDidUpdateTitle: "mac:WindowDidUpdateTitle",
150
+ WindowDidUpdateToolbar: "mac:WindowDidUpdateToolbar",
151
+ WindowDidZoom: "mac:WindowDidZoom",
152
+ WindowFileDraggingEntered: "mac:WindowFileDraggingEntered",
153
+ WindowFileDraggingExited: "mac:WindowFileDraggingExited",
154
+ WindowFileDraggingPerformed: "mac:WindowFileDraggingPerformed",
155
+ WindowHide: "mac:WindowHide",
156
+ WindowMaximise: "mac:WindowMaximise",
157
+ WindowUnMaximise: "mac:WindowUnMaximise",
158
+ WindowMinimise: "mac:WindowMinimise",
159
+ WindowUnMinimise: "mac:WindowUnMinimise",
160
+ WindowShouldClose: "mac:WindowShouldClose",
161
+ WindowShow: "mac:WindowShow",
162
+ WindowWillBecomeKey: "mac:WindowWillBecomeKey",
163
+ WindowWillBecomeMain: "mac:WindowWillBecomeMain",
164
+ WindowWillBeginSheet: "mac:WindowWillBeginSheet",
165
+ WindowWillChangeOrderingMode: "mac:WindowWillChangeOrderingMode",
166
+ WindowWillClose: "mac:WindowWillClose",
167
+ WindowWillDeminiaturize: "mac:WindowWillDeminiaturize",
168
+ WindowWillEnterFullScreen: "mac:WindowWillEnterFullScreen",
169
+ WindowWillEnterVersionBrowser: "mac:WindowWillEnterVersionBrowser",
170
+ WindowWillExitFullScreen: "mac:WindowWillExitFullScreen",
171
+ WindowWillExitVersionBrowser: "mac:WindowWillExitVersionBrowser",
172
+ WindowWillFocus: "mac:WindowWillFocus",
173
+ WindowWillMiniaturize: "mac:WindowWillMiniaturize",
174
+ WindowWillMove: "mac:WindowWillMove",
175
+ WindowWillOrderOffScreen: "mac:WindowWillOrderOffScreen",
176
+ WindowWillOrderOnScreen: "mac:WindowWillOrderOnScreen",
177
+ WindowWillResignMain: "mac:WindowWillResignMain",
178
+ WindowWillResize: "mac:WindowWillResize",
179
+ WindowWillUnfocus: "mac:WindowWillUnfocus",
180
+ WindowWillUpdate: "mac:WindowWillUpdate",
181
+ WindowWillUpdateAlpha: "mac:WindowWillUpdateAlpha",
182
+ WindowWillUpdateCollectionBehavior: "mac:WindowWillUpdateCollectionBehavior",
183
+ WindowWillUpdateCollectionProperties: "mac:WindowWillUpdateCollectionProperties",
184
+ WindowWillUpdateShadow: "mac:WindowWillUpdateShadow",
185
+ WindowWillUpdateTitle: "mac:WindowWillUpdateTitle",
186
+ WindowWillUpdateToolbar: "mac:WindowWillUpdateToolbar",
187
+ WindowWillUpdateVisibility: "mac:WindowWillUpdateVisibility",
188
+ WindowWillUseStandardFrame: "mac:WindowWillUseStandardFrame",
189
+ WindowZoomIn: "mac:WindowZoomIn",
190
+ WindowZoomOut: "mac:WindowZoomOut",
191
+ WindowZoomReset: "mac:WindowZoomReset",
192
+ }),
193
+ Linux: Object.freeze({
194
+ ApplicationStartup: "linux:ApplicationStartup",
195
+ SystemThemeChanged: "linux:SystemThemeChanged",
196
+ WindowDeleteEvent: "linux:WindowDeleteEvent",
197
+ WindowDidMove: "linux:WindowDidMove",
198
+ WindowDidResize: "linux:WindowDidResize",
199
+ WindowFocusIn: "linux:WindowFocusIn",
200
+ WindowFocusOut: "linux:WindowFocusOut",
201
+ WindowLoadChanged: "linux:WindowLoadChanged",
202
+ }),
203
+ Common: Object.freeze({
204
+ ApplicationOpenedWithFile: "common:ApplicationOpenedWithFile",
205
+ ApplicationStarted: "common:ApplicationStarted",
206
+ ApplicationLaunchedWithUrl: "common:ApplicationLaunchedWithUrl",
207
+ ThemeChanged: "common:ThemeChanged",
208
+ WindowClosing: "common:WindowClosing",
209
+ WindowDidMove: "common:WindowDidMove",
210
+ WindowDidResize: "common:WindowDidResize",
211
+ WindowDPIChanged: "common:WindowDPIChanged",
212
+ WindowFilesDropped: "common:WindowFilesDropped",
213
+ WindowFocus: "common:WindowFocus",
214
+ WindowFullscreen: "common:WindowFullscreen",
215
+ WindowHide: "common:WindowHide",
216
+ WindowLostFocus: "common:WindowLostFocus",
217
+ WindowMaximise: "common:WindowMaximise",
218
+ WindowMinimise: "common:WindowMinimise",
219
+ WindowToggleFrameless: "common:WindowToggleFrameless",
220
+ WindowRestore: "common:WindowRestore",
221
+ WindowRuntimeReady: "common:WindowRuntimeReady",
222
+ WindowShow: "common:WindowShow",
223
+ WindowUnFullscreen: "common:WindowUnFullscreen",
224
+ WindowUnMaximise: "common:WindowUnMaximise",
225
+ WindowUnMinimise: "common:WindowUnMinimise",
226
+ WindowZoom: "common:WindowZoom",
227
+ WindowZoomIn: "common:WindowZoomIn",
228
+ WindowZoomOut: "common:WindowZoomOut",
229
+ WindowZoomReset: "common:WindowZoomReset",
230
+ WindowDropZoneFilesDropped: "common:WindowDropZoneFilesDropped",
231
+ }),
232
+ });
package/dist/events.js ADDED
@@ -0,0 +1,114 @@
1
+ /*
2
+ _ __ _ __
3
+ | | / /___ _(_) /____
4
+ | | /| / / __ `/ / / ___/
5
+ | |/ |/ / /_/ / / (__ )
6
+ |__/|__/\__,_/_/_/____/
7
+ The electron alternative for Go
8
+ (c) Lea Anthony 2019-present
9
+ */
10
+ import { newRuntimeCaller, objectNames } from "./runtime.js";
11
+ import { eventListeners, Listener, listenerOff } from "./listener.js";
12
+ // Setup
13
+ window._wails = window._wails || {};
14
+ window._wails.dispatchWailsEvent = dispatchWailsEvent;
15
+ const call = newRuntimeCaller(objectNames.Events);
16
+ const EmitMethod = 0;
17
+ export { Types } from "./event_types.js";
18
+ /**
19
+ * Represents a system event or a custom event emitted through wails-provided facilities.
20
+ */
21
+ export class WailsEvent {
22
+ constructor(name, data = null) {
23
+ this.name = name;
24
+ this.data = data;
25
+ }
26
+ }
27
+ function dispatchWailsEvent(event) {
28
+ let listeners = eventListeners.get(event.name);
29
+ if (!listeners) {
30
+ return;
31
+ }
32
+ let wailsEvent = new WailsEvent(event.name, event.data);
33
+ if ('sender' in event) {
34
+ wailsEvent.sender = event.sender;
35
+ }
36
+ listeners = listeners.filter(listener => !listener.dispatch(wailsEvent));
37
+ if (listeners.length === 0) {
38
+ eventListeners.delete(event.name);
39
+ }
40
+ else {
41
+ eventListeners.set(event.name, listeners);
42
+ }
43
+ }
44
+ /**
45
+ * Register a callback function to be called multiple times for a specific event.
46
+ *
47
+ * @param eventName - The name of the event to register the callback for.
48
+ * @param callback - The callback function to be called when the event is triggered.
49
+ * @param maxCallbacks - The maximum number of times the callback can be called for the event. Once the maximum number is reached, the callback will no longer be called.
50
+ * @returns A function that, when called, will unregister the callback from the event.
51
+ */
52
+ export function OnMultiple(eventName, callback, maxCallbacks) {
53
+ let listeners = eventListeners.get(eventName) || [];
54
+ const thisListener = new Listener(eventName, callback, maxCallbacks);
55
+ listeners.push(thisListener);
56
+ eventListeners.set(eventName, listeners);
57
+ return () => listenerOff(thisListener);
58
+ }
59
+ /**
60
+ * Registers a callback function to be executed when the specified event occurs.
61
+ *
62
+ * @param eventName - The name of the event to register the callback for.
63
+ * @param callback - The callback function to be called when the event is triggered.
64
+ * @returns A function that, when called, will unregister the callback from the event.
65
+ */
66
+ export function On(eventName, callback) {
67
+ return OnMultiple(eventName, callback, -1);
68
+ }
69
+ /**
70
+ * Registers a callback function to be executed only once for the specified event.
71
+ *
72
+ * @param eventName - The name of the event to register the callback for.
73
+ * @param callback - The callback function to be called when the event is triggered.
74
+ * @returns A function that, when called, will unregister the callback from the event.
75
+ */
76
+ export function Once(eventName, callback) {
77
+ return OnMultiple(eventName, callback, 1);
78
+ }
79
+ /**
80
+ * Removes event listeners for the specified event names.
81
+ *
82
+ * @param eventNames - The name of the events to remove listeners for.
83
+ */
84
+ export function Off(...eventNames) {
85
+ eventNames.forEach(eventName => eventListeners.delete(eventName));
86
+ }
87
+ /**
88
+ * Removes all event listeners.
89
+ */
90
+ export function OffAll() {
91
+ eventListeners.clear();
92
+ }
93
+ /**
94
+ * Emits an event using the name and data.
95
+ *
96
+ * @returns A promise that will be fulfilled once the event has been emitted.
97
+ * @param name - the name of the event to emit.
98
+ * @param data - the data to be sent with the event.
99
+ */
100
+ export function Emit(name, data) {
101
+ let eventName;
102
+ let eventData;
103
+ if (typeof name === 'object' && name !== null && 'name' in name && 'data' in name) {
104
+ // If name is an object with a name property, use it directly
105
+ eventName = name['name'];
106
+ eventData = name['data'];
107
+ }
108
+ else {
109
+ // Otherwise use the standard parameters
110
+ eventName = name;
111
+ eventData = data;
112
+ }
113
+ return call(EmitMethod, { name: eventName, data: eventData });
114
+ }
package/dist/flags.js ADDED
@@ -0,0 +1,23 @@
1
+ /*
2
+ _ __ _ __
3
+ | | / /___ _(_) /____
4
+ | | /| / / __ `/ / / ___/
5
+ | |/ |/ / /_/ / / (__ )
6
+ |__/|__/\__,_/_/_/____/
7
+ The electron alternative for Go
8
+ (c) Lea Anthony 2019-present
9
+ */
10
+ /**
11
+ * Retrieves the value associated with the specified key from the flag map.
12
+ *
13
+ * @param key - The key to retrieve the value for.
14
+ * @return The value associated with the specified key.
15
+ */
16
+ export function GetFlag(key) {
17
+ try {
18
+ return window._wails.flags[key];
19
+ }
20
+ catch (e) {
21
+ throw new Error("Unable to retrieve flag '" + key + "': " + e, { cause: e });
22
+ }
23
+ }
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ /*
2
+ _ __ _ __
3
+ | | / /___ _(_) /____
4
+ | | /| / / __ `/ / / ___/
5
+ | |/ |/ / /_/ / / (__ )
6
+ |__/|__/\__,_/_/_/____/
7
+ The electron alternative for Go
8
+ (c) Lea Anthony 2019-present
9
+ */
10
+ // Setup
11
+ window._wails = window._wails || {};
12
+ import "./contextmenu.js";
13
+ import "./drag.js";
14
+ // Re-export public API
15
+ import * as Application from "./application.js";
16
+ import * as Browser from "./browser.js";
17
+ import * as Call from "./calls.js";
18
+ import * as Clipboard from "./clipboard.js";
19
+ import * as Create from "./create.js";
20
+ import * as Dialogs from "./dialogs.js";
21
+ import * as Events from "./events.js";
22
+ import * as Flags from "./flags.js";
23
+ import * as Screens from "./screens.js";
24
+ import * as System from "./system.js";
25
+ import Window from "./window.js";
26
+ import * as WML from "./wml.js";
27
+ export { Application, Browser, Call, Clipboard, Dialogs, Events, Flags, Screens, System, Window, WML };
28
+ /**
29
+ * An internal utility consumed by the binding generator.
30
+ *
31
+ * @ignore
32
+ * @internal
33
+ */
34
+ export { Create };
35
+ export * from "./cancellable.js";
36
+ // Notify backend
37
+ window._wails.invoke = System.invoke;
38
+ // Register platform handlers (internal API)
39
+ // Note: Window is the thisWindow instance (default export from window.ts)
40
+ // Binding ensures 'this' correctly refers to the current window instance
41
+ window._wails.handlePlatformFileDrop = Window.HandlePlatformFileDrop.bind(Window);
42
+ System.invoke("wails:runtime:ready");
@@ -0,0 +1,44 @@
1
+ /*
2
+ _ __ _ __
3
+ | | / /___ _(_) /____
4
+ | | /| / / __ `/ / / ___/
5
+ | |/ |/ / /_/ / / (__ )
6
+ |__/|__/\__,_/_/_/____/
7
+ The electron alternative for Go
8
+ (c) Lea Anthony 2019-present
9
+ */
10
+ // The following utilities have been factored out of ./events.ts
11
+ // for testing purposes.
12
+ export const eventListeners = new Map();
13
+ export class Listener {
14
+ constructor(eventName, callback, maxCallbacks) {
15
+ this.eventName = eventName;
16
+ this.callback = callback;
17
+ this.maxCallbacks = maxCallbacks || -1;
18
+ }
19
+ dispatch(data) {
20
+ try {
21
+ this.callback(data);
22
+ }
23
+ catch (err) {
24
+ console.error(err);
25
+ }
26
+ if (this.maxCallbacks === -1)
27
+ return false;
28
+ this.maxCallbacks -= 1;
29
+ return this.maxCallbacks === 0;
30
+ }
31
+ }
32
+ export function listenerOff(listener) {
33
+ let listeners = eventListeners.get(listener.eventName);
34
+ if (!listeners) {
35
+ return;
36
+ }
37
+ listeners = listeners.filter(l => l !== listener);
38
+ if (listeners.length === 0) {
39
+ eventListeners.delete(listener.eventName);
40
+ }
41
+ else {
42
+ eventListeners.set(listener.eventName, listeners);
43
+ }
44
+ }
package/dist/nanoid.js ADDED
@@ -0,0 +1,38 @@
1
+ // Source: https://github.com/ai/nanoid
2
+ // The MIT License (MIT)
3
+ //
4
+ // Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ // this software and associated documentation files (the "Software"), to deal in
8
+ // the Software without restriction, including without limitation the rights to
9
+ // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ // the Software, and to permit persons to whom the Software is furnished to do so,
11
+ // subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in all
14
+ // copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ // This alphabet uses `A-Za-z0-9_-` symbols.
23
+ // The order of characters is optimized for better gzip and brotli compression.
24
+ // References to the same file (works both for gzip and brotli):
25
+ // `'use`, `andom`, and `rict'`
26
+ // References to the brotli default dictionary:
27
+ // `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
28
+ const urlAlphabet = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
29
+ export function nanoid(size = 21) {
30
+ let id = '';
31
+ // A compact alternative for `for (var i = 0; i < step; i++)`.
32
+ let i = size | 0;
33
+ while (i--) {
34
+ // `| 0` is more compact and faster than `Math.floor()`.
35
+ id += urlAlphabet[(Math.random() * 64) | 0];
36
+ }
37
+ return id;
38
+ }
@@ -0,0 +1,63 @@
1
+ /*
2
+ _ __ _ __
3
+ | | / /___ _(_) /____
4
+ | | /| / / __ `/ / / ___/
5
+ | |/ |/ / /_/ / / (__ )
6
+ |__/|__/\__,_/_/_/____/
7
+ The electron alternative for Go
8
+ (c) Lea Anthony 2019-present
9
+ */
10
+ import { nanoid } from './nanoid.js';
11
+ const runtimeURL = window.location.origin + "/wails/runtime";
12
+ // Object Names
13
+ export const objectNames = Object.freeze({
14
+ Call: 0,
15
+ Clipboard: 1,
16
+ Application: 2,
17
+ Events: 3,
18
+ ContextMenu: 4,
19
+ Dialog: 5,
20
+ Window: 6,
21
+ Screens: 7,
22
+ System: 8,
23
+ Browser: 9,
24
+ CancelCall: 10,
25
+ });
26
+ export let clientId = nanoid();
27
+ /**
28
+ * Creates a new runtime caller with specified ID.
29
+ *
30
+ * @param object - The object to invoke the method on.
31
+ * @param windowName - The name of the window.
32
+ * @return The new runtime caller function.
33
+ */
34
+ export function newRuntimeCaller(object, windowName = '') {
35
+ return function (method, args = null) {
36
+ return runtimeCallWithID(object, method, windowName, args);
37
+ };
38
+ }
39
+ async function runtimeCallWithID(objectID, method, windowName, args) {
40
+ var _a, _b;
41
+ let url = new URL(runtimeURL);
42
+ url.searchParams.append("object", objectID.toString());
43
+ url.searchParams.append("method", method.toString());
44
+ if (args) {
45
+ url.searchParams.append("args", JSON.stringify(args));
46
+ }
47
+ let headers = {
48
+ ["x-wails-client-id"]: clientId
49
+ };
50
+ if (windowName) {
51
+ headers["x-wails-window-name"] = windowName;
52
+ }
53
+ let response = await fetch(url, { headers });
54
+ if (!response.ok) {
55
+ throw new Error(await response.text());
56
+ }
57
+ if (((_b = (_a = response.headers.get("Content-Type")) === null || _a === void 0 ? void 0 : _a.indexOf("application/json")) !== null && _b !== void 0 ? _b : -1) !== -1) {
58
+ return response.json();
59
+ }
60
+ else {
61
+ return response.text();
62
+ }
63
+ }
@@ -1,45 +1,38 @@
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
- /**
14
- * @typedef {import("./api/types").Screen} Screen
15
- */
16
-
17
- import {newRuntimeCallerWithID, objectNames} from "./runtime";
18
- const call = newRuntimeCallerWithID(objectNames.Screens, '');
19
-
20
- const getAll = 0;
21
- const getPrimary = 1;
22
- const getCurrent = 2;
23
-
24
- /**
25
- * Gets all screens.
26
- * @returns {Promise<Screen[]>} A promise that resolves to an array of Screen objects.
27
- */
28
- export function GetAll() {
29
- return call(getAll);
30
- }
31
- /**
32
- * Gets the primary screen.
33
- * @returns {Promise<Screen>} A promise that resolves to the primary screen.
34
- */
35
- export function GetPrimary() {
36
- return call(getPrimary);
37
- }
38
- /**
39
- * Gets the current active screen.
40
- *
41
- * @returns {Promise<Screen>} A promise that resolves with the current active screen.
42
- */
43
- export function GetCurrent() {
44
- return call(getCurrent);
45
- }
1
+ /*
2
+ _ __ _ __
3
+ | | / /___ _(_) /____
4
+ | | /| / / __ `/ / / ___/
5
+ | |/ |/ / /_/ / / (__ )
6
+ |__/|__/\__,_/_/_/____/
7
+ The electron alternative for Go
8
+ (c) Lea Anthony 2019-present
9
+ */
10
+ import { newRuntimeCaller, objectNames } from "./runtime.js";
11
+ const call = newRuntimeCaller(objectNames.Screens);
12
+ const getAll = 0;
13
+ const getPrimary = 1;
14
+ const getCurrent = 2;
15
+ /**
16
+ * Gets all screens.
17
+ *
18
+ * @returns A promise that resolves to an array of Screen objects.
19
+ */
20
+ export function GetAll() {
21
+ return call(getAll);
22
+ }
23
+ /**
24
+ * Gets the primary screen.
25
+ *
26
+ * @returns A promise that resolves to the primary screen.
27
+ */
28
+ export function GetPrimary() {
29
+ return call(getPrimary);
30
+ }
31
+ /**
32
+ * Gets the current active screen.
33
+ *
34
+ * @returns A promise that resolves with the current active screen.
35
+ */
36
+ export function GetCurrent() {
37
+ return call(getCurrent);
38
+ }