@lvce-editor/file-system-worker 1.9.0 → 1.11.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.
@@ -1068,7 +1068,7 @@ const WebWorkerRpcClient = {
1068
1068
  create: create$3
1069
1069
  };
1070
1070
 
1071
- const readFile$2 = async uri => {
1071
+ const readFile$3 = async uri => {
1072
1072
  const response = await fetch(uri);
1073
1073
  if (!response.ok) {
1074
1074
  throw new Error(response.statusText);
@@ -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) => {
@@ -1122,7 +1129,7 @@ const {
1122
1129
  const remove$1$1 = async uri => {
1123
1130
  return invoke$8('FileSystem.remove', uri);
1124
1131
  };
1125
- const readFile$1$1 = async uri => {
1132
+ const readFile$2 = async uri => {
1126
1133
  return invoke$8('FileSystem.readFile', uri);
1127
1134
  };
1128
1135
  const readDirWithFileTypes$1$1 = async uri => {
@@ -1160,19 +1167,24 @@ const copy$1$1 = async (oldUri, newUri) => {
1160
1167
  // @ts-ignore
1161
1168
  return invoke$8('FileSystem.copy', oldUri, newUri);
1162
1169
  };
1163
- const getFolderSize$1$1 = async uri => {
1170
+ const getFolderSize$2 = async uri => {
1164
1171
  // @ts-ignore
1165
1172
  return invoke$8('FileSystem.getFolderSize', uri);
1166
1173
  };
1174
+ const exists$1$1 = async uri => {
1175
+ // @ts-ignore
1176
+ return invoke$8('FileSystem.exists', uri);
1177
+ };
1167
1178
  const FileSystemProcess = {
1168
1179
  __proto__: null,
1169
1180
  copy: copy$1$1,
1170
- getFolderSize: getFolderSize$1$1,
1181
+ exists: exists$1$1,
1182
+ getFolderSize: getFolderSize$2,
1171
1183
  getPathSeparator: getPathSeparator$1$1,
1172
1184
  getRealPath: getRealPath$1$1,
1173
1185
  mkdir: mkdir$1$1,
1174
1186
  readDirWithFileTypes: readDirWithFileTypes$1$1,
1175
- readFile: readFile$1$1,
1187
+ readFile: readFile$2,
1176
1188
  readJson: readJson$2,
1177
1189
  remove: remove$1$1,
1178
1190
  rename: rename$1$1,
@@ -1188,6 +1200,7 @@ const RendererWorker = {
1188
1200
  invokeAndTransfer: invokeAndTransfer$3,
1189
1201
  set: set$3};
1190
1202
 
1203
+ // @ts-ignore
1191
1204
  const {
1192
1205
  set: set$1,
1193
1206
  rename: rename$1,
@@ -1201,7 +1214,8 @@ const {
1201
1214
  getRealPath: getRealPath$1,
1202
1215
  readDirWithFileTypes: readDirWithFileTypes$1,
1203
1216
  readFile: readFile$1,
1204
- remove: remove$1
1217
+ remove: remove$1,
1218
+ exists: exists$1
1205
1219
  } = FileSystemProcess;
1206
1220
 
1207
1221
  const Http = 'http:';
@@ -1210,9 +1224,12 @@ const Https = 'https:';
1210
1224
  const remove = async dirent => {
1211
1225
  return remove$1(dirent);
1212
1226
  };
1227
+ const isHttp = uri => {
1228
+ return uri.startsWith(Http) || uri.startsWith(Https);
1229
+ };
1213
1230
  const readFile = async uri => {
1214
- if (uri.startsWith(Http) || uri.startsWith(Https)) {
1215
- return readFile$2(uri);
1231
+ if (isHttp(uri)) {
1232
+ return readFile$3(uri);
1216
1233
  }
1217
1234
  return readFile$1(uri);
1218
1235
  };
@@ -1231,6 +1248,12 @@ const getRealPath = async path => {
1231
1248
  const stat = async dirent => {
1232
1249
  return stat$1(dirent);
1233
1250
  };
1251
+ const exists = async uri => {
1252
+ if (isHttp(uri)) {
1253
+ return exists$2(uri);
1254
+ }
1255
+ return exists$1(uri);
1256
+ };
1234
1257
  const createFile = async uri => {
1235
1258
  return writeFile$1(uri, '');
1236
1259
  };
@@ -1333,6 +1356,8 @@ const initialize = async platform => {
1333
1356
  const commandMap = {
1334
1357
  'FileSystem.copy': copy,
1335
1358
  'FileSystem.createFile': createFile,
1359
+ 'FileSystem.exists': exists,
1360
+ 'FileSystem.getFolderSize': getFolderSize,
1336
1361
  'FileSystem.getPathSeparator': getPathSeparator,
1337
1362
  'FileSystem.getRealPath': getRealPath,
1338
1363
  'FileSystem.mkdir': mkdir,
@@ -1343,7 +1368,6 @@ const commandMap = {
1343
1368
  'FileSystem.rename': rename,
1344
1369
  'FileSystem.stat': stat,
1345
1370
  'FileSystem.writeFile': writeFile,
1346
- 'FileSystem.getFolderSize': getFolderSize,
1347
1371
  'FileSystem.handleMessagePort': handleMessagePort,
1348
1372
  'Initialize.initialize': initialize
1349
1373
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-system-worker",
3
- "version": "1.9.0",
3
+ "version": "1.11.0",
4
4
  "description": "File System Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"