@lvce-editor/main-process 3.1.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 +185 -135
- package/package.json +2 -2
package/dist/mainProcessMain.js
CHANGED
|
@@ -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);
|
|
@@ -2336,8 +2336,8 @@ 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,
|
|
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,9 +2417,9 @@ 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
2424
|
if (type === Exit) {
|
|
2425
2425
|
throw new IpcError(`Utility process exited before ipc connection was established`, stdout, stderr);
|
|
@@ -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,
|
|
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,9 +2586,9 @@ 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
2593
|
if (type === Exit) {
|
|
2594
2594
|
throw new ChildProcessError(stderr);
|
|
@@ -2653,18 +2653,18 @@ const fixNodeWorkerParameters = value => {
|
|
|
2653
2653
|
};
|
|
2654
2654
|
const getFirstNodeWorkerEvent = worker => {
|
|
2655
2655
|
return getFirstEvent(worker, {
|
|
2656
|
-
|
|
2656
|
+
error: Error$2,
|
|
2657
2657
|
exit: Exit,
|
|
2658
|
-
|
|
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,13 +2680,13 @@ 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
2691
|
if (type === Exit) {
|
|
2692
2692
|
throw new IpcError(`Worker exited before ipc connection was established`);
|
|
@@ -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
|
|
@@ -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,15 +3094,8 @@ 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 {
|
|
@@ -3133,24 +3119,87 @@ const execute$1 = (command, ...args) => {
|
|
|
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,7 +3234,7 @@ 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
|
|
@@ -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
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,12 +3284,12 @@ 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
3295
|
register(commandMap);
|
|
@@ -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);
|
|
@@ -7084,6 +7133,7 @@ const shouldOpenExternal = url => {
|
|
|
7084
7133
|
};
|
|
7085
7134
|
|
|
7086
7135
|
const openExternal = async url => {
|
|
7136
|
+
string(url);
|
|
7087
7137
|
if (!shouldOpenExternal(url)) {
|
|
7088
7138
|
throw new VError(`only http or https urls are allowed`);
|
|
7089
7139
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/main-process",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"lvce-editor",
|
|
6
6
|
"electron"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"type": "module",
|
|
15
15
|
"main": "dist/mainProcessMain.js",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"electron": "
|
|
17
|
+
"electron": "40.0.0"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=22"
|