cspell-lib 7.0.0-alpha.2 → 7.0.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.
- package/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.d.mts +0 -1
- package/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.mjs +26 -28
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/util/fileReader.mjs +3 -3
- package/dist/esm/wordListHelper.mjs +1 -1
- package/package.json +15 -15
|
@@ -8,7 +8,6 @@ export declare class DictionaryLoader {
|
|
|
8
8
|
private inlineDictionaryCache;
|
|
9
9
|
private dictionaryCacheByDef;
|
|
10
10
|
private reader;
|
|
11
|
-
private readerSync;
|
|
12
11
|
constructor(cspellIO: CSpellIO);
|
|
13
12
|
loadDictionary(def: DictionaryDefinitionInternal): Promise<SpellingDictionary>;
|
|
14
13
|
loadDictionarySync(def: DictionaryDefinitionInternal): SpellingDictionary;
|
|
@@ -32,7 +32,6 @@ export class DictionaryLoader {
|
|
|
32
32
|
this.inlineDictionaryCache = new AutoResolveWeakCache();
|
|
33
33
|
this.dictionaryCacheByDef = new StrongWeakMap();
|
|
34
34
|
this.reader = toReader(cspellIO);
|
|
35
|
-
this.readerSync = toReaderSync(cspellIO);
|
|
36
35
|
}
|
|
37
36
|
loadDictionary(def) {
|
|
38
37
|
if (isDictionaryDefinitionInlineInternal(def)) {
|
|
@@ -132,7 +131,7 @@ export class DictionaryLoader {
|
|
|
132
131
|
const stat = this.getStatSync(uri);
|
|
133
132
|
const sig = now + Math.random();
|
|
134
133
|
try {
|
|
135
|
-
const dictionary = loadSync(this.
|
|
134
|
+
const dictionary = loadSync(this.reader, uri, options);
|
|
136
135
|
const pending = Promise.resolve([dictionary, stat]);
|
|
137
136
|
return {
|
|
138
137
|
uri,
|
|
@@ -190,15 +189,11 @@ export class DictionaryLoader {
|
|
|
190
189
|
}
|
|
191
190
|
}
|
|
192
191
|
function toReader(cspellIO) {
|
|
193
|
-
return
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
function toReaderSync(cspellIO) {
|
|
199
|
-
return function (filename) {
|
|
200
|
-
const res = cspellIO.readFileSync(filename);
|
|
201
|
-
return res.content.split(/\n|\r\n|\r/);
|
|
192
|
+
return {
|
|
193
|
+
read: async (filename) => (await cspellIO.readFile(filename)).content,
|
|
194
|
+
readLines: async (filename) => toLines((await cspellIO.readFile(filename)).content),
|
|
195
|
+
readSync: (filename) => cspellIO.readFileSync(filename).content,
|
|
196
|
+
readLinesSync: (filename) => toLines(cspellIO.readFileSync(filename).content),
|
|
202
197
|
};
|
|
203
198
|
}
|
|
204
199
|
const importantOptionKeys = ['name', 'noSuggest', 'useCompounds', 'type'];
|
|
@@ -230,12 +225,12 @@ function loadSync(reader, uri, options) {
|
|
|
230
225
|
const loader = loadersSync[type] || loaders.default;
|
|
231
226
|
return loader(reader, uri, options);
|
|
232
227
|
}
|
|
233
|
-
async function legacyWordList(
|
|
234
|
-
const lines = await readLines(filename);
|
|
228
|
+
async function legacyWordList(reader, filename, options) {
|
|
229
|
+
const lines = await reader.readLines(filename);
|
|
235
230
|
return _legacyWordListSync(lines, filename, options);
|
|
236
231
|
}
|
|
237
|
-
function legacyWordListSync(
|
|
238
|
-
const lines = readLinesSync(filename);
|
|
232
|
+
function legacyWordListSync(reader, filename, options) {
|
|
233
|
+
const lines = reader.readLinesSync(filename);
|
|
239
234
|
return _legacyWordListSync(lines, filename, options);
|
|
240
235
|
}
|
|
241
236
|
function _legacyWordListSync(lines, filename, options) {
|
|
@@ -246,12 +241,12 @@ function _legacyWordListSync(lines, filename, options) {
|
|
|
246
241
|
opConcatMap((line) => line.split(/[^\w\p{L}\p{M}'’]+/gu)), opFilter((word) => !!word));
|
|
247
242
|
return createSpellingDictionary(words, options.name, filename, options);
|
|
248
243
|
}
|
|
249
|
-
async function wordsPerLineWordList(
|
|
250
|
-
const lines = await readLines(filename);
|
|
244
|
+
async function wordsPerLineWordList(reader, filename, options) {
|
|
245
|
+
const lines = await reader.readLines(filename);
|
|
251
246
|
return _wordsPerLineWordList(lines, filename, options);
|
|
252
247
|
}
|
|
253
|
-
function wordsPerLineWordListSync(
|
|
254
|
-
const lines = readLinesSync(filename);
|
|
248
|
+
function wordsPerLineWordListSync(reader, filename, options) {
|
|
249
|
+
const lines = reader.readLinesSync(filename);
|
|
255
250
|
return _wordsPerLineWordList(lines, filename, options);
|
|
256
251
|
}
|
|
257
252
|
function _wordsPerLineWordList(lines, filename, options) {
|
|
@@ -263,18 +258,21 @@ function _wordsPerLineWordList(lines, filename, options) {
|
|
|
263
258
|
return createSpellingDictionary(words, options.name, filename, options);
|
|
264
259
|
}
|
|
265
260
|
async function loadSimpleWordList(reader, filename, options) {
|
|
266
|
-
const lines = await reader(filename);
|
|
261
|
+
const lines = await reader.readLines(filename);
|
|
267
262
|
return createSpellingDictionary(lines, options.name, filename, options);
|
|
268
263
|
}
|
|
269
|
-
function loadSimpleWordListSync(
|
|
270
|
-
const lines = readLinesSync(filename);
|
|
264
|
+
function loadSimpleWordListSync(reader, filename, options) {
|
|
265
|
+
const lines = reader.readLinesSync(filename);
|
|
271
266
|
return createSpellingDictionary(lines, options.name, filename, options);
|
|
272
267
|
}
|
|
273
|
-
async function loadTrie(
|
|
274
|
-
const
|
|
275
|
-
return createSpellingDictionaryFromTrieFile(
|
|
268
|
+
async function loadTrie(reader, filename, options) {
|
|
269
|
+
const content = await reader.read(filename);
|
|
270
|
+
return createSpellingDictionaryFromTrieFile(content, options.name, filename, options);
|
|
271
|
+
}
|
|
272
|
+
function loadTrieSync(reader, filename, options) {
|
|
273
|
+
const content = reader.readSync(filename);
|
|
274
|
+
return createSpellingDictionaryFromTrieFile(content, options.name, filename, options);
|
|
276
275
|
}
|
|
277
|
-
function
|
|
278
|
-
|
|
279
|
-
return createSpellingDictionaryFromTrieFile(lines, options.name, filename, options);
|
|
276
|
+
function toLines(content) {
|
|
277
|
+
return content.split(/\n|\r\n|\r/);
|
|
280
278
|
}
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -22,7 +22,7 @@ export { getLogger, Logger, setLogger } from './util/logger.mjs';
|
|
|
22
22
|
export { resolveFile } from './util/resolveFile.mjs';
|
|
23
23
|
export { checkText, checkTextDocument, CheckTextInfo, IncludeExcludeFlag, IncludeExcludeOptions, TextInfoItem, validateText, ValidationIssue, } from './validator.mjs';
|
|
24
24
|
export * from '@cspell/cspell-types';
|
|
25
|
-
export { asyncIterableToArray, readFile, readFileSync, writeToFile, writeToFileIterable, writeToFileIterableP, } from 'cspell-io';
|
|
25
|
+
export { asyncIterableToArray, readFileText as readFile, readFileTextSync as readFileSync, writeToFile, writeToFileIterable, writeToFileIterableP, } from 'cspell-io';
|
|
26
26
|
export { Link, Text };
|
|
27
27
|
export { ExclusionHelper };
|
|
28
28
|
export { clearCachedFiles } from './clearCachedFiles.mjs';
|
package/dist/esm/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ export { getLogger, setLogger } from './util/logger.mjs';
|
|
|
17
17
|
export { resolveFile } from './util/resolveFile.mjs';
|
|
18
18
|
export { checkText, checkTextDocument, IncludeExcludeFlag, validateText, } from './validator.mjs';
|
|
19
19
|
export * from '@cspell/cspell-types';
|
|
20
|
-
export { asyncIterableToArray, readFile, readFileSync, writeToFile, writeToFileIterable, writeToFileIterableP, } from 'cspell-io';
|
|
20
|
+
export { asyncIterableToArray, readFileText as readFile, readFileTextSync as readFileSync, writeToFile, writeToFileIterable, writeToFileIterableP, } from 'cspell-io';
|
|
21
21
|
export { Link, Text };
|
|
22
22
|
export { ExclusionHelper };
|
|
23
23
|
export { clearCachedFiles } from './clearCachedFiles.mjs';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileText, readFileTextSync } from 'cspell-io';
|
|
2
2
|
import { toIterableIterator } from './iterableIteratorLib.mjs';
|
|
3
3
|
export async function readLines(filename, encoding = 'utf8') {
|
|
4
4
|
try {
|
|
5
|
-
const content = await
|
|
5
|
+
const content = await readFileText(filename, encoding);
|
|
6
6
|
return toIterableIterator(content.split(/\r?\n/g));
|
|
7
7
|
}
|
|
8
8
|
catch (e) {
|
|
@@ -10,6 +10,6 @@ export async function readLines(filename, encoding = 'utf8') {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
export function readLinesSync(filename, encoding = 'utf8') {
|
|
13
|
-
const content =
|
|
13
|
+
const content = readFileTextSync(filename, encoding);
|
|
14
14
|
return content.split(/\r?\n/g);
|
|
15
15
|
}
|
|
@@ -15,7 +15,7 @@ export function splitLine(line) {
|
|
|
15
15
|
return [...Text.extractWordsFromText(line)].map(({ text }) => text);
|
|
16
16
|
}
|
|
17
17
|
export function splitCodeWords(words) {
|
|
18
|
-
return words.map(Text.splitCamelCaseWord).
|
|
18
|
+
return words.map(Text.splitCamelCaseWord).flatMap((a) => a);
|
|
19
19
|
}
|
|
20
20
|
export function splitLineIntoCodeWords(line) {
|
|
21
21
|
const asMultiWord = regExpWordsWithSpaces.test(line) ? [line] : [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-lib",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "A library of useful functions used across various cspell tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/api/api.d.ts",
|
|
@@ -60,19 +60,19 @@
|
|
|
60
60
|
},
|
|
61
61
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@cspell/cspell-bundled-dicts": "7.0.0
|
|
64
|
-
"@cspell/cspell-pipe": "7.0.0
|
|
65
|
-
"@cspell/cspell-types": "7.0.0
|
|
66
|
-
"@cspell/strong-weak-map": "7.0.0
|
|
63
|
+
"@cspell/cspell-bundled-dicts": "7.0.0",
|
|
64
|
+
"@cspell/cspell-pipe": "7.0.0",
|
|
65
|
+
"@cspell/cspell-types": "7.0.0",
|
|
66
|
+
"@cspell/strong-weak-map": "7.0.0",
|
|
67
67
|
"clear-module": "^4.1.2",
|
|
68
68
|
"comment-json": "^4.2.3",
|
|
69
69
|
"configstore": "^6.0.0",
|
|
70
70
|
"cosmiconfig": "8.0.0",
|
|
71
|
-
"cspell-dictionary": "7.0.0
|
|
72
|
-
"cspell-glob": "7.0.0
|
|
73
|
-
"cspell-grammar": "7.0.0
|
|
74
|
-
"cspell-io": "7.0.0
|
|
75
|
-
"cspell-trie-lib": "7.0.0
|
|
71
|
+
"cspell-dictionary": "7.0.0",
|
|
72
|
+
"cspell-glob": "7.0.0",
|
|
73
|
+
"cspell-grammar": "7.0.0",
|
|
74
|
+
"cspell-io": "7.0.0",
|
|
75
|
+
"cspell-trie-lib": "7.0.0",
|
|
76
76
|
"fast-equals": "^5.0.1",
|
|
77
77
|
"find-up": "^6.3.0",
|
|
78
78
|
"gensequence": "^5.0.2",
|
|
@@ -88,15 +88,15 @@
|
|
|
88
88
|
"devDependencies": {
|
|
89
89
|
"@cspell/dict-cpp": "^4.0.3",
|
|
90
90
|
"@cspell/dict-csharp": "^4.0.2",
|
|
91
|
-
"@cspell/dict-css": "^
|
|
91
|
+
"@cspell/dict-css": "^4.0.6",
|
|
92
92
|
"@cspell/dict-fa-ir": "^2.0.0",
|
|
93
|
-
"@cspell/dict-fr-fr": "^2.2.
|
|
93
|
+
"@cspell/dict-fr-fr": "^2.2.2",
|
|
94
94
|
"@cspell/dict-html": "^4.0.3",
|
|
95
|
-
"@cspell/dict-nl-nl": "^2.2.
|
|
96
|
-
"@cspell/dict-python": "^4.
|
|
95
|
+
"@cspell/dict-nl-nl": "^2.2.9",
|
|
96
|
+
"@cspell/dict-python": "^4.1.5",
|
|
97
97
|
"@types/configstore": "^6.0.0",
|
|
98
98
|
"cspell-dict-nl-nl": "^1.1.2",
|
|
99
99
|
"lorem-ipsum": "^2.0.8"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "52960d5ed75655978f9b633f44fd106937a63cd7"
|
|
102
102
|
}
|