cspell-lib 5.16.0 → 5.18.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/Models/CSpellSettingsInternalDef.d.ts +23 -0
- package/dist/Models/CSpellSettingsInternalDef.js +16 -0
- package/dist/Settings/CSpellSettingsServer.d.ts +26 -47
- package/dist/Settings/CSpellSettingsServer.js +99 -524
- package/dist/Settings/DefaultSettings.d.ts +3 -3
- package/dist/Settings/DefaultSettings.js +5 -4
- package/dist/Settings/DictionarySettings.d.ts +10 -13
- package/dist/Settings/DictionarySettings.js +51 -18
- package/dist/Settings/InDocSettings.js +5 -2
- package/dist/Settings/configLoader.d.ts +57 -0
- package/dist/Settings/configLoader.js +523 -0
- package/dist/Settings/index.d.ts +5 -4
- package/dist/Settings/index.js +30 -14
- package/dist/Settings/index.link.d.ts +3 -0
- package/dist/Settings/index.link.js +8 -0
- package/dist/Settings/link.js +2 -2
- package/dist/SpellingDictionary/Dictionaries.d.ts +4 -4
- package/dist/SpellingDictionary/Dictionaries.js +26 -7
- package/dist/SpellingDictionary/DictionaryLoader.d.ts +3 -3
- package/dist/SpellingDictionary/DictionaryLoader.js +2 -2
- package/dist/SpellingDictionary/SpellingDictionary.d.ts +4 -3
- package/dist/SpellingDictionary/SpellingDictionaryCollection.js +1 -1
- package/dist/SpellingDictionary/SpellingDictionaryFromTrie.js +1 -1
- package/dist/SpellingDictionary/SpellingDictionaryMethods.d.ts +4 -3
- package/dist/SpellingDictionary/SpellingDictionaryMethods.js +8 -3
- package/dist/SpellingDictionary/createSpellingDictionary.d.ts +2 -2
- package/dist/SpellingDictionary/createSpellingDictionary.js +35 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +16 -6
- package/dist/suggestions.d.ts +63 -0
- package/dist/suggestions.js +117 -0
- package/dist/trace.d.ts +1 -0
- package/dist/trace.js +19 -16
- package/dist/util/simpleCache.d.ts +44 -0
- package/dist/util/simpleCache.js +140 -0
- package/dist/util/types.d.ts +49 -1
- package/dist/util/types.js +6 -0
- package/dist/util/util.d.ts +3 -0
- package/dist/util/util.js +19 -1
- package/dist/validator.js +1 -2
- package/package.json +14 -10
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare class SimpleWeakCache<K extends object, T> {
|
|
2
|
+
readonly size: number;
|
|
3
|
+
private L0;
|
|
4
|
+
private L1;
|
|
5
|
+
private L2;
|
|
6
|
+
private sizeL0;
|
|
7
|
+
constructor(size: number);
|
|
8
|
+
has(key: K): boolean;
|
|
9
|
+
get(key: K): T | undefined;
|
|
10
|
+
set(key: K, value: T): this | undefined;
|
|
11
|
+
private caches;
|
|
12
|
+
private rotate;
|
|
13
|
+
}
|
|
14
|
+
export declare class AutoWeakCache<K extends object, T> extends SimpleWeakCache<K, T> {
|
|
15
|
+
readonly factory: (key: K) => T;
|
|
16
|
+
constructor(factory: (key: K) => T, size: number);
|
|
17
|
+
get(key: K): T;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* This will cache between `size` and 3 x `size` items.
|
|
21
|
+
* It has three stashes, L0, L1, and L2. Each can contain `size` items.
|
|
22
|
+
* When L0 is full, its items are given to L1 and L1's are given to L2, and L2 is empties.
|
|
23
|
+
*
|
|
24
|
+
* The stashes are searched in order, L0...L2. If an item is found in L1, or L2, it is
|
|
25
|
+
* promoted to L0.
|
|
26
|
+
*/
|
|
27
|
+
export declare class SimpleCache<K, T> {
|
|
28
|
+
readonly size: number;
|
|
29
|
+
private L0;
|
|
30
|
+
private L1;
|
|
31
|
+
private L2;
|
|
32
|
+
constructor(size: number);
|
|
33
|
+
has(key: K): boolean;
|
|
34
|
+
get(key: K): T | undefined;
|
|
35
|
+
set(key: K, value: T): this | undefined;
|
|
36
|
+
private caches;
|
|
37
|
+
private rotate;
|
|
38
|
+
}
|
|
39
|
+
export declare class AutoCache<K, T> extends SimpleCache<K, T> {
|
|
40
|
+
readonly factory: (key: K) => T;
|
|
41
|
+
constructor(factory: (key: K) => T, size: number);
|
|
42
|
+
get(key: K): T;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=simpleCache.d.ts.map
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AutoCache = exports.SimpleCache = exports.AutoWeakCache = exports.SimpleWeakCache = void 0;
|
|
4
|
+
class SimpleWeakCache {
|
|
5
|
+
constructor(size) {
|
|
6
|
+
this.size = size;
|
|
7
|
+
this.L0 = new WeakMap();
|
|
8
|
+
this.L1 = new WeakMap();
|
|
9
|
+
this.L2 = new WeakMap();
|
|
10
|
+
this.sizeL0 = 0;
|
|
11
|
+
}
|
|
12
|
+
has(key) {
|
|
13
|
+
for (const c of this.caches()) {
|
|
14
|
+
if (c.has(key))
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
get(key) {
|
|
20
|
+
for (const c of this.caches()) {
|
|
21
|
+
if (c.has(key)) {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
23
|
+
const v = c.get(key);
|
|
24
|
+
if (c !== this.L0) {
|
|
25
|
+
this.set(key, v);
|
|
26
|
+
}
|
|
27
|
+
return v;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
set(key, value) {
|
|
33
|
+
if (this.L0.has(key)) {
|
|
34
|
+
this.L0.set(key, value);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
if (this.sizeL0 >= this.size) {
|
|
38
|
+
this.rotate();
|
|
39
|
+
}
|
|
40
|
+
this.sizeL0 += 1;
|
|
41
|
+
this.L0.set(key, value);
|
|
42
|
+
}
|
|
43
|
+
caches() {
|
|
44
|
+
return [this.L0, this.L1, this.L2];
|
|
45
|
+
}
|
|
46
|
+
rotate() {
|
|
47
|
+
this.L2 = this.L1;
|
|
48
|
+
this.L1 = this.L0;
|
|
49
|
+
this.L0 = new WeakMap();
|
|
50
|
+
this.sizeL0 = 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.SimpleWeakCache = SimpleWeakCache;
|
|
54
|
+
class AutoWeakCache extends SimpleWeakCache {
|
|
55
|
+
constructor(factory, size) {
|
|
56
|
+
super(size);
|
|
57
|
+
this.factory = factory;
|
|
58
|
+
}
|
|
59
|
+
get(key) {
|
|
60
|
+
const v = super.get(key);
|
|
61
|
+
if (v !== undefined)
|
|
62
|
+
return v;
|
|
63
|
+
const val = this.factory(key);
|
|
64
|
+
this.set(key, val);
|
|
65
|
+
return val;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.AutoWeakCache = AutoWeakCache;
|
|
69
|
+
/**
|
|
70
|
+
* This will cache between `size` and 3 x `size` items.
|
|
71
|
+
* It has three stashes, L0, L1, and L2. Each can contain `size` items.
|
|
72
|
+
* When L0 is full, its items are given to L1 and L1's are given to L2, and L2 is empties.
|
|
73
|
+
*
|
|
74
|
+
* The stashes are searched in order, L0...L2. If an item is found in L1, or L2, it is
|
|
75
|
+
* promoted to L0.
|
|
76
|
+
*/
|
|
77
|
+
class SimpleCache {
|
|
78
|
+
constructor(size) {
|
|
79
|
+
this.size = size;
|
|
80
|
+
this.L0 = new Map();
|
|
81
|
+
this.L1 = new Map();
|
|
82
|
+
this.L2 = new Map();
|
|
83
|
+
}
|
|
84
|
+
has(key) {
|
|
85
|
+
for (const c of this.caches()) {
|
|
86
|
+
if (c.has(key))
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
get(key) {
|
|
92
|
+
for (const c of this.caches()) {
|
|
93
|
+
if (c.has(key)) {
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
95
|
+
const v = c.get(key);
|
|
96
|
+
if (c !== this.L0) {
|
|
97
|
+
this.set(key, v);
|
|
98
|
+
}
|
|
99
|
+
return v;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
set(key, value) {
|
|
105
|
+
if (this.L0.has(key)) {
|
|
106
|
+
this.L0.set(key, value);
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
if (this.L0.size >= this.size) {
|
|
110
|
+
this.rotate();
|
|
111
|
+
}
|
|
112
|
+
this.L0.set(key, value);
|
|
113
|
+
}
|
|
114
|
+
caches() {
|
|
115
|
+
return [this.L0, this.L1, this.L2];
|
|
116
|
+
}
|
|
117
|
+
rotate() {
|
|
118
|
+
this.L2.clear();
|
|
119
|
+
this.L2 = this.L1;
|
|
120
|
+
this.L1 = this.L0;
|
|
121
|
+
this.L0 = new Map();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.SimpleCache = SimpleCache;
|
|
125
|
+
class AutoCache extends SimpleCache {
|
|
126
|
+
constructor(factory, size) {
|
|
127
|
+
super(size);
|
|
128
|
+
this.factory = factory;
|
|
129
|
+
}
|
|
130
|
+
get(key) {
|
|
131
|
+
const v = super.get(key);
|
|
132
|
+
if (v !== undefined)
|
|
133
|
+
return v;
|
|
134
|
+
const val = this.factory(key);
|
|
135
|
+
this.set(key, val);
|
|
136
|
+
return val;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.AutoCache = AutoCache;
|
|
140
|
+
//# sourceMappingURL=simpleCache.js.map
|
package/dist/util/types.d.ts
CHANGED
|
@@ -1,2 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Make all optional fields required.
|
|
3
|
+
*/
|
|
4
|
+
export declare type RequireOptional<T> = {
|
|
5
|
+
[K in keyof Required<T>]: T[K];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Make all properties in T optional and Possibly undefined
|
|
9
|
+
*/
|
|
10
|
+
export declare type PartialWithUndefined<T> = {
|
|
11
|
+
[P in keyof T]?: T[P] | undefined;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Make all fields mandatory
|
|
15
|
+
*/
|
|
16
|
+
export declare type Mandatory<T> = {
|
|
17
|
+
[P in keyof T]-?: Exclude<T[P], undefined>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Union the fields
|
|
21
|
+
*/
|
|
22
|
+
export declare type UnionFields<T, U> = {
|
|
23
|
+
[K in keyof T | keyof U]: (K extends keyof T ? T[K] : undefined) | (K extends keyof U ? U[K] : undefined);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The keys of an object where the values cannot be undefined.
|
|
27
|
+
*/
|
|
28
|
+
export declare type RequiredKeys<T> = Exclude<{
|
|
29
|
+
[P in keyof T]: T[P] extends Exclude<T[P], undefined> ? P : never;
|
|
30
|
+
}[keyof T], undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* The keys of an object where the values cannot be undefined.
|
|
33
|
+
*/
|
|
34
|
+
export declare type OptionalKeys<T> = Exclude<{
|
|
35
|
+
[P in keyof T]: T[P] extends Exclude<T[P], undefined> ? never : P;
|
|
36
|
+
}[keyof T], undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Extract the fields that cannot be `undefined`
|
|
39
|
+
*/
|
|
40
|
+
export declare type OnlyRequired<T> = {
|
|
41
|
+
[P in RequiredKeys<T>]: T[P];
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Extract the fields that can be `undefined`
|
|
45
|
+
*/
|
|
46
|
+
export declare type OnlyOptional<T> = {
|
|
47
|
+
[P in keyof T as P extends OptionalKeys<T> ? P : never]: T[P];
|
|
48
|
+
};
|
|
49
|
+
export declare type MakeOptional<T> = OnlyRequired<T> & Partial<OnlyOptional<T>>;
|
|
2
50
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/util/types.js
CHANGED
package/dist/util/util.d.ts
CHANGED
|
@@ -13,4 +13,7 @@ export declare function clean<T>(src: T): T;
|
|
|
13
13
|
export declare function scanMap<T>(accFn: (acc: T, value: T) => T, init?: T): (value: T) => T;
|
|
14
14
|
export declare function scanMap<T, U>(accFn: (acc: U, value: T) => U, init: U): (value: T) => U;
|
|
15
15
|
export declare function isDefined<T>(v: T | undefined): v is T;
|
|
16
|
+
export declare function flattenIterable<T>(values: Iterable<Iterable<T>> | T[][]): Iterable<T>;
|
|
17
|
+
export declare function flatten<T>(values: Iterable<Iterable<T>> | T[][]): T[];
|
|
18
|
+
export declare function asyncIterableToArray<T>(iter: Iterable<T> | AsyncIterable<T>): Promise<Awaited<T>[]>;
|
|
16
19
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/util/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDefined = exports.scanMap = exports.clean = exports.unique = exports.uniqueFilterFnGenerator = exports.uniqueFn = void 0;
|
|
3
|
+
exports.asyncIterableToArray = exports.flatten = exports.flattenIterable = exports.isDefined = exports.scanMap = exports.clean = exports.unique = exports.uniqueFilterFnGenerator = exports.uniqueFn = void 0;
|
|
4
4
|
// alias for uniqueFilterFnGenerator
|
|
5
5
|
exports.uniqueFn = uniqueFilterFnGenerator;
|
|
6
6
|
function uniqueFilterFnGenerator(extractFn) {
|
|
@@ -50,4 +50,22 @@ function isDefined(v) {
|
|
|
50
50
|
return v !== undefined;
|
|
51
51
|
}
|
|
52
52
|
exports.isDefined = isDefined;
|
|
53
|
+
function* flattenIterable(values) {
|
|
54
|
+
for (const v of values) {
|
|
55
|
+
yield* v;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.flattenIterable = flattenIterable;
|
|
59
|
+
function flatten(values) {
|
|
60
|
+
return [...flattenIterable(values)];
|
|
61
|
+
}
|
|
62
|
+
exports.flatten = flatten;
|
|
63
|
+
async function asyncIterableToArray(iter) {
|
|
64
|
+
const acc = [];
|
|
65
|
+
for await (const t of iter) {
|
|
66
|
+
acc.push(t);
|
|
67
|
+
}
|
|
68
|
+
return acc;
|
|
69
|
+
}
|
|
70
|
+
exports.asyncIterableToArray = asyncIterableToArray;
|
|
53
71
|
//# sourceMappingURL=util.js.map
|
package/dist/validator.js
CHANGED
|
@@ -21,13 +21,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.checkText = exports.IncludeExcludeFlag = exports.settingsToValidateOptions = exports.validateText = exports.diagSource = void 0;
|
|
23
23
|
const Settings = __importStar(require("./Settings"));
|
|
24
|
-
const Dictionary = __importStar(require("./SpellingDictionary"));
|
|
25
24
|
const SpellingDictionary_1 = require("./SpellingDictionary");
|
|
26
25
|
const TV = __importStar(require("./textValidator"));
|
|
27
26
|
exports.diagSource = 'cSpell Checker';
|
|
28
27
|
async function validateText(text, settings, options = {}) {
|
|
29
28
|
const finalSettings = Settings.finalizeSettings(settings);
|
|
30
|
-
const dict = await
|
|
29
|
+
const dict = await (0, SpellingDictionary_1.getDictionaryInternal)(finalSettings);
|
|
31
30
|
const issues = [...TV.validateText(text, dict, settingsToValidateOptions(finalSettings))];
|
|
32
31
|
if (!options.generateSuggestions) {
|
|
33
32
|
return issues;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-lib",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.0",
|
|
4
4
|
"description": "A library of useful functions used across various cspell tools.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
16
|
"clean": "rimraf dist temp coverage .tsbuildinfo",
|
|
17
|
-
"build": "npm run compile",
|
|
17
|
+
"build": "npm run compile && npm run build-api",
|
|
18
18
|
"build-dev": "tsc -p tsconfig.dev.json",
|
|
19
|
+
"build-api": "rollup -c api/rollup.config.mjs",
|
|
19
20
|
"clean-build": "npm run clean && npm run build",
|
|
20
21
|
"compile": "tsc -p .",
|
|
21
22
|
"watch": "tsc --watch -p .",
|
|
@@ -47,15 +48,16 @@
|
|
|
47
48
|
},
|
|
48
49
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"@cspell/cspell-bundled-dicts": "^5.
|
|
51
|
-
"@cspell/cspell-types": "^5.
|
|
51
|
+
"@cspell/cspell-bundled-dicts": "^5.18.0",
|
|
52
|
+
"@cspell/cspell-types": "^5.18.0",
|
|
52
53
|
"clear-module": "^4.1.2",
|
|
53
54
|
"comment-json": "^4.1.1",
|
|
54
55
|
"configstore": "^5.0.1",
|
|
55
56
|
"cosmiconfig": "^7.0.1",
|
|
56
|
-
"cspell-glob": "^5.
|
|
57
|
-
"cspell-io": "^5.
|
|
58
|
-
"cspell-trie-lib": "^5.
|
|
57
|
+
"cspell-glob": "^5.18.0",
|
|
58
|
+
"cspell-io": "^5.18.0",
|
|
59
|
+
"cspell-trie-lib": "^5.18.0",
|
|
60
|
+
"fast-equals": "^2.0.4",
|
|
59
61
|
"find-up": "^5.0.0",
|
|
60
62
|
"fs-extra": "^10.0.0",
|
|
61
63
|
"gensequence": "^3.1.1",
|
|
@@ -70,7 +72,7 @@
|
|
|
70
72
|
"devDependencies": {
|
|
71
73
|
"@cspell/dict-cpp": "^1.1.40",
|
|
72
74
|
"@cspell/dict-csharp": "^1.0.11",
|
|
73
|
-
"@cspell/dict-css": "^1.0.
|
|
75
|
+
"@cspell/dict-css": "^1.0.13",
|
|
74
76
|
"@cspell/dict-fa-ir": "^1.0.17",
|
|
75
77
|
"@cspell/dict-fr-fr": "^2.0.1",
|
|
76
78
|
"@cspell/dict-html": "^1.1.9",
|
|
@@ -79,12 +81,14 @@
|
|
|
79
81
|
"@types/configstore": "^5.0.1",
|
|
80
82
|
"@types/fs-extra": "^9.0.13",
|
|
81
83
|
"@types/jest": "^27.4.0",
|
|
82
|
-
"@types/node": "^17.0.
|
|
84
|
+
"@types/node": "^17.0.13",
|
|
83
85
|
"cspell-dict-nl-nl": "^1.1.2",
|
|
84
86
|
"jest": "^27.4.7",
|
|
85
87
|
"lorem-ipsum": "^2.0.4",
|
|
86
88
|
"rimraf": "^3.0.2",
|
|
89
|
+
"rollup": "^2.66.1",
|
|
90
|
+
"rollup-plugin-dts": "^4.1.0",
|
|
87
91
|
"ts-jest": "^27.1.3"
|
|
88
92
|
},
|
|
89
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "ef4c46dfb6f2938724afb5332ea2fdf9b67d99e4"
|
|
90
94
|
}
|