@lvce-editor/file-system-worker 1.9.0 → 1.10.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/fileSystemWorkerMain.js +22 -3
- package/package.json +1 -1
|
@@ -1076,6 +1076,13 @@ const readFile$2 = async uri => {
|
|
|
1076
1076
|
const result = await response.text();
|
|
1077
1077
|
return result;
|
|
1078
1078
|
};
|
|
1079
|
+
const exists$2 = async uri => {
|
|
1080
|
+
const response = await fetch(uri);
|
|
1081
|
+
if (response.ok) {
|
|
1082
|
+
return true;
|
|
1083
|
+
}
|
|
1084
|
+
return false;
|
|
1085
|
+
};
|
|
1079
1086
|
|
|
1080
1087
|
const rpcs = Object.create(null);
|
|
1081
1088
|
const set$g = (id, rpc) => {
|
|
@@ -1188,6 +1195,7 @@ const RendererWorker = {
|
|
|
1188
1195
|
invokeAndTransfer: invokeAndTransfer$3,
|
|
1189
1196
|
set: set$3};
|
|
1190
1197
|
|
|
1198
|
+
// @ts-ignore
|
|
1191
1199
|
const {
|
|
1192
1200
|
set: set$1,
|
|
1193
1201
|
rename: rename$1,
|
|
@@ -1201,7 +1209,8 @@ const {
|
|
|
1201
1209
|
getRealPath: getRealPath$1,
|
|
1202
1210
|
readDirWithFileTypes: readDirWithFileTypes$1,
|
|
1203
1211
|
readFile: readFile$1,
|
|
1204
|
-
remove: remove$1
|
|
1212
|
+
remove: remove$1,
|
|
1213
|
+
exists: exists$1
|
|
1205
1214
|
} = FileSystemProcess;
|
|
1206
1215
|
|
|
1207
1216
|
const Http = 'http:';
|
|
@@ -1210,8 +1219,11 @@ const Https = 'https:';
|
|
|
1210
1219
|
const remove = async dirent => {
|
|
1211
1220
|
return remove$1(dirent);
|
|
1212
1221
|
};
|
|
1222
|
+
const isHttp = uri => {
|
|
1223
|
+
return uri.startsWith(Http) || uri.startsWith(Https);
|
|
1224
|
+
};
|
|
1213
1225
|
const readFile = async uri => {
|
|
1214
|
-
if (
|
|
1226
|
+
if (isHttp(uri)) {
|
|
1215
1227
|
return readFile$2(uri);
|
|
1216
1228
|
}
|
|
1217
1229
|
return readFile$1(uri);
|
|
@@ -1231,6 +1243,12 @@ const getRealPath = async path => {
|
|
|
1231
1243
|
const stat = async dirent => {
|
|
1232
1244
|
return stat$1(dirent);
|
|
1233
1245
|
};
|
|
1246
|
+
const exists = async uri => {
|
|
1247
|
+
if (isHttp(uri)) {
|
|
1248
|
+
return exists$2(uri);
|
|
1249
|
+
}
|
|
1250
|
+
return exists$1(uri);
|
|
1251
|
+
};
|
|
1234
1252
|
const createFile = async uri => {
|
|
1235
1253
|
return writeFile$1(uri, '');
|
|
1236
1254
|
};
|
|
@@ -1333,6 +1351,8 @@ const initialize = async platform => {
|
|
|
1333
1351
|
const commandMap = {
|
|
1334
1352
|
'FileSystem.copy': copy,
|
|
1335
1353
|
'FileSystem.createFile': createFile,
|
|
1354
|
+
'FileSystem.exists': exists,
|
|
1355
|
+
'FileSystem.getFolderSize': getFolderSize,
|
|
1336
1356
|
'FileSystem.getPathSeparator': getPathSeparator,
|
|
1337
1357
|
'FileSystem.getRealPath': getRealPath,
|
|
1338
1358
|
'FileSystem.mkdir': mkdir,
|
|
@@ -1343,7 +1363,6 @@ const commandMap = {
|
|
|
1343
1363
|
'FileSystem.rename': rename,
|
|
1344
1364
|
'FileSystem.stat': stat,
|
|
1345
1365
|
'FileSystem.writeFile': writeFile,
|
|
1346
|
-
'FileSystem.getFolderSize': getFolderSize,
|
|
1347
1366
|
'FileSystem.handleMessagePort': handleMessagePort,
|
|
1348
1367
|
'Initialize.initialize': initialize
|
|
1349
1368
|
};
|