@lvce-editor/main-process 6.44.1 → 6.46.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 +52 -11
- package/package.json +2 -2
package/dist/mainProcessMain.js
CHANGED
|
@@ -7330,11 +7330,13 @@ const createWebContentsViewForWindow = (browserWindow, options = {}) => {
|
|
|
7330
7330
|
attachEventListenersToWebContents(webContents.id, webContents, browserWindow);
|
|
7331
7331
|
return view;
|
|
7332
7332
|
};
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7333
|
+
const createWebContentsView = async (_restoreId = 0, windowId = 0) => {
|
|
7334
|
+
number(windowId);
|
|
7335
|
+
// Legacy callers omit the owner. A supplied owner must never be replaced by whichever window currently has focus.
|
|
7336
|
+
const browserWindow = windowId ? BrowserWindow.fromId(windowId) : BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
|
|
7337
|
+
if (!browserWindow || browserWindow.isDestroyed()) {
|
|
7338
|
+
throw new Error('Cannot create a browser tab because its window is closed');
|
|
7339
|
+
}
|
|
7338
7340
|
const view = createWebContentsViewForWindow(browserWindow);
|
|
7339
7341
|
return view.webContents.id;
|
|
7340
7342
|
};
|
|
@@ -7488,10 +7490,46 @@ const getDomTree = async view => {
|
|
|
7488
7490
|
const result = await getBodyOuterHtml(view);
|
|
7489
7491
|
return getSlimCode(result);
|
|
7490
7492
|
};
|
|
7491
|
-
const
|
|
7492
|
-
|
|
7493
|
+
const pendingCaptures = new WeakMap();
|
|
7494
|
+
const recoverableCaptureErrors = new Set(['Empty page capture', 'UnknownVizError', 'VizSentEmptyBitmap', 'Current display surface not available for capture']);
|
|
7495
|
+
const captureNonEmptyPage = async webContents => {
|
|
7496
|
+
const image = await webContents.capturePage();
|
|
7497
|
+
if (image.isEmpty()) {
|
|
7498
|
+
throw new Error('Empty page capture');
|
|
7499
|
+
}
|
|
7493
7500
|
return image.toPNG();
|
|
7494
7501
|
};
|
|
7502
|
+
const captureWithRecovery = async webContents => {
|
|
7503
|
+
try {
|
|
7504
|
+
return await captureNonEmptyPage(webContents);
|
|
7505
|
+
} catch (error) {
|
|
7506
|
+
if (!(error instanceof Error) || !recoverableCaptureErrors.has(error.message) || webContents.isDestroyed()) {
|
|
7507
|
+
throw error;
|
|
7508
|
+
}
|
|
7509
|
+
// A missing compositor surface must not become a blank overlay. Request a repaint without reloading the page.
|
|
7510
|
+
webContents.invalidate();
|
|
7511
|
+
return captureNonEmptyPage(webContents);
|
|
7512
|
+
}
|
|
7513
|
+
};
|
|
7514
|
+
const captureAndRelease = async webContents => {
|
|
7515
|
+
try {
|
|
7516
|
+
return await captureWithRecovery(webContents);
|
|
7517
|
+
} finally {
|
|
7518
|
+
pendingCaptures.delete(webContents);
|
|
7519
|
+
}
|
|
7520
|
+
};
|
|
7521
|
+
const capturePage = view => {
|
|
7522
|
+
const {
|
|
7523
|
+
webContents
|
|
7524
|
+
} = view;
|
|
7525
|
+
const pending = pendingCaptures.get(webContents);
|
|
7526
|
+
if (pending) {
|
|
7527
|
+
return pending;
|
|
7528
|
+
}
|
|
7529
|
+
const capture = captureAndRelease(webContents);
|
|
7530
|
+
pendingCaptures.set(webContents, capture);
|
|
7531
|
+
return capture;
|
|
7532
|
+
};
|
|
7495
7533
|
const insertCss = async (view, code) => {
|
|
7496
7534
|
const {
|
|
7497
7535
|
webContents
|
|
@@ -7585,7 +7623,6 @@ const cancelNavigation = view => {
|
|
|
7585
7623
|
}
|
|
7586
7624
|
};
|
|
7587
7625
|
const show = id => {
|
|
7588
|
-
// console.log('[main-process] show browser view', id)
|
|
7589
7626
|
const state = get$4(id);
|
|
7590
7627
|
if (!state) {
|
|
7591
7628
|
return;
|
|
@@ -7594,7 +7631,10 @@ const show = id => {
|
|
|
7594
7631
|
browserWindow,
|
|
7595
7632
|
view
|
|
7596
7633
|
} = state;
|
|
7597
|
-
browserWindow.contentView.
|
|
7634
|
+
if (!browserWindow.contentView.children.includes(view)) {
|
|
7635
|
+
browserWindow.contentView.addChildView(view);
|
|
7636
|
+
}
|
|
7637
|
+
view.setVisible(true);
|
|
7598
7638
|
};
|
|
7599
7639
|
const addToWindow = (browserWindowId, browserViewId) => {
|
|
7600
7640
|
const state = get$4(browserViewId);
|
|
@@ -7613,10 +7653,11 @@ const hide = id => {
|
|
|
7613
7653
|
return;
|
|
7614
7654
|
}
|
|
7615
7655
|
const {
|
|
7616
|
-
browserWindow,
|
|
7617
7656
|
view
|
|
7618
7657
|
} = state;
|
|
7619
|
-
|
|
7658
|
+
// Detaching and reattaching can leave Electron's native page hidden even when
|
|
7659
|
+
// the View is visible. Keep its parent and compositor surface across overlays.
|
|
7660
|
+
view.setVisible(false);
|
|
7620
7661
|
};
|
|
7621
7662
|
|
|
7622
7663
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/main-process",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.46.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"lvce-editor",
|
|
6
6
|
"electron"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"type": "module",
|
|
15
15
|
"main": "dist/mainProcessMain.js",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"electron": "44.
|
|
17
|
+
"electron": "44.3.0"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=22.11.0"
|