@wailsio/runtime 3.0.0-alpha.4 → 3.0.0-alpha.42
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/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 +7 -0
- package/docs/functions/Call.ByName.html +6 -0
- package/docs/functions/Call.Call.html +6 -0
- package/docs/functions/Call.Plugin.html +8 -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/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 +5 -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 +174 -0
- package/{clipboard.js → src/clipboard.js} +35 -35
- package/{contextmenu.js → src/contextmenu.js} +97 -96
- 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 +217 -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/{runtime.js → src/runtime.js} +123 -122
- package/src/screens.js +71 -0
- package/{system.js → src/system.js} +143 -118
- 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 +33 -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 +217 -0
- package/types/events.d.ts +269 -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/screens.js +0 -45
- package/types.d.ts +0 -130
- package/window.js +0 -122
- package/wml.js +0 -148
|
@@ -1,122 +1,123 @@
|
|
|
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
|
-
import { nanoid } from 'nanoid
|
|
13
|
-
|
|
14
|
-
const runtimeURL = window.location.origin + "/wails/runtime";
|
|
15
|
-
|
|
16
|
-
// Object Names
|
|
17
|
-
export const objectNames = {
|
|
18
|
-
Call: 0,
|
|
19
|
-
Clipboard: 1,
|
|
20
|
-
Application: 2,
|
|
21
|
-
Events: 3,
|
|
22
|
-
ContextMenu: 4,
|
|
23
|
-
Dialog: 5,
|
|
24
|
-
Window: 6,
|
|
25
|
-
Screens: 7,
|
|
26
|
-
System: 8,
|
|
27
|
-
Browser: 9,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @param {
|
|
36
|
-
* @
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @param {
|
|
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
|
-
url
|
|
95
|
-
url.searchParams.append("
|
|
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
|
+
import { nanoid } from './nanoid.js';
|
|
13
|
+
|
|
14
|
+
const runtimeURL = window.location.origin + "/wails/runtime";
|
|
15
|
+
|
|
16
|
+
// Object Names
|
|
17
|
+
export const objectNames = {
|
|
18
|
+
Call: 0,
|
|
19
|
+
Clipboard: 1,
|
|
20
|
+
Application: 2,
|
|
21
|
+
Events: 3,
|
|
22
|
+
ContextMenu: 4,
|
|
23
|
+
Dialog: 5,
|
|
24
|
+
Window: 6,
|
|
25
|
+
Screens: 7,
|
|
26
|
+
System: 8,
|
|
27
|
+
Browser: 9,
|
|
28
|
+
CancelCall: 10,
|
|
29
|
+
}
|
|
30
|
+
export let clientId = nanoid();
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates a runtime caller function that invokes a specified method on a given object within a specified window context.
|
|
34
|
+
*
|
|
35
|
+
* @param {Object} object - The object on which the method is to be invoked.
|
|
36
|
+
* @param {string} windowName - The name of the window context in which the method should be called.
|
|
37
|
+
* @returns {Function} A runtime caller function that takes the method name and optionally arguments and invokes the method within the specified window context.
|
|
38
|
+
*/
|
|
39
|
+
export function newRuntimeCaller(object, windowName) {
|
|
40
|
+
return function (method, args=null) {
|
|
41
|
+
return runtimeCall(object + "." + method, windowName, args);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new runtime caller with specified ID.
|
|
47
|
+
*
|
|
48
|
+
* @param {object} object - The object to invoke the method on.
|
|
49
|
+
* @param {string} windowName - The name of the window.
|
|
50
|
+
* @return {Function} - The new runtime caller function.
|
|
51
|
+
*/
|
|
52
|
+
export function newRuntimeCallerWithID(object, windowName) {
|
|
53
|
+
return function (method, args=null) {
|
|
54
|
+
return runtimeCallWithID(object, method, windowName, args);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
function runtimeCall(method, windowName, args) {
|
|
60
|
+
let url = new URL(runtimeURL);
|
|
61
|
+
if( method ) {
|
|
62
|
+
url.searchParams.append("method", method);
|
|
63
|
+
}
|
|
64
|
+
let fetchOptions = {
|
|
65
|
+
headers: {},
|
|
66
|
+
};
|
|
67
|
+
if (windowName) {
|
|
68
|
+
fetchOptions.headers["x-wails-window-name"] = windowName;
|
|
69
|
+
}
|
|
70
|
+
if (args) {
|
|
71
|
+
url.searchParams.append("args", JSON.stringify(args));
|
|
72
|
+
}
|
|
73
|
+
fetchOptions.headers["x-wails-client-id"] = clientId;
|
|
74
|
+
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
fetch(url, fetchOptions)
|
|
77
|
+
.then(response => {
|
|
78
|
+
if (response.ok) {
|
|
79
|
+
// check content type
|
|
80
|
+
if (response.headers.get("Content-Type") && response.headers.get("Content-Type").indexOf("application/json") !== -1) {
|
|
81
|
+
return response.json();
|
|
82
|
+
} else {
|
|
83
|
+
return response.text();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
reject(Error(response.statusText));
|
|
87
|
+
})
|
|
88
|
+
.then(data => resolve(data))
|
|
89
|
+
.catch(error => reject(error));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function runtimeCallWithID(objectID, method, windowName, args) {
|
|
94
|
+
let url = new URL(runtimeURL);
|
|
95
|
+
url.searchParams.append("object", objectID);
|
|
96
|
+
url.searchParams.append("method", method);
|
|
97
|
+
let fetchOptions = {
|
|
98
|
+
headers: {},
|
|
99
|
+
};
|
|
100
|
+
if (windowName) {
|
|
101
|
+
fetchOptions.headers["x-wails-window-name"] = windowName;
|
|
102
|
+
}
|
|
103
|
+
if (args) {
|
|
104
|
+
url.searchParams.append("args", JSON.stringify(args));
|
|
105
|
+
}
|
|
106
|
+
fetchOptions.headers["x-wails-client-id"] = clientId;
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
fetch(url, fetchOptions)
|
|
109
|
+
.then(response => {
|
|
110
|
+
if (response.ok) {
|
|
111
|
+
// check content type
|
|
112
|
+
if (response.headers.get("Content-Type") && response.headers.get("Content-Type").indexOf("application/json") !== -1) {
|
|
113
|
+
return response.json();
|
|
114
|
+
} else {
|
|
115
|
+
return response.text();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
reject(Error(response.statusText));
|
|
119
|
+
})
|
|
120
|
+
.then(data => resolve(data))
|
|
121
|
+
.catch(error => reject(error));
|
|
122
|
+
});
|
|
123
|
+
}
|
package/src/screens.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* @typedef {Object} Size
|
|
15
|
+
* @property {number} Width - The width.
|
|
16
|
+
* @property {number} Height - The height.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {Object} Rect
|
|
21
|
+
* @property {number} X - The X coordinate of the origin.
|
|
22
|
+
* @property {number} Y - The Y coordinate of the origin.
|
|
23
|
+
* @property {number} Width - The width of the rectangle.
|
|
24
|
+
* @property {number} Height - The height of the rectangle.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {Object} Screen
|
|
29
|
+
* @property {string} ID - Unique identifier for the screen.
|
|
30
|
+
* @property {string} Name - Human readable name of the screen.
|
|
31
|
+
* @property {number} ScaleFactor - The scale factor of the screen (DPI/96). 1 = standard DPI, 2 = HiDPI (Retina), etc.
|
|
32
|
+
* @property {number} X - The X coordinate of the screen.
|
|
33
|
+
* @property {number} Y - The Y coordinate of the screen.
|
|
34
|
+
* @property {Size} Size - Contains the width and height of the screen.
|
|
35
|
+
* @property {Rect} Bounds - Contains the bounds of the screen in terms of X, Y, Width, and Height.
|
|
36
|
+
* @property {Rect} PhysicalBounds - Contains the physical bounds of the screen in terms of X, Y, Width, and Height (before scaling).
|
|
37
|
+
* @property {Rect} WorkArea - Contains the area of the screen that is actually usable (excluding taskbar and other system UI).
|
|
38
|
+
* @property {Rect} PhysicalWorkArea - Contains the physical WorkArea of the screen (before scaling).
|
|
39
|
+
* @property {boolean} IsPrimary - True if this is the primary monitor selected by the user in the operating system.
|
|
40
|
+
* @property {number} Rotation - The rotation of the screen.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
import { newRuntimeCallerWithID, objectNames } from "./runtime";
|
|
44
|
+
const call = newRuntimeCallerWithID(objectNames.Screens, "");
|
|
45
|
+
|
|
46
|
+
const getAll = 0;
|
|
47
|
+
const getPrimary = 1;
|
|
48
|
+
const getCurrent = 2;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets all screens.
|
|
52
|
+
* @returns {Promise<Screen[]>} A promise that resolves to an array of Screen objects.
|
|
53
|
+
*/
|
|
54
|
+
export function GetAll() {
|
|
55
|
+
return call(getAll);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Gets the primary screen.
|
|
59
|
+
* @returns {Promise<Screen>} A promise that resolves to the primary screen.
|
|
60
|
+
*/
|
|
61
|
+
export function GetPrimary() {
|
|
62
|
+
return call(getPrimary);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets the current active screen.
|
|
66
|
+
*
|
|
67
|
+
* @returns {Promise<Screen>} A promise that resolves with the current active screen.
|
|
68
|
+
*/
|
|
69
|
+
export function GetCurrent() {
|
|
70
|
+
return call(getCurrent);
|
|
71
|
+
}
|
|
@@ -1,118 +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
|
-
|
|
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
|
+
|