@lvce-editor/text-search-worker 7.19.0 → 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 +35 -11
- 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
|
}
|
|
@@ -1622,23 +1642,27 @@ const textSearch$2 = async (scheme, root, query, options, assetDir) => {
|
|
|
1622
1642
|
}
|
|
1623
1643
|
};
|
|
1624
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 = /\/$/;
|
|
1625
1649
|
const normalizeWindowsDrive = path => {
|
|
1626
|
-
return
|
|
1650
|
+
return windowsDrivePathRegex.test(path) ? path.slice(1) : path;
|
|
1627
1651
|
};
|
|
1628
1652
|
const toPath = uri => {
|
|
1629
1653
|
if (uri.startsWith('file://')) {
|
|
1630
1654
|
return normalizeWindowsDrive(decodeURIComponent(new URL(uri).pathname)).replaceAll('\\', '/');
|
|
1631
1655
|
}
|
|
1632
|
-
if (
|
|
1656
|
+
if (windowsDriveRegex.test(uri)) {
|
|
1633
1657
|
return uri.replaceAll('\\', '/');
|
|
1634
1658
|
}
|
|
1635
|
-
if (
|
|
1659
|
+
if (uriSchemeRegex.test(uri)) {
|
|
1636
1660
|
return '';
|
|
1637
1661
|
}
|
|
1638
1662
|
return uri.replaceAll('\\', '/');
|
|
1639
1663
|
};
|
|
1640
1664
|
const getOpenEditorPaths = (root, openEditorUris) => {
|
|
1641
|
-
const rootPath = toPath(root).replace(
|
|
1665
|
+
const rootPath = toPath(root).replace(trailingSlashRegex, '');
|
|
1642
1666
|
const rootPrefix = `${rootPath}/`;
|
|
1643
1667
|
const paths = openEditorUris.map(toPath).filter(path => path.startsWith(rootPrefix)).map(path => path.slice(rootPrefix.length));
|
|
1644
1668
|
return [...new Set(paths)];
|