@lvce-editor/main-process 6.44.1 → 6.45.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.
@@ -7488,10 +7488,46 @@ const getDomTree = async view => {
7488
7488
  const result = await getBodyOuterHtml(view);
7489
7489
  return getSlimCode(result);
7490
7490
  };
7491
- const capturePage = async view => {
7492
- const image = await view.webContents.capturePage();
7491
+ const pendingCaptures = new WeakMap();
7492
+ const recoverableCaptureErrors = new Set(['Empty page capture', 'UnknownVizError', 'VizSentEmptyBitmap', 'Current display surface not available for capture']);
7493
+ const captureNonEmptyPage = async webContents => {
7494
+ const image = await webContents.capturePage();
7495
+ if (image.isEmpty()) {
7496
+ throw new Error('Empty page capture');
7497
+ }
7493
7498
  return image.toPNG();
7494
7499
  };
7500
+ const captureWithRecovery = async webContents => {
7501
+ try {
7502
+ return await captureNonEmptyPage(webContents);
7503
+ } catch (error) {
7504
+ if (!(error instanceof Error) || !recoverableCaptureErrors.has(error.message) || webContents.isDestroyed()) {
7505
+ throw error;
7506
+ }
7507
+ // A missing compositor surface must not become a blank overlay. Request a repaint without reloading the page.
7508
+ webContents.invalidate();
7509
+ return captureNonEmptyPage(webContents);
7510
+ }
7511
+ };
7512
+ const captureAndRelease = async webContents => {
7513
+ try {
7514
+ return await captureWithRecovery(webContents);
7515
+ } finally {
7516
+ pendingCaptures.delete(webContents);
7517
+ }
7518
+ };
7519
+ const capturePage = view => {
7520
+ const {
7521
+ webContents
7522
+ } = view;
7523
+ const pending = pendingCaptures.get(webContents);
7524
+ if (pending) {
7525
+ return pending;
7526
+ }
7527
+ const capture = captureAndRelease(webContents);
7528
+ pendingCaptures.set(webContents, capture);
7529
+ return capture;
7530
+ };
7495
7531
  const insertCss = async (view, code) => {
7496
7532
  const {
7497
7533
  webContents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "6.44.1",
3
+ "version": "6.45.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.0.0"
17
+ "electron": "44.3.0"
18
18
  },
19
19
  "engines": {
20
20
  "node": ">=22.11.0"