cspell-lib 8.14.4 → 8.15.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/lib/Document/Document.d.ts +1 -1
- package/dist/lib/Document/isBinaryDoc.d.ts +1 -1
- package/dist/lib/Models/TextDocument.d.ts +2 -3
- package/dist/lib/Models/TextDocument.js +5 -8
- package/dist/lib/spellCheckFile.d.ts +1 -1
- package/dist/lib/util/IUri.d.ts +13 -0
- package/dist/lib/util/IUri.js +2 -0
- package/dist/lib/util/Uri.d.ts +3 -13
- package/dist/lib/util/Uri.js +5 -3
- package/dist/lib/util/text.d.ts +1 -1
- package/package.json +21 -20
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Uri } from '../util/
|
|
1
|
+
import type { Uri } from '../util/IUri.js';
|
|
2
2
|
import type { Document } from './Document.js';
|
|
3
3
|
export declare function isBinaryDoc(document: Document): boolean;
|
|
4
4
|
export declare function isBinaryFile(filename: Uri | URL | string, languageId?: string | string[], text?: string): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
1
|
+
import type { DocumentUri } from '../util/IUri.js';
|
|
2
|
+
export { documentUriToURL } from '../util/Uri.js';
|
|
3
3
|
export interface Position {
|
|
4
4
|
line: number;
|
|
5
5
|
character: number;
|
|
@@ -82,5 +82,4 @@ export declare function createTextDocument({ uri, content, languageId, locale, v
|
|
|
82
82
|
export declare function updateTextDocument(doc: TextDocument, edits: TextDocumentContentChangeEvent[], version?: number): TextDocument;
|
|
83
83
|
export declare function loadTextDocument(filename: string | DocumentUri, languageId?: string): Promise<TextDocument>;
|
|
84
84
|
export declare const isTextDocument: (doc: TextDocument | unknown) => doc is TextDocument;
|
|
85
|
-
export declare function documentUriToURL(uri: DocumentUri): URL;
|
|
86
85
|
//# sourceMappingURL=TextDocument.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
|
-
import { toFileURL, toURL } from '@cspell/url';
|
|
3
2
|
import { TextDocument as VsTextDocument } from 'vscode-languageserver-textdocument';
|
|
4
3
|
import { getFileSystem } from '../fileSystem.js';
|
|
5
4
|
import { getLanguagesForBasename } from '../fileTypes.js';
|
|
6
|
-
import
|
|
5
|
+
import { basename, documentUriToURL, toUri } from '../util/Uri.js';
|
|
6
|
+
export { documentUriToURL } from '../util/Uri.js';
|
|
7
7
|
class TextDocumentImpl {
|
|
8
8
|
languageId;
|
|
9
9
|
locale;
|
|
@@ -90,8 +90,8 @@ class TextDocumentImpl {
|
|
|
90
90
|
}
|
|
91
91
|
export function createTextDocument({ uri, content, languageId, locale, version, }) {
|
|
92
92
|
version = version ?? 1;
|
|
93
|
-
uri =
|
|
94
|
-
languageId = languageId ?? getLanguagesForBasename(
|
|
93
|
+
uri = toUri(uri);
|
|
94
|
+
languageId = languageId ?? getLanguagesForBasename(basename(uri));
|
|
95
95
|
languageId = languageId.length === 0 ? 'text' : languageId;
|
|
96
96
|
return new TextDocumentImpl(uri, content, languageId, locale, version);
|
|
97
97
|
}
|
|
@@ -103,13 +103,10 @@ function isTextDocumentImpl(doc) {
|
|
|
103
103
|
return doc instanceof TextDocumentImpl;
|
|
104
104
|
}
|
|
105
105
|
export async function loadTextDocument(filename, languageId) {
|
|
106
|
-
const uri =
|
|
106
|
+
const uri = toUri(filename);
|
|
107
107
|
const url = new URL(uri.toString());
|
|
108
108
|
const file = await getFileSystem().readFile(url);
|
|
109
109
|
return createTextDocument({ uri, languageId, content: file.getText() });
|
|
110
110
|
}
|
|
111
111
|
export const isTextDocument = isTextDocumentImpl;
|
|
112
|
-
export function documentUriToURL(uri) {
|
|
113
|
-
return toURL(uri instanceof URL ? uri : typeof uri === 'string' ? toFileURL(uri) : new URL(Uri.from(uri).toString()));
|
|
114
|
-
}
|
|
115
112
|
//# sourceMappingURL=TextDocument.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CSpellSettingsWithSourceTrace, CSpellUserSettings } from '@cspell/cspell-types';
|
|
2
2
|
import type { Document, DocumentWithText } from './Document/index.js';
|
|
3
|
-
import type { Uri } from './util/
|
|
3
|
+
import type { Uri } from './util/IUri.js';
|
|
4
4
|
import type { ValidateTextOptions, ValidationIssue } from './validator.js';
|
|
5
5
|
export interface SpellCheckFileOptions extends ValidateTextOptions {
|
|
6
6
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Uri {
|
|
2
|
+
readonly scheme: string;
|
|
3
|
+
readonly path: string;
|
|
4
|
+
readonly authority?: string;
|
|
5
|
+
readonly fragment?: string;
|
|
6
|
+
readonly query?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface UriInstance extends Uri {
|
|
9
|
+
toString(): string;
|
|
10
|
+
toJSON(): unknown;
|
|
11
|
+
}
|
|
12
|
+
export type DocumentUri = Uri | URL | string;
|
|
13
|
+
//# sourceMappingURL=IUri.d.ts.map
|
package/dist/lib/util/Uri.d.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { URI } from 'vscode-uri';
|
|
2
|
-
import { DocumentUri } from '
|
|
3
|
-
export interface Uri {
|
|
4
|
-
readonly scheme: string;
|
|
5
|
-
readonly path: string;
|
|
6
|
-
readonly authority?: string;
|
|
7
|
-
readonly fragment?: string;
|
|
8
|
-
readonly query?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface UriInstance extends Uri {
|
|
11
|
-
toString(): string;
|
|
12
|
-
toJSON(): unknown;
|
|
13
|
-
}
|
|
2
|
+
import type { DocumentUri, Uri, UriInstance } from './IUri.js';
|
|
14
3
|
export declare function toUri(uriOrFile: string | Uri | URL): UriInstance;
|
|
15
4
|
export declare function uriToFilePath(uri: DocumentUri): string;
|
|
16
5
|
export declare function fromFilePath(file: string): UriInstance;
|
|
@@ -24,7 +13,7 @@ export declare function dirname(uri: Uri): UriInstance;
|
|
|
24
13
|
export declare function extname(uri: Uri): string;
|
|
25
14
|
export declare function joinPath(uri: Uri, ...paths: string[]): UriInstance;
|
|
26
15
|
export declare function resolvePath(uri: Uri, ...paths: string[]): UriInstance;
|
|
27
|
-
export declare function
|
|
16
|
+
export declare function uriFrom(uri: Uri, ...parts: Partial<Uri>[]): UriInstance;
|
|
28
17
|
declare class UriImpl extends URI implements UriInstance {
|
|
29
18
|
constructor(uri: Uri);
|
|
30
19
|
toString(): string;
|
|
@@ -43,6 +32,7 @@ declare class UriImpl extends URI implements UriInstance {
|
|
|
43
32
|
static stdin(filePath?: string): UriImpl;
|
|
44
33
|
}
|
|
45
34
|
declare function normalizeFilePath(path: string): string;
|
|
35
|
+
export declare function documentUriToURL(uri: DocumentUri): URL;
|
|
46
36
|
export declare const __testing__: {
|
|
47
37
|
UriImpl: typeof UriImpl;
|
|
48
38
|
normalizeFilePath: typeof normalizeFilePath;
|
package/dist/lib/util/Uri.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import { pathToFileURL } from 'node:url';
|
|
3
|
-
import { toFilePathOrHref, toFileURL } from '@cspell/url';
|
|
3
|
+
import { toFilePathOrHref, toFileURL, toURL } from '@cspell/url';
|
|
4
4
|
import { isUrlLike } from 'cspell-io';
|
|
5
5
|
import { URI, Utils } from 'vscode-uri';
|
|
6
|
-
import { documentUriToURL } from '../Models/TextDocument.js';
|
|
7
6
|
const STDIN_PROTOCOL = 'stdin:';
|
|
8
7
|
export function toUri(uriOrFile) {
|
|
9
8
|
if (UriImpl.isUri(uriOrFile))
|
|
@@ -69,7 +68,7 @@ export function joinPath(uri, ...paths) {
|
|
|
69
68
|
export function resolvePath(uri, ...paths) {
|
|
70
69
|
return UriImpl.from(Utils.resolvePath(URI.from(uri), ...paths));
|
|
71
70
|
}
|
|
72
|
-
export function
|
|
71
|
+
export function uriFrom(uri, ...parts) {
|
|
73
72
|
return UriImpl.from(uri, ...parts);
|
|
74
73
|
}
|
|
75
74
|
const keys = ['scheme', 'authority', 'path', 'query', 'fragment'];
|
|
@@ -155,6 +154,9 @@ function parseStdinUri(uri) {
|
|
|
155
154
|
fragment: decodeURI(hash),
|
|
156
155
|
};
|
|
157
156
|
}
|
|
157
|
+
export function documentUriToURL(uri) {
|
|
158
|
+
return toURL(uri instanceof URL ? uri : typeof uri === 'string' ? toFileURL(uri) : new URL(uriFrom(uri).toString()));
|
|
159
|
+
}
|
|
158
160
|
export const __testing__ = {
|
|
159
161
|
UriImpl,
|
|
160
162
|
normalizeFilePath,
|
package/dist/lib/util/text.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TextDocumentOffset, TextOffset } from '@cspell/cspell-types';
|
|
2
|
-
import type { Uri } from './
|
|
2
|
+
import type { Uri } from './IUri.js';
|
|
3
3
|
export { stringToRegExp } from './textRegex.js';
|
|
4
4
|
export declare function splitCamelCaseWordWithOffset(wo: TextOffset): TextOffset[];
|
|
5
5
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-lib",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.15.0",
|
|
4
4
|
"description": "A library of useful functions used across various cspell tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"#test": "vitest run --reporter=hanging-process --reporter=default",
|
|
34
34
|
"test": "vitest run --pool=forks",
|
|
35
35
|
"test:update-snapshot": "vitest run -u",
|
|
36
|
-
"test:perf": "NODE_ENV=production insight --file \"**/*.perf.{
|
|
36
|
+
"test:perf": "NODE_ENV=production insight --file \"**/*.perf.{mjs,js}\"",
|
|
37
|
+
"test:perf:ts": "NODE_ENV=production insight --file \"**/*.perf.{mts,ts}\" --register ts-node/esm",
|
|
37
38
|
"test:perf:prof": "NODE_ENV=production node --cpu-prof ../../node_modules/perf-insight/bin.mjs --file \"dist/**/*.perf.{mjs,js}\" -t 1000"
|
|
38
39
|
},
|
|
39
40
|
"repository": {
|
|
@@ -59,22 +60,22 @@
|
|
|
59
60
|
},
|
|
60
61
|
"homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-lib#readme",
|
|
61
62
|
"dependencies": {
|
|
62
|
-
"@cspell/cspell-bundled-dicts": "8.
|
|
63
|
-
"@cspell/cspell-pipe": "8.
|
|
64
|
-
"@cspell/cspell-resolver": "8.
|
|
65
|
-
"@cspell/cspell-types": "8.
|
|
66
|
-
"@cspell/dynamic-import": "8.
|
|
67
|
-
"@cspell/filetypes": "8.
|
|
68
|
-
"@cspell/strong-weak-map": "8.
|
|
69
|
-
"@cspell/url": "8.
|
|
63
|
+
"@cspell/cspell-bundled-dicts": "8.15.0",
|
|
64
|
+
"@cspell/cspell-pipe": "8.15.0",
|
|
65
|
+
"@cspell/cspell-resolver": "8.15.0",
|
|
66
|
+
"@cspell/cspell-types": "8.15.0",
|
|
67
|
+
"@cspell/dynamic-import": "8.15.0",
|
|
68
|
+
"@cspell/filetypes": "8.15.0",
|
|
69
|
+
"@cspell/strong-weak-map": "8.15.0",
|
|
70
|
+
"@cspell/url": "8.15.0",
|
|
70
71
|
"clear-module": "^4.1.2",
|
|
71
72
|
"comment-json": "^4.2.5",
|
|
72
|
-
"cspell-config-lib": "8.
|
|
73
|
-
"cspell-dictionary": "8.
|
|
74
|
-
"cspell-glob": "8.
|
|
75
|
-
"cspell-grammar": "8.
|
|
76
|
-
"cspell-io": "8.
|
|
77
|
-
"cspell-trie-lib": "8.
|
|
73
|
+
"cspell-config-lib": "8.15.0",
|
|
74
|
+
"cspell-dictionary": "8.15.0",
|
|
75
|
+
"cspell-glob": "8.15.0",
|
|
76
|
+
"cspell-grammar": "8.15.0",
|
|
77
|
+
"cspell-io": "8.15.0",
|
|
78
|
+
"cspell-trie-lib": "8.15.0",
|
|
78
79
|
"env-paths": "^3.0.0",
|
|
79
80
|
"fast-equals": "^5.0.1",
|
|
80
81
|
"gensequence": "^7.0.0",
|
|
@@ -88,14 +89,14 @@
|
|
|
88
89
|
"node": ">=18"
|
|
89
90
|
},
|
|
90
91
|
"devDependencies": {
|
|
91
|
-
"@cspell/dict-cpp": "^5.1.
|
|
92
|
+
"@cspell/dict-cpp": "^5.1.19",
|
|
92
93
|
"@cspell/dict-csharp": "^4.0.2",
|
|
93
94
|
"@cspell/dict-css": "^4.0.13",
|
|
94
95
|
"@cspell/dict-fa-ir": "^4.0.0",
|
|
95
96
|
"@cspell/dict-fr-fr": "^2.2.2",
|
|
96
|
-
"@cspell/dict-html": "^4.0.
|
|
97
|
+
"@cspell/dict-html": "^4.0.6",
|
|
97
98
|
"@cspell/dict-nl-nl": "^2.3.0",
|
|
98
|
-
"@cspell/dict-python": "^4.2.
|
|
99
|
+
"@cspell/dict-python": "^4.2.8",
|
|
99
100
|
"@types/configstore": "^6.0.2",
|
|
100
101
|
"configstore": "^7.0.0",
|
|
101
102
|
"cspell-dict-nl-nl": "^1.1.2",
|
|
@@ -103,5 +104,5 @@
|
|
|
103
104
|
"lorem-ipsum": "^2.0.8",
|
|
104
105
|
"perf-insight": "^1.2.0"
|
|
105
106
|
},
|
|
106
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "60b04562dfa023eede01929d86fa944163c07256"
|
|
107
108
|
}
|