@vindral/web-sdk 4.2.0-9-g20d8006e → 4.2.1

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,6 +1,6 @@
1
1
  import { n as e, t } from "./BsfwXDui.js";
2
2
  import { a as n, i as r, n as i, r as a, t as o } from "./B7hT-BKr.js";
3
- import { g as s, h as c, n as l, r as ee, t as u, v as te, y as ne } from "./wVqDCoXH.js";
3
+ import { g as s, h as c, n as l, r as ee, t as u, v as te, y as ne } from "./CF-41rJe.js";
4
4
  import { t as d } from "./RxoWWyzp.js";
5
5
  //#region \0rolldown/runtime.js
6
6
  var f = Object.defineProperty, p = (e, t) => {
@@ -1,6 +1,6 @@
1
1
  import { n as e, t } from "./BsfwXDui.js";
2
2
  import { M as n, v as r } from "./C01DcfYu.js";
3
- import { t as i } from "./B4Xt-UHG.js";
3
+ import { t as i } from "./DrWNJwZx.js";
4
4
  import { t as a } from "./RxoWWyzp.js";
5
5
  //#region ../../libs/wasm-decoders/src/opus/wasm/opus.js
6
6
  var o = (function() {
@@ -207,19 +207,19 @@ var o = (function() {
207
207
  return e[e.OK = 0] = "OK", e[e["Bad argument"] = -1] = "Bad argument", e[e["Buffer too small"] = -2] = "Buffer too small", e[e["Internal error"] = -3] = "Internal error", e[e["Invalid packet"] = -4] = "Invalid packet", e[e.Unimplemented = -5] = "Unimplemented", e[e["Invalid state"] = -6] = "Invalid state", e[e["Memory allocation fail"] = -7] = "Memory allocation fail", e;
208
208
  }(c || {}), l = class t {
209
209
  constructor(n, r, i) {
210
- e(this, "opusModule", void 0), e(this, "decoderInstance", void 0), e(this, "opusBufferPointer", void 0), e(this, "pcmBufferPointer", void 0), e(this, "opus", void 0), e(this, "pcm", void 0), e(this, "channels", void 0), e(this, "sampleRate", void 0), e(this, "pcmBufferByteSize", () => t.MAX_SAMPLES * this.channels * Float32Array.BYTES_PER_ELEMENT), e(this, "unload", () => {
210
+ e(this, "opusModule", void 0), e(this, "decoderInstance", void 0), e(this, "opusBufferPointer", void 0), e(this, "pcmBufferPointer", void 0), e(this, "channels", void 0), e(this, "pcmBufferByteSize", () => t.MAX_SAMPLES * this.channels * Float32Array.BYTES_PER_ELEMENT), e(this, "unload", () => {
211
211
  this.opusModule._free(this.opusBufferPointer), this.opusModule._free(this.pcmBufferPointer), this.opusModule._opus_decoder_destroy(this.decoderInstance);
212
212
  }), e(this, "decode", (e) => {
213
- this.opusModule.HEAPU8.set(new Uint8Array(e), this.opusBufferPointer);
213
+ if (e.byteLength > t.MAX_OPUS_BUFFER) throw Error(`Opus packet too large (${e.byteLength} bytes), max ${t.MAX_OPUS_BUFFER} bytes`);
214
+ this.opusModule.HEAPU8.set(e, this.opusBufferPointer);
214
215
  let n = this.opusModule._opus_decode_float(this.decoderInstance, this.opusBufferPointer, e.byteLength, this.pcmBufferPointer, t.MAX_SAMPLES, 0);
215
- if (n < 0) throw Error(c[n]);
216
- return this.pcm.subarray(0, n * this.channels);
217
- }), this.opusModule = n, this.channels = i, this.sampleRate = r, this.decoderInstance = this.opusModule._opus_decoder_create(r, i, 0), this.opusBufferPointer = this.opusModule._malloc(t.MAX_OPUS_BUFFER), this.opus = this.opusModule.HEAPU8.subarray(this.opusBufferPointer, this.opusBufferPointer + t.MAX_OPUS_BUFFER), this.pcmBufferPointer = this.opusModule._malloc(this.pcmBufferByteSize());
218
- let a = this.pcmBufferPointer / Float32Array.BYTES_PER_ELEMENT;
219
- this.pcm = this.opusModule.HEAPF32.subarray(a, a + this.pcmBufferByteSize() / Float32Array.BYTES_PER_ELEMENT);
216
+ if (n < 0) throw Error(`${c[n]} (${n})`);
217
+ let r = this.pcmBufferPointer / Float32Array.BYTES_PER_ELEMENT;
218
+ return this.opusModule.HEAPF32.subarray(r, r + n * this.channels);
219
+ }), this.opusModule = n, this.channels = i, this.decoderInstance = this.opusModule._opus_decoder_create(r, i, 0), this.opusBufferPointer = this.opusModule._malloc(t.MAX_OPUS_BUFFER), this.pcmBufferPointer = this.opusModule._malloc(this.pcmBufferByteSize());
220
220
  }
221
221
  };
222
- s = l, e(l, "MAX_OPUS_BUFFER", 1e3 * 1e3), e(l, "MAX_SAMPLES", 6 * 960), e(l, "create", function() {
222
+ s = l, e(l, "MAX_OPUS_BUFFER", 16384), e(l, "MAX_SAMPLES", 6 * 960), e(l, "create", function() {
223
223
  var e = t(function* (e, t) {
224
224
  return new s(yield o(), e, t);
225
225
  });
@@ -235,7 +235,7 @@ var u, d = class {
235
235
  this.decoder.unload();
236
236
  }), e(this, "enqueue", (e) => {
237
237
  try {
238
- let t = Date.now(), n = this.decoder.decode(e.data);
238
+ let t = Date.now(), n = this.decoder.decode(new Uint8Array(e.data));
239
239
  this.decodedSamples.push(a(a({}, e), {}, {
240
240
  type: "audio",
241
241
  format: "f32",
@@ -86,7 +86,7 @@ function m(e) {
86
86
  }
87
87
  function h(e) {
88
88
  if (e === null) return;
89
- let t = e.split(",").map((e) => e.trim()).filter((e) => e === "h264" || e === "av1");
89
+ let t = e.split(",").map((e) => e.trim()).filter((e) => e === "h264" || e === "h265" || e === "av1");
90
90
  if (t.length !== 0) return t;
91
91
  }
92
92
  function g(e) {
@@ -111,7 +111,7 @@ function _(e) {
111
111
  function v(e) {
112
112
  if (e === null) return;
113
113
  let t = parseFloat(e);
114
- return isNaN(t) ? void 0 : t;
114
+ return Number.isNaN(t) ? void 0 : t;
115
115
  }
116
116
  function y(e) {
117
117
  return typeof e == "string";
@@ -1,5 +1,5 @@
1
1
  import { n as e, t } from "./BsfwXDui.js";
2
- import { t as n } from "./B4Xt-UHG.js";
2
+ import { t as n } from "./DrWNJwZx.js";
3
3
  import { t as r } from "./RxoWWyzp.js";
4
4
  import { i, n as a, t as o } from "./Bt-ONXfO.js";
5
5
  //#region ../../libs/web-sdk/src/decoders/PendingSampleMap.ts
@@ -8,27 +8,30 @@ var s = class {
8
8
  e(this, "map", /* @__PURE__ */ new Map());
9
9
  }
10
10
  enqueue(e, t) {
11
- let n = this.map.get(e);
12
- n ? n.push(t) : this.map.set(e, [t]);
11
+ let r = this.map.get(e);
12
+ if (r) r.push(t);
13
+ else {
14
+ let r = new n(Infinity);
15
+ r.push(t), this.map.set(e, r);
16
+ }
13
17
  }
14
18
  dequeue(e) {
15
19
  let t = this.map.get(e);
16
- if (t && t.length > 0) {
17
- let n = t.shift();
18
- return t.length === 0 && this.map.delete(e), n;
19
- }
20
+ if (!t) return;
21
+ let n = t.pop();
22
+ return t.isEmpty() && this.map.delete(e), n;
20
23
  }
21
24
  dequeueWithFallback(e) {
22
25
  let t = this.dequeue(e);
23
26
  if (t !== void 0) return t;
24
- for (let [e, t] of this.map) if (t.length > 0) {
25
- let n = t.shift();
26
- return t.length === 0 && this.map.delete(e), n;
27
+ for (let [e, t] of this.map) {
28
+ let n = t.pop();
29
+ if (t.isEmpty() && this.map.delete(e), n !== void 0) return n;
27
30
  }
28
31
  }
29
32
  removeLast(e) {
30
33
  let t = this.map.get(e);
31
- !t || t.length === 0 || (t.pop(), t.length === 0 && this.map.delete(e));
34
+ t && (t.popLast(), t.isEmpty() && this.map.delete(e));
32
35
  }
33
36
  clear() {
34
37
  this.map.clear();
@@ -45,7 +45,7 @@ var r = class extends n {
45
45
  var e;
46
46
  let t = this.getInstance();
47
47
  if (!t) throw "cast context should exist";
48
- let n = t.getSessionState(), r = ((e = this.config) == null ? void 0 : e.receiverApplicationId) || "A5452297";
48
+ let n = t.getSessionState(), r = ((e = this.config) == null ? void 0 : e.receiverApplicationId) || void 0;
49
49
  t.setOptions({
50
50
  receiverApplicationId: r,
51
51
  autoJoinPolicy: chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED,
@@ -15,6 +15,7 @@ var i = (e) => {
15
15
  }, a = (e) => {
16
16
  switch (e) {
17
17
  case "h264":
18
+ case "h265":
18
19
  case "av1": return "video";
19
20
  case "aac":
20
21
  case "opus":
@@ -27,6 +28,7 @@ function o(e) {
27
28
  if (e.startsWith("opus")) return "opus";
28
29
  if (e.startsWith("mp4a")) return "aac";
29
30
  if (e.startsWith("avc1")) return "h264";
31
+ if (e.startsWith("hvc1") || e.startsWith("hev1")) return "h265";
30
32
  if (e.startsWith("av01")) return "av1";
31
33
  if (e.startsWith("webvtt")) return "webvtt";
32
34
  }
package/DrWNJwZx.js ADDED
@@ -0,0 +1,35 @@
1
+ import { n as e } from "./BsfwXDui.js";
2
+ //#region ../../libs/utils/src/Fifo.ts
3
+ var t = class {
4
+ constructor(t = 50) {
5
+ e(this, "maxSize", void 0), e(this, "values", []), e(this, "start", 0), e(this, "size", () => this.values.length - this.start), e(this, "compact", () => {
6
+ if (this.start !== 0) {
7
+ if (this.start >= this.values.length) {
8
+ this.values = [], this.start = 0;
9
+ return;
10
+ }
11
+ this.start < 32 && this.start * 2 < this.values.length || (this.values = this.values.slice(this.start), this.start = 0);
12
+ }
13
+ }), e(this, "push", (e) => {
14
+ this.isFull() && (this.start++, this.compact()), this.values.push(e);
15
+ }), e(this, "clear", () => {
16
+ this.values = [], this.start = 0;
17
+ }), e(this, "pop", () => {
18
+ if (this.isEmpty()) return;
19
+ let e = this.values[this.start];
20
+ return this.start++, this.compact(), e;
21
+ }), e(this, "popLast", () => {
22
+ if (this.isEmpty()) return;
23
+ let e = this.values.pop();
24
+ return this.start >= this.values.length && this.clear(), e;
25
+ }), e(this, "peekFirst", () => this.isEmpty() ? void 0 : this.values[this.start]), e(this, "peekLast", () => this.isEmpty() ? void 0 : this.values[this.values.length - 1]), e(this, "isFull", () => this.size() >= this.maxSize), e(this, "isEmpty", () => this.size() === 0), e(this, "items", () => this.start === 0 ? this.values : this.values.slice(this.start)), e(this, "filterPop", (e) => {
26
+ for (; !this.isEmpty();) {
27
+ let t = this.peekFirst();
28
+ if (t === void 0 || e(t)) return;
29
+ this.pop();
30
+ }
31
+ }), this.maxSize = t;
32
+ }
33
+ };
34
+ //#endregion
35
+ export { t };