@lvce-editor/file-search-worker 4.1.0 → 4.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.
@@ -448,7 +448,7 @@ const set$2 = (id, fn) => {
448
448
  const get$2 = id => {
449
449
  return callbacks[id];
450
450
  };
451
- const remove = id => {
451
+ const remove$1 = id => {
452
452
  delete callbacks[id];
453
453
  };
454
454
  let id = 0;
@@ -625,7 +625,7 @@ const resolve = (id, response) => {
625
625
  return;
626
626
  }
627
627
  fn(response);
628
- remove(id);
628
+ remove$1(id);
629
629
  };
630
630
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
631
631
  const getErrorType = prettyError => {
@@ -1699,13 +1699,17 @@ const create$2 = () => {
1699
1699
  oldState,
1700
1700
  newState
1701
1701
  };
1702
+ },
1703
+ remove(uid) {
1704
+ delete states[uid];
1702
1705
  }
1703
1706
  };
1704
1707
  };
1705
1708
 
1706
1709
  const {
1707
1710
  get,
1708
- set
1711
+ set,
1712
+ remove
1709
1713
  } = create$2();
1710
1714
 
1711
1715
  const create$1 = ({
@@ -1808,6 +1812,10 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, r
1808
1812
  set(uid, state, state);
1809
1813
  };
1810
1814
 
1815
+ const dispose = uid => {
1816
+ remove(uid);
1817
+ };
1818
+
1811
1819
  const emptyMatches = [];
1812
1820
 
1813
1821
  const convertToPick = item => {
@@ -2083,7 +2091,7 @@ const focusPrevious = state => {
2083
2091
  return focusIndex(state, previousIndex);
2084
2092
  };
2085
2093
 
2086
- const commandIds = ['focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleBeforeInput', 'handleBlur', 'handleClickAt', 'handleInput', 'handleWheel', 'renderEventListeners', 'selectCurrentIndex', 'selectIndex', 'selectItem', 'setValue'];
2094
+ const commandIds = ['dispose', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleBeforeInput', 'handleBlur', 'handleClickAt', 'handleFocus', 'handleInput', 'handleWheel', 'renderEventListeners', 'selectCurrentIndex', 'selectIndex', 'selectItem', 'setValue'];
2087
2095
 
2088
2096
  const getCommandIds = () => {
2089
2097
  return commandIds;
@@ -2314,13 +2322,14 @@ const handleBeforeInput = (state, inputType, data, selectionStart, selectionEnd)
2314
2322
  return handleInput(state, newValue, cursorOffset, User);
2315
2323
  };
2316
2324
 
2317
- const closeWidget = async id => {
2318
- await invoke$1('Viewlet.closeWidget', id);
2325
+ const handleBlur$1 = async state => {
2326
+ // TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
2327
+ // await CloseWidget.closeWidget(state.uid)
2328
+ return state;
2319
2329
  };
2320
2330
 
2321
- const handleBlur = async state => {
2322
- await closeWidget(state.uid);
2323
- return state;
2331
+ const closeWidget = async id => {
2332
+ await invoke$1('Viewlet.closeWidget', id);
2324
2333
  };
2325
2334
 
2326
2335
  const getPick = (items, index) => {
@@ -2380,6 +2389,17 @@ const handleClickAt = (state, x, y) => {
2380
2389
  return selectIndex(state, index);
2381
2390
  };
2382
2391
 
2392
+ const setFocus = async focusKey => {
2393
+ await invoke$1('Focus.setFocus', focusKey);
2394
+ };
2395
+
2396
+ const handleBlur = async state => {
2397
+ // TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
2398
+ await setFocus(FocusQuickPickInput);
2399
+ // await CloseWidget.closeWidget(state.uid)
2400
+ return state;
2401
+ };
2402
+
2383
2403
  const getDefaultValue = uri => {
2384
2404
  switch (uri) {
2385
2405
  case 'quickPick://everything':
@@ -2648,7 +2668,12 @@ const renderCursorOffset = newState => {
2648
2668
  return ['Viewlet.send', newState.uid, /* method */SetCursorOffset, /* cursorOffset */newState.cursorOffset];
2649
2669
  };
2650
2670
 
2671
+ const QuickPickInput = 'QuickPickInput';
2672
+
2651
2673
  const renderFocus = newState => {
2674
+ if (newState.renderAllItems) {
2675
+ return ['Viewlet.focusElementByName', QuickPickInput];
2676
+ }
2652
2677
  const selector = newState.focused ? '.InputBox' : '';
2653
2678
  return ['Viewlet.focusSelector', selector];
2654
2679
  };
@@ -2676,7 +2701,7 @@ const QuickPick$1 = 'QuickPick';
2676
2701
  const QuickPickHeader = 'QuickPickHeader';
2677
2702
  const QuickPickHighlight = 'QuickPickHighlight';
2678
2703
  const QuickPickItem = 'QuickPickItem';
2679
- const QuickPickItemActive = 'QuickPickItemActive';
2704
+ const QuickPickItemActive$1 = 'QuickPickItemActive';
2680
2705
  const QuickPickItemDescription = 'QuickPickItemDescription';
2681
2706
  const QuickPickItemLabel = 'QuickPickItemLabel';
2682
2707
  const QuickPickItems$1 = 'QuickPickItems';
@@ -2889,7 +2914,7 @@ const getQuickPickItemVirtualDom = visibleItem => {
2889
2914
  if (isActive) {
2890
2915
  // @ts-ignore
2891
2916
  parent.id = 'QuickPickItemActive';
2892
- parent.className += ' ' + QuickPickItemActive;
2917
+ parent.className += ' ' + QuickPickItemActive$1;
2893
2918
  }
2894
2919
  if (fileIcon) {
2895
2920
  parent.childCount++;
@@ -2934,23 +2959,20 @@ const getQuickPickItemsVirtualDom = visibleItems => {
2934
2959
  return dom;
2935
2960
  };
2936
2961
 
2937
- const QuickPick = 'QuickPick';
2938
- const QuickPickItems = 'QuickPickItems';
2939
-
2962
+ const HandleBeforeInput = 'handleBeforeInput';
2963
+ const HandleBlur = 'handleBlur';
2964
+ const HandleFocus = 'handleFocus';
2965
+ const HandleInput = 'handleInput';
2940
2966
  const HandlePointerDown = 'handlePointerDown';
2941
2967
  const HandleWheel = 'handleWheel';
2942
- const HandleBlur = 'handleBlur';
2943
- const HandleBeforeInput = 'handleBeforeInput';
2944
2968
 
2945
- const QuickPickInput = 'QuickPickInput';
2969
+ const QuickPick = 'QuickPick';
2970
+ const QuickPickItems = 'QuickPickItems';
2971
+ const QuickPickItemActive = 'QuickPickItemActive';
2946
2972
 
2947
- const getQuickPickHeaderVirtualDom = () => {
2973
+ const getQuickPickInputVirtualDom = () => {
2948
2974
  const ariaLabel = typeNameofCommandToRun();
2949
- return [{
2950
- type: Div$1,
2951
- className: QuickPickHeader,
2952
- childCount: 1
2953
- }, {
2975
+ return {
2954
2976
  type: Input$1,
2955
2977
  className: InputBox,
2956
2978
  spellcheck: false,
@@ -2961,8 +2983,21 @@ const getQuickPickHeaderVirtualDom = () => {
2961
2983
  name: QuickPickInput,
2962
2984
  onBeforeInput: HandleBeforeInput,
2963
2985
  onBlur: HandleBlur,
2964
- ariaLabel: ariaLabel
2965
- }];
2986
+ onInput: HandleInput,
2987
+ onFocus: HandleFocus,
2988
+ ariaLabel: ariaLabel,
2989
+ ariaAutoComplete: 'list',
2990
+ ariaExpanded: true,
2991
+ autocomplete: 'off'
2992
+ };
2993
+ };
2994
+
2995
+ const getQuickPickHeaderVirtualDom = () => {
2996
+ return [{
2997
+ type: Div$1,
2998
+ className: QuickPickHeader,
2999
+ childCount: 1
3000
+ }, getQuickPickInputVirtualDom()];
2966
3001
  };
2967
3002
 
2968
3003
  const getQuickPickVirtualDom = visibleItems => {
@@ -2978,6 +3013,8 @@ const getQuickPickVirtualDom = visibleItems => {
2978
3013
  className: QuickPickItems$1,
2979
3014
  id: QuickPickItems,
2980
3015
  role: ListBox,
3016
+ ariaActivedescendant: QuickPickItemActive,
3017
+ onWheel: HandleWheel,
2981
3018
  childCount: visibleItems.length
2982
3019
  }, ...getQuickPickItemsVirtualDom(visibleItems)];
2983
3020
  };
@@ -3018,6 +3055,12 @@ const applyRender = async (oldState, newState, diffResult) => {
3018
3055
  const commands = [];
3019
3056
  const viewModel = await createQuickPickViewModel(oldState, newState);
3020
3057
  for (const item of diffResult) {
3058
+ if (viewModel.renderAllItems && item === Height) {
3059
+ continue;
3060
+ }
3061
+ if (viewModel.renderAllItems && item === RenderFocusedIndex) {
3062
+ continue;
3063
+ }
3021
3064
  const fn = getRenderer(item);
3022
3065
  commands.push(fn(viewModel));
3023
3066
  }
@@ -3049,8 +3092,8 @@ const isEqual = (oldState, newState) => {
3049
3092
  return newState.inputSource === User || oldState.value === newState.value;
3050
3093
  };
3051
3094
 
3052
- const modules = [isEqual$2, isEqual$1, isEqual$4, isEqual, isEqual$3];
3053
- const numbers = [diffType$2, diffType$1, diffType$4, diffType, diffType$3];
3095
+ const modules = [isEqual$2, isEqual$1, isEqual, isEqual$3, isEqual$4];
3096
+ const numbers = [diffType$2, diffType$1, diffType, diffType$3, diffType$4];
3054
3097
 
3055
3098
  const diff = (oldState, newState) => {
3056
3099
  const diffResult = [];
@@ -3079,13 +3122,19 @@ const renderEventListeners = () => {
3079
3122
  preventDefault: true
3080
3123
  }, {
3081
3124
  name: HandleWheel,
3082
- params: ['handleWheel']
3125
+ params: ['handleWheel', 'event.deltaMode', 'event.deltaY']
3083
3126
  }, {
3084
3127
  name: HandleBlur,
3085
3128
  params: ['handleBlur']
3086
3129
  }, {
3087
3130
  name: HandleBeforeInput,
3088
3131
  params: ['handleBeforeInput']
3132
+ }, {
3133
+ name: HandleInput,
3134
+ params: ['handleInput', 'event.target.value']
3135
+ }, {
3136
+ name: HandleFocus,
3137
+ params: ['handleFocus']
3089
3138
  }];
3090
3139
  };
3091
3140
 
@@ -3125,6 +3174,7 @@ const wrapCommand = fn => {
3125
3174
  const commandMap = {
3126
3175
  'QuickPick.addMenuEntries': add,
3127
3176
  'QuickPick.create2': create,
3177
+ 'QuickPick.dispose': dispose,
3128
3178
  'QuickPick.focusFirst': wrapCommand(focusFirst),
3129
3179
  'QuickPick.focusIndex': wrapCommand(focusIndex),
3130
3180
  'QuickPick.focusLast': wrapCommand(focusLast),
@@ -3133,19 +3183,20 @@ const commandMap = {
3133
3183
  'QuickPick.getCommandIds': getCommandIds,
3134
3184
  'QuickPick.getKeyBindings': getKeyBindings,
3135
3185
  'QuickPick.handleBeforeInput': wrapCommand(handleBeforeInput),
3136
- 'QuickPick.handleBlur': wrapCommand(handleBlur),
3186
+ 'QuickPick.handleBlur': wrapCommand(handleBlur$1),
3137
3187
  'QuickPick.handleClickAt': wrapCommand(handleClickAt),
3188
+ 'QuickPick.handleFocus': wrapCommand(handleBlur),
3138
3189
  'QuickPick.handleInput': wrapCommand(handleInput),
3139
3190
  'QuickPick.handleWheel': wrapCommand(handleWheel),
3140
3191
  'QuickPick.loadContent': wrapCommand(loadContent),
3141
3192
  'QuickPick.loadEntries2': load,
3142
3193
  'QuickPick.render': doRender,
3194
+ 'QuickPick.renderEventListeners': renderEventListeners,
3143
3195
  'QuickPick.selectCurrentIndex': wrapCommand(selectCurrentIndex),
3144
3196
  'QuickPick.selectIndex': wrapCommand(selectIndex),
3145
3197
  'QuickPick.selectItem': wrapCommand(selectItem),
3146
3198
  'QuickPick.setDeltaY': wrapCommand(setDeltaY),
3147
3199
  'QuickPick.setValue': wrapCommand(setValue),
3148
- 'QuickPick.renderEventListeners': renderEventListeners,
3149
3200
  // deprecated
3150
3201
  'SearchFile.filter': filterQuickPickItems,
3151
3202
  'SearchFile.searchFile': searchFile$5,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-search-worker",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "text-search"