@lvce-editor/file-system-worker 5.1.0 → 5.3.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.
@@ -156,7 +156,8 @@ function binaryStringToArrayBuffer(binary) {
156
156
  }
157
157
 
158
158
  const normalizeBlobError = error => {
159
- if (error && error instanceof ProgressEvent && error.target &&
159
+ const ProgressEventConstructor = globalThis.ProgressEvent;
160
+ if (error && ProgressEventConstructor && error instanceof ProgressEventConstructor && error.target &&
160
161
  // @ts-expect-error - target.error may not be in the type definition
161
162
  error.target.error) {
162
163
  // @ts-expect-error - target.error may not be in the type definition
@@ -238,77 +239,6 @@ const blobToBinaryString = async blob => {
238
239
  }
239
240
  };
240
241
 
241
- const readFile$4 = async uri => {
242
- const response = await fetch(uri);
243
- if (!response.ok) {
244
- throw new Error(response.statusText);
245
- }
246
- const result = await response.text();
247
- return result;
248
- };
249
- const readFileAsBlob$1 = async uri => {
250
- const response = await fetch(uri);
251
- if (!response.ok) {
252
- throw new Error(response.statusText);
253
- }
254
- const result = await response.blob();
255
- return result;
256
- };
257
- const exists$3 = async uri => {
258
- const response = await fetch(uri);
259
- if (response.ok) {
260
- return true;
261
- }
262
- return false;
263
- };
264
- const readJson$4 = async uri => {
265
- const response = await fetch(uri);
266
- if (!response.ok) {
267
- throw new Error(`${response.statusText}`);
268
- }
269
- const json = await response.json();
270
- return json;
271
- };
272
-
273
- const DebugWorker = 55;
274
- const ExtensionHostWorker = 44;
275
- const FileSystemProcess$1 = 210;
276
- const FileSystemWorker = 209;
277
- const RendererProcess = 1670;
278
- const RendererWorker = 1;
279
-
280
- const rpcs = Object.create(null);
281
- const set$5 = (id, rpc) => {
282
- rpcs[id] = rpc;
283
- };
284
- const get$1 = id => {
285
- return rpcs[id];
286
- };
287
-
288
- const create$6 = rpcId => {
289
- return {
290
- async dispose() {
291
- const rpc = get$1(rpcId);
292
- await rpc.dispose();
293
- },
294
- // @ts-ignore
295
- invoke(method, ...params) {
296
- const rpc = get$1(rpcId);
297
- // @ts-ignore
298
- return rpc.invoke(method, ...params);
299
- },
300
- // @ts-ignore
301
- invokeAndTransfer(method, ...params) {
302
- const rpc = get$1(rpcId);
303
- // @ts-ignore
304
- return rpc.invokeAndTransfer(method, ...params);
305
- },
306
- set(rpc) {
307
- set$5(rpcId, rpc);
308
- }
309
- };
310
- };
311
-
312
242
  class AssertionError extends Error {
313
243
  constructor(message) {
314
244
  super(message);
@@ -708,7 +638,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
708
638
  return promise;
709
639
  };
710
640
  const Message$1 = 3;
711
- const create$5 = async ({
641
+ const create$5$1 = async ({
712
642
  isMessagePortOpen,
713
643
  messagePort
714
644
  }) => {
@@ -759,7 +689,7 @@ const wrap$5 = messagePort => {
759
689
  };
760
690
  const IpcParentWithMessagePort$1 = {
761
691
  __proto__: null,
762
- create: create$5,
692
+ create: create$5$1,
763
693
  signal: signal$1,
764
694
  wrap: wrap$5
765
695
  };
@@ -783,7 +713,7 @@ const waitForWebSocketToBeOpen = webSocket => {
783
713
  open: Open
784
714
  });
785
715
  };
786
- const create$3 = async ({
716
+ const create$b = async ({
787
717
  webSocket
788
718
  }) => {
789
719
  const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
@@ -820,16 +750,37 @@ const wrap = webSocket => {
820
750
  };
821
751
  const IpcParentWithWebSocket$1 = {
822
752
  __proto__: null,
823
- create: create$3,
753
+ create: create$b,
824
754
  wrap
825
755
  };
826
756
 
757
+ class CommandNotFoundError extends Error {
758
+ constructor(command) {
759
+ super(`Command not found ${command}`);
760
+ this.name = 'CommandNotFoundError';
761
+ }
762
+ }
763
+ const commands = Object.create(null);
764
+ const register$1 = commandMap => {
765
+ Object.assign(commands, commandMap);
766
+ };
767
+ const getCommand = key => {
768
+ return commands[key];
769
+ };
770
+ const execute = (command, ...args) => {
771
+ const fn = getCommand(command);
772
+ if (!fn) {
773
+ throw new CommandNotFoundError(command);
774
+ }
775
+ return fn(...args);
776
+ };
777
+
827
778
  const Two$1 = '2.0';
828
779
  const callbacks = Object.create(null);
829
- const get = id => {
780
+ const get$1 = id => {
830
781
  return callbacks[id];
831
782
  };
832
- const remove$4 = id => {
783
+ const remove$6 = id => {
833
784
  delete callbacks[id];
834
785
  };
835
786
  class JsonRpcError extends Error {
@@ -848,12 +799,12 @@ const getErrorConstructor = (message, type) => {
848
799
  switch (type) {
849
800
  case DomException:
850
801
  return DOMException;
851
- case TypeError$1:
852
- return TypeError;
853
- case SyntaxError$1:
854
- return SyntaxError;
855
802
  case ReferenceError$1:
856
803
  return ReferenceError;
804
+ case SyntaxError$1:
805
+ return SyntaxError;
806
+ case TypeError$1:
807
+ return TypeError;
857
808
  default:
858
809
  return Error;
859
810
  }
@@ -975,14 +926,14 @@ const warn = (...args) => {
975
926
  console.warn(...args);
976
927
  };
977
928
  const resolve = (id, response) => {
978
- const fn = get(id);
929
+ const fn = get$1(id);
979
930
  if (!fn) {
980
931
  console.log(response);
981
932
  warn(`callback ${id} may already be disposed`);
982
933
  return;
983
934
  }
984
935
  fn(response);
985
- remove$4(id);
936
+ remove$6(id);
986
937
  };
987
938
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
988
939
  const getErrorType = prettyError => {
@@ -1009,27 +960,27 @@ const getErrorProperty = (error, prettyError) => {
1009
960
  if (error && error.code === E_COMMAND_NOT_FOUND) {
1010
961
  return {
1011
962
  code: MethodNotFound,
1012
- message: error.message,
1013
- data: error.stack
963
+ data: error.stack,
964
+ message: error.message
1014
965
  };
1015
966
  }
1016
967
  return {
1017
968
  code: Custom,
1018
- message: prettyError.message,
1019
969
  data: {
1020
- stack: getStack(prettyError),
1021
- codeFrame: prettyError.codeFrame,
1022
- type: getErrorType(prettyError),
1023
970
  code: prettyError.code,
1024
- name: prettyError.name
1025
- }
971
+ codeFrame: prettyError.codeFrame,
972
+ name: prettyError.name,
973
+ stack: getStack(prettyError),
974
+ type: getErrorType(prettyError)
975
+ },
976
+ message: prettyError.message
1026
977
  };
1027
978
  };
1028
979
  const create$1$1 = (id, error) => {
1029
980
  return {
1030
- jsonrpc: Two$1,
981
+ error,
1031
982
  id,
1032
- error
983
+ jsonrpc: Two$1
1033
984
  };
1034
985
  };
1035
986
  const getErrorResponse = (id, error, preparePrettyError, logError) => {
@@ -1038,27 +989,27 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
1038
989
  const errorProperty = getErrorProperty(error, prettyError);
1039
990
  return create$1$1(id, errorProperty);
1040
991
  };
1041
- const create = (message, result) => {
992
+ const create$a = (message, result) => {
1042
993
  return {
1043
- jsonrpc: Two$1,
1044
994
  id: message.id,
995
+ jsonrpc: Two$1,
1045
996
  result: result ?? null
1046
997
  };
1047
998
  };
1048
999
  const getSuccessResponse = (message, result) => {
1049
1000
  const resultProperty = result ?? null;
1050
- return create(message, resultProperty);
1001
+ return create$a(message, resultProperty);
1051
1002
  };
1052
1003
  const getErrorResponseSimple = (id, error) => {
1053
1004
  return {
1054
- jsonrpc: Two$1,
1055
- id,
1056
1005
  error: {
1057
1006
  code: Custom,
1007
+ data: error,
1058
1008
  // @ts-ignore
1059
- message: error.message,
1060
- data: error
1061
- }
1009
+ message: error.message
1010
+ },
1011
+ id,
1012
+ jsonrpc: Two$1
1062
1013
  };
1063
1014
  };
1064
1015
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
@@ -1088,35 +1039,35 @@ const normalizeParams = args => {
1088
1039
  if (args.length === 1) {
1089
1040
  const options = args[0];
1090
1041
  return {
1042
+ execute: options.execute,
1091
1043
  ipc: options.ipc,
1044
+ logError: options.logError || defaultLogError,
1092
1045
  message: options.message,
1093
- execute: options.execute,
1094
- resolve: options.resolve || defaultResolve,
1095
1046
  preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
1096
- logError: options.logError || defaultLogError,
1097
- requiresSocket: options.requiresSocket || defaultRequiresSocket
1047
+ requiresSocket: options.requiresSocket || defaultRequiresSocket,
1048
+ resolve: options.resolve || defaultResolve
1098
1049
  };
1099
1050
  }
1100
1051
  return {
1052
+ execute: args[2],
1101
1053
  ipc: args[0],
1054
+ logError: args[5],
1102
1055
  message: args[1],
1103
- execute: args[2],
1104
- resolve: args[3],
1105
1056
  preparePrettyError: args[4],
1106
- logError: args[5],
1107
- requiresSocket: args[6]
1057
+ requiresSocket: args[6],
1058
+ resolve: args[3]
1108
1059
  };
1109
1060
  };
1110
1061
  const handleJsonRpcMessage = async (...args) => {
1111
1062
  const options = normalizeParams(args);
1112
1063
  const {
1113
- message,
1114
- ipc,
1115
1064
  execute,
1116
- resolve,
1117
- preparePrettyError,
1065
+ ipc,
1118
1066
  logError,
1119
- requiresSocket
1067
+ message,
1068
+ preparePrettyError,
1069
+ requiresSocket,
1070
+ resolve
1120
1071
  } = options;
1121
1072
  if ('id' in message) {
1122
1073
  if ('method' in message) {
@@ -1139,36 +1090,17 @@ const handleJsonRpcMessage = async (...args) => {
1139
1090
  throw new JsonRpcError('unexpected message');
1140
1091
  };
1141
1092
 
1142
- class CommandNotFoundError extends Error {
1143
- constructor(command) {
1144
- super(`Command not found ${command}`);
1145
- this.name = 'CommandNotFoundError';
1146
- }
1147
- }
1148
- const commands = Object.create(null);
1149
- const register = commandMap => {
1150
- Object.assign(commands, commandMap);
1151
- };
1152
- const getCommand = key => {
1153
- return commands[key];
1154
- };
1155
- const execute = (command, ...args) => {
1156
- const fn = getCommand(command);
1157
- if (!fn) {
1158
- throw new CommandNotFoundError(command);
1159
- }
1160
- return fn(...args);
1161
- };
1162
-
1163
1093
  const Two = '2.0';
1164
- const create$s = (method, params) => {
1094
+
1095
+ const create$9 = (method, params) => {
1165
1096
  return {
1166
1097
  jsonrpc: Two,
1167
1098
  method,
1168
1099
  params
1169
1100
  };
1170
1101
  };
1171
- const create$r = (id, method, params) => {
1102
+
1103
+ const create$8 = (id, method, params) => {
1172
1104
  const message = {
1173
1105
  id,
1174
1106
  jsonrpc: Two,
@@ -1177,15 +1109,14 @@ const create$r = (id, method, params) => {
1177
1109
  };
1178
1110
  return message;
1179
1111
  };
1112
+
1180
1113
  let id = 0;
1181
- const create$q = () => {
1114
+ const create$7 = () => {
1182
1115
  return ++id;
1183
1116
  };
1184
1117
 
1185
- /* eslint-disable n/no-unsupported-features/es-syntax */
1186
-
1187
1118
  const registerPromise = map => {
1188
- const id = create$q();
1119
+ const id = create$7();
1189
1120
  const {
1190
1121
  promise,
1191
1122
  resolve
@@ -1197,13 +1128,12 @@ const registerPromise = map => {
1197
1128
  };
1198
1129
  };
1199
1130
 
1200
- // @ts-ignore
1201
1131
  const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
1202
1132
  const {
1203
1133
  id,
1204
1134
  promise
1205
1135
  } = registerPromise(callbacks);
1206
- const message = create$r(id, method, params);
1136
+ const message = create$8(id, method, params);
1207
1137
  if (useSendAndTransfer && ipc.sendAndTransfer) {
1208
1138
  ipc.sendAndTransfer(message);
1209
1139
  } else {
@@ -1239,12 +1169,13 @@ const createRpc = ipc => {
1239
1169
  * @deprecated
1240
1170
  */
1241
1171
  send(method, ...params) {
1242
- const message = create$s(method, params);
1172
+ const message = create$9(method, params);
1243
1173
  ipc.send(message);
1244
1174
  }
1245
1175
  };
1246
1176
  return rpc;
1247
1177
  };
1178
+
1248
1179
  const requiresSocket = () => {
1249
1180
  return false;
1250
1181
  };
@@ -1259,6 +1190,7 @@ const handleMessage = event => {
1259
1190
  const actualExecute = event?.target?.execute || execute;
1260
1191
  return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
1261
1192
  };
1193
+
1262
1194
  const handleIpc = ipc => {
1263
1195
  if ('addEventListener' in ipc) {
1264
1196
  ipc.addEventListener('message', handleMessage);
@@ -1267,6 +1199,7 @@ const handleIpc = ipc => {
1267
1199
  ipc.on('message', handleMessage);
1268
1200
  }
1269
1201
  };
1202
+
1270
1203
  const listen$1 = async (module, options) => {
1271
1204
  const rawIpc = await module.listen(options);
1272
1205
  if (module.signal) {
@@ -1276,7 +1209,40 @@ const listen$1 = async (module, options) => {
1276
1209
  return ipc;
1277
1210
  };
1278
1211
 
1279
- /* eslint-disable @typescript-eslint/no-misused-promises */
1212
+ const create$6 = async ({
1213
+ commandMap,
1214
+ isMessagePortOpen = true,
1215
+ messagePort
1216
+ }) => {
1217
+ // TODO create a commandMap per rpc instance
1218
+ register$1(commandMap);
1219
+ const rawIpc = await IpcParentWithMessagePort$1.create({
1220
+ isMessagePortOpen,
1221
+ messagePort
1222
+ });
1223
+ const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1224
+ handleIpc(ipc);
1225
+ const rpc = createRpc(ipc);
1226
+ messagePort.start();
1227
+ return rpc;
1228
+ };
1229
+
1230
+ const create$5 = async ({
1231
+ commandMap,
1232
+ isMessagePortOpen,
1233
+ send
1234
+ }) => {
1235
+ const {
1236
+ port1,
1237
+ port2
1238
+ } = new MessageChannel();
1239
+ await send(port1);
1240
+ return create$6({
1241
+ commandMap,
1242
+ isMessagePortOpen,
1243
+ messagePort: port2
1244
+ });
1245
+ };
1280
1246
 
1281
1247
  const createSharedLazyRpc = factory => {
1282
1248
  let rpcPromise;
@@ -1305,45 +1271,47 @@ const createSharedLazyRpc = factory => {
1305
1271
  }
1306
1272
  };
1307
1273
  };
1308
- const create$i = async ({
1274
+
1275
+ const create$4 = async ({
1309
1276
  commandMap,
1310
1277
  isMessagePortOpen,
1311
1278
  send
1312
1279
  }) => {
1313
1280
  return createSharedLazyRpc(() => {
1314
- return create$2({
1281
+ return create$5({
1315
1282
  commandMap,
1316
1283
  isMessagePortOpen,
1317
1284
  send
1318
1285
  });
1319
1286
  });
1320
1287
  };
1321
- const LazyTransferMessagePortRpcParent = {
1322
- __proto__: null,
1323
- create: create$i
1324
- };
1288
+
1325
1289
  const Https$1 = 'https:';
1326
1290
  const Ws = 'ws:';
1327
1291
  const Wss = 'wss:';
1292
+
1328
1293
  const getWebSocketProtocol = locationProtocol => {
1329
1294
  return locationProtocol === Https$1 ? Wss : Ws;
1330
1295
  };
1296
+
1331
1297
  const getWebSocketUrl = (type, host, locationProtocol) => {
1332
1298
  const wsProtocol = getWebSocketProtocol(locationProtocol);
1333
1299
  return `${wsProtocol}//${host}/websocket/${type}`;
1334
1300
  };
1301
+
1335
1302
  const getHost = () => {
1336
1303
  return location.host;
1337
1304
  };
1338
1305
  const getProtocol = () => {
1339
1306
  return location.protocol;
1340
1307
  };
1341
- const create$h = async ({
1308
+
1309
+ const create$3 = async ({
1342
1310
  commandMap,
1343
1311
  webSocket
1344
1312
  }) => {
1345
1313
  // TODO create a commandMap per rpc instance
1346
- register(commandMap);
1314
+ register$1(commandMap);
1347
1315
  const rawIpc = await IpcParentWithWebSocket$1.create({
1348
1316
  webSocket
1349
1317
  });
@@ -1352,7 +1320,8 @@ const create$h = async ({
1352
1320
  const rpc = createRpc(ipc);
1353
1321
  return rpc;
1354
1322
  };
1355
- const create$g = async ({
1323
+
1324
+ const create$2 = async ({
1356
1325
  commandMap,
1357
1326
  type
1358
1327
  }) => {
@@ -1360,71 +1329,24 @@ const create$g = async ({
1360
1329
  const protocol = getProtocol();
1361
1330
  const wsUrl = getWebSocketUrl(type, host, protocol);
1362
1331
  const webSocket = new WebSocket(wsUrl);
1363
- const rpc = await create$h({
1332
+ const rpc = await create$3({
1364
1333
  commandMap,
1365
1334
  webSocket
1366
1335
  });
1367
1336
  return rpc;
1368
1337
  };
1369
- const WebSocketRpcParent2 = {
1370
- __proto__: null,
1371
- create: create$g
1372
- };
1373
- const create$4 = async ({
1374
- commandMap,
1375
- isMessagePortOpen = true,
1376
- messagePort
1377
- }) => {
1378
- // TODO create a commandMap per rpc instance
1379
- register(commandMap);
1380
- const rawIpc = await IpcParentWithMessagePort$1.create({
1381
- isMessagePortOpen,
1382
- messagePort
1383
- });
1384
- const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1385
- handleIpc(ipc);
1386
- const rpc = createRpc(ipc);
1387
- messagePort.start();
1388
- return rpc;
1389
- };
1390
- const PlainMessagePortRpc = {
1391
- __proto__: null,
1392
- create: create$4
1393
- };
1394
- const create$2 = async ({
1395
- commandMap,
1396
- isMessagePortOpen,
1397
- send
1398
- }) => {
1399
- const {
1400
- port1,
1401
- port2
1402
- } = new MessageChannel();
1403
- await send(port1);
1404
- return create$4({
1405
- commandMap,
1406
- isMessagePortOpen,
1407
- messagePort: port2
1408
- });
1409
- };
1410
- const TransferMessagePortRpcParent = {
1411
- __proto__: null,
1412
- create: create$2
1413
- };
1338
+
1414
1339
  const create$1 = async ({
1415
1340
  commandMap
1416
1341
  }) => {
1417
1342
  // TODO create a commandMap per rpc instance
1418
- register(commandMap);
1343
+ register$1(commandMap);
1419
1344
  const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
1420
1345
  handleIpc(ipc);
1421
1346
  const rpc = createRpc(ipc);
1422
1347
  return rpc;
1423
1348
  };
1424
- const WebWorkerRpcClient = {
1425
- __proto__: null,
1426
- create: create$1
1427
- };
1349
+
1428
1350
  const createMockRpc = ({
1429
1351
  commandMap
1430
1352
  }) => {
@@ -1445,118 +1367,165 @@ const createMockRpc = ({
1445
1367
  return mockRpc;
1446
1368
  };
1447
1369
 
1370
+ const rpcs = Object.create(null);
1371
+ const set$5 = (id, rpc) => {
1372
+ rpcs[id] = rpc;
1373
+ };
1374
+ const get = id => {
1375
+ return rpcs[id];
1376
+ };
1377
+ const remove$5 = id => {
1378
+ delete rpcs[id];
1379
+ };
1380
+
1381
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
1382
+ const create = rpcId => {
1383
+ return {
1384
+ async dispose() {
1385
+ const rpc = get(rpcId);
1386
+ await rpc.dispose();
1387
+ },
1388
+ // @ts-ignore
1389
+ invoke(method, ...params) {
1390
+ const rpc = get(rpcId);
1391
+ // @ts-ignore
1392
+ return rpc.invoke(method, ...params);
1393
+ },
1394
+ // @ts-ignore
1395
+ invokeAndTransfer(method, ...params) {
1396
+ const rpc = get(rpcId);
1397
+ // @ts-ignore
1398
+ return rpc.invokeAndTransfer(method, ...params);
1399
+ },
1400
+ registerMockRpc(commandMap) {
1401
+ const mockRpc = createMockRpc({
1402
+ commandMap
1403
+ });
1404
+ set$5(rpcId, mockRpc);
1405
+ // @ts-ignore
1406
+ mockRpc[Symbol.dispose] = () => {
1407
+ remove$5(rpcId);
1408
+ };
1409
+ // @ts-ignore
1410
+ return mockRpc;
1411
+ },
1412
+ set(rpc) {
1413
+ set$5(rpcId, rpc);
1414
+ }
1415
+ };
1416
+ };
1417
+
1418
+ const DebugWorker = 55;
1419
+ const ExtensionHostWorker = 44;
1420
+ const FileSystemProcess$1 = 210;
1421
+ const FileSystemWorker = 209;
1422
+ const RendererProcess = 1670;
1423
+ const RendererWorker = 1;
1424
+
1448
1425
  const {
1449
- invoke: invoke$3,
1426
+ invoke: invoke$4,
1450
1427
  set: set$4
1451
- } = create$6(ExtensionHostWorker);
1428
+ } = create(ExtensionHostWorker);
1452
1429
 
1453
1430
  const {
1454
- dispose,
1455
- invoke: invoke$2,
1456
- invokeAndTransfer: invokeAndTransfer$1,
1431
+ invoke: invoke$3,
1457
1432
  set: set$3
1458
- } = create$6(FileSystemProcess$1);
1459
- const remove$3 = async uri => {
1460
- return invoke$2('FileSystem.remove', uri);
1433
+ } = create(FileSystemProcess$1);
1434
+ const remove$4 = async uri => {
1435
+ return invoke$3('FileSystem.remove', uri);
1461
1436
  };
1462
- const readFile$3 = async uri => {
1463
- return invoke$2('FileSystem.readFile', uri);
1437
+ const readFile$4 = async uri => {
1438
+ return invoke$3('FileSystem.readFile', uri);
1464
1439
  };
1465
1440
  const appendFile$2 = async (uri, text) => {
1466
1441
  // @ts-ignore
1467
- return invoke$2('FileSystem.appendFile', uri, text);
1442
+ return invoke$3('FileSystem.appendFile', uri, text);
1468
1443
  };
1469
- const readDirWithFileTypes$2 = async uri => {
1470
- return invoke$2('FileSystem.readDirWithFileTypes', uri);
1444
+ const readDirWithFileTypes$4 = async uri => {
1445
+ return invoke$3('FileSystem.readDirWithFileTypes', uri);
1471
1446
  };
1472
- const getPathSeparator$2 = async root => {
1447
+ const getPathSeparator$4 = async root => {
1473
1448
  // @ts-ignore
1474
- return invoke$2('FileSystem.getPathSeparator', root);
1449
+ return invoke$3('FileSystem.getPathSeparator', root);
1475
1450
  };
1476
- const readJson$3 = async root => {
1451
+ const readJson$4 = async root => {
1477
1452
  // @ts-ignore
1478
- return invoke$2('FileSystem.readJson', root);
1453
+ return invoke$3('FileSystem.readJson', root);
1479
1454
  };
1480
- const getRealPath$2 = async path => {
1455
+ const getRealPath$4 = async path => {
1481
1456
  // @ts-ignore
1482
- return invoke$2('FileSystem.getRealPath', path);
1457
+ return invoke$3('FileSystem.getRealPath', path);
1483
1458
  };
1484
- const stat$2 = async path => {
1459
+ const stat$4 = async path => {
1485
1460
  // @ts-ignore
1486
- return invoke$2('FileSystem.stat', path);
1461
+ return invoke$3('FileSystem.stat', path);
1487
1462
  };
1488
- const writeFile$3 = async (path, content) => {
1463
+ const writeFile$4 = async (path, content) => {
1489
1464
  // @ts-ignore
1490
- return invoke$2('FileSystem.writeFile', path, content);
1465
+ return invoke$3('FileSystem.writeFile', path, content);
1491
1466
  };
1492
- const mkdir$2 = async path => {
1467
+ const mkdir$4 = async path => {
1493
1468
  // @ts-ignore
1494
- return invoke$2('FileSystem.mkdir', path);
1469
+ return invoke$3('FileSystem.mkdir', path);
1495
1470
  };
1496
- const rename$3 = async (oldUri, newUri) => {
1471
+ const rename$4 = async (oldUri, newUri) => {
1497
1472
  // @ts-ignore
1498
- return invoke$2('FileSystem.rename', oldUri, newUri);
1473
+ return invoke$3('FileSystem.rename', oldUri, newUri);
1499
1474
  };
1500
- const copy$2 = async (oldUri, newUri) => {
1475
+ const copy$4 = async (oldUri, newUri) => {
1501
1476
  // @ts-ignore
1502
- return invoke$2('FileSystem.copy', oldUri, newUri);
1477
+ return invoke$3('FileSystem.copy', oldUri, newUri);
1503
1478
  };
1504
- const getFolderSize$2 = async uri => {
1479
+ const getFolderSize$4 = async uri => {
1505
1480
  // @ts-ignore
1506
- return invoke$2('FileSystem.getFolderSize', uri);
1481
+ return invoke$3('FileSystem.getFolderSize', uri);
1507
1482
  };
1508
- const exists$2 = async uri => {
1483
+ const exists$4 = async uri => {
1509
1484
  // @ts-ignore
1510
- return invoke$2('FileSystem.exists', uri);
1511
- };
1512
- const registerMockRpc = commandMap => {
1513
- const mockRpc = createMockRpc({
1514
- commandMap
1515
- });
1516
- set$3(mockRpc);
1517
- return mockRpc;
1485
+ return invoke$3('FileSystem.exists', uri);
1518
1486
  };
1519
1487
 
1520
1488
  const FileSystemProcess = {
1521
1489
  __proto__: null,
1522
1490
  appendFile: appendFile$2,
1523
- copy: copy$2,
1524
- dispose,
1525
- exists: exists$2,
1526
- getFolderSize: getFolderSize$2,
1527
- getPathSeparator: getPathSeparator$2,
1528
- getRealPath: getRealPath$2,
1529
- invoke: invoke$2,
1530
- invokeAndTransfer: invokeAndTransfer$1,
1531
- mkdir: mkdir$2,
1532
- readDirWithFileTypes: readDirWithFileTypes$2,
1533
- readFile: readFile$3,
1534
- readJson: readJson$3,
1535
- registerMockRpc,
1536
- remove: remove$3,
1537
- rename: rename$3,
1491
+ copy: copy$4,
1492
+ exists: exists$4,
1493
+ getFolderSize: getFolderSize$4,
1494
+ getPathSeparator: getPathSeparator$4,
1495
+ getRealPath: getRealPath$4,
1496
+ invoke: invoke$3,
1497
+ mkdir: mkdir$4,
1498
+ readDirWithFileTypes: readDirWithFileTypes$4,
1499
+ readFile: readFile$4,
1500
+ readJson: readJson$4,
1501
+ remove: remove$4,
1502
+ rename: rename$4,
1538
1503
  set: set$3,
1539
- stat: stat$2,
1540
- writeFile: writeFile$3
1504
+ stat: stat$4,
1505
+ writeFile: writeFile$4
1541
1506
  };
1542
1507
 
1543
1508
  const {
1544
1509
  set: set$2
1545
- } = create$6(RendererProcess);
1510
+ } = create(RendererProcess);
1546
1511
 
1547
1512
  const {
1513
+ invoke: invoke$2,
1548
1514
  invokeAndTransfer,
1549
1515
  set: set$1
1550
- } = create$6(RendererWorker);
1516
+ } = create(RendererWorker);
1551
1517
  const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
1552
1518
  const command = 'HandleMessagePort.handleMessagePort2';
1553
1519
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1554
1520
  };
1555
1521
  const sendMessagePortToRendererProcess = async port => {
1556
1522
  const command = 'HandleMessagePort.handleMessagePort';
1557
- // @ts-ignore
1558
1523
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1559
1524
  };
1525
+ const sendMessagePortToFileSystemProcess$1 = async (port, rpcId) => {
1526
+ const command = 'HandleMessagePortForFileSystemProcess.handleMessagePortForFileSystemProcess';
1527
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, rpcId);
1528
+ };
1560
1529
 
1561
1530
  const createLazyRpc = rpcId => {
1562
1531
  let rpcPromise;
@@ -1574,12 +1543,12 @@ const createLazyRpc = rpcId => {
1574
1543
  return {
1575
1544
  async invoke(method, ...params) {
1576
1545
  await ensureRpc();
1577
- const rpc = get$1(rpcId);
1546
+ const rpc = get(rpcId);
1578
1547
  return rpc.invoke(method, ...params);
1579
1548
  },
1580
1549
  async invokeAndTransfer(method, ...params) {
1581
1550
  await ensureRpc();
1582
- const rpc = get$1(rpcId);
1551
+ const rpc = get(rpcId);
1583
1552
  return rpc.invokeAndTransfer(method, ...params);
1584
1553
  },
1585
1554
  setFactory(value) {
@@ -1588,6 +1557,87 @@ const createLazyRpc = rpcId => {
1588
1557
  };
1589
1558
  };
1590
1559
 
1560
+ const remove$3 = async dirent => {
1561
+ throw new Error('not implemented');
1562
+ };
1563
+ const readFile$3 = async uri => {
1564
+ const response = await fetch(uri);
1565
+ if (!response.ok) {
1566
+ throw new Error(response.statusText);
1567
+ }
1568
+ const result = await response.text();
1569
+ return result;
1570
+ };
1571
+ const readFileAsBlob$2 = async uri => {
1572
+ const response = await fetch(uri);
1573
+ if (!response.ok) {
1574
+ throw new Error(response.statusText);
1575
+ }
1576
+ const result = await response.blob();
1577
+ return result;
1578
+ };
1579
+ const exists$3 = async uri => {
1580
+ const response = await fetch(uri);
1581
+ return response.ok;
1582
+ };
1583
+ const readDirWithFileTypes$3 = async uri => {
1584
+ throw new Error('not implemented');
1585
+ };
1586
+ const getPathSeparator$3 = async root => {
1587
+ return '/';
1588
+ };
1589
+ const readJson$3 = async uri => {
1590
+ const response = await fetch(uri);
1591
+ if (!response.ok) {
1592
+ throw new Error(`${response.statusText}`);
1593
+ }
1594
+ const json = await response.json();
1595
+ return json;
1596
+ };
1597
+ const getRealPath$3 = async path => {
1598
+ throw new Error('not implemented');
1599
+ };
1600
+ const stat$3 = async dirent => {
1601
+ throw new Error('not implemented');
1602
+ };
1603
+ const createFile$2 = async uri => {
1604
+ throw new Error('not implemented');
1605
+ };
1606
+ const writeFile$3 = async (uri, content) => {
1607
+ throw new Error('not implemented');
1608
+ };
1609
+ const mkdir$3 = async uri => {
1610
+ throw new Error('not implemented');
1611
+ };
1612
+ const rename$3 = async (oldUri, newUri) => {
1613
+ throw new Error('not implemented');
1614
+ };
1615
+ const copy$3 = async (oldUri, newUri) => {
1616
+ throw new Error('not implemented');
1617
+ };
1618
+ const getFolderSize$3 = async uri => {
1619
+ throw new Error('not implemented');
1620
+ };
1621
+
1622
+ const FileSystemFetch = {
1623
+ __proto__: null,
1624
+ copy: copy$3,
1625
+ createFile: createFile$2,
1626
+ exists: exists$3,
1627
+ getFolderSize: getFolderSize$3,
1628
+ getPathSeparator: getPathSeparator$3,
1629
+ getRealPath: getRealPath$3,
1630
+ mkdir: mkdir$3,
1631
+ readDirWithFileTypes: readDirWithFileTypes$3,
1632
+ readFile: readFile$3,
1633
+ readFileAsBlob: readFileAsBlob$2,
1634
+ readJson: readJson$3,
1635
+ remove: remove$3,
1636
+ rename: rename$3,
1637
+ stat: stat$3,
1638
+ writeFile: writeFile$3
1639
+ };
1640
+
1591
1641
  const RE_PROTOCOL = /^([a-z-]+):\/\//;
1592
1642
  const assertUri = uri => {
1593
1643
  const protocolMatch = uri.match(RE_PROTOCOL);
@@ -1598,27 +1648,27 @@ const assertUri = uri => {
1598
1648
 
1599
1649
  const {
1600
1650
  appendFile: appendFile$1,
1601
- copy: copy$1,
1602
- exists: exists$1,
1603
- getFolderSize: getFolderSize$1,
1604
- getPathSeparator: getPathSeparator$1,
1605
- getRealPath: getRealPath$1,
1651
+ copy: copy$2,
1652
+ exists: exists$2,
1653
+ getFolderSize: getFolderSize$2,
1654
+ getPathSeparator: getPathSeparator$2,
1655
+ getRealPath: getRealPath$2,
1606
1656
  invoke: invoke$1,
1607
- mkdir: mkdir$1,
1608
- readDirWithFileTypes: readDirWithFileTypes$1,
1657
+ mkdir: mkdir$2,
1658
+ readDirWithFileTypes: readDirWithFileTypes$2,
1609
1659
  readFile: readFile$2,
1610
1660
  readJson: readJson$2,
1611
1661
  remove: remove$2,
1612
1662
  rename: rename$2,
1613
1663
  set,
1614
- stat: stat$1,
1664
+ stat: stat$2,
1615
1665
  writeFile: writeFile$2
1616
1666
  } = FileSystemProcess;
1617
1667
 
1618
1668
  const Http = 'http:';
1619
1669
  const Memory = 'memfs:';
1620
1670
  const Https = 'https:';
1621
- const File$1 = 'file:';
1671
+ const File$2 = 'file:';
1622
1672
 
1623
1673
  const watchCallbacks = Object.create(null);
1624
1674
  const registerWatchCallback = (id, rpcId, commandId, uri) => {
@@ -1637,7 +1687,7 @@ const executeWatchCallBack = async id => {
1637
1687
  commandId,
1638
1688
  rpcId
1639
1689
  } = entry;
1640
- const rpc = get$1(rpcId);
1690
+ const rpc = get(rpcId);
1641
1691
  await rpc.invoke(commandId, id);
1642
1692
  };
1643
1693
  const unregisterWatchCallback = id => {
@@ -1653,11 +1703,11 @@ const getWatchCallbackIdsForUri = uri => {
1653
1703
  return watchIds;
1654
1704
  };
1655
1705
 
1656
- const watchFile = async (id, uri, rpcId) => {
1706
+ const watchFile$2 = async (id, uri, rpcId) => {
1657
1707
  assertUri(uri);
1658
1708
  const commandId = 'Output.executeWatchCallback';
1659
1709
  registerWatchCallback(id, rpcId, commandId, uri);
1660
- if (uri.startsWith(File$1)) {
1710
+ if (uri.startsWith(File$2)) {
1661
1711
  // @ts-ignore
1662
1712
  await invoke$1('FileSystem.watchFile', id, uri);
1663
1713
  }
@@ -1684,33 +1734,123 @@ const triggerMemfsFileWatcher = async uri => {
1684
1734
  }
1685
1735
  };
1686
1736
 
1737
+ const getFileExtension = uri => {
1738
+ const lastDot = uri.lastIndexOf('.');
1739
+ if (lastDot === -1) {
1740
+ return '';
1741
+ }
1742
+ const lastSlash = Math.max(uri.lastIndexOf('/'), uri.lastIndexOf('\\'));
1743
+ if (lastSlash > lastDot) {
1744
+ return '';
1745
+ }
1746
+ return uri.slice(lastDot + 1);
1747
+ };
1748
+
1749
+ const getBlobType = uri => {
1750
+ const extension = getFileExtension(uri).toLowerCase();
1751
+ switch (extension) {
1752
+ case 'css':
1753
+ return 'text/css';
1754
+ case 'html':
1755
+ return 'text/html';
1756
+ case 'js':
1757
+ return 'text/javascript';
1758
+ case 'json':
1759
+ return 'application/json';
1760
+ case 'svg':
1761
+ return 'image/svg+xml';
1762
+ case 'txt':
1763
+ return 'text/plain';
1764
+ case 'xml':
1765
+ return 'application/xml';
1766
+ default:
1767
+ return '';
1768
+ }
1769
+ };
1687
1770
  const remove$1 = async dirent => {
1688
- await invoke$3('FileSystemMemory.remove', dirent);
1771
+ await invoke$4('FileSystemMemory.remove', dirent);
1689
1772
  // Trigger file watchers for memfs files
1690
1773
  await triggerMemfsFileWatcher(dirent);
1691
1774
  };
1692
1775
  const readFile$1 = async uri => {
1693
- return invoke$3('FileSystemMemory.readFile', uri);
1776
+ return invoke$4('FileSystemMemory.readFile', uri);
1777
+ };
1778
+ const readFileAsBlob$1 = async uri => {
1779
+ const content = await readFile$1(uri);
1780
+ const type = getBlobType(uri);
1781
+ if (type) {
1782
+ return new Blob([content], {
1783
+ type
1784
+ });
1785
+ }
1786
+ return new Blob([content]);
1787
+ };
1788
+ const exists$1 = async uri => {
1789
+ throw new Error('not implemented');
1790
+ };
1791
+ const readDirWithFileTypes$1 = async uri => {
1792
+ throw new Error('not implemented');
1793
+ };
1794
+ const getPathSeparator$1 = async root => {
1795
+ return '/';
1694
1796
  };
1695
1797
  const readJson$1 = async uri => {
1696
1798
  throw new Error('not implemented');
1697
1799
  };
1800
+ const getRealPath$1 = async path => {
1801
+ throw new Error('not implemented');
1802
+ };
1803
+ const stat$1 = async dirent => {
1804
+ throw new Error('not implemented');
1805
+ };
1698
1806
  const createFile$1 = async uri => {
1699
- await invoke$3('FileSystemMemory.createFile', uri);
1807
+ await invoke$4('FileSystemMemory.createFile', uri);
1700
1808
  // Trigger file watchers for memfs files
1701
1809
  await triggerMemfsFileWatcher(uri);
1702
1810
  };
1703
1811
  const writeFile$1 = async (uri, content) => {
1704
- await invoke$3('FileSystemMemory.writeFile', uri, content);
1812
+ await invoke$4('FileSystemMemory.writeFile', uri, content);
1705
1813
  // Trigger file watchers for memfs files
1706
1814
  await triggerMemfsFileWatcher(uri);
1707
1815
  };
1816
+ const mkdir$1 = async uri => {
1817
+ throw new Error('not implemented');
1818
+ };
1708
1819
  const rename$1 = async (oldUri, newUri) => {
1709
- await invoke$3('FileSystemMemory.rename', oldUri, newUri);
1820
+ await invoke$4('FileSystemMemory.rename', oldUri, newUri);
1710
1821
  // Trigger file watchers for both old and new URIs
1711
1822
  await triggerMemfsFileWatcher(oldUri);
1712
1823
  await triggerMemfsFileWatcher(newUri);
1713
1824
  };
1825
+ const copy$1 = async (oldUri, newUri) => {
1826
+ throw new Error('not implemented');
1827
+ };
1828
+ const getFolderSize$1 = async uri => {
1829
+ throw new Error('not implemented');
1830
+ };
1831
+ const watchFile$1 = async (id, uri) => {
1832
+ throw new Error('not implemented');
1833
+ };
1834
+
1835
+ const FileSystemMemory = {
1836
+ __proto__: null,
1837
+ copy: copy$1,
1838
+ createFile: createFile$1,
1839
+ exists: exists$1,
1840
+ getFolderSize: getFolderSize$1,
1841
+ getPathSeparator: getPathSeparator$1,
1842
+ getRealPath: getRealPath$1,
1843
+ mkdir: mkdir$1,
1844
+ readDirWithFileTypes: readDirWithFileTypes$1,
1845
+ readFile: readFile$1,
1846
+ readFileAsBlob: readFileAsBlob$1,
1847
+ readJson: readJson$1,
1848
+ remove: remove$1,
1849
+ rename: rename$1,
1850
+ stat: stat$1,
1851
+ watchFile: watchFile$1,
1852
+ writeFile: writeFile$1
1853
+ };
1714
1854
 
1715
1855
  const isHttp = uri => {
1716
1856
  return uri.startsWith(Http) || uri.startsWith(Https);
@@ -1728,7 +1868,7 @@ const remove = async dirent => {
1728
1868
  };
1729
1869
  const readFile = async uri => {
1730
1870
  if (isHttp(uri)) {
1731
- return readFile$4(uri);
1871
+ return readFile$3(uri);
1732
1872
  }
1733
1873
  if (isMemory(uri)) {
1734
1874
  return readFile$1(uri);
@@ -1739,14 +1879,14 @@ const appendFile = async (uri, text) => {
1739
1879
  return appendFile$1(uri, text);
1740
1880
  };
1741
1881
  const readDirWithFileTypes = async uri => {
1742
- return readDirWithFileTypes$1(uri);
1882
+ return readDirWithFileTypes$2(uri);
1743
1883
  };
1744
1884
  const getPathSeparator = async root => {
1745
- return getPathSeparator$1(root);
1885
+ return getPathSeparator$2(root);
1746
1886
  };
1747
1887
  const readJson = async uri => {
1748
1888
  if (isHttp(uri)) {
1749
- return readJson$4(uri);
1889
+ return readJson$3(uri);
1750
1890
  }
1751
1891
  if (isMemory(uri)) {
1752
1892
  return readJson$1();
@@ -1754,10 +1894,13 @@ const readJson = async uri => {
1754
1894
  return readJson$2(uri);
1755
1895
  };
1756
1896
  const getRealPath = async path => {
1757
- return getRealPath$1(path);
1897
+ return getRealPath$2(path);
1758
1898
  };
1759
1899
  const readFileAsBlob = async uri => {
1760
1900
  if (isHttp(uri)) {
1901
+ return readFileAsBlob$2(uri);
1902
+ }
1903
+ if (isMemory(uri)) {
1761
1904
  return readFileAsBlob$1(uri);
1762
1905
  }
1763
1906
  if (uri.startsWith('file:///')) {
@@ -1773,13 +1916,13 @@ const readFileAsBlob = async uri => {
1773
1916
  throw new Error('uri not supported');
1774
1917
  };
1775
1918
  const stat = async dirent => {
1776
- return stat$1(dirent);
1919
+ return stat$2(dirent);
1777
1920
  };
1778
1921
  const exists = async uri => {
1779
1922
  if (isHttp(uri)) {
1780
1923
  return exists$3(uri);
1781
1924
  }
1782
- return exists$1(uri);
1925
+ return exists$2(uri);
1783
1926
  };
1784
1927
  const createFile = async uri => {
1785
1928
  if (isMemory(uri)) {
@@ -1807,7 +1950,11 @@ const writeBlob = async (uri, blob) => {
1807
1950
  await invoke$1('FileSystem.writeBuffer', uri, bytes);
1808
1951
  };
1809
1952
  const mkdir = async uri => {
1810
- return mkdir$1(uri);
1953
+ if (isMemory(uri)) {
1954
+ await invoke$2('FileSystem.mkdir', uri);
1955
+ return;
1956
+ }
1957
+ return mkdir$2(uri);
1811
1958
  };
1812
1959
  const rename = async (oldUri, newUri) => {
1813
1960
  if (isMemory(oldUri) || isMemory(newUri)) {
@@ -1816,14 +1963,40 @@ const rename = async (oldUri, newUri) => {
1816
1963
  return rename$2(oldUri, newUri);
1817
1964
  };
1818
1965
  const copy = async (oldUri, newUri) => {
1819
- return copy$1(oldUri, newUri);
1966
+ return copy$2(oldUri, newUri);
1820
1967
  };
1821
1968
  const getFolderSize = async uri => {
1822
- return getFolderSize$1(uri);
1969
+ return getFolderSize$2(uri);
1970
+ };
1971
+ const watchFile = async (id, uri) => {
1972
+ // @ts-ignore
1973
+ await invoke$1('FileSystem.watchFile', id, uri);
1974
+ };
1975
+
1976
+ const FileSystemDisk = {
1977
+ __proto__: null,
1978
+ appendFile,
1979
+ copy,
1980
+ createFile,
1981
+ exists,
1982
+ getFolderSize,
1983
+ getPathSeparator,
1984
+ getRealPath,
1985
+ mkdir,
1986
+ readDirWithFileTypes,
1987
+ readFile,
1988
+ readFileAsBlob,
1989
+ readJson,
1990
+ remove,
1991
+ rename,
1992
+ stat,
1993
+ watchFile,
1994
+ writeBlob,
1995
+ writeFile
1823
1996
  };
1824
1997
 
1825
1998
  const handleMessagePort = async (port, rpcId) => {
1826
- const rpc = await PlainMessagePortRpc.create({
1999
+ const rpc = await create$6({
1827
2000
  commandMap: {},
1828
2001
  messagePort: port
1829
2002
  });
@@ -1833,13 +2006,12 @@ const handleMessagePort = async (port, rpcId) => {
1833
2006
  };
1834
2007
 
1835
2008
  const sendMessagePortToFileSystemProcess = async port => {
1836
- const command = 'HandleMessagePortForFileSystemProcess.handleMessagePortForFileSystemProcess';
1837
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, FileSystemWorker);
2009
+ await sendMessagePortToFileSystemProcess$1(port, FileSystemWorker);
1838
2010
  };
1839
2011
 
1840
2012
  const createFileSystemProcessRpcElectron = async () => {
1841
2013
  try {
1842
- const rpc = await TransferMessagePortRpcParent.create({
2014
+ const rpc = await create$5({
1843
2015
  commandMap: {},
1844
2016
  send: sendMessagePortToFileSystemProcess
1845
2017
  });
@@ -1853,7 +2025,7 @@ const commandMapRef = {};
1853
2025
 
1854
2026
  const createFileSystemProcessRpcNode = async () => {
1855
2027
  try {
1856
- const rpc = await WebSocketRpcParent2.create({
2028
+ const rpc = await create$2({
1857
2029
  commandMap: commandMapRef,
1858
2030
  type: 'file-system-process'
1859
2031
  });
@@ -1883,7 +2055,7 @@ const createFileSystemProcessRpc = async platform => {
1883
2055
  return create();
1884
2056
  };
1885
2057
 
1886
- const initializeFileSytemProcess = async platform => {
2058
+ const initializeFileSystemProcess = async platform => {
1887
2059
  if (platform === Web) {
1888
2060
  return;
1889
2061
  }
@@ -1892,11 +2064,11 @@ const initializeFileSytemProcess = async platform => {
1892
2064
  };
1893
2065
 
1894
2066
  const initialize = async platform => {
1895
- await initializeFileSytemProcess(platform);
2067
+ await initializeFileSystemProcess(platform);
1896
2068
  };
1897
2069
 
1898
2070
  const Directory = 'directory';
1899
- const File = 'file';
2071
+ const File$1 = 'file';
1900
2072
 
1901
2073
  const {
1902
2074
  invoke} = createLazyRpc(RendererProcess);
@@ -1950,7 +2122,7 @@ const uploadHandle = async (fileSystemHandle, pathSeparator, root, uploadHandles
1950
2122
  switch (kind) {
1951
2123
  case Directory:
1952
2124
  return uploadDirectory(fileSystemHandle, pathSeparator, root, uploadHandles);
1953
- case File:
2125
+ case File$1:
1954
2126
  return uploadFile(fileSystemHandle, pathSeparator, root);
1955
2127
  default:
1956
2128
  throw new Error(`unsupported file system handle type ${kind}`);
@@ -2002,15 +2174,33 @@ const commandMap = {
2002
2174
  'FileSystem.stat': stat,
2003
2175
  'FileSystem.unwatchFile': unwatchFile,
2004
2176
  'FileSystem.uploadFileSystemHandles': uploadFileSystemHandles,
2005
- 'FileSystem.watchFile': watchFile,
2177
+ 'FileSystem.watchFile': watchFile$2,
2006
2178
  'FileSystem.writeBlob': writeBlob,
2007
2179
  'FileSystem.writeFile': writeFile,
2008
2180
  'Initialize.initialize': initialize
2009
2181
  };
2010
2182
 
2183
+ /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
2184
+
2185
+ const state = Object.create(null);
2186
+ const register = modules => {
2187
+ Object.assign(state, modules);
2188
+ };
2189
+
2190
+ const Memfs = 'memfs';
2191
+ const Fetch = 'fetch';
2192
+ const File = 'file';
2193
+
2194
+ // TODO add others
2195
+ const fileSystemModules = {
2196
+ [Fetch]: FileSystemFetch,
2197
+ [File]: FileSystemDisk,
2198
+ [Memfs]: FileSystemMemory
2199
+ };
2200
+
2011
2201
  const initializeExtensionHostWorker = async () => {
2012
2202
  try {
2013
- const rpc = await LazyTransferMessagePortRpcParent.create({
2203
+ const rpc = await create$4({
2014
2204
  commandMap: {},
2015
2205
  send: sendMessagePortToExtensionHostWorker
2016
2206
  });
@@ -2022,7 +2212,7 @@ const initializeExtensionHostWorker = async () => {
2022
2212
 
2023
2213
  const initializeRendererProcess = async () => {
2024
2214
  try {
2025
- const rpc = await LazyTransferMessagePortRpcParent.create({
2215
+ const rpc = await create$4({
2026
2216
  commandMap: {},
2027
2217
  send: sendMessagePortToRendererProcess
2028
2218
  });
@@ -2033,7 +2223,7 @@ const initializeRendererProcess = async () => {
2033
2223
  };
2034
2224
 
2035
2225
  const initializeRendererWorker = async () => {
2036
- const rpc = await WebWorkerRpcClient.create({
2226
+ const rpc = await create$1({
2037
2227
  commandMap: commandMap
2038
2228
  });
2039
2229
  set$1(rpc);
@@ -2041,6 +2231,7 @@ const initializeRendererWorker = async () => {
2041
2231
 
2042
2232
  const listen = async () => {
2043
2233
  Object.assign(commandMapRef, commandMap);
2234
+ register(fileSystemModules);
2044
2235
  await Promise.all([initializeExtensionHostWorker(), initializeRendererProcess(), initializeRendererWorker()]);
2045
2236
  };
2046
2237
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-system-worker",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "description": "File System Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"