diff --git a/THIRD_PARTY.txt b/THIRD_PARTY.txt
index 5f76c648..59932bd7 100644
--- a/THIRD_PARTY.txt
+++ b/THIRD_PARTY.txt
@@ -1454,9 +1454,9 @@ https://cdn.jsdelivr.net/npm/ngx-bootstrap@18.0.2/datepicker/bs-datepicker.css
https://cdn.jsdelivr.net/npm/ngx-bootstrap@6.2.0/datepicker/bs-datepicker.css
https://cdn.jsdelivr.net/npm/object-assign@4.1.1/index.js
https://cdn.jsdelivr.net/npm/p2p-media-loader-core@0.6.2/build/p2p-media-loader-core.min.js
-https://cdn.jsdelivr.net/npm/p2p-media-loader-core@1.0.5/dist/p2p-media-loader-core.es.min.js
+https://cdn.jsdelivr.net/npm/p2p-media-loader-core@2.0.1/dist/p2p-media-loader-core.es.min.js
https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@0.6.2/build/p2p-media-loader-hlsjs.min.js
-https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@1.0.5/dist/p2p-media-loader-hlsjs.es.min.js
+https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@2.0.1/dist/p2p-media-loader-hlsjs.es.min.js
https://cdn.jsdelivr.net/npm/plyr@3.7.8/dist/plyr.css
https://cdn.jsdelivr.net/npm/plyr@3.7.8/dist/plyr.min.js
https://cdn.jsdelivr.net/npm/raven-js@3.27.2/dist/raven.min.js
diff --git a/modules/internal/targets.js b/modules/internal/targets.js
index 64487a50..a370361c 100644
--- a/modules/internal/targets.js
+++ b/modules/internal/targets.js
@@ -370,7 +370,7 @@ targets.setLastVersion = function (type, version) {
if (type.startsWith('/owl-carousel/2.')) return '2.3.4';
if (type.startsWith('/p2p-media-loader-core') || type.startsWith('/p2p-media-loader-hlsjs')) {
if (helpers.compareVersion('0.6.2', version)) return '0.6.2'; // <= v0.6.2
- return '1.0.5';
+ return '2.0.1';
}
if (type.startsWith('/p5.js/0.')) return '0.10.2';
if (type.startsWith('/p5.js/1.')) return '1.10.0';
diff --git a/pages/updates/updates.html b/pages/updates/updates.html
index 4ed9503a..e9c37c6b 100644
--- a/pages/updates/updates.html
+++ b/pages/updates/updates.html
@@ -31,6 +31,7 @@
instantsearch.css v8.5.0 -> v8.5.1
instantsearch.js v4.74.0 -> v4.74.1
libphonenumber-js v1.11.7 -> v1.11.8
+ p2p-media-loader-core & p2p-media-loader-hlsjs v1.0.5 -> v2.0.1
Improved
diff --git a/resources/p2p-media-loader-core/1.0.5/p2p-media-loader-core.min.jsm b/resources/p2p-media-loader-core/2.0.1/p2p-media-loader-core.min.jsm
similarity index 51%
rename from resources/p2p-media-loader-core/1.0.5/p2p-media-loader-core.min.jsm
rename to resources/p2p-media-loader-core/2.0.1/p2p-media-loader-core.min.jsm
index a390ae11..f154b7cf 100644
--- a/resources/p2p-media-loader-core/1.0.5/p2p-media-loader-core.min.jsm
+++ b/resources/p2p-media-loader-core/2.0.1/p2p-media-loader-core.min.jsm
@@ -1,75 +1,75 @@
-var zn = Object.defineProperty;
-var Vn = (s, t, e) => t in s ? zn(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
-var f = (s, t, e) => Vn(s, typeof t != "symbol" ? t + "" : t, e);
-class R extends Error {
+var qn = Object.defineProperty;
+var Bn = (s, t, e) => t in s ? qn(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
+var d = (s, t, e) => Bn(s, typeof t != "symbol" ? t + "" : t, e);
+class x extends Error {
constructor(e, n) {
super(n);
- f(this, "timestamp");
+ d(this, "timestamp");
this.type = e, this.timestamp = performance.now();
}
}
-class fe extends Error {
+class ae extends Error {
constructor(t) {
super(), this.type = t;
}
}
-class Gn {
+class On {
constructor(t, e, n) {
- f(this, "requestControls");
- f(this, "abortController", new AbortController());
- f(this, "expectedBytesLength");
- f(this, "requestByteRange");
- f(this, "onChunkDownloaded");
+ d(this, "requestControls");
+ d(this, "abortController", new AbortController());
+ d(this, "expectedBytesLength");
+ d(this, "requestByteRange");
+ d(this, "onChunkDownloaded");
this.request = t, this.httpConfig = e, this.onChunkDownloaded = n.getEventDispatcher("onChunkDownloaded");
- const { byteRange: r } = this.request.segment;
- r && (this.requestByteRange = { ...r }), t.loadedBytes !== 0 && (this.requestByteRange = this.requestByteRange ?? { start: 0 }, this.requestByteRange.start = this.requestByteRange.start + t.loadedBytes), this.request.totalBytes && (this.expectedBytesLength = this.request.totalBytes - this.request.loadedBytes), this.requestControls = this.request.start({ downloadSource: "http" }, { abort: () => this.abortController.abort("abort"), notReceivingBytesTimeoutMs: this.httpConfig.httpNotReceivingBytesTimeoutMs }), this.fetch();
+ const { byteRange: i } = this.request.segment;
+ i && (this.requestByteRange = { ...i }), t.loadedBytes !== 0 && (this.requestByteRange = this.requestByteRange ?? { start: 0 }, this.requestByteRange.start = this.requestByteRange.start + t.loadedBytes), this.request.totalBytes && (this.expectedBytesLength = this.request.totalBytes - this.request.loadedBytes), this.requestControls = this.request.start({ downloadSource: "http" }, { abort: () => this.abortController.abort("abort"), notReceivingBytesTimeoutMs: this.httpConfig.httpNotReceivingBytesTimeoutMs }), this.fetch();
}
async fetch() {
var e, n;
const { segment: t } = this.request;
try {
- let r = await ((n = (e = this.httpConfig).httpRequestSetup) == null ? void 0 : n.call(e, t.url, t.byteRange, this.abortController.signal, this.requestByteRange));
- if (!r) {
+ let i = await ((n = (e = this.httpConfig).httpRequestSetup) == null ? void 0 : n.call(e, t.url, t.byteRange, this.abortController.signal, this.requestByteRange));
+ if (!i) {
const h = new Headers(this.requestByteRange ? { Range: `bytes=${this.requestByteRange.start}-${this.requestByteRange.end ?? ""}` } : void 0);
- r = new Request(t.url, { headers: h, signal: this.abortController.signal });
+ i = new Request(t.url, { headers: h, signal: this.abortController.signal });
}
if (this.abortController.signal.aborted) throw new DOMException("Request aborted before request fetch", "AbortError");
- const i = await window.fetch(r);
- if (this.handleResponseHeaders(i), !i.body) return;
+ const r = await window.fetch(i);
+ if (this.handleResponseHeaders(r), !r.body) return;
const { requestControls: o } = this;
o.firstBytesReceived();
- const a = i.body.getReader();
- for await (const h of async function* (g) {
+ const a = r.body.getReader();
+ for await (const h of async function* (u) {
for (; ; ) {
- const { done: d, value: p } = await g.read();
- if (d) break;
- yield p;
+ const { done: c, value: l } = await u.read();
+ if (c) break;
+ yield l;
}
}(a)) this.requestControls.addLoadedChunk(h), this.onChunkDownloaded(h.byteLength, "http");
o.completeOnSuccess();
- } catch (r) {
- this.handleError(r);
+ } catch (i) {
+ this.handleError(i);
}
}
handleResponseHeaders(t) {
- if (!t.ok) throw t.status === 406 ? (this.request.clearLoadedBytes(), new R("http-bytes-mismatch", t.statusText)) : new R("http-error", t.statusText);
+ if (!t.ok) throw t.status === 406 ? (this.request.clearLoadedBytes(), new x("http-bytes-mismatch", t.statusText)) : new x("http-error", t.statusText);
const { requestByteRange: e } = this;
if (e) if (t.status === 200) {
- if (this.request.segment.byteRange) throw new R("http-unexpected-status-code");
+ if (this.request.segment.byteRange) throw new x("http-unexpected-status-code");
this.request.clearLoadedBytes();
} else {
- if (t.status !== 206) throw new R("http-unexpected-status-code", t.statusText);
+ if (t.status !== 206) throw new x("http-unexpected-status-code", t.statusText);
const n = t.headers.get("Content-Length");
- if (n && this.expectedBytesLength !== void 0 && this.expectedBytesLength !== +n) throw this.request.clearLoadedBytes(), new R("http-bytes-mismatch", t.statusText);
- const r = t.headers.get("Content-Range"), i = r ? function(o) {
+ if (n && this.expectedBytesLength !== void 0 && this.expectedBytesLength !== +n) throw this.request.clearLoadedBytes(), new x("http-bytes-mismatch", t.statusText);
+ const i = t.headers.get("Content-Range"), r = i ? function(o) {
const a = o.trim().match(/^bytes (?:(?:(\d+)|)-(?:(\d+)|)|\*)\/(?:(\d+)|\*)$/);
if (!a) return;
- const [, h, g, d] = a;
- return { from: h ? parseInt(h) : void 0, to: g ? parseInt(g) : void 0, total: d ? parseInt(d) : void 0 };
- }(r) : void 0;
- if (i) {
- const { from: o, to: a, total: h } = i;
- if (h !== void 0 && this.request.totalBytes !== h || o !== void 0 && e.start !== o || a !== void 0 && e.end !== void 0 && e.end !== a) throw this.request.clearLoadedBytes(), new R("http-bytes-mismatch", t.statusText);
+ const [, h, u, c] = a;
+ return { from: h ? parseInt(h) : void 0, to: u ? parseInt(u) : void 0, total: c ? parseInt(c) : void 0 };
+ }(i) : void 0;
+ if (r) {
+ const { from: o, to: a, total: h } = r;
+ if (h !== void 0 && this.request.totalBytes !== h || o !== void 0 && e.start !== o || a !== void 0 && e.end !== void 0 && e.end !== a) throw this.request.clearLoadedBytes(), new x("http-bytes-mismatch", t.statusText);
}
}
if (t.status === 200 && this.request.totalBytes === void 0) {
@@ -80,237 +80,237 @@ class Gn {
handleError(t) {
if (t instanceof Error) {
if (t.name !== "abort") return;
- const e = t instanceof R ? t : new R("http-error", t.message);
+ const e = t instanceof x ? t : new x("http-error", t.message);
this.requestControls.abortOnError(e);
}
}
}
-function Jn(s) {
+function Dn(s) {
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
}
-var D, N, nn = { exports: {} }, v = nn.exports = {};
-function jt() {
+var R, P, We = { exports: {} }, _ = We.exports = {};
+function Ut() {
throw new Error("setTimeout has not been defined");
}
-function Qt() {
+function Ht() {
throw new Error("clearTimeout has not been defined");
}
-function sn(s) {
- if (D === setTimeout) return setTimeout(s, 0);
- if ((D === jt || !D) && setTimeout) return D = setTimeout, setTimeout(s, 0);
+function Qe(s) {
+ if (R === setTimeout) return setTimeout(s, 0);
+ if ((R === Ut || !R) && setTimeout) return R = setTimeout, setTimeout(s, 0);
try {
- return D(s, 0);
+ return R(s, 0);
} catch {
try {
- return D.call(null, s, 0);
+ return R.call(null, s, 0);
} catch {
- return D.call(this, s, 0);
+ return R.call(this, s, 0);
}
}
}
(function() {
try {
- D = typeof setTimeout == "function" ? setTimeout : jt;
+ R = typeof setTimeout == "function" ? setTimeout : Ut;
} catch {
- D = jt;
+ R = Ut;
}
try {
- N = typeof clearTimeout == "function" ? clearTimeout : Qt;
+ P = typeof clearTimeout == "function" ? clearTimeout : Ht;
} catch {
- N = Qt;
+ P = Ht;
}
})();
-var Q, M = [], J = !1, bt = -1;
-function Yn() {
- J && Q && (J = !1, Q.length ? M = Q.concat(M) : bt = -1, M.length && rn());
+var H, q = [], Q = !1, pt = -1;
+function Mn() {
+ Q && H && (Q = !1, H.length ? q = H.concat(q) : pt = -1, q.length && ze());
}
-function rn() {
- if (!J) {
- var s = sn(Yn);
- J = !0;
- for (var t = M.length; t; ) {
- for (Q = M, M = []; ++bt < t; ) Q && Q[bt].run();
- bt = -1, t = M.length;
+function ze() {
+ if (!Q) {
+ var s = Qe(Mn);
+ Q = !0;
+ for (var t = q.length; t; ) {
+ for (H = q, q = []; ++pt < t; ) H && H[pt].run();
+ pt = -1, t = q.length;
}
- Q = null, J = !1, function(e) {
- if (N === clearTimeout) return clearTimeout(e);
- if ((N === Qt || !N) && clearTimeout) return N = clearTimeout, clearTimeout(e);
+ H = null, Q = !1, function(e) {
+ if (P === clearTimeout) return clearTimeout(e);
+ if ((P === Ht || !P) && clearTimeout) return P = clearTimeout, clearTimeout(e);
try {
- return N(e);
+ return P(e);
} catch {
try {
- return N.call(null, e);
+ return P.call(null, e);
} catch {
- return N.call(this, e);
+ return P.call(this, e);
}
}
}(s);
}
}
-function pe(s, t) {
+function he(s, t) {
this.fun = s, this.array = t;
}
-function q() {
+function I() {
}
-v.nextTick = function(s) {
+_.nextTick = function(s) {
var t = new Array(arguments.length - 1);
if (arguments.length > 1) for (var e = 1; e < arguments.length; e++) t[e - 1] = arguments[e];
- M.push(new pe(s, t)), M.length !== 1 || J || sn(rn);
-}, pe.prototype.run = function() {
+ q.push(new he(s, t)), q.length !== 1 || Q || Qe(ze);
+}, he.prototype.run = function() {
this.fun.apply(null, this.array);
-}, v.title = "browser", v.browser = !0, v.env = {}, v.argv = [], v.version = "", v.versions = {}, v.on = q, v.addListener = q, v.once = q, v.off = q, v.removeListener = q, v.removeAllListeners = q, v.emit = q, v.prependListener = q, v.prependOnceListener = q, v.listeners = function(s) {
+}, _.title = "browser", _.browser = !0, _.env = {}, _.argv = [], _.version = "", _.versions = {}, _.on = I, _.addListener = I, _.once = I, _.off = I, _.removeListener = I, _.removeAllListeners = I, _.emit = I, _.prependListener = I, _.prependOnceListener = I, _.listeners = function(s) {
return [];
-}, v.binding = function(s) {
+}, _.binding = function(s) {
throw new Error("process.binding is not supported");
-}, v.cwd = function() {
+}, _.cwd = function() {
return "/";
-}, v.chdir = function(s) {
+}, _.chdir = function(s) {
throw new Error("process.chdir is not supported");
-}, v.umask = function() {
+}, _.umask = function() {
return 0;
};
-const wt = Jn(nn.exports);
-var Kn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
-function V(s) {
+const ft = Dn(We.exports);
+var Nn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
+function j(s) {
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
}
-var me, ye, Wt = { exports: {} };
-function Zn() {
- if (ye) return me;
- ye = 1;
- var s = 1e3, t = 60 * s, e = 60 * t, n = 24 * e, r = 7 * n, i = 365.25 * n;
- function o(a, h, g, d) {
- var p = h >= 1.5 * g;
- return Math.round(a / g) + " " + d + (p ? "s" : "");
+var ce, de, $t = { exports: {} };
+function Fn() {
+ if (de) return ce;
+ de = 1;
+ var s = 1e3, t = 60 * s, e = 60 * t, n = 24 * e, i = 7 * n, r = 365.25 * n;
+ function o(a, h, u, c) {
+ var l = h >= 1.5 * u;
+ return Math.round(a / u) + " " + c + (l ? "s" : "");
}
- return me = function(a, h) {
+ return ce = function(a, h) {
h = h || {};
- var g = typeof a;
- if (g === "string" && a.length > 0) return function(d) {
- if (!((d = String(d)).length > 100)) {
- var p = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);
- if (p) {
- var y = parseFloat(p[1]);
- switch ((p[2] || "ms").toLowerCase()) {
+ var u = typeof a;
+ if (u === "string" && a.length > 0) return function(c) {
+ if (!((c = String(c)).length > 100)) {
+ var l = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(c);
+ if (l) {
+ var g = parseFloat(l[1]);
+ switch ((l[2] || "ms").toLowerCase()) {
case "years":
case "year":
case "yrs":
case "yr":
case "y":
- return y * i;
+ return g * r;
case "weeks":
case "week":
case "w":
- return y * r;
+ return g * i;
case "days":
case "day":
case "d":
- return y * n;
+ return g * n;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h":
- return y * e;
+ return g * e;
case "minutes":
case "minute":
case "mins":
case "min":
case "m":
- return y * t;
+ return g * t;
case "seconds":
case "second":
case "secs":
case "sec":
case "s":
- return y * s;
+ return g * s;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms":
- return y;
+ return g;
default:
return;
}
}
}
}(a);
- if (g === "number" && isFinite(a)) return h.long ? function(d) {
- var p = Math.abs(d);
- return p >= n ? o(d, p, n, "day") : p >= e ? o(d, p, e, "hour") : p >= t ? o(d, p, t, "minute") : p >= s ? o(d, p, s, "second") : d + " ms";
- }(a) : function(d) {
- var p = Math.abs(d);
- return p >= n ? Math.round(d / n) + "d" : p >= e ? Math.round(d / e) + "h" : p >= t ? Math.round(d / t) + "m" : p >= s ? Math.round(d / s) + "s" : d + "ms";
+ if (u === "number" && isFinite(a)) return h.long ? function(c) {
+ var l = Math.abs(c);
+ return l >= n ? o(c, l, n, "day") : l >= e ? o(c, l, e, "hour") : l >= t ? o(c, l, t, "minute") : l >= s ? o(c, l, s, "second") : c + " ms";
+ }(a) : function(c) {
+ var l = Math.abs(c);
+ return l >= n ? Math.round(c / n) + "d" : l >= e ? Math.round(c / e) + "h" : l >= t ? Math.round(c / t) + "m" : l >= s ? Math.round(c / s) + "s" : c + "ms";
}(a);
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(a));
};
}
-var Xn = function(s) {
- function t(r) {
- let i, o, a, h = null;
- function g(...d) {
- if (!g.enabled) return;
- const p = g, y = Number(/* @__PURE__ */ new Date()), w = y - (i || y);
- p.diff = w, p.prev = i, p.curr = y, i = y, d[0] = t.coerce(d[0]), typeof d[0] != "string" && d.unshift("%O");
- let c = 0;
- d[0] = d[0].replace(/%([a-zA-Z%])/g, (u, l) => {
- if (u === "%%") return "%";
- c++;
- const m = t.formatters[l];
- if (typeof m == "function") {
- const _ = d[c];
- u = m.call(p, _), d.splice(c, 1), c--;
+var Un = function(s) {
+ function t(i) {
+ let r, o, a, h = null;
+ function u(...c) {
+ if (!u.enabled) return;
+ const l = u, g = Number(/* @__PURE__ */ new Date()), m = g - (r || g);
+ l.diff = m, l.prev = r, l.curr = g, r = g, c[0] = t.coerce(c[0]), typeof c[0] != "string" && c.unshift("%O");
+ let f = 0;
+ c[0] = c[0].replace(/%([a-zA-Z%])/g, (v, F) => {
+ if (v === "%%") return "%";
+ f++;
+ const D = t.formatters[F];
+ if (typeof D == "function") {
+ const Rt = c[f];
+ v = D.call(l, Rt), c.splice(f, 1), f--;
}
- return u;
- }), t.formatArgs.call(p, d), (p.log || t.log).apply(p, d);
+ return v;
+ }), t.formatArgs.call(l, c), (l.log || t.log).apply(l, c);
}
- return g.namespace = r, g.useColors = t.useColors(), g.color = t.selectColor(r), g.extend = e, g.destroy = t.destroy, Object.defineProperty(g, "enabled", { enumerable: !0, configurable: !1, get: () => h !== null ? h : (o !== t.namespaces && (o = t.namespaces, a = t.enabled(r)), a), set: (d) => {
- h = d;
- } }), typeof t.init == "function" && t.init(g), g;
+ return u.namespace = i, u.useColors = t.useColors(), u.color = t.selectColor(i), u.extend = e, u.destroy = t.destroy, Object.defineProperty(u, "enabled", { enumerable: !0, configurable: !1, get: () => h !== null ? h : (o !== t.namespaces && (o = t.namespaces, a = t.enabled(i)), a), set: (c) => {
+ h = c;
+ } }), typeof t.init == "function" && t.init(u), u;
}
- function e(r, i) {
- const o = t(this.namespace + (i === void 0 ? ":" : i) + r);
+ function e(i, r) {
+ const o = t(this.namespace + (r === void 0 ? ":" : r) + i);
return o.log = this.log, o;
}
- function n(r) {
- return r.toString().substring(2, r.toString().length - 2).replace(/\.\*\?$/, "*");
+ function n(i) {
+ return i.toString().substring(2, i.toString().length - 2).replace(/\.\*\?$/, "*");
}
- return t.debug = t, t.default = t, t.coerce = function(r) {
- return r instanceof Error ? r.stack || r.message : r;
+ return t.debug = t, t.default = t, t.coerce = function(i) {
+ return i instanceof Error ? i.stack || i.message : i;
}, t.disable = function() {
- const r = [...t.names.map(n), ...t.skips.map(n).map((i) => "-" + i)].join(",");
- return t.enable(""), r;
- }, t.enable = function(r) {
- let i;
- t.save(r), t.namespaces = r, t.names = [], t.skips = [];
- const o = (typeof r == "string" ? r : "").split(/[\s,]+/), a = o.length;
- for (i = 0; i < a; i++) o[i] && ((r = o[i].replace(/\*/g, ".*?"))[0] === "-" ? t.skips.push(new RegExp("^" + r.slice(1) + "$")) : t.names.push(new RegExp("^" + r + "$")));
- }, t.enabled = function(r) {
- if (r[r.length - 1] === "*") return !0;
- let i, o;
- for (i = 0, o = t.skips.length; i < o; i++) if (t.skips[i].test(r)) return !1;
- for (i = 0, o = t.names.length; i < o; i++) if (t.names[i].test(r)) return !0;
+ const i = [...t.names.map(n), ...t.skips.map(n).map((r) => "-" + r)].join(",");
+ return t.enable(""), i;
+ }, t.enable = function(i) {
+ let r;
+ t.save(i), t.namespaces = i, t.names = [], t.skips = [];
+ const o = (typeof i == "string" ? i : "").split(/[\s,]+/), a = o.length;
+ for (r = 0; r < a; r++) o[r] && ((i = o[r].replace(/\*/g, ".*?"))[0] === "-" ? t.skips.push(new RegExp("^" + i.slice(1) + "$")) : t.names.push(new RegExp("^" + i + "$")));
+ }, t.enabled = function(i) {
+ if (i[i.length - 1] === "*") return !0;
+ let r, o;
+ for (r = 0, o = t.skips.length; r < o; r++) if (t.skips[r].test(i)) return !1;
+ for (r = 0, o = t.names.length; r < o; r++) if (t.names[r].test(i)) return !0;
return !1;
- }, t.humanize = Zn(), t.destroy = function() {
+ }, t.humanize = Fn(), t.destroy = function() {
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
- }, Object.keys(s).forEach((r) => {
- t[r] = s[r];
- }), t.names = [], t.skips = [], t.formatters = {}, t.selectColor = function(r) {
- let i = 0;
- for (let o = 0; o < r.length; o++) i = (i << 5) - i + r.charCodeAt(o), i |= 0;
- return t.colors[Math.abs(i) % t.colors.length];
+ }, Object.keys(s).forEach((i) => {
+ t[i] = s[i];
+ }), t.names = [], t.skips = [], t.formatters = {}, t.selectColor = function(i) {
+ let r = 0;
+ for (let o = 0; o < i.length; o++) r = (r << 5) - r + i.charCodeAt(o), r |= 0;
+ return t.colors[Math.abs(r) % t.colors.length];
}, t.enable(t.load()), t;
};
(function(s, t) {
t.formatArgs = function(n) {
if (n[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + n[0] + (this.useColors ? "%c " : " ") + "+" + s.exports.humanize(this.diff), !this.useColors) return;
- const r = "color: " + this.color;
- n.splice(1, 0, r, "color: inherit");
- let i = 0, o = 0;
+ const i = "color: " + this.color;
+ n.splice(1, 0, i, "color: inherit");
+ let r = 0, o = 0;
n[0].replace(/%[a-zA-Z%]/g, (a) => {
- a !== "%%" && (i++, a === "%c" && (o = i));
- }), n.splice(o, 0, r);
+ a !== "%%" && (r++, a === "%c" && (o = r));
+ }), n.splice(o, 0, i);
}, t.save = function(n) {
try {
n ? t.storage.setItem("debug", n) : t.storage.removeItem("debug");
@@ -322,7 +322,7 @@ var Xn = function(s) {
n = t.storage.getItem("debug");
} catch {
}
- return !n && wt !== void 0 && "env" in wt && (n = wt.env.DEBUG), n;
+ return !n && ft !== void 0 && "env" in ft && (n = ft.env.DEBUG), n;
}, t.useColors = function() {
if (typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return !0;
if (typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return !1;
@@ -339,79 +339,79 @@ var Xn = function(s) {
n || (n = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));
};
})(), t.colors = ["#0000CC", "#0000FF", "#0033CC", "#0033FF", "#0066CC", "#0066FF", "#0099CC", "#0099FF", "#00CC00", "#00CC33", "#00CC66", "#00CC99", "#00CCCC", "#00CCFF", "#3300CC", "#3300FF", "#3333CC", "#3333FF", "#3366CC", "#3366FF", "#3399CC", "#3399FF", "#33CC00", "#33CC33", "#33CC66", "#33CC99", "#33CCCC", "#33CCFF", "#6600CC", "#6600FF", "#6633CC", "#6633FF", "#66CC00", "#66CC33", "#9900CC", "#9900FF", "#9933CC", "#9933FF", "#99CC00", "#99CC33", "#CC0000", "#CC0033", "#CC0066", "#CC0099", "#CC00CC", "#CC00FF", "#CC3300", "#CC3333", "#CC3366", "#CC3399", "#CC33CC", "#CC33FF", "#CC6600", "#CC6633", "#CC9900", "#CC9933", "#CCCC00", "#CCCC33", "#FF0000", "#FF0033", "#FF0066", "#FF0099", "#FF00CC", "#FF00FF", "#FF3300", "#FF3333", "#FF3366", "#FF3399", "#FF33CC", "#FF33FF", "#FF6600", "#FF6633", "#FF9900", "#FF9933", "#FFCC00", "#FFCC33"], t.log = console.debug || console.log || (() => {
- }), s.exports = Xn(t);
+ }), s.exports = Un(t);
const { formatters: e } = s.exports;
e.j = function(n) {
try {
return JSON.stringify(n);
- } catch (r) {
- return "[UnexpectedJSONParseError]: " + r.message;
+ } catch (i) {
+ return "[UnexpectedJSONParseError]: " + i.message;
}
};
-})(Wt, Wt.exports);
-var on = Wt.exports;
-const P = V(on);
-var an, zt = { exports: {} }, Y = typeof Reflect == "object" ? Reflect : null, _e = Y && typeof Y.apply == "function" ? Y.apply : function(s, t, e) {
+})($t, $t.exports);
+var Ge = $t.exports;
+const A = j(Ge);
+var Je, jt = { exports: {} }, z = typeof Reflect == "object" ? Reflect : null, le = z && typeof z.apply == "function" ? z.apply : function(s, t, e) {
return Function.prototype.apply.call(s, t, e);
};
-an = Y && typeof Y.ownKeys == "function" ? Y.ownKeys : Object.getOwnPropertySymbols ? function(s) {
+Je = z && typeof z.ownKeys == "function" ? z.ownKeys : Object.getOwnPropertySymbols ? function(s) {
return Object.getOwnPropertyNames(s).concat(Object.getOwnPropertySymbols(s));
} : function(s) {
return Object.getOwnPropertyNames(s);
};
-var be = Number.isNaN || function(s) {
+var ue = Number.isNaN || function(s) {
return s != s;
};
-function S() {
- S.init.call(this);
+function p() {
+ p.init.call(this);
}
-zt.exports = S, zt.exports.once = function(s, t) {
+jt.exports = p, jt.exports.once = function(s, t) {
return new Promise(function(e, n) {
- function r(o) {
- s.removeListener(t, i), n(o);
+ function i(o) {
+ s.removeListener(t, r), n(o);
}
- function i() {
- typeof s.removeListener == "function" && s.removeListener("error", r), e([].slice.call(arguments));
+ function r() {
+ typeof s.removeListener == "function" && s.removeListener("error", i), e([].slice.call(arguments));
}
- ke(s, t, i, { once: !0 }), t !== "error" && function(o, a, h) {
- typeof o.on == "function" && ke(o, "error", a, h);
- }(s, r, { once: !0 });
+ _e(s, t, r, { once: !0 }), t !== "error" && function(o, a, h) {
+ typeof o.on == "function" && _e(o, "error", a, h);
+ }(s, i, { once: !0 });
});
-}, S.EventEmitter = S, S.prototype._events = void 0, S.prototype._eventsCount = 0, S.prototype._maxListeners = void 0;
-var we = 10;
-function St(s) {
+}, p.EventEmitter = p, p.prototype._events = void 0, p.prototype._eventsCount = 0, p.prototype._maxListeners = void 0;
+var ge = 10;
+function yt(s) {
if (typeof s != "function") throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof s);
}
-function hn(s) {
- return s._maxListeners === void 0 ? S.defaultMaxListeners : s._maxListeners;
+function Ve(s) {
+ return s._maxListeners === void 0 ? p.defaultMaxListeners : s._maxListeners;
}
-function Se(s, t, e, n) {
- var r, i, o, a;
- if (St(e), (i = s._events) === void 0 ? (i = s._events = /* @__PURE__ */ Object.create(null), s._eventsCount = 0) : (i.newListener !== void 0 && (s.emit("newListener", t, e.listener ? e.listener : e), i = s._events), o = i[t]), o === void 0) o = i[t] = e, ++s._eventsCount;
- else if (typeof o == "function" ? o = i[t] = n ? [e, o] : [o, e] : n ? o.unshift(e) : o.push(e), (r = hn(s)) > 0 && o.length > r && !o.warned) {
+function me(s, t, e, n) {
+ var i, r, o, a;
+ if (yt(e), (r = s._events) === void 0 ? (r = s._events = /* @__PURE__ */ Object.create(null), s._eventsCount = 0) : (r.newListener !== void 0 && (s.emit("newListener", t, e.listener ? e.listener : e), r = s._events), o = r[t]), o === void 0) o = r[t] = e, ++s._eventsCount;
+ else if (typeof o == "function" ? o = r[t] = n ? [e, o] : [o, e] : n ? o.unshift(e) : o.push(e), (i = Ve(s)) > 0 && o.length > i && !o.warned) {
o.warned = !0;
var h = new Error("Possible EventEmitter memory leak detected. " + o.length + " " + String(t) + " listeners added. Use emitter.setMaxListeners() to increase limit");
h.name = "MaxListenersExceededWarning", h.emitter = s, h.type = t, h.count = o.length, a = h, console && console.warn && console.warn(a);
}
return s;
}
-function ts() {
+function Hn() {
if (!this.fired) return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
}
-function Ce(s, t, e) {
- var n = { fired: !1, wrapFn: void 0, target: s, type: t, listener: e }, r = ts.bind(n);
- return r.listener = e, n.wrapFn = r, r;
+function pe(s, t, e) {
+ var n = { fired: !1, wrapFn: void 0, target: s, type: t, listener: e }, i = Hn.bind(n);
+ return i.listener = e, n.wrapFn = i, i;
}
-function ve(s, t, e) {
+function fe(s, t, e) {
var n = s._events;
if (n === void 0) return [];
- var r = n[t];
- return r === void 0 ? [] : typeof r == "function" ? e ? [r.listener || r] : [r] : e ? function(i) {
- for (var o = new Array(i.length), a = 0; a < o.length; ++a) o[a] = i[a].listener || i[a];
+ var i = n[t];
+ return i === void 0 ? [] : typeof i == "function" ? e ? [i.listener || i] : [i] : e ? function(r) {
+ for (var o = new Array(r.length), a = 0; a < o.length; ++a) o[a] = r[a].listener || r[a];
return o;
- }(r) : cn(r, r.length);
+ }(i) : Ye(i, i.length);
}
-function Le(s) {
+function ye(s) {
var t = this._events;
if (t !== void 0) {
var e = t[s];
@@ -420,163 +420,163 @@ function Le(s) {
}
return 0;
}
-function cn(s, t) {
+function Ye(s, t) {
for (var e = new Array(t), n = 0; n < t; ++n) e[n] = s[n];
return e;
}
-function ke(s, t, e, n) {
+function _e(s, t, e, n) {
if (typeof s.on == "function") n.once ? s.once(t, e) : s.on(t, e);
else {
if (typeof s.addEventListener != "function") throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof s);
- s.addEventListener(t, function r(i) {
- n.once && s.removeEventListener(t, r), e(i);
+ s.addEventListener(t, function i(r) {
+ n.once && s.removeEventListener(t, i), e(r);
});
}
}
-Object.defineProperty(S, "defaultMaxListeners", { enumerable: !0, get: function() {
- return we;
+Object.defineProperty(p, "defaultMaxListeners", { enumerable: !0, get: function() {
+ return ge;
}, set: function(s) {
- if (typeof s != "number" || s < 0 || be(s)) throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + s + ".");
- we = s;
-} }), S.init = function() {
+ if (typeof s != "number" || s < 0 || ue(s)) throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + s + ".");
+ ge = s;
+} }), p.init = function() {
this._events !== void 0 && this._events !== Object.getPrototypeOf(this)._events || (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
-}, S.prototype.setMaxListeners = function(s) {
- if (typeof s != "number" || s < 0 || be(s)) throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + s + ".");
+}, p.prototype.setMaxListeners = function(s) {
+ if (typeof s != "number" || s < 0 || ue(s)) throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + s + ".");
return this._maxListeners = s, this;
-}, S.prototype.getMaxListeners = function() {
- return hn(this);
-}, S.prototype.emit = function(s) {
+}, p.prototype.getMaxListeners = function() {
+ return Ve(this);
+}, p.prototype.emit = function(s) {
for (var t = [], e = 1; e < arguments.length; e++) t.push(arguments[e]);
- var n = s === "error", r = this._events;
- if (r !== void 0) n = n && r.error === void 0;
+ var n = s === "error", i = this._events;
+ if (i !== void 0) n = n && i.error === void 0;
else if (!n) return !1;
if (n) {
- var i;
- if (t.length > 0 && (i = t[0]), i instanceof Error) throw i;
- var o = new Error("Unhandled error." + (i ? " (" + i.message + ")" : ""));
- throw o.context = i, o;
+ var r;
+ if (t.length > 0 && (r = t[0]), r instanceof Error) throw r;
+ var o = new Error("Unhandled error." + (r ? " (" + r.message + ")" : ""));
+ throw o.context = r, o;
}
- var a = r[s];
+ var a = i[s];
if (a === void 0) return !1;
- if (typeof a == "function") _e(a, this, t);
+ if (typeof a == "function") le(a, this, t);
else {
- var h = a.length, g = cn(a, h);
- for (e = 0; e < h; ++e) _e(g[e], this, t);
+ var h = a.length, u = Ye(a, h);
+ for (e = 0; e < h; ++e) le(u[e], this, t);
}
return !0;
-}, S.prototype.addListener = function(s, t) {
- return Se(this, s, t, !1);
-}, S.prototype.on = S.prototype.addListener, S.prototype.prependListener = function(s, t) {
- return Se(this, s, t, !0);
-}, S.prototype.once = function(s, t) {
- return St(t), this.on(s, Ce(this, s, t)), this;
-}, S.prototype.prependOnceListener = function(s, t) {
- return St(t), this.prependListener(s, Ce(this, s, t)), this;
-}, S.prototype.removeListener = function(s, t) {
- var e, n, r, i, o;
- if (St(t), (n = this._events) === void 0) return this;
+}, p.prototype.addListener = function(s, t) {
+ return me(this, s, t, !1);
+}, p.prototype.on = p.prototype.addListener, p.prototype.prependListener = function(s, t) {
+ return me(this, s, t, !0);
+}, p.prototype.once = function(s, t) {
+ return yt(t), this.on(s, pe(this, s, t)), this;
+}, p.prototype.prependOnceListener = function(s, t) {
+ return yt(t), this.prependListener(s, pe(this, s, t)), this;
+}, p.prototype.removeListener = function(s, t) {
+ var e, n, i, r, o;
+ if (yt(t), (n = this._events) === void 0) return this;
if ((e = n[s]) === void 0) return this;
if (e === t || e.listener === t) --this._eventsCount == 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete n[s], n.removeListener && this.emit("removeListener", s, e.listener || t));
else if (typeof e != "function") {
- for (r = -1, i = e.length - 1; i >= 0; i--) if (e[i] === t || e[i].listener === t) {
- o = e[i].listener, r = i;
+ for (i = -1, r = e.length - 1; r >= 0; r--) if (e[r] === t || e[r].listener === t) {
+ o = e[r].listener, i = r;
break;
}
- if (r < 0) return this;
- r === 0 ? e.shift() : function(a, h) {
+ if (i < 0) return this;
+ i === 0 ? e.shift() : function(a, h) {
for (; h + 1 < a.length; h++) a[h] = a[h + 1];
a.pop();
- }(e, r), e.length === 1 && (n[s] = e[0]), n.removeListener !== void 0 && this.emit("removeListener", s, o || t);
+ }(e, i), e.length === 1 && (n[s] = e[0]), n.removeListener !== void 0 && this.emit("removeListener", s, o || t);
}
return this;
-}, S.prototype.off = S.prototype.removeListener, S.prototype.removeAllListeners = function(s) {
+}, p.prototype.off = p.prototype.removeListener, p.prototype.removeAllListeners = function(s) {
var t, e, n;
if ((e = this._events) === void 0) return this;
if (e.removeListener === void 0) return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : e[s] !== void 0 && (--this._eventsCount == 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete e[s]), this;
if (arguments.length === 0) {
- var r, i = Object.keys(e);
- for (n = 0; n < i.length; ++n) (r = i[n]) !== "removeListener" && this.removeAllListeners(r);
+ var i, r = Object.keys(e);
+ for (n = 0; n < r.length; ++n) (i = r[n]) !== "removeListener" && this.removeAllListeners(i);
return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this;
}
if (typeof (t = e[s]) == "function") this.removeListener(s, t);
else if (t !== void 0) for (n = t.length - 1; n >= 0; n--) this.removeListener(s, t[n]);
return this;
-}, S.prototype.listeners = function(s) {
- return ve(this, s, !0);
-}, S.prototype.rawListeners = function(s) {
- return ve(this, s, !1);
-}, S.listenerCount = function(s, t) {
- return typeof s.listenerCount == "function" ? s.listenerCount(t) : Le.call(s, t);
-}, S.prototype.listenerCount = Le, S.prototype.eventNames = function() {
- return this._eventsCount > 0 ? an(this._events) : [];
+}, p.prototype.listeners = function(s) {
+ return fe(this, s, !0);
+}, p.prototype.rawListeners = function(s) {
+ return fe(this, s, !1);
+}, p.listenerCount = function(s, t) {
+ return typeof s.listenerCount == "function" ? s.listenerCount(t) : ye.call(s, t);
+}, p.prototype.listenerCount = ye, p.prototype.eventNames = function() {
+ return this._eventsCount > 0 ? Je(this._events) : [];
};
-var dn = zt.exports;
-const un = V(dn);
-var Vt = { exports: {} }, es = function s(t, e) {
+var Ke = jt.exports;
+const Ze = j(Ke);
+var Wt = { exports: {} }, $n = function s(t, e) {
if (t && e) return s(t)(e);
if (typeof t != "function") throw new TypeError("need wrapper function");
- return Object.keys(t).forEach(function(r) {
- n[r] = t[r];
+ return Object.keys(t).forEach(function(i) {
+ n[i] = t[i];
}), n;
function n() {
- for (var r = new Array(arguments.length), i = 0; i < r.length; i++) r[i] = arguments[i];
- var o = t.apply(this, r), a = r[r.length - 1];
+ for (var i = new Array(arguments.length), r = 0; r < i.length; r++) i[r] = arguments[r];
+ var o = t.apply(this, i), a = i[i.length - 1];
return typeof o == "function" && o !== a && Object.keys(a).forEach(function(h) {
o[h] = a[h];
}), o;
}
-}, xe = es;
-function ut(s) {
+}, Se = $n;
+function rt(s) {
var t = function() {
return t.called ? t.value : (t.called = !0, t.value = s.apply(this, arguments));
};
return t.called = !1, t;
}
-function Ae(s) {
+function we(s) {
var t = function() {
if (t.called) throw new Error(t.onceError);
return t.called = !0, t.value = s.apply(this, arguments);
}, e = s.name || "Function wrapped with `once`";
return t.onceError = e + " shouldn't be called more than once", t.called = !1, t;
}
-Vt.exports = xe(ut), Vt.exports.strict = xe(Ae), ut.proto = ut(function() {
+Wt.exports = Se(rt), Wt.exports.strict = Se(we), rt.proto = rt(function() {
Object.defineProperty(Function.prototype, "once", { value: function() {
- return ut(this);
+ return rt(this);
}, configurable: !0 }), Object.defineProperty(Function.prototype, "onceStrict", { value: function() {
- return Ae(this);
+ return we(this);
}, configurable: !0 });
});
-const ns = V(Vt.exports);
-let Ee;
-var ln = typeof queueMicrotask == "function" ? queueMicrotask.bind(typeof window < "u" ? window : Kn) : (s) => (Ee || (Ee = Promise.resolve())).then(s).catch((t) => setTimeout(() => {
+const jn = j(Wt.exports);
+let be;
+var Xe = typeof queueMicrotask == "function" ? queueMicrotask.bind(typeof window < "u" ? window : Nn) : (s) => (be || (be = Promise.resolve())).then(s).catch((t) => setTimeout(() => {
throw t;
}, 0));
-const Gt = V(ln);
-var ss = function(s, t) {
- let e, n, r, i = !0;
- Array.isArray(s) ? (e = [], n = s.length) : (r = Object.keys(s), e = {}, n = r.length);
+const Qt = j(Xe);
+var Wn = function(s, t) {
+ let e, n, i, r = !0;
+ Array.isArray(s) ? (e = [], n = s.length) : (i = Object.keys(s), e = {}, n = i.length);
function o(h) {
- function g() {
+ function u() {
t && t(h, e), t = null;
}
- i ? rs(g) : g();
+ r ? Qn(u) : u();
}
- function a(h, g, d) {
- e[h] = d, (--n == 0 || g) && o(g);
+ function a(h, u, c) {
+ e[h] = c, (--n == 0 || u) && o(u);
}
- n ? r ? r.forEach(function(h) {
- s[h](function(g, d) {
- a(h, g, d);
+ n ? i ? i.forEach(function(h) {
+ s[h](function(u, c) {
+ a(h, u, c);
});
- }) : s.forEach(function(h, g) {
- h(function(d, p) {
- a(g, d, p);
+ }) : s.forEach(function(h, u) {
+ h(function(c, l) {
+ a(u, c, l);
});
- }) : o(null), i = !1;
+ }) : o(null), r = !1;
};
-const rs = ln, is = V(ss), U = typeof window < "u" ? window : self, Jt = U.RTCPeerConnection || U.mozRTCPeerConnection || U.webkitRTCPeerConnection, os = U.RTCSessionDescription || U.mozRTCSessionDescription || U.webkitRTCSessionDescription, as = U.RTCIceCandidate || U.mozRTCIceCandidate || U.webkitRTCIceCandidate;
-var hs = typeof queueMicrotask == "function" ? queueMicrotask : (s) => Promise.resolve().then(s);
-const Te = class {
+const Qn = Xe, zn = j(Wn), O = typeof window < "u" ? window : self, zt = O.RTCPeerConnection || O.mozRTCPeerConnection || O.webkitRTCPeerConnection, Gn = O.RTCSessionDescription || O.mozRTCSessionDescription || O.webkitRTCSessionDescription, Jn = O.RTCIceCandidate || O.mozRTCIceCandidate || O.webkitRTCIceCandidate;
+var Vn = typeof queueMicrotask == "function" ? queueMicrotask : (s) => Promise.resolve().then(s);
+const Ce = class {
constructor(s) {
if (!(s > 0) || s - 1 & s) throw new Error("Max size for a FixedFIFO should be a power of two");
this.buffer = new Array(s), this.mask = s - 1, this.top = 0, this.btm = 0, this.next = null;
@@ -598,363 +598,23 @@ const Te = class {
return this.buffer[this.btm] === void 0;
}
};
-var Yt = { exports: {} };
-function Ie(s) {
- return s.length;
-}
-var cs = { byteLength: Ie, toString: function(s) {
- const t = s.byteLength;
- let e = "";
- for (let n = 0; n < t; n++) e += String.fromCharCode(s[n]);
- return e;
-}, write: function(s, t, e = 0, n = Ie(t)) {
- const r = Math.min(n, s.byteLength - e);
- for (let i = 0; i < r; i++) s[e + i] = t.charCodeAt(i);
- return r;
-} };
-const nt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", W = new Uint8Array(256);
-for (let s = 0; s < 64; s++) W[nt.charCodeAt(s)] = s;
-function Re(s) {
- let t = s.length;
- return s.charCodeAt(t - 1) === 61 && t--, t > 1 && s.charCodeAt(t - 1) === 61 && t--, 3 * t >>> 2;
-}
-W[45] = 62, W[95] = 63;
-var ds = { byteLength: Re, toString: function(s) {
- const t = s.byteLength;
- let e = "";
- for (let n = 0; n < t; n += 3) e += nt[s[n] >> 2] + nt[(3 & s[n]) << 4 | s[n + 1] >> 4] + nt[(15 & s[n + 1]) << 2 | s[n + 2] >> 6] + nt[63 & s[n + 2]];
- return t % 3 == 2 ? e = e.substring(0, e.length - 1) + "=" : t % 3 == 1 && (e = e.substring(0, e.length - 2) + "=="), e;
-}, write: function(s, t, e = 0, n = Re(t)) {
- const r = Math.min(n, s.byteLength - e);
- for (let i = 0, o = 0; o < r; i += 4) {
- const a = W[t.charCodeAt(i)], h = W[t.charCodeAt(i + 1)], g = W[t.charCodeAt(i + 2)], d = W[t.charCodeAt(i + 3)];
- s[o++] = a << 2 | h >> 4, s[o++] = (15 & h) << 4 | g >> 2, s[o++] = (3 & g) << 6 | 63 & d;
+var tn = class {
+ constructor(s) {
+ this.decoder = new TextDecoder(s === "utf16le" ? "utf16-le" : s);
}
- return r;
-} };
-function Be(s) {
- return s.length >>> 1;
-}
-var us = { byteLength: Be, toString: function(s) {
- const t = s.byteLength;
- s = new DataView(s.buffer, s.byteOffset, t);
- let e = "", n = 0;
- for (let r = t - t % 4; n < r; n += 4) e += s.getUint32(n).toString(16).padStart(8, "0");
- for (; n < t; n++) e += s.getUint8(n).toString(16).padStart(2, "0");
- return e;
-}, write: function(s, t, e = 0, n = Be(t)) {
- const r = Math.min(n, s.byteLength - e);
- for (let i = 0; i < r; i++) {
- const o = Pe(t.charCodeAt(2 * i)), a = Pe(t.charCodeAt(2 * i + 1));
- if (o === void 0 || a === void 0) return s.subarray(0, i);
- s[e + i] = o << 4 | a;
- }
- return r;
-} };
-function Pe(s) {
- return s >= 48 && s <= 57 ? s - 48 : s >= 65 && s <= 70 ? s - 65 + 10 : s >= 97 && s <= 102 ? s - 97 + 10 : void 0;
-}
-function Kt(s) {
- let t = 0;
- for (let e = 0, n = s.length; e < n; e++) {
- const r = s.charCodeAt(e);
- if (r >= 55296 && r <= 56319 && e + 1 < n) {
- const i = s.charCodeAt(e + 1);
- if (i >= 56320 && i <= 57343) {
- t += 4, e++;
- continue;
- }
- }
- t += r <= 127 ? 1 : r <= 2047 ? 2 : 3;
- }
- return t;
-}
-let Zt, Xt;
-if (typeof TextDecoder < "u") {
- const s = new TextDecoder();
- Zt = function(t) {
- return s.decode(t);
- };
-} else Zt = function(s) {
- const t = s.byteLength;
- let e = "", n = 0;
- for (; n < t; ) {
- let r = s[n];
- if (r <= 127) {
- e += String.fromCharCode(r), n++;
- continue;
- }
- let i = 0, o = 0;
- if (r <= 223 ? (i = 1, o = 31 & r) : r <= 239 ? (i = 2, o = 15 & r) : r <= 244 && (i = 3, o = 7 & r), t - n - i > 0) {
- let a = 0;
- for (; a < i; ) r = s[n + a + 1], o = o << 6 | 63 & r, a += 1;
- } else o = 65533, i = t - n;
- e += String.fromCodePoint(o), n += i + 1;
- }
- return e;
-};
-if (typeof TextEncoder < "u") {
- const s = new TextEncoder();
- Xt = function(t, e, n = 0, r = Kt(e)) {
- const i = Math.min(r, t.byteLength - n);
- return s.encodeInto(e, t.subarray(n, n + i)), i;
- };
-} else Xt = function(s, t, e = 0, n = Kt(t)) {
- const r = Math.min(n, s.byteLength - e);
- s = s.subarray(e, e + r);
- let i = 0, o = 0;
- for (; i < t.length; ) {
- const a = t.codePointAt(i);
- if (a <= 127) {
- s[o++] = a, i++;
- continue;
- }
- let h = 0, g = 0;
- for (a <= 2047 ? (h = 6, g = 192) : a <= 65535 ? (h = 12, g = 224) : a <= 2097151 && (h = 18, g = 240), s[o++] = g | a >> h, h -= 6; h >= 0; ) s[o++] = 128 | a >> h & 63, h -= 6;
- i += a >= 65536 ? 2 : 1;
- }
- return r;
-};
-var ls = { byteLength: Kt, toString: Zt, write: Xt };
-function qe(s) {
- return 2 * s.length;
-}
-var gs = { byteLength: qe, toString: function(s) {
- const t = s.byteLength;
- let e = "";
- for (let n = 0; n < t - 1; n += 2) e += String.fromCharCode(s[n] + 256 * s[n + 1]);
- return e;
-}, write: function(s, t, e = 0, n = qe(t)) {
- const r = Math.min(n, s.byteLength - e);
- let i = r;
- for (let o = 0; o < t.length && !((i -= 2) < 0); ++o) {
- const a = t.charCodeAt(o), h = a >> 8, g = a % 256;
- s[e + 2 * o] = g, s[e + 2 * o + 1] = h;
- }
- return r;
-} };
-(function(s, t) {
- const e = cs, n = ds, r = us, i = ls, o = gs, a = new Uint8Array(Uint16Array.of(255).buffer)[0] === 255;
- function h(c) {
- switch (c) {
- case "ascii":
- return e;
- case "base64":
- return n;
- case "hex":
- return r;
- case "utf8":
- case "utf-8":
- case void 0:
- return i;
- case "ucs2":
- case "ucs-2":
- case "utf16le":
- case "utf-16le":
- return o;
- default:
- throw new Error(`Unknown encoding: ${c}`);
- }
- }
- function g(c) {
- return c instanceof Uint8Array;
- }
- function d(c, u, l) {
- return typeof c == "string" ? function(m, _) {
- const b = h(_), L = new Uint8Array(b.byteLength(m));
- return b.write(L, m, 0, L.byteLength), L;
- }(c, u) : Array.isArray(c) ? function(m) {
- const _ = new Uint8Array(m.length);
- return _.set(m), _;
- }(c) : ArrayBuffer.isView(c) ? function(m) {
- const _ = new Uint8Array(m.byteLength);
- return _.set(m), _;
- }(c) : function(m, _, b) {
- return new Uint8Array(m, _, b);
- }(c, u, l);
- }
- function p(c, u, l, m, _) {
- if (c.byteLength === 0) return -1;
- if (typeof l == "string" ? (m = l, l = 0) : l === void 0 ? l = _ ? 0 : c.length - 1 : l < 0 && (l += c.byteLength), l >= c.byteLength) {
- if (_) return -1;
- l = c.byteLength - 1;
- } else if (l < 0) {
- if (!_) return -1;
- l = 0;
- }
- if (typeof u == "string") u = d(u, m);
- else if (typeof u == "number") return u &= 255, _ ? c.indexOf(u, l) : c.lastIndexOf(u, l);
- if (u.byteLength === 0) return -1;
- if (_) {
- let b = -1;
- for (let L = l; L < c.byteLength; L++) if (c[L] === u[b === -1 ? 0 : L - b]) {
- if (b === -1 && (b = L), L - b + 1 === u.byteLength) return b;
- } else b !== -1 && (L -= L - b), b = -1;
- } else {
- l + u.byteLength > c.byteLength && (l = c.byteLength - u.byteLength);
- for (let b = l; b >= 0; b--) {
- let L = !0;
- for (let dt = 0; dt < u.byteLength; dt++) if (c[b + dt] !== u[dt]) {
- L = !1;
- break;
- }
- if (L) return b;
- }
- }
+ get remaining() {
return -1;
}
- function y(c, u, l, m) {
- return p(c, u, l, m, !0);
- }
- function w(c, u, l) {
- const m = c[u];
- c[u] = c[l], c[l] = m;
- }
- s.exports = t = { isBuffer: g, isEncoding: function(c) {
- try {
- return h(c), !0;
- } catch {
- return !1;
- }
- }, alloc: function(c, u, l) {
- const m = new Uint8Array(c);
- return u !== void 0 && t.fill(m, u, 0, m.byteLength, l), m;
- }, allocUnsafe: function(c) {
- return new Uint8Array(c);
- }, allocUnsafeSlow: function(c) {
- return new Uint8Array(c);
- }, byteLength: function(c, u) {
- return h(u).byteLength(c);
- }, compare: function(c, u) {
- if (c === u) return 0;
- const l = Math.min(c.byteLength, u.byteLength);
- c = new DataView(c.buffer, c.byteOffset, c.byteLength), u = new DataView(u.buffer, u.byteOffset, u.byteLength);
- let m = 0;
- for (let _ = l - l % 4; m < _ && c.getUint32(m, a) === u.getUint32(m, a); m += 4)
- ;
- for (; m < l; m++) {
- const _ = c.getUint8(m), b = u.getUint8(m);
- if (_ < b) return -1;
- if (_ > b) return 1;
- }
- return c.byteLength > u.byteLength ? 1 : c.byteLength < u.byteLength ? -1 : 0;
- }, concat: function(c, u) {
- u === void 0 && (u = c.reduce((_, b) => _ + b.byteLength, 0));
- const l = new Uint8Array(u);
- let m = 0;
- for (const _ of c) {
- if (m + _.byteLength > l.byteLength) {
- const b = _.subarray(0, l.byteLength - m);
- return l.set(b, m), l;
- }
- l.set(_, m), m += _.byteLength;
- }
- return l;
- }, copy: function(c, u, l = 0, m = 0, _ = c.byteLength) {
- if (_ > 0 && _ < m || _ === m || c.byteLength === 0 || u.byteLength === 0) return 0;
- if (l < 0) throw new RangeError("targetStart is out of range");
- if (m < 0 || m >= c.byteLength) throw new RangeError("sourceStart is out of range");
- if (_ < 0) throw new RangeError("sourceEnd is out of range");
- l >= u.byteLength && (l = u.byteLength), _ > c.byteLength && (_ = c.byteLength), u.byteLength - l < _ - m && (_ = u.length - l + m);
- const b = _ - m;
- return c === u ? u.copyWithin(l, m, _) : u.set(c.subarray(m, _), l), b;
- }, equals: function(c, u) {
- if (c === u) return !0;
- if (c.byteLength !== u.byteLength) return !1;
- const l = c.byteLength;
- c = new DataView(c.buffer, c.byteOffset, c.byteLength), u = new DataView(u.buffer, u.byteOffset, u.byteLength);
- let m = 0;
- for (let _ = l - l % 4; m < _; m += 4) if (c.getUint32(m, a) !== u.getUint32(m, a)) return !1;
- for (; m < l; m++) if (c.getUint8(m) !== u.getUint8(m)) return !1;
- return !0;
- }, fill: function(c, u, l, m, _) {
- if (typeof u == "string" ? typeof l == "string" ? (_ = l, l = 0, m = c.byteLength) : typeof m == "string" && (_ = m, m = c.byteLength) : typeof u == "number" ? u &= 255 : typeof u == "boolean" && (u = +u), l < 0 || c.byteLength < l || c.byteLength < m) throw new RangeError("Out of range index");
- if (l === void 0 && (l = 0), m === void 0 && (m = c.byteLength), m <= l) return c;
- if (u || (u = 0), typeof u == "number") for (let b = l; b < m; ++b) c[b] = u;
- else {
- const b = (u = g(u) ? u : d(u, _)).byteLength;
- for (let L = 0; L < m - l; ++L) c[L + l] = u[L % b];
- }
- return c;
- }, from: d, includes: function(c, u, l, m) {
- return y(c, u, l, m) !== -1;
- }, indexOf: y, lastIndexOf: function(c, u, l, m) {
- return p(c, u, l, m, !1);
- }, swap16: function(c) {
- const u = c.byteLength;
- if (u % 2 != 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
- for (let l = 0; l < u; l += 2) w(c, l, l + 1);
- return c;
- }, swap32: function(c) {
- const u = c.byteLength;
- if (u % 4 != 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
- for (let l = 0; l < u; l += 4) w(c, l, l + 3), w(c, l + 1, l + 2);
- return c;
- }, swap64: function(c) {
- const u = c.byteLength;
- if (u % 8 != 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
- for (let l = 0; l < u; l += 8) w(c, l, l + 7), w(c, l + 1, l + 6), w(c, l + 2, l + 5), w(c, l + 3, l + 4);
- return c;
- }, toBuffer: function(c) {
- return c;
- }, toString: function(c, u, l = 0, m = c.byteLength) {
- const _ = c.byteLength;
- return l >= _ || m <= l ? "" : (l < 0 && (l = 0), m > _ && (m = _), (l !== 0 || m < _) && (c = c.subarray(l, m)), h(u).toString(c));
- }, write: function(c, u, l, m, _) {
- return l === void 0 ? _ = "utf8" : m === void 0 && typeof l == "string" ? (_ = l, l = void 0) : _ === void 0 && typeof m == "string" && (_ = m, m = void 0), h(_).write(c, u, l, m);
- }, writeDoubleLE: function(c, u, l) {
- return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setFloat64(l, u, !0), l + 8;
- }, writeFloatLE: function(c, u, l) {
- return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setFloat32(l, u, !0), l + 4;
- }, writeUInt32LE: function(c, u, l) {
- return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setUint32(l, u, !0), l + 4;
- }, writeInt32LE: function(c, u, l) {
- return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setInt32(l, u, !0), l + 4;
- }, readDoubleLE: function(c, u) {
- return u === void 0 && (u = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getFloat64(u, !0);
- }, readFloatLE: function(c, u) {
- return u === void 0 && (u = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getFloat32(u, !0);
- }, readUInt32LE: function(c, u) {
- return u === void 0 && (u = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getUint32(u, !0);
- }, readInt32LE: function(c, u) {
- return u === void 0 && (u = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getInt32(u, !0);
- } };
-})(Yt, Yt.exports);
-var gn = Yt.exports;
-const fs = gn, ps = gn, ms = class {
- constructor(s) {
- this.encoding = s;
- }
decode(s) {
- return fs.toString(s, this.encoding);
+ return this.decoder.decode(s, { stream: !0 });
}
flush() {
- return "";
+ return this.decoder.decode(new Uint8Array(0));
}
-}, ys = class {
- constructor() {
- this.codePoint = 0, this.bytesSeen = 0, this.bytesNeeded = 0, this.lowerBoundary = 128, this.upperBoundary = 191;
- }
- decode(s) {
- if (this.bytesNeeded === 0) {
- let e = !0;
- for (let n = Math.max(0, s.byteLength - 4), r = s.byteLength; n < r && e; n++) e = s[n] <= 127;
- if (e) return ps.toString(s, "utf8");
- }
- let t = "";
- for (let e = 0, n = s.byteLength; e < n; e++) {
- const r = s[e];
- this.bytesNeeded !== 0 ? r < this.lowerBoundary || r > this.upperBoundary ? (this.codePoint = 0, this.bytesNeeded = 0, this.bytesSeen = 0, this.lowerBoundary = 128, this.upperBoundary = 191, t += "�") : (this.lowerBoundary = 128, this.upperBoundary = 191, this.codePoint = this.codePoint << 6 | 63 & r, this.bytesSeen++, this.bytesSeen === this.bytesNeeded && (t += String.fromCodePoint(this.codePoint), this.codePoint = 0, this.bytesNeeded = 0, this.bytesSeen = 0)) : r <= 127 ? t += String.fromCharCode(r) : r >= 194 && r <= 223 ? (this.bytesNeeded = 1, this.codePoint = 31 & r) : r >= 224 && r <= 239 ? (r === 224 ? this.lowerBoundary = 160 : r === 237 && (this.upperBoundary = 159), this.bytesNeeded = 2, this.codePoint = 15 & r) : r >= 240 && r <= 244 ? (r === 240 && (this.lowerBoundary = 144), r === 244 && (this.upperBoundary = 143), this.bytesNeeded = 3, this.codePoint = 7 & r) : t += "�";
- }
- return t;
- }
- flush() {
- const s = this.bytesNeeded > 0 ? "�" : "";
- return this.codePoint = 0, this.bytesNeeded = 0, this.bytesSeen = 0, this.lowerBoundary = 128, this.upperBoundary = 191, s;
- }
-}, { EventEmitter: _s } = dn, le = new Error("Stream was destroyed"), fn = (new Error("Premature close"), hs), pn = class {
+};
+const Yn = tn, Kn = tn, { EventEmitter: Zn } = Ke, re = new Error("Stream was destroyed"), en = (new Error("Premature close"), Vn), nn = class {
constructor(s) {
- this.hwm = s || 16, this.head = new Te(this.hwm), this.tail = this.head, this.length = 0;
+ this.hwm = s || 16, this.head = new Ce(this.hwm), this.tail = this.head, this.length = 0;
}
clear() {
this.head = this.tail, this.head.clear(), this.length = 0;
@@ -962,7 +622,7 @@ const fs = gn, ps = gn, ms = class {
push(s) {
if (this.length++, !this.head.push(s)) {
const t = this.head;
- this.head = t.next = new Te(2 * this.head.buffer.length), this.head.push(s);
+ this.head = t.next = new Ce(2 * this.head.buffer.length), this.head.push(s);
}
}
shift() {
@@ -981,7 +641,7 @@ const fs = gn, ps = gn, ms = class {
isEmpty() {
return this.length === 0;
}
-}, bs = class {
+}, Xn = class {
constructor(s = "utf8") {
switch (this.encoding = function(t) {
switch (t = t.toLowerCase()) {
@@ -1005,15 +665,18 @@ const fs = gn, ps = gn, ms = class {
}
}(s), this.encoding) {
case "utf8":
- this.decoder = new ys();
+ this.decoder = new Kn();
break;
case "utf16le":
case "base64":
throw new Error("Unsupported encoding: " + this.encoding);
default:
- this.decoder = new ms(this.encoding);
+ this.decoder = new Yn(this.encoding);
}
}
+ get remaining() {
+ return this.decoder.remaining;
+ }
push(s) {
return typeof s == "string" ? s : this.decoder.decode(s);
}
@@ -1024,35 +687,35 @@ const fs = gn, ps = gn, ms = class {
let t = "";
return s && (t = this.push(s)), t += this.decoder.flush(), t;
}
-}, ct = 536870911, mn = 1 ^ ct, ws = 2 ^ ct, yn = 64, Oe = 128, _n = 256, Ss = 1024, De = 2048, Cs = 4096, vs = 8192, Lt = 16384, Dt = 32768, te = 131072, Ls = 131328, ks = 16 ^ ct, Ne = 768 ^ ct, bn = 536838143, xs = 32 ^ ct, wn = 536739839, kt = 2 << 18, Sn = 4 << 18, Me = 8 << 18, As = 16 << 18, Cn = 32 << 18, ee = 64 << 18, Nt = 128 << 18, Ue = 512 << 18, Es = 1024 << 18, vn = 469499903, Ts = 535822335, Ln = 503316479, Is = 268435455, xt = 262160, Rs = 536608751, kn = 8404992, at = 14, Bs = 15, xn = 8405006, An = 33587200, En = 33587215, Ps = 2359296, Fe = 270794767, lt = Symbol.asyncIterator || Symbol("asyncIterator");
-class qs {
- constructor(t, { highWaterMark: e = 16384, map: n = null, mapWritable: r, byteLength: i, byteLengthWritable: o } = {}) {
- this.stream = t, this.queue = new pn(), this.highWaterMark = e, this.buffered = 0, this.error = null, this.pipeline = null, this.drains = null, this.byteLength = o || i || Bn, this.map = r || n, this.afterWrite = Us.bind(this), this.afterUpdateNextTick = $s.bind(this);
+}, it = 536870911, sn = 1 ^ it, ts = 2 ^ it, rn = 64, Pt = 128, on = 256, es = 1024, ve = 2048, ns = 4096, ss = 8192, St = 16384, qt = 32768, Gt = 131072, is = 131328, rs = 16 ^ it, ke = 536805375, Te = 768 ^ it, an = 536838143, os = 32 ^ it, hn = 536739839, wt = 2 << 18, cn = 4 << 18, xe = 8 << 18, as = 16 << 18, dn = 32 << 18, Jt = 64 << 18, Bt = 128 << 18, Le = 512 << 18, hs = 1024 << 18, ln = 469499903, cs = 535822335, un = 503316479, ds = 268435455, bt = 262160, ls = 536608751, gn = 8404992, nt = 14, us = 15, mn = 8405006, pn = 33587200, fn = 33587215, gs = 2359296, Ae = 270794767, ot = Symbol.asyncIterator || Symbol("asyncIterator");
+class ms {
+ constructor(t, { highWaterMark: e = 16384, map: n = null, mapWritable: i, byteLength: r, byteLengthWritable: o } = {}) {
+ this.stream = t, this.queue = new nn(), this.highWaterMark = e, this.buffered = 0, this.error = null, this.pipeline = null, this.drains = null, this.byteLength = o || r || wn, this.map = i || n, this.afterWrite = Ss.bind(this), this.afterUpdateNextTick = Cs.bind(this);
}
get ended() {
- return !!(this.stream._duplexState & Cn);
+ return !!(this.stream._duplexState & dn);
}
push(t) {
- return this.map !== null && (t = this.map(t)), this.buffered += this.byteLength(t), this.queue.push(t), this.buffered < this.highWaterMark ? (this.stream._duplexState |= Me, !0) : (this.stream._duplexState |= 6291456, !1);
+ return this.map !== null && (t = this.map(t)), this.buffered += this.byteLength(t), this.queue.push(t), this.buffered < this.highWaterMark ? (this.stream._duplexState |= xe, !0) : (this.stream._duplexState |= 6291456, !1);
}
shift() {
const t = this.queue.shift();
return this.buffered -= this.byteLength(t), this.buffered === 0 && (this.stream._duplexState &= 534773759), t;
}
end(t) {
- typeof t == "function" ? this.stream.once("finish", t) : t != null && this.push(t), this.stream._duplexState = (this.stream._duplexState | Ue) & Ts;
+ typeof t == "function" ? this.stream.once("finish", t) : t != null && this.push(t), this.stream._duplexState = (this.stream._duplexState | Le) & cs;
}
autoBatch(t, e) {
- const n = [], r = this.stream;
- for (n.push(t); (r._duplexState & Fe) === Ps; ) n.push(r._writableState.shift());
- if (r._duplexState & Bs) return e(null);
- r._writev(n, e);
+ const n = [], i = this.stream;
+ for (n.push(t); (i._duplexState & Ae) === gs; ) n.push(i._writableState.shift());
+ if (i._duplexState & us) return e(null);
+ i._writev(n, e);
}
update() {
const t = this.stream;
- t._duplexState |= kt;
+ t._duplexState |= wt;
do {
- for (; (t._duplexState & Fe) === Me; ) {
+ for (; (t._duplexState & Ae) === xe; ) {
const e = this.shift();
t._duplexState |= 67371008, t._write(e, this.afterWrite);
}
@@ -1062,38 +725,38 @@ class qs {
}
updateNonPrimary() {
const t = this.stream;
- if ((144965647 & t._duplexState) === Ue) return t._duplexState = 402653183 & t._duplexState | 262144, void t._final(Ms.bind(this));
- (t._duplexState & at) != 4 ? (t._duplexState & En) == 1 && (t._duplexState = (t._duplexState | xt) & mn, t._open(In.bind(this))) : t._duplexState & An || (t._duplexState |= xt, t._destroy(Tn.bind(this)));
+ if ((144965647 & t._duplexState) === Le) return t._duplexState = 402653183 & t._duplexState | 262144, void t._final(_s.bind(this));
+ (t._duplexState & nt) != 4 ? (t._duplexState & fn) == 1 && (t._duplexState = (t._duplexState | bt) & sn, t._open(_n.bind(this))) : t._duplexState & pn || (t._duplexState |= bt, t._destroy(yn.bind(this)));
}
continueUpdate() {
- return !!(this.stream._duplexState & Nt) && (this.stream._duplexState &= Ln, !0);
+ return !!(this.stream._duplexState & Bt) && (this.stream._duplexState &= un, !0);
}
updateCallback() {
- (35127311 & this.stream._duplexState) === Sn ? this.update() : this.updateNextTick();
+ (35127311 & this.stream._duplexState) === cn ? this.update() : this.updateNextTick();
}
updateNextTick() {
- this.stream._duplexState & Nt || (this.stream._duplexState |= Nt, this.stream._duplexState & kt || fn(this.afterUpdateNextTick));
+ this.stream._duplexState & Bt || (this.stream._duplexState |= Bt, this.stream._duplexState & wt || en(this.afterUpdateNextTick));
}
}
-class Os {
- constructor(t, { highWaterMark: e = 16384, map: n = null, mapReadable: r, byteLength: i, byteLengthReadable: o } = {}) {
- this.stream = t, this.queue = new pn(), this.highWaterMark = e === 0 ? 1 : e, this.buffered = 0, this.readAhead = e > 0, this.error = null, this.pipeline = null, this.byteLength = o || i || Bn, this.map = r || n, this.pipeTo = null, this.afterRead = Fs.bind(this), this.afterUpdateNextTick = Hs.bind(this);
+class ps {
+ constructor(t, { highWaterMark: e = 16384, map: n = null, mapReadable: i, byteLength: r, byteLengthReadable: o } = {}) {
+ this.stream = t, this.queue = new nn(), this.highWaterMark = e === 0 ? 1 : e, this.buffered = 0, this.readAhead = e > 0, this.error = null, this.pipeline = null, this.byteLength = o || r || wn, this.map = i || n, this.pipeTo = null, this.afterRead = ws.bind(this), this.afterUpdateNextTick = bs.bind(this);
}
get ended() {
- return !!(this.stream._duplexState & Lt);
+ return !!(this.stream._duplexState & St);
}
pipe(t, e) {
if (this.pipeTo !== null) throw new Error("Can only pipe to one destination");
- if (typeof e != "function" && (e = null), this.stream._duplexState |= 512, this.pipeTo = t, this.pipeline = new Ds(this.stream, t, e), e && this.stream.on("error", He), Rn(t)) t._writableState.pipeline = this.pipeline, e && t.on("error", He), t.on("finish", this.pipeline.finished.bind(this.pipeline));
+ if (typeof e != "function" && (e = null), this.stream._duplexState |= 512, this.pipeTo = t, this.pipeline = new fs(this.stream, t, e), e && this.stream.on("error", Ie), Sn(t)) t._writableState.pipeline = this.pipeline, e && t.on("error", Ie), t.on("finish", this.pipeline.finished.bind(this.pipeline));
else {
- const n = this.pipeline.done.bind(this.pipeline, t), r = this.pipeline.done.bind(this.pipeline, t, null);
- t.on("error", n), t.on("close", r), t.on("finish", this.pipeline.finished.bind(this.pipeline));
+ const n = this.pipeline.done.bind(this.pipeline, t), i = this.pipeline.done.bind(this.pipeline, t, null);
+ t.on("error", n), t.on("close", i), t.on("finish", this.pipeline.finished.bind(this.pipeline));
}
- t.on("drain", Ns.bind(this)), this.stream.emit("piping", t), t.emit("pipe", this.stream);
+ t.on("drain", ys.bind(this)), this.stream.emit("piping", t), t.emit("pipe", this.stream);
}
push(t) {
const e = this.stream;
- return t === null ? (this.highWaterMark = 0, e._duplexState = 536805311 & e._duplexState | 1024, !1) : (this.map !== null && (t = this.map(t)) === null || (this.buffered += this.byteLength(t), this.queue.push(t), e._duplexState = 536805375 & e._duplexState | 128), this.buffered < this.highWaterMark);
+ return t === null ? (this.highWaterMark = 0, e._duplexState = 536805311 & e._duplexState | 1024, !1) : this.map !== null && (t = this.map(t)) === null ? (e._duplexState &= ke, this.buffered < this.highWaterMark) : (this.buffered += this.byteLength(t), this.queue.push(t), e._duplexState = (e._duplexState | Pt) & ke, this.buffered < this.highWaterMark);
}
shift() {
const t = this.queue.shift();
@@ -1103,50 +766,50 @@ class Os {
const e = [this.map !== null ? this.map(t) : t];
for (; this.buffered > 0; ) e.push(this.shift());
for (let n = 0; n < e.length - 1; n++) {
- const r = e[n];
- this.buffered += this.byteLength(r), this.queue.push(r);
+ const i = e[n];
+ this.buffered += this.byteLength(i), this.queue.push(i);
}
this.push(e[e.length - 1]);
}
read() {
const t = this.stream;
- if ((16527 & t._duplexState) === Oe) {
+ if ((16527 & t._duplexState) === Pt) {
const e = this.shift();
- return this.pipeTo !== null && this.pipeTo.write(e) === !1 && (t._duplexState &= Ne), t._duplexState & De && t.emit("data", e), e;
+ return this.pipeTo !== null && this.pipeTo.write(e) === !1 && (t._duplexState &= Te), t._duplexState & ve && t.emit("data", e), e;
}
- return this.readAhead === !1 && (t._duplexState |= te, this.updateNextTick()), null;
+ return this.readAhead === !1 && (t._duplexState |= Gt, this.updateNextTick()), null;
}
drain() {
const t = this.stream;
- for (; (16527 & t._duplexState) === Oe && 768 & t._duplexState; ) {
+ for (; (16527 & t._duplexState) === Pt && 768 & t._duplexState; ) {
const e = this.shift();
- this.pipeTo !== null && this.pipeTo.write(e) === !1 && (t._duplexState &= Ne), t._duplexState & De && t.emit("data", e);
+ this.pipeTo !== null && this.pipeTo.write(e) === !1 && (t._duplexState &= Te), t._duplexState & ve && t.emit("data", e);
}
}
update() {
const t = this.stream;
t._duplexState |= 32;
do {
- for (this.drain(); this.buffered < this.highWaterMark && (214047 & t._duplexState) === te; ) t._duplexState |= 65552, t._read(this.afterRead), this.drain();
- (12431 & t._duplexState) == 4224 && (t._duplexState |= vs, t.emit("readable")), 80 & t._duplexState || this.updateNonPrimary();
+ for (this.drain(); this.buffered < this.highWaterMark && (214047 & t._duplexState) === Gt; ) t._duplexState |= 65552, t._read(this.afterRead), this.drain();
+ (12431 & t._duplexState) == 4224 && (t._duplexState |= ss, t.emit("readable")), 80 & t._duplexState || this.updateNonPrimary();
} while (this.continueUpdate() === !0);
- t._duplexState &= xs;
+ t._duplexState &= os;
}
updateNonPrimary() {
const t = this.stream;
- (1167 & t._duplexState) === Ss && (t._duplexState = 536869887 & t._duplexState | 16384, t.emit("end"), (t._duplexState & xn) === kn && (t._duplexState |= 4), this.pipeTo !== null && this.pipeTo.end()), (t._duplexState & at) != 4 ? (t._duplexState & En) == 1 && (t._duplexState = (t._duplexState | xt) & mn, t._open(In.bind(this))) : t._duplexState & An || (t._duplexState |= xt, t._destroy(Tn.bind(this)));
+ (1167 & t._duplexState) === es && (t._duplexState = 536869887 & t._duplexState | 16384, t.emit("end"), (t._duplexState & mn) === gn && (t._duplexState |= 4), this.pipeTo !== null && this.pipeTo.end()), (t._duplexState & nt) != 4 ? (t._duplexState & fn) == 1 && (t._duplexState = (t._duplexState | bt) & sn, t._open(_n.bind(this))) : t._duplexState & pn || (t._duplexState |= bt, t._destroy(yn.bind(this)));
}
continueUpdate() {
- return !!(this.stream._duplexState & Dt) && (this.stream._duplexState &= bn, !0);
+ return !!(this.stream._duplexState & qt) && (this.stream._duplexState &= an, !0);
}
updateCallback() {
- (32879 & this.stream._duplexState) === yn ? this.update() : this.updateNextTick();
+ (32879 & this.stream._duplexState) === rn ? this.update() : this.updateNextTick();
}
updateNextTick() {
- this.stream._duplexState & Dt || (this.stream._duplexState |= Dt, 32 & this.stream._duplexState || fn(this.afterUpdateNextTick));
+ this.stream._duplexState & qt || (this.stream._duplexState |= qt, 32 & this.stream._duplexState || en(this.afterUpdateNextTick));
}
}
-class Ds {
+class fs {
constructor(t, e, n) {
this.from = t, this.to = e, this.afterPipe = n, this.error = null, this.pipeToFinished = !1;
}
@@ -1154,50 +817,50 @@ class Ds {
this.pipeToFinished = !0;
}
done(t, e) {
- e && (this.error = e), t !== this.to || (this.to = null, this.from === null) ? t !== this.from || (this.from = null, this.to === null) ? (this.afterPipe !== null && this.afterPipe(this.error), this.to = this.from = this.afterPipe = null) : t._duplexState & Lt || this.to.destroy(this.error || new Error("Readable stream closed before ending")) : this.from._duplexState & Lt && this.pipeToFinished || this.from.destroy(this.error || new Error("Writable stream closed prematurely"));
+ e && (this.error = e), t !== this.to || (this.to = null, this.from === null) ? t !== this.from || (this.from = null, this.to === null) ? (this.afterPipe !== null && this.afterPipe(this.error), this.to = this.from = this.afterPipe = null) : t._duplexState & St || this.to.destroy(this.error || new Error("Readable stream closed before ending")) : this.from._duplexState & St && this.pipeToFinished || this.from.destroy(this.error || new Error("Writable stream closed prematurely"));
}
}
-function Ns() {
+function ys() {
this.stream._duplexState |= 512, this.updateCallback();
}
-function Ms(s) {
+function _s(s) {
const t = this.stream;
- s && t.destroy(s), t._duplexState & at || (t._duplexState |= Cn, t.emit("finish")), (t._duplexState & xn) === kn && (t._duplexState |= 4), t._duplexState &= vn, t._duplexState & kt ? this.updateNextTick() : this.update();
+ s && t.destroy(s), t._duplexState & nt || (t._duplexState |= dn, t.emit("finish")), (t._duplexState & mn) === gn && (t._duplexState |= 4), t._duplexState &= ln, t._duplexState & wt ? this.updateNextTick() : this.update();
}
-function Tn(s) {
+function yn(s) {
const t = this.stream;
- s || this.error === le || (s = this.error), s && t.emit("error", s), t._duplexState |= 8, t.emit("close");
+ s || this.error === re || (s = this.error), s && t.emit("error", s), t._duplexState |= 8, t.emit("close");
const e = t._readableState, n = t._writableState;
if (e !== null && e.pipeline !== null && e.pipeline.done(t, s), n !== null) {
for (; n.drains !== null && n.drains.length > 0; ) n.drains.shift().resolve(!1);
n.pipeline !== null && n.pipeline.done(t, s);
}
}
-function Us(s) {
+function Ss(s) {
const t = this.stream;
- s && t.destroy(s), t._duplexState &= vn, this.drains !== null && function(e) {
+ s && t.destroy(s), t._duplexState &= ln, this.drains !== null && function(e) {
for (let n = 0; n < e.length; n++) --e[n].writes == 0 && (e.shift().resolve(!0), n--);
- }(this.drains), (6553615 & t._duplexState) === As && (t._duplexState &= 532676607, (t._duplexState & ee) === ee && t.emit("drain")), this.updateCallback();
+ }(this.drains), (6553615 & t._duplexState) === as && (t._duplexState &= 532676607, (t._duplexState & Jt) === Jt && t.emit("drain")), this.updateCallback();
}
-function Fs(s) {
- s && this.stream.destroy(s), this.stream._duplexState &= ks, this.readAhead !== !1 || this.stream._duplexState & _n || (this.stream._duplexState &= wn), this.updateCallback();
+function ws(s) {
+ s && this.stream.destroy(s), this.stream._duplexState &= rs, this.readAhead !== !1 || this.stream._duplexState & on || (this.stream._duplexState &= hn), this.updateCallback();
}
-function Hs() {
- 32 & this.stream._duplexState || (this.stream._duplexState &= bn, this.update());
+function bs() {
+ 32 & this.stream._duplexState || (this.stream._duplexState &= an, this.update());
}
-function $s() {
- this.stream._duplexState & kt || (this.stream._duplexState &= Ln, this.update());
+function Cs() {
+ this.stream._duplexState & wt || (this.stream._duplexState &= un, this.update());
}
-function In(s) {
+function _n(s) {
const t = this.stream;
- s && t.destroy(s), 4 & t._duplexState || (17423 & t._duplexState || (t._duplexState |= yn), 142606351 & t._duplexState || (t._duplexState |= Sn), t.emit("open")), t._duplexState &= Rs, t._writableState !== null && t._writableState.updateCallback(), t._readableState !== null && t._readableState.updateCallback();
+ s && t.destroy(s), 4 & t._duplexState || (17423 & t._duplexState || (t._duplexState |= rn), 142606351 & t._duplexState || (t._duplexState |= cn), t.emit("open")), t._duplexState &= ls, t._writableState !== null && t._writableState.updateCallback(), t._readableState !== null && t._readableState.updateCallback();
}
-function js(s) {
- this._readableState !== null && (s === "data" && (this._duplexState |= 133376, this._readableState.updateNextTick()), s === "readable" && (this._duplexState |= Cs, this._readableState.updateNextTick())), this._writableState !== null && s === "drain" && (this._duplexState |= ee, this._writableState.updateNextTick());
+function vs(s) {
+ this._readableState !== null && (s === "data" && (this._duplexState |= 133376, this._readableState.updateNextTick()), s === "readable" && (this._duplexState |= ns, this._readableState.updateNextTick())), this._writableState !== null && s === "drain" && (this._duplexState |= Jt, this._writableState.updateNextTick());
}
-class Qs extends _s {
+class ks extends Zn {
constructor(t) {
- super(), this._duplexState = 0, this._readableState = null, this._writableState = null, t && (t.open && (this._open = t.open), t.destroy && (this._destroy = t.destroy), t.predestroy && (this._predestroy = t.predestroy), t.signal && t.signal.addEventListener("abort", Gs.bind(this))), this.on("newListener", js);
+ super(), this._duplexState = 0, this._readableState = null, this._writableState = null, t && (t.open && (this._open = t.open), t.destroy && (this._destroy = t.destroy), t.predestroy && (this._predestroy = t.predestroy), t.signal && t.signal.addEventListener("abort", As.bind(this))), this.on("newListener", vs);
}
_open(t) {
t(null);
@@ -1217,21 +880,21 @@ class Qs extends _s {
return !!(8 & this._duplexState);
}
get destroying() {
- return !!(this._duplexState & at);
+ return !!(this._duplexState & nt);
}
destroy(t) {
- this._duplexState & at || (t || (t = le), this._duplexState = 535822271 & this._duplexState | 4, this._readableState !== null && (this._readableState.highWaterMark = 0, this._readableState.error = t), this._writableState !== null && (this._writableState.highWaterMark = 0, this._writableState.error = t), this._duplexState |= 2, this._predestroy(), this._duplexState &= ws, this._readableState !== null && this._readableState.updateNextTick(), this._writableState !== null && this._writableState.updateNextTick());
+ this._duplexState & nt || (t || (t = re), this._duplexState = 535822271 & this._duplexState | 4, this._readableState !== null && (this._readableState.highWaterMark = 0, this._readableState.error = t), this._writableState !== null && (this._writableState.highWaterMark = 0, this._writableState.error = t), this._duplexState |= 2, this._predestroy(), this._duplexState &= ts, this._readableState !== null && this._readableState.updateNextTick(), this._writableState !== null && this._writableState.updateNextTick());
}
}
-class At extends Qs {
+class Ct extends ks {
constructor(t) {
- super(t), this._duplexState |= 8519681, this._readableState = new Os(this, t), t && (this._readableState.readAhead === !1 && (this._duplexState &= wn), t.read && (this._read = t.read), t.eagerOpen && this._readableState.updateNextTick(), t.encoding && this.setEncoding(t.encoding));
+ super(t), this._duplexState |= 8519681, this._readableState = new ps(this, t), t && (this._readableState.readAhead === !1 && (this._duplexState &= hn), t.read && (this._read = t.read), t.eagerOpen && this._readableState.updateNextTick(), t.encoding && this.setEncoding(t.encoding));
}
setEncoding(t) {
- const e = new bs(t), n = this._readableState.map || zs;
- return this._readableState.map = function(r) {
- const i = e.push(r);
- return i === "" ? null : n(i);
+ const e = new Xn(t), n = this._readableState.map || xs;
+ return this._readableState.map = function(i) {
+ const r = e.push(i);
+ return r === "" && (i.byteLength !== 0 || e.remaining > 0) ? null : n(r);
}, this;
}
_read(t) {
@@ -1250,80 +913,80 @@ class At extends Qs {
return this._readableState.updateNextTick(), this._readableState.unshift(t);
}
resume() {
- return this._duplexState |= Ls, this._readableState.updateNextTick(), this;
+ return this._duplexState |= is, this._readableState.updateNextTick(), this;
}
pause() {
return this._duplexState &= this._readableState.readAhead === !1 ? 536739583 : 536870655, this;
}
static _fromAsyncIterator(t, e) {
let n;
- const r = new At({ ...e, read(o) {
- t.next().then(i).then(o.bind(null, null)).catch(o);
+ const i = new Ct({ ...e, read(o) {
+ t.next().then(r).then(o.bind(null, null)).catch(o);
}, predestroy() {
n = t.return();
}, destroy(o) {
if (!n) return o(null);
n.then(o.bind(null, null)).catch(o);
} });
- return r;
- function i(o) {
- o.done ? r.push(null) : r.push(o.value);
+ return i;
+ function r(o) {
+ o.done ? i.push(null) : i.push(o.value);
}
}
static from(t, e) {
- if (Rn(n = t) && n.readable) return t;
+ if (Sn(n = t) && n.readable) return t;
var n;
- if (t[lt]) return this._fromAsyncIterator(t[lt](), e);
+ if (t[ot]) return this._fromAsyncIterator(t[ot](), e);
Array.isArray(t) || (t = t === void 0 ? [] : [t]);
- let r = 0;
- return new At({ ...e, read(i) {
- this.push(r === t.length ? null : t[r++]), i(null);
+ let i = 0;
+ return new Ct({ ...e, read(r) {
+ this.push(i === t.length ? null : t[i++]), r(null);
} });
}
static isBackpressured(t) {
return !!(17422 & t._duplexState) || t._readableState.buffered >= t._readableState.highWaterMark;
}
static isPaused(t) {
- return !(t._duplexState & _n);
+ return !(t._duplexState & on);
}
- [lt]() {
+ [ot]() {
const t = this;
- let e = null, n = null, r = null;
+ let e = null, n = null, i = null;
return this.on("error", (a) => {
e = a;
}), this.on("readable", function() {
- n !== null && i(t.read());
+ n !== null && r(t.read());
}), this.on("close", function() {
- n !== null && i(null);
- }), { [lt]() {
+ n !== null && r(null);
+ }), { [ot]() {
return this;
}, next: () => new Promise(function(a, h) {
- n = a, r = h;
- const g = t.read();
- g !== null ? i(g) : 8 & t._duplexState && i(null);
+ n = a, i = h;
+ const u = t.read();
+ u !== null ? r(u) : 8 & t._duplexState && r(null);
}), return: () => o(null), throw: (a) => o(a) };
- function i(a) {
- r !== null && (e ? r(e) : a !== null || t._duplexState & Lt ? n({ value: a, done: a === null }) : r(le), r = n = null);
+ function r(a) {
+ i !== null && (e ? i(e) : a !== null || t._duplexState & St ? n({ value: a, done: a === null }) : i(re), i = n = null);
}
function o(a) {
- return t.destroy(a), new Promise((h, g) => {
+ return t.destroy(a), new Promise((h, u) => {
if (8 & t._duplexState) return h({ value: void 0, done: !0 });
t.once("close", function() {
- a ? g(a) : h({ value: void 0, done: !0 });
+ a ? u(a) : h({ value: void 0, done: !0 });
});
});
}
}
}
-class Ws extends At {
+class Ts extends Ct {
constructor(t) {
- super(t), this._duplexState = 1 | this._duplexState & te, this._writableState = new qs(this, t), t && (t.writev && (this._writev = t.writev), t.write && (this._write = t.write), t.final && (this._final = t.final));
+ super(t), this._duplexState = 1 | this._duplexState & Gt, this._writableState = new ms(this, t), t && (t.writev && (this._writev = t.writev), t.write && (this._write = t.write), t.final && (this._final = t.final));
}
cork() {
- this._duplexState |= Es;
+ this._duplexState |= hs;
}
uncork() {
- this._duplexState &= Is, this._writableState.updateNextTick();
+ this._duplexState &= ds, this._writableState.updateNextTick();
}
_writev(t, e) {
e(null);
@@ -1341,85 +1004,85 @@ class Ws extends At {
return this._writableState.updateNextTick(), this._writableState.end(t), this;
}
}
-function zs(s) {
+function xs(s) {
return s;
}
-function Vs(s) {
+function Ls(s) {
return !!s._readableState || !!s._writableState;
}
-function Rn(s) {
- return typeof s._duplexState == "number" && Vs(s);
+function Sn(s) {
+ return typeof s._duplexState == "number" && Ls(s);
}
-function Bn(s) {
+function wn(s) {
return function(t) {
return typeof t == "object" && t !== null && typeof t.byteLength == "number";
}(s) ? s.byteLength : 1024;
}
-function He() {
+function Ie() {
}
-function Gs() {
+function As() {
this.destroy(new Error("Stream aborted."));
}
-var Pn = Ws;
-function $e(s, t) {
+var bn = Ts;
+function Ee(s, t) {
for (const e in t) Object.defineProperty(s, e, { value: t[e], enumerable: !0, configurable: !0 });
return s;
}
-const C = V(function(s, t, e) {
+const y = j(function(s, t, e) {
if (!s || typeof s == "string") throw new TypeError("Please pass an Error to err-code");
e || (e = {}), typeof t == "object" && (e = t, t = ""), t && (e.code = t);
try {
- return $e(s, e);
+ return Ee(s, e);
} catch {
e.message = s.message, e.stack = s.stack;
- const r = function() {
+ const i = function() {
};
- return r.prototype = Object.create(Object.getPrototypeOf(s)), $e(new r(), e);
+ return i.prototype = Object.create(Object.getPrototypeOf(s)), Ee(new i(), e);
}
-}), Et = "0123456789abcdef", qn = [], Tt = [];
-for (let s = 0; s < 256; s++) qn[s] = Et[s >> 4 & 15] + Et[15 & s], s < 16 && (s < 10 ? Tt[48 + s] = s : Tt[87 + s] = s);
-const X = (s) => {
+}), vt = "0123456789abcdef", Cn = [], kt = [];
+for (let s = 0; s < 256; s++) Cn[s] = vt[s >> 4 & 15] + vt[15 & s], s < 16 && (s < 10 ? kt[48 + s] = s : kt[87 + s] = s);
+const V = (s) => {
const t = s.length;
let e = "", n = 0;
- for (; n < t; ) e += qn[s[n++]];
+ for (; n < t; ) e += Cn[s[n++]];
return e;
-}, ne = (s) => {
+}, Vt = (s) => {
const t = s.length >> 1, e = t << 1, n = new Uint8Array(t);
- let r = 0, i = 0;
- for (; i < e; ) n[r++] = Tt[s.charCodeAt(i++)] << 4 | Tt[s.charCodeAt(i++)];
+ let i = 0, r = 0;
+ for (; r < e; ) n[i++] = kt[s.charCodeAt(r++)] << 4 | kt[s.charCodeAt(r++)];
return n;
};
-for (var Js = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ys = typeof Uint8Array > "u" ? [] : new Uint8Array(256), gt = 0; gt < 64; gt++) Ys[Js.charCodeAt(gt)] = gt;
-const Ks = new TextDecoder(), On = (s, t) => Ks.decode(s), Zs = new TextEncoder(), ge = (s) => Zs.encode(s), G = (s) => {
+for (var Is = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Es = typeof Uint8Array > "u" ? [] : new Uint8Array(256), at = 0; at < 64; at++) Es[Is.charCodeAt(at)] = at;
+const Rs = new TextDecoder(), vn = (s, t) => Rs.decode(s), Ps = new TextEncoder(), oe = (s) => Ps.encode(s), W = (s) => {
let t, e = "", n = 0;
- const r = s.length;
- for (; n < r; ) t = s.charCodeAt(n++), e += Et[t >> 4] + Et[15 & t];
+ const i = s.length;
+ for (; n < i; ) t = s.charCodeAt(n++), e += vt[t >> 4] + vt[15 & t];
return e;
-}, it = (s) => {
- const t = ne(s);
+}, tt = (s) => {
+ const t = Vt(s);
if (t.length <= 65536) return String.fromCharCode(...t);
let e = "", n = 0;
for (; n < t.length; ) e += String.fromCharCode(...t.subarray(n, n += 65536));
return e;
-}, je = typeof window < "u" ? window : self, se = je.crypto || je.msCrypto || {};
-se.subtle || se.webkitSubtle;
-const It = (s) => {
+}, Re = typeof window < "u" ? window : self, Yt = Re.crypto || Re.msCrypto || {};
+Yt.subtle || Yt.webkitSubtle;
+const Tt = (s) => {
const t = new Uint8Array(s);
- return se.getRandomValues(t);
-}, Xs = P("simple-peer"), Mt = 65536;
-function Qe(s) {
+ return Yt.getRandomValues(t);
+}, qs = A("simple-peer"), Ot = 65536;
+function Pe(s) {
return s.replace(/a=ice-options:trickle\s\n/g, "");
}
-let ot = class re extends Pn {
+let et = class Kt extends bn {
constructor(e) {
super(e = Object.assign({ allowHalfOpen: !1 }, e));
- f(this, "_pc");
- if (this.__objectMode = !!e.objectMode, this._id = X(It(4)).slice(0, 7), this._debug("new peer %o", e), this.channelName = e.initiator ? e.channelName || X(It(20)) : null, this.initiator = e.initiator || !1, this.channelConfig = e.channelConfig || re.channelConfig, this.channelNegotiated = this.channelConfig.negotiated, this.config = Object.assign({}, re.config, e.config), this.offerOptions = e.offerOptions || {}, this.answerOptions = e.answerOptions || {}, this.sdpTransform = e.sdpTransform || ((n) => n), this.trickle = e.trickle === void 0 || e.trickle, this.allowHalfTrickle = e.allowHalfTrickle !== void 0 && e.allowHalfTrickle, this.iceCompleteTimeout = e.iceCompleteTimeout || 5e3, this._destroying = !1, this._connected = !1, this.remoteAddress = void 0, this.remoteFamily = void 0, this.remotePort = void 0, this.localAddress = void 0, this.localFamily = void 0, this.localPort = void 0, !Jt) throw C(typeof window > "u" ? new Error("No WebRTC support: Specify `opts.wrtc` option in this environment") : new Error("No WebRTC support: Not a supported browser"), "ERR_WEBRTC_SUPPORT");
+ d(this, "_pc");
+ if (this.__objectMode = !!e.objectMode, this._id = V(Tt(4)).slice(0, 7), this._debug("new peer %o", e), this.channelName = e.initiator ? e.channelName || V(Tt(20)) : null, this.initiator = e.initiator || !1, this.channelConfig = e.channelConfig || Kt.channelConfig, this.channelNegotiated = this.channelConfig.negotiated, this.config = Object.assign({}, Kt.config, e.config), this.offerOptions = e.offerOptions || {}, this.answerOptions = e.answerOptions || {}, this.sdpTransform = e.sdpTransform || ((n) => n), this.trickle = e.trickle === void 0 || e.trickle, this.allowHalfTrickle = e.allowHalfTrickle !== void 0 && e.allowHalfTrickle, this.iceCompleteTimeout = e.iceCompleteTimeout || 5e3, this._destroying = !1, this._connected = !1, this.remoteAddress = void 0, this.remoteFamily = void 0, this.remotePort = void 0, this.localAddress = void 0, this.localFamily = void 0, this.localPort = void 0, !zt) throw y(typeof window > "u" ? new Error("No WebRTC support: Specify `opts.wrtc` option in this environment") : new Error("No WebRTC support: Not a supported browser"), "ERR_WEBRTC_SUPPORT");
this._pcReady = !1, this._channelReady = !1, this._iceComplete = !1, this._iceCompleteTimer = null, this._channel = null, this._pendingCandidates = [], this._isNegotiating = !1, this._firstNegotiation = !0, this._batchedNegotiation = !1, this._queuedNegotiation = !1, this._sendersAwaitingStable = [], this._closingInterval = null, this._remoteTracks = [], this._remoteStreams = [], this._chunk = null, this._cb = null, this._interval = null;
try {
- this._pc = new Jt(this.config);
+ this._pc = new zt(this.config);
} catch (n) {
- return void this.__destroy(C(n, "ERR_PC_CONSTRUCTOR"));
+ return void this.__destroy(y(n, "ERR_PC_CONSTRUCTOR"));
}
this._isReactNativeWebrtc = typeof this._pc._peerConnectionId == "number", this._pc.oniceconnectionstatechange = () => {
this._onIceStateChange();
@@ -1432,7 +1095,7 @@ let ot = class re extends Pn {
}, this._pc.onicecandidate = (n) => {
this._onIceCandidate(n);
}, typeof this._pc.peerIdentity == "object" && this._pc.peerIdentity.catch((n) => {
- this.__destroy(C(n, "ERR_PC_PEER_IDENTITY"));
+ this.__destroy(y(n, "ERR_PC_PEER_IDENTITY"));
}), this.initiator || this.channelNegotiated ? this._setupData({ channel: this._pc.createDataChannel(this.channelName, this.channelConfig) }) : this._pc.ondatachannel = (n) => {
this._setupData(n);
}, this._debug("initial negotiation"), this._needsNegotiation(), this._onFinishBound = () => {
@@ -1450,31 +1113,31 @@ let ot = class re extends Pn {
}
signal(e) {
if (!this._destroying) {
- if (this.destroyed) throw C(new Error("cannot signal after peer is destroyed"), "ERR_DESTROYED");
+ if (this.destroyed) throw y(new Error("cannot signal after peer is destroyed"), "ERR_DESTROYED");
if (typeof e == "string") try {
e = JSON.parse(e);
} catch {
e = {};
}
- this._debug("signal()"), e.renegotiate && this.initiator && (this._debug("got request to renegotiate"), this._needsNegotiation()), e.transceiverRequest && this.initiator && (this._debug("got request for transceiver"), this.addTransceiver(e.transceiverRequest.kind, e.transceiverRequest.init)), e.candidate && (this._pc.remoteDescription && this._pc.remoteDescription.type ? this._addIceCandidate(e.candidate) : this._pendingCandidates.push(e.candidate)), e.sdp && this._pc.setRemoteDescription(new os(e)).then(() => {
+ this._debug("signal()"), e.renegotiate && this.initiator && (this._debug("got request to renegotiate"), this._needsNegotiation()), e.transceiverRequest && this.initiator && (this._debug("got request for transceiver"), this.addTransceiver(e.transceiverRequest.kind, e.transceiverRequest.init)), e.candidate && (this._pc.remoteDescription && this._pc.remoteDescription.type ? this._addIceCandidate(e.candidate) : this._pendingCandidates.push(e.candidate)), e.sdp && this._pc.setRemoteDescription(new Gn(e)).then(() => {
this.destroyed || (this._pendingCandidates.forEach((n) => {
this._addIceCandidate(n);
}), this._pendingCandidates = [], this._pc.remoteDescription.type === "offer" && this._createAnswer());
}).catch((n) => {
- this.__destroy(C(n, "ERR_SET_REMOTE_DESCRIPTION"));
- }), e.sdp || e.candidate || e.renegotiate || e.transceiverRequest || this.__destroy(C(new Error("signal() called with invalid signal data"), "ERR_SIGNALING"));
+ this.__destroy(y(n, "ERR_SET_REMOTE_DESCRIPTION"));
+ }), e.sdp || e.candidate || e.renegotiate || e.transceiverRequest || this.__destroy(y(new Error("signal() called with invalid signal data"), "ERR_SIGNALING"));
}
}
_addIceCandidate(e) {
- const n = new as(e);
- this._pc.addIceCandidate(n).catch((r) => {
- var i;
- !n.address || n.address.endsWith(".local") ? (i = "Ignoring unsupported ICE candidate.", console.warn(i)) : this.__destroy(C(r, "ERR_ADD_ICE_CANDIDATE"));
+ const n = new Jn(e);
+ this._pc.addIceCandidate(n).catch((i) => {
+ var r;
+ !n.address || n.address.endsWith(".local") ? (r = "Ignoring unsupported ICE candidate.", console.warn(r)) : this.__destroy(y(i, "ERR_ADD_ICE_CANDIDATE"));
});
}
send(e) {
if (!this._destroying) {
- if (this.destroyed) throw C(new Error("cannot send after peer is destroyed"), "ERR_DESTROYED");
+ if (this.destroyed) throw y(new Error("cannot send after peer is destroyed"), "ERR_DESTROYED");
this._channel.send(e);
}
}
@@ -1485,7 +1148,7 @@ let ot = class re extends Pn {
}
negotiate() {
if (!this._destroying) {
- if (this.destroyed) throw C(new Error("cannot negotiate after peer is destroyed"), "ERR_DESTROYED");
+ if (this.destroyed) throw y(new Error("cannot negotiate after peer is destroyed"), "ERR_DESTROYED");
this.initiator ? this._isNegotiating ? (this._queuedNegotiation = !0, this._debug("already negotiating, queueing")) : (this._debug("start negotiation"), setTimeout(() => {
this._createOffer();
}, 0)) : this._isNegotiating ? (this._queuedNegotiation = !0, this._debug("already negotiating, queueing")) : (this._debug("requesting negotiation from initiator"), this.emit("signal", { type: "renegotiate", renegotiate: !0 })), this._isNegotiating = !0;
@@ -1518,18 +1181,18 @@ let ot = class re extends Pn {
}, 0));
}
_setupData(e) {
- if (!e.channel) return this.__destroy(C(new Error("Data channel event is missing `channel` property"), "ERR_DATA_CHANNEL"));
- this._channel = e.channel, this._channel.binaryType = "arraybuffer", typeof this._channel.bufferedAmountLowThreshold == "number" && (this._channel.bufferedAmountLowThreshold = Mt), this.channelName = this._channel.label, this._channel.onmessage = (r) => {
- this._onChannelMessage(r);
+ if (!e.channel) return this.__destroy(y(new Error("Data channel event is missing `channel` property"), "ERR_DATA_CHANNEL"));
+ this._channel = e.channel, this._channel.binaryType = "arraybuffer", typeof this._channel.bufferedAmountLowThreshold == "number" && (this._channel.bufferedAmountLowThreshold = Ot), this.channelName = this._channel.label, this._channel.onmessage = (i) => {
+ this._onChannelMessage(i);
}, this._channel.onbufferedamountlow = () => {
this._onChannelBufferedAmountLow();
}, this._channel.onopen = () => {
this._onChannelOpen();
}, this._channel.onclose = () => {
this._onChannelClose();
- }, this._channel.onerror = (r) => {
- const i = r.error instanceof Error ? r.error : new Error(`Datachannel error: ${r.message} ${r.filename}:${r.lineno}:${r.colno}`);
- this.__destroy(C(i, "ERR_DATA_CHANNEL"));
+ }, this._channel.onerror = (i) => {
+ const r = i.error instanceof Error ? i.error : new Error(`Datachannel error: ${i.message} ${i.filename}:${i.lineno}:${i.colno}`);
+ this.__destroy(y(r, "ERR_DATA_CHANNEL"));
};
let n = !1;
this._closingInterval = setInterval(() => {
@@ -1537,14 +1200,14 @@ let ot = class re extends Pn {
}, 5e3);
}
_write(e, n) {
- if (this.destroyed) return n(C(new Error("cannot write after peer is destroyed"), "ERR_DATA_CHANNEL"));
+ if (this.destroyed) return n(y(new Error("cannot write after peer is destroyed"), "ERR_DATA_CHANNEL"));
if (this._connected) {
try {
this.send(e);
- } catch (r) {
- return this.__destroy(C(r, "ERR_DATA_CHANNEL"));
+ } catch (i) {
+ return this.__destroy(y(i, "ERR_DATA_CHANNEL"));
}
- this._channel.bufferedAmount > Mt ? (this._debug("start backpressure: bufferedAmount %d", this._channel.bufferedAmount), this._cb = n) : n(null);
+ this._channel.bufferedAmount > Ot ? (this._debug("start backpressure: bufferedAmount %d", this._channel.bufferedAmount), this._cb = n) : n(null);
} else this._debug("write before connect"), this._chunk = e, this._cb = n;
}
_onFinish() {
@@ -1562,99 +1225,99 @@ let ot = class re extends Pn {
_createOffer() {
this.destroyed || this._pc.createOffer(this.offerOptions).then((e) => {
if (this.destroyed) return;
- this.trickle || this.allowHalfTrickle || (e.sdp = Qe(e.sdp)), e.sdp = this.sdpTransform(e.sdp);
+ this.trickle || this.allowHalfTrickle || (e.sdp = Pe(e.sdp)), e.sdp = this.sdpTransform(e.sdp);
const n = () => {
if (this.destroyed) return;
- const r = this._pc.localDescription || e;
- this._debug("signal"), this.emit("signal", { type: r.type, sdp: r.sdp });
+ const i = this._pc.localDescription || e;
+ this._debug("signal"), this.emit("signal", { type: i.type, sdp: i.sdp });
};
this._pc.setLocalDescription(e).then(() => {
this._debug("createOffer success"), this.destroyed || (this.trickle || this._iceComplete ? n() : this.once("_iceComplete", n));
- }).catch((r) => {
- this.__destroy(C(r, "ERR_SET_LOCAL_DESCRIPTION"));
+ }).catch((i) => {
+ this.__destroy(y(i, "ERR_SET_LOCAL_DESCRIPTION"));
});
}).catch((e) => {
- this.__destroy(C(e, "ERR_CREATE_OFFER"));
+ this.__destroy(y(e, "ERR_CREATE_OFFER"));
});
}
_createAnswer() {
this.destroyed || this._pc.createAnswer(this.answerOptions).then((e) => {
if (this.destroyed) return;
- this.trickle || this.allowHalfTrickle || (e.sdp = Qe(e.sdp)), e.sdp = this.sdpTransform(e.sdp);
+ this.trickle || this.allowHalfTrickle || (e.sdp = Pe(e.sdp)), e.sdp = this.sdpTransform(e.sdp);
const n = () => {
- var i;
+ var r;
if (this.destroyed) return;
- const r = this._pc.localDescription || e;
- this._debug("signal"), this.emit("signal", { type: r.type, sdp: r.sdp }), this.initiator || ((i = this._requestMissingTransceivers) == null || i.call(this));
+ const i = this._pc.localDescription || e;
+ this._debug("signal"), this.emit("signal", { type: i.type, sdp: i.sdp }), this.initiator || ((r = this._requestMissingTransceivers) == null || r.call(this));
};
this._pc.setLocalDescription(e).then(() => {
this.destroyed || (this.trickle || this._iceComplete ? n() : this.once("_iceComplete", n));
- }).catch((r) => {
- this.__destroy(C(r, "ERR_SET_LOCAL_DESCRIPTION"));
+ }).catch((i) => {
+ this.__destroy(y(i, "ERR_SET_LOCAL_DESCRIPTION"));
});
}).catch((e) => {
- this.__destroy(C(e, "ERR_CREATE_ANSWER"));
+ this.__destroy(y(e, "ERR_CREATE_ANSWER"));
});
}
_onConnectionStateChange() {
- this.destroyed || this._destroying || this._pc.connectionState === "failed" && this.__destroy(C(new Error("Connection failed."), "ERR_CONNECTION_FAILURE"));
+ this.destroyed || this._destroying || this._pc.connectionState === "failed" && this.__destroy(y(new Error("Connection failed."), "ERR_CONNECTION_FAILURE"));
}
_onIceStateChange() {
if (this.destroyed) return;
const e = this._pc.iceConnectionState, n = this._pc.iceGatheringState;
- this._debug("iceStateChange (connection: %s) (gathering: %s)", e, n), this.emit("iceStateChange", e, n), e !== "connected" && e !== "completed" || (this._pcReady = !0, this._maybeReady()), e === "failed" && this.__destroy(C(new Error("Ice connection failed."), "ERR_ICE_CONNECTION_FAILURE")), e === "closed" && this.__destroy(C(new Error("Ice connection closed."), "ERR_ICE_CONNECTION_CLOSED"));
+ this._debug("iceStateChange (connection: %s) (gathering: %s)", e, n), this.emit("iceStateChange", e, n), e !== "connected" && e !== "completed" || (this._pcReady = !0, this._maybeReady()), e === "failed" && this.__destroy(y(new Error("Ice connection failed."), "ERR_ICE_CONNECTION_FAILURE")), e === "closed" && this.__destroy(y(new Error("Ice connection closed."), "ERR_ICE_CONNECTION_CLOSED"));
}
getStats(e) {
- const n = (r) => (Object.prototype.toString.call(r.values) === "[object Array]" && r.values.forEach((i) => {
- Object.assign(r, i);
- }), r);
- this._pc.getStats.length === 0 || this._isReactNativeWebrtc ? this._pc.getStats().then((r) => {
- const i = [];
- r.forEach((o) => {
- i.push(n(o));
- }), e(null, i);
- }, (r) => e(r)) : this._pc.getStats.length > 0 ? this._pc.getStats((r) => {
+ const n = (i) => (Object.prototype.toString.call(i.values) === "[object Array]" && i.values.forEach((r) => {
+ Object.assign(i, r);
+ }), i);
+ this._pc.getStats.length === 0 || this._isReactNativeWebrtc ? this._pc.getStats().then((i) => {
+ const r = [];
+ i.forEach((o) => {
+ r.push(n(o));
+ }), e(null, r);
+ }, (i) => e(i)) : this._pc.getStats.length > 0 ? this._pc.getStats((i) => {
if (this.destroyed) return;
- const i = [];
- r.result().forEach((o) => {
+ const r = [];
+ i.result().forEach((o) => {
const a = {};
o.names().forEach((h) => {
a[h] = o.stat(h);
- }), a.id = o.id, a.type = o.type, a.timestamp = o.timestamp, i.push(n(a));
- }), e(null, i);
- }, (r) => e(r)) : e(null, []);
+ }), a.id = o.id, a.type = o.type, a.timestamp = o.timestamp, r.push(n(a));
+ }), e(null, r);
+ }, (i) => e(i)) : e(null, []);
}
_maybeReady() {
if (this._debug("maybeReady pc %s channel %s", this._pcReady, this._channelReady), this._connected || this._connecting || !this._pcReady || !this._channelReady) return;
this._connecting = !0;
const e = () => {
- this.destroyed || this._destroying || this.getStats((n, r) => {
+ this.destroyed || this._destroying || this.getStats((n, i) => {
if (this.destroyed || this._destroying) return;
- n && (r = []);
- const i = {}, o = {}, a = {};
+ n && (i = []);
+ const r = {}, o = {}, a = {};
let h = !1;
- r.forEach((d) => {
- d.type !== "remotecandidate" && d.type !== "remote-candidate" || (i[d.id] = d), d.type !== "localcandidate" && d.type !== "local-candidate" || (o[d.id] = d), d.type !== "candidatepair" && d.type !== "candidate-pair" || (a[d.id] = d);
+ i.forEach((c) => {
+ c.type !== "remotecandidate" && c.type !== "remote-candidate" || (r[c.id] = c), c.type !== "localcandidate" && c.type !== "local-candidate" || (o[c.id] = c), c.type !== "candidatepair" && c.type !== "candidate-pair" || (a[c.id] = c);
});
- const g = (d) => {
+ const u = (c) => {
h = !0;
- let p = o[d.localCandidateId];
- p && (p.ip || p.address) ? (this.localAddress = p.ip || p.address, this.localPort = Number(p.port)) : p && p.ipAddress ? (this.localAddress = p.ipAddress, this.localPort = Number(p.portNumber)) : typeof d.googLocalAddress == "string" && (p = d.googLocalAddress.split(":"), this.localAddress = p[0], this.localPort = Number(p[1])), this.localAddress && (this.localFamily = this.localAddress.includes(":") ? "IPv6" : "IPv4");
- let y = i[d.remoteCandidateId];
- y && (y.ip || y.address) ? (this.remoteAddress = y.ip || y.address, this.remotePort = Number(y.port)) : y && y.ipAddress ? (this.remoteAddress = y.ipAddress, this.remotePort = Number(y.portNumber)) : typeof d.googRemoteAddress == "string" && (y = d.googRemoteAddress.split(":"), this.remoteAddress = y[0], this.remotePort = Number(y[1])), this.remoteAddress && (this.remoteFamily = this.remoteAddress.includes(":") ? "IPv6" : "IPv4"), this._debug("connect local: %s:%s remote: %s:%s", this.localAddress, this.localPort, this.remoteAddress, this.remotePort);
+ let l = o[c.localCandidateId];
+ l && (l.ip || l.address) ? (this.localAddress = l.ip || l.address, this.localPort = Number(l.port)) : l && l.ipAddress ? (this.localAddress = l.ipAddress, this.localPort = Number(l.portNumber)) : typeof c.googLocalAddress == "string" && (l = c.googLocalAddress.split(":"), this.localAddress = l[0], this.localPort = Number(l[1])), this.localAddress && (this.localFamily = this.localAddress.includes(":") ? "IPv6" : "IPv4");
+ let g = r[c.remoteCandidateId];
+ g && (g.ip || g.address) ? (this.remoteAddress = g.ip || g.address, this.remotePort = Number(g.port)) : g && g.ipAddress ? (this.remoteAddress = g.ipAddress, this.remotePort = Number(g.portNumber)) : typeof c.googRemoteAddress == "string" && (g = c.googRemoteAddress.split(":"), this.remoteAddress = g[0], this.remotePort = Number(g[1])), this.remoteAddress && (this.remoteFamily = this.remoteAddress.includes(":") ? "IPv6" : "IPv4"), this._debug("connect local: %s:%s remote: %s:%s", this.localAddress, this.localPort, this.remoteAddress, this.remotePort);
};
- if (r.forEach((d) => {
- d.type === "transport" && d.selectedCandidatePairId && g(a[d.selectedCandidatePairId]), (d.type === "googCandidatePair" && d.googActiveConnection === "true" || (d.type === "candidatepair" || d.type === "candidate-pair") && d.selected) && g(d);
+ if (i.forEach((c) => {
+ c.type === "transport" && c.selectedCandidatePairId && u(a[c.selectedCandidatePairId]), (c.type === "googCandidatePair" && c.googActiveConnection === "true" || (c.type === "candidatepair" || c.type === "candidate-pair") && c.selected) && u(c);
}), h || Object.keys(a).length && !Object.keys(o).length) {
if (this._connecting = !1, this._connected = !0, this._chunk) {
try {
this.send(this._chunk);
- } catch (p) {
- return this.__destroy(C(p, "ERR_DATA_CHANNEL"));
+ } catch (l) {
+ return this.__destroy(y(l, "ERR_DATA_CHANNEL"));
}
this._chunk = null, this._debug('sent chunk from "write before connect"');
- const d = this._cb;
- this._cb = null, d(null);
+ const c = this._cb;
+ this._cb = null, c(null);
}
typeof this._channel.bufferedAmountLowThreshold != "number" && (this._interval = setInterval(() => this._onInterval(), 150), this._interval.unref && this._interval.unref()), this._debug("connect"), this.emit("connect");
} else setTimeout(e, 100);
@@ -1663,7 +1326,7 @@ let ot = class re extends Pn {
e();
}
_onInterval() {
- !this._cb || !this._channel || this._channel.bufferedAmount > Mt || this._onChannelBufferedAmountLow();
+ !this._cb || !this._channel || this._channel.bufferedAmount > Ot || this._onChannelBufferedAmountLow();
}
_onSignalingStateChange() {
this.destroyed || (this._pc.signalingState === "stable" && (this._isNegotiating = !1, this._debug("flushing sender queue", this._sendersAwaitingStable), this._sendersAwaitingStable.forEach((e) => {
@@ -1676,7 +1339,7 @@ let ot = class re extends Pn {
_onChannelMessage(e) {
if (this.destroyed) return;
let n = e.data;
- n instanceof ArrayBuffer ? n = new Uint8Array(n) : this.__objectMode === !1 && (n = ge(n)), this.push(n);
+ n instanceof ArrayBuffer ? n = new Uint8Array(n) : this.__objectMode === !1 && (n = oe(n)), this.push(n);
}
_onChannelBufferedAmountLow() {
if (this.destroyed || !this._cb) return;
@@ -1692,28 +1355,28 @@ let ot = class re extends Pn {
}
_debug() {
const e = [].slice.call(arguments);
- e[0] = "[" + this._id + "] " + e[0], Xs.apply(null, e);
+ e[0] = "[" + this._id + "] " + e[0], qs.apply(null, e);
}
};
-ot.WEBRTC_SUPPORT = !!Jt, ot.config = { iceServers: [{ urls: ["stun:stun.l.google.com:19302", "stun:global.stun.twilio.com:3478"] }], sdpSemantics: "unified-plan" }, ot.channelConfig = {};
-const B = {}, ie = { DEFAULT_ANNOUNCE_PEERS: 50, MAX_ANNOUNCE_PEERS: 82, parseUrl: (s) => {
+et.WEBRTC_SUPPORT = !!zt, et.config = { iceServers: [{ urls: ["stun:stun.l.google.com:19302", "stun:global.stun.twilio.com:3478"] }], sdpSemantics: "unified-plan" }, et.channelConfig = {};
+const L = {}, Zt = { DEFAULT_ANNOUNCE_PEERS: 50, MAX_ANNOUNCE_PEERS: 82, parseUrl: (s) => {
const t = new URL(s.replace(/^udp:/, "http:"));
return s.match(/^udp:/) && Object.defineProperties(t, { href: { value: t.href.replace(/^http/, "udp") }, protocol: { value: t.protocol.replace(/^http/, "udp") }, origin: { value: t.origin.replace(/^http/, "udp") } }), t;
-}, ...Object.freeze(Object.defineProperty({ __proto__: null, default: B }, Symbol.toStringTag, { value: "Module" })) }, tr = P("simple-websocket"), st = typeof B != "function" ? WebSocket : B;
-class Dn extends Pn {
+}, ...Object.freeze(Object.defineProperty({ __proto__: null, default: L }, Symbol.toStringTag, { value: "Module" })) }, Bs = A("simple-websocket"), Z = typeof L != "function" ? WebSocket : L;
+class kn extends bn {
constructor(t = {}) {
if (typeof t == "string" && (t = { url: t }), super(t = Object.assign({ allowHalfOpen: !1 }, t)), this.__objectMode = !!t.objectMode, t.objectMode != null && delete t.objectMode, t.url == null && t.socket == null) throw new Error("Missing required `url` or `socket` option");
if (t.url != null && t.socket != null) throw new Error("Must specify either `url` or `socket` option, not both");
- if (this._id = X(It(4)).slice(0, 7), this._debug("new websocket: %o", t), this.connected = !1, this._chunk = null, this._cb = null, this._interval = null, t.socket) this.url = t.socket.url, this._ws = t.socket, this.connected = t.socket.readyState === st.OPEN;
+ if (this._id = V(Tt(4)).slice(0, 7), this._debug("new websocket: %o", t), this.connected = !1, this._chunk = null, this._cb = null, this._interval = null, t.socket) this.url = t.socket.url, this._ws = t.socket, this.connected = t.socket.readyState === Z.OPEN;
else {
this.url = t.url;
try {
- this._ws = typeof B == "function" ? new st(t.url, { ...t, encoding: void 0 }) : new st(t.url);
+ this._ws = typeof L == "function" ? new Z(t.url, { ...t, encoding: void 0 }) : new Z(t.url);
} catch (e) {
- return void Gt(() => this.destroy(e));
+ return void Qt(() => this.destroy(e));
}
}
- this._ws.binaryType = "arraybuffer", t.socket && this.connected ? Gt(() => this._handleOpen()) : this._ws.onopen = () => this._handleOpen(), this._ws.onmessage = (e) => this._handleMessage(e), this._ws.onclose = () => this._handleClose(), this._ws.onerror = (e) => this._handleError(e), this._handleFinishBound = () => this._handleFinish(), this.once("finish", this._handleFinishBound);
+ this._ws.binaryType = "arraybuffer", t.socket && this.connected ? Qt(() => this._handleOpen()) : this._ws.onopen = () => this._handleOpen(), this._ws.onmessage = (e) => this._handleMessage(e), this._ws.onclose = () => this._handleClose(), this._ws.onerror = (e) => this._handleError(e), this._handleFinishBound = () => this._handleFinish(), this.once("finish", this._handleFinishBound);
}
send(t) {
this._ws.send(t);
@@ -1727,7 +1390,7 @@ class Dn extends Pn {
const e = this._ws, n = () => {
e.onclose = null;
};
- if (e.readyState === st.CLOSED) n();
+ if (e.readyState === Z.CLOSED) n();
else try {
e.onclose = n, e.close();
} catch {
@@ -1747,7 +1410,7 @@ class Dn extends Pn {
} catch (n) {
return this.destroy(n);
}
- typeof B != "function" && this._ws.bufferedAmount > 65536 ? (this._debug("start backpressure: bufferedAmount %d", this._ws.bufferedAmount), this._cb = e) : e(null);
+ typeof L != "function" && this._ws.bufferedAmount > 65536 ? (this._debug("start backpressure: bufferedAmount %d", this._ws.bufferedAmount), this._cb = e) : e(null);
} else this._debug("write before connect"), this._chunk = t, this._cb = e;
}
_handleOpen() {
@@ -1762,13 +1425,13 @@ class Dn extends Pn {
const t = this._cb;
this._cb = null, t(null);
}
- typeof B != "function" && (this._interval = setInterval(() => this._onInterval(), 150), this._interval.unref && this._interval.unref()), this._debug("connect"), this.emit("connect");
+ typeof L != "function" && (this._interval = setInterval(() => this._onInterval(), 150), this._interval.unref && this._interval.unref()), this._debug("connect"), this.emit("connect");
}
}
_handleMessage(t) {
if (this.destroyed) return;
let e = t.data;
- e instanceof ArrayBuffer && (e = new Uint8Array(e)), this.__objectMode === !1 && (e = ge(e)), this.push(e);
+ e instanceof ArrayBuffer && (e = new Uint8Array(e)), this.__objectMode === !1 && (e = oe(e)), this.push(e);
}
_handleClose() {
this.destroyed || (this._debug("on close"), this.destroy());
@@ -1791,11 +1454,11 @@ class Dn extends Pn {
}
_debug() {
const t = [].slice.call(arguments);
- t[0] = "[" + this._id + "] " + t[0], tr.apply(null, t);
+ t[0] = "[" + this._id + "] " + t[0], Bs.apply(null, t);
}
}
-Dn.WEBSOCKET_SUPPORT = !!st;
-class er extends un {
+kn.WEBSOCKET_SUPPORT = !!Z;
+class Os extends Ze {
constructor(t, e) {
super(), this.client = t, this.announceUrl = e, this.interval = null, this.destroyed = !1;
}
@@ -1805,10 +1468,10 @@ class er extends un {
}, t), this.interval.unref && this.interval.unref());
}
}
-const I = P("bittorrent-tracker:websocket-tracker"), O = {};
-class oe extends er {
+const T = A("bittorrent-tracker:websocket-tracker"), E = {};
+class Xt extends Os {
constructor(t, e) {
- super(t, e), I("new websocket tracker %s", e), this.peers = {}, this.socket = null, this.reconnecting = !1, this.retries = 0, this.reconnectTimer = null, this.expectingResponse = !1, this._openSocket();
+ super(t, e), T("new websocket tracker %s", e), this.peers = {}, this.socket = null, this.reconnecting = !1, this.retries = 0, this.reconnectTimer = null, this.expectingResponse = !1, this._openSocket();
}
announce(t) {
if (this.destroyed || this.reconnecting) return;
@@ -1819,8 +1482,8 @@ class oe extends er {
if (this._trackerId && (e.trackerid = this._trackerId), t.event === "stopped" || t.event === "completed") this._send(e);
else {
const n = Math.min(t.numwant, 5);
- this._generateOffers(n, (r) => {
- e.numwant = n, e.offers = r, this._send(e);
+ this._generateOffers(n, (i) => {
+ e.numwant = n, e.offers = i, this._send(e);
});
}
}
@@ -1829,23 +1492,23 @@ class oe extends er {
if (!this.socket.connected) return void this.socket.once("connect", () => {
this.scrape(t);
});
- const e = { action: "scrape", info_hash: Array.isArray(t.infoHash) && t.infoHash.length > 0 ? t.infoHash.map((n) => it(n)) : t.infoHash && it(t.infoHash) || this.client._infoHashBinary };
+ const e = { action: "scrape", info_hash: Array.isArray(t.infoHash) && t.infoHash.length > 0 ? t.infoHash.map((n) => tt(n)) : t.infoHash && tt(t.infoHash) || this.client._infoHashBinary };
this._send(e);
}
- destroy(t = We) {
+ destroy(t = qe) {
if (this.destroyed) return t(null);
this.destroyed = !0, clearInterval(this.interval), clearTimeout(this.reconnectTimer);
- for (const i in this.peers) {
- const o = this.peers[i];
+ for (const r in this.peers) {
+ const o = this.peers[r];
clearTimeout(o.trackerTimeout), o.destroy();
}
- if (this.peers = null, this.socket && (this.socket.removeListener("connect", this._onSocketConnectBound), this.socket.removeListener("data", this._onSocketDataBound), this.socket.removeListener("close", this._onSocketCloseBound), this.socket.removeListener("error", this._onSocketErrorBound), this.socket = null), this._onSocketConnectBound = null, this._onSocketErrorBound = null, this._onSocketDataBound = null, this._onSocketCloseBound = null, O[this.announceUrl] && (O[this.announceUrl].consumers -= 1), O[this.announceUrl].consumers > 0) return t();
- let e, n = O[this.announceUrl];
- if (delete O[this.announceUrl], n.on("error", We), n.once("close", t), !this.expectingResponse) return r();
- function r() {
- e && (clearTimeout(e), e = null), n.removeListener("data", r), n.destroy(), n = null;
+ if (this.peers = null, this.socket && (this.socket.removeListener("connect", this._onSocketConnectBound), this.socket.removeListener("data", this._onSocketDataBound), this.socket.removeListener("close", this._onSocketCloseBound), this.socket.removeListener("error", this._onSocketErrorBound), this.socket = null), this._onSocketConnectBound = null, this._onSocketErrorBound = null, this._onSocketDataBound = null, this._onSocketCloseBound = null, E[this.announceUrl] && (E[this.announceUrl].consumers -= 1), E[this.announceUrl].consumers > 0) return t();
+ let e, n = E[this.announceUrl];
+ if (delete E[this.announceUrl], n.on("error", qe), n.once("close", t), !this.expectingResponse) return i();
+ function i() {
+ e && (clearTimeout(e), e = null), n.removeListener("data", i), n.destroy(), n = null;
}
- e = setTimeout(r, ie.DESTROY_TIMEOUT), n.once("data", r);
+ e = setTimeout(i, Zt.DESTROY_TIMEOUT), n.once("data", i);
}
_openSocket() {
if (this.destroyed = !1, this.peers || (this.peers = {}), this._onSocketConnectBound = () => {
@@ -1856,11 +1519,11 @@ class oe extends er {
this._onSocketData(t);
}, this._onSocketCloseBound = () => {
this._onSocketClose();
- }, this.socket = O[this.announceUrl], this.socket) O[this.announceUrl].consumers += 1, this.socket.connected && this._onSocketConnectBound();
+ }, this.socket = E[this.announceUrl], this.socket) E[this.announceUrl].consumers += 1, this.socket.connected && this._onSocketConnectBound();
else {
const t = new URL(this.announceUrl);
let e;
- this.client._proxyOpts && (e = t.protocol === "wss:" ? this.client._proxyOpts.httpsAgent : this.client._proxyOpts.httpAgent, !e && this.client._proxyOpts.socksProxy && (e = this.client._proxyOpts.socksProxy)), this.socket = O[this.announceUrl] = new Dn({ url: this.announceUrl, agent: e }), this.socket.consumers = 1, this.socket.once("connect", this._onSocketConnectBound);
+ this.client._proxyOpts && (e = t.protocol === "wss:" ? this.client._proxyOpts.httpsAgent : this.client._proxyOpts.httpAgent, !e && this.client._proxyOpts.socksProxy && (e = this.client._proxyOpts.socksProxy)), this.socket = E[this.announceUrl] = new kn({ url: this.announceUrl, agent: e }), this.socket.consumers = 1, this.socket.once("connect", this._onSocketConnectBound);
}
this.socket.on("data", this._onSocketDataBound), this.socket.once("close", this._onSocketCloseBound), this.socket.once("error", this._onSocketErrorBound);
}
@@ -1871,7 +1534,7 @@ class oe extends er {
if (!this.destroyed) {
this.expectingResponse = !1;
try {
- t = JSON.parse(On(t));
+ t = JSON.parse(vn(t));
} catch {
return void this.client.emit("warning", new Error("Invalid tracker response"));
}
@@ -1879,35 +1542,35 @@ class oe extends er {
}
}
_onAnnounceResponse(t) {
- if (t.info_hash !== this.client._infoHashBinary) return void I("ignoring websocket data from %s for %s (looking for %s: reused socket)", this.announceUrl, G(t.info_hash), this.client.infoHash);
+ if (t.info_hash !== this.client._infoHashBinary) return void T("ignoring websocket data from %s for %s (looking for %s: reused socket)", this.announceUrl, W(t.info_hash), this.client.infoHash);
if (t.peer_id && t.peer_id === this.client._peerIdBinary) return;
- I("received %s from %s for %s", JSON.stringify(t), this.announceUrl, this.client.infoHash);
+ T("received %s from %s for %s", JSON.stringify(t), this.announceUrl, this.client.infoHash);
const e = t["failure reason"];
if (e) return this.client.emit("warning", new Error(e));
const n = t["warning message"];
n && this.client.emit("warning", new Error(n));
- const r = t.interval || t["min interval"];
- r && this.setInterval(1e3 * r);
- const i = t["tracker id"];
- if (i && (this._trackerId = i), t.complete != null) {
- const a = Object.assign({}, t, { announce: this.announceUrl, infoHash: G(t.info_hash) });
+ const i = t.interval || t["min interval"];
+ i && this.setInterval(1e3 * i);
+ const r = t["tracker id"];
+ if (r && (this._trackerId = r), t.complete != null) {
+ const a = Object.assign({}, t, { announce: this.announceUrl, infoHash: W(t.info_hash) });
this.client.emit("update", a);
}
let o;
- if (t.offer && t.peer_id && (I("creating peer (from remote offer)"), o = this._createPeer(), o.id = G(t.peer_id), o.once("signal", (a) => {
+ if (t.offer && t.peer_id && (T("creating peer (from remote offer)"), o = this._createPeer(), o.id = W(t.peer_id), o.once("signal", (a) => {
const h = { action: "announce", info_hash: this.client._infoHashBinary, peer_id: this.client._peerIdBinary, to_peer_id: t.peer_id, answer: a, offer_id: t.offer_id };
this._trackerId && (h.trackerid = this._trackerId), this._send(h);
}), this.client.emit("peer", o), o.signal(t.offer)), t.answer && t.peer_id) {
- const a = G(t.offer_id);
- o = this.peers[a], o ? (o.id = G(t.peer_id), this.client.emit("peer", o), o.signal(t.answer), clearTimeout(o.trackerTimeout), o.trackerTimeout = null, delete this.peers[a]) : I(`got unexpected answer: ${JSON.stringify(t.answer)}`);
+ const a = W(t.offer_id);
+ o = this.peers[a], o ? (o.id = W(t.peer_id), this.client.emit("peer", o), o.signal(t.answer), clearTimeout(o.trackerTimeout), o.trackerTimeout = null, delete this.peers[a]) : T(`got unexpected answer: ${JSON.stringify(t.answer)}`);
}
}
_onScrapeResponse(t) {
t = t.files || {};
const e = Object.keys(t);
e.length !== 0 ? e.forEach((n) => {
- const r = Object.assign(t[n], { announce: this.announceUrl, infoHash: G(n) });
- this.client.emit("scrape", r);
+ const i = Object.assign(t[n], { announce: this.announceUrl, infoHash: W(n) });
+ this.client.emit("scrape", i);
}) : this.client.emit("warning", new Error("invalid scrape response"));
}
_onSocketClose() {
@@ -1920,89 +1583,89 @@ class oe extends er {
const t = Math.floor(3e5 * Math.random()) + Math.min(1e4 * Math.pow(2, this.retries), 36e5);
this.reconnecting = !0, clearTimeout(this.reconnectTimer), this.reconnectTimer = setTimeout(() => {
this.retries++, this._openSocket();
- }, t), this.reconnectTimer.unref && this.reconnectTimer.unref(), I("reconnecting socket in %s ms", t);
+ }, t), this.reconnectTimer.unref && this.reconnectTimer.unref(), T("reconnecting socket in %s ms", t);
}
_send(t) {
if (this.destroyed) return;
this.expectingResponse = !0;
const e = JSON.stringify(t);
- I("send %s", e), this.socket.send(e);
+ T("send %s", e), this.socket.send(e);
}
_generateOffers(t, e) {
- const n = this, r = [];
- I("generating %s offers", t);
- for (let a = 0; a < t; ++a) i();
- function i() {
- const a = X(It(20));
- I("creating peer (from _generateOffers)");
+ const n = this, i = [];
+ T("generating %s offers", t);
+ for (let a = 0; a < t; ++a) r();
+ function r() {
+ const a = V(Tt(20));
+ T("creating peer (from _generateOffers)");
const h = n.peers[a] = n._createPeer({ initiator: !0 });
- h.once("signal", (g) => {
- r.push({ offer: g, offer_id: it(a) }), o();
+ h.once("signal", (u) => {
+ i.push({ offer: u, offer_id: tt(a) }), o();
}), h.trackerTimeout = setTimeout(() => {
- I("tracker timeout: destroying peer"), h.trackerTimeout = null, delete n.peers[a], h.destroy();
+ T("tracker timeout: destroying peer"), h.trackerTimeout = null, delete n.peers[a], h.destroy();
}, 5e4), h.trackerTimeout.unref && h.trackerTimeout.unref();
}
function o() {
- r.length === t && (I("generated %s offers", t), e(r));
+ i.length === t && (T("generated %s offers", t), e(i));
}
o();
}
_createPeer(t) {
const e = this;
t = Object.assign({ trickle: !1, config: e.client._rtcConfig, wrtc: e.client._wrtc }, t);
- const n = new ot(t);
- return n.once("error", r), n.once("connect", function i() {
- n.removeListener("error", r), n.removeListener("connect", i);
+ const n = new et(t);
+ return n.once("error", i), n.once("connect", function r() {
+ n.removeListener("error", i), n.removeListener("connect", r);
}), n;
- function r(i) {
- e.client.emit("warning", new Error(`Connection error: ${i.message}`)), n.destroy();
+ function i(r) {
+ e.client.emit("warning", new Error(`Connection error: ${r.message}`)), n.destroy();
}
}
}
-function We() {
+function qe() {
}
-oe.prototype.DEFAULT_ANNOUNCE_INTERVAL = 3e4, oe._socketPool = O;
-const F = P("bittorrent-tracker:client");
-class ae extends un {
+Xt.prototype.DEFAULT_ANNOUNCE_INTERVAL = 3e4, Xt._socketPool = E;
+const M = A("bittorrent-tracker:client");
+class te extends Ze {
constructor(t = {}) {
if (super(), !t.peerId) throw new Error("Option `peerId` is required");
if (!t.infoHash) throw new Error("Option `infoHash` is required");
if (!t.announce) throw new Error("Option `announce` is required");
- if (!wt.browser && !t.port) throw new Error("Option `port` is required");
- this.peerId = typeof t.peerId == "string" ? t.peerId : X(t.peerId), this._peerIdBuffer = ne(this.peerId), this._peerIdBinary = it(this.peerId), this.infoHash = typeof t.infoHash == "string" ? t.infoHash.toLowerCase() : X(t.infoHash), this._infoHashBuffer = ne(this.infoHash), this._infoHashBinary = it(this.infoHash), F("new client %s", this.infoHash), this.destroyed = !1, this._port = t.port, this._getAnnounceOpts = t.getAnnounceOpts, this._rtcConfig = t.rtcConfig, this._userAgent = t.userAgent, this._proxyOpts = t.proxyOpts, this._wrtc = typeof t.wrtc == "function" ? t.wrtc() : t.wrtc;
+ if (!ft.browser && !t.port) throw new Error("Option `port` is required");
+ this.peerId = typeof t.peerId == "string" ? t.peerId : V(t.peerId), this._peerIdBuffer = Vt(this.peerId), this._peerIdBinary = tt(this.peerId), this.infoHash = typeof t.infoHash == "string" ? t.infoHash.toLowerCase() : V(t.infoHash), this._infoHashBuffer = Vt(this.infoHash), this._infoHashBinary = tt(this.infoHash), M("new client %s", this.infoHash), this.destroyed = !1, this._port = t.port, this._getAnnounceOpts = t.getAnnounceOpts, this._rtcConfig = t.rtcConfig, this._userAgent = t.userAgent, this._proxyOpts = t.proxyOpts, this._wrtc = typeof t.wrtc == "function" ? t.wrtc() : t.wrtc;
let e = typeof t.announce == "string" ? [t.announce] : t.announce == null ? [] : t.announce;
- e = e.map((i) => (ArrayBuffer.isView(i) && (i = On(i)), i[i.length - 1] === "/" && (i = i.substring(0, i.length - 1)), i)), e = Array.from(new Set(e));
- const n = this._wrtc !== !1 && (!!this._wrtc || ot.WEBRTC_SUPPORT), r = (i) => {
- Gt(() => {
- this.emit("warning", i);
+ e = e.map((r) => (ArrayBuffer.isView(r) && (r = vn(r)), r[r.length - 1] === "/" && (r = r.substring(0, r.length - 1)), r)), e = Array.from(new Set(e));
+ const n = this._wrtc !== !1 && (!!this._wrtc || et.WEBRTC_SUPPORT), i = (r) => {
+ Qt(() => {
+ this.emit("warning", r);
});
};
- this._trackers = e.map((i) => {
+ this._trackers = e.map((r) => {
let o;
try {
- o = ie.parseUrl(i);
+ o = Zt.parseUrl(r);
} catch {
- return r(new Error(`Invalid tracker URL: ${i}`)), null;
+ return i(new Error(`Invalid tracker URL: ${r}`)), null;
}
const a = o.port;
- if (a < 0 || a > 65535) return r(new Error(`Invalid tracker port: ${i}`)), null;
+ if (a < 0 || a > 65535) return i(new Error(`Invalid tracker port: ${r}`)), null;
const h = o.protocol;
- return h !== "http:" && h !== "https:" || typeof B != "function" ? h === "udp:" && typeof B == "function" ? new B(this, i) : h !== "ws:" && h !== "wss:" || !n || h === "ws:" && typeof window < "u" && window.location.protocol === "https:" ? (r(new Error(`Unsupported tracker protocol: ${i}`)), null) : new oe(this, i) : new B(this, i);
+ return h !== "http:" && h !== "https:" || typeof L != "function" ? h === "udp:" && typeof L == "function" ? new L(this, r) : h !== "ws:" && h !== "wss:" || !n || h === "ws:" && typeof window < "u" && window.location.protocol === "https:" ? (i(new Error(`Unsupported tracker protocol: ${r}`)), null) : new Xt(this, r) : new L(this, r);
}).filter(Boolean);
}
start(t) {
- (t = this._defaultAnnounceOpts(t)).event = "started", F("send `start` %o", t), this._announce(t), this._trackers.forEach((e) => {
+ (t = this._defaultAnnounceOpts(t)).event = "started", M("send `start` %o", t), this._announce(t), this._trackers.forEach((e) => {
e.setInterval();
});
}
stop(t) {
- (t = this._defaultAnnounceOpts(t)).event = "stopped", F("send `stop` %o", t), this._announce(t);
+ (t = this._defaultAnnounceOpts(t)).event = "stopped", M("send `stop` %o", t), this._announce(t);
}
complete(t) {
- t || (t = {}), (t = this._defaultAnnounceOpts(t)).event = "completed", F("send `complete` %o", t), this._announce(t);
+ t || (t = {}), (t = this._defaultAnnounceOpts(t)).event = "completed", M("send `complete` %o", t), this._announce(t);
}
update(t) {
- (t = this._defaultAnnounceOpts(t)).event && delete t.event, F("send `update` %o", t), this._announce(t);
+ (t = this._defaultAnnounceOpts(t)).event && delete t.event, M("send `update` %o", t), this._announce(t);
}
_announce(t) {
this._trackers.forEach((e) => {
@@ -2010,220 +1673,220 @@ class ae extends un {
});
}
scrape(t) {
- F("send `scrape`"), t || (t = {}), this._trackers.forEach((e) => {
+ M("send `scrape`"), t || (t = {}), this._trackers.forEach((e) => {
e.scrape(t);
});
}
setInterval(t) {
- F("setInterval %d", t), this._trackers.forEach((e) => {
+ M("setInterval %d", t), this._trackers.forEach((e) => {
e.setInterval(t);
});
}
destroy(t) {
if (this.destroyed) return;
- this.destroyed = !0, F("destroy");
- const e = this._trackers.map((n) => (r) => {
- n.destroy(r);
+ this.destroyed = !0, M("destroy");
+ const e = this._trackers.map((n) => (i) => {
+ n.destroy(i);
});
- is(e, t), this._trackers = [], this._getAnnounceOpts = null;
+ zn(e, t), this._trackers = [], this._getAnnounceOpts = null;
}
_defaultAnnounceOpts(t = {}) {
- return t.numwant == null && (t.numwant = ie.DEFAULT_ANNOUNCE_PEERS), t.uploaded == null && (t.uploaded = 0), t.downloaded == null && (t.downloaded = 0), this._getAnnounceOpts && (t = Object.assign({}, t, this._getAnnounceOpts())), t;
+ return t.numwant == null && (t.numwant = Zt.DEFAULT_ANNOUNCE_PEERS), t.uploaded == null && (t.uploaded = 0), t.downloaded == null && (t.downloaded = 0), this._getAnnounceOpts && (t = Object.assign({}, t, this._getAnnounceOpts())), t;
}
}
-ae.scrape = (s, t) => {
- if (t = ns(t), !s.infoHash) throw new Error("Option `infoHash` is required");
+te.scrape = (s, t) => {
+ if (t = jn(t), !s.infoHash) throw new Error("Option `infoHash` is required");
if (!s.announce) throw new Error("Option `announce` is required");
- const e = Object.assign({}, s, { infoHash: Array.isArray(s.infoHash) ? s.infoHash[0] : s.infoHash, peerId: ge("01234567890123456789"), port: 6881 }), n = new ae(e);
+ const e = Object.assign({}, s, { infoHash: Array.isArray(s.infoHash) ? s.infoHash[0] : s.infoHash, peerId: oe("01234567890123456789"), port: 6881 }), n = new te(e);
n.once("error", t), n.once("warning", t);
- let r = Array.isArray(s.infoHash) ? s.infoHash.length : 1;
- const i = {};
+ let i = Array.isArray(s.infoHash) ? s.infoHash.length : 1;
+ const r = {};
return n.on("scrape", (o) => {
- if (r -= 1, i[o.infoHash] = o, r === 0) {
+ if (i -= 1, r[o.infoHash] = o, i === 0) {
n.destroy();
- const a = Object.keys(i);
- a.length === 1 ? t(null, i[a[0]]) : t(null, i);
+ const a = Object.keys(r);
+ a.length === 1 ? t(null, r[a[0]]) : t(null, r);
}
}), n.scrape({ infoHash: s.infoHash }), n;
};
-var Nn = { exports: {} };
-function k(s, t, e, n, r, i, o) {
- var a = s + (t & e | ~t & n) + (r >>> 0) + o;
- return (a << i | a >>> 32 - i) + t;
+var Tn = { exports: {} };
+function S(s, t, e, n, i, r, o) {
+ var a = s + (t & e | ~t & n) + (i >>> 0) + o;
+ return (a << r | a >>> 32 - r) + t;
}
-function x(s, t, e, n, r, i, o) {
- var a = s + (t & n | e & ~n) + (r >>> 0) + o;
- return (a << i | a >>> 32 - i) + t;
+function w(s, t, e, n, i, r, o) {
+ var a = s + (t & n | e & ~n) + (i >>> 0) + o;
+ return (a << r | a >>> 32 - r) + t;
}
-function A(s, t, e, n, r, i, o) {
- var a = s + (t ^ e ^ n) + (r >>> 0) + o;
- return (a << i | a >>> 32 - i) + t;
+function b(s, t, e, n, i, r, o) {
+ var a = s + (t ^ e ^ n) + (i >>> 0) + o;
+ return (a << r | a >>> 32 - r) + t;
}
-function E(s, t, e, n, r, i, o) {
- var a = s + (e ^ (t | ~n)) + (r >>> 0) + o;
- return (a << i | a >>> 32 - i) + t;
+function C(s, t, e, n, i, r, o) {
+ var a = s + (e ^ (t | ~n)) + (i >>> 0) + o;
+ return (a << r | a >>> 32 - r) + t;
}
-function ft(s) {
+function ht(s) {
return String.fromCharCode(255 & s);
}
-function pt(s) {
- return ft(s) + ft(s >>> 8) + ft(s >>> 16) + ft(s >>> 24);
+function ct(s) {
+ return ht(s) + ht(s >>> 8) + ht(s >>> 16) + ht(s >>> 24);
}
-var he = function(s) {
+var ee = function(s) {
return unescape(encodeURIComponent(s));
-}, qt = Nn.exports = function(s) {
- return nr(s).toHex();
-}, Ct = qt.fromBytes = function(s) {
- for (var t = function(w) {
- for (var c = w.length, u = c << 3, l = new Uint32Array(c + 72 >>> 6 << 4), m = 0, _ = w.length; m < _; ++m) l[m >>> 2] |= w.charCodeAt(m) << ((3 & m) << 3);
- return l[c >> 2] |= 128 << (31 & u), l[l.length - 2] = u, l;
- }(s), e = 1732584193, n = 4023233417, r = 2562383102, i = 271733878, o = 0, a = t.length; o < a; o += 16) {
- var h = e, g = n, d = r, p = i;
- e = k(e, n, r, i, t[o + 0], 7, 3614090360), i = k(i, e, n, r, t[o + 1], 12, 3905402710), r = k(r, i, e, n, t[o + 2], 17, 606105819), n = k(n, r, i, e, t[o + 3], 22, 3250441966), e = k(e, n, r, i, t[o + 4], 7, 4118548399), i = k(i, e, n, r, t[o + 5], 12, 1200080426), r = k(r, i, e, n, t[o + 6], 17, 2821735955), n = k(n, r, i, e, t[o + 7], 22, 4249261313), e = k(e, n, r, i, t[o + 8], 7, 1770035416), i = k(i, e, n, r, t[o + 9], 12, 2336552879), r = k(r, i, e, n, t[o + 10], 17, 4294925233), n = k(n, r, i, e, t[o + 11], 22, 2304563134), e = k(e, n, r, i, t[o + 12], 7, 1804603682), i = k(i, e, n, r, t[o + 13], 12, 4254626195), r = k(r, i, e, n, t[o + 14], 17, 2792965006), e = x(e, n = k(n, r, i, e, t[o + 15], 22, 1236535329), r, i, t[o + 1], 5, 4129170786), i = x(i, e, n, r, t[o + 6], 9, 3225465664), r = x(r, i, e, n, t[o + 11], 14, 643717713), n = x(n, r, i, e, t[o + 0], 20, 3921069994), e = x(e, n, r, i, t[o + 5], 5, 3593408605), i = x(i, e, n, r, t[o + 10], 9, 38016083), r = x(r, i, e, n, t[o + 15], 14, 3634488961), n = x(n, r, i, e, t[o + 4], 20, 3889429448), e = x(e, n, r, i, t[o + 9], 5, 568446438), i = x(i, e, n, r, t[o + 14], 9, 3275163606), r = x(r, i, e, n, t[o + 3], 14, 4107603335), n = x(n, r, i, e, t[o + 8], 20, 1163531501), e = x(e, n, r, i, t[o + 13], 5, 2850285829), i = x(i, e, n, r, t[o + 2], 9, 4243563512), r = x(r, i, e, n, t[o + 7], 14, 1735328473), e = A(e, n = x(n, r, i, e, t[o + 12], 20, 2368359562), r, i, t[o + 5], 4, 4294588738), i = A(i, e, n, r, t[o + 8], 11, 2272392833), r = A(r, i, e, n, t[o + 11], 16, 1839030562), n = A(n, r, i, e, t[o + 14], 23, 4259657740), e = A(e, n, r, i, t[o + 1], 4, 2763975236), i = A(i, e, n, r, t[o + 4], 11, 1272893353), r = A(r, i, e, n, t[o + 7], 16, 4139469664), n = A(n, r, i, e, t[o + 10], 23, 3200236656), e = A(e, n, r, i, t[o + 13], 4, 681279174), i = A(i, e, n, r, t[o + 0], 11, 3936430074), r = A(r, i, e, n, t[o + 3], 16, 3572445317), n = A(n, r, i, e, t[o + 6], 23, 76029189), e = A(e, n, r, i, t[o + 9], 4, 3654602809), i = A(i, e, n, r, t[o + 12], 11, 3873151461), r = A(r, i, e, n, t[o + 15], 16, 530742520), e = E(e, n = A(n, r, i, e, t[o + 2], 23, 3299628645), r, i, t[o + 0], 6, 4096336452), i = E(i, e, n, r, t[o + 7], 10, 1126891415), r = E(r, i, e, n, t[o + 14], 15, 2878612391), n = E(n, r, i, e, t[o + 5], 21, 4237533241), e = E(e, n, r, i, t[o + 12], 6, 1700485571), i = E(i, e, n, r, t[o + 3], 10, 2399980690), r = E(r, i, e, n, t[o + 10], 15, 4293915773), n = E(n, r, i, e, t[o + 1], 21, 2240044497), e = E(e, n, r, i, t[o + 8], 6, 1873313359), i = E(i, e, n, r, t[o + 15], 10, 4264355552), r = E(r, i, e, n, t[o + 6], 15, 2734768916), n = E(n, r, i, e, t[o + 13], 21, 1309151649), e = E(e, n, r, i, t[o + 4], 6, 4149444226), i = E(i, e, n, r, t[o + 11], 10, 3174756917), r = E(r, i, e, n, t[o + 2], 15, 718787259), n = E(n, r, i, e, t[o + 9], 21, 3951481745), e = e + h >>> 0, n = n + g >>> 0, r = r + d >>> 0, i = i + p >>> 0;
+}, It = Tn.exports = function(s) {
+ return Ds(s).toHex();
+}, _t = It.fromBytes = function(s) {
+ for (var t = function(m) {
+ for (var f = m.length, v = f << 3, F = new Uint32Array(f + 72 >>> 6 << 4), D = 0, Rt = m.length; D < Rt; ++D) F[D >>> 2] |= m.charCodeAt(D) << ((3 & D) << 3);
+ return F[f >> 2] |= 128 << (31 & v), F[F.length - 2] = v, F;
+ }(s), e = 1732584193, n = 4023233417, i = 2562383102, r = 271733878, o = 0, a = t.length; o < a; o += 16) {
+ var h = e, u = n, c = i, l = r;
+ e = S(e, n, i, r, t[o + 0], 7, 3614090360), r = S(r, e, n, i, t[o + 1], 12, 3905402710), i = S(i, r, e, n, t[o + 2], 17, 606105819), n = S(n, i, r, e, t[o + 3], 22, 3250441966), e = S(e, n, i, r, t[o + 4], 7, 4118548399), r = S(r, e, n, i, t[o + 5], 12, 1200080426), i = S(i, r, e, n, t[o + 6], 17, 2821735955), n = S(n, i, r, e, t[o + 7], 22, 4249261313), e = S(e, n, i, r, t[o + 8], 7, 1770035416), r = S(r, e, n, i, t[o + 9], 12, 2336552879), i = S(i, r, e, n, t[o + 10], 17, 4294925233), n = S(n, i, r, e, t[o + 11], 22, 2304563134), e = S(e, n, i, r, t[o + 12], 7, 1804603682), r = S(r, e, n, i, t[o + 13], 12, 4254626195), i = S(i, r, e, n, t[o + 14], 17, 2792965006), e = w(e, n = S(n, i, r, e, t[o + 15], 22, 1236535329), i, r, t[o + 1], 5, 4129170786), r = w(r, e, n, i, t[o + 6], 9, 3225465664), i = w(i, r, e, n, t[o + 11], 14, 643717713), n = w(n, i, r, e, t[o + 0], 20, 3921069994), e = w(e, n, i, r, t[o + 5], 5, 3593408605), r = w(r, e, n, i, t[o + 10], 9, 38016083), i = w(i, r, e, n, t[o + 15], 14, 3634488961), n = w(n, i, r, e, t[o + 4], 20, 3889429448), e = w(e, n, i, r, t[o + 9], 5, 568446438), r = w(r, e, n, i, t[o + 14], 9, 3275163606), i = w(i, r, e, n, t[o + 3], 14, 4107603335), n = w(n, i, r, e, t[o + 8], 20, 1163531501), e = w(e, n, i, r, t[o + 13], 5, 2850285829), r = w(r, e, n, i, t[o + 2], 9, 4243563512), i = w(i, r, e, n, t[o + 7], 14, 1735328473), e = b(e, n = w(n, i, r, e, t[o + 12], 20, 2368359562), i, r, t[o + 5], 4, 4294588738), r = b(r, e, n, i, t[o + 8], 11, 2272392833), i = b(i, r, e, n, t[o + 11], 16, 1839030562), n = b(n, i, r, e, t[o + 14], 23, 4259657740), e = b(e, n, i, r, t[o + 1], 4, 2763975236), r = b(r, e, n, i, t[o + 4], 11, 1272893353), i = b(i, r, e, n, t[o + 7], 16, 4139469664), n = b(n, i, r, e, t[o + 10], 23, 3200236656), e = b(e, n, i, r, t[o + 13], 4, 681279174), r = b(r, e, n, i, t[o + 0], 11, 3936430074), i = b(i, r, e, n, t[o + 3], 16, 3572445317), n = b(n, i, r, e, t[o + 6], 23, 76029189), e = b(e, n, i, r, t[o + 9], 4, 3654602809), r = b(r, e, n, i, t[o + 12], 11, 3873151461), i = b(i, r, e, n, t[o + 15], 16, 530742520), e = C(e, n = b(n, i, r, e, t[o + 2], 23, 3299628645), i, r, t[o + 0], 6, 4096336452), r = C(r, e, n, i, t[o + 7], 10, 1126891415), i = C(i, r, e, n, t[o + 14], 15, 2878612391), n = C(n, i, r, e, t[o + 5], 21, 4237533241), e = C(e, n, i, r, t[o + 12], 6, 1700485571), r = C(r, e, n, i, t[o + 3], 10, 2399980690), i = C(i, r, e, n, t[o + 10], 15, 4293915773), n = C(n, i, r, e, t[o + 1], 21, 2240044497), e = C(e, n, i, r, t[o + 8], 6, 1873313359), r = C(r, e, n, i, t[o + 15], 10, 4264355552), i = C(i, r, e, n, t[o + 6], 15, 2734768916), n = C(n, i, r, e, t[o + 13], 21, 1309151649), e = C(e, n, i, r, t[o + 4], 6, 4149444226), r = C(r, e, n, i, t[o + 11], 10, 3174756917), i = C(i, r, e, n, t[o + 2], 15, 718787259), n = C(n, i, r, e, t[o + 9], 21, 3951481745), e = e + h >>> 0, n = n + u >>> 0, i = i + c >>> 0, r = r + l >>> 0;
}
- var y = new String(pt(e) + pt(n) + pt(r) + pt(i));
- return y.toHex = function() {
- for (var w = "", c = 0, u = y.length; c < u; ++c) w += (256 + (255 & y.charCodeAt(c))).toString(16).substr(-2);
- return w;
- }, y;
-}, nr = qt.fromUtf8 = function(s) {
- return Ct(he(s));
-}, Mn = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-function ze(s, t) {
- for (var e = ""; --t >= 0; s >>>= 6) e += Mn.charAt(63 & s);
+ var g = new String(ct(e) + ct(n) + ct(i) + ct(r));
+ return g.toHex = function() {
+ for (var m = "", f = 0, v = g.length; f < v; ++f) m += (256 + (255 & g.charCodeAt(f))).toString(16).substr(-2);
+ return m;
+ }, g;
+}, Ds = It.fromUtf8 = function(s) {
+ return _t(ee(s));
+}, xn = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+function Be(s, t) {
+ for (var e = ""; --t >= 0; s >>>= 6) e += xn.charAt(63 & s);
return e;
}
-var mt = [0, 6, 12, 1, 7, 13, 2, 8, 14, 3, 9, 15, 4, 10, 5, 11], sr = qt.salt = function(s) {
+var dt = [0, 6, 12, 1, 7, 13, 2, 8, 14, 3, 9, 15, 4, 10, 5, 11], Ms = It.salt = function(s) {
var t = "";
s || (s = 8);
do
- t += Mn.charAt(64 * Math.random() >>> 0);
+ t += xn.charAt(64 * Math.random() >>> 0);
while (--s);
return t;
};
-qt.crypt = function(s, t) {
+It.crypt = function(s, t) {
if (s.length > 64) throw Error("too long key");
- t || (t = "$1$" + sr()), s = he(s);
- for (var e = he(t.replace(/^\$1\$([^$]+)(?:\$.*)?$/, "$1")), n = Ct(s + e + s), r = s + "$1$" + e, i = s.length; i > 16; i -= 16) r += n;
- for (r += n.slice(0, i), i = s.length; i; i >>= 1) r += 1 & i ? "\0" : s.charAt(0);
- n = Ct(r);
- for (var o = 0; o < 1e3; ++o) n = Ct((1 & o ? s : n) + (o % 3 ? e : "") + (o % 7 ? s : "") + (1 & o ? n : s));
+ t || (t = "$1$" + Ms()), s = ee(s);
+ for (var e = ee(t.replace(/^\$1\$([^$]+)(?:\$.*)?$/, "$1")), n = _t(s + e + s), i = s + "$1$" + e, r = s.length; r > 16; r -= 16) i += n;
+ for (i += n.slice(0, r), r = s.length; r; r >>= 1) i += 1 & r ? "\0" : s.charAt(0);
+ n = _t(i);
+ for (var o = 0; o < 1e3; ++o) n = _t((1 & o ? s : n) + (o % 3 ? e : "") + (o % 7 ? s : "") + (1 & o ? n : s));
var a = "$1$" + e + "$";
- for (o = 0; o < 15; o += 3) a += ze(n.charCodeAt(mt[o + 0]) << 16 | n.charCodeAt(mt[o + 1]) << 8 | n.charCodeAt(mt[o + 2]), 4);
- return a + ze(n.charCodeAt(mt[15]), 2);
+ for (o = 0; o < 15; o += 3) a += Be(n.charCodeAt(dt[o + 0]) << 16 | n.charCodeAt(dt[o + 1]) << 8 | n.charCodeAt(dt[o + 2]), 4);
+ return a + Be(n.charCodeAt(dt[15]), 2);
};
-const rr = V(Nn.exports), ir = `-PM${function(s) {
+const Ns = j(Tn.exports), Fs = `-PM${function(s) {
const t = s.split(".");
return `${t[0].padStart(2, "0")}${t[1].padStart(2, "0")}`;
-}("1.0.5")}-`, or = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-function z(s) {
+}("2.0.1")}-`, Us = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+function $(s) {
return `${s.type}-${s.index}`;
}
-function Ve(s) {
+function Oe(s) {
const { externalId: t } = s;
- return `(${z(s.stream)} | ${t})`;
+ return `(${$(s.stream)} | ${t})`;
}
-function ce(s, t) {
- t === void 0 && (t = s.reduce((r, i) => r + i.byteLength, 0));
+function ne(s, t) {
+ t === void 0 && (t = s.reduce((i, r) => i + r.byteLength, 0));
const e = new Uint8Array(t);
let n = 0;
- for (const r of s) e.set(r, n), n += r.byteLength;
+ for (const i of s) e.set(i, n), n += i.byteLength;
return e;
}
-function Ge(s) {
+function De(s) {
const t = new TextEncoder(), e = new Uint8Array(s.length);
return t.encodeInto(s, e), e;
}
-function* Je(s) {
+function* Me(s) {
for (let t = s.length - 1; t >= 0; t--) yield s[t];
}
-function Un(s) {
+function Ln(s) {
return !!s && typeof s == "object" && !Array.isArray(s);
}
-function K(s) {
+function G(s) {
if (function(t) {
return Array.isArray(t);
- }(s)) return s.map((t) => K(t));
- if (Un(s)) {
+ }(s)) return s.map((t) => G(t));
+ if (Ln(s)) {
const t = {};
- for (const e of Object.keys(s)) t[e] = K(s[e]);
+ for (const e of Object.keys(s)) t[e] = G(s[e]);
return t;
}
return s;
}
-function et(s, t, e = {}) {
+function K(s, t, e = {}) {
return typeof s != "object" || s === null || typeof t != "object" || t === null || Object.keys(t).forEach((n) => {
if (n === "__proto__" || n === "constructor" || n === "prototype") throw new Error(`Attempt to modify restricted property '${String(n)}'`);
- const r = t[n], i = e[n];
- n in s && (s[n] = r === void 0 ? i === void 0 ? void 0 : i : r);
+ const i = t[n], r = e[n];
+ n in s && (s[n] = i === void 0 ? r === void 0 ? void 0 : r : i);
}), s;
}
-function Ut(s) {
- const { defaultConfig: t, baseConfig: e = {}, specificStreamConfig: n = {} } = s, r = K({ ...t, ...e, ...n }), i = Object.keys(t), o = {};
- return i.forEach((a) => {
- a in r && (o[a] = r[a]);
+function Dt(s) {
+ const { defaultConfig: t, baseConfig: e = {}, specificStreamConfig: n = {} } = s, i = G({ ...t, ...e, ...n }), r = Object.keys(t), o = {};
+ return r.forEach((a) => {
+ a in i && (o[a] = i[a]);
}), o;
}
-var H = ((s) => (s[s.SegmentsAnnouncement = 0] = "SegmentsAnnouncement", s[s.SegmentRequest = 1] = "SegmentRequest", s[s.SegmentData = 2] = "SegmentData", s[s.SegmentDataSendingCompleted = 3] = "SegmentDataSendingCompleted", s[s.SegmentAbsent = 4] = "SegmentAbsent", s[s.CancelSegmentRequest = 5] = "CancelSegmentRequest", s))(H || {}), Z = ((s) => (s[s.Min = -1] = "Min", s[s.Int = 0] = "Int", s[s.SimilarIntArray = 1] = "SimilarIntArray", s[s.String = 2] = "String", s[s.Max = 3] = "Max", s))(Z || {});
-function ar(s) {
- const t = s < 0, e = function(i) {
- const o = i.toString(2), a = i < 0 ? o.length : o.length + 1;
+var N = ((s) => (s[s.SegmentsAnnouncement = 0] = "SegmentsAnnouncement", s[s.SegmentRequest = 1] = "SegmentRequest", s[s.SegmentData = 2] = "SegmentData", s[s.SegmentDataSendingCompleted = 3] = "SegmentDataSendingCompleted", s[s.SegmentAbsent = 4] = "SegmentAbsent", s[s.CancelSegmentRequest = 5] = "CancelSegmentRequest", s))(N || {}), J = ((s) => (s[s.Min = -1] = "Min", s[s.Int = 0] = "Int", s[s.SimilarIntArray = 1] = "SimilarIntArray", s[s.String = 2] = "String", s[s.Max = 3] = "Max", s))(J || {});
+function Hs(s) {
+ const t = s < 0, e = function(r) {
+ const o = r.toString(2), a = r < 0 ? o.length : o.length + 1;
return Math.ceil(a / 8);
- }(s), n = new Uint8Array(e), r = BigInt(e);
- s = function(i) {
- return i < 0 ? -i : i;
+ }(s), n = new Uint8Array(e), i = BigInt(e);
+ s = function(r) {
+ return r < 0 ? -r : r;
}(s);
- for (let i = 0; i < e; i++) {
- const o = s >> 8n * (r - 1n - BigInt(i)) & 0xffn;
- n[i] = Number(o);
+ for (let r = 0; r < e; r++) {
+ const o = s >> 8n * (i - 1n - BigInt(r)) & 0xffn;
+ n[r] = Number(o);
}
return t && (n[0] = 128 | n[0]), n;
}
-function hr(s) {
- const t = BigInt(s.length), e = (r, i) => {
- const o = 8n * (t - 1n - BigInt(i));
- return BigInt(r) << o;
+function $s(s) {
+ const t = BigInt(s.length), e = (i, r) => {
+ const o = 8n * (t - 1n - BigInt(r));
+ return BigInt(i) << o;
};
let n = e(127 & s[0], 0);
- for (let r = 1; r < t; r++) n = e(s[r], r) | n;
+ for (let i = 1; i < t; i++) n = e(s[i], i) | n;
return (128 & s[0]) >> 7 && (n = -n), n;
}
-function Ye(s) {
- const t = ar(s), e = 0 | t.length;
+function Ne(s) {
+ const t = Hs(s), e = 0 | t.length;
return new Uint8Array([e, ...t]);
}
-function Fn(s) {
+function An(s) {
const t = s[0];
if (t >> 4) throw new Error("Trying to deserialize integer with invalid serialized item code");
const e = 15 & t, n = 1 + e;
- return { number: hr(s.slice(1, n)), byteLength: e + 1 };
+ return { number: $s(s.slice(1, n)), byteLength: e + 1 };
}
-function cr(s) {
+function js(s) {
const [t, e] = s;
if (t >> 4 !== 1) throw new Error("Trying to deserialize similar int array with invalid serialized item code");
let n = 2;
- const r = [];
- for (let i = 0; i < e; i++) {
- const { number: o, byteLength: a } = Fn(s.slice(n));
+ const i = [];
+ for (let r = 0; r < e; r++) {
+ const { number: o, byteLength: a } = An(s.slice(n));
n += a;
- const h = 0xffn & o, g = -256n & o;
- for (let d = 0; d < h; d++) {
- const p = BigInt(s[n]);
- r.push(g | p), n++;
+ const h = 0xffn & o, u = -256n & o;
+ for (let c = 0; c < h; c++) {
+ const l = BigInt(s[n]);
+ i.push(u | l), n++;
}
}
- return { numbers: r, byteLength: n };
+ return { numbers: i, byteLength: n };
}
-function dr(s) {
+function Ws(s) {
const [t, e] = s;
if (t >> 4 !== 2) throw new Error("Trying to deserialize bytes (sting) with invalid serialized item code.");
- const n = (15 & t) << 8 | e, r = s.slice(2, n + 2);
- return { string: new TextDecoder("utf8").decode(r), byteLength: n + 2 };
+ const n = (15 & t) << 8 | e, i = s.slice(2, n + 2);
+ return { string: new TextDecoder("utf8").decode(i), byteLength: n + 2 };
}
-class rt {
+class X {
constructor() {
- f(this, "bytes", []);
- f(this, "_length", 0);
+ d(this, "bytes", []);
+ d(this, "_length", 0);
}
push(t) {
this.addBytes(t, "end");
@@ -2239,76 +1902,76 @@ class rt {
return this.bytes;
}
getBuffer() {
- return ce(this.bytes, this._length);
+ return ne(this.bytes, this._length);
}
get length() {
return this._length;
}
}
-const tt = Ot("cstr", 4), ht = Ot("cend", 4), de = Ot("dstr", 4), ue = Ot("dend", 4), ur = [tt, de], lr = [ht, ue], Ke = tt.length + ht.length;
-function Hn(s) {
- const t = tt.length, e = s.slice(-t);
- return ur.some((n) => Bt(s, n, 4)) && lr.some((n) => Bt(e, n, 4));
+const Y = Et("cstr", 4), st = Et("cend", 4), se = Et("dstr", 4), ie = Et("dend", 4), Qs = [Y, se], zs = [st, ie], Fe = Y.length + st.length;
+function In(s) {
+ const t = Y.length, e = s.slice(-t);
+ return Qs.some((n) => Lt(s, n, 4)) && zs.some((n) => Lt(e, n, 4));
}
-class Rt extends Error {
+class xt extends Error {
constructor(t) {
super(), this.type = t;
}
}
-class $n {
+class En {
constructor(t) {
- f(this, "chunks", new rt());
- f(this, "status", "joining");
+ d(this, "chunks", new X());
+ d(this, "status", "joining");
this.onComplete = t;
}
addCommandChunk(t) {
if (this.status === "completed") return;
- const e = Bt(t, tt, 4);
- if (!this.chunks.length && !e) throw new Rt("no-first-chunk");
- if (this.chunks.length && e) throw new Rt("incomplete-joining");
+ const e = Lt(t, Y, 4);
+ if (!this.chunks.length && !e) throw new xt("no-first-chunk");
+ if (this.chunks.length && e) throw new xt("incomplete-joining");
this.chunks.push(this.unframeCommandChunk(t)), function(n) {
- return Bt(n.slice(-4), ht, 4);
+ return Lt(n.slice(-4), st, 4);
}(t) && (this.status = "completed", this.onComplete(this.chunks.getBuffer()));
}
unframeCommandChunk(t) {
return t.slice(4, t.length - 4);
}
}
-class yt {
+class lt {
constructor(t, e) {
- f(this, "bytes", new rt());
- f(this, "resultBuffers", []);
- f(this, "status", "creating");
+ d(this, "bytes", new X());
+ d(this, "resultBuffers", []);
+ d(this, "status", "creating");
this.maxChunkLength = e, this.bytes.push(t);
}
addInteger(t, e) {
this.bytes.push(t.charCodeAt(0));
- const n = Ye(BigInt(e));
+ const n = Ne(BigInt(e));
this.bytes.push(n);
}
addSimilarIntArr(t, e) {
this.bytes.push(t.charCodeAt(0));
- const n = function(r) {
- const i = /* @__PURE__ */ new Map();
- for (const a of r) {
- const h = -256n & a, g = 0xffn & a, d = i.get(h) ?? new rt();
- d.length || i.set(h, d), d.push(Number(g));
+ const n = function(i) {
+ const r = /* @__PURE__ */ new Map();
+ for (const a of i) {
+ const h = -256n & a, u = 0xffn & a, c = r.get(h) ?? new X();
+ c.length || r.set(h, c), c.push(Number(u));
}
- const o = new rt();
- o.push([16, i.size]);
- for (const [a, h] of i) {
- const { length: g } = h.getBytesChunks(), d = a | 0xffn & BigInt(g);
- h.unshift(Ye(d)), o.push(h.getBuffer());
+ const o = new X();
+ o.push([16, r.size]);
+ for (const [a, h] of r) {
+ const { length: u } = h.getBytesChunks(), c = a | 0xffn & BigInt(u);
+ h.unshift(Ne(c)), o.push(h.getBuffer());
}
return o.getBuffer();
- }(e.map((r) => BigInt(r)));
+ }(e.map((i) => BigInt(i)));
this.bytes.push(n);
}
addString(t, e) {
this.bytes.push(t.charCodeAt(0));
- const n = function(r) {
- const { length: i } = r, o = new rt();
- return o.push([32 | i >> 8 & 15, 255 & i]), o.push(new TextEncoder().encode(r)), o.getBuffer();
+ const n = function(i) {
+ const { length: r } = i, o = new X();
+ return o.push([32 | r >> 8 & 15, 255 & r]), o.push(new TextEncoder().encode(i)), o.getBuffer();
}(e);
this.bytes.push(n);
}
@@ -2317,104 +1980,104 @@ class yt {
if (this.status === "completed") return;
this.status = "completed";
const t = this.bytes.getBuffer();
- if (t.length + Ke <= this.maxChunkLength) return void this.resultBuffers.push(_t(t, tt, ht));
+ if (t.length + Fe <= this.maxChunkLength) return void this.resultBuffers.push(ut(t, Y, st));
let e = Math.ceil(t.length / this.maxChunkLength);
- Math.ceil(t.length / e) + Ke > this.maxChunkLength && e++;
- for (const [n, r] of function* (i, o) {
- const a = Math.ceil(i.length / o);
- for (let h = 0; h < o; h++) yield [h, i.slice(h * a, (h + 1) * a)];
- }(t, e)) n === 0 ? this.resultBuffers.push(_t(r, tt, ue)) : n === e - 1 ? this.resultBuffers.push(_t(r, de, ht)) : this.resultBuffers.push(_t(r, de, ue));
+ Math.ceil(t.length / e) + Fe > this.maxChunkLength && e++;
+ for (const [n, i] of function* (r, o) {
+ const a = Math.ceil(r.length / o);
+ for (let h = 0; h < o; h++) yield [h, r.slice(h * a, (h + 1) * a)];
+ }(t, e)) n === 0 ? this.resultBuffers.push(ut(i, Y, ie)) : n === e - 1 ? this.resultBuffers.push(ut(i, se, st)) : this.resultBuffers.push(ut(i, se, ie));
}
getResultBuffers() {
if (this.status === "creating" || !this.resultBuffers.length) throw new Error("Command is not complete.");
return this.resultBuffers;
}
}
-function jn(s) {
+function Rn(s) {
const [t] = s, e = { c: t };
let n = 1;
for (; n < s.length; ) {
- const r = String.fromCharCode(s[n]);
- switch (n++, gr(s[n])) {
- case Z.Int:
+ const i = String.fromCharCode(s[n]);
+ switch (n++, Gs(s[n])) {
+ case J.Int:
{
- const { number: i, byteLength: o } = Fn(s.slice(n));
- e[r] = Number(i), n += o;
+ const { number: r, byteLength: o } = An(s.slice(n));
+ e[i] = Number(r), n += o;
}
break;
- case Z.SimilarIntArray:
+ case J.SimilarIntArray:
{
- const { numbers: i, byteLength: o } = cr(s.slice(n));
- e[r] = i.map((a) => Number(a)), n += o;
+ const { numbers: r, byteLength: o } = js(s.slice(n));
+ e[i] = r.map((a) => Number(a)), n += o;
}
break;
- case Z.String: {
- const { string: i, byteLength: o } = dr(s.slice(n));
- e[r] = i, n += o;
+ case J.String: {
+ const { string: r, byteLength: o } = Ws(s.slice(n));
+ e[i] = r, n += o;
}
}
}
return e;
}
-function gr(s) {
+function Gs(s) {
const t = s >> 4;
- if (t <= Z.Min || t >= Z.Max) throw new Error("Not existing type");
+ if (t <= J.Min || t >= J.Max) throw new Error("Not existing type");
return t;
}
-function Ot(s, t) {
+function Et(s, t) {
if (s.length !== t) throw new Error("Wrong string length");
const e = new Uint8Array(t);
for (let n = 0; n < s.length; n++) e[n] = s.charCodeAt(n);
return e;
}
-function _t(s, t, e) {
+function ut(s, t, e) {
const n = new Uint8Array(s.length + t.length + e.length);
return n.set(t), n.set(s, t.length), n.set(e, t.length + s.length), n;
}
-function Bt(s, t, e) {
+function Lt(s, t, e) {
for (let n = 0; n < e; n++) if (s[n] !== t[n]) return !1;
return !0;
}
-function Qn(s, t) {
+function Pn(s, t) {
switch (s.c) {
- case H.CancelSegmentRequest:
- case H.SegmentAbsent:
- case H.SegmentDataSendingCompleted:
+ case N.CancelSegmentRequest:
+ case N.SegmentAbsent:
+ case N.SegmentDataSendingCompleted:
return function(e, n) {
- const r = new yt(e.c, n);
- return r.addInteger("i", e.i), r.addInteger("r", e.r), r.complete(), r.getResultBuffers();
+ const i = new lt(e.c, n);
+ return i.addInteger("i", e.i), i.addInteger("r", e.r), i.complete(), i.getResultBuffers();
}(s, t);
- case H.SegmentRequest:
+ case N.SegmentRequest:
return function(e, n) {
- const r = new yt(e.c, n);
- return r.addInteger("i", e.i), r.addInteger("r", e.r), e.b && r.addInteger("b", e.b), r.complete(), r.getResultBuffers();
+ const i = new lt(e.c, n);
+ return i.addInteger("i", e.i), i.addInteger("r", e.r), e.b && i.addInteger("b", e.b), i.complete(), i.getResultBuffers();
}(s, t);
- case H.SegmentsAnnouncement:
+ case N.SegmentsAnnouncement:
return function(e, n) {
- const { c: r, p: i, l: o } = e, a = new yt(r, n);
- return o != null && o.length && a.addSimilarIntArr("l", o), i != null && i.length && a.addSimilarIntArr("p", i), a.complete(), a.getResultBuffers();
+ const { c: i, p: r, l: o } = e, a = new lt(i, n);
+ return o != null && o.length && a.addSimilarIntArr("l", o), r != null && r.length && a.addSimilarIntArr("p", r), a.complete(), a.getResultBuffers();
}(s, t);
- case H.SegmentData:
+ case N.SegmentData:
return function(e, n) {
- const r = new yt(e.c, n);
- return r.addInteger("i", e.i), r.addInteger("s", e.s), r.addInteger("r", e.r), r.complete(), r.getResultBuffers();
+ const i = new lt(e.c, n);
+ return i.addInteger("i", e.i), i.addInteger("s", e.s), i.addInteger("r", e.r), i.complete(), i.getResultBuffers();
}(s, t);
}
}
-const fr = Object.freeze(Object.defineProperty({ __proto__: null, BinaryCommandChunksJoiner: $n, BinaryCommandJoiningError: Rt, PeerCommandType: H, deserializeCommand: jn, isCommandChunk: Hn, serializePeerCommand: Qn }, Symbol.toStringTag, { value: "Module" }));
-class pr {
- constructor(t, e, n, r) {
- f(this, "commandChunks");
- f(this, "uploadingContext");
- f(this, "onChunkDownloaded");
- f(this, "onChunkUploaded");
- f(this, "onDataReceived", (t) => {
- Hn(t) ? this.receivingCommandBytes(t) : (this.eventHandlers.onSegmentChunkReceived(t), this.onChunkDownloaded(t.byteLength, "p2p", this.connection.idUtf8));
+const Js = Object.freeze(Object.defineProperty({ __proto__: null, BinaryCommandChunksJoiner: En, BinaryCommandJoiningError: xt, PeerCommandType: N, deserializeCommand: Rn, isCommandChunk: In, serializePeerCommand: Pn }, Symbol.toStringTag, { value: "Module" }));
+class Vs {
+ constructor(t, e, n, i) {
+ d(this, "commandChunks");
+ d(this, "uploadingContext");
+ d(this, "onChunkDownloaded");
+ d(this, "onChunkUploaded");
+ d(this, "onDataReceived", (t) => {
+ In(t) ? this.receivingCommandBytes(t) : (this.eventHandlers.onSegmentChunkReceived(t), this.onChunkDownloaded(t.byteLength, "p2p", this.connection.idUtf8));
});
- this.connection = t, this.peerConfig = e, this.eventHandlers = n, this.onChunkDownloaded = r.getEventDispatcher("onChunkDownloaded"), this.onChunkUploaded = r.getEventDispatcher("onChunkUploaded"), t.on("data", this.onDataReceived);
+ this.connection = t, this.peerConfig = e, this.eventHandlers = n, this.onChunkDownloaded = i.getEventDispatcher("onChunkDownloaded"), this.onChunkUploaded = i.getEventDispatcher("onChunkUploaded"), t.on("data", this.onDataReceived);
}
sendCommand(t) {
- const e = Qn(t, this.peerConfig.webRtcMaxMessageSize);
+ const e = Pn(t, this.peerConfig.webRtcMaxMessageSize);
for (const n of e) this.connection.write(n);
}
stopUploadingSegmentData() {
@@ -2427,76 +2090,76 @@ class pr {
}
async splitSegmentDataToChunksAndUploadAsync(t, e) {
if (this.uploadingContext) throw new Error("Some segment data is already uploading.");
- const n = function* (d, p) {
- let y = d.byteLength;
- for (; y > 0; ) {
- const w = y >= p ? p : y, c = d.byteLength - y, u = d.slice(c, c + w);
- y -= w, yield u;
+ const n = function* (c, l) {
+ let g = c.byteLength;
+ for (; g > 0; ) {
+ const m = g >= l ? l : g, f = c.byteLength - g, v = c.slice(f, f + m);
+ g -= m, yield v;
}
- }(t, this.peerConfig.webRtcMaxMessageSize), { promise: r, resolve: i, reject: o } = function() {
- let d, p;
- return { promise: new Promise((y, w) => {
- d = y, p = w;
- }), resolve: d, reject: p };
+ }(t, this.peerConfig.webRtcMaxMessageSize), { promise: i, resolve: r, reject: o } = function() {
+ let c, l;
+ return { promise: new Promise((g, m) => {
+ c = g, l = m;
+ }), resolve: c, reject: l };
}();
let a = !1;
const h = { stopUploading: () => {
a = !1;
}, requestId: e };
this.uploadingContext = h;
- const g = () => {
+ const u = () => {
if (a) for (; ; ) {
- const d = n.next().value;
- if (!d) {
- i();
+ const c = n.next().value;
+ if (!c) {
+ r();
break;
}
- const p = this.connection.write(d);
- if (this.onChunkUploaded(d.byteLength, this.connection.idUtf8), !p) break;
+ const l = this.connection.write(c);
+ if (this.onChunkUploaded(c.byteLength, this.connection.idUtf8), !l) break;
}
else o();
};
try {
- this.connection.on("drain", g), a = !0, g(), await r;
+ this.connection.on("drain", u), a = !0, u(), await i;
} finally {
- this.connection.off("drain", g), this.uploadingContext === h && (this.uploadingContext = void 0);
+ this.connection.off("drain", u), this.uploadingContext === h && (this.uploadingContext = void 0);
}
}
receivingCommandBytes(t) {
- this.commandChunks || (this.commandChunks = new $n((e) => {
+ this.commandChunks || (this.commandChunks = new En((e) => {
this.commandChunks = void 0;
- const n = jn(e);
+ const n = Rn(e);
this.eventHandlers.onCommandReceived(n);
}));
try {
this.commandChunks.addCommandChunk(t);
} catch (e) {
- if (!(e instanceof Rt)) return;
+ if (!(e instanceof xt)) return;
this.commandChunks = void 0;
}
}
}
-const { PeerCommandType: T } = fr;
-class Pt {
- constructor(t, e, n, r, i) {
- f(this, "id");
- f(this, "peerProtocol");
- f(this, "downloadingContext");
- f(this, "loadedSegments", /* @__PURE__ */ new Set());
- f(this, "httpLoadingSegments", /* @__PURE__ */ new Set());
- f(this, "downloadingErrors", []);
- f(this, "logger", P("p2pml-core:peer"));
- f(this, "onPeerClosed");
- f(this, "onCommandReceived", async (t) => {
- var e, n, r, i;
+const { PeerCommandType: k } = Js;
+class At {
+ constructor(t, e, n, i, r) {
+ d(this, "id");
+ d(this, "peerProtocol");
+ d(this, "downloadingContext");
+ d(this, "loadedSegments", /* @__PURE__ */ new Set());
+ d(this, "httpLoadingSegments", /* @__PURE__ */ new Set());
+ d(this, "downloadingErrors", []);
+ d(this, "logger", A("p2pml-core:peer"));
+ d(this, "onPeerClosed");
+ d(this, "onCommandReceived", async (t) => {
+ var e, n, i, r;
switch (t.c) {
- case T.SegmentsAnnouncement:
+ case k.SegmentsAnnouncement:
this.loadedSegments = new Set(t.l), this.httpLoadingSegments = new Set(t.p), this.eventHandlers.onSegmentsAnnouncement();
break;
- case T.SegmentRequest:
+ case k.SegmentRequest:
this.peerProtocol.stopUploadingSegmentData(), this.eventHandlers.onSegmentRequested(this, t.i, t.r, t.b);
break;
- case T.SegmentData:
+ case k.SegmentData:
{
if (!this.downloadingContext || this.downloadingContext.isSegmentDataCommandReceived) break;
const { request: o, controls: a, requestId: h } = this.downloadingContext;
@@ -2504,45 +2167,45 @@ class Pt {
this.downloadingContext.isSegmentDataCommandReceived = !0, a.firstBytesReceived(), o.totalBytes === void 0 ? o.setTotalBytes(t.s) : o.totalBytes - o.loadedBytes !== t.s && (o.clearLoadedBytes(), this.sendCancelSegmentRequestCommand(o.segment, h), this.cancelSegmentDownloading("peer-response-bytes-length-mismatch"), this.destroy());
}
break;
- case T.SegmentDataSendingCompleted: {
+ case k.SegmentDataSendingCompleted: {
const o = this.downloadingContext;
if (!(o != null && o.isSegmentDataCommandReceived)) return;
const { request: a, controls: h } = o;
if (o.request.segment.externalId !== t.i || o.requestId !== t.r) return a.clearLoadedBytes(), this.cancelSegmentDownloading("peer-protocol-violation"), void this.destroy();
if (a.loadedBytes !== a.totalBytes) return a.clearLoadedBytes(), this.cancelSegmentDownloading("peer-response-bytes-length-mismatch"), void this.destroy();
- const g = await ((n = (e = this.peerConfig).validateP2PSegment) == null ? void 0 : n.call(e, a.segment.url, a.segment.byteRange)) ?? !0;
+ const u = await ((n = (e = this.peerConfig).validateP2PSegment) == null ? void 0 : n.call(e, a.segment.url, a.segment.byteRange)) ?? !0;
if (this.downloadingContext !== o) return;
- if (!g) return a.clearLoadedBytes(), this.cancelSegmentDownloading("p2p-segment-validation-failed"), void this.destroy();
+ if (!u) return a.clearLoadedBytes(), this.cancelSegmentDownloading("p2p-segment-validation-failed"), void this.destroy();
this.downloadingErrors = [], h.completeOnSuccess(), this.downloadingContext = void 0;
break;
}
- case T.SegmentAbsent:
- ((r = this.downloadingContext) == null ? void 0 : r.request.segment.externalId) === t.i && ((i = this.downloadingContext) == null ? void 0 : i.requestId) === t.r && (this.cancelSegmentDownloading("peer-segment-absent"), this.loadedSegments.delete(t.i));
+ case k.SegmentAbsent:
+ ((i = this.downloadingContext) == null ? void 0 : i.request.segment.externalId) === t.i && ((r = this.downloadingContext) == null ? void 0 : r.requestId) === t.r && (this.cancelSegmentDownloading("peer-segment-absent"), this.loadedSegments.delete(t.i));
break;
- case T.CancelSegmentRequest:
+ case k.CancelSegmentRequest:
if (this.peerProtocol.getUploadingRequestId() !== t.r) break;
this.peerProtocol.stopUploadingSegmentData();
}
});
- f(this, "onSegmentChunkReceived", (t) => {
- var r;
- if (!((r = this.downloadingContext) != null && r.isSegmentDataCommandReceived)) return;
+ d(this, "onSegmentChunkReceived", (t) => {
+ var i;
+ if (!((i = this.downloadingContext) != null && i.isSegmentDataCommandReceived)) return;
const { request: e, controls: n } = this.downloadingContext;
if (e.totalBytes !== void 0 && e.loadedBytes + t.byteLength > e.totalBytes) return e.clearLoadedBytes(), this.cancelSegmentDownloading("peer-response-bytes-length-mismatch"), void this.destroy();
n.addLoadedChunk(t);
});
- f(this, "onPeerConnectionClosed", () => {
+ d(this, "onPeerConnectionClosed", () => {
this.destroy();
});
- f(this, "onConnectionError", (t) => {
+ d(this, "onConnectionError", (t) => {
this.logger(`peer connection error ${this.id} %O`, t), this.eventTarget.getEventDispatcher("onPeerError")({ peerId: this.id, streamType: this.streamType, error: t });
const e = t.code;
(e === "ERR_DATA_CHANNEL" || e === "ERR_CONNECTION_FAILURE") && this.destroy();
});
- f(this, "destroy", () => {
+ d(this, "destroy", () => {
this.cancelSegmentDownloading("peer-closed"), this.connection.destroy(), this.eventHandlers.onPeerClosed(this), this.onPeerClosed({ peerId: this.id, streamType: this.streamType }), this.logger(`peer closed ${this.id}`);
});
- this.connection = t, this.eventHandlers = e, this.peerConfig = n, this.streamType = r, this.eventTarget = i, this.onPeerClosed = i.getEventDispatcher("onPeerClose"), this.id = Pt.getPeerIdFromConnection(t), this.peerProtocol = new pr(t, n, { onSegmentChunkReceived: this.onSegmentChunkReceived, onCommandReceived: this.onCommandReceived }, i), i.getEventDispatcher("onPeerConnect")({ peerId: this.id, streamType: r }), t.on("error", this.onConnectionError), t.on("close", this.onPeerConnectionClosed), t.on("end", this.onPeerConnectionClosed), t.on("finish", this.onPeerConnectionClosed);
+ this.connection = t, this.eventHandlers = e, this.peerConfig = n, this.streamType = i, this.eventTarget = r, this.onPeerClosed = r.getEventDispatcher("onPeerClose"), this.id = At.getPeerIdFromConnection(t), this.peerProtocol = new Vs(t, n, { onSegmentChunkReceived: this.onSegmentChunkReceived, onCommandReceived: this.onCommandReceived }, r), r.getEventDispatcher("onPeerConnect")({ peerId: this.id, streamType: i }), t.on("error", this.onConnectionError), t.on("close", this.onPeerConnectionClosed), t.on("end", this.onPeerConnectionClosed), t.on("finish", this.onPeerConnectionClosed);
}
get downloadingSegment() {
var t;
@@ -2556,92 +2219,92 @@ class Pt {
if (this.downloadingContext) throw new Error("Some segment already is downloading");
this.downloadingContext = { request: t, requestId: Math.floor(1e3 * Math.random()), isSegmentDataCommandReceived: !1, controls: t.start({ downloadSource: "p2p", peerId: this.id }, { notReceivingBytesTimeoutMs: this.peerConfig.p2pNotReceivingBytesTimeoutMs, abort: (n) => {
if (!this.downloadingContext) return;
- const { request: r, requestId: i } = this.downloadingContext;
- this.sendCancelSegmentRequestCommand(r.segment, i), this.downloadingErrors.push(n), this.downloadingContext = void 0, this.downloadingErrors.filter((o) => o.type === "bytes-receiving-timeout").length >= this.peerConfig.p2pErrorRetries && this.destroy();
+ const { request: i, requestId: r } = this.downloadingContext;
+ this.sendCancelSegmentRequestCommand(i.segment, r), this.downloadingErrors.push(n), this.downloadingContext = void 0, this.downloadingErrors.filter((o) => o.type === "bytes-receiving-timeout").length >= this.peerConfig.p2pErrorRetries && this.destroy();
} }) };
- const e = { c: T.SegmentRequest, r: this.downloadingContext.requestId, i: t.segment.externalId };
+ const e = { c: k.SegmentRequest, r: this.downloadingContext.requestId, i: t.segment.externalId };
t.loadedBytes && (e.b = t.loadedBytes), this.peerProtocol.sendCommand(e);
}
async uploadSegmentData(t, e, n) {
- const { externalId: r } = t;
+ const { externalId: i } = t;
this.logger(`send segment ${t.externalId} to ${this.id}`);
- const i = { c: T.SegmentData, i: r, r: e, s: n.byteLength };
- this.peerProtocol.sendCommand(i);
+ const r = { c: k.SegmentData, i, r: e, s: n.byteLength };
+ this.peerProtocol.sendCommand(r);
try {
- await this.peerProtocol.splitSegmentDataToChunksAndUploadAsync(n, e), this.sendSegmentDataSendingCompletedCommand(t, e), this.logger(`segment ${r} has been sent to ${this.id}`);
+ await this.peerProtocol.splitSegmentDataToChunksAndUploadAsync(n, e), this.sendSegmentDataSendingCompletedCommand(t, e), this.logger(`segment ${i} has been sent to ${this.id}`);
} catch {
- this.logger(`cancel segment uploading ${r}`);
+ this.logger(`cancel segment uploading ${i}`);
}
}
cancelSegmentDownloading(t) {
if (!this.downloadingContext) return;
- const { request: e, controls: n } = this.downloadingContext, { segment: r } = e;
- this.logger(`cancel segment request ${r.externalId} (${t})`);
- const i = new R(t);
- n.abortOnError(i), this.downloadingContext = void 0, this.downloadingErrors.push(i);
+ const { request: e, controls: n } = this.downloadingContext, { segment: i } = e;
+ this.logger(`cancel segment request ${i.externalId} (${t})`);
+ const r = new x(t);
+ n.abortOnError(r), this.downloadingContext = void 0, this.downloadingErrors.push(r);
}
sendSegmentsAnnouncementCommand(t, e) {
- const n = { c: T.SegmentsAnnouncement, p: e, l: t };
+ const n = { c: k.SegmentsAnnouncement, p: e, l: t };
this.peerProtocol.sendCommand(n);
}
sendSegmentAbsentCommand(t, e) {
- this.peerProtocol.sendCommand({ c: T.SegmentAbsent, i: t, r: e });
+ this.peerProtocol.sendCommand({ c: k.SegmentAbsent, i: t, r: e });
}
sendCancelSegmentRequestCommand(t, e) {
- this.peerProtocol.sendCommand({ c: T.CancelSegmentRequest, i: t.externalId, r: e });
+ this.peerProtocol.sendCommand({ c: k.CancelSegmentRequest, i: t.externalId, r: e });
}
sendSegmentDataSendingCompletedCommand(t, e) {
- this.peerProtocol.sendCommand({ c: T.SegmentDataSendingCompleted, r: e, i: t.externalId });
+ this.peerProtocol.sendCommand({ c: k.SegmentDataSendingCompleted, r: e, i: t.externalId });
}
static getPeerIdFromConnection(t) {
return function(e) {
const n = new Uint8Array(e.length / 2);
- for (let r = 0; r < e.length; r += 2) n[r / 2] = parseInt(e.slice(r, r + 2), 16);
+ for (let i = 0; i < e.length; i += 2) n[i / 2] = parseInt(e.slice(i, i + 2), 16);
return new TextDecoder().decode(n);
}(t.id);
}
}
-function mr() {
+function Ys() {
const s = /^((?!chrome|android).)*safari/i.test(navigator.userAgent), t = /\b(iPad|iPhone|Macintosh).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent);
return s || t;
}
-class yr {
- constructor(t, e, n, r, i) {
- f(this, "streamShortId");
- f(this, "client");
- f(this, "_peers", /* @__PURE__ */ new Map());
- f(this, "logger", P("p2pml-core:p2p-tracker-client"));
- f(this, "onReceivePeerConnection", (t) => {
- const e = Pt.getPeerIdFromConnection(t);
+class Ks {
+ constructor(t, e, n, i, r) {
+ d(this, "streamShortId");
+ d(this, "client");
+ d(this, "_peers", /* @__PURE__ */ new Map());
+ d(this, "logger", A("p2pml-core:p2p-tracker-client"));
+ d(this, "onReceivePeerConnection", (t) => {
+ const e = At.getPeerIdFromConnection(t);
let n = this._peers.get(e);
n != null && n.peer ? t.destroy() : (n || (n = { potentialConnections: /* @__PURE__ */ new Set() }, t.idUtf8 = e, n.potentialConnections.add(t), this._peers.set(e, n)), t.on("connect", () => {
if (n && !n.peer) {
- for (const r of n.potentialConnections) r !== t && r.destroy();
- n.potentialConnections.clear(), n.peer = new Pt(t, { onPeerClosed: this.onPeerClosed, onSegmentRequested: this.eventHandlers.onSegmentRequested, onSegmentsAnnouncement: this.eventHandlers.onSegmentsAnnouncement }, this.config, this.stream.type, this.eventTarget), this.logger(`connected with peer: ${n.peer.id} ${this.streamShortId}`), this.eventHandlers.onPeerConnected(n.peer);
+ for (const i of n.potentialConnections) i !== t && i.destroy();
+ n.potentialConnections.clear(), n.peer = new At(t, { onPeerClosed: this.onPeerClosed, onSegmentRequested: this.eventHandlers.onSegmentRequested, onSegmentsAnnouncement: this.eventHandlers.onSegmentsAnnouncement }, this.config, this.stream.type, this.eventTarget), this.logger(`connected with peer: ${n.peer.id} ${this.streamShortId}`), this.eventHandlers.onPeerConnected(n.peer);
}
}));
});
- f(this, "onTrackerClientWarning", (t) => {
+ d(this, "onTrackerClientWarning", (t) => {
this.logger(`tracker warning (${this.streamShortId}: ${t})`), this.eventTarget.getEventDispatcher("onTrackerWarning")({ streamType: this.stream.type, warning: t });
});
- f(this, "onTrackerClientError", (t) => {
+ d(this, "onTrackerClientError", (t) => {
this.logger(`tracker error (${this.streamShortId}: ${t})`), this.eventTarget.getEventDispatcher("onTrackerError")({ streamType: this.stream.type, error: t });
});
- f(this, "onPeerClosed", (t) => {
+ d(this, "onPeerClosed", (t) => {
this.logger(`peer closed: ${t.id}`), this._peers.delete(t.id);
});
- this.stream = e, this.eventHandlers = n, this.config = r, this.eventTarget = i;
+ this.stream = e, this.eventHandlers = n, this.config = i, this.eventTarget = r;
const o = function(h) {
- const g = rr.fromUtf8(h).slice(1);
- return btoa(g);
+ const u = Ns.fromUtf8(h).slice(1);
+ return btoa(u);
}(t);
- this.streamShortId = z(e);
+ this.streamShortId = $(e);
const a = function(h) {
- const g = [h], d = 20 - h.length;
- for (let p = 0; p < d; p++) g.push(or[Math.floor(62 * Math.random())]);
- return g.join("");
- }(r.trackerClientVersionPrefix);
- this.client = new ae({ infoHash: Ge(o), peerId: Ge(a), announce: mr() ? r.announceTrackers.slice(0, 1) : r.announceTrackers, rtcConfig: this.config.rtcConfig }), this.client.on("peer", this.onReceivePeerConnection), this.client.on("warning", this.onTrackerClientWarning), this.client.on("error", this.onTrackerClientError), this.logger(`create new client;
+ const u = [h], c = 20 - h.length;
+ for (let l = 0; l < c; l++) u.push(Us[Math.floor(62 * Math.random())]);
+ return u.join("");
+ }(i.trackerClientVersionPrefix);
+ this.client = new te({ infoHash: De(o), peerId: De(a), announce: Ys() ? i.announceTrackers.slice(0, 1) : i.announceTrackers, rtcConfig: this.config.rtcConfig }), this.client.on("peer", this.onReceivePeerConnection), this.client.on("warning", this.onTrackerClientWarning), this.client.on("error", this.onTrackerClientError), this.logger(`create new client;
stream: ${this.streamShortId}; hash: ${o}
peerId: ${a}`);
}
@@ -2660,60 +2323,65 @@ peerId: ${a}`);
for (const t of this._peers.values()) t != null && t.peer && (yield t.peer);
}
}
-function Ze(s, t) {
+function B(s, t) {
+ return `v2-${s}-${function(e) {
+ return `${e.type}-${e.index}`;
+ }(t)}`;
+}
+function Ue(s, t) {
for (const e of s.values()) {
const n = e.segments.get(t);
if (n) return n;
}
}
-function $(s) {
- return `${s.type}-${s.index}`;
+function Mt(s, t, e, n, i) {
+ const { highDemandTimeWindow: r, httpDownloadTimeWindow: o, p2pDownloadTimeWindow: a } = function(h, u) {
+ const { highDemandTimeWindow: c, httpDownloadTimeWindow: l, p2pDownloadTimeWindow: g } = h, m = { highDemandTimeWindow: c, httpDownloadTimeWindow: l, p2pDownloadTimeWindow: g };
+ return u <= 5 ? (m.httpDownloadTimeWindow = 0, m.p2pDownloadTimeWindow = 0) : u <= 10 && (m.p2pDownloadTimeWindow = m.httpDownloadTimeWindow), m;
+ }(e, i);
+ return { isHighDemand: Nt(s, t, r), isHttpDownloadable: Nt(s, t, o), isP2PDownloadable: Nt(s, t, a) && n.isSegmentLoadingOrLoadedBySomeone(s) };
}
-function vt(s, t, e, n) {
- const { highDemandTimeWindow: r, httpDownloadTimeWindow: i, p2pDownloadTimeWindow: o } = e;
- return { isHighDemand: Ft(s, t, r), isHttpDownloadable: Ft(s, t, i), isP2PDownloadable: Ft(s, t, o) && (!n || n.isSegmentLoadingOrLoadedBySomeone(s)) };
+function Nt(s, t, e) {
+ const { startTime: n, endTime: i } = s, { position: r, rate: o } = t;
+ return !(r + e * o < n || r > i);
}
-function Ft(s, t, e) {
- const { startTime: n, endTime: r } = s, { position: i, rate: o } = t;
- return !(i + e * o < n || i > r);
-}
-class _r {
- constructor(t, e, n, r, i, o, a) {
- f(this, "trackerClient");
- f(this, "isAnnounceMicrotaskCreated", !1);
- f(this, "onPeerConnected", (t) => {
+class Zs {
+ constructor(t, e, n, i, r, o, a) {
+ d(this, "trackerClient");
+ d(this, "isAnnounceMicrotaskCreated", !1);
+ d(this, "onPeerConnected", (t) => {
const { httpLoading: e, loaded: n } = this.getSegmentsAnnouncement();
t.sendSegmentsAnnouncementCommand(n, e);
});
- f(this, "broadcastAnnouncement", () => {
+ d(this, "broadcastAnnouncement", () => {
this.isAnnounceMicrotaskCreated || (this.isAnnounceMicrotaskCreated = !0, queueMicrotask(() => {
const { httpLoading: t, loaded: e } = this.getSegmentsAnnouncement();
for (const n of this.trackerClient.peers()) n.sendSegmentsAnnouncementCommand(e, t);
this.isAnnounceMicrotaskCreated = !1;
}));
});
- f(this, "onSegmentRequested", async (t, e, n, r) => {
- const i = function(a, h) {
- for (const g of a.segments.values()) if (g.externalId === h) return g;
+ d(this, "onSegmentRequested", async (t, e, n, i) => {
+ const r = function(u, c) {
+ for (const l of u.segments.values()) if (l.externalId === c) return l;
}(this.stream, e);
- if (!i) return;
- const o = await this.segmentStorage.getSegmentData(i);
- o ? await t.uploadSegmentData(i, n, r !== void 0 ? o.slice(r) : o) : t.sendSegmentAbsentCommand(e, n);
+ if (!r) return;
+ const o = this.config.swarmId ?? this.streamManifestUrl, a = B(o, this.stream), h = await this.segmentStorage.getSegmentData(o, a, r.externalId);
+ h ? await t.uploadSegmentData(r, n, i !== void 0 ? h.slice(i) : h) : t.sendSegmentAbsentCommand(e, n);
});
- this.streamManifestUrl = t, this.stream = e, this.requests = n, this.segmentStorage = r, this.config = i, this.eventTarget = o, this.onSegmentAnnouncement = a;
- const h = function(g, d) {
- return `v2-${g}-${$(d)}`;
- }(this.config.swarmId ?? this.streamManifestUrl, this.stream);
- this.trackerClient = new yr(h, this.stream, { onPeerConnected: this.onPeerConnected, onSegmentRequested: this.onSegmentRequested, onSegmentsAnnouncement: this.onSegmentAnnouncement }, this.config, this.eventTarget), this.segmentStorage.subscribeOnUpdate(this.stream, this.broadcastAnnouncement), this.trackerClient.start();
+ this.streamManifestUrl = t, this.stream = e, this.requests = n, this.segmentStorage = i, this.config = r, this.eventTarget = o, this.onSegmentAnnouncement = a;
+ const h = B(this.config.swarmId ?? this.streamManifestUrl, this.stream);
+ this.trackerClient = new Ks(h, this.stream, { onPeerConnected: this.onPeerConnected, onSegmentRequested: this.onSegmentRequested, onSegmentsAnnouncement: this.onSegmentAnnouncement }, this.config, this.eventTarget), this.eventTarget.addEventListener(`onStorageUpdated-${h}`, this.broadcastAnnouncement), this.segmentStorage.setSegmentChangeCallback((u) => {
+ this.eventTarget.dispatchEvent(`onStorageUpdated-${u}`);
+ }), this.trackerClient.start();
}
downloadSegment(t) {
const e = [];
for (const o of this.trackerClient.peers()) o.downloadingSegment || o.getSegmentStatus(t) !== "loaded" || e.push(o);
- const n = (r = e)[Math.floor(Math.random() * r.length)];
- var r;
+ const n = (i = e)[Math.floor(Math.random() * i.length)];
+ var i;
if (!n) return;
- const i = this.requests.getOrCreateRequest(t);
- n.downloadSegment(i);
+ const r = this.requests.getOrCreateRequest(t);
+ n.downloadSegment(r);
}
isSegmentLoadingOrLoadedBySomeone(t) {
for (const e of this.trackerClient.peers()) if (e.getSegmentStatus(t)) return !0;
@@ -2729,39 +2397,44 @@ class _r {
return t;
}
getSegmentsAnnouncement() {
- const t = this.segmentStorage.getStoredSegmentExternalIdsOfStream(this.stream), e = [];
- for (const n of this.requests.httpRequests()) {
- const r = this.stream.segments.get(n.segment.runtimeId);
- r && e.push(r.externalId);
+ const t = this.config.swarmId ?? this.streamManifestUrl, e = B(t, this.stream), n = this.segmentStorage.getStoredSegmentIds(t, e), i = [];
+ for (const r of this.requests.httpRequests()) {
+ const o = this.stream.segments.get(r.segment.runtimeId);
+ o && i.push(o.externalId);
}
- return { loaded: t, httpLoading: e };
+ return { loaded: n, httpLoading: i };
}
destroy() {
- this.segmentStorage.unsubscribeFromUpdate(this.stream, this.broadcastAnnouncement), this.trackerClient.destroy();
+ const t = B(this.config.swarmId ?? this.streamManifestUrl, this.stream);
+ this.eventTarget.removeEventListener(`onStorageUpdated-${t}`, this.broadcastAnnouncement), this.trackerClient.destroy();
}
}
-class br {
- constructor(t, e, n, r, i, o, a) {
- f(this, "loaders", /* @__PURE__ */ new Map());
- f(this, "_currentLoaderItem");
- f(this, "logger", P("p2pml-core:p2p-loaders-container"));
- this.streamManifestUrl = t, this.requests = n, this.segmentStorage = r, this.config = i, this.eventTarget = o, this.onSegmentAnnouncement = a, this.changeCurrentLoader(e);
+class Xs {
+ constructor(t, e, n, i, r, o, a) {
+ d(this, "loaders", /* @__PURE__ */ new Map());
+ d(this, "_currentLoaderItem");
+ d(this, "logger", A("p2pml-core:p2p-loaders-container"));
+ this.streamManifestUrl = t, this.requests = n, this.segmentStorage = i, this.config = r, this.eventTarget = o, this.onSegmentAnnouncement = a, this.changeCurrentLoader(e);
}
createLoader(t) {
if (this.loaders.has(t.runtimeId)) throw new Error("Loader for this stream already exists");
- const e = new _r(this.streamManifestUrl, t, this.requests, this.segmentStorage, this.config, this.eventTarget, () => {
+ const e = new Zs(this.streamManifestUrl, t, this.requests, this.segmentStorage, this.config, this.eventTarget, () => {
this._currentLoaderItem.loader === e && this.onSegmentAnnouncement();
- }), n = z(t);
- return this.logger(`created new loader: ${n}`), { loader: e, stream: t, loggerInfo: z(t) };
+ }), n = $(t);
+ return this.logger(`created new loader: ${n}`), { loader: e, stream: t, loggerInfo: $(t) };
}
changeCurrentLoader(t) {
const e = this.loaders.get(t.runtimeId);
- if (this._currentLoaderItem && (this.segmentStorage.getStoredSegmentExternalIdsOfStream(this._currentLoaderItem.stream).length ? this.setLoaderDestroyTimeout(this._currentLoaderItem) : this.destroyAndRemoveLoader(this._currentLoaderItem)), e) this._currentLoaderItem = e, clearTimeout(e.destroyTimeoutId), e.destroyTimeoutId = void 0;
+ if (this._currentLoaderItem) {
+ const n = this.config.swarmId ?? this.streamManifestUrl, i = B(n, this._currentLoaderItem.stream);
+ this.segmentStorage.getStoredSegmentIds(n, i).length ? this.setLoaderDestroyTimeout(this._currentLoaderItem) : this.destroyAndRemoveLoader(this._currentLoaderItem);
+ }
+ if (e) this._currentLoaderItem = e, clearTimeout(e.destroyTimeoutId), e.destroyTimeoutId = void 0;
else {
const n = this.createLoader(t);
this.loaders.set(t.runtimeId, n), this._currentLoaderItem = n;
}
- this.logger(`change current p2p loader: ${z(t)}`);
+ this.logger(`change current p2p loader: ${$(t)}`);
}
setLoaderDestroyTimeout(t) {
t.destroyTimeoutId = window.setTimeout(() => this.destroyAndRemoveLoader(t), this.config.p2pInactiveLoaderDestroyTimeoutMs);
@@ -2777,55 +2450,55 @@ class br {
this.loaders.clear();
}
}
-let wr = class {
- constructor(s, t, e, n, r, i) {
- f(this, "currentAttempt");
- f(this, "_failedAttempts", new Sr());
- f(this, "finalData");
- f(this, "bytes", []);
- f(this, "_loadedBytes", 0);
- f(this, "_totalBytes");
- f(this, "_status", "not-started");
- f(this, "progress");
- f(this, "notReceivingBytesTimeout");
- f(this, "_abortRequestCallback");
- f(this, "_logger");
- f(this, "_isHandledByProcessQueue", !1);
- f(this, "onSegmentError");
- f(this, "onSegmentAbort");
- f(this, "onSegmentStart");
- f(this, "onSegmentLoaded");
- f(this, "abortOnTimeout", () => {
+let ti = class {
+ constructor(s, t, e, n, i, r) {
+ d(this, "currentAttempt");
+ d(this, "_failedAttempts", new ei());
+ d(this, "finalData");
+ d(this, "bytes", []);
+ d(this, "_loadedBytes", 0);
+ d(this, "_totalBytes");
+ d(this, "_status", "not-started");
+ d(this, "progress");
+ d(this, "notReceivingBytesTimeout");
+ d(this, "_abortRequestCallback");
+ d(this, "_logger");
+ d(this, "_isHandledByProcessQueue", !1);
+ d(this, "onSegmentError");
+ d(this, "onSegmentAbort");
+ d(this, "onSegmentStart");
+ d(this, "onSegmentLoaded");
+ d(this, "abortOnTimeout", () => {
var t;
if (this.throwErrorIfNotLoadingStatus(), !this.currentAttempt) return;
this.setStatus("failed");
- const s = new R("bytes-receiving-timeout");
+ const s = new x("bytes-receiving-timeout");
(t = this._abortRequestCallback) == null || t.call(this, s), this.logger(`${this.downloadSource} ${this.segment.externalId} failed ${s.type}`), this._failedAttempts.add({ ...this.currentAttempt, error: s }), this.onSegmentError({ segment: this.segment, error: s, downloadSource: this.currentAttempt.downloadSource, peerId: this.currentAttempt.downloadSource === "p2p" ? this.currentAttempt.peerId : void 0, streamType: this.segment.stream.type }), this.notReceivingBytesTimeout.clear(), this.manageBandwidthCalculatorsState("stop"), this.requestProcessQueueCallback();
});
- f(this, "abortOnError", (s) => {
+ d(this, "abortOnError", (s) => {
this.throwErrorIfNotLoadingStatus(), this.currentAttempt && (this.setStatus("failed"), this.logger(`${this.downloadSource} ${this.segment.externalId} failed ${s.type}`), this._failedAttempts.add({ ...this.currentAttempt, error: s }), this.onSegmentError({ segment: this.segment, error: s, downloadSource: this.currentAttempt.downloadSource, peerId: this.currentAttempt.downloadSource === "p2p" ? this.currentAttempt.peerId : void 0, streamType: this.segment.stream.type }), this.notReceivingBytesTimeout.clear(), this.manageBandwidthCalculatorsState("stop"), this.requestProcessQueueCallback());
});
- f(this, "completeOnSuccess", () => {
- this.throwErrorIfNotLoadingStatus(), this.currentAttempt && (this.manageBandwidthCalculatorsState("stop"), this.notReceivingBytesTimeout.clear(), this.finalData = ce(this.bytes), this.setStatus("succeed"), this._totalBytes = this._loadedBytes, this.onSegmentLoaded({ segmentUrl: this.segment.url, bytesLength: this.finalData.byteLength, downloadSource: this.currentAttempt.downloadSource, peerId: this.currentAttempt.downloadSource === "p2p" ? this.currentAttempt.peerId : void 0, streamType: this.segment.stream.type }), this.logger(`${this.currentAttempt.downloadSource} ${this.segment.externalId} succeed`), this.requestProcessQueueCallback());
+ d(this, "completeOnSuccess", () => {
+ this.throwErrorIfNotLoadingStatus(), this.currentAttempt && (this.manageBandwidthCalculatorsState("stop"), this.notReceivingBytesTimeout.clear(), this.finalData = ne(this.bytes), this.setStatus("succeed"), this._totalBytes = this._loadedBytes, this.onSegmentLoaded({ segmentUrl: this.segment.url, bytesLength: this.finalData.byteLength, downloadSource: this.currentAttempt.downloadSource, peerId: this.currentAttempt.downloadSource === "p2p" ? this.currentAttempt.peerId : void 0, streamType: this.segment.stream.type }), this.logger(`${this.currentAttempt.downloadSource} ${this.segment.externalId} succeed`), this.requestProcessQueueCallback());
});
- f(this, "addLoadedChunk", (s) => {
+ d(this, "addLoadedChunk", (s) => {
if (this.throwErrorIfNotLoadingStatus(), !this.currentAttempt || !this.progress) return;
this.notReceivingBytesTimeout.restart();
const t = s.byteLength, { all: e, http: n } = this.bandwidthCalculators;
e.addBytes(t), this.currentAttempt.downloadSource === "http" && n.addBytes(t), this.bytes.push(s), this.progress.lastLoadedChunkTimestamp = performance.now(), this.progress.loadedBytes += t, this._loadedBytes += t;
});
- f(this, "firstBytesReceived", () => {
+ d(this, "firstBytesReceived", () => {
this.throwErrorIfNotLoadingStatus(), this.notReceivingBytesTimeout.restart();
});
- this.segment = s, this.requestProcessQueueCallback = t, this.bandwidthCalculators = e, this.playback = n, this.playbackConfig = r, this.onSegmentError = i.getEventDispatcher("onSegmentError"), this.onSegmentAbort = i.getEventDispatcher("onSegmentAbort"), this.onSegmentStart = i.getEventDispatcher("onSegmentStart"), this.onSegmentLoaded = i.getEventDispatcher("onSegmentLoaded");
+ this.segment = s, this.requestProcessQueueCallback = t, this.bandwidthCalculators = e, this.playback = n, this.playbackConfig = i, this.onSegmentError = r.getEventDispatcher("onSegmentError"), this.onSegmentAbort = r.getEventDispatcher("onSegmentAbort"), this.onSegmentStart = r.getEventDispatcher("onSegmentStart"), this.onSegmentLoaded = r.getEventDispatcher("onSegmentLoaded");
const { byteRange: o } = this.segment;
if (o) {
- const { end: h, start: g } = o;
- this._totalBytes = h - g + 1;
+ const { end: h, start: u } = o;
+ this._totalBytes = h - u + 1;
}
- this.notReceivingBytesTimeout = new Cr(this.abortOnTimeout);
+ this.notReceivingBytesTimeout = new ni(this.abortOnTimeout);
const { type: a } = this.segment.stream;
- this._logger = P(`p2pml-core:request-${a}`);
+ this._logger = A(`p2pml-core:request-${a}`);
}
clearLoadedBytes() {
this._loadedBytes = 0, this.bytes = [], this._totalBytes = void 0;
@@ -2847,7 +2520,7 @@ let wr = class {
return this._totalBytes;
}
get data() {
- if (this.status === "succeed") return this.finalData || (this.finalData = ce(this.bytes)), this.finalData;
+ if (this.status === "succeed") return this.finalData || (this.finalData = ne(this.bytes)), this.finalData;
}
get failedAttempts() {
return this._failedAttempts;
@@ -2871,7 +2544,7 @@ let wr = class {
}
abortFromProcessQueue() {
var s, t, e, n;
- this.throwErrorIfNotLoadingStatus(), this.setStatus("aborted"), this.logger(`${(s = this.currentAttempt) == null ? void 0 : s.downloadSource} ${this.segment.externalId} aborted`), (t = this._abortRequestCallback) == null || t.call(this, new R("abort")), this.onSegmentAbort({ segment: this.segment, downloadSource: (e = this.currentAttempt) == null ? void 0 : e.downloadSource, peerId: ((n = this.currentAttempt) == null ? void 0 : n.downloadSource) === "p2p" ? this.currentAttempt.peerId : void 0, streamType: this.segment.stream.type }), this._abortRequestCallback = void 0, this.manageBandwidthCalculatorsState("stop"), this.notReceivingBytesTimeout.clear();
+ this.throwErrorIfNotLoadingStatus(), this.setStatus("aborted"), this.logger(`${(s = this.currentAttempt) == null ? void 0 : s.downloadSource} ${this.segment.externalId} aborted`), (t = this._abortRequestCallback) == null || t.call(this, new x("abort")), this.onSegmentAbort({ segment: this.segment, downloadSource: (e = this.currentAttempt) == null ? void 0 : e.downloadSource, peerId: ((n = this.currentAttempt) == null ? void 0 : n.downloadSource) === "p2p" ? this.currentAttempt.peerId : void 0, streamType: this.segment.stream.type }), this._abortRequestCallback = void 0, this.manageBandwidthCalculatorsState("stop"), this.notReceivingBytesTimeout.clear();
}
throwErrorIfNotLoadingStatus() {
if (this._status !== "loading") throw new Error(`Request has been already ${this.status}.`);
@@ -2881,14 +2554,14 @@ let wr = class {
this._logger.color = ((t = this.currentAttempt) == null ? void 0 : t.downloadSource) === "http" ? "green" : "red", this._logger(s), this._logger.color = "";
}
manageBandwidthCalculatorsState(s) {
- var r;
+ var i;
const { all: t, http: e } = this.bandwidthCalculators, n = s === "start" ? "startLoading" : "stopLoading";
- ((r = this.currentAttempt) == null ? void 0 : r.downloadSource) === "http" && e[n](), t[n]();
+ ((i = this.currentAttempt) == null ? void 0 : i.downloadSource) === "http" && e[n](), t[n]();
}
};
-class Sr {
+class ei {
constructor() {
- f(this, "attempts", []);
+ d(this, "attempts", []);
}
add(t) {
this.attempts.push(t);
@@ -2903,10 +2576,10 @@ class Sr {
this.attempts = [];
}
}
-class Cr {
+class ni {
constructor(t) {
- f(this, "timeoutId");
- f(this, "ms");
+ d(this, "timeoutId");
+ d(this, "ms");
this.action = t;
}
start(t) {
@@ -2920,10 +2593,10 @@ class Cr {
clearTimeout(this.timeoutId), this.timeoutId = void 0;
}
}
-class vr {
- constructor(t, e, n, r, i) {
- f(this, "requests", /* @__PURE__ */ new Map());
- this.requestProcessQueueCallback = t, this.bandwidthCalculators = e, this.playback = n, this.config = r, this.eventTarget = i;
+class si {
+ constructor(t, e, n, i, r) {
+ d(this, "requests", /* @__PURE__ */ new Map());
+ this.requestProcessQueueCallback = t, this.bandwidthCalculators = e, this.playback = n, this.config = i, this.eventTarget = r;
}
get executingHttpCount() {
let t = 0;
@@ -2940,7 +2613,7 @@ class vr {
}
getOrCreateRequest(t) {
let e = this.requests.get(t);
- return e || (e = new wr(t, this.requestProcessQueueCallback, this.bandwidthCalculators, this.playback, this.config, this.eventTarget), this.requests.set(t, e)), e;
+ return e || (e = new ti(t, this.requestProcessQueueCallback, this.bandwidthCalculators, this.playback, this.config, this.eventTarget), this.requests.set(t, e)), e;
}
remove(t) {
this.requests.delete(t.segment);
@@ -2959,10 +2632,10 @@ class vr {
this.requests.clear();
}
}
-class Lr {
+class ii {
constructor(t, e) {
- f(this, "_status", "pending");
- f(this, "_shouldBeStartedImmediately", !1);
+ d(this, "_status", "pending");
+ d(this, "_shouldBeStartedImmediately", !1);
this.segment = t, this.engineCallbacks = e;
}
get status() {
@@ -2975,57 +2648,57 @@ class Lr {
this._status === "pending" && (this._status = "succeed", this.engineCallbacks.onSuccess({ data: t, bandwidth: e }));
}
reject() {
- this._status === "pending" && (this._status = "failed", this.engineCallbacks.onError(new fe("failed")));
+ this._status === "pending" && (this._status = "failed", this.engineCallbacks.onError(new ae("failed")));
}
abort() {
- this._status === "pending" && (this._status = "aborted", this.engineCallbacks.onError(new fe("aborted")));
+ this._status === "pending" && (this._status = "aborted", this.engineCallbacks.onError(new ae("aborted")));
}
markAsShouldBeStartedImmediately() {
this._shouldBeStartedImmediately = !0;
}
}
-function* Xe(s, t, e, n) {
- const { runtimeId: r, stream: i } = s, o = i.segments.get(r);
- if (!o) return;
- const a = i.segments.values();
- let h;
+function* He(s, t, e, n, i) {
+ const { runtimeId: r, stream: o } = s, a = o.segments.get(r);
+ if (!a) return;
+ const h = o.segments.values();
+ let u;
do {
- const d = a.next();
- if (d.done) return;
- h = d.value;
- } while (h !== o);
- const g = vt(h, t, e, n);
- if (Ht(g)) {
- const d = a.next();
- if (d.done) return;
- const p = d.value, y = vt(p, t, e, n);
- if (Ht(y)) return;
- g.isHighDemand = !0, yield { segment: h, statuses: g }, yield { segment: p, statuses: y };
- } else yield { segment: h, statuses: g };
- for (const d of a) {
- const p = vt(d, t, e, n);
- if (Ht(p)) break;
- yield { segment: d, statuses: p };
+ const l = h.next();
+ if (l.done) return;
+ u = l.value;
+ } while (u !== a);
+ const c = Mt(u, t, e, n, i);
+ if (Ft(c)) {
+ const l = h.next();
+ if (l.done) return;
+ const g = l.value, m = Mt(g, t, e, n, i);
+ if (Ft(m)) return;
+ c.isHighDemand = !0, yield { segment: u, statuses: c }, yield { segment: g, statuses: m };
+ } else yield { segment: u, statuses: c };
+ for (const l of h) {
+ const g = Mt(l, t, e, n, i);
+ if (Ft(g)) break;
+ yield { segment: l, statuses: g };
}
}
-function Ht(s) {
+function Ft(s) {
const { isHighDemand: t = !1, isHttpDownloadable: e = !1, isP2PDownloadable: n = !1 } = s;
return !t && !e && !n;
}
-class kr {
- constructor(t, e, n, r, i, o, a) {
- f(this, "requests");
- f(this, "engineRequest");
- f(this, "p2pLoaders");
- f(this, "playback");
- f(this, "segmentAvgDuration");
- f(this, "logger");
- f(this, "storageCleanUpIntervalId");
- f(this, "levelChangedTimestamp");
- f(this, "lastQueueProcessingTimeStamp");
- f(this, "randomHttpDownloadInterval");
- f(this, "isProcessQueueMicrotaskCreated", !1);
- f(this, "requestProcessQueueMicrotask", (t = !0) => {
+class ri {
+ constructor(t, e, n, i, r, o, a) {
+ d(this, "requests");
+ d(this, "engineRequest");
+ d(this, "p2pLoaders");
+ d(this, "playback");
+ d(this, "segmentAvgDuration");
+ d(this, "logger");
+ d(this, "storageCleanUpIntervalId");
+ d(this, "levelChangedTimestamp");
+ d(this, "lastQueueProcessingTimeStamp");
+ d(this, "randomHttpDownloadInterval");
+ d(this, "isProcessQueueMicrotaskCreated", !1);
+ d(this, "requestProcessQueueMicrotask", (t = !0) => {
const e = performance.now();
!t && this.lastQueueProcessingTimeStamp !== void 0 && e - this.lastQueueProcessingTimeStamp <= 1e3 || this.isProcessQueueMicrotaskCreated || (this.isProcessQueueMicrotaskCreated = !0, queueMicrotask(() => {
try {
@@ -3035,19 +2708,16 @@ class kr {
}
}));
});
- this.streamManifestUrl = t, this.lastRequestedSegment = e, this.streamDetails = n, this.config = r, this.bandwidthCalculators = i, this.segmentStorage = o, this.eventTarget = a;
+ this.streamManifestUrl = t, this.lastRequestedSegment = e, this.streamDetails = n, this.config = i, this.bandwidthCalculators = r, this.segmentStorage = o, this.eventTarget = a;
const h = this.lastRequestedSegment.stream;
- if (this.playback = { position: this.lastRequestedSegment.startTime, rate: 1 }, this.segmentAvgDuration = function(g) {
- const { segments: d } = g;
- let p = 0;
- const y = d.size;
- for (const w of d.values()) p += w.endTime - w.startTime;
- return p / y;
- }(h), this.requests = new vr(this.requestProcessQueueMicrotask, this.bandwidthCalculators, this.playback, this.config, this.eventTarget), !this.segmentStorage.isInitialized) throw new Error("Segment storage is not initialized.");
- this.segmentStorage.addIsSegmentLockedPredicate((g) => g.stream === h && function(d, p, y) {
- const { isHighDemand: w = !1, isHttpDownloadable: c = !1, isP2PDownloadable: u = !1 } = vt(d, p, y);
- return w || c || u;
- }(g, this.playback, this.config)), this.p2pLoaders = new br(this.streamManifestUrl, this.lastRequestedSegment.stream, this.requests, this.segmentStorage, this.config, this.eventTarget, this.requestProcessQueueMicrotask), this.logger = P(`p2pml-core:hybrid-loader-${h.type}`), this.logger.color = "coral", this.setIntervalLoading();
+ if (this.playback = { position: this.lastRequestedSegment.startTime, rate: 1 }, this.segmentAvgDuration = function(u) {
+ const { segments: c } = u;
+ let l = 0;
+ const g = c.size;
+ for (const m of c.values()) l += m.endTime - m.startTime;
+ return l / g;
+ }(h), this.requests = new si(this.requestProcessQueueMicrotask, this.bandwidthCalculators, this.playback, this.config, this.eventTarget), !this.segmentStorage) throw new Error("Segment storage is not initialized.");
+ this.p2pLoaders = new Xs(this.streamManifestUrl, this.lastRequestedSegment.stream, this.requests, this.segmentStorage, this.config, this.eventTarget, this.requestProcessQueueMicrotask), this.logger = A(`p2pml-core:hybrid-loader-${h.type}`), this.logger.color = "coral", this.setIntervalLoading();
}
setIntervalLoading() {
const t = this.p2pLoaders.currentLoader.connectedPeerCount, e = 1e3 * Math.random() * t + 1e3;
@@ -3056,180 +2726,198 @@ class kr {
}, e);
}
async loadSegment(t, e) {
- this.logger(`requests: ${Ve(t)}`);
+ this.logger(`requests: ${Oe(t)}`);
const { stream: n } = t;
- n !== this.lastRequestedSegment.stream && (this.logger(`stream changed to ${z(n)}`), this.p2pLoaders.changeCurrentLoader(n)), this.lastRequestedSegment = t;
- const r = new Lr(t, e);
- if (this.segmentStorage.hasSegment(t)) {
- const i = await this.segmentStorage.getSegmentData(t);
- if (i) {
- const { queueDownloadRatio: o } = this.generateQueue();
- r.resolve(i, this.getBandwidth(o));
+ n !== this.lastRequestedSegment.stream && (this.logger(`stream changed to ${$(n)}`), this.p2pLoaders.changeCurrentLoader(n)), this.lastRequestedSegment = t;
+ const i = this.config.swarmId ?? this.streamManifestUrl, r = B(i, n);
+ this.segmentStorage.onSegmentRequested(i, r, t.externalId, t.startTime, t.endTime, n.type, this.streamDetails.isLive);
+ const o = new ii(t, e);
+ try {
+ if (this.segmentStorage.hasSegment(i, r, t.externalId)) {
+ const a = await this.segmentStorage.getSegmentData(i, r, t.externalId);
+ if (a) {
+ const { queueDownloadRatio: h } = this.generateQueue();
+ return void o.resolve(a, this.getBandwidth(h));
+ }
}
- } else this.engineRequest = r;
- this.requestProcessQueueMicrotask();
+ this.engineRequest = o;
+ } catch {
+ o.reject();
+ } finally {
+ this.requestProcessQueueMicrotask();
+ }
}
processRequests(t, e) {
var o;
- const { stream: n } = this.lastRequestedSegment, { httpErrorRetries: r } = this.config, i = performance.now();
+ const { stream: n } = this.lastRequestedSegment, { httpErrorRetries: i } = this.config, r = performance.now();
for (const a of this.requests.items()) {
- const { downloadSource: h, status: g, segment: d, isHandledByProcessQueue: p } = a, y = ((o = this.engineRequest) == null ? void 0 : o.segment) === d ? this.engineRequest : void 0;
- switch (g) {
+ const { downloadSource: h, status: u, segment: c, isHandledByProcessQueue: l } = a, g = ((o = this.engineRequest) == null ? void 0 : o.segment) === c ? this.engineRequest : void 0;
+ switch (u) {
case "loading":
- t.has(d.runtimeId) || y || (a.abortFromProcessQueue(), this.requests.remove(a));
+ t.has(c.runtimeId) || g || (a.abortFromProcessQueue(), this.requests.remove(a));
break;
case "succeed":
if (!a.data || !h) break;
- h === "http" && this.p2pLoaders.currentLoader.broadcastAnnouncement(), y && (y.resolve(a.data, this.getBandwidth(e)), this.engineRequest = void 0), this.requests.remove(a), this.segmentStorage.storeSegment(a.segment, a.data, this.streamDetails.isLive);
+ h === "http" && this.p2pLoaders.currentLoader.broadcastAnnouncement(), g && (g.resolve(a.data, this.getBandwidth(e)), this.engineRequest = void 0), this.requests.remove(a);
+ const f = this.config.swarmId ?? this.streamManifestUrl, v = B(f, n);
+ this.segmentStorage.storeSegment(f, v, c.externalId, a.data, c.startTime, c.endTime, c.stream.type, this.streamDetails.isLive);
break;
case "failed":
- h !== "http" || p || this.p2pLoaders.currentLoader.broadcastAnnouncement(), y || n.segments.has(a.segment.runtimeId) || this.requests.remove(a), a.failedAttempts.httpAttemptsCount >= r && y && (this.engineRequest = void 0, y.reject());
+ h !== "http" || l || this.p2pLoaders.currentLoader.broadcastAnnouncement(), g || n.segments.has(a.segment.runtimeId) || this.requests.remove(a), a.failedAttempts.httpAttemptsCount >= i && g && (this.engineRequest = void 0, g.reject());
break;
case "not-started":
case "aborted":
this.requests.remove(a);
}
a.markHandledByProcessQueue();
- const { lastAttempt: w } = a.failedAttempts;
- w && i - w.error.timestamp > 6e4 && a.failedAttempts.clear();
+ const { lastAttempt: m } = a.failedAttempts;
+ m && r - m.error.timestamp > 6e4 && a.failedAttempts.clear();
}
}
processQueue() {
var a;
const { queue: t, queueSegmentIds: e, queueDownloadRatio: n } = this.generateQueue();
this.processRequests(e, n);
- const { simultaneousHttpDownloads: r, simultaneousP2PDownloads: i, httpErrorRetries: o } = this.config;
- if ((a = this.engineRequest) != null && a.shouldBeStartedImmediately && this.engineRequest.status === "pending" && this.requests.executingHttpCount < r) {
- const { segment: h } = this.engineRequest, g = this.requests.get(h);
- (!g || g.status === "not-started" || g.status === "failed" && g.failedAttempts.httpAttemptsCount < this.config.httpErrorRetries) && this.loadThroughHttp(h);
+ const { simultaneousHttpDownloads: i, simultaneousP2PDownloads: r, httpErrorRetries: o } = this.config;
+ if ((a = this.engineRequest) != null && a.shouldBeStartedImmediately && this.engineRequest.status === "pending" && this.requests.executingHttpCount < i) {
+ const { segment: h } = this.engineRequest, u = this.requests.get(h);
+ (!u || u.status === "not-started" || u.status === "failed" && u.failedAttempts.httpAttemptsCount < this.config.httpErrorRetries) && this.loadThroughHttp(h);
}
for (const h of t) {
- const { statuses: g, segment: d } = h, p = this.requests.get(d);
- if (g.isHighDemand) {
- if ((p == null ? void 0 : p.downloadSource) === "http" && p.status === "loading" || (p == null ? void 0 : p.downloadSource) === "http" && p.status === "failed" && p.failedAttempts.httpAttemptsCount >= o) continue;
- const y = (p == null ? void 0 : p.status) === "loading" && p.downloadSource === "p2p";
- if (this.requests.executingHttpCount < r) {
- y && p.abortFromProcessQueue(), this.loadThroughHttp(d);
+ const { statuses: u, segment: c } = h, l = this.requests.get(c);
+ if (u.isHighDemand) {
+ if ((l == null ? void 0 : l.downloadSource) === "http" && l.status === "loading" || (l == null ? void 0 : l.downloadSource) === "http" && l.status === "failed" && l.failedAttempts.httpAttemptsCount >= o) continue;
+ const g = (l == null ? void 0 : l.status) === "loading" && l.downloadSource === "p2p";
+ if (this.requests.executingHttpCount < i) {
+ g && l.abortFromProcessQueue(), this.loadThroughHttp(c);
continue;
}
- if (this.abortLastHttpLoadingInQueueAfterItem(t, d) && this.requests.executingHttpCount < r) {
- y && p.abortFromProcessQueue(), this.loadThroughHttp(d);
+ if (this.abortLastHttpLoadingInQueueAfterItem(t, c) && this.requests.executingHttpCount < i) {
+ g && l.abortFromProcessQueue(), this.loadThroughHttp(c);
continue;
}
- if (y) continue;
- if (this.requests.executingP2PCount < i) {
- this.loadThroughP2P(d);
+ if (g) continue;
+ if (this.requests.executingP2PCount < r) {
+ this.loadThroughP2P(c);
continue;
}
- if (this.abortLastP2PLoadingInQueueAfterItem(t, d) && this.requests.executingP2PCount < i) {
- this.loadThroughP2P(d);
+ if (this.abortLastP2PLoadingInQueueAfterItem(t, c) && this.requests.executingP2PCount < r) {
+ this.loadThroughP2P(c);
continue;
}
- } else if (g.isP2PDownloadable) {
- if ((p == null ? void 0 : p.status) === "loading") continue;
- (this.requests.executingP2PCount < i || this.p2pLoaders.currentLoader.isSegmentLoadedBySomeone(d) && this.abortLastP2PLoadingInQueueAfterItem(t, d) && this.requests.executingP2PCount < i) && this.loadThroughP2P(d);
+ } else if (u.isP2PDownloadable) {
+ if ((l == null ? void 0 : l.status) === "loading") continue;
+ (this.requests.executingP2PCount < r || this.p2pLoaders.currentLoader.isSegmentLoadedBySomeone(c) && this.abortLastP2PLoadingInQueueAfterItem(t, c) && this.requests.executingP2PCount < r) && this.loadThroughP2P(c);
}
}
}
abortSegmentRequest(t) {
var e;
- ((e = this.engineRequest) == null ? void 0 : e.segment.runtimeId) === t && (this.engineRequest.abort(), this.logger("abort: ", Ve(this.engineRequest.segment)), this.engineRequest = void 0, this.requestProcessQueueMicrotask());
+ ((e = this.engineRequest) == null ? void 0 : e.segment.runtimeId) === t && (this.engineRequest.abort(), this.logger("abort: ", Oe(this.engineRequest.segment)), this.engineRequest = void 0, this.requestProcessQueueMicrotask());
}
loadThroughHttp(t) {
const e = this.requests.getOrCreateRequest(t);
- new Gn(e, this.config, this.eventTarget), this.p2pLoaders.currentLoader.broadcastAnnouncement();
+ new On(e, this.config, this.eventTarget), this.p2pLoaders.currentLoader.broadcastAnnouncement();
}
loadThroughP2P(t) {
this.p2pLoaders.currentLoader.downloadSegment(t);
}
loadRandomThroughHttp() {
- const { simultaneousHttpDownloads: t, httpErrorRetries: e } = this.config, n = this.p2pLoaders.currentLoader;
- if (this.requests.executingHttpCount >= t || !n.connectedPeerCount) return;
+ const t = this.getAvailableStorageCapacityPercent();
+ if (t <= 10) return;
+ const { simultaneousHttpDownloads: e, httpErrorRetries: n } = this.config, i = this.p2pLoaders.currentLoader;
+ if (this.requests.executingHttpCount >= e || !i.connectedPeerCount) return;
const r = [];
- for (const { segment: g, statuses: d } of Xe(this.lastRequestedSegment, this.playback, this.config, this.p2pLoaders.currentLoader)) {
- if (!d.isHttpDownloadable || d.isP2PDownloadable || this.segmentStorage.hasSegment(g)) continue;
- const p = this.requests.get(g);
- p && (p.status === "loading" || p.status === "succeed" || (p.failedAttempts.httpAttemptsCount ?? 0) >= e) || r.push(g);
+ for (const { segment: c, statuses: l } of He(this.lastRequestedSegment, this.playback, this.config, this.p2pLoaders.currentLoader, t)) {
+ const g = this.config.swarmId ?? this.streamManifestUrl, m = B(g, c.stream);
+ if (!l.isHttpDownloadable || l.isP2PDownloadable || this.segmentStorage.hasSegment(g, m, c.externalId)) continue;
+ const f = this.requests.get(c);
+ f && (f.status === "loading" || f.status === "succeed" || (f.failedAttempts.httpAttemptsCount ?? 0) >= n) || r.push(c);
}
- if (!r.length || t - this.requests.executingHttpCount === 0) return;
- const i = n.connectedPeerCount + 1, o = Math.min(r.length, t * i), a = function(g) {
- for (let d = g.length - 1; d > 0; d--) {
- const p = Math.floor(Math.random() * (d + 1));
- [g[d], g[p]] = [g[p], g[d]];
+ if (!r.length || e - this.requests.executingHttpCount === 0) return;
+ const o = i.connectedPeerCount + 1, a = Math.min(r.length, e * o), h = function(c) {
+ for (let l = c.length - 1; l > 0; l--) {
+ const g = Math.floor(Math.random() * (l + 1));
+ [c[l], c[g]] = [c[g], c[l]];
}
- return g;
- }(Array.from({ length: o }, (g, d) => d));
- let h = o / i;
- for (const g of a) {
- if (this.requests.executingHttpCount >= t) break;
- if (h >= 1 || Math.random() <= h) {
- const d = r[g];
- this.loadThroughHttp(d);
+ return c;
+ }(Array.from({ length: a }, (c, l) => l));
+ let u = a / o;
+ for (const c of h) {
+ if (this.requests.executingHttpCount >= e) break;
+ if (u >= 1 || Math.random() <= u) {
+ const l = r[c];
+ this.loadThroughHttp(l);
}
- if (h--, h <= 0) break;
+ if (u--, u <= 0) break;
}
}
abortLastHttpLoadingInQueueAfterItem(t, e) {
- for (const { segment: n } of Je(t)) {
+ for (const { segment: n } of Me(t)) {
if (n === e) break;
- const r = this.requests.get(n);
- if ((r == null ? void 0 : r.downloadSource) === "http" && r.status === "loading") return r.abortFromProcessQueue(), !0;
+ const i = this.requests.get(n);
+ if ((i == null ? void 0 : i.downloadSource) === "http" && i.status === "loading") return i.abortFromProcessQueue(), !0;
}
return !1;
}
abortLastP2PLoadingInQueueAfterItem(t, e) {
- for (const { segment: n } of Je(t)) {
+ for (const { segment: n } of Me(t)) {
if (n === e) break;
- const r = this.requests.get(n);
- if ((r == null ? void 0 : r.downloadSource) === "p2p" && r.status === "loading") return r.abortFromProcessQueue(), !0;
+ const i = this.requests.get(n);
+ if ((i == null ? void 0 : i.downloadSource) === "p2p" && i.status === "loading") return i.abortFromProcessQueue(), !0;
}
return !1;
}
+ getAvailableStorageCapacityPercent() {
+ const { totalCapacity: t, usedCapacity: e } = this.segmentStorage.getUsage();
+ return 100 - e / t * 100;
+ }
generateQueue() {
- var i;
+ var o;
const t = [], e = /* @__PURE__ */ new Set();
- let n = 0, r = 0;
- for (const o of Xe(this.lastRequestedSegment, this.playback, this.config, this.p2pLoaders.currentLoader)) {
+ let n = 0, i = 0;
+ const r = this.getAvailableStorageCapacityPercent();
+ for (const a of He(this.lastRequestedSegment, this.playback, this.config, this.p2pLoaders.currentLoader, r)) {
n++;
- const { segment: a } = o;
- this.segmentStorage.hasSegment(a) || ((i = this.requests.get(a)) == null ? void 0 : i.status) === "succeed" ? r++ : (t.push(o), e.add(a.runtimeId));
+ const { segment: h } = a, u = this.config.swarmId ?? this.streamManifestUrl, c = B(u, h.stream);
+ this.segmentStorage.hasSegment(u, c, h.externalId) || ((o = this.requests.get(h)) == null ? void 0 : o.status) === "succeed" ? i++ : (t.push(a), e.add(h.runtimeId));
}
- return { queue: t, queueSegmentIds: e, maxPossibleLength: n, alreadyLoadedCount: r, queueDownloadRatio: n !== 0 ? r / n : 0 };
+ return { queue: t, queueSegmentIds: e, maxPossibleLength: n, alreadyLoadedCount: i, queueDownloadRatio: n !== 0 ? i / n : 0 };
}
getBandwidth(t) {
- const { http: e, all: n } = this.bandwidthCalculators, { activeLevelBitrate: r } = this.streamDetails;
+ const { http: e, all: n } = this.bandwidthCalculators, { activeLevelBitrate: i } = this.streamDetails;
if (this.streamDetails.activeLevelBitrate === 0) return n.getBandwidthLoadingOnly(3);
- const i = Math.max(n.getBandwidth(30, this.levelChangedTimestamp), n.getBandwidth(60, this.levelChangedTimestamp), n.getBandwidth(90, this.levelChangedTimestamp));
- if (t >= 0.8 || i >= 0.9 * r) return Math.max(n.getBandwidthLoadingOnly(1), n.getBandwidthLoadingOnly(3), n.getBandwidthLoadingOnly(5));
+ const r = Math.max(n.getBandwidth(30, this.levelChangedTimestamp), n.getBandwidth(60, this.levelChangedTimestamp), n.getBandwidth(90, this.levelChangedTimestamp));
+ if (t >= 0.8 || r >= 0.9 * i) return Math.max(n.getBandwidthLoadingOnly(1), n.getBandwidthLoadingOnly(3), n.getBandwidthLoadingOnly(5));
const o = Math.max(e.getBandwidthLoadingOnly(1), e.getBandwidthLoadingOnly(3), e.getBandwidthLoadingOnly(5));
- return Math.max(i, o);
+ return Math.max(r, o);
}
notifyLevelChanged() {
this.levelChangedTimestamp = performance.now();
}
updatePlayback(t, e) {
var o;
- const n = this.playback.rate !== e, r = this.playback.position !== t;
- if (!n && !r) return;
- const i = Math.abs(t - this.playback.position) / this.segmentAvgDuration > 0.5;
- r && (this.playback.position = t), n && e !== 0 && (this.playback.rate = e), i && (this.logger("position significantly changed"), (o = this.engineRequest) == null || o.markAsShouldBeStartedImmediately()), this.requestProcessQueueMicrotask(i);
+ const n = this.playback.rate !== e, i = this.playback.position !== t;
+ if (!n && !i) return;
+ const r = Math.abs(t - this.playback.position) / this.segmentAvgDuration > 0.5;
+ i && (this.playback.position = t), n && e !== 0 && (this.playback.rate = e), r && (this.logger("position significantly changed"), (o = this.engineRequest) == null || o.markAsShouldBeStartedImmediately()), this.segmentStorage.onPlaybackUpdated(t, e), this.requestProcessQueueMicrotask(r);
}
updateStream(t) {
- t === this.lastRequestedSegment.stream && (this.logger(`update stream: ${z(t)}`), this.requestProcessQueueMicrotask());
+ t === this.lastRequestedSegment.stream && (this.logger(`update stream: ${$(t)}`), this.requestProcessQueueMicrotask());
}
destroy() {
var t;
clearInterval(this.storageCleanUpIntervalId), clearInterval(this.randomHttpDownloadInterval), this.storageCleanUpIntervalId = void 0, (t = this.engineRequest) == null || t.abort(), this.requests.destroy(), this.p2pLoaders.destroy();
}
}
-class tn {
+class $e {
constructor(t = 2e4) {
- f(this, "loadingsCount", 0);
- f(this, "bytes", []);
- f(this, "loadingOnlyTimestamps", []);
- f(this, "timestamps", []);
- f(this, "noLoadingsTime", 0);
- f(this, "loadingsStoppedAt", 0);
+ d(this, "loadingsCount", 0);
+ d(this, "bytes", []);
+ d(this, "loadingOnlyTimestamps", []);
+ d(this, "timestamps", []);
+ d(this, "noLoadingsTime", 0);
+ d(this, "loadingsStoppedAt", 0);
this.clearThresholdMs = t;
}
addBytes(t, e = performance.now()) {
@@ -3243,27 +2931,27 @@ class tn {
}
getBandwidthLoadingOnly(t, e = Number.NEGATIVE_INFINITY) {
if (!this.loadingOnlyTimestamps.length) return 0;
- const n = 1e3 * t, r = this.loadingOnlyTimestamps[this.loadingOnlyTimestamps.length - 1];
- let i = r;
- const o = r - n;
+ const n = 1e3 * t, i = this.loadingOnlyTimestamps[this.loadingOnlyTimestamps.length - 1];
+ let r = i;
+ const o = i - n;
let a = 0;
for (let h = this.bytes.length - 1; h >= 0; h--) {
- const g = this.loadingOnlyTimestamps[h];
- if (g < o || this.timestamps[h] < e) break;
- i = g, a += this.bytes[h];
+ const u = this.loadingOnlyTimestamps[h];
+ if (u < o || this.timestamps[h] < e) break;
+ r = u, a += this.bytes[h];
}
- return 8e3 * a / (r - i);
+ return 8e3 * a / (i - r);
}
getBandwidth(t, e = Number.NEGATIVE_INFINITY, n = performance.now()) {
if (!this.timestamps.length) return 0;
- const r = n - 1e3 * t;
- let i = n, o = 0;
+ const i = n - 1e3 * t;
+ let r = n, o = 0;
for (let a = this.bytes.length - 1; a >= 0; a--) {
const h = this.timestamps[a];
- if (h < r || h < e) break;
- i = h, o += this.bytes[a];
+ if (h < i || h < e) break;
+ r = h, o += this.bytes[a];
}
- return 8e3 * o / (n - i);
+ return 8e3 * o / (n - r);
}
clearStale() {
if (!this.loadingOnlyTimestamps.length) return;
@@ -3276,20 +2964,114 @@ class tn {
this.bytes.splice(0, e), this.loadingOnlyTimestamps.splice(0, e), this.timestamps.splice(0, e);
}
}
-class Wn {
+const gt = (s, t) => `${s}|${t}`, mt = 1048576;
+class oi {
constructor() {
- f(this, "events", /* @__PURE__ */ new Map());
+ d(this, "userAgent", navigator.userAgent);
+ d(this, "segmentMemoryStorageLimit", 4096);
+ d(this, "currentStorageUsage", 0);
+ d(this, "cache", /* @__PURE__ */ new Map());
+ d(this, "logger");
+ d(this, "coreConfig");
+ d(this, "mainStreamConfig");
+ d(this, "secondaryStreamConfig");
+ d(this, "currentPlayback");
+ d(this, "lastRequestedSegment");
+ d(this, "segmentChangeCallback");
+ this.logger = A("p2pml-core:segment-memory-storage"), this.logger.color = "RebeccaPurple";
+ }
+ async initialize(t, e, n) {
+ this.coreConfig = t, this.mainStreamConfig = e, this.secondaryStreamConfig = n, this.setMemoryStorageLimit(), this.logger("initialized");
+ }
+ onPlaybackUpdated(t, e) {
+ this.currentPlayback = { position: t, rate: e };
+ }
+ onSegmentRequested(t, e, n, i, r, o, a) {
+ this.lastRequestedSegment = { streamId: e, segmentId: n, startTime: i, endTime: r, swarmId: t, streamType: o, isLiveStream: a };
+ }
+ async storeSegment(t, e, n, i, r, o, a, h) {
+ this.clear(h, i.byteLength);
+ const u = gt(e, n);
+ if (this.cache.set(u, { data: i, segmentId: n, streamId: e, startTime: r, endTime: o, streamType: a }), this.increaseStorageUsage(i.byteLength), this.logger(`add segment: ${n} to ${e}`), !this.segmentChangeCallback) throw new Error("dispatchStorageUpdatedEvent is not set");
+ this.segmentChangeCallback(e);
+ }
+ async getSegmentData(t, e, n) {
+ const i = gt(e, n), r = this.cache.get(i);
+ if (r !== void 0) return r.data;
+ }
+ getUsage() {
+ if (!this.lastRequestedSegment || !this.currentPlayback) return { totalCapacity: this.segmentMemoryStorageLimit, usedCapacity: this.currentStorageUsage };
+ const t = this.currentPlayback.position;
+ let e = 0;
+ for (const { endTime: n, data: i } of this.cache.values()) t > n || (e += i.byteLength);
+ return { totalCapacity: this.segmentMemoryStorageLimit, usedCapacity: e / mt };
+ }
+ hasSegment(t, e, n) {
+ const i = gt(e, n);
+ return this.cache.get(i) !== void 0;
+ }
+ getStoredSegmentIds(t, e) {
+ const n = [];
+ for (const { segmentId: i, streamId: r } of this.cache.values()) r === e && n.push(i);
+ return n;
+ }
+ clear(t, e) {
+ if (!(this.currentPlayback && this.mainStreamConfig && this.secondaryStreamConfig && this.coreConfig) || !this.isMemoryLimitReached(e) && !t) return;
+ const n = /* @__PURE__ */ new Set(), i = Array.from(this.cache.values()).sort((r, o) => r.startTime - o.startTime);
+ for (const r of i) {
+ const { streamId: o, segmentId: a, data: h } = r, u = gt(o, a);
+ if (this.shouldRemoveSegment(r, t, this.currentPlayback.position) && (this.cache.delete(u), n.add(o), this.decreaseStorageUsage(h.byteLength), this.logger(`Removed segment ${a} from stream ${o}`), !this.isMemoryLimitReached(e) && !t)) break;
+ }
+ this.sendUpdatesToAffectedStreams(n);
+ }
+ isMemoryLimitReached(t) {
+ return this.currentStorageUsage + t / mt > this.segmentMemoryStorageLimit;
+ }
+ setSegmentChangeCallback(t) {
+ this.segmentChangeCallback = t;
+ }
+ sendUpdatesToAffectedStreams(t) {
+ t.size !== 0 && t.forEach((e) => {
+ if (!this.segmentChangeCallback) throw new Error("dispatchStorageUpdatedEvent is not set");
+ this.segmentChangeCallback(e);
+ });
+ }
+ shouldRemoveSegment(t, e, n) {
+ const { endTime: i, streamType: r } = t, o = this.getStreamTimeWindow(r, "highDemandTimeWindow");
+ return !(n <= i) && (!e || n > o + i);
+ }
+ increaseStorageUsage(t) {
+ this.currentStorageUsage += t / mt;
+ }
+ decreaseStorageUsage(t) {
+ this.currentStorageUsage -= t / mt;
+ }
+ setMemoryStorageLimit() {
+ var t;
+ this.coreConfig && this.coreConfig.segmentMemoryStorageLimit ? this.segmentMemoryStorageLimit = this.coreConfig.segmentMemoryStorageLimit : (t = this.userAgent, /Android/i.test(t) && !/Chrome|Firefox/i.test(t) || ((e) => /iPad|iPhone/i.test(e))(this.userAgent) ? this.segmentMemoryStorageLimit = 1024 : ((e) => /Android/i.test(e))(this.userAgent) && (this.segmentMemoryStorageLimit = 2048));
+ }
+ getStreamTimeWindow(t, e) {
+ const n = t === "main" ? this.mainStreamConfig : this.secondaryStreamConfig;
+ return (n == null ? void 0 : n[e]) ?? 0;
+ }
+ destroy() {
+ this.cache.clear();
+ }
+}
+class ai {
+ constructor() {
+ d(this, "events", /* @__PURE__ */ new Map());
}
dispatchEvent(t, ...e) {
const n = this.events.get(t);
- if (n) for (const r of n) r(...e);
+ if (n) for (const i of n) i(...e);
}
getEventDispatcher(t) {
let e = this.events.get(t);
e || (e = [], this.events.set(t, e));
const n = e;
- return (...r) => {
- for (const i of n) i(...r);
+ return (...i) => {
+ for (const r of n) r(...i);
};
}
addEventListener(t, e) {
@@ -3299,118 +3081,40 @@ class Wn {
removeEventListener(t, e) {
const n = this.events.get(t);
if (n) {
- const r = n.indexOf(e);
- r !== -1 && n.splice(r, 1);
+ const i = n.indexOf(e);
+ i !== -1 && n.splice(i, 1);
}
}
}
-function $t(s) {
- return `${$(s.stream)}|${s.externalId}`;
-}
-class xr {
+const U = class U {
constructor(t) {
- f(this, "cache", /* @__PURE__ */ new Map());
- f(this, "_isInitialized", !1);
- f(this, "isSegmentLockedPredicates", []);
- f(this, "logger");
- f(this, "eventTarget", new Wn());
- this.storageConfig = t, this.logger = P("p2pml-core:segment-memory-storage"), this.logger.color = "RebeccaPurple";
- }
- async initialize() {
- this._isInitialized = !0, this.logger("initialized");
- }
- get isInitialized() {
- return this._isInitialized;
- }
- addIsSegmentLockedPredicate(t) {
- this.isSegmentLockedPredicates.push(t);
- }
- isSegmentLocked(t) {
- return this.isSegmentLockedPredicates.some((e) => e(t));
- }
- async storeSegment(t, e, n) {
- const r = $t(t);
- this.cache.set(r, { segment: t, data: e, lastAccessed: performance.now() }), this.logger(`add segment: ${r}`), this.dispatchStorageUpdatedEvent(t.stream), this.clear(n);
- }
- async getSegmentData(t) {
- const e = $t(t), n = this.cache.get(e);
- if (n !== void 0) return n.lastAccessed = performance.now(), n.data;
- }
- hasSegment(t) {
- const e = $t(t);
- return this.cache.has(e);
- }
- getStoredSegmentExternalIdsOfStream(t) {
- const e = $(t), n = [];
- for (const { segment: r } of this.cache.values())
- $(r.stream) === e && n.push(r.externalId);
- return n;
- }
- async clear(t) {
- const e = 1e3 * (this.storageConfig.cachedSegmentExpiration ?? (t ? 1200 : 0));
- if (e === 0) return !1;
- const n = [], r = [], i = /* @__PURE__ */ new Set(), o = performance.now();
- for (const a of this.cache.entries()) {
- const [h, g] = a, { lastAccessed: d, segment: p } = g;
- o - d > e ? this.isSegmentLocked(p) || (n.push(h), i.add(p.stream)) : r.push(a);
- }
- if (this.storageConfig.cachedSegmentsCount > 0) {
- let a = r.length - this.storageConfig.cachedSegmentsCount;
- if (a > 0) {
- r.sort(([, h], [, g]) => h.lastAccessed - g.lastAccessed);
- for (const [h, { segment: g }] of r) if (!this.isSegmentLocked(g) && (n.push(h), i.add(g.stream), a--, a === 0)) break;
- }
- }
- if (n.length) {
- this.logger(`cleared ${n.length} segments`), n.forEach((a) => this.cache.delete(a));
- for (const a of i) this.dispatchStorageUpdatedEvent(a);
- }
- return n.length > 0;
- }
- subscribeOnUpdate(t, e) {
- const n = $(t);
- this.eventTarget.addEventListener(`onStorageUpdated-${n}`, e);
- }
- unsubscribeFromUpdate(t, e) {
- const n = $(t);
- this.eventTarget.removeEventListener(`onStorageUpdated-${n}`, e);
- }
- dispatchStorageUpdatedEvent(t) {
- this.eventTarget.dispatchEvent(`onStorageUpdated-${$(t)}`, t);
- }
- async destroy() {
- this.cache.clear(), this._isInitialized = !1;
- }
-}
-const j = class j {
- constructor(t) {
- f(this, "eventTarget", new Wn());
- f(this, "manifestResponseUrl");
- f(this, "streams", /* @__PURE__ */ new Map());
- f(this, "mainStreamConfig");
- f(this, "secondaryStreamConfig");
- f(this, "commonCoreConfig");
- f(this, "bandwidthCalculators", { all: new tn(), http: new tn() });
- f(this, "segmentStorage");
- f(this, "mainStreamLoader");
- f(this, "secondaryStreamLoader");
- f(this, "streamDetails", { isLive: !1, activeLevelBitrate: 0 });
- const e = function n(r) {
- if (Un(r)) {
- const i = {};
- return Object.keys(r).forEach((o) => {
- if (r[o] !== void 0) {
- const a = n(r[o]);
- a !== void 0 && (i[o] = a);
+ d(this, "eventTarget", new ai());
+ d(this, "manifestResponseUrl");
+ d(this, "streams", /* @__PURE__ */ new Map());
+ d(this, "mainStreamConfig");
+ d(this, "secondaryStreamConfig");
+ d(this, "commonCoreConfig");
+ d(this, "bandwidthCalculators", { all: new $e(), http: new $e() });
+ d(this, "segmentStorage");
+ d(this, "mainStreamLoader");
+ d(this, "secondaryStreamLoader");
+ d(this, "streamDetails", { isLive: !1, activeLevelBitrate: 0 });
+ const e = function n(i) {
+ if (Ln(i)) {
+ const r = {};
+ return Object.keys(i).forEach((o) => {
+ if (i[o] !== void 0) {
+ const a = n(i[o]);
+ a !== void 0 && (r[o] = a);
}
- }), i;
+ }), r;
}
- return r;
+ return i;
}(t ?? {});
- this.commonCoreConfig = Ut({ defaultConfig: j.DEFAULT_COMMON_CORE_CONFIG, baseConfig: e }), this.mainStreamConfig = Ut({ defaultConfig: j.DEFAULT_STREAM_CONFIG, baseConfig: e, specificStreamConfig: e == null ? void 0 : e.mainStream }), this.secondaryStreamConfig = Ut({ defaultConfig: j.DEFAULT_STREAM_CONFIG, baseConfig: e, specificStreamConfig: e == null ? void 0 : e.secondaryStream });
+ this.commonCoreConfig = Dt({ defaultConfig: U.DEFAULT_COMMON_CORE_CONFIG, baseConfig: e }), this.mainStreamConfig = Dt({ defaultConfig: U.DEFAULT_STREAM_CONFIG, baseConfig: e, specificStreamConfig: e == null ? void 0 : e.mainStream }), this.secondaryStreamConfig = Dt({ defaultConfig: U.DEFAULT_STREAM_CONFIG, baseConfig: e, specificStreamConfig: e == null ? void 0 : e.secondaryStream });
}
getConfig() {
- return { ...K(this.commonCoreConfig), mainStream: K(this.mainStreamConfig), secondaryStream: K(this.secondaryStreamConfig) };
+ return { ...G(this.commonCoreConfig), mainStream: G(this.mainStreamConfig), secondaryStream: G(this.secondaryStreamConfig) };
}
applyDynamicConfig(t) {
const { mainStream: e, secondaryStream: n } = t;
@@ -3426,7 +3130,7 @@ const j = class j {
this.manifestResponseUrl = t.split("?")[0];
}
hasSegment(t) {
- return !!Ze(this.streams, t);
+ return !!Ue(this.streams, t);
}
getStream(t) {
return this.streams.get(t);
@@ -3435,17 +3139,17 @@ const j = class j {
this.streams.has(t.runtimeId) || this.streams.set(t.runtimeId, { ...t, segments: /* @__PURE__ */ new Map() });
}
updateStream(t, e, n) {
- var i, o;
- const r = this.streams.get(t);
- if (r) {
- if (e) for (const a of e) r.segments.has(a.runtimeId) || r.segments.set(a.runtimeId, { ...a, stream: r });
- if (n) for (const a of n) r.segments.delete(a);
- (i = this.mainStreamLoader) == null || i.updateStream(r), (o = this.secondaryStreamLoader) == null || o.updateStream(r);
+ var r, o;
+ const i = this.streams.get(t);
+ if (i) {
+ if (e) for (const a of e) i.segments.has(a.runtimeId) || i.segments.set(a.runtimeId, { ...a, stream: i });
+ if (n) for (const a of n) i.segments.delete(a);
+ (r = this.mainStreamLoader) == null || r.updateStream(i), (o = this.secondaryStreamLoader) == null || o.updateStream(i);
}
}
async loadSegment(t, e) {
if (!this.manifestResponseUrl) throw new Error("Manifest response url is not defined");
- this.segmentStorage || (this.segmentStorage = new xr(this.commonCoreConfig), await this.segmentStorage.initialize());
+ await this.initializeSegmentStorage();
const n = this.identifySegment(t);
this.getStreamHybridLoader(n).loadSegment(n, e);
}
@@ -3454,8 +3158,8 @@ const j = class j {
(e = this.mainStreamLoader) == null || e.abortSegmentRequest(t), (n = this.secondaryStreamLoader) == null || n.abortSegmentRequest(t);
}
updatePlayback(t, e) {
- var n, r;
- (n = this.mainStreamLoader) == null || n.updatePlayback(t, e), (r = this.secondaryStreamLoader) == null || r.updatePlayback(t, e);
+ var n, i;
+ (n = this.mainStreamLoader) == null || n.updatePlayback(t, e), (i = this.secondaryStreamLoader) == null || i.updatePlayback(t, e);
}
setActiveLevelBitrate(t) {
var e, n;
@@ -3476,14 +3180,21 @@ const j = class j {
var t, e, n;
this.streams.clear(), (t = this.mainStreamLoader) == null || t.destroy(), (e = this.secondaryStreamLoader) == null || e.destroy(), (n = this.segmentStorage) == null || n.destroy(), this.mainStreamLoader = void 0, this.secondaryStreamLoader = void 0, this.segmentStorage = void 0, this.manifestResponseUrl = void 0, this.streamDetails = { isLive: !1, activeLevelBitrate: 0 };
}
+ async initializeSegmentStorage() {
+ if (this.segmentStorage) return;
+ const t = this.streamDetails.isLive, e = this.commonCoreConfig.customSegmentStorageFactory;
+ if (e && typeof e != "function") throw new Error("Storage configuration is invalid");
+ const n = e ? e(t) : new oi();
+ await n.initialize(this.commonCoreConfig, this.mainStreamConfig, this.secondaryStreamConfig), this.segmentStorage = n;
+ }
identifySegment(t) {
if (!this.manifestResponseUrl) throw new Error("Manifest response url is undefined");
- const e = Ze(this.streams, t);
+ const e = Ue(this.streams, t);
if (!e) throw new Error(`Not found segment with id: ${t}`);
return e;
}
overrideAllConfigs(t, e, n) {
- et(this.commonCoreConfig, t), et(this.mainStreamConfig, t), et(this.secondaryStreamConfig, t), e && et(this.mainStreamConfig, e), n && et(this.secondaryStreamConfig, n);
+ K(this.commonCoreConfig, t), K(this.mainStreamConfig, t), K(this.secondaryStreamConfig, t), e && K(this.mainStreamConfig, e), n && K(this.secondaryStreamConfig, n);
}
destroyStreamLoader(t) {
var e, n;
@@ -3493,20 +3204,19 @@ const j = class j {
return t.stream.type === "main" ? (this.mainStreamLoader ?? (this.mainStreamLoader = this.createNewHybridLoader(t)), this.mainStreamLoader) : (this.secondaryStreamLoader ?? (this.secondaryStreamLoader = this.createNewHybridLoader(t)), this.secondaryStreamLoader);
}
createNewHybridLoader(t) {
- var n;
if (!this.manifestResponseUrl) throw new Error("Manifest response url is not defined");
- if (!((n = this.segmentStorage) != null && n.isInitialized)) throw new Error("Segment storage is not initialized");
+ if (!this.segmentStorage) throw new Error("Segment storage is not initialized");
const e = t.stream.type === "main" ? this.mainStreamConfig : this.secondaryStreamConfig;
- return new kr(this.manifestResponseUrl, t, this.streamDetails, e, this.bandwidthCalculators, this.segmentStorage, this.eventTarget);
+ return new ri(this.manifestResponseUrl, t, this.streamDetails, e, this.bandwidthCalculators, this.segmentStorage, this.eventTarget);
}
};
-f(j, "DEFAULT_COMMON_CORE_CONFIG", { cachedSegmentExpiration: void 0, cachedSegmentsCount: 0 }), f(j, "DEFAULT_STREAM_CONFIG", { isP2PDisabled: !1, simultaneousHttpDownloads: 2, simultaneousP2PDownloads: 3, highDemandTimeWindow: 15, httpDownloadTimeWindow: 3e3, p2pDownloadTimeWindow: 6e3, webRtcMaxMessageSize: 65535, p2pNotReceivingBytesTimeoutMs: 2e3, p2pInactiveLoaderDestroyTimeoutMs: 3e4, httpNotReceivingBytesTimeoutMs: 3e3, httpErrorRetries: 3, p2pErrorRetries: 3, trackerClientVersionPrefix: ir, announceTrackers: ["wss://tracker.novage.com.ua", "wss://tracker.webtorrent.dev", "wss://tracker.openwebtorrent.com"], rtcConfig: { iceServers: [{ urls: "stun:stun.l.google.com:19302" }, { urls: "stun:global.stun.twilio.com:3478" }] }, validateP2PSegment: void 0, httpRequestSetup: void 0, swarmId: void 0 });
-let en = j;
-const Er = on.debug;
+d(U, "DEFAULT_COMMON_CORE_CONFIG", { segmentMemoryStorageLimit: void 0, customSegmentStorageFactory: void 0 }), d(U, "DEFAULT_STREAM_CONFIG", { isP2PDisabled: !1, simultaneousHttpDownloads: 2, simultaneousP2PDownloads: 3, highDemandTimeWindow: 15, httpDownloadTimeWindow: 3e3, p2pDownloadTimeWindow: 6e3, webRtcMaxMessageSize: 65535, p2pNotReceivingBytesTimeoutMs: 2e3, p2pInactiveLoaderDestroyTimeoutMs: 3e4, httpNotReceivingBytesTimeoutMs: 3e3, httpErrorRetries: 3, p2pErrorRetries: 3, trackerClientVersionPrefix: Fs, announceTrackers: ["wss://tracker.novage.com.ua", "wss://tracker.webtorrent.dev", "wss://tracker.openwebtorrent.com"], rtcConfig: { iceServers: [{ urls: "stun:stun.l.google.com:19302" }, { urls: "stun:global.stun.twilio.com:3478" }] }, validateP2PSegment: void 0, httpRequestSetup: void 0, swarmId: void 0 });
+let je = U;
+const ci = Ge.debug;
export {
- en as Core,
- fe as CoreRequestError,
- R as RequestError,
- Er as debug
+ je as Core,
+ ae as CoreRequestError,
+ x as RequestError,
+ ci as debug
};
//# sourceMappingURL=p2p-media-loader-core.es.min.js.map
diff --git a/resources/p2p-media-loader-hlsjs/1.0.5/p2p-media-loader-hlsjs.min.jsm b/resources/p2p-media-loader-hlsjs/2.0.1/p2p-media-loader-hlsjs.min.jsm
similarity index 100%
rename from resources/p2p-media-loader-hlsjs/1.0.5/p2p-media-loader-hlsjs.min.jsm
rename to resources/p2p-media-loader-hlsjs/2.0.1/p2p-media-loader-hlsjs.min.jsm