cspell-dictionary 7.0.0-alpha.1 → 7.0.1-alpha.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 (126) hide show
  1. package/dist/{esm/SpellingDictionary/CachingDictionary.mjs → SpellingDictionary/CachingDictionary.js} +2 -2
  2. package/dist/{esm/SpellingDictionary/FlagWordsDictionary.mjs → SpellingDictionary/FlagWordsDictionary.js} +6 -6
  3. package/dist/{esm/SpellingDictionary/IgnoreWordsDictionary.mjs → SpellingDictionary/IgnoreWordsDictionary.js} +3 -3
  4. package/dist/{esm/SpellingDictionary/SpellingDictionaryCollection.mjs → SpellingDictionary/SpellingDictionaryCollection.js} +4 -4
  5. package/dist/{esm/SpellingDictionary/SpellingDictionaryFromTrie.mjs → SpellingDictionary/SpellingDictionaryFromTrie.js} +6 -7
  6. package/dist/{esm/SpellingDictionary/SpellingDictionaryMethods.mjs → SpellingDictionary/SpellingDictionaryMethods.js} +1 -1
  7. package/dist/{esm/SpellingDictionary/SuggestDictionary.mjs → SpellingDictionary/SuggestDictionary.js} +5 -5
  8. package/dist/SpellingDictionary/Typos/index.js +2 -0
  9. package/dist/{esm/SpellingDictionary/Typos/typosParser.mjs → SpellingDictionary/Typos/typosParser.js} +1 -1
  10. package/dist/{esm/SpellingDictionary/TyposDictionary.mjs → SpellingDictionary/TyposDictionary.js} +5 -5
  11. package/dist/{esm/SpellingDictionary/createInlineSpellingDictionary.mjs → SpellingDictionary/createInlineSpellingDictionary.js} +7 -7
  12. package/dist/{esm/SpellingDictionary/createSpellingDictionary.mjs → SpellingDictionary/createSpellingDictionary.js} +4 -4
  13. package/dist/{esm/SpellingDictionary/index.mjs → SpellingDictionary/index.js} +9 -9
  14. package/dist/{esm/index.mjs → index.js} +1 -1
  15. package/dist/{esm/util/repMap.mjs → util/repMap.js} +2 -2
  16. package/dist/{esm/util/textMappers.mjs → util/textMappers.js} +1 -1
  17. package/package.json +11 -16
  18. package/dist/cjs/SpellingDictionary/CachingDictionary.js +0 -53
  19. package/dist/cjs/SpellingDictionary/FlagWordsDictionary.js +0 -165
  20. package/dist/cjs/SpellingDictionary/IgnoreWordsDictionary.js +0 -124
  21. package/dist/cjs/SpellingDictionary/SpellingDictionary.js +0 -9
  22. package/dist/cjs/SpellingDictionary/SpellingDictionaryCollection.js +0 -152
  23. package/dist/cjs/SpellingDictionary/SpellingDictionaryFromTrie.js +0 -201
  24. package/dist/cjs/SpellingDictionary/SpellingDictionaryMethods.js +0 -109
  25. package/dist/cjs/SpellingDictionary/SuggestDictionary.js +0 -128
  26. package/dist/cjs/SpellingDictionary/Terms/index.js +0 -3
  27. package/dist/cjs/SpellingDictionary/Terms/terms.js +0 -3
  28. package/dist/cjs/SpellingDictionary/Typos/index.js +0 -11
  29. package/dist/cjs/SpellingDictionary/Typos/typos.js +0 -3
  30. package/dist/cjs/SpellingDictionary/Typos/typosParser.js +0 -143
  31. package/dist/cjs/SpellingDictionary/Typos/util.js +0 -115
  32. package/dist/cjs/SpellingDictionary/TyposDictionary.js +0 -160
  33. package/dist/cjs/SpellingDictionary/createInlineSpellingDictionary.js +0 -25
  34. package/dist/cjs/SpellingDictionary/createSpellingDictionary.js +0 -74
  35. package/dist/cjs/SpellingDictionary/defaults.js +0 -6
  36. package/dist/cjs/SpellingDictionary/index.js +0 -24
  37. package/dist/cjs/index.js +0 -15
  38. package/dist/cjs/util/AutoCache.js +0 -74
  39. package/dist/cjs/util/AutoResolve.js +0 -62
  40. package/dist/cjs/util/IterableLike.js +0 -3
  41. package/dist/cjs/util/clean.js +0 -18
  42. package/dist/cjs/util/regexHelper.js +0 -13
  43. package/dist/cjs/util/repMap.js +0 -158
  44. package/dist/cjs/util/simpleCache.js +0 -143
  45. package/dist/cjs/util/text.js +0 -59
  46. package/dist/cjs/util/textMappers.js +0 -21
  47. package/dist/cjs/util/types.js +0 -3
  48. package/dist/cjs/util/util.js +0 -8
  49. package/dist/esm/SpellingDictionary/CachingDictionary.d.mts +0 -32
  50. package/dist/esm/SpellingDictionary/FlagWordsDictionary.d.mts +0 -11
  51. package/dist/esm/SpellingDictionary/IgnoreWordsDictionary.d.mts +0 -11
  52. package/dist/esm/SpellingDictionary/SpellingDictionary.d.mts +0 -158
  53. package/dist/esm/SpellingDictionary/SpellingDictionaryCollection.d.mts +0 -16
  54. package/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.d.mts +0 -50
  55. package/dist/esm/SpellingDictionary/SpellingDictionaryMethods.d.mts +0 -26
  56. package/dist/esm/SpellingDictionary/SuggestDictionary.d.mts +0 -21
  57. package/dist/esm/SpellingDictionary/Terms/index.d.mts +0 -2
  58. package/dist/esm/SpellingDictionary/Terms/terms.d.mts +0 -12
  59. package/dist/esm/SpellingDictionary/Typos/index.d.mts +0 -4
  60. package/dist/esm/SpellingDictionary/Typos/index.mjs +0 -2
  61. package/dist/esm/SpellingDictionary/Typos/typos.d.mts +0 -18
  62. package/dist/esm/SpellingDictionary/Typos/typosParser.d.mts +0 -34
  63. package/dist/esm/SpellingDictionary/Typos/util.d.mts +0 -31
  64. package/dist/esm/SpellingDictionary/TyposDictionary.d.mts +0 -22
  65. package/dist/esm/SpellingDictionary/createInlineSpellingDictionary.d.mts +0 -3
  66. package/dist/esm/SpellingDictionary/createSpellingDictionary.d.mts +0 -23
  67. package/dist/esm/SpellingDictionary/defaults.d.mts +0 -3
  68. package/dist/esm/SpellingDictionary/index.d.mts +0 -11
  69. package/dist/esm/index.d.mts +0 -3
  70. package/dist/esm/util/AutoCache.d.mts +0 -25
  71. package/dist/esm/util/AutoResolve.d.mts +0 -21
  72. package/dist/esm/util/IterableLike.d.mts +0 -4
  73. package/dist/esm/util/clean.d.mts +0 -7
  74. package/dist/esm/util/regexHelper.d.mts +0 -7
  75. package/dist/esm/util/repMap.d.mts +0 -27
  76. package/dist/esm/util/simpleCache.d.mts +0 -46
  77. package/dist/esm/util/text.d.mts +0 -10
  78. package/dist/esm/util/textMappers.d.mts +0 -3
  79. package/dist/esm/util/types.d.mts +0 -7
  80. package/dist/esm/util/util.d.mts +0 -2
  81. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/CachingDictionary.d.ts +0 -0
  82. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/FlagWordsDictionary.d.ts +0 -0
  83. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/IgnoreWordsDictionary.d.ts +0 -0
  84. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/SpellingDictionary.d.ts +0 -0
  85. /package/dist/{esm/SpellingDictionary/SpellingDictionary.mjs → SpellingDictionary/SpellingDictionary.js} +0 -0
  86. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/SpellingDictionaryCollection.d.ts +0 -0
  87. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/SpellingDictionaryFromTrie.d.ts +0 -0
  88. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/SpellingDictionaryMethods.d.ts +0 -0
  89. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/SuggestDictionary.d.ts +0 -0
  90. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/Terms/index.d.ts +0 -0
  91. /package/dist/{esm/SpellingDictionary/Terms/index.mjs → SpellingDictionary/Terms/index.js} +0 -0
  92. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/Terms/terms.d.ts +0 -0
  93. /package/dist/{esm/SpellingDictionary/Terms/terms.mjs → SpellingDictionary/Terms/terms.js} +0 -0
  94. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/Typos/index.d.ts +0 -0
  95. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/Typos/typos.d.ts +0 -0
  96. /package/dist/{esm/SpellingDictionary/Typos/typos.mjs → SpellingDictionary/Typos/typos.js} +0 -0
  97. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/Typos/typosParser.d.ts +0 -0
  98. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/Typos/util.d.ts +0 -0
  99. /package/dist/{esm/SpellingDictionary/Typos/util.mjs → SpellingDictionary/Typos/util.js} +0 -0
  100. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/TyposDictionary.d.ts +0 -0
  101. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/createInlineSpellingDictionary.d.ts +0 -0
  102. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/createSpellingDictionary.d.ts +0 -0
  103. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/defaults.d.ts +0 -0
  104. /package/dist/{esm/SpellingDictionary/defaults.mjs → SpellingDictionary/defaults.js} +0 -0
  105. /package/dist/{cjs/SpellingDictionary → SpellingDictionary}/index.d.ts +0 -0
  106. /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  107. /package/dist/{cjs/util → util}/AutoCache.d.ts +0 -0
  108. /package/dist/{esm/util/AutoCache.mjs → util/AutoCache.js} +0 -0
  109. /package/dist/{cjs/util → util}/AutoResolve.d.ts +0 -0
  110. /package/dist/{esm/util/AutoResolve.mjs → util/AutoResolve.js} +0 -0
  111. /package/dist/{cjs/util → util}/IterableLike.d.ts +0 -0
  112. /package/dist/{esm/util/IterableLike.mjs → util/IterableLike.js} +0 -0
  113. /package/dist/{cjs/util → util}/clean.d.ts +0 -0
  114. /package/dist/{esm/util/clean.mjs → util/clean.js} +0 -0
  115. /package/dist/{cjs/util → util}/regexHelper.d.ts +0 -0
  116. /package/dist/{esm/util/regexHelper.mjs → util/regexHelper.js} +0 -0
  117. /package/dist/{cjs/util → util}/repMap.d.ts +0 -0
  118. /package/dist/{cjs/util → util}/simpleCache.d.ts +0 -0
  119. /package/dist/{esm/util/simpleCache.mjs → util/simpleCache.js} +0 -0
  120. /package/dist/{cjs/util → util}/text.d.ts +0 -0
  121. /package/dist/{esm/util/text.mjs → util/text.js} +0 -0
  122. /package/dist/{cjs/util → util}/textMappers.d.ts +0 -0
  123. /package/dist/{cjs/util → util}/types.d.ts +0 -0
  124. /package/dist/{esm/util/types.mjs → util/types.js} +0 -0
  125. /package/dist/{cjs/util → util}/util.d.ts +0 -0
  126. /package/dist/{esm/util/util.mjs → util/util.js} +0 -0
@@ -1,5 +1,5 @@
1
- import { autoCache, extractStats } from '../util/AutoCache.mjs';
2
- import { canonicalSearchOptions } from './SpellingDictionaryMethods.mjs';
1
+ import { autoCache, extractStats } from '../util/AutoCache.js';
2
+ import { canonicalSearchOptions } from './SpellingDictionaryMethods.js';
3
3
  let dictionaryCounter = 0;
4
4
  const DefaultAutoCacheSize = 1000;
5
5
  class CachedDict {
@@ -1,11 +1,11 @@
1
1
  import { opMap, pipe } from '@cspell/cspell-pipe/sync';
2
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';
3
+ import { createAutoResolveWeakCache } from '../util/AutoResolve.js';
4
+ import * as Defaults from './defaults.js';
5
+ import { defaultOptions } from './SpellingDictionary.js';
6
+ import { SpellingDictionaryFromTrie } from './SpellingDictionaryFromTrie.js';
7
+ import { suggestArgsToSuggestOptions } from './SpellingDictionaryMethods.js';
8
+ import { createTyposDictionary } from './TyposDictionary.js';
9
9
  class FlagWordsDictionaryTrie extends SpellingDictionaryFromTrie {
10
10
  constructor(trie, name, source) {
11
11
  super(trie, name, defaultOptions, source);
@@ -1,8 +1,8 @@
1
1
  import { opFilter, opMap, pipe } from '@cspell/cspell-pipe/sync';
2
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';
3
+ import { createAutoResolveWeakCache } from '../util/AutoResolve.js';
4
+ import { createSpellingDictionary } from './createSpellingDictionary.js';
5
+ import * as Defaults from './defaults.js';
6
6
  const NormalizeForm = 'NFC';
7
7
  class IgnoreWordsDictionary {
8
8
  constructor(name, source, words) {
@@ -1,9 +1,9 @@
1
1
  import { CASE_INSENSITIVE_PREFIX } from 'cspell-trie-lib';
2
2
  import { genSequence } from 'gensequence';
3
- import { isDefined } from '../util/util.mjs';
4
- import * as Defaults from './defaults.mjs';
5
- import { CompoundWordsMethod } from './SpellingDictionary.mjs';
6
- import { defaultNumSuggestions, hasOptionToSearchOption, suggestArgsToSuggestOptions, suggestionCollector, } from './SpellingDictionaryMethods.mjs';
3
+ import { isDefined } from '../util/util.js';
4
+ import * as Defaults from './defaults.js';
5
+ import { CompoundWordsMethod } from './SpellingDictionary.js';
6
+ import { defaultNumSuggestions, hasOptionToSearchOption, suggestArgsToSuggestOptions, suggestionCollector, } from './SpellingDictionaryMethods.js';
7
7
  function identityString(w) {
8
8
  return w;
9
9
  }
@@ -1,13 +1,13 @@
1
1
  import { opConcatMap, pipe } from '@cspell/cspell-pipe/sync';
2
2
  import { CompoundWordsMethod, importTrie, suggestionCollector, Trie } from 'cspell-trie-lib';
3
- import { autoCache, createCache01 } from '../util/AutoCache.mjs';
4
- import { clean } from '../util/clean.mjs';
5
- import { createMapper, createRepMapper } from '../util/repMap.mjs';
6
- import * as Defaults from './defaults.mjs';
7
- import { createWeightMapFromDictionaryInformation, defaultNumSuggestions, hasOptionToSearchOption, impersonateCollector, suggestArgsToSuggestOptions, wordSearchForms, wordSuggestFormsArray, } from './SpellingDictionaryMethods.mjs';
3
+ import { autoCache, createCache01 } from '../util/AutoCache.js';
4
+ import { clean } from '../util/clean.js';
5
+ import { createMapper, createRepMapper } from '../util/repMap.js';
6
+ import * as Defaults from './defaults.js';
7
+ import { createWeightMapFromDictionaryInformation, defaultNumSuggestions, hasOptionToSearchOption, impersonateCollector, suggestArgsToSuggestOptions, wordSearchForms, wordSuggestFormsArray, } from './SpellingDictionaryMethods.js';
8
8
  const findWordOptionsCaseSensitive = Object.freeze({ caseSensitive: true });
9
9
  const findWordOptionsNotCaseSensitive = Object.freeze({ caseSensitive: false });
10
- class SpellingDictionaryFromTrie {
10
+ export class SpellingDictionaryFromTrie {
11
11
  constructor(trie, name, options, source = 'from trie', size) {
12
12
  this.trie = trie;
13
13
  this.name = name;
@@ -136,7 +136,6 @@ class SpellingDictionaryFromTrie {
136
136
  }
137
137
  }
138
138
  SpellingDictionaryFromTrie.cachedWordsLimit = 50000;
139
- export { SpellingDictionaryFromTrie };
140
139
  /**
141
140
  * Create a dictionary from a trie file.
142
141
  * @param data - contents of a trie file.
@@ -1,5 +1,5 @@
1
1
  import { mapDictionaryInformationToWeightMap } from 'cspell-trie-lib';
2
- import { isUpperCase, removeUnboundAccents, ucFirst } from '../util/text.mjs';
2
+ import { isUpperCase, removeUnboundAccents, ucFirst } from '../util/text.js';
3
3
  export { impersonateCollector, suggestionCollector } from 'cspell-trie-lib';
4
4
  export const defaultNumSuggestions = 10;
5
5
  function wordSearchFormsArray(word, isDictionaryCaseSensitive, ignoreCase) {
@@ -1,9 +1,9 @@
1
1
  import { pipe } from '@cspell/cspell-pipe/sync';
2
- import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs';
3
- import { mapperRemoveCaseAndAccents } from '../util/textMappers.mjs';
4
- import * as defaults from './defaults.mjs';
5
- import { processEntriesToTyposDef } from './Typos/index.mjs';
6
- import { extractAllSuggestions } from './Typos/util.mjs';
2
+ import { createAutoResolveWeakCache } from '../util/AutoResolve.js';
3
+ import { mapperRemoveCaseAndAccents } from '../util/textMappers.js';
4
+ import * as defaults from './defaults.js';
5
+ import { processEntriesToTyposDef } from './Typos/index.js';
6
+ import { extractAllSuggestions } from './Typos/util.js';
7
7
  class SuggestDictionaryImpl {
8
8
  constructor(name, source, typosDef) {
9
9
  this.name = name;
@@ -0,0 +1,2 @@
1
+ export { parseTyposFile, parseTyposLine, processEntriesToTyposDef } from './typosParser.js';
2
+ export { createTyposDef, extractAllSuggestions } from './util.js';
@@ -1,5 +1,5 @@
1
1
  import assert from 'assert';
2
- import { appendToDef, createTyposDef } from './util.mjs';
2
+ import { appendToDef, createTyposDef } from './util.js';
3
3
  function assertString(v) {
4
4
  assert(typeof v === 'string', 'A string was expected.');
5
5
  return true;
@@ -1,9 +1,9 @@
1
1
  import { opAppend, pipe } from '@cspell/cspell-pipe/sync';
2
- import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs';
3
- import { mapperRemoveCaseAndAccents } from '../util/textMappers.mjs';
4
- import * as defaults from './defaults.mjs';
5
- import { processEntriesToTyposDef } from './Typos/index.mjs';
6
- import { extractAllSuggestions, extractIgnoreValues } from './Typos/util.mjs';
2
+ import { createAutoResolveWeakCache } from '../util/AutoResolve.js';
3
+ import { mapperRemoveCaseAndAccents } from '../util/textMappers.js';
4
+ import * as defaults from './defaults.js';
5
+ import { processEntriesToTyposDef } from './Typos/index.js';
6
+ import { extractAllSuggestions, extractIgnoreValues } from './Typos/util.js';
7
7
  class TyposDictionaryImpl {
8
8
  constructor(name, source, typosDef, ignoreList) {
9
9
  this.name = name;
@@ -1,10 +1,10 @@
1
- import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs';
2
- import { isDefined } from '../util/util.mjs';
3
- import { createSpellingDictionary } from './createSpellingDictionary.mjs';
4
- import { createFlagWordsDictionary } from './FlagWordsDictionary.mjs';
5
- import { createIgnoreWordsDictionary } from './IgnoreWordsDictionary.mjs';
6
- import { createCollection } from './SpellingDictionaryCollection.mjs';
7
- import { createSuggestDictionary } from './SuggestDictionary.mjs';
1
+ import { createAutoResolveWeakCache } from '../util/AutoResolve.js';
2
+ import { isDefined } from '../util/util.js';
3
+ import { createSpellingDictionary } from './createSpellingDictionary.js';
4
+ import { createFlagWordsDictionary } from './FlagWordsDictionary.js';
5
+ import { createIgnoreWordsDictionary } from './IgnoreWordsDictionary.js';
6
+ import { createCollection } from './SpellingDictionaryCollection.js';
7
+ import { createSuggestDictionary } from './SuggestDictionary.js';
8
8
  const cache = createAutoResolveWeakCache();
9
9
  export function createInlineSpellingDictionary(inlineDict, source) {
10
10
  return cache.get(inlineDict, () => {
@@ -1,9 +1,9 @@
1
1
  import { buildTrieFast, parseDictionaryLines } from 'cspell-trie-lib';
2
2
  import { deepEqual } from 'fast-equals';
3
- import { AutoWeakCache, SimpleCache } from '../util/simpleCache.mjs';
4
- import { defaultOptions } from './SpellingDictionary.mjs';
5
- import { SpellingDictionaryFromTrie } from './SpellingDictionaryFromTrie.mjs';
6
- import { createWeightMapFromDictionaryInformation } from './SpellingDictionaryMethods.mjs';
3
+ import { AutoWeakCache, SimpleCache } from '../util/simpleCache.js';
4
+ import { defaultOptions } from './SpellingDictionary.js';
5
+ import { SpellingDictionaryFromTrie } from './SpellingDictionaryFromTrie.js';
6
+ import { createWeightMapFromDictionaryInformation } from './SpellingDictionaryMethods.js';
7
7
  const cachedDictionaries = new AutoWeakCache(_createSpellingDictionary, 64);
8
8
  const maxSetSize = 3;
9
9
  const cachedParamsByWordList = new SimpleCache(64);
@@ -1,9 +1,9 @@
1
- export { createCachingDictionary } from './CachingDictionary.mjs';
2
- export { createInlineSpellingDictionary } from './createInlineSpellingDictionary.mjs';
3
- export { createFailedToLoadDictionary, createSpellingDictionary } from './createSpellingDictionary.mjs';
4
- export { createFlagWordsDictionary, createFlagWordsDictionary as createForbiddenWordsDictionary, } from './FlagWordsDictionary.mjs';
5
- export { createIgnoreWordsDictionary } from './IgnoreWordsDictionary.mjs';
6
- export { createCollection } from './SpellingDictionaryCollection.mjs';
7
- export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie.mjs';
8
- export { createSuggestDictionary } from './SuggestDictionary.mjs';
9
- export { createTyposDictionary } from './TyposDictionary.mjs';
1
+ export { 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 { createCollection } from './SpellingDictionaryCollection.js';
7
+ export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie.js';
8
+ export { createSuggestDictionary } from './SuggestDictionary.js';
9
+ export { createTyposDictionary } from './TyposDictionary.js';
@@ -1 +1 @@
1
- export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, } from './SpellingDictionary/index.mjs';
1
+ export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, } from './SpellingDictionary/index.js';
@@ -1,6 +1,6 @@
1
1
  import { expandCharacterSet } from 'cspell-trie-lib';
2
- import { escapeRegEx } from './regexHelper.mjs';
3
- import { isDefined } from './util.mjs';
2
+ import { escapeRegEx } from './regexHelper.js';
3
+ import { isDefined } from './util.js';
4
4
  export function createMapper(repMap, ignoreCharset) {
5
5
  if (!repMap && !ignoreCharset)
6
6
  return (a) => a;
@@ -1,4 +1,4 @@
1
- import { removeAccents } from './text.mjs';
1
+ import { removeAccents } from './text.js';
2
2
  export function* mapperNormalizeNFC(words) {
3
3
  for (const word of words) {
4
4
  yield word.normalize('NFC');
package/package.json CHANGED
@@ -1,21 +1,17 @@
1
1
  {
2
2
  "name": "cspell-dictionary",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.1-alpha.0",
4
4
  "description": "A spelling dictionary library useful for checking words and getting suggestions.",
5
- "type": "commonjs",
6
- "main": "dist/cjs/index.js",
7
- "types": "dist/cjs/index.d.ts",
8
- "module": "dist/esm/index.mjs",
5
+ "type": "module",
6
+ "types": "dist/index.d.ts",
7
+ "module": "dist/index.js",
9
8
  "exports": {
10
9
  ".": {
11
- "import": "./dist/esm/index.mjs",
12
- "require": "./dist/cjs/index.js"
10
+ "import": "./dist/index.js"
13
11
  }
14
12
  },
15
13
  "files": [
16
14
  "dist",
17
- "!dist/esm/**/*.js",
18
- "!dist/esm/**/*.ts",
19
15
  "!**/*.tsbuildInfo",
20
16
  "!**/__mocks__",
21
17
  "!**/test/**",
@@ -24,9 +20,8 @@
24
20
  "!**/*.map"
25
21
  ],
26
22
  "scripts": {
27
- "clean": "shx rm -rf dist coverage .tsbuildinfo",
28
- "build": "tsc -b . && ts2mjs dist/esm",
29
- "build:esm": "tsc -p tsconfig.esm.json",
23
+ "clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
24
+ "build": "tsc -b .",
30
25
  "clean-build": "pnpm run clean && pnpm run build",
31
26
  "coverage": "pnpm coverage:vitest && pnpm coverage:fix",
32
27
  "coverage:vitest": "vitest run --coverage",
@@ -52,11 +47,11 @@
52
47
  "node": ">=16"
53
48
  },
54
49
  "dependencies": {
55
- "@cspell/cspell-pipe": "7.0.0-alpha.1",
56
- "@cspell/cspell-types": "7.0.0-alpha.1",
57
- "cspell-trie-lib": "7.0.0-alpha.1",
50
+ "@cspell/cspell-pipe": "7.0.1-alpha.0",
51
+ "@cspell/cspell-types": "7.0.1-alpha.0",
52
+ "cspell-trie-lib": "7.0.1-alpha.0",
58
53
  "fast-equals": "^4.0.3",
59
54
  "gensequence": "^5.0.2"
60
55
  },
61
- "gitHead": "626d1a01b413c1b6de0b386a5a264b78a10ba146"
56
+ "gitHead": "9ac874fd367a2858df9aab07fafad183347f2033"
62
57
  }
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createCachingDictionary = void 0;
4
- const AutoCache_js_1 = require("../util/AutoCache.js");
5
- const SpellingDictionaryMethods_js_1 = require("./SpellingDictionaryMethods.js");
6
- let dictionaryCounter = 0;
7
- const DefaultAutoCacheSize = 1000;
8
- class CachedDict {
9
- constructor(dict, options) {
10
- this.dict = dict;
11
- this.options = options;
12
- this.id = ++dictionaryCounter;
13
- this.has = (0, AutoCache_js_1.autoCache)((word) => this.dict.has(word, this.options), DefaultAutoCacheSize);
14
- this.isNoSuggestWord = (0, AutoCache_js_1.autoCache)((word) => this.dict.isNoSuggestWord(word, this.options), DefaultAutoCacheSize);
15
- this.isForbidden = (0, AutoCache_js_1.autoCache)((word) => this.dict.isForbidden(word), DefaultAutoCacheSize);
16
- this.getPreferredSuggestions = (0, AutoCache_js_1.autoCache)((word) => this.dict.getPreferredSuggestions?.(word), DefaultAutoCacheSize);
17
- this.name = dict.name;
18
- // console.log(`CachedDict for ${this.name}`);
19
- }
20
- stats() {
21
- return {
22
- name: this.name,
23
- id: this.id,
24
- has: (0, AutoCache_js_1.extractStats)(this.has),
25
- isNoSuggestWord: (0, AutoCache_js_1.extractStats)(this.isNoSuggestWord),
26
- isForbidden: (0, AutoCache_js_1.extractStats)(this.isForbidden),
27
- getPreferredSuggestions: (0, AutoCache_js_1.extractStats)(this.getPreferredSuggestions),
28
- };
29
- }
30
- }
31
- const knownDicts = new Map();
32
- /**
33
- * create a caching dictionary
34
- * @param dict - Dictionary to cache the search results.
35
- * @param options - Search options to use.
36
- * @returns CachingDictionary
37
- */
38
- function createCachingDictionary(dict, options) {
39
- options = (0, SpellingDictionaryMethods_js_1.canonicalSearchOptions)(options);
40
- let knownOptions = knownDicts.get(options);
41
- if (!knownOptions) {
42
- knownOptions = new WeakMap();
43
- knownDicts.set(options, knownOptions);
44
- }
45
- const known = knownOptions.get(dict);
46
- if (known)
47
- return known;
48
- const cached = new CachedDict(dict, options);
49
- knownOptions.set(dict, cached);
50
- return cached;
51
- }
52
- exports.createCachingDictionary = createCachingDictionary;
53
- //# sourceMappingURL=CachingDictionary.js.map
@@ -1,165 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.createFlagWordsDictionary = void 0;
27
- const sync_1 = require("@cspell/cspell-pipe/sync");
28
- const cspell_trie_lib_1 = require("cspell-trie-lib");
29
- const AutoResolve_js_1 = require("../util/AutoResolve.js");
30
- const Defaults = __importStar(require("./defaults.js"));
31
- const SpellingDictionary_js_1 = require("./SpellingDictionary.js");
32
- const SpellingDictionaryFromTrie_js_1 = require("./SpellingDictionaryFromTrie.js");
33
- const SpellingDictionaryMethods_js_1 = require("./SpellingDictionaryMethods.js");
34
- const TyposDictionary_js_1 = require("./TyposDictionary.js");
35
- class FlagWordsDictionaryTrie extends SpellingDictionaryFromTrie_js_1.SpellingDictionaryFromTrie {
36
- constructor(trie, name, source) {
37
- super(trie, name, SpellingDictionary_js_1.defaultOptions, source);
38
- this.name = name;
39
- this.source = source;
40
- this.containsNoSuggestWords = false;
41
- this.options = {};
42
- this.isDictionaryCaseSensitive = true;
43
- }
44
- /**
45
- * A Forbidden word list does not "have" valid words.
46
- * Therefore it always returns false.
47
- * @param _word - the word
48
- * @param _options - options
49
- * @returns always false
50
- */
51
- has(_word, _options) {
52
- return false;
53
- }
54
- find(word, hasOptions) {
55
- const f = super.find(word, hasOptions);
56
- if (!f || !f.forbidden)
57
- return undefined;
58
- return f;
59
- }
60
- suggest() {
61
- return [];
62
- }
63
- genSuggestions() {
64
- return;
65
- }
66
- }
67
- class FlagWordsDictionary {
68
- constructor(name, source, dictTypos, dictTrie) {
69
- this.name = name;
70
- this.source = source;
71
- this.dictTypos = dictTypos;
72
- this.dictTrie = dictTrie;
73
- this.containsNoSuggestWords = false;
74
- this.options = {};
75
- this.type = 'flag-words';
76
- this.isDictionaryCaseSensitive = true;
77
- }
78
- /**
79
- * A Forbidden word list does not "have" valid words.
80
- * Therefore it always returns false.
81
- * @param word - the word
82
- * @param options - options
83
- * @returns always false
84
- */
85
- has(word, options) {
86
- return this.dictTypos.has(word, options) || this.dictTrie?.has(word, options) || false;
87
- }
88
- /** A more detailed search for a word, might take longer than `has` */
89
- find(word, options) {
90
- const findTypos = this.dictTypos.find(word, options);
91
- if (findTypos)
92
- return findTypos;
93
- const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase;
94
- if (this.dictTypos.isSuggestedWord(word, ignoreCase))
95
- return undefined;
96
- return this.dictTrie?.find(word, options);
97
- }
98
- isForbidden(word, ignoreCaseAndAccents = Defaults.isForbiddenIgnoreCaseAndAccents) {
99
- const findResult = this.find(word, { ignoreCase: ignoreCaseAndAccents });
100
- return findResult?.forbidden || false;
101
- }
102
- isNoSuggestWord(word, options) {
103
- return this.dictTrie?.isNoSuggestWord(word, options) || this.dictTypos.isNoSuggestWord(word, options);
104
- }
105
- suggest(...args) {
106
- const [word] = args;
107
- const suggestOptions = (0, SpellingDictionaryMethods_js_1.suggestArgsToSuggestOptions)(args);
108
- return this.dictTypos.suggest(word, suggestOptions);
109
- }
110
- getPreferredSuggestions(word) {
111
- return this.dictTypos.getPreferredSuggestions(word);
112
- }
113
- genSuggestions() {
114
- return;
115
- }
116
- mapWord(word) {
117
- return word;
118
- }
119
- get size() {
120
- return this.dictTypos.size + (this.dictTrie?.size || 0);
121
- }
122
- getErrors() {
123
- return [];
124
- }
125
- }
126
- const createCache = (0, AutoResolve_js_1.createAutoResolveWeakCache)();
127
- /**
128
- * Create a dictionary where all words are to be forbidden.
129
- * @param wordList - list of words
130
- * @param name
131
- * @param source
132
- * @param options
133
- * @returns SpellingDictionary
134
- */
135
- function createFlagWordsDictionary(wordList, name, source) {
136
- return createCache.get(wordList, () => {
137
- const testSpecialCharacters = /[~*+]/;
138
- const { t: specialWords, f: typoWords } = bisect((0, cspell_trie_lib_1.parseDictionaryLines)(wordList, { stripCaseAndAccents: false }), (line) => testSpecialCharacters.test(line));
139
- const trieDict = specialWords.size ? buildTrieDict(specialWords, name, source) : undefined;
140
- const typosDict = (0, TyposDictionary_js_1.createTyposDictionary)(typoWords, name, source);
141
- if (!trieDict)
142
- return typosDict;
143
- return new FlagWordsDictionary(name, source, typosDict, trieDict);
144
- });
145
- }
146
- exports.createFlagWordsDictionary = createFlagWordsDictionary;
147
- const regExpCleanIgnore = /^(!!)+/;
148
- function buildTrieDict(words, name, source) {
149
- const trie = (0, cspell_trie_lib_1.buildTrieFast)((0, sync_1.pipe)(words, (0, sync_1.opMap)((w) => '!' + w), (0, sync_1.opMap)((w) => w.replace(regExpCleanIgnore, ''))));
150
- return new FlagWordsDictionaryTrie(trie, name, source);
151
- }
152
- function bisect(values, predicate) {
153
- const t = new Set();
154
- const f = new Set();
155
- for (const v of values) {
156
- if (predicate(v)) {
157
- t.add(v);
158
- }
159
- else {
160
- f.add(v);
161
- }
162
- }
163
- return { t, f };
164
- }
165
- //# sourceMappingURL=FlagWordsDictionary.js.map
@@ -1,124 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.createIgnoreWordsDictionary = void 0;
27
- const sync_1 = require("@cspell/cspell-pipe/sync");
28
- const cspell_trie_lib_1 = require("cspell-trie-lib");
29
- const AutoResolve_js_1 = require("../util/AutoResolve.js");
30
- const createSpellingDictionary_js_1 = require("./createSpellingDictionary.js");
31
- const Defaults = __importStar(require("./defaults.js"));
32
- const NormalizeForm = 'NFC';
33
- class IgnoreWordsDictionary {
34
- constructor(name, source, words) {
35
- this.name = name;
36
- this.source = source;
37
- this.containsNoSuggestWords = true;
38
- this.options = {};
39
- this.type = 'ignore';
40
- this.isDictionaryCaseSensitive = true;
41
- this.dict = new Set(words);
42
- this.dictNonStrict = new Set((0, sync_1.pipe)(this.dict, (0, sync_1.opFilter)((w) => w.startsWith('~')), (0, sync_1.opMap)((w) => w.slice(1))));
43
- }
44
- /**
45
- * A Forbidden word list does not "have" valid words.
46
- * Therefore it always returns false.
47
- * @param _word - the word
48
- * @param _options - options
49
- * @returns always false
50
- */
51
- has(word, options) {
52
- const nWord = word.normalize(NormalizeForm);
53
- if (this.dict.has(nWord))
54
- return true;
55
- const lcWord = nWord.toLowerCase();
56
- if (this.dict.has(lcWord))
57
- return true;
58
- const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase;
59
- return ignoreCase && (this.dictNonStrict.has(nWord) || this.dictNonStrict.has(lcWord));
60
- }
61
- /** A more detailed search for a word, might take longer than `has` */
62
- find(word, options) {
63
- const nWord = word.normalize(NormalizeForm);
64
- if (this.dict.has(nWord))
65
- return { found: nWord, forbidden: false, noSuggest: true };
66
- const lcWord = nWord.toLowerCase();
67
- if (this.dict.has(lcWord))
68
- return { found: lcWord, forbidden: false, noSuggest: true };
69
- const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase;
70
- if (!ignoreCase)
71
- return undefined;
72
- if (this.dictNonStrict.has(nWord))
73
- return { found: nWord, forbidden: false, noSuggest: true };
74
- return (this.dictNonStrict.has(lcWord) && { found: lcWord, forbidden: false, noSuggest: true }) || undefined;
75
- }
76
- isForbidden(_word, _ignoreCase) {
77
- return false;
78
- }
79
- isNoSuggestWord(word, options) {
80
- return this.has(word, options);
81
- }
82
- suggest() {
83
- return [];
84
- }
85
- genSuggestions() {
86
- return;
87
- }
88
- mapWord(word) {
89
- return word;
90
- }
91
- get size() {
92
- return this.dict.size;
93
- }
94
- getErrors() {
95
- return [];
96
- }
97
- }
98
- const createCache = (0, AutoResolve_js_1.createAutoResolveWeakCache)();
99
- /**
100
- * Create a dictionary where all words are to be ignored.
101
- * Ignored words override forbidden words.
102
- * @param wordList - list of words
103
- * @param name - name of dictionary
104
- * @param source - dictionary source
105
- * @returns
106
- */
107
- function createIgnoreWordsDictionary(wordList, name, source) {
108
- return createCache.get(wordList, () => {
109
- const testSpecialCharacters = /[*+]/;
110
- const words = [...(0, cspell_trie_lib_1.parseDictionaryLines)(wordList, { stripCaseAndAccents: true })].map((w) => w.normalize(NormalizeForm));
111
- const hasSpecial = words.findIndex((word) => testSpecialCharacters.test(word)) >= 0;
112
- if (hasSpecial) {
113
- return (0, createSpellingDictionary_js_1.createSpellingDictionary)(words, name, source, {
114
- caseSensitive: true,
115
- noSuggest: true,
116
- weightMap: undefined,
117
- supportNonStrictSearches: true,
118
- });
119
- }
120
- return new IgnoreWordsDictionary(name, source, words);
121
- });
122
- }
123
- exports.createIgnoreWordsDictionary = createIgnoreWordsDictionary;
124
- //# sourceMappingURL=IgnoreWordsDictionary.js.map
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultOptions = exports.CompoundWordsMethod = void 0;
4
- var cspell_trie_lib_1 = require("cspell-trie-lib");
5
- Object.defineProperty(exports, "CompoundWordsMethod", { enumerable: true, get: function () { return cspell_trie_lib_1.CompoundWordsMethod; } });
6
- exports.defaultOptions = Object.freeze({
7
- weightMap: undefined,
8
- });
9
- //# sourceMappingURL=SpellingDictionary.js.map