@skrillex1224/playwright-toolkit 3.0.15 → 3.0.17
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/browser.d.ts +6 -0
- package/dist/browser.js +446 -163
- package/dist/browser.js.map +4 -4
- package/dist/index.cjs +1224 -517
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +1222 -515
- package/dist/index.js.map +4 -4
- package/index.d.ts +49 -9
- package/package.json +9 -1
- package/scripts/postinstall.js +203 -0
package/dist/browser.js
CHANGED
|
@@ -34,6 +34,7 @@ var require_constants = __commonJS({
|
|
|
34
34
|
"use strict";
|
|
35
35
|
var WIN_SLASH = "\\\\/";
|
|
36
36
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
37
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
37
38
|
var DOT_LITERAL = "\\.";
|
|
38
39
|
var PLUS_LITERAL = "\\+";
|
|
39
40
|
var QMARK_LITERAL = "\\?";
|
|
@@ -84,6 +85,7 @@ var require_constants = __commonJS({
|
|
|
84
85
|
SEP: "\\"
|
|
85
86
|
};
|
|
86
87
|
var POSIX_REGEX_SOURCE = {
|
|
88
|
+
__proto__: null,
|
|
87
89
|
alnum: "a-zA-Z0-9",
|
|
88
90
|
alpha: "a-zA-Z",
|
|
89
91
|
ascii: "\\x00-\\x7F",
|
|
@@ -100,6 +102,7 @@ var require_constants = __commonJS({
|
|
|
100
102
|
xdigit: "A-Fa-f0-9"
|
|
101
103
|
};
|
|
102
104
|
module.exports = {
|
|
105
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
103
106
|
MAX_LENGTH: 1024 * 64,
|
|
104
107
|
POSIX_REGEX_SOURCE,
|
|
105
108
|
// regular expressions
|
|
@@ -263,19 +266,19 @@ var require_utils = __commonJS({
|
|
|
263
266
|
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
264
267
|
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
265
268
|
};
|
|
266
|
-
exports.removePrefix = (input,
|
|
269
|
+
exports.removePrefix = (input, state2 = {}) => {
|
|
267
270
|
let output = input;
|
|
268
271
|
if (output.startsWith("./")) {
|
|
269
272
|
output = output.slice(2);
|
|
270
|
-
|
|
273
|
+
state2.prefix = "./";
|
|
271
274
|
}
|
|
272
275
|
return output;
|
|
273
276
|
};
|
|
274
|
-
exports.wrapOutput = (input,
|
|
277
|
+
exports.wrapOutput = (input, state2 = {}, options = {}) => {
|
|
275
278
|
const prepend = options.contains ? "" : "^";
|
|
276
279
|
const append = options.contains ? "" : "$";
|
|
277
280
|
let output = `${prepend}(?:${input})${append}`;
|
|
278
|
-
if (
|
|
281
|
+
if (state2.negated === true) {
|
|
279
282
|
output = `(?:^(?!${output}).*$)`;
|
|
280
283
|
}
|
|
281
284
|
return output;
|
|
@@ -561,7 +564,7 @@ var require_scan = __commonJS({
|
|
|
561
564
|
base = utils.removeBackslashes(base);
|
|
562
565
|
}
|
|
563
566
|
}
|
|
564
|
-
const
|
|
567
|
+
const state2 = {
|
|
565
568
|
prefix,
|
|
566
569
|
input,
|
|
567
570
|
start,
|
|
@@ -576,11 +579,11 @@ var require_scan = __commonJS({
|
|
|
576
579
|
negatedExtglob
|
|
577
580
|
};
|
|
578
581
|
if (opts.tokens === true) {
|
|
579
|
-
|
|
582
|
+
state2.maxDepth = 0;
|
|
580
583
|
if (!isPathSeparator(code)) {
|
|
581
584
|
tokens.push(token);
|
|
582
585
|
}
|
|
583
|
-
|
|
586
|
+
state2.tokens = tokens;
|
|
584
587
|
}
|
|
585
588
|
if (opts.parts === true || opts.tokens === true) {
|
|
586
589
|
let prevIndex;
|
|
@@ -596,7 +599,7 @@ var require_scan = __commonJS({
|
|
|
596
599
|
tokens[idx].value = value;
|
|
597
600
|
}
|
|
598
601
|
depth(tokens[idx]);
|
|
599
|
-
|
|
602
|
+
state2.maxDepth += tokens[idx].depth;
|
|
600
603
|
}
|
|
601
604
|
if (idx !== 0 || value !== "") {
|
|
602
605
|
parts.push(value);
|
|
@@ -609,13 +612,13 @@ var require_scan = __commonJS({
|
|
|
609
612
|
if (opts.tokens) {
|
|
610
613
|
tokens[tokens.length - 1].value = value;
|
|
611
614
|
depth(tokens[tokens.length - 1]);
|
|
612
|
-
|
|
615
|
+
state2.maxDepth += tokens[tokens.length - 1].depth;
|
|
613
616
|
}
|
|
614
617
|
}
|
|
615
|
-
|
|
616
|
-
|
|
618
|
+
state2.slashes = slashes;
|
|
619
|
+
state2.parts = parts;
|
|
617
620
|
}
|
|
618
|
-
return
|
|
621
|
+
return state2;
|
|
619
622
|
};
|
|
620
623
|
module.exports = scan;
|
|
621
624
|
}
|
|
@@ -650,6 +653,213 @@ var require_parse = __commonJS({
|
|
|
650
653
|
var syntaxError = (type, char) => {
|
|
651
654
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
652
655
|
};
|
|
656
|
+
var splitTopLevel = (input) => {
|
|
657
|
+
const parts = [];
|
|
658
|
+
let bracket = 0;
|
|
659
|
+
let paren = 0;
|
|
660
|
+
let quote = 0;
|
|
661
|
+
let value = "";
|
|
662
|
+
let escaped = false;
|
|
663
|
+
for (const ch of input) {
|
|
664
|
+
if (escaped === true) {
|
|
665
|
+
value += ch;
|
|
666
|
+
escaped = false;
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
669
|
+
if (ch === "\\") {
|
|
670
|
+
value += ch;
|
|
671
|
+
escaped = true;
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
if (ch === '"') {
|
|
675
|
+
quote = quote === 1 ? 0 : 1;
|
|
676
|
+
value += ch;
|
|
677
|
+
continue;
|
|
678
|
+
}
|
|
679
|
+
if (quote === 0) {
|
|
680
|
+
if (ch === "[") {
|
|
681
|
+
bracket++;
|
|
682
|
+
} else if (ch === "]" && bracket > 0) {
|
|
683
|
+
bracket--;
|
|
684
|
+
} else if (bracket === 0) {
|
|
685
|
+
if (ch === "(") {
|
|
686
|
+
paren++;
|
|
687
|
+
} else if (ch === ")" && paren > 0) {
|
|
688
|
+
paren--;
|
|
689
|
+
} else if (ch === "|" && paren === 0) {
|
|
690
|
+
parts.push(value);
|
|
691
|
+
value = "";
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
value += ch;
|
|
697
|
+
}
|
|
698
|
+
parts.push(value);
|
|
699
|
+
return parts;
|
|
700
|
+
};
|
|
701
|
+
var isPlainBranch = (branch) => {
|
|
702
|
+
let escaped = false;
|
|
703
|
+
for (const ch of branch) {
|
|
704
|
+
if (escaped === true) {
|
|
705
|
+
escaped = false;
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
if (ch === "\\") {
|
|
709
|
+
escaped = true;
|
|
710
|
+
continue;
|
|
711
|
+
}
|
|
712
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
713
|
+
return false;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return true;
|
|
717
|
+
};
|
|
718
|
+
var normalizeSimpleBranch = (branch) => {
|
|
719
|
+
let value = branch.trim();
|
|
720
|
+
let changed = true;
|
|
721
|
+
while (changed === true) {
|
|
722
|
+
changed = false;
|
|
723
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
724
|
+
value = value.slice(2, -1);
|
|
725
|
+
changed = true;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
if (!isPlainBranch(value)) {
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
return value.replace(/\\(.)/g, "$1");
|
|
732
|
+
};
|
|
733
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
734
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
735
|
+
for (let i = 0; i < values.length; i++) {
|
|
736
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
737
|
+
const a = values[i];
|
|
738
|
+
const b = values[j];
|
|
739
|
+
const char = a[0];
|
|
740
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
741
|
+
continue;
|
|
742
|
+
}
|
|
743
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return false;
|
|
749
|
+
};
|
|
750
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
751
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
let bracket = 0;
|
|
755
|
+
let paren = 0;
|
|
756
|
+
let quote = 0;
|
|
757
|
+
let escaped = false;
|
|
758
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
759
|
+
const ch = pattern[i];
|
|
760
|
+
if (escaped === true) {
|
|
761
|
+
escaped = false;
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
if (ch === "\\") {
|
|
765
|
+
escaped = true;
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
if (ch === '"') {
|
|
769
|
+
quote = quote === 1 ? 0 : 1;
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
if (quote === 1) {
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
if (ch === "[") {
|
|
776
|
+
bracket++;
|
|
777
|
+
continue;
|
|
778
|
+
}
|
|
779
|
+
if (ch === "]" && bracket > 0) {
|
|
780
|
+
bracket--;
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
if (bracket > 0) {
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
if (ch === "(") {
|
|
787
|
+
paren++;
|
|
788
|
+
continue;
|
|
789
|
+
}
|
|
790
|
+
if (ch === ")") {
|
|
791
|
+
paren--;
|
|
792
|
+
if (paren === 0) {
|
|
793
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
return {
|
|
797
|
+
type: pattern[0],
|
|
798
|
+
body: pattern.slice(2, i),
|
|
799
|
+
end: i
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
var getStarExtglobSequenceOutput = (pattern) => {
|
|
806
|
+
let index = 0;
|
|
807
|
+
const chars = [];
|
|
808
|
+
while (index < pattern.length) {
|
|
809
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
810
|
+
if (!match || match.type !== "*") {
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
814
|
+
if (branches.length !== 1) {
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
818
|
+
if (!branch || branch.length !== 1) {
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
chars.push(branch);
|
|
822
|
+
index += match.end + 1;
|
|
823
|
+
}
|
|
824
|
+
if (chars.length < 1) {
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
828
|
+
return `${source}*`;
|
|
829
|
+
};
|
|
830
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
831
|
+
let depth = 0;
|
|
832
|
+
let value = pattern.trim();
|
|
833
|
+
let match = parseRepeatedExtglob(value);
|
|
834
|
+
while (match) {
|
|
835
|
+
depth++;
|
|
836
|
+
value = match.body.trim();
|
|
837
|
+
match = parseRepeatedExtglob(value);
|
|
838
|
+
}
|
|
839
|
+
return depth;
|
|
840
|
+
};
|
|
841
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
842
|
+
if (options.maxExtglobRecursion === false) {
|
|
843
|
+
return { risky: false };
|
|
844
|
+
}
|
|
845
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
846
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
847
|
+
if (branches.length > 1) {
|
|
848
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
849
|
+
return { risky: true };
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
for (const branch of branches) {
|
|
853
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
854
|
+
if (safeOutput) {
|
|
855
|
+
return { risky: true, safeOutput };
|
|
856
|
+
}
|
|
857
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
858
|
+
return { risky: true };
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return { risky: false };
|
|
862
|
+
};
|
|
653
863
|
var parse = (input, options) => {
|
|
654
864
|
if (typeof input !== "string") {
|
|
655
865
|
throw new TypeError("Expected a string");
|
|
@@ -692,7 +902,7 @@ var require_parse = __commonJS({
|
|
|
692
902
|
if (typeof opts.noext === "boolean") {
|
|
693
903
|
opts.noextglob = opts.noext;
|
|
694
904
|
}
|
|
695
|
-
const
|
|
905
|
+
const state2 = {
|
|
696
906
|
input,
|
|
697
907
|
index: -1,
|
|
698
908
|
start: 0,
|
|
@@ -709,57 +919,57 @@ var require_parse = __commonJS({
|
|
|
709
919
|
globstar: false,
|
|
710
920
|
tokens
|
|
711
921
|
};
|
|
712
|
-
input = utils.removePrefix(input,
|
|
922
|
+
input = utils.removePrefix(input, state2);
|
|
713
923
|
len = input.length;
|
|
714
924
|
const extglobs = [];
|
|
715
925
|
const braces = [];
|
|
716
926
|
const stack = [];
|
|
717
927
|
let prev = bos;
|
|
718
928
|
let value;
|
|
719
|
-
const eos = () =>
|
|
720
|
-
const peek =
|
|
721
|
-
const advance =
|
|
722
|
-
const remaining = () => input.slice(
|
|
929
|
+
const eos = () => state2.index === len - 1;
|
|
930
|
+
const peek = state2.peek = (n = 1) => input[state2.index + n];
|
|
931
|
+
const advance = state2.advance = () => input[++state2.index] || "";
|
|
932
|
+
const remaining = () => input.slice(state2.index + 1);
|
|
723
933
|
const consume = (value2 = "", num = 0) => {
|
|
724
|
-
|
|
725
|
-
|
|
934
|
+
state2.consumed += value2;
|
|
935
|
+
state2.index += num;
|
|
726
936
|
};
|
|
727
937
|
const append = (token) => {
|
|
728
|
-
|
|
938
|
+
state2.output += token.output != null ? token.output : token.value;
|
|
729
939
|
consume(token.value);
|
|
730
940
|
};
|
|
731
941
|
const negate = () => {
|
|
732
942
|
let count = 1;
|
|
733
943
|
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
734
944
|
advance();
|
|
735
|
-
|
|
945
|
+
state2.start++;
|
|
736
946
|
count++;
|
|
737
947
|
}
|
|
738
948
|
if (count % 2 === 0) {
|
|
739
949
|
return false;
|
|
740
950
|
}
|
|
741
|
-
|
|
742
|
-
|
|
951
|
+
state2.negated = true;
|
|
952
|
+
state2.start++;
|
|
743
953
|
return true;
|
|
744
954
|
};
|
|
745
955
|
const increment = (type) => {
|
|
746
|
-
|
|
956
|
+
state2[type]++;
|
|
747
957
|
stack.push(type);
|
|
748
958
|
};
|
|
749
959
|
const decrement = (type) => {
|
|
750
|
-
|
|
960
|
+
state2[type]--;
|
|
751
961
|
stack.pop();
|
|
752
962
|
};
|
|
753
963
|
const push = (tok) => {
|
|
754
964
|
if (prev.type === "globstar") {
|
|
755
|
-
const isBrace =
|
|
965
|
+
const isBrace = state2.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
756
966
|
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
757
967
|
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
758
|
-
|
|
968
|
+
state2.output = state2.output.slice(0, -prev.output.length);
|
|
759
969
|
prev.type = "star";
|
|
760
970
|
prev.value = "*";
|
|
761
971
|
prev.output = star;
|
|
762
|
-
|
|
972
|
+
state2.output += prev.output;
|
|
763
973
|
}
|
|
764
974
|
}
|
|
765
975
|
if (extglobs.length && tok.type !== "paren") {
|
|
@@ -778,15 +988,37 @@ var require_parse = __commonJS({
|
|
|
778
988
|
const extglobOpen = (type, value2) => {
|
|
779
989
|
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
780
990
|
token.prev = prev;
|
|
781
|
-
token.parens =
|
|
782
|
-
token.output =
|
|
991
|
+
token.parens = state2.parens;
|
|
992
|
+
token.output = state2.output;
|
|
993
|
+
token.startIndex = state2.index;
|
|
994
|
+
token.tokensIndex = tokens.length;
|
|
783
995
|
const output = (opts.capture ? "(" : "") + token.open;
|
|
784
996
|
increment("parens");
|
|
785
|
-
push({ type, value: value2, output:
|
|
997
|
+
push({ type, value: value2, output: state2.output ? "" : ONE_CHAR });
|
|
786
998
|
push({ type: "paren", extglob: true, value: advance(), output });
|
|
787
999
|
extglobs.push(token);
|
|
788
1000
|
};
|
|
789
1001
|
const extglobClose = (token) => {
|
|
1002
|
+
const literal = input.slice(token.startIndex, state2.index + 1);
|
|
1003
|
+
const body = input.slice(token.startIndex + 2, state2.index);
|
|
1004
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
1005
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
1006
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
1007
|
+
const open = tokens[token.tokensIndex];
|
|
1008
|
+
open.type = "text";
|
|
1009
|
+
open.value = literal;
|
|
1010
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
1011
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
1012
|
+
tokens[i].value = "";
|
|
1013
|
+
tokens[i].output = "";
|
|
1014
|
+
delete tokens[i].suffix;
|
|
1015
|
+
}
|
|
1016
|
+
state2.output = token.output + open.output;
|
|
1017
|
+
state2.backtrack = true;
|
|
1018
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
1019
|
+
decrement("parens");
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
790
1022
|
let output = token.close + (opts.capture ? ")" : "");
|
|
791
1023
|
let rest;
|
|
792
1024
|
if (token.type === "negate") {
|
|
@@ -802,7 +1034,7 @@ var require_parse = __commonJS({
|
|
|
802
1034
|
output = token.close = `)${expression})${extglobStar})`;
|
|
803
1035
|
}
|
|
804
1036
|
if (token.prev.type === "bos") {
|
|
805
|
-
|
|
1037
|
+
state2.negatedExtglob = true;
|
|
806
1038
|
}
|
|
807
1039
|
}
|
|
808
1040
|
push({ type: "paren", extglob: true, value, output });
|
|
@@ -845,11 +1077,11 @@ var require_parse = __commonJS({
|
|
|
845
1077
|
}
|
|
846
1078
|
}
|
|
847
1079
|
if (output === input && opts.contains === true) {
|
|
848
|
-
|
|
849
|
-
return
|
|
1080
|
+
state2.output = input;
|
|
1081
|
+
return state2;
|
|
850
1082
|
}
|
|
851
|
-
|
|
852
|
-
return
|
|
1083
|
+
state2.output = utils.wrapOutput(output, state2, options);
|
|
1084
|
+
return state2;
|
|
853
1085
|
}
|
|
854
1086
|
while (!eos()) {
|
|
855
1087
|
value = advance();
|
|
@@ -873,7 +1105,7 @@ var require_parse = __commonJS({
|
|
|
873
1105
|
let slashes = 0;
|
|
874
1106
|
if (match && match[0].length > 2) {
|
|
875
1107
|
slashes = match[0].length;
|
|
876
|
-
|
|
1108
|
+
state2.index += slashes;
|
|
877
1109
|
if (slashes % 2 !== 0) {
|
|
878
1110
|
value += "\\";
|
|
879
1111
|
}
|
|
@@ -883,12 +1115,12 @@ var require_parse = __commonJS({
|
|
|
883
1115
|
} else {
|
|
884
1116
|
value += advance();
|
|
885
1117
|
}
|
|
886
|
-
if (
|
|
1118
|
+
if (state2.brackets === 0) {
|
|
887
1119
|
push({ type: "text", value });
|
|
888
1120
|
continue;
|
|
889
1121
|
}
|
|
890
1122
|
}
|
|
891
|
-
if (
|
|
1123
|
+
if (state2.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
892
1124
|
if (opts.posix !== false && value === ":") {
|
|
893
1125
|
const inner = prev.value.slice(1);
|
|
894
1126
|
if (inner.includes("[")) {
|
|
@@ -900,7 +1132,7 @@ var require_parse = __commonJS({
|
|
|
900
1132
|
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
901
1133
|
if (posix) {
|
|
902
1134
|
prev.value = pre + posix;
|
|
903
|
-
|
|
1135
|
+
state2.backtrack = true;
|
|
904
1136
|
advance();
|
|
905
1137
|
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
906
1138
|
bos.output = ONE_CHAR;
|
|
@@ -923,14 +1155,14 @@ var require_parse = __commonJS({
|
|
|
923
1155
|
append({ value });
|
|
924
1156
|
continue;
|
|
925
1157
|
}
|
|
926
|
-
if (
|
|
1158
|
+
if (state2.quotes === 1 && value !== '"') {
|
|
927
1159
|
value = utils.escapeRegex(value);
|
|
928
1160
|
prev.value += value;
|
|
929
1161
|
append({ value });
|
|
930
1162
|
continue;
|
|
931
1163
|
}
|
|
932
1164
|
if (value === '"') {
|
|
933
|
-
|
|
1165
|
+
state2.quotes = state2.quotes === 1 ? 0 : 1;
|
|
934
1166
|
if (opts.keepQuotes === true) {
|
|
935
1167
|
push({ type: "text", value });
|
|
936
1168
|
}
|
|
@@ -942,15 +1174,15 @@ var require_parse = __commonJS({
|
|
|
942
1174
|
continue;
|
|
943
1175
|
}
|
|
944
1176
|
if (value === ")") {
|
|
945
|
-
if (
|
|
1177
|
+
if (state2.parens === 0 && opts.strictBrackets === true) {
|
|
946
1178
|
throw new SyntaxError(syntaxError("opening", "("));
|
|
947
1179
|
}
|
|
948
1180
|
const extglob = extglobs[extglobs.length - 1];
|
|
949
|
-
if (extglob &&
|
|
1181
|
+
if (extglob && state2.parens === extglob.parens + 1) {
|
|
950
1182
|
extglobClose(extglobs.pop());
|
|
951
1183
|
continue;
|
|
952
1184
|
}
|
|
953
|
-
push({ type: "paren", value, output:
|
|
1185
|
+
push({ type: "paren", value, output: state2.parens ? ")" : "\\)" });
|
|
954
1186
|
decrement("parens");
|
|
955
1187
|
continue;
|
|
956
1188
|
}
|
|
@@ -971,7 +1203,7 @@ var require_parse = __commonJS({
|
|
|
971
1203
|
push({ type: "text", value, output: `\\${value}` });
|
|
972
1204
|
continue;
|
|
973
1205
|
}
|
|
974
|
-
if (
|
|
1206
|
+
if (state2.brackets === 0) {
|
|
975
1207
|
if (opts.strictBrackets === true) {
|
|
976
1208
|
throw new SyntaxError(syntaxError("opening", "["));
|
|
977
1209
|
}
|
|
@@ -989,14 +1221,14 @@ var require_parse = __commonJS({
|
|
|
989
1221
|
continue;
|
|
990
1222
|
}
|
|
991
1223
|
const escaped = utils.escapeRegex(prev.value);
|
|
992
|
-
|
|
1224
|
+
state2.output = state2.output.slice(0, -prev.value.length);
|
|
993
1225
|
if (opts.literalBrackets === true) {
|
|
994
|
-
|
|
1226
|
+
state2.output += escaped;
|
|
995
1227
|
prev.value = escaped;
|
|
996
1228
|
continue;
|
|
997
1229
|
}
|
|
998
1230
|
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
999
|
-
|
|
1231
|
+
state2.output += prev.value;
|
|
1000
1232
|
continue;
|
|
1001
1233
|
}
|
|
1002
1234
|
if (value === "{" && opts.nobrace !== true) {
|
|
@@ -1005,8 +1237,8 @@ var require_parse = __commonJS({
|
|
|
1005
1237
|
type: "brace",
|
|
1006
1238
|
value,
|
|
1007
1239
|
output: "(",
|
|
1008
|
-
outputIndex:
|
|
1009
|
-
tokensIndex:
|
|
1240
|
+
outputIndex: state2.output.length,
|
|
1241
|
+
tokensIndex: state2.tokens.length
|
|
1010
1242
|
};
|
|
1011
1243
|
braces.push(open);
|
|
1012
1244
|
push(open);
|
|
@@ -1032,16 +1264,16 @@ var require_parse = __commonJS({
|
|
|
1032
1264
|
}
|
|
1033
1265
|
}
|
|
1034
1266
|
output = expandRange(range, opts);
|
|
1035
|
-
|
|
1267
|
+
state2.backtrack = true;
|
|
1036
1268
|
}
|
|
1037
1269
|
if (brace.comma !== true && brace.dots !== true) {
|
|
1038
|
-
const out =
|
|
1039
|
-
const toks =
|
|
1270
|
+
const out = state2.output.slice(0, brace.outputIndex);
|
|
1271
|
+
const toks = state2.tokens.slice(brace.tokensIndex);
|
|
1040
1272
|
brace.value = brace.output = "\\{";
|
|
1041
1273
|
value = output = "\\}";
|
|
1042
|
-
|
|
1274
|
+
state2.output = out;
|
|
1043
1275
|
for (const t of toks) {
|
|
1044
|
-
|
|
1276
|
+
state2.output += t.output || t.value;
|
|
1045
1277
|
}
|
|
1046
1278
|
}
|
|
1047
1279
|
push({ type: "brace", value, output });
|
|
@@ -1067,10 +1299,10 @@ var require_parse = __commonJS({
|
|
|
1067
1299
|
continue;
|
|
1068
1300
|
}
|
|
1069
1301
|
if (value === "/") {
|
|
1070
|
-
if (prev.type === "dot" &&
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1302
|
+
if (prev.type === "dot" && state2.index === state2.start + 1) {
|
|
1303
|
+
state2.start = state2.index + 1;
|
|
1304
|
+
state2.consumed = "";
|
|
1305
|
+
state2.output = "";
|
|
1074
1306
|
tokens.pop();
|
|
1075
1307
|
prev = bos;
|
|
1076
1308
|
continue;
|
|
@@ -1079,7 +1311,7 @@ var require_parse = __commonJS({
|
|
|
1079
1311
|
continue;
|
|
1080
1312
|
}
|
|
1081
1313
|
if (value === ".") {
|
|
1082
|
-
if (
|
|
1314
|
+
if (state2.braces > 0 && prev.type === "dot") {
|
|
1083
1315
|
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1084
1316
|
const brace = braces[braces.length - 1];
|
|
1085
1317
|
prev.type = "dots";
|
|
@@ -1088,7 +1320,7 @@ var require_parse = __commonJS({
|
|
|
1088
1320
|
brace.dots = true;
|
|
1089
1321
|
continue;
|
|
1090
1322
|
}
|
|
1091
|
-
if (
|
|
1323
|
+
if (state2.braces + state2.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1092
1324
|
push({ type: "text", value, output: DOT_LITERAL });
|
|
1093
1325
|
continue;
|
|
1094
1326
|
}
|
|
@@ -1124,7 +1356,7 @@ var require_parse = __commonJS({
|
|
|
1124
1356
|
continue;
|
|
1125
1357
|
}
|
|
1126
1358
|
}
|
|
1127
|
-
if (opts.nonegate !== true &&
|
|
1359
|
+
if (opts.nonegate !== true && state2.index === 0) {
|
|
1128
1360
|
negate();
|
|
1129
1361
|
continue;
|
|
1130
1362
|
}
|
|
@@ -1138,7 +1370,7 @@ var require_parse = __commonJS({
|
|
|
1138
1370
|
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1139
1371
|
continue;
|
|
1140
1372
|
}
|
|
1141
|
-
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") ||
|
|
1373
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state2.parens > 0) {
|
|
1142
1374
|
push({ type: "plus", value });
|
|
1143
1375
|
continue;
|
|
1144
1376
|
}
|
|
@@ -1160,7 +1392,7 @@ var require_parse = __commonJS({
|
|
|
1160
1392
|
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1161
1393
|
if (match) {
|
|
1162
1394
|
value += match[0];
|
|
1163
|
-
|
|
1395
|
+
state2.index += match[0].length;
|
|
1164
1396
|
}
|
|
1165
1397
|
push({ type: "text", value });
|
|
1166
1398
|
continue;
|
|
@@ -1170,8 +1402,8 @@ var require_parse = __commonJS({
|
|
|
1170
1402
|
prev.star = true;
|
|
1171
1403
|
prev.value += value;
|
|
1172
1404
|
prev.output = star;
|
|
1173
|
-
|
|
1174
|
-
|
|
1405
|
+
state2.backtrack = true;
|
|
1406
|
+
state2.globstar = true;
|
|
1175
1407
|
consume(value);
|
|
1176
1408
|
continue;
|
|
1177
1409
|
}
|
|
@@ -1193,14 +1425,14 @@ var require_parse = __commonJS({
|
|
|
1193
1425
|
push({ type: "star", value, output: "" });
|
|
1194
1426
|
continue;
|
|
1195
1427
|
}
|
|
1196
|
-
const isBrace =
|
|
1428
|
+
const isBrace = state2.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1197
1429
|
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1198
1430
|
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1199
1431
|
push({ type: "star", value, output: "" });
|
|
1200
1432
|
continue;
|
|
1201
1433
|
}
|
|
1202
1434
|
while (rest.slice(0, 3) === "/**") {
|
|
1203
|
-
const after = input[
|
|
1435
|
+
const after = input[state2.index + 4];
|
|
1204
1436
|
if (after && after !== "/") {
|
|
1205
1437
|
break;
|
|
1206
1438
|
}
|
|
@@ -1211,31 +1443,31 @@ var require_parse = __commonJS({
|
|
|
1211
1443
|
prev.type = "globstar";
|
|
1212
1444
|
prev.value += value;
|
|
1213
1445
|
prev.output = globstar(opts);
|
|
1214
|
-
|
|
1215
|
-
|
|
1446
|
+
state2.output = prev.output;
|
|
1447
|
+
state2.globstar = true;
|
|
1216
1448
|
consume(value);
|
|
1217
1449
|
continue;
|
|
1218
1450
|
}
|
|
1219
1451
|
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1220
|
-
|
|
1452
|
+
state2.output = state2.output.slice(0, -(prior.output + prev.output).length);
|
|
1221
1453
|
prior.output = `(?:${prior.output}`;
|
|
1222
1454
|
prev.type = "globstar";
|
|
1223
1455
|
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1224
1456
|
prev.value += value;
|
|
1225
|
-
|
|
1226
|
-
|
|
1457
|
+
state2.globstar = true;
|
|
1458
|
+
state2.output += prior.output + prev.output;
|
|
1227
1459
|
consume(value);
|
|
1228
1460
|
continue;
|
|
1229
1461
|
}
|
|
1230
1462
|
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1231
1463
|
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1232
|
-
|
|
1464
|
+
state2.output = state2.output.slice(0, -(prior.output + prev.output).length);
|
|
1233
1465
|
prior.output = `(?:${prior.output}`;
|
|
1234
1466
|
prev.type = "globstar";
|
|
1235
1467
|
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1236
1468
|
prev.value += value;
|
|
1237
|
-
|
|
1238
|
-
|
|
1469
|
+
state2.output += prior.output + prev.output;
|
|
1470
|
+
state2.globstar = true;
|
|
1239
1471
|
consume(value + advance());
|
|
1240
1472
|
push({ type: "slash", value: "/", output: "" });
|
|
1241
1473
|
continue;
|
|
@@ -1244,18 +1476,18 @@ var require_parse = __commonJS({
|
|
|
1244
1476
|
prev.type = "globstar";
|
|
1245
1477
|
prev.value += value;
|
|
1246
1478
|
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1247
|
-
|
|
1248
|
-
|
|
1479
|
+
state2.output = prev.output;
|
|
1480
|
+
state2.globstar = true;
|
|
1249
1481
|
consume(value + advance());
|
|
1250
1482
|
push({ type: "slash", value: "/", output: "" });
|
|
1251
1483
|
continue;
|
|
1252
1484
|
}
|
|
1253
|
-
|
|
1485
|
+
state2.output = state2.output.slice(0, -prev.output.length);
|
|
1254
1486
|
prev.type = "globstar";
|
|
1255
1487
|
prev.output = globstar(opts);
|
|
1256
1488
|
prev.value += value;
|
|
1257
|
-
|
|
1258
|
-
|
|
1489
|
+
state2.output += prev.output;
|
|
1490
|
+
state2.globstar = true;
|
|
1259
1491
|
consume(value);
|
|
1260
1492
|
continue;
|
|
1261
1493
|
}
|
|
@@ -1273,52 +1505,52 @@ var require_parse = __commonJS({
|
|
|
1273
1505
|
push(token);
|
|
1274
1506
|
continue;
|
|
1275
1507
|
}
|
|
1276
|
-
if (
|
|
1508
|
+
if (state2.index === state2.start || prev.type === "slash" || prev.type === "dot") {
|
|
1277
1509
|
if (prev.type === "dot") {
|
|
1278
|
-
|
|
1510
|
+
state2.output += NO_DOT_SLASH;
|
|
1279
1511
|
prev.output += NO_DOT_SLASH;
|
|
1280
1512
|
} else if (opts.dot === true) {
|
|
1281
|
-
|
|
1513
|
+
state2.output += NO_DOTS_SLASH;
|
|
1282
1514
|
prev.output += NO_DOTS_SLASH;
|
|
1283
1515
|
} else {
|
|
1284
|
-
|
|
1516
|
+
state2.output += nodot;
|
|
1285
1517
|
prev.output += nodot;
|
|
1286
1518
|
}
|
|
1287
1519
|
if (peek() !== "*") {
|
|
1288
|
-
|
|
1520
|
+
state2.output += ONE_CHAR;
|
|
1289
1521
|
prev.output += ONE_CHAR;
|
|
1290
1522
|
}
|
|
1291
1523
|
}
|
|
1292
1524
|
push(token);
|
|
1293
1525
|
}
|
|
1294
|
-
while (
|
|
1526
|
+
while (state2.brackets > 0) {
|
|
1295
1527
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1296
|
-
|
|
1528
|
+
state2.output = utils.escapeLast(state2.output, "[");
|
|
1297
1529
|
decrement("brackets");
|
|
1298
1530
|
}
|
|
1299
|
-
while (
|
|
1531
|
+
while (state2.parens > 0) {
|
|
1300
1532
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1301
|
-
|
|
1533
|
+
state2.output = utils.escapeLast(state2.output, "(");
|
|
1302
1534
|
decrement("parens");
|
|
1303
1535
|
}
|
|
1304
|
-
while (
|
|
1536
|
+
while (state2.braces > 0) {
|
|
1305
1537
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1306
|
-
|
|
1538
|
+
state2.output = utils.escapeLast(state2.output, "{");
|
|
1307
1539
|
decrement("braces");
|
|
1308
1540
|
}
|
|
1309
1541
|
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1310
1542
|
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1311
1543
|
}
|
|
1312
|
-
if (
|
|
1313
|
-
|
|
1314
|
-
for (const token of
|
|
1315
|
-
|
|
1544
|
+
if (state2.backtrack === true) {
|
|
1545
|
+
state2.output = "";
|
|
1546
|
+
for (const token of state2.tokens) {
|
|
1547
|
+
state2.output += token.output != null ? token.output : token.value;
|
|
1316
1548
|
if (token.suffix) {
|
|
1317
|
-
|
|
1549
|
+
state2.output += token.suffix;
|
|
1318
1550
|
}
|
|
1319
1551
|
}
|
|
1320
1552
|
}
|
|
1321
|
-
return
|
|
1553
|
+
return state2;
|
|
1322
1554
|
};
|
|
1323
1555
|
parse.fastpaths = (input, options) => {
|
|
1324
1556
|
const opts = { ...options };
|
|
@@ -1342,7 +1574,7 @@ var require_parse = __commonJS({
|
|
|
1342
1574
|
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1343
1575
|
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1344
1576
|
const capture = opts.capture ? "" : "?:";
|
|
1345
|
-
const
|
|
1577
|
+
const state2 = { negated: false, prefix: "" };
|
|
1346
1578
|
let star = opts.bash === true ? ".*?" : STAR;
|
|
1347
1579
|
if (opts.capture) {
|
|
1348
1580
|
star = `(${star})`;
|
|
@@ -1378,7 +1610,7 @@ var require_parse = __commonJS({
|
|
|
1378
1610
|
}
|
|
1379
1611
|
}
|
|
1380
1612
|
};
|
|
1381
|
-
const output = utils.removePrefix(input,
|
|
1613
|
+
const output = utils.removePrefix(input, state2);
|
|
1382
1614
|
let source = create(output);
|
|
1383
1615
|
if (source && opts.strictSlashes !== true) {
|
|
1384
1616
|
source += `${SLASH_LITERAL}?`;
|
|
@@ -1403,8 +1635,8 @@ var require_picomatch = __commonJS({
|
|
|
1403
1635
|
const fns = glob.map((input) => picomatch2(input, options, returnState));
|
|
1404
1636
|
const arrayMatcher = (str) => {
|
|
1405
1637
|
for (const isMatch of fns) {
|
|
1406
|
-
const
|
|
1407
|
-
if (
|
|
1638
|
+
const state3 = isMatch(str);
|
|
1639
|
+
if (state3) return state3;
|
|
1408
1640
|
}
|
|
1409
1641
|
return false;
|
|
1410
1642
|
};
|
|
@@ -1417,7 +1649,7 @@ var require_picomatch = __commonJS({
|
|
|
1417
1649
|
const opts = options || {};
|
|
1418
1650
|
const posix = opts.windows;
|
|
1419
1651
|
const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
|
|
1420
|
-
const
|
|
1652
|
+
const state2 = regex.state;
|
|
1421
1653
|
delete regex.state;
|
|
1422
1654
|
let isIgnored = () => false;
|
|
1423
1655
|
if (opts.ignore) {
|
|
@@ -1426,7 +1658,7 @@ var require_picomatch = __commonJS({
|
|
|
1426
1658
|
}
|
|
1427
1659
|
const matcher = (input, returnObject = false) => {
|
|
1428
1660
|
const { isMatch, match, output } = picomatch2.test(input, regex, options, { glob, posix });
|
|
1429
|
-
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
1661
|
+
const result = { glob, state: state2, regex, posix, input, output, match, isMatch };
|
|
1430
1662
|
if (typeof opts.onResult === "function") {
|
|
1431
1663
|
opts.onResult(result);
|
|
1432
1664
|
}
|
|
@@ -1447,7 +1679,7 @@ var require_picomatch = __commonJS({
|
|
|
1447
1679
|
return returnObject ? result : true;
|
|
1448
1680
|
};
|
|
1449
1681
|
if (returnState) {
|
|
1450
|
-
matcher.state =
|
|
1682
|
+
matcher.state = state2;
|
|
1451
1683
|
}
|
|
1452
1684
|
return matcher;
|
|
1453
1685
|
};
|
|
@@ -1485,20 +1717,20 @@ var require_picomatch = __commonJS({
|
|
|
1485
1717
|
return parse(pattern, { ...options, fastpaths: false });
|
|
1486
1718
|
};
|
|
1487
1719
|
picomatch2.scan = (input, options) => scan(input, options);
|
|
1488
|
-
picomatch2.compileRe = (
|
|
1720
|
+
picomatch2.compileRe = (state2, options, returnOutput = false, returnState = false) => {
|
|
1489
1721
|
if (returnOutput === true) {
|
|
1490
|
-
return
|
|
1722
|
+
return state2.output;
|
|
1491
1723
|
}
|
|
1492
1724
|
const opts = options || {};
|
|
1493
1725
|
const prepend = opts.contains ? "" : "^";
|
|
1494
1726
|
const append = opts.contains ? "" : "$";
|
|
1495
|
-
let source = `${prepend}(?:${
|
|
1496
|
-
if (
|
|
1727
|
+
let source = `${prepend}(?:${state2.output})${append}`;
|
|
1728
|
+
if (state2 && state2.negated === true) {
|
|
1497
1729
|
source = `^(?!${source}).*$`;
|
|
1498
1730
|
}
|
|
1499
1731
|
const regex = picomatch2.toRegex(source, options);
|
|
1500
1732
|
if (returnState === true) {
|
|
1501
|
-
regex.state =
|
|
1733
|
+
regex.state = state2;
|
|
1502
1734
|
}
|
|
1503
1735
|
return regex;
|
|
1504
1736
|
};
|
|
@@ -2512,9 +2744,12 @@ __export(constants_exports, {
|
|
|
2512
2744
|
ActorInfo: () => ActorInfo,
|
|
2513
2745
|
Code: () => Code,
|
|
2514
2746
|
Device: () => Device,
|
|
2747
|
+
Mode: () => Mode,
|
|
2515
2748
|
PresetOfLiveViewKey: () => PresetOfLiveViewKey,
|
|
2516
2749
|
Status: () => Status,
|
|
2517
|
-
|
|
2750
|
+
mode: () => mode,
|
|
2751
|
+
normalizeDevice: () => normalizeDevice,
|
|
2752
|
+
normalizeMode: () => normalizeMode
|
|
2518
2753
|
});
|
|
2519
2754
|
var Code = {
|
|
2520
2755
|
Success: 0,
|
|
@@ -2534,6 +2769,14 @@ var Device = Object.freeze({
|
|
|
2534
2769
|
Desktop: "desktop",
|
|
2535
2770
|
Mobile: "mobile"
|
|
2536
2771
|
});
|
|
2772
|
+
var Mode = Object.freeze({
|
|
2773
|
+
Default: "default",
|
|
2774
|
+
Cloak: "cloak"
|
|
2775
|
+
});
|
|
2776
|
+
var mode = Object.freeze({
|
|
2777
|
+
default: Mode.Default,
|
|
2778
|
+
cloak: Mode.Cloak
|
|
2779
|
+
});
|
|
2537
2780
|
var normalizeDevice = (value, fallback = Device.Desktop) => {
|
|
2538
2781
|
const normalizedFallback = String(fallback || "").trim().toLowerCase() === Device.Mobile ? Device.Mobile : Device.Desktop;
|
|
2539
2782
|
const raw = String(value || "").trim().toLowerCase();
|
|
@@ -2541,6 +2784,13 @@ var normalizeDevice = (value, fallback = Device.Desktop) => {
|
|
|
2541
2784
|
if (raw === Device.Desktop) return Device.Desktop;
|
|
2542
2785
|
return normalizedFallback;
|
|
2543
2786
|
};
|
|
2787
|
+
var normalizeMode = (value, fallback = Mode.Default) => {
|
|
2788
|
+
const normalizedFallback = String(fallback || "").trim().toLowerCase() === Mode.Cloak ? Mode.Cloak : Mode.Default;
|
|
2789
|
+
const raw = String(value || "").trim().toLowerCase();
|
|
2790
|
+
if (raw === Mode.Cloak) return Mode.Cloak;
|
|
2791
|
+
if (raw === Mode.Default) return Mode.Default;
|
|
2792
|
+
return normalizedFallback;
|
|
2793
|
+
};
|
|
2544
2794
|
var createActorInfo = (info) => {
|
|
2545
2795
|
const normalizeDomain = (value) => {
|
|
2546
2796
|
if (!value) return "";
|
|
@@ -2555,7 +2805,7 @@ var createActorInfo = (info) => {
|
|
|
2555
2805
|
const normalizeShare = (value) => {
|
|
2556
2806
|
const raw = value && typeof value === "object" ? value : {};
|
|
2557
2807
|
const modeRaw = String(raw.mode || "dom").trim().toLowerCase();
|
|
2558
|
-
const
|
|
2808
|
+
const mode2 = ["dom", "response", "custom"].includes(modeRaw) ? modeRaw : "dom";
|
|
2559
2809
|
const prefix = String(raw.prefix || "").trim();
|
|
2560
2810
|
const rawXurl = Array.isArray(raw.xurl) ? raw.xurl : [];
|
|
2561
2811
|
const normalizeMatcherList = (input) => {
|
|
@@ -2600,7 +2850,7 @@ var createActorInfo = (info) => {
|
|
|
2600
2850
|
xurl.push(...extraPaths);
|
|
2601
2851
|
}
|
|
2602
2852
|
return {
|
|
2603
|
-
mode,
|
|
2853
|
+
mode: mode2,
|
|
2604
2854
|
prefix,
|
|
2605
2855
|
xurl
|
|
2606
2856
|
};
|
|
@@ -2608,7 +2858,6 @@ var createActorInfo = (info) => {
|
|
|
2608
2858
|
const buildLandingUrl = ({ protocol: protocol2, domain: domain2, path: path2 }) => {
|
|
2609
2859
|
const safeProtocol = String(protocol2).trim();
|
|
2610
2860
|
const safeDomain = normalizeDomain(domain2);
|
|
2611
|
-
if (!safeDomain) return "";
|
|
2612
2861
|
const safePath = normalizePath(path2);
|
|
2613
2862
|
return `${safeProtocol}://${safeDomain}${safePath}`;
|
|
2614
2863
|
};
|
|
@@ -2816,18 +3065,6 @@ var ActorInfo = {
|
|
|
2816
3065
|
prefix: "",
|
|
2817
3066
|
xurl: []
|
|
2818
3067
|
}
|
|
2819
|
-
}),
|
|
2820
|
-
// 通用网页抓取 Actor:入口 URL 来自 query,因此这里只声明统一的 Actor 元信息。
|
|
2821
|
-
webpage: createActorInfo({
|
|
2822
|
-
key: "webpage",
|
|
2823
|
-
name: "\u901A\u7528\u7F51\u9875",
|
|
2824
|
-
domain: "",
|
|
2825
|
-
path: "/",
|
|
2826
|
-
share: {
|
|
2827
|
-
mode: "dom",
|
|
2828
|
-
prefix: "",
|
|
2829
|
-
xurl: []
|
|
2830
|
-
}
|
|
2831
3068
|
})
|
|
2832
3069
|
};
|
|
2833
3070
|
|
|
@@ -2916,6 +3153,7 @@ var PageRuntimeStateKey = "__playwright_toolkit_runtime_state__";
|
|
|
2916
3153
|
|
|
2917
3154
|
// src/runtime-env.js
|
|
2918
3155
|
var BROWSER_PROFILE_SCHEMA_VERSION = 1;
|
|
3156
|
+
var SUPPORTED_CLOAK_FINGERPRINT_PLATFORMS = /* @__PURE__ */ new Set(["linux", "macos", "windows"]);
|
|
2919
3157
|
var rememberedRuntimeState = null;
|
|
2920
3158
|
var isPlainObject = (value) => value && typeof value === "object" && !Array.isArray(value);
|
|
2921
3159
|
var normalizeKnownDevice = (value) => {
|
|
@@ -2924,6 +3162,22 @@ var normalizeKnownDevice = (value) => {
|
|
|
2924
3162
|
if (raw === Device.Desktop) return Device.Desktop;
|
|
2925
3163
|
return "";
|
|
2926
3164
|
};
|
|
3165
|
+
var normalizeCloakSeed = (value) => {
|
|
3166
|
+
const numericSeed = Number(value);
|
|
3167
|
+
if (Number.isSafeInteger(numericSeed) && numericSeed > 0) {
|
|
3168
|
+
return numericSeed;
|
|
3169
|
+
}
|
|
3170
|
+
const raw = String(value || "").trim();
|
|
3171
|
+
if (!/^\d+$/.test(raw)) {
|
|
3172
|
+
return 0;
|
|
3173
|
+
}
|
|
3174
|
+
const parsedSeed = Number(raw);
|
|
3175
|
+
return Number.isSafeInteger(parsedSeed) && parsedSeed > 0 ? parsedSeed : 0;
|
|
3176
|
+
};
|
|
3177
|
+
var normalizeCloakFingerprintPlatform = (value) => {
|
|
3178
|
+
const raw = String(value || "").trim().toLowerCase();
|
|
3179
|
+
return SUPPORTED_CLOAK_FINGERPRINT_PLATFORMS.has(raw) ? raw : "";
|
|
3180
|
+
};
|
|
2927
3181
|
var deepClone = (value) => {
|
|
2928
3182
|
if (value == null) return value;
|
|
2929
3183
|
try {
|
|
@@ -3297,6 +3551,14 @@ var normalizeBrowserProfileCore = (value) => {
|
|
|
3297
3551
|
if (Number.isFinite(browserMajorVersion) && browserMajorVersion > 0) {
|
|
3298
3552
|
profile.browser_major_version = browserMajorVersion;
|
|
3299
3553
|
}
|
|
3554
|
+
const cloakSeed = normalizeCloakSeed(source.cloak_seed);
|
|
3555
|
+
if (cloakSeed > 0) {
|
|
3556
|
+
profile.cloak_seed = cloakSeed;
|
|
3557
|
+
}
|
|
3558
|
+
const cloakFingerprintPlatform = normalizeCloakFingerprintPlatform(source.cloak_fingerprint_platform);
|
|
3559
|
+
if (cloakFingerprintPlatform) {
|
|
3560
|
+
profile.cloak_fingerprint_platform = cloakFingerprintPlatform;
|
|
3561
|
+
}
|
|
3300
3562
|
const schemaVersion = Number(source.schema_version || 0);
|
|
3301
3563
|
if (Number.isFinite(schemaVersion) && schemaVersion > 0) {
|
|
3302
3564
|
profile.schema_version = schemaVersion;
|
|
@@ -3384,8 +3646,8 @@ var normalizeBrowserProfile = (value) => {
|
|
|
3384
3646
|
payload: buildBrowserProfilePayload(core, observed)
|
|
3385
3647
|
};
|
|
3386
3648
|
};
|
|
3387
|
-
var rememberRuntimeState = (
|
|
3388
|
-
rememberedRuntimeState = deepClone(
|
|
3649
|
+
var rememberRuntimeState = (state2) => {
|
|
3650
|
+
rememberedRuntimeState = deepClone(state2);
|
|
3389
3651
|
return rememberedRuntimeState;
|
|
3390
3652
|
};
|
|
3391
3653
|
var normalizeRuntimeState = (source = {}, actor = "") => {
|
|
@@ -3445,7 +3707,7 @@ var RuntimeEnv = {
|
|
|
3445
3707
|
} else {
|
|
3446
3708
|
delete normalizedRuntime.browser_profile;
|
|
3447
3709
|
}
|
|
3448
|
-
const
|
|
3710
|
+
const state2 = {
|
|
3449
3711
|
actor: resolvedActor,
|
|
3450
3712
|
device,
|
|
3451
3713
|
runtime: normalizedRuntime,
|
|
@@ -3459,73 +3721,73 @@ var RuntimeEnv = {
|
|
|
3459
3721
|
browserProfileCore: browserProfile.core,
|
|
3460
3722
|
browserProfileObserved: browserProfile.observed
|
|
3461
3723
|
};
|
|
3462
|
-
rememberRuntimeState(
|
|
3463
|
-
return
|
|
3724
|
+
rememberRuntimeState(state2);
|
|
3725
|
+
return state2;
|
|
3464
3726
|
},
|
|
3465
3727
|
// buildEnvPatch 只构造允许回写到后端 env 的字段集合。
|
|
3466
3728
|
buildEnvPatch(source = {}, actor = "") {
|
|
3467
|
-
const
|
|
3468
|
-
const browserProfile = buildBrowserProfilePayload(
|
|
3729
|
+
const state2 = normalizeRuntimeState(source, actor);
|
|
3730
|
+
const browserProfile = buildBrowserProfilePayload(state2.browserProfileCore, state2.browserProfileObserved);
|
|
3469
3731
|
const envPatch = {
|
|
3470
|
-
...Array.isArray(
|
|
3471
|
-
...Object.keys(
|
|
3472
|
-
...Object.keys(
|
|
3732
|
+
...Array.isArray(state2.cookies) && state2.cookies.length > 0 ? { cookies: state2.cookies } : {},
|
|
3733
|
+
...Object.keys(state2.localStorage || {}).length > 0 ? { local_storage: state2.localStorage } : {},
|
|
3734
|
+
...Object.keys(state2.sessionStorage || {}).length > 0 ? { session_storage: state2.sessionStorage } : {},
|
|
3473
3735
|
...Object.keys(browserProfile).length > 0 ? { browser_profile: browserProfile } : {}
|
|
3474
3736
|
};
|
|
3475
3737
|
return Object.keys(envPatch).length > 0 ? envPatch : null;
|
|
3476
3738
|
},
|
|
3477
3739
|
// hasLoginState 只判断 runtime 是否存在有效载荷,不再区分具体字段来源。
|
|
3478
3740
|
hasLoginState(source = {}, actor = "") {
|
|
3479
|
-
const
|
|
3480
|
-
return isPlainObject(
|
|
3741
|
+
const state2 = normalizeRuntimeState(source, actor);
|
|
3742
|
+
return isPlainObject(state2.runtime) && Object.keys(state2.runtime || {}).length > 0;
|
|
3481
3743
|
},
|
|
3482
3744
|
rememberState(source = {}) {
|
|
3483
|
-
const
|
|
3484
|
-
rememberRuntimeState(
|
|
3745
|
+
const state2 = normalizeRuntimeState(source);
|
|
3746
|
+
rememberRuntimeState(state2);
|
|
3485
3747
|
return RuntimeEnv.peekRememberedState();
|
|
3486
3748
|
},
|
|
3487
3749
|
peekRememberedState() {
|
|
3488
3750
|
return rememberedRuntimeState ? deepClone(rememberedRuntimeState) : null;
|
|
3489
3751
|
},
|
|
3490
3752
|
getBrowserProfileCore(source = {}, actor = "") {
|
|
3491
|
-
const
|
|
3492
|
-
return deepClone(
|
|
3753
|
+
const state2 = normalizeRuntimeState(source, actor);
|
|
3754
|
+
return deepClone(state2.browserProfileCore || {});
|
|
3493
3755
|
},
|
|
3494
3756
|
setBrowserProfileCore(source = {}, core = {}, actor = "") {
|
|
3495
|
-
const
|
|
3757
|
+
const state2 = normalizeRuntimeState(source, actor);
|
|
3496
3758
|
const normalizedCore = normalizeBrowserProfileCore({
|
|
3497
3759
|
...core,
|
|
3498
|
-
device: normalizeKnownDevice(core == null ? void 0 : core.device) ||
|
|
3760
|
+
device: normalizeKnownDevice(core == null ? void 0 : core.device) || state2.device
|
|
3499
3761
|
});
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
if (Object.keys(
|
|
3503
|
-
|
|
3762
|
+
state2.browserProfileCore = normalizedCore;
|
|
3763
|
+
state2.browserProfile = buildBrowserProfilePayload(normalizedCore, state2.browserProfileObserved);
|
|
3764
|
+
if (Object.keys(state2.browserProfile).length > 0) {
|
|
3765
|
+
state2.runtime.browser_profile = state2.browserProfile;
|
|
3504
3766
|
} else {
|
|
3505
|
-
delete
|
|
3767
|
+
delete state2.runtime.browser_profile;
|
|
3506
3768
|
}
|
|
3507
|
-
rememberRuntimeState(
|
|
3508
|
-
return
|
|
3769
|
+
rememberRuntimeState(state2);
|
|
3770
|
+
return state2;
|
|
3509
3771
|
},
|
|
3510
3772
|
// applyToPage 只负责把登录态相关字段注入页面:
|
|
3511
3773
|
// cookies / localStorage / sessionStorage。
|
|
3512
3774
|
// 指纹、时区、UA、viewport 的回放发生在 launch.js 启动阶段,不在这里做。
|
|
3513
3775
|
async applyToPage(page, source = {}, options = {}) {
|
|
3514
3776
|
if (!page) return;
|
|
3515
|
-
let
|
|
3777
|
+
let state2 = normalizeRuntimeState(source, (options == null ? void 0 : options.actor) || "");
|
|
3516
3778
|
if (typeof (options == null ? void 0 : options.preapply) === "function") {
|
|
3517
|
-
|
|
3518
|
-
rememberRuntimeState(
|
|
3779
|
+
state2 = await options.preapply(state2) || state2;
|
|
3780
|
+
rememberRuntimeState(state2);
|
|
3519
3781
|
}
|
|
3520
3782
|
Object.defineProperty(page, PageRuntimeStateKey, {
|
|
3521
3783
|
configurable: true,
|
|
3522
3784
|
enumerable: false,
|
|
3523
3785
|
writable: true,
|
|
3524
|
-
value:
|
|
3786
|
+
value: state2
|
|
3525
3787
|
});
|
|
3526
|
-
const localStorage =
|
|
3527
|
-
const sessionStorage =
|
|
3528
|
-
const cookies = (
|
|
3788
|
+
const localStorage = state2.localStorage || {};
|
|
3789
|
+
const sessionStorage = state2.sessionStorage || {};
|
|
3790
|
+
const cookies = (state2.cookies || []).map((cookie) => {
|
|
3529
3791
|
const normalized = { ...cookie };
|
|
3530
3792
|
if (!normalized.path) {
|
|
3531
3793
|
normalized.path = "/";
|
|
@@ -3563,8 +3825,8 @@ var RuntimeEnv = {
|
|
|
3563
3825
|
},
|
|
3564
3826
|
// captureEnvPatch 在任务结束时采集最新环境快照,用于 pushSuccess / pushFailed 自动回写。
|
|
3565
3827
|
async captureEnvPatch(page, source = {}, options = {}) {
|
|
3566
|
-
const
|
|
3567
|
-
const baseline = RuntimeEnv.buildEnvPatch(
|
|
3828
|
+
const state2 = normalizeRuntimeState(source, (options == null ? void 0 : options.actor) || "");
|
|
3829
|
+
const baseline = RuntimeEnv.buildEnvPatch(state2) || {};
|
|
3568
3830
|
if (!page || typeof page.evaluate !== "function" || typeof page.context !== "function") {
|
|
3569
3831
|
return Object.keys(baseline).length > 0 ? baseline : null;
|
|
3570
3832
|
}
|
|
@@ -3583,7 +3845,7 @@ var RuntimeEnv = {
|
|
|
3583
3845
|
cookies
|
|
3584
3846
|
},
|
|
3585
3847
|
{
|
|
3586
|
-
browserProfileCore:
|
|
3848
|
+
browserProfileCore: state2.browserProfileCore
|
|
3587
3849
|
}
|
|
3588
3850
|
);
|
|
3589
3851
|
return RuntimeEnv.mergeEnvPatches(baseline, capturedPatch);
|
|
@@ -3593,8 +3855,28 @@ var RuntimeEnv = {
|
|
|
3593
3855
|
}
|
|
3594
3856
|
};
|
|
3595
3857
|
|
|
3858
|
+
// src/internals/context.js
|
|
3859
|
+
var state = {
|
|
3860
|
+
mode: Mode.Default
|
|
3861
|
+
};
|
|
3862
|
+
var ToolkitContext = {
|
|
3863
|
+
get mode() {
|
|
3864
|
+
return state.mode;
|
|
3865
|
+
},
|
|
3866
|
+
setMode(mode2 = Mode.Default) {
|
|
3867
|
+
state.mode = normalizeMode(mode2, Mode.Default);
|
|
3868
|
+
return state.mode;
|
|
3869
|
+
}
|
|
3870
|
+
};
|
|
3871
|
+
var setToolkitMode = (mode2 = Mode.Default) => ToolkitContext.setMode(mode2);
|
|
3872
|
+
|
|
3596
3873
|
// entrys/browser.js
|
|
3874
|
+
var ToolkitMode = Object.freeze({
|
|
3875
|
+
default: Mode.Default,
|
|
3876
|
+
cloak: Mode.Cloak
|
|
3877
|
+
});
|
|
3597
3878
|
var usePlaywrightToolKit = () => {
|
|
3879
|
+
setToolkitMode(Mode.Default);
|
|
3598
3880
|
return {
|
|
3599
3881
|
Logger,
|
|
3600
3882
|
Display,
|
|
@@ -3607,6 +3889,7 @@ var usePlaywrightToolKit = () => {
|
|
|
3607
3889
|
}
|
|
3608
3890
|
};
|
|
3609
3891
|
};
|
|
3892
|
+
usePlaywrightToolKit.Mode = ToolkitMode;
|
|
3610
3893
|
export {
|
|
3611
3894
|
usePlaywrightToolKit
|
|
3612
3895
|
};
|