@wailsio/runtime 3.0.0-alpha.65 → 3.0.0-alpha.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{src → dist}/application.js +2 -16
- package/dist/browser.js +20 -0
- package/dist/callable.js +144 -0
- package/dist/calls.js +194 -0
- package/dist/cancellable.js +792 -0
- package/dist/clipboard.js +30 -0
- package/dist/contextmenu.js +80 -0
- package/{src → dist}/create.js +2 -33
- package/dist/dialogs.js +134 -0
- package/dist/drag.js +222 -0
- package/dist/event_types.js +232 -0
- package/dist/events.js +114 -0
- package/dist/flags.js +23 -0
- package/dist/index.js +38 -0
- package/dist/listener.js +44 -0
- package/{src → dist}/nanoid.js +7 -11
- package/dist/runtime.js +63 -0
- package/dist/screens.js +38 -0
- package/dist/system.js +146 -0
- package/{src → dist}/utils.js +29 -20
- package/dist/window.js +570 -0
- package/{src → dist}/wml.js +52 -123
- package/package.json +43 -19
- package/types/application.d.ts +3 -10
- package/types/browser.d.ts +4 -4
- package/types/callable.d.ts +3 -0
- package/types/calls.d.ts +43 -49
- package/types/cancellable.d.ts +434 -0
- package/types/clipboard.d.ts +6 -5
- package/types/contextmenu.d.ts +1 -0
- package/types/create.d.ts +6 -27
- package/types/dialogs.d.ts +99 -143
- package/types/drag.d.ts +1 -0
- package/types/event_types.d.ts +221 -219
- package/types/events.d.ts +46 -250
- package/types/flags.d.ts +3 -3
- package/types/index.d.ts +16 -14
- package/types/listener.d.ts +9 -0
- package/types/nanoid.d.ts +1 -1
- package/types/runtime.d.ts +18 -26
- package/types/screens.d.ts +42 -76
- package/types/system.d.ts +59 -79
- package/types/utils.d.ts +15 -8
- package/types/window.d.ts +123 -224
- package/types/wml.d.ts +2 -6
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -22
- package/docs/assets/icons.js +0 -15
- package/docs/assets/icons.svg +0 -1
- package/docs/assets/main.js +0 -59
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1415
- package/docs/classes/Call.RuntimeError.html +0 -11
- package/docs/classes/Events.WailsEvent.html +0 -4
- package/docs/functions/Application.Hide.html +0 -2
- package/docs/functions/Application.Quit.html +0 -2
- package/docs/functions/Application.Show.html +0 -2
- package/docs/functions/Browser.OpenURL.html +0 -3
- package/docs/functions/Call.ByID.html +0 -8
- package/docs/functions/Call.ByName.html +0 -6
- package/docs/functions/Call.Call.html +0 -11
- package/docs/functions/Clipboard.SetText.html +0 -6
- package/docs/functions/Clipboard.Text.html +0 -3
- package/docs/functions/Create.Any.html +0 -2
- package/docs/functions/Create.Array.html +0 -4
- package/docs/functions/Create.ByteSlice.html +0 -3
- package/docs/functions/Create.Map.html +0 -4
- package/docs/functions/Create.Nullable.html +0 -3
- package/docs/functions/Create.Struct.html +0 -3
- package/docs/functions/Dialogs.Error.html +0 -5
- package/docs/functions/Dialogs.Info.html +0 -5
- package/docs/functions/Dialogs.OpenFile.html +0 -3
- package/docs/functions/Dialogs.Question.html +0 -5
- package/docs/functions/Dialogs.SaveFile.html +0 -3
- package/docs/functions/Dialogs.Warning.html +0 -5
- package/docs/functions/Events.Emit.html +0 -6
- package/docs/functions/Events.Off.html +0 -4
- package/docs/functions/Events.OffAll.html +0 -3
- package/docs/functions/Events.On.html +0 -7
- package/docs/functions/Events.OnMultiple.html +0 -8
- package/docs/functions/Events.Once.html +0 -7
- package/docs/functions/Events.setup.html +0 -1
- package/docs/functions/Flags.GetFlag.html +0 -6
- package/docs/functions/Screens.GetAll.html +0 -3
- package/docs/functions/Screens.GetCurrent.html +0 -3
- package/docs/functions/Screens.GetPrimary.html +0 -3
- package/docs/functions/System.Capabilities.html +0 -4
- package/docs/functions/System.Environment.html +0 -5
- package/docs/functions/System.IsAMD64.html +0 -3
- package/docs/functions/System.IsARM.html +0 -3
- package/docs/functions/System.IsARM64.html +0 -5
- package/docs/functions/System.IsDarkMode.html +0 -5
- package/docs/functions/System.IsDebug.html +0 -1
- package/docs/functions/System.IsLinux.html +0 -3
- package/docs/functions/System.IsMac.html +0 -3
- package/docs/functions/System.IsWindows.html +0 -3
- package/docs/functions/System.invoke.html +0 -1
- package/docs/functions/WML.Enable.html +0 -2
- package/docs/functions/WML.Reload.html +0 -2
- package/docs/functions/init.html +0 -1
- package/docs/index.html +0 -5
- package/docs/interfaces/Call.CallOptions.html +0 -7
- package/docs/interfaces/Dialogs.Button.html +0 -7
- package/docs/interfaces/Dialogs.FileFilter.html +0 -5
- package/docs/interfaces/Dialogs.MessageDialogOptions.html +0 -9
- package/docs/interfaces/Dialogs.OpenFileDialogOptions.html +0 -33
- package/docs/interfaces/Dialogs.SaveFileDialogOptions.html +0 -35
- package/docs/interfaces/Screens.Rect.html +0 -9
- package/docs/interfaces/Screens.Screen.html +0 -25
- package/docs/interfaces/Screens.Size.html +0 -5
- package/docs/interfaces/System.EnvironmentInfo.html +0 -11
- package/docs/interfaces/System.OSInfo.html +0 -9
- package/docs/modules/Application.html +0 -4
- package/docs/modules/Browser.html +0 -2
- package/docs/modules/Call.html +0 -6
- package/docs/modules/Clipboard.html +0 -3
- package/docs/modules/Create.html +0 -7
- package/docs/modules/Dialogs.html +0 -12
- package/docs/modules/Events.html +0 -10
- package/docs/modules/Flags.html +0 -2
- package/docs/modules/Screens.html +0 -7
- package/docs/modules/System.html +0 -14
- package/docs/modules/WML.html +0 -3
- package/docs/modules.html +0 -14
- package/docs/variables/Events.Types.html +0 -1
- package/docs/variables/Window.html +0 -2
- package/src/browser.js +0 -24
- package/src/calls.js +0 -221
- package/src/clipboard.js +0 -35
- package/src/contextmenu.js +0 -97
- package/src/dialogs.js +0 -200
- package/src/drag.js +0 -119
- package/src/event_types.js +0 -219
- package/src/events.js +0 -140
- package/src/flags.js +0 -25
- package/src/index.js +0 -60
- package/src/runtime.js +0 -92
- package/src/screens.js +0 -71
- package/src/system.js +0 -143
- package/src/window.js +0 -638
- package/tsconfig.json +0 -20
package/dist/system.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/*
|
|
2
|
+
_ __ _ __
|
|
3
|
+
| | / /___ _(_) /____
|
|
4
|
+
| | /| / / __ `/ / / ___/
|
|
5
|
+
| |/ |/ / /_/ / / (__ )
|
|
6
|
+
|__/|__/\__,_/_/_/____/
|
|
7
|
+
The electron alternative for Go
|
|
8
|
+
(c) Lea Anthony 2019-present
|
|
9
|
+
*/
|
|
10
|
+
import { newRuntimeCaller, objectNames } from "./runtime.js";
|
|
11
|
+
const call = newRuntimeCaller(objectNames.System);
|
|
12
|
+
const SystemIsDarkMode = 0;
|
|
13
|
+
const SystemEnvironment = 1;
|
|
14
|
+
const ApplicationFilesDroppedWithContext = 100; // New method ID for enriched drop event
|
|
15
|
+
const _invoke = (function () {
|
|
16
|
+
var _a, _b, _c, _d, _e;
|
|
17
|
+
try {
|
|
18
|
+
if ((_b = (_a = window.chrome) === null || _a === void 0 ? void 0 : _a.webview) === null || _b === void 0 ? void 0 : _b.postMessage) {
|
|
19
|
+
return window.chrome.webview.postMessage.bind(window.chrome.webview);
|
|
20
|
+
}
|
|
21
|
+
else if ((_e = (_d = (_c = window.webkit) === null || _c === void 0 ? void 0 : _c.messageHandlers) === null || _d === void 0 ? void 0 : _d['external']) === null || _e === void 0 ? void 0 : _e.postMessage) {
|
|
22
|
+
return window.webkit.messageHandlers['external'].postMessage.bind(window.webkit.messageHandlers['external']);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (e) { }
|
|
26
|
+
console.warn('\n%c⚠️ Browser Environment Detected %c\n\n%cOnly UI previews are available in the browser. For full functionality, please run the application in desktop mode.\nMore information at: https://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;');
|
|
27
|
+
return null;
|
|
28
|
+
})();
|
|
29
|
+
export function invoke(msg) {
|
|
30
|
+
_invoke === null || _invoke === void 0 ? void 0 : _invoke(msg);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves the system dark mode status.
|
|
34
|
+
*
|
|
35
|
+
* @returns A promise that resolves to a boolean value indicating if the system is in dark mode.
|
|
36
|
+
*/
|
|
37
|
+
export function IsDarkMode() {
|
|
38
|
+
return call(SystemIsDarkMode);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Fetches the capabilities of the application from the server.
|
|
42
|
+
*
|
|
43
|
+
* @returns A promise that resolves to an object containing the capabilities.
|
|
44
|
+
*/
|
|
45
|
+
export async function Capabilities() {
|
|
46
|
+
let response = await fetch("/wails/capabilities");
|
|
47
|
+
if (response.ok) {
|
|
48
|
+
return response.json();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
throw new Error("could not fetch capabilities: " + response.statusText);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves environment details.
|
|
56
|
+
*
|
|
57
|
+
* @returns A promise that resolves to an object containing OS and system architecture.
|
|
58
|
+
*/
|
|
59
|
+
export function Environment() {
|
|
60
|
+
return call(SystemEnvironment);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Checks if the current operating system is Windows.
|
|
64
|
+
*
|
|
65
|
+
* @return True if the operating system is Windows, otherwise false.
|
|
66
|
+
*/
|
|
67
|
+
export function IsWindows() {
|
|
68
|
+
return window._wails.environment.OS === "windows";
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Checks if the current operating system is Linux.
|
|
72
|
+
*
|
|
73
|
+
* @returns Returns true if the current operating system is Linux, false otherwise.
|
|
74
|
+
*/
|
|
75
|
+
export function IsLinux() {
|
|
76
|
+
return window._wails.environment.OS === "linux";
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Checks if the current environment is a macOS operating system.
|
|
80
|
+
*
|
|
81
|
+
* @returns True if the environment is macOS, false otherwise.
|
|
82
|
+
*/
|
|
83
|
+
export function IsMac() {
|
|
84
|
+
return window._wails.environment.OS === "darwin";
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Checks if the current environment architecture is AMD64.
|
|
88
|
+
*
|
|
89
|
+
* @returns True if the current environment architecture is AMD64, false otherwise.
|
|
90
|
+
*/
|
|
91
|
+
export function IsAMD64() {
|
|
92
|
+
return window._wails.environment.Arch === "amd64";
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Checks if the current architecture is ARM.
|
|
96
|
+
*
|
|
97
|
+
* @returns True if the current architecture is ARM, false otherwise.
|
|
98
|
+
*/
|
|
99
|
+
export function IsARM() {
|
|
100
|
+
return window._wails.environment.Arch === "arm";
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Checks if the current environment is ARM64 architecture.
|
|
104
|
+
*
|
|
105
|
+
* @returns Returns true if the environment is ARM64 architecture, otherwise returns false.
|
|
106
|
+
*/
|
|
107
|
+
export function IsARM64() {
|
|
108
|
+
return window._wails.environment.Arch === "arm64";
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Reports whether the app is being run in debug mode.
|
|
112
|
+
*
|
|
113
|
+
* @returns True if the app is being run in debug mode.
|
|
114
|
+
*/
|
|
115
|
+
export function IsDebug() {
|
|
116
|
+
return Boolean(window._wails.environment.Debug);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Handles file drops originating from platform-specific code (e.g., macOS native drag-and-drop).
|
|
120
|
+
* Gathers information about the drop target element and sends it back to the Go backend.
|
|
121
|
+
*
|
|
122
|
+
* @param filenames - An array of file paths (strings) that were dropped.
|
|
123
|
+
* @param x - The x-coordinate of the drop event.
|
|
124
|
+
* @param y - The y-coordinate of the drop event.
|
|
125
|
+
*/
|
|
126
|
+
export function HandlePlatformFileDrop(filenames, x, y) {
|
|
127
|
+
const element = document.elementFromPoint(x, y);
|
|
128
|
+
const elementId = element ? element.id : '';
|
|
129
|
+
const classList = element ? Array.from(element.classList) : [];
|
|
130
|
+
const payload = {
|
|
131
|
+
filenames,
|
|
132
|
+
x,
|
|
133
|
+
y,
|
|
134
|
+
elementId,
|
|
135
|
+
classList,
|
|
136
|
+
};
|
|
137
|
+
call(ApplicationFilesDroppedWithContext, payload)
|
|
138
|
+
.then(() => {
|
|
139
|
+
// Optional: Log success or handle if needed
|
|
140
|
+
console.log("Platform file drop processed and sent to Go.");
|
|
141
|
+
})
|
|
142
|
+
.catch(err => {
|
|
143
|
+
// Optional: Log error
|
|
144
|
+
console.error("Error sending platform file drop to Go:", err);
|
|
145
|
+
});
|
|
146
|
+
}
|
package/{src → dist}/utils.js
RENAMED
|
@@ -7,42 +7,52 @@
|
|
|
7
7
|
The electron alternative for Go
|
|
8
8
|
(c) Lea Anthony 2019-present
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
10
|
/**
|
|
12
11
|
* Logs a message to the console with custom formatting.
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
12
|
+
*
|
|
13
|
+
* @param message - The message to be logged.
|
|
15
14
|
*/
|
|
16
15
|
export function debugLog(message) {
|
|
17
16
|
// eslint-disable-next-line
|
|
18
|
-
console.log(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
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');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Checks whether the webview supports the {@link MouseEvent#buttons} property.
|
|
21
|
+
* Looking at you macOS High Sierra!
|
|
22
|
+
*/
|
|
23
|
+
export function canTrackButtons() {
|
|
24
|
+
return (new MouseEvent('mousedown')).buttons === 0;
|
|
23
25
|
}
|
|
24
|
-
|
|
25
26
|
/**
|
|
26
27
|
* Checks whether the browser supports removing listeners by triggering an AbortSignal
|
|
27
|
-
* (see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#signal)
|
|
28
|
-
*
|
|
29
|
-
* @return {boolean}
|
|
28
|
+
* (see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#signal).
|
|
30
29
|
*/
|
|
31
30
|
export function canAbortListeners() {
|
|
32
31
|
if (!EventTarget || !AbortSignal || !AbortController)
|
|
33
32
|
return false;
|
|
34
|
-
|
|
35
33
|
let result = true;
|
|
36
|
-
|
|
37
34
|
const target = new EventTarget();
|
|
38
35
|
const controller = new AbortController();
|
|
39
36
|
target.addEventListener('test', () => { result = false; }, { signal: controller.signal });
|
|
40
37
|
controller.abort();
|
|
41
38
|
target.dispatchEvent(new CustomEvent('test'));
|
|
42
|
-
|
|
43
39
|
return result;
|
|
44
40
|
}
|
|
45
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Resolves the closest HTMLElement ancestor of an event's target.
|
|
43
|
+
*/
|
|
44
|
+
export function eventTarget(event) {
|
|
45
|
+
var _a;
|
|
46
|
+
if (event.target instanceof HTMLElement) {
|
|
47
|
+
return event.target;
|
|
48
|
+
}
|
|
49
|
+
else if (!(event.target instanceof HTMLElement) && event.target instanceof Node) {
|
|
50
|
+
return (_a = event.target.parentElement) !== null && _a !== void 0 ? _a : document.body;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return document.body;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
46
56
|
/***
|
|
47
57
|
This technique for proper load detection is taken from HTMX:
|
|
48
58
|
|
|
@@ -73,14 +83,13 @@ export function canAbortListeners() {
|
|
|
73
83
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
74
84
|
|
|
75
85
|
***/
|
|
76
|
-
|
|
77
86
|
let isReady = false;
|
|
78
|
-
document.addEventListener('DOMContentLoaded', () => isReady = true);
|
|
79
|
-
|
|
87
|
+
document.addEventListener('DOMContentLoaded', () => { isReady = true; });
|
|
80
88
|
export function whenReady(callback) {
|
|
81
89
|
if (isReady || document.readyState === 'complete') {
|
|
82
90
|
callback();
|
|
83
|
-
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
84
93
|
document.addEventListener('DOMContentLoaded', callback);
|
|
85
94
|
}
|
|
86
95
|
}
|