@lvce-editor/text-search-view 1.15.0 → 1.17.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.
@@ -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
@@ -5686,6 +5646,9 @@ const loadPreferences = async currentDefaultExcludes => {
5686
5646
  const hasProperty = (object, key) => {
5687
5647
  return !!object && typeof object === 'object' && key in object;
5688
5648
  };
5649
+ const hasStringProperty = (object, key) => {
5650
+ return hasProperty(object, key) && typeof object[key] === 'string';
5651
+ };
5689
5652
 
5690
5653
  const getSavedFocus = savedState => {
5691
5654
  if (hasProperty(savedState, 'focus') && typeof savedState.focus === 'number') {
@@ -5711,13 +5674,13 @@ const getSavedHistory = savedState => {
5711
5674
  };
5712
5675
 
5713
5676
  const getSavedValue = savedState => {
5714
- if (hasProperty(savedState, 'value') && typeof savedState.value === 'string') {
5677
+ if (hasStringProperty(savedState, 'value')) {
5715
5678
  return savedState.value;
5716
5679
  }
5717
5680
  return '';
5718
5681
  };
5719
5682
  const getSavedReplacement = savedState => {
5720
- if (hasProperty(savedState, 'replacement') && typeof savedState.replacement === 'string') {
5683
+ if (hasStringProperty(savedState, 'replacement')) {
5721
5684
  return savedState.replacement;
5722
5685
  }
5723
5686
  return '';
@@ -5729,13 +5692,13 @@ const getSavedFlags = savedState => {
5729
5692
  return UseIgnoreFiles;
5730
5693
  };
5731
5694
  const getSavedIncludeValue = savedState => {
5732
- if (hasProperty(savedState, 'includeValue') && typeof savedState.includeValue === 'string') {
5695
+ if (hasStringProperty(savedState, 'includeValue')) {
5733
5696
  return savedState.includeValue;
5734
5697
  }
5735
5698
  return '';
5736
5699
  };
5737
5700
  const getSavedExcludeValue = savedState => {
5738
- if (hasProperty(savedState, 'excludeValue') && typeof savedState.excludeValue === 'string') {
5701
+ if (hasStringProperty(savedState, 'excludeValue')) {
5739
5702
  return savedState.excludeValue;
5740
5703
  }
5741
5704
  return '';
@@ -5906,7 +5869,7 @@ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPat
5906
5869
  const index = originalResults.indexOf(results[i]);
5907
5870
  const matchCount = getMatchCount(originalResults, index);
5908
5871
  const expanded = collapsedPaths.includes(path) ? Collapsed : Expanded;
5909
- const badgeText = `${matchCount}`;
5872
+ const badgeText = String(matchCount);
5910
5873
  const depth = 0;
5911
5874
  const indent = getTreeItemIndent(depth);
5912
5875
  return {
@@ -6206,24 +6169,31 @@ const HandleInputSelectionChange = 21;
6206
6169
  const HandleActionClick = 22;
6207
6170
  const HandleOpenFolderClick = 23;
6208
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
+ };
6209
6183
  const getNoWorkspaceMessageVirtualDom = workspacePath => {
6210
6184
  if (workspacePath !== '') {
6211
6185
  return [];
6212
6186
  }
6213
- return [{
6214
- childCount: 2,
6215
- className: mergeClassNames(ViewletSearchMessage, ViewletSearchMessageIndented, SearchWorkspaceMessage),
6216
- type: Div
6217
- }, text(`${noWorkspaceFolder()} - `), {
6218
- childCount: 1,
6219
- className: mergeClassNames(MessageAction, SearchWorkspaceMessageAction),
6220
- onClick: HandleOpenFolderClick,
6221
- type: Button$2
6222
- }, text(openFolder$1())];
6187
+ return [parentNode, text(`${noWorkspaceFolder()} - `), actionNode, text(openFolder$1())];
6223
6188
  };
6224
6189
 
6225
6190
  const Focusable = 0;
6226
6191
 
6192
+ const iconNode = {
6193
+ childCount: 0,
6194
+ className: mergeClassNames(MaskIcon, MaskIconEllipsis),
6195
+ type: Div
6196
+ };
6227
6197
  const getSearchDetailsToggleVirtualDom = () => {
6228
6198
  return [{
6229
6199
  ariaLabel: toggleSearchDetails(),
@@ -6235,11 +6205,7 @@ const getSearchDetailsToggleVirtualDom = () => {
6235
6205
  tabIndex: Focusable,
6236
6206
  title: toggleSearchDetails(),
6237
6207
  type: Button$2
6238
- }, {
6239
- childCount: 0,
6240
- className: mergeClassNames(MaskIcon, MaskIconEllipsis),
6241
- type: Div
6242
- }];
6208
+ }, iconNode];
6243
6209
  };
6244
6210
 
6245
6211
  const getSearchMessageClassName = indented => {
@@ -6258,12 +6224,13 @@ const getSearchMessageVirtualDom = (message, indented) => {
6258
6224
  }, text(message)];
6259
6225
  };
6260
6226
 
6227
+ const detailsNode$1 = {
6228
+ childCount: 2,
6229
+ className: SearchHeaderDetails,
6230
+ type: Div
6231
+ };
6261
6232
  const getSearchHeaderDetailsCollapsedVirtualDom = message => {
6262
- return [{
6263
- childCount: 2,
6264
- className: SearchHeaderDetails,
6265
- type: Div
6266
- }, ...getSearchMessageVirtualDom(message, true), ...getSearchDetailsToggleVirtualDom()];
6233
+ return [detailsNode$1, ...getSearchMessageVirtualDom(message, true), ...getSearchDetailsToggleVirtualDom()];
6267
6234
  };
6268
6235
 
6269
6236
  const CheckBoxEnabled = 1;
@@ -6422,28 +6389,27 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
6422
6389
  return dom;
6423
6390
  };
6424
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
+ };
6425
6407
  const getSearchHeaderDetailsExpandedVirtualDom = (flags, message) => {
6426
6408
  const includeButtons = getInputActionsInclude(flags);
6427
6409
  const excludeButtons = getInputActionsExclude(flags);
6428
6410
  const includePlaceholder = include();
6429
6411
  const excludePlaceholder = exclude();
6430
- return [{
6431
- childCount: 5,
6432
- className: SearchHeaderDetailsExpanded,
6433
- type: Div
6434
- }, {
6435
- childCount: 2,
6436
- className: SearchHeaderDetailsExpandedTop,
6437
- type: Div
6438
- }, ...getSearchDetailsToggleVirtualDom(), {
6439
- childCount: 1,
6440
- className: SearchHeaderDetailsHeading,
6441
- type: H4
6442
- }, text(filesToInclude()), ...getSearchFieldVirtualDom(FilesToInclude, includePlaceholder, HandleInput2, includeButtons.inside, includeButtons.outside), {
6443
- childCount: 1,
6444
- className: SearchHeaderDetailsHeading,
6445
- type: H4
6446
- }, 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)];
6447
6413
  };
6448
6414
 
6449
6415
  const getSearchHeaderDetailsVirtualDom = (flags, message) => {
@@ -6453,15 +6419,16 @@ const getSearchHeaderDetailsVirtualDom = (flags, message) => {
6453
6419
  return getSearchHeaderDetailsCollapsedVirtualDom(message);
6454
6420
  };
6455
6421
 
6422
+ const messageNode = {
6423
+ childCount: 1,
6424
+ className: SearchWarningMessage,
6425
+ type: Div
6426
+ };
6456
6427
  const getSearchHeaderLimitHitVirtualDom = limitHitWarning => {
6457
6428
  if (!limitHitWarning) {
6458
6429
  return [];
6459
6430
  }
6460
- const dom = [{
6461
- childCount: 1,
6462
- className: SearchWarningMessage,
6463
- type: Div
6464
- },
6431
+ const dom = [messageNode,
6465
6432
  // TODO warning triangle here
6466
6433
  text(limitHitWarning)];
6467
6434
  return dom;
@@ -6527,13 +6494,13 @@ const getSearchEditorContextLinesVirtualDom = (contextLines$1, contextLinesEnabl
6527
6494
  return [{
6528
6495
  ariaLabel: contextLines(),
6529
6496
  childCount: 0,
6530
- className: `${InputBox} SearchEditorContextLinesInput`,
6497
+ className: mergeClassNames(InputBox, 'SearchEditorContextLinesInput'),
6531
6498
  inputType: 'number',
6532
6499
  min: 0,
6533
6500
  name: ContextLines,
6534
6501
  onInput: HandleInput2,
6535
6502
  type: Input,
6536
- value: `${contextLines$1}`
6503
+ value: String(contextLines$1)
6537
6504
  }, ...getSearchFieldButtonVirtualDom(button)];
6538
6505
  };
6539
6506
 
@@ -6562,18 +6529,25 @@ const getSearchToggleVirtualDom = replaceExpanded => {
6562
6529
  }];
6563
6530
  };
6564
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
+ };
6565
6544
  const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount, focus, isSearchEditor = false, contextLines = 1, contextLinesEnabled = false) => {
6566
6545
  const inputActions = getInputActionsInput(flags);
6567
6546
  const replaceActions = getInputActionsReplace(flags, matchCount);
6568
6547
  const searchPlaceholder = getSearchPlaceholder(focus);
6569
6548
  const replacePlaceholder = getReplacePlaceholder(focus);
6570
6549
  const replaceExpanded = flags & ReplaceExpanded;
6571
- const dom = [{
6572
- childCount: 2,
6573
- className: SearchHeaderTop,
6574
- role: None$2,
6575
- type: Div
6576
- }, ...getSearchToggleVirtualDom(replaceExpanded), {
6550
+ const dom = [headerNode, ...getSearchToggleVirtualDom(replaceExpanded), {
6577
6551
  childCount: replaceExpanded ? 2 : 1,
6578
6552
  className: SearchHeaderTopRight,
6579
6553
  role: None$2,
@@ -6581,12 +6555,7 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
6581
6555
  }];
6582
6556
  const searchFieldDom = getSearchFieldVirtualDom(SearchValue, searchPlaceholder, HandleInput2, inputActions.inside, inputActions.outside, Boolean(searchInputErrorMessage));
6583
6557
  if (isSearchEditor) {
6584
- dom.push({
6585
- childCount: 3,
6586
- className: SearchFieldContainer,
6587
- role: None$2,
6588
- type: Div
6589
- }, ...searchFieldDom, ...getSearchEditorContextLinesVirtualDom(contextLines, contextLinesEnabled));
6558
+ dom.push(searchEditorContainerNode, ...searchFieldDom, ...getSearchEditorContextLinesVirtualDom(contextLines, contextLinesEnabled));
6590
6559
  } else {
6591
6560
  dom.push(...searchFieldDom);
6592
6561
  }
@@ -6609,16 +6578,17 @@ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matc
6609
6578
  return dom;
6610
6579
  };
6611
6580
 
6581
+ const errorNode = {
6582
+ childCount: 1,
6583
+ className: SearchInputError,
6584
+ role: Alert,
6585
+ type: Div
6586
+ };
6612
6587
  const getSearchInputErrorVirtualDom = errorMessage => {
6613
6588
  if (!errorMessage) {
6614
6589
  return [];
6615
6590
  }
6616
- return [{
6617
- childCount: 1,
6618
- className: SearchInputError,
6619
- role: Alert,
6620
- type: Div
6621
- }, text(errorMessage)];
6591
+ return [errorNode, text(errorMessage)];
6622
6592
  };
6623
6593
 
6624
6594
  const TreeItems = 'TreeItems';
@@ -6785,7 +6755,7 @@ const getSearchRemoveVirtualDom = () => {
6785
6755
 
6786
6756
  const getSearchResultClassName = focused => {
6787
6757
  if (focused) {
6788
- return TreeItem + ' ' + TreeItemActive;
6758
+ return mergeClassNames(TreeItem, TreeItemActive);
6789
6759
  }
6790
6760
  return TreeItem;
6791
6761
  };
@@ -7347,8 +7317,8 @@ const handleContextMenu = async (state, button, x, y) => {
7347
7317
  return newState;
7348
7318
  };
7349
7319
 
7350
- const handleDirectMessagePort = (port, setAsRendererProcess) => handleMessagePort(port, commandMap, setAsRendererProcess);
7351
- const commandMap = {
7320
+ const handleDirectMessagePort = (port, setAsRendererProcess) => handleMessagePort(port, commandMap$1, setAsRendererProcess);
7321
+ const commandMap$1 = {
7352
7322
  'TextSearch.clearSearchResults': wrapCommand(clearSearchResults$1),
7353
7323
  'TextSearch.collapseAll': wrapCommand(collapseAll$1),
7354
7324
  'TextSearch.collapseCurrent': wrapCommand(collapseCurrent),
@@ -7425,8 +7395,6 @@ const commandMap = {
7425
7395
  'TextSearch.handleSharedInput': wrapCommand(handleSharedInput),
7426
7396
  'TextSearch.handleWheel': wrapCommand(handleWheel),
7427
7397
  'TextSearch.handleWorkspaceChange': wrapCommand(handleWorkspaceChange),
7428
- // not wrapped
7429
- 'TextSearch.initialize': initialize,
7430
7398
  'TextSearch.loadContent': wrapCommand(loadContent),
7431
7399
  'TextSearch.nextHistoryResult': wrapCommand(nextHistoryResult),
7432
7400
  'TextSearch.openSearchEditor': wrapCommand(openSearchEditor),
@@ -7470,24 +7438,60 @@ const initializeDialogWorker = async () => {
7470
7438
  set$7(rpc);
7471
7439
  };
7472
7440
 
7473
- const send = port => {
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 => {
7474
7459
  return sendMessagePortToTextMeasurementWorker(port);
7475
7460
  };
7476
7461
  const initializeTextMeasurementWorker = async () => {
7477
7462
  const rpc = await create$5({
7478
7463
  commandMap: {},
7479
- send
7464
+ send: send$1
7480
7465
  });
7481
7466
  set$2(rpc);
7482
7467
  };
7483
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
+
7484
7488
  const listen = async () => {
7485
- registerCommands(commandMap);
7489
+ registerCommands(commandMap$1);
7486
7490
  const rpc = await create$4({
7487
- commandMap: commandMap
7491
+ commandMap: commandMap$1
7488
7492
  });
7489
7493
  set$4(rpc);
7490
- await Promise.all([initializeDialogWorker(), initializeTextMeasurementWorker()]);
7494
+ await Promise.all([initializeDialogWorker(), initializeIconThemeWorker(), initializeTextMeasurementWorker(), initializeTextSearchWorker()]);
7491
7495
  };
7492
7496
 
7493
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.15.0",
3
+ "version": "1.17.0",
4
4
  "description": "Text Search View",
5
5
  "keywords": [
6
6
  "text-search"