Skip to content

Commit 589411f

Browse files
committed
chore: refactor apis for clean seperation of app and fs apis
1 parent 6e16706 commit 589411f

17 files changed

Lines changed: 337 additions & 293 deletions

dist/virtualfs-debug.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18897,7 +18897,7 @@ let $f1a90a4a391136ce$var$preferNodeWs = false, $f1a90a4a391136ce$var$forceNodeW
1889718897
options = options || {
1889818898
multiple: false
1889918899
};
18900-
if (!options.defaultPath) options.defaultPath = await globalObject.electronAPI.documentDir();
18900+
if (!options.defaultPath) options.defaultPath = await globalObject.electronFSAPI.documentDir();
1890118901
const dialogOptions = {
1890218902
defaultPath: options.defaultPath,
1890318903
title: options.title,
@@ -18908,7 +18908,7 @@ let $f1a90a4a391136ce$var$preferNodeWs = false, $f1a90a4a391136ce$var$forceNodeW
1890818908
if (options.multiple) dialogOptions.properties.push("multiSelections");
1890918909
if (options.filters) dialogOptions.filters = options.filters;
1891018910
try {
18911-
const filePaths = await globalObject.electronAPI.showOpenDialog(dialogOptions);
18911+
const filePaths = await globalObject.electronFSAPI.showOpenDialog(dialogOptions);
1891218912
if (!filePaths || filePaths.length === 0) return null;
1891318913
if (options.multiple) return filePaths.map((p)=>$f1a90a4a391136ce$require$Utils.getTauriVirtualPath(p));
1891418914
return $f1a90a4a391136ce$require$Utils.getTauriVirtualPath(filePaths[0]);
@@ -18927,14 +18927,14 @@ let $f1a90a4a391136ce$var$preferNodeWs = false, $f1a90a4a391136ce$var$forceNodeW
1892718927
* @returns {Promise<string|null>} A promise that resolves to the selected file path or null.
1892818928
*/ async function $f1a90a4a391136ce$var$openElectronFileSaveDialogueAsync(options) {
1892918929
options = options || {};
18930-
if (!options.defaultPath) options.defaultPath = await globalObject.electronAPI.documentDir();
18930+
if (!options.defaultPath) options.defaultPath = await globalObject.electronFSAPI.documentDir();
1893118931
const dialogOptions = {
1893218932
defaultPath: options.defaultPath,
1893318933
title: options.title
1893418934
};
1893518935
if (options.filters) dialogOptions.filters = options.filters;
1893618936
try {
18937-
const filePath = await globalObject.electronAPI.showSaveDialog(dialogOptions);
18937+
const filePath = await globalObject.electronFSAPI.showSaveDialog(dialogOptions);
1893818938
if (typeof filePath === "string" && filePath) return $f1a90a4a391136ce$require$Utils.getTauriVirtualPath(filePath);
1893918939
return null;
1894018940
} catch (err) {
@@ -18943,7 +18943,7 @@ let $f1a90a4a391136ce$var$preferNodeWs = false, $f1a90a4a391136ce$var$forceNodeW
1894318943
}
1894418944
async function $f1a90a4a391136ce$var$_getElectronStat(vfsPath) {
1894518945
const platformPath = globalObject.fs.getTauriPlatformPath(vfsPath);
18946-
const stats = await $f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronAPI.fsStat(platformPath));
18946+
const stats = await $f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronFSAPI.fsStat(platformPath));
1894718947
return $f1a90a4a391136ce$require$Utils.createFromNodeStat(vfsPath, stats, $f1a90a4a391136ce$require$Constants.ELECTRON_DEVICE_NAME);
1894818948
}
1894918949
function $f1a90a4a391136ce$var$_readDirHelper(entries, path, options, callback, useDummyStats) {
@@ -18976,7 +18976,7 @@ function $f1a90a4a391136ce$var$_readDirHelper(entries, path, options, callback,
1897618976
return;
1897718977
}
1897818978
const platformPath = $f1a90a4a391136ce$require$Utils.getTauriPlatformPath(path);
18979-
$f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronAPI.fsReaddir(platformPath)).then((entries)=>{
18979+
$f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronFSAPI.fsReaddir(platformPath)).then((entries)=>{
1898018980
$f1a90a4a391136ce$var$_readDirHelper(entries, path, options, callback);
1898118981
}).catch((err)=>{
1898218982
callback($f1a90a4a391136ce$var$mapNodeErrorMessage(err, path, "Failed to read directory: "));
@@ -19000,7 +19000,7 @@ function $f1a90a4a391136ce$var$_readDirHelper(entries, path, options, callback,
1900019000
return;
1900119001
}
1900219002
const platformPath = $f1a90a4a391136ce$require$Utils.getTauriPlatformPath(path);
19003-
$f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronAPI.fsMkdir(platformPath, {
19003+
$f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronFSAPI.fsMkdir(platformPath, {
1900419004
recursive: recursive,
1900519005
mode: mode
1900619006
})).then(()=>{
@@ -19028,12 +19028,12 @@ function $f1a90a4a391136ce$var$unlink(path, callback) {
1902819028
}
1902919029
$f1a90a4a391136ce$var$_getElectronStat(path).then((stat)=>{
1903019030
const platformPath = $f1a90a4a391136ce$require$Utils.getTauriPlatformPath(path);
19031-
if (stat.isDirectory()) $f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronAPI.fsRmdir(platformPath, {
19031+
if (stat.isDirectory()) $f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronFSAPI.fsRmdir(platformPath, {
1903219032
recursive: true
1903319033
})).then(()=>{
1903419034
callback(null);
1903519035
}).catch(errCallback);
19036-
else $f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronAPI.fsUnlink(platformPath)).then(()=>{
19036+
else $f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronFSAPI.fsUnlink(platformPath)).then(()=>{
1903719037
callback(null);
1903819038
}).catch(errCallback);
1903919039
}).catch(errCallback);
@@ -19047,7 +19047,7 @@ function $f1a90a4a391136ce$var$rename(oldPath, newPath, callback) {
1904719047
}
1904819048
const oldPlatformPath = $f1a90a4a391136ce$require$Utils.getTauriPlatformPath(oldPath);
1904919049
const newPlatformPath = $f1a90a4a391136ce$require$Utils.getTauriPlatformPath(newPath);
19050-
$f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronAPI.fsRename(oldPlatformPath, newPlatformPath)).then(()=>{
19050+
$f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronFSAPI.fsRename(oldPlatformPath, newPlatformPath)).then(()=>{
1905119051
callback(null);
1905219052
}).catch((err)=>{
1905319053
callback($f1a90a4a391136ce$var$mapNodeErrorMessage(err, oldPath, `Failed to rename ${oldPath} to ${newPath}`));
@@ -19089,7 +19089,7 @@ function $f1a90a4a391136ce$var$rename(oldPath, newPath, callback) {
1908919089
return;
1909019090
}
1909119091
const platformPath = $f1a90a4a391136ce$require$Utils.getTauriPlatformPath(path);
19092-
$f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronAPI.fsReadFile(platformPath)).then((contents)=>{
19092+
$f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronFSAPI.fsReadFile(platformPath)).then((contents)=>{
1909319093
// Electron returns a Buffer, convert to ArrayBuffer
1909419094
let arrayBuffer;
1909519095
if (contents instanceof ArrayBuffer) arrayBuffer = contents;
@@ -19131,7 +19131,7 @@ function $f1a90a4a391136ce$var$rename(oldPath, newPath, callback) {
1913119131
const platformPath = $f1a90a4a391136ce$require$Utils.getTauriPlatformPath(path);
1913219132
// Convert ArrayBuffer to Uint8Array for IPC transfer
1913319133
const uint8Array = new Uint8Array(arrayBuffer);
19134-
$f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronAPI.fsWriteFile(platformPath, Array.from(uint8Array))).then(()=>{
19134+
$f1a90a4a391136ce$var$unwrapFsResult(globalObject.electronFSAPI.fsWriteFile(platformPath, Array.from(uint8Array))).then(()=>{
1913519135
callback(null);
1913619136
}).catch((err)=>{
1913719137
callback($f1a90a4a391136ce$var$mapNodeErrorMessage(err, path, `Failed to write File at path ${path}`));

dist/virtualfs-debug.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/virtualfs.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/virtualfs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)