@moq/watch 0.2.1 → 0.2.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"decoder.d.ts","sourceRoot":"","sources":["../../src/audio/decoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,MAAM,YAAY,GAAG;IAE1B,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,WAAW,UAAU;IAC1B,aAAa,EAAE,MAAM,CAAC;CACtB;AAID,qBAAa,OAAO;;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAGzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,YAAY,GAAG,SAAS,CAAC,CAAiB;IAKnE,QAAQ,CAAC,IAAI,EAAoB,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAG/D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,CAAoB;IAGnE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC,CAAe;IAI7D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,CAAmB;IAIrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAiB;IAOlD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,cAAc,CAAC,CAAkB;gBAI/C,MAAM,EAAE,MAA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4281,7 @@ class le {
4281
4281
  }
4282
4282
  if (r === void 0 || s === void 0 || s - r <= t) break;
4283
4283
  const o = this.#e.shift();
4284
+ if (!o) break;
4284
4285
  this.#t = this.#e[0]?.consumer.sequence, console.warn(`skipping slow group: ${o.consumer.sequence} -> ${this.#t}`), o.consumer.close(), o.frames.length = 0, n = !0;
4285
4286
  }
4286
4287
  n && (this.#u(), this.#s?.(), this.#s = void 0);
@@ -7029,29 +7030,36 @@ let Ec = class {
7029
7030
  this.#a.update(() => Oc(o, a));
7030
7031
  }), n.spawn(async () => {
7031
7032
  if (!await Rn()) return;
7032
- const o = new AudioDecoder({
7033
- output: (c) => this.#f(c),
7034
- error: (c) => console.error(c)
7033
+ let o = 0;
7034
+ const a = new AudioDecoder({
7035
+ output: (u) => {
7036
+ if (o++, o <= 3) {
7037
+ u.close();
7038
+ return;
7039
+ }
7040
+ this.#f(u);
7041
+ },
7042
+ error: (u) => console.error(u)
7035
7043
  });
7036
- n.cleanup(() => o.close());
7037
- const a = r.description ? L(r.description) : void 0;
7038
- for (o.configure({
7044
+ n.cleanup(() => a.close());
7045
+ const c = r.description ? L(r.description) : void 0;
7046
+ for (a.configure({
7039
7047
  ...r,
7040
- description: a
7048
+ description: c
7041
7049
  }); ; ) {
7042
- const c = await s.next();
7043
- if (!c) break;
7044
- const { frame: u } = c;
7045
- if (!u) continue;
7046
- this.#t.update((f) => ({
7047
- bytesReceived: (f?.bytesReceived ?? 0) + u.data.byteLength
7050
+ const u = await s.next();
7051
+ if (!u) break;
7052
+ const { frame: d } = u;
7053
+ if (!d) continue;
7054
+ this.#t.update((p) => ({
7055
+ bytesReceived: (p?.bytesReceived ?? 0) + d.data.byteLength
7048
7056
  }));
7049
- const d = new EncodedAudioChunk({
7050
- type: u.keyframe ? "key" : "delta",
7051
- data: u.data,
7052
- timestamp: u.timestamp
7057
+ const f = new EncodedAudioChunk({
7058
+ type: d.keyframe ? "key" : "delta",
7059
+ data: d.data,
7060
+ timestamp: d.timestamp
7053
7061
  });
7054
- o.decode(d);
7062
+ a.decode(f);
7055
7063
  }
7056
7064
  });
7057
7065
  }
@@ -7362,7 +7370,10 @@ class Nc {
7362
7370
  }
7363
7371
  #c(n) {
7364
7372
  const t = n.getAll([this.enabled, this.source.broadcast, this.source.track, this.source.config]);
7365
- if (!t) return;
7373
+ if (!t) {
7374
+ this.#n.set(void 0);
7375
+ return;
7376
+ }
7366
7377
  const [r, s, i, o] = t, a = n.get(s.active);
7367
7378
  if (!a) return;
7368
7379
  let c = new Mc({
@@ -7379,12 +7390,19 @@ class Nc {
7379
7390
  const f = u.get(c.timestamp), p = u.get(d.timestamp);
7380
7391
  if (!f || p && p > f + Rc) return;
7381
7392
  }
7382
- this.#n.set(c), c = void 0;
7393
+ this.#n.set(c), c = void 0, u.close();
7383
7394
  });
7384
7395
  }
7385
7396
  #d(n) {
7386
7397
  const t = n.get(this.#n);
7387
- t && (n.cleanup(() => t.close()), n.proxy(this.#r, t.frame), n.proxy(this.#e, t.timestamp), n.proxy(this.#o, t.buffered));
7398
+ if (!t) {
7399
+ this.#o.set([]);
7400
+ return;
7401
+ }
7402
+ n.cleanup(() => t.close()), n.run((r) => {
7403
+ const s = r.get(t.frame);
7404
+ this.#r.update((i) => (i?.close(), s?.clone()));
7405
+ }), n.proxy(this.#e, t.timestamp), n.proxy(this.#o, t.buffered);
7388
7406
  }
7389
7407
  #l(n) {
7390
7408
  const t = n.get(this.source.catalog);
@@ -7752,17 +7770,20 @@ class qc {
7752
7770
  #s(n) {
7753
7771
  const t = n.get(this.canvas);
7754
7772
  if (!t || n.get(this.paused)) return;
7755
- const s = new IntersectionObserver(
7756
- (i) => {
7757
- for (const o of i)
7758
- this.decoder.enabled.set(o.isIntersecting);
7773
+ let s = !1;
7774
+ const i = new IntersectionObserver(
7775
+ (a) => {
7776
+ for (const c of a)
7777
+ s = c.isIntersecting, this.decoder.enabled.set(s && !document.hidden);
7759
7778
  },
7760
7779
  {
7761
7780
  // fire when even a small part is visible
7762
7781
  threshold: 0.01
7763
7782
  }
7764
- );
7765
- n.cleanup(() => this.decoder.enabled.set(!1)), s.observe(t), n.cleanup(() => s.disconnect());
7783
+ ), o = () => {
7784
+ this.decoder.enabled.set(s && !document.hidden);
7785
+ };
7786
+ document.addEventListener("visibilitychange", o), n.cleanup(() => document.removeEventListener("visibilitychange", o)), n.cleanup(() => this.decoder.enabled.set(!1)), i.observe(t), n.cleanup(() => i.disconnect());
7766
7787
  }
7767
7788
  #i(n) {
7768
7789
  const t = n.get(this.#r);
@@ -8229,4 +8250,4 @@ export {
8229
8250
  eu as m,
8230
8251
  At as t
8231
8252
  };
8232
- //# sourceMappingURL=broadcast-CZc0dhfv.js.map
8253
+ //# sourceMappingURL=broadcast-DFnI-aDr.js.map