cspell-lib 5.13.3 → 5.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.
@@ -1,6 +1,7 @@
1
1
  import type { CSpellSettingsWithSourceTrace, CSpellUserSettings, Glob, ImportFileRef, PnPSettings } from '@cspell/cspell-types';
2
2
  import { URI } from 'vscode-uri';
3
3
  import { LoaderResult } from './pnpLoader';
4
+ export declare const currentSettingsFileVersion = "0.2";
4
5
  export declare const sectionCSpell = "cSpell";
5
6
  export declare const defaultFileName = "cspell.json";
6
7
  export declare const ENV_CSPELL_GLOB_ROOT = "CSPELL_GLOB_ROOT";
@@ -45,14 +46,21 @@ export interface ImportFileRefWithError extends ImportFileRef {
45
46
  error: Error;
46
47
  }
47
48
  export declare function extractImportErrors(settings: CSpellSettings): ImportFileRefWithError[];
49
+ export interface ConfigurationDependencies {
50
+ configFiles: string[];
51
+ dictionaryFiles: string[];
52
+ }
53
+ export declare function extractDependencies(settings: CSpellSettings): ConfigurationDependencies;
54
+ declare function normalizeCacheSettings(settings: Pick<CSpellSettings, 'cache'>, pathToSettingsDir: string): Pick<CSpellSettings, 'cache'>;
48
55
  declare function validateRawConfigVersion(config: CSpellUserSettings | {
49
56
  version: unknown;
50
57
  }, fileRef: ImportFileRef): void;
51
58
  declare function validateRawConfigExports(config: CSpellUserSettings, fileRef: ImportFileRef): void;
52
59
  export declare const __testing__: {
60
+ normalizeCacheSettings: typeof normalizeCacheSettings;
53
61
  normalizeSettings: typeof normalizeSettings;
54
- validateRawConfigVersion: typeof validateRawConfigVersion;
55
62
  validateRawConfigExports: typeof validateRawConfigExports;
63
+ validateRawConfigVersion: typeof validateRawConfigVersion;
56
64
  };
57
65
  export {};
58
66
  //# sourceMappingURL=CSpellSettingsServer.d.ts.map
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.__testing__ = exports.extractImportErrors = exports.getSources = exports.checkFilenameMatchesGlob = exports.clearCachedSettingsFiles = exports.getCachedFileSize = exports.getGlobalSettings = exports.finalizeSettings = exports.calcOverrideSettings = exports.mergeInDocSettings = exports.mergeSettings = exports.readSettingsFiles = exports.readRawSettings = exports.loadPnPSync = exports.loadPnP = exports.loadConfig = exports.searchForConfig = exports.readSettings = exports.defaultConfigFilenames = exports.ENV_CSPELL_GLOB_ROOT = exports.defaultFileName = exports.sectionCSpell = void 0;
22
+ exports.__testing__ = exports.extractDependencies = exports.extractImportErrors = exports.getSources = exports.checkFilenameMatchesGlob = exports.clearCachedSettingsFiles = exports.getCachedFileSize = exports.getGlobalSettings = exports.finalizeSettings = exports.calcOverrideSettings = exports.mergeInDocSettings = exports.mergeSettings = exports.readSettingsFiles = exports.readRawSettings = exports.loadPnPSync = exports.loadPnP = exports.loadConfig = exports.searchForConfig = exports.readSettings = exports.defaultConfigFilenames = exports.ENV_CSPELL_GLOB_ROOT = exports.defaultFileName = exports.sectionCSpell = exports.currentSettingsFileVersion = void 0;
23
23
  const json = __importStar(require("comment-json"));
24
24
  const cosmiconfig_1 = require("cosmiconfig");
25
25
  const cspell_glob_1 = require("cspell-glob");
@@ -36,7 +36,7 @@ const pnpLoader_1 = require("./pnpLoader");
36
36
  const supportedCSpellConfigVersions = ['0.2'];
37
37
  const configSettingsFileVersion0_1 = '0.1';
38
38
  const configSettingsFileVersion0_2 = '0.2';
39
- const currentSettingsFileVersion = configSettingsFileVersion0_2;
39
+ exports.currentSettingsFileVersion = configSettingsFileVersion0_2;
40
40
  const setOfSupportedConfigVersions = new Set(supportedCSpellConfigVersions);
41
41
  exports.sectionCSpell = 'cSpell';
42
42
  exports.defaultFileName = 'cspell.json';
@@ -90,7 +90,7 @@ const cspellConfigExplorerSync = (0, cosmiconfig_1.cosmiconfigSync)('cspell', cs
90
90
  const defaultSettings = {
91
91
  id: 'default',
92
92
  name: 'default',
93
- version: currentSettingsFileVersion,
93
+ version: exports.currentSettingsFileVersion,
94
94
  };
95
95
  const defaultPnPSettings = {};
96
96
  let globalSettings;
@@ -137,6 +137,7 @@ function normalizeSettings(rawSettings, pathToSettingsFile, pnpSettings) {
137
137
  loadPnPSync(pnpSettingsToUse, vscode_uri_1.URI.file(pathToSettingsDir));
138
138
  // Fix up dictionaryDefinitions
139
139
  const settings = {
140
+ version: defaultSettings.version,
140
141
  ...rawSettings,
141
142
  id,
142
143
  name,
@@ -149,6 +150,7 @@ function normalizeSettings(rawSettings, pathToSettingsFile, pnpSettings) {
149
150
  const normalizedOverrides = normalizeOverrides(settings, pathToSettingsFile);
150
151
  const normalizedReporters = normalizeReporters(settings, pathToSettingsFile);
151
152
  const normalizedGitignoreRoot = normalizeGitignoreRoot(settings, pathToSettingsFile);
153
+ const normalizedCacheSettings = normalizeCacheSettings(settings, pathToSettingsDir);
152
154
  const imports = typeof settings.import === 'string' ? [settings.import] : settings.import || [];
153
155
  const source = settings.source || {
154
156
  name: settings.name,
@@ -162,6 +164,7 @@ function normalizeSettings(rawSettings, pathToSettingsFile, pnpSettings) {
162
164
  ...normalizedOverrides,
163
165
  ...normalizedReporters,
164
166
  ...normalizedGitignoreRoot,
167
+ ...normalizedCacheSettings,
165
168
  };
166
169
  if (!imports.length) {
167
170
  return fileSettings;
@@ -534,7 +537,7 @@ function getSources(settings) {
534
537
  return sources;
535
538
  }
536
539
  exports.getSources = getSources;
537
- function mergeImportRefs(left, right) {
540
+ function mergeImportRefs(left, right = {}) {
538
541
  var _a;
539
542
  const imports = new Map(left.__imports || []);
540
543
  if (left.__importRef) {
@@ -553,10 +556,19 @@ function isImportFileRefWithError(ref) {
553
556
  return !!ref.error;
554
557
  }
555
558
  function extractImportErrors(settings) {
556
- const imports = mergeImportRefs(settings, {});
559
+ const imports = mergeImportRefs(settings);
557
560
  return !imports ? [] : [...imports.values()].filter(isImportFileRefWithError);
558
561
  }
559
562
  exports.extractImportErrors = extractImportErrors;
563
+ function extractDependencies(settings) {
564
+ const configFiles = [...(mergeImportRefs(settings) || [])].map(([filename]) => filename);
565
+ const dictionaryFiles = (0, DictionarySettings_1.calcDictionaryDefsToLoad)(settings).map((dict) => dict.path);
566
+ return {
567
+ configFiles,
568
+ dictionaryFiles,
569
+ };
570
+ }
571
+ exports.extractDependencies = extractDependencies;
560
572
  function resolveGlobRoot(settings, pathToSettingsFile) {
561
573
  var _a;
562
574
  const settingsFileDirRaw = path.dirname(pathToSettingsFile);
@@ -573,6 +585,10 @@ function resolveGlobRoot(settings, pathToSettingsFile) {
573
585
  const globRoot = path.resolve(settingsFileDir, rawRoot.replace('${cwd}', cwd));
574
586
  return globRoot;
575
587
  }
588
+ function resolveFilePath(filename, pathToSettingsFile) {
589
+ const cwd = process.cwd();
590
+ return path.resolve(pathToSettingsFile, filename.replace('${cwd}', cwd));
591
+ }
576
592
  function toGlobDef(g, root, source) {
577
593
  if (g === undefined)
578
594
  return undefined;
@@ -670,6 +686,15 @@ function normalizeSettingsGlobs(settings, pathToSettingsFile) {
670
686
  ignorePaths,
671
687
  };
672
688
  }
689
+ function normalizeCacheSettings(settings, pathToSettingsDir) {
690
+ const { cache } = settings;
691
+ if (cache === undefined)
692
+ return {};
693
+ const { cacheLocation } = cache;
694
+ if (cacheLocation === undefined)
695
+ return { cache };
696
+ return { cache: { ...cache, cacheLocation: resolveFilePath(cacheLocation, pathToSettingsDir) } };
697
+ }
673
698
  function validationMessage(msg, fileRef) {
674
699
  return msg + `\n File: "${fileRef.filename}"`;
675
700
  }
@@ -687,9 +712,9 @@ function validateRawConfigVersion(config, fileRef) {
687
712
  (0, logger_1.logError)(validationMessage(`Unsupported config file version: "${version}"`, fileRef));
688
713
  return;
689
714
  }
690
- const msg = version > currentSettingsFileVersion
691
- ? `Newer config file version found: "${version}". Supported version is "${currentSettingsFileVersion}"`
692
- : `Legacy config file version found: "${version}", upgrade to "${currentSettingsFileVersion}"`;
715
+ const msg = version > exports.currentSettingsFileVersion
716
+ ? `Newer config file version found: "${version}". Supported version is "${exports.currentSettingsFileVersion}"`
717
+ : `Legacy config file version found: "${version}", upgrade to "${exports.currentSettingsFileVersion}"`;
693
718
  (0, logger_1.logWarning)(validationMessage(msg, fileRef));
694
719
  }
695
720
  function validateRawConfigExports(config, fileRef) {
@@ -707,8 +732,9 @@ function validateRawConfig(config, fileRef) {
707
732
  validations.forEach((fn) => fn(config, fileRef));
708
733
  }
709
734
  exports.__testing__ = {
735
+ normalizeCacheSettings,
710
736
  normalizeSettings,
711
- validateRawConfigVersion,
712
737
  validateRawConfigExports,
738
+ validateRawConfigVersion,
713
739
  };
714
740
  //# sourceMappingURL=CSpellSettingsServer.js.map
@@ -45,10 +45,14 @@ const predefinedPatterns = [
45
45
  { name: 'SpellCheckerDisable', pattern: regExpSpellCheckerDisable },
46
46
  { name: 'PublicKey', pattern: RegPat.regExPublicKey },
47
47
  { name: 'RsaCert', pattern: RegPat.regExCert },
48
+ { name: 'SshRsa', pattern: RegPat.regExSshRSA },
48
49
  { name: 'EscapeCharacters', pattern: RegPat.regExEscapeCharacters },
49
50
  { name: 'Base64', pattern: RegPat.regExBase64 },
51
+ { name: 'Base64SingleLine', pattern: RegPat.regExBase64SingleLine },
52
+ { name: 'Base64MultiLine', pattern: RegPat.regExBase64MultiLine },
50
53
  { name: 'Email', pattern: RegPat.regExEmail },
51
54
  { name: 'SHA', pattern: RegPat.regExSha },
55
+ { name: 'HashStrings', pattern: RegPat.regExHashStrings },
52
56
  { name: 'UnicodeRef', pattern: RegPat.regExUnicodeRef },
53
57
  { name: 'UUID', pattern: RegPat.regExUUID },
54
58
  { name: 'href', pattern: RegPat.regExHRef },
@@ -68,14 +72,16 @@ const definedDefaultRegExpExcludeList = [
68
72
  'SpellCheckerIgnoreInDocSetting',
69
73
  'Urls',
70
74
  'Email',
71
- 'PublicKey',
72
75
  'RsaCert',
73
- 'Base64',
76
+ 'SshRsa',
77
+ 'Base64MultiLine',
78
+ 'Base64SingleLine',
74
79
  'CommitHash',
75
80
  'CommitHashLink',
76
81
  'CStyleHexValue',
77
82
  'CSSHexValue',
78
83
  'SHA',
84
+ 'HashStrings',
79
85
  'UnicodeRef',
80
86
  'UUID',
81
87
  ];
@@ -1,4 +1,4 @@
1
- import type { DictionaryDefinition, DictionaryDefinitionPreferred, DictionaryReference } from '@cspell/cspell-types';
1
+ import type { DictionaryDefinition, DictionaryDefinitionPreferred, DictionaryReference, CSpellSettingsWithSourceTrace } from '@cspell/cspell-types';
2
2
  export interface DictionaryDefinitionWithSource extends DictionaryDefinitionPreferred {
3
3
  /** The path to the config file that contains this dictionary definition */
4
4
  __source: string;
@@ -22,4 +22,5 @@ export declare function normalizePathForDictDefs(defs: DictionaryDefinition[], p
22
22
  export declare function normalizePathForDictDefs(defs: DictionaryDefinition[] | undefined, pathToSettingsFile: string): DictionaryDefinitionWithSource[] | undefined;
23
23
  export declare function normalizePathForDictDef(def: DictionaryDefinition, pathToSettingsFile: string): DictionaryDefinitionWithSource;
24
24
  export declare function isDictionaryDefinitionWithSource(d: DictionaryDefinition | DictionaryDefinitionWithSource): d is DictionaryDefinitionWithSource;
25
+ export declare function calcDictionaryDefsToLoad(settings: CSpellSettingsWithSourceTrace): DictionaryDefinitionPreferred[];
25
26
  //# sourceMappingURL=DictionarySettings.d.ts.map
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.isDictionaryDefinitionWithSource = exports.normalizePathForDictDef = exports.normalizePathForDictDefs = exports.filterDictDefsToLoad = void 0;
22
+ exports.calcDictionaryDefsToLoad = exports.isDictionaryDefinitionWithSource = exports.normalizePathForDictDef = exports.normalizePathForDictDefs = exports.filterDictDefsToLoad = void 0;
23
23
  const path = __importStar(require("path"));
24
24
  const resolveFile_1 = require("../util/resolveFile");
25
25
  const DictionaryReferenceCollection_1 = require("./DictionaryReferenceCollection");
@@ -87,4 +87,17 @@ exports.isDictionaryDefinitionWithSource = isDictionaryDefinitionWithSource;
87
87
  function determineName(filename, options) {
88
88
  return options.name || path.basename(filename);
89
89
  }
90
+ function calcDictionaryDefsToLoad(settings) {
91
+ const { dictionaries = [], dictionaryDefinitions = [], noSuggestDictionaries = [] } = settings;
92
+ const colNoSug = (0, DictionaryReferenceCollection_1.createDictionaryReferenceCollection)(noSuggestDictionaries);
93
+ const colDicts = (0, DictionaryReferenceCollection_1.createDictionaryReferenceCollection)(dictionaries.concat(colNoSug.enabled()));
94
+ const modDefs = dictionaryDefinitions.map((def) => {
95
+ const enabled = colNoSug.isEnabled(def.name);
96
+ if (enabled === undefined)
97
+ return def;
98
+ return { ...def, noSuggest: enabled };
99
+ });
100
+ return filterDictDefsToLoad(colDicts.enabled(), modDefs);
101
+ }
102
+ exports.calcDictionaryDefsToLoad = calcDictionaryDefsToLoad;
90
103
  //# sourceMappingURL=DictionarySettings.js.map
@@ -13,8 +13,19 @@ export declare const regExSpellingGuardLine: RegExp;
13
13
  export declare const regExIgnoreSpellingDirectives: RegExp;
14
14
  export declare const regExPublicKey: RegExp;
15
15
  export declare const regExCert: RegExp;
16
+ export declare const regExSshRSA: RegExp;
16
17
  export declare const regExEscapeCharacters: RegExp;
17
18
  export declare const regExBase64: RegExp;
19
+ /**
20
+ * Detect a string of characters that look like a Base64 string.
21
+ *
22
+ * It must be:
23
+ * - at least 40 characters
24
+ * - contain at least 1 of [0-9+=]
25
+ * - end at the end of the line or with [,"'\]
26
+ */
27
+ export declare const regExBase64SingleLine: RegExp;
28
+ export declare const regExBase64MultiLine: RegExp;
18
29
  export declare const regExPhpHereDoc: RegExp;
19
30
  export declare const regExString: RegExp;
20
31
  export declare const regExCStyleComments: RegExp;
@@ -22,4 +33,14 @@ export declare const rexExPythonStyleComments: RegExp;
22
33
  export declare const regExEmail: RegExp;
23
34
  export declare const regExRepeatedChar: RegExp;
24
35
  export declare const regExSha: RegExp;
36
+ /**
37
+ * Detect common hash strings like:
38
+ * - `sha1`, `sha256`, `sha512`
39
+ * - `md5`
40
+ * - `base64` - used in email
41
+ * - `crypt`, `bcrypt`, `script`
42
+ * - `token`
43
+ * - `assertion` - use with jwt
44
+ */
45
+ export declare const regExHashStrings: RegExp;
25
46
  //# sourceMappingURL=RegExpPatterns.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.regExSha = exports.regExRepeatedChar = exports.regExEmail = exports.rexExPythonStyleComments = exports.regExCStyleComments = exports.regExString = exports.regExPhpHereDoc = exports.regExBase64 = exports.regExEscapeCharacters = exports.regExCert = exports.regExPublicKey = exports.regExIgnoreSpellingDirectives = exports.regExSpellingGuardLine = exports.regExSpellingGuardNext = exports.regExSpellingGuardBlock = exports.regExUnicodeRef = exports.regExUUID = exports.regExCSSHexValue = exports.regExCStyleHexValue = exports.regExCommitHashLink = exports.regExCommitHash = exports.regExMatchCommonHexFormats = exports.regExHRef = exports.regExMatchUrls = void 0;
3
+ exports.regExHashStrings = exports.regExSha = exports.regExRepeatedChar = exports.regExEmail = exports.rexExPythonStyleComments = exports.regExCStyleComments = exports.regExString = exports.regExPhpHereDoc = exports.regExBase64MultiLine = exports.regExBase64SingleLine = exports.regExBase64 = exports.regExEscapeCharacters = exports.regExSshRSA = exports.regExCert = exports.regExPublicKey = exports.regExIgnoreSpellingDirectives = exports.regExSpellingGuardLine = exports.regExSpellingGuardNext = exports.regExSpellingGuardBlock = exports.regExUnicodeRef = exports.regExUUID = exports.regExCSSHexValue = exports.regExCStyleHexValue = exports.regExCommitHashLink = exports.regExCommitHash = exports.regExMatchCommonHexFormats = exports.regExHRef = exports.regExMatchUrls = void 0;
4
4
  // Exclude Expressions
5
5
  // cSpell:ignore anrvtbf
6
6
  exports.regExMatchUrls = /(?:https?|ftp):\/\/[^\s"]+/gi;
@@ -16,10 +16,21 @@ exports.regExSpellingGuardBlock = /(\bc?spell(?:-?checker)?::?)\s*disable(?!-lin
16
16
  exports.regExSpellingGuardNext = /\bc?spell(?:-?checker)?::?\s*disable-next\b.*\s\s?.*/gi;
17
17
  exports.regExSpellingGuardLine = /^.*\bc?spell(?:-?checker)?::?\s*disable-line\b.*/gim;
18
18
  exports.regExIgnoreSpellingDirectives = /\bc?spell(?:-?checker)?::?\s*ignoreRegExp.*/gim;
19
- exports.regExPublicKey = /BEGIN\s+((?:RSA\s+)?PUBLIC)\s+KEY(?:[\w=+\-/]*\r?\n)+?-*END\s+\1/g;
20
- exports.regExCert = /BEGIN\s+(CERTIFICATE|RSA\s+(?:PRIVATE|PUBLIC)\s+KEY)(?:[\w=+\-/]*\r?\n)+?-*END\s+\1/g;
19
+ exports.regExPublicKey = /-{5}BEGIN\s+((?:RSA\s+)?PUBLIC\s+KEY)[\w=+\-/=\\\s]+?END\s+\1-{5}/g;
20
+ exports.regExCert = /-{5}BEGIN\s+(CERTIFICATE|(?:RSA\s+)?(?:PRIVATE|PUBLIC)\s+KEY)[\w=+\-/=\\\s]+?END\s+\1-{5}/g;
21
+ exports.regExSshRSA = /ssh-rsa\s+[a-z0-9/+]{28,}={0,3}(?![a-z0-9/+=])/gi;
21
22
  exports.regExEscapeCharacters = /\\(?:[anrvtbf]|[xu][a-f0-9]+)/gi;
22
- exports.regExBase64 = /(?<![a-z0-9/+])(?:[a-z0-9/+]{40,})(?:\s^\s*[a-z0-9/+]{40,})*(?:\s^\s*[a-z0-9/+]+=*)?/gim;
23
+ exports.regExBase64 = /(?<![A-Za-z0-9/+])(?:[A-Za-z0-9/+]{40,})(?:\s^\s*[A-Za-z0-9/+]{40,})*(?:\s^\s*[A-Za-z0-9/+]+=*)?(?![A-Za-z0-9/+=])/gm;
24
+ /**
25
+ * Detect a string of characters that look like a Base64 string.
26
+ *
27
+ * It must be:
28
+ * - at least 40 characters
29
+ * - contain at least 1 of [0-9+=]
30
+ * - end at the end of the line or with [,"'\]
31
+ */
32
+ exports.regExBase64SingleLine = /(?<![A-Za-z0-9/+])(?=[^/]|[/][A-Za-z0-9/+]+?[=+])(?![A-Za-z/]+(?![A-Za-z0-9/+=]))(?=[A-Za-z0-9/+=]*?(?:[A-Z]{2}|[0-9]{2}))(?:[A-Za-z0-9/+]{4}){10,}(?:[A-Za-z0-9/+]{3}={1}|[A-Za-z0-9/+]{2}={2}|[A-Za-z0-9/+]{1}={3})?(?![A-Za-z0-9/+=])(?=$|[:.,"'\\)])/gm;
33
+ exports.regExBase64MultiLine = /(?<![A-Za-z0-9/+])["']?(?:[A-Za-z0-9/+]{40,})["']?(?:\s^\s*["']?[A-Za-z0-9/+]{40,}["']?)+(?:\s^\s*["']?[A-Za-z0-9/+]+={0,3}["']?)?(?![A-Za-z0-9/+=])/gm;
23
34
  // cspell:ignore aeiou
24
35
  // The following is an attempt at detecting random strings.
25
36
  // export const regExRandomString =
@@ -32,6 +43,15 @@ exports.regExCStyleComments = /(?<!\w:)(?:\/\/.*)|(?:\/\*[\s\S]*?\*\/)/g;
32
43
  exports.rexExPythonStyleComments = /#.*|(?:('''|""")[^\1]+?\1)/gm;
33
44
  exports.regExEmail = /<?\b[\w.\-+]{1,128}@\w{1,63}(\.\w{1,63}){1,4}\b>?/gi;
34
45
  exports.regExRepeatedChar = /^(\w)\1{3,}$/i;
35
- // cSpell:ignore bsha
36
- exports.regExSha = /\bsha\d+-[a-z0-9+/=]+/gi;
46
+ exports.regExSha = /\bsha\d+-[a-z0-9+/]{25,}={0,3}/gi;
47
+ /**
48
+ * Detect common hash strings like:
49
+ * - `sha1`, `sha256`, `sha512`
50
+ * - `md5`
51
+ * - `base64` - used in email
52
+ * - `crypt`, `bcrypt`, `script`
53
+ * - `token`
54
+ * - `assertion` - use with jwt
55
+ */
56
+ exports.regExHashStrings = /(?:\b(?:sha\d+|md5|base64|crypt|bcrypt|scrypt|security-token|assertion)[-,:$=]|#code[/])[-\w/+%.]{25,}={0,3}(?:(['"])\s*\+?\s*\1?[-\w/+%.]+={0,3})*(?![-\w/+=%.])/gi;
37
57
  //# sourceMappingURL=RegExpPatterns.js.map
@@ -1,7 +1,7 @@
1
- import type { CSpellUserSettings, DictionaryDefinition, DictionaryReference } from '@cspell/cspell-types';
1
+ import type { CSpellUserSettings, DictionaryDefinitionPreferred } from '@cspell/cspell-types';
2
2
  import { SpellingDictionaryCollection } from './index';
3
3
  import { SpellingDictionary } from './SpellingDictionary';
4
- export declare function loadDictionaries(dictIds: DictionaryReference[], defs: DictionaryDefinition[]): Promise<SpellingDictionary>[];
4
+ export declare function loadDictionaryDefs(defsToLoad: DictionaryDefinitionPreferred[]): Promise<SpellingDictionary>[];
5
5
  export declare function refreshDictionaryCache(maxAge?: number): Promise<void>;
6
6
  export declare function getDictionary(settings: CSpellUserSettings): Promise<SpellingDictionaryCollection>;
7
7
  //# sourceMappingURL=Dictionaries.d.ts.map
@@ -1,31 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDictionary = exports.refreshDictionaryCache = exports.loadDictionaries = void 0;
4
- const DictionaryReferenceCollection_1 = require("../Settings/DictionaryReferenceCollection");
3
+ exports.getDictionary = exports.refreshDictionaryCache = exports.loadDictionaryDefs = void 0;
5
4
  const DictionarySettings_1 = require("../Settings/DictionarySettings");
6
5
  const createSpellingDictionary_1 = require("./createSpellingDictionary");
7
6
  const DictionaryLoader_1 = require("./DictionaryLoader");
8
7
  const SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection");
9
- function loadDictionaries(dictIds, defs) {
10
- const defsToLoad = (0, DictionarySettings_1.filterDictDefsToLoad)(dictIds, defs);
8
+ function loadDictionaryDefs(defsToLoad) {
11
9
  return defsToLoad.map((def) => (0, DictionaryLoader_1.loadDictionary)(def.path, def));
12
10
  }
13
- exports.loadDictionaries = loadDictionaries;
11
+ exports.loadDictionaryDefs = loadDictionaryDefs;
14
12
  function refreshDictionaryCache(maxAge) {
15
13
  return (0, DictionaryLoader_1.refreshCacheEntries)(maxAge);
16
14
  }
17
15
  exports.refreshDictionaryCache = refreshDictionaryCache;
18
16
  function getDictionary(settings) {
19
- const { words = [], userWords = [], dictionaries = [], dictionaryDefinitions = [], noSuggestDictionaries = [], flagWords = [], ignoreWords = [], } = settings;
20
- const colNoSug = (0, DictionaryReferenceCollection_1.createDictionaryReferenceCollection)(noSuggestDictionaries);
21
- const colDicts = (0, DictionaryReferenceCollection_1.createDictionaryReferenceCollection)(dictionaries.concat(colNoSug.enabled()));
22
- const modDefs = dictionaryDefinitions.map((def) => {
23
- const enabled = colNoSug.isEnabled(def.name);
24
- if (enabled === undefined)
25
- return def;
26
- return { ...def, noSuggest: enabled };
27
- });
28
- const spellDictionaries = loadDictionaries(colDicts.enabled(), modDefs);
17
+ const { words = [], userWords = [], flagWords = [], ignoreWords = [] } = settings;
18
+ const spellDictionaries = loadDictionaryDefs((0, DictionarySettings_1.calcDictionaryDefsToLoad)(settings));
29
19
  const settingsDictionary = (0, createSpellingDictionary_1.createSpellingDictionary)(words.concat(userWords), '[words]', 'From Settings `words` and `userWords`', {
30
20
  caseSensitive: true,
31
21
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell-lib",
3
- "version": "5.13.3",
3
+ "version": "5.15.0",
4
4
  "description": "A library of useful functions used across various cspell tools.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -47,22 +47,22 @@
47
47
  },
48
48
  "homepage": "https://github.com/streetsidesoftware/cspell#readme",
49
49
  "dependencies": {
50
- "@cspell/cspell-bundled-dicts": "^5.13.3",
51
- "@cspell/cspell-types": "^5.13.3",
50
+ "@cspell/cspell-bundled-dicts": "^5.15.0",
51
+ "@cspell/cspell-types": "^5.15.0",
52
52
  "clear-module": "^4.1.2",
53
53
  "comment-json": "^4.1.1",
54
54
  "configstore": "^5.0.1",
55
55
  "cosmiconfig": "^7.0.1",
56
- "cspell-glob": "^5.13.3",
57
- "cspell-io": "^5.13.3",
58
- "cspell-trie-lib": "^5.13.3",
56
+ "cspell-glob": "^5.15.0",
57
+ "cspell-io": "^5.15.0",
58
+ "cspell-trie-lib": "^5.15.0",
59
59
  "find-up": "^5.0.0",
60
60
  "fs-extra": "^10.0.0",
61
61
  "gensequence": "^3.1.1",
62
62
  "import-fresh": "^3.3.0",
63
63
  "resolve-from": "^5.0.0",
64
64
  "resolve-global": "^1.0.0",
65
- "vscode-uri": "^3.0.2"
65
+ "vscode-uri": "^3.0.3"
66
66
  },
67
67
  "engines": {
68
68
  "node": ">=12.13.0"
@@ -78,13 +78,13 @@
78
78
  "@cspell/dict-python": "^2.0.5",
79
79
  "@types/configstore": "^5.0.1",
80
80
  "@types/fs-extra": "^9.0.13",
81
- "@types/jest": "^27.0.3",
82
- "@types/node": "^16.11.10",
81
+ "@types/jest": "^27.4.0",
82
+ "@types/node": "^17.0.8",
83
83
  "cspell-dict-nl-nl": "^1.1.2",
84
- "jest": "^27.4.0",
84
+ "jest": "^27.4.6",
85
85
  "lorem-ipsum": "^2.0.4",
86
86
  "rimraf": "^3.0.2",
87
- "ts-jest": "^27.0.7"
87
+ "ts-jest": "^27.1.2"
88
88
  },
89
- "gitHead": "f49cb2d98eed1f7274b1e6ad1ef076e7140347b5"
89
+ "gitHead": "04d61378054cbecd28df100ca704c7322abab8ba"
90
90
  }