@lvce-editor/file-system-worker 1.11.0 → 1.13.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.
@@ -1076,6 +1076,14 @@ const readFile$3 = async uri => {
1076
1076
  const result = await response.text();
1077
1077
  return result;
1078
1078
  };
1079
+ const readFileAsBlob$1 = async uri => {
1080
+ const response = await fetch(uri);
1081
+ if (!response.ok) {
1082
+ throw new Error(response.statusText);
1083
+ }
1084
+ const result = await response.blob();
1085
+ return result;
1086
+ };
1079
1087
  const exists$2 = async uri => {
1080
1088
  const response = await fetch(uri);
1081
1089
  if (response.ok) {
@@ -1200,7 +1208,6 @@ const RendererWorker = {
1200
1208
  invokeAndTransfer: invokeAndTransfer$3,
1201
1209
  set: set$3};
1202
1210
 
1203
- // @ts-ignore
1204
1211
  const {
1205
1212
  set: set$1,
1206
1213
  rename: rename$1,
@@ -1245,6 +1252,22 @@ const readJson = async uri => {
1245
1252
  const getRealPath = async path => {
1246
1253
  return getRealPath$1(path);
1247
1254
  };
1255
+ const readFileAsBlob = async uri => {
1256
+ if (isHttp(uri)) {
1257
+ return readFileAsBlob$1(uri);
1258
+ }
1259
+ if (uri.startsWith('file:///')) {
1260
+ const rest = uri.slice('file:///'.length);
1261
+ const remoteUrl = `/remote/${rest}`;
1262
+ const response = await fetch(remoteUrl);
1263
+ if (!response.ok) {
1264
+ throw new Error(response.statusText);
1265
+ }
1266
+ const blob = await response.blob();
1267
+ return blob;
1268
+ }
1269
+ throw new Error('uri not supported');
1270
+ };
1248
1271
  const stat = async dirent => {
1249
1272
  return stat$1(dirent);
1250
1273
  };
@@ -1329,6 +1352,7 @@ const createFileSystemProcessRpcNode = async () => {
1329
1352
  }
1330
1353
  };
1331
1354
 
1355
+ const Web = 1;
1332
1356
  const Electron = 2;
1333
1357
  const Remote = 3;
1334
1358
 
@@ -1348,11 +1372,18 @@ const createFileSystemProcessRpc = async platform => {
1348
1372
  return create();
1349
1373
  };
1350
1374
 
1351
- const initialize = async platform => {
1375
+ const initializeFileSytemProcess = async platform => {
1376
+ if (platform === Web) {
1377
+ return;
1378
+ }
1352
1379
  const rpc = await createFileSystemProcessRpc(platform);
1353
1380
  set$1(rpc);
1354
1381
  };
1355
1382
 
1383
+ const initialize = async platform => {
1384
+ await initializeFileSytemProcess(platform);
1385
+ };
1386
+
1356
1387
  const commandMap = {
1357
1388
  'FileSystem.copy': copy,
1358
1389
  'FileSystem.createFile': createFile,
@@ -1369,6 +1400,7 @@ const commandMap = {
1369
1400
  'FileSystem.stat': stat,
1370
1401
  'FileSystem.writeFile': writeFile,
1371
1402
  'FileSystem.handleMessagePort': handleMessagePort,
1403
+ 'FileSystem.readFileAsBlob': readFileAsBlob,
1372
1404
  'Initialize.initialize': initialize
1373
1405
  };
1374
1406
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-system-worker",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "File System Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"