@lvce-editor/main-process 6.41.2 → 6.43.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 +108 -14
- package/package.json +2 -2
package/dist/mainProcessMain.js
CHANGED
|
@@ -4813,8 +4813,8 @@ const create$3 = () => {
|
|
|
4813
4813
|
};
|
|
4814
4814
|
|
|
4815
4815
|
const windows = new Map();
|
|
4816
|
-
const setEnabled = (windowId, enabled) => {
|
|
4817
|
-
windows.get(windowId)?.setEnabled(enabled);
|
|
4816
|
+
const setEnabled = (windowId, enabled, modifier = 'ctrl=twice') => {
|
|
4817
|
+
windows.get(windowId)?.setEnabled(enabled, modifier);
|
|
4818
4818
|
};
|
|
4819
4819
|
const attach$e = (window, contents) => {
|
|
4820
4820
|
windows.get(window.id)?.attach(contents);
|
|
@@ -4822,10 +4822,16 @@ const attach$e = (window, contents) => {
|
|
|
4822
4822
|
const listen$2 = (window, rpc) => {
|
|
4823
4823
|
const gesture = create$3();
|
|
4824
4824
|
const disposers = new Map();
|
|
4825
|
+
let modifier = 'ctrl=twice';
|
|
4826
|
+
const heldControls = new Set();
|
|
4827
|
+
let holdTimer;
|
|
4825
4828
|
let enabled = false;
|
|
4826
4829
|
let pending;
|
|
4827
4830
|
const reset = () => {
|
|
4828
4831
|
gesture.reset();
|
|
4832
|
+
heldControls.clear();
|
|
4833
|
+
clearTimeout(holdTimer);
|
|
4834
|
+
holdTimer = undefined;
|
|
4829
4835
|
if (pending) {
|
|
4830
4836
|
clearImmediate(pending);
|
|
4831
4837
|
pending = undefined;
|
|
@@ -4840,6 +4846,25 @@ const listen$2 = (window, rpc) => {
|
|
|
4840
4846
|
reset();
|
|
4841
4847
|
return;
|
|
4842
4848
|
}
|
|
4849
|
+
if (modifier === 'ctrl-hold') {
|
|
4850
|
+
const isControl = input.code === 'ControlLeft' || input.code === 'ControlRight';
|
|
4851
|
+
const wasHeld = heldControls.has(input.code);
|
|
4852
|
+
if (isControl && input.type === 'keyDown') heldControls.add(input.code);
|
|
4853
|
+
if (isControl && input.type === 'keyUp') heldControls.delete(input.code);
|
|
4854
|
+
if (!isControl || input.type === 'keyUp' || input.alt || input.meta || input.shift || input.isComposing || heldControls.size !== 1) {
|
|
4855
|
+
clearTimeout(holdTimer);
|
|
4856
|
+
holdTimer = undefined;
|
|
4857
|
+
return;
|
|
4858
|
+
}
|
|
4859
|
+
if (input.type !== 'keyDown' || input.isAutoRepeat || wasHeld) return;
|
|
4860
|
+
holdTimer = setTimeout(() => {
|
|
4861
|
+
holdTimer = undefined;
|
|
4862
|
+
if (enabled && !contents.isDestroyed() && contents.isFocused() && window.isFocused()) {
|
|
4863
|
+
rpc.send('Window.handleBrowserFullWidthGesture');
|
|
4864
|
+
}
|
|
4865
|
+
}, 300);
|
|
4866
|
+
return;
|
|
4867
|
+
}
|
|
4843
4868
|
if (gesture.accept(input, performance.now())) {
|
|
4844
4869
|
// Deliver the key release before moving focus to another WebContents.
|
|
4845
4870
|
pending = setImmediate(() => {
|
|
@@ -4868,9 +4893,10 @@ const listen$2 = (window, rpc) => {
|
|
|
4868
4893
|
};
|
|
4869
4894
|
windows.set(window.id, {
|
|
4870
4895
|
attach: attachContents,
|
|
4871
|
-
setEnabled(value) {
|
|
4896
|
+
setEnabled(value, nextModifier) {
|
|
4872
4897
|
reset();
|
|
4873
4898
|
enabled = value;
|
|
4899
|
+
modifier = nextModifier;
|
|
4874
4900
|
}
|
|
4875
4901
|
});
|
|
4876
4902
|
attachContents(window.webContents);
|
|
@@ -4891,17 +4917,17 @@ const listen$2 = (window, rpc) => {
|
|
|
4891
4917
|
|
|
4892
4918
|
const closePreparationTimeout = 1000;
|
|
4893
4919
|
const prepareClose = async rpc => {
|
|
4894
|
-
|
|
4920
|
+
const {
|
|
4921
|
+
promise,
|
|
4922
|
+
reject
|
|
4923
|
+
} = Promise.withResolvers();
|
|
4924
|
+
const timeout = setTimeout(() => {
|
|
4925
|
+
reject(new Error(`Timed out preparing window close after ${closePreparationTimeout}ms`));
|
|
4926
|
+
}, closePreparationTimeout);
|
|
4895
4927
|
try {
|
|
4896
|
-
await Promise.race([rpc.invoke('Window.prepareClose'),
|
|
4897
|
-
timeout = setTimeout(() => {
|
|
4898
|
-
reject(new Error(`Timed out preparing window close after ${closePreparationTimeout}ms`));
|
|
4899
|
-
}, closePreparationTimeout);
|
|
4900
|
-
})]);
|
|
4928
|
+
await Promise.race([rpc.invoke('Window.prepareClose'), promise]);
|
|
4901
4929
|
} finally {
|
|
4902
|
-
|
|
4903
|
-
clearTimeout(timeout);
|
|
4904
|
-
}
|
|
4930
|
+
clearTimeout(timeout);
|
|
4905
4931
|
}
|
|
4906
4932
|
};
|
|
4907
4933
|
const createWindowCloseHandler = (window, rpc, onError, dispose = () => {}) => {
|
|
@@ -5281,6 +5307,72 @@ const beep$1 = () => {
|
|
|
5281
5307
|
shell.beep();
|
|
5282
5308
|
};
|
|
5283
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
|
+
|
|
5284
5376
|
const handleTimeout = () => {
|
|
5285
5377
|
throw new Error('oops');
|
|
5286
5378
|
};
|
|
@@ -5884,13 +5976,13 @@ const toggleDevtools = browserWindow => {
|
|
|
5884
5976
|
const toggleFullScreen = browserWindow => {
|
|
5885
5977
|
browserWindow.setFullScreen(!browserWindow.isFullScreen());
|
|
5886
5978
|
};
|
|
5887
|
-
const executeWindowFunction = (browserWindowId, key) => {
|
|
5979
|
+
const executeWindowFunction = (browserWindowId, key, modifier = 'ctrl=twice') => {
|
|
5888
5980
|
const browserWindow = getBrowserWindow(browserWindowId);
|
|
5889
5981
|
if (!browserWindow) {
|
|
5890
5982
|
return;
|
|
5891
5983
|
}
|
|
5892
5984
|
if (key === 'enableBrowserFullWidthGesture' || key === 'disableBrowserFullWidthGesture') {
|
|
5893
|
-
setEnabled(browserWindowId, key === 'enableBrowserFullWidthGesture');
|
|
5985
|
+
setEnabled(browserWindowId, key === 'enableBrowserFullWidthGesture', modifier);
|
|
5894
5986
|
return;
|
|
5895
5987
|
}
|
|
5896
5988
|
if (key === 'toggleDevtools') {
|
|
@@ -8004,6 +8096,8 @@ const trash = async path => {
|
|
|
8004
8096
|
const commandMap = {
|
|
8005
8097
|
'AppWindow.createAppWindow': createAppWindow,
|
|
8006
8098
|
'Beep.beep': beep$1,
|
|
8099
|
+
'BrowserFind.find': wrapBrowserViewCommand(find),
|
|
8100
|
+
'BrowserFind.stop': wrapBrowserViewCommand(stop$1),
|
|
8007
8101
|
'Crash.crashMainProcess': crashMainProcess$1,
|
|
8008
8102
|
'CreateMessagePort.createMessagePort': createMessagePort,
|
|
8009
8103
|
'CreatePidMap.createPidMap': createPidMap,
|
package/package.json
CHANGED