@lvce-editor/file-system-worker 1.7.0 → 1.9.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.
@@ -988,6 +988,10 @@ const create$5 = async ({
988
988
  messagePort.start();
989
989
  return rpc;
990
990
  };
991
+ const PlainMessagePortRpc = {
992
+ __proto__: null,
993
+ create: create$5
994
+ };
991
995
  const create$4 = async ({
992
996
  commandMap,
993
997
  messagePort
@@ -1015,11 +1019,11 @@ const create$2 = async ({
1015
1019
  const rpc = createRpc(ipc);
1016
1020
  return rpc;
1017
1021
  };
1018
- const Https = 'https:';
1022
+ const Https$1 = 'https:';
1019
1023
  const Ws = 'ws:';
1020
1024
  const Wss = 'wss:';
1021
1025
  const getWebSocketProtocol = locationProtocol => {
1022
- return locationProtocol === Https ? Wss : Ws;
1026
+ return locationProtocol === Https$1 ? Wss : Ws;
1023
1027
  };
1024
1028
  const getWebSocketUrl = (type, host, locationProtocol) => {
1025
1029
  const wsProtocol = getWebSocketProtocol(locationProtocol);
@@ -1064,6 +1068,15 @@ const WebWorkerRpcClient = {
1064
1068
  create: create$3
1065
1069
  };
1066
1070
 
1071
+ const readFile$2 = async uri => {
1072
+ const response = await fetch(uri);
1073
+ if (!response.ok) {
1074
+ throw new Error(response.statusText);
1075
+ }
1076
+ const result = await response.text();
1077
+ return result;
1078
+ };
1079
+
1067
1080
  const rpcs = Object.create(null);
1068
1081
  const set$g = (id, rpc) => {
1069
1082
  rpcs[id] = rpc;
@@ -1191,10 +1204,16 @@ const {
1191
1204
  remove: remove$1
1192
1205
  } = FileSystemProcess;
1193
1206
 
1207
+ const Http = 'http:';
1208
+ const Https = 'https:';
1209
+
1194
1210
  const remove = async dirent => {
1195
1211
  return remove$1(dirent);
1196
1212
  };
1197
1213
  const readFile = async uri => {
1214
+ if (uri.startsWith(Http) || uri.startsWith(Https)) {
1215
+ return readFile$2(uri);
1216
+ }
1198
1217
  return readFile$1(uri);
1199
1218
  };
1200
1219
  const readDirWithFileTypes = async uri => {
@@ -1231,6 +1250,13 @@ const getFolderSize = async uri => {
1231
1250
  return getFolderSize$1(uri);
1232
1251
  };
1233
1252
 
1253
+ const handleMessagePort = async (port, rpcId) => {
1254
+ await PlainMessagePortRpc.create({
1255
+ commandMap: {},
1256
+ messagePort: port
1257
+ });
1258
+ };
1259
+
1234
1260
  const getPortTuple = () => {
1235
1261
  const {
1236
1262
  port1,
@@ -1318,6 +1344,7 @@ const commandMap = {
1318
1344
  'FileSystem.stat': stat,
1319
1345
  'FileSystem.writeFile': writeFile,
1320
1346
  'FileSystem.getFolderSize': getFolderSize,
1347
+ 'FileSystem.handleMessagePort': handleMessagePort,
1321
1348
  'Initialize.initialize': initialize
1322
1349
  };
1323
1350
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-system-worker",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "File System Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"