@lvce-editor/explorer-view 4.6.0 → 4.8.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.
@@ -533,7 +533,7 @@ const create$4$1 = (method, params) => {
533
533
  };
534
534
  };
535
535
  const callbacks = Object.create(null);
536
- const set$7 = (id, fn) => {
536
+ const set$6 = (id, fn) => {
537
537
  callbacks[id] = fn;
538
538
  };
539
539
  const get$2 = id => {
@@ -552,7 +552,7 @@ const registerPromise = () => {
552
552
  resolve,
553
553
  promise
554
554
  } = Promise.withResolvers();
555
- set$7(id, resolve);
555
+ set$6(id, resolve);
556
556
  return {
557
557
  id,
558
558
  promise
@@ -897,7 +897,7 @@ const send$1 = (transport, method, ...params) => {
897
897
  const message = create$4$1(method, params);
898
898
  transport.send(message);
899
899
  };
900
- const invoke$5 = (ipc, method, ...params) => {
900
+ const invoke$4 = (ipc, method, ...params) => {
901
901
  return invokeHelper(ipc, method, params, false);
902
902
  };
903
903
  const invokeAndTransfer$2 = (ipc, method, ...params) => {
@@ -936,7 +936,7 @@ const createRpc = ipc => {
936
936
  send$1(ipc, method, ...params);
937
937
  },
938
938
  invoke(method, ...params) {
939
- return invoke$5(ipc, method, ...params);
939
+ return invoke$4(ipc, method, ...params);
940
940
  },
941
941
  invokeAndTransfer(method, ...params) {
942
942
  return invokeAndTransfer$2(ipc, method, ...params);
@@ -1045,96 +1045,6 @@ const createMockRpc = ({
1045
1045
  return mockRpc;
1046
1046
  };
1047
1047
 
1048
- const toCommandId = key => {
1049
- const dotIndex = key.indexOf('.');
1050
- return key.slice(dotIndex + 1);
1051
- };
1052
- const create$2 = () => {
1053
- const states = Object.create(null);
1054
- const commandMapRef = {};
1055
- return {
1056
- get(uid) {
1057
- return states[uid];
1058
- },
1059
- set(uid, oldState, newState) {
1060
- states[uid] = {
1061
- oldState,
1062
- newState
1063
- };
1064
- },
1065
- dispose(uid) {
1066
- delete states[uid];
1067
- },
1068
- getKeys() {
1069
- return Object.keys(states).map(key => {
1070
- return Number.parseInt(key);
1071
- });
1072
- },
1073
- clear() {
1074
- for (const key of Object.keys(states)) {
1075
- delete states[key];
1076
- }
1077
- },
1078
- wrapCommand(fn) {
1079
- const wrapped = async (uid, ...args) => {
1080
- const {
1081
- newState
1082
- } = states[uid];
1083
- const newerState = await fn(newState, ...args);
1084
- if (newState === newerState) {
1085
- return;
1086
- }
1087
- const latest = states[uid];
1088
- states[uid] = {
1089
- oldState: latest.oldState,
1090
- newState: newerState
1091
- };
1092
- };
1093
- return wrapped;
1094
- },
1095
- wrapGetter(fn) {
1096
- const wrapped = (uid, ...args) => {
1097
- const {
1098
- newState
1099
- } = states[uid];
1100
- return fn(newState, ...args);
1101
- };
1102
- return wrapped;
1103
- },
1104
- diff(uid, modules, numbers) {
1105
- const {
1106
- oldState,
1107
- newState
1108
- } = states[uid];
1109
- const diffResult = [];
1110
- for (let i = 0; i < modules.length; i++) {
1111
- const fn = modules[i];
1112
- if (!fn(oldState, newState)) {
1113
- diffResult.push(numbers[i]);
1114
- }
1115
- }
1116
- return diffResult;
1117
- },
1118
- getCommandIds() {
1119
- const keys = Object.keys(commandMapRef);
1120
- const ids = keys.map(toCommandId);
1121
- return ids;
1122
- },
1123
- registerCommands(commandMap) {
1124
- Object.assign(commandMapRef, commandMap);
1125
- }
1126
- };
1127
- };
1128
- const terminate = () => {
1129
- globalThis.close();
1130
- };
1131
-
1132
- const CreateFolder$1 = 1;
1133
- const CreateFile$1 = 2;
1134
- const Copy$1 = 3;
1135
- const Rename$2 = 4;
1136
- const Remove = 5;
1137
-
1138
1048
  const Text = 12;
1139
1049
 
1140
1050
  const Button$3 = 'event.button';
@@ -1166,9 +1076,8 @@ const CtrlCmd = 1 << 11 >>> 0;
1166
1076
  const Shift = 1 << 10 >>> 0;
1167
1077
  const Alt = 1 << 9 >>> 0;
1168
1078
 
1169
- const DebugWorker = 55;
1170
1079
  const FileSystemWorker$1 = 209;
1171
- const RendererWorker$1 = 1;
1080
+ const RendererWorker = 1;
1172
1081
  const IconThemeWorker = 7009;
1173
1082
 
1174
1083
  const FocusElementByName = 'Viewlet.focusElementByName';
@@ -1181,14 +1090,14 @@ const FocusExplorer = 13;
1181
1090
  const FocusExplorerEditBox = 14;
1182
1091
 
1183
1092
  const rpcs = Object.create(null);
1184
- const set$6 = (id, rpc) => {
1093
+ const set$5 = (id, rpc) => {
1185
1094
  rpcs[id] = rpc;
1186
1095
  };
1187
1096
  const get$1 = id => {
1188
1097
  return rpcs[id];
1189
1098
  };
1190
1099
 
1191
- const create$1 = rpcId => {
1100
+ const create$2 = rpcId => {
1192
1101
  return {
1193
1102
  // @ts-ignore
1194
1103
  invoke(method, ...params) {
@@ -1203,7 +1112,7 @@ const create$1 = rpcId => {
1203
1112
  return rpc.invokeAndTransfer(method, ...params);
1204
1113
  },
1205
1114
  set(rpc) {
1206
- set$6(rpcId, rpc);
1115
+ set$5(rpcId, rpc);
1207
1116
  },
1208
1117
  async dispose() {
1209
1118
  const rpc = get$1(rpcId);
@@ -1213,66 +1122,66 @@ const create$1 = rpcId => {
1213
1122
  };
1214
1123
 
1215
1124
  const {
1216
- invoke: invoke$4,
1125
+ invoke: invoke$3,
1217
1126
  invokeAndTransfer: invokeAndTransfer$1,
1218
- set: set$5,
1219
- dispose: dispose$1
1220
- } = create$1(FileSystemWorker$1);
1127
+ set: set$4,
1128
+ dispose
1129
+ } = create$2(FileSystemWorker$1);
1221
1130
  const remove$1 = async dirent => {
1222
- return invoke$4('FileSystem.remove', dirent);
1131
+ return invoke$3('FileSystem.remove', dirent);
1223
1132
  };
1224
1133
  const readDirWithFileTypes$1 = async uri => {
1225
- return invoke$4('FileSystem.readDirWithFileTypes', uri);
1134
+ return invoke$3('FileSystem.readDirWithFileTypes', uri);
1226
1135
  };
1227
1136
  const getPathSeparator$2 = async root => {
1228
1137
  // @ts-ignore
1229
- return invoke$4('FileSystem.getPathSeparator', root);
1138
+ return invoke$3('FileSystem.getPathSeparator', root);
1230
1139
  };
1231
1140
  const getRealPath$1 = async path => {
1232
- return invoke$4('FileSystem.getRealPath', path);
1141
+ return invoke$3('FileSystem.getRealPath', path);
1233
1142
  };
1234
1143
  const stat$1 = async dirent => {
1235
- return invoke$4('FileSystem.stat', dirent);
1144
+ return invoke$3('FileSystem.stat', dirent);
1236
1145
  };
1237
1146
  const createFile = async uri => {
1238
- return invoke$4('FileSystem.writeFile', uri, '');
1147
+ return invoke$3('FileSystem.writeFile', uri, '');
1239
1148
  };
1240
- const readFile$1 = async uri => {
1241
- return invoke$4('FileSystem.readFile', uri);
1149
+ const readFile = async uri => {
1150
+ return invoke$3('FileSystem.readFile', uri);
1242
1151
  };
1243
1152
  const writeFile$1 = async (uri, content) => {
1244
- return invoke$4('FileSystem.writeFile', uri, content);
1153
+ return invoke$3('FileSystem.writeFile', uri, content);
1245
1154
  };
1246
1155
  const mkdir$1 = async uri => {
1247
- return invoke$4('FileSystem.mkdir', uri);
1156
+ return invoke$3('FileSystem.mkdir', uri);
1248
1157
  };
1249
1158
  const rename$2 = async (oldUri, newUri) => {
1250
- return invoke$4('FileSystem.rename', oldUri, newUri);
1159
+ return invoke$3('FileSystem.rename', oldUri, newUri);
1251
1160
  };
1252
1161
  const copy$2 = async (oldUri, newUri) => {
1253
- return invoke$4('FileSystem.copy', oldUri, newUri);
1162
+ return invoke$3('FileSystem.copy', oldUri, newUri);
1254
1163
  };
1255
1164
  const exists = async uri => {
1256
1165
  // @ts-ignore
1257
- return invoke$4('FileSystem.exists', uri);
1166
+ return invoke$3('FileSystem.exists', uri);
1258
1167
  };
1259
- const getFolderSize$1 = async uri => {
1168
+ const getFolderSize = async uri => {
1260
1169
  // @ts-ignore
1261
- return invoke$4('FileSystem.getFolderSize', uri);
1170
+ return invoke$3('FileSystem.getFolderSize', uri);
1262
1171
  };
1263
1172
  const readFileAsBlob = async uri => {
1264
1173
  // @ts-ignore
1265
- return invoke$4('FileSystem.readFileAsBlob', uri);
1174
+ return invoke$3('FileSystem.readFileAsBlob', uri);
1266
1175
  };
1267
1176
  const appendFile = async (uri, text) => {
1268
1177
  // @ts-ignore
1269
- return invoke$4('FileSystem.appendFile', uri, text);
1178
+ return invoke$3('FileSystem.appendFile', uri, text);
1270
1179
  };
1271
- const registerMockRpc$1 = commandMap => {
1180
+ const registerMockRpc = commandMap => {
1272
1181
  const mockRpc = createMockRpc({
1273
1182
  commandMap
1274
1183
  });
1275
- set$5(mockRpc);
1184
+ set$4(mockRpc);
1276
1185
  return mockRpc;
1277
1186
  };
1278
1187
 
@@ -1281,395 +1190,148 @@ const FileSystemWorker = {
1281
1190
  appendFile,
1282
1191
  copy: copy$2,
1283
1192
  createFile,
1284
- dispose: dispose$1,
1193
+ dispose,
1285
1194
  exists,
1286
- getFolderSize: getFolderSize$1,
1195
+ getFolderSize,
1287
1196
  getPathSeparator: getPathSeparator$2,
1288
1197
  getRealPath: getRealPath$1,
1289
- invoke: invoke$4,
1198
+ invoke: invoke$3,
1290
1199
  invokeAndTransfer: invokeAndTransfer$1,
1291
1200
  mkdir: mkdir$1,
1292
1201
  readDirWithFileTypes: readDirWithFileTypes$1,
1293
- readFile: readFile$1,
1202
+ readFile,
1294
1203
  readFileAsBlob,
1295
- registerMockRpc: registerMockRpc$1,
1204
+ registerMockRpc,
1296
1205
  remove: remove$1,
1297
1206
  rename: rename$2,
1298
- set: set$5,
1207
+ set: set$4,
1299
1208
  stat: stat$1,
1300
1209
  writeFile: writeFile$1
1301
1210
  };
1302
1211
 
1303
1212
  const {
1304
- invoke: invoke$3,
1305
- set: set$4} = create$1(IconThemeWorker);
1306
- const getIcons$1 = async iconRequests => {
1213
+ invoke: invoke$2,
1214
+ set: set$3} = create$2(IconThemeWorker);
1215
+ const getIcons = async iconRequests => {
1307
1216
  // @ts-ignore
1308
- return invoke$3('IconTheme.getIcons', iconRequests);
1217
+ return invoke$2('IconTheme.getIcons', iconRequests);
1309
1218
  };
1310
1219
 
1311
1220
  const {
1312
- invoke: invoke$2,
1221
+ invoke: invoke$1,
1313
1222
  invokeAndTransfer,
1314
- set: set$3,
1315
- dispose
1316
- } = create$1(RendererWorker$1);
1317
- const searchFileHtml = async uri => {
1318
- return invoke$2('ExtensionHost.searchFileWithHtml', uri);
1319
- };
1320
- const getFilePathElectron$1 = async file => {
1321
- return invoke$2('FileSystemHandle.getFilePathElectron', file);
1322
- };
1323
- const showContextMenu$1 = async (x, y, id, ...args) => {
1324
- return invoke$2('ContextMenu.show', x, y, id, ...args);
1325
- };
1326
- const getElectronVersion = async () => {
1327
- return invoke$2('Process.getElectronVersion');
1328
- };
1329
- const applyBulkReplacement = async bulkEdits => {
1330
- await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
1331
- };
1332
- const setColorTheme = async id => {
1333
- // @ts-ignore
1334
- return invoke$2(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1335
- };
1336
- const getNodeVersion = async () => {
1337
- return invoke$2('Process.getNodeVersion');
1338
- };
1339
- const getChromeVersion = async () => {
1340
- return invoke$2('Process.getChromeVersion');
1341
- };
1342
- const getV8Version = async () => {
1343
- return invoke$2('Process.getV8Version');
1344
- };
1345
- const getFileHandles$1 = async fileIds => {
1346
- const files = await invoke$2('FileSystemHandle.getFileHandles', fileIds);
1347
- return files;
1348
- };
1349
- const setWorkspacePath = async path => {
1350
- await invoke$2('Workspace.setPath', path);
1351
- };
1352
- const registerWebViewInterceptor = async (id, port) => {
1353
- await invokeAndTransfer('WebView.registerInterceptor', id, port);
1354
- };
1355
- const unregisterWebViewInterceptor = async id => {
1356
- await invoke$2('WebView.unregisterInterceptor', id);
1357
- };
1358
- const sendMessagePortToEditorWorker = async (port, rpcId) => {
1359
- const command = 'HandleMessagePort.handleMessagePort';
1360
- // @ts-ignore
1361
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1362
- };
1363
- const sendMessagePortToErrorWorker = async (port, rpcId) => {
1364
- const command = 'Errors.handleMessagePort';
1365
- // @ts-ignore
1366
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
1367
- };
1368
- const sendMessagePortToMarkdownWorker = async (port, rpcId) => {
1369
- const command = 'Markdown.handleMessagePort';
1370
- // @ts-ignore
1371
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
1223
+ set: set$2} = create$2(RendererWorker);
1224
+ const showContextMenu = async (x, y, id, ...args) => {
1225
+ return invoke$1('ContextMenu.show', x, y, id, ...args);
1372
1226
  };
1373
1227
  const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1374
1228
  const command = 'IconTheme.handleMessagePort';
1375
1229
  // @ts-ignore
1376
1230
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1377
1231
  };
1378
- const sendMessagePortToFileSystemWorker$2 = async (port, rpcId) => {
1232
+ const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
1379
1233
  const command = 'FileSystem.handleMessagePort';
1380
1234
  // @ts-ignore
1381
1235
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1382
1236
  };
1383
- const readFile = async uri => {
1384
- return invoke$2('FileSystem.readFile', uri);
1385
- };
1386
- const getWebViewSecret = async key => {
1387
- // @ts-ignore
1388
- return invoke$2('WebView.getSecret', key);
1389
- };
1390
- const setWebViewPort = async (uid, port, origin, portType) => {
1391
- return invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
1392
- };
1393
- const setFocus = key => {
1394
- return invoke$2('Focus.setFocus', key);
1395
- };
1396
- const getFileIcon = async options => {
1397
- return invoke$2('IconTheme.getFileIcon', options);
1398
- };
1399
- const getColorThemeNames = async () => {
1400
- return invoke$2('ColorTheme.getColorThemeNames');
1401
- };
1402
- const disableExtension = async id => {
1403
- // @ts-ignore
1404
- return invoke$2('ExtensionManagement.disable', id);
1405
- };
1406
- const enableExtension = async id => {
1407
- // @ts-ignore
1408
- return invoke$2('ExtensionManagement.enable', id);
1409
- };
1410
- const handleDebugChange = async params => {
1237
+ const confirm = async (message, options) => {
1411
1238
  // @ts-ignore
1412
- return invoke$2('Run And Debug.handleChange', params);
1413
- };
1414
- const getFolderIcon = async options => {
1415
- return invoke$2('IconTheme.getFolderIcon', options);
1416
- };
1417
- const closeWidget = async widgetId => {
1418
- return invoke$2('Viewlet.closeWidget', widgetId);
1419
- };
1420
- const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
1421
- const command = 'HandleMessagePort.handleMessagePort2';
1422
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1423
- };
1424
- const sendMessagePortToSearchProcess = async port => {
1425
- await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
1426
- };
1427
- const confirm$1 = async (message, options) => {
1428
- // @ts-ignore
1429
- const result = await invoke$2('ConfirmPrompt.prompt', message, options);
1239
+ const result = await invoke$1('ConfirmPrompt.prompt', message, options);
1430
1240
  return result;
1431
1241
  };
1432
- const getRecentlyOpened = async () => {
1433
- return invoke$2(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1434
- };
1435
- const getKeyBindings$1 = async () => {
1436
- return invoke$2('KeyBindingsInitial.getKeyBindings');
1437
- };
1438
- const writeClipBoardText$1 = async text => {
1439
- await invoke$2('ClipBoard.writeText', /* text */text);
1440
- };
1441
- const writeClipBoardImage = async blob => {
1442
- // @ts-ignore
1443
- await invoke$2('ClipBoard.writeImage', /* text */blob);
1444
- };
1445
- const searchFileMemory = async uri => {
1446
- // @ts-ignore
1447
- return invoke$2('ExtensionHost.searchFileWithMemory', uri);
1448
- };
1449
- const searchFileFetch = async uri => {
1450
- return invoke$2('ExtensionHost.searchFileWithFetch', uri);
1451
- };
1452
- const showMessageBox = async options => {
1453
- return invoke$2('ElectronDialog.showMessageBox', options);
1454
- };
1455
- const handleDebugResumed = async params => {
1456
- await invoke$2('Run And Debug.handleResumed', params);
1457
- };
1458
- const openWidget = async name => {
1459
- await invoke$2('Viewlet.openWidget', name);
1460
- };
1461
- const getIcons = async requests => {
1462
- const icons = await invoke$2('IconTheme.getIcons', requests);
1463
- return icons;
1464
- };
1465
- const activateByEvent = event => {
1466
- return invoke$2('ExtensionHostManagement.activateByEvent', event);
1467
- };
1468
- const setAdditionalFocus = focusKey => {
1469
- // @ts-ignore
1470
- return invoke$2('Focus.setAdditionalFocus', focusKey);
1471
- };
1472
- const getActiveEditorId = () => {
1473
- // @ts-ignore
1474
- return invoke$2('GetActiveEditor.getActiveEditorId');
1242
+ const writeClipBoardText = async text => {
1243
+ await invoke$1('ClipBoard.writeText', /* text */text);
1475
1244
  };
1476
- const getWorkspacePath$1 = () => {
1477
- return invoke$2('Workspace.getPath');
1478
- };
1479
- const sendMessagePortToRendererProcess = async port => {
1480
- const command = 'HandleMessagePort.handleMessagePort';
1481
- // @ts-ignore
1482
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1483
- };
1484
- const getPreference = async key => {
1485
- return await invoke$2('Preferences.get', key);
1486
- };
1487
- const getAllExtensions = async () => {
1488
- return invoke$2('ExtensionManagement.getAllExtensions');
1489
- };
1490
- const rerenderEditor = async key => {
1491
- // @ts-ignore
1492
- return invoke$2('Editor.rerender', key);
1493
- };
1494
- const handleDebugPaused = async params => {
1495
- await invoke$2('Run And Debug.handlePaused', params);
1496
- };
1497
- const openUri$1 = async (uri, focus, options) => {
1498
- await invoke$2('Main.openUri', uri, focus, options);
1499
- };
1500
- const sendMessagePortToSyntaxHighlightingWorker = async port => {
1501
- await invokeAndTransfer(
1502
- // @ts-ignore
1503
- 'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
1504
- };
1505
- const handleDebugScriptParsed = async script => {
1506
- await invoke$2('Run And Debug.handleScriptParsed', script);
1507
- };
1508
- const getWindowId = async () => {
1509
- return invoke$2('GetWindowId.getWindowId');
1510
- };
1511
- const getBlob = async uri => {
1512
- // @ts-ignore
1513
- return invoke$2('FileSystem.getBlob', uri);
1514
- };
1515
- const getExtensionCommands = async () => {
1516
- return invoke$2('ExtensionHost.getCommands');
1517
- };
1518
- const showErrorDialog = async errorInfo => {
1519
- // @ts-ignore
1520
- await invoke$2('ErrorHandling.showErrorDialog', errorInfo);
1521
- };
1522
- const getFolderSize = async uri => {
1523
- // @ts-ignore
1524
- return await invoke$2('FileSystem.getFolderSize', uri);
1525
- };
1526
- const getExtension = async id => {
1527
- // @ts-ignore
1528
- return invoke$2('ExtensionManagement.getExtension', id);
1529
- };
1530
- const getMarkdownDom = async html => {
1531
- // @ts-ignore
1532
- return invoke$2('Markdown.getVirtualDom', html);
1533
- };
1534
- const renderMarkdown = async (markdown, options) => {
1535
- // @ts-ignore
1536
- return invoke$2('Markdown.renderMarkdown', markdown, options);
1537
- };
1538
- const openNativeFolder$1 = async uri => {
1539
- // @ts-ignore
1540
- await invoke$2('OpenNativeFolder.openNativeFolder', uri);
1541
- };
1542
- const uninstallExtension = async id => {
1543
- return invoke$2('ExtensionManagement.uninstall', id);
1544
- };
1545
- const installExtension = async id => {
1546
- // @ts-ignore
1547
- return invoke$2('ExtensionManagement.install', id);
1548
- };
1549
- const openExtensionSearch = async () => {
1550
- // @ts-ignore
1551
- return invoke$2('SideBar.openViewlet', 'Extensions');
1552
- };
1553
- const setExtensionsSearchValue = async searchValue => {
1554
- // @ts-ignore
1555
- return invoke$2('Extensions.handleInput', searchValue);
1556
- };
1557
- const openExternal = async uri => {
1558
- // @ts-ignore
1559
- await invoke$2('Open.openExternal', uri);
1560
- };
1561
- const openUrl = async uri => {
1562
- // @ts-ignore
1563
- await invoke$2('Open.openUrl', uri);
1564
- };
1565
- const getAllPreferences = async () => {
1566
- // @ts-ignore
1567
- return invoke$2('Preferences.getAll');
1568
- };
1569
- const showSaveFilePicker = async () => {
1570
- // @ts-ignore
1571
- return invoke$2('FilePicker.showSaveFilePicker');
1572
- };
1573
- const getLogsDir = async () => {
1574
- // @ts-ignore
1575
- return invoke$2('PlatformPaths.getLogsDir');
1245
+
1246
+ const toCommandId = key => {
1247
+ const dotIndex = key.indexOf('.');
1248
+ return key.slice(dotIndex + 1);
1576
1249
  };
1577
- const registerMockRpc = commandMap => {
1578
- const mockRpc = createMockRpc({
1579
- commandMap
1580
- });
1581
- set$3(mockRpc);
1582
- return mockRpc;
1250
+ const create$1 = () => {
1251
+ const states = Object.create(null);
1252
+ const commandMapRef = {};
1253
+ return {
1254
+ get(uid) {
1255
+ return states[uid];
1256
+ },
1257
+ set(uid, oldState, newState) {
1258
+ states[uid] = {
1259
+ oldState,
1260
+ newState
1261
+ };
1262
+ },
1263
+ dispose(uid) {
1264
+ delete states[uid];
1265
+ },
1266
+ getKeys() {
1267
+ return Object.keys(states).map(key => {
1268
+ return Number.parseInt(key);
1269
+ });
1270
+ },
1271
+ clear() {
1272
+ for (const key of Object.keys(states)) {
1273
+ delete states[key];
1274
+ }
1275
+ },
1276
+ wrapCommand(fn) {
1277
+ const wrapped = async (uid, ...args) => {
1278
+ const {
1279
+ newState
1280
+ } = states[uid];
1281
+ const newerState = await fn(newState, ...args);
1282
+ if (newState === newerState) {
1283
+ return;
1284
+ }
1285
+ const latest = states[uid];
1286
+ states[uid] = {
1287
+ oldState: latest.oldState,
1288
+ newState: newerState
1289
+ };
1290
+ };
1291
+ return wrapped;
1292
+ },
1293
+ wrapGetter(fn) {
1294
+ const wrapped = (uid, ...args) => {
1295
+ const {
1296
+ newState
1297
+ } = states[uid];
1298
+ return fn(newState, ...args);
1299
+ };
1300
+ return wrapped;
1301
+ },
1302
+ diff(uid, modules, numbers) {
1303
+ const {
1304
+ oldState,
1305
+ newState
1306
+ } = states[uid];
1307
+ const diffResult = [];
1308
+ for (let i = 0; i < modules.length; i++) {
1309
+ const fn = modules[i];
1310
+ if (!fn(oldState, newState)) {
1311
+ diffResult.push(numbers[i]);
1312
+ }
1313
+ }
1314
+ return diffResult;
1315
+ },
1316
+ getCommandIds() {
1317
+ const keys = Object.keys(commandMapRef);
1318
+ const ids = keys.map(toCommandId);
1319
+ return ids;
1320
+ },
1321
+ registerCommands(commandMap) {
1322
+ Object.assign(commandMapRef, commandMap);
1323
+ }
1324
+ };
1583
1325
  };
1584
-
1585
- const RendererWorker = {
1586
- __proto__: null,
1587
- activateByEvent,
1588
- applyBulkReplacement,
1589
- closeWidget,
1590
- confirm: confirm$1,
1591
- disableExtension,
1592
- dispose,
1593
- enableExtension,
1594
- getActiveEditorId,
1595
- getAllExtensions,
1596
- getAllPreferences,
1597
- getBlob,
1598
- getChromeVersion,
1599
- getColorThemeNames,
1600
- getElectronVersion,
1601
- getExtension,
1602
- getExtensionCommands,
1603
- getFileHandles: getFileHandles$1,
1604
- getFileIcon,
1605
- getFilePathElectron: getFilePathElectron$1,
1606
- getFolderIcon,
1607
- getFolderSize,
1608
- getIcons,
1609
- getKeyBindings: getKeyBindings$1,
1610
- getLogsDir,
1611
- getMarkdownDom,
1612
- getNodeVersion,
1613
- getPreference,
1614
- getRecentlyOpened,
1615
- getV8Version,
1616
- getWebViewSecret,
1617
- getWindowId,
1618
- getWorkspacePath: getWorkspacePath$1,
1619
- handleDebugChange,
1620
- handleDebugPaused,
1621
- handleDebugResumed,
1622
- handleDebugScriptParsed,
1623
- installExtension,
1624
- invoke: invoke$2,
1625
- invokeAndTransfer,
1626
- openExtensionSearch,
1627
- openExternal,
1628
- openNativeFolder: openNativeFolder$1,
1629
- openUri: openUri$1,
1630
- openUrl,
1631
- openWidget,
1632
- readFile,
1633
- registerMockRpc,
1634
- registerWebViewInterceptor,
1635
- renderMarkdown,
1636
- rerenderEditor,
1637
- searchFileFetch,
1638
- searchFileHtml,
1639
- searchFileMemory,
1640
- sendMessagePortToEditorWorker,
1641
- sendMessagePortToErrorWorker,
1642
- sendMessagePortToExtensionHostWorker,
1643
- sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$2,
1644
- sendMessagePortToIconThemeWorker,
1645
- sendMessagePortToMarkdownWorker,
1646
- sendMessagePortToRendererProcess,
1647
- sendMessagePortToSearchProcess,
1648
- sendMessagePortToSyntaxHighlightingWorker,
1649
- set: set$3,
1650
- setAdditionalFocus,
1651
- setColorTheme,
1652
- setExtensionsSearchValue,
1653
- setFocus,
1654
- setWebViewPort,
1655
- setWorkspacePath,
1656
- showContextMenu: showContextMenu$1,
1657
- showErrorDialog,
1658
- showMessageBox,
1659
- showSaveFilePicker,
1660
- uninstallExtension,
1661
- unregisterWebViewInterceptor,
1662
- writeClipBoardImage,
1663
- writeClipBoardText: writeClipBoardText$1
1326
+ const terminate = () => {
1327
+ globalThis.close();
1664
1328
  };
1665
1329
 
1666
- const {
1667
- invoke: invoke$1,
1668
- set: set$2,
1669
- writeClipBoardText,
1670
- confirm,
1671
- showContextMenu,
1672
- sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$1} = RendererWorker;
1330
+ const CreateFolder$1 = 1;
1331
+ const CreateFile$1 = 2;
1332
+ const Copy$1 = 3;
1333
+ const Rename$2 = 4;
1334
+ const Remove = 5;
1673
1335
 
1674
1336
  // TODO use direct connection
1675
1337
  const invoke = async (method, ...params) => {
@@ -2065,6 +1727,22 @@ const getPathPartsChildren = async pathparts => {
2065
1727
  return orderedPathParts;
2066
1728
  };
2067
1729
 
1730
+ const getSiblingFileNames = (items, focusedIndex, root, pathSeparator) => {
1731
+ if (focusedIndex < 0 || focusedIndex >= items.length) {
1732
+ // If no focused item or invalid index, get root level items
1733
+ return items.filter(item => item.depth === 0).map(item => item.name);
1734
+ }
1735
+ const focusedItem = items[focusedIndex];
1736
+ const focusedItemParentPath = focusedItem.path.slice(0, -(focusedItem.name.length + 1));
1737
+
1738
+ // Find all items that are direct children of the same parent as the focused item
1739
+ const siblingItems = items.filter(item => {
1740
+ const itemParentPath = item.path.slice(0, -(item.name.length + 1));
1741
+ return itemParentPath === focusedItemParentPath;
1742
+ });
1743
+ return siblingItems.map(item => item.name);
1744
+ };
1745
+
2068
1746
  const mergeTrees = (a, b) => {
2069
1747
  return {
2070
1748
  ...a,
@@ -2126,6 +1804,7 @@ const CopyRelativePath = 'Copy Relative Path';
2126
1804
  const Cut = 'Cut';
2127
1805
  const Delete = 'Delete';
2128
1806
  const FileNameCannotStartWithSlash = 'A file or folder name cannot start with a slash.';
1807
+ const FileOrFolderAlreadyExists = 'A file or folder **{0}** already exists at this location. Please choose a different name.';
2129
1808
  const FileOrFolderNameMustBeProvider = 'A file or folder name must be provided.';
2130
1809
  const FileCannotStartWithDot = 'A file or folder name cannot start with a dot.';
2131
1810
  const FileCannotStartWithBackSlash = 'A file or folder name cannot start with a backslash.';
@@ -2204,8 +1883,11 @@ const fileCannotStartWithBackSlash = () => {
2204
1883
  const typeAFileName = () => {
2205
1884
  return i18nString(TypeAFileName);
2206
1885
  };
1886
+ const fileOrFolderAlreadyExists = () => {
1887
+ return i18nString(FileOrFolderAlreadyExists);
1888
+ };
2207
1889
 
2208
- const validateFileName2 = name => {
1890
+ const validateFileName2 = (name, siblingFileNames = []) => {
2209
1891
  if (!name) {
2210
1892
  const editingErrorMessage = fileOrFolderNameMustBeProvided();
2211
1893
  return editingErrorMessage;
@@ -2219,6 +1901,11 @@ const validateFileName2 = name => {
2219
1901
  if (name.startsWith(BackSlash)) {
2220
1902
  return fileCannotStartWithBackSlash();
2221
1903
  }
1904
+
1905
+ // Check if file already exists
1906
+ if (siblingFileNames.includes(name)) {
1907
+ return fileOrFolderAlreadyExists();
1908
+ }
2222
1909
  return '';
2223
1910
  };
2224
1911
 
@@ -2231,7 +1918,8 @@ const acceptCreate = async (state, newDirentType) => {
2231
1918
  items
2232
1919
  } = state;
2233
1920
  const newFileName = editingValue;
2234
- const editingErrorMessage = validateFileName2(newFileName);
1921
+ const siblingFileNames = getSiblingFileNames(items, focusedIndex);
1922
+ const editingErrorMessage = validateFileName2(newFileName, siblingFileNames);
2235
1923
  if (editingErrorMessage) {
2236
1924
  return {
2237
1925
  ...state,
@@ -2592,7 +2280,7 @@ const requestFileIcons = async requests => {
2592
2280
  return [];
2593
2281
  }
2594
2282
  const simpleRequests = requests.map(toSimpleIconRequest);
2595
- const icons = await getIcons$1(simpleRequests);
2283
+ const icons = await getIcons(simpleRequests);
2596
2284
  return icons;
2597
2285
  };
2598
2286
 
@@ -2757,7 +2445,7 @@ const getEditingChevron = direntType => {
2757
2445
  return None$4;
2758
2446
  }
2759
2447
  };
2760
- const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris = []) => {
2448
+ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris = []) => {
2761
2449
  const visible = [];
2762
2450
  const indentFn = useChevrons ? getTreeItemIndentWithChevron : getTreeItemIndent;
2763
2451
  let iconIndex = 0;
@@ -2806,7 +2494,7 @@ const {
2806
2494
  registerCommands,
2807
2495
  getCommandIds,
2808
2496
  wrapGetter
2809
- } = create$2();
2497
+ } = create$1();
2810
2498
  const wrapListItemCommand = fn => {
2811
2499
  const wrappedCommand = async (id, ...args) => {
2812
2500
  const {
@@ -2818,8 +2506,6 @@ const wrapListItemCommand = fn => {
2818
2506
  minLineY,
2819
2507
  focusedIndex,
2820
2508
  editingIndex,
2821
- editingType,
2822
- editingValue,
2823
2509
  editingErrorMessage,
2824
2510
  useChevrons,
2825
2511
  dropTargets,
@@ -2841,7 +2527,7 @@ const wrapListItemCommand = fn => {
2841
2527
  icons,
2842
2528
  newFileIconCache
2843
2529
  } = await getFileIcons(visible, fileIconCache);
2844
- const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
2530
+ const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
2845
2531
  const finalState = {
2846
2532
  ...updatedState,
2847
2533
  visibleExplorerItems,
@@ -2976,7 +2662,7 @@ const isEqual$6 = (oldState, newState) => {
2976
2662
  // TODO compute css more optimized
2977
2663
  // maybe only when items change, and even then not
2978
2664
  // always, but only when it affects the css
2979
- return oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarActive === newState.scrollBarActive && oldState.maxIndent === newState.maxIndent && oldState.visibleExplorerItems === newState.visibleExplorerItems;
2665
+ return oldState.errorMessageLeft === newState.errorMessageLeft && oldState.errorMessageTop === newState.errorMessageTop && oldState.maxIndent === newState.maxIndent && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.visibleExplorerItems === newState.visibleExplorerItems;
2980
2666
  };
2981
2667
 
2982
2668
  const isEqual$5 = (oldState, newState) => {
@@ -3950,7 +3636,7 @@ const handleClickCurrentButKeepFocus = state => {
3950
3636
 
3951
3637
  const openFolder = async () => {
3952
3638
  // @ts-ignore
3953
- await invoke$2(`Dialog.openFolder`);
3639
+ await invoke$1(`Dialog.openFolder`);
3954
3640
  };
3955
3641
 
3956
3642
  const handleClickOpenFolder = async state => {
@@ -5152,7 +4838,7 @@ const createIconThemeWorkerRpc = async () => {
5152
4838
 
5153
4839
  const initializeIconThemeWorker = async () => {
5154
4840
  const rpc = await createIconThemeWorkerRpc();
5155
- set$4(rpc);
4841
+ set$3(rpc);
5156
4842
  };
5157
4843
 
5158
4844
  const initialize = async () => {
@@ -5417,10 +5103,12 @@ const renameDirent = async state => {
5417
5103
  };
5418
5104
  };
5419
5105
 
5420
- const getCss = (scrollBarHeight, uniqueIndents) => {
5106
+ const getCss = (scrollBarHeight, uniqueIndents, errorMessageLeft, errorMessageTop) => {
5421
5107
  // TODO each visible item should have an indent property
5422
5108
  const rules = [`.Explorer {
5423
5109
  --ScrollBarThumbHeight: ${scrollBarHeight}px;
5110
+ --ErrorMessageTop: ${errorMessageTop}px;
5111
+ --ErrorMessageLeft: ${errorMessageLeft}px;
5424
5112
  }`];
5425
5113
  for (const item of uniqueIndents) {
5426
5114
  rules.push(`.Indent-${item} {
@@ -5445,11 +5133,13 @@ const renderCss = (oldState, newState) => {
5445
5133
  const {
5446
5134
  scrollBarHeight,
5447
5135
  uid,
5448
- visibleExplorerItems
5136
+ visibleExplorerItems,
5137
+ errorMessageLeft,
5138
+ errorMessageTop
5449
5139
  } = newState;
5450
5140
  const indents = visibleExplorerItems.map(item => item.indent);
5451
5141
  const uniqueIndents = getUnique(indents);
5452
- const css = getCss(scrollBarHeight, uniqueIndents);
5142
+ const css = getCss(scrollBarHeight, uniqueIndents, errorMessageLeft, errorMessageTop);
5453
5143
  return [SetCss, uid, css];
5454
5144
  };
5455
5145
 
@@ -6303,10 +5993,17 @@ const updateEditingValue = async (state, value, inputSource = User) => {
6303
5993
  const {
6304
5994
  editingType,
6305
5995
  items,
6306
- editingIndex
5996
+ editingIndex,
5997
+ focusedIndex
6307
5998
  } = state;
6308
5999
  const editingIcon = await getEditingIcon(editingType, value, items[editingIndex]?.type);
6309
- const editingErrorMessage = validateFileName2(value);
6000
+
6001
+ // Get sibling file names for validation during file/folder creation
6002
+ let siblingFileNames = [];
6003
+ if (editingType === CreateFile || editingType === CreateFolder) {
6004
+ siblingFileNames = getSiblingFileNames(items, focusedIndex);
6005
+ }
6006
+ const editingErrorMessage = validateFileName2(value, siblingFileNames);
6310
6007
  return {
6311
6008
  ...state,
6312
6009
  editingValue: value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "4.6.0",
3
+ "version": "4.8.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",