moqtail 0.8.0 → 0.9.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.
@@ -5909,13 +5909,13 @@ var handlerSubscribeNamespaceOk = async (_client, _msg) => {
5909
5909
  };
5910
5910
 
5911
5911
  // src/client/handler/publish_done.ts
5912
- init_error2();
5913
5912
  var handlerPublishDone = async (client, msg) => {
5913
+ if (client.onPeerPublishDone) {
5914
+ client.onPeerPublishDone(msg);
5915
+ }
5914
5916
  const request = client.requests.get(msg.requestId);
5915
5917
  if (request instanceof SubscribeRequest) {
5916
5918
  request.expectedStreams = msg.streamCount;
5917
- } else {
5918
- throw new ProtocolViolationError("handlerPublishDone", "No publish request was found with the given request id");
5919
5919
  }
5920
5920
  };
5921
5921
 
@@ -6005,17 +6005,6 @@ var handlerPublish = async (client, msg) => {
6005
6005
  if (client.onPeerPublish) {
6006
6006
  client.onPeerPublish(msg, stream);
6007
6007
  }
6008
- const publishOk = new PublishOk(
6009
- msg.requestId,
6010
- 1,
6011
- 255,
6012
- 1 /* Ascending */,
6013
- 2 /* LatestObject */,
6014
- void 0,
6015
- void 0,
6016
- []
6017
- );
6018
- await client.controlStream.send(publishOk);
6019
6008
  };
6020
6009
 
6021
6010
  // src/client/publication/publish.ts
@@ -6537,6 +6526,8 @@ var MOQtailClient = class _MOQtailClient {
6537
6526
  onDatagramSent;
6538
6527
  /** Fired when an inbound PUBLISH control message is received. */
6539
6528
  onPeerPublish;
6529
+ /** Fired when an inbound PUBLISH_DONE control message is received. */
6530
+ onPeerPublishDone;
6540
6531
  /** Fired when an inbound SUBSCRIBE_NAMESPACE control message is received. */
6541
6532
  onPeerSubscribeNamespace;
6542
6533
  /** Datagram writer for sending datagrams. */
@@ -7618,6 +7609,26 @@ var MOQtailClient = class _MOQtailClient {
7618
7609
  throw error;
7619
7610
  }
7620
7611
  }
7612
+ /**
7613
+ * Signals the end of a published track to the peer/relay.
7614
+ * * @param publishRequestId - The original requestId used when `publish()` was called.
7615
+ */
7616
+ async publishDone(publishRequestId, statusCode = 0, reasonPhrase = "Track Ended") {
7617
+ this.#ensureActive();
7618
+ try {
7619
+ if (typeof publishRequestId === "number") publishRequestId = BigInt(publishRequestId);
7620
+ const msg = new PublishDone(publishRequestId, statusCode, 0n, new ReasonPhrase(reasonPhrase));
7621
+ await this.controlStream.send(msg);
7622
+ this.requests.delete(publishRequestId);
7623
+ this.requestIdMap.removeMappingByRequestId(publishRequestId);
7624
+ this.subscriptionAliasMap.delete(publishRequestId);
7625
+ } catch (error) {
7626
+ await this.disconnect(
7627
+ new InternalError("MOQtailClient.publishDone", error instanceof Error ? error.message : String(error))
7628
+ );
7629
+ throw error;
7630
+ }
7631
+ }
7621
7632
  /**
7622
7633
  * Registers an incoming PUBLISH announcement as a valid data receiver.
7623
7634
  * This prepares the client to ingest pushed data streams matching the published alias.
@@ -1,5 +1,4 @@
1
- import { n as MoqtObject, L as Location, m as FullTrackName, f as ObjectForwardingPreference, K as KeyValuePair, D as DatagramObject, h as DatagramStatus, c as Tuple, o as SubgroupObject, j as FetchObject } from '../byte_buffer-BM4uNj4n.cjs';
2
- import { w as ControlMessage, S as Subscribe, q as PublishDoneStatusCode, V as SubscribeUpdate, x as Fetch, L as Publish, b as PublishNamespaceOk, a as PublishNamespaceError, P as PublishNamespace, A as FetchOk, z as FetchError, U as SubscribeOk, Q as SubscribeError, J as SubscribeNamespaceOk, I as SubscribeNamespaceError, H as SubscribeNamespace, O as PublishOk, N as PublishError, a5 as SetupParameters, G as GroupOrder, F as FilterType, a7 as VersionSpecificParameters, h as FetchType, a2 as RequestIdMap, Z as PublishNamespaceDone, B as GoAway, a1 as SubgroupHeader, a0 as FetchHeader, E as ServerSetup, c as PublishNamespaceCancel, $ as UnsubscribeNamespace, a3 as Header } from '../version_parameter-BpmuiMQj.cjs';
1
+ import { d as ControlMessage, E as MoqtObject, L as Location, s as FullTrackName, J as ObjectForwardingPreference, ab as Subscribe, T as PublishDoneStatusCode, aj as SubscribeUpdate, F as Fetch, R as Publish, $ as PublishNamespaceOk, Z as PublishNamespaceError, W as PublishNamespace, o as FetchOk, j as FetchError, ai as SubscribeOk, ac as SubscribeError, K as KeyValuePair, ah as SubscribeNamespaceOk, af as SubscribeNamespaceError, ae as SubscribeNamespace, a0 as PublishOk, U as PublishError, t as GroupOrder, p as FetchType, av as VersionSpecificParameters, a7 as SetupParameters, f as DatagramObject, g as DatagramStatus, q as FilterType, ap as Tuple, a2 as RequestIdMap, Y as PublishNamespaceDone, G as GoAway, aa as SubgroupObject, a8 as SubgroupHeader, n as FetchObject, l as FetchHeader, S as PublishDone, a4 as ServerSetup, X as PublishNamespaceCancel, as as UnsubscribeNamespace, H as Header } from './version_parameter-DXBOBueW.cjs';
3
2
 
4
3
  /**
5
4
  * Copyright 2025 The MOQtail Authors
@@ -1118,6 +1117,8 @@ declare class MOQtailClient {
1118
1117
  onDatagramSent?: (data: DatagramObject | DatagramStatus) => void;
1119
1118
  /** Fired when an inbound PUBLISH control message is received. */
1120
1119
  onPeerPublish?: (msg: Publish, stream: ReadableStream<MoqtObject>) => void;
1120
+ /** Fired when an inbound PUBLISH_DONE control message is received. */
1121
+ onPeerPublishDone?: (msg: PublishDone) => void;
1121
1122
  /** Fired when an inbound SUBSCRIBE_NAMESPACE control message is received. */
1122
1123
  onPeerSubscribeNamespace?: (msg: SubscribeNamespace) => void;
1123
1124
  /**
@@ -1599,6 +1600,11 @@ declare class MOQtailClient {
1599
1600
  requestId: bigint;
1600
1601
  trackAlias: bigint;
1601
1602
  }>;
1603
+ /**
1604
+ * Signals the end of a published track to the peer/relay.
1605
+ * * @param publishRequestId - The original requestId used when `publish()` was called.
1606
+ */
1607
+ publishDone(publishRequestId: bigint | number, statusCode?: number, reasonPhrase?: string): Promise<void>;
1602
1608
  /**
1603
1609
  * Registers an incoming PUBLISH announcement as a valid data receiver.
1604
1610
  * This prepares the client to ingest pushed data streams matching the published alias.
@@ -1,5 +1,4 @@
1
- import { n as MoqtObject, L as Location, m as FullTrackName, f as ObjectForwardingPreference, K as KeyValuePair, D as DatagramObject, h as DatagramStatus, c as Tuple, o as SubgroupObject, j as FetchObject } from '../byte_buffer-BM4uNj4n.js';
2
- import { w as ControlMessage, S as Subscribe, q as PublishDoneStatusCode, V as SubscribeUpdate, x as Fetch, L as Publish, b as PublishNamespaceOk, a as PublishNamespaceError, P as PublishNamespace, A as FetchOk, z as FetchError, U as SubscribeOk, Q as SubscribeError, J as SubscribeNamespaceOk, I as SubscribeNamespaceError, H as SubscribeNamespace, O as PublishOk, N as PublishError, a5 as SetupParameters, G as GroupOrder, F as FilterType, a7 as VersionSpecificParameters, h as FetchType, a2 as RequestIdMap, Z as PublishNamespaceDone, B as GoAway, a1 as SubgroupHeader, a0 as FetchHeader, E as ServerSetup, c as PublishNamespaceCancel, $ as UnsubscribeNamespace, a3 as Header } from '../version_parameter-f75NkWiO.js';
1
+ import { d as ControlMessage, E as MoqtObject, L as Location, s as FullTrackName, J as ObjectForwardingPreference, ab as Subscribe, T as PublishDoneStatusCode, aj as SubscribeUpdate, F as Fetch, R as Publish, $ as PublishNamespaceOk, Z as PublishNamespaceError, W as PublishNamespace, o as FetchOk, j as FetchError, ai as SubscribeOk, ac as SubscribeError, K as KeyValuePair, ah as SubscribeNamespaceOk, af as SubscribeNamespaceError, ae as SubscribeNamespace, a0 as PublishOk, U as PublishError, t as GroupOrder, p as FetchType, av as VersionSpecificParameters, a7 as SetupParameters, f as DatagramObject, g as DatagramStatus, q as FilterType, ap as Tuple, a2 as RequestIdMap, Y as PublishNamespaceDone, G as GoAway, aa as SubgroupObject, a8 as SubgroupHeader, n as FetchObject, l as FetchHeader, S as PublishDone, a4 as ServerSetup, X as PublishNamespaceCancel, as as UnsubscribeNamespace, H as Header } from './version_parameter-DXBOBueW.js';
3
2
 
4
3
  /**
5
4
  * Copyright 2025 The MOQtail Authors
@@ -1118,6 +1117,8 @@ declare class MOQtailClient {
1118
1117
  onDatagramSent?: (data: DatagramObject | DatagramStatus) => void;
1119
1118
  /** Fired when an inbound PUBLISH control message is received. */
1120
1119
  onPeerPublish?: (msg: Publish, stream: ReadableStream<MoqtObject>) => void;
1120
+ /** Fired when an inbound PUBLISH_DONE control message is received. */
1121
+ onPeerPublishDone?: (msg: PublishDone) => void;
1121
1122
  /** Fired when an inbound SUBSCRIBE_NAMESPACE control message is received. */
1122
1123
  onPeerSubscribeNamespace?: (msg: SubscribeNamespace) => void;
1123
1124
  /**
@@ -1599,6 +1600,11 @@ declare class MOQtailClient {
1599
1600
  requestId: bigint;
1600
1601
  trackAlias: bigint;
1601
1602
  }>;
1603
+ /**
1604
+ * Signals the end of a published track to the peer/relay.
1605
+ * * @param publishRequestId - The original requestId used when `publish()` was called.
1606
+ */
1607
+ publishDone(publishRequestId: bigint | number, statusCode?: number, reasonPhrase?: string): Promise<void>;
1602
1608
  /**
1603
1609
  * Registers an incoming PUBLISH announcement as a valid data receiver.
1604
1610
  * This prepares the client to ingest pushed data streams matching the published alias.
@@ -5907,13 +5907,13 @@ var handlerSubscribeNamespaceOk = async (_client, _msg) => {
5907
5907
  };
5908
5908
 
5909
5909
  // src/client/handler/publish_done.ts
5910
- init_error2();
5911
5910
  var handlerPublishDone = async (client, msg) => {
5911
+ if (client.onPeerPublishDone) {
5912
+ client.onPeerPublishDone(msg);
5913
+ }
5912
5914
  const request = client.requests.get(msg.requestId);
5913
5915
  if (request instanceof SubscribeRequest) {
5914
5916
  request.expectedStreams = msg.streamCount;
5915
- } else {
5916
- throw new ProtocolViolationError("handlerPublishDone", "No publish request was found with the given request id");
5917
5917
  }
5918
5918
  };
5919
5919
 
@@ -6003,17 +6003,6 @@ var handlerPublish = async (client, msg) => {
6003
6003
  if (client.onPeerPublish) {
6004
6004
  client.onPeerPublish(msg, stream);
6005
6005
  }
6006
- const publishOk = new PublishOk(
6007
- msg.requestId,
6008
- 1,
6009
- 255,
6010
- 1 /* Ascending */,
6011
- 2 /* LatestObject */,
6012
- void 0,
6013
- void 0,
6014
- []
6015
- );
6016
- await client.controlStream.send(publishOk);
6017
6006
  };
6018
6007
 
6019
6008
  // src/client/publication/publish.ts
@@ -6535,6 +6524,8 @@ var MOQtailClient = class _MOQtailClient {
6535
6524
  onDatagramSent;
6536
6525
  /** Fired when an inbound PUBLISH control message is received. */
6537
6526
  onPeerPublish;
6527
+ /** Fired when an inbound PUBLISH_DONE control message is received. */
6528
+ onPeerPublishDone;
6538
6529
  /** Fired when an inbound SUBSCRIBE_NAMESPACE control message is received. */
6539
6530
  onPeerSubscribeNamespace;
6540
6531
  /** Datagram writer for sending datagrams. */
@@ -7616,6 +7607,26 @@ var MOQtailClient = class _MOQtailClient {
7616
7607
  throw error;
7617
7608
  }
7618
7609
  }
7610
+ /**
7611
+ * Signals the end of a published track to the peer/relay.
7612
+ * * @param publishRequestId - The original requestId used when `publish()` was called.
7613
+ */
7614
+ async publishDone(publishRequestId, statusCode = 0, reasonPhrase = "Track Ended") {
7615
+ this.#ensureActive();
7616
+ try {
7617
+ if (typeof publishRequestId === "number") publishRequestId = BigInt(publishRequestId);
7618
+ const msg = new PublishDone(publishRequestId, statusCode, 0n, new ReasonPhrase(reasonPhrase));
7619
+ await this.controlStream.send(msg);
7620
+ this.requests.delete(publishRequestId);
7621
+ this.requestIdMap.removeMappingByRequestId(publishRequestId);
7622
+ this.subscriptionAliasMap.delete(publishRequestId);
7623
+ } catch (error) {
7624
+ await this.disconnect(
7625
+ new InternalError("MOQtailClient.publishDone", error instanceof Error ? error.message : String(error))
7626
+ );
7627
+ throw error;
7628
+ }
7629
+ }
7619
7630
  /**
7620
7631
  * Registers an incoming PUBLISH announcement as a valid data receiver.
7621
7632
  * This prepares the client to ingest pushed data streams matching the published alias.