@lvce-editor/text-search-worker 5.2.0 → 5.4.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/textSearchWorkerMain.js +201 -126
- package/package.json +1 -1
|
@@ -829,7 +829,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
829
829
|
}
|
|
830
830
|
};
|
|
831
831
|
};
|
|
832
|
-
const create$1$
|
|
832
|
+
const create$1$2 = (id, error) => {
|
|
833
833
|
return {
|
|
834
834
|
jsonrpc: Two,
|
|
835
835
|
id,
|
|
@@ -840,7 +840,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
840
840
|
const prettyError = preparePrettyError(error);
|
|
841
841
|
logError(error, prettyError);
|
|
842
842
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
843
|
-
return create$1$
|
|
843
|
+
return create$1$2(id, errorProperty);
|
|
844
844
|
};
|
|
845
845
|
const create$6 = (message, result) => {
|
|
846
846
|
return {
|
|
@@ -1081,9 +1081,39 @@ const create$2$1 = async ({
|
|
|
1081
1081
|
const rpc = createRpc(ipc);
|
|
1082
1082
|
return rpc;
|
|
1083
1083
|
};
|
|
1084
|
-
const
|
|
1084
|
+
const Https = 'https:';
|
|
1085
|
+
const Ws = 'ws:';
|
|
1086
|
+
const Wss = 'wss:';
|
|
1087
|
+
const getWebSocketProtocol = locationProtocol => {
|
|
1088
|
+
return locationProtocol === Https ? Wss : Ws;
|
|
1089
|
+
};
|
|
1090
|
+
const getWebSocketUrl = (type, host, locationProtocol) => {
|
|
1091
|
+
const wsProtocol = getWebSocketProtocol(locationProtocol);
|
|
1092
|
+
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
1093
|
+
};
|
|
1094
|
+
const getHost = () => {
|
|
1095
|
+
return location.host;
|
|
1096
|
+
};
|
|
1097
|
+
const getProtocol$1 = () => {
|
|
1098
|
+
return location.protocol;
|
|
1099
|
+
};
|
|
1100
|
+
const create$1$1 = async ({
|
|
1101
|
+
commandMap,
|
|
1102
|
+
type
|
|
1103
|
+
}) => {
|
|
1104
|
+
const host = getHost();
|
|
1105
|
+
const protocol = getProtocol$1();
|
|
1106
|
+
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1107
|
+
const webSocket = new WebSocket(wsUrl);
|
|
1108
|
+
const rpc = await create$2$1({
|
|
1109
|
+
webSocket,
|
|
1110
|
+
commandMap
|
|
1111
|
+
});
|
|
1112
|
+
return rpc;
|
|
1113
|
+
};
|
|
1114
|
+
const WebSocketRpcParent2 = {
|
|
1085
1115
|
__proto__: null,
|
|
1086
|
-
create: create$
|
|
1116
|
+
create: create$1$1
|
|
1087
1117
|
};
|
|
1088
1118
|
const create$4 = async ({
|
|
1089
1119
|
commandMap
|
|
@@ -1100,8 +1130,13 @@ const WebWorkerRpcClient = {
|
|
|
1100
1130
|
create: create$4
|
|
1101
1131
|
};
|
|
1102
1132
|
|
|
1133
|
+
const toCommandId = key => {
|
|
1134
|
+
const dotIndex = key.indexOf('.');
|
|
1135
|
+
return key.slice(dotIndex + 1);
|
|
1136
|
+
};
|
|
1103
1137
|
const create$3 = () => {
|
|
1104
1138
|
const states = Object.create(null);
|
|
1139
|
+
const commandMapRef = {};
|
|
1105
1140
|
return {
|
|
1106
1141
|
get(uid) {
|
|
1107
1142
|
return states[uid];
|
|
@@ -1142,6 +1177,15 @@ const create$3 = () => {
|
|
|
1142
1177
|
};
|
|
1143
1178
|
return wrapped;
|
|
1144
1179
|
},
|
|
1180
|
+
wrapGetter(fn) {
|
|
1181
|
+
const wrapped = (uid, ...args) => {
|
|
1182
|
+
const {
|
|
1183
|
+
newState
|
|
1184
|
+
} = states[uid];
|
|
1185
|
+
return fn(newState, ...args);
|
|
1186
|
+
};
|
|
1187
|
+
return wrapped;
|
|
1188
|
+
},
|
|
1145
1189
|
diff(uid, modules, numbers) {
|
|
1146
1190
|
const {
|
|
1147
1191
|
oldState,
|
|
@@ -1155,6 +1199,14 @@ const create$3 = () => {
|
|
|
1155
1199
|
}
|
|
1156
1200
|
}
|
|
1157
1201
|
return diffResult;
|
|
1202
|
+
},
|
|
1203
|
+
getCommandIds() {
|
|
1204
|
+
const keys = Object.keys(commandMapRef);
|
|
1205
|
+
const ids = keys.map(toCommandId);
|
|
1206
|
+
return ids;
|
|
1207
|
+
},
|
|
1208
|
+
registerCommands(commandMap) {
|
|
1209
|
+
Object.assign(commandMapRef, commandMap);
|
|
1158
1210
|
}
|
|
1159
1211
|
};
|
|
1160
1212
|
};
|
|
@@ -1418,7 +1470,9 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
1418
1470
|
historyIndex: -1,
|
|
1419
1471
|
viewMode: List$1,
|
|
1420
1472
|
incrementalSearch: false,
|
|
1421
|
-
searchId: ''
|
|
1473
|
+
searchId: '',
|
|
1474
|
+
useChevrons: true,
|
|
1475
|
+
useFileIcons: true
|
|
1422
1476
|
};
|
|
1423
1477
|
set(uid, state, state);
|
|
1424
1478
|
return state;
|
|
@@ -2098,7 +2152,7 @@ const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
|
|
|
2098
2152
|
};
|
|
2099
2153
|
|
|
2100
2154
|
const RE_PROTOCOL = /^([a-z-\d]+):\/\//;
|
|
2101
|
-
const getProtocol
|
|
2155
|
+
const getProtocol = uri => {
|
|
2102
2156
|
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
2103
2157
|
if (protocolMatch) {
|
|
2104
2158
|
return protocolMatch[1];
|
|
@@ -2125,7 +2179,7 @@ const getTextSearchResultCounts = results => {
|
|
|
2125
2179
|
};
|
|
2126
2180
|
};
|
|
2127
2181
|
|
|
2128
|
-
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
2182
|
+
const getScrollBarSize$1 = (size, contentSize, minimumSliderSize) => {
|
|
2129
2183
|
if (size >= contentSize) {
|
|
2130
2184
|
return 0;
|
|
2131
2185
|
}
|
|
@@ -2152,7 +2206,7 @@ const getTextSearchProvider = scheme => {
|
|
|
2152
2206
|
const textSearch$6 = async (root, query, options, assetDir, platform) => {
|
|
2153
2207
|
string(root);
|
|
2154
2208
|
string(query);
|
|
2155
|
-
const scheme = getProtocol
|
|
2209
|
+
const scheme = getProtocol(root);
|
|
2156
2210
|
const provider = getTextSearchProvider(scheme);
|
|
2157
2211
|
const results = await provider(scheme, root, query, options, assetDir, platform);
|
|
2158
2212
|
return results;
|
|
@@ -2177,7 +2231,7 @@ const handleUpdateFull = async (state, update) => {
|
|
|
2177
2231
|
platform
|
|
2178
2232
|
} = partialNewState;
|
|
2179
2233
|
const root = state.workspacePath;
|
|
2180
|
-
const scheme = getProtocol
|
|
2234
|
+
const scheme = getProtocol(root);
|
|
2181
2235
|
const results = await textSearch$6(root, value, {
|
|
2182
2236
|
threads,
|
|
2183
2237
|
isCaseSensitive: Boolean(flags & MatchCase$2),
|
|
@@ -2202,7 +2256,7 @@ const handleUpdateFull = async (state, update) => {
|
|
|
2202
2256
|
const total = results.length;
|
|
2203
2257
|
const contentHeight = total * itemHeight;
|
|
2204
2258
|
const listHeight = height - headerHeight;
|
|
2205
|
-
const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
|
|
2259
|
+
const scrollBarHeight = getScrollBarSize$1(height, contentHeight, minimumSliderSize);
|
|
2206
2260
|
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
2207
2261
|
const maxLineY = Math.min(numberOfVisible, total);
|
|
2208
2262
|
const finalDeltaY = Math.max(contentHeight - listHeight, 0);
|
|
@@ -2258,10 +2312,14 @@ const {
|
|
|
2258
2312
|
} = createLazyRpc(RpcId.SearchProcess);
|
|
2259
2313
|
|
|
2260
2314
|
const waitForNextFrame = async () => {
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2315
|
+
const {
|
|
2316
|
+
resolve,
|
|
2317
|
+
promise
|
|
2318
|
+
} = Promise.withResolvers();
|
|
2319
|
+
requestAnimationFrame(resolve);
|
|
2320
|
+
await promise;
|
|
2264
2321
|
};
|
|
2322
|
+
|
|
2265
2323
|
const textSearchIncremental = async (root, query, options, assetDir, platform, searchId, uid) => {
|
|
2266
2324
|
string(root);
|
|
2267
2325
|
string(query);
|
|
@@ -2324,7 +2382,7 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
2324
2382
|
platform
|
|
2325
2383
|
} = partialNewState;
|
|
2326
2384
|
const root = state.workspacePath;
|
|
2327
|
-
const scheme = getProtocol
|
|
2385
|
+
const scheme = getProtocol(root);
|
|
2328
2386
|
const searchId = crypto.randomUUID(); // TODO try to avoid side effect
|
|
2329
2387
|
const latest1 = get$1(uid);
|
|
2330
2388
|
const updatedState1 = {
|
|
@@ -2690,34 +2748,11 @@ const launchSearchProcessElectron = async () => {
|
|
|
2690
2748
|
return rpc;
|
|
2691
2749
|
};
|
|
2692
2750
|
|
|
2693
|
-
const Https = 'https:';
|
|
2694
|
-
const Ws = 'ws:';
|
|
2695
|
-
const Wss = 'wss:';
|
|
2696
|
-
|
|
2697
|
-
const getWebSocketProtocol = locationProtocol => {
|
|
2698
|
-
return locationProtocol === Https ? Wss : Ws;
|
|
2699
|
-
};
|
|
2700
|
-
|
|
2701
|
-
const getWebSocketUrl = (type, host, locationProtocol) => {
|
|
2702
|
-
const wsProtocol = getWebSocketProtocol(locationProtocol);
|
|
2703
|
-
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
2704
|
-
};
|
|
2705
|
-
|
|
2706
|
-
const getHost = () => {
|
|
2707
|
-
return location.host;
|
|
2708
|
-
};
|
|
2709
|
-
const getProtocol = () => {
|
|
2710
|
-
return location.protocol;
|
|
2711
|
-
};
|
|
2712
|
-
|
|
2713
2751
|
const launchSearchProcessNode = async () => {
|
|
2714
|
-
const
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
const rpc = await WebSocketRpcParent.create({
|
|
2719
|
-
webSocket,
|
|
2720
|
-
commandMap: {}
|
|
2752
|
+
const rpc = await WebSocketRpcParent2.create({
|
|
2753
|
+
commandMap: {},
|
|
2754
|
+
// @ts-ignore
|
|
2755
|
+
type: 'search-process'
|
|
2721
2756
|
});
|
|
2722
2757
|
return rpc;
|
|
2723
2758
|
};
|
|
@@ -2740,32 +2775,75 @@ const initialize = async platform => {
|
|
|
2740
2775
|
const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
2741
2776
|
return Math.ceil(listHeight / itemHeight) + 1;
|
|
2742
2777
|
};
|
|
2778
|
+
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
2779
|
+
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
2780
|
+
return scrollBarOffset;
|
|
2781
|
+
};
|
|
2782
|
+
const getScrollBarY = getScrollBarOffset;
|
|
2783
|
+
const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
2784
|
+
const halfScrollBarHeight = scrollBarHeight / 2;
|
|
2785
|
+
if (relativeY <= halfScrollBarHeight) {
|
|
2786
|
+
// clicked at top
|
|
2787
|
+
return {
|
|
2788
|
+
percent: 0,
|
|
2789
|
+
handleOffset: relativeY
|
|
2790
|
+
};
|
|
2791
|
+
}
|
|
2792
|
+
if (relativeY <= height - halfScrollBarHeight) {
|
|
2793
|
+
// clicked in middle
|
|
2794
|
+
return {
|
|
2795
|
+
percent: (relativeY - halfScrollBarHeight) / (height - scrollBarHeight),
|
|
2796
|
+
handleOffset: halfScrollBarHeight
|
|
2797
|
+
};
|
|
2798
|
+
}
|
|
2799
|
+
// clicked at bottom
|
|
2800
|
+
return {
|
|
2801
|
+
percent: 1,
|
|
2802
|
+
handleOffset: scrollBarHeight - height + relativeY
|
|
2803
|
+
};
|
|
2804
|
+
};
|
|
2743
2805
|
const focusIndexScrollDown = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
2806
|
+
const {
|
|
2807
|
+
finalDeltaY,
|
|
2808
|
+
height,
|
|
2809
|
+
headerHeight,
|
|
2810
|
+
scrollBarHeight
|
|
2811
|
+
} = state;
|
|
2744
2812
|
const newMaxLineY = Math.min(index + 1, itemsLength);
|
|
2745
2813
|
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
2746
2814
|
const newMinLineY = Math.max(newMaxLineY - fittingItems, 0);
|
|
2747
2815
|
const newDeltaY = itemsLength < fittingItems ? 0 : newMinLineY * itemHeight - listHeight % itemHeight + itemHeight;
|
|
2816
|
+
const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
2748
2817
|
return {
|
|
2749
2818
|
...state,
|
|
2750
2819
|
focusedIndex: index,
|
|
2751
2820
|
minLineY: newMinLineY,
|
|
2752
2821
|
maxLineY: newMaxLineY,
|
|
2753
2822
|
focused: true,
|
|
2754
|
-
deltaY: newDeltaY
|
|
2823
|
+
deltaY: newDeltaY,
|
|
2824
|
+
scrollBarY
|
|
2755
2825
|
};
|
|
2756
2826
|
};
|
|
2757
2827
|
const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
2828
|
+
const {
|
|
2829
|
+
finalDeltaY,
|
|
2830
|
+
height,
|
|
2831
|
+
headerHeight,
|
|
2832
|
+
scrollBarHeight
|
|
2833
|
+
} = state;
|
|
2758
2834
|
const newMinLineY = index;
|
|
2759
2835
|
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
2760
2836
|
const newMaxLineY = Math.min(newMinLineY + fittingItems, itemsLength);
|
|
2761
2837
|
const newDeltaY = newMinLineY * itemHeight;
|
|
2838
|
+
const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
2762
2839
|
return {
|
|
2763
2840
|
...state,
|
|
2764
2841
|
focusedIndex: index,
|
|
2765
2842
|
minLineY: newMinLineY,
|
|
2766
2843
|
maxLineY: newMaxLineY,
|
|
2767
2844
|
focused: true,
|
|
2768
|
-
deltaY: newDeltaY
|
|
2845
|
+
deltaY: newDeltaY,
|
|
2846
|
+
scrollBarY
|
|
2769
2847
|
};
|
|
2770
2848
|
};
|
|
2771
2849
|
const focusIndex = (state, index) => {
|
|
@@ -2884,36 +2962,15 @@ const handleScrollBarCaptureLost = state => {
|
|
|
2884
2962
|
scrollBarActive: false
|
|
2885
2963
|
};
|
|
2886
2964
|
};
|
|
2887
|
-
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
2888
|
-
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
2889
|
-
return scrollBarOffset;
|
|
2890
|
-
};
|
|
2891
|
-
const getScrollBarY = getScrollBarOffset;
|
|
2892
|
-
const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
2893
|
-
const halfScrollBarHeight = scrollBarHeight / 2;
|
|
2894
|
-
if (relativeY <= halfScrollBarHeight) {
|
|
2895
|
-
// clicked at top
|
|
2896
|
-
return {
|
|
2897
|
-
percent: 0,
|
|
2898
|
-
handleOffset: relativeY
|
|
2899
|
-
};
|
|
2900
|
-
}
|
|
2901
|
-
if (relativeY <= height - halfScrollBarHeight) {
|
|
2902
|
-
// clicked in middle
|
|
2903
|
-
return {
|
|
2904
|
-
percent: (relativeY - halfScrollBarHeight) / (height - scrollBarHeight),
|
|
2905
|
-
handleOffset: halfScrollBarHeight
|
|
2906
|
-
};
|
|
2907
|
-
}
|
|
2908
|
-
// clicked at bottom
|
|
2909
|
-
return {
|
|
2910
|
-
percent: 1,
|
|
2911
|
-
handleOffset: scrollBarHeight - height + relativeY
|
|
2912
|
-
};
|
|
2913
|
-
};
|
|
2914
2965
|
const clamp = (num, min, max) => {
|
|
2915
2966
|
return Math.min(Math.max(num, min), max);
|
|
2916
2967
|
};
|
|
2968
|
+
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
2969
|
+
if (size >= contentSize) {
|
|
2970
|
+
return 0;
|
|
2971
|
+
}
|
|
2972
|
+
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
2973
|
+
};
|
|
2917
2974
|
const setDeltaY = (state, value) => {
|
|
2918
2975
|
object(state);
|
|
2919
2976
|
number(value);
|
|
@@ -2923,7 +2980,8 @@ const setDeltaY = (state, value) => {
|
|
|
2923
2980
|
deltaY,
|
|
2924
2981
|
height,
|
|
2925
2982
|
headerHeight,
|
|
2926
|
-
items
|
|
2983
|
+
items,
|
|
2984
|
+
minimumSliderSize
|
|
2927
2985
|
} = state;
|
|
2928
2986
|
const listHeight = height - headerHeight;
|
|
2929
2987
|
const newDeltaY = clamp(value, 0, finalDeltaY);
|
|
@@ -2933,13 +2991,18 @@ const setDeltaY = (state, value) => {
|
|
|
2933
2991
|
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
2934
2992
|
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
2935
2993
|
const maxLineY = Math.min(minLineY + getNumberOfVisibleItems(listHeight, itemHeight), items.length);
|
|
2936
|
-
|
|
2937
2994
|
// TODO update icons
|
|
2995
|
+
|
|
2996
|
+
const total = items.length;
|
|
2997
|
+
const contentHeight = total * itemHeight;
|
|
2998
|
+
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
|
|
2999
|
+
const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
2938
3000
|
return {
|
|
2939
3001
|
...state,
|
|
2940
3002
|
deltaY: newDeltaY,
|
|
2941
3003
|
minLineY,
|
|
2942
|
-
maxLineY
|
|
3004
|
+
maxLineY,
|
|
3005
|
+
scrollBarY
|
|
2943
3006
|
};
|
|
2944
3007
|
};
|
|
2945
3008
|
const handleScrollBarClick = (state, eventY) => {
|
|
@@ -3356,18 +3419,6 @@ const getMatchCount = (results, startIndex) => {
|
|
|
3356
3419
|
return results.length - startIndex - 1;
|
|
3357
3420
|
};
|
|
3358
3421
|
|
|
3359
|
-
const getChildCount = (expanded, matchCount) => {
|
|
3360
|
-
let childCount = 1;
|
|
3361
|
-
if (expanded === Expanded || expanded === Collapsed) {
|
|
3362
|
-
childCount += 2;
|
|
3363
|
-
}
|
|
3364
|
-
if (matchCount) {
|
|
3365
|
-
childCount++;
|
|
3366
|
-
}
|
|
3367
|
-
childCount++;
|
|
3368
|
-
return childCount;
|
|
3369
|
-
};
|
|
3370
|
-
|
|
3371
3422
|
const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, originalResults) => {
|
|
3372
3423
|
const path = text;
|
|
3373
3424
|
const absolutePath = getRelativePath(path);
|
|
@@ -3375,11 +3426,9 @@ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPat
|
|
|
3375
3426
|
const index = originalResults.indexOf(results[i]);
|
|
3376
3427
|
const matchCount = getMatchCount(results, index);
|
|
3377
3428
|
const expanded = collapsedPaths.includes(path) ? Collapsed : Expanded;
|
|
3378
|
-
const childCount = getChildCount(expanded, matchCount);
|
|
3379
3429
|
const badgeText = `${matchCount}`;
|
|
3380
3430
|
return {
|
|
3381
3431
|
badgeText,
|
|
3382
|
-
childCount,
|
|
3383
3432
|
depth: 0,
|
|
3384
3433
|
expanded,
|
|
3385
3434
|
focused,
|
|
@@ -3397,7 +3446,6 @@ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPat
|
|
|
3397
3446
|
const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, posInSet, start, focused) => {
|
|
3398
3447
|
return {
|
|
3399
3448
|
badgeText: '',
|
|
3400
|
-
childCount: getChildCount(None$1, 0),
|
|
3401
3449
|
depth: 1,
|
|
3402
3450
|
expanded: None$1,
|
|
3403
3451
|
focused,
|
|
@@ -3408,7 +3456,7 @@ const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, pos
|
|
|
3408
3456
|
replacement,
|
|
3409
3457
|
setSize,
|
|
3410
3458
|
text: text,
|
|
3411
|
-
title: text
|
|
3459
|
+
title: text.trim()
|
|
3412
3460
|
};
|
|
3413
3461
|
};
|
|
3414
3462
|
|
|
@@ -3603,8 +3651,7 @@ const ClassNames = {
|
|
|
3603
3651
|
TreeItems: TreeItems$1,
|
|
3604
3652
|
Viewlet,
|
|
3605
3653
|
ViewletSearchMessage,
|
|
3606
|
-
ViewletSearchMessageIndented
|
|
3607
|
-
};
|
|
3654
|
+
ViewletSearchMessageIndented};
|
|
3608
3655
|
const mergeClassNames = (...classNames) => {
|
|
3609
3656
|
return classNames.filter(Boolean).join(' ');
|
|
3610
3657
|
};
|
|
@@ -3626,8 +3673,14 @@ const VirtualDomElements = {
|
|
|
3626
3673
|
Img,
|
|
3627
3674
|
Ins,
|
|
3628
3675
|
Span,
|
|
3629
|
-
Text,
|
|
3630
3676
|
TextArea};
|
|
3677
|
+
const text = data => {
|
|
3678
|
+
return {
|
|
3679
|
+
type: Text,
|
|
3680
|
+
text: data,
|
|
3681
|
+
childCount: 0
|
|
3682
|
+
};
|
|
3683
|
+
};
|
|
3631
3684
|
const SetText = 1;
|
|
3632
3685
|
const SetAttribute = 3;
|
|
3633
3686
|
const RemoveAttribute = 4;
|
|
@@ -3883,14 +3936,6 @@ const getSearchDetailsToggleVirtualDom = () => {
|
|
|
3883
3936
|
}];
|
|
3884
3937
|
};
|
|
3885
3938
|
|
|
3886
|
-
const text = data => {
|
|
3887
|
-
return {
|
|
3888
|
-
type: VirtualDomElements.Text,
|
|
3889
|
-
text: data,
|
|
3890
|
-
childCount: 0
|
|
3891
|
-
};
|
|
3892
|
-
};
|
|
3893
|
-
|
|
3894
3939
|
const getClassName = indented => {
|
|
3895
3940
|
if (indented) {
|
|
3896
3941
|
return mergeClassNames(ClassNames.ViewletSearchMessage, ClassNames.ViewletSearchMessageIndented);
|
|
@@ -4250,15 +4295,16 @@ const getAriaExpanded = expanded => {
|
|
|
4250
4295
|
}
|
|
4251
4296
|
};
|
|
4252
4297
|
|
|
4253
|
-
const
|
|
4298
|
+
const badge = {
|
|
4299
|
+
type: VirtualDomElements.Div,
|
|
4300
|
+
className: mergeClassNames(ClassNames.Badge, ClassNames.SourceControlBadge),
|
|
4301
|
+
childCount: 1
|
|
4302
|
+
};
|
|
4303
|
+
const getBadgeVirtualDom = badgeText => {
|
|
4254
4304
|
if (!badgeText) {
|
|
4255
4305
|
return [];
|
|
4256
4306
|
}
|
|
4257
|
-
return [
|
|
4258
|
-
type: VirtualDomElements.Div,
|
|
4259
|
-
className: mergeClassNames(ClassNames.Badge, className),
|
|
4260
|
-
childCount: 1
|
|
4261
|
-
}, text(badgeText)];
|
|
4307
|
+
return [badge, text(badgeText)];
|
|
4262
4308
|
};
|
|
4263
4309
|
|
|
4264
4310
|
const chevronDownVirtualDom = {
|
|
@@ -4272,6 +4318,17 @@ const chevronRightVirtualDom = {
|
|
|
4272
4318
|
childCount: 0
|
|
4273
4319
|
};
|
|
4274
4320
|
|
|
4321
|
+
const getChevronVirtualDom = expanded => {
|
|
4322
|
+
switch (expanded) {
|
|
4323
|
+
case Expanded:
|
|
4324
|
+
return [chevronDownVirtualDom];
|
|
4325
|
+
case Collapsed:
|
|
4326
|
+
return [chevronRightVirtualDom];
|
|
4327
|
+
default:
|
|
4328
|
+
return [];
|
|
4329
|
+
}
|
|
4330
|
+
};
|
|
4331
|
+
|
|
4275
4332
|
const getFileIconVirtualDom = icon => {
|
|
4276
4333
|
return {
|
|
4277
4334
|
type: VirtualDomElements.Img,
|
|
@@ -4282,15 +4339,11 @@ const getFileIconVirtualDom = icon => {
|
|
|
4282
4339
|
};
|
|
4283
4340
|
};
|
|
4284
4341
|
|
|
4285
|
-
const getIconsVirtualDom =
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
return [chevronDownVirtualDom, getFileIconVirtualDom(icon)];
|
|
4289
|
-
case Collapsed:
|
|
4290
|
-
return [chevronRightVirtualDom, getFileIconVirtualDom(icon)];
|
|
4291
|
-
default:
|
|
4292
|
-
return [];
|
|
4342
|
+
const getIconsVirtualDom = icon => {
|
|
4343
|
+
if (icon) {
|
|
4344
|
+
return [getFileIconVirtualDom(icon)];
|
|
4293
4345
|
}
|
|
4346
|
+
return [];
|
|
4294
4347
|
};
|
|
4295
4348
|
|
|
4296
4349
|
const deleted = {
|
|
@@ -4338,6 +4391,36 @@ const getPaddingLeft = depth => {
|
|
|
4338
4391
|
return `${Number(depth) + 1}rem`; // TODO use classname and dynamic css
|
|
4339
4392
|
};
|
|
4340
4393
|
|
|
4394
|
+
const getChildCount = (icon, expanded, badgeText) => {
|
|
4395
|
+
let childCount = 0;
|
|
4396
|
+
if (expanded) {
|
|
4397
|
+
childCount++; // chevron
|
|
4398
|
+
}
|
|
4399
|
+
if (icon) {
|
|
4400
|
+
childCount++; // file icon
|
|
4401
|
+
}
|
|
4402
|
+
childCount++; // label
|
|
4403
|
+
if (badgeText) {
|
|
4404
|
+
childCount++; // badge
|
|
4405
|
+
}
|
|
4406
|
+
childCount++; // remove button
|
|
4407
|
+
return childCount;
|
|
4408
|
+
};
|
|
4409
|
+
|
|
4410
|
+
const getSearchRemoveVirtualDom = () => {
|
|
4411
|
+
// TODO add title/aria label
|
|
4412
|
+
const dom = [{
|
|
4413
|
+
type: VirtualDomElements.Div,
|
|
4414
|
+
className: ClassNames.SearchRemove,
|
|
4415
|
+
childCount: 1
|
|
4416
|
+
}, {
|
|
4417
|
+
type: VirtualDomElements.Div,
|
|
4418
|
+
className: ClassNames.CloseMaskIcon,
|
|
4419
|
+
childCount: 0
|
|
4420
|
+
}];
|
|
4421
|
+
return dom;
|
|
4422
|
+
};
|
|
4423
|
+
|
|
4341
4424
|
const getSearchResultClassName = focused => {
|
|
4342
4425
|
if (focused) {
|
|
4343
4426
|
return ClassNames.TreeItem + ' ' + ClassNames.TreeItemActive;
|
|
@@ -4360,9 +4443,9 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
4360
4443
|
replacement,
|
|
4361
4444
|
focused,
|
|
4362
4445
|
expanded,
|
|
4363
|
-
childCount,
|
|
4364
4446
|
badgeText
|
|
4365
4447
|
} = rowInfo;
|
|
4448
|
+
const childCount = getChildCount(icon, expanded, badgeText);
|
|
4366
4449
|
const dom = [{
|
|
4367
4450
|
type: VirtualDomElements.Div,
|
|
4368
4451
|
role: TreeItem,
|
|
@@ -4377,15 +4460,7 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
4377
4460
|
paddingLeft: getPaddingLeft(depth),
|
|
4378
4461
|
paddingRight: PaddingRight,
|
|
4379
4462
|
ariaExpanded: getAriaExpanded(expanded)
|
|
4380
|
-
}, ...
|
|
4381
|
-
type: VirtualDomElements.Div,
|
|
4382
|
-
className: ClassNames.SearchRemove,
|
|
4383
|
-
childCount: 1
|
|
4384
|
-
}, {
|
|
4385
|
-
type: VirtualDomElements.Div,
|
|
4386
|
-
className: ClassNames.CloseMaskIcon,
|
|
4387
|
-
childCount: 0
|
|
4388
|
-
}];
|
|
4463
|
+
}, ...getChevronVirtualDom(expanded), ...getIconsVirtualDom(icon), ...getLabelVirtualDom(displayText, matchLength, matchStart, replacement), ...getBadgeVirtualDom(badgeText), ...getSearchRemoveVirtualDom()];
|
|
4389
4464
|
return dom;
|
|
4390
4465
|
};
|
|
4391
4466
|
|
|
@@ -4405,13 +4480,13 @@ const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
|
|
|
4405
4480
|
};
|
|
4406
4481
|
|
|
4407
4482
|
const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight) => {
|
|
4408
|
-
const
|
|
4483
|
+
const childCount = scrollbarHeight === 0 ? 1 : 2;
|
|
4409
4484
|
return [{
|
|
4410
4485
|
type: VirtualDomElements.Div,
|
|
4411
4486
|
className: mergeClassNames(ClassNames.Viewlet, ClassNames.List, ClassNames.Tree, focusOutline ? ClassNames.FocusOutline : ClassNames.Empty),
|
|
4412
4487
|
role: Tree,
|
|
4413
4488
|
tabIndex: 0,
|
|
4414
|
-
childCount
|
|
4489
|
+
childCount
|
|
4415
4490
|
}, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
|
|
4416
4491
|
};
|
|
4417
4492
|
|