@lvce-editor/quick-pick-worker 4.23.1 → 4.24.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.
@@ -663,6 +663,9 @@ const restoreExistingError = (error, currentStack) => {
663
663
  };
664
664
  const restoreMethodNotFoundError = (error, currentStack) => {
665
665
  const restoredError = new JsonRpcError(error.message);
666
+ Object.assign(restoredError, {
667
+ code: error.code
668
+ });
666
669
  const parentStack = getParentStack(error);
667
670
  setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
668
671
  return restoredError;
@@ -682,9 +685,13 @@ const applyDataProperties = (restoredError, error) => {
682
685
  // @ts-ignore
683
686
  restoredError.codeFrame = error.data.codeFrame;
684
687
  }
685
- if (error.data.code) {
688
+ if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
686
689
  // @ts-ignore
687
- restoredError.code = error.data.code;
690
+ Object.defineProperty(restoredError, 'code', {
691
+ configurable: true,
692
+ value: error.data.code,
693
+ writable: true
694
+ });
688
695
  }
689
696
  if (error.data.type) {
690
697
  // @ts-ignore
@@ -705,7 +712,14 @@ const applyDirectProperties = (restoredError, error) => {
705
712
  }
706
713
  };
707
714
  const restoreMessageError = (error, _currentStack) => {
708
- const restoredError = constructError(error.message, error.type, error.name);
715
+ const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
716
+ if (typeof error.code === 'string' || typeof error.code === 'number') {
717
+ Object.defineProperty(restoredError, 'code', {
718
+ configurable: true,
719
+ value: error.code,
720
+ writable: true
721
+ });
722
+ }
709
723
  if (error.data) {
710
724
  applyDataProperties(restoredError, error);
711
725
  } else {
@@ -713,6 +727,23 @@ const restoreMessageError = (error, _currentStack) => {
713
727
  }
714
728
  return restoredError;
715
729
  };
730
+ const getFallbackMessage = error => {
731
+ if (error && typeof error.message === 'string' && error.message) {
732
+ return error.message;
733
+ }
734
+ if (error && error.data) {
735
+ return getFallbackMessage(error.data);
736
+ }
737
+ const stringified = String(error);
738
+ if (stringified !== '[object Object]') {
739
+ return stringified;
740
+ }
741
+ try {
742
+ return JSON.stringify(error);
743
+ } catch {
744
+ return stringified;
745
+ }
746
+ };
716
747
  const restoreJsonRpcError = error => {
717
748
  const currentStack = getCurrentStack();
718
749
  if (error && error instanceof Error) {
@@ -721,13 +752,13 @@ const restoreJsonRpcError = error => {
721
752
  if (error && error.code && error.code === MethodNotFound) {
722
753
  return restoreMethodNotFoundError(error, currentStack);
723
754
  }
755
+ if (error && error.error) {
756
+ return restoreJsonRpcError(error.error);
757
+ }
724
758
  if (error && error.message) {
725
759
  return restoreMessageError(error);
726
760
  }
727
- if (typeof error === 'string') {
728
- return new Error(`JsonRpc Error: ${error}`);
729
- }
730
- return new Error(`JsonRpc Error: ${error}`);
761
+ return new Error(`JsonRpc Error: ${getFallbackMessage(error)}`);
731
762
  };
732
763
  const unwrapJsonRpcResult = responseMessage => {
733
764
  if ('error' in responseMessage) {
@@ -784,9 +815,9 @@ const getErrorProperty = (error, prettyError) => {
784
815
  return {
785
816
  code: Custom$2,
786
817
  data: {
787
- code: prettyError.code,
818
+ code: prettyError.code ?? error?.code,
788
819
  codeFrame: prettyError.codeFrame,
789
- name: prettyError.name,
820
+ name: prettyError.name ?? error?.name,
790
821
  stack: getStack(prettyError),
791
822
  type: getErrorType(prettyError)
792
823
  },
@@ -821,7 +852,12 @@ const getErrorResponseSimple = (id, error) => {
821
852
  return {
822
853
  error: {
823
854
  code: Custom$2,
824
- data: error,
855
+ data: error instanceof Error ? {
856
+ ...error,
857
+ code: 'code' in error ? error.code : undefined,
858
+ stack: error.stack,
859
+ type: error.name
860
+ } : error,
825
861
  // @ts-ignore
826
862
  message: error.message
827
863
  },
@@ -3441,7 +3477,7 @@ const getPath = uri => {
3441
3477
  }
3442
3478
  return uri;
3443
3479
  };
3444
- const toProtoVisibleItem = uri => {
3480
+ const toProtoVisibleItem = (uri, homeDir) => {
3445
3481
  const path = getPath(uri);
3446
3482
  const isRemoteSsh = uri.startsWith(remoteSshScheme);
3447
3483
  const authority = isRemoteSsh ? getRemoteSshAuthority(uri) : '';
@@ -3455,6 +3491,9 @@ const toProtoVisibleItem = uri => {
3455
3491
  let description = '';
3456
3492
  if (path.startsWith('/')) {
3457
3493
  description = pathDirName(path);
3494
+ if (homeDir && !isRemoteSsh && description.startsWith(homeDir) && (description.length === homeDir.length || description[homeDir.length] === '/')) {
3495
+ description = `~${description.slice(homeDir.length)}`;
3496
+ }
3458
3497
  }
3459
3498
  if (path === '/' && isRemoteSsh) {
3460
3499
  description = '/';
@@ -3474,7 +3513,13 @@ const toProtoVisibleItem = uri => {
3474
3513
  };
3475
3514
  const getPicks$6 = async () => {
3476
3515
  const recentlyOpened = await getRecentlyOpened();
3477
- const picks = recentlyOpened.map(toProtoVisibleItem);
3516
+ let homeDir;
3517
+ try {
3518
+ homeDir = await invoke$3('Workspace.getHomeDir');
3519
+ } catch {
3520
+ // Ignore unavailable workspace RPCs and keep the full path.
3521
+ }
3522
+ const picks = recentlyOpened.map(uri => toProtoVisibleItem(uri, homeDir));
3478
3523
  return picks;
3479
3524
  };
3480
3525
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/quick-pick-worker",
3
- "version": "4.23.1",
3
+ "version": "4.24.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/quick-pick-worker.git"