@moq/watch 0.1.0 → 0.2.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.
@@ -4606,6 +4606,9 @@ var Effect = class _Effect {
4606
4606
  this.#scheduled = false;
4607
4607
  if (this.#fn) {
4608
4608
  this.#fn(this);
4609
+ if (DEV && this.#unwatch.length === 0) {
4610
+ console.warn("Effect did not subscribe to any signals; it will never rerun.", this.#stack);
4611
+ }
4609
4612
  }
4610
4613
  }
4611
4614
  // Get the current value of a signal, monitoring it for changes (via ===) and rerunning on change.
@@ -4715,7 +4718,7 @@ var Effect = class _Effect {
4715
4718
  this.cleanup(() => clearInterval(interval));
4716
4719
  }
4717
4720
  // Create a nested effect that can be rerun independently.
4718
- effect(fn) {
4721
+ run(fn) {
4719
4722
  if (this.#dispose === void 0) {
4720
4723
  if (DEV) {
4721
4724
  console.warn("Effect.nested called when closed, ignoring");
@@ -4725,6 +4728,10 @@ var Effect = class _Effect {
4725
4728
  const effect = new _Effect(fn);
4726
4729
  this.#dispose.push(() => effect.close());
4727
4730
  }
4731
+ // Backwards compatibility with the old name.
4732
+ effect(fn) {
4733
+ return this.run(fn);
4734
+ }
4728
4735
  // Get the values of multiple signals, returning undefined if any are falsy.
4729
4736
  getAll(signals) {
4730
4737
  const values = [];
@@ -4744,7 +4751,7 @@ var Effect = class _Effect {
4744
4751
  fn(signal.peek());
4745
4752
  return;
4746
4753
  }
4747
- this.effect((effect) => {
4754
+ this.run((effect) => {
4748
4755
  const value = effect.get(signal);
4749
4756
  fn(value);
4750
4757
  });
@@ -6954,7 +6961,7 @@ let Ec = class {
6954
6961
  buffered = this.#a;
6955
6962
  #c = new C();
6956
6963
  constructor(n, t) {
6957
- this.source = n, this.source.supported.set(Tc), this.enabled = h.from(t?.enabled ?? !1), this.#c.effect(this.#d.bind(this)), this.#c.effect(this.#l.bind(this)), this.#c.effect(this.#u.bind(this)), this.#c.effect(this.#h.bind(this));
6964
+ this.source = n, this.source.supported.set(Tc), this.enabled = h.from(t?.enabled ?? !1), this.#c.run(this.#d.bind(this)), this.#c.run(this.#l.bind(this)), this.#c.run(this.#u.bind(this)), this.#c.run(this.#h.bind(this));
6958
6965
  }
6959
6966
  #d(n) {
6960
6967
  const t = n.get(this.source.config);
@@ -7018,7 +7025,7 @@ let Ec = class {
7018
7025
  const s = new le(t, {
7019
7026
  latency: this.source.sync.latency
7020
7027
  });
7021
- n.cleanup(() => s.close()), n.effect((i) => {
7028
+ n.cleanup(() => s.close()), n.run((i) => {
7022
7029
  const o = i.get(s.buffered), a = i.get(this.#o);
7023
7030
  this.#a.update(() => Oc(o, a));
7024
7031
  }), n.spawn(async () => {
@@ -7052,7 +7059,7 @@ let Ec = class {
7052
7059
  #m(n, t, r) {
7053
7060
  if (r.container.kind !== "cmaf") return;
7054
7061
  const { timescale: s } = r.container, i = r.description ? L(r.description) : void 0;
7055
- n.effect((o) => {
7062
+ n.run((o) => {
7056
7063
  const a = o.get(this.#o);
7057
7064
  this.#a.update(() => a);
7058
7065
  }), n.spawn(async () => {
@@ -7173,22 +7180,22 @@ class Ac {
7173
7180
  // The gain node used to adjust the volume.
7174
7181
  #e = new h(void 0);
7175
7182
  constructor(n, t) {
7176
- this.source = n, this.volume = h.from(t?.volume ?? 0.5), this.muted = h.from(t?.muted ?? !1), this.paused = h.from(t?.paused ?? t?.muted ?? !1), this.#n.effect((r) => {
7183
+ this.source = n, this.volume = h.from(t?.volume ?? 0.5), this.muted = h.from(t?.muted ?? !1), this.paused = h.from(t?.paused ?? t?.muted ?? !1), this.#n.run((r) => {
7177
7184
  r.get(this.muted) ? (this.#r = this.volume.peek() || 0.5, this.volume.set(0)) : this.volume.set(this.#r);
7178
- }), this.#n.effect((r) => {
7185
+ }), this.#n.run((r) => {
7179
7186
  const s = !r.get(this.paused) && !r.get(this.muted);
7180
7187
  this.source.enabled.set(s);
7181
- }), this.#n.effect((r) => {
7188
+ }), this.#n.run((r) => {
7182
7189
  const s = r.get(this.volume);
7183
7190
  this.muted.set(s === 0);
7184
- }), this.#n.effect((r) => {
7191
+ }), this.#n.run((r) => {
7185
7192
  const s = r.get(this.source.root);
7186
7193
  if (!s) return;
7187
7194
  const i = new GainNode(s.context, { gain: r.get(this.volume) });
7188
- s.connect(i), r.set(this.#e, i), r.effect(() => {
7195
+ s.connect(i), r.set(this.#e, i), r.run(() => {
7189
7196
  r.get(this.source.enabled) && (i.connect(s.context.destination), r.cleanup(() => i.disconnect()));
7190
7197
  });
7191
- }), this.#n.effect((r) => {
7198
+ }), this.#n.run((r) => {
7192
7199
  const s = r.get(this.#e);
7193
7200
  if (!s) return;
7194
7201
  r.cleanup(() => s.gain.cancelScheduledValues(s.context.currentTime));
@@ -7208,7 +7215,7 @@ class Ot {
7208
7215
  mediaSource = this.#r;
7209
7216
  #e = new C();
7210
7217
  constructor(n, t) {
7211
- this.element = h.from(t?.element), this.paused = h.from(t?.paused ?? !1), this.#n = n, this.#e.effect(this.#t.bind(this)), this.#e.effect(this.#s.bind(this)), this.#e.effect(this.#i.bind(this)), this.#e.effect(this.#o.bind(this)), this.#e.effect(this.#a.bind(this));
7218
+ this.element = h.from(t?.element), this.paused = h.from(t?.paused ?? !1), this.#n = n, this.#e.run(this.#t.bind(this)), this.#e.run(this.#s.bind(this)), this.#e.run(this.#i.bind(this)), this.#e.run(this.#o.bind(this)), this.#e.run(this.#a.bind(this));
7212
7219
  }
7213
7220
  #t(n) {
7214
7221
  const t = n.get(this.element);
@@ -7295,7 +7302,7 @@ class Pc {
7295
7302
  constructor(n) {
7296
7303
  this.jitter = h.from(n?.jitter ?? 100), this.audio = h.from(n?.audio), this.video = h.from(n?.video), this.#e = new Promise((t) => {
7297
7304
  this.#t = t;
7298
- }), this.signals.effect(this.#s.bind(this));
7305
+ }), this.signals.run(this.#s.bind(this));
7299
7306
  }
7300
7307
  #s(n) {
7301
7308
  const t = n.get(this.jitter), r = n.get(this.video) ?? v.Milli.zero, s = n.get(this.audio) ?? v.Milli.zero, i = v.Milli.add(v.Milli.max(r, s), t);
@@ -7352,7 +7359,7 @@ class Nc {
7352
7359
  buffered = this.#o;
7353
7360
  #a = new C();
7354
7361
  constructor(n, t) {
7355
- this.enabled = h.from(t?.enabled ?? !1), this.source = n, this.source.supported.set(Dc), this.#a.effect(this.#c.bind(this)), this.#a.effect(this.#d.bind(this)), this.#a.effect(this.#l.bind(this)), this.#a.effect(this.#u.bind(this));
7362
+ this.enabled = h.from(t?.enabled ?? !1), this.source = n, this.source.supported.set(Dc), this.#a.run(this.#c.bind(this)), this.#a.run(this.#d.bind(this)), this.#a.run(this.#l.bind(this)), this.#a.run(this.#u.bind(this));
7356
7363
  }
7357
7364
  #c(n) {
7358
7365
  const t = n.getAll([this.enabled, this.source.broadcast, this.source.track, this.source.config]);
@@ -7366,7 +7373,7 @@ class Nc {
7366
7373
  config: o,
7367
7374
  stats: this.#i
7368
7375
  });
7369
- n.cleanup(() => c?.close()), n.effect((u) => {
7376
+ n.cleanup(() => c?.close()), n.run((u) => {
7370
7377
  if (!c) return;
7371
7378
  const d = u.get(this.#n);
7372
7379
  if (d) {
@@ -7428,7 +7435,7 @@ class Mc {
7428
7435
  signals = new C();
7429
7436
  constructor(n) {
7430
7437
  const { codedWidth: t, codedHeight: r, ...s } = n.config;
7431
- this.source = n.source, this.broadcast = n.broadcast, this.track = n.track, this.config = s, this.stats = n.stats, this.signals.effect(this.#r.bind(this));
7438
+ this.source = n.source, this.broadcast = n.broadcast, this.track = n.track, this.config = s, this.stats = n.stats, this.signals.run(this.#r.bind(this));
7432
7439
  }
7433
7440
  #r(n) {
7434
7441
  const t = this.broadcast.subscribe(this.track, ue.video);
@@ -7459,7 +7466,7 @@ class Mc {
7459
7466
  const s = new le(t, {
7460
7467
  latency: this.source.sync.latency
7461
7468
  });
7462
- n.cleanup(() => s.close()), n.effect((o) => {
7469
+ n.cleanup(() => s.close()), n.run((o) => {
7463
7470
  const a = o.get(s.buffered), c = o.get(this.#n);
7464
7471
  this.buffered.update(() => $c(a, c));
7465
7472
  }), r.configure({
@@ -7509,7 +7516,7 @@ class Mc {
7509
7516
  optimizeForLatency: this.config.optimizeForLatency ?? !0,
7510
7517
  // @ts-expect-error Only supported by Chrome, so the renderer has to flip manually.
7511
7518
  flip: !1
7512
- }), n.effect((o) => {
7519
+ }), n.run((o) => {
7513
7520
  const a = o.get(this.#n);
7514
7521
  this.buffered.update(() => a);
7515
7522
  }), n.spawn(async () => {
@@ -7607,7 +7614,7 @@ let Cc = class {
7607
7614
  timestamp = this.#t;
7608
7615
  signals = new C();
7609
7616
  constructor(n, t) {
7610
- this.muxer = n, this.source = t, this.source.supported.set(xc), this.signals.effect(this.#s.bind(this)), this.signals.effect(this.#c.bind(this)), this.signals.effect(this.#d.bind(this));
7617
+ this.muxer = n, this.source = t, this.source.supported.set(xc), this.signals.run(this.#s.bind(this)), this.signals.run(this.#c.bind(this)), this.signals.run(this.#d.bind(this));
7611
7618
  }
7612
7619
  #s(n) {
7613
7620
  const t = n.get(this.muxer.element);
@@ -7731,10 +7738,10 @@ class qc {
7731
7738
  #r = new h(void 0);
7732
7739
  #e = new C();
7733
7740
  constructor(n, t) {
7734
- this.decoder = n, this.canvas = h.from(t?.canvas), this.paused = h.from(t?.paused ?? !1), this.#e.effect((r) => {
7741
+ this.decoder = n, this.canvas = h.from(t?.canvas), this.paused = h.from(t?.paused ?? !1), this.#e.run((r) => {
7735
7742
  const s = r.get(this.canvas);
7736
7743
  this.#r.set(s?.getContext("2d") ?? void 0);
7737
- }), this.#e.effect(this.#s.bind(this)), this.#e.effect(this.#i.bind(this)), this.#e.effect(this.#t.bind(this));
7744
+ }), this.#e.run(this.#s.bind(this)), this.#e.run(this.#i.bind(this)), this.#e.run(this.#t.bind(this));
7738
7745
  }
7739
7746
  #t(n) {
7740
7747
  const t = n.getAll([this.canvas, this.decoder.display]);
@@ -7798,7 +7805,7 @@ let Zc = class {
7798
7805
  supported;
7799
7806
  #s = new C();
7800
7807
  constructor(n, t) {
7801
- this.broadcast = h.from(t?.broadcast), this.target = h.from(t?.target), this.sync = n, this.supported = h.from(t?.supported), this.#s.effect(this.#i.bind(this)), this.#s.effect(this.#o.bind(this)), this.#s.effect(this.#a.bind(this));
7808
+ this.broadcast = h.from(t?.broadcast), this.target = h.from(t?.target), this.sync = n, this.supported = h.from(t?.supported), this.#s.run(this.#i.bind(this)), this.#s.run(this.#o.bind(this)), this.#s.run(this.#a.bind(this));
7802
7809
  }
7803
7810
  #i(n) {
7804
7811
  const t = n.get(this.broadcast);
@@ -7900,7 +7907,7 @@ class eu {
7900
7907
  broadcast: this.broadcast
7901
7908
  }), this.#r = new Lc(this.#e, {
7902
7909
  broadcast: this.broadcast
7903
- }), this.video = new Fc(this.#n), this.audio = new Bc(this.#r), this.paused = h.from(n?.paused ?? !1), this.signals.effect(this.#t.bind(this));
7910
+ }), this.video = new Fc(this.#n), this.audio = new Bc(this.#r), this.paused = h.from(n?.paused ?? !1), this.signals.run(this.#t.bind(this));
7904
7911
  }
7905
7912
  #t(n) {
7906
7913
  const t = n.get(this.element);
@@ -7943,7 +7950,7 @@ class jc {
7943
7950
  buffered = this.#r;
7944
7951
  #e = new C();
7945
7952
  constructor(n, t, r) {
7946
- this.muxer = n, this.source = t, this.source.supported.set(Vc), this.volume = h.from(r?.volume ?? 0.5), this.muted = h.from(r?.muted ?? !1), this.#e.effect(this.#t.bind(this)), this.#e.effect(this.#a.bind(this));
7953
+ this.muxer = n, this.source = t, this.source.supported.set(Vc), this.volume = h.from(r?.volume ?? 0.5), this.muted = h.from(r?.muted ?? !1), this.#e.run(this.#t.bind(this)), this.#e.run(this.#a.bind(this));
7947
7954
  }
7948
7955
  #t(n) {
7949
7956
  const t = n.get(this.muxer.element);
@@ -8053,7 +8060,7 @@ class Lc {
8053
8060
  sync;
8054
8061
  #s = new C();
8055
8062
  constructor(n, t) {
8056
- this.sync = n, this.broadcast = h.from(t?.broadcast), this.target = h.from(t?.target), this.supported = h.from(t?.supported), this.#s.effect(this.#i.bind(this)), this.#s.effect(this.#o.bind(this)), this.#s.effect(this.#a.bind(this));
8063
+ this.sync = n, this.broadcast = h.from(t?.broadcast), this.target = h.from(t?.target), this.supported = h.from(t?.supported), this.#s.run(this.#i.bind(this)), this.#s.run(this.#o.bind(this)), this.#s.run(this.#a.bind(this));
8057
8064
  }
8058
8065
  #i(n) {
8059
8066
  const t = n.get(this.broadcast);
@@ -8101,7 +8108,7 @@ class Lc {
8101
8108
  class nu {
8102
8109
  connection;
8103
8110
  enabled;
8104
- path;
8111
+ name;
8105
8112
  status = new h("offline");
8106
8113
  reload;
8107
8114
  #n = new h(void 0);
@@ -8112,7 +8119,7 @@ class nu {
8112
8119
  #e = new h(!1);
8113
8120
  signals = new C();
8114
8121
  constructor(n) {
8115
- this.connection = h.from(n?.connection), this.path = h.from(n?.path), this.enabled = h.from(n?.enabled ?? !1), this.reload = h.from(n?.reload ?? !1), this.signals.effect(this.#t.bind(this)), this.signals.effect(this.#s.bind(this)), this.signals.effect(this.#i.bind(this));
8122
+ this.connection = h.from(n?.connection), this.name = h.from(n?.name), this.enabled = h.from(n?.enabled ?? !1), this.reload = h.from(n?.reload ?? !1), this.signals.run(this.#t.bind(this)), this.signals.run(this.#s.bind(this)), this.signals.run(this.#i.bind(this));
8116
8123
  }
8117
8124
  #t(n) {
8118
8125
  if (!n.get(this.enabled)) return;
@@ -8122,7 +8129,7 @@ class nu {
8122
8129
  }
8123
8130
  const s = n.get(this.connection);
8124
8131
  if (!s) return;
8125
- const i = n.get(this.path);
8132
+ const i = n.get(this.name);
8126
8133
  if (i === void 0) return;
8127
8134
  const o = s.announced(i);
8128
8135
  n.cleanup(() => o.close()), n.spawn(async () => {
@@ -8140,7 +8147,7 @@ class nu {
8140
8147
  #s(n) {
8141
8148
  const t = n.getAll([this.enabled, this.#e, this.connection]);
8142
8149
  if (!t) return;
8143
- const [r, s, i] = t, o = n.get(this.path);
8150
+ const [r, s, i] = t, o = n.get(this.name);
8144
8151
  if (o === void 0) return;
8145
8152
  const a = i.consume(o);
8146
8153
  n.cleanup(() => a.close()), n.set(this.#n, a);
@@ -8158,10 +8165,10 @@ class nu {
8158
8165
  for (; ; ) {
8159
8166
  const t = await Ua(n);
8160
8167
  if (!t) break;
8161
- console.debug("received catalog", this.path.peek(), t), this.#r.set(t), this.status.set("live");
8168
+ console.debug("received catalog", this.name.peek(), t), this.#r.set(t), this.status.set("live");
8162
8169
  }
8163
8170
  } catch (t) {
8164
- console.warn("error fetching catalog", this.path.peek(), t);
8171
+ console.warn("error fetching catalog", this.name.peek(), t);
8165
8172
  } finally {
8166
8173
  this.#r.set(void 0), this.status.set("offline");
8167
8174
  }
@@ -8189,4 +8196,4 @@ export {
8189
8196
  Kc as m,
8190
8197
  At as t
8191
8198
  };
8192
- //# sourceMappingURL=broadcast-CSXy8QiX.js.map
8199
+ //# sourceMappingURL=broadcast-DhcOJtcZ.js.map