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