cspell-lib 8.13.0 → 8.13.2

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 (258) hide show
  1. package/dist/{esm → lib}/Settings/Controller/configLoader/configLoader.js +1 -1
  2. package/dist/{esm → lib}/Settings/DefaultSettings.js +1 -1
  3. package/dist/{lib-cjs/pkg-info.d.cts → lib/pkg-info.d.mts} +1 -1
  4. package/dist/lib/pkg-info.mjs +15 -0
  5. package/dist/{esm → lib}/textValidation/ValidationTypes.d.ts +2 -0
  6. package/dist/lib/textValidation/isWordValid.d.ts +11 -0
  7. package/dist/lib/textValidation/lineValidatorFactory.js +271 -0
  8. package/dist/{esm → lib}/util/TextRange.d.ts +3 -8
  9. package/dist/{esm → lib}/util/TextRange.js +43 -34
  10. package/dist/{esm → lib}/util/resolveFile.js +1 -1
  11. package/dist/{esm → lib}/util/text.d.ts +6 -1
  12. package/dist/{esm → lib}/util/text.js +19 -14
  13. package/dist/{esm → lib}/util/textRegex.d.ts +2 -0
  14. package/dist/{esm → lib}/util/textRegex.js +3 -1
  15. package/dist/{esm → lib}/util/url.js +1 -1
  16. package/dist/{esm → lib}/util/wordSplitter.d.ts +1 -1
  17. package/dist/{esm → lib}/util/wordSplitter.js +4 -4
  18. package/dist/lib/util/wordSplitter.perf.d.ts +2 -0
  19. package/dist/lib/util/wordSplitter.perf.js +125 -0
  20. package/package.json +26 -26
  21. package/dist/esm/textValidation/isWordValid.d.ts +0 -9
  22. package/dist/esm/textValidation/lineValidatorFactory.js +0 -128
  23. package/dist/lib-cjs/index.cjs +0 -10
  24. package/dist/lib-cjs/index.d.cts +0 -6
  25. package/dist/lib-cjs/pkg-info.cjs +0 -7
  26. /package/dist/{esm → lib}/Cache/cspell.cache.d.ts +0 -0
  27. /package/dist/{esm → lib}/Cache/cspell.cache.js +0 -0
  28. /package/dist/{esm → lib}/Cache/index.d.ts +0 -0
  29. /package/dist/{esm → lib}/Cache/index.js +0 -0
  30. /package/dist/{esm → lib}/Document/Document.d.ts +0 -0
  31. /package/dist/{esm → lib}/Document/Document.js +0 -0
  32. /package/dist/{esm → lib}/Document/index.d.ts +0 -0
  33. /package/dist/{esm → lib}/Document/index.js +0 -0
  34. /package/dist/{esm → lib}/Document/isBinaryDoc.d.ts +0 -0
  35. /package/dist/{esm → lib}/Document/isBinaryDoc.js +0 -0
  36. /package/dist/{esm → lib}/Document/normalizeLanguageIds.d.ts +0 -0
  37. /package/dist/{esm → lib}/Document/normalizeLanguageIds.js +0 -0
  38. /package/dist/{esm → lib}/Document/resolveDocument.d.ts +0 -0
  39. /package/dist/{esm → lib}/Document/resolveDocument.js +0 -0
  40. /package/dist/{esm → lib}/FeatureFlags/FeatureFlags.d.ts +0 -0
  41. /package/dist/{esm → lib}/FeatureFlags/FeatureFlags.js +0 -0
  42. /package/dist/{esm → lib}/FeatureFlags/index.d.ts +0 -0
  43. /package/dist/{esm → lib}/FeatureFlags/index.js +0 -0
  44. /package/dist/{esm → lib}/LanguageIds.d.ts +0 -0
  45. /package/dist/{esm → lib}/LanguageIds.js +0 -0
  46. /package/dist/{esm → lib}/Models/CSpellSettingsInternalDef.d.ts +0 -0
  47. /package/dist/{esm → lib}/Models/CSpellSettingsInternalDef.js +0 -0
  48. /package/dist/{esm → lib}/Models/PatternRegExp.d.ts +0 -0
  49. /package/dist/{esm → lib}/Models/PatternRegExp.js +0 -0
  50. /package/dist/{esm → lib}/Models/Suggestion.d.ts +0 -0
  51. /package/dist/{esm → lib}/Models/Suggestion.js +0 -0
  52. /package/dist/{esm → lib}/Models/TextDocument.d.ts +0 -0
  53. /package/dist/{esm → lib}/Models/TextDocument.js +0 -0
  54. /package/dist/{esm → lib}/Models/ValidationIssue.d.ts +0 -0
  55. /package/dist/{esm → lib}/Models/ValidationIssue.js +0 -0
  56. /package/dist/{esm → lib}/Models/ValidationResult.d.ts +0 -0
  57. /package/dist/{esm → lib}/Models/ValidationResult.js +0 -0
  58. /package/dist/{esm → lib}/Settings/CSpellSettingsServer.d.ts +0 -0
  59. /package/dist/{esm → lib}/Settings/CSpellSettingsServer.js +0 -0
  60. /package/dist/{esm → lib}/Settings/Controller/ImportError.d.ts +0 -0
  61. /package/dist/{esm → lib}/Settings/Controller/ImportError.js +0 -0
  62. /package/dist/{esm → lib}/Settings/Controller/configLoader/PnPSettings.d.ts +0 -0
  63. /package/dist/{esm → lib}/Settings/Controller/configLoader/PnPSettings.js +0 -0
  64. /package/dist/{esm → lib}/Settings/Controller/configLoader/configLoader.d.ts +0 -0
  65. /package/dist/{esm → lib}/Settings/Controller/configLoader/configLocations.d.ts +0 -0
  66. /package/dist/{esm → lib}/Settings/Controller/configLoader/configLocations.js +0 -0
  67. /package/dist/{esm → lib}/Settings/Controller/configLoader/configSearch.d.ts +0 -0
  68. /package/dist/{esm → lib}/Settings/Controller/configLoader/configSearch.js +0 -0
  69. /package/dist/{esm → lib}/Settings/Controller/configLoader/configToRawSettings.d.ts +0 -0
  70. /package/dist/{esm → lib}/Settings/Controller/configLoader/configToRawSettings.js +0 -0
  71. /package/dist/{esm → lib}/Settings/Controller/configLoader/defaultConfigLoader.d.ts +0 -0
  72. /package/dist/{esm → lib}/Settings/Controller/configLoader/defaultConfigLoader.js +0 -0
  73. /package/dist/{esm → lib}/Settings/Controller/configLoader/defaultSettings.d.ts +0 -0
  74. /package/dist/{esm → lib}/Settings/Controller/configLoader/defaultSettings.js +0 -0
  75. /package/dist/{esm → lib}/Settings/Controller/configLoader/extractImportErrors.d.ts +0 -0
  76. /package/dist/{esm → lib}/Settings/Controller/configLoader/extractImportErrors.js +0 -0
  77. /package/dist/{esm → lib}/Settings/Controller/configLoader/index.d.ts +0 -0
  78. /package/dist/{esm → lib}/Settings/Controller/configLoader/index.js +0 -0
  79. /package/dist/{esm → lib}/Settings/Controller/configLoader/normalizeRawSettings.d.ts +0 -0
  80. /package/dist/{esm → lib}/Settings/Controller/configLoader/normalizeRawSettings.js +0 -0
  81. /package/dist/{esm → lib}/Settings/Controller/configLoader/readSettings.d.ts +0 -0
  82. /package/dist/{esm → lib}/Settings/Controller/configLoader/readSettings.js +0 -0
  83. /package/dist/{esm → lib}/Settings/Controller/configLoader/readSettingsFiles.d.ts +0 -0
  84. /package/dist/{esm → lib}/Settings/Controller/configLoader/readSettingsFiles.js +0 -0
  85. /package/dist/{esm → lib}/Settings/Controller/configLoader/toGlobDef.d.ts +0 -0
  86. /package/dist/{esm → lib}/Settings/Controller/configLoader/toGlobDef.js +0 -0
  87. /package/dist/{esm → lib}/Settings/Controller/configLoader/types.d.ts +0 -0
  88. /package/dist/{esm → lib}/Settings/Controller/configLoader/types.js +0 -0
  89. /package/dist/{esm → lib}/Settings/Controller/index.d.ts +0 -0
  90. /package/dist/{esm → lib}/Settings/Controller/index.js +0 -0
  91. /package/dist/{esm → lib}/Settings/Controller/pnpLoader.d.ts +0 -0
  92. /package/dist/{esm → lib}/Settings/Controller/pnpLoader.js +0 -0
  93. /package/dist/{esm → lib}/Settings/DefaultSettings.d.ts +0 -0
  94. /package/dist/{esm → lib}/Settings/DictionaryReferenceCollection.d.ts +0 -0
  95. /package/dist/{esm → lib}/Settings/DictionaryReferenceCollection.js +0 -0
  96. /package/dist/{esm → lib}/Settings/DictionarySettings.d.ts +0 -0
  97. /package/dist/{esm → lib}/Settings/DictionarySettings.js +0 -0
  98. /package/dist/{esm → lib}/Settings/GlobalSettings.d.ts +0 -0
  99. /package/dist/{esm → lib}/Settings/GlobalSettings.js +0 -0
  100. /package/dist/{esm → lib}/Settings/InDocSettings.d.ts +0 -0
  101. /package/dist/{esm → lib}/Settings/InDocSettings.js +0 -0
  102. /package/dist/{esm → lib}/Settings/LanguageSettings.d.ts +0 -0
  103. /package/dist/{esm → lib}/Settings/LanguageSettings.js +0 -0
  104. /package/dist/{esm → lib}/Settings/RegExpPatterns.d.ts +0 -0
  105. /package/dist/{esm → lib}/Settings/RegExpPatterns.js +0 -0
  106. /package/dist/{esm → lib}/Settings/TextDocumentSettings.d.ts +0 -0
  107. /package/dist/{esm → lib}/Settings/TextDocumentSettings.js +0 -0
  108. /package/dist/{esm → lib}/Settings/calcOverrideSettings.d.ts +0 -0
  109. /package/dist/{esm → lib}/Settings/calcOverrideSettings.js +0 -0
  110. /package/dist/{esm → lib}/Settings/cfgStore.d.ts +0 -0
  111. /package/dist/{esm → lib}/Settings/cfgStore.js +0 -0
  112. /package/dist/{esm → lib}/Settings/checkFilenameMatchesGlob.d.ts +0 -0
  113. /package/dist/{esm → lib}/Settings/checkFilenameMatchesGlob.js +0 -0
  114. /package/dist/{esm → lib}/Settings/constants.d.ts +0 -0
  115. /package/dist/{esm → lib}/Settings/constants.js +0 -0
  116. /package/dist/{esm → lib}/Settings/index.d.ts +0 -0
  117. /package/dist/{esm → lib}/Settings/index.js +0 -0
  118. /package/dist/{esm → lib}/Settings/index.link.d.ts +0 -0
  119. /package/dist/{esm → lib}/Settings/index.link.js +0 -0
  120. /package/dist/{esm → lib}/Settings/link.d.ts +0 -0
  121. /package/dist/{esm → lib}/Settings/link.js +0 -0
  122. /package/dist/{esm → lib}/Settings/mergeCache.d.ts +0 -0
  123. /package/dist/{esm → lib}/Settings/mergeCache.js +0 -0
  124. /package/dist/{esm → lib}/Settings/mergeList.d.ts +0 -0
  125. /package/dist/{esm → lib}/Settings/mergeList.js +0 -0
  126. /package/dist/{esm → lib}/Settings/patterns.d.ts +0 -0
  127. /package/dist/{esm → lib}/Settings/patterns.js +0 -0
  128. /package/dist/{esm → lib}/SpellingDictionary/Dictionaries.d.ts +0 -0
  129. /package/dist/{esm → lib}/SpellingDictionary/Dictionaries.js +0 -0
  130. /package/dist/{esm → lib}/SpellingDictionary/DictionaryController/DictionaryLoader.d.ts +0 -0
  131. /package/dist/{esm → lib}/SpellingDictionary/DictionaryController/DictionaryLoader.js +0 -0
  132. /package/dist/{esm → lib}/SpellingDictionary/DictionaryController/index.d.ts +0 -0
  133. /package/dist/{esm → lib}/SpellingDictionary/DictionaryController/index.js +0 -0
  134. /package/dist/{esm → lib}/SpellingDictionary/DictionaryLoader.d.ts +0 -0
  135. /package/dist/{esm → lib}/SpellingDictionary/DictionaryLoader.js +0 -0
  136. /package/dist/{esm → lib}/SpellingDictionary/SpellingDictionary.d.ts +0 -0
  137. /package/dist/{esm → lib}/SpellingDictionary/SpellingDictionary.js +0 -0
  138. /package/dist/{esm → lib}/SpellingDictionary/SpellingDictionaryError.d.ts +0 -0
  139. /package/dist/{esm → lib}/SpellingDictionary/SpellingDictionaryError.js +0 -0
  140. /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/SuggestionCollector.d.ts +0 -0
  141. /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/SuggestionCollector.js +0 -0
  142. /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/entities.d.ts +0 -0
  143. /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/entities.js +0 -0
  144. /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/helpers.d.ts +0 -0
  145. /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/helpers.js +0 -0
  146. /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/suggest.d.ts +0 -0
  147. /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/suggest.js +0 -0
  148. /package/dist/{esm → lib}/SpellingDictionary/index.d.ts +0 -0
  149. /package/dist/{esm → lib}/SpellingDictionary/index.js +0 -0
  150. /package/dist/{esm → lib}/clearCachedFiles.d.ts +0 -0
  151. /package/dist/{esm → lib}/clearCachedFiles.js +0 -0
  152. /package/dist/{esm → lib}/events/events.d.ts +0 -0
  153. /package/dist/{esm → lib}/events/events.js +0 -0
  154. /package/dist/{esm → lib}/events/index.d.ts +0 -0
  155. /package/dist/{esm → lib}/events/index.js +0 -0
  156. /package/dist/{esm → lib}/exclusionHelper.d.ts +0 -0
  157. /package/dist/{esm → lib}/exclusionHelper.js +0 -0
  158. /package/dist/{esm → lib}/fileSystem.d.ts +0 -0
  159. /package/dist/{esm → lib}/fileSystem.js +0 -0
  160. /package/dist/{esm → lib}/getDictionary.d.ts +0 -0
  161. /package/dist/{esm → lib}/getDictionary.js +0 -0
  162. /package/dist/{esm → lib}/globs/checkFilenameMatchesGlob.d.ts +0 -0
  163. /package/dist/{esm → lib}/globs/checkFilenameMatchesGlob.js +0 -0
  164. /package/dist/{esm → lib}/globs/getGlobMatcher.d.ts +0 -0
  165. /package/dist/{esm → lib}/globs/getGlobMatcher.js +0 -0
  166. /package/dist/{esm → lib}/index.d.ts +0 -0
  167. /package/dist/{esm → lib}/index.js +0 -0
  168. /package/dist/{esm → lib}/perf/index.d.ts +0 -0
  169. /package/dist/{esm → lib}/perf/index.js +0 -0
  170. /package/dist/{esm → lib}/perf/perf.d.ts +0 -0
  171. /package/dist/{esm → lib}/perf/perf.js +0 -0
  172. /package/dist/{esm → lib}/perf/timer.d.ts +0 -0
  173. /package/dist/{esm → lib}/perf/timer.js +0 -0
  174. /package/dist/{esm → lib}/spellCheckFile.d.ts +0 -0
  175. /package/dist/{esm → lib}/spellCheckFile.js +0 -0
  176. /package/dist/{esm → lib}/suggestions.d.ts +0 -0
  177. /package/dist/{esm → lib}/suggestions.js +0 -0
  178. /package/dist/{esm → lib}/textValidation/ValidateTextOptions.d.ts +0 -0
  179. /package/dist/{esm → lib}/textValidation/ValidateTextOptions.js +0 -0
  180. /package/dist/{esm → lib}/textValidation/ValidationTypes.js +0 -0
  181. /package/dist/{esm → lib}/textValidation/checkText.d.ts +0 -0
  182. /package/dist/{esm → lib}/textValidation/checkText.js +0 -0
  183. /package/dist/{esm → lib}/textValidation/defaultConstants.d.ts +0 -0
  184. /package/dist/{esm → lib}/textValidation/defaultConstants.js +0 -0
  185. /package/dist/{esm → lib}/textValidation/determineTextDocumentSettings.d.ts +0 -0
  186. /package/dist/{esm → lib}/textValidation/determineTextDocumentSettings.js +0 -0
  187. /package/dist/{esm → lib}/textValidation/docValidator.d.ts +0 -0
  188. /package/dist/{esm → lib}/textValidation/docValidator.js +0 -0
  189. /package/dist/{esm → lib}/textValidation/index.d.ts +0 -0
  190. /package/dist/{esm → lib}/textValidation/index.js +0 -0
  191. /package/dist/{esm → lib}/textValidation/isWordValid.js +0 -0
  192. /package/dist/{esm → lib}/textValidation/lineValidatorFactory.d.ts +0 -0
  193. /package/dist/{esm → lib}/textValidation/parsedText.d.ts +0 -0
  194. /package/dist/{esm → lib}/textValidation/parsedText.js +0 -0
  195. /package/dist/{esm → lib}/textValidation/settingsToValidateOptions.d.ts +0 -0
  196. /package/dist/{esm → lib}/textValidation/settingsToValidateOptions.js +0 -0
  197. /package/dist/{esm → lib}/textValidation/textValidator.d.ts +0 -0
  198. /package/dist/{esm → lib}/textValidation/textValidator.js +0 -0
  199. /package/dist/{esm → lib}/textValidation/traceWord.d.ts +0 -0
  200. /package/dist/{esm → lib}/textValidation/traceWord.js +0 -0
  201. /package/dist/{esm → lib}/textValidation/validator.d.ts +0 -0
  202. /package/dist/{esm → lib}/textValidation/validator.js +0 -0
  203. /package/dist/{esm → lib}/trace.d.ts +0 -0
  204. /package/dist/{esm → lib}/trace.js +0 -0
  205. /package/dist/{esm → lib}/util/AutoResolve.d.ts +0 -0
  206. /package/dist/{esm → lib}/util/AutoResolve.js +0 -0
  207. /package/dist/{esm → lib}/util/AutoResolveLRUCache.d.ts +0 -0
  208. /package/dist/{esm → lib}/util/AutoResolveLRUCache.js +0 -0
  209. /package/dist/{esm → lib}/util/Comparable.d.ts +0 -0
  210. /package/dist/{esm → lib}/util/Comparable.js +0 -0
  211. /package/dist/{esm → lib}/util/FreqCounter.d.ts +0 -0
  212. /package/dist/{esm → lib}/util/FreqCounter.js +0 -0
  213. /package/dist/{esm → lib}/util/IterableLike.d.ts +0 -0
  214. /package/dist/{esm → lib}/util/IterableLike.js +0 -0
  215. /package/dist/{esm → lib}/util/MinHeapQueue.d.ts +0 -0
  216. /package/dist/{esm → lib}/util/MinHeapQueue.js +0 -0
  217. /package/dist/{esm → lib}/util/PairingHeap.d.ts +0 -0
  218. /package/dist/{esm → lib}/util/PairingHeap.js +0 -0
  219. /package/dist/{esm → lib}/util/TextMap.d.ts +0 -0
  220. /package/dist/{esm → lib}/util/TextMap.js +0 -0
  221. /package/dist/{esm → lib}/util/Uri.d.ts +0 -0
  222. /package/dist/{esm → lib}/util/Uri.js +0 -0
  223. /package/dist/{esm → lib}/util/errors.d.ts +0 -0
  224. /package/dist/{esm → lib}/util/errors.js +0 -0
  225. /package/dist/{esm → lib}/util/fileReader.d.ts +0 -0
  226. /package/dist/{esm → lib}/util/fileReader.js +0 -0
  227. /package/dist/{esm → lib}/util/findUp.d.ts +0 -0
  228. /package/dist/{esm → lib}/util/findUp.js +0 -0
  229. /package/dist/{esm → lib}/util/findUpFromUrl.d.ts +0 -0
  230. /package/dist/{esm → lib}/util/findUpFromUrl.js +0 -0
  231. /package/dist/{esm → lib}/util/iterableIteratorLib.d.ts +0 -0
  232. /package/dist/{esm → lib}/util/iterableIteratorLib.js +0 -0
  233. /package/dist/{esm → lib}/util/logger.d.ts +0 -0
  234. /package/dist/{esm → lib}/util/logger.js +0 -0
  235. /package/dist/{esm → lib}/util/memorizeLastCall.d.ts +0 -0
  236. /package/dist/{esm → lib}/util/memorizeLastCall.js +0 -0
  237. /package/dist/{esm → lib}/util/memorizerWeak.d.ts +0 -0
  238. /package/dist/{esm → lib}/util/memorizerWeak.js +0 -0
  239. /package/dist/{esm → lib}/util/regexHelper.d.ts +0 -0
  240. /package/dist/{esm → lib}/util/regexHelper.js +0 -0
  241. /package/dist/{esm → lib}/util/repMap.d.ts +0 -0
  242. /package/dist/{esm → lib}/util/repMap.js +0 -0
  243. /package/dist/{esm → lib}/util/resolveFile.d.ts +0 -0
  244. /package/dist/{esm → lib}/util/search.d.ts +0 -0
  245. /package/dist/{esm → lib}/util/search.js +0 -0
  246. /package/dist/{esm → lib}/util/simpleCache.d.ts +0 -0
  247. /package/dist/{esm → lib}/util/simpleCache.js +0 -0
  248. /package/dist/{esm → lib}/util/templates.d.ts +0 -0
  249. /package/dist/{esm → lib}/util/templates.js +0 -0
  250. /package/dist/{esm → lib}/util/types.d.ts +0 -0
  251. /package/dist/{esm → lib}/util/types.js +0 -0
  252. /package/dist/{esm → lib}/util/url.d.ts +0 -0
  253. /package/dist/{esm → lib}/util/util.d.ts +0 -0
  254. /package/dist/{esm → lib}/util/util.js +0 -0
  255. /package/dist/{esm → lib}/validator.d.ts +0 -0
  256. /package/dist/{esm → lib}/validator.js +0 -0
  257. /package/dist/{esm → lib}/wordListHelper.d.ts +0 -0
  258. /package/dist/{esm → lib}/wordListHelper.js +0 -0
@@ -4,10 +4,10 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
4
4
  import { createReaderWriter, CSpellConfigFileInMemory } from 'cspell-config-lib';
5
5
  import { isUrlLike, toFileURL } from 'cspell-io';
6
6
  import { URI, Utils as UriUtils } from 'vscode-uri';
7
- import { srcDirectory } from '../../../../lib-cjs/index.cjs';
8
7
  import { onClearCache } from '../../../events/index.js';
9
8
  import { getVirtualFS } from '../../../fileSystem.js';
10
9
  import { createCSpellSettingsInternal as csi } from '../../../Models/CSpellSettingsInternalDef.js';
10
+ import { srcDirectory } from '../../../pkg-info.mjs';
11
11
  import { autoResolve, AutoResolveCache, autoResolveWeak } from '../../../util/AutoResolve.js';
12
12
  import { logError, logWarning } from '../../../util/logger.js';
13
13
  import { FileResolver } from '../../../util/resolveFile.js';
@@ -1,7 +1,7 @@
1
1
  import { parsers } from 'cspell-grammar';
2
- import { srcDirectory } from '../../lib-cjs/index.cjs';
3
2
  import { createCSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.js';
4
3
  import { PatternRegExp } from '../Models/PatternRegExp.js';
4
+ import { srcDirectory } from '../pkg-info.mjs';
5
5
  import { resolveFile } from '../util/resolveFile.js';
6
6
  import { defaultConfigFileModuleRef } from './constants.js';
7
7
  import { readSettings } from './Controller/configLoader/index.js';
@@ -1,2 +1,2 @@
1
1
  export declare const srcDirectory: string;
2
- //# sourceMappingURL=pkg-info.d.cts.map
2
+ //# sourceMappingURL=pkg-info.d.mts.map
@@ -0,0 +1,15 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ /**
3
+ * This is the url of the current file, but it might be undefined if the environment does not support it.
4
+ */
5
+ const url = import.meta.url;
6
+ function calcSrcDirectory() {
7
+ try {
8
+ return __dirname;
9
+ }
10
+ catch {
11
+ return url ? fileURLToPath(new URL('./', url)) : process.cwd();
12
+ }
13
+ }
14
+ export const srcDirectory = calcSrcDirectory();
15
+ //# sourceMappingURL=pkg-info.mjs.map
@@ -28,7 +28,9 @@ export interface WordRangeAcc {
28
28
  export type ValidationIssueRO = Readonly<ValidationIssue>;
29
29
  export type LineValidatorFn = (line: LineSegment) => Iterable<ValidationIssue>;
30
30
  export interface LineSegment {
31
+ /** A line from the document, the offset is relative to the beginning of the document. */
31
32
  line: TextOffsetRO;
33
+ /** A segment of text from the line, the offset is relative to the beginning of the document. */
32
34
  segment: TextOffsetRO;
33
35
  }
34
36
  export interface MappedTextValidationResult extends MappedText {
@@ -0,0 +1,11 @@
1
+ import type { TextOffsetRO } from './ValidationTypes.js';
2
+ interface Dict {
3
+ has(word: string): boolean;
4
+ }
5
+ declare function hasWordCheck(dict: Dict, word: string): boolean;
6
+ export declare function isWordValidWithEscapeRetry(dict: Dict, wo: TextOffsetRO, line: TextOffsetRO): boolean;
7
+ export declare const __testing__: {
8
+ hasWordCheck: typeof hasWordCheck;
9
+ };
10
+ export {};
11
+ //# sourceMappingURL=isWordValid.d.ts.map
@@ -0,0 +1,271 @@
1
+ import assert from 'node:assert';
2
+ import { opConcatMap, opFilter, pipe } from '@cspell/cspell-pipe/sync';
3
+ import { createCachingDictionary } from 'cspell-dictionary';
4
+ import * as RxPat from '../Settings/RegExpPatterns.js';
5
+ import { extractPossibleWordsFromTextOffset, extractText, extractWordsFromCodeTextOffset, extractWordsFromTextOffset, } from '../util/text.js';
6
+ import { split } from '../util/wordSplitter.js';
7
+ import { defaultMinWordLength } from './defaultConstants.js';
8
+ import { isWordValidWithEscapeRetry } from './isWordValid.js';
9
+ import { mapRangeBackToOriginalPos } from './parsedText.js';
10
+ export function lineValidatorFactory(sDict, options) {
11
+ const { minWordLength = defaultMinWordLength, flagWords = [], allowCompoundWords = false, ignoreCase = true, } = options;
12
+ const hasWordOptions = {
13
+ ignoreCase,
14
+ useCompounds: allowCompoundWords || undefined, // let the dictionaries decide on useCompounds if allow is false
15
+ };
16
+ const dictCol = createCachingDictionary(sDict, hasWordOptions);
17
+ const knownWords = new Map();
18
+ const setOfFlagWords = new Set(flagWords);
19
+ const setOfKnownIssues = new Map();
20
+ const setOfKnownSuccessfulWords = new Set();
21
+ const rememberFilter = (fn) => (v) => {
22
+ const keep = fn(v);
23
+ if (!keep) {
24
+ setOfKnownSuccessfulWords.add(v.text);
25
+ }
26
+ return keep;
27
+ };
28
+ const filterAlreadyChecked = (wo) => {
29
+ return !setOfKnownSuccessfulWords.has(wo.text);
30
+ };
31
+ const hasDict = {
32
+ has(word) {
33
+ const info = getWordInfo(word);
34
+ if (info.isFound !== undefined)
35
+ return info.isFound;
36
+ if (info.isFlagged)
37
+ return true;
38
+ if (info.isFlagged)
39
+ return false;
40
+ info.isFound = dictCol.has(word);
41
+ return info.isFound;
42
+ },
43
+ };
44
+ function calcIgnored(info) {
45
+ info.isIgnored ??= dictCol.isNoSuggestWord(info.word);
46
+ return info.isIgnored;
47
+ }
48
+ function calcFlagged(info) {
49
+ if (info.isFlagged !== undefined)
50
+ return info.isFlagged;
51
+ const word = info.word;
52
+ info.isFlagged =
53
+ (setOfFlagWords.has(word) || setOfFlagWords.has(word.toLowerCase()) || dictCol.isForbidden(word)) &&
54
+ !calcIgnored(info);
55
+ return info.isFlagged;
56
+ }
57
+ function isWordIgnored(word) {
58
+ return calcIgnored(getWordInfo(word));
59
+ }
60
+ function getSuggestions(word) {
61
+ return dictCol.getPreferredSuggestions(word);
62
+ }
63
+ function isWordFlagged(wo) {
64
+ return calcFlagged(getWordInfo(wo.text));
65
+ }
66
+ function annotateIsFlagged(word) {
67
+ word.isFlagged = isWordFlagged(word);
68
+ return word;
69
+ }
70
+ function annotateIssue(issue) {
71
+ const sugs = getSuggestions(issue.text);
72
+ if (sugs && sugs.length) {
73
+ issue.suggestionsEx = sugs;
74
+ }
75
+ return issue;
76
+ }
77
+ const isFlaggedOrMinLength = (wo) => wo.text.length >= minWordLength || !!wo.isFlagged;
78
+ const isFlaggedOrNotFound = rememberFilter((wo) => wo.isFlagged || !wo.isFound);
79
+ const isNotRepeatingChar = rememberFilter((wo) => !RxPat.regExRepeatedChar.test(wo.text));
80
+ function checkWord(issue) {
81
+ const info = getWordInfo(issue.text);
82
+ if (info.fin) {
83
+ const { isFlagged: isForbidden, isFound, isIgnored } = info;
84
+ const isFlagged = issue.isFlagged ?? (!isIgnored && isForbidden);
85
+ issue.isFlagged = isFlagged;
86
+ issue.isFound = isFlagged ? undefined : isFound;
87
+ return issue;
88
+ }
89
+ const isIgnored = calcIgnored(info);
90
+ const isFlagged = issue.isFlagged ?? calcFlagged(info);
91
+ info.isFound ??= isFlagged ? false : isIgnored || isWordValidWithEscapeRetry(hasDict, issue, issue.line);
92
+ info.isFlagged = !!isFlagged;
93
+ info.fin = true;
94
+ issue.isFlagged = isFlagged;
95
+ issue.isFound = isFlagged ? undefined : info.isFound;
96
+ return issue;
97
+ }
98
+ const regExUpperCaseWithTrailingCommonEnglishSuffix = /^([\p{Lu}\p{M}]{2,})['’]?(?:s|ing|ies|es|ings|ize|ed|ning)$/u; // cspell:disable-line
99
+ const regExpIsLetter = /\p{L}/u;
100
+ const fn = (lineSegment) => {
101
+ const line = lineSegment.line;
102
+ function isWordTooShort(word, ignoreSuffix = false) {
103
+ if (word.text.length >= minWordLength)
104
+ return false;
105
+ const offset = word.offset - line.offset;
106
+ assert.equal(line.text.slice(offset, offset + word.text.length), word.text);
107
+ const prefix = [...line.text.slice(Math.max(0, offset - 2), offset)];
108
+ const hasLetterPrefix = !!prefix.length && regExpIsLetter.test(prefix[prefix.length - 1]);
109
+ if (hasLetterPrefix)
110
+ return false;
111
+ if (ignoreSuffix)
112
+ return true;
113
+ const suffix = [...line.text.slice(offset + word.text.length, offset + word.text.length + 2)];
114
+ const hasLetterSuffix = !!suffix.length && regExpIsLetter.test(suffix[0]);
115
+ return !hasLetterSuffix;
116
+ }
117
+ function splitterIsValid(word) {
118
+ if (setOfKnownSuccessfulWords.has(word.text))
119
+ return true;
120
+ if (isWordFlagged(word))
121
+ return false;
122
+ if (isWordValidWithEscapeRetry(hasDict, word, lineSegment.line))
123
+ return true;
124
+ if (isWordTooShort(word))
125
+ return true;
126
+ return isAllCapsWithTrailingCommonEnglishSuffixOk(word);
127
+ }
128
+ function isAllCapsWithTrailingCommonEnglishSuffixOk(tWord) {
129
+ if (!regExUpperCaseWithTrailingCommonEnglishSuffix.test(tWord.text))
130
+ return false;
131
+ const m = tWord.text.match(regExUpperCaseWithTrailingCommonEnglishSuffix);
132
+ if (!m)
133
+ return false;
134
+ const offset = tWord.offset;
135
+ const v = { offset, text: m[1], line };
136
+ const check = checkWord(v);
137
+ if (check.isFlagged)
138
+ return false;
139
+ if (check.isFound)
140
+ return true;
141
+ if (isWordTooShort(v, true))
142
+ return true;
143
+ return false;
144
+ }
145
+ function checkFullWord(vr) {
146
+ if (vr.isFlagged) {
147
+ return [vr];
148
+ }
149
+ // English exceptions :-(
150
+ if (isAllCapsWithTrailingCommonEnglishSuffixOk(vr))
151
+ return [];
152
+ const codeWordResults = [];
153
+ for (const wo of extractWordsFromCodeTextOffset(vr)) {
154
+ if (setOfKnownSuccessfulWords.has(wo.text))
155
+ continue;
156
+ const issue = wo;
157
+ issue.line = vr.line;
158
+ issue.isFlagged = undefined;
159
+ issue.isFound = undefined;
160
+ annotateIsFlagged(issue);
161
+ if (!isFlaggedOrMinLength(issue))
162
+ continue;
163
+ checkWord(issue);
164
+ if (!isFlaggedOrNotFound(issue) || !isNotRepeatingChar(issue))
165
+ continue;
166
+ issue.text = extractText(lineSegment.segment, issue.offset, issue.offset + issue.text.length);
167
+ codeWordResults.push(issue);
168
+ }
169
+ if (!codeWordResults.length || isWordIgnored(vr.text) || checkWord(vr).isFound) {
170
+ rememberFilter((_) => false)(vr);
171
+ return [];
172
+ }
173
+ return codeWordResults;
174
+ }
175
+ function rebaseKnownIssues(possibleWord, known) {
176
+ const { issues } = known;
177
+ const adjOffset = possibleWord.offset - known.possibleWord.offset;
178
+ return issues.map((issue) => {
179
+ issue = { ...issue };
180
+ issue.offset += adjOffset;
181
+ issue.line = lineSegment.line;
182
+ return issue;
183
+ });
184
+ }
185
+ function checkPossibleWords(possibleWord) {
186
+ const known = setOfKnownIssues.get(possibleWord.text);
187
+ if (known) {
188
+ if (!known.issues.length)
189
+ return known.issues;
190
+ const adjusted = rebaseKnownIssues(possibleWord, known);
191
+ return adjusted;
192
+ }
193
+ const issues = _checkPossibleWords(possibleWord).map(annotateIssue);
194
+ setOfKnownIssues.set(possibleWord.text, { possibleWord, issues });
195
+ return issues;
196
+ }
197
+ function _checkPossibleWords(possibleWord) {
198
+ if (isWordFlagged(possibleWord)) {
199
+ const vr = {
200
+ ...possibleWord,
201
+ line: lineSegment.line,
202
+ isFlagged: true,
203
+ };
204
+ return [vr];
205
+ }
206
+ const mismatches = [];
207
+ for (const wo of extractWordsFromTextOffset(possibleWord)) {
208
+ if (setOfKnownSuccessfulWords.has(wo.text))
209
+ continue;
210
+ const issue = wo;
211
+ issue.line = lineSegment.line;
212
+ annotateIsFlagged(issue);
213
+ if (!isFlaggedOrMinLength(issue))
214
+ continue;
215
+ for (const w of checkFullWord(issue)) {
216
+ mismatches.push(w);
217
+ }
218
+ }
219
+ if (mismatches.length) {
220
+ // Try the more expensive word splitter
221
+ const splitResult = split(lineSegment.segment, possibleWord.offset, splitterIsValid);
222
+ const nonMatching = splitResult.words
223
+ .filter((w) => !w.isFound)
224
+ .filter((w) => {
225
+ const m = w.text.match(regExUpperCaseWithTrailingCommonEnglishSuffix);
226
+ if (!m)
227
+ return true;
228
+ const v = checkWord({ ...w, text: m[1], line: lineSegment.line });
229
+ return v.isFlagged || !v.isFound;
230
+ });
231
+ if (nonMatching.length < mismatches.length) {
232
+ return nonMatching.map((w) => ({ ...w, line: lineSegment.line })).map(annotateIsFlagged);
233
+ }
234
+ }
235
+ return mismatches;
236
+ }
237
+ const checkedPossibleWords = pipe(extractPossibleWordsFromTextOffset(lineSegment.segment), opFilter(filterAlreadyChecked), opConcatMap(checkPossibleWords));
238
+ return checkedPossibleWords;
239
+ };
240
+ function getWordInfo(word) {
241
+ const info = knownWords.get(word);
242
+ if (info)
243
+ return info;
244
+ const result = { word, isFound: undefined, isFlagged: undefined, isIgnored: undefined, fin: false };
245
+ knownWords.set(word, result);
246
+ return result;
247
+ }
248
+ return { fn, dict: dictCol };
249
+ }
250
+ export function textValidatorFactory(dict, options) {
251
+ const lineValidator = lineValidatorFactory(dict, options);
252
+ const lineValidatorFn = lineValidator.fn;
253
+ function validate(pText) {
254
+ const { text, range: srcRange, map } = pText;
255
+ const srcOffset = srcRange[0];
256
+ const segment = { text, offset: 0 };
257
+ const lineSegment = { line: segment, segment };
258
+ function mapBackToOriginSimple(vr) {
259
+ const { text, offset, isFlagged, isFound, suggestionsEx } = vr;
260
+ const r = mapRangeBackToOriginalPos([offset, offset + text.length], map);
261
+ const range = [r[0] + srcOffset, r[1] + srcOffset];
262
+ return { text, range, isFlagged, isFound, suggestionsEx };
263
+ }
264
+ return [...lineValidatorFn(lineSegment)].map(mapBackToOriginSimple);
265
+ }
266
+ return {
267
+ validate,
268
+ lineValidator,
269
+ };
270
+ }
271
+ //# sourceMappingURL=lineValidatorFactory.js.map
@@ -13,20 +13,15 @@ export interface MatchRangeOptionalText extends MatchRange {
13
13
  text?: string;
14
14
  }
15
15
  export declare function findMatchingRanges(pattern: RegExp, text: string): MatchRangeOptionalText[];
16
- export declare function unionRanges(ranges: MatchRange[]): MatchRange[];
16
+ export declare function unionRanges(ranges: MatchRange[]): SortedMatchRangeArray;
17
17
  export declare function findMatchingRangesForPatterns(patterns: RegExp[], text: string): MatchRange[];
18
18
  /**
19
19
  * Create a new set of positions that have the excluded position ranges removed.
20
20
  */
21
21
  export declare function excludeRanges(includeRanges: MatchRange[], excludeRanges: MatchRange[]): MatchRange[];
22
22
  export declare function extractRangeText(text: string, ranges: MatchRange[]): MatchRangeWithText[];
23
- declare const SymSortedMatchRangeArray: unique symbol;
24
- interface SortedMatchRangeArray extends Array<MatchRange> {
25
- [SymSortedMatchRangeArray]: true;
23
+ interface SortedMatchRangeArray {
24
+ values: MatchRange[];
26
25
  }
27
- declare function makeSortedMatchRangeArray(sortedValues: MatchRange[]): SortedMatchRangeArray;
28
- export declare const __testing__: {
29
- makeSortedMatchRangeArray: typeof makeSortedMatchRangeArray;
30
- };
31
26
  export {};
32
27
  //# sourceMappingURL=TextRange.d.ts.map
@@ -1,4 +1,3 @@
1
- import * as GS from 'gensequence';
2
1
  function toMatchRangeWithText(m) {
3
2
  const index = m.index || 0;
4
3
  const _text = m[0];
@@ -25,16 +24,17 @@ function compareRanges(a, b) {
25
24
  return a.startPos - b.startPos || a.endPos - b.endPos;
26
25
  }
27
26
  export function unionRanges(ranges) {
28
- return makeSortedMatchRangeArray([..._unionRanges(ranges)]);
29
- }
30
- function* _unionRanges(ranges) {
31
27
  const sortedRanges = sortMatchRangeArray(ranges);
32
- if (!sortedRanges.length)
33
- return;
34
- let { startPos, endPos } = sortedRanges[0];
35
- for (const r of ranges) {
28
+ ranges = sortedRanges.values;
29
+ if (!ranges.length)
30
+ return sortedRanges;
31
+ let i = 0;
32
+ let j = 0;
33
+ let { startPos, endPos } = ranges[i++];
34
+ for (; i < ranges.length; ++i) {
35
+ const r = ranges[i];
36
36
  if (r.startPos > endPos) {
37
- yield { startPos, endPos };
37
+ ranges[j++] = { startPos, endPos };
38
38
  startPos = r.startPos;
39
39
  endPos = r.endPos;
40
40
  continue;
@@ -42,26 +42,32 @@ function* _unionRanges(ranges) {
42
42
  endPos = Math.max(endPos, r.endPos);
43
43
  }
44
44
  if (startPos < endPos) {
45
- yield { startPos, endPos };
45
+ ranges[j++] = { startPos, endPos };
46
46
  }
47
+ ranges.length = j;
48
+ return sortedRanges;
47
49
  }
48
50
  export function findMatchingRangesForPatterns(patterns, text) {
49
- const matchedPatterns = GS.genSequence(patterns).concatMap((pattern) => findMatchingRanges(pattern, text));
50
- return unionRanges(matchedPatterns.toArray());
51
+ const nested = patterns.map((pattern) => findMatchingRanges(pattern, text));
52
+ return unionRanges(flatten(nested)).values;
51
53
  }
52
54
  /**
53
55
  * Create a new set of positions that have the excluded position ranges removed.
54
56
  */
55
57
  export function excludeRanges(includeRanges, excludeRanges) {
56
- return [..._excludeRanges(sortMatchRangeArray(includeRanges), sortMatchRangeArray(excludeRanges))];
58
+ return _excludeRanges(sortMatchRangeArray(includeRanges), sortMatchRangeArray(excludeRanges));
57
59
  }
58
- function* _excludeRanges(includeRanges, excludeRanges) {
60
+ function _excludeRanges(sortedIncludeRanges, sortedExcludeRanges) {
61
+ const includeRanges = sortedIncludeRanges.values;
62
+ const excludeRanges = sortedExcludeRanges.values;
59
63
  if (!includeRanges.length)
60
- return;
64
+ return includeRanges;
61
65
  if (!excludeRanges.length) {
62
- yield* includeRanges;
63
- return;
66
+ return includeRanges;
64
67
  }
68
+ const ranges = [];
69
+ ranges.length = includeRanges.length + excludeRanges.length + 1;
70
+ let i = 0;
65
71
  let exIndex = 0;
66
72
  const limit = excludeRanges.length;
67
73
  for (const incRange of includeRanges) {
@@ -74,16 +80,18 @@ function* _excludeRanges(includeRanges, excludeRanges) {
74
80
  if (ex.endPos <= startPos)
75
81
  continue;
76
82
  if (ex.startPos > startPos) {
77
- yield { startPos, endPos: ex.startPos };
83
+ ranges[i++] = { startPos, endPos: ex.startPos };
78
84
  }
79
85
  startPos = ex.endPos;
80
86
  if (startPos >= endPos)
81
87
  break;
82
88
  }
83
89
  if (startPos < endPos) {
84
- yield { startPos, endPos };
90
+ ranges[i++] = { startPos, endPos };
85
91
  }
86
92
  }
93
+ ranges.length = i;
94
+ return ranges;
87
95
  }
88
96
  export function extractRangeText(text, ranges) {
89
97
  return ranges.map(({ startPos, endPos }) => ({
@@ -92,22 +100,23 @@ export function extractRangeText(text, ranges) {
92
100
  text: text.slice(startPos, endPos),
93
101
  }));
94
102
  }
95
- const SymSortedMatchRangeArray = Symbol('SortedMatchRangeArray');
96
103
  function sortMatchRangeArray(values) {
97
- if (isSortedMatchRangeArray(values))
98
- return values;
99
- return makeSortedMatchRangeArray(values.sort(compareRanges));
100
- }
101
- function isSortedMatchRangeArray(a) {
102
- return a[SymSortedMatchRangeArray] === true;
104
+ values.sort(compareRanges);
105
+ return { values };
103
106
  }
104
- function makeSortedMatchRangeArray(sortedValues) {
105
- const sorted = sortedValues;
106
- sorted[SymSortedMatchRangeArray] = true;
107
- Object.freeze(sorted);
108
- return sorted;
107
+ function flatten(data) {
108
+ let size = 0;
109
+ for (let i = data.length - 1; i >= 0; --i) {
110
+ size += data[i].length;
111
+ }
112
+ const result = new Array(size);
113
+ let k = 0;
114
+ for (let i = 0; i < data.length; ++i) {
115
+ const d = data[i];
116
+ for (let j = 0; j < d.length; ++j) {
117
+ result[k++] = d[j];
118
+ }
119
+ }
120
+ return result;
109
121
  }
110
- export const __testing__ = {
111
- makeSortedMatchRangeArray,
112
- };
113
122
  //# sourceMappingURL=TextRange.js.map
@@ -6,8 +6,8 @@ import { fileURLToPath } from 'node:url';
6
6
  import { resolveGlobal } from '@cspell/cspell-resolver';
7
7
  import { importResolveModuleName } from '@cspell/dynamic-import';
8
8
  import resolveFrom from 'resolve-from';
9
- import { srcDirectory } from '../../lib-cjs/pkg-info.cjs';
10
9
  import { getFileSystem } from '../fileSystem.js';
10
+ import { srcDirectory } from '../pkg-info.mjs';
11
11
  import { envToTemplateVars, replaceTemplate } from './templates.js';
12
12
  import { fileURLOrPathToPath, isDataURL, isFileURL, isURLLike, resolveFileWithURL, toFilePathOrHref, toFileUrl, toURL, } from './url.js';
13
13
  const regExpStartsWidthNodeModules = /^node_modules[/\\]/;
@@ -11,7 +11,7 @@ export declare function splitCamelCaseWord(word: string): string[];
11
11
  */
12
12
  export declare function match(reg: RegExp, text: string): Iterable<RegExpExecArray>;
13
13
  export declare function matchStringToTextOffset(reg: RegExp, text: string): Iterable<TextOffset>;
14
- export declare function matchToTextOffset(reg: RegExp, text: TextOffset): Iterable<TextOffset>;
14
+ export declare function matchToTextOffset(reg: RegExp, t: TextOffset): Iterable<TextOffset>;
15
15
  export declare function extractLinesOfText(text: string): Iterable<TextOffset>;
16
16
  /**
17
17
  * Extract out whole words from a string of text.
@@ -21,6 +21,11 @@ export declare function extractWordsFromText(text: string): Iterable<TextOffset>
21
21
  * Extract out whole words from a string of text.
22
22
  */
23
23
  export declare function extractWordsFromTextOffset(text: TextOffset): Iterable<TextOffset>;
24
+ /**
25
+ * Remove Hiragana, Han, Katakana, Hangul characters from the text.
26
+ * @param text
27
+ * @returns the text with the characters removed.
28
+ */
24
29
  export declare function cleanText(text: string): string;
25
30
  export declare function cleanTextOffset(text: TextOffset): TextOffset;
26
31
  /**
@@ -1,6 +1,6 @@
1
1
  import { opConcatMap, opMap, pipe } from '@cspell/cspell-pipe/sync';
2
2
  import { binarySearch } from './search.js';
3
- import { regExAccents, regExAllLower, regExAllUpper, regExFirstUpper, regExIgnoreCharacters, regExSplitWords, regExSplitWords2, regExUpperSOrIng, regExWords, regExWordsAndDigits, } from './textRegex.js';
3
+ import { regExAccents, regExAllLower, regExAllUpper, regExFirstUpper, regExIgnoreCharacters, regExpSplitWordBreaks, regExWords, regExWordsAndDigits, } from './textRegex.js';
4
4
  import { toUri } from './Uri.js';
5
5
  import { scanMap } from './util.js';
6
6
  export { stringToRegExp } from './textRegex.js';
@@ -15,11 +15,7 @@ export function splitCamelCaseWordWithOffset(wo) {
15
15
  * Split camelCase words into an array of strings.
16
16
  */
17
17
  export function splitCamelCaseWord(word) {
18
- const wPrime = word.replace(regExUpperSOrIng, (s) => s[0] + s.slice(1).toLowerCase());
19
- const separator = '_<^*_*^>_';
20
- const pass1 = wPrime.replace(regExSplitWords, '$1' + separator + '$2');
21
- const pass2 = pass1.replace(regExSplitWords2, '$1' + separator + '$2');
22
- return pass2.split(separator);
18
+ return word.split(regExpSplitWordBreaks);
23
19
  }
24
20
  /**
25
21
  * This function lets you iterate over regular expression matches.
@@ -33,11 +29,11 @@ export function match(reg, text) {
33
29
  export function matchStringToTextOffset(reg, text) {
34
30
  return matchToTextOffset(reg, { text, offset: 0 });
35
31
  }
36
- export function matchToTextOffset(reg, text) {
37
- const textOffset = text;
38
- const fnOffsetMap = offsetMap(textOffset.offset);
39
- textOffset.text.matchAll(reg);
40
- return pipe(match(reg, textOffset.text), opMap((m) => fnOffsetMap({ text: m[0], offset: m.index || 0 })));
32
+ export function matchToTextOffset(reg, t) {
33
+ const text = t.text;
34
+ const offset = t.offset;
35
+ // return opMap((m: RegExpExecArray) => ({ text: m[0], offset: offset + m.index }))(match(reg, text));
36
+ return pipe(match(reg, text), opMap((m) => ({ text: m[0], offset: offset + m.index })));
41
37
  }
42
38
  export function* extractLinesOfText(text) {
43
39
  let i = 0;
@@ -61,11 +57,23 @@ export function extractWordsFromTextOffset(text) {
61
57
  const reg = new RegExp(regExWords);
62
58
  return matchToTextOffset(reg, cleanTextOffset(text));
63
59
  }
60
+ /**
61
+ * Remove Hiragana, Han, Katakana, Hangul characters from the text.
62
+ * @param text
63
+ * @returns the text with the characters removed.
64
+ */
64
65
  export function cleanText(text) {
66
+ regExIgnoreCharacters.lastIndex = 0;
67
+ if (!regExIgnoreCharacters.test(text))
68
+ return text;
65
69
  text = text.replace(regExIgnoreCharacters, (match) => ' '.repeat(match.length));
66
70
  return text;
67
71
  }
68
72
  export function cleanTextOffset(text) {
73
+ // Do not make a new object if the text is already clean.
74
+ regExIgnoreCharacters.lastIndex = 0;
75
+ if (!regExIgnoreCharacters.test(text.text))
76
+ return text;
69
77
  return {
70
78
  text: cleanText(text.text),
71
79
  offset: text.offset,
@@ -135,9 +143,6 @@ export function extractText(textOffset, startPos, endPos) {
135
143
  const b = Math.max(endPos - orig, 0);
136
144
  return text.slice(a, b);
137
145
  }
138
- function offsetMap(offset) {
139
- return (xo) => ({ ...xo, offset: xo.offset + offset });
140
- }
141
146
  export function calculateTextDocumentOffsets(uri, doc, wordOffsets) {
142
147
  const lines = [
143
148
  -1,
@@ -1,6 +1,8 @@
1
1
  export declare const regExUpperSOrIng: RegExp;
2
2
  export declare const regExSplitWords: RegExp;
3
3
  export declare const regExSplitWords2: RegExp;
4
+ export declare const regExpSplitWordBreaks: RegExp;
5
+ export declare const regExpAllPossibleWordBreaks: RegExp;
4
6
  export declare const regExWords: RegExp;
5
7
  export declare const regExWordsAndDigits: RegExp;
6
8
  export declare const regExIgnoreCharacters: RegExp;
@@ -1,7 +1,9 @@
1
1
  // cspell:ignore ings ning gimuy anrvtbf gimuxy
2
- export const regExUpperSOrIng = /([\p{Lu}\p{M}]+\\?['’]?(?:s|ing|ies|es|ings|ed|ning))(?!\p{Ll})/gu;
2
+ export const regExUpperSOrIng = /([\p{Lu}\p{M}]+(?:\\?['’])?(?:s|ing|ies|es|ings|ed|ning))(?!\p{Ll})/gu;
3
3
  export const regExSplitWords = /(\p{Ll}\p{M}?)(\p{Lu})/gu;
4
4
  export const regExSplitWords2 = /(\p{Lu}\p{M}?)(\p{Lu}\p{M}?\p{Ll})/gu;
5
+ export const regExpSplitWordBreaks = /(?<=\p{Ll}\p{M}?)(?=\p{Lu})|(?<=\p{Lu}\p{M}?)(?=\p{Lu}\p{M}?\p{Ll})(?!\p{Lu}\p{M}?(?:s|ing|ies|es|ings|ed|ning)(?!\p{Ll}))/gu;
6
+ export const regExpAllPossibleWordBreaks = /(?<=\p{Ll}\p{M}?)(?=\p{Lu})|(?<=\p{Lu}\p{M}?)(?=\p{Lu}\p{M}?\p{Ll})|(?<=\p{Lu}\p{M}?\p{Lu}\p{M}?)(?=\p{Ll})|(?<=\p{L}\p{M}?)(?=\P{L})|(?<=\P{L})(?=\p{L})/gu;
5
7
  export const regExWords = /\p{L}\p{M}?(?:(?:\\?['’])?\p{L}\p{M}?)*/gu;
6
8
  // Words can be made of letters, numbers, period, underscore, dash, plus, and single quote
7
9
  export const regExWordsAndDigits = /[\p{L}\w'’`.+-](?:(?:\\(?=[']))?[\p{L}\p{M}\w'’`.+-])*/gu;
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { pathToFileURL } from 'node:url';
3
3
  import { toFilePathOrHref, toFileURL } from '@cspell/url';
4
- import { srcDirectory } from '../../lib-cjs/pkg-info.cjs';
4
+ import { srcDirectory } from '../pkg-info.mjs';
5
5
  export { addTrailingSlash, isDataURL, isFileURL, isUrlLike as isURLLike, toFileURL as resolveFileWithURL, toFileDirURL, toFilePathOrHref, toURL, } from '@cspell/url';
6
6
  /**
7
7
  * This is a URL that can be used for searching for modules.
@@ -24,7 +24,7 @@ export interface SplitOptions extends WordBreakOptions {
24
24
  }
25
25
  export declare function split(line: TextOffset, offset: number, isValidWord: IsValidWordFn, options?: SplitOptions): SplitResult;
26
26
  declare function findNextWordText({ text, offset }: TextOffset): TextOffset;
27
- type BreakPairs = readonly number[];
27
+ type BreakPairs = readonly [number, number];
28
28
  interface PossibleWordBreak {
29
29
  /** offset from the start of the string */
30
30
  offset: number;