cspell-lib 9.6.2 → 9.6.4
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/cspell-rpc/client.d.ts +3 -3
- package/dist/cspell-rpc/client.js +1 -1
- package/dist/cspell-rpc/server.d.ts +3 -3
- package/dist/cspell-rpc/server.js +1 -1
- package/dist/lib/Settings/DictionaryReferenceCollection.d.ts +9 -1
- package/dist/lib/Settings/DictionaryReferenceCollection.js +5 -0
- package/dist/lib/Settings/index.d.ts +2 -0
- package/dist/lib/Settings/index.js +1 -0
- package/dist/lib/Settings/sanitizeSettings.js +2 -0
- package/dist/lib/index.d.ts +2 -3
- package/dist/lib/index.js +1 -2
- package/dist/lib/trace.d.ts +2 -0
- package/dist/lib/trace.js +9 -4
- package/dist/rpc.d.ts +1 -1
- package/dist/rpc.js +1 -1
- package/package.json +22 -21
- package/dist/rpc/Future.d.ts +0 -18
- package/dist/rpc/Future.js +0 -49
- package/dist/rpc/MessagePortEvents.d.ts +0 -56
- package/dist/rpc/MessagePortEvents.js +0 -94
- package/dist/rpc/assert.d.ts +0 -14
- package/dist/rpc/assert.js +0 -21
- package/dist/rpc/client.d.ts +0 -186
- package/dist/rpc/client.js +0 -364
- package/dist/rpc/errors.d.ts +0 -24
- package/dist/rpc/errors.js +0 -47
- package/dist/rpc/index.d.ts +0 -11
- package/dist/rpc/index.js +0 -6
- package/dist/rpc/messagePort.d.ts +0 -34
- package/dist/rpc/messagePort.js +0 -2
- package/dist/rpc/models.d.ts +0 -134
- package/dist/rpc/models.js +0 -2
- package/dist/rpc/modelsHelpers.d.ts +0 -56
- package/dist/rpc/modelsHelpers.js +0 -117
- package/dist/rpc/notify.d.ts +0 -79
- package/dist/rpc/notify.js +0 -135
- package/dist/rpc/protocol.d.ts +0 -21
- package/dist/rpc/protocol.js +0 -17
- package/dist/rpc/server.d.ts +0 -39
- package/dist/rpc/server.js +0 -146
- package/dist/rpc/types.d.ts +0 -9
- package/dist/rpc/types.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { RPCClientConfiguration, RPCClientOptions, RPCProtocol } from '
|
|
2
|
-
import { RPCClient } from '
|
|
1
|
+
import type { RPCClientConfiguration, RPCClientOptions, RPCProtocol } from '@cspell/rpc';
|
|
2
|
+
import { RPCClient } from '@cspell/rpc';
|
|
3
3
|
import type { CSpellRPCApi } from './api.js';
|
|
4
|
-
export type { MessagePortLike } from '
|
|
4
|
+
export type { MessagePortLike } from '@cspell/rpc';
|
|
5
5
|
export type CSpellRPCClientOptions = RPCClientOptions;
|
|
6
6
|
export type CSpellRPCClientConfig = RPCClientConfiguration;
|
|
7
7
|
export declare class CSpellRPCClient extends RPCClient<CSpellRPCApi> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { RPCServerConfiguration, RPCServerOptions } from '
|
|
2
|
-
import { RPCServer } from '
|
|
1
|
+
import type { RPCServerConfiguration, RPCServerOptions } from '@cspell/rpc';
|
|
2
|
+
import { RPCServer } from '@cspell/rpc';
|
|
3
3
|
import type { CSpellRPCApi } from './api.js';
|
|
4
|
-
export type { MessagePortLike } from '
|
|
4
|
+
export type { MessagePortLike } from '@cspell/rpc';
|
|
5
5
|
export type CSpellRPCServerOptions = RPCServerOptions;
|
|
6
6
|
export type CSpellRPCServerConfig = RPCServerConfiguration;
|
|
7
7
|
export declare class CSpellRPCServer extends RPCServer<CSpellRPCApi> {
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { DictionaryId, DictionaryReference } from '@cspell/cspell-types';
|
|
2
|
+
/**
|
|
3
|
+
* A collection of dictionary references to determine if a dictionary is enabled or blocked.
|
|
4
|
+
*/
|
|
2
5
|
export interface DictionaryReferenceCollection {
|
|
3
6
|
isEnabled(name: DictionaryId): boolean | undefined;
|
|
4
7
|
isBlocked(name: DictionaryId): boolean | undefined;
|
|
5
8
|
enabled(): DictionaryId[];
|
|
6
9
|
blocked(): DictionaryId[];
|
|
7
|
-
dictionaryIds: DictionaryId[];
|
|
10
|
+
readonly dictionaryIds: DictionaryId[];
|
|
8
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a collection of dictionary references to be able to easily determine if a dictionary is enabled or blocked.
|
|
14
|
+
* @param dictionaries - list of dictionary references
|
|
15
|
+
* @returns DictionaryReferenceCollection
|
|
16
|
+
*/
|
|
9
17
|
export declare function createDictionaryReferenceCollection(dictionaries: DictionaryReference[]): DictionaryReferenceCollection;
|
|
10
18
|
//# sourceMappingURL=DictionaryReferenceCollection.d.ts.map
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a collection of dictionary references to be able to easily determine if a dictionary is enabled or blocked.
|
|
3
|
+
* @param dictionaries - list of dictionary references
|
|
4
|
+
* @returns DictionaryReferenceCollection
|
|
5
|
+
*/
|
|
1
6
|
export function createDictionaryReferenceCollection(dictionaries) {
|
|
2
7
|
return new _DictionaryReferenceCollection(dictionaries);
|
|
3
8
|
}
|
|
@@ -7,6 +7,8 @@ export { ImportError } from './Controller/ImportError.js';
|
|
|
7
7
|
export type { ConfigurationDependencies, ImportFileRefWithError } from './CSpellSettingsServer.js';
|
|
8
8
|
export { extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, toCSpellSettingsWithOutSourceTrace, } from './CSpellSettingsServer.js';
|
|
9
9
|
export { defaultSettingsLoader, getDefaultBundledSettingsAsync, getDefaultSettings } from './DefaultSettings.js';
|
|
10
|
+
export type { DictionaryReferenceCollection } from './DictionaryReferenceCollection.js';
|
|
11
|
+
export { createDictionaryReferenceCollection } from './DictionaryReferenceCollection.js';
|
|
10
12
|
export type { CSpellSettingsInternal, CSpellSettingsInternalFinalized, DictionaryDefinitionInlineInternal, DictionaryDefinitionInternal, DictionaryDefinitionSimpleInternal, DictionaryFileDefinitionInternal, } from './internal/index.js';
|
|
11
13
|
export { calcDictionaryDefsToLoad, createCSpellSettingsInternal, filterDictDefsToLoad, isDictionaryDefinitionInlineInternal, isDictionaryFileDefinitionInternal, mapDictDefToInternal, } from './internal/index.js';
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -5,5 +5,6 @@ export { clearCachedSettingsFiles, createConfigLoader, defaultConfigFilenames, d
|
|
|
5
5
|
export { ImportError } from './Controller/ImportError.js';
|
|
6
6
|
export { extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, toCSpellSettingsWithOutSourceTrace, } from './CSpellSettingsServer.js';
|
|
7
7
|
export { defaultSettingsLoader, getDefaultBundledSettingsAsync, getDefaultSettings } from './DefaultSettings.js';
|
|
8
|
+
export { createDictionaryReferenceCollection } from './DictionaryReferenceCollection.js';
|
|
8
9
|
export { calcDictionaryDefsToLoad, createCSpellSettingsInternal, filterDictDefsToLoad, isDictionaryDefinitionInlineInternal, isDictionaryFileDefinitionInternal, mapDictDefToInternal, } from './internal/index.js';
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -28,6 +28,7 @@ const handlers = {
|
|
|
28
28
|
enableFiletypes: copy1,
|
|
29
29
|
enabledFileTypes: copy1,
|
|
30
30
|
enableGlobDot: copy1,
|
|
31
|
+
engines: copy1,
|
|
31
32
|
failFast: copy1,
|
|
32
33
|
features: skip,
|
|
33
34
|
files: copyGlobsSettingsFields,
|
|
@@ -68,6 +69,7 @@ const handlers = {
|
|
|
68
69
|
usePnP: skip,
|
|
69
70
|
userWords: copy1,
|
|
70
71
|
validateDirectives: copy1,
|
|
72
|
+
vfs: skip,
|
|
71
73
|
words: copy1,
|
|
72
74
|
// Experimental
|
|
73
75
|
parser: skip,
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -12,9 +12,8 @@ export type { CreateTextDocumentParams, TextDocument, TextDocumentLine, TextDocu
|
|
|
12
12
|
export { createTextDocument, updateTextDocument } from './Models/TextDocument.js';
|
|
13
13
|
export type { PerfTimer } from './perf/index.js';
|
|
14
14
|
export { createPerfTimer } from './perf/index.js';
|
|
15
|
-
export type { ConfigurationDependencies, CSpellConfigFile, ICSpellConfigFile, ImportFileRefWithError, } from './Settings/index.js';
|
|
16
|
-
export { calcOverrideSettings, checkFilenameMatchesGlob, createConfigLoader, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, finalizeSettings, getCachedFileSize, getDefaultBundledSettingsAsync, getDefaultConfigLoader, getDefaultSettings, getGlobalSettings, getGlobalSettingsAsync, getSources, ImportError, loadConfig, loadPnP, mergeInDocSettings, mergeSettings, readConfigFile, readRawSettings, readSettings, readSettingsFiles, resolveConfigFileImports, searchForConfig, sectionCSpell, toCSpellSettingsWithOutSourceTrace, } from './Settings/index.js';
|
|
17
|
-
export { defaultFileName as defaultSettingsFilename } from './Settings/index.js';
|
|
15
|
+
export type { ConfigurationDependencies, CSpellConfigFile, DictionaryReferenceCollection, ICSpellConfigFile, ImportFileRefWithError, } from './Settings/index.js';
|
|
16
|
+
export { calcOverrideSettings, checkFilenameMatchesGlob, createConfigLoader, createDictionaryReferenceCollection, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, defaultFileName as defaultSettingsFilename, ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, finalizeSettings, getCachedFileSize, getDefaultBundledSettingsAsync, getDefaultConfigLoader, getDefaultSettings, getGlobalSettings, getGlobalSettingsAsync, getSources, ImportError, loadConfig, loadPnP, mergeInDocSettings, mergeSettings, readConfigFile, readRawSettings, readSettings, readSettingsFiles, resolveConfigFileImports, searchForConfig, sectionCSpell, toCSpellSettingsWithOutSourceTrace, } from './Settings/index.js';
|
|
18
17
|
export * as Link from './Settings/index.link.js';
|
|
19
18
|
export { combineTextAndLanguageSettings, combineTextAndLanguageSettings as constructSettingsForText, } from './Settings/TextDocumentSettings.js';
|
|
20
19
|
export { determineFinalDocumentSettings, type DetermineFinalDocumentSettingsResult, spellCheckDocument, spellCheckDocumentRPC, spellCheckFile, type SpellCheckFileOptions, type SpellCheckFilePerf, type SpellCheckFileResult, } from './spellCheckFile.js';
|
package/dist/lib/index.js
CHANGED
|
@@ -7,8 +7,7 @@ export { getLanguagesForBasename as getLanguageIdsForBaseFilename, getLanguagesF
|
|
|
7
7
|
export { getDictionary } from './getDictionary.js';
|
|
8
8
|
export { createTextDocument, updateTextDocument } from './Models/TextDocument.js';
|
|
9
9
|
export { createPerfTimer } from './perf/index.js';
|
|
10
|
-
export { calcOverrideSettings, checkFilenameMatchesGlob, createConfigLoader, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, finalizeSettings, getCachedFileSize, getDefaultBundledSettingsAsync, getDefaultConfigLoader, getDefaultSettings, getGlobalSettings, getGlobalSettingsAsync, getSources, ImportError, loadConfig, loadPnP, mergeInDocSettings, mergeSettings, readConfigFile, readRawSettings, readSettings, readSettingsFiles, resolveConfigFileImports, searchForConfig, sectionCSpell, toCSpellSettingsWithOutSourceTrace, } from './Settings/index.js';
|
|
11
|
-
export { defaultFileName as defaultSettingsFilename } from './Settings/index.js';
|
|
10
|
+
export { calcOverrideSettings, checkFilenameMatchesGlob, createConfigLoader, createDictionaryReferenceCollection, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, defaultFileName as defaultSettingsFilename, ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, finalizeSettings, getCachedFileSize, getDefaultBundledSettingsAsync, getDefaultConfigLoader, getDefaultSettings, getGlobalSettings, getGlobalSettingsAsync, getSources, ImportError, loadConfig, loadPnP, mergeInDocSettings, mergeSettings, readConfigFile, readRawSettings, readSettings, readSettingsFiles, resolveConfigFileImports, searchForConfig, sectionCSpell, toCSpellSettingsWithOutSourceTrace, } from './Settings/index.js';
|
|
12
11
|
export * as Link from './Settings/index.link.js';
|
|
13
12
|
export { combineTextAndLanguageSettings, combineTextAndLanguageSettings as constructSettingsForText, } from './Settings/TextDocumentSettings.js';
|
|
14
13
|
export { determineFinalDocumentSettings, spellCheckDocument, spellCheckDocumentRPC, spellCheckFile, } from './spellCheckFile.js';
|
package/dist/lib/trace.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { DictionaryTraceResult, WordSplits } from './textValidation/traceWo
|
|
|
5
5
|
export interface TraceResult extends DictionaryTraceResult {
|
|
6
6
|
/** True if the dictionary is currently active. */
|
|
7
7
|
dictActive: boolean;
|
|
8
|
+
/** True if the dictionary is blocked from use. */
|
|
9
|
+
dictBlocked: boolean;
|
|
8
10
|
}
|
|
9
11
|
export interface TraceOptions {
|
|
10
12
|
languageId?: LanguageId | LanguageId[];
|
package/dist/lib/trace.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { satisfiesCSpellConfigFile } from 'cspell-config-lib';
|
|
2
2
|
import { genSequence } from 'gensequence';
|
|
3
3
|
import { toInternalSettings } from './Settings/CSpellSettingsServer.js';
|
|
4
|
-
import { finalizeSettings, mergeSettings, resolveConfigFileImports } from './Settings/index.js';
|
|
4
|
+
import { createDictionaryReferenceCollection, finalizeSettings, mergeSettings, resolveConfigFileImports, } from './Settings/index.js';
|
|
5
5
|
import { calcSettingsForLanguageId } from './Settings/LanguageSettings.js';
|
|
6
6
|
import { getDictionaryInternal, refreshDictionaryCache } from './SpellingDictionary/index.js';
|
|
7
7
|
import { traceWord } from './textValidation/traceWord.js';
|
|
@@ -26,28 +26,33 @@ export async function* traceWordsAsync(words, settingsOrConfig, options) {
|
|
|
26
26
|
}));
|
|
27
27
|
const withLanguageId = calcSettingsForLanguageId(withLocale, languageId ?? withLocale.languageId ?? 'plaintext');
|
|
28
28
|
const settings = finalizeSettings(withLanguageId);
|
|
29
|
-
const
|
|
29
|
+
const rawDictionaryRefs = [
|
|
30
30
|
...(settings.dictionaries || []),
|
|
31
31
|
...(settings.dictionaryDefinitions || []).map((d) => d.name),
|
|
32
|
-
]
|
|
32
|
+
];
|
|
33
|
+
const dictionaryReferenceCollection = createDictionaryReferenceCollection(rawDictionaryRefs);
|
|
34
|
+
const dictionaries = [...dictionaryReferenceCollection.enabled(), ...dictionaryReferenceCollection.blocked()];
|
|
33
35
|
const dictSettings = toInternalSettings({ ...settings, dictionaries });
|
|
34
36
|
const dictBase = await getDictionaryInternal(settings);
|
|
35
37
|
const dicts = await getDictionaryInternal(dictSettings);
|
|
36
38
|
const activeDictionaries = dictBase.dictionaries.map((d) => d.name);
|
|
37
39
|
return {
|
|
38
40
|
activeDictionaries,
|
|
41
|
+
dictionaryReferenceCollection,
|
|
39
42
|
config: settings,
|
|
40
43
|
dicts,
|
|
41
44
|
};
|
|
42
45
|
}
|
|
43
46
|
await refreshDictionaryCache();
|
|
44
|
-
const { config, dicts,
|
|
47
|
+
const { activeDictionaries, config, dicts, dictionaryReferenceCollection } = await finalize(settings);
|
|
45
48
|
const setOfActiveDicts = new Set(activeDictionaries);
|
|
49
|
+
const setOfExcludedDicts = new Set(dictionaryReferenceCollection.blocked());
|
|
46
50
|
function processWord(word) {
|
|
47
51
|
const results = traceWord(word, dicts, { ...config, ignoreCase, compoundSeparator });
|
|
48
52
|
const r = results.map((r) => ({
|
|
49
53
|
...r,
|
|
50
54
|
dictActive: setOfActiveDicts.has(r.dictName),
|
|
55
|
+
dictBlocked: setOfExcludedDicts.has(r.dictName),
|
|
51
56
|
dictSource: toFilePathOrHref(r.dictSource),
|
|
52
57
|
configSource: r.configSource || config.name || '',
|
|
53
58
|
splits: results.splits,
|
package/dist/rpc.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from '@cspell/rpc';
|
|
2
2
|
//# sourceMappingURL=rpc.d.ts.map
|
package/dist/rpc.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from '@cspell/rpc';
|
|
2
2
|
//# sourceMappingURL=rpc.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"provenance": true
|
|
6
6
|
},
|
|
7
|
-
"version": "9.6.
|
|
7
|
+
"version": "9.6.4",
|
|
8
8
|
"description": "A library of useful functions used across various cspell tools.",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"import": "./dist/index.js"
|
|
16
16
|
},
|
|
17
17
|
"./rpc": {
|
|
18
|
-
"import": "./dist/rpc
|
|
18
|
+
"import": "./dist/rpc.js"
|
|
19
19
|
},
|
|
20
20
|
"./cspell-rpc": {
|
|
21
21
|
"import": "./dist/cspell-rpc/index.js"
|
|
@@ -76,23 +76,24 @@
|
|
|
76
76
|
},
|
|
77
77
|
"homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-lib#readme",
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@cspell/cspell-bundled-dicts": "9.6.
|
|
80
|
-
"@cspell/cspell-performance-monitor": "9.6.
|
|
81
|
-
"@cspell/cspell-pipe": "9.6.
|
|
82
|
-
"@cspell/cspell-resolver": "9.6.
|
|
83
|
-
"@cspell/cspell-types": "9.6.
|
|
84
|
-
"@cspell/dynamic-import": "9.6.
|
|
85
|
-
"@cspell/filetypes": "9.6.
|
|
86
|
-
"@cspell/
|
|
87
|
-
"@cspell/
|
|
79
|
+
"@cspell/cspell-bundled-dicts": "9.6.4",
|
|
80
|
+
"@cspell/cspell-performance-monitor": "9.6.4",
|
|
81
|
+
"@cspell/cspell-pipe": "9.6.4",
|
|
82
|
+
"@cspell/cspell-resolver": "9.6.4",
|
|
83
|
+
"@cspell/cspell-types": "9.6.4",
|
|
84
|
+
"@cspell/dynamic-import": "9.6.4",
|
|
85
|
+
"@cspell/filetypes": "9.6.4",
|
|
86
|
+
"@cspell/rpc": "9.6.4",
|
|
87
|
+
"@cspell/strong-weak-map": "9.6.4",
|
|
88
|
+
"@cspell/url": "9.6.4",
|
|
88
89
|
"clear-module": "^4.1.2",
|
|
89
|
-
"cspell-config-lib": "9.6.
|
|
90
|
-
"cspell-dictionary": "9.6.
|
|
91
|
-
"cspell-glob": "9.6.
|
|
92
|
-
"cspell-grammar": "9.6.
|
|
93
|
-
"cspell-io": "9.6.
|
|
94
|
-
"cspell-trie-lib": "9.6.
|
|
95
|
-
"env-paths": "^
|
|
90
|
+
"cspell-config-lib": "9.6.4",
|
|
91
|
+
"cspell-dictionary": "9.6.4",
|
|
92
|
+
"cspell-glob": "9.6.4",
|
|
93
|
+
"cspell-grammar": "9.6.4",
|
|
94
|
+
"cspell-io": "9.6.4",
|
|
95
|
+
"cspell-trie-lib": "9.6.4",
|
|
96
|
+
"env-paths": "^4.0.0",
|
|
96
97
|
"gensequence": "^8.0.8",
|
|
97
98
|
"import-fresh": "^3.3.1",
|
|
98
99
|
"resolve-from": "^5.0.0",
|
|
@@ -104,11 +105,11 @@
|
|
|
104
105
|
"node": ">=20"
|
|
105
106
|
},
|
|
106
107
|
"devDependencies": {
|
|
107
|
-
"@cspell/cspell-tools": "9.6.
|
|
108
|
+
"@cspell/cspell-tools": "9.6.4",
|
|
108
109
|
"@cspell/dict-cpp": "^7.0.2",
|
|
109
110
|
"@cspell/dict-csharp": "^4.0.8",
|
|
110
111
|
"@cspell/dict-css": "^4.0.19",
|
|
111
|
-
"@cspell/dict-en_us": "^4.4.
|
|
112
|
+
"@cspell/dict-en_us": "^4.4.28",
|
|
112
113
|
"@cspell/dict-fa-ir": "^4.0.5",
|
|
113
114
|
"@cspell/dict-fr-fr": "^2.3.2",
|
|
114
115
|
"@cspell/dict-html": "^4.0.14",
|
|
@@ -122,5 +123,5 @@
|
|
|
122
123
|
"lorem-ipsum": "^2.0.8",
|
|
123
124
|
"perf-insight": "^2.0.1"
|
|
124
125
|
},
|
|
125
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "e126c7f5708d4258ada35ba1d29d18952d7f0886"
|
|
126
127
|
}
|
package/dist/rpc/Future.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
package/dist/rpc/Future.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
|
@@ -1,94 +0,0 @@
|
|
|
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
|
package/dist/rpc/assert.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
|
package/dist/rpc/assert.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|