@loaders.gl/scan 5.0.0-alpha.10 → 5.0.0-alpha.11

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/iceberg.cjs CHANGED
@@ -3328,892 +3328,6 @@ var init_compression = __esm({
3328
3328
  }
3329
3329
  });
3330
3330
 
3331
- // ../compression/src/lib/fflate/index.ts
3332
- function deflateSync(data, opts) {
3333
- return dopt(data, opts || {}, 0, 0);
3334
- }
3335
- function inflateSync(data, out) {
3336
- return inflt(data, out);
3337
- }
3338
- function gzipSync(data, opts) {
3339
- if (!opts) opts = {};
3340
- const c = crc(), l = data.length;
3341
- c.p(data);
3342
- const d = dopt(data, opts, gzhl(opts), 8), s = d.length;
3343
- return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;
3344
- }
3345
- function gunzipSync(data, out) {
3346
- return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));
3347
- }
3348
- function zlibSync(data, opts) {
3349
- if (!opts) opts = {};
3350
- const a = adler();
3351
- a.p(data);
3352
- const d = dopt(data, opts, 2, 4);
3353
- return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;
3354
- }
3355
- function unzlibSync(data, out) {
3356
- return inflt((zlv(data), data.subarray(2, -4)), out);
3357
- }
3358
- var u8, u16, u32, fleb, fdeb, clim, freb, fl, revfl, fd, revfd, rev, hMap, flt, fdt, flm, flrm, fdm, fdrm, max, bits, bits16, shft, slc, ec, err, inflt, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, deo, et, dflt, crct, crc, adler, dopt, wbytes, gzh, gzs, gzl, gzhl, zlh, zlv, Deflate, Inflate, Gzip, Gunzip, Zlib, Unzlib;
3359
- var init_fflate = __esm({
3360
- "../compression/src/lib/fflate/index.ts"() {
3361
- "use strict";
3362
- u8 = Uint8Array;
3363
- u16 = Uint16Array;
3364
- u32 = Uint32Array;
3365
- fleb = new u8([
3366
- 0,
3367
- 0,
3368
- 0,
3369
- 0,
3370
- 0,
3371
- 0,
3372
- 0,
3373
- 0,
3374
- 1,
3375
- 1,
3376
- 1,
3377
- 1,
3378
- 2,
3379
- 2,
3380
- 2,
3381
- 2,
3382
- 3,
3383
- 3,
3384
- 3,
3385
- 3,
3386
- 4,
3387
- 4,
3388
- 4,
3389
- 4,
3390
- 5,
3391
- 5,
3392
- 5,
3393
- 5,
3394
- 0,
3395
- /* unused */
3396
- 0,
3397
- 0,
3398
- /* impossible */
3399
- 0
3400
- ]);
3401
- fdeb = new u8([
3402
- 0,
3403
- 0,
3404
- 0,
3405
- 0,
3406
- 1,
3407
- 1,
3408
- 2,
3409
- 2,
3410
- 3,
3411
- 3,
3412
- 4,
3413
- 4,
3414
- 5,
3415
- 5,
3416
- 6,
3417
- 6,
3418
- 7,
3419
- 7,
3420
- 8,
3421
- 8,
3422
- 9,
3423
- 9,
3424
- 10,
3425
- 10,
3426
- 11,
3427
- 11,
3428
- 12,
3429
- 12,
3430
- 13,
3431
- 13,
3432
- /* unused */
3433
- 0,
3434
- 0
3435
- ]);
3436
- clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
3437
- freb = (eb, start) => {
3438
- const b = new u16(31);
3439
- for (let i = 0; i < 31; ++i) {
3440
- b[i] = start += 1 << eb[i - 1];
3441
- }
3442
- const r = new u32(b[30]);
3443
- for (let i = 1; i < 30; ++i) {
3444
- for (let j = b[i]; j < b[i + 1]; ++j) {
3445
- r[j] = j - b[i] << 5 | i;
3446
- }
3447
- }
3448
- return [b, r];
3449
- };
3450
- [fl, revfl] = freb(fleb, 2);
3451
- fl[28] = 258, revfl[258] = 28;
3452
- [fd, revfd] = freb(fdeb, 0);
3453
- rev = new u16(32768);
3454
- for (let i = 0; i < 32768; ++i) {
3455
- let x = (i & 43690) >>> 1 | (i & 21845) << 1;
3456
- x = (x & 52428) >>> 2 | (x & 13107) << 2;
3457
- x = (x & 61680) >>> 4 | (x & 3855) << 4;
3458
- rev[i] = ((x & 65280) >>> 8 | (x & 255) << 8) >>> 1;
3459
- }
3460
- hMap = (cd, mb, r) => {
3461
- const s = cd.length;
3462
- let i = 0;
3463
- const l = new u16(mb);
3464
- for (; i < s; ++i) {
3465
- if (cd[i]) ++l[cd[i] - 1];
3466
- }
3467
- const le = new u16(mb);
3468
- for (i = 0; i < mb; ++i) {
3469
- le[i] = le[i - 1] + l[i - 1] << 1;
3470
- }
3471
- let co;
3472
- if (r) {
3473
- co = new u16(1 << mb);
3474
- const rvb = 15 - mb;
3475
- for (i = 0; i < s; ++i) {
3476
- if (cd[i]) {
3477
- const sv = i << 4 | cd[i];
3478
- const r2 = mb - cd[i];
3479
- let v = le[cd[i] - 1]++ << r2;
3480
- for (const m = v | (1 << r2) - 1; v <= m; ++v) {
3481
- co[rev[v] >>> rvb] = sv;
3482
- }
3483
- }
3484
- }
3485
- } else {
3486
- co = new u16(s);
3487
- for (i = 0; i < s; ++i) {
3488
- if (cd[i]) {
3489
- co[i] = rev[le[cd[i] - 1]++] >>> 15 - cd[i];
3490
- }
3491
- }
3492
- }
3493
- return co;
3494
- };
3495
- flt = new u8(288);
3496
- for (let i = 0; i < 144; ++i) flt[i] = 8;
3497
- for (let i = 144; i < 256; ++i) flt[i] = 9;
3498
- for (let i = 256; i < 280; ++i) flt[i] = 7;
3499
- for (let i = 280; i < 288; ++i) flt[i] = 8;
3500
- fdt = new u8(32);
3501
- for (let i = 0; i < 32; ++i) fdt[i] = 5;
3502
- flm = /* @__PURE__ */ hMap(flt, 9, 0);
3503
- flrm = /* @__PURE__ */ hMap(flt, 9, 1);
3504
- fdm = /* @__PURE__ */ hMap(fdt, 5, 0);
3505
- fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
3506
- max = (a) => {
3507
- let m = a[0];
3508
- for (let i = 1; i < a.length; ++i) {
3509
- if (a[i] > m) m = a[i];
3510
- }
3511
- return m;
3512
- };
3513
- bits = (d, p, m) => {
3514
- const o = p / 8 | 0;
3515
- return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
3516
- };
3517
- bits16 = (d, p) => {
3518
- const o = p / 8 | 0;
3519
- return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
3520
- };
3521
- shft = (p) => (p + 7) / 8 | 0;
3522
- slc = (v, s, e) => {
3523
- if (s == null || s < 0) s = 0;
3524
- if (e == null || e > v.length) e = v.length;
3525
- const n = new (v.BYTES_PER_ELEMENT == 2 ? u16 : v.BYTES_PER_ELEMENT == 4 ? u32 : u8)(e - s);
3526
- n.set(v.subarray(s, e));
3527
- return n;
3528
- };
3529
- ec = [
3530
- "unexpected EOF",
3531
- "invalid block type",
3532
- "invalid length/literal",
3533
- "invalid distance",
3534
- "stream finished",
3535
- "no stream handler",
3536
- ,
3537
- // determined by compression function
3538
- "no callback",
3539
- "invalid UTF-8 data",
3540
- "extra field too long",
3541
- "date not in range 1980-2099",
3542
- "filename too long",
3543
- "stream finishing",
3544
- "invalid zip data"
3545
- // determined by unknown compression method
3546
- ];
3547
- err = (ind, msg, nt) => {
3548
- const e = new Error(msg || ec[ind]);
3549
- e.code = ind;
3550
- if (Error.captureStackTrace) Error.captureStackTrace(e, err);
3551
- if (!nt) throw e;
3552
- return e;
3553
- };
3554
- inflt = (dat, buf, st) => {
3555
- const sl = dat.length;
3556
- if (!sl || st && st.f && !st.l) return buf || new u8(0);
3557
- const noBuf = !buf || st;
3558
- const noSt = !st || st.i;
3559
- if (!st) st = {};
3560
- if (!buf) buf = new u8(sl * 3);
3561
- const cbuf = (l) => {
3562
- let bl = buf.length;
3563
- if (l > bl) {
3564
- const nbuf = new u8(Math.max(bl * 2, l));
3565
- nbuf.set(buf);
3566
- buf = nbuf;
3567
- }
3568
- };
3569
- let final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
3570
- const tbts = sl * 8;
3571
- do {
3572
- if (!lm) {
3573
- final = bits(dat, pos, 1);
3574
- const type = bits(dat, pos + 1, 3);
3575
- pos += 3;
3576
- if (!type) {
3577
- const s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
3578
- if (t > sl) {
3579
- if (noSt) err(0);
3580
- break;
3581
- }
3582
- if (noBuf) cbuf(bt + l);
3583
- buf.set(dat.subarray(s, t), bt);
3584
- st.b = bt += l, st.p = pos = t * 8, st.f = final;
3585
- continue;
3586
- } else if (type == 1) lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
3587
- else if (type == 2) {
3588
- const hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
3589
- const tl = hLit + bits(dat, pos + 5, 31) + 1;
3590
- pos += 14;
3591
- const ldt = new u8(tl);
3592
- const clt = new u8(19);
3593
- for (let i = 0; i < hcLen; ++i) {
3594
- clt[clim[i]] = bits(dat, pos + i * 3, 7);
3595
- }
3596
- pos += hcLen * 3;
3597
- const clb = max(clt), clbmsk = (1 << clb) - 1;
3598
- const clm = hMap(clt, clb, 1);
3599
- for (let i = 0; i < tl; ) {
3600
- const r = clm[bits(dat, pos, clbmsk)];
3601
- pos += r & 15;
3602
- const s = r >>> 4;
3603
- if (s < 16) {
3604
- ldt[i++] = s;
3605
- } else {
3606
- let c = 0, n = 0;
3607
- if (s == 16) n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
3608
- else if (s == 17) n = 3 + bits(dat, pos, 7), pos += 3;
3609
- else if (s == 18) n = 11 + bits(dat, pos, 127), pos += 7;
3610
- while (n--) ldt[i++] = c;
3611
- }
3612
- }
3613
- const lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
3614
- lbt = max(lt);
3615
- dbt = max(dt);
3616
- lm = hMap(lt, lbt, 1);
3617
- dm = hMap(dt, dbt, 1);
3618
- } else err(1);
3619
- if (pos > tbts) {
3620
- if (noSt) err(0);
3621
- break;
3622
- }
3623
- }
3624
- if (noBuf) cbuf(bt + 131072);
3625
- const lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
3626
- let lpos = pos;
3627
- for (; ; lpos = pos) {
3628
- const c = lm[bits16(dat, pos) & lms], sym = c >>> 4;
3629
- pos += c & 15;
3630
- if (pos > tbts) {
3631
- if (noSt) err(0);
3632
- break;
3633
- }
3634
- if (!c) err(2);
3635
- if (sym < 256) buf[bt++] = sym;
3636
- else if (sym == 256) {
3637
- lpos = pos, lm = void 0;
3638
- break;
3639
- } else {
3640
- let add = sym - 254;
3641
- if (sym > 264) {
3642
- const i = sym - 257, b = fleb[i];
3643
- add = bits(dat, pos, (1 << b) - 1) + fl[i];
3644
- pos += b;
3645
- }
3646
- const d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;
3647
- if (!d) err(3);
3648
- pos += d & 15;
3649
- let dt = fd[dsym];
3650
- if (dsym > 3) {
3651
- const b = fdeb[dsym];
3652
- dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
3653
- }
3654
- if (pos > tbts) {
3655
- if (noSt) err(0);
3656
- break;
3657
- }
3658
- if (noBuf) cbuf(bt + 131072);
3659
- const end = bt + add;
3660
- for (; bt < end; bt += 4) {
3661
- buf[bt] = buf[bt - dt];
3662
- buf[bt + 1] = buf[bt + 1 - dt];
3663
- buf[bt + 2] = buf[bt + 2 - dt];
3664
- buf[bt + 3] = buf[bt + 3 - dt];
3665
- }
3666
- bt = end;
3667
- }
3668
- }
3669
- st.l = lm, st.p = lpos, st.b = bt, st.f = final;
3670
- if (lm) final = 1, st.m = lbt, st.d = dm, st.n = dbt;
3671
- } while (!final);
3672
- return bt == buf.length ? buf : slc(buf, 0, bt);
3673
- };
3674
- wbits = (d, p, v) => {
3675
- v <<= p & 7;
3676
- const o = p / 8 | 0;
3677
- d[o] |= v;
3678
- d[o + 1] |= v >>> 8;
3679
- };
3680
- wbits16 = (d, p, v) => {
3681
- v <<= p & 7;
3682
- const o = p / 8 | 0;
3683
- d[o] |= v;
3684
- d[o + 1] |= v >>> 8;
3685
- d[o + 2] |= v >>> 16;
3686
- };
3687
- hTree = (d, mb) => {
3688
- const t = [];
3689
- for (let i = 0; i < d.length; ++i) {
3690
- if (d[i]) t.push({ s: i, f: d[i] });
3691
- }
3692
- const s = t.length;
3693
- const t2 = t.slice();
3694
- if (!s) return [et, 0];
3695
- if (s == 1) {
3696
- const v = new u8(t[0].s + 1);
3697
- v[t[0].s] = 1;
3698
- return [v, 1];
3699
- }
3700
- t.sort((a, b) => a.f - b.f);
3701
- t.push({ s: -1, f: 25001 });
3702
- let l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;
3703
- t[0] = { s: -1, f: l.f + r.f, l, r };
3704
- while (i1 != s - 1) {
3705
- l = t[t[i0].f < t[i2].f ? i0++ : i2++];
3706
- r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];
3707
- t[i1++] = { s: -1, f: l.f + r.f, l, r };
3708
- }
3709
- let maxSym = t2[0].s;
3710
- for (let i = 1; i < s; ++i) {
3711
- if (t2[i].s > maxSym) maxSym = t2[i].s;
3712
- }
3713
- const tr = new u16(maxSym + 1);
3714
- let mbt = ln(t[i1 - 1], tr, 0);
3715
- if (mbt > mb) {
3716
- let i = 0, dt = 0;
3717
- const lft = mbt - mb, cst = 1 << lft;
3718
- t2.sort((a, b) => tr[b.s] - tr[a.s] || a.f - b.f);
3719
- for (; i < s; ++i) {
3720
- const i22 = t2[i].s;
3721
- if (tr[i22] > mb) {
3722
- dt += cst - (1 << mbt - tr[i22]);
3723
- tr[i22] = mb;
3724
- } else break;
3725
- }
3726
- dt >>>= lft;
3727
- while (dt > 0) {
3728
- const i22 = t2[i].s;
3729
- if (tr[i22] < mb) dt -= 1 << mb - tr[i22]++ - 1;
3730
- else ++i;
3731
- }
3732
- for (; i >= 0 && dt; --i) {
3733
- const i22 = t2[i].s;
3734
- if (tr[i22] == mb) {
3735
- --tr[i22];
3736
- ++dt;
3737
- }
3738
- }
3739
- mbt = mb;
3740
- }
3741
- return [new u8(tr), mbt];
3742
- };
3743
- ln = (n, l, d) => {
3744
- return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
3745
- };
3746
- lc = (c) => {
3747
- let s = c.length;
3748
- while (s && !c[--s]) ;
3749
- const cl = new u16(++s);
3750
- let cli = 0, cln = c[0], cls = 1;
3751
- const w = (v) => {
3752
- cl[cli++] = v;
3753
- };
3754
- for (let i = 1; i <= s; ++i) {
3755
- if (c[i] == cln && i != s) ++cls;
3756
- else {
3757
- if (!cln && cls > 2) {
3758
- for (; cls > 138; cls -= 138) w(32754);
3759
- if (cls > 2) {
3760
- w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
3761
- cls = 0;
3762
- }
3763
- } else if (cls > 3) {
3764
- w(cln), --cls;
3765
- for (; cls > 6; cls -= 6) w(8304);
3766
- if (cls > 2) w(cls - 3 << 5 | 8208), cls = 0;
3767
- }
3768
- while (cls--) w(cln);
3769
- cls = 1;
3770
- cln = c[i];
3771
- }
3772
- }
3773
- return [cl.subarray(0, cli), s];
3774
- };
3775
- clen = (cf, cl) => {
3776
- let l = 0;
3777
- for (let i = 0; i < cl.length; ++i) l += cf[i] * cl[i];
3778
- return l;
3779
- };
3780
- wfblk = (out, pos, dat) => {
3781
- const s = dat.length;
3782
- const o = shft(pos + 2);
3783
- out[o] = s & 255;
3784
- out[o + 1] = s >>> 8;
3785
- out[o + 2] = out[o] ^ 255;
3786
- out[o + 3] = out[o + 1] ^ 255;
3787
- for (let i = 0; i < s; ++i) out[o + i + 4] = dat[i];
3788
- return (o + 4 + s) * 8;
3789
- };
3790
- wblk = (dat, out, final, syms, lf, df, eb, li, bs, bl, p) => {
3791
- wbits(out, p++, final);
3792
- ++lf[256];
3793
- const [dlt, mlb] = hTree(lf, 15);
3794
- const [ddt, mdb] = hTree(df, 15);
3795
- const [lclt, nlc] = lc(dlt);
3796
- const [lcdt, ndc] = lc(ddt);
3797
- const lcfreq = new u16(19);
3798
- for (let i = 0; i < lclt.length; ++i) lcfreq[lclt[i] & 31]++;
3799
- for (let i = 0; i < lcdt.length; ++i) lcfreq[lcdt[i] & 31]++;
3800
- const [lct, mlcb] = hTree(lcfreq, 7);
3801
- let nlcc = 19;
3802
- for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc) ;
3803
- const flen = bl + 5 << 3;
3804
- const ftlen = clen(lf, flt) + clen(df, fdt) + eb;
3805
- const dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + (2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18]);
3806
- if (flen <= ftlen && flen <= dtlen) return wfblk(out, p, dat.subarray(bs, bs + bl));
3807
- let lm, ll, dm, dl;
3808
- wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
3809
- if (dtlen < ftlen) {
3810
- lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
3811
- const llm = hMap(lct, mlcb, 0);
3812
- wbits(out, p, nlc - 257);
3813
- wbits(out, p + 5, ndc - 1);
3814
- wbits(out, p + 10, nlcc - 4);
3815
- p += 14;
3816
- for (let i = 0; i < nlcc; ++i) wbits(out, p + 3 * i, lct[clim[i]]);
3817
- p += 3 * nlcc;
3818
- const lcts = [lclt, lcdt];
3819
- for (let it = 0; it < 2; ++it) {
3820
- const clct = lcts[it];
3821
- for (let i = 0; i < clct.length; ++i) {
3822
- const len = clct[i] & 31;
3823
- wbits(out, p, llm[len]), p += lct[len];
3824
- if (len > 15) wbits(out, p, clct[i] >>> 5 & 127), p += clct[i] >>> 12;
3825
- }
3826
- }
3827
- } else {
3828
- lm = flm, ll = flt, dm = fdm, dl = fdt;
3829
- }
3830
- for (let i = 0; i < li; ++i) {
3831
- if (syms[i] > 255) {
3832
- const len = syms[i] >>> 18 & 31;
3833
- wbits16(out, p, lm[len + 257]), p += ll[len + 257];
3834
- if (len > 7) wbits(out, p, syms[i] >>> 23 & 31), p += fleb[len];
3835
- const dst = syms[i] & 31;
3836
- wbits16(out, p, dm[dst]), p += dl[dst];
3837
- if (dst > 3) wbits16(out, p, syms[i] >>> 5 & 8191), p += fdeb[dst];
3838
- } else {
3839
- wbits16(out, p, lm[syms[i]]), p += ll[syms[i]];
3840
- }
3841
- }
3842
- wbits16(out, p, lm[256]);
3843
- return p + ll[256];
3844
- };
3845
- deo = /* @__PURE__ */ new u32([
3846
- 65540,
3847
- 131080,
3848
- 131088,
3849
- 131104,
3850
- 262176,
3851
- 1048704,
3852
- 1048832,
3853
- 2114560,
3854
- 2117632
3855
- ]);
3856
- et = /* @__PURE__ */ new u8(0);
3857
- dflt = (dat, lvl, plvl, pre, post, lst) => {
3858
- const s = dat.length;
3859
- const o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7e3)) + post);
3860
- const w = o.subarray(pre, o.length - post);
3861
- let pos = 0;
3862
- if (!lvl || s < 8) {
3863
- for (let i = 0; i <= s; i += 65535) {
3864
- const e = i + 65535;
3865
- if (e >= s) {
3866
- w[pos >> 3] = lst;
3867
- }
3868
- pos = wfblk(w, pos + 1, dat.subarray(i, e));
3869
- }
3870
- } else {
3871
- const opt = deo[lvl - 1];
3872
- const n = opt >>> 13, c = opt & 8191;
3873
- const msk = (1 << plvl) - 1;
3874
- const prev = new u16(32768), head = new u16(msk + 1);
3875
- const bs1 = Math.ceil(plvl / 3), bs2 = 2 * bs1;
3876
- const hsh = (i2) => (dat[i2] ^ dat[i2 + 1] << bs1 ^ dat[i2 + 2] << bs2) & msk;
3877
- const syms = new u32(25e3);
3878
- const lf = new u16(288), df = new u16(32);
3879
- let lc2 = 0, eb = 0, i = 0, li = 0, wi = 0, bs = 0;
3880
- for (; i < s; ++i) {
3881
- const hv = hsh(i);
3882
- let imod = i & 32767, pimod = head[hv];
3883
- prev[imod] = pimod;
3884
- head[hv] = imod;
3885
- if (wi <= i) {
3886
- const rem = s - i;
3887
- if ((lc2 > 7e3 || li > 24576) && rem > 423) {
3888
- pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);
3889
- li = lc2 = eb = 0, bs = i;
3890
- for (let j = 0; j < 286; ++j) lf[j] = 0;
3891
- for (let j = 0; j < 30; ++j) df[j] = 0;
3892
- }
3893
- let l = 2, d = 0, ch = c, dif = imod - pimod & 32767;
3894
- if (rem > 2 && hv == hsh(i - dif)) {
3895
- const maxn = Math.min(n, rem) - 1;
3896
- const maxd = Math.min(32767, i);
3897
- const ml = Math.min(258, rem);
3898
- while (dif <= maxd && --ch && imod != pimod) {
3899
- if (dat[i + l] == dat[i + l - dif]) {
3900
- let nl = 0;
3901
- for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl) ;
3902
- if (nl > l) {
3903
- l = nl, d = dif;
3904
- if (nl > maxn) break;
3905
- const mmd = Math.min(dif, nl - 2);
3906
- let md = 0;
3907
- for (let j = 0; j < mmd; ++j) {
3908
- const ti = i - dif + j + 32768 & 32767;
3909
- const pti = prev[ti];
3910
- const cd = ti - pti + 32768 & 32767;
3911
- if (cd > md) md = cd, pimod = ti;
3912
- }
3913
- }
3914
- }
3915
- imod = pimod, pimod = prev[imod];
3916
- dif += imod - pimod + 32768 & 32767;
3917
- }
3918
- }
3919
- if (d) {
3920
- syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
3921
- const lin = revfl[l] & 31, din = revfd[d] & 31;
3922
- eb += fleb[lin] + fdeb[din];
3923
- ++lf[257 + lin];
3924
- ++df[din];
3925
- wi = i + l;
3926
- ++lc2;
3927
- } else {
3928
- syms[li++] = dat[i];
3929
- ++lf[dat[i]];
3930
- }
3931
- }
3932
- }
3933
- pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
3934
- if (!lst && pos & 7) pos = wfblk(w, pos + 1, et);
3935
- }
3936
- return slc(o, 0, pre + shft(pos) + post);
3937
- };
3938
- crct = /* @__PURE__ */ (() => {
3939
- const t = new Int32Array(256);
3940
- for (let i = 0; i < 256; ++i) {
3941
- let c = i, k = 9;
3942
- while (--k) c = (c & 1 && -306674912) ^ c >>> 1;
3943
- t[i] = c;
3944
- }
3945
- return t;
3946
- })();
3947
- crc = () => {
3948
- let c = -1;
3949
- return {
3950
- p(d) {
3951
- let cr = c;
3952
- for (let i = 0; i < d.length; ++i) cr = crct[cr & 255 ^ d[i]] ^ cr >>> 8;
3953
- c = cr;
3954
- },
3955
- d() {
3956
- return ~c;
3957
- }
3958
- };
3959
- };
3960
- adler = () => {
3961
- let a = 1, b = 0;
3962
- return {
3963
- p(d) {
3964
- let n = a, m = b;
3965
- const l = d.length | 0;
3966
- for (let i = 0; i != l; ) {
3967
- const e = Math.min(i + 2655, l);
3968
- for (; i < e; ++i) m += n += d[i];
3969
- n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);
3970
- }
3971
- a = n, b = m;
3972
- },
3973
- d() {
3974
- a %= 65521, b %= 65521;
3975
- return (a & 255) << 24 | a >>> 8 << 16 | (b & 255) << 8 | b >>> 8;
3976
- }
3977
- };
3978
- };
3979
- dopt = (dat, opt, pre, post, st) => dflt(
3980
- dat,
3981
- opt.level == null ? 6 : opt.level,
3982
- opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 12 + opt.mem,
3983
- pre,
3984
- post,
3985
- !st
3986
- );
3987
- wbytes = (d, b, v) => {
3988
- for (; v; ++b) d[b] = v, v >>>= 8;
3989
- };
3990
- gzh = (c, o) => {
3991
- const fn = o.filename;
3992
- c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3;
3993
- if (o.mtime != 0)
3994
- wbytes(
3995
- c,
3996
- 4,
3997
- Math.floor(new Date(o.mtime || Date.now()) / 1e3)
3998
- );
3999
- if (fn) {
4000
- c[3] = 8;
4001
- for (let i = 0; i <= fn.length; ++i) c[i + 10] = fn.charCodeAt(i);
4002
- }
4003
- };
4004
- gzs = (d) => {
4005
- if (d[0] != 31 || d[1] != 139 || d[2] != 8) err(6, "invalid gzip data");
4006
- const flg = d[3];
4007
- let st = 10;
4008
- if (flg & 4) st += d[10] | (d[11] << 8) + 2;
4009
- for (let zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++]) ;
4010
- return st + (flg & 2);
4011
- };
4012
- gzl = (d) => {
4013
- const l = d.length;
4014
- return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;
4015
- };
4016
- gzhl = (o) => 10 + (o.filename && o.filename.length + 1 || 0);
4017
- zlh = (c, o) => {
4018
- const lv = o.level, fl2 = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;
4019
- c[0] = 120, c[1] = fl2 << 6 | (fl2 ? 32 - 2 * fl2 : 1);
4020
- };
4021
- zlv = (d) => {
4022
- if ((d[0] & 15) != 8 || d[0] >>> 4 > 7 || (d[0] << 8 | d[1]) % 31) err(6, "invalid zlib data");
4023
- if (d[1] & 32) err(6, "invalid zlib data: preset dictionaries not supported");
4024
- };
4025
- Deflate = class {
4026
- /** Initializes the stream and its output handler. */
4027
- constructor(opts, cb) {
4028
- if (!cb && typeof opts == "function") cb = opts, opts = {};
4029
- this.ondata = cb;
4030
- this.o = opts || {};
4031
- }
4032
- /** Compression options or retained output window for this stream. */
4033
- o;
4034
- /** Whether the stream has received its final chunk. */
4035
- d;
4036
- /**
4037
- * The handler to call whenever data is available
4038
- */
4039
- ondata;
4040
- /** Encodes a chunk and emits its framed output. */
4041
- p(c, f) {
4042
- this.ondata(dopt(c, this.o, 0, 0, !f), f);
4043
- }
4044
- /**
4045
- * Pushes a chunk to be deflated
4046
- * @param chunk The chunk to push
4047
- * @param final Whether this is the last chunk
4048
- */
4049
- push(chunk, final) {
4050
- if (!this.ondata) err(5);
4051
- if (this.d) err(4);
4052
- this.d = final;
4053
- this.p(chunk, final || false);
4054
- }
4055
- };
4056
- Inflate = class {
4057
- /**
4058
- * Creates an inflation stream
4059
- * @param cb The callback to call whenever data is inflated
4060
- */
4061
- constructor(cb) {
4062
- this.ondata = cb;
4063
- }
4064
- /** Persistent bit-reader and Huffman decoding state. */
4065
- s = {};
4066
- /** Compression options or retained output window for this stream. */
4067
- o;
4068
- /** Compressed bytes pending decoding. */
4069
- p = new u8(0);
4070
- /** Whether the stream has received its final chunk. */
4071
- d;
4072
- /**
4073
- * The handler to call whenever data is available
4074
- */
4075
- ondata;
4076
- /** Appends pending input after checking stream lifecycle. */
4077
- e(c) {
4078
- if (!this.ondata) err(5);
4079
- if (this.d) err(4);
4080
- const l = this.p.length;
4081
- const n = new u8(l + c.length);
4082
- n.set(this.p), n.set(c, l), this.p = n;
4083
- }
4084
- /** Decodes pending input and retains the sliding window. */
4085
- c(final) {
4086
- this.d = this.s.i = final || false;
4087
- const bts = this.s.b;
4088
- const dt = inflt(this.p, this.o, this.s);
4089
- this.ondata(slc(dt, bts, this.s.b), this.d);
4090
- this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
4091
- this.p = slc(this.p, this.s.p / 8 | 0), this.s.p &= 7;
4092
- }
4093
- /**
4094
- * Pushes a chunk to be inflated
4095
- * @param chunk The chunk to push
4096
- * @param final Whether this is the final chunk
4097
- */
4098
- push(chunk, final) {
4099
- this.e(chunk), this.c(final);
4100
- }
4101
- };
4102
- Gzip = class extends Deflate {
4103
- /** Checksum accumulator for the framed output. */
4104
- c = crc();
4105
- /** Total uncompressed byte count for the GZIP footer. */
4106
- l = 0;
4107
- /** Whether the stream header still needs to be emitted or consumed. */
4108
- v = 1;
4109
- /** Initializes the stream and its output handler. */
4110
- constructor(opts, cb) {
4111
- super(opts, cb);
4112
- }
4113
- /**
4114
- * Pushes a chunk to be GZIPped
4115
- * @param chunk The chunk to push
4116
- * @param final Whether this is the last chunk
4117
- */
4118
- push(chunk, final) {
4119
- Deflate.prototype.push.call(this, chunk, final);
4120
- }
4121
- /** Encodes a chunk and emits its framed output. */
4122
- p(c, f) {
4123
- this.c.p(c);
4124
- this.l += c.length;
4125
- const raw = dopt(c, this.o, this.v ? gzhl(this.o) : 0, f ? 8 : 0, !f);
4126
- if (this.v) gzh(raw, this.o), this.v = 0;
4127
- if (f) wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);
4128
- this.ondata(raw, f);
4129
- }
4130
- };
4131
- Gunzip = class extends Inflate {
4132
- /** Whether the stream header still needs to be emitted or consumed. */
4133
- v = 1;
4134
- /**
4135
- * Creates a GUNZIP stream
4136
- * @param cb The callback to call whenever data is inflated
4137
- */
4138
- constructor(cb) {
4139
- super(cb);
4140
- }
4141
- /**
4142
- * Pushes a chunk to be GUNZIPped
4143
- * @param chunk The chunk to push
4144
- * @param final Whether this is the last chunk
4145
- */
4146
- push(chunk, final) {
4147
- Inflate.prototype.e.call(this, chunk);
4148
- if (this.v) {
4149
- const s = this.p.length > 3 ? gzs(this.p) : 4;
4150
- if (s >= this.p.length && !final) return;
4151
- this.p = this.p.subarray(s), this.v = 0;
4152
- }
4153
- if (final) {
4154
- if (this.p.length < 8) err(6, "invalid gzip data");
4155
- this.p = this.p.subarray(0, -8);
4156
- }
4157
- Inflate.prototype.c.call(this, final);
4158
- }
4159
- };
4160
- Zlib = class extends Deflate {
4161
- /** Checksum accumulator for the framed output. */
4162
- c = adler();
4163
- /** Whether the stream header still needs to be emitted or consumed. */
4164
- v = 1;
4165
- /** Initializes the stream and its output handler. */
4166
- constructor(opts, cb) {
4167
- super(opts, cb);
4168
- }
4169
- /**
4170
- * Pushes a chunk to be zlibbed
4171
- * @param chunk The chunk to push
4172
- * @param final Whether this is the last chunk
4173
- */
4174
- push(chunk, final) {
4175
- Deflate.prototype.push.call(this, chunk, final);
4176
- }
4177
- /** Encodes a chunk and emits its framed output. */
4178
- p(c, f) {
4179
- this.c.p(c);
4180
- const raw = dopt(c, this.o, this.v ? 2 : 0, f ? 4 : 0, !f);
4181
- if (this.v) zlh(raw, this.o), this.v = 0;
4182
- if (f) wbytes(raw, raw.length - 4, this.c.d());
4183
- this.ondata(raw, f);
4184
- }
4185
- };
4186
- Unzlib = class extends Inflate {
4187
- /** Whether the stream header still needs to be emitted or consumed. */
4188
- v = 1;
4189
- /**
4190
- * Creates a Zlib decompression stream
4191
- * @param cb The callback to call whenever data is inflated
4192
- */
4193
- constructor(cb) {
4194
- super(cb);
4195
- }
4196
- /**
4197
- * Pushes a chunk to be unzlibbed
4198
- * @param chunk The chunk to push
4199
- * @param final Whether this is the last chunk
4200
- */
4201
- push(chunk, final) {
4202
- Inflate.prototype.e.call(this, chunk);
4203
- if (this.v) {
4204
- if (this.p.length < 2 && !final) return;
4205
- this.p = this.p.subarray(2), this.v = 0;
4206
- }
4207
- if (final) {
4208
- if (this.p.length < 4) err(6, "invalid zlib data");
4209
- this.p = this.p.subarray(0, -4);
4210
- }
4211
- Inflate.prototype.c.call(this, final);
4212
- }
4213
- };
4214
- }
4215
- });
4216
-
4217
3331
  // ../compression/src/lib/compression-stream.ts
4218
3332
  async function compressWithNativeCompressionStream(input, format) {
4219
3333
  const outputBatches = compressBatchesWithNativeCompressionStream([input], format);
@@ -4396,322 +3510,568 @@ var init_decompression_stream = __esm({
4396
3510
  }
4397
3511
  });
4398
3512
 
4399
- // ../compression/src/lib/deflate-compression.ts
4400
- var deflate_compression_exports = {};
4401
- __export(deflate_compression_exports, {
4402
- DeflateCompression: () => DeflateCompression
3513
+ // ../compression/src/lib/native-decompressor.ts
3514
+ var native_decompressor_exports = {};
3515
+ __export(native_decompressor_exports, {
3516
+ NativeDecompressor: () => NativeDecompressor
4403
3517
  });
4404
- var import_zlib, DeflateCompression;
4405
- var init_deflate_compression = __esm({
4406
- "../compression/src/lib/deflate-compression.ts"() {
3518
+ var NativeDecompressor;
3519
+ var init_native_decompressor = __esm({
3520
+ "../compression/src/lib/native-decompressor.ts"() {
4407
3521
  "use strict";
4408
3522
  init_compression();
4409
- init_src2();
4410
- init_fflate();
4411
- import_zlib = __toESM(require("zlib"), 1);
4412
- init_compression_stream();
4413
3523
  init_decompression_stream();
4414
- DeflateCompression = class extends Compression {
4415
- name = "deflate";
4416
- extensions = [];
4417
- contentEncodings = ["deflate"];
3524
+ NativeDecompressor = class extends Decompressor {
3525
+ name;
3526
+ extensions;
3527
+ contentEncodings;
3528
+ isSupported = true;
3529
+ /** Runtime stream format used for every operation. */
3530
+ format;
3531
+ constructor(metadata, format, options = {}) {
3532
+ super(options);
3533
+ this.name = metadata.name;
3534
+ this.extensions = [...metadata.extensions];
3535
+ this.contentEncodings = [...metadata.contentEncodings];
3536
+ this.format = format;
3537
+ }
3538
+ /** Decompresses one buffer with the runtime-provided stream. */
3539
+ async decompress(input) {
3540
+ const output = await decompressWithNativeDecompressionStream(input, this.format);
3541
+ if (!output) throw new Error(`${this.name}: built-in decompression is no longer available`);
3542
+ return output;
3543
+ }
3544
+ /** Decompresses batches incrementally with the runtime-provided stream. */
3545
+ async *decompressBatches(inputBatches) {
3546
+ const output = decompressBatchesWithNativeDecompressionStream(inputBatches, this.format);
3547
+ if (!output) throw new Error(`${this.name}: built-in decompression is no longer available`);
3548
+ yield* output;
3549
+ }
3550
+ };
3551
+ }
3552
+ });
3553
+
3554
+ // ../compression/src/lib/lazy-compression.ts
3555
+ function mergeModules(options, modules) {
3556
+ return { ...options, modules: { ...options.modules, ...modules } };
3557
+ }
3558
+ var LazyDecompressor;
3559
+ var init_lazy_compression = __esm({
3560
+ "../compression/src/lib/lazy-compression.ts"() {
3561
+ "use strict";
3562
+ init_compression();
3563
+ init_decompression_stream();
3564
+ LazyDecompressor = class extends Decompressor {
3565
+ name;
3566
+ extensions;
3567
+ contentEncodings;
4418
3568
  isSupported = true;
3569
+ /** Constructor options retained until a concrete implementation is selected. */
4419
3570
  options;
4420
- constructor(options = {}) {
3571
+ /** Built-in stream format to probe, or null when the format has no built-in path. */
3572
+ nativeFormat;
3573
+ /** Returns whether built-in selection remains eligible for the merged preload options. */
3574
+ shouldUseNative;
3575
+ /** Dynamically imports the balanced fallback constructor. */
3576
+ loadFallback;
3577
+ /** Selected concrete implementation after preload completes. */
3578
+ implementation = null;
3579
+ /** Shared in-flight selection used by concurrent asynchronous calls. */
3580
+ implementationPromise = null;
3581
+ constructor(metadata, loadFallback, options = {}, nativeFormat = null, shouldUseNative = () => true) {
4421
3582
  super(options);
3583
+ this.name = metadata.name;
3584
+ this.extensions = [...metadata.extensions];
3585
+ this.contentEncodings = [...metadata.contentEncodings];
4422
3586
  this.options = options;
3587
+ this.nativeFormat = nativeFormat;
3588
+ this.shouldUseNative = shouldUseNative;
3589
+ this.loadFallback = loadFallback;
3590
+ }
3591
+ /** Selects and returns the built-in or dynamically imported fallback decompressor. */
3592
+ async preload(modules = {}) {
3593
+ if (this.implementation) return this.implementation;
3594
+ const options = mergeModules(this.options, modules);
3595
+ this.implementationPromise ||= this.loadImplementation(options);
3596
+ try {
3597
+ this.implementation = await this.implementationPromise;
3598
+ return this.implementation;
3599
+ } catch (error) {
3600
+ this.implementationPromise = null;
3601
+ throw error;
3602
+ }
3603
+ }
3604
+ /** Loads the selected concrete decompressor. */
3605
+ async loadImplementation(options) {
3606
+ if (options.useNative !== false && this.nativeFormat && this.shouldUseNative(options) && isNativeDecompressionSupported(this.nativeFormat)) {
3607
+ const { NativeDecompressor: NativeDecompressor2 } = await Promise.resolve().then(() => (init_native_decompressor(), native_decompressor_exports));
3608
+ return new NativeDecompressor2(this, this.nativeFormat, options);
3609
+ }
3610
+ const Decompressor2 = await this.loadFallback();
3611
+ const implementation = new Decompressor2({ ...options, useNative: false });
3612
+ await implementation.preload(options.modules);
3613
+ return implementation;
3614
+ }
3615
+ /** Decompresses after lazily selecting the default implementation. */
3616
+ async decompress(input, size) {
3617
+ return (await this.preload()).decompress(input, size);
3618
+ }
3619
+ /** Decompresses synchronously after an implementation has been preloaded. */
3620
+ decompressSync(input, size) {
3621
+ if (!this.implementation) {
3622
+ throw new Error(`${this.name}: call preload() before decompressSync()`);
3623
+ }
3624
+ return this.implementation.decompressSync(input, size);
3625
+ }
3626
+ /** Decompresses batches after lazily selecting the default implementation. */
3627
+ async *decompressBatches(inputBatches) {
3628
+ yield* (await this.preload()).decompressBatches(inputBatches);
3629
+ }
3630
+ };
3631
+ }
3632
+ });
3633
+
3634
+ // ../compression/src/lib/fflate/index.ts
3635
+ function inflateSync(data, out) {
3636
+ return inflt(data, out);
3637
+ }
3638
+ function gunzipSync(data, out) {
3639
+ return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));
3640
+ }
3641
+ function unzlibSync(data, out) {
3642
+ return inflt((zlv(data), data.subarray(2, -4)), out);
3643
+ }
3644
+ var u8, u16, u32, fleb, fdeb, clim, freb, fl, revfl, fd, revfd, rev, hMap, flt, fdt, flrm, fdrm, max, bits, bits16, shft, slc, ec, err, inflt, gzs, gzl, zlv, Inflate, Gunzip, Unzlib;
3645
+ var init_fflate = __esm({
3646
+ "../compression/src/lib/fflate/index.ts"() {
3647
+ "use strict";
3648
+ u8 = Uint8Array;
3649
+ u16 = Uint16Array;
3650
+ u32 = Uint32Array;
3651
+ fleb = new u8([
3652
+ 0,
3653
+ 0,
3654
+ 0,
3655
+ 0,
3656
+ 0,
3657
+ 0,
3658
+ 0,
3659
+ 0,
3660
+ 1,
3661
+ 1,
3662
+ 1,
3663
+ 1,
3664
+ 2,
3665
+ 2,
3666
+ 2,
3667
+ 2,
3668
+ 3,
3669
+ 3,
3670
+ 3,
3671
+ 3,
3672
+ 4,
3673
+ 4,
3674
+ 4,
3675
+ 4,
3676
+ 5,
3677
+ 5,
3678
+ 5,
3679
+ 5,
3680
+ 0,
3681
+ /* unused */
3682
+ 0,
3683
+ 0,
3684
+ /* impossible */
3685
+ 0
3686
+ ]);
3687
+ fdeb = new u8([
3688
+ 0,
3689
+ 0,
3690
+ 0,
3691
+ 0,
3692
+ 1,
3693
+ 1,
3694
+ 2,
3695
+ 2,
3696
+ 3,
3697
+ 3,
3698
+ 4,
3699
+ 4,
3700
+ 5,
3701
+ 5,
3702
+ 6,
3703
+ 6,
3704
+ 7,
3705
+ 7,
3706
+ 8,
3707
+ 8,
3708
+ 9,
3709
+ 9,
3710
+ 10,
3711
+ 10,
3712
+ 11,
3713
+ 11,
3714
+ 12,
3715
+ 12,
3716
+ 13,
3717
+ 13,
3718
+ /* unused */
3719
+ 0,
3720
+ 0
3721
+ ]);
3722
+ clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
3723
+ freb = (eb, start) => {
3724
+ const b = new u16(31);
3725
+ for (let i = 0; i < 31; ++i) {
3726
+ b[i] = start += 1 << eb[i - 1];
4423
3727
  }
4424
- async compress(input) {
4425
- var _a, _b, _c;
4426
- const format = this.options.raw ? null : ((_a = this.options.deflate) == null ? void 0 : _a.gzip) ? "gzip" : "deflate";
4427
- if (format && ((_b = this.options.deflate) == null ? void 0 : _b.useNative) !== false) {
4428
- const nativeOutput = await compressWithNativeCompressionStream(input, format);
4429
- if (nativeOutput) return nativeOutput;
4430
- }
4431
- if (!isBrowser && ((_c = this.options.deflate) == null ? void 0 : _c.useZlib)) {
4432
- const buffer = this.options.deflate.gzip ? await promisify1(import_zlib.default.gzip)(input) : await promisify1(import_zlib.default.deflate)(input);
4433
- return toArrayBuffer2(buffer);
3728
+ const r = new u32(b[30]);
3729
+ for (let i = 1; i < 30; ++i) {
3730
+ for (let j = b[i]; j < b[i + 1]; ++j) {
3731
+ r[j] = j - b[i] << 5 | i;
4434
3732
  }
4435
- return this.compressSync(input);
4436
3733
  }
4437
- async decompress(input) {
4438
- var _a, _b, _c;
4439
- const format = this.options.raw ? "deflate-raw" : ((_a = this.options.deflate) == null ? void 0 : _a.gzip) ? "gzip" : "deflate";
4440
- if (((_b = this.options.deflate) == null ? void 0 : _b.useNative) !== false) {
4441
- const nativeOutput = await decompressWithNativeDecompressionStream(input, format);
4442
- if (nativeOutput) return nativeOutput;
4443
- }
4444
- if (!isBrowser && ((_c = this.options.deflate) == null ? void 0 : _c.useZlib)) {
4445
- const buffer = this.options.deflate.gzip ? await promisify1(import_zlib.default.gunzip)(input) : await promisify1(import_zlib.default.inflate)(input);
4446
- return toArrayBuffer2(buffer);
4447
- }
4448
- return this.decompressSync(input);
3734
+ return [b, r];
3735
+ };
3736
+ [fl, revfl] = freb(fleb, 2);
3737
+ fl[28] = 258, revfl[258] = 28;
3738
+ [fd, revfd] = freb(fdeb, 0);
3739
+ rev = new u16(32768);
3740
+ for (let i = 0; i < 32768; ++i) {
3741
+ let x = (i & 43690) >>> 1 | (i & 21845) << 1;
3742
+ x = (x & 52428) >>> 2 | (x & 13107) << 2;
3743
+ x = (x & 61680) >>> 4 | (x & 3855) << 4;
3744
+ rev[i] = ((x & 65280) >>> 8 | (x & 255) << 8) >>> 1;
3745
+ }
3746
+ hMap = (cd, mb, r) => {
3747
+ const s = cd.length;
3748
+ let i = 0;
3749
+ const l = new u16(mb);
3750
+ for (; i < s; ++i) {
3751
+ if (cd[i]) ++l[cd[i] - 1];
4449
3752
  }
4450
- compressSync(input) {
4451
- var _a, _b, _c;
4452
- if (!isBrowser && ((_a = this.options.deflate) == null ? void 0 : _a.useZlib)) {
4453
- const buffer = ((_b = this.options.deflate) == null ? void 0 : _b.gzip) ? import_zlib.default.gzipSync(input) : import_zlib.default.deflateSync(input);
4454
- return toArrayBuffer2(buffer);
4455
- }
4456
- const bytes = new Uint8Array(input);
4457
- const options = this.options.deflate || {};
4458
- const output = this.options.raw ? deflateSync(bytes, options) : ((_c = this.options.deflate) == null ? void 0 : _c.gzip) ? gzipSync(bytes, options) : zlibSync(bytes, options);
4459
- return toArrayBuffer2(output);
3753
+ const le = new u16(mb);
3754
+ for (i = 0; i < mb; ++i) {
3755
+ le[i] = le[i - 1] + l[i - 1] << 1;
4460
3756
  }
4461
- decompressSync(input) {
4462
- var _a, _b, _c;
4463
- if (!isBrowser && ((_a = this.options.deflate) == null ? void 0 : _a.useZlib)) {
4464
- const buffer = ((_b = this.options.deflate) == null ? void 0 : _b.gzip) ? import_zlib.default.gunzipSync(input) : import_zlib.default.inflateSync(input);
4465
- return toArrayBuffer2(buffer);
3757
+ let co;
3758
+ if (r) {
3759
+ co = new u16(1 << mb);
3760
+ const rvb = 15 - mb;
3761
+ for (i = 0; i < s; ++i) {
3762
+ if (cd[i]) {
3763
+ const sv = i << 4 | cd[i];
3764
+ const r2 = mb - cd[i];
3765
+ let v = le[cd[i] - 1]++ << r2;
3766
+ for (const m = v | (1 << r2) - 1; v <= m; ++v) {
3767
+ co[rev[v] >>> rvb] = sv;
3768
+ }
3769
+ }
4466
3770
  }
4467
- const bytes = new Uint8Array(input);
4468
- const output = this.options.raw ? inflateSync(bytes) : ((_c = this.options.deflate) == null ? void 0 : _c.gzip) ? gunzipSync(bytes) : unzlibSync(bytes);
4469
- return toArrayBuffer2(output);
4470
- }
4471
- async *compressBatches(inputBatches) {
4472
- var _a, _b, _c;
4473
- if (!this.options.raw && ((_a = this.options.deflate) == null ? void 0 : _a.useNative) !== false) {
4474
- const format = ((_b = this.options.deflate) == null ? void 0 : _b.gzip) ? "gzip" : "deflate";
4475
- const nativeBatches = compressBatchesWithNativeCompressionStream(inputBatches, format);
4476
- if (nativeBatches) {
4477
- yield* nativeBatches;
4478
- return;
3771
+ } else {
3772
+ co = new u16(s);
3773
+ for (i = 0; i < s; ++i) {
3774
+ if (cd[i]) {
3775
+ co[i] = rev[le[cd[i] - 1]++] >>> 15 - cd[i];
4479
3776
  }
4480
3777
  }
4481
- const options = this.options.deflate || {};
4482
- const processor = ((_c = this.options.deflate) == null ? void 0 : _c.gzip) ? new Gzip(options) : this.options.raw ? new Deflate(options) : new Zlib(options);
4483
- yield* this.transformBatches(processor, inputBatches);
4484
3778
  }
4485
- async *decompressBatches(inputBatches) {
4486
- var _a, _b, _c;
4487
- const format = this.options.raw ? "deflate-raw" : ((_a = this.options.deflate) == null ? void 0 : _a.gzip) ? "gzip" : "deflate";
4488
- if (((_b = this.options.deflate) == null ? void 0 : _b.useNative) !== false) {
4489
- const nativeBatches = decompressBatchesWithNativeDecompressionStream(inputBatches, format);
4490
- if (nativeBatches) {
4491
- yield* nativeBatches;
4492
- return;
3779
+ return co;
3780
+ };
3781
+ flt = new u8(288);
3782
+ for (let i = 0; i < 144; ++i) flt[i] = 8;
3783
+ for (let i = 144; i < 256; ++i) flt[i] = 9;
3784
+ for (let i = 256; i < 280; ++i) flt[i] = 7;
3785
+ for (let i = 280; i < 288; ++i) flt[i] = 8;
3786
+ fdt = new u8(32);
3787
+ for (let i = 0; i < 32; ++i) fdt[i] = 5;
3788
+ flrm = /* @__PURE__ */ hMap(flt, 9, 1);
3789
+ fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
3790
+ max = (a) => {
3791
+ let m = a[0];
3792
+ for (let i = 1; i < a.length; ++i) {
3793
+ if (a[i] > m) m = a[i];
3794
+ }
3795
+ return m;
3796
+ };
3797
+ bits = (d, p, m) => {
3798
+ const o = p / 8 | 0;
3799
+ return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
3800
+ };
3801
+ bits16 = (d, p) => {
3802
+ const o = p / 8 | 0;
3803
+ return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
3804
+ };
3805
+ shft = (p) => (p + 7) / 8 | 0;
3806
+ slc = (v, s, e) => {
3807
+ if (s == null || s < 0) s = 0;
3808
+ if (e == null || e > v.length) e = v.length;
3809
+ const n = new (v.BYTES_PER_ELEMENT == 2 ? u16 : v.BYTES_PER_ELEMENT == 4 ? u32 : u8)(e - s);
3810
+ n.set(v.subarray(s, e));
3811
+ return n;
3812
+ };
3813
+ ec = [
3814
+ "unexpected EOF",
3815
+ "invalid block type",
3816
+ "invalid length/literal",
3817
+ "invalid distance",
3818
+ "stream finished",
3819
+ "no stream handler",
3820
+ ,
3821
+ // determined by compression function
3822
+ "no callback",
3823
+ "invalid UTF-8 data",
3824
+ "extra field too long",
3825
+ "date not in range 1980-2099",
3826
+ "filename too long",
3827
+ "stream finishing",
3828
+ "invalid zip data"
3829
+ // determined by unknown compression method
3830
+ ];
3831
+ err = (ind, msg, nt) => {
3832
+ const e = new Error(msg || ec[ind]);
3833
+ e.code = ind;
3834
+ if (Error.captureStackTrace) Error.captureStackTrace(e, err);
3835
+ if (!nt) throw e;
3836
+ return e;
3837
+ };
3838
+ inflt = (dat, buf, st) => {
3839
+ const sl = dat.length;
3840
+ if (!sl || st && st.f && !st.l) return buf || new u8(0);
3841
+ const noBuf = !buf || st;
3842
+ const noSt = !st || st.i;
3843
+ if (!st) st = {};
3844
+ if (!buf) buf = new u8(sl * 3);
3845
+ const cbuf = (l) => {
3846
+ let bl = buf.length;
3847
+ if (l > bl) {
3848
+ const nbuf = new u8(Math.max(bl * 2, l));
3849
+ nbuf.set(buf);
3850
+ buf = nbuf;
3851
+ }
3852
+ };
3853
+ let final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
3854
+ const tbts = sl * 8;
3855
+ do {
3856
+ if (!lm) {
3857
+ final = bits(dat, pos, 1);
3858
+ const type = bits(dat, pos + 1, 3);
3859
+ pos += 3;
3860
+ if (!type) {
3861
+ const s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
3862
+ if (t > sl) {
3863
+ if (noSt) err(0);
3864
+ break;
3865
+ }
3866
+ if (noBuf) cbuf(bt + l);
3867
+ buf.set(dat.subarray(s, t), bt);
3868
+ st.b = bt += l, st.p = pos = t * 8, st.f = final;
3869
+ continue;
3870
+ } else if (type == 1) lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
3871
+ else if (type == 2) {
3872
+ const hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
3873
+ const tl = hLit + bits(dat, pos + 5, 31) + 1;
3874
+ pos += 14;
3875
+ const ldt = new u8(tl);
3876
+ const clt = new u8(19);
3877
+ for (let i = 0; i < hcLen; ++i) {
3878
+ clt[clim[i]] = bits(dat, pos + i * 3, 7);
3879
+ }
3880
+ pos += hcLen * 3;
3881
+ const clb = max(clt), clbmsk = (1 << clb) - 1;
3882
+ const clm = hMap(clt, clb, 1);
3883
+ for (let i = 0; i < tl; ) {
3884
+ const r = clm[bits(dat, pos, clbmsk)];
3885
+ pos += r & 15;
3886
+ const s = r >>> 4;
3887
+ if (s < 16) {
3888
+ ldt[i++] = s;
3889
+ } else {
3890
+ let c = 0, n = 0;
3891
+ if (s == 16) n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
3892
+ else if (s == 17) n = 3 + bits(dat, pos, 7), pos += 3;
3893
+ else if (s == 18) n = 11 + bits(dat, pos, 127), pos += 7;
3894
+ while (n--) ldt[i++] = c;
3895
+ }
3896
+ }
3897
+ const lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
3898
+ lbt = max(lt);
3899
+ dbt = max(dt);
3900
+ lm = hMap(lt, lbt, 1);
3901
+ dm = hMap(dt, dbt, 1);
3902
+ } else err(1);
3903
+ if (pos > tbts) {
3904
+ if (noSt) err(0);
3905
+ break;
4493
3906
  }
4494
3907
  }
4495
- const processor = ((_c = this.options.deflate) == null ? void 0 : _c.gzip) ? new Gunzip() : this.options.raw ? new Inflate() : new Unzlib();
4496
- yield* this.transformBatches(processor, inputBatches);
4497
- }
4498
- /**
4499
- * Streams batches through a DEFLATE-compatible processor.
4500
- *
4501
- * @deprecated Prefer `compressBatches` or `decompressBatches`. Retained for
4502
- * compatibility with callers that supplied a Pako-style processor.
4503
- */
4504
- async *transformBatches(processor, inputBatches) {
4505
- const chunks = [];
4506
- const appendChunk = (data) => {
4507
- chunks.push(new Uint8Array(data).slice().buffer);
4508
- };
4509
- processor.ondata = appendChunk;
4510
- processor.onData = appendChunk;
4511
- processor.onEnd = (status) => {
4512
- if (status !== 0) {
4513
- throw new Error(`${this.name}: streaming processor failed with status ${status}`);
3908
+ if (noBuf) cbuf(bt + 131072);
3909
+ const lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
3910
+ let lpos = pos;
3911
+ for (; ; lpos = pos) {
3912
+ const c = lm[bits16(dat, pos) & lms], sym = c >>> 4;
3913
+ pos += c & 15;
3914
+ if (pos > tbts) {
3915
+ if (noSt) err(0);
3916
+ break;
4514
3917
  }
4515
- };
4516
- for await (const batch of inputBatches) {
4517
- const result2 = processor.push(new Uint8Array(batch), false);
4518
- if (result2 === false) {
4519
- throw new Error(`${this.name}: streaming processor rejected a batch`);
3918
+ if (!c) err(2);
3919
+ if (sym < 256) buf[bt++] = sym;
3920
+ else if (sym == 256) {
3921
+ lpos = pos, lm = void 0;
3922
+ break;
3923
+ } else {
3924
+ let add = sym - 254;
3925
+ if (sym > 264) {
3926
+ const i = sym - 257, b = fleb[i];
3927
+ add = bits(dat, pos, (1 << b) - 1) + fl[i];
3928
+ pos += b;
3929
+ }
3930
+ const d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;
3931
+ if (!d) err(3);
3932
+ pos += d & 15;
3933
+ let dt = fd[dsym];
3934
+ if (dsym > 3) {
3935
+ const b = fdeb[dsym];
3936
+ dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
3937
+ }
3938
+ if (pos > tbts) {
3939
+ if (noSt) err(0);
3940
+ break;
3941
+ }
3942
+ if (noBuf) cbuf(bt + 131072);
3943
+ const end = bt + add;
3944
+ for (; bt < end; bt += 4) {
3945
+ buf[bt] = buf[bt - dt];
3946
+ buf[bt + 1] = buf[bt + 1 - dt];
3947
+ buf[bt + 2] = buf[bt + 2 - dt];
3948
+ buf[bt + 3] = buf[bt + 3 - dt];
3949
+ }
3950
+ bt = end;
4520
3951
  }
4521
- yield* chunks.splice(0);
4522
3952
  }
4523
- const result = processor.push(new Uint8Array(0), true);
4524
- if (result === false) {
4525
- throw new Error(`${this.name}: streaming processor rejected the final batch`);
4526
- }
4527
- yield* chunks;
4528
- }
3953
+ st.l = lm, st.p = lpos, st.b = bt, st.f = final;
3954
+ if (lm) final = 1, st.m = lbt, st.d = dm, st.n = dbt;
3955
+ } while (!final);
3956
+ return bt == buf.length ? buf : slc(buf, 0, bt);
4529
3957
  };
4530
- }
4531
- });
4532
-
4533
- // ../compression/src/lib/gzip-compression.ts
4534
- var gzip_compression_exports = {};
4535
- __export(gzip_compression_exports, {
4536
- GZipCompression: () => GZipCompression
4537
- });
4538
- var GZipCompression;
4539
- var init_gzip_compression = __esm({
4540
- "../compression/src/lib/gzip-compression.ts"() {
4541
- "use strict";
4542
- init_deflate_compression();
4543
- GZipCompression = class extends DeflateCompression {
4544
- name = "gzip";
4545
- extensions = ["gz", "gzip"];
4546
- contentEncodings = ["gzip", "x-gzip"];
4547
- isSupported = true;
4548
- constructor(options) {
4549
- var _a;
4550
- super({
4551
- ...options,
4552
- deflate: {
4553
- ...options == null ? void 0 : options.gzip,
4554
- gzip: true,
4555
- useNative: (options == null ? void 0 : options.useNative) ?? ((_a = options == null ? void 0 : options.gzip) == null ? void 0 : _a.useNative)
4556
- }
4557
- });
4558
- }
3958
+ gzs = (d) => {
3959
+ if (d[0] != 31 || d[1] != 139 || d[2] != 8) err(6, "invalid gzip data");
3960
+ const flg = d[3];
3961
+ let st = 10;
3962
+ if (flg & 4) st += d[10] | (d[11] << 8) + 2;
3963
+ for (let zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++]) ;
3964
+ return st + (flg & 2);
4559
3965
  };
4560
- }
4561
- });
4562
-
4563
- // ../compression/src/lib/no-compression.ts
4564
- var no_compression_exports = {};
4565
- __export(no_compression_exports, {
4566
- NoCompression: () => NoCompression
4567
- });
4568
- var NoCompression;
4569
- var init_no_compression = __esm({
4570
- "../compression/src/lib/no-compression.ts"() {
4571
- "use strict";
4572
- init_compression();
4573
- NoCompression = class extends Compression {
4574
- name = "uncompressed";
4575
- extensions = [];
4576
- contentEncodings = [];
4577
- isSupported = true;
4578
- options;
4579
- constructor(options) {
4580
- super(options);
4581
- this.options = options || {};
4582
- }
4583
- compressSync(input) {
4584
- return input;
4585
- }
4586
- decompressSync(input) {
4587
- return input;
4588
- }
4589
- async *compressBatches(asyncIterator) {
4590
- return yield* asyncIterator;
4591
- }
4592
- async *decompressBatches(asyncIterator) {
4593
- return yield* asyncIterator;
4594
- }
3966
+ gzl = (d) => {
3967
+ const l = d.length;
3968
+ return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;
4595
3969
  };
4596
- }
4597
- });
4598
-
4599
- // ../compression/src/lib/native-decompressor.ts
4600
- var native_decompressor_exports = {};
4601
- __export(native_decompressor_exports, {
4602
- NativeDecompressor: () => NativeDecompressor
4603
- });
4604
- var NativeDecompressor;
4605
- var init_native_decompressor = __esm({
4606
- "../compression/src/lib/native-decompressor.ts"() {
4607
- "use strict";
4608
- init_compression();
4609
- init_decompression_stream();
4610
- NativeDecompressor = class extends Decompressor {
4611
- name;
4612
- extensions;
4613
- contentEncodings;
4614
- isSupported = true;
4615
- /** Runtime stream format used for every operation. */
4616
- format;
4617
- constructor(metadata, format, options = {}) {
4618
- super(options);
4619
- this.name = metadata.name;
4620
- this.extensions = [...metadata.extensions];
4621
- this.contentEncodings = [...metadata.contentEncodings];
4622
- this.format = format;
3970
+ zlv = (d) => {
3971
+ if ((d[0] & 15) != 8 || d[0] >>> 4 > 7 || (d[0] << 8 | d[1]) % 31) err(6, "invalid zlib data");
3972
+ if (d[1] & 32) err(6, "invalid zlib data: preset dictionaries not supported");
3973
+ };
3974
+ Inflate = class {
3975
+ /**
3976
+ * Creates an inflation stream
3977
+ * @param cb The callback to call whenever data is inflated
3978
+ */
3979
+ constructor(cb) {
3980
+ this.ondata = cb;
4623
3981
  }
4624
- /** Decompresses one buffer with the runtime-provided stream. */
4625
- async decompress(input) {
4626
- const output = await decompressWithNativeDecompressionStream(input, this.format);
4627
- if (!output) throw new Error(`${this.name}: built-in decompression is no longer available`);
4628
- return output;
3982
+ /** Persistent bit-reader and Huffman decoding state. */
3983
+ s = {};
3984
+ /** Compression options or retained output window for this stream. */
3985
+ o;
3986
+ /** Compressed bytes pending decoding. */
3987
+ p = new u8(0);
3988
+ /** Whether the stream has received its final chunk. */
3989
+ d;
3990
+ /**
3991
+ * The handler to call whenever data is available
3992
+ */
3993
+ ondata;
3994
+ /** Appends pending input after checking stream lifecycle. */
3995
+ e(c) {
3996
+ if (!this.ondata) err(5);
3997
+ if (this.d) err(4);
3998
+ const l = this.p.length;
3999
+ const n = new u8(l + c.length);
4000
+ n.set(this.p), n.set(c, l), this.p = n;
4629
4001
  }
4630
- /** Decompresses batches incrementally with the runtime-provided stream. */
4631
- async *decompressBatches(inputBatches) {
4632
- const output = decompressBatchesWithNativeDecompressionStream(inputBatches, this.format);
4633
- if (!output) throw new Error(`${this.name}: built-in decompression is no longer available`);
4634
- yield* output;
4002
+ /** Decodes pending input and retains the sliding window. */
4003
+ c(final) {
4004
+ this.d = this.s.i = final || false;
4005
+ const bts = this.s.b;
4006
+ const dt = inflt(this.p, this.o, this.s);
4007
+ this.ondata(slc(dt, bts, this.s.b), this.d);
4008
+ this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
4009
+ this.p = slc(this.p, this.s.p / 8 | 0), this.s.p &= 7;
4010
+ }
4011
+ /**
4012
+ * Pushes a chunk to be inflated
4013
+ * @param chunk The chunk to push
4014
+ * @param final Whether this is the final chunk
4015
+ */
4016
+ push(chunk, final) {
4017
+ this.e(chunk), this.c(final);
4635
4018
  }
4636
4019
  };
4637
- }
4638
- });
4639
-
4640
- // ../compression/src/lib/lazy-compression.ts
4641
- function mergeModules(options, modules) {
4642
- return { ...options, modules: { ...options.modules, ...modules } };
4643
- }
4644
- var LazyDecompressor;
4645
- var init_lazy_compression = __esm({
4646
- "../compression/src/lib/lazy-compression.ts"() {
4647
- "use strict";
4648
- init_compression();
4649
- init_decompression_stream();
4650
- LazyDecompressor = class extends Decompressor {
4651
- name;
4652
- extensions;
4653
- contentEncodings;
4654
- isSupported = true;
4655
- /** Constructor options retained until a concrete implementation is selected. */
4656
- options;
4657
- /** Built-in stream format to probe, or null when the format has no built-in path. */
4658
- nativeFormat;
4659
- /** Returns whether built-in selection remains eligible for the merged preload options. */
4660
- shouldUseNative;
4661
- /** Dynamically imports the balanced fallback constructor. */
4662
- loadFallback;
4663
- /** Selected concrete implementation after preload completes. */
4664
- implementation = null;
4665
- /** Shared in-flight selection used by concurrent asynchronous calls. */
4666
- implementationPromise = null;
4667
- constructor(metadata, loadFallback, options = {}, nativeFormat = null, shouldUseNative = () => true) {
4668
- super(options);
4669
- this.name = metadata.name;
4670
- this.extensions = [...metadata.extensions];
4671
- this.contentEncodings = [...metadata.contentEncodings];
4672
- this.options = options;
4673
- this.nativeFormat = nativeFormat;
4674
- this.shouldUseNative = shouldUseNative;
4675
- this.loadFallback = loadFallback;
4020
+ Gunzip = class extends Inflate {
4021
+ /** Whether the stream header still needs to be emitted or consumed. */
4022
+ v = 1;
4023
+ /**
4024
+ * Creates a GUNZIP stream
4025
+ * @param cb The callback to call whenever data is inflated
4026
+ */
4027
+ constructor(cb) {
4028
+ super(cb);
4676
4029
  }
4677
- /** Selects and returns the built-in or dynamically imported fallback decompressor. */
4678
- async preload(modules = {}) {
4679
- if (this.implementation) return this.implementation;
4680
- const options = mergeModules(this.options, modules);
4681
- this.implementationPromise ||= this.loadImplementation(options);
4682
- try {
4683
- this.implementation = await this.implementationPromise;
4684
- return this.implementation;
4685
- } catch (error) {
4686
- this.implementationPromise = null;
4687
- throw error;
4030
+ /**
4031
+ * Pushes a chunk to be GUNZIPped
4032
+ * @param chunk The chunk to push
4033
+ * @param final Whether this is the last chunk
4034
+ */
4035
+ push(chunk, final) {
4036
+ Inflate.prototype.e.call(this, chunk);
4037
+ if (this.v) {
4038
+ const s = this.p.length > 3 ? gzs(this.p) : 4;
4039
+ if (s >= this.p.length && !final) return;
4040
+ this.p = this.p.subarray(s), this.v = 0;
4688
4041
  }
4689
- }
4690
- /** Loads the selected concrete decompressor. */
4691
- async loadImplementation(options) {
4692
- if (options.useNative !== false && this.nativeFormat && this.shouldUseNative(options) && isNativeDecompressionSupported(this.nativeFormat)) {
4693
- const { NativeDecompressor: NativeDecompressor2 } = await Promise.resolve().then(() => (init_native_decompressor(), native_decompressor_exports));
4694
- return new NativeDecompressor2(this, this.nativeFormat, options);
4042
+ if (final) {
4043
+ if (this.p.length < 8) err(6, "invalid gzip data");
4044
+ this.p = this.p.subarray(0, -8);
4695
4045
  }
4696
- const Decompressor2 = await this.loadFallback();
4697
- const implementation = new Decompressor2({ ...options, useNative: false });
4698
- await implementation.preload(options.modules);
4699
- return implementation;
4046
+ Inflate.prototype.c.call(this, final);
4700
4047
  }
4701
- /** Decompresses after lazily selecting the default implementation. */
4702
- async decompress(input, size) {
4703
- return (await this.preload()).decompress(input, size);
4048
+ };
4049
+ Unzlib = class extends Inflate {
4050
+ /** Whether the stream header still needs to be emitted or consumed. */
4051
+ v = 1;
4052
+ /**
4053
+ * Creates a Zlib decompression stream
4054
+ * @param cb The callback to call whenever data is inflated
4055
+ */
4056
+ constructor(cb) {
4057
+ super(cb);
4704
4058
  }
4705
- /** Decompresses synchronously after an implementation has been preloaded. */
4706
- decompressSync(input, size) {
4707
- if (!this.implementation) {
4708
- throw new Error(`${this.name}: call preload() before decompressSync()`);
4059
+ /**
4060
+ * Pushes a chunk to be unzlibbed
4061
+ * @param chunk The chunk to push
4062
+ * @param final Whether this is the last chunk
4063
+ */
4064
+ push(chunk, final) {
4065
+ Inflate.prototype.e.call(this, chunk);
4066
+ if (this.v) {
4067
+ if (this.p.length < 2 && !final) return;
4068
+ this.p = this.p.subarray(2), this.v = 0;
4709
4069
  }
4710
- return this.implementation.decompressSync(input, size);
4711
- }
4712
- /** Decompresses batches after lazily selecting the default implementation. */
4713
- async *decompressBatches(inputBatches) {
4714
- yield* (await this.preload()).decompressBatches(inputBatches);
4070
+ if (final) {
4071
+ if (this.p.length < 4) err(6, "invalid zlib data");
4072
+ this.p = this.p.subarray(0, -4);
4073
+ }
4074
+ Inflate.prototype.c.call(this, final);
4715
4075
  }
4716
4076
  };
4717
4077
  }
@@ -4736,6 +4096,79 @@ var init_fflate_stream = __esm({
4736
4096
  }
4737
4097
  });
4738
4098
 
4099
+ // ../compression/src/deflate-decompressor-fflate.ts
4100
+ var DeflateFflateDecompressor;
4101
+ var init_deflate_decompressor_fflate = __esm({
4102
+ "../compression/src/deflate-decompressor-fflate.ts"() {
4103
+ "use strict";
4104
+ init_fflate();
4105
+ init_compression();
4106
+ init_fflate_stream();
4107
+ DeflateFflateDecompressor = class extends Decompressor {
4108
+ name = "deflate";
4109
+ extensions = [];
4110
+ contentEncodings = ["deflate"];
4111
+ isSupported = true;
4112
+ options;
4113
+ constructor(options = {}) {
4114
+ super(options);
4115
+ this.options = options;
4116
+ }
4117
+ /** Decompresses one zlib-wrapped DEFLATE payload synchronously. */
4118
+ decompressSync(input) {
4119
+ const bytes = new Uint8Array(input);
4120
+ const output = this.options.raw ? inflateSync(bytes) : unzlibSync(bytes);
4121
+ return output.slice().buffer;
4122
+ }
4123
+ /** Decompresses DEFLATE batches incrementally. */
4124
+ async *decompressBatches(inputBatches) {
4125
+ const processor = this.options.raw ? new Inflate() : new Unzlib();
4126
+ yield* transformFflateBatches(processor, inputBatches);
4127
+ }
4128
+ };
4129
+ }
4130
+ });
4131
+
4132
+ // ../compression/src/deflate-decompressor.ts
4133
+ var deflate_decompressor_exports = {};
4134
+ __export(deflate_decompressor_exports, {
4135
+ DeflateDecompressor: () => DeflateDecompressor
4136
+ });
4137
+ var DeflateDecompressor;
4138
+ var init_deflate_decompressor = __esm({
4139
+ "../compression/src/deflate-decompressor.ts"() {
4140
+ "use strict";
4141
+ init_deflate_decompressor_fflate();
4142
+ init_decompression_stream();
4143
+ DeflateDecompressor = class extends DeflateFflateDecompressor {
4144
+ constructor(options = {}) {
4145
+ super(options);
4146
+ }
4147
+ /** Decompresses with the built-in stream when available, then falls back to fflate. */
4148
+ async decompress(input) {
4149
+ if (this.options.useNative !== false) {
4150
+ const format = this.options.raw ? "deflate-raw" : "deflate";
4151
+ const output = await decompressWithNativeDecompressionStream(input, format);
4152
+ if (output) return output;
4153
+ }
4154
+ return this.decompressSync(input);
4155
+ }
4156
+ /** Decompresses batches with a built-in or fflate stream. */
4157
+ async *decompressBatches(inputBatches) {
4158
+ if (this.options.useNative !== false) {
4159
+ const format = this.options.raw ? "deflate-raw" : "deflate";
4160
+ const output = decompressBatchesWithNativeDecompressionStream(inputBatches, format);
4161
+ if (output) {
4162
+ yield* output;
4163
+ return;
4164
+ }
4165
+ }
4166
+ yield* super.decompressBatches(inputBatches);
4167
+ }
4168
+ };
4169
+ }
4170
+ });
4171
+
4739
4172
  // ../compression/src/gzip-decompressor-fflate.ts
4740
4173
  var GZipFflateDecompressor;
4741
4174
  var init_gzip_decompressor_fflate = __esm({
@@ -6890,13 +6323,13 @@ var brotli_compression_exports = {};
6890
6323
  __export(brotli_compression_exports, {
6891
6324
  BrotliCompression: () => BrotliCompression
6892
6325
  });
6893
- var import_zlib2, DEFAULT_BROTLI_OPTIONS, BrotliCompression;
6326
+ var import_zlib, DEFAULT_BROTLI_OPTIONS, BrotliCompression;
6894
6327
  var init_brotli_compression = __esm({
6895
6328
  "../compression/src/lib/brotli-compression.ts"() {
6896
6329
  "use strict";
6897
6330
  init_compression();
6898
6331
  init_src2();
6899
- import_zlib2 = __toESM(require("zlib"), 1);
6332
+ import_zlib = __toESM(require("zlib"), 1);
6900
6333
  init_compression_stream();
6901
6334
  init_decompression_stream();
6902
6335
  DEFAULT_BROTLI_OPTIONS = {
@@ -6940,7 +6373,7 @@ var init_brotli_compression = __esm({
6940
6373
  const nativeOutput = await compressWithNativeCompressionStream(input, "brotli");
6941
6374
  if (nativeOutput) return nativeOutput;
6942
6375
  if (!isBrowser && ((_a = this.options.brotli) == null ? void 0 : _a.useZlib)) {
6943
- const buffer = await promisify1(import_zlib2.default.brotliCompress)(input);
6376
+ const buffer = await promisify1(import_zlib.default.brotliCompress)(input);
6944
6377
  return toArrayBuffer2(buffer);
6945
6378
  }
6946
6379
  return this.compressSync(input);
@@ -6948,7 +6381,7 @@ var init_brotli_compression = __esm({
6948
6381
  compressSync(input) {
6949
6382
  var _a, _b;
6950
6383
  if (!isBrowser && ((_a = this.options.brotli) == null ? void 0 : _a.useZlib)) {
6951
- const buffer = import_zlib2.default.brotliCompressSync(input);
6384
+ const buffer = import_zlib.default.brotliCompressSync(input);
6952
6385
  return toArrayBuffer2(buffer);
6953
6386
  }
6954
6387
  const brotliOptions = { ...DEFAULT_BROTLI_OPTIONS.brotli, ...(_b = this.options) == null ? void 0 : _b.brotli };
@@ -6967,7 +6400,7 @@ var init_brotli_compression = __esm({
6967
6400
  if (nativeOutput) return nativeOutput;
6968
6401
  }
6969
6402
  if (!isBrowser && ((_a = this.options.brotli) == null ? void 0 : _a.useZlib)) {
6970
- const buffer = await promisify1(import_zlib2.default.brotliDecompress)(input);
6403
+ const buffer = await promisify1(import_zlib.default.brotliDecompress)(input);
6971
6404
  return toArrayBuffer2(buffer);
6972
6405
  }
6973
6406
  await this.preload();
@@ -6976,7 +6409,7 @@ var init_brotli_compression = __esm({
6976
6409
  decompressSync(input) {
6977
6410
  var _a, _b;
6978
6411
  if (!isBrowser && ((_a = this.options.brotli) == null ? void 0 : _a.useZlib)) {
6979
- const buffer = import_zlib2.default.brotliDecompressSync(input);
6412
+ const buffer = import_zlib.default.brotliDecompressSync(input);
6980
6413
  return toArrayBuffer2(buffer);
6981
6414
  }
6982
6415
  const brotliOptions = { ...DEFAULT_BROTLI_OPTIONS.brotli, ...(_b = this.options) == null ? void 0 : _b.brotli };
@@ -7122,10 +6555,6 @@ var init_snappy_decompressor = __esm({
7122
6555
  });
7123
6556
 
7124
6557
  // ../compression/src/lib/lz4-compression.ts
7125
- var lz4_compression_exports = {};
7126
- __export(lz4_compression_exports, {
7127
- LZ4Compression: () => LZ4Compression
7128
- });
7129
6558
  function readUInt32BE(data, offset) {
7130
6559
  return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
7131
6560
  }
@@ -7528,18 +6957,150 @@ var init_zstd_decompressor = __esm({
7528
6957
  }
7529
6958
  });
7530
6959
 
6960
+ // ../compression/src/lib/compress-utils-compression.ts
6961
+ async function* transformBatches2(stream, inputBatches) {
6962
+ try {
6963
+ for await (const input of inputBatches) {
6964
+ const output2 = stream.write(new Uint8Array(input));
6965
+ if (output2.byteLength > 0) yield copyArrayBuffer(output2);
6966
+ }
6967
+ const output = stream.finish();
6968
+ if (output.byteLength > 0) yield copyArrayBuffer(output);
6969
+ } finally {
6970
+ stream.destroy();
6971
+ }
6972
+ }
6973
+ function copyArrayBuffer(bytes) {
6974
+ return bytes.slice().buffer;
6975
+ }
6976
+ var CompressUtilsDecompressor;
6977
+ var init_compress_utils_compression = __esm({
6978
+ "../compression/src/lib/compress-utils-compression.ts"() {
6979
+ "use strict";
6980
+ init_compression();
6981
+ CompressUtilsDecompressor = class extends Decompressor {
6982
+ name;
6983
+ extensions;
6984
+ contentEncodings;
6985
+ isSupported = true;
6986
+ options;
6987
+ loadModule;
6988
+ /** Creates a format-specific compress-utils decoder. */
6989
+ constructor(metadata, loadModule, options = {}) {
6990
+ super(options);
6991
+ this.name = metadata.name;
6992
+ this.extensions = metadata.extensions || [];
6993
+ this.contentEncodings = metadata.contentEncodings || [];
6994
+ this.loadModule = loadModule;
6995
+ this.options = options;
6996
+ }
6997
+ /** Decompresses one buffer with the selected compress-utils decoder. */
6998
+ async decompress(input) {
6999
+ const module2 = await this.loadModule();
7000
+ const output = await module2.decompress(new Uint8Array(input), this.options.compressUtils);
7001
+ return copyArrayBuffer(output);
7002
+ }
7003
+ /** Incrementally decompresses input batches with compress-utils. */
7004
+ async *decompressBatches(inputBatches) {
7005
+ const module2 = await this.loadModule();
7006
+ const stream = await module2.createDecompressStream();
7007
+ yield* transformBatches2(stream, inputBatches);
7008
+ }
7009
+ };
7010
+ }
7011
+ });
7012
+
7013
+ // ../compression/src/bzip2-decompressor-compress-utils.ts
7014
+ var BZip2CompressUtilsDecompressor;
7015
+ var init_bzip2_decompressor_compress_utils = __esm({
7016
+ "../compression/src/bzip2-decompressor-compress-utils.ts"() {
7017
+ "use strict";
7018
+ init_compress_utils_compression();
7019
+ BZip2CompressUtilsDecompressor = class extends CompressUtilsDecompressor {
7020
+ constructor(options = {}) {
7021
+ super(
7022
+ { name: "bzip2", extensions: ["bz2"], contentEncodings: ["bzip2"] },
7023
+ () => import("compress-utils/bz2/decompress"),
7024
+ options
7025
+ );
7026
+ }
7027
+ };
7028
+ }
7029
+ });
7030
+
7031
+ // ../compression/src/bzip2-decompressor.ts
7032
+ var bzip2_decompressor_exports = {};
7033
+ __export(bzip2_decompressor_exports, {
7034
+ BZip2Decompressor: () => BZip2Decompressor
7035
+ });
7036
+ var BZip2Decompressor;
7037
+ var init_bzip2_decompressor = __esm({
7038
+ "../compression/src/bzip2-decompressor.ts"() {
7039
+ "use strict";
7040
+ init_bzip2_decompressor_compress_utils();
7041
+ BZip2Decompressor = class extends BZip2CompressUtilsDecompressor {
7042
+ };
7043
+ }
7044
+ });
7045
+
7046
+ // ../compression/src/xz-decompressor-compress-utils.ts
7047
+ var XZCompressUtilsDecompressor;
7048
+ var init_xz_decompressor_compress_utils = __esm({
7049
+ "../compression/src/xz-decompressor-compress-utils.ts"() {
7050
+ "use strict";
7051
+ init_compress_utils_compression();
7052
+ XZCompressUtilsDecompressor = class extends CompressUtilsDecompressor {
7053
+ constructor(options = {}) {
7054
+ super(
7055
+ { name: "xz", extensions: ["xz", "lzma"], contentEncodings: ["xz"] },
7056
+ () => import("compress-utils/xz/decompress"),
7057
+ options
7058
+ );
7059
+ }
7060
+ };
7061
+ }
7062
+ });
7063
+
7064
+ // ../compression/src/xz-decompressor.ts
7065
+ var xz_decompressor_exports = {};
7066
+ __export(xz_decompressor_exports, {
7067
+ XZDecompressor: () => XZDecompressor
7068
+ });
7069
+ var XZDecompressor;
7070
+ var init_xz_decompressor = __esm({
7071
+ "../compression/src/xz-decompressor.ts"() {
7072
+ "use strict";
7073
+ init_xz_decompressor_compress_utils();
7074
+ XZDecompressor = class extends XZCompressUtilsDecompressor {
7075
+ };
7076
+ }
7077
+ });
7078
+
7531
7079
  // ../compression/src/default-codecs.ts
7532
- var GZIP, BROTLI, SNAPPY, LZ4, ZSTD, GZipDecompressor2, BrotliDecompressor2, SnappyDecompressor2, LZ4Decompressor2, ZstdDecompressor2;
7080
+ var DEFLATE, GZIP, BROTLI, SNAPPY, LZ4, ZSTD, BZIP2, XZ, DeflateDecompressor2, GZipDecompressor2, BrotliDecompressor2, SnappyDecompressor2, LZ4Decompressor2, ZstdDecompressor2, BZip2Decompressor2, XZDecompressor2;
7533
7081
  var init_default_codecs = __esm({
7534
7082
  "../compression/src/default-codecs.ts"() {
7535
7083
  "use strict";
7536
7084
  init_lazy_compression();
7537
7085
  init_src2();
7086
+ DEFLATE = { name: "deflate", extensions: [], contentEncodings: ["deflate"] };
7538
7087
  GZIP = { name: "gzip", extensions: ["gz"], contentEncodings: ["gzip"] };
7539
7088
  BROTLI = { name: "brotli", extensions: ["br"], contentEncodings: ["br"] };
7540
7089
  SNAPPY = { name: "snappy", extensions: [], contentEncodings: [] };
7541
7090
  LZ4 = { name: "lz4", extensions: ["lz4"], contentEncodings: ["x-lz4"] };
7542
7091
  ZSTD = { name: "zstd", extensions: ["zst"], contentEncodings: ["zstd"] };
7092
+ BZIP2 = { name: "bzip2", extensions: ["bz2"], contentEncodings: ["bzip2"] };
7093
+ XZ = { name: "xz", extensions: ["xz", "lzma"], contentEncodings: ["xz"] };
7094
+ DeflateDecompressor2 = class extends LazyDecompressor {
7095
+ constructor(options = {}) {
7096
+ super(
7097
+ DEFLATE,
7098
+ async () => (await Promise.resolve().then(() => (init_deflate_decompressor(), deflate_decompressor_exports))).DeflateDecompressor,
7099
+ options,
7100
+ options.raw ? "deflate-raw" : "deflate"
7101
+ );
7102
+ }
7103
+ };
7543
7104
  GZipDecompressor2 = class extends LazyDecompressor {
7544
7105
  constructor(options = {}) {
7545
7106
  super(
@@ -7588,237 +7149,25 @@ var init_default_codecs = __esm({
7588
7149
  );
7589
7150
  }
7590
7151
  };
7591
- }
7592
- });
7593
-
7594
- // ../compression/src/lib/snappy-compression.ts
7595
- var snappy_compression_exports = {};
7596
- __export(snappy_compression_exports, {
7597
- SnappyCompression: () => SnappyCompression
7598
- });
7599
- var SnappyCompression;
7600
- var init_snappy_compression = __esm({
7601
- "../compression/src/lib/snappy-compression.ts"() {
7602
- "use strict";
7603
- init_compression();
7604
- init_src2();
7605
- SnappyCompression = class extends Compression {
7606
- name = "snappy";
7607
- extensions = [];
7608
- contentEncodings = [];
7609
- isSupported = true;
7610
- options;
7611
- constructor(options) {
7612
- super(options);
7613
- this.options = options || {};
7614
- registerJSModules(this.options.modules);
7615
- }
7616
- compressSync(input) {
7617
- const snappy = getJSModule("snappyjs", this.name);
7618
- return snappy.compress(input);
7619
- }
7620
- decompressSync(input) {
7621
- const snappy = getJSModule("snappyjs", this.name);
7622
- return snappy.uncompress(input);
7623
- }
7624
- async preload(modules = {}) {
7625
- registerJSModules(modules);
7626
- if (!getJSModuleOrNull("snappyjs")) {
7627
- const snappy = await import("snappyjs");
7628
- registerJSModules({ snappyjs: snappy.default || snappy });
7629
- }
7630
- }
7631
- };
7632
- }
7633
- });
7634
-
7635
- // ../compression/src/lib/bzip2-compression.ts
7636
- var bzip2_compression_exports = {};
7637
- __export(bzip2_compression_exports, {
7638
- BZip2Compression: () => BZip2Compression
7639
- });
7640
- var BZip2Compression;
7641
- var init_bzip2_compression = __esm({
7642
- "../compression/src/lib/bzip2-compression.ts"() {
7643
- "use strict";
7644
- init_compression();
7645
- BZip2Compression = class extends Compression {
7646
- name = "bzip2";
7647
- extensions = ["bz2"];
7648
- contentEncodings = ["bzip2"];
7649
- isSupported = true;
7650
- options;
7152
+ BZip2Decompressor2 = class extends LazyDecompressor {
7651
7153
  constructor(options = {}) {
7652
- super(options);
7653
- this.options = options;
7654
- }
7655
- /** Decompresses a bzip2 stream. */
7656
- async decompress(input) {
7657
- let decompress4;
7658
- try {
7659
- ({ decompress: decompress4 } = await import("compress-utils/bz2/decompress"));
7660
- } catch (error) {
7661
- throw new Error(
7662
- "BZip2Compression requires the optional compress-utils package. Install compress-utils to decode bzip2 data.",
7663
- { cause: error }
7664
- );
7665
- }
7666
- const output = await decompress4(new Uint8Array(input));
7667
- return output.slice().buffer;
7668
- }
7669
- /** Compresses a bzip2 stream. */
7670
- async compress(input) {
7671
- let compress;
7672
- try {
7673
- ({ compress } = await import("compress-utils/bz2/compress"));
7674
- } catch (error) {
7675
- throw new Error(
7676
- "BZip2Compression requires the optional compress-utils package. Install compress-utils to encode bzip2 data.",
7677
- { cause: error }
7678
- );
7679
- }
7680
- const output = await compress(new Uint8Array(input));
7681
- return output.slice().buffer;
7154
+ super(BZIP2, async () => (await Promise.resolve().then(() => (init_bzip2_decompressor(), bzip2_decompressor_exports))).BZip2Decompressor, options);
7682
7155
  }
7683
7156
  };
7684
- }
7685
- });
7686
-
7687
- // ../compression/src/lib/xz-compression.ts
7688
- var xz_compression_exports = {};
7689
- __export(xz_compression_exports, {
7690
- XZCompression: () => XZCompression
7691
- });
7692
- var XZCompression;
7693
- var init_xz_compression = __esm({
7694
- "../compression/src/lib/xz-compression.ts"() {
7695
- "use strict";
7696
- init_compression();
7697
- XZCompression = class extends Compression {
7698
- name = "xz";
7699
- extensions = ["xz", "lzma"];
7700
- contentEncodings = ["xz"];
7701
- isSupported = true;
7702
- options;
7157
+ XZDecompressor2 = class extends LazyDecompressor {
7703
7158
  constructor(options = {}) {
7704
- super(options);
7705
- this.options = options;
7706
- }
7707
- /** Decompresses an XZ stream. */
7708
- async decompress(input) {
7709
- let decompress4;
7710
- try {
7711
- ({ decompress: decompress4 } = await import("compress-utils/xz/decompress"));
7712
- } catch (error) {
7713
- throw new Error(
7714
- "XZCompression requires the optional compress-utils package. Install compress-utils to decode XZ data.",
7715
- { cause: error }
7716
- );
7717
- }
7718
- const output = await decompress4(new Uint8Array(input));
7719
- return output.slice().buffer;
7720
- }
7721
- /** Compresses an XZ stream. */
7722
- async compress(input) {
7723
- let compress;
7724
- try {
7725
- ({ compress } = await import("compress-utils/xz/compress"));
7726
- } catch (error) {
7727
- throw new Error(
7728
- "XZCompression requires the optional compress-utils package. Install compress-utils to encode XZ data.",
7729
- { cause: error }
7730
- );
7731
- }
7732
- const output = await compress(new Uint8Array(input));
7733
- return output.slice().buffer;
7159
+ super(XZ, async () => (await Promise.resolve().then(() => (init_xz_decompressor(), xz_decompressor_exports))).XZDecompressor, options);
7734
7160
  }
7735
7161
  };
7736
7162
  }
7737
7163
  });
7738
7164
 
7739
- // ../compression/src/compression-metadata.ts
7740
- function createCompressionMetadata(name, extensions, contentEncodings, loadCompression) {
7741
- return {
7742
- name,
7743
- extensions,
7744
- contentEncodings,
7745
- isSupported: true,
7746
- async preload(options = {}) {
7747
- const CompressionConstructor = await loadCompression();
7748
- const compression = new CompressionConstructor(options);
7749
- await compression.preload(options.modules);
7750
- return compression;
7751
- }
7752
- };
7753
- }
7754
- var noCompression, deflateCompression, gzipCompression, brotliCompression, snappyCompression, lz4Compression, zstdCompression, bzip2Compression, xzCompression;
7755
- var init_compression_metadata = __esm({
7756
- "../compression/src/compression-metadata.ts"() {
7757
- "use strict";
7758
- noCompression = createCompressionMetadata(
7759
- "uncompressed",
7760
- [],
7761
- [],
7762
- async () => (await Promise.resolve().then(() => (init_no_compression(), no_compression_exports))).NoCompression
7763
- );
7764
- deflateCompression = createCompressionMetadata(
7765
- "deflate",
7766
- [],
7767
- ["deflate"],
7768
- async () => (await Promise.resolve().then(() => (init_deflate_compression(), deflate_compression_exports))).DeflateCompression
7769
- );
7770
- gzipCompression = createCompressionMetadata(
7771
- "gzip",
7772
- ["gz"],
7773
- ["gzip"],
7774
- async () => (await Promise.resolve().then(() => (init_gzip_compression(), gzip_compression_exports))).GZipCompression
7775
- );
7776
- brotliCompression = createCompressionMetadata(
7777
- "brotli",
7778
- ["br"],
7779
- ["br"],
7780
- async () => (await Promise.resolve().then(() => (init_brotli_compression(), brotli_compression_exports))).BrotliCompression
7781
- );
7782
- snappyCompression = createCompressionMetadata(
7783
- "snappy",
7784
- [],
7785
- [],
7786
- async () => (await Promise.resolve().then(() => (init_snappy_compression(), snappy_compression_exports))).SnappyCompression
7787
- );
7788
- lz4Compression = createCompressionMetadata(
7789
- "lz4",
7790
- [],
7791
- [],
7792
- async () => (await Promise.resolve().then(() => (init_lz4_compression(), lz4_compression_exports))).LZ4Compression
7793
- );
7794
- zstdCompression = createCompressionMetadata(
7795
- "zstd",
7796
- [],
7797
- [],
7798
- async () => (await Promise.resolve().then(() => (init_zstd_compression(), zstd_compression_exports))).ZstdCompression
7799
- );
7800
- bzip2Compression = createCompressionMetadata(
7801
- "bzip2",
7802
- ["bz2"],
7803
- ["bzip2"],
7804
- async () => (await Promise.resolve().then(() => (init_bzip2_compression(), bzip2_compression_exports))).BZip2Compression
7805
- );
7806
- xzCompression = createCompressionMetadata(
7807
- "xz",
7808
- ["xz", "lzma"],
7809
- ["xz"],
7810
- async () => (await Promise.resolve().then(() => (init_xz_compression(), xz_compression_exports))).XZCompression
7811
- );
7812
- }
7813
- });
7814
-
7815
7165
  // ../compression/src/index.ts
7816
7166
  var init_src3 = __esm({
7817
7167
  "../compression/src/index.ts"() {
7818
7168
  "use strict";
7819
7169
  init_compression();
7820
7170
  init_default_codecs();
7821
- init_compression_metadata();
7822
7171
  }
7823
7172
  });
7824
7173
 
@@ -25606,11 +24955,11 @@ function toUint8Array(binary) {
25606
24955
  function toArrayBuffer3(binary) {
25607
24956
  return toUint8Array(binary).slice().buffer;
25608
24957
  }
25609
- var compressionPromises = {};
24958
+ var decompressors = {};
25610
24959
  async function decompressAvro(codec, value) {
25611
24960
  if (codec === "null") return value;
25612
24961
  if (!isAvroCodec(codec)) throw new Error(`avro: unsupported compression codec "${codec}"`);
25613
- const compression = await getAvroCompression(codec);
24962
+ const compression = getAvroDecompressor(codec);
25614
24963
  const compressedValue = codec === "snappy" ? value.subarray(0, -4) : value;
25615
24964
  const output = toUint8Array(await compression.decompress(toArrayBuffer3(compressedValue)));
25616
24965
  if (codec === "snappy") {
@@ -25623,22 +24972,16 @@ async function decompressAvro(codec, value) {
25623
24972
  function isAvroCodec(codec) {
25624
24973
  return codec === "deflate" || codec === "snappy" || codec === "zstandard" || codec === "bzip2" || codec === "xz";
25625
24974
  }
25626
- async function getAvroCompression(codec) {
25627
- compressionPromises[codec] ||= createAvroCompression(codec);
25628
- return await compressionPromises[codec];
25629
- }
25630
- async function createAvroCompression(codec) {
25631
- const metadata = {
25632
- deflate: deflateCompression,
25633
- snappy: snappyCompression,
25634
- zstandard: zstdCompression,
25635
- bzip2: bzip2Compression,
25636
- xz: xzCompression
25637
- }[codec];
25638
- if (metadata) {
25639
- return await metadata.preload(codec === "deflate" ? { raw: true } : {});
25640
- }
25641
- throw new Error(`avro: unsupported compression codec "${codec}"`);
24975
+ function getAvroDecompressor(codec) {
24976
+ const constructors = {
24977
+ deflate: DeflateDecompressor2,
24978
+ snappy: SnappyDecompressor2,
24979
+ zstandard: ZstdDecompressor2,
24980
+ bzip2: BZip2Decompressor2,
24981
+ xz: XZDecompressor2
24982
+ };
24983
+ decompressors[codec] ||= new constructors[codec](codec === "deflate" ? { raw: true } : {});
24984
+ return decompressors[codec];
25642
24985
  }
25643
24986
  function readUInt32BE2(bytes, offset) {
25644
24987
  return bytes[offset] << 24 | bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3];