@wailsio/runtime 3.0.0-alpha.20 → 3.0.0-alpha.22
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 +34 -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
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Window | @wailsio/runtime</title><meta name="description" content="Documentation for @wailsio/runtime"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@wailsio/runtime</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@wailsio/runtime</a></li><li><a href="Window.html">Window</a></li></ul><h1>Variable Window<code class="tsd-tag ts-flagConst">Const</code> </h1></div><div class="tsd-signature"><span class="tsd-kind-variable">Window</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Window</span><span class="tsd-signature-symbol"> = ...</span></div><div class="tsd-comment tsd-typography"><p>The window within which the script is running.</p>
|
|
2
|
+
</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/wailsapp/wails/blob/67c493f1/v3/internal/runtime/desktop/@wailsio/runtime/src/window.js#L636">window.js:636</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-index-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><h4 class="uppercase">Member Visibility</h4><form><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div><div class="tsd-theme-toggle"><h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>@wailsio/runtime</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><div class="tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div></body></html>
|
package/package.json
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@wailsio/runtime",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
4
|
-
"description": "Wails Runtime",
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"types": "types/index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/wailsapp/wails.git"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"prebuild:types": "rimraf ./types",
|
|
13
|
-
"build:types": "npx -p typescript tsc src/index.js --declaration --allowJs --emitDeclarationOnly --outDir types",
|
|
14
|
-
"postbuild:types": "wails3 task generate:events",
|
|
15
|
-
"build:docs": "npx typedoc ./src/index.js",
|
|
16
|
-
"build:docs:md": "npx typedoc --plugin typedoc-plugin-markdown --namedAnchors true --hideBreadcrumbs true --out ../../../../../../mkdocs-website/docs/en/api/js ./src/index.js"
|
|
17
|
-
},
|
|
18
|
-
"author": "The Wails Team",
|
|
19
|
-
"license": "MIT",
|
|
20
|
-
"bugs": {
|
|
21
|
-
"url": "https://github.com/wailsapp/wails/issues"
|
|
22
|
-
},
|
|
23
|
-
"homepage": "https://wails.io",
|
|
24
|
-
"private": false,
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"rimraf": "^5.0.5",
|
|
27
|
-
"typedoc": "^0.25.7",
|
|
28
|
-
"typedoc-plugin-markdown": "^3.17.1",
|
|
29
|
-
"typescript": "^5.3.3"
|
|
30
|
-
}
|
|
31
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@wailsio/runtime",
|
|
3
|
+
"version": "3.0.0-alpha.22",
|
|
4
|
+
"description": "Wails Runtime",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/wailsapp/wails.git"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"prebuild:types": "rimraf ./types",
|
|
13
|
+
"build:types": "npx -p typescript tsc src/index.js --declaration --allowJs --emitDeclarationOnly --outDir types",
|
|
14
|
+
"postbuild:types": "wails3 task generate:events",
|
|
15
|
+
"build:docs": "npx typedoc ./src/index.js",
|
|
16
|
+
"build:docs:md": "npx typedoc --plugin typedoc-plugin-markdown --namedAnchors true --hideBreadcrumbs true --out ../../../../../../mkdocs-website/docs/en/api/js ./src/index.js"
|
|
17
|
+
},
|
|
18
|
+
"author": "The Wails Team",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/wailsapp/wails/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://wails.io",
|
|
24
|
+
"private": false,
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"rimraf": "^5.0.5",
|
|
27
|
+
"typedoc": "^0.25.7",
|
|
28
|
+
"typedoc-plugin-markdown": "^3.17.1",
|
|
29
|
+
"typescript": "^5.3.3"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"nanoid": "^5.0.7"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/application.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
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
|
-
const call = newRuntimeCallerWithID(objectNames.Application, '');
|
|
15
|
-
|
|
16
|
-
const HideMethod = 0;
|
|
17
|
-
const ShowMethod = 1;
|
|
18
|
-
const QuitMethod = 2;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Hides a certain method by calling the HideMethod function.
|
|
22
|
-
*
|
|
23
|
-
* @return {Promise<void>}
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
export function Hide() {
|
|
27
|
-
return call(HideMethod);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Calls the ShowMethod and returns the result.
|
|
32
|
-
*
|
|
33
|
-
* @return {Promise<void>}
|
|
34
|
-
*/
|
|
35
|
-
export function Show() {
|
|
36
|
-
return call(ShowMethod);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Calls the QuitMethod to terminate the program.
|
|
41
|
-
*
|
|
42
|
-
* @return {Promise<void>}
|
|
43
|
-
*/
|
|
44
|
-
export function Quit() {
|
|
45
|
-
return call(QuitMethod);
|
|
46
|
-
}
|
|
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
|
+
const call = newRuntimeCallerWithID(objectNames.Application, '');
|
|
15
|
+
|
|
16
|
+
const HideMethod = 0;
|
|
17
|
+
const ShowMethod = 1;
|
|
18
|
+
const QuitMethod = 2;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Hides a certain method by calling the HideMethod function.
|
|
22
|
+
*
|
|
23
|
+
* @return {Promise<void>}
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export function Hide() {
|
|
27
|
+
return call(HideMethod);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Calls the ShowMethod and returns the result.
|
|
32
|
+
*
|
|
33
|
+
* @return {Promise<void>}
|
|
34
|
+
*/
|
|
35
|
+
export function Show() {
|
|
36
|
+
return call(ShowMethod);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Calls the QuitMethod to terminate the program.
|
|
41
|
+
*
|
|
42
|
+
* @return {Promise<void>}
|
|
43
|
+
*/
|
|
44
|
+
export function Quit() {
|
|
45
|
+
return call(QuitMethod);
|
|
46
|
+
}
|
package/src/browser.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
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 {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
13
|
-
|
|
14
|
-
const call = newRuntimeCallerWithID(objectNames.Browser, '');
|
|
15
|
-
const BrowserOpenURL = 0;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Open a browser window to the given URL
|
|
19
|
-
* @param {string} url - The URL to open
|
|
20
|
-
* @returns {Promise<string>}
|
|
21
|
-
*/
|
|
22
|
-
export function OpenURL(url) {
|
|
23
|
-
return call(BrowserOpenURL, {url});
|
|
24
|
-
}
|
|
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 {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
13
|
+
|
|
14
|
+
const call = newRuntimeCallerWithID(objectNames.Browser, '');
|
|
15
|
+
const BrowserOpenURL = 0;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Open a browser window to the given URL
|
|
19
|
+
* @param {string} url - The URL to open
|
|
20
|
+
* @returns {Promise<string>}
|
|
21
|
+
*/
|
|
22
|
+
export function OpenURL(url) {
|
|
23
|
+
return call(BrowserOpenURL, {url});
|
|
24
|
+
}
|
package/src/calls.js
CHANGED
|
@@ -1,161 +1,180 @@
|
|
|
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 { newRuntimeCallerWithID, objectNames } from "./runtime";
|
|
13
|
-
import { nanoid } from 'nanoid/non-secure';
|
|
14
|
-
|
|
15
|
-
// Setup
|
|
16
|
-
window._wails = window._wails || {};
|
|
17
|
-
window._wails.callResultHandler = resultHandler;
|
|
18
|
-
window._wails.callErrorHandler = errorHandler;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const CallBinding = 0;
|
|
22
|
-
const call = newRuntimeCallerWithID(objectNames.Call, '');
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @param {string}
|
|
43
|
-
* @param {
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @param {string}
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
callResponses.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* @param {
|
|
87
|
-
* @
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @
|
|
136
|
-
* @
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
*
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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 { newRuntimeCallerWithID, objectNames } from "./runtime";
|
|
13
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
14
|
+
|
|
15
|
+
// Setup
|
|
16
|
+
window._wails = window._wails || {};
|
|
17
|
+
window._wails.callResultHandler = resultHandler;
|
|
18
|
+
window._wails.callErrorHandler = errorHandler;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const CallBinding = 0;
|
|
22
|
+
const call = newRuntimeCallerWithID(objectNames.Call, '');
|
|
23
|
+
const cancelCall = newRuntimeCallerWithID(objectNames.CancelCall, '');
|
|
24
|
+
let callResponses = new Map();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Generates a unique ID using the nanoid library.
|
|
28
|
+
*
|
|
29
|
+
* @return {string} - A unique ID that does not exist in the callResponses set.
|
|
30
|
+
*/
|
|
31
|
+
function generateID() {
|
|
32
|
+
let result;
|
|
33
|
+
do {
|
|
34
|
+
result = nanoid();
|
|
35
|
+
} while (callResponses.has(result));
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Handles the result of a call request.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} id - The id of the request to handle the result for.
|
|
43
|
+
* @param {string} data - The result data of the request.
|
|
44
|
+
* @param {boolean} isJSON - Indicates whether the data is JSON or not.
|
|
45
|
+
*
|
|
46
|
+
* @return {undefined} - This method does not return any value.
|
|
47
|
+
*/
|
|
48
|
+
function resultHandler(id, data, isJSON) {
|
|
49
|
+
const promiseHandler = getAndDeleteResponse(id);
|
|
50
|
+
if (promiseHandler) {
|
|
51
|
+
promiseHandler.resolve(isJSON ? JSON.parse(data) : data);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Handles the error from a call request.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} id - The id of the promise handler.
|
|
59
|
+
* @param {string} message - The error message to reject the promise handler with.
|
|
60
|
+
*
|
|
61
|
+
* @return {void}
|
|
62
|
+
*/
|
|
63
|
+
function errorHandler(id, message) {
|
|
64
|
+
const promiseHandler = getAndDeleteResponse(id);
|
|
65
|
+
if (promiseHandler) {
|
|
66
|
+
promiseHandler.reject(message);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves and removes the response associated with the given ID from the callResponses map.
|
|
72
|
+
*
|
|
73
|
+
* @param {any} id - The ID of the response to be retrieved and removed.
|
|
74
|
+
*
|
|
75
|
+
* @returns {any} The response object associated with the given ID.
|
|
76
|
+
*/
|
|
77
|
+
function getAndDeleteResponse(id) {
|
|
78
|
+
const response = callResponses.get(id);
|
|
79
|
+
callResponses.delete(id);
|
|
80
|
+
return response;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Executes a call using the provided type and options.
|
|
85
|
+
*
|
|
86
|
+
* @param {string|number} type - The type of call to execute.
|
|
87
|
+
* @param {Object} [options={}] - Additional options for the call.
|
|
88
|
+
* @return {Promise} - A promise that will be resolved or rejected based on the result of the call. It also has a cancel method to cancel a long running request.
|
|
89
|
+
*/
|
|
90
|
+
function callBinding(type, options = {}) {
|
|
91
|
+
const id = generateID();
|
|
92
|
+
const doCancel = () => { return cancelCall(type, {"call-id": id}) };
|
|
93
|
+
let queuedCancel = false, callRunning = false;
|
|
94
|
+
let p = new Promise((resolve, reject) => {
|
|
95
|
+
options["call-id"] = id;
|
|
96
|
+
callResponses.set(id, { resolve, reject });
|
|
97
|
+
call(type, options).
|
|
98
|
+
then((_) => {
|
|
99
|
+
callRunning = true;
|
|
100
|
+
if (queuedCancel) {
|
|
101
|
+
return doCancel();
|
|
102
|
+
}
|
|
103
|
+
}).
|
|
104
|
+
catch((error) => {
|
|
105
|
+
reject(error);
|
|
106
|
+
callResponses.delete(id);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
p.cancel = () => {
|
|
110
|
+
if (callRunning) {
|
|
111
|
+
return doCancel();
|
|
112
|
+
} else {
|
|
113
|
+
queuedCancel = true;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return p;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Call method.
|
|
122
|
+
*
|
|
123
|
+
* @param {Object} options - The options for the method.
|
|
124
|
+
* @returns {Object} - The result of the call.
|
|
125
|
+
*/
|
|
126
|
+
export function Call(options) {
|
|
127
|
+
return callBinding(CallBinding, options);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Executes a method by name.
|
|
132
|
+
*
|
|
133
|
+
* @param {string} name - The name of the method in the format 'package.struct.method'.
|
|
134
|
+
* @param {...*} args - The arguments to pass to the method.
|
|
135
|
+
* @throws {Error} If the name is not a string or is not in the correct format.
|
|
136
|
+
* @returns {*} The result of the method execution.
|
|
137
|
+
*/
|
|
138
|
+
export function ByName(name, ...args) {
|
|
139
|
+
if (typeof name !== "string" || name.split(".").length !== 3) {
|
|
140
|
+
throw new Error("CallByName requires a string in the format 'package.struct.method'");
|
|
141
|
+
}
|
|
142
|
+
let [packageName, structName, methodName] = name.split(".");
|
|
143
|
+
return callBinding(CallBinding, {
|
|
144
|
+
packageName,
|
|
145
|
+
structName,
|
|
146
|
+
methodName,
|
|
147
|
+
args
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Calls a method by its ID with the specified arguments.
|
|
153
|
+
*
|
|
154
|
+
* @param {number} methodID - The ID of the method to call.
|
|
155
|
+
* @param {...*} args - The arguments to pass to the method.
|
|
156
|
+
* @return {*} - The result of the method call.
|
|
157
|
+
*/
|
|
158
|
+
export function ByID(methodID, ...args) {
|
|
159
|
+
return callBinding(CallBinding, {
|
|
160
|
+
methodID,
|
|
161
|
+
args
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Calls a method on a plugin.
|
|
167
|
+
*
|
|
168
|
+
* @param {string} pluginName - The name of the plugin.
|
|
169
|
+
* @param {string} methodName - The name of the method to call.
|
|
170
|
+
* @param {...*} args - The arguments to pass to the method.
|
|
171
|
+
* @returns {*} - The result of the method call.
|
|
172
|
+
*/
|
|
173
|
+
export function Plugin(pluginName, methodName, ...args) {
|
|
174
|
+
return callBinding(CallBinding, {
|
|
175
|
+
packageName: "wails-plugins",
|
|
176
|
+
structName: pluginName,
|
|
177
|
+
methodName,
|
|
178
|
+
args
|
|
179
|
+
});
|
|
180
|
+
}
|
package/src/clipboard.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
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
|
-
|
|
15
|
-
const call = newRuntimeCallerWithID(objectNames.Clipboard, '');
|
|
16
|
-
const ClipboardSetText = 0;
|
|
17
|
-
const ClipboardText = 1;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Sets the text to the Clipboard.
|
|
21
|
-
*
|
|
22
|
-
* @param {string} text - The text to be set to the Clipboard.
|
|
23
|
-
* @return {Promise} - A Promise that resolves when the operation is successful.
|
|
24
|
-
*/
|
|
25
|
-
export function SetText(text) {
|
|
26
|
-
return call(ClipboardSetText, {text});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Get the Clipboard text
|
|
31
|
-
* @returns {Promise<string>} A promise that resolves with the text from the Clipboard.
|
|
32
|
-
*/
|
|
33
|
-
export function Text() {
|
|
34
|
-
return call(ClipboardText);
|
|
35
|
-
}
|
|
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
|
+
|
|
15
|
+
const call = newRuntimeCallerWithID(objectNames.Clipboard, '');
|
|
16
|
+
const ClipboardSetText = 0;
|
|
17
|
+
const ClipboardText = 1;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Sets the text to the Clipboard.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} text - The text to be set to the Clipboard.
|
|
23
|
+
* @return {Promise} - A Promise that resolves when the operation is successful.
|
|
24
|
+
*/
|
|
25
|
+
export function SetText(text) {
|
|
26
|
+
return call(ClipboardSetText, {text});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the Clipboard text
|
|
31
|
+
* @returns {Promise<string>} A promise that resolves with the text from the Clipboard.
|
|
32
|
+
*/
|
|
33
|
+
export function Text() {
|
|
34
|
+
return call(ClipboardText);
|
|
35
|
+
}
|