cspell-lib 9.6.3 → 9.6.4

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,10 +1,18 @@
1
1
  import type { DictionaryId, DictionaryReference } from '@cspell/cspell-types';
2
+ /**
3
+ * A collection of dictionary references to determine if a dictionary is enabled or blocked.
4
+ */
2
5
  export interface DictionaryReferenceCollection {
3
6
  isEnabled(name: DictionaryId): boolean | undefined;
4
7
  isBlocked(name: DictionaryId): boolean | undefined;
5
8
  enabled(): DictionaryId[];
6
9
  blocked(): DictionaryId[];
7
- dictionaryIds: DictionaryId[];
10
+ readonly dictionaryIds: DictionaryId[];
8
11
  }
12
+ /**
13
+ * Create a collection of dictionary references to be able to easily determine if a dictionary is enabled or blocked.
14
+ * @param dictionaries - list of dictionary references
15
+ * @returns DictionaryReferenceCollection
16
+ */
9
17
  export declare function createDictionaryReferenceCollection(dictionaries: DictionaryReference[]): DictionaryReferenceCollection;
10
18
  //# sourceMappingURL=DictionaryReferenceCollection.d.ts.map
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Create a collection of dictionary references to be able to easily determine if a dictionary is enabled or blocked.
3
+ * @param dictionaries - list of dictionary references
4
+ * @returns DictionaryReferenceCollection
5
+ */
1
6
  export function createDictionaryReferenceCollection(dictionaries) {
2
7
  return new _DictionaryReferenceCollection(dictionaries);
3
8
  }
@@ -7,6 +7,8 @@ export { ImportError } from './Controller/ImportError.js';
7
7
  export type { ConfigurationDependencies, ImportFileRefWithError } from './CSpellSettingsServer.js';
8
8
  export { extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, toCSpellSettingsWithOutSourceTrace, } from './CSpellSettingsServer.js';
9
9
  export { defaultSettingsLoader, getDefaultBundledSettingsAsync, getDefaultSettings } from './DefaultSettings.js';
10
+ export type { DictionaryReferenceCollection } from './DictionaryReferenceCollection.js';
11
+ export { createDictionaryReferenceCollection } from './DictionaryReferenceCollection.js';
10
12
  export type { CSpellSettingsInternal, CSpellSettingsInternalFinalized, DictionaryDefinitionInlineInternal, DictionaryDefinitionInternal, DictionaryDefinitionSimpleInternal, DictionaryFileDefinitionInternal, } from './internal/index.js';
11
13
  export { calcDictionaryDefsToLoad, createCSpellSettingsInternal, filterDictDefsToLoad, isDictionaryDefinitionInlineInternal, isDictionaryFileDefinitionInternal, mapDictDefToInternal, } from './internal/index.js';
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -5,5 +5,6 @@ export { clearCachedSettingsFiles, createConfigLoader, defaultConfigFilenames, d
5
5
  export { ImportError } from './Controller/ImportError.js';
6
6
  export { extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, toCSpellSettingsWithOutSourceTrace, } from './CSpellSettingsServer.js';
7
7
  export { defaultSettingsLoader, getDefaultBundledSettingsAsync, getDefaultSettings } from './DefaultSettings.js';
8
+ export { createDictionaryReferenceCollection } from './DictionaryReferenceCollection.js';
8
9
  export { calcDictionaryDefsToLoad, createCSpellSettingsInternal, filterDictDefsToLoad, isDictionaryDefinitionInlineInternal, isDictionaryFileDefinitionInternal, mapDictDefToInternal, } from './internal/index.js';
9
10
  //# sourceMappingURL=index.js.map
@@ -12,9 +12,8 @@ export type { CreateTextDocumentParams, TextDocument, TextDocumentLine, TextDocu
12
12
  export { createTextDocument, updateTextDocument } from './Models/TextDocument.js';
13
13
  export type { PerfTimer } from './perf/index.js';
14
14
  export { createPerfTimer } from './perf/index.js';
15
- export type { ConfigurationDependencies, CSpellConfigFile, ICSpellConfigFile, ImportFileRefWithError, } from './Settings/index.js';
16
- export { calcOverrideSettings, checkFilenameMatchesGlob, createConfigLoader, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, finalizeSettings, getCachedFileSize, getDefaultBundledSettingsAsync, getDefaultConfigLoader, getDefaultSettings, getGlobalSettings, getGlobalSettingsAsync, getSources, ImportError, loadConfig, loadPnP, mergeInDocSettings, mergeSettings, readConfigFile, readRawSettings, readSettings, readSettingsFiles, resolveConfigFileImports, searchForConfig, sectionCSpell, toCSpellSettingsWithOutSourceTrace, } from './Settings/index.js';
17
- export { defaultFileName as defaultSettingsFilename } from './Settings/index.js';
15
+ export type { ConfigurationDependencies, CSpellConfigFile, DictionaryReferenceCollection, ICSpellConfigFile, ImportFileRefWithError, } from './Settings/index.js';
16
+ export { calcOverrideSettings, checkFilenameMatchesGlob, createConfigLoader, createDictionaryReferenceCollection, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, defaultFileName as defaultSettingsFilename, ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, finalizeSettings, getCachedFileSize, getDefaultBundledSettingsAsync, getDefaultConfigLoader, getDefaultSettings, getGlobalSettings, getGlobalSettingsAsync, getSources, ImportError, loadConfig, loadPnP, mergeInDocSettings, mergeSettings, readConfigFile, readRawSettings, readSettings, readSettingsFiles, resolveConfigFileImports, searchForConfig, sectionCSpell, toCSpellSettingsWithOutSourceTrace, } from './Settings/index.js';
18
17
  export * as Link from './Settings/index.link.js';
19
18
  export { combineTextAndLanguageSettings, combineTextAndLanguageSettings as constructSettingsForText, } from './Settings/TextDocumentSettings.js';
20
19
  export { determineFinalDocumentSettings, type DetermineFinalDocumentSettingsResult, spellCheckDocument, spellCheckDocumentRPC, spellCheckFile, type SpellCheckFileOptions, type SpellCheckFilePerf, type SpellCheckFileResult, } from './spellCheckFile.js';
package/dist/lib/index.js CHANGED
@@ -7,8 +7,7 @@ export { getLanguagesForBasename as getLanguageIdsForBaseFilename, getLanguagesF
7
7
  export { getDictionary } from './getDictionary.js';
8
8
  export { createTextDocument, updateTextDocument } from './Models/TextDocument.js';
9
9
  export { createPerfTimer } from './perf/index.js';
10
- export { calcOverrideSettings, checkFilenameMatchesGlob, createConfigLoader, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, finalizeSettings, getCachedFileSize, getDefaultBundledSettingsAsync, getDefaultConfigLoader, getDefaultSettings, getGlobalSettings, getGlobalSettingsAsync, getSources, ImportError, loadConfig, loadPnP, mergeInDocSettings, mergeSettings, readConfigFile, readRawSettings, readSettings, readSettingsFiles, resolveConfigFileImports, searchForConfig, sectionCSpell, toCSpellSettingsWithOutSourceTrace, } from './Settings/index.js';
11
- export { defaultFileName as defaultSettingsFilename } from './Settings/index.js';
10
+ export { calcOverrideSettings, checkFilenameMatchesGlob, createConfigLoader, createDictionaryReferenceCollection, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, defaultFileName as defaultSettingsFilename, ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, finalizeSettings, getCachedFileSize, getDefaultBundledSettingsAsync, getDefaultConfigLoader, getDefaultSettings, getGlobalSettings, getGlobalSettingsAsync, getSources, ImportError, loadConfig, loadPnP, mergeInDocSettings, mergeSettings, readConfigFile, readRawSettings, readSettings, readSettingsFiles, resolveConfigFileImports, searchForConfig, sectionCSpell, toCSpellSettingsWithOutSourceTrace, } from './Settings/index.js';
12
11
  export * as Link from './Settings/index.link.js';
13
12
  export { combineTextAndLanguageSettings, combineTextAndLanguageSettings as constructSettingsForText, } from './Settings/TextDocumentSettings.js';
14
13
  export { determineFinalDocumentSettings, spellCheckDocument, spellCheckDocumentRPC, spellCheckFile, } from './spellCheckFile.js';
@@ -5,6 +5,8 @@ import type { DictionaryTraceResult, WordSplits } from './textValidation/traceWo
5
5
  export interface TraceResult extends DictionaryTraceResult {
6
6
  /** True if the dictionary is currently active. */
7
7
  dictActive: boolean;
8
+ /** True if the dictionary is blocked from use. */
9
+ dictBlocked: boolean;
8
10
  }
9
11
  export interface TraceOptions {
10
12
  languageId?: LanguageId | LanguageId[];
package/dist/lib/trace.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { satisfiesCSpellConfigFile } from 'cspell-config-lib';
2
2
  import { genSequence } from 'gensequence';
3
3
  import { toInternalSettings } from './Settings/CSpellSettingsServer.js';
4
- import { finalizeSettings, mergeSettings, resolveConfigFileImports } from './Settings/index.js';
4
+ import { createDictionaryReferenceCollection, finalizeSettings, mergeSettings, resolveConfigFileImports, } from './Settings/index.js';
5
5
  import { calcSettingsForLanguageId } from './Settings/LanguageSettings.js';
6
6
  import { getDictionaryInternal, refreshDictionaryCache } from './SpellingDictionary/index.js';
7
7
  import { traceWord } from './textValidation/traceWord.js';
@@ -26,28 +26,33 @@ export async function* traceWordsAsync(words, settingsOrConfig, options) {
26
26
  }));
27
27
  const withLanguageId = calcSettingsForLanguageId(withLocale, languageId ?? withLocale.languageId ?? 'plaintext');
28
28
  const settings = finalizeSettings(withLanguageId);
29
- const dictionaries = [
29
+ const rawDictionaryRefs = [
30
30
  ...(settings.dictionaries || []),
31
31
  ...(settings.dictionaryDefinitions || []).map((d) => d.name),
32
- ].filter(util.uniqueFn);
32
+ ];
33
+ const dictionaryReferenceCollection = createDictionaryReferenceCollection(rawDictionaryRefs);
34
+ const dictionaries = [...dictionaryReferenceCollection.enabled(), ...dictionaryReferenceCollection.blocked()];
33
35
  const dictSettings = toInternalSettings({ ...settings, dictionaries });
34
36
  const dictBase = await getDictionaryInternal(settings);
35
37
  const dicts = await getDictionaryInternal(dictSettings);
36
38
  const activeDictionaries = dictBase.dictionaries.map((d) => d.name);
37
39
  return {
38
40
  activeDictionaries,
41
+ dictionaryReferenceCollection,
39
42
  config: settings,
40
43
  dicts,
41
44
  };
42
45
  }
43
46
  await refreshDictionaryCache();
44
- const { config, dicts, activeDictionaries } = await finalize(settings);
47
+ const { activeDictionaries, config, dicts, dictionaryReferenceCollection } = await finalize(settings);
45
48
  const setOfActiveDicts = new Set(activeDictionaries);
49
+ const setOfExcludedDicts = new Set(dictionaryReferenceCollection.blocked());
46
50
  function processWord(word) {
47
51
  const results = traceWord(word, dicts, { ...config, ignoreCase, compoundSeparator });
48
52
  const r = results.map((r) => ({
49
53
  ...r,
50
54
  dictActive: setOfActiveDicts.has(r.dictName),
55
+ dictBlocked: setOfExcludedDicts.has(r.dictName),
51
56
  dictSource: toFilePathOrHref(r.dictSource),
52
57
  configSource: r.configSource || config.name || '',
53
58
  splits: results.splits,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "provenance": true
6
6
  },
7
- "version": "9.6.3",
7
+ "version": "9.6.4",
8
8
  "description": "A library of useful functions used across various cspell tools.",
9
9
  "type": "module",
10
10
  "sideEffects": false,
@@ -76,23 +76,23 @@
76
76
  },
77
77
  "homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-lib#readme",
78
78
  "dependencies": {
79
- "@cspell/cspell-bundled-dicts": "9.6.3",
80
- "@cspell/cspell-performance-monitor": "9.6.3",
81
- "@cspell/cspell-pipe": "9.6.3",
82
- "@cspell/cspell-resolver": "9.6.3",
83
- "@cspell/cspell-types": "9.6.3",
84
- "@cspell/dynamic-import": "9.6.3",
85
- "@cspell/filetypes": "9.6.3",
86
- "@cspell/rpc": "9.6.3",
87
- "@cspell/strong-weak-map": "9.6.3",
88
- "@cspell/url": "9.6.3",
79
+ "@cspell/cspell-bundled-dicts": "9.6.4",
80
+ "@cspell/cspell-performance-monitor": "9.6.4",
81
+ "@cspell/cspell-pipe": "9.6.4",
82
+ "@cspell/cspell-resolver": "9.6.4",
83
+ "@cspell/cspell-types": "9.6.4",
84
+ "@cspell/dynamic-import": "9.6.4",
85
+ "@cspell/filetypes": "9.6.4",
86
+ "@cspell/rpc": "9.6.4",
87
+ "@cspell/strong-weak-map": "9.6.4",
88
+ "@cspell/url": "9.6.4",
89
89
  "clear-module": "^4.1.2",
90
- "cspell-config-lib": "9.6.3",
91
- "cspell-dictionary": "9.6.3",
92
- "cspell-glob": "9.6.3",
93
- "cspell-grammar": "9.6.3",
94
- "cspell-io": "9.6.3",
95
- "cspell-trie-lib": "9.6.3",
90
+ "cspell-config-lib": "9.6.4",
91
+ "cspell-dictionary": "9.6.4",
92
+ "cspell-glob": "9.6.4",
93
+ "cspell-grammar": "9.6.4",
94
+ "cspell-io": "9.6.4",
95
+ "cspell-trie-lib": "9.6.4",
96
96
  "env-paths": "^4.0.0",
97
97
  "gensequence": "^8.0.8",
98
98
  "import-fresh": "^3.3.1",
@@ -105,7 +105,7 @@
105
105
  "node": ">=20"
106
106
  },
107
107
  "devDependencies": {
108
- "@cspell/cspell-tools": "9.6.3",
108
+ "@cspell/cspell-tools": "9.6.4",
109
109
  "@cspell/dict-cpp": "^7.0.2",
110
110
  "@cspell/dict-csharp": "^4.0.8",
111
111
  "@cspell/dict-css": "^4.0.19",
@@ -123,5 +123,5 @@
123
123
  "lorem-ipsum": "^2.0.8",
124
124
  "perf-insight": "^2.0.1"
125
125
  },
126
- "gitHead": "500b996b6c0a6ff025c42ef98db44776f43a9e72"
126
+ "gitHead": "e126c7f5708d4258ada35ba1d29d18952d7f0886"
127
127
  }