@forward-widget/danmu-universe 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/danmu-universe.js +258 -307
- package/package.json +2 -2
package/dist/danmu-universe.js
CHANGED
|
@@ -549,7 +549,7 @@ var __webpack_modules__ = {
|
|
|
549
549
|
for(var t = e.length, n = [], r = 0; r < t; r += 2)n[r >>> 3] |= parseInt(e.substr(r, 2), 16) << 24 - r % 8 * 4;
|
|
550
550
|
return new l.init(n, t / 2);
|
|
551
551
|
}
|
|
552
|
-
},
|
|
552
|
+
}, p = c.Latin1 = {
|
|
553
553
|
stringify: function(e) {
|
|
554
554
|
for(var t = e.words, n = e.sigBytes, r = [], i = 0; i < n; i++){
|
|
555
555
|
var o = t[i >>> 2] >>> 24 - i % 4 * 8 & 0xff;
|
|
@@ -561,23 +561,23 @@ var __webpack_modules__ = {
|
|
|
561
561
|
for(var t = e.length, n = [], r = 0; r < t; r++)n[r >>> 2] |= (0xff & e.charCodeAt(r)) << 24 - r % 4 * 8;
|
|
562
562
|
return new l.init(n, t);
|
|
563
563
|
}
|
|
564
|
-
},
|
|
564
|
+
}, f = c.Utf8 = {
|
|
565
565
|
stringify: function(e) {
|
|
566
566
|
try {
|
|
567
|
-
return decodeURIComponent(escape(
|
|
567
|
+
return decodeURIComponent(escape(p.stringify(e)));
|
|
568
568
|
} catch (e) {
|
|
569
569
|
throw Error('Malformed UTF-8 data');
|
|
570
570
|
}
|
|
571
571
|
},
|
|
572
572
|
parse: function(e) {
|
|
573
|
-
return
|
|
573
|
+
return p.parse(unescape(encodeURIComponent(e)));
|
|
574
574
|
}
|
|
575
575
|
}, h = a.BufferedBlockAlgorithm = u.extend({
|
|
576
576
|
reset: function() {
|
|
577
577
|
this._data = new l.init(), this._nDataBytes = 0;
|
|
578
578
|
},
|
|
579
579
|
_append: function(e) {
|
|
580
|
-
'string' == typeof e && (e =
|
|
580
|
+
'string' == typeof e && (e = f.parse(e)), this._data.concat(e), this._nDataBytes += e.sigBytes;
|
|
581
581
|
},
|
|
582
582
|
_process: function(t) {
|
|
583
583
|
var n, r = this._data, i = r.words, o = r.sigBytes, s = this.blockSize, a = o / (4 * s), u = (a = t ? e.ceil(a) : e.max((0 | a) - this._minBufferSize, 0)) * s, c = e.min(4 * u, o);
|
|
@@ -695,8 +695,8 @@ var __webpack_modules__ = {
|
|
|
695
695
|
var r = t + n, i = e[r];
|
|
696
696
|
e[r] = (i << 8 | i >>> 24) & 0x00ff00ff | (i << 24 | i >>> 8) & 0xff00ff00;
|
|
697
697
|
}
|
|
698
|
-
var o = this._hash.words, s = e[t + 0], u = e[t + 1],
|
|
699
|
-
O = l(O, I, $, P, s, 7, a[0]), P = l(P, O, I, $, u, 12, a[1]), $ = l($, P, O, I,
|
|
698
|
+
var o = this._hash.words, s = e[t + 0], u = e[t + 1], f = e[t + 2], h = e[t + 3], m = e[t + 4], g = e[t + 5], v = e[t + 6], y = e[t + 7], b = e[t + 8], _ = e[t + 9], w = e[t + 10], k = e[t + 11], x = e[t + 12], S = e[t + 13], E = e[t + 14], z = e[t + 15], O = o[0], I = o[1], $ = o[2], P = o[3];
|
|
699
|
+
O = l(O, I, $, P, s, 7, a[0]), P = l(P, O, I, $, u, 12, a[1]), $ = l($, P, O, I, f, 17, a[2]), I = l(I, $, P, O, h, 22, a[3]), O = l(O, I, $, P, m, 7, a[4]), P = l(P, O, I, $, g, 12, a[5]), $ = l($, P, O, I, v, 17, a[6]), I = l(I, $, P, O, y, 22, a[7]), O = l(O, I, $, P, b, 7, a[8]), P = l(P, O, I, $, _, 12, a[9]), $ = l($, P, O, I, w, 17, a[10]), I = l(I, $, P, O, k, 22, a[11]), O = l(O, I, $, P, x, 7, a[12]), P = l(P, O, I, $, S, 12, a[13]), $ = l($, P, O, I, E, 17, a[14]), I = l(I, $, P, O, z, 22, a[15]), O = c(O, I, $, P, u, 5, a[16]), P = c(P, O, I, $, v, 9, a[17]), $ = c($, P, O, I, k, 14, a[18]), I = c(I, $, P, O, s, 20, a[19]), O = c(O, I, $, P, g, 5, a[20]), P = c(P, O, I, $, w, 9, a[21]), $ = c($, P, O, I, z, 14, a[22]), I = c(I, $, P, O, m, 20, a[23]), O = c(O, I, $, P, _, 5, a[24]), P = c(P, O, I, $, E, 9, a[25]), $ = c($, P, O, I, h, 14, a[26]), I = c(I, $, P, O, b, 20, a[27]), O = c(O, I, $, P, S, 5, a[28]), P = c(P, O, I, $, f, 9, a[29]), $ = c($, P, O, I, y, 14, a[30]), I = c(I, $, P, O, x, 20, a[31]), O = d(O, I, $, P, g, 4, a[32]), P = d(P, O, I, $, b, 11, a[33]), $ = d($, P, O, I, k, 16, a[34]), I = d(I, $, P, O, E, 23, a[35]), O = d(O, I, $, P, u, 4, a[36]), P = d(P, O, I, $, m, 11, a[37]), $ = d($, P, O, I, y, 16, a[38]), I = d(I, $, P, O, w, 23, a[39]), O = d(O, I, $, P, S, 4, a[40]), P = d(P, O, I, $, s, 11, a[41]), $ = d($, P, O, I, h, 16, a[42]), I = d(I, $, P, O, v, 23, a[43]), O = d(O, I, $, P, _, 4, a[44]), P = d(P, O, I, $, x, 11, a[45]), $ = d($, P, O, I, z, 16, a[46]), I = d(I, $, P, O, f, 23, a[47]), O = p(O, I, $, P, s, 6, a[48]), P = p(P, O, I, $, y, 10, a[49]), $ = p($, P, O, I, E, 15, a[50]), I = p(I, $, P, O, g, 21, a[51]), O = p(O, I, $, P, x, 6, a[52]), P = p(P, O, I, $, h, 10, a[53]), $ = p($, P, O, I, w, 15, a[54]), I = p(I, $, P, O, u, 21, a[55]), O = p(O, I, $, P, b, 6, a[56]), P = p(P, O, I, $, z, 10, a[57]), $ = p($, P, O, I, v, 15, a[58]), I = p(I, $, P, O, S, 21, a[59]), O = p(O, I, $, P, m, 6, a[60]), P = p(P, O, I, $, k, 10, a[61]), $ = p($, P, O, I, f, 15, a[62]), I = p(I, $, P, O, _, 21, a[63]), o[0] = o[0] + O | 0, o[1] = o[1] + I | 0, o[2] = o[2] + $ | 0, o[3] = o[3] + P | 0;
|
|
700
700
|
},
|
|
701
701
|
_doFinalize: function() {
|
|
702
702
|
var e = this._data, n = e.words, r = 8 * this._nDataBytes, i = 8 * e.sigBytes;
|
|
@@ -726,7 +726,7 @@ var __webpack_modules__ = {
|
|
|
726
726
|
var a = e + (t ^ n ^ r) + i + s;
|
|
727
727
|
return (a << o | a >>> 32 - o) + t;
|
|
728
728
|
}
|
|
729
|
-
function
|
|
729
|
+
function p(e, t, n, r, i, o, s) {
|
|
730
730
|
var a = e + (n ^ (t | ~r)) + i + s;
|
|
731
731
|
return (a << o | a >>> 32 - o) + t;
|
|
732
732
|
}
|
|
@@ -787,12 +787,12 @@ var __webpack_modules__ = {
|
|
|
787
787
|
}
|
|
788
788
|
throw Error("invalid varint encoding");
|
|
789
789
|
}
|
|
790
|
-
function
|
|
790
|
+
function p(e, t) {
|
|
791
791
|
return (e[t - 4] | e[t - 3] << 8 | e[t - 2] << 16 | e[t - 1] << 24) >>> 0;
|
|
792
792
|
}
|
|
793
|
-
function
|
|
793
|
+
function f() {
|
|
794
794
|
if (this.pos + 8 > this.len) throw a(this, 8);
|
|
795
|
-
return new o(
|
|
795
|
+
return new o(p(this.buf, this.pos += 4), p(this.buf, this.pos += 4));
|
|
796
796
|
}
|
|
797
797
|
u.create = c(), u.prototype._slice = i.Array.prototype.subarray || i.Array.prototype.slice, u.prototype.uint32 = function() {
|
|
798
798
|
var e = 4294967295;
|
|
@@ -810,10 +810,10 @@ var __webpack_modules__ = {
|
|
|
810
810
|
return 0 !== this.uint32();
|
|
811
811
|
}, u.prototype.fixed32 = function() {
|
|
812
812
|
if (this.pos + 4 > this.len) throw a(this, 4);
|
|
813
|
-
return
|
|
813
|
+
return p(this.buf, this.pos += 4);
|
|
814
814
|
}, u.prototype.sfixed32 = function() {
|
|
815
815
|
if (this.pos + 4 > this.len) throw a(this, 4);
|
|
816
|
-
return 0 |
|
|
816
|
+
return 0 | p(this.buf, this.pos += 4);
|
|
817
817
|
}, u.prototype.float = function() {
|
|
818
818
|
if (this.pos + 4 > this.len) throw a(this, 4);
|
|
819
819
|
var e = i.float.readFloatLE(this.buf, this.pos);
|
|
@@ -876,10 +876,10 @@ var __webpack_modules__ = {
|
|
|
876
876
|
return d.call(this).zzDecode()[t](!1);
|
|
877
877
|
},
|
|
878
878
|
fixed64: function() {
|
|
879
|
-
return
|
|
879
|
+
return f.call(this)[t](!0);
|
|
880
880
|
},
|
|
881
881
|
sfixed64: function() {
|
|
882
|
-
return
|
|
882
|
+
return f.call(this)[t](!1);
|
|
883
883
|
}
|
|
884
884
|
});
|
|
885
885
|
};
|
|
@@ -1102,7 +1102,7 @@ var __webpack_modules__ = {
|
|
|
1102
1102
|
function d() {
|
|
1103
1103
|
this.len = 0, this.head = new u(l, 0, 0), this.tail = this.head, this.states = null;
|
|
1104
1104
|
}
|
|
1105
|
-
var
|
|
1105
|
+
var p = function() {
|
|
1106
1106
|
return i.Buffer ? function() {
|
|
1107
1107
|
return (d.create = function() {
|
|
1108
1108
|
return new r();
|
|
@@ -1111,7 +1111,7 @@ var __webpack_modules__ = {
|
|
|
1111
1111
|
return new d();
|
|
1112
1112
|
};
|
|
1113
1113
|
};
|
|
1114
|
-
function
|
|
1114
|
+
function f(e, t, n) {
|
|
1115
1115
|
t[n] = 255 & e;
|
|
1116
1116
|
}
|
|
1117
1117
|
function h(e, t, n) {
|
|
@@ -1129,7 +1129,7 @@ var __webpack_modules__ = {
|
|
|
1129
1129
|
function v(e, t, n) {
|
|
1130
1130
|
t[n] = 255 & e, t[n + 1] = e >>> 8 & 255, t[n + 2] = e >>> 16 & 255, t[n + 3] = e >>> 24;
|
|
1131
1131
|
}
|
|
1132
|
-
d.create =
|
|
1132
|
+
d.create = p(), d.alloc = function(e) {
|
|
1133
1133
|
return new i.Array(e);
|
|
1134
1134
|
}, i.Array !== Array && (d.alloc = i.pool(d.alloc, i.Array.prototype.subarray)), d.prototype._push = function(e, t, n) {
|
|
1135
1135
|
return this.tail = this.tail.next = new u(e, t, n), this.len += t, this;
|
|
@@ -1146,7 +1146,7 @@ var __webpack_modules__ = {
|
|
|
1146
1146
|
var t = o.from(e).zzEncode();
|
|
1147
1147
|
return this._push(g, t.length(), t);
|
|
1148
1148
|
}, d.prototype.bool = function(e) {
|
|
1149
|
-
return this._push(
|
|
1149
|
+
return this._push(f, 1, +!!e);
|
|
1150
1150
|
}, d.prototype.fixed32 = function(e) {
|
|
1151
1151
|
return this._push(v, 4, e >>> 0);
|
|
1152
1152
|
}, d.prototype.sfixed32 = d.prototype.fixed32, d.prototype.fixed64 = function(e) {
|
|
@@ -1164,7 +1164,7 @@ var __webpack_modules__ = {
|
|
|
1164
1164
|
};
|
|
1165
1165
|
d.prototype.bytes = function(e) {
|
|
1166
1166
|
var t = e.length >>> 0;
|
|
1167
|
-
if (!t) return this._push(
|
|
1167
|
+
if (!t) return this._push(f, 1, 0);
|
|
1168
1168
|
if (i.isString(e)) {
|
|
1169
1169
|
var n = d.alloc(t = s.length(e));
|
|
1170
1170
|
s.decode(e, n, 0), e = n;
|
|
@@ -1172,7 +1172,7 @@ var __webpack_modules__ = {
|
|
|
1172
1172
|
return this.uint32(t)._push(y, t, e);
|
|
1173
1173
|
}, d.prototype.string = function(e) {
|
|
1174
1174
|
var t = a.length(e);
|
|
1175
|
-
return t ? this.uint32(t)._push(a.write, t, e) : this._push(
|
|
1175
|
+
return t ? this.uint32(t)._push(a.write, t, e) : this._push(f, 1, 0);
|
|
1176
1176
|
}, d.prototype.fork = function() {
|
|
1177
1177
|
return this.states = new c(this), this.head = this.tail = new u(l, 0, 0), this.len = 0, this;
|
|
1178
1178
|
}, d.prototype.reset = function() {
|
|
@@ -1184,7 +1184,7 @@ var __webpack_modules__ = {
|
|
|
1184
1184
|
for(var e = this.head.next, t = this.constructor.alloc(this.len), n = 0; e;)e.fn(e.val, t, n), n += e.len, e = e.next;
|
|
1185
1185
|
return t;
|
|
1186
1186
|
}, d._configure = function(e) {
|
|
1187
|
-
r = e, d.create =
|
|
1187
|
+
r = e, d.create = p(), r._configure();
|
|
1188
1188
|
};
|
|
1189
1189
|
},
|
|
1190
1190
|
491: function(e, t, n) {
|
|
@@ -1271,7 +1271,7 @@ var __webpack_modules__ = {
|
|
|
1271
1271
|
function d(e) {
|
|
1272
1272
|
return (e || '').toString().replace(o, '');
|
|
1273
1273
|
}
|
|
1274
|
-
var
|
|
1274
|
+
var p = [
|
|
1275
1275
|
[
|
|
1276
1276
|
'#',
|
|
1277
1277
|
'hash'
|
|
@@ -1312,16 +1312,16 @@ var __webpack_modules__ = {
|
|
|
1312
1312
|
1,
|
|
1313
1313
|
1
|
|
1314
1314
|
]
|
|
1315
|
-
],
|
|
1315
|
+
], f = {
|
|
1316
1316
|
hash: 1,
|
|
1317
1317
|
query: 1
|
|
1318
1318
|
};
|
|
1319
1319
|
function h(e) {
|
|
1320
1320
|
var t, r, i = (t = 'undefined' != typeof window ? window : void 0 !== n.g ? n.g : 'undefined' != typeof self ? self : {}).location || {}, o = {}, s = typeof (e = e || i);
|
|
1321
1321
|
if ('blob:' === e.protocol) o = new y(unescape(e.pathname), {});
|
|
1322
|
-
else if ('string' === s) for(r in o = new y(e, {}),
|
|
1322
|
+
else if ('string' === s) for(r in o = new y(e, {}), f)delete o[r];
|
|
1323
1323
|
else if ('object' === s) {
|
|
1324
|
-
for(r in e)r in
|
|
1324
|
+
for(r in e)r in f || (o[r] = e[r]);
|
|
1325
1325
|
void 0 === o.slashes && (o.slashes = a.test(e.href));
|
|
1326
1326
|
}
|
|
1327
1327
|
return o;
|
|
@@ -1346,7 +1346,7 @@ var __webpack_modules__ = {
|
|
|
1346
1346
|
}
|
|
1347
1347
|
function y(e, t, n) {
|
|
1348
1348
|
if (e = (e = d(e)).replace(s, ''), !(this instanceof y)) return new y(e, t, n);
|
|
1349
|
-
var o, a, u, l,
|
|
1349
|
+
var o, a, u, l, f, b, _ = p.slice(), w = typeof t, k = this, x = 0;
|
|
1350
1350
|
for('object' !== w && 'string' !== w && (n = t, t = null), n && 'function' != typeof n && (n = i.parse), o = !(a = g(e || '', t = h(t))).protocol && !a.slashes, k.slashes = a.slashes || o && t.slashes, k.protocol = a.protocol || t.protocol || '', e = a.rest, ('file:' === a.protocol && (2 !== a.slashesCount || c.test(e)) || !a.slashes && (a.protocol || a.slashesCount < 2 || !m(k.protocol))) && (_[3] = [
|
|
1351
1351
|
/(.*)/,
|
|
1352
1352
|
'pathname'
|
|
@@ -1355,9 +1355,9 @@ var __webpack_modules__ = {
|
|
|
1355
1355
|
e = l(e, k);
|
|
1356
1356
|
continue;
|
|
1357
1357
|
}
|
|
1358
|
-
u = l[0], b = l[1], u != u ? k[b] = e : 'string' == typeof u ? ~(
|
|
1358
|
+
u = l[0], b = l[1], u != u ? k[b] = e : 'string' == typeof u ? ~(f = '@' === u ? e.lastIndexOf(u) : e.indexOf(u)) && ('number' == typeof l[2] ? (k[b] = e.slice(0, f), e = e.slice(f + l[2])) : (k[b] = e.slice(f), e = e.slice(0, f))) : (f = u.exec(e)) && (k[b] = f[1], e = e.slice(0, f.index)), k[b] = k[b] || o && l[3] && t[b] || '', l[4] && (k[b] = k[b].toLowerCase());
|
|
1359
1359
|
}
|
|
1360
|
-
n && (k.query = n(k.query)), o && t.slashes && '/' !== k.pathname.charAt(0) && ('' !== k.pathname || '' !== t.pathname) && (k.pathname = v(k.pathname, t.pathname)), '/' !== k.pathname.charAt(0) && m(k.protocol) && (k.pathname = '/' + k.pathname), r(k.port, k.protocol) || (k.host = k.hostname, k.port = ''), k.username = k.password = '', k.auth && (~(
|
|
1360
|
+
n && (k.query = n(k.query)), o && t.slashes && '/' !== k.pathname.charAt(0) && ('' !== k.pathname || '' !== t.pathname) && (k.pathname = v(k.pathname, t.pathname)), '/' !== k.pathname.charAt(0) && m(k.protocol) && (k.pathname = '/' + k.pathname), r(k.port, k.protocol) || (k.host = k.hostname, k.port = ''), k.username = k.password = '', k.auth && (~(f = k.auth.indexOf(':')) ? (k.username = k.auth.slice(0, f), k.username = encodeURIComponent(decodeURIComponent(k.username)), k.password = k.auth.slice(f + 1), k.password = encodeURIComponent(decodeURIComponent(k.password))) : k.username = encodeURIComponent(decodeURIComponent(k.auth)), k.auth = k.password ? k.username + ':' + k.password : k.username), k.origin = 'file:' !== k.protocol && m(k.protocol) && k.host ? k.protocol + '//' + k.host : 'null', k.href = k.toString();
|
|
1361
1361
|
}
|
|
1362
1362
|
y.prototype = {
|
|
1363
1363
|
set: function(e, t, n) {
|
|
@@ -1393,8 +1393,8 @@ var __webpack_modules__ = {
|
|
|
1393
1393
|
var a = t.indexOf(':');
|
|
1394
1394
|
~a ? (o.username = t.slice(0, a), o.username = encodeURIComponent(decodeURIComponent(o.username)), o.password = t.slice(a + 1), o.password = encodeURIComponent(decodeURIComponent(o.password))) : o.username = encodeURIComponent(decodeURIComponent(t));
|
|
1395
1395
|
}
|
|
1396
|
-
for(var l = 0; l <
|
|
1397
|
-
var c =
|
|
1396
|
+
for(var l = 0; l < p.length; l++){
|
|
1397
|
+
var c = p[l];
|
|
1398
1398
|
c[4] && (o[c[1]] = o[c[1]].toLowerCase());
|
|
1399
1399
|
}
|
|
1400
1400
|
return o.auth = o.password ? o.username + ':' + o.password : o.username, o.origin = 'file:' !== o.protocol && m(o.protocol) && o.host ? o.protocol + '//' + o.host : 'null', o.href = o.toString(), o;
|
|
@@ -1448,13 +1448,12 @@ function __webpack_require__(e) {
|
|
|
1448
1448
|
})(), (()=>{
|
|
1449
1449
|
__webpack_require__.nmd = (e)=>(e.paths = [], e.children || (e.children = []), e);
|
|
1450
1450
|
})();
|
|
1451
|
-
const
|
|
1451
|
+
const PROVIDER_NAMES = {
|
|
1452
1452
|
tencent: "\u817E\u8BAF\u89C6\u9891",
|
|
1453
1453
|
iqiyi: "\u7231\u5947\u827A",
|
|
1454
1454
|
youku: "\u4F18\u9177\u89C6\u9891",
|
|
1455
1455
|
bilibili: "\u54D4\u54E9\u54D4\u54E9"
|
|
1456
1456
|
};
|
|
1457
|
-
var url_parse = __webpack_require__(337), url_parse_default = __webpack_require__.n(url_parse);
|
|
1458
1457
|
function $constructor(e, t, n) {
|
|
1459
1458
|
function r(n, r) {
|
|
1460
1459
|
var i;
|
|
@@ -1493,20 +1492,15 @@ class $ZodAsyncError extends Error {
|
|
|
1493
1492
|
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
1494
1493
|
}
|
|
1495
1494
|
}
|
|
1496
|
-
class $ZodEncodeError extends Error {
|
|
1497
|
-
constructor(e){
|
|
1498
|
-
super(`Encountered unidirectional transform during encode: ${e}`), this.name = "ZodEncodeError";
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
1495
|
const globalConfig = {};
|
|
1502
1496
|
function core_config(e) {
|
|
1503
1497
|
return e && Object.assign(globalConfig, e), globalConfig;
|
|
1504
1498
|
}
|
|
1505
|
-
const cuid = /^[cC][^\s-]{8,}$/, cuid2 = /^[0-9a-z]+$/, ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, xid = /^[0-9a-vA-V]{20}$/, ksuid = /^[A-Za-z0-9]{27}$/, nanoid = /^[a-zA-Z0-9_-]{21}$/, regexes_duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, uuid = (e)=>e ? RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000
|
|
1499
|
+
const cuid = /^[cC][^\s-]{8,}$/, cuid2 = /^[0-9a-z]+$/, ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, xid = /^[0-9a-vA-V]{20}$/, ksuid = /^[A-Za-z0-9]{27}$/, nanoid = /^[a-zA-Z0-9_-]{21}$/, regexes_duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, uuid = (e)=>e ? RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/, email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, _emoji = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
1506
1500
|
function emoji() {
|
|
1507
1501
|
return RegExp(_emoji, "u");
|
|
1508
1502
|
}
|
|
1509
|
-
const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/, cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/, cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,
|
|
1503
|
+
const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/, cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/, cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, base64url = /^[A-Za-z0-9_-]*$/, hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/, e164 = /^\+(?:[0-9]){6,14}[0-9]$/, dateSource = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))", regexes_date = RegExp(`^${dateSource}$`);
|
|
1510
1504
|
function timeSource(e) {
|
|
1511
1505
|
let t = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
1512
1506
|
return "number" == typeof e.precision ? -1 === e.precision ? `${t}` : 0 === e.precision ? `${t}:[0-5]\\d` : `${t}:[0-5]\\d\\.\\d{${e.precision}}` : `${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
@@ -1707,9 +1701,7 @@ function omit(e, t) {
|
|
|
1707
1701
|
}
|
|
1708
1702
|
function extend(e, t) {
|
|
1709
1703
|
if (!isPlainObject(t)) throw Error("Invalid input to extend: expected a plain object");
|
|
1710
|
-
let n = e._zod.def
|
|
1711
|
-
if (n && n.length > 0) throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
|
|
1712
|
-
let r = mergeDefs(e._zod.def, {
|
|
1704
|
+
let n = mergeDefs(e._zod.def, {
|
|
1713
1705
|
get shape () {
|
|
1714
1706
|
let n = {
|
|
1715
1707
|
...e._zod.def.shape,
|
|
@@ -1719,21 +1711,6 @@ function extend(e, t) {
|
|
|
1719
1711
|
},
|
|
1720
1712
|
checks: []
|
|
1721
1713
|
});
|
|
1722
|
-
return clone(e, r);
|
|
1723
|
-
}
|
|
1724
|
-
function safeExtend(e, t) {
|
|
1725
|
-
if (!isPlainObject(t)) throw Error("Invalid input to safeExtend: expected a plain object");
|
|
1726
|
-
let n = {
|
|
1727
|
-
...e._zod.def,
|
|
1728
|
-
get shape () {
|
|
1729
|
-
let n = {
|
|
1730
|
-
...e._zod.def.shape,
|
|
1731
|
-
...t
|
|
1732
|
-
};
|
|
1733
|
-
return assignProp(this, "shape", n), n;
|
|
1734
|
-
},
|
|
1735
|
-
checks: e._zod.def.checks
|
|
1736
|
-
};
|
|
1737
1714
|
return clone(e, n);
|
|
1738
1715
|
}
|
|
1739
1716
|
function merge(e, t) {
|
|
@@ -1799,7 +1776,6 @@ function required(e, t, n) {
|
|
|
1799
1776
|
return clone(t, r);
|
|
1800
1777
|
}
|
|
1801
1778
|
function aborted(e, t = 0) {
|
|
1802
|
-
if (!0 === e.aborted) return !0;
|
|
1803
1779
|
for(let n = t; n < e.issues.length; n++)if (e.issues[n]?.continue !== !0) return !0;
|
|
1804
1780
|
return !1;
|
|
1805
1781
|
}
|
|
@@ -2256,38 +2232,10 @@ const _parse = (e)=>(t, n, r, i)=>{
|
|
|
2256
2232
|
success: !0,
|
|
2257
2233
|
data: o.value
|
|
2258
2234
|
};
|
|
2259
|
-
}, safeParseAsync = _safeParseAsync($ZodRealError),
|
|
2260
|
-
let i = r ? Object.assign(r, {
|
|
2261
|
-
direction: "backward"
|
|
2262
|
-
}) : {
|
|
2263
|
-
direction: "backward"
|
|
2264
|
-
};
|
|
2265
|
-
return _parse(e)(t, n, i);
|
|
2266
|
-
}, _decode = (e)=>(t, n, r)=>_parse(e)(t, n, r), _encodeAsync = (e)=>async (t, n, r)=>{
|
|
2267
|
-
let i = r ? Object.assign(r, {
|
|
2268
|
-
direction: "backward"
|
|
2269
|
-
}) : {
|
|
2270
|
-
direction: "backward"
|
|
2271
|
-
};
|
|
2272
|
-
return _parseAsync(e)(t, n, i);
|
|
2273
|
-
}, _decodeAsync = (e)=>async (t, n, r)=>_parseAsync(e)(t, n, r), _safeEncode = (e)=>(t, n, r)=>{
|
|
2274
|
-
let i = r ? Object.assign(r, {
|
|
2275
|
-
direction: "backward"
|
|
2276
|
-
}) : {
|
|
2277
|
-
direction: "backward"
|
|
2278
|
-
};
|
|
2279
|
-
return _safeParse(e)(t, n, i);
|
|
2280
|
-
}, _safeDecode = (e)=>(t, n, r)=>_safeParse(e)(t, n, r), _safeEncodeAsync = (e)=>async (t, n, r)=>{
|
|
2281
|
-
let i = r ? Object.assign(r, {
|
|
2282
|
-
direction: "backward"
|
|
2283
|
-
}) : {
|
|
2284
|
-
direction: "backward"
|
|
2285
|
-
};
|
|
2286
|
-
return _safeParseAsync(e)(t, n, i);
|
|
2287
|
-
}, _safeDecodeAsync = (e)=>async (t, n, r)=>_safeParseAsync(e)(t, n, r), versions_version = {
|
|
2235
|
+
}, safeParseAsync = _safeParseAsync($ZodRealError), versions_version = {
|
|
2288
2236
|
major: 4,
|
|
2289
|
-
minor:
|
|
2290
|
-
patch:
|
|
2237
|
+
minor: 0,
|
|
2238
|
+
patch: 17
|
|
2291
2239
|
}, $ZodType = $constructor("$ZodType", (e, t)=>{
|
|
2292
2240
|
var n;
|
|
2293
2241
|
e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = versions_version;
|
|
@@ -2316,33 +2264,14 @@ const _parse = (e)=>(t, n, r, i)=>{
|
|
|
2316
2264
|
}
|
|
2317
2265
|
}
|
|
2318
2266
|
return r ? r.then(()=>e) : e;
|
|
2319
|
-
}, n = (n, i, o)=>{
|
|
2320
|
-
if (aborted(n)) return n.aborted = !0, n;
|
|
2321
|
-
let s = t(i, r, o);
|
|
2322
|
-
if (s instanceof Promise) {
|
|
2323
|
-
if (!1 === o.async) throw new $ZodAsyncError();
|
|
2324
|
-
return s.then((t)=>e._zod.parse(t, o));
|
|
2325
|
-
}
|
|
2326
|
-
return e._zod.parse(s, o);
|
|
2327
2267
|
};
|
|
2328
|
-
e._zod.run = (
|
|
2329
|
-
|
|
2330
|
-
if (
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
issues: []
|
|
2334
|
-
}, {
|
|
2335
|
-
...o,
|
|
2336
|
-
skipChecks: !0
|
|
2337
|
-
});
|
|
2338
|
-
return t instanceof Promise ? t.then((e)=>n(e, i, o)) : n(t, i, o);
|
|
2268
|
+
e._zod.run = (n, i)=>{
|
|
2269
|
+
let o = e._zod.parse(n, i);
|
|
2270
|
+
if (o instanceof Promise) {
|
|
2271
|
+
if (!1 === i.async) throw new $ZodAsyncError();
|
|
2272
|
+
return o.then((e)=>t(e, r, i));
|
|
2339
2273
|
}
|
|
2340
|
-
|
|
2341
|
-
if (s instanceof Promise) {
|
|
2342
|
-
if (!1 === o.async) throw new $ZodAsyncError();
|
|
2343
|
-
return s.then((e)=>t(e, r, o));
|
|
2344
|
-
}
|
|
2345
|
-
return t(s, r, o);
|
|
2274
|
+
return t(o, r, i);
|
|
2346
2275
|
};
|
|
2347
2276
|
}
|
|
2348
2277
|
e["~standard"] = {
|
|
@@ -2519,12 +2448,12 @@ const $ZodBase64 = $constructor("$ZodBase64", (e, t)=>{
|
|
|
2519
2448
|
};
|
|
2520
2449
|
});
|
|
2521
2450
|
function isValidBase64URL(e) {
|
|
2522
|
-
if (!
|
|
2451
|
+
if (!base64url.test(e)) return !1;
|
|
2523
2452
|
let t = e.replace(/[-_]/g, (e)=>"-" === e ? "+" : "/");
|
|
2524
2453
|
return isValidBase64(t.padEnd(4 * Math.ceil(t.length / 4), "="));
|
|
2525
2454
|
}
|
|
2526
2455
|
const $ZodBase64URL = $constructor("$ZodBase64URL", (e, t)=>{
|
|
2527
|
-
t.pattern ?? (t.pattern =
|
|
2456
|
+
t.pattern ?? (t.pattern = base64url), $ZodStringFormat.init(e, t), e._zod.onattach.push((e)=>{
|
|
2528
2457
|
e._zod.bag.contentEncoding = "base64url";
|
|
2529
2458
|
}), e._zod.check = (n)=>{
|
|
2530
2459
|
isValidBase64URL(n.value) || n.issues.push({
|
|
@@ -2631,43 +2560,21 @@ const $ZodArray = $constructor("$ZodArray", (e, t)=>{
|
|
|
2631
2560
|
function handlePropertyResult(e, t, n, r) {
|
|
2632
2561
|
e.issues.length && t.issues.push(...prefixIssues(n, e.issues)), void 0 === e.value ? n in r && (t.value[n] = void 0) : t.value[n] = e.value;
|
|
2633
2562
|
}
|
|
2634
|
-
function normalizeDef(e) {
|
|
2635
|
-
let t = Object.keys(e.shape);
|
|
2636
|
-
for (let n of t)if (!e.shape[n]._zod.traits.has("$ZodType")) throw Error(`Invalid element at key "${n}": expected a Zod schema`);
|
|
2637
|
-
let n = optionalKeys(e.shape);
|
|
2638
|
-
return {
|
|
2639
|
-
...e,
|
|
2640
|
-
keys: t,
|
|
2641
|
-
keySet: new Set(t),
|
|
2642
|
-
numKeys: t.length,
|
|
2643
|
-
optionalKeys: new Set(n)
|
|
2644
|
-
};
|
|
2645
|
-
}
|
|
2646
|
-
function handleCatchall(e, t, n, r, i, o) {
|
|
2647
|
-
let s = [], a = i.keySet, u = i.catchall._zod, l = u.def.type;
|
|
2648
|
-
for (let i of Object.keys(t)){
|
|
2649
|
-
if (a.has(i)) continue;
|
|
2650
|
-
if ("never" === l) {
|
|
2651
|
-
s.push(i);
|
|
2652
|
-
continue;
|
|
2653
|
-
}
|
|
2654
|
-
let o = u.run({
|
|
2655
|
-
value: t[i],
|
|
2656
|
-
issues: []
|
|
2657
|
-
}, r);
|
|
2658
|
-
o instanceof Promise ? e.push(o.then((e)=>handlePropertyResult(e, n, i, t))) : handlePropertyResult(o, n, i, t);
|
|
2659
|
-
}
|
|
2660
|
-
return (s.length && n.issues.push({
|
|
2661
|
-
code: "unrecognized_keys",
|
|
2662
|
-
keys: s,
|
|
2663
|
-
input: t,
|
|
2664
|
-
inst: o
|
|
2665
|
-
}), e.length) ? Promise.all(e).then(()=>n) : n;
|
|
2666
|
-
}
|
|
2667
2563
|
const $ZodObject = $constructor("$ZodObject", (e, t)=>{
|
|
2668
|
-
let n;
|
|
2564
|
+
let n, r;
|
|
2669
2565
|
$ZodType.init(e, t);
|
|
2670
|
-
let
|
|
2566
|
+
let i = util_cached(()=>{
|
|
2567
|
+
let e = Object.keys(t.shape);
|
|
2568
|
+
for (let n of e)if (!t.shape[n]._zod.traits.has("$ZodType")) throw Error(`Invalid element at key "${n}": expected a Zod schema`);
|
|
2569
|
+
let n = optionalKeys(t.shape);
|
|
2570
|
+
return {
|
|
2571
|
+
shape: t.shape,
|
|
2572
|
+
keys: e,
|
|
2573
|
+
keySet: new Set(e),
|
|
2574
|
+
numKeys: e.length,
|
|
2575
|
+
optionalKeys: new Set(n)
|
|
2576
|
+
};
|
|
2577
|
+
});
|
|
2671
2578
|
defineLazy(e._zod, "propValues", ()=>{
|
|
2672
2579
|
let e = t.shape, n = {};
|
|
2673
2580
|
for(let t in e){
|
|
@@ -2676,74 +2583,83 @@ const $ZodObject = $constructor("$ZodObject", (e, t)=>{
|
|
|
2676
2583
|
}
|
|
2677
2584
|
return n;
|
|
2678
2585
|
});
|
|
2679
|
-
let
|
|
2680
|
-
e._zod.parse = (t, s)=>{
|
|
2681
|
-
n ?? (n = r.value);
|
|
2682
|
-
let a = t.value;
|
|
2683
|
-
if (!i(a)) return t.issues.push({
|
|
2684
|
-
expected: "object",
|
|
2685
|
-
code: "invalid_type",
|
|
2686
|
-
input: a,
|
|
2687
|
-
inst: e
|
|
2688
|
-
}), t;
|
|
2689
|
-
t.value = {};
|
|
2690
|
-
let u = [], l = n.shape;
|
|
2691
|
-
for (let e of n.keys){
|
|
2692
|
-
let n = l[e]._zod.run({
|
|
2693
|
-
value: a[e],
|
|
2694
|
-
issues: []
|
|
2695
|
-
}, s);
|
|
2696
|
-
n instanceof Promise ? u.push(n.then((n)=>handlePropertyResult(n, t, e, a))) : handlePropertyResult(n, t, e, a);
|
|
2697
|
-
}
|
|
2698
|
-
return o ? handleCatchall(u, a, t, s, r.value, e) : u.length ? Promise.all(u).then(()=>t) : t;
|
|
2699
|
-
};
|
|
2700
|
-
}), $ZodObjectJIT = $constructor("$ZodObjectJIT", (e, t)=>{
|
|
2701
|
-
let n, r;
|
|
2702
|
-
$ZodObject.init(e, t);
|
|
2703
|
-
let i = e._zod.parse, o = util_cached(()=>normalizeDef(t)), s = (e)=>{
|
|
2586
|
+
let o = (e)=>{
|
|
2704
2587
|
let t = new Doc([
|
|
2705
2588
|
"shape",
|
|
2706
2589
|
"payload",
|
|
2707
2590
|
"ctx"
|
|
2708
|
-
]), n =
|
|
2591
|
+
]), n = i.value, r = (e)=>{
|
|
2709
2592
|
let t = esc(e);
|
|
2710
2593
|
return `shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`;
|
|
2711
2594
|
};
|
|
2712
2595
|
t.write("const input = payload.value;");
|
|
2713
|
-
let
|
|
2714
|
-
for (let e of n.keys)
|
|
2596
|
+
let o = Object.create(null), s = 0;
|
|
2597
|
+
for (let e of n.keys)o[e] = `key_${s++}`;
|
|
2715
2598
|
for (let e of (t.write("const newResult = {}"), n.keys)){
|
|
2716
|
-
let n =
|
|
2599
|
+
let n = o[e], i = esc(e);
|
|
2717
2600
|
t.write(`const ${n} = ${r(e)};`), t.write(`
|
|
2718
2601
|
if (${n}.issues.length) {
|
|
2719
2602
|
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
2720
2603
|
...iss,
|
|
2721
|
-
path: iss.path ? [${
|
|
2604
|
+
path: iss.path ? [${i}, ...iss.path] : [${i}]
|
|
2722
2605
|
})));
|
|
2723
2606
|
}
|
|
2724
2607
|
|
|
2725
2608
|
if (${n}.value === undefined) {
|
|
2726
|
-
if (${
|
|
2727
|
-
newResult[${
|
|
2609
|
+
if (${i} in input) {
|
|
2610
|
+
newResult[${i}] = undefined;
|
|
2728
2611
|
}
|
|
2729
2612
|
} else {
|
|
2730
|
-
newResult[${
|
|
2613
|
+
newResult[${i}] = ${n}.value;
|
|
2731
2614
|
}
|
|
2732
2615
|
`);
|
|
2733
2616
|
}
|
|
2734
2617
|
t.write("payload.value = newResult;"), t.write("return payload;");
|
|
2735
2618
|
let a = t.compile();
|
|
2736
2619
|
return (t, n)=>a(e, t, n);
|
|
2737
|
-
},
|
|
2738
|
-
e._zod.parse = (
|
|
2739
|
-
r ?? (r =
|
|
2740
|
-
let p =
|
|
2741
|
-
|
|
2620
|
+
}, s = util_isObject, a = !globalConfig.jitless, u = util_allowsEval, l = a && u.value, c = t.catchall;
|
|
2621
|
+
e._zod.parse = (u, d)=>{
|
|
2622
|
+
r ?? (r = i.value);
|
|
2623
|
+
let p = u.value;
|
|
2624
|
+
if (!s(p)) return u.issues.push({
|
|
2742
2625
|
expected: "object",
|
|
2743
2626
|
code: "invalid_type",
|
|
2744
2627
|
input: p,
|
|
2745
2628
|
inst: e
|
|
2746
|
-
}),
|
|
2629
|
+
}), u;
|
|
2630
|
+
let f = [];
|
|
2631
|
+
if (a && l && d?.async === !1 && !0 !== d.jitless) n || (n = o(t.shape)), u = n(u, d);
|
|
2632
|
+
else {
|
|
2633
|
+
u.value = {};
|
|
2634
|
+
let e = r.shape;
|
|
2635
|
+
for (let t of r.keys){
|
|
2636
|
+
let n = e[t]._zod.run({
|
|
2637
|
+
value: p[t],
|
|
2638
|
+
issues: []
|
|
2639
|
+
}, d);
|
|
2640
|
+
n instanceof Promise ? f.push(n.then((e)=>handlePropertyResult(e, u, t, p))) : handlePropertyResult(n, u, t, p);
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
if (!c) return f.length ? Promise.all(f).then(()=>u) : u;
|
|
2644
|
+
let h = [], m = r.keySet, g = c._zod, v = g.def.type;
|
|
2645
|
+
for (let e of Object.keys(p)){
|
|
2646
|
+
if (m.has(e)) continue;
|
|
2647
|
+
if ("never" === v) {
|
|
2648
|
+
h.push(e);
|
|
2649
|
+
continue;
|
|
2650
|
+
}
|
|
2651
|
+
let t = g.run({
|
|
2652
|
+
value: p[e],
|
|
2653
|
+
issues: []
|
|
2654
|
+
}, d);
|
|
2655
|
+
t instanceof Promise ? f.push(t.then((t)=>handlePropertyResult(t, u, e, p))) : handlePropertyResult(t, u, e, p);
|
|
2656
|
+
}
|
|
2657
|
+
return (h.length && u.issues.push({
|
|
2658
|
+
code: "unrecognized_keys",
|
|
2659
|
+
keys: h,
|
|
2660
|
+
input: p,
|
|
2661
|
+
inst: e
|
|
2662
|
+
}), f.length) ? Promise.all(f).then(()=>u) : u;
|
|
2747
2663
|
};
|
|
2748
2664
|
});
|
|
2749
2665
|
function handleUnionResults(e, t, n, r) {
|
|
@@ -2938,12 +2854,11 @@ const $ZodRecord = $constructor("$ZodRecord", (e, t)=>{
|
|
|
2938
2854
|
}), n;
|
|
2939
2855
|
};
|
|
2940
2856
|
}), $ZodTransform = $constructor("$ZodTransform", (e, t)=>{
|
|
2941
|
-
$ZodType.init(e, t), e._zod.parse = (
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
if (r
|
|
2945
|
-
|
|
2946
|
-
return n.value = i, n;
|
|
2857
|
+
$ZodType.init(e, t), e._zod.parse = (e, n)=>{
|
|
2858
|
+
let r = t.transform(e.value, e);
|
|
2859
|
+
if (n.async) return (r instanceof Promise ? r : Promise.resolve(r)).then((t)=>(e.value = t, e));
|
|
2860
|
+
if (r instanceof Promise) throw new $ZodAsyncError();
|
|
2861
|
+
return e.value = r, e;
|
|
2947
2862
|
};
|
|
2948
2863
|
});
|
|
2949
2864
|
function handleOptionalResult(e, t) {
|
|
@@ -2976,7 +2891,6 @@ const $ZodOptional = $constructor("$ZodOptional", (e, t)=>{
|
|
|
2976
2891
|
]) : void 0), e._zod.parse = (e, n)=>null === e.value ? e : t.innerType._zod.run(e, n);
|
|
2977
2892
|
}), $ZodDefault = $constructor("$ZodDefault", (e, t)=>{
|
|
2978
2893
|
$ZodType.init(e, t), e._zod.optin = "optional", defineLazy(e._zod, "values", ()=>t.innerType._zod.values), e._zod.parse = (e, n)=>{
|
|
2979
|
-
if ("backward" === n.direction) return t.innerType._zod.run(e, n);
|
|
2980
2894
|
if (void 0 === e.value) return e.value = t.defaultValue, e;
|
|
2981
2895
|
let r = t.innerType._zod.run(e, n);
|
|
2982
2896
|
return r instanceof Promise ? r.then((e)=>handleDefaultResult(e, t)) : handleDefaultResult(r, t);
|
|
@@ -2986,7 +2900,7 @@ function handleDefaultResult(e, t) {
|
|
|
2986
2900
|
return void 0 === e.value && (e.value = t.defaultValue), e;
|
|
2987
2901
|
}
|
|
2988
2902
|
const $ZodPrefault = $constructor("$ZodPrefault", (e, t)=>{
|
|
2989
|
-
$ZodType.init(e, t), e._zod.optin = "optional", defineLazy(e._zod, "values", ()=>t.innerType._zod.values), e._zod.parse = (e, n)=>(
|
|
2903
|
+
$ZodType.init(e, t), e._zod.optin = "optional", defineLazy(e._zod, "values", ()=>t.innerType._zod.values), e._zod.parse = (e, n)=>(void 0 === e.value && (e.value = t.defaultValue), t.innerType._zod.run(e, n));
|
|
2990
2904
|
}), $ZodNonOptional = $constructor("$ZodNonOptional", (e, t)=>{
|
|
2991
2905
|
$ZodType.init(e, t), defineLazy(e._zod, "values", ()=>{
|
|
2992
2906
|
let e = t.innerType._zod.values;
|
|
@@ -3008,7 +2922,6 @@ function handleNonOptionalResult(e, t) {
|
|
|
3008
2922
|
}
|
|
3009
2923
|
const $ZodCatch = $constructor("$ZodCatch", (e, t)=>{
|
|
3010
2924
|
$ZodType.init(e, t), defineLazy(e._zod, "optin", ()=>t.innerType._zod.optin), defineLazy(e._zod, "optout", ()=>t.innerType._zod.optout), defineLazy(e._zod, "values", ()=>t.innerType._zod.values), e._zod.parse = (e, n)=>{
|
|
3011
|
-
if ("backward" === n.direction) return t.innerType._zod.run(e, n);
|
|
3012
2925
|
let r = t.innerType._zod.run(e, n);
|
|
3013
2926
|
return r instanceof Promise ? r.then((r)=>(e.value = r.value, r.issues.length && (e.value = t.catchValue({
|
|
3014
2927
|
...e,
|
|
@@ -3026,23 +2939,18 @@ const $ZodCatch = $constructor("$ZodCatch", (e, t)=>{
|
|
|
3026
2939
|
};
|
|
3027
2940
|
}), $ZodPipe = $constructor("$ZodPipe", (e, t)=>{
|
|
3028
2941
|
$ZodType.init(e, t), defineLazy(e._zod, "values", ()=>t.in._zod.values), defineLazy(e._zod, "optin", ()=>t.in._zod.optin), defineLazy(e._zod, "optout", ()=>t.out._zod.optout), defineLazy(e._zod, "propValues", ()=>t.in._zod.propValues), e._zod.parse = (e, n)=>{
|
|
3029
|
-
if ("backward" === n.direction) {
|
|
3030
|
-
let r = t.out._zod.run(e, n);
|
|
3031
|
-
return r instanceof Promise ? r.then((e)=>handlePipeResult(e, t.in, n)) : handlePipeResult(r, t.in, n);
|
|
3032
|
-
}
|
|
3033
2942
|
let r = t.in._zod.run(e, n);
|
|
3034
|
-
return r instanceof Promise ? r.then((e)=>handlePipeResult(e, t
|
|
2943
|
+
return r instanceof Promise ? r.then((e)=>handlePipeResult(e, t, n)) : handlePipeResult(r, t, n);
|
|
3035
2944
|
};
|
|
3036
2945
|
});
|
|
3037
2946
|
function handlePipeResult(e, t, n) {
|
|
3038
|
-
return e.issues.length ?
|
|
2947
|
+
return e.issues.length ? e : t.out._zod.run({
|
|
3039
2948
|
value: e.value,
|
|
3040
2949
|
issues: e.issues
|
|
3041
2950
|
}, n);
|
|
3042
2951
|
}
|
|
3043
2952
|
const $ZodReadonly = $constructor("$ZodReadonly", (e, t)=>{
|
|
3044
2953
|
$ZodType.init(e, t), defineLazy(e._zod, "propValues", ()=>t.innerType._zod.propValues), defineLazy(e._zod, "values", ()=>t.innerType._zod.values), defineLazy(e._zod, "optin", ()=>t.innerType._zod.optin), defineLazy(e._zod, "optout", ()=>t.innerType._zod.optout), e._zod.parse = (e, n)=>{
|
|
3045
|
-
if ("backward" === n.direction) return t.innerType._zod.run(e, n);
|
|
3046
2954
|
let r = t.innerType._zod.run(e, n);
|
|
3047
2955
|
return r instanceof Promise ? r.then(handleReadonlyResult) : handleReadonlyResult(r);
|
|
3048
2956
|
};
|
|
@@ -3604,7 +3512,7 @@ const classic_errors_initializer = (e, t)=>{
|
|
|
3604
3512
|
$constructor("ZodError", classic_errors_initializer);
|
|
3605
3513
|
const ZodRealError = $constructor("ZodError", classic_errors_initializer, {
|
|
3606
3514
|
Parent: Error
|
|
3607
|
-
}),
|
|
3515
|
+
}), parse_parse = _parse(ZodRealError), parse_parseAsync = _parseAsync(ZodRealError), parse_safeParse = _safeParse(ZodRealError), parse_safeParseAsync = _safeParseAsync(ZodRealError), ZodType = $constructor("ZodType", (e, t)=>($ZodType.init(e, t), e.def = t, Object.defineProperty(e, "_def", {
|
|
3608
3516
|
value: t
|
|
3609
3517
|
}), e.check = (...n)=>e.clone({
|
|
3610
3518
|
...t,
|
|
@@ -3620,11 +3528,11 @@ const ZodRealError = $constructor("ZodError", classic_errors_initializer, {
|
|
|
3620
3528
|
}
|
|
3621
3529
|
} : e)
|
|
3622
3530
|
]
|
|
3623
|
-
}), e.clone = (t, n)=>clone(e, t, n), e.brand = ()=>e, e.register = (t, n)=>(t.add(e, n), e), e.parse = (t, n)=>
|
|
3531
|
+
}), e.clone = (t, n)=>clone(e, t, n), e.brand = ()=>e, e.register = (t, n)=>(t.add(e, n), e), e.parse = (t, n)=>parse_parse(e, t, n, {
|
|
3624
3532
|
callee: e.parse
|
|
3625
|
-
}), e.safeParse = (t, n)=>parse_safeParse(e, t, n), e.parseAsync = async (t, n)=>
|
|
3533
|
+
}), e.safeParse = (t, n)=>parse_safeParse(e, t, n), e.parseAsync = async (t, n)=>parse_parseAsync(e, t, n, {
|
|
3626
3534
|
callee: e.parseAsync
|
|
3627
|
-
}), e.safeParseAsync = async (t, n)=>parse_safeParseAsync(e, t, n), e.spa = e.safeParseAsync, e.
|
|
3535
|
+
}), e.safeParseAsync = async (t, n)=>parse_safeParseAsync(e, t, n), e.spa = e.safeParseAsync, e.refine = (t, n)=>e.check(refine(t, n)), e.superRefine = (t)=>e.check(superRefine(t)), e.overwrite = (t)=>e.check(_overwrite(t)), e.optional = ()=>optional(e), e.nullable = ()=>nullable(e), e.nullish = ()=>optional(nullable(e)), e.nonoptional = (t)=>nonoptional(e, t), e.array = ()=>schemas_array(e), e.or = (t)=>union([
|
|
3628
3536
|
e,
|
|
3629
3537
|
t
|
|
3630
3538
|
]), e.and = (t)=>intersection(e, t), e.transform = (t)=>pipe(e, transform(t)), e.default = (t)=>schemas_default(e, t), e.prefault = (t)=>prefault(e, t), e.catch = (t)=>schemas_catch(e, t), e.pipe = (t)=>pipe(e, t), e.readonly = ()=>readonly(e), e.describe = (t)=>{
|
|
@@ -3728,7 +3636,7 @@ function schemas_array(e, t) {
|
|
|
3728
3636
|
return _array(ZodArray, e, t);
|
|
3729
3637
|
}
|
|
3730
3638
|
const ZodObject = $constructor("ZodObject", (e, t)=>{
|
|
3731
|
-
$
|
|
3639
|
+
$ZodObject.init(e, t), ZodType.init(e, t), defineLazy(e, "shape", ()=>t.shape), e.keyof = ()=>schemas_enum(Object.keys(e._zod.def.shape)), e.catchall = (t)=>e.clone({
|
|
3732
3640
|
...e._zod.def,
|
|
3733
3641
|
catchall: t
|
|
3734
3642
|
}), e.passthrough = ()=>e.clone({
|
|
@@ -3743,7 +3651,7 @@ const ZodObject = $constructor("ZodObject", (e, t)=>{
|
|
|
3743
3651
|
}), e.strip = ()=>e.clone({
|
|
3744
3652
|
...e._zod.def,
|
|
3745
3653
|
catchall: void 0
|
|
3746
|
-
}), e.extend = (t)=>extend(e, t), e.
|
|
3654
|
+
}), e.extend = (t)=>extend(e, t), e.merge = (t)=>merge(e, t), e.pick = (t)=>pick(e, t), e.omit = (t)=>omit(e, t), e.partial = (...t)=>partial(ZodOptional, e, t[0]), e.required = (...t)=>required(ZodNonOptional, e, t[0]);
|
|
3747
3655
|
});
|
|
3748
3656
|
function schemas_object(e, t) {
|
|
3749
3657
|
return new ZodObject({
|
|
@@ -3851,7 +3759,6 @@ function literal(e, t) {
|
|
|
3851
3759
|
}
|
|
3852
3760
|
const ZodTransform = $constructor("ZodTransform", (e, t)=>{
|
|
3853
3761
|
$ZodTransform.init(e, t), ZodType.init(e, t), e._zod.parse = (n, r)=>{
|
|
3854
|
-
if ("backward" === r.direction) throw new $ZodEncodeError(e.constructor.name);
|
|
3855
3762
|
n.addIssue = (r)=>{
|
|
3856
3763
|
if ("string" == typeof r) n.issues.push(util_issue(r, n.value, t));
|
|
3857
3764
|
else {
|
|
@@ -3987,7 +3894,7 @@ function merge_merge(e, t) {
|
|
|
3987
3894
|
}
|
|
3988
3895
|
return e;
|
|
3989
3896
|
}
|
|
3990
|
-
var enc_base64 = __webpack_require__(716), enc_base64_default = __webpack_require__.n(enc_base64);
|
|
3897
|
+
var url_parse = __webpack_require__(337), url_parse_default = __webpack_require__.n(url_parse), enc_base64 = __webpack_require__(716), enc_base64_default = __webpack_require__.n(enc_base64);
|
|
3991
3898
|
function safeJsonParse(e) {
|
|
3992
3899
|
try {
|
|
3993
3900
|
if (!e) return null;
|
|
@@ -4002,7 +3909,7 @@ function safeJsonParseWithZod(e, t) {
|
|
|
4002
3909
|
let { success: r, data: i, error: o } = t.safeParse(n);
|
|
4003
3910
|
return r ? i : (console.warn(`Failed to parse JSON with Zod: ${e}`, o), null);
|
|
4004
3911
|
}
|
|
4005
|
-
function
|
|
3912
|
+
function base64ToUint8Array(e) {
|
|
4006
3913
|
let t = enc_base64_default().parse(e), n = new Uint8Array(t.sigBytes);
|
|
4007
3914
|
for(let e = 0; e < t.sigBytes; e++){
|
|
4008
3915
|
let r = e >>> 2, i = e % 4;
|
|
@@ -4086,6 +3993,14 @@ class HttpStatusError extends Error {
|
|
|
4086
3993
|
});
|
|
4087
3994
|
}
|
|
4088
3995
|
}
|
|
3996
|
+
class HttpSchemaError extends Error {
|
|
3997
|
+
constructor(e, t, n){
|
|
3998
|
+
super(`Failed to parse response with schema: ${prettifyError(n)}`), fetch_define_property(this, "context", void 0), fetch_define_property(this, "response", void 0), fetch_define_property(this, "error", void 0), this.context = e, this.response = t, this.error = n, this.name = "HttpSchemaError", console.error(`\u{1F6AB} HTTP Request Failed Failed to parse response with schema: ${prettifyError(n)}: ${e.method} ${e.url}`), console.error("Response:", {
|
|
3999
|
+
headers: t.headers,
|
|
4000
|
+
data: t.data
|
|
4001
|
+
});
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4089
4004
|
class Fetch {
|
|
4090
4005
|
setCookie(e) {
|
|
4091
4006
|
this.cookie = merge_merge(this.cookie, e);
|
|
@@ -4147,16 +4062,13 @@ class Fetch {
|
|
|
4147
4062
|
}, s), r = storage.getJson(n);
|
|
4148
4063
|
if (r) return console.debug("fetch cache hit", n), Promise.resolve(r);
|
|
4149
4064
|
}
|
|
4150
|
-
let a = o ? void 0 : n, { timeout: u, schema: l, params: c, ...d } = s,
|
|
4151
|
-
c && (
|
|
4152
|
-
|
|
4153
|
-
params: c
|
|
4154
|
-
});
|
|
4155
|
-
let p = o ? Widget.http.get(f, d) : Widget.http.post(f, a, d);
|
|
4065
|
+
let a = o ? void 0 : n, { timeout: u, schema: l, params: c, ...d } = s, p = t;
|
|
4066
|
+
c && (p = `${t}?${url_parse.qs.stringify(c)}`), console.debug("\u2B06\uFE0F fetch", p, null != a ? a : "", d);
|
|
4067
|
+
let f = o ? Widget.http.get(p, d) : Widget.http.post(p, a, d);
|
|
4156
4068
|
return u && u > 0 ? Promise.race([
|
|
4157
|
-
|
|
4069
|
+
f,
|
|
4158
4070
|
this.createTimeoutPromise(u)
|
|
4159
|
-
]) :
|
|
4071
|
+
]) : f;
|
|
4160
4072
|
}
|
|
4161
4073
|
getCacheKey(e, t) {
|
|
4162
4074
|
var n;
|
|
@@ -4167,9 +4079,17 @@ class Fetch {
|
|
|
4167
4079
|
fetch_define_property(this, "cookie", void 0), fetch_define_property(this, "headers", void 0), fetch_define_property(this, "handleResponse", void 0), this.cookie = e, this.headers = t, this.handleResponse = (e, t, n)=>{
|
|
4168
4080
|
var r;
|
|
4169
4081
|
if ((null == n || null == (r = n.successStatus) ? void 0 : r.length) && !n.successStatus.includes(e.statusCode)) throw new HttpStatusError(e.statusCode, n.successStatus, t, e);
|
|
4170
|
-
let i =
|
|
4171
|
-
|
|
4172
|
-
|
|
4082
|
+
let i = {
|
|
4083
|
+
...e
|
|
4084
|
+
};
|
|
4085
|
+
if (null == n ? void 0 : n.schema) {
|
|
4086
|
+
let r = n.schema.safeParse(e.data);
|
|
4087
|
+
if (!r.success) throw new HttpSchemaError(t, i, r.error);
|
|
4088
|
+
e.data = r.data;
|
|
4089
|
+
}
|
|
4090
|
+
let o = e.headers["set-cookie"] || e.headers["Set-Cookie"];
|
|
4091
|
+
if (o) {
|
|
4092
|
+
let e = o.split(",").reduce((e, t)=>{
|
|
4173
4093
|
if (!t) return e;
|
|
4174
4094
|
let [n] = t.split(";"), [r, ...i] = n.split("=");
|
|
4175
4095
|
return r && i.length > 0 && (e[r.trim()] = i.join("=").trim()), e;
|
|
@@ -4177,39 +4097,40 @@ class Fetch {
|
|
|
4177
4097
|
this.setCookie(e);
|
|
4178
4098
|
}
|
|
4179
4099
|
if (null == n ? void 0 : n.cache) {
|
|
4180
|
-
let
|
|
4181
|
-
storage.setJson(
|
|
4100
|
+
let e = this.getCacheKey(t, n);
|
|
4101
|
+
storage.setJson(e, i, {
|
|
4182
4102
|
ttl: n.cache.ttl
|
|
4183
4103
|
});
|
|
4184
4104
|
}
|
|
4185
|
-
if (null == n ? void 0 : n.schema) {
|
|
4186
|
-
let r = n.schema.safeParse(e.data);
|
|
4187
|
-
return r.success || (console.error(t.url, "Failed to parse response with schema:", prettifyError(r.error)), console.error("Response:", e.data)), {
|
|
4188
|
-
...e,
|
|
4189
|
-
data: r.data
|
|
4190
|
-
};
|
|
4191
|
-
}
|
|
4192
4105
|
return e;
|
|
4193
4106
|
};
|
|
4194
4107
|
}
|
|
4195
4108
|
}
|
|
4109
|
+
const fetch_fetch = new Fetch();
|
|
4196
4110
|
function coerce_number(e) {
|
|
4197
4111
|
return _coercedNumber(ZodNumber, e);
|
|
4198
4112
|
}
|
|
4199
|
-
const BASE_URL = "https://api.imdbapi.dev",
|
|
4113
|
+
const BASE_URL = "https://api.imdbapi.dev", imdb_fetch = new Fetch(), episodesRequestSchema = schemas_object({
|
|
4200
4114
|
season: coerce_number().optional().default(1),
|
|
4201
4115
|
pageSize: coerce_number().optional().default(20),
|
|
4202
4116
|
pageToken: schemas_string().optional()
|
|
4203
|
-
}),
|
|
4117
|
+
}), getImdbEpisodes = async (e, t)=>{
|
|
4204
4118
|
let { season: n, pageSize: r, pageToken: i } = episodesRequestSchema.parse(null != t ? t : {});
|
|
4205
|
-
return (await
|
|
4119
|
+
return (await imdb_fetch.get(`${BASE_URL}/titles/${e}/episodes`, {
|
|
4206
4120
|
params: {
|
|
4207
4121
|
season: n,
|
|
4208
4122
|
pageSize: r,
|
|
4209
4123
|
pageToken: i
|
|
4210
4124
|
},
|
|
4211
4125
|
cache: {
|
|
4212
|
-
cacheKey:
|
|
4126
|
+
cacheKey: [
|
|
4127
|
+
"imdb",
|
|
4128
|
+
"episodes",
|
|
4129
|
+
e,
|
|
4130
|
+
n,
|
|
4131
|
+
r,
|
|
4132
|
+
i
|
|
4133
|
+
].filter(Boolean).join(":")
|
|
4213
4134
|
},
|
|
4214
4135
|
successStatus: [
|
|
4215
4136
|
200
|
|
@@ -4224,12 +4145,20 @@ const BASE_URL = "https://api.imdbapi.dev", fetch = new Fetch(), episodesRequest
|
|
|
4224
4145
|
nextPageToken: schemas_string().optional()
|
|
4225
4146
|
})
|
|
4226
4147
|
})).data;
|
|
4227
|
-
},
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4148
|
+
}, getImdbSeasons = async (e)=>(await imdb_fetch.get(`${BASE_URL}/titles/${e}/seasons`, {
|
|
4149
|
+
cache: {
|
|
4150
|
+
cacheKey: [
|
|
4151
|
+
"imdb:seasons",
|
|
4152
|
+
e
|
|
4153
|
+
].join(":")
|
|
4154
|
+
},
|
|
4155
|
+
schema: schemas_object({
|
|
4156
|
+
seasons: schemas_array(schemas_object({
|
|
4157
|
+
season: schemas_string(),
|
|
4158
|
+
episodeCount: schemas_number().optional()
|
|
4159
|
+
}))
|
|
4160
|
+
})
|
|
4161
|
+
})).data, DOUBAN_API_KEY = "0ac44ae016490db2204ce0a042db2916", doubanImdbResponseSchema = schemas_object({
|
|
4233
4162
|
id: schemas_string(),
|
|
4234
4163
|
rating: schemas_object({
|
|
4235
4164
|
min: schemas_number(),
|
|
@@ -4246,9 +4175,19 @@ const BASE_URL = "https://api.imdbapi.dev", fetch = new Fetch(), episodesRequest
|
|
|
4246
4175
|
count: schemas_number().optional(),
|
|
4247
4176
|
name: schemas_string().optional()
|
|
4248
4177
|
})).optional()
|
|
4249
|
-
}), getDoubanInfoByImdbId = async (e)=>{
|
|
4250
|
-
var
|
|
4251
|
-
let
|
|
4178
|
+
}), getDoubanInfoByImdbId = async (e, t)=>{
|
|
4179
|
+
var n, r, i, o, s, a;
|
|
4180
|
+
let u = e;
|
|
4181
|
+
if (t && "1" !== t.toString()) {
|
|
4182
|
+
let n = await getImdbSeasons(e);
|
|
4183
|
+
if (!n || parseInt(t.toString()) > n.seasons.length) return null;
|
|
4184
|
+
let r = await getImdbEpisodes(e, {
|
|
4185
|
+
season: t
|
|
4186
|
+
});
|
|
4187
|
+
u = null != (s = null == r || null == (o = r.episodes.find((e)=>1 === e.episodeNumber)) ? void 0 : o.id) ? s : "";
|
|
4188
|
+
}
|
|
4189
|
+
u || (u = e), console.log("Get douban info by imdb id", u);
|
|
4190
|
+
let l = await fetch_fetch.post(`https://api.douban.com/v2/movie/imdb/${u}`, {
|
|
4252
4191
|
apikey: DOUBAN_API_KEY
|
|
4253
4192
|
}, {
|
|
4254
4193
|
headers: {
|
|
@@ -4256,30 +4195,25 @@ const BASE_URL = "https://api.imdbapi.dev", fetch = new Fetch(), episodesRequest
|
|
|
4256
4195
|
},
|
|
4257
4196
|
schema: doubanImdbResponseSchema,
|
|
4258
4197
|
cache: {
|
|
4259
|
-
cacheKey: `douban:imdb:${
|
|
4198
|
+
cacheKey: `douban:imdb:${u}`,
|
|
4260
4199
|
ttl: TTL_7_DAYS
|
|
4261
4200
|
}
|
|
4262
4201
|
});
|
|
4263
|
-
if (200 !==
|
|
4264
|
-
let
|
|
4265
|
-
if (!
|
|
4266
|
-
return /\d+/.test(
|
|
4267
|
-
doubanId:
|
|
4268
|
-
originResponse:
|
|
4202
|
+
if (200 !== l.statusCode) throw Error(`Failed to get Douban info: ${l.statusCode}, ${JSON.stringify(l.data)}`);
|
|
4203
|
+
let c = null == (i = l.data) || null == (r = i.id) || null == (n = r.split("/")) ? void 0 : n.pop();
|
|
4204
|
+
if (!c) throw Error(`Failed to extract Douban ID from response: ${null == (a = l.data) ? void 0 : a.id}`);
|
|
4205
|
+
return /\d+/.test(c) ? {
|
|
4206
|
+
doubanId: c,
|
|
4207
|
+
originResponse: l.data
|
|
4269
4208
|
} : null;
|
|
4209
|
+
}, getExternalIdsByTmdbId = async (e, t)=>{
|
|
4210
|
+
let n = null, r = `tmdb:${e}:${t}:external_ids`, i = storage.getJson(r);
|
|
4211
|
+
return i ? n = i : (n = await Widget.tmdb.get(`/${e}/${t}/external_ids`), storage.setJson(r, n, {
|
|
4212
|
+
ttl: TTL_7_DAYS
|
|
4213
|
+
})), n;
|
|
4270
4214
|
}, getDoubanInfoByTmdbId = async (e, t, n)=>{
|
|
4271
4215
|
let r = await getExternalIdsByTmdbId(e, t);
|
|
4272
|
-
console.log("Get external ids by tmdb id", r);
|
|
4273
|
-
let i = r.imdb_id;
|
|
4274
|
-
if (!i) return null;
|
|
4275
|
-
if (n && 1 !== n) {
|
|
4276
|
-
var o, s;
|
|
4277
|
-
let e = await getEpisodesByImdbId(i, {
|
|
4278
|
-
season: n
|
|
4279
|
-
});
|
|
4280
|
-
i = null != (s = null == e || null == (o = e.episodes.find((e)=>1 === e.episodeNumber)) ? void 0 : o.id) ? s : "";
|
|
4281
|
-
}
|
|
4282
|
-
return i ? getDoubanInfoByImdbId(i) : null;
|
|
4216
|
+
return (console.log("Get external ids by tmdb id", r), r.imdb_id) ? getDoubanInfoByImdbId(r.imdb_id, n) : null;
|
|
4283
4217
|
}, doubanInfoResponseSchema = schemas_object({
|
|
4284
4218
|
is_tv: schemas_boolean().optional(),
|
|
4285
4219
|
vendors: schemas_array(schemas_object({
|
|
@@ -4289,7 +4223,7 @@ const BASE_URL = "https://api.imdbapi.dev", fetch = new Fetch(), episodesRequest
|
|
|
4289
4223
|
}))
|
|
4290
4224
|
}), getVideoPlatformInfoByDoubanId = async (e)=>{
|
|
4291
4225
|
var t, n, r;
|
|
4292
|
-
let i = await
|
|
4226
|
+
let i = await fetch_fetch.get(`https://m.douban.com/rexxar/api/v2/movie/${e}?for_mobile=1`, {
|
|
4293
4227
|
headers: {
|
|
4294
4228
|
Referer: `https://m.douban.com/movie/subject/${e}/?dt_dapp=1`,
|
|
4295
4229
|
"Content-Type": "application/json"
|
|
@@ -4346,6 +4280,23 @@ const BASE_URL = "https://api.imdbapi.dev", fetch = new Fetch(), episodesRequest
|
|
|
4346
4280
|
}
|
|
4347
4281
|
return o;
|
|
4348
4282
|
};
|
|
4283
|
+
function compact(e) {
|
|
4284
|
+
let t = [];
|
|
4285
|
+
for(let n = 0; n < e.length; n++){
|
|
4286
|
+
let r = e[n];
|
|
4287
|
+
r && t.push(r);
|
|
4288
|
+
}
|
|
4289
|
+
return t;
|
|
4290
|
+
}
|
|
4291
|
+
const doubanSubjectItemSchema = schemas_object({
|
|
4292
|
+
type_name: schemas_string(),
|
|
4293
|
+
target_type: schemas_string(),
|
|
4294
|
+
target_id: coerce_number(),
|
|
4295
|
+
target: schemas_object({
|
|
4296
|
+
title: schemas_string(),
|
|
4297
|
+
has_linewatch: schemas_boolean().refine((e)=>e)
|
|
4298
|
+
})
|
|
4299
|
+
});
|
|
4349
4300
|
function keyBy(e, t) {
|
|
4350
4301
|
let n = {};
|
|
4351
4302
|
for(let r = 0; r < e.length; r++){
|
|
@@ -4372,14 +4323,6 @@ function sortBy(e, t) {
|
|
|
4372
4323
|
'asc'
|
|
4373
4324
|
]);
|
|
4374
4325
|
}
|
|
4375
|
-
function compact(e) {
|
|
4376
|
-
let t = [];
|
|
4377
|
-
for(let n = 0; n < e.length; n++){
|
|
4378
|
-
let r = e[n];
|
|
4379
|
-
r && t.push(r);
|
|
4380
|
-
}
|
|
4381
|
-
return t;
|
|
4382
|
-
}
|
|
4383
4326
|
function base_define_property(e, t, n) {
|
|
4384
4327
|
return t in e ? Object.defineProperty(e, t, {
|
|
4385
4328
|
value: n,
|
|
@@ -4388,6 +4331,14 @@ function base_define_property(e, t, n) {
|
|
|
4388
4331
|
writable: !0
|
|
4389
4332
|
}) : e[t] = n, e;
|
|
4390
4333
|
}
|
|
4334
|
+
schemas_object({
|
|
4335
|
+
subjects: schemas_object({
|
|
4336
|
+
items: schemas_array(unknown().transform((e)=>{
|
|
4337
|
+
var t;
|
|
4338
|
+
return null != (t = doubanSubjectItemSchema.safeParse(e).data) ? t : null;
|
|
4339
|
+
})).transform((e)=>compact(e))
|
|
4340
|
+
})
|
|
4341
|
+
});
|
|
4391
4342
|
class BaseScraper {
|
|
4392
4343
|
parseIdString(e) {
|
|
4393
4344
|
var t, n;
|
|
@@ -4518,7 +4469,7 @@ class BilibiliScraper extends BaseScraper {
|
|
|
4518
4469
|
base64Data: !0
|
|
4519
4470
|
});
|
|
4520
4471
|
if (404 === r.statusCode || 304 === r.statusCode) return null;
|
|
4521
|
-
let i = this.DmSegMobileReply.decode(
|
|
4472
|
+
let i = this.DmSegMobileReply.decode(base64ToUint8Array(r.data));
|
|
4522
4473
|
return console.log(i), i.elems;
|
|
4523
4474
|
} catch (r) {
|
|
4524
4475
|
console.error(`\u{83B7}\u{53D6}\u{5206}\u{6BB5} ${n} \u{5931}\u{8D25} (aid=${e}, cid=${t}): ${r}`);
|
|
@@ -4940,9 +4891,9 @@ const parseXml = function(e) {
|
|
|
4940
4891
|
} else {
|
|
4941
4892
|
let s = readTagExp(e, o, this.options.removeNSPrefix), a = s.tagName, u = s.rawTagName, l = s.tagExp, c = s.attrExpPresent, d = s.closeIndex;
|
|
4942
4893
|
this.options.transformTagName && (a = this.options.transformTagName(a)), n && r && '!xml' !== n.tagname && (r = this.saveTextToParentTag(r, n, i, !1));
|
|
4943
|
-
let
|
|
4944
|
-
|
|
4945
|
-
let
|
|
4894
|
+
let p = n;
|
|
4895
|
+
p && -1 !== this.options.unpairedTags.indexOf(p.tagname) && (n = this.tagsNodeStack.pop(), i = i.substring(0, i.lastIndexOf("."))), a !== t.tagname && (i += i ? "." + a : a);
|
|
4896
|
+
let f = o;
|
|
4946
4897
|
if (this.isItStopNode(this.options.stopNodes, i, a)) {
|
|
4947
4898
|
let t = "";
|
|
4948
4899
|
if (l.length > 0 && l.lastIndexOf("/") === l.length - 1) "/" === a[a.length - 1] ? (a = a.substr(0, a.length - 1), i = i.substr(0, i.length - 1), l = a) : l = l.substr(0, l.length - 1), o = s.closeIndex;
|
|
@@ -4953,15 +4904,15 @@ const parseXml = function(e) {
|
|
|
4953
4904
|
o = n.i, t = n.tagContent;
|
|
4954
4905
|
}
|
|
4955
4906
|
let r = new XmlNode(a);
|
|
4956
|
-
a !== l && c && (r[":@"] = this.buildAttributesMap(l, i, a)), t && (t = this.parseTextData(t, a, i, !0, c, !0, !0)), i = i.substr(0, i.lastIndexOf(".")), r.add(this.options.textNodeName, t), this.addChild(n, r, i,
|
|
4907
|
+
a !== l && c && (r[":@"] = this.buildAttributesMap(l, i, a)), t && (t = this.parseTextData(t, a, i, !0, c, !0, !0)), i = i.substr(0, i.lastIndexOf(".")), r.add(this.options.textNodeName, t), this.addChild(n, r, i, f);
|
|
4957
4908
|
} else {
|
|
4958
4909
|
if (l.length > 0 && l.lastIndexOf("/") === l.length - 1) {
|
|
4959
4910
|
"/" === a[a.length - 1] ? (a = a.substr(0, a.length - 1), i = i.substr(0, i.length - 1), l = a) : l = l.substr(0, l.length - 1), this.options.transformTagName && (a = this.options.transformTagName(a));
|
|
4960
4911
|
let e = new XmlNode(a);
|
|
4961
|
-
a !== l && c && (e[":@"] = this.buildAttributesMap(l, i, a)), this.addChild(n, e, i,
|
|
4912
|
+
a !== l && c && (e[":@"] = this.buildAttributesMap(l, i, a)), this.addChild(n, e, i, f), i = i.substr(0, i.lastIndexOf("."));
|
|
4962
4913
|
} else {
|
|
4963
4914
|
let e = new XmlNode(a);
|
|
4964
|
-
this.tagsNodeStack.push(n), a !== l && c && (e[":@"] = this.buildAttributesMap(l, i, a)), this.addChild(n, e, i,
|
|
4915
|
+
this.tagsNodeStack.push(n), a !== l && c && (e[":@"] = this.buildAttributesMap(l, i, a)), this.addChild(n, e, i, f), n = e;
|
|
4965
4916
|
}
|
|
4966
4917
|
r = "", o = d;
|
|
4967
4918
|
}
|
|
@@ -5583,7 +5534,9 @@ const tencentIdSchema = schemas_object({
|
|
|
5583
5534
|
"\u8D70\u5FC3",
|
|
5584
5535
|
"\u89E3\u5FE7",
|
|
5585
5536
|
"\u7EAF\u4EAB",
|
|
5586
|
-
"\u8282\u70B9"
|
|
5537
|
+
"\u8282\u70B9",
|
|
5538
|
+
"\u91C7\u8BBF",
|
|
5539
|
+
"\u82B1\u7D6E"
|
|
5587
5540
|
])if (e.includes(t)) return !1;
|
|
5588
5541
|
return !0;
|
|
5589
5542
|
}),
|
|
@@ -5594,8 +5547,14 @@ const tencentIdSchema = schemas_object({
|
|
|
5594
5547
|
module_datas: schemas_array(schemas_object({
|
|
5595
5548
|
item_data_lists: schemas_object({
|
|
5596
5549
|
item_datas: schemas_array(schemas_object({
|
|
5597
|
-
item_params: unknown()
|
|
5598
|
-
|
|
5550
|
+
item_params: unknown().transform((e)=>{
|
|
5551
|
+
var t;
|
|
5552
|
+
return null != (t = tencentEpisodeSchema.safeParse(e).data) ? t : null;
|
|
5553
|
+
})
|
|
5554
|
+
}).transform((e)=>{
|
|
5555
|
+
var t;
|
|
5556
|
+
return null != (t = e.item_params) ? t : null;
|
|
5557
|
+
})).transform((e)=>compact(e))
|
|
5599
5558
|
})
|
|
5600
5559
|
}))
|
|
5601
5560
|
}))
|
|
@@ -5678,7 +5637,7 @@ class TencentScraper extends BaseScraper {
|
|
|
5678
5637
|
let n = this.parseIdString(e);
|
|
5679
5638
|
if (!(null == n ? void 0 : n.vid)) return [];
|
|
5680
5639
|
let r = await this.internalGetComments(n.vid, t);
|
|
5681
|
-
return r && 0 !== r.length ? r.map((e)=>{
|
|
5640
|
+
return (console.log("\u627E\u5230", r.length, "\u6761\u5F39\u5E55"), r && 0 !== r.length) ? r.map((e)=>{
|
|
5682
5641
|
let t = 1, n = 16777215;
|
|
5683
5642
|
if (e.content_style && (2 === e.content_style.position ? t = 5 : 3 === e.content_style.position && (t = 4), e.content_style.color)) try {
|
|
5684
5643
|
n = parseInt(e.content_style.color, 10);
|
|
@@ -5719,15 +5678,11 @@ class TencentScraper extends BaseScraper {
|
|
|
5719
5678
|
cacheKey: `tencent:episodes:${e}:${n}`
|
|
5720
5679
|
}
|
|
5721
5680
|
})).data) ? i : [];
|
|
5722
|
-
|
|
5681
|
+
if (o.length >= tencent_pageSize ? (n += 1, r = url_parse.qs.stringify({
|
|
5723
5682
|
episode_begin: n * tencent_pageSize,
|
|
5724
5683
|
episode_end: (n + 1) * tencent_pageSize,
|
|
5725
5684
|
episode_step: tencent_pageSize
|
|
5726
|
-
})) : r = "", o))
|
|
5727
|
-
let { success: n, data: r } = tencentEpisodeSchema.safeParse(e.item_params);
|
|
5728
|
-
n && t.push(r);
|
|
5729
|
-
}
|
|
5730
|
-
if (!r) break;
|
|
5685
|
+
})) : r = "", t.push(...o), !r) break;
|
|
5731
5686
|
} catch (t) {
|
|
5732
5687
|
console.error(`\u{83B7}\u{53D6}\u{5206}\u{96C6}\u{5217}\u{8868}\u{5931}\u{8D25} (cid=${e})`, t);
|
|
5733
5688
|
break;
|
|
@@ -5772,7 +5727,7 @@ const youkuIdSchema = schemas_object({
|
|
|
5772
5727
|
id: schemas_string(),
|
|
5773
5728
|
show_id: schemas_string().optional(),
|
|
5774
5729
|
title: schemas_string(),
|
|
5775
|
-
seq:
|
|
5730
|
+
seq: coerce_number().optional(),
|
|
5776
5731
|
duration: schemas_string(),
|
|
5777
5732
|
category: schemas_string(),
|
|
5778
5733
|
link: schemas_string()
|
|
@@ -5837,8 +5792,8 @@ class YoukuScraper extends BaseScraper {
|
|
|
5837
5792
|
if (d) return [
|
|
5838
5793
|
n(d, u)
|
|
5839
5794
|
];
|
|
5840
|
-
let
|
|
5841
|
-
length:
|
|
5795
|
+
let p = Number(null != (i = null == o ? void 0 : o.total) ? i : 0), f = Math.max(1, Math.ceil(p / a)), h = Array.from({
|
|
5796
|
+
length: f
|
|
5842
5797
|
}, (e, t)=>t + 1).filter((e)=>e !== l), m = [];
|
|
5843
5798
|
for (let e of h){
|
|
5844
5799
|
await this.sleep(500);
|
|
@@ -6163,7 +6118,7 @@ class scrapers_Scraper {
|
|
|
6163
6118
|
});
|
|
6164
6119
|
}
|
|
6165
6120
|
}
|
|
6166
|
-
const widgetVersion = "0.0.
|
|
6121
|
+
const widgetVersion = "0.0.16";
|
|
6167
6122
|
WidgetMetadata = {
|
|
6168
6123
|
id: "baranwang.danmu.universe",
|
|
6169
6124
|
title: "\u901A\u7528\u5F39\u5E55",
|
|
@@ -6205,22 +6160,18 @@ WidgetMetadata = {
|
|
|
6205
6160
|
};
|
|
6206
6161
|
const src_scraper = new scrapers_Scraper();
|
|
6207
6162
|
searchDanmu = async (e)=>{
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
let
|
|
6211
|
-
|
|
6212
|
-
animes:
|
|
6213
|
-
};
|
|
6214
|
-
let s = await getDoubanInfoByTmdbId(r, n, i);
|
|
6215
|
-
return {
|
|
6216
|
-
animes: (await src_scraper.getDetailWithDoubanId(null != (t = null == s ? void 0 : s.doubanId) ? t : "", r, o)).map((e)=>{
|
|
6163
|
+
let { tmdbId: t, type: n, season: r, episode: i } = e;
|
|
6164
|
+
if (!t) return null;
|
|
6165
|
+
let o = await getDoubanInfoByTmdbId(n, t, r);
|
|
6166
|
+
return (null == o ? void 0 : o.doubanId) ? {
|
|
6167
|
+
animes: (await src_scraper.getDetailWithDoubanId(o.doubanId, n, i)).map((e)=>{
|
|
6217
6168
|
let t = `[${PROVIDER_NAMES[e.provider]}] `;
|
|
6218
6169
|
return e.episodeTitle && (t += e.episodeTitle), {
|
|
6219
6170
|
animeId: e.episodeId,
|
|
6220
6171
|
animeTitle: t
|
|
6221
6172
|
};
|
|
6222
6173
|
})
|
|
6223
|
-
};
|
|
6174
|
+
} : null;
|
|
6224
6175
|
}, getDetail = async (e)=>{
|
|
6225
6176
|
var t;
|
|
6226
6177
|
let { animeId: n, tmdbId: r, type: i, season: o, episode: s } = e;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forward-widget/danmu-universe",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/danmu-universe.js",
|
|
6
6
|
"exports": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"p-limit": "^6.2.0",
|
|
17
17
|
"protobufjs": "^7.5.4",
|
|
18
18
|
"url-parse": "^1.5.10",
|
|
19
|
-
"zod": "
|
|
19
|
+
"zod": "4.0.17"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@forward-widget/libs": "^1.8.4",
|