@wailsio/runtime 3.0.0-alpha.7 → 3.0.0-alpha.72

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.
Files changed (59) hide show
  1. package/{application.js → dist/application.js} +32 -46
  2. package/dist/browser.js +20 -0
  3. package/dist/callable.js +144 -0
  4. package/dist/calls.js +194 -0
  5. package/dist/cancellable.js +792 -0
  6. package/dist/clipboard.js +30 -0
  7. package/dist/contextmenu.js +80 -0
  8. package/dist/create.js +94 -0
  9. package/dist/dialogs.js +134 -0
  10. package/dist/drag.js +222 -0
  11. package/dist/event_types.js +232 -0
  12. package/dist/events.js +114 -0
  13. package/dist/flags.js +23 -0
  14. package/dist/index.js +42 -0
  15. package/dist/listener.js +44 -0
  16. package/dist/nanoid.js +38 -0
  17. package/dist/runtime.js +63 -0
  18. package/{screens.js → dist/screens.js} +38 -45
  19. package/dist/system.js +146 -0
  20. package/dist/utils.js +95 -0
  21. package/dist/window.js +570 -0
  22. package/dist/wml.js +179 -0
  23. package/package.json +62 -18
  24. package/types/application.d.ts +12 -0
  25. package/types/browser.d.ts +6 -0
  26. package/types/callable.d.ts +3 -0
  27. package/types/calls.d.ts +63 -0
  28. package/types/cancellable.d.ts +434 -0
  29. package/types/clipboard.d.ts +13 -0
  30. package/types/contextmenu.d.ts +1 -0
  31. package/types/create.d.ts +31 -0
  32. package/types/dialogs.d.ts +140 -0
  33. package/types/drag.d.ts +1 -0
  34. package/types/event_types.d.ts +221 -0
  35. package/types/events.d.ts +67 -0
  36. package/types/flags.d.ts +7 -0
  37. package/types/index.d.ts +16 -0
  38. package/types/listener.d.ts +9 -0
  39. package/types/nanoid.d.ts +1 -0
  40. package/types/runtime.d.ts +22 -0
  41. package/types/screens.d.ts +60 -0
  42. package/types/system.d.ts +92 -0
  43. package/types/utils.d.ts +21 -0
  44. package/types/window.d.ts +306 -0
  45. package/types/wml.d.ts +8 -0
  46. package/browser.js +0 -24
  47. package/calls.js +0 -123
  48. package/clipboard.js +0 -35
  49. package/contextmenu.js +0 -98
  50. package/dialogs.js +0 -138
  51. package/drag.js +0 -125
  52. package/events.js +0 -134
  53. package/flags.js +0 -63
  54. package/index.js +0 -56
  55. package/runtime.js +0 -122
  56. package/system.js +0 -122
  57. package/types.d.ts +0 -135
  58. package/window.js +0 -122
  59. package/wml.js +0 -151
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/dist/utils.js ADDED
@@ -0,0 +1,95 @@
1
+ /*
2
+ _ __ _ __
3
+ | | / /___ _(_) /____
4
+ | | /| / / __ `/ / / ___/
5
+ | |/ |/ / /_/ / / (__ )
6
+ |__/|__/\__,_/_/_/____/
7
+ The electron alternative for Go
8
+ (c) Lea Anthony 2019-present
9
+ */
10
+ /**
11
+ * Logs a message to the console with custom formatting.
12
+ *
13
+ * @param message - The message to be logged.
14
+ */
15
+ export function debugLog(message) {
16
+ // eslint-disable-next-line
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;
25
+ }
26
+ /**
27
+ * Checks whether the browser supports removing listeners by triggering an AbortSignal
28
+ * (see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#signal).
29
+ */
30
+ export function canAbortListeners() {
31
+ if (!EventTarget || !AbortSignal || !AbortController)
32
+ return false;
33
+ let result = true;
34
+ const target = new EventTarget();
35
+ const controller = new AbortController();
36
+ target.addEventListener('test', () => { result = false; }, { signal: controller.signal });
37
+ controller.abort();
38
+ target.dispatchEvent(new CustomEvent('test'));
39
+ return result;
40
+ }
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
+ }
56
+ /***
57
+ This technique for proper load detection is taken from HTMX:
58
+
59
+ BSD 2-Clause License
60
+
61
+ Copyright (c) 2020, Big Sky Software
62
+ All rights reserved.
63
+
64
+ Redistribution and use in source and binary forms, with or without
65
+ modification, are permitted provided that the following conditions are met:
66
+
67
+ 1. Redistributions of source code must retain the above copyright notice, this
68
+ list of conditions and the following disclaimer.
69
+
70
+ 2. Redistributions in binary form must reproduce the above copyright notice,
71
+ this list of conditions and the following disclaimer in the documentation
72
+ and/or other materials provided with the distribution.
73
+
74
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
75
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
76
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
77
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
78
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
79
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
80
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
81
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
82
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
83
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84
+
85
+ ***/
86
+ let isReady = false;
87
+ document.addEventListener('DOMContentLoaded', () => { isReady = true; });
88
+ export function whenReady(callback) {
89
+ if (isReady || document.readyState === 'complete') {
90
+ callback();
91
+ }
92
+ else {
93
+ document.addEventListener('DOMContentLoaded', callback);
94
+ }
95
+ }