@lvce-editor/explorer-view 2.48.0 → 2.50.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.
@@ -431,7 +431,7 @@ const create$4 = (method, params) => {
431
431
  };
432
432
  };
433
433
  const callbacks = Object.create(null);
434
- const set$3 = (id, fn) => {
434
+ const set$2 = (id, fn) => {
435
435
  callbacks[id] = fn;
436
436
  };
437
437
  const get$2 = id => {
@@ -450,7 +450,7 @@ const registerPromise = () => {
450
450
  resolve,
451
451
  promise
452
452
  } = Promise.withResolvers();
453
- set$3(id, resolve);
453
+ set$2(id, resolve);
454
454
  return {
455
455
  id,
456
456
  promise
@@ -664,18 +664,18 @@ const getErrorProperty = (error, prettyError) => {
664
664
  }
665
665
  };
666
666
  };
667
- const create$1$1 = (message, error) => {
667
+ const create$1$1 = (id, error) => {
668
668
  return {
669
669
  jsonrpc: Two,
670
- id: message.id,
670
+ id,
671
671
  error
672
672
  };
673
673
  };
674
- const getErrorResponse = (message, error, preparePrettyError, logError) => {
674
+ const getErrorResponse = (id, error, preparePrettyError, logError) => {
675
675
  const prettyError = preparePrettyError(error);
676
676
  logError(error, prettyError);
677
677
  const errorProperty = getErrorProperty(error, prettyError);
678
- return create$1$1(message, errorProperty);
678
+ return create$1$1(id, errorProperty);
679
679
  };
680
680
  const create$5 = (message, result) => {
681
681
  return {
@@ -688,12 +688,27 @@ const getSuccessResponse = (message, result) => {
688
688
  const resultProperty = result ?? null;
689
689
  return create$5(message, resultProperty);
690
690
  };
691
+ const getErrorResponseSimple = (id, error) => {
692
+ return {
693
+ jsonrpc: Two,
694
+ id,
695
+ error: {
696
+ code: Custom,
697
+ // @ts-ignore
698
+ message: error.message,
699
+ data: error
700
+ }
701
+ };
702
+ };
691
703
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
692
704
  try {
693
705
  const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
694
706
  return getSuccessResponse(message, result);
695
707
  } catch (error) {
696
- return getErrorResponse(message, error, preparePrettyError, logError);
708
+ if (ipc.canUseSimpleErrorResponse) {
709
+ return getErrorResponseSimple(message.id, error);
710
+ }
711
+ return getErrorResponse(message.id, error, preparePrettyError, logError);
697
712
  }
698
713
  };
699
714
  const defaultPreparePrettyError = error => {
@@ -748,7 +763,7 @@ const handleJsonRpcMessage = async (...args) => {
748
763
  try {
749
764
  ipc.send(response);
750
765
  } catch (error) {
751
- const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
766
+ const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
752
767
  ipc.send(errorResponse);
753
768
  }
754
769
  return;
@@ -779,7 +794,7 @@ const send = (transport, method, ...params) => {
779
794
  const message = create$4(method, params);
780
795
  transport.send(message);
781
796
  };
782
- const invoke$3 = (ipc, method, ...params) => {
797
+ const invoke$2 = (ipc, method, ...params) => {
783
798
  return invokeHelper(ipc, method, params, false);
784
799
  };
785
800
  const invokeAndTransfer = (ipc, method, ...params) => {
@@ -812,7 +827,7 @@ const createRpc = ipc => {
812
827
  send(ipc, method, ...params);
813
828
  },
814
829
  invoke(method, ...params) {
815
- return invoke$3(ipc, method, ...params);
830
+ return invoke$2(ipc, method, ...params);
816
831
  },
817
832
  invokeAndTransfer(method, ...params) {
818
833
  return invokeAndTransfer(ipc, method, ...params);
@@ -868,13 +883,13 @@ const WebWorkerRpcClient = {
868
883
  create: create$3
869
884
  };
870
885
 
871
- const CreateFolder$1 = 'createFolder'; // TODO use number
872
- const CreateFile$1 = 'createFile'; // TODO use number
873
- const Copy$2 = 'copy'; // TODO use number
874
- const Rename$2 = 'rename'; // TODO use number
886
+ const CreateFolder$1 = 1;
887
+ const CreateFile$1 = 2;
888
+ const Copy$2 = 3;
889
+ const Rename$2 = 4;
875
890
 
876
891
  const rpcs = Object.create(null);
877
- const set$b = (id, rpc) => {
892
+ const set$d = (id, rpc) => {
878
893
  rpcs[id] = rpc;
879
894
  };
880
895
  const get$1 = id => {
@@ -898,19 +913,19 @@ const create$2 = rpcId => {
898
913
  return rpc.invokeAndTransfer(method, ...params);
899
914
  },
900
915
  set(rpc) {
901
- set$b(rpcId, rpc);
916
+ set$d(rpcId, rpc);
902
917
  }
903
918
  };
904
919
  };
905
920
  const RendererWorker$1 = 1;
906
921
  const {
907
- invoke: invoke$2,
908
- set: set$2
922
+ invoke: invoke$3,
923
+ set: set$3
909
924
  } = create$2(RendererWorker$1);
910
925
  const RendererWorker = {
911
926
  __proto__: null,
912
- invoke: invoke$2,
913
- set: set$2
927
+ invoke: invoke$3,
928
+ set: set$3
914
929
  };
915
930
 
916
931
  const {
@@ -993,7 +1008,7 @@ const getBaseName = (pathSeparator, path) => {
993
1008
  return path.slice(path.lastIndexOf(pathSeparator) + 1);
994
1009
  };
995
1010
  const join2 = (path, childPath) => {
996
- if (path.endsWith('/')) {
1011
+ if (path.endsWith('/') || childPath.startsWith('/')) {
997
1012
  return `${path}${childPath}`;
998
1013
  }
999
1014
  return `${path}/${childPath}`;
@@ -1077,16 +1092,17 @@ const EditingFile = File + DELTA_EDITING;
1077
1092
  const EditingFolder = Directory + DELTA_EDITING;
1078
1093
  const EditingDirectoryExpanded = DirectoryExpanded + DELTA_EDITING;
1079
1094
 
1080
- const getSimpleType = direntType => {
1095
+ const getSimpleIconRequestType = direntType => {
1081
1096
  if (direntType === Directory || direntType === DirectoryExpanded || direntType === EditingDirectoryExpanded || direntType === EditingFolder) {
1082
1097
  return 2;
1083
1098
  }
1084
1099
  return 1;
1085
1100
  };
1101
+
1086
1102
  const toSimpleIconRequest = request => {
1087
1103
  return {
1088
1104
  name: request.name,
1089
- type: getSimpleType(request.type)
1105
+ type: getSimpleIconRequestType(request.type)
1090
1106
  };
1091
1107
  };
1092
1108
 
@@ -1132,10 +1148,10 @@ const getFileOperationsNestedPath = (path, root, pathSeparator) => {
1132
1148
  let currentPath = '';
1133
1149
  for (const part of parts) {
1134
1150
  if (!part) continue;
1135
- currentPath = currentPath ? `${currentPath}${pathSeparator}${part}` : part;
1151
+ currentPath = join2(currentPath, part);
1136
1152
  operations.push({
1137
1153
  type: CreateFolder$1,
1138
- path: `${root}${currentPath}`
1154
+ path: join2(root, currentPath)
1139
1155
  });
1140
1156
  }
1141
1157
  return operations;
@@ -1251,6 +1267,15 @@ const resolveSymbolicLinks = async (uri, rawDirents) => {
1251
1267
  return resolvedDirents;
1252
1268
  };
1253
1269
 
1270
+ const getChildDirentsRaw = async uri => {
1271
+ const rawDirents = await readDirWithFileTypes(uri);
1272
+ array(rawDirents);
1273
+ if (hasSymbolicLinks(rawDirents)) {
1274
+ return resolveSymbolicLinks(uri, rawDirents);
1275
+ }
1276
+ return rawDirents;
1277
+ };
1278
+
1254
1279
  const RE_CHARACTERS = /^[a-zA-Z.-]+$/;
1255
1280
  const compareStringNumeric = (a, b) => {
1256
1281
  if (RE_CHARACTERS.test(a) && RE_CHARACTERS.test(b)) {
@@ -1316,14 +1341,6 @@ const toDisplayDirents = (pathSeparator, rawDirents, parentDirentPath, parentDir
1316
1341
  return result;
1317
1342
  };
1318
1343
 
1319
- const getChildDirentsRaw = async uri => {
1320
- const rawDirents = await readDirWithFileTypes(uri);
1321
- array(rawDirents);
1322
- if (hasSymbolicLinks(rawDirents)) {
1323
- return resolveSymbolicLinks(uri, rawDirents);
1324
- }
1325
- return rawDirents;
1326
- };
1327
1344
  const getChildDirents = async (pathSeparator, parentDirentPath, parentDirentDepth, excluded = []) => {
1328
1345
  string(pathSeparator);
1329
1346
  // TODO use event/actor based code instead, this is impossible to cancel right now
@@ -1391,7 +1408,7 @@ const treeToArrayInternal = (map, root, items, path, depth) => {
1391
1408
  for (let i = 0; i < count; i++) {
1392
1409
  const child = children[i];
1393
1410
  const childPath = join2(path, child.name);
1394
- const absolutePath = `${root}${childPath}`;
1411
+ const absolutePath = join2(root, childPath);
1395
1412
  items.push({
1396
1413
  depth,
1397
1414
  posInSet: i + 1,
@@ -3374,7 +3391,7 @@ const getFileOperationsElectron = async (root, paths, fileHandles) => {
3374
3391
  } = fileHandle;
3375
3392
  const path = paths[i];
3376
3393
  operations.push({
3377
- type: 'copy',
3394
+ type: Copy$2,
3378
3395
  path: join2(root, name),
3379
3396
  from: path
3380
3397
  });
@@ -3640,7 +3657,6 @@ const handleKeyDown = (state, key) => {
3640
3657
  }
3641
3658
 
3642
3659
  // @ts-ignore
3643
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
3644
3660
  timeout = setTimeout(async () => {
3645
3661
  await invoke$1('Explorer.cancelTypeAhead');
3646
3662
  }, focusWordTimeout);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.48.0",
3
+ "version": "2.50.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",