@wailsio/runtime 3.0.0-alpha.20 → 3.0.0-alpha.21
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/{functions/Window.Size.html → assets/icons.js} +15 -2
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +4 -4
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +2 -1
- package/docs/classes/Events.WailsEvent.html +4 -4
- package/docs/functions/Application.Hide.html +2 -2
- package/docs/functions/Application.Quit.html +2 -2
- package/docs/functions/Application.Show.html +2 -2
- package/docs/functions/Browser.OpenURL.html +3 -3
- package/docs/functions/Call.ByID.html +4 -4
- package/docs/functions/Call.ByName.html +4 -4
- package/docs/functions/Call.Call.html +3 -3
- package/docs/functions/Call.Plugin.html +5 -5
- package/docs/functions/Clipboard.SetText.html +3 -3
- package/docs/functions/Clipboard.Text.html +2 -2
- package/docs/functions/Dialogs.Error.html +2 -2
- package/docs/functions/Dialogs.Info.html +2 -2
- package/docs/functions/Dialogs.OpenFile.html +2 -2
- package/docs/functions/Dialogs.Question.html +2 -2
- package/docs/functions/Dialogs.SaveFile.html +2 -2
- package/docs/functions/Dialogs.Warning.html +2 -2
- package/docs/functions/Events.Emit.html +3 -3
- package/docs/functions/Events.Off.html +4 -4
- package/docs/functions/Events.OffAll.html +2 -2
- package/docs/functions/Events.On.html +4 -4
- package/docs/functions/Events.OnMultiple.html +5 -5
- package/docs/functions/Events.Once.html +4 -4
- package/docs/functions/Events.setup.html +1 -1
- package/docs/functions/Flags.GetFlag.html +3 -3
- package/docs/functions/Screens.GetAll.html +3 -3
- package/docs/functions/Screens.GetCurrent.html +3 -3
- package/docs/functions/Screens.GetPrimary.html +3 -3
- package/docs/functions/System.Capabilities.html +2 -2
- package/docs/functions/System.Environment.html +2 -2
- package/docs/functions/System.IsAMD64.html +2 -2
- package/docs/functions/System.IsARM.html +2 -2
- package/docs/functions/System.IsARM64.html +2 -2
- package/docs/functions/System.IsDarkMode.html +2 -2
- package/docs/functions/System.IsDebug.html +1 -1
- package/docs/functions/System.IsLinux.html +2 -2
- package/docs/functions/System.IsMac.html +2 -2
- package/docs/functions/System.IsWindows.html +2 -2
- package/docs/functions/System.invoke.html +1 -1
- package/docs/functions/WML.Enable.html +2 -0
- package/docs/functions/WML.Reload.html +2 -2
- package/docs/index.html +2 -2
- package/docs/interfaces/Dialogs.Button.html +7 -7
- package/docs/interfaces/Dialogs.FileFilter.html +5 -5
- package/docs/interfaces/Dialogs.MessageDialogOptions.html +9 -9
- package/docs/interfaces/Dialogs.OpenFileDialogOptions.html +33 -33
- package/docs/interfaces/Dialogs.SaveFileDialogOptions.html +35 -35
- package/docs/interfaces/Screens.Position.html +5 -5
- package/docs/interfaces/Screens.Rect.html +9 -9
- package/docs/interfaces/Screens.Screen.html +19 -19
- package/docs/interfaces/Screens.Size.html +5 -5
- package/docs/interfaces/System.EnvironmentInfo.html +11 -5
- package/docs/interfaces/System.OSInfo.html +9 -0
- package/docs/modules/Application.html +4 -4
- package/docs/modules/Browser.html +2 -2
- package/docs/modules/Call.html +5 -5
- package/docs/modules/Clipboard.html +3 -3
- package/docs/modules/Dialogs.html +12 -12
- package/docs/modules/Events.html +10 -10
- package/docs/modules/Flags.html +2 -2
- package/docs/modules/Screens.html +8 -9
- package/docs/modules/System.html +14 -13
- package/docs/modules/WML.html +3 -2
- package/docs/modules.html +12 -12
- package/docs/variables/Events.Types.html +1 -1
- package/docs/variables/Window.html +2 -0
- package/package.json +31 -31
- package/src/application.js +46 -46
- package/src/browser.js +24 -24
- package/src/calls.js +180 -161
- package/src/clipboard.js +35 -35
- package/src/contextmenu.js +97 -97
- package/src/dialogs.js +200 -200
- package/src/drag.js +119 -125
- package/src/event_types.js +5 -0
- package/src/events.js +140 -140
- package/src/flags.js +25 -25
- package/src/index.js +46 -95
- package/src/runtime.js +123 -122
- package/src/screens.js +77 -83
- package/src/system.js +128 -117
- package/src/utils.js +86 -0
- package/src/window.js +638 -316
- package/src/wml.js +250 -171
- package/tsconfig.json +19 -19
- package/types/event_types.d.ts +5 -0
- package/types/events.d.ts +5 -0
- package/types/index.d.ts +2 -2
- package/types/runtime.d.ts +1 -0
- package/types/screens.d.ts +1 -5
- package/types/system.d.ts +44 -4
- package/types/utils.d.ts +14 -0
- package/types/window.d.ts +400 -133
- package/types/wml.d.ts +6 -0
- package/docs/functions/Window.Center.html +0 -2
- package/docs/functions/Window.Close.html +0 -2
- package/docs/functions/Window.Fullscreen.html +0 -2
- package/docs/functions/Window.Get.html +0 -6
- package/docs/functions/Window.GetZoomLevel.html +0 -2
- package/docs/functions/Window.Height.html +0 -2
- package/docs/functions/Window.Hide.html +0 -2
- package/docs/functions/Window.Maximise.html +0 -2
- package/docs/functions/Window.Minimise.html +0 -2
- package/docs/functions/Window.RelativePosition.html +0 -2
- package/docs/functions/Window.Restore.html +0 -2
- package/docs/functions/Window.Screen-1.html +0 -2
- package/docs/functions/Window.SetAlwaysOnTop.html +0 -3
- package/docs/functions/Window.SetBackgroundColour.html +0 -6
- package/docs/functions/Window.SetMaxSize.html +0 -4
- package/docs/functions/Window.SetMinSize.html +0 -4
- package/docs/functions/Window.SetRelativePosition.html +0 -4
- package/docs/functions/Window.SetResizable.html +0 -3
- package/docs/functions/Window.SetSize.html +0 -4
- package/docs/functions/Window.SetTitle.html +0 -3
- package/docs/functions/Window.SetZoomLevel.html +0 -3
- package/docs/functions/Window.Show.html +0 -2
- package/docs/functions/Window.ToggleMaximise.html +0 -2
- package/docs/functions/Window.UnMaximise.html +0 -2
- package/docs/functions/Window.UnMinimise.html +0 -2
- package/docs/functions/Window.Width.html +0 -2
- package/docs/functions/Window.ZoomIn.html +0 -2
- package/docs/functions/Window.ZoomOut.html +0 -2
- package/docs/functions/Window.ZoomReset.html +0 -2
- package/docs/modules/Window.html +0 -32
- package/docs/types/Screens.Rotation.html +0 -2
- package/src/log.js +0 -13
package/src/index.js
CHANGED
|
@@ -1,95 +1,46 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ __ _ __
|
|
3
|
-
| | / /___ _(_) /____
|
|
4
|
-
| | /| / / __ `/ / / ___/
|
|
5
|
-
| |/ |/ / /_/ / / (__ )
|
|
6
|
-
|__/|__/\__,_/_/_/____/
|
|
7
|
-
The electron alternative for Go
|
|
8
|
-
(c) Lea Anthony 2019-present
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// Setup
|
|
12
|
-
window.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import * as
|
|
19
|
-
import * as
|
|
20
|
-
import * as
|
|
21
|
-
import * as
|
|
22
|
-
import * as
|
|
23
|
-
import * as
|
|
24
|
-
import * as
|
|
25
|
-
import * as
|
|
26
|
-
import * as
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
49
|
-
this list of conditions and the following disclaimer in the documentation
|
|
50
|
-
and/or other materials provided with the distribution.
|
|
51
|
-
|
|
52
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
53
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
54
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
55
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
56
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
57
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
58
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
59
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
60
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
61
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
62
|
-
|
|
63
|
-
***/
|
|
64
|
-
|
|
65
|
-
window.wails = {
|
|
66
|
-
Application,
|
|
67
|
-
Browser,
|
|
68
|
-
Call,
|
|
69
|
-
Clipboard,
|
|
70
|
-
Dialogs,
|
|
71
|
-
Events,
|
|
72
|
-
Flags,
|
|
73
|
-
Screens,
|
|
74
|
-
System,
|
|
75
|
-
Window,
|
|
76
|
-
WML,
|
|
77
|
-
};
|
|
78
|
-
invoke('wails:runtime:ready');
|
|
79
|
-
|
|
80
|
-
let isReady = false;
|
|
81
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
82
|
-
isReady = true
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
function whenReady(fn) {
|
|
86
|
-
if (isReady || document.readyState === 'complete') {
|
|
87
|
-
fn();
|
|
88
|
-
} else {
|
|
89
|
-
document.addEventListener('DOMContentLoaded', fn);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
whenReady(() => {
|
|
94
|
-
WML.Reload();
|
|
95
|
-
});
|
|
1
|
+
/*
|
|
2
|
+
_ __ _ __
|
|
3
|
+
| | / /___ _(_) /____
|
|
4
|
+
| | /| / / __ `/ / / ___/
|
|
5
|
+
| |/ |/ / /_/ / / (__ )
|
|
6
|
+
|__/|__/\__,_/_/_/____/
|
|
7
|
+
The electron alternative for Go
|
|
8
|
+
(c) Lea Anthony 2019-present
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Setup
|
|
12
|
+
window._wails = window._wails || {};
|
|
13
|
+
|
|
14
|
+
import "./contextmenu";
|
|
15
|
+
import "./drag";
|
|
16
|
+
|
|
17
|
+
// Re-export public API
|
|
18
|
+
import * as Application from "./application";
|
|
19
|
+
import * as Browser from "./browser";
|
|
20
|
+
import * as Call from "./calls";
|
|
21
|
+
import * as Clipboard from "./clipboard";
|
|
22
|
+
import * as Dialogs from "./dialogs";
|
|
23
|
+
import * as Events from "./events";
|
|
24
|
+
import * as Flags from "./flags";
|
|
25
|
+
import * as Screens from "./screens";
|
|
26
|
+
import * as System from "./system";
|
|
27
|
+
import Window from "./window";
|
|
28
|
+
import * as WML from "./wml";
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
Application,
|
|
32
|
+
Browser,
|
|
33
|
+
Call,
|
|
34
|
+
Clipboard,
|
|
35
|
+
Dialogs,
|
|
36
|
+
Events,
|
|
37
|
+
Flags,
|
|
38
|
+
Screens,
|
|
39
|
+
System,
|
|
40
|
+
Window,
|
|
41
|
+
WML
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Notify backend
|
|
45
|
+
window._wails.invoke = System.invoke;
|
|
46
|
+
System.invoke("wails:runtime:ready");
|
package/src/runtime.js
CHANGED
|
@@ -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/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
|
-
|
|
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/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
|
+
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
CHANGED
|
@@ -1,83 +1,77 @@
|
|
|
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} Position
|
|
15
|
-
* @property {number} X - The X coordinate.
|
|
16
|
-
* @property {number} Y - The Y coordinate.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @typedef {Object} Size
|
|
21
|
-
* @property {number} X - The width.
|
|
22
|
-
* @property {number} Y - The height.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @typedef {Object} Rect
|
|
28
|
-
* @property {number} X - The X coordinate of the top-left corner.
|
|
29
|
-
* @property {number} Y - The Y coordinate of the top-left corner.
|
|
30
|
-
* @property {number} Width - The width of the rectangle.
|
|
31
|
-
* @property {number} Height - The height of the rectangle.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @typedef {
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* @
|
|
43
|
-
* @property {
|
|
44
|
-
* @property {
|
|
45
|
-
* @property {number}
|
|
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
|
-
* @returns {Promise<Screen>} A promise that resolves with the current active screen.
|
|
80
|
-
*/
|
|
81
|
-
export function GetCurrent() {
|
|
82
|
-
return call(getCurrent);
|
|
83
|
-
}
|
|
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} Position
|
|
15
|
+
* @property {number} X - The X coordinate.
|
|
16
|
+
* @property {number} Y - The Y coordinate.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {Object} Size
|
|
21
|
+
* @property {number} X - The width.
|
|
22
|
+
* @property {number} Y - The height.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {Object} Rect
|
|
28
|
+
* @property {number} X - The X coordinate of the top-left corner.
|
|
29
|
+
* @property {number} Y - The Y coordinate of the top-left corner.
|
|
30
|
+
* @property {number} Width - The width of the rectangle.
|
|
31
|
+
* @property {number} Height - The height of the rectangle.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {Object} Screen
|
|
37
|
+
* @property {string} Id - Unique identifier for the screen.
|
|
38
|
+
* @property {string} Name - Human readable name of the screen.
|
|
39
|
+
* @property {number} Scale - The resolution scale of the screen. 1 = standard resolution, 2 = high (Retina), etc.
|
|
40
|
+
* @property {Position} Position - Contains the X and Y coordinates of the screen's position.
|
|
41
|
+
* @property {Size} Size - Contains the width and height of the screen.
|
|
42
|
+
* @property {Rect} Bounds - Contains the bounds of the screen in terms of X, Y, Width, and Height.
|
|
43
|
+
* @property {Rect} WorkArea - Contains the area of the screen that is actually usable (excluding taskbar and other system UI).
|
|
44
|
+
* @property {boolean} IsPrimary - True if this is the primary monitor selected by the user in the operating system.
|
|
45
|
+
* @property {number} Rotation - The rotation of the screen.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
50
|
+
const call = newRuntimeCallerWithID(objectNames.Screens, '');
|
|
51
|
+
|
|
52
|
+
const getAll = 0;
|
|
53
|
+
const getPrimary = 1;
|
|
54
|
+
const getCurrent = 2;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Gets all screens.
|
|
58
|
+
* @returns {Promise<Screen[]>} A promise that resolves to an array of Screen objects.
|
|
59
|
+
*/
|
|
60
|
+
export function GetAll() {
|
|
61
|
+
return call(getAll);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the primary screen.
|
|
65
|
+
* @returns {Promise<Screen>} A promise that resolves to the primary screen.
|
|
66
|
+
*/
|
|
67
|
+
export function GetPrimary() {
|
|
68
|
+
return call(getPrimary);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the current active screen.
|
|
72
|
+
*
|
|
73
|
+
* @returns {Promise<Screen>} A promise that resolves with the current active screen.
|
|
74
|
+
*/
|
|
75
|
+
export function GetCurrent() {
|
|
76
|
+
return call(getCurrent);
|
|
77
|
+
}
|