@lvce-editor/text-search-worker 5.3.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 +88 -38
- package/package.json +1 -1
|
@@ -1098,11 +1098,12 @@ const getProtocol$1 = () => {
|
|
|
1098
1098
|
return location.protocol;
|
|
1099
1099
|
};
|
|
1100
1100
|
const create$1$1 = async ({
|
|
1101
|
-
commandMap
|
|
1101
|
+
commandMap,
|
|
1102
|
+
type
|
|
1102
1103
|
}) => {
|
|
1103
1104
|
const host = getHost();
|
|
1104
1105
|
const protocol = getProtocol$1();
|
|
1105
|
-
const wsUrl = getWebSocketUrl(
|
|
1106
|
+
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1106
1107
|
const webSocket = new WebSocket(wsUrl);
|
|
1107
1108
|
const rpc = await create$2$1({
|
|
1108
1109
|
webSocket,
|
|
@@ -1129,8 +1130,13 @@ const WebWorkerRpcClient = {
|
|
|
1129
1130
|
create: create$4
|
|
1130
1131
|
};
|
|
1131
1132
|
|
|
1133
|
+
const toCommandId = key => {
|
|
1134
|
+
const dotIndex = key.indexOf('.');
|
|
1135
|
+
return key.slice(dotIndex + 1);
|
|
1136
|
+
};
|
|
1132
1137
|
const create$3 = () => {
|
|
1133
1138
|
const states = Object.create(null);
|
|
1139
|
+
const commandMapRef = {};
|
|
1134
1140
|
return {
|
|
1135
1141
|
get(uid) {
|
|
1136
1142
|
return states[uid];
|
|
@@ -1171,6 +1177,15 @@ const create$3 = () => {
|
|
|
1171
1177
|
};
|
|
1172
1178
|
return wrapped;
|
|
1173
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
|
+
},
|
|
1174
1189
|
diff(uid, modules, numbers) {
|
|
1175
1190
|
const {
|
|
1176
1191
|
oldState,
|
|
@@ -1184,6 +1199,14 @@ const create$3 = () => {
|
|
|
1184
1199
|
}
|
|
1185
1200
|
}
|
|
1186
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);
|
|
1187
1210
|
}
|
|
1188
1211
|
};
|
|
1189
1212
|
};
|
|
@@ -2156,7 +2179,7 @@ const getTextSearchResultCounts = results => {
|
|
|
2156
2179
|
};
|
|
2157
2180
|
};
|
|
2158
2181
|
|
|
2159
|
-
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
2182
|
+
const getScrollBarSize$1 = (size, contentSize, minimumSliderSize) => {
|
|
2160
2183
|
if (size >= contentSize) {
|
|
2161
2184
|
return 0;
|
|
2162
2185
|
}
|
|
@@ -2233,7 +2256,7 @@ const handleUpdateFull = async (state, update) => {
|
|
|
2233
2256
|
const total = results.length;
|
|
2234
2257
|
const contentHeight = total * itemHeight;
|
|
2235
2258
|
const listHeight = height - headerHeight;
|
|
2236
|
-
const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
|
|
2259
|
+
const scrollBarHeight = getScrollBarSize$1(height, contentHeight, minimumSliderSize);
|
|
2237
2260
|
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
2238
2261
|
const maxLineY = Math.min(numberOfVisible, total);
|
|
2239
2262
|
const finalDeltaY = Math.max(contentHeight - listHeight, 0);
|
|
@@ -2752,32 +2775,75 @@ const initialize = async platform => {
|
|
|
2752
2775
|
const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
2753
2776
|
return Math.ceil(listHeight / itemHeight) + 1;
|
|
2754
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
|
+
};
|
|
2755
2805
|
const focusIndexScrollDown = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
2806
|
+
const {
|
|
2807
|
+
finalDeltaY,
|
|
2808
|
+
height,
|
|
2809
|
+
headerHeight,
|
|
2810
|
+
scrollBarHeight
|
|
2811
|
+
} = state;
|
|
2756
2812
|
const newMaxLineY = Math.min(index + 1, itemsLength);
|
|
2757
2813
|
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
2758
2814
|
const newMinLineY = Math.max(newMaxLineY - fittingItems, 0);
|
|
2759
2815
|
const newDeltaY = itemsLength < fittingItems ? 0 : newMinLineY * itemHeight - listHeight % itemHeight + itemHeight;
|
|
2816
|
+
const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
2760
2817
|
return {
|
|
2761
2818
|
...state,
|
|
2762
2819
|
focusedIndex: index,
|
|
2763
2820
|
minLineY: newMinLineY,
|
|
2764
2821
|
maxLineY: newMaxLineY,
|
|
2765
2822
|
focused: true,
|
|
2766
|
-
deltaY: newDeltaY
|
|
2823
|
+
deltaY: newDeltaY,
|
|
2824
|
+
scrollBarY
|
|
2767
2825
|
};
|
|
2768
2826
|
};
|
|
2769
2827
|
const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
2828
|
+
const {
|
|
2829
|
+
finalDeltaY,
|
|
2830
|
+
height,
|
|
2831
|
+
headerHeight,
|
|
2832
|
+
scrollBarHeight
|
|
2833
|
+
} = state;
|
|
2770
2834
|
const newMinLineY = index;
|
|
2771
2835
|
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
2772
2836
|
const newMaxLineY = Math.min(newMinLineY + fittingItems, itemsLength);
|
|
2773
2837
|
const newDeltaY = newMinLineY * itemHeight;
|
|
2838
|
+
const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
2774
2839
|
return {
|
|
2775
2840
|
...state,
|
|
2776
2841
|
focusedIndex: index,
|
|
2777
2842
|
minLineY: newMinLineY,
|
|
2778
2843
|
maxLineY: newMaxLineY,
|
|
2779
2844
|
focused: true,
|
|
2780
|
-
deltaY: newDeltaY
|
|
2845
|
+
deltaY: newDeltaY,
|
|
2846
|
+
scrollBarY
|
|
2781
2847
|
};
|
|
2782
2848
|
};
|
|
2783
2849
|
const focusIndex = (state, index) => {
|
|
@@ -2896,36 +2962,15 @@ const handleScrollBarCaptureLost = state => {
|
|
|
2896
2962
|
scrollBarActive: false
|
|
2897
2963
|
};
|
|
2898
2964
|
};
|
|
2899
|
-
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
2900
|
-
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
2901
|
-
return scrollBarOffset;
|
|
2902
|
-
};
|
|
2903
|
-
const getScrollBarY = getScrollBarOffset;
|
|
2904
|
-
const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
2905
|
-
const halfScrollBarHeight = scrollBarHeight / 2;
|
|
2906
|
-
if (relativeY <= halfScrollBarHeight) {
|
|
2907
|
-
// clicked at top
|
|
2908
|
-
return {
|
|
2909
|
-
percent: 0,
|
|
2910
|
-
handleOffset: relativeY
|
|
2911
|
-
};
|
|
2912
|
-
}
|
|
2913
|
-
if (relativeY <= height - halfScrollBarHeight) {
|
|
2914
|
-
// clicked in middle
|
|
2915
|
-
return {
|
|
2916
|
-
percent: (relativeY - halfScrollBarHeight) / (height - scrollBarHeight),
|
|
2917
|
-
handleOffset: halfScrollBarHeight
|
|
2918
|
-
};
|
|
2919
|
-
}
|
|
2920
|
-
// clicked at bottom
|
|
2921
|
-
return {
|
|
2922
|
-
percent: 1,
|
|
2923
|
-
handleOffset: scrollBarHeight - height + relativeY
|
|
2924
|
-
};
|
|
2925
|
-
};
|
|
2926
2965
|
const clamp = (num, min, max) => {
|
|
2927
2966
|
return Math.min(Math.max(num, min), max);
|
|
2928
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
|
+
};
|
|
2929
2974
|
const setDeltaY = (state, value) => {
|
|
2930
2975
|
object(state);
|
|
2931
2976
|
number(value);
|
|
@@ -2935,7 +2980,8 @@ const setDeltaY = (state, value) => {
|
|
|
2935
2980
|
deltaY,
|
|
2936
2981
|
height,
|
|
2937
2982
|
headerHeight,
|
|
2938
|
-
items
|
|
2983
|
+
items,
|
|
2984
|
+
minimumSliderSize
|
|
2939
2985
|
} = state;
|
|
2940
2986
|
const listHeight = height - headerHeight;
|
|
2941
2987
|
const newDeltaY = clamp(value, 0, finalDeltaY);
|
|
@@ -2945,13 +2991,18 @@ const setDeltaY = (state, value) => {
|
|
|
2945
2991
|
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
2946
2992
|
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
2947
2993
|
const maxLineY = Math.min(minLineY + getNumberOfVisibleItems(listHeight, itemHeight), items.length);
|
|
2948
|
-
|
|
2949
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);
|
|
2950
3000
|
return {
|
|
2951
3001
|
...state,
|
|
2952
3002
|
deltaY: newDeltaY,
|
|
2953
3003
|
minLineY,
|
|
2954
|
-
maxLineY
|
|
3004
|
+
maxLineY,
|
|
3005
|
+
scrollBarY
|
|
2955
3006
|
};
|
|
2956
3007
|
};
|
|
2957
3008
|
const handleScrollBarClick = (state, eventY) => {
|
|
@@ -3600,8 +3651,7 @@ const ClassNames = {
|
|
|
3600
3651
|
TreeItems: TreeItems$1,
|
|
3601
3652
|
Viewlet,
|
|
3602
3653
|
ViewletSearchMessage,
|
|
3603
|
-
ViewletSearchMessageIndented
|
|
3604
|
-
};
|
|
3654
|
+
ViewletSearchMessageIndented};
|
|
3605
3655
|
const mergeClassNames = (...classNames) => {
|
|
3606
3656
|
return classNames.filter(Boolean).join(' ');
|
|
3607
3657
|
};
|