@vindral/web-sdk 4.2.0-5-g7d2f2421 → 4.2.0-7-g7d6ca07f

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.
package/DTteQSVE.js ADDED
@@ -0,0 +1,65 @@
1
+ //#region \0@oxc-project+runtime@0.115.0/helpers/typeof.js
2
+ function e(t) {
3
+ "@babel/helpers - typeof";
4
+ return e = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
5
+ return typeof e;
6
+ } : function(e) {
7
+ return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
8
+ }, e(t);
9
+ }
10
+ //#endregion
11
+ //#region \0@oxc-project+runtime@0.115.0/helpers/toPrimitive.js
12
+ function t(t, n) {
13
+ if (e(t) != "object" || !t) return t;
14
+ var r = t[Symbol.toPrimitive];
15
+ if (r !== void 0) {
16
+ var i = r.call(t, n || "default");
17
+ if (e(i) != "object") return i;
18
+ throw TypeError("@@toPrimitive must return a primitive value.");
19
+ }
20
+ return (n === "string" ? String : Number)(t);
21
+ }
22
+ //#endregion
23
+ //#region \0@oxc-project+runtime@0.115.0/helpers/toPropertyKey.js
24
+ function n(n) {
25
+ var r = t(n, "string");
26
+ return e(r) == "symbol" ? r : r + "";
27
+ }
28
+ //#endregion
29
+ //#region \0@oxc-project+runtime@0.115.0/helpers/defineProperty.js
30
+ function r(e, t, r) {
31
+ return (t = n(t)) in e ? Object.defineProperty(e, t, {
32
+ value: r,
33
+ enumerable: !0,
34
+ configurable: !0,
35
+ writable: !0
36
+ }) : e[t] = r, e;
37
+ }
38
+ //#endregion
39
+ //#region \0@oxc-project+runtime@0.115.0/helpers/asyncToGenerator.js
40
+ function i(e, t, n, r, i, a, o) {
41
+ try {
42
+ var s = e[a](o), c = s.value;
43
+ } catch (e) {
44
+ n(e);
45
+ return;
46
+ }
47
+ s.done ? t(c) : Promise.resolve(c).then(r, i);
48
+ }
49
+ function a(e) {
50
+ return function() {
51
+ var t = this, n = arguments;
52
+ return new Promise(function(r, a) {
53
+ var o = e.apply(t, n);
54
+ function s(e) {
55
+ i(o, r, a, s, c, "next", e);
56
+ }
57
+ function c(e) {
58
+ i(o, r, a, s, c, "throw", e);
59
+ }
60
+ s(void 0);
61
+ });
62
+ };
63
+ }
64
+ //#endregion
65
+ export { r as n, a as t };
package/Dexfb10F.js ADDED
@@ -0,0 +1,25 @@
1
+ import { n as e } from "./DTteQSVE.js";
2
+ //#region \0@oxc-project+runtime@0.115.0/helpers/objectSpread2.js
3
+ function t(e, t) {
4
+ var n = Object.keys(e);
5
+ if (Object.getOwnPropertySymbols) {
6
+ var r = Object.getOwnPropertySymbols(e);
7
+ t && (r = r.filter(function(t) {
8
+ return Object.getOwnPropertyDescriptor(e, t).enumerable;
9
+ })), n.push.apply(n, r);
10
+ }
11
+ return n;
12
+ }
13
+ function n(n) {
14
+ for (var r = 1; r < arguments.length; r++) {
15
+ var i = arguments[r] == null ? {} : arguments[r];
16
+ r % 2 ? t(Object(i), !0).forEach(function(t) {
17
+ e(n, t, i[t]);
18
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(n, Object.getOwnPropertyDescriptors(i)) : t(Object(i)).forEach(function(e) {
19
+ Object.defineProperty(n, e, Object.getOwnPropertyDescriptor(i, e));
20
+ });
21
+ }
22
+ return n;
23
+ }
24
+ //#endregion
25
+ export { n as t };
package/DpGTMfRs.js ADDED
@@ -0,0 +1,146 @@
1
+ import { n as e, t } from "./DTteQSVE.js";
2
+ import { t as n } from "./CodtCCWB.js";
3
+ import { t as r } from "./Dexfb10F.js";
4
+ import { i, n as a, t as o } from "./BjFDlUkI.js";
5
+ //#region ../../libs/web-sdk/src/decoders/PendingSampleMap.ts
6
+ var s = class {
7
+ constructor() {
8
+ e(this, "map", /* @__PURE__ */ new Map());
9
+ }
10
+ enqueue(e, t) {
11
+ let n = this.map.get(e);
12
+ n ? n.push(t) : this.map.set(e, [t]);
13
+ }
14
+ dequeue(e) {
15
+ 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
+ }
21
+ dequeueWithFallback(e) {
22
+ let t = this.dequeue(e);
23
+ 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
+ }
28
+ }
29
+ removeLast(e) {
30
+ let t = this.map.get(e);
31
+ !t || t.length === 0 || (t.pop(), t.length === 0 && this.map.delete(e));
32
+ }
33
+ clear() {
34
+ this.map.clear();
35
+ }
36
+ }, c, l = globalThis, u = class {
37
+ constructor(c) {
38
+ var l = this;
39
+ e(this, "decodedSamples", []), e(this, "decoder", null), e(this, "logger", void 0), e(this, "initSegments", /* @__PURE__ */ new Map()), e(this, "previousSample", void 0), e(this, "previousCodec", void 0), e(this, "pendingSamples", new s()), e(this, "errors", new n(10)), e(this, "resetDecoderState", () => {
40
+ this.pendingSamples.clear(), this.previousSample = void 0, this.previousCodec = void 0;
41
+ }), e(this, "ensureDecoder", () => ((!this.decoder || this.decoder.state === "closed") && (this.decoder = this.createDecoder()), this.decoder)), e(this, "createDecoder", () => new AudioDecoder({
42
+ output: (e) => {
43
+ let t = this.pendingSamples.dequeueWithFallback(e.timestamp);
44
+ if (!t) {
45
+ e.close();
46
+ return;
47
+ }
48
+ let { sample: n, decodeStartTime: i } = t;
49
+ try {
50
+ let t = e.numberOfFrames, a = e.numberOfChannels, o = e.sampleRate, s = e.timestamp, c = e.duration, l = new Float32Array(t * a);
51
+ e.copyTo(l, {
52
+ planeIndex: 0,
53
+ format: "f32"
54
+ });
55
+ let u = Math.round(s * n.timescale / 1e6), d = typeof c == "number" && Number.isFinite(c) ? Math.max(0, Math.round(c * n.timescale / 1e6)) : n.duration, f = r(r({}, n), {}, {
56
+ timestamp: u,
57
+ duration: d,
58
+ type: "audio",
59
+ format: "f32",
60
+ data: l,
61
+ sampleRate: o,
62
+ channels: a,
63
+ statistics: {
64
+ decodeTime: Math.max(performance.now() - i, 0),
65
+ transportTimeFromWorker: 0,
66
+ transportTimeToWorker: 0,
67
+ samplesInBatch: 1
68
+ }
69
+ });
70
+ this.decodedSamples.push(f);
71
+ } finally {
72
+ e.close();
73
+ }
74
+ },
75
+ error: (e) => {
76
+ this.logger.error("Decoder error:", e.name, e.message), this.resetDecoderState(), this.errors.push(e);
77
+ }
78
+ })), e(this, "buildCodecString", o), e(this, "getDescription", (e, t) => {
79
+ let n = this.initSegments.get(t.renditionId);
80
+ if (n && n.data.byteLength > 0 && n.codec === e) return n.data;
81
+ if (e === "opus") return a(t.channels, t.sampleRate);
82
+ if (e === "aac") return i(t.channels, t.sampleRate);
83
+ }), e(this, "unload", () => {
84
+ this.decodedSamples = [], this.resetDecoderState(), this.decoder && this.decoder.state !== "closed" && this.decoder.close(), this.decoder = null;
85
+ }), e(this, "initSegment", (e) => {
86
+ this.initSegments.set(e.renditionId, e);
87
+ }), e(this, "enqueue", (e) => {
88
+ var t, n;
89
+ let r = this.ensureDecoder(), i = e.codec, a = ((t = this.previousSample) == null ? void 0 : t.channelId) !== e.channelId, o = ((n = this.previousSample) == null ? void 0 : n.renditionId) !== e.renditionId, s = this.previousCodec !== i;
90
+ if (!this.previousSample || a || o || s) {
91
+ this.previousSample && r.state === "configured" && r.flush().catch((e) => {
92
+ this.logger.warn("Failed to flush before reconfiguration:", e);
93
+ });
94
+ let t = this.buildCodecString(i), n = this.getDescription(i, e), a = {
95
+ codec: t,
96
+ sampleRate: e.sampleRate,
97
+ numberOfChannels: e.channels,
98
+ description: n
99
+ };
100
+ try {
101
+ r.configure(a), this.previousCodec = i;
102
+ } catch (t) {
103
+ this.logger.error(`Failed to configure decoder for ${i} (rendition ${e.renditionId}), dropping sample`, t), this.errors.push(t instanceof Error ? t : /* @__PURE__ */ Error(`Failed to configure decoder for ${i}`)), this.resetDecoderState(), this.ensureDecoder();
104
+ return;
105
+ }
106
+ }
107
+ if (e.timescale <= 0) {
108
+ this.logger.error(`Invalid timescale ${e.timescale} in sample, dropping sample`);
109
+ return;
110
+ }
111
+ this.previousSample = e;
112
+ let c = Math.floor(1e6 * e.timestamp / e.timescale), l = Math.floor(1e6 * e.duration / e.timescale);
113
+ try {
114
+ let t = new EncodedAudioChunk({
115
+ type: "key",
116
+ timestamp: c,
117
+ duration: l > 0 ? l : void 0,
118
+ data: e.data
119
+ });
120
+ this.pendingSamples.enqueue(c, {
121
+ sample: e,
122
+ decodeStartTime: performance.now()
123
+ }), r.decode(t);
124
+ } catch (e) {
125
+ this.logger.error("Failed to decode chunk:", e), this.pendingSamples.removeLast(c), r.state === "closed" && (this.resetDecoderState(), this.ensureDecoder());
126
+ }
127
+ }), e(this, "flush", t(function* () {
128
+ if (l.decoder && l.decoder.state === "configured") try {
129
+ yield l.decoder.flush();
130
+ } catch (e) {
131
+ l.logger.error("Failed to flush decoder:", e), l.resetDecoderState();
132
+ }
133
+ })), e(this, "error", () => this.errors.pop()), e(this, "take", () => this.decodedSamples.shift()), this.logger = c, this.decoder = this.createDecoder();
134
+ }
135
+ };
136
+ c = u, e(u, "isSupported", () => l.AudioDecoder !== void 0), e(u, "create", function() {
137
+ var e = t(function* (e) {
138
+ if (!c.isSupported()) throw Error("WebCodecs AudioDecoder is not supported in this environment");
139
+ return new c(e);
140
+ });
141
+ return function(t) {
142
+ return e.apply(this, arguments);
143
+ };
144
+ }());
145
+ //#endregion
146
+ export { u as WebCodecsAudioDecoderContext };