@caprid/relay 0.4.0 → 0.5.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 +4 -3
- package/dist/connect.d.ts +40 -5
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +19 -3
- package/dist/connect.js.map +1 -1
- package/dist/discovery.d.ts +38 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +273 -0
- package/dist/discovery.js.map +1 -0
- package/dist/frame-writer.d.ts +1 -2
- package/dist/frame-writer.d.ts.map +1 -1
- package/dist/frame-writer.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/media-track-properties.js +1 -1
- package/dist/media-track-properties.js.map +1 -1
- package/dist/media.d.ts +4 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +4 -1
- package/dist/media.js.map +1 -1
- package/dist/namespace-events.d.ts +32 -3
- package/dist/namespace-events.d.ts.map +1 -1
- package/dist/namespace-events.js +82 -7
- package/dist/namespace-events.js.map +1 -1
- package/dist/node.d.ts +13 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +17 -0
- package/dist/node.js.map +1 -1
- package/dist/presence.d.ts +155 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +485 -0
- package/dist/presence.js.map +1 -0
- package/dist/publish.d.ts +61 -7
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +208 -87
- package/dist/publish.js.map +1 -1
- package/dist/publishing-roots.d.ts +189 -0
- package/dist/publishing-roots.d.ts.map +1 -0
- package/dist/publishing-roots.js +426 -0
- package/dist/publishing-roots.js.map +1 -0
- package/dist/relay-session.d.ts +31 -0
- package/dist/relay-session.d.ts.map +1 -0
- package/dist/relay-session.js +64 -0
- package/dist/relay-session.js.map +1 -0
- package/dist/subscription-events.d.ts +5 -2
- package/dist/subscription-events.d.ts.map +1 -1
- package/dist/subscription-events.js +20 -6
- package/dist/subscription-events.js.map +1 -1
- package/dist/supervised-publisher.d.ts.map +1 -1
- package/dist/supervised-publisher.js +42 -808
- package/dist/supervised-publisher.js.map +1 -1
- package/dist/supervised-relay.d.ts +112 -0
- package/dist/supervised-relay.d.ts.map +1 -0
- package/dist/supervised-relay.js +80 -0
- package/dist/supervised-relay.js.map +1 -0
- package/dist/supervised-subscriber.d.ts +66 -4
- package/dist/supervised-subscriber.d.ts.map +1 -1
- package/dist/supervised-subscriber.js +244 -557
- package/dist/supervised-subscriber.js.map +1 -1
- package/dist/supervised-track.d.ts +63 -0
- package/dist/supervised-track.d.ts.map +1 -0
- package/dist/supervised-track.js +430 -0
- package/dist/supervised-track.js.map +1 -0
- package/dist/supervisor.d.ts +92 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +720 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/switchable.d.ts +1 -1
- package/dist/write-slot.d.ts +5 -0
- package/dist/write-slot.d.ts.map +1 -1
- package/dist/write-slot.js +3 -0
- package/dist/write-slot.js.map +1 -1
- package/package.json +8 -7
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,MAAM,EACN,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,mBAAmB,EACnB,6BAA6B,EAC7B,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EA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,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACjG,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAChH,OAAO,EACL,iCAAiC,EACjC,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,iCAAiC,EACjC,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,YAAY,EACV,6BAA6B,EAC7B,qBAAqB,EACrB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,YAAY,EACV,kCAAkC,EAClC,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACZ,aAAa,GACd,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export { connectRelaySubscriber, webTransport } from './connect.js';
|
|
2
2
|
export { RelayError } from './errors.js';
|
|
3
|
+
export { SNAPSHOT_LIMIT_MS, SNAPSHOT_QUIET_MS, } from './namespace-events.js';
|
|
3
4
|
export { readJSON, readText } from './payload.js';
|
|
4
5
|
export { connectRelayPublisher } from './publish.js';
|
|
6
|
+
export { connectRelay } from './relay-session.js';
|
|
5
7
|
export { DEFAULT_ENDPOINT, roomEndpoint } from './room-endpoint.js';
|
|
6
8
|
export { SubscriptionConnectionClosedError, SubscriptionOverflowError, SubscriptionRequestError, } from './subscription-events.js';
|
|
7
9
|
export { connectSupervisedPublisher } from './supervised-publisher.js';
|
|
10
|
+
export { connectSupervisedRelay } from './supervised-relay.js';
|
|
8
11
|
export { connectSupervisedSubscriber } from './supervised-subscriber.js';
|
|
9
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,UAAU,EAA6C,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,UAAU,EAA6C,MAAM,aAAa,CAAC;AACpF,OAAO,EAIL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAUlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AASrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGpE,OAAO,EACL,iCAAiC,EACjC,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAMvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAU/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_TIMEOUT_MS } from './connect-session.js';
|
|
2
2
|
import { SUBGROUP_DELIVERY_TIMEOUT } from './delivery-timeouts.js';
|
|
3
3
|
import { DEFAULT_PUBLISHER_PRIORITY, MAX_DEFAULT_PUBLISHER_PRIORITY } from './validation.js';
|
|
4
|
-
/** Audio's default subgroup timeout: measured under a 2 s uplink stall to sjc
|
|
4
|
+
/** Audio's default subgroup timeout: measured under a 2 s uplink stall to sjc. */
|
|
5
5
|
const AUDIO_SUBGROUP_TIMEOUT_US = 500_000;
|
|
6
6
|
/** Default Publisher Priority per kind, lower being more urgent: audio ahead of video, as Huddle sets them by hand. */
|
|
7
7
|
const PUBLISHER_PRIORITY = { audio: 16, video: 96 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-track-properties.js","sourceRoot":"","sources":["../src/media-track-properties.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,0BAA0B,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAuB7F,
|
|
1
|
+
{"version":3,"file":"media-track-properties.js","sourceRoot":"","sources":["../src/media-track-properties.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,0BAA0B,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAuB7F,kFAAkF;AAClF,MAAM,yBAAyB,GAAG,OAAO,CAAC;AAC1C,uHAAuH;AACvH,MAAM,kBAAkB,GAAwC,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AACzF,0GAA0G;AAC1G,MAAM,mBAAmB,GAAwC,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAC1F,sDAAsD;AACtD,MAAM,uBAAu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AAI,UAAU,CAAC,GAAG,IAAI,0CAA0C,cAAc,eAAe,CAAC,CAAC;IACvG,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,2EAA2E;AAC3E,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC,CAAC;IACzF,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,8BAA8B,EAAE,CAAC;QACpF,MAAM,IAAI,UAAU,CAAC,kDAAkD,8BAA8B,EAAE,CAAC,CAAC;IAC3G,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,oEAAoE;AACpE,SAAS,0BAA0B,CAAC,KAAc;IAChD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,qCAAqC,CAAC,CAAC;IAC1F,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,uBAAuB,EAAE,CAAC;QAC7E,MAAM,IAAI,UAAU,CAAC,mDAAmD,uBAAuB,EAAE,CAAC,CAAC;IACrG,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/media.d.ts
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* frame reader reads a subscription as frames in decode order, and a latest-value reader reads a latest-wins track as its
|
|
7
7
|
* newest values. They know no format: a frame carries its own object
|
|
8
8
|
* properties, a document is bytes, and the reader drives a sequencer it is given, so they pair with `@caprid/moq-media`'s
|
|
9
|
-
* LOC and MSF helpers and its `FrameSequencer` without depending on them.
|
|
9
|
+
* LOC and MSF helpers and its `FrameSequencer` without depending on them. Presence is a JSON convention of its own:
|
|
10
|
+
* `publishPresence` serves a participant's document with a heartbeat, and `createPresenceView` follows everyone's under
|
|
11
|
+
* a prefix as a live roster.
|
|
10
12
|
*
|
|
11
13
|
* ```ts
|
|
12
14
|
* import { createCatalogService, createFrameWriter, mediaTrackProperties } from '@caprid/relay/media';
|
|
@@ -27,5 +29,6 @@ export { createFrameReader, type FrameReader, type FrameReaderOptions, type Fram
|
|
|
27
29
|
export { createFrameWriter, type Frame, type FrameGrouping, type FrameOutcome, type FrameOutcomeKind, type FrameWriter, type FrameWriterOptions, } from './frame-writer.js';
|
|
28
30
|
export { createLatestValueReader, type LatestValueReader, type LatestValueReaderOptions, type LatestValueStats, } from './latest-value-reader.js';
|
|
29
31
|
export { type MediaKind, type MediaTrackPropertiesOptions, mediaSubscribeParameters, mediaTrackProperties, } from './media-track-properties.js';
|
|
32
|
+
export { createPresenceView, PRESENCE_HEARTBEAT_MS, PRESENCE_TRACK, type PresenceChange, type PresenceMember, type PresencePublisher, type PresenceView, type PresenceViewHandlers, type PresenceViewOptions, type PublishPresenceOptions, publishPresence, } from './presence.js';
|
|
30
33
|
export { createReplaceableTrack, type ReplaceableTrack, type ReplaceableTrackCatalog, type ReplaceableTrackOptions, type TrackReplacement, } from './replaceable-track.js';
|
|
31
34
|
//# sourceMappingURL=media.d.ts.map
|
package/dist/media.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,iBAAiB,EACjB,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,uBAAuB,EACvB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,SAAS,EACd,KAAK,2BAA2B,EAChC,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAC"}
|
package/dist/media.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* frame reader reads a subscription as frames in decode order, and a latest-value reader reads a latest-wins track as its
|
|
7
7
|
* newest values. They know no format: a frame carries its own object
|
|
8
8
|
* properties, a document is bytes, and the reader drives a sequencer it is given, so they pair with `@caprid/moq-media`'s
|
|
9
|
-
* LOC and MSF helpers and its `FrameSequencer` without depending on them.
|
|
9
|
+
* LOC and MSF helpers and its `FrameSequencer` without depending on them. Presence is a JSON convention of its own:
|
|
10
|
+
* `publishPresence` serves a participant's document with a heartbeat, and `createPresenceView` follows everyone's under
|
|
11
|
+
* a prefix as a live roster.
|
|
10
12
|
*
|
|
11
13
|
* ```ts
|
|
12
14
|
* import { createCatalogService, createFrameWriter, mediaTrackProperties } from '@caprid/relay/media';
|
|
@@ -27,5 +29,6 @@ export { createFrameReader, } from './frame-reader.js';
|
|
|
27
29
|
export { createFrameWriter, } from './frame-writer.js';
|
|
28
30
|
export { createLatestValueReader, } from './latest-value-reader.js';
|
|
29
31
|
export { mediaSubscribeParameters, mediaTrackProperties, } from './media-track-properties.js';
|
|
32
|
+
export { createPresenceView, PRESENCE_HEARTBEAT_MS, PRESENCE_TRACK, publishPresence, } from './presence.js';
|
|
30
33
|
export { createReplaceableTrack, } from './replaceable-track.js';
|
|
31
34
|
//# sourceMappingURL=media.js.map
|
package/dist/media.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAGL,oBAAoB,EACpB,qBAAqB,GAItB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,iBAAiB,GAIlB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,iBAAiB,GAOlB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,uBAAuB,GAIxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAGL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EAQd,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,GAKvB,MAAM,wBAAwB,CAAC"}
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { type MoqtSession } from '@caprid/moq-core';
|
|
9
9
|
import { type SubscriptionEventOptions } from './subscription-events.js';
|
|
10
|
-
/** One change in which namespaces under the prefix are announced. */
|
|
11
|
-
export
|
|
10
|
+
/** One change in which namespaces under the prefix are announced, or the end of the relay's initial snapshot. */
|
|
11
|
+
export type NamespaceEvent = {
|
|
12
12
|
/**
|
|
13
13
|
* `announced`: a publisher announced the namespace, or it was already announced when the request
|
|
14
14
|
* was accepted. `unannounced`: its announce was withdrawn. Each namespace alternates between the
|
|
@@ -17,7 +17,36 @@ export interface NamespaceEvent {
|
|
|
17
17
|
type: 'announced' | 'unannounced';
|
|
18
18
|
/** The full namespace: the prefix's fields followed by the rest, without splitting or joining. */
|
|
19
19
|
namespace: string[];
|
|
20
|
-
}
|
|
20
|
+
} | {
|
|
21
|
+
/**
|
|
22
|
+
* Every namespace announced when the relay accepted the request has been yielded: an application that tracks
|
|
23
|
+
* the announced set now holds the relay's view, and an empty set means nothing is announced. Yielded once, before
|
|
24
|
+
* any later change, and never once the request has ended. With MoQ Active Count negotiated it follows the
|
|
25
|
+
* NAMESPACE messages the relay counted (at once on a count of 0). Otherwise it is the SDK's estimate: the relay
|
|
26
|
+
* accepted the request, then {@link SNAPSHOT_QUIET_MS} passed without an entry, and never later than
|
|
27
|
+
* {@link SNAPSHOT_LIMIT_MS} after the relay accepted it.
|
|
28
|
+
*/
|
|
29
|
+
type: 'loaded';
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Without MoQ Active Count, how long the request's stream stays quiet after the relay accepts it before the relay's
|
|
33
|
+
* snapshot counts as loaded. Each entry restarts it, so an empty prefix loads this long after acceptance. Provisional:
|
|
34
|
+
* moq-relay 0.17.x wrote 60 entries within 0.94 ms of REQUEST_OK, cross-relay, a 50x margin (2026-11-03,
|
|
35
|
+
* https://github.com/muxinc/relay-sdks/issues/422#issuecomment-6599550554).
|
|
36
|
+
*/
|
|
37
|
+
export declare const SNAPSHOT_QUIET_MS = 50;
|
|
38
|
+
/** Without MoQ Active Count, the latest `loaded` comes after the relay accepts, so a busy prefix still loads. */
|
|
39
|
+
export declare const SNAPSHOT_LIMIT_MS = 1000;
|
|
40
|
+
/**
|
|
41
|
+
* Whether `event` is one of the withdrawals a clean end yields, not one the relay sent. The supervised subscriber's
|
|
42
|
+
* discovery reads them as the request's end, so a narrower root it moves keeps what it saw.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isWithdrawnByEnd(event: NamespaceEvent): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the request's stream has failed and its ending waits out the closure grace: nothing more arrives. The
|
|
47
|
+
* supervised subscriber's discovery reads it so a publishing root's 100 ms does not run out on a stream that is gone.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isStopped(events: NamespaceEvents): boolean;
|
|
21
50
|
/** Options for `namespaceEvents`: the prefix, the iterator's queue bound and its own cancellation. */
|
|
22
51
|
export interface NamespaceEventOptions extends SubscriptionEventOptions {
|
|
23
52
|
/** Namespace prefix to discover, matched field by field. Same rules as a namespace. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace-events.d.ts","sourceRoot":"","sources":["../src/namespace-events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAmB,KAAK,WAAW,EAAyC,MAAM,kBAAkB,CAAC;AAG5G,OAAO,EAA8C,KAAK,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAErH,
|
|
1
|
+
{"version":3,"file":"namespace-events.d.ts","sourceRoot":"","sources":["../src/namespace-events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAmB,KAAK,WAAW,EAAyC,MAAM,kBAAkB,CAAC;AAG5G,OAAO,EAA8C,KAAK,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAErH,iHAAiH;AACjH,MAAM,MAAM,cAAc,GACtB;IACE;;;;OAIG;IACH,IAAI,EAAE,WAAW,GAAG,aAAa,CAAC;IAClC,kGAAkG;IAClG,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,GACD;IACE;;;;;;;OAOG;IACH,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEN;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,iHAAiH;AACjH,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AAIvC;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAE/D;AAID;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAE1D;AAQD,sGAAsG;AACtG,MAAM,WAAW,qBAAsB,SAAQ,wBAAwB;IACrE,uFAAuF;IACvF,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED,0FAA0F;AAC1F,MAAM,WAAW,eAAgB,SAAQ,qBAAqB,CAAC,cAAc,CAAC;IAC5E,yEAAyE;IACzE,KAAK,IAAI,IAAI,CAAC;IACd,+GAA+G;IAC/G,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC;CACnD;AAED,4DAA4D;AAC5D,MAAM,WAAW,4BAA4B;IAC3C,8CAA8C;IAC9C,kBAAkB,EAAE,WAAW,CAAC,oBAAoB,CAAC,CAAC;IACtD,oFAAoF;IACpF,aAAa,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC/D,wFAAwF;IACxF,QAAQ,EAAE,GAAG,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;CAClC;AAsBD,qFAAqF;AACrF,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,4BAA4B,EAClC,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,EAAE,wBAAwB,GAChC,eAAe,CAMjB"}
|
package/dist/namespace-events.js
CHANGED
|
@@ -9,6 +9,31 @@ import { isStreamFailure, REQUEST_ERROR_CODE } from '@caprid/moq-core';
|
|
|
9
9
|
import { RelayError } from './errors.js';
|
|
10
10
|
import { CLOSURE_GRACE_MS, SubscriptionConnectionClosedError, SubscriptionRequestError } from './subscription.js';
|
|
11
11
|
import { createBoundedEvents } from './subscription-events.js';
|
|
12
|
+
/**
|
|
13
|
+
* Without MoQ Active Count, how long the request's stream stays quiet after the relay accepts it before the relay's
|
|
14
|
+
* snapshot counts as loaded. Each entry restarts it, so an empty prefix loads this long after acceptance. Provisional:
|
|
15
|
+
* moq-relay 0.17.x wrote 60 entries within 0.94 ms of REQUEST_OK, cross-relay, a 50x margin (2026-11-03,
|
|
16
|
+
* https://github.com/muxinc/relay-sdks/issues/422#issuecomment-6599550554).
|
|
17
|
+
*/
|
|
18
|
+
export const SNAPSHOT_QUIET_MS = 50;
|
|
19
|
+
/** Without MoQ Active Count, the latest `loaded` comes after the relay accepts, so a busy prefix still loads. */
|
|
20
|
+
export const SNAPSHOT_LIMIT_MS = 1_000;
|
|
21
|
+
const withdrawnByEnd = new WeakSet();
|
|
22
|
+
/**
|
|
23
|
+
* Whether `event` is one of the withdrawals a clean end yields, not one the relay sent. The supervised subscriber's
|
|
24
|
+
* discovery reads them as the request's end, so a narrower root it moves keeps what it saw.
|
|
25
|
+
*/
|
|
26
|
+
export function isWithdrawnByEnd(event) {
|
|
27
|
+
return withdrawnByEnd.has(event);
|
|
28
|
+
}
|
|
29
|
+
const stopped = new WeakSet();
|
|
30
|
+
/**
|
|
31
|
+
* Whether the request's stream has failed and its ending waits out the closure grace: nothing more arrives. The
|
|
32
|
+
* supervised subscriber's discovery reads it so a publishing root's 100 ms does not run out on a stream that is gone.
|
|
33
|
+
*/
|
|
34
|
+
export function isStopped(events) {
|
|
35
|
+
return stopped.has(events);
|
|
36
|
+
}
|
|
12
37
|
/**
|
|
13
38
|
* Hold `prefix` for one request, or refuse it when it overlaps one already held: draft-22 §9.15 has a relay answer an
|
|
14
39
|
* overlapping SUBSCRIBE_NAMESPACE on the same session with PREFIX_OVERLAP. moq-relay 0.17.0 does not, so the SDK
|
|
@@ -26,9 +51,10 @@ function claimPrefix(prefixes, prefix) {
|
|
|
26
51
|
}
|
|
27
52
|
/** Open the iterator over `prefix`, whose fields the caller has already admitted. */
|
|
28
53
|
export function createNamespaceEvents(deps, prefix, options) {
|
|
29
|
-
|
|
54
|
+
const events = createBoundedEvents((sink) => openNamespaceRequest(deps, prefix, sink, () => stopped.add(events)), options);
|
|
55
|
+
return events;
|
|
30
56
|
}
|
|
31
|
-
function openNamespaceRequest(deps, prefix, sink) {
|
|
57
|
+
function openNamespaceRequest(deps, prefix, sink, onStopped) {
|
|
32
58
|
let ended = false;
|
|
33
59
|
let core;
|
|
34
60
|
let removeClosed = () => { };
|
|
@@ -36,6 +62,27 @@ function openNamespaceRequest(deps, prefix, sink) {
|
|
|
36
62
|
const releasePrefix = claimPrefix(deps.prefixes, prefix);
|
|
37
63
|
// Keyed by the suffix's JSON: a field may hold any character, a separator could collide.
|
|
38
64
|
const announced = new Set();
|
|
65
|
+
let snapshot = { kind: 'unanswered' };
|
|
66
|
+
const stopTimers = () => {
|
|
67
|
+
if (snapshot.kind !== 'quiet')
|
|
68
|
+
return;
|
|
69
|
+
clearTimeout(snapshot.quiet);
|
|
70
|
+
clearTimeout(snapshot.limit);
|
|
71
|
+
};
|
|
72
|
+
const load = () => {
|
|
73
|
+
if (ended || snapshot.kind === 'loaded')
|
|
74
|
+
return;
|
|
75
|
+
stopTimers();
|
|
76
|
+
snapshot = { kind: 'loaded' };
|
|
77
|
+
// It comes once per request, so it takes no capacity and a snapshot that fills the queue still loads.
|
|
78
|
+
sink.event({ type: 'loaded' }, false);
|
|
79
|
+
};
|
|
80
|
+
const heard = () => {
|
|
81
|
+
if (snapshot.kind !== 'quiet')
|
|
82
|
+
return;
|
|
83
|
+
clearTimeout(snapshot.quiet);
|
|
84
|
+
snapshot.quiet = setTimeout(load, SNAPSHOT_QUIET_MS);
|
|
85
|
+
};
|
|
39
86
|
const finish = (error) => {
|
|
40
87
|
if (ended)
|
|
41
88
|
return;
|
|
@@ -43,6 +90,7 @@ function openNamespaceRequest(deps, prefix, sink) {
|
|
|
43
90
|
releasePrefix();
|
|
44
91
|
removeClosed();
|
|
45
92
|
cancelGrace();
|
|
93
|
+
stopTimers();
|
|
46
94
|
core?.cancel(error);
|
|
47
95
|
// A clean end keeps what is queued: the withdrawals the core reports for it come just before.
|
|
48
96
|
if (error === undefined)
|
|
@@ -61,10 +109,11 @@ function openNamespaceRequest(deps, prefix, sink) {
|
|
|
61
109
|
queueMicrotask(reject);
|
|
62
110
|
return;
|
|
63
111
|
}
|
|
112
|
+
onStopped();
|
|
64
113
|
const grace = setTimeout(reject, CLOSURE_GRACE_MS);
|
|
65
114
|
cancelGrace = () => clearTimeout(grace);
|
|
66
115
|
};
|
|
67
|
-
const change = (type, suffix) => {
|
|
116
|
+
const change = (type, suffix, byEnd = false) => {
|
|
68
117
|
if (ended)
|
|
69
118
|
return;
|
|
70
119
|
const key = JSON.stringify(suffix);
|
|
@@ -72,19 +121,45 @@ function openNamespaceRequest(deps, prefix, sink) {
|
|
|
72
121
|
return;
|
|
73
122
|
if (type === 'announced')
|
|
74
123
|
announced.add(key);
|
|
75
|
-
|
|
124
|
+
const event = { type, namespace: [...prefix, ...suffix] };
|
|
125
|
+
if (byEnd)
|
|
126
|
+
withdrawnByEnd.add(event);
|
|
127
|
+
sink.event(event);
|
|
76
128
|
};
|
|
77
129
|
removeClosed = deps.observeClosed((error) => finish(new SubscriptionConnectionClosedError(error)));
|
|
78
130
|
if (!ended) {
|
|
79
131
|
try {
|
|
80
132
|
core = deps.subscribeNamespace({ trackNamespacePrefix: prefix }, {
|
|
81
|
-
|
|
82
|
-
|
|
133
|
+
onOk: ({ activeCount }) => {
|
|
134
|
+
snapshot =
|
|
135
|
+
activeCount === undefined
|
|
136
|
+
? {
|
|
137
|
+
kind: 'quiet',
|
|
138
|
+
quiet: setTimeout(load, SNAPSHOT_QUIET_MS),
|
|
139
|
+
limit: setTimeout(load, SNAPSHOT_LIMIT_MS),
|
|
140
|
+
}
|
|
141
|
+
: { kind: 'counted' };
|
|
142
|
+
},
|
|
143
|
+
onSynced: load,
|
|
144
|
+
onNamespace: (suffix) => {
|
|
145
|
+
change('announced', suffix);
|
|
146
|
+
heard();
|
|
147
|
+
},
|
|
148
|
+
onNamespaceDone: (suffix, { requestEnded }) => {
|
|
149
|
+
if (requestEnded)
|
|
150
|
+
return;
|
|
151
|
+
change('unannounced', suffix);
|
|
152
|
+
heard();
|
|
153
|
+
},
|
|
83
154
|
onError: (error) => fail(error, isStreamFailure(error) && error.errorCode !== REQUEST_ERROR_CODE.TIMEOUT),
|
|
84
155
|
onEnd: ({ error }) => {
|
|
156
|
+
stopTimers();
|
|
85
157
|
// A finished stream is the relay ending the request on purpose; a failed one may be a lost connection.
|
|
86
|
-
if (error === undefined)
|
|
158
|
+
if (error === undefined) {
|
|
159
|
+
for (const key of [...announced])
|
|
160
|
+
change('unannounced', JSON.parse(key), true);
|
|
87
161
|
finish();
|
|
162
|
+
}
|
|
88
163
|
else {
|
|
89
164
|
const reason = error instanceof Error ? error.message : 'namespace request stream failed';
|
|
90
165
|
fail({ errorCode: REQUEST_ERROR_CODE.INTERNAL_ERROR, retryInterval: 0, reason }, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace-events.js","sourceRoot":"","sources":["../src/namespace-events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,eAAe,EAAoB,kBAAkB,EAAqB,MAAM,kBAAkB,CAAC;AAC5G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,iCAAiC,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClH,OAAO,EAAyB,mBAAmB,EAAiC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"namespace-events.js","sourceRoot":"","sources":["../src/namespace-events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,eAAe,EAAoB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CAAC;aACF,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,4FAA4F;YAC5F,KAAK,GAAG,IAAI,CAAC;YACb,aAAa,EAAE,CAAC;YAChB,YAAY,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;QACD,IAAI,KAAK;YAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AAChD,CAAC"}
|
package/dist/node.d.ts
CHANGED
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { type ConnectRelayOptions, type ConnectRelaySubscriberOptions, type RelaySubscriber, type RelayTransportFactory } from './connect.js';
|
|
16
16
|
import { type ConnectRelayPublisherOptions, type RelayPublisher } from './publish.js';
|
|
17
|
+
import { type ConnectRelaySessionOptions, type RelaySession } from './relay-session.js';
|
|
17
18
|
import { type ConnectSupervisedPublisherOptions, type SupervisedPublisher } from './supervised-publisher.js';
|
|
19
|
+
import { type ConnectSupervisedRelayOptions, type SupervisedRelay } from './supervised-relay.js';
|
|
18
20
|
import { type ConnectSupervisedSubscriberOptions, type SupervisedSubscriber } from './supervised-subscriber.js';
|
|
19
21
|
export * from './index.js';
|
|
20
22
|
/** A certificate hash the server's end-entity certificate must match, in the W3C WebTransport shape. */
|
|
@@ -62,6 +64,12 @@ export declare function connectRelaySubscriber(options: RelayNodeOptions<Connect
|
|
|
62
64
|
* it closes.
|
|
63
65
|
*/
|
|
64
66
|
export declare function connectRelayPublisher(options: RelayNodeOptions<ConnectRelayPublisherOptions>): Promise<RelayPublisher>;
|
|
67
|
+
/**
|
|
68
|
+
* Open one Relay connection that publishes and subscribes, as `@caprid/relay`'s `connectRelay` does, over native QUIC
|
|
69
|
+
* through `@caprid/relay-quic` unless `createTransport` is given. An open connection keeps the process alive until it
|
|
70
|
+
* closes.
|
|
71
|
+
*/
|
|
72
|
+
export declare function connectRelay(options: RelayNodeOptions<ConnectRelaySessionOptions>): Promise<RelaySession>;
|
|
65
73
|
/**
|
|
66
74
|
* Open a subscriber that reconnects, as `@caprid/relay`'s `connectSupervisedSubscriber` does, with every connection over
|
|
67
75
|
* native QUIC through `@caprid/relay-quic` unless `createTransport` is given.
|
|
@@ -72,4 +80,9 @@ export declare function connectSupervisedSubscriber(options: RelayNodeOptions<Co
|
|
|
72
80
|
* native QUIC through `@caprid/relay-quic` unless `createTransport` is given.
|
|
73
81
|
*/
|
|
74
82
|
export declare function connectSupervisedPublisher(options: RelayNodeOptions<ConnectSupervisedPublisherOptions>): Promise<SupervisedPublisher>;
|
|
83
|
+
/**
|
|
84
|
+
* Open one connection that publishes, subscribes and reconnects, as `@caprid/relay`'s `connectSupervisedRelay` does,
|
|
85
|
+
* with every connection over native QUIC through `@caprid/relay-quic` unless `createTransport` is given.
|
|
86
|
+
*/
|
|
87
|
+
export declare function connectSupervisedRelay(options: RelayNodeOptions<ConnectSupervisedRelayOptions>): Promise<SupervisedRelay>;
|
|
75
88
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,6BAA6B,EAElC,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,KAAK,4BAA4B,EAEjC,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,6BAA6B,EAElC,KAAK,eAAe,EACpB,KAAK,qBA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,sBAAsB,CAC1C,OAAO,EAAE,gBAAgB,CAAC,6BAA6B,CAAC,GACvD,OAAO,CAAC,eAAe,CAAC,CAE1B;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,gBAAgB,CAAC,4BAA4B,CAAC,GACtD,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,0BAA0B,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAE/G;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,gBAAgB,CAAC,kCAAkC,CAAC,GAC5D,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,gBAAgB,CAAC,iCAAiC,CAAC,GAC3D,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,gBAAgB,CAAC,6BAA6B,CAAC,GACvD,OAAO,CAAC,eAAe,CAAC,CAE1B"}
|
package/dist/node.js
CHANGED
|
@@ -16,7 +16,9 @@ import { connectRelaySubscriber as connectSubscriber, } from './connect.js';
|
|
|
16
16
|
import { resolveTransport } from './connect-session.js';
|
|
17
17
|
import { RelayError } from './errors.js';
|
|
18
18
|
import { connectRelayPublisher as connectPublisher, } from './publish.js';
|
|
19
|
+
import { connectRelay as connectSession } from './relay-session.js';
|
|
19
20
|
import { superviseRelayPublisher, } from './supervised-publisher.js';
|
|
21
|
+
import { superviseRelay } from './supervised-relay.js';
|
|
20
22
|
import { superviseRelaySubscriber, } from './supervised-subscriber.js';
|
|
21
23
|
export * from './index.js';
|
|
22
24
|
let loading;
|
|
@@ -97,6 +99,14 @@ export async function connectRelaySubscriber(options) {
|
|
|
97
99
|
export async function connectRelayPublisher(options) {
|
|
98
100
|
return connectPublisher(withTransport(options));
|
|
99
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Open one Relay connection that publishes and subscribes, as `@caprid/relay`'s `connectRelay` does, over native QUIC
|
|
104
|
+
* through `@caprid/relay-quic` unless `createTransport` is given. An open connection keeps the process alive until it
|
|
105
|
+
* closes.
|
|
106
|
+
*/
|
|
107
|
+
export async function connectRelay(options) {
|
|
108
|
+
return connectSession(withTransport(options));
|
|
109
|
+
}
|
|
100
110
|
/**
|
|
101
111
|
* Open a subscriber that reconnects, as `@caprid/relay`'s `connectSupervisedSubscriber` does, with every connection over
|
|
102
112
|
* native QUIC through `@caprid/relay-quic` unless `createTransport` is given.
|
|
@@ -111,4 +121,11 @@ export async function connectSupervisedSubscriber(options) {
|
|
|
111
121
|
export async function connectSupervisedPublisher(options) {
|
|
112
122
|
return superviseRelayPublisher(connectPublisher, withTransport(options));
|
|
113
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Open one connection that publishes, subscribes and reconnects, as `@caprid/relay`'s `connectSupervisedRelay` does,
|
|
126
|
+
* with every connection over native QUIC through `@caprid/relay-quic` unless `createTransport` is given.
|
|
127
|
+
*/
|
|
128
|
+
export async function connectSupervisedRelay(options) {
|
|
129
|
+
return superviseRelay(connectSession, withTransport(options));
|
|
130
|
+
}
|
|
114
131
|
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAGL,sBAAsB,IAAI,iBAAiB,GAG5C,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAEL,qBAAqB,IAAI,gBAAgB,GAE1C,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],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AACT,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAwD;IAExD,OAAO,iBAAiB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAuD;IAEvD,OAAO,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAqD;IACtF,OAAO,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAA6D;IAE7D,OAAO,wBAAwB,CAAC,iBAAiB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,OAA4D;IAE5D,OAAO,uBAAuB,CAAC,gBAAgB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAwD;IAExD,OAAO,cAAc,CAAC,cAAc,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { PublishingRoot } from './publishing-roots.js';
|
|
2
|
+
import type { SupervisedPublisher } from './supervised-publisher.js';
|
|
3
|
+
import type { SupervisedSubscriber } from './supervised-subscriber.js';
|
|
4
|
+
/** The presence track's default name. */
|
|
5
|
+
export declare const PRESENCE_TRACK = "presence";
|
|
6
|
+
/**
|
|
7
|
+
* How often a presence publisher resends an unchanged document by default. A view calls a member stale after three
|
|
8
|
+
* heartbeats with nothing new (6 s), before the relay withdraws a crashed publisher at its idle timeout (about 10 s).
|
|
9
|
+
*/
|
|
10
|
+
export declare const PRESENCE_HEARTBEAT_MS = 2000;
|
|
11
|
+
/** Options for {@link publishPresence}. */
|
|
12
|
+
export interface PublishPresenceOptions {
|
|
13
|
+
/** The track name. Default {@link PRESENCE_TRACK}; listeners use the same. */
|
|
14
|
+
track?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Resend an unchanged document this long after the last change or resend, in milliseconds: an integer from 100 to
|
|
17
|
+
* 715827882.
|
|
18
|
+
* Default {@link PRESENCE_HEARTBEAT_MS}; listeners use the same.
|
|
19
|
+
*/
|
|
20
|
+
heartbeatMs?: number;
|
|
21
|
+
}
|
|
22
|
+
/** This participant's presence document, served on its supervised publisher. It lasts as long as the publisher. */
|
|
23
|
+
export interface PresencePublisher<T> {
|
|
24
|
+
/** The latest document given. */
|
|
25
|
+
readonly document: T;
|
|
26
|
+
/**
|
|
27
|
+
* Replace the document. It is encoded at once, and a `TypeError` or `RangeError` leaves the current one in place;
|
|
28
|
+
* it is sent only if its JSON differs. Returns at once.
|
|
29
|
+
*/
|
|
30
|
+
update(document: T): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Publish this participant's presence: register `track` on the supervised publisher and serve `document` as compact
|
|
34
|
+
* UTF-8 JSON, one group per send, on every relay subscription, on every change, and again `heartbeatMs` after the last
|
|
35
|
+
* change or resend, which keeps listeners from calling it stale. A heartbeat with nobody subscribed sends nothing. Presence ends
|
|
36
|
+
* with the publisher: close the publisher to leave. Arguments are checked at once, and a document `JSON.stringify`
|
|
37
|
+
* cannot encode is a `TypeError`, and one over the 16 MiB object limit a `RangeError`, before anything is registered.
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* const me = publishPresence(publisher, { name: 'Ada', joinedAt: Date.now() });
|
|
41
|
+
* me.update({ ...me.document, name: 'Ada L.' });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function publishPresence<T>(publisher: Pick<SupervisedPublisher, 'registerTrack' | 'closed'>, document: T, options?: PublishPresenceOptions): PresencePublisher<T>;
|
|
45
|
+
/** One member with a presence document, as a view reports it. Replaced, never changed, when anything in it changes. */
|
|
46
|
+
export interface PresenceMember<T> extends PublishingRoot {
|
|
47
|
+
/** The newest document read from the member. */
|
|
48
|
+
readonly document: T;
|
|
49
|
+
/** `Date.now()` when the view first read the member's document; kept across updates, staleness and rotations. */
|
|
50
|
+
readonly since: number;
|
|
51
|
+
/**
|
|
52
|
+
* No new document for three heartbeats. The count pauses only while the view's own connection is down (the member's
|
|
53
|
+
* want restarted for `connection`), and the next subscription starts a full window; any other restart leaves it
|
|
54
|
+
* running. The member is still announced; most UIs hide it.
|
|
55
|
+
*/
|
|
56
|
+
readonly stale: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** What `onChanged` receives: what changed since the last call, and who is present now. */
|
|
59
|
+
export interface PresenceChange<T> {
|
|
60
|
+
/** Members whose first document arrived. On the first call (`initial`), everyone with one at the load. */
|
|
61
|
+
readonly joined: readonly PresenceMember<T>[];
|
|
62
|
+
/** Reported members that left, as last reported. A member that never had a document leaves unreported. */
|
|
63
|
+
readonly left: readonly PresenceMember<T>[];
|
|
64
|
+
/**
|
|
65
|
+
* Members whose document bytes changed and parsed, even when `parse` returned a value equal to the old one. A stale
|
|
66
|
+
* member with a changed document is in `resumed` too.
|
|
67
|
+
*/
|
|
68
|
+
readonly updated: readonly PresenceMember<T>[];
|
|
69
|
+
/**
|
|
70
|
+
* Members that went stale. On the first call, the members in `joined` that are stale at the load, so a member is
|
|
71
|
+
* always in `stale` before it is in `resumed`.
|
|
72
|
+
*/
|
|
73
|
+
readonly stale: readonly PresenceMember<T>[];
|
|
74
|
+
/** Stale members with a new document. */
|
|
75
|
+
readonly resumed: readonly PresenceMember<T>[];
|
|
76
|
+
/**
|
|
77
|
+
* Every reported member after this change, by id, in the order `publishingRoots()` reported them. The same map as
|
|
78
|
+
* `present`.
|
|
79
|
+
*/
|
|
80
|
+
readonly present: ReadonlyMap<string, PresenceMember<T>>;
|
|
81
|
+
/** True on the first call only: the view has just loaded. */
|
|
82
|
+
readonly initial: boolean;
|
|
83
|
+
}
|
|
84
|
+
/** What a presence view follows. */
|
|
85
|
+
export interface PresenceViewOptions<T> {
|
|
86
|
+
/**
|
|
87
|
+
* The prefix whose members to follow, as for `publishingRoots()`: each member is a root, whose supervised publisher
|
|
88
|
+
* serves `<prefix>/<id>`.
|
|
89
|
+
*/
|
|
90
|
+
prefix: readonly string[];
|
|
91
|
+
/** The track name. Default {@link PRESENCE_TRACK}. */
|
|
92
|
+
track?: string;
|
|
93
|
+
/**
|
|
94
|
+
* The publishers' heartbeat, in milliseconds: an integer from 100 to 715827882. Default
|
|
95
|
+
* {@link PRESENCE_HEARTBEAT_MS}. A member is stale after three heartbeats with no new document.
|
|
96
|
+
*/
|
|
97
|
+
heartbeatMs?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Check a peer's parsed JSON and return its document, or throw. A throw skips that document: the member keeps the
|
|
100
|
+
* one it had, or stays unreported. The view reports refusals nowhere, so log inside `parse` to see them. Without it,
|
|
101
|
+
* documents are the parsed JSON, typed `unknown`.
|
|
102
|
+
*/
|
|
103
|
+
parse?(value: unknown): T;
|
|
104
|
+
}
|
|
105
|
+
/** The callbacks a presence view delivers to. Like `PublishingRootsHandlers`, they must be synchronous. */
|
|
106
|
+
export interface PresenceViewHandlers<T> {
|
|
107
|
+
/**
|
|
108
|
+
* The view loaded, or a member joined, left, changed its document, went stale or resumed. The first call is the
|
|
109
|
+
* load and runs once, after every member present at `publishingRoots()`'s load has a document or after 1 s; every
|
|
110
|
+
* later call names at least one member. One input calls it at most once, with everything that input changed. A
|
|
111
|
+
* member's publisher rotating with the same document, the relay repeating a document, and the subscriber's
|
|
112
|
+
* reconnects and rotations call nothing.
|
|
113
|
+
*/
|
|
114
|
+
onChanged?(change: PresenceChange<T>): void;
|
|
115
|
+
/**
|
|
116
|
+
* The publishing-roots view failed in a way no wait fixes, as `PublishingRootsHandlers.onError` describes. The view
|
|
117
|
+
* is closed. A prefix outside the token's grant is not one: the roster loads empty and this is never called.
|
|
118
|
+
*/
|
|
119
|
+
onError?(error: unknown): void;
|
|
120
|
+
}
|
|
121
|
+
/** A live roster: the members under a prefix with a presence document. Create one with {@link createPresenceView}. */
|
|
122
|
+
export interface PresenceView<T> {
|
|
123
|
+
/** False until the first `onChanged`. Stays true across reconnects. */
|
|
124
|
+
readonly loaded: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Reported members by id; empty until loaded. The same map until the next `onChanged`, so a UI can compare it by
|
|
127
|
+
* identity.
|
|
128
|
+
*/
|
|
129
|
+
readonly present: ReadonlyMap<string, PresenceMember<T>>;
|
|
130
|
+
/**
|
|
131
|
+
* Stop: unwant every member's presence track and close the publishing-roots view. Idempotent; nothing is delivered
|
|
132
|
+
* after it, even when called from `onChanged`. The view also stops on its own, reporting nothing, once the subscriber closes.
|
|
133
|
+
*/
|
|
134
|
+
close(): void;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Follow the presence documents of everyone under a prefix: `subscriber.publishingRoots({ prefix })` plus one want per
|
|
138
|
+
* root that follows the member's supervised publisher to its newest generation. A member is reported once its first
|
|
139
|
+
* readable document arrives, and goes stale after three heartbeats with nothing new (see `PresenceMember.stale`). The
|
|
140
|
+
* view ends with the subscriber. Arguments are checked at once; handlers run from the next turn on. Throws a
|
|
141
|
+
* `RelayError` with code `CLOSED` when the subscriber is already closed.
|
|
142
|
+
*
|
|
143
|
+
* ```ts
|
|
144
|
+
* const room = createPresenceView(subscriber, { prefix: ['room', id], parse: parseProfile }, {
|
|
145
|
+
* onChanged: ({ present }) => render([...present.values()].filter((member) => !member.stale)),
|
|
146
|
+
* });
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export declare function createPresenceView(subscriber: Pick<SupervisedSubscriber, 'publishingRoots' | 'want' | 'unwant' | 'status' | 'closed'>, options: PresenceViewOptions<unknown> & {
|
|
150
|
+
parse?: undefined;
|
|
151
|
+
}, handlers?: PresenceViewHandlers<unknown>): PresenceView<unknown>;
|
|
152
|
+
export declare function createPresenceView<T>(subscriber: Pick<SupervisedSubscriber, 'publishingRoots' | 'want' | 'unwant' | 'status' | 'closed'>, options: PresenceViewOptions<T> & {
|
|
153
|
+
parse(value: unknown): T;
|
|
154
|
+
}, handlers?: PresenceViewHandlers<T>): PresenceView<T>;
|
|
155
|
+
//# sourceMappingURL=presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAyB,MAAM,uBAAuB,CAAC;AAEnF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAiB,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGtF,yCAAyC;AACzC,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAc1C,2CAA2C;AAC3C,MAAM,WAAW,sBAAsB;IACrC,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,mHAAmH;AACnH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,iCAAiC;IACjC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,GAAG,QAAQ,CAAC,EAChE,QAAQ,EAAE,CAAC,EACX,OAAO,GAAE,sBAA2B,GACnC,iBAAiB,CAAC,CAAC,CAAC,CA2CtB;AA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