@zlink-systems/stream-connector 0.26.0 → 0.28.0
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/browser/Contracts/ZlinkStreamConnectorOptions.d.ts +1 -0
- package/dist/browser/Contracts/ZlinkStreamEnums.d.ts +3 -17
- package/dist/browser/Contracts/index.d.ts +1 -1
- package/dist/browser/Runtime/Protocol/ZlinkSessionClosing.d.ts +2 -7
- package/dist/browser/Runtime/Protocol/ZlinkStreamFrameProtocol.d.ts +3 -4
- package/dist/browser/Runtime/Protocol/ZlinkStreamMetadataCodec.d.ts +1 -3
- package/dist/browser/Runtime/Transport/BrowserWebSocketConnection.d.ts +1 -2
- package/dist/browser/Runtime/ZlinkStreamActors.d.ts +2 -3
- package/dist/browser/Runtime/ZlinkStreamConnector.d.ts +3 -3
- package/dist/browser/Runtime/ZlinkStreamConnectorLifecycle.d.ts +4 -6
- package/dist/browser/Runtime/ZlinkStreamConnectorOptions.d.ts +1 -0
- package/dist/browser/Runtime/ZlinkStreamReceivedMessages.d.ts +2 -1
- package/dist/browser/Runtime/ZlinkStreamSupport.d.ts +8 -7
- package/dist/browser/index.global.js +583 -507
- package/dist/browser/index.mjs +582 -503
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ZlinkStreamCompression, ZlinkStreamDispatchMode, ZlinkStreamTransport } from './ZlinkStreamEnums';
|
|
2
2
|
import type { ZlinkStreamEncodedPayload } from './ZlinkStreamModels';
|
|
3
|
+
export declare const ZLINK_STREAM_DEFAULT_PAYLOAD_BYTES: number;
|
|
3
4
|
export interface ZlinkStreamConnectorOptions {
|
|
4
5
|
readonly endpoint: string;
|
|
5
6
|
readonly codec?: ZlinkStreamPayloadCodec;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { ZlinkStreamMessageKind, ZlinkStreamHeaderFlags } from '@zlink-systems/stream-wire';
|
|
1
2
|
export declare enum ZlinkStreamTransport {
|
|
2
3
|
WebSocket = "webSocket",
|
|
3
4
|
WebSocketSecure = "webSocketSecure"
|
|
@@ -11,23 +12,7 @@ export declare enum ZlinkStreamDispatchMode {
|
|
|
11
12
|
Manual = "manual",
|
|
12
13
|
Immediate = "immediate"
|
|
13
14
|
}
|
|
14
|
-
export
|
|
15
|
-
Send = 1,
|
|
16
|
-
Request = 2,
|
|
17
|
-
Response = 3,
|
|
18
|
-
Error = 4,
|
|
19
|
-
Control = 5
|
|
20
|
-
}
|
|
21
|
-
export declare enum ZlinkStreamHeaderFlags {
|
|
22
|
-
None = 0,
|
|
23
|
-
HasRequestSeq = 1,
|
|
24
|
-
HasMetadata = 2,
|
|
25
|
-
PayloadCompressed = 4,
|
|
26
|
-
HasCorrelationId = 8,
|
|
27
|
-
HasFlowId = 16,
|
|
28
|
-
HasActorSlot = 32
|
|
29
|
-
}
|
|
30
|
-
export type ZlinkStreamCloseReason = 'ClientClose' | 'IdleTimeout' | 'HeartbeatTimeout' | 'ServerDrain' | 'ProtocolError' | 'TransportError';
|
|
15
|
+
export type { ZlinkStreamCloseReason } from '@zlink-systems/stream-wire';
|
|
31
16
|
export declare enum ZlinkStreamErrorCode {
|
|
32
17
|
Disconnected = "disconnected",
|
|
33
18
|
ConfigurationError = "configurationError",
|
|
@@ -39,6 +24,7 @@ export declare enum ZlinkStreamErrorCode {
|
|
|
39
24
|
SendFailed = "sendFailed",
|
|
40
25
|
CompressionFailed = "compressionFailed",
|
|
41
26
|
DecompressionFailed = "decompressionFailed",
|
|
27
|
+
TlsValidationFailed = "tlsValidationFailed",
|
|
42
28
|
UserCallbackFailed = "userCallbackFailed",
|
|
43
29
|
RemoteError = "remoteError"
|
|
44
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ZlinkStreamTransport, ZlinkStreamCodec, ZlinkStreamCompression, ZlinkStreamDispatchMode, ZlinkStreamMessageKind, ZlinkStreamHeaderFlags, ZlinkStreamErrorCode, ZlinkStreamConnectionState } from './ZlinkStreamEnums';
|
|
2
2
|
export type { ZlinkStreamCloseReason } from './ZlinkStreamEnums';
|
|
3
|
-
export
|
|
3
|
+
export type { ZlinkStreamConnectorOptions, ZlinkStreamHeartbeatOptions, ZlinkStreamReconnectOptions, ZlinkStreamPacketNameResolver, ZlinkStreamPayloadCodec, ZlinkStreamCompressionCodec, ZlinkStreamTransportFactory, ZlinkStreamConnection, RequiredZlinkStreamConnectorOptions } from './ZlinkStreamConnectorOptions';
|
|
4
4
|
export * from './ZlinkStreamInterfaces';
|
|
5
5
|
export * from './ZlinkStreamMetadata';
|
|
6
6
|
export type { ZlinkStreamEncodedPayload, ZlinkStreamMessage, ZlinkStreamRequestSendingContext, ZlinkStreamReplyReceivedContext, ZlinkStreamError, ZlinkStreamConnectionStateChanged, ZlinkStreamResult, ZlinkStreamResultOf } from './ZlinkStreamModels';
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const ZLINK_SESSION_CLOSING
|
|
3
|
-
export declare function decodeSessionClosing(payload: Uint8Array): {
|
|
4
|
-
readonly closeReason: ZlinkStreamCloseReason;
|
|
5
|
-
readonly diagnostic?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function encodeSessionClosing(reason: ZlinkStreamCloseReason, diagnostic?: string): Uint8Array;
|
|
1
|
+
export { decodeStreamWireSessionClosing as decodeSessionClosing } from '@zlink-systems/stream-wire';
|
|
2
|
+
export declare const ZLINK_SESSION_CLOSING: "session-closing";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { ZlinkStreamMessageKind } from '../../Contracts';
|
|
1
|
+
import { type RequiredZlinkStreamConnectorOptions, type ZlinkStreamEncodedPayload, type ZlinkStreamMetadata, ZlinkStreamMessageKind } from '../../Contracts';
|
|
3
2
|
import type { ZlinkStreamHeader } from '../../Contracts/ZlinkStreamModels';
|
|
4
|
-
export declare const ZLINK_STREAM_HEARTBEAT_PING
|
|
5
|
-
export declare const ZLINK_STREAM_HEARTBEAT_PONG
|
|
3
|
+
export declare const ZLINK_STREAM_HEARTBEAT_PING: "$zlink.heartbeat.ping";
|
|
4
|
+
export declare const ZLINK_STREAM_HEARTBEAT_PONG: "$zlink.heartbeat.pong";
|
|
6
5
|
export declare class ZlinkStreamFrameProtocol {
|
|
7
6
|
private readonly options;
|
|
8
7
|
constructor(options: RequiredZlinkStreamConnectorOptions);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ZlinkStreamMetadata } from '../../Contracts';
|
|
2
|
-
export
|
|
2
|
+
export { ZLINK_STREAM_MAX_METADATA_BYTES } from '@zlink-systems/stream-wire';
|
|
3
3
|
export declare class ZlinkStreamMetadataCodec {
|
|
4
4
|
static size(metadata: ZlinkStreamMetadata): number;
|
|
5
|
-
static write(metadata: ZlinkStreamMetadata, destination: Uint8Array): void;
|
|
6
|
-
static decode(metadata: Uint8Array): ZlinkStreamMetadata;
|
|
7
5
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ZlinkStreamConnection, ZlinkStreamTransportFactory } from '../../Contracts';
|
|
2
|
-
import type { RequiredZlinkStreamConnectorOptions } from '../../Contracts';
|
|
1
|
+
import { type RequiredZlinkStreamConnectorOptions, ZlinkStreamConnection, ZlinkStreamTransportFactory } from '../../Contracts';
|
|
3
2
|
interface BrowserWebSocketEventMap {
|
|
4
3
|
open: unknown;
|
|
5
4
|
close: unknown;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { ZlinkStreamReceivedMessages } from './ZlinkStreamReceivedMessages';
|
|
1
|
+
import { type Disposable, type ZlinkStreamActor, type ZlinkStreamEncodedPayload, type ZlinkStreamMessage, type ZlinkStreamRequestCall, type ZlinkStreamSendCall } from '../Contracts';
|
|
3
2
|
import type { ZlinkStreamConnectorEvents } from './ZlinkStreamConnectorEvents';
|
|
3
|
+
import type { ZlinkStreamReceivedMessages } from './ZlinkStreamReceivedMessages';
|
|
4
4
|
export declare const zlinkStreamActorBinding: unique symbol;
|
|
5
5
|
interface ActorConnector {
|
|
6
6
|
sendForActor(actor: DefaultZlinkStreamActor, payload: unknown, messageType?: Function): ZlinkStreamSendCall;
|
|
@@ -26,7 +26,6 @@ export declare class ZlinkStreamActors {
|
|
|
26
26
|
private readonly events;
|
|
27
27
|
private readonly bySlot;
|
|
28
28
|
private readonly byId;
|
|
29
|
-
private readonly issued;
|
|
30
29
|
private readonly boundHandlers;
|
|
31
30
|
private readonly unboundHandlers;
|
|
32
31
|
constructor(connector: ActorConnector, receivedMessages: ZlinkStreamReceivedMessages, events: ZlinkStreamConnectorEvents);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Disposable, RequiredZlinkStreamConnectorOptions, ZlinkStreamConnectionState, ZlinkStreamConnectionStateChanged, ZlinkStreamConnector, ZlinkStreamConnectorOptions, ZlinkStreamEncodedPayload, ZlinkStreamError, ZlinkStreamExpectNoneCall, ZlinkStreamMessage, ZlinkStreamRequestSendingContext, ZlinkStreamReplyReceivedContext, ZlinkStreamMessageKind, ZlinkStreamMetadata, ZlinkStreamRequestCall, ZlinkStreamActor, ZlinkStreamSendCall, ZlinkStreamSequenceCall, ZlinkStreamWaitCall } from '../Contracts';
|
|
2
2
|
import { DefaultZlinkStreamActor } from './ZlinkStreamActors';
|
|
3
3
|
export declare class DefaultZlinkStreamConnector implements ZlinkStreamConnector {
|
|
4
|
-
static readonly heartbeatPingName
|
|
5
|
-
static readonly heartbeatPongName
|
|
4
|
+
static readonly heartbeatPingName: "$zlink.heartbeat.ping";
|
|
5
|
+
static readonly heartbeatPongName: "$zlink.heartbeat.pong";
|
|
6
6
|
private readonly receivedMessages;
|
|
7
7
|
private readonly lifecycle;
|
|
8
8
|
private readonly events;
|
|
@@ -16,7 +16,7 @@ export declare class DefaultZlinkStreamConnector implements ZlinkStreamConnector
|
|
|
16
16
|
readonly options: RequiredZlinkStreamConnectorOptions;
|
|
17
17
|
constructor(options: ZlinkStreamConnectorOptions);
|
|
18
18
|
get isConnected(): boolean;
|
|
19
|
-
get closeReason():
|
|
19
|
+
get closeReason(): "ClientClose" | "IdleTimeout" | "HeartbeatTimeout" | "ServerDrain" | "ProtocolError" | "TransportError" | undefined;
|
|
20
20
|
get state(): ZlinkStreamConnectionState;
|
|
21
21
|
get pendingDispatchCount(): number;
|
|
22
22
|
get actors(): readonly ZlinkStreamActor[];
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import type { ZlinkStreamCloseReason } from '../Contracts';
|
|
1
|
+
import { type RequiredZlinkStreamConnectorOptions, type ZlinkStreamCloseReason, type ZlinkStreamConnection, ZlinkStreamConnectionState } from '../Contracts';
|
|
2
|
+
import type { ZlinkStreamActors } from './ZlinkStreamActors';
|
|
4
3
|
import type { ZlinkStreamConnectorEvents } from './ZlinkStreamConnectorEvents';
|
|
5
4
|
import type { ZlinkStreamFrameSender } from './ZlinkStreamFrameSender';
|
|
6
5
|
import type { ZlinkStreamPendingRequests } from './ZlinkStreamPendingRequests';
|
|
7
6
|
import { type ZlinkStreamReceiveDispatcher } from './ZlinkStreamReceiveDispatcher';
|
|
8
7
|
import type { ZlinkStreamReceivedMessages } from './ZlinkStreamReceivedMessages';
|
|
9
|
-
import type { ZlinkStreamActors } from './ZlinkStreamActors';
|
|
10
8
|
export declare class ZlinkStreamConnectorLifecycle {
|
|
11
9
|
private readonly options;
|
|
12
10
|
private readonly pendingRequests;
|
|
@@ -32,7 +30,6 @@ export declare class ZlinkStreamConnectorLifecycle {
|
|
|
32
30
|
private closeRequested;
|
|
33
31
|
private disconnectedPublished;
|
|
34
32
|
private closeReasonValue?;
|
|
35
|
-
private lateConnectCleanupError;
|
|
36
33
|
constructor(options: RequiredZlinkStreamConnectorOptions, pendingRequests: ZlinkStreamPendingRequests, frameSender: ZlinkStreamFrameSender, receiveDispatcher: ZlinkStreamReceiveDispatcher, receivedMessages: ZlinkStreamReceivedMessages, actors: ZlinkStreamActors, events: ZlinkStreamConnectorEvents);
|
|
37
34
|
get isConnected(): boolean;
|
|
38
35
|
get state(): ZlinkStreamConnectionState;
|
|
@@ -87,13 +84,14 @@ export declare class ZlinkStreamConnectorLifecycle {
|
|
|
87
84
|
private isCurrentConnection;
|
|
88
85
|
/**
|
|
89
86
|
* Ends the current connection, for close and for transport loss alike. No
|
|
90
|
-
* application callback runs
|
|
87
|
+
* application callback runs before terminal operations settle. Spec stream-connector 32 §7 and §9:
|
|
91
88
|
* every operation the ending connection fails (the frames it has not
|
|
92
89
|
* written, the one it is writing and the pending requests) fails with
|
|
93
90
|
* `Disconnected`, whatever ended it; the cause stays in the close reason.
|
|
94
91
|
* The transport is closed without waiting for the frames.
|
|
95
92
|
*/
|
|
96
93
|
private tearDownConnection;
|
|
94
|
+
private closeTransport;
|
|
97
95
|
/**
|
|
98
96
|
* Runs once the teardown promise has settled, so a handler reached from here
|
|
99
97
|
* may call `connect` without waiting for a task its own caller still holds.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RequiredZlinkStreamConnectorOptions, ZlinkStreamConnectorOptions, ZlinkStreamPacketNameResolver } from '../Contracts';
|
|
2
|
+
export { ZLINK_STREAM_DEFAULT_PAYLOAD_BYTES as ZLINK_STREAM_DEFAULT_PAYLOAD_SIZE } from '../Contracts/ZlinkStreamConnectorOptions';
|
|
2
3
|
export declare function normalizeOptions(options: ZlinkStreamConnectorOptions, defaultTransportFactory: RequiredZlinkStreamConnectorOptions['transportFactory']): RequiredZlinkStreamConnectorOptions;
|
|
3
4
|
/**
|
|
4
5
|
* Spec stream-connector 32 §5 and the TypeScript projection §4: a payload type
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Disposable, ZlinkStreamEncodedPayload, ZlinkStreamMessage } from '../Contracts';
|
|
2
2
|
import type { ZlinkStreamConnectorEvents } from './ZlinkStreamConnectorEvents';
|
|
3
|
+
import { type DefaultZlinkStreamActor } from './ZlinkStreamActors';
|
|
3
4
|
type EncodedMessageHandler = (message: ZlinkStreamMessage<ZlinkStreamEncodedPayload>, signal?: AbortSignal) => Promise<void> | void;
|
|
4
5
|
/**
|
|
5
6
|
* A wait surface (`waitFor`, `expectNone`, `waitForSequence`) reading the queue
|
|
@@ -29,7 +30,7 @@ export declare class ZlinkStreamReceivedMessages {
|
|
|
29
30
|
* @param actor The Actor handle that registers the handler, if any. Its
|
|
30
31
|
* handler receives only that Actor's packets.
|
|
31
32
|
*/
|
|
32
|
-
on(name: string, handler: EncodedMessageHandler, actor?:
|
|
33
|
+
on(name: string, handler: EncodedMessageHandler, actor?: DefaultZlinkStreamActor): Disposable;
|
|
33
34
|
/**
|
|
34
35
|
* Registers a wait surface over the receive queue. Spec stream-connector 32
|
|
35
36
|
* §7: these are not registered callbacks — they observe and consume the
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Disposable, ZlinkStreamError, ZlinkStreamErrorCode, ZlinkStreamException } from '../Contracts';
|
|
2
|
+
/** Returns whether the consumed prefix should compact the backing array. */
|
|
3
|
+
export declare function shouldCompactBackingArray(head: number, length: number): boolean;
|
|
2
4
|
export declare function connectorError(code: ZlinkStreamErrorCode, message: string, cause?: unknown): ZlinkStreamException;
|
|
3
5
|
export declare function toStreamError(cause: unknown, code: ZlinkStreamErrorCode, message: string): ZlinkStreamError;
|
|
4
6
|
export declare function unwrapStreamError(error: unknown): ZlinkStreamError;
|
|
5
7
|
export declare function subscription(dispose: () => void): Disposable;
|
|
8
|
+
/** Snapshot order is preserved; membership owns each registration's lifetime. */
|
|
9
|
+
export declare function currentRegistrations<T>(registrations: ReadonlySet<T>, snapshot?: readonly T[]): IterableIterator<T>;
|
|
10
|
+
export interface HandlerRegistration<T> {
|
|
11
|
+
readonly handler: T;
|
|
12
|
+
}
|
|
13
|
+
export declare function registerHandler<T>(handlers: Set<HandlerRegistration<T>>, handler: T): Disposable;
|
|
6
14
|
export declare function throwIfAborted(signal: AbortSignal | undefined): void;
|
|
7
15
|
export declare function delay(delayMs: number, signal: AbortSignal | undefined): Promise<void>;
|
|
8
|
-
export declare function readLength(source: Uint8Array, offset: number, bytes: 1 | 2, label: string): number;
|
|
9
|
-
export declare function writeUInt16BE(destination: Uint8Array, offset: number, value: number): void;
|
|
10
|
-
export declare function writeUInt32BE(destination: Uint8Array, offset: number, value: number): void;
|
|
11
|
-
export declare function readUInt16BE(source: Uint8Array, offset: number): number;
|
|
12
|
-
export declare function readUInt32BE(source: Uint8Array, offset: number): number;
|
|
13
|
-
export declare function writeBigUInt64BE(destination: Uint8Array, offset: number, value: bigint): void;
|
|
14
|
-
export declare function readBigUInt64BE(source: Uint8Array, offset: number): bigint;
|
|
15
16
|
export declare function utf8Encode(value: string): Uint8Array;
|
|
16
17
|
export declare function utf8Decode(value: Uint8Array): string;
|