cspell-lib 7.3.9 → 8.1.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.
Files changed (106) hide show
  1. package/dist/esm/FeatureFlags/FeatureFlags.js +3 -1
  2. package/dist/esm/Models/TextDocument.js +4 -0
  3. package/dist/esm/Settings/CSpellSettingsServer.d.ts +3 -12
  4. package/dist/esm/Settings/CSpellSettingsServer.js +19 -55
  5. package/dist/esm/Settings/Controller/ImportError.js +1 -0
  6. package/dist/esm/Settings/Controller/SettingsController.js +1 -0
  7. package/dist/esm/Settings/Controller/configLoader/configLoader.d.ts +55 -126
  8. package/dist/esm/Settings/Controller/configLoader/configLoader.js +242 -335
  9. package/dist/esm/Settings/Controller/configLoader/configLocations.d.ts +3 -0
  10. package/dist/esm/Settings/Controller/configLoader/configLocations.js +57 -0
  11. package/dist/esm/Settings/Controller/configLoader/configSearch.d.ts +12 -0
  12. package/dist/esm/Settings/Controller/configLoader/configSearch.js +116 -0
  13. package/dist/esm/Settings/Controller/configLoader/configToRawSettings.d.ts +5 -0
  14. package/dist/esm/Settings/Controller/configLoader/configToRawSettings.js +36 -0
  15. package/dist/esm/Settings/Controller/configLoader/defaultConfigLoader.d.ts +34 -0
  16. package/dist/esm/Settings/Controller/configLoader/defaultConfigLoader.js +67 -0
  17. package/dist/esm/Settings/Controller/configLoader/extractImportErrors.d.ts +1 -0
  18. package/dist/esm/Settings/Controller/configLoader/extractImportErrors.js +4 -0
  19. package/dist/esm/Settings/Controller/configLoader/index.d.ts +3 -1
  20. package/dist/esm/Settings/Controller/configLoader/index.js +3 -1
  21. package/dist/esm/Settings/Controller/configLoader/normalizeRawSettings.d.ts +8 -6
  22. package/dist/esm/Settings/Controller/configLoader/normalizeRawSettings.js +31 -14
  23. package/dist/esm/Settings/Controller/configLoader/readSettings.d.ts +6 -5
  24. package/dist/esm/Settings/Controller/configLoader/readSettings.js +10 -5
  25. package/dist/esm/Settings/Controller/configLoader/readSettingsFiles.d.ts +1 -1
  26. package/dist/esm/Settings/Controller/configLoader/readSettingsFiles.js +3 -2
  27. package/dist/esm/Settings/Controller/pnpLoader.d.ts +4 -12
  28. package/dist/esm/Settings/Controller/pnpLoader.js +24 -48
  29. package/dist/esm/Settings/DefaultSettings.d.ts +10 -2
  30. package/dist/esm/Settings/DefaultSettings.js +33 -22
  31. package/dist/esm/Settings/DictionaryReferenceCollection.js +2 -0
  32. package/dist/esm/Settings/DictionarySettings.d.ts +4 -4
  33. package/dist/esm/Settings/DictionarySettings.js +21 -4
  34. package/dist/esm/Settings/GlobalSettings.d.ts +6 -3
  35. package/dist/esm/Settings/GlobalSettings.js +24 -19
  36. package/dist/esm/Settings/InDocSettings.js +2 -2
  37. package/dist/esm/Settings/LanguageSettings.js +10 -15
  38. package/dist/esm/Settings/TextDocumentSettings.js +4 -4
  39. package/dist/esm/Settings/calcOverrideSettings.d.ts +3 -0
  40. package/dist/esm/Settings/calcOverrideSettings.js +11 -0
  41. package/dist/esm/Settings/checkFilenameMatchesGlob.d.ts +10 -0
  42. package/dist/esm/Settings/checkFilenameMatchesGlob.js +10 -0
  43. package/dist/esm/Settings/index.d.ts +5 -3
  44. package/dist/esm/Settings/index.js +5 -3
  45. package/dist/esm/Settings/link.d.ts +3 -3
  46. package/dist/esm/Settings/link.js +20 -13
  47. package/dist/esm/Settings/mergeCache.d.ts +13 -0
  48. package/dist/esm/Settings/mergeCache.js +22 -0
  49. package/dist/esm/Settings/mergeList.d.ts +18 -0
  50. package/dist/esm/Settings/mergeList.js +34 -0
  51. package/dist/esm/Settings/patterns.js +13 -2
  52. package/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.d.ts +1 -0
  53. package/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.js +45 -41
  54. package/dist/esm/SpellingDictionary/SpellingDictionaryError.js +4 -0
  55. package/dist/esm/SpellingDictionary/SuggestExperimental/SuggestionCollector.js +3 -1
  56. package/dist/esm/SpellingDictionary/SuggestExperimental/helpers.js +1 -1
  57. package/dist/esm/clearCachedFiles.d.ts +14 -0
  58. package/dist/esm/clearCachedFiles.js +29 -3
  59. package/dist/esm/events/events.d.ts +17 -0
  60. package/dist/esm/events/events.js +28 -0
  61. package/dist/esm/events/index.d.ts +3 -0
  62. package/dist/esm/events/index.js +2 -0
  63. package/dist/esm/getDictionary.js +1 -1
  64. package/dist/esm/globs/checkFilenameMatchesGlob.d.ts +8 -0
  65. package/dist/esm/globs/checkFilenameMatchesGlob.js +11 -0
  66. package/dist/esm/globs/getGlobMatcher.d.ts +4 -0
  67. package/dist/esm/globs/getGlobMatcher.js +31 -0
  68. package/dist/esm/index.d.ts +4 -2
  69. package/dist/esm/index.js +3 -2
  70. package/dist/esm/perf/index.d.ts +3 -0
  71. package/dist/esm/perf/index.js +2 -0
  72. package/dist/esm/perf/perf.d.ts +14 -0
  73. package/dist/esm/perf/perf.js +27 -0
  74. package/dist/esm/perf/timer.d.ts +11 -0
  75. package/dist/esm/perf/timer.js +37 -0
  76. package/dist/esm/spellCheckFile.d.ts +8 -1
  77. package/dist/esm/spellCheckFile.js +33 -4
  78. package/dist/esm/suggestions.js +6 -5
  79. package/dist/esm/textValidation/ValidateTextOptions.d.ts +5 -0
  80. package/dist/esm/textValidation/determineTextDocumentSettings.d.ts +1 -1
  81. package/dist/esm/textValidation/determineTextDocumentSettings.js +2 -2
  82. package/dist/esm/textValidation/docValidator.d.ts +4 -9
  83. package/dist/esm/textValidation/docValidator.js +62 -95
  84. package/dist/esm/trace.js +8 -1
  85. package/dist/esm/util/AutoResolve.d.ts +21 -4
  86. package/dist/esm/util/AutoResolve.js +26 -9
  87. package/dist/esm/util/AutoResolveLRUCache.js +8 -6
  88. package/dist/esm/util/FreqCounter.js +2 -4
  89. package/dist/esm/util/MinHeapQueue.js +2 -1
  90. package/dist/esm/util/PairingHeap.js +3 -1
  91. package/dist/esm/util/Uri.js +5 -0
  92. package/dist/esm/util/errors.js +5 -4
  93. package/dist/esm/util/fileReader.d.ts +3 -3
  94. package/dist/esm/util/findUp.d.ts +9 -0
  95. package/dist/esm/util/findUp.js +43 -0
  96. package/dist/esm/util/resolveFile.d.ts +31 -1
  97. package/dist/esm/util/resolveFile.js +107 -27
  98. package/dist/esm/util/simpleCache.js +11 -7
  99. package/dist/esm/util/url.d.ts +29 -0
  100. package/dist/esm/util/url.js +91 -0
  101. package/dist/esm/util/wordSplitter.js +4 -4
  102. package/package.json +17 -18
  103. package/dist/esm/util/debugPerf.d.ts +0 -9
  104. package/dist/esm/util/debugPerf.js +0 -18
  105. package/dist/esm/util/timer.d.ts +0 -26
  106. package/dist/esm/util/timer.js +0 -51
@@ -4,8 +4,9 @@ let systemFeatureFlags;
4
4
  * These are primarily used before a feature has been fully released.
5
5
  */
6
6
  export class FeatureFlags {
7
+ flags;
8
+ flagValues = new Map();
7
9
  constructor(flags = []) {
8
- this.flagValues = new Map();
9
10
  this.flags = new Map(flags.map((f) => [f.name, f]));
10
11
  }
11
12
  register(flagOrName, description) {
@@ -43,6 +44,7 @@ export class FeatureFlags {
43
44
  }
44
45
  }
45
46
  export class UnknownFeatureFlagError extends Error {
47
+ flag;
46
48
  constructor(flag) {
47
49
  super(`Unknown feature flag: ${flag}`);
48
50
  this.flag = flag;
@@ -4,6 +4,10 @@ import { TextDocument as VsTextDocument } from 'vscode-languageserver-textdocume
4
4
  import { getLanguagesForBasename } from '../LanguageIds.js';
5
5
  import * as Uri from '../util/Uri.js';
6
6
  class TextDocumentImpl {
7
+ uri;
8
+ languageId;
9
+ locale;
10
+ vsTextDoc;
7
11
  constructor(uri, text, languageId, locale, version) {
8
12
  this.uri = uri;
9
13
  this.languageId = languageId;
@@ -1,16 +1,15 @@
1
- import type { AdvancedCSpellSettingsWithSourceTrace, Glob, ImportFileRef } from '@cspell/cspell-types';
1
+ import type { AdvancedCSpellSettingsWithSourceTrace, ImportFileRef } from '@cspell/cspell-types';
2
2
  import type { CSpellSettingsInternal, CSpellSettingsInternalFinalized } from '../Models/CSpellSettingsInternalDef.js';
3
3
  import type { OptionalOrUndefined } from '../util/types.js';
4
4
  type CSpellSettingsWST = AdvancedCSpellSettingsWithSourceTrace;
5
- type CSpellSettingsWSTO = OptionalOrUndefined<AdvancedCSpellSettingsWithSourceTrace>;
6
- type CSpellSettingsI = CSpellSettingsInternal;
5
+ export type CSpellSettingsWSTO = OptionalOrUndefined<AdvancedCSpellSettingsWithSourceTrace>;
6
+ export type CSpellSettingsI = CSpellSettingsInternal;
7
7
  declare function mergeObjects(left: undefined, right: undefined): undefined;
8
8
  declare function mergeObjects<T>(left: T, right: undefined): T;
9
9
  declare function mergeObjects<T>(left: T, right: T): T;
10
10
  declare function mergeObjects<T>(left: undefined, right: T): T;
11
11
  export declare function mergeSettings(left: CSpellSettingsWSTO | CSpellSettingsI, ...settings: (CSpellSettingsWSTO | CSpellSettingsI | undefined)[]): CSpellSettingsI;
12
12
  export declare function mergeInDocSettings(left: CSpellSettingsWSTO, right: CSpellSettingsWSTO): CSpellSettingsWST;
13
- export declare function calcOverrideSettings(settings: CSpellSettingsWSTO, filename: string): CSpellSettingsI;
14
13
  /**
15
14
  *
16
15
  * @param settings - settings to finalize
@@ -20,14 +19,6 @@ export declare function finalizeSettings(settings: CSpellSettingsWSTO | CSpellSe
20
19
  export declare function toInternalSettings(settings: undefined): undefined;
21
20
  export declare function toInternalSettings(settings: CSpellSettingsI | CSpellSettingsWSTO): CSpellSettingsI;
22
21
  export declare function toInternalSettings(settings?: CSpellSettingsI | CSpellSettingsWSTO): CSpellSettingsI | undefined;
23
- /**
24
- * @param filename - filename
25
- * @param globs - globs
26
- * @returns true if it matches
27
- * @deprecated true
28
- * @deprecationMessage No longer actively supported. Use package: `cspell-glob`.
29
- */
30
- export declare function checkFilenameMatchesGlob(filename: string, globs: Glob | Glob[]): boolean;
31
22
  /**
32
23
  * Return a list of Setting Sources used to create this Setting.
33
24
  * @param settings the settings to search
@@ -1,37 +1,28 @@
1
1
  import assert from 'assert';
2
- import { GlobMatcher } from 'cspell-glob';
3
- import * as path from 'path';
2
+ import { pathToFileURL } from 'url';
3
+ import { onClearCache } from '../events/index.js';
4
4
  import { cleanCSpellSettingsInternal as csi, isCSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.js';
5
5
  import { autoResolveWeak, AutoResolveWeakCache } from '../util/AutoResolve.js';
6
+ import { toFileUrl } from '../util/url.js';
6
7
  import * as util from '../util/util.js';
7
8
  import { configSettingsFileVersion0_1, ENV_CSPELL_GLOB_ROOT } from './constants.js';
8
9
  import { calcDictionaryDefsToLoad, mapDictDefsToInternal } from './DictionarySettings.js';
10
+ import { mergeList, mergeListUnique } from './mergeList.js';
9
11
  import { resolvePatterns } from './patterns.js';
10
- function mergeListUnique(left, right) {
11
- if (!Array.isArray(left))
12
- return Array.isArray(right) ? right : undefined;
13
- if (!Array.isArray(right))
14
- return left;
15
- if (!right.length)
16
- return left;
17
- if (!left.length)
18
- return right;
19
- return [...new Set([...left, ...right])];
20
- }
21
- function mergeList(left, right) {
22
- if (!Array.isArray(left))
23
- return Array.isArray(right) ? right : undefined;
24
- if (!Array.isArray(right))
25
- return left;
26
- if (!left.length)
27
- return right;
28
- if (!right.length)
29
- return left;
30
- return left.concat(right);
31
- }
32
12
  const emptyWords = [];
33
13
  Object.freeze(emptyWords);
34
- const cachedMerges = new WeakMap();
14
+ const cachedMerges = new AutoResolveWeakCache();
15
+ const mergeCache = new AutoResolveWeakCache();
16
+ const cacheInternalSettings = new AutoResolveWeakCache();
17
+ const parserCache = new AutoResolveWeakCache();
18
+ const emptyParserMap = new Map();
19
+ onClearCache(() => {
20
+ parserCache.clear();
21
+ emptyParserMap.clear();
22
+ cachedMerges.clear();
23
+ mergeCache.clear();
24
+ cacheInternalSettings.clear();
25
+ });
35
26
  function _mergeWordsCached(left, right) {
36
27
  const map = autoResolveWeak(cachedMerges, left, () => new WeakMap());
37
28
  return autoResolveWeak(map, right, () => left.concat(right));
@@ -62,11 +53,9 @@ export function mergeSettings(left, ...settings) {
62
53
  const rawSettings = settings.filter(util.isDefined).reduce(merge, toInternalSettings(left));
63
54
  return util.clean(rawSettings);
64
55
  }
65
- // eslint-disable-next-line @typescript-eslint/ban-types
66
56
  function isEmpty(obj) {
67
- return Object.keys(obj).length === 0 && obj.constructor === Object;
57
+ return !obj || Object.keys(obj).length === 0;
68
58
  }
69
- const mergeCache = new AutoResolveWeakCache();
70
59
  function merge(left, right) {
71
60
  const map = mergeCache.get(left, () => new WeakMap());
72
61
  return autoResolveWeak(map, right, () => _merge(left, right));
@@ -176,14 +165,6 @@ function takeRightOtherwiseLeft(left, right) {
176
165
  }
177
166
  return left || right;
178
167
  }
179
- export function calcOverrideSettings(settings, filename) {
180
- const _settings = toInternalSettings(settings);
181
- const overrides = _settings.overrides || [];
182
- const result = overrides
183
- .filter((override) => checkFilenameMatchesGlob(filename, override.filename))
184
- .reduce((settings, override) => mergeSettings(settings, override), _settings);
185
- return result;
186
- }
187
168
  /**
188
169
  *
189
170
  * @param settings - settings to finalize
@@ -205,7 +186,6 @@ function _finalizeSettings(settings) {
205
186
  finalized.source = { name: settings.name || 'src', sources: [settings] };
206
187
  return finalized;
207
188
  }
208
- const cacheInternalSettings = new AutoResolveWeakCache();
209
189
  export function toInternalSettings(settings) {
210
190
  if (settings === undefined)
211
191
  return undefined;
@@ -215,24 +195,10 @@ export function toInternalSettings(settings) {
215
195
  }
216
196
  function _toInternalSettings(settings) {
217
197
  const { dictionaryDefinitions: defs, ...rest } = settings;
218
- const dictionaryDefinitions = mapDictDefsToInternal(defs, filenameToDirectory(settings.source?.filename) || resolveCwd());
198
+ const dictionaryDefinitions = mapDictDefsToInternal(defs, (settings.source?.filename && toFileUrl(settings.source?.filename)) || resolveCwd());
219
199
  const setting = dictionaryDefinitions ? { ...rest, dictionaryDefinitions } : rest;
220
200
  return csi(setting);
221
201
  }
222
- function filenameToDirectory(filename) {
223
- return filename ? path.dirname(filename) : undefined;
224
- }
225
- /**
226
- * @param filename - filename
227
- * @param globs - globs
228
- * @returns true if it matches
229
- * @deprecated true
230
- * @deprecationMessage No longer actively supported. Use package: `cspell-glob`.
231
- */
232
- export function checkFilenameMatchesGlob(filename, globs) {
233
- const m = new GlobMatcher(globs);
234
- return m.match(filename);
235
- }
236
202
  function mergeSources(left, right) {
237
203
  return {
238
204
  name: 'merged',
@@ -294,7 +260,7 @@ export function extractDependencies(settings) {
294
260
  function resolveCwd() {
295
261
  const envGlobRoot = process.env[ENV_CSPELL_GLOB_ROOT];
296
262
  const cwd = envGlobRoot || process.cwd();
297
- return cwd;
263
+ return pathToFileURL(cwd);
298
264
  }
299
265
  function resolveParser(settings) {
300
266
  if (!settings.parser)
@@ -308,8 +274,6 @@ function resolveParser(settings) {
308
274
  assert(parser, `Parser "${parserName}" not found.`);
309
275
  return parser;
310
276
  }
311
- const parserCache = new AutoResolveWeakCache();
312
- const emptyParserMap = new Map();
313
277
  function* parsers(plugins) {
314
278
  for (const plugin of plugins) {
315
279
  if (!plugin.parsers)
@@ -1,5 +1,6 @@
1
1
  import { isError } from '../../util/errors.js';
2
2
  export class ImportError extends Error {
3
+ cause;
3
4
  constructor(msg, cause) {
4
5
  super(msg);
5
6
  this.cause = isError(cause) ? cause : undefined;
@@ -2,6 +2,7 @@
2
2
  * The settings controller manages requests to resolve configuration settings and files.
3
3
  */
4
4
  export class SettingsController {
5
+ cspellIO;
5
6
  constructor(cspellIO) {
6
7
  this.cspellIO = cspellIO;
7
8
  }
@@ -1,164 +1,93 @@
1
1
  import type { CSpellUserSettings, ImportFileRef } from '@cspell/cspell-types';
2
+ import type { CSpellConfigFile, CSpellConfigFileReaderWriter } from 'cspell-config-lib';
2
3
  import type { CSpellIO } from 'cspell-io';
3
- import type { Uri } from '../../../util/Uri.js';
4
- import { ImportError } from '../ImportError.js';
4
+ import { AutoResolveCache } from '../../../util/AutoResolve.js';
5
5
  import type { LoaderResult } from '../pnpLoader.js';
6
+ import { ConfigSearch } from './configSearch.js';
6
7
  import { normalizeCacheSettings } from './normalizeRawSettings.js';
7
8
  import type { PnPSettingsOptional } from './PnPSettings.js';
8
- import type { CSpellSettingsI, CSpellSettingsWST } from './types.js';
9
+ import type { CSpellSettingsI } from './types.js';
9
10
  export declare const sectionCSpell = "cSpell";
10
11
  export declare const defaultFileName = "cspell.json";
11
- export declare const defaultConfigFilenames: readonly string[];
12
+ interface ImportedConfigEntry {
13
+ /** href of the configFile URL, this is the key to the cache. */
14
+ href: string;
15
+ /** The fileRef used. */
16
+ fileRef: ImportFileRef;
17
+ /** resolved config file */
18
+ configFile: CSpellConfigFile | undefined;
19
+ /** resolved settings */
20
+ settings: CSpellSettingsI | undefined;
21
+ isReady: boolean;
22
+ /** Resolved when the settings have been fully resolved. */
23
+ onReady: Promise<CSpellSettingsI>;
24
+ /** Resolved when the config file has been loaded. */
25
+ onConfigFileReady: Promise<CSpellConfigFile | Error>;
26
+ /** Set of all references used to catch circular references */
27
+ referencedSet: Set<string>;
28
+ }
29
+ interface CacheMergeConfigFileWithImports {
30
+ pnpSettings: PnPSettingsOptional | undefined;
31
+ referencedBy: string[] | undefined;
32
+ result: Promise<CSpellSettingsI>;
33
+ }
12
34
  export declare class ConfigLoader {
13
35
  readonly cspellIO: CSpellIO;
36
+ onReady: Promise<void>;
14
37
  /**
15
38
  * Use `createConfigLoader`
16
39
  * @param cspellIO - CSpellIO interface for reading files.
17
40
  */
18
41
  protected constructor(cspellIO: CSpellIO);
19
- protected cachedFiles: Map<string, import("../../../Models/CSpellSettingsInternalDef.js").CSpellSettingsInternal>;
20
- protected cspellConfigExplorer: {
21
- readonly search: (searchFrom?: string | undefined) => Promise<import("cosmiconfig/dist/types.js").CosmiconfigResult>;
22
- readonly load: (filepath: string) => Promise<import("cosmiconfig/dist/types.js").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.js").CosmiconfigResult;
29
- readonly load: (filepath: string) => import("cosmiconfig/dist/types.js").CosmiconfigResult;
30
- readonly clearLoadCache: () => void;
31
- readonly clearSearchCache: () => void;
32
- readonly clearCaches: () => void;
33
- };
42
+ private subscribeToEvents;
43
+ protected cachedConfig: Map<string, ImportedConfigEntry>;
44
+ protected cachedConfigFiles: Map<string, CSpellConfigFile>;
45
+ protected cachedPendingConfigFile: AutoResolveCache<string, Promise<Error | CSpellConfigFile>>;
46
+ protected cachedMergedConfig: WeakMap<CSpellConfigFile, CacheMergeConfigFileWithImports>;
34
47
  protected globalSettings: CSpellSettingsI | undefined;
35
- /**
36
- * Read / import a cspell configuration file.
37
- * @param filename - the path to the file.
38
- * Supported types: json, yaml, js, and cjs. ES Modules are not supported.
39
- * - absolute path `/absolute/path/to/file`
40
- * - relative path `./path/to/file` (relative to the current working directory)
41
- * - package `@cspell/dict-typescript/cspell-ext.json`
42
- */
43
- readSettings(filename: string): CSpellSettingsI;
44
- readSettings(filename: string, defaultValues: CSpellSettingsWST): CSpellSettingsI;
45
- /**
46
- * Read / import a cspell configuration file.
47
- * @param filename - the path to the file.
48
- * Supported types: json, yaml, js, and cjs. ES Modules are not supported.
49
- * - absolute path `/absolute/path/to/file`
50
- * - relative path `./path/to/file` (relative to `relativeTo`)
51
- * - package `@cspell/dict-typescript/cspell-ext.json` searches for node_modules relative to `relativeTo`
52
- * @param relativeTo - absolute path to start searching for relative files or node_modules.
53
- */
54
- readSettings(filename: string, relativeTo?: string): CSpellSettingsI;
55
- readSettings(filename: string, relativeTo: string, defaultValues: CSpellSettingsWST): CSpellSettingsI;
56
- readSettings(filename: string, relativeToOrDefault?: CSpellSettingsWST | string): CSpellSettingsI;
57
- readSettingsAsync(filename: string, relativeTo?: string, pnpSettings?: PnPSettingsOptional): Promise<CSpellSettingsI>;
48
+ protected cspellConfigFileReaderWriter: CSpellConfigFileReaderWriter;
49
+ protected configSearch: ConfigSearch;
50
+ protected toDispose: {
51
+ dispose: () => void;
52
+ }[];
53
+ readSettingsAsync(filename: string | URL, relativeTo?: string | URL, pnpSettings?: PnPSettingsOptional): Promise<CSpellSettingsI>;
54
+ readConfigFile(filenameOrURL: string | URL, relativeTo?: string | URL): Promise<CSpellConfigFile | Error>;
55
+ searchForConfigFileLocation(searchFrom: URL | string | undefined): Promise<URL | undefined>;
56
+ searchForConfigFile(searchFrom: URL | string | undefined): Promise<CSpellConfigFile | undefined>;
58
57
  /**
59
58
  *
60
- * @param searchFrom the directory / file to start searching from.
59
+ * @param searchFrom the directory / file URL to start searching from.
61
60
  * @param pnpSettings - related to Using Yarn PNP.
62
61
  * @returns the resulting settings
63
62
  */
64
- searchForConfig(searchFrom: string | undefined, pnpSettings?: PnPSettingsOptional): Promise<CSpellSettingsI | undefined>;
65
- private searchConfigLRU;
66
- private _searchForConfig;
63
+ searchForConfig(searchFrom: URL | string | undefined, pnpSettings?: PnPSettingsOptional): Promise<CSpellSettingsI | undefined>;
67
64
  getGlobalSettings(): CSpellSettingsI;
65
+ getGlobalSettingsAsync(): Promise<CSpellSettingsI>;
68
66
  clearCachedSettingsFiles(): void;
69
- /**
70
- * Read a config file and inject the fileRef.
71
- * @param fileRef - filename plus context, injected into the resulting config.
72
- */
73
- protected readConfig(fileRef: ImportFileRef): CSpellSettingsWST;
74
- protected importSettings(fileRef: ImportFileRef, defaultValues: CSpellSettingsWST | undefined, pnpSettings: PnPSettingsOptional): CSpellSettingsI;
67
+ protected importSettings(fileRef: ImportFileRef, pnpSettings: PnPSettingsOptional | undefined, backReferences: string[]): ImportedConfigEntry;
68
+ private setupPnp;
69
+ mergeConfigFileWithImports(cfgFile: CSpellConfigFile, pnpSettings: PnPSettingsOptional | undefined, referencedBy?: string[] | undefined): Promise<CSpellSettingsI>;
70
+ private _mergeConfigFileWithImports;
75
71
  /**
76
72
  * normalizeSettings handles correcting all relative paths, anchoring globs, and importing other config files.
77
73
  * @param rawSettings - raw configuration settings
78
74
  * @param pathToSettingsFile - path to the source file of the configuration settings.
79
75
  */
80
- protected normalizeSettings(rawSettings: CSpellSettingsWST, pathToSettingsFile: string, pnpSettings: PnPSettingsOptional): CSpellSettingsI;
76
+ protected mergeImports(cfgFile: CSpellConfigFile, importedSettings: CSpellUserSettings[]): CSpellSettingsI;
77
+ createCSpellConfigFile(filename: URL | string, settings: CSpellUserSettings): CSpellConfigFile;
78
+ dispose(): void;
81
79
  }
82
80
  declare class ConfigLoaderInternal extends ConfigLoader {
83
81
  constructor(cspellIO: CSpellIO);
84
- get _cachedFiles(): Map<string, import("../../../Models/CSpellSettingsInternalDef.js").CSpellSettingsInternal>;
85
- get _cspellConfigExplorer(): {
86
- readonly search: (searchFrom?: string | undefined) => Promise<import("cosmiconfig/dist/types.js").CosmiconfigResult>;
87
- readonly load: (filepath: string) => Promise<import("cosmiconfig/dist/types.js").CosmiconfigResult>;
88
- readonly clearLoadCache: () => void;
89
- readonly clearSearchCache: () => void;
90
- readonly clearCaches: () => void;
91
- };
92
- get _cspellConfigExplorerSync(): {
93
- readonly search: (searchFrom?: string | undefined) => import("cosmiconfig/dist/types.js").CosmiconfigResult;
94
- readonly load: (filepath: string) => import("cosmiconfig/dist/types.js").CosmiconfigResult;
95
- readonly clearLoadCache: () => void;
96
- readonly clearSearchCache: () => void;
97
- readonly clearCaches: () => void;
98
- };
99
- readonly _readConfig: (fileRef: ImportFileRef) => import("@cspell/cspell-types").CSpellSettingsWithSourceTrace;
100
- readonly _normalizeSettings: (rawSettings: import("@cspell/cspell-types").CSpellSettingsWithSourceTrace, pathToSettingsFile: string, pnpSettings: import("../../../util/types.js").OptionalOrUndefined<import("@cspell/cspell-types").PnPSettings>) => import("../../../Models/CSpellSettingsInternalDef.js").CSpellSettingsInternal;
101
- normalizeSearchForConfigResultAsync(searchPath: string, searchResult: Promise<SearchForConfigResult | null>, pnpSettings: PnPSettingsOptional): Promise<NormalizeSearchForConfigResult>;
102
- normalizeSearchForConfigResult(searchPath: string, searchResult: SearchForConfigResult | ImportError | undefined, pnpSettings: PnPSettingsOptional): NormalizeSearchForConfigResult;
103
- }
104
- interface SearchForConfigResult {
105
- config: CSpellSettingsI | undefined;
106
- filepath: string;
107
- isEmpty?: boolean;
108
- }
109
- interface NormalizeSearchForConfigResult {
110
- config: CSpellSettingsI;
111
- filepath: string | undefined;
112
- error: ImportError | undefined;
82
+ get _cachedFiles(): Map<string, ImportedConfigEntry>;
113
83
  }
114
- /**
115
- *
116
- * @param searchFrom the directory / file to start searching from.
117
- * @param pnpSettings - related to Using Yarn PNP.
118
- * @returns the resulting settings
119
- */
120
- export declare function searchForConfig(searchFrom: string | undefined, pnpSettings?: PnPSettingsOptional): Promise<CSpellSettingsI | undefined>;
121
- /**
122
- *
123
- * @param searchFrom the directory / file to start searching from.
124
- * @param pnpSettings - related to Using Yarn PNP.
125
- * @returns the resulting settings
126
- * @deprecated
127
- * @deprecationMessage Use `searchForConfig`. It is very difficult to support Sync files when settings include web requests.
128
- */
129
- export declare function searchForConfigSync(searchFrom: string | undefined, pnpSettings?: PnPSettingsOptional): CSpellSettingsI | undefined;
130
- /**
131
- * Load a CSpell configuration files.
132
- * @param file - path or package reference to load.
133
- * @param pnpSettings - PnP settings
134
- * @returns normalized CSpellSettings
135
- */
136
- export declare function loadConfig(file: string, pnpSettings?: PnPSettingsOptional): Promise<CSpellSettingsI>;
137
- /**
138
- * Load a CSpell configuration files.
139
- * @param filename - path or package reference to load.
140
- * @param pnpSettings - PnP settings
141
- * @returns normalized CSpellSettings
142
- * @deprecated
143
- */
144
- export declare function loadConfigSync(filename: string, pnpSettings?: PnPSettingsOptional): CSpellSettingsI;
145
- export declare function loadPnP(pnpSettings: PnPSettingsOptional, searchFrom: Uri): Promise<LoaderResult>;
146
- export declare function loadPnPSync(pnpSettings: PnPSettingsOptional, searchFrom: Uri): LoaderResult;
147
- export declare function readRawSettings(filename: string, relativeTo?: string): CSpellSettingsWST;
148
- export declare function getGlobalSettings(): CSpellSettingsI;
149
- export declare function getCachedFileSize(): number;
150
- export declare function clearCachedSettingsFiles(): void;
151
- declare function validateRawConfigVersion(config: CSpellUserSettings | {
152
- version: unknown;
153
- }, fileRef: ImportFileRef): void;
154
- declare function validateRawConfigExports(config: CSpellUserSettings, fileRef: ImportFileRef): void;
84
+ export declare function loadPnP(pnpSettings: PnPSettingsOptional, searchFrom: URL): Promise<LoaderResult>;
85
+ declare function validateRawConfigVersion(config: CSpellConfigFile): void;
155
86
  export declare function createConfigLoader(cspellIO?: CSpellIO): ConfigLoader;
156
- declare function getDefaultConfigLoaderInternal(): ConfigLoaderInternal;
157
- export declare function getDefaultConfigLoader(): ConfigLoader;
87
+ export declare function getDefaultConfigLoaderInternal(): ConfigLoaderInternal;
158
88
  export declare const __testing__: {
159
89
  getDefaultConfigLoaderInternal: typeof getDefaultConfigLoaderInternal;
160
90
  normalizeCacheSettings: typeof normalizeCacheSettings;
161
- validateRawConfigExports: typeof validateRawConfigExports;
162
91
  validateRawConfigVersion: typeof validateRawConfigVersion;
163
92
  };
164
93
  export {};