@lvce-editor/renderer-process 30.36.1 → 30.36.2

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.
@@ -1221,13 +1221,14 @@ const unwrapItemString = async item => {
1221
1221
  const unwrapItemFile = async item => {
1222
1222
  // @ts-ignore
1223
1223
  if (item.getAsFileSystemHandle) {
1224
+ const nativeFile = item.getAsFile();
1224
1225
  // @ts-ignore
1225
- const file = await item.getAsFileSystemHandle();
1226
+ const fileHandle = await item.getAsFileSystemHandle();
1226
1227
  return {
1227
- file: item.getAsFile(),
1228
+ file: nativeFile,
1228
1229
  kind: 'file',
1229
1230
  type: item.type,
1230
- value: file
1231
+ value: fileHandle
1231
1232
  };
1232
1233
  }
1233
1234
  const file = item.getAsFile();
@@ -368,13 +368,14 @@ const unwrapItemString = async item => {
368
368
  const unwrapItemFile = async item => {
369
369
  // @ts-ignore
370
370
  if (item.getAsFileSystemHandle) {
371
+ const nativeFile = item.getAsFile();
371
372
  // @ts-ignore
372
- const file = await item.getAsFileSystemHandle();
373
+ const fileHandle = await item.getAsFileSystemHandle();
373
374
  return {
374
- file: item.getAsFile(),
375
+ file: nativeFile,
375
376
  kind: 'file',
376
377
  type: item.type,
377
- value: file
378
+ value: fileHandle
378
379
  };
379
380
  }
380
381
  const file = item.getAsFile();
@@ -1977,8 +1978,57 @@ const downloadFile = (fileName, url) => {
1977
1978
  a.click();
1978
1979
  };
1979
1980
 
1980
- const get$5 = ids => {
1981
- return getFileHandles$1(ids);
1981
+ const isFile = value => {
1982
+ return value instanceof File;
1983
+ };
1984
+
1985
+ const getFilePathElectron = async file => {
1986
+ if (!isFile(file)) {
1987
+ throw new TypeError(`file must be of type File`);
1988
+ }
1989
+ if (!globalThis.electronGlobals) {
1990
+ throw new Error(`electron globals are not available`);
1991
+ }
1992
+ const filePath = globalThis.electronGlobals.getPathForFile(file);
1993
+ return filePath;
1994
+ };
1995
+
1996
+ const isFileSystemFileHandle = value => {
1997
+ if (!value || typeof value !== 'object') {
1998
+ return false;
1999
+ }
2000
+ const candidate = value;
2001
+ return candidate.kind === 'file' && typeof candidate.getFile === 'function';
2002
+ };
2003
+ const getNativeFile = async item => {
2004
+ if (item.kind === 'file-legacy') {
2005
+ return item.value instanceof File ? item.value : undefined;
2006
+ }
2007
+ if (item.file instanceof File) {
2008
+ return item.file;
2009
+ }
2010
+ if (isFileSystemFileHandle(item.value)) {
2011
+ return item.value.getFile();
2012
+ }
2013
+ return undefined;
2014
+ };
2015
+ const addElectronPath = async item => {
2016
+ if (!globalThis.electronGlobals) {
2017
+ return item;
2018
+ }
2019
+ const file = await getNativeFile(item);
2020
+ if (!file) {
2021
+ return item;
2022
+ }
2023
+ const path = await getFilePathElectron(file);
2024
+ return {
2025
+ ...item,
2026
+ path
2027
+ };
2028
+ };
2029
+ const get$5 = async ids => {
2030
+ const items = await getFileHandles$1(ids);
2031
+ return Promise.all(items.map(addElectronPath));
1982
2032
  };
1983
2033
 
1984
2034
  const showDirectoryPicker = options => {
@@ -9576,21 +9626,6 @@ const unmock = () => {
9576
9626
  Element.prototype.releasePointerCapture = originalPointerCapture.releasePointerCapture;
9577
9627
  };
9578
9628
 
9579
- const isFile = value => {
9580
- return value instanceof File;
9581
- };
9582
-
9583
- const getFilePathElectron = async file => {
9584
- if (!isFile(file)) {
9585
- throw new TypeError(`file must be of type File`);
9586
- }
9587
- if (!globalThis.electronGlobals) {
9588
- throw new Error(`electron globals are not available`);
9589
- }
9590
- const filePath = globalThis.electronGlobals.getPathForFile(file);
9591
- return filePath;
9592
- };
9593
-
9594
9629
  const forwardRendererWorkerCommand = (method, ...params) => {
9595
9630
  send$1(method, ...params);
9596
9631
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.36.1",
3
+ "version": "30.36.2",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"