@lvce-editor/file-system-worker 1.25.0 → 2.0.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.
@@ -535,13 +535,13 @@ const create$4$1 = (method, params) => {
535
535
  };
536
536
  };
537
537
  const callbacks = Object.create(null);
538
- const set$2 = (id, fn) => {
538
+ const set$5 = (id, fn) => {
539
539
  callbacks[id] = fn;
540
540
  };
541
541
  const get$1 = id => {
542
542
  return callbacks[id];
543
543
  };
544
- const remove$2 = id => {
544
+ const remove$3 = id => {
545
545
  delete callbacks[id];
546
546
  };
547
547
  let id = 0;
@@ -554,7 +554,7 @@ const registerPromise = () => {
554
554
  resolve,
555
555
  promise
556
556
  } = Promise.withResolvers();
557
- set$2(id, resolve);
557
+ set$5(id, resolve);
558
558
  return {
559
559
  id,
560
560
  promise
@@ -726,7 +726,7 @@ const resolve = (id, response) => {
726
726
  return;
727
727
  }
728
728
  fn(response);
729
- remove$2(id);
729
+ remove$3(id);
730
730
  };
731
731
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
732
732
  const getErrorType = prettyError => {
@@ -899,10 +899,10 @@ const send = (transport, method, ...params) => {
899
899
  const message = create$4$1(method, params);
900
900
  transport.send(message);
901
901
  };
902
- const invoke$2 = (ipc, method, ...params) => {
902
+ const invoke$4 = (ipc, method, ...params) => {
903
903
  return invokeHelper(ipc, method, params, false);
904
904
  };
905
- const invokeAndTransfer$1 = (ipc, method, ...params) => {
905
+ const invokeAndTransfer$3 = (ipc, method, ...params) => {
906
906
  return invokeHelper(ipc, method, params, true);
907
907
  };
908
908
 
@@ -938,10 +938,10 @@ const createRpc = ipc => {
938
938
  send(ipc, method, ...params);
939
939
  },
940
940
  invoke(method, ...params) {
941
- return invoke$2(ipc, method, ...params);
941
+ return invoke$4(ipc, method, ...params);
942
942
  },
943
943
  invokeAndTransfer(method, ...params) {
944
- return invokeAndTransfer$1(ipc, method, ...params);
944
+ return invokeAndTransfer$3(ipc, method, ...params);
945
945
  },
946
946
  async dispose() {
947
947
  await ipc?.dispose();
@@ -1074,8 +1074,27 @@ const WebWorkerRpcClient = {
1074
1074
  __proto__: null,
1075
1075
  create: create$3
1076
1076
  };
1077
+ const createMockRpc = ({
1078
+ commandMap
1079
+ }) => {
1080
+ const invocations = [];
1081
+ const invoke = (method, ...params) => {
1082
+ invocations.push([method, ...params]);
1083
+ const command = commandMap[method];
1084
+ if (!command) {
1085
+ throw new Error(`command ${method} not found`);
1086
+ }
1087
+ return command(...params);
1088
+ };
1089
+ const mockRpc = {
1090
+ invoke,
1091
+ invokeAndTransfer: invoke,
1092
+ invocations
1093
+ };
1094
+ return mockRpc;
1095
+ };
1077
1096
 
1078
- const readFile$3 = async uri => {
1097
+ const readFile$5 = async uri => {
1079
1098
  const response = await fetch(uri);
1080
1099
  if (!response.ok) {
1081
1100
  throw new Error(response.statusText);
@@ -1091,7 +1110,7 @@ const readFileAsBlob$1 = async uri => {
1091
1110
  const result = await response.blob();
1092
1111
  return result;
1093
1112
  };
1094
- const exists$2 = async uri => {
1113
+ const exists$3 = async uri => {
1095
1114
  const response = await fetch(uri);
1096
1115
  if (response.ok) {
1097
1116
  return true;
@@ -1107,16 +1126,19 @@ const readJson$4 = async uri => {
1107
1126
  return json;
1108
1127
  };
1109
1128
 
1129
+ const DebugWorker = 55;
1130
+ const FileSystemProcess$1 = 210;
1131
+ const FileSystemWorker = 209;
1132
+ const RendererWorker$1 = 1;
1133
+
1110
1134
  const rpcs = Object.create(null);
1111
- const set$g = (id, rpc) => {
1135
+ const set$4 = (id, rpc) => {
1112
1136
  rpcs[id] = rpc;
1113
1137
  };
1114
1138
  const get = id => {
1115
1139
  return rpcs[id];
1116
1140
  };
1117
1141
 
1118
- /* eslint-disable @typescript-eslint/explicit-function-return-type */
1119
-
1120
1142
  const create = rpcId => {
1121
1143
  return {
1122
1144
  // @ts-ignore
@@ -1132,7 +1154,7 @@ const create = rpcId => {
1132
1154
  return rpc.invokeAndTransfer(method, ...params);
1133
1155
  },
1134
1156
  set(rpc) {
1135
- set$g(rpcId, rpc);
1157
+ set$4(rpcId, rpc);
1136
1158
  },
1137
1159
  async dispose() {
1138
1160
  const rpc = get(rpcId);
@@ -1140,99 +1162,437 @@ const create = rpcId => {
1140
1162
  }
1141
1163
  };
1142
1164
  };
1143
- const RendererWorker$1 = 1;
1144
- const FileSystemWorker$1 = 209;
1145
- const FileSystemProcess$1 = 210;
1146
- const RpcId = {
1147
- __proto__: null,
1148
- FileSystemWorker: FileSystemWorker$1};
1165
+
1149
1166
  const {
1150
- invoke: invoke$8,
1151
- set: set$8} = create(FileSystemProcess$1);
1152
- const remove$1$1 = async uri => {
1153
- return invoke$8('FileSystem.remove', uri);
1154
- };
1155
- const readFile$2$1 = async uri => {
1156
- return invoke$8('FileSystem.readFile', uri);
1157
- };
1158
- const appendFile$1$1 = async (uri, text) => {
1167
+ invoke: invoke$3,
1168
+ invokeAndTransfer: invokeAndTransfer$2,
1169
+ set: set$3,
1170
+ dispose: dispose$1
1171
+ } = create(FileSystemProcess$1);
1172
+ const remove$2 = async uri => {
1173
+ return invoke$3('FileSystem.remove', uri);
1174
+ };
1175
+ const readFile$4 = async uri => {
1176
+ return invoke$3('FileSystem.readFile', uri);
1177
+ };
1178
+ const appendFile$2 = async (uri, text) => {
1159
1179
  // @ts-ignore
1160
- return invoke$8('FileSystem.appendFile', uri, text);
1180
+ return invoke$3('FileSystem.appendFile', uri, text);
1161
1181
  };
1162
- const readDirWithFileTypes$1$1 = async uri => {
1163
- return invoke$8('FileSystem.readDirWithFileTypes', uri);
1182
+ const readDirWithFileTypes$2 = async uri => {
1183
+ return invoke$3('FileSystem.readDirWithFileTypes', uri);
1164
1184
  };
1165
- const getPathSeparator$1$1 = async root => {
1185
+ const getPathSeparator$2 = async root => {
1166
1186
  // @ts-ignore
1167
- return invoke$8('FileSystem.getPathSeparator', root);
1187
+ return invoke$3('FileSystem.getPathSeparator', root);
1168
1188
  };
1169
1189
  const readJson$3 = async root => {
1170
1190
  // @ts-ignore
1171
- return invoke$8('FileSystem.readJson', root);
1191
+ return invoke$3('FileSystem.readJson', root);
1172
1192
  };
1173
- const getRealPath$1$1 = async path => {
1193
+ const getRealPath$2 = async path => {
1174
1194
  // @ts-ignore
1175
- return invoke$8('FileSystem.getRealPath', path);
1195
+ return invoke$3('FileSystem.getRealPath', path);
1176
1196
  };
1177
- const stat$1$1 = async path => {
1197
+ const stat$2 = async path => {
1178
1198
  // @ts-ignore
1179
- return invoke$8('FileSystem.stat', path);
1199
+ return invoke$3('FileSystem.stat', path);
1180
1200
  };
1181
- const writeFile$1$1 = async (path, content) => {
1201
+ const writeFile$3 = async (path, content) => {
1182
1202
  // @ts-ignore
1183
- return invoke$8('FileSystem.writeFile', path, content);
1203
+ return invoke$3('FileSystem.writeFile', path, content);
1184
1204
  };
1185
- const mkdir$1$1 = async path => {
1205
+ const mkdir$2 = async path => {
1186
1206
  // @ts-ignore
1187
- return invoke$8('FileSystem.mkdir', path);
1207
+ return invoke$3('FileSystem.mkdir', path);
1188
1208
  };
1189
- const rename$1$1 = async (oldUri, newUri) => {
1209
+ const rename$2 = async (oldUri, newUri) => {
1190
1210
  // @ts-ignore
1191
- return invoke$8('FileSystem.rename', oldUri, newUri);
1211
+ return invoke$3('FileSystem.rename', oldUri, newUri);
1192
1212
  };
1193
- const copy$1$1 = async (oldUri, newUri) => {
1213
+ const copy$2 = async (oldUri, newUri) => {
1194
1214
  // @ts-ignore
1195
- return invoke$8('FileSystem.copy', oldUri, newUri);
1215
+ return invoke$3('FileSystem.copy', oldUri, newUri);
1196
1216
  };
1197
- const getFolderSize$2 = async uri => {
1217
+ const getFolderSize$3 = async uri => {
1198
1218
  // @ts-ignore
1199
- return invoke$8('FileSystem.getFolderSize', uri);
1219
+ return invoke$3('FileSystem.getFolderSize', uri);
1200
1220
  };
1201
- const exists$1$1 = async uri => {
1221
+ const exists$2 = async uri => {
1202
1222
  // @ts-ignore
1203
- return invoke$8('FileSystem.exists', uri);
1223
+ return invoke$3('FileSystem.exists', uri);
1204
1224
  };
1225
+
1205
1226
  const FileSystemProcess = {
1206
1227
  __proto__: null,
1207
- appendFile: appendFile$1$1,
1208
- copy: copy$1$1,
1209
- exists: exists$1$1,
1210
- getFolderSize: getFolderSize$2,
1211
- getPathSeparator: getPathSeparator$1$1,
1212
- getRealPath: getRealPath$1$1,
1213
- invoke: invoke$8,
1214
- mkdir: mkdir$1$1,
1215
- readDirWithFileTypes: readDirWithFileTypes$1$1,
1216
- readFile: readFile$2$1,
1228
+ appendFile: appendFile$2,
1229
+ copy: copy$2,
1230
+ dispose: dispose$1,
1231
+ exists: exists$2,
1232
+ getFolderSize: getFolderSize$3,
1233
+ getPathSeparator: getPathSeparator$2,
1234
+ getRealPath: getRealPath$2,
1235
+ invoke: invoke$3,
1236
+ invokeAndTransfer: invokeAndTransfer$2,
1237
+ mkdir: mkdir$2,
1238
+ readDirWithFileTypes: readDirWithFileTypes$2,
1239
+ readFile: readFile$4,
1217
1240
  readJson: readJson$3,
1218
- remove: remove$1$1,
1219
- rename: rename$1$1,
1220
- set: set$8,
1221
- stat: stat$1$1,
1222
- writeFile: writeFile$1$1
1241
+ remove: remove$2,
1242
+ rename: rename$2,
1243
+ set: set$3,
1244
+ stat: stat$2,
1245
+ writeFile: writeFile$3
1223
1246
  };
1247
+
1224
1248
  const {
1225
- invokeAndTransfer: invokeAndTransfer$3,
1226
- set: set$3} = create(RendererWorker$1);
1249
+ invoke: invoke$2,
1250
+ invokeAndTransfer: invokeAndTransfer$1,
1251
+ set: set$2,
1252
+ dispose
1253
+ } = create(RendererWorker$1);
1254
+ const searchFileHtml = async uri => {
1255
+ return invoke$2('ExtensionHost.searchFileWithHtml', uri);
1256
+ };
1257
+ const getFilePathElectron = async file => {
1258
+ return invoke$2('FileSystemHandle.getFilePathElectron', file);
1259
+ };
1260
+ const showContextMenu = async (x, y, id, ...args) => {
1261
+ return invoke$2('ContextMenu.show', x, y, id, ...args);
1262
+ };
1263
+ const getElectronVersion = async () => {
1264
+ return invoke$2('Process.getElectronVersion');
1265
+ };
1266
+ const applyBulkReplacement = async bulkEdits => {
1267
+ await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
1268
+ };
1269
+ const setColorTheme = async id => {
1270
+ // @ts-ignore
1271
+ return invoke$2(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1272
+ };
1273
+ const getNodeVersion = async () => {
1274
+ return invoke$2('Process.getNodeVersion');
1275
+ };
1276
+ const getChromeVersion = async () => {
1277
+ return invoke$2('Process.getChromeVersion');
1278
+ };
1279
+ const getV8Version = async () => {
1280
+ return invoke$2('Process.getV8Version');
1281
+ };
1282
+ const getFileHandles = async fileIds => {
1283
+ const files = await invoke$2('FileSystemHandle.getFileHandles', fileIds);
1284
+ return files;
1285
+ };
1286
+ const setWorkspacePath = async path => {
1287
+ await invoke$2('Workspace.setPath', path);
1288
+ };
1289
+ const registerWebViewInterceptor = async (id, port) => {
1290
+ await invokeAndTransfer$1('WebView.registerInterceptor', id, port);
1291
+ };
1292
+ const unregisterWebViewInterceptor = async id => {
1293
+ await invoke$2('WebView.unregisterInterceptor', id);
1294
+ };
1295
+ const sendMessagePortToEditorWorker = async (port, rpcId) => {
1296
+ const command = 'HandleMessagePort.handleMessagePort';
1297
+ // @ts-ignore
1298
+ await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1299
+ };
1300
+ const sendMessagePortToErrorWorker = async (port, rpcId) => {
1301
+ const command = 'Errors.handleMessagePort';
1302
+ // @ts-ignore
1303
+ await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
1304
+ };
1305
+ const sendMessagePortToMarkdownWorker = async (port, rpcId) => {
1306
+ const command = 'Markdown.handleMessagePort';
1307
+ // @ts-ignore
1308
+ await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
1309
+ };
1310
+ const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
1311
+ const command = 'FileSystem.handleMessagePort';
1312
+ // @ts-ignore
1313
+ await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1314
+ };
1315
+ const readFile$3 = async uri => {
1316
+ return invoke$2('FileSystem.readFile', uri);
1317
+ };
1318
+ const getWebViewSecret = async key => {
1319
+ // @ts-ignore
1320
+ return invoke$2('WebView.getSecret', key);
1321
+ };
1322
+ const setWebViewPort = async (uid, port, origin, portType) => {
1323
+ return invokeAndTransfer$1('WebView.setPort', uid, port, origin, portType);
1324
+ };
1325
+ const setFocus = key => {
1326
+ return invoke$2('Focus.setFocus', key);
1327
+ };
1328
+ const getFileIcon = async options => {
1329
+ return invoke$2('IconTheme.getFileIcon', options);
1330
+ };
1331
+ const getColorThemeNames = async () => {
1332
+ return invoke$2('ColorTheme.getColorThemeNames');
1333
+ };
1334
+ const disableExtension = async id => {
1335
+ // @ts-ignore
1336
+ return invoke$2('ExtensionManagement.disable', id);
1337
+ };
1338
+ const enableExtension = async id => {
1339
+ // @ts-ignore
1340
+ return invoke$2('ExtensionManagement.enable', id);
1341
+ };
1342
+ const handleDebugChange = async params => {
1343
+ // @ts-ignore
1344
+ return invoke$2('Run And Debug.handleChange', params);
1345
+ };
1346
+ const getFolderIcon = async options => {
1347
+ return invoke$2('IconTheme.getFolderIcon', options);
1348
+ };
1349
+ const closeWidget = async widgetId => {
1350
+ return invoke$2('Viewlet.closeWidget', widgetId);
1351
+ };
1227
1352
  const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
1228
1353
  const command = 'HandleMessagePort.handleMessagePort2';
1229
- await invokeAndTransfer$3('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1354
+ await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1355
+ };
1356
+ const sendMessagePortToSearchProcess = async port => {
1357
+ await invokeAndTransfer$1('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
1358
+ };
1359
+ const confirm = async (message, options) => {
1360
+ // @ts-ignore
1361
+ const result = await invoke$2('ConfirmPrompt.prompt', message, options);
1362
+ return result;
1363
+ };
1364
+ const getRecentlyOpened = async () => {
1365
+ return invoke$2(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1366
+ };
1367
+ const getKeyBindings = async () => {
1368
+ return invoke$2('KeyBindingsInitial.getKeyBindings');
1369
+ };
1370
+ const writeClipBoardText = async text => {
1371
+ await invoke$2('ClipBoard.writeText', /* text */text);
1372
+ };
1373
+ const writeClipBoardImage = async blob => {
1374
+ // @ts-ignore
1375
+ await invoke$2('ClipBoard.writeImage', /* text */blob);
1376
+ };
1377
+ const searchFileMemory = async uri => {
1378
+ // @ts-ignore
1379
+ return invoke$2('ExtensionHost.searchFileWithMemory', uri);
1380
+ };
1381
+ const searchFileFetch = async uri => {
1382
+ return invoke$2('ExtensionHost.searchFileWithFetch', uri);
1383
+ };
1384
+ const showMessageBox = async options => {
1385
+ return invoke$2('ElectronDialog.showMessageBox', options);
1230
1386
  };
1387
+ const handleDebugResumed = async params => {
1388
+ await invoke$2('Run And Debug.handleResumed', params);
1389
+ };
1390
+ const openWidget = async name => {
1391
+ await invoke$2('Viewlet.openWidget', name);
1392
+ };
1393
+ const getIcons = async requests => {
1394
+ const icons = await invoke$2('IconTheme.getIcons', requests);
1395
+ return icons;
1396
+ };
1397
+ const activateByEvent = event => {
1398
+ return invoke$2('ExtensionHostManagement.activateByEvent', event);
1399
+ };
1400
+ const setAdditionalFocus = focusKey => {
1401
+ // @ts-ignore
1402
+ return invoke$2('Focus.setAdditionalFocus', focusKey);
1403
+ };
1404
+ const getActiveEditorId = () => {
1405
+ // @ts-ignore
1406
+ return invoke$2('GetActiveEditor.getActiveEditorId');
1407
+ };
1408
+ const getWorkspacePath = () => {
1409
+ return invoke$2('Workspace.getPath');
1410
+ };
1411
+ const sendMessagePortToRendererProcess = async port => {
1412
+ const command = 'HandleMessagePort.handleMessagePort';
1413
+ // @ts-ignore
1414
+ await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1415
+ };
1416
+ const getPreference = async key => {
1417
+ return await invoke$2('Preferences.get', key);
1418
+ };
1419
+ const getAllExtensions = async () => {
1420
+ return invoke$2('ExtensionManagement.getAllExtensions');
1421
+ };
1422
+ const rerenderEditor = async key => {
1423
+ // @ts-ignore
1424
+ return invoke$2('Editor.rerender', key);
1425
+ };
1426
+ const handleDebugPaused = async params => {
1427
+ await invoke$2('Run And Debug.handlePaused', params);
1428
+ };
1429
+ const openUri = async (uri, focus, options) => {
1430
+ await invoke$2('Main.openUri', uri, focus, options);
1431
+ };
1432
+ const sendMessagePortToSyntaxHighlightingWorker = async port => {
1433
+ await invokeAndTransfer$1(
1434
+ // @ts-ignore
1435
+ 'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
1436
+ };
1437
+ const handleDebugScriptParsed = async script => {
1438
+ await invoke$2('Run And Debug.handleScriptParsed', script);
1439
+ };
1440
+ const getWindowId = async () => {
1441
+ return invoke$2('GetWindowId.getWindowId');
1442
+ };
1443
+ const getBlob = async uri => {
1444
+ // @ts-ignore
1445
+ return invoke$2('FileSystem.getBlob', uri);
1446
+ };
1447
+ const getExtensionCommands = async () => {
1448
+ return invoke$2('ExtensionHost.getCommands');
1449
+ };
1450
+ const showErrorDialog = async errorInfo => {
1451
+ // @ts-ignore
1452
+ await invoke$2('ErrorHandling.showErrorDialog', errorInfo);
1453
+ };
1454
+ const getFolderSize$2 = async uri => {
1455
+ // @ts-ignore
1456
+ return await invoke$2('FileSystem.getFolderSize', uri);
1457
+ };
1458
+ const getExtension = async id => {
1459
+ // @ts-ignore
1460
+ return invoke$2('ExtensionManagement.getExtension', id);
1461
+ };
1462
+ const getMarkdownDom = async html => {
1463
+ // @ts-ignore
1464
+ return invoke$2('Markdown.getVirtualDom', html);
1465
+ };
1466
+ const renderMarkdown = async (markdown, options) => {
1467
+ // @ts-ignore
1468
+ return invoke$2('Markdown.renderMarkdown', markdown, options);
1469
+ };
1470
+ const openNativeFolder = async uri => {
1471
+ // @ts-ignore
1472
+ await invoke$2('OpenNativeFolder.openNativeFolder', uri);
1473
+ };
1474
+ const uninstallExtension = async id => {
1475
+ return invoke$2('ExtensionManagement.uninstall', id);
1476
+ };
1477
+ const installExtension = async id => {
1478
+ // @ts-ignore
1479
+ return invoke$2('ExtensionManagement.install', id);
1480
+ };
1481
+ const openExtensionSearch = async () => {
1482
+ // @ts-ignore
1483
+ return invoke$2('SideBar.openViewlet', 'Extensions');
1484
+ };
1485
+ const setExtensionsSearchValue = async searchValue => {
1486
+ // @ts-ignore
1487
+ return invoke$2('Extensions.handleInput', searchValue);
1488
+ };
1489
+ const openExternal = async uri => {
1490
+ // @ts-ignore
1491
+ await invoke$2('Open.openExternal', uri);
1492
+ };
1493
+ const openUrl = async uri => {
1494
+ // @ts-ignore
1495
+ await invoke$2('Open.openUrl', uri);
1496
+ };
1497
+ const getAllPreferences = async () => {
1498
+ // @ts-ignore
1499
+ return invoke$2('Preferences.getAll');
1500
+ };
1501
+ const showSaveFilePicker = async () => {
1502
+ // @ts-ignore
1503
+ return invoke$2('FilePicker.showSaveFilePicker');
1504
+ };
1505
+ const getLogsDir = async () => {
1506
+ // @ts-ignore
1507
+ return invoke$2('PlatformPaths.getLogsDir');
1508
+ };
1509
+ const registerMockRpc = commandMap => {
1510
+ const mockRpc = createMockRpc({
1511
+ commandMap
1512
+ });
1513
+ set$2(mockRpc);
1514
+ return mockRpc;
1515
+ };
1516
+
1231
1517
  const RendererWorker = {
1232
1518
  __proto__: null,
1233
- invokeAndTransfer: invokeAndTransfer$3,
1519
+ activateByEvent,
1520
+ applyBulkReplacement,
1521
+ closeWidget,
1522
+ confirm,
1523
+ disableExtension,
1524
+ dispose,
1525
+ enableExtension,
1526
+ getActiveEditorId,
1527
+ getAllExtensions,
1528
+ getAllPreferences,
1529
+ getBlob,
1530
+ getChromeVersion,
1531
+ getColorThemeNames,
1532
+ getElectronVersion,
1533
+ getExtension,
1534
+ getExtensionCommands,
1535
+ getFileHandles,
1536
+ getFileIcon,
1537
+ getFilePathElectron,
1538
+ getFolderIcon,
1539
+ getFolderSize: getFolderSize$2,
1540
+ getIcons,
1541
+ getKeyBindings,
1542
+ getLogsDir,
1543
+ getMarkdownDom,
1544
+ getNodeVersion,
1545
+ getPreference,
1546
+ getRecentlyOpened,
1547
+ getV8Version,
1548
+ getWebViewSecret,
1549
+ getWindowId,
1550
+ getWorkspacePath,
1551
+ handleDebugChange,
1552
+ handleDebugPaused,
1553
+ handleDebugResumed,
1554
+ handleDebugScriptParsed,
1555
+ installExtension,
1556
+ invoke: invoke$2,
1557
+ invokeAndTransfer: invokeAndTransfer$1,
1558
+ openExtensionSearch,
1559
+ openExternal,
1560
+ openNativeFolder,
1561
+ openUri,
1562
+ openUrl,
1563
+ openWidget,
1564
+ readFile: readFile$3,
1565
+ registerMockRpc,
1566
+ registerWebViewInterceptor,
1567
+ renderMarkdown,
1568
+ rerenderEditor,
1569
+ searchFileFetch,
1570
+ searchFileHtml,
1571
+ searchFileMemory,
1572
+ sendMessagePortToEditorWorker,
1573
+ sendMessagePortToErrorWorker,
1234
1574
  sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
1235
- set: set$3};
1575
+ sendMessagePortToFileSystemWorker,
1576
+ sendMessagePortToMarkdownWorker,
1577
+ sendMessagePortToRendererProcess,
1578
+ sendMessagePortToSearchProcess,
1579
+ sendMessagePortToSyntaxHighlightingWorker,
1580
+ set: set$2,
1581
+ setAdditionalFocus,
1582
+ setColorTheme,
1583
+ setExtensionsSearchValue,
1584
+ setFocus,
1585
+ setWebViewPort,
1586
+ setWorkspacePath,
1587
+ showContextMenu,
1588
+ showErrorDialog,
1589
+ showMessageBox,
1590
+ showSaveFilePicker,
1591
+ uninstallExtension,
1592
+ unregisterWebViewInterceptor,
1593
+ writeClipBoardImage,
1594
+ writeClipBoardText
1595
+ };
1236
1596
 
1237
1597
  const getPortTuple = () => {
1238
1598
  const {
@@ -1312,6 +1672,7 @@ const {
1312
1672
  const Http = 'http:';
1313
1673
  const Memory = 'memfs:';
1314
1674
  const Https = 'https:';
1675
+ const File = 'file:';
1315
1676
 
1316
1677
  const isHttp = uri => {
1317
1678
  return uri.startsWith(Http) || uri.startsWith(Https);
@@ -1326,7 +1687,7 @@ const remove = async dirent => {
1326
1687
  };
1327
1688
  const readFile = async uri => {
1328
1689
  if (isHttp(uri)) {
1329
- return readFile$3(uri);
1690
+ return readFile$5(uri);
1330
1691
  }
1331
1692
  if (isMemory(uri)) {
1332
1693
  return readFile$2(uri);
@@ -1375,7 +1736,7 @@ const stat = async dirent => {
1375
1736
  };
1376
1737
  const exists = async uri => {
1377
1738
  if (isHttp(uri)) {
1378
- return exists$2(uri);
1739
+ return exists$3(uri);
1379
1740
  }
1380
1741
  return exists$1(uri);
1381
1742
  };
@@ -1401,28 +1762,47 @@ const getFolderSize = async uri => {
1401
1762
  return getFolderSize$1(uri);
1402
1763
  };
1403
1764
 
1765
+ const RE_PROTOCOL = /^([a-z-]+):\/\//;
1766
+ const assertUri = uri => {
1767
+ const protocolMatch = uri.match(RE_PROTOCOL);
1768
+ if (!protocolMatch) {
1769
+ throw new Error(`uri must be a valid uri`);
1770
+ }
1771
+ };
1772
+
1404
1773
  const watchCallbacks = Object.create(null);
1405
- const registerWatchCallback = (id, fn) => {
1406
- watchCallbacks[id] = fn;
1774
+ const registerWatchCallback = (id, rpcId, commandId) => {
1775
+ watchCallbacks[id] = {
1776
+ rpcId,
1777
+ commandId
1778
+ };
1407
1779
  };
1408
1780
  const executeWatchCallBack = async id => {
1409
- await watchCallbacks[id]();
1781
+ const entry = watchCallbacks[id];
1782
+ if (!entry) {
1783
+ throw new Error(`watch callback ${id} not found`);
1784
+ }
1785
+ const {
1786
+ rpcId,
1787
+ commandId
1788
+ } = entry;
1789
+ const rpc = get(rpcId);
1790
+ await rpc.invoke(commandId, id);
1410
1791
  };
1411
1792
  const unregisterWatchCallback = id => {
1412
1793
  delete watchCallbacks[id];
1413
1794
  };
1414
1795
 
1796
+ // TODO support file watchers for differenr protocols like memfs, http
1797
+
1415
1798
  const watchFile = async (id, uri, rpcId) => {
1799
+ assertUri(uri);
1416
1800
  const commandId = 'Output.executeWatchCallback';
1417
- registerWatchCallback(id, async () => {
1418
- const rpc = get(rpcId);
1419
- if (!rpc) {
1420
- return;
1421
- }
1422
- await rpc.invoke(commandId, id);
1423
- });
1424
- // @ts-ignore
1425
- await invoke('FileSystem.watchFile', id, uri);
1801
+ registerWatchCallback(id, rpcId, commandId);
1802
+ if (uri.startsWith(File)) {
1803
+ // @ts-ignore
1804
+ await invoke('FileSystem.watchFile', id, uri);
1805
+ }
1426
1806
  };
1427
1807
  const executeWatchCallback = async id => {
1428
1808
  try {
@@ -1433,6 +1813,7 @@ const executeWatchCallback = async id => {
1433
1813
  };
1434
1814
  const unwatchFile = async id => {
1435
1815
  unregisterWatchCallback(id);
1816
+ // TODO only if it is a file uri
1436
1817
  // @ts-ignore
1437
1818
  await invoke('FileSystem.unwatchFile', id);
1438
1819
  };
@@ -1443,13 +1824,13 @@ const handleMessagePort = async (port, rpcId) => {
1443
1824
  messagePort: port
1444
1825
  });
1445
1826
  if (rpcId) {
1446
- set$g(rpcId, rpc);
1827
+ set$4(rpcId, rpc);
1447
1828
  }
1448
1829
  };
1449
1830
 
1450
1831
  const sendMessagePortToFileSystemProcess = async port => {
1451
1832
  const command = 'HandleMessagePortForFileSystemProcess.handleMessagePortForFileSystemProcess';
1452
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, RpcId.FileSystemWorker);
1833
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, FileSystemWorker);
1453
1834
  };
1454
1835
 
1455
1836
  const createFileSystemProcessRpcElectron = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-system-worker",
3
- "version": "1.25.0",
3
+ "version": "2.0.0",
4
4
  "description": "File System Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"