@wailsio/runtime 3.0.0-alpha.9 → 3.0.0-alpha.94
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/dist/android.js +39 -0
- package/{src → dist}/application.js +32 -46
- package/dist/browser.js +20 -0
- package/dist/callable.js +144 -0
- package/dist/calls.js +114 -0
- package/dist/cancellable.js +792 -0
- package/dist/clipboard.js +30 -0
- package/dist/contextmenu.js +83 -0
- package/dist/create.js +99 -0
- package/dist/dialogs.js +69 -0
- package/dist/drag.js +268 -0
- package/dist/environment.js +17 -0
- package/dist/event_types.js +292 -0
- package/dist/events.js +119 -0
- package/dist/flags.js +23 -0
- package/dist/index.js +88 -0
- package/dist/ios.js +28 -0
- package/dist/listener.js +44 -0
- package/dist/nanoid.js +38 -0
- package/dist/plugins/vite.js +64 -0
- package/dist/runtime.js +198 -0
- package/dist/screens.js +58 -0
- package/dist/system.js +158 -0
- package/dist/updater.js +74 -0
- package/dist/utils.js +98 -0
- package/dist/window.js +734 -0
- package/dist/wml.js +179 -0
- package/package.json +71 -26
- package/types/android.d.ts +21 -0
- 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 +52 -24
- package/types/cancellable.d.ts +433 -0
- package/types/clipboard.d.ts +6 -5
- package/types/contextmenu.d.ts +1 -1
- package/types/create.d.ts +36 -0
- package/types/dialogs.d.ts +132 -20
- package/types/drag.d.ts +1 -4
- package/types/environment.d.ts +8 -0
- package/types/event_types.d.ts +281 -0
- package/types/events.d.ts +70 -33
- package/types/flags.d.ts +3 -3
- package/types/index.d.ts +32 -48
- package/types/ios.d.ts +13 -0
- package/types/listener.d.ts +9 -0
- package/types/nanoid.d.ts +1 -0
- package/types/plugins/vite.d.ts +10 -0
- package/types/runtime.d.ts +61 -22
- package/types/screens.d.ts +64 -7
- package/types/system.d.ts +74 -39
- package/types/updater.d.ts +65 -0
- package/types/utils.d.ts +21 -0
- package/types/window.d.ts +327 -13
- package/types/wml.d.ts +5 -3
- package/src/browser.js +0 -24
- package/src/calls.js +0 -123
- package/src/clipboard.js +0 -35
- package/src/contextmenu.js +0 -98
- package/src/dialogs.js +0 -138
- package/src/drag.js +0 -125
- package/src/events.js +0 -134
- package/src/flags.js +0 -63
- package/src/index.d.ts +0 -136
- package/src/index.js +0 -58
- package/src/runtime.js +0 -122
- package/src/screens.js +0 -45
- package/src/system.js +0 -122
- package/src/window.js +0 -122
- package/src/wml.js +0 -151
- package/tsconfig.json +0 -20
package/src/flags.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
let flags = new Map();
|
|
14
|
-
|
|
15
|
-
function convertToMap(obj) {
|
|
16
|
-
const map = new Map();
|
|
17
|
-
|
|
18
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
19
|
-
if (typeof value === 'object' && value !== null) {
|
|
20
|
-
map.set(key, convertToMap(value)); // Recursively convert nested object
|
|
21
|
-
} else {
|
|
22
|
-
map.set(key, value);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return map;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
fetch("/wails/flags").then((response) => {
|
|
30
|
-
response.json().then((data) => {
|
|
31
|
-
flags = convertToMap(data);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function getValueFromMap(keyString) {
|
|
37
|
-
const keys = keyString.split('.');
|
|
38
|
-
let value = flags;
|
|
39
|
-
|
|
40
|
-
for (const key of keys) {
|
|
41
|
-
if (value instanceof Map) {
|
|
42
|
-
value = value.get(key);
|
|
43
|
-
} else {
|
|
44
|
-
value = value[key];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (value === undefined) {
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return value;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Retrieves the value associated with the specified key from the flag map.
|
|
57
|
-
*
|
|
58
|
-
* @param {string} keyString - The key to retrieve the value for.
|
|
59
|
-
* @return {*} - The value associated with the specified key.
|
|
60
|
-
*/
|
|
61
|
-
export function GetFlag(keyString) {
|
|
62
|
-
return getValueFromMap(keyString);
|
|
63
|
-
}
|
package/src/index.d.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
declare module '@wailsio/runtime';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Describes the properties of a Button object.
|
|
5
|
-
*/
|
|
6
|
-
export interface Button {
|
|
7
|
-
// Text that appears within the button.
|
|
8
|
-
Label?: string;
|
|
9
|
-
// True if the button should cancel an operation when clicked.
|
|
10
|
-
IsCancel?: boolean;
|
|
11
|
-
// True if the button should be the default action when the user presses enter.
|
|
12
|
-
IsDefault?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Describes the properties of a FileFilter object.
|
|
17
|
-
*/
|
|
18
|
-
export interface FileFilter {
|
|
19
|
-
// Display name for the filter, it could be "Text Files", "Images" etc.
|
|
20
|
-
DisplayName?: string;
|
|
21
|
-
// Pattern to match for the filter, e.g. "*.txt;*.md" for text markdown files.
|
|
22
|
-
Pattern?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Describes the properties of a Position object.
|
|
27
|
-
*/
|
|
28
|
-
export interface Position {
|
|
29
|
-
X: number;
|
|
30
|
-
Y: number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Describes the properties of a Size object.
|
|
35
|
-
* Extends the properties of Position.
|
|
36
|
-
*/
|
|
37
|
-
export type Size = Position;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Describes the properties of a Rect object.
|
|
41
|
-
* Extends the properties of Size.
|
|
42
|
-
*/
|
|
43
|
-
export type Rect = Size & Position;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Describes the possible rotations a Screen can have.
|
|
47
|
-
*/
|
|
48
|
-
export enum Rotation {
|
|
49
|
-
Zero = 0,
|
|
50
|
-
Ninety = 90,
|
|
51
|
-
OneEighty = 180,
|
|
52
|
-
TwoSeventy = 270
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Describes the properties of a Screen object.
|
|
57
|
-
*/
|
|
58
|
-
export interface Screen {
|
|
59
|
-
// Unique identifier for the screen.
|
|
60
|
-
Id: string;
|
|
61
|
-
// Human readable name of the screen.
|
|
62
|
-
Name: string;
|
|
63
|
-
// The resolution scale of the screen. 1 = standard resolution, 2 = high (Retina), etc.
|
|
64
|
-
Scale: number;
|
|
65
|
-
// Contains the X and Y coordinates of the screen's position.
|
|
66
|
-
Position: Position;
|
|
67
|
-
// Contains the width and height of the screen.
|
|
68
|
-
Size: Size;
|
|
69
|
-
// Contains the bounds of the screen in terms of X, Y, Width, and Height.
|
|
70
|
-
Bounds: Rect;
|
|
71
|
-
// Contains the area of the screen that is actually usable (excluding taskbar and other system UI).
|
|
72
|
-
WorkArea: Rect;
|
|
73
|
-
// True if this is the primary monitor selected by the user in the operating system.
|
|
74
|
-
IsPrimary: boolean;
|
|
75
|
-
// The rotation of the screen. Can be one of 0, 90, 180, 270 degrees.
|
|
76
|
-
Rotation: Rotation;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Describes the properties of a MessageDialogOptions object.
|
|
81
|
-
*/
|
|
82
|
-
export interface MessageDialogOptions {
|
|
83
|
-
// The title of the dialog window.
|
|
84
|
-
Title?: string;
|
|
85
|
-
// The main message to show in the dialog.
|
|
86
|
-
Message?: string;
|
|
87
|
-
// Array of button options to show in the dialog.
|
|
88
|
-
Buttons?: Button[];
|
|
89
|
-
// True if the dialog should appear detached from the main window (if applicable).
|
|
90
|
-
Detached?: boolean;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Describes the properties common to OpenFileDialogOptions and SaveFileDialogOptions objects.
|
|
95
|
-
*/
|
|
96
|
-
export interface DialogOptions {
|
|
97
|
-
CanChooseDirectories?: boolean;
|
|
98
|
-
CanChooseFiles?: boolean;
|
|
99
|
-
CanCreateDirectories?: boolean;
|
|
100
|
-
ShowHiddenFiles?: boolean;
|
|
101
|
-
ResolvesAliases?: boolean;
|
|
102
|
-
AllowsMultipleSelection?: boolean;
|
|
103
|
-
HideExtension?: boolean;
|
|
104
|
-
CanSelectHiddenExtension?: boolean;
|
|
105
|
-
TreatsFilePackagesAsDirectories?: boolean;
|
|
106
|
-
AllowsOtherFiletypes?: boolean;
|
|
107
|
-
Filters?: FileFilter[];
|
|
108
|
-
Title?: string;
|
|
109
|
-
Message?: string;
|
|
110
|
-
ButtonText?: string;
|
|
111
|
-
Directory?: string;
|
|
112
|
-
Detached?: boolean;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Describes properties unique to OpenFileDialogOptions.
|
|
117
|
-
*/
|
|
118
|
-
export type OpenFileDialogOptions = DialogOptions;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Describes properties unique to SaveFileDialogOptions.
|
|
122
|
-
*/
|
|
123
|
-
export type SaveFileDialogOptions = DialogOptions & {
|
|
124
|
-
// Default filename to use for the save dialog.
|
|
125
|
-
Filename?: string;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Describes the properties of a WailsEvent object.
|
|
130
|
-
*/
|
|
131
|
-
export interface WailsEvent {
|
|
132
|
-
// The name of the event.
|
|
133
|
-
Name: string;
|
|
134
|
-
// Any data associated with the event.
|
|
135
|
-
Data?: unknown;
|
|
136
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ __ _ __
|
|
3
|
-
| | / /___ _(_) /____
|
|
4
|
-
| | /| / / __ `/ / / ___/
|
|
5
|
-
| |/ |/ / /_/ / / (__ )
|
|
6
|
-
|__/|__/\__,_/_/_/____/
|
|
7
|
-
The electron alternative for Go
|
|
8
|
-
(c) Lea Anthony 2019-present
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {setupContextMenus} from "./contextmenu";
|
|
12
|
-
import {setupDrag} from "./drag";
|
|
13
|
-
import {reloadWML} from "./wml";
|
|
14
|
-
import {Emit, Off, OffAll, On, Once, OnMultiple, WailsEvent} from './events';
|
|
15
|
-
import {ByID, ByName, Plugin} from "./calls";
|
|
16
|
-
import {Error, Info, OpenFile, Question, SaveFile, Warning} from "./dialogs";
|
|
17
|
-
|
|
18
|
-
import * as Application from "./application";
|
|
19
|
-
import * as Browser from "./browser";
|
|
20
|
-
import * as Clipboard from "./clipboard";
|
|
21
|
-
import * as ContextMenu from "./contextmenu";
|
|
22
|
-
import * as Flags from "./flags";
|
|
23
|
-
import * as Runtime from "./runtime";
|
|
24
|
-
import * as Screens from "./screens";
|
|
25
|
-
import * as System from "./system";
|
|
26
|
-
import * as Window from "./window";
|
|
27
|
-
|
|
28
|
-
export { Application, Browser, Clipboard, ContextMenu, Flags, Runtime, Screens, System, Window };
|
|
29
|
-
|
|
30
|
-
export const Events = {
|
|
31
|
-
On,
|
|
32
|
-
Off,
|
|
33
|
-
OnMultiple,
|
|
34
|
-
WailsEvent,
|
|
35
|
-
OffAll,
|
|
36
|
-
Emit,
|
|
37
|
-
Once
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const Call = {
|
|
42
|
-
Plugin,
|
|
43
|
-
ByID,
|
|
44
|
-
ByName
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export const Dialogs = {
|
|
48
|
-
Info,
|
|
49
|
-
Error,
|
|
50
|
-
OpenFile, Question, Warning, SaveFile
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
setupContextMenus();
|
|
54
|
-
setupDrag();
|
|
55
|
-
|
|
56
|
-
document.addEventListener("DOMContentLoaded", function () {
|
|
57
|
-
reloadWML();
|
|
58
|
-
});
|
package/src/runtime.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
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/non-secure';
|
|
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
|
-
export let clientId = nanoid();
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Creates a runtime caller function that invokes a specified method on a given object within a specified window context.
|
|
33
|
-
*
|
|
34
|
-
* @param {Object} object - The object on which the method is to be invoked.
|
|
35
|
-
* @param {string} windowName - The name of the window context in which the method should be called.
|
|
36
|
-
* @returns {Function} A runtime caller function that takes the method name and optionally arguments and invokes the method within the specified window context.
|
|
37
|
-
*/
|
|
38
|
-
export function newRuntimeCaller(object, windowName) {
|
|
39
|
-
return function (method, args=null) {
|
|
40
|
-
return runtimeCall(object + "." + method, windowName, args);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Creates a new runtime caller with specified ID.
|
|
46
|
-
*
|
|
47
|
-
* @param {object} object - The object to invoke the method on.
|
|
48
|
-
* @param {string} windowName - The name of the window.
|
|
49
|
-
* @return {Function} - The new runtime caller function.
|
|
50
|
-
*/
|
|
51
|
-
export function newRuntimeCallerWithID(object, windowName) {
|
|
52
|
-
return function (method, args=null) {
|
|
53
|
-
return runtimeCallWithID(object, method, windowName, args);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
function runtimeCall(method, windowName, args) {
|
|
59
|
-
let url = new URL(runtimeURL);
|
|
60
|
-
if( method ) {
|
|
61
|
-
url.searchParams.append("method", method);
|
|
62
|
-
}
|
|
63
|
-
let fetchOptions = {
|
|
64
|
-
headers: {},
|
|
65
|
-
};
|
|
66
|
-
if (windowName) {
|
|
67
|
-
fetchOptions.headers["x-wails-window-name"] = windowName;
|
|
68
|
-
}
|
|
69
|
-
if (args) {
|
|
70
|
-
url.searchParams.append("args", JSON.stringify(args));
|
|
71
|
-
}
|
|
72
|
-
fetchOptions.headers["x-wails-client-id"] = clientId;
|
|
73
|
-
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
fetch(url, fetchOptions)
|
|
76
|
-
.then(response => {
|
|
77
|
-
if (response.ok) {
|
|
78
|
-
// check content type
|
|
79
|
-
if (response.headers.get("Content-Type") && response.headers.get("Content-Type").indexOf("application/json") !== -1) {
|
|
80
|
-
return response.json();
|
|
81
|
-
} else {
|
|
82
|
-
return response.text();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
reject(Error(response.statusText));
|
|
86
|
-
})
|
|
87
|
-
.then(data => resolve(data))
|
|
88
|
-
.catch(error => reject(error));
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function runtimeCallWithID(objectID, method, windowName, args) {
|
|
93
|
-
let url = new URL(runtimeURL);
|
|
94
|
-
url.searchParams.append("object", objectID);
|
|
95
|
-
url.searchParams.append("method", method);
|
|
96
|
-
let fetchOptions = {
|
|
97
|
-
headers: {},
|
|
98
|
-
};
|
|
99
|
-
if (windowName) {
|
|
100
|
-
fetchOptions.headers["x-wails-window-name"] = windowName;
|
|
101
|
-
}
|
|
102
|
-
if (args) {
|
|
103
|
-
url.searchParams.append("args", JSON.stringify(args));
|
|
104
|
-
}
|
|
105
|
-
fetchOptions.headers["x-wails-client-id"] = clientId;
|
|
106
|
-
return new Promise((resolve, reject) => {
|
|
107
|
-
fetch(url, fetchOptions)
|
|
108
|
-
.then(response => {
|
|
109
|
-
if (response.ok) {
|
|
110
|
-
// check content type
|
|
111
|
-
if (response.headers.get("Content-Type") && response.headers.get("Content-Type").indexOf("application/json") !== -1) {
|
|
112
|
-
return response.json();
|
|
113
|
-
} else {
|
|
114
|
-
return response.text();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
reject(Error(response.statusText));
|
|
118
|
-
})
|
|
119
|
-
.then(data => resolve(data))
|
|
120
|
-
.catch(error => reject(error));
|
|
121
|
-
});
|
|
122
|
-
}
|
package/src/screens.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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 {import("./api/types").Screen} Screen
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
18
|
-
const call = newRuntimeCallerWithID(objectNames.Screens, '');
|
|
19
|
-
|
|
20
|
-
const getAll = 0;
|
|
21
|
-
const getPrimary = 1;
|
|
22
|
-
const getCurrent = 2;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Gets all screens.
|
|
26
|
-
* @returns {Promise<Screen[]>} A promise that resolves to an array of Screen objects.
|
|
27
|
-
*/
|
|
28
|
-
export function GetAll() {
|
|
29
|
-
return call(getAll);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Gets the primary screen.
|
|
33
|
-
* @returns {Promise<Screen>} A promise that resolves to the primary screen.
|
|
34
|
-
*/
|
|
35
|
-
export function GetPrimary() {
|
|
36
|
-
return call(getPrimary);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Gets the current active screen.
|
|
40
|
-
*
|
|
41
|
-
* @returns {Promise<Screen>} A promise that resolves with the current active screen.
|
|
42
|
-
*/
|
|
43
|
-
export function GetCurrent() {
|
|
44
|
-
return call(getCurrent);
|
|
45
|
-
}
|
package/src/system.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
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
|
-
* @function
|
|
20
|
-
* Retrieves the system dark mode status.
|
|
21
|
-
* @returns {Promise<boolean>} - A promise that resolves to a boolean value indicating if the system is in dark mode.
|
|
22
|
-
*/
|
|
23
|
-
export function IsDarkMode() {
|
|
24
|
-
return call(systemIsDarkMode);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Fetches the capabilities of the application from the server.
|
|
30
|
-
*
|
|
31
|
-
* @async
|
|
32
|
-
* @function Capabilities
|
|
33
|
-
* @returns {Promise<Object>} A promise that resolves to an object containing the capabilities.
|
|
34
|
-
*/
|
|
35
|
-
export async function Capabilities() {
|
|
36
|
-
let response = fetch("/wails/capabilities");
|
|
37
|
-
return response.json();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @typedef {object} EnvironmentInfo
|
|
42
|
-
* @property {string} OS - The operating system in use.
|
|
43
|
-
* @property {string} Arch - The architecture of the system.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @function
|
|
48
|
-
* Retrieves environment details.
|
|
49
|
-
* @returns {Promise<EnvironmentInfo>} - A promise that resolves to an object containing OS and system architecture.
|
|
50
|
-
*/
|
|
51
|
-
export function Environment() {
|
|
52
|
-
return call(environment);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export let invoke = null;
|
|
56
|
-
let environmentCache = null;
|
|
57
|
-
|
|
58
|
-
Environment()
|
|
59
|
-
.then(result => {
|
|
60
|
-
environmentCache = result;
|
|
61
|
-
invoke = IsWindows() ? window.chrome.webview.postMessage : window.webkit.messageHandlers.external.postMessage;
|
|
62
|
-
})
|
|
63
|
-
.catch(error => {
|
|
64
|
-
console.error(`Error getting Environment: ${error}`);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Checks if the current operating system is Windows.
|
|
69
|
-
*
|
|
70
|
-
* @return {boolean} True if the operating system is Windows, otherwise false.
|
|
71
|
-
*/
|
|
72
|
-
export function IsWindows() {
|
|
73
|
-
return environmentCache.OS === "windows";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Checks if the current operating system is Linux.
|
|
78
|
-
*
|
|
79
|
-
* @returns {boolean} Returns true if the current operating system is Linux, false otherwise.
|
|
80
|
-
*/
|
|
81
|
-
export function IsLinux() {
|
|
82
|
-
return environmentCache.OS === "linux";
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Checks if the current environment is a macOS operating system.
|
|
87
|
-
*
|
|
88
|
-
* @returns {boolean} True if the environment is macOS, false otherwise.
|
|
89
|
-
*/
|
|
90
|
-
export function IsMac() {
|
|
91
|
-
return environmentCache.OS === "darwin";
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Checks if the current environment architecture is AMD64.
|
|
96
|
-
* @returns {boolean} True if the current environment architecture is AMD64, false otherwise.
|
|
97
|
-
*/
|
|
98
|
-
export function IsAMD64() {
|
|
99
|
-
return environmentCache.Arch === "amd64";
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Checks if the current architecture is ARM.
|
|
104
|
-
*
|
|
105
|
-
* @returns {boolean} True if the current architecture is ARM, false otherwise.
|
|
106
|
-
*/
|
|
107
|
-
export function IsARM() {
|
|
108
|
-
return environmentCache.Arch === "arm";
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Checks if the current environment is ARM64 architecture.
|
|
113
|
-
*
|
|
114
|
-
* @returns {boolean} - Returns true if the environment is ARM64 architecture, otherwise returns false.
|
|
115
|
-
*/
|
|
116
|
-
export function IsARM64() {
|
|
117
|
-
return environmentCache.Arch === "arm64";
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function IsDebug() {
|
|
121
|
-
return environmentCache.Debug === true;
|
|
122
|
-
}
|
package/src/window.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
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 {import("../api/types").Size} Size
|
|
15
|
-
* @typedef {import("../api/types").Position} Position
|
|
16
|
-
* @typedef {import("../api/types").Screen} Screen
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
20
|
-
|
|
21
|
-
const center = 0;
|
|
22
|
-
const setTitle = 1;
|
|
23
|
-
const fullscreen = 2;
|
|
24
|
-
const unFullscreen = 3;
|
|
25
|
-
const setSize = 4;
|
|
26
|
-
const size = 5;
|
|
27
|
-
const setMaxSize = 6;
|
|
28
|
-
const setMinSize = 7;
|
|
29
|
-
const setAlwaysOnTop = 8;
|
|
30
|
-
const setRelativePosition = 9;
|
|
31
|
-
const relativePosition = 10;
|
|
32
|
-
const screen = 11;
|
|
33
|
-
const hide = 12;
|
|
34
|
-
const maximise = 13;
|
|
35
|
-
const unMaximise = 14;
|
|
36
|
-
const toggleMaximise = 15;
|
|
37
|
-
const minimise = 16;
|
|
38
|
-
const unMinimise = 17;
|
|
39
|
-
const restore = 18;
|
|
40
|
-
const show = 19;
|
|
41
|
-
const close = 20;
|
|
42
|
-
const setBackgroundColour = 21;
|
|
43
|
-
const setResizable = 22;
|
|
44
|
-
const width = 23;
|
|
45
|
-
const height = 24;
|
|
46
|
-
const zoomIn = 25;
|
|
47
|
-
const zoomOut = 26;
|
|
48
|
-
const zoomReset = 27;
|
|
49
|
-
const getZoomLevel = 28;
|
|
50
|
-
const setZoomLevel = 29;
|
|
51
|
-
|
|
52
|
-
const thisWindow = newRuntimeCallerWithID(objectNames.Window, '');
|
|
53
|
-
|
|
54
|
-
function createWindow(call) {
|
|
55
|
-
return {
|
|
56
|
-
Get: (windowName) => createWindow(newRuntimeCallerWithID(objectNames.Window, windowName)),
|
|
57
|
-
Center: () => call(center),
|
|
58
|
-
SetTitle: (title) => call(setTitle, {title}),
|
|
59
|
-
Fullscreen: () => call(fullscreen),
|
|
60
|
-
UnFullscreen: () => call(unFullscreen),
|
|
61
|
-
SetSize: (width, height) => call(setSize, {width, height}),
|
|
62
|
-
Size: () => call(size),
|
|
63
|
-
SetMaxSize: (width, height) => call(setMaxSize, {width, height}),
|
|
64
|
-
SetMinSize: (width, height) => call(setMinSize, {width, height}),
|
|
65
|
-
SetAlwaysOnTop: (onTop) => call(setAlwaysOnTop, {alwaysOnTop: onTop}),
|
|
66
|
-
SetRelativePosition: (x, y) => call(setRelativePosition, {x, y}),
|
|
67
|
-
RelativePosition: () => call(relativePosition),
|
|
68
|
-
Screen: () => call(screen),
|
|
69
|
-
Hide: () => call(hide),
|
|
70
|
-
Maximise: () => call(maximise),
|
|
71
|
-
UnMaximise: () => call(unMaximise),
|
|
72
|
-
ToggleMaximise: () => call(toggleMaximise),
|
|
73
|
-
Minimise: () => call(minimise),
|
|
74
|
-
UnMinimise: () => call(unMinimise),
|
|
75
|
-
Restore: () => call(restore),
|
|
76
|
-
Show: () => call(show),
|
|
77
|
-
Close: () => call(close),
|
|
78
|
-
SetBackgroundColour: (r, g, b, a) => call(setBackgroundColour, {r, g, b, a}),
|
|
79
|
-
SetResizable: (resizable) => call(setResizable, {resizable}),
|
|
80
|
-
Width: () => call(width),
|
|
81
|
-
Height: () => call(height),
|
|
82
|
-
ZoomIn: () => call(zoomIn),
|
|
83
|
-
ZoomOut: () => call(zoomOut),
|
|
84
|
-
ZoomReset: () => call(zoomReset),
|
|
85
|
-
GetZoomLevel: () => call(getZoomLevel),
|
|
86
|
-
SetZoomLevel: (zoomLevel) => call(setZoomLevel, {zoomLevel}),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Gets the specified window.
|
|
92
|
-
*
|
|
93
|
-
* @param {string} windowName - The name of the window to get.
|
|
94
|
-
* @return {Object} - The specified window object.
|
|
95
|
-
*/
|
|
96
|
-
export function Get(windowName) {
|
|
97
|
-
return createWindow(newRuntimeCallerWithID(objectNames.Window, windowName));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Returns a map of all methods in the current window.
|
|
102
|
-
* @returns {Map} - A map of window methods.
|
|
103
|
-
*/
|
|
104
|
-
export function WindowMethods(targetWindow) {
|
|
105
|
-
// Create a new map to store methods
|
|
106
|
-
let result = new Map();
|
|
107
|
-
|
|
108
|
-
// Iterate over all properties of the window object
|
|
109
|
-
for (let method in targetWindow) {
|
|
110
|
-
// Check if the property is indeed a method (function)
|
|
111
|
-
if(typeof targetWindow[method] === 'function') {
|
|
112
|
-
// Add the method to the map
|
|
113
|
-
result.set(method, targetWindow[method]);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
// Return the map of window methods
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
export default {
|
|
121
|
-
...Get('')
|
|
122
|
-
}
|