@lvce-editor/file-system-worker 1.18.0 → 1.20.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 +15 -4
- package/package.json +1 -1
|
@@ -1325,16 +1325,24 @@ const unregisterWatchCallback = id => {
|
|
|
1325
1325
|
delete watchCallbacks[id];
|
|
1326
1326
|
};
|
|
1327
1327
|
|
|
1328
|
-
const watchFile = async (id, uri,
|
|
1328
|
+
const watchFile = async (id, uri, rpcId) => {
|
|
1329
1329
|
const commandId = 'Output.executeWatchCallback';
|
|
1330
1330
|
registerWatchCallback(id, async () => {
|
|
1331
|
+
const rpc = get(rpcId);
|
|
1332
|
+
if (!rpc) {
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1331
1335
|
await rpc.invoke(commandId);
|
|
1332
1336
|
});
|
|
1333
1337
|
// @ts-ignore
|
|
1334
1338
|
await invoke('FileSystem.watchFile', id, uri);
|
|
1335
1339
|
};
|
|
1336
1340
|
const executeWatchCallback = async id => {
|
|
1337
|
-
|
|
1341
|
+
try {
|
|
1342
|
+
await executeWatchCallBack(id);
|
|
1343
|
+
} catch (error) {
|
|
1344
|
+
console.error(error);
|
|
1345
|
+
}
|
|
1338
1346
|
};
|
|
1339
1347
|
const unwatchFile = async id => {
|
|
1340
1348
|
unregisterWatchCallback(id);
|
|
@@ -1389,11 +1397,13 @@ const createFileSystemProcessRpcElectron = async () => {
|
|
|
1389
1397
|
}
|
|
1390
1398
|
};
|
|
1391
1399
|
|
|
1400
|
+
const commandMapRef = {};
|
|
1401
|
+
|
|
1392
1402
|
const createFileSystemProcessRpcNode = async () => {
|
|
1393
1403
|
try {
|
|
1394
1404
|
const rpc = await WebSocketRpcParent2.create({
|
|
1395
1405
|
type: 'file-system-process',
|
|
1396
|
-
commandMap:
|
|
1406
|
+
commandMap: commandMapRef
|
|
1397
1407
|
});
|
|
1398
1408
|
return rpc;
|
|
1399
1409
|
} catch (error) {
|
|
@@ -1437,7 +1447,7 @@ const commandMap = {
|
|
|
1437
1447
|
'FileSystem.appendFile': appendFile,
|
|
1438
1448
|
'FileSystem.copy': copy,
|
|
1439
1449
|
'FileSystem.createFile': createFile,
|
|
1440
|
-
'FileSystem.
|
|
1450
|
+
'FileSystem.executeWatchCallback': executeWatchCallback,
|
|
1441
1451
|
'FileSystem.exists': exists,
|
|
1442
1452
|
'FileSystem.getFolderSize': getFolderSize,
|
|
1443
1453
|
'FileSystem.getPathSeparator': getPathSeparator,
|
|
@@ -1458,6 +1468,7 @@ const commandMap = {
|
|
|
1458
1468
|
};
|
|
1459
1469
|
|
|
1460
1470
|
const listen = async () => {
|
|
1471
|
+
Object.assign(commandMapRef, commandMap);
|
|
1461
1472
|
const rpc = await WebWorkerRpcClient.create({
|
|
1462
1473
|
commandMap: commandMap
|
|
1463
1474
|
});
|