@lvce-editor/main-process 3.0.0 → 4.0.0
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/dist/mainProcessMain.js +359 -986
- package/package.json +2 -2
package/dist/mainProcessMain.js
CHANGED
|
@@ -4,15 +4,15 @@ import process$1 from 'node:process';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { inspect } from 'node:util';
|
|
6
6
|
import { spawn } from 'node:child_process';
|
|
7
|
-
import {
|
|
7
|
+
import { Console } from 'node:console';
|
|
8
8
|
import { createWriteStream, readFileSync } from 'node:fs';
|
|
9
|
+
import { tmpdir, homedir } from 'node:os';
|
|
9
10
|
import * as NodePath from 'node:path';
|
|
10
11
|
import { dirname } from 'node:path';
|
|
11
12
|
import require$$1 from 'tty';
|
|
12
13
|
import require$$1$1 from 'util';
|
|
13
14
|
import require$$0 from 'os';
|
|
14
|
-
import {
|
|
15
|
-
import { Console } from 'node:console';
|
|
15
|
+
import { MessageChannel } from 'node:worker_threads';
|
|
16
16
|
|
|
17
17
|
function escapeStringRegexp(string) {
|
|
18
18
|
if (typeof string !== 'string') {
|
|
@@ -779,7 +779,7 @@ const getNewLineIndex$2 = (string, startIndex = undefined) => {
|
|
|
779
779
|
|
|
780
780
|
// TODO disable logging via environment variable, don't enable logging during tests
|
|
781
781
|
|
|
782
|
-
const state$
|
|
782
|
+
const state$6 = {
|
|
783
783
|
console: undefined
|
|
784
784
|
};
|
|
785
785
|
const createConsole = () => {
|
|
@@ -789,8 +789,8 @@ const createConsole = () => {
|
|
|
789
789
|
return logger;
|
|
790
790
|
};
|
|
791
791
|
const getOrCreateLogger = () => {
|
|
792
|
-
state$
|
|
793
|
-
return state$
|
|
792
|
+
state$6.console ||= createConsole();
|
|
793
|
+
return state$6.console;
|
|
794
794
|
};
|
|
795
795
|
const info = (...args) => {
|
|
796
796
|
const logger = getOrCreateLogger();
|
|
@@ -1163,39 +1163,39 @@ function requireLib () {
|
|
|
1163
1163
|
const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
|
|
1164
1164
|
const BRACKET = /^[()[\]{}]$/;
|
|
1165
1165
|
let tokenize;
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
}
|
|
1173
|
-
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) === "</")) {
|
|
1174
|
-
return "jsxIdentifier";
|
|
1175
|
-
}
|
|
1176
|
-
if (token.value[0] !== token.value[0].toLowerCase()) {
|
|
1177
|
-
return "capitalized";
|
|
1178
|
-
}
|
|
1166
|
+
const JSX_TAG = /^[a-z][\w-]*$/i;
|
|
1167
|
+
const getTokenType = function (token, offset, text) {
|
|
1168
|
+
if (token.type === "name") {
|
|
1169
|
+
const tokenValue = token.value;
|
|
1170
|
+
if (helperValidatorIdentifier.isKeyword(tokenValue) || helperValidatorIdentifier.isStrictReservedWord(tokenValue, true) || sometimesKeywords.has(tokenValue)) {
|
|
1171
|
+
return "keyword";
|
|
1179
1172
|
}
|
|
1180
|
-
if (
|
|
1181
|
-
return "
|
|
1173
|
+
if (JSX_TAG.test(tokenValue) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) === "</")) {
|
|
1174
|
+
return "jsxIdentifier";
|
|
1182
1175
|
}
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
return token.type;
|
|
1187
|
-
};
|
|
1188
|
-
tokenize = function* (text) {
|
|
1189
|
-
let match;
|
|
1190
|
-
while (match = jsTokens.default.exec(text)) {
|
|
1191
|
-
const token = jsTokens.matchToToken(match);
|
|
1192
|
-
yield {
|
|
1193
|
-
type: getTokenType(token, match.index, text),
|
|
1194
|
-
value: token.value
|
|
1195
|
-
};
|
|
1176
|
+
const firstChar = String.fromCodePoint(tokenValue.codePointAt(0));
|
|
1177
|
+
if (firstChar !== firstChar.toLowerCase()) {
|
|
1178
|
+
return "capitalized";
|
|
1196
1179
|
}
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1180
|
+
}
|
|
1181
|
+
if (token.type === "punctuator" && BRACKET.test(token.value)) {
|
|
1182
|
+
return "bracket";
|
|
1183
|
+
}
|
|
1184
|
+
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
|
|
1185
|
+
return "punctuator";
|
|
1186
|
+
}
|
|
1187
|
+
return token.type;
|
|
1188
|
+
};
|
|
1189
|
+
tokenize = function* (text) {
|
|
1190
|
+
let match;
|
|
1191
|
+
while (match = jsTokens.default.exec(text)) {
|
|
1192
|
+
const token = jsTokens.matchToToken(match);
|
|
1193
|
+
yield {
|
|
1194
|
+
type: getTokenType(token, match.index, text),
|
|
1195
|
+
value: token.value
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
1199
|
function highlight(text) {
|
|
1200
1200
|
if (text === "") return "";
|
|
1201
1201
|
const defs = getDefs(true);
|
|
@@ -1923,8 +1923,8 @@ const getModuleNotFoundError = stderr => {
|
|
|
1923
1923
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
1924
1924
|
const message = lines[messageIndex];
|
|
1925
1925
|
return {
|
|
1926
|
-
|
|
1927
|
-
|
|
1926
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
1927
|
+
message
|
|
1928
1928
|
};
|
|
1929
1929
|
};
|
|
1930
1930
|
const isModuleNotFoundError = stderr => {
|
|
@@ -1947,14 +1947,14 @@ const isUnhelpfulNativeModuleError = stderr => {
|
|
|
1947
1947
|
const getNativeModuleErrorMessage = stderr => {
|
|
1948
1948
|
const message = getMessageCodeBlock(stderr);
|
|
1949
1949
|
return {
|
|
1950
|
-
|
|
1951
|
-
|
|
1950
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
1951
|
+
message: `Incompatible native node module: ${message}`
|
|
1952
1952
|
};
|
|
1953
1953
|
};
|
|
1954
1954
|
const getModuleSyntaxError = () => {
|
|
1955
1955
|
return {
|
|
1956
|
-
|
|
1957
|
-
|
|
1956
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
1957
|
+
message: `ES Modules are not supported in electron`
|
|
1958
1958
|
};
|
|
1959
1959
|
};
|
|
1960
1960
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -1973,8 +1973,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
1973
1973
|
rest
|
|
1974
1974
|
} = getDetails(lines);
|
|
1975
1975
|
return {
|
|
1976
|
-
message: actualMessage,
|
|
1977
1976
|
code: '',
|
|
1977
|
+
message: actualMessage,
|
|
1978
1978
|
stack: rest
|
|
1979
1979
|
};
|
|
1980
1980
|
};
|
|
@@ -1984,8 +1984,8 @@ class IpcError extends VError {
|
|
|
1984
1984
|
if (stdout || stderr) {
|
|
1985
1985
|
// @ts-ignore
|
|
1986
1986
|
const {
|
|
1987
|
-
message,
|
|
1988
1987
|
code,
|
|
1988
|
+
message,
|
|
1989
1989
|
stack
|
|
1990
1990
|
} = getHelpfulChildProcessError(stdout, stderr);
|
|
1991
1991
|
const cause = new Error(message);
|
|
@@ -2267,8 +2267,8 @@ const removeListener = (emitter, type, callback) => {
|
|
|
2267
2267
|
};
|
|
2268
2268
|
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
2269
2269
|
const {
|
|
2270
|
-
|
|
2271
|
-
|
|
2270
|
+
promise,
|
|
2271
|
+
resolve
|
|
2272
2272
|
} = Promise.withResolvers();
|
|
2273
2273
|
const listenerMap = Object.create(null);
|
|
2274
2274
|
const cleanup = value => {
|
|
@@ -2280,8 +2280,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
2280
2280
|
for (const [event, type] of Object.entries(eventMap)) {
|
|
2281
2281
|
const listener = event => {
|
|
2282
2282
|
cleanup({
|
|
2283
|
-
|
|
2284
|
-
|
|
2283
|
+
event,
|
|
2284
|
+
type
|
|
2285
2285
|
});
|
|
2286
2286
|
};
|
|
2287
2287
|
addListener(eventEmitter, event, listener);
|
|
@@ -2331,13 +2331,13 @@ const IpcParentWithElectronMessagePort$1 = {
|
|
|
2331
2331
|
signal: signal$2,
|
|
2332
2332
|
wrap: wrap$7
|
|
2333
2333
|
};
|
|
2334
|
-
const Exit
|
|
2334
|
+
const Exit = 1;
|
|
2335
2335
|
const Error$2 = 2;
|
|
2336
2336
|
const Message$1 = 3;
|
|
2337
2337
|
const getFirstUtilityProcessEvent = async utilityProcess => {
|
|
2338
2338
|
const {
|
|
2339
|
-
|
|
2340
|
-
|
|
2339
|
+
promise,
|
|
2340
|
+
resolve
|
|
2341
2341
|
} = Promise.withResolvers();
|
|
2342
2342
|
let stdout = '';
|
|
2343
2343
|
let stderr = '';
|
|
@@ -2358,18 +2358,18 @@ const getFirstUtilityProcessEvent = async utilityProcess => {
|
|
|
2358
2358
|
};
|
|
2359
2359
|
const handleMessage = event => {
|
|
2360
2360
|
cleanup({
|
|
2361
|
-
type: Message$1,
|
|
2362
2361
|
event,
|
|
2362
|
+
stderr,
|
|
2363
2363
|
stdout,
|
|
2364
|
-
|
|
2364
|
+
type: Message$1
|
|
2365
2365
|
});
|
|
2366
2366
|
};
|
|
2367
2367
|
const handleExit = event => {
|
|
2368
2368
|
cleanup({
|
|
2369
|
-
type: Exit$1,
|
|
2370
2369
|
event,
|
|
2370
|
+
stderr,
|
|
2371
2371
|
stdout,
|
|
2372
|
-
|
|
2372
|
+
type: Exit
|
|
2373
2373
|
});
|
|
2374
2374
|
};
|
|
2375
2375
|
// @ts-ignore
|
|
@@ -2379,22 +2379,22 @@ const getFirstUtilityProcessEvent = async utilityProcess => {
|
|
|
2379
2379
|
utilityProcess.on('message', handleMessage);
|
|
2380
2380
|
utilityProcess.on('exit', handleExit);
|
|
2381
2381
|
const {
|
|
2382
|
-
|
|
2383
|
-
|
|
2382
|
+
event,
|
|
2383
|
+
type
|
|
2384
2384
|
} = await promise;
|
|
2385
2385
|
return {
|
|
2386
|
-
type,
|
|
2387
2386
|
event,
|
|
2387
|
+
stderr,
|
|
2388
2388
|
stdout,
|
|
2389
|
-
|
|
2389
|
+
type
|
|
2390
2390
|
};
|
|
2391
2391
|
};
|
|
2392
2392
|
const create$6 = async ({
|
|
2393
|
-
path,
|
|
2394
2393
|
argv = [],
|
|
2394
|
+
env = process.env,
|
|
2395
2395
|
execArgv = [],
|
|
2396
2396
|
name,
|
|
2397
|
-
|
|
2397
|
+
path
|
|
2398
2398
|
}) => {
|
|
2399
2399
|
string(path);
|
|
2400
2400
|
const actualArgv = ['--ipc-type=electron-utility-process', ...argv];
|
|
@@ -2402,10 +2402,10 @@ const create$6 = async ({
|
|
|
2402
2402
|
utilityProcess
|
|
2403
2403
|
} = await import('electron');
|
|
2404
2404
|
const childProcess = utilityProcess.fork(path, actualArgv, {
|
|
2405
|
+
env,
|
|
2405
2406
|
execArgv,
|
|
2406
|
-
stdio: 'pipe',
|
|
2407
2407
|
serviceName: name,
|
|
2408
|
-
|
|
2408
|
+
stdio: 'pipe'
|
|
2409
2409
|
});
|
|
2410
2410
|
const handleExit = () => {
|
|
2411
2411
|
// @ts-ignore
|
|
@@ -2417,11 +2417,11 @@ const create$6 = async ({
|
|
|
2417
2417
|
// @ts-ignore
|
|
2418
2418
|
childProcess.stdout.pipe(process.stdout);
|
|
2419
2419
|
const {
|
|
2420
|
-
|
|
2420
|
+
stderr,
|
|
2421
2421
|
stdout,
|
|
2422
|
-
|
|
2422
|
+
type
|
|
2423
2423
|
} = await getFirstUtilityProcessEvent(childProcess);
|
|
2424
|
-
if (type === Exit
|
|
2424
|
+
if (type === Exit) {
|
|
2425
2425
|
throw new IpcError(`Utility process exited before ipc connection was established`, stdout, stderr);
|
|
2426
2426
|
}
|
|
2427
2427
|
// @ts-ignore
|
|
@@ -2465,8 +2465,8 @@ class ChildProcessError extends Error {
|
|
|
2465
2465
|
constructor(stderr) {
|
|
2466
2466
|
// @ts-ignore
|
|
2467
2467
|
const {
|
|
2468
|
-
message,
|
|
2469
2468
|
code,
|
|
2469
|
+
message,
|
|
2470
2470
|
stack
|
|
2471
2471
|
} = getHelpfulChildProcessError('', stderr);
|
|
2472
2472
|
super(message || 'child process error');
|
|
@@ -2502,10 +2502,10 @@ const fixNodeChildProcessParameters = value => {
|
|
|
2502
2502
|
};
|
|
2503
2503
|
const getFirstNodeChildProcessEvent = async childProcess => {
|
|
2504
2504
|
const {
|
|
2505
|
-
type,
|
|
2506
2505
|
event,
|
|
2506
|
+
stderr,
|
|
2507
2507
|
stdout,
|
|
2508
|
-
|
|
2508
|
+
type
|
|
2509
2509
|
} = await new Promise((resolve, reject) => {
|
|
2510
2510
|
let stderr = '';
|
|
2511
2511
|
let stdout = '';
|
|
@@ -2527,26 +2527,26 @@ const getFirstNodeChildProcessEvent = async childProcess => {
|
|
|
2527
2527
|
};
|
|
2528
2528
|
const handleMessage = event => {
|
|
2529
2529
|
cleanup({
|
|
2530
|
-
type: Message$1,
|
|
2531
2530
|
event,
|
|
2531
|
+
stderr,
|
|
2532
2532
|
stdout,
|
|
2533
|
-
|
|
2533
|
+
type: Message$1
|
|
2534
2534
|
});
|
|
2535
2535
|
};
|
|
2536
2536
|
const handleExit = event => {
|
|
2537
2537
|
cleanup({
|
|
2538
|
-
type: Exit$1,
|
|
2539
2538
|
event,
|
|
2539
|
+
stderr,
|
|
2540
2540
|
stdout,
|
|
2541
|
-
|
|
2541
|
+
type: Exit
|
|
2542
2542
|
});
|
|
2543
2543
|
};
|
|
2544
2544
|
const handleError = event => {
|
|
2545
2545
|
cleanup({
|
|
2546
|
-
type: Error$2,
|
|
2547
2546
|
event,
|
|
2547
|
+
stderr,
|
|
2548
2548
|
stdout,
|
|
2549
|
-
|
|
2549
|
+
type: Error$2
|
|
2550
2550
|
});
|
|
2551
2551
|
};
|
|
2552
2552
|
if (childProcess.stdout && childProcess.stderr) {
|
|
@@ -2558,21 +2558,21 @@ const getFirstNodeChildProcessEvent = async childProcess => {
|
|
|
2558
2558
|
childProcess.on('error', handleError);
|
|
2559
2559
|
});
|
|
2560
2560
|
return {
|
|
2561
|
-
type,
|
|
2562
2561
|
event,
|
|
2562
|
+
stderr,
|
|
2563
2563
|
stdout,
|
|
2564
|
-
|
|
2564
|
+
type
|
|
2565
2565
|
};
|
|
2566
2566
|
};
|
|
2567
2567
|
|
|
2568
2568
|
// @ts-ignore
|
|
2569
2569
|
const create$2$2 = async ({
|
|
2570
|
-
path,
|
|
2571
2570
|
argv = [],
|
|
2572
2571
|
env,
|
|
2573
2572
|
execArgv = [],
|
|
2574
|
-
|
|
2575
|
-
|
|
2573
|
+
name = 'child process',
|
|
2574
|
+
path,
|
|
2575
|
+
stdio = 'inherit'
|
|
2576
2576
|
}) => {
|
|
2577
2577
|
try {
|
|
2578
2578
|
string(path);
|
|
@@ -2586,11 +2586,11 @@ const create$2$2 = async ({
|
|
|
2586
2586
|
stdio: 'pipe'
|
|
2587
2587
|
});
|
|
2588
2588
|
const {
|
|
2589
|
-
type,
|
|
2590
2589
|
event,
|
|
2591
|
-
stderr
|
|
2590
|
+
stderr,
|
|
2591
|
+
type
|
|
2592
2592
|
} = await getFirstNodeChildProcessEvent(childProcess);
|
|
2593
|
-
if (type === Exit
|
|
2593
|
+
if (type === Exit) {
|
|
2594
2594
|
throw new ChildProcessError(stderr);
|
|
2595
2595
|
}
|
|
2596
2596
|
if (type === Error$2) {
|
|
@@ -2653,18 +2653,18 @@ const fixNodeWorkerParameters = value => {
|
|
|
2653
2653
|
};
|
|
2654
2654
|
const getFirstNodeWorkerEvent = worker => {
|
|
2655
2655
|
return getFirstEvent(worker, {
|
|
2656
|
-
|
|
2657
|
-
exit: Exit
|
|
2658
|
-
|
|
2656
|
+
error: Error$2,
|
|
2657
|
+
exit: Exit,
|
|
2658
|
+
message: Message$1
|
|
2659
2659
|
});
|
|
2660
2660
|
};
|
|
2661
2661
|
const create$1$2 = async ({
|
|
2662
|
-
path,
|
|
2663
2662
|
argv = [],
|
|
2664
2663
|
env = process.env,
|
|
2665
2664
|
execArgv = [],
|
|
2666
|
-
|
|
2667
|
-
|
|
2665
|
+
name,
|
|
2666
|
+
path,
|
|
2667
|
+
stdio
|
|
2668
2668
|
}) => {
|
|
2669
2669
|
string(path);
|
|
2670
2670
|
const actualArgv = ['--ipc-type=node-worker', ...argv];
|
|
@@ -2680,15 +2680,15 @@ const create$1$2 = async ({
|
|
|
2680
2680
|
argv: actualArgv,
|
|
2681
2681
|
env: actualEnv,
|
|
2682
2682
|
execArgv,
|
|
2683
|
-
|
|
2683
|
+
name,
|
|
2684
2684
|
stderr: ignoreStdio,
|
|
2685
|
-
|
|
2685
|
+
stdout: ignoreStdio
|
|
2686
2686
|
});
|
|
2687
2687
|
const {
|
|
2688
|
-
|
|
2689
|
-
|
|
2688
|
+
event,
|
|
2689
|
+
type
|
|
2690
2690
|
} = await getFirstNodeWorkerEvent(worker);
|
|
2691
|
-
if (type === Exit
|
|
2691
|
+
if (type === Exit) {
|
|
2692
2692
|
throw new IpcError(`Worker exited before ipc connection was established`);
|
|
2693
2693
|
}
|
|
2694
2694
|
if (type === Error$2) {
|
|
@@ -2732,14 +2732,7 @@ const IpcParentWithNodeWorker$1 = {
|
|
|
2732
2732
|
wrap: wrap$1
|
|
2733
2733
|
};
|
|
2734
2734
|
|
|
2735
|
-
const Two = '2.0';
|
|
2736
|
-
const create$4 = (method, params) => {
|
|
2737
|
-
return {
|
|
2738
|
-
jsonrpc: Two,
|
|
2739
|
-
method,
|
|
2740
|
-
params
|
|
2741
|
-
};
|
|
2742
|
-
};
|
|
2735
|
+
const Two$1 = '2.0';
|
|
2743
2736
|
const callbacks = Object.create(null);
|
|
2744
2737
|
const set$2 = (id, fn) => {
|
|
2745
2738
|
callbacks[id] = fn;
|
|
@@ -2750,11 +2743,11 @@ const get$4 = id => {
|
|
|
2750
2743
|
const remove$2 = id => {
|
|
2751
2744
|
delete callbacks[id];
|
|
2752
2745
|
};
|
|
2753
|
-
let id = 0;
|
|
2746
|
+
let id$1 = 0;
|
|
2754
2747
|
const create$3 = () => {
|
|
2755
|
-
return ++id;
|
|
2748
|
+
return ++id$1;
|
|
2756
2749
|
};
|
|
2757
|
-
const registerPromise = () => {
|
|
2750
|
+
const registerPromise$1 = () => {
|
|
2758
2751
|
const id = create$3();
|
|
2759
2752
|
const {
|
|
2760
2753
|
resolve,
|
|
@@ -2770,9 +2763,9 @@ const create$2$1 = (method, params) => {
|
|
|
2770
2763
|
const {
|
|
2771
2764
|
id,
|
|
2772
2765
|
promise
|
|
2773
|
-
} = registerPromise();
|
|
2766
|
+
} = registerPromise$1();
|
|
2774
2767
|
const message = {
|
|
2775
|
-
jsonrpc: Two,
|
|
2768
|
+
jsonrpc: Two$1,
|
|
2776
2769
|
method,
|
|
2777
2770
|
params,
|
|
2778
2771
|
id
|
|
@@ -2934,7 +2927,7 @@ const resolve = (id, response) => {
|
|
|
2934
2927
|
fn(response);
|
|
2935
2928
|
remove$2(id);
|
|
2936
2929
|
};
|
|
2937
|
-
const E_COMMAND_NOT_FOUND
|
|
2930
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
2938
2931
|
const getErrorType = prettyError => {
|
|
2939
2932
|
if (prettyError && prettyError.type) {
|
|
2940
2933
|
return prettyError.type;
|
|
@@ -2956,7 +2949,7 @@ const getStack = prettyError => {
|
|
|
2956
2949
|
return stackString;
|
|
2957
2950
|
};
|
|
2958
2951
|
const getErrorProperty = (error, prettyError) => {
|
|
2959
|
-
if (error && error.code === E_COMMAND_NOT_FOUND
|
|
2952
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
2960
2953
|
return {
|
|
2961
2954
|
code: MethodNotFound,
|
|
2962
2955
|
message: error.message,
|
|
@@ -2977,7 +2970,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
2977
2970
|
};
|
|
2978
2971
|
const create$1$1 = (id, error) => {
|
|
2979
2972
|
return {
|
|
2980
|
-
jsonrpc: Two,
|
|
2973
|
+
jsonrpc: Two$1,
|
|
2981
2974
|
id,
|
|
2982
2975
|
error
|
|
2983
2976
|
};
|
|
@@ -2988,20 +2981,20 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
2988
2981
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
2989
2982
|
return create$1$1(id, errorProperty);
|
|
2990
2983
|
};
|
|
2991
|
-
const create$
|
|
2984
|
+
const create$4 = (message, result) => {
|
|
2992
2985
|
return {
|
|
2993
|
-
jsonrpc: Two,
|
|
2986
|
+
jsonrpc: Two$1,
|
|
2994
2987
|
id: message.id,
|
|
2995
2988
|
result: result ?? null
|
|
2996
2989
|
};
|
|
2997
2990
|
};
|
|
2998
2991
|
const getSuccessResponse = (message, result) => {
|
|
2999
2992
|
const resultProperty = result ?? null;
|
|
3000
|
-
return create$
|
|
2993
|
+
return create$4(message, resultProperty);
|
|
3001
2994
|
};
|
|
3002
2995
|
const getErrorResponseSimple = (id, error) => {
|
|
3003
2996
|
return {
|
|
3004
|
-
jsonrpc: Two,
|
|
2997
|
+
jsonrpc: Two$1,
|
|
3005
2998
|
id,
|
|
3006
2999
|
error: {
|
|
3007
3000
|
code: Custom,
|
|
@@ -3088,12 +3081,12 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
3088
3081
|
}
|
|
3089
3082
|
throw new JsonRpcError('unexpected message');
|
|
3090
3083
|
};
|
|
3091
|
-
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
3084
|
+
const invokeHelper$1 = async (ipc, method, params, useSendAndTransfer) => {
|
|
3092
3085
|
const {
|
|
3093
3086
|
message,
|
|
3094
3087
|
promise
|
|
3095
3088
|
} = create$2$1(method, params);
|
|
3096
|
-
if (
|
|
3089
|
+
if (ipc.sendAndTransfer) {
|
|
3097
3090
|
ipc.sendAndTransfer(message);
|
|
3098
3091
|
} else {
|
|
3099
3092
|
ipc.send(message);
|
|
@@ -3101,25 +3094,18 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
3101
3094
|
const responseMessage = await promise;
|
|
3102
3095
|
return unwrapJsonRpcResult(responseMessage);
|
|
3103
3096
|
};
|
|
3104
|
-
const send$2 = (transport, method, ...params) => {
|
|
3105
|
-
const message = create$4(method, params);
|
|
3106
|
-
transport.send(message);
|
|
3107
|
-
};
|
|
3108
|
-
const invoke$1 = (ipc, method, ...params) => {
|
|
3109
|
-
return invokeHelper(ipc, method, params, false);
|
|
3110
|
-
};
|
|
3111
3097
|
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
3112
|
-
return invokeHelper(ipc, method, params
|
|
3098
|
+
return invokeHelper$1(ipc, method, params);
|
|
3113
3099
|
};
|
|
3114
3100
|
|
|
3115
|
-
|
|
3101
|
+
class CommandNotFoundError extends Error {
|
|
3116
3102
|
constructor(command) {
|
|
3117
3103
|
super(`Command not found ${command}`);
|
|
3118
3104
|
this.name = 'CommandNotFoundError';
|
|
3119
3105
|
}
|
|
3120
|
-
}
|
|
3106
|
+
}
|
|
3121
3107
|
const commands = Object.create(null);
|
|
3122
|
-
const register
|
|
3108
|
+
const register = commandMap => {
|
|
3123
3109
|
Object.assign(commands, commandMap);
|
|
3124
3110
|
};
|
|
3125
3111
|
const getCommand = key => {
|
|
@@ -3128,29 +3114,92 @@ const getCommand = key => {
|
|
|
3128
3114
|
const execute$1 = (command, ...args) => {
|
|
3129
3115
|
const fn = getCommand(command);
|
|
3130
3116
|
if (!fn) {
|
|
3131
|
-
throw new CommandNotFoundError
|
|
3117
|
+
throw new CommandNotFoundError(command);
|
|
3132
3118
|
}
|
|
3133
3119
|
return fn(...args);
|
|
3134
3120
|
};
|
|
3135
3121
|
|
|
3122
|
+
const Two = '2.0';
|
|
3123
|
+
const create$s = (method, params) => {
|
|
3124
|
+
return {
|
|
3125
|
+
jsonrpc: Two,
|
|
3126
|
+
method,
|
|
3127
|
+
params
|
|
3128
|
+
};
|
|
3129
|
+
};
|
|
3130
|
+
const create$r = (id, method, params) => {
|
|
3131
|
+
const message = {
|
|
3132
|
+
id,
|
|
3133
|
+
jsonrpc: Two,
|
|
3134
|
+
method,
|
|
3135
|
+
params
|
|
3136
|
+
};
|
|
3137
|
+
return message;
|
|
3138
|
+
};
|
|
3139
|
+
let id = 0;
|
|
3140
|
+
const create$q = () => {
|
|
3141
|
+
return ++id;
|
|
3142
|
+
};
|
|
3143
|
+
|
|
3144
|
+
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
3145
|
+
|
|
3146
|
+
const registerPromise = map => {
|
|
3147
|
+
const id = create$q();
|
|
3148
|
+
const {
|
|
3149
|
+
promise,
|
|
3150
|
+
resolve
|
|
3151
|
+
} = Promise.withResolvers();
|
|
3152
|
+
map[id] = resolve;
|
|
3153
|
+
return {
|
|
3154
|
+
id,
|
|
3155
|
+
promise
|
|
3156
|
+
};
|
|
3157
|
+
};
|
|
3158
|
+
|
|
3159
|
+
// @ts-ignore
|
|
3160
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
3161
|
+
const {
|
|
3162
|
+
id,
|
|
3163
|
+
promise
|
|
3164
|
+
} = registerPromise(callbacks);
|
|
3165
|
+
const message = create$r(id, method, params);
|
|
3166
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
3167
|
+
ipc.sendAndTransfer(message);
|
|
3168
|
+
} else {
|
|
3169
|
+
ipc.send(message);
|
|
3170
|
+
}
|
|
3171
|
+
const responseMessage = await promise;
|
|
3172
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
3173
|
+
};
|
|
3136
3174
|
const createRpc = ipc => {
|
|
3175
|
+
const callbacks = Object.create(null);
|
|
3176
|
+
ipc._resolve = (id, response) => {
|
|
3177
|
+
const fn = callbacks[id];
|
|
3178
|
+
if (!fn) {
|
|
3179
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
3180
|
+
return;
|
|
3181
|
+
}
|
|
3182
|
+
fn(response);
|
|
3183
|
+
delete callbacks[id];
|
|
3184
|
+
};
|
|
3137
3185
|
const rpc = {
|
|
3186
|
+
async dispose() {
|
|
3187
|
+
await ipc?.dispose();
|
|
3188
|
+
},
|
|
3189
|
+
invoke(method, ...params) {
|
|
3190
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
3191
|
+
},
|
|
3192
|
+
invokeAndTransfer(method, ...params) {
|
|
3193
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
3194
|
+
},
|
|
3138
3195
|
// @ts-ignore
|
|
3139
3196
|
ipc,
|
|
3140
3197
|
/**
|
|
3141
3198
|
* @deprecated
|
|
3142
3199
|
*/
|
|
3143
3200
|
send(method, ...params) {
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
invoke(method, ...params) {
|
|
3147
|
-
return invoke$1(ipc, method, ...params);
|
|
3148
|
-
},
|
|
3149
|
-
invokeAndTransfer(method, ...params) {
|
|
3150
|
-
return invokeAndTransfer$1(ipc, method, ...params);
|
|
3151
|
-
},
|
|
3152
|
-
async dispose() {
|
|
3153
|
-
await ipc?.dispose();
|
|
3201
|
+
const message = create$s(method, params);
|
|
3202
|
+
ipc.send(message);
|
|
3154
3203
|
}
|
|
3155
3204
|
};
|
|
3156
3205
|
return rpc;
|
|
@@ -3167,7 +3216,7 @@ const logError$1 = () => {
|
|
|
3167
3216
|
const handleMessage$1 = event => {
|
|
3168
3217
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket$1;
|
|
3169
3218
|
const actualExecute = event?.target?.execute || execute$1;
|
|
3170
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute,
|
|
3219
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError$1, actualRequiresSocket);
|
|
3171
3220
|
};
|
|
3172
3221
|
const handleIpc$1 = ipc => {
|
|
3173
3222
|
if ('addEventListener' in ipc) {
|
|
@@ -3185,13 +3234,13 @@ const listen$1 = async (module, options) => {
|
|
|
3185
3234
|
const ipc = module.wrap(rawIpc);
|
|
3186
3235
|
return ipc;
|
|
3187
3236
|
};
|
|
3188
|
-
const create$
|
|
3237
|
+
const create$p = async ({
|
|
3189
3238
|
commandMap,
|
|
3190
3239
|
messagePort,
|
|
3191
3240
|
requiresSocket
|
|
3192
3241
|
}) => {
|
|
3193
3242
|
// TODO create a commandMap per rpc instance
|
|
3194
|
-
register
|
|
3243
|
+
register(commandMap);
|
|
3195
3244
|
const ipc = await listen$1(IpcChildWithElectronMessagePort$1, {
|
|
3196
3245
|
messagePort
|
|
3197
3246
|
});
|
|
@@ -3204,25 +3253,25 @@ const create$k = async ({
|
|
|
3204
3253
|
};
|
|
3205
3254
|
const ElectronMessagePortRpcClient = {
|
|
3206
3255
|
__proto__: null,
|
|
3207
|
-
create: create$
|
|
3256
|
+
create: create$p
|
|
3208
3257
|
};
|
|
3209
|
-
const create$
|
|
3258
|
+
const create$n = async ({
|
|
3259
|
+
argv,
|
|
3210
3260
|
commandMap,
|
|
3211
3261
|
env,
|
|
3212
|
-
argv,
|
|
3213
3262
|
execArgv,
|
|
3214
|
-
path,
|
|
3215
3263
|
name,
|
|
3264
|
+
path,
|
|
3216
3265
|
requiresSocket
|
|
3217
3266
|
}) => {
|
|
3218
3267
|
// TODO create a commandMap per rpc instance
|
|
3219
|
-
register
|
|
3268
|
+
register(commandMap);
|
|
3220
3269
|
const rawIpc = await IpcParentWithElectronUtilityProcess$1$1.create({
|
|
3221
|
-
env,
|
|
3222
3270
|
argv,
|
|
3271
|
+
env,
|
|
3223
3272
|
execArgv,
|
|
3224
|
-
|
|
3225
|
-
|
|
3273
|
+
name,
|
|
3274
|
+
path
|
|
3226
3275
|
});
|
|
3227
3276
|
const ipc = IpcParentWithElectronUtilityProcess$1$1.wrap(rawIpc);
|
|
3228
3277
|
if (requiresSocket) {
|
|
@@ -3235,15 +3284,15 @@ const create$i = async ({
|
|
|
3235
3284
|
};
|
|
3236
3285
|
const ElectronUtilityProcessRpcParent = {
|
|
3237
3286
|
__proto__: null,
|
|
3238
|
-
create: create$
|
|
3287
|
+
create: create$n
|
|
3239
3288
|
};
|
|
3240
|
-
const create$
|
|
3289
|
+
const create$m = async ({
|
|
3241
3290
|
commandMap,
|
|
3242
|
-
|
|
3243
|
-
|
|
3291
|
+
requiresSocket,
|
|
3292
|
+
webContents
|
|
3244
3293
|
}) => {
|
|
3245
3294
|
// TODO create a commandMap per rpc instance
|
|
3246
|
-
register
|
|
3295
|
+
register(commandMap);
|
|
3247
3296
|
const ipc = IpcChildWithRendererProcess2$1.wrap(webContents);
|
|
3248
3297
|
if (requiresSocket) {
|
|
3249
3298
|
// @ts-ignore
|
|
@@ -3255,7 +3304,7 @@ const create$h = async ({
|
|
|
3255
3304
|
};
|
|
3256
3305
|
const ElectronWebContentsRpcClient = {
|
|
3257
3306
|
__proto__: null,
|
|
3258
|
-
create: create$
|
|
3307
|
+
create: create$m
|
|
3259
3308
|
};
|
|
3260
3309
|
|
|
3261
3310
|
const commandMapRef = Object.create(null);
|
|
@@ -3411,7 +3460,7 @@ const launchSharedProcess = async ({
|
|
|
3411
3460
|
return sharedProcessRpc;
|
|
3412
3461
|
};
|
|
3413
3462
|
|
|
3414
|
-
const state$
|
|
3463
|
+
const state$5 = {
|
|
3415
3464
|
/**
|
|
3416
3465
|
* @type {any}
|
|
3417
3466
|
*/
|
|
@@ -3422,14 +3471,14 @@ const getOrCreate = async ({
|
|
|
3422
3471
|
env = {},
|
|
3423
3472
|
method
|
|
3424
3473
|
}) => {
|
|
3425
|
-
if (!state$
|
|
3474
|
+
if (!state$5.promise) {
|
|
3426
3475
|
// @ts-ignore
|
|
3427
|
-
state$
|
|
3476
|
+
state$5.promise = launchSharedProcess({
|
|
3428
3477
|
env,
|
|
3429
3478
|
method
|
|
3430
3479
|
});
|
|
3431
3480
|
}
|
|
3432
|
-
return state$
|
|
3481
|
+
return state$5.promise;
|
|
3433
3482
|
};
|
|
3434
3483
|
const send$1 = async (method, ...params) => {
|
|
3435
3484
|
const rpc = await getOrCreate({
|
|
@@ -4557,14 +4606,14 @@ const createTitleBar = items => {
|
|
|
4557
4606
|
|
|
4558
4607
|
const PHASE_DEFAULT = 0;
|
|
4559
4608
|
const PHASE_SHUTDOWN = -1;
|
|
4560
|
-
const state$
|
|
4609
|
+
const state$4 = {
|
|
4561
4610
|
phase: PHASE_DEFAULT
|
|
4562
4611
|
};
|
|
4563
4612
|
const isShutDown = () => {
|
|
4564
|
-
return state$
|
|
4613
|
+
return state$4.phase === PHASE_SHUTDOWN;
|
|
4565
4614
|
};
|
|
4566
4615
|
const setShutDown = () => {
|
|
4567
|
-
state$
|
|
4616
|
+
state$4.phase = PHASE_SHUTDOWN;
|
|
4568
4617
|
};
|
|
4569
4618
|
|
|
4570
4619
|
// TODO move this function to shared process
|
|
@@ -4869,21 +4918,21 @@ const BeforeInputEvent = 'before-input-event';
|
|
|
4869
4918
|
const Allow = 'allow';
|
|
4870
4919
|
const Deny = 'deny';
|
|
4871
4920
|
|
|
4872
|
-
const state$
|
|
4921
|
+
const state$3 = {
|
|
4873
4922
|
canceled: Object.create(null),
|
|
4874
4923
|
fallThroughKeyBindings: [],
|
|
4875
4924
|
views: Object.create(null)
|
|
4876
4925
|
};
|
|
4877
4926
|
const add$1 = (id, browserWindow, view) => {
|
|
4878
4927
|
// state
|
|
4879
|
-
state$
|
|
4928
|
+
state$3.views[id] = {
|
|
4880
4929
|
browserWindow,
|
|
4881
4930
|
view
|
|
4882
4931
|
};
|
|
4883
4932
|
};
|
|
4884
4933
|
const hasWebContents = id => {
|
|
4885
4934
|
number(id);
|
|
4886
|
-
return id in state$
|
|
4935
|
+
return id in state$3.views;
|
|
4887
4936
|
};
|
|
4888
4937
|
/**
|
|
4889
4938
|
*
|
|
@@ -4891,19 +4940,19 @@ const hasWebContents = id => {
|
|
|
4891
4940
|
* @returns {{browserWindow: Electron.BrowserWindow, view: Electron.WebContentsView}}
|
|
4892
4941
|
*/
|
|
4893
4942
|
const get$3 = id => {
|
|
4894
|
-
return state$
|
|
4943
|
+
return state$3.views[id];
|
|
4895
4944
|
};
|
|
4896
4945
|
const remove$1 = id => {
|
|
4897
|
-
delete state$
|
|
4946
|
+
delete state$3.views[id];
|
|
4898
4947
|
};
|
|
4899
4948
|
const setFallthroughKeyBindings = fallthroughKeyBindings => {
|
|
4900
|
-
state$
|
|
4949
|
+
state$3.fallThroughKeyBindings = fallthroughKeyBindings;
|
|
4901
4950
|
};
|
|
4902
4951
|
const getFallthroughKeyBindings = () => {
|
|
4903
|
-
return state$
|
|
4952
|
+
return state$3.fallThroughKeyBindings;
|
|
4904
4953
|
};
|
|
4905
4954
|
const setCanceled = id => {
|
|
4906
|
-
state$
|
|
4955
|
+
state$3.canceled[id] = true;
|
|
4907
4956
|
};
|
|
4908
4957
|
|
|
4909
4958
|
const shouldAllowNavigation = webContentsId => {
|
|
@@ -5065,197 +5114,6 @@ const {
|
|
|
5065
5114
|
argv
|
|
5066
5115
|
} = process;
|
|
5067
5116
|
|
|
5068
|
-
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
5069
|
-
const E_MODULE_NOT_FOUND = 'E_MODULE_NOT_FOUND';
|
|
5070
|
-
|
|
5071
|
-
class CommandNotFoundError extends Error {
|
|
5072
|
-
constructor(id) {
|
|
5073
|
-
super(`command ${id} not found`);
|
|
5074
|
-
this.name = 'CommandNotFoundError';
|
|
5075
|
-
// @ts-ignore
|
|
5076
|
-
this.code = E_COMMAND_NOT_FOUND;
|
|
5077
|
-
}
|
|
5078
|
-
}
|
|
5079
|
-
|
|
5080
|
-
const App = 1;
|
|
5081
|
-
const AppWindow = 2;
|
|
5082
|
-
const Beep = 3;
|
|
5083
|
-
const Developer = 4;
|
|
5084
|
-
const Dialog = 5;
|
|
5085
|
-
const ElectronWindowProcessExplorer = 6;
|
|
5086
|
-
const Window = 7;
|
|
5087
|
-
const ElectronShell = 8;
|
|
5088
|
-
const ElectronPowerSaveBlocker = 9;
|
|
5089
|
-
const ElectronSafeStorage = 10;
|
|
5090
|
-
const ElectronContentTracing = 11;
|
|
5091
|
-
const ElectronNetLog = 12;
|
|
5092
|
-
const ElectronBrowserView = 13;
|
|
5093
|
-
const ElectronBrowserViewQuickPick = 14;
|
|
5094
|
-
const ElectronContextMenu = 16;
|
|
5095
|
-
const ElectronClipBoard = 17;
|
|
5096
|
-
const ElectronApplicationMenu = 18;
|
|
5097
|
-
const Process = 19;
|
|
5098
|
-
const ElectronNet = 20;
|
|
5099
|
-
const ElectronBrowserViewSuggestions = 21;
|
|
5100
|
-
const CreatePidMap = 22;
|
|
5101
|
-
const OpenExternal$1 = 23;
|
|
5102
|
-
const Platform = 25;
|
|
5103
|
-
const GetWindowId = 26;
|
|
5104
|
-
const DesktopCapturer = 27;
|
|
5105
|
-
const Trash = 28;
|
|
5106
|
-
const IpcParent = 29;
|
|
5107
|
-
const Crash = 30;
|
|
5108
|
-
const Exit = 31;
|
|
5109
|
-
const ElectronScreen = 32;
|
|
5110
|
-
const TemporaryMessagePort = 34;
|
|
5111
|
-
const ElectronWebContents = 35;
|
|
5112
|
-
const ElectronWebContentsView = 36;
|
|
5113
|
-
const ElectronWebContentsViewFunctions = 37;
|
|
5114
|
-
const CreateMessagePort = 38;
|
|
5115
|
-
const HandleElectronMessagePort = 39;
|
|
5116
|
-
const ElectronSession = 40;
|
|
5117
|
-
|
|
5118
|
-
const getPrefix = commandId => {
|
|
5119
|
-
return commandId.slice(0, commandId.indexOf('.'));
|
|
5120
|
-
};
|
|
5121
|
-
const getModuleId = commandId => {
|
|
5122
|
-
const prefix = getPrefix(commandId);
|
|
5123
|
-
switch (prefix) {
|
|
5124
|
-
case 'App':
|
|
5125
|
-
case 'ElectronApp':
|
|
5126
|
-
return App;
|
|
5127
|
-
case 'AppWindow':
|
|
5128
|
-
return AppWindow;
|
|
5129
|
-
case 'Beep':
|
|
5130
|
-
return Beep;
|
|
5131
|
-
case 'Crash':
|
|
5132
|
-
return Crash;
|
|
5133
|
-
case 'CreateMessagePort':
|
|
5134
|
-
return CreateMessagePort;
|
|
5135
|
-
case 'CreatePidMap':
|
|
5136
|
-
return CreatePidMap;
|
|
5137
|
-
case 'DesktopCapturer':
|
|
5138
|
-
return DesktopCapturer;
|
|
5139
|
-
case 'ElectronApplicationMenu':
|
|
5140
|
-
return ElectronApplicationMenu;
|
|
5141
|
-
case 'ElectronBeep':
|
|
5142
|
-
return Beep;
|
|
5143
|
-
case 'ElectronBrowserView':
|
|
5144
|
-
return ElectronBrowserView;
|
|
5145
|
-
case 'ElectronBrowserViewQuickPick':
|
|
5146
|
-
return ElectronBrowserViewQuickPick;
|
|
5147
|
-
case 'ElectronBrowserViewSuggestions':
|
|
5148
|
-
return ElectronBrowserViewSuggestions;
|
|
5149
|
-
case 'ElectronClipBoard':
|
|
5150
|
-
return ElectronClipBoard;
|
|
5151
|
-
case 'ElectronContentTracing':
|
|
5152
|
-
return ElectronContentTracing;
|
|
5153
|
-
case 'ElectronContextMenu':
|
|
5154
|
-
return ElectronContextMenu;
|
|
5155
|
-
case 'ElectronDeveloper':
|
|
5156
|
-
return Developer;
|
|
5157
|
-
case 'ElectronDialog':
|
|
5158
|
-
return Dialog;
|
|
5159
|
-
case 'ElectronNet':
|
|
5160
|
-
return ElectronNet;
|
|
5161
|
-
case 'ElectronNetLog':
|
|
5162
|
-
return ElectronNetLog;
|
|
5163
|
-
case 'ElectronPowerSaveBlocker':
|
|
5164
|
-
return ElectronPowerSaveBlocker;
|
|
5165
|
-
case 'ElectronSafeStorage':
|
|
5166
|
-
return ElectronSafeStorage;
|
|
5167
|
-
case 'ElectronScreen':
|
|
5168
|
-
return ElectronScreen;
|
|
5169
|
-
case 'ElectronSession':
|
|
5170
|
-
return ElectronSession;
|
|
5171
|
-
case 'ElectronShell':
|
|
5172
|
-
return ElectronShell;
|
|
5173
|
-
case 'ElectronWebContents':
|
|
5174
|
-
return ElectronWebContents;
|
|
5175
|
-
case 'ElectronWebContentsView':
|
|
5176
|
-
return ElectronWebContentsView;
|
|
5177
|
-
case 'ElectronWebContentsViewFunctions':
|
|
5178
|
-
return ElectronWebContentsViewFunctions;
|
|
5179
|
-
case 'ElectronWindow':
|
|
5180
|
-
return Window;
|
|
5181
|
-
case 'ElectronWindowProcessExplorer':
|
|
5182
|
-
return ElectronWindowProcessExplorer;
|
|
5183
|
-
case 'Exit':
|
|
5184
|
-
return Exit;
|
|
5185
|
-
case 'GetWindowId':
|
|
5186
|
-
return GetWindowId;
|
|
5187
|
-
case 'HandleElectronMessagePort':
|
|
5188
|
-
return HandleElectronMessagePort;
|
|
5189
|
-
case 'IpcParent':
|
|
5190
|
-
return IpcParent;
|
|
5191
|
-
case 'OpenExternal':
|
|
5192
|
-
return OpenExternal$1;
|
|
5193
|
-
case 'Platform':
|
|
5194
|
-
return Platform;
|
|
5195
|
-
case 'Process':
|
|
5196
|
-
return Process;
|
|
5197
|
-
case 'TemporaryMessagePort':
|
|
5198
|
-
return TemporaryMessagePort;
|
|
5199
|
-
case 'Trash':
|
|
5200
|
-
return Trash;
|
|
5201
|
-
default:
|
|
5202
|
-
throw new CommandNotFoundError(commandId);
|
|
5203
|
-
}
|
|
5204
|
-
};
|
|
5205
|
-
|
|
5206
|
-
const state$3 = {
|
|
5207
|
-
commands: Object.create(null),
|
|
5208
|
-
async load(moduleId) {},
|
|
5209
|
-
pendingModules: Object.create(null)
|
|
5210
|
-
};
|
|
5211
|
-
const initializeModule = module => {
|
|
5212
|
-
if (module.Commands) {
|
|
5213
|
-
for (const [key, value] of Object.entries(module.Commands)) {
|
|
5214
|
-
if (module.name) {
|
|
5215
|
-
const actualKey = `${module.name}.${key}`;
|
|
5216
|
-
register(actualKey, value);
|
|
5217
|
-
} else {
|
|
5218
|
-
register(key, value);
|
|
5219
|
-
}
|
|
5220
|
-
}
|
|
5221
|
-
return;
|
|
5222
|
-
}
|
|
5223
|
-
throw new Error(`module ${module.name || '<unnamed module>'} is missing commands`);
|
|
5224
|
-
};
|
|
5225
|
-
const getOrLoadModule = moduleId => {
|
|
5226
|
-
if (!state$3.pendingModules[moduleId]) {
|
|
5227
|
-
const importPromise = state$3.load(moduleId);
|
|
5228
|
-
state$3.pendingModules[moduleId] = importPromise.then(initializeModule);
|
|
5229
|
-
}
|
|
5230
|
-
return state$3.pendingModules[moduleId];
|
|
5231
|
-
};
|
|
5232
|
-
const loadCommand = command => getOrLoadModule(getModuleId(command));
|
|
5233
|
-
const register = (commandId, listener) => {
|
|
5234
|
-
state$3.commands[commandId] = listener;
|
|
5235
|
-
};
|
|
5236
|
-
const hasThrown = new Set();
|
|
5237
|
-
const loadThenExecute = async (command, ...args) => {
|
|
5238
|
-
await loadCommand(command);
|
|
5239
|
-
// TODO can skip then block in prod (only to prevent endless loop in dev)
|
|
5240
|
-
if (!(command in state$3.commands)) {
|
|
5241
|
-
if (hasThrown.has(command)) {
|
|
5242
|
-
return;
|
|
5243
|
-
}
|
|
5244
|
-
hasThrown.add(command);
|
|
5245
|
-
throw new Error(`Command did not register "${command}"`);
|
|
5246
|
-
}
|
|
5247
|
-
return execute(command, ...args);
|
|
5248
|
-
};
|
|
5249
|
-
const execute = (command, ...args) => {
|
|
5250
|
-
if (command in state$3.commands) {
|
|
5251
|
-
return state$3.commands[command](...args);
|
|
5252
|
-
}
|
|
5253
|
-
return loadThenExecute(command, ...args);
|
|
5254
|
-
};
|
|
5255
|
-
const setLoad = load => {
|
|
5256
|
-
state$3.load = load;
|
|
5257
|
-
};
|
|
5258
|
-
|
|
5259
5117
|
const ClipBoardRead = 'clipboard-read';
|
|
5260
5118
|
const ClipBoardSanitizedWrite = 'clipboard-sanitized-write';
|
|
5261
5119
|
const FullScreen = 'fullscreen';
|
|
@@ -5704,45 +5562,144 @@ const stopRecording = () => {
|
|
|
5704
5562
|
return contentTracing.stopRecording();
|
|
5705
5563
|
};
|
|
5706
5564
|
|
|
5707
|
-
const
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5565
|
+
const withResolvers = () => {
|
|
5566
|
+
/**
|
|
5567
|
+
* @type {any}
|
|
5568
|
+
*/
|
|
5569
|
+
let _resolve;
|
|
5570
|
+
/**
|
|
5571
|
+
* @type {any}
|
|
5572
|
+
*/
|
|
5573
|
+
let _reject;
|
|
5574
|
+
const promise = new Promise((resolve, reject) => {
|
|
5575
|
+
_resolve = resolve;
|
|
5576
|
+
_reject = reject;
|
|
5577
|
+
});
|
|
5712
5578
|
return {
|
|
5713
|
-
|
|
5714
|
-
|
|
5579
|
+
promise,
|
|
5580
|
+
reject: _reject,
|
|
5581
|
+
resolve: _resolve
|
|
5715
5582
|
};
|
|
5716
5583
|
};
|
|
5717
|
-
const crashMainProcess = () => {
|
|
5718
|
-
throw new Error('oops');
|
|
5719
|
-
};
|
|
5720
|
-
|
|
5721
|
-
const Error$1 = 'error';
|
|
5722
5584
|
|
|
5723
|
-
const
|
|
5724
|
-
|
|
5725
|
-
|
|
5585
|
+
const getElectronCallbacks = () => {
|
|
5586
|
+
const {
|
|
5587
|
+
promise,
|
|
5588
|
+
resolve
|
|
5589
|
+
} = withResolvers();
|
|
5590
|
+
const handleClick = menuItem => {
|
|
5591
|
+
resolve({
|
|
5592
|
+
data: menuItem,
|
|
5593
|
+
type: 'click'
|
|
5594
|
+
});
|
|
5595
|
+
};
|
|
5596
|
+
const handleClose = () => {
|
|
5597
|
+
resolve({
|
|
5598
|
+
data: undefined,
|
|
5599
|
+
type: 'close'
|
|
5600
|
+
});
|
|
5601
|
+
};
|
|
5602
|
+
return {
|
|
5603
|
+
handleClick,
|
|
5604
|
+
handleClose,
|
|
5605
|
+
promise
|
|
5606
|
+
};
|
|
5726
5607
|
};
|
|
5727
5608
|
|
|
5728
|
-
const
|
|
5729
|
-
const
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
};
|
|
5736
|
-
const executeWebContentsFunction = (browserWindowId, key, ...args) => {
|
|
5737
|
-
const browserWindow = getWindowById(browserWindowId);
|
|
5738
|
-
if (!browserWindow) {
|
|
5739
|
-
info(`[main-process] browser window not found ${browserWindow}`);
|
|
5740
|
-
return;
|
|
5609
|
+
const getElectronMenuItems = (menuItems, click) => {
|
|
5610
|
+
const template = [];
|
|
5611
|
+
for (const menuItem of menuItems) {
|
|
5612
|
+
// @ts-ignore
|
|
5613
|
+
template.push({
|
|
5614
|
+
...menuItem,
|
|
5615
|
+
click
|
|
5616
|
+
});
|
|
5741
5617
|
}
|
|
5742
|
-
|
|
5743
|
-
};
|
|
5744
|
-
|
|
5745
|
-
|
|
5618
|
+
return template;
|
|
5619
|
+
};
|
|
5620
|
+
|
|
5621
|
+
const openContextMenu = async (menuItems, x, y) => {
|
|
5622
|
+
array(menuItems);
|
|
5623
|
+
number(x);
|
|
5624
|
+
number(y);
|
|
5625
|
+
const {
|
|
5626
|
+
handleClick,
|
|
5627
|
+
handleClose,
|
|
5628
|
+
promise
|
|
5629
|
+
} = getElectronCallbacks();
|
|
5630
|
+
const template = getElectronMenuItems(menuItems, handleClick);
|
|
5631
|
+
const menu = Menu.buildFromTemplate(template);
|
|
5632
|
+
// TODO pass window id
|
|
5633
|
+
const window = BrowserWindow.getFocusedWindow();
|
|
5634
|
+
if (!window) {
|
|
5635
|
+
return {
|
|
5636
|
+
data: undefined,
|
|
5637
|
+
type: 'close'
|
|
5638
|
+
};
|
|
5639
|
+
}
|
|
5640
|
+
menu.popup({
|
|
5641
|
+
callback: handleClose,
|
|
5642
|
+
window,
|
|
5643
|
+
x,
|
|
5644
|
+
y
|
|
5645
|
+
});
|
|
5646
|
+
const event = await promise;
|
|
5647
|
+
// @ts-ignore
|
|
5648
|
+
if (event.type === 'click') {
|
|
5649
|
+
return {
|
|
5650
|
+
// @ts-ignore
|
|
5651
|
+
data: event.data.label,
|
|
5652
|
+
type: 'click'
|
|
5653
|
+
};
|
|
5654
|
+
}
|
|
5655
|
+
// @ts-ignore
|
|
5656
|
+
if (event.type === 'close') {
|
|
5657
|
+
return {
|
|
5658
|
+
data: undefined,
|
|
5659
|
+
type: 'close'
|
|
5660
|
+
};
|
|
5661
|
+
}
|
|
5662
|
+
};
|
|
5663
|
+
|
|
5664
|
+
const getPerformanceEntries = () => {
|
|
5665
|
+
const entries = getEntries();
|
|
5666
|
+
const {
|
|
5667
|
+
timeOrigin
|
|
5668
|
+
} = Performance;
|
|
5669
|
+
return {
|
|
5670
|
+
entries,
|
|
5671
|
+
timeOrigin
|
|
5672
|
+
};
|
|
5673
|
+
};
|
|
5674
|
+
const crashMainProcess = () => {
|
|
5675
|
+
throw new Error('oops');
|
|
5676
|
+
};
|
|
5677
|
+
|
|
5678
|
+
const Error$1 = 'error';
|
|
5679
|
+
|
|
5680
|
+
const getWindowById = windowId => {
|
|
5681
|
+
number(windowId);
|
|
5682
|
+
return Electron.BrowserWindow.fromId(windowId);
|
|
5683
|
+
};
|
|
5684
|
+
|
|
5685
|
+
const executeWindowFunction = (browserWindowId, key) => {
|
|
5686
|
+
const browserWindow = getWindowById(browserWindowId);
|
|
5687
|
+
if (!browserWindow) {
|
|
5688
|
+
info(`[main-process] browser window not found ${browserWindow}`);
|
|
5689
|
+
return;
|
|
5690
|
+
}
|
|
5691
|
+
browserWindow[key]();
|
|
5692
|
+
};
|
|
5693
|
+
const executeWebContentsFunction = (browserWindowId, key, ...args) => {
|
|
5694
|
+
const browserWindow = getWindowById(browserWindowId);
|
|
5695
|
+
if (!browserWindow) {
|
|
5696
|
+
info(`[main-process] browser window not found ${browserWindow}`);
|
|
5697
|
+
return;
|
|
5698
|
+
}
|
|
5699
|
+
browserWindow.webContents[key](...args);
|
|
5700
|
+
};
|
|
5701
|
+
const getFocusedWindow = () => {
|
|
5702
|
+
return Electron.BrowserWindow.getFocusedWindow() || undefined;
|
|
5746
5703
|
};
|
|
5747
5704
|
const findById = windowId => {
|
|
5748
5705
|
return getWindowById(windowId);
|
|
@@ -6992,6 +6949,13 @@ const printPrettyError = (prettyError, prefix = '') => {
|
|
|
6992
6949
|
error(`${prefix}${prettyError.type}: ${prettyError.message}\n\n${prettyError.codeFrame}\n\n${prettyError.stack}\n`);
|
|
6993
6950
|
};
|
|
6994
6951
|
|
|
6952
|
+
const execute = (method, ...params) => {
|
|
6953
|
+
const fn = commandMapRef[method];
|
|
6954
|
+
if (!fn) {
|
|
6955
|
+
throw new Error(`command not found: ${method}`);
|
|
6956
|
+
}
|
|
6957
|
+
return fn(...params);
|
|
6958
|
+
};
|
|
6995
6959
|
const logError = (error, prettyError) => {
|
|
6996
6960
|
printPrettyError(prettyError, '[main-process] ');
|
|
6997
6961
|
};
|
|
@@ -7169,6 +7133,7 @@ const shouldOpenExternal = url => {
|
|
|
7169
7133
|
};
|
|
7170
7134
|
|
|
7171
7135
|
const openExternal = async url => {
|
|
7136
|
+
string(url);
|
|
7172
7137
|
if (!shouldOpenExternal(url)) {
|
|
7173
7138
|
throw new VError(`only http or https urls are allowed`);
|
|
7174
7139
|
}
|
|
@@ -7299,6 +7264,7 @@ const commandMap = {
|
|
|
7299
7264
|
'ElectronBeep.beep': beep,
|
|
7300
7265
|
'ElectronContentTracing.startRecording': startRecording,
|
|
7301
7266
|
'ElectronContentTracing.stopRecording': stopRecording,
|
|
7267
|
+
'ElectronContextMenu.openContextMenu': openContextMenu,
|
|
7302
7268
|
'ElectronDeveloper.crashMainProcess': crashMainProcess,
|
|
7303
7269
|
'ElectronDeveloper.getPerformanceEntries': getPerformanceEntries,
|
|
7304
7270
|
'ElectronDialog.showMessageBox': showMessageBox,
|
|
@@ -7369,88 +7335,6 @@ const commandMap = {
|
|
|
7369
7335
|
'Trash.trash': trash
|
|
7370
7336
|
};
|
|
7371
7337
|
|
|
7372
|
-
class ModuleNotFoundError extends Error {
|
|
7373
|
-
constructor(id) {
|
|
7374
|
-
super(`Module ${id} not found`);
|
|
7375
|
-
this.name = 'ModuleNotFoundError';
|
|
7376
|
-
// @ts-ignore
|
|
7377
|
-
this.code = E_MODULE_NOT_FOUND;
|
|
7378
|
-
}
|
|
7379
|
-
}
|
|
7380
|
-
|
|
7381
|
-
const load = async moduleId => {
|
|
7382
|
-
switch (moduleId) {
|
|
7383
|
-
case App:
|
|
7384
|
-
return Promise.resolve().then(function () { return App_ipc; });
|
|
7385
|
-
case AppWindow:
|
|
7386
|
-
return Promise.resolve().then(function () { return AppWindow_ipc; });
|
|
7387
|
-
case Beep:
|
|
7388
|
-
return Promise.resolve().then(function () { return Beep_ipc; });
|
|
7389
|
-
case Crash:
|
|
7390
|
-
return Promise.resolve().then(function () { return Crash_ipc; });
|
|
7391
|
-
case CreateMessagePort:
|
|
7392
|
-
return Promise.resolve().then(function () { return CreateMessagePort_ipc; });
|
|
7393
|
-
case CreatePidMap:
|
|
7394
|
-
return Promise.resolve().then(function () { return CreatePidMap_ipc; });
|
|
7395
|
-
case DesktopCapturer:
|
|
7396
|
-
return Promise.resolve().then(function () { return DesktopCapturer_ipc; });
|
|
7397
|
-
case Developer:
|
|
7398
|
-
return Promise.resolve().then(function () { return ElectronDeveloper_ipc; });
|
|
7399
|
-
case Dialog:
|
|
7400
|
-
return Promise.resolve().then(function () { return ElectronDialog_ipc; });
|
|
7401
|
-
case ElectronApplicationMenu:
|
|
7402
|
-
return Promise.resolve().then(function () { return ElectronApplicationMenu_ipc; });
|
|
7403
|
-
case ElectronClipBoard:
|
|
7404
|
-
return Promise.resolve().then(function () { return ElectronClipBoard_ipc; });
|
|
7405
|
-
case ElectronContentTracing:
|
|
7406
|
-
return Promise.resolve().then(function () { return ElectronContentTracing_ipc; });
|
|
7407
|
-
case ElectronContextMenu:
|
|
7408
|
-
return Promise.resolve().then(function () { return ElectronContextMenu_ipc; });
|
|
7409
|
-
case ElectronNet:
|
|
7410
|
-
return Promise.resolve().then(function () { return ElectronNet_ipc; });
|
|
7411
|
-
case ElectronNetLog:
|
|
7412
|
-
return Promise.resolve().then(function () { return ElectronNetLog_ipc; });
|
|
7413
|
-
case ElectronPowerSaveBlocker:
|
|
7414
|
-
return Promise.resolve().then(function () { return ElectronPowerSaveBlocker_ipc; });
|
|
7415
|
-
case ElectronSafeStorage:
|
|
7416
|
-
return Promise.resolve().then(function () { return ElectronSafeStorage_ipc; });
|
|
7417
|
-
case ElectronScreen:
|
|
7418
|
-
return Promise.resolve().then(function () { return ElectronScreen_ipc; });
|
|
7419
|
-
case ElectronSession:
|
|
7420
|
-
return Promise.resolve().then(function () { return ElectronSession_ipc; });
|
|
7421
|
-
case ElectronShell:
|
|
7422
|
-
return Promise.resolve().then(function () { return ElectronShell_ipc; });
|
|
7423
|
-
case ElectronWebContents:
|
|
7424
|
-
return Promise.resolve().then(function () { return ElectronWebContents_ipc; });
|
|
7425
|
-
case ElectronWebContentsView:
|
|
7426
|
-
return Promise.resolve().then(function () { return ElectronWebContentsView_ipc; });
|
|
7427
|
-
case ElectronWebContentsViewFunctions:
|
|
7428
|
-
return Promise.resolve().then(function () { return ElectronWebContentsViewFunctions_ipc; });
|
|
7429
|
-
case ElectronWindowProcessExplorer:
|
|
7430
|
-
return Promise.resolve().then(function () { return ElectronWindowProcessExplorer_ipc; });
|
|
7431
|
-
case Exit:
|
|
7432
|
-
return Promise.resolve().then(function () { return Exit_ipc; });
|
|
7433
|
-
case GetWindowId:
|
|
7434
|
-
return Promise.resolve().then(function () { return GetWindowId_ipc; });
|
|
7435
|
-
case HandleElectronMessagePort:
|
|
7436
|
-
return Promise.resolve().then(function () { return HandleElectronMessagePort_ipc; });
|
|
7437
|
-
case IpcParent:
|
|
7438
|
-
return Promise.resolve().then(function () { return IpcParent_ipc; });
|
|
7439
|
-
case OpenExternal$1:
|
|
7440
|
-
return Promise.resolve().then(function () { return OpenExternal_ipc; });
|
|
7441
|
-
case Process:
|
|
7442
|
-
return Promise.resolve().then(function () { return Process_ipc; });
|
|
7443
|
-
case TemporaryMessagePort:
|
|
7444
|
-
return Promise.resolve().then(function () { return TemporaryMessagePort_ipc; });
|
|
7445
|
-
case Trash:
|
|
7446
|
-
return Promise.resolve().then(function () { return Trash_ipc; });
|
|
7447
|
-
case Window:
|
|
7448
|
-
return Promise.resolve().then(function () { return ElectronWindow_ipc; });
|
|
7449
|
-
default:
|
|
7450
|
-
throw new ModuleNotFoundError(moduleId);
|
|
7451
|
-
}
|
|
7452
|
-
};
|
|
7453
|
-
|
|
7454
7338
|
const setStackTraceLimit = value => {
|
|
7455
7339
|
if (Error.stackTraceLimit && Error.stackTraceLimit < value) {
|
|
7456
7340
|
Error.stackTraceLimit = value;
|
|
@@ -7465,518 +7349,7 @@ const main = async () => {
|
|
|
7465
7349
|
on$1('uncaughtExceptionMonitor', handleUncaughtExceptionMonitor);
|
|
7466
7350
|
// workaround for https://github.com/electron/electron/issues/36526
|
|
7467
7351
|
on$1('unhandledRejection', handleUnhandledRejection);
|
|
7468
|
-
setLoad(load);
|
|
7469
7352
|
await hydrate(isLinux, chromeUserDataPath, argv);
|
|
7470
7353
|
};
|
|
7471
7354
|
|
|
7472
7355
|
main();
|
|
7473
|
-
|
|
7474
|
-
const name$w = 'App';
|
|
7475
|
-
const Commands$w = {};
|
|
7476
|
-
|
|
7477
|
-
const App_ipc = {
|
|
7478
|
-
__proto__: null,
|
|
7479
|
-
Commands: Commands$w,
|
|
7480
|
-
name: name$w
|
|
7481
|
-
};
|
|
7482
|
-
|
|
7483
|
-
const name$v = 'AppWindow';
|
|
7484
|
-
const Commands$v = {
|
|
7485
|
-
createAppWindow: createAppWindow
|
|
7486
|
-
};
|
|
7487
|
-
|
|
7488
|
-
const AppWindow_ipc = {
|
|
7489
|
-
__proto__: null,
|
|
7490
|
-
Commands: Commands$v,
|
|
7491
|
-
name: name$v
|
|
7492
|
-
};
|
|
7493
|
-
|
|
7494
|
-
const name$u = 'Beep';
|
|
7495
|
-
const Commands$u = {
|
|
7496
|
-
beep: beep$1
|
|
7497
|
-
};
|
|
7498
|
-
|
|
7499
|
-
const Beep_ipc = {
|
|
7500
|
-
__proto__: null,
|
|
7501
|
-
Commands: Commands$u,
|
|
7502
|
-
name: name$u
|
|
7503
|
-
};
|
|
7504
|
-
|
|
7505
|
-
const name$t = 'Crash';
|
|
7506
|
-
const Commands$t = {
|
|
7507
|
-
crashMainProcess: crashMainProcess$1
|
|
7508
|
-
};
|
|
7509
|
-
|
|
7510
|
-
const Crash_ipc = {
|
|
7511
|
-
__proto__: null,
|
|
7512
|
-
Commands: Commands$t,
|
|
7513
|
-
name: name$t
|
|
7514
|
-
};
|
|
7515
|
-
|
|
7516
|
-
const name$s = 'CreateMessagePort';
|
|
7517
|
-
const Commands$s = {
|
|
7518
|
-
createMessagePort: createMessagePort
|
|
7519
|
-
};
|
|
7520
|
-
|
|
7521
|
-
const CreateMessagePort_ipc = {
|
|
7522
|
-
__proto__: null,
|
|
7523
|
-
Commands: Commands$s,
|
|
7524
|
-
name: name$s
|
|
7525
|
-
};
|
|
7526
|
-
|
|
7527
|
-
const name$r = 'CreatePidMap';
|
|
7528
|
-
const Commands$r = {
|
|
7529
|
-
createPidMap: createPidMap
|
|
7530
|
-
};
|
|
7531
|
-
|
|
7532
|
-
const CreatePidMap_ipc = {
|
|
7533
|
-
__proto__: null,
|
|
7534
|
-
Commands: Commands$r,
|
|
7535
|
-
name: name$r
|
|
7536
|
-
};
|
|
7537
|
-
|
|
7538
|
-
const name$q = 'DesktopCapturer';
|
|
7539
|
-
const Commands$q = {
|
|
7540
|
-
getSources: getSources
|
|
7541
|
-
};
|
|
7542
|
-
|
|
7543
|
-
const DesktopCapturer_ipc = {
|
|
7544
|
-
__proto__: null,
|
|
7545
|
-
Commands: Commands$q,
|
|
7546
|
-
name: name$q
|
|
7547
|
-
};
|
|
7548
|
-
|
|
7549
|
-
const name$p = 'ElectronDeveloper';
|
|
7550
|
-
const Commands$p = {
|
|
7551
|
-
crashMainProcess: crashMainProcess,
|
|
7552
|
-
getPerformanceEntries: getPerformanceEntries
|
|
7553
|
-
};
|
|
7554
|
-
|
|
7555
|
-
const ElectronDeveloper_ipc = {
|
|
7556
|
-
__proto__: null,
|
|
7557
|
-
Commands: Commands$p,
|
|
7558
|
-
name: name$p
|
|
7559
|
-
};
|
|
7560
|
-
|
|
7561
|
-
const name$o = 'ElectronDialog';
|
|
7562
|
-
const Commands$o = {
|
|
7563
|
-
showMessageBox: showMessageBox,
|
|
7564
|
-
showOpenDialog: showOpenDialog
|
|
7565
|
-
};
|
|
7566
|
-
|
|
7567
|
-
const ElectronDialog_ipc = {
|
|
7568
|
-
__proto__: null,
|
|
7569
|
-
Commands: Commands$o,
|
|
7570
|
-
name: name$o
|
|
7571
|
-
};
|
|
7572
|
-
|
|
7573
|
-
const name$n = 'ElectronApplicationMenu';
|
|
7574
|
-
const Commands$n = {
|
|
7575
|
-
setItems: setItems
|
|
7576
|
-
};
|
|
7577
|
-
|
|
7578
|
-
const ElectronApplicationMenu_ipc = {
|
|
7579
|
-
__proto__: null,
|
|
7580
|
-
Commands: Commands$n,
|
|
7581
|
-
name: name$n
|
|
7582
|
-
};
|
|
7583
|
-
|
|
7584
|
-
const writeText = text => {
|
|
7585
|
-
clipboard.writeText(text);
|
|
7586
|
-
};
|
|
7587
|
-
|
|
7588
|
-
const name$m = 'ElectronClipBoard';
|
|
7589
|
-
const Commands$m = {
|
|
7590
|
-
writeText: writeText
|
|
7591
|
-
};
|
|
7592
|
-
|
|
7593
|
-
const ElectronClipBoard_ipc = {
|
|
7594
|
-
__proto__: null,
|
|
7595
|
-
Commands: Commands$m,
|
|
7596
|
-
name: name$m
|
|
7597
|
-
};
|
|
7598
|
-
|
|
7599
|
-
const name$l = 'ElectronContentTracing';
|
|
7600
|
-
const Commands$l = {
|
|
7601
|
-
startRecording: startRecording,
|
|
7602
|
-
stopRecording: stopRecording
|
|
7603
|
-
};
|
|
7604
|
-
|
|
7605
|
-
const ElectronContentTracing_ipc = {
|
|
7606
|
-
__proto__: null,
|
|
7607
|
-
Commands: Commands$l,
|
|
7608
|
-
name: name$l
|
|
7609
|
-
};
|
|
7610
|
-
|
|
7611
|
-
const withResolvers = () => {
|
|
7612
|
-
/**
|
|
7613
|
-
* @type {any}
|
|
7614
|
-
*/
|
|
7615
|
-
let _resolve;
|
|
7616
|
-
/**
|
|
7617
|
-
* @type {any}
|
|
7618
|
-
*/
|
|
7619
|
-
let _reject;
|
|
7620
|
-
const promise = new Promise((resolve, reject) => {
|
|
7621
|
-
_resolve = resolve;
|
|
7622
|
-
_reject = reject;
|
|
7623
|
-
});
|
|
7624
|
-
return {
|
|
7625
|
-
promise,
|
|
7626
|
-
reject: _reject,
|
|
7627
|
-
resolve: _resolve
|
|
7628
|
-
};
|
|
7629
|
-
};
|
|
7630
|
-
|
|
7631
|
-
const getElectronCallbacks = () => {
|
|
7632
|
-
const {
|
|
7633
|
-
promise,
|
|
7634
|
-
resolve
|
|
7635
|
-
} = withResolvers();
|
|
7636
|
-
const handleClick = menuItem => {
|
|
7637
|
-
resolve({
|
|
7638
|
-
data: menuItem,
|
|
7639
|
-
type: 'click'
|
|
7640
|
-
});
|
|
7641
|
-
};
|
|
7642
|
-
const handleClose = () => {
|
|
7643
|
-
resolve({
|
|
7644
|
-
data: undefined,
|
|
7645
|
-
type: 'close'
|
|
7646
|
-
});
|
|
7647
|
-
};
|
|
7648
|
-
return {
|
|
7649
|
-
handleClick,
|
|
7650
|
-
handleClose,
|
|
7651
|
-
promise
|
|
7652
|
-
};
|
|
7653
|
-
};
|
|
7654
|
-
|
|
7655
|
-
const getElectronMenuItems = (menuItems, click) => {
|
|
7656
|
-
const template = [];
|
|
7657
|
-
for (const menuItem of menuItems) {
|
|
7658
|
-
// @ts-ignore
|
|
7659
|
-
template.push({
|
|
7660
|
-
...menuItem,
|
|
7661
|
-
click
|
|
7662
|
-
});
|
|
7663
|
-
}
|
|
7664
|
-
return template;
|
|
7665
|
-
};
|
|
7666
|
-
|
|
7667
|
-
// @ts-ignore
|
|
7668
|
-
const openContextMenu = async (menuItems, x, y) => {
|
|
7669
|
-
array(menuItems);
|
|
7670
|
-
number(x);
|
|
7671
|
-
number(y);
|
|
7672
|
-
const {
|
|
7673
|
-
handleClick,
|
|
7674
|
-
handleClose,
|
|
7675
|
-
promise
|
|
7676
|
-
} = getElectronCallbacks();
|
|
7677
|
-
const template = getElectronMenuItems(menuItems, handleClick);
|
|
7678
|
-
const menu = Menu.buildFromTemplate(template);
|
|
7679
|
-
const window = BrowserWindow.getFocusedWindow();
|
|
7680
|
-
if (!window) {
|
|
7681
|
-
return {
|
|
7682
|
-
data: undefined,
|
|
7683
|
-
type: 'close'
|
|
7684
|
-
};
|
|
7685
|
-
}
|
|
7686
|
-
menu.popup({
|
|
7687
|
-
callback: handleClose,
|
|
7688
|
-
window,
|
|
7689
|
-
x,
|
|
7690
|
-
y
|
|
7691
|
-
});
|
|
7692
|
-
const event = await promise;
|
|
7693
|
-
// @ts-ignore
|
|
7694
|
-
if (event.type === 'click') {
|
|
7695
|
-
return {
|
|
7696
|
-
// @ts-ignore
|
|
7697
|
-
data: event.data.label,
|
|
7698
|
-
type: 'click'
|
|
7699
|
-
};
|
|
7700
|
-
}
|
|
7701
|
-
// @ts-ignore
|
|
7702
|
-
if (event.type === 'close') {
|
|
7703
|
-
return {
|
|
7704
|
-
data: undefined,
|
|
7705
|
-
type: 'close'
|
|
7706
|
-
};
|
|
7707
|
-
}
|
|
7708
|
-
};
|
|
7709
|
-
|
|
7710
|
-
const name$k = 'ElectronContextMenu';
|
|
7711
|
-
const Commands$k = {
|
|
7712
|
-
openContextMenu: openContextMenu
|
|
7713
|
-
};
|
|
7714
|
-
|
|
7715
|
-
const ElectronContextMenu_ipc = {
|
|
7716
|
-
__proto__: null,
|
|
7717
|
-
Commands: Commands$k,
|
|
7718
|
-
name: name$k
|
|
7719
|
-
};
|
|
7720
|
-
|
|
7721
|
-
const name$j = 'ElectronNet';
|
|
7722
|
-
const Commands$j = {
|
|
7723
|
-
getJson: getJson
|
|
7724
|
-
};
|
|
7725
|
-
|
|
7726
|
-
const ElectronNet_ipc = {
|
|
7727
|
-
__proto__: null,
|
|
7728
|
-
Commands: Commands$j,
|
|
7729
|
-
name: name$j
|
|
7730
|
-
};
|
|
7731
|
-
|
|
7732
|
-
const name$i = 'ElectronNetLog';
|
|
7733
|
-
const Commands$i = {
|
|
7734
|
-
startLogging: startLogging,
|
|
7735
|
-
stopLogging: stopLogging
|
|
7736
|
-
};
|
|
7737
|
-
|
|
7738
|
-
const ElectronNetLog_ipc = {
|
|
7739
|
-
__proto__: null,
|
|
7740
|
-
Commands: Commands$i,
|
|
7741
|
-
name: name$i
|
|
7742
|
-
};
|
|
7743
|
-
|
|
7744
|
-
const name$h = 'ElectronPowerSaveBlocker';
|
|
7745
|
-
const Commands$h = {
|
|
7746
|
-
start: start,
|
|
7747
|
-
stop: stop
|
|
7748
|
-
};
|
|
7749
|
-
|
|
7750
|
-
const ElectronPowerSaveBlocker_ipc = {
|
|
7751
|
-
__proto__: null,
|
|
7752
|
-
Commands: Commands$h,
|
|
7753
|
-
name: name$h
|
|
7754
|
-
};
|
|
7755
|
-
|
|
7756
|
-
const name$g = 'ElectronSafeStorage';
|
|
7757
|
-
const Commands$g = {
|
|
7758
|
-
decrypt: decrypt,
|
|
7759
|
-
encrypt: encrypt,
|
|
7760
|
-
isEncryptionAvailable: isEncryptionAvailable
|
|
7761
|
-
};
|
|
7762
|
-
|
|
7763
|
-
const ElectronSafeStorage_ipc = {
|
|
7764
|
-
__proto__: null,
|
|
7765
|
-
Commands: Commands$g,
|
|
7766
|
-
name: name$g
|
|
7767
|
-
};
|
|
7768
|
-
|
|
7769
|
-
const name$f = 'ElectronScreen';
|
|
7770
|
-
const Commands$f = {
|
|
7771
|
-
getBounds: getBounds,
|
|
7772
|
-
getHeight: getHeight,
|
|
7773
|
-
getWidth: getWidth
|
|
7774
|
-
};
|
|
7775
|
-
|
|
7776
|
-
const ElectronScreen_ipc = {
|
|
7777
|
-
__proto__: null,
|
|
7778
|
-
Commands: Commands$f,
|
|
7779
|
-
name: name$f
|
|
7780
|
-
};
|
|
7781
|
-
|
|
7782
|
-
const name$e = 'ElectronSession';
|
|
7783
|
-
const Commands$e = {
|
|
7784
|
-
registerWebviewProtocol: registerWebviewProtocol
|
|
7785
|
-
};
|
|
7786
|
-
|
|
7787
|
-
const ElectronSession_ipc = {
|
|
7788
|
-
__proto__: null,
|
|
7789
|
-
Commands: Commands$e,
|
|
7790
|
-
name: name$e
|
|
7791
|
-
};
|
|
7792
|
-
|
|
7793
|
-
const name$d = 'ElectronShell';
|
|
7794
|
-
const Commands$d = {
|
|
7795
|
-
beep: beep$1,
|
|
7796
|
-
openExternal: openExternal,
|
|
7797
|
-
openPath: showItemInFolder,
|
|
7798
|
-
showItemInFolder: showItemInFolder
|
|
7799
|
-
};
|
|
7800
|
-
|
|
7801
|
-
const ElectronShell_ipc = {
|
|
7802
|
-
__proto__: null,
|
|
7803
|
-
Commands: Commands$d,
|
|
7804
|
-
name: name$d
|
|
7805
|
-
};
|
|
7806
|
-
|
|
7807
|
-
const name$c = 'ElectronWebContents';
|
|
7808
|
-
const Commands$c = {
|
|
7809
|
-
callFunction: callFunction,
|
|
7810
|
-
dispose: dispose$1,
|
|
7811
|
-
getStats: getStats$1
|
|
7812
|
-
};
|
|
7813
|
-
|
|
7814
|
-
const ElectronWebContents_ipc = {
|
|
7815
|
-
__proto__: null,
|
|
7816
|
-
Commands: Commands$c,
|
|
7817
|
-
name: name$c
|
|
7818
|
-
};
|
|
7819
|
-
|
|
7820
|
-
const name$b = 'ElectronWebContentsView';
|
|
7821
|
-
const Commands$b = {
|
|
7822
|
-
attachEventListeners: attachEventListeners,
|
|
7823
|
-
createWebContentsView: createWebContentsView,
|
|
7824
|
-
disposeWebContentsView: disposeWebContentsView
|
|
7825
|
-
};
|
|
7826
|
-
|
|
7827
|
-
const ElectronWebContentsView_ipc = {
|
|
7828
|
-
__proto__: null,
|
|
7829
|
-
Commands: Commands$b,
|
|
7830
|
-
name: name$b
|
|
7831
|
-
};
|
|
7832
|
-
|
|
7833
|
-
const name$a = 'ElectronWebContentsViewFunctions';
|
|
7834
|
-
const Commands$a = {
|
|
7835
|
-
addToWindow: addToWindow,
|
|
7836
|
-
backward: wrapBrowserViewCommand(backward),
|
|
7837
|
-
cancelNavigation: wrapBrowserViewCommand(cancelNavigation),
|
|
7838
|
-
copyImageAt: wrapBrowserViewCommand(copyImageAt),
|
|
7839
|
-
executeJavaScript: wrapBrowserViewCommand(executeJavaScript),
|
|
7840
|
-
focus: wrapBrowserViewCommand(focus),
|
|
7841
|
-
forward: wrapBrowserViewCommand(forward),
|
|
7842
|
-
getDomTree: wrapBrowserViewCommand(getDomTree),
|
|
7843
|
-
getStats: wrapBrowserViewCommand(getStats),
|
|
7844
|
-
hide: hide,
|
|
7845
|
-
insertCss: wrapBrowserViewCommand(insertCss),
|
|
7846
|
-
insertJavaScript: wrapBrowserViewCommand(executeJavaScript),
|
|
7847
|
-
inspectElement: wrapBrowserViewCommand(inspectElement),
|
|
7848
|
-
openDevtools: wrapBrowserViewCommand(openDevtools),
|
|
7849
|
-
reload: wrapBrowserViewCommand(reload),
|
|
7850
|
-
resizeBrowserView: wrapBrowserViewCommand(resizeBrowserView),
|
|
7851
|
-
setBackgroundColor: wrapBrowserViewCommand(setBackgroundColor),
|
|
7852
|
-
setFallthroughKeyBindings: setFallThroughKeyBindings,
|
|
7853
|
-
setIframeSrc: wrapBrowserViewCommand(setIframeSrc),
|
|
7854
|
-
setIframeSrcFallback: wrapBrowserViewCommand(setIframeSrcFallback),
|
|
7855
|
-
show: show
|
|
7856
|
-
};
|
|
7857
|
-
|
|
7858
|
-
const ElectronWebContentsViewFunctions_ipc = {
|
|
7859
|
-
__proto__: null,
|
|
7860
|
-
Commands: Commands$a,
|
|
7861
|
-
name: name$a
|
|
7862
|
-
};
|
|
7863
|
-
|
|
7864
|
-
const name$9 = 'ElectronWindowProcessExplorer';
|
|
7865
|
-
const Commands$9 = {
|
|
7866
|
-
open2: open2
|
|
7867
|
-
};
|
|
7868
|
-
|
|
7869
|
-
const ElectronWindowProcessExplorer_ipc = {
|
|
7870
|
-
__proto__: null,
|
|
7871
|
-
Commands: Commands$9,
|
|
7872
|
-
name: name$9
|
|
7873
|
-
};
|
|
7874
|
-
|
|
7875
|
-
const name$8 = 'Exit';
|
|
7876
|
-
const Commands$8 = {
|
|
7877
|
-
exit: exit
|
|
7878
|
-
};
|
|
7879
|
-
|
|
7880
|
-
const Exit_ipc = {
|
|
7881
|
-
__proto__: null,
|
|
7882
|
-
Commands: Commands$8,
|
|
7883
|
-
name: name$8
|
|
7884
|
-
};
|
|
7885
|
-
|
|
7886
|
-
const name$7 = 'GetWindowId';
|
|
7887
|
-
const Commands$7 = {
|
|
7888
|
-
getWindowId: getWindowId
|
|
7889
|
-
};
|
|
7890
|
-
|
|
7891
|
-
const GetWindowId_ipc = {
|
|
7892
|
-
__proto__: null,
|
|
7893
|
-
Commands: Commands$7,
|
|
7894
|
-
name: name$7
|
|
7895
|
-
};
|
|
7896
|
-
|
|
7897
|
-
const name$6 = 'HandleElectronMessagePort';
|
|
7898
|
-
const Commands$6 = {
|
|
7899
|
-
handleElectronMessagePort: handleElectronMessagePort
|
|
7900
|
-
};
|
|
7901
|
-
|
|
7902
|
-
const HandleElectronMessagePort_ipc = {
|
|
7903
|
-
__proto__: null,
|
|
7904
|
-
Commands: Commands$6,
|
|
7905
|
-
name: name$6
|
|
7906
|
-
};
|
|
7907
|
-
|
|
7908
|
-
const name$5 = 'IpcParent';
|
|
7909
|
-
const Commands$5 = {
|
|
7910
|
-
create: create$1
|
|
7911
|
-
};
|
|
7912
|
-
|
|
7913
|
-
const IpcParent_ipc = {
|
|
7914
|
-
__proto__: null,
|
|
7915
|
-
Commands: Commands$5,
|
|
7916
|
-
name: name$5
|
|
7917
|
-
};
|
|
7918
|
-
|
|
7919
|
-
const name$4 = 'OpenExternal';
|
|
7920
|
-
const Commands$4 = {
|
|
7921
|
-
openExternal: openExternal
|
|
7922
|
-
};
|
|
7923
|
-
|
|
7924
|
-
const OpenExternal_ipc = {
|
|
7925
|
-
__proto__: null,
|
|
7926
|
-
Commands: Commands$4,
|
|
7927
|
-
name: name$4
|
|
7928
|
-
};
|
|
7929
|
-
|
|
7930
|
-
const name$3 = 'Process';
|
|
7931
|
-
const Commands$3 = {
|
|
7932
|
-
getArgv: getArgv,
|
|
7933
|
-
getChromeVersion: getChromeVersion,
|
|
7934
|
-
getElectronVersion: getElectronVersion,
|
|
7935
|
-
getNodeVersion: getNodeVersion,
|
|
7936
|
-
getPid: getPid,
|
|
7937
|
-
getV8Version: getV8Version
|
|
7938
|
-
};
|
|
7939
|
-
|
|
7940
|
-
const Process_ipc = {
|
|
7941
|
-
__proto__: null,
|
|
7942
|
-
Commands: Commands$3,
|
|
7943
|
-
name: name$3
|
|
7944
|
-
};
|
|
7945
|
-
|
|
7946
|
-
const name$2 = 'TemporaryMessagePort';
|
|
7947
|
-
const Commands$2 = {
|
|
7948
|
-
createPortTuple: createPortTuple,
|
|
7949
|
-
dispose: dispose,
|
|
7950
|
-
sendTo: sendTo
|
|
7951
|
-
};
|
|
7952
|
-
|
|
7953
|
-
const TemporaryMessagePort_ipc = {
|
|
7954
|
-
__proto__: null,
|
|
7955
|
-
Commands: Commands$2,
|
|
7956
|
-
name: name$2
|
|
7957
|
-
};
|
|
7958
|
-
|
|
7959
|
-
const name$1 = 'Trash';
|
|
7960
|
-
const Commands$1 = {
|
|
7961
|
-
trash: trash
|
|
7962
|
-
};
|
|
7963
|
-
|
|
7964
|
-
const Trash_ipc = {
|
|
7965
|
-
__proto__: null,
|
|
7966
|
-
Commands: Commands$1,
|
|
7967
|
-
name: name$1
|
|
7968
|
-
};
|
|
7969
|
-
|
|
7970
|
-
const name = 'ElectronWindow';
|
|
7971
|
-
const Commands = {
|
|
7972
|
-
executeWebContentsFunction: executeWebContentsFunction,
|
|
7973
|
-
executeWindowFunction: executeWindowFunction,
|
|
7974
|
-
getFocusedWindowId: getFocusedWindowId,
|
|
7975
|
-
getZoom: getZoom
|
|
7976
|
-
};
|
|
7977
|
-
|
|
7978
|
-
const ElectronWindow_ipc = {
|
|
7979
|
-
__proto__: null,
|
|
7980
|
-
Commands,
|
|
7981
|
-
name
|
|
7982
|
-
};
|