@zlink-systems/stream-connector 0.18.0 → 0.19.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/Runtime/Calls/ZlinkStreamCallBuilders.d.ts +1 -1
- package/dist/browser/Runtime/Calls/ZlinkStreamObservationBuilders.d.ts +1 -1
- package/dist/browser/Runtime/ZlinkStreamConnector.d.ts +13 -1
- package/dist/browser/Runtime/ZlinkStreamReceivedMessages.d.ts +18 -11
- package/dist/browser/index.global.js +55 -30
- package/dist/browser/index.mjs +55 -30
- package/dist/package.json +1 -0
- package/package.json +3 -2
|
@@ -3,7 +3,7 @@ interface ZlinkStreamConnectorSubmitter {
|
|
|
3
3
|
readonly options: RequiredZlinkStreamConnectorOptions;
|
|
4
4
|
sendEncoded(kind: ZlinkStreamMessageKind, name: string, payload: ZlinkStreamEncodedPayload, metadata: ZlinkStreamMetadata, compress: boolean, requestSeq: bigint | undefined, signal?: AbortSignal, flow?: ZlinkStreamFlow): Promise<void>;
|
|
5
5
|
requestEncoded(name: string, payload: ZlinkStreamEncodedPayload, metadata: ZlinkStreamMetadata, compress: boolean, timeoutMs: number, signal?: AbortSignal, flow?: ZlinkStreamFlow): Promise<ZlinkStreamEncodedPayload>;
|
|
6
|
-
waitForMessage<TPayload>(name: string, timeoutMs: number, predicate: (message: ZlinkStreamMessage<TPayload>) => boolean, signal?: AbortSignal): Promise<ZlinkStreamMessage<TPayload
|
|
6
|
+
waitForMessage<TPayload>(name: string, timeoutMs: number, predicate: (message: ZlinkStreamMessage<TPayload>) => boolean, signal?: AbortSignal): Promise<ZlinkStreamMessage<TPayload> | undefined>;
|
|
7
7
|
}
|
|
8
8
|
export declare class ZlinkStreamSendBuilder implements ZlinkStreamSendCall {
|
|
9
9
|
private readonly connector;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type RequiredZlinkStreamConnectorOptions, type ZlinkStreamExpectNoneCall, type ZlinkStreamMessage, type ZlinkStreamSequenceCall } from '../../Contracts';
|
|
2
2
|
export interface ZlinkStreamMessageWaiter {
|
|
3
3
|
readonly options: RequiredZlinkStreamConnectorOptions;
|
|
4
|
-
waitForMessage<TPayload>(name: string, timeoutMs: number, predicate: (message: ZlinkStreamMessage<TPayload>) => boolean, signal?: AbortSignal): Promise<ZlinkStreamMessage<TPayload
|
|
4
|
+
waitForMessage<TPayload>(name: string, timeoutMs: number, predicate: (message: ZlinkStreamMessage<TPayload>) => boolean, signal?: AbortSignal): Promise<ZlinkStreamMessage<TPayload> | undefined>;
|
|
5
5
|
}
|
|
6
6
|
export declare class ZlinkStreamExpectNoneBuilder<TPayload> implements ZlinkStreamExpectNoneCall<TPayload> {
|
|
7
7
|
private readonly connector;
|
|
@@ -67,7 +67,19 @@ export declare class DefaultZlinkStreamConnector implements ZlinkStreamConnector
|
|
|
67
67
|
* `send` and `request` use, so both paths land on one name for one type.
|
|
68
68
|
*/
|
|
69
69
|
private observedName;
|
|
70
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Consumes the first message under `name` that `predicate` accepts, or
|
|
72
|
+
* resolves `undefined` when `timeoutMs` elapses first.
|
|
73
|
+
*
|
|
74
|
+
* A timeout is not a failure here. Each wait surface decides what its own
|
|
75
|
+
* timeout means — `waitFor` fails on it while `expectNone` succeeds — and
|
|
76
|
+
* reports that decision as `ValidationFailed` (spec stream-connector 32
|
|
77
|
+
* §10.1.1; .NET `ZlinkStreamReceivedMessages.WaitForAsync` parity). Losing
|
|
78
|
+
* the connection the wait observes is the one ending decided here, because
|
|
79
|
+
* the wait has no place left to observe: that is `Disconnected` for every
|
|
80
|
+
* surface (§10.1.1).
|
|
81
|
+
*/
|
|
82
|
+
waitForMessage<TPayload>(name: string, timeoutMs: number, predicate: (message: ZlinkStreamMessage<TPayload>) => boolean, signal?: AbortSignal): Promise<ZlinkStreamMessage<TPayload> | undefined>;
|
|
71
83
|
private encodePayload;
|
|
72
84
|
private decodePayload;
|
|
73
85
|
private decodeWaitPayload;
|
|
@@ -35,10 +35,10 @@ export declare class ZlinkStreamReceivedMessages {
|
|
|
35
35
|
* observed, and so the caller has its subscription in hand by then.
|
|
36
36
|
*
|
|
37
37
|
* @param onConnectionEnded Called, instead of {@link observer}, when
|
|
38
|
-
* {@link
|
|
38
|
+
* {@link connectionEnded} abandons this registration because the
|
|
39
39
|
* connection it was watching ended before a message matched (spec
|
|
40
|
-
* stream-connector 32 §10.1: "연결이 끝나 대기를 이어갈 수 없으면
|
|
41
|
-
* `Disconnected`다").
|
|
40
|
+
* stream-connector 32 §10.1.1: "연결이 끝나 대기를 이어갈 수 없으면
|
|
41
|
+
* `Disconnected`다", released when that connection ends).
|
|
42
42
|
*/
|
|
43
43
|
observe(name: string, observer: EncodedMessageObserver, onConnectionEnded: () => void): Disposable;
|
|
44
44
|
/** Spec stream-connector 32 §10: arrivals under `name` on this connection. */
|
|
@@ -57,15 +57,22 @@ export declare class ZlinkStreamReceivedMessages {
|
|
|
57
57
|
* unlike Java's queued frames, which `closeMessage` releases — so dropping
|
|
58
58
|
* the queue's references is the whole of the release here.
|
|
59
59
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* connection that just ended with `Disconnected` (Java
|
|
64
|
-
* `ZLinkStreamDispatchQueue.resetForNewConnection` parity) — that
|
|
65
|
-
* registration was watching a queue this call just discarded, so letting
|
|
66
|
-
* it keep watching would silently rebind it to the new connection.
|
|
60
|
+
* Wait surfaces are not touched here. The ones of the previous connection
|
|
61
|
+
* were released by {@link connectionEnded} when that connection ended, and
|
|
62
|
+
* one registered since then is waiting for this connection.
|
|
67
63
|
*/
|
|
68
|
-
resetForNewConnection(
|
|
64
|
+
resetForNewConnection(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Releases every registered wait surface because the connection it was
|
|
67
|
+
* watching has ended — a transport loss, a server close, or `close()`.
|
|
68
|
+
* Spec stream-connector 32 §10.1.1: "푸는 시점은 연결이 끝난 때이지 다음
|
|
69
|
+
* 연결이 성립한 때가 아니다". The release belongs to the ending, so a wait
|
|
70
|
+
* does not hang until its own timeout when no next connection comes
|
|
71
|
+
* (reconnect off, attempts spent) and does not silently rebind to the next
|
|
72
|
+
* one when it does. The queue and the counts stay: they are rebaselined by
|
|
73
|
+
* the next {@link resetForNewConnection}, not by the ending (§10).
|
|
74
|
+
*/
|
|
75
|
+
connectionEnded(): void;
|
|
69
76
|
enqueue(message: ZlinkStreamMessage<ZlinkStreamEncodedPayload>, signal?: AbortSignal): void;
|
|
70
77
|
/**
|
|
71
78
|
* Runs the registered handlers the receive path left queued. `Manual` calls
|
|
@@ -913,15 +913,18 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
913
913
|
this.timeoutMs = timeoutMs;
|
|
914
914
|
return this;
|
|
915
915
|
}
|
|
916
|
-
submit(signal) {
|
|
916
|
+
async submit(signal) {
|
|
917
917
|
var _a;
|
|
918
918
|
this.markExecuted();
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
919
|
+
const timeoutMs = (_a = this.timeoutMs) != null ? _a : this.connector.options.waitTimeoutMs;
|
|
920
|
+
const message = await this.connector.waitForMessage(this.name, timeoutMs, this.predicate, signal);
|
|
921
|
+
if (message === void 0) {
|
|
922
|
+
throw connectorError(
|
|
923
|
+
"validationFailed" /* ValidationFailed */,
|
|
924
|
+
`No '${this.name}' message arrived within ${timeoutMs}ms.`
|
|
925
|
+
);
|
|
926
|
+
}
|
|
927
|
+
return message;
|
|
925
928
|
}
|
|
926
929
|
ensureConfigurable() {
|
|
927
930
|
if (this.executed) {
|
|
@@ -953,13 +956,9 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
953
956
|
if (this.windowMs === void 0) {
|
|
954
957
|
throw connectorError("validationFailed" /* ValidationFailed */, "expectNone requires within(windowMs).");
|
|
955
958
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
if (unwrapStreamError(error).code === "requestTimeout" /* RequestTimeout */) {
|
|
960
|
-
return;
|
|
961
|
-
}
|
|
962
|
-
throw error;
|
|
959
|
+
const message = await this.connector.waitForMessage(this.name, this.windowMs, () => true, signal);
|
|
960
|
+
if (message === void 0) {
|
|
961
|
+
return;
|
|
963
962
|
}
|
|
964
963
|
throw connectorError(
|
|
965
964
|
"validationFailed" /* ValidationFailed */,
|
|
@@ -1022,6 +1021,12 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1022
1021
|
},
|
|
1023
1022
|
signal
|
|
1024
1023
|
);
|
|
1024
|
+
if (message === void 0) {
|
|
1025
|
+
throw connectorError(
|
|
1026
|
+
"validationFailed" /* ValidationFailed */,
|
|
1027
|
+
`The '${this.name}' sequence did not complete within ${timeoutMs}ms.`
|
|
1028
|
+
);
|
|
1029
|
+
}
|
|
1025
1030
|
messages.push(message);
|
|
1026
1031
|
}
|
|
1027
1032
|
return messages;
|
|
@@ -1642,10 +1647,10 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1642
1647
|
* observed, and so the caller has its subscription in hand by then.
|
|
1643
1648
|
*
|
|
1644
1649
|
* @param onConnectionEnded Called, instead of {@link observer}, when
|
|
1645
|
-
* {@link
|
|
1650
|
+
* {@link connectionEnded} abandons this registration because the
|
|
1646
1651
|
* connection it was watching ended before a message matched (spec
|
|
1647
|
-
* stream-connector 32 §10.1: "연결이 끝나 대기를 이어갈 수 없으면
|
|
1648
|
-
* `Disconnected`다").
|
|
1652
|
+
* stream-connector 32 §10.1.1: "연결이 끝나 대기를 이어갈 수 없으면
|
|
1653
|
+
* `Disconnected`다", released when that connection ends).
|
|
1649
1654
|
*/
|
|
1650
1655
|
observe(name, observer, onConnectionEnded) {
|
|
1651
1656
|
validateName(name);
|
|
@@ -1688,20 +1693,28 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
1688
1693
|
* unlike Java's queued frames, which `closeMessage` releases — so dropping
|
|
1689
1694
|
* the queue's references is the whole of the release here.
|
|
1690
1695
|
*
|
|
1691
|
-
*
|
|
1692
|
-
*
|
|
1693
|
-
*
|
|
1694
|
-
* connection that just ended with `Disconnected` (Java
|
|
1695
|
-
* `ZLinkStreamDispatchQueue.resetForNewConnection` parity) — that
|
|
1696
|
-
* registration was watching a queue this call just discarded, so letting
|
|
1697
|
-
* it keep watching would silently rebind it to the new connection.
|
|
1696
|
+
* Wait surfaces are not touched here. The ones of the previous connection
|
|
1697
|
+
* were released by {@link connectionEnded} when that connection ended, and
|
|
1698
|
+
* one registered since then is waiting for this connection.
|
|
1698
1699
|
*/
|
|
1699
|
-
resetForNewConnection(
|
|
1700
|
+
resetForNewConnection() {
|
|
1700
1701
|
this.receivedCounts.clear();
|
|
1701
1702
|
this.queue.length = 0;
|
|
1702
1703
|
this.queueHead = 0;
|
|
1703
1704
|
this.queuedCount = 0;
|
|
1704
|
-
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Releases every registered wait surface because the connection it was
|
|
1708
|
+
* watching has ended — a transport loss, a server close, or `close()`.
|
|
1709
|
+
* Spec stream-connector 32 §10.1.1: "푸는 시점은 연결이 끝난 때이지 다음
|
|
1710
|
+
* 연결이 성립한 때가 아니다". The release belongs to the ending, so a wait
|
|
1711
|
+
* does not hang until its own timeout when no next connection comes
|
|
1712
|
+
* (reconnect off, attempts spent) and does not silently rebind to the next
|
|
1713
|
+
* one when it does. The queue and the counts stay: they are rebaselined by
|
|
1714
|
+
* the next {@link resetForNewConnection}, not by the ending (§10).
|
|
1715
|
+
*/
|
|
1716
|
+
connectionEnded() {
|
|
1717
|
+
if (this.observers.size === 0) {
|
|
1705
1718
|
return;
|
|
1706
1719
|
}
|
|
1707
1720
|
const abandoned = [...this.observers.values()].flatMap((set) => [...set]);
|
|
@@ -2141,7 +2154,7 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2141
2154
|
this.currentConnection = connection;
|
|
2142
2155
|
this.connectionGeneration += 1;
|
|
2143
2156
|
this.disconnectedPublished = false;
|
|
2144
|
-
this.receivedMessages.resetForNewConnection(
|
|
2157
|
+
this.receivedMessages.resetForNewConnection();
|
|
2145
2158
|
this.lastInboundAt = Date.now();
|
|
2146
2159
|
await this.setState("connected" /* Connected */, void 0, signal);
|
|
2147
2160
|
this.startHeartbeat();
|
|
@@ -2202,6 +2215,7 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2202
2215
|
errors.push(error);
|
|
2203
2216
|
}
|
|
2204
2217
|
this.pendingRequests.failAll({ code: "disconnected" /* Disconnected */, message: "Connector closed." });
|
|
2218
|
+
this.receivedMessages.connectionEnded();
|
|
2205
2219
|
await this.setState("closed" /* Closed */, void 0, signal);
|
|
2206
2220
|
this.publishDisconnectedWithoutWaiting(signal);
|
|
2207
2221
|
if (errors.length === 1) throw errors[0];
|
|
@@ -2427,6 +2441,7 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2427
2441
|
const connection = this.currentConnection;
|
|
2428
2442
|
this.currentConnection = void 0;
|
|
2429
2443
|
this.pendingRequests.failAll(error);
|
|
2444
|
+
this.receivedMessages.connectionEnded();
|
|
2430
2445
|
try {
|
|
2431
2446
|
await (connection == null ? void 0 : connection.close());
|
|
2432
2447
|
} catch {
|
|
@@ -2920,6 +2935,18 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2920
2935
|
validateName(name);
|
|
2921
2936
|
return name;
|
|
2922
2937
|
}
|
|
2938
|
+
/**
|
|
2939
|
+
* Consumes the first message under `name` that `predicate` accepts, or
|
|
2940
|
+
* resolves `undefined` when `timeoutMs` elapses first.
|
|
2941
|
+
*
|
|
2942
|
+
* A timeout is not a failure here. Each wait surface decides what its own
|
|
2943
|
+
* timeout means — `waitFor` fails on it while `expectNone` succeeds — and
|
|
2944
|
+
* reports that decision as `ValidationFailed` (spec stream-connector 32
|
|
2945
|
+
* §10.1.1; .NET `ZlinkStreamReceivedMessages.WaitForAsync` parity). Losing
|
|
2946
|
+
* the connection the wait observes is the one ending decided here, because
|
|
2947
|
+
* the wait has no place left to observe: that is `Disconnected` for every
|
|
2948
|
+
* surface (§10.1.1).
|
|
2949
|
+
*/
|
|
2923
2950
|
waitForMessage(name, timeoutMs, predicate, signal) {
|
|
2924
2951
|
validateName(name);
|
|
2925
2952
|
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
|
|
@@ -2947,9 +2974,7 @@ var ZlinkStreamConnectorBundle = (() => {
|
|
|
2947
2974
|
resolve(message);
|
|
2948
2975
|
}
|
|
2949
2976
|
};
|
|
2950
|
-
timer = setTimeout(() =>
|
|
2951
|
-
finish(connectorError("requestTimeout" /* RequestTimeout */, "Wait for stream message timed out."));
|
|
2952
|
-
}, timeoutMs);
|
|
2977
|
+
timer = setTimeout(() => finish(), timeoutMs);
|
|
2953
2978
|
signal == null ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
|
|
2954
2979
|
disposable = this.receivedMessages.observe(name, (message) => {
|
|
2955
2980
|
if (done) {
|
package/dist/browser/index.mjs
CHANGED
|
@@ -861,14 +861,17 @@ var ZlinkStreamWaitBuilder = class {
|
|
|
861
861
|
this.timeoutMs = timeoutMs;
|
|
862
862
|
return this;
|
|
863
863
|
}
|
|
864
|
-
submit(signal) {
|
|
864
|
+
async submit(signal) {
|
|
865
865
|
this.markExecuted();
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
866
|
+
const timeoutMs = this.timeoutMs ?? this.connector.options.waitTimeoutMs;
|
|
867
|
+
const message = await this.connector.waitForMessage(this.name, timeoutMs, this.predicate, signal);
|
|
868
|
+
if (message === void 0) {
|
|
869
|
+
throw connectorError(
|
|
870
|
+
"validationFailed" /* ValidationFailed */,
|
|
871
|
+
`No '${this.name}' message arrived within ${timeoutMs}ms.`
|
|
872
|
+
);
|
|
873
|
+
}
|
|
874
|
+
return message;
|
|
872
875
|
}
|
|
873
876
|
ensureConfigurable() {
|
|
874
877
|
if (this.executed) {
|
|
@@ -900,13 +903,9 @@ var ZlinkStreamExpectNoneBuilder = class {
|
|
|
900
903
|
if (this.windowMs === void 0) {
|
|
901
904
|
throw connectorError("validationFailed" /* ValidationFailed */, "expectNone requires within(windowMs).");
|
|
902
905
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
if (unwrapStreamError(error).code === "requestTimeout" /* RequestTimeout */) {
|
|
907
|
-
return;
|
|
908
|
-
}
|
|
909
|
-
throw error;
|
|
906
|
+
const message = await this.connector.waitForMessage(this.name, this.windowMs, () => true, signal);
|
|
907
|
+
if (message === void 0) {
|
|
908
|
+
return;
|
|
910
909
|
}
|
|
911
910
|
throw connectorError(
|
|
912
911
|
"validationFailed" /* ValidationFailed */,
|
|
@@ -968,6 +967,12 @@ var ZlinkStreamSequenceBuilder = class {
|
|
|
968
967
|
},
|
|
969
968
|
signal
|
|
970
969
|
);
|
|
970
|
+
if (message === void 0) {
|
|
971
|
+
throw connectorError(
|
|
972
|
+
"validationFailed" /* ValidationFailed */,
|
|
973
|
+
`The '${this.name}' sequence did not complete within ${timeoutMs}ms.`
|
|
974
|
+
);
|
|
975
|
+
}
|
|
971
976
|
messages.push(message);
|
|
972
977
|
}
|
|
973
978
|
return messages;
|
|
@@ -1582,10 +1587,10 @@ var ZlinkStreamReceivedMessages = class {
|
|
|
1582
1587
|
* observed, and so the caller has its subscription in hand by then.
|
|
1583
1588
|
*
|
|
1584
1589
|
* @param onConnectionEnded Called, instead of {@link observer}, when
|
|
1585
|
-
* {@link
|
|
1590
|
+
* {@link connectionEnded} abandons this registration because the
|
|
1586
1591
|
* connection it was watching ended before a message matched (spec
|
|
1587
|
-
* stream-connector 32 §10.1: "연결이 끝나 대기를 이어갈 수 없으면
|
|
1588
|
-
* `Disconnected`다").
|
|
1592
|
+
* stream-connector 32 §10.1.1: "연결이 끝나 대기를 이어갈 수 없으면
|
|
1593
|
+
* `Disconnected`다", released when that connection ends).
|
|
1589
1594
|
*/
|
|
1590
1595
|
observe(name, observer, onConnectionEnded) {
|
|
1591
1596
|
validateName(name);
|
|
@@ -1626,20 +1631,28 @@ var ZlinkStreamReceivedMessages = class {
|
|
|
1626
1631
|
* unlike Java's queued frames, which `closeMessage` releases — so dropping
|
|
1627
1632
|
* the queue's references is the whole of the release here.
|
|
1628
1633
|
*
|
|
1629
|
-
*
|
|
1630
|
-
*
|
|
1631
|
-
*
|
|
1632
|
-
* connection that just ended with `Disconnected` (Java
|
|
1633
|
-
* `ZLinkStreamDispatchQueue.resetForNewConnection` parity) — that
|
|
1634
|
-
* registration was watching a queue this call just discarded, so letting
|
|
1635
|
-
* it keep watching would silently rebind it to the new connection.
|
|
1634
|
+
* Wait surfaces are not touched here. The ones of the previous connection
|
|
1635
|
+
* were released by {@link connectionEnded} when that connection ended, and
|
|
1636
|
+
* one registered since then is waiting for this connection.
|
|
1636
1637
|
*/
|
|
1637
|
-
resetForNewConnection(
|
|
1638
|
+
resetForNewConnection() {
|
|
1638
1639
|
this.receivedCounts.clear();
|
|
1639
1640
|
this.queue.length = 0;
|
|
1640
1641
|
this.queueHead = 0;
|
|
1641
1642
|
this.queuedCount = 0;
|
|
1642
|
-
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Releases every registered wait surface because the connection it was
|
|
1646
|
+
* watching has ended — a transport loss, a server close, or `close()`.
|
|
1647
|
+
* Spec stream-connector 32 §10.1.1: "푸는 시점은 연결이 끝난 때이지 다음
|
|
1648
|
+
* 연결이 성립한 때가 아니다". The release belongs to the ending, so a wait
|
|
1649
|
+
* does not hang until its own timeout when no next connection comes
|
|
1650
|
+
* (reconnect off, attempts spent) and does not silently rebind to the next
|
|
1651
|
+
* one when it does. The queue and the counts stay: they are rebaselined by
|
|
1652
|
+
* the next {@link resetForNewConnection}, not by the ending (§10).
|
|
1653
|
+
*/
|
|
1654
|
+
connectionEnded() {
|
|
1655
|
+
if (this.observers.size === 0) {
|
|
1643
1656
|
return;
|
|
1644
1657
|
}
|
|
1645
1658
|
const abandoned = [...this.observers.values()].flatMap((set) => [...set]);
|
|
@@ -2073,7 +2086,7 @@ var ZlinkStreamConnectorLifecycle = class {
|
|
|
2073
2086
|
this.currentConnection = connection;
|
|
2074
2087
|
this.connectionGeneration += 1;
|
|
2075
2088
|
this.disconnectedPublished = false;
|
|
2076
|
-
this.receivedMessages.resetForNewConnection(
|
|
2089
|
+
this.receivedMessages.resetForNewConnection();
|
|
2077
2090
|
this.lastInboundAt = Date.now();
|
|
2078
2091
|
await this.setState("connected" /* Connected */, void 0, signal);
|
|
2079
2092
|
this.startHeartbeat();
|
|
@@ -2133,6 +2146,7 @@ var ZlinkStreamConnectorLifecycle = class {
|
|
|
2133
2146
|
errors.push(error);
|
|
2134
2147
|
}
|
|
2135
2148
|
this.pendingRequests.failAll({ code: "disconnected" /* Disconnected */, message: "Connector closed." });
|
|
2149
|
+
this.receivedMessages.connectionEnded();
|
|
2136
2150
|
await this.setState("closed" /* Closed */, void 0, signal);
|
|
2137
2151
|
this.publishDisconnectedWithoutWaiting(signal);
|
|
2138
2152
|
if (errors.length === 1) throw errors[0];
|
|
@@ -2354,6 +2368,7 @@ var ZlinkStreamConnectorLifecycle = class {
|
|
|
2354
2368
|
const connection = this.currentConnection;
|
|
2355
2369
|
this.currentConnection = void 0;
|
|
2356
2370
|
this.pendingRequests.failAll(error);
|
|
2371
|
+
this.receivedMessages.connectionEnded();
|
|
2357
2372
|
try {
|
|
2358
2373
|
await connection?.close();
|
|
2359
2374
|
} catch {
|
|
@@ -2846,6 +2861,18 @@ var DefaultZlinkStreamConnector = class {
|
|
|
2846
2861
|
validateName(name);
|
|
2847
2862
|
return name;
|
|
2848
2863
|
}
|
|
2864
|
+
/**
|
|
2865
|
+
* Consumes the first message under `name` that `predicate` accepts, or
|
|
2866
|
+
* resolves `undefined` when `timeoutMs` elapses first.
|
|
2867
|
+
*
|
|
2868
|
+
* A timeout is not a failure here. Each wait surface decides what its own
|
|
2869
|
+
* timeout means — `waitFor` fails on it while `expectNone` succeeds — and
|
|
2870
|
+
* reports that decision as `ValidationFailed` (spec stream-connector 32
|
|
2871
|
+
* §10.1.1; .NET `ZlinkStreamReceivedMessages.WaitForAsync` parity). Losing
|
|
2872
|
+
* the connection the wait observes is the one ending decided here, because
|
|
2873
|
+
* the wait has no place left to observe: that is `Disconnected` for every
|
|
2874
|
+
* surface (§10.1.1).
|
|
2875
|
+
*/
|
|
2849
2876
|
waitForMessage(name, timeoutMs, predicate, signal) {
|
|
2850
2877
|
validateName(name);
|
|
2851
2878
|
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
|
|
@@ -2873,9 +2900,7 @@ var DefaultZlinkStreamConnector = class {
|
|
|
2873
2900
|
resolve(message);
|
|
2874
2901
|
}
|
|
2875
2902
|
};
|
|
2876
|
-
timer = setTimeout(() =>
|
|
2877
|
-
finish(connectorError("requestTimeout" /* RequestTimeout */, "Wait for stream message timed out."));
|
|
2878
|
-
}, timeoutMs);
|
|
2903
|
+
timer = setTimeout(() => finish(), timeoutMs);
|
|
2879
2904
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
2880
2905
|
disposable = this.receivedMessages.observe(name, (message) => {
|
|
2881
2906
|
if (done) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zlink-systems/stream-connector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"types": "dist/browser/index.d.ts",
|
|
13
13
|
"files": [
|
|
14
14
|
"dist/browser",
|
|
15
|
+
"dist/package.json",
|
|
15
16
|
"LICENSE"
|
|
16
17
|
],
|
|
17
18
|
"exports": {
|
|
@@ -21,6 +22,6 @@
|
|
|
21
22
|
}
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@zlink-systems/stream-wire": "0.
|
|
25
|
+
"@zlink-systems/stream-wire": "0.19.0"
|
|
25
26
|
}
|
|
26
27
|
}
|