@lvce-editor/file-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.
@@ -809,6 +809,9 @@ const createRpc = ipc => {
809
809
  },
810
810
  invokeAndTransfer(method, ...params) {
811
811
  return invokeAndTransfer(ipc, method, ...params);
812
+ },
813
+ async dispose() {
814
+ await ipc?.dispose();
812
815
  }
813
816
  };
814
817
  return rpc;
@@ -944,7 +947,7 @@ const getQuickPickProviderId = prefix => {
944
947
  }
945
948
  };
946
949
 
947
- const getVisibleItems$i = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
950
+ const getVisibleItems$i = (picks, icons) => {
948
951
  return [];
949
952
  };
950
953
 
@@ -1052,9 +1055,9 @@ const state$b = {
1052
1055
  provider: QuickPickNoop,
1053
1056
  prefix: 'string-that-should-never-match-another-string'
1054
1057
  };
1055
- const getVisibleItems$g = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
1058
+ const getVisibleItems$g = (picks, icons) => {
1056
1059
  const items = picks.map(pick => pick.pick);
1057
- const visibleItems = state$b.provider.getVisibleItems(items, minLineY, maxLineY, focusedIndex, setSize, icons);
1060
+ const visibleItems = state$b.provider.getVisibleItems(items, icons);
1058
1061
  return visibleItems;
1059
1062
  };
1060
1063
 
@@ -1148,7 +1151,7 @@ const getPickIcon$e = pick => {
1148
1151
  // @ts-ignore
1149
1152
  return provider.getPickIcon(pick);
1150
1153
  };
1151
- const getPickFileIcon$3 = pick => {
1154
+ const getPickFileIcon$2 = pick => {
1152
1155
  const {
1153
1156
  provider
1154
1157
  } = state$b;
@@ -1177,7 +1180,7 @@ const QuickPickEntriesEverything = {
1177
1180
  getLabel: getLabel$5,
1178
1181
  getNoResults: getNoResults$8,
1179
1182
  getPickDescription: getPickDescription$d,
1180
- getPickFileIcon: getPickFileIcon$3,
1183
+ getPickFileIcon: getPickFileIcon$2,
1181
1184
  getPickFilterValue: getPickFilterValue$8,
1182
1185
  getPickIcon: getPickIcon$e,
1183
1186
  getPickLabel: getPickLabel$e,
@@ -1387,7 +1390,6 @@ const getIconsCached = (paths, fileIconCache) => {
1387
1390
  return paths.map(path => fileIconCache[path]);
1388
1391
  };
1389
1392
 
1390
- const Directory = 3;
1391
1393
  const File$1 = 7;
1392
1394
 
1393
1395
  const getMissingIconRequests = (dirents, fileIconCache) => {
@@ -1600,53 +1602,47 @@ const getKeyBindings = () => {
1600
1602
  }];
1601
1603
  };
1602
1604
 
1603
- const InsertText = 'insertText';
1604
- const DeleteContentBackward = 'deleteContentBackward';
1605
- const DeleteContentForward = 'deleteContentForward';
1606
- const DeleteWordForward = 'deleteWordForward';
1607
- const DeleteWordBackward = 'deleteWordBackward';
1608
- const InsertLineBreak = 'insertLineBreak';
1609
- const InsertCompositionText = 'insertCompositionText';
1610
- const InsertFromPaste = 'insertFromPaste';
1611
-
1612
- const RE_ALPHA_NUMERIC = /[a-z\d]/i;
1613
- const isAlphaNumeric = character => {
1614
- return RE_ALPHA_NUMERIC.test(character);
1615
- };
1616
-
1617
- const getNewValueInsertText = (value, selectionStart, selectionEnd, data) => {
1618
- if (selectionStart === value.length) {
1619
- const newValue = value + data;
1605
+ const getNewValueDeleteContentBackward = (value, selectionStart, selectionEnd, data) => {
1606
+ const after = value.slice(selectionEnd);
1607
+ if (selectionStart === selectionEnd) {
1608
+ const before = value.slice(0, selectionStart - 1);
1609
+ const newValue = before + after;
1620
1610
  return {
1621
1611
  newValue,
1622
- cursorOffset: newValue.length
1612
+ cursorOffset: before.length
1623
1613
  };
1624
1614
  }
1625
1615
  const before = value.slice(0, selectionStart);
1626
- const after = value.slice(selectionEnd);
1627
- const newValue = before + data + after;
1616
+ const newValue = before + after;
1628
1617
  return {
1629
1618
  newValue,
1630
- cursorOffset: selectionStart + data.length
1619
+ cursorOffset: selectionStart
1631
1620
  };
1632
1621
  };
1633
- const getNewValueDeleteContentBackward = (value, selectionStart, selectionEnd, data) => {
1634
- const after = value.slice(selectionEnd);
1622
+
1623
+ const getNewValueDeleteContentForward = (value, selectionStart, selectionEnd, data) => {
1624
+ const before = value.slice(0, selectionStart);
1635
1625
  if (selectionStart === selectionEnd) {
1636
- const before = value.slice(0, selectionStart - 1);
1626
+ const after = value.slice(selectionEnd + 1);
1637
1627
  const newValue = before + after;
1638
1628
  return {
1639
1629
  newValue,
1640
- cursorOffset: before.length
1630
+ cursorOffset: selectionStart
1641
1631
  };
1642
1632
  }
1643
- const before = value.slice(0, selectionStart);
1633
+ const after = value.slice(selectionEnd);
1644
1634
  const newValue = before + after;
1645
1635
  return {
1646
1636
  newValue,
1647
1637
  cursorOffset: selectionStart
1648
1638
  };
1649
1639
  };
1640
+
1641
+ const RE_ALPHA_NUMERIC = /[a-z\d]/i;
1642
+ const isAlphaNumeric = character => {
1643
+ return RE_ALPHA_NUMERIC.test(character);
1644
+ };
1645
+
1650
1646
  const getNewValueDeleteWordBackward = (value, selectionStart, selectionEnd, data) => {
1651
1647
  const after = value.slice(selectionEnd);
1652
1648
  if (selectionStart === selectionEnd) {
@@ -1668,14 +1664,19 @@ const getNewValueDeleteWordBackward = (value, selectionStart, selectionEnd, data
1668
1664
  cursorOffset: selectionStart
1669
1665
  };
1670
1666
  };
1671
- const getNewValueDeleteContentForward = (value, selectionStart, selectionEnd, data) => {
1667
+
1668
+ const getNewValueDeleteWordForward = (value, selectionStart, selectionEnd, data) => {
1672
1669
  const before = value.slice(0, selectionStart);
1673
1670
  if (selectionStart === selectionEnd) {
1674
- const after = value.slice(selectionEnd + 1);
1671
+ let startIndex = Math.min(selectionStart + 1, value.length - 1);
1672
+ while (startIndex < value.length && isAlphaNumeric(value[startIndex])) {
1673
+ startIndex++;
1674
+ }
1675
+ const after = value.slice(startIndex);
1675
1676
  const newValue = before + after;
1676
1677
  return {
1677
1678
  newValue,
1678
- cursorOffset: selectionStart
1679
+ cursorOffset: before.length
1679
1680
  };
1680
1681
  }
1681
1682
  const after = value.slice(selectionEnd);
@@ -1685,36 +1686,44 @@ const getNewValueDeleteContentForward = (value, selectionStart, selectionEnd, da
1685
1686
  cursorOffset: selectionStart
1686
1687
  };
1687
1688
  };
1688
- const getNewValueDeleteWordForward = (value, selectionStart, selectionEnd, data) => {
1689
- const before = value.slice(0, selectionStart);
1690
- if (selectionStart === selectionEnd) {
1691
- let startIndex = Math.min(selectionStart + 1, value.length - 1);
1692
- while (startIndex < value.length && isAlphaNumeric(value[startIndex])) {
1693
- startIndex++;
1694
- }
1695
- const after = value.slice(startIndex);
1696
- const newValue = before + after;
1689
+
1690
+ const getNewValueInsertText = (value, selectionStart, selectionEnd, data) => {
1691
+ if (selectionStart === value.length) {
1692
+ const newValue = value + data;
1697
1693
  return {
1698
1694
  newValue,
1699
- cursorOffset: before.length
1695
+ cursorOffset: newValue.length
1700
1696
  };
1701
1697
  }
1698
+ const before = value.slice(0, selectionStart);
1702
1699
  const after = value.slice(selectionEnd);
1703
- const newValue = before + after;
1700
+ const newValue = before + data + after;
1704
1701
  return {
1705
1702
  newValue,
1706
- cursorOffset: selectionStart
1703
+ cursorOffset: selectionStart + data.length
1707
1704
  };
1708
1705
  };
1706
+
1709
1707
  const getNewValueInsertCompositionText = (value, selectionStart, selectionEnd, data) => {
1710
1708
  return getNewValueInsertText(value, selectionStart, selectionEnd, data);
1711
1709
  };
1710
+
1712
1711
  const getNewValueInsertLineBreak = (value, selectionStart, selectionEnd, data) => {
1713
1712
  return {
1714
1713
  newValue: value,
1715
1714
  cursorOffset: selectionEnd
1716
1715
  };
1717
1716
  };
1717
+
1718
+ const InsertText = 'insertText';
1719
+ const DeleteContentBackward = 'deleteContentBackward';
1720
+ const DeleteContentForward = 'deleteContentForward';
1721
+ const DeleteWordForward = 'deleteWordForward';
1722
+ const DeleteWordBackward = 'deleteWordBackward';
1723
+ const InsertLineBreak = 'insertLineBreak';
1724
+ const InsertCompositionText = 'insertCompositionText';
1725
+ const InsertFromPaste = 'insertFromPaste';
1726
+
1718
1727
  const getNewValueFunction = inputType => {
1719
1728
  switch (inputType) {
1720
1729
  case InsertFromPaste:
@@ -2145,15 +2154,27 @@ const add = menuEntries => {
2145
2154
  state$9.menuEntries = [...state$9.menuEntries, ...menuEntries];
2146
2155
  };
2147
2156
 
2148
- const getVisible = (provider, items, minLineY, maxLineY, focusedIndex, icons) => {
2149
- const setSize = items.length;
2157
+ const getVisible$1 = (provider, items, minLineY, maxLineY, icons) => {
2150
2158
  const range = items.slice(minLineY, maxLineY);
2151
- const visibleItems = provider.getVisibleItems(range, minLineY, maxLineY, focusedIndex, setSize, icons);
2159
+ const protoVisibleItems = provider.getVisibleItems(range, icons);
2160
+ return protoVisibleItems;
2161
+ };
2162
+
2163
+ const getVisible = (setSize, protoVisibleItems, minLineY, focusedIndex) => {
2164
+ const visibleItems = protoVisibleItems.map((visibleItem, i) => {
2165
+ return {
2166
+ ...visibleItem,
2167
+ posInSet: minLineY + i + 1,
2168
+ setSize,
2169
+ isActive: i === focusedIndex
2170
+ };
2171
+ });
2152
2172
  return visibleItems;
2153
2173
  };
2154
2174
 
2155
2175
  const createQuickPickViewModel = (oldState, newState) => {
2156
- const visibleItems = getVisible(newState.provider, newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.icons);
2176
+ const protoVisibleItems = getVisible$1(newState.provider, newState.items, newState.minLineY, newState.maxLineY, newState.icons);
2177
+ const visibleItems = getVisible(newState.items.length, protoVisibleItems, newState.minLineY, newState.focusedIndex);
2157
2178
  const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
2158
2179
  const newFocusedIndex = newState.focusedIndex - newState.minLineY;
2159
2180
  const maxLineY = Math.min(newState.maxLineY, newState.items.length);
@@ -2567,17 +2588,17 @@ const getPickIcon$d = pick => {
2567
2588
  const getPickLabel$d = pick => {
2568
2589
  return pick;
2569
2590
  };
2570
- const getVisibleItems$f = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
2571
- const visibleItems = picks.map((pick, index) => ({
2572
- description: getPickDescription$c(),
2573
- fileIcon: '',
2574
- icon: getPickIcon$d(),
2575
- isActive: index + minLineY === focusedIndex,
2576
- label: getPickLabel$d(pick),
2577
- matches: [],
2578
- posInSet: index + minLineY + 1,
2579
- setSize
2580
- }));
2591
+ const getVisibleItems$f = (picks, icons) => {
2592
+ const visibleItems = picks.map((item, index) => {
2593
+ const pick = item.pick;
2594
+ return {
2595
+ description: getPickDescription$c(),
2596
+ fileIcon: '',
2597
+ icon: getPickIcon$d(),
2598
+ label: getPickLabel$d(pick),
2599
+ matches: []
2600
+ };
2601
+ });
2581
2602
  return visibleItems;
2582
2603
  };
2583
2604
 
@@ -2680,17 +2701,17 @@ const getPickIcon$b = () => {
2680
2701
  const getPickLabel$b = pick => {
2681
2702
  return pick.label;
2682
2703
  };
2683
- const getVisibleItems$d = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
2684
- const visibleItems = picks.map((pick, index) => ({
2685
- description: pick.description || '',
2686
- fileIcon: '',
2687
- icon: getPickIcon$b(),
2688
- isActive: index + minLineY === focusedIndex,
2689
- label: getPickLabel$b(pick),
2690
- matches: [],
2691
- posInSet: index + minLineY + 1,
2692
- setSize
2693
- }));
2704
+ const getVisibleItems$d = (picks, icons) => {
2705
+ const visibleItems = picks.map((item, index) => {
2706
+ const pick = item;
2707
+ return {
2708
+ description: pick.description || '',
2709
+ fileIcon: '',
2710
+ icon: getPickIcon$b(),
2711
+ label: getPickLabel$b(pick),
2712
+ matches: []
2713
+ };
2714
+ });
2694
2715
  return visibleItems;
2695
2716
  };
2696
2717
 
@@ -2854,16 +2875,13 @@ const convertIcon$1 = icon => {
2854
2875
  const getPickIcon$9 = pick => {
2855
2876
  return convertIcon$1(pick.icon);
2856
2877
  };
2857
- const getVisibleItems$b = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
2858
- const visibleItems = picks.slice(minLineY, maxLineY + 1).map((pick, index) => ({
2878
+ const getVisibleItems$b = (picks, icons) => {
2879
+ const visibleItems = picks.map((pick, index) => ({
2859
2880
  description: getPickDescription$9(pick),
2860
2881
  fileIcon: '',
2861
2882
  icon: getPickIcon$9(pick),
2862
- isActive: index + minLineY === focusedIndex,
2863
2883
  label: getPickLabel$9(pick),
2864
- matches: [],
2865
- posInSet: index + minLineY + 1,
2866
- setSize
2884
+ matches: []
2867
2885
  }));
2868
2886
  return visibleItems;
2869
2887
  };
@@ -2966,7 +2984,7 @@ const getProtocol = uri => {
2966
2984
  return '';
2967
2985
  };
2968
2986
 
2969
- const getVisibleItems$9 = (files, minLineY, maxLineY, focusedIndex, setSize, icons) => {
2987
+ const getVisibleItems$9 = (files, icons) => {
2970
2988
  const visibleItems = files.map((item, i) => {
2971
2989
  const pick = item.pick;
2972
2990
  const label = getPickLabel$7(pick);
@@ -2978,9 +2996,6 @@ const getVisibleItems$9 = (files, minLineY, maxLineY, focusedIndex, setSize, ico
2978
2996
  description,
2979
2997
  icon,
2980
2998
  fileIcon,
2981
- posInSet: minLineY + i + 1,
2982
- setSize,
2983
- isActive: i === focusedIndex,
2984
2999
  matches: item.matches
2985
3000
  };
2986
3001
  });
@@ -3093,7 +3108,7 @@ const getPickDescription$6 = pick => {
3093
3108
  const getPickIcon$6 = () => {
3094
3109
  return '';
3095
3110
  };
3096
- const getPickFileIcon$2 = pick => {
3111
+ const getPickFileIcon$1 = pick => {
3097
3112
  if (typeof pick === 'object') {
3098
3113
  pick = pick.pick;
3099
3114
  }
@@ -3121,7 +3136,7 @@ const QuickPickEntriesFile = {
3121
3136
  getLabel: getLabel$1,
3122
3137
  getNoResults: getNoResults$4,
3123
3138
  getPickDescription: getPickDescription$6,
3124
- getPickFileIcon: getPickFileIcon$2,
3139
+ getPickFileIcon: getPickFileIcon$1,
3125
3140
  getPickFilterValue: getPickFilterValue$4,
3126
3141
  getPickIcon: getPickIcon$6,
3127
3142
  getPickLabel: getPickLabel$6,
@@ -3147,29 +3162,18 @@ const getPickIcon$5 = () => {
3147
3162
  const getPickLabel$5 = pick => {
3148
3163
  return pathBaseName(pick);
3149
3164
  };
3150
- const getPickFileIcon$1 = pick => {
3151
- if (typeof pick === 'object') {
3152
- pick = pick.pick;
3153
- }
3154
- if (typeof pick === 'object') {
3155
- pick = pick.pick;
3156
- }
3157
- return {
3158
- type: Directory,
3159
- name: pick
3160
- };
3161
- };
3162
- const getVisibleItems$7 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
3163
- const visibleItems = picks.map((pick, index) => ({
3164
- description: getPickDescription$5(pick),
3165
- fileIcon: getPickFileIcon$1(pick),
3166
- icon: getPickIcon$5(),
3167
- isActive: index + minLineY === focusedIndex,
3168
- label: getPickLabel$5(pick),
3169
- matches: [],
3170
- posInSet: index + minLineY + 1,
3171
- setSize
3172
- }));
3165
+ const getVisibleItems$7 = (picks, icons) => {
3166
+ const visibleItems = picks.map((item, index) => {
3167
+ const pick = item.pick;
3168
+ const fileIcon = icons[index];
3169
+ return {
3170
+ description: getPickDescription$5(pick),
3171
+ fileIcon,
3172
+ icon: getPickIcon$5(),
3173
+ label: getPickLabel$5(pick),
3174
+ matches: pick.matches || []
3175
+ };
3176
+ });
3173
3177
  return visibleItems;
3174
3178
  };
3175
3179
 
@@ -3230,9 +3234,11 @@ const getPickFileIcon = pick => {
3230
3234
  if (typeof pick === 'object') {
3231
3235
  pick = pick.pick;
3232
3236
  }
3237
+ const baseName = pathBaseName(pick);
3233
3238
  return {
3234
- type: Directory,
3235
- name: pick
3239
+ type: File$1,
3240
+ name: baseName,
3241
+ path: pick
3236
3242
  };
3237
3243
  };
3238
3244
  const state$3 = {};
@@ -3260,7 +3266,7 @@ const QuickPickEntriesOpenRecent = {
3260
3266
  state: state$3
3261
3267
  };
3262
3268
 
3263
- const getVisibleItems$5 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
3269
+ const getVisibleItems$5 = picks => {
3264
3270
  return [];
3265
3271
  };
3266
3272
 
@@ -3329,16 +3335,13 @@ const getPickIcon$2 = value => {
3329
3335
  const getPickLabel$2 = value => {
3330
3336
  return value;
3331
3337
  };
3332
- const getVisibleItems$3 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
3338
+ const getVisibleItems$3 = picks => {
3333
3339
  const visibleItems = picks.map((pick, index) => ({
3334
3340
  description: getPickDescription$2(),
3335
3341
  fileIcon: '',
3336
3342
  icon: getPickIcon$2(),
3337
- isActive: index + minLineY === focusedIndex,
3338
3343
  label: getPickLabel$2(pick),
3339
- matches: [],
3340
- posInSet: index + minLineY + 1,
3341
- setSize
3344
+ matches: []
3342
3345
  }));
3343
3346
  return visibleItems;
3344
3347
  };
@@ -3406,16 +3409,13 @@ const QuickPickEntriesView = {
3406
3409
  state: state$1
3407
3410
  };
3408
3411
 
3409
- const getVisibleItems$1 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
3412
+ const getVisibleItems$1 = picks => {
3410
3413
  const visibleItems = picks.map((pick, index) => ({
3411
3414
  description: '',
3412
3415
  fileIcon: '',
3413
3416
  icon: '',
3414
- isActive: index + minLineY === focusedIndex,
3415
3417
  label: pick.label || '',
3416
- matches: [],
3417
- posInSet: index + minLineY + 1,
3418
- setSize
3418
+ matches: []
3419
3419
  }));
3420
3420
  return visibleItems;
3421
3421
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-search-worker",
3
- "version": "5.2.0",
3
+ "version": "5.4.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "text-search"