cspell-lib 5.16.0 → 5.18.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 (41) hide show
  1. package/dist/Models/CSpellSettingsInternalDef.d.ts +23 -0
  2. package/dist/Models/CSpellSettingsInternalDef.js +16 -0
  3. package/dist/Settings/CSpellSettingsServer.d.ts +26 -47
  4. package/dist/Settings/CSpellSettingsServer.js +99 -524
  5. package/dist/Settings/DefaultSettings.d.ts +3 -3
  6. package/dist/Settings/DefaultSettings.js +5 -4
  7. package/dist/Settings/DictionarySettings.d.ts +10 -13
  8. package/dist/Settings/DictionarySettings.js +51 -18
  9. package/dist/Settings/InDocSettings.js +5 -2
  10. package/dist/Settings/configLoader.d.ts +57 -0
  11. package/dist/Settings/configLoader.js +523 -0
  12. package/dist/Settings/index.d.ts +5 -4
  13. package/dist/Settings/index.js +30 -14
  14. package/dist/Settings/index.link.d.ts +3 -0
  15. package/dist/Settings/index.link.js +8 -0
  16. package/dist/Settings/link.js +2 -2
  17. package/dist/SpellingDictionary/Dictionaries.d.ts +4 -4
  18. package/dist/SpellingDictionary/Dictionaries.js +26 -7
  19. package/dist/SpellingDictionary/DictionaryLoader.d.ts +3 -3
  20. package/dist/SpellingDictionary/DictionaryLoader.js +2 -2
  21. package/dist/SpellingDictionary/SpellingDictionary.d.ts +4 -3
  22. package/dist/SpellingDictionary/SpellingDictionaryCollection.js +1 -1
  23. package/dist/SpellingDictionary/SpellingDictionaryFromTrie.js +1 -1
  24. package/dist/SpellingDictionary/SpellingDictionaryMethods.d.ts +4 -3
  25. package/dist/SpellingDictionary/SpellingDictionaryMethods.js +8 -3
  26. package/dist/SpellingDictionary/createSpellingDictionary.d.ts +2 -2
  27. package/dist/SpellingDictionary/createSpellingDictionary.js +35 -4
  28. package/dist/index.d.ts +10 -4
  29. package/dist/index.js +16 -6
  30. package/dist/suggestions.d.ts +63 -0
  31. package/dist/suggestions.js +117 -0
  32. package/dist/trace.d.ts +1 -0
  33. package/dist/trace.js +19 -16
  34. package/dist/util/simpleCache.d.ts +44 -0
  35. package/dist/util/simpleCache.js +140 -0
  36. package/dist/util/types.d.ts +49 -1
  37. package/dist/util/types.js +6 -0
  38. package/dist/util/util.d.ts +3 -0
  39. package/dist/util/util.js +19 -1
  40. package/dist/validator.js +1 -2
  41. package/package.json +14 -10
@@ -0,0 +1,23 @@
1
+ import { CSpellSettingsWithSourceTrace, DictionaryDefinitionAugmented, DictionaryDefinitionCustom, DictionaryDefinitionPreferred } from '@cspell/cspell-types';
2
+ import { WeightMap } from 'cspell-trie-lib';
3
+ export declare const SymbolCSpellSettingsInternal: unique symbol;
4
+ export interface CSpellSettingsInternal extends Omit<CSpellSettingsWithSourceTrace, 'dictionaryDefinitions'> {
5
+ [SymbolCSpellSettingsInternal]: true;
6
+ dictionaryDefinitions?: DictionaryDefinitionInternal[];
7
+ }
8
+ declare type DictionaryDefinitionCustomUniqueFields = Omit<DictionaryDefinitionCustom, keyof DictionaryDefinitionPreferred>;
9
+ export interface DictionaryDefinitionInternal extends Readonly<DictionaryDefinitionPreferred>, Readonly<Partial<DictionaryDefinitionCustomUniqueFields>>, Readonly<DictionaryDefinitionAugmented> {
10
+ /**
11
+ * Optional weight map used to improve suggestions.
12
+ */
13
+ readonly weightMap?: WeightMap | undefined;
14
+ /** The path to the config file that contains this dictionary definition */
15
+ readonly __source?: string | undefined;
16
+ }
17
+ export interface DictionaryDefinitionInternalWithSource extends DictionaryDefinitionInternal {
18
+ readonly __source: string;
19
+ }
20
+ export declare function createCSpellSettingsInternal(parts?: Partial<CSpellSettingsInternal>): CSpellSettingsInternal;
21
+ export declare function isCSpellSettingsInternal(cs: CSpellSettingsInternal | CSpellSettingsWithSourceTrace): cs is CSpellSettingsInternal;
22
+ export {};
23
+ //# sourceMappingURL=CSpellSettingsInternalDef.d.ts.map
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isCSpellSettingsInternal = exports.createCSpellSettingsInternal = exports.SymbolCSpellSettingsInternal = void 0;
4
+ exports.SymbolCSpellSettingsInternal = Symbol('CSpellSettingsInternal');
5
+ function createCSpellSettingsInternal(parts = {}) {
6
+ return {
7
+ ...parts,
8
+ [exports.SymbolCSpellSettingsInternal]: true,
9
+ };
10
+ }
11
+ exports.createCSpellSettingsInternal = createCSpellSettingsInternal;
12
+ function isCSpellSettingsInternal(cs) {
13
+ return !!cs[exports.SymbolCSpellSettingsInternal];
14
+ }
15
+ exports.isCSpellSettingsInternal = isCSpellSettingsInternal;
16
+ //# sourceMappingURL=CSpellSettingsInternalDef.js.map
@@ -1,71 +1,50 @@
1
- import type { CSpellSettingsWithSourceTrace, CSpellUserSettings, Glob, ImportFileRef, PnPSettings } from '@cspell/cspell-types';
2
- import { URI } from 'vscode-uri';
3
- import { LoaderResult } from './pnpLoader';
1
+ import type { CSpellSettingsWithSourceTrace, Glob, ImportFileRef } from '@cspell/cspell-types';
2
+ import { CSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef';
3
+ declare type CSpellSettingsWST = CSpellSettingsWithSourceTrace;
4
+ declare type CSpellSettingsI = CSpellSettingsInternal;
5
+ export declare const configSettingsFileVersion0_1 = "0.1";
6
+ export declare const configSettingsFileVersion0_2 = "0.2";
4
7
  export declare const currentSettingsFileVersion = "0.2";
5
- export declare const sectionCSpell = "cSpell";
6
- export declare const defaultFileName = "cspell.json";
7
8
  export declare const ENV_CSPELL_GLOB_ROOT = "CSPELL_GLOB_ROOT";
8
- export declare const defaultConfigFilenames: readonly string[];
9
- declare type CSpellSettings = CSpellSettingsWithSourceTrace;
9
+ declare function mergeObjects(left: undefined, right: undefined): undefined;
10
+ declare function mergeObjects<T>(left: T, right: undefined): T;
11
+ declare function mergeObjects<T>(left: T, right: T): T;
12
+ declare function mergeObjects<T>(left: undefined, right: T): T;
13
+ export declare function mergeSettings(left: CSpellSettingsWST | CSpellSettingsI, ...settings: (CSpellSettingsWST | CSpellSettingsI)[]): CSpellSettingsI;
14
+ export declare function mergeInDocSettings(left: CSpellSettingsWST, right: CSpellSettingsWST): CSpellSettingsWST;
15
+ export declare function calcOverrideSettings(settings: CSpellSettingsWST, filename: string): CSpellSettingsI;
10
16
  /**
11
- * normalizeSettings handles correcting all relative paths, anchoring globs, and importing other config files.
12
- * @param rawSettings - raw configuration settings
13
- * @param pathToSettingsFile - path to the source file of the configuration settings.
17
+ *
18
+ * @param settings - settings to finalize
19
+ * @returns settings where all globs and file paths have been resolved.
14
20
  */
15
- declare function normalizeSettings(rawSettings: CSpellSettings, pathToSettingsFile: string, pnpSettings: PnPSettings): CSpellSettings;
16
- export declare function readSettings(filename: string): CSpellSettings;
17
- export declare function readSettings(filename: string, defaultValues: CSpellSettings): CSpellSettings;
18
- export declare function readSettings(filename: string, relativeTo: string): CSpellSettings;
19
- export declare function readSettings(filename: string, relativeTo: string, defaultValues: CSpellSettings): CSpellSettings;
20
- export declare function searchForConfig(searchFrom: string | undefined, pnpSettings?: PnPSettings): Promise<CSpellSettings | undefined>;
21
- export declare function loadConfig(file: string, pnpSettings?: PnPSettings): Promise<CSpellSettings>;
22
- export declare function loadPnP(pnpSettings: PnPSettings, searchFrom: URI): Promise<LoaderResult>;
23
- export declare function loadPnPSync(pnpSettings: PnPSettings, searchFrom: URI): LoaderResult;
24
- export declare function readRawSettings(filename: string, relativeTo?: string): CSpellSettings;
21
+ export declare function finalizeSettings(settings: CSpellSettingsWST | CSpellSettingsI): CSpellSettingsI;
22
+ export declare function toInternalSettings(settings: undefined): undefined;
23
+ export declare function toInternalSettings(settings: CSpellSettingsI | CSpellSettingsWST): CSpellSettingsI;
24
+ export declare function toInternalSettings(settings?: CSpellSettingsI | CSpellSettingsWST): CSpellSettingsI | undefined;
25
25
  /**
26
- *
27
- * @param filenames - settings files to read
28
- * @returns combined configuration
26
+ * @param filename - filename
27
+ * @param globs - globs
28
+ * @returns true if it matches
29
29
  * @deprecated true
30
+ * @deprecationMessage No longer actively supported. Use package: `cspell-glob`.
30
31
  */
31
- export declare function readSettingsFiles(filenames: string[]): CSpellSettings;
32
- declare function mergeObjects(left: undefined, right: undefined): undefined;
33
- declare function mergeObjects<T>(left: T, right: undefined): T;
34
- declare function mergeObjects<T>(left: T, right: T): T;
35
- declare function mergeObjects<T>(left: undefined, right: T): T;
36
- export declare function mergeSettings(left: CSpellSettings, ...settings: CSpellSettings[]): CSpellSettings;
37
- export declare function mergeInDocSettings(left: CSpellSettings, right: CSpellSettings): CSpellSettings;
38
- export declare function calcOverrideSettings(settings: CSpellSettings, filename: string): CSpellSettings;
39
- export declare function finalizeSettings(settings: CSpellSettings): CSpellSettings;
40
- export declare function getGlobalSettings(): CSpellSettings;
41
- export declare function getCachedFileSize(): number;
42
- export declare function clearCachedSettingsFiles(): void;
43
32
  export declare function checkFilenameMatchesGlob(filename: string, globs: Glob | Glob[]): boolean;
44
33
  /**
45
34
  * Return a list of Setting Sources used to create this Setting.
46
35
  * @param settings the settings to search
47
36
  */
48
- export declare function getSources(settings: CSpellSettings): CSpellSettings[];
37
+ export declare function getSources(settings: CSpellSettingsWST): CSpellSettingsWST[];
49
38
  export interface ImportFileRefWithError extends ImportFileRef {
50
39
  error: Error;
51
40
  }
52
- export declare function extractImportErrors(settings: CSpellSettings): ImportFileRefWithError[];
53
41
  export interface ConfigurationDependencies {
54
42
  configFiles: string[];
55
43
  dictionaryFiles: string[];
56
44
  }
57
- export declare function extractDependencies(settings: CSpellSettings): ConfigurationDependencies;
58
- declare function normalizeCacheSettings(settings: Pick<CSpellSettings, 'cache'>, pathToSettingsDir: string): Pick<CSpellSettings, 'cache'>;
59
- declare function validateRawConfigVersion(config: CSpellUserSettings | {
60
- version: unknown;
61
- }, fileRef: ImportFileRef): void;
62
- declare function validateRawConfigExports(config: CSpellUserSettings, fileRef: ImportFileRef): void;
45
+ export declare function extractDependencies(settings: CSpellSettingsWST | CSpellSettingsI): ConfigurationDependencies;
63
46
  export declare const __testing__: {
64
47
  mergeObjects: typeof mergeObjects;
65
- normalizeCacheSettings: typeof normalizeCacheSettings;
66
- normalizeSettings: typeof normalizeSettings;
67
- validateRawConfigExports: typeof validateRawConfigExports;
68
- validateRawConfigVersion: typeof validateRawConfigVersion;
69
48
  };
70
49
  export {};
71
50
  //# sourceMappingURL=CSpellSettingsServer.d.ts.map