@lvce-editor/text-search-worker 3.44.0 → 3.45.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.
@@ -473,6 +473,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
473
473
  }
474
474
  return promise;
475
475
  };
476
+ const Message$1 = 3;
476
477
  const create$5$1 = async ({
477
478
  messagePort,
478
479
  isMessagePortOpen
@@ -480,9 +481,24 @@ const create$5$1 = async ({
480
481
  if (!isMessagePort(messagePort)) {
481
482
  throw new IpcError('port must be of type MessagePort');
482
483
  }
483
- {
484
+ if (isMessagePortOpen) {
484
485
  return messagePort;
485
486
  }
487
+ const eventPromise = getFirstEvent(messagePort, {
488
+ message: Message$1
489
+ });
490
+ messagePort.start();
491
+ const {
492
+ type,
493
+ event
494
+ } = await eventPromise;
495
+ if (type !== Message$1) {
496
+ throw new IpcError('Failed to wait for ipc message');
497
+ }
498
+ if (event.data !== readyMessage) {
499
+ throw new IpcError('unexpected first message');
500
+ }
501
+ return messagePort;
486
502
  };
487
503
  const signal$1 = messagePort => {
488
504
  messagePort.start();
@@ -811,7 +827,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
811
827
  const errorProperty = getErrorProperty(error, prettyError);
812
828
  return create$1$2(message, errorProperty);
813
829
  };
814
- const create$6 = (message, result) => {
830
+ const create$5 = (message, result) => {
815
831
  return {
816
832
  jsonrpc: Two,
817
833
  id: message.id,
@@ -820,7 +836,7 @@ const create$6 = (message, result) => {
820
836
  };
821
837
  const getSuccessResponse = (message, result) => {
822
838
  const resultProperty = result ?? null;
823
- return create$6(message, resultProperty);
839
+ return create$5(message, resultProperty);
824
840
  };
825
841
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
826
842
  try {
@@ -984,7 +1000,7 @@ const listen$1 = async (module, options) => {
984
1000
  const ipc = module.wrap(rawIpc);
985
1001
  return ipc;
986
1002
  };
987
- const create$5 = async ({
1003
+ const create$6 = async ({
988
1004
  commandMap,
989
1005
  messagePort,
990
1006
  isMessagePortOpen
@@ -1002,7 +1018,7 @@ const create$5 = async ({
1002
1018
  };
1003
1019
  const MessagePortRpcParent = {
1004
1020
  __proto__: null,
1005
- create: create$5
1021
+ create: create$6
1006
1022
  };
1007
1023
  const create$1$1 = async ({
1008
1024
  commandMap,
@@ -3690,14 +3706,55 @@ const RenderReplaceValue = 4;
3690
3706
  const RenderIncludeValue = 5;
3691
3707
  const RenderExcludeValue = 6;
3692
3708
 
3709
+ const createViewModel = state => {
3710
+ const {
3711
+ listItems,
3712
+ itemHeight,
3713
+ fileCount,
3714
+ value,
3715
+ minLineY,
3716
+ maxLineY,
3717
+ replacement,
3718
+ icons,
3719
+ listFocusedIndex,
3720
+ collapsedPaths,
3721
+ items,
3722
+ listFocused,
3723
+ deltaY,
3724
+ finalDeltaY,
3725
+ height,
3726
+ headerHeight,
3727
+ flags,
3728
+ message,
3729
+ searchInputErrorMessage,
3730
+ scrollBarHeight,
3731
+ matchCount
3732
+ } = state;
3733
+ const displayResults = getDisplayResults(listItems, itemHeight, fileCount, value, minLineY, maxLineY, replacement, icons, listFocusedIndex, collapsedPaths, items);
3734
+ const focusOutline = listFocused && listFocusedIndex === -1;
3735
+ const scrollBarValue = deltaY / finalDeltaY * 100;
3736
+ const scrollBarY = getScrollBarY(deltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
3737
+ return {
3738
+ displayResults,
3739
+ flags,
3740
+ message,
3741
+ focusOutline,
3742
+ searchInputErrorMessage,
3743
+ scrollBarHeight,
3744
+ scrollBarY,
3745
+ scrollBarValue,
3746
+ deltaY,
3747
+ itemHeight,
3748
+ matchCount
3749
+ };
3750
+ };
3751
+
3693
3752
  const renderItems = (oldState, newState) => {
3694
- const displayResults = getDisplayResults(newState.listItems, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.icons, newState.listFocusedIndex, newState.collapsedPaths, newState.items);
3695
- const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
3696
- const scrollBarValue = newState.deltaY / newState.finalDeltaY * 100;
3697
- const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, newState.scrollBarHeight);
3698
- const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage, newState.scrollBarHeight, scrollBarY, scrollBarValue, newState.deltaY, newState.itemHeight, newState.matchCount);
3753
+ const viewModel = createViewModel(newState);
3754
+ const dom = getSearchVirtualDom(viewModel.displayResults, viewModel.flags, viewModel.message, viewModel.focusOutline, viewModel.searchInputErrorMessage, viewModel.scrollBarHeight, viewModel.scrollBarY, viewModel.scrollBarValue, viewModel.deltaY, viewModel.itemHeight, viewModel.matchCount);
3699
3755
  return ['Viewlet.setDom2', newState.uid, dom];
3700
3756
  };
3757
+
3701
3758
  const renderFocus = (oldState, newState) => {
3702
3759
  return oldState.focus === newState.focus || newState.focusSource === User;
3703
3760
  };
@@ -3808,6 +3865,7 @@ const DiffValue = {
3808
3865
  };
3809
3866
 
3810
3867
  const modules = [DiffItems, DiffFocus, DiffIncludeValue, DiffExcludeValue, DiffReplaceValue, DiffValue];
3868
+
3811
3869
  const diff$1 = (oldState, newState) => {
3812
3870
  const diffResult = [];
3813
3871
  for (const module of modules) {
@@ -4515,6 +4573,7 @@ const commandMap = {
4515
4573
  'TextSearch.render': doRender,
4516
4574
  'TextSearch.renderEventListeners': renderEventListeners,
4517
4575
  'TextSearch.renderIncremental': renderIncremental,
4576
+ 'TextSearch.restoreState': restoreState,
4518
4577
  'TextSearch.saveState': saveState,
4519
4578
  'TextSearch.terminate': terminate,
4520
4579
  // TODO needed?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "3.44.0",
3
+ "version": "3.45.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"