movi-player 0.3.0 → 0.3.2

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.
Files changed (61) hide show
  1. package/AGENTS.md +2 -0
  2. package/README.md +54 -7
  3. package/dist/core/MoviPlayer.d.ts +77 -1
  4. package/dist/core/MoviPlayer.d.ts.map +1 -1
  5. package/dist/core/MoviPlayer.js +667 -121
  6. package/dist/core/MoviPlayer.js.map +1 -1
  7. package/dist/core/PlayerState.js +1 -1
  8. package/dist/core/PlayerState.js.map +1 -1
  9. package/dist/decode/VideoDecoder.d.ts.map +1 -1
  10. package/dist/decode/VideoDecoder.js +6 -2
  11. package/dist/decode/VideoDecoder.js.map +1 -1
  12. package/dist/demuxer.cjs +315 -129
  13. package/dist/demuxer.js +377 -191
  14. package/dist/element.cjs +58309 -16596
  15. package/dist/element.js +59520 -17807
  16. package/dist/index.cjs +58309 -16596
  17. package/dist/index.js +59520 -17807
  18. package/dist/player.cjs +56818 -15360
  19. package/dist/player.js +57818 -16360
  20. package/dist/render/DASHPlayerWrapper.d.ts +65 -0
  21. package/dist/render/DASHPlayerWrapper.d.ts.map +1 -0
  22. package/dist/render/DASHPlayerWrapper.js +540 -0
  23. package/dist/render/DASHPlayerWrapper.js.map +1 -0
  24. package/dist/render/HLSPlayerWrapper.d.ts.map +1 -1
  25. package/dist/render/HLSPlayerWrapper.js +47 -11
  26. package/dist/render/HLSPlayerWrapper.js.map +1 -1
  27. package/dist/render/MoviElement.d.ts +97 -0
  28. package/dist/render/MoviElement.d.ts.map +1 -1
  29. package/dist/render/MoviElement.js +852 -152
  30. package/dist/render/MoviElement.js.map +1 -1
  31. package/dist/render/ShakaPlayerWrapper.d.ts +111 -0
  32. package/dist/render/ShakaPlayerWrapper.d.ts.map +1 -0
  33. package/dist/render/ShakaPlayerWrapper.js +956 -0
  34. package/dist/render/ShakaPlayerWrapper.js.map +1 -0
  35. package/dist/source/DashFallback.d.ts +32 -0
  36. package/dist/source/DashFallback.d.ts.map +1 -0
  37. package/dist/source/DashFallback.js +142 -0
  38. package/dist/source/DashFallback.js.map +1 -0
  39. package/dist/source/DashManifest.d.ts +34 -0
  40. package/dist/source/DashManifest.d.ts.map +1 -0
  41. package/dist/source/DashManifest.js +194 -0
  42. package/dist/source/DashManifest.js.map +1 -0
  43. package/dist/source/DashSegmentSource.d.ts +32 -0
  44. package/dist/source/DashSegmentSource.d.ts.map +1 -0
  45. package/dist/source/DashSegmentSource.js +86 -0
  46. package/dist/source/DashSegmentSource.js.map +1 -0
  47. package/dist/source/HttpSource.d.ts +64 -0
  48. package/dist/source/HttpSource.d.ts.map +1 -1
  49. package/dist/source/HttpSource.js +444 -57
  50. package/dist/source/HttpSource.js.map +1 -1
  51. package/dist/source/ThumbnailHttpSource.d.ts +13 -0
  52. package/dist/source/ThumbnailHttpSource.d.ts.map +1 -1
  53. package/dist/source/ThumbnailHttpSource.js +70 -8
  54. package/dist/source/ThumbnailHttpSource.js.map +1 -1
  55. package/dist/source/index.d.ts +2 -0
  56. package/dist/source/index.d.ts.map +1 -1
  57. package/dist/source/index.js +1 -0
  58. package/dist/source/index.js.map +1 -1
  59. package/dist/types.d.ts +10 -0
  60. package/dist/types.d.ts.map +1 -1
  61. package/package.json +16 -6
package/dist/demuxer.cjs CHANGED
@@ -79,12 +79,12 @@ class CodecParser {
79
79
  }
80
80
  let k = 0, e = f;
81
81
  for (let A2 = 0; A2 < 32; A2++) k = 2 * k + (1 & e), e = Math.floor(e / 2);
82
- let s = `hvc1.${l}${E}.${(k >>> 0).toString(16)}.${0 === t ? "L" : "H"}${F}`, i = false;
82
+ let i = `hvc1.${l}${E}.${(k >>> 0).toString(16)}.${0 === t ? "L" : "H"}${F}`, s = false;
83
83
  for (let A2 = 5; A2 >= 0; A2--) {
84
84
  const v2 = n[A2];
85
- (0 !== v2 || i) && (s += "." + v2.toString(16), i = true);
85
+ (0 !== v2 || s) && (i += "." + v2.toString(16), s = true);
86
86
  }
87
- return Logger.debug(TAG$e, `HEVC codec string: ${s}`), s;
87
+ return Logger.debug(TAG$e, `HEVC codec string: ${i}`), i;
88
88
  }
89
89
  static getAvcCodecString(A) {
90
90
  if (A.length < 4) return "avc1.420028";
@@ -285,7 +285,7 @@ class MoviVideoDecoder {
285
285
  }
286
286
  async configure(A, v, r = 0) {
287
287
  if (this.currentTrack = A, this.targetFps = r, this.currentProfile = A.profile, this.useSoftware = false, this.requiresSoftware = false, this.isAnnexBSource = false, this.openGopErrorCount = 0, this.hardwareRetryCount = 0, this.lastHardwareRetryTime = 0, this.swDecoder && (this.swDecoder.close(), this.swDecoder = null), this.forceSoftware) return Logger.info(TAG$c, "Force software decoding enabled, using WASM decoder"), this.useSoftware = true, this.initSoftwareDecoder();
288
- if (!("VideoDecoder" in window)) return Logger.error(TAG$c, "WebCodecs VideoDecoder not supported"), false;
288
+ if (!("VideoDecoder" in window)) return Logger.warn(TAG$c, "WebCodecs VideoDecoder not supported — falling back to software decoder"), this.useSoftware = true, this.initSoftwareDecoder();
289
289
  let j = CodecParser.getCodecString(A.codec, A.extradata);
290
290
  if (j || (Logger.debug(TAG$c, "CodecParser returned null, falling back to manual mapping"), j = this.mapCodecToWebCodecs(A.codec, A.width, A.height, A.profile, A.level)), !j) return Logger.error(TAG$c, `Unsupported codec: ${A.codec}`), false;
291
291
  const b = { codec: j, codedWidth: A.width, codedHeight: A.height, hardwareAcceleration: "prefer-hardware" };
@@ -646,28 +646,28 @@ class MoviVideoDecoder {
646
646
  }
647
647
  if (0 === b.length) return Logger.warn(TAG$c, "No SPS found in Annex B extradata"), null;
648
648
  const E = j[0] || b[0], f = this.removeEpb(E), n = 32 == (f[0] >> 1 & 63) ? 6 : 3;
649
- let F = v?.profile ?? 2, l = 0, k = new Uint8Array([32, 0, 0, 0]), e = new Uint8Array(6), s = v?.level ?? 153;
649
+ let F = v?.profile ?? 2, l = 0, k = new Uint8Array([32, 0, 0, 0]), e = new Uint8Array(6), i = v?.level ?? 153;
650
650
  if (f.length >= n + 12) {
651
651
  const A2 = f[n];
652
- F = 31 & A2, l = A2 >> 5 & 1, k = f.slice(n + 1, n + 5), e = f.slice(n + 5, n + 11), s = f[n + 11], Logger.debug(TAG$c, `hvcC from NAL: profile=${F}, tier=${l}, level=${s}`);
653
- } else null == v?.profile && null == v?.level || Logger.debug(TAG$c, `hvcC from track metadata: profile=${F}, level=${s}`);
654
- const i = [];
655
- j.length > 0 && i.push({ type: 32, nalus: j }), b.length > 0 && i.push({ type: 33, nalus: b }), t.length > 0 && i.push({ type: 34, nalus: t });
656
- let u = 23;
657
- for (const A2 of i) {
658
- u += 3;
659
- for (const v2 of A2.nalus) u += 2 + v2.length;
652
+ F = 31 & A2, l = A2 >> 5 & 1, k = f.slice(n + 1, n + 5), e = f.slice(n + 5, n + 11), i = f[n + 11], Logger.debug(TAG$c, `hvcC from NAL: profile=${F}, tier=${l}, level=${i}`);
653
+ } else null == v?.profile && null == v?.level || Logger.debug(TAG$c, `hvcC from track metadata: profile=${F}, level=${i}`);
654
+ const s = [];
655
+ j.length > 0 && s.push({ type: 32, nalus: j }), b.length > 0 && s.push({ type: 33, nalus: b }), t.length > 0 && s.push({ type: 34, nalus: t });
656
+ let a = 23;
657
+ for (const A2 of s) {
658
+ a += 3;
659
+ for (const v2 of A2.nalus) a += 2 + v2.length;
660
660
  }
661
- const a = new Uint8Array(u), o = new DataView(a.buffer);
661
+ const u = new Uint8Array(a), o = new DataView(u.buffer);
662
662
  let x = 0;
663
- a[x++] = 1, a[x++] = l << 5 | 31 & F, a[x++] = k[0], a[x++] = k[1], a[x++] = k[2], a[x++] = k[3];
664
- for (let A2 = 0; A2 < 6; A2++) a[x++] = e[A2];
665
- a[x++] = s, o.setUint16(x, 61440), x += 2, a[x++] = 252, a[x++] = 253, a[x++] = 250, a[x++] = 250, o.setUint16(x, 0), x += 2, a[x++] = 15, a[x++] = i.length;
666
- for (const A2 of i) {
667
- a[x++] = 128 | 63 & A2.type, o.setUint16(x, A2.nalus.length), x += 2;
668
- for (const v2 of A2.nalus) o.setUint16(x, v2.length), x += 2, a.set(v2, x), x += v2.length;
663
+ u[x++] = 1, u[x++] = l << 5 | 31 & F, u[x++] = k[0], u[x++] = k[1], u[x++] = k[2], u[x++] = k[3];
664
+ for (let A2 = 0; A2 < 6; A2++) u[x++] = e[A2];
665
+ u[x++] = i, o.setUint16(x, 61440), x += 2, u[x++] = 252, u[x++] = 253, u[x++] = 250, u[x++] = 250, o.setUint16(x, 0), x += 2, u[x++] = 15, u[x++] = s.length;
666
+ for (const A2 of s) {
667
+ u[x++] = 128 | 63 & A2.type, o.setUint16(x, A2.nalus.length), x += 2;
668
+ for (const v2 of A2.nalus) o.setUint16(x, v2.length), x += 2, u.set(v2, x), x += v2.length;
669
669
  }
670
- return a;
670
+ return u;
671
671
  }
672
672
  static annexBToAvcC(A) {
673
673
  const v = this.splitAnnexBNalUnits(A);
@@ -1268,12 +1268,12 @@ async function createMoviModule(A = {}) {
1268
1268
  throw new Error(v2.status + " : " + v2.url);
1269
1269
  };
1270
1270
  }
1271
- var n, F, l, k, e, HEAP32, s, i, u, HEAPU8, a = function() {
1271
+ var n, F, l, k, e, HEAP32, i, s, a, HEAPU8, u = function() {
1272
1272
  }.bind(), o = function() {
1273
1273
  }.bind(), x = false, q = false;
1274
1274
  function B() {
1275
1275
  var A2 = I.buffer;
1276
- i = new Int8Array(A2), e = new Int16Array(A2), Module.HEAPU8 = HEAPU8 = new Uint8Array(A2), HEAP32 = new Int32Array(A2), u = new Uint32Array(A2), Module.HEAPF32 = new Float32Array(A2), s = new BigInt64Array(A2), new BigUint64Array(A2);
1276
+ s = new Int8Array(A2), e = new Int16Array(A2), Module.HEAPU8 = HEAPU8 = new Uint8Array(A2), HEAP32 = new Int32Array(A2), a = new Uint32Array(A2), Module.HEAPF32 = new Float32Array(A2), i = new BigInt64Array(A2), new BigUint64Array(A2);
1277
1277
  }
1278
1278
  function d(A2) {
1279
1279
  Module.onAbort?.(A2), o(A2 = `Aborted(${A2})`), x = true, A2 += ". Build with -sASSERTIONS for more info.";
@@ -1286,9 +1286,9 @@ async function createMoviModule(A = {}) {
1286
1286
  this.message = `Program terminated with exit(${A2})`, this.status = A2;
1287
1287
  }
1288
1288
  }
1289
- var $, H, c, p, G, m, _, J, h, g, N, I, L, P = (A2) => {
1289
+ var $, c, H, p, G, m, _, J, h, g, N, I, L, P = (A2) => {
1290
1290
  for (; A2.length > 0; ) A2.shift()(Module);
1291
- }, D = [], O = (A2) => D.push(A2), y = [], K = (A2) => y.push(A2), T = true, C = (A2) => A2 < -9007199254740992 || A2 > 9007199254740992 ? NaN : Number(A2), M = new TextDecoder(), S = (A2, v2, r2, j2) => {
1291
+ }, D = [], O = (A2) => D.push(A2), y = [], T = (A2) => y.push(A2), K = true, C = (A2) => A2 < -9007199254740992 || A2 > 9007199254740992 ? NaN : Number(A2), M = new TextDecoder(), S = (A2, v2, r2, j2) => {
1292
1292
  var b2 = v2 + r2;
1293
1293
  if (j2) return b2;
1294
1294
  for (; A2[v2] && !(v2 >= b2); ) ++v2;
@@ -1405,9 +1405,9 @@ async function createMoviModule(A = {}) {
1405
1405
  }
1406
1406
  return z.shift();
1407
1407
  })(), put_char(A2, v2) {
1408
- null === v2 || 10 === v2 ? (a(V(A2.output)), A2.output = []) : 0 != v2 && A2.output.push(v2);
1408
+ null === v2 || 10 === v2 ? (u(V(A2.output)), A2.output = []) : 0 != v2 && A2.output.push(v2);
1409
1409
  }, fsync(A2) {
1410
- A2.output?.length > 0 && (a(V(A2.output)), A2.output = []);
1410
+ A2.output?.length > 0 && (u(V(A2.output)), A2.output = []);
1411
1411
  }, ioctl_tcgets: (A2) => ({ c_iflag: 25856, c_oflag: 5, c_cflag: 191, c_lflag: 35387, c_cc: [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 15, 23, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }), ioctl_tcsets: (A2, v2, r2) => 0, ioctl_tiocgwinsz: (A2) => [24, 80] }, default_tty1_ops: { put_char(A2, v2) {
1412
1412
  null === v2 || 10 === v2 ? (o(V(A2.output)), A2.output = []) : 0 != v2 && A2.output.push(v2);
1413
1413
  }, fsync(A2) {
@@ -1468,7 +1468,7 @@ async function createMoviModule(A = {}) {
1468
1468
  var E2 = Math.min(A2.node.usedBytes - b2, j2);
1469
1469
  return v2.set(t2.subarray(b2, b2 + E2), r2), E2;
1470
1470
  }, write(A2, v2, r2, j2, b2, t2) {
1471
- if (v2.buffer === i.buffer && (t2 = false), !j2) return 0;
1471
+ if (v2.buffer === s.buffer && (t2 = false), !j2) return 0;
1472
1472
  var E2 = A2.node;
1473
1473
  return E2.mtime = E2.ctime = Date.now(), t2 ? (E2.contents = v2.subarray(r2, r2 + j2), E2.usedBytes = j2) : 0 === E2.usedBytes && 0 === b2 ? (E2.contents = v2.slice(r2, r2 + j2), E2.usedBytes = j2) : (vA.expandFileStorage(E2, b2 + j2), E2.contents.set(v2.subarray(r2, r2 + j2), b2), E2.usedBytes = Math.max(E2.usedBytes, b2 + j2)), j2;
1474
1474
  }, llseek(A2, v2, r2) {
@@ -1478,9 +1478,9 @@ async function createMoviModule(A = {}) {
1478
1478
  }, mmap(A2, v2, r2, j2, b2) {
1479
1479
  if (!FS.isFile(A2.node.mode)) throw new FS.ErrnoError(43);
1480
1480
  var t2, E2, f2 = A2.node.contents;
1481
- if (2 & b2 || f2.buffer !== i.buffer) {
1481
+ if (2 & b2 || f2.buffer !== s.buffer) {
1482
1482
  if (E2 = true, !(t2 = AA())) throw new FS.ErrnoError(48);
1483
- f2 && ((r2 > 0 || r2 + v2 < f2.length) && (f2 = f2.subarray ? f2.subarray(r2, r2 + v2) : Array.prototype.slice.call(f2, r2, r2 + v2)), i.set(f2, t2 >>> 0));
1483
+ f2 && ((r2 > 0 || r2 + v2 < f2.length) && (f2 = f2.subarray ? f2.subarray(r2, r2 + v2) : Array.prototype.slice.call(f2, r2, r2 + v2)), s.set(f2, t2 >>> 0));
1484
1484
  } else E2 = false, t2 = f2.byteOffset;
1485
1485
  return { ptr: t2, allocated: E2 };
1486
1486
  }, msync: (A2, v2, r2, j2, b2) => (vA.stream_ops.write(A2, v2, 0, j2, r2, false), 0) } }, rA = (A2) => ("string" == typeof A2 && (A2 = W(A2)), A2.subarray || (A2 = new Uint8Array(A2)), A2), jA = (A2, v2) => {
@@ -2082,7 +2082,7 @@ async function createMoviModule(A = {}) {
2082
2082
  var b5 = new XMLHttpRequest();
2083
2083
  return b5.open("GET", j2, false), r2 !== E3 && b5.setRequestHeader("Range", "bytes=" + A5 + "-" + v5), b5.responseType = "arraybuffer", b5.overrideMimeType && b5.overrideMimeType("text/plain; charset=x-user-defined"), b5.send(null), b5.status >= 200 && b5.status < 300 || 304 === b5.status || d("Couldn't load " + j2 + ". Status: " + b5.status), void 0 !== b5.response ? new Uint8Array(b5.response || []) : W(b5.responseText || "");
2084
2084
  })(v4, b4)), void 0 === f3.chunks[A4] && d("doXHR failed!"), f3.chunks[A4];
2085
- }), !t3 && r2 || (E3 = r2 = 1, r2 = this.getter(0).length, E3 = r2, a("LazyFiles on gzip forces download of the whole file when length is accessed")), this._length = r2, this._chunkSize = E3, this.lengthKnown = true;
2085
+ }), !t3 && r2 || (E3 = r2 = 1, r2 = this.getter(0).length, E3 = r2, u("LazyFiles on gzip forces download of the whole file when length is accessed")), this._length = r2, this._chunkSize = E3, this.lengthKnown = true;
2086
2086
  }
2087
2087
  get length() {
2088
2088
  return this.lengthKnown || this.cacheLength(), this._length;
@@ -2113,7 +2113,7 @@ async function createMoviModule(A = {}) {
2113
2113
  FS.forceLoadFile(f2);
2114
2114
  var t3 = AA();
2115
2115
  if (!t3) throw new FS.ErrnoError(48);
2116
- return F2(A3, i, t3, v3, r2), { ptr: t3, allocated: true };
2116
+ return F2(A3, s, t3, v3, r2), { ptr: t3, allocated: true };
2117
2117
  }, f2.stream_ops = n2, f2;
2118
2118
  } }, nA = { currentUmask: 18, calculateAt(A2, v2, r2) {
2119
2119
  if (R.isAbs(v2)) return v2;
@@ -2124,11 +2124,11 @@ async function createMoviModule(A = {}) {
2124
2124
  }
2125
2125
  return j2 + "/" + v2;
2126
2126
  }, writeStat(A2, v2) {
2127
- u[A2 >>> 2 >>> 0] = v2.dev, u[A2 + 4 >>> 2 >>> 0] = v2.mode, u[A2 + 8 >>> 2 >>> 0] = v2.nlink, u[A2 + 12 >>> 2 >>> 0] = v2.uid, u[A2 + 16 >>> 2 >>> 0] = v2.gid, u[A2 + 20 >>> 2 >>> 0] = v2.rdev, s[A2 + 24 >>> 3 >>> 0] = BigInt(v2.size), HEAP32[A2 + 32 >>> 2 >>> 0] = 4096, HEAP32[A2 + 36 >>> 2 >>> 0] = v2.blocks;
2127
+ a[A2 >>> 2 >>> 0] = v2.dev, a[A2 + 4 >>> 2 >>> 0] = v2.mode, a[A2 + 8 >>> 2 >>> 0] = v2.nlink, a[A2 + 12 >>> 2 >>> 0] = v2.uid, a[A2 + 16 >>> 2 >>> 0] = v2.gid, a[A2 + 20 >>> 2 >>> 0] = v2.rdev, i[A2 + 24 >>> 3 >>> 0] = BigInt(v2.size), HEAP32[A2 + 32 >>> 2 >>> 0] = 4096, HEAP32[A2 + 36 >>> 2 >>> 0] = v2.blocks;
2128
2128
  var r2 = v2.atime.getTime(), j2 = v2.mtime.getTime(), b2 = v2.ctime.getTime();
2129
- return s[A2 + 40 >>> 3 >>> 0] = BigInt(Math.floor(r2 / 1e3)), u[A2 + 48 >>> 2 >>> 0] = r2 % 1e3 * 1e3 * 1e3, s[A2 + 56 >>> 3 >>> 0] = BigInt(Math.floor(j2 / 1e3)), u[A2 + 64 >>> 2 >>> 0] = j2 % 1e3 * 1e3 * 1e3, s[A2 + 72 >>> 3 >>> 0] = BigInt(Math.floor(b2 / 1e3)), u[A2 + 80 >>> 2 >>> 0] = b2 % 1e3 * 1e3 * 1e3, s[A2 + 88 >>> 3 >>> 0] = BigInt(v2.ino), 0;
2129
+ return i[A2 + 40 >>> 3 >>> 0] = BigInt(Math.floor(r2 / 1e3)), a[A2 + 48 >>> 2 >>> 0] = r2 % 1e3 * 1e3 * 1e3, i[A2 + 56 >>> 3 >>> 0] = BigInt(Math.floor(j2 / 1e3)), a[A2 + 64 >>> 2 >>> 0] = j2 % 1e3 * 1e3 * 1e3, i[A2 + 72 >>> 3 >>> 0] = BigInt(Math.floor(b2 / 1e3)), a[A2 + 80 >>> 2 >>> 0] = b2 % 1e3 * 1e3 * 1e3, i[A2 + 88 >>> 3 >>> 0] = BigInt(v2.ino), 0;
2130
2130
  }, writeStatFs(A2, v2) {
2131
- u[A2 + 4 >>> 2 >>> 0] = v2.bsize, u[A2 + 60 >>> 2 >>> 0] = v2.bsize, s[A2 + 8 >>> 3 >>> 0] = BigInt(v2.blocks), s[A2 + 16 >>> 3 >>> 0] = BigInt(v2.bfree), s[A2 + 24 >>> 3 >>> 0] = BigInt(v2.bavail), s[A2 + 32 >>> 3 >>> 0] = BigInt(v2.files), s[A2 + 40 >>> 3 >>> 0] = BigInt(v2.ffree), u[A2 + 48 >>> 2 >>> 0] = v2.fsid, u[A2 + 64 >>> 2 >>> 0] = v2.flags, u[A2 + 56 >>> 2 >>> 0] = v2.namelen;
2131
+ a[A2 + 4 >>> 2 >>> 0] = v2.bsize, a[A2 + 60 >>> 2 >>> 0] = v2.bsize, i[A2 + 8 >>> 3 >>> 0] = BigInt(v2.blocks), i[A2 + 16 >>> 3 >>> 0] = BigInt(v2.bfree), i[A2 + 24 >>> 3 >>> 0] = BigInt(v2.bavail), i[A2 + 32 >>> 3 >>> 0] = BigInt(v2.files), i[A2 + 40 >>> 3 >>> 0] = BigInt(v2.ffree), a[A2 + 48 >>> 2 >>> 0] = v2.fsid, a[A2 + 64 >>> 2 >>> 0] = v2.flags, a[A2 + 56 >>> 2 >>> 0] = v2.namelen;
2132
2132
  }, doMsync(A2, v2, r2, j2, b2) {
2133
2133
  if (!FS.isFile(v2.node.mode)) throw new FS.ErrnoError(43);
2134
2134
  if (2 & j2) return 0;
@@ -2137,22 +2137,22 @@ async function createMoviModule(A = {}) {
2137
2137
  }, getStreamFromFD: (A2) => FS.getStreamChecked(A2), varargs: void 0, getStr: (A2) => w(A2) }, FA = () => {
2138
2138
  var A2 = HEAP32[+nA.varargs >>> 2 >>> 0];
2139
2139
  return nA.varargs += 4, A2;
2140
- }, lA = FA, kA = (A2, v2, r2) => Y(A2, HEAPU8, v2, r2), eA = 0, sA = {}, iA = (A2) => {
2140
+ }, lA = FA, kA = (A2, v2, r2) => Y(A2, HEAPU8, v2, r2), eA = 0, iA = {}, sA = (A2) => {
2141
2141
  if (A2 instanceof ExitStatus || "unwind" == A2) return n;
2142
2142
  E(0, A2);
2143
- }, uA = () => T || eA > 0, aA = (A2) => {
2144
- n = A2, uA() || (Module.onExit?.(A2), x = true), E(0, new ExitStatus(A2));
2143
+ }, aA = () => K || eA > 0, uA = (A2) => {
2144
+ n = A2, aA() || (Module.onExit?.(A2), x = true), E(0, new ExitStatus(A2));
2145
2145
  }, oA = (A2) => {
2146
2146
  if (!x) try {
2147
2147
  return A2();
2148
2148
  } catch (A3) {
2149
- iA(A3);
2149
+ sA(A3);
2150
2150
  } finally {
2151
2151
  (() => {
2152
- if (!uA()) try {
2153
- n = A3 = n, aA(A3);
2152
+ if (!aA()) try {
2153
+ n = A3 = n, uA(A3);
2154
2154
  } catch (A4) {
2155
- iA(A4);
2155
+ sA(A4);
2156
2156
  }
2157
2157
  var A3;
2158
2158
  })();
@@ -2163,16 +2163,16 @@ async function createMoviModule(A = {}) {
2163
2163
  return I.grow(v2), B(), 1;
2164
2164
  } catch (A3) {
2165
2165
  }
2166
- }, $A = {}, HA = () => {
2167
- if (!HA.strings) {
2166
+ }, $A = {}, cA = () => {
2167
+ if (!cA.strings) {
2168
2168
  var A2 = { USER: "web_user", LOGNAME: "web_user", PATH: "/", PWD: "/", HOME: "/home/web_user", LANG: (globalThis.navigator?.language ?? "C").replace("-", "_") + ".UTF-8", _: t || "./this.program" };
2169
2169
  for (var v2 in $A) void 0 === $A[v2] ? delete A2[v2] : A2[v2] = $A[v2];
2170
2170
  var r2 = [];
2171
2171
  for (var v2 in A2) r2.push(`${v2}=${A2[v2]}`);
2172
- HA.strings = r2;
2172
+ cA.strings = r2;
2173
2173
  }
2174
- return HA.strings;
2175
- }, cA = (A2) => {
2174
+ return cA.strings;
2175
+ }, HA = (A2) => {
2176
2176
  try {
2177
2177
  return A2();
2178
2178
  } catch (A3) {
@@ -2205,14 +2205,14 @@ async function createMoviModule(A = {}) {
2205
2205
  }
2206
2206
  return pA.callstackFuncToId.get(A2);
2207
2207
  }, maybeStopUnwind() {
2208
- pA.currData && pA.state === pA.State.Unwinding && 0 === pA.exportCallStack.length && (pA.state = pA.State.Normal, cA(h), "undefined" != typeof Fibers && Fibers.trampoline());
2208
+ pA.currData && pA.state === pA.State.Unwinding && 0 === pA.exportCallStack.length && (pA.state = pA.State.Normal, HA(h), "undefined" != typeof Fibers && Fibers.trampoline());
2209
2209
  }, whenDone: () => new Promise((A2, v2) => {
2210
2210
  pA.asyncPromiseHandlers = { resolve: A2, reject: v2 };
2211
2211
  }), allocateData() {
2212
- var A2 = c(12 + pA.StackSize);
2212
+ var A2 = H(12 + pA.StackSize);
2213
2213
  return pA.setDataHeader(A2, A2 + 12, pA.StackSize), pA.setDataRewindFunc(A2), A2;
2214
2214
  }, setDataHeader(A2, v2, r2) {
2215
- u[A2 >>> 2 >>> 0] = v2, u[A2 + 4 >>> 2 >>> 0] = v2 + r2;
2215
+ a[A2 >>> 2 >>> 0] = v2, a[A2 + 4 >>> 2 >>> 0] = v2 + r2;
2216
2216
  }, setDataRewindFunc(A2) {
2217
2217
  var v2 = pA.exportCallStack[0], r2 = pA.getCallStackId(v2);
2218
2218
  HEAP32[A2 + 8 >>> 2 >>> 0] = r2;
@@ -2228,7 +2228,7 @@ async function createMoviModule(A = {}) {
2228
2228
  var v2 = false, r2 = false;
2229
2229
  A2((A3 = 0) => {
2230
2230
  if (!x && (pA.handleSleepReturnValue = A3, v2 = true, r2)) {
2231
- pA.state = pA.State.Rewinding, cA(() => g(pA.currData)), "undefined" != typeof MainLoop && MainLoop.func && MainLoop.resume();
2231
+ pA.state = pA.State.Rewinding, HA(() => g(pA.currData)), "undefined" != typeof MainLoop && MainLoop.func && MainLoop.resume();
2232
2232
  var j2, b2 = false;
2233
2233
  try {
2234
2234
  j2 = pA.doRewind(pA.currData);
@@ -2242,8 +2242,8 @@ async function createMoviModule(A = {}) {
2242
2242
  }
2243
2243
  if (b2 && !t2) throw j2;
2244
2244
  }
2245
- }), r2 = true, v2 || (pA.state = pA.State.Unwinding, pA.currData = pA.allocateData(), "undefined" != typeof MainLoop && MainLoop.func && MainLoop.pause(), cA(() => J(pA.currData)));
2246
- } else pA.state === pA.State.Rewinding ? (pA.state = pA.State.Normal, cA(N), H(pA.currData), pA.currData = null, pA.sleepCallbacks.forEach(oA)) : d(`invalid state: ${pA.state}`);
2245
+ }), r2 = true, v2 || (pA.state = pA.State.Unwinding, pA.currData = pA.allocateData(), "undefined" != typeof MainLoop && MainLoop.func && MainLoop.pause(), HA(() => J(pA.currData)));
2246
+ } else pA.state === pA.State.Rewinding ? (pA.state = pA.State.Normal, HA(N), c(pA.currData), pA.currData = null, pA.sleepCallbacks.forEach(oA)) : d(`invalid state: ${pA.state}`);
2247
2247
  return pA.handleSleepReturnValue;
2248
2248
  }
2249
2249
  }, handleAsync: (A2) => pA.handleSleep(async (v2) => {
@@ -2257,27 +2257,27 @@ async function createMoviModule(A = {}) {
2257
2257
  })(A3)), v3;
2258
2258
  }, array: (A3) => {
2259
2259
  var v3, r3, j3 = mA(A3.length);
2260
- return v3 = A3, r3 = j3, i.set(v3, r3 >>> 0), j3;
2260
+ return v3 = A3, r3 = j3, s.set(v3, r3 >>> 0), j3;
2261
2261
  } }, E2 = GA(A2), f2 = [], n2 = 0;
2262
2262
  if (j2) for (var F2 = 0; F2 < j2.length; F2++) {
2263
2263
  var l2 = t2[r2[F2]];
2264
2264
  l2 ? (0 === n2 && (n2 = _A()), f2[F2] = l2(j2[F2])) : f2[F2] = j2[F2];
2265
2265
  }
2266
2266
  var k2 = pA.currData, e2 = E2(...f2);
2267
- function s2(A3) {
2267
+ function i2(A3) {
2268
2268
  return eA -= 1, 0 !== n2 && G(n2), function(A4) {
2269
2269
  return "string" === v2 ? w(A4) : "pointer" === v2 ? A4 >>> 0 : "boolean" === v2 ? Boolean(A4) : A4;
2270
2270
  }(A3);
2271
2271
  }
2272
- var u2 = b2?.async;
2273
- return eA += 1, pA.currData != k2 ? pA.whenDone().then(s2) : (e2 = s2(e2), u2 ? Promise.resolve(e2) : e2);
2272
+ var a2 = b2?.async;
2273
+ return eA += 1, pA.currData != k2 ? pA.whenDone().then(i2) : (e2 = i2(e2), a2 ? Promise.resolve(e2) : e2);
2274
2274
  }, hA = (A2) => L.get(A2), gA = [], NA = (A2, v2) => L.set(A2, v2), IA = (A2) => {
2275
2275
  const v2 = A2.length;
2276
2276
  return [v2 % 128 | 128, v2 >> 7, ...A2];
2277
2277
  }, LA = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 }, PA = (A2) => IA(Array.from(A2, (A3) => LA[A3]));
2278
2278
  if (FS.createPreloadedFile = (A2, v2, r2, j2, b2, t2, E2, f2, n2, F2) => {
2279
2279
  fA(A2, v2, r2, j2, b2, f2, n2, F2).then(t2).catch(E2);
2280
- }, FS.preloadFile = fA, FS.staticInit(), Module.noExitRuntime && (T = Module.noExitRuntime), Module.preloadPlugins && (EA = Module.preloadPlugins), Module.print && (a = Module.print), Module.printErr && (o = Module.printErr), Module.wasmBinary && Module.wasmBinary, Module.arguments && Module.arguments, Module.thisProgram && (t = Module.thisProgram), Module.preInit) for ("function" == typeof Module.preInit && (Module.preInit = [Module.preInit]); Module.preInit.length > 0; ) Module.preInit.shift()();
2280
+ }, FS.preloadFile = fA, FS.staticInit(), Module.noExitRuntime && (K = Module.noExitRuntime), Module.preloadPlugins && (EA = Module.preloadPlugins), Module.print && (u = Module.print), Module.printErr && (o = Module.printErr), Module.wasmBinary && Module.wasmBinary, Module.arguments && Module.arguments, Module.thisProgram && (t = Module.thisProgram), Module.preInit) for ("function" == typeof Module.preInit && (Module.preInit = [Module.preInit]); Module.preInit.length > 0; ) Module.preInit.shift()();
2281
2281
  Module.ccall = JA, Module.cwrap = (A2, v2, r2, j2) => {
2282
2282
  var b2 = !r2 || r2.every((A3) => "number" === A3 || "boolean" === A3);
2283
2283
  return "string" !== v2 && b2 && !j2 ? GA(A2) : (...b3) => JA(A2, v2, r2, b3, j2);
@@ -2302,7 +2302,7 @@ async function createMoviModule(A = {}) {
2302
2302
  }
2303
2303
  return $.set(A2, j2), j2;
2304
2304
  }, Module.UTF8ToString = w, Module.lengthBytesUTF8 = Q, Module.stringToNewUTF8 = (A2) => {
2305
- var v2 = Q(A2) + 1, r2 = c(v2);
2305
+ var v2 = Q(A2) + 1, r2 = H(v2);
2306
2306
  return r2 && kA(A2, r2, v2), r2;
2307
2307
  }, Module.FS = FS;
2308
2308
  var DA, OA = { b: function(A2, v2, r2, j2) {
@@ -2360,20 +2360,20 @@ async function createMoviModule(A = {}) {
2360
2360
  var j2 = nA.getStreamFromFD(A2);
2361
2361
  j2.getdents ||= FS.readdir(j2.path);
2362
2362
  for (var b2 = 280, t2 = 0, E2 = FS.llseek(j2, 0, 1), f2 = Math.floor(E2 / b2), n2 = Math.min(j2.getdents.length, f2 + Math.floor(r2 / b2)), F2 = f2; F2 < n2; F2++) {
2363
- var l2, k2, u2 = j2.getdents[F2];
2364
- if ("." === u2) l2 = j2.node.id, k2 = 4;
2365
- else if (".." === u2) l2 = FS.lookupPath(j2.path, { parent: true }).node.id, k2 = 4;
2363
+ var l2, k2, a2 = j2.getdents[F2];
2364
+ if ("." === a2) l2 = j2.node.id, k2 = 4;
2365
+ else if (".." === a2) l2 = FS.lookupPath(j2.path, { parent: true }).node.id, k2 = 4;
2366
2366
  else {
2367
- var a2;
2367
+ var u2;
2368
2368
  try {
2369
- a2 = FS.lookupNode(j2.node, u2);
2369
+ u2 = FS.lookupNode(j2.node, a2);
2370
2370
  } catch (A3) {
2371
2371
  if (28 === A3?.errno) continue;
2372
2372
  throw A3;
2373
2373
  }
2374
- l2 = a2.id, k2 = FS.isChrdev(a2.mode) ? 2 : FS.isDir(a2.mode) ? 4 : FS.isLink(a2.mode) ? 10 : 8;
2374
+ l2 = u2.id, k2 = FS.isChrdev(u2.mode) ? 2 : FS.isDir(u2.mode) ? 4 : FS.isLink(u2.mode) ? 10 : 8;
2375
2375
  }
2376
- s[v2 + t2 >>> 3 >>> 0] = BigInt(l2), s[v2 + t2 + 8 >>> 3 >>> 0] = BigInt((F2 + 1) * b2), e[v2 + t2 + 16 >>> 1 >>> 0] = 280, i[v2 + t2 + 18 >>> 0] = k2, kA(u2, v2 + t2 + 19, 256), t2 += b2;
2376
+ i[v2 + t2 >>> 3 >>> 0] = BigInt(l2), i[v2 + t2 + 8 >>> 3 >>> 0] = BigInt((F2 + 1) * b2), e[v2 + t2 + 16 >>> 1 >>> 0] = 280, s[v2 + t2 + 18 >>> 0] = k2, kA(a2, v2 + t2 + 19, 256), t2 += b2;
2377
2377
  }
2378
2378
  return FS.llseek(j2, F2 * b2, 0), t2;
2379
2379
  } catch (A3) {
@@ -2397,7 +2397,7 @@ async function createMoviModule(A = {}) {
2397
2397
  if (j2.tty.ops.ioctl_tcgets) {
2398
2398
  var b2 = j2.tty.ops.ioctl_tcgets(j2), t2 = lA();
2399
2399
  HEAP32[t2 >>> 2 >>> 0] = b2.c_iflag || 0, HEAP32[t2 + 4 >>> 2 >>> 0] = b2.c_oflag || 0, HEAP32[t2 + 8 >>> 2 >>> 0] = b2.c_cflag || 0, HEAP32[t2 + 12 >>> 2 >>> 0] = b2.c_lflag || 0;
2400
- for (var E2 = 0; E2 < 32; E2++) i[t2 + E2 + 17 >>> 0] = b2.c_cc[E2] || 0;
2400
+ for (var E2 = 0; E2 < 32; E2++) s[t2 + E2 + 17 >>> 0] = b2.c_cc[E2] || 0;
2401
2401
  return 0;
2402
2402
  }
2403
2403
  return 0;
@@ -2408,7 +2408,7 @@ async function createMoviModule(A = {}) {
2408
2408
  if (j2.tty.ops.ioctl_tcsets) {
2409
2409
  t2 = lA();
2410
2410
  var f2 = HEAP32[t2 >>> 2 >>> 0], n2 = HEAP32[t2 + 4 >>> 2 >>> 0], F2 = HEAP32[t2 + 8 >>> 2 >>> 0], l2 = HEAP32[t2 + 12 >>> 2 >>> 0], k2 = [];
2411
- for (E2 = 0; E2 < 32; E2++) k2.push(i[t2 + E2 + 17 >>> 0]);
2411
+ for (E2 = 0; E2 < 32; E2++) k2.push(s[t2 + E2 + 17 >>> 0]);
2412
2412
  return j2.tty.ops.ioctl_tcsets(j2.tty, v2, { c_iflag: f2, c_oflag: n2, c_cflag: F2, c_lflag: l2, c_cc: k2 });
2413
2413
  }
2414
2414
  return 0;
@@ -2422,8 +2422,8 @@ async function createMoviModule(A = {}) {
2422
2422
  case 21523:
2423
2423
  if (!j2.tty) return -59;
2424
2424
  if (j2.tty.ops.ioctl_tiocgwinsz) {
2425
- var s2 = j2.tty.ops.ioctl_tiocgwinsz(j2.tty);
2426
- t2 = lA(), e[t2 >>> 1 >>> 0] = s2[0], e[t2 + 2 >>> 1 >>> 0] = s2[1];
2425
+ var i2 = j2.tty.ops.ioctl_tiocgwinsz(j2.tty);
2426
+ t2 = lA(), e[t2 >>> 1 >>> 0] = i2[0], e[t2 + 2 >>> 1 >>> 0] = i2[1];
2427
2427
  }
2428
2428
  return 0;
2429
2429
  default:
@@ -2498,7 +2498,7 @@ async function createMoviModule(A = {}) {
2498
2498
  return -A3.errno;
2499
2499
  }
2500
2500
  }, i: () => d(""), s: () => {
2501
- T = false, eA = 0;
2501
+ K = false, eA = 0;
2502
2502
  }, u: function(A2, v2) {
2503
2503
  A2 = C(A2), v2 >>>= 0;
2504
2504
  var r2 = new Date(1e3 * A2);
@@ -2506,15 +2506,15 @@ async function createMoviModule(A = {}) {
2506
2506
  var j2 = Date.UTC(r2.getUTCFullYear(), 0, 1, 0, 0, 0, 0), b2 = (r2.getTime() - j2) / 864e5 | 0;
2507
2507
  HEAP32[v2 + 28 >>> 2 >>> 0] = b2;
2508
2508
  }, k: (A2, v2) => {
2509
- if (sA[A2] && (clearTimeout(sA[A2].id), delete sA[A2]), !v2) return 0;
2509
+ if (iA[A2] && (clearTimeout(iA[A2].id), delete iA[A2]), !v2) return 0;
2510
2510
  var r2 = setTimeout(() => {
2511
- delete sA[A2], oA(() => p(A2, xA()));
2511
+ delete iA[A2], oA(() => p(A2, xA()));
2512
2512
  }, v2);
2513
- return sA[A2] = { id: r2, timeout_ms: v2 }, 0;
2513
+ return iA[A2] = { id: r2, timeout_ms: v2 }, 0;
2514
2514
  }, v: function(A2, v2, r2, j2) {
2515
2515
  A2 >>>= 0, v2 >>>= 0, r2 >>>= 0, j2 >>>= 0;
2516
2516
  var b2 = (/* @__PURE__ */ new Date()).getFullYear(), t2 = new Date(b2, 0, 1), E2 = new Date(b2, 6, 1), f2 = t2.getTimezoneOffset(), n2 = E2.getTimezoneOffset(), F2 = Math.max(f2, n2);
2517
- u[A2 >>> 2 >>> 0] = 60 * F2, HEAP32[v2 >>> 2 >>> 0] = Number(f2 != n2);
2517
+ a[A2 >>> 2 >>> 0] = 60 * F2, HEAP32[v2 >>> 2 >>> 0] = Number(f2 != n2);
2518
2518
  var l2 = (A3) => {
2519
2519
  var v3 = A3 >= 0 ? "-" : "+", r3 = Math.abs(A3);
2520
2520
  return `UTC${v3}${String(Math.floor(r3 / 60)).padStart(2, "0")}${String(r3 % 60).padStart(2, "0")}`;
@@ -2525,7 +2525,7 @@ async function createMoviModule(A = {}) {
2525
2525
  var j2, b2;
2526
2526
  b2 = 0 === A2 ? qA() : xA();
2527
2527
  var t2 = Math.round(1e3 * b2 * 1e3);
2528
- return s[r2 >>> 3 >>> 0] = BigInt(t2), 0;
2528
+ return i[r2 >>> 3 >>> 0] = BigInt(t2), 0;
2529
2529
  }, E: qA, e: xA, m: function(A2) {
2530
2530
  A2 >>>= 0;
2531
2531
  var v2 = HEAPU8.length, r2 = 4294901760;
@@ -2540,18 +2540,18 @@ async function createMoviModule(A = {}) {
2540
2540
  }, y: function(A2, v2) {
2541
2541
  A2 >>>= 0, v2 >>>= 0;
2542
2542
  var r2 = 0, j2 = 0;
2543
- for (var b2 of HA()) {
2543
+ for (var b2 of cA()) {
2544
2544
  var t2 = v2 + r2;
2545
- u[A2 + j2 >>> 2 >>> 0] = t2, r2 += kA(b2, t2, 1 / 0) + 1, j2 += 4;
2545
+ a[A2 + j2 >>> 2 >>> 0] = t2, r2 += kA(b2, t2, 1 / 0) + 1, j2 += 4;
2546
2546
  }
2547
2547
  return 0;
2548
2548
  }, z: function(A2, v2) {
2549
2549
  A2 >>>= 0, v2 >>>= 0;
2550
- var r2 = HA();
2551
- u[A2 >>> 2 >>> 0] = r2.length;
2550
+ var r2 = cA();
2551
+ a[A2 >>> 2 >>> 0] = r2.length;
2552
2552
  var j2 = 0;
2553
2553
  for (var b2 of r2) j2 += Q(b2) + 1;
2554
- return u[v2 >>> 2 >>> 0] = j2, 0;
2554
+ return a[v2 >>> 2 >>> 0] = j2, 0;
2555
2555
  }, c: function(A2) {
2556
2556
  try {
2557
2557
  var v2 = nA.getStreamFromFD(A2);
@@ -2564,7 +2564,7 @@ async function createMoviModule(A = {}) {
2564
2564
  v2 >>>= 0;
2565
2565
  try {
2566
2566
  var r2 = nA.getStreamFromFD(A2), j2 = r2.tty ? 2 : FS.isDir(r2.mode) ? 3 : FS.isLink(r2.mode) ? 7 : 4;
2567
- return i[v2 >>> 0] = j2, e[v2 + 2 >>> 1 >>> 0] = 0, s[v2 + 8 >>> 3 >>> 0] = BigInt(0), s[v2 + 16 >>> 3 >>> 0] = BigInt(0), 0;
2567
+ return s[v2 >>> 0] = j2, e[v2 + 2 >>> 1 >>> 0] = 0, i[v2 + 8 >>> 3 >>> 0] = BigInt(0), i[v2 + 16 >>> 3 >>> 0] = BigInt(0), 0;
2568
2568
  } catch (A3) {
2569
2569
  if (void 0 === FS || "ErrnoError" !== A3.name) throw A3;
2570
2570
  return A3.errno;
@@ -2574,15 +2574,15 @@ async function createMoviModule(A = {}) {
2574
2574
  try {
2575
2575
  var b2 = ((A3, v3, r3) => {
2576
2576
  for (var j3 = 0, b3 = 0; b3 < r3; b3++) {
2577
- var t2 = u[v3 >>> 2 >>> 0], E2 = u[v3 + 4 >>> 2 >>> 0];
2577
+ var t2 = a[v3 >>> 2 >>> 0], E2 = a[v3 + 4 >>> 2 >>> 0];
2578
2578
  v3 += 8;
2579
- var f2 = FS.read(A3, i, t2, E2, void 0);
2579
+ var f2 = FS.read(A3, s, t2, E2, void 0);
2580
2580
  if (f2 < 0) return -1;
2581
2581
  if (j3 += f2, f2 < E2) break;
2582
2582
  }
2583
2583
  return j3;
2584
2584
  })(nA.getStreamFromFD(A2), v2, r2);
2585
- return u[j2 >>> 2 >>> 0] = b2, 0;
2585
+ return a[j2 >>> 2 >>> 0] = b2, 0;
2586
2586
  } catch (A3) {
2587
2587
  if (void 0 === FS || "ErrnoError" !== A3.name) throw A3;
2588
2588
  return A3.errno;
@@ -2592,7 +2592,7 @@ async function createMoviModule(A = {}) {
2592
2592
  try {
2593
2593
  if (isNaN(v2)) return 22;
2594
2594
  var b2 = nA.getStreamFromFD(A2);
2595
- return FS.llseek(b2, v2, r2), s[j2 >>> 3 >>> 0] = BigInt(b2.position), b2.getdents && 0 === v2 && 0 === r2 && (b2.getdents = null), 0;
2595
+ return FS.llseek(b2, v2, r2), i[j2 >>> 3 >>> 0] = BigInt(b2.position), b2.getdents && 0 === v2 && 0 === r2 && (b2.getdents = null), 0;
2596
2596
  } catch (A3) {
2597
2597
  if (void 0 === FS || "ErrnoError" !== A3.name) throw A3;
2598
2598
  return A3.errno;
@@ -2602,15 +2602,15 @@ async function createMoviModule(A = {}) {
2602
2602
  try {
2603
2603
  var b2 = ((A3, v3, r3) => {
2604
2604
  for (var j3 = 0, b3 = 0; b3 < r3; b3++) {
2605
- var t2 = u[v3 >>> 2 >>> 0], E2 = u[v3 + 4 >>> 2 >>> 0];
2605
+ var t2 = a[v3 >>> 2 >>> 0], E2 = a[v3 + 4 >>> 2 >>> 0];
2606
2606
  v3 += 8;
2607
- var f2 = FS.write(A3, i, t2, E2, void 0);
2607
+ var f2 = FS.write(A3, s, t2, E2, void 0);
2608
2608
  if (f2 < 0) return -1;
2609
2609
  if (j3 += f2, f2 < E2) break;
2610
2610
  }
2611
2611
  return j3;
2612
2612
  })(nA.getStreamFromFD(A2), v2, r2);
2613
- return u[j2 >>> 2 >>> 0] = b2, 0;
2613
+ return a[j2 >>> 2 >>> 0] = b2, 0;
2614
2614
  } catch (A3) {
2615
2615
  if (void 0 === FS || "ErrnoError" !== A3.name) throw A3;
2616
2616
  return A3.errno;
@@ -2626,13 +2626,13 @@ async function createMoviModule(A = {}) {
2626
2626
  });
2627
2627
  }, a: function(A2, v2) {
2628
2628
  globalThis.__movilog?.log("[library_movi] Thumbnail packet ready:", A2, v2), Module._pendingThumbnail && (Module._pendingThumbnail.resolve({ size: A2, pts: v2 }), Module._pendingThumbnail = null);
2629
- }, r: aA, l: function(A2, v2) {
2629
+ }, r: uA, l: function(A2, v2) {
2630
2630
  return A2 >>>= 0, v2 >>>= 0, X(HEAPU8.subarray(A2 >>> 0, A2 + v2 >>> 0));
2631
2631
  } };
2632
2632
  return DA = await async function() {
2633
2633
  function A2(A3, v3) {
2634
2634
  return DA = A3.exports, function(A4) {
2635
- Module._movi_create = A4.J, H = Module._free = A4.K, Module._movi_set_file_size = A4.L, Module._movi_destroy = A4.M, Module._movi_open = A4.N, Module._movi_set_log_level = A4.O, Module._movi_enable_audio_downmix = A4.P, Module._movi_get_format_name = A4.Q, Module._movi_get_metadata_title = A4.R, Module._movi_enable_decoder = A4.S, Module._movi_send_packet = A4.T, Module._movi_set_skip_frame = A4.U, Module._movi_receive_frame = A4.V, Module._movi_get_frame_rgba = A4.W, Module._movi_get_frame_rgba_size = A4.X, Module._movi_get_frame_rgba_linesize = A4.Y, Module._movi_decode_subtitle = A4.Z, Module._movi_get_subtitle_text = A4._, Module._movi_get_subtitle_times = A4.$, Module._movi_get_subtitle_image_info = A4.aa, Module._movi_get_subtitle_image_data = A4.ba, Module._movi_free_subtitle = A4.ca, Module._movi_get_frame_pts = A4.da, Module._movi_flush_decoder = A4.ea, Module._movi_clear_prefetched_cues = A4.fa, Module._movi_prefetch_subtitle_cues = A4.ga, c = Module._malloc = A4.ha, Module._movi_get_prefetched_cue_count = A4.ia, Module._movi_get_prefetched_cue = A4.ja, Module._movi_get_frame_width = A4.ka, Module._movi_get_frame_height = A4.la, Module._movi_get_frame_format = A4.ma, Module._movi_get_frame_data = A4.na, Module._movi_get_frame_linesize = A4.oa, Module._movi_get_frame_samples = A4.pa, Module._movi_get_frame_channels = A4.qa, Module._movi_get_frame_sample_rate = A4.ra, Module._movi_get_duration = A4.sa, Module._movi_get_start_time = A4.ta, Module._movi_get_stream_count = A4.ua, Module._movi_get_stream_info = A4.va, Module._movi_get_extradata = A4.wa, Module._movi_seek_to = A4.xa, Module._movi_read_frame = A4.ya, Module._movi_get_chapter_count = A4.za, Module._movi_get_chapter_start = A4.Aa, Module._movi_get_chapter_end = A4.Ba, Module._movi_get_chapter_title = A4.Ca, Module._movi_stretch_new = A4.Da, Module._movi_stretch_delete = A4.Ea, Module._movi_stretch_reset = A4.Fa, Module._movi_stretch_set_transpose_semitones = A4.Ga, Module._movi_stretch_input_latency = A4.Ha, Module._movi_stretch_output_latency = A4.Ia, Module._movi_stretch_process = A4.Ja, Module._movi_thumbnail_create = A4.Ka, Module._movi_thumbnail_open = A4.La, Module._movi_thumbnail_read_keyframe = A4.Ma, Module._movi_thumbnail_get_packet_data = A4.Na, Module._movi_thumbnail_get_stream_info = A4.Oa, Module._movi_thumbnail_get_extradata = A4.Pa, Module._movi_thumbnail_decode_frame_yuv = A4.Qa, Module._movi_thumbnail_get_plane_data = A4.Ra, Module._movi_thumbnail_get_plane_linesize = A4.Sa, Module._movi_thumbnail_get_frame_width = A4.Ta, Module._movi_thumbnail_get_frame_height = A4.Ua, Module._movi_thumbnail_decode_frame = A4.Va, Module._movi_thumbnail_clear_buffer = A4.Wa, Module._movi_thumbnail_destroy = A4.Xa, p = A4._a, G = A4.$a, m = A4.ab, _ = A4.bb, A4.cb, A4.db, A4.eb, A4.fb, A4.gb, A4.hb, A4.ib, A4.jb, A4.kb, A4.lb, A4.mb, A4.nb, A4.ob, A4.pb, A4.qb, A4.rb, A4.sb, A4.tb, A4.ub, A4.vb, A4.wb, A4.xb, A4.yb, A4.zb, A4.Ab, A4.Bb, A4.Cb, A4.Db, A4.Eb, A4.Fb, A4.Gb, A4.Hb, A4.Ib, A4.Jb, A4.Kb, A4.Lb, A4.Mb, A4.Nb, A4.Ob, A4.Pb, A4.Qb, A4.Rb, A4.Sb, A4.Tb, A4.Ub, A4.Vb, A4.Wb, A4.Xb, A4.Yb, A4.Zb, A4._b, A4.$b, A4.ac, J = A4.bc, h = A4.cc, g = A4.dc, N = A4.ec, I = A4.H, Module._ff_h264_cabac_tables = A4.Ya.value >>> 0, L = A4.Za;
2635
+ Module._movi_create = A4.J, c = Module._free = A4.K, Module._movi_set_file_size = A4.L, Module._movi_destroy = A4.M, Module._movi_open = A4.N, Module._movi_set_log_level = A4.O, Module._movi_enable_audio_downmix = A4.P, Module._movi_get_format_name = A4.Q, Module._movi_get_metadata_title = A4.R, Module._movi_enable_decoder = A4.S, Module._movi_send_packet = A4.T, Module._movi_set_skip_frame = A4.U, Module._movi_receive_frame = A4.V, Module._movi_get_frame_rgba = A4.W, Module._movi_get_frame_rgba_size = A4.X, Module._movi_get_frame_rgba_linesize = A4.Y, Module._movi_decode_subtitle = A4.Z, Module._movi_get_subtitle_text = A4._, Module._movi_get_subtitle_times = A4.$, Module._movi_get_subtitle_image_info = A4.aa, Module._movi_get_subtitle_image_data = A4.ba, Module._movi_free_subtitle = A4.ca, Module._movi_get_frame_pts = A4.da, Module._movi_flush_decoder = A4.ea, Module._movi_clear_prefetched_cues = A4.fa, Module._movi_prefetch_subtitle_cues = A4.ga, H = Module._malloc = A4.ha, Module._movi_get_prefetched_cue_count = A4.ia, Module._movi_get_prefetched_cue = A4.ja, Module._movi_get_frame_width = A4.ka, Module._movi_get_frame_height = A4.la, Module._movi_get_frame_format = A4.ma, Module._movi_get_frame_data = A4.na, Module._movi_get_frame_linesize = A4.oa, Module._movi_get_frame_samples = A4.pa, Module._movi_get_frame_channels = A4.qa, Module._movi_get_frame_sample_rate = A4.ra, Module._movi_get_duration = A4.sa, Module._movi_get_start_time = A4.ta, Module._movi_get_stream_count = A4.ua, Module._movi_get_stream_info = A4.va, Module._movi_get_extradata = A4.wa, Module._movi_seek_to = A4.xa, Module._movi_read_frame = A4.ya, Module._movi_get_chapter_count = A4.za, Module._movi_get_chapter_start = A4.Aa, Module._movi_get_chapter_end = A4.Ba, Module._movi_get_chapter_title = A4.Ca, Module._movi_stretch_new = A4.Da, Module._movi_stretch_delete = A4.Ea, Module._movi_stretch_reset = A4.Fa, Module._movi_stretch_set_transpose_semitones = A4.Ga, Module._movi_stretch_input_latency = A4.Ha, Module._movi_stretch_output_latency = A4.Ia, Module._movi_stretch_process = A4.Ja, Module._movi_thumbnail_create = A4.Ka, Module._movi_thumbnail_open = A4.La, Module._movi_thumbnail_read_keyframe = A4.Ma, Module._movi_thumbnail_get_packet_data = A4.Na, Module._movi_thumbnail_get_stream_info = A4.Oa, Module._movi_thumbnail_get_extradata = A4.Pa, Module._movi_thumbnail_decode_frame_yuv = A4.Qa, Module._movi_thumbnail_get_plane_data = A4.Ra, Module._movi_thumbnail_get_plane_linesize = A4.Sa, Module._movi_thumbnail_get_frame_width = A4.Ta, Module._movi_thumbnail_get_frame_height = A4.Ua, Module._movi_thumbnail_decode_frame = A4.Va, Module._movi_thumbnail_clear_buffer = A4.Wa, Module._movi_thumbnail_destroy = A4.Xa, p = A4._a, G = A4.$a, m = A4.ab, _ = A4.bb, A4.cb, A4.db, A4.eb, A4.fb, A4.gb, A4.hb, A4.ib, A4.jb, A4.kb, A4.lb, A4.mb, A4.nb, A4.ob, A4.pb, A4.qb, A4.rb, A4.sb, A4.tb, A4.ub, A4.vb, A4.wb, A4.xb, A4.yb, A4.zb, A4.Ab, A4.Bb, A4.Cb, A4.Db, A4.Eb, A4.Fb, A4.Gb, A4.Hb, A4.Ib, A4.Jb, A4.Kb, A4.Lb, A4.Mb, A4.Nb, A4.Ob, A4.Pb, A4.Qb, A4.Rb, A4.Sb, A4.Tb, A4.Ub, A4.Vb, A4.Wb, A4.Xb, A4.Yb, A4.Zb, A4._b, A4.$b, A4.ac, J = A4.bc, h = A4.cc, g = A4.dc, N = A4.ec, I = A4.H, Module._ff_h264_cabac_tables = A4.Ya.value >>> 0, L = A4.Za;
2636
2636
  }(DA = function(A4) {
2637
2637
  var v4, r2 = (A5) => (v5) => A5(v5) >>> 0;
2638
2638
  return (A4 = Object.assign({}, A4)).ha = r2(A4.ha), A4.ab = r2(A4.ab), A4.bb = (v4 = A4.bb, () => v4() >>> 0), A4;
@@ -48852,7 +48852,7 @@ RR\vR\bR\x07R;\fR\rRR RSQR@#RRRRRRRRRR\x1BRRR(.RJ!LRR R!R"R
48852
48852
  }());
48853
48853
  }
48854
48854
  bA > 0 ? tA = A2 : (function() {
48855
- if (Module.preRun) for ("function" == typeof Module.preRun && (Module.preRun = [Module.preRun]); Module.preRun.length; ) K(Module.preRun.shift());
48855
+ if (Module.preRun) for ("function" == typeof Module.preRun && (Module.preRun = [Module.preRun]); Module.preRun.length; ) T(Module.preRun.shift());
48856
48856
  P(y);
48857
48857
  }(), bA > 0 ? tA = A2 : Module.setStatus ? (Module.setStatus("Running..."), setTimeout(() => {
48858
48858
  setTimeout(() => Module.setStatus(""), 1), v2();
@@ -48919,6 +48919,11 @@ class HttpSource {
48919
48919
  streamError = null;
48920
48920
  maxBufferedEnd = 0;
48921
48921
  fullyBuffered = false;
48922
+ rangeUnsupported = false;
48923
+ linearMode = false;
48924
+ onLinearMode = null;
48925
+ readMax = 0;
48926
+ recentReads = [];
48922
48927
  consecutiveForceRestarts = 0;
48923
48928
  lastForceRestartTime = 0;
48924
48929
  MAX_FORCE_RESTARTS = 3;
@@ -48941,6 +48946,15 @@ class HttpSource {
48941
48946
  this.resizeBuffer(r);
48942
48947
  }
48943
48948
  }
48949
+ setOnLinearMode(A) {
48950
+ this.onLinearMode = A, this.linearMode && A();
48951
+ }
48952
+ isLinearMode() {
48953
+ return this.linearMode;
48954
+ }
48955
+ isRangeUnsupported() {
48956
+ return this.rangeUnsupported;
48957
+ }
48944
48958
  resizeBuffer(A) {
48945
48959
  const v = 1024 * this.maxBufferSizeMB * 1024, r = Math.max(2097152, Math.min(v, A));
48946
48960
  if (this.bufferSize !== r || !this.sharedBuffer && !this.fallbackBuffer) {
@@ -48983,34 +48997,85 @@ class HttpSource {
48983
48997
  this.useSharedBuffer && this.headerView && Atomics.store(this.headerView, 3, 0);
48984
48998
  }
48985
48999
  async resolveSize() {
48986
- const A = await fetch(this.url, { method: "HEAD", headers: await this.buildRequestHeaders() });
48987
- if (!A.ok) {
48988
- if (403 === A.status) throw new Error("Access denied. Check video permissions.");
48989
- if (401 === A.status) throw new Error("Authentication required.");
48990
- if (404 === A.status) throw new Error("Video not found.");
48991
- throw new Error(`HTTP ${A.status}`);
49000
+ let A = new Error("Content-Length missing");
49001
+ for (let v = 0; v < 4; v++) {
49002
+ try {
49003
+ const v2 = await fetch(this.url, { method: "HEAD", headers: await this.buildRequestHeaders() });
49004
+ if (v2.ok) {
49005
+ this.setFilenameFromDisposition(v2.headers.get("Content-Disposition"));
49006
+ const r = v2.headers.get("Content-Length");
49007
+ if (r) return parseInt(r, 10);
49008
+ const j = await this.resolveSizeViaRange();
49009
+ if (null !== j) return j;
49010
+ const b = await this.resolveSizeViaPlainGet();
49011
+ if (null !== b) return b;
49012
+ A = new Error("Content-Length missing");
49013
+ } else {
49014
+ if (403 === v2.status) throw new Error("Access denied. Check video permissions.");
49015
+ if (401 === v2.status) throw new Error("Authentication required.");
49016
+ if (404 === v2.status) throw new Error("Video not found.");
49017
+ A = new Error(`HTTP ${v2.status}`);
49018
+ }
49019
+ } catch (v2) {
49020
+ if (/Access denied|Authentication required|Video not found/.test(v2?.message || "")) throw v2;
49021
+ A = v2 instanceof Error ? v2 : new Error(String(v2));
49022
+ }
49023
+ v < 3 && await new Promise((A2) => setTimeout(A2, 400 * (v + 1)));
49024
+ }
49025
+ throw A;
49026
+ }
49027
+ async resolveSizeViaRange() {
49028
+ let A;
49029
+ try {
49030
+ A = await fetch(this.url, { method: "GET", headers: await this.buildRequestHeaders({ offset: 0, length: 1 }) });
49031
+ } catch {
49032
+ return null;
49033
+ }
49034
+ if (A.body?.cancel().catch(() => {
49035
+ }), !A.ok && 206 !== A.status) return null;
49036
+ const v = A.headers.get("Content-Range");
49037
+ if (v) {
49038
+ const A2 = /\/\s*(\d+)\s*$/.exec(v);
49039
+ if (A2) return parseInt(A2[1], 10);
49040
+ }
49041
+ const r = A.headers.get("Content-Length");
49042
+ return 200 === A.status && r ? parseInt(r, 10) : null;
49043
+ }
49044
+ async resolveSizeViaPlainGet() {
49045
+ let A;
49046
+ try {
49047
+ A = await fetch(this.url, { method: "GET", headers: await this.buildRequestHeaders() });
49048
+ } catch {
49049
+ return null;
48992
49050
  }
49051
+ if (A.body?.cancel().catch(() => {
49052
+ }), !A.ok) return null;
48993
49053
  const v = A.headers.get("Content-Length");
48994
- if (!v) throw new Error("Content-Length missing");
48995
- const r = A.headers.get("Content-Disposition");
49054
+ if (200 === A.status && v) return parseInt(v, 10);
49055
+ const r = A.headers.get("Content-Range");
48996
49056
  if (r) {
48997
- let A2 = r.match(/filename\*\s*=\s*(?:UTF-8''|utf-8'')([^;]+)/i);
48998
- if (A2) try {
48999
- this._contentDispositionFilename = decodeURIComponent(A2[1].trim());
49057
+ const A2 = /\/\s*(\d+)\s*$/.exec(r);
49058
+ if (A2) return parseInt(A2[1], 10);
49059
+ }
49060
+ return null;
49061
+ }
49062
+ setFilenameFromDisposition(A) {
49063
+ if (!A) return;
49064
+ let v = A.match(/filename\*\s*=\s*(?:UTF-8''|utf-8'')([^;]+)/i);
49065
+ if (v) try {
49066
+ this._contentDispositionFilename = decodeURIComponent(v[1].trim());
49067
+ } catch {
49068
+ this._contentDispositionFilename = v[1].trim();
49069
+ }
49070
+ if (!this._contentDispositionFilename && (v = A.match(/filename\s*=\s*"([^"]+)"/i), v || (v = A.match(/filename\s*=\s*([^;]+)/i)), v)) {
49071
+ const A2 = v[1].trim();
49072
+ try {
49073
+ this._contentDispositionFilename = decodeURIComponent(A2);
49000
49074
  } catch {
49001
- this._contentDispositionFilename = A2[1].trim();
49002
- }
49003
- if (!this._contentDispositionFilename && (A2 = r.match(/filename\s*=\s*"([^"]+)"/i), A2 || (A2 = r.match(/filename\s*=\s*([^;]+)/i)), A2)) {
49004
- const v2 = A2[1].trim();
49005
- try {
49006
- this._contentDispositionFilename = decodeURIComponent(v2);
49007
- } catch {
49008
- this._contentDispositionFilename = v2;
49009
- }
49075
+ this._contentDispositionFilename = A2;
49010
49076
  }
49011
- this._contentDispositionFilename && Logger.debug(TAG$7, `Content-Disposition filename: ${this._contentDispositionFilename}`);
49012
49077
  }
49013
- return parseInt(v, 10);
49078
+ this._contentDispositionFilename && Logger.debug(TAG$7, `Content-Disposition filename: ${this._contentDispositionFilename}`);
49014
49079
  }
49015
49080
  async buildRequestHeaders(A) {
49016
49081
  return A ? { ...this.headers, Range: `bytes=${A.offset}-${A.offset + A.length - 1}` } : { ...this.headers };
@@ -49095,16 +49160,21 @@ class HttpSource {
49095
49160
  Logger.debug(TAG$7, `Fetching range: ${f}-${F} (max ${(n / 1024 / 1024).toFixed(1)}MB)`);
49096
49161
  const l = await fetch(this.url, { headers: await this.buildRequestHeaders({ offset: f, length: F - f + 1 }), cache: "no-store", signal: this.abortController.signal });
49097
49162
  if (200 === l.status) {
49163
+ if (j++, j <= 3) {
49164
+ try {
49165
+ l.body?.cancel();
49166
+ } catch {
49167
+ }
49168
+ Logger.warn(TAG$7, `Server returned 200 instead of 206 (attempt ${j}/3). CDN may be caching — retrying in 1500ms...`), await new Promise((A2) => setTimeout(A2, 1500));
49169
+ continue;
49170
+ }
49171
+ if (0 === A) return Logger.warn(TAG$7, "No Range support after 3 retries — falling back to sequential playback."), void await this.consumeNonRangeStream(l);
49098
49172
  try {
49099
49173
  l.body?.cancel();
49100
49174
  } catch {
49101
49175
  }
49102
- if (j++, j <= 3) {
49103
- Logger.warn(TAG$7, `Server returned 200 instead of 206 (attempt ${j}/3). CDN may be caching — retrying in 1500ms...`), await new Promise((A3) => setTimeout(A3, 1500));
49104
- continue;
49105
- }
49106
- const A2 = new Error("Server does not support range requests.");
49107
- throw Logger.error(TAG$7, "Server returned 200 after 3 retries. Range requests not supported."), this.abortController?.abort(), this.atomicSetStreaming(false), this.streamError = A2, A2;
49176
+ const v2 = new Error("Server does not support range requests.");
49177
+ throw Logger.error(TAG$7, `Server returned 200 for offset ${A}; range requests not supported.`), this.abortController?.abort(), this.atomicSetStreaming(false), this.streamError = v2, v2;
49108
49178
  }
49109
49179
  if (j = 0, !l.ok && 206 !== l.status) {
49110
49180
  if (l.status >= 400 && l.status < 500) {
@@ -49118,8 +49188,8 @@ class HttpSource {
49118
49188
  }
49119
49189
  this.reader = l.body.getReader(), v = 0, b = 0, r || (this.atomicSetBufferStart(A), this.atomicSetWritePos(0), r = true);
49120
49190
  let k = 0, e = 0;
49121
- const s = Date.now();
49122
- for (0 === this.streamStartTime && (this.streamStartTime = s, this.lastSpeedTime = s); this.atomicIsStreaming(); ) {
49191
+ const i = Date.now();
49192
+ for (0 === this.streamStartTime && (this.streamStartTime = i, this.lastSpeedTime = i); this.atomicIsStreaming(); ) {
49123
49193
  const { done: A2, value: v2 } = await this.reader.read();
49124
49194
  if (A2) {
49125
49195
  this.atomicSetStreaming(false);
@@ -49133,7 +49203,7 @@ class HttpSource {
49133
49203
  this.currentSpeed = v3 / r2, this.lastSpeedBytes = this.totalBytesDownloaded, this.lastSpeedTime = A3;
49134
49204
  }
49135
49205
  if (k - e > 1048576) {
49136
- const A4 = (Date.now() - s) / 1e3, v3 = A4 > 0 ? k / 1024 / 1024 / A4 : 0;
49206
+ const A4 = (Date.now() - i) / 1e3, v3 = A4 > 0 ? k / 1024 / 1024 / A4 : 0;
49137
49207
  Logger.debug(TAG$7, `Stream progress: ${(k / 1024 / 1024).toFixed(2)} MB read @ ${v3.toFixed(2)} MB/s`), e = k;
49138
49208
  }
49139
49209
  let j2 = this.atomicGetWritePos();
@@ -49249,6 +49319,87 @@ class HttpSource {
49249
49319
  this.reader = null;
49250
49320
  }
49251
49321
  }
49322
+ async consumeNonRangeStream(A) {
49323
+ if (this.rangeUnsupported = true, this.size > 0) {
49324
+ const A2 = this.useSharedBuffer && this.headerView ? Atomics.load(this.headerView, 5) : 0;
49325
+ this.resizeBuffer(this.size), this.useSharedBuffer && this.headerView && Atomics.store(this.headerView, 5, A2);
49326
+ }
49327
+ const v = this.getBuffer(), r = this.size > 0 && this.bufferSize >= this.size;
49328
+ if (r) Logger.info(TAG$7, `Caching entire ${(this.size / 1048576).toFixed(1)}MB file in memory (no Range support).`);
49329
+ else {
49330
+ this.linearMode = true, Logger.warn(TAG$7, `Linear (non-seekable) playback: ${this.size > 0 ? (this.size / 1048576).toFixed(0) + "MB" : "unknown size"} exceeds the ${this.maxBufferSizeMB}MB cache cap or size is unknown.`);
49331
+ try {
49332
+ this.onLinearMode?.();
49333
+ } catch {
49334
+ }
49335
+ }
49336
+ if (this.atomicSetBufferStart(0), this.atomicSetWritePos(0), this.maxBufferedEnd = 0, this.fullyBuffered = false, this.atomicSetStreaming(true), !A.body) return this.streamError = new Error("Empty response body"), void this.atomicSetStreaming(false);
49337
+ const j = A.body.getReader();
49338
+ this.reader = j;
49339
+ try {
49340
+ for (; this.atomicIsStreaming(); ) {
49341
+ const { done: A2, value: b2 } = await j.read();
49342
+ if (A2) break;
49343
+ b2 && 0 !== b2.length && (this.totalBytesDownloaded += b2.length, await this.writeSequential(b2, v, r));
49344
+ }
49345
+ } catch (A2) {
49346
+ "AbortError" !== A2?.name && (this.streamError = A2 instanceof Error ? A2 : new Error(String(A2)), Logger.error(TAG$7, "Non-range stream failed", A2));
49347
+ } finally {
49348
+ try {
49349
+ await j.cancel();
49350
+ } catch {
49351
+ }
49352
+ this.reader = null;
49353
+ }
49354
+ const b = this.atomicGetBufferStart() + this.atomicGetWritePos();
49355
+ this.size <= 0 && (this.size = b), r && 0 === this.atomicGetBufferStart() && this.size > 0 && b >= this.size && (this.fullyBuffered = true, Logger.info(TAG$7, `Entire file cached (${(this.size / 1048576).toFixed(1)}MB) — full random access.`)), this.atomicSetStreaming(false);
49356
+ }
49357
+ async writeSequential(A, v, r) {
49358
+ let j = 0;
49359
+ for (; j < A.length; ) {
49360
+ if (!this.atomicIsStreaming()) return;
49361
+ let b = this.atomicGetWritePos();
49362
+ if (b >= v.length) {
49363
+ if (r) return;
49364
+ if (!await this.slideWindow(v)) {
49365
+ await new Promise((A2) => setTimeout(A2, 5));
49366
+ continue;
49367
+ }
49368
+ b = this.atomicGetWritePos();
49369
+ }
49370
+ const t = v.length - b, E = Math.min(t, A.length - j);
49371
+ let f = false;
49372
+ for (let A2 = 0; A2 < 50; A2++) {
49373
+ if (this.tryLock()) {
49374
+ f = true;
49375
+ break;
49376
+ }
49377
+ await new Promise((A3) => setTimeout(A3, 1));
49378
+ }
49379
+ if (!f) {
49380
+ await new Promise((A2) => setTimeout(A2, 5));
49381
+ continue;
49382
+ }
49383
+ v.set(A.subarray(j, j + E), b);
49384
+ const n = b + E;
49385
+ this.atomicSetWritePos(n);
49386
+ const F = this.atomicGetBufferStart() + n;
49387
+ F > this.maxBufferedEnd && (this.maxBufferedEnd = F), this.unlock(), j += E;
49388
+ }
49389
+ }
49390
+ async slideWindow(A) {
49391
+ const v = this.atomicGetBufferStart(), r = this.atomicGetWritePos(), j = Math.floor(this.bufferSize / 2), b = this.recentReads.length ? Math.min(...this.recentReads) : this.readMax, t = Math.max(0, Math.min(b, this.readMax - j)), E = Math.min(t - v, r);
49392
+ if (E <= 0) return false;
49393
+ let f = false;
49394
+ for (let A2 = 0; A2 < 50; A2++) {
49395
+ if (this.tryLock()) {
49396
+ f = true;
49397
+ break;
49398
+ }
49399
+ await new Promise((A3) => setTimeout(A3, 1));
49400
+ }
49401
+ return !!f && (A.copyWithin(0, E, r), this.atomicSetBufferStart(v + E), this.atomicSetWritePos(r - E), this.unlock(), true);
49402
+ }
49252
49403
  async stopStream() {
49253
49404
  if (this.atomicSetStreaming(false), this.abortController && (this.abortController.abort(), this.abortController = null), this.reader) {
49254
49405
  try {
@@ -49297,6 +49448,14 @@ class HttpSource {
49297
49448
  return r2.set(this.headBuffer.subarray(A, A + v)), this.position = A + v, Logger.debug(TAG$7, "Read: served from head cache"), r2.buffer;
49298
49449
  }
49299
49450
  if (this.isInBuffer(A, v)) return this.consecutiveForceRestarts = 0, Logger.debug(TAG$7, "Read: serving from buffer"), this.readFromBuffer(A, v);
49451
+ if (this.rangeUnsupported) {
49452
+ if (A < this.atomicGetBufferStart()) throw new Error("Server does not support range requests.");
49453
+ if (this.linearMode && A + v > this.atomicGetBufferStart() + this.bufferSize) throw new Error("Server does not support range requests.");
49454
+ if (this.atomicIsStreaming() && await this.waitForData(A, v)) return this.readFromBuffer(A, v);
49455
+ if (this.isInBuffer(A, v)) return this.readFromBuffer(A, v);
49456
+ if (this.streamError) throw this.streamError;
49457
+ throw new Error("Server does not support range requests.");
49458
+ }
49300
49459
  const r = this.atomicGetBufferStart(), j = A - this.bufferEnd, b = 2097152, t = this.atomicIsStreaming() && A >= r && A < r + this.bufferSize && j <= b;
49301
49460
  if (Logger.debug(TAG$7, `Read: isCoveredByStream=${t}, gap=${(j / 1024).toFixed(0)}KB`), t) {
49302
49461
  Logger.debug(TAG$7, "Read: waiting for data from active stream...");
@@ -49331,7 +49490,7 @@ class HttpSource {
49331
49490
  }
49332
49491
  readFromBuffer(A, v) {
49333
49492
  const r = this.getBuffer(), j = A - this.atomicGetBufferStart(), b = Math.min(v, this.bufferEnd - A), t = new Uint8Array(b);
49334
- return t.set(r.subarray(j, j + b)), this.position = A + b, t.buffer;
49493
+ return t.set(r.subarray(j, j + b)), this.position = A + b, this.position > this.readMax && (this.readMax = this.position), this.recentReads.push(A), this.recentReads.length > 64 && this.recentReads.shift(), t.buffer;
49335
49494
  }
49336
49495
  seek(A) {
49337
49496
  return this.position = A, this.position;
@@ -49598,6 +49757,7 @@ class ThumbnailHttpSource {
49598
49757
  size = -1;
49599
49758
  position = 0;
49600
49759
  abortController = null;
49760
+ rangeUnsupported = false;
49601
49761
  buffer = null;
49602
49762
  bufferStart = 0;
49603
49763
  bufferEnd = 0;
@@ -49608,13 +49768,38 @@ class ThumbnailHttpSource {
49608
49768
  setBorrowSource(A) {
49609
49769
  this.borrowSource = A;
49610
49770
  }
49771
+ seedSize(A) {
49772
+ A > 0 && (this.size = A);
49773
+ }
49611
49774
  async getSize() {
49612
49775
  if (this.size >= 0) return this.size;
49613
49776
  const A = await fetch(this.url, { method: "HEAD", headers: this.headers });
49614
49777
  if (!A.ok) throw new Error(`HTTP ${A.status}`);
49615
49778
  const v = A.headers.get("Content-Length");
49616
- if (!v) throw new Error("Content-Length missing");
49617
- return this.size = parseInt(v, 10), Logger.debug(TAG$4, `File size: ${this.size} bytes`), this.size;
49779
+ if (v) this.size = parseInt(v, 10);
49780
+ else {
49781
+ const A2 = await this.resolveSizeViaRange();
49782
+ if (null === A2) throw new Error("Content-Length missing");
49783
+ this.size = A2;
49784
+ }
49785
+ return Logger.debug(TAG$4, `File size: ${this.size} bytes`), this.size;
49786
+ }
49787
+ async resolveSizeViaRange() {
49788
+ let A;
49789
+ try {
49790
+ A = await fetch(this.url, { method: "GET", headers: { ...this.headers, Range: "bytes=0-0" } });
49791
+ } catch {
49792
+ return null;
49793
+ }
49794
+ if (A.body?.cancel().catch(() => {
49795
+ }), !A.ok && 206 !== A.status) return null;
49796
+ const v = A.headers.get("Content-Range");
49797
+ if (v) {
49798
+ const A2 = /\/\s*(\d+)\s*$/.exec(v);
49799
+ if (A2) return parseInt(A2[1], 10);
49800
+ }
49801
+ const r = A.headers.get("Content-Length");
49802
+ return 200 === A.status && r ? parseInt(r, 10) : null;
49618
49803
  }
49619
49804
  isInBuffer(A, v) {
49620
49805
  return null !== this.buffer && A >= this.bufferStart && A + v <= this.bufferEnd;
@@ -49631,6 +49816,7 @@ class ThumbnailHttpSource {
49631
49816
  const j2 = this.borrowSource.peekRange(A, v);
49632
49817
  if (j2) return this.position = A + v, Logger.debug(TAG$4, `Read borrowed from main window: offset=${A}, length=${v}`), j2.buffer;
49633
49818
  }
49819
+ if (this.rangeUnsupported) return new ArrayBuffer(0);
49634
49820
  const r = A, j = Math.min(Math.max(2097152, v), 5242880), b = this.size > 0 ? Math.min(r + j - 1, this.size - 1) : r + j - 1;
49635
49821
  Logger.debug(TAG$4, `Fetching: range=${r}-${b} (${((b - r + 1) / 1024).toFixed(1)} KB)`);
49636
49822
  for (let j2 = 0; j2 <= 5; j2++) {
@@ -49643,7 +49829,7 @@ class ThumbnailHttpSource {
49643
49829
  const t = new AbortController(), E = setTimeout(() => t.abort(), 1e4);
49644
49830
  try {
49645
49831
  const j3 = await fetch(this.url, { headers: { ...this.headers, Range: `bytes=${r}-${b}` }, cache: "no-store", signal: t.signal });
49646
- if (clearTimeout(E), 200 === j3.status) throw Logger.error(TAG$4, "Server returned 200 instead of 206. Range requests not supported."), t.abort(), new Error("Server does not support range requests.");
49832
+ if (clearTimeout(E), 200 === j3.status) return Logger.info(TAG$4, "Server returned 200 (no Range support) thumbnails switch to borrow-only."), t.abort(), this.rangeUnsupported = true, new ArrayBuffer(0);
49647
49833
  if (!j3.ok && 206 !== j3.status) {
49648
49834
  if (416 === j3.status) return Logger.warn(TAG$4, `HTTP 416 (Range Not Satisfiable) at ${r}-${b}. Treating as EOF.`), new ArrayBuffer(0);
49649
49835
  throw j3.status >= 500 || 429 === j3.status ? new Error(`HTTP ${j3.status}`) : new Error(`HTTP ${j3.status} (Fatal)`);
@@ -50219,8 +50405,8 @@ exports.CodecParser = CodecParser, exports.Demuxer = class {
50219
50405
  } catch (A2) {
50220
50406
  Logger.warn(TAG$b, "Failed to set drawingBufferColorSpace", A2);
50221
50407
  }
50222
- const s = this.detectChromium();
50223
- this.hasNativeHDRSupport = s, !this.hasNativeHDRSupport && this.isHDRSource ? (Logger.debug(TAG$b, "Using shader-based HDR tone mapping (non-Chromium)"), this.initWebGLWithHDR()) : (Logger.debug(TAG$b, "Using simple passthrough (Chromium native HDR)"), this.initWebGLSimple()), Logger.info(TAG$b, `Initialized: ${v}x${r}, isChromium=${s}, isHDR=${this.isHDRSource}, colorSpace=${e}`);
50408
+ const i = this.detectChromium();
50409
+ this.hasNativeHDRSupport = i, !this.hasNativeHDRSupport && this.isHDRSource ? (Logger.debug(TAG$b, "Using shader-based HDR tone mapping (non-Chromium)"), this.initWebGLWithHDR()) : (Logger.debug(TAG$b, "Using simple passthrough (Chromium native HDR)"), this.initWebGLSimple()), Logger.info(TAG$b, `Initialized: ${v}x${r}, isChromium=${i}, isHDR=${this.isHDRSource}, colorSpace=${e}`);
50224
50410
  }
50225
50411
  initWebGLSimple() {
50226
50412
  if (!this.gl) return;