@prisma/fetch-engine 6.6.0-dev.10 → 6.6.0-dev.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BinaryType.js +1 -1
- package/dist/chmodPlusX.js +1 -1
- package/dist/{chunk-SXLYQ75W.js → chunk-4GLRZ2GS.js} +9 -9
- package/dist/{chunk-QWMYWBXN.js → chunk-H5RYYN3Z.js} +205 -205
- package/dist/{chunk-S3LWA4WZ.js → chunk-LOOX3H4O.js} +40 -40
- package/dist/{chunk-FXSJF4XA.js → chunk-MWVY55RY.js} +7 -7
- package/dist/{chunk-ZQ7VTSJF.js → chunk-N6GW4AC6.js} +81 -81
- package/dist/{chunk-OSFPEEC6.js → chunk-QGM4M3NI.js} +3 -27
- package/dist/{chunk-EQBIW23N.js → chunk-RXM4EBGR.js} +66 -68
- package/dist/{chunk-MSGI7ABO.js → chunk-SVP4SRAT.js} +1627 -1639
- package/dist/{chunk-GMWXCACB.js → chunk-TREJQGBX.js} +80 -80
- package/dist/{chunk-TEEFYD2G.js → chunk-YJOPKU47.js} +60 -60
- package/dist/cleanupCache.js +5 -5
- package/dist/download.js +15 -15
- package/dist/downloadZip.js +7 -7
- package/dist/env.js +1 -1
- package/dist/getHash.js +1 -1
- package/dist/getProxyAgent.js +3 -3
- package/dist/index.js +18 -18
- package/dist/log.js +3 -3
- package/dist/{multipart-parser-54WEFGGN.js → multipart-parser-ASKQAOL4.js} +7 -7
- package/dist/utils.js +6 -6
- package/package.json +4 -4
@@ -26,14 +26,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
26
26
|
mod
|
27
27
|
));
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var
|
30
|
-
__export(
|
29
|
+
var chunk_SVP4SRAT_exports = {};
|
30
|
+
__export(chunk_SVP4SRAT_exports, {
|
31
31
|
require_balanced_match: () => require_balanced_match,
|
32
32
|
require_p_map: () => require_p_map,
|
33
33
|
rimraf: () => rimraf
|
34
34
|
});
|
35
|
-
module.exports = __toCommonJS(
|
36
|
-
var
|
35
|
+
module.exports = __toCommonJS(chunk_SVP4SRAT_exports);
|
36
|
+
var import_chunk_QGM4M3NI = require("./chunk-QGM4M3NI.js");
|
37
37
|
var import_node_url = require("node:url");
|
38
38
|
var import_node_path = require("node:path");
|
39
39
|
var import_node_url2 = require("node:url");
|
@@ -53,7 +53,7 @@ var import_path3 = require("path");
|
|
53
53
|
var import_path4 = require("path");
|
54
54
|
var import_os = require("os");
|
55
55
|
var import_path5 = require("path");
|
56
|
-
var require_indent_string = (0,
|
56
|
+
var require_indent_string = (0, import_chunk_QGM4M3NI.__commonJS)({
|
57
57
|
"../../node_modules/.pnpm/indent-string@4.0.0/node_modules/indent-string/index.js"(exports, module2) {
|
58
58
|
"use strict";
|
59
59
|
module2.exports = (string, count = 1, options) => {
|
@@ -85,10 +85,10 @@ var require_indent_string = (0, import_chunk_OSFPEEC6.__commonJS)({
|
|
85
85
|
};
|
86
86
|
}
|
87
87
|
});
|
88
|
-
var require_clean_stack = (0,
|
88
|
+
var require_clean_stack = (0, import_chunk_QGM4M3NI.__commonJS)({
|
89
89
|
"../../node_modules/.pnpm/clean-stack@2.2.0/node_modules/clean-stack/index.js"(exports, module2) {
|
90
90
|
"use strict";
|
91
|
-
var os = (0,
|
91
|
+
var os = (0, import_chunk_QGM4M3NI.__require)("os");
|
92
92
|
var extractPathRegex = /\s+at.*(?:\(|\s)(.*)\)?/;
|
93
93
|
var pathRegex = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/;
|
94
94
|
var homeDir = typeof os.homedir === "undefined" ? "" : os.homedir();
|
@@ -113,7 +113,7 @@ var require_clean_stack = (0, import_chunk_OSFPEEC6.__commonJS)({
|
|
113
113
|
};
|
114
114
|
}
|
115
115
|
});
|
116
|
-
var require_aggregate_error = (0,
|
116
|
+
var require_aggregate_error = (0, import_chunk_QGM4M3NI.__commonJS)({
|
117
117
|
"../../node_modules/.pnpm/aggregate-error@3.1.0/node_modules/aggregate-error/index.js"(exports, module2) {
|
118
118
|
"use strict";
|
119
119
|
var indentString = require_indent_string();
|
@@ -150,7 +150,7 @@ var require_aggregate_error = (0, import_chunk_OSFPEEC6.__commonJS)({
|
|
150
150
|
module2.exports = AggregateError;
|
151
151
|
}
|
152
152
|
});
|
153
|
-
var require_p_map = (0,
|
153
|
+
var require_p_map = (0, import_chunk_QGM4M3NI.__commonJS)({
|
154
154
|
"../../node_modules/.pnpm/p-map@4.0.0/node_modules/p-map/index.js"(exports, module2) {
|
155
155
|
"use strict";
|
156
156
|
var AggregateError = require_aggregate_error();
|
@@ -219,7 +219,7 @@ var require_p_map = (0, import_chunk_OSFPEEC6.__commonJS)({
|
|
219
219
|
};
|
220
220
|
}
|
221
221
|
});
|
222
|
-
var require_balanced_match = (0,
|
222
|
+
var require_balanced_match = (0, import_chunk_QGM4M3NI.__commonJS)({
|
223
223
|
"../../node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports, module2) {
|
224
224
|
"use strict";
|
225
225
|
module2.exports = balanced;
|
@@ -275,7 +275,7 @@ var require_balanced_match = (0, import_chunk_OSFPEEC6.__commonJS)({
|
|
275
275
|
}
|
276
276
|
}
|
277
277
|
});
|
278
|
-
var require_brace_expansion = (0,
|
278
|
+
var require_brace_expansion = (0, import_chunk_QGM4M3NI.__commonJS)({
|
279
279
|
"../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js"(exports, module2) {
|
280
280
|
"use strict";
|
281
281
|
var balanced = require_balanced_match();
|
@@ -424,7 +424,7 @@ var require_brace_expansion = (0, import_chunk_OSFPEEC6.__commonJS)({
|
|
424
424
|
}
|
425
425
|
}
|
426
426
|
});
|
427
|
-
var import_brace_expansion = (0,
|
427
|
+
var import_brace_expansion = (0, import_chunk_QGM4M3NI.__toESM)(require_brace_expansion(), 1);
|
428
428
|
var MAX_PATTERN_LENGTH = 1024 * 64;
|
429
429
|
var assertValidPattern = (pattern) => {
|
430
430
|
if (typeof pattern !== "string") {
|
@@ -555,100 +555,128 @@ var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
555
555
|
var qmark = "[^/]";
|
556
556
|
var star = qmark + "*?";
|
557
557
|
var starNoEmpty = qmark + "+?";
|
558
|
-
var
|
559
|
-
|
558
|
+
var AST = class _AST {
|
559
|
+
type;
|
560
|
+
#root;
|
561
|
+
#hasMagic;
|
562
|
+
#uflag = false;
|
563
|
+
#parts = [];
|
564
|
+
#parent;
|
565
|
+
#parentIndex;
|
566
|
+
#negs;
|
567
|
+
#filledNegs = false;
|
568
|
+
#options;
|
569
|
+
#toString;
|
570
|
+
// set to true if it's an extglob with no children
|
571
|
+
// (which really means one child of '')
|
572
|
+
#emptyExt = false;
|
560
573
|
constructor(type, parent, options = {}) {
|
561
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _AST_instances);
|
562
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "type");
|
563
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _root);
|
564
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _hasMagic);
|
565
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _uflag, false);
|
566
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _parts, []);
|
567
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _parent);
|
568
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _parentIndex);
|
569
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _negs);
|
570
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _filledNegs, false);
|
571
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _options);
|
572
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _toString);
|
573
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _emptyExt, false);
|
574
574
|
this.type = type;
|
575
575
|
if (type)
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
if (type === "!" && !
|
582
|
-
|
583
|
-
|
576
|
+
this.#hasMagic = true;
|
577
|
+
this.#parent = parent;
|
578
|
+
this.#root = this.#parent ? this.#parent.#root : this;
|
579
|
+
this.#options = this.#root === this ? options : this.#root.#options;
|
580
|
+
this.#negs = this.#root === this ? [] : this.#root.#negs;
|
581
|
+
if (type === "!" && !this.#root.#filledNegs)
|
582
|
+
this.#negs.push(this);
|
583
|
+
this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
|
584
584
|
}
|
585
585
|
get hasMagic() {
|
586
|
-
if (
|
587
|
-
return
|
588
|
-
for (const p of
|
586
|
+
if (this.#hasMagic !== void 0)
|
587
|
+
return this.#hasMagic;
|
588
|
+
for (const p of this.#parts) {
|
589
589
|
if (typeof p === "string")
|
590
590
|
continue;
|
591
591
|
if (p.type || p.hasMagic)
|
592
|
-
return
|
592
|
+
return this.#hasMagic = true;
|
593
593
|
}
|
594
|
-
return
|
594
|
+
return this.#hasMagic;
|
595
595
|
}
|
596
596
|
// reconstructs the pattern
|
597
597
|
toString() {
|
598
|
-
if (
|
599
|
-
return
|
598
|
+
if (this.#toString !== void 0)
|
599
|
+
return this.#toString;
|
600
600
|
if (!this.type) {
|
601
|
-
return
|
601
|
+
return this.#toString = this.#parts.map((p) => String(p)).join("");
|
602
602
|
} else {
|
603
|
-
return
|
603
|
+
return this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
|
604
604
|
}
|
605
605
|
}
|
606
|
+
#fillNegs() {
|
607
|
+
if (this !== this.#root)
|
608
|
+
throw new Error("should only call on root");
|
609
|
+
if (this.#filledNegs)
|
610
|
+
return this;
|
611
|
+
this.toString();
|
612
|
+
this.#filledNegs = true;
|
613
|
+
let n;
|
614
|
+
while (n = this.#negs.pop()) {
|
615
|
+
if (n.type !== "!")
|
616
|
+
continue;
|
617
|
+
let p = n;
|
618
|
+
let pp = p.#parent;
|
619
|
+
while (pp) {
|
620
|
+
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
|
621
|
+
for (const part of n.#parts) {
|
622
|
+
if (typeof part === "string") {
|
623
|
+
throw new Error("string part in extglob AST??");
|
624
|
+
}
|
625
|
+
part.copyIn(pp.#parts[i]);
|
626
|
+
}
|
627
|
+
}
|
628
|
+
p = pp;
|
629
|
+
pp = p.#parent;
|
630
|
+
}
|
631
|
+
}
|
632
|
+
return this;
|
633
|
+
}
|
606
634
|
push(...parts) {
|
607
635
|
for (const p of parts) {
|
608
636
|
if (p === "")
|
609
637
|
continue;
|
610
|
-
if (typeof p !== "string" && !(p instanceof
|
638
|
+
if (typeof p !== "string" && !(p instanceof _AST && p.#parent === this)) {
|
611
639
|
throw new Error("invalid part: " + p);
|
612
640
|
}
|
613
|
-
|
641
|
+
this.#parts.push(p);
|
614
642
|
}
|
615
643
|
}
|
616
644
|
toJSON() {
|
617
|
-
const ret = this.type === null ?
|
645
|
+
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
618
646
|
if (this.isStart() && !this.type)
|
619
647
|
ret.unshift([]);
|
620
|
-
if (this.isEnd() && (this ===
|
648
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) {
|
621
649
|
ret.push({});
|
622
650
|
}
|
623
651
|
return ret;
|
624
652
|
}
|
625
653
|
isStart() {
|
626
|
-
if (
|
654
|
+
if (this.#root === this)
|
627
655
|
return true;
|
628
|
-
if (!
|
656
|
+
if (!this.#parent?.isStart())
|
629
657
|
return false;
|
630
|
-
if (
|
658
|
+
if (this.#parentIndex === 0)
|
631
659
|
return true;
|
632
|
-
const p =
|
633
|
-
for (let i = 0; i <
|
634
|
-
const pp =
|
635
|
-
if (!(pp instanceof
|
660
|
+
const p = this.#parent;
|
661
|
+
for (let i = 0; i < this.#parentIndex; i++) {
|
662
|
+
const pp = p.#parts[i];
|
663
|
+
if (!(pp instanceof _AST && pp.type === "!")) {
|
636
664
|
return false;
|
637
665
|
}
|
638
666
|
}
|
639
667
|
return true;
|
640
668
|
}
|
641
669
|
isEnd() {
|
642
|
-
if (
|
670
|
+
if (this.#root === this)
|
643
671
|
return true;
|
644
|
-
if (
|
672
|
+
if (this.#parent?.type === "!")
|
645
673
|
return true;
|
646
|
-
if (!
|
674
|
+
if (!this.#parent?.isEnd())
|
647
675
|
return false;
|
648
676
|
if (!this.type)
|
649
|
-
return
|
650
|
-
const pl =
|
651
|
-
return
|
677
|
+
return this.#parent?.isEnd();
|
678
|
+
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
679
|
+
return this.#parentIndex === pl - 1;
|
652
680
|
}
|
653
681
|
copyIn(part) {
|
654
682
|
if (typeof part === "string")
|
@@ -657,37 +685,140 @@ var _AST = class _AST2 {
|
|
657
685
|
this.push(part.clone(this));
|
658
686
|
}
|
659
687
|
clone(parent) {
|
660
|
-
const c = new
|
661
|
-
for (const p of
|
688
|
+
const c = new _AST(this.type, parent);
|
689
|
+
for (const p of this.#parts) {
|
662
690
|
c.copyIn(p);
|
663
691
|
}
|
664
692
|
return c;
|
665
693
|
}
|
694
|
+
static #parseAST(str, ast, pos, opt) {
|
695
|
+
let escaping = false;
|
696
|
+
let inBrace = false;
|
697
|
+
let braceStart = -1;
|
698
|
+
let braceNeg = false;
|
699
|
+
if (ast.type === null) {
|
700
|
+
let i2 = pos;
|
701
|
+
let acc2 = "";
|
702
|
+
while (i2 < str.length) {
|
703
|
+
const c = str.charAt(i2++);
|
704
|
+
if (escaping || c === "\\") {
|
705
|
+
escaping = !escaping;
|
706
|
+
acc2 += c;
|
707
|
+
continue;
|
708
|
+
}
|
709
|
+
if (inBrace) {
|
710
|
+
if (i2 === braceStart + 1) {
|
711
|
+
if (c === "^" || c === "!") {
|
712
|
+
braceNeg = true;
|
713
|
+
}
|
714
|
+
} else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
|
715
|
+
inBrace = false;
|
716
|
+
}
|
717
|
+
acc2 += c;
|
718
|
+
continue;
|
719
|
+
} else if (c === "[") {
|
720
|
+
inBrace = true;
|
721
|
+
braceStart = i2;
|
722
|
+
braceNeg = false;
|
723
|
+
acc2 += c;
|
724
|
+
continue;
|
725
|
+
}
|
726
|
+
if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
|
727
|
+
ast.push(acc2);
|
728
|
+
acc2 = "";
|
729
|
+
const ext2 = new _AST(c, ast);
|
730
|
+
i2 = _AST.#parseAST(str, ext2, i2, opt);
|
731
|
+
ast.push(ext2);
|
732
|
+
continue;
|
733
|
+
}
|
734
|
+
acc2 += c;
|
735
|
+
}
|
736
|
+
ast.push(acc2);
|
737
|
+
return i2;
|
738
|
+
}
|
739
|
+
let i = pos + 1;
|
740
|
+
let part = new _AST(null, ast);
|
741
|
+
const parts = [];
|
742
|
+
let acc = "";
|
743
|
+
while (i < str.length) {
|
744
|
+
const c = str.charAt(i++);
|
745
|
+
if (escaping || c === "\\") {
|
746
|
+
escaping = !escaping;
|
747
|
+
acc += c;
|
748
|
+
continue;
|
749
|
+
}
|
750
|
+
if (inBrace) {
|
751
|
+
if (i === braceStart + 1) {
|
752
|
+
if (c === "^" || c === "!") {
|
753
|
+
braceNeg = true;
|
754
|
+
}
|
755
|
+
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
|
756
|
+
inBrace = false;
|
757
|
+
}
|
758
|
+
acc += c;
|
759
|
+
continue;
|
760
|
+
} else if (c === "[") {
|
761
|
+
inBrace = true;
|
762
|
+
braceStart = i;
|
763
|
+
braceNeg = false;
|
764
|
+
acc += c;
|
765
|
+
continue;
|
766
|
+
}
|
767
|
+
if (isExtglobType(c) && str.charAt(i) === "(") {
|
768
|
+
part.push(acc);
|
769
|
+
acc = "";
|
770
|
+
const ext2 = new _AST(c, part);
|
771
|
+
part.push(ext2);
|
772
|
+
i = _AST.#parseAST(str, ext2, i, opt);
|
773
|
+
continue;
|
774
|
+
}
|
775
|
+
if (c === "|") {
|
776
|
+
part.push(acc);
|
777
|
+
acc = "";
|
778
|
+
parts.push(part);
|
779
|
+
part = new _AST(null, ast);
|
780
|
+
continue;
|
781
|
+
}
|
782
|
+
if (c === ")") {
|
783
|
+
if (acc === "" && ast.#parts.length === 0) {
|
784
|
+
ast.#emptyExt = true;
|
785
|
+
}
|
786
|
+
part.push(acc);
|
787
|
+
acc = "";
|
788
|
+
ast.push(...parts, part);
|
789
|
+
return i;
|
790
|
+
}
|
791
|
+
acc += c;
|
792
|
+
}
|
793
|
+
ast.type = null;
|
794
|
+
ast.#hasMagic = void 0;
|
795
|
+
ast.#parts = [str.substring(pos - 1)];
|
796
|
+
return i;
|
797
|
+
}
|
666
798
|
static fromGlob(pattern, options = {}) {
|
667
|
-
|
668
|
-
|
669
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(_a3 = _AST2, _AST_static, parseAST_fn).call(_a3, pattern, ast, 0, options);
|
799
|
+
const ast = new _AST(null, void 0, options);
|
800
|
+
_AST.#parseAST(pattern, ast, 0, options);
|
670
801
|
return ast;
|
671
802
|
}
|
672
803
|
// returns the regular expression if there's magic, or the unescaped
|
673
804
|
// string if not.
|
674
805
|
toMMPattern() {
|
675
|
-
if (this !==
|
676
|
-
return
|
806
|
+
if (this !== this.#root)
|
807
|
+
return this.#root.toMMPattern();
|
677
808
|
const glob2 = this.toString();
|
678
809
|
const [re, body, hasMagic2, uflag] = this.toRegExpSource();
|
679
|
-
const anyMagic = hasMagic2 ||
|
810
|
+
const anyMagic = hasMagic2 || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob2.toUpperCase() !== glob2.toLowerCase();
|
680
811
|
if (!anyMagic) {
|
681
812
|
return body;
|
682
813
|
}
|
683
|
-
const flags = (
|
814
|
+
const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
684
815
|
return Object.assign(new RegExp(`^${re}$`, flags), {
|
685
816
|
_src: re,
|
686
817
|
_glob: glob2
|
687
818
|
});
|
688
819
|
}
|
689
820
|
get options() {
|
690
|
-
return
|
821
|
+
return this.#options;
|
691
822
|
}
|
692
823
|
// returns the string match, the regexp source, whether there's magic
|
693
824
|
// in the regexp (so a regular expression is required) and whether or
|
@@ -759,22 +890,21 @@ var _AST = class _AST2 {
|
|
759
890
|
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
760
891
|
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
761
892
|
toRegExpSource(allowDot) {
|
762
|
-
const dot = allowDot ?? !!
|
763
|
-
if (
|
764
|
-
|
893
|
+
const dot = allowDot ?? !!this.#options.dot;
|
894
|
+
if (this.#root === this)
|
895
|
+
this.#fillNegs();
|
765
896
|
if (!this.type) {
|
766
897
|
const noEmpty = this.isStart() && this.isEnd();
|
767
|
-
const src =
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _uflag, (0, import_chunk_OSFPEEC6.__privateGet)(this, _uflag) || uflag);
|
898
|
+
const src = this.#parts.map((p) => {
|
899
|
+
const [re, _, hasMagic2, uflag] = typeof p === "string" ? _AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
900
|
+
this.#hasMagic = this.#hasMagic || hasMagic2;
|
901
|
+
this.#uflag = this.#uflag || uflag;
|
772
902
|
return re;
|
773
903
|
}).join("");
|
774
904
|
let start2 = "";
|
775
905
|
if (this.isStart()) {
|
776
|
-
if (typeof
|
777
|
-
const dotTravAllowed =
|
906
|
+
if (typeof this.#parts[0] === "string") {
|
907
|
+
const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
|
778
908
|
if (!dotTravAllowed) {
|
779
909
|
const aps = addPatternStart;
|
780
910
|
const needNoTrav = (
|
@@ -789,28 +919,28 @@ var _AST = class _AST2 {
|
|
789
919
|
}
|
790
920
|
}
|
791
921
|
let end = "";
|
792
|
-
if (this.isEnd() &&
|
922
|
+
if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") {
|
793
923
|
end = "(?:$|\\/)";
|
794
924
|
}
|
795
925
|
const final2 = start2 + src + end;
|
796
926
|
return [
|
797
927
|
final2,
|
798
928
|
unescape(src),
|
799
|
-
|
800
|
-
|
929
|
+
this.#hasMagic = !!this.#hasMagic,
|
930
|
+
this.#uflag
|
801
931
|
];
|
802
932
|
}
|
803
933
|
const repeated = this.type === "*" || this.type === "+";
|
804
934
|
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
805
|
-
let body =
|
935
|
+
let body = this.#partsToRegExp(dot);
|
806
936
|
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
807
937
|
const s = this.toString();
|
808
|
-
|
938
|
+
this.#parts = [s];
|
809
939
|
this.type = null;
|
810
|
-
|
940
|
+
this.#hasMagic = void 0;
|
811
941
|
return [s, unescape(this.toString()), false, false];
|
812
942
|
}
|
813
|
-
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" :
|
943
|
+
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(true);
|
814
944
|
if (bodyDotAllowed === body) {
|
815
945
|
bodyDotAllowed = "";
|
816
946
|
}
|
@@ -818,7 +948,7 @@ var _AST = class _AST2 {
|
|
818
948
|
body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
819
949
|
}
|
820
950
|
let final = "";
|
821
|
-
if (this.type === "!" &&
|
951
|
+
if (this.type === "!" && this.#emptyExt) {
|
822
952
|
final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
|
823
953
|
} else {
|
824
954
|
const close = this.type === "!" ? (
|
@@ -830,215 +960,67 @@ var _AST = class _AST2 {
|
|
830
960
|
return [
|
831
961
|
final,
|
832
962
|
unescape(body),
|
833
|
-
|
834
|
-
|
963
|
+
this.#hasMagic = !!this.#hasMagic,
|
964
|
+
this.#uflag
|
835
965
|
];
|
836
966
|
}
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _filledNegs, true);
|
857
|
-
let n;
|
858
|
-
while (n = (0, import_chunk_OSFPEEC6.__privateGet)(this, _negs).pop()) {
|
859
|
-
if (n.type !== "!")
|
860
|
-
continue;
|
861
|
-
let p = n;
|
862
|
-
let pp = (0, import_chunk_OSFPEEC6.__privateGet)(p, _parent);
|
863
|
-
while (pp) {
|
864
|
-
for (let i = (0, import_chunk_OSFPEEC6.__privateGet)(p, _parentIndex) + 1; !pp.type && i < (0, import_chunk_OSFPEEC6.__privateGet)(pp, _parts).length; i++) {
|
865
|
-
for (const part of (0, import_chunk_OSFPEEC6.__privateGet)(n, _parts)) {
|
866
|
-
if (typeof part === "string") {
|
867
|
-
throw new Error("string part in extglob AST??");
|
868
|
-
}
|
869
|
-
part.copyIn((0, import_chunk_OSFPEEC6.__privateGet)(pp, _parts)[i]);
|
870
|
-
}
|
871
|
-
}
|
872
|
-
p = pp;
|
873
|
-
pp = (0, import_chunk_OSFPEEC6.__privateGet)(p, _parent);
|
874
|
-
}
|
875
|
-
}
|
876
|
-
return this;
|
877
|
-
};
|
878
|
-
_AST_static = /* @__PURE__ */ new WeakSet();
|
879
|
-
parseAST_fn = function(str, ast, pos, opt) {
|
880
|
-
var _a3, _b3;
|
881
|
-
let escaping = false;
|
882
|
-
let inBrace = false;
|
883
|
-
let braceStart = -1;
|
884
|
-
let braceNeg = false;
|
885
|
-
if (ast.type === null) {
|
886
|
-
let i2 = pos;
|
887
|
-
let acc2 = "";
|
888
|
-
while (i2 < str.length) {
|
889
|
-
const c = str.charAt(i2++);
|
890
|
-
if (escaping || c === "\\") {
|
891
|
-
escaping = !escaping;
|
892
|
-
acc2 += c;
|
967
|
+
#partsToRegExp(dot) {
|
968
|
+
return this.#parts.map((p) => {
|
969
|
+
if (typeof p === "string") {
|
970
|
+
throw new Error("string type in extglob ast??");
|
971
|
+
}
|
972
|
+
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
973
|
+
this.#uflag = this.#uflag || uflag;
|
974
|
+
return re;
|
975
|
+
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
976
|
+
}
|
977
|
+
static #parseGlob(glob2, hasMagic2, noEmpty = false) {
|
978
|
+
let escaping = false;
|
979
|
+
let re = "";
|
980
|
+
let uflag = false;
|
981
|
+
for (let i = 0; i < glob2.length; i++) {
|
982
|
+
const c = glob2.charAt(i);
|
983
|
+
if (escaping) {
|
984
|
+
escaping = false;
|
985
|
+
re += (reSpecials.has(c) ? "\\" : "") + c;
|
893
986
|
continue;
|
894
987
|
}
|
895
|
-
if (
|
896
|
-
if (
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
} else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
|
901
|
-
inBrace = false;
|
988
|
+
if (c === "\\") {
|
989
|
+
if (i === glob2.length - 1) {
|
990
|
+
re += "\\\\";
|
991
|
+
} else {
|
992
|
+
escaping = true;
|
902
993
|
}
|
903
|
-
acc2 += c;
|
904
|
-
continue;
|
905
|
-
} else if (c === "[") {
|
906
|
-
inBrace = true;
|
907
|
-
braceStart = i2;
|
908
|
-
braceNeg = false;
|
909
|
-
acc2 += c;
|
910
994
|
continue;
|
911
995
|
}
|
912
|
-
if (
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
acc2 += c;
|
921
|
-
}
|
922
|
-
ast.push(acc2);
|
923
|
-
return i2;
|
924
|
-
}
|
925
|
-
let i = pos + 1;
|
926
|
-
let part = new _AST(null, ast);
|
927
|
-
const parts = [];
|
928
|
-
let acc = "";
|
929
|
-
while (i < str.length) {
|
930
|
-
const c = str.charAt(i++);
|
931
|
-
if (escaping || c === "\\") {
|
932
|
-
escaping = !escaping;
|
933
|
-
acc += c;
|
934
|
-
continue;
|
935
|
-
}
|
936
|
-
if (inBrace) {
|
937
|
-
if (i === braceStart + 1) {
|
938
|
-
if (c === "^" || c === "!") {
|
939
|
-
braceNeg = true;
|
996
|
+
if (c === "[") {
|
997
|
+
const [src, needUflag, consumed, magic] = parseClass(glob2, i);
|
998
|
+
if (consumed) {
|
999
|
+
re += src;
|
1000
|
+
uflag = uflag || needUflag;
|
1001
|
+
i += consumed - 1;
|
1002
|
+
hasMagic2 = hasMagic2 || magic;
|
1003
|
+
continue;
|
940
1004
|
}
|
941
|
-
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
|
942
|
-
inBrace = false;
|
943
|
-
}
|
944
|
-
acc += c;
|
945
|
-
continue;
|
946
|
-
} else if (c === "[") {
|
947
|
-
inBrace = true;
|
948
|
-
braceStart = i;
|
949
|
-
braceNeg = false;
|
950
|
-
acc += c;
|
951
|
-
continue;
|
952
|
-
}
|
953
|
-
if (isExtglobType(c) && str.charAt(i) === "(") {
|
954
|
-
part.push(acc);
|
955
|
-
acc = "";
|
956
|
-
const ext2 = new _AST(c, part);
|
957
|
-
part.push(ext2);
|
958
|
-
i = (0, import_chunk_OSFPEEC6.__privateMethod)(_b3 = _AST, _AST_static, parseAST_fn).call(_b3, str, ext2, i, opt);
|
959
|
-
continue;
|
960
|
-
}
|
961
|
-
if (c === "|") {
|
962
|
-
part.push(acc);
|
963
|
-
acc = "";
|
964
|
-
parts.push(part);
|
965
|
-
part = new _AST(null, ast);
|
966
|
-
continue;
|
967
|
-
}
|
968
|
-
if (c === ")") {
|
969
|
-
if (acc === "" && (0, import_chunk_OSFPEEC6.__privateGet)(ast, _parts).length === 0) {
|
970
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(ast, _emptyExt, true);
|
971
1005
|
}
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
ast.type = null;
|
980
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(ast, _hasMagic, void 0);
|
981
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(ast, _parts, [str.substring(pos - 1)]);
|
982
|
-
return i;
|
983
|
-
};
|
984
|
-
partsToRegExp_fn = function(dot) {
|
985
|
-
return (0, import_chunk_OSFPEEC6.__privateGet)(this, _parts).map((p) => {
|
986
|
-
if (typeof p === "string") {
|
987
|
-
throw new Error("string type in extglob ast??");
|
988
|
-
}
|
989
|
-
const [re, _, _hasMagic2, uflag] = p.toRegExpSource(dot);
|
990
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _uflag, (0, import_chunk_OSFPEEC6.__privateGet)(this, _uflag) || uflag);
|
991
|
-
return re;
|
992
|
-
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
993
|
-
};
|
994
|
-
parseGlob_fn = function(glob2, hasMagic2, noEmpty = false) {
|
995
|
-
let escaping = false;
|
996
|
-
let re = "";
|
997
|
-
let uflag = false;
|
998
|
-
for (let i = 0; i < glob2.length; i++) {
|
999
|
-
const c = glob2.charAt(i);
|
1000
|
-
if (escaping) {
|
1001
|
-
escaping = false;
|
1002
|
-
re += (reSpecials.has(c) ? "\\" : "") + c;
|
1003
|
-
continue;
|
1004
|
-
}
|
1005
|
-
if (c === "\\") {
|
1006
|
-
if (i === glob2.length - 1) {
|
1007
|
-
re += "\\\\";
|
1008
|
-
} else {
|
1009
|
-
escaping = true;
|
1006
|
+
if (c === "*") {
|
1007
|
+
if (noEmpty && glob2 === "*")
|
1008
|
+
re += starNoEmpty;
|
1009
|
+
else
|
1010
|
+
re += star;
|
1011
|
+
hasMagic2 = true;
|
1012
|
+
continue;
|
1010
1013
|
}
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
const [src, needUflag, consumed, magic] = parseClass(glob2, i);
|
1015
|
-
if (consumed) {
|
1016
|
-
re += src;
|
1017
|
-
uflag = uflag || needUflag;
|
1018
|
-
i += consumed - 1;
|
1019
|
-
hasMagic2 = hasMagic2 || magic;
|
1014
|
+
if (c === "?") {
|
1015
|
+
re += qmark;
|
1016
|
+
hasMagic2 = true;
|
1020
1017
|
continue;
|
1021
1018
|
}
|
1019
|
+
re += regExpEscape(c);
|
1022
1020
|
}
|
1023
|
-
|
1024
|
-
if (noEmpty && glob2 === "*")
|
1025
|
-
re += starNoEmpty;
|
1026
|
-
else
|
1027
|
-
re += star;
|
1028
|
-
hasMagic2 = true;
|
1029
|
-
continue;
|
1030
|
-
}
|
1031
|
-
if (c === "?") {
|
1032
|
-
re += qmark;
|
1033
|
-
hasMagic2 = true;
|
1034
|
-
continue;
|
1035
|
-
}
|
1036
|
-
re += regExpEscape(c);
|
1021
|
+
return [re, unescape(glob2), !!hasMagic2, uflag];
|
1037
1022
|
}
|
1038
|
-
return [re, unescape(glob2), !!hasMagic2, uflag];
|
1039
1023
|
};
|
1040
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(_AST, _AST_static);
|
1041
|
-
var AST = _AST;
|
1042
1024
|
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
|
1043
1025
|
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
1044
1026
|
};
|
@@ -1174,24 +1156,24 @@ minimatch.match = match;
|
|
1174
1156
|
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
1175
1157
|
var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
1176
1158
|
var Minimatch = class {
|
1159
|
+
options;
|
1160
|
+
set;
|
1161
|
+
pattern;
|
1162
|
+
windowsPathsNoEscape;
|
1163
|
+
nonegate;
|
1164
|
+
negate;
|
1165
|
+
comment;
|
1166
|
+
empty;
|
1167
|
+
preserveMultipleSlashes;
|
1168
|
+
partial;
|
1169
|
+
globSet;
|
1170
|
+
globParts;
|
1171
|
+
nocase;
|
1172
|
+
isWindows;
|
1173
|
+
platform;
|
1174
|
+
windowsNoMagicRoot;
|
1175
|
+
regexp;
|
1177
1176
|
constructor(pattern, options = {}) {
|
1178
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "options");
|
1179
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "set");
|
1180
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "pattern");
|
1181
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "windowsPathsNoEscape");
|
1182
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "nonegate");
|
1183
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "negate");
|
1184
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "comment");
|
1185
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "empty");
|
1186
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "preserveMultipleSlashes");
|
1187
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "partial");
|
1188
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "globSet");
|
1189
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "globParts");
|
1190
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "nocase");
|
1191
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "isWindows");
|
1192
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "platform");
|
1193
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "windowsNoMagicRoot");
|
1194
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "regexp");
|
1195
1177
|
assertValidPattern(pattern);
|
1196
1178
|
options = options || {};
|
1197
1179
|
this.options = options;
|
@@ -1768,21 +1750,19 @@ var AC = globalThis.AbortController;
|
|
1768
1750
|
var AS = globalThis.AbortSignal;
|
1769
1751
|
if (typeof AC === "undefined") {
|
1770
1752
|
AS = class AbortSignal {
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "aborted", false);
|
1776
|
-
}
|
1753
|
+
onabort;
|
1754
|
+
_onabort = [];
|
1755
|
+
reason;
|
1756
|
+
aborted = false;
|
1777
1757
|
addEventListener(_, fn) {
|
1778
1758
|
this._onabort.push(fn);
|
1779
1759
|
}
|
1780
1760
|
};
|
1781
1761
|
AC = class AbortController {
|
1782
1762
|
constructor() {
|
1783
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "signal", new AS());
|
1784
1763
|
warnACPolyfill();
|
1785
1764
|
}
|
1765
|
+
signal = new AS();
|
1786
1766
|
abort(reason) {
|
1787
1767
|
if (this.signal.aborted)
|
1788
1768
|
return;
|
@@ -1812,26 +1792,27 @@ var ZeroArray = class extends Array {
|
|
1812
1792
|
this.fill(0);
|
1813
1793
|
}
|
1814
1794
|
};
|
1815
|
-
var
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
if (!(0, import_chunk_OSFPEEC6.__privateGet)(_Stack2, _constructing)) {
|
1821
|
-
throw new TypeError("instantiate Stack using Stack.create(n)");
|
1822
|
-
}
|
1823
|
-
this.heap = new HeapCls(max);
|
1824
|
-
this.length = 0;
|
1825
|
-
}
|
1795
|
+
var Stack = class _Stack {
|
1796
|
+
heap;
|
1797
|
+
length;
|
1798
|
+
// private constructor
|
1799
|
+
static #constructing = false;
|
1826
1800
|
static create(max) {
|
1827
1801
|
const HeapCls = getUintArray(max);
|
1828
1802
|
if (!HeapCls)
|
1829
1803
|
return [];
|
1830
|
-
|
1831
|
-
const s = new
|
1832
|
-
|
1804
|
+
_Stack.#constructing = true;
|
1805
|
+
const s = new _Stack(max, HeapCls);
|
1806
|
+
_Stack.#constructing = false;
|
1833
1807
|
return s;
|
1834
1808
|
}
|
1809
|
+
constructor(max, HeapCls) {
|
1810
|
+
if (!_Stack.#constructing) {
|
1811
|
+
throw new TypeError("instantiate Stack using Stack.create(n)");
|
1812
|
+
}
|
1813
|
+
this.heap = new HeapCls(max);
|
1814
|
+
this.length = 0;
|
1815
|
+
}
|
1835
1816
|
push(n) {
|
1836
1817
|
this.heap[this.length++] = n;
|
1837
1818
|
}
|
@@ -1839,69 +1820,175 @@ var _Stack = class _Stack2 {
|
|
1839
1820
|
return this.heap[--this.length];
|
1840
1821
|
}
|
1841
1822
|
};
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1823
|
+
var LRUCache = class _LRUCache {
|
1824
|
+
// options that cannot be changed without disaster
|
1825
|
+
#max;
|
1826
|
+
#maxSize;
|
1827
|
+
#dispose;
|
1828
|
+
#disposeAfter;
|
1829
|
+
#fetchMethod;
|
1830
|
+
#memoMethod;
|
1831
|
+
/**
|
1832
|
+
* {@link LRUCache.OptionsBase.ttl}
|
1833
|
+
*/
|
1834
|
+
ttl;
|
1835
|
+
/**
|
1836
|
+
* {@link LRUCache.OptionsBase.ttlResolution}
|
1837
|
+
*/
|
1838
|
+
ttlResolution;
|
1839
|
+
/**
|
1840
|
+
* {@link LRUCache.OptionsBase.ttlAutopurge}
|
1841
|
+
*/
|
1842
|
+
ttlAutopurge;
|
1843
|
+
/**
|
1844
|
+
* {@link LRUCache.OptionsBase.updateAgeOnGet}
|
1845
|
+
*/
|
1846
|
+
updateAgeOnGet;
|
1847
|
+
/**
|
1848
|
+
* {@link LRUCache.OptionsBase.updateAgeOnHas}
|
1849
|
+
*/
|
1850
|
+
updateAgeOnHas;
|
1851
|
+
/**
|
1852
|
+
* {@link LRUCache.OptionsBase.allowStale}
|
1853
|
+
*/
|
1854
|
+
allowStale;
|
1855
|
+
/**
|
1856
|
+
* {@link LRUCache.OptionsBase.noDisposeOnSet}
|
1857
|
+
*/
|
1858
|
+
noDisposeOnSet;
|
1859
|
+
/**
|
1860
|
+
* {@link LRUCache.OptionsBase.noUpdateTTL}
|
1861
|
+
*/
|
1862
|
+
noUpdateTTL;
|
1863
|
+
/**
|
1864
|
+
* {@link LRUCache.OptionsBase.maxEntrySize}
|
1865
|
+
*/
|
1866
|
+
maxEntrySize;
|
1867
|
+
/**
|
1868
|
+
* {@link LRUCache.OptionsBase.sizeCalculation}
|
1869
|
+
*/
|
1870
|
+
sizeCalculation;
|
1871
|
+
/**
|
1872
|
+
* {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
|
1873
|
+
*/
|
1874
|
+
noDeleteOnFetchRejection;
|
1875
|
+
/**
|
1876
|
+
* {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
|
1877
|
+
*/
|
1878
|
+
noDeleteOnStaleGet;
|
1879
|
+
/**
|
1880
|
+
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
|
1881
|
+
*/
|
1882
|
+
allowStaleOnFetchAbort;
|
1883
|
+
/**
|
1884
|
+
* {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
|
1885
|
+
*/
|
1886
|
+
allowStaleOnFetchRejection;
|
1887
|
+
/**
|
1888
|
+
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
|
1889
|
+
*/
|
1890
|
+
ignoreFetchAbort;
|
1891
|
+
// computed properties
|
1892
|
+
#size;
|
1893
|
+
#calculatedSize;
|
1894
|
+
#keyMap;
|
1895
|
+
#keyList;
|
1896
|
+
#valList;
|
1897
|
+
#next;
|
1898
|
+
#prev;
|
1899
|
+
#head;
|
1900
|
+
#tail;
|
1901
|
+
#free;
|
1902
|
+
#disposed;
|
1903
|
+
#sizes;
|
1904
|
+
#starts;
|
1905
|
+
#ttls;
|
1906
|
+
#hasDispose;
|
1907
|
+
#hasFetchMethod;
|
1908
|
+
#hasDisposeAfter;
|
1909
|
+
/**
|
1910
|
+
* Do not call this method unless you need to inspect the
|
1911
|
+
* inner workings of the cache. If anything returned by this
|
1912
|
+
* object is modified in any way, strange breakage may occur.
|
1913
|
+
*
|
1914
|
+
* These fields are private for a reason!
|
1915
|
+
*
|
1916
|
+
* @internal
|
1917
|
+
*/
|
1918
|
+
static unsafeExposeInternals(c) {
|
1919
|
+
return {
|
1920
|
+
// properties
|
1921
|
+
starts: c.#starts,
|
1922
|
+
ttls: c.#ttls,
|
1923
|
+
sizes: c.#sizes,
|
1924
|
+
keyMap: c.#keyMap,
|
1925
|
+
keyList: c.#keyList,
|
1926
|
+
valList: c.#valList,
|
1927
|
+
next: c.#next,
|
1928
|
+
prev: c.#prev,
|
1929
|
+
get head() {
|
1930
|
+
return c.#head;
|
1931
|
+
},
|
1932
|
+
get tail() {
|
1933
|
+
return c.#tail;
|
1934
|
+
},
|
1935
|
+
free: c.#free,
|
1936
|
+
// methods
|
1937
|
+
isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
|
1938
|
+
backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
|
1939
|
+
moveToTail: (index) => c.#moveToTail(index),
|
1940
|
+
indexes: (options) => c.#indexes(options),
|
1941
|
+
rindexes: (options) => c.#rindexes(options),
|
1942
|
+
isStale: (index) => c.#isStale(index)
|
1943
|
+
};
|
1944
|
+
}
|
1945
|
+
// Protected read-only members
|
1946
|
+
/**
|
1947
|
+
* {@link LRUCache.OptionsBase.max} (read-only)
|
1948
|
+
*/
|
1949
|
+
get max() {
|
1950
|
+
return this.#max;
|
1951
|
+
}
|
1952
|
+
/**
|
1953
|
+
* {@link LRUCache.OptionsBase.maxSize} (read-only)
|
1954
|
+
*/
|
1955
|
+
get maxSize() {
|
1956
|
+
return this.#maxSize;
|
1957
|
+
}
|
1958
|
+
/**
|
1959
|
+
* The total computed size of items in the cache (read-only)
|
1960
|
+
*/
|
1961
|
+
get calculatedSize() {
|
1962
|
+
return this.#calculatedSize;
|
1963
|
+
}
|
1964
|
+
/**
|
1965
|
+
* The number of items stored in the cache (read-only)
|
1966
|
+
*/
|
1967
|
+
get size() {
|
1968
|
+
return this.#size;
|
1969
|
+
}
|
1970
|
+
/**
|
1971
|
+
* {@link LRUCache.OptionsBase.fetchMethod} (read-only)
|
1972
|
+
*/
|
1973
|
+
get fetchMethod() {
|
1974
|
+
return this.#fetchMethod;
|
1975
|
+
}
|
1976
|
+
get memoMethod() {
|
1977
|
+
return this.#memoMethod;
|
1978
|
+
}
|
1979
|
+
/**
|
1980
|
+
* {@link LRUCache.OptionsBase.dispose} (read-only)
|
1981
|
+
*/
|
1982
|
+
get dispose() {
|
1983
|
+
return this.#dispose;
|
1984
|
+
}
|
1985
|
+
/**
|
1986
|
+
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
|
1987
|
+
*/
|
1988
|
+
get disposeAfter() {
|
1989
|
+
return this.#disposeAfter;
|
1990
|
+
}
|
1847
1991
|
constructor(options) {
|
1848
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _LRUCache_instances);
|
1849
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _max);
|
1850
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _maxSize);
|
1851
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _dispose);
|
1852
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _disposeAfter);
|
1853
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _fetchMethod);
|
1854
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _memoMethod);
|
1855
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "ttl");
|
1856
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "ttlResolution");
|
1857
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "ttlAutopurge");
|
1858
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "updateAgeOnGet");
|
1859
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "updateAgeOnHas");
|
1860
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "allowStale");
|
1861
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "noDisposeOnSet");
|
1862
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "noUpdateTTL");
|
1863
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "maxEntrySize");
|
1864
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "sizeCalculation");
|
1865
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "noDeleteOnFetchRejection");
|
1866
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "noDeleteOnStaleGet");
|
1867
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "allowStaleOnFetchAbort");
|
1868
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "allowStaleOnFetchRejection");
|
1869
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "ignoreFetchAbort");
|
1870
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _size);
|
1871
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _calculatedSize);
|
1872
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _keyMap);
|
1873
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _keyList);
|
1874
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _valList);
|
1875
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _next);
|
1876
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _prev);
|
1877
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _head);
|
1878
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _tail);
|
1879
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _free);
|
1880
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _disposed);
|
1881
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _sizes);
|
1882
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _starts);
|
1883
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _ttls);
|
1884
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _hasDispose);
|
1885
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _hasFetchMethod);
|
1886
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _hasDisposeAfter);
|
1887
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _updateItemAge, () => {
|
1888
|
-
});
|
1889
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _statusTTL, () => {
|
1890
|
-
});
|
1891
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _setItemTTL, () => {
|
1892
|
-
});
|
1893
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _isStale, () => false);
|
1894
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _removeItemSize, (_i2) => {
|
1895
|
-
});
|
1896
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _addItemSize, (_i2, _s2, _st) => {
|
1897
|
-
});
|
1898
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _requireSize, (_k2, _v, size, sizeCalculation2) => {
|
1899
|
-
if (size || sizeCalculation2) {
|
1900
|
-
throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
1901
|
-
}
|
1902
|
-
return 0;
|
1903
|
-
});
|
1904
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _a, "LRUCache");
|
1905
1992
|
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
|
1906
1993
|
if (max !== 0 && !isPosInt(max)) {
|
1907
1994
|
throw new TypeError("max option must be a nonnegative integer");
|
@@ -1910,12 +1997,12 @@ var _LRUCache = class _LRUCache2 {
|
|
1910
1997
|
if (!UintArray) {
|
1911
1998
|
throw new Error("invalid max value: " + max);
|
1912
1999
|
}
|
1913
|
-
|
1914
|
-
|
1915
|
-
this.maxEntrySize = maxEntrySize ||
|
2000
|
+
this.#max = max;
|
2001
|
+
this.#maxSize = maxSize;
|
2002
|
+
this.maxEntrySize = maxEntrySize || this.#maxSize;
|
1916
2003
|
this.sizeCalculation = sizeCalculation;
|
1917
2004
|
if (this.sizeCalculation) {
|
1918
|
-
if (!
|
2005
|
+
if (!this.#maxSize && !this.maxEntrySize) {
|
1919
2006
|
throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
1920
2007
|
}
|
1921
2008
|
if (typeof this.sizeCalculation !== "function") {
|
@@ -1925,34 +2012,34 @@ var _LRUCache = class _LRUCache2 {
|
|
1925
2012
|
if (memoMethod !== void 0 && typeof memoMethod !== "function") {
|
1926
2013
|
throw new TypeError("memoMethod must be a function if defined");
|
1927
2014
|
}
|
1928
|
-
|
2015
|
+
this.#memoMethod = memoMethod;
|
1929
2016
|
if (fetchMethod !== void 0 && typeof fetchMethod !== "function") {
|
1930
2017
|
throw new TypeError("fetchMethod must be a function if specified");
|
1931
2018
|
}
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
2019
|
+
this.#fetchMethod = fetchMethod;
|
2020
|
+
this.#hasFetchMethod = !!fetchMethod;
|
2021
|
+
this.#keyMap = /* @__PURE__ */ new Map();
|
2022
|
+
this.#keyList = new Array(max).fill(void 0);
|
2023
|
+
this.#valList = new Array(max).fill(void 0);
|
2024
|
+
this.#next = new UintArray(max);
|
2025
|
+
this.#prev = new UintArray(max);
|
2026
|
+
this.#head = 0;
|
2027
|
+
this.#tail = 0;
|
2028
|
+
this.#free = Stack.create(max);
|
2029
|
+
this.#size = 0;
|
2030
|
+
this.#calculatedSize = 0;
|
1944
2031
|
if (typeof dispose === "function") {
|
1945
|
-
|
2032
|
+
this.#dispose = dispose;
|
1946
2033
|
}
|
1947
2034
|
if (typeof disposeAfter === "function") {
|
1948
|
-
|
1949
|
-
|
2035
|
+
this.#disposeAfter = disposeAfter;
|
2036
|
+
this.#disposed = [];
|
1950
2037
|
} else {
|
1951
|
-
|
1952
|
-
|
2038
|
+
this.#disposeAfter = void 0;
|
2039
|
+
this.#disposed = void 0;
|
1953
2040
|
}
|
1954
|
-
|
1955
|
-
|
2041
|
+
this.#hasDispose = !!this.#dispose;
|
2042
|
+
this.#hasDisposeAfter = !!this.#disposeAfter;
|
1956
2043
|
this.noDisposeOnSet = !!noDisposeOnSet;
|
1957
2044
|
this.noUpdateTTL = !!noUpdateTTL;
|
1958
2045
|
this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
|
@@ -1960,15 +2047,15 @@ var _LRUCache = class _LRUCache2 {
|
|
1960
2047
|
this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
|
1961
2048
|
this.ignoreFetchAbort = !!ignoreFetchAbort;
|
1962
2049
|
if (this.maxEntrySize !== 0) {
|
1963
|
-
if (
|
1964
|
-
if (!isPosInt(
|
2050
|
+
if (this.#maxSize !== 0) {
|
2051
|
+
if (!isPosInt(this.#maxSize)) {
|
1965
2052
|
throw new TypeError("maxSize must be a positive integer if specified");
|
1966
2053
|
}
|
1967
2054
|
}
|
1968
2055
|
if (!isPosInt(this.maxEntrySize)) {
|
1969
2056
|
throw new TypeError("maxEntrySize must be a positive integer if specified");
|
1970
2057
|
}
|
1971
|
-
|
2058
|
+
this.#initializeSizeTracking();
|
1972
2059
|
}
|
1973
2060
|
this.allowStale = !!allowStale;
|
1974
2061
|
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
|
@@ -1981,135 +2068,199 @@ var _LRUCache = class _LRUCache2 {
|
|
1981
2068
|
if (!isPosInt(this.ttl)) {
|
1982
2069
|
throw new TypeError("ttl must be a positive integer if specified");
|
1983
2070
|
}
|
1984
|
-
|
2071
|
+
this.#initializeTTLTracking();
|
1985
2072
|
}
|
1986
|
-
if (
|
2073
|
+
if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) {
|
1987
2074
|
throw new TypeError("At least one of max, maxSize, or ttl is required");
|
1988
2075
|
}
|
1989
|
-
if (!this.ttlAutopurge && !
|
2076
|
+
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
1990
2077
|
const code = "LRU_CACHE_UNBOUNDED";
|
1991
2078
|
if (shouldWarn(code)) {
|
1992
2079
|
warned.add(code);
|
1993
2080
|
const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
|
1994
|
-
emitWarning(msg, "UnboundedCacheWarning", code,
|
2081
|
+
emitWarning(msg, "UnboundedCacheWarning", code, _LRUCache);
|
1995
2082
|
}
|
1996
2083
|
}
|
1997
2084
|
}
|
1998
2085
|
/**
|
1999
|
-
*
|
2000
|
-
*
|
2001
|
-
* object is modified in any way, strange breakage may occur.
|
2002
|
-
*
|
2003
|
-
* These fields are private for a reason!
|
2004
|
-
*
|
2005
|
-
* @internal
|
2086
|
+
* Return the number of ms left in the item's TTL. If item is not in cache,
|
2087
|
+
* returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
|
2006
2088
|
*/
|
2007
|
-
|
2008
|
-
return
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
var _a3;
|
2028
|
-
return (0, import_chunk_OSFPEEC6.__privateMethod)(_a3 = c, _LRUCache_instances, isBackgroundFetch_fn).call(_a3, p);
|
2029
|
-
},
|
2030
|
-
backgroundFetch: (k, index, options, context) => {
|
2031
|
-
var _a3;
|
2032
|
-
return (0, import_chunk_OSFPEEC6.__privateMethod)(_a3 = c, _LRUCache_instances, backgroundFetch_fn).call(_a3, k, index, options, context);
|
2033
|
-
},
|
2034
|
-
moveToTail: (index) => {
|
2035
|
-
var _a3;
|
2036
|
-
return (0, import_chunk_OSFPEEC6.__privateMethod)(_a3 = c, _LRUCache_instances, moveToTail_fn).call(_a3, index);
|
2037
|
-
},
|
2038
|
-
indexes: (options) => {
|
2039
|
-
var _a3;
|
2040
|
-
return (0, import_chunk_OSFPEEC6.__privateMethod)(_a3 = c, _LRUCache_instances, indexes_fn).call(_a3, options);
|
2041
|
-
},
|
2042
|
-
rindexes: (options) => {
|
2043
|
-
var _a3;
|
2044
|
-
return (0, import_chunk_OSFPEEC6.__privateMethod)(_a3 = c, _LRUCache_instances, rindexes_fn).call(_a3, options);
|
2045
|
-
},
|
2046
|
-
isStale: (index) => {
|
2047
|
-
var _a3;
|
2048
|
-
return (0, import_chunk_OSFPEEC6.__privateGet)(_a3 = c, _isStale).call(_a3, index);
|
2089
|
+
getRemainingTTL(key) {
|
2090
|
+
return this.#keyMap.has(key) ? Infinity : 0;
|
2091
|
+
}
|
2092
|
+
#initializeTTLTracking() {
|
2093
|
+
const ttls = new ZeroArray(this.#max);
|
2094
|
+
const starts = new ZeroArray(this.#max);
|
2095
|
+
this.#ttls = ttls;
|
2096
|
+
this.#starts = starts;
|
2097
|
+
this.#setItemTTL = (index, ttl, start = perf.now()) => {
|
2098
|
+
starts[index] = ttl !== 0 ? start : 0;
|
2099
|
+
ttls[index] = ttl;
|
2100
|
+
if (ttl !== 0 && this.ttlAutopurge) {
|
2101
|
+
const t = setTimeout(() => {
|
2102
|
+
if (this.#isStale(index)) {
|
2103
|
+
this.#delete(this.#keyList[index], "expire");
|
2104
|
+
}
|
2105
|
+
}, ttl + 1);
|
2106
|
+
if (t.unref) {
|
2107
|
+
t.unref();
|
2108
|
+
}
|
2049
2109
|
}
|
2050
2110
|
};
|
2111
|
+
this.#updateItemAge = (index) => {
|
2112
|
+
starts[index] = ttls[index] !== 0 ? perf.now() : 0;
|
2113
|
+
};
|
2114
|
+
this.#statusTTL = (status, index) => {
|
2115
|
+
if (ttls[index]) {
|
2116
|
+
const ttl = ttls[index];
|
2117
|
+
const start = starts[index];
|
2118
|
+
if (!ttl || !start)
|
2119
|
+
return;
|
2120
|
+
status.ttl = ttl;
|
2121
|
+
status.start = start;
|
2122
|
+
status.now = cachedNow || getNow();
|
2123
|
+
const age = status.now - start;
|
2124
|
+
status.remainingTTL = ttl - age;
|
2125
|
+
}
|
2126
|
+
};
|
2127
|
+
let cachedNow = 0;
|
2128
|
+
const getNow = () => {
|
2129
|
+
const n = perf.now();
|
2130
|
+
if (this.ttlResolution > 0) {
|
2131
|
+
cachedNow = n;
|
2132
|
+
const t = setTimeout(() => cachedNow = 0, this.ttlResolution);
|
2133
|
+
if (t.unref) {
|
2134
|
+
t.unref();
|
2135
|
+
}
|
2136
|
+
}
|
2137
|
+
return n;
|
2138
|
+
};
|
2139
|
+
this.getRemainingTTL = (key) => {
|
2140
|
+
const index = this.#keyMap.get(key);
|
2141
|
+
if (index === void 0) {
|
2142
|
+
return 0;
|
2143
|
+
}
|
2144
|
+
const ttl = ttls[index];
|
2145
|
+
const start = starts[index];
|
2146
|
+
if (!ttl || !start) {
|
2147
|
+
return Infinity;
|
2148
|
+
}
|
2149
|
+
const age = (cachedNow || getNow()) - start;
|
2150
|
+
return ttl - age;
|
2151
|
+
};
|
2152
|
+
this.#isStale = (index) => {
|
2153
|
+
const s = starts[index];
|
2154
|
+
const t = ttls[index];
|
2155
|
+
return !!t && !!s && (cachedNow || getNow()) - s > t;
|
2156
|
+
};
|
2051
2157
|
}
|
2052
|
-
//
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
}
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2158
|
+
// conditionally set private methods related to TTL
|
2159
|
+
#updateItemAge = () => {
|
2160
|
+
};
|
2161
|
+
#statusTTL = () => {
|
2162
|
+
};
|
2163
|
+
#setItemTTL = () => {
|
2164
|
+
};
|
2165
|
+
/* c8 ignore stop */
|
2166
|
+
#isStale = () => false;
|
2167
|
+
#initializeSizeTracking() {
|
2168
|
+
const sizes = new ZeroArray(this.#max);
|
2169
|
+
this.#calculatedSize = 0;
|
2170
|
+
this.#sizes = sizes;
|
2171
|
+
this.#removeItemSize = (index) => {
|
2172
|
+
this.#calculatedSize -= sizes[index];
|
2173
|
+
sizes[index] = 0;
|
2174
|
+
};
|
2175
|
+
this.#requireSize = (k, v, size, sizeCalculation) => {
|
2176
|
+
if (this.#isBackgroundFetch(v)) {
|
2177
|
+
return 0;
|
2178
|
+
}
|
2179
|
+
if (!isPosInt(size)) {
|
2180
|
+
if (sizeCalculation) {
|
2181
|
+
if (typeof sizeCalculation !== "function") {
|
2182
|
+
throw new TypeError("sizeCalculation must be a function");
|
2183
|
+
}
|
2184
|
+
size = sizeCalculation(v, k);
|
2185
|
+
if (!isPosInt(size)) {
|
2186
|
+
throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
2187
|
+
}
|
2188
|
+
} else {
|
2189
|
+
throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
2190
|
+
}
|
2191
|
+
}
|
2192
|
+
return size;
|
2193
|
+
};
|
2194
|
+
this.#addItemSize = (index, size, status) => {
|
2195
|
+
sizes[index] = size;
|
2196
|
+
if (this.#maxSize) {
|
2197
|
+
const maxSize = this.#maxSize - sizes[index];
|
2198
|
+
while (this.#calculatedSize > maxSize) {
|
2199
|
+
this.#evict(true);
|
2200
|
+
}
|
2201
|
+
}
|
2202
|
+
this.#calculatedSize += sizes[index];
|
2203
|
+
if (status) {
|
2204
|
+
status.entrySize = size;
|
2205
|
+
status.totalCalculatedSize = this.#calculatedSize;
|
2206
|
+
}
|
2207
|
+
};
|
2085
2208
|
}
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2209
|
+
#removeItemSize = (_i) => {
|
2210
|
+
};
|
2211
|
+
#addItemSize = (_i, _s, _st) => {
|
2212
|
+
};
|
2213
|
+
#requireSize = (_k, _v, size, sizeCalculation) => {
|
2214
|
+
if (size || sizeCalculation) {
|
2215
|
+
throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
2216
|
+
}
|
2217
|
+
return 0;
|
2218
|
+
};
|
2219
|
+
*#indexes({ allowStale = this.allowStale } = {}) {
|
2220
|
+
if (this.#size) {
|
2221
|
+
for (let i = this.#tail; true; ) {
|
2222
|
+
if (!this.#isValidIndex(i)) {
|
2223
|
+
break;
|
2224
|
+
}
|
2225
|
+
if (allowStale || !this.#isStale(i)) {
|
2226
|
+
yield i;
|
2227
|
+
}
|
2228
|
+
if (i === this.#head) {
|
2229
|
+
break;
|
2230
|
+
} else {
|
2231
|
+
i = this.#prev[i];
|
2232
|
+
}
|
2233
|
+
}
|
2234
|
+
}
|
2091
2235
|
}
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2236
|
+
*#rindexes({ allowStale = this.allowStale } = {}) {
|
2237
|
+
if (this.#size) {
|
2238
|
+
for (let i = this.#head; true; ) {
|
2239
|
+
if (!this.#isValidIndex(i)) {
|
2240
|
+
break;
|
2241
|
+
}
|
2242
|
+
if (allowStale || !this.#isStale(i)) {
|
2243
|
+
yield i;
|
2244
|
+
}
|
2245
|
+
if (i === this.#tail) {
|
2246
|
+
break;
|
2247
|
+
} else {
|
2248
|
+
i = this.#next[i];
|
2249
|
+
}
|
2250
|
+
}
|
2251
|
+
}
|
2097
2252
|
}
|
2098
|
-
|
2099
|
-
|
2100
|
-
* returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
|
2101
|
-
*/
|
2102
|
-
getRemainingTTL(key) {
|
2103
|
-
return (0, import_chunk_OSFPEEC6.__privateGet)(this, _keyMap).has(key) ? Infinity : 0;
|
2253
|
+
#isValidIndex(index) {
|
2254
|
+
return index !== void 0 && this.#keyMap.get(this.#keyList[index]) === index;
|
2104
2255
|
}
|
2105
2256
|
/**
|
2106
2257
|
* Return a generator yielding `[key, value]` pairs,
|
2107
2258
|
* in order from most recently used to least recently used.
|
2108
2259
|
*/
|
2109
2260
|
*entries() {
|
2110
|
-
for (const i of
|
2111
|
-
if (
|
2112
|
-
yield [
|
2261
|
+
for (const i of this.#indexes()) {
|
2262
|
+
if (this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
|
2263
|
+
yield [this.#keyList[i], this.#valList[i]];
|
2113
2264
|
}
|
2114
2265
|
}
|
2115
2266
|
}
|
@@ -2120,9 +2271,9 @@ var _LRUCache = class _LRUCache2 {
|
|
2120
2271
|
* in order from least recently used to most recently used.
|
2121
2272
|
*/
|
2122
2273
|
*rentries() {
|
2123
|
-
for (const i of
|
2124
|
-
if (
|
2125
|
-
yield [
|
2274
|
+
for (const i of this.#rindexes()) {
|
2275
|
+
if (this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
|
2276
|
+
yield [this.#keyList[i], this.#valList[i]];
|
2126
2277
|
}
|
2127
2278
|
}
|
2128
2279
|
}
|
@@ -2131,9 +2282,9 @@ var _LRUCache = class _LRUCache2 {
|
|
2131
2282
|
* in order from most recently used to least recently used.
|
2132
2283
|
*/
|
2133
2284
|
*keys() {
|
2134
|
-
for (const i of
|
2135
|
-
const k =
|
2136
|
-
if (k !== void 0 && !
|
2285
|
+
for (const i of this.#indexes()) {
|
2286
|
+
const k = this.#keyList[i];
|
2287
|
+
if (k !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
|
2137
2288
|
yield k;
|
2138
2289
|
}
|
2139
2290
|
}
|
@@ -2145,9 +2296,9 @@ var _LRUCache = class _LRUCache2 {
|
|
2145
2296
|
* in order from least recently used to most recently used.
|
2146
2297
|
*/
|
2147
2298
|
*rkeys() {
|
2148
|
-
for (const i of
|
2149
|
-
const k =
|
2150
|
-
if (k !== void 0 && !
|
2299
|
+
for (const i of this.#rindexes()) {
|
2300
|
+
const k = this.#keyList[i];
|
2301
|
+
if (k !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
|
2151
2302
|
yield k;
|
2152
2303
|
}
|
2153
2304
|
}
|
@@ -2157,10 +2308,10 @@ var _LRUCache = class _LRUCache2 {
|
|
2157
2308
|
* in order from most recently used to least recently used.
|
2158
2309
|
*/
|
2159
2310
|
*values() {
|
2160
|
-
for (const i of
|
2161
|
-
const v =
|
2162
|
-
if (v !== void 0 && !
|
2163
|
-
yield
|
2311
|
+
for (const i of this.#indexes()) {
|
2312
|
+
const v = this.#valList[i];
|
2313
|
+
if (v !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
|
2314
|
+
yield this.#valList[i];
|
2164
2315
|
}
|
2165
2316
|
}
|
2166
2317
|
}
|
@@ -2171,10 +2322,10 @@ var _LRUCache = class _LRUCache2 {
|
|
2171
2322
|
* in order from least recently used to most recently used.
|
2172
2323
|
*/
|
2173
2324
|
*rvalues() {
|
2174
|
-
for (const i of
|
2175
|
-
const v =
|
2176
|
-
if (v !== void 0 && !
|
2177
|
-
yield
|
2325
|
+
for (const i of this.#rindexes()) {
|
2326
|
+
const v = this.#valList[i];
|
2327
|
+
if (v !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
|
2328
|
+
yield this.#valList[i];
|
2178
2329
|
}
|
2179
2330
|
}
|
2180
2331
|
}
|
@@ -2182,21 +2333,27 @@ var _LRUCache = class _LRUCache2 {
|
|
2182
2333
|
* Iterating over the cache itself yields the same results as
|
2183
2334
|
* {@link LRUCache.entries}
|
2184
2335
|
*/
|
2185
|
-
[
|
2336
|
+
[Symbol.iterator]() {
|
2186
2337
|
return this.entries();
|
2187
2338
|
}
|
2339
|
+
/**
|
2340
|
+
* A String value that is used in the creation of the default string
|
2341
|
+
* description of an object. Called by the built-in method
|
2342
|
+
* `Object.prototype.toString`.
|
2343
|
+
*/
|
2344
|
+
[Symbol.toStringTag] = "LRUCache";
|
2188
2345
|
/**
|
2189
2346
|
* Find a value for which the supplied fn method returns a truthy value,
|
2190
2347
|
* similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
|
2191
2348
|
*/
|
2192
2349
|
find(fn, getOptions = {}) {
|
2193
|
-
for (const i of
|
2194
|
-
const v =
|
2195
|
-
const value =
|
2350
|
+
for (const i of this.#indexes()) {
|
2351
|
+
const v = this.#valList[i];
|
2352
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
2196
2353
|
if (value === void 0)
|
2197
2354
|
continue;
|
2198
|
-
if (fn(value,
|
2199
|
-
return this.get(
|
2355
|
+
if (fn(value, this.#keyList[i], this)) {
|
2356
|
+
return this.get(this.#keyList[i], getOptions);
|
2200
2357
|
}
|
2201
2358
|
}
|
2202
2359
|
}
|
@@ -2212,12 +2369,12 @@ var _LRUCache = class _LRUCache2 {
|
|
2212
2369
|
* Does not update age or recenty of use, or iterate over stale values.
|
2213
2370
|
*/
|
2214
2371
|
forEach(fn, thisp = this) {
|
2215
|
-
for (const i of
|
2216
|
-
const v =
|
2217
|
-
const value =
|
2372
|
+
for (const i of this.#indexes()) {
|
2373
|
+
const v = this.#valList[i];
|
2374
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
2218
2375
|
if (value === void 0)
|
2219
2376
|
continue;
|
2220
|
-
fn.call(thisp, value,
|
2377
|
+
fn.call(thisp, value, this.#keyList[i], this);
|
2221
2378
|
}
|
2222
2379
|
}
|
2223
2380
|
/**
|
@@ -2225,12 +2382,12 @@ var _LRUCache = class _LRUCache2 {
|
|
2225
2382
|
* reverse order. (ie, less recently used items are iterated over first.)
|
2226
2383
|
*/
|
2227
2384
|
rforEach(fn, thisp = this) {
|
2228
|
-
for (const i of
|
2229
|
-
const v =
|
2230
|
-
const value =
|
2385
|
+
for (const i of this.#rindexes()) {
|
2386
|
+
const v = this.#valList[i];
|
2387
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
2231
2388
|
if (value === void 0)
|
2232
2389
|
continue;
|
2233
|
-
fn.call(thisp, value,
|
2390
|
+
fn.call(thisp, value, this.#keyList[i], this);
|
2234
2391
|
}
|
2235
2392
|
}
|
2236
2393
|
/**
|
@@ -2239,9 +2396,9 @@ var _LRUCache = class _LRUCache2 {
|
|
2239
2396
|
*/
|
2240
2397
|
purgeStale() {
|
2241
2398
|
let deleted = false;
|
2242
|
-
for (const i of
|
2243
|
-
if (
|
2244
|
-
|
2399
|
+
for (const i of this.#rindexes({ allowStale: true })) {
|
2400
|
+
if (this.#isStale(i)) {
|
2401
|
+
this.#delete(this.#keyList[i], "expire");
|
2245
2402
|
deleted = true;
|
2246
2403
|
}
|
2247
2404
|
}
|
@@ -2260,25 +2417,25 @@ var _LRUCache = class _LRUCache2 {
|
|
2260
2417
|
* if relevant.
|
2261
2418
|
*/
|
2262
2419
|
info(key) {
|
2263
|
-
const i =
|
2420
|
+
const i = this.#keyMap.get(key);
|
2264
2421
|
if (i === void 0)
|
2265
2422
|
return void 0;
|
2266
|
-
const v =
|
2267
|
-
const value =
|
2423
|
+
const v = this.#valList[i];
|
2424
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
2268
2425
|
if (value === void 0)
|
2269
2426
|
return void 0;
|
2270
2427
|
const entry = { value };
|
2271
|
-
if (
|
2272
|
-
const ttl =
|
2273
|
-
const start =
|
2428
|
+
if (this.#ttls && this.#starts) {
|
2429
|
+
const ttl = this.#ttls[i];
|
2430
|
+
const start = this.#starts[i];
|
2274
2431
|
if (ttl && start) {
|
2275
2432
|
const remain = ttl - (perf.now() - start);
|
2276
2433
|
entry.ttl = remain;
|
2277
2434
|
entry.start = Date.now();
|
2278
2435
|
}
|
2279
2436
|
}
|
2280
|
-
if (
|
2281
|
-
entry.size =
|
2437
|
+
if (this.#sizes) {
|
2438
|
+
entry.size = this.#sizes[i];
|
2282
2439
|
}
|
2283
2440
|
return entry;
|
2284
2441
|
}
|
@@ -2297,20 +2454,20 @@ var _LRUCache = class _LRUCache2 {
|
|
2297
2454
|
*/
|
2298
2455
|
dump() {
|
2299
2456
|
const arr = [];
|
2300
|
-
for (const i of
|
2301
|
-
const key =
|
2302
|
-
const v =
|
2303
|
-
const value =
|
2457
|
+
for (const i of this.#indexes({ allowStale: true })) {
|
2458
|
+
const key = this.#keyList[i];
|
2459
|
+
const v = this.#valList[i];
|
2460
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
2304
2461
|
if (value === void 0 || key === void 0)
|
2305
2462
|
continue;
|
2306
2463
|
const entry = { value };
|
2307
|
-
if (
|
2308
|
-
entry.ttl =
|
2309
|
-
const age = perf.now() -
|
2464
|
+
if (this.#ttls && this.#starts) {
|
2465
|
+
entry.ttl = this.#ttls[i];
|
2466
|
+
const age = perf.now() - this.#starts[i];
|
2310
2467
|
entry.start = Math.floor(Date.now() - age);
|
2311
2468
|
}
|
2312
|
-
if (
|
2313
|
-
entry.size =
|
2469
|
+
if (this.#sizes) {
|
2470
|
+
entry.size = this.#sizes[i];
|
2314
2471
|
}
|
2315
2472
|
arr.unshift([key, entry]);
|
2316
2473
|
}
|
@@ -2366,65 +2523,64 @@ var _LRUCache = class _LRUCache2 {
|
|
2366
2523
|
* `cache.delete(key)`. `undefined` is never stored in the cache.
|
2367
2524
|
*/
|
2368
2525
|
set(k, v, setOptions = {}) {
|
2369
|
-
var _a3, _b3, _c2;
|
2370
2526
|
if (v === void 0) {
|
2371
2527
|
this.delete(k);
|
2372
2528
|
return this;
|
2373
2529
|
}
|
2374
2530
|
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions;
|
2375
2531
|
let { noUpdateTTL = this.noUpdateTTL } = setOptions;
|
2376
|
-
const size =
|
2532
|
+
const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
|
2377
2533
|
if (this.maxEntrySize && size > this.maxEntrySize) {
|
2378
2534
|
if (status) {
|
2379
2535
|
status.set = "miss";
|
2380
2536
|
status.maxEntrySizeExceeded = true;
|
2381
2537
|
}
|
2382
|
-
|
2538
|
+
this.#delete(k, "set");
|
2383
2539
|
return this;
|
2384
2540
|
}
|
2385
|
-
let index =
|
2541
|
+
let index = this.#size === 0 ? void 0 : this.#keyMap.get(k);
|
2386
2542
|
if (index === void 0) {
|
2387
|
-
index =
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2543
|
+
index = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
|
2544
|
+
this.#keyList[index] = k;
|
2545
|
+
this.#valList[index] = v;
|
2546
|
+
this.#keyMap.set(k, index);
|
2547
|
+
this.#next[this.#tail] = index;
|
2548
|
+
this.#prev[index] = this.#tail;
|
2549
|
+
this.#tail = index;
|
2550
|
+
this.#size++;
|
2551
|
+
this.#addItemSize(index, size, status);
|
2396
2552
|
if (status)
|
2397
2553
|
status.set = "add";
|
2398
2554
|
noUpdateTTL = false;
|
2399
2555
|
} else {
|
2400
|
-
|
2401
|
-
const oldVal =
|
2556
|
+
this.#moveToTail(index);
|
2557
|
+
const oldVal = this.#valList[index];
|
2402
2558
|
if (v !== oldVal) {
|
2403
|
-
if (
|
2559
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
|
2404
2560
|
oldVal.__abortController.abort(new Error("replaced"));
|
2405
2561
|
const { __staleWhileFetching: s } = oldVal;
|
2406
2562
|
if (s !== void 0 && !noDisposeOnSet) {
|
2407
|
-
if (
|
2408
|
-
|
2563
|
+
if (this.#hasDispose) {
|
2564
|
+
this.#dispose?.(s, k, "set");
|
2409
2565
|
}
|
2410
|
-
if (
|
2411
|
-
|
2566
|
+
if (this.#hasDisposeAfter) {
|
2567
|
+
this.#disposed?.push([s, k, "set"]);
|
2412
2568
|
}
|
2413
2569
|
}
|
2414
2570
|
} else if (!noDisposeOnSet) {
|
2415
|
-
if (
|
2416
|
-
|
2571
|
+
if (this.#hasDispose) {
|
2572
|
+
this.#dispose?.(oldVal, k, "set");
|
2417
2573
|
}
|
2418
|
-
if (
|
2419
|
-
|
2574
|
+
if (this.#hasDisposeAfter) {
|
2575
|
+
this.#disposed?.push([oldVal, k, "set"]);
|
2420
2576
|
}
|
2421
2577
|
}
|
2422
|
-
|
2423
|
-
|
2424
|
-
|
2578
|
+
this.#removeItemSize(index);
|
2579
|
+
this.#addItemSize(index, size, status);
|
2580
|
+
this.#valList[index] = v;
|
2425
2581
|
if (status) {
|
2426
2582
|
status.set = "replace";
|
2427
|
-
const oldValue = oldVal &&
|
2583
|
+
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
|
2428
2584
|
if (oldValue !== void 0)
|
2429
2585
|
status.oldValue = oldValue;
|
2430
2586
|
}
|
@@ -2432,21 +2588,21 @@ var _LRUCache = class _LRUCache2 {
|
|
2432
2588
|
status.set = "update";
|
2433
2589
|
}
|
2434
2590
|
}
|
2435
|
-
if (ttl !== 0 && !
|
2436
|
-
|
2591
|
+
if (ttl !== 0 && !this.#ttls) {
|
2592
|
+
this.#initializeTTLTracking();
|
2437
2593
|
}
|
2438
|
-
if (
|
2594
|
+
if (this.#ttls) {
|
2439
2595
|
if (!noUpdateTTL) {
|
2440
|
-
|
2596
|
+
this.#setItemTTL(index, ttl, start);
|
2441
2597
|
}
|
2442
2598
|
if (status)
|
2443
|
-
|
2599
|
+
this.#statusTTL(status, index);
|
2444
2600
|
}
|
2445
|
-
if (!noDisposeOnSet &&
|
2446
|
-
const dt =
|
2601
|
+
if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
|
2602
|
+
const dt = this.#disposed;
|
2447
2603
|
let task;
|
2448
2604
|
while (task = dt?.shift()) {
|
2449
|
-
|
2605
|
+
this.#disposeAfter?.(...task);
|
2450
2606
|
}
|
2451
2607
|
}
|
2452
2608
|
return this;
|
@@ -2456,12 +2612,11 @@ var _LRUCache = class _LRUCache2 {
|
|
2456
2612
|
* `undefined` if cache is empty.
|
2457
2613
|
*/
|
2458
2614
|
pop() {
|
2459
|
-
var _a3;
|
2460
2615
|
try {
|
2461
|
-
while (
|
2462
|
-
const val =
|
2463
|
-
|
2464
|
-
if (
|
2616
|
+
while (this.#size) {
|
2617
|
+
const val = this.#valList[this.#head];
|
2618
|
+
this.#evict(true);
|
2619
|
+
if (this.#isBackgroundFetch(val)) {
|
2465
2620
|
if (val.__staleWhileFetching) {
|
2466
2621
|
return val.__staleWhileFetching;
|
2467
2622
|
}
|
@@ -2470,15 +2625,45 @@ var _LRUCache = class _LRUCache2 {
|
|
2470
2625
|
}
|
2471
2626
|
}
|
2472
2627
|
} finally {
|
2473
|
-
if (
|
2474
|
-
const dt =
|
2628
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
2629
|
+
const dt = this.#disposed;
|
2475
2630
|
let task;
|
2476
2631
|
while (task = dt?.shift()) {
|
2477
|
-
|
2632
|
+
this.#disposeAfter?.(...task);
|
2478
2633
|
}
|
2479
2634
|
}
|
2480
2635
|
}
|
2481
2636
|
}
|
2637
|
+
#evict(free) {
|
2638
|
+
const head = this.#head;
|
2639
|
+
const k = this.#keyList[head];
|
2640
|
+
const v = this.#valList[head];
|
2641
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) {
|
2642
|
+
v.__abortController.abort(new Error("evicted"));
|
2643
|
+
} else if (this.#hasDispose || this.#hasDisposeAfter) {
|
2644
|
+
if (this.#hasDispose) {
|
2645
|
+
this.#dispose?.(v, k, "evict");
|
2646
|
+
}
|
2647
|
+
if (this.#hasDisposeAfter) {
|
2648
|
+
this.#disposed?.push([v, k, "evict"]);
|
2649
|
+
}
|
2650
|
+
}
|
2651
|
+
this.#removeItemSize(head);
|
2652
|
+
if (free) {
|
2653
|
+
this.#keyList[head] = void 0;
|
2654
|
+
this.#valList[head] = void 0;
|
2655
|
+
this.#free.push(head);
|
2656
|
+
}
|
2657
|
+
if (this.#size === 1) {
|
2658
|
+
this.#head = this.#tail = 0;
|
2659
|
+
this.#free.length = 0;
|
2660
|
+
} else {
|
2661
|
+
this.#head = this.#next[head];
|
2662
|
+
}
|
2663
|
+
this.#keyMap.delete(k);
|
2664
|
+
this.#size--;
|
2665
|
+
return head;
|
2666
|
+
}
|
2482
2667
|
/**
|
2483
2668
|
* Check if a key is in the cache, without updating the recency of use.
|
2484
2669
|
* Will return false if the item is stale, even though it is technically
|
@@ -2497,24 +2682,24 @@ var _LRUCache = class _LRUCache2 {
|
|
2497
2682
|
*/
|
2498
2683
|
has(k, hasOptions = {}) {
|
2499
2684
|
const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
|
2500
|
-
const index =
|
2685
|
+
const index = this.#keyMap.get(k);
|
2501
2686
|
if (index !== void 0) {
|
2502
|
-
const v =
|
2503
|
-
if (
|
2687
|
+
const v = this.#valList[index];
|
2688
|
+
if (this.#isBackgroundFetch(v) && v.__staleWhileFetching === void 0) {
|
2504
2689
|
return false;
|
2505
2690
|
}
|
2506
|
-
if (!
|
2691
|
+
if (!this.#isStale(index)) {
|
2507
2692
|
if (updateAgeOnHas) {
|
2508
|
-
|
2693
|
+
this.#updateItemAge(index);
|
2509
2694
|
}
|
2510
2695
|
if (status) {
|
2511
2696
|
status.has = "hit";
|
2512
|
-
|
2697
|
+
this.#statusTTL(status, index);
|
2513
2698
|
}
|
2514
2699
|
return true;
|
2515
2700
|
} else if (status) {
|
2516
2701
|
status.has = "stale";
|
2517
|
-
|
2702
|
+
this.#statusTTL(status, index);
|
2518
2703
|
}
|
2519
2704
|
} else if (status) {
|
2520
2705
|
status.has = "miss";
|
@@ -2530,12 +2715,125 @@ var _LRUCache = class _LRUCache2 {
|
|
2530
2715
|
*/
|
2531
2716
|
peek(k, peekOptions = {}) {
|
2532
2717
|
const { allowStale = this.allowStale } = peekOptions;
|
2533
|
-
const index =
|
2534
|
-
if (index === void 0 || !allowStale &&
|
2718
|
+
const index = this.#keyMap.get(k);
|
2719
|
+
if (index === void 0 || !allowStale && this.#isStale(index)) {
|
2535
2720
|
return;
|
2536
2721
|
}
|
2537
|
-
const v =
|
2538
|
-
return
|
2722
|
+
const v = this.#valList[index];
|
2723
|
+
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
2724
|
+
}
|
2725
|
+
#backgroundFetch(k, index, options, context) {
|
2726
|
+
const v = index === void 0 ? void 0 : this.#valList[index];
|
2727
|
+
if (this.#isBackgroundFetch(v)) {
|
2728
|
+
return v;
|
2729
|
+
}
|
2730
|
+
const ac = new AC();
|
2731
|
+
const { signal } = options;
|
2732
|
+
signal?.addEventListener("abort", () => ac.abort(signal.reason), {
|
2733
|
+
signal: ac.signal
|
2734
|
+
});
|
2735
|
+
const fetchOpts = {
|
2736
|
+
signal: ac.signal,
|
2737
|
+
options,
|
2738
|
+
context
|
2739
|
+
};
|
2740
|
+
const cb = (v2, updateCache = false) => {
|
2741
|
+
const { aborted } = ac.signal;
|
2742
|
+
const ignoreAbort = options.ignoreFetchAbort && v2 !== void 0;
|
2743
|
+
if (options.status) {
|
2744
|
+
if (aborted && !updateCache) {
|
2745
|
+
options.status.fetchAborted = true;
|
2746
|
+
options.status.fetchError = ac.signal.reason;
|
2747
|
+
if (ignoreAbort)
|
2748
|
+
options.status.fetchAbortIgnored = true;
|
2749
|
+
} else {
|
2750
|
+
options.status.fetchResolved = true;
|
2751
|
+
}
|
2752
|
+
}
|
2753
|
+
if (aborted && !ignoreAbort && !updateCache) {
|
2754
|
+
return fetchFail(ac.signal.reason);
|
2755
|
+
}
|
2756
|
+
const bf2 = p;
|
2757
|
+
if (this.#valList[index] === p) {
|
2758
|
+
if (v2 === void 0) {
|
2759
|
+
if (bf2.__staleWhileFetching) {
|
2760
|
+
this.#valList[index] = bf2.__staleWhileFetching;
|
2761
|
+
} else {
|
2762
|
+
this.#delete(k, "fetch");
|
2763
|
+
}
|
2764
|
+
} else {
|
2765
|
+
if (options.status)
|
2766
|
+
options.status.fetchUpdated = true;
|
2767
|
+
this.set(k, v2, fetchOpts.options);
|
2768
|
+
}
|
2769
|
+
}
|
2770
|
+
return v2;
|
2771
|
+
};
|
2772
|
+
const eb = (er) => {
|
2773
|
+
if (options.status) {
|
2774
|
+
options.status.fetchRejected = true;
|
2775
|
+
options.status.fetchError = er;
|
2776
|
+
}
|
2777
|
+
return fetchFail(er);
|
2778
|
+
};
|
2779
|
+
const fetchFail = (er) => {
|
2780
|
+
const { aborted } = ac.signal;
|
2781
|
+
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
|
2782
|
+
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
|
2783
|
+
const noDelete = allowStale || options.noDeleteOnFetchRejection;
|
2784
|
+
const bf2 = p;
|
2785
|
+
if (this.#valList[index] === p) {
|
2786
|
+
const del = !noDelete || bf2.__staleWhileFetching === void 0;
|
2787
|
+
if (del) {
|
2788
|
+
this.#delete(k, "fetch");
|
2789
|
+
} else if (!allowStaleAborted) {
|
2790
|
+
this.#valList[index] = bf2.__staleWhileFetching;
|
2791
|
+
}
|
2792
|
+
}
|
2793
|
+
if (allowStale) {
|
2794
|
+
if (options.status && bf2.__staleWhileFetching !== void 0) {
|
2795
|
+
options.status.returnedStale = true;
|
2796
|
+
}
|
2797
|
+
return bf2.__staleWhileFetching;
|
2798
|
+
} else if (bf2.__returned === bf2) {
|
2799
|
+
throw er;
|
2800
|
+
}
|
2801
|
+
};
|
2802
|
+
const pcall = (res, rej) => {
|
2803
|
+
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
2804
|
+
if (fmp && fmp instanceof Promise) {
|
2805
|
+
fmp.then((v2) => res(v2 === void 0 ? void 0 : v2), rej);
|
2806
|
+
}
|
2807
|
+
ac.signal.addEventListener("abort", () => {
|
2808
|
+
if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
|
2809
|
+
res(void 0);
|
2810
|
+
if (options.allowStaleOnFetchAbort) {
|
2811
|
+
res = (v2) => cb(v2, true);
|
2812
|
+
}
|
2813
|
+
}
|
2814
|
+
});
|
2815
|
+
};
|
2816
|
+
if (options.status)
|
2817
|
+
options.status.fetchDispatched = true;
|
2818
|
+
const p = new Promise(pcall).then(cb, eb);
|
2819
|
+
const bf = Object.assign(p, {
|
2820
|
+
__abortController: ac,
|
2821
|
+
__staleWhileFetching: v,
|
2822
|
+
__returned: void 0
|
2823
|
+
});
|
2824
|
+
if (index === void 0) {
|
2825
|
+
this.set(k, bf, { ...fetchOpts.options, status: void 0 });
|
2826
|
+
index = this.#keyMap.get(k);
|
2827
|
+
} else {
|
2828
|
+
this.#valList[index] = bf;
|
2829
|
+
}
|
2830
|
+
return bf;
|
2831
|
+
}
|
2832
|
+
#isBackgroundFetch(p) {
|
2833
|
+
if (!this.#hasFetchMethod)
|
2834
|
+
return false;
|
2835
|
+
const b = p;
|
2836
|
+
return !!b && b instanceof Promise && b.hasOwnProperty("__staleWhileFetching") && b.__abortController instanceof AC;
|
2539
2837
|
}
|
2540
2838
|
async fetch(k, fetchOptions = {}) {
|
2541
2839
|
const {
|
@@ -2559,7 +2857,7 @@ var _LRUCache = class _LRUCache2 {
|
|
2559
2857
|
status,
|
2560
2858
|
signal
|
2561
2859
|
} = fetchOptions;
|
2562
|
-
if (!
|
2860
|
+
if (!this.#hasFetchMethod) {
|
2563
2861
|
if (status)
|
2564
2862
|
status.fetch = "get";
|
2565
2863
|
return this.get(k, {
|
@@ -2585,15 +2883,15 @@ var _LRUCache = class _LRUCache2 {
|
|
2585
2883
|
status,
|
2586
2884
|
signal
|
2587
2885
|
};
|
2588
|
-
let index =
|
2886
|
+
let index = this.#keyMap.get(k);
|
2589
2887
|
if (index === void 0) {
|
2590
2888
|
if (status)
|
2591
2889
|
status.fetch = "miss";
|
2592
|
-
const p =
|
2890
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
2593
2891
|
return p.__returned = p;
|
2594
2892
|
} else {
|
2595
|
-
const v =
|
2596
|
-
if (
|
2893
|
+
const v = this.#valList[index];
|
2894
|
+
if (this.#isBackgroundFetch(v)) {
|
2597
2895
|
const stale = allowStale && v.__staleWhileFetching !== void 0;
|
2598
2896
|
if (status) {
|
2599
2897
|
status.fetch = "inflight";
|
@@ -2602,19 +2900,19 @@ var _LRUCache = class _LRUCache2 {
|
|
2602
2900
|
}
|
2603
2901
|
return stale ? v.__staleWhileFetching : v.__returned = v;
|
2604
2902
|
}
|
2605
|
-
const isStale =
|
2903
|
+
const isStale = this.#isStale(index);
|
2606
2904
|
if (!forceRefresh && !isStale) {
|
2607
2905
|
if (status)
|
2608
2906
|
status.fetch = "hit";
|
2609
|
-
|
2907
|
+
this.#moveToTail(index);
|
2610
2908
|
if (updateAgeOnGet) {
|
2611
|
-
|
2909
|
+
this.#updateItemAge(index);
|
2612
2910
|
}
|
2613
2911
|
if (status)
|
2614
|
-
|
2912
|
+
this.#statusTTL(status, index);
|
2615
2913
|
return v;
|
2616
2914
|
}
|
2617
|
-
const p =
|
2915
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
2618
2916
|
const hasStale = p.__staleWhileFetching !== void 0;
|
2619
2917
|
const staleVal = hasStale && allowStale;
|
2620
2918
|
if (status) {
|
@@ -2632,7 +2930,7 @@ var _LRUCache = class _LRUCache2 {
|
|
2632
2930
|
return v;
|
2633
2931
|
}
|
2634
2932
|
memo(k, memoOptions = {}) {
|
2635
|
-
const memoMethod =
|
2933
|
+
const memoMethod = this.#memoMethod;
|
2636
2934
|
if (!memoMethod) {
|
2637
2935
|
throw new Error("no memoMethod provided to constructor");
|
2638
2936
|
}
|
@@ -2655,18 +2953,18 @@ var _LRUCache = class _LRUCache2 {
|
|
2655
2953
|
*/
|
2656
2954
|
get(k, getOptions = {}) {
|
2657
2955
|
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions;
|
2658
|
-
const index =
|
2956
|
+
const index = this.#keyMap.get(k);
|
2659
2957
|
if (index !== void 0) {
|
2660
|
-
const value =
|
2661
|
-
const fetching =
|
2958
|
+
const value = this.#valList[index];
|
2959
|
+
const fetching = this.#isBackgroundFetch(value);
|
2662
2960
|
if (status)
|
2663
|
-
|
2664
|
-
if (
|
2961
|
+
this.#statusTTL(status, index);
|
2962
|
+
if (this.#isStale(index)) {
|
2665
2963
|
if (status)
|
2666
2964
|
status.get = "stale";
|
2667
2965
|
if (!fetching) {
|
2668
2966
|
if (!noDeleteOnStaleGet) {
|
2669
|
-
|
2967
|
+
this.#delete(k, "expire");
|
2670
2968
|
}
|
2671
2969
|
if (status && allowStale)
|
2672
2970
|
status.returnedStale = true;
|
@@ -2675,464 +2973,140 @@ var _LRUCache = class _LRUCache2 {
|
|
2675
2973
|
if (status && allowStale && value.__staleWhileFetching !== void 0) {
|
2676
2974
|
status.returnedStale = true;
|
2677
2975
|
}
|
2678
|
-
return allowStale ? value.__staleWhileFetching : void 0;
|
2679
|
-
}
|
2680
|
-
} else {
|
2681
|
-
if (status)
|
2682
|
-
status.get = "hit";
|
2683
|
-
if (fetching) {
|
2684
|
-
return value.__staleWhileFetching;
|
2685
|
-
}
|
2686
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, moveToTail_fn).call(this, index);
|
2687
|
-
if (updateAgeOnGet) {
|
2688
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _updateItemAge).call(this, index);
|
2689
|
-
}
|
2690
|
-
return value;
|
2691
|
-
}
|
2692
|
-
} else if (status) {
|
2693
|
-
status.get = "miss";
|
2694
|
-
}
|
2695
|
-
}
|
2696
|
-
/**
|
2697
|
-
* Deletes a key out of the cache.
|
2698
|
-
*
|
2699
|
-
* Returns true if the key was deleted, false otherwise.
|
2700
|
-
*/
|
2701
|
-
delete(k) {
|
2702
|
-
return (0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, delete_fn).call(this, k, "delete");
|
2703
|
-
}
|
2704
|
-
/**
|
2705
|
-
* Clear the cache entirely, throwing away all values.
|
2706
|
-
*/
|
2707
|
-
clear() {
|
2708
|
-
return (0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, clear_fn).call(this, "delete");
|
2709
|
-
}
|
2710
|
-
};
|
2711
|
-
_max = /* @__PURE__ */ new WeakMap();
|
2712
|
-
_maxSize = /* @__PURE__ */ new WeakMap();
|
2713
|
-
_dispose = /* @__PURE__ */ new WeakMap();
|
2714
|
-
_disposeAfter = /* @__PURE__ */ new WeakMap();
|
2715
|
-
_fetchMethod = /* @__PURE__ */ new WeakMap();
|
2716
|
-
_memoMethod = /* @__PURE__ */ new WeakMap();
|
2717
|
-
_size = /* @__PURE__ */ new WeakMap();
|
2718
|
-
_calculatedSize = /* @__PURE__ */ new WeakMap();
|
2719
|
-
_keyMap = /* @__PURE__ */ new WeakMap();
|
2720
|
-
_keyList = /* @__PURE__ */ new WeakMap();
|
2721
|
-
_valList = /* @__PURE__ */ new WeakMap();
|
2722
|
-
_next = /* @__PURE__ */ new WeakMap();
|
2723
|
-
_prev = /* @__PURE__ */ new WeakMap();
|
2724
|
-
_head = /* @__PURE__ */ new WeakMap();
|
2725
|
-
_tail = /* @__PURE__ */ new WeakMap();
|
2726
|
-
_free = /* @__PURE__ */ new WeakMap();
|
2727
|
-
_disposed = /* @__PURE__ */ new WeakMap();
|
2728
|
-
_sizes = /* @__PURE__ */ new WeakMap();
|
2729
|
-
_starts = /* @__PURE__ */ new WeakMap();
|
2730
|
-
_ttls = /* @__PURE__ */ new WeakMap();
|
2731
|
-
_hasDispose = /* @__PURE__ */ new WeakMap();
|
2732
|
-
_hasFetchMethod = /* @__PURE__ */ new WeakMap();
|
2733
|
-
_hasDisposeAfter = /* @__PURE__ */ new WeakMap();
|
2734
|
-
_LRUCache_instances = /* @__PURE__ */ new WeakSet();
|
2735
|
-
initializeTTLTracking_fn = function() {
|
2736
|
-
const ttls = new ZeroArray((0, import_chunk_OSFPEEC6.__privateGet)(this, _max));
|
2737
|
-
const starts = new ZeroArray((0, import_chunk_OSFPEEC6.__privateGet)(this, _max));
|
2738
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _ttls, ttls);
|
2739
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _starts, starts);
|
2740
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _setItemTTL, (index, ttl, start = perf.now()) => {
|
2741
|
-
starts[index] = ttl !== 0 ? start : 0;
|
2742
|
-
ttls[index] = ttl;
|
2743
|
-
if (ttl !== 0 && this.ttlAutopurge) {
|
2744
|
-
const t = setTimeout(() => {
|
2745
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _isStale).call(this, index)) {
|
2746
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, delete_fn).call(this, (0, import_chunk_OSFPEEC6.__privateGet)(this, _keyList)[index], "expire");
|
2976
|
+
return allowStale ? value.__staleWhileFetching : void 0;
|
2747
2977
|
}
|
2748
|
-
}
|
2749
|
-
|
2750
|
-
|
2751
|
-
|
2752
|
-
|
2753
|
-
});
|
2754
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _updateItemAge, (index) => {
|
2755
|
-
starts[index] = ttls[index] !== 0 ? perf.now() : 0;
|
2756
|
-
});
|
2757
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _statusTTL, (status, index) => {
|
2758
|
-
if (ttls[index]) {
|
2759
|
-
const ttl = ttls[index];
|
2760
|
-
const start = starts[index];
|
2761
|
-
if (!ttl || !start)
|
2762
|
-
return;
|
2763
|
-
status.ttl = ttl;
|
2764
|
-
status.start = start;
|
2765
|
-
status.now = cachedNow || getNow();
|
2766
|
-
const age = status.now - start;
|
2767
|
-
status.remainingTTL = ttl - age;
|
2768
|
-
}
|
2769
|
-
});
|
2770
|
-
let cachedNow = 0;
|
2771
|
-
const getNow = () => {
|
2772
|
-
const n = perf.now();
|
2773
|
-
if (this.ttlResolution > 0) {
|
2774
|
-
cachedNow = n;
|
2775
|
-
const t = setTimeout(() => cachedNow = 0, this.ttlResolution);
|
2776
|
-
if (t.unref) {
|
2777
|
-
t.unref();
|
2778
|
-
}
|
2779
|
-
}
|
2780
|
-
return n;
|
2781
|
-
};
|
2782
|
-
this.getRemainingTTL = (key) => {
|
2783
|
-
const index = (0, import_chunk_OSFPEEC6.__privateGet)(this, _keyMap).get(key);
|
2784
|
-
if (index === void 0) {
|
2785
|
-
return 0;
|
2786
|
-
}
|
2787
|
-
const ttl = ttls[index];
|
2788
|
-
const start = starts[index];
|
2789
|
-
if (!ttl || !start) {
|
2790
|
-
return Infinity;
|
2791
|
-
}
|
2792
|
-
const age = (cachedNow || getNow()) - start;
|
2793
|
-
return ttl - age;
|
2794
|
-
};
|
2795
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _isStale, (index) => {
|
2796
|
-
const s = starts[index];
|
2797
|
-
const t = ttls[index];
|
2798
|
-
return !!t && !!s && (cachedNow || getNow()) - s > t;
|
2799
|
-
});
|
2800
|
-
};
|
2801
|
-
_updateItemAge = /* @__PURE__ */ new WeakMap();
|
2802
|
-
_statusTTL = /* @__PURE__ */ new WeakMap();
|
2803
|
-
_setItemTTL = /* @__PURE__ */ new WeakMap();
|
2804
|
-
_isStale = /* @__PURE__ */ new WeakMap();
|
2805
|
-
initializeSizeTracking_fn = function() {
|
2806
|
-
const sizes = new ZeroArray((0, import_chunk_OSFPEEC6.__privateGet)(this, _max));
|
2807
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _calculatedSize, 0);
|
2808
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _sizes, sizes);
|
2809
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _removeItemSize, (index) => {
|
2810
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _calculatedSize, (0, import_chunk_OSFPEEC6.__privateGet)(this, _calculatedSize) - sizes[index]);
|
2811
|
-
sizes[index] = 0;
|
2812
|
-
});
|
2813
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _requireSize, (k, v, size, sizeCalculation) => {
|
2814
|
-
if ((0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v)) {
|
2815
|
-
return 0;
|
2816
|
-
}
|
2817
|
-
if (!isPosInt(size)) {
|
2818
|
-
if (sizeCalculation) {
|
2819
|
-
if (typeof sizeCalculation !== "function") {
|
2820
|
-
throw new TypeError("sizeCalculation must be a function");
|
2978
|
+
} else {
|
2979
|
+
if (status)
|
2980
|
+
status.get = "hit";
|
2981
|
+
if (fetching) {
|
2982
|
+
return value.__staleWhileFetching;
|
2821
2983
|
}
|
2822
|
-
|
2823
|
-
if (
|
2824
|
-
|
2984
|
+
this.#moveToTail(index);
|
2985
|
+
if (updateAgeOnGet) {
|
2986
|
+
this.#updateItemAge(index);
|
2825
2987
|
}
|
2826
|
-
|
2827
|
-
throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
2828
|
-
}
|
2829
|
-
}
|
2830
|
-
return size;
|
2831
|
-
});
|
2832
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _addItemSize, (index, size, status) => {
|
2833
|
-
sizes[index] = size;
|
2834
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _maxSize)) {
|
2835
|
-
const maxSize = (0, import_chunk_OSFPEEC6.__privateGet)(this, _maxSize) - sizes[index];
|
2836
|
-
while ((0, import_chunk_OSFPEEC6.__privateGet)(this, _calculatedSize) > maxSize) {
|
2837
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, evict_fn).call(this, true);
|
2838
|
-
}
|
2839
|
-
}
|
2840
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _calculatedSize, (0, import_chunk_OSFPEEC6.__privateGet)(this, _calculatedSize) + sizes[index]);
|
2841
|
-
if (status) {
|
2842
|
-
status.entrySize = size;
|
2843
|
-
status.totalCalculatedSize = (0, import_chunk_OSFPEEC6.__privateGet)(this, _calculatedSize);
|
2844
|
-
}
|
2845
|
-
});
|
2846
|
-
};
|
2847
|
-
_removeItemSize = /* @__PURE__ */ new WeakMap();
|
2848
|
-
_addItemSize = /* @__PURE__ */ new WeakMap();
|
2849
|
-
_requireSize = /* @__PURE__ */ new WeakMap();
|
2850
|
-
indexes_fn = function* ({ allowStale = this.allowStale } = {}) {
|
2851
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _size)) {
|
2852
|
-
for (let i = (0, import_chunk_OSFPEEC6.__privateGet)(this, _tail); true; ) {
|
2853
|
-
if (!(0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, isValidIndex_fn).call(this, i)) {
|
2854
|
-
break;
|
2855
|
-
}
|
2856
|
-
if (allowStale || !(0, import_chunk_OSFPEEC6.__privateGet)(this, _isStale).call(this, i)) {
|
2857
|
-
yield i;
|
2858
|
-
}
|
2859
|
-
if (i === (0, import_chunk_OSFPEEC6.__privateGet)(this, _head)) {
|
2860
|
-
break;
|
2861
|
-
} else {
|
2862
|
-
i = (0, import_chunk_OSFPEEC6.__privateGet)(this, _prev)[i];
|
2988
|
+
return value;
|
2863
2989
|
}
|
2990
|
+
} else if (status) {
|
2991
|
+
status.get = "miss";
|
2864
2992
|
}
|
2865
2993
|
}
|
2866
|
-
|
2867
|
-
|
2868
|
-
|
2869
|
-
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
2874
|
-
yield i;
|
2875
|
-
}
|
2876
|
-
if (i === (0, import_chunk_OSFPEEC6.__privateGet)(this, _tail)) {
|
2877
|
-
break;
|
2994
|
+
#connect(p, n) {
|
2995
|
+
this.#prev[n] = p;
|
2996
|
+
this.#next[p] = n;
|
2997
|
+
}
|
2998
|
+
#moveToTail(index) {
|
2999
|
+
if (index !== this.#tail) {
|
3000
|
+
if (index === this.#head) {
|
3001
|
+
this.#head = this.#next[index];
|
2878
3002
|
} else {
|
2879
|
-
|
3003
|
+
this.#connect(this.#prev[index], this.#next[index]);
|
2880
3004
|
}
|
3005
|
+
this.#connect(this.#tail, index);
|
3006
|
+
this.#tail = index;
|
2881
3007
|
}
|
2882
3008
|
}
|
2883
|
-
|
2884
|
-
|
2885
|
-
|
2886
|
-
|
2887
|
-
|
2888
|
-
|
2889
|
-
|
2890
|
-
const k = (0, import_chunk_OSFPEEC6.__privateGet)(this, _keyList)[head];
|
2891
|
-
const v = (0, import_chunk_OSFPEEC6.__privateGet)(this, _valList)[head];
|
2892
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _hasFetchMethod) && (0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v)) {
|
2893
|
-
v.__abortController.abort(new Error("evicted"));
|
2894
|
-
} else if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _hasDispose) || (0, import_chunk_OSFPEEC6.__privateGet)(this, _hasDisposeAfter)) {
|
2895
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _hasDispose)) {
|
2896
|
-
(_a3 = (0, import_chunk_OSFPEEC6.__privateGet)(this, _dispose)) == null ? void 0 : _a3.call(this, v, k, "evict");
|
2897
|
-
}
|
2898
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _hasDisposeAfter)) {
|
2899
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _disposed)?.push([v, k, "evict"]);
|
2900
|
-
}
|
2901
|
-
}
|
2902
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _removeItemSize).call(this, head);
|
2903
|
-
if (free) {
|
2904
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _keyList)[head] = void 0;
|
2905
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _valList)[head] = void 0;
|
2906
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _free).push(head);
|
2907
|
-
}
|
2908
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _size) === 1) {
|
2909
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _head, (0, import_chunk_OSFPEEC6.__privateSet)(this, _tail, 0));
|
2910
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _free).length = 0;
|
2911
|
-
} else {
|
2912
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _head, (0, import_chunk_OSFPEEC6.__privateGet)(this, _next)[head]);
|
2913
|
-
}
|
2914
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _keyMap).delete(k);
|
2915
|
-
(0, import_chunk_OSFPEEC6.__privateWrapper)(this, _size)._--;
|
2916
|
-
return head;
|
2917
|
-
};
|
2918
|
-
backgroundFetch_fn = function(k, index, options, context) {
|
2919
|
-
const v = index === void 0 ? void 0 : (0, import_chunk_OSFPEEC6.__privateGet)(this, _valList)[index];
|
2920
|
-
if ((0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v)) {
|
2921
|
-
return v;
|
3009
|
+
/**
|
3010
|
+
* Deletes a key out of the cache.
|
3011
|
+
*
|
3012
|
+
* Returns true if the key was deleted, false otherwise.
|
3013
|
+
*/
|
3014
|
+
delete(k) {
|
3015
|
+
return this.#delete(k, "delete");
|
2922
3016
|
}
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2931
|
-
context
|
2932
|
-
};
|
2933
|
-
const cb = (v2, updateCache = false) => {
|
2934
|
-
const { aborted } = ac.signal;
|
2935
|
-
const ignoreAbort = options.ignoreFetchAbort && v2 !== void 0;
|
2936
|
-
if (options.status) {
|
2937
|
-
if (aborted && !updateCache) {
|
2938
|
-
options.status.fetchAborted = true;
|
2939
|
-
options.status.fetchError = ac.signal.reason;
|
2940
|
-
if (ignoreAbort)
|
2941
|
-
options.status.fetchAbortIgnored = true;
|
2942
|
-
} else {
|
2943
|
-
options.status.fetchResolved = true;
|
2944
|
-
}
|
2945
|
-
}
|
2946
|
-
if (aborted && !ignoreAbort && !updateCache) {
|
2947
|
-
return fetchFail(ac.signal.reason);
|
2948
|
-
}
|
2949
|
-
const bf2 = p;
|
2950
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _valList)[index] === p) {
|
2951
|
-
if (v2 === void 0) {
|
2952
|
-
if (bf2.__staleWhileFetching) {
|
2953
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _valList)[index] = bf2.__staleWhileFetching;
|
3017
|
+
#delete(k, reason) {
|
3018
|
+
let deleted = false;
|
3019
|
+
if (this.#size !== 0) {
|
3020
|
+
const index = this.#keyMap.get(k);
|
3021
|
+
if (index !== void 0) {
|
3022
|
+
deleted = true;
|
3023
|
+
if (this.#size === 1) {
|
3024
|
+
this.#clear(reason);
|
2954
3025
|
} else {
|
2955
|
-
|
3026
|
+
this.#removeItemSize(index);
|
3027
|
+
const v = this.#valList[index];
|
3028
|
+
if (this.#isBackgroundFetch(v)) {
|
3029
|
+
v.__abortController.abort(new Error("deleted"));
|
3030
|
+
} else if (this.#hasDispose || this.#hasDisposeAfter) {
|
3031
|
+
if (this.#hasDispose) {
|
3032
|
+
this.#dispose?.(v, k, reason);
|
3033
|
+
}
|
3034
|
+
if (this.#hasDisposeAfter) {
|
3035
|
+
this.#disposed?.push([v, k, reason]);
|
3036
|
+
}
|
3037
|
+
}
|
3038
|
+
this.#keyMap.delete(k);
|
3039
|
+
this.#keyList[index] = void 0;
|
3040
|
+
this.#valList[index] = void 0;
|
3041
|
+
if (index === this.#tail) {
|
3042
|
+
this.#tail = this.#prev[index];
|
3043
|
+
} else if (index === this.#head) {
|
3044
|
+
this.#head = this.#next[index];
|
3045
|
+
} else {
|
3046
|
+
const pi = this.#prev[index];
|
3047
|
+
this.#next[pi] = this.#next[index];
|
3048
|
+
const ni = this.#next[index];
|
3049
|
+
this.#prev[ni] = this.#prev[index];
|
3050
|
+
}
|
3051
|
+
this.#size--;
|
3052
|
+
this.#free.push(index);
|
2956
3053
|
}
|
2957
|
-
} else {
|
2958
|
-
if (options.status)
|
2959
|
-
options.status.fetchUpdated = true;
|
2960
|
-
this.set(k, v2, fetchOpts.options);
|
2961
3054
|
}
|
2962
3055
|
}
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
options.status.fetchError = er;
|
2969
|
-
}
|
2970
|
-
return fetchFail(er);
|
2971
|
-
};
|
2972
|
-
const fetchFail = (er) => {
|
2973
|
-
const { aborted } = ac.signal;
|
2974
|
-
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
|
2975
|
-
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
|
2976
|
-
const noDelete = allowStale || options.noDeleteOnFetchRejection;
|
2977
|
-
const bf2 = p;
|
2978
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _valList)[index] === p) {
|
2979
|
-
const del = !noDelete || bf2.__staleWhileFetching === void 0;
|
2980
|
-
if (del) {
|
2981
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, delete_fn).call(this, k, "fetch");
|
2982
|
-
} else if (!allowStaleAborted) {
|
2983
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _valList)[index] = bf2.__staleWhileFetching;
|
2984
|
-
}
|
2985
|
-
}
|
2986
|
-
if (allowStale) {
|
2987
|
-
if (options.status && bf2.__staleWhileFetching !== void 0) {
|
2988
|
-
options.status.returnedStale = true;
|
2989
|
-
}
|
2990
|
-
return bf2.__staleWhileFetching;
|
2991
|
-
} else if (bf2.__returned === bf2) {
|
2992
|
-
throw er;
|
2993
|
-
}
|
2994
|
-
};
|
2995
|
-
const pcall = (res, rej) => {
|
2996
|
-
var _a3;
|
2997
|
-
const fmp = (_a3 = (0, import_chunk_OSFPEEC6.__privateGet)(this, _fetchMethod)) == null ? void 0 : _a3.call(this, k, v, fetchOpts);
|
2998
|
-
if (fmp && fmp instanceof Promise) {
|
2999
|
-
fmp.then((v2) => res(v2 === void 0 ? void 0 : v2), rej);
|
3000
|
-
}
|
3001
|
-
ac.signal.addEventListener("abort", () => {
|
3002
|
-
if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
|
3003
|
-
res(void 0);
|
3004
|
-
if (options.allowStaleOnFetchAbort) {
|
3005
|
-
res = (v2) => cb(v2, true);
|
3006
|
-
}
|
3056
|
+
if (this.#hasDisposeAfter && this.#disposed?.length) {
|
3057
|
+
const dt = this.#disposed;
|
3058
|
+
let task;
|
3059
|
+
while (task = dt?.shift()) {
|
3060
|
+
this.#disposeAfter?.(...task);
|
3007
3061
|
}
|
3008
|
-
});
|
3009
|
-
};
|
3010
|
-
if (options.status)
|
3011
|
-
options.status.fetchDispatched = true;
|
3012
|
-
const p = new Promise(pcall).then(cb, eb);
|
3013
|
-
const bf = Object.assign(p, {
|
3014
|
-
__abortController: ac,
|
3015
|
-
__staleWhileFetching: v,
|
3016
|
-
__returned: void 0
|
3017
|
-
});
|
3018
|
-
if (index === void 0) {
|
3019
|
-
this.set(k, bf, { ...fetchOpts.options, status: void 0 });
|
3020
|
-
index = (0, import_chunk_OSFPEEC6.__privateGet)(this, _keyMap).get(k);
|
3021
|
-
} else {
|
3022
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _valList)[index] = bf;
|
3023
|
-
}
|
3024
|
-
return bf;
|
3025
|
-
};
|
3026
|
-
isBackgroundFetch_fn = function(p) {
|
3027
|
-
if (!(0, import_chunk_OSFPEEC6.__privateGet)(this, _hasFetchMethod))
|
3028
|
-
return false;
|
3029
|
-
const b = p;
|
3030
|
-
return !!b && b instanceof Promise && b.hasOwnProperty("__staleWhileFetching") && b.__abortController instanceof AC;
|
3031
|
-
};
|
3032
|
-
connect_fn = function(p, n) {
|
3033
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _prev)[n] = p;
|
3034
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _next)[p] = n;
|
3035
|
-
};
|
3036
|
-
moveToTail_fn = function(index) {
|
3037
|
-
if (index !== (0, import_chunk_OSFPEEC6.__privateGet)(this, _tail)) {
|
3038
|
-
if (index === (0, import_chunk_OSFPEEC6.__privateGet)(this, _head)) {
|
3039
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _head, (0, import_chunk_OSFPEEC6.__privateGet)(this, _next)[index]);
|
3040
|
-
} else {
|
3041
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, connect_fn).call(this, (0, import_chunk_OSFPEEC6.__privateGet)(this, _prev)[index], (0, import_chunk_OSFPEEC6.__privateGet)(this, _next)[index]);
|
3042
3062
|
}
|
3043
|
-
|
3044
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _tail, index);
|
3063
|
+
return deleted;
|
3045
3064
|
}
|
3046
|
-
|
3047
|
-
|
3048
|
-
|
3049
|
-
|
3050
|
-
|
3051
|
-
|
3052
|
-
|
3053
|
-
|
3054
|
-
|
3055
|
-
|
3065
|
+
/**
|
3066
|
+
* Clear the cache entirely, throwing away all values.
|
3067
|
+
*/
|
3068
|
+
clear() {
|
3069
|
+
return this.#clear("delete");
|
3070
|
+
}
|
3071
|
+
#clear(reason) {
|
3072
|
+
for (const index of this.#rindexes({ allowStale: true })) {
|
3073
|
+
const v = this.#valList[index];
|
3074
|
+
if (this.#isBackgroundFetch(v)) {
|
3075
|
+
v.__abortController.abort(new Error("deleted"));
|
3056
3076
|
} else {
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
v.__abortController.abort(new Error("deleted"));
|
3061
|
-
} else if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _hasDispose) || (0, import_chunk_OSFPEEC6.__privateGet)(this, _hasDisposeAfter)) {
|
3062
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _hasDispose)) {
|
3063
|
-
(_a3 = (0, import_chunk_OSFPEEC6.__privateGet)(this, _dispose)) == null ? void 0 : _a3.call(this, v, k, reason);
|
3064
|
-
}
|
3065
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _hasDisposeAfter)) {
|
3066
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _disposed)?.push([v, k, reason]);
|
3067
|
-
}
|
3077
|
+
const k = this.#keyList[index];
|
3078
|
+
if (this.#hasDispose) {
|
3079
|
+
this.#dispose?.(v, k, reason);
|
3068
3080
|
}
|
3069
|
-
|
3070
|
-
|
3071
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _valList)[index] = void 0;
|
3072
|
-
if (index === (0, import_chunk_OSFPEEC6.__privateGet)(this, _tail)) {
|
3073
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _tail, (0, import_chunk_OSFPEEC6.__privateGet)(this, _prev)[index]);
|
3074
|
-
} else if (index === (0, import_chunk_OSFPEEC6.__privateGet)(this, _head)) {
|
3075
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _head, (0, import_chunk_OSFPEEC6.__privateGet)(this, _next)[index]);
|
3076
|
-
} else {
|
3077
|
-
const pi = (0, import_chunk_OSFPEEC6.__privateGet)(this, _prev)[index];
|
3078
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _next)[pi] = (0, import_chunk_OSFPEEC6.__privateGet)(this, _next)[index];
|
3079
|
-
const ni = (0, import_chunk_OSFPEEC6.__privateGet)(this, _next)[index];
|
3080
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _prev)[ni] = (0, import_chunk_OSFPEEC6.__privateGet)(this, _prev)[index];
|
3081
|
+
if (this.#hasDisposeAfter) {
|
3082
|
+
this.#disposed?.push([v, k, reason]);
|
3081
3083
|
}
|
3082
|
-
(0, import_chunk_OSFPEEC6.__privateWrapper)(this, _size)._--;
|
3083
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _free).push(index);
|
3084
3084
|
}
|
3085
3085
|
}
|
3086
|
-
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
3086
|
+
this.#keyMap.clear();
|
3087
|
+
this.#valList.fill(void 0);
|
3088
|
+
this.#keyList.fill(void 0);
|
3089
|
+
if (this.#ttls && this.#starts) {
|
3090
|
+
this.#ttls.fill(0);
|
3091
|
+
this.#starts.fill(0);
|
3092
3092
|
}
|
3093
|
-
|
3094
|
-
|
3095
|
-
};
|
3096
|
-
clear_fn = function(reason) {
|
3097
|
-
var _a3, _b3;
|
3098
|
-
for (const index of (0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, rindexes_fn).call(this, { allowStale: true })) {
|
3099
|
-
const v = (0, import_chunk_OSFPEEC6.__privateGet)(this, _valList)[index];
|
3100
|
-
if ((0, import_chunk_OSFPEEC6.__privateMethod)(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v)) {
|
3101
|
-
v.__abortController.abort(new Error("deleted"));
|
3102
|
-
} else {
|
3103
|
-
const k = (0, import_chunk_OSFPEEC6.__privateGet)(this, _keyList)[index];
|
3104
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _hasDispose)) {
|
3105
|
-
(_a3 = (0, import_chunk_OSFPEEC6.__privateGet)(this, _dispose)) == null ? void 0 : _a3.call(this, v, k, reason);
|
3106
|
-
}
|
3107
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _hasDisposeAfter)) {
|
3108
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _disposed)?.push([v, k, reason]);
|
3109
|
-
}
|
3093
|
+
if (this.#sizes) {
|
3094
|
+
this.#sizes.fill(0);
|
3110
3095
|
}
|
3111
|
-
|
3112
|
-
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
|
3121
|
-
|
3122
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _head, 0);
|
3123
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _tail, 0);
|
3124
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _free).length = 0;
|
3125
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _calculatedSize, 0);
|
3126
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _size, 0);
|
3127
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _hasDisposeAfter) && (0, import_chunk_OSFPEEC6.__privateGet)(this, _disposed)) {
|
3128
|
-
const dt = (0, import_chunk_OSFPEEC6.__privateGet)(this, _disposed);
|
3129
|
-
let task;
|
3130
|
-
while (task = dt?.shift()) {
|
3131
|
-
(_b3 = (0, import_chunk_OSFPEEC6.__privateGet)(this, _disposeAfter)) == null ? void 0 : _b3.call(this, ...task);
|
3096
|
+
this.#head = 0;
|
3097
|
+
this.#tail = 0;
|
3098
|
+
this.#free.length = 0;
|
3099
|
+
this.#calculatedSize = 0;
|
3100
|
+
this.#size = 0;
|
3101
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
3102
|
+
const dt = this.#disposed;
|
3103
|
+
let task;
|
3104
|
+
while (task = dt?.shift()) {
|
3105
|
+
this.#disposeAfter?.(...task);
|
3106
|
+
}
|
3132
3107
|
}
|
3133
3108
|
}
|
3134
3109
|
};
|
3135
|
-
var LRUCache = _LRUCache;
|
3136
3110
|
var proc = typeof process === "object" && process ? process : {
|
3137
3111
|
stdout: null,
|
3138
3112
|
stderr: null
|
@@ -3178,11 +3152,11 @@ var isEndish = (ev) => ev === "end" || ev === "finish" || ev === "prefinish";
|
|
3178
3152
|
var isArrayBufferLike = (b) => b instanceof ArrayBuffer || !!b && typeof b === "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0;
|
3179
3153
|
var isArrayBufferView = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b);
|
3180
3154
|
var Pipe = class {
|
3155
|
+
src;
|
3156
|
+
dest;
|
3157
|
+
opts;
|
3158
|
+
ondrain;
|
3181
3159
|
constructor(src, dest, opts) {
|
3182
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "src");
|
3183
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "dest");
|
3184
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "opts");
|
3185
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "ondrain");
|
3186
3160
|
this.src = src;
|
3187
3161
|
this.dest = dest;
|
3188
3162
|
this.opts = opts;
|
@@ -3216,8 +3190,34 @@ var PipeProxyErrors = class extends Pipe {
|
|
3216
3190
|
};
|
3217
3191
|
var isObjectModeOptions = (o) => !!o.objectMode;
|
3218
3192
|
var isEncodingOptions = (o) => !o.objectMode && !!o.encoding && o.encoding !== "buffer";
|
3219
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
3220
3193
|
var Minipass = class extends import_node_events.EventEmitter {
|
3194
|
+
[FLOWING] = false;
|
3195
|
+
[PAUSED] = false;
|
3196
|
+
[PIPES] = [];
|
3197
|
+
[BUFFER] = [];
|
3198
|
+
[OBJECTMODE];
|
3199
|
+
[ENCODING];
|
3200
|
+
[ASYNC];
|
3201
|
+
[DECODER];
|
3202
|
+
[EOF] = false;
|
3203
|
+
[EMITTED_END] = false;
|
3204
|
+
[EMITTING_END] = false;
|
3205
|
+
[CLOSED] = false;
|
3206
|
+
[EMITTED_ERROR] = null;
|
3207
|
+
[BUFFERLENGTH] = 0;
|
3208
|
+
[DESTROYED] = false;
|
3209
|
+
[SIGNAL];
|
3210
|
+
[ABORTED] = false;
|
3211
|
+
[DATALISTENERS] = 0;
|
3212
|
+
[DISCARDED] = false;
|
3213
|
+
/**
|
3214
|
+
* true if the stream can be written
|
3215
|
+
*/
|
3216
|
+
writable = true;
|
3217
|
+
/**
|
3218
|
+
* true if the stream can be read
|
3219
|
+
*/
|
3220
|
+
readable = true;
|
3221
3221
|
/**
|
3222
3222
|
* If `RType` is Buffer, then options do not need to be provided.
|
3223
3223
|
* Otherwise, an options object must be provided to specify either
|
@@ -3227,27 +3227,6 @@ var Minipass = class extends import_node_events.EventEmitter {
|
|
3227
3227
|
constructor(...args) {
|
3228
3228
|
const options = args[0] || {};
|
3229
3229
|
super();
|
3230
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _s, false);
|
3231
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _r, false);
|
3232
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _q, []);
|
3233
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _p, []);
|
3234
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _o);
|
3235
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _n);
|
3236
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _m);
|
3237
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _l);
|
3238
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _k, false);
|
3239
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _j, false);
|
3240
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _i, false);
|
3241
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _h, false);
|
3242
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _g, null);
|
3243
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _f, 0);
|
3244
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _e, false);
|
3245
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _d);
|
3246
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _c, false);
|
3247
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _b2, 0);
|
3248
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, _a2, false);
|
3249
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "writable", true);
|
3250
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "readable", true);
|
3251
3230
|
if (options.objectMode && typeof options.encoding === "string") {
|
3252
3231
|
throw new TypeError("Encoding and objectMode may not be used together");
|
3253
3232
|
}
|
@@ -3338,7 +3317,7 @@ var Minipass = class extends import_node_events.EventEmitter {
|
|
3338
3317
|
this[ASYNC] = this[ASYNC] || !!a;
|
3339
3318
|
}
|
3340
3319
|
// drop everything and get out of the flow completely
|
3341
|
-
[
|
3320
|
+
[ABORT]() {
|
3342
3321
|
this[ABORTED] = true;
|
3343
3322
|
this.emit("abort", this[SIGNAL]?.reason);
|
3344
3323
|
this.destroy(this[SIGNAL]?.reason);
|
@@ -4078,125 +4057,130 @@ var ChildrenCache = class extends LRUCache {
|
|
4078
4057
|
}
|
4079
4058
|
};
|
4080
4059
|
var setAsCwd = Symbol("PathScurry setAsCwd");
|
4081
|
-
var _fs, _dev, _mode, _nlink, _uid, _gid, _rdev, _blksize, _ino, _size2, _blocks, _atimeMs, _mtimeMs, _ctimeMs, _birthtimeMs, _atime, _mtime, _ctime, _birthtime, _matchName, _depth, _fullpath, _fullpathPosix, _relative, _relativePosix, _type, _children, _linkTarget, _realpath, _PathBase_instances, resolveParts_fn, readdirSuccess_fn, markENOENT_fn, markChildrenENOENT_fn, markENOREALPATH_fn, markENOTDIR_fn, readdirFail_fn, lstatFail_fn, readlinkFail_fn, readdirAddChild_fn, readdirAddNewChild_fn, readdirMaybePromoteChild_fn, readdirPromoteChild_fn, applyStat_fn, _onReaddirCB, _readdirCBInFlight, callOnReaddirCB_fn, _asyncReaddirInFlight;
|
4082
4060
|
var PathBase = class {
|
4083
4061
|
/**
|
4084
|
-
*
|
4085
|
-
*
|
4062
|
+
* the basename of this path
|
4063
|
+
*
|
4064
|
+
* **Important**: *always* test the path name against any test string
|
4065
|
+
* usingthe {@link isNamed} method, and not by directly comparing this
|
4066
|
+
* string. Otherwise, unicode path strings that the system sees as identical
|
4067
|
+
* will not be properly treated as the same path, leading to incorrect
|
4068
|
+
* behavior and possible security issues.
|
4069
|
+
*/
|
4070
|
+
name;
|
4071
|
+
/**
|
4072
|
+
* the Path entry corresponding to the path root.
|
4086
4073
|
*
|
4087
4074
|
* @internal
|
4088
4075
|
*/
|
4089
|
-
|
4090
|
-
|
4091
|
-
|
4092
|
-
|
4093
|
-
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
4100
|
-
|
4101
|
-
|
4102
|
-
|
4103
|
-
|
4104
|
-
|
4105
|
-
|
4106
|
-
|
4107
|
-
|
4108
|
-
|
4109
|
-
|
4110
|
-
|
4111
|
-
|
4112
|
-
|
4113
|
-
|
4114
|
-
|
4115
|
-
|
4116
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _matchName);
|
4117
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _depth);
|
4118
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _fullpath);
|
4119
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _fullpathPosix);
|
4120
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _relative);
|
4121
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _relativePosix);
|
4122
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _type);
|
4123
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _children);
|
4124
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _linkTarget);
|
4125
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _realpath);
|
4126
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _onReaddirCB, []);
|
4127
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _readdirCBInFlight, false);
|
4128
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _asyncReaddirInFlight);
|
4129
|
-
this.name = name;
|
4130
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _matchName, nocase ? normalizeNocase(name) : normalize(name));
|
4131
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _type, type & TYPEMASK);
|
4132
|
-
this.nocase = nocase;
|
4133
|
-
this.roots = roots;
|
4134
|
-
this.root = root || this;
|
4135
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _children, children);
|
4136
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _fullpath, opts.fullpath);
|
4137
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _relative, opts.relative);
|
4138
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _relativePosix, opts.relativePosix);
|
4139
|
-
this.parent = opts.parent;
|
4140
|
-
if (this.parent) {
|
4141
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _fs, (0, import_chunk_OSFPEEC6.__privateGet)(this.parent, _fs));
|
4142
|
-
} else {
|
4143
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _fs, fsFromOption(opts.fs));
|
4144
|
-
}
|
4145
|
-
}
|
4076
|
+
root;
|
4077
|
+
/**
|
4078
|
+
* All roots found within the current PathScurry family
|
4079
|
+
*
|
4080
|
+
* @internal
|
4081
|
+
*/
|
4082
|
+
roots;
|
4083
|
+
/**
|
4084
|
+
* a reference to the parent path, or undefined in the case of root entries
|
4085
|
+
*
|
4086
|
+
* @internal
|
4087
|
+
*/
|
4088
|
+
parent;
|
4089
|
+
/**
|
4090
|
+
* boolean indicating whether paths are compared case-insensitively
|
4091
|
+
* @internal
|
4092
|
+
*/
|
4093
|
+
nocase;
|
4094
|
+
/**
|
4095
|
+
* boolean indicating that this path is the current working directory
|
4096
|
+
* of the PathScurry collection that contains it.
|
4097
|
+
*/
|
4098
|
+
isCWD = false;
|
4099
|
+
// potential default fs override
|
4100
|
+
#fs;
|
4101
|
+
// Stats fields
|
4102
|
+
#dev;
|
4146
4103
|
get dev() {
|
4147
|
-
return
|
4104
|
+
return this.#dev;
|
4148
4105
|
}
|
4106
|
+
#mode;
|
4149
4107
|
get mode() {
|
4150
|
-
return
|
4108
|
+
return this.#mode;
|
4151
4109
|
}
|
4110
|
+
#nlink;
|
4152
4111
|
get nlink() {
|
4153
|
-
return
|
4112
|
+
return this.#nlink;
|
4154
4113
|
}
|
4114
|
+
#uid;
|
4155
4115
|
get uid() {
|
4156
|
-
return
|
4116
|
+
return this.#uid;
|
4157
4117
|
}
|
4118
|
+
#gid;
|
4158
4119
|
get gid() {
|
4159
|
-
return
|
4120
|
+
return this.#gid;
|
4160
4121
|
}
|
4122
|
+
#rdev;
|
4161
4123
|
get rdev() {
|
4162
|
-
return
|
4124
|
+
return this.#rdev;
|
4163
4125
|
}
|
4126
|
+
#blksize;
|
4164
4127
|
get blksize() {
|
4165
|
-
return
|
4128
|
+
return this.#blksize;
|
4166
4129
|
}
|
4130
|
+
#ino;
|
4167
4131
|
get ino() {
|
4168
|
-
return
|
4132
|
+
return this.#ino;
|
4169
4133
|
}
|
4134
|
+
#size;
|
4170
4135
|
get size() {
|
4171
|
-
return
|
4136
|
+
return this.#size;
|
4172
4137
|
}
|
4138
|
+
#blocks;
|
4173
4139
|
get blocks() {
|
4174
|
-
return
|
4140
|
+
return this.#blocks;
|
4175
4141
|
}
|
4142
|
+
#atimeMs;
|
4176
4143
|
get atimeMs() {
|
4177
|
-
return
|
4144
|
+
return this.#atimeMs;
|
4178
4145
|
}
|
4146
|
+
#mtimeMs;
|
4179
4147
|
get mtimeMs() {
|
4180
|
-
return
|
4148
|
+
return this.#mtimeMs;
|
4181
4149
|
}
|
4150
|
+
#ctimeMs;
|
4182
4151
|
get ctimeMs() {
|
4183
|
-
return
|
4152
|
+
return this.#ctimeMs;
|
4184
4153
|
}
|
4154
|
+
#birthtimeMs;
|
4185
4155
|
get birthtimeMs() {
|
4186
|
-
return
|
4156
|
+
return this.#birthtimeMs;
|
4187
4157
|
}
|
4158
|
+
#atime;
|
4188
4159
|
get atime() {
|
4189
|
-
return
|
4160
|
+
return this.#atime;
|
4190
4161
|
}
|
4162
|
+
#mtime;
|
4191
4163
|
get mtime() {
|
4192
|
-
return
|
4164
|
+
return this.#mtime;
|
4193
4165
|
}
|
4166
|
+
#ctime;
|
4194
4167
|
get ctime() {
|
4195
|
-
return
|
4168
|
+
return this.#ctime;
|
4196
4169
|
}
|
4170
|
+
#birthtime;
|
4197
4171
|
get birthtime() {
|
4198
|
-
return
|
4199
|
-
}
|
4172
|
+
return this.#birthtime;
|
4173
|
+
}
|
4174
|
+
#matchName;
|
4175
|
+
#depth;
|
4176
|
+
#fullpath;
|
4177
|
+
#fullpathPosix;
|
4178
|
+
#relative;
|
4179
|
+
#relativePosix;
|
4180
|
+
#type;
|
4181
|
+
#children;
|
4182
|
+
#linkTarget;
|
4183
|
+
#realpath;
|
4200
4184
|
/**
|
4201
4185
|
* This property is for compatibility with the Dirent class as of
|
4202
4186
|
* Node v20, where Dirent['parentPath'] refers to the path of the
|
@@ -4215,38 +4199,68 @@ var PathBase = class {
|
|
4215
4199
|
get path() {
|
4216
4200
|
return this.parentPath;
|
4217
4201
|
}
|
4202
|
+
/**
|
4203
|
+
* Do not create new Path objects directly. They should always be accessed
|
4204
|
+
* via the PathScurry class or other methods on the Path class.
|
4205
|
+
*
|
4206
|
+
* @internal
|
4207
|
+
*/
|
4208
|
+
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
4209
|
+
this.name = name;
|
4210
|
+
this.#matchName = nocase ? normalizeNocase(name) : normalize(name);
|
4211
|
+
this.#type = type & TYPEMASK;
|
4212
|
+
this.nocase = nocase;
|
4213
|
+
this.roots = roots;
|
4214
|
+
this.root = root || this;
|
4215
|
+
this.#children = children;
|
4216
|
+
this.#fullpath = opts.fullpath;
|
4217
|
+
this.#relative = opts.relative;
|
4218
|
+
this.#relativePosix = opts.relativePosix;
|
4219
|
+
this.parent = opts.parent;
|
4220
|
+
if (this.parent) {
|
4221
|
+
this.#fs = this.parent.#fs;
|
4222
|
+
} else {
|
4223
|
+
this.#fs = fsFromOption(opts.fs);
|
4224
|
+
}
|
4225
|
+
}
|
4218
4226
|
/**
|
4219
4227
|
* Returns the depth of the Path object from its root.
|
4220
4228
|
*
|
4221
4229
|
* For example, a path at `/foo/bar` would have a depth of 2.
|
4222
4230
|
*/
|
4223
4231
|
depth() {
|
4224
|
-
if (
|
4225
|
-
return
|
4232
|
+
if (this.#depth !== void 0)
|
4233
|
+
return this.#depth;
|
4226
4234
|
if (!this.parent)
|
4227
|
-
return
|
4228
|
-
return
|
4235
|
+
return this.#depth = 0;
|
4236
|
+
return this.#depth = this.parent.depth() + 1;
|
4229
4237
|
}
|
4230
4238
|
/**
|
4231
4239
|
* @internal
|
4232
4240
|
*/
|
4233
4241
|
childrenCache() {
|
4234
|
-
return
|
4242
|
+
return this.#children;
|
4235
4243
|
}
|
4236
4244
|
/**
|
4237
4245
|
* Get the Path object referenced by the string path, resolved from this Path
|
4238
4246
|
*/
|
4239
4247
|
resolve(path2) {
|
4240
|
-
var _a3;
|
4241
4248
|
if (!path2) {
|
4242
4249
|
return this;
|
4243
4250
|
}
|
4244
4251
|
const rootPath = this.getRootString(path2);
|
4245
4252
|
const dir = path2.substring(rootPath.length);
|
4246
4253
|
const dirParts = dir.split(this.splitSep);
|
4247
|
-
const result = rootPath ?
|
4254
|
+
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
4248
4255
|
return result;
|
4249
4256
|
}
|
4257
|
+
#resolveParts(dirParts) {
|
4258
|
+
let p = this;
|
4259
|
+
for (const part of dirParts) {
|
4260
|
+
p = p.child(part);
|
4261
|
+
}
|
4262
|
+
return p;
|
4263
|
+
}
|
4250
4264
|
/**
|
4251
4265
|
* Returns the cached children Path objects, if still available. If they
|
4252
4266
|
* have fallen out of the cache, then returns an empty array, and resets the
|
@@ -4256,13 +4270,13 @@ var PathBase = class {
|
|
4256
4270
|
* @internal
|
4257
4271
|
*/
|
4258
4272
|
children() {
|
4259
|
-
const cached =
|
4273
|
+
const cached = this.#children.get(this);
|
4260
4274
|
if (cached) {
|
4261
4275
|
return cached;
|
4262
4276
|
}
|
4263
4277
|
const children = Object.assign([], { provisional: 0 });
|
4264
|
-
|
4265
|
-
|
4278
|
+
this.#children.set(this, children);
|
4279
|
+
this.#type &= ~READDIR_CALLED;
|
4266
4280
|
return children;
|
4267
4281
|
}
|
4268
4282
|
/**
|
@@ -4288,19 +4302,19 @@ var PathBase = class {
|
|
4288
4302
|
const children = this.children();
|
4289
4303
|
const name = this.nocase ? normalizeNocase(pathPart) : normalize(pathPart);
|
4290
4304
|
for (const p of children) {
|
4291
|
-
if (
|
4305
|
+
if (p.#matchName === name) {
|
4292
4306
|
return p;
|
4293
4307
|
}
|
4294
4308
|
}
|
4295
4309
|
const s = this.parent ? this.sep : "";
|
4296
|
-
const fullpath =
|
4310
|
+
const fullpath = this.#fullpath ? this.#fullpath + s + pathPart : void 0;
|
4297
4311
|
const pchild = this.newChild(pathPart, UNKNOWN, {
|
4298
4312
|
...opts,
|
4299
4313
|
parent: this,
|
4300
4314
|
fullpath
|
4301
4315
|
});
|
4302
4316
|
if (!this.canReaddir()) {
|
4303
|
-
|
4317
|
+
pchild.#type |= ENOENT;
|
4304
4318
|
}
|
4305
4319
|
children.push(pchild);
|
4306
4320
|
return pchild;
|
@@ -4312,13 +4326,13 @@ var PathBase = class {
|
|
4312
4326
|
relative() {
|
4313
4327
|
if (this.isCWD)
|
4314
4328
|
return "";
|
4315
|
-
if (
|
4316
|
-
return
|
4329
|
+
if (this.#relative !== void 0) {
|
4330
|
+
return this.#relative;
|
4317
4331
|
}
|
4318
4332
|
const name = this.name;
|
4319
4333
|
const p = this.parent;
|
4320
4334
|
if (!p) {
|
4321
|
-
return
|
4335
|
+
return this.#relative = this.name;
|
4322
4336
|
}
|
4323
4337
|
const pv = p.relative();
|
4324
4338
|
return pv + (!pv || !p.parent ? "" : this.sep) + name;
|
@@ -4334,12 +4348,12 @@ var PathBase = class {
|
|
4334
4348
|
return this.relative();
|
4335
4349
|
if (this.isCWD)
|
4336
4350
|
return "";
|
4337
|
-
if (
|
4338
|
-
return
|
4351
|
+
if (this.#relativePosix !== void 0)
|
4352
|
+
return this.#relativePosix;
|
4339
4353
|
const name = this.name;
|
4340
4354
|
const p = this.parent;
|
4341
4355
|
if (!p) {
|
4342
|
-
return
|
4356
|
+
return this.#relativePosix = this.fullpathPosix();
|
4343
4357
|
}
|
4344
4358
|
const pv = p.relativePosix();
|
4345
4359
|
return pv + (!pv || !p.parent ? "" : "/") + name;
|
@@ -4348,17 +4362,17 @@ var PathBase = class {
|
|
4348
4362
|
* The fully resolved path string for this Path entry
|
4349
4363
|
*/
|
4350
4364
|
fullpath() {
|
4351
|
-
if (
|
4352
|
-
return
|
4365
|
+
if (this.#fullpath !== void 0) {
|
4366
|
+
return this.#fullpath;
|
4353
4367
|
}
|
4354
4368
|
const name = this.name;
|
4355
4369
|
const p = this.parent;
|
4356
4370
|
if (!p) {
|
4357
|
-
return
|
4371
|
+
return this.#fullpath = this.name;
|
4358
4372
|
}
|
4359
4373
|
const pv = p.fullpath();
|
4360
4374
|
const fp = pv + (!p.parent ? "" : this.sep) + name;
|
4361
|
-
return
|
4375
|
+
return this.#fullpath = fp;
|
4362
4376
|
}
|
4363
4377
|
/**
|
4364
4378
|
* On platforms other than windows, this is identical to fullpath.
|
@@ -4367,22 +4381,22 @@ var PathBase = class {
|
|
4367
4381
|
* full UNC path.
|
4368
4382
|
*/
|
4369
4383
|
fullpathPosix() {
|
4370
|
-
if (
|
4371
|
-
return
|
4384
|
+
if (this.#fullpathPosix !== void 0)
|
4385
|
+
return this.#fullpathPosix;
|
4372
4386
|
if (this.sep === "/")
|
4373
|
-
return
|
4387
|
+
return this.#fullpathPosix = this.fullpath();
|
4374
4388
|
if (!this.parent) {
|
4375
4389
|
const p2 = this.fullpath().replace(/\\/g, "/");
|
4376
4390
|
if (/^[a-z]:\//i.test(p2)) {
|
4377
|
-
return
|
4391
|
+
return this.#fullpathPosix = `//?/${p2}`;
|
4378
4392
|
} else {
|
4379
|
-
return
|
4393
|
+
return this.#fullpathPosix = p2;
|
4380
4394
|
}
|
4381
4395
|
}
|
4382
4396
|
const p = this.parent;
|
4383
4397
|
const pfpp = p.fullpathPosix();
|
4384
4398
|
const fpp = pfpp + (!pfpp || !p.parent ? "" : "/") + this.name;
|
4385
|
-
return
|
4399
|
+
return this.#fullpathPosix = fpp;
|
4386
4400
|
}
|
4387
4401
|
/**
|
4388
4402
|
* Is the Path of an unknown type?
|
@@ -4392,7 +4406,7 @@ var PathBase = class {
|
|
4392
4406
|
* link, or whether it has child entries.
|
4393
4407
|
*/
|
4394
4408
|
isUnknown() {
|
4395
|
-
return (
|
4409
|
+
return (this.#type & IFMT) === UNKNOWN;
|
4396
4410
|
}
|
4397
4411
|
isType(type) {
|
4398
4412
|
return this[`is${type}`]();
|
@@ -4407,43 +4421,43 @@ var PathBase = class {
|
|
4407
4421
|
* Is the Path a regular file?
|
4408
4422
|
*/
|
4409
4423
|
isFile() {
|
4410
|
-
return (
|
4424
|
+
return (this.#type & IFMT) === IFREG;
|
4411
4425
|
}
|
4412
4426
|
/**
|
4413
4427
|
* Is the Path a directory?
|
4414
4428
|
*/
|
4415
4429
|
isDirectory() {
|
4416
|
-
return (
|
4430
|
+
return (this.#type & IFMT) === IFDIR;
|
4417
4431
|
}
|
4418
4432
|
/**
|
4419
4433
|
* Is the path a character device?
|
4420
4434
|
*/
|
4421
4435
|
isCharacterDevice() {
|
4422
|
-
return (
|
4436
|
+
return (this.#type & IFMT) === IFCHR;
|
4423
4437
|
}
|
4424
4438
|
/**
|
4425
4439
|
* Is the path a block device?
|
4426
4440
|
*/
|
4427
4441
|
isBlockDevice() {
|
4428
|
-
return (
|
4442
|
+
return (this.#type & IFMT) === IFBLK;
|
4429
4443
|
}
|
4430
4444
|
/**
|
4431
4445
|
* Is the path a FIFO pipe?
|
4432
4446
|
*/
|
4433
4447
|
isFIFO() {
|
4434
|
-
return (
|
4448
|
+
return (this.#type & IFMT) === IFIFO;
|
4435
4449
|
}
|
4436
4450
|
/**
|
4437
4451
|
* Is the path a socket?
|
4438
4452
|
*/
|
4439
4453
|
isSocket() {
|
4440
|
-
return (
|
4454
|
+
return (this.#type & IFMT) === IFSOCK;
|
4441
4455
|
}
|
4442
4456
|
/**
|
4443
4457
|
* Is the path a symbolic link?
|
4444
4458
|
*/
|
4445
4459
|
isSymbolicLink() {
|
4446
|
-
return (
|
4460
|
+
return (this.#type & IFLNK) === IFLNK;
|
4447
4461
|
}
|
4448
4462
|
/**
|
4449
4463
|
* Return the entry if it has been subject of a successful lstat, or
|
@@ -4453,7 +4467,7 @@ var PathBase = class {
|
|
4453
4467
|
* mean that we haven't called lstat on it.
|
4454
4468
|
*/
|
4455
4469
|
lstatCached() {
|
4456
|
-
return
|
4470
|
+
return this.#type & LSTAT_CALLED ? this : void 0;
|
4457
4471
|
}
|
4458
4472
|
/**
|
4459
4473
|
* Return the cached link target if the entry has been the subject of a
|
@@ -4464,7 +4478,7 @@ var PathBase = class {
|
|
4464
4478
|
* readlink() has been called at some point.
|
4465
4479
|
*/
|
4466
4480
|
readlinkCached() {
|
4467
|
-
return
|
4481
|
+
return this.#linkTarget;
|
4468
4482
|
}
|
4469
4483
|
/**
|
4470
4484
|
* Returns the cached realpath target if the entry has been the subject
|
@@ -4475,7 +4489,7 @@ var PathBase = class {
|
|
4475
4489
|
* realpath() has been called at some point.
|
4476
4490
|
*/
|
4477
4491
|
realpathCached() {
|
4478
|
-
return
|
4492
|
+
return this.#realpath;
|
4479
4493
|
}
|
4480
4494
|
/**
|
4481
4495
|
* Returns the cached child Path entries array if the entry has been the
|
@@ -4497,19 +4511,19 @@ var PathBase = class {
|
|
4497
4511
|
* readlink failed, or if the entry does not exist.
|
4498
4512
|
*/
|
4499
4513
|
canReadlink() {
|
4500
|
-
if (
|
4514
|
+
if (this.#linkTarget)
|
4501
4515
|
return true;
|
4502
4516
|
if (!this.parent)
|
4503
4517
|
return false;
|
4504
|
-
const ifmt =
|
4505
|
-
return !(ifmt !== UNKNOWN && ifmt !== IFLNK ||
|
4518
|
+
const ifmt = this.#type & IFMT;
|
4519
|
+
return !(ifmt !== UNKNOWN && ifmt !== IFLNK || this.#type & ENOREADLINK || this.#type & ENOENT);
|
4506
4520
|
}
|
4507
4521
|
/**
|
4508
4522
|
* Return true if readdir has previously been successfully called on this
|
4509
4523
|
* path, indicating that cachedReaddir() is likely valid.
|
4510
4524
|
*/
|
4511
4525
|
calledReaddir() {
|
4512
|
-
return !!(
|
4526
|
+
return !!(this.#type & READDIR_CALLED);
|
4513
4527
|
}
|
4514
4528
|
/**
|
4515
4529
|
* Returns true if the path is known to not exist. That is, a previous lstat
|
@@ -4517,7 +4531,7 @@ var PathBase = class {
|
|
4517
4531
|
* expected, or a parent entry was marked either enoent or enotdir.
|
4518
4532
|
*/
|
4519
4533
|
isENOENT() {
|
4520
|
-
return !!(
|
4534
|
+
return !!(this.#type & ENOENT);
|
4521
4535
|
}
|
4522
4536
|
/**
|
4523
4537
|
* Return true if the path is a match for the given path name. This handles
|
@@ -4531,7 +4545,7 @@ var PathBase = class {
|
|
4531
4545
|
* directly.
|
4532
4546
|
*/
|
4533
4547
|
isNamed(n) {
|
4534
|
-
return !this.nocase ?
|
4548
|
+
return !this.nocase ? this.#matchName === normalize(n) : this.#matchName === normalizeNocase(n);
|
4535
4549
|
}
|
4536
4550
|
/**
|
4537
4551
|
* Return the Path object corresponding to the target of a symbolic link.
|
@@ -4542,7 +4556,7 @@ var PathBase = class {
|
|
4542
4556
|
* Result is cached, and thus may be outdated if the filesystem is mutated.
|
4543
4557
|
*/
|
4544
4558
|
async readlink() {
|
4545
|
-
const target =
|
4559
|
+
const target = this.#linkTarget;
|
4546
4560
|
if (target) {
|
4547
4561
|
return target;
|
4548
4562
|
}
|
@@ -4553,13 +4567,13 @@ var PathBase = class {
|
|
4553
4567
|
return void 0;
|
4554
4568
|
}
|
4555
4569
|
try {
|
4556
|
-
const read = await
|
4570
|
+
const read = await this.#fs.promises.readlink(this.fullpath());
|
4557
4571
|
const linkTarget = (await this.parent.realpath())?.resolve(read);
|
4558
4572
|
if (linkTarget) {
|
4559
|
-
return
|
4573
|
+
return this.#linkTarget = linkTarget;
|
4560
4574
|
}
|
4561
4575
|
} catch (er) {
|
4562
|
-
|
4576
|
+
this.#readlinkFail(er.code);
|
4563
4577
|
return void 0;
|
4564
4578
|
}
|
4565
4579
|
}
|
@@ -4567,7 +4581,7 @@ var PathBase = class {
|
|
4567
4581
|
* Synchronous {@link PathBase.readlink}
|
4568
4582
|
*/
|
4569
4583
|
readlinkSync() {
|
4570
|
-
const target =
|
4584
|
+
const target = this.#linkTarget;
|
4571
4585
|
if (target) {
|
4572
4586
|
return target;
|
4573
4587
|
}
|
@@ -4578,16 +4592,120 @@ var PathBase = class {
|
|
4578
4592
|
return void 0;
|
4579
4593
|
}
|
4580
4594
|
try {
|
4581
|
-
const read =
|
4595
|
+
const read = this.#fs.readlinkSync(this.fullpath());
|
4582
4596
|
const linkTarget = this.parent.realpathSync()?.resolve(read);
|
4583
4597
|
if (linkTarget) {
|
4584
|
-
return
|
4598
|
+
return this.#linkTarget = linkTarget;
|
4585
4599
|
}
|
4586
4600
|
} catch (er) {
|
4587
|
-
|
4601
|
+
this.#readlinkFail(er.code);
|
4588
4602
|
return void 0;
|
4589
4603
|
}
|
4590
4604
|
}
|
4605
|
+
#readdirSuccess(children) {
|
4606
|
+
this.#type |= READDIR_CALLED;
|
4607
|
+
for (let p = children.provisional; p < children.length; p++) {
|
4608
|
+
const c = children[p];
|
4609
|
+
if (c)
|
4610
|
+
c.#markENOENT();
|
4611
|
+
}
|
4612
|
+
}
|
4613
|
+
#markENOENT() {
|
4614
|
+
if (this.#type & ENOENT)
|
4615
|
+
return;
|
4616
|
+
this.#type = (this.#type | ENOENT) & IFMT_UNKNOWN;
|
4617
|
+
this.#markChildrenENOENT();
|
4618
|
+
}
|
4619
|
+
#markChildrenENOENT() {
|
4620
|
+
const children = this.children();
|
4621
|
+
children.provisional = 0;
|
4622
|
+
for (const p of children) {
|
4623
|
+
p.#markENOENT();
|
4624
|
+
}
|
4625
|
+
}
|
4626
|
+
#markENOREALPATH() {
|
4627
|
+
this.#type |= ENOREALPATH;
|
4628
|
+
this.#markENOTDIR();
|
4629
|
+
}
|
4630
|
+
// save the information when we know the entry is not a dir
|
4631
|
+
#markENOTDIR() {
|
4632
|
+
if (this.#type & ENOTDIR)
|
4633
|
+
return;
|
4634
|
+
let t = this.#type;
|
4635
|
+
if ((t & IFMT) === IFDIR)
|
4636
|
+
t &= IFMT_UNKNOWN;
|
4637
|
+
this.#type = t | ENOTDIR;
|
4638
|
+
this.#markChildrenENOENT();
|
4639
|
+
}
|
4640
|
+
#readdirFail(code = "") {
|
4641
|
+
if (code === "ENOTDIR" || code === "EPERM") {
|
4642
|
+
this.#markENOTDIR();
|
4643
|
+
} else if (code === "ENOENT") {
|
4644
|
+
this.#markENOENT();
|
4645
|
+
} else {
|
4646
|
+
this.children().provisional = 0;
|
4647
|
+
}
|
4648
|
+
}
|
4649
|
+
#lstatFail(code = "") {
|
4650
|
+
if (code === "ENOTDIR") {
|
4651
|
+
const p = this.parent;
|
4652
|
+
p.#markENOTDIR();
|
4653
|
+
} else if (code === "ENOENT") {
|
4654
|
+
this.#markENOENT();
|
4655
|
+
}
|
4656
|
+
}
|
4657
|
+
#readlinkFail(code = "") {
|
4658
|
+
let ter = this.#type;
|
4659
|
+
ter |= ENOREADLINK;
|
4660
|
+
if (code === "ENOENT")
|
4661
|
+
ter |= ENOENT;
|
4662
|
+
if (code === "EINVAL" || code === "UNKNOWN") {
|
4663
|
+
ter &= IFMT_UNKNOWN;
|
4664
|
+
}
|
4665
|
+
this.#type = ter;
|
4666
|
+
if (code === "ENOTDIR" && this.parent) {
|
4667
|
+
this.parent.#markENOTDIR();
|
4668
|
+
}
|
4669
|
+
}
|
4670
|
+
#readdirAddChild(e, c) {
|
4671
|
+
return this.#readdirMaybePromoteChild(e, c) || this.#readdirAddNewChild(e, c);
|
4672
|
+
}
|
4673
|
+
#readdirAddNewChild(e, c) {
|
4674
|
+
const type = entToType(e);
|
4675
|
+
const child = this.newChild(e.name, type, { parent: this });
|
4676
|
+
const ifmt = child.#type & IFMT;
|
4677
|
+
if (ifmt !== IFDIR && ifmt !== IFLNK && ifmt !== UNKNOWN) {
|
4678
|
+
child.#type |= ENOTDIR;
|
4679
|
+
}
|
4680
|
+
c.unshift(child);
|
4681
|
+
c.provisional++;
|
4682
|
+
return child;
|
4683
|
+
}
|
4684
|
+
#readdirMaybePromoteChild(e, c) {
|
4685
|
+
for (let p = c.provisional; p < c.length; p++) {
|
4686
|
+
const pchild = c[p];
|
4687
|
+
const name = this.nocase ? normalizeNocase(e.name) : normalize(e.name);
|
4688
|
+
if (name !== pchild.#matchName) {
|
4689
|
+
continue;
|
4690
|
+
}
|
4691
|
+
return this.#readdirPromoteChild(e, pchild, p, c);
|
4692
|
+
}
|
4693
|
+
}
|
4694
|
+
#readdirPromoteChild(e, p, index, c) {
|
4695
|
+
const v = p.name;
|
4696
|
+
p.#type = p.#type & IFMT_UNKNOWN | entToType(e);
|
4697
|
+
if (v !== e.name)
|
4698
|
+
p.name = e.name;
|
4699
|
+
if (index !== c.provisional) {
|
4700
|
+
if (index === c.length - 1)
|
4701
|
+
c.pop();
|
4702
|
+
else
|
4703
|
+
c.splice(index, 1);
|
4704
|
+
c.unshift(p);
|
4705
|
+
}
|
4706
|
+
c.provisional++;
|
4707
|
+
return p;
|
4708
|
+
}
|
4591
4709
|
/**
|
4592
4710
|
* Call lstat() on this Path, and update all known information that can be
|
4593
4711
|
* determined.
|
@@ -4604,12 +4722,12 @@ var PathBase = class {
|
|
4604
4722
|
* mutated.
|
4605
4723
|
*/
|
4606
4724
|
async lstat() {
|
4607
|
-
if ((
|
4725
|
+
if ((this.#type & ENOENT) === 0) {
|
4608
4726
|
try {
|
4609
|
-
|
4727
|
+
this.#applyStat(await this.#fs.promises.lstat(this.fullpath()));
|
4610
4728
|
return this;
|
4611
4729
|
} catch (er) {
|
4612
|
-
|
4730
|
+
this.#lstatFail(er.code);
|
4613
4731
|
}
|
4614
4732
|
}
|
4615
4733
|
}
|
@@ -4617,14 +4735,48 @@ var PathBase = class {
|
|
4617
4735
|
* synchronous {@link PathBase.lstat}
|
4618
4736
|
*/
|
4619
4737
|
lstatSync() {
|
4620
|
-
if ((
|
4738
|
+
if ((this.#type & ENOENT) === 0) {
|
4621
4739
|
try {
|
4622
|
-
|
4740
|
+
this.#applyStat(this.#fs.lstatSync(this.fullpath()));
|
4623
4741
|
return this;
|
4624
4742
|
} catch (er) {
|
4625
|
-
|
4626
|
-
}
|
4627
|
-
}
|
4743
|
+
this.#lstatFail(er.code);
|
4744
|
+
}
|
4745
|
+
}
|
4746
|
+
}
|
4747
|
+
#applyStat(st) {
|
4748
|
+
const { atime, atimeMs, birthtime, birthtimeMs, blksize, blocks, ctime, ctimeMs, dev, gid, ino, mode, mtime, mtimeMs, nlink, rdev, size, uid } = st;
|
4749
|
+
this.#atime = atime;
|
4750
|
+
this.#atimeMs = atimeMs;
|
4751
|
+
this.#birthtime = birthtime;
|
4752
|
+
this.#birthtimeMs = birthtimeMs;
|
4753
|
+
this.#blksize = blksize;
|
4754
|
+
this.#blocks = blocks;
|
4755
|
+
this.#ctime = ctime;
|
4756
|
+
this.#ctimeMs = ctimeMs;
|
4757
|
+
this.#dev = dev;
|
4758
|
+
this.#gid = gid;
|
4759
|
+
this.#ino = ino;
|
4760
|
+
this.#mode = mode;
|
4761
|
+
this.#mtime = mtime;
|
4762
|
+
this.#mtimeMs = mtimeMs;
|
4763
|
+
this.#nlink = nlink;
|
4764
|
+
this.#rdev = rdev;
|
4765
|
+
this.#size = size;
|
4766
|
+
this.#uid = uid;
|
4767
|
+
const ifmt = entToType(st);
|
4768
|
+
this.#type = this.#type & IFMT_UNKNOWN | ifmt | LSTAT_CALLED;
|
4769
|
+
if (ifmt !== UNKNOWN && ifmt !== IFDIR && ifmt !== IFLNK) {
|
4770
|
+
this.#type |= ENOTDIR;
|
4771
|
+
}
|
4772
|
+
}
|
4773
|
+
#onReaddirCB = [];
|
4774
|
+
#readdirCBInFlight = false;
|
4775
|
+
#callOnReaddirCB(children) {
|
4776
|
+
this.#readdirCBInFlight = false;
|
4777
|
+
const cbs = this.#onReaddirCB.slice();
|
4778
|
+
this.#onReaddirCB.length = 0;
|
4779
|
+
cbs.forEach((cb) => cb(null, children));
|
4628
4780
|
}
|
4629
4781
|
/**
|
4630
4782
|
* Standard node-style callback interface to get list of directory entries.
|
@@ -4659,26 +4811,27 @@ var PathBase = class {
|
|
4659
4811
|
queueMicrotask(() => cb(null, c));
|
4660
4812
|
return;
|
4661
4813
|
}
|
4662
|
-
|
4663
|
-
if (
|
4814
|
+
this.#onReaddirCB.push(cb);
|
4815
|
+
if (this.#readdirCBInFlight) {
|
4664
4816
|
return;
|
4665
4817
|
}
|
4666
|
-
|
4818
|
+
this.#readdirCBInFlight = true;
|
4667
4819
|
const fullpath = this.fullpath();
|
4668
|
-
|
4820
|
+
this.#fs.readdir(fullpath, { withFileTypes: true }, (er, entries) => {
|
4669
4821
|
if (er) {
|
4670
|
-
|
4822
|
+
this.#readdirFail(er.code);
|
4671
4823
|
children.provisional = 0;
|
4672
4824
|
} else {
|
4673
4825
|
for (const e of entries) {
|
4674
|
-
|
4826
|
+
this.#readdirAddChild(e, children);
|
4675
4827
|
}
|
4676
|
-
|
4828
|
+
this.#readdirSuccess(children);
|
4677
4829
|
}
|
4678
|
-
|
4830
|
+
this.#callOnReaddirCB(children.slice(0, children.provisional));
|
4679
4831
|
return;
|
4680
4832
|
});
|
4681
4833
|
}
|
4834
|
+
#asyncReaddirInFlight;
|
4682
4835
|
/**
|
4683
4836
|
* Return an array of known child entries.
|
4684
4837
|
*
|
@@ -4697,24 +4850,24 @@ var PathBase = class {
|
|
4697
4850
|
return children.slice(0, children.provisional);
|
4698
4851
|
}
|
4699
4852
|
const fullpath = this.fullpath();
|
4700
|
-
if (
|
4701
|
-
await
|
4853
|
+
if (this.#asyncReaddirInFlight) {
|
4854
|
+
await this.#asyncReaddirInFlight;
|
4702
4855
|
} else {
|
4703
4856
|
let resolve6 = () => {
|
4704
4857
|
};
|
4705
|
-
|
4858
|
+
this.#asyncReaddirInFlight = new Promise((res) => resolve6 = res);
|
4706
4859
|
try {
|
4707
|
-
for (const e of await
|
4860
|
+
for (const e of await this.#fs.promises.readdir(fullpath, {
|
4708
4861
|
withFileTypes: true
|
4709
4862
|
})) {
|
4710
|
-
|
4863
|
+
this.#readdirAddChild(e, children);
|
4711
4864
|
}
|
4712
|
-
|
4865
|
+
this.#readdirSuccess(children);
|
4713
4866
|
} catch (er) {
|
4714
|
-
|
4867
|
+
this.#readdirFail(er.code);
|
4715
4868
|
children.provisional = 0;
|
4716
4869
|
}
|
4717
|
-
|
4870
|
+
this.#asyncReaddirInFlight = void 0;
|
4718
4871
|
resolve6();
|
4719
4872
|
}
|
4720
4873
|
return children.slice(0, children.provisional);
|
@@ -4732,29 +4885,29 @@ var PathBase = class {
|
|
4732
4885
|
}
|
4733
4886
|
const fullpath = this.fullpath();
|
4734
4887
|
try {
|
4735
|
-
for (const e of
|
4888
|
+
for (const e of this.#fs.readdirSync(fullpath, {
|
4736
4889
|
withFileTypes: true
|
4737
4890
|
})) {
|
4738
|
-
|
4891
|
+
this.#readdirAddChild(e, children);
|
4739
4892
|
}
|
4740
|
-
|
4893
|
+
this.#readdirSuccess(children);
|
4741
4894
|
} catch (er) {
|
4742
|
-
|
4895
|
+
this.#readdirFail(er.code);
|
4743
4896
|
children.provisional = 0;
|
4744
4897
|
}
|
4745
4898
|
return children.slice(0, children.provisional);
|
4746
4899
|
}
|
4747
4900
|
canReaddir() {
|
4748
|
-
if (
|
4901
|
+
if (this.#type & ENOCHILD)
|
4749
4902
|
return false;
|
4750
|
-
const ifmt = IFMT &
|
4903
|
+
const ifmt = IFMT & this.#type;
|
4751
4904
|
if (!(ifmt === UNKNOWN || ifmt === IFDIR || ifmt === IFLNK)) {
|
4752
4905
|
return false;
|
4753
4906
|
}
|
4754
4907
|
return true;
|
4755
4908
|
}
|
4756
4909
|
shouldWalk(dirs, walkFilter) {
|
4757
|
-
return (
|
4910
|
+
return (this.#type & IFDIR) === IFDIR && !(this.#type & ENOCHILD) && !dirs.has(this) && (!walkFilter || walkFilter(this));
|
4758
4911
|
}
|
4759
4912
|
/**
|
4760
4913
|
* Return the Path object corresponding to path as resolved
|
@@ -4766,30 +4919,30 @@ var PathBase = class {
|
|
4766
4919
|
* On success, returns a Path object.
|
4767
4920
|
*/
|
4768
4921
|
async realpath() {
|
4769
|
-
if (
|
4770
|
-
return
|
4771
|
-
if ((ENOREALPATH | ENOREADLINK | ENOENT) &
|
4922
|
+
if (this.#realpath)
|
4923
|
+
return this.#realpath;
|
4924
|
+
if ((ENOREALPATH | ENOREADLINK | ENOENT) & this.#type)
|
4772
4925
|
return void 0;
|
4773
4926
|
try {
|
4774
|
-
const rp = await
|
4775
|
-
return
|
4927
|
+
const rp = await this.#fs.promises.realpath(this.fullpath());
|
4928
|
+
return this.#realpath = this.resolve(rp);
|
4776
4929
|
} catch (_) {
|
4777
|
-
|
4930
|
+
this.#markENOREALPATH();
|
4778
4931
|
}
|
4779
4932
|
}
|
4780
4933
|
/**
|
4781
4934
|
* Synchronous {@link realpath}
|
4782
4935
|
*/
|
4783
4936
|
realpathSync() {
|
4784
|
-
if (
|
4785
|
-
return
|
4786
|
-
if ((ENOREALPATH | ENOREADLINK | ENOENT) &
|
4937
|
+
if (this.#realpath)
|
4938
|
+
return this.#realpath;
|
4939
|
+
if ((ENOREALPATH | ENOREADLINK | ENOENT) & this.#type)
|
4787
4940
|
return void 0;
|
4788
4941
|
try {
|
4789
|
-
const rp =
|
4790
|
-
return
|
4942
|
+
const rp = this.#fs.realpathSync(this.fullpath());
|
4943
|
+
return this.#realpath = this.resolve(rp);
|
4791
4944
|
} catch (_) {
|
4792
|
-
|
4945
|
+
this.#markENOREALPATH();
|
4793
4946
|
}
|
4794
4947
|
}
|
4795
4948
|
/**
|
@@ -4808,199 +4961,28 @@ var PathBase = class {
|
|
4808
4961
|
let p = this;
|
4809
4962
|
while (p && p.parent) {
|
4810
4963
|
changed.add(p);
|
4811
|
-
|
4812
|
-
|
4964
|
+
p.#relative = rp.join(this.sep);
|
4965
|
+
p.#relativePosix = rp.join("/");
|
4813
4966
|
p = p.parent;
|
4814
4967
|
rp.push("..");
|
4815
4968
|
}
|
4816
4969
|
p = oldCwd;
|
4817
4970
|
while (p && p.parent && !changed.has(p)) {
|
4818
|
-
|
4819
|
-
|
4971
|
+
p.#relative = void 0;
|
4972
|
+
p.#relativePosix = void 0;
|
4820
4973
|
p = p.parent;
|
4821
4974
|
}
|
4822
4975
|
}
|
4823
4976
|
};
|
4824
|
-
_fs = /* @__PURE__ */ new WeakMap();
|
4825
|
-
_dev = /* @__PURE__ */ new WeakMap();
|
4826
|
-
_mode = /* @__PURE__ */ new WeakMap();
|
4827
|
-
_nlink = /* @__PURE__ */ new WeakMap();
|
4828
|
-
_uid = /* @__PURE__ */ new WeakMap();
|
4829
|
-
_gid = /* @__PURE__ */ new WeakMap();
|
4830
|
-
_rdev = /* @__PURE__ */ new WeakMap();
|
4831
|
-
_blksize = /* @__PURE__ */ new WeakMap();
|
4832
|
-
_ino = /* @__PURE__ */ new WeakMap();
|
4833
|
-
_size2 = /* @__PURE__ */ new WeakMap();
|
4834
|
-
_blocks = /* @__PURE__ */ new WeakMap();
|
4835
|
-
_atimeMs = /* @__PURE__ */ new WeakMap();
|
4836
|
-
_mtimeMs = /* @__PURE__ */ new WeakMap();
|
4837
|
-
_ctimeMs = /* @__PURE__ */ new WeakMap();
|
4838
|
-
_birthtimeMs = /* @__PURE__ */ new WeakMap();
|
4839
|
-
_atime = /* @__PURE__ */ new WeakMap();
|
4840
|
-
_mtime = /* @__PURE__ */ new WeakMap();
|
4841
|
-
_ctime = /* @__PURE__ */ new WeakMap();
|
4842
|
-
_birthtime = /* @__PURE__ */ new WeakMap();
|
4843
|
-
_matchName = /* @__PURE__ */ new WeakMap();
|
4844
|
-
_depth = /* @__PURE__ */ new WeakMap();
|
4845
|
-
_fullpath = /* @__PURE__ */ new WeakMap();
|
4846
|
-
_fullpathPosix = /* @__PURE__ */ new WeakMap();
|
4847
|
-
_relative = /* @__PURE__ */ new WeakMap();
|
4848
|
-
_relativePosix = /* @__PURE__ */ new WeakMap();
|
4849
|
-
_type = /* @__PURE__ */ new WeakMap();
|
4850
|
-
_children = /* @__PURE__ */ new WeakMap();
|
4851
|
-
_linkTarget = /* @__PURE__ */ new WeakMap();
|
4852
|
-
_realpath = /* @__PURE__ */ new WeakMap();
|
4853
|
-
_PathBase_instances = /* @__PURE__ */ new WeakSet();
|
4854
|
-
resolveParts_fn = function(dirParts) {
|
4855
|
-
let p = this;
|
4856
|
-
for (const part of dirParts) {
|
4857
|
-
p = p.child(part);
|
4858
|
-
}
|
4859
|
-
return p;
|
4860
|
-
};
|
4861
|
-
readdirSuccess_fn = function(children) {
|
4862
|
-
var _a3;
|
4863
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _type, (0, import_chunk_OSFPEEC6.__privateGet)(this, _type) | READDIR_CALLED);
|
4864
|
-
for (let p = children.provisional; p < children.length; p++) {
|
4865
|
-
const c = children[p];
|
4866
|
-
if (c)
|
4867
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(_a3 = c, _PathBase_instances, markENOENT_fn).call(_a3);
|
4868
|
-
}
|
4869
|
-
};
|
4870
|
-
markENOENT_fn = function() {
|
4871
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _type) & ENOENT)
|
4872
|
-
return;
|
4873
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _type, ((0, import_chunk_OSFPEEC6.__privateGet)(this, _type) | ENOENT) & IFMT_UNKNOWN);
|
4874
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(this, _PathBase_instances, markChildrenENOENT_fn).call(this);
|
4875
|
-
};
|
4876
|
-
markChildrenENOENT_fn = function() {
|
4877
|
-
var _a3;
|
4878
|
-
const children = this.children();
|
4879
|
-
children.provisional = 0;
|
4880
|
-
for (const p of children) {
|
4881
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(_a3 = p, _PathBase_instances, markENOENT_fn).call(_a3);
|
4882
|
-
}
|
4883
|
-
};
|
4884
|
-
markENOREALPATH_fn = function() {
|
4885
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _type, (0, import_chunk_OSFPEEC6.__privateGet)(this, _type) | ENOREALPATH);
|
4886
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(this, _PathBase_instances, markENOTDIR_fn).call(this);
|
4887
|
-
};
|
4888
|
-
markENOTDIR_fn = function() {
|
4889
|
-
if ((0, import_chunk_OSFPEEC6.__privateGet)(this, _type) & ENOTDIR)
|
4890
|
-
return;
|
4891
|
-
let t = (0, import_chunk_OSFPEEC6.__privateGet)(this, _type);
|
4892
|
-
if ((t & IFMT) === IFDIR)
|
4893
|
-
t &= IFMT_UNKNOWN;
|
4894
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _type, t | ENOTDIR);
|
4895
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(this, _PathBase_instances, markChildrenENOENT_fn).call(this);
|
4896
|
-
};
|
4897
|
-
readdirFail_fn = function(code = "") {
|
4898
|
-
if (code === "ENOTDIR" || code === "EPERM") {
|
4899
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(this, _PathBase_instances, markENOTDIR_fn).call(this);
|
4900
|
-
} else if (code === "ENOENT") {
|
4901
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(this, _PathBase_instances, markENOENT_fn).call(this);
|
4902
|
-
} else {
|
4903
|
-
this.children().provisional = 0;
|
4904
|
-
}
|
4905
|
-
};
|
4906
|
-
lstatFail_fn = function(code = "") {
|
4907
|
-
var _a3;
|
4908
|
-
if (code === "ENOTDIR") {
|
4909
|
-
const p = this.parent;
|
4910
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(_a3 = p, _PathBase_instances, markENOTDIR_fn).call(_a3);
|
4911
|
-
} else if (code === "ENOENT") {
|
4912
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(this, _PathBase_instances, markENOENT_fn).call(this);
|
4913
|
-
}
|
4914
|
-
};
|
4915
|
-
readlinkFail_fn = function(code = "") {
|
4916
|
-
var _a3;
|
4917
|
-
let ter = (0, import_chunk_OSFPEEC6.__privateGet)(this, _type);
|
4918
|
-
ter |= ENOREADLINK;
|
4919
|
-
if (code === "ENOENT")
|
4920
|
-
ter |= ENOENT;
|
4921
|
-
if (code === "EINVAL" || code === "UNKNOWN") {
|
4922
|
-
ter &= IFMT_UNKNOWN;
|
4923
|
-
}
|
4924
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _type, ter);
|
4925
|
-
if (code === "ENOTDIR" && this.parent) {
|
4926
|
-
(0, import_chunk_OSFPEEC6.__privateMethod)(_a3 = this.parent, _PathBase_instances, markENOTDIR_fn).call(_a3);
|
4927
|
-
}
|
4928
|
-
};
|
4929
|
-
readdirAddChild_fn = function(e, c) {
|
4930
|
-
return (0, import_chunk_OSFPEEC6.__privateMethod)(this, _PathBase_instances, readdirMaybePromoteChild_fn).call(this, e, c) || (0, import_chunk_OSFPEEC6.__privateMethod)(this, _PathBase_instances, readdirAddNewChild_fn).call(this, e, c);
|
4931
|
-
};
|
4932
|
-
readdirAddNewChild_fn = function(e, c) {
|
4933
|
-
const type = entToType(e);
|
4934
|
-
const child = this.newChild(e.name, type, { parent: this });
|
4935
|
-
const ifmt = (0, import_chunk_OSFPEEC6.__privateGet)(child, _type) & IFMT;
|
4936
|
-
if (ifmt !== IFDIR && ifmt !== IFLNK && ifmt !== UNKNOWN) {
|
4937
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(child, _type, (0, import_chunk_OSFPEEC6.__privateGet)(child, _type) | ENOTDIR);
|
4938
|
-
}
|
4939
|
-
c.unshift(child);
|
4940
|
-
c.provisional++;
|
4941
|
-
return child;
|
4942
|
-
};
|
4943
|
-
readdirMaybePromoteChild_fn = function(e, c) {
|
4944
|
-
for (let p = c.provisional; p < c.length; p++) {
|
4945
|
-
const pchild = c[p];
|
4946
|
-
const name = this.nocase ? normalizeNocase(e.name) : normalize(e.name);
|
4947
|
-
if (name !== (0, import_chunk_OSFPEEC6.__privateGet)(pchild, _matchName)) {
|
4948
|
-
continue;
|
4949
|
-
}
|
4950
|
-
return (0, import_chunk_OSFPEEC6.__privateMethod)(this, _PathBase_instances, readdirPromoteChild_fn).call(this, e, pchild, p, c);
|
4951
|
-
}
|
4952
|
-
};
|
4953
|
-
readdirPromoteChild_fn = function(e, p, index, c) {
|
4954
|
-
const v = p.name;
|
4955
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(p, _type, (0, import_chunk_OSFPEEC6.__privateGet)(p, _type) & IFMT_UNKNOWN | entToType(e));
|
4956
|
-
if (v !== e.name)
|
4957
|
-
p.name = e.name;
|
4958
|
-
if (index !== c.provisional) {
|
4959
|
-
if (index === c.length - 1)
|
4960
|
-
c.pop();
|
4961
|
-
else
|
4962
|
-
c.splice(index, 1);
|
4963
|
-
c.unshift(p);
|
4964
|
-
}
|
4965
|
-
c.provisional++;
|
4966
|
-
return p;
|
4967
|
-
};
|
4968
|
-
applyStat_fn = function(st) {
|
4969
|
-
const { atime, atimeMs, birthtime, birthtimeMs, blksize, blocks, ctime, ctimeMs, dev, gid, ino, mode, mtime, mtimeMs, nlink, rdev, size, uid } = st;
|
4970
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _atime, atime);
|
4971
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _atimeMs, atimeMs);
|
4972
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _birthtime, birthtime);
|
4973
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _birthtimeMs, birthtimeMs);
|
4974
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _blksize, blksize);
|
4975
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _blocks, blocks);
|
4976
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _ctime, ctime);
|
4977
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _ctimeMs, ctimeMs);
|
4978
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _dev, dev);
|
4979
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _gid, gid);
|
4980
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _ino, ino);
|
4981
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _mode, mode);
|
4982
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _mtime, mtime);
|
4983
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _mtimeMs, mtimeMs);
|
4984
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _nlink, nlink);
|
4985
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _rdev, rdev);
|
4986
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _size2, size);
|
4987
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _uid, uid);
|
4988
|
-
const ifmt = entToType(st);
|
4989
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _type, (0, import_chunk_OSFPEEC6.__privateGet)(this, _type) & IFMT_UNKNOWN | ifmt | LSTAT_CALLED);
|
4990
|
-
if (ifmt !== UNKNOWN && ifmt !== IFDIR && ifmt !== IFLNK) {
|
4991
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _type, (0, import_chunk_OSFPEEC6.__privateGet)(this, _type) | ENOTDIR);
|
4992
|
-
}
|
4993
|
-
};
|
4994
|
-
_onReaddirCB = /* @__PURE__ */ new WeakMap();
|
4995
|
-
_readdirCBInFlight = /* @__PURE__ */ new WeakMap();
|
4996
|
-
callOnReaddirCB_fn = function(children) {
|
4997
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _readdirCBInFlight, false);
|
4998
|
-
const cbs = (0, import_chunk_OSFPEEC6.__privateGet)(this, _onReaddirCB).slice();
|
4999
|
-
(0, import_chunk_OSFPEEC6.__privateGet)(this, _onReaddirCB).length = 0;
|
5000
|
-
cbs.forEach((cb) => cb(null, children));
|
5001
|
-
};
|
5002
|
-
_asyncReaddirInFlight = /* @__PURE__ */ new WeakMap();
|
5003
4977
|
var PathWin32 = class _PathWin32 extends PathBase {
|
4978
|
+
/**
|
4979
|
+
* Separator for generating path strings.
|
4980
|
+
*/
|
4981
|
+
sep = "\\";
|
4982
|
+
/**
|
4983
|
+
* Separator for parsing path strings.
|
4984
|
+
*/
|
4985
|
+
splitSep = eitherSep;
|
5004
4986
|
/**
|
5005
4987
|
* Do not create new Path objects directly. They should always be accessed
|
5006
4988
|
* via the PathScurry class or other methods on the Path class.
|
@@ -5009,8 +4991,6 @@ var PathWin32 = class _PathWin32 extends PathBase {
|
|
5009
4991
|
*/
|
5010
4992
|
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
5011
4993
|
super(name, type, root, roots, nocase, children, opts);
|
5012
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "sep", "\\");
|
5013
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "splitSep", eitherSep);
|
5014
4994
|
}
|
5015
4995
|
/**
|
5016
4996
|
* @internal
|
@@ -5048,6 +5028,14 @@ var PathWin32 = class _PathWin32 extends PathBase {
|
|
5048
5028
|
}
|
5049
5029
|
};
|
5050
5030
|
var PathPosix = class _PathPosix extends PathBase {
|
5031
|
+
/**
|
5032
|
+
* separator for parsing path strings
|
5033
|
+
*/
|
5034
|
+
splitSep = "/";
|
5035
|
+
/**
|
5036
|
+
* separator for generating path strings
|
5037
|
+
*/
|
5038
|
+
sep = "/";
|
5051
5039
|
/**
|
5052
5040
|
* Do not create new Path objects directly. They should always be accessed
|
5053
5041
|
* via the PathScurry class or other methods on the Path class.
|
@@ -5056,8 +5044,6 @@ var PathPosix = class _PathPosix extends PathBase {
|
|
5056
5044
|
*/
|
5057
5045
|
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
5058
5046
|
super(name, type, root, roots, nocase, children, opts);
|
5059
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "splitSep", "/");
|
5060
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "sep", "/");
|
5061
5047
|
}
|
5062
5048
|
/**
|
5063
5049
|
* @internal
|
@@ -5078,8 +5064,33 @@ var PathPosix = class _PathPosix extends PathBase {
|
|
5078
5064
|
return new _PathPosix(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
|
5079
5065
|
}
|
5080
5066
|
};
|
5081
|
-
var _resolveCache, _resolvePosixCache, _children2, _fs2;
|
5082
5067
|
var PathScurryBase = class {
|
5068
|
+
/**
|
5069
|
+
* The root Path entry for the current working directory of this Scurry
|
5070
|
+
*/
|
5071
|
+
root;
|
5072
|
+
/**
|
5073
|
+
* The string path for the root of this Scurry's current working directory
|
5074
|
+
*/
|
5075
|
+
rootPath;
|
5076
|
+
/**
|
5077
|
+
* A collection of all roots encountered, referenced by rootPath
|
5078
|
+
*/
|
5079
|
+
roots;
|
5080
|
+
/**
|
5081
|
+
* The Path entry corresponding to this PathScurry's current working directory.
|
5082
|
+
*/
|
5083
|
+
cwd;
|
5084
|
+
#resolveCache;
|
5085
|
+
#resolvePosixCache;
|
5086
|
+
#children;
|
5087
|
+
/**
|
5088
|
+
* Perform path comparisons case-insensitively.
|
5089
|
+
*
|
5090
|
+
* Defaults true on Darwin and Windows systems, false elsewhere.
|
5091
|
+
*/
|
5092
|
+
nocase;
|
5093
|
+
#fs;
|
5083
5094
|
/**
|
5084
5095
|
* This class should not be instantiated directly.
|
5085
5096
|
*
|
@@ -5088,25 +5099,16 @@ var PathScurryBase = class {
|
|
5088
5099
|
* @internal
|
5089
5100
|
*/
|
5090
5101
|
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs2 = defaultFS } = {}) {
|
5091
|
-
|
5092
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "rootPath");
|
5093
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "roots");
|
5094
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "cwd");
|
5095
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _resolveCache);
|
5096
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _resolvePosixCache);
|
5097
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _children2);
|
5098
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "nocase");
|
5099
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _fs2);
|
5100
|
-
(0, import_chunk_OSFPEEC6.__privateSet)(this, _fs2, fsFromOption(fs2));
|
5102
|
+
this.#fs = fsFromOption(fs2);
|
5101
5103
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
5102
5104
|
cwd = (0, import_node_url2.fileURLToPath)(cwd);
|
5103
5105
|
}
|
5104
5106
|
const cwdPath = pathImpl.resolve(cwd);
|
5105
5107
|
this.roots = /* @__PURE__ */ Object.create(null);
|
5106
5108
|
this.rootPath = this.parseRootPath(cwdPath);
|
5107
|
-
|
5108
|
-
|
5109
|
-
|
5109
|
+
this.#resolveCache = new ResolveCache();
|
5110
|
+
this.#resolvePosixCache = new ResolveCache();
|
5111
|
+
this.#children = new ChildrenCache(childrenCacheSize);
|
5110
5112
|
const split = cwdPath.substring(this.rootPath.length).split(sep2);
|
5111
5113
|
if (split.length === 1 && !split[0]) {
|
5112
5114
|
split.pop();
|
@@ -5115,7 +5117,7 @@ var PathScurryBase = class {
|
|
5115
5117
|
throw new TypeError("must provide nocase setting to PathScurryBase ctor");
|
5116
5118
|
}
|
5117
5119
|
this.nocase = nocase;
|
5118
|
-
this.root = this.newRoot(
|
5120
|
+
this.root = this.newRoot(this.#fs);
|
5119
5121
|
this.roots[this.rootPath] = this.root;
|
5120
5122
|
let prev = this.root;
|
5121
5123
|
let len = split.length - 1;
|
@@ -5149,7 +5151,7 @@ var PathScurryBase = class {
|
|
5149
5151
|
* @internal
|
5150
5152
|
*/
|
5151
5153
|
childrenCache() {
|
5152
|
-
return
|
5154
|
+
return this.#children;
|
5153
5155
|
}
|
5154
5156
|
/**
|
5155
5157
|
* Resolve one or more path strings to a resolved string
|
@@ -5171,12 +5173,12 @@ var PathScurryBase = class {
|
|
5171
5173
|
break;
|
5172
5174
|
}
|
5173
5175
|
}
|
5174
|
-
const cached =
|
5176
|
+
const cached = this.#resolveCache.get(r);
|
5175
5177
|
if (cached !== void 0) {
|
5176
5178
|
return cached;
|
5177
5179
|
}
|
5178
5180
|
const result = this.cwd.resolve(r).fullpath();
|
5179
|
-
|
5181
|
+
this.#resolveCache.set(r, result);
|
5180
5182
|
return result;
|
5181
5183
|
}
|
5182
5184
|
/**
|
@@ -5201,12 +5203,12 @@ var PathScurryBase = class {
|
|
5201
5203
|
break;
|
5202
5204
|
}
|
5203
5205
|
}
|
5204
|
-
const cached =
|
5206
|
+
const cached = this.#resolvePosixCache.get(r);
|
5205
5207
|
if (cached !== void 0) {
|
5206
5208
|
return cached;
|
5207
5209
|
}
|
5208
5210
|
const result = this.cwd.resolve(r).fullpathPosix();
|
5209
|
-
|
5211
|
+
this.#resolvePosixCache.set(r, result);
|
5210
5212
|
return result;
|
5211
5213
|
}
|
5212
5214
|
/**
|
@@ -5633,15 +5635,14 @@ var PathScurryBase = class {
|
|
5633
5635
|
this.cwd[setAsCwd](oldCwd);
|
5634
5636
|
}
|
5635
5637
|
};
|
5636
|
-
_resolveCache = /* @__PURE__ */ new WeakMap();
|
5637
|
-
_resolvePosixCache = /* @__PURE__ */ new WeakMap();
|
5638
|
-
_children2 = /* @__PURE__ */ new WeakMap();
|
5639
|
-
_fs2 = /* @__PURE__ */ new WeakMap();
|
5640
5638
|
var PathScurryWin32 = class extends PathScurryBase {
|
5639
|
+
/**
|
5640
|
+
* separator for generating path strings
|
5641
|
+
*/
|
5642
|
+
sep = "\\";
|
5641
5643
|
constructor(cwd = process.cwd(), opts = {}) {
|
5642
5644
|
const { nocase = true } = opts;
|
5643
5645
|
super(cwd, import_node_path.win32, "\\", { ...opts, nocase });
|
5644
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "sep", "\\");
|
5645
5646
|
this.nocase = nocase;
|
5646
5647
|
for (let p = this.cwd; p; p = p.parent) {
|
5647
5648
|
p.nocase = this.nocase;
|
@@ -5667,10 +5668,13 @@ var PathScurryWin32 = class extends PathScurryBase {
|
|
5667
5668
|
}
|
5668
5669
|
};
|
5669
5670
|
var PathScurryPosix = class extends PathScurryBase {
|
5671
|
+
/**
|
5672
|
+
* separator for generating path strings
|
5673
|
+
*/
|
5674
|
+
sep = "/";
|
5670
5675
|
constructor(cwd = process.cwd(), opts = {}) {
|
5671
5676
|
const { nocase = false } = opts;
|
5672
5677
|
super(cwd, import_node_path.posix, "/", { ...opts, nocase });
|
5673
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "sep", "/");
|
5674
5678
|
this.nocase = nocase;
|
5675
5679
|
}
|
5676
5680
|
/**
|
@@ -5702,20 +5706,19 @@ var Path = process.platform === "win32" ? PathWin32 : PathPosix;
|
|
5702
5706
|
var PathScurry = process.platform === "win32" ? PathScurryWin32 : process.platform === "darwin" ? PathScurryDarwin : PathScurryPosix;
|
5703
5707
|
var isPatternList = (pl) => pl.length >= 1;
|
5704
5708
|
var isGlobList = (gl) => gl.length >= 1;
|
5705
|
-
var
|
5706
|
-
|
5709
|
+
var Pattern = class _Pattern {
|
5710
|
+
#patternList;
|
5711
|
+
#globList;
|
5712
|
+
#index;
|
5713
|
+
length;
|
5714
|
+
#platform;
|
5715
|
+
#rest;
|
5716
|
+
#globString;
|
5717
|
+
#isDrive;
|
5718
|
+
#isUNC;
|
5719
|
+
#isAbsolute;
|
5720
|
+
#followGlobstar = true;
|
5707
5721
|
constructor(patternList, globList, index, platform) {
|
5708
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _patternList);
|
5709
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _globList);
|
5710
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _index);
|
5711
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "length");
|
5712
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _platform);
|
5713
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _rest);
|
5714
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _globString);
|
5715
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _isDrive);
|
5716
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _isUNC);
|
5717
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _isAbsolute);
|
5718
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _followGlobstar, true);
|
5719
5722
|
if (!isPatternList(patternList)) {
|
5720
5723
|
throw new TypeError("empty pattern list");
|
5721
5724
|
}
|
@@ -5729,35 +5732,35 @@ var _Pattern = class _Pattern2 {
|
|
5729
5732
|
if (index < 0 || index >= this.length) {
|
5730
5733
|
throw new TypeError("index out of range");
|
5731
5734
|
}
|
5732
|
-
|
5733
|
-
|
5734
|
-
|
5735
|
-
|
5736
|
-
if (
|
5735
|
+
this.#patternList = patternList;
|
5736
|
+
this.#globList = globList;
|
5737
|
+
this.#index = index;
|
5738
|
+
this.#platform = platform;
|
5739
|
+
if (this.#index === 0) {
|
5737
5740
|
if (this.isUNC()) {
|
5738
|
-
const [p0, p1, p2, p3, ...prest] =
|
5739
|
-
const [g0, g1, g2, g3, ...grest] =
|
5741
|
+
const [p0, p1, p2, p3, ...prest] = this.#patternList;
|
5742
|
+
const [g0, g1, g2, g3, ...grest] = this.#globList;
|
5740
5743
|
if (prest[0] === "") {
|
5741
5744
|
prest.shift();
|
5742
5745
|
grest.shift();
|
5743
5746
|
}
|
5744
5747
|
const p = [p0, p1, p2, p3, ""].join("/");
|
5745
5748
|
const g = [g0, g1, g2, g3, ""].join("/");
|
5746
|
-
|
5747
|
-
|
5748
|
-
this.length =
|
5749
|
+
this.#patternList = [p, ...prest];
|
5750
|
+
this.#globList = [g, ...grest];
|
5751
|
+
this.length = this.#patternList.length;
|
5749
5752
|
} else if (this.isDrive() || this.isAbsolute()) {
|
5750
|
-
const [p1, ...prest] =
|
5751
|
-
const [g1, ...grest] =
|
5753
|
+
const [p1, ...prest] = this.#patternList;
|
5754
|
+
const [g1, ...grest] = this.#globList;
|
5752
5755
|
if (prest[0] === "") {
|
5753
5756
|
prest.shift();
|
5754
5757
|
grest.shift();
|
5755
5758
|
}
|
5756
5759
|
const p = p1 + "/";
|
5757
5760
|
const g = g1 + "/";
|
5758
|
-
|
5759
|
-
|
5760
|
-
this.length =
|
5761
|
+
this.#patternList = [p, ...prest];
|
5762
|
+
this.#globList = [g, ...grest];
|
5763
|
+
this.length = this.#patternList.length;
|
5761
5764
|
}
|
5762
5765
|
}
|
5763
5766
|
}
|
@@ -5765,58 +5768,58 @@ var _Pattern = class _Pattern2 {
|
|
5765
5768
|
* The first entry in the parsed list of patterns
|
5766
5769
|
*/
|
5767
5770
|
pattern() {
|
5768
|
-
return
|
5771
|
+
return this.#patternList[this.#index];
|
5769
5772
|
}
|
5770
5773
|
/**
|
5771
5774
|
* true of if pattern() returns a string
|
5772
5775
|
*/
|
5773
5776
|
isString() {
|
5774
|
-
return typeof
|
5777
|
+
return typeof this.#patternList[this.#index] === "string";
|
5775
5778
|
}
|
5776
5779
|
/**
|
5777
5780
|
* true of if pattern() returns GLOBSTAR
|
5778
5781
|
*/
|
5779
5782
|
isGlobstar() {
|
5780
|
-
return
|
5783
|
+
return this.#patternList[this.#index] === GLOBSTAR;
|
5781
5784
|
}
|
5782
5785
|
/**
|
5783
5786
|
* true if pattern() returns a regexp
|
5784
5787
|
*/
|
5785
5788
|
isRegExp() {
|
5786
|
-
return
|
5789
|
+
return this.#patternList[this.#index] instanceof RegExp;
|
5787
5790
|
}
|
5788
5791
|
/**
|
5789
5792
|
* The /-joined set of glob parts that make up this pattern
|
5790
5793
|
*/
|
5791
5794
|
globString() {
|
5792
|
-
return
|
5795
|
+
return this.#globString = this.#globString || (this.#index === 0 ? this.isAbsolute() ? this.#globList[0] + this.#globList.slice(1).join("/") : this.#globList.join("/") : this.#globList.slice(this.#index).join("/"));
|
5793
5796
|
}
|
5794
5797
|
/**
|
5795
5798
|
* true if there are more pattern parts after this one
|
5796
5799
|
*/
|
5797
5800
|
hasMore() {
|
5798
|
-
return this.length >
|
5801
|
+
return this.length > this.#index + 1;
|
5799
5802
|
}
|
5800
5803
|
/**
|
5801
5804
|
* The rest of the pattern after this part, or null if this is the end
|
5802
5805
|
*/
|
5803
5806
|
rest() {
|
5804
|
-
if (
|
5805
|
-
return
|
5807
|
+
if (this.#rest !== void 0)
|
5808
|
+
return this.#rest;
|
5806
5809
|
if (!this.hasMore())
|
5807
|
-
return
|
5808
|
-
|
5809
|
-
|
5810
|
-
|
5811
|
-
|
5812
|
-
return
|
5810
|
+
return this.#rest = null;
|
5811
|
+
this.#rest = new _Pattern(this.#patternList, this.#globList, this.#index + 1, this.#platform);
|
5812
|
+
this.#rest.#isAbsolute = this.#isAbsolute;
|
5813
|
+
this.#rest.#isUNC = this.#isUNC;
|
5814
|
+
this.#rest.#isDrive = this.#isDrive;
|
5815
|
+
return this.#rest;
|
5813
5816
|
}
|
5814
5817
|
/**
|
5815
5818
|
* true if the pattern represents a //unc/path/ on windows
|
5816
5819
|
*/
|
5817
5820
|
isUNC() {
|
5818
|
-
const pl =
|
5819
|
-
return
|
5821
|
+
const pl = this.#patternList;
|
5822
|
+
return this.#isUNC !== void 0 ? this.#isUNC : this.#isUNC = this.#platform === "win32" && this.#index === 0 && pl[0] === "" && pl[1] === "" && typeof pl[2] === "string" && !!pl[2] && typeof pl[3] === "string" && !!pl[3];
|
5820
5823
|
}
|
5821
5824
|
// pattern like C:/...
|
5822
5825
|
// split = ['C:', ...]
|
@@ -5827,8 +5830,8 @@ var _Pattern = class _Pattern2 {
|
|
5827
5830
|
* True if the pattern starts with a drive letter on Windows
|
5828
5831
|
*/
|
5829
5832
|
isDrive() {
|
5830
|
-
const pl =
|
5831
|
-
return
|
5833
|
+
const pl = this.#patternList;
|
5834
|
+
return this.#isDrive !== void 0 ? this.#isDrive : this.#isDrive = this.#platform === "win32" && this.#index === 0 && this.length > 1 && typeof pl[0] === "string" && /^[a-z]:$/i.test(pl[0]);
|
5832
5835
|
}
|
5833
5836
|
// pattern = '/' or '/...' or '/x/...'
|
5834
5837
|
// split = ['', ''] or ['', ...] or ['', 'x', ...]
|
@@ -5837,53 +5840,42 @@ var _Pattern = class _Pattern2 {
|
|
5837
5840
|
* True if the pattern is rooted on an absolute path
|
5838
5841
|
*/
|
5839
5842
|
isAbsolute() {
|
5840
|
-
const pl =
|
5841
|
-
return
|
5843
|
+
const pl = this.#patternList;
|
5844
|
+
return this.#isAbsolute !== void 0 ? this.#isAbsolute : this.#isAbsolute = pl[0] === "" && pl.length > 1 || this.isDrive() || this.isUNC();
|
5842
5845
|
}
|
5843
5846
|
/**
|
5844
5847
|
* consume the root of the pattern, and return it
|
5845
5848
|
*/
|
5846
5849
|
root() {
|
5847
|
-
const p =
|
5848
|
-
return typeof p === "string" && this.isAbsolute() &&
|
5850
|
+
const p = this.#patternList[0];
|
5851
|
+
return typeof p === "string" && this.isAbsolute() && this.#index === 0 ? p : "";
|
5849
5852
|
}
|
5850
5853
|
/**
|
5851
5854
|
* Check to see if the current globstar pattern is allowed to follow
|
5852
5855
|
* a symbolic link.
|
5853
5856
|
*/
|
5854
5857
|
checkFollowGlobstar() {
|
5855
|
-
return !(
|
5858
|
+
return !(this.#index === 0 || !this.isGlobstar() || !this.#followGlobstar);
|
5856
5859
|
}
|
5857
5860
|
/**
|
5858
5861
|
* Mark that the current globstar pattern is following a symbolic link
|
5859
5862
|
*/
|
5860
5863
|
markFollowGlobstar() {
|
5861
|
-
if (
|
5864
|
+
if (this.#index === 0 || !this.isGlobstar() || !this.#followGlobstar)
|
5862
5865
|
return false;
|
5863
|
-
|
5866
|
+
this.#followGlobstar = false;
|
5864
5867
|
return true;
|
5865
5868
|
}
|
5866
5869
|
};
|
5867
|
-
_patternList = /* @__PURE__ */ new WeakMap();
|
5868
|
-
_globList = /* @__PURE__ */ new WeakMap();
|
5869
|
-
_index = /* @__PURE__ */ new WeakMap();
|
5870
|
-
_platform = /* @__PURE__ */ new WeakMap();
|
5871
|
-
_rest = /* @__PURE__ */ new WeakMap();
|
5872
|
-
_globString = /* @__PURE__ */ new WeakMap();
|
5873
|
-
_isDrive = /* @__PURE__ */ new WeakMap();
|
5874
|
-
_isUNC = /* @__PURE__ */ new WeakMap();
|
5875
|
-
_isAbsolute = /* @__PURE__ */ new WeakMap();
|
5876
|
-
_followGlobstar = /* @__PURE__ */ new WeakMap();
|
5877
|
-
var Pattern = _Pattern;
|
5878
5870
|
var defaultPlatform2 = typeof process === "object" && process && typeof process.platform === "string" ? process.platform : "linux";
|
5879
5871
|
var Ignore = class {
|
5872
|
+
relative;
|
5873
|
+
relativeChildren;
|
5874
|
+
absolute;
|
5875
|
+
absoluteChildren;
|
5876
|
+
platform;
|
5877
|
+
mmopts;
|
5880
5878
|
constructor(ignored, { nobrace, nocase, noext, noglobstar, platform = defaultPlatform2 }) {
|
5881
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "relative");
|
5882
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "relativeChildren");
|
5883
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "absolute");
|
5884
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "absoluteChildren");
|
5885
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "platform");
|
5886
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "mmopts");
|
5887
5879
|
this.relative = [];
|
5888
5880
|
this.absolute = [];
|
5889
5881
|
this.relativeChildren = [];
|
@@ -5961,8 +5953,8 @@ var Ignore = class {
|
|
5961
5953
|
}
|
5962
5954
|
};
|
5963
5955
|
var HasWalkedCache = class _HasWalkedCache {
|
5956
|
+
store;
|
5964
5957
|
constructor(store = /* @__PURE__ */ new Map()) {
|
5965
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "store");
|
5966
5958
|
this.store = store;
|
5967
5959
|
}
|
5968
5960
|
copy() {
|
@@ -5981,9 +5973,7 @@ var HasWalkedCache = class _HasWalkedCache {
|
|
5981
5973
|
}
|
5982
5974
|
};
|
5983
5975
|
var MatchRecord = class {
|
5984
|
-
|
5985
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "store", /* @__PURE__ */ new Map());
|
5986
|
-
}
|
5976
|
+
store = /* @__PURE__ */ new Map();
|
5987
5977
|
add(target, absolute, ifDir) {
|
5988
5978
|
const n = (absolute ? 2 : 0) | (ifDir ? 1 : 0);
|
5989
5979
|
const current = this.store.get(target);
|
@@ -5999,9 +5989,7 @@ var MatchRecord = class {
|
|
5999
5989
|
}
|
6000
5990
|
};
|
6001
5991
|
var SubWalks = class {
|
6002
|
-
|
6003
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "store", /* @__PURE__ */ new Map());
|
6004
|
-
}
|
5992
|
+
store = /* @__PURE__ */ new Map();
|
6005
5993
|
add(target, pattern) {
|
6006
5994
|
if (!target.canReaddir()) {
|
6007
5995
|
return;
|
@@ -6029,14 +6017,14 @@ var SubWalks = class {
|
|
6029
6017
|
}
|
6030
6018
|
};
|
6031
6019
|
var Processor = class _Processor {
|
6020
|
+
hasWalkedCache;
|
6021
|
+
matches = new MatchRecord();
|
6022
|
+
subwalks = new SubWalks();
|
6023
|
+
patterns;
|
6024
|
+
follow;
|
6025
|
+
dot;
|
6026
|
+
opts;
|
6032
6027
|
constructor(opts, hasWalkedCache) {
|
6033
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "hasWalkedCache");
|
6034
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "matches", new MatchRecord());
|
6035
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "subwalks", new SubWalks());
|
6036
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "patterns");
|
6037
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "follow");
|
6038
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "dot");
|
6039
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "opts");
|
6040
6028
|
this.opts = opts;
|
6041
6029
|
this.follow = !!opts.follow;
|
6042
6030
|
this.dot = !!opts.dot;
|
@@ -6184,30 +6172,28 @@ var Processor = class _Processor {
|
|
6184
6172
|
}
|
6185
6173
|
};
|
6186
6174
|
var makeIgnore = (ignore, opts) => typeof ignore === "string" ? new Ignore([ignore], opts) : Array.isArray(ignore) ? new Ignore(ignore, opts) : ignore;
|
6187
|
-
var _onResume, _ignore, _sep, _GlobUtil_instances, ignored_fn, childrenIgnored_fn;
|
6188
6175
|
var GlobUtil = class {
|
6176
|
+
path;
|
6177
|
+
patterns;
|
6178
|
+
opts;
|
6179
|
+
seen = /* @__PURE__ */ new Set();
|
6180
|
+
paused = false;
|
6181
|
+
aborted = false;
|
6182
|
+
#onResume = [];
|
6183
|
+
#ignore;
|
6184
|
+
#sep;
|
6185
|
+
signal;
|
6186
|
+
maxDepth;
|
6187
|
+
includeChildMatches;
|
6189
6188
|
constructor(patterns, path2, opts) {
|
6190
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _GlobUtil_instances);
|
6191
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "path");
|
6192
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "patterns");
|
6193
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "opts");
|
6194
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "seen", /* @__PURE__ */ new Set());
|
6195
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "paused", false);
|
6196
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "aborted", false);
|
6197
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _onResume, []);
|
6198
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _ignore);
|
6199
|
-
(0, import_chunk_OSFPEEC6.__privateAdd)(this, _sep);
|
6200
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "signal");
|
6201
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "maxDepth");
|
6202
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "includeChildMatches");
|
6203
6189
|
this.patterns = patterns;
|
6204
6190
|
this.path = path2;
|
6205
6191
|
this.opts = opts;
|
6206
|
-
|
6192
|
+
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
6207
6193
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
6208
6194
|
if (opts.ignore || !this.includeChildMatches) {
|
6209
|
-
|
6210
|
-
if (!this.includeChildMatches && typeof
|
6195
|
+
this.#ignore = makeIgnore(opts.ignore ?? [], opts);
|
6196
|
+
if (!this.includeChildMatches && typeof this.#ignore.add !== "function") {
|
6211
6197
|
const m = "cannot ignore child matches, ignore lacks add() method.";
|
6212
6198
|
throw new Error(m);
|
6213
6199
|
}
|
@@ -6216,10 +6202,16 @@ var GlobUtil = class {
|
|
6216
6202
|
if (opts.signal) {
|
6217
6203
|
this.signal = opts.signal;
|
6218
6204
|
this.signal.addEventListener("abort", () => {
|
6219
|
-
|
6205
|
+
this.#onResume.length = 0;
|
6220
6206
|
});
|
6221
6207
|
}
|
6222
6208
|
}
|
6209
|
+
#ignored(path2) {
|
6210
|
+
return this.seen.has(path2) || !!this.#ignore?.ignored?.(path2);
|
6211
|
+
}
|
6212
|
+
#childrenIgnored(path2) {
|
6213
|
+
return !!this.#ignore?.childrenIgnored?.(path2);
|
6214
|
+
}
|
6223
6215
|
// backpressure mechanism
|
6224
6216
|
pause() {
|
6225
6217
|
this.paused = true;
|
@@ -6229,7 +6221,7 @@ var GlobUtil = class {
|
|
6229
6221
|
return;
|
6230
6222
|
this.paused = false;
|
6231
6223
|
let fn = void 0;
|
6232
|
-
while (!this.paused && (fn =
|
6224
|
+
while (!this.paused && (fn = this.#onResume.shift())) {
|
6233
6225
|
fn();
|
6234
6226
|
}
|
6235
6227
|
}
|
@@ -6239,7 +6231,7 @@ var GlobUtil = class {
|
|
6239
6231
|
if (!this.paused) {
|
6240
6232
|
fn();
|
6241
6233
|
} else {
|
6242
|
-
|
6234
|
+
this.#onResume.push(fn);
|
6243
6235
|
}
|
6244
6236
|
}
|
6245
6237
|
// do the requisite realpath/stat checking, and return the path
|
@@ -6265,7 +6257,7 @@ var GlobUtil = class {
|
|
6265
6257
|
return this.matchCheckTest(s, ifDir);
|
6266
6258
|
}
|
6267
6259
|
matchCheckTest(e, ifDir) {
|
6268
|
-
return e && (this.maxDepth === Infinity || e.depth() <= this.maxDepth) && (!ifDir || e.canReaddir()) && (!this.opts.nodir || !e.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !e.isSymbolicLink() || !e.realpathCached()?.isDirectory()) && !
|
6260
|
+
return e && (this.maxDepth === Infinity || e.depth() <= this.maxDepth) && (!ifDir || e.canReaddir()) && (!this.opts.nodir || !e.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !e.isSymbolicLink() || !e.realpathCached()?.isDirectory()) && !this.#ignored(e) ? e : void 0;
|
6269
6261
|
}
|
6270
6262
|
matchCheckSync(e, ifDir) {
|
6271
6263
|
if (ifDir && this.opts.nodir)
|
@@ -6288,15 +6280,15 @@ var GlobUtil = class {
|
|
6288
6280
|
return this.matchCheckTest(s, ifDir);
|
6289
6281
|
}
|
6290
6282
|
matchFinish(e, absolute) {
|
6291
|
-
if (
|
6283
|
+
if (this.#ignored(e))
|
6292
6284
|
return;
|
6293
|
-
if (!this.includeChildMatches &&
|
6285
|
+
if (!this.includeChildMatches && this.#ignore?.add) {
|
6294
6286
|
const ign = `${e.relativePosix()}/**`;
|
6295
|
-
|
6287
|
+
this.#ignore.add(ign);
|
6296
6288
|
}
|
6297
6289
|
const abs = this.opts.absolute === void 0 ? absolute : this.opts.absolute;
|
6298
6290
|
this.seen.add(e);
|
6299
|
-
const mark = this.opts.mark && e.isDirectory() ?
|
6291
|
+
const mark = this.opts.mark && e.isDirectory() ? this.#sep : "";
|
6300
6292
|
if (this.opts.withFileTypes) {
|
6301
6293
|
this.matchEmit(e);
|
6302
6294
|
} else if (abs) {
|
@@ -6304,7 +6296,7 @@ var GlobUtil = class {
|
|
6304
6296
|
this.matchEmit(abs2 + mark);
|
6305
6297
|
} else {
|
6306
6298
|
const rel = this.opts.posix ? e.relativePosix() : e.relative();
|
6307
|
-
const pre = this.opts.dotRelative && !rel.startsWith(".." +
|
6299
|
+
const pre = this.opts.dotRelative && !rel.startsWith(".." + this.#sep) ? "." + this.#sep : "";
|
6308
6300
|
this.matchEmit(!rel ? "." + mark : pre + rel + mark);
|
6309
6301
|
}
|
6310
6302
|
}
|
@@ -6324,7 +6316,7 @@ var GlobUtil = class {
|
|
6324
6316
|
this.walkCB2(target, patterns, new Processor(this.opts), cb);
|
6325
6317
|
}
|
6326
6318
|
walkCB2(target, patterns, processor, cb) {
|
6327
|
-
if (
|
6319
|
+
if (this.#childrenIgnored(target))
|
6328
6320
|
return cb();
|
6329
6321
|
if (this.signal?.aborted)
|
6330
6322
|
cb();
|
@@ -6339,7 +6331,7 @@ var GlobUtil = class {
|
|
6339
6331
|
cb();
|
6340
6332
|
};
|
6341
6333
|
for (const [m, absolute, ifDir] of processor.matches.entries()) {
|
6342
|
-
if (
|
6334
|
+
if (this.#ignored(m))
|
6343
6335
|
continue;
|
6344
6336
|
tasks++;
|
6345
6337
|
this.match(m, absolute, ifDir).then(() => next());
|
@@ -6366,7 +6358,7 @@ var GlobUtil = class {
|
|
6366
6358
|
cb();
|
6367
6359
|
};
|
6368
6360
|
for (const [m, absolute, ifDir] of processor.matches.entries()) {
|
6369
|
-
if (
|
6361
|
+
if (this.#ignored(m))
|
6370
6362
|
continue;
|
6371
6363
|
tasks++;
|
6372
6364
|
this.match(m, absolute, ifDir).then(() => next());
|
@@ -6383,7 +6375,7 @@ var GlobUtil = class {
|
|
6383
6375
|
this.walkCB2Sync(target, patterns, new Processor(this.opts), cb);
|
6384
6376
|
}
|
6385
6377
|
walkCB2Sync(target, patterns, processor, cb) {
|
6386
|
-
if (
|
6378
|
+
if (this.#childrenIgnored(target))
|
6387
6379
|
return cb();
|
6388
6380
|
if (this.signal?.aborted)
|
6389
6381
|
cb();
|
@@ -6398,7 +6390,7 @@ var GlobUtil = class {
|
|
6398
6390
|
cb();
|
6399
6391
|
};
|
6400
6392
|
for (const [m, absolute, ifDir] of processor.matches.entries()) {
|
6401
|
-
if (
|
6393
|
+
if (this.#ignored(m))
|
6402
6394
|
continue;
|
6403
6395
|
this.matchSync(m, absolute, ifDir);
|
6404
6396
|
}
|
@@ -6420,7 +6412,7 @@ var GlobUtil = class {
|
|
6420
6412
|
cb();
|
6421
6413
|
};
|
6422
6414
|
for (const [m, absolute, ifDir] of processor.matches.entries()) {
|
6423
|
-
if (
|
6415
|
+
if (this.#ignored(m))
|
6424
6416
|
continue;
|
6425
6417
|
this.matchSync(m, absolute, ifDir);
|
6426
6418
|
}
|
@@ -6431,20 +6423,10 @@ var GlobUtil = class {
|
|
6431
6423
|
next();
|
6432
6424
|
}
|
6433
6425
|
};
|
6434
|
-
_onResume = /* @__PURE__ */ new WeakMap();
|
6435
|
-
_ignore = /* @__PURE__ */ new WeakMap();
|
6436
|
-
_sep = /* @__PURE__ */ new WeakMap();
|
6437
|
-
_GlobUtil_instances = /* @__PURE__ */ new WeakSet();
|
6438
|
-
ignored_fn = function(path2) {
|
6439
|
-
return this.seen.has(path2) || !!(0, import_chunk_OSFPEEC6.__privateGet)(this, _ignore)?.ignored?.(path2);
|
6440
|
-
};
|
6441
|
-
childrenIgnored_fn = function(path2) {
|
6442
|
-
return !!(0, import_chunk_OSFPEEC6.__privateGet)(this, _ignore)?.childrenIgnored?.(path2);
|
6443
|
-
};
|
6444
6426
|
var GlobWalker = class extends GlobUtil {
|
6427
|
+
matches = /* @__PURE__ */ new Set();
|
6445
6428
|
constructor(patterns, path2, opts) {
|
6446
6429
|
super(patterns, path2, opts);
|
6447
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "matches", /* @__PURE__ */ new Set());
|
6448
6430
|
}
|
6449
6431
|
matchEmit(e) {
|
6450
6432
|
this.matches.add(e);
|
@@ -6480,9 +6462,9 @@ var GlobWalker = class extends GlobUtil {
|
|
6480
6462
|
}
|
6481
6463
|
};
|
6482
6464
|
var GlobStream = class extends GlobUtil {
|
6465
|
+
results;
|
6483
6466
|
constructor(patterns, path2, opts) {
|
6484
6467
|
super(patterns, path2, opts);
|
6485
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "results");
|
6486
6468
|
this.results = new Minipass({
|
6487
6469
|
signal: this.signal,
|
6488
6470
|
objectMode: true
|
@@ -6516,6 +6498,39 @@ var GlobStream = class extends GlobUtil {
|
|
6516
6498
|
};
|
6517
6499
|
var defaultPlatform3 = typeof process === "object" && process && typeof process.platform === "string" ? process.platform : "linux";
|
6518
6500
|
var Glob = class {
|
6501
|
+
absolute;
|
6502
|
+
cwd;
|
6503
|
+
root;
|
6504
|
+
dot;
|
6505
|
+
dotRelative;
|
6506
|
+
follow;
|
6507
|
+
ignore;
|
6508
|
+
magicalBraces;
|
6509
|
+
mark;
|
6510
|
+
matchBase;
|
6511
|
+
maxDepth;
|
6512
|
+
nobrace;
|
6513
|
+
nocase;
|
6514
|
+
nodir;
|
6515
|
+
noext;
|
6516
|
+
noglobstar;
|
6517
|
+
pattern;
|
6518
|
+
platform;
|
6519
|
+
realpath;
|
6520
|
+
scurry;
|
6521
|
+
stat;
|
6522
|
+
signal;
|
6523
|
+
windowsPathsNoEscape;
|
6524
|
+
withFileTypes;
|
6525
|
+
includeChildMatches;
|
6526
|
+
/**
|
6527
|
+
* The options provided to the constructor.
|
6528
|
+
*/
|
6529
|
+
opts;
|
6530
|
+
/**
|
6531
|
+
* An array of parsed immutable {@link Pattern} objects.
|
6532
|
+
*/
|
6533
|
+
patterns;
|
6519
6534
|
/**
|
6520
6535
|
* All options are stored as properties on the `Glob` object.
|
6521
6536
|
*
|
@@ -6529,33 +6544,6 @@ var Glob = class {
|
|
6529
6544
|
* again.
|
6530
6545
|
*/
|
6531
6546
|
constructor(pattern, opts) {
|
6532
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "absolute");
|
6533
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "cwd");
|
6534
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "root");
|
6535
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "dot");
|
6536
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "dotRelative");
|
6537
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "follow");
|
6538
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "ignore");
|
6539
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "magicalBraces");
|
6540
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "mark");
|
6541
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "matchBase");
|
6542
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "maxDepth");
|
6543
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "nobrace");
|
6544
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "nocase");
|
6545
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "nodir");
|
6546
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "noext");
|
6547
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "noglobstar");
|
6548
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "pattern");
|
6549
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "platform");
|
6550
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "realpath");
|
6551
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "scurry");
|
6552
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "stat");
|
6553
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "signal");
|
6554
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "windowsPathsNoEscape");
|
6555
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "withFileTypes");
|
6556
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "includeChildMatches");
|
6557
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "opts");
|
6558
|
-
(0, import_chunk_OSFPEEC6.__publicField)(this, "patterns");
|
6559
6547
|
if (!opts)
|
6560
6548
|
throw new TypeError("glob options required");
|
6561
6549
|
this.withFileTypes = !!opts.withFileTypes;
|