cspell-lib 6.22.0 → 6.23.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.
@@ -8,6 +8,7 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.getLanguagesForBasename = exports.getLanguagesForExt = exports.buildLanguageExtensionMapSet = exports.isGenerated = exports.isGeneratedFile = exports.isGeneratedExt = exports.isBinary = exports.isBinaryFile = exports.isBinaryExt = exports.languageIds = exports.generatedFiles = exports.binaryLanguages = exports.languageExtensionDefinitions = void 0;
11
+ const AutoResolve_1 = require("./util/AutoResolve");
11
12
  exports.languageExtensionDefinitions = [
12
13
  { id: 'ada', extensions: ['.adb', '.ads'] },
13
14
  { id: 'apiblueprint', extensions: ['.apib', '.apiblueprint'] },
@@ -276,16 +277,8 @@ function doesSetContainAnyOf(setOfIds, languageId) {
276
277
  }
277
278
  function buildLanguageExtensionMapSet(defs) {
278
279
  return defs.reduce((map, def) => {
279
- function getMapSet(value) {
280
- const found = map.get(value);
281
- if (found)
282
- return found;
283
- const s = new Set();
284
- map.set(value, s);
285
- return s;
286
- }
287
280
  function addId(value) {
288
- getMapSet(value).add(def.id);
281
+ (0, AutoResolve_1.autoResolve)(map, value, () => new Set()).add(def.id);
289
282
  }
290
283
  def.extensions.forEach(addId);
291
284
  def.filenames?.forEach(addId);
@@ -1,4 +1,4 @@
1
- import type { AdvancedCSpellSettingsWithSourceTrace, CSpellSettingsWithSourceTrace, DictionaryDefinitionAugmented, DictionaryDefinitionCustom, DictionaryDefinitionPreferred, Parser } from '@cspell/cspell-types';
1
+ import type { AdvancedCSpellSettingsWithSourceTrace, CSpellSettingsWithSourceTrace, DictionaryDefinition, DictionaryDefinitionAugmented, DictionaryDefinitionCustom, DictionaryDefinitionInline, DictionaryDefinitionPreferred, Parser } from '@cspell/cspell-types';
2
2
  import type { WeightMap } from 'cspell-trie-lib';
3
3
  import type { OptionalOrUndefined } from '../util/types';
4
4
  export declare const SymbolCSpellSettingsInternal: unique symbol;
@@ -13,7 +13,12 @@ export interface CSpellSettingsInternalFinalized extends CSpellSettingsInternal
13
13
  includeRegExpList: RegExp[];
14
14
  }
15
15
  type DictionaryDefinitionCustomUniqueFields = Omit<DictionaryDefinitionCustom, keyof DictionaryDefinitionPreferred>;
16
- export interface DictionaryDefinitionInternal extends Readonly<DictionaryDefinitionPreferred>, Readonly<Partial<DictionaryDefinitionCustomUniqueFields>>, Readonly<DictionaryDefinitionAugmented> {
16
+ export type DictionaryDefinitionInternal = DictionaryFileDefinitionInternal | DictionaryDefinitionInlineInternal;
17
+ export type DictionaryDefinitionInlineInternal = DictionaryDefinitionInline & {
18
+ /** The path to the config file that contains this dictionary definition */
19
+ readonly __source?: string | undefined;
20
+ };
21
+ export interface DictionaryFileDefinitionInternal extends Readonly<DictionaryDefinitionPreferred>, Readonly<Partial<DictionaryDefinitionCustomUniqueFields>>, Readonly<DictionaryDefinitionAugmented> {
17
22
  /**
18
23
  * Optional weight map used to improve suggestions.
19
24
  */
@@ -21,10 +26,14 @@ export interface DictionaryDefinitionInternal extends Readonly<DictionaryDefinit
21
26
  /** The path to the config file that contains this dictionary definition */
22
27
  readonly __source?: string | undefined;
23
28
  }
24
- export interface DictionaryDefinitionInternalWithSource extends DictionaryDefinitionInternal {
29
+ export interface DictionaryFileDefinitionInternalWithSource extends DictionaryFileDefinitionInternal {
25
30
  readonly __source: string;
26
31
  }
32
+ export type DictionaryDefinitionInternalWithSource = DictionaryDefinitionInternal & {
33
+ readonly __source: string;
34
+ };
27
35
  export declare function createCSpellSettingsInternal(parts?: OptionalOrUndefined<Partial<CSpellSettingsInternal>>): CSpellSettingsInternal;
28
36
  export declare function isCSpellSettingsInternal(cs: CSpellSettingsInternal | CSpellSettingsWithSourceTrace | OptionalOrUndefined<CSpellSettingsInternal | CSpellSettingsWithSourceTrace>): cs is CSpellSettingsInternal;
37
+ export declare function isDictionaryDefinitionInlineInternal(def: DictionaryDefinitionInternal | DictionaryDefinitionInline | DictionaryDefinition): def is DictionaryDefinitionInlineInternal;
29
38
  export {};
30
39
  //# sourceMappingURL=CSpellSettingsInternalDef.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCSpellSettingsInternal = exports.createCSpellSettingsInternal = exports.SymbolCSpellSettingsInternal = void 0;
3
+ exports.isDictionaryDefinitionInlineInternal = exports.isCSpellSettingsInternal = exports.createCSpellSettingsInternal = exports.SymbolCSpellSettingsInternal = void 0;
4
4
  const util_1 = require("../util/util");
5
5
  exports.SymbolCSpellSettingsInternal = Symbol('CSpellSettingsInternal');
6
6
  function createCSpellSettingsInternal(parts = {}) {
@@ -14,4 +14,11 @@ function isCSpellSettingsInternal(cs) {
14
14
  return !!cs[exports.SymbolCSpellSettingsInternal];
15
15
  }
16
16
  exports.isCSpellSettingsInternal = isCSpellSettingsInternal;
17
+ function isDictionaryDefinitionInlineInternal(def) {
18
+ if (def.path)
19
+ return false;
20
+ const defInline = def;
21
+ return !!(defInline.words || defInline.flagWords || defInline.ignoreWords);
22
+ }
23
+ exports.isDictionaryDefinitionInlineInternal = isDictionaryDefinitionInlineInternal;
17
24
  //# sourceMappingURL=CSpellSettingsInternalDef.js.map
@@ -31,6 +31,7 @@ const assert_1 = __importDefault(require("assert"));
31
31
  const cspell_glob_1 = require("cspell-glob");
32
32
  const path = __importStar(require("path"));
33
33
  const CSpellSettingsInternalDef_1 = require("../Models/CSpellSettingsInternalDef");
34
+ const AutoResolve_1 = require("../util/AutoResolve");
34
35
  const util = __importStar(require("../util/util"));
35
36
  const constants_1 = require("./constants");
36
37
  const DictionarySettings_1 = require("./DictionarySettings");
@@ -310,7 +311,9 @@ function mergeImportRefs(left, right = {}) {
310
311
  function extractDependencies(settings) {
311
312
  const settingsI = toInternalSettings(settings);
312
313
  const configFiles = [...(mergeImportRefs(settingsI) || [])].map(([filename]) => filename);
313
- const dictionaryFiles = (0, DictionarySettings_1.calcDictionaryDefsToLoad)(settingsI).map((dict) => dict.path);
314
+ const dictionaryFiles = (0, DictionarySettings_1.calcDictionaryDefsToLoad)(settingsI)
315
+ .map((dict) => dict.path)
316
+ .filter(util.isDefined);
314
317
  return {
315
318
  configFiles,
316
319
  dictionaryFiles,
@@ -334,26 +337,24 @@ function resolveParser(settings) {
334
337
  (0, assert_1.default)(parser, `Parser "${parserName}" not found.`);
335
338
  return parser;
336
339
  }
337
- const parserCache = new WeakMap();
340
+ const parserCache = new AutoResolve_1.AutoResolveWeakCache();
338
341
  const emptyParserMap = new Map();
342
+ function* parsers(plugins) {
343
+ for (const plugin of plugins) {
344
+ if (!plugin.parsers)
345
+ continue;
346
+ for (const parser of plugin.parsers) {
347
+ yield [parser.name, parser];
348
+ }
349
+ }
350
+ }
351
+ function mapPlugins(plugins) {
352
+ return new Map(parsers(plugins));
353
+ }
339
354
  function extractParsers(plugins) {
340
355
  if (!plugins || !plugins.length)
341
356
  return emptyParserMap;
342
- const found = parserCache.get(plugins);
343
- if (found)
344
- return found;
345
- function* parsers(plugins) {
346
- for (const plugin of plugins) {
347
- if (!plugin.parsers)
348
- continue;
349
- for (const parser of plugin.parsers) {
350
- yield [parser.name, parser];
351
- }
352
- }
353
- }
354
- const map = new Map(parsers(plugins));
355
- parserCache.set(plugins, map);
356
- return map;
357
+ return parserCache.get(plugins, mapPlugins);
357
358
  }
358
359
  exports.__testing__ = {
359
360
  mergeObjects,
@@ -16,9 +16,6 @@ export declare function normalizeDictionaryDefs(settings: NormalizeDictionaryDef
16
16
  name?: string;
17
17
  description?: string;
18
18
  enabled?: boolean;
19
- words?: string[];
20
- flagWords?: string[];
21
- ignoreWords?: string[];
22
19
  allowCompoundWords?: boolean;
23
20
  caseSensitive?: boolean;
24
21
  dictionaries?: string[];
@@ -26,6 +23,9 @@ export declare function normalizeDictionaryDefs(settings: NormalizeDictionaryDef
26
23
  ignoreRegExpList?: import("@cspell/cspell-types").RegExpPatternList;
27
24
  includeRegExpList?: import("@cspell/cspell-types").RegExpPatternList;
28
25
  patterns?: import("@cspell/cspell-types").RegExpPatternDefinition[];
26
+ words?: string[];
27
+ flagWords?: string[];
28
+ ignoreWords?: string[];
29
29
  parser?: string;
30
30
  }>[] | undefined;
31
31
  }>;
@@ -1,5 +1,5 @@
1
1
  import type { DictionaryDefinition } from '@cspell/cspell-types';
2
- import type { CSpellSettingsInternal, DictionaryDefinitionInternal, DictionaryDefinitionInternalWithSource } from '../Models/CSpellSettingsInternalDef';
2
+ import type { CSpellSettingsInternal, DictionaryDefinitionInternal, DictionaryDefinitionInternalWithSource, DictionaryFileDefinitionInternalWithSource } from '../Models/CSpellSettingsInternalDef';
3
3
  import type { DictionaryReferenceCollection } from './DictionaryReferenceCollection';
4
4
  export type DefMapArrayItem = [string, DictionaryDefinitionInternal];
5
5
  /**
@@ -19,7 +19,9 @@ export declare function mapDictDefsToInternal(defs: undefined, pathToSettingsFil
19
19
  export declare function mapDictDefsToInternal(defs: DictionaryDefinition[], pathToSettingsFile: string): DictionaryDefinitionInternalWithSource[];
20
20
  export declare function mapDictDefsToInternal(defs: DictionaryDefinition[] | undefined, pathToSettingsFile: string): DictionaryDefinitionInternalWithSource[] | undefined;
21
21
  export declare function mapDictDefToInternal(def: DictionaryDefinition, pathToSettingsFile: string): DictionaryDefinitionInternalWithSource;
22
- export declare function isDictionaryDefinitionWithSource(d: DictionaryDefinition | DictionaryDefinitionInternalWithSource): d is DictionaryDefinitionInternalWithSource;
23
22
  export declare function calcDictionaryDefsToLoad(settings: CSpellSettingsInternal): DictionaryDefinitionInternal[];
23
+ export declare function isDictionaryDefinitionWithSource(d: DictionaryDefinition | DictionaryDefinitionInternalWithSource): d is DictionaryDefinitionInternalWithSource;
24
24
  export declare function isDictionaryDefinitionInternal(def: DictionaryDefinition | DictionaryDefinitionInternal): def is DictionaryDefinitionInternal;
25
+ export declare function isDictionaryFileDefinitionInternalWithSource(def: DictionaryDefinition | DictionaryDefinitionInternal): def is DictionaryFileDefinitionInternalWithSource;
26
+ export declare function isDictionaryDefinitionInlineInternalWithSource(def: DictionaryDefinition | DictionaryDefinitionInternal): def is DictionaryDefinitionInternalWithSource;
25
27
  //# sourceMappingURL=DictionarySettings.d.ts.map
@@ -23,9 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.isDictionaryDefinitionInternal = exports.calcDictionaryDefsToLoad = exports.isDictionaryDefinitionWithSource = exports.mapDictDefToInternal = exports.mapDictDefsToInternal = exports.filterDictDefsToLoad = void 0;
26
+ exports.isDictionaryDefinitionInlineInternalWithSource = exports.isDictionaryFileDefinitionInternalWithSource = exports.isDictionaryDefinitionInternal = exports.isDictionaryDefinitionWithSource = exports.calcDictionaryDefsToLoad = exports.mapDictDefToInternal = exports.mapDictDefsToInternal = exports.filterDictDefsToLoad = void 0;
27
27
  const cspell_trie_lib_1 = require("cspell-trie-lib");
28
28
  const path = __importStar(require("path"));
29
+ const CSpellSettingsInternalDef_1 = require("../Models/CSpellSettingsInternalDef");
30
+ const AutoResolve_1 = require("../util/AutoResolve");
29
31
  const resolveFile_1 = require("../util/resolveFile");
30
32
  const util_1 = require("../util/util");
31
33
  const DictionaryReferenceCollection_1 = require("./DictionaryReferenceCollection");
@@ -65,17 +67,20 @@ function mapDictDefsToInternal(defs, pathToSettingsFile) {
65
67
  return defs?.map((def) => mapDictDefToInternal(def, pathToSettingsFile));
66
68
  }
67
69
  exports.mapDictDefsToInternal = mapDictDefsToInternal;
70
+ const internalDefs = new AutoResolve_1.AutoResolveWeakCache();
68
71
  function mapDictDefToInternal(def, pathToSettingsFile) {
72
+ return internalDefs.get(def, (def) => _mapDictDefToInternal(def, pathToSettingsFile));
73
+ }
74
+ exports.mapDictDefToInternal = mapDictDefToInternal;
75
+ function _mapDictDefToInternal(def, pathToSettingsFile) {
69
76
  if (isDictionaryDefinitionWithSource(def)) {
70
77
  return def;
71
78
  }
79
+ if ((0, CSpellSettingsInternalDef_1.isDictionaryDefinitionInlineInternal)(def)) {
80
+ return { ...def, __source: pathToSettingsFile };
81
+ }
72
82
  return new _DictionaryDefinitionInternalWithSource(def, pathToSettingsFile);
73
83
  }
74
- exports.mapDictDefToInternal = mapDictDefToInternal;
75
- function isDictionaryDefinitionWithSource(d) {
76
- return d instanceof _DictionaryDefinitionInternalWithSource;
77
- }
78
- exports.isDictionaryDefinitionWithSource = isDictionaryDefinitionWithSource;
79
84
  function determineName(filename, options) {
80
85
  return options.name || path.basename(filename);
81
86
  }
@@ -92,10 +97,22 @@ function calcDictionaryDefsToLoad(settings) {
92
97
  return filterDictDefsToLoad(colDicts, modDefs);
93
98
  }
94
99
  exports.calcDictionaryDefsToLoad = calcDictionaryDefsToLoad;
100
+ function isDictionaryDefinitionWithSource(d) {
101
+ return isDictionaryFileDefinitionInternalWithSource(d) || isDictionaryDefinitionInlineInternalWithSource(d);
102
+ }
103
+ exports.isDictionaryDefinitionWithSource = isDictionaryDefinitionWithSource;
95
104
  function isDictionaryDefinitionInternal(def) {
96
105
  return def instanceof _DictionaryDefinitionInternalWithSource;
97
106
  }
98
107
  exports.isDictionaryDefinitionInternal = isDictionaryDefinitionInternal;
108
+ function isDictionaryFileDefinitionInternalWithSource(def) {
109
+ return def instanceof _DictionaryDefinitionInternalWithSource;
110
+ }
111
+ exports.isDictionaryFileDefinitionInternalWithSource = isDictionaryFileDefinitionInternalWithSource;
112
+ function isDictionaryDefinitionInlineInternalWithSource(def) {
113
+ return (0, CSpellSettingsInternalDef_1.isDictionaryDefinitionInlineInternal)(def) && !!def.__source;
114
+ }
115
+ exports.isDictionaryDefinitionInlineInternalWithSource = isDictionaryDefinitionInlineInternalWithSource;
99
116
  class _DictionaryDefinitionInternalWithSource {
100
117
  constructor(def, __source) {
101
118
  this.__source = __source;
@@ -87,7 +87,7 @@ const allDirectives = new Set(preferredDirectives.concat(officialDirectives));
87
87
  const allDirectiveSuggestions = [
88
88
  ...(0, sync_1.pipeSync)(allDirectives, (0, sync_1.opMap)((word) => ({ word }))),
89
89
  ];
90
- const dictInDocSettings = (0, SpellingDictionary_1.getSpellDictInterface)().createSpellingDictionary(allDirectives, 'Directives', 'Directive List', {
90
+ const dictInDocSettings = (0, SpellingDictionary_1.createSpellingDictionary)(allDirectives, 'Directives', 'Directive List', {
91
91
  supportNonStrictSearches: false,
92
92
  });
93
93
  const EmptyWords = [];
@@ -5,6 +5,7 @@ export type LoadOptions = DictionaryDefinitionInternal;
5
5
  export declare class DictionaryLoader {
6
6
  private cspellIO;
7
7
  private dictionaryCache;
8
+ private inlineDictionaryCache;
8
9
  private dictionaryCacheByDef;
9
10
  private reader;
10
11
  private readerSync;
@@ -26,5 +27,6 @@ export declare class DictionaryLoader {
26
27
  private getStatSync;
27
28
  private isEqual;
28
29
  private normalizeOptions;
30
+ private loadInlineDict;
29
31
  }
30
32
  //# sourceMappingURL=DictionaryLoader.d.ts.map
@@ -4,6 +4,8 @@ exports.DictionaryLoader = void 0;
4
4
  const sync_1 = require("@cspell/cspell-pipe/sync");
5
5
  const strong_weak_map_1 = require("@cspell/strong-weak-map");
6
6
  const cspell_dictionary_1 = require("cspell-dictionary");
7
+ const CSpellSettingsInternalDef_1 = require("../../Models/CSpellSettingsInternalDef");
8
+ const AutoResolve_1 = require("../../util/AutoResolve");
7
9
  const errors_1 = require("../../util/errors");
8
10
  const SpellingDictionaryError_1 = require("../SpellingDictionaryError");
9
11
  const MAX_AGE = 10000;
@@ -30,11 +32,15 @@ class DictionaryLoader {
30
32
  constructor(cspellIO) {
31
33
  this.cspellIO = cspellIO;
32
34
  this.dictionaryCache = new strong_weak_map_1.StrongWeakMap();
35
+ this.inlineDictionaryCache = new AutoResolve_1.AutoResolveWeakCache();
33
36
  this.dictionaryCacheByDef = new strong_weak_map_1.StrongWeakMap();
34
37
  this.reader = toReader(cspellIO);
35
38
  this.readerSync = toReaderSync(cspellIO);
36
39
  }
37
40
  loadDictionary(def) {
41
+ if ((0, CSpellSettingsInternalDef_1.isDictionaryDefinitionInlineInternal)(def)) {
42
+ return Promise.resolve(this.loadInlineDict(def));
43
+ }
38
44
  const { key, entry } = this.getCacheEntry(def);
39
45
  if (entry) {
40
46
  return entry.pending.then(([dictionary]) => dictionary);
@@ -44,6 +50,9 @@ class DictionaryLoader {
44
50
  return loadedEntry.pending.then(([dictionary]) => dictionary);
45
51
  }
46
52
  loadDictionarySync(def) {
53
+ if ((0, CSpellSettingsInternalDef_1.isDictionaryDefinitionInlineInternal)(def)) {
54
+ return this.loadInlineDict(def);
55
+ }
47
56
  const { key, entry } = this.getCacheEntry(def);
48
57
  if (entry?.dictionary && entry.loadingState === LoadingState.Loaded) {
49
58
  return entry.dictionary;
@@ -179,6 +188,9 @@ class DictionaryLoader {
179
188
  return options;
180
189
  return { ...options, name: this.cspellIO.uriBasename(uri) };
181
190
  }
191
+ loadInlineDict(def) {
192
+ return this.inlineDictionaryCache.get(def, (def) => (0, cspell_dictionary_1.createInlineSpellingDictionary)(def, def.__source || 'memory'));
193
+ }
182
194
  }
183
195
  exports.DictionaryLoader = DictionaryLoader;
184
196
  function toReader(cspellIO) {
@@ -1,15 +1,4 @@
1
- import * as cspellDictModule from 'cspell-dictionary';
2
- export { CompoundWordsMethod } from 'cspell-trie-lib';
3
- declare const SpellingDictionaryModule: {
4
- readonly createCollection: typeof cspellDictModule.createCollection;
5
- readonly createForbiddenWordsDictionary: typeof cspellDictModule.createFlagWordsDictionary;
6
- readonly createSpellingDictionary: typeof cspellDictModule.createSpellingDictionary;
7
- readonly createIgnoreWordsDictionary: typeof cspellDictModule.createIgnoreWordsDictionary;
8
- readonly createSpellingDictionaryFromTrieFile: typeof cspellDictModule.createSpellingDictionaryFromTrieFile;
9
- };
10
- type SpellDictInterface = typeof SpellingDictionaryModule;
11
1
  export type { FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from 'cspell-dictionary';
12
- export declare function getSpellDictInterface(): SpellDictInterface;
13
- export declare const createSpellingDictionary: typeof cspellDictModule.createSpellingDictionary;
14
- export declare const createCollection: typeof cspellDictModule.createCollection;
2
+ export { createCollection, createInlineSpellingDictionary, createSpellingDictionary } from 'cspell-dictionary';
3
+ export { CompoundWordsMethod } from 'cspell-trie-lib';
15
4
  //# sourceMappingURL=SpellingDictionary.d.ts.map
@@ -1,43 +1,10 @@
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
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.createCollection = exports.createSpellingDictionary = exports.getSpellDictInterface = exports.CompoundWordsMethod = void 0;
27
- const cspellDictModule = __importStar(require("cspell-dictionary"));
3
+ exports.CompoundWordsMethod = exports.createSpellingDictionary = exports.createInlineSpellingDictionary = exports.createCollection = void 0;
4
+ var cspell_dictionary_1 = require("cspell-dictionary");
5
+ Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return cspell_dictionary_1.createCollection; } });
6
+ Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return cspell_dictionary_1.createInlineSpellingDictionary; } });
7
+ Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return cspell_dictionary_1.createSpellingDictionary; } });
28
8
  var cspell_trie_lib_1 = require("cspell-trie-lib");
29
9
  Object.defineProperty(exports, "CompoundWordsMethod", { enumerable: true, get: function () { return cspell_trie_lib_1.CompoundWordsMethod; } });
30
- const SpellingDictionaryModule = {
31
- createCollection: cspellDictModule.createCollection,
32
- createForbiddenWordsDictionary: cspellDictModule.createForbiddenWordsDictionary,
33
- createSpellingDictionary: cspellDictModule.createSpellingDictionary,
34
- createIgnoreWordsDictionary: cspellDictModule.createIgnoreWordsDictionary,
35
- createSpellingDictionaryFromTrieFile: cspellDictModule.createSpellingDictionaryFromTrieFile,
36
- };
37
- function getSpellDictInterface() {
38
- return SpellingDictionaryModule;
39
- }
40
- exports.getSpellDictInterface = getSpellDictInterface;
41
- exports.createSpellingDictionary = getSpellDictInterface().createSpellingDictionary;
42
- exports.createCollection = getSpellDictInterface().createCollection;
43
10
  //# sourceMappingURL=SpellingDictionary.js.map
@@ -0,0 +1,21 @@
1
+ export declare function autoResolve<K, V>(map: Map<K, V>, key: K, resolve: (k: K) => V): V;
2
+ export declare class AutoResolveCache<K, V> {
3
+ readonly map: Map<K, V>;
4
+ get(k: K): V | undefined;
5
+ get(k: K, resolve: (k: K) => V): V;
6
+ get(k: K, resolve?: (k: K) => V): V | undefined;
7
+ has(k: K): boolean;
8
+ set(k: K, v: V): this;
9
+ }
10
+ export declare function createAutoResolveCache<K, V>(): AutoResolveCache<K, V>;
11
+ export declare function autoResolveWeak<K extends object, V>(map: WeakMap<K, V>, key: K, resolve: (k: K) => V): V;
12
+ export declare class AutoResolveWeakCache<K extends object, V> {
13
+ readonly map: WeakMap<K, V>;
14
+ get(k: K): V | undefined;
15
+ get(k: K, resolve: (k: K) => V): V;
16
+ get(k: K, resolve?: (k: K) => V): V | undefined;
17
+ has(k: K): boolean;
18
+ set(k: K, v: V): this;
19
+ }
20
+ export declare function createAutoResolveWeakCache<K extends object, V>(): AutoResolveWeakCache<K, V>;
21
+ //# sourceMappingURL=AutoResolve.d.ts.map
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAutoResolveWeakCache = exports.AutoResolveWeakCache = exports.autoResolveWeak = exports.createAutoResolveCache = exports.AutoResolveCache = exports.autoResolve = void 0;
4
+ function autoResolve(map, key, resolve) {
5
+ const found = map.get(key);
6
+ if (found !== undefined || map.has(key))
7
+ return found;
8
+ const value = resolve(key);
9
+ map.set(key, value);
10
+ return value;
11
+ }
12
+ exports.autoResolve = autoResolve;
13
+ class AutoResolveCache {
14
+ constructor() {
15
+ this.map = new Map();
16
+ }
17
+ get(k, resolve) {
18
+ return resolve ? autoResolve(this.map, k, resolve) : this.map.get(k);
19
+ }
20
+ has(k) {
21
+ return this.map.has(k);
22
+ }
23
+ set(k, v) {
24
+ this.map.set(k, v);
25
+ return this;
26
+ }
27
+ }
28
+ exports.AutoResolveCache = AutoResolveCache;
29
+ function createAutoResolveCache() {
30
+ return new AutoResolveCache();
31
+ }
32
+ exports.createAutoResolveCache = createAutoResolveCache;
33
+ function autoResolveWeak(map, key, resolve) {
34
+ const found = map.get(key);
35
+ if (found !== undefined || map.has(key))
36
+ return found;
37
+ const value = resolve(key);
38
+ map.set(key, value);
39
+ return value;
40
+ }
41
+ exports.autoResolveWeak = autoResolveWeak;
42
+ class AutoResolveWeakCache {
43
+ constructor() {
44
+ this.map = new WeakMap();
45
+ }
46
+ get(k, resolve) {
47
+ return resolve ? autoResolveWeak(this.map, k, resolve) : this.map.get(k);
48
+ }
49
+ has(k) {
50
+ return this.map.has(k);
51
+ }
52
+ set(k, v) {
53
+ this.map.set(k, v);
54
+ return this;
55
+ }
56
+ }
57
+ exports.AutoResolveWeakCache = AutoResolveWeakCache;
58
+ function createAutoResolveWeakCache() {
59
+ return new AutoResolveWeakCache();
60
+ }
61
+ exports.createAutoResolveWeakCache = createAutoResolveWeakCache;
62
+ //# sourceMappingURL=AutoResolve.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell-lib",
3
- "version": "6.22.0",
3
+ "version": "6.23.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",
@@ -48,19 +48,19 @@
48
48
  },
49
49
  "homepage": "https://github.com/streetsidesoftware/cspell#readme",
50
50
  "dependencies": {
51
- "@cspell/cspell-bundled-dicts": "6.22.0",
52
- "@cspell/cspell-pipe": "6.22.0",
53
- "@cspell/cspell-types": "6.22.0",
54
- "@cspell/strong-weak-map": "6.22.0",
51
+ "@cspell/cspell-bundled-dicts": "6.23.0",
52
+ "@cspell/cspell-pipe": "6.23.0",
53
+ "@cspell/cspell-types": "6.23.0",
54
+ "@cspell/strong-weak-map": "6.23.0",
55
55
  "clear-module": "^4.1.2",
56
56
  "comment-json": "^4.2.3",
57
57
  "configstore": "^5.0.1",
58
58
  "cosmiconfig": "^8.0.0",
59
- "cspell-dictionary": "6.22.0",
60
- "cspell-glob": "6.22.0",
61
- "cspell-grammar": "6.22.0",
62
- "cspell-io": "6.22.0",
63
- "cspell-trie-lib": "6.22.0",
59
+ "cspell-dictionary": "6.23.0",
60
+ "cspell-glob": "6.23.0",
61
+ "cspell-grammar": "6.23.0",
62
+ "cspell-io": "6.23.0",
63
+ "cspell-trie-lib": "6.23.0",
64
64
  "fast-equals": "^4.0.3",
65
65
  "find-up": "^5.0.0",
66
66
  "gensequence": "^4.0.3",
@@ -84,13 +84,13 @@
84
84
  "@cspell/dict-python": "^4.0.1",
85
85
  "@types/configstore": "^5.0.1",
86
86
  "@types/jest": "^29.4.0",
87
- "@types/node": "^18.11.19",
87
+ "@types/node": "^18.13.0",
88
88
  "cspell-dict-nl-nl": "^1.1.2",
89
- "jest": "^29.4.1",
89
+ "jest": "^29.4.2",
90
90
  "lorem-ipsum": "^2.0.8",
91
91
  "rollup": "^3.14.0",
92
92
  "rollup-plugin-dts": "^5.1.1",
93
93
  "ts-jest": "^29.0.5"
94
94
  },
95
- "gitHead": "a133874ed7590cbe140f5067cfa80db84b644a5d"
95
+ "gitHead": "a7cfbfa6cf42c9d9746dd8229d9f1317472e5af8"
96
96
  }