@ahmedrowaihi/mediabunny 1.65.2-beta.546 → 1.65.2-beta.548

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.
@@ -275,6 +275,7 @@ var Mediabunny = (() => {
275
275
  TRANSFER_FUNCTION_PQ: () => TRANSFER_FUNCTION_PQ,
276
276
  Tag: () => Tag,
277
277
  Target: () => Target,
278
+ TargetWriter: () => TargetWriter,
278
279
  TextSubtitleSource: () => TextSubtitleSource,
279
280
  UnsupportedInputFormatError: () => UnsupportedInputFormatError,
280
281
  UnsupportedMediaError: () => UnsupportedMediaError,
@@ -65316,6 +65317,80 @@ ${baseUrl}${p.getFileName()}`;
65316
65317
  return out;
65317
65318
  };
65318
65319
 
65320
+ // src/target-writer.ts
65321
+ var TargetWriter = class {
65322
+ constructor(target) {
65323
+ /** @internal */
65324
+ this._position = 0;
65325
+ /** @internal */
65326
+ this._started = false;
65327
+ /** @internal */
65328
+ this._closed = false;
65329
+ if (!(target instanceof Target)) {
65330
+ throw new TypeError("target must be a Target.");
65331
+ }
65332
+ if (target._writerAcquired) {
65333
+ throw new InvalidUsageError(
65334
+ "That Target is already being written to, by an Output or another TargetWriter."
65335
+ );
65336
+ }
65337
+ this._target = target;
65338
+ this._target._setMonotonicity(true);
65339
+ this._target._writerAcquired = true;
65340
+ }
65341
+ /** Bytes handed to the target so far, which is also the next write's offset. */
65342
+ get position() {
65343
+ return this._position;
65344
+ }
65345
+ /**
65346
+ * Appends bytes. Returns once the target has taken them, which for a buffering target is immediately
65347
+ * — {@link TargetWriter.flush} is what waits for them to be written out.
65348
+ */
65349
+ write(bytes2) {
65350
+ if (this._closed) {
65351
+ throw new InvalidUsageError("Cannot write to a closed TargetWriter.");
65352
+ }
65353
+ if (!(bytes2 instanceof Uint8Array)) {
65354
+ throw new TypeError("bytes must be a Uint8Array.");
65355
+ }
65356
+ if (!this._started) {
65357
+ this._started = true;
65358
+ this._target._start();
65359
+ }
65360
+ if (bytes2.byteLength === 0) {
65361
+ return;
65362
+ }
65363
+ this._target._write(bytes2, this._position);
65364
+ this._position += bytes2.byteLength;
65365
+ }
65366
+ /**
65367
+ * Writes out what has been appended. This is the point backpressure arrives at, the same as on an
65368
+ * `Output`'s own path, so a caller that wants it awaits this rather than {@link TargetWriter.write}.
65369
+ */
65370
+ async flush() {
65371
+ if (this._closed) {
65372
+ throw new InvalidUsageError("Cannot flush a closed TargetWriter.");
65373
+ }
65374
+ if (!this._started) {
65375
+ return;
65376
+ }
65377
+ await this._target._flush();
65378
+ }
65379
+ /** Flushes, then finalizes the target, which is where a draining target drains. */
65380
+ async close() {
65381
+ if (this._closed) {
65382
+ return;
65383
+ }
65384
+ if (!this._started) {
65385
+ this._closed = true;
65386
+ return;
65387
+ }
65388
+ this._closed = true;
65389
+ await this._target._flush();
65390
+ await this._target._finalize();
65391
+ }
65392
+ };
65393
+
65319
65394
  // src/smooth-streaming.ts
65320
65395
  var UUID_TYPE = [117, 117, 105, 100];
65321
65396
  var TFXD_UUID = [