cspell-lib 9.6.2 → 9.6.3
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/sanitizeSettings.js +2 -0
- 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> {
|
|
@@ -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/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.3",
|
|
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.3",
|
|
80
|
+
"@cspell/cspell-performance-monitor": "9.6.3",
|
|
81
|
+
"@cspell/cspell-pipe": "9.6.3",
|
|
82
|
+
"@cspell/cspell-resolver": "9.6.3",
|
|
83
|
+
"@cspell/cspell-types": "9.6.3",
|
|
84
|
+
"@cspell/dynamic-import": "9.6.3",
|
|
85
|
+
"@cspell/filetypes": "9.6.3",
|
|
86
|
+
"@cspell/rpc": "9.6.3",
|
|
87
|
+
"@cspell/strong-weak-map": "9.6.3",
|
|
88
|
+
"@cspell/url": "9.6.3",
|
|
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.3",
|
|
91
|
+
"cspell-dictionary": "9.6.3",
|
|
92
|
+
"cspell-glob": "9.6.3",
|
|
93
|
+
"cspell-grammar": "9.6.3",
|
|
94
|
+
"cspell-io": "9.6.3",
|
|
95
|
+
"cspell-trie-lib": "9.6.3",
|
|
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.3",
|
|
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": "500b996b6c0a6ff025c42ef98db44776f43a9e72"
|
|
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
|
package/dist/rpc/client.d.ts
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import type { MessagePortLike } from './messagePort.js';
|
|
2
|
-
import type { RCPBaseRequest, RequestID, RPCPendingClientRequest, RPCResponse } from './models.js';
|
|
3
|
-
import type { RPCProtocol, RPCProtocolMethodNames } from './protocol.js';
|
|
4
|
-
interface PendingRequest {
|
|
5
|
-
readonly id: RequestID;
|
|
6
|
-
readonly request: RCPBaseRequest;
|
|
7
|
-
readonly response: Promise<RPCResponse>;
|
|
8
|
-
readonly isResolved: boolean;
|
|
9
|
-
readonly isCanceled: boolean;
|
|
10
|
-
/** calling abort will cancel the request if it has not already been resolved. */
|
|
11
|
-
abort: AbortController['abort'];
|
|
12
|
-
handleResponse: (res: RPCResponse) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Cancels the request by telling the server to cancel the request and waiting on the response.
|
|
15
|
-
*/
|
|
16
|
-
cancel: () => Promise<boolean>;
|
|
17
|
-
}
|
|
18
|
-
export interface RPCClientOptions {
|
|
19
|
-
/**
|
|
20
|
-
* A function to generate random UUIDs.
|
|
21
|
-
* @default undefined
|
|
22
|
-
*/
|
|
23
|
-
randomUUID?: () => string;
|
|
24
|
-
/**
|
|
25
|
-
* If true, the client will close the port when disposed.
|
|
26
|
-
* @default false
|
|
27
|
-
*/
|
|
28
|
-
closePortOnDispose?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Set the default timeout in milliseconds for requests.
|
|
31
|
-
*/
|
|
32
|
-
timeoutMs?: number;
|
|
33
|
-
}
|
|
34
|
-
export interface RPCClientConfiguration extends RPCClientOptions {
|
|
35
|
-
/**
|
|
36
|
-
* The message port to use for communication.
|
|
37
|
-
*/
|
|
38
|
-
port: MessagePortLike;
|
|
39
|
-
}
|
|
40
|
-
export interface RequestOptions {
|
|
41
|
-
/**
|
|
42
|
-
* An AbortSignal to abort the request.
|
|
43
|
-
*/
|
|
44
|
-
signal?: AbortSignal | undefined;
|
|
45
|
-
/**
|
|
46
|
-
* Timeout in milliseconds to wait before aborting the request.
|
|
47
|
-
*/
|
|
48
|
-
timeoutMs?: number | undefined;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* The RPC Client.
|
|
52
|
-
*/
|
|
53
|
-
declare class RPCClientImpl<T, P extends RPCProtocol<T> = RPCProtocol<T>, MethodNames extends RPCProtocolMethodNames<P> = RPCProtocolMethodNames<P>> {
|
|
54
|
-
#private;
|
|
55
|
-
/**
|
|
56
|
-
* Create an RPC Client.
|
|
57
|
-
* @param config - The client configuration.
|
|
58
|
-
*/
|
|
59
|
-
constructor(config: RPCClientConfiguration);
|
|
60
|
-
/**
|
|
61
|
-
* Make a request to the RPC server.
|
|
62
|
-
*
|
|
63
|
-
* It is unlikely you need to use this method directly. Consider using `call` or `getApi` instead.
|
|
64
|
-
*
|
|
65
|
-
* @param method - The method name.
|
|
66
|
-
* @param params - The method parameters.
|
|
67
|
-
* @param options - Request options including abort signal and timeout.
|
|
68
|
-
* @returns The pending client request.
|
|
69
|
-
*/
|
|
70
|
-
request<M extends MethodNames>(method: M, params: Parameters<P[M]>, options?: RequestOptions): RPCPendingClientRequest<M, ReturnType<P[M]>>;
|
|
71
|
-
/**
|
|
72
|
-
* Check the health of the RPC server.
|
|
73
|
-
* @param options - used to set timeout and abort signal.
|
|
74
|
-
* @returns resolves to true if the server is OK, false on timeout.
|
|
75
|
-
*/
|
|
76
|
-
isOK(options?: RequestOptions): Promise<boolean>;
|
|
77
|
-
/**
|
|
78
|
-
* The current known ready state of the RPC server.
|
|
79
|
-
* - `true` - The server is ready.
|
|
80
|
-
* - `false` - The server is not ready.
|
|
81
|
-
*/
|
|
82
|
-
get isReady(): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Check if the RPC server is ready. If already ready, returns true immediately.
|
|
85
|
-
* If not ready, sends a 'ready' request to the server.
|
|
86
|
-
* @param options - used to set timeout and abort signal.
|
|
87
|
-
* @returns resolves to true when the server is ready, rejects if the request times out or fails.
|
|
88
|
-
*/
|
|
89
|
-
ready(options?: RequestOptions): Promise<boolean>;
|
|
90
|
-
/**
|
|
91
|
-
* Call a method on the RPC server.
|
|
92
|
-
* @param method - The method name.
|
|
93
|
-
* @param params - The method parameters.
|
|
94
|
-
* @param options - Call options including abort signal.
|
|
95
|
-
* @returns A Promise with the method result.
|
|
96
|
-
*/
|
|
97
|
-
call<M extends MethodNames>(method: M, params: Parameters<P[M]>, options?: RequestOptions): ReturnType<P[M]>;
|
|
98
|
-
/**
|
|
99
|
-
* Get the API for the given method names.
|
|
100
|
-
*
|
|
101
|
-
* This is useful passing the API to other parts of the code that do not need to know about the RPCClient.
|
|
102
|
-
*
|
|
103
|
-
* @param methods - The method names to include in the API.
|
|
104
|
-
* @returns A partial API with the requested methods.
|
|
105
|
-
*/
|
|
106
|
-
getApi<M extends MethodNames>(methods: M[]): Pick<P, M>;
|
|
107
|
-
/**
|
|
108
|
-
* Get info about a pending request by its RequestID.
|
|
109
|
-
* @param id - The RequestID of the pending request.
|
|
110
|
-
* @returns The found pending request or undefined if not found.
|
|
111
|
-
*/
|
|
112
|
-
getPendingRequestById(id: RequestID): PendingRequest | undefined;
|
|
113
|
-
/**
|
|
114
|
-
* Get info about a pending request by the promise returned using `call` or an api method.
|
|
115
|
-
* @param id - The RequestID of the pending request.
|
|
116
|
-
* @returns The found pending request or undefined if not found.
|
|
117
|
-
*/
|
|
118
|
-
getPendingRequestByPromise(promise: Promise<unknown>): PendingRequest | undefined;
|
|
119
|
-
/**
|
|
120
|
-
* Get the number of pending requests.
|
|
121
|
-
*/
|
|
122
|
-
get length(): number;
|
|
123
|
-
/**
|
|
124
|
-
* Abort a pending request by its promise.
|
|
125
|
-
*
|
|
126
|
-
* Note: the request promise will be rejected with an AbortRequestError.
|
|
127
|
-
* @param promise - The promise returned by the request.
|
|
128
|
-
* @param reason - The reason for aborting the request.
|
|
129
|
-
* @returns True if the request was found and aborted, false otherwise.
|
|
130
|
-
*/
|
|
131
|
-
abortPromise(promise: Promise<unknown>, reason: unknown): boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Abort a pending request by its RequestId.
|
|
134
|
-
*
|
|
135
|
-
* Note: the request promise will be rejected with an AbortRequestError.
|
|
136
|
-
* @param requestId - The RequestID of the request to abort.
|
|
137
|
-
* @param reason - The reason for aborting the request.
|
|
138
|
-
* @returns True if the request was found and aborted, false otherwise.
|
|
139
|
-
*/
|
|
140
|
-
abortRequest(requestId: RequestID, reason?: unknown): boolean;
|
|
141
|
-
/**
|
|
142
|
-
* Abort all pending requests.
|
|
143
|
-
*
|
|
144
|
-
* Note: each request promise will be rejected with an AbortRequestError.
|
|
145
|
-
*
|
|
146
|
-
* @param reason - The reason for aborting the request.
|
|
147
|
-
*/
|
|
148
|
-
abortAllRequests(reason?: unknown): void;
|
|
149
|
-
/**
|
|
150
|
-
* Cancel a pending request by its RequestID.
|
|
151
|
-
*
|
|
152
|
-
* Tries to cancel the request by sending a cancel request to the server and waiting for the response.
|
|
153
|
-
* @param id - The RequestID of the request to cancel.
|
|
154
|
-
* @returns resolves to true if the request was found and canceled, false otherwise.
|
|
155
|
-
*/
|
|
156
|
-
cancelRequest(id: RequestID): Promise<boolean>;
|
|
157
|
-
/**
|
|
158
|
-
* Cancel a pending request by its Promise.
|
|
159
|
-
*
|
|
160
|
-
* Tries to cancel the request by sending a cancel request to the server and waiting for the response.
|
|
161
|
-
* @param id - The RequestID of the request to cancel.
|
|
162
|
-
* @returns resolves to true if the request was found and canceled, false otherwise.
|
|
163
|
-
*/
|
|
164
|
-
cancelPromise(promise: Promise<unknown>): Promise<boolean>;
|
|
165
|
-
/**
|
|
166
|
-
* Set the default timeout for requests. Requests can override this value.
|
|
167
|
-
* @param timeoutMs - the timeout in milliseconds
|
|
168
|
-
*/
|
|
169
|
-
setTimeout(timeoutMs: number | undefined): void;
|
|
170
|
-
/**
|
|
171
|
-
* Dispose of the RPC client, aborting all pending requests and closing the port if specified in options.
|
|
172
|
-
*/
|
|
173
|
-
[Symbol.dispose](): void;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* The RPC Client.
|
|
177
|
-
*/
|
|
178
|
-
export declare class RPCClient<T> extends RPCClientImpl<T> {
|
|
179
|
-
/**
|
|
180
|
-
* Create an RPC Client.
|
|
181
|
-
* @param config - The client configuration.
|
|
182
|
-
*/
|
|
183
|
-
constructor(config: RPCClientConfiguration);
|
|
184
|
-
}
|
|
185
|
-
export {};
|
|
186
|
-
//# sourceMappingURL=client.d.ts.map
|