cspell-dictionary 6.28.0 → 6.29.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 (127) hide show
  1. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/CachingDictionary.d.ts +3 -3
  2. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/CachingDictionary.js +9 -9
  3. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/FlagWordsDictionary.d.ts +1 -1
  4. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/FlagWordsDictionary.js +11 -11
  5. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/IgnoreWordsDictionary.d.ts +1 -1
  6. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/IgnoreWordsDictionary.js +5 -5
  7. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryCollection.d.ts +1 -1
  8. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryCollection.js +12 -12
  9. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryFromTrie.d.ts +1 -1
  10. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryFromTrie.js +16 -16
  11. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryMethods.d.ts +1 -1
  12. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryMethods.js +5 -5
  13. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SuggestDictionary.d.ts +2 -2
  14. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SuggestDictionary.js +9 -9
  15. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Terms/index.d.ts +1 -1
  16. package/dist/cjs/SpellingDictionary/Typos/index.d.ts +4 -0
  17. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/index.js +7 -7
  18. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/typos.d.ts +1 -1
  19. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/typosParser.d.ts +1 -1
  20. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/typosParser.js +6 -6
  21. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/util.d.ts +1 -1
  22. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/TyposDictionary.d.ts +2 -2
  23. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/TyposDictionary.js +10 -10
  24. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/createInlineSpellingDictionary.d.ts +1 -1
  25. package/dist/cjs/SpellingDictionary/createInlineSpellingDictionary.js +25 -0
  26. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/createSpellingDictionary.d.ts +2 -2
  27. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/createSpellingDictionary.js +9 -9
  28. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/index.d.ts +10 -10
  29. package/dist/{SpellingDictionary → cjs/SpellingDictionary}/index.js +20 -20
  30. package/dist/{index.d.ts → cjs/index.d.ts} +2 -2
  31. package/dist/{index.js → cjs/index.js} +11 -11
  32. package/dist/{util → cjs/util}/clean.d.ts +1 -1
  33. package/dist/{util → cjs/util}/repMap.js +4 -4
  34. package/dist/{util → cjs/util}/textMappers.js +2 -2
  35. package/dist/esm/SpellingDictionary/CachingDictionary.d.mts +30 -0
  36. package/dist/esm/SpellingDictionary/CachingDictionary.mjs +45 -0
  37. package/dist/esm/SpellingDictionary/FlagWordsDictionary.d.mts +11 -0
  38. package/dist/esm/SpellingDictionary/FlagWordsDictionary.mjs +134 -0
  39. package/dist/esm/SpellingDictionary/IgnoreWordsDictionary.d.mts +11 -0
  40. package/dist/esm/SpellingDictionary/IgnoreWordsDictionary.mjs +96 -0
  41. package/dist/esm/SpellingDictionary/SpellingDictionary.d.mts +150 -0
  42. package/dist/esm/SpellingDictionary/SpellingDictionary.mjs +4 -0
  43. package/dist/esm/SpellingDictionary/SpellingDictionaryCollection.d.mts +16 -0
  44. package/dist/esm/SpellingDictionary/SpellingDictionaryCollection.mjs +111 -0
  45. package/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.d.mts +50 -0
  46. package/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.mjs +172 -0
  47. package/dist/esm/SpellingDictionary/SpellingDictionaryMethods.d.mts +26 -0
  48. package/dist/esm/SpellingDictionary/SpellingDictionaryMethods.mjs +96 -0
  49. package/dist/esm/SpellingDictionary/SuggestDictionary.d.mts +20 -0
  50. package/dist/esm/SpellingDictionary/SuggestDictionary.mjs +97 -0
  51. package/dist/esm/SpellingDictionary/Terms/index.d.mts +2 -0
  52. package/dist/esm/SpellingDictionary/Terms/index.mjs +1 -0
  53. package/dist/esm/SpellingDictionary/Terms/terms.d.mts +12 -0
  54. package/dist/esm/SpellingDictionary/Terms/terms.mjs +1 -0
  55. package/dist/esm/SpellingDictionary/Typos/index.d.mts +4 -0
  56. package/dist/esm/SpellingDictionary/Typos/index.mjs +2 -0
  57. package/dist/esm/SpellingDictionary/Typos/typos.d.mts +18 -0
  58. package/dist/esm/SpellingDictionary/Typos/typos.mjs +1 -0
  59. package/dist/esm/SpellingDictionary/Typos/typosParser.d.mts +34 -0
  60. package/dist/esm/SpellingDictionary/Typos/typosParser.mjs +131 -0
  61. package/dist/esm/SpellingDictionary/Typos/util.d.mts +31 -0
  62. package/dist/esm/SpellingDictionary/Typos/util.mjs +105 -0
  63. package/dist/esm/SpellingDictionary/TyposDictionary.d.mts +21 -0
  64. package/dist/esm/SpellingDictionary/TyposDictionary.mjs +129 -0
  65. package/dist/esm/SpellingDictionary/createInlineSpellingDictionary.d.mts +3 -0
  66. package/dist/esm/SpellingDictionary/createInlineSpellingDictionary.mjs +20 -0
  67. package/dist/esm/SpellingDictionary/createSpellingDictionary.d.mts +23 -0
  68. package/dist/esm/SpellingDictionary/createSpellingDictionary.mjs +68 -0
  69. package/dist/esm/SpellingDictionary/defaults.d.mts +3 -0
  70. package/dist/esm/SpellingDictionary/defaults.mjs +2 -0
  71. package/dist/esm/SpellingDictionary/index.d.mts +11 -0
  72. package/dist/esm/SpellingDictionary/index.mjs +9 -0
  73. package/dist/esm/index.d.mts +3 -0
  74. package/dist/esm/index.mjs +1 -0
  75. package/dist/esm/util/AutoCache.d.mts +25 -0
  76. package/dist/esm/util/AutoCache.mjs +67 -0
  77. package/dist/esm/util/AutoResolve.d.mts +21 -0
  78. package/dist/esm/util/AutoResolve.mjs +52 -0
  79. package/dist/esm/util/IterableLike.d.mts +4 -0
  80. package/dist/esm/util/IterableLike.mjs +1 -0
  81. package/dist/esm/util/clean.d.mts +7 -0
  82. package/dist/esm/util/clean.mjs +13 -0
  83. package/dist/esm/util/regexHelper.d.mts +7 -0
  84. package/dist/esm/util/regexHelper.mjs +8 -0
  85. package/dist/esm/util/repMap.d.mts +27 -0
  86. package/dist/esm/util/repMap.mjs +152 -0
  87. package/dist/esm/util/simpleCache.d.mts +46 -0
  88. package/dist/esm/util/simpleCache.mjs +135 -0
  89. package/dist/esm/util/text.d.mts +10 -0
  90. package/dist/esm/util/text.mjs +46 -0
  91. package/dist/esm/util/textMappers.d.mts +3 -0
  92. package/dist/esm/util/textMappers.mjs +15 -0
  93. package/dist/esm/util/types.d.mts +7 -0
  94. package/dist/esm/util/types.mjs +1 -0
  95. package/dist/esm/util/util.d.mts +2 -0
  96. package/dist/esm/util/util.mjs +3 -0
  97. package/package.json +27 -18
  98. package/dist/SpellingDictionary/Typos/index.d.ts +0 -4
  99. package/dist/SpellingDictionary/createInlineSpellingDictionary.js +0 -25
  100. /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionary.d.ts +0 -0
  101. /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionary.js +0 -0
  102. /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Terms/index.js +0 -0
  103. /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Terms/terms.d.ts +0 -0
  104. /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Terms/terms.js +0 -0
  105. /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/typos.js +0 -0
  106. /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/util.js +0 -0
  107. /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/defaults.d.ts +0 -0
  108. /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/defaults.js +0 -0
  109. /package/dist/{util → cjs/util}/AutoCache.d.ts +0 -0
  110. /package/dist/{util → cjs/util}/AutoCache.js +0 -0
  111. /package/dist/{util → cjs/util}/AutoResolve.d.ts +0 -0
  112. /package/dist/{util → cjs/util}/AutoResolve.js +0 -0
  113. /package/dist/{util → cjs/util}/IterableLike.d.ts +0 -0
  114. /package/dist/{util → cjs/util}/IterableLike.js +0 -0
  115. /package/dist/{util → cjs/util}/clean.js +0 -0
  116. /package/dist/{util → cjs/util}/regexHelper.d.ts +0 -0
  117. /package/dist/{util → cjs/util}/regexHelper.js +0 -0
  118. /package/dist/{util → cjs/util}/repMap.d.ts +0 -0
  119. /package/dist/{util → cjs/util}/simpleCache.d.ts +0 -0
  120. /package/dist/{util → cjs/util}/simpleCache.js +0 -0
  121. /package/dist/{util → cjs/util}/text.d.ts +0 -0
  122. /package/dist/{util → cjs/util}/text.js +0 -0
  123. /package/dist/{util → cjs/util}/textMappers.d.ts +0 -0
  124. /package/dist/{util → cjs/util}/types.d.ts +0 -0
  125. /package/dist/{util → cjs/util}/types.js +0 -0
  126. /package/dist/{util → cjs/util}/util.d.ts +0 -0
  127. /package/dist/{util → cjs/util}/util.js +0 -0
@@ -1,5 +1,5 @@
1
- import type { IterableLike } from '../util/IterableLike';
2
- import type { DictionaryInfo, SpellingDictionary, SpellingDictionaryOptions } from './SpellingDictionary';
1
+ import type { IterableLike } from '../util/IterableLike.js';
2
+ import type { DictionaryInfo, SpellingDictionary, SpellingDictionaryOptions } from './SpellingDictionary.js';
3
3
  /**
4
4
  * Create a SpellingDictionary
5
5
  * @param wordList - list of words
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createFailedToLoadDictionary = exports.createSpellingDictionary = void 0;
4
4
  const cspell_trie_lib_1 = require("cspell-trie-lib");
5
5
  const fast_equals_1 = require("fast-equals");
6
- const simpleCache_1 = require("../util/simpleCache");
7
- const SpellingDictionary_1 = require("./SpellingDictionary");
8
- const SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie");
9
- const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods");
10
- const cachedDictionaries = new simpleCache_1.AutoWeakCache(_createSpellingDictionary, 64);
6
+ const simpleCache_js_1 = require("../util/simpleCache.js");
7
+ const SpellingDictionary_js_1 = require("./SpellingDictionary.js");
8
+ const SpellingDictionaryFromTrie_js_1 = require("./SpellingDictionaryFromTrie.js");
9
+ const SpellingDictionaryMethods_js_1 = require("./SpellingDictionaryMethods.js");
10
+ const cachedDictionaries = new simpleCache_js_1.AutoWeakCache(_createSpellingDictionary, 64);
11
11
  const maxSetSize = 3;
12
- const cachedParamsByWordList = new simpleCache_1.SimpleCache(64);
12
+ const cachedParamsByWordList = new simpleCache_js_1.SimpleCache(64);
13
13
  /**
14
14
  * Create a SpellingDictionary
15
15
  * @param wordList - list of words
@@ -42,11 +42,11 @@ function _createSpellingDictionary(params) {
42
42
  const parseOptions = { stripCaseAndAccents: options?.supportNonStrictSearches ?? true };
43
43
  const words = (0, cspell_trie_lib_1.parseDictionaryLines)(wordList, parseOptions);
44
44
  const trie = (0, cspell_trie_lib_1.buildTrieFast)(words);
45
- const opts = { ...(options || SpellingDictionary_1.defaultOptions) };
45
+ const opts = { ...(options || SpellingDictionary_js_1.defaultOptions) };
46
46
  if (opts.weightMap === undefined && opts.dictionaryInformation) {
47
- opts.weightMap = (0, SpellingDictionaryMethods_1.createWeightMapFromDictionaryInformation)(opts.dictionaryInformation);
47
+ opts.weightMap = (0, SpellingDictionaryMethods_js_1.createWeightMapFromDictionaryInformation)(opts.dictionaryInformation);
48
48
  }
49
- return new SpellingDictionaryFromTrie_1.SpellingDictionaryFromTrie(trie, name, opts, source);
49
+ return new SpellingDictionaryFromTrie_js_1.SpellingDictionaryFromTrie(trie, name, opts, source);
50
50
  }
51
51
  function createFailedToLoadDictionary(name, source, error, options) {
52
52
  options = options || {};
@@ -1,11 +1,11 @@
1
- export { CachingDictionary, createCachingDictionary } from './CachingDictionary';
2
- export { createInlineSpellingDictionary } from './createInlineSpellingDictionary';
3
- export { createFailedToLoadDictionary, createSpellingDictionary } from './createSpellingDictionary';
4
- export { createFlagWordsDictionary, createFlagWordsDictionary as createForbiddenWordsDictionary, } from './FlagWordsDictionary';
5
- export { createIgnoreWordsDictionary } from './IgnoreWordsDictionary';
6
- export type { DictionaryDefinitionInline, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary';
7
- export { createCollection, SpellingDictionaryCollection } from './SpellingDictionaryCollection';
8
- export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie';
9
- export { createSuggestDictionary } from './SuggestDictionary';
10
- export { createTyposDictionary } from './TyposDictionary';
1
+ export { CachingDictionary, createCachingDictionary } from './CachingDictionary.js';
2
+ export { createInlineSpellingDictionary } from './createInlineSpellingDictionary.js';
3
+ export { createFailedToLoadDictionary, createSpellingDictionary } from './createSpellingDictionary.js';
4
+ export { createFlagWordsDictionary, createFlagWordsDictionary as createForbiddenWordsDictionary, } from './FlagWordsDictionary.js';
5
+ export { createIgnoreWordsDictionary } from './IgnoreWordsDictionary.js';
6
+ export type { DictionaryDefinitionInline, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary.js';
7
+ export { createCollection, SpellingDictionaryCollection } from './SpellingDictionaryCollection.js';
8
+ export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie.js';
9
+ export { createSuggestDictionary } from './SuggestDictionary.js';
10
+ export { createTyposDictionary } from './TyposDictionary.js';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTyposDictionary = exports.createSuggestDictionary = exports.createSpellingDictionaryFromTrieFile = exports.createCollection = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createSpellingDictionary = exports.createFailedToLoadDictionary = exports.createInlineSpellingDictionary = exports.createCachingDictionary = void 0;
4
- var CachingDictionary_1 = require("./CachingDictionary");
5
- Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return CachingDictionary_1.createCachingDictionary; } });
6
- var createInlineSpellingDictionary_1 = require("./createInlineSpellingDictionary");
7
- Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return createInlineSpellingDictionary_1.createInlineSpellingDictionary; } });
8
- var createSpellingDictionary_1 = require("./createSpellingDictionary");
9
- Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return createSpellingDictionary_1.createFailedToLoadDictionary; } });
10
- Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return createSpellingDictionary_1.createSpellingDictionary; } });
11
- var FlagWordsDictionary_1 = require("./FlagWordsDictionary");
12
- Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_1.createFlagWordsDictionary; } });
13
- Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_1.createFlagWordsDictionary; } });
14
- var IgnoreWordsDictionary_1 = require("./IgnoreWordsDictionary");
15
- Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return IgnoreWordsDictionary_1.createIgnoreWordsDictionary; } });
16
- var SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection");
17
- Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionaryCollection_1.createCollection; } });
18
- var SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie");
19
- Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionaryFromTrie_1.createSpellingDictionaryFromTrieFile; } });
20
- var SuggestDictionary_1 = require("./SuggestDictionary");
21
- Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return SuggestDictionary_1.createSuggestDictionary; } });
22
- var TyposDictionary_1 = require("./TyposDictionary");
23
- Object.defineProperty(exports, "createTyposDictionary", { enumerable: true, get: function () { return TyposDictionary_1.createTyposDictionary; } });
4
+ var CachingDictionary_js_1 = require("./CachingDictionary.js");
5
+ Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return CachingDictionary_js_1.createCachingDictionary; } });
6
+ var createInlineSpellingDictionary_js_1 = require("./createInlineSpellingDictionary.js");
7
+ Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return createInlineSpellingDictionary_js_1.createInlineSpellingDictionary; } });
8
+ var createSpellingDictionary_js_1 = require("./createSpellingDictionary.js");
9
+ Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return createSpellingDictionary_js_1.createFailedToLoadDictionary; } });
10
+ Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return createSpellingDictionary_js_1.createSpellingDictionary; } });
11
+ var FlagWordsDictionary_js_1 = require("./FlagWordsDictionary.js");
12
+ Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_js_1.createFlagWordsDictionary; } });
13
+ Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_js_1.createFlagWordsDictionary; } });
14
+ var IgnoreWordsDictionary_js_1 = require("./IgnoreWordsDictionary.js");
15
+ Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return IgnoreWordsDictionary_js_1.createIgnoreWordsDictionary; } });
16
+ var SpellingDictionaryCollection_js_1 = require("./SpellingDictionaryCollection.js");
17
+ Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionaryCollection_js_1.createCollection; } });
18
+ var SpellingDictionaryFromTrie_js_1 = require("./SpellingDictionaryFromTrie.js");
19
+ Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionaryFromTrie_js_1.createSpellingDictionaryFromTrieFile; } });
20
+ var SuggestDictionary_js_1 = require("./SuggestDictionary.js");
21
+ Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return SuggestDictionary_js_1.createSuggestDictionary; } });
22
+ var TyposDictionary_js_1 = require("./TyposDictionary.js");
23
+ Object.defineProperty(exports, "createTyposDictionary", { enumerable: true, get: function () { return TyposDictionary_js_1.createTyposDictionary; } });
24
24
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
- export type { CachingDictionary, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary';
2
- export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, } from './SpellingDictionary';
1
+ export type { CachingDictionary, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary/index.js';
2
+ export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, } from './SpellingDictionary/index.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createSuggestDictionary = exports.createSpellingDictionaryFromTrieFile = exports.createSpellingDictionary = exports.createInlineSpellingDictionary = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createFailedToLoadDictionary = exports.createCollection = exports.createCachingDictionary = void 0;
4
- var SpellingDictionary_1 = require("./SpellingDictionary");
5
- Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createCachingDictionary; } });
6
- Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionary_1.createCollection; } });
7
- Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createFailedToLoadDictionary; } });
8
- Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createFlagWordsDictionary; } });
9
- Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createForbiddenWordsDictionary; } });
10
- Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createIgnoreWordsDictionary; } });
11
- Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createInlineSpellingDictionary; } });
12
- Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createSpellingDictionary; } });
13
- Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionary_1.createSpellingDictionaryFromTrieFile; } });
14
- Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createSuggestDictionary; } });
4
+ var index_js_1 = require("./SpellingDictionary/index.js");
5
+ Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return index_js_1.createCachingDictionary; } });
6
+ Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return index_js_1.createCollection; } });
7
+ Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return index_js_1.createFailedToLoadDictionary; } });
8
+ Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return index_js_1.createFlagWordsDictionary; } });
9
+ Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return index_js_1.createForbiddenWordsDictionary; } });
10
+ Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return index_js_1.createIgnoreWordsDictionary; } });
11
+ Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return index_js_1.createInlineSpellingDictionary; } });
12
+ Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return index_js_1.createSpellingDictionary; } });
13
+ Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return index_js_1.createSpellingDictionaryFromTrieFile; } });
14
+ Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return index_js_1.createSuggestDictionary; } });
15
15
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import type { RemoveUndefined } from './types';
1
+ import type { RemoveUndefined } from './types.js';
2
2
  /**
3
3
  * Delete all `undefined` fields from an object.
4
4
  * @param src - object to be cleaned
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.__testing__ = exports.createRepMapper = exports.createMapper = void 0;
4
4
  const cspell_trie_lib_1 = require("cspell-trie-lib");
5
- const regexHelper_1 = require("./regexHelper");
6
- const util_1 = require("./util");
5
+ const regexHelper_js_1 = require("./regexHelper.js");
6
+ const util_js_1 = require("./util.js");
7
7
  function createMapper(repMap, ignoreCharset) {
8
8
  if (!repMap && !ignoreCharset)
9
9
  return (a) => a;
@@ -62,7 +62,7 @@ function createMapperRegExp(repMap) {
62
62
  s = r;
63
63
  }
64
64
  catch (err) {
65
- return (0, regexHelper_1.escapeRegEx)(s);
65
+ return (0, regexHelper_js_1.escapeRegEx)(s);
66
66
  }
67
67
  return s;
68
68
  })
@@ -130,7 +130,7 @@ function calcAllEdits(root, word) {
130
130
  return edits;
131
131
  }
132
132
  function createTrie(repMap, ignoreCharset) {
133
- const combined = [repMap, charsetToRepMap(ignoreCharset)].filter(util_1.isDefined).flatMap((a) => a);
133
+ const combined = [repMap, charsetToRepMap(ignoreCharset)].filter(util_js_1.isDefined).flatMap((a) => a);
134
134
  const expanded = expandReplaceMap(combined);
135
135
  const trieRoot = Object.create(null);
136
136
  expanded.forEach(([match, replaceWith]) => addToTrie(trieRoot, match, replaceWith));
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapperRemoveCaseAndAccents = exports.mapperNormalizeNFC = void 0;
4
- const text_1 = require("./text");
4
+ const text_js_1 = require("./text.js");
5
5
  function* mapperNormalizeNFC(words) {
6
6
  for (const word of words) {
7
7
  yield word.normalize('NFC');
@@ -12,7 +12,7 @@ function* mapperRemoveCaseAndAccents(words) {
12
12
  for (const word of words) {
13
13
  const lc = word.toLowerCase();
14
14
  yield lc;
15
- const woAccents = (0, text_1.removeAccents)(lc);
15
+ const woAccents = (0, text_js_1.removeAccents)(lc);
16
16
  if (lc !== woAccents)
17
17
  yield woAccents;
18
18
  }
@@ -0,0 +1,30 @@
1
+ import type { CacheStats } from '../util/AutoCache.mjs';
2
+ import type { SearchOptions, SpellingDictionary } from './SpellingDictionary.mjs';
3
+ import type { SpellingDictionaryCollection } from './SpellingDictionaryCollection.mjs';
4
+ interface CallStats {
5
+ name: string;
6
+ id: number;
7
+ has: CacheStats;
8
+ isNoSuggestWord: CacheStats;
9
+ isForbidden: CacheStats;
10
+ }
11
+ /**
12
+ * Caching Dictionary remembers method calls to increase performance.
13
+ */
14
+ export interface CachingDictionary {
15
+ name: string;
16
+ id: number;
17
+ has(word: string): boolean;
18
+ isNoSuggestWord(word: string): boolean;
19
+ isForbidden(word: string): boolean;
20
+ stats(): CallStats;
21
+ }
22
+ /**
23
+ * create a caching dictionary
24
+ * @param dict - Dictionary to cache the search results.
25
+ * @param options - Search options to use.
26
+ * @returns CachingDictionary
27
+ */
28
+ export declare function createCachingDictionary(dict: SpellingDictionary | SpellingDictionaryCollection, options: SearchOptions): CachingDictionary;
29
+ export {};
30
+ //# sourceMappingURL=CachingDictionary.d.mts.map
@@ -0,0 +1,45 @@
1
+ import { autoCache, extractStats } from '../util/AutoCache.mjs';
2
+ import { canonicalSearchOptions } from './SpellingDictionaryMethods.mjs';
3
+ let dictionaryCounter = 0;
4
+ class CachedDict {
5
+ constructor(dict, options) {
6
+ this.dict = dict;
7
+ this.options = options;
8
+ this.id = ++dictionaryCounter;
9
+ this.has = autoCache((word) => this.dict.has(word, this.options));
10
+ this.isNoSuggestWord = autoCache((word) => this.dict.isNoSuggestWord(word, this.options));
11
+ this.isForbidden = autoCache((word) => this.dict.isForbidden(word));
12
+ this.name = dict.name;
13
+ // console.log(`CachedDict for ${this.name}`);
14
+ }
15
+ stats() {
16
+ return {
17
+ name: this.name,
18
+ id: this.id,
19
+ has: extractStats(this.has),
20
+ isNoSuggestWord: extractStats(this.isNoSuggestWord),
21
+ isForbidden: extractStats(this.isForbidden),
22
+ };
23
+ }
24
+ }
25
+ const knownDicts = new Map();
26
+ /**
27
+ * create a caching dictionary
28
+ * @param dict - Dictionary to cache the search results.
29
+ * @param options - Search options to use.
30
+ * @returns CachingDictionary
31
+ */
32
+ export function createCachingDictionary(dict, options) {
33
+ options = canonicalSearchOptions(options);
34
+ let knownOptions = knownDicts.get(options);
35
+ if (!knownOptions) {
36
+ knownOptions = new WeakMap();
37
+ knownDicts.set(options, knownOptions);
38
+ }
39
+ const known = knownOptions.get(dict);
40
+ if (known)
41
+ return known;
42
+ const cached = new CachedDict(dict, options);
43
+ knownOptions.set(dict, cached);
44
+ return cached;
45
+ }
@@ -0,0 +1,11 @@
1
+ import type { SpellingDictionary } from './SpellingDictionary.mjs';
2
+ /**
3
+ * Create a dictionary where all words are to be forbidden.
4
+ * @param wordList - list of words
5
+ * @param name
6
+ * @param source
7
+ * @param options
8
+ * @returns SpellingDictionary
9
+ */
10
+ export declare function createFlagWordsDictionary(wordList: readonly string[], name: string, source: string): SpellingDictionary;
11
+ //# sourceMappingURL=FlagWordsDictionary.d.mts.map
@@ -0,0 +1,134 @@
1
+ import { opMap, pipe } from '@cspell/cspell-pipe/sync';
2
+ import { buildTrieFast, parseDictionaryLines } from 'cspell-trie-lib';
3
+ import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs';
4
+ import * as Defaults from './defaults.mjs';
5
+ import { defaultOptions } from './SpellingDictionary.mjs';
6
+ import { SpellingDictionaryFromTrie } from './SpellingDictionaryFromTrie.mjs';
7
+ import { suggestArgsToSuggestOptions } from './SpellingDictionaryMethods.mjs';
8
+ import { createTyposDictionary } from './TyposDictionary.mjs';
9
+ class FlagWordsDictionaryTrie extends SpellingDictionaryFromTrie {
10
+ constructor(trie, name, source) {
11
+ super(trie, name, defaultOptions, source);
12
+ this.name = name;
13
+ this.source = source;
14
+ this.containsNoSuggestWords = false;
15
+ this.options = {};
16
+ this.isDictionaryCaseSensitive = true;
17
+ }
18
+ /**
19
+ * A Forbidden word list does not "have" valid words.
20
+ * Therefore it always returns false.
21
+ * @param _word - the word
22
+ * @param _options - options
23
+ * @returns always false
24
+ */
25
+ has(_word, _options) {
26
+ return false;
27
+ }
28
+ find(word, hasOptions) {
29
+ const f = super.find(word, hasOptions);
30
+ if (!f || !f.forbidden)
31
+ return undefined;
32
+ return f;
33
+ }
34
+ suggest() {
35
+ return [];
36
+ }
37
+ genSuggestions() {
38
+ return;
39
+ }
40
+ }
41
+ class FlagWordsDictionary {
42
+ constructor(name, source, dictTypos, dictTrie) {
43
+ this.name = name;
44
+ this.source = source;
45
+ this.dictTypos = dictTypos;
46
+ this.dictTrie = dictTrie;
47
+ this.containsNoSuggestWords = false;
48
+ this.options = {};
49
+ this.type = 'flag-words';
50
+ this.isDictionaryCaseSensitive = true;
51
+ }
52
+ /**
53
+ * A Forbidden word list does not "have" valid words.
54
+ * Therefore it always returns false.
55
+ * @param word - the word
56
+ * @param options - options
57
+ * @returns always false
58
+ */
59
+ has(word, options) {
60
+ return this.dictTypos.has(word, options) || this.dictTrie?.has(word, options) || false;
61
+ }
62
+ /** A more detailed search for a word, might take longer than `has` */
63
+ find(word, options) {
64
+ const findTypos = this.dictTypos.find(word, options);
65
+ if (findTypos)
66
+ return findTypos;
67
+ const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase;
68
+ if (this.dictTypos.isSuggestedWord(word, ignoreCase))
69
+ return undefined;
70
+ return this.dictTrie?.find(word, options);
71
+ }
72
+ isForbidden(word, ignoreCaseAndAccents = Defaults.isForbiddenIgnoreCaseAndAccents) {
73
+ const findResult = this.find(word, { ignoreCase: ignoreCaseAndAccents });
74
+ return findResult?.forbidden || false;
75
+ }
76
+ isNoSuggestWord(word, options) {
77
+ return this.dictTrie?.isNoSuggestWord(word, options) || this.dictTypos.isNoSuggestWord(word, options);
78
+ }
79
+ suggest(...args) {
80
+ const [word] = args;
81
+ const suggestOptions = suggestArgsToSuggestOptions(args);
82
+ return this.dictTypos.suggest(word, suggestOptions);
83
+ }
84
+ genSuggestions() {
85
+ return;
86
+ }
87
+ mapWord(word) {
88
+ return word;
89
+ }
90
+ get size() {
91
+ return this.dictTypos.size + (this.dictTrie?.size || 0);
92
+ }
93
+ getErrors() {
94
+ return [];
95
+ }
96
+ }
97
+ const createCache = createAutoResolveWeakCache();
98
+ /**
99
+ * Create a dictionary where all words are to be forbidden.
100
+ * @param wordList - list of words
101
+ * @param name
102
+ * @param source
103
+ * @param options
104
+ * @returns SpellingDictionary
105
+ */
106
+ export function createFlagWordsDictionary(wordList, name, source) {
107
+ return createCache.get(wordList, () => {
108
+ const testSpecialCharacters = /[~*+]/;
109
+ const { t: specialWords, f: typoWords } = bisect(parseDictionaryLines(wordList, { stripCaseAndAccents: false }), (line) => testSpecialCharacters.test(line));
110
+ const trieDict = specialWords.size ? buildTrieDict(specialWords, name, source) : undefined;
111
+ const typosDict = createTyposDictionary(typoWords, name, source);
112
+ if (!trieDict)
113
+ return typosDict;
114
+ return new FlagWordsDictionary(name, source, typosDict, trieDict);
115
+ });
116
+ }
117
+ const regExpCleanIgnore = /^(!!)+/;
118
+ function buildTrieDict(words, name, source) {
119
+ const trie = buildTrieFast(pipe(words, opMap((w) => '!' + w), opMap((w) => w.replace(regExpCleanIgnore, ''))));
120
+ return new FlagWordsDictionaryTrie(trie, name, source);
121
+ }
122
+ function bisect(values, predicate) {
123
+ const t = new Set();
124
+ const f = new Set();
125
+ for (const v of values) {
126
+ if (predicate(v)) {
127
+ t.add(v);
128
+ }
129
+ else {
130
+ f.add(v);
131
+ }
132
+ }
133
+ return { t, f };
134
+ }
@@ -0,0 +1,11 @@
1
+ import type { SpellingDictionary } from './SpellingDictionary.mjs';
2
+ /**
3
+ * Create a dictionary where all words are to be ignored.
4
+ * Ignored words override forbidden words.
5
+ * @param wordList - list of words
6
+ * @param name - name of dictionary
7
+ * @param source - dictionary source
8
+ * @returns
9
+ */
10
+ export declare function createIgnoreWordsDictionary(wordList: readonly string[], name: string, source: string): SpellingDictionary;
11
+ //# sourceMappingURL=IgnoreWordsDictionary.d.mts.map
@@ -0,0 +1,96 @@
1
+ import { opFilter, opMap, pipe } from '@cspell/cspell-pipe/sync';
2
+ import { parseDictionaryLines } from 'cspell-trie-lib';
3
+ import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs';
4
+ import { createSpellingDictionary } from './createSpellingDictionary.mjs';
5
+ import * as Defaults from './defaults.mjs';
6
+ const NormalizeForm = 'NFC';
7
+ class IgnoreWordsDictionary {
8
+ constructor(name, source, words) {
9
+ this.name = name;
10
+ this.source = source;
11
+ this.containsNoSuggestWords = true;
12
+ this.options = {};
13
+ this.type = 'ignore';
14
+ this.isDictionaryCaseSensitive = true;
15
+ this.dict = new Set(words);
16
+ this.dictNonStrict = new Set(pipe(this.dict, opFilter((w) => w.startsWith('~')), opMap((w) => w.slice(1))));
17
+ }
18
+ /**
19
+ * A Forbidden word list does not "have" valid words.
20
+ * Therefore it always returns false.
21
+ * @param _word - the word
22
+ * @param _options - options
23
+ * @returns always false
24
+ */
25
+ has(word, options) {
26
+ const nWord = word.normalize(NormalizeForm);
27
+ if (this.dict.has(nWord))
28
+ return true;
29
+ const lcWord = nWord.toLowerCase();
30
+ if (this.dict.has(lcWord))
31
+ return true;
32
+ const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase;
33
+ return ignoreCase && (this.dictNonStrict.has(nWord) || this.dictNonStrict.has(lcWord));
34
+ }
35
+ /** A more detailed search for a word, might take longer than `has` */
36
+ find(word, options) {
37
+ const nWord = word.normalize(NormalizeForm);
38
+ if (this.dict.has(nWord))
39
+ return { found: nWord, forbidden: false, noSuggest: true };
40
+ const lcWord = nWord.toLowerCase();
41
+ if (this.dict.has(lcWord))
42
+ return { found: lcWord, forbidden: false, noSuggest: true };
43
+ const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase;
44
+ if (!ignoreCase)
45
+ return undefined;
46
+ if (this.dictNonStrict.has(nWord))
47
+ return { found: nWord, forbidden: false, noSuggest: true };
48
+ return (this.dictNonStrict.has(lcWord) && { found: lcWord, forbidden: false, noSuggest: true }) || undefined;
49
+ }
50
+ isForbidden(_word, _ignoreCase) {
51
+ return false;
52
+ }
53
+ isNoSuggestWord(word, options) {
54
+ return this.has(word, options);
55
+ }
56
+ suggest() {
57
+ return [];
58
+ }
59
+ genSuggestions() {
60
+ return;
61
+ }
62
+ mapWord(word) {
63
+ return word;
64
+ }
65
+ get size() {
66
+ return this.dict.size;
67
+ }
68
+ getErrors() {
69
+ return [];
70
+ }
71
+ }
72
+ const createCache = createAutoResolveWeakCache();
73
+ /**
74
+ * Create a dictionary where all words are to be ignored.
75
+ * Ignored words override forbidden words.
76
+ * @param wordList - list of words
77
+ * @param name - name of dictionary
78
+ * @param source - dictionary source
79
+ * @returns
80
+ */
81
+ export function createIgnoreWordsDictionary(wordList, name, source) {
82
+ return createCache.get(wordList, () => {
83
+ const testSpecialCharacters = /[*+]/;
84
+ const words = [...parseDictionaryLines(wordList, { stripCaseAndAccents: true })].map((w) => w.normalize(NormalizeForm));
85
+ const hasSpecial = words.findIndex((word) => testSpecialCharacters.test(word)) >= 0;
86
+ if (hasSpecial) {
87
+ return createSpellingDictionary(words, name, source, {
88
+ caseSensitive: true,
89
+ noSuggest: true,
90
+ weightMap: undefined,
91
+ supportNonStrictSearches: true,
92
+ });
93
+ }
94
+ return new IgnoreWordsDictionary(name, source, words);
95
+ });
96
+ }