@lvce-editor/main-process 1.12.0 → 2.1.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 +2328 -2145
- package/package.json +2 -2
package/dist/mainProcessMain.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as Electron from 'electron';
|
|
2
|
-
import Electron__default, { dialog, app, clipboard, BrowserWindow, MessageChannelMain, Menu, shell, desktopCapturer, contentTracing, net, netLog, powerSaveBlocker, safeStorage, screen,
|
|
2
|
+
import Electron__default, { dialog, app, clipboard, BrowserWindow, MessageChannelMain, Menu, shell, desktopCapturer, contentTracing, net, netLog, powerSaveBlocker, safeStorage, screen, WebContentsView, webContents } from 'electron';
|
|
3
3
|
import process$1 from 'node:process';
|
|
4
4
|
import { inspect } from 'node:util';
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
6
|
+
import { MessageChannel } from 'node:worker_threads';
|
|
6
7
|
import { createWriteStream, readFileSync } from 'node:fs';
|
|
7
8
|
import * as NodePath from 'node:path';
|
|
8
9
|
import { dirname } from 'node:path';
|
|
@@ -12,7 +13,6 @@ import require$$0 from 'os';
|
|
|
12
13
|
import { Console } from 'node:console';
|
|
13
14
|
import { tmpdir, homedir } from 'node:os';
|
|
14
15
|
import { fileURLToPath } from 'node:url';
|
|
15
|
-
import { MessageChannel } from 'node:worker_threads';
|
|
16
16
|
|
|
17
17
|
function escapeStringRegexp(string) {
|
|
18
18
|
if (typeof string !== 'string') {
|
|
@@ -1679,11 +1679,11 @@ const remove$2 = id => {
|
|
|
1679
1679
|
delete callbacks[id];
|
|
1680
1680
|
};
|
|
1681
1681
|
let id = 0;
|
|
1682
|
-
const create$3 = () => {
|
|
1682
|
+
const create$3$1 = () => {
|
|
1683
1683
|
return ++id;
|
|
1684
1684
|
};
|
|
1685
1685
|
const registerPromise = () => {
|
|
1686
|
-
const id = create$3();
|
|
1686
|
+
const id = create$3$1();
|
|
1687
1687
|
const {
|
|
1688
1688
|
resolve,
|
|
1689
1689
|
promise
|
|
@@ -2006,245 +2006,6 @@ const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
|
2006
2006
|
return invokeHelper(ipc, method, params, true);
|
|
2007
2007
|
};
|
|
2008
2008
|
|
|
2009
|
-
const getPortTuple = () => {
|
|
2010
|
-
const {
|
|
2011
|
-
port1,
|
|
2012
|
-
port2
|
|
2013
|
-
} = new MessageChannelMain();
|
|
2014
|
-
return {
|
|
2015
|
-
port1,
|
|
2016
|
-
port2
|
|
2017
|
-
};
|
|
2018
|
-
};
|
|
2019
|
-
|
|
2020
|
-
const getSharedProcessArgv = isProduction => {
|
|
2021
|
-
return [];
|
|
2022
|
-
};
|
|
2023
|
-
|
|
2024
|
-
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
2025
|
-
const E_MODULE_NOT_FOUND = 'E_MODULE_NOT_FOUND';
|
|
2026
|
-
|
|
2027
|
-
class CommandNotFoundError extends Error {
|
|
2028
|
-
constructor(id) {
|
|
2029
|
-
super(`command ${id} not found`);
|
|
2030
|
-
this.name = 'CommandNotFoundError';
|
|
2031
|
-
// @ts-ignore
|
|
2032
|
-
this.code = E_COMMAND_NOT_FOUND;
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
|
|
2036
|
-
const App = 1;
|
|
2037
|
-
const AppWindow = 2;
|
|
2038
|
-
const Beep = 3;
|
|
2039
|
-
const Developer = 4;
|
|
2040
|
-
const Dialog = 5;
|
|
2041
|
-
const ElectronWindowProcessExplorer = 6;
|
|
2042
|
-
const Window = 7;
|
|
2043
|
-
const ElectronShell = 8;
|
|
2044
|
-
const ElectronPowerSaveBlocker = 9;
|
|
2045
|
-
const ElectronSafeStorage = 10;
|
|
2046
|
-
const ElectronContentTracing = 11;
|
|
2047
|
-
const ElectronNetLog = 12;
|
|
2048
|
-
const ElectronBrowserView = 13;
|
|
2049
|
-
const ElectronBrowserViewQuickPick = 14;
|
|
2050
|
-
const ElectronContextMenu = 16;
|
|
2051
|
-
const ElectronClipBoard = 17;
|
|
2052
|
-
const ElectronApplicationMenu = 18;
|
|
2053
|
-
const Process = 19;
|
|
2054
|
-
const ElectronNet = 20;
|
|
2055
|
-
const ElectronBrowserViewSuggestions = 21;
|
|
2056
|
-
const CreatePidMap = 22;
|
|
2057
|
-
const OpenExternal$1 = 23;
|
|
2058
|
-
const Platform = 25;
|
|
2059
|
-
const GetWindowId = 26;
|
|
2060
|
-
const DesktopCapturer = 27;
|
|
2061
|
-
const Trash = 28;
|
|
2062
|
-
const IpcParent = 29;
|
|
2063
|
-
const Crash = 30;
|
|
2064
|
-
const Exit$1 = 31;
|
|
2065
|
-
const ElectronScreen = 32;
|
|
2066
|
-
const TemporaryMessagePort = 34;
|
|
2067
|
-
const ElectronWebContents = 35;
|
|
2068
|
-
const ElectronWebContentsView = 36;
|
|
2069
|
-
const ElectronWebContentsViewFunctions = 37;
|
|
2070
|
-
const CreateMessagePort = 38;
|
|
2071
|
-
const HandleElectronMessagePort = 39;
|
|
2072
|
-
const ElectronSession = 40;
|
|
2073
|
-
|
|
2074
|
-
const getPrefix = commandId => {
|
|
2075
|
-
return commandId.slice(0, commandId.indexOf('.'));
|
|
2076
|
-
};
|
|
2077
|
-
const getModuleId = commandId => {
|
|
2078
|
-
const prefix = getPrefix(commandId);
|
|
2079
|
-
switch (prefix) {
|
|
2080
|
-
case 'Crash':
|
|
2081
|
-
return Crash;
|
|
2082
|
-
case 'ElectronApp':
|
|
2083
|
-
case 'App':
|
|
2084
|
-
return App;
|
|
2085
|
-
case 'Beep':
|
|
2086
|
-
return Beep;
|
|
2087
|
-
case 'ElectronWindow':
|
|
2088
|
-
return Window;
|
|
2089
|
-
case 'ElectronDeveloper':
|
|
2090
|
-
return Developer;
|
|
2091
|
-
case 'AppWindow':
|
|
2092
|
-
return AppWindow;
|
|
2093
|
-
case 'ElectronWindowProcessExplorer':
|
|
2094
|
-
return ElectronWindowProcessExplorer;
|
|
2095
|
-
case 'ElectronDialog':
|
|
2096
|
-
return Dialog;
|
|
2097
|
-
case 'ElectronBeep':
|
|
2098
|
-
return Beep;
|
|
2099
|
-
case 'ElectronShell':
|
|
2100
|
-
return ElectronShell;
|
|
2101
|
-
case 'ElectronPowerSaveBlocker':
|
|
2102
|
-
return ElectronPowerSaveBlocker;
|
|
2103
|
-
case 'ElectronSafeStorage':
|
|
2104
|
-
return ElectronSafeStorage;
|
|
2105
|
-
case 'ElectronContentTracing':
|
|
2106
|
-
return ElectronContentTracing;
|
|
2107
|
-
case 'ElectronNetLog':
|
|
2108
|
-
return ElectronNetLog;
|
|
2109
|
-
case 'ElectronBrowserView':
|
|
2110
|
-
return ElectronBrowserView;
|
|
2111
|
-
case 'ElectronBrowserViewQuickPick':
|
|
2112
|
-
return ElectronBrowserViewQuickPick;
|
|
2113
|
-
case 'ElectronContextMenu':
|
|
2114
|
-
return ElectronContextMenu;
|
|
2115
|
-
case 'ElectronClipBoard':
|
|
2116
|
-
return ElectronClipBoard;
|
|
2117
|
-
case 'ElectronApplicationMenu':
|
|
2118
|
-
return ElectronApplicationMenu;
|
|
2119
|
-
case 'Process':
|
|
2120
|
-
return Process;
|
|
2121
|
-
case 'ElectronNet':
|
|
2122
|
-
return ElectronNet;
|
|
2123
|
-
case 'ElectronBrowserViewSuggestions':
|
|
2124
|
-
return ElectronBrowserViewSuggestions;
|
|
2125
|
-
case 'CreatePidMap':
|
|
2126
|
-
return CreatePidMap;
|
|
2127
|
-
case 'OpenExternal':
|
|
2128
|
-
return OpenExternal$1;
|
|
2129
|
-
case 'Platform':
|
|
2130
|
-
return Platform;
|
|
2131
|
-
case 'GetWindowId':
|
|
2132
|
-
return GetWindowId;
|
|
2133
|
-
case 'DesktopCapturer':
|
|
2134
|
-
return DesktopCapturer;
|
|
2135
|
-
case 'Trash':
|
|
2136
|
-
return Trash;
|
|
2137
|
-
case 'IpcParent':
|
|
2138
|
-
return IpcParent;
|
|
2139
|
-
case 'Exit':
|
|
2140
|
-
return Exit$1;
|
|
2141
|
-
case 'ElectronScreen':
|
|
2142
|
-
return ElectronScreen;
|
|
2143
|
-
case 'TemporaryMessagePort':
|
|
2144
|
-
return TemporaryMessagePort;
|
|
2145
|
-
case 'ElectronWebContents':
|
|
2146
|
-
return ElectronWebContents;
|
|
2147
|
-
case 'ElectronWebContentsView':
|
|
2148
|
-
return ElectronWebContentsView;
|
|
2149
|
-
case 'ElectronWebContentsViewFunctions':
|
|
2150
|
-
return ElectronWebContentsViewFunctions;
|
|
2151
|
-
case 'CreateMessagePort':
|
|
2152
|
-
return CreateMessagePort;
|
|
2153
|
-
case 'HandleElectronMessagePort':
|
|
2154
|
-
return HandleElectronMessagePort;
|
|
2155
|
-
case 'ElectronSession':
|
|
2156
|
-
return ElectronSession;
|
|
2157
|
-
default:
|
|
2158
|
-
throw new CommandNotFoundError(commandId);
|
|
2159
|
-
}
|
|
2160
|
-
};
|
|
2161
|
-
|
|
2162
|
-
const state$7 = {
|
|
2163
|
-
commands: Object.create(null),
|
|
2164
|
-
pendingModules: Object.create(null),
|
|
2165
|
-
async load(moduleId) {}
|
|
2166
|
-
};
|
|
2167
|
-
const initializeModule = module => {
|
|
2168
|
-
if (module.Commands) {
|
|
2169
|
-
for (const [key, value] of Object.entries(module.Commands)) {
|
|
2170
|
-
if (module.name) {
|
|
2171
|
-
const actualKey = `${module.name}.${key}`;
|
|
2172
|
-
register(actualKey, value);
|
|
2173
|
-
} else {
|
|
2174
|
-
register(key, value);
|
|
2175
|
-
}
|
|
2176
|
-
}
|
|
2177
|
-
return;
|
|
2178
|
-
}
|
|
2179
|
-
throw new Error(`module ${module.name || '<unnamed module>'} is missing commands`);
|
|
2180
|
-
};
|
|
2181
|
-
const getOrLoadModule = moduleId => {
|
|
2182
|
-
if (!state$7.pendingModules[moduleId]) {
|
|
2183
|
-
const importPromise = state$7.load(moduleId);
|
|
2184
|
-
state$7.pendingModules[moduleId] = importPromise.then(initializeModule);
|
|
2185
|
-
}
|
|
2186
|
-
return state$7.pendingModules[moduleId];
|
|
2187
|
-
};
|
|
2188
|
-
const loadCommand = command => getOrLoadModule(getModuleId(command));
|
|
2189
|
-
const register = (commandId, listener) => {
|
|
2190
|
-
state$7.commands[commandId] = listener;
|
|
2191
|
-
};
|
|
2192
|
-
const hasThrown = new Set();
|
|
2193
|
-
const loadThenExecute = async (command, ...args) => {
|
|
2194
|
-
await loadCommand(command);
|
|
2195
|
-
// TODO can skip then block in prod (only to prevent endless loop in dev)
|
|
2196
|
-
if (!(command in state$7.commands)) {
|
|
2197
|
-
if (hasThrown.has(command)) {
|
|
2198
|
-
return;
|
|
2199
|
-
}
|
|
2200
|
-
hasThrown.add(command);
|
|
2201
|
-
throw new Error(`Command did not register "${command}"`);
|
|
2202
|
-
}
|
|
2203
|
-
return execute(command, ...args);
|
|
2204
|
-
};
|
|
2205
|
-
const execute = (command, ...args) => {
|
|
2206
|
-
if (command in state$7.commands) {
|
|
2207
|
-
return state$7.commands[command](...args);
|
|
2208
|
-
}
|
|
2209
|
-
return loadThenExecute(command, ...args);
|
|
2210
|
-
};
|
|
2211
|
-
const setLoad = load => {
|
|
2212
|
-
state$7.load = load;
|
|
2213
|
-
};
|
|
2214
|
-
|
|
2215
|
-
const printPrettyError = (prettyError, prefix = '') => {
|
|
2216
|
-
error(`${prefix}${prettyError.type}: ${prettyError.message}\n\n${prettyError.codeFrame}\n\n${prettyError.stack}\n`);
|
|
2217
|
-
};
|
|
2218
|
-
|
|
2219
|
-
const requiresSocket = () => {
|
|
2220
|
-
return false;
|
|
2221
|
-
};
|
|
2222
|
-
|
|
2223
|
-
const logError = (error, prettyError) => {
|
|
2224
|
-
printPrettyError(prettyError, '[main-process] ');
|
|
2225
|
-
};
|
|
2226
|
-
const handleMessage = event => {
|
|
2227
|
-
return handleJsonRpcMessage(event.target, event.data, execute, resolve, prepare,
|
|
2228
|
-
// @ts-ignore
|
|
2229
|
-
logError, requiresSocket);
|
|
2230
|
-
};
|
|
2231
|
-
|
|
2232
|
-
const handleIpc = ipc => {
|
|
2233
|
-
if ('addEventListener' in ipc) {
|
|
2234
|
-
ipc.addEventListener('message', handleMessage);
|
|
2235
|
-
} else if ('on' in ipc) {
|
|
2236
|
-
// deprecated
|
|
2237
|
-
ipc.on('message', handleMessage);
|
|
2238
|
-
}
|
|
2239
|
-
};
|
|
2240
|
-
const unhandleIpc = ipc => {
|
|
2241
|
-
if ('removeEventListener' in ipc) {
|
|
2242
|
-
ipc.removeEventListener('message', handleMessage);
|
|
2243
|
-
} else if ('off' in ipc) {
|
|
2244
|
-
ipc.off('message', handleMessage);
|
|
2245
|
-
}
|
|
2246
|
-
};
|
|
2247
|
-
|
|
2248
2009
|
const normalizeLine = line => {
|
|
2249
2010
|
if (line.startsWith('Error: ')) {
|
|
2250
2011
|
return line.slice('Error: '.length);
|
|
@@ -2663,17 +2424,6 @@ const IpcChildWithElectronUtilityProcess$1 = {
|
|
|
2663
2424
|
signal: signal$b,
|
|
2664
2425
|
wrap: wrap$i
|
|
2665
2426
|
};
|
|
2666
|
-
const withResolvers$1 = () => {
|
|
2667
|
-
let _resolve;
|
|
2668
|
-
const promise = new Promise(resolve => {
|
|
2669
|
-
_resolve = resolve;
|
|
2670
|
-
});
|
|
2671
|
-
return {
|
|
2672
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
2673
|
-
resolve: _resolve,
|
|
2674
|
-
promise
|
|
2675
|
-
};
|
|
2676
|
-
};
|
|
2677
2427
|
const getActualData = (message, handle) => {
|
|
2678
2428
|
if (handle) {
|
|
2679
2429
|
return {
|
|
@@ -2835,7 +2585,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
2835
2585
|
const {
|
|
2836
2586
|
resolve,
|
|
2837
2587
|
promise
|
|
2838
|
-
} = withResolvers
|
|
2588
|
+
} = Promise.withResolvers();
|
|
2839
2589
|
const listenerMap = Object.create(null);
|
|
2840
2590
|
const cleanup = value => {
|
|
2841
2591
|
for (const event of Object.keys(eventMap)) {
|
|
@@ -2897,14 +2647,14 @@ const IpcParentWithElectronMessagePort$1 = {
|
|
|
2897
2647
|
signal: signal$2,
|
|
2898
2648
|
wrap: wrap$7
|
|
2899
2649
|
};
|
|
2900
|
-
const Exit = 1;
|
|
2650
|
+
const Exit$1 = 1;
|
|
2901
2651
|
const Error$2 = 2;
|
|
2902
2652
|
const Message$1 = 3;
|
|
2903
2653
|
const getFirstUtilityProcessEvent = async utilityProcess => {
|
|
2904
2654
|
const {
|
|
2905
2655
|
resolve,
|
|
2906
2656
|
promise
|
|
2907
|
-
} = withResolvers
|
|
2657
|
+
} = Promise.withResolvers();
|
|
2908
2658
|
let stdout = '';
|
|
2909
2659
|
let stderr = '';
|
|
2910
2660
|
const cleanup = value => {
|
|
@@ -2932,7 +2682,7 @@ const getFirstUtilityProcessEvent = async utilityProcess => {
|
|
|
2932
2682
|
};
|
|
2933
2683
|
const handleExit = event => {
|
|
2934
2684
|
cleanup({
|
|
2935
|
-
type: Exit,
|
|
2685
|
+
type: Exit$1,
|
|
2936
2686
|
event,
|
|
2937
2687
|
stdout,
|
|
2938
2688
|
stderr
|
|
@@ -2987,7 +2737,7 @@ const create$6 = async ({
|
|
|
2987
2737
|
stdout,
|
|
2988
2738
|
stderr
|
|
2989
2739
|
} = await getFirstUtilityProcessEvent(childProcess);
|
|
2990
|
-
if (type === Exit) {
|
|
2740
|
+
if (type === Exit$1) {
|
|
2991
2741
|
throw new IpcError(`Utility process exited before ipc connection was established`, stdout, stderr);
|
|
2992
2742
|
}
|
|
2993
2743
|
// @ts-ignore
|
|
@@ -3101,7 +2851,7 @@ const getFirstNodeChildProcessEvent = async childProcess => {
|
|
|
3101
2851
|
};
|
|
3102
2852
|
const handleExit = event => {
|
|
3103
2853
|
cleanup({
|
|
3104
|
-
type: Exit,
|
|
2854
|
+
type: Exit$1,
|
|
3105
2855
|
event,
|
|
3106
2856
|
stdout,
|
|
3107
2857
|
stderr
|
|
@@ -3156,7 +2906,7 @@ const create$2$1 = async ({
|
|
|
3156
2906
|
event,
|
|
3157
2907
|
stderr
|
|
3158
2908
|
} = await getFirstNodeChildProcessEvent(childProcess);
|
|
3159
|
-
if (type === Exit) {
|
|
2909
|
+
if (type === Exit$1) {
|
|
3160
2910
|
throw new ChildProcessError(stderr);
|
|
3161
2911
|
}
|
|
3162
2912
|
if (type === Error$2) {
|
|
@@ -3220,7 +2970,7 @@ const fixNodeWorkerParameters = value => {
|
|
|
3220
2970
|
const getFirstNodeWorkerEvent = worker => {
|
|
3221
2971
|
return getFirstEvent(worker, {
|
|
3222
2972
|
message: Message$1,
|
|
3223
|
-
exit: Exit,
|
|
2973
|
+
exit: Exit$1,
|
|
3224
2974
|
error: Error$2
|
|
3225
2975
|
});
|
|
3226
2976
|
};
|
|
@@ -3250,7 +3000,7 @@ const create$1$1 = async ({
|
|
|
3250
3000
|
type,
|
|
3251
3001
|
event
|
|
3252
3002
|
} = await getFirstNodeWorkerEvent(worker);
|
|
3253
|
-
if (type === Exit) {
|
|
3003
|
+
if (type === Exit$1) {
|
|
3254
3004
|
throw new IpcError(`Worker exited before ipc connection was established`);
|
|
3255
3005
|
}
|
|
3256
3006
|
if (type === Error$2) {
|
|
@@ -3294,91 +3044,146 @@ const IpcParentWithNodeWorker$1 = {
|
|
|
3294
3044
|
wrap: wrap$1
|
|
3295
3045
|
};
|
|
3296
3046
|
|
|
3297
|
-
const
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
return IpcChildWithRendererProcess2$1;
|
|
3309
|
-
default:
|
|
3310
|
-
throw new Error('unexpected ipc type');
|
|
3047
|
+
const commands = Object.create(null);
|
|
3048
|
+
const register$1 = commandMap => {
|
|
3049
|
+
Object.assign(commands, commandMap);
|
|
3050
|
+
};
|
|
3051
|
+
const getCommand = key => {
|
|
3052
|
+
return commands[key];
|
|
3053
|
+
};
|
|
3054
|
+
const execute$1 = (command, ...args) => {
|
|
3055
|
+
const fn = getCommand(command);
|
|
3056
|
+
if (!fn) {
|
|
3057
|
+
throw new Error(`command not found ${command}`);
|
|
3311
3058
|
}
|
|
3059
|
+
return fn(...args);
|
|
3312
3060
|
};
|
|
3313
3061
|
|
|
3314
|
-
const
|
|
3315
|
-
|
|
3316
|
-
...params
|
|
3317
|
-
}) => {
|
|
3318
|
-
const module = getModule$3(method);
|
|
3319
|
-
// @ts-ignore
|
|
3320
|
-
const rawIpc = await module.listen(params);
|
|
3321
|
-
// @ts-ignore
|
|
3322
|
-
if (module.signal) {
|
|
3062
|
+
const createRpc = ipc => {
|
|
3063
|
+
const rpc = {
|
|
3323
3064
|
// @ts-ignore
|
|
3065
|
+
ipc,
|
|
3066
|
+
/**
|
|
3067
|
+
* @deprecated
|
|
3068
|
+
*/
|
|
3069
|
+
send(method, ...params) {
|
|
3070
|
+
send$2(ipc, method, ...params);
|
|
3071
|
+
},
|
|
3072
|
+
invoke(method, ...params) {
|
|
3073
|
+
return invoke$1(ipc, method, ...params);
|
|
3074
|
+
},
|
|
3075
|
+
invokeAndTransfer(method, ...params) {
|
|
3076
|
+
return invokeAndTransfer$1(ipc, method, ...params);
|
|
3077
|
+
},
|
|
3078
|
+
async dispose() {
|
|
3079
|
+
await ipc?.dispose();
|
|
3080
|
+
}
|
|
3081
|
+
};
|
|
3082
|
+
return rpc;
|
|
3083
|
+
};
|
|
3084
|
+
const requiresSocket$1 = () => {
|
|
3085
|
+
return false;
|
|
3086
|
+
};
|
|
3087
|
+
const preparePrettyError = error => {
|
|
3088
|
+
return error;
|
|
3089
|
+
};
|
|
3090
|
+
const logError$1 = () => {
|
|
3091
|
+
// handled by renderer worker
|
|
3092
|
+
};
|
|
3093
|
+
const handleMessage$1 = event => {
|
|
3094
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket$1;
|
|
3095
|
+
const actualExecute = event?.target?.execute || execute$1;
|
|
3096
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError$1, actualRequiresSocket);
|
|
3097
|
+
};
|
|
3098
|
+
const handleIpc$1 = ipc => {
|
|
3099
|
+
if ('addEventListener' in ipc) {
|
|
3100
|
+
ipc.addEventListener('message', handleMessage$1);
|
|
3101
|
+
} else if ('on' in ipc) {
|
|
3102
|
+
// deprecated
|
|
3103
|
+
ipc.on('message', handleMessage$1);
|
|
3104
|
+
}
|
|
3105
|
+
};
|
|
3106
|
+
const listen$1 = async (module, options) => {
|
|
3107
|
+
const rawIpc = await module.listen(options);
|
|
3108
|
+
if (module.signal) {
|
|
3324
3109
|
module.signal(rawIpc);
|
|
3325
3110
|
}
|
|
3326
|
-
// @ts-ignore
|
|
3327
3111
|
const ipc = module.wrap(rawIpc);
|
|
3328
3112
|
return ipc;
|
|
3329
3113
|
};
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
const
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
return IpcParentWithNodeWorker$1;
|
|
3343
|
-
case NodeForkedProcess:
|
|
3344
|
-
return IpcParentWithNodeForkedProcess$1;
|
|
3345
|
-
case ElectronUtilityProcess:
|
|
3346
|
-
return Promise.resolve().then(function () { return IpcParentWithElectronUtilityProcess; });
|
|
3347
|
-
case ElectronMessagePort:
|
|
3348
|
-
return IpcParentWithElectronMessagePort$1;
|
|
3349
|
-
default:
|
|
3350
|
-
throw new Error(`unexpected ipc type ${method}`);
|
|
3114
|
+
const create$d = async ({
|
|
3115
|
+
commandMap,
|
|
3116
|
+
messagePort,
|
|
3117
|
+
requiresSocket
|
|
3118
|
+
}) => {
|
|
3119
|
+
// TODO create a commandMap per rpc instance
|
|
3120
|
+
register$1(commandMap);
|
|
3121
|
+
const ipc = await listen$1(IpcChildWithElectronMessagePort$1, {
|
|
3122
|
+
messagePort
|
|
3123
|
+
});
|
|
3124
|
+
if (requiresSocket) {
|
|
3125
|
+
ipc.requiresSocket = requiresSocket;
|
|
3351
3126
|
}
|
|
3127
|
+
handleIpc$1(ipc);
|
|
3128
|
+
const rpc = createRpc(ipc);
|
|
3129
|
+
return rpc;
|
|
3352
3130
|
};
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3131
|
+
const ElectronMessagePortRpcClient = {
|
|
3132
|
+
__proto__: null,
|
|
3133
|
+
create: create$d
|
|
3134
|
+
};
|
|
3135
|
+
const create$3 = async ({
|
|
3136
|
+
commandMap,
|
|
3137
|
+
env,
|
|
3138
|
+
argv,
|
|
3139
|
+
execArgv,
|
|
3140
|
+
path,
|
|
3141
|
+
name,
|
|
3142
|
+
requiresSocket
|
|
3362
3143
|
}) => {
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
const rawIpc = await
|
|
3366
|
-
|
|
3367
|
-
|
|
3144
|
+
// TODO create a commandMap per rpc instance
|
|
3145
|
+
register$1(commandMap);
|
|
3146
|
+
const rawIpc = await IpcParentWithElectronUtilityProcess$1$1.create({
|
|
3147
|
+
env,
|
|
3148
|
+
argv,
|
|
3149
|
+
execArgv,
|
|
3150
|
+
path,
|
|
3151
|
+
name
|
|
3152
|
+
});
|
|
3153
|
+
const ipc = IpcParentWithElectronUtilityProcess$1$1.wrap(rawIpc);
|
|
3154
|
+
if (requiresSocket) {
|
|
3368
3155
|
// @ts-ignore
|
|
3369
|
-
|
|
3370
|
-
rawIpc,
|
|
3371
|
-
...options
|
|
3372
|
-
});
|
|
3373
|
-
}
|
|
3374
|
-
if (options.noReturn) {
|
|
3375
|
-
return undefined;
|
|
3156
|
+
ipc.requiresSocket = requiresSocket;
|
|
3376
3157
|
}
|
|
3377
|
-
|
|
3378
|
-
const
|
|
3379
|
-
return
|
|
3158
|
+
handleIpc$1(ipc);
|
|
3159
|
+
const rpc = createRpc(ipc);
|
|
3160
|
+
return rpc;
|
|
3161
|
+
};
|
|
3162
|
+
const ElectronUtilityProcessRpcParent = {
|
|
3163
|
+
__proto__: null,
|
|
3164
|
+
create: create$3
|
|
3165
|
+
};
|
|
3166
|
+
|
|
3167
|
+
const commandMapRef = Object.create(null);
|
|
3168
|
+
|
|
3169
|
+
const getPortTuple = () => {
|
|
3170
|
+
const {
|
|
3171
|
+
port1,
|
|
3172
|
+
port2
|
|
3173
|
+
} = new MessageChannelMain();
|
|
3174
|
+
return {
|
|
3175
|
+
port1,
|
|
3176
|
+
port2
|
|
3177
|
+
};
|
|
3178
|
+
};
|
|
3179
|
+
|
|
3180
|
+
const getSharedProcessArgv = isProduction => {
|
|
3181
|
+
return [];
|
|
3380
3182
|
};
|
|
3381
3183
|
|
|
3184
|
+
const EmbedsProcess = 2;
|
|
3185
|
+
const MainProcess = -5;
|
|
3186
|
+
|
|
3382
3187
|
const mark = key => {
|
|
3383
3188
|
performance.mark(key);
|
|
3384
3189
|
};
|
|
@@ -3449,15 +3254,8 @@ const getSharedProcessPath = () => {
|
|
|
3449
3254
|
return join(root, 'packages', 'shared-process', 'src', 'sharedProcessMain.ts');
|
|
3450
3255
|
};
|
|
3451
3256
|
|
|
3452
|
-
const
|
|
3453
|
-
|
|
3454
|
-
* @type{any|undefined}
|
|
3455
|
-
*/
|
|
3456
|
-
sharedProcess: undefined,
|
|
3457
|
-
/**
|
|
3458
|
-
* @type {any}
|
|
3459
|
-
*/
|
|
3460
|
-
promise: undefined
|
|
3257
|
+
const requiresSocket = () => {
|
|
3258
|
+
return false;
|
|
3461
3259
|
};
|
|
3462
3260
|
|
|
3463
3261
|
const handleChildError = error => {
|
|
@@ -3481,21 +3279,25 @@ const launchSharedProcess = async ({
|
|
|
3481
3279
|
...process.env,
|
|
3482
3280
|
...env
|
|
3483
3281
|
};
|
|
3484
|
-
const
|
|
3485
|
-
method,
|
|
3282
|
+
const sharedProcessRpc = await ElectronUtilityProcessRpcParent.create({
|
|
3486
3283
|
env: fullEnv,
|
|
3487
3284
|
argv: [],
|
|
3488
3285
|
execArgv,
|
|
3489
3286
|
path: sharedProcessPath,
|
|
3490
|
-
name: 'shared-process'
|
|
3287
|
+
name: 'shared-process',
|
|
3288
|
+
commandMap: commandMapRef,
|
|
3289
|
+
// @ts-ignore
|
|
3290
|
+
requiresSocket: requiresSocket
|
|
3491
3291
|
});
|
|
3292
|
+
|
|
3293
|
+
// @ts-ignore
|
|
3294
|
+
const sharedProcess = sharedProcessRpc.ipc;
|
|
3492
3295
|
// @ts-ignore
|
|
3493
3296
|
sharedProcess._rawIpc.on('error', handleChildError);
|
|
3494
3297
|
// @ts-ignore
|
|
3495
3298
|
sharedProcess._rawIpc.on('exit', handleChildExit);
|
|
3496
3299
|
// @ts-ignore
|
|
3497
3300
|
sharedProcess._rawIpc.on('disconnect', handleChildDisconnect);
|
|
3498
|
-
handleIpc(sharedProcess);
|
|
3499
3301
|
|
|
3500
3302
|
// create secondary ipc to support transferring objects
|
|
3501
3303
|
// from shared process to main process
|
|
@@ -3505,48 +3307,53 @@ const launchSharedProcess = async ({
|
|
|
3505
3307
|
port1,
|
|
3506
3308
|
port2
|
|
3507
3309
|
} = getPortTuple();
|
|
3508
|
-
|
|
3509
|
-
|
|
3310
|
+
await sharedProcessRpc.invokeAndTransfer('HandleElectronMessagePort.handleElectronMessagePort', port2, MainProcess);
|
|
3311
|
+
await ElectronMessagePortRpcClient.create({
|
|
3312
|
+
commandMap: commandMapRef,
|
|
3313
|
+
requiresSocket: requiresSocket,
|
|
3510
3314
|
messagePort: port1
|
|
3511
3315
|
});
|
|
3512
|
-
handleIpc(childIpc);
|
|
3513
|
-
await invokeAndTransfer$1(sharedProcess, 'HandleElectronMessagePort.handleElectronMessagePort', port2, MainProcess);
|
|
3514
|
-
// @ts-ignore
|
|
3515
|
-
state$6.sharedProcess = sharedProcess;
|
|
3516
3316
|
mark(DidStartSharedProcess);
|
|
3517
|
-
return
|
|
3317
|
+
return sharedProcessRpc;
|
|
3318
|
+
};
|
|
3319
|
+
|
|
3320
|
+
const state$7 = {
|
|
3321
|
+
/**
|
|
3322
|
+
* @type {any}
|
|
3323
|
+
*/
|
|
3324
|
+
promise: undefined
|
|
3518
3325
|
};
|
|
3519
3326
|
|
|
3520
3327
|
const getOrCreate = async ({
|
|
3521
3328
|
method,
|
|
3522
3329
|
env = {}
|
|
3523
3330
|
}) => {
|
|
3524
|
-
if (!state$
|
|
3331
|
+
if (!state$7.promise) {
|
|
3525
3332
|
// @ts-ignore
|
|
3526
|
-
state$
|
|
3333
|
+
state$7.promise = launchSharedProcess({
|
|
3527
3334
|
method,
|
|
3528
3335
|
env
|
|
3529
3336
|
});
|
|
3530
3337
|
}
|
|
3531
|
-
return state$
|
|
3338
|
+
return state$7.promise;
|
|
3532
3339
|
};
|
|
3533
3340
|
const send$1 = async (method, ...params) => {
|
|
3534
3341
|
const ipc = await getOrCreate({
|
|
3535
3342
|
method: ElectronUtilityProcess$1
|
|
3536
3343
|
});
|
|
3537
|
-
send$2(ipc, method, ...params);
|
|
3344
|
+
send$2(ipc.ipc, method, ...params);
|
|
3538
3345
|
};
|
|
3539
3346
|
const invoke = async (method, ...params) => {
|
|
3540
3347
|
const ipc = await getOrCreate({
|
|
3541
3348
|
method: ElectronUtilityProcess$1
|
|
3542
3349
|
});
|
|
3543
|
-
return invoke$1(ipc, method, ...params);
|
|
3350
|
+
return invoke$1(ipc.ipc, method, ...params);
|
|
3544
3351
|
};
|
|
3545
3352
|
const invokeAndTransfer = async (transfer, method, ...params) => {
|
|
3546
3353
|
const ipc = await getOrCreate({
|
|
3547
3354
|
method: ElectronUtilityProcess$1
|
|
3548
3355
|
});
|
|
3549
|
-
return invokeAndTransfer$1(ipc, transfer, method, ...params);
|
|
3356
|
+
return invokeAndTransfer$1(ipc.ipc, transfer, method, ...params);
|
|
3550
3357
|
};
|
|
3551
3358
|
|
|
3552
3359
|
const handleCliArgs = async parsedArgs => {
|
|
@@ -3600,7 +3407,7 @@ const getCliModuleId = parsedArgs => {
|
|
|
3600
3407
|
return None;
|
|
3601
3408
|
};
|
|
3602
3409
|
|
|
3603
|
-
const getModule$
|
|
3410
|
+
const getModule$3 = moduleId => {
|
|
3604
3411
|
switch (moduleId) {
|
|
3605
3412
|
case SharedProcess:
|
|
3606
3413
|
return CliForwardToSharedProcess;
|
|
@@ -3609,7 +3416,7 @@ const getModule$1 = moduleId => {
|
|
|
3609
3416
|
}
|
|
3610
3417
|
};
|
|
3611
3418
|
const handleArgs = (moduleId, parsedArgs) => {
|
|
3612
|
-
const module = getModule$
|
|
3419
|
+
const module = getModule$3(moduleId);
|
|
3613
3420
|
return module.handleCliArgs(parsedArgs);
|
|
3614
3421
|
};
|
|
3615
3422
|
const canHandleFastCliArgs = parsedArgs => {
|
|
@@ -4651,14 +4458,14 @@ const createTitleBar = items => {
|
|
|
4651
4458
|
|
|
4652
4459
|
const PHASE_DEFAULT = 0;
|
|
4653
4460
|
const PHASE_SHUTDOWN = -1;
|
|
4654
|
-
const state$
|
|
4461
|
+
const state$6 = {
|
|
4655
4462
|
phase: PHASE_DEFAULT
|
|
4656
4463
|
};
|
|
4657
4464
|
const isShutDown = () => {
|
|
4658
|
-
return state$
|
|
4465
|
+
return state$6.phase === PHASE_SHUTDOWN;
|
|
4659
4466
|
};
|
|
4660
4467
|
const setShutDown = () => {
|
|
4661
|
-
state$
|
|
4468
|
+
state$6.phase = PHASE_SHUTDOWN;
|
|
4662
4469
|
};
|
|
4663
4470
|
|
|
4664
4471
|
// TODO move this function to shared process
|
|
@@ -4940,6 +4747,10 @@ const handleSecondInstance = async (event, commandLine, workingDirectory, additi
|
|
|
4940
4747
|
const showItemInFolder = fullPath => {
|
|
4941
4748
|
shell.showItemInFolder(fullPath);
|
|
4942
4749
|
};
|
|
4750
|
+
const openPath = async path => {
|
|
4751
|
+
// TODO handle error
|
|
4752
|
+
await shell.openPath(path);
|
|
4753
|
+
};
|
|
4943
4754
|
|
|
4944
4755
|
const ContextMenu = 'context-menu';
|
|
4945
4756
|
const WillNavigate = 'will-navigate';
|
|
@@ -4951,21 +4762,21 @@ const BeforeInputEvent = 'before-input-event';
|
|
|
4951
4762
|
const Allow = 'allow';
|
|
4952
4763
|
const Deny = 'deny';
|
|
4953
4764
|
|
|
4954
|
-
const state$
|
|
4765
|
+
const state$5 = {
|
|
4955
4766
|
views: Object.create(null),
|
|
4956
4767
|
fallThroughKeyBindings: [],
|
|
4957
4768
|
canceled: Object.create(null)
|
|
4958
4769
|
};
|
|
4959
4770
|
const add$1 = (id, browserWindow, view) => {
|
|
4960
4771
|
// state
|
|
4961
|
-
state$
|
|
4772
|
+
state$5.views[id] = {
|
|
4962
4773
|
browserWindow,
|
|
4963
4774
|
view
|
|
4964
4775
|
};
|
|
4965
4776
|
};
|
|
4966
4777
|
const hasWebContents = id => {
|
|
4967
4778
|
number(id);
|
|
4968
|
-
return id in state$
|
|
4779
|
+
return id in state$5.views;
|
|
4969
4780
|
};
|
|
4970
4781
|
/**
|
|
4971
4782
|
*
|
|
@@ -4973,19 +4784,19 @@ const hasWebContents = id => {
|
|
|
4973
4784
|
* @returns {{browserWindow: Electron.BrowserWindow, view: Electron.WebContentsView}}
|
|
4974
4785
|
*/
|
|
4975
4786
|
const get$2 = id => {
|
|
4976
|
-
return state$
|
|
4787
|
+
return state$5.views[id];
|
|
4977
4788
|
};
|
|
4978
4789
|
const remove$1 = id => {
|
|
4979
|
-
delete state$
|
|
4790
|
+
delete state$5.views[id];
|
|
4980
4791
|
};
|
|
4981
4792
|
const setFallthroughKeyBindings = fallthroughKeyBindings => {
|
|
4982
|
-
state$
|
|
4793
|
+
state$5.fallThroughKeyBindings = fallthroughKeyBindings;
|
|
4983
4794
|
};
|
|
4984
4795
|
const getFallthroughKeyBindings = () => {
|
|
4985
|
-
return state$
|
|
4796
|
+
return state$5.fallThroughKeyBindings;
|
|
4986
4797
|
};
|
|
4987
4798
|
const setCanceled = id => {
|
|
4988
|
-
state$
|
|
4799
|
+
state$5.canceled[id] = true;
|
|
4989
4800
|
};
|
|
4990
4801
|
|
|
4991
4802
|
const shouldAllowNavigation = webContentsId => {
|
|
@@ -5154,210 +4965,195 @@ const hydrate = async () => {
|
|
|
5154
4965
|
debug('[info] app window created');
|
|
5155
4966
|
};
|
|
5156
4967
|
|
|
5157
|
-
|
|
4968
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
4969
|
+
const E_MODULE_NOT_FOUND = 'E_MODULE_NOT_FOUND';
|
|
4970
|
+
|
|
4971
|
+
class CommandNotFoundError extends Error {
|
|
5158
4972
|
constructor(id) {
|
|
5159
|
-
super(`
|
|
5160
|
-
this.name = '
|
|
4973
|
+
super(`command ${id} not found`);
|
|
4974
|
+
this.name = 'CommandNotFoundError';
|
|
5161
4975
|
// @ts-ignore
|
|
5162
|
-
this.code =
|
|
4976
|
+
this.code = E_COMMAND_NOT_FOUND;
|
|
5163
4977
|
}
|
|
5164
4978
|
}
|
|
5165
4979
|
|
|
5166
|
-
const
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
return Promise.resolve().then(function () { return ElectronShell_ipc; });
|
|
5204
|
-
case Window:
|
|
5205
|
-
return Promise.resolve().then(function () { return ElectronWindow_ipc; });
|
|
5206
|
-
case ElectronWindowProcessExplorer:
|
|
5207
|
-
return Promise.resolve().then(function () { return ElectronWindowProcessExplorer_ipc; });
|
|
5208
|
-
case IpcParent:
|
|
5209
|
-
return Promise.resolve().then(function () { return IpcParent_ipc; });
|
|
5210
|
-
case OpenExternal$1:
|
|
5211
|
-
return Promise.resolve().then(function () { return OpenExternal_ipc; });
|
|
5212
|
-
case Process:
|
|
5213
|
-
return Promise.resolve().then(function () { return Process_ipc; });
|
|
5214
|
-
case Exit$1:
|
|
5215
|
-
return Promise.resolve().then(function () { return Exit_ipc; });
|
|
5216
|
-
case ElectronScreen:
|
|
5217
|
-
return Promise.resolve().then(function () { return ElectronScreen_ipc; });
|
|
5218
|
-
case TemporaryMessagePort:
|
|
5219
|
-
return Promise.resolve().then(function () { return TemporaryMessagePort_ipc; });
|
|
5220
|
-
case ElectronWebContents:
|
|
5221
|
-
return Promise.resolve().then(function () { return ElectronWebContents_ipc; });
|
|
5222
|
-
case ElectronWebContentsView:
|
|
5223
|
-
return Promise.resolve().then(function () { return ElectronWebContentsView_ipc; });
|
|
5224
|
-
case ElectronWebContentsViewFunctions:
|
|
5225
|
-
return Promise.resolve().then(function () { return ElectronWebContentsViewFunctions_ipc; });
|
|
5226
|
-
case HandleElectronMessagePort:
|
|
5227
|
-
return Promise.resolve().then(function () { return HandleElectronMessagePort_ipc; });
|
|
5228
|
-
case GetWindowId:
|
|
5229
|
-
return Promise.resolve().then(function () { return GetWindowId_ipc; });
|
|
5230
|
-
case ElectronSession:
|
|
5231
|
-
return Promise.resolve().then(function () { return ElectronSession_ipc; });
|
|
5232
|
-
case Trash:
|
|
5233
|
-
return Promise.resolve().then(function () { return Trash_ipc; });
|
|
5234
|
-
default:
|
|
5235
|
-
throw new ModuleNotFoundError(moduleId);
|
|
5236
|
-
}
|
|
5237
|
-
};
|
|
4980
|
+
const App = 1;
|
|
4981
|
+
const AppWindow = 2;
|
|
4982
|
+
const Beep = 3;
|
|
4983
|
+
const Developer = 4;
|
|
4984
|
+
const Dialog = 5;
|
|
4985
|
+
const ElectronWindowProcessExplorer = 6;
|
|
4986
|
+
const Window = 7;
|
|
4987
|
+
const ElectronShell = 8;
|
|
4988
|
+
const ElectronPowerSaveBlocker = 9;
|
|
4989
|
+
const ElectronSafeStorage = 10;
|
|
4990
|
+
const ElectronContentTracing = 11;
|
|
4991
|
+
const ElectronNetLog = 12;
|
|
4992
|
+
const ElectronBrowserView = 13;
|
|
4993
|
+
const ElectronBrowserViewQuickPick = 14;
|
|
4994
|
+
const ElectronContextMenu = 16;
|
|
4995
|
+
const ElectronClipBoard = 17;
|
|
4996
|
+
const ElectronApplicationMenu = 18;
|
|
4997
|
+
const Process = 19;
|
|
4998
|
+
const ElectronNet = 20;
|
|
4999
|
+
const ElectronBrowserViewSuggestions = 21;
|
|
5000
|
+
const CreatePidMap = 22;
|
|
5001
|
+
const OpenExternal$1 = 23;
|
|
5002
|
+
const Platform = 25;
|
|
5003
|
+
const GetWindowId = 26;
|
|
5004
|
+
const DesktopCapturer = 27;
|
|
5005
|
+
const Trash = 28;
|
|
5006
|
+
const IpcParent = 29;
|
|
5007
|
+
const Crash = 30;
|
|
5008
|
+
const Exit = 31;
|
|
5009
|
+
const ElectronScreen = 32;
|
|
5010
|
+
const TemporaryMessagePort = 34;
|
|
5011
|
+
const ElectronWebContents = 35;
|
|
5012
|
+
const ElectronWebContentsView = 36;
|
|
5013
|
+
const ElectronWebContentsViewFunctions = 37;
|
|
5014
|
+
const CreateMessagePort = 38;
|
|
5015
|
+
const HandleElectronMessagePort = 39;
|
|
5016
|
+
const ElectronSession = 40;
|
|
5238
5017
|
|
|
5239
|
-
const
|
|
5240
|
-
|
|
5241
|
-
Error.stackTraceLimit = value;
|
|
5242
|
-
}
|
|
5243
|
-
};
|
|
5244
|
-
|
|
5245
|
-
// @ts-ignore
|
|
5246
|
-
performance.mark('code/start');
|
|
5247
|
-
const main = async () => {
|
|
5248
|
-
setStackTraceLimit(20);
|
|
5249
|
-
on$1('uncaughtExceptionMonitor', handleUncaughtExceptionMonitor);
|
|
5250
|
-
// workaround for https://github.com/electron/electron/issues/36526
|
|
5251
|
-
on$1('unhandledRejection', handleUnhandledRejection);
|
|
5252
|
-
setLoad(load);
|
|
5253
|
-
await hydrate();
|
|
5254
|
-
};
|
|
5255
|
-
|
|
5256
|
-
main();
|
|
5257
|
-
|
|
5258
|
-
if (typeof Electron__default === 'string') {
|
|
5259
|
-
throw new TypeError('Not running in an Electron environment!');
|
|
5260
|
-
}
|
|
5261
|
-
const {
|
|
5262
|
-
env
|
|
5263
|
-
} = process; // eslint-disable-line n/prefer-global/process
|
|
5264
|
-
const isEnvSet = 'ELECTRON_IS_DEV' in env;
|
|
5265
|
-
const getFromEnv = Number.parseInt(env.ELECTRON_IS_DEV, 10) === 1;
|
|
5266
|
-
const isDev = isEnvSet ? getFromEnv : !Electron__default.app.isPackaged;
|
|
5267
|
-
|
|
5268
|
-
const index = {
|
|
5269
|
-
__proto__: null,
|
|
5270
|
-
default: isDev
|
|
5271
|
-
};
|
|
5272
|
-
|
|
5273
|
-
const Dash = '-';
|
|
5274
|
-
const Space$2 = ' ';
|
|
5275
|
-
|
|
5276
|
-
const firstLetterLowerCase = string => {
|
|
5277
|
-
return string[0].toLowerCase() + string.slice(1);
|
|
5278
|
-
};
|
|
5279
|
-
const camelCase = string => {
|
|
5280
|
-
const parts = string.split(Space$2);
|
|
5281
|
-
const lowerParts = parts.map(firstLetterLowerCase);
|
|
5282
|
-
return lowerParts.join(Dash);
|
|
5018
|
+
const getPrefix = commandId => {
|
|
5019
|
+
return commandId.slice(0, commandId.indexOf('.'));
|
|
5283
5020
|
};
|
|
5284
|
-
|
|
5285
|
-
const
|
|
5286
|
-
|
|
5021
|
+
const getModuleId = commandId => {
|
|
5022
|
+
const prefix = getPrefix(commandId);
|
|
5023
|
+
switch (prefix) {
|
|
5024
|
+
case 'Crash':
|
|
5025
|
+
return Crash;
|
|
5026
|
+
case 'ElectronApp':
|
|
5027
|
+
case 'App':
|
|
5028
|
+
return App;
|
|
5029
|
+
case 'Beep':
|
|
5030
|
+
return Beep;
|
|
5031
|
+
case 'ElectronWindow':
|
|
5032
|
+
return Window;
|
|
5033
|
+
case 'ElectronDeveloper':
|
|
5034
|
+
return Developer;
|
|
5035
|
+
case 'AppWindow':
|
|
5036
|
+
return AppWindow;
|
|
5037
|
+
case 'ElectronWindowProcessExplorer':
|
|
5038
|
+
return ElectronWindowProcessExplorer;
|
|
5039
|
+
case 'ElectronDialog':
|
|
5040
|
+
return Dialog;
|
|
5041
|
+
case 'ElectronBeep':
|
|
5042
|
+
return Beep;
|
|
5043
|
+
case 'ElectronShell':
|
|
5044
|
+
return ElectronShell;
|
|
5045
|
+
case 'ElectronPowerSaveBlocker':
|
|
5046
|
+
return ElectronPowerSaveBlocker;
|
|
5047
|
+
case 'ElectronSafeStorage':
|
|
5048
|
+
return ElectronSafeStorage;
|
|
5049
|
+
case 'ElectronContentTracing':
|
|
5050
|
+
return ElectronContentTracing;
|
|
5051
|
+
case 'ElectronNetLog':
|
|
5052
|
+
return ElectronNetLog;
|
|
5053
|
+
case 'ElectronBrowserView':
|
|
5054
|
+
return ElectronBrowserView;
|
|
5055
|
+
case 'ElectronBrowserViewQuickPick':
|
|
5056
|
+
return ElectronBrowserViewQuickPick;
|
|
5057
|
+
case 'ElectronContextMenu':
|
|
5058
|
+
return ElectronContextMenu;
|
|
5059
|
+
case 'ElectronClipBoard':
|
|
5060
|
+
return ElectronClipBoard;
|
|
5061
|
+
case 'ElectronApplicationMenu':
|
|
5062
|
+
return ElectronApplicationMenu;
|
|
5063
|
+
case 'Process':
|
|
5064
|
+
return Process;
|
|
5065
|
+
case 'ElectronNet':
|
|
5066
|
+
return ElectronNet;
|
|
5067
|
+
case 'ElectronBrowserViewSuggestions':
|
|
5068
|
+
return ElectronBrowserViewSuggestions;
|
|
5069
|
+
case 'CreatePidMap':
|
|
5070
|
+
return CreatePidMap;
|
|
5071
|
+
case 'OpenExternal':
|
|
5072
|
+
return OpenExternal$1;
|
|
5073
|
+
case 'Platform':
|
|
5074
|
+
return Platform;
|
|
5075
|
+
case 'GetWindowId':
|
|
5076
|
+
return GetWindowId;
|
|
5077
|
+
case 'DesktopCapturer':
|
|
5078
|
+
return DesktopCapturer;
|
|
5079
|
+
case 'Trash':
|
|
5080
|
+
return Trash;
|
|
5081
|
+
case 'IpcParent':
|
|
5082
|
+
return IpcParent;
|
|
5083
|
+
case 'Exit':
|
|
5084
|
+
return Exit;
|
|
5085
|
+
case 'ElectronScreen':
|
|
5086
|
+
return ElectronScreen;
|
|
5087
|
+
case 'TemporaryMessagePort':
|
|
5088
|
+
return TemporaryMessagePort;
|
|
5089
|
+
case 'ElectronWebContents':
|
|
5090
|
+
return ElectronWebContents;
|
|
5091
|
+
case 'ElectronWebContentsView':
|
|
5092
|
+
return ElectronWebContentsView;
|
|
5093
|
+
case 'ElectronWebContentsViewFunctions':
|
|
5094
|
+
return ElectronWebContentsViewFunctions;
|
|
5095
|
+
case 'CreateMessagePort':
|
|
5096
|
+
return CreateMessagePort;
|
|
5097
|
+
case 'HandleElectronMessagePort':
|
|
5098
|
+
return HandleElectronMessagePort;
|
|
5099
|
+
case 'ElectronSession':
|
|
5100
|
+
return ElectronSession;
|
|
5101
|
+
default:
|
|
5102
|
+
throw new CommandNotFoundError(commandId);
|
|
5103
|
+
}
|
|
5287
5104
|
};
|
|
5288
5105
|
|
|
5289
|
-
const state$
|
|
5290
|
-
|
|
5106
|
+
const state$4 = {
|
|
5107
|
+
commands: Object.create(null),
|
|
5108
|
+
pendingModules: Object.create(null),
|
|
5109
|
+
async load(moduleId) {}
|
|
5291
5110
|
};
|
|
5292
|
-
const
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5111
|
+
const initializeModule = module => {
|
|
5112
|
+
if (module.Commands) {
|
|
5113
|
+
for (const [key, value] of Object.entries(module.Commands)) {
|
|
5114
|
+
if (module.name) {
|
|
5115
|
+
const actualKey = `${module.name}.${key}`;
|
|
5116
|
+
register(actualKey, value);
|
|
5117
|
+
} else {
|
|
5118
|
+
register(key, value);
|
|
5119
|
+
}
|
|
5120
|
+
}
|
|
5121
|
+
return;
|
|
5122
|
+
}
|
|
5123
|
+
throw new Error(`module ${module.name || '<unnamed module>'} is missing commands`);
|
|
5300
5124
|
};
|
|
5301
|
-
const
|
|
5302
|
-
|
|
5303
|
-
|
|
5125
|
+
const getOrLoadModule = moduleId => {
|
|
5126
|
+
if (!state$4.pendingModules[moduleId]) {
|
|
5127
|
+
const importPromise = state$4.load(moduleId);
|
|
5128
|
+
state$4.pendingModules[moduleId] = importPromise.then(initializeModule);
|
|
5129
|
+
}
|
|
5130
|
+
return state$4.pendingModules[moduleId];
|
|
5304
5131
|
};
|
|
5305
|
-
const
|
|
5306
|
-
|
|
5132
|
+
const loadCommand = command => getOrLoadModule(getModuleId(command));
|
|
5133
|
+
const register = (commandId, listener) => {
|
|
5134
|
+
state$4.commands[commandId] = listener;
|
|
5307
5135
|
};
|
|
5308
|
-
const
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5136
|
+
const hasThrown = new Set();
|
|
5137
|
+
const loadThenExecute = async (command, ...args) => {
|
|
5138
|
+
await loadCommand(command);
|
|
5139
|
+
// TODO can skip then block in prod (only to prevent endless loop in dev)
|
|
5140
|
+
if (!(command in state$4.commands)) {
|
|
5141
|
+
if (hasThrown.has(command)) {
|
|
5142
|
+
return;
|
|
5314
5143
|
}
|
|
5144
|
+
hasThrown.add(command);
|
|
5145
|
+
throw new Error(`Command did not register "${command}"`);
|
|
5315
5146
|
}
|
|
5316
|
-
return
|
|
5147
|
+
return execute(command, ...args);
|
|
5317
5148
|
};
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
} = IpcParentWithElectronUtilityProcess$1$1;
|
|
5322
|
-
const {
|
|
5323
|
-
wrap
|
|
5324
|
-
} = IpcParentWithElectronUtilityProcess$1$1;
|
|
5325
|
-
const effects = ({
|
|
5326
|
-
rawIpc,
|
|
5327
|
-
name
|
|
5328
|
-
}) => {
|
|
5329
|
-
if (!rawIpc.pid) {
|
|
5330
|
-
return;
|
|
5149
|
+
const execute = (command, ...args) => {
|
|
5150
|
+
if (command in state$4.commands) {
|
|
5151
|
+
return state$4.commands[command](...args);
|
|
5331
5152
|
}
|
|
5332
|
-
|
|
5333
|
-
pid
|
|
5334
|
-
} = rawIpc;
|
|
5335
|
-
const formattedName = formatUtilityProcessName(name);
|
|
5336
|
-
add(pid, rawIpc, formattedName);
|
|
5337
|
-
const cleanup = () => {
|
|
5338
|
-
remove(pid);
|
|
5339
|
-
rawIpc.off('exit', handleExit);
|
|
5340
|
-
};
|
|
5341
|
-
const handleExit = () => {
|
|
5342
|
-
cleanup();
|
|
5343
|
-
};
|
|
5344
|
-
rawIpc.on('exit', handleExit);
|
|
5345
|
-
};
|
|
5346
|
-
|
|
5347
|
-
const IpcParentWithElectronUtilityProcess = {
|
|
5348
|
-
__proto__: null,
|
|
5349
|
-
create: create$1,
|
|
5350
|
-
effects,
|
|
5351
|
-
wrap
|
|
5153
|
+
return loadThenExecute(command, ...args);
|
|
5352
5154
|
};
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
const Commands$w = {};
|
|
5356
|
-
|
|
5357
|
-
const App_ipc = {
|
|
5358
|
-
__proto__: null,
|
|
5359
|
-
Commands: Commands$w,
|
|
5360
|
-
name: name$w
|
|
5155
|
+
const setLoad = load => {
|
|
5156
|
+
state$4.load = load;
|
|
5361
5157
|
};
|
|
5362
5158
|
|
|
5363
5159
|
const ClipBoardRead = 'clipboard-read';
|
|
@@ -5449,62 +5245,173 @@ const createElectronSession = () => {
|
|
|
5449
5245
|
return session;
|
|
5450
5246
|
};
|
|
5451
5247
|
|
|
5452
|
-
const state$
|
|
5248
|
+
const state$3 = {
|
|
5453
5249
|
session: undefined
|
|
5454
5250
|
};
|
|
5455
5251
|
const has = () => {
|
|
5456
|
-
return Boolean(state$
|
|
5252
|
+
return Boolean(state$3.session);
|
|
5457
5253
|
};
|
|
5458
5254
|
const get$1 = () => {
|
|
5459
|
-
if (!state$
|
|
5255
|
+
if (!state$3.session) {
|
|
5460
5256
|
throw new Error('session is not defined');
|
|
5461
5257
|
}
|
|
5462
|
-
return state$
|
|
5258
|
+
return state$3.session;
|
|
5463
5259
|
};
|
|
5464
5260
|
const set$1 = value => {
|
|
5465
|
-
state$
|
|
5261
|
+
state$3.session = value;
|
|
5466
5262
|
};
|
|
5467
5263
|
|
|
5468
|
-
const
|
|
5469
|
-
|
|
5470
|
-
const {
|
|
5471
|
-
method,
|
|
5472
|
-
url
|
|
5473
|
-
} = request;
|
|
5474
|
-
console.log('got request', method, url);
|
|
5475
|
-
const {
|
|
5476
|
-
body,
|
|
5477
|
-
init
|
|
5478
|
-
} = await invoke$1(ipc, 'WebViewProtocol.getResponse', method, url);
|
|
5479
|
-
return new Response(body, init);
|
|
5480
|
-
};
|
|
5481
|
-
return handleRequest;
|
|
5264
|
+
const printPrettyError = (prettyError, prefix = '') => {
|
|
5265
|
+
error(`${prefix}${prettyError.type}: ${prettyError.message}\n\n${prettyError.codeFrame}\n\n${prettyError.stack}\n`);
|
|
5482
5266
|
};
|
|
5483
5267
|
|
|
5484
|
-
const
|
|
5485
|
-
|
|
5486
|
-
set$1(createElectronSession());
|
|
5487
|
-
}
|
|
5488
|
-
return get$1();
|
|
5268
|
+
const logError = (error, prettyError) => {
|
|
5269
|
+
printPrettyError(prettyError, '[main-process] ');
|
|
5489
5270
|
};
|
|
5490
|
-
const
|
|
5491
|
-
|
|
5492
|
-
console.log('will register ptorocol');
|
|
5493
|
-
const ipc = await create$2({
|
|
5494
|
-
method: ElectronMessagePort,
|
|
5495
|
-
messagePort: port
|
|
5496
|
-
});
|
|
5497
|
-
console.log('do register protocol');
|
|
5498
|
-
handleIpc(ipc);
|
|
5499
|
-
port.start();
|
|
5500
|
-
const session = get();
|
|
5501
|
-
const handleRequest = create(ipc);
|
|
5271
|
+
const handleMessage = event => {
|
|
5272
|
+
return handleJsonRpcMessage(event.target, event.data, execute, resolve, prepare,
|
|
5502
5273
|
// @ts-ignore
|
|
5503
|
-
|
|
5274
|
+
logError, requiresSocket);
|
|
5504
5275
|
};
|
|
5505
5276
|
|
|
5506
|
-
|
|
5507
|
-
|
|
5277
|
+
const handleIpc = ipc => {
|
|
5278
|
+
if ('addEventListener' in ipc) {
|
|
5279
|
+
ipc.addEventListener('message', handleMessage);
|
|
5280
|
+
} else if ('on' in ipc) {
|
|
5281
|
+
// deprecated
|
|
5282
|
+
ipc.on('message', handleMessage);
|
|
5283
|
+
}
|
|
5284
|
+
};
|
|
5285
|
+
const unhandleIpc = ipc => {
|
|
5286
|
+
if ('removeEventListener' in ipc) {
|
|
5287
|
+
ipc.removeEventListener('message', handleMessage);
|
|
5288
|
+
} else if ('off' in ipc) {
|
|
5289
|
+
ipc.off('message', handleMessage);
|
|
5290
|
+
}
|
|
5291
|
+
};
|
|
5292
|
+
|
|
5293
|
+
const NodeWorker = 1;
|
|
5294
|
+
const NodeForkedProcess = 2;
|
|
5295
|
+
const ElectronUtilityProcess = 3;
|
|
5296
|
+
const ElectronMessagePort = 4;
|
|
5297
|
+
|
|
5298
|
+
const getModule$2 = method => {
|
|
5299
|
+
switch (method) {
|
|
5300
|
+
case NodeWorker:
|
|
5301
|
+
return IpcParentWithNodeWorker$1;
|
|
5302
|
+
case NodeForkedProcess:
|
|
5303
|
+
return IpcParentWithNodeForkedProcess$1;
|
|
5304
|
+
case ElectronUtilityProcess:
|
|
5305
|
+
return Promise.resolve().then(function () { return IpcParentWithElectronUtilityProcess; });
|
|
5306
|
+
case ElectronMessagePort:
|
|
5307
|
+
return IpcParentWithElectronMessagePort$1;
|
|
5308
|
+
default:
|
|
5309
|
+
throw new Error(`unexpected ipc type ${method}`);
|
|
5310
|
+
}
|
|
5311
|
+
};
|
|
5312
|
+
|
|
5313
|
+
/**
|
|
5314
|
+
*
|
|
5315
|
+
* @param {*} param0
|
|
5316
|
+
* @returns {Promise<any>}
|
|
5317
|
+
*/
|
|
5318
|
+
const create$2 = async ({
|
|
5319
|
+
method,
|
|
5320
|
+
...options
|
|
5321
|
+
}) => {
|
|
5322
|
+
const module = await getModule$2(method);
|
|
5323
|
+
// @ts-ignore
|
|
5324
|
+
const rawIpc = await module.create(options);
|
|
5325
|
+
// @ts-ignore
|
|
5326
|
+
if (module.effects) {
|
|
5327
|
+
// @ts-ignore
|
|
5328
|
+
module.effects({
|
|
5329
|
+
rawIpc,
|
|
5330
|
+
...options
|
|
5331
|
+
});
|
|
5332
|
+
}
|
|
5333
|
+
if (options.noReturn) {
|
|
5334
|
+
return undefined;
|
|
5335
|
+
}
|
|
5336
|
+
// @ts-ignore
|
|
5337
|
+
const ipc = module.wrap(rawIpc);
|
|
5338
|
+
return ipc;
|
|
5339
|
+
};
|
|
5340
|
+
|
|
5341
|
+
const create$1 = ipc => {
|
|
5342
|
+
const handleRequest = async request => {
|
|
5343
|
+
const {
|
|
5344
|
+
method,
|
|
5345
|
+
url
|
|
5346
|
+
} = request;
|
|
5347
|
+
console.log('got request', method, url);
|
|
5348
|
+
const {
|
|
5349
|
+
body,
|
|
5350
|
+
init
|
|
5351
|
+
} = await invoke$1(ipc, 'WebViewProtocol.getResponse', method, url);
|
|
5352
|
+
return new Response(body, init);
|
|
5353
|
+
};
|
|
5354
|
+
return handleRequest;
|
|
5355
|
+
};
|
|
5356
|
+
|
|
5357
|
+
const get = () => {
|
|
5358
|
+
if (!has()) {
|
|
5359
|
+
set$1(createElectronSession());
|
|
5360
|
+
}
|
|
5361
|
+
return get$1();
|
|
5362
|
+
};
|
|
5363
|
+
const registerWebviewProtocol = async port => {
|
|
5364
|
+
object(port);
|
|
5365
|
+
console.log('will register ptorocol');
|
|
5366
|
+
const ipc = await create$2({
|
|
5367
|
+
method: ElectronMessagePort,
|
|
5368
|
+
messagePort: port
|
|
5369
|
+
});
|
|
5370
|
+
console.log('do register protocol');
|
|
5371
|
+
handleIpc(ipc);
|
|
5372
|
+
port.start();
|
|
5373
|
+
const session = get();
|
|
5374
|
+
const handleRequest = create$1(ipc);
|
|
5375
|
+
// @ts-ignore
|
|
5376
|
+
handle(session.protocol, WebView, handleRequest);
|
|
5377
|
+
};
|
|
5378
|
+
|
|
5379
|
+
const getModule$1 = method => {
|
|
5380
|
+
switch (method) {
|
|
5381
|
+
case NodeForkedProcess$1:
|
|
5382
|
+
return IpcChildWithNodeForkedProcess$1;
|
|
5383
|
+
case NodeWorker$1:
|
|
5384
|
+
return IpcChildWithNodeWorker$1;
|
|
5385
|
+
case ElectronUtilityProcess$1:
|
|
5386
|
+
return IpcChildWithElectronUtilityProcess$1;
|
|
5387
|
+
case ElectronMessagePort$1:
|
|
5388
|
+
return IpcChildWithElectronMessagePort$1;
|
|
5389
|
+
case RendererProcess2:
|
|
5390
|
+
return IpcChildWithRendererProcess2$1;
|
|
5391
|
+
default:
|
|
5392
|
+
throw new Error('unexpected ipc type');
|
|
5393
|
+
}
|
|
5394
|
+
};
|
|
5395
|
+
|
|
5396
|
+
const listen = async ({
|
|
5397
|
+
method,
|
|
5398
|
+
...params
|
|
5399
|
+
}) => {
|
|
5400
|
+
const module = getModule$1(method);
|
|
5401
|
+
// @ts-ignore
|
|
5402
|
+
const rawIpc = await module.listen(params);
|
|
5403
|
+
// @ts-ignore
|
|
5404
|
+
if (module.signal) {
|
|
5405
|
+
// @ts-ignore
|
|
5406
|
+
module.signal(rawIpc);
|
|
5407
|
+
}
|
|
5408
|
+
// @ts-ignore
|
|
5409
|
+
const ipc = module.wrap(rawIpc);
|
|
5410
|
+
return ipc;
|
|
5411
|
+
};
|
|
5412
|
+
|
|
5413
|
+
class WindowLoadError extends VError {
|
|
5414
|
+
constructor(error, url) {
|
|
5508
5415
|
super(error, `Failed to load url ${url}`);
|
|
5509
5416
|
this.name = 'WindowLoadError';
|
|
5510
5417
|
}
|
|
@@ -5570,32 +5477,10 @@ const createAppWindow = async (windowOptions, parsedArgs, workingDirectory, titl
|
|
|
5570
5477
|
await loadUrl(window, url);
|
|
5571
5478
|
};
|
|
5572
5479
|
|
|
5573
|
-
const
|
|
5574
|
-
const Commands$v = {
|
|
5575
|
-
createAppWindow: createAppWindow
|
|
5576
|
-
};
|
|
5577
|
-
|
|
5578
|
-
const AppWindow_ipc = {
|
|
5579
|
-
__proto__: null,
|
|
5580
|
-
Commands: Commands$v,
|
|
5581
|
-
name: name$v
|
|
5582
|
-
};
|
|
5583
|
-
|
|
5584
|
-
const beep = () => {
|
|
5480
|
+
const beep$1 = () => {
|
|
5585
5481
|
shell.beep();
|
|
5586
5482
|
};
|
|
5587
5483
|
|
|
5588
|
-
const name$u = 'Beep';
|
|
5589
|
-
const Commands$u = {
|
|
5590
|
-
beep: beep
|
|
5591
|
-
};
|
|
5592
|
-
|
|
5593
|
-
const Beep_ipc = {
|
|
5594
|
-
__proto__: null,
|
|
5595
|
-
Commands: Commands$u,
|
|
5596
|
-
name: name$u
|
|
5597
|
-
};
|
|
5598
|
-
|
|
5599
5484
|
const handleTimeout = () => {
|
|
5600
5485
|
throw new Error('oops');
|
|
5601
5486
|
};
|
|
@@ -5603,30 +5488,57 @@ const crashMainProcess$1 = () => {
|
|
|
5603
5488
|
setTimeout(handleTimeout, 0);
|
|
5604
5489
|
};
|
|
5605
5490
|
|
|
5606
|
-
const
|
|
5607
|
-
|
|
5608
|
-
|
|
5491
|
+
const transferMessagePortMain = async (ipc, port, ...params) => {
|
|
5492
|
+
try {
|
|
5493
|
+
await invokeAndTransfer$1(ipc, 'HandleElectronMessagePort.handleElectronMessagePort', port, ...params);
|
|
5494
|
+
} catch (error) {
|
|
5495
|
+
throw new VError(error, `Failed to send message port to utility process`);
|
|
5496
|
+
}
|
|
5609
5497
|
};
|
|
5610
5498
|
|
|
5611
|
-
const
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5499
|
+
const connectIpc$2 = async (ipc, browserWindowPort, ...params) => {
|
|
5500
|
+
await transferMessagePortMain(ipc, browserWindowPort, ...params);
|
|
5501
|
+
};
|
|
5502
|
+
|
|
5503
|
+
const transferMessagePort = async (ipc, port, ...params) => {
|
|
5504
|
+
try {
|
|
5505
|
+
await invokeAndTransfer$1(ipc, 'HandleNodeMessagePort.handleNodeMessagePort', port, ...params);
|
|
5506
|
+
} catch (error) {
|
|
5507
|
+
throw new VError(error, `Failed to send message port to worker thread`);
|
|
5508
|
+
}
|
|
5509
|
+
};
|
|
5510
|
+
|
|
5511
|
+
const connectIpc$1 = async (ipc, browserWindowPort, ...params) => {
|
|
5512
|
+
const messageChannel = new MessageChannel();
|
|
5513
|
+
const {
|
|
5514
|
+
port1,
|
|
5515
|
+
port2
|
|
5516
|
+
} = messageChannel;
|
|
5517
|
+
browserWindowPort.on('message', event => {
|
|
5518
|
+
// console.log('got message from browser window', event.data)
|
|
5519
|
+
port2.postMessage(event.data);
|
|
5520
|
+
});
|
|
5521
|
+
port2.on('message', message => {
|
|
5522
|
+
// console.log('send message to browser window', message)
|
|
5523
|
+
browserWindowPort.postMessage(message);
|
|
5524
|
+
});
|
|
5525
|
+
await transferMessagePort(ipc, port1, ...params);
|
|
5526
|
+
browserWindowPort.start();
|
|
5615
5527
|
};
|
|
5616
5528
|
|
|
5617
5529
|
const getModule = method => {
|
|
5618
5530
|
switch (method) {
|
|
5619
5531
|
case NodeWorker:
|
|
5620
|
-
return
|
|
5532
|
+
return connectIpc$1;
|
|
5621
5533
|
case ElectronUtilityProcess:
|
|
5622
|
-
return
|
|
5534
|
+
return connectIpc$2;
|
|
5623
5535
|
default:
|
|
5624
5536
|
throw new Error('unexpected ipc type');
|
|
5625
5537
|
}
|
|
5626
5538
|
};
|
|
5627
|
-
const connectIpc
|
|
5628
|
-
const
|
|
5629
|
-
return
|
|
5539
|
+
const connectIpc = async (method, ipc, browserWindowPort, ipcId) => {
|
|
5540
|
+
const connectIpc = getModule(method);
|
|
5541
|
+
return connectIpc(ipc, browserWindowPort, ipcId);
|
|
5630
5542
|
};
|
|
5631
5543
|
|
|
5632
5544
|
// TODO maybe handle critical (first render) request via ipcMain
|
|
@@ -5649,7 +5561,7 @@ const handlePort = async (browserWindowPort, ipcId) => {
|
|
|
5649
5561
|
FOLDER: ''
|
|
5650
5562
|
}
|
|
5651
5563
|
});
|
|
5652
|
-
await connectIpc
|
|
5564
|
+
await connectIpc(method, sharedProcess.ipc, browserWindowPort, ipcId);
|
|
5653
5565
|
};
|
|
5654
5566
|
|
|
5655
5567
|
// TODO reverse order of parameters: make ports first
|
|
@@ -5661,15 +5573,34 @@ const createMessagePort = async (ipcId, port, webContentsId) => {
|
|
|
5661
5573
|
return webContentsId;
|
|
5662
5574
|
};
|
|
5663
5575
|
|
|
5664
|
-
const
|
|
5665
|
-
|
|
5666
|
-
createMessagePort: createMessagePort
|
|
5576
|
+
const state$2 = {
|
|
5577
|
+
all: Object.create(null)
|
|
5667
5578
|
};
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5579
|
+
const add = (pid, process, name) => {
|
|
5580
|
+
number(pid);
|
|
5581
|
+
object(process);
|
|
5582
|
+
string(name);
|
|
5583
|
+
state$2.all[pid] = {
|
|
5584
|
+
process,
|
|
5585
|
+
name
|
|
5586
|
+
};
|
|
5587
|
+
};
|
|
5588
|
+
const remove = pid => {
|
|
5589
|
+
number(pid);
|
|
5590
|
+
delete state$2.all[pid];
|
|
5591
|
+
};
|
|
5592
|
+
const getAll = () => {
|
|
5593
|
+
return Object.entries(state$2.all);
|
|
5594
|
+
};
|
|
5595
|
+
const getByName = name => {
|
|
5596
|
+
for (const value of Object.values(state$2.all)) {
|
|
5597
|
+
// @ts-ignore
|
|
5598
|
+
if (value.name === name) {
|
|
5599
|
+
// @ts-ignore
|
|
5600
|
+
return value.process;
|
|
5601
|
+
}
|
|
5602
|
+
}
|
|
5603
|
+
return undefined;
|
|
5673
5604
|
};
|
|
5674
5605
|
|
|
5675
5606
|
const createPidMap = () => {
|
|
@@ -5716,17 +5647,6 @@ const createPidMap = () => {
|
|
|
5716
5647
|
return pidWindowMap;
|
|
5717
5648
|
};
|
|
5718
5649
|
|
|
5719
|
-
const name$r = 'CreatePidMap';
|
|
5720
|
-
const Commands$r = {
|
|
5721
|
-
createPidMap: createPidMap
|
|
5722
|
-
};
|
|
5723
|
-
|
|
5724
|
-
const CreatePidMap_ipc = {
|
|
5725
|
-
__proto__: null,
|
|
5726
|
-
Commands: Commands$r,
|
|
5727
|
-
name: name$r
|
|
5728
|
-
};
|
|
5729
|
-
|
|
5730
5650
|
const serializeDeskopCapturerSource = source => {
|
|
5731
5651
|
return {
|
|
5732
5652
|
display_id: source.display_id,
|
|
@@ -5750,175 +5670,22 @@ const getSources = async options => {
|
|
|
5750
5670
|
}
|
|
5751
5671
|
};
|
|
5752
5672
|
|
|
5753
|
-
|
|
5754
|
-
const Commands$q = {
|
|
5755
|
-
getSources: getSources
|
|
5756
|
-
};
|
|
5673
|
+
// TODO rename module to ElectronShell
|
|
5757
5674
|
|
|
5758
|
-
const
|
|
5759
|
-
|
|
5760
|
-
Commands: Commands$q,
|
|
5761
|
-
name: name$q
|
|
5675
|
+
const beep = () => {
|
|
5676
|
+
shell.beep();
|
|
5762
5677
|
};
|
|
5763
5678
|
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
const ElectronApplicationMenu_ipc = {
|
|
5770
|
-
__proto__: null,
|
|
5771
|
-
Commands: Commands$p,
|
|
5772
|
-
name: name$p
|
|
5773
|
-
};
|
|
5774
|
-
|
|
5775
|
-
const writeText = text => {
|
|
5776
|
-
clipboard.writeText(text);
|
|
5777
|
-
};
|
|
5778
|
-
|
|
5779
|
-
const name$o = 'ElectronClipBoard';
|
|
5780
|
-
const Commands$o = {
|
|
5781
|
-
writeText: writeText
|
|
5782
|
-
};
|
|
5783
|
-
|
|
5784
|
-
const ElectronClipBoard_ipc = {
|
|
5785
|
-
__proto__: null,
|
|
5786
|
-
Commands: Commands$o,
|
|
5787
|
-
name: name$o
|
|
5788
|
-
};
|
|
5789
|
-
|
|
5790
|
-
/**
|
|
5791
|
-
* @param { Electron.TraceConfig | Electron.TraceCategoriesAndOptions} options
|
|
5792
|
-
*/
|
|
5793
|
-
const startRecording = async options => {
|
|
5794
|
-
await contentTracing.startRecording(options);
|
|
5679
|
+
/**
|
|
5680
|
+
* @param { Electron.TraceConfig | Electron.TraceCategoriesAndOptions} options
|
|
5681
|
+
*/
|
|
5682
|
+
const startRecording = async options => {
|
|
5683
|
+
await contentTracing.startRecording(options);
|
|
5795
5684
|
};
|
|
5796
5685
|
const stopRecording = () => {
|
|
5797
5686
|
return contentTracing.stopRecording();
|
|
5798
5687
|
};
|
|
5799
5688
|
|
|
5800
|
-
const name$n = 'ElectronContentTracing';
|
|
5801
|
-
const Commands$n = {
|
|
5802
|
-
startRecording: startRecording,
|
|
5803
|
-
stopRecording: stopRecording
|
|
5804
|
-
};
|
|
5805
|
-
|
|
5806
|
-
const ElectronContentTracing_ipc = {
|
|
5807
|
-
__proto__: null,
|
|
5808
|
-
Commands: Commands$n,
|
|
5809
|
-
name: name$n
|
|
5810
|
-
};
|
|
5811
|
-
|
|
5812
|
-
const withResolvers = () => {
|
|
5813
|
-
/**
|
|
5814
|
-
* @type {any}
|
|
5815
|
-
*/
|
|
5816
|
-
let _resolve;
|
|
5817
|
-
/**
|
|
5818
|
-
* @type {any}
|
|
5819
|
-
*/
|
|
5820
|
-
let _reject;
|
|
5821
|
-
const promise = new Promise((resolve, reject) => {
|
|
5822
|
-
_resolve = resolve;
|
|
5823
|
-
_reject = reject;
|
|
5824
|
-
});
|
|
5825
|
-
return {
|
|
5826
|
-
resolve: _resolve,
|
|
5827
|
-
reject: _reject,
|
|
5828
|
-
promise
|
|
5829
|
-
};
|
|
5830
|
-
};
|
|
5831
|
-
|
|
5832
|
-
const getElectronCallbacks = () => {
|
|
5833
|
-
const {
|
|
5834
|
-
resolve,
|
|
5835
|
-
promise
|
|
5836
|
-
} = withResolvers();
|
|
5837
|
-
const handleClick = menuItem => {
|
|
5838
|
-
resolve({
|
|
5839
|
-
type: 'click',
|
|
5840
|
-
data: menuItem
|
|
5841
|
-
});
|
|
5842
|
-
};
|
|
5843
|
-
const handleClose = () => {
|
|
5844
|
-
resolve({
|
|
5845
|
-
type: 'close',
|
|
5846
|
-
data: undefined
|
|
5847
|
-
});
|
|
5848
|
-
};
|
|
5849
|
-
return {
|
|
5850
|
-
handleClick,
|
|
5851
|
-
handleClose,
|
|
5852
|
-
promise
|
|
5853
|
-
};
|
|
5854
|
-
};
|
|
5855
|
-
|
|
5856
|
-
const getElectronMenuItems = (menuItems, click) => {
|
|
5857
|
-
const template = [];
|
|
5858
|
-
for (const menuItem of menuItems) {
|
|
5859
|
-
// @ts-ignore
|
|
5860
|
-
template.push({
|
|
5861
|
-
...menuItem,
|
|
5862
|
-
click
|
|
5863
|
-
});
|
|
5864
|
-
}
|
|
5865
|
-
return template;
|
|
5866
|
-
};
|
|
5867
|
-
|
|
5868
|
-
// @ts-ignore
|
|
5869
|
-
const openContextMenu = async (menuItems, x, y) => {
|
|
5870
|
-
array(menuItems);
|
|
5871
|
-
number(x);
|
|
5872
|
-
number(y);
|
|
5873
|
-
const {
|
|
5874
|
-
promise,
|
|
5875
|
-
handleClick,
|
|
5876
|
-
handleClose
|
|
5877
|
-
} = getElectronCallbacks();
|
|
5878
|
-
const template = getElectronMenuItems(menuItems, handleClick);
|
|
5879
|
-
const menu = Menu.buildFromTemplate(template);
|
|
5880
|
-
const window = BrowserWindow.getFocusedWindow();
|
|
5881
|
-
if (!window) {
|
|
5882
|
-
return {
|
|
5883
|
-
type: 'close',
|
|
5884
|
-
data: undefined
|
|
5885
|
-
};
|
|
5886
|
-
}
|
|
5887
|
-
menu.popup({
|
|
5888
|
-
window,
|
|
5889
|
-
x,
|
|
5890
|
-
y,
|
|
5891
|
-
callback: handleClose
|
|
5892
|
-
});
|
|
5893
|
-
const event = await promise;
|
|
5894
|
-
// @ts-ignore
|
|
5895
|
-
if (event.type === 'click') {
|
|
5896
|
-
return {
|
|
5897
|
-
type: 'click',
|
|
5898
|
-
// @ts-ignore
|
|
5899
|
-
data: event.data.label
|
|
5900
|
-
};
|
|
5901
|
-
}
|
|
5902
|
-
// @ts-ignore
|
|
5903
|
-
if (event.type === 'close') {
|
|
5904
|
-
return {
|
|
5905
|
-
type: 'close',
|
|
5906
|
-
data: undefined
|
|
5907
|
-
};
|
|
5908
|
-
}
|
|
5909
|
-
};
|
|
5910
|
-
|
|
5911
|
-
const name$m = 'ElectronContextMenu';
|
|
5912
|
-
const Commands$m = {
|
|
5913
|
-
openContextMenu: openContextMenu
|
|
5914
|
-
};
|
|
5915
|
-
|
|
5916
|
-
const ElectronContextMenu_ipc = {
|
|
5917
|
-
__proto__: null,
|
|
5918
|
-
Commands: Commands$m,
|
|
5919
|
-
name: name$m
|
|
5920
|
-
};
|
|
5921
|
-
|
|
5922
5689
|
const getPerformanceEntries = () => {
|
|
5923
5690
|
const entries = getEntries();
|
|
5924
5691
|
const {
|
|
@@ -5933,18 +5700,6 @@ const crashMainProcess = () => {
|
|
|
5933
5700
|
throw new Error('oops');
|
|
5934
5701
|
};
|
|
5935
5702
|
|
|
5936
|
-
const name$l = 'ElectronDeveloper';
|
|
5937
|
-
const Commands$l = {
|
|
5938
|
-
crashMainProcess: crashMainProcess,
|
|
5939
|
-
getPerformanceEntries: getPerformanceEntries
|
|
5940
|
-
};
|
|
5941
|
-
|
|
5942
|
-
const ElectronDeveloper_ipc = {
|
|
5943
|
-
__proto__: null,
|
|
5944
|
-
Commands: Commands$l,
|
|
5945
|
-
name: name$l
|
|
5946
|
-
};
|
|
5947
|
-
|
|
5948
5703
|
const Error$1 = 'error';
|
|
5949
5704
|
|
|
5950
5705
|
const getWindowById = windowId => {
|
|
@@ -6063,18 +5818,6 @@ const showMessageBox = async ({
|
|
|
6063
5818
|
return selectedButtonIndex;
|
|
6064
5819
|
};
|
|
6065
5820
|
|
|
6066
|
-
const name$k = 'ElectronDialog';
|
|
6067
|
-
const Commands$k = {
|
|
6068
|
-
showMessageBox: showMessageBox,
|
|
6069
|
-
showOpenDialog: showOpenDialog
|
|
6070
|
-
};
|
|
6071
|
-
|
|
6072
|
-
const ElectronDialog_ipc = {
|
|
6073
|
-
__proto__: null,
|
|
6074
|
-
Commands: Commands$k,
|
|
6075
|
-
name: name$k
|
|
6076
|
-
};
|
|
6077
|
-
|
|
6078
5821
|
const getJson = async url => {
|
|
6079
5822
|
string(url);
|
|
6080
5823
|
const request = net.request({
|
|
@@ -6097,17 +5840,6 @@ const getJson = async url => {
|
|
|
6097
5840
|
return json;
|
|
6098
5841
|
};
|
|
6099
5842
|
|
|
6100
|
-
const name$j = 'ElectronNet';
|
|
6101
|
-
const Commands$j = {
|
|
6102
|
-
getJson: getJson
|
|
6103
|
-
};
|
|
6104
|
-
|
|
6105
|
-
const ElectronNet_ipc = {
|
|
6106
|
-
__proto__: null,
|
|
6107
|
-
Commands: Commands$j,
|
|
6108
|
-
name: name$j
|
|
6109
|
-
};
|
|
6110
|
-
|
|
6111
5843
|
const startLogging = async path => {
|
|
6112
5844
|
await netLog.startLogging(path);
|
|
6113
5845
|
};
|
|
@@ -6115,18 +5847,6 @@ const stopLogging = async () => {
|
|
|
6115
5847
|
await netLog.stopLogging();
|
|
6116
5848
|
};
|
|
6117
5849
|
|
|
6118
|
-
const name$i = 'ElectronNetLog';
|
|
6119
|
-
const Commands$i = {
|
|
6120
|
-
startLogging: startLogging,
|
|
6121
|
-
stopLogging: stopLogging
|
|
6122
|
-
};
|
|
6123
|
-
|
|
6124
|
-
const ElectronNetLog_ipc = {
|
|
6125
|
-
__proto__: null,
|
|
6126
|
-
Commands: Commands$i,
|
|
6127
|
-
name: name$i
|
|
6128
|
-
};
|
|
6129
|
-
|
|
6130
5850
|
/**
|
|
6131
5851
|
*
|
|
6132
5852
|
* @param {'prevent-app-suspension'|'prevent-display-sleep'} type
|
|
@@ -6143,18 +5863,6 @@ const stop = id => {
|
|
|
6143
5863
|
powerSaveBlocker.stop(id);
|
|
6144
5864
|
};
|
|
6145
5865
|
|
|
6146
|
-
const name$h = 'ElectronPowerSaveBlocker';
|
|
6147
|
-
const Commands$h = {
|
|
6148
|
-
start: start,
|
|
6149
|
-
stop: stop
|
|
6150
|
-
};
|
|
6151
|
-
|
|
6152
|
-
const ElectronPowerSaveBlocker_ipc = {
|
|
6153
|
-
__proto__: null,
|
|
6154
|
-
Commands: Commands$h,
|
|
6155
|
-
name: name$h
|
|
6156
|
-
};
|
|
6157
|
-
|
|
6158
5866
|
const Base64 = 'base64';
|
|
6159
5867
|
|
|
6160
5868
|
const isEncryptionAvailable = () => {
|
|
@@ -6168,1371 +5876,1924 @@ const decrypt = encrypted => {
|
|
|
6168
5876
|
return safeStorage.decryptString(buffer);
|
|
6169
5877
|
};
|
|
6170
5878
|
|
|
6171
|
-
const
|
|
6172
|
-
const
|
|
6173
|
-
|
|
6174
|
-
encrypt: encrypt,
|
|
6175
|
-
isEncryptionAvailable: isEncryptionAvailable
|
|
6176
|
-
};
|
|
6177
|
-
|
|
6178
|
-
const ElectronSafeStorage_ipc = {
|
|
6179
|
-
__proto__: null,
|
|
6180
|
-
Commands: Commands$g,
|
|
6181
|
-
name: name$g
|
|
5879
|
+
const getWidth = () => {
|
|
5880
|
+
const primaryDisplay = screen.getPrimaryDisplay();
|
|
5881
|
+
return primaryDisplay.bounds.width;
|
|
6182
5882
|
};
|
|
6183
|
-
|
|
6184
|
-
const
|
|
6185
|
-
|
|
6186
|
-
return true;
|
|
6187
|
-
}
|
|
6188
|
-
return false;
|
|
5883
|
+
const getHeight = () => {
|
|
5884
|
+
const primaryDisplay = screen.getPrimaryDisplay();
|
|
5885
|
+
return primaryDisplay.bounds.height;
|
|
6189
5886
|
};
|
|
6190
|
-
|
|
6191
|
-
const
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
5887
|
+
const getBounds = () => {
|
|
5888
|
+
const primaryDisplay = screen.getPrimaryDisplay();
|
|
5889
|
+
return {
|
|
5890
|
+
width: primaryDisplay.bounds.width,
|
|
5891
|
+
height: primaryDisplay.bounds.height
|
|
5892
|
+
};
|
|
6196
5893
|
};
|
|
6197
5894
|
|
|
6198
|
-
const
|
|
6199
|
-
const Commands$f = {
|
|
6200
|
-
beep: beep,
|
|
6201
|
-
openExternal: openExternal,
|
|
6202
|
-
openPath: showItemInFolder,
|
|
6203
|
-
showItemInFolder: showItemInFolder
|
|
6204
|
-
};
|
|
5895
|
+
const KeyDown = 'keyDown';
|
|
6205
5896
|
|
|
6206
|
-
const
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
const
|
|
6213
|
-
const
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
const
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
const
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
const
|
|
6268
|
-
const
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
const
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
const
|
|
6279
|
-
const
|
|
6280
|
-
|
|
6281
|
-
|
|
5897
|
+
const Backspace$1 = 'Backspace';
|
|
5898
|
+
const Tab$1 = 'Tab';
|
|
5899
|
+
const Space$2 = ' ';
|
|
5900
|
+
const Enter$1 = 'Enter';
|
|
5901
|
+
const Escape$1 = 'Escape';
|
|
5902
|
+
const PageUp$1 = 'PageUp';
|
|
5903
|
+
const PageDown$1 = 'PageDown';
|
|
5904
|
+
const Home$1 = 'Home';
|
|
5905
|
+
const End$1 = 'End';
|
|
5906
|
+
const LeftArrow$1 = 'ArrowLeft';
|
|
5907
|
+
const RightArrow$1 = 'ArrowRight';
|
|
5908
|
+
const UpArrow$1 = 'ArrowUp';
|
|
5909
|
+
const DownArrow$1 = 'ArrowDown';
|
|
5910
|
+
const Insert$1 = 'Insert';
|
|
5911
|
+
const Delete$1 = 'Delete';
|
|
5912
|
+
const Digit0$1 = '0';
|
|
5913
|
+
const Digit1$1 = '1';
|
|
5914
|
+
const Digit2$1 = '2';
|
|
5915
|
+
const Digit3$1 = '3';
|
|
5916
|
+
const Digit4$1 = '4';
|
|
5917
|
+
const Digit5$1 = '5';
|
|
5918
|
+
const Digit6$1 = '6';
|
|
5919
|
+
const Digit7$1 = '7';
|
|
5920
|
+
const Digit8$1 = '8';
|
|
5921
|
+
const Digit9$1 = '9';
|
|
5922
|
+
const KeyA$1 = 'a';
|
|
5923
|
+
const KeyB$1 = 'b';
|
|
5924
|
+
const KeyC$1 = 'c';
|
|
5925
|
+
const KeyD$1 = 'd';
|
|
5926
|
+
const KeyE$1 = 'e';
|
|
5927
|
+
const KeyF$1 = 'f';
|
|
5928
|
+
const KeyG$1 = 'g';
|
|
5929
|
+
const KeyH$1 = 'h';
|
|
5930
|
+
const KeyI$1 = 'i';
|
|
5931
|
+
const KeyJ$1 = 'j';
|
|
5932
|
+
const KeyK$1 = 'k';
|
|
5933
|
+
const KeyL$1 = 'l';
|
|
5934
|
+
const KeyM$1 = 'm';
|
|
5935
|
+
const KeyN$1 = 'n';
|
|
5936
|
+
const KeyO$1 = 'o';
|
|
5937
|
+
const KeyP$1 = 'p';
|
|
5938
|
+
const KeyQ$1 = 'q';
|
|
5939
|
+
const KeyR$1 = 'r';
|
|
5940
|
+
const KeyS$1 = 's';
|
|
5941
|
+
const KeyT$1 = 't';
|
|
5942
|
+
const KeyU$1 = 'u';
|
|
5943
|
+
const KeyV$1 = 'v';
|
|
5944
|
+
const KeyW$1 = 'w';
|
|
5945
|
+
const KeyX$1 = 'x';
|
|
5946
|
+
const KeyY$1 = 'y';
|
|
5947
|
+
const KeyZ$1 = 'z';
|
|
5948
|
+
const F1$1 = 'F1';
|
|
5949
|
+
const F2$1 = 'F2';
|
|
5950
|
+
const F3$1 = 'F3';
|
|
5951
|
+
const F4$1 = 'F4';
|
|
5952
|
+
const F5$1 = 'F5';
|
|
5953
|
+
const F6$1 = 'F6';
|
|
5954
|
+
const F7$1 = 'F7';
|
|
5955
|
+
const F8$1 = 'F8';
|
|
5956
|
+
const F9$1 = 'F9';
|
|
5957
|
+
const F10$1 = 'F10';
|
|
5958
|
+
const F11$1 = 'F11';
|
|
5959
|
+
const F12$1 = 'F12';
|
|
5960
|
+
const F13$1 = 'F13';
|
|
5961
|
+
const F14$1 = 'F14';
|
|
5962
|
+
const F15$1 = 'F15';
|
|
5963
|
+
const F16$1 = 'F16';
|
|
5964
|
+
const F17$1 = 'F17';
|
|
5965
|
+
const F18$1 = 'F18';
|
|
5966
|
+
const F19$1 = 'F19';
|
|
5967
|
+
const F20$1 = 'F20';
|
|
5968
|
+
const F21$1 = 'F21';
|
|
5969
|
+
const F22$1 = 'F22';
|
|
5970
|
+
const F23$1 = 'F23';
|
|
5971
|
+
const F24$1 = 'F24';
|
|
5972
|
+
const SemiColon$1 = ';';
|
|
5973
|
+
const Equal$1 = '=';
|
|
5974
|
+
const Comma$1 = ',';
|
|
5975
|
+
const Minus$1 = '-';
|
|
5976
|
+
const Period$1 = '.';
|
|
5977
|
+
const Slash$1 = '/';
|
|
5978
|
+
const Backquote$1 = '`';
|
|
5979
|
+
const BracketLeft$1 = '[';
|
|
5980
|
+
const Backslash$1 = '\\';
|
|
5981
|
+
const BracketRight$1 = ']';
|
|
5982
|
+
const Quote$1 = `'`;
|
|
5983
|
+
const Star$1 = '*';
|
|
5984
|
+
const Plus$1 = '+';
|
|
6282
5985
|
|
|
6283
|
-
const
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
5986
|
+
const Unknown = 0;
|
|
5987
|
+
const Backspace = 1;
|
|
5988
|
+
const Tab = 2;
|
|
5989
|
+
const Enter = 3;
|
|
5990
|
+
const Escape = 8;
|
|
5991
|
+
const Space$1 = 9;
|
|
5992
|
+
const PageUp = 10;
|
|
5993
|
+
const PageDown = 11;
|
|
5994
|
+
const End = 255;
|
|
5995
|
+
const Home = 12;
|
|
5996
|
+
const LeftArrow = 13;
|
|
5997
|
+
const UpArrow = 14;
|
|
5998
|
+
const RightArrow = 15;
|
|
5999
|
+
const DownArrow = 16;
|
|
6000
|
+
const Insert = 17;
|
|
6001
|
+
const Delete = 18;
|
|
6002
|
+
const Digit0 = 19;
|
|
6003
|
+
const Digit1 = 20;
|
|
6004
|
+
const Digit2 = 21;
|
|
6005
|
+
const Digit3 = 22;
|
|
6006
|
+
const Digit4 = 23;
|
|
6007
|
+
const Digit5 = 24;
|
|
6008
|
+
const Digit6 = 25;
|
|
6009
|
+
const Digit7 = 26;
|
|
6010
|
+
const Digit8 = 27;
|
|
6011
|
+
const Digit9 = 28;
|
|
6012
|
+
const KeyA = 29;
|
|
6013
|
+
const KeyB = 30;
|
|
6014
|
+
const KeyC = 31;
|
|
6015
|
+
const KeyD = 32;
|
|
6016
|
+
const KeyE = 33;
|
|
6017
|
+
const KeyF = 34;
|
|
6018
|
+
const KeyG = 35;
|
|
6019
|
+
const KeyH = 36;
|
|
6020
|
+
const KeyI = 37;
|
|
6021
|
+
const KeyJ = 38;
|
|
6022
|
+
const KeyK = 39;
|
|
6023
|
+
const KeyL = 40;
|
|
6024
|
+
const KeyM = 41;
|
|
6025
|
+
const KeyN = 42;
|
|
6026
|
+
const KeyO = 43;
|
|
6027
|
+
const KeyP = 44;
|
|
6028
|
+
const KeyQ = 45;
|
|
6029
|
+
const KeyR = 46;
|
|
6030
|
+
const KeyS = 47;
|
|
6031
|
+
const KeyT = 48;
|
|
6032
|
+
const KeyU = 49;
|
|
6033
|
+
const KeyV = 50;
|
|
6034
|
+
const KeyW = 51;
|
|
6035
|
+
const KeyX = 52;
|
|
6036
|
+
const KeyY = 53;
|
|
6037
|
+
const KeyZ = 54;
|
|
6038
|
+
const F1 = 57;
|
|
6039
|
+
const F2 = 58;
|
|
6040
|
+
const F3 = 59;
|
|
6041
|
+
const F4 = 60;
|
|
6042
|
+
const F5 = 61;
|
|
6043
|
+
const F6 = 62;
|
|
6044
|
+
const F7 = 63;
|
|
6045
|
+
const F8 = 64;
|
|
6046
|
+
const F9 = 65;
|
|
6047
|
+
const F10 = 66;
|
|
6048
|
+
const F11 = 67;
|
|
6049
|
+
const F12 = 68;
|
|
6050
|
+
const F13 = 69;
|
|
6051
|
+
const F14 = 70;
|
|
6052
|
+
const F15 = 71;
|
|
6053
|
+
const F16 = 72;
|
|
6054
|
+
const F17 = 72;
|
|
6055
|
+
const F18 = 74;
|
|
6056
|
+
const F19 = 75;
|
|
6057
|
+
const F20 = 76;
|
|
6058
|
+
const F21 = 77;
|
|
6059
|
+
const F22 = 78;
|
|
6060
|
+
const F23 = 79;
|
|
6061
|
+
const F24 = 80;
|
|
6062
|
+
const SemiColon = 83;
|
|
6063
|
+
const Equal = 84;
|
|
6064
|
+
const Comma = 85;
|
|
6065
|
+
const Minus = 86;
|
|
6066
|
+
const Period = 87;
|
|
6067
|
+
const Slash = 88;
|
|
6068
|
+
const Backquote = 89;
|
|
6069
|
+
const BracketLeft = 90;
|
|
6070
|
+
const Backslash = 91;
|
|
6071
|
+
const BracketRight = 92;
|
|
6072
|
+
const Quote = 93;
|
|
6073
|
+
const Star = 131;
|
|
6074
|
+
const Plus = 132;
|
|
6288
6075
|
|
|
6289
|
-
const
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6076
|
+
const getKeyCode = key => {
|
|
6077
|
+
switch (key) {
|
|
6078
|
+
case Backspace$1:
|
|
6079
|
+
return Backspace;
|
|
6080
|
+
case Tab$1:
|
|
6081
|
+
return Tab;
|
|
6082
|
+
case Escape$1:
|
|
6083
|
+
return Escape;
|
|
6084
|
+
case Enter$1:
|
|
6085
|
+
return Enter;
|
|
6086
|
+
case Space$2:
|
|
6087
|
+
return Space$1;
|
|
6088
|
+
case PageUp$1:
|
|
6089
|
+
return PageUp;
|
|
6090
|
+
case PageDown$1:
|
|
6091
|
+
return PageDown;
|
|
6092
|
+
case End$1:
|
|
6093
|
+
return End;
|
|
6094
|
+
case Home$1:
|
|
6095
|
+
return Home;
|
|
6096
|
+
case LeftArrow$1:
|
|
6097
|
+
return LeftArrow;
|
|
6098
|
+
case UpArrow$1:
|
|
6099
|
+
return UpArrow;
|
|
6100
|
+
case RightArrow$1:
|
|
6101
|
+
return RightArrow;
|
|
6102
|
+
case DownArrow$1:
|
|
6103
|
+
return DownArrow;
|
|
6104
|
+
case Insert$1:
|
|
6105
|
+
return Insert;
|
|
6106
|
+
case Delete$1:
|
|
6107
|
+
return Delete;
|
|
6108
|
+
case Digit0$1:
|
|
6109
|
+
return Digit0;
|
|
6110
|
+
case Digit1$1:
|
|
6111
|
+
return Digit1;
|
|
6112
|
+
case Digit2$1:
|
|
6113
|
+
return Digit2;
|
|
6114
|
+
case Digit3$1:
|
|
6115
|
+
return Digit3;
|
|
6116
|
+
case Digit4$1:
|
|
6117
|
+
return Digit4;
|
|
6118
|
+
case Digit5$1:
|
|
6119
|
+
return Digit5;
|
|
6120
|
+
case Digit6$1:
|
|
6121
|
+
return Digit6;
|
|
6122
|
+
case Digit7$1:
|
|
6123
|
+
return Digit7;
|
|
6124
|
+
case Digit8$1:
|
|
6125
|
+
return Digit8;
|
|
6126
|
+
case Digit9$1:
|
|
6127
|
+
return Digit9;
|
|
6128
|
+
case KeyA$1:
|
|
6129
|
+
return KeyA;
|
|
6130
|
+
case KeyB$1:
|
|
6131
|
+
return KeyB;
|
|
6132
|
+
case KeyC$1:
|
|
6133
|
+
return KeyC;
|
|
6134
|
+
case KeyD$1:
|
|
6135
|
+
return KeyD;
|
|
6136
|
+
case KeyE$1:
|
|
6137
|
+
return KeyE;
|
|
6138
|
+
case KeyF$1:
|
|
6139
|
+
return KeyF;
|
|
6140
|
+
case KeyG$1:
|
|
6141
|
+
return KeyG;
|
|
6142
|
+
case KeyH$1:
|
|
6143
|
+
return KeyH;
|
|
6144
|
+
case KeyI$1:
|
|
6145
|
+
return KeyI;
|
|
6146
|
+
case KeyJ$1:
|
|
6147
|
+
return KeyJ;
|
|
6148
|
+
case KeyK$1:
|
|
6149
|
+
return KeyK;
|
|
6150
|
+
case KeyL$1:
|
|
6151
|
+
return KeyL;
|
|
6152
|
+
case KeyM$1:
|
|
6153
|
+
return KeyM;
|
|
6154
|
+
case KeyN$1:
|
|
6155
|
+
return KeyN;
|
|
6156
|
+
case KeyO$1:
|
|
6157
|
+
return KeyO;
|
|
6158
|
+
case KeyP$1:
|
|
6159
|
+
return KeyP;
|
|
6160
|
+
case KeyQ$1:
|
|
6161
|
+
return KeyQ;
|
|
6162
|
+
case KeyR$1:
|
|
6163
|
+
return KeyR;
|
|
6164
|
+
case KeyS$1:
|
|
6165
|
+
return KeyS;
|
|
6166
|
+
case KeyT$1:
|
|
6167
|
+
return KeyT;
|
|
6168
|
+
case KeyU$1:
|
|
6169
|
+
return KeyU;
|
|
6170
|
+
case KeyV$1:
|
|
6171
|
+
return KeyV;
|
|
6172
|
+
case KeyW$1:
|
|
6173
|
+
return KeyW;
|
|
6174
|
+
case KeyX$1:
|
|
6175
|
+
return KeyX;
|
|
6176
|
+
case KeyY$1:
|
|
6177
|
+
return KeyY;
|
|
6178
|
+
case KeyZ$1:
|
|
6179
|
+
return KeyZ;
|
|
6180
|
+
case F1$1:
|
|
6181
|
+
return F1;
|
|
6182
|
+
case F2$1:
|
|
6183
|
+
return F2;
|
|
6184
|
+
case F3$1:
|
|
6185
|
+
return F3;
|
|
6186
|
+
case F4$1:
|
|
6187
|
+
return F4;
|
|
6188
|
+
case F5$1:
|
|
6189
|
+
return F5;
|
|
6190
|
+
case F6$1:
|
|
6191
|
+
return F6;
|
|
6192
|
+
case F7$1:
|
|
6193
|
+
return F7;
|
|
6194
|
+
case F8$1:
|
|
6195
|
+
return F8;
|
|
6196
|
+
case F9$1:
|
|
6197
|
+
return F9;
|
|
6198
|
+
case F10$1:
|
|
6199
|
+
return F10;
|
|
6200
|
+
case F11$1:
|
|
6201
|
+
return F11;
|
|
6202
|
+
case F12$1:
|
|
6203
|
+
return F12;
|
|
6204
|
+
case F13$1:
|
|
6205
|
+
return F13;
|
|
6206
|
+
case F14$1:
|
|
6207
|
+
return F14;
|
|
6208
|
+
case F15$1:
|
|
6209
|
+
return F15;
|
|
6210
|
+
case F16$1:
|
|
6211
|
+
return F16;
|
|
6212
|
+
case F17$1:
|
|
6213
|
+
return F17;
|
|
6214
|
+
case F18$1:
|
|
6215
|
+
return F18;
|
|
6216
|
+
case F19$1:
|
|
6217
|
+
return F19;
|
|
6218
|
+
case F20$1:
|
|
6219
|
+
return F20;
|
|
6220
|
+
case F21$1:
|
|
6221
|
+
return F21;
|
|
6222
|
+
case F22$1:
|
|
6223
|
+
return F22;
|
|
6224
|
+
case F23$1:
|
|
6225
|
+
return F23;
|
|
6226
|
+
case F24$1:
|
|
6227
|
+
return F24;
|
|
6228
|
+
case SemiColon$1:
|
|
6229
|
+
return SemiColon;
|
|
6230
|
+
case Equal$1:
|
|
6231
|
+
return Equal;
|
|
6232
|
+
case Comma$1:
|
|
6233
|
+
return Comma;
|
|
6234
|
+
case Minus$1:
|
|
6235
|
+
return Minus;
|
|
6236
|
+
case Period$1:
|
|
6237
|
+
return Period;
|
|
6238
|
+
case Slash$1:
|
|
6239
|
+
return Slash;
|
|
6240
|
+
case Backquote$1:
|
|
6241
|
+
return Backquote;
|
|
6242
|
+
case BracketLeft$1:
|
|
6243
|
+
return BracketLeft;
|
|
6244
|
+
case Backslash$1:
|
|
6245
|
+
return Backslash;
|
|
6246
|
+
case BracketRight$1:
|
|
6247
|
+
return BracketRight;
|
|
6248
|
+
case Quote$1:
|
|
6249
|
+
return Quote;
|
|
6250
|
+
case Star$1:
|
|
6251
|
+
return Star;
|
|
6252
|
+
case Plus$1:
|
|
6253
|
+
return Plus;
|
|
6254
|
+
default:
|
|
6255
|
+
return Unknown;
|
|
6256
|
+
}
|
|
6308
6257
|
};
|
|
6309
6258
|
|
|
6310
|
-
const
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
name: name$a
|
|
6314
|
-
};
|
|
6259
|
+
const CtrlCmd = 1 << 11 >>> 0;
|
|
6260
|
+
const Shift = 1 << 10 >>> 0;
|
|
6261
|
+
const Alt = 1 << 9 >>> 0;
|
|
6315
6262
|
|
|
6316
|
-
const
|
|
6317
|
-
|
|
6318
|
-
|
|
6263
|
+
const normalizeKey = key => {
|
|
6264
|
+
if (key.length === 1) {
|
|
6265
|
+
return key.toLowerCase();
|
|
6266
|
+
}
|
|
6267
|
+
return key;
|
|
6319
6268
|
};
|
|
6320
6269
|
|
|
6321
|
-
const
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6270
|
+
const getKeyBindingIdentifier = input => {
|
|
6271
|
+
const {
|
|
6272
|
+
control,
|
|
6273
|
+
shift,
|
|
6274
|
+
alt,
|
|
6275
|
+
key
|
|
6276
|
+
} = input;
|
|
6277
|
+
const modifierControl = control ? CtrlCmd : 0;
|
|
6278
|
+
const modifierShift = shift ? Shift : 0;
|
|
6279
|
+
const modifierAlt = alt ? Alt : 0;
|
|
6280
|
+
const normalizedKey = normalizeKey(key);
|
|
6281
|
+
const keyCode = getKeyCode(normalizedKey);
|
|
6282
|
+
const identifier = modifierControl | modifierShift | modifierAlt | keyCode;
|
|
6283
|
+
return identifier;
|
|
6325
6284
|
};
|
|
6326
6285
|
|
|
6327
|
-
const
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
};
|
|
6331
|
-
const getHeight = () => {
|
|
6332
|
-
const primaryDisplay = screen.getPrimaryDisplay();
|
|
6333
|
-
return primaryDisplay.bounds.height;
|
|
6334
|
-
};
|
|
6335
|
-
const getBounds = () => {
|
|
6336
|
-
const primaryDisplay = screen.getPrimaryDisplay();
|
|
6337
|
-
return {
|
|
6338
|
-
width: primaryDisplay.bounds.width,
|
|
6339
|
-
height: primaryDisplay.bounds.height
|
|
6340
|
-
};
|
|
6286
|
+
const key$6 = 'before-input';
|
|
6287
|
+
const attach$6 = (webContents, listener) => {
|
|
6288
|
+
webContents.on(BeforeInputEvent, listener);
|
|
6341
6289
|
};
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
const Commands$8 = {
|
|
6345
|
-
getBounds: getBounds,
|
|
6346
|
-
getWidth: getWidth,
|
|
6347
|
-
getHeight: getHeight
|
|
6290
|
+
const detach$6 = (webContents, listener) => {
|
|
6291
|
+
webContents.off(BeforeInputEvent, listener);
|
|
6348
6292
|
};
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6293
|
+
const handler$6 = (event, input) => {
|
|
6294
|
+
if (input.type !== KeyDown) {
|
|
6295
|
+
return {
|
|
6296
|
+
result: undefined,
|
|
6297
|
+
messages: []
|
|
6298
|
+
};
|
|
6299
|
+
}
|
|
6300
|
+
const falltroughKeyBindings = getFallthroughKeyBindings();
|
|
6301
|
+
const identifier = getKeyBindingIdentifier(input);
|
|
6302
|
+
// @ts-ignore
|
|
6303
|
+
const matches = falltroughKeyBindings.includes(identifier);
|
|
6304
|
+
if (matches) {
|
|
6305
|
+
event.preventDefault();
|
|
6306
|
+
return {
|
|
6307
|
+
result: undefined,
|
|
6308
|
+
messages: [['handleKeyBinding', identifier]]
|
|
6309
|
+
};
|
|
6310
|
+
}
|
|
6311
|
+
return {
|
|
6312
|
+
result: undefined,
|
|
6313
|
+
messages: []
|
|
6314
|
+
};
|
|
6354
6315
|
};
|
|
6355
6316
|
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
// that was created in the main process to the new utility process
|
|
6364
|
-
// The message ports in main process only exist temporarily
|
|
6365
|
-
// because they are sent to the shared process/utility process
|
|
6317
|
+
const ElectronBrowserViewEventListenerBeforeInput = {
|
|
6318
|
+
__proto__: null,
|
|
6319
|
+
attach: attach$6,
|
|
6320
|
+
detach: detach$6,
|
|
6321
|
+
handler: handler$6,
|
|
6322
|
+
key: key$6
|
|
6323
|
+
};
|
|
6366
6324
|
|
|
6367
|
-
const
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
const {
|
|
6371
|
-
port1,
|
|
6372
|
-
port2
|
|
6373
|
-
} = getPortTuple();
|
|
6374
|
-
await invokeAndTransfer('TemporaryMessagePort.handlePorts', port1, port2, id1, id2);
|
|
6325
|
+
const key$5 = 'context-menu';
|
|
6326
|
+
const attach$5 = (webContents, listener) => {
|
|
6327
|
+
webContents.on(ContextMenu, listener);
|
|
6375
6328
|
};
|
|
6376
|
-
const
|
|
6377
|
-
|
|
6378
|
-
object(port);
|
|
6379
|
-
const formattedName = formatUtilityProcessName(name);
|
|
6380
|
-
const utilityProcess = getByName(formattedName);
|
|
6381
|
-
const utilityProcessIpc = wrap(utilityProcess);
|
|
6382
|
-
handleIpc(utilityProcessIpc);
|
|
6383
|
-
await invokeAndTransfer$1(utilityProcessIpc, 'HandleElectronMessagePort.handleElectronMessagePort', port, ipcId);
|
|
6384
|
-
unhandleIpc(utilityProcessIpc);
|
|
6329
|
+
const detach$5 = (webContents, listener) => {
|
|
6330
|
+
webContents.off(ContextMenu, listener);
|
|
6385
6331
|
};
|
|
6386
|
-
const
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
return;
|
|
6392
|
-
}
|
|
6393
|
-
utilityProcess.kill();
|
|
6332
|
+
const handler$5 = (event, params) => {
|
|
6333
|
+
return {
|
|
6334
|
+
result: undefined,
|
|
6335
|
+
messages: [['handleContextMenu', params]]
|
|
6336
|
+
};
|
|
6394
6337
|
};
|
|
6395
6338
|
|
|
6396
|
-
const
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6339
|
+
const ElectronBrowserViewEventListenerContextMenu = {
|
|
6340
|
+
__proto__: null,
|
|
6341
|
+
attach: attach$5,
|
|
6342
|
+
detach: detach$5,
|
|
6343
|
+
handler: handler$5,
|
|
6344
|
+
key: key$5
|
|
6401
6345
|
};
|
|
6402
6346
|
|
|
6403
|
-
const
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6347
|
+
const key$4 = 'destroyed';
|
|
6348
|
+
const attach$4 = (webContents, listener) => {
|
|
6349
|
+
webContents.on(Destroyed, listener);
|
|
6350
|
+
};
|
|
6351
|
+
const detach$4 = (webContents, listener) => {
|
|
6352
|
+
webContents.off(Destroyed, listener);
|
|
6353
|
+
};
|
|
6354
|
+
const handler$4 = () => {
|
|
6355
|
+
return {
|
|
6356
|
+
result: undefined,
|
|
6357
|
+
messages: [['handleBrowserViewDestroyed']]
|
|
6358
|
+
};
|
|
6407
6359
|
};
|
|
6408
6360
|
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
// electron v22
|
|
6416
|
-
webContents.close();
|
|
6417
|
-
// @ts-ignore
|
|
6418
|
-
} else if (webContents.destroy) {
|
|
6419
|
-
// older versions of electron
|
|
6420
|
-
// @ts-ignore
|
|
6421
|
-
webContents.destroy();
|
|
6422
|
-
}
|
|
6361
|
+
const ElectronBrowserViewEventListenerDestroyed = {
|
|
6362
|
+
__proto__: null,
|
|
6363
|
+
attach: attach$4,
|
|
6364
|
+
detach: detach$4,
|
|
6365
|
+
handler: handler$4,
|
|
6366
|
+
key: key$4
|
|
6423
6367
|
};
|
|
6424
6368
|
|
|
6425
|
-
const
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
const url = contents.getURL();
|
|
6434
|
-
const title = contents.getTitle();
|
|
6369
|
+
const key$3 = 'did-navigate';
|
|
6370
|
+
const attach$3 = (webContents, listener) => {
|
|
6371
|
+
webContents.on(DidNavigate, listener);
|
|
6372
|
+
};
|
|
6373
|
+
const detach$3 = (webContents, listener) => {
|
|
6374
|
+
webContents.off(DidNavigate, listener);
|
|
6375
|
+
};
|
|
6376
|
+
const handler$3 = (event, url) => {
|
|
6435
6377
|
return {
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
url,
|
|
6439
|
-
title
|
|
6378
|
+
result: undefined,
|
|
6379
|
+
messages: [['handleDidNavigate', url]]
|
|
6440
6380
|
};
|
|
6441
6381
|
};
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6382
|
+
|
|
6383
|
+
const ElectronBrowserViewEventListenerDidNavigate = {
|
|
6384
|
+
__proto__: null,
|
|
6385
|
+
attach: attach$3,
|
|
6386
|
+
detach: detach$3,
|
|
6387
|
+
handler: handler$3,
|
|
6388
|
+
key: key$3
|
|
6449
6389
|
};
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6390
|
+
|
|
6391
|
+
const key$2 = 'page-title-updated';
|
|
6392
|
+
const attach$2 = (webContents, listener) => {
|
|
6393
|
+
webContents.on(PageTitleUpdated, listener);
|
|
6394
|
+
};
|
|
6395
|
+
const detach$2 = (webContents, listener) => {
|
|
6396
|
+
webContents.off(PageTitleUpdated, listener);
|
|
6397
|
+
};
|
|
6398
|
+
const handler$2 = (event, title) => {
|
|
6399
|
+
return {
|
|
6400
|
+
result: undefined,
|
|
6401
|
+
messages: [['handleTitleUpdated', title]]
|
|
6402
|
+
};
|
|
6458
6403
|
};
|
|
6459
6404
|
|
|
6460
|
-
const
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6405
|
+
const ElectronBrowserViewEventListenerPageTitleUpdated = {
|
|
6406
|
+
__proto__: null,
|
|
6407
|
+
attach: attach$2,
|
|
6408
|
+
detach: detach$2,
|
|
6409
|
+
handler: handler$2,
|
|
6410
|
+
key: key$2
|
|
6465
6411
|
};
|
|
6466
6412
|
|
|
6467
|
-
const
|
|
6413
|
+
const key$1 = 'will-navigate';
|
|
6414
|
+
const attach$1 = (webContents, listener) => {
|
|
6415
|
+
webContents.on(WillNavigate, listener);
|
|
6416
|
+
};
|
|
6417
|
+
const detach$1 = (webContents, listener) => {
|
|
6418
|
+
webContents.off(WillNavigate, listener);
|
|
6419
|
+
};
|
|
6420
|
+
const handler$1 = (event, url) => {
|
|
6421
|
+
return {
|
|
6422
|
+
result: undefined,
|
|
6423
|
+
messages: [['handleWillNavigate', url]]
|
|
6424
|
+
};
|
|
6425
|
+
};
|
|
6426
|
+
|
|
6427
|
+
const ElectronBrowserViewEventListenerWillNavigate = {
|
|
6468
6428
|
__proto__: null,
|
|
6469
|
-
|
|
6470
|
-
|
|
6429
|
+
attach: attach$1,
|
|
6430
|
+
detach: detach$1,
|
|
6431
|
+
handler: handler$1,
|
|
6432
|
+
key: key$1
|
|
6471
6433
|
};
|
|
6472
6434
|
|
|
6473
|
-
const
|
|
6435
|
+
const BackgroundTab = 'background-tab';
|
|
6436
|
+
const NewWindow = 'new-window';
|
|
6474
6437
|
|
|
6475
|
-
const
|
|
6476
|
-
const
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
const
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
const
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
const KeyW$1 = 'w';
|
|
6523
|
-
const KeyX$1 = 'x';
|
|
6524
|
-
const KeyY$1 = 'y';
|
|
6525
|
-
const KeyZ$1 = 'z';
|
|
6526
|
-
const F1$1 = 'F1';
|
|
6527
|
-
const F2$1 = 'F2';
|
|
6528
|
-
const F3$1 = 'F3';
|
|
6529
|
-
const F4$1 = 'F4';
|
|
6530
|
-
const F5$1 = 'F5';
|
|
6531
|
-
const F6$1 = 'F6';
|
|
6532
|
-
const F7$1 = 'F7';
|
|
6533
|
-
const F8$1 = 'F8';
|
|
6534
|
-
const F9$1 = 'F9';
|
|
6535
|
-
const F10$1 = 'F10';
|
|
6536
|
-
const F11$1 = 'F11';
|
|
6537
|
-
const F12$1 = 'F12';
|
|
6538
|
-
const F13$1 = 'F13';
|
|
6539
|
-
const F14$1 = 'F14';
|
|
6540
|
-
const F15$1 = 'F15';
|
|
6541
|
-
const F16$1 = 'F16';
|
|
6542
|
-
const F17$1 = 'F17';
|
|
6543
|
-
const F18$1 = 'F18';
|
|
6544
|
-
const F19$1 = 'F19';
|
|
6545
|
-
const F20$1 = 'F20';
|
|
6546
|
-
const F21$1 = 'F21';
|
|
6547
|
-
const F22$1 = 'F22';
|
|
6548
|
-
const F23$1 = 'F23';
|
|
6549
|
-
const F24$1 = 'F24';
|
|
6550
|
-
const SemiColon$1 = ';';
|
|
6551
|
-
const Equal$1 = '=';
|
|
6552
|
-
const Comma$1 = ',';
|
|
6553
|
-
const Minus$1 = '-';
|
|
6554
|
-
const Period$1 = '.';
|
|
6555
|
-
const Slash$1 = '/';
|
|
6556
|
-
const Backquote$1 = '`';
|
|
6557
|
-
const BracketLeft$1 = '[';
|
|
6558
|
-
const Backslash$1 = '\\';
|
|
6559
|
-
const BracketRight$1 = ']';
|
|
6560
|
-
const Quote$1 = `'`;
|
|
6561
|
-
const Star$1 = '*';
|
|
6562
|
-
const Plus$1 = '+';
|
|
6438
|
+
const key = 'window-open';
|
|
6439
|
+
const attach = (webContents, listener) => {
|
|
6440
|
+
webContents.setWindowOpenHandler(listener);
|
|
6441
|
+
};
|
|
6442
|
+
const detach = (webContents, listener) => {
|
|
6443
|
+
webContents.setWindowOpenHandler(null);
|
|
6444
|
+
};
|
|
6445
|
+
const handler = ({
|
|
6446
|
+
url,
|
|
6447
|
+
disposition,
|
|
6448
|
+
features,
|
|
6449
|
+
frameName,
|
|
6450
|
+
referrer,
|
|
6451
|
+
postBody
|
|
6452
|
+
}) => {
|
|
6453
|
+
if (url === 'about:blank') {
|
|
6454
|
+
return {
|
|
6455
|
+
result: {
|
|
6456
|
+
action: Allow
|
|
6457
|
+
},
|
|
6458
|
+
messages: []
|
|
6459
|
+
};
|
|
6460
|
+
}
|
|
6461
|
+
if (disposition === BackgroundTab) {
|
|
6462
|
+
return {
|
|
6463
|
+
result: {
|
|
6464
|
+
action: Deny
|
|
6465
|
+
},
|
|
6466
|
+
messages: [['handleWindowOpen', url]]
|
|
6467
|
+
};
|
|
6468
|
+
}
|
|
6469
|
+
if (disposition === NewWindow) {
|
|
6470
|
+
return {
|
|
6471
|
+
result: {
|
|
6472
|
+
action: Allow
|
|
6473
|
+
},
|
|
6474
|
+
messages: []
|
|
6475
|
+
};
|
|
6476
|
+
}
|
|
6477
|
+
info(`[main-process] blocked popup for ${url}`);
|
|
6478
|
+
return {
|
|
6479
|
+
result: {
|
|
6480
|
+
action: Deny
|
|
6481
|
+
},
|
|
6482
|
+
messages: []
|
|
6483
|
+
};
|
|
6484
|
+
};
|
|
6563
6485
|
|
|
6564
|
-
const
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
const PageDown = 11;
|
|
6572
|
-
const End = 255;
|
|
6573
|
-
const Home = 12;
|
|
6574
|
-
const LeftArrow = 13;
|
|
6575
|
-
const UpArrow = 14;
|
|
6576
|
-
const RightArrow = 15;
|
|
6577
|
-
const DownArrow = 16;
|
|
6578
|
-
const Insert = 17;
|
|
6579
|
-
const Delete = 18;
|
|
6580
|
-
const Digit0 = 19;
|
|
6581
|
-
const Digit1 = 20;
|
|
6582
|
-
const Digit2 = 21;
|
|
6583
|
-
const Digit3 = 22;
|
|
6584
|
-
const Digit4 = 23;
|
|
6585
|
-
const Digit5 = 24;
|
|
6586
|
-
const Digit6 = 25;
|
|
6587
|
-
const Digit7 = 26;
|
|
6588
|
-
const Digit8 = 27;
|
|
6589
|
-
const Digit9 = 28;
|
|
6590
|
-
const KeyA = 29;
|
|
6591
|
-
const KeyB = 30;
|
|
6592
|
-
const KeyC = 31;
|
|
6593
|
-
const KeyD = 32;
|
|
6594
|
-
const KeyE = 33;
|
|
6595
|
-
const KeyF = 34;
|
|
6596
|
-
const KeyG = 35;
|
|
6597
|
-
const KeyH = 36;
|
|
6598
|
-
const KeyI = 37;
|
|
6599
|
-
const KeyJ = 38;
|
|
6600
|
-
const KeyK = 39;
|
|
6601
|
-
const KeyL = 40;
|
|
6602
|
-
const KeyM = 41;
|
|
6603
|
-
const KeyN = 42;
|
|
6604
|
-
const KeyO = 43;
|
|
6605
|
-
const KeyP = 44;
|
|
6606
|
-
const KeyQ = 45;
|
|
6607
|
-
const KeyR = 46;
|
|
6608
|
-
const KeyS = 47;
|
|
6609
|
-
const KeyT = 48;
|
|
6610
|
-
const KeyU = 49;
|
|
6611
|
-
const KeyV = 50;
|
|
6612
|
-
const KeyW = 51;
|
|
6613
|
-
const KeyX = 52;
|
|
6614
|
-
const KeyY = 53;
|
|
6615
|
-
const KeyZ = 54;
|
|
6616
|
-
const F1 = 57;
|
|
6617
|
-
const F2 = 58;
|
|
6618
|
-
const F3 = 59;
|
|
6619
|
-
const F4 = 60;
|
|
6620
|
-
const F5 = 61;
|
|
6621
|
-
const F6 = 62;
|
|
6622
|
-
const F7 = 63;
|
|
6623
|
-
const F8 = 64;
|
|
6624
|
-
const F9 = 65;
|
|
6625
|
-
const F10 = 66;
|
|
6626
|
-
const F11 = 67;
|
|
6627
|
-
const F12 = 68;
|
|
6628
|
-
const F13 = 69;
|
|
6629
|
-
const F14 = 70;
|
|
6630
|
-
const F15 = 71;
|
|
6631
|
-
const F16 = 72;
|
|
6632
|
-
const F17 = 72;
|
|
6633
|
-
const F18 = 74;
|
|
6634
|
-
const F19 = 75;
|
|
6635
|
-
const F20 = 76;
|
|
6636
|
-
const F21 = 77;
|
|
6637
|
-
const F22 = 78;
|
|
6638
|
-
const F23 = 79;
|
|
6639
|
-
const F24 = 80;
|
|
6640
|
-
const SemiColon = 83;
|
|
6641
|
-
const Equal = 84;
|
|
6642
|
-
const Comma = 85;
|
|
6643
|
-
const Minus = 86;
|
|
6644
|
-
const Period = 87;
|
|
6645
|
-
const Slash = 88;
|
|
6646
|
-
const Backquote = 89;
|
|
6647
|
-
const BracketLeft = 90;
|
|
6648
|
-
const Backslash = 91;
|
|
6649
|
-
const BracketRight = 92;
|
|
6650
|
-
const Quote = 93;
|
|
6651
|
-
const Star = 131;
|
|
6652
|
-
const Plus = 132;
|
|
6486
|
+
const ElectronBrowserViewEventListenerWindowOpen = {
|
|
6487
|
+
__proto__: null,
|
|
6488
|
+
attach,
|
|
6489
|
+
detach,
|
|
6490
|
+
handler,
|
|
6491
|
+
key
|
|
6492
|
+
};
|
|
6653
6493
|
|
|
6654
|
-
const
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
case
|
|
6765
|
-
|
|
6766
|
-
case
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6494
|
+
const ElectronBrowserViewEventListeners = {
|
|
6495
|
+
__proto__: null,
|
|
6496
|
+
beforeInput: ElectronBrowserViewEventListenerBeforeInput,
|
|
6497
|
+
contextMenu: ElectronBrowserViewEventListenerContextMenu,
|
|
6498
|
+
destroyed: ElectronBrowserViewEventListenerDestroyed,
|
|
6499
|
+
didNavigate: ElectronBrowserViewEventListenerDidNavigate,
|
|
6500
|
+
pageTitleUpdated: ElectronBrowserViewEventListenerPageTitleUpdated,
|
|
6501
|
+
willNavigate: ElectronBrowserViewEventListenerWillNavigate,
|
|
6502
|
+
windowOpen: ElectronBrowserViewEventListenerWindowOpen
|
|
6503
|
+
};
|
|
6504
|
+
|
|
6505
|
+
const MainFrame = 'mainFrame';
|
|
6506
|
+
const Script = 'script';
|
|
6507
|
+
const Xhr = 'xhr';
|
|
6508
|
+
|
|
6509
|
+
const Get = 'GET';
|
|
6510
|
+
const Head = 'HEAD';
|
|
6511
|
+
const Options = 'OPTIONS';
|
|
6512
|
+
const Post = 'POST';
|
|
6513
|
+
|
|
6514
|
+
// @ts-ignore
|
|
6515
|
+
|
|
6516
|
+
const getBeforeRequestResponseMainFrame = (method, url) => {
|
|
6517
|
+
return {};
|
|
6518
|
+
};
|
|
6519
|
+
const cancelIfStartsWith = (url, canceledUrls) => {
|
|
6520
|
+
for (const canceledUrl of canceledUrls) {
|
|
6521
|
+
if (url.startsWith(canceledUrl)) {
|
|
6522
|
+
return {
|
|
6523
|
+
cancel: true
|
|
6524
|
+
};
|
|
6525
|
+
}
|
|
6526
|
+
}
|
|
6527
|
+
return {};
|
|
6528
|
+
};
|
|
6529
|
+
const getBeforeRequestResponseXhrPost = url => {
|
|
6530
|
+
const canceledUrls = ['https://www.youtube.com/api/stats/qoe', 'https://www.youtube.com/youtubei/v1/log_event', 'https://play.google.com/log'];
|
|
6531
|
+
return cancelIfStartsWith(url, canceledUrls);
|
|
6532
|
+
};
|
|
6533
|
+
const getBeforeRequestResponseXhrGet = url => {
|
|
6534
|
+
const canceledUrls = ['https://www.youtube.com/pagead/', 'https://www.youtube.com/api/stats/qoe', 'https://www.youtube.com/api/stats/ads', 'https://www.youtube.com/api/stats/delayplay', 'https://www.youtube.com/ptracking', 'https://www.youtube.com/api/timedtext', 'https://www.youtube.com/pcs/activeview', 'https://googleads.g.doubleclick.net/pagead/id'];
|
|
6535
|
+
return cancelIfStartsWith(url, canceledUrls);
|
|
6536
|
+
};
|
|
6537
|
+
const getBeforeRequestResponseXhrOptions = url => {
|
|
6538
|
+
const canceledUrls = ['https://play.google.com/log'];
|
|
6539
|
+
return cancelIfStartsWith(url, canceledUrls);
|
|
6540
|
+
};
|
|
6541
|
+
const getBeforeRequestResponseXhrHead = url => {
|
|
6542
|
+
const canceledUrls = ['https://www.youtube.com/generate_204'];
|
|
6543
|
+
return cancelIfStartsWith(url, canceledUrls);
|
|
6544
|
+
};
|
|
6545
|
+
const getBeforeRequestResponseXhr = (method, url) => {
|
|
6546
|
+
switch (method) {
|
|
6547
|
+
case Post:
|
|
6548
|
+
return getBeforeRequestResponseXhrPost(url);
|
|
6549
|
+
case Get:
|
|
6550
|
+
return getBeforeRequestResponseXhrGet(url);
|
|
6551
|
+
case Head:
|
|
6552
|
+
return getBeforeRequestResponseXhrHead(url);
|
|
6553
|
+
case Options:
|
|
6554
|
+
return getBeforeRequestResponseXhrOptions(url);
|
|
6555
|
+
default:
|
|
6556
|
+
return {};
|
|
6557
|
+
}
|
|
6558
|
+
};
|
|
6559
|
+
const getBeforeRequestResponseDefault = (method, url) => {
|
|
6560
|
+
return {};
|
|
6561
|
+
};
|
|
6562
|
+
const getBeforeRequestResponseScript = (method, url) => {
|
|
6563
|
+
const canceledUrls = ['https://static.doubleclick.net'];
|
|
6564
|
+
return cancelIfStartsWith(url, canceledUrls);
|
|
6565
|
+
};
|
|
6566
|
+
const getBeforeRequestResponse = details => {
|
|
6567
|
+
const {
|
|
6568
|
+
method,
|
|
6569
|
+
resourceType,
|
|
6570
|
+
url
|
|
6571
|
+
} = details;
|
|
6572
|
+
switch (resourceType) {
|
|
6573
|
+
case MainFrame:
|
|
6574
|
+
return getBeforeRequestResponseMainFrame();
|
|
6575
|
+
case Script:
|
|
6576
|
+
return getBeforeRequestResponseScript(method, url);
|
|
6577
|
+
case Xhr:
|
|
6578
|
+
return getBeforeRequestResponseXhr(method, url);
|
|
6579
|
+
default:
|
|
6580
|
+
return getBeforeRequestResponseDefault();
|
|
6581
|
+
}
|
|
6582
|
+
};
|
|
6583
|
+
|
|
6584
|
+
/**
|
|
6585
|
+
*
|
|
6586
|
+
* @param {Electron.OnBeforeRequestListenerDetails } details
|
|
6587
|
+
* @param {(response: globalThis.Electron.CallbackResponse) => void} callback
|
|
6588
|
+
*/
|
|
6589
|
+
const handleBeforeRequest = (details, callback) => {
|
|
6590
|
+
const response = getBeforeRequestResponse(details);
|
|
6591
|
+
callback(response);
|
|
6592
|
+
};
|
|
6593
|
+
const filter = {
|
|
6594
|
+
// urls: ['https://*.youtube.com/*'],
|
|
6595
|
+
urls: ['<all_urls>']
|
|
6596
|
+
};
|
|
6597
|
+
|
|
6598
|
+
const state$1 = {
|
|
6599
|
+
session: undefined
|
|
6600
|
+
};
|
|
6601
|
+
const isAllowedPermission = permission => {
|
|
6602
|
+
switch (permission) {
|
|
6603
|
+
case ClipBoardRead:
|
|
6604
|
+
case ClipBoardSanitizedWrite:
|
|
6605
|
+
case WindowPlacement:
|
|
6606
|
+
case FullScreen:
|
|
6607
|
+
case GeoLocation:
|
|
6608
|
+
return true;
|
|
6609
|
+
default:
|
|
6610
|
+
return false;
|
|
6611
|
+
}
|
|
6612
|
+
};
|
|
6613
|
+
const handlePermissionRequest = (webContents, permission, callback, details) => {
|
|
6614
|
+
callback(isAllowedPermission(permission));
|
|
6615
|
+
};
|
|
6616
|
+
const handlePermissionCheck = (webContents, permission, origin, details) => {
|
|
6617
|
+
return isAllowedPermission(permission);
|
|
6618
|
+
};
|
|
6619
|
+
const createSession = () => {
|
|
6620
|
+
const sessionId = `persist:browserView`;
|
|
6621
|
+
const session = Electron.session.fromPartition(sessionId, {
|
|
6622
|
+
cache: true
|
|
6623
|
+
});
|
|
6624
|
+
session.setPermissionRequestHandler(handlePermissionRequest);
|
|
6625
|
+
session.setPermissionCheckHandler(handlePermissionCheck);
|
|
6626
|
+
session.webRequest.onBeforeRequest(filter, handleBeforeRequest);
|
|
6627
|
+
// session.webRequest.addSessionChromeExtensions(session)
|
|
6628
|
+
return session;
|
|
6629
|
+
};
|
|
6630
|
+
const getSession = () => {
|
|
6631
|
+
state$1.session ||= createSession();
|
|
6632
|
+
return state$1.session;
|
|
6633
|
+
};
|
|
6634
|
+
|
|
6635
|
+
const state = {
|
|
6636
|
+
ipc: undefined
|
|
6637
|
+
};
|
|
6638
|
+
const set = ipc => {
|
|
6639
|
+
state.ipc = ipc;
|
|
6640
|
+
};
|
|
6641
|
+
const send = (method, ...params) => {
|
|
6642
|
+
const {
|
|
6643
|
+
ipc
|
|
6644
|
+
} = state;
|
|
6645
|
+
if (!ipc) {
|
|
6646
|
+
return;
|
|
6647
|
+
}
|
|
6648
|
+
send$2(ipc, method, ...params);
|
|
6649
|
+
};
|
|
6650
|
+
|
|
6651
|
+
// TODO use electron 30 webcontentsview api
|
|
6652
|
+
const createWebContentsView = async () => {
|
|
6653
|
+
const view = new WebContentsView({
|
|
6654
|
+
webPreferences: {
|
|
6655
|
+
session: getSession()
|
|
6656
|
+
}
|
|
6657
|
+
});
|
|
6658
|
+
// TODO get browser window id from renderer worker
|
|
6659
|
+
const browserWindow = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
|
|
6660
|
+
const {
|
|
6661
|
+
webContents
|
|
6662
|
+
} = view;
|
|
6663
|
+
const {
|
|
6664
|
+
id
|
|
6665
|
+
} = webContents;
|
|
6666
|
+
add$1(id, browserWindow, view);
|
|
6667
|
+
return id;
|
|
6668
|
+
};
|
|
6669
|
+
const attachEventListeners = webContentsId => {
|
|
6670
|
+
number(webContentsId);
|
|
6671
|
+
const webContents = Electron.webContents.fromId(webContentsId);
|
|
6672
|
+
if (!webContents) {
|
|
6673
|
+
return;
|
|
6674
|
+
}
|
|
6675
|
+
const values = Object.values(ElectronBrowserViewEventListeners);
|
|
6676
|
+
for (const value of values) {
|
|
6677
|
+
const wrappedListener = (...args) => {
|
|
6678
|
+
// @ts-ignore
|
|
6679
|
+
const {
|
|
6680
|
+
result,
|
|
6681
|
+
messages
|
|
6682
|
+
} = value.handler(...args);
|
|
6683
|
+
for (const message of messages) {
|
|
6684
|
+
const [key, ...rest] = message;
|
|
6685
|
+
send(`ElectronWebContents.${key}`, webContentsId, ...rest);
|
|
6686
|
+
}
|
|
6687
|
+
return result;
|
|
6688
|
+
};
|
|
6689
|
+
// TODO detached listeners when webcontents are disposed
|
|
6690
|
+
// to avoid potential memory leaks
|
|
6691
|
+
value.attach(webContents, wrappedListener);
|
|
6692
|
+
}
|
|
6693
|
+
};
|
|
6694
|
+
const disposeWebContentsView = browserViewId => {
|
|
6695
|
+
console.log('[main process] dispose browser view', browserViewId);
|
|
6696
|
+
const instance = get$2(browserViewId);
|
|
6697
|
+
if (!instance) {
|
|
6698
|
+
return;
|
|
6699
|
+
}
|
|
6700
|
+
const {
|
|
6701
|
+
view,
|
|
6702
|
+
browserWindow
|
|
6703
|
+
} = instance;
|
|
6704
|
+
remove$1(browserViewId);
|
|
6705
|
+
browserWindow.contentView.removeChildView(view);
|
|
6706
|
+
};
|
|
6707
|
+
|
|
6708
|
+
const webContentsViewErrorPath = join(root, 'packages', 'main-process', 'pages', 'error', 'error.html');
|
|
6709
|
+
|
|
6710
|
+
// TODO create output channel for browser view debug logs
|
|
6711
|
+
|
|
6712
|
+
const wrapBrowserViewCommand = fn => {
|
|
6713
|
+
const wrappedCommand = (id, ...args) => {
|
|
6714
|
+
const state = get$2(id);
|
|
6715
|
+
if (!state) {
|
|
6716
|
+
console.log(`[main process] no browser view with id ${id}`);
|
|
6717
|
+
return;
|
|
6718
|
+
}
|
|
6719
|
+
const {
|
|
6720
|
+
view
|
|
6721
|
+
} = state;
|
|
6722
|
+
return fn(view, ...args);
|
|
6723
|
+
};
|
|
6724
|
+
return wrappedCommand;
|
|
6725
|
+
};
|
|
6726
|
+
|
|
6727
|
+
/**
|
|
6728
|
+
*
|
|
6729
|
+
* @param {Electron.BrowserView} view
|
|
6730
|
+
* @param {number} x
|
|
6731
|
+
* @param {number} y
|
|
6732
|
+
* @param {number} width
|
|
6733
|
+
* @param {number} height
|
|
6734
|
+
*/
|
|
6735
|
+
const resizeBrowserView = (view, x, y, width, height) => {
|
|
6736
|
+
object(view);
|
|
6737
|
+
number(x);
|
|
6738
|
+
number(y);
|
|
6739
|
+
number(width);
|
|
6740
|
+
number(height);
|
|
6741
|
+
view.setBounds({
|
|
6742
|
+
x,
|
|
6743
|
+
y,
|
|
6744
|
+
width,
|
|
6745
|
+
height
|
|
6746
|
+
});
|
|
6747
|
+
};
|
|
6748
|
+
const setIframeSrcFallback = async (view, code, message) => {
|
|
6749
|
+
await view.webContents.loadFile(webContentsViewErrorPath, {
|
|
6750
|
+
query: {
|
|
6751
|
+
code,
|
|
6752
|
+
message
|
|
6753
|
+
}
|
|
6754
|
+
});
|
|
6755
|
+
};
|
|
6756
|
+
|
|
6757
|
+
/**
|
|
6758
|
+
*
|
|
6759
|
+
* @param {Electron.BrowserView} view
|
|
6760
|
+
* @param {string} iframeSrc
|
|
6761
|
+
*/
|
|
6762
|
+
const setIframeSrc = async (view, iframeSrc) => {
|
|
6763
|
+
try {
|
|
6764
|
+
object(view);
|
|
6765
|
+
string(iframeSrc);
|
|
6766
|
+
const {
|
|
6767
|
+
webContents
|
|
6768
|
+
} = view;
|
|
6769
|
+
await webContents.loadURL(iframeSrc);
|
|
6770
|
+
} catch (error) {
|
|
6771
|
+
const betterError = new VError(error, `Failed to set iframe src`);
|
|
6772
|
+
// @ts-ignore
|
|
6773
|
+
betterError.dontPrint = true;
|
|
6774
|
+
throw betterError;
|
|
6775
|
+
}
|
|
6776
|
+
};
|
|
6777
|
+
/**
|
|
6778
|
+
*
|
|
6779
|
+
* @param {Electron.BrowserView} view
|
|
6780
|
+
*/
|
|
6781
|
+
const focus = view => {
|
|
6782
|
+
const {
|
|
6783
|
+
webContents
|
|
6784
|
+
} = view;
|
|
6785
|
+
webContents.focus();
|
|
6786
|
+
};
|
|
6787
|
+
|
|
6788
|
+
/**
|
|
6789
|
+
*
|
|
6790
|
+
* @param {Electron.BrowserView} view
|
|
6791
|
+
*/
|
|
6792
|
+
const openDevtools = view => {
|
|
6793
|
+
const {
|
|
6794
|
+
webContents
|
|
6795
|
+
} = view;
|
|
6796
|
+
// TODO return promise that resolves once devtools are actually open
|
|
6797
|
+
webContents.openDevTools();
|
|
6798
|
+
};
|
|
6799
|
+
/**
|
|
6800
|
+
*
|
|
6801
|
+
* @param {Electron.BrowserView} view
|
|
6802
|
+
*/
|
|
6803
|
+
const reload = view => {
|
|
6804
|
+
const {
|
|
6805
|
+
webContents
|
|
6806
|
+
} = view;
|
|
6807
|
+
webContents.reload();
|
|
6808
|
+
};
|
|
6809
|
+
/**
|
|
6810
|
+
*
|
|
6811
|
+
* @param {Electron.BrowserView} view
|
|
6812
|
+
*/
|
|
6813
|
+
const forward = view => {
|
|
6814
|
+
const {
|
|
6815
|
+
webContents
|
|
6816
|
+
} = view;
|
|
6817
|
+
webContents.goForward();
|
|
6818
|
+
};
|
|
6819
|
+
|
|
6820
|
+
/**
|
|
6821
|
+
*
|
|
6822
|
+
* @param {Electron.BrowserView} view
|
|
6823
|
+
*/
|
|
6824
|
+
const backward = view => {
|
|
6825
|
+
// TODO return promise that resolves once devtools are actually open
|
|
6826
|
+
const {
|
|
6827
|
+
webContents
|
|
6828
|
+
} = view;
|
|
6829
|
+
webContents.goBack();
|
|
6830
|
+
};
|
|
6831
|
+
|
|
6832
|
+
/**
|
|
6833
|
+
*
|
|
6834
|
+
* @param {Electron.BrowserView} view
|
|
6835
|
+
*/
|
|
6836
|
+
const cancelNavigation = view => {
|
|
6837
|
+
const {
|
|
6838
|
+
webContents
|
|
6839
|
+
} = view;
|
|
6840
|
+
setCanceled(webContents.id);
|
|
6841
|
+
debug(`[main process] canceled navigation to ${webContents.getURL()}`);
|
|
6842
|
+
webContents.stop();
|
|
6843
|
+
if (webContents.canGoBack()) {
|
|
6844
|
+
webContents.goBack();
|
|
6845
|
+
}
|
|
6846
|
+
};
|
|
6847
|
+
const show = id => {
|
|
6848
|
+
// console.log('[main-process] show browser view', id)
|
|
6849
|
+
const state = get$2(id);
|
|
6850
|
+
if (!state) {
|
|
6851
|
+
debug('[main-process] failed to show browser view', id);
|
|
6852
|
+
return;
|
|
6853
|
+
}
|
|
6854
|
+
const {
|
|
6855
|
+
view,
|
|
6856
|
+
browserWindow
|
|
6857
|
+
} = state;
|
|
6858
|
+
browserWindow.contentView.addChildView(view);
|
|
6859
|
+
};
|
|
6860
|
+
const addToWindow = (browserWindowId, browserViewId) => {
|
|
6861
|
+
const state = get$2(browserViewId);
|
|
6862
|
+
const {
|
|
6863
|
+
view
|
|
6864
|
+
} = state;
|
|
6865
|
+
const browserWindow = BrowserWindow.fromId(browserWindowId);
|
|
6866
|
+
if (!browserWindow) {
|
|
6867
|
+
return;
|
|
6868
|
+
}
|
|
6869
|
+
browserWindow.contentView.addChildView(view);
|
|
6870
|
+
};
|
|
6871
|
+
const hide = id => {
|
|
6872
|
+
const state = get$2(id);
|
|
6873
|
+
if (!state) {
|
|
6874
|
+
debug('[main-process] failed to hide browser view', id);
|
|
6875
|
+
return;
|
|
6876
|
+
}
|
|
6877
|
+
const {
|
|
6878
|
+
view,
|
|
6879
|
+
browserWindow
|
|
6880
|
+
} = state;
|
|
6881
|
+
browserWindow.contentView.removeChildView(view);
|
|
6882
|
+
};
|
|
6883
|
+
|
|
6884
|
+
/**
|
|
6885
|
+
*
|
|
6886
|
+
* @param {Electron.BrowserView} view
|
|
6887
|
+
* @param {number} x
|
|
6888
|
+
* @param {number} y
|
|
6889
|
+
*/
|
|
6890
|
+
const inspectElement = (view, x, y) => {
|
|
6891
|
+
number(x);
|
|
6892
|
+
number(y);
|
|
6893
|
+
const {
|
|
6894
|
+
webContents
|
|
6895
|
+
} = view;
|
|
6896
|
+
webContents.inspectElement(x, y);
|
|
6897
|
+
};
|
|
6898
|
+
|
|
6899
|
+
/**
|
|
6900
|
+
*
|
|
6901
|
+
* @param {Electron.BrowserView} view
|
|
6902
|
+
* @param {string} backgroundColor
|
|
6903
|
+
*/
|
|
6904
|
+
const setBackgroundColor = (view, backgroundColor) => {
|
|
6905
|
+
view.setBackgroundColor(backgroundColor);
|
|
6906
|
+
};
|
|
6907
|
+
|
|
6908
|
+
/**
|
|
6909
|
+
*
|
|
6910
|
+
* @param {Electron.BrowserView} view
|
|
6911
|
+
* @param {number} x
|
|
6912
|
+
* @param {number} y
|
|
6913
|
+
*/
|
|
6914
|
+
const copyImageAt = (view, x, y) => {
|
|
6915
|
+
number(x);
|
|
6916
|
+
number(y);
|
|
6917
|
+
const {
|
|
6918
|
+
webContents
|
|
6919
|
+
} = view;
|
|
6920
|
+
webContents.copyImageAt(x, y);
|
|
6921
|
+
};
|
|
6922
|
+
const setFallThroughKeyBindings = fallthroughKeyBindings => {
|
|
6923
|
+
setFallthroughKeyBindings(fallthroughKeyBindings);
|
|
6924
|
+
};
|
|
6925
|
+
|
|
6926
|
+
// TODO maybe move some of these to webContentFunctions
|
|
6927
|
+
|
|
6928
|
+
/**
|
|
6929
|
+
* @param {Electron.BrowserView} view
|
|
6930
|
+
*/
|
|
6931
|
+
const getStats$1 = view => {
|
|
6932
|
+
const {
|
|
6933
|
+
webContents
|
|
6934
|
+
} = view;
|
|
6935
|
+
const canGoBack = webContents.canGoBack();
|
|
6936
|
+
const canGoForward = webContents.canGoForward();
|
|
6937
|
+
const url = webContents.getURL();
|
|
6938
|
+
const title = webContents.getTitle();
|
|
6939
|
+
return {
|
|
6940
|
+
canGoBack,
|
|
6941
|
+
canGoForward,
|
|
6942
|
+
url,
|
|
6943
|
+
title
|
|
6944
|
+
};
|
|
6945
|
+
};
|
|
6946
|
+
|
|
6947
|
+
const open2 = async (options, url) => {
|
|
6948
|
+
const allOptions = {
|
|
6949
|
+
...options,
|
|
6950
|
+
webPreferences: {
|
|
6951
|
+
...options.webPreferences,
|
|
6952
|
+
session: get()
|
|
6953
|
+
}
|
|
6954
|
+
};
|
|
6955
|
+
const processExplorerWindow = new BrowserWindow(allOptions);
|
|
6956
|
+
|
|
6957
|
+
/**
|
|
6958
|
+
*
|
|
6959
|
+
* @param {Electron.Event} event
|
|
6960
|
+
* @param {Electron.Input} input
|
|
6961
|
+
*/
|
|
6962
|
+
const handleBeforeInput = (event, input) => {
|
|
6963
|
+
if (input.control && input.key.toLowerCase() === 'i') {
|
|
6964
|
+
event.preventDefault();
|
|
6965
|
+
processExplorerWindow.webContents.openDevTools();
|
|
6966
|
+
}
|
|
6967
|
+
if (input.code && input.key.toLowerCase() === 'r') {
|
|
6968
|
+
event.preventDefault();
|
|
6969
|
+
processExplorerWindow.reload();
|
|
6970
|
+
}
|
|
6971
|
+
};
|
|
6972
|
+
processExplorerWindow.setMenuBarVisibility(false);
|
|
6973
|
+
processExplorerWindow.webContents.on(BeforeInputEvent, handleBeforeInput);
|
|
6974
|
+
const ipc = await listen({
|
|
6975
|
+
method: RendererProcess2,
|
|
6976
|
+
webContents: processExplorerWindow.webContents
|
|
6977
|
+
});
|
|
6978
|
+
handleIpc(ipc);
|
|
6979
|
+
try {
|
|
6980
|
+
await processExplorerWindow.loadURL(url);
|
|
6981
|
+
} catch (error) {
|
|
6982
|
+
console.error(error);
|
|
6983
|
+
// @ts-ignore
|
|
6984
|
+
// throw new VError(error, `Failed to load process explorer url `)
|
|
6985
|
+
}
|
|
6986
|
+
};
|
|
6987
|
+
|
|
6988
|
+
const getWindowId = webContentsId => {
|
|
6989
|
+
number(webContentsId);
|
|
6990
|
+
const webContents = Electron.webContents.fromId(webContentsId);
|
|
6991
|
+
if (!webContents) {
|
|
6992
|
+
return -1;
|
|
6993
|
+
}
|
|
6994
|
+
const browserWindow = Electron.BrowserWindow.fromWebContents(webContents);
|
|
6995
|
+
if (!browserWindow) {
|
|
6996
|
+
return -1;
|
|
6997
|
+
}
|
|
6998
|
+
return browserWindow.id;
|
|
6999
|
+
};
|
|
7000
|
+
|
|
7001
|
+
const handleElectronMessagePort = async (messagePort, ipcId) => {
|
|
7002
|
+
object(messagePort);
|
|
7003
|
+
const ipc = await listen({
|
|
7004
|
+
method: ElectronMessagePort$1,
|
|
7005
|
+
messagePort
|
|
7006
|
+
});
|
|
7007
|
+
handleIpc(ipc);
|
|
7008
|
+
if (ipcId === EmbedsProcess) {
|
|
7009
|
+
set(ipc);
|
|
7010
|
+
}
|
|
7011
|
+
};
|
|
7012
|
+
|
|
7013
|
+
const shouldOpenExternal = url => {
|
|
7014
|
+
if (url.startsWith('http:') || url.startsWith('https:')) {
|
|
7015
|
+
return true;
|
|
7016
|
+
}
|
|
7017
|
+
return false;
|
|
7018
|
+
};
|
|
7019
|
+
|
|
7020
|
+
const openExternal = async url => {
|
|
7021
|
+
if (!shouldOpenExternal(url)) {
|
|
7022
|
+
throw new VError(`only http or https urls are allowed`);
|
|
7023
|
+
}
|
|
7024
|
+
await shell.openExternal(url);
|
|
7025
|
+
};
|
|
7026
|
+
|
|
7027
|
+
const Dash = '-';
|
|
7028
|
+
const Space = ' ';
|
|
7029
|
+
|
|
7030
|
+
const firstLetterLowerCase = string => {
|
|
7031
|
+
return string[0].toLowerCase() + string.slice(1);
|
|
7032
|
+
};
|
|
7033
|
+
const camelCase = string => {
|
|
7034
|
+
const parts = string.split(Space);
|
|
7035
|
+
const lowerParts = parts.map(firstLetterLowerCase);
|
|
7036
|
+
return lowerParts.join(Dash);
|
|
7037
|
+
};
|
|
7038
|
+
|
|
7039
|
+
const formatUtilityProcessName = name => {
|
|
7040
|
+
return camelCase(name);
|
|
7041
|
+
};
|
|
7042
|
+
|
|
7043
|
+
const {
|
|
7044
|
+
create
|
|
7045
|
+
} = IpcParentWithElectronUtilityProcess$1$1;
|
|
7046
|
+
const {
|
|
7047
|
+
wrap
|
|
7048
|
+
} = IpcParentWithElectronUtilityProcess$1$1;
|
|
7049
|
+
const effects = ({
|
|
7050
|
+
rawIpc,
|
|
7051
|
+
name
|
|
7052
|
+
}) => {
|
|
7053
|
+
if (!rawIpc.pid) {
|
|
7054
|
+
return;
|
|
7055
|
+
}
|
|
7056
|
+
const {
|
|
7057
|
+
pid
|
|
7058
|
+
} = rawIpc;
|
|
7059
|
+
const formattedName = formatUtilityProcessName(name);
|
|
7060
|
+
add(pid, rawIpc, formattedName);
|
|
7061
|
+
const cleanup = () => {
|
|
7062
|
+
remove(pid);
|
|
7063
|
+
rawIpc.off('exit', handleExit);
|
|
7064
|
+
};
|
|
7065
|
+
const handleExit = () => {
|
|
7066
|
+
cleanup();
|
|
7067
|
+
};
|
|
7068
|
+
rawIpc.on('exit', handleExit);
|
|
7069
|
+
};
|
|
7070
|
+
|
|
7071
|
+
const IpcParentWithElectronUtilityProcess = {
|
|
7072
|
+
__proto__: null,
|
|
7073
|
+
create,
|
|
7074
|
+
effects,
|
|
7075
|
+
wrap
|
|
7076
|
+
};
|
|
7077
|
+
|
|
7078
|
+
// TODO
|
|
7079
|
+
// In order to create utility process from shared process
|
|
7080
|
+
// create a message channel in the main process and
|
|
7081
|
+
// send one port to the shared process and the other port
|
|
7082
|
+
// to the utilityprocess that should be created.
|
|
7083
|
+
// Then send the other message port that has been sent from renderer worker
|
|
7084
|
+
// to renderer process to shared process onto the message port
|
|
7085
|
+
// that was created in the main process to the new utility process
|
|
7086
|
+
// The message ports in main process only exist temporarily
|
|
7087
|
+
// because they are sent to the shared process/utility process
|
|
7088
|
+
|
|
7089
|
+
const createPortTuple = async (id1, id2) => {
|
|
7090
|
+
number(id1);
|
|
7091
|
+
number(id2);
|
|
7092
|
+
const {
|
|
7093
|
+
port1,
|
|
7094
|
+
port2
|
|
7095
|
+
} = getPortTuple();
|
|
7096
|
+
await invokeAndTransfer('TemporaryMessagePort.handlePorts', port1, port2, id1, id2);
|
|
7097
|
+
};
|
|
7098
|
+
const sendTo = async (port, name, ipcId) => {
|
|
7099
|
+
string(name);
|
|
7100
|
+
object(port);
|
|
7101
|
+
const formattedName = formatUtilityProcessName(name);
|
|
7102
|
+
const utilityProcess = getByName(formattedName);
|
|
7103
|
+
const utilityProcessIpc = wrap(utilityProcess);
|
|
7104
|
+
handleIpc(utilityProcessIpc);
|
|
7105
|
+
await invokeAndTransfer$1(utilityProcessIpc, 'HandleElectronMessagePort.handleElectronMessagePort', port, ipcId);
|
|
7106
|
+
unhandleIpc(utilityProcessIpc);
|
|
7107
|
+
};
|
|
7108
|
+
const dispose$1 = name => {
|
|
7109
|
+
string(name);
|
|
7110
|
+
const formattedName = formatUtilityProcessName(name);
|
|
7111
|
+
const utilityProcess = getByName(formattedName);
|
|
7112
|
+
if (!utilityProcess) {
|
|
7113
|
+
return;
|
|
7114
|
+
}
|
|
7115
|
+
utilityProcess.kill();
|
|
7116
|
+
};
|
|
7117
|
+
|
|
7118
|
+
const trash = async path => {
|
|
7119
|
+
string(path);
|
|
7120
|
+
await shell.trashItem(path);
|
|
7121
|
+
};
|
|
7122
|
+
|
|
7123
|
+
const commandMap = {
|
|
7124
|
+
'AppWindow.createAppWindow': createAppWindow,
|
|
7125
|
+
'Beep.beep': beep$1,
|
|
7126
|
+
'Crash.crashMainProcess': crashMainProcess$1,
|
|
7127
|
+
'DesktopCapturer.getSources': getSources,
|
|
7128
|
+
'CreateMessagePort.createMessagePort': createMessagePort,
|
|
7129
|
+
'CreatePidMap.createPidMap': createPidMap,
|
|
7130
|
+
'ElectronApplicationMenu.setItems': setItems,
|
|
7131
|
+
'ElectronBeep.beep': beep,
|
|
7132
|
+
'ElectronContentTracing.startRecording': startRecording,
|
|
7133
|
+
'ElectronContentTracing.stopRecording': stopRecording,
|
|
7134
|
+
'ElectronDeveloper.crashMainProcess': crashMainProcess,
|
|
7135
|
+
'ElectronDeveloper.getPerformanceEntries': getPerformanceEntries,
|
|
7136
|
+
'ElectronDialog.showMessageBox': showMessageBox,
|
|
7137
|
+
'ElectronDialog.showOpenDialog': showOpenDialog,
|
|
7138
|
+
'ElectronNet.getJson': getJson,
|
|
7139
|
+
'ElectronNetLog.startLogging': startLogging,
|
|
7140
|
+
'ElectronNetLog.stopLogging': stopLogging,
|
|
7141
|
+
'ElectronPowerSaveBlocker.start': start,
|
|
7142
|
+
'ElectronPowerSaveBlocker.stop': stop,
|
|
7143
|
+
'ElectronSafeStorage.decrypt': decrypt,
|
|
7144
|
+
'ElectronSafeStorage.encrypt': encrypt,
|
|
7145
|
+
'ElectronSafeStorage.isEncryptionAvailable': isEncryptionAvailable,
|
|
7146
|
+
'ElectronScreen.getBounds': getBounds,
|
|
7147
|
+
'ElectronScreen.getHeight': getHeight,
|
|
7148
|
+
'ElectronScreen.getWidth': getWidth,
|
|
7149
|
+
'ElectronSession.registerWebviewProtocol': registerWebviewProtocol,
|
|
7150
|
+
'ElectronShell.beep': beep,
|
|
7151
|
+
'ElectronShell.openExternal': openExternal,
|
|
7152
|
+
'ElectronShell.openPath': openPath,
|
|
7153
|
+
'ElectronShell.showItemInFolder': showItemInFolder,
|
|
7154
|
+
'ElectronWebContentsView.attachEventListeners': attachEventListeners,
|
|
7155
|
+
'ElectronWebContentsView.createWebContentsView': createWebContentsView,
|
|
7156
|
+
'ElectronWebContentsView.disposeWebContentsView': disposeWebContentsView,
|
|
7157
|
+
'ElectronWebContentsViewFunctions.addToWindow': addToWindow,
|
|
7158
|
+
'ElectronWebContentsViewFunctions.backward': backward,
|
|
7159
|
+
'ElectronWebContentsViewFunctions.cancelNavigation': cancelNavigation,
|
|
7160
|
+
'ElectronWebContentsViewFunctions.copyImageAt': copyImageAt,
|
|
7161
|
+
'ElectronWebContentsViewFunctions.focus': focus,
|
|
7162
|
+
'ElectronWebContentsViewFunctions.forward': forward,
|
|
7163
|
+
'ElectronWebContentsViewFunctions.getStats': getStats$1,
|
|
7164
|
+
'ElectronWebContentsViewFunctions.hide': hide,
|
|
7165
|
+
'ElectronWebContentsViewFunctions.inspectElement': inspectElement,
|
|
7166
|
+
'ElectronWebContentsViewFunctions.openDevtools': openDevtools,
|
|
7167
|
+
'ElectronWebContentsViewFunctions.reload': reload,
|
|
7168
|
+
'ElectronWebContentsViewFunctions.resizeBrowserView': resizeBrowserView,
|
|
7169
|
+
'ElectronWebContentsViewFunctions.setBackgroundColor': setBackgroundColor,
|
|
7170
|
+
'ElectronWebContentsViewFunctions.setFallthroughKeyBindings': undefined,
|
|
7171
|
+
'ElectronWebContentsViewFunctions.setIframeSrc': setIframeSrc,
|
|
7172
|
+
'ElectronWebContentsViewFunctions.setIframeSrcFallback': setIframeSrcFallback,
|
|
7173
|
+
'ElectronWebContentsViewFunctions.show': show,
|
|
7174
|
+
'ElectronWindow.executeWebContentsFunction': executeWebContentsFunction,
|
|
7175
|
+
'ElectronWindow.executeWindowFunction': executeWindowFunction,
|
|
7176
|
+
'ElectronWindow.getFocusedWindowId': getFocusedWindowId,
|
|
7177
|
+
'ElectronWindow.getZoom': getZoom,
|
|
7178
|
+
'ElectronWindowProcessExplorer.open2': open2,
|
|
7179
|
+
'Exit.exit': exit,
|
|
7180
|
+
'GetWindowId.getWindowId': getWindowId,
|
|
7181
|
+
'HandleElectronMessagePort.handleElectronMessagePort': handleElectronMessagePort,
|
|
7182
|
+
'IpcParent.create': create$2,
|
|
7183
|
+
'OpenExternal.openExternal': openExternal,
|
|
7184
|
+
'Process.getArgv': getArgv,
|
|
7185
|
+
'Process.getChromeVersion': getChromeVersion,
|
|
7186
|
+
'Process.getElectronVersion': getElectronVersion,
|
|
7187
|
+
'Process.getNodeVersion': getNodeVersion,
|
|
7188
|
+
'Process.getPid': getPid,
|
|
7189
|
+
'Process.getV8Version': getV8Version,
|
|
7190
|
+
'TemporaryMessagePort.createPortTuple': createPortTuple,
|
|
7191
|
+
'TemporaryMessagePort.dispose': dispose$1,
|
|
7192
|
+
'TemporaryMessagePort.sendTo': sendTo,
|
|
7193
|
+
'Trash.trash': trash
|
|
7194
|
+
};
|
|
7195
|
+
|
|
7196
|
+
class ModuleNotFoundError extends Error {
|
|
7197
|
+
constructor(id) {
|
|
7198
|
+
super(`Module ${id} not found`);
|
|
7199
|
+
this.name = 'ModuleNotFoundError';
|
|
7200
|
+
// @ts-ignore
|
|
7201
|
+
this.code = E_MODULE_NOT_FOUND;
|
|
7202
|
+
}
|
|
7203
|
+
}
|
|
7204
|
+
|
|
7205
|
+
const load = async moduleId => {
|
|
7206
|
+
switch (moduleId) {
|
|
7207
|
+
case App:
|
|
7208
|
+
return Promise.resolve().then(function () { return App_ipc; });
|
|
7209
|
+
case AppWindow:
|
|
7210
|
+
return Promise.resolve().then(function () { return AppWindow_ipc; });
|
|
7211
|
+
case Beep:
|
|
7212
|
+
return Promise.resolve().then(function () { return Beep_ipc; });
|
|
7213
|
+
case Crash:
|
|
7214
|
+
return Promise.resolve().then(function () { return Crash_ipc; });
|
|
7215
|
+
case CreateMessagePort:
|
|
7216
|
+
return Promise.resolve().then(function () { return CreateMessagePort_ipc; });
|
|
7217
|
+
case CreatePidMap:
|
|
7218
|
+
return Promise.resolve().then(function () { return CreatePidMap_ipc; });
|
|
7219
|
+
case DesktopCapturer:
|
|
7220
|
+
return Promise.resolve().then(function () { return DesktopCapturer_ipc; });
|
|
7221
|
+
case ElectronApplicationMenu:
|
|
7222
|
+
return Promise.resolve().then(function () { return ElectronApplicationMenu_ipc; });
|
|
7223
|
+
case ElectronClipBoard:
|
|
7224
|
+
return Promise.resolve().then(function () { return ElectronClipBoard_ipc; });
|
|
7225
|
+
case ElectronContentTracing:
|
|
7226
|
+
return Promise.resolve().then(function () { return ElectronContentTracing_ipc; });
|
|
7227
|
+
case ElectronContextMenu:
|
|
7228
|
+
return Promise.resolve().then(function () { return ElectronContextMenu_ipc; });
|
|
7229
|
+
case Developer:
|
|
7230
|
+
return Promise.resolve().then(function () { return ElectronDeveloper_ipc; });
|
|
7231
|
+
case Dialog:
|
|
7232
|
+
return Promise.resolve().then(function () { return ElectronDialog_ipc; });
|
|
7233
|
+
case ElectronNet:
|
|
7234
|
+
return Promise.resolve().then(function () { return ElectronNet_ipc; });
|
|
7235
|
+
case ElectronNetLog:
|
|
7236
|
+
return Promise.resolve().then(function () { return ElectronNetLog_ipc; });
|
|
7237
|
+
case ElectronPowerSaveBlocker:
|
|
7238
|
+
return Promise.resolve().then(function () { return ElectronPowerSaveBlocker_ipc; });
|
|
7239
|
+
case ElectronSafeStorage:
|
|
7240
|
+
return Promise.resolve().then(function () { return ElectronSafeStorage_ipc; });
|
|
7241
|
+
case ElectronShell:
|
|
7242
|
+
return Promise.resolve().then(function () { return ElectronShell_ipc; });
|
|
7243
|
+
case Window:
|
|
7244
|
+
return Promise.resolve().then(function () { return ElectronWindow_ipc; });
|
|
7245
|
+
case ElectronWindowProcessExplorer:
|
|
7246
|
+
return Promise.resolve().then(function () { return ElectronWindowProcessExplorer_ipc; });
|
|
7247
|
+
case IpcParent:
|
|
7248
|
+
return Promise.resolve().then(function () { return IpcParent_ipc; });
|
|
7249
|
+
case OpenExternal$1:
|
|
7250
|
+
return Promise.resolve().then(function () { return OpenExternal_ipc; });
|
|
7251
|
+
case Process:
|
|
7252
|
+
return Promise.resolve().then(function () { return Process_ipc; });
|
|
7253
|
+
case Exit:
|
|
7254
|
+
return Promise.resolve().then(function () { return Exit_ipc; });
|
|
7255
|
+
case ElectronScreen:
|
|
7256
|
+
return Promise.resolve().then(function () { return ElectronScreen_ipc; });
|
|
7257
|
+
case TemporaryMessagePort:
|
|
7258
|
+
return Promise.resolve().then(function () { return TemporaryMessagePort_ipc; });
|
|
7259
|
+
case ElectronWebContents:
|
|
7260
|
+
return Promise.resolve().then(function () { return ElectronWebContents_ipc; });
|
|
7261
|
+
case ElectronWebContentsView:
|
|
7262
|
+
return Promise.resolve().then(function () { return ElectronWebContentsView_ipc; });
|
|
7263
|
+
case ElectronWebContentsViewFunctions:
|
|
7264
|
+
return Promise.resolve().then(function () { return ElectronWebContentsViewFunctions_ipc; });
|
|
7265
|
+
case HandleElectronMessagePort:
|
|
7266
|
+
return Promise.resolve().then(function () { return HandleElectronMessagePort_ipc; });
|
|
7267
|
+
case GetWindowId:
|
|
7268
|
+
return Promise.resolve().then(function () { return GetWindowId_ipc; });
|
|
7269
|
+
case ElectronSession:
|
|
7270
|
+
return Promise.resolve().then(function () { return ElectronSession_ipc; });
|
|
7271
|
+
case Trash:
|
|
7272
|
+
return Promise.resolve().then(function () { return Trash_ipc; });
|
|
6832
7273
|
default:
|
|
6833
|
-
|
|
7274
|
+
throw new ModuleNotFoundError(moduleId);
|
|
7275
|
+
}
|
|
7276
|
+
};
|
|
7277
|
+
|
|
7278
|
+
const setStackTraceLimit = value => {
|
|
7279
|
+
if (Error.stackTraceLimit && Error.stackTraceLimit < value) {
|
|
7280
|
+
Error.stackTraceLimit = value;
|
|
6834
7281
|
}
|
|
6835
7282
|
};
|
|
6836
7283
|
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
const
|
|
7284
|
+
// @ts-ignore
|
|
7285
|
+
performance.mark('code/start');
|
|
7286
|
+
const main = async () => {
|
|
7287
|
+
Object.assign(commandMapRef, commandMap);
|
|
7288
|
+
setStackTraceLimit(20);
|
|
7289
|
+
on$1('uncaughtExceptionMonitor', handleUncaughtExceptionMonitor);
|
|
7290
|
+
// workaround for https://github.com/electron/electron/issues/36526
|
|
7291
|
+
on$1('unhandledRejection', handleUnhandledRejection);
|
|
7292
|
+
setLoad(load);
|
|
7293
|
+
await hydrate();
|
|
7294
|
+
};
|
|
7295
|
+
|
|
7296
|
+
main();
|
|
6840
7297
|
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
};
|
|
7298
|
+
if (typeof Electron__default === 'string') {
|
|
7299
|
+
throw new TypeError('Not running in an Electron environment!');
|
|
7300
|
+
}
|
|
7301
|
+
const {
|
|
7302
|
+
env
|
|
7303
|
+
} = process; // eslint-disable-line n/prefer-global/process
|
|
7304
|
+
const isEnvSet = 'ELECTRON_IS_DEV' in env;
|
|
7305
|
+
const getFromEnv = Number.parseInt(env.ELECTRON_IS_DEV, 10) === 1;
|
|
7306
|
+
const isDev = isEnvSet ? getFromEnv : !Electron__default.app.isPackaged;
|
|
6847
7307
|
|
|
6848
|
-
const
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
shift,
|
|
6852
|
-
alt,
|
|
6853
|
-
key
|
|
6854
|
-
} = input;
|
|
6855
|
-
const modifierControl = control ? CtrlCmd : 0;
|
|
6856
|
-
const modifierShift = shift ? Shift : 0;
|
|
6857
|
-
const modifierAlt = alt ? Alt : 0;
|
|
6858
|
-
const normalizedKey = normalizeKey(key);
|
|
6859
|
-
const keyCode = getKeyCode(normalizedKey);
|
|
6860
|
-
const identifier = modifierControl | modifierShift | modifierAlt | keyCode;
|
|
6861
|
-
return identifier;
|
|
7308
|
+
const index = {
|
|
7309
|
+
__proto__: null,
|
|
7310
|
+
default: isDev
|
|
6862
7311
|
};
|
|
6863
7312
|
|
|
6864
|
-
const
|
|
6865
|
-
const
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
7313
|
+
const name$w = 'App';
|
|
7314
|
+
const Commands$w = {};
|
|
7315
|
+
|
|
7316
|
+
const App_ipc = {
|
|
7317
|
+
__proto__: null,
|
|
7318
|
+
Commands: Commands$w,
|
|
7319
|
+
name: name$w
|
|
6870
7320
|
};
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
messages: []
|
|
6876
|
-
};
|
|
6877
|
-
}
|
|
6878
|
-
const falltroughKeyBindings = getFallthroughKeyBindings();
|
|
6879
|
-
const identifier = getKeyBindingIdentifier(input);
|
|
6880
|
-
// @ts-ignore
|
|
6881
|
-
const matches = falltroughKeyBindings.includes(identifier);
|
|
6882
|
-
if (matches) {
|
|
6883
|
-
event.preventDefault();
|
|
6884
|
-
return {
|
|
6885
|
-
result: undefined,
|
|
6886
|
-
messages: [['handleKeyBinding', identifier]]
|
|
6887
|
-
};
|
|
6888
|
-
}
|
|
6889
|
-
return {
|
|
6890
|
-
result: undefined,
|
|
6891
|
-
messages: []
|
|
6892
|
-
};
|
|
7321
|
+
|
|
7322
|
+
const name$v = 'AppWindow';
|
|
7323
|
+
const Commands$v = {
|
|
7324
|
+
createAppWindow: createAppWindow
|
|
6893
7325
|
};
|
|
6894
7326
|
|
|
6895
|
-
const
|
|
7327
|
+
const AppWindow_ipc = {
|
|
6896
7328
|
__proto__: null,
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
handler: handler$6,
|
|
6900
|
-
key: key$6
|
|
7329
|
+
Commands: Commands$v,
|
|
7330
|
+
name: name$v
|
|
6901
7331
|
};
|
|
6902
7332
|
|
|
6903
|
-
const
|
|
6904
|
-
const
|
|
6905
|
-
|
|
7333
|
+
const name$u = 'Beep';
|
|
7334
|
+
const Commands$u = {
|
|
7335
|
+
beep: beep$1
|
|
6906
7336
|
};
|
|
6907
|
-
|
|
6908
|
-
|
|
7337
|
+
|
|
7338
|
+
const Beep_ipc = {
|
|
7339
|
+
__proto__: null,
|
|
7340
|
+
Commands: Commands$u,
|
|
7341
|
+
name: name$u
|
|
6909
7342
|
};
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
};
|
|
7343
|
+
|
|
7344
|
+
const name$t = 'Crash';
|
|
7345
|
+
const Commands$t = {
|
|
7346
|
+
crashMainProcess: crashMainProcess$1
|
|
6915
7347
|
};
|
|
6916
7348
|
|
|
6917
|
-
const
|
|
7349
|
+
const Crash_ipc = {
|
|
6918
7350
|
__proto__: null,
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
handler: handler$5,
|
|
6922
|
-
key: key$5
|
|
7351
|
+
Commands: Commands$t,
|
|
7352
|
+
name: name$t
|
|
6923
7353
|
};
|
|
6924
7354
|
|
|
6925
|
-
const
|
|
6926
|
-
const
|
|
6927
|
-
|
|
7355
|
+
const name$s = 'CreateMessagePort';
|
|
7356
|
+
const Commands$s = {
|
|
7357
|
+
createMessagePort: createMessagePort
|
|
6928
7358
|
};
|
|
6929
|
-
|
|
6930
|
-
|
|
7359
|
+
|
|
7360
|
+
const CreateMessagePort_ipc = {
|
|
7361
|
+
__proto__: null,
|
|
7362
|
+
Commands: Commands$s,
|
|
7363
|
+
name: name$s
|
|
6931
7364
|
};
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
};
|
|
7365
|
+
|
|
7366
|
+
const name$r = 'CreatePidMap';
|
|
7367
|
+
const Commands$r = {
|
|
7368
|
+
createPidMap: createPidMap
|
|
6937
7369
|
};
|
|
6938
7370
|
|
|
6939
|
-
const
|
|
7371
|
+
const CreatePidMap_ipc = {
|
|
6940
7372
|
__proto__: null,
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
handler: handler$4,
|
|
6944
|
-
key: key$4
|
|
7373
|
+
Commands: Commands$r,
|
|
7374
|
+
name: name$r
|
|
6945
7375
|
};
|
|
6946
7376
|
|
|
6947
|
-
const
|
|
6948
|
-
const
|
|
6949
|
-
|
|
7377
|
+
const name$q = 'DesktopCapturer';
|
|
7378
|
+
const Commands$q = {
|
|
7379
|
+
getSources: getSources
|
|
6950
7380
|
};
|
|
6951
|
-
|
|
6952
|
-
|
|
7381
|
+
|
|
7382
|
+
const DesktopCapturer_ipc = {
|
|
7383
|
+
__proto__: null,
|
|
7384
|
+
Commands: Commands$q,
|
|
7385
|
+
name: name$q
|
|
6953
7386
|
};
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
};
|
|
7387
|
+
|
|
7388
|
+
const name$p = 'ElectronApplicationMenu';
|
|
7389
|
+
const Commands$p = {
|
|
7390
|
+
setItems: setItems
|
|
6959
7391
|
};
|
|
6960
7392
|
|
|
6961
|
-
const
|
|
7393
|
+
const ElectronApplicationMenu_ipc = {
|
|
6962
7394
|
__proto__: null,
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
handler: handler$3,
|
|
6966
|
-
key: key$3
|
|
7395
|
+
Commands: Commands$p,
|
|
7396
|
+
name: name$p
|
|
6967
7397
|
};
|
|
6968
7398
|
|
|
6969
|
-
const
|
|
6970
|
-
|
|
6971
|
-
webContents.on(PageTitleUpdated, listener);
|
|
6972
|
-
};
|
|
6973
|
-
const detach$2 = (webContents, listener) => {
|
|
6974
|
-
webContents.off(PageTitleUpdated, listener);
|
|
7399
|
+
const writeText = text => {
|
|
7400
|
+
clipboard.writeText(text);
|
|
6975
7401
|
};
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
};
|
|
7402
|
+
|
|
7403
|
+
const name$o = 'ElectronClipBoard';
|
|
7404
|
+
const Commands$o = {
|
|
7405
|
+
writeText: writeText
|
|
6981
7406
|
};
|
|
6982
7407
|
|
|
6983
|
-
const
|
|
7408
|
+
const ElectronClipBoard_ipc = {
|
|
6984
7409
|
__proto__: null,
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
handler: handler$2,
|
|
6988
|
-
key: key$2
|
|
7410
|
+
Commands: Commands$o,
|
|
7411
|
+
name: name$o
|
|
6989
7412
|
};
|
|
6990
7413
|
|
|
6991
|
-
const
|
|
6992
|
-
const
|
|
6993
|
-
|
|
7414
|
+
const name$n = 'ElectronContentTracing';
|
|
7415
|
+
const Commands$n = {
|
|
7416
|
+
startRecording: startRecording,
|
|
7417
|
+
stopRecording: stopRecording
|
|
6994
7418
|
};
|
|
6995
|
-
|
|
6996
|
-
|
|
7419
|
+
|
|
7420
|
+
const ElectronContentTracing_ipc = {
|
|
7421
|
+
__proto__: null,
|
|
7422
|
+
Commands: Commands$n,
|
|
7423
|
+
name: name$n
|
|
6997
7424
|
};
|
|
6998
|
-
|
|
7425
|
+
|
|
7426
|
+
const withResolvers = () => {
|
|
7427
|
+
/**
|
|
7428
|
+
* @type {any}
|
|
7429
|
+
*/
|
|
7430
|
+
let _resolve;
|
|
7431
|
+
/**
|
|
7432
|
+
* @type {any}
|
|
7433
|
+
*/
|
|
7434
|
+
let _reject;
|
|
7435
|
+
const promise = new Promise((resolve, reject) => {
|
|
7436
|
+
_resolve = resolve;
|
|
7437
|
+
_reject = reject;
|
|
7438
|
+
});
|
|
6999
7439
|
return {
|
|
7000
|
-
|
|
7001
|
-
|
|
7440
|
+
resolve: _resolve,
|
|
7441
|
+
reject: _reject,
|
|
7442
|
+
promise
|
|
7002
7443
|
};
|
|
7003
7444
|
};
|
|
7004
7445
|
|
|
7005
|
-
const
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7446
|
+
const getElectronCallbacks = () => {
|
|
7447
|
+
const {
|
|
7448
|
+
resolve,
|
|
7449
|
+
promise
|
|
7450
|
+
} = withResolvers();
|
|
7451
|
+
const handleClick = menuItem => {
|
|
7452
|
+
resolve({
|
|
7453
|
+
type: 'click',
|
|
7454
|
+
data: menuItem
|
|
7455
|
+
});
|
|
7456
|
+
};
|
|
7457
|
+
const handleClose = () => {
|
|
7458
|
+
resolve({
|
|
7459
|
+
type: 'close',
|
|
7460
|
+
data: undefined
|
|
7461
|
+
});
|
|
7462
|
+
};
|
|
7463
|
+
return {
|
|
7464
|
+
handleClick,
|
|
7465
|
+
handleClose,
|
|
7466
|
+
promise
|
|
7467
|
+
};
|
|
7011
7468
|
};
|
|
7012
7469
|
|
|
7013
|
-
const
|
|
7014
|
-
const
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7470
|
+
const getElectronMenuItems = (menuItems, click) => {
|
|
7471
|
+
const template = [];
|
|
7472
|
+
for (const menuItem of menuItems) {
|
|
7473
|
+
// @ts-ignore
|
|
7474
|
+
template.push({
|
|
7475
|
+
...menuItem,
|
|
7476
|
+
click
|
|
7477
|
+
});
|
|
7478
|
+
}
|
|
7479
|
+
return template;
|
|
7022
7480
|
};
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7481
|
+
|
|
7482
|
+
// @ts-ignore
|
|
7483
|
+
const openContextMenu = async (menuItems, x, y) => {
|
|
7484
|
+
array(menuItems);
|
|
7485
|
+
number(x);
|
|
7486
|
+
number(y);
|
|
7487
|
+
const {
|
|
7488
|
+
promise,
|
|
7489
|
+
handleClick,
|
|
7490
|
+
handleClose
|
|
7491
|
+
} = getElectronCallbacks();
|
|
7492
|
+
const template = getElectronMenuItems(menuItems, handleClick);
|
|
7493
|
+
const menu = Menu.buildFromTemplate(template);
|
|
7494
|
+
const window = BrowserWindow.getFocusedWindow();
|
|
7495
|
+
if (!window) {
|
|
7032
7496
|
return {
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
},
|
|
7036
|
-
messages: []
|
|
7497
|
+
type: 'close',
|
|
7498
|
+
data: undefined
|
|
7037
7499
|
};
|
|
7038
7500
|
}
|
|
7039
|
-
|
|
7501
|
+
menu.popup({
|
|
7502
|
+
window,
|
|
7503
|
+
x,
|
|
7504
|
+
y,
|
|
7505
|
+
callback: handleClose
|
|
7506
|
+
});
|
|
7507
|
+
const event = await promise;
|
|
7508
|
+
// @ts-ignore
|
|
7509
|
+
if (event.type === 'click') {
|
|
7040
7510
|
return {
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
messages: [['handleWindowOpen', url]]
|
|
7511
|
+
type: 'click',
|
|
7512
|
+
// @ts-ignore
|
|
7513
|
+
data: event.data.label
|
|
7045
7514
|
};
|
|
7046
7515
|
}
|
|
7047
|
-
|
|
7516
|
+
// @ts-ignore
|
|
7517
|
+
if (event.type === 'close') {
|
|
7048
7518
|
return {
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
},
|
|
7052
|
-
messages: []
|
|
7519
|
+
type: 'close',
|
|
7520
|
+
data: undefined
|
|
7053
7521
|
};
|
|
7054
7522
|
}
|
|
7055
|
-
info(`[main-process] blocked popup for ${url}`);
|
|
7056
|
-
return {
|
|
7057
|
-
result: {
|
|
7058
|
-
action: Deny
|
|
7059
|
-
},
|
|
7060
|
-
messages: []
|
|
7061
|
-
};
|
|
7062
7523
|
};
|
|
7063
7524
|
|
|
7064
|
-
const
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
detach,
|
|
7068
|
-
handler,
|
|
7069
|
-
key
|
|
7525
|
+
const name$m = 'ElectronContextMenu';
|
|
7526
|
+
const Commands$m = {
|
|
7527
|
+
openContextMenu: openContextMenu
|
|
7070
7528
|
};
|
|
7071
7529
|
|
|
7072
|
-
const
|
|
7530
|
+
const ElectronContextMenu_ipc = {
|
|
7073
7531
|
__proto__: null,
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
destroyed: ElectronBrowserViewEventListenerDestroyed,
|
|
7077
|
-
didNavigate: ElectronBrowserViewEventListenerDidNavigate,
|
|
7078
|
-
pageTitleUpdated: ElectronBrowserViewEventListenerPageTitleUpdated,
|
|
7079
|
-
willNavigate: ElectronBrowserViewEventListenerWillNavigate,
|
|
7080
|
-
windowOpen: ElectronBrowserViewEventListenerWindowOpen
|
|
7532
|
+
Commands: Commands$m,
|
|
7533
|
+
name: name$m
|
|
7081
7534
|
};
|
|
7082
7535
|
|
|
7083
|
-
const
|
|
7084
|
-
const
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
const Get = 'GET';
|
|
7088
|
-
const Head = 'HEAD';
|
|
7089
|
-
const Options = 'OPTIONS';
|
|
7090
|
-
const Post = 'POST';
|
|
7091
|
-
|
|
7092
|
-
// @ts-ignore
|
|
7093
|
-
|
|
7094
|
-
const getBeforeRequestResponseMainFrame = (method, url) => {
|
|
7095
|
-
return {};
|
|
7096
|
-
};
|
|
7097
|
-
const cancelIfStartsWith = (url, canceledUrls) => {
|
|
7098
|
-
for (const canceledUrl of canceledUrls) {
|
|
7099
|
-
if (url.startsWith(canceledUrl)) {
|
|
7100
|
-
return {
|
|
7101
|
-
cancel: true
|
|
7102
|
-
};
|
|
7103
|
-
}
|
|
7104
|
-
}
|
|
7105
|
-
return {};
|
|
7106
|
-
};
|
|
7107
|
-
const getBeforeRequestResponseXhrPost = url => {
|
|
7108
|
-
const canceledUrls = ['https://www.youtube.com/api/stats/qoe', 'https://www.youtube.com/youtubei/v1/log_event', 'https://play.google.com/log'];
|
|
7109
|
-
return cancelIfStartsWith(url, canceledUrls);
|
|
7110
|
-
};
|
|
7111
|
-
const getBeforeRequestResponseXhrGet = url => {
|
|
7112
|
-
const canceledUrls = ['https://www.youtube.com/pagead/', 'https://www.youtube.com/api/stats/qoe', 'https://www.youtube.com/api/stats/ads', 'https://www.youtube.com/api/stats/delayplay', 'https://www.youtube.com/ptracking', 'https://www.youtube.com/api/timedtext', 'https://www.youtube.com/pcs/activeview', 'https://googleads.g.doubleclick.net/pagead/id'];
|
|
7113
|
-
return cancelIfStartsWith(url, canceledUrls);
|
|
7114
|
-
};
|
|
7115
|
-
const getBeforeRequestResponseXhrOptions = url => {
|
|
7116
|
-
const canceledUrls = ['https://play.google.com/log'];
|
|
7117
|
-
return cancelIfStartsWith(url, canceledUrls);
|
|
7118
|
-
};
|
|
7119
|
-
const getBeforeRequestResponseXhrHead = url => {
|
|
7120
|
-
const canceledUrls = ['https://www.youtube.com/generate_204'];
|
|
7121
|
-
return cancelIfStartsWith(url, canceledUrls);
|
|
7122
|
-
};
|
|
7123
|
-
const getBeforeRequestResponseXhr = (method, url) => {
|
|
7124
|
-
switch (method) {
|
|
7125
|
-
case Post:
|
|
7126
|
-
return getBeforeRequestResponseXhrPost(url);
|
|
7127
|
-
case Get:
|
|
7128
|
-
return getBeforeRequestResponseXhrGet(url);
|
|
7129
|
-
case Head:
|
|
7130
|
-
return getBeforeRequestResponseXhrHead(url);
|
|
7131
|
-
case Options:
|
|
7132
|
-
return getBeforeRequestResponseXhrOptions(url);
|
|
7133
|
-
default:
|
|
7134
|
-
return {};
|
|
7135
|
-
}
|
|
7136
|
-
};
|
|
7137
|
-
const getBeforeRequestResponseDefault = (method, url) => {
|
|
7138
|
-
return {};
|
|
7139
|
-
};
|
|
7140
|
-
const getBeforeRequestResponseScript = (method, url) => {
|
|
7141
|
-
const canceledUrls = ['https://static.doubleclick.net'];
|
|
7142
|
-
return cancelIfStartsWith(url, canceledUrls);
|
|
7143
|
-
};
|
|
7144
|
-
const getBeforeRequestResponse = details => {
|
|
7145
|
-
const {
|
|
7146
|
-
method,
|
|
7147
|
-
resourceType,
|
|
7148
|
-
url
|
|
7149
|
-
} = details;
|
|
7150
|
-
switch (resourceType) {
|
|
7151
|
-
case MainFrame:
|
|
7152
|
-
return getBeforeRequestResponseMainFrame();
|
|
7153
|
-
case Script:
|
|
7154
|
-
return getBeforeRequestResponseScript(method, url);
|
|
7155
|
-
case Xhr:
|
|
7156
|
-
return getBeforeRequestResponseXhr(method, url);
|
|
7157
|
-
default:
|
|
7158
|
-
return getBeforeRequestResponseDefault();
|
|
7159
|
-
}
|
|
7536
|
+
const name$l = 'ElectronDeveloper';
|
|
7537
|
+
const Commands$l = {
|
|
7538
|
+
crashMainProcess: crashMainProcess,
|
|
7539
|
+
getPerformanceEntries: getPerformanceEntries
|
|
7160
7540
|
};
|
|
7161
7541
|
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
*/
|
|
7167
|
-
const handleBeforeRequest = (details, callback) => {
|
|
7168
|
-
const response = getBeforeRequestResponse(details);
|
|
7169
|
-
callback(response);
|
|
7542
|
+
const ElectronDeveloper_ipc = {
|
|
7543
|
+
__proto__: null,
|
|
7544
|
+
Commands: Commands$l,
|
|
7545
|
+
name: name$l
|
|
7170
7546
|
};
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7547
|
+
|
|
7548
|
+
const name$k = 'ElectronDialog';
|
|
7549
|
+
const Commands$k = {
|
|
7550
|
+
showMessageBox: showMessageBox,
|
|
7551
|
+
showOpenDialog: showOpenDialog
|
|
7174
7552
|
};
|
|
7175
7553
|
|
|
7176
|
-
const
|
|
7177
|
-
|
|
7554
|
+
const ElectronDialog_ipc = {
|
|
7555
|
+
__proto__: null,
|
|
7556
|
+
Commands: Commands$k,
|
|
7557
|
+
name: name$k
|
|
7178
7558
|
};
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
case WindowPlacement:
|
|
7184
|
-
case FullScreen:
|
|
7185
|
-
case GeoLocation:
|
|
7186
|
-
return true;
|
|
7187
|
-
default:
|
|
7188
|
-
return false;
|
|
7189
|
-
}
|
|
7559
|
+
|
|
7560
|
+
const name$j = 'ElectronNet';
|
|
7561
|
+
const Commands$j = {
|
|
7562
|
+
getJson: getJson
|
|
7190
7563
|
};
|
|
7191
|
-
|
|
7192
|
-
|
|
7564
|
+
|
|
7565
|
+
const ElectronNet_ipc = {
|
|
7566
|
+
__proto__: null,
|
|
7567
|
+
Commands: Commands$j,
|
|
7568
|
+
name: name$j
|
|
7193
7569
|
};
|
|
7194
|
-
|
|
7195
|
-
|
|
7570
|
+
|
|
7571
|
+
const name$i = 'ElectronNetLog';
|
|
7572
|
+
const Commands$i = {
|
|
7573
|
+
startLogging: startLogging,
|
|
7574
|
+
stopLogging: stopLogging
|
|
7196
7575
|
};
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
session.setPermissionRequestHandler(handlePermissionRequest);
|
|
7203
|
-
session.setPermissionCheckHandler(handlePermissionCheck);
|
|
7204
|
-
session.webRequest.onBeforeRequest(filter, handleBeforeRequest);
|
|
7205
|
-
// session.webRequest.addSessionChromeExtensions(session)
|
|
7206
|
-
return session;
|
|
7576
|
+
|
|
7577
|
+
const ElectronNetLog_ipc = {
|
|
7578
|
+
__proto__: null,
|
|
7579
|
+
Commands: Commands$i,
|
|
7580
|
+
name: name$i
|
|
7207
7581
|
};
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7582
|
+
|
|
7583
|
+
const name$h = 'ElectronPowerSaveBlocker';
|
|
7584
|
+
const Commands$h = {
|
|
7585
|
+
start: start,
|
|
7586
|
+
stop: stop
|
|
7211
7587
|
};
|
|
7212
7588
|
|
|
7213
|
-
const
|
|
7214
|
-
|
|
7589
|
+
const ElectronPowerSaveBlocker_ipc = {
|
|
7590
|
+
__proto__: null,
|
|
7591
|
+
Commands: Commands$h,
|
|
7592
|
+
name: name$h
|
|
7215
7593
|
};
|
|
7216
|
-
|
|
7217
|
-
|
|
7594
|
+
|
|
7595
|
+
const name$g = 'ElectronSafeStorage';
|
|
7596
|
+
const Commands$g = {
|
|
7597
|
+
decrypt: decrypt,
|
|
7598
|
+
encrypt: encrypt,
|
|
7599
|
+
isEncryptionAvailable: isEncryptionAvailable
|
|
7218
7600
|
};
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
return;
|
|
7225
|
-
}
|
|
7226
|
-
send$2(ipc, method, ...params);
|
|
7601
|
+
|
|
7602
|
+
const ElectronSafeStorage_ipc = {
|
|
7603
|
+
__proto__: null,
|
|
7604
|
+
Commands: Commands$g,
|
|
7605
|
+
name: name$g
|
|
7227
7606
|
};
|
|
7228
7607
|
|
|
7229
|
-
|
|
7230
|
-
const
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
});
|
|
7236
|
-
// TODO get browser window id from renderer worker
|
|
7237
|
-
const browserWindow = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
|
|
7238
|
-
const {
|
|
7239
|
-
webContents
|
|
7240
|
-
} = view;
|
|
7241
|
-
const {
|
|
7242
|
-
id
|
|
7243
|
-
} = webContents;
|
|
7244
|
-
add$1(id, browserWindow, view);
|
|
7245
|
-
return id;
|
|
7608
|
+
const name$f = 'ElectronShell';
|
|
7609
|
+
const Commands$f = {
|
|
7610
|
+
beep: beep$1,
|
|
7611
|
+
openExternal: openExternal,
|
|
7612
|
+
openPath: showItemInFolder,
|
|
7613
|
+
showItemInFolder: showItemInFolder
|
|
7246
7614
|
};
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
}
|
|
7253
|
-
const values = Object.values(ElectronBrowserViewEventListeners);
|
|
7254
|
-
for (const value of values) {
|
|
7255
|
-
const wrappedListener = (...args) => {
|
|
7256
|
-
// @ts-ignore
|
|
7257
|
-
const {
|
|
7258
|
-
result,
|
|
7259
|
-
messages
|
|
7260
|
-
} = value.handler(...args);
|
|
7261
|
-
for (const message of messages) {
|
|
7262
|
-
const [key, ...rest] = message;
|
|
7263
|
-
send(`ElectronWebContents.${key}`, webContentsId, ...rest);
|
|
7264
|
-
}
|
|
7265
|
-
return result;
|
|
7266
|
-
};
|
|
7267
|
-
// TODO detached listeners when webcontents are disposed
|
|
7268
|
-
// to avoid potential memory leaks
|
|
7269
|
-
value.attach(webContents, wrappedListener);
|
|
7270
|
-
}
|
|
7615
|
+
|
|
7616
|
+
const ElectronShell_ipc = {
|
|
7617
|
+
__proto__: null,
|
|
7618
|
+
Commands: Commands$f,
|
|
7619
|
+
name: name$f
|
|
7271
7620
|
};
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
view,
|
|
7280
|
-
browserWindow
|
|
7281
|
-
} = instance;
|
|
7282
|
-
remove$1(browserViewId);
|
|
7283
|
-
browserWindow.contentView.removeChildView(view);
|
|
7621
|
+
|
|
7622
|
+
const name$e = 'ElectronWindow';
|
|
7623
|
+
const Commands$e = {
|
|
7624
|
+
executeWindowFunction: executeWindowFunction,
|
|
7625
|
+
executeWebContentsFunction: executeWebContentsFunction,
|
|
7626
|
+
getFocusedWindowId: getFocusedWindowId,
|
|
7627
|
+
getZoom: getZoom
|
|
7284
7628
|
};
|
|
7285
7629
|
|
|
7286
|
-
const
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
disposeWebContentsView: disposeWebContentsView
|
|
7630
|
+
const ElectronWindow_ipc = {
|
|
7631
|
+
__proto__: null,
|
|
7632
|
+
Commands: Commands$e,
|
|
7633
|
+
name: name$e
|
|
7291
7634
|
};
|
|
7292
7635
|
|
|
7293
|
-
const
|
|
7636
|
+
const name$d = 'ElectronWindowProcessExplorer';
|
|
7637
|
+
const Commands$d = {
|
|
7638
|
+
open2: open2
|
|
7639
|
+
};
|
|
7640
|
+
|
|
7641
|
+
const ElectronWindowProcessExplorer_ipc = {
|
|
7294
7642
|
__proto__: null,
|
|
7295
|
-
Commands: Commands$
|
|
7296
|
-
name: name$
|
|
7643
|
+
Commands: Commands$d,
|
|
7644
|
+
name: name$d
|
|
7297
7645
|
};
|
|
7298
7646
|
|
|
7299
|
-
const
|
|
7647
|
+
const name$c = 'IpcParent';
|
|
7648
|
+
const Commands$c = {
|
|
7649
|
+
create: create$2
|
|
7650
|
+
};
|
|
7300
7651
|
|
|
7301
|
-
|
|
7652
|
+
const IpcParent_ipc = {
|
|
7653
|
+
__proto__: null,
|
|
7654
|
+
Commands: Commands$c,
|
|
7655
|
+
name: name$c
|
|
7656
|
+
};
|
|
7302
7657
|
|
|
7303
|
-
const
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
if (!state) {
|
|
7307
|
-
console.log(`[main process] no browser view with id ${id}`);
|
|
7308
|
-
return;
|
|
7309
|
-
}
|
|
7310
|
-
const {
|
|
7311
|
-
view
|
|
7312
|
-
} = state;
|
|
7313
|
-
return fn(view, ...args);
|
|
7314
|
-
};
|
|
7315
|
-
return wrappedCommand;
|
|
7658
|
+
const name$b = 'OpenExternal';
|
|
7659
|
+
const Commands$b = {
|
|
7660
|
+
openExternal: openExternal
|
|
7316
7661
|
};
|
|
7317
7662
|
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
* @param {number} y
|
|
7323
|
-
* @param {number} width
|
|
7324
|
-
* @param {number} height
|
|
7325
|
-
*/
|
|
7326
|
-
const resizeBrowserView = (view, x, y, width, height) => {
|
|
7327
|
-
object(view);
|
|
7328
|
-
number(x);
|
|
7329
|
-
number(y);
|
|
7330
|
-
number(width);
|
|
7331
|
-
number(height);
|
|
7332
|
-
view.setBounds({
|
|
7333
|
-
x,
|
|
7334
|
-
y,
|
|
7335
|
-
width,
|
|
7336
|
-
height
|
|
7337
|
-
});
|
|
7663
|
+
const OpenExternal_ipc = {
|
|
7664
|
+
__proto__: null,
|
|
7665
|
+
Commands: Commands$b,
|
|
7666
|
+
name: name$b
|
|
7338
7667
|
};
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7668
|
+
|
|
7669
|
+
const name$a = 'Process';
|
|
7670
|
+
const Commands$a = {
|
|
7671
|
+
getArgv: getArgv,
|
|
7672
|
+
getChromeVersion: getChromeVersion,
|
|
7673
|
+
getElectronVersion: getElectronVersion,
|
|
7674
|
+
getNodeVersion: getNodeVersion,
|
|
7675
|
+
getPid: getPid,
|
|
7676
|
+
getV8Version: getV8Version
|
|
7346
7677
|
};
|
|
7347
7678
|
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
*/
|
|
7353
|
-
const setIframeSrc = async (view, iframeSrc) => {
|
|
7354
|
-
try {
|
|
7355
|
-
object(view);
|
|
7356
|
-
string(iframeSrc);
|
|
7357
|
-
const {
|
|
7358
|
-
webContents
|
|
7359
|
-
} = view;
|
|
7360
|
-
await webContents.loadURL(iframeSrc);
|
|
7361
|
-
} catch (error) {
|
|
7362
|
-
const betterError = new VError(error, `Failed to set iframe src`);
|
|
7363
|
-
// @ts-ignore
|
|
7364
|
-
betterError.dontPrint = true;
|
|
7365
|
-
throw betterError;
|
|
7366
|
-
}
|
|
7679
|
+
const Process_ipc = {
|
|
7680
|
+
__proto__: null,
|
|
7681
|
+
Commands: Commands$a,
|
|
7682
|
+
name: name$a
|
|
7367
7683
|
};
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
const focus = view => {
|
|
7373
|
-
const {
|
|
7374
|
-
webContents
|
|
7375
|
-
} = view;
|
|
7376
|
-
webContents.focus();
|
|
7684
|
+
|
|
7685
|
+
const name$9 = 'Exit';
|
|
7686
|
+
const Commands$9 = {
|
|
7687
|
+
exit: exit
|
|
7377
7688
|
};
|
|
7378
7689
|
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
const openDevtools = view => {
|
|
7384
|
-
const {
|
|
7385
|
-
webContents
|
|
7386
|
-
} = view;
|
|
7387
|
-
// TODO return promise that resolves once devtools are actually open
|
|
7388
|
-
webContents.openDevTools();
|
|
7690
|
+
const Exit_ipc = {
|
|
7691
|
+
__proto__: null,
|
|
7692
|
+
Commands: Commands$9,
|
|
7693
|
+
name: name$9
|
|
7389
7694
|
};
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
webContents
|
|
7397
|
-
} = view;
|
|
7398
|
-
webContents.reload();
|
|
7695
|
+
|
|
7696
|
+
const name$8 = 'ElectronScreen';
|
|
7697
|
+
const Commands$8 = {
|
|
7698
|
+
getBounds: getBounds,
|
|
7699
|
+
getWidth: getWidth,
|
|
7700
|
+
getHeight: getHeight
|
|
7399
7701
|
};
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
const {
|
|
7406
|
-
webContents
|
|
7407
|
-
} = view;
|
|
7408
|
-
webContents.goForward();
|
|
7702
|
+
|
|
7703
|
+
const ElectronScreen_ipc = {
|
|
7704
|
+
__proto__: null,
|
|
7705
|
+
Commands: Commands$8,
|
|
7706
|
+
name: name$8
|
|
7409
7707
|
};
|
|
7410
7708
|
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7709
|
+
const name$7 = 'TemporaryMessagePort';
|
|
7710
|
+
const Commands$7 = {
|
|
7711
|
+
createPortTuple: createPortTuple,
|
|
7712
|
+
dispose: dispose$1,
|
|
7713
|
+
sendTo: sendTo
|
|
7714
|
+
};
|
|
7715
|
+
|
|
7716
|
+
const TemporaryMessagePort_ipc = {
|
|
7717
|
+
__proto__: null,
|
|
7718
|
+
Commands: Commands$7,
|
|
7719
|
+
name: name$7
|
|
7421
7720
|
};
|
|
7422
7721
|
|
|
7423
7722
|
/**
|
|
7424
7723
|
*
|
|
7425
|
-
* @param {Electron.
|
|
7724
|
+
* @param {Electron.WebContents} webContents
|
|
7426
7725
|
*/
|
|
7427
|
-
const
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
webContents.
|
|
7726
|
+
const disposeWebContents = webContents => {
|
|
7727
|
+
if (webContents.close) {
|
|
7728
|
+
// electron v22
|
|
7729
|
+
webContents.close();
|
|
7730
|
+
// @ts-ignore
|
|
7731
|
+
} else if (webContents.destroy) {
|
|
7732
|
+
// older versions of electron
|
|
7733
|
+
// @ts-ignore
|
|
7734
|
+
webContents.destroy();
|
|
7436
7735
|
}
|
|
7437
7736
|
};
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
return;
|
|
7737
|
+
|
|
7738
|
+
const getStats = webContentsId => {
|
|
7739
|
+
number(webContentsId);
|
|
7740
|
+
const contents = webContents.fromId(webContentsId);
|
|
7741
|
+
if (!contents) {
|
|
7742
|
+
return undefined;
|
|
7444
7743
|
}
|
|
7445
|
-
const
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7744
|
+
const canGoBack = contents.navigationHistory.canGoBack();
|
|
7745
|
+
const canGoForward = contents.navigationHistory.canGoForward();
|
|
7746
|
+
const url = contents.getURL();
|
|
7747
|
+
const title = contents.getTitle();
|
|
7748
|
+
return {
|
|
7749
|
+
canGoBack,
|
|
7750
|
+
canGoForward,
|
|
7751
|
+
url,
|
|
7752
|
+
title
|
|
7753
|
+
};
|
|
7450
7754
|
};
|
|
7451
|
-
const
|
|
7452
|
-
|
|
7453
|
-
const
|
|
7454
|
-
|
|
7455
|
-
} = state;
|
|
7456
|
-
const browserWindow = BrowserWindow.fromId(browserWindowId);
|
|
7457
|
-
if (!browserWindow) {
|
|
7755
|
+
const dispose = webContentsId => {
|
|
7756
|
+
number(webContentsId);
|
|
7757
|
+
const contents = webContents.fromId(webContentsId);
|
|
7758
|
+
if (!contents) {
|
|
7458
7759
|
return;
|
|
7459
7760
|
}
|
|
7460
|
-
|
|
7761
|
+
disposeWebContents(contents);
|
|
7461
7762
|
};
|
|
7462
|
-
const
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7763
|
+
const callFunction = (webContentsId, functionName, ...args) => {
|
|
7764
|
+
number(webContentsId);
|
|
7765
|
+
string(functionName);
|
|
7766
|
+
const contents = webContents.fromId(webContentsId);
|
|
7767
|
+
if (!contents) {
|
|
7466
7768
|
return;
|
|
7467
7769
|
}
|
|
7468
|
-
|
|
7469
|
-
view,
|
|
7470
|
-
browserWindow
|
|
7471
|
-
} = state;
|
|
7472
|
-
browserWindow.contentView.removeChildView(view);
|
|
7770
|
+
contents[functionName](...args);
|
|
7473
7771
|
};
|
|
7474
7772
|
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
*/
|
|
7481
|
-
const inspectElement = (view, x, y) => {
|
|
7482
|
-
number(x);
|
|
7483
|
-
number(y);
|
|
7484
|
-
const {
|
|
7485
|
-
webContents
|
|
7486
|
-
} = view;
|
|
7487
|
-
webContents.inspectElement(x, y);
|
|
7773
|
+
const name$6 = 'ElectronWebContents';
|
|
7774
|
+
const Commands$6 = {
|
|
7775
|
+
dispose: dispose,
|
|
7776
|
+
getStats: getStats,
|
|
7777
|
+
callFunction: callFunction
|
|
7488
7778
|
};
|
|
7489
7779
|
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
*/
|
|
7495
|
-
const setBackgroundColor = (view, backgroundColor) => {
|
|
7496
|
-
view.setBackgroundColor(backgroundColor);
|
|
7780
|
+
const ElectronWebContents_ipc = {
|
|
7781
|
+
__proto__: null,
|
|
7782
|
+
Commands: Commands$6,
|
|
7783
|
+
name: name$6
|
|
7497
7784
|
};
|
|
7498
7785
|
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
*/
|
|
7505
|
-
const copyImageAt = (view, x, y) => {
|
|
7506
|
-
number(x);
|
|
7507
|
-
number(y);
|
|
7508
|
-
const {
|
|
7509
|
-
webContents
|
|
7510
|
-
} = view;
|
|
7511
|
-
webContents.copyImageAt(x, y);
|
|
7512
|
-
};
|
|
7513
|
-
const setFallThroughKeyBindings = fallthroughKeyBindings => {
|
|
7514
|
-
setFallthroughKeyBindings(fallthroughKeyBindings);
|
|
7786
|
+
const name$5 = 'ElectronWebContentsView';
|
|
7787
|
+
const Commands$5 = {
|
|
7788
|
+
createWebContentsView: createWebContentsView,
|
|
7789
|
+
attachEventListeners: attachEventListeners,
|
|
7790
|
+
disposeWebContentsView: disposeWebContentsView
|
|
7515
7791
|
};
|
|
7516
7792
|
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
*/
|
|
7522
|
-
const getStats = view => {
|
|
7523
|
-
const {
|
|
7524
|
-
webContents
|
|
7525
|
-
} = view;
|
|
7526
|
-
const canGoBack = webContents.canGoBack();
|
|
7527
|
-
const canGoForward = webContents.canGoForward();
|
|
7528
|
-
const url = webContents.getURL();
|
|
7529
|
-
const title = webContents.getTitle();
|
|
7530
|
-
return {
|
|
7531
|
-
canGoBack,
|
|
7532
|
-
canGoForward,
|
|
7533
|
-
url,
|
|
7534
|
-
title
|
|
7535
|
-
};
|
|
7793
|
+
const ElectronWebContentsView_ipc = {
|
|
7794
|
+
__proto__: null,
|
|
7795
|
+
Commands: Commands$5,
|
|
7796
|
+
name: name$5
|
|
7536
7797
|
};
|
|
7537
7798
|
|
|
7538
7799
|
const name$4 = 'ElectronWebContentsViewFunctions';
|
|
@@ -7543,7 +7804,7 @@ const Commands$4 = {
|
|
|
7543
7804
|
copyImageAt: wrapBrowserViewCommand(copyImageAt),
|
|
7544
7805
|
focus: wrapBrowserViewCommand(focus),
|
|
7545
7806
|
forward: wrapBrowserViewCommand(forward),
|
|
7546
|
-
getStats: wrapBrowserViewCommand(getStats),
|
|
7807
|
+
getStats: wrapBrowserViewCommand(getStats$1),
|
|
7547
7808
|
hide: hide,
|
|
7548
7809
|
inspectElement: wrapBrowserViewCommand(inspectElement),
|
|
7549
7810
|
openDevtools: wrapBrowserViewCommand(openDevtools),
|
|
@@ -7562,18 +7823,6 @@ const ElectronWebContentsViewFunctions_ipc = {
|
|
|
7562
7823
|
name: name$4
|
|
7563
7824
|
};
|
|
7564
7825
|
|
|
7565
|
-
const handleElectronMessagePort = async (messagePort, ipcId) => {
|
|
7566
|
-
object(messagePort);
|
|
7567
|
-
const ipc = await listen({
|
|
7568
|
-
method: ElectronMessagePort$1,
|
|
7569
|
-
messagePort
|
|
7570
|
-
});
|
|
7571
|
-
handleIpc(ipc);
|
|
7572
|
-
if (ipcId === EmbedsProcess) {
|
|
7573
|
-
set(ipc);
|
|
7574
|
-
}
|
|
7575
|
-
};
|
|
7576
|
-
|
|
7577
7826
|
const name$3 = 'HandleElectronMessagePort';
|
|
7578
7827
|
const Commands$3 = {
|
|
7579
7828
|
handleElectronMessagePort: handleElectronMessagePort
|
|
@@ -7585,19 +7834,6 @@ const HandleElectronMessagePort_ipc = {
|
|
|
7585
7834
|
name: name$3
|
|
7586
7835
|
};
|
|
7587
7836
|
|
|
7588
|
-
const getWindowId = webContentsId => {
|
|
7589
|
-
number(webContentsId);
|
|
7590
|
-
const webContents = Electron.webContents.fromId(webContentsId);
|
|
7591
|
-
if (!webContents) {
|
|
7592
|
-
return -1;
|
|
7593
|
-
}
|
|
7594
|
-
const browserWindow = Electron.BrowserWindow.fromWebContents(webContents);
|
|
7595
|
-
if (!browserWindow) {
|
|
7596
|
-
return -1;
|
|
7597
|
-
}
|
|
7598
|
-
return browserWindow.id;
|
|
7599
|
-
};
|
|
7600
|
-
|
|
7601
7837
|
const name$2 = 'GetWindowId';
|
|
7602
7838
|
const Commands$2 = {
|
|
7603
7839
|
getWindowId: getWindowId
|
|
@@ -7620,11 +7856,6 @@ const ElectronSession_ipc = {
|
|
|
7620
7856
|
name: name$1
|
|
7621
7857
|
};
|
|
7622
7858
|
|
|
7623
|
-
const trash = async path => {
|
|
7624
|
-
string(path);
|
|
7625
|
-
await shell.trashItem(path);
|
|
7626
|
-
};
|
|
7627
|
-
|
|
7628
7859
|
const name = 'Trash';
|
|
7629
7860
|
const Commands = {
|
|
7630
7861
|
trash: trash
|
|
@@ -7635,51 +7866,3 @@ const Trash_ipc = {
|
|
|
7635
7866
|
Commands,
|
|
7636
7867
|
name
|
|
7637
7868
|
};
|
|
7638
|
-
|
|
7639
|
-
const transferMessagePort = async (ipc, port, ...params) => {
|
|
7640
|
-
try {
|
|
7641
|
-
await invokeAndTransfer$1(ipc, 'HandleNodeMessagePort.handleNodeMessagePort', port, ...params);
|
|
7642
|
-
} catch (error) {
|
|
7643
|
-
throw new VError(error, `Failed to send message port to worker thread`);
|
|
7644
|
-
}
|
|
7645
|
-
};
|
|
7646
|
-
|
|
7647
|
-
const connectIpc$1 = async (ipc, browserWindowPort, ...params) => {
|
|
7648
|
-
const messageChannel = new MessageChannel();
|
|
7649
|
-
const {
|
|
7650
|
-
port1,
|
|
7651
|
-
port2
|
|
7652
|
-
} = messageChannel;
|
|
7653
|
-
browserWindowPort.on('message', event => {
|
|
7654
|
-
// console.log('got message from browser window', event.data)
|
|
7655
|
-
port2.postMessage(event.data);
|
|
7656
|
-
});
|
|
7657
|
-
port2.on('message', message => {
|
|
7658
|
-
// console.log('send message to browser window', message)
|
|
7659
|
-
browserWindowPort.postMessage(message);
|
|
7660
|
-
});
|
|
7661
|
-
await transferMessagePort(ipc, port1, ...params);
|
|
7662
|
-
browserWindowPort.start();
|
|
7663
|
-
};
|
|
7664
|
-
|
|
7665
|
-
const ConnectIpcNodeWorker = {
|
|
7666
|
-
__proto__: null,
|
|
7667
|
-
connectIpc: connectIpc$1
|
|
7668
|
-
};
|
|
7669
|
-
|
|
7670
|
-
const transferMessagePortMain = async (ipc, port, ...params) => {
|
|
7671
|
-
try {
|
|
7672
|
-
await invokeAndTransfer$1(ipc, 'HandleElectronMessagePort.handleElectronMessagePort', port, ...params);
|
|
7673
|
-
} catch (error) {
|
|
7674
|
-
throw new VError(error, `Failed to send message port to utility process`);
|
|
7675
|
-
}
|
|
7676
|
-
};
|
|
7677
|
-
|
|
7678
|
-
const connectIpc = async (ipc, browserWindowPort, ...params) => {
|
|
7679
|
-
await transferMessagePortMain(ipc, browserWindowPort, ...params);
|
|
7680
|
-
};
|
|
7681
|
-
|
|
7682
|
-
const ConnectIpcElectronUtilityProcess = {
|
|
7683
|
-
__proto__: null,
|
|
7684
|
-
connectIpc
|
|
7685
|
-
};
|