@lvce-editor/explorer-view 2.7.0 → 2.9.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.
@@ -901,6 +901,245 @@ const compareDirent = (direntA, direntB) => {
901
901
  return compareDirentType(direntA, direntB) || compareDirentName(direntA, direntB);
902
902
  };
903
903
 
904
+ const None$5 = 0;
905
+ const CreateFile = 1;
906
+ const CreateFolder = 2;
907
+ const Rename$1 = 3;
908
+
909
+ const emptyObject = {};
910
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
911
+ const i18nString = (key, placeholders = emptyObject) => {
912
+ if (placeholders === emptyObject) {
913
+ return key;
914
+ }
915
+ const replacer = (match, rest) => {
916
+ return placeholders[rest];
917
+ };
918
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
919
+ };
920
+
921
+ const CollapseAllFoldersInExplorer = 'Collapse All Folders in Explorer';
922
+ const Copy$1 = 'Copy';
923
+ const CopyPath = 'Copy Path';
924
+ const CopyRelativePath = 'Copy Relative Path';
925
+ const Cut$1 = 'Cut';
926
+ const Delete$1 = 'Delete';
927
+ const FileOrFolderNameMustBeProvider = 'A file or folder name must be provided.';
928
+ const FilesExplorer = 'Files Explorer';
929
+ const NewFile$1 = 'New File...';
930
+ const NewFolder$1 = 'New Folder...';
931
+ const OpenContainingFolder = 'Open Containing Folder';
932
+ const OpenFolder = 'Open folder';
933
+ const OpenInIntegratedTerminal = 'Open in integrated Terminal';
934
+ const Paste = 'Paste';
935
+ const RefreshExplorer = 'Refresh Explorer';
936
+ const Rename = 'Rename';
937
+ const YouHaveNotYetOpenedAFolder = 'You have not yet opened a folder';
938
+
939
+ const newFile$1 = () => {
940
+ return i18nString(NewFile$1);
941
+ };
942
+ const newFolder$1 = () => {
943
+ return i18nString(NewFolder$1);
944
+ };
945
+ const openContainingFolder$1 = () => {
946
+ return i18nString(OpenContainingFolder);
947
+ };
948
+ const openInIntegratedTerminal = () => {
949
+ return i18nString(OpenInIntegratedTerminal);
950
+ };
951
+ const cut = () => {
952
+ return i18nString(Cut$1);
953
+ };
954
+ const copy$1 = () => {
955
+ return i18nString(Copy$1);
956
+ };
957
+ const paste = () => {
958
+ return i18nString(Paste);
959
+ };
960
+ const copyPath$1 = () => {
961
+ return i18nString(CopyPath);
962
+ };
963
+ const copyRelativePath$1 = () => {
964
+ return i18nString(CopyRelativePath);
965
+ };
966
+ const rename$1 = () => {
967
+ return i18nString(Rename);
968
+ };
969
+ const deleteItem = () => {
970
+ return i18nString(Delete$1);
971
+ };
972
+ const refresh$1 = () => {
973
+ return i18nString(RefreshExplorer);
974
+ };
975
+ const collapseAll$1 = () => {
976
+ return i18nString(CollapseAllFoldersInExplorer);
977
+ };
978
+ const filesExplorer = () => {
979
+ return i18nString(FilesExplorer);
980
+ };
981
+ const youHaveNotYetOpenedAFolder = () => {
982
+ return i18nString(YouHaveNotYetOpenedAFolder);
983
+ };
984
+ const openFolder$1 = () => {
985
+ return i18nString(OpenFolder);
986
+ };
987
+ const fileOrFolderNameMustBeProvided = () => {
988
+ return i18nString(FileOrFolderNameMustBeProvider);
989
+ };
990
+
991
+ const List = 1;
992
+ const Input$1 = 2;
993
+
994
+ const getParentFolder = (dirents, index, root) => {
995
+ if (index < 0) {
996
+ return root;
997
+ }
998
+ return dirents[index].path;
999
+ };
1000
+ const acceptCreate = async (state, newDirentType, createFn) => {
1001
+ const {
1002
+ focusedIndex,
1003
+ editingValue
1004
+ } = state;
1005
+ const newFileName = editingValue;
1006
+ if (!newFileName) {
1007
+ // TODO show error message that file name must not be empty
1008
+ // below input box
1009
+ // await ErrorHandling.showErrorDialog(new Error('file name must not be empty'))
1010
+ const editingErrorMessage = fileOrFolderNameMustBeProvided();
1011
+ return {
1012
+ ...state,
1013
+ editingErrorMessage
1014
+ };
1015
+ }
1016
+ const parentFolder = getParentFolder(state.items, focusedIndex, state.root);
1017
+ const absolutePath = [parentFolder, newFileName].join(state.pathSeparator);
1018
+ // TODO better handle error
1019
+ try {
1020
+ await createFn(absolutePath);
1021
+ } catch (error) {
1022
+ console.error(new VError(error, `Failed to create file`));
1023
+ // TODO display error
1024
+ return state;
1025
+ }
1026
+ const parentDirent = focusedIndex >= 0 ? state.items[focusedIndex] : {
1027
+ depth: 0};
1028
+ const depth = parentDirent.depth + 1;
1029
+ const newDirent = {
1030
+ path: absolutePath,
1031
+ posInSet: -1,
1032
+ setSize: 1,
1033
+ depth,
1034
+ name: newFileName,
1035
+ type: newDirentType,
1036
+ icon: ''
1037
+ };
1038
+ newDirent.icon = '';
1039
+ let insertIndex = state.focusedIndex;
1040
+ let deltaPosInSet = 0;
1041
+ let posInSet = 1;
1042
+ let setSize = 1;
1043
+ let i = Math.max(state.focusedIndex, -1) + 1;
1044
+ const {
1045
+ items
1046
+ } = state;
1047
+ // TODO update posinset and setsize of all affected dirents
1048
+ for (; i < items.length; i++) {
1049
+ const dirent = items[i];
1050
+ if (dirent.depth !== depth) {
1051
+ break;
1052
+ }
1053
+ const compareResult = compareDirent(dirent, newDirent);
1054
+ if (compareResult === 1) {
1055
+ insertIndex = i - 1;
1056
+ deltaPosInSet = 1 - 1;
1057
+ break;
1058
+ } else {
1059
+ // @ts-ignore
1060
+ posInSet = dirent.posInSet + 1;
1061
+ // @ts-ignore
1062
+ setSize = dirent.setSize + 1;
1063
+ // @ts-ignore
1064
+ insertIndex = i;
1065
+ }
1066
+ // @ts-ignore
1067
+ dirent.setSize++;
1068
+ // @ts-ignore
1069
+ dirent.posInSet += deltaPosInSet;
1070
+ }
1071
+ newDirent.setSize = setSize;
1072
+ newDirent.posInSet = posInSet;
1073
+ // @ts-ignore
1074
+ items.splice(insertIndex + 1, 0, newDirent);
1075
+ const newDirents = [...items];
1076
+ const newMaxlineY = Math.max(state.maxLineY, newDirents.length);
1077
+ return {
1078
+ ...state,
1079
+ items: newDirents,
1080
+ editingIndex: -1,
1081
+ focusedIndex: insertIndex + 1,
1082
+ editingType: None$5,
1083
+ maxLineY: newMaxlineY,
1084
+ focus: List
1085
+ };
1086
+ };
1087
+
1088
+ const RendererWorker = 1;
1089
+
1090
+ const rpcs = Object.create(null);
1091
+ const set$1 = (id, rpc) => {
1092
+ rpcs[id] = rpc;
1093
+ };
1094
+ const get$1 = id => {
1095
+ return rpcs[id];
1096
+ };
1097
+
1098
+ const invoke = (method, ...params) => {
1099
+ const rpc = get$1(RendererWorker);
1100
+ // @ts-ignore
1101
+ return rpc.invoke(method, ...params);
1102
+ };
1103
+
1104
+ const remove = async dirent => {
1105
+ return invoke('FileSystem.remove', dirent);
1106
+ };
1107
+ const readDirWithFileTypes = async uri => {
1108
+ return invoke('FileSystem.readDirWithFileTypes', uri);
1109
+ };
1110
+ const getPathSeparator$1 = async root => {
1111
+ return invoke('FileSystem.getPathSeparator', root);
1112
+ };
1113
+ const getRealPath = async path => {
1114
+ return invoke('FileSystem.getRealPath', path);
1115
+ };
1116
+ const stat = async dirent => {
1117
+ return invoke('FileSystem.stat', dirent);
1118
+ };
1119
+ const createFile = async uri => {
1120
+ return invoke('FileSystem.writeFile', uri, '');
1121
+ };
1122
+ const writeFile = async (uri, content) => {
1123
+ return invoke('FileSystem.writeFile', uri, content);
1124
+ };
1125
+ const mkdir = async uri => {
1126
+ return invoke('FileSystem.mkdir', uri);
1127
+ };
1128
+ const rename = async (oldUri, newUri) => {
1129
+ return invoke('FileSystem.rename', oldUri, newUri);
1130
+ };
1131
+ const copy = async (oldUri, newUri) => {
1132
+ return invoke('FileSystem.copy', oldUri, newUri);
1133
+ };
1134
+
1135
+ const acceptCreateFile = async state => {
1136
+ return acceptCreate(state, File, createFile);
1137
+ };
1138
+
1139
+ const acceptCreateFolder = async state => {
1140
+ return acceptCreate(state, Directory, mkdir);
1141
+ };
1142
+
904
1143
  // TODO use posInSet and setSize properties to compute more effectively
905
1144
  const computeExplorerRenamedDirent = (dirents, index, newName) => {
906
1145
  let startIndex = index;
@@ -996,58 +1235,6 @@ const computeExplorerRenamedDirent = (dirents, index, newName) => {
996
1235
  };
997
1236
  };
998
1237
 
999
- const None$5 = 0;
1000
- const CreateFile = 1;
1001
- const CreateFolder = 2;
1002
- const Rename$1 = 3;
1003
-
1004
- const RendererWorker = 1;
1005
-
1006
- const rpcs = Object.create(null);
1007
- const set$1 = (id, rpc) => {
1008
- rpcs[id] = rpc;
1009
- };
1010
- const get$1 = id => {
1011
- return rpcs[id];
1012
- };
1013
-
1014
- const invoke = (method, ...params) => {
1015
- const rpc = get$1(RendererWorker);
1016
- // @ts-ignore
1017
- return rpc.invoke(method, ...params);
1018
- };
1019
-
1020
- const remove = async dirent => {
1021
- return invoke('FileSystem.remove', dirent);
1022
- };
1023
- const readDirWithFileTypes = async uri => {
1024
- return invoke('FileSystem.readDirWithFileTypes', uri);
1025
- };
1026
- const getPathSeparator$1 = async root => {
1027
- return invoke('FileSystem.getPathSeparator', root);
1028
- };
1029
- const getRealPath = async path => {
1030
- return invoke('FileSystem.getRealPath', path);
1031
- };
1032
- const stat = async dirent => {
1033
- return invoke('FileSystem.stat', dirent);
1034
- };
1035
- const createFile = async uri => {
1036
- return invoke('FileSystem.createFile', uri);
1037
- };
1038
- const writeFile = async (uri, content) => {
1039
- return invoke('FileSystem.writeFile', uri, content);
1040
- };
1041
- const mkdir = async uri => {
1042
- return invoke('FileSystem.mkdir', uri);
1043
- };
1044
- const rename$1 = async (oldUri, newUri) => {
1045
- return invoke('FileSystem.rename', oldUri, newUri);
1046
- };
1047
- const copy$1 = async (oldUri, newUri) => {
1048
- return invoke('FileSystem.copy', oldUri, newUri);
1049
- };
1050
-
1051
1238
  const dirname = (pathSeparator, path) => {
1052
1239
  const index = path.lastIndexOf(pathSeparator);
1053
1240
  if (index === -1) {
@@ -1062,93 +1249,6 @@ const getBaseName = (pathSeparator, path) => {
1062
1249
  return path.slice(path.lastIndexOf(pathSeparator) + 1);
1063
1250
  };
1064
1251
 
1065
- const getParentFolder = (dirents, index, root) => {
1066
- if (index < 0) {
1067
- return root;
1068
- }
1069
- return dirents[index].path;
1070
- };
1071
- const acceptCreate = async (state, newDirentType, createFn) => {
1072
- const {
1073
- focusedIndex,
1074
- editingValue
1075
- } = state;
1076
- const newFileName = editingValue;
1077
- if (!newFileName) {
1078
- // TODO show error message that file name must not be empty
1079
- // below input box
1080
- // await ErrorHandling.showErrorDialog(new Error('file name must not be empty'))
1081
- return state;
1082
- }
1083
- const parentFolder = getParentFolder(state.items, focusedIndex, state.root);
1084
- const absolutePath = [parentFolder, newFileName].join(state.pathSeparator);
1085
- // TODO better handle error
1086
- try {
1087
- await createFn(absolutePath);
1088
- } catch {
1089
- // TODO display error
1090
- return state;
1091
- }
1092
- const parentDirent = focusedIndex >= 0 ? state.items[focusedIndex] : {
1093
- depth: 0};
1094
- const depth = parentDirent.depth + 1;
1095
- const newDirent = {
1096
- path: absolutePath,
1097
- posInSet: -1,
1098
- setSize: 1,
1099
- depth,
1100
- name: newFileName,
1101
- type: newDirentType,
1102
- icon: ''
1103
- };
1104
- newDirent.icon = '';
1105
- let insertIndex = state.focusedIndex;
1106
- let deltaPosInSet = 0;
1107
- let posInSet = 1;
1108
- let setSize = 1;
1109
- let i = Math.max(state.focusedIndex, -1) + 1;
1110
- const {
1111
- items
1112
- } = state;
1113
- // TODO update posinset and setsize of all affected dirents
1114
- for (; i < items.length; i++) {
1115
- const dirent = items[i];
1116
- if (dirent.depth !== depth) {
1117
- break;
1118
- }
1119
- const compareResult = compareDirent(dirent, newDirent);
1120
- if (compareResult === 1) {
1121
- insertIndex = i - 1;
1122
- deltaPosInSet = 1 - 1;
1123
- break;
1124
- } else {
1125
- // @ts-ignore
1126
- posInSet = dirent.posInSet + 1;
1127
- // @ts-ignore
1128
- setSize = dirent.setSize + 1;
1129
- // @ts-ignore
1130
- insertIndex = i;
1131
- }
1132
- // @ts-ignore
1133
- dirent.setSize++;
1134
- // @ts-ignore
1135
- dirent.posInSet += deltaPosInSet;
1136
- }
1137
- newDirent.setSize = setSize;
1138
- newDirent.posInSet = posInSet;
1139
- // @ts-ignore
1140
- items.splice(insertIndex + 1, 0, newDirent);
1141
- const newDirents = [...items];
1142
- const newMaxlineY = Math.max(state.maxLineY, newDirents.length);
1143
- return {
1144
- ...state,
1145
- items: newDirents,
1146
- editingIndex: -1,
1147
- focusedIndex: insertIndex + 1,
1148
- editingType: None$5,
1149
- maxLineY: newMaxlineY
1150
- };
1151
- };
1152
1252
  const acceptRename = async state => {
1153
1253
  const {
1154
1254
  editingIndex,
@@ -1162,7 +1262,7 @@ const acceptRename = async state => {
1162
1262
  const oldAbsolutePath = renamedDirent.path;
1163
1263
  const oldParentPath = dirname(pathSeparator, oldAbsolutePath);
1164
1264
  const newAbsolutePath = [oldParentPath, editingValue].join(pathSeparator);
1165
- await rename$1(oldAbsolutePath, newAbsolutePath);
1265
+ await rename(oldAbsolutePath, newAbsolutePath);
1166
1266
  } catch {
1167
1267
  // TODO
1168
1268
  // await ErrorHandling.showErrorDialog(error)
@@ -1182,18 +1282,20 @@ const acceptRename = async state => {
1182
1282
  editingType: None$5,
1183
1283
  editingIcon: '',
1184
1284
  focusedIndex,
1185
- focused: true
1285
+ focused: true,
1286
+ focus: List
1186
1287
  };
1187
1288
  };
1289
+
1188
1290
  const acceptEdit = async state => {
1189
1291
  const {
1190
1292
  editingType
1191
1293
  } = state;
1192
1294
  switch (editingType) {
1193
1295
  case CreateFile:
1194
- return acceptCreate(state, File, createFile);
1296
+ return acceptCreateFile(state);
1195
1297
  case CreateFolder:
1196
- return acceptCreate(state, Directory, mkdir);
1298
+ return acceptCreateFolder(state);
1197
1299
  case Rename$1:
1198
1300
  return acceptRename(state);
1199
1301
  default:
@@ -1211,7 +1313,8 @@ const cancelEdit = state => {
1211
1313
  focused: true,
1212
1314
  editingIndex: -1,
1213
1315
  editingValue: '',
1214
- editingType: None$5
1316
+ editingType: None$5,
1317
+ focus: List
1215
1318
  };
1216
1319
  };
1217
1320
 
@@ -1229,7 +1332,7 @@ const toCollapsedDirent = dirent => {
1229
1332
  return dirent;
1230
1333
  };
1231
1334
 
1232
- const collapseAll$1 = state => {
1335
+ const collapseAll = state => {
1233
1336
  const {
1234
1337
  items
1235
1338
  } = state;
@@ -1250,7 +1353,7 @@ const getFocusedDirent$1 = state => {
1250
1353
  return dirent;
1251
1354
  };
1252
1355
 
1253
- const copyPath$1 = async state => {
1356
+ const copyPath = async state => {
1254
1357
  // await Command.execute(RendererWorkerCommandType.ClipBoardWriteText, /* text */ path)
1255
1358
  return state;
1256
1359
  };
@@ -1265,7 +1368,7 @@ const writeNativeFiles = async (type, files) => {
1265
1368
  return invoke('ClipBoard.writeNativeFiles', type, files);
1266
1369
  };
1267
1370
 
1268
- const copyRelativePath$1 = async state => {
1371
+ const copyRelativePath = async state => {
1269
1372
  const dirent = getFocusedDirent$1(state);
1270
1373
  const relativePath = dirent.path.slice(1);
1271
1374
  // TODO handle error
@@ -1318,7 +1421,8 @@ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) =
1318
1421
  useChevrons: false,
1319
1422
  icons: [],
1320
1423
  platform,
1321
- focus: 0
1424
+ focus: 0,
1425
+ editingErrorMessage: ''
1322
1426
  };
1323
1427
  set(uid, state, state);
1324
1428
  };
@@ -1353,7 +1457,8 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
1353
1457
  useChevrons: false,
1354
1458
  icons: [],
1355
1459
  platform,
1356
- focus: 0
1460
+ focus: 0,
1461
+ editingErrorMessage: ''
1357
1462
  };
1358
1463
  set(state.uid, state, state);
1359
1464
  return state;
@@ -1376,7 +1481,7 @@ const DiffEditingIndex = {
1376
1481
 
1377
1482
  const diffType$1 = RenderFocus;
1378
1483
  const isEqual$2 = (oldState, newState) => {
1379
- return oldState.focused === newState.focused;
1484
+ return oldState.focused === newState.focused && oldState.focus === newState.focus;
1380
1485
  };
1381
1486
 
1382
1487
  const DiffFocus = {
@@ -1387,7 +1492,7 @@ const DiffFocus = {
1387
1492
 
1388
1493
  const diffType = RenderItems;
1389
1494
  const isEqual$1 = (oldState, newState) => {
1390
- return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType && oldState.editingValue === newState.editingValue && oldState.width === newState.width && oldState.focused === newState.focused && oldState.dropTargets === newState.dropTargets;
1495
+ return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingType === newState.editingType && oldState.editingValue === newState.editingValue && oldState.editingErrorMessage === newState.editingErrorMessage && oldState.width === newState.width && oldState.focused === newState.focused && oldState.dropTargets === newState.dropTargets;
1391
1496
  };
1392
1497
 
1393
1498
  const DiffItems = {
@@ -1862,7 +1967,7 @@ const LeftArrow = 13;
1862
1967
  const UpArrow = 14;
1863
1968
  const RightArrow = 15;
1864
1969
  const DownArrow = 16;
1865
- const Delete$1 = 18;
1970
+ const Delete = 18;
1866
1971
  const KeyC = 31;
1867
1972
  const KeyV = 50;
1868
1973
  const F2 = 58;
@@ -1932,7 +2037,7 @@ const getKeyBindings = () => {
1932
2037
  command: 'Explorer.acceptEdit',
1933
2038
  when: FocusExplorerEditBox
1934
2039
  }, {
1935
- key: Delete$1,
2040
+ key: Delete,
1936
2041
  command: 'Explorer.removeDirent',
1937
2042
  when: FocusExplorer
1938
2043
  }, {
@@ -1950,84 +2055,6 @@ const getKeyBindings = () => {
1950
2055
  }];
1951
2056
  };
1952
2057
 
1953
- const emptyObject = {};
1954
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1955
- const i18nString = (key, placeholders = emptyObject) => {
1956
- if (placeholders === emptyObject) {
1957
- return key;
1958
- }
1959
- const replacer = (match, rest) => {
1960
- return placeholders[rest];
1961
- };
1962
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1963
- };
1964
-
1965
- const NewFile$1 = 'New File...';
1966
- const NewFolder$1 = 'New Folder...';
1967
- const OpenContainingFolder = 'Open Containing Folder';
1968
- const OpenInIntegratedTerminal = 'Open in integrated Terminal';
1969
- const Cut$1 = 'Cut';
1970
- const Copy$1 = 'Copy';
1971
- const Paste = 'Paste';
1972
- const CopyPath = 'Copy Path';
1973
- const CopyRelativePath = 'Copy Relative Path';
1974
- const Rename = 'Rename';
1975
- const Delete = 'Delete';
1976
- const RefreshExplorer = 'Refresh Explorer';
1977
- const CollapseAllFoldersInExplorer = 'Collapse All Folders in Explorer';
1978
- const FilesExplorer = 'Files Explorer';
1979
- const YouHaveNotYetOpenedAFolder = 'You have not yet opened a folder';
1980
- const OpenFolder = 'Open folder';
1981
-
1982
- const newFile$1 = () => {
1983
- return i18nString(NewFile$1);
1984
- };
1985
- const newFolder$1 = () => {
1986
- return i18nString(NewFolder$1);
1987
- };
1988
- const openContainingFolder$1 = () => {
1989
- return i18nString(OpenContainingFolder);
1990
- };
1991
- const openInIntegratedTerminal = () => {
1992
- return i18nString(OpenInIntegratedTerminal);
1993
- };
1994
- const cut = () => {
1995
- return i18nString(Cut$1);
1996
- };
1997
- const copy = () => {
1998
- return i18nString(Copy$1);
1999
- };
2000
- const paste = () => {
2001
- return i18nString(Paste);
2002
- };
2003
- const copyPath = () => {
2004
- return i18nString(CopyPath);
2005
- };
2006
- const copyRelativePath = () => {
2007
- return i18nString(CopyRelativePath);
2008
- };
2009
- const rename = () => {
2010
- return i18nString(Rename);
2011
- };
2012
- const deleteItem = () => {
2013
- return i18nString(Delete);
2014
- };
2015
- const refresh$1 = () => {
2016
- return i18nString(RefreshExplorer);
2017
- };
2018
- const collapseAll = () => {
2019
- return i18nString(CollapseAllFoldersInExplorer);
2020
- };
2021
- const filesExplorer = () => {
2022
- return i18nString(FilesExplorer);
2023
- };
2024
- const youHaveNotYetOpenedAFolder = () => {
2025
- return i18nString(YouHaveNotYetOpenedAFolder);
2026
- };
2027
- const openFolder$1 = () => {
2028
- return i18nString(OpenFolder);
2029
- };
2030
-
2031
2058
  const Separator = 1;
2032
2059
  const None$4 = 0;
2033
2060
  const RestoreFocus = 6;
@@ -2071,7 +2098,7 @@ const menuEntryCut = {
2071
2098
  };
2072
2099
  const menuEntryCopy = {
2073
2100
  id: 'copy',
2074
- label: copy(),
2101
+ label: copy$1(),
2075
2102
  flags: RestoreFocus,
2076
2103
  command: 'Explorer.handleCopy'
2077
2104
  };
@@ -2083,19 +2110,19 @@ const menuEntryPaste = {
2083
2110
  };
2084
2111
  const menuEntryCopyPath = {
2085
2112
  id: 'copyPath',
2086
- label: copyPath(),
2113
+ label: copyPath$1(),
2087
2114
  flags: RestoreFocus,
2088
2115
  command: 'Explorer.copyPath'
2089
2116
  };
2090
2117
  const menuEntryCopyRelativePath = {
2091
2118
  id: 'copyRelativePath',
2092
- label: copyRelativePath(),
2119
+ label: copyRelativePath$1(),
2093
2120
  flags: RestoreFocus,
2094
2121
  command: 'Explorer.copyRelativePath'
2095
2122
  };
2096
2123
  const menuEntryRename = {
2097
2124
  id: 'rename',
2098
- label: rename(),
2125
+ label: rename$1(),
2099
2126
  flags: None$4,
2100
2127
  command: 'Explorer.renameDirent'
2101
2128
  };
@@ -2569,7 +2596,7 @@ const handleCopy = async state => {
2569
2596
  // TODO if not file is selected, what happens?
2570
2597
  const dirent = getFocusedDirent$1(state);
2571
2598
  if (!dirent) {
2572
- console.info('[ViewletExplorer/handleCopy] no dirent selected');
2599
+ console.error('[ViewletExplorer/handleCopy] no dirent selected');
2573
2600
  return state;
2574
2601
  }
2575
2602
  const absolutePath = dirent.path;
@@ -2689,7 +2716,7 @@ const applyOperation = operation => {
2689
2716
  return mkdir(operation.path);
2690
2717
  }
2691
2718
  if (operation.type === 'copy') {
2692
- return copy$1(operation.from || '', operation.path);
2719
+ return copy(operation.from || '', operation.path);
2693
2720
  }
2694
2721
  return writeFile(operation.path, operation.text);
2695
2722
  };
@@ -2724,7 +2751,9 @@ const isFileHandle = fileHandle => {
2724
2751
  const createUploadTree = async (root, fileHandles) => {
2725
2752
  const uploadTree = Object.create(null);
2726
2753
  for (const fileHandle of fileHandles) {
2727
- const name = fileHandle.name;
2754
+ const {
2755
+ name
2756
+ } = fileHandle;
2728
2757
  if (isDirectoryHandle(fileHandle)) {
2729
2758
  const children = await getChildHandles(fileHandle);
2730
2759
  const childTree = await createUploadTree(name, children);
@@ -2812,7 +2841,9 @@ const getFileOperationsElectron = async (root, paths, fileHandles) => {
2812
2841
  const operations = [];
2813
2842
  for (let i = 0; i < paths.length; i++) {
2814
2843
  const fileHandle = fileHandles[i];
2815
- const name = fileHandle.name;
2844
+ const {
2845
+ name
2846
+ } = fileHandle;
2816
2847
  const path = paths[i];
2817
2848
  operations.push({
2818
2849
  type: 'copy',
@@ -2898,7 +2929,7 @@ const handleDropIntoFolder = async (state, dirent, index, fileHandles, files, pa
2898
2929
  const baseName = file.name;
2899
2930
  const to = dirent.path + pathSeparator + baseName;
2900
2931
  // @ts-ignore
2901
- await copy$1(file, to);
2932
+ await copy(file, to);
2902
2933
  }
2903
2934
  const childDirents = await getChildDirents(pathSeparator, dirent);
2904
2935
  const mergedDirents = getMergedDirents(items, index, dirent, childDirents);
@@ -3051,7 +3082,7 @@ const handlePasteCopy = async (state, nativeFiles) => {
3051
3082
  for (const source of nativeFiles.files) {
3052
3083
  // @ts-ignore
3053
3084
  const target = join(state.pathSeperator, state.root, getBaseName(state.pathSeparator, source));
3054
- await copy$1(source, target);
3085
+ await copy(source, target);
3055
3086
  }
3056
3087
  // TODO only update folder at which level it changed
3057
3088
  return updateRoot(state);
@@ -3060,13 +3091,13 @@ const handlePasteCopy = async (state, nativeFiles) => {
3060
3091
  const handlePasteCut = async (state, nativeFiles) => {
3061
3092
  for (const source of nativeFiles.files) {
3062
3093
  const target = `${state.root}${state.pathSeparator}${getBaseName(state.pathSeparator, source)}`;
3063
- await rename$1(source, target);
3094
+ await rename(source, target);
3064
3095
  }
3065
3096
  return state;
3066
3097
  };
3067
3098
 
3068
3099
  const handlePasteNone = async (state, nativeFiles) => {
3069
- console.info('[ViewletExplorer/handlePaste] no paths detected');
3100
+ console.error('[ViewletExplorer/handlePaste] no paths detected');
3070
3101
  return state;
3071
3102
  };
3072
3103
 
@@ -3392,7 +3423,8 @@ const newDirent = async (state, editingType) => {
3392
3423
  ...state,
3393
3424
  editingIndex: focusedIndex,
3394
3425
  editingType,
3395
- editingValue: ''
3426
+ editingValue: '',
3427
+ focus: Input$1
3396
3428
  };
3397
3429
  };
3398
3430
 
@@ -3507,7 +3539,12 @@ const renderEditingIndex = (oldState, newState) => {
3507
3539
  return ['focusInput', 'ExplorerInput'];
3508
3540
  };
3509
3541
 
3542
+ const ExplorerInput = 'ExplorerInput';
3543
+
3510
3544
  const renderFocus = (oldState, newState) => {
3545
+ if (newState.focus === Input$1) {
3546
+ return ['Viewlet.focusElementByName', ExplorerInput];
3547
+ }
3511
3548
  // TODO
3512
3549
  // 1. when focused, focus the outer list element
3513
3550
  // 2. when focused, set focus context in renderer worker
@@ -3525,13 +3562,14 @@ const ButtonNarrow = 'ButtonNarrow';
3525
3562
  const ButtonPrimary = 'ButtonPrimary';
3526
3563
  const ButtonWide = 'ButtonWide';
3527
3564
  const Chevron = 'Chevron';
3528
- const Explorer = 'Explorer';
3529
3565
  const Empty = '';
3566
+ const Explorer = 'Explorer';
3530
3567
  const ExplorerDropTarget = 'DropTarget';
3531
3568
  const FileIcon = 'FileIcon';
3532
3569
  const FocusOutline = 'FocusOutline';
3533
3570
  const IconButton = 'IconButton';
3534
3571
  const InputBox = 'InputBox';
3572
+ const InputValidationError = 'InputValidationError';
3535
3573
  const Label = 'Label';
3536
3574
  const MaskIconChevronDown = 'MaskIconChevronDown';
3537
3575
  const MaskIconChevronRight = 'MaskIconChevronRight';
@@ -3610,18 +3648,22 @@ const getFileIconVirtualDom = icon => {
3610
3648
  };
3611
3649
  };
3612
3650
 
3613
- const ExplorerInput = 'ExplorerInput';
3614
-
3615
3651
  const label = {
3616
3652
  type: Div,
3617
3653
  className: Label,
3618
3654
  childCount: 1
3619
3655
  };
3620
- const getInputOrLabelDom = (isEditing, name) => {
3656
+ const getClassName$1 = hasEditingError => {
3657
+ if (hasEditingError) {
3658
+ return mergeClassNames(InputBox, InputValidationError);
3659
+ }
3660
+ return InputBox;
3661
+ };
3662
+ const getInputOrLabelDom = (isEditing, hasEditingError, name) => {
3621
3663
  if (isEditing) {
3622
3664
  return [{
3623
3665
  type: Input,
3624
- className: InputBox,
3666
+ className: getClassName$1(hasEditingError),
3625
3667
  id: 'ExplorerInput',
3626
3668
  onInput: HandleEditingInput,
3627
3669
  childCount: 0,
@@ -3644,7 +3686,8 @@ const getExplorerItemVirtualDom = item => {
3644
3686
  id,
3645
3687
  className,
3646
3688
  isEditing,
3647
- ariaExpanded
3689
+ ariaExpanded,
3690
+ hasEditingError
3648
3691
  } = item;
3649
3692
  const chevronDom = getChevronVirtualDom(chevron);
3650
3693
  const dom = [{
@@ -3662,7 +3705,7 @@ const getExplorerItemVirtualDom = item => {
3662
3705
  ariaExpanded,
3663
3706
  ariaDescription: '',
3664
3707
  id
3665
- }, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, name)];
3708
+ }, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name)];
3666
3709
  return dom;
3667
3710
  };
3668
3711
 
@@ -3778,7 +3821,7 @@ const getTreeItemIndentWithChevron = (depth, chevron) => {
3778
3821
  };
3779
3822
 
3780
3823
  const ariaExpandedValues = [undefined, 'true', 'false'];
3781
- const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, icons, useChevrons, dropTargets) => {
3824
+ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets) => {
3782
3825
  const visible = [];
3783
3826
  const indentFn = useChevrons ? getTreeItemIndentWithChevron : getTreeItemIndent;
3784
3827
  let iconIndex = 0;
@@ -3795,6 +3838,7 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
3795
3838
  visible.push({
3796
3839
  ...item,
3797
3840
  isEditing: i === editingIndex,
3841
+ hasEditingError: i === editingIndex && Boolean(editingErrorMessage),
3798
3842
  icon,
3799
3843
  indent,
3800
3844
  ariaExpanded,
@@ -3812,6 +3856,7 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
3812
3856
  name: 'new',
3813
3857
  path: '/test/new',
3814
3858
  isEditing: true,
3859
+ hasEditingError: Boolean(editingErrorMessage),
3815
3860
  indent: '',
3816
3861
  ariaExpanded: undefined,
3817
3862
  chevron: 0,
@@ -3823,7 +3868,7 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
3823
3868
  };
3824
3869
 
3825
3870
  const renderItems = (oldState, newState) => {
3826
- const visibleDirents = getVisibleExplorerItems(newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.editingIndex, newState.editingType, newState.editingValue, newState.icons, newState.useChevrons);
3871
+ const visibleDirents = getVisibleExplorerItems(newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.editingIndex, newState.editingType, newState.editingValue, newState.editingErrorMessage, newState.icons, newState.useChevrons);
3827
3872
  const isWide = newState.width > 450;
3828
3873
  const dom = getExplorerVirtualDom(visibleDirents, newState.focusedIndex, newState.root, isWide, newState.focused, newState.dropTargets);
3829
3874
  return ['Viewlet.setDom2', dom];
@@ -3892,7 +3937,7 @@ const getActions = root => {
3892
3937
  command: 'refresh'
3893
3938
  }, {
3894
3939
  type: Button,
3895
- id: collapseAll(),
3940
+ id: collapseAll$1(),
3896
3941
  icon: CollapseAll,
3897
3942
  command: 'collapseAll'
3898
3943
  }];
@@ -3973,7 +4018,7 @@ const renderEventListeners = () => {
3973
4018
  preventDefault: true
3974
4019
  }, {
3975
4020
  name: HandleEditingInput,
3976
- params: ['handleEditingInput', 'event.target.value']
4021
+ params: ['updateEditingValue', 'event.target.value']
3977
4022
  }, {
3978
4023
  name: HandleContextMenu,
3979
4024
  params: ['handleContextMenu', 'event.button', 'event.clientX', 'event.clientY'],
@@ -4265,7 +4310,9 @@ const isExpandedDirectory = dirent => {
4265
4310
  const saveState = uid => {
4266
4311
  number(uid);
4267
4312
  const value = get(uid);
4268
- const newState = value.newState;
4313
+ const {
4314
+ newState
4315
+ } = value;
4269
4316
  const {
4270
4317
  items,
4271
4318
  root,
@@ -4315,9 +4362,9 @@ const commandMap = {
4315
4362
  'Explorer.getMenuEntries2': getMenuEntries2,
4316
4363
  'Explorer.acceptEdit': wrapCommand(acceptEdit),
4317
4364
  'Explorer.cancelEdit': wrapCommand(cancelEdit),
4318
- 'Explorer.collapseAll': wrapCommand(collapseAll$1),
4319
- 'Explorer.copyPath': wrapCommand(copyPath$1),
4320
- 'Explorer.copyRelativePath': wrapCommand(copyRelativePath$1),
4365
+ 'Explorer.collapseAll': wrapCommand(collapseAll),
4366
+ 'Explorer.copyPath': wrapCommand(copyPath),
4367
+ 'Explorer.copyRelativePath': wrapCommand(copyRelativePath),
4321
4368
  'Explorer.expandAll': wrapCommand(expandAll),
4322
4369
  'Explorer.expandRecursively': wrapCommand(expandRecursively),
4323
4370
  'Explorer.focusFirst': wrapCommand(focusFirst),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",