@lvce-editor/file-search-worker 5.15.0 → 5.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.
@@ -431,7 +431,7 @@ const create$4$1 = (method, params) => {
431
431
  };
432
432
  };
433
433
  const callbacks = Object.create(null);
434
- const set$3 = (id, fn) => {
434
+ const set$2 = (id, fn) => {
435
435
  callbacks[id] = fn;
436
436
  };
437
437
  const get$2 = id => {
@@ -450,7 +450,7 @@ const registerPromise = () => {
450
450
  resolve,
451
451
  promise
452
452
  } = Promise.withResolvers();
453
- set$3(id, resolve);
453
+ set$2(id, resolve);
454
454
  return {
455
455
  id,
456
456
  promise
@@ -523,6 +523,16 @@ const constructError = (message, type, name) => {
523
523
  }
524
524
  return new ErrorConstructor(message);
525
525
  };
526
+ const joinLines = lines => {
527
+ return lines.join(NewLine);
528
+ };
529
+ const splitLines$1 = lines => {
530
+ return lines.split(NewLine);
531
+ };
532
+ const getCurrentStack = () => {
533
+ const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(2));
534
+ return currentStack;
535
+ };
526
536
  const getNewLineIndex = (string, startIndex = undefined) => {
527
537
  return string.indexOf(NewLine, startIndex);
528
538
  };
@@ -533,19 +543,16 @@ const getParentStack = error => {
533
543
  }
534
544
  return parentStack;
535
545
  };
536
- const joinLines = lines => {
537
- return lines.join(NewLine);
538
- };
539
546
  const MethodNotFound = -32601;
540
547
  const Custom$1 = -32001;
541
- const splitLines$1 = lines => {
542
- return lines.split(NewLine);
543
- };
544
548
  const restoreJsonRpcError = error => {
549
+ const currentStack = getCurrentStack();
545
550
  if (error && error instanceof Error) {
551
+ if (typeof error.stack === 'string') {
552
+ error.stack = error.stack + NewLine + currentStack;
553
+ }
546
554
  return error;
547
555
  }
548
- const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(1));
549
556
  if (error && error.code && error.code === MethodNotFound) {
550
557
  const restoredError = new JsonRpcError(error.message);
551
558
  const parentStack = getParentStack(error);
@@ -626,6 +633,17 @@ const getErrorType = prettyError => {
626
633
  }
627
634
  return undefined;
628
635
  };
636
+ const isAlreadyStack = line => {
637
+ return line.trim().startsWith('at ');
638
+ };
639
+ const getStack = prettyError => {
640
+ const stackString = prettyError.stack || '';
641
+ const newLineIndex = stackString.indexOf('\n');
642
+ if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
643
+ return stackString.slice(newLineIndex + 1);
644
+ }
645
+ return stackString;
646
+ };
629
647
  const getErrorProperty = (error, prettyError) => {
630
648
  if (error && error.code === E_COMMAND_NOT_FOUND) {
631
649
  return {
@@ -638,7 +656,7 @@ const getErrorProperty = (error, prettyError) => {
638
656
  code: Custom$1,
639
657
  message: prettyError.message,
640
658
  data: {
641
- stack: prettyError.stack,
659
+ stack: getStack(prettyError),
642
660
  codeFrame: prettyError.codeFrame,
643
661
  type: getErrorType(prettyError),
644
662
  code: prettyError.code,
@@ -646,18 +664,18 @@ const getErrorProperty = (error, prettyError) => {
646
664
  }
647
665
  };
648
666
  };
649
- const create$1$1 = (message, error) => {
667
+ const create$1$1 = (id, error) => {
650
668
  return {
651
669
  jsonrpc: Two,
652
- id: message.id,
670
+ id,
653
671
  error
654
672
  };
655
673
  };
656
- const getErrorResponse = (message, error, preparePrettyError, logError) => {
674
+ const getErrorResponse = (id, error, preparePrettyError, logError) => {
657
675
  const prettyError = preparePrettyError(error);
658
676
  logError(error, prettyError);
659
677
  const errorProperty = getErrorProperty(error, prettyError);
660
- return create$1$1(message, errorProperty);
678
+ return create$1$1(id, errorProperty);
661
679
  };
662
680
  const create$5 = (message, result) => {
663
681
  return {
@@ -670,12 +688,27 @@ const getSuccessResponse = (message, result) => {
670
688
  const resultProperty = result ?? null;
671
689
  return create$5(message, resultProperty);
672
690
  };
691
+ const getErrorResponseSimple = (id, error) => {
692
+ return {
693
+ jsonrpc: Two,
694
+ id,
695
+ error: {
696
+ code: Custom$1,
697
+ // @ts-ignore
698
+ message: error.message,
699
+ data: error
700
+ }
701
+ };
702
+ };
673
703
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
674
704
  try {
675
705
  const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
676
706
  return getSuccessResponse(message, result);
677
707
  } catch (error) {
678
- return getErrorResponse(message, error, preparePrettyError, logError);
708
+ if (ipc.canUseSimpleErrorResponse) {
709
+ return getErrorResponseSimple(message.id, error);
710
+ }
711
+ return getErrorResponse(message.id, error, preparePrettyError, logError);
679
712
  }
680
713
  };
681
714
  const defaultPreparePrettyError = error => {
@@ -730,7 +763,7 @@ const handleJsonRpcMessage = async (...args) => {
730
763
  try {
731
764
  ipc.send(response);
732
765
  } catch (error) {
733
- const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
766
+ const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
734
767
  ipc.send(errorResponse);
735
768
  }
736
769
  return;
@@ -761,7 +794,7 @@ const send = (transport, method, ...params) => {
761
794
  const message = create$4$1(method, params);
762
795
  transport.send(message);
763
796
  };
764
- const invoke$3 = (ipc, method, ...params) => {
797
+ const invoke$2 = (ipc, method, ...params) => {
765
798
  return invokeHelper(ipc, method, params, false);
766
799
  };
767
800
  const invokeAndTransfer = (ipc, method, ...params) => {
@@ -794,7 +827,7 @@ const createRpc = ipc => {
794
827
  send(ipc, method, ...params);
795
828
  },
796
829
  invoke(method, ...params) {
797
- return invoke$3(ipc, method, ...params);
830
+ return invoke$2(ipc, method, ...params);
798
831
  },
799
832
  invokeAndTransfer(method, ...params) {
800
833
  return invokeAndTransfer(ipc, method, ...params);
@@ -851,7 +884,7 @@ const WebWorkerRpcClient = {
851
884
  };
852
885
 
853
886
  const rpcs = Object.create(null);
854
- const set$7 = (id, rpc) => {
887
+ const set$g = (id, rpc) => {
855
888
  rpcs[id] = rpc;
856
889
  };
857
890
  const get$1 = id => {
@@ -875,19 +908,22 @@ const create$3 = rpcId => {
875
908
  return rpc.invokeAndTransfer(method, ...params);
876
909
  },
877
910
  set(rpc) {
878
- set$7(rpcId, rpc);
911
+ set$g(rpcId, rpc);
912
+ },
913
+ async dispose() {
914
+ const rpc = get$1(rpcId);
915
+ await rpc.dispose();
879
916
  }
880
917
  };
881
918
  };
882
919
  const RendererWorker$1 = 1;
883
920
  const {
884
- invoke: invoke$2,
885
- set: set$2
886
- } = create$3(RendererWorker$1);
921
+ invoke: invoke$4,
922
+ set: set$3} = create$3(RendererWorker$1);
887
923
  const RendererWorker = {
888
924
  __proto__: null,
889
- invoke: invoke$2,
890
- set: set$2
925
+ invoke: invoke$4,
926
+ set: set$3
891
927
  };
892
928
 
893
929
  const {
@@ -2824,6 +2860,12 @@ const getFileIconVirtualDom = icon => {
2824
2860
  const mergeClassNames = (...classNames) => {
2825
2861
  return classNames.filter(Boolean).join(' ');
2826
2862
  };
2863
+ const px = value => {
2864
+ return `${value}px`;
2865
+ };
2866
+ const position = (x, y) => {
2867
+ return `${x}px ${y}px`;
2868
+ };
2827
2869
  const Text = 12;
2828
2870
  const text = data => {
2829
2871
  return {
@@ -2832,12 +2874,6 @@ const text = data => {
2832
2874
  childCount: 0
2833
2875
  };
2834
2876
  };
2835
- const px = value => {
2836
- return `${value}px`;
2837
- };
2838
- const position = (x, y) => {
2839
- return `${x}px ${y}px`;
2840
- };
2841
2877
 
2842
2878
  const quickPickHighlight = {
2843
2879
  type: Span,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-search-worker",
3
- "version": "5.15.0",
3
+ "version": "5.16.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "text-search"