@lvce-editor/renderer-process 30.68.16 → 30.69.1
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/rendererProcessMain.js +88 -13
- package/package.json +1 -1
|
@@ -10781,6 +10781,63 @@ const revokeObjectUrl = url => {
|
|
|
10781
10781
|
URL.revokeObjectURL(url);
|
|
10782
10782
|
};
|
|
10783
10783
|
|
|
10784
|
+
const createCanvasPresentation = (canvas, onDispose) => {
|
|
10785
|
+
const {
|
|
10786
|
+
port1,
|
|
10787
|
+
port2
|
|
10788
|
+
} = new MessageChannel();
|
|
10789
|
+
const context = canvas.getContext('bitmaprenderer');
|
|
10790
|
+
if (!context) {
|
|
10791
|
+
port1.close();
|
|
10792
|
+
port2.close();
|
|
10793
|
+
throw new Error('Canvas bitmap presentation is unavailable');
|
|
10794
|
+
}
|
|
10795
|
+
let disposed = false;
|
|
10796
|
+
const dispose = () => {
|
|
10797
|
+
if (disposed) return;
|
|
10798
|
+
disposed = true;
|
|
10799
|
+
port1.onmessage = null;
|
|
10800
|
+
port1.close();
|
|
10801
|
+
onDispose();
|
|
10802
|
+
};
|
|
10803
|
+
port1.onmessage = event => {
|
|
10804
|
+
const {
|
|
10805
|
+
bitmap,
|
|
10806
|
+
type
|
|
10807
|
+
} = event.data;
|
|
10808
|
+
if (type === 'dispose') {
|
|
10809
|
+
dispose();
|
|
10810
|
+
return;
|
|
10811
|
+
}
|
|
10812
|
+
if (type !== 'frame') return;
|
|
10813
|
+
try {
|
|
10814
|
+
context.transferFromImageBitmap(bitmap);
|
|
10815
|
+
} finally {
|
|
10816
|
+
bitmap.close();
|
|
10817
|
+
port1.postMessage({
|
|
10818
|
+
type: 'presented'
|
|
10819
|
+
});
|
|
10820
|
+
}
|
|
10821
|
+
};
|
|
10822
|
+
return {
|
|
10823
|
+
dispose,
|
|
10824
|
+
port: port2
|
|
10825
|
+
};
|
|
10826
|
+
};
|
|
10827
|
+
|
|
10828
|
+
const getIsFirefox = () => {
|
|
10829
|
+
if (typeof navigator === 'undefined') {
|
|
10830
|
+
return false;
|
|
10831
|
+
}
|
|
10832
|
+
if (
|
|
10833
|
+
// @ts-expect-error
|
|
10834
|
+
globalThis.navigator.userAgentData?.brands) {
|
|
10835
|
+
// @ts-expect-error
|
|
10836
|
+
return globalThis.navigator.userAgentData.brands.includes('Firefox');
|
|
10837
|
+
}
|
|
10838
|
+
return navigator.userAgent.toLowerCase().includes('firefox');
|
|
10839
|
+
};
|
|
10840
|
+
|
|
10784
10841
|
const state$1 = {
|
|
10785
10842
|
canvasObjects: Object.create(null)
|
|
10786
10843
|
};
|
|
@@ -10812,6 +10869,36 @@ const create2 = async (canvasId, objectId, width, height) => {
|
|
|
10812
10869
|
});
|
|
10813
10870
|
await invokeAndTransfer('Transferrable.transfer', objectId, offscreenCanvas);
|
|
10814
10871
|
};
|
|
10872
|
+
const createForPreview = async (canvasId, objectId, portId, width, height) => {
|
|
10873
|
+
if (!getIsFirefox()) {
|
|
10874
|
+
await create2(canvasId, objectId, width, height);
|
|
10875
|
+
return false;
|
|
10876
|
+
}
|
|
10877
|
+
// Firefox can lose automatic WebGL presentation when a preview canvas is reinserted.
|
|
10878
|
+
const canvas = document.createElement('canvas');
|
|
10879
|
+
canvas.width = width;
|
|
10880
|
+
canvas.height = height;
|
|
10881
|
+
canvas.dataset.id = String(canvasId);
|
|
10882
|
+
const offscreen = new OffscreenCanvas(width, height);
|
|
10883
|
+
const presentation = createCanvasPresentation(canvas, () => set$c(canvasId, undefined));
|
|
10884
|
+
// Keep the receiving port reachable until the sandbox disposes this canvas.
|
|
10885
|
+
set$c(canvasId, {
|
|
10886
|
+
factory: {},
|
|
10887
|
+
state: {
|
|
10888
|
+
$Viewlet: canvas,
|
|
10889
|
+
canvasPresentation: presentation
|
|
10890
|
+
}
|
|
10891
|
+
});
|
|
10892
|
+
try {
|
|
10893
|
+
await invokeAndTransfer('Transferrable.transfer', objectId, offscreen);
|
|
10894
|
+
await invokeAndTransfer('Transferrable.transfer', portId, presentation.port);
|
|
10895
|
+
} catch (error) {
|
|
10896
|
+
presentation.dispose();
|
|
10897
|
+
presentation.port.close();
|
|
10898
|
+
throw error;
|
|
10899
|
+
}
|
|
10900
|
+
return true;
|
|
10901
|
+
};
|
|
10815
10902
|
|
|
10816
10903
|
const redirectToUrl = url => {
|
|
10817
10904
|
window.location.assign(url);
|
|
@@ -12122,6 +12209,7 @@ const commandMap = {
|
|
|
12122
12209
|
'ObjectUrl.revoke': revokeObjectUrl,
|
|
12123
12210
|
'OffscreenCanvas.create': create$2,
|
|
12124
12211
|
'OffscreenCanvas.create2': create2,
|
|
12212
|
+
'OffscreenCanvas.createForPreview': createForPreview,
|
|
12125
12213
|
'Open.openUrl': openUrl,
|
|
12126
12214
|
'Open.redirectToUrl': redirectToUrl,
|
|
12127
12215
|
'Performance.getMemory': getMemory,
|
|
@@ -12305,19 +12393,6 @@ const isActualSourceFile = path => {
|
|
|
12305
12393
|
return !(path === '<anonymous>' || path === 'debugger eval code' || path.startsWith('"') || path.startsWith(`'`) || path.startsWith(')') || path.startsWith('file://'));
|
|
12306
12394
|
};
|
|
12307
12395
|
|
|
12308
|
-
const getIsFirefox = () => {
|
|
12309
|
-
if (typeof navigator === 'undefined') {
|
|
12310
|
-
return false;
|
|
12311
|
-
}
|
|
12312
|
-
if (
|
|
12313
|
-
// @ts-expect-error
|
|
12314
|
-
globalThis.navigator.userAgentData?.brands) {
|
|
12315
|
-
// @ts-expect-error
|
|
12316
|
-
return globalThis.navigator.userAgentData.brands.includes('Firefox');
|
|
12317
|
-
}
|
|
12318
|
-
return navigator.userAgent.toLowerCase().includes('firefox');
|
|
12319
|
-
};
|
|
12320
|
-
|
|
12321
12396
|
const getErrorMessage = error => {
|
|
12322
12397
|
if (!error) {
|
|
12323
12398
|
return `Error: ${error}`;
|