cspell-lib 6.26.3 → 6.28.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/Document/Document.d.ts +2 -0
- package/dist/Document/isBinaryDoc.d.ts +3 -2
- package/dist/Document/isBinaryDoc.js +6 -5
- package/dist/Document/resolveDocument.js +28 -5
- package/dist/LanguageIds.js +2 -1
- package/dist/Models/TextDocument.d.ts +21 -1
- package/dist/Models/TextDocument.js +2 -2
- package/dist/Settings/CSpellSettingsServer.js +19 -7
- package/dist/Settings/Controller/configLoader/PnPSettings.d.ts +12 -0
- package/dist/Settings/Controller/configLoader/PnPSettings.js +26 -0
- package/dist/Settings/Controller/configLoader/configLoader.d.ts +40 -41
- package/dist/Settings/Controller/configLoader/configLoader.js +83 -76
- package/dist/Settings/Controller/pnpLoader.d.ts +6 -6
- package/dist/Settings/Controller/pnpLoader.js +5 -5
- package/dist/Settings/LanguageSettings.js +8 -1
- package/dist/Settings/TextDocumentSettings.d.ts +1 -1
- package/dist/Settings/TextDocumentSettings.js +3 -0
- package/dist/exclusionHelper.js +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/spellCheckFile.d.ts +3 -1
- package/dist/spellCheckFile.js +2 -2
- package/dist/test/test.matchers.d.ts +9 -0
- package/dist/test/test.matchers.js +27 -0
- package/dist/textValidation/determineTextDocumentSettings.d.ts +2 -2
- package/dist/textValidation/determineTextDocumentSettings.js +2 -1
- package/dist/textValidation/docValidator.d.ts +12 -3
- package/dist/textValidation/docValidator.js +46 -26
- package/dist/textValidation/index.d.ts +1 -1
- package/dist/textValidation/index.js +2 -1
- package/dist/util/AutoResolveLRUCache.d.ts +54 -0
- package/dist/util/AutoResolveLRUCache.js +138 -0
- package/dist/util/Uri.d.ts +51 -0
- package/dist/util/Uri.js +178 -0
- package/dist/util/errors.d.ts +9 -0
- package/dist/util/errors.js +26 -1
- package/dist/util/text.d.ts +3 -1
- package/dist/util/text.js +3 -1
- package/dist/util/util.d.ts +1 -2
- package/dist/util/util.js +17 -11
- package/package.json +17 -19
- package/dist/Models/Uri.d.ts +0 -5
- package/dist/Models/Uri.js +0 -16
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Uri } from '../util/Uri';
|
|
1
2
|
export interface Document {
|
|
2
3
|
uri: UriString;
|
|
3
4
|
text?: string;
|
|
@@ -5,6 +6,7 @@ export interface Document {
|
|
|
5
6
|
locale?: string;
|
|
6
7
|
}
|
|
7
8
|
export type UriString = string;
|
|
9
|
+
export type UriOrString = UriString | Uri;
|
|
8
10
|
export interface DocumentWithText extends Document {
|
|
9
11
|
text: string;
|
|
10
12
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Uri } from '../util/Uri';
|
|
2
3
|
import type { Document } from './Document';
|
|
3
4
|
export declare function isBinaryDoc(document: Document): boolean;
|
|
4
|
-
export declare function isBinaryFile(
|
|
5
|
+
export declare function isBinaryFile(filename: Uri | URL | string, languageId?: string | string[]): boolean;
|
|
5
6
|
//# sourceMappingURL=isBinaryDoc.d.ts.map
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isBinaryFile = exports.isBinaryDoc = void 0;
|
|
4
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
5
4
|
const LanguageIds_1 = require("../LanguageIds");
|
|
5
|
+
const Uri_1 = require("../util/Uri");
|
|
6
6
|
const normalizeLanguageIds_1 = require("./normalizeLanguageIds");
|
|
7
7
|
function isBinaryDoc(document) {
|
|
8
|
-
return isBinaryFile(
|
|
8
|
+
return isBinaryFile((0, Uri_1.toUri)(document.uri), document.languageId);
|
|
9
9
|
}
|
|
10
10
|
exports.isBinaryDoc = isBinaryDoc;
|
|
11
|
-
function isBinaryFile(
|
|
11
|
+
function isBinaryFile(filename, languageId) {
|
|
12
|
+
const filenameUri = (0, Uri_1.toUri)(filename);
|
|
12
13
|
if (languageId) {
|
|
13
14
|
const ids = (0, normalizeLanguageIds_1.normalizeLanguageIds)(languageId);
|
|
14
15
|
if (ids.length)
|
|
15
16
|
return (0, LanguageIds_1.isGenerated)(ids);
|
|
16
17
|
}
|
|
17
|
-
const
|
|
18
|
-
return (0, LanguageIds_1.isGeneratedFile)(
|
|
18
|
+
const file = (0, Uri_1.basename)(filenameUri);
|
|
19
|
+
return (0, LanguageIds_1.isGeneratedFile)(file);
|
|
19
20
|
}
|
|
20
21
|
exports.isBinaryFile = isBinaryFile;
|
|
21
22
|
//# sourceMappingURL=isBinaryDoc.js.map
|
|
@@ -1,14 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.resolveDocument = exports.resolveDocumentToTextDocument = exports.documentToTextDocument = exports.fileToTextDocument = exports.fileToDocument = void 0;
|
|
4
27
|
const promises_1 = require("fs/promises");
|
|
5
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
6
28
|
const TextDocument_1 = require("../Models/TextDocument");
|
|
29
|
+
const Uri = __importStar(require("../util/Uri"));
|
|
7
30
|
const util_1 = require("../util/util");
|
|
8
31
|
const defaultEncoding = 'utf8';
|
|
9
32
|
function fileToDocument(file, text, languageId, locale) {
|
|
10
33
|
return (0, util_1.clean)({
|
|
11
|
-
uri:
|
|
34
|
+
uri: Uri.toUri(file).toString(),
|
|
12
35
|
text,
|
|
13
36
|
languageId,
|
|
14
37
|
locale,
|
|
@@ -30,7 +53,7 @@ async function resolveDocumentToTextDocument(doc) {
|
|
|
30
53
|
exports.resolveDocumentToTextDocument = resolveDocumentToTextDocument;
|
|
31
54
|
async function readDocument(filename, encoding = defaultEncoding) {
|
|
32
55
|
const text = await (0, promises_1.readFile)(filename, encoding);
|
|
33
|
-
const uri =
|
|
56
|
+
const uri = Uri.toUri(filename).toString();
|
|
34
57
|
return {
|
|
35
58
|
uri,
|
|
36
59
|
text,
|
|
@@ -39,11 +62,11 @@ async function readDocument(filename, encoding = defaultEncoding) {
|
|
|
39
62
|
function resolveDocument(document, encoding) {
|
|
40
63
|
if (isDocumentWithText(document))
|
|
41
64
|
return Promise.resolve(document);
|
|
42
|
-
const uri =
|
|
65
|
+
const uri = Uri.toUri(document.uri);
|
|
43
66
|
if (uri.scheme !== 'file') {
|
|
44
67
|
throw new Error(`Unsupported schema: "${uri.scheme}", open "${uri.toString()}"`);
|
|
45
68
|
}
|
|
46
|
-
return readDocument(uri
|
|
69
|
+
return readDocument(Uri.uriToFilePath(uri), encoding);
|
|
47
70
|
}
|
|
48
71
|
exports.resolveDocument = resolveDocument;
|
|
49
72
|
function isDocumentWithText(doc) {
|
package/dist/LanguageIds.js
CHANGED
|
@@ -234,10 +234,11 @@ exports.languageExtensionDefinitions = [
|
|
|
234
234
|
{ id: 'spv', extensions: ['.spv'], format: 'Binary', description: 'SPSS Output Document' },
|
|
235
235
|
{ id: 'mdb', extensions: ['.mdb'], format: 'Binary', description: 'Microsoft Access DB' },
|
|
236
236
|
{ id: 'webm', extensions: ['.webm'], format: 'Binary', description: 'WebM is an audiovisual media file format.' },
|
|
237
|
+
{ id: 'trie', extensions: ['.trie'], format: 'Binary', description: 'CSpell dictionary file.' },
|
|
237
238
|
];
|
|
238
239
|
const binaryFormatIds = exports.languageExtensionDefinitions.filter((d) => d.format === 'Binary').map((d) => d.id);
|
|
239
240
|
exports.binaryLanguages = new Set(['binary', 'image', 'video', 'fonts'].concat(binaryFormatIds));
|
|
240
|
-
exports.generatedFiles = new Set([...exports.binaryLanguages, 'map', 'lock', 'pdf', 'cache_files', 'rsa', 'pem']);
|
|
241
|
+
exports.generatedFiles = new Set([...exports.binaryLanguages, 'map', 'lock', 'pdf', 'cache_files', 'rsa', 'pem', 'trie']);
|
|
241
242
|
exports.languageIds = exports.languageExtensionDefinitions.map(({ id }) => id);
|
|
242
243
|
const mapExtensionToSetOfLanguageIds = buildLanguageExtensionMapSet(exports.languageExtensionDefinitions);
|
|
243
244
|
const mapExtensionToLanguageIds = buildExtensionToLanguageIdMap(mapExtensionToSetOfLanguageIds);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as Uri from '
|
|
1
|
+
import * as Uri from '../util/Uri';
|
|
2
2
|
export type DocumentUri = Uri.Uri;
|
|
3
3
|
export interface Position {
|
|
4
4
|
line: number;
|
|
@@ -13,6 +13,26 @@ export interface TextDocumentLine {
|
|
|
13
13
|
readonly offset: number;
|
|
14
14
|
readonly position: Position;
|
|
15
15
|
}
|
|
16
|
+
export interface TextDocumentRef {
|
|
17
|
+
/**
|
|
18
|
+
* The associated URI for this document. Most documents have the __file__-scheme, indicating that they
|
|
19
|
+
* represent files on disk. However, some documents may have other schemes indicating that they are not
|
|
20
|
+
* available on disk.
|
|
21
|
+
*/
|
|
22
|
+
readonly uri: DocumentUri;
|
|
23
|
+
/**
|
|
24
|
+
* The identifier of the language associated with this document.
|
|
25
|
+
*/
|
|
26
|
+
readonly languageId?: string | string[] | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* the raw Document Text
|
|
29
|
+
*/
|
|
30
|
+
readonly text?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The natural language locale.
|
|
33
|
+
*/
|
|
34
|
+
readonly locale?: string | undefined;
|
|
35
|
+
}
|
|
16
36
|
/**
|
|
17
37
|
* A simple text document. Not to be implemented. The document keeps the content
|
|
18
38
|
* as string.
|
|
@@ -31,7 +31,7 @@ const assert_1 = __importDefault(require("assert"));
|
|
|
31
31
|
const fs_1 = require("fs");
|
|
32
32
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
33
33
|
const LanguageIds_1 = require("../LanguageIds");
|
|
34
|
-
const Uri = __importStar(require("
|
|
34
|
+
const Uri = __importStar(require("../util/Uri"));
|
|
35
35
|
class TextDocumentImpl {
|
|
36
36
|
constructor(uri, text, languageId, locale, version) {
|
|
37
37
|
this.uri = uri;
|
|
@@ -130,7 +130,7 @@ function isTextDocumentImpl(doc) {
|
|
|
130
130
|
}
|
|
131
131
|
async function loadTextDocument(filename, languageId) {
|
|
132
132
|
const uri = Uri.toUri(filename);
|
|
133
|
-
const content = await fs_1.promises.readFile(uri
|
|
133
|
+
const content = await fs_1.promises.readFile(Uri.uriToFilePath(uri), 'utf8');
|
|
134
134
|
return createTextDocument({ uri, languageId, content });
|
|
135
135
|
}
|
|
136
136
|
exports.loadTextDocument = loadTextDocument;
|
|
@@ -102,7 +102,12 @@ exports.mergeSettings = mergeSettings;
|
|
|
102
102
|
function isEmpty(obj) {
|
|
103
103
|
return Object.keys(obj).length === 0 && obj.constructor === Object;
|
|
104
104
|
}
|
|
105
|
+
const mergeCache = new AutoResolve_1.AutoResolveWeakCache();
|
|
105
106
|
function merge(left, right) {
|
|
107
|
+
const map = mergeCache.get(left, () => new WeakMap());
|
|
108
|
+
return (0, AutoResolve_1.autoResolveWeak)(map, right, () => _merge(left, right));
|
|
109
|
+
}
|
|
110
|
+
function _merge(left, right) {
|
|
106
111
|
const _left = toInternalSettings(left);
|
|
107
112
|
const _right = toInternalSettings(right);
|
|
108
113
|
if (left === right) {
|
|
@@ -123,13 +128,20 @@ function merge(left, right) {
|
|
|
123
128
|
const includeRegExpList = takeRightOtherwiseLeft(_left.includeRegExpList, _right.includeRegExpList);
|
|
124
129
|
const optionals = includeRegExpList?.length ? { includeRegExpList } : {};
|
|
125
130
|
const version = max(_left.version, _right.version);
|
|
131
|
+
const valuesToClear = {
|
|
132
|
+
name: undefined,
|
|
133
|
+
id: undefined,
|
|
134
|
+
description: undefined,
|
|
135
|
+
globRoot: undefined,
|
|
136
|
+
import: undefined,
|
|
137
|
+
__importRef: undefined,
|
|
138
|
+
};
|
|
126
139
|
const settings = (0, CSpellSettingsInternalDef_1.cleanCSpellSettingsInternal)({
|
|
127
140
|
..._left,
|
|
128
141
|
..._right,
|
|
129
142
|
...optionals,
|
|
143
|
+
...valuesToClear,
|
|
130
144
|
version,
|
|
131
|
-
id: undefined,
|
|
132
|
-
name: undefined,
|
|
133
145
|
words: mergeWordsCached(_left.words, _right.words),
|
|
134
146
|
userWords: mergeWordsCached(_left.userWords, _right.userWords),
|
|
135
147
|
flagWords: mergeWordsCached(_left.flagWords, _right.flagWords),
|
|
@@ -149,12 +161,8 @@ function merge(left, right) {
|
|
|
149
161
|
overrides: versionBasedMergeList(_left.overrides, _right.overrides, version),
|
|
150
162
|
features: mergeObjects(_left.features, _right.features),
|
|
151
163
|
source: mergeSources(_left, _right),
|
|
152
|
-
description: undefined,
|
|
153
|
-
globRoot: undefined,
|
|
154
|
-
import: undefined,
|
|
155
164
|
plugins: mergeList(_left.plugins, _right.plugins),
|
|
156
165
|
__imports: mergeImportRefs(_left, _right),
|
|
157
|
-
__importRef: undefined,
|
|
158
166
|
});
|
|
159
167
|
return settings;
|
|
160
168
|
}
|
|
@@ -236,17 +244,21 @@ function _finalizeSettings(settings) {
|
|
|
236
244
|
finalized.source = { name: settings.name || 'src', sources: [settings] };
|
|
237
245
|
return finalized;
|
|
238
246
|
}
|
|
247
|
+
const cacheInternalSettings = new AutoResolve_1.AutoResolveWeakCache();
|
|
239
248
|
function toInternalSettings(settings) {
|
|
240
249
|
if (settings === undefined)
|
|
241
250
|
return undefined;
|
|
242
251
|
if ((0, CSpellSettingsInternalDef_1.isCSpellSettingsInternal)(settings))
|
|
243
252
|
return settings;
|
|
253
|
+
return cacheInternalSettings.get(settings, _toInternalSettings);
|
|
254
|
+
}
|
|
255
|
+
exports.toInternalSettings = toInternalSettings;
|
|
256
|
+
function _toInternalSettings(settings) {
|
|
244
257
|
const { dictionaryDefinitions: defs, ...rest } = settings;
|
|
245
258
|
const dictionaryDefinitions = (0, DictionarySettings_1.mapDictDefsToInternal)(defs, filenameToDirectory(settings.source?.filename) || resolveCwd());
|
|
246
259
|
const setting = dictionaryDefinitions ? { ...rest, dictionaryDefinitions } : rest;
|
|
247
260
|
return (0, CSpellSettingsInternalDef_1.cleanCSpellSettingsInternal)(setting);
|
|
248
261
|
}
|
|
249
|
-
exports.toInternalSettings = toInternalSettings;
|
|
250
262
|
function filenameToDirectory(filename) {
|
|
251
263
|
return filename ? path.dirname(filename) : undefined;
|
|
252
264
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CSpellSettings, PnPSettings } from '@cspell/cspell-types';
|
|
2
|
+
import type { OptionalOrUndefined } from '../../../util/types';
|
|
3
|
+
export type PnPSettingsOptional = OptionalOrUndefined<PnPSettings>;
|
|
4
|
+
export declare const defaultPnPSettings: PnPSettings;
|
|
5
|
+
/**
|
|
6
|
+
* create PnPSettings object that can be used to compare to the last call.
|
|
7
|
+
* This is to reduce object churn and unnecessary configuration loading.
|
|
8
|
+
* @param settings - value to normalize
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizePnPSettings(settings: PnPSettingsOptional | CSpellSettings): PnPSettings;
|
|
12
|
+
//# sourceMappingURL=PnPSettings.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizePnPSettings = exports.defaultPnPSettings = void 0;
|
|
4
|
+
const util_1 = require("../../../util/util");
|
|
5
|
+
exports.defaultPnPSettings = Object.freeze({});
|
|
6
|
+
let lastPnP = exports.defaultPnPSettings;
|
|
7
|
+
/**
|
|
8
|
+
* create PnPSettings object that can be used to compare to the last call.
|
|
9
|
+
* This is to reduce object churn and unnecessary configuration loading.
|
|
10
|
+
* @param settings - value to normalize
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
function normalizePnPSettings(settings) {
|
|
14
|
+
if (equal(lastPnP, settings))
|
|
15
|
+
return lastPnP;
|
|
16
|
+
if (equal(exports.defaultPnPSettings, settings))
|
|
17
|
+
return exports.defaultPnPSettings;
|
|
18
|
+
const { usePnP, pnpFiles } = settings;
|
|
19
|
+
return (lastPnP = (0, util_1.clean)({ usePnP, pnpFiles }));
|
|
20
|
+
}
|
|
21
|
+
exports.normalizePnPSettings = normalizePnPSettings;
|
|
22
|
+
function equal(a, b) {
|
|
23
|
+
return (a === b ||
|
|
24
|
+
(a.usePnP === b.usePnP && (a.pnpFiles === b.pnpFiles || a.pnpFiles?.join('|') === b.pnpFiles?.join('|'))));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=PnPSettings.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { CSpellUserSettings, ImportFileRef
|
|
1
|
+
import type { CSpellUserSettings, ImportFileRef } from '@cspell/cspell-types';
|
|
2
2
|
import type { CSpellIO } from 'cspell-io';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import type { Uri } from '../../../util/Uri';
|
|
4
|
+
import { ImportError } from '../ImportError';
|
|
5
5
|
import type { LoaderResult } from '../pnpLoader';
|
|
6
6
|
import { normalizeCacheSettings } from './normalizeRawSettings';
|
|
7
|
+
import type { PnPSettingsOptional } from './PnPSettings';
|
|
7
8
|
import type { CSpellSettingsI, CSpellSettingsWST } from './types';
|
|
8
|
-
type PnPSettings = OptionalOrUndefined<PnPSettingsStrict>;
|
|
9
9
|
export declare const sectionCSpell = "cSpell";
|
|
10
10
|
export declare const defaultFileName = "cspell.json";
|
|
11
11
|
export declare const defaultConfigFilenames: readonly string[];
|
|
@@ -17,20 +17,8 @@ export declare class ConfigLoader {
|
|
|
17
17
|
*/
|
|
18
18
|
protected constructor(cspellIO: CSpellIO);
|
|
19
19
|
protected cachedFiles: Map<string, import("../../../Models/CSpellSettingsInternalDef").CSpellSettingsInternal>;
|
|
20
|
-
protected cspellConfigExplorer:
|
|
21
|
-
|
|
22
|
-
readonly load: (filepath: string) => Promise<import("cosmiconfig/dist/types").CosmiconfigResult>;
|
|
23
|
-
readonly clearLoadCache: () => void;
|
|
24
|
-
readonly clearSearchCache: () => void;
|
|
25
|
-
readonly clearCaches: () => void;
|
|
26
|
-
};
|
|
27
|
-
protected cspellConfigExplorerSync: {
|
|
28
|
-
readonly search: (searchFrom?: string | undefined) => import("cosmiconfig/dist/types").CosmiconfigResult;
|
|
29
|
-
readonly load: (filepath: string) => import("cosmiconfig/dist/types").CosmiconfigResult;
|
|
30
|
-
readonly clearLoadCache: () => void;
|
|
31
|
-
readonly clearSearchCache: () => void;
|
|
32
|
-
readonly clearCaches: () => void;
|
|
33
|
-
};
|
|
20
|
+
protected cspellConfigExplorer: import("cosmiconfig").PublicExplorer;
|
|
21
|
+
protected cspellConfigExplorerSync: import("cosmiconfig").PublicExplorerSync;
|
|
34
22
|
protected globalSettings: CSpellSettingsI | undefined;
|
|
35
23
|
/**
|
|
36
24
|
* Read / import a cspell configuration file.
|
|
@@ -54,6 +42,16 @@ export declare class ConfigLoader {
|
|
|
54
42
|
readSettings(filename: string, relativeTo?: string): CSpellSettingsI;
|
|
55
43
|
readSettings(filename: string, relativeTo: string, defaultValues: CSpellSettingsWST): CSpellSettingsI;
|
|
56
44
|
readSettings(filename: string, relativeToOrDefault?: CSpellSettingsWST | string): CSpellSettingsI;
|
|
45
|
+
readSettingsAsync(filename: string, relativeTo?: string, pnpSettings?: PnPSettingsOptional): Promise<CSpellSettingsI>;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @param searchFrom the directory / file to start searching from.
|
|
49
|
+
* @param pnpSettings - related to Using Yarn PNP.
|
|
50
|
+
* @returns the resulting settings
|
|
51
|
+
*/
|
|
52
|
+
searchForConfig(searchFrom: string | undefined, pnpSettings?: PnPSettingsOptional): Promise<CSpellSettingsI | undefined>;
|
|
53
|
+
private searchConfigLRU;
|
|
54
|
+
private _searchForConfig;
|
|
57
55
|
getGlobalSettings(): CSpellSettingsI;
|
|
58
56
|
clearCachedSettingsFiles(): void;
|
|
59
57
|
/**
|
|
@@ -61,33 +59,33 @@ export declare class ConfigLoader {
|
|
|
61
59
|
* @param fileRef - filename plus context, injected into the resulting config.
|
|
62
60
|
*/
|
|
63
61
|
protected readConfig(fileRef: ImportFileRef): CSpellSettingsWST;
|
|
64
|
-
protected importSettings(fileRef: ImportFileRef, defaultValues: CSpellSettingsWST | undefined, pnpSettings:
|
|
62
|
+
protected importSettings(fileRef: ImportFileRef, defaultValues: CSpellSettingsWST | undefined, pnpSettings: PnPSettingsOptional): CSpellSettingsI;
|
|
65
63
|
/**
|
|
66
64
|
* normalizeSettings handles correcting all relative paths, anchoring globs, and importing other config files.
|
|
67
65
|
* @param rawSettings - raw configuration settings
|
|
68
66
|
* @param pathToSettingsFile - path to the source file of the configuration settings.
|
|
69
67
|
*/
|
|
70
|
-
protected normalizeSettings(rawSettings: CSpellSettingsWST, pathToSettingsFile: string, pnpSettings:
|
|
68
|
+
protected normalizeSettings(rawSettings: CSpellSettingsWST, pathToSettingsFile: string, pnpSettings: PnPSettingsOptional): CSpellSettingsI;
|
|
71
69
|
}
|
|
72
70
|
declare class ConfigLoaderInternal extends ConfigLoader {
|
|
73
71
|
constructor(cspellIO: CSpellIO);
|
|
74
72
|
get _cachedFiles(): Map<string, import("../../../Models/CSpellSettingsInternalDef").CSpellSettingsInternal>;
|
|
75
|
-
get _cspellConfigExplorer():
|
|
76
|
-
|
|
77
|
-
readonly load: (filepath: string) => Promise<import("cosmiconfig/dist/types").CosmiconfigResult>;
|
|
78
|
-
readonly clearLoadCache: () => void;
|
|
79
|
-
readonly clearSearchCache: () => void;
|
|
80
|
-
readonly clearCaches: () => void;
|
|
81
|
-
};
|
|
82
|
-
get _cspellConfigExplorerSync(): {
|
|
83
|
-
readonly search: (searchFrom?: string | undefined) => import("cosmiconfig/dist/types").CosmiconfigResult;
|
|
84
|
-
readonly load: (filepath: string) => import("cosmiconfig/dist/types").CosmiconfigResult;
|
|
85
|
-
readonly clearLoadCache: () => void;
|
|
86
|
-
readonly clearSearchCache: () => void;
|
|
87
|
-
readonly clearCaches: () => void;
|
|
88
|
-
};
|
|
73
|
+
get _cspellConfigExplorer(): import("cosmiconfig").PublicExplorer;
|
|
74
|
+
get _cspellConfigExplorerSync(): import("cosmiconfig").PublicExplorerSync;
|
|
89
75
|
readonly _readConfig: (fileRef: ImportFileRef) => import("@cspell/cspell-types").CSpellSettingsWithSourceTrace;
|
|
90
|
-
readonly _normalizeSettings: (rawSettings: import("@cspell/cspell-types").CSpellSettingsWithSourceTrace, pathToSettingsFile: string, pnpSettings: OptionalOrUndefined<
|
|
76
|
+
readonly _normalizeSettings: (rawSettings: import("@cspell/cspell-types").CSpellSettingsWithSourceTrace, pathToSettingsFile: string, pnpSettings: import("../../../util/types").OptionalOrUndefined<import("@cspell/cspell-types").PnPSettings>) => import("../../../Models/CSpellSettingsInternalDef").CSpellSettingsInternal;
|
|
77
|
+
normalizeSearchForConfigResultAsync(searchPath: string, searchResult: Promise<SearchForConfigResult | null>, pnpSettings: PnPSettingsOptional): Promise<NormalizeSearchForConfigResult>;
|
|
78
|
+
normalizeSearchForConfigResult(searchPath: string, searchResult: SearchForConfigResult | ImportError | undefined, pnpSettings: PnPSettingsOptional): NormalizeSearchForConfigResult;
|
|
79
|
+
}
|
|
80
|
+
interface SearchForConfigResult {
|
|
81
|
+
config: CSpellSettingsI | undefined;
|
|
82
|
+
filepath: string;
|
|
83
|
+
isEmpty?: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface NormalizeSearchForConfigResult {
|
|
86
|
+
config: CSpellSettingsI;
|
|
87
|
+
filepath: string | undefined;
|
|
88
|
+
error: ImportError | undefined;
|
|
91
89
|
}
|
|
92
90
|
/**
|
|
93
91
|
*
|
|
@@ -95,7 +93,7 @@ declare class ConfigLoaderInternal extends ConfigLoader {
|
|
|
95
93
|
* @param pnpSettings - related to Using Yarn PNP.
|
|
96
94
|
* @returns the resulting settings
|
|
97
95
|
*/
|
|
98
|
-
export declare function searchForConfig(searchFrom: string | undefined, pnpSettings?:
|
|
96
|
+
export declare function searchForConfig(searchFrom: string | undefined, pnpSettings?: PnPSettingsOptional): Promise<CSpellSettingsI | undefined>;
|
|
99
97
|
/**
|
|
100
98
|
*
|
|
101
99
|
* @param searchFrom the directory / file to start searching from.
|
|
@@ -104,23 +102,24 @@ export declare function searchForConfig(searchFrom: string | undefined, pnpSetti
|
|
|
104
102
|
* @deprecated
|
|
105
103
|
* @deprecationMessage Use `searchForConfig`. It is very difficult to support Sync files when settings include web requests.
|
|
106
104
|
*/
|
|
107
|
-
export declare function searchForConfigSync(searchFrom: string | undefined, pnpSettings?:
|
|
105
|
+
export declare function searchForConfigSync(searchFrom: string | undefined, pnpSettings?: PnPSettingsOptional): CSpellSettingsI | undefined;
|
|
108
106
|
/**
|
|
109
107
|
* Load a CSpell configuration files.
|
|
110
108
|
* @param file - path or package reference to load.
|
|
111
109
|
* @param pnpSettings - PnP settings
|
|
112
110
|
* @returns normalized CSpellSettings
|
|
113
111
|
*/
|
|
114
|
-
export declare function loadConfig(file: string, pnpSettings?:
|
|
112
|
+
export declare function loadConfig(file: string, pnpSettings?: PnPSettingsOptional): Promise<CSpellSettingsI>;
|
|
115
113
|
/**
|
|
116
114
|
* Load a CSpell configuration files.
|
|
117
115
|
* @param filename - path or package reference to load.
|
|
118
116
|
* @param pnpSettings - PnP settings
|
|
119
117
|
* @returns normalized CSpellSettings
|
|
118
|
+
* @deprecated
|
|
120
119
|
*/
|
|
121
|
-
export declare function loadConfigSync(filename: string, pnpSettings?:
|
|
122
|
-
export declare function loadPnP(pnpSettings:
|
|
123
|
-
export declare function loadPnPSync(pnpSettings:
|
|
120
|
+
export declare function loadConfigSync(filename: string, pnpSettings?: PnPSettingsOptional): CSpellSettingsI;
|
|
121
|
+
export declare function loadPnP(pnpSettings: PnPSettingsOptional, searchFrom: Uri): Promise<LoaderResult>;
|
|
122
|
+
export declare function loadPnPSync(pnpSettings: PnPSettingsOptional, searchFrom: Uri): LoaderResult;
|
|
124
123
|
export declare function readRawSettings(filename: string, relativeTo?: string): CSpellSettingsWST;
|
|
125
124
|
export declare function getGlobalSettings(): CSpellSettingsI;
|
|
126
125
|
export declare function getCachedFileSize(): number;
|