@lvce-editor/renderer-process 30.68.16 → 30.69.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/rendererProcessMain.js +86 -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,34 @@ 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
|
+
set$c(canvasId, {
|
|
10885
|
+
factory: {},
|
|
10886
|
+
state: {
|
|
10887
|
+
$Viewlet: canvas
|
|
10888
|
+
}
|
|
10889
|
+
});
|
|
10890
|
+
try {
|
|
10891
|
+
await invokeAndTransfer('Transferrable.transfer', objectId, offscreen);
|
|
10892
|
+
await invokeAndTransfer('Transferrable.transfer', portId, presentation.port);
|
|
10893
|
+
} catch (error) {
|
|
10894
|
+
presentation.dispose();
|
|
10895
|
+
presentation.port.close();
|
|
10896
|
+
throw error;
|
|
10897
|
+
}
|
|
10898
|
+
return true;
|
|
10899
|
+
};
|
|
10815
10900
|
|
|
10816
10901
|
const redirectToUrl = url => {
|
|
10817
10902
|
window.location.assign(url);
|
|
@@ -12122,6 +12207,7 @@ const commandMap = {
|
|
|
12122
12207
|
'ObjectUrl.revoke': revokeObjectUrl,
|
|
12123
12208
|
'OffscreenCanvas.create': create$2,
|
|
12124
12209
|
'OffscreenCanvas.create2': create2,
|
|
12210
|
+
'OffscreenCanvas.createForPreview': createForPreview,
|
|
12125
12211
|
'Open.openUrl': openUrl,
|
|
12126
12212
|
'Open.redirectToUrl': redirectToUrl,
|
|
12127
12213
|
'Performance.getMemory': getMemory,
|
|
@@ -12305,19 +12391,6 @@ const isActualSourceFile = path => {
|
|
|
12305
12391
|
return !(path === '<anonymous>' || path === 'debugger eval code' || path.startsWith('"') || path.startsWith(`'`) || path.startsWith(')') || path.startsWith('file://'));
|
|
12306
12392
|
};
|
|
12307
12393
|
|
|
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
12394
|
const getErrorMessage = error => {
|
|
12322
12395
|
if (!error) {
|
|
12323
12396
|
return `Error: ${error}`;
|