@lvce-editor/main-process 2.4.0 → 2.6.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 +236 -295
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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, webContents, WebContentsView } 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
6
|
import { MessageChannel } from 'node:worker_threads';
|
|
7
7
|
import { createWriteStream, readFileSync } from 'node:fs';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
8
9
|
import * as NodePath from 'node:path';
|
|
9
10
|
import { dirname } from 'node:path';
|
|
10
11
|
import require$$1 from 'tty';
|
|
@@ -12,7 +13,6 @@ import require$$1$1 from 'util';
|
|
|
12
13
|
import require$$0 from 'os';
|
|
13
14
|
import { Console } from 'node:console';
|
|
14
15
|
import { tmpdir, homedir } from 'node:os';
|
|
15
|
-
import { fileURLToPath } from 'node:url';
|
|
16
16
|
|
|
17
17
|
function escapeStringRegexp(string) {
|
|
18
18
|
if (typeof string !== 'string') {
|
|
@@ -757,7 +757,7 @@ const getNewLineIndex$2 = (string, startIndex = undefined) => {
|
|
|
757
757
|
|
|
758
758
|
// TODO disable logging via environment variable, don't enable logging during tests
|
|
759
759
|
|
|
760
|
-
const state$
|
|
760
|
+
const state$7 = {
|
|
761
761
|
console: undefined
|
|
762
762
|
};
|
|
763
763
|
const createConsole = () => {
|
|
@@ -767,8 +767,8 @@ const createConsole = () => {
|
|
|
767
767
|
return logger;
|
|
768
768
|
};
|
|
769
769
|
const getOrCreateLogger = () => {
|
|
770
|
-
state$
|
|
771
|
-
return state$
|
|
770
|
+
state$7.console ||= createConsole();
|
|
771
|
+
return state$7.console;
|
|
772
772
|
};
|
|
773
773
|
const info = (...args) => {
|
|
774
774
|
const logger = getOrCreateLogger();
|
|
@@ -2707,7 +2707,7 @@ const create$4 = (method, params) => {
|
|
|
2707
2707
|
};
|
|
2708
2708
|
};
|
|
2709
2709
|
const callbacks = Object.create(null);
|
|
2710
|
-
const set$
|
|
2710
|
+
const set$1 = (id, fn) => {
|
|
2711
2711
|
callbacks[id] = fn;
|
|
2712
2712
|
};
|
|
2713
2713
|
const get$4 = id => {
|
|
@@ -2726,7 +2726,7 @@ const registerPromise = () => {
|
|
|
2726
2726
|
resolve,
|
|
2727
2727
|
promise
|
|
2728
2728
|
} = Promise.withResolvers();
|
|
2729
|
-
set$
|
|
2729
|
+
set$1(id, resolve);
|
|
2730
2730
|
return {
|
|
2731
2731
|
id,
|
|
2732
2732
|
promise
|
|
@@ -3337,7 +3337,7 @@ const launchSharedProcess = async ({
|
|
|
3337
3337
|
return sharedProcessRpc;
|
|
3338
3338
|
};
|
|
3339
3339
|
|
|
3340
|
-
const state$
|
|
3340
|
+
const state$6 = {
|
|
3341
3341
|
/**
|
|
3342
3342
|
* @type {any}
|
|
3343
3343
|
*/
|
|
@@ -3348,14 +3348,14 @@ const getOrCreate = async ({
|
|
|
3348
3348
|
method,
|
|
3349
3349
|
env = {}
|
|
3350
3350
|
}) => {
|
|
3351
|
-
if (!state$
|
|
3351
|
+
if (!state$6.promise) {
|
|
3352
3352
|
// @ts-ignore
|
|
3353
|
-
state$
|
|
3353
|
+
state$6.promise = launchSharedProcess({
|
|
3354
3354
|
method,
|
|
3355
3355
|
env
|
|
3356
3356
|
});
|
|
3357
3357
|
}
|
|
3358
|
-
return state$
|
|
3358
|
+
return state$6.promise;
|
|
3359
3359
|
};
|
|
3360
3360
|
const send$1 = async (method, ...params) => {
|
|
3361
3361
|
const rpc = await getOrCreate({
|
|
@@ -4478,14 +4478,14 @@ const createTitleBar = items => {
|
|
|
4478
4478
|
|
|
4479
4479
|
const PHASE_DEFAULT = 0;
|
|
4480
4480
|
const PHASE_SHUTDOWN = -1;
|
|
4481
|
-
const state$
|
|
4481
|
+
const state$5 = {
|
|
4482
4482
|
phase: PHASE_DEFAULT
|
|
4483
4483
|
};
|
|
4484
4484
|
const isShutDown = () => {
|
|
4485
|
-
return state$
|
|
4485
|
+
return state$5.phase === PHASE_SHUTDOWN;
|
|
4486
4486
|
};
|
|
4487
4487
|
const setShutDown = () => {
|
|
4488
|
-
state$
|
|
4488
|
+
state$5.phase = PHASE_SHUTDOWN;
|
|
4489
4489
|
};
|
|
4490
4490
|
|
|
4491
4491
|
// TODO move this function to shared process
|
|
@@ -4782,21 +4782,21 @@ const BeforeInputEvent = 'before-input-event';
|
|
|
4782
4782
|
const Allow = 'allow';
|
|
4783
4783
|
const Deny = 'deny';
|
|
4784
4784
|
|
|
4785
|
-
const state$
|
|
4785
|
+
const state$4 = {
|
|
4786
4786
|
views: Object.create(null),
|
|
4787
4787
|
fallThroughKeyBindings: [],
|
|
4788
4788
|
canceled: Object.create(null)
|
|
4789
4789
|
};
|
|
4790
4790
|
const add$1 = (id, browserWindow, view) => {
|
|
4791
4791
|
// state
|
|
4792
|
-
state$
|
|
4792
|
+
state$4.views[id] = {
|
|
4793
4793
|
browserWindow,
|
|
4794
4794
|
view
|
|
4795
4795
|
};
|
|
4796
4796
|
};
|
|
4797
4797
|
const hasWebContents = id => {
|
|
4798
4798
|
number(id);
|
|
4799
|
-
return id in state$
|
|
4799
|
+
return id in state$4.views;
|
|
4800
4800
|
};
|
|
4801
4801
|
/**
|
|
4802
4802
|
*
|
|
@@ -4804,19 +4804,19 @@ const hasWebContents = id => {
|
|
|
4804
4804
|
* @returns {{browserWindow: Electron.BrowserWindow, view: Electron.WebContentsView}}
|
|
4805
4805
|
*/
|
|
4806
4806
|
const get$3 = id => {
|
|
4807
|
-
return state$
|
|
4807
|
+
return state$4.views[id];
|
|
4808
4808
|
};
|
|
4809
4809
|
const remove$1 = id => {
|
|
4810
|
-
delete state$
|
|
4810
|
+
delete state$4.views[id];
|
|
4811
4811
|
};
|
|
4812
4812
|
const setFallthroughKeyBindings = fallthroughKeyBindings => {
|
|
4813
|
-
state$
|
|
4813
|
+
state$4.fallThroughKeyBindings = fallthroughKeyBindings;
|
|
4814
4814
|
};
|
|
4815
4815
|
const getFallthroughKeyBindings = () => {
|
|
4816
|
-
return state$
|
|
4816
|
+
return state$4.fallThroughKeyBindings;
|
|
4817
4817
|
};
|
|
4818
4818
|
const setCanceled = id => {
|
|
4819
|
-
state$
|
|
4819
|
+
state$4.canceled[id] = true;
|
|
4820
4820
|
};
|
|
4821
4821
|
|
|
4822
4822
|
const shouldAllowNavigation = webContentsId => {
|
|
@@ -4829,6 +4829,7 @@ const shouldAllowNavigation = webContentsId => {
|
|
|
4829
4829
|
const handleWebContentsWindowOpen = ({
|
|
4830
4830
|
url
|
|
4831
4831
|
}) => {
|
|
4832
|
+
// @ts-ignore
|
|
4832
4833
|
void undefined(url);
|
|
4833
4834
|
return {
|
|
4834
4835
|
action: Deny
|
|
@@ -4891,13 +4892,6 @@ const privilegedSchems = [{
|
|
|
4891
4892
|
}
|
|
4892
4893
|
}];
|
|
4893
4894
|
|
|
4894
|
-
/**
|
|
4895
|
-
*
|
|
4896
|
-
* @param {Electron.Protocol} protocol
|
|
4897
|
-
* @param {string} name
|
|
4898
|
-
* @param {(request: GlobalRequest) => Promise<GlobalResponse>} handleRequest
|
|
4899
|
-
* @returns
|
|
4900
|
-
*/
|
|
4901
4895
|
const handle = (protocol, name, handleRequest) => {
|
|
4902
4896
|
if (isProtocolHandleApiSupported(protocol)) {
|
|
4903
4897
|
protocol.handle(name, handleRequest);
|
|
@@ -4905,12 +4899,6 @@ const handle = (protocol, name, handleRequest) => {
|
|
|
4905
4899
|
}
|
|
4906
4900
|
throw new Error('protocol.handle api is not supported');
|
|
4907
4901
|
};
|
|
4908
|
-
|
|
4909
|
-
/**
|
|
4910
|
-
*
|
|
4911
|
-
* @param {Electron.Protocol} protocol
|
|
4912
|
-
* @returns
|
|
4913
|
-
*/
|
|
4914
4902
|
const enable = protocol => {
|
|
4915
4903
|
protocol.registerSchemesAsPrivileged(privilegedSchems);
|
|
4916
4904
|
};
|
|
@@ -5123,7 +5111,7 @@ const getModuleId = commandId => {
|
|
|
5123
5111
|
}
|
|
5124
5112
|
};
|
|
5125
5113
|
|
|
5126
|
-
const state$
|
|
5114
|
+
const state$3 = {
|
|
5127
5115
|
commands: Object.create(null),
|
|
5128
5116
|
pendingModules: Object.create(null),
|
|
5129
5117
|
async load(moduleId) {}
|
|
@@ -5143,21 +5131,21 @@ const initializeModule = module => {
|
|
|
5143
5131
|
throw new Error(`module ${module.name || '<unnamed module>'} is missing commands`);
|
|
5144
5132
|
};
|
|
5145
5133
|
const getOrLoadModule = moduleId => {
|
|
5146
|
-
if (!state$
|
|
5147
|
-
const importPromise = state$
|
|
5148
|
-
state$
|
|
5134
|
+
if (!state$3.pendingModules[moduleId]) {
|
|
5135
|
+
const importPromise = state$3.load(moduleId);
|
|
5136
|
+
state$3.pendingModules[moduleId] = importPromise.then(initializeModule);
|
|
5149
5137
|
}
|
|
5150
|
-
return state$
|
|
5138
|
+
return state$3.pendingModules[moduleId];
|
|
5151
5139
|
};
|
|
5152
5140
|
const loadCommand = command => getOrLoadModule(getModuleId(command));
|
|
5153
5141
|
const register = (commandId, listener) => {
|
|
5154
|
-
state$
|
|
5142
|
+
state$3.commands[commandId] = listener;
|
|
5155
5143
|
};
|
|
5156
5144
|
const hasThrown = new Set();
|
|
5157
5145
|
const loadThenExecute = async (command, ...args) => {
|
|
5158
5146
|
await loadCommand(command);
|
|
5159
5147
|
// TODO can skip then block in prod (only to prevent endless loop in dev)
|
|
5160
|
-
if (!(command in state$
|
|
5148
|
+
if (!(command in state$3.commands)) {
|
|
5161
5149
|
if (hasThrown.has(command)) {
|
|
5162
5150
|
return;
|
|
5163
5151
|
}
|
|
@@ -5167,13 +5155,13 @@ const loadThenExecute = async (command, ...args) => {
|
|
|
5167
5155
|
return execute(command, ...args);
|
|
5168
5156
|
};
|
|
5169
5157
|
const execute = (command, ...args) => {
|
|
5170
|
-
if (command in state$
|
|
5171
|
-
return state$
|
|
5158
|
+
if (command in state$3.commands) {
|
|
5159
|
+
return state$3.commands[command](...args);
|
|
5172
5160
|
}
|
|
5173
5161
|
return loadThenExecute(command, ...args);
|
|
5174
5162
|
};
|
|
5175
5163
|
const setLoad = load => {
|
|
5176
|
-
state$
|
|
5164
|
+
state$3.load = load;
|
|
5177
5165
|
};
|
|
5178
5166
|
|
|
5179
5167
|
const ClipBoardRead = 'clipboard-read';
|
|
@@ -5265,110 +5253,32 @@ const createElectronSession = () => {
|
|
|
5265
5253
|
return session;
|
|
5266
5254
|
};
|
|
5267
5255
|
|
|
5268
|
-
const state$
|
|
5256
|
+
const state$2 = {
|
|
5269
5257
|
session: undefined
|
|
5270
5258
|
};
|
|
5271
5259
|
const has = () => {
|
|
5272
|
-
return Boolean(state$
|
|
5260
|
+
return Boolean(state$2.session);
|
|
5273
5261
|
};
|
|
5274
5262
|
const get$2 = () => {
|
|
5275
|
-
if (!state$
|
|
5263
|
+
if (!state$2.session) {
|
|
5276
5264
|
throw new Error('session is not defined');
|
|
5277
5265
|
}
|
|
5278
|
-
return state$
|
|
5279
|
-
};
|
|
5280
|
-
const set$1 = value => {
|
|
5281
|
-
state$3.session = value;
|
|
5282
|
-
};
|
|
5283
|
-
|
|
5284
|
-
const printPrettyError = (prettyError, prefix = '') => {
|
|
5285
|
-
error(`${prefix}${prettyError.type}: ${prettyError.message}\n\n${prettyError.codeFrame}\n\n${prettyError.stack}\n`);
|
|
5286
|
-
};
|
|
5287
|
-
|
|
5288
|
-
const logError = (error, prettyError) => {
|
|
5289
|
-
printPrettyError(prettyError, '[main-process] ');
|
|
5290
|
-
};
|
|
5291
|
-
const handleMessage = event => {
|
|
5292
|
-
return handleJsonRpcMessage(event.target, event.data, execute, resolve, prepare,
|
|
5293
|
-
// @ts-ignore
|
|
5294
|
-
logError, requiresSocket);
|
|
5295
|
-
};
|
|
5296
|
-
|
|
5297
|
-
const handleIpc = ipc => {
|
|
5298
|
-
if ('addEventListener' in ipc) {
|
|
5299
|
-
ipc.addEventListener('message', handleMessage);
|
|
5300
|
-
} else if ('on' in ipc) {
|
|
5301
|
-
// deprecated
|
|
5302
|
-
ipc.on('message', handleMessage);
|
|
5303
|
-
}
|
|
5304
|
-
};
|
|
5305
|
-
const unhandleIpc = ipc => {
|
|
5306
|
-
if ('removeEventListener' in ipc) {
|
|
5307
|
-
ipc.removeEventListener('message', handleMessage);
|
|
5308
|
-
} else if ('off' in ipc) {
|
|
5309
|
-
ipc.off('message', handleMessage);
|
|
5310
|
-
}
|
|
5311
|
-
};
|
|
5312
|
-
|
|
5313
|
-
const NodeWorker = 1;
|
|
5314
|
-
const NodeForkedProcess = 2;
|
|
5315
|
-
const ElectronUtilityProcess = 3;
|
|
5316
|
-
const ElectronMessagePort = 4;
|
|
5317
|
-
|
|
5318
|
-
const getModule$2 = method => {
|
|
5319
|
-
switch (method) {
|
|
5320
|
-
case NodeWorker:
|
|
5321
|
-
return IpcParentWithNodeWorker$1;
|
|
5322
|
-
case NodeForkedProcess:
|
|
5323
|
-
return IpcParentWithNodeForkedProcess$1;
|
|
5324
|
-
case ElectronUtilityProcess:
|
|
5325
|
-
return Promise.resolve().then(function () { return IpcParentWithElectronUtilityProcess; });
|
|
5326
|
-
case ElectronMessagePort:
|
|
5327
|
-
return IpcParentWithElectronMessagePort$1;
|
|
5328
|
-
default:
|
|
5329
|
-
throw new Error(`unexpected ipc type ${method}`);
|
|
5330
|
-
}
|
|
5266
|
+
return state$2.session;
|
|
5331
5267
|
};
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
*
|
|
5335
|
-
* @param {*} param0
|
|
5336
|
-
* @returns {Promise<any>}
|
|
5337
|
-
*/
|
|
5338
|
-
const create$2 = async ({
|
|
5339
|
-
method,
|
|
5340
|
-
...options
|
|
5341
|
-
}) => {
|
|
5342
|
-
const module = await getModule$2(method);
|
|
5343
|
-
// @ts-ignore
|
|
5344
|
-
const rawIpc = await module.create(options);
|
|
5345
|
-
// @ts-ignore
|
|
5346
|
-
if (module.effects) {
|
|
5347
|
-
// @ts-ignore
|
|
5348
|
-
module.effects({
|
|
5349
|
-
rawIpc,
|
|
5350
|
-
...options
|
|
5351
|
-
});
|
|
5352
|
-
}
|
|
5353
|
-
if (options.noReturn) {
|
|
5354
|
-
return undefined;
|
|
5355
|
-
}
|
|
5356
|
-
// @ts-ignore
|
|
5357
|
-
const ipc = module.wrap(rawIpc);
|
|
5358
|
-
return ipc;
|
|
5268
|
+
const set = value => {
|
|
5269
|
+
state$2.session = value;
|
|
5359
5270
|
};
|
|
5360
5271
|
|
|
5361
|
-
const create$
|
|
5272
|
+
const create$2 = rpc => {
|
|
5362
5273
|
const handleRequest = async request => {
|
|
5363
5274
|
const {
|
|
5364
5275
|
method,
|
|
5365
5276
|
url
|
|
5366
5277
|
} = request;
|
|
5367
|
-
console.log('got request', method, url);
|
|
5368
5278
|
const {
|
|
5369
5279
|
body,
|
|
5370
5280
|
init
|
|
5371
|
-
} = await invoke
|
|
5281
|
+
} = await rpc.invoke('WebViewProtocol.getResponse', method, url);
|
|
5372
5282
|
return new Response(body, init);
|
|
5373
5283
|
};
|
|
5374
5284
|
return handleRequest;
|
|
@@ -5376,23 +5286,19 @@ const create$1 = ipc => {
|
|
|
5376
5286
|
|
|
5377
5287
|
const get$1 = () => {
|
|
5378
5288
|
if (!has()) {
|
|
5379
|
-
set
|
|
5289
|
+
set(createElectronSession());
|
|
5380
5290
|
}
|
|
5381
5291
|
return get$2();
|
|
5382
5292
|
};
|
|
5383
5293
|
const registerWebviewProtocol = async port => {
|
|
5384
5294
|
object(port);
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5295
|
+
const rpc = await ElectronMessagePortRpcClient.create({
|
|
5296
|
+
commandMap: {},
|
|
5297
|
+
messagePort: port,
|
|
5298
|
+
requiresSocket: requiresSocket
|
|
5389
5299
|
});
|
|
5390
|
-
console.log('do register protocol');
|
|
5391
|
-
handleIpc(ipc);
|
|
5392
|
-
port.start();
|
|
5393
5300
|
const session = get$1();
|
|
5394
|
-
const handleRequest = create$
|
|
5395
|
-
// @ts-ignore
|
|
5301
|
+
const handleRequest = create$2(rpc);
|
|
5396
5302
|
handle(session.protocol, WebView, handleRequest);
|
|
5397
5303
|
};
|
|
5398
5304
|
|
|
@@ -5511,7 +5417,12 @@ const connectIpc$1 = async (rpc, browserWindowPort, ...params) => {
|
|
|
5511
5417
|
browserWindowPort.start();
|
|
5512
5418
|
};
|
|
5513
5419
|
|
|
5514
|
-
const
|
|
5420
|
+
const NodeWorker = 1;
|
|
5421
|
+
const NodeForkedProcess = 2;
|
|
5422
|
+
const ElectronUtilityProcess = 3;
|
|
5423
|
+
const ElectronMessagePort = 4;
|
|
5424
|
+
|
|
5425
|
+
const getModule$2 = method => {
|
|
5515
5426
|
switch (method) {
|
|
5516
5427
|
case NodeWorker:
|
|
5517
5428
|
return connectIpc$1;
|
|
@@ -5522,7 +5433,7 @@ const getModule$1 = method => {
|
|
|
5522
5433
|
}
|
|
5523
5434
|
};
|
|
5524
5435
|
const connectIpc = async (method, rpc, browserWindowPort, ipcId) => {
|
|
5525
|
-
const connectIpc = getModule$
|
|
5436
|
+
const connectIpc = getModule$2(method);
|
|
5526
5437
|
return connectIpc(rpc, browserWindowPort, ipcId);
|
|
5527
5438
|
};
|
|
5528
5439
|
|
|
@@ -5558,27 +5469,27 @@ const createMessagePort = async (ipcId, port, webContentsId) => {
|
|
|
5558
5469
|
return webContentsId;
|
|
5559
5470
|
};
|
|
5560
5471
|
|
|
5561
|
-
const state$
|
|
5472
|
+
const state$1 = {
|
|
5562
5473
|
all: Object.create(null)
|
|
5563
5474
|
};
|
|
5564
5475
|
const add = (pid, process, name) => {
|
|
5565
5476
|
number(pid);
|
|
5566
5477
|
object(process);
|
|
5567
5478
|
string(name);
|
|
5568
|
-
state$
|
|
5479
|
+
state$1.all[pid] = {
|
|
5569
5480
|
process,
|
|
5570
5481
|
name
|
|
5571
5482
|
};
|
|
5572
5483
|
};
|
|
5573
5484
|
const remove = pid => {
|
|
5574
5485
|
number(pid);
|
|
5575
|
-
delete state$
|
|
5486
|
+
delete state$1.all[pid];
|
|
5576
5487
|
};
|
|
5577
5488
|
const getAll = () => {
|
|
5578
|
-
return Object.entries(state$
|
|
5489
|
+
return Object.entries(state$1.all);
|
|
5579
5490
|
};
|
|
5580
5491
|
const getByName = name => {
|
|
5581
|
-
for (const value of Object.values(state$
|
|
5492
|
+
for (const value of Object.values(state$1.all)) {
|
|
5582
5493
|
// @ts-ignore
|
|
5583
5494
|
if (value.name === name) {
|
|
5584
5495
|
// @ts-ignore
|
|
@@ -5645,7 +5556,8 @@ const createUtilityProcessRpc = async options => {
|
|
|
5645
5556
|
commandMap: commandMapRef,
|
|
5646
5557
|
...options
|
|
5647
5558
|
});
|
|
5648
|
-
|
|
5559
|
+
const rpcId = options.targetRpcId || options.rpcId || options.ipcId;
|
|
5560
|
+
set$3(rpcId, rpc);
|
|
5649
5561
|
};
|
|
5650
5562
|
|
|
5651
5563
|
const serializeDeskopCapturerSource = source => {
|
|
@@ -5893,6 +5805,53 @@ const getBounds = () => {
|
|
|
5893
5805
|
};
|
|
5894
5806
|
};
|
|
5895
5807
|
|
|
5808
|
+
const disposeWebContents = webContents => {
|
|
5809
|
+
if (webContents.close) {
|
|
5810
|
+
// electron v22
|
|
5811
|
+
webContents.close();
|
|
5812
|
+
// @ts-ignore
|
|
5813
|
+
} else if (webContents.destroy) {
|
|
5814
|
+
// older versions of electron
|
|
5815
|
+
// @ts-ignore
|
|
5816
|
+
webContents.destroy();
|
|
5817
|
+
}
|
|
5818
|
+
};
|
|
5819
|
+
|
|
5820
|
+
const getStats$1 = webContentsId => {
|
|
5821
|
+
number(webContentsId);
|
|
5822
|
+
const contents = webContents.fromId(webContentsId);
|
|
5823
|
+
if (!contents) {
|
|
5824
|
+
return undefined;
|
|
5825
|
+
}
|
|
5826
|
+
const canGoBack = contents.navigationHistory.canGoBack();
|
|
5827
|
+
const canGoForward = contents.navigationHistory.canGoForward();
|
|
5828
|
+
const url = contents.getURL();
|
|
5829
|
+
const title = contents.getTitle();
|
|
5830
|
+
return {
|
|
5831
|
+
canGoBack,
|
|
5832
|
+
canGoForward,
|
|
5833
|
+
url,
|
|
5834
|
+
title
|
|
5835
|
+
};
|
|
5836
|
+
};
|
|
5837
|
+
const dispose$1 = webContentsId => {
|
|
5838
|
+
number(webContentsId);
|
|
5839
|
+
const contents = webContents.fromId(webContentsId);
|
|
5840
|
+
if (!contents) {
|
|
5841
|
+
return;
|
|
5842
|
+
}
|
|
5843
|
+
disposeWebContents(contents);
|
|
5844
|
+
};
|
|
5845
|
+
const callFunction = (webContentsId, functionName, ...args) => {
|
|
5846
|
+
number(webContentsId);
|
|
5847
|
+
string(functionName);
|
|
5848
|
+
const contents = webContents.fromId(webContentsId);
|
|
5849
|
+
if (!contents) {
|
|
5850
|
+
return;
|
|
5851
|
+
}
|
|
5852
|
+
contents[functionName](...args);
|
|
5853
|
+
};
|
|
5854
|
+
|
|
5896
5855
|
const KeyDown = 'keyDown';
|
|
5897
5856
|
|
|
5898
5857
|
const Backspace$1 = 'Backspace';
|
|
@@ -6596,7 +6555,7 @@ const filter = {
|
|
|
6596
6555
|
urls: ['<all_urls>']
|
|
6597
6556
|
};
|
|
6598
6557
|
|
|
6599
|
-
const state
|
|
6558
|
+
const state = {
|
|
6600
6559
|
session: undefined
|
|
6601
6560
|
};
|
|
6602
6561
|
const isAllowedPermission = permission => {
|
|
@@ -6629,24 +6588,16 @@ const createSession = () => {
|
|
|
6629
6588
|
return session;
|
|
6630
6589
|
};
|
|
6631
6590
|
const getSession = () => {
|
|
6632
|
-
state
|
|
6633
|
-
return state
|
|
6591
|
+
state.session ||= createSession();
|
|
6592
|
+
return state.session;
|
|
6634
6593
|
};
|
|
6635
6594
|
|
|
6636
|
-
const state = {
|
|
6637
|
-
ipc: undefined
|
|
6638
|
-
};
|
|
6639
|
-
const set = ipc => {
|
|
6640
|
-
state.ipc = ipc;
|
|
6641
|
-
};
|
|
6642
6595
|
const send = (method, ...params) => {
|
|
6643
|
-
const
|
|
6644
|
-
|
|
6645
|
-
} = state;
|
|
6646
|
-
if (!ipc) {
|
|
6596
|
+
const rpc = get(EmbedsProcess);
|
|
6597
|
+
if (!rpc) {
|
|
6647
6598
|
return;
|
|
6648
6599
|
}
|
|
6649
|
-
send
|
|
6600
|
+
return rpc.send(method, ...params);
|
|
6650
6601
|
};
|
|
6651
6602
|
|
|
6652
6603
|
// TODO use electron 30 webcontentsview api
|
|
@@ -6724,15 +6675,6 @@ const wrapBrowserViewCommand = fn => {
|
|
|
6724
6675
|
};
|
|
6725
6676
|
return wrappedCommand;
|
|
6726
6677
|
};
|
|
6727
|
-
|
|
6728
|
-
/**
|
|
6729
|
-
*
|
|
6730
|
-
* @param {Electron.BrowserView} view
|
|
6731
|
-
* @param {number} x
|
|
6732
|
-
* @param {number} y
|
|
6733
|
-
* @param {number} width
|
|
6734
|
-
* @param {number} height
|
|
6735
|
-
*/
|
|
6736
6678
|
const resizeBrowserView = (view, x, y, width, height) => {
|
|
6737
6679
|
object(view);
|
|
6738
6680
|
number(x);
|
|
@@ -6754,12 +6696,6 @@ const setIframeSrcFallback = async (view, code, message) => {
|
|
|
6754
6696
|
}
|
|
6755
6697
|
});
|
|
6756
6698
|
};
|
|
6757
|
-
|
|
6758
|
-
/**
|
|
6759
|
-
*
|
|
6760
|
-
* @param {Electron.BrowserView} view
|
|
6761
|
-
* @param {string} iframeSrc
|
|
6762
|
-
*/
|
|
6763
6699
|
const setIframeSrc = async (view, iframeSrc) => {
|
|
6764
6700
|
try {
|
|
6765
6701
|
object(view);
|
|
@@ -6775,21 +6711,12 @@ const setIframeSrc = async (view, iframeSrc) => {
|
|
|
6775
6711
|
throw betterError;
|
|
6776
6712
|
}
|
|
6777
6713
|
};
|
|
6778
|
-
/**
|
|
6779
|
-
*
|
|
6780
|
-
* @param {Electron.BrowserView} view
|
|
6781
|
-
*/
|
|
6782
6714
|
const focus = view => {
|
|
6783
6715
|
const {
|
|
6784
6716
|
webContents
|
|
6785
6717
|
} = view;
|
|
6786
6718
|
webContents.focus();
|
|
6787
6719
|
};
|
|
6788
|
-
|
|
6789
|
-
/**
|
|
6790
|
-
*
|
|
6791
|
-
* @param {Electron.BrowserView} view
|
|
6792
|
-
*/
|
|
6793
6720
|
const openDevtools = view => {
|
|
6794
6721
|
const {
|
|
6795
6722
|
webContents
|
|
@@ -6797,43 +6724,25 @@ const openDevtools = view => {
|
|
|
6797
6724
|
// TODO return promise that resolves once devtools are actually open
|
|
6798
6725
|
webContents.openDevTools();
|
|
6799
6726
|
};
|
|
6800
|
-
/**
|
|
6801
|
-
*
|
|
6802
|
-
* @param {Electron.BrowserView} view
|
|
6803
|
-
*/
|
|
6804
6727
|
const reload = view => {
|
|
6805
6728
|
const {
|
|
6806
6729
|
webContents
|
|
6807
6730
|
} = view;
|
|
6808
6731
|
webContents.reload();
|
|
6809
6732
|
};
|
|
6810
|
-
/**
|
|
6811
|
-
*
|
|
6812
|
-
* @param {Electron.BrowserView} view
|
|
6813
|
-
*/
|
|
6814
6733
|
const forward = view => {
|
|
6815
6734
|
const {
|
|
6816
6735
|
webContents
|
|
6817
6736
|
} = view;
|
|
6818
|
-
webContents.goForward();
|
|
6737
|
+
webContents.navigationHistory.goForward();
|
|
6819
6738
|
};
|
|
6820
|
-
|
|
6821
|
-
/**
|
|
6822
|
-
*
|
|
6823
|
-
* @param {Electron.BrowserView} view
|
|
6824
|
-
*/
|
|
6825
6739
|
const backward = view => {
|
|
6826
6740
|
// TODO return promise that resolves once devtools are actually open
|
|
6827
6741
|
const {
|
|
6828
6742
|
webContents
|
|
6829
6743
|
} = view;
|
|
6830
|
-
webContents.goBack();
|
|
6744
|
+
webContents.navigationHistory.goBack();
|
|
6831
6745
|
};
|
|
6832
|
-
|
|
6833
|
-
/**
|
|
6834
|
-
*
|
|
6835
|
-
* @param {Electron.BrowserView} view
|
|
6836
|
-
*/
|
|
6837
6746
|
const cancelNavigation = view => {
|
|
6838
6747
|
const {
|
|
6839
6748
|
webContents
|
|
@@ -6841,8 +6750,8 @@ const cancelNavigation = view => {
|
|
|
6841
6750
|
setCanceled(webContents.id);
|
|
6842
6751
|
debug(`[main process] canceled navigation to ${webContents.getURL()}`);
|
|
6843
6752
|
webContents.stop();
|
|
6844
|
-
if (webContents.canGoBack()) {
|
|
6845
|
-
webContents.goBack();
|
|
6753
|
+
if (webContents.navigationHistory.canGoBack()) {
|
|
6754
|
+
webContents.navigationHistory.goBack();
|
|
6846
6755
|
}
|
|
6847
6756
|
};
|
|
6848
6757
|
const show = id => {
|
|
@@ -6929,7 +6838,7 @@ const setFallThroughKeyBindings = fallthroughKeyBindings => {
|
|
|
6929
6838
|
/**
|
|
6930
6839
|
* @param {Electron.BrowserView} view
|
|
6931
6840
|
*/
|
|
6932
|
-
const getStats
|
|
6841
|
+
const getStats = view => {
|
|
6933
6842
|
const {
|
|
6934
6843
|
webContents
|
|
6935
6844
|
} = view;
|
|
@@ -6945,7 +6854,36 @@ const getStats$1 = view => {
|
|
|
6945
6854
|
};
|
|
6946
6855
|
};
|
|
6947
6856
|
|
|
6948
|
-
const
|
|
6857
|
+
const printPrettyError = (prettyError, prefix = '') => {
|
|
6858
|
+
error(`${prefix}${prettyError.type}: ${prettyError.message}\n\n${prettyError.codeFrame}\n\n${prettyError.stack}\n`);
|
|
6859
|
+
};
|
|
6860
|
+
|
|
6861
|
+
const logError = (error, prettyError) => {
|
|
6862
|
+
printPrettyError(prettyError, '[main-process] ');
|
|
6863
|
+
};
|
|
6864
|
+
const handleMessage = event => {
|
|
6865
|
+
return handleJsonRpcMessage(event.target, event.data, execute, resolve, prepare,
|
|
6866
|
+
// @ts-ignore
|
|
6867
|
+
logError, requiresSocket);
|
|
6868
|
+
};
|
|
6869
|
+
|
|
6870
|
+
const handleIpc = ipc => {
|
|
6871
|
+
if ('addEventListener' in ipc) {
|
|
6872
|
+
ipc.addEventListener('message', handleMessage);
|
|
6873
|
+
} else if ('on' in ipc) {
|
|
6874
|
+
// deprecated
|
|
6875
|
+
ipc.on('message', handleMessage);
|
|
6876
|
+
}
|
|
6877
|
+
};
|
|
6878
|
+
const unhandleIpc = ipc => {
|
|
6879
|
+
if ('removeEventListener' in ipc) {
|
|
6880
|
+
ipc.removeEventListener('message', handleMessage);
|
|
6881
|
+
} else if ('off' in ipc) {
|
|
6882
|
+
ipc.off('message', handleMessage);
|
|
6883
|
+
}
|
|
6884
|
+
};
|
|
6885
|
+
|
|
6886
|
+
const getModule$1 = method => {
|
|
6949
6887
|
switch (method) {
|
|
6950
6888
|
case NodeForkedProcess$1:
|
|
6951
6889
|
return IpcChildWithNodeForkedProcess$1;
|
|
@@ -6966,7 +6904,7 @@ const listen = async ({
|
|
|
6966
6904
|
method,
|
|
6967
6905
|
...params
|
|
6968
6906
|
}) => {
|
|
6969
|
-
const module = getModule(method);
|
|
6907
|
+
const module = getModule$1(method);
|
|
6970
6908
|
// @ts-ignore
|
|
6971
6909
|
const rawIpc = await module.listen(params);
|
|
6972
6910
|
// @ts-ignore
|
|
@@ -7033,18 +6971,62 @@ const getWindowId = webContentsId => {
|
|
|
7033
6971
|
return browserWindow.id;
|
|
7034
6972
|
};
|
|
7035
6973
|
|
|
7036
|
-
const handleElectronMessagePort = async (messagePort,
|
|
6974
|
+
const handleElectronMessagePort = async (messagePort, rpcId) => {
|
|
7037
6975
|
object(messagePort);
|
|
7038
|
-
const
|
|
7039
|
-
|
|
7040
|
-
|
|
6976
|
+
const rpc = await ElectronMessagePortRpcClient.create({
|
|
6977
|
+
messagePort: messagePort,
|
|
6978
|
+
commandMap: commandMapRef,
|
|
6979
|
+
requiresSocket: requiresSocket
|
|
7041
6980
|
});
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
6981
|
+
if (rpcId) {
|
|
6982
|
+
set$3(rpcId, rpc);
|
|
6983
|
+
}
|
|
6984
|
+
};
|
|
6985
|
+
|
|
6986
|
+
const getModule = method => {
|
|
6987
|
+
switch (method) {
|
|
6988
|
+
case NodeWorker:
|
|
6989
|
+
return IpcParentWithNodeWorker$1;
|
|
6990
|
+
case NodeForkedProcess:
|
|
6991
|
+
return IpcParentWithNodeForkedProcess$1;
|
|
6992
|
+
case ElectronUtilityProcess:
|
|
6993
|
+
return Promise.resolve().then(function () { return IpcParentWithElectronUtilityProcess; });
|
|
6994
|
+
case ElectronMessagePort:
|
|
6995
|
+
return IpcParentWithElectronMessagePort$1;
|
|
6996
|
+
default:
|
|
6997
|
+
throw new Error(`unexpected ipc type ${method}`);
|
|
7045
6998
|
}
|
|
7046
6999
|
};
|
|
7047
7000
|
|
|
7001
|
+
/**
|
|
7002
|
+
*
|
|
7003
|
+
* @param {*} param0
|
|
7004
|
+
* @returns {Promise<any>}
|
|
7005
|
+
* @deprecated
|
|
7006
|
+
*/
|
|
7007
|
+
const create$1 = async ({
|
|
7008
|
+
method,
|
|
7009
|
+
...options
|
|
7010
|
+
}) => {
|
|
7011
|
+
const module = await getModule(method);
|
|
7012
|
+
// @ts-ignore
|
|
7013
|
+
const rawIpc = await module.create(options);
|
|
7014
|
+
// @ts-ignore
|
|
7015
|
+
if (module.effects) {
|
|
7016
|
+
// @ts-ignore
|
|
7017
|
+
module.effects({
|
|
7018
|
+
rawIpc,
|
|
7019
|
+
...options
|
|
7020
|
+
});
|
|
7021
|
+
}
|
|
7022
|
+
if (options.noReturn) {
|
|
7023
|
+
return undefined;
|
|
7024
|
+
}
|
|
7025
|
+
// @ts-ignore
|
|
7026
|
+
const ipc = module.wrap(rawIpc);
|
|
7027
|
+
return ipc;
|
|
7028
|
+
};
|
|
7029
|
+
|
|
7048
7030
|
const shouldOpenExternal = url => {
|
|
7049
7031
|
if (url.startsWith('http:') || url.startsWith('https:')) {
|
|
7050
7032
|
return true;
|
|
@@ -7130,6 +7112,10 @@ const createPortTuple = async (id1, id2) => {
|
|
|
7130
7112
|
} = getPortTuple();
|
|
7131
7113
|
await invokeAndTransfer('TemporaryMessagePort.handlePorts', port1, port2, id1, id2);
|
|
7132
7114
|
};
|
|
7115
|
+
|
|
7116
|
+
/**
|
|
7117
|
+
* @deprecated
|
|
7118
|
+
*/
|
|
7133
7119
|
const sendTo = async (port, name, ipcId) => {
|
|
7134
7120
|
string(name);
|
|
7135
7121
|
object(port);
|
|
@@ -7142,14 +7128,17 @@ const sendTo = async (port, name, ipcId) => {
|
|
|
7142
7128
|
};
|
|
7143
7129
|
|
|
7144
7130
|
// TODO use rpc id, and then use rpc.invokeAndtransfer
|
|
7145
|
-
const sendTo2 = async (port,
|
|
7131
|
+
const sendTo2 = async (port, targetRpcId, sourceRpcId) => {
|
|
7146
7132
|
object(port);
|
|
7147
|
-
const rpc = get(
|
|
7148
|
-
|
|
7133
|
+
const rpc = get(targetRpcId);
|
|
7134
|
+
if (!rpc) {
|
|
7135
|
+
throw new Error(`rpc ${targetRpcId} not found`);
|
|
7136
|
+
}
|
|
7137
|
+
await rpc.invokeAndTransfer('HandleElectronMessagePort.handleElectronMessagePort', port, sourceRpcId);
|
|
7149
7138
|
};
|
|
7150
7139
|
|
|
7151
7140
|
// todo dispose the rpc by rpc id
|
|
7152
|
-
const dispose
|
|
7141
|
+
const dispose = name => {
|
|
7153
7142
|
string(name);
|
|
7154
7143
|
const formattedName = formatUtilityProcessName(name);
|
|
7155
7144
|
const utilityProcess = getByName(formattedName);
|
|
@@ -7196,25 +7185,28 @@ const commandMap = {
|
|
|
7196
7185
|
'ElectronShell.openExternal': openExternal,
|
|
7197
7186
|
'ElectronShell.openPath': openPath,
|
|
7198
7187
|
'ElectronShell.showItemInFolder': showItemInFolder,
|
|
7188
|
+
'ElectronWebContents.callFunction': callFunction,
|
|
7189
|
+
'ElectronWebContents.dispose': dispose$1,
|
|
7190
|
+
'ElectronWebContents.getStats': getStats$1,
|
|
7199
7191
|
'ElectronWebContentsView.attachEventListeners': attachEventListeners,
|
|
7200
7192
|
'ElectronWebContentsView.createWebContentsView': createWebContentsView,
|
|
7201
7193
|
'ElectronWebContentsView.disposeWebContentsView': disposeWebContentsView,
|
|
7202
7194
|
'ElectronWebContentsViewFunctions.addToWindow': addToWindow,
|
|
7203
|
-
'ElectronWebContentsViewFunctions.backward': backward,
|
|
7204
|
-
'ElectronWebContentsViewFunctions.cancelNavigation': cancelNavigation,
|
|
7205
|
-
'ElectronWebContentsViewFunctions.copyImageAt': copyImageAt,
|
|
7206
|
-
'ElectronWebContentsViewFunctions.focus': focus,
|
|
7207
|
-
'ElectronWebContentsViewFunctions.forward': forward,
|
|
7208
|
-
'ElectronWebContentsViewFunctions.getStats': getStats
|
|
7195
|
+
'ElectronWebContentsViewFunctions.backward': wrapBrowserViewCommand(backward),
|
|
7196
|
+
'ElectronWebContentsViewFunctions.cancelNavigation': wrapBrowserViewCommand(cancelNavigation),
|
|
7197
|
+
'ElectronWebContentsViewFunctions.copyImageAt': wrapBrowserViewCommand(copyImageAt),
|
|
7198
|
+
'ElectronWebContentsViewFunctions.focus': wrapBrowserViewCommand(focus),
|
|
7199
|
+
'ElectronWebContentsViewFunctions.forward': wrapBrowserViewCommand(forward),
|
|
7200
|
+
'ElectronWebContentsViewFunctions.getStats': wrapBrowserViewCommand(getStats),
|
|
7209
7201
|
'ElectronWebContentsViewFunctions.hide': hide,
|
|
7210
|
-
'ElectronWebContentsViewFunctions.inspectElement': inspectElement,
|
|
7211
|
-
'ElectronWebContentsViewFunctions.openDevtools': openDevtools,
|
|
7212
|
-
'ElectronWebContentsViewFunctions.reload': reload,
|
|
7213
|
-
'ElectronWebContentsViewFunctions.resizeBrowserView': resizeBrowserView,
|
|
7214
|
-
'ElectronWebContentsViewFunctions.setBackgroundColor': setBackgroundColor,
|
|
7215
|
-
'ElectronWebContentsViewFunctions.setFallthroughKeyBindings': setFallThroughKeyBindings,
|
|
7216
|
-
'ElectronWebContentsViewFunctions.setIframeSrc': setIframeSrc,
|
|
7217
|
-
'ElectronWebContentsViewFunctions.setIframeSrcFallback': setIframeSrcFallback,
|
|
7202
|
+
'ElectronWebContentsViewFunctions.inspectElement': wrapBrowserViewCommand(inspectElement),
|
|
7203
|
+
'ElectronWebContentsViewFunctions.openDevtools': wrapBrowserViewCommand(openDevtools),
|
|
7204
|
+
'ElectronWebContentsViewFunctions.reload': wrapBrowserViewCommand(wrapBrowserViewCommand(reload)),
|
|
7205
|
+
'ElectronWebContentsViewFunctions.resizeBrowserView': wrapBrowserViewCommand(resizeBrowserView),
|
|
7206
|
+
'ElectronWebContentsViewFunctions.setBackgroundColor': wrapBrowserViewCommand(setBackgroundColor),
|
|
7207
|
+
'ElectronWebContentsViewFunctions.setFallthroughKeyBindings': wrapBrowserViewCommand(setFallThroughKeyBindings),
|
|
7208
|
+
'ElectronWebContentsViewFunctions.setIframeSrc': wrapBrowserViewCommand(setIframeSrc),
|
|
7209
|
+
'ElectronWebContentsViewFunctions.setIframeSrcFallback': wrapBrowserViewCommand(setIframeSrcFallback),
|
|
7218
7210
|
'ElectronWebContentsViewFunctions.show': show,
|
|
7219
7211
|
'ElectronWindow.executeWebContentsFunction': executeWebContentsFunction,
|
|
7220
7212
|
'ElectronWindow.executeWindowFunction': executeWindowFunction,
|
|
@@ -7224,7 +7216,7 @@ const commandMap = {
|
|
|
7224
7216
|
'Exit.exit': exit,
|
|
7225
7217
|
'GetWindowId.getWindowId': getWindowId,
|
|
7226
7218
|
'HandleElectronMessagePort.handleElectronMessagePort': handleElectronMessagePort,
|
|
7227
|
-
'IpcParent.create': create$
|
|
7219
|
+
'IpcParent.create': create$1,
|
|
7228
7220
|
'OpenExternal.openExternal': openExternal,
|
|
7229
7221
|
'Process.getArgv': getArgv,
|
|
7230
7222
|
'Process.getChromeVersion': getChromeVersion,
|
|
@@ -7233,7 +7225,7 @@ const commandMap = {
|
|
|
7233
7225
|
'Process.getPid': getPid,
|
|
7234
7226
|
'Process.getV8Version': getV8Version,
|
|
7235
7227
|
'TemporaryMessagePort.createPortTuple': createPortTuple,
|
|
7236
|
-
'TemporaryMessagePort.dispose': dispose
|
|
7228
|
+
'TemporaryMessagePort.dispose': dispose,
|
|
7237
7229
|
'TemporaryMessagePort.sendTo': sendTo,
|
|
7238
7230
|
'TemporaryMessagePort.sendTo2': sendTo2,
|
|
7239
7231
|
'Trash.trash': trash
|
|
@@ -7692,7 +7684,7 @@ const ElectronWindowProcessExplorer_ipc = {
|
|
|
7692
7684
|
|
|
7693
7685
|
const name$c = 'IpcParent';
|
|
7694
7686
|
const Commands$c = {
|
|
7695
|
-
create: create$
|
|
7687
|
+
create: create$1
|
|
7696
7688
|
};
|
|
7697
7689
|
|
|
7698
7690
|
const IpcParent_ipc = {
|
|
@@ -7755,7 +7747,7 @@ const ElectronScreen_ipc = {
|
|
|
7755
7747
|
const name$7 = 'TemporaryMessagePort';
|
|
7756
7748
|
const Commands$7 = {
|
|
7757
7749
|
createPortTuple: createPortTuple,
|
|
7758
|
-
dispose: dispose
|
|
7750
|
+
dispose: dispose,
|
|
7759
7751
|
sendTo: sendTo
|
|
7760
7752
|
};
|
|
7761
7753
|
|
|
@@ -7765,61 +7757,10 @@ const TemporaryMessagePort_ipc = {
|
|
|
7765
7757
|
name: name$7
|
|
7766
7758
|
};
|
|
7767
7759
|
|
|
7768
|
-
/**
|
|
7769
|
-
*
|
|
7770
|
-
* @param {Electron.WebContents} webContents
|
|
7771
|
-
*/
|
|
7772
|
-
const disposeWebContents = webContents => {
|
|
7773
|
-
if (webContents.close) {
|
|
7774
|
-
// electron v22
|
|
7775
|
-
webContents.close();
|
|
7776
|
-
// @ts-ignore
|
|
7777
|
-
} else if (webContents.destroy) {
|
|
7778
|
-
// older versions of electron
|
|
7779
|
-
// @ts-ignore
|
|
7780
|
-
webContents.destroy();
|
|
7781
|
-
}
|
|
7782
|
-
};
|
|
7783
|
-
|
|
7784
|
-
const getStats = webContentsId => {
|
|
7785
|
-
number(webContentsId);
|
|
7786
|
-
const contents = webContents.fromId(webContentsId);
|
|
7787
|
-
if (!contents) {
|
|
7788
|
-
return undefined;
|
|
7789
|
-
}
|
|
7790
|
-
const canGoBack = contents.navigationHistory.canGoBack();
|
|
7791
|
-
const canGoForward = contents.navigationHistory.canGoForward();
|
|
7792
|
-
const url = contents.getURL();
|
|
7793
|
-
const title = contents.getTitle();
|
|
7794
|
-
return {
|
|
7795
|
-
canGoBack,
|
|
7796
|
-
canGoForward,
|
|
7797
|
-
url,
|
|
7798
|
-
title
|
|
7799
|
-
};
|
|
7800
|
-
};
|
|
7801
|
-
const dispose = webContentsId => {
|
|
7802
|
-
number(webContentsId);
|
|
7803
|
-
const contents = webContents.fromId(webContentsId);
|
|
7804
|
-
if (!contents) {
|
|
7805
|
-
return;
|
|
7806
|
-
}
|
|
7807
|
-
disposeWebContents(contents);
|
|
7808
|
-
};
|
|
7809
|
-
const callFunction = (webContentsId, functionName, ...args) => {
|
|
7810
|
-
number(webContentsId);
|
|
7811
|
-
string(functionName);
|
|
7812
|
-
const contents = webContents.fromId(webContentsId);
|
|
7813
|
-
if (!contents) {
|
|
7814
|
-
return;
|
|
7815
|
-
}
|
|
7816
|
-
contents[functionName](...args);
|
|
7817
|
-
};
|
|
7818
|
-
|
|
7819
7760
|
const name$6 = 'ElectronWebContents';
|
|
7820
7761
|
const Commands$6 = {
|
|
7821
|
-
dispose: dispose,
|
|
7822
|
-
getStats: getStats,
|
|
7762
|
+
dispose: dispose$1,
|
|
7763
|
+
getStats: getStats$1,
|
|
7823
7764
|
callFunction: callFunction
|
|
7824
7765
|
};
|
|
7825
7766
|
|
|
@@ -7850,7 +7791,7 @@ const Commands$4 = {
|
|
|
7850
7791
|
copyImageAt: wrapBrowserViewCommand(copyImageAt),
|
|
7851
7792
|
focus: wrapBrowserViewCommand(focus),
|
|
7852
7793
|
forward: wrapBrowserViewCommand(forward),
|
|
7853
|
-
getStats: wrapBrowserViewCommand(getStats
|
|
7794
|
+
getStats: wrapBrowserViewCommand(getStats),
|
|
7854
7795
|
hide: hide,
|
|
7855
7796
|
inspectElement: wrapBrowserViewCommand(inspectElement),
|
|
7856
7797
|
openDevtools: wrapBrowserViewCommand(openDevtools),
|