@lvce-editor/search-process 15.11.0 → 15.12.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.
Files changed (2) hide show
  1. package/dist/index.js +52 -13
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -109,7 +109,7 @@ class AssertionError extends Error {
109
109
  const Object$1 = 1;
110
110
  const Number = 2;
111
111
  const Array$1 = 3;
112
- const String = 4;
112
+ const String$1 = 4;
113
113
  const Boolean = 5;
114
114
  const Function = 6;
115
115
  const Null = 7;
@@ -121,7 +121,7 @@ const getType = value => {
121
121
  case 'function':
122
122
  return Function;
123
123
  case 'string':
124
- return String;
124
+ return String$1;
125
125
  case 'object':
126
126
  if (value === null) {
127
127
  return Null;
@@ -156,7 +156,7 @@ const array = value => {
156
156
  };
157
157
  const string = value => {
158
158
  const type = getType(value);
159
- if (type !== String) {
159
+ if (type !== String$1) {
160
160
  throw new AssertionError('expected value to be of type string');
161
161
  }
162
162
  };
@@ -931,6 +931,9 @@ const restoreExistingError = (error, currentStack) => {
931
931
  };
932
932
  const restoreMethodNotFoundError = (error, currentStack) => {
933
933
  const restoredError = new JsonRpcError(error.message);
934
+ Object.assign(restoredError, {
935
+ code: error.code
936
+ });
934
937
  const parentStack = getParentStack(error);
935
938
  setStack(restoredError, `${parentStack}${NewLine$1}${currentStack}`);
936
939
  return restoredError;
@@ -950,9 +953,13 @@ const applyDataProperties = (restoredError, error) => {
950
953
  // @ts-ignore
951
954
  restoredError.codeFrame = error.data.codeFrame;
952
955
  }
953
- if (error.data.code) {
956
+ if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
954
957
  // @ts-ignore
955
- restoredError.code = error.data.code;
958
+ Object.defineProperty(restoredError, 'code', {
959
+ configurable: true,
960
+ value: error.data.code,
961
+ writable: true
962
+ });
956
963
  }
957
964
  if (error.data.type) {
958
965
  // @ts-ignore
@@ -973,7 +980,14 @@ const applyDirectProperties = (restoredError, error) => {
973
980
  }
974
981
  };
975
982
  const restoreMessageError = (error, _currentStack) => {
976
- const restoredError = constructError(error.message, error.type, error.name);
983
+ const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
984
+ if (typeof error.code === 'string' || typeof error.code === 'number') {
985
+ Object.defineProperty(restoredError, 'code', {
986
+ configurable: true,
987
+ value: error.code,
988
+ writable: true
989
+ });
990
+ }
977
991
  if (error.data) {
978
992
  applyDataProperties(restoredError, error);
979
993
  } else {
@@ -981,6 +995,23 @@ const restoreMessageError = (error, _currentStack) => {
981
995
  }
982
996
  return restoredError;
983
997
  };
998
+ const getFallbackMessage = error => {
999
+ if (error && typeof error.message === 'string' && error.message) {
1000
+ return error.message;
1001
+ }
1002
+ if (error && error.data) {
1003
+ return getFallbackMessage(error.data);
1004
+ }
1005
+ const stringified = String(error);
1006
+ if (stringified !== '[object Object]') {
1007
+ return stringified;
1008
+ }
1009
+ try {
1010
+ return JSON.stringify(error);
1011
+ } catch {
1012
+ return stringified;
1013
+ }
1014
+ };
984
1015
  const restoreJsonRpcError = error => {
985
1016
  const currentStack = getCurrentStack();
986
1017
  if (error && error instanceof Error) {
@@ -989,13 +1020,13 @@ const restoreJsonRpcError = error => {
989
1020
  if (error && error.code && error.code === MethodNotFound) {
990
1021
  return restoreMethodNotFoundError(error, currentStack);
991
1022
  }
1023
+ if (error && error.error) {
1024
+ return restoreJsonRpcError(error.error);
1025
+ }
992
1026
  if (error && error.message) {
993
1027
  return restoreMessageError(error);
994
1028
  }
995
- if (typeof error === 'string') {
996
- return new Error(`JsonRpc Error: ${error}`);
997
- }
998
- return new Error(`JsonRpc Error: ${error}`);
1029
+ return new Error(`JsonRpc Error: ${getFallbackMessage(error)}`);
999
1030
  };
1000
1031
  const unwrapJsonRpcResult = responseMessage => {
1001
1032
  if ('error' in responseMessage) {
@@ -1052,9 +1083,9 @@ const getErrorProperty = (error, prettyError) => {
1052
1083
  return {
1053
1084
  code: Custom,
1054
1085
  data: {
1055
- code: prettyError.code,
1086
+ code: prettyError.code ?? error?.code,
1056
1087
  codeFrame: prettyError.codeFrame,
1057
- name: prettyError.name,
1088
+ name: prettyError.name ?? error?.name,
1058
1089
  stack: getStack(prettyError),
1059
1090
  type: getErrorType(prettyError)
1060
1091
  },
@@ -1089,7 +1120,12 @@ const getErrorResponseSimple = (id, error) => {
1089
1120
  return {
1090
1121
  error: {
1091
1122
  code: Custom,
1092
- data: error,
1123
+ data: error instanceof Error ? {
1124
+ ...error,
1125
+ code: 'code' in error ? error.code : undefined,
1126
+ stack: error.stack,
1127
+ type: error.name
1128
+ } : error,
1093
1129
  // @ts-ignore
1094
1130
  message: error.message
1095
1131
  },
@@ -1271,6 +1307,9 @@ const logError = () => {
1271
1307
  // handled by renderer worker
1272
1308
  };
1273
1309
  const handleMessage = event => {
1310
+ if (event.data === 'ready') {
1311
+ return Promise.resolve();
1312
+ }
1274
1313
  const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket$1;
1275
1314
  const actualExecute = event?.target?.execute || execute;
1276
1315
  return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/search-process",
3
- "version": "15.11.0",
3
+ "version": "15.12.0",
4
4
  "description": "Search Process",
5
5
  "keywords": [
6
6
  "Lvce Editor",
@@ -18,11 +18,11 @@
18
18
  "search-process": "bin/searchProcess.js"
19
19
  },
20
20
  "dependencies": {
21
- "execa": "^9.6.1",
22
- "ws": "^8.21.3"
21
+ "execa": "^10.0.1",
22
+ "ws": "^8.22.0"
23
23
  },
24
24
  "optionalDependencies": {
25
- "@lvce-editor/ripgrep": "^5.2.0"
25
+ "@lvce-editor/ripgrep": "^5.7.0"
26
26
  },
27
27
  "engines": {
28
28
  "node": ">=24"