diff --git a/THIRD_PARTY.txt b/THIRD_PARTY.txt
index 79104146..062982d0 100644
--- a/THIRD_PARTY.txt
+++ b/THIRD_PARTY.txt
@@ -1453,9 +1453,9 @@ https://cdn.jsdelivr.net/npm/ngx-bootstrap@18.0.2/datepicker/bs-datepicker.css
https://cdn.jsdelivr.net/npm/ngx-bootstrap@6.2.0/datepicker/bs-datepicker.css
https://cdn.jsdelivr.net/npm/object-assign@4.1.1/index.js
https://cdn.jsdelivr.net/npm/p2p-media-loader-core@0.6.2/build/p2p-media-loader-core.min.js
-https://cdn.jsdelivr.net/npm/p2p-media-loader-core@1.0.3/dist/p2p-media-loader-core.es.min.js
+https://cdn.jsdelivr.net/npm/p2p-media-loader-core@1.0.4/dist/p2p-media-loader-core.es.min.js
https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@0.6.2/build/p2p-media-loader-hlsjs.min.js
-https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@1.0.3/dist/p2p-media-loader-hlsjs.es.min.js
+https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@1.0.4/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 cb205c9f..cbb2fe12 100644
--- a/modules/internal/targets.js
+++ b/modules/internal/targets.js
@@ -368,7 +368,7 @@ targets.setLastVersion = function (type, version) {
if (type.startsWith('/owl-carousel/2.')) return '2.3.4';
if (type.startsWith('/p2p-media-loader-core') || type.startsWith('/p2p-media-loader-hlsjs')) {
if (helpers.compareVersion('0.6.2', version)) return '0.6.2'; // <= v0.6.2
- return '1.0.3';
+ return '1.0.4';
}
if (type.startsWith('/p5.js/0.')) return '0.10.2';
if (type.startsWith('/p5.js/1.')) return '1.9.4';
diff --git a/pages/updates/updates.html b/pages/updates/updates.html
index 61dd1337..eadc0b78 100644
--- a/pages/updates/updates.html
+++ b/pages/updates/updates.html
@@ -45,6 +45,7 @@
jsrender v1.0.14 -> v1.0.15
libphonenumber-js v1.11.4 -> v1.11.5
ngx-bootstrap v18.0.0 -> v18.0.2
+ p2p-media-loader-core & p2p-media-loader-hlsjs v1.0.3 -> v1.0.4
Added
diff --git a/resources/p2p-media-loader-core/1.0.3/p2p-media-loader-core.min.jsm b/resources/p2p-media-loader-core/1.0.4/p2p-media-loader-core.min.jsm
similarity index 83%
rename from resources/p2p-media-loader-core/1.0.3/p2p-media-loader-core.min.jsm
rename to resources/p2p-media-loader-core/1.0.4/p2p-media-loader-core.min.jsm
index a1b65dd4..6de5ee5c 100644
--- a/resources/p2p-media-loader-core/1.0.3/p2p-media-loader-core.min.jsm
+++ b/resources/p2p-media-loader-core/1.0.4/p2p-media-loader-core.min.jsm
@@ -1,7 +1,7 @@
var zn = Object.defineProperty;
var Vn = (s, t, e) => t in s ? zn(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
var f = (s, t, e) => Vn(s, typeof t != "symbol" ? t + "" : t, e);
-class I extends Error {
+class R extends Error {
constructor(e, n) {
super(n);
f(this, "timestamp");
@@ -39,9 +39,9 @@ class Gn {
const { requestControls: o } = this;
o.firstBytesReceived();
const a = i.body.getReader();
- for await (const h of async function* (u) {
+ for await (const h of async function* (g) {
for (; ; ) {
- const { done: d, value: p } = await u.read();
+ const { done: d, value: p } = await g.read();
if (d) break;
yield p;
}
@@ -52,24 +52,24 @@ class Gn {
}
}
handleResponseHeaders(t) {
- if (!t.ok) throw t.status === 406 ? (this.request.clearLoadedBytes(), new I("http-bytes-mismatch", t.statusText)) : new I("http-error", t.statusText);
+ if (!t.ok) throw t.status === 406 ? (this.request.clearLoadedBytes(), new R("http-bytes-mismatch", t.statusText)) : new R("http-error", t.statusText);
const { requestByteRange: e } = this;
if (e) if (t.status === 200) {
- if (this.request.segment.byteRange) throw new I("http-unexpected-status-code");
+ if (this.request.segment.byteRange) throw new R("http-unexpected-status-code");
this.request.clearLoadedBytes();
} else {
- if (t.status !== 206) throw new I("http-unexpected-status-code", t.statusText);
+ if (t.status !== 206) throw new R("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 I("http-bytes-mismatch", t.statusText);
+ if (n && this.expectedBytesLength !== void 0 && this.expectedBytesLength !== +n) throw this.request.clearLoadedBytes(), new R("http-bytes-mismatch", t.statusText);
const r = t.headers.get("Content-Range"), i = r ? function(o) {
const a = o.trim().match(/^bytes (?:(?:(\d+)|)-(?:(\d+)|)|\*)\/(?:(\d+)|\*)$/);
if (!a) return;
- const [, h, u, d] = a;
- return { from: h ? parseInt(h) : void 0, to: u ? parseInt(u) : void 0, total: d ? parseInt(d) : void 0 };
+ const [, h, g, d] = a;
+ return { from: h ? parseInt(h) : void 0, to: g ? parseInt(g) : void 0, total: d ? parseInt(d) : void 0 };
}(r) : void 0;
if (i) {
const { from: o, to: a, total: h } = i;
- if (h !== void 0 && this.request.totalBytes !== h || o !== void 0 && e.start !== o || a !== void 0 && e.end !== void 0 && e.end !== a) throw this.request.clearLoadedBytes(), new I("http-bytes-mismatch", t.statusText);
+ if (h !== void 0 && this.request.totalBytes !== h || o !== void 0 && e.start !== o || a !== void 0 && e.end !== void 0 && e.end !== a) throw this.request.clearLoadedBytes(), new R("http-bytes-mismatch", t.statusText);
}
}
if (t.status === 200 && this.request.totalBytes === void 0) {
@@ -80,7 +80,7 @@ class Gn {
handleError(t) {
if (t instanceof Error) {
if (t.name !== "abort") return;
- const e = t instanceof I ? t : new I("http-error", t.message);
+ const e = t instanceof R ? t : new R("http-error", t.message);
this.requestControls.abortOnError(e);
}
}
@@ -150,7 +150,7 @@ function rn() {
function pe(s, t) {
this.fun = s, this.array = t;
}
-function O() {
+function q() {
}
v.nextTick = function(s) {
var t = new Array(arguments.length - 1);
@@ -158,7 +158,7 @@ v.nextTick = function(s) {
M.push(new pe(s, t)), M.length !== 1 || J || sn(rn);
}, pe.prototype.run = function() {
this.fun.apply(null, this.array);
-}, v.title = "browser", v.browser = !0, v.env = {}, v.argv = [], v.version = "", v.versions = {}, v.on = O, v.addListener = O, v.once = O, v.off = O, v.removeListener = O, v.removeAllListeners = O, v.emit = O, v.prependListener = O, v.prependOnceListener = O, v.listeners = function(s) {
+}, v.title = "browser", v.browser = !0, v.env = {}, v.argv = [], v.version = "", v.versions = {}, v.on = q, v.addListener = q, v.once = q, v.off = q, v.removeListener = q, v.removeAllListeners = q, v.emit = q, v.prependListener = q, v.prependOnceListener = q, v.listeners = function(s) {
return [];
}, v.binding = function(s) {
throw new Error("process.binding is not supported");
@@ -179,64 +179,64 @@ function Xn() {
if (ye) return me;
ye = 1;
var s = 1e3, t = 60 * s, e = 60 * t, n = 24 * e, r = 7 * n, i = 365.25 * n;
- function o(a, h, u, d) {
- var p = h >= 1.5 * u;
- return Math.round(a / u) + " " + d + (p ? "s" : "");
+ function o(a, h, g, d) {
+ var p = h >= 1.5 * g;
+ return Math.round(a / g) + " " + d + (p ? "s" : "");
}
return me = function(a, h) {
h = h || {};
- var u = typeof a;
- if (u === "string" && a.length > 0) return function(d) {
+ var g = typeof a;
+ if (g === "string" && a.length > 0) return function(d) {
if (!((d = String(d)).length > 100)) {
var p = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);
if (p) {
- var _ = parseFloat(p[1]);
+ var y = parseFloat(p[1]);
switch ((p[2] || "ms").toLowerCase()) {
case "years":
case "year":
case "yrs":
case "yr":
case "y":
- return _ * i;
+ return y * i;
case "weeks":
case "week":
case "w":
- return _ * r;
+ return y * r;
case "days":
case "day":
case "d":
- return _ * n;
+ return y * n;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h":
- return _ * e;
+ return y * e;
case "minutes":
case "minute":
case "mins":
case "min":
case "m":
- return _ * t;
+ return y * t;
case "seconds":
case "second":
case "secs":
case "sec":
case "s":
- return _ * s;
+ return y * s;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms":
- return _;
+ return y;
default:
return;
}
}
}
}(a);
- if (u === "number" && isFinite(a)) return h.long ? function(d) {
+ if (g === "number" && isFinite(a)) return h.long ? function(d) {
var p = Math.abs(d);
return p >= n ? o(d, p, n, "day") : p >= e ? o(d, p, e, "hour") : p >= t ? o(d, p, t, "minute") : p >= s ? o(d, p, s, "second") : d + " ms";
}(a) : function(d) {
@@ -249,25 +249,25 @@ function Xn() {
var Zn = function(s) {
function t(r) {
let i, o, a, h = null;
- function u(...d) {
- if (!u.enabled) return;
- const p = u, _ = Number(/* @__PURE__ */ new Date()), S = _ - (i || _);
- p.diff = S, p.prev = i, p.curr = _, i = _, d[0] = t.coerce(d[0]), typeof d[0] != "string" && d.unshift("%O");
+ function g(...d) {
+ if (!g.enabled) return;
+ const p = g, y = Number(/* @__PURE__ */ new Date()), w = y - (i || y);
+ p.diff = w, p.prev = i, p.curr = y, i = y, d[0] = t.coerce(d[0]), typeof d[0] != "string" && d.unshift("%O");
let c = 0;
- d[0] = d[0].replace(/%([a-zA-Z%])/g, (g, l) => {
- if (g === "%%") return "%";
+ d[0] = d[0].replace(/%([a-zA-Z%])/g, (u, l) => {
+ if (u === "%%") return "%";
c++;
const m = t.formatters[l];
if (typeof m == "function") {
- const y = d[c];
- g = m.call(p, y), d.splice(c, 1), c--;
+ const _ = d[c];
+ u = m.call(p, _), d.splice(c, 1), c--;
}
- return g;
+ return u;
}), t.formatArgs.call(p, d), (p.log || t.log).apply(p, d);
}
- return u.namespace = r, u.useColors = t.useColors(), u.color = t.selectColor(r), 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(r)), a), set: (d) => {
+ return g.namespace = r, g.useColors = t.useColors(), g.color = t.selectColor(r), g.extend = e, g.destroy = t.destroy, Object.defineProperty(g, "enabled", { enumerable: !0, configurable: !1, get: () => h !== null ? h : (o !== t.namespaces && (o = t.namespaces, a = t.enabled(r)), a), set: (d) => {
h = d;
- } }), typeof t.init == "function" && t.init(u), u;
+ } }), typeof t.init == "function" && t.init(g), g;
}
function e(r, i) {
const o = t(this.namespace + (i === void 0 ? ":" : i) + r);
@@ -359,10 +359,10 @@ an = Y && typeof Y.ownKeys == "function" ? Y.ownKeys : Object.getOwnPropertySymb
var be = Number.isNaN || function(s) {
return s != s;
};
-function w() {
- w.init.call(this);
+function S() {
+ S.init.call(this);
}
-zt.exports = w, zt.exports.once = function(s, t) {
+zt.exports = S, zt.exports.once = function(s, t) {
return new Promise(function(e, n) {
function r(o) {
s.removeListener(t, i), n(o);
@@ -374,13 +374,13 @@ zt.exports = w, zt.exports.once = function(s, t) {
typeof o.on == "function" && ke(o, "error", a, h);
}(s, r, { once: !0 });
});
-}, w.EventEmitter = w, w.prototype._events = void 0, w.prototype._eventsCount = 0, w.prototype._maxListeners = void 0;
+}, S.EventEmitter = S, S.prototype._events = void 0, S.prototype._eventsCount = 0, S.prototype._maxListeners = void 0;
var we = 10;
function St(s) {
if (typeof s != "function") throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof s);
}
function hn(s) {
- return s._maxListeners === void 0 ? w.defaultMaxListeners : s._maxListeners;
+ return s._maxListeners === void 0 ? S.defaultMaxListeners : s._maxListeners;
}
function Se(s, t, e, n) {
var r, i, o, a;
@@ -430,19 +430,19 @@ function ke(s, t, e, n) {
});
}
}
-Object.defineProperty(w, "defaultMaxListeners", { enumerable: !0, get: function() {
+Object.defineProperty(S, "defaultMaxListeners", { enumerable: !0, get: function() {
return we;
}, set: function(s) {
if (typeof s != "number" || s < 0 || be(s)) throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + s + ".");
we = s;
-} }), w.init = function() {
+} }), S.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;
-}, w.prototype.setMaxListeners = function(s) {
+}, S.prototype.setMaxListeners = function(s) {
if (typeof s != "number" || s < 0 || be(s)) throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + s + ".");
return this._maxListeners = s, this;
-}, w.prototype.getMaxListeners = function() {
+}, S.prototype.getMaxListeners = function() {
return hn(this);
-}, w.prototype.emit = function(s) {
+}, S.prototype.emit = function(s) {
for (var t = [], e = 1; e < arguments.length; e++) t.push(arguments[e]);
var n = s === "error", r = this._events;
if (r !== void 0) n = n && r.error === void 0;
@@ -457,19 +457,19 @@ Object.defineProperty(w, "defaultMaxListeners", { enumerable: !0, get: function(
if (a === void 0) return !1;
if (typeof a == "function") _e(a, this, t);
else {
- var h = a.length, u = cn(a, h);
- for (e = 0; e < h; ++e) _e(u[e], this, t);
+ var h = a.length, g = cn(a, h);
+ for (e = 0; e < h; ++e) _e(g[e], this, t);
}
return !0;
-}, w.prototype.addListener = function(s, t) {
+}, S.prototype.addListener = function(s, t) {
return Se(this, s, t, !1);
-}, w.prototype.on = w.prototype.addListener, w.prototype.prependListener = function(s, t) {
+}, S.prototype.on = S.prototype.addListener, S.prototype.prependListener = function(s, t) {
return Se(this, s, t, !0);
-}, w.prototype.once = function(s, t) {
+}, S.prototype.once = function(s, t) {
return St(t), this.on(s, Ce(this, s, t)), this;
-}, w.prototype.prependOnceListener = function(s, t) {
+}, S.prototype.prependOnceListener = function(s, t) {
return St(t), this.prependListener(s, Ce(this, s, t)), this;
-}, w.prototype.removeListener = function(s, t) {
+}, S.prototype.removeListener = function(s, t) {
var e, n, r, i, o;
if (St(t), (n = this._events) === void 0) return this;
if ((e = n[s]) === void 0) return this;
@@ -486,7 +486,7 @@ Object.defineProperty(w, "defaultMaxListeners", { enumerable: !0, get: function(
}(e, r), e.length === 1 && (n[s] = e[0]), n.removeListener !== void 0 && this.emit("removeListener", s, o || t);
}
return this;
-}, w.prototype.off = w.prototype.removeListener, w.prototype.removeAllListeners = function(s) {
+}, S.prototype.off = S.prototype.removeListener, S.prototype.removeAllListeners = function(s) {
var t, e, n;
if ((e = this._events) === void 0) return this;
if (e.removeListener === void 0) return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : e[s] !== void 0 && (--this._eventsCount == 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete e[s]), this;
@@ -498,13 +498,13 @@ Object.defineProperty(w, "defaultMaxListeners", { enumerable: !0, get: function(
if (typeof (t = e[s]) == "function") this.removeListener(s, t);
else if (t !== void 0) for (n = t.length - 1; n >= 0; n--) this.removeListener(s, t[n]);
return this;
-}, w.prototype.listeners = function(s) {
+}, S.prototype.listeners = function(s) {
return ve(this, s, !0);
-}, w.prototype.rawListeners = function(s) {
+}, S.prototype.rawListeners = function(s) {
return ve(this, s, !1);
-}, w.listenerCount = function(s, t) {
+}, S.listenerCount = function(s, t) {
return typeof s.listenerCount == "function" ? s.listenerCount(t) : Le.call(s, t);
-}, w.prototype.listenerCount = Le, w.prototype.eventNames = function() {
+}, S.prototype.listenerCount = Le, S.prototype.eventNames = function() {
return this._eventsCount > 0 ? an(this._events) : [];
};
var dn = zt.exports;
@@ -553,25 +553,25 @@ var ss = function(s, t) {
let e, n, r, i = !0;
Array.isArray(s) ? (e = [], n = s.length) : (r = Object.keys(s), e = {}, n = r.length);
function o(h) {
- function u() {
+ function g() {
t && t(h, e), t = null;
}
- i ? rs(u) : u();
+ i ? rs(g) : g();
}
- function a(h, u, d) {
- e[h] = d, (--n == 0 || u) && o(u);
+ function a(h, g, d) {
+ e[h] = d, (--n == 0 || g) && o(g);
}
n ? r ? r.forEach(function(h) {
- s[h](function(u, d) {
- a(h, u, d);
+ s[h](function(g, d) {
+ a(h, g, d);
});
- }) : s.forEach(function(h, u) {
+ }) : s.forEach(function(h, g) {
h(function(d, p) {
- a(u, d, p);
+ a(g, d, p);
});
}) : o(null), i = !1;
};
-const rs = ln, is = V(ss), F = typeof window < "u" ? window : self, Jt = F.RTCPeerConnection || F.mozRTCPeerConnection || F.webkitRTCPeerConnection, os = F.RTCSessionDescription || F.mozRTCSessionDescription || F.webkitRTCSessionDescription, as = F.RTCIceCandidate || F.mozRTCIceCandidate || F.webkitRTCIceCandidate;
+const rs = ln, is = V(ss), U = typeof window < "u" ? window : self, Jt = U.RTCPeerConnection || U.mozRTCPeerConnection || U.webkitRTCPeerConnection, os = U.RTCSessionDescription || U.mozRTCSessionDescription || U.webkitRTCSessionDescription, as = U.RTCIceCandidate || U.mozRTCIceCandidate || U.webkitRTCIceCandidate;
var hs = typeof queueMicrotask == "function" ? queueMicrotask : (s) => Promise.resolve().then(s);
const Te = class {
constructor(s) {
@@ -596,36 +596,36 @@ const Te = class {
}
};
var Yt = { exports: {} };
-function Re(s) {
+function Ie(s) {
return s.length;
}
-var cs = { byteLength: Re, toString: function(s) {
+var cs = { byteLength: Ie, toString: function(s) {
const t = s.byteLength;
let e = "";
for (let n = 0; n < t; n++) e += String.fromCharCode(s[n]);
return e;
-}, write: function(s, t, e = 0, n = Re(t)) {
+}, write: function(s, t, e = 0, n = Ie(t)) {
const r = Math.min(n, s.byteLength - e);
for (let i = 0; i < r; i++) s[e + i] = t.charCodeAt(i);
return r;
} };
const nt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", W = new Uint8Array(256);
for (let s = 0; s < 64; s++) W[nt.charCodeAt(s)] = s;
-function Ie(s) {
+function Re(s) {
let t = s.length;
return s.charCodeAt(t - 1) === 61 && t--, t > 1 && s.charCodeAt(t - 1) === 61 && t--, 3 * t >>> 2;
}
W[45] = 62, W[95] = 63;
-var ds = { byteLength: Ie, toString: function(s) {
+var ds = { byteLength: Re, toString: function(s) {
const t = s.byteLength;
let e = "";
for (let n = 0; n < t; n += 3) e += nt[s[n] >> 2] + nt[(3 & s[n]) << 4 | s[n + 1] >> 4] + nt[(15 & s[n + 1]) << 2 | s[n + 2] >> 6] + nt[63 & s[n + 2]];
return t % 3 == 2 ? e = e.substring(0, e.length - 1) + "=" : t % 3 == 1 && (e = e.substring(0, e.length - 2) + "=="), e;
-}, write: function(s, t, e = 0, n = Ie(t)) {
+}, write: function(s, t, e = 0, n = Re(t)) {
const r = Math.min(n, s.byteLength - e);
for (let i = 0, o = 0; o < r; i += 4) {
- const a = W[t.charCodeAt(i)], h = W[t.charCodeAt(i + 1)], u = W[t.charCodeAt(i + 2)], d = W[t.charCodeAt(i + 3)];
- s[o++] = a << 2 | h >> 4, s[o++] = (15 & h) << 4 | u >> 2, s[o++] = (3 & u) << 6 | 63 & d;
+ const a = W[t.charCodeAt(i)], h = W[t.charCodeAt(i + 1)], g = W[t.charCodeAt(i + 2)], d = W[t.charCodeAt(i + 3)];
+ s[o++] = a << 2 | h >> 4, s[o++] = (15 & h) << 4 | g >> 2, s[o++] = (3 & g) << 6 | 63 & d;
}
return r;
} };
@@ -706,27 +706,27 @@ if (typeof TextEncoder < "u") {
s[o++] = a, i++;
continue;
}
- let h = 0, u = 0;
- for (a <= 2047 ? (h = 6, u = 192) : a <= 65535 ? (h = 12, u = 224) : a <= 2097151 && (h = 18, u = 240), s[o++] = u | a >> h, h -= 6; h >= 0; ) s[o++] = 128 | a >> h & 63, h -= 6;
+ let h = 0, g = 0;
+ for (a <= 2047 ? (h = 6, g = 192) : a <= 65535 ? (h = 12, g = 224) : a <= 2097151 && (h = 18, g = 240), s[o++] = g | a >> h, h -= 6; h >= 0; ) s[o++] = 128 | a >> h & 63, h -= 6;
i += a >= 65536 ? 2 : 1;
}
return r;
};
var ls = { byteLength: Kt, toString: Xt, write: Zt };
-function Oe(s) {
+function qe(s) {
return 2 * s.length;
}
-var gs = { byteLength: Oe, toString: function(s) {
+var gs = { byteLength: qe, toString: function(s) {
const t = s.byteLength;
let e = "";
for (let n = 0; n < t - 1; n += 2) e += String.fromCharCode(s[n] + 256 * s[n + 1]);
return e;
-}, write: function(s, t, e = 0, n = Oe(t)) {
+}, write: function(s, t, e = 0, n = qe(t)) {
const r = Math.min(n, s.byteLength - e);
let i = r;
for (let o = 0; o < t.length && !((i -= 2) < 0); ++o) {
- const a = t.charCodeAt(o), h = a >> 8, u = a % 256;
- s[e + 2 * o] = u, s[e + 2 * o + 1] = h;
+ const a = t.charCodeAt(o), h = a >> 8, g = a % 256;
+ s[e + 2 * o] = g, s[e + 2 * o + 1] = h;
}
return r;
} };
@@ -753,45 +753,45 @@ var gs = { byteLength: Oe, toString: function(s) {
throw new Error(`Unknown encoding: ${c}`);
}
}
- function u(c) {
+ function g(c) {
return c instanceof Uint8Array;
}
- function d(c, g, l) {
- return typeof c == "string" ? function(m, y) {
- const b = h(y), L = new Uint8Array(b.byteLength(m));
+ function d(c, u, l) {
+ return typeof c == "string" ? function(m, _) {
+ const b = h(_), L = new Uint8Array(b.byteLength(m));
return b.write(L, m, 0, L.byteLength), L;
- }(c, g) : Array.isArray(c) ? function(m) {
- const y = new Uint8Array(m.length);
- return y.set(m), y;
+ }(c, u) : Array.isArray(c) ? function(m) {
+ const _ = new Uint8Array(m.length);
+ return _.set(m), _;
}(c) : ArrayBuffer.isView(c) ? function(m) {
- const y = new Uint8Array(m.byteLength);
- return y.set(m), y;
- }(c) : function(m, y, b) {
- return new Uint8Array(m, y, b);
- }(c, g, l);
+ const _ = new Uint8Array(m.byteLength);
+ return _.set(m), _;
+ }(c) : function(m, _, b) {
+ return new Uint8Array(m, _, b);
+ }(c, u, l);
}
- function p(c, g, l, m, y) {
+ function p(c, u, l, m, _) {
if (c.byteLength === 0) return -1;
- if (typeof l == "string" ? (m = l, l = 0) : l === void 0 ? l = y ? 0 : c.length - 1 : l < 0 && (l += c.byteLength), l >= c.byteLength) {
- if (y) return -1;
+ if (typeof l == "string" ? (m = l, l = 0) : l === void 0 ? l = _ ? 0 : c.length - 1 : l < 0 && (l += c.byteLength), l >= c.byteLength) {
+ if (_) return -1;
l = c.byteLength - 1;
} else if (l < 0) {
- if (!y) return -1;
+ if (!_) return -1;
l = 0;
}
- if (typeof g == "string") g = d(g, m);
- else if (typeof g == "number") return g &= 255, y ? c.indexOf(g, l) : c.lastIndexOf(g, l);
- if (g.byteLength === 0) return -1;
- if (y) {
+ if (typeof u == "string") u = d(u, m);
+ else if (typeof u == "number") return u &= 255, _ ? c.indexOf(u, l) : c.lastIndexOf(u, l);
+ if (u.byteLength === 0) return -1;
+ if (_) {
let b = -1;
- for (let L = l; L < c.byteLength; L++) if (c[L] === g[b === -1 ? 0 : L - b]) {
- if (b === -1 && (b = L), L - b + 1 === g.byteLength) return b;
+ for (let L = l; L < c.byteLength; L++) if (c[L] === u[b === -1 ? 0 : L - b]) {
+ if (b === -1 && (b = L), L - b + 1 === u.byteLength) return b;
} else b !== -1 && (L -= L - b), b = -1;
} else {
- l + g.byteLength > c.byteLength && (l = c.byteLength - g.byteLength);
+ l + u.byteLength > c.byteLength && (l = c.byteLength - u.byteLength);
for (let b = l; b >= 0; b--) {
let L = !0;
- for (let dt = 0; dt < g.byteLength; dt++) if (c[b + dt] !== g[dt]) {
+ for (let dt = 0; dt < u.byteLength; dt++) if (c[b + dt] !== u[dt]) {
L = !1;
break;
}
@@ -800,121 +800,121 @@ var gs = { byteLength: Oe, toString: function(s) {
}
return -1;
}
- function _(c, g, l, m) {
- return p(c, g, l, m, !0);
+ function y(c, u, l, m) {
+ return p(c, u, l, m, !0);
}
- function S(c, g, l) {
- const m = c[g];
- c[g] = c[l], c[l] = m;
+ function w(c, u, l) {
+ const m = c[u];
+ c[u] = c[l], c[l] = m;
}
- s.exports = t = { isBuffer: u, isEncoding: function(c) {
+ s.exports = t = { isBuffer: g, isEncoding: function(c) {
try {
return h(c), !0;
} catch {
return !1;
}
- }, alloc: function(c, g, l) {
+ }, alloc: function(c, u, l) {
const m = new Uint8Array(c);
- return g !== void 0 && t.fill(m, g, 0, m.byteLength, l), m;
+ return u !== void 0 && t.fill(m, u, 0, m.byteLength, l), m;
}, allocUnsafe: function(c) {
return new Uint8Array(c);
}, allocUnsafeSlow: function(c) {
return new Uint8Array(c);
- }, byteLength: function(c, g) {
- return h(g).byteLength(c);
- }, compare: function(c, g) {
- if (c === g) return 0;
- const l = Math.min(c.byteLength, g.byteLength);
- c = new DataView(c.buffer, c.byteOffset, c.byteLength), g = new DataView(g.buffer, g.byteOffset, g.byteLength);
+ }, byteLength: function(c, u) {
+ return h(u).byteLength(c);
+ }, compare: function(c, u) {
+ if (c === u) return 0;
+ const l = Math.min(c.byteLength, u.byteLength);
+ c = new DataView(c.buffer, c.byteOffset, c.byteLength), u = new DataView(u.buffer, u.byteOffset, u.byteLength);
let m = 0;
- for (let y = l - l % 4; m < y && c.getUint32(m, a) === g.getUint32(m, a); m += 4)
+ for (let _ = l - l % 4; m < _ && c.getUint32(m, a) === u.getUint32(m, a); m += 4)
;
for (; m < l; m++) {
- const y = c.getUint8(m), b = g.getUint8(m);
- if (y < b) return -1;
- if (y > b) return 1;
+ const _ = c.getUint8(m), b = u.getUint8(m);
+ if (_ < b) return -1;
+ if (_ > b) return 1;
}
- return c.byteLength > g.byteLength ? 1 : c.byteLength < g.byteLength ? -1 : 0;
- }, concat: function(c, g) {
- g === void 0 && (g = c.reduce((y, b) => y + b.byteLength, 0));
- const l = new Uint8Array(g);
+ return c.byteLength > u.byteLength ? 1 : c.byteLength < u.byteLength ? -1 : 0;
+ }, concat: function(c, u) {
+ u === void 0 && (u = c.reduce((_, b) => _ + b.byteLength, 0));
+ const l = new Uint8Array(u);
let m = 0;
- for (const y of c) {
- if (m + y.byteLength > l.byteLength) {
- const b = y.subarray(0, l.byteLength - m);
+ for (const _ of c) {
+ if (m + _.byteLength > l.byteLength) {
+ const b = _.subarray(0, l.byteLength - m);
return l.set(b, m), l;
}
- l.set(y, m), m += y.byteLength;
+ l.set(_, m), m += _.byteLength;
}
return l;
- }, copy: function(c, g, l = 0, m = 0, y = c.byteLength) {
- if (y > 0 && y < m || y === m || c.byteLength === 0 || g.byteLength === 0) return 0;
+ }, copy: function(c, u, l = 0, m = 0, _ = c.byteLength) {
+ if (_ > 0 && _ < m || _ === m || c.byteLength === 0 || u.byteLength === 0) return 0;
if (l < 0) throw new RangeError("targetStart is out of range");
if (m < 0 || m >= c.byteLength) throw new RangeError("sourceStart is out of range");
- if (y < 0) throw new RangeError("sourceEnd is out of range");
- l >= g.byteLength && (l = g.byteLength), y > c.byteLength && (y = c.byteLength), g.byteLength - l < y - m && (y = g.length - l + m);
- const b = y - m;
- return c === g ? g.copyWithin(l, m, y) : g.set(c.subarray(m, y), l), b;
- }, equals: function(c, g) {
- if (c === g) return !0;
- if (c.byteLength !== g.byteLength) return !1;
+ if (_ < 0) throw new RangeError("sourceEnd is out of range");
+ l >= u.byteLength && (l = u.byteLength), _ > c.byteLength && (_ = c.byteLength), u.byteLength - l < _ - m && (_ = u.length - l + m);
+ const b = _ - m;
+ return c === u ? u.copyWithin(l, m, _) : u.set(c.subarray(m, _), l), b;
+ }, equals: function(c, u) {
+ if (c === u) return !0;
+ if (c.byteLength !== u.byteLength) return !1;
const l = c.byteLength;
- c = new DataView(c.buffer, c.byteOffset, c.byteLength), g = new DataView(g.buffer, g.byteOffset, g.byteLength);
+ c = new DataView(c.buffer, c.byteOffset, c.byteLength), u = new DataView(u.buffer, u.byteOffset, u.byteLength);
let m = 0;
- for (let y = l - l % 4; m < y; m += 4) if (c.getUint32(m, a) !== g.getUint32(m, a)) return !1;
- for (; m < l; m++) if (c.getUint8(m) !== g.getUint8(m)) return !1;
+ for (let _ = l - l % 4; m < _; m += 4) if (c.getUint32(m, a) !== u.getUint32(m, a)) return !1;
+ for (; m < l; m++) if (c.getUint8(m) !== u.getUint8(m)) return !1;
return !0;
- }, fill: function(c, g, l, m, y) {
- if (typeof g == "string" ? typeof l == "string" ? (y = l, l = 0, m = c.byteLength) : typeof m == "string" && (y = m, m = c.byteLength) : typeof g == "number" ? g &= 255 : typeof g == "boolean" && (g = +g), l < 0 || c.byteLength < l || c.byteLength < m) throw new RangeError("Out of range index");
+ }, fill: function(c, u, l, m, _) {
+ if (typeof u == "string" ? typeof l == "string" ? (_ = l, l = 0, m = c.byteLength) : typeof m == "string" && (_ = m, m = c.byteLength) : typeof u == "number" ? u &= 255 : typeof u == "boolean" && (u = +u), l < 0 || c.byteLength < l || c.byteLength < m) throw new RangeError("Out of range index");
if (l === void 0 && (l = 0), m === void 0 && (m = c.byteLength), m <= l) return c;
- if (g || (g = 0), typeof g == "number") for (let b = l; b < m; ++b) c[b] = g;
+ if (u || (u = 0), typeof u == "number") for (let b = l; b < m; ++b) c[b] = u;
else {
- const b = (g = u(g) ? g : d(g, y)).byteLength;
- for (let L = 0; L < m - l; ++L) c[L + l] = g[L % b];
+ const b = (u = g(u) ? u : d(u, _)).byteLength;
+ for (let L = 0; L < m - l; ++L) c[L + l] = u[L % b];
}
return c;
- }, from: d, includes: function(c, g, l, m) {
- return _(c, g, l, m) !== -1;
- }, indexOf: _, lastIndexOf: function(c, g, l, m) {
- return p(c, g, l, m, !1);
+ }, from: d, includes: function(c, u, l, m) {
+ return y(c, u, l, m) !== -1;
+ }, indexOf: y, lastIndexOf: function(c, u, l, m) {
+ return p(c, u, l, m, !1);
}, swap16: function(c) {
- const g = c.byteLength;
- if (g % 2 != 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
- for (let l = 0; l < g; l += 2) S(c, l, l + 1);
+ const u = c.byteLength;
+ if (u % 2 != 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
+ for (let l = 0; l < u; l += 2) w(c, l, l + 1);
return c;
}, swap32: function(c) {
- const g = c.byteLength;
- if (g % 4 != 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
- for (let l = 0; l < g; l += 4) S(c, l, l + 3), S(c, l + 1, l + 2);
+ const u = c.byteLength;
+ if (u % 4 != 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
+ for (let l = 0; l < u; l += 4) w(c, l, l + 3), w(c, l + 1, l + 2);
return c;
}, swap64: function(c) {
- const g = c.byteLength;
- if (g % 8 != 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
- for (let l = 0; l < g; l += 8) S(c, l, l + 7), S(c, l + 1, l + 6), S(c, l + 2, l + 5), S(c, l + 3, l + 4);
+ const u = c.byteLength;
+ if (u % 8 != 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
+ for (let l = 0; l < u; l += 8) w(c, l, l + 7), w(c, l + 1, l + 6), w(c, l + 2, l + 5), w(c, l + 3, l + 4);
return c;
}, toBuffer: function(c) {
return c;
- }, toString: function(c, g, l = 0, m = c.byteLength) {
- const y = c.byteLength;
- return l >= y || m <= l ? "" : (l < 0 && (l = 0), m > y && (m = y), (l !== 0 || m < y) && (c = c.subarray(l, m)), h(g).toString(c));
- }, write: function(c, g, l, m, y) {
- return l === void 0 ? y = "utf8" : m === void 0 && typeof l == "string" ? (y = l, l = void 0) : y === void 0 && typeof m == "string" && (y = m, m = void 0), h(y).write(c, g, l, m);
- }, writeDoubleLE: function(c, g, l) {
- return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setFloat64(l, g, !0), l + 8;
- }, writeFloatLE: function(c, g, l) {
- return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setFloat32(l, g, !0), l + 4;
- }, writeUInt32LE: function(c, g, l) {
- return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setUint32(l, g, !0), l + 4;
- }, writeInt32LE: function(c, g, l) {
- return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setInt32(l, g, !0), l + 4;
- }, readDoubleLE: function(c, g) {
- return g === void 0 && (g = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getFloat64(g, !0);
- }, readFloatLE: function(c, g) {
- return g === void 0 && (g = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getFloat32(g, !0);
- }, readUInt32LE: function(c, g) {
- return g === void 0 && (g = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getUint32(g, !0);
- }, readInt32LE: function(c, g) {
- return g === void 0 && (g = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getInt32(g, !0);
+ }, toString: function(c, u, l = 0, m = c.byteLength) {
+ const _ = c.byteLength;
+ return l >= _ || m <= l ? "" : (l < 0 && (l = 0), m > _ && (m = _), (l !== 0 || m < _) && (c = c.subarray(l, m)), h(u).toString(c));
+ }, write: function(c, u, l, m, _) {
+ return l === void 0 ? _ = "utf8" : m === void 0 && typeof l == "string" ? (_ = l, l = void 0) : _ === void 0 && typeof m == "string" && (_ = m, m = void 0), h(_).write(c, u, l, m);
+ }, writeDoubleLE: function(c, u, l) {
+ return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setFloat64(l, u, !0), l + 8;
+ }, writeFloatLE: function(c, u, l) {
+ return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setFloat32(l, u, !0), l + 4;
+ }, writeUInt32LE: function(c, u, l) {
+ return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setUint32(l, u, !0), l + 4;
+ }, writeInt32LE: function(c, u, l) {
+ return l === void 0 && (l = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).setInt32(l, u, !0), l + 4;
+ }, readDoubleLE: function(c, u) {
+ return u === void 0 && (u = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getFloat64(u, !0);
+ }, readFloatLE: function(c, u) {
+ return u === void 0 && (u = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getFloat32(u, !0);
+ }, readUInt32LE: function(c, u) {
+ return u === void 0 && (u = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getUint32(u, !0);
+ }, readInt32LE: function(c, u) {
+ return u === void 0 && (u = 0), new DataView(c.buffer, c.byteOffset, c.byteLength).getInt32(u, !0);
} };
})(Yt, Yt.exports);
var gn = Yt.exports;
@@ -1021,10 +1021,10 @@ const fs = gn, ps = gn, ms = class {
let t = "";
return s && (t = this.push(s)), t += this.decoder.flush(), t;
}
-}, ct = 536870911, mn = 1 ^ ct, ws = 2 ^ ct, yn = 64, qe = 128, _n = 256, Ss = 1024, De = 2048, Cs = 4096, vs = 8192, Lt = 16384, Dt = 32768, te = 131072, Ls = 131328, ks = 16 ^ ct, Ne = 768 ^ ct, bn = 536838143, xs = 32 ^ ct, wn = 536739839, kt = 2 << 18, Sn = 4 << 18, Me = 8 << 18, As = 16 << 18, Cn = 32 << 18, ee = 64 << 18, Nt = 128 << 18, Fe = 512 << 18, Es = 1024 << 18, vn = 469499903, Ts = 535822335, Ln = 503316479, Rs = 268435455, xt = 262160, Is = 536608751, kn = 8404992, at = 14, Bs = 15, xn = 8405006, An = 33587200, En = 33587215, Ps = 2359296, Ue = 270794767, lt = Symbol.asyncIterator || Symbol("asyncIterator");
-class Os {
+}, ct = 536870911, mn = 1 ^ ct, ws = 2 ^ ct, yn = 64, Oe = 128, _n = 256, Ss = 1024, De = 2048, Cs = 4096, vs = 8192, Lt = 16384, Dt = 32768, te = 131072, Ls = 131328, ks = 16 ^ ct, Ne = 768 ^ ct, bn = 536838143, xs = 32 ^ ct, wn = 536739839, kt = 2 << 18, Sn = 4 << 18, Me = 8 << 18, As = 16 << 18, Cn = 32 << 18, ee = 64 << 18, Nt = 128 << 18, Ue = 512 << 18, Es = 1024 << 18, vn = 469499903, Ts = 535822335, Ln = 503316479, Is = 268435455, xt = 262160, Rs = 536608751, kn = 8404992, at = 14, Bs = 15, xn = 8405006, An = 33587200, En = 33587215, Ps = 2359296, Fe = 270794767, lt = Symbol.asyncIterator || Symbol("asyncIterator");
+class qs {
constructor(t, { highWaterMark: e = 16384, map: n = null, mapWritable: r, byteLength: i, byteLengthWritable: o } = {}) {
- this.stream = t, this.queue = new pn(), this.highWaterMark = e, this.buffered = 0, this.error = null, this.pipeline = null, this.drains = null, this.byteLength = o || i || Bn, this.map = r || n, this.afterWrite = Fs.bind(this), this.afterUpdateNextTick = $s.bind(this);
+ this.stream = t, this.queue = new pn(), this.highWaterMark = e, this.buffered = 0, this.error = null, this.pipeline = null, this.drains = null, this.byteLength = o || i || Bn, this.map = r || n, this.afterWrite = Us.bind(this), this.afterUpdateNextTick = $s.bind(this);
}
get ended() {
return !!(this.stream._duplexState & Cn);
@@ -1037,11 +1037,11 @@ class Os {
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 | Fe) & Ts;
+ typeof t == "function" ? this.stream.once("finish", t) : t != null && this.push(t), this.stream._duplexState = (this.stream._duplexState | Ue) & Ts;
}
autoBatch(t, e) {
const n = [], r = this.stream;
- for (n.push(t); (r._duplexState & Ue) === Ps; ) n.push(r._writableState.shift());
+ for (n.push(t); (r._duplexState & Fe) === Ps; ) n.push(r._writableState.shift());
if (r._duplexState & Bs) return e(null);
r._writev(n, e);
}
@@ -1049,7 +1049,7 @@ class Os {
const t = this.stream;
t._duplexState |= kt;
do {
- for (; (t._duplexState & Ue) === Me; ) {
+ for (; (t._duplexState & Fe) === Me; ) {
const e = this.shift();
t._duplexState |= 67371008, t._write(e, this.afterWrite);
}
@@ -1059,8 +1059,8 @@ class Os {
}
updateNonPrimary() {
const t = this.stream;
- if ((144965647 & t._duplexState) === Fe) return t._duplexState = 402653183 & t._duplexState | 262144, void t._final(Ms.bind(this));
- (t._duplexState & at) != 4 ? (t._duplexState & En) == 1 && (t._duplexState = (t._duplexState | xt) & mn, t._open(Rn.bind(this))) : t._duplexState & An || (t._duplexState |= xt, t._destroy(Tn.bind(this)));
+ if ((144965647 & t._duplexState) === Ue) return t._duplexState = 402653183 & t._duplexState | 262144, void t._final(Ms.bind(this));
+ (t._duplexState & at) != 4 ? (t._duplexState & En) == 1 && (t._duplexState = (t._duplexState | xt) & mn, t._open(In.bind(this))) : t._duplexState & An || (t._duplexState |= xt, t._destroy(Tn.bind(this)));
}
continueUpdate() {
return !!(this.stream._duplexState & Nt) && (this.stream._duplexState &= Ln, !0);
@@ -1072,16 +1072,16 @@ class Os {
this.stream._duplexState & Nt || (this.stream._duplexState |= Nt, this.stream._duplexState & kt || fn(this.afterUpdateNextTick));
}
}
-class qs {
+class Os {
constructor(t, { highWaterMark: e = 16384, map: n = null, mapReadable: r, byteLength: i, byteLengthReadable: o } = {}) {
- this.stream = t, this.queue = new pn(), this.highWaterMark = e === 0 ? 1 : e, this.buffered = 0, this.readAhead = e > 0, this.error = null, this.pipeline = null, this.byteLength = o || i || Bn, this.map = r || n, this.pipeTo = null, this.afterRead = Us.bind(this), this.afterUpdateNextTick = Hs.bind(this);
+ this.stream = t, this.queue = new pn(), this.highWaterMark = e === 0 ? 1 : e, this.buffered = 0, this.readAhead = e > 0, this.error = null, this.pipeline = null, this.byteLength = o || i || Bn, this.map = r || n, this.pipeTo = null, this.afterRead = Fs.bind(this), this.afterUpdateNextTick = Hs.bind(this);
}
get ended() {
return !!(this.stream._duplexState & Lt);
}
pipe(t, e) {
if (this.pipeTo !== null) throw new Error("Can only pipe to one destination");
- if (typeof e != "function" && (e = null), this.stream._duplexState |= 512, this.pipeTo = t, this.pipeline = new Ds(this.stream, t, e), e && this.stream.on("error", He), In(t)) t._writableState.pipeline = this.pipeline, e && t.on("error", He), t.on("finish", this.pipeline.finished.bind(this.pipeline));
+ if (typeof e != "function" && (e = null), this.stream._duplexState |= 512, this.pipeTo = t, this.pipeline = new Ds(this.stream, t, e), e && this.stream.on("error", He), Rn(t)) t._writableState.pipeline = this.pipeline, e && t.on("error", He), t.on("finish", this.pipeline.finished.bind(this.pipeline));
else {
const n = this.pipeline.done.bind(this.pipeline, t), r = this.pipeline.done.bind(this.pipeline, t, null);
t.on("error", n), t.on("close", r), t.on("finish", this.pipeline.finished.bind(this.pipeline));
@@ -1107,7 +1107,7 @@ class qs {
}
read() {
const t = this.stream;
- if ((16527 & t._duplexState) === qe) {
+ if ((16527 & t._duplexState) === Oe) {
const e = this.shift();
return this.pipeTo !== null && this.pipeTo.write(e) === !1 && (t._duplexState &= Ne), t._duplexState & De && t.emit("data", e), e;
}
@@ -1115,7 +1115,7 @@ class qs {
}
drain() {
const t = this.stream;
- for (; (16527 & t._duplexState) === qe && 768 & t._duplexState; ) {
+ for (; (16527 & t._duplexState) === Oe && 768 & t._duplexState; ) {
const e = this.shift();
this.pipeTo !== null && this.pipeTo.write(e) === !1 && (t._duplexState &= Ne), t._duplexState & De && t.emit("data", e);
}
@@ -1131,7 +1131,7 @@ class qs {
}
updateNonPrimary() {
const t = this.stream;
- (1167 & t._duplexState) === Ss && (t._duplexState = 536869887 & t._duplexState | 16384, t.emit("end"), (t._duplexState & xn) === kn && (t._duplexState |= 4), this.pipeTo !== null && this.pipeTo.end()), (t._duplexState & at) != 4 ? (t._duplexState & En) == 1 && (t._duplexState = (t._duplexState | xt) & mn, t._open(Rn.bind(this))) : t._duplexState & An || (t._duplexState |= xt, t._destroy(Tn.bind(this)));
+ (1167 & t._duplexState) === Ss && (t._duplexState = 536869887 & t._duplexState | 16384, t.emit("end"), (t._duplexState & xn) === kn && (t._duplexState |= 4), this.pipeTo !== null && this.pipeTo.end()), (t._duplexState & at) != 4 ? (t._duplexState & En) == 1 && (t._duplexState = (t._duplexState | xt) & mn, t._open(In.bind(this))) : t._duplexState & An || (t._duplexState |= xt, t._destroy(Tn.bind(this)));
}
continueUpdate() {
return !!(this.stream._duplexState & Dt) && (this.stream._duplexState &= bn, !0);
@@ -1170,13 +1170,13 @@ function Tn(s) {
n.pipeline !== null && n.pipeline.done(t, s);
}
}
-function Fs(s) {
+function Us(s) {
const t = this.stream;
s && t.destroy(s), t._duplexState &= vn, this.drains !== null && function(e) {
for (let n = 0; n < e.length; n++) --e[n].writes == 0 && (e.shift().resolve(!0), n--);
}(this.drains), (6553615 & t._duplexState) === As && (t._duplexState &= 532676607, (t._duplexState & ee) === ee && t.emit("drain")), this.updateCallback();
}
-function Us(s) {
+function Fs(s) {
s && this.stream.destroy(s), this.stream._duplexState &= ks, this.readAhead !== !1 || this.stream._duplexState & _n || (this.stream._duplexState &= wn), this.updateCallback();
}
function Hs() {
@@ -1185,9 +1185,9 @@ function Hs() {
function $s() {
this.stream._duplexState & kt || (this.stream._duplexState &= Ln, this.update());
}
-function Rn(s) {
+function In(s) {
const t = this.stream;
- s && t.destroy(s), 4 & t._duplexState || (17423 & t._duplexState || (t._duplexState |= yn), 142606351 & t._duplexState || (t._duplexState |= Sn), t.emit("open")), t._duplexState &= Is, t._writableState !== null && t._writableState.updateCallback(), t._readableState !== null && t._readableState.updateCallback();
+ s && t.destroy(s), 4 & t._duplexState || (17423 & t._duplexState || (t._duplexState |= yn), 142606351 & t._duplexState || (t._duplexState |= Sn), t.emit("open")), t._duplexState &= Rs, t._writableState !== null && t._writableState.updateCallback(), t._readableState !== null && t._readableState.updateCallback();
}
function js(s) {
this._readableState !== null && (s === "data" && (this._duplexState |= 133376, this._readableState.updateNextTick()), s === "readable" && (this._duplexState |= Cs, this._readableState.updateNextTick())), this._writableState !== null && s === "drain" && (this._duplexState |= ee, this._writableState.updateNextTick());
@@ -1222,7 +1222,7 @@ class Qs extends _s {
}
class At extends Qs {
constructor(t) {
- super(t), this._duplexState |= 8519681, this._readableState = new qs(this, t), t && (this._readableState.readAhead === !1 && (this._duplexState &= wn), t.read && (this._read = t.read), t.eagerOpen && this._readableState.updateNextTick(), t.encoding && this.setEncoding(t.encoding));
+ super(t), this._duplexState |= 8519681, this._readableState = new Os(this, t), t && (this._readableState.readAhead === !1 && (this._duplexState &= wn), t.read && (this._read = t.read), t.eagerOpen && this._readableState.updateNextTick(), t.encoding && this.setEncoding(t.encoding));
}
setEncoding(t) {
const e = new bs(t), n = this._readableState.map || zs;
@@ -1268,7 +1268,7 @@ class At extends Qs {
}
}
static from(t, e) {
- if (In(n = t) && n.readable) return t;
+ if (Rn(n = t) && n.readable) return t;
var n;
if (t[lt]) return this._fromAsyncIterator(t[lt](), e);
Array.isArray(t) || (t = t === void 0 ? [] : [t]);
@@ -1296,17 +1296,17 @@ class At extends Qs {
return this;
}, next: () => new Promise(function(a, h) {
n = a, r = h;
- const u = t.read();
- u !== null ? i(u) : 8 & t._duplexState && i(null);
+ const g = t.read();
+ g !== null ? i(g) : 8 & t._duplexState && i(null);
}), return: () => o(null), throw: (a) => o(a) };
function i(a) {
r !== null && (e ? r(e) : a !== null || t._duplexState & Lt ? n({ value: a, done: a === null }) : r(le), r = n = null);
}
function o(a) {
- return t.destroy(a), new Promise((h, u) => {
+ return t.destroy(a), new Promise((h, g) => {
if (8 & t._duplexState) return h({ value: void 0, done: !0 });
t.once("close", function() {
- a ? u(a) : h({ value: void 0, done: !0 });
+ a ? g(a) : h({ value: void 0, done: !0 });
});
});
}
@@ -1314,13 +1314,13 @@ class At extends Qs {
}
class Ws extends At {
constructor(t) {
- super(t), this._duplexState = 1 | this._duplexState & te, this._writableState = new Os(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 & te, this._writableState = new qs(this, t), t && (t.writev && (this._writev = t.writev), t.write && (this._write = t.write), t.final && (this._final = t.final));
}
cork() {
this._duplexState |= Es;
}
uncork() {
- this._duplexState &= Rs, this._writableState.updateNextTick();
+ this._duplexState &= Is, this._writableState.updateNextTick();
}
_writev(t, e) {
e(null);
@@ -1344,7 +1344,7 @@ function zs(s) {
function Vs(s) {
return !!s._readableState || !!s._writableState;
}
-function In(s) {
+function Rn(s) {
return typeof s._duplexState == "number" && Vs(s);
}
function Bn(s) {
@@ -1373,12 +1373,12 @@ const C = V(function(s, t, e) {
};
return r.prototype = Object.create(Object.getPrototypeOf(s)), $e(new r(), e);
}
-}), Et = "0123456789abcdef", On = [], Tt = [];
-for (let s = 0; s < 256; s++) On[s] = Et[s >> 4 & 15] + Et[15 & s], s < 16 && (s < 10 ? Tt[48 + s] = s : Tt[87 + s] = s);
+}), Et = "0123456789abcdef", qn = [], Tt = [];
+for (let s = 0; s < 256; s++) qn[s] = Et[s >> 4 & 15] + Et[15 & s], s < 16 && (s < 10 ? Tt[48 + s] = s : Tt[87 + s] = s);
const Z = (s) => {
const t = s.length;
let e = "", n = 0;
- for (; n < t; ) e += On[s[n++]];
+ for (; n < t; ) e += qn[s[n++]];
return e;
}, ne = (s) => {
const t = s.length >> 1, e = t << 1, n = new Uint8Array(t);
@@ -1387,7 +1387,7 @@ const Z = (s) => {
return n;
};
for (var Js = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ys = typeof Uint8Array > "u" ? [] : new Uint8Array(256), gt = 0; gt < 64; gt++) Ys[Js.charCodeAt(gt)] = gt;
-const Ks = new TextDecoder(), qn = (s, t) => Ks.decode(s), Xs = new TextEncoder(), ge = (s) => Xs.encode(s), G = (s) => {
+const Ks = new TextDecoder(), On = (s, t) => Ks.decode(s), Xs = new TextEncoder(), ge = (s) => Xs.encode(s), G = (s) => {
let t, e = "", n = 0;
const r = s.length;
for (; n < r; ) t = s.charCodeAt(n++), e += Et[t >> 4] + Et[15 & t];
@@ -1400,7 +1400,7 @@ const Ks = new TextDecoder(), qn = (s, t) => Ks.decode(s), Xs = new TextEncoder(
return e;
}, je = typeof window < "u" ? window : self, se = je.crypto || je.msCrypto || {};
se.subtle || se.webkitSubtle;
-const Rt = (s) => {
+const It = (s) => {
const t = new Uint8Array(s);
return se.getRandomValues(t);
}, Zs = P("simple-peer"), Mt = 65536;
@@ -1411,7 +1411,7 @@ let ot = class re extends Pn {
constructor(e) {
super(e = Object.assign({ allowHalfOpen: !1 }, e));
f(this, "_pc");
- if (this.__objectMode = !!e.objectMode, this._id = Z(Rt(4)).slice(0, 7), this._debug("new peer %o", e), this.channelName = e.initiator ? e.channelName || Z(Rt(20)) : null, this.initiator = e.initiator || !1, this.channelConfig = e.channelConfig || re.channelConfig, this.channelNegotiated = this.channelConfig.negotiated, this.config = Object.assign({}, re.config, e.config), this.offerOptions = e.offerOptions || {}, this.answerOptions = e.answerOptions || {}, this.sdpTransform = e.sdpTransform || ((n) => n), this.trickle = e.trickle === void 0 || e.trickle, this.allowHalfTrickle = e.allowHalfTrickle !== void 0 && e.allowHalfTrickle, this.iceCompleteTimeout = e.iceCompleteTimeout || 5e3, this._destroying = !1, this._connected = !1, this.remoteAddress = void 0, this.remoteFamily = void 0, this.remotePort = void 0, this.localAddress = void 0, this.localFamily = void 0, this.localPort = void 0, !Jt) throw C(typeof window > "u" ? new Error("No WebRTC support: Specify `opts.wrtc` option in this environment") : new Error("No WebRTC support: Not a supported browser"), "ERR_WEBRTC_SUPPORT");
+ if (this.__objectMode = !!e.objectMode, this._id = Z(It(4)).slice(0, 7), this._debug("new peer %o", e), this.channelName = e.initiator ? e.channelName || Z(It(20)) : null, this.initiator = e.initiator || !1, this.channelConfig = e.channelConfig || re.channelConfig, this.channelNegotiated = this.channelConfig.negotiated, this.config = Object.assign({}, re.config, e.config), this.offerOptions = e.offerOptions || {}, this.answerOptions = e.answerOptions || {}, this.sdpTransform = e.sdpTransform || ((n) => n), this.trickle = e.trickle === void 0 || e.trickle, this.allowHalfTrickle = e.allowHalfTrickle !== void 0 && e.allowHalfTrickle, this.iceCompleteTimeout = e.iceCompleteTimeout || 5e3, this._destroying = !1, this._connected = !1, this.remoteAddress = void 0, this.remoteFamily = void 0, this.remotePort = void 0, this.localAddress = void 0, this.localFamily = void 0, this.localPort = void 0, !Jt) throw C(typeof window > "u" ? new Error("No WebRTC support: Specify `opts.wrtc` option in this environment") : new Error("No WebRTC support: Not a supported browser"), "ERR_WEBRTC_SUPPORT");
this._pcReady = !1, this._channelReady = !1, this._iceComplete = !1, this._iceCompleteTimer = null, this._channel = null, this._pendingCandidates = [], this._isNegotiating = !1, this._firstNegotiation = !0, this._batchedNegotiation = !1, this._queuedNegotiation = !1, this._sendersAwaitingStable = [], this._closingInterval = null, this._remoteTracks = [], this._remoteStreams = [], this._chunk = null, this._cb = null, this._interval = null;
try {
this._pc = new Jt(this.config);
@@ -1633,15 +1633,15 @@ let ot = class re extends Pn {
r.forEach((d) => {
d.type !== "remotecandidate" && d.type !== "remote-candidate" || (i[d.id] = d), d.type !== "localcandidate" && d.type !== "local-candidate" || (o[d.id] = d), d.type !== "candidatepair" && d.type !== "candidate-pair" || (a[d.id] = d);
});
- const u = (d) => {
+ const g = (d) => {
h = !0;
let p = o[d.localCandidateId];
p && (p.ip || p.address) ? (this.localAddress = p.ip || p.address, this.localPort = Number(p.port)) : p && p.ipAddress ? (this.localAddress = p.ipAddress, this.localPort = Number(p.portNumber)) : typeof d.googLocalAddress == "string" && (p = d.googLocalAddress.split(":"), this.localAddress = p[0], this.localPort = Number(p[1])), this.localAddress && (this.localFamily = this.localAddress.includes(":") ? "IPv6" : "IPv4");
- let _ = i[d.remoteCandidateId];
- _ && (_.ip || _.address) ? (this.remoteAddress = _.ip || _.address, this.remotePort = Number(_.port)) : _ && _.ipAddress ? (this.remoteAddress = _.ipAddress, this.remotePort = Number(_.portNumber)) : typeof d.googRemoteAddress == "string" && (_ = d.googRemoteAddress.split(":"), this.remoteAddress = _[0], this.remotePort = Number(_[1])), this.remoteAddress && (this.remoteFamily = this.remoteAddress.includes(":") ? "IPv6" : "IPv4"), this._debug("connect local: %s:%s remote: %s:%s", this.localAddress, this.localPort, this.remoteAddress, this.remotePort);
+ let y = i[d.remoteCandidateId];
+ y && (y.ip || y.address) ? (this.remoteAddress = y.ip || y.address, this.remotePort = Number(y.port)) : y && y.ipAddress ? (this.remoteAddress = y.ipAddress, this.remotePort = Number(y.portNumber)) : typeof d.googRemoteAddress == "string" && (y = d.googRemoteAddress.split(":"), this.remoteAddress = y[0], this.remotePort = Number(y[1])), this.remoteAddress && (this.remoteFamily = this.remoteAddress.includes(":") ? "IPv6" : "IPv4"), this._debug("connect local: %s:%s remote: %s:%s", this.localAddress, this.localPort, this.remoteAddress, this.remotePort);
};
if (r.forEach((d) => {
- d.type === "transport" && d.selectedCandidatePairId && u(a[d.selectedCandidatePairId]), (d.type === "googCandidatePair" && d.googActiveConnection === "true" || (d.type === "candidatepair" || d.type === "candidate-pair") && d.selected) && u(d);
+ d.type === "transport" && d.selectedCandidatePairId && g(a[d.selectedCandidatePairId]), (d.type === "googCandidatePair" && d.googActiveConnection === "true" || (d.type === "candidatepair" || d.type === "candidate-pair") && d.selected) && g(d);
}), h || Object.keys(a).length && !Object.keys(o).length) {
if (this._connecting = !1, this._connected = !0, this._chunk) {
try {
@@ -1701,7 +1701,7 @@ class Dn extends Pn {
constructor(t = {}) {
if (typeof t == "string" && (t = { url: t }), super(t = Object.assign({ allowHalfOpen: !1 }, t)), this.__objectMode = !!t.objectMode, t.objectMode != null && delete t.objectMode, t.url == null && t.socket == null) throw new Error("Missing required `url` or `socket` option");
if (t.url != null && t.socket != null) throw new Error("Must specify either `url` or `socket` option, not both");
- if (this._id = Z(Rt(4)).slice(0, 7), this._debug("new websocket: %o", t), this.connected = !1, this._chunk = null, this._cb = null, this._interval = null, t.socket) this.url = t.socket.url, this._ws = t.socket, this.connected = t.socket.readyState === st.OPEN;
+ if (this._id = Z(It(4)).slice(0, 7), this._debug("new websocket: %o", t), this.connected = !1, this._chunk = null, this._cb = null, this._interval = null, t.socket) this.url = t.socket.url, this._ws = t.socket, this.connected = t.socket.readyState === st.OPEN;
else {
this.url = t.url;
try {
@@ -1802,10 +1802,10 @@ class er extends un {
}, t), this.interval.unref && this.interval.unref());
}
}
-const R = P("bittorrent-tracker:websocket-tracker"), q = {};
+const I = P("bittorrent-tracker:websocket-tracker"), O = {};
class oe extends er {
constructor(t, e) {
- super(t, e), R("new websocket tracker %s", e), this.peers = {}, this.socket = null, this.reconnecting = !1, this.retries = 0, this.reconnectTimer = null, this.expectingResponse = !1, this._openSocket();
+ super(t, e), I("new websocket tracker %s", e), this.peers = {}, this.socket = null, this.reconnecting = !1, this.retries = 0, this.reconnectTimer = null, this.expectingResponse = !1, this._openSocket();
}
announce(t) {
if (this.destroyed || this.reconnecting) return;
@@ -1836,9 +1836,9 @@ class oe extends er {
const o = this.peers[i];
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, q[this.announceUrl] && (q[this.announceUrl].consumers -= 1), q[this.announceUrl].consumers > 0) return t();
- let e, n = q[this.announceUrl];
- if (delete q[this.announceUrl], n.on("error", We), n.once("close", t), !this.expectingResponse) return r();
+ if (this.peers = null, this.socket && (this.socket.removeListener("connect", this._onSocketConnectBound), this.socket.removeListener("data", this._onSocketDataBound), this.socket.removeListener("close", this._onSocketCloseBound), this.socket.removeListener("error", this._onSocketErrorBound), this.socket = null), this._onSocketConnectBound = null, this._onSocketErrorBound = null, this._onSocketDataBound = null, this._onSocketCloseBound = null, O[this.announceUrl] && (O[this.announceUrl].consumers -= 1), O[this.announceUrl].consumers > 0) return t();
+ let e, n = O[this.announceUrl];
+ if (delete O[this.announceUrl], n.on("error", We), n.once("close", t), !this.expectingResponse) return r();
function r() {
e && (clearTimeout(e), e = null), n.removeListener("data", r), n.destroy(), n = null;
}
@@ -1853,11 +1853,11 @@ class oe extends er {
this._onSocketData(t);
}, this._onSocketCloseBound = () => {
this._onSocketClose();
- }, this.socket = q[this.announceUrl], this.socket) q[this.announceUrl].consumers += 1, this.socket.connected && this._onSocketConnectBound();
+ }, this.socket = O[this.announceUrl], this.socket) O[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 = q[this.announceUrl] = new Dn({ url: this.announceUrl, agent: e }), this.socket.consumers = 1, this.socket.once("connect", this._onSocketConnectBound);
+ this.client._proxyOpts && (e = t.protocol === "wss:" ? this.client._proxyOpts.httpsAgent : this.client._proxyOpts.httpAgent, !e && this.client._proxyOpts.socksProxy && (e = this.client._proxyOpts.socksProxy)), this.socket = O[this.announceUrl] = new Dn({ 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);
}
@@ -1868,7 +1868,7 @@ class oe extends er {
if (!this.destroyed) {
this.expectingResponse = !1;
try {
- t = JSON.parse(qn(t));
+ t = JSON.parse(On(t));
} catch {
return void this.client.emit("warning", new Error("Invalid tracker response"));
}
@@ -1876,9 +1876,9 @@ class oe extends er {
}
}
_onAnnounceResponse(t) {
- if (t.info_hash !== this.client._infoHashBinary) return void R("ignoring websocket data from %s for %s (looking for %s: reused socket)", this.announceUrl, G(t.info_hash), this.client.infoHash);
+ if (t.info_hash !== this.client._infoHashBinary) return void I("ignoring websocket data from %s for %s (looking for %s: reused socket)", this.announceUrl, G(t.info_hash), this.client.infoHash);
if (t.peer_id && t.peer_id === this.client._peerIdBinary) return;
- R("received %s from %s for %s", JSON.stringify(t), this.announceUrl, this.client.infoHash);
+ I("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"];
@@ -1891,12 +1891,12 @@ class oe extends er {
this.client.emit("update", a);
}
let o;
- if (t.offer && t.peer_id && (R("creating peer (from remote offer)"), o = this._createPeer(), o.id = G(t.peer_id), o.once("signal", (a) => {
+ if (t.offer && t.peer_id && (I("creating peer (from remote offer)"), o = this._createPeer(), o.id = G(t.peer_id), o.once("signal", (a) => {
const h = { action: "announce", info_hash: this.client._infoHashBinary, peer_id: this.client._peerIdBinary, to_peer_id: t.peer_id, answer: a, offer_id: t.offer_id };
this._trackerId && (h.trackerid = this._trackerId), this._send(h);
}), this.client.emit("peer", o), o.signal(t.offer)), t.answer && t.peer_id) {
const a = G(t.offer_id);
- o = this.peers[a], o ? (o.id = G(t.peer_id), this.client.emit("peer", o), o.signal(t.answer), clearTimeout(o.trackerTimeout), o.trackerTimeout = null, delete this.peers[a]) : R(`got unexpected answer: ${JSON.stringify(t.answer)}`);
+ o = this.peers[a], o ? (o.id = G(t.peer_id), this.client.emit("peer", o), o.signal(t.answer), clearTimeout(o.trackerTimeout), o.trackerTimeout = null, delete this.peers[a]) : I(`got unexpected answer: ${JSON.stringify(t.answer)}`);
}
}
_onScrapeResponse(t) {
@@ -1917,30 +1917,30 @@ class oe extends er {
const t = Math.floor(3e5 * Math.random()) + Math.min(1e4 * Math.pow(2, this.retries), 36e5);
this.reconnecting = !0, clearTimeout(this.reconnectTimer), this.reconnectTimer = setTimeout(() => {
this.retries++, this._openSocket();
- }, t), this.reconnectTimer.unref && this.reconnectTimer.unref(), R("reconnecting socket in %s ms", t);
+ }, t), this.reconnectTimer.unref && this.reconnectTimer.unref(), I("reconnecting socket in %s ms", t);
}
_send(t) {
if (this.destroyed) return;
this.expectingResponse = !0;
const e = JSON.stringify(t);
- R("send %s", e), this.socket.send(e);
+ I("send %s", e), this.socket.send(e);
}
_generateOffers(t, e) {
const n = this, r = [];
- R("generating %s offers", t);
+ I("generating %s offers", t);
for (let a = 0; a < t; ++a) i();
function i() {
- const a = Z(Rt(20));
- R("creating peer (from _generateOffers)");
+ const a = Z(It(20));
+ I("creating peer (from _generateOffers)");
const h = n.peers[a] = n._createPeer({ initiator: !0 });
- h.once("signal", (u) => {
- r.push({ offer: u, offer_id: it(a) }), o();
+ h.once("signal", (g) => {
+ r.push({ offer: g, offer_id: it(a) }), o();
}), h.trackerTimeout = setTimeout(() => {
- R("tracker timeout: destroying peer"), h.trackerTimeout = null, delete n.peers[a], h.destroy();
+ I("tracker timeout: destroying peer"), h.trackerTimeout = null, delete n.peers[a], h.destroy();
}, 5e4), h.trackerTimeout.unref && h.trackerTimeout.unref();
}
function o() {
- r.length === t && (R("generated %s offers", t), e(r));
+ r.length === t && (I("generated %s offers", t), e(r));
}
o();
}
@@ -1958,17 +1958,17 @@ class oe extends er {
}
function We() {
}
-oe.prototype.DEFAULT_ANNOUNCE_INTERVAL = 3e4, oe._socketPool = q;
-const U = P("bittorrent-tracker:client");
+oe.prototype.DEFAULT_ANNOUNCE_INTERVAL = 3e4, oe._socketPool = O;
+const F = P("bittorrent-tracker:client");
class ae extends un {
constructor(t = {}) {
if (super(), !t.peerId) throw new Error("Option `peerId` is required");
if (!t.infoHash) throw new Error("Option `infoHash` is required");
if (!t.announce) throw new Error("Option `announce` is required");
if (!wt.browser && !t.port) throw new Error("Option `port` is required");
- this.peerId = typeof t.peerId == "string" ? t.peerId : Z(t.peerId), this._peerIdBuffer = ne(this.peerId), this._peerIdBinary = it(this.peerId), this.infoHash = typeof t.infoHash == "string" ? t.infoHash.toLowerCase() : Z(t.infoHash), this._infoHashBuffer = ne(this.infoHash), this._infoHashBinary = it(this.infoHash), U("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;
+ this.peerId = typeof t.peerId == "string" ? t.peerId : Z(t.peerId), this._peerIdBuffer = ne(this.peerId), this._peerIdBinary = it(this.peerId), this.infoHash = typeof t.infoHash == "string" ? t.infoHash.toLowerCase() : Z(t.infoHash), this._infoHashBuffer = ne(this.infoHash), this._infoHashBinary = it(this.infoHash), F("new client %s", this.infoHash), this.destroyed = !1, this._port = t.port, this._getAnnounceOpts = t.getAnnounceOpts, this._rtcConfig = t.rtcConfig, this._userAgent = t.userAgent, this._proxyOpts = t.proxyOpts, this._wrtc = typeof t.wrtc == "function" ? t.wrtc() : t.wrtc;
let e = typeof t.announce == "string" ? [t.announce] : t.announce == null ? [] : t.announce;
- e = e.map((i) => (ArrayBuffer.isView(i) && (i = qn(i)), i[i.length - 1] === "/" && (i = i.substring(0, i.length - 1)), i)), e = Array.from(new Set(e));
+ e = e.map((i) => (ArrayBuffer.isView(i) && (i = On(i)), i[i.length - 1] === "/" && (i = i.substring(0, i.length - 1)), i)), e = Array.from(new Set(e));
const n = this._wrtc !== !1 && (!!this._wrtc || ot.WEBRTC_SUPPORT), r = (i) => {
Gt(() => {
this.emit("warning", i);
@@ -1988,18 +1988,18 @@ class ae extends un {
}).filter(Boolean);
}
start(t) {
- (t = this._defaultAnnounceOpts(t)).event = "started", U("send `start` %o", t), this._announce(t), this._trackers.forEach((e) => {
+ (t = this._defaultAnnounceOpts(t)).event = "started", F("send `start` %o", t), this._announce(t), this._trackers.forEach((e) => {
e.setInterval();
});
}
stop(t) {
- (t = this._defaultAnnounceOpts(t)).event = "stopped", U("send `stop` %o", t), this._announce(t);
+ (t = this._defaultAnnounceOpts(t)).event = "stopped", F("send `stop` %o", t), this._announce(t);
}
complete(t) {
- t || (t = {}), (t = this._defaultAnnounceOpts(t)).event = "completed", U("send `complete` %o", t), this._announce(t);
+ t || (t = {}), (t = this._defaultAnnounceOpts(t)).event = "completed", F("send `complete` %o", t), this._announce(t);
}
update(t) {
- (t = this._defaultAnnounceOpts(t)).event && delete t.event, U("send `update` %o", t), this._announce(t);
+ (t = this._defaultAnnounceOpts(t)).event && delete t.event, F("send `update` %o", t), this._announce(t);
}
_announce(t) {
this._trackers.forEach((e) => {
@@ -2007,18 +2007,18 @@ class ae extends un {
});
}
scrape(t) {
- U("send `scrape`"), t || (t = {}), this._trackers.forEach((e) => {
+ F("send `scrape`"), t || (t = {}), this._trackers.forEach((e) => {
e.scrape(t);
});
}
setInterval(t) {
- U("setInterval %d", t), this._trackers.forEach((e) => {
+ F("setInterval %d", t), this._trackers.forEach((e) => {
e.setInterval(t);
});
}
destroy(t) {
if (this.destroyed) return;
- this.destroyed = !0, U("destroy");
+ this.destroyed = !0, F("destroy");
const e = this._trackers.map((n) => (r) => {
n.destroy(r);
});
@@ -2068,29 +2068,29 @@ function pt(s) {
}
var he = function(s) {
return unescape(encodeURIComponent(s));
-}, Ot = Nn.exports = function(s) {
+}, qt = Nn.exports = function(s) {
return nr(s).toHex();
-}, Ct = Ot.fromBytes = function(s) {
- for (var t = function(S) {
- for (var c = S.length, g = c << 3, l = new Uint32Array(c + 72 >>> 6 << 4), m = 0, y = S.length; m < y; ++m) l[m >>> 2] |= S.charCodeAt(m) << ((3 & m) << 3);
- return l[c >> 2] |= 128 << (31 & g), l[l.length - 2] = g, l;
+}, Ct = qt.fromBytes = function(s) {
+ for (var t = function(w) {
+ for (var c = w.length, u = c << 3, l = new Uint32Array(c + 72 >>> 6 << 4), m = 0, _ = w.length; m < _; ++m) l[m >>> 2] |= w.charCodeAt(m) << ((3 & m) << 3);
+ return l[c >> 2] |= 128 << (31 & u), l[l.length - 2] = u, l;
}(s), e = 1732584193, n = 4023233417, r = 2562383102, i = 271733878, o = 0, a = t.length; o < a; o += 16) {
- var h = e, u = n, d = r, p = i;
- e = k(e, n, r, i, t[o + 0], 7, 3614090360), i = k(i, e, n, r, t[o + 1], 12, 3905402710), r = k(r, i, e, n, t[o + 2], 17, 606105819), n = k(n, r, i, e, t[o + 3], 22, 3250441966), e = k(e, n, r, i, t[o + 4], 7, 4118548399), i = k(i, e, n, r, t[o + 5], 12, 1200080426), r = k(r, i, e, n, t[o + 6], 17, 2821735955), n = k(n, r, i, e, t[o + 7], 22, 4249261313), e = k(e, n, r, i, t[o + 8], 7, 1770035416), i = k(i, e, n, r, t[o + 9], 12, 2336552879), r = k(r, i, e, n, t[o + 10], 17, 4294925233), n = k(n, r, i, e, t[o + 11], 22, 2304563134), e = k(e, n, r, i, t[o + 12], 7, 1804603682), i = k(i, e, n, r, t[o + 13], 12, 4254626195), r = k(r, i, e, n, t[o + 14], 17, 2792965006), e = x(e, n = k(n, r, i, e, t[o + 15], 22, 1236535329), r, i, t[o + 1], 5, 4129170786), i = x(i, e, n, r, t[o + 6], 9, 3225465664), r = x(r, i, e, n, t[o + 11], 14, 643717713), n = x(n, r, i, e, t[o + 0], 20, 3921069994), e = x(e, n, r, i, t[o + 5], 5, 3593408605), i = x(i, e, n, r, t[o + 10], 9, 38016083), r = x(r, i, e, n, t[o + 15], 14, 3634488961), n = x(n, r, i, e, t[o + 4], 20, 3889429448), e = x(e, n, r, i, t[o + 9], 5, 568446438), i = x(i, e, n, r, t[o + 14], 9, 3275163606), r = x(r, i, e, n, t[o + 3], 14, 4107603335), n = x(n, r, i, e, t[o + 8], 20, 1163531501), e = x(e, n, r, i, t[o + 13], 5, 2850285829), i = x(i, e, n, r, t[o + 2], 9, 4243563512), r = x(r, i, e, n, t[o + 7], 14, 1735328473), e = A(e, n = x(n, r, i, e, t[o + 12], 20, 2368359562), r, i, t[o + 5], 4, 4294588738), i = A(i, e, n, r, t[o + 8], 11, 2272392833), r = A(r, i, e, n, t[o + 11], 16, 1839030562), n = A(n, r, i, e, t[o + 14], 23, 4259657740), e = A(e, n, r, i, t[o + 1], 4, 2763975236), i = A(i, e, n, r, t[o + 4], 11, 1272893353), r = A(r, i, e, n, t[o + 7], 16, 4139469664), n = A(n, r, i, e, t[o + 10], 23, 3200236656), e = A(e, n, r, i, t[o + 13], 4, 681279174), i = A(i, e, n, r, t[o + 0], 11, 3936430074), r = A(r, i, e, n, t[o + 3], 16, 3572445317), n = A(n, r, i, e, t[o + 6], 23, 76029189), e = A(e, n, r, i, t[o + 9], 4, 3654602809), i = A(i, e, n, r, t[o + 12], 11, 3873151461), r = A(r, i, e, n, t[o + 15], 16, 530742520), e = E(e, n = A(n, r, i, e, t[o + 2], 23, 3299628645), r, i, t[o + 0], 6, 4096336452), i = E(i, e, n, r, t[o + 7], 10, 1126891415), r = E(r, i, e, n, t[o + 14], 15, 2878612391), n = E(n, r, i, e, t[o + 5], 21, 4237533241), e = E(e, n, r, i, t[o + 12], 6, 1700485571), i = E(i, e, n, r, t[o + 3], 10, 2399980690), r = E(r, i, e, n, t[o + 10], 15, 4293915773), n = E(n, r, i, e, t[o + 1], 21, 2240044497), e = E(e, n, r, i, t[o + 8], 6, 1873313359), i = E(i, e, n, r, t[o + 15], 10, 4264355552), r = E(r, i, e, n, t[o + 6], 15, 2734768916), n = E(n, r, i, e, t[o + 13], 21, 1309151649), e = E(e, n, r, i, t[o + 4], 6, 4149444226), i = E(i, e, n, r, t[o + 11], 10, 3174756917), r = E(r, i, e, n, t[o + 2], 15, 718787259), n = E(n, r, i, e, t[o + 9], 21, 3951481745), e = e + h >>> 0, n = n + u >>> 0, r = r + d >>> 0, i = i + p >>> 0;
+ var h = e, g = n, d = r, p = i;
+ e = k(e, n, r, i, t[o + 0], 7, 3614090360), i = k(i, e, n, r, t[o + 1], 12, 3905402710), r = k(r, i, e, n, t[o + 2], 17, 606105819), n = k(n, r, i, e, t[o + 3], 22, 3250441966), e = k(e, n, r, i, t[o + 4], 7, 4118548399), i = k(i, e, n, r, t[o + 5], 12, 1200080426), r = k(r, i, e, n, t[o + 6], 17, 2821735955), n = k(n, r, i, e, t[o + 7], 22, 4249261313), e = k(e, n, r, i, t[o + 8], 7, 1770035416), i = k(i, e, n, r, t[o + 9], 12, 2336552879), r = k(r, i, e, n, t[o + 10], 17, 4294925233), n = k(n, r, i, e, t[o + 11], 22, 2304563134), e = k(e, n, r, i, t[o + 12], 7, 1804603682), i = k(i, e, n, r, t[o + 13], 12, 4254626195), r = k(r, i, e, n, t[o + 14], 17, 2792965006), e = x(e, n = k(n, r, i, e, t[o + 15], 22, 1236535329), r, i, t[o + 1], 5, 4129170786), i = x(i, e, n, r, t[o + 6], 9, 3225465664), r = x(r, i, e, n, t[o + 11], 14, 643717713), n = x(n, r, i, e, t[o + 0], 20, 3921069994), e = x(e, n, r, i, t[o + 5], 5, 3593408605), i = x(i, e, n, r, t[o + 10], 9, 38016083), r = x(r, i, e, n, t[o + 15], 14, 3634488961), n = x(n, r, i, e, t[o + 4], 20, 3889429448), e = x(e, n, r, i, t[o + 9], 5, 568446438), i = x(i, e, n, r, t[o + 14], 9, 3275163606), r = x(r, i, e, n, t[o + 3], 14, 4107603335), n = x(n, r, i, e, t[o + 8], 20, 1163531501), e = x(e, n, r, i, t[o + 13], 5, 2850285829), i = x(i, e, n, r, t[o + 2], 9, 4243563512), r = x(r, i, e, n, t[o + 7], 14, 1735328473), e = A(e, n = x(n, r, i, e, t[o + 12], 20, 2368359562), r, i, t[o + 5], 4, 4294588738), i = A(i, e, n, r, t[o + 8], 11, 2272392833), r = A(r, i, e, n, t[o + 11], 16, 1839030562), n = A(n, r, i, e, t[o + 14], 23, 4259657740), e = A(e, n, r, i, t[o + 1], 4, 2763975236), i = A(i, e, n, r, t[o + 4], 11, 1272893353), r = A(r, i, e, n, t[o + 7], 16, 4139469664), n = A(n, r, i, e, t[o + 10], 23, 3200236656), e = A(e, n, r, i, t[o + 13], 4, 681279174), i = A(i, e, n, r, t[o + 0], 11, 3936430074), r = A(r, i, e, n, t[o + 3], 16, 3572445317), n = A(n, r, i, e, t[o + 6], 23, 76029189), e = A(e, n, r, i, t[o + 9], 4, 3654602809), i = A(i, e, n, r, t[o + 12], 11, 3873151461), r = A(r, i, e, n, t[o + 15], 16, 530742520), e = E(e, n = A(n, r, i, e, t[o + 2], 23, 3299628645), r, i, t[o + 0], 6, 4096336452), i = E(i, e, n, r, t[o + 7], 10, 1126891415), r = E(r, i, e, n, t[o + 14], 15, 2878612391), n = E(n, r, i, e, t[o + 5], 21, 4237533241), e = E(e, n, r, i, t[o + 12], 6, 1700485571), i = E(i, e, n, r, t[o + 3], 10, 2399980690), r = E(r, i, e, n, t[o + 10], 15, 4293915773), n = E(n, r, i, e, t[o + 1], 21, 2240044497), e = E(e, n, r, i, t[o + 8], 6, 1873313359), i = E(i, e, n, r, t[o + 15], 10, 4264355552), r = E(r, i, e, n, t[o + 6], 15, 2734768916), n = E(n, r, i, e, t[o + 13], 21, 1309151649), e = E(e, n, r, i, t[o + 4], 6, 4149444226), i = E(i, e, n, r, t[o + 11], 10, 3174756917), r = E(r, i, e, n, t[o + 2], 15, 718787259), n = E(n, r, i, e, t[o + 9], 21, 3951481745), e = e + h >>> 0, n = n + g >>> 0, r = r + d >>> 0, i = i + p >>> 0;
}
- var _ = new String(pt(e) + pt(n) + pt(r) + pt(i));
- return _.toHex = function() {
- for (var S = "", c = 0, g = _.length; c < g; ++c) S += (256 + (255 & _.charCodeAt(c))).toString(16).substr(-2);
- return S;
- }, _;
-}, nr = Ot.fromUtf8 = function(s) {
+ var y = new String(pt(e) + pt(n) + pt(r) + pt(i));
+ return y.toHex = function() {
+ for (var w = "", c = 0, u = y.length; c < u; ++c) w += (256 + (255 & y.charCodeAt(c))).toString(16).substr(-2);
+ return w;
+ }, y;
+}, nr = qt.fromUtf8 = function(s) {
return Ct(he(s));
}, Mn = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
function ze(s, t) {
for (var e = ""; --t >= 0; s >>>= 6) e += Mn.charAt(63 & s);
return e;
}
-var mt = [0, 6, 12, 1, 7, 13, 2, 8, 14, 3, 9, 15, 4, 10, 5, 11], sr = Ot.salt = function(s) {
+var mt = [0, 6, 12, 1, 7, 13, 2, 8, 14, 3, 9, 15, 4, 10, 5, 11], sr = qt.salt = function(s) {
var t = "";
s || (s = 8);
do
@@ -2098,7 +2098,7 @@ var mt = [0, 6, 12, 1, 7, 13, 2, 8, 14, 3, 9, 15, 4, 10, 5, 11], sr = Ot.salt =
while (--s);
return t;
};
-Ot.crypt = function(s, t) {
+qt.crypt = function(s, t) {
if (s.length > 64) throw Error("too long key");
t || (t = "$1$" + sr()), s = he(s);
for (var e = he(t.replace(/^\$1\$([^$]+)(?:\$.*)?$/, "$1")), n = Ct(s + e + s), r = s + "$1$" + e, i = s.length; i > 16; i -= 16) r += n;
@@ -2112,7 +2112,7 @@ Ot.crypt = function(s, t) {
const rr = V(Nn.exports), ir = `-PM${function(s) {
const t = s.split(".");
return `${t[0].padStart(2, "0")}${t[1].padStart(2, "0")}`;
-}("1.0.3")}-`, or = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+}("1.0.4")}-`, or = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
function z(s) {
return `${s.type}-${s.index}`;
}
@@ -2134,14 +2134,14 @@ function Ge(s) {
function* Je(s) {
for (let t = s.length - 1; t >= 0; t--) yield s[t];
}
-function Fn(s) {
+function Un(s) {
return !!s && typeof s == "object" && !Array.isArray(s);
}
function K(s) {
if (function(t) {
return Array.isArray(t);
}(s)) return s.map((t) => K(t));
- if (Fn(s)) {
+ if (Un(s)) {
const t = {};
for (const e of Object.keys(s)) t[e] = K(s[e]);
return t;
@@ -2155,7 +2155,7 @@ function et(s, t, e = {}) {
n in s && (s[n] = r === void 0 ? i === void 0 ? void 0 : i : r);
}), s;
}
-function Ft(s) {
+function Ut(s) {
const { defaultConfig: t, baseConfig: e = {}, specificStreamConfig: n = {} } = s, r = K({ ...t, ...e, ...n }), i = Object.keys(t), o = {};
return i.forEach((a) => {
a in r && (o[a] = r[a]);
@@ -2189,7 +2189,7 @@ function Ye(s) {
const t = ar(s), e = 0 | t.length;
return new Uint8Array([e, ...t]);
}
-function Un(s) {
+function Fn(s) {
const t = s[0];
if (t >> 4) throw new Error("Trying to deserialize integer with invalid serialized item code");
const e = 15 & t, n = 1 + e;
@@ -2201,12 +2201,12 @@ function cr(s) {
let n = 2;
const r = [];
for (let i = 0; i < e; i++) {
- const { number: o, byteLength: a } = Un(s.slice(n));
+ const { number: o, byteLength: a } = Fn(s.slice(n));
n += a;
- const h = 0xffn & o, u = -256n & o;
+ const h = 0xffn & o, g = -256n & o;
for (let d = 0; d < h; d++) {
const p = BigInt(s[n]);
- r.push(u | p), n++;
+ r.push(g | p), n++;
}
}
return { numbers: r, byteLength: n };
@@ -2242,12 +2242,12 @@ class rt {
return this._length;
}
}
-const tt = qt("cstr", 4), ht = qt("cend", 4), de = qt("dstr", 4), ue = qt("dend", 4), ur = [tt, de], lr = [ht, ue], Ke = tt.length + ht.length;
+const tt = Ot("cstr", 4), ht = Ot("cend", 4), de = Ot("dstr", 4), ue = Ot("dend", 4), ur = [tt, de], lr = [ht, ue], Ke = tt.length + ht.length;
function Hn(s) {
const t = tt.length, e = s.slice(-t);
return ur.some((n) => Bt(s, n, 4)) && lr.some((n) => Bt(e, n, 4));
}
-class It extends Error {
+class Rt extends Error {
constructor(t) {
super(), this.type = t;
}
@@ -2261,8 +2261,8 @@ class $n {
addCommandChunk(t) {
if (this.status === "completed") return;
const e = Bt(t, tt, 4);
- if (!this.chunks.length && !e) throw new It("no-first-chunk");
- if (this.chunks.length && e) throw new It("incomplete-joining");
+ if (!this.chunks.length && !e) throw new Rt("no-first-chunk");
+ if (this.chunks.length && e) throw new Rt("incomplete-joining");
this.chunks.push(this.unframeCommandChunk(t)), function(n) {
return Bt(n.slice(-4), ht, 4);
}(t) && (this.status = "completed", this.onComplete(this.chunks.getBuffer()));
@@ -2288,13 +2288,13 @@ class yt {
const n = function(r) {
const i = /* @__PURE__ */ new Map();
for (const a of r) {
- const h = -256n & a, u = 0xffn & a, d = i.get(h) ?? new rt();
- d.length || i.set(h, d), d.push(Number(u));
+ const h = -256n & a, g = 0xffn & a, d = i.get(h) ?? new rt();
+ d.length || i.set(h, d), d.push(Number(g));
}
const o = new rt();
o.push([16, i.size]);
for (const [a, h] of i) {
- const { length: u } = h.getBytesChunks(), d = a | 0xffn & BigInt(u);
+ const { length: g } = h.getBytesChunks(), d = a | 0xffn & BigInt(g);
h.unshift(Ye(d)), o.push(h.getBuffer());
}
return o.getBuffer();
@@ -2335,7 +2335,7 @@ function jn(s) {
switch (n++, gr(s[n])) {
case X.Int:
{
- const { number: i, byteLength: o } = Un(s.slice(n));
+ const { number: i, byteLength: o } = Fn(s.slice(n));
e[r] = Number(i), n += o;
}
break;
@@ -2358,7 +2358,7 @@ function gr(s) {
if (t <= X.Min || t >= X.Max) throw new Error("Not existing type");
return t;
}
-function qt(s, t) {
+function Ot(s, t) {
if (s.length !== t) throw new Error("Wrong string length");
const e = new Uint8Array(t);
for (let n = 0; n < s.length; n++) e[n] = s.charCodeAt(n);
@@ -2379,12 +2379,12 @@ function Qn(s, t) {
case H.SegmentDataSendingCompleted:
return function(e, n) {
const r = new yt(e.c, n);
- return r.addInteger("i", e.i), r.complete(), r.getResultBuffers();
+ return r.addInteger("i", e.i), r.addInteger("r", e.r), r.complete(), r.getResultBuffers();
}(s, t);
case H.SegmentRequest:
return function(e, n) {
const r = new yt(e.c, n);
- return r.addInteger("i", e.i), e.b && r.addInteger("b", e.b), r.complete(), r.getResultBuffers();
+ return r.addInteger("i", e.i), r.addInteger("r", e.r), e.b && r.addInteger("b", e.b), r.complete(), r.getResultBuffers();
}(s, t);
case H.SegmentsAnnouncement:
return function(e, n) {
@@ -2394,11 +2394,11 @@ function Qn(s, t) {
case H.SegmentData:
return function(e, n) {
const r = new yt(e.c, n);
- return r.addInteger("i", e.i), r.addInteger("s", e.s), r.complete(), r.getResultBuffers();
+ return r.addInteger("i", e.i), r.addInteger("s", e.s), r.addInteger("r", e.r), r.complete(), r.getResultBuffers();
}(s, t);
}
}
-const fr = Object.freeze(Object.defineProperty({ __proto__: null, BinaryCommandChunksJoiner: $n, BinaryCommandJoiningError: It, PeerCommandType: H, deserializeCommand: jn, isCommandChunk: Hn, serializePeerCommand: Qn }, Symbol.toStringTag, { value: "Module" }));
+const fr = Object.freeze(Object.defineProperty({ __proto__: null, BinaryCommandChunksJoiner: $n, BinaryCommandJoiningError: Rt, PeerCommandType: H, deserializeCommand: jn, isCommandChunk: Hn, serializePeerCommand: Qn }, Symbol.toStringTag, { value: "Module" }));
class pr {
constructor(t, e, n, r) {
f(this, "commandChunks");
@@ -2406,53 +2406,57 @@ class pr {
f(this, "onChunkDownloaded");
f(this, "onChunkUploaded");
f(this, "onDataReceived", (t) => {
- Hn(t) ? this.receivingCommandBytes(t) : (this.eventHandlers.onSegmentChunkReceived(t), this.onChunkDownloaded(t.length, "p2p", this.connection.idUtf8));
+ Hn(t) ? this.receivingCommandBytes(t) : (this.eventHandlers.onSegmentChunkReceived(t), this.onChunkDownloaded(t.byteLength, "p2p", this.connection.idUtf8));
});
this.connection = t, this.peerConfig = e, this.eventHandlers = n, this.onChunkDownloaded = r.getEventDispatcher("onChunkDownloaded"), this.onChunkUploaded = r.getEventDispatcher("onChunkUploaded"), t.on("data", this.onDataReceived);
}
sendCommand(t) {
const e = Qn(t, this.peerConfig.webRtcMaxMessageSize);
- for (const n of e) this.connection.send(n);
+ for (const n of e) this.connection.write(n);
}
stopUploadingSegmentData() {
var t;
(t = this.uploadingContext) == null || t.stopUploading(), this.uploadingContext = void 0;
}
- async splitSegmentDataToChunksAndUploadAsync(t) {
+ getUploadingRequestId() {
+ var t;
+ return (t = this.uploadingContext) == null ? void 0 : t.requestId;
+ }
+ async splitSegmentDataToChunksAndUploadAsync(t, e) {
if (this.uploadingContext) throw new Error("Some segment data is already uploading.");
- const e = function* (u, d) {
- let p = u.byteLength;
- for (; p > 0; ) {
- const _ = p >= d ? d : p, S = u.byteLength - p, c = u.slice(S, S + _);
- p -= _, yield c;
+ const n = function* (d, p) {
+ let y = d.byteLength;
+ for (; y > 0; ) {
+ const w = y >= p ? p : y, c = d.byteLength - y, u = d.slice(c, c + w);
+ y -= w, yield u;
}
- }(t, this.peerConfig.webRtcMaxMessageSize), { promise: n, resolve: r, reject: i } = function() {
- let u, d;
- return { promise: new Promise((p, _) => {
- u = p, d = _;
- }), resolve: u, reject: d };
+ }(t, this.peerConfig.webRtcMaxMessageSize), { promise: r, resolve: i, reject: o } = function() {
+ let d, p;
+ return { promise: new Promise((y, w) => {
+ d = y, p = w;
+ }), resolve: d, reject: p };
}();
- let o = !1;
- const a = { stopUploading: () => {
- o = !1;
- } };
- this.uploadingContext = a;
- const h = () => {
- if (o) for (; ; ) {
- const u = e.next().value;
- if (!u) {
- r();
+ let a = !1;
+ const h = { stopUploading: () => {
+ a = !1;
+ }, requestId: e };
+ this.uploadingContext = h;
+ const g = () => {
+ if (a) for (; ; ) {
+ const d = n.next().value;
+ if (!d) {
+ i();
break;
}
- const d = this.connection.write(u);
- if (this.onChunkUploaded(u.byteLength, this.connection.idUtf8), !d) break;
+ const p = this.connection.write(d);
+ if (this.onChunkUploaded(d.byteLength, this.connection.idUtf8), !p) break;
}
- else i();
+ else o();
};
try {
- this.connection.on("drain", h), o = !0, h(), await n;
+ this.connection.on("drain", g), a = !0, g(), await r;
} finally {
- this.connection.off("drain", h), this.uploadingContext === a && (this.uploadingContext = void 0);
+ this.connection.off("drain", g), this.uploadingContext === h && (this.uploadingContext = void 0);
}
}
receivingCommandBytes(t) {
@@ -2464,14 +2468,14 @@ class pr {
try {
this.commandChunks.addCommandChunk(t);
} catch (e) {
- if (!(e instanceof It)) return;
+ if (!(e instanceof Rt)) return;
this.commandChunks = void 0;
}
}
}
const { PeerCommandType: T } = fr;
class Pt {
- constructor(t, e, n, r) {
+ constructor(t, e, n, r, i) {
f(this, "id");
f(this, "peerProtocol");
f(this, "downloadingContext");
@@ -2481,38 +2485,39 @@ class Pt {
f(this, "logger", P("p2pml-core:peer"));
f(this, "onPeerClosed");
f(this, "onCommandReceived", async (t) => {
- var e, n, r;
+ var e, n, r, i;
switch (t.c) {
case T.SegmentsAnnouncement:
this.loadedSegments = new Set(t.l), this.httpLoadingSegments = new Set(t.p), this.eventHandlers.onSegmentsAnnouncement();
break;
case T.SegmentRequest:
- this.peerProtocol.stopUploadingSegmentData(), this.eventHandlers.onSegmentRequested(this, t.i, t.b);
+ this.peerProtocol.stopUploadingSegmentData(), this.eventHandlers.onSegmentRequested(this, t.i, t.r, t.b);
break;
case T.SegmentData:
{
if (!this.downloadingContext || this.downloadingContext.isSegmentDataCommandReceived) break;
- const { request: i, controls: o } = this.downloadingContext;
- if (i.segment.externalId !== t.i) break;
- this.downloadingContext.isSegmentDataCommandReceived = !0, o.firstBytesReceived(), i.totalBytes === void 0 ? i.setTotalBytes(t.s) : i.totalBytes - i.loadedBytes !== t.s && (i.clearLoadedBytes(), this.sendCancelSegmentRequestCommand(i.segment), this.cancelSegmentDownloading("peer-response-bytes-length-mismatch"), this.destroy());
+ 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());
}
break;
case T.SegmentDataSendingCompleted: {
- const i = this.downloadingContext;
- if (!(i != null && i.isSegmentDataCommandReceived)) return;
- const { request: o, controls: a } = i;
- if (i.request.segment.externalId !== t.i) 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)) ?? !0;
- if (this.downloadingContext !== i) return;
- if (!h) return o.clearLoadedBytes(), this.cancelSegmentDownloading("p2p-segment-validation-failed"), void this.destroy();
- this.downloadingErrors = [], a.completeOnSuccess(), this.downloadingContext = void 0;
+ const o = this.downloadingContext;
+ if (!(o != null && o.isSegmentDataCommandReceived)) return;
+ const { request: a, controls: h } = o;
+ if (o.request.segment.externalId !== t.i || o.requestId !== t.r) return a.clearLoadedBytes(), this.cancelSegmentDownloading("peer-protocol-violation"), void this.destroy();
+ if (a.loadedBytes !== a.totalBytes) return a.clearLoadedBytes(), this.cancelSegmentDownloading("peer-response-bytes-length-mismatch"), void this.destroy();
+ const g = await ((n = (e = this.peerConfig).validateP2PSegment) == null ? void 0 : n.call(e, a.segment.url, a.segment.byteRange)) ?? !0;
+ if (this.downloadingContext !== o) return;
+ if (!g) return a.clearLoadedBytes(), this.cancelSegmentDownloading("p2p-segment-validation-failed"), void this.destroy();
+ this.downloadingErrors = [], h.completeOnSuccess(), this.downloadingContext = void 0;
break;
}
case T.SegmentAbsent:
- ((r = this.downloadingContext) == null ? void 0 : r.request.segment.externalId) === t.i && (this.cancelSegmentDownloading("peer-segment-absent"), this.loadedSegments.delete(t.i));
+ ((r = this.downloadingContext) == null ? void 0 : r.request.segment.externalId) === t.i && ((i = this.downloadingContext) == null ? void 0 : i.requestId) === t.r && (this.cancelSegmentDownloading("peer-segment-absent"), this.loadedSegments.delete(t.i));
break;
case T.CancelSegmentRequest:
+ if (this.peerProtocol.getUploadingRequestId() !== t.r) break;
this.peerProtocol.stopUploadingSegmentData();
}
});
@@ -2527,14 +2532,14 @@ class Pt {
this.destroy();
});
f(this, "onConnectionError", (t) => {
- this.logger(`peer connection error ${this.id} %O`, t);
+ this.logger(`peer connection error ${this.id} %O`, t), this.eventTarget.getEventDispatcher("onPeerError")({ peerId: this.id, streamType: this.streamType, error: t });
const e = t.code;
- (e === "ERR_DATA_CHANNEL" || e === "ERR_CONNECTION_FAILURE" || e === "ERR_CONNECTION_FAILURE") && this.destroy();
+ (e === "ERR_DATA_CHANNEL" || e === "ERR_CONNECTION_FAILURE") && this.destroy();
});
f(this, "destroy", () => {
- this.cancelSegmentDownloading("peer-closed"), this.connection.destroy(), this.eventHandlers.onPeerClosed(this), this.onPeerClosed({ peerId: this.id }), this.logger(`peer closed ${this.id}`);
+ 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.onPeerClosed = r.getEventDispatcher("onPeerClose"), this.id = Pt.getPeerIdFromConnection(t), this.peerProtocol = new pr(t, n, { onSegmentChunkReceived: this.onSegmentChunkReceived, onCommandReceived: this.onCommandReceived }, r), r.getEventDispatcher("onPeerConnect")({ peerId: this.id }), 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 = r, this.eventTarget = i, this.onPeerClosed = i.getEventDispatcher("onPeerClose"), this.id = Pt.getPeerIdFromConnection(t), this.peerProtocol = new pr(t, n, { onSegmentChunkReceived: this.onSegmentChunkReceived, onCommandReceived: this.onCommandReceived }, i), i.getEventDispatcher("onPeerConnect")({ peerId: this.id, streamType: r }), t.on("error", this.onConnectionError), t.on("close", this.onPeerConnectionClosed), t.on("end", this.onPeerConnectionClosed), t.on("finish", this.onPeerConnectionClosed);
}
get downloadingSegment() {
var t;
@@ -2546,44 +2551,44 @@ class Pt {
}
downloadSegment(t) {
if (this.downloadingContext) throw new Error("Some segment already is downloading");
- this.downloadingContext = { request: t, isSegmentDataCommandReceived: !1, controls: t.start({ downloadSource: "p2p", peerId: this.id }, { notReceivingBytesTimeoutMs: this.peerConfig.p2pNotReceivingBytesTimeoutMs, abort: (n) => {
+ this.downloadingContext = { request: t, requestId: Math.floor(1e3 * Math.random()), isSegmentDataCommandReceived: !1, controls: t.start({ downloadSource: "p2p", peerId: this.id }, { notReceivingBytesTimeoutMs: this.peerConfig.p2pNotReceivingBytesTimeoutMs, abort: (n) => {
if (!this.downloadingContext) return;
- const { request: r } = this.downloadingContext;
- this.sendCancelSegmentRequestCommand(r.segment), this.downloadingErrors.push(n), this.downloadingContext = void 0, this.downloadingErrors.filter((i) => i.type === "bytes-receiving-timeout").length >= this.peerConfig.p2pErrorRetries && this.destroy();
+ const { request: r, requestId: i } = this.downloadingContext;
+ this.sendCancelSegmentRequestCommand(r.segment, i), this.downloadingErrors.push(n), this.downloadingContext = void 0, this.downloadingErrors.filter((o) => o.type === "bytes-receiving-timeout").length >= this.peerConfig.p2pErrorRetries && this.destroy();
} }) };
- const e = { c: T.SegmentRequest, i: t.segment.externalId };
+ const e = { c: T.SegmentRequest, r: this.downloadingContext.requestId, i: t.segment.externalId };
t.loadedBytes && (e.b = t.loadedBytes), this.peerProtocol.sendCommand(e);
}
- async uploadSegmentData(t, e) {
- const { externalId: n } = t;
+ async uploadSegmentData(t, e, n) {
+ const { externalId: r } = t;
this.logger(`send segment ${t.externalId} to ${this.id}`);
- const r = { c: T.SegmentData, i: n, s: e.byteLength };
- this.peerProtocol.sendCommand(r);
+ const i = { c: T.SegmentData, i: r, r: e, s: n.byteLength };
+ this.peerProtocol.sendCommand(i);
try {
- await this.peerProtocol.splitSegmentDataToChunksAndUploadAsync(e), this.sendSegmentDataSendingCompletedCommand(t), this.logger(`segment ${n} has been sent to ${this.id}`);
+ await this.peerProtocol.splitSegmentDataToChunksAndUploadAsync(n, e), this.sendSegmentDataSendingCompletedCommand(t, e), this.logger(`segment ${r} has been sent to ${this.id}`);
} catch {
- this.logger(`cancel segment uploading ${n}`);
+ this.logger(`cancel segment uploading ${r}`);
}
}
cancelSegmentDownloading(t) {
if (!this.downloadingContext) return;
const { request: e, controls: n } = this.downloadingContext, { segment: r } = e;
this.logger(`cancel segment request ${r.externalId} (${t})`);
- const i = new I(t);
+ const i = new R(t);
n.abortOnError(i), this.downloadingContext = void 0, this.downloadingErrors.push(i);
}
sendSegmentsAnnouncementCommand(t, e) {
const n = { c: T.SegmentsAnnouncement, p: e, l: t };
this.peerProtocol.sendCommand(n);
}
- sendSegmentAbsentCommand(t) {
- this.peerProtocol.sendCommand({ c: T.SegmentAbsent, i: t });
+ sendSegmentAbsentCommand(t, e) {
+ this.peerProtocol.sendCommand({ c: T.SegmentAbsent, i: t, r: e });
}
- sendCancelSegmentRequestCommand(t) {
- this.peerProtocol.sendCommand({ c: T.CancelSegmentRequest, i: t.externalId });
+ sendCancelSegmentRequestCommand(t, e) {
+ this.peerProtocol.sendCommand({ c: T.CancelSegmentRequest, i: t.externalId, r: e });
}
- sendSegmentDataSendingCompletedCommand(t) {
- this.peerProtocol.sendCommand({ c: T.SegmentDataSendingCompleted, i: t.externalId });
+ sendSegmentDataSendingCompletedCommand(t, e) {
+ this.peerProtocol.sendCommand({ c: T.SegmentDataSendingCompleted, r: e, i: t.externalId });
}
static getPeerIdFromConnection(t) {
return function(e) {
@@ -2605,31 +2610,31 @@ class mr {
n != null && n.peer ? t.destroy() : (n || (n = { potentialConnections: /* @__PURE__ */ new Set() }, t.idUtf8 = e, n.potentialConnections.add(t), this._peers.set(e, n)), t.on("connect", () => {
if (n && !n.peer) {
for (const r of n.potentialConnections) r !== t && r.destroy();
- n.potentialConnections.clear(), n.peer = new Pt(t, { onPeerClosed: this.onPeerClosed, onSegmentRequested: this.eventHandlers.onSegmentRequested, onSegmentsAnnouncement: this.eventHandlers.onSegmentsAnnouncement }, this.config, this.eventTarget), this.logger(`connected with peer: ${n.peer.id} ${this.streamShortId}`), this.eventHandlers.onPeerConnected(n.peer);
+ n.potentialConnections.clear(), n.peer = new Pt(t, { onPeerClosed: this.onPeerClosed, onSegmentRequested: this.eventHandlers.onSegmentRequested, onSegmentsAnnouncement: this.eventHandlers.onSegmentsAnnouncement }, this.config, this.stream.type, this.eventTarget), this.logger(`connected with peer: ${n.peer.id} ${this.streamShortId}`), this.eventHandlers.onPeerConnected(n.peer);
}
}));
});
f(this, "onTrackerClientWarning", (t) => {
- this.logger(`tracker warning (${this.streamShortId}: ${t})`);
+ this.logger(`tracker warning (${this.streamShortId}: ${t})`), this.eventTarget.getEventDispatcher("onTrackerWarning")({ streamType: this.stream.type, warning: t });
});
f(this, "onTrackerClientError", (t) => {
- this.logger(`tracker error (${this.streamShortId}: ${t})`);
+ this.logger(`tracker error (${this.streamShortId}: ${t})`), this.eventTarget.getEventDispatcher("onTrackerError")({ streamType: this.stream.type, error: t });
});
f(this, "onPeerClosed", (t) => {
this.logger(`peer closed: ${t.id}`), this._peers.delete(t.id);
});
- this.eventHandlers = n, this.config = r, this.eventTarget = i;
+ this.stream = e, this.eventHandlers = n, this.config = r, this.eventTarget = i;
const o = function(h) {
- const u = rr.fromUtf8(h).slice(1);
- return btoa(u);
+ const g = rr.fromUtf8(h).slice(1);
+ return btoa(g);
}(t);
this.streamShortId = z(e);
const a = function(h) {
- const u = [h], d = 20 - h.length;
- for (let p = 0; p < d; p++) u.push(or[Math.floor(62 * Math.random())]);
- return u.join("");
+ const g = [h], d = 20 - h.length;
+ for (let p = 0; p < d; p++) g.push(or[Math.floor(62 * Math.random())]);
+ return g.join("");
}(r.trackerClientVersionPrefix);
- this.client = new ae({ infoHash: Ge(o), peerId: Ge(a), announce: this.config.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;
+ this.client = new ae({ infoHash: Ge(o), peerId: Ge(a), announce: /^((?!chrome|android).)*safari/i.test(navigator.userAgent) ? r.announceTrackers.slice(0, 1) : r.announceTrackers, rtcConfig: this.config.rtcConfig }), this.client.on("peer", this.onReceivePeerConnection), this.client.on("warning", this.onTrackerClientWarning), this.client.on("error", this.onTrackerClientError), this.logger(`create new client;
stream: ${this.streamShortId}; hash: ${o}
peerId: ${a}`);
}
@@ -2659,9 +2664,9 @@ function $(s) {
}
function vt(s, t, e, n) {
const { highDemandTimeWindow: r, httpDownloadTimeWindow: i, p2pDownloadTimeWindow: o } = e;
- return { isHighDemand: Ut(s, t, r), isHttpDownloadable: Ut(s, t, i), isP2PDownloadable: Ut(s, t, o) && (!n || n.isSegmentLoadingOrLoadedBySomeone(s)) };
+ return { isHighDemand: Ft(s, t, r), isHttpDownloadable: Ft(s, t, i), isP2PDownloadable: Ft(s, t, o) && (!n || n.isSegmentLoadingOrLoadedBySomeone(s)) };
}
-function Ut(s, t, e) {
+function Ft(s, t, e) {
const { startTime: n, endTime: r } = s, { position: i, rate: o } = t;
return !(i + e * o < n || i > r);
}
@@ -2680,17 +2685,17 @@ class yr {
this.isAnnounceMicrotaskCreated = !1;
}));
});
- f(this, "onSegmentRequested", async (t, e, n) => {
- const r = function(o, a) {
- for (const h of o.segments.values()) if (h.externalId === a) return h;
+ f(this, "onSegmentRequested", async (t, e, n, r) => {
+ const i = function(a, h) {
+ for (const g of a.segments.values()) if (g.externalId === h) return g;
}(this.stream, e);
- if (!r) return;
- const i = await this.segmentStorage.getSegmentData(r);
- i ? await t.uploadSegmentData(r, n !== void 0 ? i.slice(n) : i) : t.sendSegmentAbsentCommand(e);
+ if (!i) return;
+ const o = await this.segmentStorage.getSegmentData(i);
+ o ? await t.uploadSegmentData(i, n, r !== void 0 ? o.slice(r) : o) : t.sendSegmentAbsentCommand(e, n);
});
this.streamManifestUrl = t, this.stream = e, this.requests = n, this.segmentStorage = r, this.config = i, this.eventTarget = o, this.onSegmentAnnouncement = a;
- const h = function(u, d) {
- return `v1-${u}-${$(d)}`;
+ const h = function(g, d) {
+ return `v2-${g}-${$(d)}`;
}(this.config.swarmId ?? this.streamManifestUrl, this.stream);
this.trackerClient = new mr(h, this.stream, { onPeerConnected: this.onPeerConnected, onSegmentRequested: this.onSegmentRequested, onSegmentsAnnouncement: this.onSegmentAnnouncement }, this.config, this.eventTarget), this.segmentStorage.subscribeOnUpdate(this.stream, this.broadcastAnnouncement), this.trackerClient.start();
}
@@ -2767,7 +2772,6 @@ class _r {
}
let br = class {
constructor(s, t, e, n, r, i) {
- f(this, "id");
f(this, "currentAttempt");
f(this, "_failedAttempts", new wr());
f(this, "finalData");
@@ -2788,14 +2792,14 @@ let br = class {
var t;
if (this.throwErrorIfNotLoadingStatus(), !this.currentAttempt) return;
this.setStatus("failed");
- const s = new I("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 }), this.notReceivingBytesTimeout.clear(), this.manageBandwidthCalculatorsState("stop"), this.requestProcessQueueCallback();
+ const s = new R("bytes-receiving-timeout");
+ (t = this._abortRequestCallback) == null || t.call(this, s), this.logger(`${this.downloadSource} ${this.segment.externalId} failed ${s.type}`), this._failedAttempts.add({ ...this.currentAttempt, error: s }), this.onSegmentError({ segment: this.segment, error: s, downloadSource: this.currentAttempt.downloadSource, peerId: this.currentAttempt.downloadSource === "p2p" ? this.currentAttempt.peerId : void 0, streamType: this.segment.stream.type }), this.notReceivingBytesTimeout.clear(), this.manageBandwidthCalculatorsState("stop"), this.requestProcessQueueCallback();
});
f(this, "abortOnError", (s) => {
- 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 }), this.notReceivingBytesTimeout.clear(), this.manageBandwidthCalculatorsState("stop"), this.requestProcessQueueCallback());
+ this.throwErrorIfNotLoadingStatus(), this.currentAttempt && (this.setStatus("failed"), this.logger(`${this.downloadSource} ${this.segment.externalId} failed ${s.type}`), this._failedAttempts.add({ ...this.currentAttempt, error: s }), this.onSegmentError({ segment: this.segment, error: s, downloadSource: this.currentAttempt.downloadSource, peerId: this.currentAttempt.downloadSource === "p2p" ? this.currentAttempt.peerId : void 0, streamType: this.segment.stream.type }), this.notReceivingBytesTimeout.clear(), this.manageBandwidthCalculatorsState("stop"), this.requestProcessQueueCallback());
});
f(this, "completeOnSuccess", () => {
- this.throwErrorIfNotLoadingStatus(), this.currentAttempt && (this.manageBandwidthCalculatorsState("stop"), this.notReceivingBytesTimeout.clear(), this.finalData = ce(this.bytes), this.setStatus("succeed"), this._totalBytes = this._loadedBytes, this.onSegmentLoaded({ bytesLength: this.finalData.byteLength, downloadSource: this.currentAttempt.downloadSource, peerId: this.currentAttempt.downloadSource === "p2p" ? this.currentAttempt.peerId : void 0 }), this.logger(`${this.currentAttempt.downloadSource} ${this.segment.externalId} succeed`), this.requestProcessQueueCallback());
+ this.throwErrorIfNotLoadingStatus(), this.currentAttempt && (this.manageBandwidthCalculatorsState("stop"), this.notReceivingBytesTimeout.clear(), this.finalData = ce(this.bytes), this.setStatus("succeed"), this._totalBytes = this._loadedBytes, this.onSegmentLoaded({ segmentUrl: this.segment.url, bytesLength: this.finalData.byteLength, downloadSource: this.currentAttempt.downloadSource, peerId: this.currentAttempt.downloadSource === "p2p" ? this.currentAttempt.peerId : void 0, streamType: this.segment.stream.type }), this.logger(`${this.currentAttempt.downloadSource} ${this.segment.externalId} succeed`), this.requestProcessQueueCallback());
});
f(this, "addLoadedChunk", (s) => {
if (this.throwErrorIfNotLoadingStatus(), !this.currentAttempt || !this.progress) return;
@@ -2806,11 +2810,11 @@ let br = class {
f(this, "firstBytesReceived", () => {
this.throwErrorIfNotLoadingStatus(), this.notReceivingBytesTimeout.restart();
});
- this.segment = s, this.requestProcessQueueCallback = t, this.bandwidthCalculators = e, this.playback = n, this.playbackConfig = r, this.onSegmentError = i.getEventDispatcher("onSegmentError"), this.onSegmentAbort = i.getEventDispatcher("onSegmentAbort"), this.onSegmentStart = i.getEventDispatcher("onSegmentStart"), this.onSegmentLoaded = i.getEventDispatcher("onSegmentLoaded"), this.id = this.segment.runtimeId;
+ this.segment = s, this.requestProcessQueueCallback = t, this.bandwidthCalculators = e, this.playback = n, this.playbackConfig = r, this.onSegmentError = i.getEventDispatcher("onSegmentError"), this.onSegmentAbort = i.getEventDispatcher("onSegmentAbort"), this.onSegmentStart = i.getEventDispatcher("onSegmentStart"), this.onSegmentLoaded = i.getEventDispatcher("onSegmentLoaded");
const { byteRange: o } = this.segment;
if (o) {
- const { end: h, start: u } = o;
- this._totalBytes = h - u + 1;
+ const { end: h, start: g } = o;
+ this._totalBytes = h - g + 1;
}
this.notReceivingBytesTimeout = new Sr(this.abortOnTimeout);
const { type: a } = this.segment.stream;
@@ -2860,7 +2864,7 @@ let br = class {
}
abortFromProcessQueue() {
var s, t, e, n;
- this.throwErrorIfNotLoadingStatus(), this.setStatus("aborted"), this.logger(`${(s = this.currentAttempt) == null ? void 0 : s.downloadSource} ${this.segment.externalId} aborted`), (t = this._abortRequestCallback) == null || t.call(this, new I("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 }), this._abortRequestCallback = void 0, this.manageBandwidthCalculatorsState("stop"), this.notReceivingBytesTimeout.clear();
+ this.throwErrorIfNotLoadingStatus(), this.setStatus("aborted"), this.logger(`${(s = this.currentAttempt) == null ? void 0 : s.downloadSource} ${this.segment.externalId} aborted`), (t = this._abortRequestCallback) == null || t.call(this, new R("abort")), this.onSegmentAbort({ segment: this.segment, downloadSource: (e = this.currentAttempt) == null ? void 0 : e.downloadSource, peerId: ((n = this.currentAttempt) == null ? void 0 : n.downloadSource) === "p2p" ? this.currentAttempt.peerId : void 0, streamType: this.segment.stream.type }), this._abortRequestCallback = void 0, this.manageBandwidthCalculatorsState("stop"), this.notReceivingBytesTimeout.clear();
}
throwErrorIfNotLoadingStatus() {
if (this._status !== "loading") throw new Error(`Request has been already ${this.status}.`);
@@ -2983,14 +2987,14 @@ function* Ze(s, t, e, n) {
if (d.done) return;
h = d.value;
} while (h !== o);
- const u = vt(h, t, e, n);
- if (Ht(u)) {
+ const g = vt(h, t, e, n);
+ if (Ht(g)) {
const d = a.next();
if (d.done) return;
- const p = d.value, _ = vt(p, t, e, n);
- if (Ht(_)) return;
- u.isHighDemand = !0, yield { segment: h, statuses: u }, yield { segment: p, statuses: _ };
- } else yield { segment: h, statuses: u };
+ const p = d.value, y = vt(p, t, e, n);
+ if (Ht(y)) return;
+ g.isHighDemand = !0, yield { segment: h, statuses: g }, yield { segment: p, statuses: y };
+ } else yield { segment: h, statuses: g };
for (const d of a) {
const p = vt(d, t, e, n);
if (Ht(p)) break;
@@ -3026,17 +3030,17 @@ class Lr {
});
this.streamManifestUrl = t, this.lastRequestedSegment = e, this.streamDetails = n, this.config = r, this.bandwidthCalculators = i, this.segmentStorage = o, this.eventTarget = a;
const h = this.lastRequestedSegment.stream;
- if (this.playback = { position: this.lastRequestedSegment.startTime, rate: 1 }, this.segmentAvgDuration = function(u) {
- const { segments: d } = u;
+ if (this.playback = { position: this.lastRequestedSegment.startTime, rate: 1 }, this.segmentAvgDuration = function(g) {
+ const { segments: d } = g;
let p = 0;
- const _ = d.size;
- for (const S of d.values()) p += S.endTime - S.startTime;
- return p / _;
+ const y = d.size;
+ for (const w of d.values()) p += w.endTime - w.startTime;
+ return p / y;
}(h), this.requests = new Cr(this.requestProcessQueueMicrotask, this.bandwidthCalculators, this.playback, this.config, this.eventTarget), !this.segmentStorage.isInitialized) throw new Error("Segment storage is not initialized.");
- this.segmentStorage.addIsSegmentLockedPredicate((u) => u.stream === h && function(d, p, _) {
- const { isHighDemand: S = !1, isHttpDownloadable: c = !1, isP2PDownloadable: g = !1 } = vt(d, p, _);
- return S || c || g;
- }(u, this.playback, this.config)), this.p2pLoaders = new _r(this.streamManifestUrl, this.lastRequestedSegment.stream, this.requests, this.segmentStorage, this.config, this.eventTarget, this.requestProcessQueueMicrotask), this.logger = P(`p2pml-core:hybrid-loader-${h.type}`), this.logger.color = "coral", this.setIntervalLoading();
+ this.segmentStorage.addIsSegmentLockedPredicate((g) => g.stream === h && function(d, p, y) {
+ const { isHighDemand: w = !1, isHttpDownloadable: c = !1, isP2PDownloadable: u = !1 } = vt(d, p, y);
+ return w || c || u;
+ }(g, this.playback, this.config)), this.p2pLoaders = new _r(this.streamManifestUrl, this.lastRequestedSegment.stream, this.requests, this.segmentStorage, this.config, this.eventTarget, this.requestProcessQueueMicrotask), this.logger = P(`p2pml-core:hybrid-loader-${h.type}`), this.logger.color = "coral", this.setIntervalLoading();
}
setIntervalLoading() {
const t = this.p2pLoaders.currentLoader.connectedPeerCount, e = 1e3 * Math.random() * t + 1e3;
@@ -3062,25 +3066,25 @@ class Lr {
var o;
const { stream: n } = this.lastRequestedSegment, { httpErrorRetries: r } = this.config, i = performance.now();
for (const a of this.requests.items()) {
- const { downloadSource: h, status: u, segment: d, isHandledByProcessQueue: p } = a, _ = ((o = this.engineRequest) == null ? void 0 : o.segment) === d ? this.engineRequest : void 0;
- switch (u) {
+ const { downloadSource: h, status: g, segment: d, isHandledByProcessQueue: p } = a, y = ((o = this.engineRequest) == null ? void 0 : o.segment) === d ? this.engineRequest : void 0;
+ switch (g) {
case "loading":
- t.has(d.runtimeId) || _ || (a.abortFromProcessQueue(), this.requests.remove(a));
+ t.has(d.runtimeId) || y || (a.abortFromProcessQueue(), this.requests.remove(a));
break;
case "succeed":
if (!a.data || !h) break;
- h === "http" && this.p2pLoaders.currentLoader.broadcastAnnouncement(), _ && (_.resolve(a.data, this.getBandwidth(e)), this.engineRequest = void 0), this.requests.remove(a), this.segmentStorage.storeSegment(a.segment, a.data, this.streamDetails.isLive);
+ h === "http" && this.p2pLoaders.currentLoader.broadcastAnnouncement(), y && (y.resolve(a.data, this.getBandwidth(e)), this.engineRequest = void 0), this.requests.remove(a), this.segmentStorage.storeSegment(a.segment, a.data, this.streamDetails.isLive);
break;
case "failed":
- h !== "http" || p || this.p2pLoaders.currentLoader.broadcastAnnouncement(), _ || n.segments.has(a.segment.runtimeId) || this.requests.remove(a), a.failedAttempts.httpAttemptsCount >= r && _ && (this.engineRequest = void 0, _.reject());
+ h !== "http" || p || this.p2pLoaders.currentLoader.broadcastAnnouncement(), y || n.segments.has(a.segment.runtimeId) || this.requests.remove(a), a.failedAttempts.httpAttemptsCount >= r && y && (this.engineRequest = void 0, y.reject());
break;
case "not-started":
case "aborted":
this.requests.remove(a);
}
a.markHandledByProcessQueue();
- const { lastAttempt: S } = a.failedAttempts;
- S && i - S.error.timestamp > 6e4 && a.failedAttempts.clear();
+ const { lastAttempt: w } = a.failedAttempts;
+ w && i - w.error.timestamp > 6e4 && a.failedAttempts.clear();
}
}
processQueue() {
@@ -3089,23 +3093,23 @@ class Lr {
this.processRequests(e, n);
const { simultaneousHttpDownloads: r, simultaneousP2PDownloads: i, httpErrorRetries: o } = this.config;
if ((a = this.engineRequest) != null && a.shouldBeStartedImmediately && this.engineRequest.status === "pending" && this.requests.executingHttpCount < r) {
- const { segment: h } = this.engineRequest, u = this.requests.get(h);
- (!u || u.status === "not-started" || u.status === "failed" && u.failedAttempts.httpAttemptsCount < this.config.httpErrorRetries) && this.loadThroughHttp(h);
+ const { segment: h } = this.engineRequest, g = this.requests.get(h);
+ (!g || g.status === "not-started" || g.status === "failed" && g.failedAttempts.httpAttemptsCount < this.config.httpErrorRetries) && this.loadThroughHttp(h);
}
for (const h of t) {
- const { statuses: u, segment: d } = h, p = this.requests.get(d);
- if (u.isHighDemand) {
+ const { statuses: g, segment: d } = h, p = this.requests.get(d);
+ if (g.isHighDemand) {
if ((p == null ? void 0 : p.downloadSource) === "http" && p.status === "loading" || (p == null ? void 0 : p.downloadSource) === "http" && p.status === "failed" && p.failedAttempts.httpAttemptsCount >= o) continue;
- const _ = (p == null ? void 0 : p.status) === "loading" && p.downloadSource === "p2p";
+ const y = (p == null ? void 0 : p.status) === "loading" && p.downloadSource === "p2p";
if (this.requests.executingHttpCount < r) {
- _ && p.abortFromProcessQueue(), this.loadThroughHttp(d);
+ y && p.abortFromProcessQueue(), this.loadThroughHttp(d);
continue;
}
if (this.abortLastHttpLoadingInQueueAfterItem(t, d) && this.requests.executingHttpCount < r) {
- _ && p.abortFromProcessQueue(), this.loadThroughHttp(d);
+ y && p.abortFromProcessQueue(), this.loadThroughHttp(d);
continue;
}
- if (_) continue;
+ if (y) continue;
if (this.requests.executingP2PCount < i) {
this.loadThroughP2P(d);
continue;
@@ -3114,7 +3118,7 @@ class Lr {
this.loadThroughP2P(d);
continue;
}
- } else if (u.isP2PDownloadable) {
+ } else if (g.isP2PDownloadable) {
if ((p == null ? void 0 : p.status) === "loading") continue;
(this.requests.executingP2PCount < i || this.p2pLoaders.currentLoader.isSegmentLoadedBySomeone(d) && this.abortLastP2PLoadingInQueueAfterItem(t, d) && this.requests.executingP2PCount < i) && this.loadThroughP2P(d);
}
@@ -3135,24 +3139,24 @@ class Lr {
const { simultaneousHttpDownloads: t, httpErrorRetries: e } = this.config, n = this.p2pLoaders.currentLoader;
if (this.requests.executingHttpCount >= t || !n.connectedPeerCount) return;
const r = [];
- for (const { segment: u, statuses: d } of Ze(this.lastRequestedSegment, this.playback, this.config, this.p2pLoaders.currentLoader)) {
- if (!d.isHttpDownloadable || d.isP2PDownloadable || this.segmentStorage.hasSegment(u)) continue;
- const p = this.requests.get(u);
- p && (p.status === "loading" || p.status === "succeed" || (p.failedAttempts.httpAttemptsCount ?? 0) >= e) || r.push(u);
+ for (const { segment: g, statuses: d } of Ze(this.lastRequestedSegment, this.playback, this.config, this.p2pLoaders.currentLoader)) {
+ if (!d.isHttpDownloadable || d.isP2PDownloadable || this.segmentStorage.hasSegment(g)) continue;
+ const p = this.requests.get(g);
+ p && (p.status === "loading" || p.status === "succeed" || (p.failedAttempts.httpAttemptsCount ?? 0) >= e) || r.push(g);
}
if (!r.length || t - this.requests.executingHttpCount === 0) return;
- const i = n.connectedPeerCount + 1, o = Math.min(r.length, t * i), a = function(u) {
- for (let d = u.length - 1; d > 0; d--) {
+ const i = n.connectedPeerCount + 1, o = Math.min(r.length, t * i), a = function(g) {
+ for (let d = g.length - 1; d > 0; d--) {
const p = Math.floor(Math.random() * (d + 1));
- [u[d], u[p]] = [u[p], u[d]];
+ [g[d], g[p]] = [g[p], g[d]];
}
- return u;
- }(Array.from({ length: o }, (u, d) => d));
+ return g;
+ }(Array.from({ length: o }, (g, d) => d));
let h = o / i;
- for (const u of a) {
+ for (const g of a) {
if (this.requests.executingHttpCount >= t) break;
if (h >= 1 || Math.random() <= h) {
- const d = r[u];
+ const d = r[g];
this.loadThroughHttp(d);
}
if (h--, h <= 0) break;
@@ -3237,9 +3241,9 @@ class tn {
const o = r - 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;
- i = u, a += this.bytes[h];
+ const g = this.loadingOnlyTimestamps[h];
+ if (g < o || this.timestamps[h] < e) break;
+ i = g, a += this.bytes[h];
}
return 8e3 * a / (r - i);
}
@@ -3340,14 +3344,14 @@ class kr {
if (e === 0) return !1;
const n = [], r = [], i = /* @__PURE__ */ new Set(), o = performance.now();
for (const a of this.cache.entries()) {
- const [h, u] = a, { lastAccessed: d, segment: p } = u;
+ const [h, g] = a, { lastAccessed: d, segment: p } = g;
o - d > e ? this.isSegmentLocked(p) || (n.push(h), i.add(p.stream)) : r.push(a);
}
if (this.storageConfig.cachedSegmentsCount > 0) {
let a = r.length - this.storageConfig.cachedSegmentsCount;
if (a > 0) {
- r.sort(([, h], [, u]) => h.lastAccessed - u.lastAccessed);
- for (const [h, { segment: u }] of r) if (!this.isSegmentLocked(u) && (n.push(h), i.add(u.stream), a--, a === 0)) break;
+ r.sort(([, h], [, g]) => h.lastAccessed - g.lastAccessed);
+ for (const [h, { segment: g }] of r) if (!this.isSegmentLocked(g) && (n.push(h), i.add(g.stream), a--, a === 0)) break;
}
}
if (n.length) {
@@ -3385,7 +3389,7 @@ const j = class j {
f(this, "secondaryStreamLoader");
f(this, "streamDetails", { isLive: !1, activeLevelBitrate: 0 });
const e = function n(r) {
- if (Fn(r)) {
+ if (Un(r)) {
const i = {};
return Object.keys(r).forEach((o) => {
if (r[o] !== void 0) {
@@ -3396,7 +3400,7 @@ const j = class j {
}
return r;
}(t ?? {});
- this.commonCoreConfig = Ft({ defaultConfig: j.DEFAULT_COMMON_CORE_CONFIG, baseConfig: e }), this.mainStreamConfig = Ft({ defaultConfig: j.DEFAULT_STREAM_CONFIG, baseConfig: e, specificStreamConfig: e == null ? void 0 : e.mainStream }), this.secondaryStreamConfig = Ft({ defaultConfig: j.DEFAULT_STREAM_CONFIG, baseConfig: e, specificStreamConfig: e == null ? void 0 : e.secondaryStream });
+ this.commonCoreConfig = Ut({ defaultConfig: j.DEFAULT_COMMON_CORE_CONFIG, baseConfig: e }), this.mainStreamConfig = Ut({ defaultConfig: j.DEFAULT_STREAM_CONFIG, baseConfig: e, specificStreamConfig: e == null ? void 0 : e.mainStream }), this.secondaryStreamConfig = Ut({ defaultConfig: j.DEFAULT_STREAM_CONFIG, baseConfig: e, specificStreamConfig: e == null ? void 0 : e.secondaryStream });
}
getConfig() {
return { ...K(this.commonCoreConfig), mainStream: K(this.mainStreamConfig), secondaryStream: K(this.secondaryStreamConfig) };
@@ -3489,13 +3493,13 @@ const j = class j {
return new Lr(this.manifestResponseUrl, t, this.streamDetails, e, this.bandwidthCalculators, this.segmentStorage, this.eventTarget);
}
};
-f(j, "DEFAULT_COMMON_CORE_CONFIG", { cachedSegmentExpiration: void 0, cachedSegmentsCount: 0 }), f(j, "DEFAULT_STREAM_CONFIG", { isP2PDisabled: !1, simultaneousHttpDownloads: 3, simultaneousP2PDownloads: 3, highDemandTimeWindow: 15, httpDownloadTimeWindow: 3e3, p2pDownloadTimeWindow: 6e3, webRtcMaxMessageSize: 65535, p2pNotReceivingBytesTimeoutMs: 1e3, p2pInactiveLoaderDestroyTimeoutMs: 3e4, httpNotReceivingBytesTimeoutMs: 1e3, httpErrorRetries: 3, p2pErrorRetries: 3, trackerClientVersionPrefix: ir, announceTrackers: ["wss://tracker.novage.com.ua", "wss://tracker.webtorrent.dev", "wss://tracker.openwebtorrent.com"], rtcConfig: { iceServers: [{ urls: "stun:stun.l.google.com:19302" }, { urls: "stun:global.stun.twilio.com:3478" }] }, validateP2PSegment: void 0, httpRequestSetup: void 0, swarmId: void 0 });
+f(j, "DEFAULT_COMMON_CORE_CONFIG", { cachedSegmentExpiration: void 0, cachedSegmentsCount: 0 }), f(j, "DEFAULT_STREAM_CONFIG", { isP2PDisabled: !1, simultaneousHttpDownloads: 2, simultaneousP2PDownloads: 3, highDemandTimeWindow: 15, httpDownloadTimeWindow: 3e3, p2pDownloadTimeWindow: 6e3, webRtcMaxMessageSize: 65535, p2pNotReceivingBytesTimeoutMs: 2e3, p2pInactiveLoaderDestroyTimeoutMs: 3e4, httpNotReceivingBytesTimeoutMs: 3e3, httpErrorRetries: 3, p2pErrorRetries: 3, trackerClientVersionPrefix: ir, announceTrackers: ["wss://tracker.novage.com.ua", "wss://tracker.webtorrent.dev", "wss://tracker.openwebtorrent.com"], rtcConfig: { iceServers: [{ urls: "stun:stun.l.google.com:19302" }, { urls: "stun:global.stun.twilio.com:3478" }] }, validateP2PSegment: void 0, httpRequestSetup: void 0, swarmId: void 0 });
let en = j;
const Ar = on.debug;
export {
en as Core,
fe as CoreRequestError,
- I as RequestError,
+ R as RequestError,
Ar as debug
};
//# sourceMappingURL=p2p-media-loader-core.es.min.js.map
diff --git a/resources/p2p-media-loader-hlsjs/1.0.3/p2p-media-loader-hlsjs.min.jsm b/resources/p2p-media-loader-hlsjs/1.0.4/p2p-media-loader-hlsjs.min.jsm
similarity index 100%
rename from resources/p2p-media-loader-hlsjs/1.0.3/p2p-media-loader-hlsjs.min.jsm
rename to resources/p2p-media-loader-hlsjs/1.0.4/p2p-media-loader-hlsjs.min.jsm