@lvce-editor/file-search-worker 4.2.0 → 4.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.
@@ -1778,7 +1778,7 @@ const handleWheel = (state, deltaMode, deltaY) => {
1778
1778
  return setDeltaY(state, state.deltaY + deltaY);
1779
1779
  };
1780
1780
 
1781
- const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, renderAllItems) => {
1781
+ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) => {
1782
1782
  const state = {
1783
1783
  uid,
1784
1784
  state: Default$1,
@@ -1806,8 +1806,7 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, r
1806
1806
  args,
1807
1807
  focused: false,
1808
1808
  platform,
1809
- value: '',
1810
- renderAllItems
1809
+ value: ''
1811
1810
  };
1812
1811
  set(uid, state, state);
1813
1812
  };
@@ -2091,7 +2090,7 @@ const focusPrevious = state => {
2091
2090
  return focusIndex(state, previousIndex);
2092
2091
  };
2093
2092
 
2094
- const commandIds = ['focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleBeforeInput', 'handleBlur', 'handleClickAt', 'handleInput', 'handleWheel', 'dispose', 'renderEventListeners', 'selectCurrentIndex', 'selectIndex', 'selectItem', 'setValue'];
2093
+ const commandIds = ['dispose', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleBeforeInput', 'handleBlur', 'handleClickAt', 'handleFocus', 'handleInput', 'handleWheel', 'renderEventListeners', 'selectCurrentIndex', 'selectIndex', 'selectItem', 'setValue'];
2095
2094
 
2096
2095
  const getCommandIds = () => {
2097
2096
  return commandIds;
@@ -2144,6 +2143,11 @@ const InsertLineBreak = 'insertLineBreak';
2144
2143
  const InsertCompositionText = 'insertCompositionText';
2145
2144
  const InsertFromPaste = 'insertFromPaste';
2146
2145
 
2146
+ const RE_ALPHA_NUMERIC = /[a-z\d]/i;
2147
+ const isAlphaNumeric = character => {
2148
+ return RE_ALPHA_NUMERIC.test(character);
2149
+ };
2150
+
2147
2151
  const getNewValueInsertText = (value, selectionStart, selectionEnd, data) => {
2148
2152
  if (selectionStart === value.length) {
2149
2153
  const newValue = value + data;
@@ -2177,10 +2181,6 @@ const getNewValueDeleteContentBackward = (value, selectionStart, selectionEnd, d
2177
2181
  cursorOffset: selectionStart
2178
2182
  };
2179
2183
  };
2180
- const RE_ALPHA_NUMERIC = /[a-z\d]/i;
2181
- const isAlphaNumeric = character => {
2182
- return RE_ALPHA_NUMERIC.test(character);
2183
- };
2184
2184
  const getNewValueDeleteWordBackward = (value, selectionStart, selectionEnd, data) => {
2185
2185
  const after = value.slice(selectionEnd);
2186
2186
  if (selectionStart === selectionEnd) {
@@ -2322,7 +2322,7 @@ const handleBeforeInput = (state, inputType, data, selectionStart, selectionEnd)
2322
2322
  return handleInput(state, newValue, cursorOffset, User);
2323
2323
  };
2324
2324
 
2325
- const handleBlur = async state => {
2325
+ const handleBlur$1 = async state => {
2326
2326
  // TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
2327
2327
  // await CloseWidget.closeWidget(state.uid)
2328
2328
  return state;
@@ -2389,6 +2389,17 @@ const handleClickAt = (state, x, y) => {
2389
2389
  return selectIndex(state, index);
2390
2390
  };
2391
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
+
2392
2403
  const getDefaultValue = uri => {
2393
2404
  switch (uri) {
2394
2405
  case 'quickPick://everything':
@@ -2573,6 +2584,13 @@ const getIconRequests = (items, provider) => {
2573
2584
  return iconRequests;
2574
2585
  };
2575
2586
 
2587
+ const getPickDescription$3 = (provider, pick) => {
2588
+ if (provider.getPickDescription) {
2589
+ return provider.getPickDescription(pick);
2590
+ }
2591
+ return '';
2592
+ };
2593
+
2576
2594
  const requestFileIcons = async requests => {
2577
2595
  const promises = requests.map(request => {
2578
2596
  if (!request.name) {
@@ -2587,12 +2605,6 @@ const requestFileIcons = async requests => {
2587
2605
  return Promise.all(promises);
2588
2606
  };
2589
2607
 
2590
- const getPickDescription$3 = (provider, pick) => {
2591
- if (provider.getPickDescription) {
2592
- return provider.getPickDescription(pick);
2593
- }
2594
- return '';
2595
- };
2596
2608
  const getVisible = async (provider, items, minLineY, maxLineY, focusedIndex) => {
2597
2609
  const visibleItems = [];
2598
2610
  const setSize = items.length;
@@ -2636,8 +2648,7 @@ const createQuickPickViewModel = async (oldState, newState) => {
2636
2648
  height,
2637
2649
  oldFocusedIndex,
2638
2650
  newFocusedIndex,
2639
- uid: newState.uid,
2640
- renderAllItems: newState.renderAllItems
2651
+ uid: newState.uid
2641
2652
  };
2642
2653
  };
2643
2654
 
@@ -2660,11 +2671,7 @@ const renderCursorOffset = newState => {
2660
2671
  const QuickPickInput = 'QuickPickInput';
2661
2672
 
2662
2673
  const renderFocus = newState => {
2663
- if (newState.renderAllItems) {
2664
- return ['Viewlet.focusElementByName', QuickPickInput];
2665
- }
2666
- const selector = newState.focused ? '.InputBox' : '';
2667
- return ['Viewlet.focusSelector', selector];
2674
+ return ['Viewlet.focusElementByName', QuickPickInput];
2668
2675
  };
2669
2676
 
2670
2677
  const renderFocusedIndex = newState => {
@@ -2696,21 +2703,52 @@ const QuickPickItemLabel = 'QuickPickItemLabel';
2696
2703
  const QuickPickItems$1 = 'QuickPickItems';
2697
2704
  const Viewlet = 'Viewlet';
2698
2705
 
2706
+ const HandleBeforeInput = 'handleBeforeInput';
2707
+ const HandleBlur = 'handleBlur';
2708
+ const HandleFocus = 'handleFocus';
2709
+ const HandleInput = 'handleInput';
2710
+ const HandlePointerDown = 'handlePointerDown';
2711
+ const HandleWheel = 'handleWheel';
2712
+
2713
+ const QuickPick = 'QuickPick';
2714
+ const QuickPickItems = 'QuickPickItems';
2715
+ const QuickPickItemActive = 'QuickPickItemActive';
2716
+
2699
2717
  const Div$1 = 4;
2700
2718
  const Input$1 = 6;
2701
2719
  const Span$1 = 8;
2702
2720
  const Img$1 = 17;
2703
2721
 
2704
- const getFileIconVirtualDom = icon => {
2722
+ const getQuickPickInputVirtualDom = () => {
2723
+ const ariaLabel = typeNameofCommandToRun();
2705
2724
  return {
2706
- type: Img$1,
2707
- className: FileIcon,
2708
- src: icon,
2709
- role: None$1,
2710
- childCount: 0
2725
+ type: Input$1,
2726
+ className: InputBox,
2727
+ spellcheck: false,
2728
+ autocapitalize: 'off',
2729
+ inputType: 'text',
2730
+ childCount: 0,
2731
+ role: ComboBox,
2732
+ name: QuickPickInput,
2733
+ onBeforeInput: HandleBeforeInput,
2734
+ onBlur: HandleBlur,
2735
+ onInput: HandleInput,
2736
+ onFocus: HandleFocus,
2737
+ ariaLabel: ariaLabel,
2738
+ ariaAutoComplete: 'list',
2739
+ ariaExpanded: true,
2740
+ autocomplete: 'off'
2711
2741
  };
2712
2742
  };
2713
2743
 
2744
+ const getQuickPickHeaderVirtualDom = () => {
2745
+ return [{
2746
+ type: Div$1,
2747
+ className: QuickPickHeader,
2748
+ childCount: 1
2749
+ }, getQuickPickInputVirtualDom()];
2750
+ };
2751
+
2714
2752
  var __defProp = Object.defineProperty;
2715
2753
  var __export = (target, all) => {
2716
2754
  for (var name in all) __defProp(target, name, {
@@ -2878,6 +2916,17 @@ const addHighlights = (dom, highlights, label) => {
2878
2916
  dom.push(text(afterText));
2879
2917
  }
2880
2918
  };
2919
+
2920
+ const getFileIconVirtualDom = icon => {
2921
+ return {
2922
+ type: Img$1,
2923
+ className: FileIcon,
2924
+ src: icon,
2925
+ role: None$1,
2926
+ childCount: 0
2927
+ };
2928
+ };
2929
+
2881
2930
  const getQuickPickItemVirtualDom = visibleItem => {
2882
2931
  const {
2883
2932
  posInSet,
@@ -2948,40 +2997,6 @@ const getQuickPickItemsVirtualDom = visibleItems => {
2948
2997
  return dom;
2949
2998
  };
2950
2999
 
2951
- const HandlePointerDown = 'handlePointerDown';
2952
- const HandleWheel = 'handleWheel';
2953
- const HandleBlur = 'handleBlur';
2954
- const HandleBeforeInput = 'handleBeforeInput';
2955
- const HandleInput = 'handleInput';
2956
-
2957
- const QuickPick = 'QuickPick';
2958
- const QuickPickItems = 'QuickPickItems';
2959
- const QuickPickItemActive = 'QuickPickItemActive';
2960
-
2961
- const getQuickPickHeaderVirtualDom = () => {
2962
- const ariaLabel = typeNameofCommandToRun();
2963
- return [{
2964
- type: Div$1,
2965
- className: QuickPickHeader,
2966
- childCount: 1
2967
- }, {
2968
- type: Input$1,
2969
- className: InputBox,
2970
- spellcheck: false,
2971
- autocapitalize: 'off',
2972
- inputType: 'text',
2973
- childCount: 0,
2974
- role: ComboBox,
2975
- name: QuickPickInput,
2976
- onBeforeInput: HandleBeforeInput,
2977
- onBlur: HandleBlur,
2978
- onInput: HandleInput,
2979
- ariaLabel: ariaLabel,
2980
- ariaAutoComplete: 'list',
2981
- ariaExpanded: true
2982
- }];
2983
- };
2984
-
2985
3000
  const getQuickPickVirtualDom = visibleItems => {
2986
3001
  const quickOpen$1 = quickOpen();
2987
3002
  return [{
@@ -2995,19 +3010,15 @@ const getQuickPickVirtualDom = visibleItems => {
2995
3010
  className: QuickPickItems$1,
2996
3011
  id: QuickPickItems,
2997
3012
  role: ListBox,
2998
- ariaActiveDescendant: QuickPickItemActive,
3013
+ ariaActivedescendant: QuickPickItemActive,
2999
3014
  onWheel: HandleWheel,
3000
3015
  childCount: visibleItems.length
3001
3016
  }, ...getQuickPickItemsVirtualDom(visibleItems)];
3002
3017
  };
3003
3018
 
3004
3019
  const renderItems = newState => {
3005
- if (newState.renderAllItems) {
3006
- const dom = getQuickPickVirtualDom(newState.visibleItems);
3007
- return ['Viewlet.setDom2', dom];
3008
- }
3009
- const dom = getQuickPickItemsVirtualDom(newState.visibleItems);
3010
- return ['Viewlet.send', newState.uid, /* method */'setItemsDom', dom];
3020
+ const dom = getQuickPickVirtualDom(newState.visibleItems);
3021
+ return ['Viewlet.setDom2', dom];
3011
3022
  };
3012
3023
 
3013
3024
  const renderValue = newState => {
@@ -3037,10 +3048,10 @@ const applyRender = async (oldState, newState, diffResult) => {
3037
3048
  const commands = [];
3038
3049
  const viewModel = await createQuickPickViewModel(oldState, newState);
3039
3050
  for (const item of diffResult) {
3040
- if (viewModel.renderAllItems && item === Height) {
3051
+ if (item === Height) {
3041
3052
  continue;
3042
3053
  }
3043
- if (viewModel.renderAllItems && item === RenderFocusedIndex) {
3054
+ if (item === RenderFocusedIndex) {
3044
3055
  continue;
3045
3056
  }
3046
3057
  const fn = getRenderer(item);
@@ -3114,6 +3125,9 @@ const renderEventListeners = () => {
3114
3125
  }, {
3115
3126
  name: HandleInput,
3116
3127
  params: ['handleInput', 'event.target.value']
3128
+ }, {
3129
+ name: HandleFocus,
3130
+ params: ['handleFocus']
3117
3131
  }];
3118
3132
  };
3119
3133
 
@@ -3153,6 +3167,7 @@ const wrapCommand = fn => {
3153
3167
  const commandMap = {
3154
3168
  'QuickPick.addMenuEntries': add,
3155
3169
  'QuickPick.create2': create,
3170
+ 'QuickPick.dispose': dispose,
3156
3171
  'QuickPick.focusFirst': wrapCommand(focusFirst),
3157
3172
  'QuickPick.focusIndex': wrapCommand(focusIndex),
3158
3173
  'QuickPick.focusLast': wrapCommand(focusLast),
@@ -3161,20 +3176,20 @@ const commandMap = {
3161
3176
  'QuickPick.getCommandIds': getCommandIds,
3162
3177
  'QuickPick.getKeyBindings': getKeyBindings,
3163
3178
  'QuickPick.handleBeforeInput': wrapCommand(handleBeforeInput),
3164
- 'QuickPick.handleBlur': wrapCommand(handleBlur),
3165
- 'QuickPick.dispose': dispose,
3179
+ 'QuickPick.handleBlur': wrapCommand(handleBlur$1),
3166
3180
  'QuickPick.handleClickAt': wrapCommand(handleClickAt),
3181
+ 'QuickPick.handleFocus': wrapCommand(handleBlur),
3167
3182
  'QuickPick.handleInput': wrapCommand(handleInput),
3168
3183
  'QuickPick.handleWheel': wrapCommand(handleWheel),
3169
3184
  'QuickPick.loadContent': wrapCommand(loadContent),
3170
3185
  'QuickPick.loadEntries2': load,
3171
3186
  'QuickPick.render': doRender,
3187
+ 'QuickPick.renderEventListeners': renderEventListeners,
3172
3188
  'QuickPick.selectCurrentIndex': wrapCommand(selectCurrentIndex),
3173
3189
  'QuickPick.selectIndex': wrapCommand(selectIndex),
3174
3190
  'QuickPick.selectItem': wrapCommand(selectItem),
3175
3191
  'QuickPick.setDeltaY': wrapCommand(setDeltaY),
3176
3192
  'QuickPick.setValue': wrapCommand(setValue),
3177
- 'QuickPick.renderEventListeners': renderEventListeners,
3178
3193
  // deprecated
3179
3194
  'SearchFile.filter': filterQuickPickItems,
3180
3195
  '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.2.0",
3
+ "version": "4.4.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "text-search"