@wailsio/runtime 3.0.0-alpha.6 → 3.0.0-alpha.61
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/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +22 -0
- package/docs/assets/icons.js +15 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +59 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1415 -0
- package/docs/classes/Call.RuntimeError.html +11 -0
- package/docs/classes/Events.WailsEvent.html +4 -0
- package/docs/functions/Application.Hide.html +2 -0
- package/docs/functions/Application.Quit.html +2 -0
- package/docs/functions/Application.Show.html +2 -0
- package/docs/functions/Browser.OpenURL.html +3 -0
- package/docs/functions/Call.ByID.html +8 -0
- package/docs/functions/Call.ByName.html +6 -0
- package/docs/functions/Call.Call.html +11 -0
- package/docs/functions/Clipboard.SetText.html +6 -0
- package/docs/functions/Clipboard.Text.html +3 -0
- package/docs/functions/Create.Any.html +2 -0
- package/docs/functions/Create.Array.html +4 -0
- package/docs/functions/Create.ByteSlice.html +3 -0
- package/docs/functions/Create.Map.html +4 -0
- package/docs/functions/Create.Nullable.html +3 -0
- package/docs/functions/Create.Struct.html +3 -0
- package/docs/functions/Dialogs.Error.html +5 -0
- package/docs/functions/Dialogs.Info.html +5 -0
- package/docs/functions/Dialogs.OpenFile.html +3 -0
- package/docs/functions/Dialogs.Question.html +5 -0
- package/docs/functions/Dialogs.SaveFile.html +3 -0
- package/docs/functions/Dialogs.Warning.html +5 -0
- package/docs/functions/Events.Emit.html +6 -0
- package/docs/functions/Events.Off.html +4 -0
- package/docs/functions/Events.OffAll.html +3 -0
- package/docs/functions/Events.On.html +7 -0
- package/docs/functions/Events.OnMultiple.html +8 -0
- package/docs/functions/Events.Once.html +7 -0
- package/docs/functions/Events.setup.html +1 -0
- package/docs/functions/Flags.GetFlag.html +6 -0
- package/docs/functions/Screens.GetAll.html +3 -0
- package/docs/functions/Screens.GetCurrent.html +3 -0
- package/docs/functions/Screens.GetPrimary.html +3 -0
- package/docs/functions/System.Capabilities.html +4 -0
- package/docs/functions/System.Environment.html +5 -0
- package/docs/functions/System.IsAMD64.html +3 -0
- package/docs/functions/System.IsARM.html +3 -0
- package/docs/functions/System.IsARM64.html +5 -0
- package/docs/functions/System.IsDarkMode.html +5 -0
- package/docs/functions/System.IsDebug.html +1 -0
- package/docs/functions/System.IsLinux.html +3 -0
- package/docs/functions/System.IsMac.html +3 -0
- package/docs/functions/System.IsWindows.html +3 -0
- package/docs/functions/System.invoke.html +1 -0
- package/docs/functions/WML.Enable.html +2 -0
- package/docs/functions/WML.Reload.html +2 -0
- package/docs/functions/init.html +1 -0
- package/docs/index.html +5 -0
- package/docs/interfaces/Call.CallOptions.html +7 -0
- package/docs/interfaces/Dialogs.Button.html +7 -0
- package/docs/interfaces/Dialogs.FileFilter.html +5 -0
- package/docs/interfaces/Dialogs.MessageDialogOptions.html +9 -0
- package/docs/interfaces/Dialogs.OpenFileDialogOptions.html +33 -0
- package/docs/interfaces/Dialogs.SaveFileDialogOptions.html +35 -0
- package/docs/interfaces/Screens.Rect.html +9 -0
- package/docs/interfaces/Screens.Screen.html +25 -0
- package/docs/interfaces/Screens.Size.html +5 -0
- package/docs/interfaces/System.EnvironmentInfo.html +11 -0
- package/docs/interfaces/System.OSInfo.html +9 -0
- package/docs/modules/Application.html +4 -0
- package/docs/modules/Browser.html +2 -0
- package/docs/modules/Call.html +6 -0
- package/docs/modules/Clipboard.html +3 -0
- package/docs/modules/Create.html +7 -0
- package/docs/modules/Dialogs.html +12 -0
- package/docs/modules/Events.html +10 -0
- package/docs/modules/Flags.html +2 -0
- package/docs/modules/Screens.html +7 -0
- package/docs/modules/System.html +14 -0
- package/docs/modules/WML.html +3 -0
- package/docs/modules.html +14 -0
- package/docs/variables/Events.Types.html +1 -0
- package/docs/variables/Window.html +2 -0
- package/package.json +38 -17
- package/{application.js → src/application.js} +46 -46
- package/{browser.js → src/browser.js} +24 -24
- package/src/calls.js +221 -0
- package/{clipboard.js → src/clipboard.js} +35 -35
- package/{contextmenu.js → src/contextmenu.js} +97 -98
- package/src/create.js +125 -0
- package/src/dialogs.js +200 -0
- package/{drag.js → src/drag.js} +119 -125
- package/src/event_types.js +219 -0
- package/{events.js → src/events.js} +140 -134
- package/src/flags.js +25 -0
- package/src/index.js +60 -0
- package/src/nanoid.js +42 -0
- package/src/runtime.js +92 -0
- package/src/screens.js +71 -0
- package/{system.js → src/system.js} +143 -122
- package/src/utils.js +86 -0
- package/src/window.js +638 -0
- package/src/wml.js +250 -0
- package/tsconfig.json +20 -0
- package/types/application.d.ts +19 -0
- package/types/browser.d.ts +6 -0
- package/types/calls.d.ts +69 -0
- package/types/clipboard.d.ts +12 -0
- package/types/create.d.ts +52 -0
- package/types/dialogs.d.ts +184 -0
- package/types/event_types.d.ts +219 -0
- package/types/events.d.ts +271 -0
- package/types/flags.d.ts +7 -0
- package/types/index.d.ts +14 -0
- package/types/nanoid.d.ts +1 -0
- package/types/runtime.d.ts +30 -0
- package/types/screens.d.ts +94 -0
- package/types/system.d.ts +112 -0
- package/types/utils.d.ts +14 -0
- package/types/window.d.ts +407 -0
- package/types/wml.d.ts +12 -0
- package/calls.js +0 -123
- package/dialogs.js +0 -138
- package/flags.js +0 -63
- package/index.js +0 -56
- package/runtime.js +0 -122
- package/screens.js +0 -45
- package/types.d.ts +0 -130
- package/window.js +0 -122
- package/wml.js +0 -149
|
@@ -1,122 +1,143 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ __ _ __
|
|
3
|
-
| | / /___ _(_) /____
|
|
4
|
-
| | /| / / __ `/ / / ___/
|
|
5
|
-
| |/ |/ / /_/ / / (__ )
|
|
6
|
-
|__/|__/\__,_/_/_/____/
|
|
7
|
-
The electron alternative for Go
|
|
8
|
-
(c) Lea Anthony 2019-present
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/* jshint esversion: 9 */
|
|
12
|
-
|
|
13
|
-
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
14
|
-
let call = newRuntimeCallerWithID(objectNames.System, '');
|
|
15
|
-
const systemIsDarkMode = 0;
|
|
16
|
-
const environment = 1;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @
|
|
42
|
-
*
|
|
43
|
-
* @
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* @
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
* @
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
*
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
1
|
+
/*
|
|
2
|
+
_ __ _ __
|
|
3
|
+
| | / /___ _(_) /____
|
|
4
|
+
| | /| / / __ `/ / / ___/
|
|
5
|
+
| |/ |/ / /_/ / / (__ )
|
|
6
|
+
|__/|__/\__,_/_/_/____/
|
|
7
|
+
The electron alternative for Go
|
|
8
|
+
(c) Lea Anthony 2019-present
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* jshint esversion: 9 */
|
|
12
|
+
|
|
13
|
+
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
14
|
+
let call = newRuntimeCallerWithID(objectNames.System, '');
|
|
15
|
+
const systemIsDarkMode = 0;
|
|
16
|
+
const environment = 1;
|
|
17
|
+
|
|
18
|
+
const _invoke = (() => {
|
|
19
|
+
try {
|
|
20
|
+
if(window?.chrome?.webview) {
|
|
21
|
+
return (msg) => window.chrome.webview.postMessage(msg);
|
|
22
|
+
}
|
|
23
|
+
if(window?.webkit?.messageHandlers?.external) {
|
|
24
|
+
return (msg) => window.webkit.messageHandlers.external.postMessage(msg);
|
|
25
|
+
}
|
|
26
|
+
} catch(e) {
|
|
27
|
+
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',
|
|
28
|
+
'background: #ffffff; color: #000000; font-weight: bold; padding: 4px 8px; border-radius: 4px; border: 2px solid #000000;',
|
|
29
|
+
'background: transparent;',
|
|
30
|
+
'color: #ffffff; font-style: italic; font-weight: bold;');
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
})();
|
|
34
|
+
|
|
35
|
+
export function invoke(msg) {
|
|
36
|
+
if (!_invoke) return;
|
|
37
|
+
return _invoke(msg);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @function
|
|
42
|
+
* Retrieves the system dark mode status.
|
|
43
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean value indicating if the system is in dark mode.
|
|
44
|
+
*/
|
|
45
|
+
export function IsDarkMode() {
|
|
46
|
+
return call(systemIsDarkMode);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Fetches the capabilities of the application from the server.
|
|
51
|
+
*
|
|
52
|
+
* @async
|
|
53
|
+
* @function Capabilities
|
|
54
|
+
* @returns {Promise<Object>} A promise that resolves to an object containing the capabilities.
|
|
55
|
+
*/
|
|
56
|
+
export function Capabilities() {
|
|
57
|
+
let response = fetch("/wails/capabilities");
|
|
58
|
+
return response.json();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @typedef {Object} OSInfo
|
|
63
|
+
* @property {string} Branding - The branding of the OS.
|
|
64
|
+
* @property {string} ID - The ID of the OS.
|
|
65
|
+
* @property {string} Name - The name of the OS.
|
|
66
|
+
* @property {string} Version - The version of the OS.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @typedef {Object} EnvironmentInfo
|
|
71
|
+
* @property {string} Arch - The architecture of the system.
|
|
72
|
+
* @property {boolean} Debug - True if the application is running in debug mode, otherwise false.
|
|
73
|
+
* @property {string} OS - The operating system in use.
|
|
74
|
+
* @property {OSInfo} OSInfo - Details of the operating system.
|
|
75
|
+
* @property {Object} PlatformInfo - Additional platform information.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @function
|
|
80
|
+
* Retrieves environment details.
|
|
81
|
+
* @returns {Promise<EnvironmentInfo>} - A promise that resolves to an object containing OS and system architecture.
|
|
82
|
+
*/
|
|
83
|
+
export function Environment() {
|
|
84
|
+
return call(environment);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Checks if the current operating system is Windows.
|
|
89
|
+
*
|
|
90
|
+
* @return {boolean} True if the operating system is Windows, otherwise false.
|
|
91
|
+
*/
|
|
92
|
+
export function IsWindows() {
|
|
93
|
+
return window._wails.environment.OS === "windows";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Checks if the current operating system is Linux.
|
|
98
|
+
*
|
|
99
|
+
* @returns {boolean} Returns true if the current operating system is Linux, false otherwise.
|
|
100
|
+
*/
|
|
101
|
+
export function IsLinux() {
|
|
102
|
+
return window._wails.environment.OS === "linux";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Checks if the current environment is a macOS operating system.
|
|
107
|
+
*
|
|
108
|
+
* @returns {boolean} True if the environment is macOS, false otherwise.
|
|
109
|
+
*/
|
|
110
|
+
export function IsMac() {
|
|
111
|
+
return window._wails.environment.OS === "darwin";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Checks if the current environment architecture is AMD64.
|
|
116
|
+
* @returns {boolean} True if the current environment architecture is AMD64, false otherwise.
|
|
117
|
+
*/
|
|
118
|
+
export function IsAMD64() {
|
|
119
|
+
return window._wails.environment.Arch === "amd64";
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Checks if the current architecture is ARM.
|
|
124
|
+
*
|
|
125
|
+
* @returns {boolean} True if the current architecture is ARM, false otherwise.
|
|
126
|
+
*/
|
|
127
|
+
export function IsARM() {
|
|
128
|
+
return window._wails.environment.Arch === "arm";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Checks if the current environment is ARM64 architecture.
|
|
133
|
+
*
|
|
134
|
+
* @returns {boolean} - Returns true if the environment is ARM64 architecture, otherwise returns false.
|
|
135
|
+
*/
|
|
136
|
+
export function IsARM64() {
|
|
137
|
+
return window._wails.environment.Arch === "arm64";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function IsDebug() {
|
|
141
|
+
return window._wails.environment.Debug === true;
|
|
142
|
+
}
|
|
143
|
+
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
_ __ _ __
|
|
3
|
+
| | / /___ _(_) /____
|
|
4
|
+
| | /| / / __ `/ / / ___/
|
|
5
|
+
| |/ |/ / /_/ / / (__ )
|
|
6
|
+
|__/|__/\__,_/_/_/____/
|
|
7
|
+
The electron alternative for Go
|
|
8
|
+
(c) Lea Anthony 2019-present
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Logs a message to the console with custom formatting.
|
|
13
|
+
* @param {string} message - The message to be logged.
|
|
14
|
+
* @return {void}
|
|
15
|
+
*/
|
|
16
|
+
export function debugLog(message) {
|
|
17
|
+
// eslint-disable-next-line
|
|
18
|
+
console.log(
|
|
19
|
+
'%c wails3 %c ' + message + ' ',
|
|
20
|
+
'background: #aa0000; color: #fff; border-radius: 3px 0px 0px 3px; padding: 1px; font-size: 0.7rem',
|
|
21
|
+
'background: #009900; color: #fff; border-radius: 0px 3px 3px 0px; padding: 1px; font-size: 0.7rem'
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 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}
|
|
30
|
+
*/
|
|
31
|
+
export function canAbortListeners() {
|
|
32
|
+
if (!EventTarget || !AbortSignal || !AbortController)
|
|
33
|
+
return false;
|
|
34
|
+
|
|
35
|
+
let result = true;
|
|
36
|
+
|
|
37
|
+
const target = new EventTarget();
|
|
38
|
+
const controller = new AbortController();
|
|
39
|
+
target.addEventListener('test', () => { result = false; }, { signal: controller.signal });
|
|
40
|
+
controller.abort();
|
|
41
|
+
target.dispatchEvent(new CustomEvent('test'));
|
|
42
|
+
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/***
|
|
47
|
+
This technique for proper load detection is taken from HTMX:
|
|
48
|
+
|
|
49
|
+
BSD 2-Clause License
|
|
50
|
+
|
|
51
|
+
Copyright (c) 2020, Big Sky Software
|
|
52
|
+
All rights reserved.
|
|
53
|
+
|
|
54
|
+
Redistribution and use in source and binary forms, with or without
|
|
55
|
+
modification, are permitted provided that the following conditions are met:
|
|
56
|
+
|
|
57
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
58
|
+
list of conditions and the following disclaimer.
|
|
59
|
+
|
|
60
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
61
|
+
this list of conditions and the following disclaimer in the documentation
|
|
62
|
+
and/or other materials provided with the distribution.
|
|
63
|
+
|
|
64
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
65
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
66
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
67
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
68
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
69
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
70
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
71
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
72
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
73
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
74
|
+
|
|
75
|
+
***/
|
|
76
|
+
|
|
77
|
+
let isReady = false;
|
|
78
|
+
document.addEventListener('DOMContentLoaded', () => isReady = true);
|
|
79
|
+
|
|
80
|
+
export function whenReady(callback) {
|
|
81
|
+
if (isReady || document.readyState === 'complete') {
|
|
82
|
+
callback();
|
|
83
|
+
} else {
|
|
84
|
+
document.addEventListener('DOMContentLoaded', callback);
|
|
85
|
+
}
|
|
86
|
+
}
|