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