@lvce-editor/text-search-worker 7.22.1 → 7.23.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.
- package/dist/textSearchWorkerMain.js +55 -21
- package/package.json +1 -1
|
@@ -63,7 +63,7 @@ class AssertionError extends Error {
|
|
|
63
63
|
const Object$1 = 1;
|
|
64
64
|
const Number = 2;
|
|
65
65
|
const Array$1 = 3;
|
|
66
|
-
const String = 4;
|
|
66
|
+
const String$1 = 4;
|
|
67
67
|
const Boolean$1 = 5;
|
|
68
68
|
const Function = 6;
|
|
69
69
|
const Null = 7;
|
|
@@ -75,7 +75,7 @@ const getType = value => {
|
|
|
75
75
|
case 'function':
|
|
76
76
|
return Function;
|
|
77
77
|
case 'string':
|
|
78
|
-
return String;
|
|
78
|
+
return String$1;
|
|
79
79
|
case 'object':
|
|
80
80
|
if (value === null) {
|
|
81
81
|
return Null;
|
|
@@ -92,7 +92,7 @@ const getType = value => {
|
|
|
92
92
|
};
|
|
93
93
|
const string = value => {
|
|
94
94
|
const type = getType(value);
|
|
95
|
-
if (type !== String) {
|
|
95
|
+
if (type !== String$1) {
|
|
96
96
|
throw new AssertionError('expected value to be of type string');
|
|
97
97
|
}
|
|
98
98
|
};
|
|
@@ -738,9 +738,12 @@ const applyDataProperties = (restoredError, error) => {
|
|
|
738
738
|
writable: true
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
restoredError
|
|
741
|
+
const name = error.data.name || error.data.type;
|
|
742
|
+
if (name) {
|
|
743
|
+
Object.defineProperty(restoredError, 'name', {
|
|
744
|
+
configurable: true,
|
|
745
|
+
value: name
|
|
746
|
+
});
|
|
744
747
|
}
|
|
745
748
|
};
|
|
746
749
|
const applyDirectProperties = (restoredError, error) => {
|
|
@@ -757,7 +760,7 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
757
760
|
}
|
|
758
761
|
};
|
|
759
762
|
const restoreMessageError = (error, _currentStack) => {
|
|
760
|
-
const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
|
|
763
|
+
const restoredError = constructError(error.message, error.type || error.data?.type, error.name || error.data?.name);
|
|
761
764
|
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
762
765
|
Object.defineProperty(restoredError, 'code', {
|
|
763
766
|
configurable: true,
|
|
@@ -772,6 +775,23 @@ const restoreMessageError = (error, _currentStack) => {
|
|
|
772
775
|
}
|
|
773
776
|
return restoredError;
|
|
774
777
|
};
|
|
778
|
+
const getFallbackMessage = error => {
|
|
779
|
+
if (error && typeof error.message === 'string' && error.message) {
|
|
780
|
+
return error.message;
|
|
781
|
+
}
|
|
782
|
+
if (error && error.data) {
|
|
783
|
+
return getFallbackMessage(error.data);
|
|
784
|
+
}
|
|
785
|
+
const stringified = String(error);
|
|
786
|
+
if (stringified !== '[object Object]') {
|
|
787
|
+
return stringified;
|
|
788
|
+
}
|
|
789
|
+
try {
|
|
790
|
+
return JSON.stringify(error);
|
|
791
|
+
} catch {
|
|
792
|
+
return stringified;
|
|
793
|
+
}
|
|
794
|
+
};
|
|
775
795
|
const restoreJsonRpcError = error => {
|
|
776
796
|
const currentStack = getCurrentStack();
|
|
777
797
|
if (error && error instanceof Error) {
|
|
@@ -780,13 +800,13 @@ const restoreJsonRpcError = error => {
|
|
|
780
800
|
if (error && error.code && error.code === MethodNotFound) {
|
|
781
801
|
return restoreMethodNotFoundError(error, currentStack);
|
|
782
802
|
}
|
|
803
|
+
if (error && error.error) {
|
|
804
|
+
return restoreJsonRpcError(error.error);
|
|
805
|
+
}
|
|
783
806
|
if (error && error.message) {
|
|
784
807
|
return restoreMessageError(error);
|
|
785
808
|
}
|
|
786
|
-
|
|
787
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
788
|
-
}
|
|
789
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
809
|
+
return new Error(`JsonRpc Error: ${getFallbackMessage(error)}`);
|
|
790
810
|
};
|
|
791
811
|
const unwrapJsonRpcResult = responseMessage => {
|
|
792
812
|
if ('error' in responseMessage) {
|
|
@@ -950,6 +970,12 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
950
970
|
requiresSocket,
|
|
951
971
|
resolve
|
|
952
972
|
} = options;
|
|
973
|
+
if (message === 'ready') {
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
if (!message || typeof message !== 'object') {
|
|
977
|
+
throw new JsonRpcError('unexpected message');
|
|
978
|
+
}
|
|
953
979
|
if ('id' in message) {
|
|
954
980
|
if ('method' in message) {
|
|
955
981
|
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
@@ -1067,6 +1093,9 @@ const logError = () => {
|
|
|
1067
1093
|
// handled by renderer worker
|
|
1068
1094
|
};
|
|
1069
1095
|
const handleMessage = event => {
|
|
1096
|
+
if (event.data === 'ready') {
|
|
1097
|
+
return Promise.resolve();
|
|
1098
|
+
}
|
|
1070
1099
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
1071
1100
|
const actualExecute = event?.target?.execute || execute;
|
|
1072
1101
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
@@ -1366,6 +1395,12 @@ const {
|
|
|
1366
1395
|
invokeAndTransfer,
|
|
1367
1396
|
set: set$3
|
|
1368
1397
|
} = create(RendererWorker);
|
|
1398
|
+
const initializeRendererWorkerForWorker = async commandMap => {
|
|
1399
|
+
const rpc = await create$1({
|
|
1400
|
+
commandMap
|
|
1401
|
+
});
|
|
1402
|
+
set$3(rpc);
|
|
1403
|
+
};
|
|
1369
1404
|
const sendMessagePortToSearchProcess = async port => {
|
|
1370
1405
|
await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
|
|
1371
1406
|
};
|
|
@@ -1505,12 +1540,11 @@ const getContextArgs = contextLines => {
|
|
|
1505
1540
|
}
|
|
1506
1541
|
return [];
|
|
1507
1542
|
};
|
|
1508
|
-
|
|
1509
|
-
return part.trim();
|
|
1510
|
-
};
|
|
1543
|
+
|
|
1511
1544
|
const hasGlob = pattern => {
|
|
1512
1545
|
return pattern.includes('*') || pattern.includes('?') || pattern.includes('[') || pattern.includes('{');
|
|
1513
1546
|
};
|
|
1547
|
+
|
|
1514
1548
|
const toGlob = pattern => {
|
|
1515
1549
|
const args = ['--glob', pattern];
|
|
1516
1550
|
if (!hasGlob(pattern)) {
|
|
@@ -1521,9 +1555,15 @@ const toGlob = pattern => {
|
|
|
1521
1555
|
}
|
|
1522
1556
|
return args;
|
|
1523
1557
|
};
|
|
1558
|
+
|
|
1559
|
+
const trimPart = part => {
|
|
1560
|
+
return part.trim();
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1524
1563
|
const getIncludeArgs = include => {
|
|
1525
1564
|
return (include || '').split(',').map(trimPart).filter(Boolean).flatMap(toGlob);
|
|
1526
1565
|
};
|
|
1566
|
+
|
|
1527
1567
|
const getRipGrepArgs = ({
|
|
1528
1568
|
contextLines,
|
|
1529
1569
|
defaultExcludes,
|
|
@@ -1763,16 +1803,10 @@ const textSearchProviderMap = {
|
|
|
1763
1803
|
web: textSearch
|
|
1764
1804
|
};
|
|
1765
1805
|
|
|
1766
|
-
const initializeRendererWorker = async () => {
|
|
1767
|
-
const rpc = await create$1({
|
|
1768
|
-
commandMap: commandMapRef
|
|
1769
|
-
});
|
|
1770
|
-
set$3(rpc);
|
|
1771
|
-
};
|
|
1772
1806
|
const listen = async () => {
|
|
1773
1807
|
Object.assign(commandMapRef, commandMap);
|
|
1774
1808
|
add(textSearchProviderMap);
|
|
1775
|
-
await
|
|
1809
|
+
await initializeRendererWorkerForWorker(commandMapRef);
|
|
1776
1810
|
};
|
|
1777
1811
|
|
|
1778
1812
|
const main = async () => {
|