@wailsio/runtime 3.0.0-alpha.13 → 3.0.0-alpha.15

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wailsio/runtime",
3
- "version": "3.0.0-alpha.13",
3
+ "version": "3.0.0-alpha.15",
4
4
  "description": "Wails Runtime",
5
5
  "main": "src/index.js",
6
6
  "types": "types/index.d.ts",
@@ -10,7 +10,10 @@
10
10
  },
11
11
  "scripts": {
12
12
  "prebuild:types": "rimraf ./types",
13
- "build:types": "npx -p typescript tsc src/index.js --declaration --allowJs --emitDeclarationOnly --outDir types"
13
+ "build:types": "npx -p typescript tsc src/index.js --declaration --allowJs --emitDeclarationOnly --outDir types",
14
+ "postbuild:types": "wails3 task generate:events",
15
+ "build:docs": "npx typedoc ./src/index.js",
16
+ "build:docs:md": "npx typedoc --plugin typedoc-plugin-markdown --namedAnchors true --hideBreadcrumbs true --out ../../../../../../mkdocs-website/docs/en/api/js ./src/index.js"
14
17
  },
15
18
  "author": "The Wails Team",
16
19
  "license": "MIT",
@@ -21,6 +24,8 @@
21
24
  "private": false,
22
25
  "devDependencies": {
23
26
  "rimraf": "^5.0.5",
27
+ "typedoc": "^0.25.7",
28
+ "typedoc-plugin-markdown": "^3.17.1",
24
29
  "typescript": "^5.3.3"
25
30
  }
26
31
  }
package/src/calls.js CHANGED
@@ -20,6 +20,11 @@ window._wails = window._wails || {};
20
20
  window._wails.callResultHandler = resultHandler;
21
21
  window._wails.callErrorHandler = errorHandler;
22
22
 
23
+ /**
24
+ * Generates a unique ID using the nanoid library.
25
+ *
26
+ * @return {string} - A unique ID that does not exist in the callResponses set.
27
+ */
23
28
  function generateID() {
24
29
  let result;
25
30
  do {
@@ -28,26 +33,57 @@ function generateID() {
28
33
  return result;
29
34
  }
30
35
 
31
- export function resultHandler(id, data, isJSON) {
36
+ /**
37
+ * Handles the result of a call request.
38
+ *
39
+ * @param {string} id - The id of the request to handle the result for.
40
+ * @param {string} data - The result data of the request.
41
+ * @param {boolean} isJSON - Indicates whether the data is JSON or not.
42
+ *
43
+ * @return {undefined} - This method does not return any value.
44
+ */
45
+ function resultHandler(id, data, isJSON) {
32
46
  const promiseHandler = getAndDeleteResponse(id);
33
47
  if (promiseHandler) {
34
48
  promiseHandler.resolve(isJSON ? JSON.parse(data) : data);
35
49
  }
36
50
  }
37
51
 
38
- export function errorHandler(id, message) {
52
+ /**
53
+ * Handles the error from a call request.
54
+ *
55
+ * @param {string} id - The id of the promise handler.
56
+ * @param {string} message - The error message to reject the promise handler with.
57
+ *
58
+ * @return {void}
59
+ */
60
+ function errorHandler(id, message) {
39
61
  const promiseHandler = getAndDeleteResponse(id);
40
62
  if (promiseHandler) {
41
63
  promiseHandler.reject(message);
42
64
  }
43
65
  }
44
66
 
67
+ /**
68
+ * Retrieves and removes the response associated with the given ID from the callResponses map.
69
+ *
70
+ * @param {any} id - The ID of the response to be retrieved and removed.
71
+ *
72
+ * @returns {any} The response object associated with the given ID.
73
+ */
45
74
  function getAndDeleteResponse(id) {
46
75
  const response = callResponses.get(id);
47
76
  callResponses.delete(id);
48
77
  return response;
49
78
  }
50
79
 
80
+ /**
81
+ * Executes a call using the provided type and options.
82
+ *
83
+ * @param {string|number} type - The type of call to execute.
84
+ * @param {Object} [options={}] - Additional options for the call.
85
+ * @return {Promise} - A promise that will be resolved or rejected based on the result of the call.
86
+ */
51
87
  function callBinding(type, options = {}) {
52
88
  return new Promise((resolve, reject) => {
53
89
  const id = generateID();
package/src/dialogs.js CHANGED
@@ -11,9 +11,66 @@ The electron alternative for Go
11
11
  /* jshint esversion: 9 */
12
12
 
13
13
  /**
14
- * @typedef {import("./types").MessageDialogOptions} MessageDialogOptions
15
- * @typedef {import("./types").OpenDialogOptions} OpenDialogOptions
16
- * @typedef {import("./types").SaveDialogOptions} SaveDialogOptions
14
+ * @typedef {Object} OpenFileDialogOptions
15
+ * @property {boolean} [CanChooseDirectories] - Indicates if directories can be chosen.
16
+ * @property {boolean} [CanChooseFiles] - Indicates if files can be chosen.
17
+ * @property {boolean} [CanCreateDirectories] - Indicates if directories can be created.
18
+ * @property {boolean} [ShowHiddenFiles] - Indicates if hidden files should be shown.
19
+ * @property {boolean} [ResolvesAliases] - Indicates if aliases should be resolved.
20
+ * @property {boolean} [AllowsMultipleSelection] - Indicates if multiple selection is allowed.
21
+ * @property {boolean} [HideExtension] - Indicates if the extension should be hidden.
22
+ * @property {boolean} [CanSelectHiddenExtension] - Indicates if hidden extensions can be selected.
23
+ * @property {boolean} [TreatsFilePackagesAsDirectories] - Indicates if file packages should be treated as directories.
24
+ * @property {boolean} [AllowsOtherFiletypes] - Indicates if other file types are allowed.
25
+ * @property {FileFilter[]} [Filters] - Array of file filters.
26
+ * @property {string} [Title] - Title of the dialog.
27
+ * @property {string} [Message] - Message to show in the dialog.
28
+ * @property {string} [ButtonText] - Text to display on the button.
29
+ * @property {string} [Directory] - Directory to open in the dialog.
30
+ * @property {boolean} [Detached] - Indicates if the dialog should appear detached from the main window.
31
+ */
32
+
33
+
34
+ /**
35
+ * @typedef {Object} SaveFileDialogOptions
36
+ * @property {string} [Filename] - Default filename to use in the dialog.
37
+ * @property {boolean} [CanChooseDirectories] - Indicates if directories can be chosen.
38
+ * @property {boolean} [CanChooseFiles] - Indicates if files can be chosen.
39
+ * @property {boolean} [CanCreateDirectories] - Indicates if directories can be created.
40
+ * @property {boolean} [ShowHiddenFiles] - Indicates if hidden files should be shown.
41
+ * @property {boolean} [ResolvesAliases] - Indicates if aliases should be resolved.
42
+ * @property {boolean} [AllowsMultipleSelection] - Indicates if multiple selection is allowed.
43
+ * @property {boolean} [HideExtension] - Indicates if the extension should be hidden.
44
+ * @property {boolean} [CanSelectHiddenExtension] - Indicates if hidden extensions can be selected.
45
+ * @property {boolean} [TreatsFilePackagesAsDirectories] - Indicates if file packages should be treated as directories.
46
+ * @property {boolean} [AllowsOtherFiletypes] - Indicates if other file types are allowed.
47
+ * @property {FileFilter[]} [Filters] - Array of file filters.
48
+ * @property {string} [Title] - Title of the dialog.
49
+ * @property {string} [Message] - Message to show in the dialog.
50
+ * @property {string} [ButtonText] - Text to display on the button.
51
+ * @property {string} [Directory] - Directory to open in the dialog.
52
+ * @property {boolean} [Detached] - Indicates if the dialog should appear detached from the main window.
53
+ */
54
+
55
+ /**
56
+ * @typedef {Object} MessageDialogOptions
57
+ * @property {string} [Title] - The title of the dialog window.
58
+ * @property {string} [Message] - The main message to show in the dialog.
59
+ * @property {Button[]} [Buttons] - Array of button options to show in the dialog.
60
+ * @property {boolean} [Detached] - True if the dialog should appear detached from the main window (if applicable).
61
+ */
62
+
63
+ /**
64
+ * @typedef {Object} Button
65
+ * @property {string} [Label] - Text that appears within the button.
66
+ * @property {boolean} [IsCancel] - True if the button should cancel an operation when clicked.
67
+ * @property {boolean} [IsDefault] - True if the button should be the default action when the user presses enter.
68
+ */
69
+
70
+ /**
71
+ * @typedef {Object} FileFilter
72
+ * @property {string} [DisplayName] - Display name for the filter, it could be "Text Files", "Images" etc.
73
+ * @property {string} [Pattern] - Pattern to match for the filter, e.g. "*.txt;*.md" for text markdown files.
17
74
  */
18
75
 
19
76
  import {newRuntimeCallerWithID, objectNames} from "./runtime";
@@ -46,7 +103,7 @@ function generateID() {
46
103
  /**
47
104
  * Shows a dialog of specified type with the given options.
48
105
  * @param {number} type - type of dialog
49
- * @param {object} options - options for the dialog
106
+ * @param {MessageDialogOptions|OpenFileDialogOptions|SaveFileDialogOptions} options - options for the dialog
50
107
  * @returns {Promise} promise that resolves with result of dialog
51
108
  */
52
109
  function dialog(type, options = {}) {
@@ -61,6 +118,10 @@ function dialog(type, options = {}) {
61
118
  });
62
119
  }
63
120
 
121
+ window._wails = window._wails || {};
122
+ window._wails.dialogErrorCallback = dialogErrorCallback;
123
+ window._wails.dialogResultCallback = dialogResultCallback;
124
+
64
125
  /**
65
126
  * Handles the callback from a dialog.
66
127
  *
@@ -70,7 +131,7 @@ function dialog(type, options = {}) {
70
131
  *
71
132
  * @return {undefined}
72
133
  */
73
- export function dialogResultCallback(id, data, isJSON) {
134
+ function dialogResultCallback(id, data, isJSON) {
74
135
  let p = dialogResponses.get(id);
75
136
  if (p) {
76
137
  if (isJSON) {
@@ -90,7 +151,7 @@ export function dialogResultCallback(id, data, isJSON) {
90
151
  *
91
152
  * @return {void}
92
153
  */
93
- export function dialogErrorCallback(id, message) {
154
+ function dialogErrorCallback(id, message) {
94
155
  let p = dialogResponses.get(id);
95
156
  if (p) {
96
157
  p.reject(message);
@@ -126,13 +187,13 @@ export const Error = (options) => dialog(DialogError, options);
126
187
  export const Question = (options) => dialog(DialogQuestion, options);
127
188
 
128
189
  /**
129
- * @param {OpenDialogOptions} options - Dialog options
190
+ * @param {OpenFileDialogOptions} options - Dialog options
130
191
  * @returns {Promise<string[]|string>} Returns selected file or list of files. Returns blank string if no file is selected.
131
192
  */
132
193
  export const OpenFile = (options) => dialog(DialogOpenFile, options);
133
194
 
134
195
  /**
135
- * @param {SaveDialogOptions} options - Dialog options
196
+ * @param {SaveFileDialogOptions} options - Dialog options
136
197
  * @returns {Promise<string>} Returns the selected file. Returns blank string if no file is selected.
137
198
  */
138
199
  export const SaveFile = (options) => dialog(DialogSaveFile, options);
@@ -0,0 +1,181 @@
1
+
2
+ export const EventTypes = {
3
+ Windows: {
4
+ SystemThemeChanged: "windows:SystemThemeChanged",
5
+ APMPowerStatusChange: "windows:APMPowerStatusChange",
6
+ APMSuspend: "windows:APMSuspend",
7
+ APMResumeAutomatic: "windows:APMResumeAutomatic",
8
+ APMResumeSuspend: "windows:APMResumeSuspend",
9
+ APMPowerSettingChange: "windows:APMPowerSettingChange",
10
+ ApplicationStarted: "windows:ApplicationStarted",
11
+ WebViewNavigationCompleted: "windows:WebViewNavigationCompleted",
12
+ WindowInactive: "windows:WindowInactive",
13
+ WindowActive: "windows:WindowActive",
14
+ WindowClickActive: "windows:WindowClickActive",
15
+ WindowMaximise: "windows:WindowMaximise",
16
+ WindowUnMaximise: "windows:WindowUnMaximise",
17
+ WindowFullscreen: "windows:WindowFullscreen",
18
+ WindowUnFullscreen: "windows:WindowUnFullscreen",
19
+ WindowRestore: "windows:WindowRestore",
20
+ WindowMinimise: "windows:WindowMinimise",
21
+ WindowUnMinimise: "windows:WindowUnMinimise",
22
+ WindowClose: "windows:WindowClose",
23
+ WindowSetFocus: "windows:WindowSetFocus",
24
+ WindowKillFocus: "windows:WindowKillFocus",
25
+ WindowDragDrop: "windows:WindowDragDrop",
26
+ WindowDragEnter: "windows:WindowDragEnter",
27
+ WindowDragLeave: "windows:WindowDragLeave",
28
+ WindowDragOver: "windows:WindowDragOver",
29
+ },
30
+ Mac: {
31
+ ApplicationDidBecomeActive: "mac:ApplicationDidBecomeActive",
32
+ ApplicationDidChangeBackingProperties: "mac:ApplicationDidChangeBackingProperties",
33
+ ApplicationDidChangeEffectiveAppearance: "mac:ApplicationDidChangeEffectiveAppearance",
34
+ ApplicationDidChangeIcon: "mac:ApplicationDidChangeIcon",
35
+ ApplicationDidChangeOcclusionState: "mac:ApplicationDidChangeOcclusionState",
36
+ ApplicationDidChangeScreenParameters: "mac:ApplicationDidChangeScreenParameters",
37
+ ApplicationDidChangeStatusBarFrame: "mac:ApplicationDidChangeStatusBarFrame",
38
+ ApplicationDidChangeStatusBarOrientation: "mac:ApplicationDidChangeStatusBarOrientation",
39
+ ApplicationDidFinishLaunching: "mac:ApplicationDidFinishLaunching",
40
+ ApplicationDidHide: "mac:ApplicationDidHide",
41
+ ApplicationDidResignActiveNotification: "mac:ApplicationDidResignActiveNotification",
42
+ ApplicationDidUnhide: "mac:ApplicationDidUnhide",
43
+ ApplicationDidUpdate: "mac:ApplicationDidUpdate",
44
+ ApplicationWillBecomeActive: "mac:ApplicationWillBecomeActive",
45
+ ApplicationWillFinishLaunching: "mac:ApplicationWillFinishLaunching",
46
+ ApplicationWillHide: "mac:ApplicationWillHide",
47
+ ApplicationWillResignActive: "mac:ApplicationWillResignActive",
48
+ ApplicationWillTerminate: "mac:ApplicationWillTerminate",
49
+ ApplicationWillUnhide: "mac:ApplicationWillUnhide",
50
+ ApplicationWillUpdate: "mac:ApplicationWillUpdate",
51
+ ApplicationDidChangeTheme: "mac:ApplicationDidChangeTheme!",
52
+ ApplicationShouldHandleReopen: "mac:ApplicationShouldHandleReopen!",
53
+ WindowDidBecomeKey: "mac:WindowDidBecomeKey",
54
+ WindowDidBecomeMain: "mac:WindowDidBecomeMain",
55
+ WindowDidBeginSheet: "mac:WindowDidBeginSheet",
56
+ WindowDidChangeAlpha: "mac:WindowDidChangeAlpha",
57
+ WindowDidChangeBackingLocation: "mac:WindowDidChangeBackingLocation",
58
+ WindowDidChangeBackingProperties: "mac:WindowDidChangeBackingProperties",
59
+ WindowDidChangeCollectionBehavior: "mac:WindowDidChangeCollectionBehavior",
60
+ WindowDidChangeEffectiveAppearance: "mac:WindowDidChangeEffectiveAppearance",
61
+ WindowDidChangeOcclusionState: "mac:WindowDidChangeOcclusionState",
62
+ WindowDidChangeOrderingMode: "mac:WindowDidChangeOrderingMode",
63
+ WindowDidChangeScreen: "mac:WindowDidChangeScreen",
64
+ WindowDidChangeScreenParameters: "mac:WindowDidChangeScreenParameters",
65
+ WindowDidChangeScreenProfile: "mac:WindowDidChangeScreenProfile",
66
+ WindowDidChangeScreenSpace: "mac:WindowDidChangeScreenSpace",
67
+ WindowDidChangeScreenSpaceProperties: "mac:WindowDidChangeScreenSpaceProperties",
68
+ WindowDidChangeSharingType: "mac:WindowDidChangeSharingType",
69
+ WindowDidChangeSpace: "mac:WindowDidChangeSpace",
70
+ WindowDidChangeSpaceOrderingMode: "mac:WindowDidChangeSpaceOrderingMode",
71
+ WindowDidChangeTitle: "mac:WindowDidChangeTitle",
72
+ WindowDidChangeToolbar: "mac:WindowDidChangeToolbar",
73
+ WindowDidChangeVisibility: "mac:WindowDidChangeVisibility",
74
+ WindowDidDeminiaturize: "mac:WindowDidDeminiaturize",
75
+ WindowDidEndSheet: "mac:WindowDidEndSheet",
76
+ WindowDidEnterFullScreen: "mac:WindowDidEnterFullScreen",
77
+ WindowDidEnterVersionBrowser: "mac:WindowDidEnterVersionBrowser",
78
+ WindowDidExitFullScreen: "mac:WindowDidExitFullScreen",
79
+ WindowDidExitVersionBrowser: "mac:WindowDidExitVersionBrowser",
80
+ WindowDidExpose: "mac:WindowDidExpose",
81
+ WindowDidFocus: "mac:WindowDidFocus",
82
+ WindowDidMiniaturize: "mac:WindowDidMiniaturize",
83
+ WindowDidMove: "mac:WindowDidMove",
84
+ WindowDidOrderOffScreen: "mac:WindowDidOrderOffScreen",
85
+ WindowDidOrderOnScreen: "mac:WindowDidOrderOnScreen",
86
+ WindowDidResignKey: "mac:WindowDidResignKey",
87
+ WindowDidResignMain: "mac:WindowDidResignMain",
88
+ WindowDidResize: "mac:WindowDidResize",
89
+ WindowDidUpdate: "mac:WindowDidUpdate",
90
+ WindowDidUpdateAlpha: "mac:WindowDidUpdateAlpha",
91
+ WindowDidUpdateCollectionBehavior: "mac:WindowDidUpdateCollectionBehavior",
92
+ WindowDidUpdateCollectionProperties: "mac:WindowDidUpdateCollectionProperties",
93
+ WindowDidUpdateShadow: "mac:WindowDidUpdateShadow",
94
+ WindowDidUpdateTitle: "mac:WindowDidUpdateTitle",
95
+ WindowDidUpdateToolbar: "mac:WindowDidUpdateToolbar",
96
+ WindowDidUpdateVisibility: "mac:WindowDidUpdateVisibility",
97
+ WindowShouldClose: "mac:WindowShouldClose!",
98
+ WindowWillBecomeKey: "mac:WindowWillBecomeKey",
99
+ WindowWillBecomeMain: "mac:WindowWillBecomeMain",
100
+ WindowWillBeginSheet: "mac:WindowWillBeginSheet",
101
+ WindowWillChangeOrderingMode: "mac:WindowWillChangeOrderingMode",
102
+ WindowWillClose: "mac:WindowWillClose",
103
+ WindowWillDeminiaturize: "mac:WindowWillDeminiaturize",
104
+ WindowWillEnterFullScreen: "mac:WindowWillEnterFullScreen",
105
+ WindowWillEnterVersionBrowser: "mac:WindowWillEnterVersionBrowser",
106
+ WindowWillExitFullScreen: "mac:WindowWillExitFullScreen",
107
+ WindowWillExitVersionBrowser: "mac:WindowWillExitVersionBrowser",
108
+ WindowWillFocus: "mac:WindowWillFocus",
109
+ WindowWillMiniaturize: "mac:WindowWillMiniaturize",
110
+ WindowWillMove: "mac:WindowWillMove",
111
+ WindowWillOrderOffScreen: "mac:WindowWillOrderOffScreen",
112
+ WindowWillOrderOnScreen: "mac:WindowWillOrderOnScreen",
113
+ WindowWillResignMain: "mac:WindowWillResignMain",
114
+ WindowWillResize: "mac:WindowWillResize",
115
+ WindowWillUnfocus: "mac:WindowWillUnfocus",
116
+ WindowWillUpdate: "mac:WindowWillUpdate",
117
+ WindowWillUpdateAlpha: "mac:WindowWillUpdateAlpha",
118
+ WindowWillUpdateCollectionBehavior: "mac:WindowWillUpdateCollectionBehavior",
119
+ WindowWillUpdateCollectionProperties: "mac:WindowWillUpdateCollectionProperties",
120
+ WindowWillUpdateShadow: "mac:WindowWillUpdateShadow",
121
+ WindowWillUpdateTitle: "mac:WindowWillUpdateTitle",
122
+ WindowWillUpdateToolbar: "mac:WindowWillUpdateToolbar",
123
+ WindowWillUpdateVisibility: "mac:WindowWillUpdateVisibility",
124
+ WindowWillUseStandardFrame: "mac:WindowWillUseStandardFrame",
125
+ MenuWillOpen: "mac:MenuWillOpen",
126
+ MenuDidOpen: "mac:MenuDidOpen",
127
+ MenuDidClose: "mac:MenuDidClose",
128
+ MenuWillSendAction: "mac:MenuWillSendAction",
129
+ MenuDidSendAction: "mac:MenuDidSendAction",
130
+ MenuWillHighlightItem: "mac:MenuWillHighlightItem",
131
+ MenuDidHighlightItem: "mac:MenuDidHighlightItem",
132
+ MenuWillDisplayItem: "mac:MenuWillDisplayItem",
133
+ MenuDidDisplayItem: "mac:MenuDidDisplayItem",
134
+ MenuWillAddItem: "mac:MenuWillAddItem",
135
+ MenuDidAddItem: "mac:MenuDidAddItem",
136
+ MenuWillRemoveItem: "mac:MenuWillRemoveItem",
137
+ MenuDidRemoveItem: "mac:MenuDidRemoveItem",
138
+ MenuWillBeginTracking: "mac:MenuWillBeginTracking",
139
+ MenuDidBeginTracking: "mac:MenuDidBeginTracking",
140
+ MenuWillEndTracking: "mac:MenuWillEndTracking",
141
+ MenuDidEndTracking: "mac:MenuDidEndTracking",
142
+ MenuWillUpdate: "mac:MenuWillUpdate",
143
+ MenuDidUpdate: "mac:MenuDidUpdate",
144
+ MenuWillPopUp: "mac:MenuWillPopUp",
145
+ MenuDidPopUp: "mac:MenuDidPopUp",
146
+ MenuWillSendActionToItem: "mac:MenuWillSendActionToItem",
147
+ MenuDidSendActionToItem: "mac:MenuDidSendActionToItem",
148
+ WebViewDidStartProvisionalNavigation: "mac:WebViewDidStartProvisionalNavigation",
149
+ WebViewDidReceiveServerRedirectForProvisionalNavigation: "mac:WebViewDidReceiveServerRedirectForProvisionalNavigation",
150
+ WebViewDidFinishNavigation: "mac:WebViewDidFinishNavigation",
151
+ WebViewDidCommitNavigation: "mac:WebViewDidCommitNavigation",
152
+ WindowFileDraggingEntered: "mac:WindowFileDraggingEntered",
153
+ WindowFileDraggingPerformed: "mac:WindowFileDraggingPerformed",
154
+ WindowFileDraggingExited: "mac:WindowFileDraggingExited",
155
+ },
156
+ Linux: {
157
+ SystemThemeChanged: "linux:SystemThemeChanged",
158
+ },
159
+ Common: {
160
+ ApplicationStarted: "common:ApplicationStarted",
161
+ WindowMaximise: "common:WindowMaximise",
162
+ WindowUnMaximise: "common:WindowUnMaximise",
163
+ WindowFullscreen: "common:WindowFullscreen",
164
+ WindowUnFullscreen: "common:WindowUnFullscreen",
165
+ WindowRestore: "common:WindowRestore",
166
+ WindowMinimise: "common:WindowMinimise",
167
+ WindowUnMinimise: "common:WindowUnMinimise",
168
+ WindowClosing: "common:WindowClosing",
169
+ WindowZoom: "common:WindowZoom",
170
+ WindowZoomIn: "common:WindowZoomIn",
171
+ WindowZoomOut: "common:WindowZoomOut",
172
+ WindowZoomReset: "common:WindowZoomReset",
173
+ WindowFocus: "common:WindowFocus",
174
+ WindowLostFocus: "common:WindowLostFocus",
175
+ WindowShow: "common:WindowShow",
176
+ WindowHide: "common:WindowHide",
177
+ WindowDPIChanged: "common:WindowDPIChanged",
178
+ WindowFilesDropped: "common:WindowFilesDropped",
179
+ ThemeChanged: "common:ThemeChanged",
180
+ },
181
+ };
package/src/events.js CHANGED
@@ -15,6 +15,9 @@ The electron alternative for Go
15
15
  */
16
16
  import {newRuntimeCallerWithID, objectNames} from "./runtime";
17
17
 
18
+ import {EventTypes} from "./event_types";
19
+ export const Types = EventTypes;
20
+
18
21
  const call = newRuntimeCallerWithID(objectNames.Events, '');
19
22
  const EmitMethod = 0;
20
23
  const eventListeners = new Map();
@@ -39,11 +42,22 @@ export class WailsEvent {
39
42
  }
40
43
  }
41
44
 
45
+ /**
46
+ * Sets up event callbacks for Wails.
47
+ *
48
+ * @function setupEventCallbacks
49
+ *
50
+ * @description This method is responsible for setting up event callbacks for Wails. It checks if the global object `_wails` exists on the `window` object, and if not, initializes it
51
+ *. It then assigns the `dispatchWailsEvent` function as a property on the `_wails` object.
52
+ *
53
+ * @returns {undefined} Returns nothing.
54
+ */
55
+ export function setupEventCallbacks() {
56
+ window._wails = window._wails || {};
57
+ window._wails.dispatchWailsEvent = dispatchWailsEvent;
58
+ }
42
59
 
43
- window._wails = window._wails || {};
44
- window._wails.dispatchWailsEvent = dispatchWailsEvent;
45
-
46
- export function dispatchWailsEvent(event) {
60
+ function dispatchWailsEvent(event) {
47
61
  let listeners = eventListeners.get(event.name);
48
62
  if (listeners) {
49
63
  let toRemove = listeners.filter(listener => {
@@ -88,7 +102,7 @@ export function On(eventName, callback) { return OnMultiple(eventName, callback,
88
102
  *
89
103
  * @param {string} eventName - The name of the event.
90
104
  * @param {function} callback - The function to be executed when the event occurs.
91
- * @return {void@return {function} - A function that, when called, will unregister the callback from the event.
105
+ * @return {function} - A function that, when called, will unregister the callback from the event.
92
106
  */
93
107
  export function Once(eventName, callback) { return OnMultiple(eventName, callback, 1); }
94
108
 
package/src/index.js CHANGED
@@ -10,45 +10,22 @@ The electron alternative for Go
10
10
 
11
11
  import {setupContextMenus} from "./contextmenu";
12
12
  import {setupDrag} from "./drag";
13
- import {Emit, Off, OffAll, On, Once, OnMultiple, WailsEvent} from './events';
14
13
  import {ByID, ByName, Plugin} from "./calls";
15
- import {Error, Info, OpenFile, Question, SaveFile, Warning} from "./dialogs";
16
14
 
17
15
  import * as Application from "./application";
18
16
  import * as Browser from "./browser";
19
17
  import * as Clipboard from "./clipboard";
20
- import * as ContextMenu from "./contextmenu";
21
18
  import * as Flags from "./flags";
22
- import * as Runtime from "./runtime";
23
19
  import * as Screens from "./screens";
24
20
  import * as System from "./system";
25
21
  import * as Window from "./window";
26
22
  import * as WML from './wml';
23
+ import * as Events from "./events";
24
+ import * as Dialogs from "./dialogs";
25
+ import * as Call from "./calls";
27
26
 
28
- export { Application, Browser, Clipboard, ContextMenu, Flags, Runtime, Screens, System, Window, WML };
27
+ export { Application, Browser, Call, Clipboard, Dialogs, Events, Flags, Screens, System, Window, WML};
29
28
 
30
- export const Events = {
31
- On,
32
- Off,
33
- OnMultiple,
34
- WailsEvent,
35
- OffAll,
36
- Emit,
37
- Once
38
-
39
- }
40
-
41
- export const Call = {
42
- Plugin,
43
- ByID,
44
- ByName
45
- }
46
-
47
- export const Dialogs = {
48
- Info,
49
- Error,
50
- OpenFile, Question, Warning, SaveFile
51
- }
52
29
 
53
30
  /***
54
31
  This technique for proper load detection is taken from HTMX:
@@ -97,5 +74,6 @@ function whenReady(fn) {
97
74
  whenReady(() => {
98
75
  setupContextMenus();
99
76
  setupDrag();
77
+ setupEventCallbacks();
100
78
  WML.Reload();
101
79
  });
package/src/screens.js CHANGED
@@ -10,10 +10,21 @@ The electron alternative for Go
10
10
 
11
11
  /* jshint esversion: 9 */
12
12
 
13
+
13
14
  /**
14
- * @typedef {import("./api/types").Screen} Screen
15
+ * @typedef {Object} Screen
16
+ * @property {string} Id - Unique identifier for the screen.
17
+ * @property {string} Name - Human readable name of the screen.
18
+ * @property {number} Scale - The resolution scale of the screen. 1 = standard resolution, 2 = high (Retina), etc.
19
+ * @property {Position} Position - Contains the X and Y coordinates of the screen's position.
20
+ * @property {Size} Size - Contains the width and height of the screen.
21
+ * @property {Rect} Bounds - Contains the bounds of the screen in terms of X, Y, Width, and Height.
22
+ * @property {Rect} WorkArea - Contains the area of the screen that is actually usable (excluding taskbar and other system UI).
23
+ * @property {boolean} IsPrimary - True if this is the primary monitor selected by the user in the operating system.
24
+ * @property {Rotation} Rotation - The rotation of the screen.
15
25
  */
16
26
 
27
+
17
28
  import {newRuntimeCallerWithID, objectNames} from "./runtime";
18
29
  const call = newRuntimeCallerWithID(objectNames.Screens, '');
19
30