@wailsio/runtime v3.0.0-alpha.15

This commit is contained in:
Lea Anthony
2024-01-20 11:34:36 +11:00
parent 3d08f92705
commit a805d6c2b1
5 changed files with 186 additions and 31 deletions
@@ -1,6 +1,6 @@
{
"name": "@wailsio/runtime",
"version": "3.0.0-alpha.14",
"version": "3.0.0-alpha.15",
"description": "Wails Runtime",
"main": "src/index.js",
"types": "types/index.d.ts",
@@ -42,9 +42,20 @@ export class WailsEvent {
}
}
window._wails = window._wails || {};
window._wails.dispatchWailsEvent = dispatchWailsEvent;
/**
* Sets up event callbacks for Wails.
*
* @function setupEventCallbacks
*
* @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
*. It then assigns the `dispatchWailsEvent` function as a property on the `_wails` object.
*
* @returns {undefined} Returns nothing.
*/
export function setupEventCallbacks() {
window._wails = window._wails || {};
window._wails.dispatchWailsEvent = dispatchWailsEvent;
}
function dispatchWailsEvent(event) {
let listeners = eventListeners.get(event.name);
@@ -91,7 +102,7 @@ export function On(eventName, callback) { return OnMultiple(eventName, callback,
*
* @param {string} eventName - The name of the event.
* @param {function} callback - The function to be executed when the event occurs.
* @return {void@return {function} - A function that, when called, will unregister the callback from the event.
* @return {function} - A function that, when called, will unregister the callback from the event.
*/
export function Once(eventName, callback) { return OnMultiple(eventName, callback, 1); }
@@ -74,5 +74,6 @@ function whenReady(fn) {
whenReady(() => {
setupContextMenus();
setupDrag();
setupEventCallbacks();
WML.Reload();
});
@@ -1,3 +1,14 @@
/**
* Sets up event callbacks for Wails.
*
* @function setupEventCallbacks
*
* @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
*. It then assigns the `dispatchWailsEvent` function as a property on the `_wails` object.
*
* @returns {undefined} Returns nothing.
*/
export function setupEventCallbacks(): undefined;
/**
* Register a callback function to be called multiple times for a specific event.
*
@@ -20,9 +31,9 @@ export function On(eventName: string, callback: Function): Function;
*
* @param {string} eventName - The name of the event.
* @param {function} callback - The function to be executed when the event occurs.
* @return {void@return {function} - A function that, when called, will unregister the callback from the event.
* @return {function} - A function that, when called, will unregister the callback from the event.
*/
export function Once(eventName: string, callback: Function): void;
export function Once(eventName: string, callback: Function): Function;
/**
* Removes event listeners for the specified event names.
*
@@ -80,15 +91,6 @@ export const Types: {
ApplicationDidChangeIcon: string;
ApplicationDidChangeOcclusionState: string;
ApplicationDidChangeScreenParameters: string;
/**
* Register a callback function to be called multiple times for a specific event.
*
* @param {string} eventName - The name of the event to register the callback for.
* @param {function} callback - The callback function to be called when the event is triggered.
* @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.
*
@return {function} - A function that, when called, will unregister the callback from the event.
*/
ApplicationDidChangeStatusBarFrame: string;
ApplicationDidChangeStatusBarOrientation: string;
ApplicationDidFinishLaunching: string;
@@ -103,7 +105,6 @@ export const Types: {
ApplicationWillTerminate: string;
ApplicationWillUnhide: string;
ApplicationWillUpdate: string;
ApplicationTerminate: string;
ApplicationDidChangeTheme: string;
ApplicationShouldHandleReopen: string;
WindowDidBecomeKey: string;
@@ -124,6 +125,12 @@ export const Types: {
WindowDidChangeSharingType: string;
WindowDidChangeSpace: string;
WindowDidChangeSpaceOrderingMode: string;
/**
* Removes the specified listener from the event listeners collection.
* If all listeners for the event are removed, the event key is deleted from the collection.
*
* @param {Object} listener - The listener to be removed.
*/
WindowDidChangeTitle: string;
WindowDidChangeToolbar: string;
WindowDidChangeVisibility: string;
@@ -133,6 +140,13 @@ export const Types: {
WindowDidEnterVersionBrowser: string;
WindowDidExitFullScreen: string;
WindowDidExitVersionBrowser: string;
/**
* Removes event listeners for the specified event names.
*
* @param {string} eventName - The name of the event to remove listeners for.
* @param {...string} additionalEventNames - Additional event names to remove listeners for.
* @return {undefined}
*/
WindowDidExpose: string;
WindowDidFocus: string;
WindowDidMiniaturize: string;
@@ -233,7 +247,6 @@ export const Types: {
WindowDPIChanged: string;
WindowFilesDropped: string;
ThemeChanged: string;
ApplicationTerminate: string;
};
};
export class WailsEvent {
+143 -13
View File
@@ -5,19 +5,29 @@
* @return {Object} - The specified window object.
*/
export function Get(windowName: string): any;
declare const _default: any;
export default _default;
export type Screen = import("./screens").Screen;
export type Position = {
/**
* - The X coordinate.
*/
X: number;
/**
* - The Y coordinate.
*/
Y: number;
};
/**
* Centers the window on the screen.
*/
export function Center(): void;
/**
* Sets the title of the window.
* @param {string} title - The title to set.
*/
export function SetTitle(title: string): void;
/**
* Sets the window to fullscreen.
*/
export function Fullscreen(): void;
/**
* Sets the size of the window.
* @param {number} width - The width of the window.
* @param {number} height - The height of the window.
*/
export function SetSize(width: number, height: number): void;
/**
* Gets the size of the window.
*/
export function Size(): any;
export type Size = {
/**
* - The width.
@@ -28,6 +38,126 @@ export type Size = {
*/
Y: number;
};
/**
* Sets the maximum size of the window.
* @param {number} width - The maximum width of the window.
* @param {number} height - The maximum height of the window.
*/
export function SetMaxSize(width: number, height: number): void;
/**
* Sets the minimum size of the window.
* @param {number} width - The minimum width of the window.
* @param {number} height - The minimum height of the window.
*/
export function SetMinSize(width: number, height: number): void;
/**
* Sets the window to always be on top.
* @param {boolean} onTop - Whether the window should always be on top.
*/
export function SetAlwaysOnTop(onTop: boolean): void;
/**
* Sets the relative position of the window.
* @param {number} x - The x-coordinate of the window's position.
* @param {number} y - The y-coordinate of the window's position.
*/
export function SetRelativePosition(x: number, y: number): void;
/**
* Gets the relative position of the window.
*/
export function RelativePosition(): any;
/**
* Gets the screen that the window is on.
*/
export function Screen(): any;
export type Screen = import("./screens").Screen;
/**
* Hides the window.
*/
export function Hide(): void;
/**
* Maximises the window.
*/
export function Maximise(): void;
/**
* Un-maximises the window.
*/
export function UnMaximise(): void;
/**
* Toggles the maximisation of the window.
*/
export function ToggleMaximise(): void;
/**
* Minimises the window.
*/
export function Minimise(): void;
/**
* Un-minimises the window.
*/
export function UnMinimise(): void;
/**
* Restores the window.
*/
export function Restore(): void;
/**
* Shows the window.
*/
export function Show(): void;
/**
* Closes the window.
*/
export function Close(): void;
/**
* Sets the background colour of the window.
* @param {number} r - The red component of the colour.
* @param {number} g - The green component of the colour.
* @param {number} b - The blue component of the colour.
* @param {number} a - The alpha component of the colour.
*/
export function SetBackgroundColour(r: number, g: number, b: number, a: number): void;
/**
* Sets whether the window is resizable.
* @param {boolean} resizable - Whether the window should be resizable.
*/
export function SetResizable(resizable: boolean): void;
/**
* Gets the width of the window.
*/
export function Width(): any;
/**
* Gets the height of the window.
*/
export function Height(): any;
/**
* Zooms in the window.
*/
export function ZoomIn(): void;
/**
* Zooms out the window.
*/
export function ZoomOut(): void;
/**
* Resets the zoom of the window.
*/
export function ZoomReset(): void;
/**
* Gets the zoom level of the window.
*/
export function GetZoomLevel(): any;
/**
* Sets the zoom level of the window.
* @param {number} zoomLevel - The zoom level to set.
*/
export function SetZoomLevel(zoomLevel: number): void;
export type Position = {
/**
* - The X coordinate.
*/
X: number;
/**
* - The Y coordinate.
*/
Y: number;
};
export type Rect = {
/**
* - The X coordinate of the top-left corner.