feat: base

This commit is contained in:
GogaCoder
2025-01-03 00:05:10 +07:00
commit 493ebacfcb
1224 changed files with 1648045 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
import { newRuntimeCallerWithID, objectNames } from "./runtime";
const call = newRuntimeCallerWithID(objectNames.Application, '');
const HideMethod = 0;
const ShowMethod = 1;
const QuitMethod = 2;
/**
* Hides a certain method by calling the HideMethod function.
*
* @return {Promise<void>}
*
*/
export function Hide() {
return call(HideMethod);
}
/**
* Calls the ShowMethod and returns the result.
*
* @return {Promise<void>}
*/
export function Show() {
return call(ShowMethod);
}
/**
* Calls the QuitMethod to terminate the program.
*
* @return {Promise<void>}
*/
export function Quit() {
return call(QuitMethod);
}

24
frontend/node_modules/@wailsio/runtime/src/browser.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
import {newRuntimeCallerWithID, objectNames} from "./runtime";
const call = newRuntimeCallerWithID(objectNames.Browser, '');
const BrowserOpenURL = 0;
/**
* Open a browser window to the given URL
* @param {string} url - The URL to open
* @returns {Promise<string>}
*/
export function OpenURL(url) {
return call(BrowserOpenURL, {url});
}

174
frontend/node_modules/@wailsio/runtime/src/calls.js generated vendored Normal file
View File

@@ -0,0 +1,174 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
import { newRuntimeCallerWithID, objectNames } from "./runtime";
import { nanoid } from 'nanoid/non-secure';
// Setup
window._wails = window._wails || {};
window._wails.callResultHandler = resultHandler;
window._wails.callErrorHandler = errorHandler;
const CallBinding = 0;
const call = newRuntimeCallerWithID(objectNames.Call, '');
const cancelCall = newRuntimeCallerWithID(objectNames.CancelCall, '');
let callResponses = new Map();
/**
* Generates a unique ID using the nanoid library.
*
* @return {string} - A unique ID that does not exist in the callResponses set.
*/
function generateID() {
let result;
do {
result = nanoid();
} while (callResponses.has(result));
return result;
}
/**
* Handles the result of a call request.
*
* @param {string} id - The id of the request to handle the result for.
* @param {string} data - The result data of the request.
* @param {boolean} isJSON - Indicates whether the data is JSON or not.
*
* @return {undefined} - This method does not return any value.
*/
function resultHandler(id, data, isJSON) {
const promiseHandler = getAndDeleteResponse(id);
if (promiseHandler) {
promiseHandler.resolve(isJSON ? JSON.parse(data) : data);
}
}
/**
* Handles the error from a call request.
*
* @param {string} id - The id of the promise handler.
* @param {string} message - The error message to reject the promise handler with.
*
* @return {void}
*/
function errorHandler(id, message) {
const promiseHandler = getAndDeleteResponse(id);
if (promiseHandler) {
promiseHandler.reject(message);
}
}
/**
* Retrieves and removes the response associated with the given ID from the callResponses map.
*
* @param {any} id - The ID of the response to be retrieved and removed.
*
* @returns {any} The response object associated with the given ID.
*/
function getAndDeleteResponse(id) {
const response = callResponses.get(id);
callResponses.delete(id);
return response;
}
/**
* Executes a call using the provided type and options.
*
* @param {string|number} type - The type of call to execute.
* @param {Object} [options={}] - Additional options for the call.
* @return {Promise} - A promise that will be resolved or rejected based on the result of the call. It also has a cancel method to cancel a long running request.
*/
function callBinding(type, options = {}) {
const id = generateID();
const doCancel = () => { return cancelCall(type, {"call-id": id}) };
let queuedCancel = false, callRunning = false;
let p = new Promise((resolve, reject) => {
options["call-id"] = id;
callResponses.set(id, { resolve, reject });
call(type, options).
then((_) => {
callRunning = true;
if (queuedCancel) {
return doCancel();
}
}).
catch((error) => {
reject(error);
callResponses.delete(id);
});
});
p.cancel = () => {
if (callRunning) {
return doCancel();
} else {
queuedCancel = true;
}
};
return p;
}
/**
* Call method.
*
* @param {Object} options - The options for the method.
* @returns {Object} - The result of the call.
*/
export function Call(options) {
return callBinding(CallBinding, options);
}
/**
* Executes a method by name.
*
* @param {string} methodName - The name of the method in the format 'package.struct.method'.
* @param {...*} args - The arguments to pass to the method.
* @throws {Error} If the name is not a string or is not in the correct format.
* @returns {*} The result of the method execution.
*/
export function ByName(methodName, ...args) {
return callBinding(CallBinding, {
methodName,
args
});
}
/**
* Calls a method by its ID with the specified arguments.
*
* @param {number} methodID - The ID of the method to call.
* @param {...*} args - The arguments to pass to the method.
* @return {*} - The result of the method call.
*/
export function ByID(methodID, ...args) {
return callBinding(CallBinding, {
methodID,
args
});
}
/**
* Calls a method on a plugin.
*
* @param {string} pluginName - The name of the plugin.
* @param {string} methodName - The name of the method to call.
* @param {...*} args - The arguments to pass to the method.
* @returns {*} - The result of the method call.
*/
export function Plugin(pluginName, methodName, ...args) {
return callBinding(CallBinding, {
packageName: "wails-plugins",
structName: pluginName,
methodName,
args
});
}

View File

@@ -0,0 +1,35 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
import {newRuntimeCallerWithID, objectNames} from "./runtime";
const call = newRuntimeCallerWithID(objectNames.Clipboard, '');
const ClipboardSetText = 0;
const ClipboardText = 1;
/**
* Sets the text to the Clipboard.
*
* @param {string} text - The text to be set to the Clipboard.
* @return {Promise} - A Promise that resolves when the operation is successful.
*/
export function SetText(text) {
return call(ClipboardSetText, {text});
}
/**
* Get the Clipboard text
* @returns {Promise<string>} A promise that resolves with the text from the Clipboard.
*/
export function Text() {
return call(ClipboardText);
}

View File

@@ -0,0 +1,97 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
import {newRuntimeCallerWithID, objectNames} from "./runtime";
import {IsDebug} from "./system";
// setup
window.addEventListener('contextmenu', contextMenuHandler);
const call = newRuntimeCallerWithID(objectNames.ContextMenu, '');
const ContextMenuOpen = 0;
function openContextMenu(id, x, y, data) {
void call(ContextMenuOpen, {id, x, y, data});
}
function contextMenuHandler(event) {
// Check for custom context menu
let element = event.target;
let customContextMenu = window.getComputedStyle(element).getPropertyValue("--custom-contextmenu");
customContextMenu = customContextMenu ? customContextMenu.trim() : "";
if (customContextMenu) {
event.preventDefault();
let customContextMenuData = window.getComputedStyle(element).getPropertyValue("--custom-contextmenu-data");
openContextMenu(customContextMenu, event.clientX, event.clientY, customContextMenuData);
return
}
processDefaultContextMenu(event);
}
/*
--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
--default-contextmenu: show; will always show the default context menu
--default-contextmenu: hide; will always hide the default context menu
This rule is inherited like normal CSS rules, so nesting works as expected
*/
function processDefaultContextMenu(event) {
// Debug builds always show the menu
if (IsDebug()) {
return;
}
// Process default context menu
const element = event.target;
const computedStyle = window.getComputedStyle(element);
const defaultContextMenuAction = computedStyle.getPropertyValue("--default-contextmenu").trim();
switch (defaultContextMenuAction) {
case "show":
return;
case "hide":
event.preventDefault();
return;
default:
// Check if contentEditable is true
if (element.isContentEditable) {
return;
}
// Check if text has been selected
const selection = window.getSelection();
const hasSelection = (selection.toString().length > 0)
if (hasSelection) {
for (let i = 0; i < selection.rangeCount; i++) {
const range = selection.getRangeAt(i);
const rects = range.getClientRects();
for (let j = 0; j < rects.length; j++) {
const rect = rects[j];
if (document.elementFromPoint(rect.left, rect.top) === element) {
return;
}
}
}
}
// Check if tagname is input or textarea
if (element.tagName === "INPUT" || element.tagName === "TEXTAREA") {
if (hasSelection || (!element.readOnly && !element.disabled)) {
return;
}
}
// hide default context menu
event.preventDefault();
}
}

125
frontend/node_modules/@wailsio/runtime/src/create.js generated vendored Normal file
View File

@@ -0,0 +1,125 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
/**
* Any is a dummy creation function for simple or unknown types.
* @template T
* @param {any} source
* @returns {T}
*/
export function Any(source) {
return /** @type {T} */(source);
}
/**
* ByteSlice is a creation function that replaces
* null strings with empty strings.
* @param {any} source
* @returns {string}
*/
export function ByteSlice(source) {
return /** @type {any} */((source == null) ? "" : source);
}
/**
* Array takes a creation function for an arbitrary type
* and returns an in-place creation function for an array
* whose elements are of that type.
* @template T
* @param {(source: any) => T} element
* @returns {(source: any) => T[]}
*/
export function Array(element) {
if (element === Any) {
return (source) => (source === null ? [] : source);
}
return (source) => {
if (source === null) {
return [];
}
for (let i = 0; i < source.length; i++) {
source[i] = element(source[i]);
}
return source;
};
}
/**
* Map takes creation functions for two arbitrary types
* and returns an in-place creation function for an object
* whose keys and values are of those types.
* @template K, V
* @param {(source: any) => K} key
* @param {(source: any) => V} value
* @returns {(source: any) => { [_: K]: V }}
*/
export function Map(key, value) {
if (value === Any) {
return (source) => (source === null ? {} : source);
}
return (source) => {
if (source === null) {
return {};
}
for (const key in source) {
source[key] = value(source[key]);
}
return source;
};
}
/**
* Nullable takes a creation function for an arbitrary type
* and returns a creation function for a nullable value of that type.
* @template T
* @param {(source: any) => T} element
* @returns {(source: any) => (T | null)}
*/
export function Nullable(element) {
if (element === Any) {
return Any;
}
return (source) => (source === null ? null : element(source));
}
/**
* Struct takes an object mapping field names to creation functions
* and returns an in-place creation function for a struct.
* @template {{ [_: string]: ((source: any) => any) }} T
* @template {{ [Key in keyof T]?: ReturnType<T[Key]> }} U
* @param {T} createField
* @returns {(source: any) => U}
*/
export function Struct(createField) {
let allAny = true;
for (const name in createField) {
if (createField[name] !== Any) {
allAny = false;
break;
}
}
if (allAny) {
return Any;
}
return (source) => {
for (const name in createField) {
if (name in source) {
source[name] = createField[name](source[name]);
}
}
return source;
};
}

200
frontend/node_modules/@wailsio/runtime/src/dialogs.js generated vendored Normal file
View File

@@ -0,0 +1,200 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
/**
* @typedef {Object} OpenFileDialogOptions
* @property {boolean} [CanChooseDirectories] - Indicates if directories can be chosen.
* @property {boolean} [CanChooseFiles] - Indicates if files can be chosen.
* @property {boolean} [CanCreateDirectories] - Indicates if directories can be created.
* @property {boolean} [ShowHiddenFiles] - Indicates if hidden files should be shown.
* @property {boolean} [ResolvesAliases] - Indicates if aliases should be resolved.
* @property {boolean} [AllowsMultipleSelection] - Indicates if multiple selection is allowed.
* @property {boolean} [HideExtension] - Indicates if the extension should be hidden.
* @property {boolean} [CanSelectHiddenExtension] - Indicates if hidden extensions can be selected.
* @property {boolean} [TreatsFilePackagesAsDirectories] - Indicates if file packages should be treated as directories.
* @property {boolean} [AllowsOtherFiletypes] - Indicates if other file types are allowed.
* @property {FileFilter[]} [Filters] - Array of file filters.
* @property {string} [Title] - Title of the dialog.
* @property {string} [Message] - Message to show in the dialog.
* @property {string} [ButtonText] - Text to display on the button.
* @property {string} [Directory] - Directory to open in the dialog.
* @property {boolean} [Detached] - Indicates if the dialog should appear detached from the main window.
*/
/**
* @typedef {Object} SaveFileDialogOptions
* @property {string} [Filename] - Default filename to use in the dialog.
* @property {boolean} [CanChooseDirectories] - Indicates if directories can be chosen.
* @property {boolean} [CanChooseFiles] - Indicates if files can be chosen.
* @property {boolean} [CanCreateDirectories] - Indicates if directories can be created.
* @property {boolean} [ShowHiddenFiles] - Indicates if hidden files should be shown.
* @property {boolean} [ResolvesAliases] - Indicates if aliases should be resolved.
* @property {boolean} [AllowsMultipleSelection] - Indicates if multiple selection is allowed.
* @property {boolean} [HideExtension] - Indicates if the extension should be hidden.
* @property {boolean} [CanSelectHiddenExtension] - Indicates if hidden extensions can be selected.
* @property {boolean} [TreatsFilePackagesAsDirectories] - Indicates if file packages should be treated as directories.
* @property {boolean} [AllowsOtherFiletypes] - Indicates if other file types are allowed.
* @property {FileFilter[]} [Filters] - Array of file filters.
* @property {string} [Title] - Title of the dialog.
* @property {string} [Message] - Message to show in the dialog.
* @property {string} [ButtonText] - Text to display on the button.
* @property {string} [Directory] - Directory to open in the dialog.
* @property {boolean} [Detached] - Indicates if the dialog should appear detached from the main window.
*/
/**
* @typedef {Object} MessageDialogOptions
* @property {string} [Title] - The title of the dialog window.
* @property {string} [Message] - The main message to show in the dialog.
* @property {Button[]} [Buttons] - Array of button options to show in the dialog.
* @property {boolean} [Detached] - True if the dialog should appear detached from the main window (if applicable).
*/
/**
* @typedef {Object} Button
* @property {string} [Label] - Text that appears within the button.
* @property {boolean} [IsCancel] - True if the button should cancel an operation when clicked.
* @property {boolean} [IsDefault] - True if the button should be the default action when the user presses enter.
*/
/**
* @typedef {Object} FileFilter
* @property {string} [DisplayName] - Display name for the filter, it could be "Text Files", "Images" etc.
* @property {string} [Pattern] - Pattern to match for the filter, e.g. "*.txt;*.md" for text markdown files.
*/
// setup
window._wails = window._wails || {};
window._wails.dialogErrorCallback = dialogErrorCallback;
window._wails.dialogResultCallback = dialogResultCallback;
import {newRuntimeCallerWithID, objectNames} from "./runtime";
import { nanoid } from 'nanoid/non-secure';
// Define constants from the `methods` object in Title Case
const DialogInfo = 0;
const DialogWarning = 1;
const DialogError = 2;
const DialogQuestion = 3;
const DialogOpenFile = 4;
const DialogSaveFile = 5;
const call = newRuntimeCallerWithID(objectNames.Dialog, '');
const dialogResponses = new Map();
/**
* Generates a unique id that is not present in dialogResponses.
* @returns {string} unique id
*/
function generateID() {
let result;
do {
result = nanoid();
} while (dialogResponses.has(result));
return result;
}
/**
* Shows a dialog of specified type with the given options.
* @param {number} type - type of dialog
* @param {MessageDialogOptions|OpenFileDialogOptions|SaveFileDialogOptions} options - options for the dialog
* @returns {Promise} promise that resolves with result of dialog
*/
function dialog(type, options = {}) {
const id = generateID();
options["dialog-id"] = id;
return new Promise((resolve, reject) => {
dialogResponses.set(id, {resolve, reject});
call(type, options).catch((error) => {
reject(error);
dialogResponses.delete(id);
});
});
}
/**
* Handles the callback from a dialog.
*
* @param {string} id - The ID of the dialog response.
* @param {string} data - The data received from the dialog.
* @param {boolean} isJSON - Flag indicating whether the data is in JSON format.
*
* @return {undefined}
*/
function dialogResultCallback(id, data, isJSON) {
let p = dialogResponses.get(id);
if (p) {
if (isJSON) {
p.resolve(JSON.parse(data));
} else {
p.resolve(data);
}
dialogResponses.delete(id);
}
}
/**
* Callback function for handling errors in dialog.
*
* @param {string} id - The id of the dialog response.
* @param {string} message - The error message.
*
* @return {void}
*/
function dialogErrorCallback(id, message) {
let p = dialogResponses.get(id);
if (p) {
p.reject(message);
dialogResponses.delete(id);
}
}
// Replace `methods` with constants in Title Case
/**
* @param {MessageDialogOptions} options - Dialog options
* @returns {Promise<string>} - The label of the button pressed
*/
export const Info = (options) => dialog(DialogInfo, options);
/**
* @param {MessageDialogOptions} options - Dialog options
* @returns {Promise<string>} - The label of the button pressed
*/
export const Warning = (options) => dialog(DialogWarning, options);
/**
* @param {MessageDialogOptions} options - Dialog options
* @returns {Promise<string>} - The label of the button pressed
*/
export const Error = (options) => dialog(DialogError, options);
/**
* @param {MessageDialogOptions} options - Dialog options
* @returns {Promise<string>} - The label of the button pressed
*/
export const Question = (options) => dialog(DialogQuestion, options);
/**
* @param {OpenFileDialogOptions} options - Dialog options
* @returns {Promise<string[]|string>} Returns selected file or list of files. Returns blank string if no file is selected.
*/
export const OpenFile = (options) => dialog(DialogOpenFile, options);
/**
* @param {SaveFileDialogOptions} options - Dialog options
* @returns {Promise<string>} Returns the selected file. Returns blank string if no file is selected.
*/
export const SaveFile = (options) => dialog(DialogSaveFile, options);

119
frontend/node_modules/@wailsio/runtime/src/drag.js generated vendored Normal file
View File

@@ -0,0 +1,119 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
import {invoke, IsWindows} from "./system";
import {GetFlag} from "./flags";
// Setup
let shouldDrag = false;
let resizable = false;
let resizeEdge = null;
let defaultCursor = "auto";
window._wails = window._wails || {};
window._wails.setResizable = function(value) {
resizable = value;
};
window._wails.endDrag = function() {
document.body.style.cursor = 'default';
shouldDrag = false;
};
window.addEventListener('mousedown', onMouseDown);
window.addEventListener('mousemove', onMouseMove);
window.addEventListener('mouseup', onMouseUp);
function dragTest(e) {
let val = window.getComputedStyle(e.target).getPropertyValue("--wails-draggable");
let mousePressed = e.buttons !== undefined ? e.buttons : e.which;
if (!val || val === "" || val.trim() !== "drag" || mousePressed === 0) {
return false;
}
return e.detail === 1;
}
function onMouseDown(e) {
// Check for resizing
if (resizeEdge) {
invoke("wails:resize:" + resizeEdge);
e.preventDefault();
return;
}
if (dragTest(e)) {
// This checks for clicks on the scroll bar
if (e.offsetX > e.target.clientWidth || e.offsetY > e.target.clientHeight) {
return;
}
shouldDrag = true;
} else {
shouldDrag = false;
}
}
function onMouseUp() {
shouldDrag = false;
}
function setResize(cursor) {
document.documentElement.style.cursor = cursor || defaultCursor;
resizeEdge = cursor;
}
function onMouseMove(e) {
if (shouldDrag) {
shouldDrag = false;
let mousePressed = e.buttons !== undefined ? e.buttons : e.which;
if (mousePressed > 0) {
invoke("wails:drag");
return;
}
}
if (!resizable || !IsWindows()) {
return;
}
if (defaultCursor == null) {
defaultCursor = document.documentElement.style.cursor;
}
let resizeHandleHeight = GetFlag("system.resizeHandleHeight") || 5;
let resizeHandleWidth = GetFlag("system.resizeHandleWidth") || 5;
// Extra pixels for the corner areas
let cornerExtra = GetFlag("resizeCornerExtra") || 10;
let rightBorder = window.outerWidth - e.clientX < resizeHandleWidth;
let leftBorder = e.clientX < resizeHandleWidth;
let topBorder = e.clientY < resizeHandleHeight;
let bottomBorder = window.outerHeight - e.clientY < resizeHandleHeight;
// Adjust for corners
let rightCorner = window.outerWidth - e.clientX < (resizeHandleWidth + cornerExtra);
let leftCorner = e.clientX < (resizeHandleWidth + cornerExtra);
let topCorner = e.clientY < (resizeHandleHeight + cornerExtra);
let bottomCorner = window.outerHeight - e.clientY < (resizeHandleHeight + cornerExtra);
// If we aren't on an edge, but were, reset the cursor to default
if (!leftBorder && !rightBorder && !topBorder && !bottomBorder && resizeEdge !== undefined) {
setResize();
}
// Adjusted for corner areas
else if (rightCorner && bottomCorner) setResize("se-resize");
else if (leftCorner && bottomCorner) setResize("sw-resize");
else if (leftCorner && topCorner) setResize("nw-resize");
else if (topCorner && rightCorner) setResize("ne-resize");
else if (leftBorder) setResize("w-resize");
else if (topBorder) setResize("n-resize");
else if (bottomBorder) setResize("s-resize");
else if (rightBorder) setResize("e-resize");
}

View File

@@ -0,0 +1,216 @@
export const EventTypes = {
Windows: {
SystemThemeChanged: "windows:SystemThemeChanged",
APMPowerStatusChange: "windows:APMPowerStatusChange",
APMSuspend: "windows:APMSuspend",
APMResumeAutomatic: "windows:APMResumeAutomatic",
APMResumeSuspend: "windows:APMResumeSuspend",
APMPowerSettingChange: "windows:APMPowerSettingChange",
ApplicationStarted: "windows:ApplicationStarted",
WebViewNavigationCompleted: "windows:WebViewNavigationCompleted",
WindowInactive: "windows:WindowInactive",
WindowActive: "windows:WindowActive",
WindowClickActive: "windows:WindowClickActive",
WindowMaximise: "windows:WindowMaximise",
WindowUnMaximise: "windows:WindowUnMaximise",
WindowFullscreen: "windows:WindowFullscreen",
WindowUnFullscreen: "windows:WindowUnFullscreen",
WindowRestore: "windows:WindowRestore",
WindowMinimise: "windows:WindowMinimise",
WindowUnMinimise: "windows:WindowUnMinimise",
WindowClosing: "windows:WindowClosing",
WindowSetFocus: "windows:WindowSetFocus",
WindowKillFocus: "windows:WindowKillFocus",
WindowDragDrop: "windows:WindowDragDrop",
WindowDragEnter: "windows:WindowDragEnter",
WindowDragLeave: "windows:WindowDragLeave",
WindowDragOver: "windows:WindowDragOver",
WindowDidMove: "windows:WindowDidMove",
WindowDidResize: "windows:WindowDidResize",
WindowShow: "windows:WindowShow",
WindowHide: "windows:WindowHide",
WindowStartMove: "windows:WindowStartMove",
WindowEndMove: "windows:WindowEndMove",
WindowStartResize: "windows:WindowStartResize",
WindowEndResize: "windows:WindowEndResize",
WindowKeyDown: "windows:WindowKeyDown",
WindowKeyUp: "windows:WindowKeyUp",
WindowZOrderChanged: "windows:WindowZOrderChanged",
WindowPaint: "windows:WindowPaint",
WindowBackgroundErase: "windows:WindowBackgroundErase",
WindowNonClientHit: "windows:WindowNonClientHit",
WindowNonClientMouseDown: "windows:WindowNonClientMouseDown",
WindowNonClientMouseUp: "windows:WindowNonClientMouseUp",
WindowNonClientMouseMove: "windows:WindowNonClientMouseMove",
WindowNonClientMouseLeave: "windows:WindowNonClientMouseLeave",
},
Mac: {
ApplicationDidBecomeActive: "mac:ApplicationDidBecomeActive",
ApplicationDidChangeBackingProperties: "mac:ApplicationDidChangeBackingProperties",
ApplicationDidChangeEffectiveAppearance: "mac:ApplicationDidChangeEffectiveAppearance",
ApplicationDidChangeIcon: "mac:ApplicationDidChangeIcon",
ApplicationDidChangeOcclusionState: "mac:ApplicationDidChangeOcclusionState",
ApplicationDidChangeScreenParameters: "mac:ApplicationDidChangeScreenParameters",
ApplicationDidChangeStatusBarFrame: "mac:ApplicationDidChangeStatusBarFrame",
ApplicationDidChangeStatusBarOrientation: "mac:ApplicationDidChangeStatusBarOrientation",
ApplicationDidFinishLaunching: "mac:ApplicationDidFinishLaunching",
ApplicationDidHide: "mac:ApplicationDidHide",
ApplicationDidResignActiveNotification: "mac:ApplicationDidResignActiveNotification",
ApplicationDidUnhide: "mac:ApplicationDidUnhide",
ApplicationDidUpdate: "mac:ApplicationDidUpdate",
ApplicationWillBecomeActive: "mac:ApplicationWillBecomeActive",
ApplicationWillFinishLaunching: "mac:ApplicationWillFinishLaunching",
ApplicationWillHide: "mac:ApplicationWillHide",
ApplicationWillResignActive: "mac:ApplicationWillResignActive",
ApplicationWillTerminate: "mac:ApplicationWillTerminate",
ApplicationWillUnhide: "mac:ApplicationWillUnhide",
ApplicationWillUpdate: "mac:ApplicationWillUpdate",
ApplicationDidChangeTheme: "mac:ApplicationDidChangeTheme!",
ApplicationShouldHandleReopen: "mac:ApplicationShouldHandleReopen!",
WindowDidBecomeKey: "mac:WindowDidBecomeKey",
WindowDidBecomeMain: "mac:WindowDidBecomeMain",
WindowDidBeginSheet: "mac:WindowDidBeginSheet",
WindowDidChangeAlpha: "mac:WindowDidChangeAlpha",
WindowDidChangeBackingLocation: "mac:WindowDidChangeBackingLocation",
WindowDidChangeBackingProperties: "mac:WindowDidChangeBackingProperties",
WindowDidChangeCollectionBehavior: "mac:WindowDidChangeCollectionBehavior",
WindowDidChangeEffectiveAppearance: "mac:WindowDidChangeEffectiveAppearance",
WindowDidChangeOcclusionState: "mac:WindowDidChangeOcclusionState",
WindowDidChangeOrderingMode: "mac:WindowDidChangeOrderingMode",
WindowDidChangeScreen: "mac:WindowDidChangeScreen",
WindowDidChangeScreenParameters: "mac:WindowDidChangeScreenParameters",
WindowDidChangeScreenProfile: "mac:WindowDidChangeScreenProfile",
WindowDidChangeScreenSpace: "mac:WindowDidChangeScreenSpace",
WindowDidChangeScreenSpaceProperties: "mac:WindowDidChangeScreenSpaceProperties",
WindowDidChangeSharingType: "mac:WindowDidChangeSharingType",
WindowDidChangeSpace: "mac:WindowDidChangeSpace",
WindowDidChangeSpaceOrderingMode: "mac:WindowDidChangeSpaceOrderingMode",
WindowDidChangeTitle: "mac:WindowDidChangeTitle",
WindowDidChangeToolbar: "mac:WindowDidChangeToolbar",
WindowDidDeminiaturize: "mac:WindowDidDeminiaturize",
WindowDidEndSheet: "mac:WindowDidEndSheet",
WindowDidEnterFullScreen: "mac:WindowDidEnterFullScreen",
WindowMaximise: "mac:WindowMaximise",
WindowUnMaximise: "mac:WindowUnMaximise",
WindowDidZoom: "mac:WindowDidZoom!",
WindowZoomIn: "mac:WindowZoomIn!",
WindowZoomOut: "mac:WindowZoomOut!",
WindowZoomReset: "mac:WindowZoomReset!",
WindowDidEnterVersionBrowser: "mac:WindowDidEnterVersionBrowser",
WindowDidExitFullScreen: "mac:WindowDidExitFullScreen",
WindowDidExitVersionBrowser: "mac:WindowDidExitVersionBrowser",
WindowDidExpose: "mac:WindowDidExpose",
WindowDidFocus: "mac:WindowDidFocus",
WindowDidMiniaturize: "mac:WindowDidMiniaturize",
WindowDidMove: "mac:WindowDidMove",
WindowDidOrderOffScreen: "mac:WindowDidOrderOffScreen",
WindowDidOrderOnScreen: "mac:WindowDidOrderOnScreen",
WindowDidResignKey: "mac:WindowDidResignKey",
WindowDidResignMain: "mac:WindowDidResignMain",
WindowDidResize: "mac:WindowDidResize",
WindowDidUpdate: "mac:WindowDidUpdate",
WindowDidUpdateAlpha: "mac:WindowDidUpdateAlpha",
WindowDidUpdateCollectionBehavior: "mac:WindowDidUpdateCollectionBehavior",
WindowDidUpdateCollectionProperties: "mac:WindowDidUpdateCollectionProperties",
WindowDidUpdateShadow: "mac:WindowDidUpdateShadow",
WindowDidUpdateTitle: "mac:WindowDidUpdateTitle",
WindowDidUpdateToolbar: "mac:WindowDidUpdateToolbar",
WindowShouldClose: "mac:WindowShouldClose!",
WindowWillBecomeKey: "mac:WindowWillBecomeKey",
WindowWillBecomeMain: "mac:WindowWillBecomeMain",
WindowWillBeginSheet: "mac:WindowWillBeginSheet",
WindowWillChangeOrderingMode: "mac:WindowWillChangeOrderingMode",
WindowWillClose: "mac:WindowWillClose",
WindowWillDeminiaturize: "mac:WindowWillDeminiaturize",
WindowWillEnterFullScreen: "mac:WindowWillEnterFullScreen",
WindowWillEnterVersionBrowser: "mac:WindowWillEnterVersionBrowser",
WindowWillExitFullScreen: "mac:WindowWillExitFullScreen",
WindowWillExitVersionBrowser: "mac:WindowWillExitVersionBrowser",
WindowWillFocus: "mac:WindowWillFocus",
WindowWillMiniaturize: "mac:WindowWillMiniaturize",
WindowWillMove: "mac:WindowWillMove",
WindowWillOrderOffScreen: "mac:WindowWillOrderOffScreen",
WindowWillOrderOnScreen: "mac:WindowWillOrderOnScreen",
WindowWillResignMain: "mac:WindowWillResignMain",
WindowWillResize: "mac:WindowWillResize",
WindowWillUnfocus: "mac:WindowWillUnfocus",
WindowWillUpdate: "mac:WindowWillUpdate",
WindowWillUpdateAlpha: "mac:WindowWillUpdateAlpha",
WindowWillUpdateCollectionBehavior: "mac:WindowWillUpdateCollectionBehavior",
WindowWillUpdateCollectionProperties: "mac:WindowWillUpdateCollectionProperties",
WindowWillUpdateShadow: "mac:WindowWillUpdateShadow",
WindowWillUpdateTitle: "mac:WindowWillUpdateTitle",
WindowWillUpdateToolbar: "mac:WindowWillUpdateToolbar",
WindowWillUpdateVisibility: "mac:WindowWillUpdateVisibility",
WindowWillUseStandardFrame: "mac:WindowWillUseStandardFrame",
MenuWillOpen: "mac:MenuWillOpen",
MenuDidOpen: "mac:MenuDidOpen",
MenuDidClose: "mac:MenuDidClose",
MenuWillSendAction: "mac:MenuWillSendAction",
MenuDidSendAction: "mac:MenuDidSendAction",
MenuWillHighlightItem: "mac:MenuWillHighlightItem",
MenuDidHighlightItem: "mac:MenuDidHighlightItem",
MenuWillDisplayItem: "mac:MenuWillDisplayItem",
MenuDidDisplayItem: "mac:MenuDidDisplayItem",
MenuWillAddItem: "mac:MenuWillAddItem",
MenuDidAddItem: "mac:MenuDidAddItem",
MenuWillRemoveItem: "mac:MenuWillRemoveItem",
MenuDidRemoveItem: "mac:MenuDidRemoveItem",
MenuWillBeginTracking: "mac:MenuWillBeginTracking",
MenuDidBeginTracking: "mac:MenuDidBeginTracking",
MenuWillEndTracking: "mac:MenuWillEndTracking",
MenuDidEndTracking: "mac:MenuDidEndTracking",
MenuWillUpdate: "mac:MenuWillUpdate",
MenuDidUpdate: "mac:MenuDidUpdate",
MenuWillPopUp: "mac:MenuWillPopUp",
MenuDidPopUp: "mac:MenuDidPopUp",
MenuWillSendActionToItem: "mac:MenuWillSendActionToItem",
MenuDidSendActionToItem: "mac:MenuDidSendActionToItem",
WebViewDidStartProvisionalNavigation: "mac:WebViewDidStartProvisionalNavigation",
WebViewDidReceiveServerRedirectForProvisionalNavigation: "mac:WebViewDidReceiveServerRedirectForProvisionalNavigation",
WebViewDidFinishNavigation: "mac:WebViewDidFinishNavigation",
WebViewDidCommitNavigation: "mac:WebViewDidCommitNavigation",
WindowFileDraggingEntered: "mac:WindowFileDraggingEntered",
WindowFileDraggingPerformed: "mac:WindowFileDraggingPerformed",
WindowFileDraggingExited: "mac:WindowFileDraggingExited",
WindowShow: "mac:WindowShow",
WindowHide: "mac:WindowHide",
},
Linux: {
SystemThemeChanged: "linux:SystemThemeChanged",
WindowLoadChanged: "linux:WindowLoadChanged",
WindowDeleteEvent: "linux:WindowDeleteEvent",
WindowDidMove: "linux:WindowDidMove",
WindowDidResize: "linux:WindowDidResize",
WindowFocusIn: "linux:WindowFocusIn",
WindowFocusOut: "linux:WindowFocusOut",
ApplicationStartup: "linux:ApplicationStartup",
},
Common: {
ApplicationStarted: "common:ApplicationStarted",
WindowMaximise: "common:WindowMaximise",
WindowUnMaximise: "common:WindowUnMaximise",
WindowFullscreen: "common:WindowFullscreen",
WindowUnFullscreen: "common:WindowUnFullscreen",
WindowRestore: "common:WindowRestore",
WindowMinimise: "common:WindowMinimise",
WindowUnMinimise: "common:WindowUnMinimise",
WindowClosing: "common:WindowClosing",
WindowZoom: "common:WindowZoom",
WindowZoomIn: "common:WindowZoomIn",
WindowZoomOut: "common:WindowZoomOut",
WindowZoomReset: "common:WindowZoomReset",
WindowFocus: "common:WindowFocus",
WindowLostFocus: "common:WindowLostFocus",
WindowShow: "common:WindowShow",
WindowHide: "common:WindowHide",
WindowDPIChanged: "common:WindowDPIChanged",
WindowFilesDropped: "common:WindowFilesDropped",
WindowRuntimeReady: "common:WindowRuntimeReady",
ThemeChanged: "common:ThemeChanged",
WindowDidMove: "common:WindowDidMove",
WindowDidResize: "common:WindowDidResize",
ApplicationOpenedWithFile: "common:ApplicationOpenedWithFile",
},
};

140
frontend/node_modules/@wailsio/runtime/src/events.js generated vendored Normal file
View File

@@ -0,0 +1,140 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
/**
* @typedef {import("./types").WailsEvent} WailsEvent
*/
import {newRuntimeCallerWithID, objectNames} from "./runtime";
import {EventTypes} from "./event_types";
export const Types = EventTypes;
// Setup
window._wails = window._wails || {};
window._wails.dispatchWailsEvent = dispatchWailsEvent;
const call = newRuntimeCallerWithID(objectNames.Events, '');
const EmitMethod = 0;
const eventListeners = new Map();
class Listener {
constructor(eventName, callback, maxCallbacks) {
this.eventName = eventName;
this.maxCallbacks = maxCallbacks || -1;
this.Callback = (data) => {
callback(data);
if (this.maxCallbacks === -1) return false;
this.maxCallbacks -= 1;
return this.maxCallbacks === 0;
};
}
}
export class WailsEvent {
constructor(name, data = null) {
this.name = name;
this.data = data;
}
}
export function setup() {
}
function dispatchWailsEvent(event) {
let listeners = eventListeners.get(event.name);
if (listeners) {
let toRemove = listeners.filter(listener => {
let remove = listener.Callback(event);
if (remove) return true;
});
if (toRemove.length > 0) {
listeners = listeners.filter(l => !toRemove.includes(l));
if (listeners.length === 0) eventListeners.delete(event.name);
else eventListeners.set(event.name, listeners);
}
}
}
/**
* 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.
*/
export function OnMultiple(eventName, callback, maxCallbacks) {
let listeners = eventListeners.get(eventName) || [];
const thisListener = new Listener(eventName, callback, maxCallbacks);
listeners.push(thisListener);
eventListeners.set(eventName, listeners);
return () => listenerOff(thisListener);
}
/**
* Registers a callback function to be executed when the specified event occurs.
*
* @param {string} eventName - The name of the event.
* @param {function} callback - The callback function to be executed. It takes no parameters.
* @return {function} - A function that, when called, will unregister the callback from the event. */
export function On(eventName, callback) { return OnMultiple(eventName, callback, -1); }
/**
* Registers a callback function to be executed only once for the specified event.
*
* @param {string} eventName - The name of the event.
* @param {function} callback - The function to be executed when the event occurs.
* @return {function} - A function that, when called, will unregister the callback from the event.
*/
export function Once(eventName, callback) { return OnMultiple(eventName, callback, 1); }
/**
* 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.
*/
function listenerOff(listener) {
const eventName = listener.eventName;
let listeners = eventListeners.get(eventName).filter(l => l !== listener);
if (listeners.length === 0) eventListeners.delete(eventName);
else eventListeners.set(eventName, listeners);
}
/**
* 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}
*/
export function Off(eventName, ...additionalEventNames) {
let eventsToRemove = [eventName, ...additionalEventNames];
eventsToRemove.forEach(eventName => eventListeners.delete(eventName));
}
/**
* Removes all event listeners.
*
* @function OffAll
* @returns {void}
*/
export function OffAll() { eventListeners.clear(); }
/**
* Emits an event using the given event name.
*
* @param {WailsEvent} event - The name of the event to emit.
* @returns {any} - The result of the emitted event.
*/
export function Emit(event) { return call(EmitMethod, event); }

25
frontend/node_modules/@wailsio/runtime/src/flags.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
/**
* Retrieves the value associated with the specified key from the flag map.
*
* @param {string} keyString - The key to retrieve the value for.
* @return {*} - The value associated with the specified key.
*/
export function GetFlag(keyString) {
try {
return window._wails.flags[keyString];
} catch (e) {
throw new Error("Unable to retrieve flag '" + keyString + "': " + e);
}
}

60
frontend/node_modules/@wailsio/runtime/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
// Setup
window._wails = window._wails || {};
import "./contextmenu";
import "./drag";
// Re-export public API
import * as Application from "./application";
import * as Browser from "./browser";
import * as Call from "./calls";
import * as Clipboard from "./clipboard";
import * as Create from "./create";
import * as Dialogs from "./dialogs";
import * as Events from "./events";
import * as Flags from "./flags";
import * as Screens from "./screens";
import * as System from "./system";
import Window from "./window";
import * as WML from "./wml";
export {
Application,
Browser,
Call,
Clipboard,
Create,
Dialogs,
Events,
Flags,
Screens,
System,
Window,
WML
};
let initialised = false;
export function init() {
window._wails.invoke = System.invoke;
System.invoke("wails:runtime:ready");
initialised = true;
}
window.addEventListener("load", () => {
if (!initialised) {
init();
}
});
// Notify backend

123
frontend/node_modules/@wailsio/runtime/src/runtime.js generated vendored Normal file
View File

@@ -0,0 +1,123 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
import { nanoid } from 'nanoid/non-secure';
const runtimeURL = window.location.origin + "/wails/runtime";
// Object Names
export const objectNames = {
Call: 0,
Clipboard: 1,
Application: 2,
Events: 3,
ContextMenu: 4,
Dialog: 5,
Window: 6,
Screens: 7,
System: 8,
Browser: 9,
CancelCall: 10,
}
export let clientId = nanoid();
/**
* Creates a runtime caller function that invokes a specified method on a given object within a specified window context.
*
* @param {Object} object - The object on which the method is to be invoked.
* @param {string} windowName - The name of the window context in which the method should be called.
* @returns {Function} A runtime caller function that takes the method name and optionally arguments and invokes the method within the specified window context.
*/
export function newRuntimeCaller(object, windowName) {
return function (method, args=null) {
return runtimeCall(object + "." + method, windowName, args);
};
}
/**
* Creates a new runtime caller with specified ID.
*
* @param {object} object - The object to invoke the method on.
* @param {string} windowName - The name of the window.
* @return {Function} - The new runtime caller function.
*/
export function newRuntimeCallerWithID(object, windowName) {
return function (method, args=null) {
return runtimeCallWithID(object, method, windowName, args);
};
}
function runtimeCall(method, windowName, args) {
let url = new URL(runtimeURL);
if( method ) {
url.searchParams.append("method", method);
}
let fetchOptions = {
headers: {},
};
if (windowName) {
fetchOptions.headers["x-wails-window-name"] = windowName;
}
if (args) {
url.searchParams.append("args", JSON.stringify(args));
}
fetchOptions.headers["x-wails-client-id"] = clientId;
return new Promise((resolve, reject) => {
fetch(url, fetchOptions)
.then(response => {
if (response.ok) {
// check content type
if (response.headers.get("Content-Type") && response.headers.get("Content-Type").indexOf("application/json") !== -1) {
return response.json();
} else {
return response.text();
}
}
reject(Error(response.statusText));
})
.then(data => resolve(data))
.catch(error => reject(error));
});
}
function runtimeCallWithID(objectID, method, windowName, args) {
let url = new URL(runtimeURL);
url.searchParams.append("object", objectID);
url.searchParams.append("method", method);
let fetchOptions = {
headers: {},
};
if (windowName) {
fetchOptions.headers["x-wails-window-name"] = windowName;
}
if (args) {
url.searchParams.append("args", JSON.stringify(args));
}
fetchOptions.headers["x-wails-client-id"] = clientId;
return new Promise((resolve, reject) => {
fetch(url, fetchOptions)
.then(response => {
if (response.ok) {
// check content type
if (response.headers.get("Content-Type") && response.headers.get("Content-Type").indexOf("application/json") !== -1) {
return response.json();
} else {
return response.text();
}
}
reject(Error(response.statusText));
})
.then(data => resolve(data))
.catch(error => reject(error));
});
}

71
frontend/node_modules/@wailsio/runtime/src/screens.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
/**
* @typedef {Object} Size
* @property {number} Width - The width.
* @property {number} Height - The height.
*/
/**
* @typedef {Object} Rect
* @property {number} X - The X coordinate of the origin.
* @property {number} Y - The Y coordinate of the origin.
* @property {number} Width - The width of the rectangle.
* @property {number} Height - The height of the rectangle.
*/
/**
* @typedef {Object} Screen
* @property {string} ID - Unique identifier for the screen.
* @property {string} Name - Human readable name of the screen.
* @property {number} ScaleFactor - The scale factor of the screen (DPI/96). 1 = standard DPI, 2 = HiDPI (Retina), etc.
* @property {number} X - The X coordinate of the screen.
* @property {number} Y - The Y coordinate of the screen.
* @property {Size} Size - Contains the width and height of the screen.
* @property {Rect} Bounds - Contains the bounds of the screen in terms of X, Y, Width, and Height.
* @property {Rect} PhysicalBounds - Contains the physical bounds of the screen in terms of X, Y, Width, and Height (before scaling).
* @property {Rect} WorkArea - Contains the area of the screen that is actually usable (excluding taskbar and other system UI).
* @property {Rect} PhysicalWorkArea - Contains the physical WorkArea of the screen (before scaling).
* @property {boolean} IsPrimary - True if this is the primary monitor selected by the user in the operating system.
* @property {number} Rotation - The rotation of the screen.
*/
import { newRuntimeCallerWithID, objectNames } from "./runtime";
const call = newRuntimeCallerWithID(objectNames.Screens, "");
const getAll = 0;
const getPrimary = 1;
const getCurrent = 2;
/**
* Gets all screens.
* @returns {Promise<Screen[]>} A promise that resolves to an array of Screen objects.
*/
export function GetAll() {
return call(getAll);
}
/**
* Gets the primary screen.
* @returns {Promise<Screen>} A promise that resolves to the primary screen.
*/
export function GetPrimary() {
return call(getPrimary);
}
/**
* Gets the current active screen.
*
* @returns {Promise<Screen>} A promise that resolves with the current active screen.
*/
export function GetCurrent() {
return call(getCurrent);
}

143
frontend/node_modules/@wailsio/runtime/src/system.js generated vendored Normal file
View File

@@ -0,0 +1,143 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
import {newRuntimeCallerWithID, objectNames} from "./runtime";
let call = newRuntimeCallerWithID(objectNames.System, '');
const systemIsDarkMode = 0;
const environment = 1;
const _invoke = (() => {
try {
if(window?.chrome?.webview) {
return (msg) => window.chrome.webview.postMessage(msg);
}
if(window?.webkit?.messageHandlers?.external) {
return (msg) => window.webkit.messageHandlers.external.postMessage(msg);
}
} catch(e) {
console.warn('\n%c⚠ Browser Environment Detected %c\n\n%cOnly UI previews are available in the browser. For full functionality, please run the application in desktop mode.\nMore information at: https://v3alpha.wails.io/learn/build/#using-a-browser-for-development\n',
'background: #ffffff; color: #000000; font-weight: bold; padding: 4px 8px; border-radius: 4px; border: 2px solid #000000;',
'background: transparent;',
'color: #ffffff; font-style: italic; font-weight: bold;');
}
return null;
})();
export function invoke(msg) {
if (!_invoke) return;
return _invoke(msg);
}
/**
* @function
* Retrieves the system dark mode status.
* @returns {Promise<boolean>} - A promise that resolves to a boolean value indicating if the system is in dark mode.
*/
export function IsDarkMode() {
return call(systemIsDarkMode);
}
/**
* Fetches the capabilities of the application from the server.
*
* @async
* @function Capabilities
* @returns {Promise<Object>} A promise that resolves to an object containing the capabilities.
*/
export function Capabilities() {
let response = fetch("/wails/capabilities");
return response.json();
}
/**
* @typedef {Object} OSInfo
* @property {string} Branding - The branding of the OS.
* @property {string} ID - The ID of the OS.
* @property {string} Name - The name of the OS.
* @property {string} Version - The version of the OS.
*/
/**
* @typedef {Object} EnvironmentInfo
* @property {string} Arch - The architecture of the system.
* @property {boolean} Debug - True if the application is running in debug mode, otherwise false.
* @property {string} OS - The operating system in use.
* @property {OSInfo} OSInfo - Details of the operating system.
* @property {Object} PlatformInfo - Additional platform information.
*/
/**
* @function
* Retrieves environment details.
* @returns {Promise<EnvironmentInfo>} - A promise that resolves to an object containing OS and system architecture.
*/
export function Environment() {
return call(environment);
}
/**
* Checks if the current operating system is Windows.
*
* @return {boolean} True if the operating system is Windows, otherwise false.
*/
export function IsWindows() {
return window._wails.environment.OS === "windows";
}
/**
* Checks if the current operating system is Linux.
*
* @returns {boolean} Returns true if the current operating system is Linux, false otherwise.
*/
export function IsLinux() {
return window._wails.environment.OS === "linux";
}
/**
* Checks if the current environment is a macOS operating system.
*
* @returns {boolean} True if the environment is macOS, false otherwise.
*/
export function IsMac() {
return window._wails.environment.OS === "darwin";
}
/**
* Checks if the current environment architecture is AMD64.
* @returns {boolean} True if the current environment architecture is AMD64, false otherwise.
*/
export function IsAMD64() {
return window._wails.environment.Arch === "amd64";
}
/**
* Checks if the current architecture is ARM.
*
* @returns {boolean} True if the current architecture is ARM, false otherwise.
*/
export function IsARM() {
return window._wails.environment.Arch === "arm";
}
/**
* Checks if the current environment is ARM64 architecture.
*
* @returns {boolean} - Returns true if the environment is ARM64 architecture, otherwise returns false.
*/
export function IsARM64() {
return window._wails.environment.Arch === "arm64";
}
export function IsDebug() {
return window._wails.environment.Debug === true;
}

86
frontend/node_modules/@wailsio/runtime/src/utils.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/**
* Logs a message to the console with custom formatting.
* @param {string} message - The message to be logged.
* @return {void}
*/
export function debugLog(message) {
// eslint-disable-next-line
console.log(
'%c wails3 %c ' + message + ' ',
'background: #aa0000; color: #fff; border-radius: 3px 0px 0px 3px; padding: 1px; font-size: 0.7rem',
'background: #009900; color: #fff; border-radius: 0px 3px 3px 0px; padding: 1px; font-size: 0.7rem'
);
}
/**
* Checks whether the browser supports removing listeners by triggering an AbortSignal
* (see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#signal)
*
* @return {boolean}
*/
export function canAbortListeners() {
if (!EventTarget || !AbortSignal || !AbortController)
return false;
let result = true;
const target = new EventTarget();
const controller = new AbortController();
target.addEventListener('test', () => { result = false; }, { signal: controller.signal });
controller.abort();
target.dispatchEvent(new CustomEvent('test'));
return result;
}
/***
This technique for proper load detection is taken from HTMX:
BSD 2-Clause License
Copyright (c) 2020, Big Sky Software
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***/
let isReady = false;
document.addEventListener('DOMContentLoaded', () => isReady = true);
export function whenReady(callback) {
if (isReady || document.readyState === 'complete') {
callback();
} else {
document.addEventListener('DOMContentLoaded', callback);
}
}

638
frontend/node_modules/@wailsio/runtime/src/window.js generated vendored Normal file
View File

@@ -0,0 +1,638 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
// Import screen jsdoc definition from ./screens.js
/**
* @typedef {import("./screens").Screen} Screen
*/
/**
* A record describing the position of a window.
*
* @typedef {Object} Position
* @property {number} x - The horizontal position of the window
* @property {number} y - The vertical position of the window
*/
/**
* A record describing the size of a window.
*
* @typedef {Object} Size
* @property {number} width - The width of the window
* @property {number} height - The height of the window
*/
import {newRuntimeCallerWithID, objectNames} from "./runtime";
const PositionMethod = 0;
const CenterMethod = 1;
const CloseMethod = 2;
const DisableSizeConstraintsMethod = 3;
const EnableSizeConstraintsMethod = 4;
const FocusMethod = 5;
const ForceReloadMethod = 6;
const FullscreenMethod = 7;
const GetScreenMethod = 8;
const GetZoomMethod = 9;
const HeightMethod = 10;
const HideMethod = 11;
const IsFocusedMethod = 12;
const IsFullscreenMethod = 13;
const IsMaximisedMethod = 14;
const IsMinimisedMethod = 15;
const MaximiseMethod = 16;
const MinimiseMethod = 17;
const NameMethod = 18;
const OpenDevToolsMethod = 19;
const RelativePositionMethod = 20;
const ReloadMethod = 21;
const ResizableMethod = 22;
const RestoreMethod = 23;
const SetPositionMethod = 24;
const SetAlwaysOnTopMethod = 25;
const SetBackgroundColourMethod = 26;
const SetFramelessMethod = 27;
const SetFullscreenButtonEnabledMethod = 28;
const SetMaxSizeMethod = 29;
const SetMinSizeMethod = 30;
const SetRelativePositionMethod = 31;
const SetResizableMethod = 32;
const SetSizeMethod = 33;
const SetTitleMethod = 34;
const SetZoomMethod = 35;
const ShowMethod = 36;
const SizeMethod = 37;
const ToggleFullscreenMethod = 38;
const ToggleMaximiseMethod = 39;
const UnFullscreenMethod = 40;
const UnMaximiseMethod = 41;
const UnMinimiseMethod = 42;
const WidthMethod = 43;
const ZoomMethod = 44;
const ZoomInMethod = 45;
const ZoomOutMethod = 46;
const ZoomResetMethod = 47;
/**
* @type {symbol}
*/
const caller = Symbol();
export class Window {
/**
* Initialises a window object with the specified name.
*
* @private
* @param {string} name - The name of the target window.
*/
constructor(name = '') {
/**
* @private
* @name {@link caller}
* @type {(...args: any[]) => any}
*/
this[caller] = newRuntimeCallerWithID(objectNames.Window, name)
// bind instance method to make them easily usable in event handlers
for (const method of Object.getOwnPropertyNames(Window.prototype)) {
if (
method !== "constructor"
&& typeof this[method] === "function"
) {
this[method] = this[method].bind(this);
}
}
}
/**
* Gets the specified window.
*
* @public
* @param {string} name - The name of the window to get.
* @return {Window} - The corresponding window object.
*/
Get(name) {
return new Window(name);
}
/**
* Returns the absolute position of the window.
*
* @public
* @return {Promise<Position>} - The current absolute position of the window.
*/
Position() {
return this[caller](PositionMethod);
}
/**
* Centers the window on the screen.
*
* @public
* @return {Promise<void>}
*/
Center() {
return this[caller](CenterMethod);
}
/**
* Closes the window.
*
* @public
* @return {Promise<void>}
*/
Close() {
return this[caller](CloseMethod);
}
/**
* Disables min/max size constraints.
*
* @public
* @return {Promise<void>}
*/
DisableSizeConstraints() {
return this[caller](DisableSizeConstraintsMethod);
}
/**
* Enables min/max size constraints.
*
* @public
* @return {Promise<void>}
*/
EnableSizeConstraints() {
return this[caller](EnableSizeConstraintsMethod);
}
/**
* Focuses the window.
*
* @public
* @return {Promise<void>}
*/
Focus() {
return this[caller](FocusMethod);
}
/**
* Forces the window to reload the page assets.
*
* @public
* @return {Promise<void>}
*/
ForceReload() {
return this[caller](ForceReloadMethod);
}
/**
* Doc.
*
* @public
* @return {Promise<void>}
*/
Fullscreen() {
return this[caller](FullscreenMethod);
}
/**
* Returns the screen that the window is on.
*
* @public
* @return {Promise<Screen>} - The screen the window is currently on
*/
GetScreen() {
return this[caller](GetScreenMethod);
}
/**
* Returns the current zoom level of the window.
*
* @public
* @return {Promise<number>} - The current zoom level
*/
GetZoom() {
return this[caller](GetZoomMethod);
}
/**
* Returns the height of the window.
*
* @public
* @return {Promise<number>} - The current height of the window
*/
Height() {
return this[caller](HeightMethod);
}
/**
* Hides the window.
*
* @public
* @return {Promise<void>}
*/
Hide() {
return this[caller](HideMethod);
}
/**
* Returns true if the window is focused.
*
* @public
* @return {Promise<boolean>} - Whether the window is currently focused
*/
IsFocused() {
return this[caller](IsFocusedMethod);
}
/**
* Returns true if the window is fullscreen.
*
* @public
* @return {Promise<boolean>} - Whether the window is currently fullscreen
*/
IsFullscreen() {
return this[caller](IsFullscreenMethod);
}
/**
* Returns true if the window is maximised.
*
* @public
* @return {Promise<boolean>} - Whether the window is currently maximised
*/
IsMaximised() {
return this[caller](IsMaximisedMethod);
}
/**
* Returns true if the window is minimised.
*
* @public
* @return {Promise<boolean>} - Whether the window is currently minimised
*/
IsMinimised() {
return this[caller](IsMinimisedMethod);
}
/**
* Maximises the window.
*
* @public
* @return {Promise<void>}
*/
Maximise() {
return this[caller](MaximiseMethod);
}
/**
* Minimises the window.
*
* @public
* @return {Promise<void>}
*/
Minimise() {
return this[caller](MinimiseMethod);
}
/**
* Returns the name of the window.
*
* @public
* @return {Promise<string>} - The name of the window
*/
Name() {
return this[caller](NameMethod);
}
/**
* Opens the development tools pane.
*
* @public
* @return {Promise<void>}
*/
OpenDevTools() {
return this[caller](OpenDevToolsMethod);
}
/**
* Returns the relative position of the window to the screen.
*
* @public
* @return {Promise<Position>} - The current relative position of the window
*/
RelativePosition() {
return this[caller](RelativePositionMethod);
}
/**
* Reloads the page assets.
*
* @public
* @return {Promise<void>}
*/
Reload() {
return this[caller](ReloadMethod);
}
/**
* Returns true if the window is resizable.
*
* @public
* @return {Promise<boolean>} - Whether the window is currently resizable
*/
Resizable() {
return this[caller](ResizableMethod);
}
/**
* Restores the window to its previous state if it was previously minimised, maximised or fullscreen.
*
* @public
* @return {Promise<void>}
*/
Restore() {
return this[caller](RestoreMethod);
}
/**
* Sets the absolute position of the window.
*
* @public
* @param {number} x - The desired horizontal absolute position of the window
* @param {number} y - The desired vertical absolute position of the window
* @return {Promise<void>}
*/
SetPosition(x, y) {
return this[caller](SetPositionMethod, { x, y });
}
/**
* Sets the window to be always on top.
*
* @public
* @param {boolean} alwaysOnTop - Whether the window should stay on top
* @return {Promise<void>}
*/
SetAlwaysOnTop(alwaysOnTop) {
return this[caller](SetAlwaysOnTopMethod, { alwaysOnTop });
}
/**
* Sets the background colour of the window.
*
* @public
* @param {number} r - The desired red component of the window background
* @param {number} g - The desired green component of the window background
* @param {number} b - The desired blue component of the window background
* @param {number} a - The desired alpha component of the window background
* @return {Promise<void>}
*/
SetBackgroundColour(r, g, b, a) {
return this[caller](SetBackgroundColourMethod, { r, g, b, a });
}
/**
* Removes the window frame and title bar.
*
* @public
* @param {boolean} frameless - Whether the window should be frameless
* @return {Promise<void>}
*/
SetFrameless(frameless) {
return this[caller](SetFramelessMethod, { frameless });
}
/**
* Disables the system fullscreen button.
*
* @public
* @param {boolean} enabled - Whether the fullscreen button should be enabled
* @return {Promise<void>}
*/
SetFullscreenButtonEnabled(enabled) {
return this[caller](SetFullscreenButtonEnabledMethod, { enabled });
}
/**
* Sets the maximum size of the window.
*
* @public
* @param {number} width - The desired maximum width of the window
* @param {number} height - The desired maximum height of the window
* @return {Promise<void>}
*/
SetMaxSize(width, height) {
return this[caller](SetMaxSizeMethod, { width, height });
}
/**
* Sets the minimum size of the window.
*
* @public
* @param {number} width - The desired minimum width of the window
* @param {number} height - The desired minimum height of the window
* @return {Promise<void>}
*/
SetMinSize(width, height) {
return this[caller](SetMinSizeMethod, { width, height });
}
/**
* Sets the relative position of the window to the screen.
*
* @public
* @param {number} x - The desired horizontal relative position of the window
* @param {number} y - The desired vertical relative position of the window
* @return {Promise<void>}
*/
SetRelativePosition(x, y) {
return this[caller](SetRelativePositionMethod, { x, y });
}
/**
* Sets whether the window is resizable.
*
* @public
* @param {boolean} resizable - Whether the window should be resizable
* @return {Promise<void>}
*/
SetResizable(resizable) {
return this[caller](SetResizableMethod, { resizable });
}
/**
* Sets the size of the window.
*
* @public
* @param {number} width - The desired width of the window
* @param {number} height - The desired height of the window
* @return {Promise<void>}
*/
SetSize(width, height) {
return this[caller](SetSizeMethod, { width, height });
}
/**
* Sets the title of the window.
*
* @public
* @param {string} title - The desired title of the window
* @return {Promise<void>}
*/
SetTitle(title) {
return this[caller](SetTitleMethod, { title });
}
/**
* Sets the zoom level of the window.
*
* @public
* @param {number} zoom - The desired zoom level
* @return {Promise<void>}
*/
SetZoom(zoom) {
return this[caller](SetZoomMethod, { zoom });
}
/**
* Shows the window.
*
* @public
* @return {Promise<void>}
*/
Show() {
return this[caller](ShowMethod);
}
/**
* Returns the size of the window.
*
* @public
* @return {Promise<Size>} - The current size of the window
*/
Size() {
return this[caller](SizeMethod);
}
/**
* Toggles the window between fullscreen and normal.
*
* @public
* @return {Promise<void>}
*/
ToggleFullscreen() {
return this[caller](ToggleFullscreenMethod);
}
/**
* Toggles the window between maximised and normal.
*
* @public
* @return {Promise<void>}
*/
ToggleMaximise() {
return this[caller](ToggleMaximiseMethod);
}
/**
* Un-fullscreens the window.
*
* @public
* @return {Promise<void>}
*/
UnFullscreen() {
return this[caller](UnFullscreenMethod);
}
/**
* Un-maximises the window.
*
* @public
* @return {Promise<void>}
*/
UnMaximise() {
return this[caller](UnMaximiseMethod);
}
/**
* Un-minimises the window.
*
* @public
* @return {Promise<void>}
*/
UnMinimise() {
return this[caller](UnMinimiseMethod);
}
/**
* Returns the width of the window.
*
* @public
* @return {Promise<number>} - The current width of the window
*/
Width() {
return this[caller](WidthMethod);
}
/**
* Zooms the window.
*
* @public
* @return {Promise<void>}
*/
Zoom() {
return this[caller](ZoomMethod);
}
/**
* Increases the zoom level of the webview content.
*
* @public
* @return {Promise<void>}
*/
ZoomIn() {
return this[caller](ZoomInMethod);
}
/**
* Decreases the zoom level of the webview content.
*
* @public
* @return {Promise<void>}
*/
ZoomOut() {
return this[caller](ZoomOutMethod);
}
/**
* Resets the zoom level of the webview content.
*
* @public
* @return {Promise<void>}
*/
ZoomReset() {
return this[caller](ZoomResetMethod);
}
}
/**
* The window within which the script is running.
*
* @type {Window}
*/
const thisWindow = new Window('');
export default thisWindow;

250
frontend/node_modules/@wailsio/runtime/src/wml.js generated vendored Normal file
View File

@@ -0,0 +1,250 @@
/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
import {OpenURL} from "./browser";
import {Question} from "./dialogs";
import {Emit, WailsEvent} from "./events";
import {canAbortListeners, whenReady} from "./utils";
import Window from "./window";
/**
* Sends an event with the given name and optional data.
*
* @param {string} eventName - The name of the event to send.
* @param {any} [data=null] - Optional data to send along with the event.
*
* @return {void}
*/
function sendEvent(eventName, data=null) {
Emit(new WailsEvent(eventName, data));
}
/**
* Calls a method on a specified window.
* @param {string} windowName - The name of the window to call the method on.
* @param {string} methodName - The name of the method to call.
*/
function callWindowMethod(windowName, methodName) {
const targetWindow = Window.Get(windowName);
const method = targetWindow[methodName];
if (typeof method !== "function") {
console.error(`Window method '${methodName}' not found`);
return;
}
try {
method.call(targetWindow);
} catch (e) {
console.error(`Error calling window method '${methodName}': `, e);
}
}
/**
* Responds to a triggering event by running appropriate WML actions for the current target
*
* @param {Event} ev
* @return {void}
*/
function onWMLTriggered(ev) {
const element = ev.currentTarget;
function runEffect(choice = "Yes") {
if (choice !== "Yes")
return;
const eventType = element.getAttribute('wml-event');
const targetWindow = element.getAttribute('wml-target-window') || "";
const windowMethod = element.getAttribute('wml-window');
const url = element.getAttribute('wml-openurl');
if (eventType !== null)
sendEvent(eventType);
if (windowMethod !== null)
callWindowMethod(targetWindow, windowMethod);
if (url !== null)
void OpenURL(url);
}
const confirm = element.getAttribute('wml-confirm');
if (confirm) {
Question({
Title: "Confirm",
Message: confirm,
Detached: false,
Buttons: [
{ Label: "Yes" },
{ Label: "No", IsDefault: true }
]
}).then(runEffect);
} else {
runEffect();
}
}
/**
* @type {symbol}
*/
const controller = Symbol();
/**
* AbortControllerRegistry does not actually remember active event listeners: instead
* it ties them to an AbortSignal and uses an AbortController to remove them all at once.
*/
class AbortControllerRegistry {
constructor() {
/**
* Stores the AbortController that can be used to remove all currently active listeners.
*
* @private
* @name {@link controller}
* @member {AbortController}
*/
this[controller] = new AbortController();
}
/**
* Returns an options object for addEventListener that ties the listener
* to the AbortSignal from the current AbortController.
*
* @param {HTMLElement} element An HTML element
* @param {string[]} triggers The list of active WML trigger events for the specified elements
* @returns {AddEventListenerOptions}
*/
set(element, triggers) {
return { signal: this[controller].signal };
}
/**
* Removes all registered event listeners.
*
* @returns {void}
*/
reset() {
this[controller].abort();
this[controller] = new AbortController();
}
}
/**
* @type {symbol}
*/
const triggerMap = Symbol();
/**
* @type {symbol}
*/
const elementCount = Symbol();
/**
* WeakMapRegistry maps active trigger events to each DOM element through a WeakMap.
* This ensures that the mapping remains private to this module, while still allowing garbage
* collection of the involved elements.
*/
class WeakMapRegistry {
constructor() {
/**
* Stores the current element-to-trigger mapping.
*
* @private
* @name {@link triggerMap}
* @member {WeakMap<HTMLElement, string[]>}
*/
this[triggerMap] = new WeakMap();
/**
* Counts the number of elements with active WML triggers.
*
* @private
* @name {@link elementCount}
* @member {number}
*/
this[elementCount] = 0;
}
/**
* Sets the active triggers for the specified element.
*
* @param {HTMLElement} element An HTML element
* @param {string[]} triggers The list of active WML trigger events for the specified element
* @returns {AddEventListenerOptions}
*/
set(element, triggers) {
this[elementCount] += !this[triggerMap].has(element);
this[triggerMap].set(element, triggers);
return {};
}
/**
* Removes all registered event listeners.
*
* @returns {void}
*/
reset() {
if (this[elementCount] <= 0)
return;
for (const element of document.body.querySelectorAll('*')) {
if (this[elementCount] <= 0)
break;
const triggers = this[triggerMap].get(element);
this[elementCount] -= (typeof triggers !== "undefined");
for (const trigger of triggers || [])
element.removeEventListener(trigger, onWMLTriggered);
}
this[triggerMap] = new WeakMap();
this[elementCount] = 0;
}
}
const triggerRegistry = canAbortListeners() ? new AbortControllerRegistry() : new WeakMapRegistry();
/**
* Adds event listeners to the specified element.
*
* @param {HTMLElement} element
* @return {void}
*/
function addWMLListeners(element) {
const triggerRegExp = /\S+/g;
const triggerAttr = (element.getAttribute('wml-trigger') || "click");
const triggers = [];
let match;
while ((match = triggerRegExp.exec(triggerAttr)) !== null)
triggers.push(match[0]);
const options = triggerRegistry.set(element, triggers);
for (const trigger of triggers)
element.addEventListener(trigger, onWMLTriggered, options);
}
/**
* Schedules an automatic reload of WML to be performed as soon as the document is fully loaded.
*
* @return {void}
*/
export function Enable() {
whenReady(Reload);
}
/**
* Reloads the WML page by adding necessary event listeners and browser listeners.
*
* @return {void}
*/
export function Reload() {
triggerRegistry.reset();
document.body.querySelectorAll('[wml-event], [wml-window], [wml-openurl]').forEach(addWMLListeners);
}