@wailsio/runtime 3.0.0-alpha.14 → 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.14",
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",
@@ -48,7 +48,6 @@ export const EventTypes = {
48
48
  ApplicationWillTerminate: "mac:ApplicationWillTerminate",
49
49
  ApplicationWillUnhide: "mac:ApplicationWillUnhide",
50
50
  ApplicationWillUpdate: "mac:ApplicationWillUpdate",
51
- ApplicationTerminate: "mac:ApplicationTerminate",
52
51
  ApplicationDidChangeTheme: "mac:ApplicationDidChangeTheme!",
53
52
  ApplicationShouldHandleReopen: "mac:ApplicationShouldHandleReopen!",
54
53
  WindowDidBecomeKey: "mac:WindowDidBecomeKey",
@@ -178,6 +177,5 @@ export const EventTypes = {
178
177
  WindowDPIChanged: "common:WindowDPIChanged",
179
178
  WindowFilesDropped: "common:WindowFilesDropped",
180
179
  ThemeChanged: "common:ThemeChanged",
181
- ApplicationTerminate: "common:ApplicationTerminate",
182
180
  },
183
181
  };
package/src/events.js CHANGED
@@ -42,9 +42,20 @@ export class WailsEvent {
42
42
  }
43
43
  }
44
44
 
45
-
46
- window._wails = window._wails || {};
47
- window._wails.dispatchWailsEvent = dispatchWailsEvent;
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
+ }
48
59
 
49
60
  function dispatchWailsEvent(event) {
50
61
  let listeners = eventListeners.get(event.name);
@@ -91,7 +102,7 @@ export function On(eventName, callback) { return OnMultiple(eventName, callback,
91
102
  *
92
103
  * @param {string} eventName - The name of the event.
93
104
  * @param {function} callback - The function to be executed when the event occurs.
94
- * @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.
95
106
  */
96
107
  export function Once(eventName, callback) { return OnMultiple(eventName, callback, 1); }
97
108
 
package/src/index.js CHANGED
@@ -74,5 +74,6 @@ function whenReady(fn) {
74
74
  whenReady(() => {
75
75
  setupContextMenus();
76
76
  setupDrag();
77
+ setupEventCallbacks();
77
78
  WML.Reload();
78
79
  });
package/tsconfig.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "include": ["./src/**/*"],
3
- "compilerOptions": {
4
- "lib": [
5
- "dom",
6
- "dom.iterable",
7
- "esnext"
8
- ],
9
- "allowJs": true,
10
- "declaration": true,
11
- "declarationMap": true,
12
- "emitDeclarationOnly": true,
13
- "esModuleInterop": true,
14
- "module": "esnext",
15
- "moduleResolution": "node",
16
- "outDir": "dist",
17
- "strict": true,
18
- "target": "es6"
19
- }
1
+ {
2
+ "include": ["./src/**/*"],
3
+ "compilerOptions": {
4
+ "lib": [
5
+ "dom",
6
+ "dom.iterable",
7
+ "esnext"
8
+ ],
9
+ "allowJs": true,
10
+ "declaration": true,
11
+ "declarationMap": true,
12
+ "emitDeclarationOnly": true,
13
+ "esModuleInterop": true,
14
+ "module": "esnext",
15
+ "moduleResolution": "node",
16
+ "outDir": "dist",
17
+ "strict": true,
18
+ "target": "es6"
19
+ }
20
20
  }
@@ -48,7 +48,6 @@ export declare const EventTypes: {
48
48
  ApplicationWillTerminate: string,
49
49
  ApplicationWillUnhide: string,
50
50
  ApplicationWillUpdate: string,
51
- ApplicationTerminate: string,
52
51
  ApplicationDidChangeTheme: string,
53
52
  ApplicationShouldHandleReopen: string,
54
53
  WindowDidBecomeKey: string,
@@ -178,6 +177,5 @@ export declare const EventTypes: {
178
177
  WindowDPIChanged: string,
179
178
  WindowFilesDropped: string,
180
179
  ThemeChanged: string,
181
- ApplicationTerminate: string,
182
180
  },
183
181
  };
package/types/events.d.ts CHANGED
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Sets up event callbacks for Wails.
3
+ *
4
+ * @function setupEventCallbacks
5
+ *
6
+ * @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
7
+ *. It then assigns the `dispatchWailsEvent` function as a property on the `_wails` object.
8
+ *
9
+ * @returns {undefined} Returns nothing.
10
+ */
11
+ export function setupEventCallbacks(): undefined;
1
12
  /**
2
13
  * Register a callback function to be called multiple times for a specific event.
3
14
  *
@@ -20,9 +31,9 @@ export function On(eventName: string, callback: Function): Function;
20
31
  *
21
32
  * @param {string} eventName - The name of the event.
22
33
  * @param {function} callback - The function to be executed when the event occurs.
23
- * @return {void@return {function} - A function that, when called, will unregister the callback from the event.
34
+ * @return {function} - A function that, when called, will unregister the callback from the event.
24
35
  */
25
- export function Once(eventName: string, callback: Function): void;
36
+ export function Once(eventName: string, callback: Function): Function;
26
37
  /**
27
38
  * Removes event listeners for the specified event names.
28
39
  *
@@ -80,15 +91,6 @@ export const Types: {
80
91
  ApplicationDidChangeIcon: string;
81
92
  ApplicationDidChangeOcclusionState: string;
82
93
  ApplicationDidChangeScreenParameters: string;
83
- /**
84
- * Register a callback function to be called multiple times for a specific event.
85
- *
86
- * @param {string} eventName - The name of the event to register the callback for.
87
- * @param {function} callback - The callback function to be called when the event is triggered.
88
- * @param {number} 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.
89
- *
90
- @return {function} - A function that, when called, will unregister the callback from the event.
91
- */
92
94
  ApplicationDidChangeStatusBarFrame: string;
93
95
  ApplicationDidChangeStatusBarOrientation: string;
94
96
  ApplicationDidFinishLaunching: string;
@@ -103,7 +105,6 @@ export const Types: {
103
105
  ApplicationWillTerminate: string;
104
106
  ApplicationWillUnhide: string;
105
107
  ApplicationWillUpdate: string;
106
- ApplicationTerminate: string;
107
108
  ApplicationDidChangeTheme: string;
108
109
  ApplicationShouldHandleReopen: string;
109
110
  WindowDidBecomeKey: string;
@@ -124,6 +125,12 @@ export const Types: {
124
125
  WindowDidChangeSharingType: string;
125
126
  WindowDidChangeSpace: string;
126
127
  WindowDidChangeSpaceOrderingMode: string;
128
+ /**
129
+ * Removes the specified listener from the event listeners collection.
130
+ * If all listeners for the event are removed, the event key is deleted from the collection.
131
+ *
132
+ * @param {Object} listener - The listener to be removed.
133
+ */
127
134
  WindowDidChangeTitle: string;
128
135
  WindowDidChangeToolbar: string;
129
136
  WindowDidChangeVisibility: string;
@@ -133,6 +140,13 @@ export const Types: {
133
140
  WindowDidEnterVersionBrowser: string;
134
141
  WindowDidExitFullScreen: string;
135
142
  WindowDidExitVersionBrowser: string;
143
+ /**
144
+ * Removes event listeners for the specified event names.
145
+ *
146
+ * @param {string} eventName - The name of the event to remove listeners for.
147
+ * @param {...string} additionalEventNames - Additional event names to remove listeners for.
148
+ * @return {undefined}
149
+ */
136
150
  WindowDidExpose: string;
137
151
  WindowDidFocus: string;
138
152
  WindowDidMiniaturize: string;
@@ -233,7 +247,6 @@ export const Types: {
233
247
  WindowDPIChanged: string;
234
248
  WindowFilesDropped: string;
235
249
  ThemeChanged: string;
236
- ApplicationTerminate: string;
237
250
  };
238
251
  };
239
252
  export class WailsEvent {
package/types/window.d.ts CHANGED
@@ -5,26 +5,156 @@
5
5
  * @return {Object} - The specified window object.
6
6
  */
7
7
  export function Get(windowName: string): any;
8
- declare const _default: any;
9
- export default _default;
10
- export type Screen = import("./screens").Screen;
11
- export type Position = {
8
+ /**
9
+ * Centers the window on the screen.
10
+ */
11
+ export function Center(): void;
12
+ /**
13
+ * Sets the title of the window.
14
+ * @param {string} title - The title to set.
15
+ */
16
+ export function SetTitle(title: string): void;
17
+ /**
18
+ * Sets the window to fullscreen.
19
+ */
20
+ export function Fullscreen(): void;
21
+ /**
22
+ * Sets the size of the window.
23
+ * @param {number} width - The width of the window.
24
+ * @param {number} height - The height of the window.
25
+ */
26
+ export function SetSize(width: number, height: number): void;
27
+ /**
28
+ * Gets the size of the window.
29
+ */
30
+ export function Size(): any;
31
+ export type Size = {
12
32
  /**
13
- * - The X coordinate.
33
+ * - The width.
14
34
  */
15
35
  X: number;
16
36
  /**
17
- * - The Y coordinate.
37
+ * - The height.
18
38
  */
19
39
  Y: number;
20
40
  };
21
- export type Size = {
41
+ /**
42
+ * Sets the maximum size of the window.
43
+ * @param {number} width - The maximum width of the window.
44
+ * @param {number} height - The maximum height of the window.
45
+ */
46
+ export function SetMaxSize(width: number, height: number): void;
47
+ /**
48
+ * Sets the minimum size of the window.
49
+ * @param {number} width - The minimum width of the window.
50
+ * @param {number} height - The minimum height of the window.
51
+ */
52
+ export function SetMinSize(width: number, height: number): void;
53
+ /**
54
+ * Sets the window to always be on top.
55
+ * @param {boolean} onTop - Whether the window should always be on top.
56
+ */
57
+ export function SetAlwaysOnTop(onTop: boolean): void;
58
+ /**
59
+ * Sets the relative position of the window.
60
+ * @param {number} x - The x-coordinate of the window's position.
61
+ * @param {number} y - The y-coordinate of the window's position.
62
+ */
63
+ export function SetRelativePosition(x: number, y: number): void;
64
+ /**
65
+ * Gets the relative position of the window.
66
+ */
67
+ export function RelativePosition(): any;
68
+ /**
69
+ * Gets the screen that the window is on.
70
+ */
71
+ export function Screen(): any;
72
+ export type Screen = import("./screens").Screen;
73
+ /**
74
+ * Hides the window.
75
+ */
76
+ export function Hide(): void;
77
+ /**
78
+ * Maximises the window.
79
+ */
80
+ export function Maximise(): void;
81
+ /**
82
+ * Un-maximises the window.
83
+ */
84
+ export function UnMaximise(): void;
85
+ /**
86
+ * Toggles the maximisation of the window.
87
+ */
88
+ export function ToggleMaximise(): void;
89
+ /**
90
+ * Minimises the window.
91
+ */
92
+ export function Minimise(): void;
93
+ /**
94
+ * Un-minimises the window.
95
+ */
96
+ export function UnMinimise(): void;
97
+ /**
98
+ * Restores the window.
99
+ */
100
+ export function Restore(): void;
101
+ /**
102
+ * Shows the window.
103
+ */
104
+ export function Show(): void;
105
+ /**
106
+ * Closes the window.
107
+ */
108
+ export function Close(): void;
109
+ /**
110
+ * Sets the background colour of the window.
111
+ * @param {number} r - The red component of the colour.
112
+ * @param {number} g - The green component of the colour.
113
+ * @param {number} b - The blue component of the colour.
114
+ * @param {number} a - The alpha component of the colour.
115
+ */
116
+ export function SetBackgroundColour(r: number, g: number, b: number, a: number): void;
117
+ /**
118
+ * Sets whether the window is resizable.
119
+ * @param {boolean} resizable - Whether the window should be resizable.
120
+ */
121
+ export function SetResizable(resizable: boolean): void;
122
+ /**
123
+ * Gets the width of the window.
124
+ */
125
+ export function Width(): any;
126
+ /**
127
+ * Gets the height of the window.
128
+ */
129
+ export function Height(): any;
130
+ /**
131
+ * Zooms in the window.
132
+ */
133
+ export function ZoomIn(): void;
134
+ /**
135
+ * Zooms out the window.
136
+ */
137
+ export function ZoomOut(): void;
138
+ /**
139
+ * Resets the zoom of the window.
140
+ */
141
+ export function ZoomReset(): void;
142
+ /**
143
+ * Gets the zoom level of the window.
144
+ */
145
+ export function GetZoomLevel(): any;
146
+ /**
147
+ * Sets the zoom level of the window.
148
+ * @param {number} zoomLevel - The zoom level to set.
149
+ */
150
+ export function SetZoomLevel(zoomLevel: number): void;
151
+ export type Position = {
22
152
  /**
23
- * - The width.
153
+ * - The X coordinate.
24
154
  */
25
155
  X: number;
26
156
  /**
27
- * - The height.
157
+ * - The Y coordinate.
28
158
  */
29
159
  Y: number;
30
160
  };