@vindral/web-sdk 4.8.2-9-gec246501 → 4.8.3

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,9 +1,7 @@
1
- import { t as e } from "./CFqytvUK.js";
2
- import { t } from "./CuYn2z5X.js";
3
- import { t as n } from "./DJNS7hc2.js";
4
- import { t as r } from "./CXMDq12B.js";
5
- import { t as i } from "./2sSTdNyC.js";
6
- //#region ../../libs/wasm-decoders/src/opus/wasm/opus.js
1
+ import { F as e, P as t } from "./CnefSzun.js";
2
+ import { n, t as r } from "./DvtbAkGW.js";
3
+ import { l as i } from "./BeCY4GvT.js";
4
+ // ../../libs/wasm-decoders/src/opus/wasm/opus.js
7
5
  var a = (function() {
8
6
  var e = typeof document < "u" && document.currentScript ? document.currentScript.src : void 0;
9
7
  return (function(t) {
@@ -206,21 +204,21 @@ var a = (function() {
206
204
  });
207
205
  })(), o, s = /* @__PURE__ */ function(e) {
208
206
  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;
209
- }(s || {}), c = class t {
210
- constructor(n, r, i) {
211
- 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", () => {
207
+ }(s || {}), c = class e {
208
+ constructor(t, r, i) {
209
+ n(this, "opusModule", void 0), n(this, "decoderInstance", void 0), n(this, "opusBufferPointer", void 0), n(this, "pcmBufferPointer", void 0), n(this, "channels", void 0), n(this, "pcmBufferByteSize", () => e.MAX_SAMPLES * this.channels * Float32Array.BYTES_PER_ELEMENT), n(this, "unload", () => {
212
210
  this.opusModule._free(this.opusBufferPointer), this.opusModule._free(this.pcmBufferPointer), this.opusModule._opus_decoder_destroy(this.decoderInstance);
213
- }), e(this, "decode", (e) => {
214
- if (e.byteLength > t.MAX_OPUS_BUFFER) throw Error(`Opus packet too large (${e.byteLength} bytes), max ${t.MAX_OPUS_BUFFER} bytes`);
215
- this.opusModule.HEAPU8.set(e, this.opusBufferPointer);
216
- let n = this.opusModule._opus_decode_float(this.decoderInstance, this.opusBufferPointer, e.byteLength, this.pcmBufferPointer, t.MAX_SAMPLES, 0);
211
+ }), n(this, "decode", (t) => {
212
+ if (t.byteLength > e.MAX_OPUS_BUFFER) throw Error(`Opus packet too large (${t.byteLength} bytes), max ${e.MAX_OPUS_BUFFER} bytes`);
213
+ this.opusModule.HEAPU8.set(t, this.opusBufferPointer);
214
+ let n = this.opusModule._opus_decode_float(this.decoderInstance, this.opusBufferPointer, t.byteLength, this.pcmBufferPointer, e.MAX_SAMPLES, 0);
217
215
  if (n < 0) throw Error(`${s[n]} (${n})`);
218
216
  let r = this.pcmBufferPointer / Float32Array.BYTES_PER_ELEMENT;
219
217
  return this.opusModule.HEAPF32.subarray(r, r + n * this.channels);
220
- }), 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());
218
+ }), this.opusModule = t, this.channels = i, this.decoderInstance = this.opusModule._opus_decoder_create(r, i, 0), this.opusBufferPointer = this.opusModule._malloc(e.MAX_OPUS_BUFFER), this.pcmBufferPointer = this.opusModule._malloc(this.pcmBufferByteSize());
221
219
  }
222
220
  };
223
- o = c, e(c, "MAX_OPUS_BUFFER", 16384), e(c, "MAX_SAMPLES", 6 * 960), e(c, "create", function() {
221
+ o = c, n(c, "MAX_OPUS_BUFFER", 16384), n(c, "MAX_SAMPLES", 5760), n(c, "create", function() {
224
222
  var e = r(function* (e, t) {
225
223
  return new o(yield a(), e, t);
226
224
  });
@@ -228,13 +226,12 @@ o = c, e(c, "MAX_OPUS_BUFFER", 16384), e(c, "MAX_SAMPLES", 6 * 960), e(c, "creat
228
226
  return e.apply(this, arguments);
229
227
  };
230
228
  }());
231
- //#endregion
232
- //#region ../../libs/web-sdk/src/decoders/OpusDecoderContext.ts
229
+ // ../../libs/web-sdk/src/decoders/OpusDecoderContext.ts
233
230
  var l, u = class {
234
231
  constructor(r) {
235
- e(this, "decodedSamples", []), e(this, "decoder", void 0), e(this, "errors", new n(10)), e(this, "unload", () => {
232
+ n(this, "decodedSamples", []), n(this, "decoder", void 0), n(this, "errors", new t(10)), n(this, "unload", () => {
236
233
  this.decoder.unload();
237
- }), e(this, "enqueue", (e) => {
234
+ }), n(this, "enqueue", (e) => {
238
235
  try {
239
236
  let t = performance.now(), n = this.decoder.decode(new Uint8Array(e.data));
240
237
  this.decodedSamples.push(i(i({}, e), {}, {
@@ -251,13 +248,13 @@ var l, u = class {
251
248
  } catch (e) {
252
249
  e instanceof Error && this.errors.push(e);
253
250
  }
254
- }), e(this, "initSegment", t), e(this, "take", () => this.decodedSamples.shift()), this.decoder = r;
251
+ }), n(this, "initSegment", e), n(this, "take", () => this.decodedSamples.shift()), this.decoder = r;
255
252
  }
256
253
  error() {
257
254
  return this.errors.pop();
258
255
  }
259
256
  };
260
- l = u, e(u, "create", function() {
257
+ l = u, n(u, "create", function() {
261
258
  var e = r(function* (e, t) {
262
259
  return new l(yield c.create(e, t));
263
260
  });
@@ -265,5 +262,4 @@ l = u, e(u, "create", function() {
265
262
  return e.apply(this, arguments);
266
263
  };
267
264
  }());
268
- //#endregion
269
265
  export { u as OpusDecoderContext };
@@ -1,28 +1,27 @@
1
- import { t as e } from "./CFqytvUK.js";
2
- import { t } from "./CXMDq12B.js";
3
- import { n, r } from "./Wh46-8RX.js";
4
- //#region ../../libs/cast-sender/src/CastSender.ts
5
- var i = 1e4, a = "CastSender was unloaded before the Google Cast SDK finished initializing", o = class extends r {
6
- constructor(r) {
1
+ import { n as e, r as t } from "./Bz5OiWeK.js";
2
+ import { n, t as r } from "./DvtbAkGW.js";
3
+ // ../../libs/cast-sender/src/CastSender.ts
4
+ var i = 1e4, a = "CastSender was unloaded before the Google Cast SDK finished initializing", o = class extends t {
5
+ constructor(t) {
7
6
  var o;
8
- super(), o = this, e(this, "state", "not casting"), e(this, "config", void 0), e(this, "unloaded", !1), e(this, "logger", n.get().createContext("CastSender")), e(this, "devicesAvailable", void 0), e(this, "updateAuthenticationToken", (e) => {
7
+ super(), o = this, n(this, "state", "not casting"), n(this, "config", void 0), n(this, "unloaded", !1), n(this, "logger", e.get().createContext("CastSender")), n(this, "devicesAvailable", void 0), n(this, "updateAuthenticationToken", (e) => {
9
8
  this.config && (this.config.options.authenticationToken = e, this.send({
10
9
  type: "updateAuthToken",
11
10
  token: e
12
11
  }));
13
- }), e(this, "unload", () => {
12
+ }), n(this, "unload", () => {
14
13
  var e;
15
14
  this.unloaded = !0, (e = this.getSession()) == null || e.removeMessageListener("urn:x-cast:com.vindral.castdata", this.onMessage), this.devicesAvailable && this.emit("devices available", !1), this.devicesAvailable = void 0;
16
- }), e(this, "init", t(function* () {
15
+ }), n(this, "init", r(function* () {
17
16
  return new Promise((e, t) => {
18
17
  let n = !1, r = setTimeout(() => {
19
18
  n = !0, t(/* @__PURE__ */ Error(`Timed out after ${i} ms waiting for the Google Cast SDK`));
20
19
  }, i);
21
20
  window.__onGCastApiAvailable = (i) => {
22
- if (clearTimeout(r), o.unloaded) return t(Error(a));
21
+ if (clearTimeout(r), o.unloaded) return t(/* @__PURE__ */ Error(a));
23
22
  if (!i) return t(/* @__PURE__ */ Error("The Google Cast SDK reported the Cast API as unavailable"));
24
23
  setTimeout(() => {
25
- if (o.unloaded) return t(Error(a));
24
+ if (o.unloaded) return t(/* @__PURE__ */ Error(a));
26
25
  try {
27
26
  o.onGCastApiAvailable(), e();
28
27
  } catch (e) {
@@ -32,16 +31,16 @@ var i = 1e4, a = "CastSender was unloaded before the Google Cast SDK finished in
32
31
  }, 1e3);
33
32
  }, o.castLibrariesAdded() && window.cast ? window.__onGCastApiAvailable(!0) : o.verifyCastLibraries();
34
33
  });
35
- })), e(this, "start", t(function* () {
34
+ })), n(this, "start", r(function* () {
36
35
  var e;
37
36
  yield (e = o.getInstance()) == null ? void 0 : e.requestSession();
38
- })), e(this, "stop", () => {
37
+ })), n(this, "stop", () => {
39
38
  var e;
40
39
  (e = this.getSession()) == null || e.endSession(!0);
41
- }), e(this, "getReceiverName", () => {
40
+ }), n(this, "getReceiverName", () => {
42
41
  var e;
43
42
  return ((e = this.getSession()) == null || (e = e.getCastDevice()) == null ? void 0 : e.friendlyName) || void 0;
44
- }), e(this, "onGCastApiAvailable", () => {
43
+ }), n(this, "onGCastApiAvailable", () => {
45
44
  var e;
46
45
  let t = this.getInstance();
47
46
  if (!t) throw "cast context should exist";
@@ -53,34 +52,31 @@ var i = 1e4, a = "CastSender was unloaded before the Google Cast SDK finished in
53
52
  }), t.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED, this.onSessionStateChanged), t.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED, this.onCastStateChanged), this.updateDevicesAvailable(t.getCastState()), n === cast.framework.SessionState.SESSION_STARTED && setTimeout(() => {
54
53
  this.state = "casting", this.emit("resumed");
55
54
  });
56
- }), e(this, "send", (e) => {
55
+ }), n(this, "send", (e) => {
57
56
  var t;
58
57
  (t = this.getSession()) == null || t.sendMessage("urn:x-cast:com.vindral.castdata", e);
59
- }), e(this, "onMessage", (e, t) => {
58
+ }), n(this, "onMessage", (e, t) => {
60
59
  if (e === "urn:x-cast:com.vindral.castdata") try {
61
60
  let e = JSON.parse(t);
62
61
  switch (e.type) {
63
62
  case "metadata":
64
63
  this.emit("metadata", e.metadata);
65
64
  break;
66
- case "serverWallclockTime":
67
- this.emit("server wallclock time", e.serverWallclockTime);
68
- break;
69
- default: break;
65
+ case "serverWallclockTime": this.emit("server wallclock time", e.serverWallclockTime);
70
66
  }
71
67
  } catch (e) {}
72
- }), e(this, "onSessionStarted", () => {
68
+ }), n(this, "onSessionStarted", () => {
73
69
  var e;
74
70
  (e = this.getSession()) == null || e.addMessageListener("urn:x-cast:com.vindral.castdata", this.onMessage), this.send({
75
71
  type: "start",
76
72
  config: this.config
77
73
  });
78
- }), e(this, "onCastStateChanged", (e) => {
74
+ }), n(this, "onCastStateChanged", (e) => {
79
75
  this.unloaded || this.updateDevicesAvailable(e.castState);
80
- }), e(this, "updateDevicesAvailable", (e) => {
76
+ }), n(this, "updateDevicesAvailable", (e) => {
81
77
  let t = e !== cast.framework.CastState.NO_DEVICES_AVAILABLE;
82
78
  t !== this.devicesAvailable && (this.devicesAvailable = t, this.emit("devices available", t));
83
- }), e(this, "onSessionStateChanged", (e) => {
79
+ }), n(this, "onSessionStateChanged", (e) => {
84
80
  if (!this.unloaded) switch (e.sessionState) {
85
81
  case cast.framework.SessionState.SESSION_START_FAILED:
86
82
  this.state = "not casting", this.emit("failed");
@@ -95,22 +91,21 @@ var i = 1e4, a = "CastSender was unloaded before the Google Cast SDK finished in
95
91
  case cast.framework.SessionState.SESSION_STARTED:
96
92
  this.onSessionStarted(), this.state = "casting", this.emit("connected");
97
93
  break;
98
- case cast.framework.SessionState.SESSION_STARTING: break;
99
- default: break;
94
+ case cast.framework.SessionState.SESSION_STARTING:
100
95
  }
101
- }), e(this, "getInstance", () => {
96
+ }), n(this, "getInstance", () => {
102
97
  var e;
103
98
  return (e = window.cast) == null ? void 0 : e.framework.CastContext.getInstance();
104
- }), e(this, "getSession", () => {
99
+ }), n(this, "getSession", () => {
105
100
  var e;
106
101
  return (e = this.getInstance()) == null ? void 0 : e.getCurrentSession();
107
- }), e(this, "castLibrariesAdded", () => !!(document.querySelector("#vindralCastFrameworkLib") && document.querySelector("#vindralCastSenderLib"))), e(this, "verifyCastLibraries", () => {
102
+ }), n(this, "castLibrariesAdded", () => !!(document.querySelector("#vindralCastFrameworkLib") && document.querySelector("#vindralCastSenderLib"))), n(this, "verifyCastLibraries", () => {
108
103
  if (this.castLibrariesAdded()) return;
109
104
  let e = document.createElement("script");
110
105
  e.type = "text/javascript", e.id = "vindralCastFrameworkLib", e.src = "//www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js", document.head.appendChild(e);
111
106
  let t = document.createElement("script");
112
107
  t.type = "text/javascript", t.id = "vindralCastSenderLib", t.src = "//www.gstatic.com/cv/js/sender/v1/cast_sender.js", document.head.appendChild(t);
113
- }), this.config = r;
108
+ }), this.config = t;
114
109
  }
115
110
  get casting() {
116
111
  return this.state === "casting";
@@ -144,5 +139,4 @@ var i = 1e4, a = "CastSender was unloaded before the Google Cast SDK finished in
144
139
  }));
145
140
  }
146
141
  };
147
- //#endregion
148
142
  export { o as t };
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.115.0/helpers/typeof.js
1
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
2
2
  function e(t) {
3
3
  "@babel/helpers - typeof";
4
4
  return e = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
@@ -7,8 +7,7 @@ function e(t) {
7
7
  return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
8
8
  }, e(t);
9
9
  }
10
- //#endregion
11
- //#region \0@oxc-project+runtime@0.115.0/helpers/toPrimitive.js
10
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
12
11
  function t(t, n) {
13
12
  if (e(t) != "object" || !t) return t;
14
13
  var r = t[Symbol.toPrimitive];
@@ -19,14 +18,12 @@ function t(t, n) {
19
18
  }
20
19
  return (n === "string" ? String : Number)(t);
21
20
  }
22
- //#endregion
23
- //#region \0@oxc-project+runtime@0.115.0/helpers/toPropertyKey.js
21
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
24
22
  function n(n) {
25
23
  var r = t(n, "string");
26
24
  return e(r) == "symbol" ? r : r + "";
27
25
  }
28
- //#endregion
29
- //#region \0@oxc-project+runtime@0.115.0/helpers/defineProperty.js
26
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
30
27
  function r(e, t, r) {
31
28
  return (t = n(t)) in e ? Object.defineProperty(e, t, {
32
29
  value: r,
@@ -35,5 +32,29 @@ function r(e, t, r) {
35
32
  writable: !0
36
33
  }) : e[t] = r, e;
37
34
  }
38
- //#endregion
39
- export { r as t };
35
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/asyncToGenerator.js
36
+ function i(e, t, n, r, i, a, o) {
37
+ try {
38
+ var s = e[a](o), c = s.value;
39
+ } catch (e) {
40
+ n(e);
41
+ return;
42
+ }
43
+ s.done ? t(c) : Promise.resolve(c).then(r, i);
44
+ }
45
+ function a(e) {
46
+ return function() {
47
+ var t = this, n = arguments;
48
+ return new Promise(function(r, a) {
49
+ var o = e.apply(t, n);
50
+ function s(e) {
51
+ i(o, r, a, s, c, "next", e);
52
+ }
53
+ function c(e) {
54
+ i(o, r, a, s, c, "throw", e);
55
+ }
56
+ s(void 0);
57
+ });
58
+ };
59
+ }
60
+ export { r as n, a as t };