@lvce-editor/text-search-worker 3.51.0 → 4.0.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.
@@ -609,11 +609,11 @@ const remove$1 = id => {
609
609
  delete callbacks[id];
610
610
  };
611
611
  let id = 0;
612
- const create$3 = () => {
612
+ const create$3$1 = () => {
613
613
  return ++id;
614
614
  };
615
615
  const registerPromise = () => {
616
- const id = create$3();
616
+ const id = create$3$1();
617
617
  const {
618
618
  resolve,
619
619
  promise
@@ -1038,7 +1038,7 @@ const WebSocketRpcParent = {
1038
1038
  __proto__: null,
1039
1039
  create: create$1$1
1040
1040
  };
1041
- const create$2 = async ({
1041
+ const create$3 = async ({
1042
1042
  commandMap
1043
1043
  }) => {
1044
1044
  // TODO create a commandMap per rpc instance
@@ -1050,7 +1050,7 @@ const create$2 = async ({
1050
1050
  };
1051
1051
  const WebWorkerRpcClient = {
1052
1052
  __proto__: null,
1053
- create: create$2
1053
+ create: create$3
1054
1054
  };
1055
1055
 
1056
1056
  const User = 1;
@@ -1146,17 +1146,33 @@ const copy = async state => {
1146
1146
 
1147
1147
  const minimumSliderSize = 20;
1148
1148
 
1149
- const states = Object.create(null);
1150
- const get = uid => {
1151
- return states[uid];
1152
- };
1153
- const set = (uid, oldState, newState) => {
1154
- states[uid] = {
1155
- oldState,
1156
- newState
1149
+ const create$2 = () => {
1150
+ const states = Object.create(null);
1151
+ return {
1152
+ get(uid) {
1153
+ return states[uid];
1154
+ },
1155
+ set(uid, oldState, newState) {
1156
+ states[uid] = {
1157
+ oldState,
1158
+ newState
1159
+ };
1160
+ },
1161
+ dispose(uid) {
1162
+ delete states[uid];
1163
+ },
1164
+ getKeys() {
1165
+ return Object.keys(states).map(key => {
1166
+ return Number.parseInt(key);
1167
+ });
1168
+ }
1157
1169
  };
1158
1170
  };
1159
1171
 
1172
+ const {
1173
+ get,
1174
+ set} = create$2();
1175
+
1160
1176
  const create$1 = ({
1161
1177
  itemHeight,
1162
1178
  headerHeight = 0,
@@ -1228,14 +1244,68 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
1228
1244
  return state;
1229
1245
  };
1230
1246
 
1231
- // based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
1247
+ const RenderItems = 1;
1248
+ const RenderFocus = 2;
1249
+ const RenderValue = 3;
1250
+ const RenderReplaceValue = 4;
1251
+ const RenderIncludeValue = 5;
1252
+ const RenderExcludeValue = 6;
1232
1253
 
1233
- const isLastIndex = (array, index) => {
1234
- return index === array.length - 1;
1254
+ const diffType$5 = RenderExcludeValue;
1255
+ const isEqual$5 = (oldState, newState) => {
1256
+ return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
1235
1257
  };
1236
- const lastIndex = array => {
1237
- return array.length - 1;
1258
+
1259
+ const diffType$4 = RenderFocus;
1260
+ const isEqual$4 = (oldState, newState) => {
1261
+ return oldState.focus === newState.focus || newState.focusSource === User;
1262
+ };
1263
+
1264
+ const diffType$3 = RenderIncludeValue;
1265
+ const isEqual$3 = (oldState, newState) => {
1266
+ return oldState.includeValue === newState.includeValue || newState.inputSource === User;
1267
+ };
1268
+
1269
+ const diffType$2 = RenderItems;
1270
+ const isEqual$2 = (oldState, newState) => {
1271
+ return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons && oldState.searchInputErrorMessage === newState.searchInputErrorMessage && oldState.deltaY === newState.deltaY;
1238
1272
  };
1273
+
1274
+ const diffType$1 = RenderReplaceValue;
1275
+ const isEqual$1 = (oldState, newState) => {
1276
+ return oldState.replacement === newState.replacement || newState.inputSource === User;
1277
+ };
1278
+
1279
+ const diffType = RenderValue;
1280
+ const isEqual = (oldState, newState) => {
1281
+ return oldState.value === newState.value || newState.inputSource === User;
1282
+ };
1283
+
1284
+ const modules = [isEqual$2, isEqual$4, isEqual$3, isEqual$5, isEqual$1, isEqual];
1285
+ const numbers = [diffType$2, diffType$4, diffType$3, diffType$5, diffType$1, diffType];
1286
+
1287
+ const diff$1 = (oldState, newState) => {
1288
+ const diffResult = [];
1289
+ for (let i = 0; i < modules.length; i++) {
1290
+ const fn = modules[i];
1291
+ if (!fn(oldState, newState)) {
1292
+ diffResult.push(numbers[i]);
1293
+ }
1294
+ }
1295
+ return diffResult;
1296
+ };
1297
+
1298
+ const diff2 = uid => {
1299
+ const {
1300
+ oldState,
1301
+ newState
1302
+ } = get(uid);
1303
+ const diffResult = diff$1(oldState, newState);
1304
+ return diffResult;
1305
+ };
1306
+
1307
+ // based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
1308
+
1239
1309
  const remove = (array, index, deleteCount) => {
1240
1310
  return array.toSpliced(index, deleteCount);
1241
1311
  };
@@ -1927,7 +1997,7 @@ var getTotalChildCount = (nodes, index) => {
1927
1997
  };
1928
1998
 
1929
1999
  // src/parts/VirtualDomDiff/VirtualDomDiff.ts
1930
- var diff$1 = (oldNodes, newNodes) => {
2000
+ var diff = (oldNodes, newNodes) => {
1931
2001
  const patches = [];
1932
2002
  const pendingPatches = [];
1933
2003
  let i = 0;
@@ -2151,20 +2221,6 @@ const getCommandIds = () => {
2151
2221
  return commandIds;
2152
2222
  };
2153
2223
 
2154
- const getFlags = uid => {
2155
- const {
2156
- newState
2157
- } = get(uid);
2158
- return newState.flags;
2159
- };
2160
-
2161
- const getFocus = uid => {
2162
- const {
2163
- newState
2164
- } = get(uid);
2165
- return newState.focus;
2166
- };
2167
-
2168
2224
  const Tab = 2;
2169
2225
  const Enter = 3;
2170
2226
  const End = 255;
@@ -2960,7 +3016,7 @@ const getFileIcons = async matches => {
2960
3016
  // TODO optimize this function to return the minimum number
2961
3017
  // of visible items needed, e.g. when not scrolled 5 items with
2962
3018
  // 20px fill 100px but when scrolled 6 items are needed
2963
- const getNumberOfVisibleItems = (listHeight, itemHeight) => {
3019
+ const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
2964
3020
  return Math.ceil(listHeight / itemHeight) + 1;
2965
3021
  };
2966
3022
 
@@ -3004,33 +3060,11 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
3004
3060
  }
3005
3061
  return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
3006
3062
  };
3007
- const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
3063
+ const getScrollBarOffset$1 = (delta, finalDelta, size, scrollBarSize) => {
3008
3064
  const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
3009
3065
  return scrollBarOffset;
3010
3066
  };
3011
- const getScrollBarY = getScrollBarOffset;
3012
- const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
3013
- const halfScrollBarHeight = scrollBarHeight / 2;
3014
- if (relativeY <= halfScrollBarHeight) {
3015
- // clicked at top
3016
- return {
3017
- percent: 0,
3018
- handleOffset: relativeY
3019
- };
3020
- }
3021
- if (relativeY <= height - halfScrollBarHeight) {
3022
- // clicked in middle
3023
- return {
3024
- percent: (relativeY - halfScrollBarHeight) / (height - scrollBarHeight),
3025
- handleOffset: halfScrollBarHeight
3026
- };
3027
- }
3028
- // clicked at bottom
3029
- return {
3030
- percent: 1,
3031
- handleOffset: scrollBarHeight - height + relativeY
3032
- };
3033
- };
3067
+ const getScrollBarY$1 = getScrollBarOffset$1;
3034
3068
 
3035
3069
  const textSearch$6 = async (scheme, root, query) => {
3036
3070
  string(scheme);
@@ -3319,7 +3353,7 @@ const handleUpdate = async (state, update) => {
3319
3353
  const contentHeight = total * itemHeight;
3320
3354
  const listHeight = height - headerHeight;
3321
3355
  const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
3322
- const numberOfVisible = getNumberOfVisibleItems(listHeight, itemHeight);
3356
+ const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
3323
3357
  const maxLineY = Math.min(numberOfVisible, total);
3324
3358
  const finalDeltaY = Math.max(contentHeight - listHeight, 0);
3325
3359
  const visible = results.slice(0, maxLineY);
@@ -3582,6 +3616,12 @@ const handleSharedInput = (state, name, value, inputSource = Script) => {
3582
3616
  return fn(state, value, inputSource);
3583
3617
  };
3584
3618
 
3619
+ // TODO optimize this function to return the minimum number
3620
+ // of visible items needed, e.g. when not scrolled 5 items with
3621
+ // 20px fill 100px but when scrolled 6 items are needed
3622
+ const getNumberOfVisibleItems = (listHeight, itemHeight) => {
3623
+ return Math.ceil(listHeight / itemHeight) + 1;
3624
+ };
3585
3625
  const focusIndexScrollDown = (state, index, listHeight, itemHeight, itemsLength) => {
3586
3626
  const newMaxLineY = Math.min(index + 1, itemsLength);
3587
3627
  const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
@@ -3596,7 +3636,6 @@ const focusIndexScrollDown = (state, index, listHeight, itemHeight, itemsLength)
3596
3636
  deltaY: newDeltaY
3597
3637
  };
3598
3638
  };
3599
-
3600
3639
  const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) => {
3601
3640
  const newMinLineY = index;
3602
3641
  const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
@@ -3611,7 +3650,6 @@ const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) =
3611
3650
  deltaY: newDeltaY
3612
3651
  };
3613
3652
  };
3614
-
3615
3653
  const focusIndex = (state, index) => {
3616
3654
  const {
3617
3655
  itemHeight,
@@ -3646,7 +3684,6 @@ const focusIndex = (state, index) => {
3646
3684
  focused: true
3647
3685
  };
3648
3686
  };
3649
-
3650
3687
  const first = () => {
3651
3688
  return 0;
3652
3689
  };
@@ -3659,12 +3696,10 @@ const next = (items, index) => {
3659
3696
  const previous = (items, index) => {
3660
3697
  return index === 0 ? items.length - 1 : index - 1;
3661
3698
  };
3662
-
3663
3699
  const focusFirst = state => {
3664
3700
  const firstIndex = first();
3665
3701
  return focusIndex(state, firstIndex);
3666
3702
  };
3667
-
3668
3703
  const focusLast = state => {
3669
3704
  const {
3670
3705
  items
@@ -3672,7 +3707,6 @@ const focusLast = state => {
3672
3707
  const lastIndex = last(items);
3673
3708
  return focusIndex(state, lastIndex);
3674
3709
  };
3675
-
3676
3710
  const focusNext = state => {
3677
3711
  const {
3678
3712
  focusedIndex,
@@ -3682,6 +3716,14 @@ const focusNext = state => {
3682
3716
  return focusIndex(state, nextIndex);
3683
3717
  };
3684
3718
 
3719
+ // based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
3720
+
3721
+ const isLastIndex = (array, index) => {
3722
+ return index === array.length - 1;
3723
+ };
3724
+ const lastIndex = array => {
3725
+ return array.length - 1;
3726
+ };
3685
3727
  const focusNextPage = state => {
3686
3728
  const {
3687
3729
  focusedIndex,
@@ -3695,7 +3737,6 @@ const focusNextPage = state => {
3695
3737
  const indexNextPage = Math.min(maxLineY + (maxLineY - minLineY) - 2, lastIndex(items));
3696
3738
  return focusIndex(state, indexNextPage);
3697
3739
  };
3698
-
3699
3740
  const focusPrevious = state => {
3700
3741
  const {
3701
3742
  focusedIndex,
@@ -3707,7 +3748,6 @@ const focusPrevious = state => {
3707
3748
  const previousIndex = previous(items, focusedIndex);
3708
3749
  return focusIndex(state, previousIndex);
3709
3750
  };
3710
-
3711
3751
  const focusPreviousPage = state => {
3712
3752
  const {
3713
3753
  focusedIndex,
@@ -3720,6 +3760,129 @@ const focusPreviousPage = state => {
3720
3760
  const indexPreviousPage = Math.max(minLineY - (maxLineY - minLineY) + 1, 0);
3721
3761
  return focusIndex(state, indexPreviousPage);
3722
3762
  };
3763
+ const handleScrollBarCaptureLost = state => {
3764
+ return {
3765
+ ...state,
3766
+ scrollBarActive: false
3767
+ };
3768
+ };
3769
+ const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
3770
+ const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
3771
+ return scrollBarOffset;
3772
+ };
3773
+ const getScrollBarY = getScrollBarOffset;
3774
+ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
3775
+ const halfScrollBarHeight = scrollBarHeight / 2;
3776
+ if (relativeY <= halfScrollBarHeight) {
3777
+ // clicked at top
3778
+ return {
3779
+ percent: 0,
3780
+ handleOffset: relativeY
3781
+ };
3782
+ }
3783
+ if (relativeY <= height - halfScrollBarHeight) {
3784
+ // clicked in middle
3785
+ return {
3786
+ percent: (relativeY - halfScrollBarHeight) / (height - scrollBarHeight),
3787
+ handleOffset: halfScrollBarHeight
3788
+ };
3789
+ }
3790
+ // clicked at bottom
3791
+ return {
3792
+ percent: 1,
3793
+ handleOffset: scrollBarHeight - height + relativeY
3794
+ };
3795
+ };
3796
+ const clamp = (num, min, max) => {
3797
+ return Math.min(Math.max(num, min), max);
3798
+ };
3799
+ const setDeltaY = (state, value) => {
3800
+ object(state);
3801
+ number(value);
3802
+ const {
3803
+ itemHeight,
3804
+ finalDeltaY,
3805
+ deltaY,
3806
+ height,
3807
+ headerHeight,
3808
+ items
3809
+ } = state;
3810
+ const listHeight = height - headerHeight;
3811
+ const newDeltaY = clamp(value, 0, finalDeltaY);
3812
+ if (deltaY === newDeltaY) {
3813
+ return state;
3814
+ }
3815
+ // TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
3816
+ const minLineY = Math.floor(newDeltaY / itemHeight);
3817
+ const maxLineY = Math.min(minLineY + getNumberOfVisibleItems(listHeight, itemHeight), items.length);
3818
+
3819
+ // TODO update icons
3820
+ return {
3821
+ ...state,
3822
+ deltaY: newDeltaY,
3823
+ minLineY,
3824
+ maxLineY
3825
+ };
3826
+ };
3827
+ const handleScrollBarClick = (state, eventY) => {
3828
+ const {
3829
+ y,
3830
+ deltaY,
3831
+ headerHeight,
3832
+ finalDeltaY,
3833
+ scrollBarHeight,
3834
+ height
3835
+ } = state;
3836
+ const contentHeight = height - headerHeight;
3837
+ const relativeY = eventY - y - headerHeight;
3838
+ const currentScrollBarY = getScrollBarY(deltaY, finalDeltaY, contentHeight, scrollBarHeight);
3839
+ const diff = relativeY - currentScrollBarY;
3840
+ if (diff >= 0 && diff < scrollBarHeight) {
3841
+ return {
3842
+ ...state,
3843
+ handleOffset: diff,
3844
+ scrollBarActive: true
3845
+ };
3846
+ }
3847
+ const {
3848
+ percent,
3849
+ handleOffset
3850
+ } = getNewDeltaPercent(contentHeight, scrollBarHeight, relativeY);
3851
+ const newDeltaY = percent * finalDeltaY;
3852
+ return {
3853
+ ...setDeltaY(state, newDeltaY),
3854
+ handleOffset,
3855
+ scrollBarActive: true
3856
+ };
3857
+ };
3858
+ const getNewPercent = (contentHeight, scrollBarHeight, relativeY) => {
3859
+ if (relativeY <= contentHeight - scrollBarHeight / 2) {
3860
+ // clicked in middle
3861
+ return relativeY / (contentHeight - scrollBarHeight);
3862
+ }
3863
+ // clicked at bottom
3864
+ return 1;
3865
+ };
3866
+ const handleScrollBarMove = (state, eventY) => {
3867
+ const {
3868
+ y,
3869
+ headerHeight,
3870
+ handleOffset,
3871
+ finalDeltaY,
3872
+ height,
3873
+ scrollBarHeight
3874
+ } = state;
3875
+ const relativeY = eventY - y - headerHeight - handleOffset;
3876
+ const contentHeight = height - headerHeight;
3877
+ const newPercent = getNewPercent(contentHeight, scrollBarHeight, relativeY);
3878
+ const newDeltaY = newPercent * finalDeltaY;
3879
+ return setDeltaY(state, newDeltaY);
3880
+ };
3881
+ const handleWheel = (state, deltaMode, deltaY) => {
3882
+ number(deltaMode);
3883
+ number(deltaY);
3884
+ return setDeltaY(state, state.deltaY + deltaY);
3885
+ };
3723
3886
 
3724
3887
  const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight, itemCount) => {
3725
3888
  const relativeY = eventY - y - topHeight + deltaY;
@@ -3783,7 +3946,7 @@ const selectIndexFile = async (state, searchResult, index) => {
3783
3946
  const icons = await getFileIcons(filteredResults);
3784
3947
  const total = filteredResults.length;
3785
3948
  const listHeight = height - headerHeight;
3786
- const numberOfVisible = getNumberOfVisibleItems(listHeight, itemHeight);
3949
+ const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
3787
3950
  const maxLineY = Math.min(numberOfVisible, total);
3788
3951
  return {
3789
3952
  ...state,
@@ -3876,108 +4039,6 @@ const handleClickAt = (state, eventX, eventY) => {
3876
4039
  return selectIndex(state, index);
3877
4040
  };
3878
4041
 
3879
- const handleScrollBarCaptureLost = state => {
3880
- return {
3881
- ...state,
3882
- scrollBarActive: false
3883
- };
3884
- };
3885
-
3886
- const clamp = (num, min, max) => {
3887
- return Math.min(Math.max(num, min), max);
3888
- };
3889
-
3890
- const setDeltaY = (state, value) => {
3891
- object(state);
3892
- number(value);
3893
- const {
3894
- itemHeight,
3895
- finalDeltaY,
3896
- deltaY,
3897
- height,
3898
- headerHeight,
3899
- listItems
3900
- } = state;
3901
- const listHeight = height - headerHeight;
3902
- const newDeltaY = clamp(value, 0, finalDeltaY);
3903
- if (deltaY === newDeltaY) {
3904
- return state;
3905
- }
3906
- // TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
3907
- const minLineY = Math.floor(newDeltaY / itemHeight);
3908
- const maxLineY = Math.min(minLineY + getNumberOfVisibleItems(listHeight, itemHeight), listItems.length);
3909
-
3910
- // TODO update icons
3911
- return {
3912
- ...state,
3913
- deltaY: newDeltaY,
3914
- minLineY,
3915
- maxLineY
3916
- };
3917
- };
3918
-
3919
- const handleScrollBarClick = (state, eventY) => {
3920
- const {
3921
- y,
3922
- deltaY,
3923
- headerHeight,
3924
- finalDeltaY,
3925
- scrollBarHeight,
3926
- height
3927
- } = state;
3928
- const contentHeight = height - headerHeight;
3929
- const relativeY = eventY - y - headerHeight;
3930
- const currentScrollBarY = getScrollBarY(deltaY, finalDeltaY, contentHeight, scrollBarHeight);
3931
- const diff = relativeY - currentScrollBarY;
3932
- if (diff >= 0 && diff < scrollBarHeight) {
3933
- return {
3934
- ...state,
3935
- handleOffset: diff,
3936
- scrollBarActive: true
3937
- };
3938
- }
3939
- const {
3940
- percent,
3941
- handleOffset
3942
- } = getNewDeltaPercent(contentHeight, scrollBarHeight, relativeY);
3943
- const newDeltaY = percent * finalDeltaY;
3944
- return {
3945
- ...setDeltaY(state, newDeltaY),
3946
- handleOffset,
3947
- scrollBarActive: true
3948
- };
3949
- };
3950
-
3951
- const getNewPercent = (contentHeight, scrollBarHeight, relativeY) => {
3952
- if (relativeY <= contentHeight - scrollBarHeight / 2) {
3953
- // clicked in middle
3954
- return relativeY / (contentHeight - scrollBarHeight);
3955
- }
3956
- // clicked at bottom
3957
- return 1;
3958
- };
3959
- const handleScrollBarMove = (state, eventY) => {
3960
- const {
3961
- y,
3962
- headerHeight,
3963
- handleOffset,
3964
- finalDeltaY,
3965
- height,
3966
- scrollBarHeight
3967
- } = state;
3968
- const relativeY = eventY - y - headerHeight - handleOffset;
3969
- const contentHeight = height - headerHeight;
3970
- const newPercent = getNewPercent(contentHeight, scrollBarHeight, relativeY);
3971
- const newDeltaY = newPercent * finalDeltaY;
3972
- return setDeltaY(state, newDeltaY);
3973
- };
3974
-
3975
- const handleWheel = (state, deltaMode, deltaY) => {
3976
- number(deltaMode);
3977
- number(deltaY);
3978
- return setDeltaY(state, state.deltaY + deltaY);
3979
- };
3980
-
3981
4042
  const getSavedValue = savedState => {
3982
4043
  if (savedState && typeof savedState === 'object' && 'value' in savedState && typeof savedState.value === 'string') {
3983
4044
  return savedState.value;
@@ -4054,13 +4115,6 @@ const refresh = state => {
4054
4115
  return handleUpdate(state, {});
4055
4116
  };
4056
4117
 
4057
- const RenderItems = 1;
4058
- const RenderFocus = 2;
4059
- const RenderValue = 3;
4060
- const RenderReplaceValue = 4;
4061
- const RenderIncludeValue = 5;
4062
- const RenderExcludeValue = 6;
4063
-
4064
4118
  const getFocusSelector = focusKey => {
4065
4119
  switch (focusKey) {
4066
4120
  case FocusSearchInput:
@@ -4126,7 +4180,7 @@ const createViewModel = state => {
4126
4180
  const displayResults = getDisplayResults(listItems, itemHeight, fileCount, value, minLineY, maxLineY, replacement, icons, listFocusedIndex, collapsedPaths, items);
4127
4181
  const focusOutline = listFocused && listFocusedIndex === -1;
4128
4182
  const scrollBarValue = deltaY / finalDeltaY * 100;
4129
- const scrollBarY = getScrollBarY(deltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
4183
+ const scrollBarY = getScrollBarY$1(deltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
4130
4184
  return {
4131
4185
  displayResults,
4132
4186
  flags,
@@ -4189,56 +4243,12 @@ const applyRender = (oldState, newState, diffResult) => {
4189
4243
  return commands;
4190
4244
  };
4191
4245
 
4192
- const diffType$5 = RenderExcludeValue;
4193
- const isEqual$5 = (oldState, newState) => {
4194
- return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
4195
- };
4196
-
4197
- const diffType$4 = RenderFocus;
4198
- const isEqual$4 = (oldState, newState) => {
4199
- return oldState.focus === newState.focus || newState.focusSource === User;
4200
- };
4201
-
4202
- const diffType$3 = RenderIncludeValue;
4203
- const isEqual$3 = (oldState, newState) => {
4204
- return oldState.includeValue === newState.includeValue || newState.inputSource === User;
4205
- };
4206
-
4207
- const diffType$2 = RenderItems;
4208
- const isEqual$2 = (oldState, newState) => {
4209
- return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons && oldState.searchInputErrorMessage === newState.searchInputErrorMessage && oldState.deltaY === newState.deltaY;
4210
- };
4211
-
4212
- const diffType$1 = RenderReplaceValue;
4213
- const isEqual$1 = (oldState, newState) => {
4214
- return oldState.replacement === newState.replacement || newState.inputSource === User;
4215
- };
4216
-
4217
- const diffType = RenderValue;
4218
- const isEqual = (oldState, newState) => {
4219
- return oldState.value === newState.value || newState.inputSource === User;
4220
- };
4221
-
4222
- const modules = [isEqual$2, isEqual$4, isEqual$3, isEqual$5, isEqual$1, isEqual];
4223
- const numbers = [diffType$2, diffType$4, diffType$3, diffType$5, diffType$1, diffType];
4224
-
4225
- const diff = (oldState, newState) => {
4226
- const diffResult = [];
4227
- for (let i = 0; i < modules.length; i++) {
4228
- const fn = modules[i];
4229
- if (!fn(oldState, newState)) {
4230
- diffResult.push(numbers[i]);
4231
- }
4232
- }
4233
- return diffResult;
4234
- };
4235
-
4236
- const doRender = uid => {
4246
+ const render2 = (uid, diffResult) => {
4237
4247
  const {
4238
4248
  oldState,
4239
4249
  newState
4240
4250
  } = get(uid);
4241
- const diffResult = diff(oldState, newState);
4251
+ set(uid, newState, newState);
4242
4252
  const commands = applyRender(oldState, newState, diffResult);
4243
4253
  return commands;
4244
4254
  };
@@ -4305,7 +4315,7 @@ const getDom = state => {
4305
4315
  const displayResults = getDisplayResults(state.listItems, state.itemHeight, state.fileCount, state.value, state.minLineY, state.maxLineY, state.replacement, state.icons, state.listFocusedIndex, state.collapsedPaths, state.items);
4306
4316
  const focusOutline = state.listFocused && state.listFocusedIndex === -1;
4307
4317
  const scrollBarValue = state.deltaY / state.finalDeltaY * 100;
4308
- const scrollBarY = getScrollBarY(state.deltaY, state.finalDeltaY, state.height - state.headerHeight, state.scrollBarHeight);
4318
+ const scrollBarY = getScrollBarY$1(state.deltaY, state.finalDeltaY, state.height - state.headerHeight, state.scrollBarHeight);
4309
4319
  const dom = getSearchVirtualDom(displayResults, state.flags, state.message, focusOutline, state.searchInputErrorMessage, state.scrollBarHeight, scrollBarY, scrollBarValue, state.deltaY, state.itemHeight, state.matchCount);
4310
4320
  return dom;
4311
4321
  };
@@ -4318,7 +4328,7 @@ const renderIncremental = uid => {
4318
4328
  } = get(uid);
4319
4329
  const oldDom = getDom(oldState);
4320
4330
  const newDom = getDom(newState);
4321
- const patches = diff$1(oldDom, newDom);
4331
+ const patches = diff(oldDom, newDom);
4322
4332
  return patches;
4323
4333
  };
4324
4334
 
@@ -4542,12 +4552,12 @@ const wrapCommand = fn => {
4542
4552
 
4543
4553
  const commandMap = {
4544
4554
  'TextSearch.clearSearchResults': wrapCommand(clearSearchResults$1),
4555
+ 'TextSearch.collapseDetails': wrapCommand(collapseDetails),
4545
4556
  'TextSearch.copy': wrapCommand(copy),
4557
+ 'TextSearch.diff2': diff2,
4546
4558
  'TextSearch.dismissItem': wrapCommand(dismissItem),
4547
- 'TextSearch.handleHeaderFocusIn': wrapCommand(handleHeaderFocusIn),
4548
- 'TextSearch.focusFirst': wrapCommand(focusFirst),
4549
- 'TextSearch.collapseDetails': wrapCommand(collapseDetails),
4550
4559
  'TextSearch.expandDetails': wrapCommand(expandDetails),
4560
+ 'TextSearch.focusFirst': wrapCommand(focusFirst),
4551
4561
  'TextSearch.focusIndex': wrapCommand(focusIndex),
4552
4562
  'TextSearch.focusLast': wrapCommand(focusLast),
4553
4563
  'TextSearch.focusMatchCase': wrapCommand(focusMatchCase$1),
@@ -4568,11 +4578,10 @@ const commandMap = {
4568
4578
  'TextSearch.focusReplaceValueNext': wrapCommand(focusReplaceValueNext),
4569
4579
  'TextSearch.focusReplaceValuePrevious': wrapCommand(focusReplaceValuePrevious),
4570
4580
  'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
4571
- 'TextSearch.getCommandIds': getCommandIds,
4572
- 'TextSearch.renderActions': wrapCommand(renderActions),
4573
4581
  'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
4574
4582
  'TextSearch.getActions': wrapCommand(getActions),
4575
4583
  'TextSearch.getActionsVirtualDom': wrapCommand(getActionsVirtualDom),
4584
+ 'TextSearch.getCommandIds': getCommandIds,
4576
4585
  'TextSearch.getSearchDisplayResults': wrapCommand(getDisplayResults),
4577
4586
  'TextSearch.getVirtualDom': wrapCommand(getSearchVirtualDom),
4578
4587
  'TextSearch.handleClickAt': wrapCommand(handleClickAt),
@@ -4580,6 +4589,7 @@ const commandMap = {
4580
4589
  'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
4581
4590
  'TextSearch.handleFocusIn': wrapCommand(handleFocusIn),
4582
4591
  'TextSearch.handleHeaderClick': wrapCommand(handleHeaderClick),
4592
+ 'TextSearch.handleHeaderFocusIn': wrapCommand(handleHeaderFocusIn),
4583
4593
  'TextSearch.handleIconThemeChange': wrapCommand(handleIconThemeChange),
4584
4594
  'TextSearch.handleIncludeInput': wrapCommand(handleIncludeInput),
4585
4595
  'TextSearch.handleInput': wrapCommand(handleInput),
@@ -4593,6 +4603,7 @@ const commandMap = {
4593
4603
  'TextSearch.launchSearchProcess': wrapCommand(launchSearchProcess),
4594
4604
  'TextSearch.loadContent': wrapCommand(loadContent),
4595
4605
  'TextSearch.refresh': wrapCommand(refresh),
4606
+ 'TextSearch.renderActions': wrapCommand(renderActions),
4596
4607
  'TextSearch.replaceAll': wrapCommand(replaceAll),
4597
4608
  'TextSearch.replaceAllAndPrompt': wrapCommand(replaceAllAndPrompt),
4598
4609
  'TextSearch.selectIndex': wrapCommand(selectIndex),
@@ -4607,10 +4618,8 @@ const commandMap = {
4607
4618
  'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
4608
4619
  // not wrapped
4609
4620
  'TextSearch.create': create,
4610
- 'TextSearch.getFlags': getFlags,
4611
- 'TextSearch.getFocus': getFocus,
4612
4621
  'TextSearch.getKeyBindings': getKeyBindings,
4613
- 'TextSearch.render': doRender,
4622
+ 'TextSearch.render2': render2,
4614
4623
  'TextSearch.renderEventListeners': renderEventListeners,
4615
4624
  'TextSearch.renderIncremental': renderIncremental,
4616
4625
  'TextSearch.restoreState': restoreState,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "3.51.0",
3
+ "version": "4.0.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"