@lvce-editor/text-search-view 1.14.3 → 1.16.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.
@@ -4,7 +4,7 @@
4
4
  "description": "Configures glob patterns for excluding files and folders from text search results.",
5
5
  "heading": "Exclude",
6
6
  "id": "search.exclude",
7
- "type": 4,
7
+ "type": "array",
8
8
  "value": {}
9
9
  },
10
10
  {
@@ -13,7 +13,7 @@
13
13
  "heading": "Search Threads",
14
14
  "id": "search.threads",
15
15
  "minimum": 1,
16
- "type": 5,
16
+ "type": "number",
17
17
  "value": 1
18
18
  }
19
19
  ]
@@ -3733,7 +3733,7 @@ const handleUpdateError = async (state, update, error) => {
3733
3733
  ...state,
3734
3734
  ...update
3735
3735
  };
3736
- const message = `${error}`;
3736
+ const message = String(error);
3737
3737
  const messageHeight = await getSearchMessageHeight(message, partialNewState.width, partialNewState.flags);
3738
3738
  const headerHeight = partialNewState.headerHeight + messageHeight - partialNewState.messageHeight;
3739
3739
  return {
@@ -4014,7 +4014,7 @@ const handleUpdateIncremental = async (state, update) => {
4014
4014
  return state;
4015
4015
  };
4016
4016
 
4017
- const getsearchid = () => {
4017
+ const getSearchId = () => {
4018
4018
  return crypto.randomUUID();
4019
4019
  };
4020
4020
  const handleUpdatePullBased = async (state, update) => {
@@ -4022,7 +4022,7 @@ const handleUpdatePullBased = async (state, update) => {
4022
4022
  uid: previousUid,
4023
4023
  workspacePath
4024
4024
  } = state;
4025
- const searchId = getsearchid();
4025
+ const searchId = getSearchId();
4026
4026
  const partialNewState = {
4027
4027
  ...state,
4028
4028
  ...update,
@@ -5183,46 +5183,6 @@ const handleWorkspaceChange = (state, workspacePath) => {
5183
5183
  };
5184
5184
  };
5185
5185
 
5186
- const send$2 = async port => {
5187
- await sendMessagePortToIconThemeWorker(port, 0);
5188
- };
5189
- const launchIconThemeWorker = async () => {
5190
- // TODO connect to icon theme worker
5191
- const rpc = await create$5({
5192
- commandMap: {},
5193
- send: send$2
5194
- });
5195
- return rpc;
5196
- };
5197
-
5198
- const initializeIconThemeWorker = async () => {
5199
- const rpc = await launchIconThemeWorker();
5200
- set$6(rpc);
5201
- };
5202
-
5203
- const commandMap$1 = {
5204
- 'TextSearch.handlePullResultsFound': wrapCommand(handlePullResultsFound)
5205
- };
5206
-
5207
- const send$1 = async port => {
5208
- await sendMessagePortToTextSearchWorker(port, 0);
5209
- };
5210
- const launchTextSearchWorker = async () => {
5211
- return create$5({
5212
- commandMap: commandMap$1,
5213
- send: send$1
5214
- });
5215
- };
5216
-
5217
- const initializeTextSearchWorker = async () => {
5218
- const rpc = await launchTextSearchWorker();
5219
- set$3(rpc);
5220
- };
5221
-
5222
- const initialize = async () => {
5223
- await Promise.all([initializeTextSearchWorker(), initializeIconThemeWorker()]);
5224
- };
5225
-
5226
5186
  // TODO optimize this function to return the minimum number
5227
5187
  // of visible items needed, e.g. when not scrolled 5 items with
5228
5188
  // 20px fill 100px but when scrolled 6 items are needed
@@ -5675,9 +5635,20 @@ const getUsePullBasedSearch = async () => {
5675
5635
  }
5676
5636
  };
5677
5637
 
5638
+ const loadPreferences = async currentDefaultExcludes => {
5639
+ const [defaultExcludes, usePullBasedSearch] = await Promise.all([getSearchExcludes(currentDefaultExcludes), getUsePullBasedSearch()]);
5640
+ return {
5641
+ defaultExcludes,
5642
+ usePullBasedSearch
5643
+ };
5644
+ };
5645
+
5678
5646
  const hasProperty = (object, key) => {
5679
5647
  return !!object && typeof object === 'object' && key in object;
5680
5648
  };
5649
+ const hasStringProperty = (object, key) => {
5650
+ return hasProperty(object, key) && typeof object[key] === 'string';
5651
+ };
5681
5652
 
5682
5653
  const getSavedFocus = savedState => {
5683
5654
  if (hasProperty(savedState, 'focus') && typeof savedState.focus === 'number') {
@@ -5703,13 +5674,13 @@ const getSavedHistory = savedState => {
5703
5674
  };
5704
5675
 
5705
5676
  const getSavedValue = savedState => {
5706
- if (hasProperty(savedState, 'value') && typeof savedState.value === 'string') {
5677
+ if (hasStringProperty(savedState, 'value')) {
5707
5678
  return savedState.value;
5708
5679
  }
5709
5680
  return '';
5710
5681
  };
5711
5682
  const getSavedReplacement = savedState => {
5712
- if (hasProperty(savedState, 'replacement') && typeof savedState.replacement === 'string') {
5683
+ if (hasStringProperty(savedState, 'replacement')) {
5713
5684
  return savedState.replacement;
5714
5685
  }
5715
5686
  return '';
@@ -5721,13 +5692,13 @@ const getSavedFlags = savedState => {
5721
5692
  return UseIgnoreFiles;
5722
5693
  };
5723
5694
  const getSavedIncludeValue = savedState => {
5724
- if (hasProperty(savedState, 'includeValue') && typeof savedState.includeValue === 'string') {
5695
+ if (hasStringProperty(savedState, 'includeValue')) {
5725
5696
  return savedState.includeValue;
5726
5697
  }
5727
5698
  return '';
5728
5699
  };
5729
5700
  const getSavedExcludeValue = savedState => {
5730
- if (hasProperty(savedState, 'excludeValue') && typeof savedState.excludeValue === 'string') {
5701
+ if (hasStringProperty(savedState, 'excludeValue')) {
5731
5702
  return savedState.excludeValue;
5732
5703
  }
5733
5704
  return '';
@@ -5770,8 +5741,10 @@ const loadContent = async (state, savedState) => {
5770
5741
  savedValue,
5771
5742
  threads
5772
5743
  } = restoreState(savedState);
5773
- const defaultExcludes = await getSearchExcludes(currentDefaultExcludes);
5774
- const usePullBasedSearch = await getUsePullBasedSearch();
5744
+ const {
5745
+ defaultExcludes,
5746
+ usePullBasedSearch
5747
+ } = await loadPreferences(currentDefaultExcludes);
5775
5748
  const warningHeight = await getSearchWarningMessageHeight(limitHitWarning, width);
5776
5749
  const headerHeight = getSearchHeaderHeight(flags, messageHeight, warningHeight);
5777
5750
  const update = {
@@ -5896,7 +5869,7 @@ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPat
5896
5869
  const index = originalResults.indexOf(results[i]);
5897
5870
  const matchCount = getMatchCount(originalResults, index);
5898
5871
  const expanded = collapsedPaths.includes(path) ? Collapsed : Expanded;
5899
- const badgeText = `${matchCount}`;
5872
+ const badgeText = String(matchCount);
5900
5873
  const depth = 0;
5901
5874
  const indent = getTreeItemIndent(depth);
5902
5875
  return {
@@ -6196,24 +6169,31 @@ const HandleInputSelectionChange = 21;
6196
6169
  const HandleActionClick = 22;
6197
6170
  const HandleOpenFolderClick = 23;
6198
6171
 
6172
+ const parentNode = {
6173
+ childCount: 2,
6174
+ className: mergeClassNames(ViewletSearchMessage, ViewletSearchMessageIndented, SearchWorkspaceMessage),
6175
+ type: Div
6176
+ };
6177
+ const actionNode = {
6178
+ childCount: 1,
6179
+ className: mergeClassNames(MessageAction, SearchWorkspaceMessageAction),
6180
+ onClick: HandleOpenFolderClick,
6181
+ type: Button$2
6182
+ };
6199
6183
  const getNoWorkspaceMessageVirtualDom = workspacePath => {
6200
6184
  if (workspacePath !== '') {
6201
6185
  return [];
6202
6186
  }
6203
- return [{
6204
- childCount: 2,
6205
- className: mergeClassNames(ViewletSearchMessage, ViewletSearchMessageIndented, SearchWorkspaceMessage),
6206
- type: Div
6207
- }, text(`${noWorkspaceFolder()} - `), {
6208
- childCount: 1,
6209
- className: mergeClassNames(MessageAction, SearchWorkspaceMessageAction),
6210
- onClick: HandleOpenFolderClick,
6211
- type: Button$2
6212
- }, text(openFolder$1())];
6187
+ return [parentNode, text(`${noWorkspaceFolder()} - `), actionNode, text(openFolder$1())];
6213
6188
  };
6214
6189
 
6215
6190
  const Focusable = 0;
6216
6191
 
6192
+ const iconNode = {
6193
+ childCount: 0,
6194
+ className: mergeClassNames(MaskIcon, MaskIconEllipsis),
6195
+ type: Div
6196
+ };
6217
6197
  const getSearchDetailsToggleVirtualDom = () => {
6218
6198
  return [{
6219
6199
  ariaLabel: toggleSearchDetails(),
@@ -6225,11 +6205,7 @@ const getSearchDetailsToggleVirtualDom = () => {
6225
6205
  tabIndex: Focusable,
6226
6206
  title: toggleSearchDetails(),
6227
6207
  type: Button$2
6228
- }, {
6229
- childCount: 0,
6230
- className: mergeClassNames(MaskIcon, MaskIconEllipsis),
6231
- type: Div
6232
- }];
6208
+ }, iconNode];
6233
6209
  };
6234
6210
 
6235
6211
  const getSearchMessageClassName = indented => {
@@ -6248,12 +6224,13 @@ const getSearchMessageVirtualDom = (message, indented) => {
6248
6224
  }, text(message)];
6249
6225
  };
6250
6226
 
6227
+ const detailsNode$1 = {
6228
+ childCount: 2,
6229
+ className: SearchHeaderDetails,
6230
+ type: Div
6231
+ };
6251
6232
  const getSearchHeaderDetailsCollapsedVirtualDom = message => {
6252
- return [{
6253
- childCount: 2,
6254
- className: SearchHeaderDetails,
6255
- type: Div
6256
- }, ...getSearchMessageVirtualDom(message, true), ...getSearchDetailsToggleVirtualDom()];
6233
+ return [detailsNode$1, ...getSearchMessageVirtualDom(message, true), ...getSearchDetailsToggleVirtualDom()];
6257
6234
  };
6258
6235
 
6259
6236
  const CheckBoxEnabled = 1;
@@ -6412,28 +6389,27 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
6412
6389
  return dom;
6413
6390
  };
6414
6391
 
6392
+ const detailsNode = {
6393
+ childCount: 5,
6394
+ className: SearchHeaderDetailsExpanded,
6395
+ type: Div
6396
+ };
6397
+ const topNode = {
6398
+ childCount: 2,
6399
+ className: SearchHeaderDetailsExpandedTop,
6400
+ type: Div
6401
+ };
6402
+ const headingNode = {
6403
+ childCount: 1,
6404
+ className: SearchHeaderDetailsHeading,
6405
+ type: H4
6406
+ };
6415
6407
  const getSearchHeaderDetailsExpandedVirtualDom = (flags, message) => {
6416
6408
  const includeButtons = getInputActionsInclude(flags);
6417
6409
  const excludeButtons = getInputActionsExclude(flags);
6418
6410
  const includePlaceholder = include();
6419
6411
  const excludePlaceholder = exclude();
6420
- return [{
6421
- childCount: 5,
6422
- className: SearchHeaderDetailsExpanded,
6423
- type: Div
6424
- }, {
6425
- childCount: 2,
6426
- className: SearchHeaderDetailsExpandedTop,
6427
- type: Div
6428
- }, ...getSearchDetailsToggleVirtualDom(), {
6429
- childCount: 1,
6430
- className: SearchHeaderDetailsHeading,
6431
- type: H4
6432
- }, text(filesToInclude()), ...getSearchFieldVirtualDom(FilesToInclude, includePlaceholder, HandleInput2, includeButtons.inside, includeButtons.outside), {
6433
- childCount: 1,
6434
- className: SearchHeaderDetailsHeading,
6435
- type: H4
6436
- }, text(filesToExclude()), ...getSearchFieldVirtualDom(FilesToExclude, excludePlaceholder, HandleInput2, excludeButtons.inside, excludeButtons.outside), ...getSearchMessageVirtualDom(message, false)];
6412
+ return [detailsNode, topNode, ...getSearchDetailsToggleVirtualDom(), headingNode, text(filesToInclude()), ...getSearchFieldVirtualDom(FilesToInclude, includePlaceholder, HandleInput2, includeButtons.inside, includeButtons.outside), headingNode, text(filesToExclude()), ...getSearchFieldVirtualDom(FilesToExclude, excludePlaceholder, HandleInput2, excludeButtons.inside, excludeButtons.outside), ...getSearchMessageVirtualDom(message, false)];
6437
6413
  };
6438
6414
 
6439
6415
  const getSearchHeaderDetailsVirtualDom = (flags, message) => {
@@ -6443,15 +6419,16 @@ const getSearchHeaderDetailsVirtualDom = (flags, message) => {
6443
6419
  return getSearchHeaderDetailsCollapsedVirtualDom(message);
6444
6420
  };
6445
6421
 
6422
+ const messageNode = {
6423
+ childCount: 1,
6424
+ className: SearchWarningMessage,
6425
+ type: Div
6426
+ };
6446
6427
  const getSearchHeaderLimitHitVirtualDom = limitHitWarning => {
6447
6428
  if (!limitHitWarning) {
6448
6429
  return [];
6449
6430
  }
6450
- const dom = [{
6451
- childCount: 1,
6452
- className: SearchWarningMessage,
6453
- type: Div
6454
- },
6431
+ const dom = [messageNode,
6455
6432
  // TODO warning triangle here
6456
6433
  text(limitHitWarning)];
6457
6434
  return dom;
@@ -6517,13 +6494,13 @@ const getSearchEditorContextLinesVirtualDom = (contextLines$1, contextLinesEnabl
6517
6494
  return [{
6518
6495
  ariaLabel: contextLines(),
6519
6496
  childCount: 0,
6520
- className: `${InputBox} SearchEditorContextLinesInput`,
6497
+ className: mergeClassNames(InputBox, 'SearchEditorContextLinesInput'),
6521
6498
  inputType: 'number',
6522
6499
  min: 0,
6523
6500
  name: ContextLines,
6524
6501
  onInput: HandleInput2,
6525
6502
  type: Input,
6526
- value: `${contextLines$1}`
6503
+ value: String(contextLines$1)
6527
6504
  }, ...getSearchFieldButtonVirtualDom(button)];
6528
6505
  };
6529
6506
 
@@ -6552,18 +6529,25 @@ const getSearchToggleVirtualDom = replaceExpanded => {
6552
6529
  }];
6553
6530
  };
6554
6531
 
6532
+ const headerNode = {
6533
+ childCount: 2,
6534
+ className: SearchHeaderTop,
6535
+ role: None$2,
6536
+ type: Div
6537
+ };
6538
+ const searchEditorContainerNode = {
6539
+ childCount: 3,
6540
+ className: SearchFieldContainer,
6541
+ role: None$2,
6542
+ type: Div
6543
+ };
6555
6544
  const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount, focus, isSearchEditor = false, contextLines = 1, contextLinesEnabled = false) => {
6556
6545
  const inputActions = getInputActionsInput(flags);
6557
6546
  const replaceActions = getInputActionsReplace(flags, matchCount);
6558
6547
  const searchPlaceholder = getSearchPlaceholder(focus);
6559
6548
  const replacePlaceholder = getReplacePlaceholder(focus);
6560
6549
  const replaceExpanded = flags & ReplaceExpanded;
6561
- const dom = [{
6562
- childCount: 2,
6563
- className: SearchHeaderTop,
6564
- role: None$2,
6565
- type: Div
6566
- }, ...getSearchToggleVirtualDom(replaceExpanded), {
6550
+ const dom = [headerNode, ...getSearchToggleVirtualDom(replaceExpanded), {
6567
6551
  childCount: replaceExpanded ? 2 : 1,
6568
6552
  className: SearchHeaderTopRight,
6569
6553
  role: None$2,
@@ -6571,12 +6555,7 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
6571
6555
  }];
6572
6556
  const searchFieldDom = getSearchFieldVirtualDom(SearchValue, searchPlaceholder, HandleInput2, inputActions.inside, inputActions.outside, Boolean(searchInputErrorMessage));
6573
6557
  if (isSearchEditor) {
6574
- dom.push({
6575
- childCount: 3,
6576
- className: SearchFieldContainer,
6577
- role: None$2,
6578
- type: Div
6579
- }, ...searchFieldDom, ...getSearchEditorContextLinesVirtualDom(contextLines, contextLinesEnabled));
6558
+ dom.push(searchEditorContainerNode, ...searchFieldDom, ...getSearchEditorContextLinesVirtualDom(contextLines, contextLinesEnabled));
6580
6559
  } else {
6581
6560
  dom.push(...searchFieldDom);
6582
6561
  }
@@ -6599,16 +6578,17 @@ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matc
6599
6578
  return dom;
6600
6579
  };
6601
6580
 
6581
+ const errorNode = {
6582
+ childCount: 1,
6583
+ className: SearchInputError,
6584
+ role: Alert,
6585
+ type: Div
6586
+ };
6602
6587
  const getSearchInputErrorVirtualDom = errorMessage => {
6603
6588
  if (!errorMessage) {
6604
6589
  return [];
6605
6590
  }
6606
- return [{
6607
- childCount: 1,
6608
- className: SearchInputError,
6609
- role: Alert,
6610
- type: Div
6611
- }, text(errorMessage)];
6591
+ return [errorNode, text(errorMessage)];
6612
6592
  };
6613
6593
 
6614
6594
  const TreeItems = 'TreeItems';
@@ -6775,7 +6755,7 @@ const getSearchRemoveVirtualDom = () => {
6775
6755
 
6776
6756
  const getSearchResultClassName = focused => {
6777
6757
  if (focused) {
6778
- return TreeItem + ' ' + TreeItemActive;
6758
+ return mergeClassNames(TreeItem, TreeItemActive);
6779
6759
  }
6780
6760
  return TreeItem;
6781
6761
  };
@@ -7337,8 +7317,8 @@ const handleContextMenu = async (state, button, x, y) => {
7337
7317
  return newState;
7338
7318
  };
7339
7319
 
7340
- const handleDirectMessagePort = (port, setAsRendererProcess) => handleMessagePort(port, commandMap, setAsRendererProcess);
7341
- const commandMap = {
7320
+ const handleDirectMessagePort = (port, setAsRendererProcess) => handleMessagePort(port, commandMap$1, setAsRendererProcess);
7321
+ const commandMap$1 = {
7342
7322
  'TextSearch.clearSearchResults': wrapCommand(clearSearchResults$1),
7343
7323
  'TextSearch.collapseAll': wrapCommand(collapseAll$1),
7344
7324
  'TextSearch.collapseCurrent': wrapCommand(collapseCurrent),
@@ -7415,8 +7395,6 @@ const commandMap = {
7415
7395
  'TextSearch.handleSharedInput': wrapCommand(handleSharedInput),
7416
7396
  'TextSearch.handleWheel': wrapCommand(handleWheel),
7417
7397
  'TextSearch.handleWorkspaceChange': wrapCommand(handleWorkspaceChange),
7418
- // not wrapped
7419
- 'TextSearch.initialize': initialize,
7420
7398
  'TextSearch.loadContent': wrapCommand(loadContent),
7421
7399
  'TextSearch.nextHistoryResult': wrapCommand(nextHistoryResult),
7422
7400
  'TextSearch.openSearchEditor': wrapCommand(openSearchEditor),
@@ -7452,28 +7430,68 @@ const commandMap = {
7452
7430
  'TextSearch.viewAsTree': wrapCommand(viewAsTree)
7453
7431
  };
7454
7432
 
7455
- const send = port => {
7433
+ const initializeDialogWorker = async () => {
7434
+ const rpc = await create$5({
7435
+ commandMap: {},
7436
+ send: sendMessagePortToDialogWorker
7437
+ });
7438
+ set$7(rpc);
7439
+ };
7440
+
7441
+ const send$2 = async port => {
7442
+ await sendMessagePortToIconThemeWorker(port, 0);
7443
+ };
7444
+ const launchIconThemeWorker = async () => {
7445
+ // TODO connect to icon theme worker
7446
+ const rpc = await create$5({
7447
+ commandMap: {},
7448
+ send: send$2
7449
+ });
7450
+ return rpc;
7451
+ };
7452
+
7453
+ const initializeIconThemeWorker = async () => {
7454
+ const rpc = await launchIconThemeWorker();
7455
+ set$6(rpc);
7456
+ };
7457
+
7458
+ const send$1 = port => {
7456
7459
  return sendMessagePortToTextMeasurementWorker(port);
7457
7460
  };
7458
7461
  const initializeTextMeasurementWorker = async () => {
7459
7462
  const rpc = await create$5({
7460
7463
  commandMap: {},
7461
- send
7464
+ send: send$1
7462
7465
  });
7463
7466
  set$2(rpc);
7464
7467
  };
7465
7468
 
7469
+ const commandMap = {
7470
+ 'TextSearch.handlePullResultsFound': wrapCommand(handlePullResultsFound)
7471
+ };
7472
+
7473
+ const send = async port => {
7474
+ await sendMessagePortToTextSearchWorker(port, 0);
7475
+ };
7476
+ const launchTextSearchWorker = async () => {
7477
+ return create$5({
7478
+ commandMap: commandMap,
7479
+ send
7480
+ });
7481
+ };
7482
+
7483
+ const initializeTextSearchWorker = async () => {
7484
+ const rpc = await launchTextSearchWorker();
7485
+ set$3(rpc);
7486
+ };
7487
+
7466
7488
  const listen = async () => {
7467
- registerCommands(commandMap);
7489
+ registerCommands(commandMap$1);
7468
7490
  const rpc = await create$4({
7469
- commandMap: commandMap
7491
+ commandMap: commandMap$1
7470
7492
  });
7471
7493
  set$4(rpc);
7472
- const [dialogRpc] = await Promise.all([create$5({
7473
- commandMap: {},
7474
- send: sendMessagePortToDialogWorker
7475
- }), initializeTextMeasurementWorker()]);
7476
- set$7(dialogRpc);
7494
+ await Promise.all([initializeDialogWorker(), initializeIconThemeWorker(), initializeTextMeasurementWorker(), initializeTextSearchWorker()]);
7477
7495
  };
7478
7496
 
7479
7497
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-view",
3
- "version": "1.14.3",
3
+ "version": "1.16.0",
4
4
  "description": "Text Search View",
5
5
  "keywords": [
6
6
  "text-search"