@lvce-editor/file-system-worker 1.12.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) {
@@ -1244,6 +1252,22 @@ const readJson = async uri => {
1244
1252
  const getRealPath = async path => {
1245
1253
  return getRealPath$1(path);
1246
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
+ };
1247
1271
  const stat = async dirent => {
1248
1272
  return stat$1(dirent);
1249
1273
  };
@@ -1376,6 +1400,7 @@ const commandMap = {
1376
1400
  'FileSystem.stat': stat,
1377
1401
  'FileSystem.writeFile': writeFile,
1378
1402
  'FileSystem.handleMessagePort': handleMessagePort,
1403
+ 'FileSystem.readFileAsBlob': readFileAsBlob,
1379
1404
  'Initialize.initialize': initialize
1380
1405
  };
1381
1406
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-system-worker",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "File System Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"