ewvjs 1.0.8 → 1.0.10
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/README.md +3 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -52
- package/dist/platforms/windows.d.ts.map +1 -1
- package/dist/platforms/windows.js +9 -41
- package/dist/types.js +1 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +44 -10
- package/dist/webview.d.ts +6 -2
- package/dist/webview.d.ts.map +1 -1
- package/dist/webview.js +139 -47
- package/dist/window.d.ts +7 -13
- package/dist/window.d.ts.map +1 -1
- package/dist/window.js +187 -250
- package/native/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
- package/native/Microsoft.Web.WebView2.WinForms.dll +0 -0
- package/native/Microsoft.Web.WebView2.Wpf.dll +0 -0
- package/native/System.Buffers.dll +0 -0
- package/native/System.Collections.Immutable.dll +0 -0
- package/native/System.Memory.dll +0 -0
- package/native/System.Numerics.Vectors.dll +0 -0
- package/native/System.Reflection.Metadata.dll +0 -0
- package/native/System.Reflection.MetadataLoadContext.dll +0 -0
- package/native/System.Runtime.CompilerServices.Unsafe.dll +0 -0
- package/native/System.Text.Encoding.CodePages.dll +0 -0
- package/native/System.Text.Encodings.Web.dll +0 -0
- package/native/System.Text.Json.dll +0 -0
- package/native/System.Threading.Tasks.Extensions.dll +0 -0
- package/native/System.ValueTuple.dll +0 -0
- package/native/WebView.cjs +1 -1
- package/native/WebView.deps.json +117 -101
- package/native/WebView.dll +0 -0
- package/native/WebView.mjs +1 -1
- package/package.json +56 -55
- package/native/node_modules/node-api-dotnet/README.md +0 -80
- package/native/node_modules/node-api-dotnet/index.d.ts +0 -98
- package/native/node_modules/node-api-dotnet/linux-arm64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/native/node_modules/node-api-dotnet/linux-x64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/native/node_modules/node-api-dotnet/net10.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/native/node_modules/node-api-dotnet/net10.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/native/node_modules/node-api-dotnet/net10.0/Microsoft.JavaScript.NodeApi.runtimeconfig.json +0 -14
- package/native/node_modules/node-api-dotnet/net10.0.js +0 -2
- package/native/node_modules/node-api-dotnet/net472.d.ts +0 -2
- package/native/node_modules/node-api-dotnet/net8.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/native/node_modules/node-api-dotnet/net8.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/native/node_modules/node-api-dotnet/net8.0/Microsoft.JavaScript.NodeApi.runtimeconfig.json +0 -14
- package/native/node_modules/node-api-dotnet/net8.0.d.ts +0 -2
- package/native/node_modules/node-api-dotnet/net8.0.js +0 -2
- package/native/node_modules/node-api-dotnet/net9.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/native/node_modules/node-api-dotnet/net9.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/native/node_modules/node-api-dotnet/net9.0/Microsoft.JavaScript.NodeApi.runtimeconfig.json +0 -14
- package/native/node_modules/node-api-dotnet/net9.0.d.ts +0 -2
- package/native/node_modules/node-api-dotnet/net9.0.js +0 -2
- package/native/node_modules/node-api-dotnet/osx-arm64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/native/node_modules/node-api-dotnet/osx-x64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/native/node_modules/node-api-dotnet/package.json +0 -27
- package/src/README.md +0 -125
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Core.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Core.xml +0 -6817
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.WinForms.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.WinForms.xml +0 -510
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Wpf.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Wpf.xml +0 -1902
- package/src/csharp/bin/Release/net10.0-windows/WebView.cjs +0 -26
- package/src/csharp/bin/Release/net10.0-windows/WebView.d.ts +0 -8
- package/src/csharp/bin/Release/net10.0-windows/WebView.deps.json +0 -260
- package/src/csharp/bin/Release/net10.0-windows/WebView.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/WebView.mjs +0 -31
- package/src/csharp/bin/Release/net10.0-windows/WebView.pdb +0 -0
- package/src/csharp/bin/Release/net10.0-windows/import.cjs +0 -3
- package/src/csharp/bin/Release/net10.0-windows/runtimes/win-arm64/native/WebView2Loader.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/runtimes/win-x64/native/WebView2Loader.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/runtimes/win-x86/native/WebView2Loader.dll +0 -0
package/dist/window.js
CHANGED
|
@@ -1,34 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const utils_1 = require("./utils");
|
|
14
|
-
class Window {
|
|
1
|
+
import { getParamNames, generateId } from "./utils.js";
|
|
2
|
+
export class Window {
|
|
3
|
+
platform;
|
|
4
|
+
options;
|
|
5
|
+
controller;
|
|
6
|
+
_closedPromise;
|
|
7
|
+
_resolveClosed;
|
|
8
|
+
_menuCallbacks = new Map();
|
|
9
|
+
_exposedFunctions;
|
|
10
|
+
_isClosed = false;
|
|
11
|
+
_pendingApiInjection = null;
|
|
12
|
+
on_context_menu = () => null;
|
|
15
13
|
constructor(platform, options, exposedFunctions) {
|
|
16
|
-
this._menuCallbacks = new Map();
|
|
17
|
-
this._isClosed = false;
|
|
18
|
-
this.on_context_menu = () => null;
|
|
19
14
|
this.platform = platform;
|
|
20
|
-
this.options =
|
|
15
|
+
this.options = { ...options };
|
|
21
16
|
this._exposedFunctions = exposedFunctions;
|
|
22
17
|
this._closedPromise = new Promise((resolve) => {
|
|
23
18
|
this._resolveClosed = resolve;
|
|
24
19
|
});
|
|
25
20
|
const originalCallback = this.options.jsCallback;
|
|
26
|
-
this.options.jsCallback = (msg) =>
|
|
27
|
-
const result =
|
|
21
|
+
this.options.jsCallback = async (msg) => {
|
|
22
|
+
const result = await this._on_message(msg, this._exposedFunctions);
|
|
28
23
|
if (originalCallback)
|
|
29
|
-
|
|
24
|
+
await originalCallback(msg);
|
|
30
25
|
return result;
|
|
31
|
-
}
|
|
26
|
+
};
|
|
32
27
|
}
|
|
33
28
|
get closed() {
|
|
34
29
|
return this._closedPromise;
|
|
@@ -36,239 +31,190 @@ class Window {
|
|
|
36
31
|
get is_closed() {
|
|
37
32
|
return this._isClosed;
|
|
38
33
|
}
|
|
39
|
-
run() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const code = `if (window.ewvjs) { window.ewvjs._createApi(${JSON.stringify(funcList)}); }`;
|
|
48
|
-
setTimeout(() => this.evaluate_js(code).catch((err) => {
|
|
49
|
-
console.error('Failed to inject exposed functions API:', err);
|
|
50
|
-
}), 500);
|
|
51
|
-
}
|
|
52
|
-
return this.controller;
|
|
34
|
+
async run() {
|
|
35
|
+
this.controller = await this.platform.createWindow(this.options);
|
|
36
|
+
// Inject exposed functions API after DOM is ready
|
|
37
|
+
const funcList = Object.keys(this._exposedFunctions).map((name) => {
|
|
38
|
+
return {
|
|
39
|
+
func: name,
|
|
40
|
+
params: getParamNames(this._exposedFunctions[name]),
|
|
41
|
+
};
|
|
53
42
|
});
|
|
43
|
+
if (funcList.length > 0) {
|
|
44
|
+
const code = `window.ewvjs._createApi(${JSON.stringify(funcList)});`;
|
|
45
|
+
this._pendingApiInjection = code;
|
|
46
|
+
}
|
|
47
|
+
return this.controller;
|
|
54
48
|
}
|
|
55
|
-
_call(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
async _call(method, payload = null) {
|
|
50
|
+
if (this._isClosed) {
|
|
51
|
+
console.warn(`Cannot call ${method}: Window is closed`);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (!this.controller || !this.controller[method]) {
|
|
55
|
+
throw new Error(`Window not running or ${method} not supported`);
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const result = this.controller[method](payload);
|
|
59
|
+
// Check if method returns a Promise (node-api-dotnet JSCallback style)
|
|
60
|
+
if (result && typeof result.then === "function") {
|
|
61
|
+
return result;
|
|
63
62
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// Check if method returns a Promise (node-api-dotnet JSCallback style)
|
|
67
|
-
if (result && typeof result.then === 'function') {
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
63
|
+
else {
|
|
64
|
+
return result;
|
|
73
65
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
// If window was closed mid-operation, mark as closed and return null
|
|
69
|
+
if (err &&
|
|
70
|
+
err.message &&
|
|
71
|
+
err.message.includes("Window not initialized")) {
|
|
72
|
+
this._isClosed = true;
|
|
73
|
+
console.warn(`Window was closed during ${method} call`);
|
|
74
|
+
return null;
|
|
82
75
|
}
|
|
83
|
-
|
|
76
|
+
throw err;
|
|
77
|
+
}
|
|
84
78
|
}
|
|
85
79
|
// Core methods
|
|
86
|
-
|
|
87
|
-
return
|
|
88
|
-
return this._call('evaluate', script);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
evaluate(script) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return this.evaluate_js(script);
|
|
94
|
-
});
|
|
80
|
+
async evaluate(script) {
|
|
81
|
+
return this._call("evaluate", script);
|
|
95
82
|
}
|
|
96
|
-
close() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return result;
|
|
104
|
-
});
|
|
83
|
+
async close() {
|
|
84
|
+
if (this._isClosed)
|
|
85
|
+
return;
|
|
86
|
+
this._isClosed = true;
|
|
87
|
+
const result = await this._call("close");
|
|
88
|
+
this._resolveClosed();
|
|
89
|
+
return result;
|
|
105
90
|
}
|
|
106
|
-
destroy() {
|
|
107
|
-
return
|
|
108
|
-
return this._call('close');
|
|
109
|
-
});
|
|
91
|
+
async destroy() {
|
|
92
|
+
return this._call("close");
|
|
110
93
|
}
|
|
111
94
|
// Window state methods
|
|
112
|
-
maximize() {
|
|
113
|
-
return
|
|
95
|
+
async maximize() {
|
|
96
|
+
return this._call("maximize");
|
|
114
97
|
}
|
|
115
|
-
restore() {
|
|
116
|
-
return
|
|
98
|
+
async restore() {
|
|
99
|
+
return this._call("restore");
|
|
117
100
|
}
|
|
118
|
-
minimize() {
|
|
119
|
-
return
|
|
101
|
+
async minimize() {
|
|
102
|
+
return this._call("minimize");
|
|
120
103
|
}
|
|
121
|
-
focus() {
|
|
122
|
-
return
|
|
104
|
+
async focus() {
|
|
105
|
+
return this._call("focus");
|
|
123
106
|
}
|
|
124
|
-
show() {
|
|
125
|
-
return
|
|
107
|
+
async show() {
|
|
108
|
+
return this._call("show");
|
|
126
109
|
}
|
|
127
|
-
hide() {
|
|
128
|
-
return
|
|
110
|
+
async hide() {
|
|
111
|
+
return this._call("hide");
|
|
129
112
|
}
|
|
130
113
|
// Size and position methods
|
|
131
|
-
getSize() {
|
|
132
|
-
return
|
|
133
|
-
}
|
|
134
|
-
setSize(width, height) {
|
|
135
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
return this._call('setSize', { width, height });
|
|
137
|
-
});
|
|
114
|
+
async getSize() {
|
|
115
|
+
return this._call("getSize");
|
|
138
116
|
}
|
|
139
|
-
|
|
140
|
-
return
|
|
141
|
-
return this._call('setSize', { width, height });
|
|
142
|
-
});
|
|
117
|
+
async setSize(width, height) {
|
|
118
|
+
return this._call("setSize", { width, height });
|
|
143
119
|
}
|
|
144
|
-
|
|
145
|
-
return
|
|
120
|
+
async resize(width, height) {
|
|
121
|
+
return this._call("setSize", { width, height });
|
|
146
122
|
}
|
|
147
|
-
|
|
148
|
-
return
|
|
149
|
-
return this._call('setMinSize', { width, height });
|
|
150
|
-
});
|
|
123
|
+
async getMinSize() {
|
|
124
|
+
return this._call("getMinSize");
|
|
151
125
|
}
|
|
152
|
-
|
|
153
|
-
return
|
|
154
|
-
return this._call('setMinSize', { width, height });
|
|
155
|
-
});
|
|
126
|
+
async setMinSize(width, height) {
|
|
127
|
+
return this._call("setMinSize", { width, height });
|
|
156
128
|
}
|
|
157
|
-
getPosition() {
|
|
158
|
-
return
|
|
129
|
+
async getPosition() {
|
|
130
|
+
return this._call("getPosition");
|
|
159
131
|
}
|
|
160
|
-
setPosition(x, y) {
|
|
161
|
-
return
|
|
162
|
-
return this._call('setPosition', { x, y });
|
|
163
|
-
});
|
|
132
|
+
async setPosition(x, y) {
|
|
133
|
+
return this._call("setPosition", { x, y });
|
|
164
134
|
}
|
|
165
|
-
move(x, y) {
|
|
166
|
-
return
|
|
167
|
-
return this._call('move', { x, y });
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
get_position() {
|
|
171
|
-
return __awaiter(this, void 0, void 0, function* () { return this._call('getPosition'); });
|
|
172
|
-
}
|
|
173
|
-
set_position(x, y) {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
return this._call('setPosition', { x, y });
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
get_width() {
|
|
179
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
const size = yield this._call('getSize');
|
|
181
|
-
return size.width;
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
get_height() {
|
|
185
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
const size = yield this._call('getSize');
|
|
187
|
-
return size.height;
|
|
188
|
-
});
|
|
135
|
+
async move(x, y) {
|
|
136
|
+
return this._call("move", { x, y });
|
|
189
137
|
}
|
|
190
138
|
// Title methods
|
|
191
|
-
setTitle(title) {
|
|
192
|
-
return
|
|
193
|
-
return this._call('setTitle', title);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
set_title(title) {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
-
return this._call('setTitle', title);
|
|
199
|
-
});
|
|
139
|
+
async setTitle(title) {
|
|
140
|
+
return this._call("setTitle", title);
|
|
200
141
|
}
|
|
201
142
|
// Title bar methods
|
|
202
|
-
|
|
203
|
-
return
|
|
143
|
+
async showTitlebar() {
|
|
144
|
+
return this._call("setTitleBar", true);
|
|
204
145
|
}
|
|
205
|
-
|
|
206
|
-
return
|
|
146
|
+
async hideTitlebar() {
|
|
147
|
+
return this._call("setTitleBar", false);
|
|
207
148
|
}
|
|
208
149
|
// Icon methods
|
|
209
|
-
setIcon(iconPath) {
|
|
210
|
-
return
|
|
211
|
-
return this._call('setIcon', iconPath);
|
|
212
|
-
});
|
|
150
|
+
async setIcon(iconPath) {
|
|
151
|
+
return this._call("setIcon", iconPath);
|
|
213
152
|
}
|
|
214
153
|
// Cookie methods
|
|
215
|
-
|
|
216
|
-
return
|
|
154
|
+
async getCookies() {
|
|
155
|
+
return this._call("getCookies");
|
|
217
156
|
}
|
|
218
|
-
|
|
219
|
-
return
|
|
220
|
-
return this._call('setCookie', { name, value, domain, path });
|
|
221
|
-
});
|
|
157
|
+
async setCookie(name, value, domain = "", path = "/") {
|
|
158
|
+
return this._call("setCookie", { name, value, domain, path });
|
|
222
159
|
}
|
|
223
|
-
|
|
224
|
-
return
|
|
225
|
-
}
|
|
226
|
-
_on_message(message, exposedFunctions) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
if (funcName === 'context_menu_requested') {
|
|
250
|
-
return this._handleContextMenu(params);
|
|
251
|
-
}
|
|
252
|
-
// Handle window state methods
|
|
253
|
-
if (funcName.startsWith('window_')) {
|
|
254
|
-
const method = funcName.substring(7); // Remove 'window_' prefix
|
|
255
|
-
if (typeof this[method] === 'function') {
|
|
256
|
-
yield this[method]();
|
|
257
|
-
}
|
|
258
|
-
return null;
|
|
160
|
+
async clearCookies() {
|
|
161
|
+
return this._call("clearCookies");
|
|
162
|
+
}
|
|
163
|
+
async _on_message(message, exposedFunctions) {
|
|
164
|
+
try {
|
|
165
|
+
const data = typeof message === "string" ? JSON.parse(message) : message;
|
|
166
|
+
if (!Array.isArray(data))
|
|
167
|
+
return null;
|
|
168
|
+
const funcName = data[0];
|
|
169
|
+
const rawParams = data[1];
|
|
170
|
+
const id = data[2];
|
|
171
|
+
const params = this._parseParams(rawParams);
|
|
172
|
+
// Handle special messages
|
|
173
|
+
if (funcName === "closed") {
|
|
174
|
+
this._isClosed = true;
|
|
175
|
+
this._resolveClosed();
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
if (funcName === "dom_ready") {
|
|
179
|
+
// DOM is ready, inject the API now
|
|
180
|
+
if (this._pendingApiInjection) {
|
|
181
|
+
await this.evaluate(this._pendingApiInjection).catch((err) => {
|
|
182
|
+
console.error("Failed to inject exposed functions API:", err);
|
|
183
|
+
});
|
|
184
|
+
this._pendingApiInjection = null;
|
|
259
185
|
}
|
|
260
|
-
|
|
261
|
-
return this._handleExposedFunction(funcName, params, id, exposedFunctions);
|
|
186
|
+
return null;
|
|
262
187
|
}
|
|
263
|
-
|
|
188
|
+
if (funcName === "console") {
|
|
189
|
+
console.log("WebView Console:", ...params);
|
|
264
190
|
return null;
|
|
265
191
|
}
|
|
266
|
-
|
|
192
|
+
if (funcName === "menu_click") {
|
|
193
|
+
return this._handleMenuClick(params);
|
|
194
|
+
}
|
|
195
|
+
if (funcName === "context_menu_requested") {
|
|
196
|
+
return this._handleContextMenu(params);
|
|
197
|
+
}
|
|
198
|
+
// Handle window state methods
|
|
199
|
+
if (funcName.startsWith("window_")) {
|
|
200
|
+
const method = funcName.substring(7); // Remove 'window_' prefix
|
|
201
|
+
if (typeof this[method] === "function") {
|
|
202
|
+
await this[method]();
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
// Handle exposed function calls
|
|
207
|
+
return this._handleExposedFunction(funcName, params, id, exposedFunctions);
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
267
212
|
}
|
|
268
213
|
_parseParams(rawParams) {
|
|
269
214
|
let params = [];
|
|
270
215
|
if (rawParams) {
|
|
271
|
-
if (typeof rawParams ===
|
|
216
|
+
if (typeof rawParams === "string" &&
|
|
217
|
+
(rawParams.startsWith("[") || rawParams.startsWith("{"))) {
|
|
272
218
|
try {
|
|
273
219
|
const parsed = JSON.parse(rawParams);
|
|
274
220
|
params = Array.isArray(parsed) ? parsed : [parsed];
|
|
@@ -290,52 +236,44 @@ class Window {
|
|
|
290
236
|
callback();
|
|
291
237
|
return null;
|
|
292
238
|
}
|
|
293
|
-
_handleContextMenu(params) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
return this._processMenu(customMenu);
|
|
299
|
-
}
|
|
239
|
+
async _handleContextMenu(params) {
|
|
240
|
+
if (this.on_context_menu) {
|
|
241
|
+
const customMenu = await this.on_context_menu(params);
|
|
242
|
+
if (customMenu) {
|
|
243
|
+
return this._processMenu(customMenu);
|
|
300
244
|
}
|
|
301
|
-
|
|
302
|
-
|
|
245
|
+
}
|
|
246
|
+
return null;
|
|
303
247
|
}
|
|
304
|
-
_handleExposedFunction(funcName, params, id, exposedFunctions) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
});
|
|
248
|
+
async _handleExposedFunction(funcName, params, id, exposedFunctions) {
|
|
249
|
+
const func = exposedFunctions[funcName];
|
|
250
|
+
if (!func)
|
|
251
|
+
return null;
|
|
252
|
+
try {
|
|
253
|
+
const result = await func(...params);
|
|
254
|
+
await this._sendSuccessResponse(funcName, id, result);
|
|
255
|
+
return result !== undefined ? result : null;
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
await this._sendErrorResponse(funcName, id, err);
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
319
261
|
}
|
|
320
|
-
_sendSuccessResponse(funcName, id, result) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
yield this.evaluate_js(code);
|
|
325
|
-
});
|
|
262
|
+
async _sendSuccessResponse(funcName, id, result) {
|
|
263
|
+
const resJson = JSON.stringify(result);
|
|
264
|
+
const code = `window.ewvjs._returnValuesCallbacks["${funcName}"]["${id}"]({value: ${JSON.stringify(resJson)}, isError: false})`;
|
|
265
|
+
await this.evaluate(code);
|
|
326
266
|
}
|
|
327
|
-
_sendErrorResponse(funcName, id, err) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
yield this.evaluate_js(code);
|
|
332
|
-
});
|
|
267
|
+
async _sendErrorResponse(funcName, id, err) {
|
|
268
|
+
const errObj = { message: err.message, name: err.name, stack: err.stack };
|
|
269
|
+
const code = `window.ewvjs._returnValuesCallbacks["${funcName}"]["${id}"]({value: ${JSON.stringify(JSON.stringify(errObj))}, isError: true})`;
|
|
270
|
+
await this.evaluate(code);
|
|
333
271
|
}
|
|
334
272
|
_processMenu(menu) {
|
|
335
273
|
return menu.map((item) => {
|
|
336
|
-
const newItem =
|
|
274
|
+
const newItem = { ...item };
|
|
337
275
|
if (newItem.click) {
|
|
338
|
-
const id = newItem.id ||
|
|
276
|
+
const id = newItem.id || generateId();
|
|
339
277
|
newItem.id = id;
|
|
340
278
|
this._menuCallbacks.set(id, newItem.click);
|
|
341
279
|
delete newItem.click;
|
|
@@ -347,4 +285,3 @@ class Window {
|
|
|
347
285
|
});
|
|
348
286
|
}
|
|
349
287
|
}
|
|
350
|
-
exports.Window = Window;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/native/WebView.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Generated by: Microsoft.JavaScript.NodeApi.Generator 0.9.0.0
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
|
|
5
|
-
const dotnet = require('node-api-dotnet/
|
|
5
|
+
const dotnet = require('node-api-dotnet/net472');
|
|
6
6
|
const path = require('node:path');
|
|
7
7
|
// @ts-ignore - https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65252
|
|
8
8
|
const { dlopen, platform, arch } = require('node:process');
|