@wailsio/runtime 3.0.0-alpha.55 → 3.0.0-alpha.56
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/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Call.RuntimeError.html +11 -0
- package/docs/classes/Events.WailsEvent.html +2 -2
- package/docs/functions/Application.Hide.html +1 -1
- package/docs/functions/Application.Quit.html +1 -1
- package/docs/functions/Application.Show.html +1 -1
- package/docs/functions/Browser.OpenURL.html +1 -1
- package/docs/functions/Call.ByID.html +4 -3
- package/docs/functions/Call.ByName.html +4 -4
- package/docs/functions/Call.Call.html +9 -4
- package/docs/functions/Clipboard.SetText.html +1 -1
- package/docs/functions/Clipboard.Text.html +1 -1
- package/docs/functions/Create.Any.html +1 -1
- package/docs/functions/Create.Array.html +1 -1
- package/docs/functions/Create.ByteSlice.html +1 -1
- package/docs/functions/Create.Map.html +1 -1
- package/docs/functions/Create.Nullable.html +1 -1
- package/docs/functions/Create.Struct.html +1 -1
- package/docs/functions/Dialogs.Error.html +1 -1
- package/docs/functions/Dialogs.Info.html +1 -1
- package/docs/functions/Dialogs.OpenFile.html +1 -1
- package/docs/functions/Dialogs.Question.html +1 -1
- package/docs/functions/Dialogs.SaveFile.html +1 -1
- package/docs/functions/Dialogs.Warning.html +1 -1
- package/docs/functions/Events.Emit.html +1 -1
- package/docs/functions/Events.Off.html +1 -1
- package/docs/functions/Events.OffAll.html +1 -1
- package/docs/functions/Events.On.html +1 -1
- package/docs/functions/Events.OnMultiple.html +1 -1
- package/docs/functions/Events.Once.html +1 -1
- package/docs/functions/Events.setup.html +1 -1
- package/docs/functions/Flags.GetFlag.html +1 -1
- package/docs/functions/Screens.GetAll.html +1 -1
- package/docs/functions/Screens.GetCurrent.html +1 -1
- package/docs/functions/Screens.GetPrimary.html +1 -1
- package/docs/functions/System.Capabilities.html +1 -1
- package/docs/functions/System.Environment.html +1 -1
- package/docs/functions/System.IsAMD64.html +1 -1
- package/docs/functions/System.IsARM.html +1 -1
- package/docs/functions/System.IsARM64.html +1 -1
- package/docs/functions/System.IsDarkMode.html +1 -1
- package/docs/functions/System.IsDebug.html +1 -1
- package/docs/functions/System.IsLinux.html +1 -1
- package/docs/functions/System.IsMac.html +1 -1
- package/docs/functions/System.IsWindows.html +1 -1
- package/docs/functions/System.invoke.html +1 -1
- package/docs/functions/WML.Enable.html +1 -1
- package/docs/functions/WML.Reload.html +1 -1
- package/docs/functions/init.html +1 -1
- package/docs/interfaces/Call.CallOptions.html +7 -0
- package/docs/interfaces/Dialogs.Button.html +4 -4
- package/docs/interfaces/Dialogs.FileFilter.html +3 -3
- package/docs/interfaces/Dialogs.MessageDialogOptions.html +5 -5
- package/docs/interfaces/Dialogs.OpenFileDialogOptions.html +17 -17
- package/docs/interfaces/Dialogs.SaveFileDialogOptions.html +18 -18
- package/docs/interfaces/Screens.Rect.html +5 -5
- package/docs/interfaces/Screens.Screen.html +13 -13
- package/docs/interfaces/Screens.Size.html +3 -3
- package/docs/interfaces/System.EnvironmentInfo.html +6 -6
- package/docs/interfaces/System.OSInfo.html +5 -5
- package/docs/modules/Application.html +1 -1
- package/docs/modules/Browser.html +1 -1
- package/docs/modules/Call.html +3 -2
- package/docs/modules/Clipboard.html +1 -1
- package/docs/modules/Create.html +1 -1
- package/docs/modules/Dialogs.html +1 -1
- package/docs/modules/Events.html +1 -1
- package/docs/modules/Flags.html +1 -1
- package/docs/modules/Screens.html +1 -1
- package/docs/modules/System.html +1 -1
- package/docs/modules/WML.html +1 -1
- package/docs/variables/Events.Types.html +1 -1
- package/docs/variables/Window.html +1 -1
- package/package.json +1 -1
- package/src/calls.js +103 -56
- package/src/dialogs.js +2 -2
- package/src/runtime.js +17 -48
- package/types/calls.d.ts +55 -19
- package/types/runtime.d.ts +2 -2
- package/docs/functions/Call.Plugin.html +0 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
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/
|
|
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/29c0d150/v3/internal/runtime/desktop/@wailsio/runtime/src/window.js#L636">src/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
package/src/calls.js
CHANGED
|
@@ -48,7 +48,17 @@ function generateID() {
|
|
|
48
48
|
function resultHandler(id, data, isJSON) {
|
|
49
49
|
const promiseHandler = getAndDeleteResponse(id);
|
|
50
50
|
if (promiseHandler) {
|
|
51
|
-
|
|
51
|
+
if (!data) {
|
|
52
|
+
promiseHandler.resolve();
|
|
53
|
+
} else if (!isJSON) {
|
|
54
|
+
promiseHandler.resolve(data);
|
|
55
|
+
} else {
|
|
56
|
+
try {
|
|
57
|
+
promiseHandler.resolve(JSON.parse(data));
|
|
58
|
+
} catch (err) {
|
|
59
|
+
promiseHandler.reject(new TypeError("could not parse result: " + err.message, { cause: err }));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
52
62
|
}
|
|
53
63
|
}
|
|
54
64
|
|
|
@@ -56,14 +66,48 @@ function resultHandler(id, data, isJSON) {
|
|
|
56
66
|
* Handles the error from a call request.
|
|
57
67
|
*
|
|
58
68
|
* @param {string} id - The id of the promise handler.
|
|
59
|
-
* @param {string}
|
|
69
|
+
* @param {string} data - The error data to reject the promise handler with.
|
|
70
|
+
* @param {boolean} isJSON - Indicates whether the data is JSON or not.
|
|
60
71
|
*
|
|
61
72
|
* @return {void}
|
|
62
73
|
*/
|
|
63
|
-
function errorHandler(id,
|
|
74
|
+
function errorHandler(id, data, isJSON) {
|
|
64
75
|
const promiseHandler = getAndDeleteResponse(id);
|
|
65
76
|
if (promiseHandler) {
|
|
66
|
-
|
|
77
|
+
if (!isJSON) {
|
|
78
|
+
promiseHandler.reject(new Error(data));
|
|
79
|
+
} else {
|
|
80
|
+
let error;
|
|
81
|
+
try {
|
|
82
|
+
error = JSON.parse(data);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
promiseHandler.reject(new TypeError("could not parse error: " + err.message, { cause: err }));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let options = {};
|
|
89
|
+
if (error.cause) {
|
|
90
|
+
options.cause = error.cause;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let exception;
|
|
94
|
+
switch (error.kind) {
|
|
95
|
+
case "ReferenceError":
|
|
96
|
+
exception = new ReferenceError(error.message, options);
|
|
97
|
+
break;
|
|
98
|
+
case "TypeError":
|
|
99
|
+
exception = new TypeError(error.message, options);
|
|
100
|
+
break;
|
|
101
|
+
case "RuntimeError":
|
|
102
|
+
exception = new RuntimeError(error.message, options);
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
exception = new Error(error.message, options);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
promiseHandler.reject(exception);
|
|
110
|
+
}
|
|
67
111
|
}
|
|
68
112
|
}
|
|
69
113
|
|
|
@@ -81,30 +125,59 @@ function getAndDeleteResponse(id) {
|
|
|
81
125
|
}
|
|
82
126
|
|
|
83
127
|
/**
|
|
84
|
-
*
|
|
128
|
+
* Collects all required information for a binding call.
|
|
85
129
|
*
|
|
86
|
-
* @
|
|
87
|
-
* @
|
|
88
|
-
* @
|
|
130
|
+
* @typedef {Object} CallOptions
|
|
131
|
+
* @property {number} [methodID] - The numeric ID of the bound method to call.
|
|
132
|
+
* @property {string} [methodName] - The fully qualified name of the bound method to call.
|
|
133
|
+
* @property {any[]} args - Arguments to be passed into the bound method.
|
|
89
134
|
*/
|
|
90
|
-
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Exception class that will be thrown in case the bound method returns an error.
|
|
138
|
+
* The value of the {@link RuntimeError#name} property is "RuntimeError".
|
|
139
|
+
*/
|
|
140
|
+
export class RuntimeError extends Error {
|
|
141
|
+
/**
|
|
142
|
+
* Constructs a new RuntimeError instance.
|
|
143
|
+
*
|
|
144
|
+
* @param {string} message - The error message.
|
|
145
|
+
* @param {any[]} args - Optional arguments for the Error constructor.
|
|
146
|
+
*/
|
|
147
|
+
constructor(message, ...args) {
|
|
148
|
+
super(message, ...args);
|
|
149
|
+
this.name = "RuntimeError";
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Call a bound method according to the given call options.
|
|
155
|
+
*
|
|
156
|
+
* In case of failure, the returned promise will reject with an exception
|
|
157
|
+
* among ReferenceError (unknown method), TypeError (wrong argument count or type),
|
|
158
|
+
* {@link RuntimeError} (method returned an error), or other (network or internal errors).
|
|
159
|
+
* The exception might have a "cause" field with the value returned
|
|
160
|
+
* by the application- or service-level error marshaling functions.
|
|
161
|
+
*
|
|
162
|
+
* @param {CallOptions} options - A method call descriptor.
|
|
163
|
+
* @returns {Promise<any>} - The result of the call.
|
|
164
|
+
*/
|
|
165
|
+
export function Call(options) {
|
|
91
166
|
const id = generateID();
|
|
92
167
|
const doCancel = () => { return cancelCall(type, {"call-id": id}) };
|
|
93
168
|
let queuedCancel = false, callRunning = false;
|
|
94
169
|
let p = new Promise((resolve, reject) => {
|
|
95
170
|
options["call-id"] = id;
|
|
96
171
|
callResponses.set(id, { resolve, reject });
|
|
97
|
-
call(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
callResponses.delete(id);
|
|
107
|
-
});
|
|
172
|
+
call(CallBinding, options).then((_) => {
|
|
173
|
+
callRunning = true;
|
|
174
|
+
if (queuedCancel) {
|
|
175
|
+
return doCancel();
|
|
176
|
+
}
|
|
177
|
+
}).catch((error) => {
|
|
178
|
+
reject(error);
|
|
179
|
+
callResponses.delete(id);
|
|
180
|
+
});
|
|
108
181
|
});
|
|
109
182
|
p.cancel = () => {
|
|
110
183
|
if (callRunning) {
|
|
@@ -118,57 +191,31 @@ function callBinding(type, options = {}) {
|
|
|
118
191
|
}
|
|
119
192
|
|
|
120
193
|
/**
|
|
121
|
-
*
|
|
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.
|
|
194
|
+
* Calls a bound method by name with the specified arguments.
|
|
195
|
+
* See {@link Call} for details.
|
|
132
196
|
*
|
|
133
197
|
* @param {string} methodName - The name of the method in the format 'package.struct.method'.
|
|
134
|
-
* @param {
|
|
135
|
-
* @
|
|
136
|
-
* @returns {*} The result of the method execution.
|
|
198
|
+
* @param {any[]} args - The arguments to pass to the method.
|
|
199
|
+
* @returns {Promise<any>} The result of the method call.
|
|
137
200
|
*/
|
|
138
201
|
export function ByName(methodName, ...args) {
|
|
139
|
-
return
|
|
202
|
+
return Call({
|
|
140
203
|
methodName,
|
|
141
204
|
args
|
|
142
205
|
});
|
|
143
206
|
}
|
|
144
207
|
|
|
145
208
|
/**
|
|
146
|
-
* Calls a method by its ID with the specified arguments.
|
|
209
|
+
* Calls a method by its numeric ID with the specified arguments.
|
|
210
|
+
* See {@link Call} for details.
|
|
147
211
|
*
|
|
148
212
|
* @param {number} methodID - The ID of the method to call.
|
|
149
|
-
* @param {
|
|
150
|
-
* @return {
|
|
213
|
+
* @param {any[]} args - The arguments to pass to the method.
|
|
214
|
+
* @return {Promise<any>} - The result of the method call.
|
|
151
215
|
*/
|
|
152
216
|
export function ByID(methodID, ...args) {
|
|
153
|
-
return
|
|
217
|
+
return Call({
|
|
154
218
|
methodID,
|
|
155
219
|
args
|
|
156
220
|
});
|
|
157
221
|
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Calls a method on a plugin.
|
|
161
|
-
*
|
|
162
|
-
* @param {string} pluginName - The name of the plugin.
|
|
163
|
-
* @param {string} methodName - The name of the method to call.
|
|
164
|
-
* @param {...*} args - The arguments to pass to the method.
|
|
165
|
-
* @returns {*} - The result of the method call.
|
|
166
|
-
*/
|
|
167
|
-
export function Plugin(pluginName, methodName, ...args) {
|
|
168
|
-
return callBinding(CallBinding, {
|
|
169
|
-
packageName: "wails-plugins",
|
|
170
|
-
structName: pluginName,
|
|
171
|
-
methodName,
|
|
172
|
-
args
|
|
173
|
-
});
|
|
174
|
-
}
|
package/src/dialogs.js
CHANGED
|
@@ -135,12 +135,12 @@ function dialog(type, options = {}) {
|
|
|
135
135
|
function dialogResultCallback(id, data, isJSON) {
|
|
136
136
|
let p = dialogResponses.get(id);
|
|
137
137
|
if (p) {
|
|
138
|
+
dialogResponses.delete(id);
|
|
138
139
|
if (isJSON) {
|
|
139
140
|
p.resolve(JSON.parse(data));
|
|
140
141
|
} else {
|
|
141
142
|
p.resolve(data);
|
|
142
143
|
}
|
|
143
|
-
dialogResponses.delete(id);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -155,8 +155,8 @@ function dialogResultCallback(id, data, isJSON) {
|
|
|
155
155
|
function dialogErrorCallback(id, message) {
|
|
156
156
|
let p = dialogResponses.get(id);
|
|
157
157
|
if (p) {
|
|
158
|
-
p.reject(message);
|
|
159
158
|
dialogResponses.delete(id);
|
|
159
|
+
p.reject(new Error(message));
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
package/src/runtime.js
CHANGED
|
@@ -45,7 +45,7 @@ export function newRuntimeCaller(object, windowName) {
|
|
|
45
45
|
/**
|
|
46
46
|
* Creates a new runtime caller with specified ID.
|
|
47
47
|
*
|
|
48
|
-
* @param {
|
|
48
|
+
* @param {number} object - The object to invoke the method on.
|
|
49
49
|
* @param {string} windowName - The name of the window.
|
|
50
50
|
* @return {Function} - The new runtime caller function.
|
|
51
51
|
*/
|
|
@@ -57,8 +57,15 @@ export function newRuntimeCallerWithID(object, windowName) {
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
function runtimeCall(method, windowName, args) {
|
|
60
|
+
return runtimeCallWithID(null, method, windowName, args);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function runtimeCallWithID(objectID, method, windowName, args) {
|
|
60
64
|
let url = new URL(runtimeURL);
|
|
61
|
-
if(
|
|
65
|
+
if (objectID != null) {
|
|
66
|
+
url.searchParams.append("object", objectID);
|
|
67
|
+
}
|
|
68
|
+
if (method != null) {
|
|
62
69
|
url.searchParams.append("method", method);
|
|
63
70
|
}
|
|
64
71
|
let fetchOptions = {
|
|
@@ -72,52 +79,14 @@ function runtimeCall(method, windowName, args) {
|
|
|
72
79
|
}
|
|
73
80
|
fetchOptions.headers["x-wails-client-id"] = clientId;
|
|
74
81
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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;
|
|
82
|
+
let response = await fetch(url, fetchOptions);
|
|
83
|
+
if (!response.ok) {
|
|
84
|
+
throw new Error(await response.text());
|
|
102
85
|
}
|
|
103
|
-
|
|
104
|
-
|
|
86
|
+
|
|
87
|
+
if (response.headers.get("Content-Type") && response.headers.get("Content-Type").indexOf("application/json") !== -1) {
|
|
88
|
+
return response.json();
|
|
89
|
+
} else {
|
|
90
|
+
return response.text();
|
|
105
91
|
}
|
|
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
92
|
}
|
package/types/calls.d.ts
CHANGED
|
@@ -1,33 +1,69 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Call method.
|
|
2
|
+
* Call a bound method according to the given call options.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* In case of failure, the returned promise will reject with an exception
|
|
5
|
+
* among ReferenceError (unknown method), TypeError (wrong argument count or type),
|
|
6
|
+
* {@link RuntimeError} (method returned an error), or other (network or internal errors).
|
|
7
|
+
* The exception might have a "cause" field with the value returned
|
|
8
|
+
* by the application- or service-level error marshaling functions.
|
|
9
|
+
*
|
|
10
|
+
* @param {CallOptions} options - A method call descriptor.
|
|
11
|
+
* @returns {Promise<any>} - The result of the call.
|
|
6
12
|
*/
|
|
7
|
-
export function Call(options:
|
|
13
|
+
export function Call(options: CallOptions): Promise<any>;
|
|
8
14
|
/**
|
|
9
|
-
*
|
|
15
|
+
* Calls a bound method by name with the specified arguments.
|
|
16
|
+
* See {@link Call} for details.
|
|
10
17
|
*
|
|
11
18
|
* @param {string} methodName - The name of the method in the format 'package.struct.method'.
|
|
12
|
-
* @param {
|
|
13
|
-
* @
|
|
14
|
-
* @returns {*} The result of the method execution.
|
|
19
|
+
* @param {any[]} args - The arguments to pass to the method.
|
|
20
|
+
* @returns {Promise<any>} The result of the method call.
|
|
15
21
|
*/
|
|
16
|
-
export function ByName(methodName: string, ...args: any[]): any
|
|
22
|
+
export function ByName(methodName: string, ...args: any[]): Promise<any>;
|
|
17
23
|
/**
|
|
18
|
-
* Calls a method by its ID with the specified arguments.
|
|
24
|
+
* Calls a method by its numeric ID with the specified arguments.
|
|
25
|
+
* See {@link Call} for details.
|
|
19
26
|
*
|
|
20
27
|
* @param {number} methodID - The ID of the method to call.
|
|
21
|
-
* @param {
|
|
22
|
-
* @return {
|
|
28
|
+
* @param {any[]} args - The arguments to pass to the method.
|
|
29
|
+
* @return {Promise<any>} - The result of the method call.
|
|
23
30
|
*/
|
|
24
|
-
export function ByID(methodID: number, ...args: any[]): any
|
|
31
|
+
export function ByID(methodID: number, ...args: any[]): Promise<any>;
|
|
25
32
|
/**
|
|
26
|
-
*
|
|
33
|
+
* Collects all required information for a binding call.
|
|
27
34
|
*
|
|
28
|
-
* @
|
|
29
|
-
* @
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
35
|
+
* @typedef {Object} CallOptions
|
|
36
|
+
* @property {number} [methodID] - The numeric ID of the bound method to call.
|
|
37
|
+
* @property {string} [methodName] - The fully qualified name of the bound method to call.
|
|
38
|
+
* @property {any[]} args - Arguments to be passed into the bound method.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Exception class that will be thrown in case the bound method returns an error.
|
|
42
|
+
* The value of the {@link RuntimeError#name} property is "RuntimeError".
|
|
43
|
+
*/
|
|
44
|
+
export class RuntimeError extends Error {
|
|
45
|
+
/**
|
|
46
|
+
* Constructs a new RuntimeError instance.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} message - The error message.
|
|
49
|
+
* @param {any[]} args - Optional arguments for the Error constructor.
|
|
50
|
+
*/
|
|
51
|
+
constructor(message: string, ...args: any[]);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Collects all required information for a binding call.
|
|
32
55
|
*/
|
|
33
|
-
export
|
|
56
|
+
export type CallOptions = {
|
|
57
|
+
/**
|
|
58
|
+
* - The numeric ID of the bound method to call.
|
|
59
|
+
*/
|
|
60
|
+
methodID?: number;
|
|
61
|
+
/**
|
|
62
|
+
* - The fully qualified name of the bound method to call.
|
|
63
|
+
*/
|
|
64
|
+
methodName?: string;
|
|
65
|
+
/**
|
|
66
|
+
* - Arguments to be passed into the bound method.
|
|
67
|
+
*/
|
|
68
|
+
args: any[];
|
|
69
|
+
};
|
package/types/runtime.d.ts
CHANGED
|
@@ -9,11 +9,11 @@ export function newRuntimeCaller(object: any, windowName: string): Function;
|
|
|
9
9
|
/**
|
|
10
10
|
* Creates a new runtime caller with specified ID.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {number} object - The object to invoke the method on.
|
|
13
13
|
* @param {string} windowName - The name of the window.
|
|
14
14
|
* @return {Function} - The new runtime caller function.
|
|
15
15
|
*/
|
|
16
|
-
export function newRuntimeCallerWithID(object:
|
|
16
|
+
export function newRuntimeCallerWithID(object: number, windowName: string): Function;
|
|
17
17
|
export namespace objectNames {
|
|
18
18
|
let Call: number;
|
|
19
19
|
let Clipboard: number;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Plugin | @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="../modules/Call.html">Call</a></li><li><a href="Call.Plugin.html">Plugin</a></li></ul><h1>Function Plugin</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="Plugin" class="tsd-anchor"></a><span class="tsd-kind-call-signature">Plugin</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">pluginName</span>, <span class="tsd-kind-parameter">methodName</span>, <span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#Plugin" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Calls a method on a plugin.</p>
|
|
2
|
-
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">pluginName</span>: <span class="tsd-signature-type">string</span></span><div class="tsd-comment tsd-typography"><p>The name of the plugin.</p>
|
|
3
|
-
</div><div class="tsd-comment tsd-typography"></div></li><li><span><span class="tsd-kind-parameter">methodName</span>: <span class="tsd-signature-type">string</span></span><div class="tsd-comment tsd-typography"><p>The name of the method to call.</p>
|
|
4
|
-
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag ts-flagRest">Rest</code> <span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span>: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span><div class="tsd-comment tsd-typography"><p>The arguments to pass to the method.</p>
|
|
5
|
-
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><ul>
|
|
6
|
-
<li>The result of the method call.</li>
|
|
7
|
-
</ul>
|
|
8
|
-
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/wailsapp/wails/blob/b4c4cd8a/v3/internal/runtime/desktop/@wailsio/runtime/src/calls.js#L167">calls.js:167</a></li></ul></aside></li></ul></section></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>
|