@lvce-editor/explorer-view 6.11.0 → 6.13.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 +108 -135
- package/package.json +1 -1
|
@@ -189,7 +189,7 @@ class AssertionError extends Error {
|
|
|
189
189
|
const Object$1 = 1;
|
|
190
190
|
const Number$1 = 2;
|
|
191
191
|
const Array$1 = 3;
|
|
192
|
-
const String = 4;
|
|
192
|
+
const String$1 = 4;
|
|
193
193
|
const Boolean$1 = 5;
|
|
194
194
|
const Function = 6;
|
|
195
195
|
const Null = 7;
|
|
@@ -201,7 +201,7 @@ const getType = value => {
|
|
|
201
201
|
case 'function':
|
|
202
202
|
return Function;
|
|
203
203
|
case 'string':
|
|
204
|
-
return String;
|
|
204
|
+
return String$1;
|
|
205
205
|
case 'object':
|
|
206
206
|
if (value === null) {
|
|
207
207
|
return Null;
|
|
@@ -236,7 +236,7 @@ const array = value => {
|
|
|
236
236
|
};
|
|
237
237
|
const string = value => {
|
|
238
238
|
const type = getType(value);
|
|
239
|
-
if (type !== String) {
|
|
239
|
+
if (type !== String$1) {
|
|
240
240
|
throw new AssertionError('expected value to be of type string');
|
|
241
241
|
}
|
|
242
242
|
};
|
|
@@ -1436,8 +1436,8 @@ const applyFileOperations = async operations => {
|
|
|
1436
1436
|
}
|
|
1437
1437
|
return '';
|
|
1438
1438
|
} catch (error) {
|
|
1439
|
-
console.error(new VError(error,
|
|
1440
|
-
return
|
|
1439
|
+
console.error(new VError(error, 'Failed to apply file operations'));
|
|
1440
|
+
return String(error);
|
|
1441
1441
|
}
|
|
1442
1442
|
};
|
|
1443
1443
|
|
|
@@ -1981,7 +1981,7 @@ const validateFileName2 = (name, siblingFileNames = []) => {
|
|
|
1981
1981
|
}
|
|
1982
1982
|
|
|
1983
1983
|
// Disallow reserved directory names
|
|
1984
|
-
if (
|
|
1984
|
+
if (['.', '..', '...'].includes(name)) {
|
|
1985
1985
|
return theNameIsNotValid();
|
|
1986
1986
|
}
|
|
1987
1987
|
|
|
@@ -2065,7 +2065,7 @@ const computeExplorerRenamedDirentUpdate = (root, parentPath, oldUri, children,
|
|
|
2065
2065
|
update[relativeNewUri] = oldItems;
|
|
2066
2066
|
for (const [key, value] of Object.entries(tree)) {
|
|
2067
2067
|
if (key.startsWith(`${relativeOldPath}/`)) {
|
|
2068
|
-
const newKey =
|
|
2068
|
+
const newKey = relativeNewUri + key.slice(relativeOldPath.length);
|
|
2069
2069
|
update[newKey] = value;
|
|
2070
2070
|
}
|
|
2071
2071
|
}
|
|
@@ -2384,7 +2384,7 @@ const getPaths = items => {
|
|
|
2384
2384
|
};
|
|
2385
2385
|
|
|
2386
2386
|
const getSimpleIconRequestType = direntType => {
|
|
2387
|
-
if (
|
|
2387
|
+
if ([Directory, DirectoryExpanded, EditingDirectoryExpanded, EditingFolder].includes(direntType)) {
|
|
2388
2388
|
return 2;
|
|
2389
2389
|
}
|
|
2390
2390
|
return 1;
|
|
@@ -2625,12 +2625,12 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
|
2625
2625
|
};
|
|
2626
2626
|
|
|
2627
2627
|
const compareNodes = (oldNode, newNode) => {
|
|
2628
|
-
const patches = [];
|
|
2629
2628
|
// Check if node type changed - return null to signal incompatible nodes
|
|
2630
2629
|
// (caller should handle this with a Replace operation)
|
|
2631
2630
|
if (oldNode.type !== newNode.type) {
|
|
2632
2631
|
return null;
|
|
2633
2632
|
}
|
|
2633
|
+
const patches = [];
|
|
2634
2634
|
// Handle reference nodes - special handling for uid changes
|
|
2635
2635
|
if (oldNode.type === Reference) {
|
|
2636
2636
|
if (oldNode.uid !== newNode.uid) {
|
|
@@ -2666,7 +2666,7 @@ const compareNodes = (oldNode, newNode) => {
|
|
|
2666
2666
|
}
|
|
2667
2667
|
// Check for removed attributes
|
|
2668
2668
|
for (const key of oldKeys) {
|
|
2669
|
-
if (!(key
|
|
2669
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
2670
2670
|
patches.push({
|
|
2671
2671
|
type: RemoveAttribute,
|
|
2672
2672
|
key
|
|
@@ -2684,11 +2684,78 @@ const treeToArray = node => {
|
|
|
2684
2684
|
return result;
|
|
2685
2685
|
};
|
|
2686
2686
|
|
|
2687
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
2688
|
+
if (currentChildIndex === -1) {
|
|
2689
|
+
patches.push({
|
|
2690
|
+
type: NavigateChild,
|
|
2691
|
+
index
|
|
2692
|
+
});
|
|
2693
|
+
return index;
|
|
2694
|
+
}
|
|
2695
|
+
if (currentChildIndex !== index) {
|
|
2696
|
+
patches.push({
|
|
2697
|
+
type: NavigateSibling,
|
|
2698
|
+
index
|
|
2699
|
+
});
|
|
2700
|
+
}
|
|
2701
|
+
return index;
|
|
2702
|
+
};
|
|
2703
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
2704
|
+
if (currentChildIndex >= 0) {
|
|
2705
|
+
patches.push({
|
|
2706
|
+
type: NavigateParent
|
|
2707
|
+
});
|
|
2708
|
+
}
|
|
2709
|
+
return -1;
|
|
2710
|
+
};
|
|
2711
|
+
const addTree = (newNode, patches) => {
|
|
2712
|
+
patches.push({
|
|
2713
|
+
type: Add,
|
|
2714
|
+
nodes: treeToArray(newNode)
|
|
2715
|
+
});
|
|
2716
|
+
};
|
|
2717
|
+
const replaceTree = (newNode, patches) => {
|
|
2718
|
+
patches.push({
|
|
2719
|
+
type: Replace,
|
|
2720
|
+
nodes: treeToArray(newNode)
|
|
2721
|
+
});
|
|
2722
|
+
};
|
|
2723
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
2724
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2725
|
+
if (nodePatches === null) {
|
|
2726
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
2727
|
+
replaceTree(newNode, patches);
|
|
2728
|
+
return nextChildIndex;
|
|
2729
|
+
}
|
|
2730
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
2731
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
2732
|
+
return currentChildIndex;
|
|
2733
|
+
}
|
|
2734
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
2735
|
+
if (nodePatches.length > 0) {
|
|
2736
|
+
patches.push(...nodePatches);
|
|
2737
|
+
}
|
|
2738
|
+
if (hasChildrenToCompare) {
|
|
2739
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2740
|
+
}
|
|
2741
|
+
return nextChildIndex;
|
|
2742
|
+
};
|
|
2743
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
2744
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2745
|
+
if (nodePatches === null) {
|
|
2746
|
+
replaceTree(newNode, patches);
|
|
2747
|
+
return;
|
|
2748
|
+
}
|
|
2749
|
+
if (nodePatches.length > 0) {
|
|
2750
|
+
patches.push(...nodePatches);
|
|
2751
|
+
}
|
|
2752
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
2753
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2754
|
+
}
|
|
2755
|
+
};
|
|
2687
2756
|
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
2688
2757
|
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
2689
|
-
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
2690
2758
|
let currentChildIndex = -1;
|
|
2691
|
-
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
2692
2759
|
const indicesToRemove = [];
|
|
2693
2760
|
for (let i = 0; i < maxLength; i++) {
|
|
2694
2761
|
const oldNode = oldChildren[i];
|
|
@@ -2697,88 +2764,17 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
2697
2764
|
continue;
|
|
2698
2765
|
}
|
|
2699
2766
|
if (!oldNode) {
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
});
|
|
2706
|
-
currentChildIndex = -1;
|
|
2707
|
-
}
|
|
2708
|
-
// Flatten the entire subtree so renderInternal can handle it
|
|
2709
|
-
const flatNodes = treeToArray(newNode);
|
|
2710
|
-
patches.push({
|
|
2711
|
-
type: Add,
|
|
2712
|
-
nodes: flatNodes
|
|
2713
|
-
});
|
|
2714
|
-
} else if (newNode) {
|
|
2715
|
-
// Compare nodes to see if we need any patches
|
|
2716
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2717
|
-
// If nodePatches is null, the node types are incompatible - need to replace
|
|
2718
|
-
if (nodePatches === null) {
|
|
2719
|
-
// Navigate to this child
|
|
2720
|
-
if (currentChildIndex === -1) {
|
|
2721
|
-
patches.push({
|
|
2722
|
-
type: NavigateChild,
|
|
2723
|
-
index: i
|
|
2724
|
-
});
|
|
2725
|
-
currentChildIndex = i;
|
|
2726
|
-
} else if (currentChildIndex !== i) {
|
|
2727
|
-
patches.push({
|
|
2728
|
-
type: NavigateSibling,
|
|
2729
|
-
index: i
|
|
2730
|
-
});
|
|
2731
|
-
currentChildIndex = i;
|
|
2732
|
-
}
|
|
2733
|
-
// Replace the entire subtree
|
|
2734
|
-
const flatNodes = treeToArray(newNode);
|
|
2735
|
-
patches.push({
|
|
2736
|
-
type: Replace,
|
|
2737
|
-
nodes: flatNodes
|
|
2738
|
-
});
|
|
2739
|
-
// After replace, we're at the new element (same position)
|
|
2740
|
-
continue;
|
|
2741
|
-
}
|
|
2742
|
-
// Check if we need to recurse into children
|
|
2743
|
-
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
2744
|
-
// Only navigate to this element if we need to do something
|
|
2745
|
-
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
2746
|
-
// Navigate to this child if not already there
|
|
2747
|
-
if (currentChildIndex === -1) {
|
|
2748
|
-
patches.push({
|
|
2749
|
-
type: NavigateChild,
|
|
2750
|
-
index: i
|
|
2751
|
-
});
|
|
2752
|
-
currentChildIndex = i;
|
|
2753
|
-
} else if (currentChildIndex !== i) {
|
|
2754
|
-
patches.push({
|
|
2755
|
-
type: NavigateSibling,
|
|
2756
|
-
index: i
|
|
2757
|
-
});
|
|
2758
|
-
currentChildIndex = i;
|
|
2759
|
-
}
|
|
2760
|
-
// Apply node patches (these apply to the current element, not children)
|
|
2761
|
-
if (nodePatches.length > 0) {
|
|
2762
|
-
patches.push(...nodePatches);
|
|
2763
|
-
}
|
|
2764
|
-
// Compare children recursively
|
|
2765
|
-
if (hasChildrenToCompare) {
|
|
2766
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
2767
|
-
}
|
|
2768
|
-
}
|
|
2769
|
-
} else {
|
|
2770
|
-
// Remove old node - collect the index for later removal
|
|
2767
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
2768
|
+
addTree(newNode, patches);
|
|
2769
|
+
continue;
|
|
2770
|
+
}
|
|
2771
|
+
if (!newNode) {
|
|
2771
2772
|
indicesToRemove.push(i);
|
|
2773
|
+
continue;
|
|
2772
2774
|
}
|
|
2775
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
2773
2776
|
}
|
|
2774
|
-
|
|
2775
|
-
if (currentChildIndex >= 0) {
|
|
2776
|
-
patches.push({
|
|
2777
|
-
type: NavigateParent
|
|
2778
|
-
});
|
|
2779
|
-
}
|
|
2780
|
-
// Add remove patches in reverse order (highest index first)
|
|
2781
|
-
// This ensures indices remain valid as we remove
|
|
2777
|
+
navigateToParent(patches, currentChildIndex);
|
|
2782
2778
|
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
2783
2779
|
patches.push({
|
|
2784
2780
|
type: RemoveChild,
|
|
@@ -2787,33 +2783,11 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
2787
2783
|
}
|
|
2788
2784
|
};
|
|
2789
2785
|
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
2790
|
-
// At the root level (path.length === 0), we're already AT the element
|
|
2791
|
-
// So we compare the root node directly, then compare its children
|
|
2792
2786
|
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
// Compare root nodes
|
|
2796
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2797
|
-
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
2798
|
-
if (nodePatches === null) {
|
|
2799
|
-
const flatNodes = treeToArray(newNode);
|
|
2800
|
-
patches.push({
|
|
2801
|
-
type: Replace,
|
|
2802
|
-
nodes: flatNodes
|
|
2803
|
-
});
|
|
2804
|
-
return;
|
|
2805
|
-
}
|
|
2806
|
-
if (nodePatches.length > 0) {
|
|
2807
|
-
patches.push(...nodePatches);
|
|
2808
|
-
}
|
|
2809
|
-
// Compare children
|
|
2810
|
-
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
2811
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
2812
|
-
}
|
|
2813
|
-
} else {
|
|
2814
|
-
// Non-root level or multiple root elements - use the regular comparison
|
|
2815
|
-
diffChildren(oldTree, newTree, patches);
|
|
2787
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
2788
|
+
return;
|
|
2816
2789
|
}
|
|
2790
|
+
diffChildren(oldTree, newTree, patches);
|
|
2817
2791
|
};
|
|
2818
2792
|
|
|
2819
2793
|
const removeTrailingNavigationPatches = patches => {
|
|
@@ -2892,6 +2866,12 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
2892
2866
|
for (let i = minLineY; i < Math.min(maxLineY, items.length); i++) {
|
|
2893
2867
|
const item = items[i];
|
|
2894
2868
|
let chevron = getChevronType(item.type, useChevrons);
|
|
2869
|
+
const isEditing = i === editingIndex;
|
|
2870
|
+
let icon = icons[iconIndex++];
|
|
2871
|
+
if (isEditing) {
|
|
2872
|
+
icon = editingIcon;
|
|
2873
|
+
chevron = getEditingChevron(item.type);
|
|
2874
|
+
}
|
|
2895
2875
|
const isFocused = i === focusedIndex;
|
|
2896
2876
|
const id = isFocused ? 'TreeItemActive' : undefined;
|
|
2897
2877
|
const isSelected = item.selected;
|
|
@@ -2903,12 +2883,6 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
2903
2883
|
const className = getTreeItemClassName(isSelected, isFocused, isDropping, useChevrons, indent, decoration);
|
|
2904
2884
|
const expanded = getExpandedType(item.type);
|
|
2905
2885
|
const ariaExpanded = ariaExpandedValues[expanded];
|
|
2906
|
-
const isEditing = i === editingIndex;
|
|
2907
|
-
let icon = icons[iconIndex++];
|
|
2908
|
-
if (isEditing) {
|
|
2909
|
-
icon = editingIcon;
|
|
2910
|
-
chevron = getEditingChevron(item.type);
|
|
2911
|
-
}
|
|
2912
2886
|
visible.push({
|
|
2913
2887
|
...item,
|
|
2914
2888
|
ariaExpanded,
|
|
@@ -3845,7 +3819,7 @@ const OpenFolder = 'OpenFolder';
|
|
|
3845
3819
|
const Refresh$1 = 'Refresh';
|
|
3846
3820
|
|
|
3847
3821
|
const isFolder = direntType => {
|
|
3848
|
-
return
|
|
3822
|
+
return [Directory, DirectoryExpanded, SymLinkFolder].includes(direntType);
|
|
3849
3823
|
};
|
|
3850
3824
|
const getFittingIndex = (dirents, startIndex) => {
|
|
3851
3825
|
for (let i = startIndex; i >= 0; i--) {
|
|
@@ -4386,6 +4360,7 @@ const handleCopy = async state => {
|
|
|
4386
4360
|
await writeNativeFiles('copy', files);
|
|
4387
4361
|
return {
|
|
4388
4362
|
...state,
|
|
4363
|
+
cutItems: [],
|
|
4389
4364
|
pasteShouldMove: false
|
|
4390
4365
|
};
|
|
4391
4366
|
};
|
|
@@ -4874,11 +4849,7 @@ const getDroppedName = item => {
|
|
|
4874
4849
|
return item.name;
|
|
4875
4850
|
};
|
|
4876
4851
|
const getFileSystemHandlesNormalized = fileSystemHandles => {
|
|
4877
|
-
|
|
4878
|
-
for (const item of fileSystemHandles) {
|
|
4879
|
-
normalized.push(getFileSystemHandle(item));
|
|
4880
|
-
}
|
|
4881
|
-
return normalized;
|
|
4852
|
+
return Array.from(fileSystemHandles, getFileSystemHandle);
|
|
4882
4853
|
};
|
|
4883
4854
|
const uploadFileSystemHandles = async (root, pathSeparator, fileSystemHandles) => {
|
|
4884
4855
|
if (fileSystemHandles.length === 0) {
|
|
@@ -5258,7 +5229,7 @@ const isAscii = key => {
|
|
|
5258
5229
|
return RE_ASCII.test(key);
|
|
5259
5230
|
};
|
|
5260
5231
|
|
|
5261
|
-
|
|
5232
|
+
const typeAheadTimeout = {};
|
|
5262
5233
|
const handleKeyDown = (state, key) => {
|
|
5263
5234
|
const {
|
|
5264
5235
|
focusedIndex,
|
|
@@ -5275,10 +5246,10 @@ const handleKeyDown = (state, key) => {
|
|
|
5275
5246
|
const newFocusWord = focusWord + key.toLowerCase();
|
|
5276
5247
|
const itemNames = items.map(item => item.name);
|
|
5277
5248
|
const matchingIndex = filterByFocusWord(itemNames, focusedIndex, newFocusWord);
|
|
5278
|
-
if (
|
|
5279
|
-
clearTimeout(
|
|
5249
|
+
if (typeAheadTimeout.value) {
|
|
5250
|
+
clearTimeout(typeAheadTimeout.value);
|
|
5280
5251
|
}
|
|
5281
|
-
|
|
5252
|
+
typeAheadTimeout.value = setTimeout(async () => {
|
|
5282
5253
|
await invoke$2('Explorer.cancelTypeAhead');
|
|
5283
5254
|
}, focusWordTimeout);
|
|
5284
5255
|
if (matchingIndex === -1) {
|
|
@@ -5667,7 +5638,7 @@ const getContainingFolder = (root, dirents, focusedIndex, pathSeparator) => {
|
|
|
5667
5638
|
const dirent = dirents[focusedIndex];
|
|
5668
5639
|
const direntPath = dirent.path;
|
|
5669
5640
|
const direntParentPath = direntPath.slice(0, -(dirent.name.length + 1));
|
|
5670
|
-
const path =
|
|
5641
|
+
const path = direntParentPath;
|
|
5671
5642
|
return path;
|
|
5672
5643
|
};
|
|
5673
5644
|
|
|
@@ -5893,7 +5864,7 @@ const getDragLabel = urls => {
|
|
|
5893
5864
|
if (urls.length === 1) {
|
|
5894
5865
|
return getBaseName('/', urls[0]);
|
|
5895
5866
|
}
|
|
5896
|
-
return
|
|
5867
|
+
return String(urls.length);
|
|
5897
5868
|
};
|
|
5898
5869
|
|
|
5899
5870
|
const toUri = path => {
|
|
@@ -6709,6 +6680,8 @@ const saveState = state => {
|
|
|
6709
6680
|
};
|
|
6710
6681
|
};
|
|
6711
6682
|
|
|
6683
|
+
// TODO select all should only select all items in the current folder
|
|
6684
|
+
// and when calling it next item, expand selection to its parent folder
|
|
6712
6685
|
const selectAll = state => {
|
|
6713
6686
|
const {
|
|
6714
6687
|
items
|
|
@@ -6810,7 +6783,7 @@ const getEditingIcon = async (editingType, value, direntType) => {
|
|
|
6810
6783
|
name: value
|
|
6811
6784
|
});
|
|
6812
6785
|
}
|
|
6813
|
-
if (direntType
|
|
6786
|
+
if (direntType !== undefined && [Directory, EditingFolder, EditingDirectoryExpanded].includes(direntType)) {
|
|
6814
6787
|
return invoke$2('IconTheme.getFolderIcon', {
|
|
6815
6788
|
name: value
|
|
6816
6789
|
});
|