cspell-lib 9.4.0 → 9.6.1
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/README.md +6 -6
- package/dist/cspell-rpc/api.d.ts +28 -0
- package/dist/cspell-rpc/api.js +6 -0
- package/dist/cspell-rpc/client.d.ts +17 -0
- package/dist/cspell-rpc/client.js +20 -0
- package/dist/cspell-rpc/index.d.ts +7 -0
- package/dist/cspell-rpc/index.js +4 -0
- package/dist/cspell-rpc/server.d.ts +16 -0
- package/dist/cspell-rpc/server.js +37 -0
- package/dist/cspell-rpc/spellCheckFile.d.ts +2 -0
- package/dist/cspell-rpc/spellCheckFile.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/Settings/CSpellSettingsServer.d.ts +4 -2
- package/dist/lib/Settings/CSpellSettingsServer.js +10 -2
- package/dist/lib/Settings/Controller/ImportError.js +3 -0
- package/dist/lib/Settings/Controller/configLoader/configLoader.d.ts +6 -4
- package/dist/lib/Settings/Controller/configLoader/configLoader.js +12 -6
- package/dist/lib/Settings/Controller/configLoader/configLocations.js +1 -0
- package/dist/lib/Settings/Controller/configLoader/defaultSettings.js +1 -1
- package/dist/lib/Settings/Controller/configLoader/normalizeRawSettings.js +1 -1
- package/dist/lib/Settings/Controller/configLoader/types.d.ts +1 -1
- package/dist/lib/Settings/DefaultSettings.d.ts +1 -1
- package/dist/lib/Settings/DefaultSettings.js +1 -1
- package/dist/lib/Settings/InDocSettings.d.ts +0 -3
- package/dist/lib/Settings/InDocSettings.js +2 -3
- package/dist/lib/Settings/LanguageSettings.js +3 -3
- package/dist/lib/Settings/RegExpPatterns.js +2 -2
- package/dist/lib/Settings/TextDocumentSettings.d.ts +1 -1
- package/dist/lib/Settings/cfgStore.d.ts +1 -1
- package/dist/lib/Settings/index.d.ts +3 -1
- package/dist/lib/Settings/index.js +2 -1
- package/dist/lib/Settings/internal/CSpellSettingsInternalDef.d.ts +18 -0
- package/dist/lib/{Models → Settings/internal}/CSpellSettingsInternalDef.js +1 -10
- package/dist/lib/Settings/{DictionarySettings.d.ts → internal/DictionarySettings.d.ts} +3 -2
- package/dist/lib/Settings/{DictionarySettings.js → internal/DictionarySettings.js} +20 -10
- package/dist/lib/{Models/CSpellSettingsInternalDef.d.ts → Settings/internal/InternalDictionaryDef.d.ts} +2 -17
- package/dist/lib/Settings/internal/InternalDictionaryDef.js +10 -0
- package/dist/lib/Settings/internal/index.d.ts +6 -0
- package/dist/lib/Settings/internal/index.js +4 -0
- package/dist/lib/Settings/link.js +1 -1
- package/dist/lib/Settings/mergeCache.d.ts +1 -1
- package/dist/lib/Settings/mergeList.d.ts +1 -1
- package/dist/lib/Settings/sanitizeSettings.d.ts +11 -0
- package/dist/lib/Settings/sanitizeSettings.js +254 -0
- package/dist/lib/Settings/util/settingsToJson.d.ts +28 -0
- package/dist/lib/Settings/util/settingsToJson.js +125 -0
- package/dist/lib/SpellingDictionary/Dictionaries.d.ts +1 -1
- package/dist/lib/SpellingDictionary/Dictionaries.js +1 -1
- package/dist/lib/SpellingDictionary/DictionaryController/DictionaryLoader.d.ts +1 -1
- package/dist/lib/SpellingDictionary/DictionaryController/DictionaryLoader.js +115 -28
- package/dist/lib/SpellingDictionary/DictionaryLoader.d.ts +1 -1
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.js +2 -2
- package/dist/lib/perf/index.d.ts +1 -0
- package/dist/lib/perf/index.js +1 -0
- package/dist/lib/spellCheckFile.d.ts +11 -1
- package/dist/lib/spellCheckFile.js +24 -4
- package/dist/lib/suggestions.d.ts +1 -1
- package/dist/lib/suggestions.js +3 -3
- package/dist/lib/textValidation/cleanValidationIssue.d.ts +3 -0
- package/dist/lib/textValidation/cleanValidationIssue.js +21 -0
- package/dist/lib/textValidation/determineTextDocumentSettings.d.ts +1 -1
- package/dist/lib/textValidation/docValidator.d.ts +6 -3
- package/dist/lib/textValidation/docValidator.js +29 -6
- package/dist/lib/textValidation/isRandomString.d.ts +1 -1
- package/dist/lib/textValidation/lineValidatorFactory.js +13 -5
- package/dist/lib/textValidation/settingsToValidateOptions.d.ts +1 -1
- package/dist/lib/textValidation/traceWord.d.ts +1 -0
- package/dist/lib/textValidation/traceWord.js +1 -0
- package/dist/lib/trace.d.ts +2 -1
- package/dist/lib/trace.js +2 -2
- package/dist/lib/util/clone.d.ts +35 -0
- package/dist/lib/util/clone.js +76 -0
- package/dist/lib/util/errors.js +1 -1
- package/dist/lib/util/memoizeLastCall.d.ts +13 -0
- package/dist/lib/util/{memorizeLastCall.js → memoizeLastCall.js} +2 -2
- package/dist/lib/util/memoizeWeak.d.ts +6 -0
- package/dist/lib/util/{memorizerWeak.js → memoizeWeak.js} +2 -2
- package/dist/lib/util/text.js +6 -4
- package/dist/lib/util/textRegex.d.ts +2 -2
- package/dist/lib/util/textRegex.js +2 -2
- package/dist/rpc/Future.d.ts +18 -0
- package/dist/rpc/Future.js +49 -0
- package/dist/rpc/MessagePortEvents.d.ts +56 -0
- package/dist/rpc/MessagePortEvents.js +94 -0
- package/dist/rpc/assert.d.ts +14 -0
- package/dist/rpc/assert.js +21 -0
- package/dist/rpc/client.d.ts +186 -0
- package/dist/rpc/client.js +364 -0
- package/dist/rpc/errors.d.ts +24 -0
- package/dist/rpc/errors.js +47 -0
- package/dist/rpc/index.d.ts +11 -0
- package/dist/rpc/index.js +6 -0
- package/dist/rpc/messagePort.d.ts +34 -0
- package/dist/rpc/messagePort.js +2 -0
- package/dist/rpc/models.d.ts +134 -0
- package/dist/rpc/models.js +2 -0
- package/dist/rpc/modelsHelpers.d.ts +56 -0
- package/dist/rpc/modelsHelpers.js +117 -0
- package/dist/rpc/notify.d.ts +79 -0
- package/dist/rpc/notify.js +135 -0
- package/dist/rpc/protocol.d.ts +21 -0
- package/dist/rpc/protocol.js +17 -0
- package/dist/rpc/server.d.ts +39 -0
- package/dist/rpc/server.js +146 -0
- package/dist/rpc/types.d.ts +9 -0
- package/dist/rpc/types.js +2 -0
- package/dist/rpc.d.ts +2 -0
- package/dist/rpc.js +2 -0
- package/package.json +41 -26
- package/dist/lib/perf/perf.d.ts +0 -20
- package/dist/lib/perf/perf.js +0 -32
- package/dist/lib/util/memorizeLastCall.d.ts +0 -13
- package/dist/lib/util/memorizerWeak.d.ts +0 -6
|
@@ -7,6 +7,7 @@ export function traceWord(word, dictCollection, config) {
|
|
|
7
7
|
const opts = {
|
|
8
8
|
ignoreCase: config.ignoreCase ?? true,
|
|
9
9
|
useCompounds: config.allowCompoundWords || false,
|
|
10
|
+
compoundSeparator: '•',
|
|
10
11
|
};
|
|
11
12
|
const splits = split({ text: word, offset: 0 }, 0, checkWord);
|
|
12
13
|
const wfSplits = splits.words.map((s) => ({ word: s.text, found: s.isFound }));
|
package/dist/lib/trace.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSpellSettings, LocaleId } from '@cspell/cspell-types';
|
|
2
|
-
import { ICSpellConfigFile } from 'cspell-config-lib';
|
|
2
|
+
import type { ICSpellConfigFile } from 'cspell-config-lib';
|
|
3
3
|
import type { LanguageId } from './fileTypes.js';
|
|
4
4
|
import type { DictionaryTraceResult, WordSplits } from './textValidation/traceWord.js';
|
|
5
5
|
export interface TraceResult extends DictionaryTraceResult {
|
|
@@ -11,6 +11,7 @@ export interface TraceOptions {
|
|
|
11
11
|
locale?: LocaleId;
|
|
12
12
|
ignoreCase?: boolean;
|
|
13
13
|
allowCompoundWords?: boolean;
|
|
14
|
+
compoundSeparator?: string | undefined;
|
|
14
15
|
}
|
|
15
16
|
export interface TraceWordResult extends Array<TraceResult> {
|
|
16
17
|
splits: readonly WordSplits[];
|
package/dist/lib/trace.js
CHANGED
|
@@ -15,7 +15,7 @@ export async function traceWords(words, settings, options) {
|
|
|
15
15
|
return s;
|
|
16
16
|
}
|
|
17
17
|
export async function* traceWordsAsync(words, settingsOrConfig, options) {
|
|
18
|
-
const { languageId, locale: language, ignoreCase = true, allowCompoundWords } = options || {};
|
|
18
|
+
const { languageId, locale: language, ignoreCase = true, allowCompoundWords, compoundSeparator } = options || {};
|
|
19
19
|
const settings = satisfiesCSpellConfigFile(settingsOrConfig)
|
|
20
20
|
? await resolveConfigFileImports(settingsOrConfig)
|
|
21
21
|
: settingsOrConfig;
|
|
@@ -44,7 +44,7 @@ export async function* traceWordsAsync(words, settingsOrConfig, options) {
|
|
|
44
44
|
const { config, dicts, activeDictionaries } = await finalize(settings);
|
|
45
45
|
const setOfActiveDicts = new Set(activeDictionaries);
|
|
46
46
|
function processWord(word) {
|
|
47
|
-
const results = traceWord(word, dicts, { ...config, ignoreCase });
|
|
47
|
+
const results = traceWord(word, dicts, { ...config, ignoreCase, compoundSeparator });
|
|
48
48
|
const r = results.map((r) => ({
|
|
49
49
|
...r,
|
|
50
50
|
dictActive: setOfActiveDicts.has(r.dictName),
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type Handler<T, K extends keyof T> = (src: Readonly<T>, dst: T, key: K) => void;
|
|
2
|
+
export type Handlers<T> = {
|
|
3
|
+
[key in keyof T]-?: Handler<T, key>;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Clones the properties from src to dst using the provided handlers.
|
|
7
|
+
* @param src
|
|
8
|
+
* @param dst
|
|
9
|
+
* @param handlers
|
|
10
|
+
* @param keys
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function cloneInto<T, K extends keyof T>(src: Readonly<T>, dst: Partial<T>, handlers: Handlers<T>, keys?: K[]): Pick<T, K>;
|
|
14
|
+
export declare function skip<T, K extends keyof T>(_src: Readonly<T>, _dst: T, _key: K): void;
|
|
15
|
+
/**
|
|
16
|
+
* Copy the property from src to dst.
|
|
17
|
+
* If the property is undefined, it is not copied.
|
|
18
|
+
* @param src - source object
|
|
19
|
+
* @param dst - destination object
|
|
20
|
+
* @param key - property key
|
|
21
|
+
*/
|
|
22
|
+
export declare function copy0<T, K extends keyof T>(src: Readonly<T>, dst: T, key: K): void;
|
|
23
|
+
/**
|
|
24
|
+
* Copy the property from src to dst.
|
|
25
|
+
* If the property is undefined, it is not copied.
|
|
26
|
+
* If the property is an array, a shallow copy of the array is made.
|
|
27
|
+
* If the property is a Set, a shallow copy of the Set is made.
|
|
28
|
+
* If the property is a Map, a shallow copy of the Map is made.
|
|
29
|
+
* If the property is an object, a shallow copy of the object is made.
|
|
30
|
+
* @param src - source object
|
|
31
|
+
* @param dst - destination object
|
|
32
|
+
* @param key - property key
|
|
33
|
+
*/
|
|
34
|
+
export declare function copy1<T, K extends keyof T>(src: Readonly<T>, dst: T, key: K): void;
|
|
35
|
+
//# sourceMappingURL=clone.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clones the properties from src to dst using the provided handlers.
|
|
3
|
+
* @param src
|
|
4
|
+
* @param dst
|
|
5
|
+
* @param handlers
|
|
6
|
+
* @param keys
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export function cloneInto(src, dst, handlers, keys) {
|
|
10
|
+
const keysToProcess = keys || Object.keys(handlers);
|
|
11
|
+
for (const key of keysToProcess) {
|
|
12
|
+
if (src[key] === undefined)
|
|
13
|
+
continue;
|
|
14
|
+
const handler = handlers[key];
|
|
15
|
+
if (handler === skip)
|
|
16
|
+
continue;
|
|
17
|
+
handler(src, dst, key);
|
|
18
|
+
}
|
|
19
|
+
return dst;
|
|
20
|
+
}
|
|
21
|
+
export function skip(_src, _dst, _key) {
|
|
22
|
+
// do nothing
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Copy the property from src to dst.
|
|
26
|
+
* If the property is undefined, it is not copied.
|
|
27
|
+
* @param src - source object
|
|
28
|
+
* @param dst - destination object
|
|
29
|
+
* @param key - property key
|
|
30
|
+
*/
|
|
31
|
+
export function copy0(src, dst, key) {
|
|
32
|
+
const value = src[key];
|
|
33
|
+
if (value === undefined)
|
|
34
|
+
return;
|
|
35
|
+
dst[key] = value;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Copy the property from src to dst.
|
|
39
|
+
* If the property is undefined, it is not copied.
|
|
40
|
+
* If the property is an array, a shallow copy of the array is made.
|
|
41
|
+
* If the property is a Set, a shallow copy of the Set is made.
|
|
42
|
+
* If the property is a Map, a shallow copy of the Map is made.
|
|
43
|
+
* If the property is an object, a shallow copy of the object is made.
|
|
44
|
+
* @param src - source object
|
|
45
|
+
* @param dst - destination object
|
|
46
|
+
* @param key - property key
|
|
47
|
+
*/
|
|
48
|
+
export function copy1(src, dst, key) {
|
|
49
|
+
if (src[key] === undefined)
|
|
50
|
+
return;
|
|
51
|
+
const value = src[key];
|
|
52
|
+
if (value === undefined)
|
|
53
|
+
return;
|
|
54
|
+
if (Array.isArray(value)) {
|
|
55
|
+
dst[key] = [...value];
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (value instanceof Set) {
|
|
59
|
+
dst[key] = new Set(value);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (value instanceof Map) {
|
|
63
|
+
dst[key] = new Map(value);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (value instanceof RegExp) {
|
|
67
|
+
dst[key] = value;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (typeof value === 'object') {
|
|
71
|
+
dst[key] = { ...value };
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
dst[key] = value;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=clone.js.map
|
package/dist/lib/util/errors.js
CHANGED
|
@@ -26,7 +26,7 @@ export function isError(e) {
|
|
|
26
26
|
if (!e || typeof e !== 'object')
|
|
27
27
|
return false;
|
|
28
28
|
const ex = e;
|
|
29
|
-
return typeof ex.name
|
|
29
|
+
return typeof ex.name === 'string' && typeof ex.message === 'string' && (typeof ex.stack) in allowStringOrUndefined;
|
|
30
30
|
}
|
|
31
31
|
export function toError(e, errorFactory = UnknownError) {
|
|
32
32
|
if (isError(e))
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a function that memoizes the last call. If the next call is called with the same arguments, the
|
|
3
|
+
* the last value is returned.
|
|
4
|
+
* @param fn - function to memoize
|
|
5
|
+
* @returns a new function.
|
|
6
|
+
*/
|
|
7
|
+
export declare function memoizeLastCall<T>(fn: (...p: []) => T): (...p: []) => T;
|
|
8
|
+
export declare function memoizeLastCall<T, K0>(fn: (...p: [K0]) => T): (...p: [K0]) => T;
|
|
9
|
+
export declare function memoizeLastCall<T, K0, K1>(fn: (...p: [K0, K1]) => T): (...p: [K0, K1]) => T;
|
|
10
|
+
export declare function memoizeLastCall<T, K0, K1, K2>(fn: (...p: [K0, K1, K2]) => T): (...p: [K0, K1, K2]) => T;
|
|
11
|
+
export declare function memoizeLastCall<T, K0, K1, K2, K3>(fn: (...p: [K0, K1, K2, K3]) => T): (...p: [K0, K1, K2, K3]) => T;
|
|
12
|
+
export declare function memoizeLastCall<T, K>(fn: (...p: [...K[]]) => T): (...p: [...K[]]) => T;
|
|
13
|
+
//# sourceMappingURL=memoizeLastCall.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isArrayEqual } from './util.js';
|
|
2
|
-
export function
|
|
2
|
+
export function memoizeLastCall(fn) {
|
|
3
3
|
let last;
|
|
4
4
|
return (...p) => {
|
|
5
5
|
if (last && isArrayEqual(last.args, p)) {
|
|
@@ -11,4 +11,4 @@ export function memorizeLastCall(fn) {
|
|
|
11
11
|
return value;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=memoizeLastCall.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function memoizeWeak<T, K extends object>(fn: (...p: [...K[]]) => T): (...p: [...K[]]) => T;
|
|
2
|
+
export declare function memoizeWeak<T, K0 extends object, K1 extends object>(fn: (...p: [K0, K1]) => T): (...p: [K0, K1]) => T;
|
|
3
|
+
export declare function memoizeWeak<T, K0 extends object, K1 extends object, K2 extends object>(fn: (...p: [K0, K1, K2]) => T): (...p: [K0, K1, K2]) => T;
|
|
4
|
+
export declare function memoizeWeak<T, K0 extends object, K1 extends object, K2 extends object, K3 extends object>(fn: (...p: [K0, K1, K2, K3]) => T): (...p: [K0, K1, K2, K3]) => T;
|
|
5
|
+
export declare function memoizeWeak<T, K0 extends object>(fn: (...p: [K0]) => T): (...p: [K0]) => T;
|
|
6
|
+
//# sourceMappingURL=memoizeWeak.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// prettier-ignore
|
|
2
|
-
export function
|
|
2
|
+
export function memoizeWeak(fn) {
|
|
3
3
|
const r = {};
|
|
4
4
|
function find(p) {
|
|
5
5
|
let n = r;
|
|
@@ -35,4 +35,4 @@ export function memorizerWeak(fn) {
|
|
|
35
35
|
return v;
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
//# sourceMappingURL=
|
|
38
|
+
//# sourceMappingURL=memoizeWeak.js.map
|
package/dist/lib/util/text.js
CHANGED
|
@@ -27,7 +27,7 @@ export function splitWordWithOffset(wo, regExpWordBreaks) {
|
|
|
27
27
|
* Split camelCase words into an array of strings.
|
|
28
28
|
*/
|
|
29
29
|
export function splitWord(word, regExpWordBreaks) {
|
|
30
|
-
return word.split(regExpWordBreaks);
|
|
30
|
+
return word.split(new RegExp(regExpWordBreaks));
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* This function lets you iterate over regular expression matches.
|
|
@@ -35,7 +35,7 @@ export function splitWord(word, regExpWordBreaks) {
|
|
|
35
35
|
export function match(reg, text) {
|
|
36
36
|
if (!text)
|
|
37
37
|
return [];
|
|
38
|
-
reg = reg.global ? reg : new RegExp(reg.source, reg.flags + 'g');
|
|
38
|
+
reg = reg.global ? new RegExp(reg) : new RegExp(reg.source, reg.flags + 'g');
|
|
39
39
|
return text.matchAll(reg);
|
|
40
40
|
}
|
|
41
41
|
export function matchStringToTextOffset(reg, text) {
|
|
@@ -78,6 +78,7 @@ export function cleanText(text) {
|
|
|
78
78
|
regExIgnoreCharacters.lastIndex = 0;
|
|
79
79
|
if (!regExIgnoreCharacters.test(text))
|
|
80
80
|
return text;
|
|
81
|
+
regExIgnoreCharacters.lastIndex = 0;
|
|
81
82
|
text = text.replace(regExIgnoreCharacters, (match) => ' '.repeat(match.length));
|
|
82
83
|
return text;
|
|
83
84
|
}
|
|
@@ -191,10 +192,11 @@ export function calculateTextDocumentOffsets(uri, doc, wordOffsets) {
|
|
|
191
192
|
});
|
|
192
193
|
}
|
|
193
194
|
export function removeAccents(text) {
|
|
195
|
+
regExAccents.lastIndex = 0;
|
|
194
196
|
return text.normalize('NFD').replace(regExAccents, '');
|
|
195
197
|
}
|
|
196
198
|
export const __testing__ = {
|
|
197
|
-
regExWords,
|
|
198
|
-
regExWordsAndDigits,
|
|
199
|
+
regExWords: regExWords,
|
|
200
|
+
regExWordsAndDigits: regExWordsAndDigits,
|
|
199
201
|
};
|
|
200
202
|
//# sourceMappingURL=text.js.map
|
|
@@ -2,8 +2,8 @@ export declare const regExUpperSOrIng: RegExp;
|
|
|
2
2
|
export declare const regExSplitWords: RegExp;
|
|
3
3
|
export declare const regExSplitWords2: RegExp;
|
|
4
4
|
export declare const regExpCamelCaseWordBreaksWithEnglishSuffix: RegExp;
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const regExpCamelCaseWordBreaks_NOT_USED: RegExp;
|
|
6
|
+
export declare const regExpAllPossibleWordBreaks_NOT_USED: RegExp;
|
|
7
7
|
export declare const regExWords: RegExp;
|
|
8
8
|
export declare const regExWordsAndDigits: RegExp;
|
|
9
9
|
export declare const regExIgnoreCharacters: RegExp;
|
|
@@ -3,8 +3,8 @@ export const regExUpperSOrIng = /([\p{Lu}\p{M}]+(?:\\?['’])?(?:s|ing|ies|es|in
|
|
|
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
5
|
export const regExpCamelCaseWordBreaksWithEnglishSuffix = /(?<=\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
|
|
7
|
-
export const
|
|
6
|
+
export const regExpCamelCaseWordBreaks_NOT_USED = /(?<=\p{Ll}\p{M}?)(?=\p{Lu})|(?<=\p{Lu}\p{M}?)(?=\p{Lu}\p{M}?\p{Ll})/gu;
|
|
7
|
+
export const regExpAllPossibleWordBreaks_NOT_USED = /(?<=\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;
|
|
8
8
|
export const regExWords = /\p{L}\p{M}?(?:(?:\\?['’])?\p{L}\p{M}?)*/gu;
|
|
9
9
|
// Words can be made of letters, numbers, period, underscore, dash, plus, and single quote
|
|
10
10
|
export const regExWordsAndDigits = /[\p{L}\w'’`.+-](?:(?:\\(?=[']))?[\p{L}\p{M}\w'’`.+-])*/gu;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class Future<T> {
|
|
2
|
+
#private;
|
|
3
|
+
constructor();
|
|
4
|
+
/**
|
|
5
|
+
* Indicates if the promise has been resolved or rejected.
|
|
6
|
+
*
|
|
7
|
+
* Use isRejected to determine if it was rejected.
|
|
8
|
+
*/
|
|
9
|
+
get isResolved(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Indicates if the promise has been rejected.
|
|
12
|
+
*/
|
|
13
|
+
get isRejected(): boolean;
|
|
14
|
+
get promise(): Promise<T>;
|
|
15
|
+
resolve(value: T): void;
|
|
16
|
+
reject(reason?: unknown): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=Future.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export class Future {
|
|
2
|
+
#isResolved = false;
|
|
3
|
+
#isRejected = false;
|
|
4
|
+
#promise;
|
|
5
|
+
#resolve;
|
|
6
|
+
#reject;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.#reject = noop;
|
|
9
|
+
this.#resolve = noop;
|
|
10
|
+
this.#promise = new Promise((resolve, reject) => {
|
|
11
|
+
this.#resolve = resolve;
|
|
12
|
+
this.#reject = reject;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Indicates if the promise has been resolved or rejected.
|
|
17
|
+
*
|
|
18
|
+
* Use isRejected to determine if it was rejected.
|
|
19
|
+
*/
|
|
20
|
+
get isResolved() {
|
|
21
|
+
return this.#isResolved;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Indicates if the promise has been rejected.
|
|
25
|
+
*/
|
|
26
|
+
get isRejected() {
|
|
27
|
+
return this.#isRejected;
|
|
28
|
+
}
|
|
29
|
+
get promise() {
|
|
30
|
+
return this.#promise;
|
|
31
|
+
}
|
|
32
|
+
resolve(value) {
|
|
33
|
+
if (this.#isResolved)
|
|
34
|
+
return;
|
|
35
|
+
this.#isResolved = true;
|
|
36
|
+
this.#resolve(value);
|
|
37
|
+
}
|
|
38
|
+
reject(reason) {
|
|
39
|
+
if (this.#isResolved)
|
|
40
|
+
return;
|
|
41
|
+
this.#isResolved = true;
|
|
42
|
+
this.#isRejected = true;
|
|
43
|
+
this.#reject(reason);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function noop() {
|
|
47
|
+
// do nothing
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=Future.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { MessagePortLike } from './messagePort.js';
|
|
2
|
+
import type { NotifyEvent } from './notify.js';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a {@link MessagePortLike} and exposes its key events through a
|
|
5
|
+
* {@link NotifyEmitter}-based interface.
|
|
6
|
+
*
|
|
7
|
+
* This class listens to the underlying port's `message`,
|
|
8
|
+
* `messageerror`, and `close` events and re-emits them as
|
|
9
|
+
* {@link NotifyEvent} instances, making it easier to subscribe to and manage
|
|
10
|
+
* notifications from a message port.
|
|
11
|
+
*/
|
|
12
|
+
export declare class MessagePortNotifyEvents<T extends MessagePortLike = MessagePortLike> {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(port: T);
|
|
15
|
+
[Symbol.dispose](): void;
|
|
16
|
+
/**
|
|
17
|
+
* Register a handler to be called when a message is received.
|
|
18
|
+
*/
|
|
19
|
+
get onMessage(): NotifyEvent<unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Return a Promise that resolves on the next message.
|
|
22
|
+
* @param signal - A signal to abort the wait.
|
|
23
|
+
* @returns A Promise that resolves with the next message received.
|
|
24
|
+
*/
|
|
25
|
+
readonly awaitNextMessage: (signal?: AbortSignal) => Promise<unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Return a Promise that resolves on the close event.
|
|
28
|
+
* @param signal - A signal to abort the wait.
|
|
29
|
+
* @returns A Promise that resolves when the port is closed.
|
|
30
|
+
*/
|
|
31
|
+
readonly awaitClose: (signal?: AbortSignal) => Promise<Event>;
|
|
32
|
+
/**
|
|
33
|
+
* Post a message to the underlying port.
|
|
34
|
+
* @param message - The message to post.
|
|
35
|
+
*/
|
|
36
|
+
readonly postMessage: T['postMessage'];
|
|
37
|
+
/**
|
|
38
|
+
* Start the underlying port.
|
|
39
|
+
*/
|
|
40
|
+
start(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Close the underlying port.
|
|
43
|
+
*/
|
|
44
|
+
close(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Register a handler to be called when the port is closed.
|
|
47
|
+
*/
|
|
48
|
+
get onClose(): NotifyEvent<Event>;
|
|
49
|
+
/**
|
|
50
|
+
* Register a handler to be called when a message error is received.
|
|
51
|
+
*/
|
|
52
|
+
get onMessageError(): NotifyEvent<Error>;
|
|
53
|
+
get isClosed(): boolean;
|
|
54
|
+
get port(): T;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=MessagePortEvents.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { NotifyEmitter } from './notify.js';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a {@link MessagePortLike} and exposes its key events through a
|
|
4
|
+
* {@link NotifyEmitter}-based interface.
|
|
5
|
+
*
|
|
6
|
+
* This class listens to the underlying port's `message`,
|
|
7
|
+
* `messageerror`, and `close` events and re-emits them as
|
|
8
|
+
* {@link NotifyEvent} instances, making it easier to subscribe to and manage
|
|
9
|
+
* notifications from a message port.
|
|
10
|
+
*/
|
|
11
|
+
export class MessagePortNotifyEvents {
|
|
12
|
+
#notifyMessage = new NotifyEmitter();
|
|
13
|
+
#notifyClose = new NotifyEmitter();
|
|
14
|
+
#notifyMessageError = new NotifyEmitter();
|
|
15
|
+
#port;
|
|
16
|
+
#disposed = false;
|
|
17
|
+
#closed;
|
|
18
|
+
constructor(port) {
|
|
19
|
+
this.#port = port;
|
|
20
|
+
this.#port.addListener('message', this.#notifyMessage.notify);
|
|
21
|
+
this.#port.addListener('messageerror', this.#notifyMessageError.notify);
|
|
22
|
+
this.#port.addListener('close', this.#notifyClose.notify);
|
|
23
|
+
this.#notifyClose.once((event) => (this.#closed = event));
|
|
24
|
+
}
|
|
25
|
+
[Symbol.dispose]() {
|
|
26
|
+
if (this.#disposed)
|
|
27
|
+
return;
|
|
28
|
+
this.#disposed = true;
|
|
29
|
+
this.#port.removeListener('message', this.#notifyMessage.notify);
|
|
30
|
+
this.#port.removeListener('messageerror', this.#notifyMessageError.notify);
|
|
31
|
+
this.#port.removeListener('close', this.#notifyClose.notify);
|
|
32
|
+
this.#notifyMessage[Symbol.dispose]();
|
|
33
|
+
this.#notifyClose[Symbol.dispose]();
|
|
34
|
+
this.#notifyMessageError[Symbol.dispose]();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Register a handler to be called when a message is received.
|
|
38
|
+
*/
|
|
39
|
+
get onMessage() {
|
|
40
|
+
return this.#notifyMessage.onEvent;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Return a Promise that resolves on the next message.
|
|
44
|
+
* @param signal - A signal to abort the wait.
|
|
45
|
+
* @returns A Promise that resolves with the next message received.
|
|
46
|
+
*/
|
|
47
|
+
awaitNextMessage = (signal) => this.#notifyMessage.awaitNext(signal);
|
|
48
|
+
/**
|
|
49
|
+
* Return a Promise that resolves on the close event.
|
|
50
|
+
* @param signal - A signal to abort the wait.
|
|
51
|
+
* @returns A Promise that resolves when the port is closed.
|
|
52
|
+
*/
|
|
53
|
+
awaitClose = (signal) => {
|
|
54
|
+
if (this.#closed)
|
|
55
|
+
return Promise.resolve(this.#closed);
|
|
56
|
+
return this.#notifyClose.awaitNext(signal);
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Post a message to the underlying port.
|
|
60
|
+
* @param message - The message to post.
|
|
61
|
+
*/
|
|
62
|
+
postMessage = (message) => this.#port.postMessage(message);
|
|
63
|
+
/**
|
|
64
|
+
* Start the underlying port.
|
|
65
|
+
*/
|
|
66
|
+
start() {
|
|
67
|
+
this.#port.start?.();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Close the underlying port.
|
|
71
|
+
*/
|
|
72
|
+
close() {
|
|
73
|
+
this.#port.close?.();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Register a handler to be called when the port is closed.
|
|
77
|
+
*/
|
|
78
|
+
get onClose() {
|
|
79
|
+
return this.#notifyClose.onEvent;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Register a handler to be called when a message error is received.
|
|
83
|
+
*/
|
|
84
|
+
get onMessageError() {
|
|
85
|
+
return this.#notifyMessageError.onEvent;
|
|
86
|
+
}
|
|
87
|
+
get isClosed() {
|
|
88
|
+
return this.#closed !== undefined;
|
|
89
|
+
}
|
|
90
|
+
get port() {
|
|
91
|
+
return this.#port;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=MessagePortEvents.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Note: This code is here to avoid a dependency on Node's 'assert' module.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Asserts that a condition is true.
|
|
6
|
+
* @param condition - The condition to assert.
|
|
7
|
+
* @param msg - optional message for the assertion error.
|
|
8
|
+
* @throws {AssertionError} If the condition is false.
|
|
9
|
+
*/
|
|
10
|
+
export declare function assert(condition: unknown, msg?: string): asserts condition;
|
|
11
|
+
export declare class AssertionError extends Error {
|
|
12
|
+
constructor(message?: string);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Note: This code is here to avoid a dependency on Node's 'assert' module.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Asserts that a condition is true.
|
|
6
|
+
* @param condition - The condition to assert.
|
|
7
|
+
* @param msg - optional message for the assertion error.
|
|
8
|
+
* @throws {AssertionError} If the condition is false.
|
|
9
|
+
*/
|
|
10
|
+
export function assert(condition, msg) {
|
|
11
|
+
if (!condition) {
|
|
12
|
+
throw new AssertionError(msg);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class AssertionError extends Error {
|
|
16
|
+
constructor(message) {
|
|
17
|
+
super(message || 'Assertion failed');
|
|
18
|
+
this.name = 'AssertionError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=assert.js.map
|