@lvce-editor/main-process 6.37.9 → 6.37.11
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 +91 -53
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -4090,6 +4090,7 @@ const BeforeInputEvent = 'before-input-event';
|
|
|
4090
4090
|
const Login = 'login';
|
|
4091
4091
|
const AudioStateChanged = 'audio-state-changed';
|
|
4092
4092
|
|
|
4093
|
+
const Allow = 'allow';
|
|
4093
4094
|
const Deny = 'deny';
|
|
4094
4095
|
|
|
4095
4096
|
const shouldOpenExternal = url => {
|
|
@@ -6352,6 +6353,39 @@ const ElectronBrowserViewEventListenerContextMenu = {
|
|
|
6352
6353
|
key: key$8
|
|
6353
6354
|
};
|
|
6354
6355
|
|
|
6356
|
+
const pendingLogins = new Map();
|
|
6357
|
+
let nextRequestId = 1;
|
|
6358
|
+
const add = (webContentsId, callback) => {
|
|
6359
|
+
const requestId = `${webContentsId}:${nextRequestId++}`;
|
|
6360
|
+
pendingLogins.set(requestId, {
|
|
6361
|
+
callback,
|
|
6362
|
+
webContentsId
|
|
6363
|
+
});
|
|
6364
|
+
return requestId;
|
|
6365
|
+
};
|
|
6366
|
+
const take = requestId => {
|
|
6367
|
+
const pendingLogin = pendingLogins.get(requestId);
|
|
6368
|
+
pendingLogins.delete(requestId);
|
|
6369
|
+
return pendingLogin;
|
|
6370
|
+
};
|
|
6371
|
+
const accept = (requestId, username, password) => {
|
|
6372
|
+
const pendingLogin = take(requestId);
|
|
6373
|
+
pendingLogin?.callback(username, password);
|
|
6374
|
+
};
|
|
6375
|
+
const cancel = requestId => {
|
|
6376
|
+
const pendingLogin = take(requestId);
|
|
6377
|
+
pendingLogin?.callback();
|
|
6378
|
+
};
|
|
6379
|
+
const cancelForWebContents = webContentsId => {
|
|
6380
|
+
for (const [requestId, pendingLogin] of pendingLogins) {
|
|
6381
|
+
if (pendingLogin.webContentsId !== webContentsId) {
|
|
6382
|
+
continue;
|
|
6383
|
+
}
|
|
6384
|
+
pendingLogins.delete(requestId);
|
|
6385
|
+
pendingLogin.callback();
|
|
6386
|
+
}
|
|
6387
|
+
};
|
|
6388
|
+
|
|
6355
6389
|
const key$7 = 'destroyed';
|
|
6356
6390
|
const attach$9 = (webContents, listener) => {
|
|
6357
6391
|
webContents.on(Destroyed, listener);
|
|
@@ -6359,9 +6393,20 @@ const attach$9 = (webContents, listener) => {
|
|
|
6359
6393
|
const detach$7 = (webContents, listener) => {
|
|
6360
6394
|
webContents.off(Destroyed, listener);
|
|
6361
6395
|
};
|
|
6362
|
-
const handler$7 = () => {
|
|
6396
|
+
const handler$7 = (_event, webContentsId) => {
|
|
6397
|
+
cancelForWebContents(webContentsId);
|
|
6398
|
+
const instance = get$4(webContentsId);
|
|
6399
|
+
const messages = instance ? [['handleBrowserViewDestroyed']] : [];
|
|
6400
|
+
if (instance) {
|
|
6401
|
+
const {
|
|
6402
|
+
browserWindow,
|
|
6403
|
+
view
|
|
6404
|
+
} = instance;
|
|
6405
|
+
remove(webContentsId);
|
|
6406
|
+
browserWindow.contentView.removeChildView(view);
|
|
6407
|
+
}
|
|
6363
6408
|
return {
|
|
6364
|
-
messages
|
|
6409
|
+
messages,
|
|
6365
6410
|
result: undefined
|
|
6366
6411
|
};
|
|
6367
6412
|
};
|
|
@@ -6549,39 +6594,6 @@ const ElectronBrowserViewEventListenerDidNavigateInPage = {
|
|
|
6549
6594
|
key: key$4
|
|
6550
6595
|
};
|
|
6551
6596
|
|
|
6552
|
-
const pendingLogins = new Map();
|
|
6553
|
-
let nextRequestId = 1;
|
|
6554
|
-
const add = (webContentsId, callback) => {
|
|
6555
|
-
const requestId = `${webContentsId}:${nextRequestId++}`;
|
|
6556
|
-
pendingLogins.set(requestId, {
|
|
6557
|
-
callback,
|
|
6558
|
-
webContentsId
|
|
6559
|
-
});
|
|
6560
|
-
return requestId;
|
|
6561
|
-
};
|
|
6562
|
-
const take = requestId => {
|
|
6563
|
-
const pendingLogin = pendingLogins.get(requestId);
|
|
6564
|
-
pendingLogins.delete(requestId);
|
|
6565
|
-
return pendingLogin;
|
|
6566
|
-
};
|
|
6567
|
-
const accept = (requestId, username, password) => {
|
|
6568
|
-
const pendingLogin = take(requestId);
|
|
6569
|
-
pendingLogin?.callback(username, password);
|
|
6570
|
-
};
|
|
6571
|
-
const cancel = requestId => {
|
|
6572
|
-
const pendingLogin = take(requestId);
|
|
6573
|
-
pendingLogin?.callback();
|
|
6574
|
-
};
|
|
6575
|
-
const cancelForWebContents = webContentsId => {
|
|
6576
|
-
for (const [requestId, pendingLogin] of pendingLogins) {
|
|
6577
|
-
if (pendingLogin.webContentsId !== webContentsId) {
|
|
6578
|
-
continue;
|
|
6579
|
-
}
|
|
6580
|
-
pendingLogins.delete(requestId);
|
|
6581
|
-
pendingLogin.callback();
|
|
6582
|
-
}
|
|
6583
|
-
};
|
|
6584
|
-
|
|
6585
6597
|
const key$3 = Login;
|
|
6586
6598
|
const attach$5 = (webContents, listener) => {
|
|
6587
6599
|
webContents.on(Login, listener);
|
|
@@ -6668,12 +6680,21 @@ const detach = (webContents, listener) => {
|
|
|
6668
6680
|
const handler = ({
|
|
6669
6681
|
disposition,
|
|
6670
6682
|
url
|
|
6671
|
-
}) => {
|
|
6672
|
-
const
|
|
6683
|
+
}, _webContentsId, _webContents, createWindow) => {
|
|
6684
|
+
const shouldCreateWindow = url === 'about:blank' || shouldOpenExternal(url);
|
|
6685
|
+
if (!shouldCreateWindow) {
|
|
6686
|
+
return {
|
|
6687
|
+
messages: [],
|
|
6688
|
+
result: {
|
|
6689
|
+
action: Deny
|
|
6690
|
+
}
|
|
6691
|
+
};
|
|
6692
|
+
}
|
|
6673
6693
|
return {
|
|
6674
|
-
messages,
|
|
6694
|
+
messages: [],
|
|
6675
6695
|
result: {
|
|
6676
|
-
action:
|
|
6696
|
+
action: Allow,
|
|
6697
|
+
createWindow: options => createWindow(options, url, disposition)
|
|
6677
6698
|
}
|
|
6678
6699
|
};
|
|
6679
6700
|
};
|
|
@@ -6944,7 +6965,13 @@ const attachEventListenersToWebContents = (webContentsId, webContents, browserWi
|
|
|
6944
6965
|
};
|
|
6945
6966
|
const wrappedListener = (...args) => {
|
|
6946
6967
|
// @ts-ignore
|
|
6947
|
-
const
|
|
6968
|
+
const createWindow = (options, url, disposition) => {
|
|
6969
|
+
const view = createWebContentsViewForWindow(browserWindow, options.webPreferences);
|
|
6970
|
+
send('ElectronWebContents.handleWindowOpen', webContentsId, view.webContents.id, url, disposition);
|
|
6971
|
+
return view.webContents;
|
|
6972
|
+
};
|
|
6973
|
+
// @ts-ignore Electron event handlers have different argument tuples
|
|
6974
|
+
const handlerResult = value.handler(...args, webContentsId, webContents, createWindow);
|
|
6948
6975
|
if (handlerResult instanceof Promise) {
|
|
6949
6976
|
return handleAsyncResult(handlerResult);
|
|
6950
6977
|
}
|
|
@@ -6954,16 +6981,13 @@ const attachEventListenersToWebContents = (webContentsId, webContents, browserWi
|
|
|
6954
6981
|
}
|
|
6955
6982
|
webContentsWithEventListeners.add(webContents);
|
|
6956
6983
|
};
|
|
6957
|
-
|
|
6958
|
-
// TODO use electron 30 webcontentsview api
|
|
6959
|
-
const createWebContentsView = async () => {
|
|
6984
|
+
const createWebContentsViewForWindow = (browserWindow, webPreferences = {}) => {
|
|
6960
6985
|
const view = new WebContentsView({
|
|
6961
6986
|
webPreferences: {
|
|
6987
|
+
...webPreferences,
|
|
6962
6988
|
session: getSession()
|
|
6963
6989
|
}
|
|
6964
6990
|
});
|
|
6965
|
-
// TODO get browser window id from renderer worker
|
|
6966
|
-
const browserWindow = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
|
|
6967
6991
|
view.setBounds({
|
|
6968
6992
|
height: 720,
|
|
6969
6993
|
width: 1280,
|
|
@@ -6974,12 +6998,17 @@ const createWebContentsView = async () => {
|
|
|
6974
6998
|
const {
|
|
6975
6999
|
webContents
|
|
6976
7000
|
} = view;
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
7001
|
+
add$1(webContents.id, browserWindow, view);
|
|
7002
|
+
attachEventListenersToWebContents(webContents.id, webContents, browserWindow);
|
|
7003
|
+
return view;
|
|
7004
|
+
};
|
|
7005
|
+
|
|
7006
|
+
// TODO use electron 30 webcontentsview api
|
|
7007
|
+
const createWebContentsView = async () => {
|
|
7008
|
+
// TODO get browser window id from renderer worker
|
|
7009
|
+
const browserWindow = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
|
|
7010
|
+
const view = createWebContentsViewForWindow(browserWindow);
|
|
7011
|
+
return view.webContents.id;
|
|
6983
7012
|
};
|
|
6984
7013
|
const attachEventListeners = webContentsId => {
|
|
6985
7014
|
number(webContentsId);
|
|
@@ -7293,7 +7322,7 @@ const setFallThroughKeyBindings = (_view, fallthroughKeyBindings) => {
|
|
|
7293
7322
|
/**
|
|
7294
7323
|
* @param {Electron.BrowserView} view
|
|
7295
7324
|
*/
|
|
7296
|
-
const getStats = view => {
|
|
7325
|
+
const getStats = (view, includeMemory = false) => {
|
|
7297
7326
|
const {
|
|
7298
7327
|
webContents
|
|
7299
7328
|
} = view;
|
|
@@ -7302,13 +7331,22 @@ const getStats = view => {
|
|
|
7302
7331
|
const isAudioMuted = webContents.isAudioMuted();
|
|
7303
7332
|
const url = webContents.getURL();
|
|
7304
7333
|
const title = webContents.getTitle();
|
|
7305
|
-
|
|
7334
|
+
const stats = {
|
|
7306
7335
|
canGoBack,
|
|
7307
7336
|
canGoForward,
|
|
7308
7337
|
isAudioMuted,
|
|
7309
7338
|
title,
|
|
7310
7339
|
url
|
|
7311
7340
|
};
|
|
7341
|
+
if (!includeMemory) {
|
|
7342
|
+
return stats;
|
|
7343
|
+
}
|
|
7344
|
+
const processId = webContents.getOSProcessId();
|
|
7345
|
+
const processMetric = app.getAppMetrics().find(metric => metric.pid === processId);
|
|
7346
|
+
return {
|
|
7347
|
+
...stats,
|
|
7348
|
+
memory: (processMetric?.memory.workingSetSize || 0) * 1024
|
|
7349
|
+
};
|
|
7312
7350
|
};
|
|
7313
7351
|
|
|
7314
7352
|
const gpuInfoUrl = 'chrome://gpu';
|