@lvce-editor/file-system-worker 5.1.0 → 5.2.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.
- package/dist/fileSystemWorkerMain.js +306 -103
- package/package.json +1 -1
|
@@ -238,6 +238,9 @@ const blobToBinaryString = async blob => {
|
|
|
238
238
|
}
|
|
239
239
|
};
|
|
240
240
|
|
|
241
|
+
const remove$6 = async dirent => {
|
|
242
|
+
throw new Error('not implemented');
|
|
243
|
+
};
|
|
241
244
|
const readFile$4 = async uri => {
|
|
242
245
|
const response = await fetch(uri);
|
|
243
246
|
if (!response.ok) {
|
|
@@ -246,7 +249,7 @@ const readFile$4 = async uri => {
|
|
|
246
249
|
const result = await response.text();
|
|
247
250
|
return result;
|
|
248
251
|
};
|
|
249
|
-
const readFileAsBlob$
|
|
252
|
+
const readFileAsBlob$2 = async uri => {
|
|
250
253
|
const response = await fetch(uri);
|
|
251
254
|
if (!response.ok) {
|
|
252
255
|
throw new Error(response.statusText);
|
|
@@ -254,13 +257,19 @@ const readFileAsBlob$1 = async uri => {
|
|
|
254
257
|
const result = await response.blob();
|
|
255
258
|
return result;
|
|
256
259
|
};
|
|
257
|
-
const exists$
|
|
260
|
+
const exists$4 = async uri => {
|
|
258
261
|
const response = await fetch(uri);
|
|
259
262
|
if (response.ok) {
|
|
260
263
|
return true;
|
|
261
264
|
}
|
|
262
265
|
return false;
|
|
263
266
|
};
|
|
267
|
+
const readDirWithFileTypes$4 = async uri => {
|
|
268
|
+
throw new Error('not implemented');
|
|
269
|
+
};
|
|
270
|
+
const getPathSeparator$4 = async root => {
|
|
271
|
+
return '/';
|
|
272
|
+
};
|
|
264
273
|
const readJson$4 = async uri => {
|
|
265
274
|
const response = await fetch(uri);
|
|
266
275
|
if (!response.ok) {
|
|
@@ -269,6 +278,49 @@ const readJson$4 = async uri => {
|
|
|
269
278
|
const json = await response.json();
|
|
270
279
|
return json;
|
|
271
280
|
};
|
|
281
|
+
const getRealPath$4 = async path => {
|
|
282
|
+
throw new Error('not implemented');
|
|
283
|
+
};
|
|
284
|
+
const stat$4 = async dirent => {
|
|
285
|
+
throw new Error('not implemented');
|
|
286
|
+
};
|
|
287
|
+
const createFile$2 = async uri => {
|
|
288
|
+
throw new Error('not implemented');
|
|
289
|
+
};
|
|
290
|
+
const writeFile$4 = async (uri, content) => {
|
|
291
|
+
throw new Error('not implemented');
|
|
292
|
+
};
|
|
293
|
+
const mkdir$4 = async uri => {
|
|
294
|
+
throw new Error('not implemented');
|
|
295
|
+
};
|
|
296
|
+
const rename$4 = async (oldUri, newUri) => {
|
|
297
|
+
throw new Error('not implemented');
|
|
298
|
+
};
|
|
299
|
+
const copy$4 = async (oldUri, newUri) => {
|
|
300
|
+
throw new Error('not implemented');
|
|
301
|
+
};
|
|
302
|
+
const getFolderSize$4 = async uri => {
|
|
303
|
+
throw new Error('not implemented');
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const FileSystemFetch = {
|
|
307
|
+
__proto__: null,
|
|
308
|
+
copy: copy$4,
|
|
309
|
+
createFile: createFile$2,
|
|
310
|
+
exists: exists$4,
|
|
311
|
+
getFolderSize: getFolderSize$4,
|
|
312
|
+
getPathSeparator: getPathSeparator$4,
|
|
313
|
+
getRealPath: getRealPath$4,
|
|
314
|
+
mkdir: mkdir$4,
|
|
315
|
+
readDirWithFileTypes: readDirWithFileTypes$4,
|
|
316
|
+
readFile: readFile$4,
|
|
317
|
+
readFileAsBlob: readFileAsBlob$2,
|
|
318
|
+
readJson: readJson$4,
|
|
319
|
+
remove: remove$6,
|
|
320
|
+
rename: rename$4,
|
|
321
|
+
stat: stat$4,
|
|
322
|
+
writeFile: writeFile$4
|
|
323
|
+
};
|
|
272
324
|
|
|
273
325
|
const DebugWorker = 55;
|
|
274
326
|
const ExtensionHostWorker = 44;
|
|
@@ -277,38 +329,6 @@ const FileSystemWorker = 209;
|
|
|
277
329
|
const RendererProcess = 1670;
|
|
278
330
|
const RendererWorker = 1;
|
|
279
331
|
|
|
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
332
|
class AssertionError extends Error {
|
|
313
333
|
constructor(message) {
|
|
314
334
|
super(message);
|
|
@@ -783,7 +803,7 @@ const waitForWebSocketToBeOpen = webSocket => {
|
|
|
783
803
|
open: Open
|
|
784
804
|
});
|
|
785
805
|
};
|
|
786
|
-
const create$
|
|
806
|
+
const create$6 = async ({
|
|
787
807
|
webSocket
|
|
788
808
|
}) => {
|
|
789
809
|
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
@@ -820,16 +840,16 @@ const wrap = webSocket => {
|
|
|
820
840
|
};
|
|
821
841
|
const IpcParentWithWebSocket$1 = {
|
|
822
842
|
__proto__: null,
|
|
823
|
-
create: create$
|
|
843
|
+
create: create$6,
|
|
824
844
|
wrap
|
|
825
845
|
};
|
|
826
846
|
|
|
827
847
|
const Two$1 = '2.0';
|
|
828
848
|
const callbacks = Object.create(null);
|
|
829
|
-
const get = id => {
|
|
849
|
+
const get$1 = id => {
|
|
830
850
|
return callbacks[id];
|
|
831
851
|
};
|
|
832
|
-
const remove$
|
|
852
|
+
const remove$5 = id => {
|
|
833
853
|
delete callbacks[id];
|
|
834
854
|
};
|
|
835
855
|
class JsonRpcError extends Error {
|
|
@@ -975,14 +995,14 @@ const warn = (...args) => {
|
|
|
975
995
|
console.warn(...args);
|
|
976
996
|
};
|
|
977
997
|
const resolve = (id, response) => {
|
|
978
|
-
const fn = get(id);
|
|
998
|
+
const fn = get$1(id);
|
|
979
999
|
if (!fn) {
|
|
980
1000
|
console.log(response);
|
|
981
1001
|
warn(`callback ${id} may already be disposed`);
|
|
982
1002
|
return;
|
|
983
1003
|
}
|
|
984
1004
|
fn(response);
|
|
985
|
-
remove$
|
|
1005
|
+
remove$5(id);
|
|
986
1006
|
};
|
|
987
1007
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
988
1008
|
const getErrorType = prettyError => {
|
|
@@ -1038,7 +1058,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
1038
1058
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1039
1059
|
return create$1$1(id, errorProperty);
|
|
1040
1060
|
};
|
|
1041
|
-
const create = (message, result) => {
|
|
1061
|
+
const create$3 = (message, result) => {
|
|
1042
1062
|
return {
|
|
1043
1063
|
jsonrpc: Two$1,
|
|
1044
1064
|
id: message.id,
|
|
@@ -1047,7 +1067,7 @@ const create = (message, result) => {
|
|
|
1047
1067
|
};
|
|
1048
1068
|
const getSuccessResponse = (message, result) => {
|
|
1049
1069
|
const resultProperty = result ?? null;
|
|
1050
|
-
return create(message, resultProperty);
|
|
1070
|
+
return create$3(message, resultProperty);
|
|
1051
1071
|
};
|
|
1052
1072
|
const getErrorResponseSimple = (id, error) => {
|
|
1053
1073
|
return {
|
|
@@ -1146,7 +1166,7 @@ class CommandNotFoundError extends Error {
|
|
|
1146
1166
|
}
|
|
1147
1167
|
}
|
|
1148
1168
|
const commands = Object.create(null);
|
|
1149
|
-
const register = commandMap => {
|
|
1169
|
+
const register$1 = commandMap => {
|
|
1150
1170
|
Object.assign(commands, commandMap);
|
|
1151
1171
|
};
|
|
1152
1172
|
const getCommand = key => {
|
|
@@ -1343,7 +1363,7 @@ const create$h = async ({
|
|
|
1343
1363
|
webSocket
|
|
1344
1364
|
}) => {
|
|
1345
1365
|
// TODO create a commandMap per rpc instance
|
|
1346
|
-
register(commandMap);
|
|
1366
|
+
register$1(commandMap);
|
|
1347
1367
|
const rawIpc = await IpcParentWithWebSocket$1.create({
|
|
1348
1368
|
webSocket
|
|
1349
1369
|
});
|
|
@@ -1376,7 +1396,7 @@ const create$4 = async ({
|
|
|
1376
1396
|
messagePort
|
|
1377
1397
|
}) => {
|
|
1378
1398
|
// TODO create a commandMap per rpc instance
|
|
1379
|
-
register(commandMap);
|
|
1399
|
+
register$1(commandMap);
|
|
1380
1400
|
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1381
1401
|
isMessagePortOpen,
|
|
1382
1402
|
messagePort
|
|
@@ -1415,7 +1435,7 @@ const create$1 = async ({
|
|
|
1415
1435
|
commandMap
|
|
1416
1436
|
}) => {
|
|
1417
1437
|
// TODO create a commandMap per rpc instance
|
|
1418
|
-
register(commandMap);
|
|
1438
|
+
register$1(commandMap);
|
|
1419
1439
|
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1420
1440
|
handleIpc(ipc);
|
|
1421
1441
|
const rpc = createRpc(ipc);
|
|
@@ -1445,17 +1465,66 @@ const createMockRpc = ({
|
|
|
1445
1465
|
return mockRpc;
|
|
1446
1466
|
};
|
|
1447
1467
|
|
|
1468
|
+
const rpcs = Object.create(null);
|
|
1469
|
+
const set$5 = (id, rpc) => {
|
|
1470
|
+
rpcs[id] = rpc;
|
|
1471
|
+
};
|
|
1472
|
+
const get = id => {
|
|
1473
|
+
return rpcs[id];
|
|
1474
|
+
};
|
|
1475
|
+
const remove$4 = id => {
|
|
1476
|
+
delete rpcs[id];
|
|
1477
|
+
};
|
|
1478
|
+
|
|
1479
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1480
|
+
const create = rpcId => {
|
|
1481
|
+
return {
|
|
1482
|
+
async dispose() {
|
|
1483
|
+
const rpc = get(rpcId);
|
|
1484
|
+
await rpc.dispose();
|
|
1485
|
+
},
|
|
1486
|
+
// @ts-ignore
|
|
1487
|
+
invoke(method, ...params) {
|
|
1488
|
+
const rpc = get(rpcId);
|
|
1489
|
+
// @ts-ignore
|
|
1490
|
+
return rpc.invoke(method, ...params);
|
|
1491
|
+
},
|
|
1492
|
+
// @ts-ignore
|
|
1493
|
+
invokeAndTransfer(method, ...params) {
|
|
1494
|
+
const rpc = get(rpcId);
|
|
1495
|
+
// @ts-ignore
|
|
1496
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1497
|
+
},
|
|
1498
|
+
registerMockRpc(commandMap) {
|
|
1499
|
+
const mockRpc = createMockRpc({
|
|
1500
|
+
commandMap
|
|
1501
|
+
});
|
|
1502
|
+
set$5(rpcId, mockRpc);
|
|
1503
|
+
// @ts-ignore
|
|
1504
|
+
mockRpc[Symbol.dispose] = () => {
|
|
1505
|
+
remove$4(rpcId);
|
|
1506
|
+
};
|
|
1507
|
+
// @ts-ignore
|
|
1508
|
+
return mockRpc;
|
|
1509
|
+
},
|
|
1510
|
+
set(rpc) {
|
|
1511
|
+
set$5(rpcId, rpc);
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1514
|
+
};
|
|
1515
|
+
|
|
1448
1516
|
const {
|
|
1449
1517
|
invoke: invoke$3,
|
|
1450
1518
|
set: set$4
|
|
1451
|
-
} = create
|
|
1519
|
+
} = create(ExtensionHostWorker);
|
|
1452
1520
|
|
|
1453
1521
|
const {
|
|
1454
1522
|
dispose,
|
|
1455
1523
|
invoke: invoke$2,
|
|
1456
1524
|
invokeAndTransfer: invokeAndTransfer$1,
|
|
1525
|
+
registerMockRpc,
|
|
1457
1526
|
set: set$3
|
|
1458
|
-
} = create
|
|
1527
|
+
} = create(FileSystemProcess$1);
|
|
1459
1528
|
const remove$3 = async uri => {
|
|
1460
1529
|
return invoke$2('FileSystem.remove', uri);
|
|
1461
1530
|
};
|
|
@@ -1466,10 +1535,10 @@ const appendFile$2 = async (uri, text) => {
|
|
|
1466
1535
|
// @ts-ignore
|
|
1467
1536
|
return invoke$2('FileSystem.appendFile', uri, text);
|
|
1468
1537
|
};
|
|
1469
|
-
const readDirWithFileTypes$
|
|
1538
|
+
const readDirWithFileTypes$3 = async uri => {
|
|
1470
1539
|
return invoke$2('FileSystem.readDirWithFileTypes', uri);
|
|
1471
1540
|
};
|
|
1472
|
-
const getPathSeparator$
|
|
1541
|
+
const getPathSeparator$3 = async root => {
|
|
1473
1542
|
// @ts-ignore
|
|
1474
1543
|
return invoke$2('FileSystem.getPathSeparator', root);
|
|
1475
1544
|
};
|
|
@@ -1477,11 +1546,11 @@ const readJson$3 = async root => {
|
|
|
1477
1546
|
// @ts-ignore
|
|
1478
1547
|
return invoke$2('FileSystem.readJson', root);
|
|
1479
1548
|
};
|
|
1480
|
-
const getRealPath$
|
|
1549
|
+
const getRealPath$3 = async path => {
|
|
1481
1550
|
// @ts-ignore
|
|
1482
1551
|
return invoke$2('FileSystem.getRealPath', path);
|
|
1483
1552
|
};
|
|
1484
|
-
const stat$
|
|
1553
|
+
const stat$3 = async path => {
|
|
1485
1554
|
// @ts-ignore
|
|
1486
1555
|
return invoke$2('FileSystem.stat', path);
|
|
1487
1556
|
};
|
|
@@ -1489,7 +1558,7 @@ const writeFile$3 = async (path, content) => {
|
|
|
1489
1558
|
// @ts-ignore
|
|
1490
1559
|
return invoke$2('FileSystem.writeFile', path, content);
|
|
1491
1560
|
};
|
|
1492
|
-
const mkdir$
|
|
1561
|
+
const mkdir$3 = async path => {
|
|
1493
1562
|
// @ts-ignore
|
|
1494
1563
|
return invoke$2('FileSystem.mkdir', path);
|
|
1495
1564
|
};
|
|
@@ -1497,57 +1566,50 @@ const rename$3 = async (oldUri, newUri) => {
|
|
|
1497
1566
|
// @ts-ignore
|
|
1498
1567
|
return invoke$2('FileSystem.rename', oldUri, newUri);
|
|
1499
1568
|
};
|
|
1500
|
-
const copy$
|
|
1569
|
+
const copy$3 = async (oldUri, newUri) => {
|
|
1501
1570
|
// @ts-ignore
|
|
1502
1571
|
return invoke$2('FileSystem.copy', oldUri, newUri);
|
|
1503
1572
|
};
|
|
1504
|
-
const getFolderSize$
|
|
1573
|
+
const getFolderSize$3 = async uri => {
|
|
1505
1574
|
// @ts-ignore
|
|
1506
1575
|
return invoke$2('FileSystem.getFolderSize', uri);
|
|
1507
1576
|
};
|
|
1508
|
-
const exists$
|
|
1577
|
+
const exists$3 = async uri => {
|
|
1509
1578
|
// @ts-ignore
|
|
1510
1579
|
return invoke$2('FileSystem.exists', uri);
|
|
1511
1580
|
};
|
|
1512
|
-
const registerMockRpc = commandMap => {
|
|
1513
|
-
const mockRpc = createMockRpc({
|
|
1514
|
-
commandMap
|
|
1515
|
-
});
|
|
1516
|
-
set$3(mockRpc);
|
|
1517
|
-
return mockRpc;
|
|
1518
|
-
};
|
|
1519
1581
|
|
|
1520
1582
|
const FileSystemProcess = {
|
|
1521
1583
|
__proto__: null,
|
|
1522
1584
|
appendFile: appendFile$2,
|
|
1523
|
-
copy: copy$
|
|
1585
|
+
copy: copy$3,
|
|
1524
1586
|
dispose,
|
|
1525
|
-
exists: exists$
|
|
1526
|
-
getFolderSize: getFolderSize$
|
|
1527
|
-
getPathSeparator: getPathSeparator$
|
|
1528
|
-
getRealPath: getRealPath$
|
|
1587
|
+
exists: exists$3,
|
|
1588
|
+
getFolderSize: getFolderSize$3,
|
|
1589
|
+
getPathSeparator: getPathSeparator$3,
|
|
1590
|
+
getRealPath: getRealPath$3,
|
|
1529
1591
|
invoke: invoke$2,
|
|
1530
1592
|
invokeAndTransfer: invokeAndTransfer$1,
|
|
1531
|
-
mkdir: mkdir$
|
|
1532
|
-
readDirWithFileTypes: readDirWithFileTypes$
|
|
1593
|
+
mkdir: mkdir$3,
|
|
1594
|
+
readDirWithFileTypes: readDirWithFileTypes$3,
|
|
1533
1595
|
readFile: readFile$3,
|
|
1534
1596
|
readJson: readJson$3,
|
|
1535
1597
|
registerMockRpc,
|
|
1536
1598
|
remove: remove$3,
|
|
1537
1599
|
rename: rename$3,
|
|
1538
1600
|
set: set$3,
|
|
1539
|
-
stat: stat$
|
|
1601
|
+
stat: stat$3,
|
|
1540
1602
|
writeFile: writeFile$3
|
|
1541
1603
|
};
|
|
1542
1604
|
|
|
1543
1605
|
const {
|
|
1544
1606
|
set: set$2
|
|
1545
|
-
} = create
|
|
1607
|
+
} = create(RendererProcess);
|
|
1546
1608
|
|
|
1547
1609
|
const {
|
|
1548
1610
|
invokeAndTransfer,
|
|
1549
1611
|
set: set$1
|
|
1550
|
-
} = create
|
|
1612
|
+
} = create(RendererWorker);
|
|
1551
1613
|
const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
|
|
1552
1614
|
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1553
1615
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
@@ -1557,6 +1619,10 @@ const sendMessagePortToRendererProcess = async port => {
|
|
|
1557
1619
|
// @ts-ignore
|
|
1558
1620
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
|
|
1559
1621
|
};
|
|
1622
|
+
const sendMessagePortToFileSystemProcess$1 = async (port, rpcId) => {
|
|
1623
|
+
const command = 'HandleMessagePortForFileSystemProcess.handleMessagePortForFileSystemProcess';
|
|
1624
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, rpcId);
|
|
1625
|
+
};
|
|
1560
1626
|
|
|
1561
1627
|
const createLazyRpc = rpcId => {
|
|
1562
1628
|
let rpcPromise;
|
|
@@ -1574,12 +1640,12 @@ const createLazyRpc = rpcId => {
|
|
|
1574
1640
|
return {
|
|
1575
1641
|
async invoke(method, ...params) {
|
|
1576
1642
|
await ensureRpc();
|
|
1577
|
-
const rpc = get
|
|
1643
|
+
const rpc = get(rpcId);
|
|
1578
1644
|
return rpc.invoke(method, ...params);
|
|
1579
1645
|
},
|
|
1580
1646
|
async invokeAndTransfer(method, ...params) {
|
|
1581
1647
|
await ensureRpc();
|
|
1582
|
-
const rpc = get
|
|
1648
|
+
const rpc = get(rpcId);
|
|
1583
1649
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1584
1650
|
},
|
|
1585
1651
|
setFactory(value) {
|
|
@@ -1598,27 +1664,27 @@ const assertUri = uri => {
|
|
|
1598
1664
|
|
|
1599
1665
|
const {
|
|
1600
1666
|
appendFile: appendFile$1,
|
|
1601
|
-
copy: copy$
|
|
1602
|
-
exists: exists$
|
|
1603
|
-
getFolderSize: getFolderSize$
|
|
1604
|
-
getPathSeparator: getPathSeparator$
|
|
1605
|
-
getRealPath: getRealPath$
|
|
1667
|
+
copy: copy$2,
|
|
1668
|
+
exists: exists$2,
|
|
1669
|
+
getFolderSize: getFolderSize$2,
|
|
1670
|
+
getPathSeparator: getPathSeparator$2,
|
|
1671
|
+
getRealPath: getRealPath$2,
|
|
1606
1672
|
invoke: invoke$1,
|
|
1607
|
-
mkdir: mkdir$
|
|
1608
|
-
readDirWithFileTypes: readDirWithFileTypes$
|
|
1673
|
+
mkdir: mkdir$2,
|
|
1674
|
+
readDirWithFileTypes: readDirWithFileTypes$2,
|
|
1609
1675
|
readFile: readFile$2,
|
|
1610
1676
|
readJson: readJson$2,
|
|
1611
1677
|
remove: remove$2,
|
|
1612
1678
|
rename: rename$2,
|
|
1613
1679
|
set,
|
|
1614
|
-
stat: stat$
|
|
1680
|
+
stat: stat$2,
|
|
1615
1681
|
writeFile: writeFile$2
|
|
1616
1682
|
} = FileSystemProcess;
|
|
1617
1683
|
|
|
1618
1684
|
const Http = 'http:';
|
|
1619
1685
|
const Memory = 'memfs:';
|
|
1620
1686
|
const Https = 'https:';
|
|
1621
|
-
const File$
|
|
1687
|
+
const File$2 = 'file:';
|
|
1622
1688
|
|
|
1623
1689
|
const watchCallbacks = Object.create(null);
|
|
1624
1690
|
const registerWatchCallback = (id, rpcId, commandId, uri) => {
|
|
@@ -1637,7 +1703,7 @@ const executeWatchCallBack = async id => {
|
|
|
1637
1703
|
commandId,
|
|
1638
1704
|
rpcId
|
|
1639
1705
|
} = entry;
|
|
1640
|
-
const rpc = get
|
|
1706
|
+
const rpc = get(rpcId);
|
|
1641
1707
|
await rpc.invoke(commandId, id);
|
|
1642
1708
|
};
|
|
1643
1709
|
const unregisterWatchCallback = id => {
|
|
@@ -1653,11 +1719,11 @@ const getWatchCallbackIdsForUri = uri => {
|
|
|
1653
1719
|
return watchIds;
|
|
1654
1720
|
};
|
|
1655
1721
|
|
|
1656
|
-
const watchFile = async (id, uri, rpcId) => {
|
|
1722
|
+
const watchFile$2 = async (id, uri, rpcId) => {
|
|
1657
1723
|
assertUri(uri);
|
|
1658
1724
|
const commandId = 'Output.executeWatchCallback';
|
|
1659
1725
|
registerWatchCallback(id, rpcId, commandId, uri);
|
|
1660
|
-
if (uri.startsWith(File$
|
|
1726
|
+
if (uri.startsWith(File$2)) {
|
|
1661
1727
|
// @ts-ignore
|
|
1662
1728
|
await invoke$1('FileSystem.watchFile', id, uri);
|
|
1663
1729
|
}
|
|
@@ -1684,6 +1750,39 @@ const triggerMemfsFileWatcher = async uri => {
|
|
|
1684
1750
|
}
|
|
1685
1751
|
};
|
|
1686
1752
|
|
|
1753
|
+
const getFileExtension = uri => {
|
|
1754
|
+
const lastDot = uri.lastIndexOf('.');
|
|
1755
|
+
if (lastDot === -1) {
|
|
1756
|
+
return '';
|
|
1757
|
+
}
|
|
1758
|
+
const lastSlash = Math.max(uri.lastIndexOf('/'), uri.lastIndexOf('\\'));
|
|
1759
|
+
if (lastSlash > lastDot) {
|
|
1760
|
+
return '';
|
|
1761
|
+
}
|
|
1762
|
+
return uri.slice(lastDot + 1);
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
const getBlobType = uri => {
|
|
1766
|
+
const extension = getFileExtension(uri).toLowerCase();
|
|
1767
|
+
switch (extension) {
|
|
1768
|
+
case 'css':
|
|
1769
|
+
return 'text/css';
|
|
1770
|
+
case 'html':
|
|
1771
|
+
return 'text/html';
|
|
1772
|
+
case 'js':
|
|
1773
|
+
return 'text/javascript';
|
|
1774
|
+
case 'json':
|
|
1775
|
+
return 'application/json';
|
|
1776
|
+
case 'svg':
|
|
1777
|
+
return 'image/svg+xml';
|
|
1778
|
+
case 'txt':
|
|
1779
|
+
return 'text/plain';
|
|
1780
|
+
case 'xml':
|
|
1781
|
+
return 'application/xml';
|
|
1782
|
+
default:
|
|
1783
|
+
return '';
|
|
1784
|
+
}
|
|
1785
|
+
};
|
|
1687
1786
|
const remove$1 = async dirent => {
|
|
1688
1787
|
await invoke$3('FileSystemMemory.remove', dirent);
|
|
1689
1788
|
// Trigger file watchers for memfs files
|
|
@@ -1692,9 +1791,34 @@ const remove$1 = async dirent => {
|
|
|
1692
1791
|
const readFile$1 = async uri => {
|
|
1693
1792
|
return invoke$3('FileSystemMemory.readFile', uri);
|
|
1694
1793
|
};
|
|
1794
|
+
const readFileAsBlob$1 = async uri => {
|
|
1795
|
+
const content = await readFile$1(uri);
|
|
1796
|
+
const type = getBlobType(uri);
|
|
1797
|
+
if (type) {
|
|
1798
|
+
return new Blob([content], {
|
|
1799
|
+
type
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
return new Blob([content]);
|
|
1803
|
+
};
|
|
1804
|
+
const exists$1 = async uri => {
|
|
1805
|
+
throw new Error('not implemented');
|
|
1806
|
+
};
|
|
1807
|
+
const readDirWithFileTypes$1 = async uri => {
|
|
1808
|
+
throw new Error('not implemented');
|
|
1809
|
+
};
|
|
1810
|
+
const getPathSeparator$1 = async root => {
|
|
1811
|
+
return '/';
|
|
1812
|
+
};
|
|
1695
1813
|
const readJson$1 = async uri => {
|
|
1696
1814
|
throw new Error('not implemented');
|
|
1697
1815
|
};
|
|
1816
|
+
const getRealPath$1 = async path => {
|
|
1817
|
+
throw new Error('not implemented');
|
|
1818
|
+
};
|
|
1819
|
+
const stat$1 = async dirent => {
|
|
1820
|
+
throw new Error('not implemented');
|
|
1821
|
+
};
|
|
1698
1822
|
const createFile$1 = async uri => {
|
|
1699
1823
|
await invoke$3('FileSystemMemory.createFile', uri);
|
|
1700
1824
|
// Trigger file watchers for memfs files
|
|
@@ -1705,12 +1829,44 @@ const writeFile$1 = async (uri, content) => {
|
|
|
1705
1829
|
// Trigger file watchers for memfs files
|
|
1706
1830
|
await triggerMemfsFileWatcher(uri);
|
|
1707
1831
|
};
|
|
1832
|
+
const mkdir$1 = async uri => {
|
|
1833
|
+
throw new Error('not implemented');
|
|
1834
|
+
};
|
|
1708
1835
|
const rename$1 = async (oldUri, newUri) => {
|
|
1709
1836
|
await invoke$3('FileSystemMemory.rename', oldUri, newUri);
|
|
1710
1837
|
// Trigger file watchers for both old and new URIs
|
|
1711
1838
|
await triggerMemfsFileWatcher(oldUri);
|
|
1712
1839
|
await triggerMemfsFileWatcher(newUri);
|
|
1713
1840
|
};
|
|
1841
|
+
const copy$1 = async (oldUri, newUri) => {
|
|
1842
|
+
throw new Error('not implemented');
|
|
1843
|
+
};
|
|
1844
|
+
const getFolderSize$1 = async uri => {
|
|
1845
|
+
throw new Error('not implemented');
|
|
1846
|
+
};
|
|
1847
|
+
const watchFile$1 = async (id, uri) => {
|
|
1848
|
+
throw new Error('not implemented');
|
|
1849
|
+
};
|
|
1850
|
+
|
|
1851
|
+
const FileSystemMemory = {
|
|
1852
|
+
__proto__: null,
|
|
1853
|
+
copy: copy$1,
|
|
1854
|
+
createFile: createFile$1,
|
|
1855
|
+
exists: exists$1,
|
|
1856
|
+
getFolderSize: getFolderSize$1,
|
|
1857
|
+
getPathSeparator: getPathSeparator$1,
|
|
1858
|
+
getRealPath: getRealPath$1,
|
|
1859
|
+
mkdir: mkdir$1,
|
|
1860
|
+
readDirWithFileTypes: readDirWithFileTypes$1,
|
|
1861
|
+
readFile: readFile$1,
|
|
1862
|
+
readFileAsBlob: readFileAsBlob$1,
|
|
1863
|
+
readJson: readJson$1,
|
|
1864
|
+
remove: remove$1,
|
|
1865
|
+
rename: rename$1,
|
|
1866
|
+
stat: stat$1,
|
|
1867
|
+
watchFile: watchFile$1,
|
|
1868
|
+
writeFile: writeFile$1
|
|
1869
|
+
};
|
|
1714
1870
|
|
|
1715
1871
|
const isHttp = uri => {
|
|
1716
1872
|
return uri.startsWith(Http) || uri.startsWith(Https);
|
|
@@ -1739,10 +1895,10 @@ const appendFile = async (uri, text) => {
|
|
|
1739
1895
|
return appendFile$1(uri, text);
|
|
1740
1896
|
};
|
|
1741
1897
|
const readDirWithFileTypes = async uri => {
|
|
1742
|
-
return readDirWithFileTypes$
|
|
1898
|
+
return readDirWithFileTypes$2(uri);
|
|
1743
1899
|
};
|
|
1744
1900
|
const getPathSeparator = async root => {
|
|
1745
|
-
return getPathSeparator$
|
|
1901
|
+
return getPathSeparator$2(root);
|
|
1746
1902
|
};
|
|
1747
1903
|
const readJson = async uri => {
|
|
1748
1904
|
if (isHttp(uri)) {
|
|
@@ -1754,10 +1910,13 @@ const readJson = async uri => {
|
|
|
1754
1910
|
return readJson$2(uri);
|
|
1755
1911
|
};
|
|
1756
1912
|
const getRealPath = async path => {
|
|
1757
|
-
return getRealPath$
|
|
1913
|
+
return getRealPath$2(path);
|
|
1758
1914
|
};
|
|
1759
1915
|
const readFileAsBlob = async uri => {
|
|
1760
1916
|
if (isHttp(uri)) {
|
|
1917
|
+
return readFileAsBlob$2(uri);
|
|
1918
|
+
}
|
|
1919
|
+
if (isMemory(uri)) {
|
|
1761
1920
|
return readFileAsBlob$1(uri);
|
|
1762
1921
|
}
|
|
1763
1922
|
if (uri.startsWith('file:///')) {
|
|
@@ -1773,13 +1932,13 @@ const readFileAsBlob = async uri => {
|
|
|
1773
1932
|
throw new Error('uri not supported');
|
|
1774
1933
|
};
|
|
1775
1934
|
const stat = async dirent => {
|
|
1776
|
-
return stat$
|
|
1935
|
+
return stat$2(dirent);
|
|
1777
1936
|
};
|
|
1778
1937
|
const exists = async uri => {
|
|
1779
1938
|
if (isHttp(uri)) {
|
|
1780
|
-
return exists$
|
|
1939
|
+
return exists$4(uri);
|
|
1781
1940
|
}
|
|
1782
|
-
return exists$
|
|
1941
|
+
return exists$2(uri);
|
|
1783
1942
|
};
|
|
1784
1943
|
const createFile = async uri => {
|
|
1785
1944
|
if (isMemory(uri)) {
|
|
@@ -1807,7 +1966,7 @@ const writeBlob = async (uri, blob) => {
|
|
|
1807
1966
|
await invoke$1('FileSystem.writeBuffer', uri, bytes);
|
|
1808
1967
|
};
|
|
1809
1968
|
const mkdir = async uri => {
|
|
1810
|
-
return mkdir$
|
|
1969
|
+
return mkdir$2(uri);
|
|
1811
1970
|
};
|
|
1812
1971
|
const rename = async (oldUri, newUri) => {
|
|
1813
1972
|
if (isMemory(oldUri) || isMemory(newUri)) {
|
|
@@ -1816,10 +1975,36 @@ const rename = async (oldUri, newUri) => {
|
|
|
1816
1975
|
return rename$2(oldUri, newUri);
|
|
1817
1976
|
};
|
|
1818
1977
|
const copy = async (oldUri, newUri) => {
|
|
1819
|
-
return copy$
|
|
1978
|
+
return copy$2(oldUri, newUri);
|
|
1820
1979
|
};
|
|
1821
1980
|
const getFolderSize = async uri => {
|
|
1822
|
-
return getFolderSize$
|
|
1981
|
+
return getFolderSize$2(uri);
|
|
1982
|
+
};
|
|
1983
|
+
const watchFile = async (id, uri) => {
|
|
1984
|
+
// @ts-ignore
|
|
1985
|
+
await invoke$1('FileSystem.watchFile', id, uri);
|
|
1986
|
+
};
|
|
1987
|
+
|
|
1988
|
+
const FileSystemDisk = {
|
|
1989
|
+
__proto__: null,
|
|
1990
|
+
appendFile,
|
|
1991
|
+
copy,
|
|
1992
|
+
createFile,
|
|
1993
|
+
exists,
|
|
1994
|
+
getFolderSize,
|
|
1995
|
+
getPathSeparator,
|
|
1996
|
+
getRealPath,
|
|
1997
|
+
mkdir,
|
|
1998
|
+
readDirWithFileTypes,
|
|
1999
|
+
readFile,
|
|
2000
|
+
readFileAsBlob,
|
|
2001
|
+
readJson,
|
|
2002
|
+
remove,
|
|
2003
|
+
rename,
|
|
2004
|
+
stat,
|
|
2005
|
+
watchFile,
|
|
2006
|
+
writeBlob,
|
|
2007
|
+
writeFile
|
|
1823
2008
|
};
|
|
1824
2009
|
|
|
1825
2010
|
const handleMessagePort = async (port, rpcId) => {
|
|
@@ -1833,8 +2018,7 @@ const handleMessagePort = async (port, rpcId) => {
|
|
|
1833
2018
|
};
|
|
1834
2019
|
|
|
1835
2020
|
const sendMessagePortToFileSystemProcess = async port => {
|
|
1836
|
-
|
|
1837
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, FileSystemWorker);
|
|
2021
|
+
await sendMessagePortToFileSystemProcess$1(port, FileSystemWorker);
|
|
1838
2022
|
};
|
|
1839
2023
|
|
|
1840
2024
|
const createFileSystemProcessRpcElectron = async () => {
|
|
@@ -1883,7 +2067,7 @@ const createFileSystemProcessRpc = async platform => {
|
|
|
1883
2067
|
return create();
|
|
1884
2068
|
};
|
|
1885
2069
|
|
|
1886
|
-
const
|
|
2070
|
+
const initializeFileSystemProcess = async platform => {
|
|
1887
2071
|
if (platform === Web) {
|
|
1888
2072
|
return;
|
|
1889
2073
|
}
|
|
@@ -1892,11 +2076,11 @@ const initializeFileSytemProcess = async platform => {
|
|
|
1892
2076
|
};
|
|
1893
2077
|
|
|
1894
2078
|
const initialize = async platform => {
|
|
1895
|
-
await
|
|
2079
|
+
await initializeFileSystemProcess(platform);
|
|
1896
2080
|
};
|
|
1897
2081
|
|
|
1898
2082
|
const Directory = 'directory';
|
|
1899
|
-
const File = 'file';
|
|
2083
|
+
const File$1 = 'file';
|
|
1900
2084
|
|
|
1901
2085
|
const {
|
|
1902
2086
|
invoke} = createLazyRpc(RendererProcess);
|
|
@@ -1950,7 +2134,7 @@ const uploadHandle = async (fileSystemHandle, pathSeparator, root, uploadHandles
|
|
|
1950
2134
|
switch (kind) {
|
|
1951
2135
|
case Directory:
|
|
1952
2136
|
return uploadDirectory(fileSystemHandle, pathSeparator, root, uploadHandles);
|
|
1953
|
-
case File:
|
|
2137
|
+
case File$1:
|
|
1954
2138
|
return uploadFile(fileSystemHandle, pathSeparator, root);
|
|
1955
2139
|
default:
|
|
1956
2140
|
throw new Error(`unsupported file system handle type ${kind}`);
|
|
@@ -2002,12 +2186,30 @@ const commandMap = {
|
|
|
2002
2186
|
'FileSystem.stat': stat,
|
|
2003
2187
|
'FileSystem.unwatchFile': unwatchFile,
|
|
2004
2188
|
'FileSystem.uploadFileSystemHandles': uploadFileSystemHandles,
|
|
2005
|
-
'FileSystem.watchFile': watchFile,
|
|
2189
|
+
'FileSystem.watchFile': watchFile$2,
|
|
2006
2190
|
'FileSystem.writeBlob': writeBlob,
|
|
2007
2191
|
'FileSystem.writeFile': writeFile,
|
|
2008
2192
|
'Initialize.initialize': initialize
|
|
2009
2193
|
};
|
|
2010
2194
|
|
|
2195
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
2196
|
+
|
|
2197
|
+
const state = Object.create(null);
|
|
2198
|
+
const register = modules => {
|
|
2199
|
+
Object.assign(state, modules);
|
|
2200
|
+
};
|
|
2201
|
+
|
|
2202
|
+
const Memfs = 'memfs';
|
|
2203
|
+
const Fetch = 'fetch';
|
|
2204
|
+
const File = 'file';
|
|
2205
|
+
|
|
2206
|
+
// TODO add others
|
|
2207
|
+
const fileSystemModules = {
|
|
2208
|
+
[Fetch]: FileSystemFetch,
|
|
2209
|
+
[File]: FileSystemDisk,
|
|
2210
|
+
[Memfs]: FileSystemMemory
|
|
2211
|
+
};
|
|
2212
|
+
|
|
2011
2213
|
const initializeExtensionHostWorker = async () => {
|
|
2012
2214
|
try {
|
|
2013
2215
|
const rpc = await LazyTransferMessagePortRpcParent.create({
|
|
@@ -2041,6 +2243,7 @@ const initializeRendererWorker = async () => {
|
|
|
2041
2243
|
|
|
2042
2244
|
const listen = async () => {
|
|
2043
2245
|
Object.assign(commandMapRef, commandMap);
|
|
2246
|
+
register(fileSystemModules);
|
|
2044
2247
|
await Promise.all([initializeExtensionHostWorker(), initializeRendererProcess(), initializeRendererWorker()]);
|
|
2045
2248
|
};
|
|
2046
2249
|
|