@lvce-editor/renderer-process 30.36.0 → 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
|
|
1226
|
+
const fileHandle = await item.getAsFileSystemHandle();
|
|
1226
1227
|
return {
|
|
1227
|
-
file:
|
|
1228
|
+
file: nativeFile,
|
|
1228
1229
|
kind: 'file',
|
|
1229
1230
|
type: item.type,
|
|
1230
|
-
value:
|
|
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
|
|
373
|
+
const fileHandle = await item.getAsFileSystemHandle();
|
|
373
374
|
return {
|
|
374
|
-
file:
|
|
375
|
+
file: nativeFile,
|
|
375
376
|
kind: 'file',
|
|
376
377
|
type: item.type,
|
|
377
|
-
value:
|
|
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
|
|
1981
|
-
return
|
|
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
|
};
|
|
@@ -10475,6 +10510,18 @@ const flushPendingData = state => {
|
|
|
10475
10510
|
}
|
|
10476
10511
|
pendingData.length = 0;
|
|
10477
10512
|
};
|
|
10513
|
+
const focusIfConnected = state => {
|
|
10514
|
+
const {
|
|
10515
|
+
$Viewlet,
|
|
10516
|
+
pendingFocus,
|
|
10517
|
+
terminal
|
|
10518
|
+
} = state;
|
|
10519
|
+
if (!pendingFocus || !terminal || !$Viewlet.isConnected) {
|
|
10520
|
+
return;
|
|
10521
|
+
}
|
|
10522
|
+
state.pendingFocus = false;
|
|
10523
|
+
terminal.focus();
|
|
10524
|
+
};
|
|
10478
10525
|
const mountTerminal = async (state, uid) => {
|
|
10479
10526
|
const {
|
|
10480
10527
|
fitAddon,
|
|
@@ -10499,6 +10546,7 @@ const mountTerminal = async (state, uid) => {
|
|
|
10499
10546
|
terminal.open(state.$Viewlet);
|
|
10500
10547
|
const resizeObserver = new ResizeObserver(() => {
|
|
10501
10548
|
fitAddon.fit();
|
|
10549
|
+
focusIfConnected(state);
|
|
10502
10550
|
});
|
|
10503
10551
|
resizeObserver.observe(state.$Viewlet);
|
|
10504
10552
|
state.fitAddon = fitAddon;
|
|
@@ -10507,10 +10555,7 @@ const mountTerminal = async (state, uid) => {
|
|
|
10507
10555
|
state.disposables = [inputDisposable, resizeDisposable];
|
|
10508
10556
|
fitAddon.fit();
|
|
10509
10557
|
flushPendingData(state);
|
|
10510
|
-
|
|
10511
|
-
state.pendingFocus = false;
|
|
10512
|
-
terminal.focus();
|
|
10513
|
-
}
|
|
10558
|
+
focusIfConnected(state);
|
|
10514
10559
|
};
|
|
10515
10560
|
const create = () => {
|
|
10516
10561
|
const $Viewlet = document.createElement('div');
|
|
@@ -10554,7 +10599,7 @@ const focus = state => {
|
|
|
10554
10599
|
const {
|
|
10555
10600
|
terminal
|
|
10556
10601
|
} = state;
|
|
10557
|
-
if (!terminal) {
|
|
10602
|
+
if (!terminal || !state.$Viewlet.isConnected) {
|
|
10558
10603
|
state.pendingFocus = true;
|
|
10559
10604
|
return;
|
|
10560
10605
|
}
|