@wailsio/runtime 3.0.0-alpha.6 → 3.0.0-alpha.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/docs/.nojekyll +1 -0
  2. package/docs/assets/highlight.css +22 -0
  3. package/docs/assets/icons.js +15 -0
  4. package/docs/assets/icons.svg +1 -0
  5. package/docs/assets/main.js +59 -0
  6. package/docs/assets/navigation.js +1 -0
  7. package/docs/assets/search.js +1 -0
  8. package/docs/assets/style.css +1415 -0
  9. package/docs/classes/Call.RuntimeError.html +11 -0
  10. package/docs/classes/Events.WailsEvent.html +4 -0
  11. package/docs/functions/Application.Hide.html +2 -0
  12. package/docs/functions/Application.Quit.html +2 -0
  13. package/docs/functions/Application.Show.html +2 -0
  14. package/docs/functions/Browser.OpenURL.html +3 -0
  15. package/docs/functions/Call.ByID.html +8 -0
  16. package/docs/functions/Call.ByName.html +6 -0
  17. package/docs/functions/Call.Call.html +11 -0
  18. package/docs/functions/Clipboard.SetText.html +6 -0
  19. package/docs/functions/Clipboard.Text.html +3 -0
  20. package/docs/functions/Create.Any.html +2 -0
  21. package/docs/functions/Create.Array.html +4 -0
  22. package/docs/functions/Create.ByteSlice.html +3 -0
  23. package/docs/functions/Create.Map.html +4 -0
  24. package/docs/functions/Create.Nullable.html +3 -0
  25. package/docs/functions/Create.Struct.html +3 -0
  26. package/docs/functions/Dialogs.Error.html +5 -0
  27. package/docs/functions/Dialogs.Info.html +5 -0
  28. package/docs/functions/Dialogs.OpenFile.html +3 -0
  29. package/docs/functions/Dialogs.Question.html +5 -0
  30. package/docs/functions/Dialogs.SaveFile.html +3 -0
  31. package/docs/functions/Dialogs.Warning.html +5 -0
  32. package/docs/functions/Events.Emit.html +6 -0
  33. package/docs/functions/Events.Off.html +4 -0
  34. package/docs/functions/Events.OffAll.html +3 -0
  35. package/docs/functions/Events.On.html +7 -0
  36. package/docs/functions/Events.OnMultiple.html +8 -0
  37. package/docs/functions/Events.Once.html +7 -0
  38. package/docs/functions/Events.setup.html +1 -0
  39. package/docs/functions/Flags.GetFlag.html +6 -0
  40. package/docs/functions/Screens.GetAll.html +3 -0
  41. package/docs/functions/Screens.GetCurrent.html +3 -0
  42. package/docs/functions/Screens.GetPrimary.html +3 -0
  43. package/docs/functions/System.Capabilities.html +4 -0
  44. package/docs/functions/System.Environment.html +5 -0
  45. package/docs/functions/System.IsAMD64.html +3 -0
  46. package/docs/functions/System.IsARM.html +3 -0
  47. package/docs/functions/System.IsARM64.html +5 -0
  48. package/docs/functions/System.IsDarkMode.html +5 -0
  49. package/docs/functions/System.IsDebug.html +1 -0
  50. package/docs/functions/System.IsLinux.html +3 -0
  51. package/docs/functions/System.IsMac.html +3 -0
  52. package/docs/functions/System.IsWindows.html +3 -0
  53. package/docs/functions/System.invoke.html +1 -0
  54. package/docs/functions/WML.Enable.html +2 -0
  55. package/docs/functions/WML.Reload.html +2 -0
  56. package/docs/functions/init.html +1 -0
  57. package/docs/index.html +5 -0
  58. package/docs/interfaces/Call.CallOptions.html +7 -0
  59. package/docs/interfaces/Dialogs.Button.html +7 -0
  60. package/docs/interfaces/Dialogs.FileFilter.html +5 -0
  61. package/docs/interfaces/Dialogs.MessageDialogOptions.html +9 -0
  62. package/docs/interfaces/Dialogs.OpenFileDialogOptions.html +33 -0
  63. package/docs/interfaces/Dialogs.SaveFileDialogOptions.html +35 -0
  64. package/docs/interfaces/Screens.Rect.html +9 -0
  65. package/docs/interfaces/Screens.Screen.html +25 -0
  66. package/docs/interfaces/Screens.Size.html +5 -0
  67. package/docs/interfaces/System.EnvironmentInfo.html +11 -0
  68. package/docs/interfaces/System.OSInfo.html +9 -0
  69. package/docs/modules/Application.html +4 -0
  70. package/docs/modules/Browser.html +2 -0
  71. package/docs/modules/Call.html +6 -0
  72. package/docs/modules/Clipboard.html +3 -0
  73. package/docs/modules/Create.html +7 -0
  74. package/docs/modules/Dialogs.html +12 -0
  75. package/docs/modules/Events.html +10 -0
  76. package/docs/modules/Flags.html +2 -0
  77. package/docs/modules/Screens.html +7 -0
  78. package/docs/modules/System.html +14 -0
  79. package/docs/modules/WML.html +3 -0
  80. package/docs/modules.html +14 -0
  81. package/docs/variables/Events.Types.html +1 -0
  82. package/docs/variables/Window.html +2 -0
  83. package/package.json +38 -17
  84. package/{application.js → src/application.js} +46 -46
  85. package/{browser.js → src/browser.js} +24 -24
  86. package/src/calls.js +221 -0
  87. package/{clipboard.js → src/clipboard.js} +35 -35
  88. package/{contextmenu.js → src/contextmenu.js} +97 -98
  89. package/src/create.js +125 -0
  90. package/src/dialogs.js +200 -0
  91. package/{drag.js → src/drag.js} +119 -125
  92. package/src/event_types.js +219 -0
  93. package/{events.js → src/events.js} +140 -134
  94. package/src/flags.js +25 -0
  95. package/src/index.js +60 -0
  96. package/src/nanoid.js +42 -0
  97. package/src/runtime.js +92 -0
  98. package/src/screens.js +71 -0
  99. package/{system.js → src/system.js} +143 -122
  100. package/src/utils.js +86 -0
  101. package/src/window.js +638 -0
  102. package/src/wml.js +250 -0
  103. package/tsconfig.json +20 -0
  104. package/types/application.d.ts +19 -0
  105. package/types/browser.d.ts +6 -0
  106. package/types/calls.d.ts +69 -0
  107. package/types/clipboard.d.ts +12 -0
  108. package/types/create.d.ts +52 -0
  109. package/types/dialogs.d.ts +184 -0
  110. package/types/event_types.d.ts +219 -0
  111. package/types/events.d.ts +271 -0
  112. package/types/flags.d.ts +7 -0
  113. package/types/index.d.ts +14 -0
  114. package/types/nanoid.d.ts +1 -0
  115. package/types/runtime.d.ts +30 -0
  116. package/types/screens.d.ts +94 -0
  117. package/types/system.d.ts +112 -0
  118. package/types/utils.d.ts +14 -0
  119. package/types/window.d.ts +407 -0
  120. package/types/wml.d.ts +12 -0
  121. package/calls.js +0 -123
  122. package/dialogs.js +0 -138
  123. package/flags.js +0 -63
  124. package/index.js +0 -56
  125. package/runtime.js +0 -122
  126. package/screens.js +0 -45
  127. package/types.d.ts +0 -130
  128. package/window.js +0 -122
  129. package/wml.js +0 -149
package/dialogs.js DELETED
@@ -1,138 +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("./types").MessageDialogOptions} MessageDialogOptions
15
- * @typedef {import("./types").OpenDialogOptions} OpenDialogOptions
16
- * @typedef {import("./types").SaveDialogOptions} SaveDialogOptions
17
- */
18
-
19
- import {newRuntimeCallerWithID, objectNames} from "./runtime";
20
-
21
- import { nanoid } from 'nanoid/non-secure';
22
-
23
- // Define constants from the `methods` object in Title Case
24
- const DialogInfo = 0;
25
- const DialogWarning = 1;
26
- const DialogError = 2;
27
- const DialogQuestion = 3;
28
- const DialogOpenFile = 4;
29
- const DialogSaveFile = 5;
30
-
31
- const call = newRuntimeCallerWithID(objectNames.Dialog, '');
32
- const dialogResponses = new Map();
33
-
34
- /**
35
- * Generates a unique id that is not present in dialogResponses.
36
- * @returns {string} unique id
37
- */
38
- function generateID() {
39
- let result;
40
- do {
41
- result = nanoid();
42
- } while (dialogResponses.has(result));
43
- return result;
44
- }
45
-
46
- /**
47
- * Shows a dialog of specified type with the given options.
48
- * @param {number} type - type of dialog
49
- * @param {object} options - options for the dialog
50
- * @returns {Promise} promise that resolves with result of dialog
51
- */
52
- function dialog(type, options = {}) {
53
- const id = generateID();
54
- options["dialog-id"] = id;
55
- return new Promise((resolve, reject) => {
56
- dialogResponses.set(id, {resolve, reject});
57
- call(type, options).catch((error) => {
58
- reject(error);
59
- dialogResponses.delete(id);
60
- });
61
- });
62
- }
63
-
64
- /**
65
- * Handles the callback from a dialog.
66
- *
67
- * @param {string} id - The ID of the dialog response.
68
- * @param {string} data - The data received from the dialog.
69
- * @param {boolean} isJSON - Flag indicating whether the data is in JSON format.
70
- *
71
- * @return {undefined}
72
- */
73
- export function dialogCallback(id, data, isJSON) {
74
- let p = dialogResponses.get(id);
75
- if (p) {
76
- if (isJSON) {
77
- p.resolve(JSON.parse(data));
78
- } else {
79
- p.resolve(data);
80
- }
81
- dialogResponses.delete(id);
82
- }
83
- }
84
-
85
- /**
86
- * Callback function for handling errors in dialog.
87
- *
88
- * @param {string} id - The id of the dialog response.
89
- * @param {string} message - The error message.
90
- *
91
- * @return {void}
92
- */
93
- export function dialogErrorCallback(id, message) {
94
- let p = dialogResponses.get(id);
95
- if (p) {
96
- p.reject(message);
97
- dialogResponses.delete(id);
98
- }
99
- }
100
-
101
-
102
- // Replace `methods` with constants in Title Case
103
-
104
- /**
105
- * @param {MessageDialogOptions} options - Dialog options
106
- * @returns {Promise<string>} - The label of the button pressed
107
- */
108
- export const Info = (options) => dialog(DialogInfo, options);
109
-
110
- /**
111
- * @param {MessageDialogOptions} options - Dialog options
112
- * @returns {Promise<string>} - The label of the button pressed
113
- */
114
- export const Warning = (options) => dialog(DialogWarning, options);
115
-
116
- /**
117
- * @param {MessageDialogOptions} options - Dialog options
118
- * @returns {Promise<string>} - The label of the button pressed
119
- */
120
- export const Error = (options) => dialog(DialogError, options);
121
-
122
- /**
123
- * @param {MessageDialogOptions} options - Dialog options
124
- * @returns {Promise<string>} - The label of the button pressed
125
- */
126
- export const Question = (options) => dialog(DialogQuestion, options);
127
-
128
- /**
129
- * @param {OpenDialogOptions} options - Dialog options
130
- * @returns {Promise<string[]|string>} Returns selected file or list of files. Returns blank string if no file is selected.
131
- */
132
- export const OpenFile = (options) => dialog(DialogOpenFile, options);
133
-
134
- /**
135
- * @param {SaveDialogOptions} options - Dialog options
136
- * @returns {Promise<string>} Returns the selected file. Returns blank string if no file is selected.
137
- */
138
- export const SaveFile = (options) => dialog(DialogSaveFile, options);
package/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/index.js DELETED
@@ -1,56 +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
- export * as Application from "./application";
19
- export * as Browser from "./browser";
20
- export * as Clipboard from "./clipboard";
21
- export * as ContextMenu from "./contextmenu";
22
- export * as Flags from "./flags";
23
- export * as Runtime from "./runtime";
24
- export * as Screens from "./screens";
25
- export * as System from "./system";
26
- export * as Window from "./window";
27
-
28
- export const Events = {
29
- On,
30
- Off,
31
- OnMultiple,
32
- WailsEvent,
33
- OffAll,
34
- Emit,
35
- Once
36
-
37
- }
38
-
39
- export const Call = {
40
- Plugin,
41
- ByID,
42
- ByName
43
- }
44
-
45
- export const Dialogs = {
46
- Info,
47
- Error,
48
- OpenFile, Question, Warning, SaveFile
49
- }
50
-
51
- setupContextMenus();
52
- setupDrag();
53
-
54
- document.addEventListener("DOMContentLoaded", function () {
55
- reloadWML();
56
- });
package/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/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/types.d.ts DELETED
@@ -1,130 +0,0 @@
1
-
2
- export interface Button {
3
- // The label of the button
4
- Label?: string;
5
- // True if this button is the cancel button (selected when pressing escape)
6
- IsCancel?: boolean;
7
- // True if this button is the default button (selected when pressing enter)
8
- IsDefault?: boolean;
9
- }
10
-
11
- interface MessageDialogOptions {
12
- // The title for the dialog
13
- Title?: string;
14
- // The message to display
15
- Message?: string;
16
- // The buttons to use on the dialog
17
- Buttons?: Button[];
18
- // Whether the dialog is detached from the current window
19
- Detached?: boolean;
20
- }
21
-
22
- export interface OpenFileDialogOptions {
23
- // Allows the user to be able to select directories
24
- CanChooseDirectories?: boolean;
25
- // Allows the user to be able to select files
26
- CanChooseFiles?: boolean;
27
- // Provide an option to create directories in the dialog
28
- CanCreateDirectories?: boolean;
29
- // Makes the dialog show hidden files
30
- ShowHiddenFiles?: boolean;
31
- // Whether the dialog should follow filesystem aliases
32
- ResolvesAliases?: boolean;
33
- // Allow the user to select multiple files or directories
34
- AllowsMultipleSelection?: boolean;
35
- // Hide the extension when showing the filename
36
- HideExtension?: boolean;
37
- // Allow the user to select files where the system hides their extensions
38
- CanSelectHiddenExtension?: boolean;
39
- // Treats file packages as directories, e.g. .app on macOS
40
- TreatsFilePackagesAsDirectories?: boolean;
41
- // Allows selection of filetypes not specified in the filters
42
- AllowsOtherFiletypes?: boolean;
43
- // The file filters to use in the dialog
44
- Filters?: FileFilter[];
45
- // The title of the dialog
46
- Title?: string;
47
- // The message to display
48
- Message?: string;
49
- // The label for the select button
50
- ButtonText?: string;
51
- // The default directory to open the dialog in
52
- Directory?: string;
53
- // Whether the dialog is detached from the current window
54
- Detached?: boolean;
55
- }
56
- export interface FileFilter {
57
- // The display name for the filter, e.g. "Text Files"
58
- DisplayName?: string;
59
- // The pattern to use for the filter, e.g. "*.txt;*.md"
60
- Pattern?: string;
61
- }
62
- export interface SaveFileDialogOptions {
63
- // Provide an option to create directories in the dialog
64
- CanCreateDirectories?: boolean;
65
- // Makes the dialog show hidden files
66
- ShowHiddenFiles?: boolean;
67
- // Allow the user to select files where the system hides their extensions
68
- CanSelectHiddenExtension?: boolean;
69
- // Allows selection of filetypes not specified in the filters
70
- AllowOtherFiletypes?: boolean;
71
- // Hide the extension when showing the filename
72
- HideExtension?: boolean;
73
- // Treats file packages as directories, e.g. .app on macOS
74
- TreatsFilePackagesAsDirectories?: boolean;
75
- // The message to show in the dialog
76
- Message?: string;
77
- // The default directory to open the dialog in
78
- Directory?: string;
79
- // The default filename to use in the dialog
80
- Filename?: string;
81
- // The label for the select button
82
- ButtonText?: string;
83
- // Whether the dialog is detached from the current window
84
- Detached?: boolean;
85
- }
86
-
87
- export interface Screen {
88
- // The screen ID
89
- Id: string;
90
- // The screen name
91
- Name: string;
92
- // The screen scale. 1 = standard resolution, 2: 2x retina, etc.
93
- Scale: number;
94
- // The X position of the screen
95
- X: number;
96
- // The Y position of the screen
97
- Y: number;
98
- // The width and height of the screen
99
- Size: Size;
100
- // The bounds of the screen
101
- Bounds: Rect;
102
- // The work area of the screen
103
- WorkArea: Rect;
104
- // True if this is the primary screen
105
- IsPrimary: boolean;
106
- // The rotation of the screen
107
- Rotation: number;
108
- }
109
- export interface Rect {
110
- X: number;
111
- Y: number;
112
- Width: number;
113
- Height: number;
114
- }
115
-
116
- export interface WailsEvent {
117
- // The name of the event
118
- Name: string;
119
- // The data associated with the event
120
- Data?: any;
121
- }
122
-
123
- export interface Size {
124
- Width: number;
125
- Height: number;
126
- }
127
- export interface Position {
128
- X: number;
129
- Y: number;
130
- }
package/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
- }