2659 lines
333 KiB
JavaScript
2659 lines
333 KiB
JavaScript
var __defProp = Object.defineProperty;
|
|||
|
|
var __defProps = Object.defineProperties;
|
||
|
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||
|
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||
|
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||
|
|
var __spreadValues = (a, b) => {
|
||
|
|
for (var prop in b || (b = {}))
|
||
|
|
if (__hasOwnProp.call(b, prop))
|
||
|
|
__defNormalProp(a, prop, b[prop]);
|
||
|
|
if (__getOwnPropSymbols)
|
||
|
|
for (var prop of __getOwnPropSymbols(b)) {
|
||
|
|
if (__propIsEnum.call(b, prop))
|
||
|
|
__defNormalProp(a, prop, b[prop]);
|
||
|
|
}
|
||
|
|
return a;
|
||
|
|
};
|
||
|
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||
|
|
var __export = (target, all) => {
|
||
|
|
for (var name in all)
|
||
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
||
|
|
};
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/index.ts
|
||
|
|
var index_exports = {};
|
||
|
|
__export(index_exports, {
|
||
|
|
Application: () => application_exports,
|
||
|
|
Browser: () => browser_exports,
|
||
|
|
Call: () => calls_exports,
|
||
|
|
CancelError: () => CancelError,
|
||
|
|
CancellablePromise: () => CancellablePromise,
|
||
|
|
CancelledRejectionError: () => CancelledRejectionError,
|
||
|
|
Clipboard: () => clipboard_exports,
|
||
|
|
Create: () => create_exports,
|
||
|
|
Dialogs: () => dialogs_exports,
|
||
|
|
Events: () => events_exports,
|
||
|
|
Flags: () => flags_exports,
|
||
|
|
Screens: () => screens_exports,
|
||
|
|
System: () => system_exports,
|
||
|
|
WML: () => wml_exports,
|
||
|
|
Window: () => window_default
|
||
|
|
});
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/wml.ts
|
||
|
|
var wml_exports = {};
|
||
|
|
__export(wml_exports, {
|
||
|
|
Enable: () => Enable,
|
||
|
|
Reload: () => Reload
|
||
|
|
});
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/browser.ts
|
||
|
|
var browser_exports = {};
|
||
|
|
__export(browser_exports, {
|
||
|
|
OpenURL: () => OpenURL
|
||
|
|
});
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/nanoid.ts
|
||
|
|
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
||
|
|
function nanoid(size = 21) {
|
||
|
|
let id = "";
|
||
|
|
let i = size | 0;
|
||
|
|
while (i--) {
|
||
|
|
id += urlAlphabet[Math.random() * 64 | 0];
|
||
|
|
}
|
||
|
|
return id;
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/runtime.ts
|
||
|
|
var runtimeURL = window.location.origin + "/wails/runtime";
|
||
|
|
var objectNames = Object.freeze({
|
||
|
|
Call: 0,
|
||
|
|
Clipboard: 1,
|
||
|
|
Application: 2,
|
||
|
|
Events: 3,
|
||
|
|
ContextMenu: 4,
|
||
|
|
Dialog: 5,
|
||
|
|
Window: 6,
|
||
|
|
Screens: 7,
|
||
|
|
System: 8,
|
||
|
|
Browser: 9,
|
||
|
|
CancelCall: 10
|
||
|
|
});
|
||
|
|
var clientId = nanoid();
|
||
|
|
function newRuntimeCaller(object, windowName = "") {
|
||
|
|
return function(method, args = null) {
|
||
|
|
return runtimeCallWithID(object, method, windowName, args);
|
||
|
|
};
|
||
|
|
}
|
||
|
|
async function runtimeCallWithID(objectID, method, windowName, args) {
|
||
|
|
var _a2, _b;
|
||
|
|
let url = new URL(runtimeURL);
|
||
|
|
url.searchParams.append("object", objectID.toString());
|
||
|
|
url.searchParams.append("method", method.toString());
|
||
|
|
if (args) {
|
||
|
|
url.searchParams.append("args", JSON.stringify(args));
|
||
|
|
}
|
||
|
|
let headers = {
|
||
|
|
["x-wails-client-id"]: clientId
|
||
|
|
};
|
||
|
|
if (windowName) {
|
||
|
|
headers["x-wails-window-name"] = windowName;
|
||
|
|
}
|
||
|
|
let response = await fetch(url, { headers });
|
||
|
|
if (!response.ok) {
|
||
|
|
throw new Error(await response.text());
|
||
|
|
}
|
||
|
|
if (((_b = (_a2 = response.headers.get("Content-Type")) == null ? void 0 : _a2.indexOf("application/json")) != null ? _b : -1) !== -1) {
|
||
|
|
return response.json();
|
||
|
|
} else {
|
||
|
|
return response.text();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/browser.ts
|
||
|
|
var call = newRuntimeCaller(objectNames.Browser);
|
||
|
|
var BrowserOpenURL = 0;
|
||
|
|
function OpenURL(url) {
|
||
|
|
return call(BrowserOpenURL, { url: url.toString() });
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/dialogs.ts
|
||
|
|
var dialogs_exports = {};
|
||
|
|
__export(dialogs_exports, {
|
||
|
|
Error: () => Error2,
|
||
|
|
Info: () => Info,
|
||
|
|
OpenFile: () => OpenFile,
|
||
|
|
Question: () => Question,
|
||
|
|
SaveFile: () => SaveFile,
|
||
|
|
Warning: () => Warning
|
||
|
|
});
|
||
|
|
window._wails = window._wails || {};
|
||
|
|
window._wails.dialogErrorCallback = dialogErrorCallback;
|
||
|
|
window._wails.dialogResultCallback = dialogResultCallback;
|
||
|
|
var call2 = newRuntimeCaller(objectNames.Dialog);
|
||
|
|
var dialogResponses = /* @__PURE__ */ new Map();
|
||
|
|
var DialogInfo = 0;
|
||
|
|
var DialogWarning = 1;
|
||
|
|
var DialogError = 2;
|
||
|
|
var DialogQuestion = 3;
|
||
|
|
var DialogOpenFile = 4;
|
||
|
|
var DialogSaveFile = 5;
|
||
|
|
function dialogResultCallback(id, data, isJSON) {
|
||
|
|
let resolvers = getAndDeleteResponse(id);
|
||
|
|
if (!resolvers) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (isJSON) {
|
||
|
|
try {
|
||
|
|
resolvers.resolve(JSON.parse(data));
|
||
|
|
} catch (err) {
|
||
|
|
resolvers.reject(new TypeError("could not parse result: " + err.message, { cause: err }));
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
resolvers.resolve(data);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function dialogErrorCallback(id, message) {
|
||
|
|
var _a2;
|
||
|
|
(_a2 = getAndDeleteResponse(id)) == null ? void 0 : _a2.reject(new window.Error(message));
|
||
|
|
}
|
||
|
|
function getAndDeleteResponse(id) {
|
||
|
|
const response = dialogResponses.get(id);
|
||
|
|
dialogResponses.delete(id);
|
||
|
|
return response;
|
||
|
|
}
|
||
|
|
function generateID() {
|
||
|
|
let result;
|
||
|
|
do {
|
||
|
|
result = nanoid();
|
||
|
|
} while (dialogResponses.has(result));
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
function dialog(type, options = {}) {
|
||
|
|
const id = generateID();
|
||
|
|
return new Promise((resolve, reject) => {
|
||
|
|
dialogResponses.set(id, { resolve, reject });
|
||
|
|
call2(type, Object.assign({ "dialog-id": id }, options)).catch((err) => {
|
||
|
|
dialogResponses.delete(id);
|
||
|
|
reject(err);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}
|
||
|
|
function Info(options) {
|
||
|
|
return dialog(DialogInfo, options);
|
||
|
|
}
|
||
|
|
function Warning(options) {
|
||
|
|
return dialog(DialogWarning, options);
|
||
|
|
}
|
||
|
|
function Error2(options) {
|
||
|
|
return dialog(DialogError, options);
|
||
|
|
}
|
||
|
|
function Question(options) {
|
||
|
|
return dialog(DialogQuestion, options);
|
||
|
|
}
|
||
|
|
function OpenFile(options) {
|
||
|
|
var _a2;
|
||
|
|
return (_a2 = dialog(DialogOpenFile, options)) != null ? _a2 : [];
|
||
|
|
}
|
||
|
|
function SaveFile(options) {
|
||
|
|
return dialog(DialogSaveFile, options);
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/events.ts
|
||
|
|
var events_exports = {};
|
||
|
|
__export(events_exports, {
|
||
|
|
Emit: () => Emit,
|
||
|
|
Off: () => Off,
|
||
|
|
OffAll: () => OffAll,
|
||
|
|
On: () => On,
|
||
|
|
OnMultiple: () => OnMultiple,
|
||
|
|
Once: () => Once,
|
||
|
|
Types: () => Types,
|
||
|
|
WailsEvent: () => WailsEvent
|
||
|
|
});
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/listener.ts
|
||
|
|
var eventListeners = /* @__PURE__ */ new Map();
|
||
|
|
var Listener = class {
|
||
|
|
constructor(eventName, callback, maxCallbacks) {
|
||
|
|
this.eventName = eventName;
|
||
|
|
this.callback = callback;
|
||
|
|
this.maxCallbacks = maxCallbacks || -1;
|
||
|
|
}
|
||
|
|
dispatch(data) {
|
||
|
|
try {
|
||
|
|
this.callback(data);
|
||
|
|
} catch (err) {
|
||
|
|
console.error(err);
|
||
|
|
}
|
||
|
|
if (this.maxCallbacks === -1) return false;
|
||
|
|
this.maxCallbacks -= 1;
|
||
|
|
return this.maxCallbacks === 0;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
function listenerOff(listener) {
|
||
|
|
let listeners = eventListeners.get(listener.eventName);
|
||
|
|
if (!listeners) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
listeners = listeners.filter((l) => l !== listener);
|
||
|
|
if (listeners.length === 0) {
|
||
|
|
eventListeners.delete(listener.eventName);
|
||
|
|
} else {
|
||
|
|
eventListeners.set(listener.eventName, listeners);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/event_types.ts
|
||
|
|
var Types = Object.freeze({
|
||
|
|
Windows: Object.freeze({
|
||
|
|
APMPowerSettingChange: "windows:APMPowerSettingChange",
|
||
|
|
APMPowerStatusChange: "windows:APMPowerStatusChange",
|
||
|
|
APMResumeAutomatic: "windows:APMResumeAutomatic",
|
||
|
|
APMResumeSuspend: "windows:APMResumeSuspend",
|
||
|
|
APMSuspend: "windows:APMSuspend",
|
||
|
|
ApplicationStarted: "windows:ApplicationStarted",
|
||
|
|
SystemThemeChanged: "windows:SystemThemeChanged",
|
||
|
|
WebViewNavigationCompleted: "windows:WebViewNavigationCompleted",
|
||
|
|
WindowActive: "windows:WindowActive",
|
||
|
|
WindowBackgroundErase: "windows:WindowBackgroundErase",
|
||
|
|
WindowClickActive: "windows:WindowClickActive",
|
||
|
|
WindowClosing: "windows:WindowClosing",
|
||
|
|
WindowDidMove: "windows:WindowDidMove",
|
||
|
|
WindowDidResize: "windows:WindowDidResize",
|
||
|
|
WindowDPIChanged: "windows:WindowDPIChanged",
|
||
|
|
WindowDragDrop: "windows:WindowDragDrop",
|
||
|
|
WindowDragEnter: "windows:WindowDragEnter",
|
||
|
|
WindowDragLeave: "windows:WindowDragLeave",
|
||
|
|
WindowDragOver: "windows:WindowDragOver",
|
||
|
|
WindowEndMove: "windows:WindowEndMove",
|
||
|
|
WindowEndResize: "windows:WindowEndResize",
|
||
|
|
WindowFullscreen: "windows:WindowFullscreen",
|
||
|
|
WindowHide: "windows:WindowHide",
|
||
|
|
WindowInactive: "windows:WindowInactive",
|
||
|
|
WindowKeyDown: "windows:WindowKeyDown",
|
||
|
|
WindowKeyUp: "windows:WindowKeyUp",
|
||
|
|
WindowKillFocus: "windows:WindowKillFocus",
|
||
|
|
WindowNonClientHit: "windows:WindowNonClientHit",
|
||
|
|
WindowNonClientMouseDown: "windows:WindowNonClientMouseDown",
|
||
|
|
WindowNonClientMouseLeave: "windows:WindowNonClientMouseLeave",
|
||
|
|
WindowNonClientMouseMove: "windows:WindowNonClientMouseMove",
|
||
|
|
WindowNonClientMouseUp: "windows:WindowNonClientMouseUp",
|
||
|
|
WindowPaint: "windows:WindowPaint",
|
||
|
|
WindowRestore: "windows:WindowRestore",
|
||
|
|
WindowSetFocus: "windows:WindowSetFocus",
|
||
|
|
WindowShow: "windows:WindowShow",
|
||
|
|
WindowStartMove: "windows:WindowStartMove",
|
||
|
|
WindowStartResize: "windows:WindowStartResize",
|
||
|
|
WindowUnFullscreen: "windows:WindowUnFullscreen",
|
||
|
|
WindowZOrderChanged: "windows:WindowZOrderChanged",
|
||
|
|
WindowMinimise: "windows:WindowMinimise",
|
||
|
|
WindowUnMinimise: "windows:WindowUnMinimise",
|
||
|
|
WindowMaximise: "windows:WindowMaximise",
|
||
|
|
WindowUnMaximise: "windows:WindowUnMaximise"
|
||
|
|
}),
|
||
|
|
Mac: Object.freeze({
|
||
|
|
ApplicationDidBecomeActive: "mac:ApplicationDidBecomeActive",
|
||
|
|
ApplicationDidChangeBackingProperties: "mac:ApplicationDidChangeBackingProperties",
|
||
|
|
ApplicationDidChangeEffectiveAppearance: "mac:ApplicationDidChangeEffectiveAppearance",
|
||
|
|
ApplicationDidChangeIcon: "mac:ApplicationDidChangeIcon",
|
||
|
|
ApplicationDidChangeOcclusionState: "mac:ApplicationDidChangeOcclusionState",
|
||
|
|
ApplicationDidChangeScreenParameters: "mac:ApplicationDidChangeScreenParameters",
|
||
|
|
ApplicationDidChangeStatusBarFrame: "mac:ApplicationDidChangeStatusBarFrame",
|
||
|
|
ApplicationDidChangeStatusBarOrientation: "mac:ApplicationDidChangeStatusBarOrientation",
|
||
|
|
ApplicationDidChangeTheme: "mac:ApplicationDidChangeTheme",
|
||
|
|
ApplicationDidFinishLaunching: "mac:ApplicationDidFinishLaunching",
|
||
|
|
ApplicationDidHide: "mac:ApplicationDidHide",
|
||
|
|
ApplicationDidResignActive: "mac:ApplicationDidResignActive",
|
||
|
|
ApplicationDidUnhide: "mac:ApplicationDidUnhide",
|
||
|
|
ApplicationDidUpdate: "mac:ApplicationDidUpdate",
|
||
|
|
ApplicationShouldHandleReopen: "mac:ApplicationShouldHandleReopen",
|
||
|
|
ApplicationWillBecomeActive: "mac:ApplicationWillBecomeActive",
|
||
|
|
ApplicationWillFinishLaunching: "mac:ApplicationWillFinishLaunching",
|
||
|
|
ApplicationWillHide: "mac:ApplicationWillHide",
|
||
|
|
ApplicationWillResignActive: "mac:ApplicationWillResignActive",
|
||
|
|
ApplicationWillTerminate: "mac:ApplicationWillTerminate",
|
||
|
|
ApplicationWillUnhide: "mac:ApplicationWillUnhide",
|
||
|
|
ApplicationWillUpdate: "mac:ApplicationWillUpdate",
|
||
|
|
MenuDidAddItem: "mac:MenuDidAddItem",
|
||
|
|
MenuDidBeginTracking: "mac:MenuDidBeginTracking",
|
||
|
|
MenuDidClose: "mac:MenuDidClose",
|
||
|
|
MenuDidDisplayItem: "mac:MenuDidDisplayItem",
|
||
|
|
MenuDidEndTracking: "mac:MenuDidEndTracking",
|
||
|
|
MenuDidHighlightItem: "mac:MenuDidHighlightItem",
|
||
|
|
MenuDidOpen: "mac:MenuDidOpen",
|
||
|
|
MenuDidPopUp: "mac:MenuDidPopUp",
|
||
|
|
MenuDidRemoveItem: "mac:MenuDidRemoveItem",
|
||
|
|
MenuDidSendAction: "mac:MenuDidSendAction",
|
||
|
|
MenuDidSendActionToItem: "mac:MenuDidSendActionToItem",
|
||
|
|
MenuDidUpdate: "mac:MenuDidUpdate",
|
||
|
|
MenuWillAddItem: "mac:MenuWillAddItem",
|
||
|
|
MenuWillBeginTracking: "mac:MenuWillBeginTracking",
|
||
|
|
MenuWillDisplayItem: "mac:MenuWillDisplayItem",
|
||
|
|
MenuWillEndTracking: "mac:MenuWillEndTracking",
|
||
|
|
MenuWillHighlightItem: "mac:MenuWillHighlightItem",
|
||
|
|
MenuWillOpen: "mac:MenuWillOpen",
|
||
|
|
MenuWillPopUp: "mac:MenuWillPopUp",
|
||
|
|
MenuWillRemoveItem: "mac:MenuWillRemoveItem",
|
||
|
|
MenuWillSendAction: "mac:MenuWillSendAction",
|
||
|
|
MenuWillSendActionToItem: "mac:MenuWillSendActionToItem",
|
||
|
|
MenuWillUpdate: "mac:MenuWillUpdate",
|
||
|
|
WebViewDidCommitNavigation: "mac:WebViewDidCommitNavigation",
|
||
|
|
WebViewDidFinishNavigation: "mac:WebViewDidFinishNavigation",
|
||
|
|
WebViewDidReceiveServerRedirectForProvisionalNavigation: "mac:WebViewDidReceiveServerRedirectForProvisionalNavigation",
|
||
|
|
WebViewDidStartProvisionalNavigation: "mac:WebViewDidStartProvisionalNavigation",
|
||
|
|
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",
|
||
|
|
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",
|
||
|
|
WindowDidZoom: "mac:WindowDidZoom",
|
||
|
|
WindowFileDraggingEntered: "mac:WindowFileDraggingEntered",
|
||
|
|
WindowFileDraggingExited: "mac:WindowFileDraggingExited",
|
||
|
|
WindowFileDraggingPerformed: "mac:WindowFileDraggingPerformed",
|
||
|
|
WindowHide: "mac:WindowHide",
|
||
|
|
WindowMaximise: "mac:WindowMaximise",
|
||
|
|
WindowUnMaximise: "mac:WindowUnMaximise",
|
||
|
|
WindowMinimise: "mac:WindowMinimise",
|
||
|
|
WindowUnMinimise: "mac:WindowUnMinimise",
|
||
|
|
WindowShouldClose: "mac:WindowShouldClose",
|
||
|
|
WindowShow: "mac:WindowShow",
|
||
|
|
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",
|
||
|
|
WindowZoomIn: "mac:WindowZoomIn",
|
||
|
|
WindowZoomOut: "mac:WindowZoomOut",
|
||
|
|
WindowZoomReset: "mac:WindowZoomReset"
|
||
|
|
}),
|
||
|
|
Linux: Object.freeze({
|
||
|
|
ApplicationStartup: "linux:ApplicationStartup",
|
||
|
|
SystemThemeChanged: "linux:SystemThemeChanged",
|
||
|
|
WindowDeleteEvent: "linux:WindowDeleteEvent",
|
||
|
|
WindowDidMove: "linux:WindowDidMove",
|
||
|
|
WindowDidResize: "linux:WindowDidResize",
|
||
|
|
WindowFocusIn: "linux:WindowFocusIn",
|
||
|
|
WindowFocusOut: "linux:WindowFocusOut",
|
||
|
|
WindowLoadChanged: "linux:WindowLoadChanged"
|
||
|
|
}),
|
||
|
|
Common: Object.freeze({
|
||
|
|
ApplicationOpenedWithFile: "common:ApplicationOpenedWithFile",
|
||
|
|
ApplicationStarted: "common:ApplicationStarted",
|
||
|
|
ApplicationLaunchedWithUrl: "common:ApplicationLaunchedWithUrl",
|
||
|
|
ThemeChanged: "common:ThemeChanged",
|
||
|
|
WindowClosing: "common:WindowClosing",
|
||
|
|
WindowDidMove: "common:WindowDidMove",
|
||
|
|
WindowDidResize: "common:WindowDidResize",
|
||
|
|
WindowDPIChanged: "common:WindowDPIChanged",
|
||
|
|
WindowFilesDropped: "common:WindowFilesDropped",
|
||
|
|
WindowFocus: "common:WindowFocus",
|
||
|
|
WindowFullscreen: "common:WindowFullscreen",
|
||
|
|
WindowHide: "common:WindowHide",
|
||
|
|
WindowLostFocus: "common:WindowLostFocus",
|
||
|
|
WindowMaximise: "common:WindowMaximise",
|
||
|
|
WindowMinimise: "common:WindowMinimise",
|
||
|
|
WindowToggleFrameless: "common:WindowToggleFrameless",
|
||
|
|
WindowRestore: "common:WindowRestore",
|
||
|
|
WindowRuntimeReady: "common:WindowRuntimeReady",
|
||
|
|
WindowShow: "common:WindowShow",
|
||
|
|
WindowUnFullscreen: "common:WindowUnFullscreen",
|
||
|
|
WindowUnMaximise: "common:WindowUnMaximise",
|
||
|
|
WindowUnMinimise: "common:WindowUnMinimise",
|
||
|
|
WindowZoom: "common:WindowZoom",
|
||
|
|
WindowZoomIn: "common:WindowZoomIn",
|
||
|
|
WindowZoomOut: "common:WindowZoomOut",
|
||
|
|
WindowZoomReset: "common:WindowZoomReset",
|
||
|
|
WindowDropZoneFilesDropped: "common:WindowDropZoneFilesDropped"
|
||
|
|
})
|
||
|
|
});
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/events.ts
|
||
|
|
window._wails = window._wails || {};
|
||
|
|
window._wails.dispatchWailsEvent = dispatchWailsEvent;
|
||
|
|
var call3 = newRuntimeCaller(objectNames.Events);
|
||
|
|
var EmitMethod = 0;
|
||
|
|
var WailsEvent = class {
|
||
|
|
constructor(name, data = null) {
|
||
|
|
this.name = name;
|
||
|
|
this.data = data;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
function dispatchWailsEvent(event) {
|
||
|
|
let listeners = eventListeners.get(event.name);
|
||
|
|
if (!listeners) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
let wailsEvent = new WailsEvent(event.name, event.data);
|
||
|
|
if ("sender" in event) {
|
||
|
|
wailsEvent.sender = event.sender;
|
||
|
|
}
|
||
|
|
listeners = listeners.filter((listener) => !listener.dispatch(wailsEvent));
|
||
|
|
if (listeners.length === 0) {
|
||
|
|
eventListeners.delete(event.name);
|
||
|
|
} else {
|
||
|
|
eventListeners.set(event.name, listeners);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
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);
|
||
|
|
}
|
||
|
|
function On(eventName, callback) {
|
||
|
|
return OnMultiple(eventName, callback, -1);
|
||
|
|
}
|
||
|
|
function Once(eventName, callback) {
|
||
|
|
return OnMultiple(eventName, callback, 1);
|
||
|
|
}
|
||
|
|
function Off(...eventNames) {
|
||
|
|
eventNames.forEach((eventName) => eventListeners.delete(eventName));
|
||
|
|
}
|
||
|
|
function OffAll() {
|
||
|
|
eventListeners.clear();
|
||
|
|
}
|
||
|
|
function Emit(name, data) {
|
||
|
|
let eventName;
|
||
|
|
let eventData;
|
||
|
|
if (typeof name === "object" && name !== null && "name" in name && "data" in name) {
|
||
|
|
eventName = name["name"];
|
||
|
|
eventData = name["data"];
|
||
|
|
} else {
|
||
|
|
eventName = name;
|
||
|
|
eventData = data;
|
||
|
|
}
|
||
|
|
return call3(EmitMethod, { name: eventName, data: eventData });
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/utils.ts
|
||
|
|
function debugLog(message) {
|
||
|
|
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"
|
||
|
|
);
|
||
|
|
}
|
||
|
|
function canTrackButtons() {
|
||
|
|
return new MouseEvent("mousedown").buttons === 0;
|
||
|
|
}
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
function eventTarget(event) {
|
||
|
|
var _a2;
|
||
|
|
if (event.target instanceof HTMLElement) {
|
||
|
|
return event.target;
|
||
|
|
} else if (!(event.target instanceof HTMLElement) && event.target instanceof Node) {
|
||
|
|
return (_a2 = event.target.parentElement) != null ? _a2 : document.body;
|
||
|
|
} else {
|
||
|
|
return document.body;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
var isReady = false;
|
||
|
|
document.addEventListener("DOMContentLoaded", () => {
|
||
|
|
isReady = true;
|
||
|
|
});
|
||
|
|
function whenReady(callback) {
|
||
|
|
if (isReady || document.readyState === "complete") {
|
||
|
|
callback();
|
||
|
|
} else {
|
||
|
|
document.addEventListener("DOMContentLoaded", callback);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/window.ts
|
||
|
|
var DROPZONE_ATTRIBUTE = "data-wails-dropzone";
|
||
|
|
var DROPZONE_HOVER_CLASS = "wails-dropzone-hover";
|
||
|
|
var currentHoveredDropzone = null;
|
||
|
|
var PositionMethod = 0;
|
||
|
|
var CenterMethod = 1;
|
||
|
|
var CloseMethod = 2;
|
||
|
|
var DisableSizeConstraintsMethod = 3;
|
||
|
|
var EnableSizeConstraintsMethod = 4;
|
||
|
|
var FocusMethod = 5;
|
||
|
|
var ForceReloadMethod = 6;
|
||
|
|
var FullscreenMethod = 7;
|
||
|
|
var GetScreenMethod = 8;
|
||
|
|
var GetZoomMethod = 9;
|
||
|
|
var HeightMethod = 10;
|
||
|
|
var HideMethod = 11;
|
||
|
|
var IsFocusedMethod = 12;
|
||
|
|
var IsFullscreenMethod = 13;
|
||
|
|
var IsMaximisedMethod = 14;
|
||
|
|
var IsMinimisedMethod = 15;
|
||
|
|
var MaximiseMethod = 16;
|
||
|
|
var MinimiseMethod = 17;
|
||
|
|
var NameMethod = 18;
|
||
|
|
var OpenDevToolsMethod = 19;
|
||
|
|
var RelativePositionMethod = 20;
|
||
|
|
var ReloadMethod = 21;
|
||
|
|
var ResizableMethod = 22;
|
||
|
|
var RestoreMethod = 23;
|
||
|
|
var SetPositionMethod = 24;
|
||
|
|
var SetAlwaysOnTopMethod = 25;
|
||
|
|
var SetBackgroundColourMethod = 26;
|
||
|
|
var SetFramelessMethod = 27;
|
||
|
|
var SetFullscreenButtonEnabledMethod = 28;
|
||
|
|
var SetMaxSizeMethod = 29;
|
||
|
|
var SetMinSizeMethod = 30;
|
||
|
|
var SetRelativePositionMethod = 31;
|
||
|
|
var SetResizableMethod = 32;
|
||
|
|
var SetSizeMethod = 33;
|
||
|
|
var SetTitleMethod = 34;
|
||
|
|
var SetZoomMethod = 35;
|
||
|
|
var ShowMethod = 36;
|
||
|
|
var SizeMethod = 37;
|
||
|
|
var ToggleFullscreenMethod = 38;
|
||
|
|
var ToggleMaximiseMethod = 39;
|
||
|
|
var ToggleFramelessMethod = 40;
|
||
|
|
var UnFullscreenMethod = 41;
|
||
|
|
var UnMaximiseMethod = 42;
|
||
|
|
var UnMinimiseMethod = 43;
|
||
|
|
var WidthMethod = 44;
|
||
|
|
var ZoomMethod = 45;
|
||
|
|
var ZoomInMethod = 46;
|
||
|
|
var ZoomOutMethod = 47;
|
||
|
|
var ZoomResetMethod = 48;
|
||
|
|
var SnapAssistMethod = 49;
|
||
|
|
var WindowDropZoneDropped = 50;
|
||
|
|
function getDropzoneElement(element) {
|
||
|
|
if (!element) {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return element.closest("[".concat(DROPZONE_ATTRIBUTE, "]"));
|
||
|
|
}
|
||
|
|
var callerSym = Symbol("caller");
|
||
|
|
callerSym;
|
||
|
|
var _Window = class _Window {
|
||
|
|
/**
|
||
|
|
* Initialises a window object with the specified name.
|
||
|
|
*
|
||
|
|
* @private
|
||
|
|
* @param name - The name of the target window.
|
||
|
|
*/
|
||
|
|
constructor(name = "") {
|
||
|
|
this[callerSym] = newRuntimeCaller(objectNames.Window, name);
|
||
|
|
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.
|
||
|
|
*
|
||
|
|
* @param name - The name of the window to get.
|
||
|
|
* @returns The corresponding window object.
|
||
|
|
*/
|
||
|
|
Get(name) {
|
||
|
|
return new _Window(name);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns the absolute position of the window.
|
||
|
|
*
|
||
|
|
* @returns The current absolute position of the window.
|
||
|
|
*/
|
||
|
|
Position() {
|
||
|
|
return this[callerSym](PositionMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Centers the window on the screen.
|
||
|
|
*/
|
||
|
|
Center() {
|
||
|
|
return this[callerSym](CenterMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Closes the window.
|
||
|
|
*/
|
||
|
|
Close() {
|
||
|
|
return this[callerSym](CloseMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Disables min/max size constraints.
|
||
|
|
*/
|
||
|
|
DisableSizeConstraints() {
|
||
|
|
return this[callerSym](DisableSizeConstraintsMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Enables min/max size constraints.
|
||
|
|
*/
|
||
|
|
EnableSizeConstraints() {
|
||
|
|
return this[callerSym](EnableSizeConstraintsMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Focuses the window.
|
||
|
|
*/
|
||
|
|
Focus() {
|
||
|
|
return this[callerSym](FocusMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Forces the window to reload the page assets.
|
||
|
|
*/
|
||
|
|
ForceReload() {
|
||
|
|
return this[callerSym](ForceReloadMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Switches the window to fullscreen mode.
|
||
|
|
*/
|
||
|
|
Fullscreen() {
|
||
|
|
return this[callerSym](FullscreenMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns the screen that the window is on.
|
||
|
|
*
|
||
|
|
* @returns The screen the window is currently on.
|
||
|
|
*/
|
||
|
|
GetScreen() {
|
||
|
|
return this[callerSym](GetScreenMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns the current zoom level of the window.
|
||
|
|
*
|
||
|
|
* @returns The current zoom level.
|
||
|
|
*/
|
||
|
|
GetZoom() {
|
||
|
|
return this[callerSym](GetZoomMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns the height of the window.
|
||
|
|
*
|
||
|
|
* @returns The current height of the window.
|
||
|
|
*/
|
||
|
|
Height() {
|
||
|
|
return this[callerSym](HeightMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Hides the window.
|
||
|
|
*/
|
||
|
|
Hide() {
|
||
|
|
return this[callerSym](HideMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns true if the window is focused.
|
||
|
|
*
|
||
|
|
* @returns Whether the window is currently focused.
|
||
|
|
*/
|
||
|
|
IsFocused() {
|
||
|
|
return this[callerSym](IsFocusedMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns true if the window is fullscreen.
|
||
|
|
*
|
||
|
|
* @returns Whether the window is currently fullscreen.
|
||
|
|
*/
|
||
|
|
IsFullscreen() {
|
||
|
|
return this[callerSym](IsFullscreenMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns true if the window is maximised.
|
||
|
|
*
|
||
|
|
* @returns Whether the window is currently maximised.
|
||
|
|
*/
|
||
|
|
IsMaximised() {
|
||
|
|
return this[callerSym](IsMaximisedMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns true if the window is minimised.
|
||
|
|
*
|
||
|
|
* @returns Whether the window is currently minimised.
|
||
|
|
*/
|
||
|
|
IsMinimised() {
|
||
|
|
return this[callerSym](IsMinimisedMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Maximises the window.
|
||
|
|
*/
|
||
|
|
Maximise() {
|
||
|
|
return this[callerSym](MaximiseMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Minimises the window.
|
||
|
|
*/
|
||
|
|
Minimise() {
|
||
|
|
return this[callerSym](MinimiseMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns the name of the window.
|
||
|
|
*
|
||
|
|
* @returns The name of the window.
|
||
|
|
*/
|
||
|
|
Name() {
|
||
|
|
return this[callerSym](NameMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Opens the development tools pane.
|
||
|
|
*/
|
||
|
|
OpenDevTools() {
|
||
|
|
return this[callerSym](OpenDevToolsMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns the relative position of the window to the screen.
|
||
|
|
*
|
||
|
|
* @returns The current relative position of the window.
|
||
|
|
*/
|
||
|
|
RelativePosition() {
|
||
|
|
return this[callerSym](RelativePositionMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Reloads the page assets.
|
||
|
|
*/
|
||
|
|
Reload() {
|
||
|
|
return this[callerSym](ReloadMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns true if the window is resizable.
|
||
|
|
*
|
||
|
|
* @returns Whether the window is currently resizable.
|
||
|
|
*/
|
||
|
|
Resizable() {
|
||
|
|
return this[callerSym](ResizableMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Restores the window to its previous state if it was previously minimised, maximised or fullscreen.
|
||
|
|
*/
|
||
|
|
Restore() {
|
||
|
|
return this[callerSym](RestoreMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Sets the absolute position of the window.
|
||
|
|
*
|
||
|
|
* @param x - The desired horizontal absolute position of the window.
|
||
|
|
* @param y - The desired vertical absolute position of the window.
|
||
|
|
*/
|
||
|
|
SetPosition(x, y) {
|
||
|
|
return this[callerSym](SetPositionMethod, { x, y });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Sets the window to be always on top.
|
||
|
|
*
|
||
|
|
* @param alwaysOnTop - Whether the window should stay on top.
|
||
|
|
*/
|
||
|
|
SetAlwaysOnTop(alwaysOnTop) {
|
||
|
|
return this[callerSym](SetAlwaysOnTopMethod, { alwaysOnTop });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Sets the background colour of the window.
|
||
|
|
*
|
||
|
|
* @param r - The desired red component of the window background.
|
||
|
|
* @param g - The desired green component of the window background.
|
||
|
|
* @param b - The desired blue component of the window background.
|
||
|
|
* @param a - The desired alpha component of the window background.
|
||
|
|
*/
|
||
|
|
SetBackgroundColour(r, g, b, a) {
|
||
|
|
return this[callerSym](SetBackgroundColourMethod, { r, g, b, a });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Removes the window frame and title bar.
|
||
|
|
*
|
||
|
|
* @param frameless - Whether the window should be frameless.
|
||
|
|
*/
|
||
|
|
SetFrameless(frameless) {
|
||
|
|
return this[callerSym](SetFramelessMethod, { frameless });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Disables the system fullscreen button.
|
||
|
|
*
|
||
|
|
* @param enabled - Whether the fullscreen button should be enabled.
|
||
|
|
*/
|
||
|
|
SetFullscreenButtonEnabled(enabled) {
|
||
|
|
return this[callerSym](SetFullscreenButtonEnabledMethod, { enabled });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Sets the maximum size of the window.
|
||
|
|
*
|
||
|
|
* @param width - The desired maximum width of the window.
|
||
|
|
* @param height - The desired maximum height of the window.
|
||
|
|
*/
|
||
|
|
SetMaxSize(width, height) {
|
||
|
|
return this[callerSym](SetMaxSizeMethod, { width, height });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Sets the minimum size of the window.
|
||
|
|
*
|
||
|
|
* @param width - The desired minimum width of the window.
|
||
|
|
* @param height - The desired minimum height of the window.
|
||
|
|
*/
|
||
|
|
SetMinSize(width, height) {
|
||
|
|
return this[callerSym](SetMinSizeMethod, { width, height });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Sets the relative position of the window to the screen.
|
||
|
|
*
|
||
|
|
* @param x - The desired horizontal relative position of the window.
|
||
|
|
* @param y - The desired vertical relative position of the window.
|
||
|
|
*/
|
||
|
|
SetRelativePosition(x, y) {
|
||
|
|
return this[callerSym](SetRelativePositionMethod, { x, y });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Sets whether the window is resizable.
|
||
|
|
*
|
||
|
|
* @param resizable - Whether the window should be resizable.
|
||
|
|
*/
|
||
|
|
SetResizable(resizable2) {
|
||
|
|
return this[callerSym](SetResizableMethod, { resizable: resizable2 });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Sets the size of the window.
|
||
|
|
*
|
||
|
|
* @param width - The desired width of the window.
|
||
|
|
* @param height - The desired height of the window.
|
||
|
|
*/
|
||
|
|
SetSize(width, height) {
|
||
|
|
return this[callerSym](SetSizeMethod, { width, height });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Sets the title of the window.
|
||
|
|
*
|
||
|
|
* @param title - The desired title of the window.
|
||
|
|
*/
|
||
|
|
SetTitle(title) {
|
||
|
|
return this[callerSym](SetTitleMethod, { title });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Sets the zoom level of the window.
|
||
|
|
*
|
||
|
|
* @param zoom - The desired zoom level.
|
||
|
|
*/
|
||
|
|
SetZoom(zoom) {
|
||
|
|
return this[callerSym](SetZoomMethod, { zoom });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Shows the window.
|
||
|
|
*/
|
||
|
|
Show() {
|
||
|
|
return this[callerSym](ShowMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns the size of the window.
|
||
|
|
*
|
||
|
|
* @returns The current size of the window.
|
||
|
|
*/
|
||
|
|
Size() {
|
||
|
|
return this[callerSym](SizeMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Toggles the window between fullscreen and normal.
|
||
|
|
*/
|
||
|
|
ToggleFullscreen() {
|
||
|
|
return this[callerSym](ToggleFullscreenMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Toggles the window between maximised and normal.
|
||
|
|
*/
|
||
|
|
ToggleMaximise() {
|
||
|
|
return this[callerSym](ToggleMaximiseMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Toggles the window between frameless and normal.
|
||
|
|
*/
|
||
|
|
ToggleFrameless() {
|
||
|
|
return this[callerSym](ToggleFramelessMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Un-fullscreens the window.
|
||
|
|
*/
|
||
|
|
UnFullscreen() {
|
||
|
|
return this[callerSym](UnFullscreenMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Un-maximises the window.
|
||
|
|
*/
|
||
|
|
UnMaximise() {
|
||
|
|
return this[callerSym](UnMaximiseMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Un-minimises the window.
|
||
|
|
*/
|
||
|
|
UnMinimise() {
|
||
|
|
return this[callerSym](UnMinimiseMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns the width of the window.
|
||
|
|
*
|
||
|
|
* @returns The current width of the window.
|
||
|
|
*/
|
||
|
|
Width() {
|
||
|
|
return this[callerSym](WidthMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Zooms the window.
|
||
|
|
*/
|
||
|
|
Zoom() {
|
||
|
|
return this[callerSym](ZoomMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Increases the zoom level of the webview content.
|
||
|
|
*/
|
||
|
|
ZoomIn() {
|
||
|
|
return this[callerSym](ZoomInMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Decreases the zoom level of the webview content.
|
||
|
|
*/
|
||
|
|
ZoomOut() {
|
||
|
|
return this[callerSym](ZoomOutMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Resets the zoom level of the webview content.
|
||
|
|
*/
|
||
|
|
ZoomReset() {
|
||
|
|
return this[callerSym](ZoomResetMethod);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Handles file drops originating from platform-specific code (e.g., macOS native drag-and-drop).
|
||
|
|
* Gathers information about the drop target element and sends it back to the Go backend.
|
||
|
|
*
|
||
|
|
* @param filenames - An array of file paths (strings) that were dropped.
|
||
|
|
* @param x - The x-coordinate of the drop event.
|
||
|
|
* @param y - The y-coordinate of the drop event.
|
||
|
|
*/
|
||
|
|
HandlePlatformFileDrop(filenames, x, y) {
|
||
|
|
const element = document.elementFromPoint(x, y);
|
||
|
|
const dropzoneTarget = getDropzoneElement(element);
|
||
|
|
if (!dropzoneTarget) {
|
||
|
|
console.log("Wails Runtime: Drop on element (or no element) at ".concat(x, ",").concat(y, " which is not a designated dropzone. Ignoring. Element:"), element);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
console.log("Wails Runtime: Drop on designated dropzone. Element at (".concat(x, ", ").concat(y, "):"), element, "Effective dropzone:", dropzoneTarget);
|
||
|
|
const elementDetails = {
|
||
|
|
id: dropzoneTarget.id,
|
||
|
|
classList: Array.from(dropzoneTarget.classList),
|
||
|
|
attributes: {}
|
||
|
|
};
|
||
|
|
for (let i = 0; i < dropzoneTarget.attributes.length; i++) {
|
||
|
|
const attr = dropzoneTarget.attributes[i];
|
||
|
|
elementDetails.attributes[attr.name] = attr.value;
|
||
|
|
}
|
||
|
|
const payload = {
|
||
|
|
filenames,
|
||
|
|
x,
|
||
|
|
y,
|
||
|
|
elementDetails
|
||
|
|
};
|
||
|
|
this[callerSym](WindowDropZoneDropped, payload);
|
||
|
|
}
|
||
|
|
/* Triggers Windows 11 Snap Assist feature (Windows only).
|
||
|
|
* This is equivalent to pressing Win+Z and shows snap layout options.
|
||
|
|
*/
|
||
|
|
SnapAssist() {
|
||
|
|
return this[callerSym](SnapAssistMethod);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
var Window = _Window;
|
||
|
|
var thisWindow = new Window("");
|
||
|
|
function setupGlobalDropzoneListeners() {
|
||
|
|
const docElement = document.documentElement;
|
||
|
|
let dragEnterCounter = 0;
|
||
|
|
docElement.addEventListener("dragenter", (event) => {
|
||
|
|
event.preventDefault();
|
||
|
|
if (event.dataTransfer && event.dataTransfer.types.includes("Files")) {
|
||
|
|
dragEnterCounter++;
|
||
|
|
const targetElement = document.elementFromPoint(event.clientX, event.clientY);
|
||
|
|
const dropzone = getDropzoneElement(targetElement);
|
||
|
|
if (currentHoveredDropzone && currentHoveredDropzone !== dropzone) {
|
||
|
|
currentHoveredDropzone.classList.remove(DROPZONE_HOVER_CLASS);
|
||
|
|
}
|
||
|
|
if (dropzone) {
|
||
|
|
dropzone.classList.add(DROPZONE_HOVER_CLASS);
|
||
|
|
event.dataTransfer.dropEffect = "copy";
|
||
|
|
currentHoveredDropzone = dropzone;
|
||
|
|
} else {
|
||
|
|
event.dataTransfer.dropEffect = "none";
|
||
|
|
currentHoveredDropzone = null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, false);
|
||
|
|
docElement.addEventListener("dragover", (event) => {
|
||
|
|
event.preventDefault();
|
||
|
|
if (event.dataTransfer && event.dataTransfer.types.includes("Files")) {
|
||
|
|
if (currentHoveredDropzone) {
|
||
|
|
if (!currentHoveredDropzone.classList.contains(DROPZONE_HOVER_CLASS)) {
|
||
|
|
currentHoveredDropzone.classList.add(DROPZONE_HOVER_CLASS);
|
||
|
|
}
|
||
|
|
event.dataTransfer.dropEffect = "copy";
|
||
|
|
} else {
|
||
|
|
event.dataTransfer.dropEffect = "none";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, false);
|
||
|
|
docElement.addEventListener("dragleave", (event) => {
|
||
|
|
event.preventDefault();
|
||
|
|
if (event.dataTransfer && event.dataTransfer.types.includes("Files")) {
|
||
|
|
dragEnterCounter--;
|
||
|
|
if (dragEnterCounter === 0 || event.relatedTarget === null || currentHoveredDropzone && !currentHoveredDropzone.contains(event.relatedTarget)) {
|
||
|
|
if (currentHoveredDropzone) {
|
||
|
|
currentHoveredDropzone.classList.remove(DROPZONE_HOVER_CLASS);
|
||
|
|
currentHoveredDropzone = null;
|
||
|
|
}
|
||
|
|
dragEnterCounter = 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, false);
|
||
|
|
docElement.addEventListener("drop", (event) => {
|
||
|
|
event.preventDefault();
|
||
|
|
dragEnterCounter = 0;
|
||
|
|
if (currentHoveredDropzone) {
|
||
|
|
currentHoveredDropzone.classList.remove(DROPZONE_HOVER_CLASS);
|
||
|
|
currentHoveredDropzone = null;
|
||
|
|
}
|
||
|
|
}, false);
|
||
|
|
}
|
||
|
|
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
||
|
|
setupGlobalDropzoneListeners();
|
||
|
|
}
|
||
|
|
var window_default = thisWindow;
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/wml.ts
|
||
|
|
function sendEvent(eventName, data = null) {
|
||
|
|
Emit(eventName, data);
|
||
|
|
}
|
||
|
|
function callWindowMethod(windowName, methodName) {
|
||
|
|
const targetWindow = window_default.Get(windowName);
|
||
|
|
const method = targetWindow[methodName];
|
||
|
|
if (typeof method !== "function") {
|
||
|
|
console.error("Window method '".concat(methodName, "' not found"));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
method.call(targetWindow);
|
||
|
|
} catch (e) {
|
||
|
|
console.error("Error calling window method '".concat(methodName, "': "), e);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function onWMLTriggered(ev) {
|
||
|
|
const element = ev.currentTarget;
|
||
|
|
function runEffect(choice = "Yes") {
|
||
|
|
if (choice !== "Yes")
|
||
|
|
return;
|
||
|
|
const eventType = element.getAttribute("wml-event") || element.getAttribute("data-wml-event");
|
||
|
|
const targetWindow = element.getAttribute("wml-target-window") || element.getAttribute("data-wml-target-window") || "";
|
||
|
|
const windowMethod = element.getAttribute("wml-window") || element.getAttribute("data-wml-window");
|
||
|
|
const url = element.getAttribute("wml-openurl") || element.getAttribute("data-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") || element.getAttribute("data-wml-confirm");
|
||
|
|
if (confirm) {
|
||
|
|
Question({
|
||
|
|
Title: "Confirm",
|
||
|
|
Message: confirm,
|
||
|
|
Detached: false,
|
||
|
|
Buttons: [
|
||
|
|
{ Label: "Yes" },
|
||
|
|
{ Label: "No", IsDefault: true }
|
||
|
|
]
|
||
|
|
}).then(runEffect);
|
||
|
|
} else {
|
||
|
|
runEffect();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
var controllerSym = Symbol("controller");
|
||
|
|
var triggerMapSym = Symbol("triggerMap");
|
||
|
|
var elementCountSym = Symbol("elementCount");
|
||
|
|
controllerSym;
|
||
|
|
var AbortControllerRegistry = class {
|
||
|
|
constructor() {
|
||
|
|
this[controllerSym] = new AbortController();
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns an options object for addEventListener that ties the listener
|
||
|
|
* to the AbortSignal from the current AbortController.
|
||
|
|
*
|
||
|
|
* @param element - An HTML element
|
||
|
|
* @param triggers - The list of active WML trigger events for the specified elements
|
||
|
|
*/
|
||
|
|
set(element, triggers) {
|
||
|
|
return { signal: this[controllerSym].signal };
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Removes all registered event listeners and resets the registry.
|
||
|
|
*/
|
||
|
|
reset() {
|
||
|
|
this[controllerSym].abort();
|
||
|
|
this[controllerSym] = new AbortController();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
triggerMapSym, elementCountSym;
|
||
|
|
var WeakMapRegistry = class {
|
||
|
|
constructor() {
|
||
|
|
this[triggerMapSym] = /* @__PURE__ */ new WeakMap();
|
||
|
|
this[elementCountSym] = 0;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Sets active triggers for the specified element.
|
||
|
|
*
|
||
|
|
* @param element - An HTML element
|
||
|
|
* @param triggers - The list of active WML trigger events for the specified element
|
||
|
|
*/
|
||
|
|
set(element, triggers) {
|
||
|
|
if (!this[triggerMapSym].has(element)) {
|
||
|
|
this[elementCountSym]++;
|
||
|
|
}
|
||
|
|
this[triggerMapSym].set(element, triggers);
|
||
|
|
return {};
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Removes all registered event listeners.
|
||
|
|
*/
|
||
|
|
reset() {
|
||
|
|
if (this[elementCountSym] <= 0)
|
||
|
|
return;
|
||
|
|
for (const element of document.body.querySelectorAll("*")) {
|
||
|
|
if (this[elementCountSym] <= 0)
|
||
|
|
break;
|
||
|
|
const triggers = this[triggerMapSym].get(element);
|
||
|
|
if (triggers != null) {
|
||
|
|
this[elementCountSym]--;
|
||
|
|
}
|
||
|
|
for (const trigger of triggers || [])
|
||
|
|
element.removeEventListener(trigger, onWMLTriggered);
|
||
|
|
}
|
||
|
|
this[triggerMapSym] = /* @__PURE__ */ new WeakMap();
|
||
|
|
this[elementCountSym] = 0;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
var triggerRegistry = canAbortListeners() ? new AbortControllerRegistry() : new WeakMapRegistry();
|
||
|
|
function addWMLListeners(element) {
|
||
|
|
const triggerRegExp = /\S+/g;
|
||
|
|
const triggerAttr = element.getAttribute("wml-trigger") || element.getAttribute("data-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);
|
||
|
|
}
|
||
|
|
function Enable() {
|
||
|
|
whenReady(Reload);
|
||
|
|
}
|
||
|
|
function Reload() {
|
||
|
|
triggerRegistry.reset();
|
||
|
|
document.body.querySelectorAll("[wml-event], [wml-window], [wml-openurl], [data-wml-event], [data-wml-window], [data-wml-openurl]").forEach(addWMLListeners);
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/compiled/main.js
|
||
|
|
window.wails = index_exports;
|
||
|
|
Enable();
|
||
|
|
if (true) {
|
||
|
|
debugLog("Wails Runtime Loaded");
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/system.ts
|
||
|
|
var system_exports = {};
|
||
|
|
__export(system_exports, {
|
||
|
|
Capabilities: () => Capabilities,
|
||
|
|
Environment: () => Environment,
|
||
|
|
HandlePlatformFileDrop: () => HandlePlatformFileDrop,
|
||
|
|
IsAMD64: () => IsAMD64,
|
||
|
|
IsARM: () => IsARM,
|
||
|
|
IsARM64: () => IsARM64,
|
||
|
|
IsDarkMode: () => IsDarkMode,
|
||
|
|
IsDebug: () => IsDebug,
|
||
|
|
IsLinux: () => IsLinux,
|
||
|
|
IsMac: () => IsMac,
|
||
|
|
IsWindows: () => IsWindows,
|
||
|
|
invoke: () => invoke
|
||
|
|
});
|
||
|
|
var call4 = newRuntimeCaller(objectNames.System);
|
||
|
|
var SystemIsDarkMode = 0;
|
||
|
|
var SystemEnvironment = 1;
|
||
|
|
var ApplicationFilesDroppedWithContext = 100;
|
||
|
|
var _invoke = (function() {
|
||
|
|
var _a2, _b, _c, _d, _e;
|
||
|
|
try {
|
||
|
|
if ((_b = (_a2 = window.chrome) == null ? void 0 : _a2.webview) == null ? void 0 : _b.postMessage) {
|
||
|
|
return window.chrome.webview.postMessage.bind(window.chrome.webview);
|
||
|
|
} else if ((_e = (_d = (_c = window.webkit) == null ? void 0 : _c.messageHandlers) == null ? void 0 : _d["external"]) == null ? void 0 : _e.postMessage) {
|
||
|
|
return window.webkit.messageHandlers["external"].postMessage.bind(window.webkit.messageHandlers["external"]);
|
||
|
|
}
|
||
|
|
} catch (e) {
|
||
|
|
}
|
||
|
|
console.warn(
|
||
|
|
"\n%c\u26A0\uFE0F 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://v3.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;
|
||
|
|
})();
|
||
|
|
function invoke(msg) {
|
||
|
|
_invoke == null ? void 0 : _invoke(msg);
|
||
|
|
}
|
||
|
|
function IsDarkMode() {
|
||
|
|
return call4(SystemIsDarkMode);
|
||
|
|
}
|
||
|
|
async function Capabilities() {
|
||
|
|
let response = await fetch("/wails/capabilities");
|
||
|
|
if (response.ok) {
|
||
|
|
return response.json();
|
||
|
|
} else {
|
||
|
|
throw new Error("could not fetch capabilities: " + response.statusText);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function Environment() {
|
||
|
|
return call4(SystemEnvironment);
|
||
|
|
}
|
||
|
|
function IsWindows() {
|
||
|
|
return window._wails.environment.OS === "windows";
|
||
|
|
}
|
||
|
|
function IsLinux() {
|
||
|
|
return window._wails.environment.OS === "linux";
|
||
|
|
}
|
||
|
|
function IsMac() {
|
||
|
|
return window._wails.environment.OS === "darwin";
|
||
|
|
}
|
||
|
|
function IsAMD64() {
|
||
|
|
return window._wails.environment.Arch === "amd64";
|
||
|
|
}
|
||
|
|
function IsARM() {
|
||
|
|
return window._wails.environment.Arch === "arm";
|
||
|
|
}
|
||
|
|
function IsARM64() {
|
||
|
|
return window._wails.environment.Arch === "arm64";
|
||
|
|
}
|
||
|
|
function IsDebug() {
|
||
|
|
return Boolean(window._wails.environment.Debug);
|
||
|
|
}
|
||
|
|
function HandlePlatformFileDrop(filenames, x, y) {
|
||
|
|
const element = document.elementFromPoint(x, y);
|
||
|
|
const elementId = element ? element.id : "";
|
||
|
|
const classList = element ? Array.from(element.classList) : [];
|
||
|
|
const payload = {
|
||
|
|
filenames,
|
||
|
|
x,
|
||
|
|
y,
|
||
|
|
elementId,
|
||
|
|
classList
|
||
|
|
};
|
||
|
|
call4(ApplicationFilesDroppedWithContext, payload).then(() => {
|
||
|
|
console.log("Platform file drop processed and sent to Go.");
|
||
|
|
}).catch((err) => {
|
||
|
|
console.error("Error sending platform file drop to Go:", err);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/contextmenu.ts
|
||
|
|
window.addEventListener("contextmenu", contextMenuHandler);
|
||
|
|
var call5 = newRuntimeCaller(objectNames.ContextMenu);
|
||
|
|
var ContextMenuOpen = 0;
|
||
|
|
function openContextMenu(id, x, y, data) {
|
||
|
|
void call5(ContextMenuOpen, { id, x, y, data });
|
||
|
|
}
|
||
|
|
function contextMenuHandler(event) {
|
||
|
|
const target = eventTarget(event);
|
||
|
|
const customContextMenu = window.getComputedStyle(target).getPropertyValue("--custom-contextmenu").trim();
|
||
|
|
if (customContextMenu) {
|
||
|
|
event.preventDefault();
|
||
|
|
const data = window.getComputedStyle(target).getPropertyValue("--custom-contextmenu-data");
|
||
|
|
openContextMenu(customContextMenu, event.clientX, event.clientY, data);
|
||
|
|
} else {
|
||
|
|
processDefaultContextMenu(event, target);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function processDefaultContextMenu(event, target) {
|
||
|
|
if (IsDebug()) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
switch (window.getComputedStyle(target).getPropertyValue("--default-contextmenu").trim()) {
|
||
|
|
case "show":
|
||
|
|
return;
|
||
|
|
case "hide":
|
||
|
|
event.preventDefault();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (target.isContentEditable) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
const selection = window.getSelection();
|
||
|
|
const hasSelection = selection && 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) === target) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) {
|
||
|
|
if (hasSelection || !target.readOnly && !target.disabled) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
event.preventDefault();
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/flags.ts
|
||
|
|
var flags_exports = {};
|
||
|
|
__export(flags_exports, {
|
||
|
|
GetFlag: () => GetFlag
|
||
|
|
});
|
||
|
|
function GetFlag(key) {
|
||
|
|
try {
|
||
|
|
return window._wails.flags[key];
|
||
|
|
} catch (e) {
|
||
|
|
throw new Error("Unable to retrieve flag '" + key + "': " + e, { cause: e });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/drag.ts
|
||
|
|
var canDrag = false;
|
||
|
|
var dragging = false;
|
||
|
|
var resizable = false;
|
||
|
|
var canResize = false;
|
||
|
|
var resizing = false;
|
||
|
|
var resizeEdge = "";
|
||
|
|
var defaultCursor = "auto";
|
||
|
|
var buttons = 0;
|
||
|
|
var buttonsTracked = canTrackButtons();
|
||
|
|
window._wails = window._wails || {};
|
||
|
|
window._wails.setResizable = (value) => {
|
||
|
|
resizable = value;
|
||
|
|
if (!resizable) {
|
||
|
|
canResize = resizing = false;
|
||
|
|
setResize();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
window.addEventListener("mousedown", update, { capture: true });
|
||
|
|
window.addEventListener("mousemove", update, { capture: true });
|
||
|
|
window.addEventListener("mouseup", update, { capture: true });
|
||
|
|
for (const ev of ["click", "contextmenu", "dblclick"]) {
|
||
|
|
window.addEventListener(ev, suppressEvent, { capture: true });
|
||
|
|
}
|
||
|
|
function suppressEvent(event) {
|
||
|
|
if (dragging || resizing) {
|
||
|
|
event.stopImmediatePropagation();
|
||
|
|
event.stopPropagation();
|
||
|
|
event.preventDefault();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
var MouseDown = 0;
|
||
|
|
var MouseUp = 1;
|
||
|
|
var MouseMove = 2;
|
||
|
|
function update(event) {
|
||
|
|
let eventType, eventButtons = event.buttons;
|
||
|
|
switch (event.type) {
|
||
|
|
case "mousedown":
|
||
|
|
eventType = MouseDown;
|
||
|
|
if (!buttonsTracked) {
|
||
|
|
eventButtons = buttons | 1 << event.button;
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case "mouseup":
|
||
|
|
eventType = MouseUp;
|
||
|
|
if (!buttonsTracked) {
|
||
|
|
eventButtons = buttons & ~(1 << event.button);
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
eventType = MouseMove;
|
||
|
|
if (!buttonsTracked) {
|
||
|
|
eventButtons = buttons;
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
let released = buttons & ~eventButtons;
|
||
|
|
let pressed = eventButtons & ~buttons;
|
||
|
|
buttons = eventButtons;
|
||
|
|
if (eventType === MouseDown && !(pressed & event.button)) {
|
||
|
|
released |= 1 << event.button;
|
||
|
|
pressed |= 1 << event.button;
|
||
|
|
}
|
||
|
|
if (eventType !== MouseMove && resizing || dragging && (eventType === MouseDown || event.button !== 0)) {
|
||
|
|
event.stopImmediatePropagation();
|
||
|
|
event.stopPropagation();
|
||
|
|
event.preventDefault();
|
||
|
|
}
|
||
|
|
if (released & 1) {
|
||
|
|
primaryUp(event);
|
||
|
|
}
|
||
|
|
if (pressed & 1) {
|
||
|
|
primaryDown(event);
|
||
|
|
}
|
||
|
|
if (eventType === MouseMove) {
|
||
|
|
onMouseMove(event);
|
||
|
|
}
|
||
|
|
;
|
||
|
|
}
|
||
|
|
function primaryDown(event) {
|
||
|
|
canDrag = false;
|
||
|
|
canResize = false;
|
||
|
|
if (!IsWindows()) {
|
||
|
|
if (event.type === "mousedown" && event.button === 0 && event.detail !== 1) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (resizeEdge) {
|
||
|
|
canResize = true;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
const target = eventTarget(event);
|
||
|
|
const style = window.getComputedStyle(target);
|
||
|
|
canDrag = style.getPropertyValue("--wails-draggable").trim() === "drag" && (event.offsetX - parseFloat(style.paddingLeft) < target.clientWidth && event.offsetY - parseFloat(style.paddingTop) < target.clientHeight);
|
||
|
|
}
|
||
|
|
function primaryUp(event) {
|
||
|
|
canDrag = false;
|
||
|
|
dragging = false;
|
||
|
|
canResize = false;
|
||
|
|
resizing = false;
|
||
|
|
}
|
||
|
|
var cursorForEdge = Object.freeze({
|
||
|
|
"se-resize": "nwse-resize",
|
||
|
|
"sw-resize": "nesw-resize",
|
||
|
|
"nw-resize": "nwse-resize",
|
||
|
|
"ne-resize": "nesw-resize",
|
||
|
|
"w-resize": "ew-resize",
|
||
|
|
"n-resize": "ns-resize",
|
||
|
|
"s-resize": "ns-resize",
|
||
|
|
"e-resize": "ew-resize"
|
||
|
|
});
|
||
|
|
function setResize(edge) {
|
||
|
|
if (edge) {
|
||
|
|
if (!resizeEdge) {
|
||
|
|
defaultCursor = document.body.style.cursor;
|
||
|
|
}
|
||
|
|
document.body.style.cursor = cursorForEdge[edge];
|
||
|
|
} else if (!edge && resizeEdge) {
|
||
|
|
document.body.style.cursor = defaultCursor;
|
||
|
|
}
|
||
|
|
resizeEdge = edge || "";
|
||
|
|
}
|
||
|
|
function onMouseMove(event) {
|
||
|
|
if (canResize && resizeEdge) {
|
||
|
|
resizing = true;
|
||
|
|
invoke("wails:resize:" + resizeEdge);
|
||
|
|
} else if (canDrag) {
|
||
|
|
dragging = true;
|
||
|
|
invoke("wails:drag");
|
||
|
|
}
|
||
|
|
if (dragging || resizing) {
|
||
|
|
canDrag = canResize = false;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (!resizable || !IsWindows()) {
|
||
|
|
if (resizeEdge) {
|
||
|
|
setResize();
|
||
|
|
}
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
const resizeHandleHeight = GetFlag("system.resizeHandleHeight") || 5;
|
||
|
|
const resizeHandleWidth = GetFlag("system.resizeHandleWidth") || 5;
|
||
|
|
const cornerExtra = GetFlag("resizeCornerExtra") || 10;
|
||
|
|
const rightBorder = window.outerWidth - event.clientX < resizeHandleWidth;
|
||
|
|
const leftBorder = event.clientX < resizeHandleWidth;
|
||
|
|
const topBorder = event.clientY < resizeHandleHeight;
|
||
|
|
const bottomBorder = window.outerHeight - event.clientY < resizeHandleHeight;
|
||
|
|
const rightCorner = window.outerWidth - event.clientX < resizeHandleWidth + cornerExtra;
|
||
|
|
const leftCorner = event.clientX < resizeHandleWidth + cornerExtra;
|
||
|
|
const topCorner = event.clientY < resizeHandleHeight + cornerExtra;
|
||
|
|
const bottomCorner = window.outerHeight - event.clientY < resizeHandleHeight + cornerExtra;
|
||
|
|
if (!leftCorner && !topCorner && !bottomCorner && !rightCorner) {
|
||
|
|
setResize();
|
||
|
|
} 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");
|
||
|
|
else setResize();
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/application.ts
|
||
|
|
var application_exports = {};
|
||
|
|
__export(application_exports, {
|
||
|
|
Hide: () => Hide,
|
||
|
|
Quit: () => Quit,
|
||
|
|
Show: () => Show
|
||
|
|
});
|
||
|
|
var call6 = newRuntimeCaller(objectNames.Application);
|
||
|
|
var HideMethod2 = 0;
|
||
|
|
var ShowMethod2 = 1;
|
||
|
|
var QuitMethod = 2;
|
||
|
|
function Hide() {
|
||
|
|
return call6(HideMethod2);
|
||
|
|
}
|
||
|
|
function Show() {
|
||
|
|
return call6(ShowMethod2);
|
||
|
|
}
|
||
|
|
function Quit() {
|
||
|
|
return call6(QuitMethod);
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/calls.ts
|
||
|
|
var calls_exports = {};
|
||
|
|
__export(calls_exports, {
|
||
|
|
ByID: () => ByID,
|
||
|
|
ByName: () => ByName,
|
||
|
|
Call: () => Call,
|
||
|
|
RuntimeError: () => RuntimeError
|
||
|
|
});
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/callable.ts
|
||
|
|
var fnToStr = Function.prototype.toString;
|
||
|
|
var reflectApply = typeof Reflect === "object" && Reflect !== null && Reflect.apply;
|
||
|
|
var badArrayLike;
|
||
|
|
var isCallableMarker;
|
||
|
|
if (typeof reflectApply === "function" && typeof Object.defineProperty === "function") {
|
||
|
|
try {
|
||
|
|
badArrayLike = Object.defineProperty({}, "length", {
|
||
|
|
get: function() {
|
||
|
|
throw isCallableMarker;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
isCallableMarker = {};
|
||
|
|
reflectApply(function() {
|
||
|
|
throw 42;
|
||
|
|
}, null, badArrayLike);
|
||
|
|
} catch (_) {
|
||
|
|
if (_ !== isCallableMarker) {
|
||
|
|
reflectApply = null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
reflectApply = null;
|
||
|
|
}
|
||
|
|
var constructorRegex = /^\s*class\b/;
|
||
|
|
var isES6ClassFn = function isES6ClassFunction(value) {
|
||
|
|
try {
|
||
|
|
var fnStr = fnToStr.call(value);
|
||
|
|
return constructorRegex.test(fnStr);
|
||
|
|
} catch (e) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
var tryFunctionObject = function tryFunctionToStr(value) {
|
||
|
|
try {
|
||
|
|
if (isES6ClassFn(value)) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
fnToStr.call(value);
|
||
|
|
return true;
|
||
|
|
} catch (e) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
var toStr = Object.prototype.toString;
|
||
|
|
var objectClass = "[object Object]";
|
||
|
|
var fnClass = "[object Function]";
|
||
|
|
var genClass = "[object GeneratorFunction]";
|
||
|
|
var ddaClass = "[object HTMLAllCollection]";
|
||
|
|
var ddaClass2 = "[object HTML document.all class]";
|
||
|
|
var ddaClass3 = "[object HTMLCollection]";
|
||
|
|
var hasToStringTag = typeof Symbol === "function" && !!Symbol.toStringTag;
|
||
|
|
var isIE68 = !(0 in [,]);
|
||
|
|
var isDDA = function isDocumentDotAll() {
|
||
|
|
return false;
|
||
|
|
};
|
||
|
|
if (typeof document === "object") {
|
||
|
|
all = document.all;
|
||
|
|
if (toStr.call(all) === toStr.call(document.all)) {
|
||
|
|
isDDA = function isDocumentDotAll2(value) {
|
||
|
|
if ((isIE68 || !value) && (typeof value === "undefined" || typeof value === "object")) {
|
||
|
|
try {
|
||
|
|
var str = toStr.call(value);
|
||
|
|
return (str === ddaClass || str === ddaClass2 || str === ddaClass3 || str === objectClass) && value("") == null;
|
||
|
|
} catch (e) {
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
var all;
|
||
|
|
function isCallableRefApply(value) {
|
||
|
|
if (isDDA(value)) {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
if (!value) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if (typeof value !== "function" && typeof value !== "object") {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
reflectApply(value, null, badArrayLike);
|
||
|
|
} catch (e) {
|
||
|
|
if (e !== isCallableMarker) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return !isES6ClassFn(value) && tryFunctionObject(value);
|
||
|
|
}
|
||
|
|
function isCallableNoRefApply(value) {
|
||
|
|
if (isDDA(value)) {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
if (!value) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if (typeof value !== "function" && typeof value !== "object") {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if (hasToStringTag) {
|
||
|
|
return tryFunctionObject(value);
|
||
|
|
}
|
||
|
|
if (isES6ClassFn(value)) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
var strClass = toStr.call(value);
|
||
|
|
if (strClass !== fnClass && strClass !== genClass && !/^\[object HTML/.test(strClass)) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
return tryFunctionObject(value);
|
||
|
|
}
|
||
|
|
var callable_default = reflectApply ? isCallableRefApply : isCallableNoRefApply;
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/cancellable.ts
|
||
|
|
var CancelError = class extends Error {
|
||
|
|
/**
|
||
|
|
* Constructs a new `CancelError` instance.
|
||
|
|
* @param message - The error message.
|
||
|
|
* @param options - Options to be forwarded to the Error constructor.
|
||
|
|
*/
|
||
|
|
constructor(message, options) {
|
||
|
|
super(message, options);
|
||
|
|
this.name = "CancelError";
|
||
|
|
}
|
||
|
|
};
|
||
|
|
var CancelledRejectionError = class extends Error {
|
||
|
|
/**
|
||
|
|
* Constructs a new `CancelledRejectionError` instance.
|
||
|
|
* @param promise - The promise that caused the error originally.
|
||
|
|
* @param reason - The rejection reason.
|
||
|
|
* @param info - An optional informative message specifying the circumstances in which the error was thrown.
|
||
|
|
* Defaults to the string `"Unhandled rejection in cancelled promise."`.
|
||
|
|
*/
|
||
|
|
constructor(promise, reason, info) {
|
||
|
|
super((info != null ? info : "Unhandled rejection in cancelled promise.") + " Reason: " + errorMessage(reason), { cause: reason });
|
||
|
|
this.promise = promise;
|
||
|
|
this.name = "CancelledRejectionError";
|
||
|
|
}
|
||
|
|
};
|
||
|
|
var barrierSym = Symbol("barrier");
|
||
|
|
var cancelImplSym = Symbol("cancelImpl");
|
||
|
|
var _a;
|
||
|
|
var species = (_a = Symbol.species) != null ? _a : Symbol("speciesPolyfill");
|
||
|
|
var CancellablePromise = class _CancellablePromise extends Promise {
|
||
|
|
/**
|
||
|
|
* Creates a new `CancellablePromise`.
|
||
|
|
*
|
||
|
|
* @param executor - A callback used to initialize the promise. This callback is passed two arguments:
|
||
|
|
* a `resolve` callback used to resolve the promise with a value
|
||
|
|
* or the result of another promise (possibly cancellable),
|
||
|
|
* and a `reject` callback used to reject the promise with a provided reason or error.
|
||
|
|
* If the value provided to the `resolve` callback is a thenable _and_ cancellable object
|
||
|
|
* (it has a `then` _and_ a `cancel` method),
|
||
|
|
* cancellation requests will be forwarded to that object and the oncancelled will not be invoked anymore.
|
||
|
|
* If any one of the two callbacks is called _after_ the promise has been cancelled,
|
||
|
|
* the provided values will be cancelled and resolved as usual,
|
||
|
|
* but their results will be discarded.
|
||
|
|
* However, if the resolution process ultimately ends up in a rejection
|
||
|
|
* that is not due to cancellation, the rejection reason
|
||
|
|
* will be wrapped in a {@link CancelledRejectionError}
|
||
|
|
* and bubbled up as an unhandled rejection.
|
||
|
|
* @param oncancelled - It is the caller's responsibility to ensure that any operation
|
||
|
|
* started by the executor is properly halted upon cancellation.
|
||
|
|
* This optional callback can be used to that purpose.
|
||
|
|
* It will be called _synchronously_ with a cancellation cause
|
||
|
|
* when cancellation is requested, _after_ the promise has already rejected
|
||
|
|
* with a {@link CancelError}, but _before_
|
||
|
|
* any {@link then}/{@link catch}/{@link finally} callback runs.
|
||
|
|
* If the callback returns a thenable, the promise returned from {@link cancel}
|
||
|
|
* will only fulfill after the former has settled.
|
||
|
|
* Unhandled exceptions or rejections from the callback will be wrapped
|
||
|
|
* in a {@link CancelledRejectionError} and bubbled up as unhandled rejections.
|
||
|
|
* If the `resolve` callback is called before cancellation with a cancellable promise,
|
||
|
|
* cancellation requests on this promise will be diverted to that promise,
|
||
|
|
* and the original `oncancelled` callback will be discarded.
|
||
|
|
*/
|
||
|
|
constructor(executor, oncancelled) {
|
||
|
|
let resolve;
|
||
|
|
let reject;
|
||
|
|
super((res, rej) => {
|
||
|
|
resolve = res;
|
||
|
|
reject = rej;
|
||
|
|
});
|
||
|
|
if (this.constructor[species] !== Promise) {
|
||
|
|
throw new TypeError("CancellablePromise does not support transparent subclassing. Please refrain from overriding the [Symbol.species] static property.");
|
||
|
|
}
|
||
|
|
let promise = {
|
||
|
|
promise: this,
|
||
|
|
resolve,
|
||
|
|
reject,
|
||
|
|
get oncancelled() {
|
||
|
|
return oncancelled != null ? oncancelled : null;
|
||
|
|
},
|
||
|
|
set oncancelled(cb) {
|
||
|
|
oncancelled = cb != null ? cb : void 0;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
const state = {
|
||
|
|
get root() {
|
||
|
|
return state;
|
||
|
|
},
|
||
|
|
resolving: false,
|
||
|
|
settled: false
|
||
|
|
};
|
||
|
|
void Object.defineProperties(this, {
|
||
|
|
[barrierSym]: {
|
||
|
|
configurable: false,
|
||
|
|
enumerable: false,
|
||
|
|
writable: true,
|
||
|
|
value: null
|
||
|
|
},
|
||
|
|
[cancelImplSym]: {
|
||
|
|
configurable: false,
|
||
|
|
enumerable: false,
|
||
|
|
writable: false,
|
||
|
|
value: cancellerFor(promise, state)
|
||
|
|
}
|
||
|
|
});
|
||
|
|
const rejector = rejectorFor(promise, state);
|
||
|
|
try {
|
||
|
|
executor(resolverFor(promise, state), rejector);
|
||
|
|
} catch (err) {
|
||
|
|
if (state.resolving) {
|
||
|
|
console.log("Unhandled exception in CancellablePromise executor.", err);
|
||
|
|
} else {
|
||
|
|
rejector(err);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Cancels immediately the execution of the operation associated with this promise.
|
||
|
|
* The promise rejects with a {@link CancelError} instance as reason,
|
||
|
|
* with the {@link CancelError#cause} property set to the given argument, if any.
|
||
|
|
*
|
||
|
|
* Has no effect if called after the promise has already settled;
|
||
|
|
* repeated calls in particular are safe, but only the first one
|
||
|
|
* will set the cancellation cause.
|
||
|
|
*
|
||
|
|
* The `CancelError` exception _need not_ be handled explicitly _on the promises that are being cancelled:_
|
||
|
|
* cancelling a promise with no attached rejection handler does not trigger an unhandled rejection event.
|
||
|
|
* Therefore, the following idioms are all equally correct:
|
||
|
|
* ```ts
|
||
|
|
* new CancellablePromise((resolve, reject) => { ... }).cancel();
|
||
|
|
* new CancellablePromise((resolve, reject) => { ... }).then(...).cancel();
|
||
|
|
* new CancellablePromise((resolve, reject) => { ... }).then(...).catch(...).cancel();
|
||
|
|
* ```
|
||
|
|
* Whenever some cancelled promise in a chain rejects with a `CancelError`
|
||
|
|
* with the same cancellation cause as itself, the error will be discarded silently.
|
||
|
|
* However, the `CancelError` _will still be delivered_ to all attached rejection handlers
|
||
|
|
* added by {@link then} and related methods:
|
||
|
|
* ```ts
|
||
|
|
* let cancellable = new CancellablePromise((resolve, reject) => { ... });
|
||
|
|
* cancellable.then(() => { ... }).catch(console.log);
|
||
|
|
* cancellable.cancel(); // A CancelError is printed to the console.
|
||
|
|
* ```
|
||
|
|
* If the `CancelError` is not handled downstream by the time it reaches
|
||
|
|
* a _non-cancelled_ promise, it _will_ trigger an unhandled rejection event,
|
||
|
|
* just like normal rejections would:
|
||
|
|
* ```ts
|
||
|
|
* let cancellable = new CancellablePromise((resolve, reject) => { ... });
|
||
|
|
* let chained = cancellable.then(() => { ... }).then(() => { ... }); // No catch...
|
||
|
|
* cancellable.cancel(); // Unhandled rejection event on chained!
|
||
|
|
* ```
|
||
|
|
* Therefore, it is important to either cancel whole promise chains from their tail,
|
||
|
|
* as shown in the correct idioms above, or take care of handling errors everywhere.
|
||
|
|
*
|
||
|
|
* @returns A cancellable promise that _fulfills_ after the cancel callback (if any)
|
||
|
|
* and all handlers attached up to the call to cancel have run.
|
||
|
|
* If the cancel callback returns a thenable, the promise returned by `cancel`
|
||
|
|
* will also wait for that thenable to settle.
|
||
|
|
* This enables callers to wait for the cancelled operation to terminate
|
||
|
|
* without being forced to handle potential errors at the call site.
|
||
|
|
* ```ts
|
||
|
|
* cancellable.cancel().then(() => {
|
||
|
|
* // Cleanup finished, it's safe to do something else.
|
||
|
|
* }, (err) => {
|
||
|
|
* // Unreachable: the promise returned from cancel will never reject.
|
||
|
|
* });
|
||
|
|
* ```
|
||
|
|
* Note that the returned promise will _not_ handle implicitly any rejection
|
||
|
|
* that might have occurred already in the cancelled chain.
|
||
|
|
* It will just track whether registered handlers have been executed or not.
|
||
|
|
* Therefore, unhandled rejections will never be silently handled by calling cancel.
|
||
|
|
*/
|
||
|
|
cancel(cause) {
|
||
|
|
return new _CancellablePromise((resolve) => {
|
||
|
|
Promise.all([
|
||
|
|
this[cancelImplSym](new CancelError("Promise cancelled.", { cause })),
|
||
|
|
currentBarrier(this)
|
||
|
|
]).then(() => resolve(), () => resolve());
|
||
|
|
});
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Binds promise cancellation to the abort event of the given {@link AbortSignal}.
|
||
|
|
* If the signal has already aborted, the promise will be cancelled immediately.
|
||
|
|
* When either condition is verified, the cancellation cause will be set
|
||
|
|
* to the signal's abort reason (see {@link AbortSignal#reason}).
|
||
|
|
*
|
||
|
|
* Has no effect if called (or if the signal aborts) _after_ the promise has already settled.
|
||
|
|
* Only the first signal to abort will set the cancellation cause.
|
||
|
|
*
|
||
|
|
* For more details about the cancellation process,
|
||
|
|
* see {@link cancel} and the `CancellablePromise` constructor.
|
||
|
|
*
|
||
|
|
* This method enables `await`ing cancellable promises without having
|
||
|
|
* to store them for future cancellation, e.g.:
|
||
|
|
* ```ts
|
||
|
|
* await longRunningOperation().cancelOn(signal);
|
||
|
|
* ```
|
||
|
|
* instead of:
|
||
|
|
* ```ts
|
||
|
|
* let promiseToBeCancelled = longRunningOperation();
|
||
|
|
* await promiseToBeCancelled;
|
||
|
|
* ```
|
||
|
|
*
|
||
|
|
* @returns This promise, for method chaining.
|
||
|
|
*/
|
||
|
|
cancelOn(signal) {
|
||
|
|
if (signal.aborted) {
|
||
|
|
void this.cancel(signal.reason);
|
||
|
|
} else {
|
||
|
|
signal.addEventListener("abort", () => void this.cancel(signal.reason), { capture: true });
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Attaches callbacks for the resolution and/or rejection of the `CancellablePromise`.
|
||
|
|
*
|
||
|
|
* The optional `oncancelled` argument will be invoked when the returned promise is cancelled,
|
||
|
|
* with the same semantics as the `oncancelled` argument of the constructor.
|
||
|
|
* When the parent promise rejects or is cancelled, the `onrejected` callback will run,
|
||
|
|
* _even after the returned promise has been cancelled:_
|
||
|
|
* in that case, should it reject or throw, the reason will be wrapped
|
||
|
|
* in a {@link CancelledRejectionError} and bubbled up as an unhandled rejection.
|
||
|
|
*
|
||
|
|
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||
|
|
* @param onrejected The callback to execute when the Promise is rejected.
|
||
|
|
* @returns A `CancellablePromise` for the completion of whichever callback is executed.
|
||
|
|
* The returned promise is hooked up to propagate cancellation requests up the chain, but not down:
|
||
|
|
*
|
||
|
|
* - if the parent promise is cancelled, the `onrejected` handler will be invoked with a `CancelError`
|
||
|
|
* and the returned promise _will resolve regularly_ with its result;
|
||
|
|
* - conversely, if the returned promise is cancelled, _the parent promise is cancelled too;_
|
||
|
|
* the `onrejected` handler will still be invoked with the parent's `CancelError`,
|
||
|
|
* but its result will be discarded
|
||
|
|
* and the returned promise will reject with a `CancelError` as well.
|
||
|
|
*
|
||
|
|
* The promise returned from {@link cancel} will fulfill only after all attached handlers
|
||
|
|
* up the entire promise chain have been run.
|
||
|
|
*
|
||
|
|
* If either callback returns a cancellable promise,
|
||
|
|
* cancellation requests will be diverted to it,
|
||
|
|
* and the specified `oncancelled` callback will be discarded.
|
||
|
|
*/
|
||
|
|
then(onfulfilled, onrejected, oncancelled) {
|
||
|
|
if (!(this instanceof _CancellablePromise)) {
|
||
|
|
throw new TypeError("CancellablePromise.prototype.then called on an invalid object.");
|
||
|
|
}
|
||
|
|
if (!callable_default(onfulfilled)) {
|
||
|
|
onfulfilled = identity;
|
||
|
|
}
|
||
|
|
if (!callable_default(onrejected)) {
|
||
|
|
onrejected = thrower;
|
||
|
|
}
|
||
|
|
if (onfulfilled === identity && onrejected == thrower) {
|
||
|
|
return new _CancellablePromise((resolve) => resolve(this));
|
||
|
|
}
|
||
|
|
const barrier = {};
|
||
|
|
this[barrierSym] = barrier;
|
||
|
|
return new _CancellablePromise((resolve, reject) => {
|
||
|
|
void super.then(
|
||
|
|
(value) => {
|
||
|
|
var _a2;
|
||
|
|
if (this[barrierSym] === barrier) {
|
||
|
|
this[barrierSym] = null;
|
||
|
|
}
|
||
|
|
(_a2 = barrier.resolve) == null ? void 0 : _a2.call(barrier);
|
||
|
|
try {
|
||
|
|
resolve(onfulfilled(value));
|
||
|
|
} catch (err) {
|
||
|
|
reject(err);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
(reason) => {
|
||
|
|
var _a2;
|
||
|
|
if (this[barrierSym] === barrier) {
|
||
|
|
this[barrierSym] = null;
|
||
|
|
}
|
||
|
|
(_a2 = barrier.resolve) == null ? void 0 : _a2.call(barrier);
|
||
|
|
try {
|
||
|
|
resolve(onrejected(reason));
|
||
|
|
} catch (err) {
|
||
|
|
reject(err);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
);
|
||
|
|
}, async (cause) => {
|
||
|
|
try {
|
||
|
|
return oncancelled == null ? void 0 : oncancelled(cause);
|
||
|
|
} finally {
|
||
|
|
await this.cancel(cause);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Attaches a callback for only the rejection of the Promise.
|
||
|
|
*
|
||
|
|
* The optional `oncancelled` argument will be invoked when the returned promise is cancelled,
|
||
|
|
* with the same semantics as the `oncancelled` argument of the constructor.
|
||
|
|
* When the parent promise rejects or is cancelled, the `onrejected` callback will run,
|
||
|
|
* _even after the returned promise has been cancelled:_
|
||
|
|
* in that case, should it reject or throw, the reason will be wrapped
|
||
|
|
* in a {@link CancelledRejectionError} and bubbled up as an unhandled rejection.
|
||
|
|
*
|
||
|
|
* It is equivalent to
|
||
|
|
* ```ts
|
||
|
|
* cancellablePromise.then(undefined, onrejected, oncancelled);
|
||
|
|
* ```
|
||
|
|
* and the same caveats apply.
|
||
|
|
*
|
||
|
|
* @returns A Promise for the completion of the callback.
|
||
|
|
* Cancellation requests on the returned promise
|
||
|
|
* will propagate up the chain to the parent promise,
|
||
|
|
* but not in the other direction.
|
||
|
|
*
|
||
|
|
* The promise returned from {@link cancel} will fulfill only after all attached handlers
|
||
|
|
* up the entire promise chain have been run.
|
||
|
|
*
|
||
|
|
* If `onrejected` returns a cancellable promise,
|
||
|
|
* cancellation requests will be diverted to it,
|
||
|
|
* and the specified `oncancelled` callback will be discarded.
|
||
|
|
* See {@link then} for more details.
|
||
|
|
*/
|
||
|
|
catch(onrejected, oncancelled) {
|
||
|
|
return this.then(void 0, onrejected, oncancelled);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Attaches a callback that is invoked when the CancellablePromise is settled (fulfilled or rejected). The
|
||
|
|
* resolved value cannot be accessed or modified from the callback.
|
||
|
|
* The returned promise will settle in the same state as the original one
|
||
|
|
* after the provided callback has completed execution,
|
||
|
|
* unless the callback throws or returns a rejecting promise,
|
||
|
|
* in which case the returned promise will reject as well.
|
||
|
|
*
|
||
|
|
* The optional `oncancelled` argument will be invoked when the returned promise is cancelled,
|
||
|
|
* with the same semantics as the `oncancelled` argument of the constructor.
|
||
|
|
* Once the parent promise settles, the `onfinally` callback will run,
|
||
|
|
* _even after the returned promise has been cancelled:_
|
||
|
|
* in that case, should it reject or throw, the reason will be wrapped
|
||
|
|
* in a {@link CancelledRejectionError} and bubbled up as an unhandled rejection.
|
||
|
|
*
|
||
|
|
* This method is implemented in terms of {@link then} and the same caveats apply.
|
||
|
|
* It is polyfilled, hence available in every OS/webview version.
|
||
|
|
*
|
||
|
|
* @returns A Promise for the completion of the callback.
|
||
|
|
* Cancellation requests on the returned promise
|
||
|
|
* will propagate up the chain to the parent promise,
|
||
|
|
* but not in the other direction.
|
||
|
|
*
|
||
|
|
* The promise returned from {@link cancel} will fulfill only after all attached handlers
|
||
|
|
* up the entire promise chain have been run.
|
||
|
|
*
|
||
|
|
* If `onfinally` returns a cancellable promise,
|
||
|
|
* cancellation requests will be diverted to it,
|
||
|
|
* and the specified `oncancelled` callback will be discarded.
|
||
|
|
* See {@link then} for more details.
|
||
|
|
*/
|
||
|
|
finally(onfinally, oncancelled) {
|
||
|
|
if (!(this instanceof _CancellablePromise)) {
|
||
|
|
throw new TypeError("CancellablePromise.prototype.finally called on an invalid object.");
|
||
|
|
}
|
||
|
|
if (!callable_default(onfinally)) {
|
||
|
|
return this.then(onfinally, onfinally, oncancelled);
|
||
|
|
}
|
||
|
|
return this.then(
|
||
|
|
(value) => _CancellablePromise.resolve(onfinally()).then(() => value),
|
||
|
|
(reason) => _CancellablePromise.resolve(onfinally()).then(() => {
|
||
|
|
throw reason;
|
||
|
|
}),
|
||
|
|
oncancelled
|
||
|
|
);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* We use the `[Symbol.species]` static property, if available,
|
||
|
|
* to disable the built-in automatic subclassing features from {@link Promise}.
|
||
|
|
* It is critical for performance reasons that extenders do not override this.
|
||
|
|
* Once the proposal at https://github.com/tc39/proposal-rm-builtin-subclassing
|
||
|
|
* is either accepted or retired, this implementation will have to be revised accordingly.
|
||
|
|
*
|
||
|
|
* @ignore
|
||
|
|
* @internal
|
||
|
|
*/
|
||
|
|
static get [(barrierSym, cancelImplSym, species)]() {
|
||
|
|
return Promise;
|
||
|
|
}
|
||
|
|
static all(values) {
|
||
|
|
let collected = Array.from(values);
|
||
|
|
const promise = collected.length === 0 ? _CancellablePromise.resolve(collected) : new _CancellablePromise((resolve, reject) => {
|
||
|
|
void Promise.all(collected).then(resolve, reject);
|
||
|
|
}, (cause) => cancelAll(promise, collected, cause));
|
||
|
|
return promise;
|
||
|
|
}
|
||
|
|
static allSettled(values) {
|
||
|
|
let collected = Array.from(values);
|
||
|
|
const promise = collected.length === 0 ? _CancellablePromise.resolve(collected) : new _CancellablePromise((resolve, reject) => {
|
||
|
|
void Promise.allSettled(collected).then(resolve, reject);
|
||
|
|
}, (cause) => cancelAll(promise, collected, cause));
|
||
|
|
return promise;
|
||
|
|
}
|
||
|
|
static any(values) {
|
||
|
|
let collected = Array.from(values);
|
||
|
|
const promise = collected.length === 0 ? _CancellablePromise.resolve(collected) : new _CancellablePromise((resolve, reject) => {
|
||
|
|
void Promise.any(collected).then(resolve, reject);
|
||
|
|
}, (cause) => cancelAll(promise, collected, cause));
|
||
|
|
return promise;
|
||
|
|
}
|
||
|
|
static race(values) {
|
||
|
|
let collected = Array.from(values);
|
||
|
|
const promise = new _CancellablePromise((resolve, reject) => {
|
||
|
|
void Promise.race(collected).then(resolve, reject);
|
||
|
|
}, (cause) => cancelAll(promise, collected, cause));
|
||
|
|
return promise;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Creates a new cancelled CancellablePromise for the provided cause.
|
||
|
|
*
|
||
|
|
* @group Static Methods
|
||
|
|
*/
|
||
|
|
static cancel(cause) {
|
||
|
|
const p = new _CancellablePromise(() => {
|
||
|
|
});
|
||
|
|
p.cancel(cause);
|
||
|
|
return p;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Creates a new CancellablePromise that cancels
|
||
|
|
* after the specified timeout, with the provided cause.
|
||
|
|
*
|
||
|
|
* If the {@link AbortSignal.timeout} factory method is available,
|
||
|
|
* it is used to base the timeout on _active_ time rather than _elapsed_ time.
|
||
|
|
* Otherwise, `timeout` falls back to {@link setTimeout}.
|
||
|
|
*
|
||
|
|
* @group Static Methods
|
||
|
|
*/
|
||
|
|
static timeout(milliseconds, cause) {
|
||
|
|
const promise = new _CancellablePromise(() => {
|
||
|
|
});
|
||
|
|
if (AbortSignal && typeof AbortSignal === "function" && AbortSignal.timeout && typeof AbortSignal.timeout === "function") {
|
||
|
|
AbortSignal.timeout(milliseconds).addEventListener("abort", () => void promise.cancel(cause));
|
||
|
|
} else {
|
||
|
|
setTimeout(() => void promise.cancel(cause), milliseconds);
|
||
|
|
}
|
||
|
|
return promise;
|
||
|
|
}
|
||
|
|
static sleep(milliseconds, value) {
|
||
|
|
return new _CancellablePromise((resolve) => {
|
||
|
|
setTimeout(() => resolve(value), milliseconds);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Creates a new rejected CancellablePromise for the provided reason.
|
||
|
|
*
|
||
|
|
* @group Static Methods
|
||
|
|
*/
|
||
|
|
static reject(reason) {
|
||
|
|
return new _CancellablePromise((_, reject) => reject(reason));
|
||
|
|
}
|
||
|
|
static resolve(value) {
|
||
|
|
if (value instanceof _CancellablePromise) {
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
return new _CancellablePromise((resolve) => resolve(value));
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Creates a new CancellablePromise and returns it in an object, along with its resolve and reject functions
|
||
|
|
* and a getter/setter for the cancellation callback.
|
||
|
|
*
|
||
|
|
* This method is polyfilled, hence available in every OS/webview version.
|
||
|
|
*
|
||
|
|
* @group Static Methods
|
||
|
|
*/
|
||
|
|
static withResolvers() {
|
||
|
|
let result = { oncancelled: null };
|
||
|
|
result.promise = new _CancellablePromise((resolve, reject) => {
|
||
|
|
result.resolve = resolve;
|
||
|
|
result.reject = reject;
|
||
|
|
}, (cause) => {
|
||
|
|
var _a2;
|
||
|
|
(_a2 = result.oncancelled) == null ? void 0 : _a2.call(result, cause);
|
||
|
|
});
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
function cancellerFor(promise, state) {
|
||
|
|
let cancellationPromise = void 0;
|
||
|
|
return (reason) => {
|
||
|
|
if (!state.settled) {
|
||
|
|
state.settled = true;
|
||
|
|
state.reason = reason;
|
||
|
|
promise.reject(reason);
|
||
|
|
void Promise.prototype.then.call(promise.promise, void 0, (err) => {
|
||
|
|
if (err !== reason) {
|
||
|
|
throw err;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
if (!state.reason || !promise.oncancelled) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
cancellationPromise = new Promise((resolve) => {
|
||
|
|
try {
|
||
|
|
resolve(promise.oncancelled(state.reason.cause));
|
||
|
|
} catch (err) {
|
||
|
|
Promise.reject(new CancelledRejectionError(promise.promise, err, "Unhandled exception in oncancelled callback."));
|
||
|
|
}
|
||
|
|
}).catch((reason2) => {
|
||
|
|
Promise.reject(new CancelledRejectionError(promise.promise, reason2, "Unhandled rejection in oncancelled callback."));
|
||
|
|
});
|
||
|
|
promise.oncancelled = null;
|
||
|
|
return cancellationPromise;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
function resolverFor(promise, state) {
|
||
|
|
return (value) => {
|
||
|
|
if (state.resolving) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
state.resolving = true;
|
||
|
|
if (value === promise.promise) {
|
||
|
|
if (state.settled) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
state.settled = true;
|
||
|
|
promise.reject(new TypeError("A promise cannot be resolved with itself."));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (value != null && (typeof value === "object" || typeof value === "function")) {
|
||
|
|
let then;
|
||
|
|
try {
|
||
|
|
then = value.then;
|
||
|
|
} catch (err) {
|
||
|
|
state.settled = true;
|
||
|
|
promise.reject(err);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (callable_default(then)) {
|
||
|
|
try {
|
||
|
|
let cancel = value.cancel;
|
||
|
|
if (callable_default(cancel)) {
|
||
|
|
const oncancelled = (cause) => {
|
||
|
|
Reflect.apply(cancel, value, [cause]);
|
||
|
|
};
|
||
|
|
if (state.reason) {
|
||
|
|
void cancellerFor(__spreadProps(__spreadValues({}, promise), { oncancelled }), state)(state.reason);
|
||
|
|
} else {
|
||
|
|
promise.oncancelled = oncancelled;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} catch (e) {
|
||
|
|
}
|
||
|
|
const newState = {
|
||
|
|
root: state.root,
|
||
|
|
resolving: false,
|
||
|
|
get settled() {
|
||
|
|
return this.root.settled;
|
||
|
|
},
|
||
|
|
set settled(value2) {
|
||
|
|
this.root.settled = value2;
|
||
|
|
},
|
||
|
|
get reason() {
|
||
|
|
return this.root.reason;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
const rejector = rejectorFor(promise, newState);
|
||
|
|
try {
|
||
|
|
Reflect.apply(then, value, [resolverFor(promise, newState), rejector]);
|
||
|
|
} catch (err) {
|
||
|
|
rejector(err);
|
||
|
|
}
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (state.settled) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
state.settled = true;
|
||
|
|
promise.resolve(value);
|
||
|
|
};
|
||
|
|
}
|
||
|
|
function rejectorFor(promise, state) {
|
||
|
|
return (reason) => {
|
||
|
|
if (state.resolving) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
state.resolving = true;
|
||
|
|
if (state.settled) {
|
||
|
|
try {
|
||
|
|
if (reason instanceof CancelError && state.reason instanceof CancelError && Object.is(reason.cause, state.reason.cause)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
} catch (e) {
|
||
|
|
}
|
||
|
|
void Promise.reject(new CancelledRejectionError(promise.promise, reason));
|
||
|
|
} else {
|
||
|
|
state.settled = true;
|
||
|
|
promise.reject(reason);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
}
|
||
|
|
function cancelAll(parent, values, cause) {
|
||
|
|
const results = [];
|
||
|
|
for (const value of values) {
|
||
|
|
let cancel;
|
||
|
|
try {
|
||
|
|
if (!callable_default(value.then)) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
cancel = value.cancel;
|
||
|
|
if (!callable_default(cancel)) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
} catch (e) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
let result;
|
||
|
|
try {
|
||
|
|
result = Reflect.apply(cancel, value, [cause]);
|
||
|
|
} catch (err) {
|
||
|
|
Promise.reject(new CancelledRejectionError(parent, err, "Unhandled exception in cancel method."));
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
if (!result) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
results.push(
|
||
|
|
(result instanceof Promise ? result : Promise.resolve(result)).catch((reason) => {
|
||
|
|
Promise.reject(new CancelledRejectionError(parent, reason, "Unhandled rejection in cancel method."));
|
||
|
|
})
|
||
|
|
);
|
||
|
|
}
|
||
|
|
return Promise.all(results);
|
||
|
|
}
|
||
|
|
function identity(x) {
|
||
|
|
return x;
|
||
|
|
}
|
||
|
|
function thrower(reason) {
|
||
|
|
throw reason;
|
||
|
|
}
|
||
|
|
function errorMessage(err) {
|
||
|
|
try {
|
||
|
|
if (err instanceof Error || typeof err !== "object" || err.toString !== Object.prototype.toString) {
|
||
|
|
return "" + err;
|
||
|
|
}
|
||
|
|
} catch (e) {
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
return JSON.stringify(err);
|
||
|
|
} catch (e) {
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
return Object.prototype.toString.call(err);
|
||
|
|
} catch (e) {
|
||
|
|
}
|
||
|
|
return "<could not convert error to string>";
|
||
|
|
}
|
||
|
|
function currentBarrier(promise) {
|
||
|
|
var _a2;
|
||
|
|
let pwr = (_a2 = promise[barrierSym]) != null ? _a2 : {};
|
||
|
|
if (!("promise" in pwr)) {
|
||
|
|
Object.assign(pwr, promiseWithResolvers());
|
||
|
|
}
|
||
|
|
if (promise[barrierSym] == null) {
|
||
|
|
pwr.resolve();
|
||
|
|
promise[barrierSym] = pwr;
|
||
|
|
}
|
||
|
|
return pwr.promise;
|
||
|
|
}
|
||
|
|
var promiseWithResolvers = Promise.withResolvers;
|
||
|
|
if (promiseWithResolvers && typeof promiseWithResolvers === "function") {
|
||
|
|
promiseWithResolvers = promiseWithResolvers.bind(Promise);
|
||
|
|
} else {
|
||
|
|
promiseWithResolvers = function() {
|
||
|
|
let resolve;
|
||
|
|
let reject;
|
||
|
|
const promise = new Promise((res, rej) => {
|
||
|
|
resolve = res;
|
||
|
|
reject = rej;
|
||
|
|
});
|
||
|
|
return { promise, resolve, reject };
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/calls.ts
|
||
|
|
window._wails = window._wails || {};
|
||
|
|
window._wails.callResultHandler = resultHandler;
|
||
|
|
window._wails.callErrorHandler = errorHandler;
|
||
|
|
var call7 = newRuntimeCaller(objectNames.Call);
|
||
|
|
var cancelCall = newRuntimeCaller(objectNames.CancelCall);
|
||
|
|
var callResponses = /* @__PURE__ */ new Map();
|
||
|
|
var CallBinding = 0;
|
||
|
|
var CancelMethod = 0;
|
||
|
|
var RuntimeError = class extends Error {
|
||
|
|
/**
|
||
|
|
* Constructs a new RuntimeError instance.
|
||
|
|
* @param message - The error message.
|
||
|
|
* @param options - Options to be forwarded to the Error constructor.
|
||
|
|
*/
|
||
|
|
constructor(message, options) {
|
||
|
|
super(message, options);
|
||
|
|
this.name = "RuntimeError";
|
||
|
|
}
|
||
|
|
};
|
||
|
|
function resultHandler(id, data, isJSON) {
|
||
|
|
const resolvers = getAndDeleteResponse2(id);
|
||
|
|
if (!resolvers) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (!data) {
|
||
|
|
resolvers.resolve(void 0);
|
||
|
|
} else if (!isJSON) {
|
||
|
|
resolvers.resolve(data);
|
||
|
|
} else {
|
||
|
|
try {
|
||
|
|
resolvers.resolve(JSON.parse(data));
|
||
|
|
} catch (err) {
|
||
|
|
resolvers.reject(new TypeError("could not parse result: " + err.message, { cause: err }));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function errorHandler(id, data, isJSON) {
|
||
|
|
const resolvers = getAndDeleteResponse2(id);
|
||
|
|
if (!resolvers) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (!isJSON) {
|
||
|
|
resolvers.reject(new Error(data));
|
||
|
|
} else {
|
||
|
|
let error;
|
||
|
|
try {
|
||
|
|
error = JSON.parse(data);
|
||
|
|
} catch (err) {
|
||
|
|
resolvers.reject(new TypeError("could not parse error: " + err.message, { cause: err }));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
let options = {};
|
||
|
|
if (error.cause) {
|
||
|
|
options.cause = error.cause;
|
||
|
|
}
|
||
|
|
let exception;
|
||
|
|
switch (error.kind) {
|
||
|
|
case "ReferenceError":
|
||
|
|
exception = new ReferenceError(error.message, options);
|
||
|
|
break;
|
||
|
|
case "TypeError":
|
||
|
|
exception = new TypeError(error.message, options);
|
||
|
|
break;
|
||
|
|
case "RuntimeError":
|
||
|
|
exception = new RuntimeError(error.message, options);
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
exception = new Error(error.message, options);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
resolvers.reject(exception);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function getAndDeleteResponse2(id) {
|
||
|
|
const response = callResponses.get(id);
|
||
|
|
callResponses.delete(id);
|
||
|
|
return response;
|
||
|
|
}
|
||
|
|
function generateID2() {
|
||
|
|
let result;
|
||
|
|
do {
|
||
|
|
result = nanoid();
|
||
|
|
} while (callResponses.has(result));
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
function Call(options) {
|
||
|
|
const id = generateID2();
|
||
|
|
const result = CancellablePromise.withResolvers();
|
||
|
|
callResponses.set(id, { resolve: result.resolve, reject: result.reject });
|
||
|
|
const request = call7(CallBinding, Object.assign({ "call-id": id }, options));
|
||
|
|
let running = false;
|
||
|
|
request.then(() => {
|
||
|
|
running = true;
|
||
|
|
}, (err) => {
|
||
|
|
callResponses.delete(id);
|
||
|
|
result.reject(err);
|
||
|
|
});
|
||
|
|
const cancel = () => {
|
||
|
|
callResponses.delete(id);
|
||
|
|
return cancelCall(CancelMethod, { "call-id": id }).catch((err) => {
|
||
|
|
console.error("Error while requesting binding call cancellation:", err);
|
||
|
|
});
|
||
|
|
};
|
||
|
|
result.oncancelled = () => {
|
||
|
|
if (running) {
|
||
|
|
return cancel();
|
||
|
|
} else {
|
||
|
|
return request.then(cancel);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
return result.promise;
|
||
|
|
}
|
||
|
|
function ByName(methodName, ...args) {
|
||
|
|
return Call({ methodName, args });
|
||
|
|
}
|
||
|
|
function ByID(methodID, ...args) {
|
||
|
|
return Call({ methodID, args });
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/clipboard.ts
|
||
|
|
var clipboard_exports = {};
|
||
|
|
__export(clipboard_exports, {
|
||
|
|
SetText: () => SetText,
|
||
|
|
Text: () => Text
|
||
|
|
});
|
||
|
|
var call8 = newRuntimeCaller(objectNames.Clipboard);
|
||
|
|
var ClipboardSetText = 0;
|
||
|
|
var ClipboardText = 1;
|
||
|
|
function SetText(text) {
|
||
|
|
return call8(ClipboardSetText, { text });
|
||
|
|
}
|
||
|
|
function Text() {
|
||
|
|
return call8(ClipboardText);
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/create.ts
|
||
|
|
var create_exports = {};
|
||
|
|
__export(create_exports, {
|
||
|
|
Any: () => Any,
|
||
|
|
Array: () => Array2,
|
||
|
|
ByteSlice: () => ByteSlice,
|
||
|
|
Map: () => Map2,
|
||
|
|
Nullable: () => Nullable,
|
||
|
|
Struct: () => Struct
|
||
|
|
});
|
||
|
|
function Any(source) {
|
||
|
|
return source;
|
||
|
|
}
|
||
|
|
function ByteSlice(source) {
|
||
|
|
return source == null ? "" : source;
|
||
|
|
}
|
||
|
|
function Array2(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;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
function Map2(key, value) {
|
||
|
|
if (value === Any) {
|
||
|
|
return (source) => source === null ? {} : source;
|
||
|
|
}
|
||
|
|
return (source) => {
|
||
|
|
if (source === null) {
|
||
|
|
return {};
|
||
|
|
}
|
||
|
|
for (const key2 in source) {
|
||
|
|
source[key2] = value(source[key2]);
|
||
|
|
}
|
||
|
|
return source;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
function Nullable(element) {
|
||
|
|
if (element === Any) {
|
||
|
|
return Any;
|
||
|
|
}
|
||
|
|
return (source) => source === null ? null : element(source);
|
||
|
|
}
|
||
|
|
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;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/screens.ts
|
||
|
|
var screens_exports = {};
|
||
|
|
__export(screens_exports, {
|
||
|
|
GetAll: () => GetAll,
|
||
|
|
GetCurrent: () => GetCurrent,
|
||
|
|
GetPrimary: () => GetPrimary
|
||
|
|
});
|
||
|
|
var call9 = newRuntimeCaller(objectNames.Screens);
|
||
|
|
var getAll = 0;
|
||
|
|
var getPrimary = 1;
|
||
|
|
var getCurrent = 2;
|
||
|
|
function GetAll() {
|
||
|
|
return call9(getAll);
|
||
|
|
}
|
||
|
|
function GetPrimary() {
|
||
|
|
return call9(getPrimary);
|
||
|
|
}
|
||
|
|
function GetCurrent() {
|
||
|
|
return call9(getCurrent);
|
||
|
|
}
|
||
|
|
|
||
|
|
// desktop/@wailsio/runtime/src/index.ts
|
||
|
|
window._wails = window._wails || {};
|
||
|
|
window._wails.invoke = invoke;
|
||
|
|
window._wails.handlePlatformFileDrop = window_default.HandlePlatformFileDrop.bind(window_default);
|
||
|
|
invoke("wails:runtime:ready");
|
||
|
|
export {
|
||
|
|
application_exports as Application,
|
||
|
|
browser_exports as Browser,
|
||
|
|
calls_exports as Call,
|
||
|
|
CancelError,
|
||
|
|
CancellablePromise,
|
||
|
|
CancelledRejectionError,
|
||
|
|
clipboard_exports as Clipboard,
|
||
|
|
create_exports as Create,
|
||
|
|
dialogs_exports as Dialogs,
|
||
|
|
events_exports as Events,
|
||
|
|
flags_exports as Flags,
|
||
|
|
screens_exports as Screens,
|
||
|
|
system_exports as System,
|
||
|
|
wml_exports as WML,
|
||
|
|
window_default as Window
|
||
|
|
};
|
||
|
|
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vcnVudGltZS9kZXNrdG9wL0B3YWlsc2lvL3J1bnRpbWUvc3JjL2luZGV4LnRzIiwgIi4uLy4uL3J1bnRpbWUvZGVza3RvcC9Ad2FpbHNpby9ydW50aW1lL3NyYy93bWwudHMiLCAiLi4vLi4vcnVudGltZS9kZXNrdG9wL0B3YWlsc2lvL3J1bnRpbWUvc3JjL2Jyb3dzZXIudHMiLCAiLi4vLi4vcnVudGltZS9kZXNrdG9wL0B3YWlsc2lvL3J1bnRpbWUvc3JjL25hbm9pZC50cyIsICIuLi8uLi9ydW50aW1lL2Rlc2t0b3AvQHdhaWxzaW8vcnVudGltZS9zcmMvcnVudGltZS50cyIsICIuLi8uLi9ydW50aW1lL2Rlc2t0b3AvQHdhaWxzaW8vcnVudGltZS9zcmMvZGlhbG9ncy50cyIsICIuLi8uLi9ydW50aW1lL2Rlc2t0b3AvQHdhaWxzaW8vcnVudGltZS9zcmMvZXZlbnRzLnRzIiwgIi4uLy4uL3J1bnRpbWUvZGVza3RvcC9Ad2FpbHNpby9ydW50aW1lL3NyYy9saXN0ZW5lci50cyIsICIuLi8uLi9ydW50aW1lL2Rlc2t0b3AvQHdhaWxzaW8vcnVudGltZS9zcmMvZXZlbnRfdHlwZXMudHMiLCAiLi4vLi4vcnVudGltZS9kZXNrdG9wL0B3YWlsc2lvL3J1bnRpbWUvc3JjL3V0aWxzLnRzIiwgIi4uLy4uL3J1bnRpbWUvZGVza3RvcC9Ad2FpbHNpby9ydW50aW1lL3NyYy93aW5kb3cudHMiLCAiLi4vLi4vcnVudGltZS9kZXNrdG9wL2NvbXBpbGVkL21haW4uanMiLCAiLi4vLi4vcnVudGltZS9kZXNrdG9wL0B3YWlsc2lvL3J1bnRpbWUvc3JjL3N5c3RlbS50cyIsICIuLi8uLi9ydW50aW1lL2Rlc2t0b3AvQHdhaWxzaW8vcnVudGltZS9zcmMvY29udGV4dG1lbnUudHMiLCAiLi4vLi4vcnVudGltZS9kZXNrdG9wL0B3YWlsc2lvL3J1bnRpbWUvc3JjL2ZsYWdzLnRzIiwgIi4uLy4uL3J1bnRpbWUvZGVza3RvcC9Ad2FpbHNpby9ydW50aW1lL3NyYy9kcmFnLnRzIiwgIi4uLy4uL3J1bnRpbWUvZGVza3RvcC9Ad2FpbHNpby9ydW50aW1lL3NyYy9hcHBsaWNhdGlvbi50cyIsICIuLi8uLi9ydW50aW1lL2Rlc2t0b3AvQHdhaWxzaW8vcnVudGltZS9zcmMvY2FsbHMudHMiLCAiLi4vLi4vcnVudGltZS9kZXNrdG9wL0B3YWlsc2lvL3J1bnRpbWUvc3JjL2NhbGxhYmxlLnRzIiwgIi4uLy4uL3J1bnRpbWUvZGVza3RvcC9Ad2FpbHNpby9ydW50aW1lL3NyYy9jYW5jZWxsYWJsZS50cyIsICIuLi8uLi9ydW50aW1lL2Rlc2t0b3AvQHdhaWxzaW8vcnVudGltZS9zcmMvY2xpcGJvYXJkLnRzIiwgIi4uLy4uL3J1bnRpbWUvZGVza3RvcC9Ad2FpbHNpby9ydW50aW1lL3NyYy9jcmVhdGUudHMiLCAiLi4vLi4vcnVudGltZS9kZXNrdG9wL0B3YWlsc2lvL3J1bnRpbWUvc3JjL3NjcmVlbnMudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbIi8qXG4gX1x0ICAgX19cdCAgXyBfX1xufCB8XHQgLyAvX19fIF8oXykgL19fX19cbnwgfCAvfCAvIC8gX18gYC8gLyAvIF9fXy9cbnwgfC8gfC8gLyAvXy8gLyAvIChfXyAgKVxufF9fL3xfXy9cXF9fLF8vXy9fL19fX18vXG5UaGUgZWxlY3Ryb24gYWx0ZXJuYXRpdmUgZm9yIEdvXG4oYykgTGVhIEFudGhvbnkgMjAxOS1wcmVzZW50XG4qL1xuXG4vLyBTZXR1cFxud2luZG93Ll93YWlscyA9IHdpbmRvdy5fd2FpbHMgfHwge307XG5cbmltcG9ydCBcIi4vY29udGV4dG1lbnUuanNcIjtcbmltcG9ydCBcIi4vZHJhZy5qc1wiO1xuXG4vLyBSZS1leHBvcnQgcHVibGljIEFQSVxuaW1wb3J0ICogYXMgQXBwbGljYXRpb24gZnJvbSBcIi4vYXBwbGljYXRpb24uanNcIjtcbmltcG9ydCAqIGFzIEJyb3dzZXIgZnJvbSBcIi4vYnJvd3Nlci5qc1wiO1xuaW1wb3J0ICogYXMgQ2FsbCBmcm9tIFwiLi9jYWxscy5qc1wiO1xuaW1wb3J0ICogYXMgQ2xpcGJvYXJkIGZyb20gXCIuL2NsaXBib2FyZC5qc1wiO1xuaW1wb3J0ICogYXMgQ3JlYXRlIGZyb20gXCIuL2NyZWF0ZS5qc1wiO1xuaW1wb3J0ICogYXMgRGlhbG9ncyBmcm9tIFwiLi9kaWFsb2dzLmpzXCI7XG5pbXBvcnQgKiBhcyBFdmVudHMgZnJvbSBcIi4vZXZlbnRzLmpzXCI7XG5pbXBvcnQgKiBhcyBGbGFncyBmcm9tIFwiLi9mbGFncy5qc1wiO1xuaW1wb3J0ICogYXMgU2NyZWVucyBmcm9tIFwiLi9zY3JlZW5zLmpzXCI7XG5pbXBvcnQgKiBhcyBTeXN0ZW0gZnJvbSBcIi4vc3lzdGVtLmpzXCI7XG5pbXBvcnQgV2luZG93IGZyb20gXCIuL3dpbmRvdy5qc1wiO1xuaW1wb3J0ICogYXMgV01MIGZyb20gXCIuL3dtbC5qc1wiO1xuXG5leHBvcnQge1xuICAgIEFwcGxpY2F0aW9uLFxuICAgIEJyb3dzZXIsXG4gICAgQ2FsbCxcbiAgICBDbGlwYm9hcmQsXG4gICAgRGlhbG9ncyxcbiAgICBFdmVudHMsXG4gICAgRmxhZ3MsXG4gICAgU2NyZWVucyxcbiAgICBTeXN0ZW0sXG4gICAgV2luZG93LFxuICAgIFdNTFxufTtcblxuLyoqXG4gKiBBbiBpbnRlcm5hbCB1dGlsaXR5IGNvbnN1bWVkIGJ5IHRoZSBiaW5kaW5nIGdlbmVyYXRvci5cbiAqXG4gKiBAaWdub3JlXG4gKiBAaW50ZXJuYWxcbiAqL1xuZXhwb3J0IHsgQ3JlYXRlIH07XG5cbmV4cG9ydCAqIGZyb20gXCIuL2NhbmNlbGxhYmxlLmpzXCI7XG5cbi8vIE5vdGlmeSBiYWNrZW5kXG53aW5kb3cuX3dhaWxzLmludm9rZSA9IFN5c3RlbS5pbnZva2U7XG5cbi8vIFJlZ2lzdGVyIHBsYXRmb3JtIGhhbmRsZXJzIChpbnRlcm5hbCBBUEkpXG4vLyBOb3RlOiBXaW5kb3cgaXMgdGhlIHRoaXNXaW5kb3cgaW5zdGFuY2UgKGRlZmF1bHQgZXhwb3J0IGZyb20gd2luZG93LnRzKVxuLy8gQmluZGluZyBlbnN1cmVzICd0aGlzJyBjb3JyZWN0bHkgcmVmZXJzIHRvIHRoZSBjdXJyZW50IHdpbmRvdyBpbnN0YW5jZVxud2luZG93Ll93YWlscy5oYW5kbGVQbGF0Zm9ybUZpbGVEcm9wID0gV2luZG93LkhhbmRsZVBsYXRmb3JtRmlsZURyb3AuYmluZChXaW5kb3cpO1xuXG5TeXN0ZW0uaW52b2tlKFwid2FpbHM6cnVudGltZTpyZWFkeVwiKTtcbiIsICIvKlxuIF8gICAgIF9fICAgICBfIF9fXG58IHwgIC8gL19fXyBfKF8pIC9fX19fXG58IHwgL3wgLyAvIF9fIGAvIC8gLyBfX18vXG58IHwvIHwvIC8gL18vIC8gLyAoX18gIClcbnxfXy98X18vXFxfXyxfL18vXy9fX19fL1xuVGhlIGVsZ
|