@lvce-editor/explorer-view 6.8.0 → 6.11.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 +86 -72
- package/package.json +1 -1
|
@@ -1717,12 +1717,7 @@ const toDisplayDirent = (parentPath, parentDepth, rawDirentType, rawDirentName,
|
|
|
1717
1717
|
const toDisplayDirents = (pathSeparator, rawDirents, parentDirentPath, parentDirentDepth, excluded, expanded = false) => {
|
|
1718
1718
|
rawDirents = sortExplorerItems(rawDirents);
|
|
1719
1719
|
const result = [];
|
|
1720
|
-
const visibleItems = rawDirents.filter(item =>
|
|
1721
|
-
if (excluded.includes(item.name)) {
|
|
1722
|
-
return false;
|
|
1723
|
-
}
|
|
1724
|
-
return true;
|
|
1725
|
-
});
|
|
1720
|
+
const visibleItems = rawDirents.filter(item => !excluded.includes(item.name));
|
|
1726
1721
|
const count = visibleItems.length;
|
|
1727
1722
|
for (let i = 0; i < visibleItems.length; i++) {
|
|
1728
1723
|
const rawDirent = visibleItems[i];
|
|
@@ -2781,7 +2776,6 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
2781
2776
|
patches.push({
|
|
2782
2777
|
type: NavigateParent
|
|
2783
2778
|
});
|
|
2784
|
-
currentChildIndex = -1;
|
|
2785
2779
|
}
|
|
2786
2780
|
// Add remove patches in reverse order (highest index first)
|
|
2787
2781
|
// This ensures indices remain valid as we remove
|
|
@@ -4288,12 +4282,7 @@ const handleClickAt = async (state, defaultPrevented, button, ctrlKey, shiftKey,
|
|
|
4288
4282
|
}
|
|
4289
4283
|
const index = getIndexFromPosition(state, eventX, eventY);
|
|
4290
4284
|
if (index === -1 || index >= state.items.length) {
|
|
4291
|
-
return
|
|
4292
|
-
...state,
|
|
4293
|
-
focused: true,
|
|
4294
|
-
focusedIndex: -1
|
|
4295
|
-
// TODO mark all items as not selected
|
|
4296
|
-
};
|
|
4285
|
+
return focusIndex(state, -1);
|
|
4297
4286
|
}
|
|
4298
4287
|
if (shiftKey) {
|
|
4299
4288
|
return handleClickAtRangeSelection(state, index);
|
|
@@ -4534,6 +4523,34 @@ const isDirectoryHandle = fileHandle => {
|
|
|
4534
4523
|
return fileHandle.kind === 'directory';
|
|
4535
4524
|
};
|
|
4536
4525
|
|
|
4526
|
+
const getErrorCode = error => {
|
|
4527
|
+
if (error && typeof error === 'object' && 'code' in error && typeof error.code === 'string') {
|
|
4528
|
+
return error.code;
|
|
4529
|
+
}
|
|
4530
|
+
return '';
|
|
4531
|
+
};
|
|
4532
|
+
|
|
4533
|
+
const getErrorMessage = error => {
|
|
4534
|
+
if (error instanceof Error) {
|
|
4535
|
+
return error.message;
|
|
4536
|
+
}
|
|
4537
|
+
if (typeof error === 'string') {
|
|
4538
|
+
return error;
|
|
4539
|
+
}
|
|
4540
|
+
return 'Unknown error';
|
|
4541
|
+
};
|
|
4542
|
+
|
|
4543
|
+
const getExcluded = () => {
|
|
4544
|
+
const excludedObject = {};
|
|
4545
|
+
const excluded = [];
|
|
4546
|
+
for (const [key, value] of Object.entries(excludedObject)) {
|
|
4547
|
+
if (value) {
|
|
4548
|
+
excluded.push(key);
|
|
4549
|
+
}
|
|
4550
|
+
}
|
|
4551
|
+
return excluded;
|
|
4552
|
+
};
|
|
4553
|
+
|
|
4537
4554
|
const isValid = decoration => {
|
|
4538
4555
|
return decoration && typeof decoration.decoration === 'string' && typeof decoration.uri === 'string';
|
|
4539
4556
|
};
|
|
@@ -4565,6 +4582,37 @@ const getFileDecorations = async (scheme, root, maybeUris, decorationsEnabled, a
|
|
|
4565
4582
|
}
|
|
4566
4583
|
};
|
|
4567
4584
|
|
|
4585
|
+
const getFriendlyErrorMessage = (errorMessage, errorCode) => {
|
|
4586
|
+
switch (errorCode) {
|
|
4587
|
+
case 'EACCES':
|
|
4588
|
+
case 'EPERM':
|
|
4589
|
+
return 'permission was denied';
|
|
4590
|
+
case 'EBUSY':
|
|
4591
|
+
return 'the folder is currently in use';
|
|
4592
|
+
case 'ENOENT':
|
|
4593
|
+
return 'the folder does not exist';
|
|
4594
|
+
case 'ENOTDIR':
|
|
4595
|
+
return 'the path is not a folder';
|
|
4596
|
+
default:
|
|
4597
|
+
return errorMessage || 'an unexpected error occurred';
|
|
4598
|
+
}
|
|
4599
|
+
};
|
|
4600
|
+
|
|
4601
|
+
const getPathSeparator = async root => {
|
|
4602
|
+
return getPathSeparator$1(root);
|
|
4603
|
+
};
|
|
4604
|
+
|
|
4605
|
+
const getRestoredDeltaY = savedState => {
|
|
4606
|
+
if (savedState && typeof savedState.deltaY === 'number') {
|
|
4607
|
+
return savedState.deltaY;
|
|
4608
|
+
}
|
|
4609
|
+
return 0;
|
|
4610
|
+
};
|
|
4611
|
+
|
|
4612
|
+
const getSavedRoot = (savedState, workspacePath) => {
|
|
4613
|
+
return workspacePath;
|
|
4614
|
+
};
|
|
4615
|
+
|
|
4568
4616
|
const RE_PROTOCOL = /^[a-z+]:\/\//;
|
|
4569
4617
|
const getScheme = uri => {
|
|
4570
4618
|
const match = uri.match(RE_PROTOCOL);
|
|
@@ -4690,55 +4738,11 @@ const restoreExpandedState = async (savedState, root, pathSeparator, excluded) =
|
|
|
4690
4738
|
return dirents;
|
|
4691
4739
|
};
|
|
4692
4740
|
|
|
4693
|
-
const getPathSeparator = root => {
|
|
4694
|
-
return getPathSeparator$1(root);
|
|
4695
|
-
};
|
|
4696
|
-
const getExcluded = () => {
|
|
4697
|
-
const excludedObject = {};
|
|
4698
|
-
const excluded = [];
|
|
4699
|
-
for (const [key, value] of Object.entries(excludedObject)) {
|
|
4700
|
-
if (value) {
|
|
4701
|
-
excluded.push(key);
|
|
4702
|
-
}
|
|
4703
|
-
}
|
|
4704
|
-
return excluded;
|
|
4705
|
-
};
|
|
4706
|
-
const getSavedRoot = (savedState, workspacePath) => {
|
|
4707
|
-
return workspacePath;
|
|
4708
|
-
};
|
|
4709
|
-
const getErrorCode = error => {
|
|
4710
|
-
if (error && typeof error === 'object' && 'code' in error && typeof error.code === 'string') {
|
|
4711
|
-
return error.code;
|
|
4712
|
-
}
|
|
4713
|
-
return '';
|
|
4714
|
-
};
|
|
4715
|
-
const getErrorMessage = error => {
|
|
4716
|
-
if (error instanceof Error) {
|
|
4717
|
-
return error.message;
|
|
4718
|
-
}
|
|
4719
|
-
if (typeof error === 'string') {
|
|
4720
|
-
return error;
|
|
4721
|
-
}
|
|
4722
|
-
return 'Unknown error';
|
|
4723
|
-
};
|
|
4724
|
-
const getFriendlyErrorMessage = (errorMessage, errorCode) => {
|
|
4725
|
-
switch (errorCode) {
|
|
4726
|
-
case 'EACCES':
|
|
4727
|
-
case 'EPERM':
|
|
4728
|
-
return 'permission was denied';
|
|
4729
|
-
case 'EBUSY':
|
|
4730
|
-
return 'the folder is currently in use';
|
|
4731
|
-
case 'ENOENT':
|
|
4732
|
-
return 'the folder does not exist';
|
|
4733
|
-
case 'ENOTDIR':
|
|
4734
|
-
return 'the path is not a folder';
|
|
4735
|
-
default:
|
|
4736
|
-
return errorMessage || 'an unexpected error occurred';
|
|
4737
|
-
}
|
|
4738
|
-
};
|
|
4739
4741
|
const loadContent = async (state, savedState) => {
|
|
4740
4742
|
const {
|
|
4741
4743
|
assetDir,
|
|
4744
|
+
height,
|
|
4745
|
+
itemHeight,
|
|
4742
4746
|
platform
|
|
4743
4747
|
} = state;
|
|
4744
4748
|
const {
|
|
@@ -4753,14 +4757,10 @@ const loadContent = async (state, savedState) => {
|
|
|
4753
4757
|
const pathSeparator = await getPathSeparator(root); // TODO only load path separator once
|
|
4754
4758
|
const excluded = getExcluded();
|
|
4755
4759
|
const restoredDirents = await restoreExpandedState(savedState, root, pathSeparator, excluded);
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
let deltaY = 0;
|
|
4761
|
-
if (savedState && typeof savedState.deltaY === 'number') {
|
|
4762
|
-
deltaY = savedState.deltaY;
|
|
4763
|
-
}
|
|
4760
|
+
const rawDeltaY = getRestoredDeltaY(savedState);
|
|
4761
|
+
const maxDeltaY = Math.max(restoredDirents.length * itemHeight - height, 0);
|
|
4762
|
+
const deltaY = Math.min(Math.max(rawDeltaY, 0), maxDeltaY);
|
|
4763
|
+
const minLineY = Math.round(deltaY / itemHeight);
|
|
4764
4764
|
const scheme = getScheme(root);
|
|
4765
4765
|
const decorations = await getFileDecorations(scheme, root, restoredDirents.filter(item => item.depth === 1).map(item => item.path), sourceControlDecorations, assetDir, platform);
|
|
4766
4766
|
return {
|
|
@@ -5176,6 +5176,9 @@ const handleEscape = async state => {
|
|
|
5176
5176
|
};
|
|
5177
5177
|
|
|
5178
5178
|
const handleFocus = async state => {
|
|
5179
|
+
if (state.editingIndex !== -1) {
|
|
5180
|
+
return state;
|
|
5181
|
+
}
|
|
5179
5182
|
return {
|
|
5180
5183
|
...state,
|
|
5181
5184
|
focus: List
|
|
@@ -6539,10 +6542,7 @@ const renderEventListeners = () => {
|
|
|
6539
6542
|
};
|
|
6540
6543
|
|
|
6541
6544
|
const hasProperty = (object, key) => {
|
|
6542
|
-
|
|
6543
|
-
return false;
|
|
6544
|
-
}
|
|
6545
|
-
return true;
|
|
6545
|
+
return !!object && typeof object === 'object' && key in object;
|
|
6546
6546
|
};
|
|
6547
6547
|
|
|
6548
6548
|
const getSavedMinLineY = savedState => {
|
|
@@ -6581,6 +6581,14 @@ const restoreState = savedState => {
|
|
|
6581
6581
|
};
|
|
6582
6582
|
};
|
|
6583
6583
|
|
|
6584
|
+
const isUriWithinRoot = (root, uri, pathSeparator) => {
|
|
6585
|
+
if (uri === root) {
|
|
6586
|
+
return true;
|
|
6587
|
+
}
|
|
6588
|
+
const rootWithSeparator = root.endsWith(pathSeparator) ? root : `${root}${pathSeparator}`;
|
|
6589
|
+
return uri.startsWith(rootWithSeparator);
|
|
6590
|
+
};
|
|
6591
|
+
|
|
6584
6592
|
const getPathPartsToReveal = (root, pathParts, dirents) => {
|
|
6585
6593
|
for (let i = 0; i < pathParts.length; i++) {
|
|
6586
6594
|
const pathPart = pathParts[i];
|
|
@@ -6665,8 +6673,13 @@ const revealItem = async (state, uri) => {
|
|
|
6665
6673
|
object(state);
|
|
6666
6674
|
string(uri);
|
|
6667
6675
|
const {
|
|
6668
|
-
items
|
|
6676
|
+
items,
|
|
6677
|
+
pathSeparator,
|
|
6678
|
+
root
|
|
6669
6679
|
} = state;
|
|
6680
|
+
if (!isUriWithinRoot(root, uri, pathSeparator)) {
|
|
6681
|
+
return state;
|
|
6682
|
+
}
|
|
6670
6683
|
const index = getIndex(items, uri);
|
|
6671
6684
|
if (index === -1) {
|
|
6672
6685
|
return revealItemHidden(state, uri);
|
|
@@ -6907,6 +6920,7 @@ const commandMap = {
|
|
|
6907
6920
|
'Explorer.renderActions2': renderActions,
|
|
6908
6921
|
'Explorer.renderEventListeners': renderEventListeners,
|
|
6909
6922
|
'Explorer.restoreState': restoreState,
|
|
6923
|
+
'Explorer.reveal': wrapListItemCommand(revealItem),
|
|
6910
6924
|
'Explorer.revealItem': wrapListItemCommand(revealItem),
|
|
6911
6925
|
'Explorer.saveState': wrapGetter(saveState),
|
|
6912
6926
|
'Explorer.selectAll': wrapListItemCommand(selectAll),
|