@lvce-editor/renderer-process 30.69.1 → 30.69.3
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 +55 -1
- package/package.json +1 -1
|
@@ -10491,7 +10491,53 @@ const showDirectoryPicker = options => {
|
|
|
10491
10491
|
};
|
|
10492
10492
|
const showFilePicker = options => {
|
|
10493
10493
|
// @ts-expect-error
|
|
10494
|
-
|
|
10494
|
+
if (typeof window.showOpenFilePicker === 'function') {
|
|
10495
|
+
// @ts-expect-error
|
|
10496
|
+
return window.showOpenFilePicker(options);
|
|
10497
|
+
}
|
|
10498
|
+
return showFilePickerFallback(options);
|
|
10499
|
+
};
|
|
10500
|
+
const showFilePickerFallback = options => {
|
|
10501
|
+
const input = document.createElement('input');
|
|
10502
|
+
input.type = 'file';
|
|
10503
|
+
input.multiple = Boolean(options?.multiple);
|
|
10504
|
+
if (options?.accept) {
|
|
10505
|
+
input.accept = options.accept;
|
|
10506
|
+
}
|
|
10507
|
+
document.body.append(input);
|
|
10508
|
+
return new Promise((resolve, reject) => {
|
|
10509
|
+
const cleanup = () => {
|
|
10510
|
+
input.removeEventListener('change', onChange);
|
|
10511
|
+
input.removeEventListener('cancel', onCancel);
|
|
10512
|
+
input.remove();
|
|
10513
|
+
};
|
|
10514
|
+
const onChange = () => {
|
|
10515
|
+
const files = Array.from(input.files || [], file => ({
|
|
10516
|
+
file,
|
|
10517
|
+
kind: 'file',
|
|
10518
|
+
name: file.name,
|
|
10519
|
+
readonly: true
|
|
10520
|
+
}));
|
|
10521
|
+
cleanup();
|
|
10522
|
+
resolve(files);
|
|
10523
|
+
};
|
|
10524
|
+
const onCancel = () => {
|
|
10525
|
+
cleanup();
|
|
10526
|
+
resolve([]);
|
|
10527
|
+
};
|
|
10528
|
+
input.addEventListener('change', onChange, {
|
|
10529
|
+
once: true
|
|
10530
|
+
});
|
|
10531
|
+
input.addEventListener('cancel', onCancel, {
|
|
10532
|
+
once: true
|
|
10533
|
+
});
|
|
10534
|
+
try {
|
|
10535
|
+
input.click();
|
|
10536
|
+
} catch (error) {
|
|
10537
|
+
cleanup();
|
|
10538
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
10539
|
+
}
|
|
10540
|
+
});
|
|
10495
10541
|
};
|
|
10496
10542
|
const showSaveFilePicker = options => {
|
|
10497
10543
|
// @ts-expect-error
|
|
@@ -10797,9 +10843,17 @@ const createCanvasPresentation = (canvas, onDispose) => {
|
|
|
10797
10843
|
if (disposed) return;
|
|
10798
10844
|
disposed = true;
|
|
10799
10845
|
port1.onmessage = null;
|
|
10846
|
+
port1.onmessageerror = null;
|
|
10800
10847
|
port1.close();
|
|
10801
10848
|
onDispose();
|
|
10802
10849
|
};
|
|
10850
|
+
port1.onmessageerror = () => {
|
|
10851
|
+
// Firefox can reject a transferred bitmap while decoding the message.
|
|
10852
|
+
// Release the sender's single frame slot so the next frame can recover.
|
|
10853
|
+
if (!disposed) port1.postMessage({
|
|
10854
|
+
type: 'presented'
|
|
10855
|
+
});
|
|
10856
|
+
};
|
|
10803
10857
|
port1.onmessage = event => {
|
|
10804
10858
|
const {
|
|
10805
10859
|
bitmap,
|