@lvce-editor/text-search-worker 3.44.0 → 3.46.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,17 +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
  };
3701
- const renderFocus = (oldState, newState) => {
3702
- return oldState.focus === newState.focus || newState.focusSource === User;
3703
- };
3757
+
3704
3758
  const renderValue = (oldState, newState) => {
3705
3759
  return ['Viewlet.send', newState.uid, 'setValue', newState.value, `[name="${SearchValue}"]`];
3706
3760
  };
@@ -3713,6 +3767,10 @@ const renderIncludeValue = (oldState, newState) => {
3713
3767
  const renderExcludeValue = (oldState, newState) => {
3714
3768
  return ['Viewlet.send', newState.uid, 'setValue', newState.excludeValue, `[name=${FilesToExclude}]`];
3715
3769
  };
3770
+
3771
+ const renderFocus = (oldState, newState) => {
3772
+ return oldState.focus === newState.focus || newState.focusSource === User;
3773
+ };
3716
3774
  const getRenderer = diffType => {
3717
3775
  switch (diffType) {
3718
3776
  case RenderValue:
@@ -3808,6 +3866,7 @@ const DiffValue = {
3808
3866
  };
3809
3867
 
3810
3868
  const modules = [DiffItems, DiffFocus, DiffIncludeValue, DiffExcludeValue, DiffReplaceValue, DiffValue];
3869
+
3811
3870
  const diff$1 = (oldState, newState) => {
3812
3871
  const diffResult = [];
3813
3872
  for (const module of modules) {
@@ -3827,6 +3886,19 @@ const doRender = uid => {
3827
3886
  return applyRender(oldState, newState, diffResult);
3828
3887
  };
3829
3888
 
3889
+ const renderActions = uid => {
3890
+ const {
3891
+ oldState,
3892
+ newState
3893
+ } = get(uid);
3894
+ if (oldState === newState) {
3895
+ return [];
3896
+ }
3897
+ const actions = [];
3898
+ const dom = getActionsVirtualDom(actions);
3899
+ return dom;
3900
+ };
3901
+
3830
3902
  const renderEventListeners = () => {
3831
3903
  return [{
3832
3904
  name: HandleExcludeInput,
@@ -4471,6 +4543,7 @@ const commandMap = {
4471
4543
  'TextSearch.focusReplaceValue': wrapCommand(focusReplaceValue$1),
4472
4544
  'TextSearch.focusReplaceValueNext': wrapCommand(focusReplaceValueNext),
4473
4545
  'TextSearch.focusReplaceValuePrevious': wrapCommand(focusReplaceValuePrevious),
4546
+ 'TextSearch.renderActions': wrapCommand(renderActions),
4474
4547
  'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
4475
4548
  'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
4476
4549
  'TextSearch.getActions': wrapCommand(getActions),
@@ -4515,6 +4588,7 @@ const commandMap = {
4515
4588
  'TextSearch.render': doRender,
4516
4589
  'TextSearch.renderEventListeners': renderEventListeners,
4517
4590
  'TextSearch.renderIncremental': renderIncremental,
4591
+ 'TextSearch.restoreState': restoreState,
4518
4592
  'TextSearch.saveState': saveState,
4519
4593
  'TextSearch.terminate': terminate,
4520
4594
  // 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.46.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"