@actuallab/rpc 12.1.100 → 12.1.115
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/index.cjs +16 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -302,6 +302,8 @@ declare class RpcSharedObjectTracker {
|
|
|
302
302
|
* so "json5np" (System.Text.Json, no polymorphism) is the correct match.
|
|
303
303
|
*/
|
|
304
304
|
declare const DEFAULT_SERIALIZATION_FORMAT = "json5np";
|
|
305
|
+
/** WebSocket close code sent by the server when the client's serialization format is unsupported. */
|
|
306
|
+
declare const RPC_CLOSE_CODE_UNSUPPORTED_FORMAT = 4001;
|
|
305
307
|
/** Builds the WebSocket connection URL for an RpcClientPeer. */
|
|
306
308
|
type RpcConnectionUrlResolver = (peer: RpcClientPeer) => string;
|
|
307
309
|
/** Default connection URL provider — appends `clientId` and `f` query parameters. */
|
|
@@ -384,6 +386,10 @@ declare class RpcClientPeer extends RpcPeer {
|
|
|
384
386
|
/** Builds the WebSocket URL for this peer. Replace to customize URL construction. */
|
|
385
387
|
connectionUrlResolver: RpcConnectionUrlResolver;
|
|
386
388
|
readonly peerChanged: EventHandlerSet<void>;
|
|
389
|
+
/** Fired when the server rejects the connection due to an unsupported serialization format (close code 4010). */
|
|
390
|
+
readonly unsupportedFormat: EventHandlerSet<{
|
|
391
|
+
reason: string;
|
|
392
|
+
}>;
|
|
387
393
|
readonly reconnectDelayer: RpcClientPeerReconnectDelayer;
|
|
388
394
|
readonly reconnectsAtChanged: EventHandlerSet<void>;
|
|
389
395
|
get reconnectsAt(): number;
|
|
@@ -590,4 +596,4 @@ declare class RpcPeerStateMonitor {
|
|
|
590
596
|
private _scheduleRecompute;
|
|
591
597
|
}
|
|
592
598
|
|
|
593
|
-
export { ARG_DELIMITER, DEFAULT_SERIALIZATION_FORMAT, ENVELOPE_DELIMITER, FRAME_DELIMITER, type IRpcObject, type MethodMeta, type RemoteHandshake, type RpcCallOptions, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, type RpcConnectionUrlResolver, type RpcDispatchContext, RpcHub, RpcInboundCall, RpcInboundCallTracker, type RpcMessage, RpcMessageChannelConnection, type RpcMethodDef, type RpcMethodDefInput, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, RpcPeerConnectionKind, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, RpcRemoteObjectTracker, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamRef, RpcStreamSender, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, createMessageChannelPair, createRpcClient, defaultConnectionUrlResolver, defineRpcService, deserializeMessage, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, likelyConnected, parseStreamRef, resolveStreamRefs, rpcMethod, rpcService, serializeFrame, serializeMessage, splitFrame, wireMethodName };
|
|
599
|
+
export { ARG_DELIMITER, DEFAULT_SERIALIZATION_FORMAT, ENVELOPE_DELIMITER, FRAME_DELIMITER, type IRpcObject, type MethodMeta, RPC_CLOSE_CODE_UNSUPPORTED_FORMAT, type RemoteHandshake, type RpcCallOptions, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, type RpcConnectionUrlResolver, type RpcDispatchContext, RpcHub, RpcInboundCall, RpcInboundCallTracker, type RpcMessage, RpcMessageChannelConnection, type RpcMethodDef, type RpcMethodDefInput, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, RpcPeerConnectionKind, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, RpcRemoteObjectTracker, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamRef, RpcStreamSender, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, createMessageChannelPair, createRpcClient, defaultConnectionUrlResolver, defineRpcService, deserializeMessage, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, likelyConnected, parseStreamRef, resolveStreamRefs, rpcMethod, rpcService, serializeFrame, serializeMessage, splitFrame, wireMethodName };
|
package/dist/index.d.ts
CHANGED
|
@@ -302,6 +302,8 @@ declare class RpcSharedObjectTracker {
|
|
|
302
302
|
* so "json5np" (System.Text.Json, no polymorphism) is the correct match.
|
|
303
303
|
*/
|
|
304
304
|
declare const DEFAULT_SERIALIZATION_FORMAT = "json5np";
|
|
305
|
+
/** WebSocket close code sent by the server when the client's serialization format is unsupported. */
|
|
306
|
+
declare const RPC_CLOSE_CODE_UNSUPPORTED_FORMAT = 4001;
|
|
305
307
|
/** Builds the WebSocket connection URL for an RpcClientPeer. */
|
|
306
308
|
type RpcConnectionUrlResolver = (peer: RpcClientPeer) => string;
|
|
307
309
|
/** Default connection URL provider — appends `clientId` and `f` query parameters. */
|
|
@@ -384,6 +386,10 @@ declare class RpcClientPeer extends RpcPeer {
|
|
|
384
386
|
/** Builds the WebSocket URL for this peer. Replace to customize URL construction. */
|
|
385
387
|
connectionUrlResolver: RpcConnectionUrlResolver;
|
|
386
388
|
readonly peerChanged: EventHandlerSet<void>;
|
|
389
|
+
/** Fired when the server rejects the connection due to an unsupported serialization format (close code 4010). */
|
|
390
|
+
readonly unsupportedFormat: EventHandlerSet<{
|
|
391
|
+
reason: string;
|
|
392
|
+
}>;
|
|
387
393
|
readonly reconnectDelayer: RpcClientPeerReconnectDelayer;
|
|
388
394
|
readonly reconnectsAtChanged: EventHandlerSet<void>;
|
|
389
395
|
get reconnectsAt(): number;
|
|
@@ -590,4 +596,4 @@ declare class RpcPeerStateMonitor {
|
|
|
590
596
|
private _scheduleRecompute;
|
|
591
597
|
}
|
|
592
598
|
|
|
593
|
-
export { ARG_DELIMITER, DEFAULT_SERIALIZATION_FORMAT, ENVELOPE_DELIMITER, FRAME_DELIMITER, type IRpcObject, type MethodMeta, type RemoteHandshake, type RpcCallOptions, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, type RpcConnectionUrlResolver, type RpcDispatchContext, RpcHub, RpcInboundCall, RpcInboundCallTracker, type RpcMessage, RpcMessageChannelConnection, type RpcMethodDef, type RpcMethodDefInput, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, RpcPeerConnectionKind, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, RpcRemoteObjectTracker, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamRef, RpcStreamSender, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, createMessageChannelPair, createRpcClient, defaultConnectionUrlResolver, defineRpcService, deserializeMessage, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, likelyConnected, parseStreamRef, resolveStreamRefs, rpcMethod, rpcService, serializeFrame, serializeMessage, splitFrame, wireMethodName };
|
|
599
|
+
export { ARG_DELIMITER, DEFAULT_SERIALIZATION_FORMAT, ENVELOPE_DELIMITER, FRAME_DELIMITER, type IRpcObject, type MethodMeta, RPC_CLOSE_CODE_UNSUPPORTED_FORMAT, type RemoteHandshake, type RpcCallOptions, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, type RpcConnectionUrlResolver, type RpcDispatchContext, RpcHub, RpcInboundCall, RpcInboundCallTracker, type RpcMessage, RpcMessageChannelConnection, type RpcMethodDef, type RpcMethodDefInput, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, RpcPeerConnectionKind, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, RpcRemoteObjectTracker, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamRef, RpcStreamSender, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, createMessageChannelPair, createRpcClient, defaultConnectionUrlResolver, defineRpcService, deserializeMessage, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, likelyConnected, parseStreamRef, resolveStreamRefs, rpcMethod, rpcService, serializeFrame, serializeMessage, splitFrame, wireMethodName };
|
package/dist/index.js
CHANGED
|
@@ -793,6 +793,7 @@ var RpcClientPeerReconnectDelayer = class extends RetryDelayer {
|
|
|
793
793
|
|
|
794
794
|
// src/rpc-peer.ts
|
|
795
795
|
var DEFAULT_SERIALIZATION_FORMAT = "json5np";
|
|
796
|
+
var RPC_CLOSE_CODE_UNSUPPORTED_FORMAT = 4001;
|
|
796
797
|
var defaultConnectionUrlResolver = (peer) => {
|
|
797
798
|
const sep = peer.ref.includes("?") ? "&" : "?";
|
|
798
799
|
return peer.ref + sep + `clientId=${peer.clientId}&f=${peer.serializationFormat}`;
|
|
@@ -998,6 +999,8 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
998
999
|
/** Builds the WebSocket URL for this peer. Replace to customize URL construction. */
|
|
999
1000
|
connectionUrlResolver = defaultConnectionUrlResolver;
|
|
1000
1001
|
peerChanged = new EventHandlerSet3();
|
|
1002
|
+
/** Fired when the server rejects the connection due to an unsupported serialization format (close code 4010). */
|
|
1003
|
+
unsupportedFormat = new EventHandlerSet3();
|
|
1001
1004
|
reconnectDelayer = new RpcClientPeerReconnectDelayer();
|
|
1002
1005
|
reconnectsAtChanged = new EventHandlerSet3();
|
|
1003
1006
|
get reconnectsAt() {
|
|
@@ -1025,10 +1028,16 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
1025
1028
|
async run(wsFactory) {
|
|
1026
1029
|
const connUrl = this.connectionUrlResolver(this);
|
|
1027
1030
|
while (!this._disposed) {
|
|
1031
|
+
let lastCloseCode = 0;
|
|
1032
|
+
let lastCloseReason = "";
|
|
1028
1033
|
try {
|
|
1029
1034
|
const ws = wsFactory?.(connUrl) ?? new WebSocket(connUrl);
|
|
1030
1035
|
const conn = new RpcWebSocketConnection(ws);
|
|
1031
1036
|
this._connectionKind = 1 /* Connecting */;
|
|
1037
|
+
conn.closed.add((ev) => {
|
|
1038
|
+
lastCloseCode = ev.code;
|
|
1039
|
+
lastCloseReason = ev.reason;
|
|
1040
|
+
});
|
|
1032
1041
|
this._pendingHandshake = new PromiseSource5();
|
|
1033
1042
|
this.setupConnection(conn);
|
|
1034
1043
|
this._connection = void 0;
|
|
@@ -1061,6 +1070,11 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
1061
1070
|
}
|
|
1062
1071
|
this._connectionKind = 0 /* Disconnected */;
|
|
1063
1072
|
if (this._disposed) break;
|
|
1073
|
+
if (lastCloseCode === RPC_CLOSE_CODE_UNSUPPORTED_FORMAT) {
|
|
1074
|
+
this.unsupportedFormat.trigger({ reason: lastCloseReason });
|
|
1075
|
+
this._disposed = true;
|
|
1076
|
+
break;
|
|
1077
|
+
}
|
|
1064
1078
|
this._tryIndex++;
|
|
1065
1079
|
const delay = this.reconnectDelayer.getDelay(this._tryIndex);
|
|
1066
1080
|
if (delay.isLimitExceeded) {
|
|
@@ -1531,6 +1545,7 @@ export {
|
|
|
1531
1545
|
DEFAULT_SERIALIZATION_FORMAT,
|
|
1532
1546
|
ENVELOPE_DELIMITER,
|
|
1533
1547
|
FRAME_DELIMITER,
|
|
1548
|
+
RPC_CLOSE_CODE_UNSUPPORTED_FORMAT,
|
|
1534
1549
|
RpcCallTypeId,
|
|
1535
1550
|
RpcClientPeer,
|
|
1536
1551
|
RpcClientPeerReconnectDelayer,
|