@moq/net 0.3.4 → 0.4.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/README.md +2 -2
- package/announce.d.ts +7 -0
- package/announce.d.ts.map +1 -0
- package/announce.js +8 -0
- package/announce.js.map +1 -0
- package/announced.d.ts +35 -91
- package/announced.d.ts.map +1 -1
- package/announced.js +21 -156
- package/announced.js.map +1 -1
- package/bandwidth.d.ts +163 -0
- package/bandwidth.d.ts.map +1 -0
- package/bandwidth.js +304 -0
- package/bandwidth.js.map +1 -0
- package/bandwidth_api.d.ts +7 -0
- package/bandwidth_api.d.ts.map +1 -0
- package/bandwidth_api.js +8 -0
- package/bandwidth_api.js.map +1 -0
- package/broadcast.d.ts +20 -28
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +60 -42
- package/broadcast.js.map +1 -1
- package/connection/accept.d.ts +16 -1
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +39 -24
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +9 -7
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +30 -6
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +97 -50
- package/connection/connect.js.map +1 -1
- package/connection/established.d.ts +16 -21
- package/connection/established.d.ts.map +1 -1
- package/connection/established.js.map +1 -1
- package/connection/forward.d.ts +2 -0
- package/connection/forward.d.ts.map +1 -0
- package/connection/forward.js +159 -0
- package/connection/forward.js.map +1 -0
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +2 -2
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +5 -5
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +4 -5
- package/connection/index.js.map +1 -1
- package/connection/pool.d.ts +188 -0
- package/connection/pool.d.ts.map +1 -0
- package/connection/pool.js +351 -0
- package/connection/pool.js.map +1 -0
- package/connection/reload.d.ts +14 -93
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +216 -80
- package/connection/reload.js.map +1 -1
- package/connection/stats.d.ts +3 -26
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js.map +1 -1
- package/connection/transport.d.ts +0 -7
- package/connection/transport.d.ts.map +1 -1
- package/consume.d.ts +1 -43
- package/consume.d.ts.map +1 -1
- package/consume.js +1 -1
- package/consume.js.map +1 -1
- package/error.d.ts +180 -29
- package/error.d.ts.map +1 -1
- package/error.js +310 -16
- package/error.js.map +1 -1
- package/errors.d.ts +7 -0
- package/errors.d.ts.map +1 -0
- package/errors.js +8 -0
- package/errors.js.map +1 -0
- package/group.d.ts +9 -43
- package/group.d.ts.map +1 -1
- package/group.js +283 -69
- package/group.js.map +1 -1
- package/hop.d.ts +107 -0
- package/hop.d.ts.map +1 -0
- package/hop.js +103 -0
- package/hop.js.map +1 -0
- package/ietf/aliases.d.ts +1 -78
- package/ietf/aliases.d.ts.map +1 -1
- package/ietf/cluster.d.ts +6 -120
- package/ietf/cluster.d.ts.map +1 -1
- package/ietf/cluster.js +81 -41
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +6 -72
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +11 -47
- package/ietf/connection.js.map +1 -1
- package/ietf/error.d.ts +11 -0
- package/ietf/error.d.ts.map +1 -0
- package/ietf/error.js +168 -0
- package/ietf/error.js.map +1 -0
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +6 -1
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -5
- package/ietf/goaway.js.map +1 -1
- package/ietf/parameters.d.ts +2 -2
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +15 -17
- package/ietf/parameters.js.map +1 -1
- package/ietf/publish_namespace.d.ts +25 -0
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +63 -0
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.d.ts +1 -82
- package/ietf/publisher.d.ts.map +1 -1
- package/ietf/publisher.js +219 -125
- package/ietf/publisher.js.map +1 -1
- package/ietf/solicit.d.ts +1 -40
- package/ietf/solicit.d.ts.map +1 -1
- package/ietf/subscribe.d.ts +1 -5
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +8 -9
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscriber.d.ts +1 -65
- package/ietf/subscriber.d.ts.map +1 -1
- package/ietf/subscriber.js +154 -73
- package/ietf/subscriber.js.map +1 -1
- package/ietf/version.d.ts +12 -1
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +13 -0
- package/ietf/version.js.map +1 -1
- package/index.d.ts +11 -6
- package/index.d.ts.map +1 -1
- package/index.js +10 -5
- package/index.js.map +1 -1
- package/internal.d.ts +99 -1
- package/internal.d.ts.map +1 -1
- package/internal.js +65 -0
- package/internal.js.map +1 -1
- package/lite/announce.d.ts +15 -9
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +47 -20
- package/lite/announce.js.map +1 -1
- package/lite/connection.d.ts +9 -59
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +20 -32
- package/lite/connection.js.map +1 -1
- package/lite/fetch.d.ts +15 -1
- package/lite/fetch.d.ts.map +1 -1
- package/lite/fetch.js +39 -7
- package/lite/fetch.js.map +1 -1
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +7 -1
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +18 -4
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +31 -10
- package/lite/group.js.map +1 -1
- package/lite/priority.d.ts +1 -61
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +4 -5
- package/lite/priority.js.map +1 -1
- package/lite/publisher.d.ts +1 -69
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +559 -232
- package/lite/publisher.js.map +1 -1
- package/lite/setup.d.ts +7 -7
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +13 -13
- package/lite/setup.js.map +1 -1
- package/lite/subscribe.d.ts +61 -13
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +186 -44
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +8 -57
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +179 -117
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +4 -10
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +34 -29
- package/lite/track.js.map +1 -1
- package/lite/version.d.ts +31 -6
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +71 -11
- package/lite/version.js.map +1 -1
- package/origin.d.ts +229 -29
- package/origin.d.ts.map +1 -1
- package/origin.js +1087 -37
- package/origin.js.map +1 -1
- package/package.json +3 -2
- package/path.d.ts +25 -7
- package/path.d.ts.map +1 -1
- package/path.js +5 -3
- package/path.js.map +1 -1
- package/stream.d.ts.map +1 -1
- package/stream.js +25 -16
- package/stream.js.map +1 -1
- package/time.d.ts +15 -2
- package/time.d.ts.map +1 -1
- package/time.js +28 -9
- package/time.js.map +1 -1
- package/track.d.ts +171 -82
- package/track.d.ts.map +1 -1
- package/track.js +633 -184
- package/track.js.map +1 -1
- package/util/log.d.ts +5 -0
- package/util/log.d.ts.map +1 -0
- package/util/log.js +17 -0
- package/util/log.js.map +1 -0
- package/wire.d.ts +67 -0
- package/wire.d.ts.map +1 -0
- package/wire.js +32 -0
- package/wire.js.map +1 -0
- package/zod.d.ts +1 -1
- package/zod.d.ts.map +1 -1
- package/zod.js.map +1 -1
- package/mock.d.ts +0 -66
- package/mock.d.ts.map +0 -1
- package/mock.js +0 -243
- package/mock.js.map +0 -1
package/track.d.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
import { type GetPromise, type Getter } from "@moq/signals";
|
|
7
7
|
import type { Datagram } from "./datagram";
|
|
8
8
|
import { type Frame, type Consumer as GroupConsumer, Producer as GroupProducer } from "./group";
|
|
9
|
-
import { Timescale, type Timestamp } from "./time";
|
|
9
|
+
import { Milli, Timescale, type Timestamp } from "./time";
|
|
10
10
|
export type { Datagram } from "./datagram";
|
|
11
|
-
/** Default {@link Info.
|
|
12
|
-
export declare const
|
|
11
|
+
/** Default {@link Info.maxAge} window (milliseconds) when the publisher does not set one. */
|
|
12
|
+
export declare const DEFAULT_MAX_AGE_MS: Milli;
|
|
13
13
|
/** A position within a track: a group's sequence and a frame's index inside it. */
|
|
14
14
|
export interface Location {
|
|
15
15
|
/** The group's sequence number within the track. */
|
|
@@ -32,39 +32,59 @@ export interface Info {
|
|
|
32
32
|
*/
|
|
33
33
|
timescale: Timescale;
|
|
34
34
|
/**
|
|
35
|
-
* Publisher Max
|
|
35
|
+
* Publisher Max Age: the maximum age (milliseconds) of a non-latest group before
|
|
36
36
|
* the publisher evicts it. Reported in TRACK_INFO (Lite05+) so relays re-serve with the
|
|
37
37
|
* same bound. The publisher-side half of the budget a subscriber sets for itself.
|
|
38
|
+
* Rounded up to a whole millisecond by {@link infoDefaults}, which refuses a negative
|
|
39
|
+
* or non-finite value and a result past `Number.MAX_SAFE_INTEGER`.
|
|
38
40
|
*/
|
|
39
|
-
|
|
40
|
-
/** Tie-break priority between subscriptions of equal subscriber priority. */
|
|
41
|
+
maxAge: Milli;
|
|
42
|
+
/** Tie-break priority between subscriptions of equal subscriber priority (`0..=255`). */
|
|
41
43
|
priority: number;
|
|
42
|
-
/**
|
|
43
|
-
* Whether groups are prioritized in sequence order. Groups may always arrive
|
|
44
|
-
* out-of-order (or not at all) over the network. Defaults to `false` (newest-first).
|
|
45
|
-
*/
|
|
46
|
-
ordered: boolean;
|
|
47
44
|
}
|
|
48
45
|
/** Fill in any unset {@link Info} fields with their defaults. */
|
|
49
46
|
export declare function infoDefaults(info?: Partial<Info>): Info;
|
|
47
|
+
/** An explicitly included or excluded group sequence. */
|
|
48
|
+
export type Bound = {
|
|
49
|
+
included: number;
|
|
50
|
+
excluded?: never;
|
|
51
|
+
} | {
|
|
52
|
+
excluded: number;
|
|
53
|
+
included?: never;
|
|
54
|
+
};
|
|
55
|
+
/** Group limits; an omitted endpoint is unbounded. */
|
|
56
|
+
export interface Groups {
|
|
57
|
+
/** The first group boundary. */
|
|
58
|
+
start?: Bound;
|
|
59
|
+
/** The last group boundary. */
|
|
60
|
+
end?: Bound;
|
|
61
|
+
}
|
|
50
62
|
/**
|
|
51
63
|
* Per-subscription options, requested when a subscription opens and adjustable later via
|
|
52
64
|
* {@link Subscriber.update}. Mirrors the Rust `Subscription`.
|
|
53
65
|
*/
|
|
54
66
|
export interface Subscription {
|
|
55
|
-
/** Delivery priority relative to this session's other subscriptions. Defaults to `0`. */
|
|
67
|
+
/** Delivery priority relative to this session's other subscriptions (`0..=255`). Defaults to `0`. */
|
|
56
68
|
priority?: number;
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Maximum age (milliseconds) of a non-latest group before it is skipped. Defaults to `0`.
|
|
71
|
+
* Rounded up to a whole millisecond, so a value derived from a measurement is never
|
|
72
|
+
* shortened. A negative or non-finite value, or one past `Number.MAX_SAFE_INTEGER`
|
|
73
|
+
* after rounding, is refused.
|
|
74
|
+
*/
|
|
75
|
+
maxAge?: Milli;
|
|
76
|
+
/**
|
|
77
|
+
* The lowest group the publisher may deliver (a floor), or omit for none.
|
|
78
|
+
*
|
|
79
|
+
* A floor, not a request: only {@link maxAge} asks for data, and the floor bounds how
|
|
80
|
+
* far back it may reach. Omitting it and a floor of 0 mean the same thing, and a floor
|
|
81
|
+
* above the live edge simply waits there (a resumed subscription naming where it left
|
|
82
|
+
* off).
|
|
83
|
+
*/
|
|
84
|
+
groups?: Groups;
|
|
65
85
|
}
|
|
66
86
|
/**
|
|
67
|
-
* A request for a track the peer wants,
|
|
87
|
+
* A request for a track the peer wants, delivered to the publishing wire layer.
|
|
68
88
|
*
|
|
69
89
|
* Created internally by the broadcast when a subscription (or info lookup) needs a track
|
|
70
90
|
* served; answer it with {@link accept} or {@link reject}.
|
|
@@ -90,21 +110,6 @@ export interface FetchGroupOptions {
|
|
|
90
110
|
/** Delivery priority for the fetch stream. Defaults to `0`. */
|
|
91
111
|
priority?: number;
|
|
92
112
|
}
|
|
93
|
-
/**
|
|
94
|
-
* The per-track operations a lazy {@link Consumer} delegates to the broadcast it came from.
|
|
95
|
-
*
|
|
96
|
-
* Implemented by `broadcast.Producer` / `broadcast.Consumer` (and the wire-layer subclasses
|
|
97
|
-
* that resolve them over the network), so a track handle holds a reference to its broadcast
|
|
98
|
-
* and calls methods on it rather than capturing a bag of callbacks.
|
|
99
|
-
*/
|
|
100
|
-
export interface Broadcast {
|
|
101
|
-
/** Open a live subscription to the named track. */
|
|
102
|
-
subscribe(name: string, options?: Subscription): Subscriber;
|
|
103
|
-
/** Resolve the named track's immutable info. */
|
|
104
|
-
resolveTrackInfo(name: string): Promise<Info>;
|
|
105
|
-
/** Fetch a single group of the named track by sequence. */
|
|
106
|
-
fetchGroup(name: string, sequence: number, options?: FetchGroupOptions): Promise<GroupConsumer>;
|
|
107
|
-
}
|
|
108
113
|
/**
|
|
109
114
|
* A lazy handle to a track on a consumed broadcast.
|
|
110
115
|
*
|
|
@@ -114,8 +119,15 @@ export declare class Consumer {
|
|
|
114
119
|
#private;
|
|
115
120
|
/** The track name. */
|
|
116
121
|
readonly name: string;
|
|
117
|
-
constructor(
|
|
118
|
-
/**
|
|
122
|
+
private constructor();
|
|
123
|
+
/**
|
|
124
|
+
* Open a live subscription to the track.
|
|
125
|
+
*
|
|
126
|
+
* The cursor starts at the group the subscription named (its floor), or 0.
|
|
127
|
+
* {@link Subscription.maxAge} is what asks for data: delivery skips everything above
|
|
128
|
+
* the floor that the budget convicts, so the default budget of zero delivers only the
|
|
129
|
+
* latest group and a larger one reaches back over what it can still use.
|
|
130
|
+
*/
|
|
119
131
|
subscribe(options?: Subscription): Subscriber;
|
|
120
132
|
/** Fetch the track's immutable publisher properties without subscribing. */
|
|
121
133
|
info(): Promise<Info>;
|
|
@@ -129,7 +141,7 @@ export declare class Consumer {
|
|
|
129
141
|
* subscription the publisher serves from it) gets an independent
|
|
130
142
|
* {@link Subscriber} that receives a full copy of the groups, each with its own
|
|
131
143
|
* read cursor. Groups are mirrored into every live subscriber and retained for the
|
|
132
|
-
* track's `
|
|
144
|
+
* track's `maxAge` window so a late subscriber replays the recent groups.
|
|
133
145
|
*
|
|
134
146
|
* Obtained from {@link Request.accept} (the wire asks the application for a track to
|
|
135
147
|
* serve) or constructed directly for an in-process track.
|
|
@@ -144,6 +156,13 @@ export declare class Producer {
|
|
|
144
156
|
* Rejects if the track is closed before the properties are known.
|
|
145
157
|
*/
|
|
146
158
|
info(): Promise<Info>;
|
|
159
|
+
/**
|
|
160
|
+
* Publisher priority from the committed {@link Info}, or 0 before {@link accept}.
|
|
161
|
+
*
|
|
162
|
+
* Higher is served first. Hang publishers set this from `Catalog.PRIORITY` so
|
|
163
|
+
* audio outranks video on the wire and in the bandwidth allocator.
|
|
164
|
+
*/
|
|
165
|
+
get priority(): number;
|
|
147
166
|
/**
|
|
148
167
|
* Settles once the track closes: `null` on a clean close, or the abort {@link Error}.
|
|
149
168
|
* Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.
|
|
@@ -156,7 +175,14 @@ export declare class Producer {
|
|
|
156
175
|
get subscription(): Getter<Subscription | undefined>;
|
|
157
176
|
/** Commit the immutable publisher properties, resolving {@link info}. Returns `this`. */
|
|
158
177
|
accept(info?: Partial<Info>): this;
|
|
159
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* An independent {@link Subscriber} reading this track's groups.
|
|
180
|
+
*
|
|
181
|
+
* Its cursor starts at the group the subscription named (its floor), or 0.
|
|
182
|
+
* {@link Subscription.maxAge} is what asks for data: delivery skips everything above
|
|
183
|
+
* the floor that the budget convicts, so the default budget of zero delivers only the
|
|
184
|
+
* latest group and a larger one reaches back over what it can still use.
|
|
185
|
+
*/
|
|
160
186
|
subscribe(options?: Subscription): Subscriber;
|
|
161
187
|
/**
|
|
162
188
|
* Whether the track currently has any subscribers.
|
|
@@ -189,17 +215,17 @@ export declare class Producer {
|
|
|
189
215
|
* keep datagram payloads small (e.g. a single audio frame). Datagrams are never delivered
|
|
190
216
|
* over IETF moq-transport or stream-only transports (the WebSocket fallback). A payload over
|
|
191
217
|
* 65535 bytes (the QUIC datagram frame ceiling) throws. An origin publisher uses this; a
|
|
192
|
-
* relay preserving upstream numbering uses {@link
|
|
218
|
+
* relay preserving upstream numbering uses {@link insertDatagram}.
|
|
193
219
|
*/
|
|
194
220
|
appendDatagram(timestamp: Timestamp, payload: Uint8Array): number;
|
|
195
221
|
/**
|
|
196
|
-
*
|
|
222
|
+
* Insert a datagram with an explicit sequence number.
|
|
197
223
|
*
|
|
198
224
|
* Preserves the supplied sequence (advancing the shared counter if needed) so a relay can
|
|
199
225
|
* forward a datagram without renumbering it. The size limits of {@link appendDatagram}
|
|
200
226
|
* apply. Most origin publishers want {@link appendDatagram} instead.
|
|
201
227
|
*/
|
|
202
|
-
|
|
228
|
+
insertDatagram(sequence: number, timestamp: Timestamp, payload: Uint8Array): void;
|
|
203
229
|
/** Close the track and every subscriber, mirroring the abort to their groups. Idempotent. */
|
|
204
230
|
close(abort?: Error): void;
|
|
205
231
|
/** Append a frame as its own single-frame group. */
|
|
@@ -237,6 +263,13 @@ export declare class Subscriber {
|
|
|
237
263
|
get subscription(): Getter<Subscription | undefined>;
|
|
238
264
|
/** Return the latest group sequence observed on this track, if any. */
|
|
239
265
|
latest(): number | undefined;
|
|
266
|
+
/**
|
|
267
|
+
* The track's exclusive final boundary, known once the producer closes cleanly:
|
|
268
|
+
* one past the highest sequence produced, or 0 for a track that produced none.
|
|
269
|
+
* Groups and datagrams share the sequence namespace, so this can exceed
|
|
270
|
+
* `latest() + 1`. Undefined while the track is live or after an abort.
|
|
271
|
+
*/
|
|
272
|
+
final(): number | undefined;
|
|
240
273
|
/**
|
|
241
274
|
* The newest frame this track has produced, or `undefined` while it has none.
|
|
242
275
|
*
|
|
@@ -246,39 +279,33 @@ export declare class Subscriber {
|
|
|
246
279
|
* left can no longer say where the edge is.
|
|
247
280
|
*/
|
|
248
281
|
largest(): Location | undefined;
|
|
282
|
+
/** Limit subsequent reads to these groups and return this reader for chaining. */
|
|
283
|
+
withGroups(groups: Groups): this;
|
|
249
284
|
/**
|
|
250
|
-
*
|
|
251
|
-
* the
|
|
252
|
-
*
|
|
253
|
-
* Reads here do not consume anything this one would deliver, which is what lets a
|
|
254
|
-
* publisher read the cache alongside the cursor it is serving from. Resolving the track
|
|
255
|
-
* again through the broadcast would not do: a dynamic serve is one request per peer
|
|
256
|
-
* subscription, so that mints a second producer the application has to answer separately.
|
|
257
|
-
*
|
|
258
|
-
* @internal Wire layers only.
|
|
259
|
-
*/
|
|
260
|
-
fork(options?: Subscription): Subscriber;
|
|
261
|
-
/** Start this subscriber's local read cursor at `sequence`, without changing its wire request. */
|
|
262
|
-
startAt(sequence: number): void;
|
|
263
|
-
/**
|
|
264
|
-
* Cap {@link nextGroup} and {@link recvGroup} at `sequence` inclusively, or omit it to
|
|
265
|
-
* remove the cap. Groups above the cap remain buffered and become readable if the cap
|
|
266
|
-
* is raised. This local cursor does not change the subscription's wire request.
|
|
285
|
+
* Limit subsequent reads without rewinding read progress or changing the wire request.
|
|
286
|
+
* An omitted start preserves the current floor; an omitted end removes the cap.
|
|
287
|
+
* Raising the end makes unread buffered groups available again.
|
|
267
288
|
*/
|
|
268
|
-
|
|
289
|
+
setGroups(groups: Groups): void;
|
|
269
290
|
/** Close the track (optionally with an error), closing any pending groups. Idempotent. */
|
|
270
291
|
close(abort?: Error): void;
|
|
271
292
|
/**
|
|
272
293
|
* Receive every group on this track exactly once, as it becomes available.
|
|
273
294
|
*
|
|
274
295
|
* Groups may arrive out of order or with gaps due to network conditions; unlike
|
|
275
|
-
* {@link nextGroup}, one that arrives after a newer group was already returned
|
|
276
|
-
* still delivered. When several groups are buffered, the lowest sequence is
|
|
296
|
+
* {@link Ordered.nextGroup}, one that arrives after a newer group was already returned
|
|
297
|
+
* is still delivered. When several groups are buffered, the lowest sequence is
|
|
277
298
|
* returned first.
|
|
278
299
|
*
|
|
279
|
-
* Honors the
|
|
300
|
+
* Honors the range set by {@link setGroups}: a group
|
|
280
301
|
* beyond the cap stays buffered (not dropped) and is offered once the cap rises, even
|
|
281
302
|
* after a clean close, without blocking in-range groups that arrive behind it.
|
|
303
|
+
* A group whose presentation time is further behind the live edge than this
|
|
304
|
+
* subscriber's `maxAge` is skipped. The default of zero takes the live edge.
|
|
305
|
+
* The budget remains attached after return, so a pending frame read rejects if a stalled
|
|
306
|
+
* group becomes stale while newer data advances.
|
|
307
|
+
*
|
|
308
|
+
* The first call commits this track to arrival order: {@link ordered} throws afterwards.
|
|
282
309
|
*/
|
|
283
310
|
recvGroup(): Promise<GroupConsumer | undefined>;
|
|
284
311
|
/**
|
|
@@ -287,7 +314,7 @@ export declare class Subscriber {
|
|
|
287
314
|
*
|
|
288
315
|
* Returns `undefined` when nothing is deliverable right now, which is not by itself the
|
|
289
316
|
* end of the track: a group may still arrive, or one may be parked beyond the
|
|
290
|
-
* {@link
|
|
317
|
+
* {@link setGroups} cap. Use it to drain what the retained window already holds, where
|
|
291
318
|
* waiting for a sequence nothing will republish would park forever.
|
|
292
319
|
*/
|
|
293
320
|
tryRecvGroup(): GroupConsumer | undefined;
|
|
@@ -297,40 +324,102 @@ export declare class Subscriber {
|
|
|
297
324
|
* Datagrams are a separate best-effort channel from groups (see
|
|
298
325
|
* {@link Producer.appendDatagram}); they share only the sequence namespace. A consumer
|
|
299
326
|
* that falls too far behind silently loses the oldest datagrams. Read this alongside
|
|
300
|
-
* {@link recvGroup} (e.g. in a separate loop) to receive both channels concurrently.
|
|
301
|
-
* a datagram
|
|
327
|
+
* {@link recvGroup} (e.g. in a separate loop) to receive both channels concurrently.
|
|
328
|
+
* The two cursors are independent: a datagram never moves the group cursor.
|
|
302
329
|
*/
|
|
303
330
|
recvDatagram(): Promise<Datagram | undefined>;
|
|
304
331
|
/**
|
|
305
|
-
*
|
|
332
|
+
* Read this track's groups in sequence order instead of arrival order.
|
|
333
|
+
*
|
|
334
|
+
* Both cursors draw from the same buffer, so a track is read one way or the other: this
|
|
335
|
+
* hands the subscription to the returned {@link Ordered} and leaves this handle inert.
|
|
336
|
+
* {@link recvGroup} and {@link recvDatagram} throw afterwards. Throws once a
|
|
337
|
+
* {@link recvGroup} call has already committed the track to arrival order.
|
|
306
338
|
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
339
|
+
* Datagrams come along: they are a separate cursor either way, so the choice of group
|
|
340
|
+
* order says nothing about them, and reading them commits nothing.
|
|
309
341
|
*/
|
|
310
|
-
|
|
342
|
+
ordered(): Ordered;
|
|
311
343
|
/**
|
|
312
|
-
*
|
|
313
|
-
*
|
|
344
|
+
* Update this subscription's options (e.g. priority), triggering a SUBSCRIBE_UPDATE to the
|
|
345
|
+
* publisher. Mirrors the Rust `Subscriber::update`.
|
|
346
|
+
*/
|
|
347
|
+
update(options: Subscription): void;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* A {@link Subscriber} that reads groups in sequence order.
|
|
351
|
+
*
|
|
352
|
+
* Created by {@link Subscriber.ordered}, which takes the subscription over: the two
|
|
353
|
+
* cursors draw from one buffer, so a track is read one way or the other and never both.
|
|
354
|
+
* Every group this returns has a higher sequence than the last, so a late arrival is
|
|
355
|
+
* skipped rather than delivered out of turn.
|
|
356
|
+
*
|
|
357
|
+
* `maxAge` applies as this cursor reads, exactly as it does on the arrival cursor: a
|
|
358
|
+
* group is skipped once its reach, where its immediate successor begins, is that far
|
|
359
|
+
* behind the newest frame on the track. Nothing weaker convicts it, since the reach is
|
|
360
|
+
* the only proof that every frame it could still hold is past the budget, so a backlog
|
|
361
|
+
* inside the budget is still delivered whole, as a burst in order. The budget follows a
|
|
362
|
+
* group already handed out too: a stalled group's pending frame read rejects once newer
|
|
363
|
+
* content has pulled that far ahead.
|
|
364
|
+
*/
|
|
365
|
+
export declare class Ordered {
|
|
366
|
+
#private;
|
|
367
|
+
/** The track name. */
|
|
368
|
+
readonly name: string;
|
|
369
|
+
private constructor();
|
|
370
|
+
/** Resolve this track's immutable publisher properties; see {@link Subscriber.info}. */
|
|
371
|
+
info(): Promise<Info>;
|
|
372
|
+
/** Settles once the track closes; see {@link Producer.closed}. */
|
|
373
|
+
get closed(): GetPromise<Error | null>;
|
|
374
|
+
/** This subscriber's current options, including defaults and the last {@link update}. */
|
|
375
|
+
get subscription(): Getter<Subscription | undefined>;
|
|
376
|
+
/** The latest group sequence observed on this track, if any. */
|
|
377
|
+
latest(): number | undefined;
|
|
378
|
+
/** The track's exclusive final boundary; see {@link Subscriber.final}. */
|
|
379
|
+
final(): number | undefined;
|
|
380
|
+
/** Limit subsequent reads to these groups and return this reader for chaining. */
|
|
381
|
+
withGroups(groups: Groups): this;
|
|
382
|
+
/** Limit subsequent reads to these groups; see {@link Subscriber.setGroups}. */
|
|
383
|
+
setGroups(groups: Groups): void;
|
|
384
|
+
/** Update this subscription's options; see {@link Subscriber.update}. */
|
|
385
|
+
update(options: Subscription): void;
|
|
386
|
+
/** Close the track (optionally with an error), closing any pending groups. Idempotent. */
|
|
387
|
+
close(abort?: Error): void;
|
|
388
|
+
/**
|
|
389
|
+
* Return the next group with a strictly-greater sequence number than the last returned.
|
|
390
|
+
*
|
|
391
|
+
* Late arrivals (sequence at or below the last returned) are silently skipped, as is a
|
|
392
|
+
* group whose every frame is further behind the live edge than `maxAge` (the default of
|
|
393
|
+
* zero keeps only what nothing newer has superseded). Honors the bounds set by
|
|
394
|
+
* {@link setGroups}.
|
|
314
395
|
*/
|
|
315
|
-
|
|
396
|
+
nextGroup(): Promise<GroupConsumer | undefined>;
|
|
316
397
|
/**
|
|
317
|
-
*
|
|
398
|
+
* Read the next frame across groups, in sequence order, with its group and frame numbers.
|
|
399
|
+
*
|
|
400
|
+
* Rides the same cursor as {@link nextGroup} and shares this handle's contract: a
|
|
401
|
+
* buffered backlog is drained in full up to the point `maxAge` proves it useless.
|
|
318
402
|
* Treat the returned frame bytes as read-only; they are shared with other consumers.
|
|
319
403
|
*/
|
|
320
|
-
|
|
404
|
+
readFrame(): Promise<({
|
|
321
405
|
group: number;
|
|
322
406
|
frame: number;
|
|
323
407
|
} & Frame) | undefined>;
|
|
324
|
-
/**
|
|
408
|
+
/** Read the next frame and decode it as a UTF-8 string. */
|
|
325
409
|
readString(): Promise<string | undefined>;
|
|
326
|
-
/**
|
|
410
|
+
/** Read the next frame and parse it as JSON. */
|
|
327
411
|
readJson(): Promise<unknown | undefined>;
|
|
328
|
-
/**
|
|
412
|
+
/** Read the next frame and decode it as a one-byte boolean, throwing on a malformed frame. */
|
|
329
413
|
readBool(): Promise<boolean | undefined>;
|
|
330
414
|
/**
|
|
331
|
-
*
|
|
332
|
-
*
|
|
415
|
+
* Receive the next datagram in arrival order.
|
|
416
|
+
*
|
|
417
|
+
* Datagrams are a separate best-effort channel from groups (see
|
|
418
|
+
* {@link Producer.appendDatagram}); they share only the sequence namespace, and
|
|
419
|
+
* neither cursor moves the other. Unordered by construction, so this behaves
|
|
420
|
+
* identically on either handle; it is here so a track carrying both channels needs
|
|
421
|
+
* one subscription rather than two.
|
|
333
422
|
*/
|
|
334
|
-
|
|
423
|
+
recvDatagram(): Promise<Datagram | undefined>;
|
|
335
424
|
}
|
|
336
425
|
//# sourceMappingURL=track.d.ts.map
|
package/track.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,MAAM,EAAgB,MAAM,cAAc,CAAC;AAC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