@lvce-editor/main-process 6.42.0 → 6.44.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 +89 -0
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -5307,6 +5307,72 @@ const beep$1 = () => {
|
|
|
5307
5307
|
shell.beep();
|
|
5308
5308
|
};
|
|
5309
5309
|
|
|
5310
|
+
const pending = new WeakMap();
|
|
5311
|
+
const stop$1 = view => {
|
|
5312
|
+
pending.get(view)?.();
|
|
5313
|
+
if (!view.webContents.isDestroyed()) view.webContents.stopFindInPage('clearSelection');
|
|
5314
|
+
};
|
|
5315
|
+
const find = (view, text, forward = true, matchCase = false, newSession = true) => {
|
|
5316
|
+
pending.get(view)?.();
|
|
5317
|
+
const {
|
|
5318
|
+
webContents
|
|
5319
|
+
} = view;
|
|
5320
|
+
if (webContents.isDestroyed()) return Promise.resolve(undefined);
|
|
5321
|
+
if (!text) {
|
|
5322
|
+
stop$1(view);
|
|
5323
|
+
return Promise.resolve({
|
|
5324
|
+
activeMatchOrdinal: 0,
|
|
5325
|
+
matches: 0
|
|
5326
|
+
});
|
|
5327
|
+
}
|
|
5328
|
+
return new Promise((resolve, reject) => {
|
|
5329
|
+
let requestId = 0;
|
|
5330
|
+
const finish = result => {
|
|
5331
|
+
clearTimeout(timeout);
|
|
5332
|
+
webContents.off('found-in-page', onResult);
|
|
5333
|
+
webContents.off('did-start-navigation', onNavigation);
|
|
5334
|
+
webContents.off('destroyed', cancel);
|
|
5335
|
+
webContents.off('render-process-gone', cancel);
|
|
5336
|
+
pending.delete(view);
|
|
5337
|
+
resolve(result);
|
|
5338
|
+
};
|
|
5339
|
+
const cancel = () => finish();
|
|
5340
|
+
const onNavigation = (_event, _url, inPlace, mainFrame) => {
|
|
5341
|
+
if (mainFrame && !inPlace) cancel();
|
|
5342
|
+
};
|
|
5343
|
+
const onResult = (_event, result) => {
|
|
5344
|
+
if (result.requestId === requestId && result.finalUpdate) {
|
|
5345
|
+
finish({
|
|
5346
|
+
activeMatchOrdinal: result.activeMatchOrdinal,
|
|
5347
|
+
matches: result.matches
|
|
5348
|
+
});
|
|
5349
|
+
}
|
|
5350
|
+
};
|
|
5351
|
+
const timeout = setTimeout(cancel, 10_000);
|
|
5352
|
+
pending.set(view, cancel);
|
|
5353
|
+
webContents.on('found-in-page', onResult);
|
|
5354
|
+
webContents.on('did-start-navigation', onNavigation);
|
|
5355
|
+
webContents.once('destroyed', cancel);
|
|
5356
|
+
webContents.once('render-process-gone', cancel);
|
|
5357
|
+
try {
|
|
5358
|
+
// Electron maps findNext to Chromium's new_session option.
|
|
5359
|
+
requestId = webContents.findInPage(text, {
|
|
5360
|
+
findNext: newSession,
|
|
5361
|
+
forward,
|
|
5362
|
+
matchCase
|
|
5363
|
+
});
|
|
5364
|
+
} catch (error) {
|
|
5365
|
+
clearTimeout(timeout);
|
|
5366
|
+
webContents.off('found-in-page', onResult);
|
|
5367
|
+
webContents.off('did-start-navigation', onNavigation);
|
|
5368
|
+
webContents.off('destroyed', cancel);
|
|
5369
|
+
webContents.off('render-process-gone', cancel);
|
|
5370
|
+
pending.delete(view);
|
|
5371
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
5372
|
+
}
|
|
5373
|
+
});
|
|
5374
|
+
};
|
|
5375
|
+
|
|
5310
5376
|
const handleTimeout = () => {
|
|
5311
5377
|
throw new Error('oops');
|
|
5312
5378
|
};
|
|
@@ -7465,6 +7531,26 @@ const click = async (view, selector) => {
|
|
|
7465
7531
|
});
|
|
7466
7532
|
return true;
|
|
7467
7533
|
};
|
|
7534
|
+
const pressKey = (view, keyCode, modifiers = []) => {
|
|
7535
|
+
string(keyCode);
|
|
7536
|
+
const {
|
|
7537
|
+
webContents
|
|
7538
|
+
} = view;
|
|
7539
|
+
if (webContents.isDestroyed()) {
|
|
7540
|
+
throw new Error('Cannot press a key in a closed browser tab');
|
|
7541
|
+
}
|
|
7542
|
+
webContents.focus();
|
|
7543
|
+
webContents.sendInputEvent({
|
|
7544
|
+
keyCode,
|
|
7545
|
+
modifiers,
|
|
7546
|
+
type: 'keyDown'
|
|
7547
|
+
});
|
|
7548
|
+
webContents.sendInputEvent({
|
|
7549
|
+
keyCode,
|
|
7550
|
+
modifiers,
|
|
7551
|
+
type: 'keyUp'
|
|
7552
|
+
});
|
|
7553
|
+
};
|
|
7468
7554
|
const reload = view => {
|
|
7469
7555
|
const {
|
|
7470
7556
|
webContents
|
|
@@ -8030,6 +8116,8 @@ const trash = async path => {
|
|
|
8030
8116
|
const commandMap = {
|
|
8031
8117
|
'AppWindow.createAppWindow': createAppWindow,
|
|
8032
8118
|
'Beep.beep': beep$1,
|
|
8119
|
+
'BrowserFind.find': wrapBrowserViewCommand(find),
|
|
8120
|
+
'BrowserFind.stop': wrapBrowserViewCommand(stop$1),
|
|
8033
8121
|
'Crash.crashMainProcess': crashMainProcess$1,
|
|
8034
8122
|
'CreateMessagePort.createMessagePort': createMessagePort,
|
|
8035
8123
|
'CreatePidMap.createPidMap': createPidMap,
|
|
@@ -8092,6 +8180,7 @@ const commandMap = {
|
|
|
8092
8180
|
'ElectronWebContentsViewFunctions.insertJavaScript': wrapBrowserViewCommand(executeJavaScript),
|
|
8093
8181
|
'ElectronWebContentsViewFunctions.inspectElement': wrapBrowserViewCommand(inspectElement),
|
|
8094
8182
|
'ElectronWebContentsViewFunctions.openDevtools': wrapBrowserViewCommand(openDevtools),
|
|
8183
|
+
'ElectronWebContentsViewFunctions.pressKey': wrapBrowserViewCommand(pressKey),
|
|
8095
8184
|
'ElectronWebContentsViewFunctions.reload': wrapBrowserViewCommand(reload),
|
|
8096
8185
|
'ElectronWebContentsViewFunctions.resizeBrowserView': wrapBrowserViewCommand(resizeBrowserView),
|
|
8097
8186
|
'ElectronWebContentsViewFunctions.setAudioMuted': wrapBrowserViewCommand(setAudioMuted),
|