@lvce-editor/explorer-view 5.1.0 → 5.3.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 +60 -41
- package/package.json +1 -1
|
@@ -2340,6 +2340,25 @@ const None$4 = 0;
|
|
|
2340
2340
|
const Right = 1;
|
|
2341
2341
|
const Down = 2;
|
|
2342
2342
|
|
|
2343
|
+
const ensureUri = item => {
|
|
2344
|
+
if (item.startsWith('/')) {
|
|
2345
|
+
return `file://` + item;
|
|
2346
|
+
}
|
|
2347
|
+
return item;
|
|
2348
|
+
};
|
|
2349
|
+
const ensureUris = maybeUris => {
|
|
2350
|
+
return maybeUris.map(ensureUri);
|
|
2351
|
+
};
|
|
2352
|
+
|
|
2353
|
+
const createDecorationMap = decorations => {
|
|
2354
|
+
const map = Object.create(null);
|
|
2355
|
+
for (const decoration of decorations) {
|
|
2356
|
+
const uri = ensureUri(decoration.uri);
|
|
2357
|
+
map[uri] = decoration.decoration;
|
|
2358
|
+
}
|
|
2359
|
+
return map;
|
|
2360
|
+
};
|
|
2361
|
+
|
|
2343
2362
|
const getChevronType = (type, useChevrons) => {
|
|
2344
2363
|
if (!useChevrons) {
|
|
2345
2364
|
return None$4;
|
|
@@ -2430,7 +2449,7 @@ const text = data => {
|
|
|
2430
2449
|
};
|
|
2431
2450
|
};
|
|
2432
2451
|
|
|
2433
|
-
const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, indent) => {
|
|
2452
|
+
const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, indent, decoration) => {
|
|
2434
2453
|
let className = TreeItem$1;
|
|
2435
2454
|
className = mergeClassNames(className, `Indent-${indent}`);
|
|
2436
2455
|
if (isSelected || isFocused) {
|
|
@@ -2439,6 +2458,9 @@ const getTreeItemClassName = (isSelected, isFocused, isDropping, useChevrons, in
|
|
|
2439
2458
|
if (isDropping) {
|
|
2440
2459
|
className = mergeClassNames(className, 'DropTarget');
|
|
2441
2460
|
}
|
|
2461
|
+
if (decoration) {
|
|
2462
|
+
className = mergeClassNames(className, `decoration-${decoration}`);
|
|
2463
|
+
}
|
|
2442
2464
|
return className;
|
|
2443
2465
|
};
|
|
2444
2466
|
|
|
@@ -2470,7 +2492,8 @@ const getEditingChevron = direntType => {
|
|
|
2470
2492
|
return None$4;
|
|
2471
2493
|
}
|
|
2472
2494
|
};
|
|
2473
|
-
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris = []) => {
|
|
2495
|
+
const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editingIndex, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris = [], decorations) => {
|
|
2496
|
+
const decorationMap = createDecorationMap(decorations);
|
|
2474
2497
|
const visible = [];
|
|
2475
2498
|
const indentFn = useChevrons ? getTreeItemIndentWithChevron : getTreeItemIndent;
|
|
2476
2499
|
let iconIndex = 0;
|
|
@@ -2484,7 +2507,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
2484
2507
|
const isDropping = dropTargets.includes(i);
|
|
2485
2508
|
const isIgnored = sourceControlIgnoredUris.includes(item.path);
|
|
2486
2509
|
const indent = indentFn(item.depth, chevron);
|
|
2487
|
-
const
|
|
2510
|
+
const decoration = decorationMap[item.path] || '';
|
|
2511
|
+
const className = getTreeItemClassName(isSelected, isFocused, isDropping, useChevrons, indent, decoration);
|
|
2488
2512
|
const expanded = getExpandedType(item.type);
|
|
2489
2513
|
const ariaExpanded = ariaExpandedValues[expanded];
|
|
2490
2514
|
const isEditing = i === editingIndex;
|
|
@@ -2507,7 +2531,9 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
2507
2531
|
className,
|
|
2508
2532
|
isCut,
|
|
2509
2533
|
isIgnored,
|
|
2510
|
-
index: i
|
|
2534
|
+
index: i,
|
|
2535
|
+
// @ts-ignore
|
|
2536
|
+
decoration
|
|
2511
2537
|
});
|
|
2512
2538
|
}
|
|
2513
2539
|
return visible;
|
|
@@ -2539,12 +2565,13 @@ const wrapListItemCommand = fn => {
|
|
|
2539
2565
|
sourceControlIgnoredUris,
|
|
2540
2566
|
height,
|
|
2541
2567
|
itemHeight,
|
|
2542
|
-
fileIconCache
|
|
2568
|
+
fileIconCache,
|
|
2569
|
+
decorations
|
|
2543
2570
|
} = updatedState;
|
|
2544
2571
|
const intermediate = get(id);
|
|
2545
2572
|
set(id, intermediate.oldState, updatedState);
|
|
2546
2573
|
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, items.length);
|
|
2547
|
-
if (items === intermediate.newState.items && minLineY === intermediate.newState.minLineY && editingIcon === intermediate.newState.editingIcon && cutItems === intermediate.newState.cutItems && editingErrorMessage === intermediate.newState.editingErrorMessage && dropTargets === intermediate.newState.dropTargets && fileIconCache === intermediate.newState.fileIconCache) {
|
|
2574
|
+
if (items === intermediate.newState.items && minLineY === intermediate.newState.minLineY && editingIcon === intermediate.newState.editingIcon && cutItems === intermediate.newState.cutItems && editingErrorMessage === intermediate.newState.editingErrorMessage && dropTargets === intermediate.newState.dropTargets && fileIconCache === intermediate.newState.fileIconCache && decorations === intermediate.newState.decorations) {
|
|
2548
2575
|
return;
|
|
2549
2576
|
}
|
|
2550
2577
|
const visible = items.slice(minLineY, maxLineY);
|
|
@@ -2552,7 +2579,7 @@ const wrapListItemCommand = fn => {
|
|
|
2552
2579
|
icons,
|
|
2553
2580
|
newFileIconCache
|
|
2554
2581
|
} = await getFileIcons(visible, fileIconCache);
|
|
2555
|
-
const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris);
|
|
2582
|
+
const visibleExplorerItems = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems, sourceControlIgnoredUris, decorations);
|
|
2556
2583
|
const finalState = {
|
|
2557
2584
|
...updatedState,
|
|
2558
2585
|
visibleExplorerItems,
|
|
@@ -2622,7 +2649,9 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
2622
2649
|
errorMessageLeft: 0,
|
|
2623
2650
|
errorMessageTop: 0,
|
|
2624
2651
|
visibleExplorerItems: [],
|
|
2625
|
-
errorMessageWidth: 0
|
|
2652
|
+
errorMessageWidth: 0,
|
|
2653
|
+
decorations: [],
|
|
2654
|
+
sourceControlDecorations: false
|
|
2626
2655
|
};
|
|
2627
2656
|
set(state.uid, state, state);
|
|
2628
2657
|
return state;
|
|
@@ -4607,30 +4636,17 @@ const getWorkspacePath = () => {
|
|
|
4607
4636
|
return invoke$2('Workspace.getPath');
|
|
4608
4637
|
};
|
|
4609
4638
|
|
|
4610
|
-
const
|
|
4611
|
-
|
|
4612
|
-
const ensureUris = maybeUris => {
|
|
4613
|
-
const uris = [];
|
|
4614
|
-
for (const item of maybeUris) {
|
|
4615
|
-
if (item.startsWith('/')) {
|
|
4616
|
-
uris.push(`file://` + item);
|
|
4617
|
-
} else {
|
|
4618
|
-
uris.push(item);
|
|
4619
|
-
}
|
|
4620
|
-
}
|
|
4621
|
-
return uris;
|
|
4622
|
-
};
|
|
4623
|
-
const getFileDecorations = async (scheme, root, maybeUris) => {
|
|
4639
|
+
const getFileDecorations = async (scheme, root, maybeUris, decorationsEnabled) => {
|
|
4624
4640
|
try {
|
|
4625
|
-
if (!
|
|
4641
|
+
if (!decorationsEnabled) {
|
|
4626
4642
|
return [];
|
|
4627
4643
|
}
|
|
4628
4644
|
const providerIds = await invoke$1('SourceControl.getEnabledProviderIds', scheme, root);
|
|
4629
4645
|
if (providerIds.length === 0) {
|
|
4630
4646
|
return [];
|
|
4631
4647
|
}
|
|
4632
|
-
|
|
4633
|
-
|
|
4648
|
+
// TODO how to handle multiple providers?
|
|
4649
|
+
const providerId = providerIds.at(-1);
|
|
4634
4650
|
const uris = ensureUris(maybeUris);
|
|
4635
4651
|
const decorations = await invoke$1('SourceControl.getFileDecorations', providerId, uris);
|
|
4636
4652
|
return decorations;
|
|
@@ -4640,7 +4656,17 @@ const getFileDecorations = async (scheme, root, maybeUris) => {
|
|
|
4640
4656
|
}
|
|
4641
4657
|
};
|
|
4642
4658
|
|
|
4659
|
+
const RE_PROTOCOL = /^[a-z+]:\/\//;
|
|
4660
|
+
const getScheme = uri => {
|
|
4661
|
+
const match = uri.match(RE_PROTOCOL);
|
|
4662
|
+
if (!match) {
|
|
4663
|
+
return '';
|
|
4664
|
+
}
|
|
4665
|
+
return match[0];
|
|
4666
|
+
};
|
|
4667
|
+
|
|
4643
4668
|
const getSettings = async () => {
|
|
4669
|
+
// TODO don't return false always
|
|
4644
4670
|
// TODO get all settings at once
|
|
4645
4671
|
const useChevronsRaw = await invoke$2('Preferences.get', 'explorer.useChevrons');
|
|
4646
4672
|
const useChevrons = useChevronsRaw === false ? false : true;
|
|
@@ -4648,10 +4674,13 @@ const getSettings = async () => {
|
|
|
4648
4674
|
const confirmDelete = confirmDeleteRaw === false ? false : false;
|
|
4649
4675
|
const confirmPasteRaw = await invoke$2('Preferences.get', 'explorer.confirmpaste');
|
|
4650
4676
|
const confirmPaste = confirmPasteRaw === false ? false : false;
|
|
4677
|
+
const sourceControlDecorationsRaw = await invoke$2('Preferences.get', 'explorer.sourceControlDecorations');
|
|
4678
|
+
const sourceControlDecorations = sourceControlDecorationsRaw === false ? false : true;
|
|
4651
4679
|
return {
|
|
4652
4680
|
useChevrons,
|
|
4653
4681
|
confirmDelete,
|
|
4654
|
-
confirmPaste
|
|
4682
|
+
confirmPaste,
|
|
4683
|
+
sourceControlDecorations
|
|
4655
4684
|
};
|
|
4656
4685
|
};
|
|
4657
4686
|
|
|
@@ -4764,18 +4793,11 @@ const getExcluded = () => {
|
|
|
4764
4793
|
const getSavedRoot = (savedState, workspacePath) => {
|
|
4765
4794
|
return workspacePath;
|
|
4766
4795
|
};
|
|
4767
|
-
const RE_PROTOCOL = /^[a-z+]:\/\//;
|
|
4768
|
-
const getScheme = uri => {
|
|
4769
|
-
const match = uri.match(RE_PROTOCOL);
|
|
4770
|
-
if (!match) {
|
|
4771
|
-
return '';
|
|
4772
|
-
}
|
|
4773
|
-
return match[0];
|
|
4774
|
-
};
|
|
4775
4796
|
const loadContent = async (state, savedState) => {
|
|
4776
4797
|
const {
|
|
4777
4798
|
useChevrons,
|
|
4778
|
-
confirmDelete
|
|
4799
|
+
confirmDelete,
|
|
4800
|
+
sourceControlDecorations
|
|
4779
4801
|
} = await getSettings();
|
|
4780
4802
|
const workspacePath = await getWorkspacePath();
|
|
4781
4803
|
const root = getSavedRoot(savedState, workspacePath);
|
|
@@ -4792,10 +4814,11 @@ const loadContent = async (state, savedState) => {
|
|
|
4792
4814
|
deltaY = savedState.deltaY;
|
|
4793
4815
|
}
|
|
4794
4816
|
const scheme = getScheme(root);
|
|
4795
|
-
const decorations = await getFileDecorations(scheme, root, restoredDirents.filter(item => item.depth === 1).map(item => item.path));
|
|
4817
|
+
const decorations = await getFileDecorations(scheme, root, restoredDirents.filter(item => item.depth === 1).map(item => item.path), sourceControlDecorations);
|
|
4796
4818
|
return {
|
|
4797
4819
|
...state,
|
|
4798
4820
|
confirmDelete,
|
|
4821
|
+
decorations,
|
|
4799
4822
|
deltaY,
|
|
4800
4823
|
excluded,
|
|
4801
4824
|
items: restoredDirents,
|
|
@@ -4803,8 +4826,7 @@ const loadContent = async (state, savedState) => {
|
|
|
4803
4826
|
minLineY,
|
|
4804
4827
|
pathSeparator,
|
|
4805
4828
|
root,
|
|
4806
|
-
useChevrons
|
|
4807
|
-
decorations
|
|
4829
|
+
useChevrons
|
|
4808
4830
|
};
|
|
4809
4831
|
};
|
|
4810
4832
|
|
|
@@ -4877,9 +4899,6 @@ const createSourceControlWorkerRpc = async () => {
|
|
|
4877
4899
|
|
|
4878
4900
|
const initializeSourceControlWorker = async () => {
|
|
4879
4901
|
try {
|
|
4880
|
-
if (!DecorationsEnabled) {
|
|
4881
|
-
return;
|
|
4882
|
-
}
|
|
4883
4902
|
const rpc = await createSourceControlWorkerRpc();
|
|
4884
4903
|
// TODO
|
|
4885
4904
|
set$2(rpc);
|