scream-code 0.18.6 → 0.18.8
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/README.md +6 -3
- package/dist/{app-Ca2pwAk7.mjs → app-Db7f8Kja.mjs} +296 -205
- package/dist/{dispatch-BgO7wAf9.mjs → dispatch-BPfUTccZ.mjs} +505 -129
- package/dist/{dispatch-0mihbsV3.mjs → dispatch-zsFzFFoY.mjs} +1 -1
- package/dist/main.mjs +1 -1
- package/dist/{src-C3oCiVNb.mjs → src-CFHysu0q.mjs} +11 -11
- package/dist/{src-C7C9e5Ds.mjs → src-ClB_Hzp9.mjs} +3355 -100
- package/dist/{src-qit_jRUM.mjs → src-DA34cXSv.mjs} +1 -1
- package/dist/{text-input-dialog-DWepgNF4.mjs → text-input-dialog-CFRUSCi6.mjs} +1 -1
- package/dist/{text-input-dialog-BvbqjvzB.mjs → text-input-dialog-DHDsHCqR.mjs} +60 -4
- package/package.json +3 -4
|
@@ -3,11 +3,22 @@ import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
|
|
|
3
3
|
import { dirname as __cjsShimDirname } from 'node:path';
|
|
4
4
|
const __filename = __cjsShimFileURLToPath(import.meta.url);
|
|
5
5
|
const __dirname = __cjsShimDirname(__filename);
|
|
6
|
-
import { createHash } from "node:crypto";
|
|
7
|
-
import { mkdir, readFile, readdir, rename, rm, rmdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
6
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
7
|
+
import ro, { mkdir, open, readFile, readdir, rename, rm, rmdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
8
|
+
import I from "fs";
|
|
9
|
+
import Qr, { EventEmitter } from "events";
|
|
10
|
+
import js, { dirname, parse } from "path";
|
|
11
|
+
import { Buffer as Buffer$1 } from "buffer";
|
|
12
|
+
import Cs from "node:stream";
|
|
13
|
+
import Kt, { createReadStream, existsSync, mkdirSync, readFileSync, rmSync, statSync } from "node:fs";
|
|
14
|
+
import path, { basename, join, posix, resolve, win32 } from "node:path";
|
|
10
15
|
import { DatabaseSync } from "node:sqlite";
|
|
16
|
+
import { EventEmitter as EventEmitter$1 } from "node:events";
|
|
17
|
+
import { StringDecoder } from "node:string_decoder";
|
|
18
|
+
import zi from "assert";
|
|
19
|
+
import * as Ps from "zlib";
|
|
20
|
+
import en from "zlib";
|
|
21
|
+
import co from "node:assert";
|
|
11
22
|
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
12
23
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
13
24
|
function normalizeWindowsPath(input = "") {
|
|
@@ -140,7 +151,7 @@ const relative$1 = function(from, to) {
|
|
|
140
151
|
}
|
|
141
152
|
return [..._from.map(() => ".."), ..._to].join("/");
|
|
142
153
|
};
|
|
143
|
-
const dirname$
|
|
154
|
+
const dirname$2 = function(p) {
|
|
144
155
|
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
145
156
|
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
146
157
|
return segments.join("/") || (isAbsolute$1(p) ? "/" : ".");
|
|
@@ -157,13 +168,13 @@ const basename$1 = function(p, extension) {
|
|
|
157
168
|
}
|
|
158
169
|
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
159
170
|
};
|
|
160
|
-
const parse = function(p) {
|
|
171
|
+
const parse$1 = function(p) {
|
|
161
172
|
const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
|
|
162
173
|
const base = basename$1(p);
|
|
163
174
|
const extension = extname$1(base);
|
|
164
175
|
return {
|
|
165
176
|
root,
|
|
166
|
-
dir: dirname$
|
|
177
|
+
dir: dirname$2(p),
|
|
167
178
|
base,
|
|
168
179
|
ext: extension,
|
|
169
180
|
name: base.slice(0, base.length - extension.length)
|
|
@@ -487,6 +498,3022 @@ function toSummary(memo) {
|
|
|
487
498
|
};
|
|
488
499
|
}
|
|
489
500
|
//#endregion
|
|
501
|
+
//#region ../../node_modules/.pnpm/tar@7.5.22/node_modules/tar/dist/esm/index.min.js
|
|
502
|
+
var zr = Object.defineProperty;
|
|
503
|
+
var Ur = (s, t) => {
|
|
504
|
+
for (var e in t) zr(s, e, {
|
|
505
|
+
get: t[e],
|
|
506
|
+
enumerable: !0
|
|
507
|
+
});
|
|
508
|
+
};
|
|
509
|
+
var Ds = typeof process == "object" && process ? process : {
|
|
510
|
+
stdout: null,
|
|
511
|
+
stderr: null
|
|
512
|
+
}, Wr = (s) => !!s && typeof s == "object" && (s instanceof A || s instanceof Cs || Gr(s) || Zr(s)), Gr = (s) => !!s && typeof s == "object" && s instanceof EventEmitter$1 && typeof s.pipe == "function" && s.pipe !== Cs.Writable.prototype.pipe, Zr = (s) => !!s && typeof s == "object" && s instanceof EventEmitter$1 && typeof s.write == "function" && typeof s.end == "function", Q = Symbol("EOF"), J = Symbol("maybeEmitEnd"), nt = Symbol("emittedEnd"), De = Symbol("emittingEnd"), qt = Symbol("emittedError"), Ne = Symbol("closed"), Ns = Symbol("read"), Ae = Symbol("flush"), As = Symbol("flushChunk"), z = Symbol("encoding"), Mt = Symbol("decoder"), g = Symbol("flowing"), Qt = Symbol("paused"), Bt = Symbol("resume"), b = Symbol("buffer"), N = Symbol("pipes"), _ = Symbol("bufferLength"), bi = Symbol("bufferPush"), Ie = Symbol("bufferShift"), L = Symbol("objectMode"), S = Symbol("destroyed"), _i = Symbol("error"), Oi = Symbol("emitData"), Is = Symbol("emitEnd"), Ti = Symbol("emitEnd2"), Z = Symbol("async"), xi = Symbol("abort"), Ce = Symbol("aborted"), Jt = Symbol("signal"), Rt = Symbol("dataListeners"), C = Symbol("discarded"), jt = (s) => Promise.resolve().then(s), Yr = (s) => s(), Kr = (s) => s === "end" || s === "finish" || s === "prefinish", Vr = (s) => s instanceof ArrayBuffer || !!s && typeof s == "object" && s.constructor && s.constructor.name === "ArrayBuffer" && s.byteLength >= 0, $r = (s) => !Buffer.isBuffer(s) && ArrayBuffer.isView(s), Fe = class {
|
|
513
|
+
src;
|
|
514
|
+
dest;
|
|
515
|
+
opts;
|
|
516
|
+
ondrain;
|
|
517
|
+
constructor(t, e, i) {
|
|
518
|
+
this.src = t, this.dest = e, this.opts = i, this.ondrain = () => t[Bt](), this.dest.on("drain", this.ondrain);
|
|
519
|
+
}
|
|
520
|
+
unpipe() {
|
|
521
|
+
this.dest.removeListener("drain", this.ondrain);
|
|
522
|
+
}
|
|
523
|
+
proxyErrors(t) {}
|
|
524
|
+
end() {
|
|
525
|
+
this.unpipe(), this.opts.end && this.dest.end();
|
|
526
|
+
}
|
|
527
|
+
}, Li = class extends Fe {
|
|
528
|
+
unpipe() {
|
|
529
|
+
this.src.removeListener("error", this.proxyErrors), super.unpipe();
|
|
530
|
+
}
|
|
531
|
+
constructor(t, e, i) {
|
|
532
|
+
super(t, e, i), this.proxyErrors = (r) => this.dest.emit("error", r), t.on("error", this.proxyErrors);
|
|
533
|
+
}
|
|
534
|
+
}, Xr = (s) => !!s.objectMode, qr = (s) => !s.objectMode && !!s.encoding && s.encoding !== "buffer", A = class extends EventEmitter$1 {
|
|
535
|
+
[g] = !1;
|
|
536
|
+
[Qt] = !1;
|
|
537
|
+
[N] = [];
|
|
538
|
+
[b] = [];
|
|
539
|
+
[L];
|
|
540
|
+
[z];
|
|
541
|
+
[Z];
|
|
542
|
+
[Mt];
|
|
543
|
+
[Q] = !1;
|
|
544
|
+
[nt] = !1;
|
|
545
|
+
[De] = !1;
|
|
546
|
+
[Ne] = !1;
|
|
547
|
+
[qt] = null;
|
|
548
|
+
[_] = 0;
|
|
549
|
+
[S] = !1;
|
|
550
|
+
[Jt];
|
|
551
|
+
[Ce] = !1;
|
|
552
|
+
[Rt] = 0;
|
|
553
|
+
[C] = !1;
|
|
554
|
+
writable = !0;
|
|
555
|
+
readable = !0;
|
|
556
|
+
constructor(...t) {
|
|
557
|
+
let e = t[0] || {};
|
|
558
|
+
if (super(), e.objectMode && typeof e.encoding == "string") throw new TypeError("Encoding and objectMode may not be used together");
|
|
559
|
+
Xr(e) ? (this[L] = !0, this[z] = null) : qr(e) ? (this[z] = e.encoding, this[L] = !1) : (this[L] = !1, this[z] = null), this[Z] = !!e.async, this[Mt] = this[z] ? new StringDecoder(this[z]) : null, e && e.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[b] }), e && e.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[N] });
|
|
560
|
+
let { signal: i } = e;
|
|
561
|
+
i && (this[Jt] = i, i.aborted ? this[xi]() : i.addEventListener("abort", () => this[xi]()));
|
|
562
|
+
}
|
|
563
|
+
get bufferLength() {
|
|
564
|
+
return this[_];
|
|
565
|
+
}
|
|
566
|
+
get encoding() {
|
|
567
|
+
return this[z];
|
|
568
|
+
}
|
|
569
|
+
set encoding(t) {
|
|
570
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
571
|
+
}
|
|
572
|
+
setEncoding(t) {
|
|
573
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
574
|
+
}
|
|
575
|
+
get objectMode() {
|
|
576
|
+
return this[L];
|
|
577
|
+
}
|
|
578
|
+
set objectMode(t) {
|
|
579
|
+
throw new Error("objectMode must be set at instantiation time");
|
|
580
|
+
}
|
|
581
|
+
get async() {
|
|
582
|
+
return this[Z];
|
|
583
|
+
}
|
|
584
|
+
set async(t) {
|
|
585
|
+
this[Z] = this[Z] || !!t;
|
|
586
|
+
}
|
|
587
|
+
[xi]() {
|
|
588
|
+
this[Ce] = !0, this.emit("abort", this[Jt]?.reason), this.destroy(this[Jt]?.reason);
|
|
589
|
+
}
|
|
590
|
+
get aborted() {
|
|
591
|
+
return this[Ce];
|
|
592
|
+
}
|
|
593
|
+
set aborted(t) {}
|
|
594
|
+
write(t, e, i) {
|
|
595
|
+
if (this[Ce]) return !1;
|
|
596
|
+
if (this[Q]) throw new Error("write after end");
|
|
597
|
+
if (this[S]) return this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
|
|
598
|
+
typeof e == "function" && (i = e, e = "utf8"), e || (e = "utf8");
|
|
599
|
+
let r = this[Z] ? jt : Yr;
|
|
600
|
+
if (!this[L] && !Buffer.isBuffer(t)) {
|
|
601
|
+
if ($r(t)) t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
|
|
602
|
+
else if (Vr(t)) t = Buffer.from(t);
|
|
603
|
+
else if (typeof t != "string") throw new Error("Non-contiguous data written to non-objectMode stream");
|
|
604
|
+
}
|
|
605
|
+
return this[L] ? (this[g] && this[_] !== 0 && this[Ae](!0), this[g] ? this.emit("data", t) : this[bi](t), this[_] !== 0 && this.emit("readable"), i && r(i), this[g]) : t.length ? (typeof t == "string" && !(e === this[z] && !this[Mt]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[z] && (t = this[Mt].write(t)), this[g] && this[_] !== 0 && this[Ae](!0), this[g] ? this.emit("data", t) : this[bi](t), this[_] !== 0 && this.emit("readable"), i && r(i), this[g]) : (this[_] !== 0 && this.emit("readable"), i && r(i), this[g]);
|
|
606
|
+
}
|
|
607
|
+
read(t) {
|
|
608
|
+
if (this[S]) return null;
|
|
609
|
+
if (this[C] = !1, this[_] === 0 || t === 0 || t && t > this[_]) return this[J](), null;
|
|
610
|
+
this[L] && (t = null), this[b].length > 1 && !this[L] && (this[b] = [this[z] ? this[b].join("") : Buffer.concat(this[b], this[_])]);
|
|
611
|
+
let e = this[Ns](t || null, this[b][0]);
|
|
612
|
+
return this[J](), e;
|
|
613
|
+
}
|
|
614
|
+
[Ns](t, e) {
|
|
615
|
+
if (this[L]) this[Ie]();
|
|
616
|
+
else {
|
|
617
|
+
let i = e;
|
|
618
|
+
t === i.length || t === null ? this[Ie]() : typeof i == "string" ? (this[b][0] = i.slice(t), e = i.slice(0, t), this[_] -= t) : (this[b][0] = i.subarray(t), e = i.subarray(0, t), this[_] -= t);
|
|
619
|
+
}
|
|
620
|
+
return this.emit("data", e), !this[b].length && !this[Q] && this.emit("drain"), e;
|
|
621
|
+
}
|
|
622
|
+
end(t, e, i) {
|
|
623
|
+
return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = "utf8"), t !== void 0 && this.write(t, e), i && this.once("end", i), this[Q] = !0, this.writable = !1, (this[g] || !this[Qt]) && this[J](), this;
|
|
624
|
+
}
|
|
625
|
+
[Bt]() {
|
|
626
|
+
this[S] || (!this[Rt] && !this[N].length && (this[C] = !0), this[Qt] = !1, this[g] = !0, this.emit("resume"), this[b].length ? this[Ae]() : this[Q] ? this[J]() : this.emit("drain"));
|
|
627
|
+
}
|
|
628
|
+
resume() {
|
|
629
|
+
return this[Bt]();
|
|
630
|
+
}
|
|
631
|
+
pause() {
|
|
632
|
+
this[g] = !1, this[Qt] = !0, this[C] = !1;
|
|
633
|
+
}
|
|
634
|
+
get destroyed() {
|
|
635
|
+
return this[S];
|
|
636
|
+
}
|
|
637
|
+
get flowing() {
|
|
638
|
+
return this[g];
|
|
639
|
+
}
|
|
640
|
+
get paused() {
|
|
641
|
+
return this[Qt];
|
|
642
|
+
}
|
|
643
|
+
[bi](t) {
|
|
644
|
+
this[L] ? this[_] += 1 : this[_] += t.length, this[b].push(t);
|
|
645
|
+
}
|
|
646
|
+
[Ie]() {
|
|
647
|
+
return this[L] ? this[_] -= 1 : this[_] -= this[b][0].length, this[b].shift();
|
|
648
|
+
}
|
|
649
|
+
[Ae](t = !1) {
|
|
650
|
+
do ;
|
|
651
|
+
while (this[As](this[Ie]()) && this[b].length);
|
|
652
|
+
!t && !this[b].length && !this[Q] && this.emit("drain");
|
|
653
|
+
}
|
|
654
|
+
[As](t) {
|
|
655
|
+
return this.emit("data", t), this[g];
|
|
656
|
+
}
|
|
657
|
+
pipe(t, e) {
|
|
658
|
+
if (this[S]) return t;
|
|
659
|
+
this[C] = !1;
|
|
660
|
+
let i = this[nt];
|
|
661
|
+
return e = e || {}, t === Ds.stdout || t === Ds.stderr ? e.end = !1 : e.end = e.end !== !1, e.proxyErrors = !!e.proxyErrors, i ? e.end && t.end() : (this[N].push(e.proxyErrors ? new Li(this, t, e) : new Fe(this, t, e)), this[Z] ? jt(() => this[Bt]()) : this[Bt]()), t;
|
|
662
|
+
}
|
|
663
|
+
unpipe(t) {
|
|
664
|
+
let e = this[N].find((i) => i.dest === t);
|
|
665
|
+
e && (this[N].length === 1 ? (this[g] && this[Rt] === 0 && (this[g] = !1), this[N] = []) : this[N].splice(this[N].indexOf(e), 1), e.unpipe());
|
|
666
|
+
}
|
|
667
|
+
addListener(t, e) {
|
|
668
|
+
return this.on(t, e);
|
|
669
|
+
}
|
|
670
|
+
on(t, e) {
|
|
671
|
+
let i = super.on(t, e);
|
|
672
|
+
if (t === "data") this[C] = !1, this[Rt]++, !this[N].length && !this[g] && this[Bt]();
|
|
673
|
+
else if (t === "readable" && this[_] !== 0) super.emit("readable");
|
|
674
|
+
else if (Kr(t) && this[nt]) super.emit(t), this.removeAllListeners(t);
|
|
675
|
+
else if (t === "error" && this[qt]) {
|
|
676
|
+
let r = e;
|
|
677
|
+
this[Z] ? jt(() => r.call(this, this[qt])) : r.call(this, this[qt]);
|
|
678
|
+
}
|
|
679
|
+
return i;
|
|
680
|
+
}
|
|
681
|
+
removeListener(t, e) {
|
|
682
|
+
return this.off(t, e);
|
|
683
|
+
}
|
|
684
|
+
off(t, e) {
|
|
685
|
+
let i = super.off(t, e);
|
|
686
|
+
return t === "data" && (this[Rt] = this.listeners("data").length, this[Rt] === 0 && !this[C] && !this[N].length && (this[g] = !1)), i;
|
|
687
|
+
}
|
|
688
|
+
removeAllListeners(t) {
|
|
689
|
+
let e = super.removeAllListeners(t);
|
|
690
|
+
return (t === "data" || t === void 0) && (this[Rt] = 0, !this[C] && !this[N].length && (this[g] = !1)), e;
|
|
691
|
+
}
|
|
692
|
+
get emittedEnd() {
|
|
693
|
+
return this[nt];
|
|
694
|
+
}
|
|
695
|
+
[J]() {
|
|
696
|
+
!this[De] && !this[nt] && !this[S] && this[b].length === 0 && this[Q] && (this[De] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Ne] && this.emit("close"), this[De] = !1);
|
|
697
|
+
}
|
|
698
|
+
emit(t, ...e) {
|
|
699
|
+
let i = e[0];
|
|
700
|
+
if (t !== "error" && t !== "close" && t !== S && this[S]) return !1;
|
|
701
|
+
if (t === "data") return !this[L] && !i ? !1 : this[Z] ? (jt(() => this[Oi](i)), !0) : this[Oi](i);
|
|
702
|
+
if (t === "end") return this[Is]();
|
|
703
|
+
if (t === "close") {
|
|
704
|
+
if (this[Ne] = !0, !this[nt] && !this[S]) return !1;
|
|
705
|
+
let n = super.emit("close");
|
|
706
|
+
return this.removeAllListeners("close"), n;
|
|
707
|
+
} else if (t === "error") {
|
|
708
|
+
this[qt] = i, super.emit(_i, i);
|
|
709
|
+
let n = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : !1;
|
|
710
|
+
return this[J](), n;
|
|
711
|
+
} else if (t === "resume") {
|
|
712
|
+
let n = super.emit("resume");
|
|
713
|
+
return this[J](), n;
|
|
714
|
+
} else if (t === "finish" || t === "prefinish") {
|
|
715
|
+
let n = super.emit(t);
|
|
716
|
+
return this.removeAllListeners(t), n;
|
|
717
|
+
}
|
|
718
|
+
let r = super.emit(t, ...e);
|
|
719
|
+
return this[J](), r;
|
|
720
|
+
}
|
|
721
|
+
[Oi](t) {
|
|
722
|
+
for (let i of this[N]) i.dest.write(t) === !1 && this.pause();
|
|
723
|
+
let e = this[C] ? !1 : super.emit("data", t);
|
|
724
|
+
return this[J](), e;
|
|
725
|
+
}
|
|
726
|
+
[Is]() {
|
|
727
|
+
return this[nt] ? !1 : (this[nt] = !0, this.readable = !1, this[Z] ? (jt(() => this[Ti]()), !0) : this[Ti]());
|
|
728
|
+
}
|
|
729
|
+
[Ti]() {
|
|
730
|
+
if (this[Mt]) {
|
|
731
|
+
let e = this[Mt].end();
|
|
732
|
+
if (e) {
|
|
733
|
+
for (let i of this[N]) i.dest.write(e);
|
|
734
|
+
this[C] || super.emit("data", e);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
for (let e of this[N]) e.end();
|
|
738
|
+
let t = super.emit("end");
|
|
739
|
+
return this.removeAllListeners("end"), t;
|
|
740
|
+
}
|
|
741
|
+
async collect() {
|
|
742
|
+
let t = Object.assign([], { dataLength: 0 });
|
|
743
|
+
this[L] || (t.dataLength = 0);
|
|
744
|
+
let e = this.promise();
|
|
745
|
+
return this.on("data", (i) => {
|
|
746
|
+
t.push(i), this[L] || (t.dataLength += i.length);
|
|
747
|
+
}), await e, t;
|
|
748
|
+
}
|
|
749
|
+
async concat() {
|
|
750
|
+
if (this[L]) throw new Error("cannot concat in objectMode");
|
|
751
|
+
let t = await this.collect();
|
|
752
|
+
return this[z] ? t.join("") : Buffer.concat(t, t.dataLength);
|
|
753
|
+
}
|
|
754
|
+
async promise() {
|
|
755
|
+
return new Promise((t, e) => {
|
|
756
|
+
this.on(S, () => e(/* @__PURE__ */ new Error("stream destroyed"))), this.on("error", (i) => e(i)), this.on("end", () => t());
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
[Symbol.asyncIterator]() {
|
|
760
|
+
this[C] = !1;
|
|
761
|
+
let t = !1, e = async () => (this.pause(), t = !0, {
|
|
762
|
+
value: void 0,
|
|
763
|
+
done: !0
|
|
764
|
+
});
|
|
765
|
+
return {
|
|
766
|
+
next: () => {
|
|
767
|
+
if (t) return e();
|
|
768
|
+
let r = this.read();
|
|
769
|
+
if (r !== null) return Promise.resolve({
|
|
770
|
+
done: !1,
|
|
771
|
+
value: r
|
|
772
|
+
});
|
|
773
|
+
if (this[Q]) return e();
|
|
774
|
+
let n, o, h = (d) => {
|
|
775
|
+
this.off("data", a), this.off("end", l), this.off(S, c), e(), o(d);
|
|
776
|
+
}, a = (d) => {
|
|
777
|
+
this.off("error", h), this.off("end", l), this.off(S, c), this.pause(), n({
|
|
778
|
+
value: d,
|
|
779
|
+
done: !!this[Q]
|
|
780
|
+
});
|
|
781
|
+
}, l = () => {
|
|
782
|
+
this.off("error", h), this.off("data", a), this.off(S, c), e(), n({
|
|
783
|
+
done: !0,
|
|
784
|
+
value: void 0
|
|
785
|
+
});
|
|
786
|
+
}, c = () => h(/* @__PURE__ */ new Error("stream destroyed"));
|
|
787
|
+
return new Promise((d, y) => {
|
|
788
|
+
o = y, n = d, this.once(S, c), this.once("error", h), this.once("end", l), this.once("data", a);
|
|
789
|
+
});
|
|
790
|
+
},
|
|
791
|
+
throw: e,
|
|
792
|
+
return: e,
|
|
793
|
+
[Symbol.asyncIterator]() {
|
|
794
|
+
return this;
|
|
795
|
+
},
|
|
796
|
+
[Symbol.asyncDispose]: async () => {}
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
[Symbol.iterator]() {
|
|
800
|
+
this[C] = !1;
|
|
801
|
+
let t = !1, e = () => (this.pause(), this.off(_i, e), this.off(S, e), this.off("end", e), t = !0, {
|
|
802
|
+
done: !0,
|
|
803
|
+
value: void 0
|
|
804
|
+
}), i = () => {
|
|
805
|
+
if (t) return e();
|
|
806
|
+
let r = this.read();
|
|
807
|
+
return r === null ? e() : {
|
|
808
|
+
done: !1,
|
|
809
|
+
value: r
|
|
810
|
+
};
|
|
811
|
+
};
|
|
812
|
+
return this.once("end", e), this.once(_i, e), this.once(S, e), {
|
|
813
|
+
next: i,
|
|
814
|
+
throw: e,
|
|
815
|
+
return: e,
|
|
816
|
+
[Symbol.iterator]() {
|
|
817
|
+
return this;
|
|
818
|
+
},
|
|
819
|
+
[Symbol.dispose]: () => {}
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
destroy(t) {
|
|
823
|
+
if (this[S]) return t ? this.emit("error", t) : this.emit(S), this;
|
|
824
|
+
this[S] = !0, this[C] = !0, this[b].length = 0, this[_] = 0;
|
|
825
|
+
let e = this;
|
|
826
|
+
return typeof e.close == "function" && !this[Ne] && e.close(), t ? this.emit("error", t) : this.emit(S), this;
|
|
827
|
+
}
|
|
828
|
+
static get isStream() {
|
|
829
|
+
return Wr;
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
var Jr = I.writev, ht = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol("_ended"), m = Symbol("_fd"), Ni = Symbol("_finished"), tt = Symbol("_flags"), Ai = Symbol("_flush"), ki = Symbol("_handleChunk"), vi = Symbol("_makeBuf"), ie = Symbol("_mode"), ke = Symbol("_needDrain"), Ut = Symbol("_onerror"), Ht = Symbol("_onopen"), Ii = Symbol("_onread"), Pt = Symbol("_onwrite"), at = Symbol("_open"), U = Symbol("_path"), ot = Symbol("_pos"), Y = Symbol("_queue"), zt = Symbol("_read"), Ci = Symbol("_readSize"), j = Symbol("_reading"), ee = Symbol("_remain"), Fi = Symbol("_size"), ve = Symbol("_write"), gt = Symbol("_writing"), Me = Symbol("_defaultFlag"), bt = Symbol("_errored"), _t = class extends A {
|
|
833
|
+
[bt] = !1;
|
|
834
|
+
[m];
|
|
835
|
+
[U];
|
|
836
|
+
[Ci];
|
|
837
|
+
[j] = !1;
|
|
838
|
+
[Fi];
|
|
839
|
+
[ee];
|
|
840
|
+
[ht];
|
|
841
|
+
constructor(t, e) {
|
|
842
|
+
if (e = e || {}, super(e), this.readable = !0, this.writable = !1, typeof t != "string") throw new TypeError("path must be a string");
|
|
843
|
+
this[bt] = !1, this[m] = typeof e.fd == "number" ? e.fd : void 0, this[U] = t, this[Ci] = e.readSize || 16 * 1024 * 1024, this[j] = !1, this[Fi] = typeof e.size == "number" ? e.size : Infinity, this[ee] = this[Fi], this[ht] = typeof e.autoClose == "boolean" ? e.autoClose : !0, typeof this[m] == "number" ? this[zt]() : this[at]();
|
|
844
|
+
}
|
|
845
|
+
get fd() {
|
|
846
|
+
return this[m];
|
|
847
|
+
}
|
|
848
|
+
get path() {
|
|
849
|
+
return this[U];
|
|
850
|
+
}
|
|
851
|
+
write() {
|
|
852
|
+
throw new TypeError("this is a readable stream");
|
|
853
|
+
}
|
|
854
|
+
end() {
|
|
855
|
+
throw new TypeError("this is a readable stream");
|
|
856
|
+
}
|
|
857
|
+
[at]() {
|
|
858
|
+
I.open(this[U], "r", (t, e) => this[Ht](t, e));
|
|
859
|
+
}
|
|
860
|
+
[Ht](t, e) {
|
|
861
|
+
t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[zt]());
|
|
862
|
+
}
|
|
863
|
+
[vi]() {
|
|
864
|
+
return Buffer.allocUnsafe(Math.min(this[Ci], this[ee]));
|
|
865
|
+
}
|
|
866
|
+
[zt]() {
|
|
867
|
+
if (!this[j]) {
|
|
868
|
+
this[j] = !0;
|
|
869
|
+
let t = this[vi]();
|
|
870
|
+
if (t.length === 0) return process.nextTick(() => this[Ii](null, 0, t));
|
|
871
|
+
I.read(this[m], t, 0, t.length, null, (e, i, r) => this[Ii](e, i, r));
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
[Ii](t, e, i) {
|
|
875
|
+
this[j] = !1, t ? this[Ut](t) : this[ki](e, i) && this[zt]();
|
|
876
|
+
}
|
|
877
|
+
[H]() {
|
|
878
|
+
if (this[ht] && typeof this[m] == "number") {
|
|
879
|
+
let t = this[m];
|
|
880
|
+
this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
[Ut](t) {
|
|
884
|
+
this[j] = !0, this[H](), this.emit("error", t);
|
|
885
|
+
}
|
|
886
|
+
[ki](t, e) {
|
|
887
|
+
let i = !1;
|
|
888
|
+
return this[ee] -= t, t > 0 && (i = super.write(t < e.length ? e.subarray(0, t) : e)), (t === 0 || this[ee] <= 0) && (i = !1, this[H](), super.end()), i;
|
|
889
|
+
}
|
|
890
|
+
emit(t, ...e) {
|
|
891
|
+
switch (t) {
|
|
892
|
+
case "prefinish":
|
|
893
|
+
case "finish": return !1;
|
|
894
|
+
case "drain": return typeof this[m] == "number" && this[zt](), !1;
|
|
895
|
+
case "error": return this[bt] ? !1 : (this[bt] = !0, super.emit(t, ...e));
|
|
896
|
+
default: return super.emit(t, ...e);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}, Be = class extends _t {
|
|
900
|
+
[at]() {
|
|
901
|
+
let t = !0;
|
|
902
|
+
try {
|
|
903
|
+
this[Ht](null, I.openSync(this[U], "r")), t = !1;
|
|
904
|
+
} finally {
|
|
905
|
+
t && this[H]();
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
[zt]() {
|
|
909
|
+
let t = !0;
|
|
910
|
+
try {
|
|
911
|
+
if (!this[j]) {
|
|
912
|
+
this[j] = !0;
|
|
913
|
+
do {
|
|
914
|
+
let e = this[vi](), i = e.length === 0 ? 0 : I.readSync(this[m], e, 0, e.length, null);
|
|
915
|
+
if (!this[ki](i, e)) break;
|
|
916
|
+
} while (!0);
|
|
917
|
+
this[j] = !1;
|
|
918
|
+
}
|
|
919
|
+
t = !1;
|
|
920
|
+
} finally {
|
|
921
|
+
t && this[H]();
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
[H]() {
|
|
925
|
+
if (this[ht] && typeof this[m] == "number") {
|
|
926
|
+
let t = this[m];
|
|
927
|
+
this[m] = void 0, I.closeSync(t), this.emit("close");
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}, et = class extends Qr {
|
|
931
|
+
readable = !1;
|
|
932
|
+
writable = !0;
|
|
933
|
+
[bt] = !1;
|
|
934
|
+
[gt] = !1;
|
|
935
|
+
[te] = !1;
|
|
936
|
+
[Y] = [];
|
|
937
|
+
[ke] = !1;
|
|
938
|
+
[U];
|
|
939
|
+
[ie];
|
|
940
|
+
[ht];
|
|
941
|
+
[m];
|
|
942
|
+
[Me];
|
|
943
|
+
[tt];
|
|
944
|
+
[Ni] = !1;
|
|
945
|
+
[ot];
|
|
946
|
+
constructor(t, e) {
|
|
947
|
+
e = e || {}, super(e), this[U] = t, this[m] = typeof e.fd == "number" ? e.fd : void 0, this[ie] = e.mode === void 0 ? 438 : e.mode, this[ot] = typeof e.start == "number" ? e.start : void 0, this[ht] = typeof e.autoClose == "boolean" ? e.autoClose : !0;
|
|
948
|
+
let i = this[ot] !== void 0 ? "r+" : "w";
|
|
949
|
+
this[Me] = e.flags === void 0, this[tt] = e.flags === void 0 ? i : e.flags, this[m] === void 0 && this[at]();
|
|
950
|
+
}
|
|
951
|
+
emit(t, ...e) {
|
|
952
|
+
if (t === "error") {
|
|
953
|
+
if (this[bt]) return !1;
|
|
954
|
+
this[bt] = !0;
|
|
955
|
+
}
|
|
956
|
+
return super.emit(t, ...e);
|
|
957
|
+
}
|
|
958
|
+
get fd() {
|
|
959
|
+
return this[m];
|
|
960
|
+
}
|
|
961
|
+
get path() {
|
|
962
|
+
return this[U];
|
|
963
|
+
}
|
|
964
|
+
[Ut](t) {
|
|
965
|
+
this[H](), this[gt] = !0, this.emit("error", t);
|
|
966
|
+
}
|
|
967
|
+
[at]() {
|
|
968
|
+
I.open(this[U], this[tt], this[ie], (t, e) => this[Ht](t, e));
|
|
969
|
+
}
|
|
970
|
+
[Ht](t, e) {
|
|
971
|
+
this[Me] && this[tt] === "r+" && t && t.code === "ENOENT" ? (this[tt] = "w", this[at]()) : t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[gt] || this[Ai]());
|
|
972
|
+
}
|
|
973
|
+
end(t, e) {
|
|
974
|
+
return t && this.write(t, e), this[te] = !0, !this[gt] && !this[Y].length && typeof this[m] == "number" && this[Pt](null, 0), this;
|
|
975
|
+
}
|
|
976
|
+
write(t, e) {
|
|
977
|
+
return typeof t == "string" && (t = Buffer.from(t, e)), this[te] ? (this.emit("error", /* @__PURE__ */ new Error("write() after end()")), !1) : this[m] === void 0 || this[gt] || this[Y].length ? (this[Y].push(t), this[ke] = !0, !1) : (this[gt] = !0, this[ve](t), !0);
|
|
978
|
+
}
|
|
979
|
+
[ve](t) {
|
|
980
|
+
I.write(this[m], t, 0, t.length, this[ot], (e, i) => this[Pt](e, i));
|
|
981
|
+
}
|
|
982
|
+
[Pt](t, e) {
|
|
983
|
+
t ? this[Ut](t) : (this[ot] !== void 0 && typeof e == "number" && (this[ot] += e), this[Y].length ? this[Ai]() : (this[gt] = !1, this[te] && !this[Ni] ? (this[Ni] = !0, this[H](), this.emit("finish")) : this[ke] && (this[ke] = !1, this.emit("drain"))));
|
|
984
|
+
}
|
|
985
|
+
[Ai]() {
|
|
986
|
+
if (this[Y].length === 0) this[te] && this[Pt](null, 0);
|
|
987
|
+
else if (this[Y].length === 1) this[ve](this[Y].pop());
|
|
988
|
+
else {
|
|
989
|
+
let t = this[Y];
|
|
990
|
+
this[Y] = [], Jr(this[m], t, this[ot], (e, i) => this[Pt](e, i));
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
[H]() {
|
|
994
|
+
if (this[ht] && typeof this[m] == "number") {
|
|
995
|
+
let t = this[m];
|
|
996
|
+
this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}, Wt = class extends et {
|
|
1000
|
+
[at]() {
|
|
1001
|
+
let t;
|
|
1002
|
+
if (this[Me] && this[tt] === "r+") try {
|
|
1003
|
+
t = I.openSync(this[U], this[tt], this[ie]);
|
|
1004
|
+
} catch (e) {
|
|
1005
|
+
if (e?.code === "ENOENT") return this[tt] = "w", this[at]();
|
|
1006
|
+
throw e;
|
|
1007
|
+
}
|
|
1008
|
+
else t = I.openSync(this[U], this[tt], this[ie]);
|
|
1009
|
+
this[Ht](null, t);
|
|
1010
|
+
}
|
|
1011
|
+
[H]() {
|
|
1012
|
+
if (this[ht] && typeof this[m] == "number") {
|
|
1013
|
+
let t = this[m];
|
|
1014
|
+
this[m] = void 0, I.closeSync(t), this.emit("close");
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
[ve](t) {
|
|
1018
|
+
let e = !0;
|
|
1019
|
+
try {
|
|
1020
|
+
this[Pt](null, I.writeSync(this[m], t, 0, t.length, this[ot])), e = !1;
|
|
1021
|
+
} finally {
|
|
1022
|
+
if (e) try {
|
|
1023
|
+
this[H]();
|
|
1024
|
+
} catch {}
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
var jr = new Map([
|
|
1029
|
+
["C", "cwd"],
|
|
1030
|
+
["f", "file"],
|
|
1031
|
+
["z", "gzip"],
|
|
1032
|
+
["P", "preservePaths"],
|
|
1033
|
+
["U", "unlink"],
|
|
1034
|
+
["strip-components", "strip"],
|
|
1035
|
+
["stripComponents", "strip"],
|
|
1036
|
+
["keep-newer", "newer"],
|
|
1037
|
+
["keepNewer", "newer"],
|
|
1038
|
+
["keep-newer-files", "newer"],
|
|
1039
|
+
["keepNewerFiles", "newer"],
|
|
1040
|
+
["k", "keep"],
|
|
1041
|
+
["keep-existing", "keep"],
|
|
1042
|
+
["keepExisting", "keep"],
|
|
1043
|
+
["m", "noMtime"],
|
|
1044
|
+
["no-mtime", "noMtime"],
|
|
1045
|
+
["p", "preserveOwner"],
|
|
1046
|
+
["L", "follow"],
|
|
1047
|
+
["h", "follow"],
|
|
1048
|
+
["onentry", "onReadEntry"]
|
|
1049
|
+
]), Fs = (s) => !!s.sync && !!s.file, ks = (s) => !s.sync && !!s.file, vs = (s) => !!s.sync && !s.file, Ms = (s) => !s.sync && !s.file;
|
|
1050
|
+
var Bs = (s) => !!s.file;
|
|
1051
|
+
var tn = (s) => {
|
|
1052
|
+
return jr.get(s) || s;
|
|
1053
|
+
}, se = (s = {}) => {
|
|
1054
|
+
if (!s) return {};
|
|
1055
|
+
let t = {};
|
|
1056
|
+
for (let [e, i] of Object.entries(s)) {
|
|
1057
|
+
let r = tn(e);
|
|
1058
|
+
t[r] = i;
|
|
1059
|
+
}
|
|
1060
|
+
return t.chmod === void 0 && t.noChmod === !1 && (t.chmod = !0), delete t.noChmod, t;
|
|
1061
|
+
};
|
|
1062
|
+
var K = (s, t, e, i, r) => Object.assign((n = [], o, h) => {
|
|
1063
|
+
Array.isArray(n) && (o = n, n = {}), typeof o == "function" && (h = o, o = void 0), o = o ? Array.from(o) : [];
|
|
1064
|
+
let a = se(n);
|
|
1065
|
+
if (r?.(a, o), Fs(a)) {
|
|
1066
|
+
if (typeof h == "function") throw new TypeError("callback not supported for sync tar functions");
|
|
1067
|
+
return s(a, o);
|
|
1068
|
+
} else if (ks(a)) {
|
|
1069
|
+
let l = t(a, o);
|
|
1070
|
+
return h ? l.then(() => h(), h) : l;
|
|
1071
|
+
} else if (vs(a)) {
|
|
1072
|
+
if (typeof h == "function") throw new TypeError("callback not supported for sync tar functions");
|
|
1073
|
+
return e(a, o);
|
|
1074
|
+
} else if (Ms(a)) {
|
|
1075
|
+
if (typeof h == "function") throw new TypeError("callback only supported with file option");
|
|
1076
|
+
return i(a, o);
|
|
1077
|
+
}
|
|
1078
|
+
throw new Error("impossible options??");
|
|
1079
|
+
}, {
|
|
1080
|
+
syncFile: s,
|
|
1081
|
+
asyncFile: t,
|
|
1082
|
+
syncNoFile: e,
|
|
1083
|
+
asyncNoFile: i,
|
|
1084
|
+
validate: r
|
|
1085
|
+
});
|
|
1086
|
+
var sn = en.constants || { ZLIB_VERNUM: 4736 }, M = Object.freeze(Object.assign(Object.create(null), {
|
|
1087
|
+
Z_NO_FLUSH: 0,
|
|
1088
|
+
Z_PARTIAL_FLUSH: 1,
|
|
1089
|
+
Z_SYNC_FLUSH: 2,
|
|
1090
|
+
Z_FULL_FLUSH: 3,
|
|
1091
|
+
Z_FINISH: 4,
|
|
1092
|
+
Z_BLOCK: 5,
|
|
1093
|
+
Z_OK: 0,
|
|
1094
|
+
Z_STREAM_END: 1,
|
|
1095
|
+
Z_NEED_DICT: 2,
|
|
1096
|
+
Z_ERRNO: -1,
|
|
1097
|
+
Z_STREAM_ERROR: -2,
|
|
1098
|
+
Z_DATA_ERROR: -3,
|
|
1099
|
+
Z_MEM_ERROR: -4,
|
|
1100
|
+
Z_BUF_ERROR: -5,
|
|
1101
|
+
Z_VERSION_ERROR: -6,
|
|
1102
|
+
Z_NO_COMPRESSION: 0,
|
|
1103
|
+
Z_BEST_SPEED: 1,
|
|
1104
|
+
Z_BEST_COMPRESSION: 9,
|
|
1105
|
+
Z_DEFAULT_COMPRESSION: -1,
|
|
1106
|
+
Z_FILTERED: 1,
|
|
1107
|
+
Z_HUFFMAN_ONLY: 2,
|
|
1108
|
+
Z_RLE: 3,
|
|
1109
|
+
Z_FIXED: 4,
|
|
1110
|
+
Z_DEFAULT_STRATEGY: 0,
|
|
1111
|
+
DEFLATE: 1,
|
|
1112
|
+
INFLATE: 2,
|
|
1113
|
+
GZIP: 3,
|
|
1114
|
+
GUNZIP: 4,
|
|
1115
|
+
DEFLATERAW: 5,
|
|
1116
|
+
INFLATERAW: 6,
|
|
1117
|
+
UNZIP: 7,
|
|
1118
|
+
BROTLI_DECODE: 8,
|
|
1119
|
+
BROTLI_ENCODE: 9,
|
|
1120
|
+
Z_MIN_WINDOWBITS: 8,
|
|
1121
|
+
Z_MAX_WINDOWBITS: 15,
|
|
1122
|
+
Z_DEFAULT_WINDOWBITS: 15,
|
|
1123
|
+
Z_MIN_CHUNK: 64,
|
|
1124
|
+
Z_MAX_CHUNK: Infinity,
|
|
1125
|
+
Z_DEFAULT_CHUNK: 16384,
|
|
1126
|
+
Z_MIN_MEMLEVEL: 1,
|
|
1127
|
+
Z_MAX_MEMLEVEL: 9,
|
|
1128
|
+
Z_DEFAULT_MEMLEVEL: 8,
|
|
1129
|
+
Z_MIN_LEVEL: -1,
|
|
1130
|
+
Z_MAX_LEVEL: 9,
|
|
1131
|
+
Z_DEFAULT_LEVEL: -1,
|
|
1132
|
+
BROTLI_OPERATION_PROCESS: 0,
|
|
1133
|
+
BROTLI_OPERATION_FLUSH: 1,
|
|
1134
|
+
BROTLI_OPERATION_FINISH: 2,
|
|
1135
|
+
BROTLI_OPERATION_EMIT_METADATA: 3,
|
|
1136
|
+
BROTLI_MODE_GENERIC: 0,
|
|
1137
|
+
BROTLI_MODE_TEXT: 1,
|
|
1138
|
+
BROTLI_MODE_FONT: 2,
|
|
1139
|
+
BROTLI_DEFAULT_MODE: 0,
|
|
1140
|
+
BROTLI_MIN_QUALITY: 0,
|
|
1141
|
+
BROTLI_MAX_QUALITY: 11,
|
|
1142
|
+
BROTLI_DEFAULT_QUALITY: 11,
|
|
1143
|
+
BROTLI_MIN_WINDOW_BITS: 10,
|
|
1144
|
+
BROTLI_MAX_WINDOW_BITS: 24,
|
|
1145
|
+
BROTLI_LARGE_MAX_WINDOW_BITS: 30,
|
|
1146
|
+
BROTLI_DEFAULT_WINDOW: 22,
|
|
1147
|
+
BROTLI_MIN_INPUT_BLOCK_BITS: 16,
|
|
1148
|
+
BROTLI_MAX_INPUT_BLOCK_BITS: 24,
|
|
1149
|
+
BROTLI_PARAM_MODE: 0,
|
|
1150
|
+
BROTLI_PARAM_QUALITY: 1,
|
|
1151
|
+
BROTLI_PARAM_LGWIN: 2,
|
|
1152
|
+
BROTLI_PARAM_LGBLOCK: 3,
|
|
1153
|
+
BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4,
|
|
1154
|
+
BROTLI_PARAM_SIZE_HINT: 5,
|
|
1155
|
+
BROTLI_PARAM_LARGE_WINDOW: 6,
|
|
1156
|
+
BROTLI_PARAM_NPOSTFIX: 7,
|
|
1157
|
+
BROTLI_PARAM_NDIRECT: 8,
|
|
1158
|
+
BROTLI_DECODER_RESULT_ERROR: 0,
|
|
1159
|
+
BROTLI_DECODER_RESULT_SUCCESS: 1,
|
|
1160
|
+
BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2,
|
|
1161
|
+
BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3,
|
|
1162
|
+
BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0,
|
|
1163
|
+
BROTLI_DECODER_PARAM_LARGE_WINDOW: 1,
|
|
1164
|
+
BROTLI_DECODER_NO_ERROR: 0,
|
|
1165
|
+
BROTLI_DECODER_SUCCESS: 1,
|
|
1166
|
+
BROTLI_DECODER_NEEDS_MORE_INPUT: 2,
|
|
1167
|
+
BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3,
|
|
1168
|
+
BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1,
|
|
1169
|
+
BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2,
|
|
1170
|
+
BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3,
|
|
1171
|
+
BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4,
|
|
1172
|
+
BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5,
|
|
1173
|
+
BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6,
|
|
1174
|
+
BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7,
|
|
1175
|
+
BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8,
|
|
1176
|
+
BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9,
|
|
1177
|
+
BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10,
|
|
1178
|
+
BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11,
|
|
1179
|
+
BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12,
|
|
1180
|
+
BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13,
|
|
1181
|
+
BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14,
|
|
1182
|
+
BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15,
|
|
1183
|
+
BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16,
|
|
1184
|
+
BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19,
|
|
1185
|
+
BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20,
|
|
1186
|
+
BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21,
|
|
1187
|
+
BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22,
|
|
1188
|
+
BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25,
|
|
1189
|
+
BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26,
|
|
1190
|
+
BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27,
|
|
1191
|
+
BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30,
|
|
1192
|
+
BROTLI_DECODER_ERROR_UNREACHABLE: -31
|
|
1193
|
+
}, sn));
|
|
1194
|
+
var rn = Buffer$1.concat, zs = Object.getOwnPropertyDescriptor(Buffer$1, "concat"), nn = (s) => s, Bi = zs?.writable === !0 || zs?.set !== void 0 ? (s) => {
|
|
1195
|
+
Buffer$1.concat = s ? nn : rn;
|
|
1196
|
+
} : (s) => {}, Tt = Symbol("_superWrite"), Gt = class extends Error {
|
|
1197
|
+
code;
|
|
1198
|
+
errno;
|
|
1199
|
+
constructor(t, e) {
|
|
1200
|
+
super("zlib: " + t.message, { cause: t }), this.code = t.code, this.errno = t.errno, this.code || (this.code = "ZLIB_ERROR"), this.message = "zlib: " + t.message, Error.captureStackTrace(this, e ?? this.constructor);
|
|
1201
|
+
}
|
|
1202
|
+
get name() {
|
|
1203
|
+
return "ZlibError";
|
|
1204
|
+
}
|
|
1205
|
+
}, Pi = Symbol("flushFlag"), re = class extends A {
|
|
1206
|
+
#t = !1;
|
|
1207
|
+
#i = !1;
|
|
1208
|
+
#s;
|
|
1209
|
+
#n;
|
|
1210
|
+
#r;
|
|
1211
|
+
#e;
|
|
1212
|
+
#o;
|
|
1213
|
+
get sawError() {
|
|
1214
|
+
return this.#t;
|
|
1215
|
+
}
|
|
1216
|
+
get handle() {
|
|
1217
|
+
return this.#e;
|
|
1218
|
+
}
|
|
1219
|
+
get flushFlag() {
|
|
1220
|
+
return this.#s;
|
|
1221
|
+
}
|
|
1222
|
+
constructor(t, e) {
|
|
1223
|
+
if (!t || typeof t != "object") throw new TypeError("invalid options for ZlibBase constructor");
|
|
1224
|
+
if (super(t), this.#s = t.flush ?? 0, this.#n = t.finishFlush ?? 0, this.#r = t.fullFlushFlag ?? 0, typeof Ps[e] != "function") throw new TypeError("Compression method not supported: " + e);
|
|
1225
|
+
try {
|
|
1226
|
+
this.#e = new Ps[e](t);
|
|
1227
|
+
} catch (i) {
|
|
1228
|
+
throw new Gt(i, this.constructor);
|
|
1229
|
+
}
|
|
1230
|
+
this.#o = (i) => {
|
|
1231
|
+
this.#t || (this.#t = !0, this.close(), this.emit("error", i));
|
|
1232
|
+
}, this.#e?.on("error", (i) => this.#o(new Gt(i))), this.once("end", () => this.close);
|
|
1233
|
+
}
|
|
1234
|
+
close() {
|
|
1235
|
+
this.#e && (this.#e.close(), this.#e = void 0, this.emit("close"));
|
|
1236
|
+
}
|
|
1237
|
+
reset() {
|
|
1238
|
+
if (!this.#t) return zi(this.#e, "zlib binding closed"), this.#e.reset?.();
|
|
1239
|
+
}
|
|
1240
|
+
flush(t) {
|
|
1241
|
+
this.ended || (typeof t != "number" && (t = this.#r), this.write(Object.assign(Buffer$1.alloc(0), { [Pi]: t })));
|
|
1242
|
+
}
|
|
1243
|
+
end(t, e, i) {
|
|
1244
|
+
return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), t && (e ? this.write(t, e) : this.write(t)), this.flush(this.#n), this.#i = !0, super.end(i);
|
|
1245
|
+
}
|
|
1246
|
+
get ended() {
|
|
1247
|
+
return this.#i;
|
|
1248
|
+
}
|
|
1249
|
+
[Tt](t) {
|
|
1250
|
+
return super.write(t);
|
|
1251
|
+
}
|
|
1252
|
+
write(t, e, i) {
|
|
1253
|
+
if (typeof e == "function" && (i = e, e = "utf8"), typeof t == "string" && (t = Buffer$1.from(t, e)), this.#t) return;
|
|
1254
|
+
zi(this.#e, "zlib binding closed");
|
|
1255
|
+
let r = this.#e._handle, n = r.close;
|
|
1256
|
+
r.close = () => {};
|
|
1257
|
+
let o = this.#e.close;
|
|
1258
|
+
this.#e.close = () => {}, Bi(!0);
|
|
1259
|
+
let h;
|
|
1260
|
+
try {
|
|
1261
|
+
let l = typeof t[Pi] == "number" ? t[Pi] : this.#s;
|
|
1262
|
+
h = this.#e._processChunk(t, l), Bi(!1);
|
|
1263
|
+
} catch (l) {
|
|
1264
|
+
Bi(!1), this.#o(new Gt(l, this.write));
|
|
1265
|
+
} finally {
|
|
1266
|
+
this.#e && (this.#e._handle = r, r.close = n, this.#e.close = o, this.#e.removeAllListeners("error"));
|
|
1267
|
+
}
|
|
1268
|
+
this.#e && this.#e.on("error", (l) => this.#o(new Gt(l, this.write)));
|
|
1269
|
+
let a;
|
|
1270
|
+
if (h) if (Array.isArray(h) && h.length > 0) {
|
|
1271
|
+
let l = h[0];
|
|
1272
|
+
a = this[Tt](Buffer$1.from(l));
|
|
1273
|
+
for (let c = 1; c < h.length; c++) a = this[Tt](h[c]);
|
|
1274
|
+
} else a = this[Tt](Buffer$1.from(h));
|
|
1275
|
+
return i && i(), a;
|
|
1276
|
+
}
|
|
1277
|
+
}, Pe = class extends re {
|
|
1278
|
+
#t;
|
|
1279
|
+
#i;
|
|
1280
|
+
constructor(t, e) {
|
|
1281
|
+
t = t || {}, t.flush = t.flush || M.Z_NO_FLUSH, t.finishFlush = t.finishFlush || M.Z_FINISH, t.fullFlushFlag = M.Z_FULL_FLUSH, super(t, e), this.#t = t.level, this.#i = t.strategy;
|
|
1282
|
+
}
|
|
1283
|
+
params(t, e) {
|
|
1284
|
+
if (!this.sawError) {
|
|
1285
|
+
if (!this.handle) throw new Error("cannot switch params when binding is closed");
|
|
1286
|
+
if (!this.handle.params) throw new Error("not supported in this implementation");
|
|
1287
|
+
if (this.#t !== t || this.#i !== e) {
|
|
1288
|
+
this.flush(M.Z_SYNC_FLUSH), zi(this.handle, "zlib binding closed");
|
|
1289
|
+
let i = this.handle.flush;
|
|
1290
|
+
this.handle.flush = (r, n) => {
|
|
1291
|
+
typeof r == "function" && (n = r, r = this.flushFlag), this.flush(r), n?.();
|
|
1292
|
+
};
|
|
1293
|
+
try {
|
|
1294
|
+
this.handle.params(t, e);
|
|
1295
|
+
} finally {
|
|
1296
|
+
this.handle.flush = i;
|
|
1297
|
+
}
|
|
1298
|
+
this.handle && (this.#t = t, this.#i = e);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
var ze = class extends Pe {
|
|
1304
|
+
#t;
|
|
1305
|
+
constructor(t) {
|
|
1306
|
+
super(t, "Gzip"), this.#t = t && !!t.portable;
|
|
1307
|
+
}
|
|
1308
|
+
[Tt](t) {
|
|
1309
|
+
return this.#t ? (this.#t = !1, t[9] = 255, super[Tt](t)) : super[Tt](t);
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
var Ue = class extends Pe {
|
|
1313
|
+
constructor(t) {
|
|
1314
|
+
super(t, "Unzip");
|
|
1315
|
+
}
|
|
1316
|
+
}, He = class extends re {
|
|
1317
|
+
constructor(t, e) {
|
|
1318
|
+
t = t || {}, t.flush = t.flush || M.BROTLI_OPERATION_PROCESS, t.finishFlush = t.finishFlush || M.BROTLI_OPERATION_FINISH, t.fullFlushFlag = M.BROTLI_OPERATION_FLUSH, super(t, e);
|
|
1319
|
+
}
|
|
1320
|
+
}, We = class extends He {
|
|
1321
|
+
constructor(t) {
|
|
1322
|
+
super(t, "BrotliCompress");
|
|
1323
|
+
}
|
|
1324
|
+
}, Ge = class extends He {
|
|
1325
|
+
constructor(t) {
|
|
1326
|
+
super(t, "BrotliDecompress");
|
|
1327
|
+
}
|
|
1328
|
+
}, Ze = class extends re {
|
|
1329
|
+
constructor(t, e) {
|
|
1330
|
+
t = t || {}, t.flush = t.flush || M.ZSTD_e_continue, t.finishFlush = t.finishFlush || M.ZSTD_e_end, t.fullFlushFlag = M.ZSTD_e_flush, super(t, e);
|
|
1331
|
+
}
|
|
1332
|
+
}, Ye = class extends Ze {
|
|
1333
|
+
constructor(t) {
|
|
1334
|
+
super(t, "ZstdCompress");
|
|
1335
|
+
}
|
|
1336
|
+
}, Ke = class extends Ze {
|
|
1337
|
+
constructor(t) {
|
|
1338
|
+
super(t, "ZstdDecompress");
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
var Us = (s, t) => {
|
|
1342
|
+
if (Number.isSafeInteger(s)) s < 0 ? an(s, t) : hn(s, t);
|
|
1343
|
+
else throw Error("cannot encode number outside of javascript safe integer range");
|
|
1344
|
+
return t;
|
|
1345
|
+
}, hn = (s, t) => {
|
|
1346
|
+
t[0] = 128;
|
|
1347
|
+
for (var e = t.length; e > 1; e--) t[e - 1] = s & 255, s = Math.floor(s / 256);
|
|
1348
|
+
}, an = (s, t) => {
|
|
1349
|
+
t[0] = 255;
|
|
1350
|
+
var e = !1;
|
|
1351
|
+
s = s * -1;
|
|
1352
|
+
for (var i = t.length; i > 1; i--) {
|
|
1353
|
+
var r = s & 255;
|
|
1354
|
+
s = Math.floor(s / 256), e ? t[i - 1] = Ws(r) : r === 0 ? t[i - 1] = 0 : (e = !0, t[i - 1] = Gs(r));
|
|
1355
|
+
}
|
|
1356
|
+
}, Hs = (s) => {
|
|
1357
|
+
let t = s[0], e = t === 128 ? cn(s.subarray(1, s.length)) : t === 255 ? ln(s) : null;
|
|
1358
|
+
if (e === null) throw Error("invalid base256 encoding");
|
|
1359
|
+
if (!Number.isSafeInteger(e)) throw Error("parsed number outside of javascript safe integer range");
|
|
1360
|
+
return e;
|
|
1361
|
+
}, ln = (s) => {
|
|
1362
|
+
for (var t = s.length, e = 0, i = !1, r = t - 1; r > -1; r--) {
|
|
1363
|
+
var n = Number(s[r]), o;
|
|
1364
|
+
i ? o = Ws(n) : n === 0 ? o = n : (i = !0, o = Gs(n)), o !== 0 && (e -= o * Math.pow(256, t - r - 1));
|
|
1365
|
+
}
|
|
1366
|
+
return e;
|
|
1367
|
+
}, cn = (s) => {
|
|
1368
|
+
for (var t = s.length, e = 0, i = t - 1; i > -1; i--) {
|
|
1369
|
+
var r = Number(s[i]);
|
|
1370
|
+
r !== 0 && (e += r * Math.pow(256, t - i - 1));
|
|
1371
|
+
}
|
|
1372
|
+
return e;
|
|
1373
|
+
}, Ws = (s) => (255 ^ s) & 255, Gs = (s) => (255 ^ s) + 1 & 255;
|
|
1374
|
+
Ur({}, {
|
|
1375
|
+
code: () => Ve,
|
|
1376
|
+
isCode: () => ne,
|
|
1377
|
+
isName: () => dn,
|
|
1378
|
+
name: () => oe,
|
|
1379
|
+
normalFsTypes: () => Ui
|
|
1380
|
+
});
|
|
1381
|
+
var ne = (s) => oe.has(s), dn = (s) => Ve.has(s), Ui = new Set([
|
|
1382
|
+
"0",
|
|
1383
|
+
"",
|
|
1384
|
+
"1",
|
|
1385
|
+
"2",
|
|
1386
|
+
"3",
|
|
1387
|
+
"4",
|
|
1388
|
+
"5",
|
|
1389
|
+
"6",
|
|
1390
|
+
"7",
|
|
1391
|
+
"D"
|
|
1392
|
+
]), oe = new Map([
|
|
1393
|
+
["0", "File"],
|
|
1394
|
+
["", "OldFile"],
|
|
1395
|
+
["1", "Link"],
|
|
1396
|
+
["2", "SymbolicLink"],
|
|
1397
|
+
["3", "CharacterDevice"],
|
|
1398
|
+
["4", "BlockDevice"],
|
|
1399
|
+
["5", "Directory"],
|
|
1400
|
+
["6", "FIFO"],
|
|
1401
|
+
["7", "ContiguousFile"],
|
|
1402
|
+
["g", "GlobalExtendedHeader"],
|
|
1403
|
+
["x", "ExtendedHeader"],
|
|
1404
|
+
["A", "SolarisACL"],
|
|
1405
|
+
["D", "GNUDumpDir"],
|
|
1406
|
+
["I", "Inode"],
|
|
1407
|
+
["K", "NextFileHasLongLinkpath"],
|
|
1408
|
+
["L", "NextFileHasLongPath"],
|
|
1409
|
+
["M", "ContinuationFile"],
|
|
1410
|
+
["N", "OldGnuLongPath"],
|
|
1411
|
+
["S", "SparseFile"],
|
|
1412
|
+
["V", "TapeVolumeHeader"],
|
|
1413
|
+
["X", "OldExtendedHeader"]
|
|
1414
|
+
]), Ve = new Map(Array.from(oe).map((s) => [s[1], s[0]]));
|
|
1415
|
+
var un = (s) => s === void 0 || s < 0 ? void 0 : s, F = class {
|
|
1416
|
+
cksumValid = !1;
|
|
1417
|
+
needPax = !1;
|
|
1418
|
+
nullBlock = !1;
|
|
1419
|
+
block;
|
|
1420
|
+
path;
|
|
1421
|
+
mode;
|
|
1422
|
+
uid;
|
|
1423
|
+
gid;
|
|
1424
|
+
size;
|
|
1425
|
+
cksum;
|
|
1426
|
+
#t = "Unsupported";
|
|
1427
|
+
linkpath;
|
|
1428
|
+
uname;
|
|
1429
|
+
gname;
|
|
1430
|
+
devmaj = 0;
|
|
1431
|
+
devmin = 0;
|
|
1432
|
+
atime;
|
|
1433
|
+
ctime;
|
|
1434
|
+
mtime;
|
|
1435
|
+
charset;
|
|
1436
|
+
comment;
|
|
1437
|
+
constructor(t, e = 0, i, r) {
|
|
1438
|
+
Buffer.isBuffer(t) ? this.decode(t, e || 0, i, r) : t && this.#i(t);
|
|
1439
|
+
}
|
|
1440
|
+
decode(t, e, i, r) {
|
|
1441
|
+
if (e || (e = 0), !t || !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
|
|
1442
|
+
let n = xt(t, e + 156, 1), o = Ui.has(n), h = o ? i : void 0, a = o ? r : void 0;
|
|
1443
|
+
if (this.path = h?.path ?? xt(t, e, 100), this.mode = h?.mode ?? a?.mode ?? lt(t, e + 100, 8), this.uid = h?.uid ?? a?.uid ?? lt(t, e + 108, 8), this.gid = h?.gid ?? a?.gid ?? lt(t, e + 116, 8), this.size = un(h?.size ?? a?.size ?? lt(t, e + 124, 12)), this.mtime = h?.mtime ?? a?.mtime ?? Wi(t, e + 136, 12), this.cksum = lt(t, e + 148, 12), a && this.#i(a, !0), h && this.#i(h), ne(n) && (this.#t = n || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = xt(t, e + 157, 100), t.subarray(e + 257, e + 265).toString() === "ustar\x0000") if (this.uname = h?.uname ?? a?.uname ?? xt(t, e + 265, 32), this.gname = h?.gname ?? a?.gname ?? xt(t, e + 297, 32), this.devmaj = h?.devmaj ?? a?.devmaj ?? lt(t, e + 329, 8) ?? 0, this.devmin = h?.devmin ?? a?.devmin ?? lt(t, e + 337, 8) ?? 0, t[e + 475] !== 0) {
|
|
1444
|
+
let c = xt(t, e + 345, 155);
|
|
1445
|
+
this.path = c + "/" + this.path;
|
|
1446
|
+
} else {
|
|
1447
|
+
let c = xt(t, e + 345, 130);
|
|
1448
|
+
c && (this.path = c + "/" + this.path), this.atime = i?.atime ?? r?.atime ?? Wi(t, e + 476, 12), this.ctime = i?.ctime ?? r?.ctime ?? Wi(t, e + 488, 12);
|
|
1449
|
+
}
|
|
1450
|
+
let l = 256;
|
|
1451
|
+
for (let c = e; c < e + 148; c++) l += t[c];
|
|
1452
|
+
for (let c = e + 156; c < e + 512; c++) l += t[c];
|
|
1453
|
+
this.cksumValid = l === this.cksum, this.cksum === void 0 && l === 256 && (this.nullBlock = !0);
|
|
1454
|
+
}
|
|
1455
|
+
#i(t, e = !1) {
|
|
1456
|
+
Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "size" && Number(r) < 0 || i === "path" && e || i === "linkpath" && e || i === "global"))));
|
|
1457
|
+
}
|
|
1458
|
+
encode(t, e = 0) {
|
|
1459
|
+
if (t || (t = this.block = Buffer.alloc(512)), this.#t === "Unsupported" && (this.#t = "0"), !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
|
|
1460
|
+
let i = this.ctime || this.atime ? 130 : 155, r = mn(this.path || "", i), n = r[0], o = r[1];
|
|
1461
|
+
this.needPax = !!r[2], this.needPax = Lt(t, e, 100, n) || this.needPax, this.needPax = ct(t, e + 100, 8, this.mode) || this.needPax, this.needPax = ct(t, e + 108, 8, this.uid) || this.needPax, this.needPax = ct(t, e + 116, 8, this.gid) || this.needPax, this.needPax = ct(t, e + 124, 12, this.size) || this.needPax, this.needPax = Gi(t, e + 136, 12, this.mtime) || this.needPax, t[e + 156] = Number(this.#t.codePointAt(0)), this.needPax = Lt(t, e + 157, 100, this.linkpath) || this.needPax, t.write("ustar\x0000", e + 257, 8), this.needPax = Lt(t, e + 265, 32, this.uname) || this.needPax, this.needPax = Lt(t, e + 297, 32, this.gname) || this.needPax, this.needPax = ct(t, e + 329, 8, this.devmaj) || this.needPax, this.needPax = ct(t, e + 337, 8, this.devmin) || this.needPax, this.needPax = Lt(t, e + 345, i, o) || this.needPax, t[e + 475] !== 0 ? this.needPax = Lt(t, e + 345, 155, o) || this.needPax : (this.needPax = Lt(t, e + 345, 130, o) || this.needPax, this.needPax = Gi(t, e + 476, 12, this.atime) || this.needPax, this.needPax = Gi(t, e + 488, 12, this.ctime) || this.needPax);
|
|
1462
|
+
let h = 256;
|
|
1463
|
+
for (let a = e; a < e + 148; a++) h += t[a];
|
|
1464
|
+
for (let a = e + 156; a < e + 512; a++) h += t[a];
|
|
1465
|
+
return this.cksum = h, ct(t, e + 148, 8, this.cksum), this.cksumValid = !0, this.needPax;
|
|
1466
|
+
}
|
|
1467
|
+
get type() {
|
|
1468
|
+
return this.#t === "Unsupported" ? this.#t : oe.get(this.#t);
|
|
1469
|
+
}
|
|
1470
|
+
get typeKey() {
|
|
1471
|
+
return this.#t;
|
|
1472
|
+
}
|
|
1473
|
+
set type(t) {
|
|
1474
|
+
let e = String(Ve.get(t));
|
|
1475
|
+
if (ne(e) || e === "Unsupported") this.#t = e;
|
|
1476
|
+
else if (ne(t)) this.#t = t;
|
|
1477
|
+
else throw new TypeError("invalid entry type: " + t);
|
|
1478
|
+
}
|
|
1479
|
+
}, mn = (s, t) => {
|
|
1480
|
+
let i = s, r = "", n, o = posix.parse(s).root || ".";
|
|
1481
|
+
if (Buffer.byteLength(i) < 100) n = [
|
|
1482
|
+
i,
|
|
1483
|
+
r,
|
|
1484
|
+
!1
|
|
1485
|
+
];
|
|
1486
|
+
else {
|
|
1487
|
+
r = posix.dirname(i), i = posix.basename(i);
|
|
1488
|
+
do
|
|
1489
|
+
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [
|
|
1490
|
+
i,
|
|
1491
|
+
r,
|
|
1492
|
+
!1
|
|
1493
|
+
] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [
|
|
1494
|
+
i.slice(0, 99),
|
|
1495
|
+
r,
|
|
1496
|
+
!0
|
|
1497
|
+
] : (i = posix.join(posix.basename(r), i), r = posix.dirname(r));
|
|
1498
|
+
while (r !== o && n === void 0);
|
|
1499
|
+
n || (n = [
|
|
1500
|
+
s.slice(0, 99),
|
|
1501
|
+
"",
|
|
1502
|
+
!0
|
|
1503
|
+
]);
|
|
1504
|
+
}
|
|
1505
|
+
return n;
|
|
1506
|
+
}, xt = (s, t, e) => s.subarray(t, t + e).toString("utf8").replace(/\0.*/, ""), Wi = (s, t, e) => pn(lt(s, t, e)), pn = (s) => s === void 0 ? void 0 : /* @__PURE__ */ new Date(s * 1e3), lt = (s, t, e) => Number(s[t]) & 128 ? Hs(s.subarray(t, t + e)) : wn(s, t, e), En = (s) => isNaN(s) ? void 0 : s, wn = (s, t, e) => En(parseInt(s.subarray(t, t + e).toString("utf8").replace(/\0.*$/, "").trim(), 8)), Sn = {
|
|
1507
|
+
12: 8589934591,
|
|
1508
|
+
8: 2097151
|
|
1509
|
+
}, ct = (s, t, e, i) => i === void 0 ? !1 : i > Sn[e] || i < 0 ? (Us(i, s.subarray(t, t + e)), !0) : (yn(s, t, e, i), !1), yn = (s, t, e, i) => s.write(Rn(i, e), t, e, "ascii"), Rn = (s, t) => gn(Math.floor(s).toString(8), t), gn = (s, t) => (s.length === t - 1 ? s : new Array(t - s.length - 1).join("0") + s + " ") + "\0", Gi = (s, t, e, i) => i === void 0 ? !1 : ct(s, t, e, i.getTime() / 1e3), bn = new Array(156).join("\0"), Lt = (s, t, e, i) => i === void 0 ? !1 : (s.write(i + bn, t, e, "utf8"), i.length !== Buffer.byteLength(i) || i.length > e);
|
|
1510
|
+
var ft = class s {
|
|
1511
|
+
atime;
|
|
1512
|
+
mtime;
|
|
1513
|
+
ctime;
|
|
1514
|
+
charset;
|
|
1515
|
+
comment;
|
|
1516
|
+
gid;
|
|
1517
|
+
uid;
|
|
1518
|
+
gname;
|
|
1519
|
+
uname;
|
|
1520
|
+
linkpath;
|
|
1521
|
+
dev;
|
|
1522
|
+
ino;
|
|
1523
|
+
nlink;
|
|
1524
|
+
path;
|
|
1525
|
+
size;
|
|
1526
|
+
mode;
|
|
1527
|
+
global;
|
|
1528
|
+
constructor(t, e = !1) {
|
|
1529
|
+
this.atime = t.atime, this.charset = t.charset, this.comment = t.comment, this.ctime = t.ctime, this.dev = t.dev, this.gid = t.gid, this.global = e, this.gname = t.gname, this.ino = t.ino, this.linkpath = t.linkpath, this.mtime = t.mtime, this.nlink = t.nlink, this.path = t.path, this.size = t.size, this.uid = t.uid, this.uname = t.uname;
|
|
1530
|
+
}
|
|
1531
|
+
encode() {
|
|
1532
|
+
let t = this.encodeBody();
|
|
1533
|
+
if (t === "") return Buffer.allocUnsafe(0);
|
|
1534
|
+
let e = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
|
|
1535
|
+
for (let n = 0; n < 512; n++) r[n] = 0;
|
|
1536
|
+
new F({
|
|
1537
|
+
path: ("PaxHeader/" + basename(this.path ?? "")).slice(0, 99),
|
|
1538
|
+
mode: this.mode || 420,
|
|
1539
|
+
uid: this.uid,
|
|
1540
|
+
gid: this.gid,
|
|
1541
|
+
size: e,
|
|
1542
|
+
mtime: this.mtime,
|
|
1543
|
+
type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader",
|
|
1544
|
+
linkpath: "",
|
|
1545
|
+
uname: this.uname || "",
|
|
1546
|
+
gname: this.gname || "",
|
|
1547
|
+
devmaj: 0,
|
|
1548
|
+
devmin: 0,
|
|
1549
|
+
atime: this.atime,
|
|
1550
|
+
ctime: this.ctime
|
|
1551
|
+
}).encode(r), r.write(t, 512, e, "utf8");
|
|
1552
|
+
for (let n = e + 512; n < r.length; n++) r[n] = 0;
|
|
1553
|
+
return r;
|
|
1554
|
+
}
|
|
1555
|
+
encodeBody() {
|
|
1556
|
+
return this.encodeField("path") + this.encodeField("ctime") + this.encodeField("atime") + this.encodeField("dev") + this.encodeField("ino") + this.encodeField("nlink") + this.encodeField("charset") + this.encodeField("comment") + this.encodeField("gid") + this.encodeField("gname") + this.encodeField("linkpath") + this.encodeField("mtime") + this.encodeField("size") + this.encodeField("uid") + this.encodeField("uname");
|
|
1557
|
+
}
|
|
1558
|
+
encodeField(t) {
|
|
1559
|
+
if (this[t] === void 0) return "";
|
|
1560
|
+
let e = this[t], i = e instanceof Date ? e.getTime() / 1e3 : e, r = " " + (t === "dev" || t === "ino" || t === "nlink" ? "SCHILY." : "") + t + "=" + i + `
|
|
1561
|
+
`, n = Buffer.byteLength(r), o = Math.floor(Math.log(n) / Math.log(10)) + 1;
|
|
1562
|
+
return n + o >= Math.pow(10, o) && (o += 1), o + n + r;
|
|
1563
|
+
}
|
|
1564
|
+
static parse(t, e, i = !1) {
|
|
1565
|
+
return new s(On(Tn(t), e), i);
|
|
1566
|
+
}
|
|
1567
|
+
}, On = (s, t) => t ? Object.assign({}, t, s) : s, Tn = (s) => s.replace(/\n$/, "").split(`
|
|
1568
|
+
`).reduce(xn, Object.create(null)), xn = (s, t) => {
|
|
1569
|
+
let e = parseInt(t, 10);
|
|
1570
|
+
if (e !== Buffer.byteLength(t) + 1) return s;
|
|
1571
|
+
t = t.slice((e + " ").length);
|
|
1572
|
+
let i = t.split("="), r = i.shift();
|
|
1573
|
+
if (!r) return s;
|
|
1574
|
+
let n = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o = i.join("=").replace(/\0.*/, "");
|
|
1575
|
+
switch (n) {
|
|
1576
|
+
case "path":
|
|
1577
|
+
case "linkpath":
|
|
1578
|
+
case "type":
|
|
1579
|
+
case "charset":
|
|
1580
|
+
case "comment":
|
|
1581
|
+
case "gname":
|
|
1582
|
+
case "uname":
|
|
1583
|
+
s[n] = o;
|
|
1584
|
+
break;
|
|
1585
|
+
case "ctime":
|
|
1586
|
+
case "atime":
|
|
1587
|
+
case "mtime":
|
|
1588
|
+
s[n] = /* @__PURE__ */ new Date(Number(o) * 1e3);
|
|
1589
|
+
break;
|
|
1590
|
+
case "size":
|
|
1591
|
+
let h = +o;
|
|
1592
|
+
h >= 0 && (s[n] = h);
|
|
1593
|
+
break;
|
|
1594
|
+
case "gid":
|
|
1595
|
+
case "uid":
|
|
1596
|
+
case "dev":
|
|
1597
|
+
case "ino":
|
|
1598
|
+
case "nlink":
|
|
1599
|
+
case "mode":
|
|
1600
|
+
s[n] = +o;
|
|
1601
|
+
break;
|
|
1602
|
+
}
|
|
1603
|
+
return s;
|
|
1604
|
+
};
|
|
1605
|
+
var f = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) !== "win32" ? (s) => String(s) : (s) => String(s).replaceAll(/\\/g, "/");
|
|
1606
|
+
var $e = class extends A {
|
|
1607
|
+
extended;
|
|
1608
|
+
globalExtended;
|
|
1609
|
+
header;
|
|
1610
|
+
startBlockSize;
|
|
1611
|
+
blockRemain;
|
|
1612
|
+
remain;
|
|
1613
|
+
type;
|
|
1614
|
+
meta = !1;
|
|
1615
|
+
ignore = !1;
|
|
1616
|
+
path;
|
|
1617
|
+
mode;
|
|
1618
|
+
uid;
|
|
1619
|
+
gid;
|
|
1620
|
+
uname;
|
|
1621
|
+
gname;
|
|
1622
|
+
size = 0;
|
|
1623
|
+
mtime;
|
|
1624
|
+
atime;
|
|
1625
|
+
ctime;
|
|
1626
|
+
linkpath;
|
|
1627
|
+
dev;
|
|
1628
|
+
ino;
|
|
1629
|
+
nlink;
|
|
1630
|
+
invalid = !1;
|
|
1631
|
+
absolute;
|
|
1632
|
+
unsupported = !1;
|
|
1633
|
+
constructor(t, e, i) {
|
|
1634
|
+
switch (super({}), this.pause(), this.extended = e, this.globalExtended = i, this.header = t, this.remain = t.size ?? 0, this.startBlockSize = 512 * Math.ceil(this.remain / 512), this.blockRemain = this.startBlockSize, this.type = t.type, this.type) {
|
|
1635
|
+
case "File":
|
|
1636
|
+
case "OldFile":
|
|
1637
|
+
case "Link":
|
|
1638
|
+
case "SymbolicLink":
|
|
1639
|
+
case "CharacterDevice":
|
|
1640
|
+
case "BlockDevice":
|
|
1641
|
+
case "Directory":
|
|
1642
|
+
case "FIFO":
|
|
1643
|
+
case "ContiguousFile":
|
|
1644
|
+
case "GNUDumpDir": break;
|
|
1645
|
+
case "NextFileHasLongLinkpath":
|
|
1646
|
+
case "NextFileHasLongPath":
|
|
1647
|
+
case "OldGnuLongPath":
|
|
1648
|
+
case "GlobalExtendedHeader":
|
|
1649
|
+
case "ExtendedHeader":
|
|
1650
|
+
case "OldExtendedHeader":
|
|
1651
|
+
this.meta = !0;
|
|
1652
|
+
break;
|
|
1653
|
+
default: this.ignore = !0;
|
|
1654
|
+
}
|
|
1655
|
+
if (!t.path) throw new Error("no path provided for tar.ReadEntry");
|
|
1656
|
+
this.path = f(t.path), this.mode = t.mode, this.mode && (this.mode = this.mode & 4095), this.uid = t.uid, this.gid = t.gid, this.uname = t.uname, this.gname = t.gname, this.size = this.remain, this.mtime = t.mtime, this.atime = t.atime, this.ctime = t.ctime, this.linkpath = t.linkpath ? f(t.linkpath) : void 0, this.uname = t.uname, this.gname = t.gname, e && this.#t(e), i && this.#t(i, !0);
|
|
1657
|
+
}
|
|
1658
|
+
write(t) {
|
|
1659
|
+
let e = t.length;
|
|
1660
|
+
if (e > this.blockRemain) throw new Error("writing more to entry than is appropriate");
|
|
1661
|
+
let i = this.remain, r = this.blockRemain;
|
|
1662
|
+
return this.remain = Math.max(0, i - e), this.blockRemain = Math.max(0, r - e), this.ignore ? !0 : i >= e ? super.write(t) : super.write(t.subarray(0, i));
|
|
1663
|
+
}
|
|
1664
|
+
#t(t, e = !1) {
|
|
1665
|
+
t.path && (t.path = f(t.path)), t.linkpath && (t.linkpath = f(t.linkpath)), Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "path" && e))));
|
|
1666
|
+
}
|
|
1667
|
+
};
|
|
1668
|
+
var Dt = (s, t, e, i = {}) => {
|
|
1669
|
+
s.file && (i.file = s.file), s.cwd && (i.cwd = s.cwd), i.code = e instanceof Error && e.code || t, i.tarCode = t, !s.strict && i.recoverable !== !1 ? (e instanceof Error && (i = Object.assign(e, i), e = e.message), s.emit("warn", t, e, i)) : e instanceof Error ? s.emit("error", Object.assign(e, i)) : s.emit("error", Object.assign(/* @__PURE__ */ new Error(`${t}: ${e}`), i));
|
|
1670
|
+
};
|
|
1671
|
+
var Nn = 1024 * 1024, Xi = Buffer.from([31, 139]), qi = Buffer.from([
|
|
1672
|
+
40,
|
|
1673
|
+
181,
|
|
1674
|
+
47,
|
|
1675
|
+
253
|
|
1676
|
+
]), An = Math.max(Xi.length, qi.length), B = Symbol("state"), Nt = Symbol("writeEntry"), it = Symbol("readEntry"), Zi = Symbol("nextEntry"), Zs = Symbol("processEntry"), V = Symbol("extendedHeader"), he = Symbol("globalExtendedHeader"), dt = Symbol("meta"), Ys = Symbol("emitMeta"), p = Symbol("buffer"), st = Symbol("queue"), ut = Symbol("ended"), Yi = Symbol("emittedEnd"), At = Symbol("emit"), w = Symbol("unzip"), Xe = Symbol("consumeChunk"), qe = Symbol("consumeChunkSub"), Ki = Symbol("consumeBody"), Ks = Symbol("consumeMeta"), Vs = Symbol("consumeHeader"), ae = Symbol("consuming"), Vi = Symbol("bufferConcat"), Qe = Symbol("maybeEnd"), Yt = Symbol("writing"), $ = Symbol("aborted"), Je = Symbol("onDone"), It = Symbol("sawValidEntry"), je = Symbol("sawNullBlock"), ti = Symbol("sawEOF"), $s = Symbol("closeStream"), In = 1e3, le = Symbol("compressedBytesRead"), $i = Symbol("decompressedBytesRead"), Xs = Symbol("checkDecompressionRatio"), Cn = () => !0, rt = class extends EventEmitter {
|
|
1677
|
+
file;
|
|
1678
|
+
strict;
|
|
1679
|
+
maxMetaEntrySize;
|
|
1680
|
+
filter;
|
|
1681
|
+
brotli;
|
|
1682
|
+
zstd;
|
|
1683
|
+
maxDecompressionRatio;
|
|
1684
|
+
writable = !0;
|
|
1685
|
+
readable = !1;
|
|
1686
|
+
[st] = [];
|
|
1687
|
+
[p];
|
|
1688
|
+
[it];
|
|
1689
|
+
[Nt];
|
|
1690
|
+
[B] = "begin";
|
|
1691
|
+
[dt] = "";
|
|
1692
|
+
[V];
|
|
1693
|
+
[he];
|
|
1694
|
+
[ut] = !1;
|
|
1695
|
+
[w];
|
|
1696
|
+
[$] = !1;
|
|
1697
|
+
[It];
|
|
1698
|
+
[je] = !1;
|
|
1699
|
+
[ti] = !1;
|
|
1700
|
+
[Yt] = !1;
|
|
1701
|
+
[ae] = !1;
|
|
1702
|
+
[Yi] = !1;
|
|
1703
|
+
[le] = 0;
|
|
1704
|
+
[$i] = 0;
|
|
1705
|
+
constructor(t = {}) {
|
|
1706
|
+
super(), this.file = t.file || "", this.on(Je, () => {
|
|
1707
|
+
(this[B] === "begin" || this[It] === !1) && this.warn("TAR_BAD_ARCHIVE", "Unrecognized archive format");
|
|
1708
|
+
}), t.ondone ? this.on(Je, t.ondone) : this.on(Je, () => {
|
|
1709
|
+
this.emit("prefinish"), this.emit("finish"), this.emit("end");
|
|
1710
|
+
}), this.strict = !!t.strict, this.maxDecompressionRatio = typeof t.maxDecompressionRatio == "number" ? t.maxDecompressionRatio : In, this.maxMetaEntrySize = t.maxMetaEntrySize || Nn, this.filter = typeof t.filter == "function" ? t.filter : Cn;
|
|
1711
|
+
let e = t.file && (t.file.endsWith(".tar.br") || t.file.endsWith(".tbr"));
|
|
1712
|
+
this.brotli = !(t.gzip || t.zstd) && t.brotli !== void 0 ? t.brotli : e ? void 0 : !1;
|
|
1713
|
+
let i = t.file && (t.file.endsWith(".tar.zst") || t.file.endsWith(".tzst"));
|
|
1714
|
+
this.zstd = !(t.gzip || t.brotli) && t.zstd !== void 0 ? t.zstd : i ? !0 : void 0, this.on("end", () => this[$s]()), typeof t.onwarn == "function" && this.on("warn", t.onwarn), typeof t.onReadEntry == "function" && this.on("entry", t.onReadEntry);
|
|
1715
|
+
}
|
|
1716
|
+
warn(t, e, i = {}) {
|
|
1717
|
+
Dt(this, t, e, i);
|
|
1718
|
+
}
|
|
1719
|
+
[Vs](t, e) {
|
|
1720
|
+
this[It] === void 0 && (this[It] = !1);
|
|
1721
|
+
let i;
|
|
1722
|
+
try {
|
|
1723
|
+
i = new F(t, e, this[V], this[he]);
|
|
1724
|
+
} catch (r) {
|
|
1725
|
+
return this.warn("TAR_ENTRY_INVALID", r);
|
|
1726
|
+
}
|
|
1727
|
+
if (i.nullBlock) this[je] ? (this[ti] = !0, this[B] === "begin" && (this[B] = "header"), this[At]("eof")) : (this[je] = !0, this[At]("nullBlock"));
|
|
1728
|
+
else if (this[je] = !1, !i.cksumValid) this.warn("TAR_ENTRY_INVALID", "checksum failure", { header: i });
|
|
1729
|
+
else if (!i.path) this.warn("TAR_ENTRY_INVALID", "path is required", { header: i });
|
|
1730
|
+
else {
|
|
1731
|
+
let r = i.type;
|
|
1732
|
+
if (/^(Symbolic)?Link$/.test(r) && !i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath required", { header: i });
|
|
1733
|
+
else if (!/^(Symbolic)?Link$/.test(r) && !/^(Global)?ExtendedHeader$/.test(r) && i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", { header: i });
|
|
1734
|
+
else {
|
|
1735
|
+
let n = this[Nt] = new $e(i, this[V], this[he]);
|
|
1736
|
+
if (!this[It]) if (n.remain) {
|
|
1737
|
+
let o = () => {
|
|
1738
|
+
n.invalid || (this[It] = !0);
|
|
1739
|
+
};
|
|
1740
|
+
n.on("end", o);
|
|
1741
|
+
} else this[It] = !0;
|
|
1742
|
+
n.meta ? n.size > this.maxMetaEntrySize ? (n.ignore = !0, this[At]("ignoredEntry", n), this[B] = "ignore", n.resume()) : n.size > 0 && (this[dt] = "", n.on("data", (o) => this[dt] += o), this[B] = "meta") : (this[V] = void 0, n.ignore = n.ignore || !this.filter(n.path, n), n.ignore ? (this[At]("ignoredEntry", n), this[B] = n.remain ? "ignore" : "header", n.resume()) : (n.remain ? this[B] = "body" : (this[B] = "header", n.end()), this[it] ? this[st].push(n) : (this[st].push(n), this[Zi]())));
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
[$s]() {
|
|
1747
|
+
queueMicrotask(() => this.emit("close"));
|
|
1748
|
+
}
|
|
1749
|
+
[Zs](t) {
|
|
1750
|
+
let e = !0;
|
|
1751
|
+
if (!t) this[it] = void 0, e = !1;
|
|
1752
|
+
else if (Array.isArray(t)) {
|
|
1753
|
+
let [i, ...r] = t;
|
|
1754
|
+
this.emit(i, ...r);
|
|
1755
|
+
} else this[it] = t, this.emit("entry", t), t.emittedEnd || (t.on("end", () => this[Zi]()), e = !1);
|
|
1756
|
+
return e;
|
|
1757
|
+
}
|
|
1758
|
+
[Zi]() {
|
|
1759
|
+
do ;
|
|
1760
|
+
while (this[Zs](this[st].shift()));
|
|
1761
|
+
if (this[st].length === 0) {
|
|
1762
|
+
let t = this[it];
|
|
1763
|
+
!t || t.flowing || t.size === t.remain ? this[Yt] || this.emit("drain") : t.once("drain", () => this.emit("drain"));
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
[Ki](t, e) {
|
|
1767
|
+
let i = this[Nt];
|
|
1768
|
+
if (!i) throw new Error("attempt to consume body without entry??");
|
|
1769
|
+
let r = i.blockRemain ?? 0, n = r >= t.length && e === 0 ? t : t.subarray(e, e + r);
|
|
1770
|
+
return i.write(n), i.blockRemain || (this[B] = "header", this[Nt] = void 0, i.end()), n.length;
|
|
1771
|
+
}
|
|
1772
|
+
[Ks](t, e) {
|
|
1773
|
+
let i = this[Nt], r = this[Ki](t, e);
|
|
1774
|
+
return !this[Nt] && i && this[Ys](i), r;
|
|
1775
|
+
}
|
|
1776
|
+
[At](t, e, i) {
|
|
1777
|
+
this[st].length === 0 && !this[it] ? this.emit(t, e, i) : this[st].push([
|
|
1778
|
+
t,
|
|
1779
|
+
e,
|
|
1780
|
+
i
|
|
1781
|
+
]);
|
|
1782
|
+
}
|
|
1783
|
+
[Ys](t) {
|
|
1784
|
+
switch (this[At]("meta", this[dt]), t.type) {
|
|
1785
|
+
case "ExtendedHeader":
|
|
1786
|
+
case "OldExtendedHeader":
|
|
1787
|
+
this[V] = ft.parse(this[dt], this[V], !1);
|
|
1788
|
+
break;
|
|
1789
|
+
case "GlobalExtendedHeader":
|
|
1790
|
+
this[he] = ft.parse(this[dt], this[he], !0);
|
|
1791
|
+
break;
|
|
1792
|
+
case "NextFileHasLongPath":
|
|
1793
|
+
case "OldGnuLongPath": {
|
|
1794
|
+
let e = this[V] ?? Object.create(null);
|
|
1795
|
+
this[V] = e, e.path = this[dt].replace(/\0.*/, "");
|
|
1796
|
+
break;
|
|
1797
|
+
}
|
|
1798
|
+
case "NextFileHasLongLinkpath": {
|
|
1799
|
+
let e = this[V] || Object.create(null);
|
|
1800
|
+
this[V] = e, e.linkpath = this[dt].replace(/\0.*/, "");
|
|
1801
|
+
break;
|
|
1802
|
+
}
|
|
1803
|
+
default: throw new Error("unknown meta: " + t.type);
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
abort(t) {
|
|
1807
|
+
if (!this[$]) {
|
|
1808
|
+
if (this[w]) {
|
|
1809
|
+
let e = this[w];
|
|
1810
|
+
e.write = () => !0, e.end = () => e, e.emit = () => !1, e.destroy?.();
|
|
1811
|
+
}
|
|
1812
|
+
this[$] = !0, this.emit("abort", t), this.warn("TAR_ABORT", t, { recoverable: !1 });
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
[Xs](t) {
|
|
1816
|
+
this[$i] += t.length;
|
|
1817
|
+
let e = this[$i] / this[le];
|
|
1818
|
+
return e > this.maxDecompressionRatio ? (this.abort(/* @__PURE__ */ new Error(`max decompression ratio exceeded: ${e.toFixed(2)} > ${this.maxDecompressionRatio}`)), !1) : !0;
|
|
1819
|
+
}
|
|
1820
|
+
write(t, e, i) {
|
|
1821
|
+
if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this[$]) return i?.(), !1;
|
|
1822
|
+
if ((this[w] === void 0 || this.brotli === void 0 && this[w] === !1) && t) {
|
|
1823
|
+
if (this[p] && (t = Buffer.concat([this[p], t]), this[p] = void 0), t.length < An) return this[p] = t, i?.(), !0;
|
|
1824
|
+
for (let a = 0; this[w] === void 0 && a < Xi.length; a++) t[a] !== Xi[a] && (this[w] = !1);
|
|
1825
|
+
let o = !1;
|
|
1826
|
+
if (this[w] === !1 && this.zstd !== !1) {
|
|
1827
|
+
o = !0;
|
|
1828
|
+
for (let a = 0; a < qi.length; a++) if (t[a] !== qi[a]) {
|
|
1829
|
+
o = !1;
|
|
1830
|
+
break;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
let h = this.brotli === void 0 && !o;
|
|
1834
|
+
if (this[w] === !1 && h) if (t.length < 512) if (this[ut]) this.brotli = !0;
|
|
1835
|
+
else return this[p] = t, i?.(), !0;
|
|
1836
|
+
else try {
|
|
1837
|
+
new F(t.subarray(0, 512)), this.brotli = !1;
|
|
1838
|
+
} catch {
|
|
1839
|
+
this.brotli = !0;
|
|
1840
|
+
}
|
|
1841
|
+
if (this[w] === void 0 || this[w] === !1 && (this.brotli || o)) {
|
|
1842
|
+
let a = this[ut];
|
|
1843
|
+
this[ut] = !1, this[w] = this[w] === void 0 ? new Ue({}) : o ? new Ke({}) : new Ge({}), this[w].on("data", (c) => {
|
|
1844
|
+
this[Xs](c) && this[Xe](c);
|
|
1845
|
+
}), this[w].on("error", (c) => {
|
|
1846
|
+
this[$] || this.abort(c);
|
|
1847
|
+
}), this[w].on("end", () => {
|
|
1848
|
+
this[ut] = !0, this[Xe]();
|
|
1849
|
+
}), this[Yt] = !0, this[le] += t.length;
|
|
1850
|
+
let l = !!this[w][a ? "end" : "write"](t);
|
|
1851
|
+
return this[Yt] = !1, i?.(), l;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
this[Yt] = !0, this[w] ? (this[le] += t.length, this[w].write(t)) : this[Xe](t), this[Yt] = !1;
|
|
1855
|
+
let n = this[st].length > 0 ? !1 : this[it] ? this[it].flowing : !0;
|
|
1856
|
+
return !n && this[st].length === 0 && this[it]?.once("drain", () => this.emit("drain")), i?.(), n;
|
|
1857
|
+
}
|
|
1858
|
+
[Vi](t) {
|
|
1859
|
+
t && !this[$] && (this[p] = this[p] ? Buffer.concat([this[p], t]) : t);
|
|
1860
|
+
}
|
|
1861
|
+
[Qe]() {
|
|
1862
|
+
if (this[ut] && !this[Yi] && !this[$] && !this[ae]) {
|
|
1863
|
+
this[Yi] = !0;
|
|
1864
|
+
let t = this[Nt];
|
|
1865
|
+
if (t?.blockRemain) {
|
|
1866
|
+
let e = this[p] ? this[p].length : 0;
|
|
1867
|
+
this.warn("TAR_BAD_ARCHIVE", `Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`, { entry: t }), this[p] && t.write(this[p]), t.end();
|
|
1868
|
+
}
|
|
1869
|
+
this[At](Je);
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
[Xe](t) {
|
|
1873
|
+
if (this[ae] && t) this[Vi](t);
|
|
1874
|
+
else if (!t && !this[p]) this[Qe]();
|
|
1875
|
+
else if (t) {
|
|
1876
|
+
if (this[ae] = !0, this[p]) {
|
|
1877
|
+
this[Vi](t);
|
|
1878
|
+
let e = this[p];
|
|
1879
|
+
this[p] = void 0, this[qe](e);
|
|
1880
|
+
} else this[qe](t);
|
|
1881
|
+
for (; this[p] && this[p]?.length >= 512 && !this[$] && !this[ti];) {
|
|
1882
|
+
let e = this[p];
|
|
1883
|
+
this[p] = void 0, this[qe](e);
|
|
1884
|
+
}
|
|
1885
|
+
this[ae] = !1;
|
|
1886
|
+
}
|
|
1887
|
+
(!this[p] || this[ut]) && this[Qe]();
|
|
1888
|
+
}
|
|
1889
|
+
[qe](t) {
|
|
1890
|
+
let e = 0, i = t.length;
|
|
1891
|
+
for (; e + 512 <= i && !this[$] && !this[ti];) switch (this[B]) {
|
|
1892
|
+
case "begin":
|
|
1893
|
+
case "header":
|
|
1894
|
+
this[Vs](t, e), e += 512;
|
|
1895
|
+
break;
|
|
1896
|
+
case "ignore":
|
|
1897
|
+
case "body":
|
|
1898
|
+
e += this[Ki](t, e);
|
|
1899
|
+
break;
|
|
1900
|
+
case "meta":
|
|
1901
|
+
e += this[Ks](t, e);
|
|
1902
|
+
break;
|
|
1903
|
+
default: throw new Error("invalid state: " + this[B]);
|
|
1904
|
+
}
|
|
1905
|
+
e < i && (this[p] = this[p] ? Buffer.concat([t.subarray(e), this[p]]) : t.subarray(e));
|
|
1906
|
+
}
|
|
1907
|
+
end(t, e, i) {
|
|
1908
|
+
return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e)), i && this.once("finish", i), this[$] || (this[w] ? (t && (this[le] += t.length, this[w].write(t)), this[w].end()) : (this[ut] = !0, (this.brotli === void 0 || this.zstd === void 0) && (t = t || Buffer.alloc(0)), t && this.write(t), this[Qe]())), this;
|
|
1909
|
+
}
|
|
1910
|
+
};
|
|
1911
|
+
var mt = (s) => {
|
|
1912
|
+
let t = s.length - 1, e = -1;
|
|
1913
|
+
for (; t > -1 && s.charAt(t) === "/";) e = t, t--;
|
|
1914
|
+
return e === -1 ? s : s.slice(0, e);
|
|
1915
|
+
};
|
|
1916
|
+
var vn = (s) => {
|
|
1917
|
+
let t = s.onReadEntry;
|
|
1918
|
+
s.onReadEntry = t ? (e) => {
|
|
1919
|
+
t(e), e.resume();
|
|
1920
|
+
} : (e) => e.resume();
|
|
1921
|
+
}, Qi = (s, t) => {
|
|
1922
|
+
let e = new Map(t.map((o) => [mt(o), !0])), i = s.filter, r = 100, n = (o, h = "", a = 0) => {
|
|
1923
|
+
if (a >= r) return e.set(o, !1), !1;
|
|
1924
|
+
let l = h || parse(o).root || ".", c;
|
|
1925
|
+
if (o === l) c = !1;
|
|
1926
|
+
else {
|
|
1927
|
+
let d = e.get(o);
|
|
1928
|
+
c = d !== void 0 ? d : n(dirname(o), l, a + 1);
|
|
1929
|
+
}
|
|
1930
|
+
return e.set(o, c), c;
|
|
1931
|
+
};
|
|
1932
|
+
s.filter = i ? (o, h) => i(o, h) && n(mt(o)) : (o) => n(mt(o));
|
|
1933
|
+
}, Mn = (s) => {
|
|
1934
|
+
let t = new rt(s), e = s.file, i;
|
|
1935
|
+
try {
|
|
1936
|
+
i = Kt.openSync(e, "r");
|
|
1937
|
+
let r = Kt.fstatSync(i), n = s.maxReadSize || 16 * 1024 * 1024;
|
|
1938
|
+
if (r.size < n) {
|
|
1939
|
+
let o = Buffer.allocUnsafe(r.size), h = Kt.readSync(i, o, 0, r.size, 0);
|
|
1940
|
+
t.end(h === o.byteLength ? o : o.subarray(0, h));
|
|
1941
|
+
} else {
|
|
1942
|
+
let o = 0, h = Buffer.allocUnsafe(n);
|
|
1943
|
+
for (; o < r.size;) {
|
|
1944
|
+
let a = Kt.readSync(i, h, 0, n, o);
|
|
1945
|
+
if (a === 0) break;
|
|
1946
|
+
o += a, t.write(h.subarray(0, a));
|
|
1947
|
+
}
|
|
1948
|
+
t.end();
|
|
1949
|
+
}
|
|
1950
|
+
} finally {
|
|
1951
|
+
if (typeof i == "number") try {
|
|
1952
|
+
Kt.closeSync(i);
|
|
1953
|
+
} catch {}
|
|
1954
|
+
}
|
|
1955
|
+
}, Bn = (s, t) => {
|
|
1956
|
+
let e = new rt(s), i = s.maxReadSize || 16 * 1024 * 1024, r = s.file;
|
|
1957
|
+
return new Promise((o, h) => {
|
|
1958
|
+
e.on("error", h), e.on("end", o), Kt.stat(r, (a, l) => {
|
|
1959
|
+
if (a) h(a);
|
|
1960
|
+
else {
|
|
1961
|
+
let c = new _t(r, {
|
|
1962
|
+
readSize: i,
|
|
1963
|
+
size: l.size
|
|
1964
|
+
});
|
|
1965
|
+
c.on("error", h), c.pipe(e);
|
|
1966
|
+
}
|
|
1967
|
+
});
|
|
1968
|
+
});
|
|
1969
|
+
}, Ct = K(Mn, Bn, (s) => new rt(s), (s) => new rt(s), (s, t) => {
|
|
1970
|
+
t?.length && Qi(s, t), s.noResume || vn(s);
|
|
1971
|
+
});
|
|
1972
|
+
var Ji = (s, t, e) => (s &= 4095, e && (s = (s | 384) & -19), t && (s & 256 && (s |= 64), s & 32 && (s |= 8), s & 4 && (s |= 1)), s);
|
|
1973
|
+
var { isAbsolute: zn, parse: qs } = win32, ce = (s) => {
|
|
1974
|
+
let t = "", e = qs(s);
|
|
1975
|
+
for (; zn(s) || e.root;) {
|
|
1976
|
+
let i = s.charAt(0) === "/" && s.slice(0, 4) !== "//?/" ? "/" : e.root;
|
|
1977
|
+
s = s.slice(i.length), t += i, e = qs(s);
|
|
1978
|
+
}
|
|
1979
|
+
return [t, s];
|
|
1980
|
+
};
|
|
1981
|
+
var ei = [
|
|
1982
|
+
"|",
|
|
1983
|
+
"<",
|
|
1984
|
+
">",
|
|
1985
|
+
"?",
|
|
1986
|
+
":"
|
|
1987
|
+
], ji = ei.map((s) => String.fromCodePoint(61440 + Number(s.codePointAt(0)))), Un = new Map(ei.map((s, t) => [s, ji[t]])), Hn = new Map(ji.map((s, t) => [s, ei[t]])), ts = (s) => ei.reduce((t, e) => t.split(e).join(Un.get(e)), s), Qs = (s) => ji.reduce((t, e) => t.split(e).join(Hn.get(e)), s);
|
|
1988
|
+
var rr = (s, t) => t ? (s = f(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f(s), Wn = 16 * 1024 * 1024, tr = Symbol("process"), er = Symbol("file"), ir = Symbol("directory"), is = Symbol("symlink"), sr = Symbol("hardlink"), fe = Symbol("header"), ii = Symbol("read"), ss = Symbol("lstat"), si = Symbol("onlstat"), rs = Symbol("onread"), ns = Symbol("onreadlink"), os = Symbol("openfile"), hs = Symbol("onopenfile"), pt = Symbol("close"), ri = Symbol("mode"), as = Symbol("awaitDrain"), es = Symbol("ondrain"), q = Symbol("prefix"), de = class extends A {
|
|
1989
|
+
path;
|
|
1990
|
+
portable;
|
|
1991
|
+
myuid = process.getuid && process.getuid() || 0;
|
|
1992
|
+
myuser = process.env.USER || "";
|
|
1993
|
+
maxReadSize;
|
|
1994
|
+
linkCache;
|
|
1995
|
+
statCache;
|
|
1996
|
+
preservePaths;
|
|
1997
|
+
cwd;
|
|
1998
|
+
strict;
|
|
1999
|
+
mtime;
|
|
2000
|
+
noPax;
|
|
2001
|
+
noMtime;
|
|
2002
|
+
prefix;
|
|
2003
|
+
fd;
|
|
2004
|
+
blockLen = 0;
|
|
2005
|
+
blockRemain = 0;
|
|
2006
|
+
buf;
|
|
2007
|
+
pos = 0;
|
|
2008
|
+
remain = 0;
|
|
2009
|
+
length = 0;
|
|
2010
|
+
offset = 0;
|
|
2011
|
+
win32;
|
|
2012
|
+
absolute;
|
|
2013
|
+
header;
|
|
2014
|
+
type;
|
|
2015
|
+
linkpath;
|
|
2016
|
+
stat;
|
|
2017
|
+
onWriteEntry;
|
|
2018
|
+
#t = !1;
|
|
2019
|
+
constructor(t, e = {}) {
|
|
2020
|
+
let i = se(e);
|
|
2021
|
+
super(), this.path = f(t), this.portable = !!i.portable, this.maxReadSize = i.maxReadSize || Wn, this.linkCache = i.linkCache || /* @__PURE__ */ new Map(), this.statCache = i.statCache || /* @__PURE__ */ new Map(), this.preservePaths = !!i.preservePaths, this.cwd = f(i.cwd || process.cwd()), this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.mtime = i.mtime, this.prefix = i.prefix ? f(i.prefix) : void 0, this.onWriteEntry = i.onWriteEntry, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
|
|
2022
|
+
let r = !1;
|
|
2023
|
+
if (!this.preservePaths) {
|
|
2024
|
+
let [o, h] = ce(this.path);
|
|
2025
|
+
o && typeof h == "string" && (this.path = h, r = o);
|
|
2026
|
+
}
|
|
2027
|
+
this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Qs(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || js.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r && this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, {
|
|
2028
|
+
entry: this,
|
|
2029
|
+
path: r + this.path
|
|
2030
|
+
});
|
|
2031
|
+
let n = this.statCache.get(this.absolute);
|
|
2032
|
+
n ? this[si](n) : this[ss]();
|
|
2033
|
+
}
|
|
2034
|
+
warn(t, e, i = {}) {
|
|
2035
|
+
return Dt(this, t, e, i);
|
|
2036
|
+
}
|
|
2037
|
+
emit(t, ...e) {
|
|
2038
|
+
return t === "error" && (this.#t = !0), super.emit(t, ...e);
|
|
2039
|
+
}
|
|
2040
|
+
[ss]() {
|
|
2041
|
+
I.lstat(this.absolute, (t, e) => {
|
|
2042
|
+
if (t) return this.emit("error", t);
|
|
2043
|
+
this[si](e);
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
[si](t) {
|
|
2047
|
+
this.statCache.set(this.absolute, t), this.stat = t, t.isFile() || (t.size = 0), this.type = Gn(t), this.emit("stat", t), this[tr]();
|
|
2048
|
+
}
|
|
2049
|
+
[tr]() {
|
|
2050
|
+
switch (this.type) {
|
|
2051
|
+
case "File": return this[er]();
|
|
2052
|
+
case "Directory": return this[ir]();
|
|
2053
|
+
case "SymbolicLink": return this[is]();
|
|
2054
|
+
default: return this.end();
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
[ri](t) {
|
|
2058
|
+
return Ji(t, this.type === "Directory", this.portable);
|
|
2059
|
+
}
|
|
2060
|
+
[q](t) {
|
|
2061
|
+
return rr(t, this.prefix);
|
|
2062
|
+
}
|
|
2063
|
+
[fe]() {
|
|
2064
|
+
if (!this.stat) throw new Error("cannot write header before stat");
|
|
2065
|
+
this.type === "Directory" && this.portable && (this.noMtime = !0), this.onWriteEntry?.(this), this.header = new F({
|
|
2066
|
+
path: this[q](this.path),
|
|
2067
|
+
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
|
|
2068
|
+
mode: this[ri](this.stat.mode),
|
|
2069
|
+
uid: this.portable ? void 0 : this.stat.uid,
|
|
2070
|
+
gid: this.portable ? void 0 : this.stat.gid,
|
|
2071
|
+
size: this.stat.size,
|
|
2072
|
+
mtime: this.noMtime ? void 0 : this.mtime || this.stat.mtime,
|
|
2073
|
+
type: this.type === "Unsupported" ? void 0 : this.type,
|
|
2074
|
+
uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : "",
|
|
2075
|
+
atime: this.portable ? void 0 : this.stat.atime,
|
|
2076
|
+
ctime: this.portable ? void 0 : this.stat.ctime
|
|
2077
|
+
}), this.header.encode() && !this.noPax && super.write(new ft({
|
|
2078
|
+
atime: this.portable ? void 0 : this.header.atime,
|
|
2079
|
+
ctime: this.portable ? void 0 : this.header.ctime,
|
|
2080
|
+
gid: this.portable ? void 0 : this.header.gid,
|
|
2081
|
+
mtime: this.noMtime ? void 0 : this.mtime || this.header.mtime,
|
|
2082
|
+
path: this[q](this.path),
|
|
2083
|
+
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
|
|
2084
|
+
size: this.header.size,
|
|
2085
|
+
uid: this.portable ? void 0 : this.header.uid,
|
|
2086
|
+
uname: this.portable ? void 0 : this.header.uname,
|
|
2087
|
+
dev: this.portable ? void 0 : this.stat.dev,
|
|
2088
|
+
ino: this.portable ? void 0 : this.stat.ino,
|
|
2089
|
+
nlink: this.portable ? void 0 : this.stat.nlink
|
|
2090
|
+
}).encode());
|
|
2091
|
+
let t = this.header?.block;
|
|
2092
|
+
if (!t) throw new Error("failed to encode header");
|
|
2093
|
+
super.write(t);
|
|
2094
|
+
}
|
|
2095
|
+
[ir]() {
|
|
2096
|
+
if (!this.stat) throw new Error("cannot create directory entry without stat");
|
|
2097
|
+
this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[fe](), this.end();
|
|
2098
|
+
}
|
|
2099
|
+
[is]() {
|
|
2100
|
+
I.readlink(this.absolute, (t, e) => {
|
|
2101
|
+
if (t) return this.emit("error", t);
|
|
2102
|
+
this[ns](e);
|
|
2103
|
+
});
|
|
2104
|
+
}
|
|
2105
|
+
[ns](t) {
|
|
2106
|
+
this.linkpath = f(t), this[fe](), this.end();
|
|
2107
|
+
}
|
|
2108
|
+
[sr](t) {
|
|
2109
|
+
if (!this.stat) throw new Error("cannot create link entry without stat");
|
|
2110
|
+
this.type = "Link", this.linkpath = f(js.relative(this.cwd, t)), this.stat.size = 0, this[fe](), this.end();
|
|
2111
|
+
}
|
|
2112
|
+
[er]() {
|
|
2113
|
+
if (!this.stat) throw new Error("cannot create file entry without stat");
|
|
2114
|
+
if (this.stat.nlink > 1) {
|
|
2115
|
+
let t = `${this.stat.dev}:${this.stat.ino}`, e = this.linkCache.get(t);
|
|
2116
|
+
if (e?.indexOf(this.cwd) === 0) return this[sr](e);
|
|
2117
|
+
this.linkCache.set(t, this.absolute);
|
|
2118
|
+
}
|
|
2119
|
+
if (this[fe](), this.stat.size === 0) return this.end();
|
|
2120
|
+
this[os]();
|
|
2121
|
+
}
|
|
2122
|
+
[os]() {
|
|
2123
|
+
I.open(this.absolute, "r", (t, e) => {
|
|
2124
|
+
if (t) return this.emit("error", t);
|
|
2125
|
+
this[hs](e);
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
[hs](t) {
|
|
2129
|
+
if (this.fd = t, this.#t) return this[pt]();
|
|
2130
|
+
if (!this.stat) throw new Error("should stat before calling onopenfile");
|
|
2131
|
+
this.blockLen = 512 * Math.ceil(this.stat.size / 512), this.blockRemain = this.blockLen;
|
|
2132
|
+
let e = Math.min(this.blockLen, this.maxReadSize);
|
|
2133
|
+
this.buf = Buffer.allocUnsafe(e), this.offset = 0, this.pos = 0, this.remain = this.stat.size, this.length = this.buf.length, this[ii]();
|
|
2134
|
+
}
|
|
2135
|
+
[ii]() {
|
|
2136
|
+
let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
|
|
2137
|
+
if (t === void 0 || e === void 0) throw new Error("cannot read file without first opening");
|
|
2138
|
+
I.read(t, e, i, r, n, (o, h) => {
|
|
2139
|
+
if (o) return this[pt](() => this.emit("error", o));
|
|
2140
|
+
this[rs](h);
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
[pt](t = () => {}) {
|
|
2144
|
+
this.fd !== void 0 && I.close(this.fd, t);
|
|
2145
|
+
}
|
|
2146
|
+
[rs](t) {
|
|
2147
|
+
if (t <= 0 && this.remain > 0) {
|
|
2148
|
+
let r = Object.assign(/* @__PURE__ */ new Error("encountered unexpected EOF"), {
|
|
2149
|
+
path: this.absolute,
|
|
2150
|
+
syscall: "read",
|
|
2151
|
+
code: "EOF"
|
|
2152
|
+
});
|
|
2153
|
+
return this[pt](() => this.emit("error", r));
|
|
2154
|
+
}
|
|
2155
|
+
if (t > this.remain) {
|
|
2156
|
+
let r = Object.assign(/* @__PURE__ */ new Error("did not encounter expected EOF"), {
|
|
2157
|
+
path: this.absolute,
|
|
2158
|
+
syscall: "read",
|
|
2159
|
+
code: "EOF"
|
|
2160
|
+
});
|
|
2161
|
+
return this[pt](() => this.emit("error", r));
|
|
2162
|
+
}
|
|
2163
|
+
if (!this.buf) throw new Error("should have created buffer prior to reading");
|
|
2164
|
+
if (t === this.remain) for (let r = t; r < this.length && t < this.blockRemain; r++) this.buf[r + this.offset] = 0, t++, this.remain++;
|
|
2165
|
+
let e = this.offset === 0 && t === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + t);
|
|
2166
|
+
this.write(e) ? this[es]() : this[as](() => this[es]());
|
|
2167
|
+
}
|
|
2168
|
+
[as](t) {
|
|
2169
|
+
this.once("drain", t);
|
|
2170
|
+
}
|
|
2171
|
+
write(t, e, i) {
|
|
2172
|
+
if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this.blockRemain < t.length) {
|
|
2173
|
+
let r = Object.assign(/* @__PURE__ */ new Error("writing more data than expected"), { path: this.absolute });
|
|
2174
|
+
return this.emit("error", r);
|
|
2175
|
+
}
|
|
2176
|
+
return this.remain -= t.length, this.blockRemain -= t.length, this.pos += t.length, this.offset += t.length, super.write(t, null, i);
|
|
2177
|
+
}
|
|
2178
|
+
[es]() {
|
|
2179
|
+
if (!this.remain) return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), this[pt]((t) => t ? this.emit("error", t) : this.end());
|
|
2180
|
+
if (!this.buf) throw new Error("buffer lost somehow in ONDRAIN");
|
|
2181
|
+
this.offset >= this.length && (this.buf = Buffer.allocUnsafe(Math.min(this.blockRemain, this.buf.length)), this.offset = 0), this.length = this.buf.length - this.offset, this[ii]();
|
|
2182
|
+
}
|
|
2183
|
+
}, ni = class extends de {
|
|
2184
|
+
sync = !0;
|
|
2185
|
+
[ss]() {
|
|
2186
|
+
this[si](I.lstatSync(this.absolute));
|
|
2187
|
+
}
|
|
2188
|
+
[is]() {
|
|
2189
|
+
this[ns](I.readlinkSync(this.absolute));
|
|
2190
|
+
}
|
|
2191
|
+
[os]() {
|
|
2192
|
+
this[hs](I.openSync(this.absolute, "r"));
|
|
2193
|
+
}
|
|
2194
|
+
[ii]() {
|
|
2195
|
+
let t = !0;
|
|
2196
|
+
try {
|
|
2197
|
+
let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
|
|
2198
|
+
if (e === void 0 || i === void 0) throw new Error("fd and buf must be set in READ method");
|
|
2199
|
+
let h = I.readSync(e, i, r, n, o);
|
|
2200
|
+
this[rs](h), t = !1;
|
|
2201
|
+
} finally {
|
|
2202
|
+
if (t) try {
|
|
2203
|
+
this[pt](() => {});
|
|
2204
|
+
} catch {}
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
[as](t) {
|
|
2208
|
+
t();
|
|
2209
|
+
}
|
|
2210
|
+
[pt](t = () => {}) {
|
|
2211
|
+
this.fd !== void 0 && I.closeSync(this.fd), t();
|
|
2212
|
+
}
|
|
2213
|
+
}, oi = class extends A {
|
|
2214
|
+
blockLen = 0;
|
|
2215
|
+
blockRemain = 0;
|
|
2216
|
+
buf = 0;
|
|
2217
|
+
pos = 0;
|
|
2218
|
+
remain = 0;
|
|
2219
|
+
length = 0;
|
|
2220
|
+
preservePaths;
|
|
2221
|
+
portable;
|
|
2222
|
+
strict;
|
|
2223
|
+
noPax;
|
|
2224
|
+
noMtime;
|
|
2225
|
+
readEntry;
|
|
2226
|
+
type;
|
|
2227
|
+
prefix;
|
|
2228
|
+
path;
|
|
2229
|
+
mode;
|
|
2230
|
+
uid;
|
|
2231
|
+
gid;
|
|
2232
|
+
uname;
|
|
2233
|
+
gname;
|
|
2234
|
+
header;
|
|
2235
|
+
mtime;
|
|
2236
|
+
atime;
|
|
2237
|
+
ctime;
|
|
2238
|
+
linkpath;
|
|
2239
|
+
size;
|
|
2240
|
+
onWriteEntry;
|
|
2241
|
+
warn(t, e, i = {}) {
|
|
2242
|
+
return Dt(this, t, e, i);
|
|
2243
|
+
}
|
|
2244
|
+
constructor(t, e = {}) {
|
|
2245
|
+
let i = se(e);
|
|
2246
|
+
super(), this.preservePaths = !!i.preservePaths, this.portable = !!i.portable, this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.onWriteEntry = i.onWriteEntry, this.readEntry = t;
|
|
2247
|
+
let { type: r } = t;
|
|
2248
|
+
if (r === "Unsupported") throw new Error("writing entry that should be ignored");
|
|
2249
|
+
this.type = r, this.type === "Directory" && this.portable && (this.noMtime = !0), this.prefix = i.prefix, this.path = f(t.path), this.mode = t.mode !== void 0 ? this[ri](t.mode) : void 0, this.uid = this.portable ? void 0 : t.uid, this.gid = this.portable ? void 0 : t.gid, this.uname = this.portable ? void 0 : t.uname, this.gname = this.portable ? void 0 : t.gname, this.size = t.size, this.mtime = this.noMtime ? void 0 : i.mtime || t.mtime, this.atime = this.portable ? void 0 : t.atime, this.ctime = this.portable ? void 0 : t.ctime, this.linkpath = t.linkpath !== void 0 ? f(t.linkpath) : void 0, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
|
|
2250
|
+
let n = !1;
|
|
2251
|
+
if (!this.preservePaths) {
|
|
2252
|
+
let [h, a] = ce(this.path);
|
|
2253
|
+
h && typeof a == "string" && (this.path = a, n = h);
|
|
2254
|
+
}
|
|
2255
|
+
this.remain = t.size, this.blockRemain = t.startBlockSize, this.onWriteEntry?.(this), this.header = new F({
|
|
2256
|
+
path: this[q](this.path),
|
|
2257
|
+
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
|
|
2258
|
+
mode: this.mode,
|
|
2259
|
+
uid: this.portable ? void 0 : this.uid,
|
|
2260
|
+
gid: this.portable ? void 0 : this.gid,
|
|
2261
|
+
size: this.size,
|
|
2262
|
+
mtime: this.noMtime ? void 0 : this.mtime,
|
|
2263
|
+
type: this.type,
|
|
2264
|
+
uname: this.portable ? void 0 : this.uname,
|
|
2265
|
+
atime: this.portable ? void 0 : this.atime,
|
|
2266
|
+
ctime: this.portable ? void 0 : this.ctime
|
|
2267
|
+
}), n && this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute path`, {
|
|
2268
|
+
entry: this,
|
|
2269
|
+
path: n + this.path
|
|
2270
|
+
}), this.header.encode() && !this.noPax && super.write(new ft({
|
|
2271
|
+
atime: this.portable ? void 0 : this.atime,
|
|
2272
|
+
ctime: this.portable ? void 0 : this.ctime,
|
|
2273
|
+
gid: this.portable ? void 0 : this.gid,
|
|
2274
|
+
mtime: this.noMtime ? void 0 : this.mtime,
|
|
2275
|
+
path: this[q](this.path),
|
|
2276
|
+
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[q](this.linkpath) : this.linkpath,
|
|
2277
|
+
size: this.size,
|
|
2278
|
+
uid: this.portable ? void 0 : this.uid,
|
|
2279
|
+
uname: this.portable ? void 0 : this.uname,
|
|
2280
|
+
dev: this.portable ? void 0 : this.readEntry.dev,
|
|
2281
|
+
ino: this.portable ? void 0 : this.readEntry.ino,
|
|
2282
|
+
nlink: this.portable ? void 0 : this.readEntry.nlink
|
|
2283
|
+
}).encode());
|
|
2284
|
+
let o = this.header?.block;
|
|
2285
|
+
if (!o) throw new Error("failed to encode header");
|
|
2286
|
+
super.write(o), t.pipe(this);
|
|
2287
|
+
}
|
|
2288
|
+
[q](t) {
|
|
2289
|
+
return rr(t, this.prefix);
|
|
2290
|
+
}
|
|
2291
|
+
[ri](t) {
|
|
2292
|
+
return Ji(t, this.type === "Directory", this.portable);
|
|
2293
|
+
}
|
|
2294
|
+
write(t, e, i) {
|
|
2295
|
+
typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8"));
|
|
2296
|
+
let r = t.length;
|
|
2297
|
+
if (r > this.blockRemain) throw new Error("writing more to entry than is appropriate");
|
|
2298
|
+
return this.blockRemain -= r, super.write(t, i);
|
|
2299
|
+
}
|
|
2300
|
+
end(t, e, i) {
|
|
2301
|
+
return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e ?? "utf8")), i && this.once("finish", i), t ? super.end(t, i) : super.end(i), this;
|
|
2302
|
+
}
|
|
2303
|
+
}, Gn = (s) => s.isFile() ? "File" : s.isDirectory() ? "Directory" : s.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
|
|
2304
|
+
var hi = class s {
|
|
2305
|
+
tail;
|
|
2306
|
+
head;
|
|
2307
|
+
length = 0;
|
|
2308
|
+
static create(t = []) {
|
|
2309
|
+
return new s(t);
|
|
2310
|
+
}
|
|
2311
|
+
constructor(t = []) {
|
|
2312
|
+
for (let e of t) this.push(e);
|
|
2313
|
+
}
|
|
2314
|
+
*[Symbol.iterator]() {
|
|
2315
|
+
for (let t = this.head; t; t = t.next) yield t.value;
|
|
2316
|
+
}
|
|
2317
|
+
removeNode(t) {
|
|
2318
|
+
if (t.list !== this) throw new Error("removing node which does not belong to this list");
|
|
2319
|
+
let e = t.next, i = t.prev;
|
|
2320
|
+
return e && (e.prev = i), i && (i.next = e), t === this.head && (this.head = e), t === this.tail && (this.tail = i), this.length--, t.next = void 0, t.prev = void 0, t.list = void 0, e;
|
|
2321
|
+
}
|
|
2322
|
+
unshiftNode(t) {
|
|
2323
|
+
if (t === this.head) return;
|
|
2324
|
+
t.list && t.list.removeNode(t);
|
|
2325
|
+
let e = this.head;
|
|
2326
|
+
t.list = this, t.next = e, e && (e.prev = t), this.head = t, this.tail || (this.tail = t), this.length++;
|
|
2327
|
+
}
|
|
2328
|
+
pushNode(t) {
|
|
2329
|
+
if (t === this.tail) return;
|
|
2330
|
+
t.list && t.list.removeNode(t);
|
|
2331
|
+
let e = this.tail;
|
|
2332
|
+
t.list = this, t.prev = e, e && (e.next = t), this.tail = t, this.head || (this.head = t), this.length++;
|
|
2333
|
+
}
|
|
2334
|
+
push(...t) {
|
|
2335
|
+
for (let e = 0, i = t.length; e < i; e++) Yn(this, t[e]);
|
|
2336
|
+
return this.length;
|
|
2337
|
+
}
|
|
2338
|
+
unshift(...t) {
|
|
2339
|
+
for (var e = 0, i = t.length; e < i; e++) Kn(this, t[e]);
|
|
2340
|
+
return this.length;
|
|
2341
|
+
}
|
|
2342
|
+
pop() {
|
|
2343
|
+
if (!this.tail) return;
|
|
2344
|
+
let t = this.tail.value, e = this.tail;
|
|
2345
|
+
return this.tail = this.tail.prev, this.tail ? this.tail.next = void 0 : this.head = void 0, e.list = void 0, this.length--, t;
|
|
2346
|
+
}
|
|
2347
|
+
shift() {
|
|
2348
|
+
if (!this.head) return;
|
|
2349
|
+
let t = this.head.value, e = this.head;
|
|
2350
|
+
return this.head = this.head.next, this.head ? this.head.prev = void 0 : this.tail = void 0, e.list = void 0, this.length--, t;
|
|
2351
|
+
}
|
|
2352
|
+
forEach(t, e) {
|
|
2353
|
+
e = e || this;
|
|
2354
|
+
for (let i = this.head, r = 0; i; r++) t.call(e, i.value, r, this), i = i.next;
|
|
2355
|
+
}
|
|
2356
|
+
forEachReverse(t, e) {
|
|
2357
|
+
e = e || this;
|
|
2358
|
+
for (let i = this.tail, r = this.length - 1; i; r--) t.call(e, i.value, r, this), i = i.prev;
|
|
2359
|
+
}
|
|
2360
|
+
get(t) {
|
|
2361
|
+
let e = 0, i = this.head;
|
|
2362
|
+
for (; i && e < t; e++) i = i.next;
|
|
2363
|
+
if (e === t && i) return i.value;
|
|
2364
|
+
}
|
|
2365
|
+
getReverse(t) {
|
|
2366
|
+
let e = 0, i = this.tail;
|
|
2367
|
+
for (; i && e < t; e++) i = i.prev;
|
|
2368
|
+
if (e === t && i) return i.value;
|
|
2369
|
+
}
|
|
2370
|
+
map(t, e) {
|
|
2371
|
+
e = e || this;
|
|
2372
|
+
let i = new s();
|
|
2373
|
+
for (let r = this.head; r;) i.push(t.call(e, r.value, this)), r = r.next;
|
|
2374
|
+
return i;
|
|
2375
|
+
}
|
|
2376
|
+
mapReverse(t, e) {
|
|
2377
|
+
e = e || this;
|
|
2378
|
+
var i = new s();
|
|
2379
|
+
for (let r = this.tail; r;) i.push(t.call(e, r.value, this)), r = r.prev;
|
|
2380
|
+
return i;
|
|
2381
|
+
}
|
|
2382
|
+
reduce(t, e) {
|
|
2383
|
+
let i, r = this.head;
|
|
2384
|
+
if (arguments.length > 1) i = e;
|
|
2385
|
+
else if (this.head) r = this.head.next, i = this.head.value;
|
|
2386
|
+
else throw new TypeError("Reduce of empty list with no initial value");
|
|
2387
|
+
for (var n = 0; r; n++) i = t(i, r.value, n), r = r.next;
|
|
2388
|
+
return i;
|
|
2389
|
+
}
|
|
2390
|
+
reduceReverse(t, e) {
|
|
2391
|
+
let i, r = this.tail;
|
|
2392
|
+
if (arguments.length > 1) i = e;
|
|
2393
|
+
else if (this.tail) r = this.tail.prev, i = this.tail.value;
|
|
2394
|
+
else throw new TypeError("Reduce of empty list with no initial value");
|
|
2395
|
+
for (let n = this.length - 1; r; n--) i = t(i, r.value, n), r = r.prev;
|
|
2396
|
+
return i;
|
|
2397
|
+
}
|
|
2398
|
+
toArray() {
|
|
2399
|
+
let t = new Array(this.length);
|
|
2400
|
+
for (let e = 0, i = this.head; i; e++) t[e] = i.value, i = i.next;
|
|
2401
|
+
return t;
|
|
2402
|
+
}
|
|
2403
|
+
toArrayReverse() {
|
|
2404
|
+
let t = new Array(this.length);
|
|
2405
|
+
for (let e = 0, i = this.tail; i; e++) t[e] = i.value, i = i.prev;
|
|
2406
|
+
return t;
|
|
2407
|
+
}
|
|
2408
|
+
slice(t = 0, e = this.length) {
|
|
2409
|
+
e < 0 && (e += this.length), t < 0 && (t += this.length);
|
|
2410
|
+
let i = new s();
|
|
2411
|
+
if (e < t || e < 0) return i;
|
|
2412
|
+
t < 0 && (t = 0), e > this.length && (e = this.length);
|
|
2413
|
+
let r = this.head, n = 0;
|
|
2414
|
+
for (n = 0; r && n < t; n++) r = r.next;
|
|
2415
|
+
for (; r && n < e; n++, r = r.next) i.push(r.value);
|
|
2416
|
+
return i;
|
|
2417
|
+
}
|
|
2418
|
+
sliceReverse(t = 0, e = this.length) {
|
|
2419
|
+
e < 0 && (e += this.length), t < 0 && (t += this.length);
|
|
2420
|
+
let i = new s();
|
|
2421
|
+
if (e < t || e < 0) return i;
|
|
2422
|
+
t < 0 && (t = 0), e > this.length && (e = this.length);
|
|
2423
|
+
let r = this.length, n = this.tail;
|
|
2424
|
+
for (; n && r > e; r--) n = n.prev;
|
|
2425
|
+
for (; n && r > t; r--, n = n.prev) i.push(n.value);
|
|
2426
|
+
return i;
|
|
2427
|
+
}
|
|
2428
|
+
splice(t, e = 0, ...i) {
|
|
2429
|
+
t > this.length && (t = this.length - 1), t < 0 && (t = this.length + t);
|
|
2430
|
+
let r = this.head;
|
|
2431
|
+
for (let o = 0; r && o < t; o++) r = r.next;
|
|
2432
|
+
let n = [];
|
|
2433
|
+
for (let o = 0; r && o < e; o++) n.push(r.value), r = this.removeNode(r);
|
|
2434
|
+
r ? r !== this.tail && (r = r.prev) : r = this.tail;
|
|
2435
|
+
for (let o of i) r = Zn(this, r, o);
|
|
2436
|
+
return n;
|
|
2437
|
+
}
|
|
2438
|
+
reverse() {
|
|
2439
|
+
let t = this.head, e = this.tail;
|
|
2440
|
+
for (let i = t; i; i = i.prev) {
|
|
2441
|
+
let r = i.prev;
|
|
2442
|
+
i.prev = i.next, i.next = r;
|
|
2443
|
+
}
|
|
2444
|
+
return this.head = e, this.tail = t, this;
|
|
2445
|
+
}
|
|
2446
|
+
};
|
|
2447
|
+
function Zn(s, t, e) {
|
|
2448
|
+
let n = new ue(e, t, t ? t.next : s.head, s);
|
|
2449
|
+
return n.next === void 0 && (s.tail = n), n.prev === void 0 && (s.head = n), s.length++, n;
|
|
2450
|
+
}
|
|
2451
|
+
function Yn(s, t) {
|
|
2452
|
+
s.tail = new ue(t, s.tail, void 0, s), s.head || (s.head = s.tail), s.length++;
|
|
2453
|
+
}
|
|
2454
|
+
function Kn(s, t) {
|
|
2455
|
+
s.head = new ue(t, void 0, s.head, s), s.tail || (s.tail = s.head), s.length++;
|
|
2456
|
+
}
|
|
2457
|
+
var ue = class {
|
|
2458
|
+
list;
|
|
2459
|
+
next;
|
|
2460
|
+
prev;
|
|
2461
|
+
value;
|
|
2462
|
+
constructor(t, e, i, r) {
|
|
2463
|
+
this.list = r, this.value = t, e ? (e.next = this, this.prev = e) : this.prev = void 0, i ? (i.prev = this, this.next = i) : this.next = void 0;
|
|
2464
|
+
}
|
|
2465
|
+
};
|
|
2466
|
+
var pi = class {
|
|
2467
|
+
path;
|
|
2468
|
+
absolute;
|
|
2469
|
+
entry;
|
|
2470
|
+
stat;
|
|
2471
|
+
readdir;
|
|
2472
|
+
pending = !1;
|
|
2473
|
+
pendingLink = !1;
|
|
2474
|
+
ignore = !1;
|
|
2475
|
+
piped = !1;
|
|
2476
|
+
constructor(t, e) {
|
|
2477
|
+
this.path = t || "./", this.absolute = e;
|
|
2478
|
+
}
|
|
2479
|
+
}, nr = Buffer.alloc(1024), li = Symbol("onStat"), me = Symbol("ended"), W = Symbol("queue"), pe = Symbol("pendingLinks"), Et = Symbol("current"), Ft = Symbol("process"), Ee = Symbol("processing"), ai = Symbol("processJob"), G = Symbol("jobs"), ls = Symbol("jobDone"), ci = Symbol("addFSEntry"), or = Symbol("addTarEntry"), ds = Symbol("stat"), us = Symbol("readdir"), fi = Symbol("onreaddir"), di = Symbol("pipe"), hr = Symbol("entry"), cs = Symbol("entryOpt"), ui = Symbol("writeEntryClass"), lr = Symbol("write"), fs = Symbol("ondrain"), wt = class extends A {
|
|
2480
|
+
sync = !1;
|
|
2481
|
+
opt;
|
|
2482
|
+
cwd;
|
|
2483
|
+
maxReadSize;
|
|
2484
|
+
preservePaths;
|
|
2485
|
+
strict;
|
|
2486
|
+
noPax;
|
|
2487
|
+
prefix;
|
|
2488
|
+
linkCache;
|
|
2489
|
+
statCache;
|
|
2490
|
+
file;
|
|
2491
|
+
portable;
|
|
2492
|
+
zip;
|
|
2493
|
+
readdirCache;
|
|
2494
|
+
noDirRecurse;
|
|
2495
|
+
follow;
|
|
2496
|
+
noMtime;
|
|
2497
|
+
mtime;
|
|
2498
|
+
filter;
|
|
2499
|
+
jobs;
|
|
2500
|
+
[ui];
|
|
2501
|
+
onWriteEntry;
|
|
2502
|
+
[W];
|
|
2503
|
+
[pe] = /* @__PURE__ */ new Map();
|
|
2504
|
+
[G] = 0;
|
|
2505
|
+
[Ee] = !1;
|
|
2506
|
+
[me] = !1;
|
|
2507
|
+
constructor(t = {}) {
|
|
2508
|
+
if (super(), this.opt = t, this.file = t.file || "", this.cwd = t.cwd || process.cwd(), this.maxReadSize = t.maxReadSize, this.preservePaths = !!t.preservePaths, this.strict = !!t.strict, this.noPax = !!t.noPax, this.prefix = f(t.prefix || ""), this.linkCache = t.linkCache || /* @__PURE__ */ new Map(), this.statCache = t.statCache || /* @__PURE__ */ new Map(), this.readdirCache = t.readdirCache || /* @__PURE__ */ new Map(), this.onWriteEntry = t.onWriteEntry, this[ui] = de, typeof t.onwarn == "function" && this.on("warn", t.onwarn), this.portable = !!t.portable, t.gzip || t.brotli || t.zstd) {
|
|
2509
|
+
if ((t.gzip ? 1 : 0) + (t.brotli ? 1 : 0) + (t.zstd ? 1 : 0) > 1) throw new TypeError("gzip, brotli, zstd are mutually exclusive");
|
|
2510
|
+
if (t.gzip && (typeof t.gzip != "object" && (t.gzip = {}), this.portable && (t.gzip.portable = !0), this.zip = new ze(t.gzip)), t.brotli && (typeof t.brotli != "object" && (t.brotli = {}), this.zip = new We(t.brotli)), t.zstd && (typeof t.zstd != "object" && (t.zstd = {}), this.zip = new Ye(t.zstd)), !this.zip) throw new Error("impossible");
|
|
2511
|
+
let e = this.zip;
|
|
2512
|
+
e.on("data", (i) => super.write(i)), e.on("end", () => super.end()), e.on("drain", () => this[fs]()), this.on("resume", () => e.resume());
|
|
2513
|
+
} else this.on("drain", this[fs]);
|
|
2514
|
+
this.noDirRecurse = !!t.noDirRecurse, this.follow = !!t.follow, this.noMtime = !!t.noMtime, t.mtime && (this.mtime = t.mtime), this.filter = typeof t.filter == "function" ? t.filter : () => !0, this[W] = new hi(), this[G] = 0, this.jobs = Number(t.jobs) || 4, this[Ee] = !1, this[me] = !1;
|
|
2515
|
+
}
|
|
2516
|
+
[lr](t) {
|
|
2517
|
+
return super.write(t);
|
|
2518
|
+
}
|
|
2519
|
+
add(t) {
|
|
2520
|
+
return this.write(t), this;
|
|
2521
|
+
}
|
|
2522
|
+
end(t, e, i) {
|
|
2523
|
+
return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = void 0), t && this.add(t), this[me] = !0, this[Ft](), i && i(), this;
|
|
2524
|
+
}
|
|
2525
|
+
write(t) {
|
|
2526
|
+
if (this[me]) throw new Error("write after end");
|
|
2527
|
+
return typeof t == "string" ? this[ci](t) : this[or](t), this.flowing;
|
|
2528
|
+
}
|
|
2529
|
+
[or](t) {
|
|
2530
|
+
let e = f(js.resolve(this.cwd, t.path));
|
|
2531
|
+
if (!this.filter(t.path, t)) t.resume();
|
|
2532
|
+
else {
|
|
2533
|
+
let i = new pi(t.path, e);
|
|
2534
|
+
i.entry = new oi(t, this[cs](i)), i.entry.on("end", () => this[ls](i)), this[G] += 1, this[W].push(i);
|
|
2535
|
+
}
|
|
2536
|
+
this[Ft]();
|
|
2537
|
+
}
|
|
2538
|
+
[ci](t) {
|
|
2539
|
+
let e = f(js.resolve(this.cwd, t));
|
|
2540
|
+
this[W].push(new pi(t, e)), this[Ft]();
|
|
2541
|
+
}
|
|
2542
|
+
[ds](t) {
|
|
2543
|
+
t.pending = !0, this[G] += 1;
|
|
2544
|
+
I[this.follow ? "stat" : "lstat"](t.absolute, (i, r) => {
|
|
2545
|
+
t.pending = !1, this[G] -= 1, i ? this.emit("error", i) : this[li](t, r);
|
|
2546
|
+
});
|
|
2547
|
+
}
|
|
2548
|
+
[li](t, e) {
|
|
2549
|
+
if (this.statCache.set(t.absolute, e), t.stat = e, !this.filter(t.path, e)) t.ignore = !0;
|
|
2550
|
+
else if (e.isFile() && e.nlink > 1 && !this.linkCache.get(`${e.dev}:${e.ino}`) && !this.sync) if (t === this[Et]) this[ai](t);
|
|
2551
|
+
else {
|
|
2552
|
+
let i = `${e.dev}:${e.ino}`, r = this[pe].get(i);
|
|
2553
|
+
r ? r.push(t) : this[pe].set(i, [t]), t.pendingLink = !0, t.pending = !0;
|
|
2554
|
+
}
|
|
2555
|
+
this[Ft]();
|
|
2556
|
+
}
|
|
2557
|
+
[us](t) {
|
|
2558
|
+
t.pending = !0, this[G] += 1, I.readdir(t.absolute, (e, i) => {
|
|
2559
|
+
if (t.pending = !1, this[G] -= 1, e) return this.emit("error", e);
|
|
2560
|
+
this[fi](t, i);
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
[fi](t, e) {
|
|
2564
|
+
this.readdirCache.set(t.absolute, e), t.readdir = e, this[Ft]();
|
|
2565
|
+
}
|
|
2566
|
+
[Ft]() {
|
|
2567
|
+
if (!this[Ee]) {
|
|
2568
|
+
this[Ee] = !0;
|
|
2569
|
+
for (let t = this[W].head; t && this[G] < this.jobs; t = t.next) if (this[ai](t.value), t.value.ignore) {
|
|
2570
|
+
let e = t.next;
|
|
2571
|
+
this[W].removeNode(t), t.next = e;
|
|
2572
|
+
}
|
|
2573
|
+
this[Ee] = !1, this[me] && this[W].length === 0 && this[G] === 0 && (this.zip ? this.zip.end(nr) : (super.write(nr), super.end()));
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
get [Et]() {
|
|
2577
|
+
return this[W] && this[W].head && this[W].head.value;
|
|
2578
|
+
}
|
|
2579
|
+
[ls](t) {
|
|
2580
|
+
this[W].shift(), this[G] -= 1;
|
|
2581
|
+
let { stat: e } = t;
|
|
2582
|
+
if (e && e.isFile() && e.nlink > 1) {
|
|
2583
|
+
let i = `${e.dev}:${e.ino}`, r = this[pe].get(i);
|
|
2584
|
+
if (r) {
|
|
2585
|
+
this[pe].delete(i);
|
|
2586
|
+
for (let n of r) n.pending = !1, this[ai](n);
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
this[Ft]();
|
|
2590
|
+
}
|
|
2591
|
+
[ai](t) {
|
|
2592
|
+
if (t.pending && t.pendingLink && t === this[Et] && (t.pending = !1, t.pendingLink = !1), !t.pending) {
|
|
2593
|
+
if (t.entry) {
|
|
2594
|
+
t === this[Et] && !t.piped && this[di](t);
|
|
2595
|
+
return;
|
|
2596
|
+
}
|
|
2597
|
+
if (!t.stat) {
|
|
2598
|
+
let e = this.statCache.get(t.absolute);
|
|
2599
|
+
e ? this[li](t, e) : this[ds](t);
|
|
2600
|
+
}
|
|
2601
|
+
if (t.stat && !t.ignore) {
|
|
2602
|
+
if (!this.noDirRecurse && t.stat.isDirectory() && !t.readdir) {
|
|
2603
|
+
let e = this.readdirCache.get(t.absolute);
|
|
2604
|
+
if (e ? this[fi](t, e) : this[us](t), !t.readdir) return;
|
|
2605
|
+
}
|
|
2606
|
+
if (t.entry = this[hr](t), !t.entry) {
|
|
2607
|
+
t.ignore = !0;
|
|
2608
|
+
return;
|
|
2609
|
+
}
|
|
2610
|
+
t === this[Et] && !t.piped && this[di](t);
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
[cs](t) {
|
|
2615
|
+
return {
|
|
2616
|
+
onwarn: (e, i, r) => this.warn(e, i, r),
|
|
2617
|
+
noPax: this.noPax,
|
|
2618
|
+
cwd: this.cwd,
|
|
2619
|
+
absolute: t.absolute,
|
|
2620
|
+
preservePaths: this.preservePaths,
|
|
2621
|
+
maxReadSize: this.maxReadSize,
|
|
2622
|
+
strict: this.strict,
|
|
2623
|
+
portable: this.portable,
|
|
2624
|
+
linkCache: this.linkCache,
|
|
2625
|
+
statCache: this.statCache,
|
|
2626
|
+
noMtime: this.noMtime,
|
|
2627
|
+
mtime: this.mtime,
|
|
2628
|
+
prefix: this.prefix,
|
|
2629
|
+
onWriteEntry: this.onWriteEntry
|
|
2630
|
+
};
|
|
2631
|
+
}
|
|
2632
|
+
[hr](t) {
|
|
2633
|
+
this[G] += 1;
|
|
2634
|
+
try {
|
|
2635
|
+
return new this[ui](t.path, this[cs](t)).on("end", () => this[ls](t)).on("error", (i) => this.emit("error", i));
|
|
2636
|
+
} catch (e) {
|
|
2637
|
+
this.emit("error", e);
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
[fs]() {
|
|
2641
|
+
this[Et] && this[Et].entry && this[Et].entry.resume();
|
|
2642
|
+
}
|
|
2643
|
+
[di](t) {
|
|
2644
|
+
t.piped = !0, t.readdir && t.readdir.forEach((r) => {
|
|
2645
|
+
let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
|
|
2646
|
+
this[ci](o + r);
|
|
2647
|
+
});
|
|
2648
|
+
let e = t.entry, i = this.zip;
|
|
2649
|
+
if (!e) throw new Error("cannot pipe without source");
|
|
2650
|
+
i ? e.on("data", (r) => {
|
|
2651
|
+
i.write(r) || e.pause();
|
|
2652
|
+
}) : e.on("data", (r) => {
|
|
2653
|
+
super.write(r) || e.pause();
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
pause() {
|
|
2657
|
+
return this.zip && this.zip.pause(), super.pause();
|
|
2658
|
+
}
|
|
2659
|
+
warn(t, e, i = {}) {
|
|
2660
|
+
Dt(this, t, e, i);
|
|
2661
|
+
}
|
|
2662
|
+
}, kt = class extends wt {
|
|
2663
|
+
sync = !0;
|
|
2664
|
+
constructor(t) {
|
|
2665
|
+
super(t), this[ui] = ni;
|
|
2666
|
+
}
|
|
2667
|
+
pause() {}
|
|
2668
|
+
resume() {}
|
|
2669
|
+
[ds](t) {
|
|
2670
|
+
let e = this.follow ? "statSync" : "lstatSync";
|
|
2671
|
+
this[li](t, I[e](t.absolute));
|
|
2672
|
+
}
|
|
2673
|
+
[us](t) {
|
|
2674
|
+
this[fi](t, I.readdirSync(t.absolute));
|
|
2675
|
+
}
|
|
2676
|
+
[di](t) {
|
|
2677
|
+
let e = t.entry, i = this.zip;
|
|
2678
|
+
if (t.readdir && t.readdir.forEach((r) => {
|
|
2679
|
+
let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
|
|
2680
|
+
this[ci](o + r);
|
|
2681
|
+
}), !e) throw new Error("Cannot pipe without source");
|
|
2682
|
+
i ? e.on("data", (r) => {
|
|
2683
|
+
i.write(r);
|
|
2684
|
+
}) : e.on("data", (r) => {
|
|
2685
|
+
super[lr](r);
|
|
2686
|
+
});
|
|
2687
|
+
}
|
|
2688
|
+
}, Vn = (s, t) => {
|
|
2689
|
+
let e = new kt(s), i = new Wt(s.file, { mode: s.mode || 438 });
|
|
2690
|
+
e.pipe(i), fr(e, t);
|
|
2691
|
+
}, $n = (s, t) => {
|
|
2692
|
+
let e = new wt(s), i = new et(s.file, { mode: s.mode || 438 });
|
|
2693
|
+
e.pipe(i);
|
|
2694
|
+
let r = new Promise((n, o) => {
|
|
2695
|
+
i.on("error", o), i.on("close", n), e.on("error", o);
|
|
2696
|
+
});
|
|
2697
|
+
return dr(e, t).catch((n) => e.emit("error", n)), r;
|
|
2698
|
+
}, fr = (s, t) => {
|
|
2699
|
+
t.forEach((e) => {
|
|
2700
|
+
e.charAt(0) === "@" ? Ct({
|
|
2701
|
+
file: path.resolve(s.cwd, e.slice(1)),
|
|
2702
|
+
sync: !0,
|
|
2703
|
+
noResume: !0,
|
|
2704
|
+
onReadEntry: (i) => s.add(i)
|
|
2705
|
+
}) : s.add(e);
|
|
2706
|
+
}), s.end();
|
|
2707
|
+
}, dr = async (s, t) => {
|
|
2708
|
+
for (let e of t) e.charAt(0) === "@" ? await Ct({
|
|
2709
|
+
file: path.resolve(String(s.cwd), e.slice(1)),
|
|
2710
|
+
noResume: !0,
|
|
2711
|
+
onReadEntry: (i) => {
|
|
2712
|
+
s.add(i);
|
|
2713
|
+
}
|
|
2714
|
+
}) : s.add(e);
|
|
2715
|
+
s.end();
|
|
2716
|
+
}, Xn = (s, t) => {
|
|
2717
|
+
let e = new kt(s);
|
|
2718
|
+
return fr(e, t), e;
|
|
2719
|
+
}, qn = (s, t) => {
|
|
2720
|
+
let e = new wt(s);
|
|
2721
|
+
return dr(e, t).catch((i) => e.emit("error", i)), e;
|
|
2722
|
+
};
|
|
2723
|
+
K(Vn, $n, Xn, qn, (s, t) => {
|
|
2724
|
+
if (!t?.length) throw new TypeError("no paths specified to add to archive");
|
|
2725
|
+
});
|
|
2726
|
+
var Er = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32", { O_CREAT: wr, O_NOFOLLOW: ur, O_TRUNC: Sr, O_WRONLY: yr } = I.constants, Rr = Number(process.env.__FAKE_FS_O_FILENAME__) || I.constants.UV_FS_O_FILEMAP || 0, jn = Er && !!Rr, to = 512 * 1024, eo = Rr | Sr | wr | yr, mr = !Er && typeof ur == "number" ? ur | Sr | wr | yr : null, ms = mr !== null ? () => mr : jn ? (s) => s < to ? eo : "w" : () => "w";
|
|
2727
|
+
var ps = (s, t, e) => {
|
|
2728
|
+
try {
|
|
2729
|
+
return Kt.lchownSync(s, t, e);
|
|
2730
|
+
} catch (i) {
|
|
2731
|
+
if (i?.code !== "ENOENT") throw i;
|
|
2732
|
+
}
|
|
2733
|
+
}, Ei = (s, t, e, i) => {
|
|
2734
|
+
Kt.lchown(s, t, e, (r) => {
|
|
2735
|
+
i(r && r?.code !== "ENOENT" ? r : null);
|
|
2736
|
+
});
|
|
2737
|
+
}, io = (s, t, e, i, r) => {
|
|
2738
|
+
if (t.isDirectory()) Es(path.resolve(s, t.name), e, i, (n) => {
|
|
2739
|
+
if (n) return r(n);
|
|
2740
|
+
Ei(path.resolve(s, t.name), e, i, r);
|
|
2741
|
+
});
|
|
2742
|
+
else Ei(path.resolve(s, t.name), e, i, r);
|
|
2743
|
+
}, Es = (s, t, e, i) => {
|
|
2744
|
+
Kt.readdir(s, { withFileTypes: !0 }, (r, n) => {
|
|
2745
|
+
if (r) {
|
|
2746
|
+
if (r.code === "ENOENT") return i();
|
|
2747
|
+
if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP") return i(r);
|
|
2748
|
+
}
|
|
2749
|
+
if (r || !n.length) return Ei(s, t, e, i);
|
|
2750
|
+
let o = n.length, h = null, a = (l) => {
|
|
2751
|
+
if (!h) {
|
|
2752
|
+
if (l) return i(h = l);
|
|
2753
|
+
if (--o === 0) return Ei(s, t, e, i);
|
|
2754
|
+
}
|
|
2755
|
+
};
|
|
2756
|
+
for (let l of n) io(s, l, t, e, a);
|
|
2757
|
+
});
|
|
2758
|
+
}, so = (s, t, e, i) => {
|
|
2759
|
+
t.isDirectory() && ws(path.resolve(s, t.name), e, i), ps(path.resolve(s, t.name), e, i);
|
|
2760
|
+
}, ws = (s, t, e) => {
|
|
2761
|
+
let i;
|
|
2762
|
+
try {
|
|
2763
|
+
i = Kt.readdirSync(s, { withFileTypes: !0 });
|
|
2764
|
+
} catch (r) {
|
|
2765
|
+
let n = r;
|
|
2766
|
+
if (n?.code === "ENOENT") return;
|
|
2767
|
+
if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP") return ps(s, t, e);
|
|
2768
|
+
throw n;
|
|
2769
|
+
}
|
|
2770
|
+
for (let r of i) so(s, r, t, e);
|
|
2771
|
+
return ps(s, t, e);
|
|
2772
|
+
};
|
|
2773
|
+
var Se = class extends Error {
|
|
2774
|
+
path;
|
|
2775
|
+
code;
|
|
2776
|
+
syscall = "chdir";
|
|
2777
|
+
constructor(t, e) {
|
|
2778
|
+
super(`${e}: Cannot cd into '${t}'`), this.path = t, this.code = e;
|
|
2779
|
+
}
|
|
2780
|
+
get name() {
|
|
2781
|
+
return "CwdError";
|
|
2782
|
+
}
|
|
2783
|
+
};
|
|
2784
|
+
var St = class extends Error {
|
|
2785
|
+
path;
|
|
2786
|
+
symlink;
|
|
2787
|
+
syscall = "symlink";
|
|
2788
|
+
code = "TAR_SYMLINK_ERROR";
|
|
2789
|
+
constructor(t, e) {
|
|
2790
|
+
super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"), this.symlink = t, this.path = e;
|
|
2791
|
+
}
|
|
2792
|
+
get name() {
|
|
2793
|
+
return "SymlinkError";
|
|
2794
|
+
}
|
|
2795
|
+
};
|
|
2796
|
+
var no = (s, t) => {
|
|
2797
|
+
Kt.stat(s, (e, i) => {
|
|
2798
|
+
(e || !i.isDirectory()) && (e = new Se(s, e?.code || "ENOTDIR")), t(e);
|
|
2799
|
+
});
|
|
2800
|
+
}, gr = (s, t, e) => {
|
|
2801
|
+
s = f(s);
|
|
2802
|
+
let i = t.umask ?? 18, r = t.mode | 448, n = (r & i) !== 0, o = t.uid, h = t.gid, a = typeof o == "number" && typeof h == "number" && (o !== t.processUid || h !== t.processGid), l = t.preserve, c = t.unlink, d = f(t.cwd), y = (E, x) => {
|
|
2803
|
+
E ? e(E) : x && a ? Es(x, o, h, (Le) => y(Le)) : n ? Kt.chmod(s, r, e) : e();
|
|
2804
|
+
};
|
|
2805
|
+
if (s === d) return no(s, y);
|
|
2806
|
+
if (l) return ro.mkdir(s, {
|
|
2807
|
+
mode: r,
|
|
2808
|
+
recursive: !0
|
|
2809
|
+
}).then((E) => y(null, E ?? void 0), y);
|
|
2810
|
+
Ss(d, f(path.relative(d, s)).split("/"), r, c, d, void 0, y);
|
|
2811
|
+
}, Ss = (s, t, e, i, r, n, o) => {
|
|
2812
|
+
if (t.length === 0) return o(null, n);
|
|
2813
|
+
let h = t.shift(), a = f(path.resolve(s + "/" + h));
|
|
2814
|
+
Kt.mkdir(a, e, br(a, t, e, i, r, n, o));
|
|
2815
|
+
}, br = (s, t, e, i, r, n, o) => (h) => {
|
|
2816
|
+
h ? Kt.lstat(s, (a, l) => {
|
|
2817
|
+
if (a) a.path = a.path && f(a.path), o(a);
|
|
2818
|
+
else if (l.isDirectory()) Ss(s, t, e, i, r, n, o);
|
|
2819
|
+
else if (i) Kt.unlink(s, (c) => {
|
|
2820
|
+
if (c) return o(c);
|
|
2821
|
+
Kt.mkdir(s, e, br(s, t, e, i, r, n, o));
|
|
2822
|
+
});
|
|
2823
|
+
else {
|
|
2824
|
+
if (l.isSymbolicLink()) return o(new St(s, s + "/" + t.join("/")));
|
|
2825
|
+
o(h);
|
|
2826
|
+
}
|
|
2827
|
+
}) : (n = n || s, Ss(s, t, e, i, r, n, o));
|
|
2828
|
+
}, oo = (s) => {
|
|
2829
|
+
let t = !1, e;
|
|
2830
|
+
try {
|
|
2831
|
+
t = Kt.statSync(s).isDirectory();
|
|
2832
|
+
} catch (i) {
|
|
2833
|
+
e = i?.code;
|
|
2834
|
+
} finally {
|
|
2835
|
+
if (!t) throw new Se(s, e ?? "ENOTDIR");
|
|
2836
|
+
}
|
|
2837
|
+
}, _r = (s, t) => {
|
|
2838
|
+
s = f(s);
|
|
2839
|
+
let e = t.umask ?? 18, i = t.mode | 448, r = (i & e) !== 0, n = t.uid, o = t.gid, h = typeof n == "number" && typeof o == "number" && (n !== t.processUid || o !== t.processGid), a = t.preserve, l = t.unlink, c = f(t.cwd), d = (E) => {
|
|
2840
|
+
E && h && ws(E, n, o), r && Kt.chmodSync(s, i);
|
|
2841
|
+
};
|
|
2842
|
+
if (s === c) return oo(c), d();
|
|
2843
|
+
if (a) return d(Kt.mkdirSync(s, {
|
|
2844
|
+
mode: i,
|
|
2845
|
+
recursive: !0
|
|
2846
|
+
}) ?? void 0);
|
|
2847
|
+
let T = f(path.relative(c, s)).split("/"), D;
|
|
2848
|
+
for (let E = T.shift(), x = c; E && (x += "/" + E); E = T.shift()) {
|
|
2849
|
+
x = f(path.resolve(x));
|
|
2850
|
+
try {
|
|
2851
|
+
Kt.mkdirSync(x, i), D = D || x;
|
|
2852
|
+
} catch {
|
|
2853
|
+
let Le = Kt.lstatSync(x);
|
|
2854
|
+
if (Le.isDirectory()) continue;
|
|
2855
|
+
if (l) {
|
|
2856
|
+
Kt.unlinkSync(x), Kt.mkdirSync(x, i), D = D || x;
|
|
2857
|
+
continue;
|
|
2858
|
+
} else if (Le.isSymbolicLink()) return new St(x, x + "/" + T.join("/"));
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
return d(D);
|
|
2862
|
+
};
|
|
2863
|
+
var ys = Object.create(null), Or = 1e4, Vt = /* @__PURE__ */ new Set(), Tr = (s) => {
|
|
2864
|
+
Vt.has(s) ? Vt.delete(s) : ys[s] = s.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"), Vt.add(s);
|
|
2865
|
+
let t = ys[s], e = Vt.size - Or;
|
|
2866
|
+
if (e > Or / 10) {
|
|
2867
|
+
for (let i of Vt) if (Vt.delete(i), delete ys[i], --e <= 0) break;
|
|
2868
|
+
}
|
|
2869
|
+
return t;
|
|
2870
|
+
};
|
|
2871
|
+
var ao = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32", lo = (s) => s.split("/").slice(0, -1).reduce((e, i) => {
|
|
2872
|
+
let r = e.at(-1);
|
|
2873
|
+
return r !== void 0 && (i = join(r, i)), e.push(i || "/"), e;
|
|
2874
|
+
}, []), yi = class {
|
|
2875
|
+
#t = /* @__PURE__ */ new Map();
|
|
2876
|
+
#i = /* @__PURE__ */ new Map();
|
|
2877
|
+
#s = /* @__PURE__ */ new Set();
|
|
2878
|
+
reserve(t, e) {
|
|
2879
|
+
t = ao ? ["win32 parallelization disabled"] : t.map((r) => mt(join(Tr(r))));
|
|
2880
|
+
let i = new Set(t.map((r) => lo(r)).reduce((r, n) => r.concat(n)));
|
|
2881
|
+
this.#i.set(e, {
|
|
2882
|
+
dirs: i,
|
|
2883
|
+
paths: t
|
|
2884
|
+
});
|
|
2885
|
+
for (let r of t) {
|
|
2886
|
+
let n = this.#t.get(r);
|
|
2887
|
+
n ? n.push(e) : this.#t.set(r, [e]);
|
|
2888
|
+
}
|
|
2889
|
+
for (let r of i) {
|
|
2890
|
+
let n = this.#t.get(r);
|
|
2891
|
+
if (!n) this.#t.set(r, [new Set([e])]);
|
|
2892
|
+
else {
|
|
2893
|
+
let o = n.at(-1);
|
|
2894
|
+
o instanceof Set ? o.add(e) : n.push(new Set([e]));
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2897
|
+
return this.#r(e);
|
|
2898
|
+
}
|
|
2899
|
+
#n(t) {
|
|
2900
|
+
let e = this.#i.get(t);
|
|
2901
|
+
if (!e) throw new Error("function does not have any path reservations");
|
|
2902
|
+
return {
|
|
2903
|
+
paths: e.paths.map((i) => this.#t.get(i)),
|
|
2904
|
+
dirs: [...e.dirs].map((i) => this.#t.get(i))
|
|
2905
|
+
};
|
|
2906
|
+
}
|
|
2907
|
+
check(t) {
|
|
2908
|
+
let { paths: e, dirs: i } = this.#n(t);
|
|
2909
|
+
return e.every((r) => r && r[0] === t) && i.every((r) => r && r[0] instanceof Set && r[0].has(t));
|
|
2910
|
+
}
|
|
2911
|
+
#r(t) {
|
|
2912
|
+
return this.#s.has(t) || !this.check(t) ? !1 : (this.#s.add(t), t(() => this.#e(t)), !0);
|
|
2913
|
+
}
|
|
2914
|
+
#e(t) {
|
|
2915
|
+
if (!this.#s.has(t)) return !1;
|
|
2916
|
+
let e = this.#i.get(t);
|
|
2917
|
+
if (!e) throw new Error("invalid reservation");
|
|
2918
|
+
let { paths: i, dirs: r } = e, n = /* @__PURE__ */ new Set();
|
|
2919
|
+
for (let o of i) {
|
|
2920
|
+
let h = this.#t.get(o);
|
|
2921
|
+
if (!h || h?.[0] !== t) continue;
|
|
2922
|
+
let a = h[1];
|
|
2923
|
+
if (!a) {
|
|
2924
|
+
this.#t.delete(o);
|
|
2925
|
+
continue;
|
|
2926
|
+
}
|
|
2927
|
+
if (h.shift(), typeof a == "function") n.add(a);
|
|
2928
|
+
else for (let l of a) n.add(l);
|
|
2929
|
+
}
|
|
2930
|
+
for (let o of r) {
|
|
2931
|
+
let h = this.#t.get(o), a = h?.[0];
|
|
2932
|
+
if (!(!h || !(a instanceof Set))) if (a.size === 1 && h.length === 1) {
|
|
2933
|
+
this.#t.delete(o);
|
|
2934
|
+
continue;
|
|
2935
|
+
} else if (a.size === 1) {
|
|
2936
|
+
h.shift();
|
|
2937
|
+
let l = h[0];
|
|
2938
|
+
typeof l == "function" && n.add(l);
|
|
2939
|
+
} else a.delete(t);
|
|
2940
|
+
}
|
|
2941
|
+
return this.#s.delete(t), n.forEach((o) => this.#r(o)), !0;
|
|
2942
|
+
}
|
|
2943
|
+
};
|
|
2944
|
+
var Lr = () => process.umask();
|
|
2945
|
+
var Dr = Symbol("onEntry"), _s = Symbol("checkFs"), Nr = Symbol("checkFs2"), Os = Symbol("isReusable"), P = Symbol("makeFs"), Ts = Symbol("file"), xs = Symbol("directory"), gi = Symbol("link"), Ar = Symbol("symlink"), Ir = Symbol("hardlink"), Re = Symbol("ensureNoSymlink"), Cr = Symbol("unsupported"), Fr = Symbol("checkPath"), Rs = Symbol("stripAbsolutePath"), yt = Symbol("mkdir"), O = Symbol("onError"), Ri = Symbol("pending"), kr = Symbol("pend"), $t = Symbol("unpend"), gs = Symbol("ended"), bs = Symbol("maybeClose"), Ls = Symbol("skip"), ge = Symbol("doChown"), be = Symbol("uid"), _e = Symbol("gid"), Oe = Symbol("checkedCwd"), Te = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32", uo = 1024, mo = (s, t) => {
|
|
2946
|
+
if (!Te) return Kt.unlink(s, t);
|
|
2947
|
+
let e = s + ".DELETE." + randomBytes(16).toString("hex");
|
|
2948
|
+
Kt.rename(s, e, (i) => {
|
|
2949
|
+
if (i) return t(i);
|
|
2950
|
+
Kt.unlink(e, t);
|
|
2951
|
+
});
|
|
2952
|
+
}, po = (s) => {
|
|
2953
|
+
if (!Te) return Kt.unlinkSync(s);
|
|
2954
|
+
let t = s + ".DELETE." + randomBytes(16).toString("hex");
|
|
2955
|
+
Kt.renameSync(s, t), Kt.unlinkSync(t);
|
|
2956
|
+
}, vr = (s, t, e) => s !== void 0 && s === s >>> 0 ? s : t !== void 0 && t === t >>> 0 ? t : e, Xt = class extends rt {
|
|
2957
|
+
[gs] = !1;
|
|
2958
|
+
[Oe] = !1;
|
|
2959
|
+
[Ri] = 0;
|
|
2960
|
+
reservations = new yi();
|
|
2961
|
+
transform;
|
|
2962
|
+
writable = !0;
|
|
2963
|
+
readable = !1;
|
|
2964
|
+
uid;
|
|
2965
|
+
gid;
|
|
2966
|
+
setOwner;
|
|
2967
|
+
preserveOwner;
|
|
2968
|
+
processGid;
|
|
2969
|
+
processUid;
|
|
2970
|
+
maxDepth;
|
|
2971
|
+
forceChown;
|
|
2972
|
+
win32;
|
|
2973
|
+
newer;
|
|
2974
|
+
keep;
|
|
2975
|
+
noMtime;
|
|
2976
|
+
preservePaths;
|
|
2977
|
+
unlink;
|
|
2978
|
+
cwd;
|
|
2979
|
+
strip;
|
|
2980
|
+
processUmask;
|
|
2981
|
+
umask;
|
|
2982
|
+
dmode;
|
|
2983
|
+
fmode;
|
|
2984
|
+
chmod;
|
|
2985
|
+
constructor(t = {}) {
|
|
2986
|
+
if (t.ondone = () => {
|
|
2987
|
+
this[gs] = !0, this[bs]();
|
|
2988
|
+
}, super(t), this.transform = t.transform, this.chmod = !!t.chmod, typeof t.uid == "number" || typeof t.gid == "number") {
|
|
2989
|
+
if (typeof t.uid != "number" || typeof t.gid != "number") throw new TypeError("cannot set owner without number uid and gid");
|
|
2990
|
+
if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
|
|
2991
|
+
this.uid = t.uid, this.gid = t.gid, this.setOwner = !0;
|
|
2992
|
+
} else this.uid = void 0, this.gid = void 0, this.setOwner = !1;
|
|
2993
|
+
this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? process.getuid?.() === 0 : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : uo, this.forceChown = t.forceChown === !0, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(path.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : Lr() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Dr](e));
|
|
2994
|
+
}
|
|
2995
|
+
warn(t, e, i = {}) {
|
|
2996
|
+
return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = !1), super.warn(t, e, i);
|
|
2997
|
+
}
|
|
2998
|
+
[bs]() {
|
|
2999
|
+
this[gs] && this[Ri] === 0 && (this.emit("prefinish"), this.emit("finish"), this.emit("end"));
|
|
3000
|
+
}
|
|
3001
|
+
[Rs](t, e) {
|
|
3002
|
+
let i = t[e], { type: r } = t;
|
|
3003
|
+
if (!i || this.preservePaths) return !0;
|
|
3004
|
+
let [n, o] = ce(i), h = o.replaceAll(/\\/g, "/").split("/");
|
|
3005
|
+
if (h.includes("..") || Te && /^[a-z]:\.\.$/i.test(h[0] ?? "")) {
|
|
3006
|
+
if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, {
|
|
3007
|
+
entry: t,
|
|
3008
|
+
[e]: i
|
|
3009
|
+
}), !1;
|
|
3010
|
+
let a = path.posix.dirname(t.path), l = path.posix.normalize(path.posix.join(a, h.join("/")));
|
|
3011
|
+
if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, {
|
|
3012
|
+
entry: t,
|
|
3013
|
+
[e]: i
|
|
3014
|
+
}), !1;
|
|
3015
|
+
}
|
|
3016
|
+
return n && (t[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, {
|
|
3017
|
+
entry: t,
|
|
3018
|
+
[e]: i
|
|
3019
|
+
})), !0;
|
|
3020
|
+
}
|
|
3021
|
+
[Fr](t) {
|
|
3022
|
+
let e = f(t.path), i = e.split("/");
|
|
3023
|
+
if (this.strip) {
|
|
3024
|
+
if (i.length < this.strip) return !1;
|
|
3025
|
+
if (t.type === "Link") {
|
|
3026
|
+
let r = f(String(t.linkpath)).split("/");
|
|
3027
|
+
if (r.length >= this.strip) t.linkpath = r.slice(this.strip).join("/");
|
|
3028
|
+
else return !1;
|
|
3029
|
+
}
|
|
3030
|
+
i.splice(0, this.strip), t.path = i.join("/");
|
|
3031
|
+
}
|
|
3032
|
+
if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", {
|
|
3033
|
+
entry: t,
|
|
3034
|
+
path: e,
|
|
3035
|
+
depth: i.length,
|
|
3036
|
+
maxDepth: this.maxDepth
|
|
3037
|
+
}), !1;
|
|
3038
|
+
if (!this[Rs](t, "path") || !this[Rs](t, "linkpath")) return !1;
|
|
3039
|
+
if (t.absolute = path.isAbsolute(t.path) ? f(path.resolve(t.path)) : f(path.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", {
|
|
3040
|
+
entry: t,
|
|
3041
|
+
path: f(t.path),
|
|
3042
|
+
resolvedPath: t.absolute,
|
|
3043
|
+
cwd: this.cwd
|
|
3044
|
+
}), !1;
|
|
3045
|
+
if (t.absolute === this.cwd && t.type !== "Directory" && t.type !== "GNUDumpDir") return !1;
|
|
3046
|
+
if (this.win32) {
|
|
3047
|
+
let { root: r } = path.win32.parse(String(t.absolute));
|
|
3048
|
+
t.absolute = r + ts(String(t.absolute).slice(r.length));
|
|
3049
|
+
let { root: n } = path.win32.parse(t.path);
|
|
3050
|
+
t.path = n + ts(t.path.slice(n.length));
|
|
3051
|
+
}
|
|
3052
|
+
return !0;
|
|
3053
|
+
}
|
|
3054
|
+
[Dr](t) {
|
|
3055
|
+
if (!this[Fr](t)) return t.resume();
|
|
3056
|
+
switch (co.equal(typeof t.absolute, "string"), t.type) {
|
|
3057
|
+
case "Directory":
|
|
3058
|
+
case "GNUDumpDir": t.mode && (t.mode = t.mode | 448);
|
|
3059
|
+
case "File":
|
|
3060
|
+
case "OldFile":
|
|
3061
|
+
case "ContiguousFile":
|
|
3062
|
+
case "Link":
|
|
3063
|
+
case "SymbolicLink": return this[_s](t);
|
|
3064
|
+
default: return this[Cr](t);
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
[O](t, e) {
|
|
3068
|
+
t.name === "CwdError" ? this.emit("error", t) : (this.warn("TAR_ENTRY_ERROR", t, { entry: e }), this[$t](), e.resume());
|
|
3069
|
+
}
|
|
3070
|
+
[yt](t, e, i) {
|
|
3071
|
+
gr(f(t), {
|
|
3072
|
+
uid: this.uid,
|
|
3073
|
+
gid: this.gid,
|
|
3074
|
+
processUid: this.processUid,
|
|
3075
|
+
processGid: this.processGid,
|
|
3076
|
+
umask: this.processUmask,
|
|
3077
|
+
preserve: this.preservePaths,
|
|
3078
|
+
unlink: this.unlink,
|
|
3079
|
+
cwd: this.cwd,
|
|
3080
|
+
mode: e
|
|
3081
|
+
}, i);
|
|
3082
|
+
}
|
|
3083
|
+
[ge](t) {
|
|
3084
|
+
return this.forceChown || this.preserveOwner && (typeof t.uid == "number" && t.uid !== this.processUid || typeof t.gid == "number" && t.gid !== this.processGid) || typeof this.uid == "number" && this.uid !== this.processUid || typeof this.gid == "number" && this.gid !== this.processGid;
|
|
3085
|
+
}
|
|
3086
|
+
[be](t) {
|
|
3087
|
+
return vr(this.uid, t.uid, this.processUid);
|
|
3088
|
+
}
|
|
3089
|
+
[_e](t) {
|
|
3090
|
+
return vr(this.gid, t.gid, this.processGid);
|
|
3091
|
+
}
|
|
3092
|
+
[Ts](t, e) {
|
|
3093
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = new et(String(t.absolute), {
|
|
3094
|
+
flags: ms(t.size),
|
|
3095
|
+
mode: i,
|
|
3096
|
+
autoClose: !1
|
|
3097
|
+
});
|
|
3098
|
+
r.on("error", (a) => {
|
|
3099
|
+
r.fd && Kt.close(r.fd, () => {}), r.write = () => !0, this[O](a, t), e();
|
|
3100
|
+
});
|
|
3101
|
+
let n = 1, o = (a) => {
|
|
3102
|
+
if (a) {
|
|
3103
|
+
r.fd && Kt.close(r.fd, () => {}), this[O](a, t), e();
|
|
3104
|
+
return;
|
|
3105
|
+
}
|
|
3106
|
+
--n === 0 && r.fd !== void 0 && Kt.close(r.fd, (l) => {
|
|
3107
|
+
l ? this[O](l, t) : this[$t](), e();
|
|
3108
|
+
});
|
|
3109
|
+
};
|
|
3110
|
+
r.on("finish", () => {
|
|
3111
|
+
let a = String(t.absolute), l = r.fd;
|
|
3112
|
+
if (typeof l == "number" && t.mtime && !this.noMtime) {
|
|
3113
|
+
n++;
|
|
3114
|
+
let c = t.atime || /* @__PURE__ */ new Date(), d = t.mtime;
|
|
3115
|
+
Kt.futimes(l, c, d, (y) => y ? Kt.utimes(a, c, d, (T) => o(T && y)) : o());
|
|
3116
|
+
}
|
|
3117
|
+
if (typeof l == "number" && this[ge](t)) {
|
|
3118
|
+
n++;
|
|
3119
|
+
let c = this[be](t), d = this[_e](t);
|
|
3120
|
+
typeof c == "number" && typeof d == "number" && Kt.fchown(l, c, d, (y) => y ? Kt.chown(a, c, d, (T) => o(T && y)) : o());
|
|
3121
|
+
}
|
|
3122
|
+
o();
|
|
3123
|
+
});
|
|
3124
|
+
let h = this.transform && this.transform(t) || t;
|
|
3125
|
+
h !== t && (h.on("error", (a) => {
|
|
3126
|
+
this[O](a, t), e();
|
|
3127
|
+
}), t.pipe(h)), h.pipe(r);
|
|
3128
|
+
}
|
|
3129
|
+
[xs](t, e) {
|
|
3130
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode;
|
|
3131
|
+
this[yt](String(t.absolute), i, (r) => {
|
|
3132
|
+
if (r) {
|
|
3133
|
+
this[O](r, t), e();
|
|
3134
|
+
return;
|
|
3135
|
+
}
|
|
3136
|
+
let n = 1, o = () => {
|
|
3137
|
+
--n === 0 && (e(), this[$t](), t.resume());
|
|
3138
|
+
};
|
|
3139
|
+
t.mtime && !this.noMtime && (n++, Kt.utimes(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime, o)), this[ge](t) && (n++, Kt.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o)), o();
|
|
3140
|
+
});
|
|
3141
|
+
}
|
|
3142
|
+
[Cr](t) {
|
|
3143
|
+
t.unsupported = !0, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t.type}`, { entry: t }), t.resume();
|
|
3144
|
+
}
|
|
3145
|
+
[Ar](t, e) {
|
|
3146
|
+
let i = f(path.relative(this.cwd, path.resolve(path.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
|
|
3147
|
+
this[Re](t, this.cwd, i, () => this[gi](t, String(t.linkpath), "symlink", e), (r) => {
|
|
3148
|
+
this[O](r, t), e();
|
|
3149
|
+
});
|
|
3150
|
+
}
|
|
3151
|
+
[Ir](t, e) {
|
|
3152
|
+
let i = f(path.resolve(this.cwd, String(t.linkpath))), r = f(String(t.linkpath)).split("/");
|
|
3153
|
+
this[Re](t, this.cwd, r, () => this[gi](t, i, "link", e), (n) => {
|
|
3154
|
+
this[O](n, t), e();
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3157
|
+
[Re](t, e, i, r, n) {
|
|
3158
|
+
let o = i.shift();
|
|
3159
|
+
if (this.preservePaths || o === void 0) return r();
|
|
3160
|
+
let h = path.resolve(e, o);
|
|
3161
|
+
Kt.lstat(h, (a, l) => {
|
|
3162
|
+
if (a) return r();
|
|
3163
|
+
if (l?.isSymbolicLink()) return n(new St(h, path.resolve(h, i.join("/"))));
|
|
3164
|
+
this[Re](t, h, i, r, n);
|
|
3165
|
+
});
|
|
3166
|
+
}
|
|
3167
|
+
[kr]() {
|
|
3168
|
+
this[Ri]++;
|
|
3169
|
+
}
|
|
3170
|
+
[$t]() {
|
|
3171
|
+
this[Ri]--, this[bs]();
|
|
3172
|
+
}
|
|
3173
|
+
[Ls](t) {
|
|
3174
|
+
this[$t](), t.resume();
|
|
3175
|
+
}
|
|
3176
|
+
[Os](t, e) {
|
|
3177
|
+
return t.type === "File" && !this.unlink && e.isFile() && e.nlink <= 1 && !Te;
|
|
3178
|
+
}
|
|
3179
|
+
[_s](t) {
|
|
3180
|
+
this[kr]();
|
|
3181
|
+
let e = [t.path];
|
|
3182
|
+
t.linkpath && e.push(t.linkpath), this.reservations.reserve(e, (i) => this[Nr](t, i));
|
|
3183
|
+
}
|
|
3184
|
+
[Nr](t, e) {
|
|
3185
|
+
let i = (h) => {
|
|
3186
|
+
e(h);
|
|
3187
|
+
}, r = () => {
|
|
3188
|
+
this[yt](this.cwd, this.dmode, (h) => {
|
|
3189
|
+
if (h) {
|
|
3190
|
+
this[O](h, t), i();
|
|
3191
|
+
return;
|
|
3192
|
+
}
|
|
3193
|
+
this[Oe] = !0, n();
|
|
3194
|
+
});
|
|
3195
|
+
}, n = () => {
|
|
3196
|
+
if (t.absolute !== this.cwd) {
|
|
3197
|
+
let h = f(path.dirname(String(t.absolute)));
|
|
3198
|
+
if (h !== this.cwd) return this[yt](h, this.dmode, (a) => {
|
|
3199
|
+
if (a) {
|
|
3200
|
+
this[O](a, t), i();
|
|
3201
|
+
return;
|
|
3202
|
+
}
|
|
3203
|
+
o();
|
|
3204
|
+
});
|
|
3205
|
+
}
|
|
3206
|
+
o();
|
|
3207
|
+
}, o = () => {
|
|
3208
|
+
Kt.lstat(String(t.absolute), (h, a) => {
|
|
3209
|
+
if (a && (this.keep || this.newer && a.mtime > (t.mtime ?? a.mtime))) {
|
|
3210
|
+
this[Ls](t), i();
|
|
3211
|
+
return;
|
|
3212
|
+
}
|
|
3213
|
+
if (h || this[Os](t, a)) return this[P](null, t, i);
|
|
3214
|
+
if (a.isDirectory()) {
|
|
3215
|
+
if (t.type === "Directory") {
|
|
3216
|
+
let l = this.chmod && t.mode && (a.mode & 4095) !== t.mode, c = (d) => this[P](d ?? null, t, i);
|
|
3217
|
+
return l ? Kt.chmod(String(t.absolute), Number(t.mode), c) : c();
|
|
3218
|
+
}
|
|
3219
|
+
if (t.absolute !== this.cwd) return Kt.rmdir(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
3220
|
+
}
|
|
3221
|
+
if (t.absolute === this.cwd) return this[P](null, t, i);
|
|
3222
|
+
mo(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
3223
|
+
});
|
|
3224
|
+
};
|
|
3225
|
+
this[Oe] ? n() : r();
|
|
3226
|
+
}
|
|
3227
|
+
[P](t, e, i) {
|
|
3228
|
+
if (t) {
|
|
3229
|
+
this[O](t, e), i();
|
|
3230
|
+
return;
|
|
3231
|
+
}
|
|
3232
|
+
switch (e.type) {
|
|
3233
|
+
case "File":
|
|
3234
|
+
case "OldFile":
|
|
3235
|
+
case "ContiguousFile": return this[Ts](e, i);
|
|
3236
|
+
case "Link": return this[Ir](e, i);
|
|
3237
|
+
case "SymbolicLink": return this[Ar](e, i);
|
|
3238
|
+
case "Directory":
|
|
3239
|
+
case "GNUDumpDir": return this[xs](e, i);
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
[gi](t, e, i, r) {
|
|
3243
|
+
Kt[i](e, String(t.absolute), (n) => {
|
|
3244
|
+
n ? this[O](n, t) : (this[$t](), t.resume()), r();
|
|
3245
|
+
});
|
|
3246
|
+
}
|
|
3247
|
+
}, ye = (s) => {
|
|
3248
|
+
try {
|
|
3249
|
+
return [null, s()];
|
|
3250
|
+
} catch (t) {
|
|
3251
|
+
return [t, null];
|
|
3252
|
+
}
|
|
3253
|
+
}, xe = class extends Xt {
|
|
3254
|
+
sync = !0;
|
|
3255
|
+
[P](t, e) {
|
|
3256
|
+
return super[P](t, e, () => {});
|
|
3257
|
+
}
|
|
3258
|
+
[_s](t) {
|
|
3259
|
+
if (!this[Oe]) {
|
|
3260
|
+
let n = this[yt](this.cwd, this.dmode);
|
|
3261
|
+
if (n) return this[O](n, t);
|
|
3262
|
+
this[Oe] = !0;
|
|
3263
|
+
}
|
|
3264
|
+
if (t.absolute !== this.cwd) {
|
|
3265
|
+
let n = f(path.dirname(String(t.absolute)));
|
|
3266
|
+
if (n !== this.cwd) {
|
|
3267
|
+
let o = this[yt](n, this.dmode);
|
|
3268
|
+
if (o) return this[O](o, t);
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
let [e, i] = ye(() => Kt.lstatSync(String(t.absolute)));
|
|
3272
|
+
if (i && (this.keep || this.newer && i.mtime > (t.mtime ?? i.mtime))) return this[Ls](t);
|
|
3273
|
+
if (e || this[Os](t, i)) return this[P](null, t);
|
|
3274
|
+
if (i.isDirectory()) {
|
|
3275
|
+
if (t.type === "Directory") {
|
|
3276
|
+
let [h] = this.chmod && t.mode && (i.mode & 4095) !== t.mode ? ye(() => {
|
|
3277
|
+
Kt.chmodSync(String(t.absolute), Number(t.mode));
|
|
3278
|
+
}) : [];
|
|
3279
|
+
return this[P](h, t);
|
|
3280
|
+
}
|
|
3281
|
+
let [n] = ye(() => Kt.rmdirSync(String(t.absolute)));
|
|
3282
|
+
this[P](n, t);
|
|
3283
|
+
}
|
|
3284
|
+
let [r] = t.absolute === this.cwd ? [] : ye(() => po(String(t.absolute)));
|
|
3285
|
+
this[P](r, t);
|
|
3286
|
+
}
|
|
3287
|
+
[Ts](t, e) {
|
|
3288
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = (h) => {
|
|
3289
|
+
let a;
|
|
3290
|
+
try {
|
|
3291
|
+
Kt.closeSync(n);
|
|
3292
|
+
} catch (l) {
|
|
3293
|
+
a = l;
|
|
3294
|
+
}
|
|
3295
|
+
(h || a) && this[O](h || a, t), e();
|
|
3296
|
+
}, n;
|
|
3297
|
+
try {
|
|
3298
|
+
n = Kt.openSync(String(t.absolute), ms(t.size), i);
|
|
3299
|
+
} catch (h) {
|
|
3300
|
+
return r(h);
|
|
3301
|
+
}
|
|
3302
|
+
let o = this.transform && this.transform(t) || t;
|
|
3303
|
+
o !== t && (o.on("error", (h) => this[O](h, t)), t.pipe(o)), o.on("data", (h) => {
|
|
3304
|
+
try {
|
|
3305
|
+
Kt.writeSync(n, h, 0, h.length);
|
|
3306
|
+
} catch (a) {
|
|
3307
|
+
r(a);
|
|
3308
|
+
}
|
|
3309
|
+
}), o.on("end", () => {
|
|
3310
|
+
let h = null;
|
|
3311
|
+
if (t.mtime && !this.noMtime) {
|
|
3312
|
+
let a = t.atime || /* @__PURE__ */ new Date(), l = t.mtime;
|
|
3313
|
+
try {
|
|
3314
|
+
Kt.futimesSync(n, a, l);
|
|
3315
|
+
} catch (c) {
|
|
3316
|
+
try {
|
|
3317
|
+
Kt.utimesSync(String(t.absolute), a, l);
|
|
3318
|
+
} catch {
|
|
3319
|
+
h = c;
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
if (this[ge](t)) {
|
|
3324
|
+
let a = this[be](t), l = this[_e](t);
|
|
3325
|
+
try {
|
|
3326
|
+
Kt.fchownSync(n, Number(a), Number(l));
|
|
3327
|
+
} catch (c) {
|
|
3328
|
+
try {
|
|
3329
|
+
Kt.chownSync(String(t.absolute), Number(a), Number(l));
|
|
3330
|
+
} catch {
|
|
3331
|
+
h = h || c;
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
r(h);
|
|
3336
|
+
});
|
|
3337
|
+
}
|
|
3338
|
+
[xs](t, e) {
|
|
3339
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode, r = this[yt](String(t.absolute), i);
|
|
3340
|
+
if (r) {
|
|
3341
|
+
this[O](r, t), e();
|
|
3342
|
+
return;
|
|
3343
|
+
}
|
|
3344
|
+
if (t.mtime && !this.noMtime) try {
|
|
3345
|
+
Kt.utimesSync(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime);
|
|
3346
|
+
} catch {}
|
|
3347
|
+
if (this[ge](t)) try {
|
|
3348
|
+
Kt.chownSync(String(t.absolute), Number(this[be](t)), Number(this[_e](t)));
|
|
3349
|
+
} catch {}
|
|
3350
|
+
e(), t.resume();
|
|
3351
|
+
}
|
|
3352
|
+
[yt](t, e) {
|
|
3353
|
+
try {
|
|
3354
|
+
return _r(f(t), {
|
|
3355
|
+
uid: this.uid,
|
|
3356
|
+
gid: this.gid,
|
|
3357
|
+
processUid: this.processUid,
|
|
3358
|
+
processGid: this.processGid,
|
|
3359
|
+
umask: this.processUmask,
|
|
3360
|
+
preserve: this.preservePaths,
|
|
3361
|
+
unlink: this.unlink,
|
|
3362
|
+
cwd: this.cwd,
|
|
3363
|
+
mode: e
|
|
3364
|
+
});
|
|
3365
|
+
} catch (i) {
|
|
3366
|
+
return i;
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
[Re](t, e, i, r, n) {
|
|
3370
|
+
if (this.preservePaths || i.length === 0) return r();
|
|
3371
|
+
let o = e;
|
|
3372
|
+
for (let h of i) {
|
|
3373
|
+
o = path.resolve(o, h);
|
|
3374
|
+
let [a, l] = ye(() => Kt.lstatSync(o));
|
|
3375
|
+
if (a) return r();
|
|
3376
|
+
if (l.isSymbolicLink()) return n(new St(o, path.resolve(e, i.join("/"))));
|
|
3377
|
+
}
|
|
3378
|
+
r();
|
|
3379
|
+
}
|
|
3380
|
+
[gi](t, e, i, r) {
|
|
3381
|
+
let n = `${i}Sync`;
|
|
3382
|
+
try {
|
|
3383
|
+
Kt[n](e, String(t.absolute)), r(), t.resume();
|
|
3384
|
+
} catch (o) {
|
|
3385
|
+
return this[O](o, t);
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
};
|
|
3389
|
+
var Eo = (s) => {
|
|
3390
|
+
let t = new xe(s), e = s.file, i = Kt.statSync(e);
|
|
3391
|
+
new Be(e, {
|
|
3392
|
+
readSize: s.maxReadSize || 16 * 1024 * 1024,
|
|
3393
|
+
size: i.size
|
|
3394
|
+
}).pipe(t);
|
|
3395
|
+
}, wo = (s, t) => {
|
|
3396
|
+
let e = new Xt(s), i = s.maxReadSize || 16 * 1024 * 1024, r = s.file;
|
|
3397
|
+
return new Promise((o, h) => {
|
|
3398
|
+
e.on("error", h), e.on("close", o), Kt.stat(r, (a, l) => {
|
|
3399
|
+
if (a) h(a);
|
|
3400
|
+
else {
|
|
3401
|
+
let c = new _t(r, {
|
|
3402
|
+
readSize: i,
|
|
3403
|
+
size: l.size
|
|
3404
|
+
});
|
|
3405
|
+
c.on("error", h), c.pipe(e);
|
|
3406
|
+
}
|
|
3407
|
+
});
|
|
3408
|
+
});
|
|
3409
|
+
}, So = K(Eo, wo, (s) => new xe(s), (s) => new Xt(s), (s, t) => {
|
|
3410
|
+
t?.length && Qi(s, t);
|
|
3411
|
+
});
|
|
3412
|
+
var yo = (s, t) => {
|
|
3413
|
+
let e = new kt(s), i = !0, r, n;
|
|
3414
|
+
try {
|
|
3415
|
+
try {
|
|
3416
|
+
r = Kt.openSync(s.file, "r+");
|
|
3417
|
+
} catch (a) {
|
|
3418
|
+
if (a?.code === "ENOENT") r = Kt.openSync(s.file, "w+");
|
|
3419
|
+
else throw a;
|
|
3420
|
+
}
|
|
3421
|
+
let o = Kt.fstatSync(r), h = Buffer.alloc(512);
|
|
3422
|
+
t: for (n = 0; n < o.size; n += 512) {
|
|
3423
|
+
for (let c = 0, d = 0; c < 512; c += d) {
|
|
3424
|
+
if (d = Kt.readSync(r, h, c, h.length - c, n + c), n === 0 && h[0] === 31 && h[1] === 139) throw new Error("cannot append to compressed archives");
|
|
3425
|
+
if (!d) break t;
|
|
3426
|
+
}
|
|
3427
|
+
let a = new F(h);
|
|
3428
|
+
if (!a.cksumValid) break;
|
|
3429
|
+
let l = 512 * Math.ceil((a.size || 0) / 512);
|
|
3430
|
+
if (n + l + 512 > o.size) break;
|
|
3431
|
+
n += l, s.mtimeCache && a.mtime && s.mtimeCache.set(String(a.path), a.mtime);
|
|
3432
|
+
}
|
|
3433
|
+
i = !1, Ro(s, e, n, r, t);
|
|
3434
|
+
} finally {
|
|
3435
|
+
if (i) try {
|
|
3436
|
+
Kt.closeSync(r);
|
|
3437
|
+
} catch {}
|
|
3438
|
+
}
|
|
3439
|
+
}, Ro = (s, t, e, i, r) => {
|
|
3440
|
+
let n = new Wt(s.file, {
|
|
3441
|
+
fd: i,
|
|
3442
|
+
start: e
|
|
3443
|
+
});
|
|
3444
|
+
t.pipe(n), bo(t, r);
|
|
3445
|
+
}, go = (s, t) => {
|
|
3446
|
+
t = Array.from(t);
|
|
3447
|
+
let e = new wt(s), i = (n, o, h) => {
|
|
3448
|
+
let a = (T, D) => {
|
|
3449
|
+
T ? Kt.close(n, (E) => h(T)) : h(null, D);
|
|
3450
|
+
}, l = 0;
|
|
3451
|
+
if (o === 0) return a(null, 0);
|
|
3452
|
+
let c = 0, d = Buffer.alloc(512), y = (T, D) => {
|
|
3453
|
+
if (T || D === void 0) return a(T);
|
|
3454
|
+
if (c += D, c < 512 && D) return Kt.read(n, d, c, d.length - c, l + c, y);
|
|
3455
|
+
if (l === 0 && d[0] === 31 && d[1] === 139) return a(/* @__PURE__ */ new Error("cannot append to compressed archives"));
|
|
3456
|
+
if (c < 512) return a(null, l);
|
|
3457
|
+
let E = new F(d);
|
|
3458
|
+
if (!E.cksumValid) return a(null, l);
|
|
3459
|
+
let x = 512 * Math.ceil((E.size ?? 0) / 512);
|
|
3460
|
+
if (l + x + 512 > o || (l += x + 512, l >= o)) return a(null, l);
|
|
3461
|
+
s.mtimeCache && E.mtime && s.mtimeCache.set(String(E.path), E.mtime), c = 0, Kt.read(n, d, 0, 512, l, y);
|
|
3462
|
+
};
|
|
3463
|
+
Kt.read(n, d, 0, 512, l, y);
|
|
3464
|
+
};
|
|
3465
|
+
return new Promise((n, o) => {
|
|
3466
|
+
e.on("error", o);
|
|
3467
|
+
let h = "r+", a = (l, c) => {
|
|
3468
|
+
if (l && l.code === "ENOENT" && h === "r+") return h = "w+", Kt.open(s.file, h, a);
|
|
3469
|
+
if (l || !c) return o(l);
|
|
3470
|
+
Kt.fstat(c, (d, y) => {
|
|
3471
|
+
if (d) return Kt.close(c, () => o(d));
|
|
3472
|
+
i(c, y.size, (T, D) => {
|
|
3473
|
+
if (T) return o(T);
|
|
3474
|
+
let E = new et(s.file, {
|
|
3475
|
+
fd: c,
|
|
3476
|
+
start: D
|
|
3477
|
+
});
|
|
3478
|
+
e.pipe(E), E.on("error", o), E.on("close", n), _o(e, t);
|
|
3479
|
+
});
|
|
3480
|
+
});
|
|
3481
|
+
};
|
|
3482
|
+
Kt.open(s.file, h, a);
|
|
3483
|
+
});
|
|
3484
|
+
}, bo = (s, t) => {
|
|
3485
|
+
t.forEach((e) => {
|
|
3486
|
+
e.charAt(0) === "@" ? Ct({
|
|
3487
|
+
file: path.resolve(s.cwd, e.slice(1)),
|
|
3488
|
+
sync: !0,
|
|
3489
|
+
noResume: !0,
|
|
3490
|
+
onReadEntry: (i) => s.add(i)
|
|
3491
|
+
}) : s.add(e);
|
|
3492
|
+
}), s.end();
|
|
3493
|
+
}, _o = async (s, t) => {
|
|
3494
|
+
for (let e of t) e.charAt(0) === "@" ? await Ct({
|
|
3495
|
+
file: path.resolve(String(s.cwd), e.slice(1)),
|
|
3496
|
+
noResume: !0,
|
|
3497
|
+
onReadEntry: (i) => s.add(i)
|
|
3498
|
+
}) : s.add(e);
|
|
3499
|
+
s.end();
|
|
3500
|
+
}, vt = K(yo, go, () => {
|
|
3501
|
+
throw new TypeError("file is required");
|
|
3502
|
+
}, () => {
|
|
3503
|
+
throw new TypeError("file is required");
|
|
3504
|
+
}, (s, t) => {
|
|
3505
|
+
if (!Bs(s)) throw new TypeError("file is required");
|
|
3506
|
+
if (s.gzip || s.brotli || s.zstd || s.file.endsWith(".br") || s.file.endsWith(".tbr")) throw new TypeError("cannot append to compressed archives");
|
|
3507
|
+
if (!t?.length) throw new TypeError("no paths specified to add/replace");
|
|
3508
|
+
});
|
|
3509
|
+
K(vt.syncFile, vt.asyncFile, vt.syncNoFile, vt.asyncNoFile, (s, t = []) => {
|
|
3510
|
+
vt.validate?.(s, t), To(s);
|
|
3511
|
+
});
|
|
3512
|
+
var To = (s) => {
|
|
3513
|
+
let t = s.filter;
|
|
3514
|
+
s.mtimeCache || (s.mtimeCache = /* @__PURE__ */ new Map()), s.filter = t ? (e, i) => t(e, i) && !((s.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0)) : (e, i) => !((s.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0));
|
|
3515
|
+
};
|
|
3516
|
+
//#endregion
|
|
490
3517
|
//#region ../../packages/memory/src/embeddings.ts
|
|
491
3518
|
/**
|
|
492
3519
|
* Text used to generate embeddings for a memo.
|
|
@@ -504,7 +3531,7 @@ function buildEmbeddingText(memo) {
|
|
|
504
3531
|
*/
|
|
505
3532
|
const engineCache = /* @__PURE__ */ new Map();
|
|
506
3533
|
/**
|
|
507
|
-
* Create an embedding engine backed by
|
|
3534
|
+
* Create an embedding engine backed by the in-process WASM pipeline.
|
|
508
3535
|
* Lazily loads the model on first use so startup is not blocked.
|
|
509
3536
|
* Engines are cached by cacheDir so repeated calls with the same cacheDir
|
|
510
3537
|
* return the same instance, sharing model state and download progress.
|
|
@@ -512,21 +3539,22 @@ const engineCache = /* @__PURE__ */ new Map();
|
|
|
512
3539
|
* Defaults to "local_cache" (CWD-relative) if not provided — prefer
|
|
513
3540
|
* passing an explicit path so the cache doesn't duplicate across CWDs.
|
|
514
3541
|
*/
|
|
515
|
-
function
|
|
516
|
-
const key = cacheDir
|
|
3542
|
+
function createEmbeddingEngine(cacheDir) {
|
|
3543
|
+
const key = cacheDir === void 0 ? "" : resolve(cacheDir);
|
|
517
3544
|
const cached = engineCache.get(key);
|
|
518
3545
|
if (cached !== void 0) return cached;
|
|
519
|
-
const engine =
|
|
3546
|
+
const engine = createEmbeddingEngineImpl(cacheDir);
|
|
520
3547
|
engineCache.set(key, engine);
|
|
521
3548
|
return engine;
|
|
522
3549
|
}
|
|
523
3550
|
/** Stable identity of the model used by every engine created here. */
|
|
524
3551
|
const EMBEDDING_MODEL_NAME = "bge-small-zh-v1.5";
|
|
525
|
-
function
|
|
3552
|
+
function createEmbeddingEngineImpl(cacheDir) {
|
|
526
3553
|
let embedder = null;
|
|
527
3554
|
let initPromise = null;
|
|
528
3555
|
let loadFailed = false;
|
|
529
3556
|
let lastError;
|
|
3557
|
+
let progressListener;
|
|
530
3558
|
return {
|
|
531
3559
|
modelName: EMBEDDING_MODEL_NAME,
|
|
532
3560
|
get available() {
|
|
@@ -535,6 +3563,9 @@ function createFastEmbedEngineImpl(cacheDir) {
|
|
|
535
3563
|
get lastError() {
|
|
536
3564
|
return lastError;
|
|
537
3565
|
},
|
|
3566
|
+
setProgressListener(listener) {
|
|
3567
|
+
progressListener = listener;
|
|
3568
|
+
},
|
|
538
3569
|
async embedBatch(texts) {
|
|
539
3570
|
if (!this.available) return null;
|
|
540
3571
|
if (texts.length === 0) return [];
|
|
@@ -571,12 +3602,12 @@ function createFastEmbedEngineImpl(cacheDir) {
|
|
|
571
3602
|
if (loadFailed || initPromise === null) {
|
|
572
3603
|
loadFailed = false;
|
|
573
3604
|
lastError = void 0;
|
|
574
|
-
initPromise =
|
|
3605
|
+
initPromise = loadEmbeddingRuntime(cacheDir, (progress) => progressListener?.(progress));
|
|
575
3606
|
}
|
|
576
3607
|
embedder = await initPromise;
|
|
577
3608
|
if (embedder === null) {
|
|
578
3609
|
initPromise = null;
|
|
579
|
-
lastError = "
|
|
3610
|
+
lastError = "embedding runtime returned an empty session";
|
|
580
3611
|
return false;
|
|
581
3612
|
}
|
|
582
3613
|
loadFailed = false;
|
|
@@ -591,52 +3622,309 @@ function createFastEmbedEngineImpl(cacheDir) {
|
|
|
591
3622
|
}
|
|
592
3623
|
};
|
|
593
3624
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
3625
|
+
/** Maximum tokens per text; matches the model's position-embedding limit. */
|
|
3626
|
+
const MAX_SEQ_LEN = 512;
|
|
3627
|
+
/** Texts per inference batch: 16 × 512 × 512 floats ≈ 16MB of activations. */
|
|
3628
|
+
const EMBED_BATCH_SIZE = 16;
|
|
3629
|
+
/** Threads for the WASM backend. One keeps resolution deterministic in packaged
|
|
3630
|
+
* builds; `SCREAM_CODE_EMBEDDING_THREADS=4` is the supported opt-in. */
|
|
3631
|
+
const EMBEDDING_THREADS_ENV = "SCREAM_CODE_EMBEDDING_THREADS";
|
|
3632
|
+
/**
|
|
3633
|
+
* Token-level truncation that keeps the sentence boundary tokens.
|
|
3634
|
+
*
|
|
3635
|
+
* The tokenizer package does not apply the truncation policy itself and the
|
|
3636
|
+
* model package ships no truncation config, so this is the only place it can
|
|
3637
|
+
* happen. Keeping the head (which starts with `[CLS]`) and re-appending the
|
|
3638
|
+
* trailing special token (`[SEP]`) mirrors what a HuggingFace pipeline would
|
|
3639
|
+
* produce; slicing the tail off blindly would feed the encoder a sentence that
|
|
3640
|
+
* never closes and drift from the reference vectors on long inputs.
|
|
3641
|
+
*/
|
|
3642
|
+
function truncateEncoded(ids, types) {
|
|
3643
|
+
if (ids.length <= MAX_SEQ_LEN) return {
|
|
3644
|
+
ids: [...ids],
|
|
3645
|
+
types: [...types]
|
|
3646
|
+
};
|
|
3647
|
+
const headSize = MAX_SEQ_LEN - 1;
|
|
3648
|
+
const head = ids.slice(0, headSize);
|
|
3649
|
+
const headTypes = types.slice(0, headSize);
|
|
3650
|
+
return {
|
|
3651
|
+
ids: [...head, ids.at(-1)],
|
|
3652
|
+
types: [...headTypes, types.at(-1)]
|
|
3653
|
+
};
|
|
610
3654
|
}
|
|
611
3655
|
/**
|
|
612
|
-
*
|
|
613
|
-
*
|
|
3656
|
+
* Builds the embedding runtime in-process on `onnxruntime-web` (WASM) and the
|
|
3657
|
+
* pure-JS tokenizer. No native binaries, no install scripts: the whole stack is
|
|
3658
|
+
* JavaScript plus one WebAssembly artifact resolved from the package.
|
|
3659
|
+
*
|
|
3660
|
+
* The numeric pipeline is load-bearing and must stay compatible with the
|
|
3661
|
+
* reference embeddings of this model: token ids come from `tokenizer.json`, and
|
|
3662
|
+
* the sentence vector is the **CLS token** hidden state (`last_hidden_state[0]`)
|
|
3663
|
+
* followed by L2 normalization. Mean pooling produces visibly different vectors
|
|
3664
|
+
* (cosine ≈ 0.9 against the reference), so pooling is not a stylistic choice.
|
|
3665
|
+
*/
|
|
3666
|
+
async function createWasmRuntime(modelDir) {
|
|
3667
|
+
const ort = await import("onnxruntime-web");
|
|
3668
|
+
const { Tokenizer } = await import("@huggingface/tokenizers");
|
|
3669
|
+
const requestedThreads = Number(process.env[EMBEDDING_THREADS_ENV]);
|
|
3670
|
+
ort.env.wasm.numThreads = Number.isFinite(requestedThreads) && requestedThreads > 0 ? requestedThreads : 1;
|
|
3671
|
+
ort.env.logLevel = "error";
|
|
3672
|
+
const tokenizer = new Tokenizer(JSON.parse(readFileSync(join(modelDir, "tokenizer.json"), "utf8")), JSON.parse(readFileSync(join(modelDir, "tokenizer_config.json"), "utf8")));
|
|
3673
|
+
const session = await ort.InferenceSession.create(readFileSync(join(modelDir, "model_optimized.onnx")), { executionProviders: ["wasm"] });
|
|
3674
|
+
if (session === null || session === void 0) return null;
|
|
3675
|
+
return { async *embed(textStrings) {
|
|
3676
|
+
if (textStrings.length === 0) return;
|
|
3677
|
+
const encoded = textStrings.map((text, index) => {
|
|
3678
|
+
const encoding = tokenizer.encode(text, { return_token_type_ids: true });
|
|
3679
|
+
const types = encoding.token_type_ids ?? encoding.ids.map(() => 0);
|
|
3680
|
+
const truncated = truncateEncoded(encoding.ids, types);
|
|
3681
|
+
return {
|
|
3682
|
+
index,
|
|
3683
|
+
ids: truncated.ids,
|
|
3684
|
+
types: truncated.types
|
|
3685
|
+
};
|
|
3686
|
+
});
|
|
3687
|
+
const results = Array.from({ length: textStrings.length });
|
|
3688
|
+
const buckets = encoded.toSorted((a, b) => a.ids.length - b.ids.length);
|
|
3689
|
+
for (let start = 0; start < buckets.length; start += EMBED_BATCH_SIZE) {
|
|
3690
|
+
const group = buckets.slice(start, start + EMBED_BATCH_SIZE);
|
|
3691
|
+
const rows = group.length;
|
|
3692
|
+
const width = Math.max(...group.map((entry) => entry.ids.length));
|
|
3693
|
+
const ids = new BigInt64Array(rows * width);
|
|
3694
|
+
const mask = new BigInt64Array(rows * width);
|
|
3695
|
+
const types = new BigInt64Array(rows * width);
|
|
3696
|
+
group.forEach((entry, row) => {
|
|
3697
|
+
for (let column = 0; column < width; column++) {
|
|
3698
|
+
const offset = row * width + column;
|
|
3699
|
+
ids[offset] = BigInt(column < entry.ids.length ? entry.ids[column] : 0);
|
|
3700
|
+
mask[offset] = column < entry.ids.length ? 1n : 0n;
|
|
3701
|
+
types[offset] = BigInt(column < entry.types.length ? entry.types[column] : 0);
|
|
3702
|
+
}
|
|
3703
|
+
});
|
|
3704
|
+
const output = await session.run({
|
|
3705
|
+
input_ids: new ort.Tensor("int64", ids, [rows, width]),
|
|
3706
|
+
attention_mask: new ort.Tensor("int64", mask, [rows, width]),
|
|
3707
|
+
token_type_ids: new ort.Tensor("int64", types, [rows, width])
|
|
3708
|
+
});
|
|
3709
|
+
const hidden = output["last_hidden_state"] ?? output[Object.keys(output)[0]];
|
|
3710
|
+
const hiddenSize = hidden.dims.at(-1);
|
|
3711
|
+
const data = hidden.data;
|
|
3712
|
+
group.forEach((entry, row) => {
|
|
3713
|
+
const rowStart = row * width * hiddenSize;
|
|
3714
|
+
const vector = Array.from(data.subarray(rowStart, rowStart + hiddenSize));
|
|
3715
|
+
let norm = 0;
|
|
3716
|
+
for (const value of vector) norm += value * value;
|
|
3717
|
+
norm = Math.sqrt(norm) || 1;
|
|
3718
|
+
for (let i = 0; i < vector.length; i += 1) vector[i] = vector[i] / norm;
|
|
3719
|
+
results[entry.index] = vector;
|
|
3720
|
+
});
|
|
3721
|
+
}
|
|
3722
|
+
for (let start = 0; start < results.length; start += EMBED_BATCH_SIZE) yield results.slice(start, start + EMBED_BATCH_SIZE);
|
|
3723
|
+
} };
|
|
3724
|
+
}
|
|
3725
|
+
async function loadEmbeddingRuntime(cacheDir, emit) {
|
|
3726
|
+
if (cacheDir === void 0) {
|
|
3727
|
+
emit?.({ phase: "load" });
|
|
3728
|
+
return createWasmRuntime(join("local_cache", BGESMALLZH_CACHE_NAME));
|
|
3729
|
+
}
|
|
3730
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
3731
|
+
await ensureEmbeddingModelFiles(cacheDir, {
|
|
3732
|
+
onProgress: (received, total) => {
|
|
3733
|
+
emit?.(total === void 0 ? {
|
|
3734
|
+
phase: "download",
|
|
3735
|
+
received
|
|
3736
|
+
} : {
|
|
3737
|
+
phase: "download",
|
|
3738
|
+
received,
|
|
3739
|
+
total
|
|
3740
|
+
});
|
|
3741
|
+
},
|
|
3742
|
+
onPhase: (phase) => {
|
|
3743
|
+
if (phase === "verify") emit?.({ phase: "verify" });
|
|
3744
|
+
}
|
|
3745
|
+
});
|
|
3746
|
+
emit?.({ phase: "load" });
|
|
3747
|
+
return createWasmRuntime(join(cacheDir, BGESMALLZH_CACHE_NAME));
|
|
3748
|
+
}
|
|
3749
|
+
/**
|
|
3750
|
+
* Cache entry name for the fixed BGESmallZH model: the staged archive extracts
|
|
3751
|
+
* to `<cacheDir>/<name>/` and the runtime loads from that directory.
|
|
614
3752
|
*/
|
|
615
3753
|
const BGESMALLZH_CACHE_NAME = "fast-bge-small-zh-v1.5";
|
|
616
|
-
|
|
617
|
-
const
|
|
618
|
-
|
|
3754
|
+
/** Files the runtime needs before the model can be considered installed. */
|
|
3755
|
+
const EMBEDDING_REQUIRED_FILES = [
|
|
3756
|
+
"model_optimized.onnx",
|
|
3757
|
+
"tokenizer.json",
|
|
3758
|
+
"tokenizer_config.json"
|
|
3759
|
+
];
|
|
3760
|
+
/** Escape hatch for air-gapped installs and tests: points at an archive file. */
|
|
3761
|
+
const EMBEDDING_MODEL_URL_ENV = "SCREAM_CODE_EMBEDDING_MODEL_URL";
|
|
3762
|
+
/** Default stall guards: a trickling connection must not spin a spinner forever. */
|
|
3763
|
+
const DEFAULT_IDLE_TIMEOUT_MS = 6e4;
|
|
3764
|
+
const DEFAULT_TOTAL_TIMEOUT_MS = 15 * 6e4;
|
|
3765
|
+
/** Progress callback throttle: frequent enough to move, rare enough to be free. */
|
|
3766
|
+
const PROGRESS_THROTTLE_MS = 100;
|
|
3767
|
+
function modelDirPath(cacheDir) {
|
|
3768
|
+
return join(cacheDir, BGESMALLZH_CACHE_NAME);
|
|
3769
|
+
}
|
|
3770
|
+
function sha256File(filePath) {
|
|
3771
|
+
return readFile(filePath).then((data) => createHash("sha256").update(data).digest("hex"));
|
|
3772
|
+
}
|
|
3773
|
+
/**
|
|
3774
|
+
* Stage the embedding model files when they are missing: download the pinned
|
|
3775
|
+
* archive (HTTP status verified, unlike a naive downloader), extract,
|
|
3776
|
+
* and verify the weights payload against the pinned sha256.
|
|
3777
|
+
*
|
|
3778
|
+
* A partially extracted tree or a hash mismatch is removed so the caller keeps
|
|
3779
|
+
* the honest "weights missing" state the setup card is gated on — never a
|
|
3780
|
+
* directory that only looks installed.
|
|
3781
|
+
*/
|
|
3782
|
+
async function ensureEmbeddingModelFiles(cacheDir, options) {
|
|
3783
|
+
if (hasEmbeddingModelCache(cacheDir)) return;
|
|
3784
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
3785
|
+
const modelDir = modelDirPath(cacheDir);
|
|
3786
|
+
const stagingPath = join(cacheDir, `${BGESMALLZH_CACHE_NAME}.tar.gz.part`);
|
|
3787
|
+
const url = options?.sourceUrl ?? process.env[EMBEDDING_MODEL_URL_ENV] ?? "https://github.com/LIUTod/scream-code/releases/download/embedding-models-v1/fast-bge-small-zh-v1.5.tar.gz";
|
|
3788
|
+
const idleTimeoutMs = options?.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS;
|
|
3789
|
+
const totalTimeoutMs = options?.totalTimeoutMs ?? DEFAULT_TOTAL_TIMEOUT_MS;
|
|
3790
|
+
const controller = new AbortController();
|
|
3791
|
+
const onExternalAbort = () => {
|
|
3792
|
+
controller.abort();
|
|
3793
|
+
};
|
|
3794
|
+
if (options?.signal !== void 0) if (options.signal.aborted) controller.abort();
|
|
3795
|
+
else options.signal.addEventListener("abort", onExternalAbort, { once: true });
|
|
3796
|
+
let idleTimer;
|
|
3797
|
+
const armIdleTimer = () => {
|
|
3798
|
+
if (idleTimer !== void 0) clearTimeout(idleTimer);
|
|
3799
|
+
idleTimer = setTimeout(() => {
|
|
3800
|
+
controller.abort();
|
|
3801
|
+
}, idleTimeoutMs);
|
|
3802
|
+
};
|
|
3803
|
+
const totalTimer = setTimeout(() => {
|
|
3804
|
+
controller.abort();
|
|
3805
|
+
}, totalTimeoutMs);
|
|
3806
|
+
let received = 0;
|
|
3807
|
+
let announcedTotal;
|
|
3808
|
+
let downloadCompleted = false;
|
|
3809
|
+
const announceProgress = () => {
|
|
3810
|
+
options?.onProgress?.(received, announcedTotal);
|
|
3811
|
+
};
|
|
3812
|
+
try {
|
|
3813
|
+
let response;
|
|
3814
|
+
try {
|
|
3815
|
+
armIdleTimer();
|
|
3816
|
+
response = await fetch(url, { signal: controller.signal });
|
|
3817
|
+
} catch (error) {
|
|
3818
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3819
|
+
throw new Error(`fetch failed for ${url}: ${message}`, { cause: error });
|
|
3820
|
+
}
|
|
3821
|
+
if (!response.ok) throw new Error(`model source returned HTTP ${response.status} for ${url}`);
|
|
3822
|
+
const contentLength = Number(response.headers.get("content-length"));
|
|
3823
|
+
announcedTotal = Number.isFinite(contentLength) && contentLength > 0 ? contentLength : void 0;
|
|
3824
|
+
announceProgress();
|
|
3825
|
+
const body = response.body;
|
|
3826
|
+
if (body === null) throw new Error(`model source returned an empty body for ${url}`);
|
|
3827
|
+
const reader = body.getReader();
|
|
3828
|
+
const abortRejection = new Promise((_, reject) => {
|
|
3829
|
+
if (controller.signal.aborted) {
|
|
3830
|
+
reject(/* @__PURE__ */ new Error("aborted"));
|
|
3831
|
+
return;
|
|
3832
|
+
}
|
|
3833
|
+
controller.signal.addEventListener("abort", () => {
|
|
3834
|
+
reject(/* @__PURE__ */ new Error("aborted"));
|
|
3835
|
+
}, { once: true });
|
|
3836
|
+
});
|
|
3837
|
+
const abortAwareRead = () => Promise.race([reader.read(), abortRejection]);
|
|
3838
|
+
let handle;
|
|
3839
|
+
try {
|
|
3840
|
+
handle = await open(stagingPath, "w");
|
|
3841
|
+
} catch (error) {
|
|
3842
|
+
await reader.cancel().catch(() => void 0);
|
|
3843
|
+
throw error;
|
|
3844
|
+
}
|
|
3845
|
+
let lastProgressAt = 0;
|
|
3846
|
+
try {
|
|
3847
|
+
await (async () => {
|
|
3848
|
+
for (;;) {
|
|
3849
|
+
let chunk;
|
|
3850
|
+
try {
|
|
3851
|
+
chunk = await abortAwareRead();
|
|
3852
|
+
} catch (error) {
|
|
3853
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3854
|
+
throw new Error(`${message} (received ${received} of ${announcedTotal ?? "?"} bytes): ${url}`, { cause: error });
|
|
3855
|
+
}
|
|
3856
|
+
if (chunk.done) break;
|
|
3857
|
+
const bytes = chunk.value;
|
|
3858
|
+
armIdleTimer();
|
|
3859
|
+
await handle.write(bytes);
|
|
3860
|
+
received += bytes.byteLength;
|
|
3861
|
+
const now = Date.now();
|
|
3862
|
+
if (now - lastProgressAt >= PROGRESS_THROTTLE_MS) {
|
|
3863
|
+
lastProgressAt = now;
|
|
3864
|
+
announceProgress();
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
announceProgress();
|
|
3868
|
+
downloadCompleted = true;
|
|
3869
|
+
})();
|
|
3870
|
+
} finally {
|
|
3871
|
+
if (idleTimer !== void 0) clearTimeout(idleTimer);
|
|
3872
|
+
await handle.close();
|
|
3873
|
+
await reader.cancel().catch(() => void 0);
|
|
3874
|
+
}
|
|
3875
|
+
options?.onPhase?.("verify");
|
|
3876
|
+
await So({
|
|
3877
|
+
file: stagingPath,
|
|
3878
|
+
cwd: cacheDir
|
|
3879
|
+
});
|
|
3880
|
+
for (const fileName of EMBEDDING_REQUIRED_FILES) {
|
|
3881
|
+
const target = join(modelDir, fileName);
|
|
3882
|
+
if (!existsSync(target) || statSync(target).size === 0) throw new Error(`model package is missing ${fileName} after extraction: ${url}`);
|
|
3883
|
+
}
|
|
3884
|
+
const sha256 = await sha256File(join(modelDir, "model_optimized.onnx"));
|
|
3885
|
+
const expected = options?.expectedOnnxSha256 ?? "1294ea4b6331115a353d81f96b85e8c8d7fdcc284453d5b2fab5b016230aad38";
|
|
3886
|
+
if (sha256 !== expected) throw new Error(`model weights sha256 mismatch (${sha256.slice(0, 12)}… != ${expected.slice(0, 12)}…): ${url}`);
|
|
3887
|
+
} catch (error) {
|
|
3888
|
+
try {
|
|
3889
|
+
rmSync(modelDir, {
|
|
3890
|
+
recursive: true,
|
|
3891
|
+
force: true
|
|
3892
|
+
});
|
|
3893
|
+
} catch {}
|
|
3894
|
+
if (!downloadCompleted && controller.signal.aborted && !(options?.signal?.aborted ?? false)) throw new Error(`model download timed out (received ${received} of ${announcedTotal ?? "?"} bytes): ${url}`, { cause: error });
|
|
3895
|
+
throw error instanceof Error ? error : new Error(String(error), { cause: error });
|
|
3896
|
+
} finally {
|
|
3897
|
+
clearTimeout(totalTimer);
|
|
3898
|
+
if (idleTimer !== void 0) clearTimeout(idleTimer);
|
|
3899
|
+
if (options?.signal !== void 0) options.signal.removeEventListener("abort", onExternalAbort);
|
|
3900
|
+
rmSync(stagingPath, { force: true });
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
const INSTALL_FAILURE = /Cannot find (?:package|module) '(?:onnxruntime-web|@huggingface\/tokenizers)'|ERR_MODULE_NOT_FOUND|Failed to resolve module specifier/iu;
|
|
3904
|
+
const ARCHIVE_FAILURE = /\bTAR_[A-Z_]+|incorrect header check|unexpected end of file|invalid tar|zlib|after extraction|sha256 mismatch/iu;
|
|
3905
|
+
const NETWORK_FAILURE = /\b(?:ENOTFOUND|EAI_AGAIN|ETIMEDOUT|ECONNRESET|ECONNREFUSED|EHOSTUNREACH|socket hang up|fetch failed)\b|network error|HTTP \d{3}|timed out|empty body/iu;
|
|
619
3906
|
/**
|
|
620
|
-
* Classify a load failure so callers can say something true about it:
|
|
621
|
-
*
|
|
622
|
-
*
|
|
3907
|
+
* Classify a load failure so callers can say something true about it: an
|
|
3908
|
+
* incomplete install, a corrupt cache, a network problem and anything else need
|
|
3909
|
+
* four different answers, and they used to be reported as one network problem.
|
|
623
3910
|
*/
|
|
624
3911
|
function classifyEmbeddingFailure(message) {
|
|
625
3912
|
if (message === void 0) return "other";
|
|
626
|
-
if (
|
|
3913
|
+
if (INSTALL_FAILURE.test(message)) return "install";
|
|
627
3914
|
if (ARCHIVE_FAILURE.test(message)) return "archive";
|
|
628
3915
|
if (NETWORK_FAILURE.test(message)) return "network";
|
|
629
3916
|
return "other";
|
|
630
3917
|
}
|
|
631
3918
|
/**
|
|
632
|
-
* Loads
|
|
633
|
-
*
|
|
634
|
-
* failed".
|
|
635
|
-
*
|
|
3919
|
+
* Loads both runtime packages — no model download — so callers can tell "this
|
|
3920
|
+
* installation cannot run the local model at all" apart from "the download
|
|
3921
|
+
* failed". The runtime is JavaScript plus WebAssembly, so a failure here is an
|
|
3922
|
+
* incomplete installation rather than an unsupported platform.
|
|
636
3923
|
*/
|
|
637
3924
|
async function probeLocalEmbeddingSupport() {
|
|
638
3925
|
try {
|
|
639
|
-
await import("
|
|
3926
|
+
await import("onnxruntime-web");
|
|
3927
|
+
await import("@huggingface/tokenizers");
|
|
640
3928
|
return { supported: true };
|
|
641
3929
|
} catch (error) {
|
|
642
3930
|
return {
|
|
@@ -647,15 +3935,11 @@ async function probeLocalEmbeddingSupport() {
|
|
|
647
3935
|
}
|
|
648
3936
|
/**
|
|
649
3937
|
* Remove every trace of a previous BGESmallZH download: the extracted model
|
|
650
|
-
* directory
|
|
3938
|
+
* directory and the legacy staged archive name.
|
|
651
3939
|
*
|
|
652
|
-
* The
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
* error) reject and leave whatever was written behind. So an archive sitting
|
|
656
|
-
* next to a failed attempt is usually a partial leftover, and keeping it makes
|
|
657
|
-
* every retry extract the same junk locally: no network traffic, a few
|
|
658
|
-
* milliseconds, the same failure forever.
|
|
3940
|
+
* The legacy `<name>.tar.gz` file is still swept because older versions staged
|
|
3941
|
+
* the archive under that name; leaving it behind would waste 55MB per doomed
|
|
3942
|
+
* attempt. Our own downloader stages `.tar.gz.part` and always removes it.
|
|
659
3943
|
*
|
|
660
3944
|
* Never throws: a file locked by another process (on Windows a mapped ONNX file
|
|
661
3945
|
* stays locked) must not replace the download error the caller is reporting.
|
|
@@ -673,48 +3957,19 @@ function clearEmbeddingModelCache(cacheDir) {
|
|
|
673
3957
|
}
|
|
674
3958
|
}
|
|
675
3959
|
/**
|
|
676
|
-
* True when the
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
3960
|
+
* True when every file the runtime needs is already on disk. Loading then never
|
|
3961
|
+
* downloads, so callers can safely trigger a local load without risking a
|
|
3962
|
+
* surprise mid-query download. All required files are checked (not just the
|
|
3963
|
+
* weights): a partially restored cache must count as missing so the setup flow
|
|
3964
|
+
* repairs it instead of failing at load time.
|
|
680
3965
|
*/
|
|
681
3966
|
function hasEmbeddingModelCache(cacheDir) {
|
|
682
|
-
const modelDir =
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* Small config/tokenizer files that fastembed expects alongside model.onnx.
|
|
687
|
-
* If these are missing (e.g. GCS download partially failed), fastembed throws.
|
|
688
|
-
* We download them from HuggingFace so the model can load — this covers the
|
|
689
|
-
* case where the GCS tarball was incomplete but the HF repo is reachable.
|
|
690
|
-
*/
|
|
691
|
-
const FASTEMBED_SIDECARS = [
|
|
692
|
-
"config.json",
|
|
693
|
-
"tokenizer.json",
|
|
694
|
-
"tokenizer_config.json",
|
|
695
|
-
"special_tokens_map.json"
|
|
696
|
-
];
|
|
697
|
-
const FASTEMBED_HF_REPOS = { "fast-bge-small-zh-v1.5": "BAAI/bge-small-zh-v1.5" };
|
|
698
|
-
async function ensureFastembedModelSidecars(model, cacheDir) {
|
|
699
|
-
const repo = FASTEMBED_HF_REPOS[model];
|
|
700
|
-
if (repo === void 0) return;
|
|
701
|
-
const modelDir = join(cacheDir ?? "local_cache", model);
|
|
702
|
-
mkdirSync(modelDir, { recursive: true });
|
|
703
|
-
for (const fileName of FASTEMBED_SIDECARS) {
|
|
3967
|
+
const modelDir = modelDirPath(cacheDir);
|
|
3968
|
+
if (!existsSync(modelDir)) return false;
|
|
3969
|
+
return EMBEDDING_REQUIRED_FILES.every((fileName) => {
|
|
704
3970
|
const target = join(modelDir, fileName);
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
await access(target);
|
|
708
|
-
continue;
|
|
709
|
-
} catch {}
|
|
710
|
-
const hfUrl = `https://huggingface.co/${repo}/resolve/main/${fileName}`;
|
|
711
|
-
try {
|
|
712
|
-
const response = await fetch(hfUrl);
|
|
713
|
-
if (!response.ok) continue;
|
|
714
|
-
const { writeFile } = await import("node:fs/promises");
|
|
715
|
-
await writeFile(target, Buffer.from(await response.arrayBuffer()));
|
|
716
|
-
} catch {}
|
|
717
|
-
}
|
|
3971
|
+
return existsSync(target) && statSync(target).size > 0;
|
|
3972
|
+
});
|
|
718
3973
|
}
|
|
719
3974
|
//#endregion
|
|
720
3975
|
//#region ../../packages/memory/src/store.ts
|
|
@@ -944,7 +4199,7 @@ var MemoryMemoStore = class MemoryMemoStore {
|
|
|
944
4199
|
}
|
|
945
4200
|
for (const legacyPath of legacyPaths) {
|
|
946
4201
|
await unlink(legacyPath).catch(() => {});
|
|
947
|
-
await rmdir(dirname$
|
|
4202
|
+
await rmdir(dirname$2(legacyPath)).catch(() => {});
|
|
948
4203
|
}
|
|
949
4204
|
await writeFile(markerPath, `${migratedCount}\n`, "utf8").catch(() => {});
|
|
950
4205
|
} finally {
|
|
@@ -1390,7 +4645,7 @@ var MemoryMemoStore = class MemoryMemoStore {
|
|
|
1390
4645
|
};
|
|
1391
4646
|
}
|
|
1392
4647
|
async ensureDir() {
|
|
1393
|
-
await mkdir(dirname$
|
|
4648
|
+
await mkdir(dirname$2(this.dbPath), { recursive: true });
|
|
1394
4649
|
}
|
|
1395
4650
|
async withWriteLock(fn) {
|
|
1396
4651
|
const next = this.writeLock.then(fn, fn);
|
|
@@ -1918,7 +5173,7 @@ var DreamTracker = class {
|
|
|
1918
5173
|
state: this.state
|
|
1919
5174
|
};
|
|
1920
5175
|
try {
|
|
1921
|
-
await mkdir(dirname$
|
|
5176
|
+
await mkdir(dirname$2(this.lockPath), { recursive: true });
|
|
1922
5177
|
await writeFileAtomic(this.lockPath, JSON.stringify(data, null, 2));
|
|
1923
5178
|
} catch {}
|
|
1924
5179
|
}
|
|
@@ -1952,7 +5207,7 @@ var DreamTracker = class {
|
|
|
1952
5207
|
}
|
|
1953
5208
|
for (const candidate of candidates) try {
|
|
1954
5209
|
await rm(candidate);
|
|
1955
|
-
await rmdir(dirname$
|
|
5210
|
+
await rmdir(dirname$2(candidate)).catch(() => {});
|
|
1956
5211
|
} catch {}
|
|
1957
5212
|
}
|
|
1958
5213
|
};
|
|
@@ -2024,7 +5279,7 @@ var KnowledgeStore = class {
|
|
|
2024
5279
|
}
|
|
2025
5280
|
async _doInit() {
|
|
2026
5281
|
if (this.initialized) return;
|
|
2027
|
-
await mkdir(dirname$
|
|
5282
|
+
await mkdir(dirname$2(this.dbPath), { recursive: true });
|
|
2028
5283
|
this.db = new DatabaseSync(this.dbPath);
|
|
2029
5284
|
this.db.exec("PRAGMA journal_mode = WAL;");
|
|
2030
5285
|
this.db.exec("PRAGMA foreign_keys = ON;");
|
|
@@ -2895,7 +6150,7 @@ function entryFor(homeDir) {
|
|
|
2895
6150
|
await store.init();
|
|
2896
6151
|
const cacheDir = join$1(homeDir, "cache", "fastembed");
|
|
2897
6152
|
mkdirSync(cacheDir, { recursive: true });
|
|
2898
|
-
store.setEmbeddingEngine(
|
|
6153
|
+
store.setEmbeddingEngine(createEmbeddingEngine(cacheDir));
|
|
2899
6154
|
} catch (error) {
|
|
2900
6155
|
entries.delete(homeDir);
|
|
2901
6156
|
throw error;
|
|
@@ -2912,7 +6167,7 @@ function entryFor(homeDir) {
|
|
|
2912
6167
|
*
|
|
2913
6168
|
* The map key is the raw homeDir string so the engine cache key
|
|
2914
6169
|
* join(homeDir, 'cache', 'fastembed') stays byte-identical with every other
|
|
2915
|
-
*
|
|
6170
|
+
* createEmbeddingEngine call site: same string → same engine instance.
|
|
2916
6171
|
*/
|
|
2917
6172
|
function sharedKnowledgeStore(homeDir) {
|
|
2918
6173
|
return entryFor(homeDir).store;
|
|
@@ -2926,7 +6181,7 @@ function sharedKnowledgeStoreReady(homeDir) {
|
|
|
2926
6181
|
const HEADING_RE = /^(#{1,6})\s+(.+?)\s*$/;
|
|
2927
6182
|
const CODE_FENCE_RE = /^(\s*)(`{3,}|~{3,})/;
|
|
2928
6183
|
/**
|
|
2929
|
-
* Soft cap on chunk token count. BGE-small-zh-v1.5 (the
|
|
6184
|
+
* Soft cap on chunk token count. BGE-small-zh-v1.5 (the embedding model used
|
|
2930
6185
|
* here) has a 512-token sequence limit; chunks longer than that get truncated
|
|
2931
6186
|
* at the embedding layer, hurting retrieval quality. We split at ~480 to leave
|
|
2932
6187
|
* headroom for the heading line that gets prepended at embed time.
|
|
@@ -4172,4 +7427,4 @@ async function chunkVectorFallback(store, queryVec, topK) {
|
|
|
4172
7427
|
return results;
|
|
4173
7428
|
}
|
|
4174
7429
|
//#endregion
|
|
4175
|
-
export { sharedMemoStore as A, buildProjectTagCloud as B, applyConsolidation as C, parseMemoryMemos as D, buildExitExtractionPrompt as E, probeLocalEmbeddingSupport as F, join$1 as G, basename$1 as H, createMemoryMemo as I, relative$1 as J, normalize as K, toSummary as L, clearEmbeddingModelCache as M,
|
|
7430
|
+
export { sharedMemoStore as A, buildProjectTagCloud as B, applyConsolidation as C, parseMemoryMemos as D, buildExitExtractionPrompt as E, probeLocalEmbeddingSupport as F, join$1 as G, basename$1 as H, createMemoryMemo as I, relative$1 as J, normalize as K, toSummary as L, clearEmbeddingModelCache as M, createEmbeddingEngine as N, stripMemoryTags as O, hasEmbeddingModelCache as P, generateTags as R, DreamTracker as S, EXIT_EXTRACTION_SYSTEM_PROMPT as T, dirname$2 as U, rankMemos as V, isAbsolute$1 as W, resolve$1 as Y, splitLargeSection as _, isSupportedFile as a, sharedKnowledgeStoreReady as b, buildExtractionUserPrompt as c, extractQueryEntities as d, parseExtractionResponse as f, estimateTokens as g, chunkText as h, ingestFile as i, classifyEmbeddingFailure as j, MemoryMemoStore as k, extractEventFromChunk as l, chunkMarkdown as m, multiSearchWithTrace as n, ENTITY_TYPES as o, rerankEventsWithLlm as p, parse$1 as q, ingestDirectory as r, EXTRACTION_SYSTEM_PROMPT as s, multiSearch as t, extractJsonFromText as u, stripMarkdown as v, buildConsolidationPlan as w, KnowledgeStore as x, sharedKnowledgeStore as y, normalizeTags as z };
|