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

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
@@ -1,122 +1,143 @@
1
- /*
2
- _ __ _ __
3
- | | / /___ _(_) /____
4
- | | /| / / __ `/ / / ___/
5
- | |/ |/ / /_/ / / (__ )
6
- |__/|__/\__,_/_/_/____/
7
- The electron alternative for Go
8
- (c) Lea Anthony 2019-present
9
- */
10
-
11
- /* jshint esversion: 9 */
12
-
13
- import {newRuntimeCallerWithID, objectNames} from "./runtime";
14
- let call = newRuntimeCallerWithID(objectNames.System, '');
15
- const systemIsDarkMode = 0;
16
- const environment = 1;
17
-
18
- /**
19
- * @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
- }
1
+ /*
2
+ _ __ _ __
3
+ | | / /___ _(_) /____
4
+ | | /| / / __ `/ / / ___/
5
+ | |/ |/ / /_/ / / (__ )
6
+ |__/|__/\__,_/_/_/____/
7
+ The electron alternative for Go
8
+ (c) Lea Anthony 2019-present
9
+ */
10
+
11
+ /* jshint esversion: 9 */
12
+
13
+ import {newRuntimeCallerWithID, objectNames} from "./runtime";
14
+ let call = newRuntimeCallerWithID(objectNames.System, '');
15
+ const systemIsDarkMode = 0;
16
+ const environment = 1;
17
+
18
+ const _invoke = (() => {
19
+ try {
20
+ if(window?.chrome?.webview) {
21
+ return (msg) => window.chrome.webview.postMessage(msg);
22
+ }
23
+ if(window?.webkit?.messageHandlers?.external) {
24
+ return (msg) => window.webkit.messageHandlers.external.postMessage(msg);
25
+ }
26
+ } catch(e) {
27
+ console.warn('\n%c⚠️ Browser Environment Detected %c\n\n%cOnly UI previews are available in the browser. For full functionality, please run the application in desktop mode.\nMore information at: https://v3.wails.io/learn/build/#using-a-browser-for-development\n',
28
+ 'background: #ffffff; color: #000000; font-weight: bold; padding: 4px 8px; border-radius: 4px; border: 2px solid #000000;',
29
+ 'background: transparent;',
30
+ 'color: #ffffff; font-style: italic; font-weight: bold;');
31
+ }
32
+ return null;
33
+ })();
34
+
35
+ export function invoke(msg) {
36
+ if (!_invoke) return;
37
+ return _invoke(msg);
38
+ }
39
+
40
+ /**
41
+ * @function
42
+ * Retrieves the system dark mode status.
43
+ * @returns {Promise<boolean>} - A promise that resolves to a boolean value indicating if the system is in dark mode.
44
+ */
45
+ export function IsDarkMode() {
46
+ return call(systemIsDarkMode);
47
+ }
48
+
49
+ /**
50
+ * Fetches the capabilities of the application from the server.
51
+ *
52
+ * @async
53
+ * @function Capabilities
54
+ * @returns {Promise<Object>} A promise that resolves to an object containing the capabilities.
55
+ */
56
+ export function Capabilities() {
57
+ let response = fetch("/wails/capabilities");
58
+ return response.json();
59
+ }
60
+
61
+ /**
62
+ * @typedef {Object} OSInfo
63
+ * @property {string} Branding - The branding of the OS.
64
+ * @property {string} ID - The ID of the OS.
65
+ * @property {string} Name - The name of the OS.
66
+ * @property {string} Version - The version of the OS.
67
+ */
68
+
69
+ /**
70
+ * @typedef {Object} EnvironmentInfo
71
+ * @property {string} Arch - The architecture of the system.
72
+ * @property {boolean} Debug - True if the application is running in debug mode, otherwise false.
73
+ * @property {string} OS - The operating system in use.
74
+ * @property {OSInfo} OSInfo - Details of the operating system.
75
+ * @property {Object} PlatformInfo - Additional platform information.
76
+ */
77
+
78
+ /**
79
+ * @function
80
+ * Retrieves environment details.
81
+ * @returns {Promise<EnvironmentInfo>} - A promise that resolves to an object containing OS and system architecture.
82
+ */
83
+ export function Environment() {
84
+ return call(environment);
85
+ }
86
+
87
+ /**
88
+ * Checks if the current operating system is Windows.
89
+ *
90
+ * @return {boolean} True if the operating system is Windows, otherwise false.
91
+ */
92
+ export function IsWindows() {
93
+ return window._wails.environment.OS === "windows";
94
+ }
95
+
96
+ /**
97
+ * Checks if the current operating system is Linux.
98
+ *
99
+ * @returns {boolean} Returns true if the current operating system is Linux, false otherwise.
100
+ */
101
+ export function IsLinux() {
102
+ return window._wails.environment.OS === "linux";
103
+ }
104
+
105
+ /**
106
+ * Checks if the current environment is a macOS operating system.
107
+ *
108
+ * @returns {boolean} True if the environment is macOS, false otherwise.
109
+ */
110
+ export function IsMac() {
111
+ return window._wails.environment.OS === "darwin";
112
+ }
113
+
114
+ /**
115
+ * Checks if the current environment architecture is AMD64.
116
+ * @returns {boolean} True if the current environment architecture is AMD64, false otherwise.
117
+ */
118
+ export function IsAMD64() {
119
+ return window._wails.environment.Arch === "amd64";
120
+ }
121
+
122
+ /**
123
+ * Checks if the current architecture is ARM.
124
+ *
125
+ * @returns {boolean} True if the current architecture is ARM, false otherwise.
126
+ */
127
+ export function IsARM() {
128
+ return window._wails.environment.Arch === "arm";
129
+ }
130
+
131
+ /**
132
+ * Checks if the current environment is ARM64 architecture.
133
+ *
134
+ * @returns {boolean} - Returns true if the environment is ARM64 architecture, otherwise returns false.
135
+ */
136
+ export function IsARM64() {
137
+ return window._wails.environment.Arch === "arm64";
138
+ }
139
+
140
+ export function IsDebug() {
141
+ return window._wails.environment.Debug === true;
142
+ }
143
+
package/src/utils.js ADDED
@@ -0,0 +1,86 @@
1
+ /*
2
+ _ __ _ __
3
+ | | / /___ _(_) /____
4
+ | | /| / / __ `/ / / ___/
5
+ | |/ |/ / /_/ / / (__ )
6
+ |__/|__/\__,_/_/_/____/
7
+ The electron alternative for Go
8
+ (c) Lea Anthony 2019-present
9
+ */
10
+
11
+ /**
12
+ * Logs a message to the console with custom formatting.
13
+ * @param {string} message - The message to be logged.
14
+ * @return {void}
15
+ */
16
+ export function debugLog(message) {
17
+ // eslint-disable-next-line
18
+ console.log(
19
+ '%c wails3 %c ' + message + ' ',
20
+ 'background: #aa0000; color: #fff; border-radius: 3px 0px 0px 3px; padding: 1px; font-size: 0.7rem',
21
+ 'background: #009900; color: #fff; border-radius: 0px 3px 3px 0px; padding: 1px; font-size: 0.7rem'
22
+ );
23
+ }
24
+
25
+ /**
26
+ * Checks whether the browser supports removing listeners by triggering an AbortSignal
27
+ * (see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#signal)
28
+ *
29
+ * @return {boolean}
30
+ */
31
+ export function canAbortListeners() {
32
+ if (!EventTarget || !AbortSignal || !AbortController)
33
+ return false;
34
+
35
+ let result = true;
36
+
37
+ const target = new EventTarget();
38
+ const controller = new AbortController();
39
+ target.addEventListener('test', () => { result = false; }, { signal: controller.signal });
40
+ controller.abort();
41
+ target.dispatchEvent(new CustomEvent('test'));
42
+
43
+ return result;
44
+ }
45
+
46
+ /***
47
+ This technique for proper load detection is taken from HTMX:
48
+
49
+ BSD 2-Clause License
50
+
51
+ Copyright (c) 2020, Big Sky Software
52
+ All rights reserved.
53
+
54
+ Redistribution and use in source and binary forms, with or without
55
+ modification, are permitted provided that the following conditions are met:
56
+
57
+ 1. Redistributions of source code must retain the above copyright notice, this
58
+ list of conditions and the following disclaimer.
59
+
60
+ 2. Redistributions in binary form must reproduce the above copyright notice,
61
+ this list of conditions and the following disclaimer in the documentation
62
+ and/or other materials provided with the distribution.
63
+
64
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
65
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
66
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
67
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
68
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
69
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
70
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
71
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
72
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
73
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74
+
75
+ ***/
76
+
77
+ let isReady = false;
78
+ document.addEventListener('DOMContentLoaded', () => isReady = true);
79
+
80
+ export function whenReady(callback) {
81
+ if (isReady || document.readyState === 'complete') {
82
+ callback();
83
+ } else {
84
+ document.addEventListener('DOMContentLoaded', callback);
85
+ }
86
+ }