@lvce-editor/explorer-view 1.19.0 → 1.21.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 +206 -264
- package/package.json +1 -2
|
@@ -779,12 +779,12 @@ const invokeAndTransfer = (ipc, method, ...params) => {
|
|
|
779
779
|
return invokeHelper(ipc, method, params, true);
|
|
780
780
|
};
|
|
781
781
|
|
|
782
|
-
const commands = Object.create(null);
|
|
782
|
+
const commands$1 = Object.create(null);
|
|
783
783
|
const register = commandMap => {
|
|
784
|
-
Object.assign(commands, commandMap);
|
|
784
|
+
Object.assign(commands$1, commandMap);
|
|
785
785
|
};
|
|
786
786
|
const getCommand = key => {
|
|
787
|
-
return commands[key];
|
|
787
|
+
return commands$1[key];
|
|
788
788
|
};
|
|
789
789
|
const execute = (command, ...args) => {
|
|
790
790
|
const fn = getCommand(command);
|
|
@@ -1100,9 +1100,7 @@ const acceptCreate = async (state, newDirentType, createFn) => {
|
|
|
1100
1100
|
return state;
|
|
1101
1101
|
}
|
|
1102
1102
|
const parentDirent = focusedIndex >= 0 ? state.items[focusedIndex] : {
|
|
1103
|
-
depth: 0
|
|
1104
|
-
path: state.root
|
|
1105
|
-
};
|
|
1103
|
+
depth: 0};
|
|
1106
1104
|
const depth = parentDirent.depth + 1;
|
|
1107
1105
|
const newDirent = {
|
|
1108
1106
|
path: absolutePath,
|
|
@@ -1300,6 +1298,7 @@ const ListItem = 22;
|
|
|
1300
1298
|
|
|
1301
1299
|
const Slash = '/';
|
|
1302
1300
|
|
|
1301
|
+
// TODO parentUid might ot be needed
|
|
1303
1302
|
const create = (id, uri, x, y, width, height, args, parentUid) => {
|
|
1304
1303
|
const state = {
|
|
1305
1304
|
uid: id,
|
|
@@ -1852,6 +1851,11 @@ const getActions = root => {
|
|
|
1852
1851
|
}];
|
|
1853
1852
|
};
|
|
1854
1853
|
|
|
1854
|
+
const commands = ['acceptEdit', 'cancelEdit', 'collapseAll', 'copyPath', 'copyRelativePath', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleCopy', 'handleDragOver', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'refresh', 'relealItem', 'removeDirent', 'rename', 'renameDirent', 'revealItem', 'scrollDown', 'scrollUp', 'setDeltaY', 'updateEditingValue', 'updateIcons'];
|
|
1855
|
+
const getCommandIds = () => {
|
|
1856
|
+
return commands;
|
|
1857
|
+
};
|
|
1858
|
+
|
|
1855
1859
|
const None$4 = 'none';
|
|
1856
1860
|
const ToolBar = 'toolbar';
|
|
1857
1861
|
const Tree = 'tree';
|
|
@@ -2354,19 +2358,59 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
2354
2358
|
return visible;
|
|
2355
2359
|
};
|
|
2356
2360
|
|
|
2357
|
-
const
|
|
2358
|
-
|
|
2359
|
-
|
|
2361
|
+
const getParentStartIndex = (dirents, index) => {
|
|
2362
|
+
const dirent = dirents[index];
|
|
2363
|
+
let startIndex = index - 1;
|
|
2364
|
+
while (startIndex >= 0 && dirents[startIndex].depth >= dirent.depth) {
|
|
2365
|
+
startIndex--;
|
|
2366
|
+
}
|
|
2367
|
+
return startIndex;
|
|
2368
|
+
};
|
|
2369
|
+
|
|
2370
|
+
const focusParentFolder = state => {
|
|
2371
|
+
const parentStartIndex = getParentStartIndex(state.items, state.focusedIndex);
|
|
2372
|
+
if (parentStartIndex === -1) {
|
|
2373
|
+
return state;
|
|
2374
|
+
}
|
|
2375
|
+
return focusIndex(state, parentStartIndex);
|
|
2376
|
+
};
|
|
2377
|
+
|
|
2378
|
+
const handleArrowLeft = state => {
|
|
2360
2379
|
const {
|
|
2361
|
-
|
|
2380
|
+
items,
|
|
2381
|
+
focusedIndex
|
|
2362
2382
|
} = state;
|
|
2363
|
-
if (
|
|
2383
|
+
if (focusedIndex === -1) {
|
|
2364
2384
|
return state;
|
|
2365
2385
|
}
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2386
|
+
const dirent = items[focusedIndex];
|
|
2387
|
+
switch (dirent.type) {
|
|
2388
|
+
case Directory:
|
|
2389
|
+
case File:
|
|
2390
|
+
case SymLinkFile:
|
|
2391
|
+
return focusParentFolder(state);
|
|
2392
|
+
case DirectoryExpanded:
|
|
2393
|
+
// @ts-ignore
|
|
2394
|
+
return handleClickDirectoryExpanded(state, dirent, focusedIndex);
|
|
2395
|
+
default:
|
|
2396
|
+
// TODO handle expanding directory and cancel file system call to read child dirents
|
|
2397
|
+
return state;
|
|
2398
|
+
}
|
|
2399
|
+
};
|
|
2400
|
+
|
|
2401
|
+
const handleArrowRightDirectoryExpanded = (state, dirent) => {
|
|
2402
|
+
const {
|
|
2403
|
+
items,
|
|
2404
|
+
focusedIndex
|
|
2405
|
+
} = state;
|
|
2406
|
+
if (focusedIndex === items.length - 1) {
|
|
2407
|
+
return state;
|
|
2408
|
+
}
|
|
2409
|
+
const nextDirent = items[focusedIndex + 1];
|
|
2410
|
+
if (nextDirent.depth === dirent.depth + 1) {
|
|
2411
|
+
return focusIndex(state, focusedIndex + 1);
|
|
2412
|
+
}
|
|
2413
|
+
return state;
|
|
2370
2414
|
};
|
|
2371
2415
|
|
|
2372
2416
|
const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
@@ -2413,6 +2457,71 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
|
2413
2457
|
};
|
|
2414
2458
|
};
|
|
2415
2459
|
|
|
2460
|
+
const openUri = async (uri, focus) => {
|
|
2461
|
+
await invoke(/* Main.openAbsolutePath */'Main.openUri', /* absolutePath */uri, /* focus */focus);
|
|
2462
|
+
};
|
|
2463
|
+
|
|
2464
|
+
const handleClickFile = async (state, dirent, index, keepFocus = false) => {
|
|
2465
|
+
await openUri(dirent.path, !keepFocus);
|
|
2466
|
+
return {
|
|
2467
|
+
...state,
|
|
2468
|
+
focusedIndex: index,
|
|
2469
|
+
focused: keepFocus
|
|
2470
|
+
};
|
|
2471
|
+
};
|
|
2472
|
+
|
|
2473
|
+
const handleClickSymLink = async (state, dirent, index) => {
|
|
2474
|
+
const realPath = await getRealPath(dirent.path);
|
|
2475
|
+
const type = await stat(realPath);
|
|
2476
|
+
switch (type) {
|
|
2477
|
+
case File:
|
|
2478
|
+
return handleClickFile(state, dirent, index);
|
|
2479
|
+
default:
|
|
2480
|
+
throw new Error(`unsupported file type ${type}`);
|
|
2481
|
+
}
|
|
2482
|
+
};
|
|
2483
|
+
|
|
2484
|
+
const handleArrowRight = async state => {
|
|
2485
|
+
const {
|
|
2486
|
+
items,
|
|
2487
|
+
focusedIndex
|
|
2488
|
+
} = state;
|
|
2489
|
+
if (focusedIndex === -1) {
|
|
2490
|
+
return state;
|
|
2491
|
+
}
|
|
2492
|
+
const dirent = items[focusedIndex];
|
|
2493
|
+
switch (dirent.type) {
|
|
2494
|
+
case File:
|
|
2495
|
+
case SymLinkFile:
|
|
2496
|
+
return state;
|
|
2497
|
+
case Directory:
|
|
2498
|
+
case SymLinkFolder:
|
|
2499
|
+
// @ts-ignore
|
|
2500
|
+
return handleClickDirectory(state, dirent);
|
|
2501
|
+
case DirectoryExpanded:
|
|
2502
|
+
return handleArrowRightDirectoryExpanded(state, dirent);
|
|
2503
|
+
case Symlink:
|
|
2504
|
+
return handleClickSymLink(state, dirent, focusedIndex);
|
|
2505
|
+
default:
|
|
2506
|
+
throw new Error(`unsupported file type ${dirent.type}`);
|
|
2507
|
+
}
|
|
2508
|
+
};
|
|
2509
|
+
|
|
2510
|
+
const handleBlur = state => {
|
|
2511
|
+
// TODO when blur event occurs because of context menu, focused index should stay the same
|
|
2512
|
+
// but focus outline should be removed
|
|
2513
|
+
const {
|
|
2514
|
+
editingType
|
|
2515
|
+
} = state;
|
|
2516
|
+
if (editingType !== None$5) {
|
|
2517
|
+
return state;
|
|
2518
|
+
}
|
|
2519
|
+
return {
|
|
2520
|
+
...state,
|
|
2521
|
+
focused: false
|
|
2522
|
+
};
|
|
2523
|
+
};
|
|
2524
|
+
|
|
2416
2525
|
const handleClickDirectoryExpanded$1 = async (state, dirent, index, keepFocus) => {
|
|
2417
2526
|
const {
|
|
2418
2527
|
minLineY,
|
|
@@ -2479,30 +2588,6 @@ const handleClickDirectoryExpanding = async (state, dirent, index, keepFocus) =>
|
|
|
2479
2588
|
};
|
|
2480
2589
|
};
|
|
2481
2590
|
|
|
2482
|
-
const openUri = async (uri, focus) => {
|
|
2483
|
-
await invoke(/* Main.openAbsolutePath */'Main.openUri', /* absolutePath */uri, /* focus */focus);
|
|
2484
|
-
};
|
|
2485
|
-
|
|
2486
|
-
const handleClickFile$1 = async (state, dirent, index, keepFocus = false) => {
|
|
2487
|
-
await openUri(dirent.path, !keepFocus);
|
|
2488
|
-
return {
|
|
2489
|
-
...state,
|
|
2490
|
-
focusedIndex: index,
|
|
2491
|
-
focused: keepFocus
|
|
2492
|
-
};
|
|
2493
|
-
};
|
|
2494
|
-
|
|
2495
|
-
const handleClickSymLink$1 = async (state, dirent, index) => {
|
|
2496
|
-
const realPath = await getRealPath(dirent.path);
|
|
2497
|
-
const type = await stat(realPath);
|
|
2498
|
-
switch (type) {
|
|
2499
|
-
case File:
|
|
2500
|
-
return handleClickFile$1(state, dirent, index);
|
|
2501
|
-
default:
|
|
2502
|
-
throw new Error(`unsupported file type ${type}`);
|
|
2503
|
-
}
|
|
2504
|
-
};
|
|
2505
|
-
|
|
2506
2591
|
// TODO viewlet should only have create and refresh functions
|
|
2507
2592
|
// every thing else can be in a separate module <viewlet>.lazy.js
|
|
2508
2593
|
// and <viewlet>.ipc.js
|
|
@@ -2524,7 +2609,7 @@ const getClickFn = direntType => {
|
|
|
2524
2609
|
switch (direntType) {
|
|
2525
2610
|
case File:
|
|
2526
2611
|
case SymLinkFile:
|
|
2527
|
-
return handleClickFile
|
|
2612
|
+
return handleClickFile;
|
|
2528
2613
|
case Directory:
|
|
2529
2614
|
case SymLinkFolder:
|
|
2530
2615
|
return handleClickDirectory;
|
|
@@ -2533,7 +2618,7 @@ const getClickFn = direntType => {
|
|
|
2533
2618
|
case DirectoryExpanded:
|
|
2534
2619
|
return handleClickDirectoryExpanded$1;
|
|
2535
2620
|
case Symlink:
|
|
2536
|
-
return handleClickSymLink
|
|
2621
|
+
return handleClickSymLink;
|
|
2537
2622
|
case CharacterDevice:
|
|
2538
2623
|
throw new Error('Cannot open character device files');
|
|
2539
2624
|
case BlockDevice:
|
|
@@ -2545,34 +2630,6 @@ const getClickFn = direntType => {
|
|
|
2545
2630
|
}
|
|
2546
2631
|
};
|
|
2547
2632
|
|
|
2548
|
-
const getIndexFromPosition = (state, eventX, eventY) => {
|
|
2549
|
-
const {
|
|
2550
|
-
y,
|
|
2551
|
-
itemHeight,
|
|
2552
|
-
items
|
|
2553
|
-
} = state;
|
|
2554
|
-
const index = Math.floor((eventY - y) / itemHeight);
|
|
2555
|
-
if (index < 0) {
|
|
2556
|
-
return 0;
|
|
2557
|
-
}
|
|
2558
|
-
if (index >= items.length) {
|
|
2559
|
-
return -1;
|
|
2560
|
-
}
|
|
2561
|
-
return index;
|
|
2562
|
-
};
|
|
2563
|
-
|
|
2564
|
-
const getParentStartIndex = (dirents, index) => {
|
|
2565
|
-
const dirent = dirents[index];
|
|
2566
|
-
let startIndex = index - 1;
|
|
2567
|
-
while (startIndex >= 0 && dirents[startIndex].depth >= dirent.depth) {
|
|
2568
|
-
startIndex--;
|
|
2569
|
-
}
|
|
2570
|
-
return startIndex;
|
|
2571
|
-
};
|
|
2572
|
-
|
|
2573
|
-
const Keyboard = -1;
|
|
2574
|
-
const LeftClick = 0;
|
|
2575
|
-
|
|
2576
2633
|
// TODO viewlet should only have create and refresh functions
|
|
2577
2634
|
// every thing else can be in a separate module <viewlet>.lazy.js
|
|
2578
2635
|
// and <viewlet>.ipc.js
|
|
@@ -2583,81 +2640,11 @@ const LeftClick = 0;
|
|
|
2583
2640
|
// TODO instead of root string, there should be a root dirent
|
|
2584
2641
|
|
|
2585
2642
|
// TODO rename dirents to items, then can use virtual list component directly
|
|
2586
|
-
const setDeltaY$1 = (state, deltaY) => {
|
|
2587
|
-
const {
|
|
2588
|
-
itemHeight,
|
|
2589
|
-
height,
|
|
2590
|
-
items
|
|
2591
|
-
} = state;
|
|
2592
|
-
if (deltaY < 0) {
|
|
2593
|
-
deltaY = 0;
|
|
2594
|
-
} else if (deltaY > items.length * itemHeight - height) {
|
|
2595
|
-
deltaY = Math.max(items.length * itemHeight - height, 0);
|
|
2596
|
-
}
|
|
2597
|
-
if (state.deltaY === deltaY) {
|
|
2598
|
-
return state;
|
|
2599
|
-
}
|
|
2600
|
-
const minLineY = Math.round(deltaY / itemHeight);
|
|
2601
|
-
const maxLineY = minLineY + Math.round(height / itemHeight);
|
|
2602
|
-
return {
|
|
2603
|
-
...state,
|
|
2604
|
-
deltaY,
|
|
2605
|
-
minLineY,
|
|
2606
|
-
maxLineY
|
|
2607
|
-
};
|
|
2608
|
-
};
|
|
2609
|
-
const handleWheel = (state, deltaMode, deltaY) => {
|
|
2610
|
-
return setDeltaY$1(state, state.deltaY + deltaY);
|
|
2611
|
-
};
|
|
2612
2643
|
|
|
2613
2644
|
// TODO use posInSet and setSize properties to compute more effectively
|
|
2614
2645
|
|
|
2615
2646
|
// TODO much shared logic with newFolder
|
|
2616
2647
|
|
|
2617
|
-
const handleClickFile = async (state, dirent, index, keepFocus = false) => {
|
|
2618
|
-
// await Command.execute(/* Main.openAbsolutePath */ 'Main.openUri', /* absolutePath */ dirent.path, /* focus */ !keepFocus)
|
|
2619
|
-
return {
|
|
2620
|
-
...state,
|
|
2621
|
-
focusedIndex: index,
|
|
2622
|
-
focused: keepFocus
|
|
2623
|
-
};
|
|
2624
|
-
};
|
|
2625
|
-
const handleClickDirectoryExpanded = (state, dirent, index, keepFocus) => {
|
|
2626
|
-
const {
|
|
2627
|
-
minLineY,
|
|
2628
|
-
maxLineY,
|
|
2629
|
-
itemHeight
|
|
2630
|
-
} = state;
|
|
2631
|
-
dirent.type = Directory;
|
|
2632
|
-
dirent.icon = getIcon();
|
|
2633
|
-
const endIndex = getParentEndIndex(state.items, index);
|
|
2634
|
-
const removeCount = endIndex - index - 1;
|
|
2635
|
-
// TODO race conditions and side effects are everywhere
|
|
2636
|
-
const newDirents = [...state.items];
|
|
2637
|
-
newDirents.splice(index + 1, removeCount);
|
|
2638
|
-
const newTotal = newDirents.length;
|
|
2639
|
-
if (newTotal < maxLineY) {
|
|
2640
|
-
const visibleItems = Math.min(maxLineY - minLineY, newTotal);
|
|
2641
|
-
const newMaxLineY = Math.min(maxLineY, newTotal);
|
|
2642
|
-
const newMinLineY = newMaxLineY - visibleItems;
|
|
2643
|
-
const deltaY = newMinLineY * itemHeight;
|
|
2644
|
-
return {
|
|
2645
|
-
...state,
|
|
2646
|
-
items: newDirents,
|
|
2647
|
-
focusedIndex: index,
|
|
2648
|
-
focused: keepFocus,
|
|
2649
|
-
minLineY: newMinLineY,
|
|
2650
|
-
maxLineY: newMaxLineY,
|
|
2651
|
-
deltaY
|
|
2652
|
-
};
|
|
2653
|
-
}
|
|
2654
|
-
return {
|
|
2655
|
-
...state,
|
|
2656
|
-
items: newDirents,
|
|
2657
|
-
focusedIndex: index,
|
|
2658
|
-
focused: keepFocus
|
|
2659
|
-
};
|
|
2660
|
-
};
|
|
2661
2648
|
const handleClick = async (state, index, keepFocus = false) => {
|
|
2662
2649
|
const {
|
|
2663
2650
|
items,
|
|
@@ -2675,102 +2662,44 @@ const handleClick = async (state, index, keepFocus = false) => {
|
|
|
2675
2662
|
const clickFn = getClickFn(dirent.type);
|
|
2676
2663
|
return clickFn(state, dirent, actualIndex, keepFocus);
|
|
2677
2664
|
};
|
|
2678
|
-
const handleClickAt = (state, button, x, y) => {
|
|
2679
|
-
if (button !== LeftClick) {
|
|
2680
|
-
return state;
|
|
2681
|
-
}
|
|
2682
|
-
const index = getIndexFromPosition(state, x, y);
|
|
2683
|
-
return handleClick(state, index);
|
|
2684
|
-
};
|
|
2685
|
-
const handleClickCurrentButKeepFocus = state => {
|
|
2686
|
-
return handleClick(state, state.focusedIndex - state.minLineY, /* keepFocus */true);
|
|
2687
|
-
};
|
|
2688
2665
|
|
|
2689
2666
|
// export const handleBlur=()=>{}
|
|
2690
2667
|
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
default:
|
|
2698
|
-
throw new Error(`unsupported file type ${type}`);
|
|
2699
|
-
}
|
|
2700
|
-
};
|
|
2701
|
-
const handleArrowRightDirectoryExpanded = (state, dirent) => {
|
|
2702
|
-
const {
|
|
2703
|
-
items,
|
|
2704
|
-
focusedIndex
|
|
2705
|
-
} = state;
|
|
2706
|
-
if (focusedIndex === items.length - 1) {
|
|
2707
|
-
return state;
|
|
2708
|
-
}
|
|
2709
|
-
const nextDirent = items[focusedIndex + 1];
|
|
2710
|
-
if (nextDirent.depth === dirent.depth + 1) {
|
|
2711
|
-
return focusIndex(state, focusedIndex + 1);
|
|
2712
|
-
}
|
|
2713
|
-
return state;
|
|
2714
|
-
};
|
|
2715
|
-
const handleArrowRight = async state => {
|
|
2668
|
+
// TODO what happens when mouse leave and anther mouse enter event occur?
|
|
2669
|
+
// should update preview instead of closing and reopening
|
|
2670
|
+
|
|
2671
|
+
// TODO maybe just insert items into explorer and refresh whole explorer
|
|
2672
|
+
|
|
2673
|
+
const getIndexFromPosition = (state, eventX, eventY) => {
|
|
2716
2674
|
const {
|
|
2717
|
-
|
|
2718
|
-
|
|
2675
|
+
y,
|
|
2676
|
+
itemHeight,
|
|
2677
|
+
items
|
|
2719
2678
|
} = state;
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
const dirent = items[focusedIndex];
|
|
2724
|
-
switch (dirent.type) {
|
|
2725
|
-
case File:
|
|
2726
|
-
case SymLinkFile:
|
|
2727
|
-
return state;
|
|
2728
|
-
case Directory:
|
|
2729
|
-
case SymLinkFolder:
|
|
2730
|
-
// @ts-ignore
|
|
2731
|
-
return handleClickDirectory(state, dirent);
|
|
2732
|
-
case DirectoryExpanded:
|
|
2733
|
-
return handleArrowRightDirectoryExpanded(state, dirent);
|
|
2734
|
-
case Symlink:
|
|
2735
|
-
return handleClickSymLink(state, dirent, focusedIndex);
|
|
2736
|
-
default:
|
|
2737
|
-
throw new Error(`unsupported file type ${dirent.type}`);
|
|
2679
|
+
const index = Math.floor((eventY - y) / itemHeight);
|
|
2680
|
+
if (index < 0) {
|
|
2681
|
+
return 0;
|
|
2738
2682
|
}
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
const parentStartIndex = getParentStartIndex(state.items, state.focusedIndex);
|
|
2742
|
-
if (parentStartIndex === -1) {
|
|
2743
|
-
return state;
|
|
2683
|
+
if (index >= items.length) {
|
|
2684
|
+
return -1;
|
|
2744
2685
|
}
|
|
2745
|
-
return
|
|
2686
|
+
return index;
|
|
2746
2687
|
};
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
if (
|
|
2688
|
+
|
|
2689
|
+
const Keyboard = -1;
|
|
2690
|
+
const LeftClick = 0;
|
|
2691
|
+
|
|
2692
|
+
const handleClickAt = (state, button, x, y) => {
|
|
2693
|
+
if (button !== LeftClick) {
|
|
2753
2694
|
return state;
|
|
2754
2695
|
}
|
|
2755
|
-
const
|
|
2756
|
-
|
|
2757
|
-
case Directory:
|
|
2758
|
-
case File:
|
|
2759
|
-
case SymLinkFile:
|
|
2760
|
-
return focusParentFolder(state);
|
|
2761
|
-
case DirectoryExpanded:
|
|
2762
|
-
// @ts-ignore
|
|
2763
|
-
return handleClickDirectoryExpanded(state, dirent, focusedIndex);
|
|
2764
|
-
default:
|
|
2765
|
-
// TODO handle expanding directory and cancel file system call to read child dirents
|
|
2766
|
-
return state;
|
|
2767
|
-
}
|
|
2696
|
+
const index = getIndexFromPosition(state, x, y);
|
|
2697
|
+
return handleClick(state, index);
|
|
2768
2698
|
};
|
|
2769
2699
|
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
// TODO maybe just insert items into explorer and refresh whole explorer
|
|
2700
|
+
const handleClickCurrentButKeepFocus = state => {
|
|
2701
|
+
return handleClick(state, state.focusedIndex - state.minLineY, /* keepFocus */true);
|
|
2702
|
+
};
|
|
2774
2703
|
|
|
2775
2704
|
const openFolder = async () => {
|
|
2776
2705
|
// TODO
|
|
@@ -3238,27 +3167,51 @@ const handleUpload = async (state, dirents) => {
|
|
|
3238
3167
|
}
|
|
3239
3168
|
};
|
|
3240
3169
|
|
|
3170
|
+
const setDeltaY = (state, deltaY) => {
|
|
3171
|
+
const {
|
|
3172
|
+
itemHeight,
|
|
3173
|
+
height,
|
|
3174
|
+
items
|
|
3175
|
+
} = state;
|
|
3176
|
+
if (deltaY < 0) {
|
|
3177
|
+
deltaY = 0;
|
|
3178
|
+
} else if (deltaY > items.length * itemHeight - height) {
|
|
3179
|
+
deltaY = Math.max(items.length * itemHeight - height, 0);
|
|
3180
|
+
}
|
|
3181
|
+
if (state.deltaY === deltaY) {
|
|
3182
|
+
return state;
|
|
3183
|
+
}
|
|
3184
|
+
const minLineY = Math.round(deltaY / itemHeight);
|
|
3185
|
+
const maxLineY = minLineY + Math.round(height / itemHeight);
|
|
3186
|
+
return {
|
|
3187
|
+
...state,
|
|
3188
|
+
deltaY,
|
|
3189
|
+
minLineY,
|
|
3190
|
+
maxLineY
|
|
3191
|
+
};
|
|
3192
|
+
};
|
|
3193
|
+
|
|
3194
|
+
const handleWheel = (state, deltaMode, deltaY) => {
|
|
3195
|
+
return setDeltaY(state, state.deltaY + deltaY);
|
|
3196
|
+
};
|
|
3197
|
+
|
|
3241
3198
|
const getWorkspacePath = () => {
|
|
3242
3199
|
return invoke('Workspace.getPath');
|
|
3243
3200
|
};
|
|
3244
3201
|
|
|
3202
|
+
const getSettings = async () => {
|
|
3203
|
+
const useChevronsRaw = await invoke('Preferences.get', 'explorer.useChevrons');
|
|
3204
|
+
const useChevrons = useChevronsRaw === false ? false : true;
|
|
3205
|
+
return {
|
|
3206
|
+
useChevrons
|
|
3207
|
+
};
|
|
3208
|
+
};
|
|
3209
|
+
|
|
3245
3210
|
const EmptyString = '';
|
|
3246
3211
|
|
|
3247
3212
|
const Fulfilled = 'fulfilled';
|
|
3248
3213
|
const Rejected = 'rejected';
|
|
3249
3214
|
|
|
3250
|
-
// TODO viewlet should only have create and refresh functions
|
|
3251
|
-
// every thing else can be in a separate module <viewlet>.lazy.js
|
|
3252
|
-
// and <viewlet>.ipc.js
|
|
3253
|
-
|
|
3254
|
-
// viewlet: creating | refreshing | done | disposed
|
|
3255
|
-
// TODO recycle viewlets (maybe)
|
|
3256
|
-
|
|
3257
|
-
// TODO instead of root string, there should be a root dirent
|
|
3258
|
-
|
|
3259
|
-
const getPathSeparator = root => {
|
|
3260
|
-
return getPathSeparator$1(root);
|
|
3261
|
-
};
|
|
3262
3215
|
const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
|
|
3263
3216
|
const children = map[path];
|
|
3264
3217
|
if (!children) {
|
|
@@ -3347,6 +3300,19 @@ const restoreExpandedState = async (savedState, root, pathSeparator, excluded) =
|
|
|
3347
3300
|
const dirents = createDirents(root, expandedDirentPaths, expandedDirentChildren, excluded, pathSeparator);
|
|
3348
3301
|
return dirents;
|
|
3349
3302
|
};
|
|
3303
|
+
|
|
3304
|
+
// TODO viewlet should only have create and refresh functions
|
|
3305
|
+
// every thing else can be in a separate module <viewlet>.lazy.js
|
|
3306
|
+
// and <viewlet>.ipc.js
|
|
3307
|
+
|
|
3308
|
+
// viewlet: creating | refreshing | done | disposed
|
|
3309
|
+
// TODO recycle viewlets (maybe)
|
|
3310
|
+
|
|
3311
|
+
// TODO instead of root string, there should be a root dirent
|
|
3312
|
+
|
|
3313
|
+
const getPathSeparator = root => {
|
|
3314
|
+
return getPathSeparator$1(root);
|
|
3315
|
+
};
|
|
3350
3316
|
const getExcluded = () => {
|
|
3351
3317
|
const excludedObject = {};
|
|
3352
3318
|
const excluded = [];
|
|
@@ -3361,8 +3327,9 @@ const getSavedRoot$1 = (savedState, workspacePath) => {
|
|
|
3361
3327
|
return workspacePath;
|
|
3362
3328
|
};
|
|
3363
3329
|
const loadContent = async (state, savedState) => {
|
|
3364
|
-
const
|
|
3365
|
-
|
|
3330
|
+
const {
|
|
3331
|
+
useChevrons
|
|
3332
|
+
} = await getSettings();
|
|
3366
3333
|
const workspacePath = await getWorkspacePath();
|
|
3367
3334
|
const root = getSavedRoot$1(savedState, workspacePath);
|
|
3368
3335
|
// TODO path separator could be restored from saved state
|
|
@@ -3460,9 +3427,7 @@ const openContainingFolder = async state => {
|
|
|
3460
3427
|
const {
|
|
3461
3428
|
focusedIndex,
|
|
3462
3429
|
root,
|
|
3463
|
-
items
|
|
3464
|
-
pathSeparator
|
|
3465
|
-
} = state;
|
|
3430
|
+
items} = state;
|
|
3466
3431
|
const path = getContaingingFolder(root, items, focusedIndex);
|
|
3467
3432
|
await invoke('OpenNativeFolder.openNativeFolder', /* path */path);
|
|
3468
3433
|
return state;
|
|
@@ -3946,30 +3911,6 @@ const saveState = uid => {
|
|
|
3946
3911
|
};
|
|
3947
3912
|
};
|
|
3948
3913
|
|
|
3949
|
-
const setDeltaY = (state, deltaY) => {
|
|
3950
|
-
const {
|
|
3951
|
-
itemHeight,
|
|
3952
|
-
height,
|
|
3953
|
-
items
|
|
3954
|
-
} = state;
|
|
3955
|
-
if (deltaY < 0) {
|
|
3956
|
-
deltaY = 0;
|
|
3957
|
-
} else if (deltaY > items.length * itemHeight - height) {
|
|
3958
|
-
deltaY = Math.max(items.length * itemHeight - height, 0);
|
|
3959
|
-
}
|
|
3960
|
-
if (state.deltaY === deltaY) {
|
|
3961
|
-
return state;
|
|
3962
|
-
}
|
|
3963
|
-
const minLineY = Math.round(deltaY / itemHeight);
|
|
3964
|
-
const maxLineY = minLineY + Math.round(height / itemHeight);
|
|
3965
|
-
return {
|
|
3966
|
-
...state,
|
|
3967
|
-
deltaY,
|
|
3968
|
-
minLineY,
|
|
3969
|
-
maxLineY
|
|
3970
|
-
};
|
|
3971
|
-
};
|
|
3972
|
-
|
|
3973
3914
|
const terminate = () => {
|
|
3974
3915
|
globalThis.close();
|
|
3975
3916
|
};
|
|
@@ -4019,6 +3960,7 @@ const commandMap = {
|
|
|
4019
3960
|
'Explorer.getKeyBindings': wrapCommand(getKeyBindings),
|
|
4020
3961
|
'Explorer.getMenuEntries': wrapCommand(getMenuEntries),
|
|
4021
3962
|
'Explorer.getVirtualDom': wrapCommand(getExplorerVirtualDom),
|
|
3963
|
+
'Explorer.getCommandIds': getCommandIds,
|
|
4022
3964
|
'Explorer.getVisibleItems': wrapCommand(getVisibleExplorerItems),
|
|
4023
3965
|
'Explorer.handleArrowLeft': wrapCommand(handleArrowLeft),
|
|
4024
3966
|
'Explorer.handleArrowRight': wrapCommand(handleArrowRight),
|
package/package.json
CHANGED