diff --git a/THIRD_PARTY.txt b/THIRD_PARTY.txt
index 2a129419..83a9f101 100644
--- a/THIRD_PARTY.txt
+++ b/THIRD_PARTY.txt
@@ -1463,9 +1463,9 @@ https://cdn.jsdelivr.net/npm/ngx-bootstrap@18.1.3/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@2.0.1/dist/p2p-media-loader-core.es.min.js
+https://cdn.jsdelivr.net/npm/p2p-media-loader-core@2.1.0/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@2.0.1/dist/p2p-media-loader-hlsjs.es.min.js
+https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@2.1.0/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 9d53d09b..0d38a8a0 100644
--- a/modules/internal/targets.js
+++ b/modules/internal/targets.js
@@ -372,7 +372,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 '2.0.1';
+ return '2.1.0';
}
if (type.startsWith('/p5.js/0.')) return '0.10.2';
if (type.startsWith('/p5.js/1.')) return '1.11.1';
diff --git a/pages/updates/updates.html b/pages/updates/updates.html
index 764def9f..47015128 100644
--- a/pages/updates/updates.html
+++ b/pages/updates/updates.html
@@ -36,6 +36,7 @@
libphonenumber-js v1.11.12 -> v1.11.15
lightgallery v2.7.2 -> v2.8.1
mdb-ui-kit v8.0.0 -> v8.1.0
+ p2p-media-loader-core & p2p-media-loader-hlsjs v2.0.1 -> v2.1.0
Added
diff --git a/resources/p2p-media-loader-core/2.0.1/p2p-media-loader-core.min.jsm b/resources/p2p-media-loader-core/2.1.0/p2p-media-loader-core.min.jsm
similarity index 67%
rename from resources/p2p-media-loader-core/2.0.1/p2p-media-loader-core.min.jsm
rename to resources/p2p-media-loader-core/2.1.0/p2p-media-loader-core.min.jsm
index f154b7cf..cff31158 100644
--- a/resources/p2p-media-loader-core/2.0.1/p2p-media-loader-core.min.jsm
+++ b/resources/p2p-media-loader-core/2.1.0/p2p-media-loader-core.min.jsm
@@ -1,6 +1,6 @@
-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);
+var Pn = Object.defineProperty;
+var qn = (i, t, e) => t in i ? Pn(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
+var d = (i, t, e) => qn(i, typeof t != "symbol" ? t + "" : t, e);
class x extends Error {
constructor(e, n) {
super(n);
@@ -8,12 +8,12 @@ class x extends Error {
this.type = e, this.timestamp = performance.now();
}
}
-class ae extends Error {
+class oe extends Error {
constructor(t) {
super(), this.type = t;
}
}
-class On {
+class Bn {
constructor(t, e, n) {
d(this, "requestControls");
d(this, "abortController", new AbortController());
@@ -21,20 +21,20 @@ class On {
d(this, "requestByteRange");
d(this, "onChunkDownloaded");
this.request = t, this.httpConfig = e, this.onChunkDownloaded = n.getEventDispatcher("onChunkDownloaded");
- 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();
+ const { byteRange: s } = this.request.segment;
+ s && (this.requestByteRange = { ...s }), 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 i = await ((n = (e = this.httpConfig).httpRequestSetup) == null ? void 0 : n.call(e, t.url, t.byteRange, this.abortController.signal, this.requestByteRange));
- if (!i) {
+ let s = await ((n = (e = this.httpConfig).httpRequestSetup) == null ? void 0 : n.call(e, t.url, t.byteRange, this.abortController.signal, this.requestByteRange));
+ if (!s) {
const h = new Headers(this.requestByteRange ? { Range: `bytes=${this.requestByteRange.start}-${this.requestByteRange.end ?? ""}` } : void 0);
- i = new Request(t.url, { headers: h, signal: this.abortController.signal });
+ s = 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 r = await window.fetch(i);
+ const r = await window.fetch(s);
if (this.handleResponseHeaders(r), !r.body) return;
const { requestControls: o } = this;
o.firstBytesReceived();
@@ -47,8 +47,8 @@ class On {
}
}(a)) this.requestControls.addLoadedChunk(h), this.onChunkDownloaded(h.byteLength, "http");
o.completeOnSuccess();
- } catch (i) {
- this.handleError(i);
+ } catch (s) {
+ this.handleError(s);
}
}
handleResponseHeaders(t) {
@@ -61,12 +61,12 @@ class On {
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 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+)|\*)$/);
+ const s = t.headers.get("Content-Range"), r = s ? function(o) {
+ const a = On.exec(o.trim());
if (!a) return;
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;
+ }(s) : 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);
@@ -85,34 +85,35 @@ class On {
}
}
}
-function Dn(s) {
- return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
+const On = /^bytes (?:(?:(\d+)|)-(?:(\d+)|)|\*)\/(?:(\d+)|\*)$/;
+function Dn(i) {
+ return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
}
-var R, P, We = { exports: {} }, _ = We.exports = {};
-function Ut() {
+var E, P, je = { exports: {} }, _ = je.exports = {};
+function Ft() {
throw new Error("setTimeout has not been defined");
}
function Ht() {
throw new Error("clearTimeout has not been defined");
}
-function Qe(s) {
- if (R === setTimeout) return setTimeout(s, 0);
- if ((R === Ut || !R) && setTimeout) return R = setTimeout, setTimeout(s, 0);
+function We(i) {
+ if (E === setTimeout) return setTimeout(i, 0);
+ if ((E === Ft || !E) && setTimeout) return E = setTimeout, setTimeout(i, 0);
try {
- return R(s, 0);
+ return E(i, 0);
} catch {
try {
- return R.call(null, s, 0);
+ return E.call(null, i, 0);
} catch {
- return R.call(this, s, 0);
+ return E.call(this, i, 0);
}
}
}
(function() {
try {
- R = typeof setTimeout == "function" ? setTimeout : Ut;
+ E = typeof setTimeout == "function" ? setTimeout : Ft;
} catch {
- R = Ut;
+ E = Ft;
}
try {
P = typeof clearTimeout == "function" ? clearTimeout : Ht;
@@ -120,19 +121,19 @@ function Qe(s) {
P = Ht;
}
})();
-var H, q = [], Q = !1, pt = -1;
+var j, q = [], z = !1, pt = -1;
function Mn() {
- Q && H && (Q = !1, H.length ? q = H.concat(q) : pt = -1, q.length && ze());
+ z && j && (z = !1, j.length ? q = j.concat(q) : pt = -1, q.length && Qe());
}
-function ze() {
- if (!Q) {
- var s = Qe(Mn);
- Q = !0;
+function Qe() {
+ if (!z) {
+ var i = We(Mn);
+ z = !0;
for (var t = q.length; t; ) {
- for (H = q, q = []; ++pt < t; ) H && H[pt].run();
+ for (j = q, q = []; ++pt < t; ) j && j[pt].run();
pt = -1, t = q.length;
}
- H = null, Q = !1, function(e) {
+ j = null, z = !1, function(e) {
if (P === clearTimeout) return clearTimeout(e);
if ((P === Ht || !P) && clearTimeout) return P = clearTimeout, clearTimeout(e);
try {
@@ -144,46 +145,46 @@ function ze() {
return P.call(this, e);
}
}
- }(s);
+ }(i);
}
}
-function he(s, t) {
- this.fun = s, this.array = t;
+function ae(i, t) {
+ this.fun = i, this.array = t;
}
-function I() {
+function R() {
}
-_.nextTick = function(s) {
+_.nextTick = function(i) {
var t = new Array(arguments.length - 1);
if (arguments.length > 1) for (var e = 1; e < arguments.length; e++) t[e - 1] = arguments[e];
- q.push(new he(s, t)), q.length !== 1 || Q || Qe(ze);
-}, he.prototype.run = function() {
+ q.push(new ae(i, t)), q.length !== 1 || z || We(Qe);
+}, ae.prototype.run = function() {
this.fun.apply(null, this.array);
-}, _.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) {
+}, _.title = "browser", _.browser = !0, _.env = {}, _.argv = [], _.version = "", _.versions = {}, _.on = R, _.addListener = R, _.once = R, _.off = R, _.removeListener = R, _.removeAllListeners = R, _.emit = R, _.prependListener = R, _.prependOnceListener = R, _.listeners = function(i) {
return [];
-}, _.binding = function(s) {
+}, _.binding = function(i) {
throw new Error("process.binding is not supported");
}, _.cwd = function() {
return "/";
-}, _.chdir = function(s) {
+}, _.chdir = function(i) {
throw new Error("process.chdir is not supported");
}, _.umask = function() {
return 0;
};
-const ft = Dn(We.exports);
+const ft = Dn(je.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;
+function W(i) {
+ return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
}
-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;
+var he, ce, $t = { exports: {} };
+function Un() {
+ if (ce) return he;
+ ce = 1;
+ var i = 1e3, t = 60 * i, e = 60 * t, n = 24 * e, s = 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 ce = function(a, h) {
+ return he = function(a, h) {
h = h || {};
var u = typeof a;
if (u === "string" && a.length > 0) return function(c) {
@@ -201,7 +202,7 @@ function Fn() {
case "weeks":
case "week":
case "w":
- return g * i;
+ return g * s;
case "days":
case "day":
case "d":
@@ -223,7 +224,7 @@ function Fn() {
case "secs":
case "sec":
case "s":
- return g * s;
+ return g * i;
case "milliseconds":
case "millisecond":
case "msecs":
@@ -238,79 +239,79 @@ function Fn() {
}(a);
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";
+ return l >= n ? o(c, l, n, "day") : l >= e ? o(c, l, e, "hour") : l >= t ? o(c, l, t, "minute") : l >= i ? o(c, l, i, "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";
+ return l >= n ? Math.round(c / n) + "d" : l >= e ? Math.round(c / e) + "h" : l >= t ? Math.round(c / t) + "m" : l >= i ? Math.round(c / i) + "s" : c + "ms";
}(a);
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(a));
};
}
-var Un = function(s) {
- function t(i) {
+var Fn = function(i) {
+ function t(s) {
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) => {
+ c[0] = c[0].replace(/%([a-zA-Z%])/g, (v, H) => {
if (v === "%%") return "%";
f++;
- const D = t.formatters[F];
+ const D = t.formatters[H];
if (typeof D == "function") {
- const Rt = c[f];
- v = D.call(l, Rt), c.splice(f, 1), f--;
+ const Et = c[f];
+ v = D.call(l, Et), c.splice(f, 1), f--;
}
return v;
}), t.formatArgs.call(l, c), (l.log || t.log).apply(l, c);
}
- 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) => {
+ return u.namespace = s, u.useColors = t.useColors(), u.color = t.selectColor(s), 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(s)), a), set: (c) => {
h = c;
} }), typeof t.init == "function" && t.init(u), u;
}
- function e(i, r) {
- const o = t(this.namespace + (r === void 0 ? ":" : r) + i);
+ function e(s, r) {
+ const o = t(this.namespace + (r === void 0 ? ":" : r) + s);
return o.log = this.log, o;
}
- function n(i) {
- return i.toString().substring(2, i.toString().length - 2).replace(/\.\*\?$/, "*");
+ function n(s) {
+ return s.toString().substring(2, s.toString().length - 2).replace(/\.\*\?$/, "*");
}
- return t.debug = t, t.default = t, t.coerce = function(i) {
- return i instanceof Error ? i.stack || i.message : i;
+ return t.debug = t, t.default = t, t.coerce = function(s) {
+ return s instanceof Error ? s.stack || s.message : s;
}, t.disable = function() {
- const i = [...t.names.map(n), ...t.skips.map(n).map((r) => "-" + r)].join(",");
- return t.enable(""), i;
- }, t.enable = function(i) {
+ const s = [...t.names.map(n), ...t.skips.map(n).map((r) => "-" + r)].join(",");
+ return t.enable(""), s;
+ }, t.enable = function(s) {
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;
+ t.save(s), t.namespaces = s, t.names = [], t.skips = [];
+ const o = (typeof s == "string" ? s : "").split(/[\s,]+/), a = o.length;
+ for (r = 0; r < a; r++) o[r] && ((s = o[r].replace(/\*/g, ".*?"))[0] === "-" ? t.skips.push(new RegExp("^" + s.slice(1) + "$")) : t.names.push(new RegExp("^" + s + "$")));
+ }, t.enabled = function(s) {
+ if (s[s.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;
+ for (r = 0, o = t.skips.length; r < o; r++) if (t.skips[r].test(s)) return !1;
+ for (r = 0, o = t.names.length; r < o; r++) if (t.names[r].test(s)) return !0;
return !1;
- }, t.humanize = Fn(), t.destroy = function() {
+ }, t.humanize = Un(), 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((i) => {
- t[i] = s[i];
- }), t.names = [], t.skips = [], t.formatters = {}, t.selectColor = function(i) {
+ }, Object.keys(i).forEach((s) => {
+ t[s] = i[s];
+ }), t.names = [], t.skips = [], t.formatters = {}, t.selectColor = function(s) {
let r = 0;
- for (let o = 0; o < i.length; o++) r = (r << 5) - r + i.charCodeAt(o), r |= 0;
+ for (let o = 0; o < s.length; o++) r = (r << 5) - r + s.charCodeAt(o), r |= 0;
return t.colors[Math.abs(r) % t.colors.length];
}, t.enable(t.load()), t;
};
-(function(s, t) {
+(function(i, 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 i = "color: " + this.color;
- n.splice(1, 0, i, "color: inherit");
+ if (n[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + n[0] + (this.useColors ? "%c " : " ") + "+" + i.exports.humanize(this.diff), !this.useColors) return;
+ const s = "color: " + this.color;
+ n.splice(1, 0, s, "color: inherit");
let r = 0, o = 0;
n[0].replace(/%[a-zA-Z%]/g, (a) => {
a !== "%%" && (r++, a === "%c" && (o = r));
- }), n.splice(o, 0, i);
+ }), n.splice(o, 0, s);
}, t.save = function(n) {
try {
n ? t.storage.setItem("debug", n) : t.storage.removeItem("debug");
@@ -339,116 +340,116 @@ var Un = 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 = Un(t);
- const { formatters: e } = s.exports;
+ }), i.exports = Fn(t);
+ const { formatters: e } = i.exports;
e.j = function(n) {
try {
return JSON.stringify(n);
- } catch (i) {
- return "[UnexpectedJSONParseError]: " + i.message;
+ } catch (s) {
+ return "[UnexpectedJSONParseError]: " + s.message;
}
};
})($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);
+var ze = $t.exports;
+const L = W(ze);
+var Ge, jt = { exports: {} }, G = typeof Reflect == "object" ? Reflect : null, de = G && typeof G.apply == "function" ? G.apply : function(i, t, e) {
+ return Function.prototype.apply.call(i, t, e);
};
-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);
+Ge = G && typeof G.ownKeys == "function" ? G.ownKeys : Object.getOwnPropertySymbols ? function(i) {
+ return Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i));
+} : function(i) {
+ return Object.getOwnPropertyNames(i);
};
-var ue = Number.isNaN || function(s) {
- return s != s;
+var le = Number.isNaN || function(i) {
+ return i != i;
};
function p() {
p.init.call(this);
}
-jt.exports = p, jt.exports.once = function(s, t) {
+jt.exports = p, jt.exports.once = function(i, t) {
return new Promise(function(e, n) {
- function i(o) {
- s.removeListener(t, r), n(o);
+ function s(o) {
+ i.removeListener(t, r), n(o);
}
function r() {
- typeof s.removeListener == "function" && s.removeListener("error", i), e([].slice.call(arguments));
+ typeof i.removeListener == "function" && i.removeListener("error", s), e([].slice.call(arguments));
}
- _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 });
+ ye(i, t, r, { once: !0 }), t !== "error" && function(o, a, h) {
+ typeof o.on == "function" && ye(o, "error", a, h);
+ }(i, s, { once: !0 });
});
}, 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);
+var ue = 10;
+function yt(i) {
+ if (typeof i != "function") throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof i);
}
-function Ve(s) {
- return s._maxListeners === void 0 ? p.defaultMaxListeners : s._maxListeners;
+function Je(i) {
+ return i._maxListeners === void 0 ? p.defaultMaxListeners : i._maxListeners;
}
-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) {
+function ge(i, t, e, n) {
+ var s, r, o, a;
+ if (yt(e), (r = i._events) === void 0 ? (r = i._events = /* @__PURE__ */ Object.create(null), i._eventsCount = 0) : (r.newListener !== void 0 && (i.emit("newListener", t, e.listener ? e.listener : e), r = i._events), o = r[t]), o === void 0) o = r[t] = e, ++i._eventsCount;
+ else if (typeof o == "function" ? o = r[t] = n ? [e, o] : [o, e] : n ? o.unshift(e) : o.push(e), (s = Je(i)) > 0 && o.length > s && !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);
+ h.name = "MaxListenersExceededWarning", h.emitter = i, h.type = t, h.count = o.length, a = h, console && console.warn && console.warn(a);
}
- return s;
+ return i;
}
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 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 me(i, t, e) {
+ var n = { fired: !1, wrapFn: void 0, target: i, type: t, listener: e }, s = Hn.bind(n);
+ return s.listener = e, n.wrapFn = s, s;
}
-function fe(s, t, e) {
- var n = s._events;
+function pe(i, t, e) {
+ var n = i._events;
if (n === void 0) return [];
- var i = n[t];
- return i === void 0 ? [] : typeof i == "function" ? e ? [i.listener || i] : [i] : e ? function(r) {
+ var s = n[t];
+ return s === void 0 ? [] : typeof s == "function" ? e ? [s.listener || s] : [s] : 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;
- }(i) : Ye(i, i.length);
+ }(s) : Ve(s, s.length);
}
-function ye(s) {
+function fe(i) {
var t = this._events;
if (t !== void 0) {
- var e = t[s];
+ var e = t[i];
if (typeof e == "function") return 1;
if (e !== void 0) return e.length;
}
return 0;
}
-function Ye(s, t) {
- for (var e = new Array(t), n = 0; n < t; ++n) e[n] = s[n];
+function Ve(i, t) {
+ for (var e = new Array(t), n = 0; n < t; ++n) e[n] = i[n];
return e;
}
-function _e(s, t, e, n) {
- if (typeof s.on == "function") n.once ? s.once(t, e) : s.on(t, e);
+function ye(i, t, e, n) {
+ if (typeof i.on == "function") n.once ? i.once(t, e) : i.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 i(r) {
- n.once && s.removeEventListener(t, i), e(r);
+ if (typeof i.addEventListener != "function") throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof i);
+ i.addEventListener(t, function s(r) {
+ n.once && i.removeEventListener(t, s), e(r);
});
}
}
Object.defineProperty(p, "defaultMaxListeners", { enumerable: !0, get: function() {
- return ge;
-}, set: function(s) {
- 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;
+ return ue;
+}, set: function(i) {
+ if (typeof i != "number" || i < 0 || le(i)) throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + i + ".");
+ ue = i;
} }), 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;
-}, 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;
+}, p.prototype.setMaxListeners = function(i) {
+ if (typeof i != "number" || i < 0 || le(i)) throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + i + ".");
+ return this._maxListeners = i, this;
}, p.prototype.getMaxListeners = function() {
- return Ve(this);
-}, p.prototype.emit = function(s) {
+ return Je(this);
+}, p.prototype.emit = function(i) {
for (var t = [], e = 1; e < arguments.length; e++) t.push(arguments[e]);
- var n = s === "error", i = this._events;
- if (i !== void 0) n = n && i.error === void 0;
+ var n = i === "error", s = this._events;
+ if (s !== void 0) n = n && s.error === void 0;
else if (!n) return !1;
if (n) {
var r;
@@ -456,105 +457,105 @@ Object.defineProperty(p, "defaultMaxListeners", { enumerable: !0, get: function(
var o = new Error("Unhandled error." + (r ? " (" + r.message + ")" : ""));
throw o.context = r, o;
}
- var a = i[s];
+ var a = s[i];
if (a === void 0) return !1;
- if (typeof a == "function") le(a, this, t);
+ if (typeof a == "function") de(a, this, t);
else {
- var h = a.length, u = Ye(a, h);
- for (e = 0; e < h; ++e) le(u[e], this, t);
+ var h = a.length, u = Ve(a, h);
+ for (e = 0; e < h; ++e) de(u[e], this, t);
}
return !0;
-}, 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;
+}, p.prototype.addListener = function(i, t) {
+ return ge(this, i, t, !1);
+}, p.prototype.on = p.prototype.addListener, p.prototype.prependListener = function(i, t) {
+ return ge(this, i, t, !0);
+}, p.prototype.once = function(i, t) {
+ return yt(t), this.on(i, me(this, i, t)), this;
+}, p.prototype.prependOnceListener = function(i, t) {
+ return yt(t), this.prependListener(i, me(this, i, t)), this;
+}, p.prototype.removeListener = function(i, t) {
+ var e, n, s, 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));
+ if ((e = n[i]) === void 0) return this;
+ if (e === t || e.listener === t) --this._eventsCount == 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete n[i], n.removeListener && this.emit("removeListener", i, e.listener || t));
else if (typeof e != "function") {
- for (i = -1, r = e.length - 1; r >= 0; r--) if (e[r] === t || e[r].listener === t) {
- o = e[r].listener, i = r;
+ for (s = -1, r = e.length - 1; r >= 0; r--) if (e[r] === t || e[r].listener === t) {
+ o = e[r].listener, s = r;
break;
}
- if (i < 0) return this;
- i === 0 ? e.shift() : function(a, h) {
+ if (s < 0) return this;
+ s === 0 ? e.shift() : function(a, h) {
for (; h + 1 < a.length; h++) a[h] = a[h + 1];
a.pop();
- }(e, i), e.length === 1 && (n[s] = e[0]), n.removeListener !== void 0 && this.emit("removeListener", s, o || t);
+ }(e, s), e.length === 1 && (n[i] = e[0]), n.removeListener !== void 0 && this.emit("removeListener", i, o || t);
}
return this;
-}, p.prototype.off = p.prototype.removeListener, p.prototype.removeAllListeners = function(s) {
+}, p.prototype.off = p.prototype.removeListener, p.prototype.removeAllListeners = function(i) {
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 (e.removeListener === void 0) return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : e[i] !== void 0 && (--this._eventsCount == 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete e[i]), this;
if (arguments.length === 0) {
- var i, r = Object.keys(e);
- for (n = 0; n < r.length; ++n) (i = r[n]) !== "removeListener" && this.removeAllListeners(i);
+ var s, r = Object.keys(e);
+ for (n = 0; n < r.length; ++n) (s = r[n]) !== "removeListener" && this.removeAllListeners(s);
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]);
+ if (typeof (t = e[i]) == "function") this.removeListener(i, t);
+ else if (t !== void 0) for (n = t.length - 1; n >= 0; n--) this.removeListener(i, t[n]);
return this;
-}, 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) : [];
+}, p.prototype.listeners = function(i) {
+ return pe(this, i, !0);
+}, p.prototype.rawListeners = function(i) {
+ return pe(this, i, !1);
+}, p.listenerCount = function(i, t) {
+ return typeof i.listenerCount == "function" ? i.listenerCount(t) : fe.call(i, t);
+}, p.prototype.listenerCount = fe, p.prototype.eventNames = function() {
+ return this._eventsCount > 0 ? Ge(this._events) : [];
};
-var Ke = jt.exports;
-const Ze = j(Ke);
-var Wt = { exports: {} }, $n = function s(t, e) {
- if (t && e) return s(t)(e);
+var Ye = jt.exports;
+const Ke = W(Ye);
+var Wt = { exports: {} }, $n = function i(t, e) {
+ if (t && e) return i(t)(e);
if (typeof t != "function") throw new TypeError("need wrapper function");
- return Object.keys(t).forEach(function(i) {
- n[i] = t[i];
+ return Object.keys(t).forEach(function(s) {
+ n[s] = t[s];
}), n;
function n() {
- 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];
+ for (var s = new Array(arguments.length), r = 0; r < s.length; r++) s[r] = arguments[r];
+ var o = t.apply(this, s), a = s[s.length - 1];
return typeof o == "function" && o !== a && Object.keys(a).forEach(function(h) {
o[h] = a[h];
}), o;
}
-}, Se = $n;
-function rt(s) {
+}, _e = $n;
+function rt(i) {
var t = function() {
- return t.called ? t.value : (t.called = !0, t.value = s.apply(this, arguments));
+ return t.called ? t.value : (t.called = !0, t.value = i.apply(this, arguments));
};
return t.called = !1, t;
}
-function we(s) {
+function Se(i) {
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.called = !0, t.value = i.apply(this, arguments);
+ }, e = i.name || "Function wrapped with `once`";
return t.onceError = e + " shouldn't be called more than once", t.called = !1, t;
}
-Wt.exports = Se(rt), Wt.exports.strict = Se(we), rt.proto = rt(function() {
+Wt.exports = _e(rt), Wt.exports.strict = _e(Se), rt.proto = rt(function() {
Object.defineProperty(Function.prototype, "once", { value: function() {
return rt(this);
}, configurable: !0 }), Object.defineProperty(Function.prototype, "onceStrict", { value: function() {
- return we(this);
+ return Se(this);
}, configurable: !0 });
});
-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(() => {
+const jn = W(Wt.exports);
+let we;
+var Ze = typeof queueMicrotask == "function" ? queueMicrotask.bind(typeof window < "u" ? window : Nn) : (i) => (we || (we = Promise.resolve())).then(i).catch((t) => setTimeout(() => {
throw t;
}, 0));
-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);
+const Qt = W(Ze);
+var Wn = function(i, t) {
+ let e, n, s, r = !0;
+ Array.isArray(i) ? (e = [], n = i.length) : (s = Object.keys(i), e = {}, n = s.length);
function o(h) {
function u() {
t && t(h, e), t = null;
@@ -564,32 +565,32 @@ var Wn = function(s, t) {
function a(h, u, c) {
e[h] = c, (--n == 0 || u) && o(u);
}
- n ? i ? i.forEach(function(h) {
- s[h](function(u, c) {
+ n ? s ? s.forEach(function(h) {
+ i[h](function(u, c) {
a(h, u, c);
});
- }) : s.forEach(function(h, u) {
+ }) : i.forEach(function(h, u) {
h(function(c, l) {
a(u, c, l);
});
}) : o(null), r = !1;
};
-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;
+const Qn = Ze, zn = W(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 : (i) => Promise.resolve().then(i);
+const be = class {
+ constructor(i) {
+ if (!(i > 0) || i - 1 & i) throw new Error("Max size for a FixedFIFO should be a power of two");
+ this.buffer = new Array(i), this.mask = i - 1, this.top = 0, this.btm = 0, this.next = null;
}
clear() {
this.top = this.btm = 0, this.next = null, this.buffer.fill(void 0);
}
- push(s) {
- return this.buffer[this.top] === void 0 && (this.buffer[this.top] = s, this.top = this.top + 1 & this.mask, !0);
+ push(i) {
+ return this.buffer[this.top] === void 0 && (this.buffer[this.top] = i, this.top = this.top + 1 & this.mask, !0);
}
shift() {
- const s = this.buffer[this.btm];
- if (s !== void 0) return this.buffer[this.btm] = void 0, this.btm = this.btm + 1 & this.mask, s;
+ const i = this.buffer[this.btm];
+ if (i !== void 0) return this.buffer[this.btm] = void 0, this.btm = this.btm + 1 & this.mask, i;
}
peek() {
return this.buffer[this.btm];
@@ -598,51 +599,51 @@ const Ce = class {
return this.buffer[this.btm] === void 0;
}
};
-var tn = class {
- constructor(s) {
- this.decoder = new TextDecoder(s === "utf16le" ? "utf16-le" : s);
+var Xe = class {
+ constructor(i) {
+ this.decoder = new TextDecoder(i === "utf16le" ? "utf16-le" : i);
}
get remaining() {
return -1;
}
- decode(s) {
- return this.decoder.decode(s, { stream: !0 });
+ decode(i) {
+ return this.decoder.decode(i, { stream: !0 });
}
flush() {
return this.decoder.decode(new Uint8Array(0));
}
};
-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 Ce(this.hwm), this.tail = this.head, this.length = 0;
+const Yn = Xe, Kn = Xe, { EventEmitter: Zn } = Ye, ie = new Error("Stream was destroyed"), tn = (new Error("Premature close"), Vn), en = class {
+ constructor(i) {
+ this.hwm = i || 16, this.head = new be(this.hwm), this.tail = this.head, this.length = 0;
}
clear() {
this.head = this.tail, this.head.clear(), this.length = 0;
}
- push(s) {
- if (this.length++, !this.head.push(s)) {
+ push(i) {
+ if (this.length++, !this.head.push(i)) {
const t = this.head;
- this.head = t.next = new Ce(2 * this.head.buffer.length), this.head.push(s);
+ this.head = t.next = new be(2 * this.head.buffer.length), this.head.push(i);
}
}
shift() {
this.length !== 0 && this.length--;
- const s = this.tail.shift();
- if (s === void 0 && this.tail.next) {
+ const i = this.tail.shift();
+ if (i === void 0 && this.tail.next) {
const t = this.tail.next;
return this.tail.next = null, this.tail = t, this.tail.shift();
}
- return s;
+ return i;
}
peek() {
- const s = this.tail.peek();
- return s === void 0 && this.tail.next ? this.tail.next.peek() : s;
+ const i = this.tail.peek();
+ return i === void 0 && this.tail.next ? this.tail.next.peek() : i;
}
isEmpty() {
return this.length === 0;
}
}, Xn = class {
- constructor(s = "utf8") {
+ constructor(i = "utf8") {
switch (this.encoding = function(t) {
switch (t = t.toLowerCase()) {
case "utf8":
@@ -663,7 +664,7 @@ const Yn = tn, Kn = tn, { EventEmitter: Zn } = Ke, re = new Error("Stream was de
default:
throw new Error("Unknown encoding: " + t);
}
- }(s), this.encoding) {
+ }(i), this.encoding) {
case "utf8":
this.decoder = new Kn();
break;
@@ -677,45 +678,45 @@ const Yn = tn, Kn = tn, { EventEmitter: Zn } = Ke, re = new Error("Stream was de
get remaining() {
return this.decoder.remaining;
}
- push(s) {
- return typeof s == "string" ? s : this.decoder.decode(s);
+ push(i) {
+ return typeof i == "string" ? i : this.decoder.decode(i);
}
- write(s) {
- return this.push(s);
+ write(i) {
+ return this.push(i);
}
- end(s) {
+ end(i) {
let t = "";
- return s && (t = this.push(s)), t += this.decoder.flush(), t;
+ return i && (t = this.push(i)), t += this.decoder.flush(), t;
}
-}, 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);
+}, it = 536870911, nn = 1 ^ it, ts = 2 ^ it, sn = 64, Pt = 128, rn = 256, es = 1024, Ce = 2048, ns = 4096, ss = 8192, St = 16384, qt = 32768, Gt = 131072, is = 131328, rs = 16 ^ it, ve = 536805375, ke = 768 ^ it, on = 536838143, os = 32 ^ it, an = 536739839, as = 1 << 18, wt = 2 << 18, hn = 4 << 18, Te = 8 << 18, hs = 16 << 18, cn = 32 << 18, Jt = 64 << 18, Bt = 128 << 18, xe = 512 << 18, cs = 1024 << 18, ds = 535822335, dn = 503316479, ls = 268435455, bt = 262160, us = 536608751, ln = 8404992, nt = 14, gs = 15, un = 8405006, gn = 33587200, mn = 33587215, ms = 2359296, Ae = 270794767, ot = Symbol.asyncIterator || Symbol("asyncIterator");
+class ps {
+ constructor(t, { highWaterMark: e = 16384, map: n = null, mapWritable: s, byteLength: r, byteLengthWritable: o } = {}) {
+ this.stream = t, this.queue = new en(), this.highWaterMark = e, this.buffered = 0, this.error = null, this.pipeline = null, this.drains = null, this.byteLength = o || r || _n, this.map = s || n, this.afterWrite = ws.bind(this), this.afterUpdateNextTick = vs.bind(this);
}
get ended() {
- return !!(this.stream._duplexState & dn);
+ return !!(this.stream._duplexState & cn);
}
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 |= xe, !0) : (this.stream._duplexState |= 6291456, !1);
+ return !(142606350 & this.stream._duplexState) && (this.map !== null && (t = this.map(t)), this.buffered += this.byteLength(t), this.queue.push(t), this.buffered < this.highWaterMark ? (this.stream._duplexState |= Te, !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 | Le) & cs;
+ typeof t == "function" ? this.stream.once("finish", t) : t != null && this.push(t), this.stream._duplexState = (this.stream._duplexState | xe) & ds;
}
autoBatch(t, 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);
+ const n = [], s = this.stream;
+ for (n.push(t); (s._duplexState & Ae) === ms; ) n.push(s._writableState.shift());
+ if (s._duplexState & gs) return e(null);
+ s._writev(n, e);
}
update() {
const t = this.stream;
t._duplexState |= wt;
do {
- for (; (t._duplexState & Ae) === xe; ) {
+ for (; (t._duplexState & Ae) === Te; ) {
const e = this.shift();
t._duplexState |= 67371008, t._write(e, this.afterWrite);
}
@@ -725,38 +726,38 @@ class ms {
}
updateNonPrimary() {
const t = this.stream;
- 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)));
+ if ((144965647 & t._duplexState) === xe) return t._duplexState = t._duplexState | as, void t._final(Ss.bind(this));
+ (t._duplexState & nt) != 4 ? (t._duplexState & mn) == 1 && (t._duplexState = (t._duplexState | bt) & nn, t._open(fn.bind(this))) : t._duplexState & gn || (t._duplexState |= bt, t._destroy(pn.bind(this)));
}
continueUpdate() {
- return !!(this.stream._duplexState & Bt) && (this.stream._duplexState &= un, !0);
+ return !!(this.stream._duplexState & Bt) && (this.stream._duplexState &= dn, !0);
}
updateCallback() {
- (35127311 & this.stream._duplexState) === cn ? this.update() : this.updateNextTick();
+ (35127311 & this.stream._duplexState) === hn ? this.update() : this.updateNextTick();
}
updateNextTick() {
- this.stream._duplexState & Bt || (this.stream._duplexState |= Bt, this.stream._duplexState & wt || en(this.afterUpdateNextTick));
+ this.stream._duplexState & Bt || (this.stream._duplexState |= Bt, this.stream._duplexState & wt || tn(this.afterUpdateNextTick));
}
}
-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);
+class fs {
+ constructor(t, { highWaterMark: e = 16384, map: n = null, mapReadable: s, byteLength: r, byteLengthReadable: o } = {}) {
+ this.stream = t, this.queue = new en(), this.highWaterMark = e === 0 ? 1 : e, this.buffered = 0, this.readAhead = e > 0, this.error = null, this.pipeline = null, this.byteLength = o || r || _n, this.map = s || n, this.pipeTo = null, this.afterRead = bs.bind(this), this.afterUpdateNextTick = Cs.bind(this);
}
get ended() {
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 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));
+ if (typeof e != "function" && (e = null), this.stream._duplexState |= 512, this.pipeTo = t, this.pipeline = new ys(this.stream, t, e), e && this.stream.on("error", Le), yn(t)) t._writableState.pipeline = this.pipeline, e && t.on("error", Le), t.on("finish", this.pipeline.finished.bind(this.pipeline));
else {
- 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));
+ const n = this.pipeline.done.bind(this.pipeline, t), s = this.pipeline.done.bind(this.pipeline, t, null);
+ t.on("error", n), t.on("close", s), t.on("finish", this.pipeline.finished.bind(this.pipeline));
}
- t.on("drain", ys.bind(this)), this.stream.emit("piping", t), t.emit("pipe", this.stream);
+ t.on("drain", _s.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 ? (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);
+ return t === null ? (this.highWaterMark = 0, e._duplexState = 536805311 & e._duplexState | 1024, !1) : this.map !== null && (t = this.map(t)) === null ? (e._duplexState &= ve, this.buffered < this.highWaterMark) : (this.buffered += this.byteLength(t), this.queue.push(t), e._duplexState = (e._duplexState | Pt) & ve, this.buffered < this.highWaterMark);
}
shift() {
const t = this.queue.shift();
@@ -766,8 +767,8 @@ class ps {
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 i = e[n];
- this.buffered += this.byteLength(i), this.queue.push(i);
+ const s = e[n];
+ this.buffered += this.byteLength(s), this.queue.push(s);
}
this.push(e[e.length - 1]);
}
@@ -775,7 +776,7 @@ class ps {
const t = this.stream;
if ((16527 & t._duplexState) === Pt) {
const e = this.shift();
- return this.pipeTo !== null && this.pipeTo.write(e) === !1 && (t._duplexState &= Te), t._duplexState & ve && t.emit("data", e), e;
+ return this.pipeTo !== null && this.pipeTo.write(e) === !1 && (t._duplexState &= ke), t._duplexState & Ce && t.emit("data", e), e;
}
return this.readAhead === !1 && (t._duplexState |= Gt, this.updateNextTick()), null;
}
@@ -783,7 +784,7 @@ class ps {
const t = this.stream;
for (; (16527 & t._duplexState) === Pt && 768 & t._duplexState; ) {
const e = this.shift();
- this.pipeTo !== null && this.pipeTo.write(e) === !1 && (t._duplexState &= Te), t._duplexState & ve && t.emit("data", e);
+ this.pipeTo !== null && this.pipeTo.write(e) === !1 && (t._duplexState &= ke), t._duplexState & Ce && t.emit("data", e);
}
}
update() {
@@ -797,19 +798,19 @@ class ps {
}
updateNonPrimary() {
const t = this.stream;
- (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)));
+ (1167 & t._duplexState) === es && (t._duplexState = 536869887 & t._duplexState | 16384, t.emit("end"), (t._duplexState & un) === ln && (t._duplexState |= 4), this.pipeTo !== null && this.pipeTo.end()), (t._duplexState & nt) != 4 ? (t._duplexState & mn) == 1 && (t._duplexState = (t._duplexState | bt) & nn, t._open(fn.bind(this))) : t._duplexState & gn || (t._duplexState |= bt, t._destroy(pn.bind(this)));
}
continueUpdate() {
- return !!(this.stream._duplexState & qt) && (this.stream._duplexState &= an, !0);
+ return !!(this.stream._duplexState & qt) && (this.stream._duplexState &= on, !0);
}
updateCallback() {
- (32879 & this.stream._duplexState) === rn ? this.update() : this.updateNextTick();
+ (32879 & this.stream._duplexState) === sn ? this.update() : this.updateNextTick();
}
updateNextTick() {
- this.stream._duplexState & qt || (this.stream._duplexState |= qt, 32 & this.stream._duplexState || en(this.afterUpdateNextTick));
+ this.stream._duplexState & qt || (this.stream._duplexState |= qt, 32 & this.stream._duplexState || tn(this.afterUpdateNextTick));
}
}
-class fs {
+class ys {
constructor(t, e, n) {
this.from = t, this.to = e, this.afterPipe = n, this.error = null, this.pipeToFinished = !1;
}
@@ -820,47 +821,47 @@ class fs {
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 ys() {
+function _s() {
this.stream._duplexState |= 512, this.updateCallback();
}
-function _s(s) {
+function Ss(i) {
const t = this.stream;
- 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();
+ i && t.destroy(i), t._duplexState & nt || (t._duplexState |= cn, t.emit("finish")), (t._duplexState & un) === ln && (t._duplexState |= 4), t._duplexState &= 402391039, t._duplexState & wt ? this.updateNextTick() : this.update();
}
-function yn(s) {
+function pn(i) {
const t = this.stream;
- s || this.error === re || (s = this.error), s && t.emit("error", s), t._duplexState |= 8, t.emit("close");
+ i || this.error === ie || (i = this.error), i && t.emit("error", i), 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) {
+ if (e !== null && e.pipeline !== null && e.pipeline.done(t, i), n !== null) {
for (; n.drains !== null && n.drains.length > 0; ) n.drains.shift().resolve(!1);
- n.pipeline !== null && n.pipeline.done(t, s);
+ n.pipeline !== null && n.pipeline.done(t, i);
}
}
-function Ss(s) {
+function ws(i) {
const t = this.stream;
- s && t.destroy(s), t._duplexState &= ln, this.drains !== null && function(e) {
+ i && t.destroy(i), t._duplexState &= 469499903, 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 & Jt) === Jt && t.emit("drain")), this.updateCallback();
+ }(this.drains), (6553615 & t._duplexState) === hs && (t._duplexState &= 532676607, (t._duplexState & Jt) === Jt && t.emit("drain")), 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 bs() {
- 32 & this.stream._duplexState || (this.stream._duplexState &= an, this.update());
+function bs(i) {
+ i && this.stream.destroy(i), this.stream._duplexState &= rs, this.readAhead !== !1 || this.stream._duplexState & rn || (this.stream._duplexState &= an), this.updateCallback();
}
function Cs() {
- this.stream._duplexState & wt || (this.stream._duplexState &= un, this.update());
+ 32 & this.stream._duplexState || (this.stream._duplexState &= on, this.update());
}
-function _n(s) {
+function vs() {
+ this.stream._duplexState & wt || (this.stream._duplexState &= dn, this.update());
+}
+function fn(i) {
const t = this.stream;
- 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();
+ i && t.destroy(i), 4 & t._duplexState || (17423 & t._duplexState || (t._duplexState |= sn), 142606351 & t._duplexState || (t._duplexState |= hn), t.emit("open")), t._duplexState &= us, t._writableState !== null && t._writableState.updateCallback(), t._readableState !== null && t._readableState.updateCallback();
}
-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());
+function ks(i) {
+ this._readableState !== null && (i === "data" && (this._duplexState |= 133376, this._readableState.updateNextTick()), i === "readable" && (this._duplexState |= ns, this._readableState.updateNextTick())), this._writableState !== null && i === "drain" && (this._duplexState |= Jt, this._writableState.updateNextTick());
}
-class ks extends Zn {
+class Ts 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", As.bind(this))), this.on("newListener", vs);
+ 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", Rs.bind(this))), this.on("newListener", ks);
}
_open(t) {
t(null);
@@ -883,18 +884,18 @@ class ks extends Zn {
return !!(this._duplexState & nt);
}
destroy(t) {
- 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());
+ this._duplexState & nt || (t || (t = ie), 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 Ct extends ks {
+class Ct extends Ts {
constructor(t) {
- 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));
+ super(t), this._duplexState |= 8519681, this._readableState = new fs(this, t), t && (this._readableState.readAhead === !1 && (this._duplexState &= an), t.read && (this._read = t.read), t.eagerOpen && this._readableState.updateNextTick(), t.encoding && this.setEncoding(t.encoding));
}
setEncoding(t) {
- 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);
+ const e = new Xn(t), n = this._readableState.map || As;
+ return this._readableState.map = function(s) {
+ const r = e.push(s);
+ return r === "" && (s.byteLength !== 0 || e.remaining > 0) ? null : n(r);
}, this;
}
_read(t) {
@@ -920,7 +921,7 @@ class Ct extends ks {
}
static _fromAsyncIterator(t, e) {
let n;
- const i = new Ct({ ...e, read(o) {
+ const s = new Ct({ ...e, read(o) {
t.next().then(r).then(o.bind(null, null)).catch(o);
}, predestroy() {
n = t.return();
@@ -928,30 +929,30 @@ class Ct extends ks {
if (!n) return o(null);
n.then(o.bind(null, null)).catch(o);
} });
- return i;
+ return s;
function r(o) {
- o.done ? i.push(null) : i.push(o.value);
+ o.done ? s.push(null) : s.push(o.value);
}
}
static from(t, e) {
- if (Sn(n = t) && n.readable) return t;
+ if (yn(n = t) && n.readable) return t;
var n;
if (t[ot]) return this._fromAsyncIterator(t[ot](), e);
Array.isArray(t) || (t = t === void 0 ? [] : [t]);
- let i = 0;
+ let s = 0;
return new Ct({ ...e, read(r) {
- this.push(i === t.length ? null : t[i++]), r(null);
+ this.push(s === t.length ? null : t[s++]), r(null);
} });
}
static isBackpressured(t) {
return !!(17422 & t._duplexState) || t._readableState.buffered >= t._readableState.highWaterMark;
}
static isPaused(t) {
- return !(t._duplexState & on);
+ return !(t._duplexState & rn);
}
[ot]() {
const t = this;
- let e = null, n = null, i = null;
+ let e = null, n = null, s = null;
return this.on("error", (a) => {
e = a;
}), this.on("readable", function() {
@@ -961,12 +962,12 @@ class Ct extends ks {
}), { [ot]() {
return this;
}, next: () => new Promise(function(a, h) {
- n = a, i = h;
+ n = a, s = h;
const u = t.read();
u !== null ? r(u) : 8 & t._duplexState && r(null);
}), return: () => o(null), throw: (a) => o(a) };
function r(a) {
- i !== null && (e ? i(e) : a !== null || t._duplexState & St ? n({ value: a, done: a === null }) : i(re), i = n = null);
+ s !== null && (e ? s(e) : a !== null || t._duplexState & St ? n({ value: a, done: a === null }) : s(ie), s = n = null);
}
function o(a) {
return t.destroy(a), new Promise((h, u) => {
@@ -978,15 +979,15 @@ class Ct extends ks {
}
}
}
-class Ts extends Ct {
+class xs extends Ct {
constructor(t) {
- 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));
+ super(t), this._duplexState = 1 | this._duplexState & Gt, this._writableState = new ps(this, t), t && (t.writev && (this._writev = t.writev), t.write && (this._write = t.write), t.final && (this._final = t.final));
}
cork() {
- this._duplexState |= hs;
+ this._duplexState |= cs;
}
uncork() {
- this._duplexState &= ds, this._writableState.updateNextTick();
+ this._duplexState &= ls, this._writableState.updateNextTick();
}
_writev(t, e) {
e(null);
@@ -1004,76 +1005,76 @@ class Ts extends Ct {
return this._writableState.updateNextTick(), this._writableState.end(t), this;
}
}
-function xs(s) {
- return s;
+function As(i) {
+ return i;
}
-function Ls(s) {
- return !!s._readableState || !!s._writableState;
+function Ls(i) {
+ return !!i._readableState || !!i._writableState;
}
-function Sn(s) {
- return typeof s._duplexState == "number" && Ls(s);
+function yn(i) {
+ return typeof i._duplexState == "number" && Ls(i);
}
-function wn(s) {
+function _n(i) {
return function(t) {
return typeof t == "object" && t !== null && typeof t.byteLength == "number";
- }(s) ? s.byteLength : 1024;
+ }(i) ? i.byteLength : 1024;
}
-function Ie() {
+function Le() {
}
-function As() {
+function Rs() {
this.destroy(new Error("Stream aborted."));
}
-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;
+var Sn = xs;
+function Re(i, t) {
+ for (const e in t) Object.defineProperty(i, e, { value: t[e], enumerable: !0, configurable: !0 });
+ return i;
}
-const y = j(function(s, t, e) {
- if (!s || typeof s == "string") throw new TypeError("Please pass an Error to err-code");
+const y = W(function(i, t, e) {
+ if (!i || typeof i == "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 Ee(s, e);
+ return Re(i, e);
} catch {
- e.message = s.message, e.stack = s.stack;
- const i = function() {
+ e.message = i.message, e.stack = i.stack;
+ const s = function() {
};
- return i.prototype = Object.create(Object.getPrototypeOf(s)), Ee(new i(), e);
+ return s.prototype = Object.create(Object.getPrototypeOf(i)), Re(new s(), e);
}
-}), 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;
+}), vt = "0123456789abcdef", wn = [], kt = [];
+for (let i = 0; i < 256; i++) wn[i] = vt[i >> 4 & 15] + vt[15 & i], i < 16 && (i < 10 ? kt[48 + i] = i : kt[87 + i] = i);
+const V = (i) => {
+ const t = i.length;
let e = "", n = 0;
- for (; n < t; ) e += Cn[s[n++]];
+ for (; n < t; ) e += wn[i[n++]];
return e;
-}, Vt = (s) => {
- const t = s.length >> 1, e = t << 1, n = new Uint8Array(t);
- let i = 0, r = 0;
- for (; r < e; ) n[i++] = kt[s.charCodeAt(r++)] << 4 | kt[s.charCodeAt(r++)];
+}, Vt = (i) => {
+ const t = i.length >> 1, e = t << 1, n = new Uint8Array(t);
+ let s = 0, r = 0;
+ for (; r < e; ) n[s++] = kt[i.charCodeAt(r++)] << 4 | kt[i.charCodeAt(r++)];
return n;
};
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) => {
+const Ps = new TextDecoder(), bn = (i, t) => Ps.decode(i), qs = new TextEncoder(), re = (i) => qs.encode(i), Q = (i) => {
let t, e = "", n = 0;
- const i = s.length;
- for (; n < i; ) t = s.charCodeAt(n++), e += vt[t >> 4] + vt[15 & t];
+ const s = i.length;
+ for (; n < s; ) t = i.charCodeAt(n++), e += vt[t >> 4] + vt[15 & t];
return e;
-}, tt = (s) => {
- const t = Vt(s);
+}, tt = (i) => {
+ const t = Vt(i);
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;
-}, Re = typeof window < "u" ? window : self, Yt = Re.crypto || Re.msCrypto || {};
+}, Ie = typeof window < "u" ? window : self, Yt = Ie.crypto || Ie.msCrypto || {};
Yt.subtle || Yt.webkitSubtle;
-const Tt = (s) => {
- const t = new Uint8Array(s);
+const Tt = (i) => {
+ const t = new Uint8Array(i);
return Yt.getRandomValues(t);
-}, qs = A("simple-peer"), Ot = 65536;
-function Pe(s) {
- return s.replace(/a=ice-options:trickle\s\n/g, "");
+}, Bs = L("simple-peer"), Ot = 65536;
+function Ee(i) {
+ return i.replace(/a=ice-options:trickle\s\n/g, "");
}
-let et = class Kt extends bn {
+let et = class Kt extends Sn {
constructor(e) {
super(e = Object.assign({ allowHalfOpen: !1 }, e));
d(this, "_pc");
@@ -1130,9 +1131,9 @@ let et = class Kt extends bn {
}
_addIceCandidate(e) {
const n = new Jn(e);
- this._pc.addIceCandidate(n).catch((i) => {
+ this._pc.addIceCandidate(n).catch((s) => {
var r;
- !n.address || n.address.endsWith(".local") ? (r = "Ignoring unsupported ICE candidate.", console.warn(r)) : this.__destroy(y(i, "ERR_ADD_ICE_CANDIDATE"));
+ !n.address || n.address.endsWith(".local") ? (r = "Ignoring unsupported ICE candidate.", console.warn(r)) : this.__destroy(y(s, "ERR_ADD_ICE_CANDIDATE"));
});
}
send(e) {
@@ -1182,16 +1183,16 @@ let et = class Kt extends bn {
}
_setupData(e) {
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 = e.channel, this._channel.binaryType = "arraybuffer", typeof this._channel.bufferedAmountLowThreshold == "number" && (this._channel.bufferedAmountLowThreshold = Ot), this.channelName = this._channel.label, this._channel.onmessage = (s) => {
+ this._onChannelMessage(s);
}, this._channel.onbufferedamountlow = () => {
this._onChannelBufferedAmountLow();
}, this._channel.onopen = () => {
this._onChannelOpen();
}, this._channel.onclose = () => {
this._onChannelClose();
- }, 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._channel.onerror = (s) => {
+ const r = s.error instanceof Error ? s.error : new Error(`Datachannel error: ${s.message} ${s.filename}:${s.lineno}:${s.colno}`);
this.__destroy(y(r, "ERR_DATA_CHANNEL"));
};
let n = !1;
@@ -1204,8 +1205,8 @@ let et = class Kt extends bn {
if (this._connected) {
try {
this.send(e);
- } catch (i) {
- return this.__destroy(y(i, "ERR_DATA_CHANNEL"));
+ } catch (s) {
+ return this.__destroy(y(s, "ERR_DATA_CHANNEL"));
}
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;
@@ -1225,16 +1226,16 @@ let et = class Kt extends bn {
_createOffer() {
this.destroyed || this._pc.createOffer(this.offerOptions).then((e) => {
if (this.destroyed) return;
- this.trickle || this.allowHalfTrickle || (e.sdp = Pe(e.sdp)), e.sdp = this.sdpTransform(e.sdp);
+ this.trickle || this.allowHalfTrickle || (e.sdp = Ee(e.sdp)), e.sdp = this.sdpTransform(e.sdp);
const n = () => {
if (this.destroyed) return;
- const i = this._pc.localDescription || e;
- this._debug("signal"), this.emit("signal", { type: i.type, sdp: i.sdp });
+ const s = this._pc.localDescription || e;
+ this._debug("signal"), this.emit("signal", { type: s.type, sdp: s.sdp });
};
this._pc.setLocalDescription(e).then(() => {
this._debug("createOffer success"), this.destroyed || (this.trickle || this._iceComplete ? n() : this.once("_iceComplete", n));
- }).catch((i) => {
- this.__destroy(y(i, "ERR_SET_LOCAL_DESCRIPTION"));
+ }).catch((s) => {
+ this.__destroy(y(s, "ERR_SET_LOCAL_DESCRIPTION"));
});
}).catch((e) => {
this.__destroy(y(e, "ERR_CREATE_OFFER"));
@@ -1243,17 +1244,17 @@ let et = class Kt extends bn {
_createAnswer() {
this.destroyed || this._pc.createAnswer(this.answerOptions).then((e) => {
if (this.destroyed) return;
- this.trickle || this.allowHalfTrickle || (e.sdp = Pe(e.sdp)), e.sdp = this.sdpTransform(e.sdp);
+ this.trickle || this.allowHalfTrickle || (e.sdp = Ee(e.sdp)), e.sdp = this.sdpTransform(e.sdp);
const n = () => {
var r;
if (this.destroyed) return;
- 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));
+ const s = this._pc.localDescription || e;
+ this._debug("signal"), this.emit("signal", { type: s.type, sdp: s.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((i) => {
- this.__destroy(y(i, "ERR_SET_LOCAL_DESCRIPTION"));
+ }).catch((s) => {
+ this.__destroy(y(s, "ERR_SET_LOCAL_DESCRIPTION"));
});
}).catch((e) => {
this.__destroy(y(e, "ERR_CREATE_ANSWER"));
@@ -1268,35 +1269,35 @@ let et = class Kt extends bn {
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 = (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 n = (s) => (Object.prototype.toString.call(s.values) === "[object Array]" && s.values.forEach((r) => {
+ Object.assign(s, r);
+ }), s);
+ this._pc.getStats.length === 0 || this._isReactNativeWebrtc ? this._pc.getStats().then((s) => {
const r = [];
- i.forEach((o) => {
+ s.forEach((o) => {
r.push(n(o));
}), e(null, r);
- }, (i) => e(i)) : this._pc.getStats.length > 0 ? this._pc.getStats((i) => {
+ }, (s) => e(s)) : this._pc.getStats.length > 0 ? this._pc.getStats((s) => {
if (this.destroyed) return;
const r = [];
- i.result().forEach((o) => {
+ s.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, r.push(n(a));
}), e(null, r);
- }, (i) => e(i)) : e(null, []);
+ }, (s) => e(s)) : 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, i) => {
+ this.destroyed || this._destroying || this.getStats((n, s) => {
if (this.destroyed || this._destroying) return;
- n && (i = []);
+ n && (s = []);
const r = {}, o = {}, a = {};
let h = !1;
- i.forEach((c) => {
+ s.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 u = (c) => {
@@ -1306,7 +1307,7 @@ let et = class Kt extends bn {
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 (i.forEach((c) => {
+ if (s.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) {
@@ -1339,7 +1340,7 @@ let et = class Kt extends bn {
_onChannelMessage(e) {
if (this.destroyed) return;
let n = e.data;
- n instanceof ArrayBuffer ? n = new Uint8Array(n) : this.__objectMode === !1 && (n = oe(n)), this.push(n);
+ n instanceof ArrayBuffer ? n = new Uint8Array(n) : this.__objectMode === !1 && (n = re(n)), this.push(n);
}
_onChannelBufferedAmountLow() {
if (this.destroyed || !this._cb) return;
@@ -1355,15 +1356,15 @@ let et = class Kt extends bn {
}
_debug() {
const e = [].slice.call(arguments);
- e[0] = "[" + this._id + "] " + e[0], qs.apply(null, e);
+ e[0] = "[" + this._id + "] " + e[0], Bs.apply(null, e);
}
};
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: L }, Symbol.toStringTag, { value: "Module" })) }, Bs = A("simple-websocket"), Z = typeof L != "function" ? WebSocket : L;
-class kn extends bn {
+const A = {}, Zt = { DEFAULT_ANNOUNCE_PEERS: 50, MAX_ANNOUNCE_PEERS: 82, parseUrl: (i) => {
+ const t = new URL(i.replace(/^udp:/, "http:"));
+ return i.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: A }, Symbol.toStringTag, { value: "Module" })) }, Os = L("simple-websocket"), Z = typeof A != "function" ? WebSocket : A;
+class Cn extends Sn {
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");
@@ -1371,7 +1372,7 @@ class kn extends bn {
else {
this.url = t.url;
try {
- this._ws = typeof L == "function" ? new Z(t.url, { ...t, encoding: void 0 }) : new Z(t.url);
+ this._ws = typeof A == "function" ? new Z(t.url, { ...t, encoding: void 0 }) : new Z(t.url);
} catch (e) {
return void Qt(() => this.destroy(e));
}
@@ -1410,7 +1411,7 @@ class kn extends bn {
} catch (n) {
return this.destroy(n);
}
- typeof L != "function" && this._ws.bufferedAmount > 65536 ? (this._debug("start backpressure: bufferedAmount %d", this._ws.bufferedAmount), this._cb = e) : e(null);
+ typeof A != "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() {
@@ -1425,13 +1426,13 @@ class kn extends bn {
const t = this._cb;
this._cb = null, t(null);
}
- typeof L != "function" && (this._interval = setInterval(() => this._onInterval(), 150), this._interval.unref && this._interval.unref()), this._debug("connect"), this.emit("connect");
+ typeof A != "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 = oe(e)), this.push(e);
+ e instanceof ArrayBuffer && (e = new Uint8Array(e)), this.__objectMode === !1 && (e = re(e)), this.push(e);
}
_handleClose() {
this.destroyed || (this._debug("on close"), this.destroy());
@@ -1454,11 +1455,11 @@ class kn extends bn {
}
_debug() {
const t = [].slice.call(arguments);
- t[0] = "[" + this._id + "] " + t[0], Bs.apply(null, t);
+ t[0] = "[" + this._id + "] " + t[0], Os.apply(null, t);
}
}
-kn.WEBSOCKET_SUPPORT = !!Z;
-class Os extends Ze {
+Cn.WEBSOCKET_SUPPORT = !!Z;
+class Ds extends Ke {
constructor(t, e) {
super(), this.client = t, this.announceUrl = e, this.interval = null, this.destroyed = !1;
}
@@ -1468,8 +1469,8 @@ class Os extends Ze {
}, t), this.interval.unref && this.interval.unref());
}
}
-const T = A("bittorrent-tracker:websocket-tracker"), E = {};
-class Xt extends Os {
+const T = L("bittorrent-tracker:websocket-tracker"), I = {};
+class Xt extends Ds {
constructor(t, e) {
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();
}
@@ -1482,8 +1483,8 @@ class Xt extends Os {
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, (i) => {
- e.numwant = n, e.offers = i, this._send(e);
+ this._generateOffers(n, (s) => {
+ e.numwant = n, e.offers = s, this._send(e);
});
}
}
@@ -1495,20 +1496,20 @@ class Xt extends Os {
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 = qe) {
+ destroy(t = Pe) {
if (this.destroyed) return t(null);
this.destroyed = !0, clearInterval(this.interval), clearTimeout(this.reconnectTimer);
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, 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;
+ 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, I[this.announceUrl] && (I[this.announceUrl].consumers -= 1), I[this.announceUrl].consumers > 0) return t();
+ let e, n = I[this.announceUrl];
+ if (delete I[this.announceUrl], n.on("error", Pe), n.once("close", t), !this.expectingResponse) return s();
+ function s() {
+ e && (clearTimeout(e), e = null), n.removeListener("data", s), n.destroy(), n = null;
}
- e = setTimeout(i, Zt.DESTROY_TIMEOUT), n.once("data", i);
+ e = setTimeout(s, Zt.DESTROY_TIMEOUT), n.once("data", s);
}
_openSocket() {
if (this.destroyed = !1, this.peers || (this.peers = {}), this._onSocketConnectBound = () => {
@@ -1519,11 +1520,11 @@ class Xt extends Os {
this._onSocketData(t);
}, this._onSocketCloseBound = () => {
this._onSocketClose();
- }, this.socket = E[this.announceUrl], this.socket) E[this.announceUrl].consumers += 1, this.socket.connected && this._onSocketConnectBound();
+ }, this.socket = I[this.announceUrl], this.socket) I[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 = E[this.announceUrl] = new kn({ 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 = I[this.announceUrl] = new Cn({ 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);
}
@@ -1534,7 +1535,7 @@ class Xt extends Os {
if (!this.destroyed) {
this.expectingResponse = !1;
try {
- t = JSON.parse(vn(t));
+ t = JSON.parse(bn(t));
} catch {
return void this.client.emit("warning", new Error("Invalid tracker response"));
}
@@ -1542,35 +1543,35 @@ class Xt extends Os {
}
}
_onAnnounceResponse(t) {
- 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.info_hash !== this.client._infoHashBinary) return void T("ignoring websocket data from %s for %s (looking for %s: reused socket)", this.announceUrl, Q(t.info_hash), this.client.infoHash);
if (t.peer_id && t.peer_id === this.client._peerIdBinary) return;
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 i = t.interval || t["min interval"];
- i && this.setInterval(1e3 * i);
+ const s = t.interval || t["min interval"];
+ s && this.setInterval(1e3 * s);
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) });
+ const a = Object.assign({}, t, { announce: this.announceUrl, infoHash: Q(t.info_hash) });
this.client.emit("update", a);
}
let o;
- 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) => {
+ if (t.offer && t.peer_id && (T("creating peer (from remote offer)"), o = this._createPeer(), o.id = Q(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 = 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)}`);
+ const a = Q(t.offer_id);
+ o = this.peers[a], o ? (o.id = Q(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 i = Object.assign(t[n], { announce: this.announceUrl, infoHash: W(n) });
- this.client.emit("scrape", i);
+ const s = Object.assign(t[n], { announce: this.announceUrl, infoHash: Q(n) });
+ this.client.emit("scrape", s);
}) : this.client.emit("warning", new Error("invalid scrape response"));
}
_onSocketClose() {
@@ -1592,7 +1593,7 @@ class Xt extends Os {
T("send %s", e), this.socket.send(e);
}
_generateOffers(t, e) {
- const n = this, i = [];
+ const n = this, s = [];
T("generating %s offers", t);
for (let a = 0; a < t; ++a) r();
function r() {
@@ -1600,13 +1601,13 @@ class Xt extends Os {
T("creating peer (from _generateOffers)");
const h = n.peers[a] = n._createPeer({ initiator: !0 });
h.once("signal", (u) => {
- i.push({ offer: u, offer_id: tt(a) }), o();
+ s.push({ offer: u, offer_id: tt(a) }), o();
}), h.trackerTimeout = setTimeout(() => {
T("tracker timeout: destroying peer"), h.trackerTimeout = null, delete n.peers[a], h.destroy();
}, 5e4), h.trackerTimeout.unref && h.trackerTimeout.unref();
}
function o() {
- i.length === t && (T("generated %s offers", t), e(i));
+ s.length === t && (T("generated %s offers", t), e(s));
}
o();
}
@@ -1614,19 +1615,19 @@ class Xt extends Os {
const e = this;
t = Object.assign({ trickle: !1, config: e.client._rtcConfig, wrtc: e.client._wrtc }, t);
const n = new et(t);
- return n.once("error", i), n.once("connect", function r() {
- n.removeListener("error", i), n.removeListener("connect", r);
+ return n.once("error", s), n.once("connect", function r() {
+ n.removeListener("error", s), n.removeListener("connect", r);
}), n;
- function i(r) {
+ function s(r) {
e.client.emit("warning", new Error(`Connection error: ${r.message}`)), n.destroy();
}
}
}
-function qe() {
+function Pe() {
}
-Xt.prototype.DEFAULT_ANNOUNCE_INTERVAL = 3e4, Xt._socketPool = E;
-const M = A("bittorrent-tracker:client");
-class te extends Ze {
+Xt.prototype.DEFAULT_ANNOUNCE_INTERVAL = 3e4, Xt._socketPool = I;
+const M = L("bittorrent-tracker:client");
+class te extends Ke {
constructor(t = {}) {
if (super(), !t.peerId) throw new Error("Option `peerId` is required");
if (!t.infoHash) throw new Error("Option `infoHash` is required");
@@ -1634,8 +1635,8 @@ class te extends Ze {
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((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) => {
+ e = e.map((r) => (ArrayBuffer.isView(r) && (r = bn(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), s = (r) => {
Qt(() => {
this.emit("warning", r);
});
@@ -1645,12 +1646,12 @@ class te extends Ze {
try {
o = Zt.parseUrl(r);
} catch {
- return i(new Error(`Invalid tracker URL: ${r}`)), null;
+ return s(new Error(`Invalid tracker URL: ${r}`)), null;
}
const a = o.port;
- if (a < 0 || a > 65535) return i(new Error(`Invalid tracker port: ${r}`)), null;
+ if (a < 0 || a > 65535) return s(new Error(`Invalid tracker port: ${r}`)), null;
const h = o.protocol;
- 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);
+ return h !== "http:" && h !== "https:" || typeof A != "function" ? h === "udp:" && typeof A == "function" ? new A(this, r) : h !== "ws:" && h !== "wss:" || !n || h === "ws:" && typeof window < "u" && window.location.protocol === "https:" ? (s(new Error(`Unsupported tracker protocol: ${r}`)), null) : new Xt(this, r) : new A(this, r);
}).filter(Boolean);
}
start(t) {
@@ -1685,8 +1686,8 @@ class te extends Ze {
destroy(t) {
if (this.destroyed) return;
this.destroyed = !0, M("destroy");
- const e = this._trackers.map((n) => (i) => {
- n.destroy(i);
+ const e = this._trackers.map((n) => (s) => {
+ n.destroy(s);
});
zn(e, t), this._trackers = [], this._getAnnounceOpts = null;
}
@@ -1694,194 +1695,194 @@ class te extends Ze {
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;
}
}
-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: oe("01234567890123456789"), port: 6881 }), n = new te(e);
+te.scrape = (i, t) => {
+ if (t = jn(t), !i.infoHash) throw new Error("Option `infoHash` is required");
+ if (!i.announce) throw new Error("Option `announce` is required");
+ const e = Object.assign({}, i, { infoHash: Array.isArray(i.infoHash) ? i.infoHash[0] : i.infoHash, peerId: re("01234567890123456789"), port: 6881 }), n = new te(e);
n.once("error", t), n.once("warning", t);
- let i = Array.isArray(s.infoHash) ? s.infoHash.length : 1;
+ let s = Array.isArray(i.infoHash) ? i.infoHash.length : 1;
const r = {};
return n.on("scrape", (o) => {
- if (i -= 1, r[o.infoHash] = o, i === 0) {
+ if (s -= 1, r[o.infoHash] = o, s === 0) {
n.destroy();
const a = Object.keys(r);
a.length === 1 ? t(null, r[a[0]]) : t(null, r);
}
- }), n.scrape({ infoHash: s.infoHash }), n;
+ }), n.scrape({ infoHash: i.infoHash }), n;
};
-var Tn = { exports: {} };
-function S(s, t, e, n, i, r, o) {
- var a = s + (t & e | ~t & n) + (i >>> 0) + o;
+var vn = { exports: {} };
+function S(i, t, e, n, s, r, o) {
+ var a = i + (t & e | ~t & n) + (s >>> 0) + o;
return (a << r | a >>> 32 - r) + t;
}
-function w(s, t, e, n, i, r, o) {
- var a = s + (t & n | e & ~n) + (i >>> 0) + o;
+function w(i, t, e, n, s, r, o) {
+ var a = i + (t & n | e & ~n) + (s >>> 0) + o;
return (a << r | a >>> 32 - r) + t;
}
-function b(s, t, e, n, i, r, o) {
- var a = s + (t ^ e ^ n) + (i >>> 0) + o;
+function b(i, t, e, n, s, r, o) {
+ var a = i + (t ^ e ^ n) + (s >>> 0) + o;
return (a << r | a >>> 32 - r) + t;
}
-function C(s, t, e, n, i, r, o) {
- var a = s + (e ^ (t | ~n)) + (i >>> 0) + o;
+function C(i, t, e, n, s, r, o) {
+ var a = i + (e ^ (t | ~n)) + (s >>> 0) + o;
return (a << r | a >>> 32 - r) + t;
}
-function ht(s) {
- return String.fromCharCode(255 & s);
+function ht(i) {
+ return String.fromCharCode(255 & i);
}
-function ct(s) {
- return ht(s) + ht(s >>> 8) + ht(s >>> 16) + ht(s >>> 24);
+function ct(i) {
+ return ht(i) + ht(i >>> 8) + ht(i >>> 16) + ht(i >>> 24);
}
-var ee = function(s) {
- return unescape(encodeURIComponent(s));
-}, It = Tn.exports = function(s) {
- return Ds(s).toHex();
-}, _t = It.fromBytes = function(s) {
+var ee = function(i) {
+ return unescape(encodeURIComponent(i));
+}, Rt = vn.exports = function(i) {
+ return Ms(i).toHex();
+}, _t = Rt.fromBytes = function(i) {
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;
+ for (var f = m.length, v = f << 3, H = new Uint32Array(f + 72 >>> 6 << 4), D = 0, Et = m.length; D < Et; ++D) H[D >>> 2] |= m.charCodeAt(D) << ((3 & D) << 3);
+ return H[f >> 2] |= 128 << (31 & v), H[H.length - 2] = v, H;
+ }(i), e = 1732584193, n = 4023233417, s = 2562383102, r = 271733878, o = 0, a = t.length; o < a; o += 16) {
+ var h = e, u = n, c = s, l = r;
+ e = S(e, n, s, r, t[o + 0], 7, 3614090360), r = S(r, e, n, s, t[o + 1], 12, 3905402710), s = S(s, r, e, n, t[o + 2], 17, 606105819), n = S(n, s, r, e, t[o + 3], 22, 3250441966), e = S(e, n, s, r, t[o + 4], 7, 4118548399), r = S(r, e, n, s, t[o + 5], 12, 1200080426), s = S(s, r, e, n, t[o + 6], 17, 2821735955), n = S(n, s, r, e, t[o + 7], 22, 4249261313), e = S(e, n, s, r, t[o + 8], 7, 1770035416), r = S(r, e, n, s, t[o + 9], 12, 2336552879), s = S(s, r, e, n, t[o + 10], 17, 4294925233), n = S(n, s, r, e, t[o + 11], 22, 2304563134), e = S(e, n, s, r, t[o + 12], 7, 1804603682), r = S(r, e, n, s, t[o + 13], 12, 4254626195), s = S(s, r, e, n, t[o + 14], 17, 2792965006), e = w(e, n = S(n, s, r, e, t[o + 15], 22, 1236535329), s, r, t[o + 1], 5, 4129170786), r = w(r, e, n, s, t[o + 6], 9, 3225465664), s = w(s, r, e, n, t[o + 11], 14, 643717713), n = w(n, s, r, e, t[o + 0], 20, 3921069994), e = w(e, n, s, r, t[o + 5], 5, 3593408605), r = w(r, e, n, s, t[o + 10], 9, 38016083), s = w(s, r, e, n, t[o + 15], 14, 3634488961), n = w(n, s, r, e, t[o + 4], 20, 3889429448), e = w(e, n, s, r, t[o + 9], 5, 568446438), r = w(r, e, n, s, t[o + 14], 9, 3275163606), s = w(s, r, e, n, t[o + 3], 14, 4107603335), n = w(n, s, r, e, t[o + 8], 20, 1163531501), e = w(e, n, s, r, t[o + 13], 5, 2850285829), r = w(r, e, n, s, t[o + 2], 9, 4243563512), s = w(s, r, e, n, t[o + 7], 14, 1735328473), e = b(e, n = w(n, s, r, e, t[o + 12], 20, 2368359562), s, r, t[o + 5], 4, 4294588738), r = b(r, e, n, s, t[o + 8], 11, 2272392833), s = b(s, r, e, n, t[o + 11], 16, 1839030562), n = b(n, s, r, e, t[o + 14], 23, 4259657740), e = b(e, n, s, r, t[o + 1], 4, 2763975236), r = b(r, e, n, s, t[o + 4], 11, 1272893353), s = b(s, r, e, n, t[o + 7], 16, 4139469664), n = b(n, s, r, e, t[o + 10], 23, 3200236656), e = b(e, n, s, r, t[o + 13], 4, 681279174), r = b(r, e, n, s, t[o + 0], 11, 3936430074), s = b(s, r, e, n, t[o + 3], 16, 3572445317), n = b(n, s, r, e, t[o + 6], 23, 76029189), e = b(e, n, s, r, t[o + 9], 4, 3654602809), r = b(r, e, n, s, t[o + 12], 11, 3873151461), s = b(s, r, e, n, t[o + 15], 16, 530742520), e = C(e, n = b(n, s, r, e, t[o + 2], 23, 3299628645), s, r, t[o + 0], 6, 4096336452), r = C(r, e, n, s, t[o + 7], 10, 1126891415), s = C(s, r, e, n, t[o + 14], 15, 2878612391), n = C(n, s, r, e, t[o + 5], 21, 4237533241), e = C(e, n, s, r, t[o + 12], 6, 1700485571), r = C(r, e, n, s, t[o + 3], 10, 2399980690), s = C(s, r, e, n, t[o + 10], 15, 4293915773), n = C(n, s, r, e, t[o + 1], 21, 2240044497), e = C(e, n, s, r, t[o + 8], 6, 1873313359), r = C(r, e, n, s, t[o + 15], 10, 4264355552), s = C(s, r, e, n, t[o + 6], 15, 2734768916), n = C(n, s, r, e, t[o + 13], 21, 1309151649), e = C(e, n, s, r, t[o + 4], 6, 4149444226), r = C(r, e, n, s, t[o + 11], 10, 3174756917), s = C(s, r, e, n, t[o + 2], 15, 718787259), n = C(n, s, r, e, t[o + 9], 21, 3951481745), e = e + h >>> 0, n = n + u >>> 0, s = s + c >>> 0, r = r + l >>> 0;
}
- var g = new String(ct(e) + ct(n) + ct(i) + ct(r));
+ var g = new String(ct(e) + ct(n) + ct(s) + 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);
+}, Ms = Rt.fromUtf8 = function(i) {
+ return _t(ee(i));
+}, kn = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+function qe(i, t) {
+ for (var e = ""; --t >= 0; i >>>= 6) e += kn.charAt(63 & i);
return e;
}
-var dt = [0, 6, 12, 1, 7, 13, 2, 8, 14, 3, 9, 15, 4, 10, 5, 11], Ms = It.salt = function(s) {
+var dt = [0, 6, 12, 1, 7, 13, 2, 8, 14, 3, 9, 15, 4, 10, 5, 11], Ns = Rt.salt = function(i) {
var t = "";
- s || (s = 8);
+ i || (i = 8);
do
- t += xn.charAt(64 * Math.random() >>> 0);
- while (--s);
+ t += kn.charAt(64 * Math.random() >>> 0);
+ while (--i);
return t;
};
-It.crypt = function(s, t) {
- if (s.length > 64) throw Error("too long key");
- 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));
+Rt.crypt = function(i, t) {
+ if (i.length > 64) throw Error("too long key");
+ t || (t = "$1$" + Ns()), i = ee(i);
+ for (var e = ee(t.replace(/^\$1\$([^$]+)(?:\$.*)?$/, "$1")), n = _t(i + e + i), s = i + "$1$" + e, r = i.length; r > 16; r -= 16) s += n;
+ for (s += n.slice(0, r), r = i.length; r; r >>= 1) s += 1 & r ? "\0" : i.charAt(0);
+ n = _t(s);
+ for (var o = 0; o < 1e3; ++o) n = _t((1 & o ? i : n) + (o % 3 ? e : "") + (o % 7 ? i : "") + (1 & o ? n : i));
var a = "$1$" + e + "$";
- 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);
+ for (o = 0; o < 15; o += 3) a += qe(n.charCodeAt(dt[o + 0]) << 16 | n.charCodeAt(dt[o + 1]) << 8 | n.charCodeAt(dt[o + 2]), 4);
+ return a + qe(n.charCodeAt(dt[15]), 2);
};
-const Ns = j(Tn.exports), Fs = `-PM${function(s) {
- const t = s.split(".");
+const Us = W(vn.exports), Fs = `-PM${function(i) {
+ const t = i.split(".");
return `${t[0].padStart(2, "0")}${t[1].padStart(2, "0")}`;
-}("2.0.1")}-`, Us = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-function $(s) {
- return `${s.type}-${s.index}`;
+}("2.1.0")}-`, Hs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+function F(i) {
+ return `${i.type}-${i.index}`;
}
-function Oe(s) {
- const { externalId: t } = s;
- return `(${$(s.stream)} | ${t})`;
+function Be(i) {
+ const { externalId: t } = i;
+ return `(${F(i.stream)} | ${t})`;
}
-function ne(s, t) {
- t === void 0 && (t = s.reduce((i, r) => i + r.byteLength, 0));
+function Tn(i, t) {
+ t === void 0 && (t = i.reduce((s, r) => s + r.byteLength, 0));
const e = new Uint8Array(t);
let n = 0;
- for (const i of s) e.set(i, n), n += i.byteLength;
+ for (const s of i) e.set(s, n), n += s.byteLength;
return e;
}
-function De(s) {
- const t = new TextEncoder(), e = new Uint8Array(s.length);
- return t.encodeInto(s, e), e;
+function Oe(i) {
+ const t = new TextEncoder(), e = new Uint8Array(i.length);
+ return t.encodeInto(i, e), e;
}
-function* Me(s) {
- for (let t = s.length - 1; t >= 0; t--) yield s[t];
+function* De(i) {
+ for (let t = i.length - 1; t >= 0; t--) yield i[t];
}
-function Ln(s) {
- return !!s && typeof s == "object" && !Array.isArray(s);
+function xn(i) {
+ return !!i && typeof i == "object" && !Array.isArray(i);
}
-function G(s) {
+function U(i) {
if (function(t) {
return Array.isArray(t);
- }(s)) return s.map((t) => G(t));
- if (Ln(s)) {
+ }(i)) return i.map((t) => U(t));
+ if (xn(i)) {
const t = {};
- for (const e of Object.keys(s)) t[e] = G(s[e]);
+ for (const e of Object.keys(i)) t[e] = U(i[e]);
return t;
}
- return s;
+ return i;
}
-function K(s, t, e = {}) {
- return typeof s != "object" || s === null || typeof t != "object" || t === null || Object.keys(t).forEach((n) => {
+function K(i, t, e = {}) {
+ return typeof i != "object" || i === 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 i = t[n], r = e[n];
- n in s && (s[n] = i === void 0 ? r === void 0 ? void 0 : r : i);
- }), s;
+ const s = t[n], r = e[n];
+ n in i && (i[n] = s === void 0 ? r === void 0 ? void 0 : r : s);
+ }), i;
}
-function Dt(s) {
- const { defaultConfig: t, baseConfig: e = {}, specificStreamConfig: n = {} } = s, i = G({ ...t, ...e, ...n }), r = Object.keys(t), o = {};
+function Dt(i) {
+ const { defaultConfig: t, baseConfig: e = {}, specificStreamConfig: n = {} } = i, s = U({ ...t, ...e, ...n }), r = Object.keys(t), o = {};
return r.forEach((a) => {
- a in i && (o[a] = i[a]);
+ a in s && (o[a] = s[a]);
}), o;
}
-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) {
+var N = ((i) => (i[i.SegmentsAnnouncement = 0] = "SegmentsAnnouncement", i[i.SegmentRequest = 1] = "SegmentRequest", i[i.SegmentData = 2] = "SegmentData", i[i.SegmentDataSendingCompleted = 3] = "SegmentDataSendingCompleted", i[i.SegmentAbsent = 4] = "SegmentAbsent", i[i.CancelSegmentRequest = 5] = "CancelSegmentRequest", i))(N || {}), J = ((i) => (i[i.Min = -1] = "Min", i[i.Int = 0] = "Int", i[i.SimilarIntArray = 1] = "SimilarIntArray", i[i.String = 2] = "String", i[i.Max = 3] = "Max", i))(J || {});
+function $s(i) {
+ const t = i < 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), i = BigInt(e);
- s = function(r) {
+ }(i), n = new Uint8Array(e), s = BigInt(e);
+ i = function(r) {
return r < 0 ? -r : r;
- }(s);
+ }(i);
for (let r = 0; r < e; r++) {
- const o = s >> 8n * (i - 1n - BigInt(r)) & 0xffn;
+ const o = i >> 8n * (s - 1n - BigInt(r)) & 0xffn;
n[r] = Number(o);
}
return t && (n[0] = 128 | n[0]), n;
}
-function $s(s) {
- const t = BigInt(s.length), e = (i, r) => {
+function js(i) {
+ const t = BigInt(i.length), e = (s, r) => {
const o = 8n * (t - 1n - BigInt(r));
- return BigInt(i) << o;
+ return BigInt(s) << o;
};
- let n = e(127 & s[0], 0);
- for (let i = 1; i < t; i++) n = e(s[i], i) | n;
- return (128 & s[0]) >> 7 && (n = -n), n;
+ let n = e(127 & i[0], 0);
+ for (let s = 1; s < t; s++) n = e(i[s], s) | n;
+ return (128 & i[0]) >> 7 && (n = -n), n;
}
-function Ne(s) {
- const t = Hs(s), e = 0 | t.length;
+function Me(i) {
+ const t = $s(i), e = 0 | t.length;
return new Uint8Array([e, ...t]);
}
-function An(s) {
- const t = s[0];
+function An(i) {
+ const t = i[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: $s(s.slice(1, n)), byteLength: e + 1 };
+ return { number: js(i.slice(1, n)), byteLength: e + 1 };
}
-function js(s) {
- const [t, e] = s;
+function Ws(i) {
+ const [t, e] = i;
if (t >> 4 !== 1) throw new Error("Trying to deserialize similar int array with invalid serialized item code");
let n = 2;
- const i = [];
+ const s = [];
for (let r = 0; r < e; r++) {
- const { number: o, byteLength: a } = An(s.slice(n));
+ const { number: o, byteLength: a } = An(i.slice(n));
n += a;
const h = 0xffn & o, u = -256n & o;
for (let c = 0; c < h; c++) {
- const l = BigInt(s[n]);
- i.push(u | l), n++;
+ const l = BigInt(i[n]);
+ s.push(u | l), n++;
}
}
- return { numbers: i, byteLength: n };
+ return { numbers: s, byteLength: n };
}
-function Ws(s) {
- const [t, e] = s;
+function Qs(i) {
+ const [t, e] = i;
if (t >> 4 !== 2) throw new Error("Trying to deserialize bytes (sting) with invalid serialized item code.");
- const n = (15 & t) << 8 | e, i = s.slice(2, n + 2);
- return { string: new TextDecoder("utf8").decode(i), byteLength: n + 2 };
+ const n = (15 & t) << 8 | e, s = i.slice(2, n + 2);
+ return { string: new TextDecoder("utf8").decode(s), byteLength: n + 2 };
}
class X {
constructor() {
@@ -1902,23 +1903,23 @@ class X {
return this.bytes;
}
getBuffer() {
- return ne(this.bytes, this._length);
+ return Tn(this.bytes, this._length);
}
get length() {
return this._length;
}
}
-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));
+const Y = It("cstr", 4), st = It("cend", 4), ne = It("dstr", 4), se = It("dend", 4), zs = [Y, ne], Gs = [st, se], Ne = Y.length + st.length;
+function Ln(i) {
+ const { length: t } = Y, e = i.slice(-t);
+ return zs.some((n) => At(i, n, 4)) && Gs.some((n) => At(e, n, 4));
}
class xt extends Error {
constructor(t) {
super(), this.type = t;
}
}
-class En {
+class Rn {
constructor(t) {
d(this, "chunks", new X());
d(this, "status", "joining");
@@ -1926,11 +1927,11 @@ class En {
}
addCommandChunk(t) {
if (this.status === "completed") return;
- const e = Lt(t, Y, 4);
+ const e = At(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 Lt(n.slice(-4), st, 4);
+ return At(n.slice(-4), st, 4);
}(t) && (this.status = "completed", this.onComplete(this.chunks.getBuffer()));
}
unframeCommandChunk(t) {
@@ -1946,14 +1947,14 @@ class lt {
}
addInteger(t, e) {
this.bytes.push(t.charCodeAt(0));
- const n = Ne(BigInt(e));
+ const n = Me(BigInt(e));
this.bytes.push(n);
}
addSimilarIntArr(t, e) {
this.bytes.push(t.charCodeAt(0));
- const n = function(i) {
+ const n = function(s) {
const r = /* @__PURE__ */ new Map();
- for (const a of i) {
+ for (const a of s) {
const h = -256n & a, u = 0xffn & a, c = r.get(h) ?? new X();
c.length || r.set(h, c), c.push(Number(u));
}
@@ -1961,17 +1962,17 @@ class lt {
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());
+ h.unshift(Me(c)), o.push(h.getBuffer());
}
return o.getBuffer();
- }(e.map((i) => BigInt(i)));
+ }(e.map((s) => BigInt(s)));
this.bytes.push(n);
}
addString(t, e) {
this.bytes.push(t.charCodeAt(0));
- 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();
+ const n = function(s) {
+ const { length: r } = s, o = new X();
+ return o.push([32 | r >> 8 & 15, 255 & r]), o.push(new TextEncoder().encode(s)), o.getBuffer();
}(e);
this.bytes.push(n);
}
@@ -1980,104 +1981,104 @@ class lt {
if (this.status === "completed") return;
this.status = "completed";
const t = this.bytes.getBuffer();
- if (t.length + Fe <= this.maxChunkLength) return void this.resultBuffers.push(ut(t, Y, st));
+ if (t.length + Ne <= this.maxChunkLength) return void this.resultBuffers.push(ut(t, Y, st));
let e = Math.ceil(t.length / this.maxChunkLength);
- Math.ceil(t.length / e) + Fe > this.maxChunkLength && e++;
- for (const [n, i] of function* (r, o) {
+ Math.ceil(t.length / e) + Ne > this.maxChunkLength && e++;
+ for (const [n, s] 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));
+ }(t, e)) n === 0 ? this.resultBuffers.push(ut(s, Y, se)) : n === e - 1 ? this.resultBuffers.push(ut(s, ne, st)) : this.resultBuffers.push(ut(s, ne, se));
}
getResultBuffers() {
if (this.status === "creating" || !this.resultBuffers.length) throw new Error("Command is not complete.");
return this.resultBuffers;
}
}
-function Rn(s) {
- const [t] = s, e = { c: t };
+function In(i) {
+ const [t] = i, e = { c: t };
let n = 1;
- for (; n < s.length; ) {
- const i = String.fromCharCode(s[n]);
- switch (n++, Gs(s[n])) {
+ for (; n < i.length; ) {
+ const s = String.fromCharCode(i[n]);
+ switch (n++, Js(i[n])) {
case J.Int:
{
- const { number: r, byteLength: o } = An(s.slice(n));
- e[i] = Number(r), n += o;
+ const { number: r, byteLength: o } = An(i.slice(n));
+ e[s] = Number(r), n += o;
}
break;
case J.SimilarIntArray:
{
- const { numbers: r, byteLength: o } = js(s.slice(n));
- e[i] = r.map((a) => Number(a)), n += o;
+ const { numbers: r, byteLength: o } = Ws(i.slice(n));
+ e[s] = r.map((a) => Number(a)), n += o;
}
break;
case J.String: {
- const { string: r, byteLength: o } = Ws(s.slice(n));
- e[i] = r, n += o;
+ const { string: r, byteLength: o } = Qs(i.slice(n));
+ e[s] = r, n += o;
}
}
}
return e;
}
-function Gs(s) {
- const t = s >> 4;
+function Js(i) {
+ const t = i >> 4;
if (t <= J.Min || t >= J.Max) throw new Error("Not existing type");
return t;
}
-function Et(s, t) {
- if (s.length !== t) throw new Error("Wrong string length");
+function It(i, t) {
+ if (i.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);
+ for (let n = 0; n < i.length; n++) e[n] = i.charCodeAt(n);
return 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 ut(i, t, e) {
+ const n = new Uint8Array(i.length + t.length + e.length);
+ return n.set(t), n.set(i, t.length), n.set(e, t.length + i.length), n;
}
-function Lt(s, t, e) {
- for (let n = 0; n < e; n++) if (s[n] !== t[n]) return !1;
+function At(i, t, e) {
+ for (let n = 0; n < e; n++) if (i[n] !== t[n]) return !1;
return !0;
}
-function Pn(s, t) {
- switch (s.c) {
+function En(i, t) {
+ switch (i.c) {
case N.CancelSegmentRequest:
case N.SegmentAbsent:
case N.SegmentDataSendingCompleted:
return function(e, n) {
- const i = new lt(e.c, n);
- return i.addInteger("i", e.i), i.addInteger("r", e.r), i.complete(), i.getResultBuffers();
- }(s, t);
+ const s = new lt(e.c, n);
+ return s.addInteger("i", e.i), s.addInteger("r", e.r), s.complete(), s.getResultBuffers();
+ }(i, t);
case N.SegmentRequest:
return function(e, n) {
- 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);
+ const s = new lt(e.c, n);
+ return s.addInteger("i", e.i), s.addInteger("r", e.r), e.b && s.addInteger("b", e.b), s.complete(), s.getResultBuffers();
+ }(i, t);
case N.SegmentsAnnouncement:
return function(e, n) {
- const { c: i, p: r, l: o } = e, a = new lt(i, n);
+ const { c: s, p: r, l: o } = e, a = new lt(s, n);
return o != null && o.length && a.addSimilarIntArr("l", o), r != null && r.length && a.addSimilarIntArr("p", r), a.complete(), a.getResultBuffers();
- }(s, t);
+ }(i, t);
case N.SegmentData:
return function(e, n) {
- 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 s = new lt(e.c, n);
+ return s.addInteger("i", e.i), s.addInteger("s", e.s), s.addInteger("r", e.r), s.complete(), s.getResultBuffers();
+ }(i, t);
}
}
-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) {
+const Vs = Object.freeze(Object.defineProperty({ __proto__: null, BinaryCommandChunksJoiner: Rn, BinaryCommandJoiningError: xt, PeerCommandType: N, deserializeCommand: In, isCommandChunk: Ln, serializePeerCommand: En }, Symbol.toStringTag, { value: "Module" }));
+class Ys {
+ constructor(t, e, n, s) {
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));
+ Ln(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 = i.getEventDispatcher("onChunkDownloaded"), this.onChunkUploaded = i.getEventDispatcher("onChunkUploaded"), t.on("data", this.onDataReceived);
+ this.connection = t, this.peerConfig = e, this.eventHandlers = n, this.onChunkDownloaded = s.getEventDispatcher("onChunkDownloaded"), this.onChunkUploaded = s.getEventDispatcher("onChunkUploaded"), t.on("data", this.onDataReceived);
}
sendCommand(t) {
- const e = Pn(t, this.peerConfig.webRtcMaxMessageSize);
+ const e = En(t, this.peerConfig.webRtcMaxMessageSize);
for (const n of e) this.connection.write(n);
}
stopUploadingSegmentData() {
@@ -2096,7 +2097,7 @@ class Vs {
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: i, resolve: r, reject: o } = function() {
+ }(t, this.peerConfig.webRtcMaxMessageSize), { promise: s, resolve: r, reject: o } = function() {
let c, l;
return { promise: new Promise((g, m) => {
c = g, l = m;
@@ -2120,15 +2121,15 @@ class Vs {
else o();
};
try {
- this.connection.on("drain", u), a = !0, u(), await i;
+ this.connection.on("drain", u), a = !0, u(), await s;
} finally {
this.connection.off("drain", u), this.uploadingContext === h && (this.uploadingContext = void 0);
}
}
receivingCommandBytes(t) {
- this.commandChunks || (this.commandChunks = new En((e) => {
+ this.commandChunks || (this.commandChunks = new Rn((e) => {
this.commandChunks = void 0;
- const n = Rn(e);
+ const n = In(e);
this.eventHandlers.onCommandReceived(n);
}));
try {
@@ -2139,19 +2140,19 @@ class Vs {
}
}
}
-const { PeerCommandType: k } = Js;
-class At {
- constructor(t, e, n, i, r) {
+const { PeerCommandType: k } = Vs;
+class Lt {
+ constructor(t, e, n, s, 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, "logger", L("p2pml-core:peer"));
d(this, "onPeerClosed");
d(this, "onCommandReceived", async (t) => {
- var e, n, i, r;
+ var e, n, s;
switch (t.c) {
case k.SegmentsAnnouncement:
this.loadedSegments = new Set(t.l), this.httpLoadingSegments = new Set(t.p), this.eventHandlers.onSegmentsAnnouncement();
@@ -2162,34 +2163,35 @@ class At {
case k.SegmentData:
{
if (!this.downloadingContext || this.downloadingContext.isSegmentDataCommandReceived) break;
- const { request: o, controls: a, requestId: h } = this.downloadingContext;
- if (o.segment.externalId !== t.i || h !== t.r) break;
- 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());
+ const { request: r, controls: o, requestId: a } = this.downloadingContext;
+ if (r.segment.externalId !== t.i || a !== t.r) break;
+ this.downloadingContext.isSegmentDataCommandReceived = !0, o.firstBytesReceived(), r.totalBytes === void 0 ? r.setTotalBytes(t.s) : r.totalBytes - r.loadedBytes !== t.s && (r.clearLoadedBytes(), this.sendCancelSegmentRequestCommand(r.segment, a), this.cancelSegmentDownloading("peer-response-bytes-length-mismatch"), this.destroy());
}
break;
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 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 (!u) return a.clearLoadedBytes(), this.cancelSegmentDownloading("p2p-segment-validation-failed"), void this.destroy();
- this.downloadingErrors = [], h.completeOnSuccess(), this.downloadingContext = void 0;
+ const { downloadingContext: r } = this;
+ if (!(r != null && r.isSegmentDataCommandReceived)) return;
+ const { request: o, controls: a } = r;
+ if (r.request.segment.externalId !== t.i || r.requestId !== t.r) return o.clearLoadedBytes(), this.cancelSegmentDownloading("peer-protocol-violation"), void this.destroy();
+ if (o.loadedBytes !== o.totalBytes) return o.clearLoadedBytes(), this.cancelSegmentDownloading("peer-response-bytes-length-mismatch"), void this.destroy();
+ const h = await ((n = (e = this.peerConfig).validateP2PSegment) == null ? void 0 : n.call(e, o.segment.url, o.segment.byteRange, o.data)) ?? !0;
+ if (this.downloadingContext !== r) return;
+ if (!h) return o.clearLoadedBytes(), this.cancelSegmentDownloading("p2p-segment-validation-failed"), void this.destroy();
+ this.downloadingErrors = [], a.completeOnSuccess(), this.downloadingContext = void 0;
break;
}
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));
+ ((s = this.downloadingContext) == null ? void 0 : s.request.segment.externalId) === t.i && this.downloadingContext.requestId === t.r && (this.cancelSegmentDownloading("peer-segment-absent"), this.loadedSegments.delete(t.i));
break;
case k.CancelSegmentRequest:
if (this.peerProtocol.getUploadingRequestId() !== t.r) break;
this.peerProtocol.stopUploadingSegmentData();
+ break;
}
});
d(this, "onSegmentChunkReceived", (t) => {
- var i;
- if (!((i = this.downloadingContext) != null && i.isSegmentDataCommandReceived)) return;
+ var s;
+ if (!((s = this.downloadingContext) != null && s.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);
@@ -2199,13 +2201,13 @@ class At {
});
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;
+ const { code: e } = t;
(e === "ERR_DATA_CHANNEL" || e === "ERR_CONNECTION_FAILURE") && 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 = 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);
+ this.connection = t, this.eventHandlers = e, this.peerConfig = n, this.streamType = s, this.eventTarget = r, this.onPeerClosed = r.getEventDispatcher("onPeerClose"), this.id = Lt.getPeerIdFromConnection(t), this.peerProtocol = new Ys(t, n, { onSegmentChunkReceived: this.onSegmentChunkReceived, onCommandReceived: this.onCommandReceived }, r), r.getEventDispatcher("onPeerConnect")({ peerId: this.id, streamType: s }), t.on("error", this.onConnectionError), t.on("close", this.onPeerConnectionClosed), t.on("end", this.onPeerConnectionClosed), t.on("finish", this.onPeerConnectionClosed);
}
get downloadingSegment() {
var t;
@@ -2219,27 +2221,27 @@ class At {
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: 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 { request: s, requestId: r } = this.downloadingContext;
+ this.sendCancelSegmentRequestCommand(s.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: 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: i } = t;
+ const { externalId: s } = t;
this.logger(`send segment ${t.externalId} to ${this.id}`);
- const r = { c: k.SegmentData, i, r: e, s: n.byteLength };
+ const r = { c: k.SegmentData, i: s, r: e, s: n.byteLength };
this.peerProtocol.sendCommand(r);
try {
- await this.peerProtocol.splitSegmentDataToChunksAndUploadAsync(n, e), this.sendSegmentDataSendingCompletedCommand(t, e), this.logger(`segment ${i} has been sent to ${this.id}`);
+ await this.peerProtocol.splitSegmentDataToChunksAndUploadAsync(n, e), this.sendSegmentDataSendingCompletedCommand(t, e), this.logger(`segment ${s} has been sent to ${this.id}`);
} catch {
- this.logger(`cancel segment uploading ${i}`);
+ this.logger(`cancel segment uploading ${s}`);
}
}
cancelSegmentDownloading(t) {
if (!this.downloadingContext) return;
- const { request: e, controls: n } = this.downloadingContext, { segment: i } = e;
- this.logger(`cancel segment request ${i.externalId} (${t})`);
+ const { request: e, controls: n } = this.downloadingContext, { segment: s } = e;
+ this.logger(`cancel segment request ${s.externalId} (${t})`);
const r = new x(t);
n.abortOnError(r), this.downloadingContext = void 0, this.downloadingErrors.push(r);
}
@@ -2259,28 +2261,28 @@ class At {
static getPeerIdFromConnection(t) {
return function(e) {
const n = new Uint8Array(e.length / 2);
- for (let i = 0; i < e.length; i += 2) n[i / 2] = parseInt(e.slice(i, i + 2), 16);
+ for (let s = 0; s < e.length; s += 2) n[s / 2] = parseInt(e.slice(s, s + 2), 16);
return new TextDecoder().decode(n);
}(t.id);
}
}
-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;
+function Ks() {
+ const i = /^((?!chrome|android).)*safari/i.test(navigator.userAgent), t = /\b(iPad|iPhone|Macintosh).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent);
+ return i || t;
}
-class Ks {
- constructor(t, e, n, i, r) {
+class Zs {
+ constructor(t, e, n, s, r) {
d(this, "streamShortId");
d(this, "client");
d(this, "_peers", /* @__PURE__ */ new Map());
- d(this, "logger", A("p2pml-core:p2p-tracker-client"));
+ d(this, "logger", L("p2pml-core:p2p-tracker-client"));
d(this, "onReceivePeerConnection", (t) => {
- const e = At.getPeerIdFromConnection(t);
+ const e = Lt.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 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);
+ if (!n.peer) {
+ for (const s of n.potentialConnections) s !== t && s.destroy();
+ n.potentialConnections.clear(), n.peer = new Lt(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);
}
}));
});
@@ -2293,18 +2295,18 @@ class Ks {
d(this, "onPeerClosed", (t) => {
this.logger(`peer closed: ${t.id}`), this._peers.delete(t.id);
});
- this.stream = e, this.eventHandlers = n, this.config = i, this.eventTarget = r;
+ this.stream = e, this.eventHandlers = n, this.config = s, this.eventTarget = r;
const o = function(h) {
- const u = Ns.fromUtf8(h).slice(1);
+ const u = Us.fromUtf8(h).slice(1);
return btoa(u);
}(t);
- this.streamShortId = $(e);
+ this.streamShortId = F(e);
const a = function(h) {
const u = [h], c = 20 - h.length;
- for (let l = 0; l < c; l++) u.push(Us[Math.floor(62 * Math.random())]);
+ for (let l = 0; l < c; l++) u.push(Hs[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;
+ }(s.trackerClientVersionPrefix);
+ this.client = new te({ infoHash: Oe(o), peerId: Oe(a), announce: Ks() ? s.announceTrackers.slice(0, 1) : s.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}`);
}
@@ -2320,66 +2322,73 @@ peerId: ${a}`);
this._peers.clear(), this.logger(`destroy client; stream: ${this.streamShortId}`);
}
*peers() {
- for (const t of this._peers.values()) t != null && t.peer && (yield t.peer);
+ for (const t of this._peers.values()) t.peer && (yield t.peer);
}
}
-function B(s, t) {
- return `v2-${s}-${function(e) {
+function B(i, t) {
+ return `v2-${i}-${function(e) {
return `${e.type}-${e.index}`;
}(t)}`;
}
-function Ue(s, t) {
- for (const e of s.values()) {
+function Ue(i, t) {
+ for (const e of i.values()) {
const n = e.segments.get(t);
if (n) return n;
}
}
-function Mt(s, t, e, n, i) {
+function Mt(i, t, e, n, s) {
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) };
+ }(e, s);
+ return { isHighDemand: Nt(i, t, r), isHttpDownloadable: Nt(i, t, o), isP2PDownloadable: Nt(i, t, a) && n.isSegmentLoadingOrLoadedBySomeone(i) };
}
-function Nt(s, t, e) {
- const { startTime: n, endTime: i } = s, { position: r, rate: o } = t;
- return !(r + e * o < n || r > i);
+function Nt(i, t, e) {
+ const { startTime: n, endTime: s } = i, { position: r, rate: o } = t;
+ return !(r + e * o < n || r > s);
}
-class Zs {
- constructor(t, e, n, i, r, o, a) {
+class Xs {
+ constructor(t, e, n, s, r, o, a) {
d(this, "trackerClient");
d(this, "isAnnounceMicrotaskCreated", !1);
d(this, "onPeerConnected", (t) => {
+ if (this.config.isP2PUploadDisabled) return;
const { httpLoading: e, loaded: n } = this.getSegmentsAnnouncement();
t.sendSegmentsAnnouncementCommand(n, e);
});
- 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;
- }));
+ d(this, "broadcastAnnouncement", (t = !1) => {
+ if (t) return void this.sendSegmentsAnnouncement([], []);
+ if (this.isAnnounceMicrotaskCreated || this.config.isP2PUploadDisabled) return;
+ const { loaded: e, httpLoading: n } = this.getSegmentsAnnouncement();
+ this.sendSegmentsAnnouncement(e, n);
});
- d(this, "onSegmentRequested", async (t, e, n, i) => {
+ d(this, "sendSegmentsAnnouncement", (t, e) => {
+ this.isAnnounceMicrotaskCreated = !0, queueMicrotask(() => {
+ for (const n of this.trackerClient.peers()) n.sendSegmentsAnnouncementCommand(t, e);
+ this.isAnnounceMicrotaskCreated = !1;
+ });
+ });
+ d(this, "onSegmentRequested", async (t, e, n, s) => {
const r = function(u, c) {
for (const l of u.segments.values()) if (l.externalId === c) return l;
}(this.stream, e);
if (!r) return;
+ if (this.config.isP2PUploadDisabled) return void t.sendSegmentAbsentCommand(e, n);
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);
+ h ? await t.uploadSegmentData(r, n, s !== void 0 ? h.slice(s) : h) : t.sendSegmentAbsentCommand(e, n);
});
- this.streamManifestUrl = t, this.stream = e, this.requests = n, this.segmentStorage = i, this.config = r, this.eventTarget = o, this.onSegmentAnnouncement = a;
+ this.streamManifestUrl = t, this.stream = e, this.requests = n, this.segmentStorage = s, 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.trackerClient = new Zs(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 = (i = e)[Math.floor(Math.random() * i.length)];
- var i;
- if (!n) return;
+ if (e.length === 0) return;
+ const n = (s = e)[Math.floor(Math.random() * s.length)];
+ var s;
const r = this.requests.getOrCreateRequest(t);
n.downloadSegment(r);
}
@@ -2397,44 +2406,43 @@ class Zs {
return t;
}
getSegmentsAnnouncement() {
- const t = this.config.swarmId ?? this.streamManifestUrl, e = B(t, this.stream), n = this.segmentStorage.getStoredSegmentIds(t, e), i = [];
+ const t = this.config.swarmId ?? this.streamManifestUrl, e = B(t, this.stream), n = this.segmentStorage.getStoredSegmentIds(t, e), s = [];
for (const r of this.requests.httpRequests()) {
const o = this.stream.segments.get(r.segment.runtimeId);
- o && i.push(o.externalId);
+ o && s.push(o.externalId);
}
- return { loaded: n, httpLoading: i };
+ return { loaded: n, httpLoading: s };
}
destroy() {
const t = B(this.config.swarmId ?? this.streamManifestUrl, this.stream);
this.eventTarget.removeEventListener(`onStorageUpdated-${t}`, this.broadcastAnnouncement), this.trackerClient.destroy();
}
}
-class Xs {
- constructor(t, e, n, i, r, o, a) {
+class ti {
+ constructor(t, e, n, s, 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);
+ d(this, "logger", L("p2pml-core:p2p-loaders-container"));
+ this.streamManifestUrl = t, this.requests = n, this.segmentStorage = s, this.config = r, this.eventTarget = o, this.onSegmentAnnouncement = a, this._currentLoaderItem = this.findOrCreateLoaderForStream(e), this.logger(`set current p2p loader: ${F(e)}`);
}
createLoader(t) {
if (this.loaders.has(t.runtimeId)) throw new Error("Loader for this stream already exists");
- const e = new Zs(this.streamManifestUrl, t, this.requests, this.segmentStorage, this.config, this.eventTarget, () => {
+ const e = new Xs(this.streamManifestUrl, t, this.requests, this.segmentStorage, this.config, this.eventTarget, () => {
this._currentLoaderItem.loader === e && this.onSegmentAnnouncement();
- }), n = $(t);
- return this.logger(`created new loader: ${n}`), { loader: e, stream: t, loggerInfo: $(t) };
+ }), n = F(t);
+ return this.logger(`created new loader: ${n}`), { loader: e, stream: t, loggerInfo: F(t) };
+ }
+ findOrCreateLoaderForStream(t) {
+ const e = this.loaders.get(t.runtimeId);
+ if (e) return clearTimeout(e.destroyTimeoutId), e.destroyTimeoutId = void 0, e;
+ {
+ const n = this.createLoader(t);
+ return this.loaders.set(t.runtimeId, n), n;
+ }
}
changeCurrentLoader(t) {
- const e = this.loaders.get(t.runtimeId);
- 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: ${$(t)}`);
+ const e = this.config.swarmId ?? this.streamManifestUrl, n = B(e, this._currentLoaderItem.stream);
+ this.segmentStorage.getStoredSegmentIds(e, n).length ? this.setLoaderDestroyTimeout(this._currentLoaderItem) : this.destroyAndRemoveLoader(this._currentLoaderItem), this._currentLoaderItem = this.findOrCreateLoaderForStream(t), this.logger(`change current p2p loader: ${F(t)}`);
}
setLoaderDestroyTimeout(t) {
t.destroyTimeoutId = window.setTimeout(() => this.destroyAndRemoveLoader(t), this.config.p2pInactiveLoaderDestroyTimeoutMs);
@@ -2450,10 +2458,10 @@ class Xs {
this.loaders.clear();
}
}
-let ti = class {
- constructor(s, t, e, n, i, r) {
+let ei = class {
+ constructor(i, t, e, n, s, r) {
d(this, "currentAttempt");
- d(this, "_failedAttempts", new ei());
+ d(this, "_failedAttempts", new ni());
d(this, "finalData");
d(this, "bytes", []);
d(this, "_loadedBytes", 0);
@@ -2472,46 +2480,46 @@ let ti = class {
var t;
if (this.throwErrorIfNotLoadingStatus(), !this.currentAttempt) return;
this.setStatus("failed");
- 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();
+ const i = new x("bytes-receiving-timeout");
+ (t = this._abortRequestCallback) == null || t.call(this, i), this.logger(`${this.downloadSource} ${this.segment.externalId} failed ${i.type}`), this._failedAttempts.add({ ...this.currentAttempt, error: i }), this.onSegmentError({ segment: this.segment, error: i, 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();
});
- 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());
+ d(this, "abortOnError", (i) => {
+ this.throwErrorIfNotLoadingStatus(), this.currentAttempt && (this.setStatus("failed"), this.logger(`${this.downloadSource} ${this.segment.externalId} failed ${i.type}`), this._failedAttempts.add({ ...this.currentAttempt, error: i }), this.onSegmentError({ segment: this.segment, error: i, 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());
});
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());
+ this.throwErrorIfNotLoadingStatus(), this.currentAttempt && (this.manageBandwidthCalculatorsState("stop"), this.notReceivingBytesTimeout.clear(), this.setStatus("succeed"), this._totalBytes = this._loadedBytes, this.onSegmentLoaded({ segmentUrl: this.segment.url, bytesLength: this.data.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, "addLoadedChunk", (s) => {
+ d(this, "addLoadedChunk", (i) => {
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;
+ const { byteLength: t } = i, { all: e, http: n } = this.bandwidthCalculators;
+ e.addBytes(t), this.currentAttempt.downloadSource === "http" && n.addBytes(t), this.bytes.push(i), this.progress.lastLoadedChunkTimestamp = performance.now(), this.progress.loadedBytes += t, this._loadedBytes += t;
});
d(this, "firstBytesReceived", () => {
this.throwErrorIfNotLoadingStatus(), this.notReceivingBytesTimeout.restart();
});
- 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");
+ this.segment = i, this.requestProcessQueueCallback = t, this.bandwidthCalculators = e, this.playback = n, this.playbackConfig = s, 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: u } = o;
this._totalBytes = h - u + 1;
}
- this.notReceivingBytesTimeout = new ni(this.abortOnTimeout);
+ this.notReceivingBytesTimeout = new si(this.abortOnTimeout);
const { type: a } = this.segment.stream;
- this._logger = A(`p2pml-core:request-${a}`);
+ this._logger = L(`p2pml-core:request-${a}`);
}
clearLoadedBytes() {
- this._loadedBytes = 0, this.bytes = [], this._totalBytes = void 0;
+ this._loadedBytes = 0, this.bytes = [], this._totalBytes = void 0, this.finalData = void 0;
}
get status() {
return this._status;
}
- setStatus(s) {
- this._status = s, this._isHandledByProcessQueue = !1;
+ setStatus(i) {
+ this._status = i, this._isHandledByProcessQueue = !1;
}
get downloadSource() {
- var s;
- return (s = this.currentAttempt) == null ? void 0 : s.downloadSource;
+ var i;
+ return (i = this.currentAttempt) == null ? void 0 : i.downloadSource;
}
get loadedBytes() {
return this._loadedBytes;
@@ -2520,7 +2528,7 @@ let ti = class {
return this._totalBytes;
}
get data() {
- if (this.status === "succeed") return this.finalData || (this.finalData = ne(this.bytes)), this.finalData;
+ return this.finalData || (this.finalData = Tn(this.bytes)), this.finalData;
}
get failedAttempts() {
return this._failedAttempts;
@@ -2531,35 +2539,35 @@ let ti = class {
markHandledByProcessQueue() {
this._isHandledByProcessQueue = !0;
}
- setTotalBytes(s) {
+ setTotalBytes(i) {
if (this._totalBytes !== void 0) throw new Error("Request total bytes value is already set");
- this._totalBytes = s;
+ this._totalBytes = i;
}
- start(s, t) {
+ start(i, t) {
if (this._status === "succeed") throw new Error(`Request ${this.segment.externalId} has been already succeed.`);
if (this._status === "loading") throw new Error(`Request ${this.segment.externalId} has been already started.`);
- this.setStatus("loading"), this.currentAttempt = { ...s }, this.progress = { startFromByte: this._loadedBytes, loadedBytes: 0, startTimestamp: performance.now() }, this.manageBandwidthCalculatorsState("start");
+ this.setStatus("loading"), this.currentAttempt = { ...i }, this.progress = { startFromByte: this._loadedBytes, loadedBytes: 0, startTimestamp: performance.now() }, this.manageBandwidthCalculatorsState("start");
const { notReceivingBytesTimeoutMs: e, abort: n } = t;
- return this._abortRequestCallback = n, e !== void 0 && this.notReceivingBytesTimeout.start(e), this.logger(`${s.downloadSource} ${this.segment.externalId} started`), this.onSegmentStart({ segment: this.segment, downloadSource: s.downloadSource, peerId: s.downloadSource === "p2p" ? s.peerId : void 0 }), { firstBytesReceived: this.firstBytesReceived, addLoadedChunk: this.addLoadedChunk, completeOnSuccess: this.completeOnSuccess, abortOnError: this.abortOnError };
+ return this._abortRequestCallback = n, e !== void 0 && this.notReceivingBytesTimeout.start(e), this.logger(`${i.downloadSource} ${this.segment.externalId} started`), this.onSegmentStart({ segment: this.segment, downloadSource: i.downloadSource, peerId: i.downloadSource === "p2p" ? i.peerId : void 0 }), { firstBytesReceived: this.firstBytesReceived, addLoadedChunk: this.addLoadedChunk, completeOnSuccess: this.completeOnSuccess, abortOnError: this.abortOnError };
}
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 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();
+ var i, t, e, n;
+ this.throwErrorIfNotLoadingStatus(), this.setStatus("aborted"), this.logger(`${(i = this.currentAttempt) == null ? void 0 : i.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}.`);
}
- logger(s) {
+ logger(i) {
var t;
- this._logger.color = ((t = this.currentAttempt) == null ? void 0 : t.downloadSource) === "http" ? "green" : "red", this._logger(s), this._logger.color = "";
+ this._logger.color = ((t = this.currentAttempt) == null ? void 0 : t.downloadSource) === "http" ? "green" : "red", this._logger(i), this._logger.color = "";
}
- manageBandwidthCalculatorsState(s) {
- var i;
- const { all: t, http: e } = this.bandwidthCalculators, n = s === "start" ? "startLoading" : "stopLoading";
- ((i = this.currentAttempt) == null ? void 0 : i.downloadSource) === "http" && e[n](), t[n]();
+ manageBandwidthCalculatorsState(i) {
+ var s;
+ const { all: t, http: e } = this.bandwidthCalculators, n = i === "start" ? "startLoading" : "stopLoading";
+ ((s = this.currentAttempt) == null ? void 0 : s.downloadSource) === "http" && e[n](), t[n]();
}
};
-class ei {
+class ni {
constructor() {
d(this, "attempts", []);
}
@@ -2576,7 +2584,7 @@ class ei {
this.attempts = [];
}
}
-class ni {
+class si {
constructor(t) {
d(this, "timeoutId");
d(this, "ms");
@@ -2593,10 +2601,10 @@ class ni {
clearTimeout(this.timeoutId), this.timeoutId = void 0;
}
}
-class si {
- constructor(t, e, n, i, r) {
+class ii {
+ constructor(t, e, n, s, r) {
d(this, "requests", /* @__PURE__ */ new Map());
- this.requestProcessQueueCallback = t, this.bandwidthCalculators = e, this.playback = n, this.config = i, this.eventTarget = r;
+ this.requestProcessQueueCallback = t, this.bandwidthCalculators = e, this.playback = n, this.config = s, this.eventTarget = r;
}
get executingHttpCount() {
let t = 0;
@@ -2613,7 +2621,7 @@ class si {
}
getOrCreateRequest(t) {
let e = this.requests.get(t);
- return e || (e = new ti(t, this.requestProcessQueueCallback, this.bandwidthCalculators, this.playback, this.config, this.eventTarget), this.requests.set(t, e)), e;
+ return e || (e = new ei(t, this.requestProcessQueueCallback, this.bandwidthCalculators, this.playback, this.config, this.eventTarget), this.requests.set(t, e)), e;
}
remove(t) {
this.requests.delete(t.segment);
@@ -2632,7 +2640,7 @@ class si {
this.requests.clear();
}
}
-class ii {
+class ri {
constructor(t, e) {
d(this, "_status", "pending");
d(this, "_shouldBeStartedImmediately", !1);
@@ -2648,17 +2656,17 @@ class ii {
this._status === "pending" && (this._status = "succeed", this.engineCallbacks.onSuccess({ data: t, bandwidth: e }));
}
reject() {
- this._status === "pending" && (this._status = "failed", this.engineCallbacks.onError(new ae("failed")));
+ this._status === "pending" && (this._status = "failed", this.engineCallbacks.onError(new oe("failed")));
}
abort() {
- this._status === "pending" && (this._status = "aborted", this.engineCallbacks.onError(new ae("aborted")));
+ this._status === "pending" && (this._status = "aborted", this.engineCallbacks.onError(new oe("aborted")));
}
markAsShouldBeStartedImmediately() {
this._shouldBeStartedImmediately = !0;
}
}
-function* He(s, t, e, n, i) {
- const { runtimeId: r, stream: o } = s, a = o.segments.get(r);
+function* Fe(i, t, e, n, s) {
+ const { runtimeId: r, stream: o } = i, a = o.segments.get(r);
if (!a) return;
const h = o.segments.values();
let u;
@@ -2667,26 +2675,26 @@ function* He(s, t, e, n, i) {
if (l.done) return;
u = l.value;
} while (u !== a);
- const c = Mt(u, t, e, n, i);
- if (Ft(c)) {
+ const c = Mt(u, t, e, n, s);
+ if (Ut(c)) {
const l = h.next();
if (l.done) return;
- const g = l.value, m = Mt(g, t, e, n, i);
- if (Ft(m)) return;
+ const g = l.value, m = Mt(g, t, e, n, s);
+ if (Ut(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;
+ const g = Mt(l, t, e, n, s);
+ if (Ut(g)) break;
yield { segment: l, statuses: g };
}
}
-function Ft(s) {
- const { isHighDemand: t = !1, isHttpDownloadable: e = !1, isP2PDownloadable: n = !1 } = s;
+function Ut(i) {
+ const { isHighDemand: t = !1, isHttpDownloadable: e = !1, isP2PDownloadable: n = !1 } = i;
return !t && !e && !n;
}
-class ri {
- constructor(t, e, n, i, r, o, a) {
+class oi {
+ constructor(t, e, n, s, r, o, a) {
d(this, "requests");
d(this, "engineRequest");
d(this, "p2pLoaders");
@@ -2708,16 +2716,15 @@ class ri {
}
}));
});
- this.streamManifestUrl = t, this.lastRequestedSegment = e, this.streamDetails = n, this.config = i, this.bandwidthCalculators = r, this.segmentStorage = o, this.eventTarget = a;
+ this.streamManifestUrl = t, this.lastRequestedSegment = e, this.streamDetails = n, this.config = s, 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(u) {
+ this.playback = { position: this.lastRequestedSegment.startTime, rate: 1 }, this.segmentAvgDuration = function(u) {
const { segments: c } = u;
let l = 0;
- const g = c.size;
+ const { size: g } = c;
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();
+ }(h), this.requests = new ii(this.requestProcessQueueMicrotask, this.bandwidthCalculators, this.playback, this.config, this.eventTarget), this.p2pLoaders = new ti(this.streamManifestUrl, this.lastRequestedSegment.stream, this.requests, this.segmentStorage, this.config, this.eventTarget, this.requestProcessQueueMicrotask), this.logger = L(`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;
@@ -2726,21 +2733,22 @@ class ri {
}, e);
}
async loadSegment(t, e) {
- this.logger(`requests: ${Oe(t)}`);
+ var a;
+ this.logger(`requests: ${Be(t)}`);
const { stream: n } = t;
- 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);
+ n !== this.lastRequestedSegment.stream && (this.logger(`stream changed to ${F(n)}`), this.p2pLoaders.changeCurrentLoader(n)), this.lastRequestedSegment = t;
+ const s = this.config.swarmId ?? this.streamManifestUrl, r = B(s, n);
+ this.segmentStorage.onSegmentRequested(s, r, t.externalId, t.startTime, t.endTime, n.type, this.streamDetails.isLive);
+ const o = new ri(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));
+ if (this.segmentStorage.hasSegment(s, r, t.externalId)) {
+ const h = await this.segmentStorage.getSegmentData(s, r, t.externalId);
+ if (h) {
+ const { queueDownloadRatio: u } = this.generateQueue();
+ return void o.resolve(h, this.getBandwidth(u));
}
}
- this.engineRequest = o;
+ (a = this.engineRequest) == null || a.abort(), this.engineRequest = o;
} catch {
o.reject();
} finally {
@@ -2749,21 +2757,22 @@ class ri {
}
processRequests(t, e) {
var o;
- const { stream: n } = this.lastRequestedSegment, { httpErrorRetries: i } = this.config, r = performance.now();
+ const { stream: n } = this.lastRequestedSegment, { httpErrorRetries: s } = this.config, r = performance.now();
for (const a of this.requests.items()) {
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(c.runtimeId) || g || (a.abortFromProcessQueue(), this.requests.remove(a));
break;
- case "succeed":
- if (!a.data || !h) break;
+ case "succeed": {
+ if (!h) break;
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" || 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());
+ h !== "http" || l || this.p2pLoaders.currentLoader.broadcastAnnouncement(), g || n.segments.has(a.segment.runtimeId) || this.requests.remove(a), a.failedAttempts.httpAttemptsCount >= s && g && (this.engineRequest = void 0, g.reject());
break;
case "not-started":
case "aborted":
@@ -2778,8 +2787,8 @@ class ri {
var a;
const { queue: t, queueSegmentIds: e, queueDownloadRatio: n } = this.generateQueue();
this.processRequests(e, n);
- 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 { simultaneousHttpDownloads: s, simultaneousP2PDownloads: r, httpErrorRetries: o } = this.config;
+ if ((a = this.engineRequest) != null && a.shouldBeStartedImmediately && this.engineRequest.status === "pending" && this.requests.executingHttpCount < s) {
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);
}
@@ -2788,11 +2797,11 @@ class ri {
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) {
+ if (this.requests.executingHttpCount < s) {
g && l.abortFromProcessQueue(), this.loadThroughHttp(c);
continue;
}
- if (this.abortLastHttpLoadingInQueueAfterItem(t, c) && this.requests.executingHttpCount < i) {
+ if (this.abortLastHttpLoadingInQueueAfterItem(t, c) && this.requests.executingHttpCount < s) {
g && l.abortFromProcessQueue(), this.loadThroughHttp(c);
continue;
}
@@ -2813,11 +2822,11 @@ class ri {
}
abortSegmentRequest(t) {
var e;
- ((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());
+ ((e = this.engineRequest) == null ? void 0 : e.segment.runtimeId) === t && (this.engineRequest.abort(), this.logger("abort: ", Be(this.engineRequest.segment)), this.engineRequest = void 0, this.requestProcessQueueMicrotask());
}
loadThroughHttp(t) {
const e = this.requests.getOrCreateRequest(t);
- new On(e, this.config, this.eventTarget), this.p2pLoaders.currentLoader.broadcastAnnouncement();
+ new Bn(e, this.config, this.eventTarget), this.p2pLoaders.currentLoader.broadcastAnnouncement();
}
loadThroughP2P(t) {
this.p2pLoaders.currentLoader.downloadSegment(t);
@@ -2825,17 +2834,17 @@ class ri {
loadRandomThroughHttp() {
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 { simultaneousHttpDownloads: e, httpErrorRetries: n } = this.config, s = this.p2pLoaders.currentLoader;
+ if (this.requests.executingHttpCount >= e || !s.connectedPeerCount) return;
const r = [];
- for (const { segment: c, statuses: l } of He(this.lastRequestedSegment, this.playback, this.config, this.p2pLoaders.currentLoader, t)) {
+ for (const { segment: c, statuses: l } of Fe(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);
+ f && (f.status === "loading" || f.status === "succeed" || f.failedAttempts.httpAttemptsCount >= n) || r.push(c);
}
if (!r.length || e - this.requests.executingHttpCount === 0) return;
- const o = i.connectedPeerCount + 1, a = Math.min(r.length, e * o), h = function(c) {
+ const o = s.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]];
@@ -2853,18 +2862,18 @@ class ri {
}
}
abortLastHttpLoadingInQueueAfterItem(t, e) {
- for (const { segment: n } of Me(t)) {
+ for (const { segment: n } of De(t)) {
if (n === e) break;
- const i = this.requests.get(n);
- if ((i == null ? void 0 : i.downloadSource) === "http" && i.status === "loading") return i.abortFromProcessQueue(), !0;
+ const s = this.requests.get(n);
+ if ((s == null ? void 0 : s.downloadSource) === "http" && s.status === "loading") return s.abortFromProcessQueue(), !0;
}
return !1;
}
abortLastP2PLoadingInQueueAfterItem(t, e) {
- for (const { segment: n } of Me(t)) {
+ for (const { segment: n } of De(t)) {
if (n === e) break;
- const i = this.requests.get(n);
- if ((i == null ? void 0 : i.downloadSource) === "p2p" && i.status === "loading") return i.abortFromProcessQueue(), !0;
+ const s = this.requests.get(n);
+ if ((s == null ? void 0 : s.downloadSource) === "p2p" && s.status === "loading") return s.abortFromProcessQueue(), !0;
}
return !1;
}
@@ -2875,42 +2884,45 @@ class ri {
generateQueue() {
var o;
const t = [], e = /* @__PURE__ */ new Set();
- let n = 0, i = 0;
+ let n = 0, s = 0;
const r = this.getAvailableStorageCapacityPercent();
- for (const a of He(this.lastRequestedSegment, this.playback, this.config, this.p2pLoaders.currentLoader, r)) {
+ for (const a of Fe(this.lastRequestedSegment, this.playback, this.config, this.p2pLoaders.currentLoader, r)) {
n++;
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));
+ this.segmentStorage.hasSegment(u, c, h.externalId) || ((o = this.requests.get(h)) == null ? void 0 : o.status) === "succeed" ? s++ : (t.push(a), e.add(h.runtimeId));
}
- return { queue: t, queueSegmentIds: e, maxPossibleLength: n, alreadyLoadedCount: i, queueDownloadRatio: n !== 0 ? i / n : 0 };
+ return { queue: t, queueSegmentIds: e, maxPossibleLength: n, alreadyLoadedCount: s, queueDownloadRatio: n !== 0 ? s / n : 0 };
}
getBandwidth(t) {
- const { http: e, all: n } = this.bandwidthCalculators, { activeLevelBitrate: i } = this.streamDetails;
+ const { http: e, all: n } = this.bandwidthCalculators, { activeLevelBitrate: s } = this.streamDetails;
if (this.streamDetails.activeLevelBitrate === 0) return n.getBandwidthLoadingOnly(3);
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));
+ if (t >= 0.8 || r >= 0.9 * s) 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(r, o);
}
notifyLevelChanged() {
this.levelChangedTimestamp = performance.now();
}
+ sendBroadcastAnnouncement(t = !1) {
+ this.p2pLoaders.currentLoader.broadcastAnnouncement(t);
+ }
updatePlayback(t, e) {
var o;
- const n = this.playback.rate !== e, i = this.playback.position !== t;
- if (!n && !i) return;
+ const n = this.playback.rate !== e, s = this.playback.position !== t;
+ if (!n && !s) 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);
+ s && (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: ${$(t)}`), this.requestProcessQueueMicrotask());
+ t === this.lastRequestedSegment.stream && (this.logger(`update stream: ${F(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 $e {
+class He {
constructor(t = 2e4) {
d(this, "loadingsCount", 0);
d(this, "bytes", []);
@@ -2931,24 +2943,24 @@ class $e {
}
getBandwidthLoadingOnly(t, e = Number.NEGATIVE_INFINITY) {
if (!this.loadingOnlyTimestamps.length) return 0;
- const n = 1e3 * t, i = this.loadingOnlyTimestamps[this.loadingOnlyTimestamps.length - 1];
- let r = i;
- const o = i - n;
+ const n = 1e3 * t, s = this.loadingOnlyTimestamps[this.loadingOnlyTimestamps.length - 1];
+ let r = s;
+ const o = s - n;
let a = 0;
for (let h = this.bytes.length - 1; h >= 0; h--) {
const u = this.loadingOnlyTimestamps[h];
if (u < o || this.timestamps[h] < e) break;
r = u, a += this.bytes[h];
}
- return 8e3 * a / (i - r);
+ return 8e3 * a / (s - r);
}
getBandwidth(t, e = Number.NEGATIVE_INFINITY, n = performance.now()) {
if (!this.timestamps.length) return 0;
- const i = n - 1e3 * t;
+ const s = 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 < i || h < e) break;
+ if (h < s || h < e) break;
r = h, o += this.bytes[a];
}
return 8e3 * o / (n - r);
@@ -2964,8 +2976,8 @@ class $e {
this.bytes.splice(0, e), this.loadingOnlyTimestamps.splice(0, e), this.timestamps.splice(0, e);
}
}
-const gt = (s, t) => `${s}|${t}`, mt = 1048576;
-class oi {
+const gt = (i, t) => `${i}|${t}`, mt = 1048576;
+class ai {
constructor() {
d(this, "userAgent", navigator.userAgent);
d(this, "segmentMemoryStorageLimit", 4096);
@@ -2978,7 +2990,7 @@ class oi {
d(this, "currentPlayback");
d(this, "lastRequestedSegment");
d(this, "segmentChangeCallback");
- this.logger = A("p2pml-core:segment-memory-storage"), this.logger.color = "RebeccaPurple";
+ this.logger = L("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");
@@ -2986,39 +2998,39 @@ class oi {
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 };
+ onSegmentRequested(t, e, n, s, r, o, a) {
+ this.lastRequestedSegment = { streamId: e, segmentId: n, startTime: s, endTime: r, swarmId: t, streamType: o, isLiveStream: a };
}
- async storeSegment(t, e, n, i, r, o, a, h) {
- this.clear(h, i.byteLength);
+ async storeSegment(t, e, n, s, r, o, a, h) {
+ this.clear(h, s.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");
+ if (this.cache.set(u, { data: s, segmentId: n, streamId: e, startTime: r, endTime: o, streamType: a }), this.increaseStorageUsage(s.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);
+ const s = gt(e, n), r = this.cache.get(s);
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);
+ for (const { endTime: n, data: s } of this.cache.values()) t > n || (e += s.byteLength);
return { totalCapacity: this.segmentMemoryStorageLimit, usedCapacity: e / mt };
}
hasSegment(t, e, n) {
- const i = gt(e, n);
- return this.cache.get(i) !== void 0;
+ const s = gt(e, n);
+ return this.cache.get(s) !== void 0;
}
getStoredSegmentIds(t, e) {
const n = [];
- for (const { segmentId: i, streamId: r } of this.cache.values()) r === e && n.push(i);
+ for (const { segmentId: s, streamId: r } of this.cache.values()) r === e && n.push(s);
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 n = /* @__PURE__ */ new Set(), s = Array.from(this.cache.values()).sort((r, o) => r.startTime - o.startTime);
+ for (const r of s) {
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;
}
@@ -3037,8 +3049,8 @@ class oi {
});
}
shouldRemoveSegment(t, e, n) {
- const { endTime: i, streamType: r } = t, o = this.getStreamTimeWindow(r, "highDemandTimeWindow");
- return !(n <= i) && (!e || n > o + i);
+ const { endTime: s, streamType: r } = t, o = this.getStreamTimeWindow(r, "highDemandTimeWindow");
+ return !(n <= s) && (!e || n > o + s);
}
increaseStorageUsage(t) {
this.currentStorageUsage += t / mt;
@@ -3047,8 +3059,9 @@ class oi {
this.currentStorageUsage -= t / mt;
}
setMemoryStorageLimit() {
+ var e;
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));
+ (e = this.coreConfig) != null && e.segmentMemoryStorageLimit ? this.segmentMemoryStorageLimit = this.coreConfig.segmentMemoryStorageLimit : (t = this.userAgent, /Android/i.test(t) && !/Chrome|Firefox/i.test(t) || ((n) => /iPad|iPhone/i.test(n))(this.userAgent) ? this.segmentMemoryStorageLimit = 1024 : ((n) => /Android/i.test(n))(this.userAgent) && (this.segmentMemoryStorageLimit = 2048));
}
getStreamTimeWindow(t, e) {
const n = t === "main" ? this.mainStreamConfig : this.secondaryStreamConfig;
@@ -3058,20 +3071,20 @@ class oi {
this.cache.clear();
}
}
-class ai {
+class hi {
constructor() {
d(this, "events", /* @__PURE__ */ new Map());
}
dispatchEvent(t, ...e) {
const n = this.events.get(t);
- if (n) for (const i of n) i(...e);
+ if (n) for (const s of n) s(...e);
}
getEventDispatcher(t) {
let e = this.events.get(t);
e || (e = [], this.events.set(t, e));
const n = e;
- return (...i) => {
- for (const r of n) r(...i);
+ return (...s) => {
+ for (const r of n) r(...s);
};
}
addEventListener(t, e) {
@@ -3081,44 +3094,57 @@ class ai {
removeEventListener(t, e) {
const n = this.events.get(t);
if (n) {
- const i = n.indexOf(e);
- i !== -1 && n.splice(i, 1);
+ const s = n.indexOf(e);
+ s !== -1 && n.splice(s, 1);
}
}
}
-const U = class U {
+const $ = class $ {
constructor(t) {
- d(this, "eventTarget", new ai());
+ d(this, "eventTarget", new hi());
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, "bandwidthCalculators", { all: new He(), http: new He() });
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 e = function n(s) {
+ if (xn(s)) {
const r = {};
- return Object.keys(i).forEach((o) => {
- if (i[o] !== void 0) {
- const a = n(i[o]);
+ return Object.keys(s).forEach((o) => {
+ if (s[o] !== void 0) {
+ const a = n(s[o]);
a !== void 0 && (r[o] = a);
}
}), r;
}
- return i;
+ return s;
}(t ?? {});
- 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 });
+ this.commonCoreConfig = Dt({ defaultConfig: $.DEFAULT_COMMON_CORE_CONFIG, baseConfig: e }), this.mainStreamConfig = Dt({ defaultConfig: $.DEFAULT_STREAM_CONFIG, baseConfig: e, specificStreamConfig: e.mainStream }), this.secondaryStreamConfig = Dt({ defaultConfig: $.DEFAULT_STREAM_CONFIG, baseConfig: e, specificStreamConfig: e.secondaryStream });
}
getConfig() {
- return { ...G(this.commonCoreConfig), mainStream: G(this.mainStreamConfig), secondaryStream: G(this.secondaryStreamConfig) };
+ return { ...U(this.commonCoreConfig), mainStream: U(this.mainStreamConfig), secondaryStream: U(this.secondaryStreamConfig) };
}
applyDynamicConfig(t) {
- const { mainStream: e, secondaryStream: n } = t;
- this.overrideAllConfigs(t, e, n), this.mainStreamConfig.isP2PDisabled && this.destroyStreamLoader("main"), this.secondaryStreamConfig.isP2PDisabled && this.destroyStreamLoader("secondary");
+ const { mainStream: e, secondaryStream: n } = t, s = U(this.mainStreamConfig), r = U(this.secondaryStreamConfig);
+ this.overrideAllConfigs(t, e, n), this.processSpecificDynamicConfigParams(s, t, "main"), this.processSpecificDynamicConfigParams(r, t, "secondary");
+ }
+ processSpecificDynamicConfigParams(t, e, n) {
+ const s = this.getUpdatedStreamProperty("isP2PDisabled", e, n);
+ s && t.isP2PDisabled !== s && this.destroyStreamLoader(n);
+ const r = this.getUpdatedStreamProperty("isP2PUploadDisabled", e, n);
+ if (r !== void 0 && t.isP2PUploadDisabled !== r) {
+ const o = n === "main" ? this.mainStreamLoader : this.secondaryStreamLoader;
+ o == null || o.sendBroadcastAnnouncement(r);
+ }
+ }
+ getUpdatedStreamProperty(t, e, n) {
+ const s = n === "main" ? e.mainStream : e.secondaryStream;
+ return (s == null ? void 0 : s[t]) ?? e[t];
}
addEventListener(t, e) {
this.eventTarget.addEventListener(t, e);
@@ -3140,11 +3166,11 @@ const U = class U {
}
updateStream(t, e, n) {
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);
+ const s = this.streams.get(t);
+ if (s) {
+ if (e) for (const a of e) s.segments.has(a.runtimeId) || s.segments.set(a.runtimeId, { ...a, stream: s });
+ if (n) for (const a of n) s.segments.delete(a);
+ (r = this.mainStreamLoader) == null || r.updateStream(s), (o = this.secondaryStreamLoader) == null || o.updateStream(s);
}
}
async loadSegment(t, e) {
@@ -3158,8 +3184,8 @@ const U = class U {
(e = this.mainStreamLoader) == null || e.abortSegmentRequest(t), (n = this.secondaryStreamLoader) == null || n.abortSegmentRequest(t);
}
updatePlayback(t, e) {
- var n, i;
- (n = this.mainStreamLoader) == null || n.updatePlayback(t, e), (i = this.secondaryStreamLoader) == null || i.updatePlayback(t, e);
+ var n, s;
+ (n = this.mainStreamLoader) == null || n.updatePlayback(t, e), (s = this.secondaryStreamLoader) == null || s.updatePlayback(t, e);
}
setActiveLevelBitrate(t) {
var e, n;
@@ -3182,9 +3208,9 @@ const U = class U {
}
async initializeSegmentStorage() {
if (this.segmentStorage) return;
- const t = this.streamDetails.isLive, e = this.commonCoreConfig.customSegmentStorageFactory;
+ const { isLive: t } = this.streamDetails, e = this.commonCoreConfig.customSegmentStorageFactory;
if (e && typeof e != "function") throw new Error("Storage configuration is invalid");
- const n = e ? e(t) : new oi();
+ const n = e ? e(t) : new ai();
await n.initialize(this.commonCoreConfig, this.mainStreamConfig, this.secondaryStreamConfig), this.segmentStorage = n;
}
identifySegment(t) {
@@ -3207,16 +3233,16 @@ const U = class U {
if (!this.manifestResponseUrl) throw new Error("Manifest response url is not defined");
if (!this.segmentStorage) throw new Error("Segment storage is not initialized");
const e = t.stream.type === "main" ? this.mainStreamConfig : this.secondaryStreamConfig;
- return new ri(this.manifestResponseUrl, t, this.streamDetails, e, this.bandwidthCalculators, this.segmentStorage, this.eventTarget);
+ return new oi(this.manifestResponseUrl, t, this.streamDetails, e, this.bandwidthCalculators, this.segmentStorage, this.eventTarget);
}
};
-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;
+d($, "DEFAULT_COMMON_CORE_CONFIG", { segmentMemoryStorageLimit: void 0, customSegmentStorageFactory: void 0 }), d($, "DEFAULT_STREAM_CONFIG", { isP2PUploadDisabled: !1, 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 $e = $;
+const di = ze.debug;
export {
- je as Core,
- ae as CoreRequestError,
+ $e as Core,
+ oe as CoreRequestError,
x as RequestError,
- ci as debug
+ di as debug
};
//# sourceMappingURL=p2p-media-loader-core.es.min.js.map
diff --git a/resources/p2p-media-loader-hlsjs/2.0.1/p2p-media-loader-hlsjs.min.jsm b/resources/p2p-media-loader-hlsjs/2.1.0/p2p-media-loader-hlsjs.min.jsm
similarity index 69%
rename from resources/p2p-media-loader-hlsjs/2.0.1/p2p-media-loader-hlsjs.min.jsm
rename to resources/p2p-media-loader-hlsjs/2.1.0/p2p-media-loader-hlsjs.min.jsm
index 23bbb096..b7bb713f 100644
--- a/resources/p2p-media-loader-hlsjs/2.0.1/p2p-media-loader-hlsjs.min.jsm
+++ b/resources/p2p-media-loader-hlsjs/2.1.0/p2p-media-loader-hlsjs.min.jsm
@@ -3,8 +3,8 @@ var R = (n) => {
throw TypeError(n);
};
var q = (n, t, e) => t in n ? j(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
-var r = (n, t, e) => q(n, typeof t != "symbol" ? t + "" : t, e), A = (n, t, e) => t.has(n) || R("Cannot " + e);
-var i = (n, t, e) => (A(n, t, "read from private field"), e ? e.call(n) : t.get(n)), l = (n, t, e) => t.has(n) ? R("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), u = (n, t, e, s) => (A(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), x = (n, t, e) => (A(n, t, "access private method"), e);
+var r = (n, t, e) => q(n, typeof t != "symbol" ? t + "" : t, e), D = (n, t, e) => t.has(n) || R("Cannot " + e);
+var i = (n, t, e) => (D(n, t, "read from private field"), e ? e.call(n) : t.get(n)), l = (n, t, e) => t.has(n) ? R("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), u = (n, t, e, s) => (D(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), x = (n, t, e) => (D(n, t, "access private method"), e);
import { CoreRequestError as T, debug as N, Core as z } from "p2p-media-loader-core";
function F(n, t) {
return t ? `${n}|${t.start}-${t.end}` : n;
@@ -12,7 +12,7 @@ function F(n, t) {
function J(n, t) {
if (n !== void 0 && t !== void 0 && n <= t) return { start: n, end: t };
}
-var H, C, g, v, f, p, b, G, U;
+var H, M, g, y, p, m, b, G, A;
class B {
constructor(t, e) {
l(this, b);
@@ -20,65 +20,64 @@ class B {
r(this, "config");
r(this, "stats");
l(this, H);
- l(this, C);
+ l(this, M);
l(this, g);
- l(this, v);
- l(this, f);
+ l(this, y);
l(this, p);
- u(this, v, e), u(this, C, () => new t.loader(t)), this.stats = { aborted: !1, chunkCount: 0, loading: { start: 0, first: 0, end: 0 }, buffering: { start: 0, first: 0, end: 0 }, parsing: { start: 0, end: 0 }, total: 1, loaded: 1, bwEstimate: 0, retry: 0 };
+ l(this, m);
+ u(this, y, e), u(this, M, () => new t.loader(t)), this.stats = { aborted: !1, chunkCount: 0, loading: { start: 0, first: 0, end: 0 }, buffering: { start: 0, first: 0, end: 0 }, parsing: { start: 0, end: 0 }, total: 1, loaded: 1, bwEstimate: 0, retry: 0 };
}
load(t, e, s) {
- var L;
this.context = t, this.config = e, u(this, H, s);
- const o = this.stats, { rangeStart: h, rangeEnd: a } = t, y = J(h, a !== void 0 ? a - 1 : void 0);
- u(this, p, F(t.url, y));
- const c = i(this, v).isSegmentLoadable(i(this, p));
- if (!i(this, v).hasSegment(i(this, p)) || c === !1) return u(this, g, i(this, C).call(this)), i(this, g).stats = this.stats, void ((L = i(this, g)) == null ? void 0 : L.load(t, e, s));
- i(this, v).loadSegment(i(this, p), { onSuccess: (d) => {
- u(this, f, d);
- const E = i(this, f).data.byteLength;
- o.loading = function(I, w, S) {
- const P = 8e3 * w / I, M = S - P;
- return { start: M - 10, first: M, end: S };
- }(i(this, f).bandwidth, E, performance.now()), o.total = o.loaded = E, s.onProgress && s.onProgress(this.stats, t, i(this, f).data, void 0), s.onSuccess({ data: i(this, f).data, url: t.url }, this.stats, t, void 0);
- }, onError: (d) => {
- d instanceof T && d.type === "aborted" && this.stats.aborted || x(this, b, G).call(this, d);
+ const { stats: o } = this, { rangeStart: d, rangeEnd: a } = t, E = J(d, a !== void 0 ? a - 1 : void 0);
+ u(this, m, F(t.url, E));
+ const h = i(this, y).isSegmentLoadable(i(this, m));
+ if (!i(this, y).hasSegment(i(this, m)) || !h) return u(this, g, i(this, M).call(this)), i(this, g).stats = this.stats, void i(this, g).load(t, e, s);
+ i(this, y).loadSegment(i(this, m), { onSuccess: (f) => {
+ u(this, p, f);
+ const c = i(this, p).data.byteLength;
+ o.loading = function(L, C, I) {
+ const w = 8e3 * C / L, S = I - w;
+ return { start: S - 10, first: S, end: I };
+ }(i(this, p).bandwidth, c, performance.now()), o.total = c, o.loaded = c, s.onProgress && s.onProgress(this.stats, t, i(this, p).data, void 0), s.onSuccess({ data: i(this, p).data, url: t.url }, this.stats, t, void 0);
+ }, onError: (f) => {
+ f instanceof T && f.type === "aborted" && this.stats.aborted || x(this, b, G).call(this, f);
} });
}
abort() {
var t, e;
- i(this, g) ? i(this, g).abort() : (x(this, b, U).call(this), (e = (t = i(this, H)) == null ? void 0 : t.onAbort) == null || e.call(t, this.stats, this.context, {}));
+ i(this, g) ? i(this, g).abort() : (x(this, b, A).call(this), (e = (t = i(this, H)) == null ? void 0 : t.onAbort) == null || e.call(t, this.stats, this.context, {}));
}
destroy() {
- i(this, g) ? i(this, g).destroy() : (this.stats.aborted || x(this, b, U).call(this), u(this, H, null), this.config = null);
+ i(this, g) ? i(this, g).destroy() : (this.stats.aborted || x(this, b, A).call(this), u(this, H, null), this.config = null);
}
}
-H = new WeakMap(), C = new WeakMap(), g = new WeakMap(), v = new WeakMap(), f = new WeakMap(), p = new WeakMap(), b = new WeakSet(), G = function(t) {
+H = new WeakMap(), M = new WeakMap(), g = new WeakMap(), y = new WeakMap(), p = new WeakMap(), m = new WeakMap(), b = new WeakSet(), G = function(t) {
var s;
const e = { code: 0, text: "" };
(t instanceof T && t.type === "failed" || t instanceof Error) && (e.text = t.message), (s = i(this, H)) == null || s.onError(e, this.context, null, this.stats);
-}, U = function() {
- !i(this, f) && i(this, p) && (this.stats.aborted = !0, i(this, v).abortSegmentLoading(i(this, p)));
+}, A = function() {
+ !i(this, p) && i(this, m) && (this.stats.aborted = !0, i(this, y).abortSegmentLoading(i(this, m)));
};
-var m;
+var v;
class X {
constructor(t) {
- l(this, m);
+ l(this, v);
r(this, "context");
r(this, "stats");
- u(this, m, new t.loader(t)), this.stats = i(this, m).stats, this.context = i(this, m).context;
+ u(this, v, new t.loader(t)), this.stats = i(this, v).stats, this.context = i(this, v).context;
}
load(t, e, s) {
- i(this, m).load(t, e, s);
+ i(this, v).load(t, e, s);
}
abort() {
- i(this, m).abort();
+ i(this, v).abort();
}
destroy() {
- i(this, m).destroy();
+ i(this, v).destroy();
}
}
-m = new WeakMap();
+v = new WeakMap();
class K {
constructor(t) {
r(this, "core");
@@ -86,26 +85,25 @@ class K {
}
processMainManifest(t) {
const { levels: e, audioTracks: s } = t;
- for (const [o, h] of e.entries()) {
- const { url: a } = h;
+ for (const [o, d] of e.entries()) {
+ const { url: a } = d;
this.core.addStreamIfNoneExists({ runtimeId: Array.isArray(a) ? a[0] : a, type: "main", index: o });
}
- for (const [o, h] of s.entries()) {
- const { url: a } = h;
+ for (const [o, d] of s.entries()) {
+ const { url: a } = d;
this.core.addStreamIfNoneExists({ runtimeId: Array.isArray(a) ? a[0] : a, type: "secondary", index: o });
}
}
updatePlaylist(t) {
- if (!t.details) return;
- const { details: { url: e, fragments: s, live: o } } = t, h = this.core.getStream(e);
- if (!h) return;
- const a = new Set(h.segments.keys()), y = [];
- s.forEach((c, L) => {
- const { url: d, byteRange: E, sn: I, start: w, end: S } = c;
- if (I === "initSegment") return;
- const [P, M] = E, k = J(P, M !== void 0 ? M - 1 : void 0), D = F(d, k);
- a.delete(D), h.segments.has(D) || y.push({ runtimeId: D, url: d, externalId: o ? I : L, byteRange: k, startTime: w, endTime: S });
- }), (y.length || a.size) && this.core.updateStream(e, y, a.values());
+ const { details: { url: e, fragments: s, live: o } } = t, d = this.core.getStream(e);
+ if (!d) return;
+ const a = new Set(d.segments.keys()), E = [];
+ s.forEach((h, f) => {
+ const { url: c, byteRange: L, sn: C, start: I, end: w } = h;
+ if (C === "initSegment") return;
+ const [S, P] = L, U = J(S, P !== void 0 ? P - 1 : void 0), k = F(c, U);
+ a.delete(k), d.segments.has(k) || E.push({ runtimeId: k, url: c, externalId: o ? C : f, byteRange: U, startTime: I, endTime: w });
+ }), (E.length || a.size) && this.core.updateStream(e, E, a.values());
}
}
class $ {
@@ -152,11 +150,11 @@ class $ {
var s, o;
return e = t, o = class extends e {
constructor(...a) {
- var E;
- const y = a[0], { p2p: c, ...L } = y ?? {}, d = new $(c);
- super({ ...L, ...d.getConfigForHlsJs() });
+ var L;
+ const E = a[0], { p2p: h, ...f } = E ?? {}, c = new $(h);
+ super({ ...f, ...c.getConfigForHlsJs() });
l(this, s);
- d.bindHls(this), u(this, s, d), (E = c == null ? void 0 : c.onHlsJsCreated) == null || E.call(c, this);
+ c.bindHls(this), u(this, s, c), (L = h == null ? void 0 : h.onHlsJsCreated) == null || L.call(h, this);
}
get p2pEngine() {
return i(this, s);
@@ -194,7 +192,7 @@ class $ {
e[s]("hlsManifestLoaded", this.handleManifestLoaded), e[s]("hlsLevelSwitching", this.handleLevelSwitching), e[s]("hlsLevelUpdated", this.handleLevelUpdated), e[s]("hlsAudioTrackLoaded", this.handleLevelUpdated), e[s]("hlsDestroying", this.destroy), e[s]("hlsMediaAttaching", this.destroyCore), e[s]("hlsManifestLoading", this.destroyCore), e[s]("hlsMediaDetached", this.handleMediaDetached), e[s]("hlsMediaAttached", this.handleMediaAttached);
}
createFragmentLoaderClass() {
- const t = this.core, e = this;
+ const { core: t } = this, e = this;
return class extends B {
constructor(s) {
super(s, t);