@lvce-editor/explorer-view 6.7.0 → 6.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/explorerViewWorkerMain.js +106 -63
- package/package.json +1 -1
|
@@ -1563,11 +1563,22 @@ const getIndex = (dirents, uri) => {
|
|
|
1563
1563
|
return -1;
|
|
1564
1564
|
};
|
|
1565
1565
|
|
|
1566
|
-
const
|
|
1566
|
+
const isFileLike = type => {
|
|
1567
|
+
return type === File || type === SymLinkFile;
|
|
1568
|
+
};
|
|
1569
|
+
const getParentFolder = (dirents, index, root, pathSeparator) => {
|
|
1567
1570
|
if (index < 0) {
|
|
1568
1571
|
return root;
|
|
1569
1572
|
}
|
|
1570
|
-
|
|
1573
|
+
const item = dirents[index];
|
|
1574
|
+
if (!item) {
|
|
1575
|
+
return root;
|
|
1576
|
+
}
|
|
1577
|
+
if (isFileLike(item.type)) {
|
|
1578
|
+
const parentFolder = dirname(pathSeparator, item.path);
|
|
1579
|
+
return parentFolder || root;
|
|
1580
|
+
}
|
|
1581
|
+
return item.path;
|
|
1571
1582
|
};
|
|
1572
1583
|
|
|
1573
1584
|
const getPathParts = (root, uri, pathSeparator) => {
|
|
@@ -2008,7 +2019,7 @@ const acceptCreate = async (state, newDirentType) => {
|
|
|
2008
2019
|
editingErrorMessage
|
|
2009
2020
|
};
|
|
2010
2021
|
}
|
|
2011
|
-
const parentFolder = getParentFolder(items, focusedIndex, root);
|
|
2022
|
+
const parentFolder = getParentFolder(items, focusedIndex, root, pathSeparator);
|
|
2012
2023
|
const absolutePath = join2(parentFolder, newFileName);
|
|
2013
2024
|
const operations = getFileOperationsCreate(editingValue, newDirentType, pathSeparator, absolutePath, root);
|
|
2014
2025
|
const createErrorMessage = await applyFileOperations(operations);
|
|
@@ -2770,7 +2781,6 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
2770
2781
|
patches.push({
|
|
2771
2782
|
type: NavigateParent
|
|
2772
2783
|
});
|
|
2773
|
-
currentChildIndex = -1;
|
|
2774
2784
|
}
|
|
2775
2785
|
// Add remove patches in reverse order (highest index first)
|
|
2776
2786
|
// This ensures indices remain valid as we remove
|
|
@@ -4368,6 +4378,10 @@ const handleContextMenu = async (state, button, x, y) => {
|
|
|
4368
4378
|
return newState;
|
|
4369
4379
|
};
|
|
4370
4380
|
|
|
4381
|
+
const handleContextMenuWelcome = state => {
|
|
4382
|
+
return state;
|
|
4383
|
+
};
|
|
4384
|
+
|
|
4371
4385
|
const handleCopy = async state => {
|
|
4372
4386
|
// TODO handle multiple files
|
|
4373
4387
|
// TODO if not file is selected, what happens?
|
|
@@ -4519,6 +4533,34 @@ const isDirectoryHandle = fileHandle => {
|
|
|
4519
4533
|
return fileHandle.kind === 'directory';
|
|
4520
4534
|
};
|
|
4521
4535
|
|
|
4536
|
+
const getErrorCode = error => {
|
|
4537
|
+
if (error && typeof error === 'object' && 'code' in error && typeof error.code === 'string') {
|
|
4538
|
+
return error.code;
|
|
4539
|
+
}
|
|
4540
|
+
return '';
|
|
4541
|
+
};
|
|
4542
|
+
|
|
4543
|
+
const getErrorMessage = error => {
|
|
4544
|
+
if (error instanceof Error) {
|
|
4545
|
+
return error.message;
|
|
4546
|
+
}
|
|
4547
|
+
if (typeof error === 'string') {
|
|
4548
|
+
return error;
|
|
4549
|
+
}
|
|
4550
|
+
return 'Unknown error';
|
|
4551
|
+
};
|
|
4552
|
+
|
|
4553
|
+
const getExcluded = () => {
|
|
4554
|
+
const excludedObject = {};
|
|
4555
|
+
const excluded = [];
|
|
4556
|
+
for (const [key, value] of Object.entries(excludedObject)) {
|
|
4557
|
+
if (value) {
|
|
4558
|
+
excluded.push(key);
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4561
|
+
return excluded;
|
|
4562
|
+
};
|
|
4563
|
+
|
|
4522
4564
|
const isValid = decoration => {
|
|
4523
4565
|
return decoration && typeof decoration.decoration === 'string' && typeof decoration.uri === 'string';
|
|
4524
4566
|
};
|
|
@@ -4550,6 +4592,37 @@ const getFileDecorations = async (scheme, root, maybeUris, decorationsEnabled, a
|
|
|
4550
4592
|
}
|
|
4551
4593
|
};
|
|
4552
4594
|
|
|
4595
|
+
const getFriendlyErrorMessage = (errorMessage, errorCode) => {
|
|
4596
|
+
switch (errorCode) {
|
|
4597
|
+
case 'EACCES':
|
|
4598
|
+
case 'EPERM':
|
|
4599
|
+
return 'permission was denied';
|
|
4600
|
+
case 'EBUSY':
|
|
4601
|
+
return 'the folder is currently in use';
|
|
4602
|
+
case 'ENOENT':
|
|
4603
|
+
return 'the folder does not exist';
|
|
4604
|
+
case 'ENOTDIR':
|
|
4605
|
+
return 'the path is not a folder';
|
|
4606
|
+
default:
|
|
4607
|
+
return errorMessage || 'an unexpected error occurred';
|
|
4608
|
+
}
|
|
4609
|
+
};
|
|
4610
|
+
|
|
4611
|
+
const getPathSeparator = async root => {
|
|
4612
|
+
return getPathSeparator$1(root);
|
|
4613
|
+
};
|
|
4614
|
+
|
|
4615
|
+
const getRestoredDeltaY = savedState => {
|
|
4616
|
+
if (savedState && typeof savedState.deltaY === 'number') {
|
|
4617
|
+
return savedState.deltaY;
|
|
4618
|
+
}
|
|
4619
|
+
return 0;
|
|
4620
|
+
};
|
|
4621
|
+
|
|
4622
|
+
const getSavedRoot = (savedState, workspacePath) => {
|
|
4623
|
+
return workspacePath;
|
|
4624
|
+
};
|
|
4625
|
+
|
|
4553
4626
|
const RE_PROTOCOL = /^[a-z+]:\/\//;
|
|
4554
4627
|
const getScheme = uri => {
|
|
4555
4628
|
const match = uri.match(RE_PROTOCOL);
|
|
@@ -4675,55 +4748,11 @@ const restoreExpandedState = async (savedState, root, pathSeparator, excluded) =
|
|
|
4675
4748
|
return dirents;
|
|
4676
4749
|
};
|
|
4677
4750
|
|
|
4678
|
-
const getPathSeparator = root => {
|
|
4679
|
-
return getPathSeparator$1(root);
|
|
4680
|
-
};
|
|
4681
|
-
const getExcluded = () => {
|
|
4682
|
-
const excludedObject = {};
|
|
4683
|
-
const excluded = [];
|
|
4684
|
-
for (const [key, value] of Object.entries(excludedObject)) {
|
|
4685
|
-
if (value) {
|
|
4686
|
-
excluded.push(key);
|
|
4687
|
-
}
|
|
4688
|
-
}
|
|
4689
|
-
return excluded;
|
|
4690
|
-
};
|
|
4691
|
-
const getSavedRoot = (savedState, workspacePath) => {
|
|
4692
|
-
return workspacePath;
|
|
4693
|
-
};
|
|
4694
|
-
const getErrorCode = error => {
|
|
4695
|
-
if (error && typeof error === 'object' && 'code' in error && typeof error.code === 'string') {
|
|
4696
|
-
return error.code;
|
|
4697
|
-
}
|
|
4698
|
-
return '';
|
|
4699
|
-
};
|
|
4700
|
-
const getErrorMessage = error => {
|
|
4701
|
-
if (error instanceof Error) {
|
|
4702
|
-
return error.message;
|
|
4703
|
-
}
|
|
4704
|
-
if (typeof error === 'string') {
|
|
4705
|
-
return error;
|
|
4706
|
-
}
|
|
4707
|
-
return 'Unknown error';
|
|
4708
|
-
};
|
|
4709
|
-
const getFriendlyErrorMessage = (errorMessage, errorCode) => {
|
|
4710
|
-
switch (errorCode) {
|
|
4711
|
-
case 'EACCES':
|
|
4712
|
-
case 'EPERM':
|
|
4713
|
-
return 'permission was denied';
|
|
4714
|
-
case 'EBUSY':
|
|
4715
|
-
return 'the folder is currently in use';
|
|
4716
|
-
case 'ENOENT':
|
|
4717
|
-
return 'the folder does not exist';
|
|
4718
|
-
case 'ENOTDIR':
|
|
4719
|
-
return 'the path is not a folder';
|
|
4720
|
-
default:
|
|
4721
|
-
return errorMessage || 'an unexpected error occurred';
|
|
4722
|
-
}
|
|
4723
|
-
};
|
|
4724
4751
|
const loadContent = async (state, savedState) => {
|
|
4725
4752
|
const {
|
|
4726
4753
|
assetDir,
|
|
4754
|
+
height,
|
|
4755
|
+
itemHeight,
|
|
4727
4756
|
platform
|
|
4728
4757
|
} = state;
|
|
4729
4758
|
const {
|
|
@@ -4738,14 +4767,10 @@ const loadContent = async (state, savedState) => {
|
|
|
4738
4767
|
const pathSeparator = await getPathSeparator(root); // TODO only load path separator once
|
|
4739
4768
|
const excluded = getExcluded();
|
|
4740
4769
|
const restoredDirents = await restoreExpandedState(savedState, root, pathSeparator, excluded);
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
let deltaY = 0;
|
|
4746
|
-
if (savedState && typeof savedState.deltaY === 'number') {
|
|
4747
|
-
deltaY = savedState.deltaY;
|
|
4748
|
-
}
|
|
4770
|
+
const rawDeltaY = getRestoredDeltaY(savedState);
|
|
4771
|
+
const maxDeltaY = Math.max(restoredDirents.length * itemHeight - height, 0);
|
|
4772
|
+
const deltaY = Math.min(Math.max(rawDeltaY, 0), maxDeltaY);
|
|
4773
|
+
const minLineY = Math.round(deltaY / itemHeight);
|
|
4749
4774
|
const scheme = getScheme(root);
|
|
4750
4775
|
const decorations = await getFileDecorations(scheme, root, restoredDirents.filter(item => item.depth === 1).map(item => item.path), sourceControlDecorations, assetDir, platform);
|
|
4751
4776
|
return {
|
|
@@ -5975,6 +6000,7 @@ const HandleButtonClick = 18;
|
|
|
5975
6000
|
const HandleClick = 1;
|
|
5976
6001
|
const HandleClickOpenFolder = 2;
|
|
5977
6002
|
const HandleContextMenu = 3;
|
|
6003
|
+
const HandleContextMenuWelcome = 20;
|
|
5978
6004
|
const HandleDragEnd = 19;
|
|
5979
6005
|
const HandleDragLeave = 4;
|
|
5980
6006
|
const HandleDragOver = 5;
|
|
@@ -5997,6 +6023,7 @@ const getExplorerWelcomeVirtualDom = (isWide, dropTargets) => {
|
|
|
5997
6023
|
return [{
|
|
5998
6024
|
childCount: 1,
|
|
5999
6025
|
className: getClassName$1(dropTargets),
|
|
6026
|
+
onContextMenu: HandleContextMenuWelcome,
|
|
6000
6027
|
onDragLeave: HandleDragLeave,
|
|
6001
6028
|
onDragOver: HandleDragOver,
|
|
6002
6029
|
onDrop: HandleDrop,
|
|
@@ -6488,6 +6515,10 @@ const renderEventListeners = () => {
|
|
|
6488
6515
|
name: HandleContextMenu,
|
|
6489
6516
|
params: ['handleContextMenu', Button$3, ClientX, ClientY],
|
|
6490
6517
|
preventDefault: true
|
|
6518
|
+
}, {
|
|
6519
|
+
name: HandleContextMenuWelcome,
|
|
6520
|
+
params: ['handleContextMenuWelcome'],
|
|
6521
|
+
preventDefault: true
|
|
6491
6522
|
}, {
|
|
6492
6523
|
name: HandleWheel,
|
|
6493
6524
|
params: ['handleWheel', DeltaMode, DeltaY],
|
|
@@ -6518,10 +6549,7 @@ const renderEventListeners = () => {
|
|
|
6518
6549
|
};
|
|
6519
6550
|
|
|
6520
6551
|
const hasProperty = (object, key) => {
|
|
6521
|
-
|
|
6522
|
-
return false;
|
|
6523
|
-
}
|
|
6524
|
-
return true;
|
|
6552
|
+
return !!object && typeof object === 'object' && key in object;
|
|
6525
6553
|
};
|
|
6526
6554
|
|
|
6527
6555
|
const getSavedMinLineY = savedState => {
|
|
@@ -6560,6 +6588,14 @@ const restoreState = savedState => {
|
|
|
6560
6588
|
};
|
|
6561
6589
|
};
|
|
6562
6590
|
|
|
6591
|
+
const isUriWithinRoot = (root, uri, pathSeparator) => {
|
|
6592
|
+
if (uri === root) {
|
|
6593
|
+
return true;
|
|
6594
|
+
}
|
|
6595
|
+
const rootWithSeparator = root.endsWith(pathSeparator) ? root : `${root}${pathSeparator}`;
|
|
6596
|
+
return uri.startsWith(rootWithSeparator);
|
|
6597
|
+
};
|
|
6598
|
+
|
|
6563
6599
|
const getPathPartsToReveal = (root, pathParts, dirents) => {
|
|
6564
6600
|
for (let i = 0; i < pathParts.length; i++) {
|
|
6565
6601
|
const pathPart = pathParts[i];
|
|
@@ -6644,8 +6680,13 @@ const revealItem = async (state, uri) => {
|
|
|
6644
6680
|
object(state);
|
|
6645
6681
|
string(uri);
|
|
6646
6682
|
const {
|
|
6647
|
-
items
|
|
6683
|
+
items,
|
|
6684
|
+
pathSeparator,
|
|
6685
|
+
root
|
|
6648
6686
|
} = state;
|
|
6687
|
+
if (!isUriWithinRoot(root, uri, pathSeparator)) {
|
|
6688
|
+
return state;
|
|
6689
|
+
}
|
|
6649
6690
|
const index = getIndex(items, uri);
|
|
6650
6691
|
if (index === -1) {
|
|
6651
6692
|
return revealItemHidden(state, uri);
|
|
@@ -6849,6 +6890,7 @@ const commandMap = {
|
|
|
6849
6890
|
'Explorer.handleClickOpenFolder': wrapListItemCommand(handleClickOpenFolder),
|
|
6850
6891
|
'Explorer.handleContextMenu': wrapListItemCommand(handleContextMenu),
|
|
6851
6892
|
'Explorer.handleContextMenuKeyboard': wrapListItemCommand(handleContextMenuKeyboard),
|
|
6893
|
+
'Explorer.handleContextMenuWelcome': wrapListItemCommand(handleContextMenuWelcome),
|
|
6852
6894
|
'Explorer.handleCopy': wrapListItemCommand(handleCopy),
|
|
6853
6895
|
'Explorer.handleCut': wrapListItemCommand(handleCut),
|
|
6854
6896
|
'Explorer.handleDoubleClick': wrapListItemCommand(handleDoubleClick),
|
|
@@ -6885,6 +6927,7 @@ const commandMap = {
|
|
|
6885
6927
|
'Explorer.renderActions2': renderActions,
|
|
6886
6928
|
'Explorer.renderEventListeners': renderEventListeners,
|
|
6887
6929
|
'Explorer.restoreState': restoreState,
|
|
6930
|
+
'Explorer.reveal': wrapListItemCommand(revealItem),
|
|
6888
6931
|
'Explorer.revealItem': wrapListItemCommand(revealItem),
|
|
6889
6932
|
'Explorer.saveState': wrapGetter(saveState),
|
|
6890
6933
|
'Explorer.selectAll': wrapListItemCommand(selectAll),
|