@lvce-editor/text-search-worker 7.18.2 → 7.20.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 +48 -15
- package/package.json +1 -1
|
@@ -708,6 +708,9 @@ const restoreExistingError = (error, currentStack) => {
|
|
|
708
708
|
};
|
|
709
709
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
710
710
|
const restoredError = new JsonRpcError(error.message);
|
|
711
|
+
Object.assign(restoredError, {
|
|
712
|
+
code: error.code
|
|
713
|
+
});
|
|
711
714
|
const parentStack = getParentStack(error);
|
|
712
715
|
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
713
716
|
return restoredError;
|
|
@@ -727,9 +730,13 @@ const applyDataProperties = (restoredError, error) => {
|
|
|
727
730
|
// @ts-ignore
|
|
728
731
|
restoredError.codeFrame = error.data.codeFrame;
|
|
729
732
|
}
|
|
730
|
-
if (error.data.code) {
|
|
733
|
+
if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
|
|
731
734
|
// @ts-ignore
|
|
732
|
-
restoredError
|
|
735
|
+
Object.defineProperty(restoredError, 'code', {
|
|
736
|
+
configurable: true,
|
|
737
|
+
value: error.data.code,
|
|
738
|
+
writable: true
|
|
739
|
+
});
|
|
733
740
|
}
|
|
734
741
|
if (error.data.type) {
|
|
735
742
|
// @ts-ignore
|
|
@@ -750,7 +757,14 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
750
757
|
}
|
|
751
758
|
};
|
|
752
759
|
const restoreMessageError = (error, _currentStack) => {
|
|
753
|
-
const restoredError = constructError(error.message, error.type, error.name);
|
|
760
|
+
const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
|
|
761
|
+
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
762
|
+
Object.defineProperty(restoredError, 'code', {
|
|
763
|
+
configurable: true,
|
|
764
|
+
value: error.code,
|
|
765
|
+
writable: true
|
|
766
|
+
});
|
|
767
|
+
}
|
|
754
768
|
if (error.data) {
|
|
755
769
|
applyDataProperties(restoredError, error);
|
|
756
770
|
} else {
|
|
@@ -829,9 +843,9 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
829
843
|
return {
|
|
830
844
|
code: Custom,
|
|
831
845
|
data: {
|
|
832
|
-
code: prettyError.code,
|
|
846
|
+
code: prettyError.code ?? error?.code,
|
|
833
847
|
codeFrame: prettyError.codeFrame,
|
|
834
|
-
name: prettyError.name,
|
|
848
|
+
name: prettyError.name ?? error?.name,
|
|
835
849
|
stack: getStack(prettyError),
|
|
836
850
|
type: getErrorType(prettyError)
|
|
837
851
|
},
|
|
@@ -866,7 +880,12 @@ const getErrorResponseSimple = (id, error) => {
|
|
|
866
880
|
return {
|
|
867
881
|
error: {
|
|
868
882
|
code: Custom,
|
|
869
|
-
data: error
|
|
883
|
+
data: error instanceof Error ? {
|
|
884
|
+
...error,
|
|
885
|
+
code: 'code' in error ? error.code : undefined,
|
|
886
|
+
stack: error.stack,
|
|
887
|
+
type: error.name
|
|
888
|
+
} : error,
|
|
870
889
|
// @ts-ignore
|
|
871
890
|
message: error.message
|
|
872
891
|
},
|
|
@@ -1412,6 +1431,7 @@ const launchSearchProcessElectron = async () => {
|
|
|
1412
1431
|
});
|
|
1413
1432
|
};
|
|
1414
1433
|
|
|
1434
|
+
const commandNotFoundRegex = /command not found|not found/i;
|
|
1415
1435
|
const launchSearchProcessNode = async () => {
|
|
1416
1436
|
try {
|
|
1417
1437
|
const {
|
|
@@ -1423,7 +1443,7 @@ const launchSearchProcessNode = async () => {
|
|
|
1423
1443
|
webSocket: new WebSocket(url, protocols)
|
|
1424
1444
|
});
|
|
1425
1445
|
} catch (error) {
|
|
1426
|
-
if (!(error instanceof Error && (error.message.includes('WebSocketCapability.create') || error.message.includes('module WebSocketCapability not found')) &&
|
|
1446
|
+
if (!(error instanceof Error && (error.message.includes('WebSocketCapability.create') || error.message.includes('module WebSocketCapability not found')) && commandNotFoundRegex.test(error.message))) {
|
|
1427
1447
|
throw error;
|
|
1428
1448
|
}
|
|
1429
1449
|
}
|
|
@@ -1485,8 +1505,14 @@ const getContextArgs = contextLines => {
|
|
|
1485
1505
|
}
|
|
1486
1506
|
return [];
|
|
1487
1507
|
};
|
|
1508
|
+
const trimPart = part => {
|
|
1509
|
+
return part.trim();
|
|
1510
|
+
};
|
|
1511
|
+
const toGlob = pattern => {
|
|
1512
|
+
return ['--glob', pattern];
|
|
1513
|
+
};
|
|
1488
1514
|
const getIncludeArgs = include => {
|
|
1489
|
-
return (include || '').split(',').map(
|
|
1515
|
+
return (include || '').split(',').map(trimPart).filter(Boolean).flatMap(toGlob);
|
|
1490
1516
|
};
|
|
1491
1517
|
const getRipGrepArgs = ({
|
|
1492
1518
|
contextLines,
|
|
@@ -1616,23 +1642,27 @@ const textSearch$2 = async (scheme, root, query, options, assetDir) => {
|
|
|
1616
1642
|
}
|
|
1617
1643
|
};
|
|
1618
1644
|
|
|
1645
|
+
const windowsDrivePathRegex = /^\/[A-Za-z]:\//;
|
|
1646
|
+
const windowsDriveRegex = /^[A-Za-z]:[\\/]/;
|
|
1647
|
+
const uriSchemeRegex = /^[A-Za-z][A-Za-z\d+.-]*:/;
|
|
1648
|
+
const trailingSlashRegex = /\/$/;
|
|
1619
1649
|
const normalizeWindowsDrive = path => {
|
|
1620
|
-
return
|
|
1650
|
+
return windowsDrivePathRegex.test(path) ? path.slice(1) : path;
|
|
1621
1651
|
};
|
|
1622
1652
|
const toPath = uri => {
|
|
1623
1653
|
if (uri.startsWith('file://')) {
|
|
1624
1654
|
return normalizeWindowsDrive(decodeURIComponent(new URL(uri).pathname)).replaceAll('\\', '/');
|
|
1625
1655
|
}
|
|
1626
|
-
if (
|
|
1656
|
+
if (windowsDriveRegex.test(uri)) {
|
|
1627
1657
|
return uri.replaceAll('\\', '/');
|
|
1628
1658
|
}
|
|
1629
|
-
if (
|
|
1659
|
+
if (uriSchemeRegex.test(uri)) {
|
|
1630
1660
|
return '';
|
|
1631
1661
|
}
|
|
1632
1662
|
return uri.replaceAll('\\', '/');
|
|
1633
1663
|
};
|
|
1634
1664
|
const getOpenEditorPaths = (root, openEditorUris) => {
|
|
1635
|
-
const rootPath = toPath(root).replace(
|
|
1665
|
+
const rootPath = toPath(root).replace(trailingSlashRegex, '');
|
|
1636
1666
|
const rootPrefix = `${rootPath}/`;
|
|
1637
1667
|
const paths = openEditorUris.map(toPath).filter(path => path.startsWith(rootPrefix)).map(path => path.slice(rootPrefix.length));
|
|
1638
1668
|
return [...new Set(paths)];
|
|
@@ -1696,14 +1726,17 @@ const textSearchProviderMap = {
|
|
|
1696
1726
|
web: textSearch
|
|
1697
1727
|
};
|
|
1698
1728
|
|
|
1699
|
-
const
|
|
1700
|
-
Object.assign(commandMapRef, commandMap);
|
|
1701
|
-
add(textSearchProviderMap);
|
|
1729
|
+
const initializeRendererWorker = async () => {
|
|
1702
1730
|
const rpc = await create$1({
|
|
1703
1731
|
commandMap: commandMapRef
|
|
1704
1732
|
});
|
|
1705
1733
|
set$3(rpc);
|
|
1706
1734
|
};
|
|
1735
|
+
const listen = async () => {
|
|
1736
|
+
Object.assign(commandMapRef, commandMap);
|
|
1737
|
+
add(textSearchProviderMap);
|
|
1738
|
+
await initializeRendererWorker();
|
|
1739
|
+
};
|
|
1707
1740
|
|
|
1708
1741
|
const main = async () => {
|
|
1709
1742
|
await listen();
|