@nmtjs/client 0.15.0-beta.43 → 0.15.0-beta.44
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/clients/static.js +4 -1
- package/dist/clients/static.js.map +1 -1
- package/dist/core.d.ts +35 -8
- package/dist/core.js +314 -59
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/plugins/browser.d.ts +2 -0
- package/dist/plugins/browser.js +41 -0
- package/dist/plugins/browser.js.map +1 -0
- package/dist/plugins/heartbeat.d.ts +6 -0
- package/dist/plugins/heartbeat.js +86 -0
- package/dist/plugins/heartbeat.js.map +1 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/logging.d.ts +9 -0
- package/dist/plugins/logging.js +30 -0
- package/dist/plugins/logging.js.map +1 -0
- package/dist/plugins/reconnect.d.ts +6 -0
- package/dist/plugins/reconnect.js +98 -0
- package/dist/plugins/reconnect.js.map +1 -0
- package/dist/plugins/types.d.ts +53 -0
- package/dist/plugins/types.js +2 -0
- package/dist/plugins/types.js.map +1 -0
- package/package.json +25 -13
- package/src/clients/static.ts +5 -1
- package/src/core.ts +371 -69
- package/src/index.ts +1 -0
- package/src/plugins/browser.ts +61 -0
- package/src/plugins/heartbeat.ts +111 -0
- package/src/plugins/index.ts +5 -0
- package/src/plugins/logging.ts +42 -0
- package/src/plugins/reconnect.ts +130 -0
- package/src/plugins/types.ts +61 -0
package/dist/clients/static.js
CHANGED
|
@@ -18,7 +18,10 @@ export class StaticClient extends BaseClient {
|
|
|
18
18
|
if (prop === 'then')
|
|
19
19
|
return obj;
|
|
20
20
|
const newPath = [...path, String(prop)];
|
|
21
|
-
const caller = (payload, options) => this._call(newPath.join('/'), payload,
|
|
21
|
+
const caller = (payload, options) => this._call(newPath.join('/'), payload, {
|
|
22
|
+
...options,
|
|
23
|
+
_stream_response: isStream || options?._stream_response,
|
|
24
|
+
});
|
|
22
25
|
return this.createProxy(caller, isStream, newPath);
|
|
23
26
|
},
|
|
24
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static.js","sourceRoot":"","sources":["../../src/clients/static.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,MAAM,OAAO,YAOX,SAAQ,UAMT;IACoB,WAAW,CAAuB;IAErD,YACE,OAAoD,EACpD,SAAoB,EACpB,gBAKS,EACT;QACA,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAA;QAC3C,IAAI,CAAC,WAAW,GAAG,IAAI,qBAAqB,EAAE,CAAA;IAAA,CAC/C;IAED,IAAa,IAAI,GAAwD;QACvE,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAA;IAAA,CACpD;IAED,IAAa,MAAM,GAAuD;QACxE,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;IAAA,CACnD;IAES,WAAW,CACnB,MAA+B,EAC/B,QAAiB,EACjB,IAAI,GAAa,EAAE,EACnB;QACA,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;YACvB,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;gBAClB,IAAI,IAAI,KAAK,MAAM;oBAAE,OAAO,GAAG,CAAA;gBAC/B,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;gBACvC,MAAM,MAAM,GAAG,CACb,OAAiB,EACjB,OAAoC,EACpC,EAAE,
|
|
1
|
+
{"version":3,"file":"static.js","sourceRoot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AAa,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;YAAA,CAC1D;SACF,CAAM,CAAA;IAAA,CACR;CACF"}
|
package/dist/core.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import type { Future, TypeProvider } from '@nmtjs/common';
|
|
|
2
2
|
import type { TAnyRouterContract } from '@nmtjs/contract';
|
|
3
3
|
import type { ProtocolBlobMetadata, ProtocolVersion } from '@nmtjs/protocol';
|
|
4
4
|
import type { BaseClientFormat, MessageContext, ProtocolVersionInterface } from '@nmtjs/protocol/client';
|
|
5
|
-
import { ProtocolBlob } from '@nmtjs/protocol';
|
|
5
|
+
import { ConnectionType, ProtocolBlob } from '@nmtjs/protocol';
|
|
6
6
|
import { ProtocolError } from '@nmtjs/protocol/client';
|
|
7
|
+
import type { ClientDisconnectReason, ClientPlugin, ClientPluginEvent, ClientPluginInstance } from './plugins/types.ts';
|
|
7
8
|
import type { BaseClientTransformer } from './transformers.ts';
|
|
8
9
|
import type { ClientTransportFactory } from './transport.ts';
|
|
9
10
|
import type { ClientCallers, ClientCallOptions, ResolveAPIRouterRoutes } from './types.ts';
|
|
@@ -23,7 +24,7 @@ export interface BaseClientOptions<RouterContract extends TAnyRouterContract = T
|
|
|
23
24
|
format: BaseClientFormat;
|
|
24
25
|
application?: string;
|
|
25
26
|
timeout?: number;
|
|
26
|
-
|
|
27
|
+
plugins?: ClientPlugin[];
|
|
27
28
|
safe?: SafeCall;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
@@ -32,9 +33,9 @@ export interface BaseClientOptions<RouterContract extends TAnyRouterContract = T
|
|
|
32
33
|
*/
|
|
33
34
|
export declare abstract class BaseClient<TransportFactory extends ClientTransportFactory<any, any> = ClientTransportFactory<any, any>, RouterContract extends TAnyRouterContract = TAnyRouterContract, SafeCall extends boolean = false, InputTypeProvider extends TypeProvider = TypeProvider, OutputTypeProvider extends TypeProvider = TypeProvider> extends EventEmitter<{
|
|
34
35
|
connected: [];
|
|
35
|
-
disconnected: [reason:
|
|
36
|
+
disconnected: [reason: ClientDisconnectReason];
|
|
37
|
+
pong: [nonce: number];
|
|
36
38
|
}> {
|
|
37
|
-
#private;
|
|
38
39
|
readonly options: BaseClientOptions<RouterContract, SafeCall>;
|
|
39
40
|
readonly transportFactory: TransportFactory;
|
|
40
41
|
readonly transportOptions: TransportFactory extends ClientTransportFactory<any, infer U> ? U : never;
|
|
@@ -55,17 +56,43 @@ export declare abstract class BaseClient<TransportFactory extends ClientTranspor
|
|
|
55
56
|
protected callId: number;
|
|
56
57
|
protected streamId: number;
|
|
57
58
|
protected cab: AbortController | null;
|
|
58
|
-
protected reconnectTimeout: number;
|
|
59
59
|
protected connecting: Promise<void> | null;
|
|
60
|
-
protected
|
|
60
|
+
protected _state: 'connected' | 'disconnected';
|
|
61
|
+
protected _lastDisconnectReason: ClientDisconnectReason;
|
|
62
|
+
protected _disposed: boolean;
|
|
63
|
+
protected pingNonce: number;
|
|
64
|
+
protected pendingPings: Map<number, Future<void>>;
|
|
65
|
+
protected plugins: ClientPluginInstance[];
|
|
66
|
+
private clientDisconnectAsReconnect;
|
|
67
|
+
private clientDisconnectOverrideReason;
|
|
68
|
+
private authValue;
|
|
61
69
|
constructor(options: BaseClientOptions<RouterContract, SafeCall>, transportFactory: TransportFactory, transportOptions: TransportFactory extends ClientTransportFactory<any, infer U> ? U : never);
|
|
70
|
+
dispose(): void;
|
|
71
|
+
get state(): "connected" | "disconnected";
|
|
72
|
+
get lastDisconnectReason(): ClientDisconnectReason;
|
|
73
|
+
get transportType(): ConnectionType;
|
|
74
|
+
isDisposed(): boolean;
|
|
75
|
+
requestReconnect(reason?: string): Promise<void>;
|
|
62
76
|
get auth(): any;
|
|
63
77
|
set auth(value: any);
|
|
64
78
|
connect(): Promise<void>;
|
|
65
|
-
disconnect(
|
|
79
|
+
disconnect(options?: {
|
|
80
|
+
reconnect?: boolean;
|
|
81
|
+
reason?: string;
|
|
82
|
+
}): Promise<void>;
|
|
66
83
|
blob(source: Blob | ReadableStream | string | AsyncIterable<Uint8Array>, metadata?: ProtocolBlobMetadata): ProtocolBlob;
|
|
67
84
|
protected _call(procedure: string, payload: any, options?: ClientCallOptions): Promise<any>;
|
|
68
85
|
protected onConnect(): Promise<void>;
|
|
69
|
-
protected onDisconnect(reason:
|
|
86
|
+
protected onDisconnect(reason: ClientDisconnectReason): Promise<void>;
|
|
87
|
+
protected nextPingNonce(): number;
|
|
88
|
+
ping(timeout: number, signal?: AbortSignal): Promise<any>;
|
|
89
|
+
protected stopAllPendingPings(reason?: any): void;
|
|
70
90
|
protected onMessage(buffer: ArrayBufferView): Promise<void>;
|
|
91
|
+
private handleRPCResponseMessage;
|
|
92
|
+
private handleRPCStreamResponseMessage;
|
|
93
|
+
private handleCallResponse;
|
|
94
|
+
protected send(buffer: ArrayBufferView, signal?: AbortSignal): Promise<void>;
|
|
95
|
+
protected getStreamId(): number;
|
|
96
|
+
protected getCallId(): number;
|
|
97
|
+
protected emitClientEvent(event: ClientPluginEvent): void;
|
|
71
98
|
}
|