@skrillex1224/playwright-toolkit 3.0.14 → 3.0.15
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/browser.js +161 -409
- package/dist/browser.js.map +4 -4
- package/dist/index.cjs +479 -992
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +479 -992
- package/dist/index.js.map +4 -4
- package/index.d.ts +9 -40
- package/package.json +1 -7
package/dist/browser.js
CHANGED
|
@@ -34,7 +34,6 @@ 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;
|
|
38
37
|
var DOT_LITERAL = "\\.";
|
|
39
38
|
var PLUS_LITERAL = "\\+";
|
|
40
39
|
var QMARK_LITERAL = "\\?";
|
|
@@ -85,7 +84,6 @@ var require_constants = __commonJS({
|
|
|
85
84
|
SEP: "\\"
|
|
86
85
|
};
|
|
87
86
|
var POSIX_REGEX_SOURCE = {
|
|
88
|
-
__proto__: null,
|
|
89
87
|
alnum: "a-zA-Z0-9",
|
|
90
88
|
alpha: "a-zA-Z",
|
|
91
89
|
ascii: "\\x00-\\x7F",
|
|
@@ -102,7 +100,6 @@ var require_constants = __commonJS({
|
|
|
102
100
|
xdigit: "A-Fa-f0-9"
|
|
103
101
|
};
|
|
104
102
|
module.exports = {
|
|
105
|
-
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
106
103
|
MAX_LENGTH: 1024 * 64,
|
|
107
104
|
POSIX_REGEX_SOURCE,
|
|
108
105
|
// regular expressions
|
|
@@ -266,19 +263,19 @@ var require_utils = __commonJS({
|
|
|
266
263
|
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
267
264
|
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
268
265
|
};
|
|
269
|
-
exports.removePrefix = (input,
|
|
266
|
+
exports.removePrefix = (input, state = {}) => {
|
|
270
267
|
let output = input;
|
|
271
268
|
if (output.startsWith("./")) {
|
|
272
269
|
output = output.slice(2);
|
|
273
|
-
|
|
270
|
+
state.prefix = "./";
|
|
274
271
|
}
|
|
275
272
|
return output;
|
|
276
273
|
};
|
|
277
|
-
exports.wrapOutput = (input,
|
|
274
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
278
275
|
const prepend = options.contains ? "" : "^";
|
|
279
276
|
const append = options.contains ? "" : "$";
|
|
280
277
|
let output = `${prepend}(?:${input})${append}`;
|
|
281
|
-
if (
|
|
278
|
+
if (state.negated === true) {
|
|
282
279
|
output = `(?:^(?!${output}).*$)`;
|
|
283
280
|
}
|
|
284
281
|
return output;
|
|
@@ -564,7 +561,7 @@ var require_scan = __commonJS({
|
|
|
564
561
|
base = utils.removeBackslashes(base);
|
|
565
562
|
}
|
|
566
563
|
}
|
|
567
|
-
const
|
|
564
|
+
const state = {
|
|
568
565
|
prefix,
|
|
569
566
|
input,
|
|
570
567
|
start,
|
|
@@ -579,11 +576,11 @@ var require_scan = __commonJS({
|
|
|
579
576
|
negatedExtglob
|
|
580
577
|
};
|
|
581
578
|
if (opts.tokens === true) {
|
|
582
|
-
|
|
579
|
+
state.maxDepth = 0;
|
|
583
580
|
if (!isPathSeparator(code)) {
|
|
584
581
|
tokens.push(token);
|
|
585
582
|
}
|
|
586
|
-
|
|
583
|
+
state.tokens = tokens;
|
|
587
584
|
}
|
|
588
585
|
if (opts.parts === true || opts.tokens === true) {
|
|
589
586
|
let prevIndex;
|
|
@@ -599,7 +596,7 @@ var require_scan = __commonJS({
|
|
|
599
596
|
tokens[idx].value = value;
|
|
600
597
|
}
|
|
601
598
|
depth(tokens[idx]);
|
|
602
|
-
|
|
599
|
+
state.maxDepth += tokens[idx].depth;
|
|
603
600
|
}
|
|
604
601
|
if (idx !== 0 || value !== "") {
|
|
605
602
|
parts.push(value);
|
|
@@ -612,13 +609,13 @@ var require_scan = __commonJS({
|
|
|
612
609
|
if (opts.tokens) {
|
|
613
610
|
tokens[tokens.length - 1].value = value;
|
|
614
611
|
depth(tokens[tokens.length - 1]);
|
|
615
|
-
|
|
612
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
616
613
|
}
|
|
617
614
|
}
|
|
618
|
-
|
|
619
|
-
|
|
615
|
+
state.slashes = slashes;
|
|
616
|
+
state.parts = parts;
|
|
620
617
|
}
|
|
621
|
-
return
|
|
618
|
+
return state;
|
|
622
619
|
};
|
|
623
620
|
module.exports = scan;
|
|
624
621
|
}
|
|
@@ -653,213 +650,6 @@ var require_parse = __commonJS({
|
|
|
653
650
|
var syntaxError = (type, char) => {
|
|
654
651
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
655
652
|
};
|
|
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
|
-
};
|
|
863
653
|
var parse = (input, options) => {
|
|
864
654
|
if (typeof input !== "string") {
|
|
865
655
|
throw new TypeError("Expected a string");
|
|
@@ -902,7 +692,7 @@ var require_parse = __commonJS({
|
|
|
902
692
|
if (typeof opts.noext === "boolean") {
|
|
903
693
|
opts.noextglob = opts.noext;
|
|
904
694
|
}
|
|
905
|
-
const
|
|
695
|
+
const state = {
|
|
906
696
|
input,
|
|
907
697
|
index: -1,
|
|
908
698
|
start: 0,
|
|
@@ -919,57 +709,57 @@ var require_parse = __commonJS({
|
|
|
919
709
|
globstar: false,
|
|
920
710
|
tokens
|
|
921
711
|
};
|
|
922
|
-
input = utils.removePrefix(input,
|
|
712
|
+
input = utils.removePrefix(input, state);
|
|
923
713
|
len = input.length;
|
|
924
714
|
const extglobs = [];
|
|
925
715
|
const braces = [];
|
|
926
716
|
const stack = [];
|
|
927
717
|
let prev = bos;
|
|
928
718
|
let value;
|
|
929
|
-
const eos = () =>
|
|
930
|
-
const peek =
|
|
931
|
-
const advance =
|
|
932
|
-
const remaining = () => input.slice(
|
|
719
|
+
const eos = () => state.index === len - 1;
|
|
720
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
721
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
722
|
+
const remaining = () => input.slice(state.index + 1);
|
|
933
723
|
const consume = (value2 = "", num = 0) => {
|
|
934
|
-
|
|
935
|
-
|
|
724
|
+
state.consumed += value2;
|
|
725
|
+
state.index += num;
|
|
936
726
|
};
|
|
937
727
|
const append = (token) => {
|
|
938
|
-
|
|
728
|
+
state.output += token.output != null ? token.output : token.value;
|
|
939
729
|
consume(token.value);
|
|
940
730
|
};
|
|
941
731
|
const negate = () => {
|
|
942
732
|
let count = 1;
|
|
943
733
|
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
944
734
|
advance();
|
|
945
|
-
|
|
735
|
+
state.start++;
|
|
946
736
|
count++;
|
|
947
737
|
}
|
|
948
738
|
if (count % 2 === 0) {
|
|
949
739
|
return false;
|
|
950
740
|
}
|
|
951
|
-
|
|
952
|
-
|
|
741
|
+
state.negated = true;
|
|
742
|
+
state.start++;
|
|
953
743
|
return true;
|
|
954
744
|
};
|
|
955
745
|
const increment = (type) => {
|
|
956
|
-
|
|
746
|
+
state[type]++;
|
|
957
747
|
stack.push(type);
|
|
958
748
|
};
|
|
959
749
|
const decrement = (type) => {
|
|
960
|
-
|
|
750
|
+
state[type]--;
|
|
961
751
|
stack.pop();
|
|
962
752
|
};
|
|
963
753
|
const push = (tok) => {
|
|
964
754
|
if (prev.type === "globstar") {
|
|
965
|
-
const isBrace =
|
|
755
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
966
756
|
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
967
757
|
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
968
|
-
|
|
758
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
969
759
|
prev.type = "star";
|
|
970
760
|
prev.value = "*";
|
|
971
761
|
prev.output = star;
|
|
972
|
-
|
|
762
|
+
state.output += prev.output;
|
|
973
763
|
}
|
|
974
764
|
}
|
|
975
765
|
if (extglobs.length && tok.type !== "paren") {
|
|
@@ -988,37 +778,15 @@ var require_parse = __commonJS({
|
|
|
988
778
|
const extglobOpen = (type, value2) => {
|
|
989
779
|
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
990
780
|
token.prev = prev;
|
|
991
|
-
token.parens =
|
|
992
|
-
token.output =
|
|
993
|
-
token.startIndex = state2.index;
|
|
994
|
-
token.tokensIndex = tokens.length;
|
|
781
|
+
token.parens = state.parens;
|
|
782
|
+
token.output = state.output;
|
|
995
783
|
const output = (opts.capture ? "(" : "") + token.open;
|
|
996
784
|
increment("parens");
|
|
997
|
-
push({ type, value: value2, output:
|
|
785
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
998
786
|
push({ type: "paren", extglob: true, value: advance(), output });
|
|
999
787
|
extglobs.push(token);
|
|
1000
788
|
};
|
|
1001
789
|
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
|
-
}
|
|
1022
790
|
let output = token.close + (opts.capture ? ")" : "");
|
|
1023
791
|
let rest;
|
|
1024
792
|
if (token.type === "negate") {
|
|
@@ -1034,7 +802,7 @@ var require_parse = __commonJS({
|
|
|
1034
802
|
output = token.close = `)${expression})${extglobStar})`;
|
|
1035
803
|
}
|
|
1036
804
|
if (token.prev.type === "bos") {
|
|
1037
|
-
|
|
805
|
+
state.negatedExtglob = true;
|
|
1038
806
|
}
|
|
1039
807
|
}
|
|
1040
808
|
push({ type: "paren", extglob: true, value, output });
|
|
@@ -1077,11 +845,11 @@ var require_parse = __commonJS({
|
|
|
1077
845
|
}
|
|
1078
846
|
}
|
|
1079
847
|
if (output === input && opts.contains === true) {
|
|
1080
|
-
|
|
1081
|
-
return
|
|
848
|
+
state.output = input;
|
|
849
|
+
return state;
|
|
1082
850
|
}
|
|
1083
|
-
|
|
1084
|
-
return
|
|
851
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
852
|
+
return state;
|
|
1085
853
|
}
|
|
1086
854
|
while (!eos()) {
|
|
1087
855
|
value = advance();
|
|
@@ -1105,7 +873,7 @@ var require_parse = __commonJS({
|
|
|
1105
873
|
let slashes = 0;
|
|
1106
874
|
if (match && match[0].length > 2) {
|
|
1107
875
|
slashes = match[0].length;
|
|
1108
|
-
|
|
876
|
+
state.index += slashes;
|
|
1109
877
|
if (slashes % 2 !== 0) {
|
|
1110
878
|
value += "\\";
|
|
1111
879
|
}
|
|
@@ -1115,12 +883,12 @@ var require_parse = __commonJS({
|
|
|
1115
883
|
} else {
|
|
1116
884
|
value += advance();
|
|
1117
885
|
}
|
|
1118
|
-
if (
|
|
886
|
+
if (state.brackets === 0) {
|
|
1119
887
|
push({ type: "text", value });
|
|
1120
888
|
continue;
|
|
1121
889
|
}
|
|
1122
890
|
}
|
|
1123
|
-
if (
|
|
891
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1124
892
|
if (opts.posix !== false && value === ":") {
|
|
1125
893
|
const inner = prev.value.slice(1);
|
|
1126
894
|
if (inner.includes("[")) {
|
|
@@ -1132,7 +900,7 @@ var require_parse = __commonJS({
|
|
|
1132
900
|
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
1133
901
|
if (posix) {
|
|
1134
902
|
prev.value = pre + posix;
|
|
1135
|
-
|
|
903
|
+
state.backtrack = true;
|
|
1136
904
|
advance();
|
|
1137
905
|
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
1138
906
|
bos.output = ONE_CHAR;
|
|
@@ -1155,14 +923,14 @@ var require_parse = __commonJS({
|
|
|
1155
923
|
append({ value });
|
|
1156
924
|
continue;
|
|
1157
925
|
}
|
|
1158
|
-
if (
|
|
926
|
+
if (state.quotes === 1 && value !== '"') {
|
|
1159
927
|
value = utils.escapeRegex(value);
|
|
1160
928
|
prev.value += value;
|
|
1161
929
|
append({ value });
|
|
1162
930
|
continue;
|
|
1163
931
|
}
|
|
1164
932
|
if (value === '"') {
|
|
1165
|
-
|
|
933
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1166
934
|
if (opts.keepQuotes === true) {
|
|
1167
935
|
push({ type: "text", value });
|
|
1168
936
|
}
|
|
@@ -1174,15 +942,15 @@ var require_parse = __commonJS({
|
|
|
1174
942
|
continue;
|
|
1175
943
|
}
|
|
1176
944
|
if (value === ")") {
|
|
1177
|
-
if (
|
|
945
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
1178
946
|
throw new SyntaxError(syntaxError("opening", "("));
|
|
1179
947
|
}
|
|
1180
948
|
const extglob = extglobs[extglobs.length - 1];
|
|
1181
|
-
if (extglob &&
|
|
949
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1182
950
|
extglobClose(extglobs.pop());
|
|
1183
951
|
continue;
|
|
1184
952
|
}
|
|
1185
|
-
push({ type: "paren", value, output:
|
|
953
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
1186
954
|
decrement("parens");
|
|
1187
955
|
continue;
|
|
1188
956
|
}
|
|
@@ -1203,7 +971,7 @@ var require_parse = __commonJS({
|
|
|
1203
971
|
push({ type: "text", value, output: `\\${value}` });
|
|
1204
972
|
continue;
|
|
1205
973
|
}
|
|
1206
|
-
if (
|
|
974
|
+
if (state.brackets === 0) {
|
|
1207
975
|
if (opts.strictBrackets === true) {
|
|
1208
976
|
throw new SyntaxError(syntaxError("opening", "["));
|
|
1209
977
|
}
|
|
@@ -1221,14 +989,14 @@ var require_parse = __commonJS({
|
|
|
1221
989
|
continue;
|
|
1222
990
|
}
|
|
1223
991
|
const escaped = utils.escapeRegex(prev.value);
|
|
1224
|
-
|
|
992
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1225
993
|
if (opts.literalBrackets === true) {
|
|
1226
|
-
|
|
994
|
+
state.output += escaped;
|
|
1227
995
|
prev.value = escaped;
|
|
1228
996
|
continue;
|
|
1229
997
|
}
|
|
1230
998
|
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1231
|
-
|
|
999
|
+
state.output += prev.value;
|
|
1232
1000
|
continue;
|
|
1233
1001
|
}
|
|
1234
1002
|
if (value === "{" && opts.nobrace !== true) {
|
|
@@ -1237,8 +1005,8 @@ var require_parse = __commonJS({
|
|
|
1237
1005
|
type: "brace",
|
|
1238
1006
|
value,
|
|
1239
1007
|
output: "(",
|
|
1240
|
-
outputIndex:
|
|
1241
|
-
tokensIndex:
|
|
1008
|
+
outputIndex: state.output.length,
|
|
1009
|
+
tokensIndex: state.tokens.length
|
|
1242
1010
|
};
|
|
1243
1011
|
braces.push(open);
|
|
1244
1012
|
push(open);
|
|
@@ -1264,16 +1032,16 @@ var require_parse = __commonJS({
|
|
|
1264
1032
|
}
|
|
1265
1033
|
}
|
|
1266
1034
|
output = expandRange(range, opts);
|
|
1267
|
-
|
|
1035
|
+
state.backtrack = true;
|
|
1268
1036
|
}
|
|
1269
1037
|
if (brace.comma !== true && brace.dots !== true) {
|
|
1270
|
-
const out =
|
|
1271
|
-
const toks =
|
|
1038
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1039
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1272
1040
|
brace.value = brace.output = "\\{";
|
|
1273
1041
|
value = output = "\\}";
|
|
1274
|
-
|
|
1042
|
+
state.output = out;
|
|
1275
1043
|
for (const t of toks) {
|
|
1276
|
-
|
|
1044
|
+
state.output += t.output || t.value;
|
|
1277
1045
|
}
|
|
1278
1046
|
}
|
|
1279
1047
|
push({ type: "brace", value, output });
|
|
@@ -1299,10 +1067,10 @@ var require_parse = __commonJS({
|
|
|
1299
1067
|
continue;
|
|
1300
1068
|
}
|
|
1301
1069
|
if (value === "/") {
|
|
1302
|
-
if (prev.type === "dot" &&
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1070
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1071
|
+
state.start = state.index + 1;
|
|
1072
|
+
state.consumed = "";
|
|
1073
|
+
state.output = "";
|
|
1306
1074
|
tokens.pop();
|
|
1307
1075
|
prev = bos;
|
|
1308
1076
|
continue;
|
|
@@ -1311,7 +1079,7 @@ var require_parse = __commonJS({
|
|
|
1311
1079
|
continue;
|
|
1312
1080
|
}
|
|
1313
1081
|
if (value === ".") {
|
|
1314
|
-
if (
|
|
1082
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1315
1083
|
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1316
1084
|
const brace = braces[braces.length - 1];
|
|
1317
1085
|
prev.type = "dots";
|
|
@@ -1320,7 +1088,7 @@ var require_parse = __commonJS({
|
|
|
1320
1088
|
brace.dots = true;
|
|
1321
1089
|
continue;
|
|
1322
1090
|
}
|
|
1323
|
-
if (
|
|
1091
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1324
1092
|
push({ type: "text", value, output: DOT_LITERAL });
|
|
1325
1093
|
continue;
|
|
1326
1094
|
}
|
|
@@ -1356,7 +1124,7 @@ var require_parse = __commonJS({
|
|
|
1356
1124
|
continue;
|
|
1357
1125
|
}
|
|
1358
1126
|
}
|
|
1359
|
-
if (opts.nonegate !== true &&
|
|
1127
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1360
1128
|
negate();
|
|
1361
1129
|
continue;
|
|
1362
1130
|
}
|
|
@@ -1370,7 +1138,7 @@ var require_parse = __commonJS({
|
|
|
1370
1138
|
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1371
1139
|
continue;
|
|
1372
1140
|
}
|
|
1373
|
-
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") ||
|
|
1141
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1374
1142
|
push({ type: "plus", value });
|
|
1375
1143
|
continue;
|
|
1376
1144
|
}
|
|
@@ -1392,7 +1160,7 @@ var require_parse = __commonJS({
|
|
|
1392
1160
|
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1393
1161
|
if (match) {
|
|
1394
1162
|
value += match[0];
|
|
1395
|
-
|
|
1163
|
+
state.index += match[0].length;
|
|
1396
1164
|
}
|
|
1397
1165
|
push({ type: "text", value });
|
|
1398
1166
|
continue;
|
|
@@ -1402,8 +1170,8 @@ var require_parse = __commonJS({
|
|
|
1402
1170
|
prev.star = true;
|
|
1403
1171
|
prev.value += value;
|
|
1404
1172
|
prev.output = star;
|
|
1405
|
-
|
|
1406
|
-
|
|
1173
|
+
state.backtrack = true;
|
|
1174
|
+
state.globstar = true;
|
|
1407
1175
|
consume(value);
|
|
1408
1176
|
continue;
|
|
1409
1177
|
}
|
|
@@ -1425,14 +1193,14 @@ var require_parse = __commonJS({
|
|
|
1425
1193
|
push({ type: "star", value, output: "" });
|
|
1426
1194
|
continue;
|
|
1427
1195
|
}
|
|
1428
|
-
const isBrace =
|
|
1196
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1429
1197
|
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1430
1198
|
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1431
1199
|
push({ type: "star", value, output: "" });
|
|
1432
1200
|
continue;
|
|
1433
1201
|
}
|
|
1434
1202
|
while (rest.slice(0, 3) === "/**") {
|
|
1435
|
-
const after = input[
|
|
1203
|
+
const after = input[state.index + 4];
|
|
1436
1204
|
if (after && after !== "/") {
|
|
1437
1205
|
break;
|
|
1438
1206
|
}
|
|
@@ -1443,31 +1211,31 @@ var require_parse = __commonJS({
|
|
|
1443
1211
|
prev.type = "globstar";
|
|
1444
1212
|
prev.value += value;
|
|
1445
1213
|
prev.output = globstar(opts);
|
|
1446
|
-
|
|
1447
|
-
|
|
1214
|
+
state.output = prev.output;
|
|
1215
|
+
state.globstar = true;
|
|
1448
1216
|
consume(value);
|
|
1449
1217
|
continue;
|
|
1450
1218
|
}
|
|
1451
1219
|
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1452
|
-
|
|
1220
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1453
1221
|
prior.output = `(?:${prior.output}`;
|
|
1454
1222
|
prev.type = "globstar";
|
|
1455
1223
|
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1456
1224
|
prev.value += value;
|
|
1457
|
-
|
|
1458
|
-
|
|
1225
|
+
state.globstar = true;
|
|
1226
|
+
state.output += prior.output + prev.output;
|
|
1459
1227
|
consume(value);
|
|
1460
1228
|
continue;
|
|
1461
1229
|
}
|
|
1462
1230
|
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1463
1231
|
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1464
|
-
|
|
1232
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1465
1233
|
prior.output = `(?:${prior.output}`;
|
|
1466
1234
|
prev.type = "globstar";
|
|
1467
1235
|
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1468
1236
|
prev.value += value;
|
|
1469
|
-
|
|
1470
|
-
|
|
1237
|
+
state.output += prior.output + prev.output;
|
|
1238
|
+
state.globstar = true;
|
|
1471
1239
|
consume(value + advance());
|
|
1472
1240
|
push({ type: "slash", value: "/", output: "" });
|
|
1473
1241
|
continue;
|
|
@@ -1476,18 +1244,18 @@ var require_parse = __commonJS({
|
|
|
1476
1244
|
prev.type = "globstar";
|
|
1477
1245
|
prev.value += value;
|
|
1478
1246
|
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1479
|
-
|
|
1480
|
-
|
|
1247
|
+
state.output = prev.output;
|
|
1248
|
+
state.globstar = true;
|
|
1481
1249
|
consume(value + advance());
|
|
1482
1250
|
push({ type: "slash", value: "/", output: "" });
|
|
1483
1251
|
continue;
|
|
1484
1252
|
}
|
|
1485
|
-
|
|
1253
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1486
1254
|
prev.type = "globstar";
|
|
1487
1255
|
prev.output = globstar(opts);
|
|
1488
1256
|
prev.value += value;
|
|
1489
|
-
|
|
1490
|
-
|
|
1257
|
+
state.output += prev.output;
|
|
1258
|
+
state.globstar = true;
|
|
1491
1259
|
consume(value);
|
|
1492
1260
|
continue;
|
|
1493
1261
|
}
|
|
@@ -1505,52 +1273,52 @@ var require_parse = __commonJS({
|
|
|
1505
1273
|
push(token);
|
|
1506
1274
|
continue;
|
|
1507
1275
|
}
|
|
1508
|
-
if (
|
|
1276
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1509
1277
|
if (prev.type === "dot") {
|
|
1510
|
-
|
|
1278
|
+
state.output += NO_DOT_SLASH;
|
|
1511
1279
|
prev.output += NO_DOT_SLASH;
|
|
1512
1280
|
} else if (opts.dot === true) {
|
|
1513
|
-
|
|
1281
|
+
state.output += NO_DOTS_SLASH;
|
|
1514
1282
|
prev.output += NO_DOTS_SLASH;
|
|
1515
1283
|
} else {
|
|
1516
|
-
|
|
1284
|
+
state.output += nodot;
|
|
1517
1285
|
prev.output += nodot;
|
|
1518
1286
|
}
|
|
1519
1287
|
if (peek() !== "*") {
|
|
1520
|
-
|
|
1288
|
+
state.output += ONE_CHAR;
|
|
1521
1289
|
prev.output += ONE_CHAR;
|
|
1522
1290
|
}
|
|
1523
1291
|
}
|
|
1524
1292
|
push(token);
|
|
1525
1293
|
}
|
|
1526
|
-
while (
|
|
1294
|
+
while (state.brackets > 0) {
|
|
1527
1295
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1528
|
-
|
|
1296
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
1529
1297
|
decrement("brackets");
|
|
1530
1298
|
}
|
|
1531
|
-
while (
|
|
1299
|
+
while (state.parens > 0) {
|
|
1532
1300
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1533
|
-
|
|
1301
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
1534
1302
|
decrement("parens");
|
|
1535
1303
|
}
|
|
1536
|
-
while (
|
|
1304
|
+
while (state.braces > 0) {
|
|
1537
1305
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1538
|
-
|
|
1306
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
1539
1307
|
decrement("braces");
|
|
1540
1308
|
}
|
|
1541
1309
|
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1542
1310
|
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1543
1311
|
}
|
|
1544
|
-
if (
|
|
1545
|
-
|
|
1546
|
-
for (const token of
|
|
1547
|
-
|
|
1312
|
+
if (state.backtrack === true) {
|
|
1313
|
+
state.output = "";
|
|
1314
|
+
for (const token of state.tokens) {
|
|
1315
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1548
1316
|
if (token.suffix) {
|
|
1549
|
-
|
|
1317
|
+
state.output += token.suffix;
|
|
1550
1318
|
}
|
|
1551
1319
|
}
|
|
1552
1320
|
}
|
|
1553
|
-
return
|
|
1321
|
+
return state;
|
|
1554
1322
|
};
|
|
1555
1323
|
parse.fastpaths = (input, options) => {
|
|
1556
1324
|
const opts = { ...options };
|
|
@@ -1574,7 +1342,7 @@ var require_parse = __commonJS({
|
|
|
1574
1342
|
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1575
1343
|
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1576
1344
|
const capture = opts.capture ? "" : "?:";
|
|
1577
|
-
const
|
|
1345
|
+
const state = { negated: false, prefix: "" };
|
|
1578
1346
|
let star = opts.bash === true ? ".*?" : STAR;
|
|
1579
1347
|
if (opts.capture) {
|
|
1580
1348
|
star = `(${star})`;
|
|
@@ -1610,7 +1378,7 @@ var require_parse = __commonJS({
|
|
|
1610
1378
|
}
|
|
1611
1379
|
}
|
|
1612
1380
|
};
|
|
1613
|
-
const output = utils.removePrefix(input,
|
|
1381
|
+
const output = utils.removePrefix(input, state);
|
|
1614
1382
|
let source = create(output);
|
|
1615
1383
|
if (source && opts.strictSlashes !== true) {
|
|
1616
1384
|
source += `${SLASH_LITERAL}?`;
|
|
@@ -1635,8 +1403,8 @@ var require_picomatch = __commonJS({
|
|
|
1635
1403
|
const fns = glob.map((input) => picomatch2(input, options, returnState));
|
|
1636
1404
|
const arrayMatcher = (str) => {
|
|
1637
1405
|
for (const isMatch of fns) {
|
|
1638
|
-
const
|
|
1639
|
-
if (
|
|
1406
|
+
const state2 = isMatch(str);
|
|
1407
|
+
if (state2) return state2;
|
|
1640
1408
|
}
|
|
1641
1409
|
return false;
|
|
1642
1410
|
};
|
|
@@ -1649,7 +1417,7 @@ var require_picomatch = __commonJS({
|
|
|
1649
1417
|
const opts = options || {};
|
|
1650
1418
|
const posix = opts.windows;
|
|
1651
1419
|
const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
|
|
1652
|
-
const
|
|
1420
|
+
const state = regex.state;
|
|
1653
1421
|
delete regex.state;
|
|
1654
1422
|
let isIgnored = () => false;
|
|
1655
1423
|
if (opts.ignore) {
|
|
@@ -1658,7 +1426,7 @@ var require_picomatch = __commonJS({
|
|
|
1658
1426
|
}
|
|
1659
1427
|
const matcher = (input, returnObject = false) => {
|
|
1660
1428
|
const { isMatch, match, output } = picomatch2.test(input, regex, options, { glob, posix });
|
|
1661
|
-
const result = { glob, state
|
|
1429
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
1662
1430
|
if (typeof opts.onResult === "function") {
|
|
1663
1431
|
opts.onResult(result);
|
|
1664
1432
|
}
|
|
@@ -1679,7 +1447,7 @@ var require_picomatch = __commonJS({
|
|
|
1679
1447
|
return returnObject ? result : true;
|
|
1680
1448
|
};
|
|
1681
1449
|
if (returnState) {
|
|
1682
|
-
matcher.state =
|
|
1450
|
+
matcher.state = state;
|
|
1683
1451
|
}
|
|
1684
1452
|
return matcher;
|
|
1685
1453
|
};
|
|
@@ -1717,20 +1485,20 @@ var require_picomatch = __commonJS({
|
|
|
1717
1485
|
return parse(pattern, { ...options, fastpaths: false });
|
|
1718
1486
|
};
|
|
1719
1487
|
picomatch2.scan = (input, options) => scan(input, options);
|
|
1720
|
-
picomatch2.compileRe = (
|
|
1488
|
+
picomatch2.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1721
1489
|
if (returnOutput === true) {
|
|
1722
|
-
return
|
|
1490
|
+
return state.output;
|
|
1723
1491
|
}
|
|
1724
1492
|
const opts = options || {};
|
|
1725
1493
|
const prepend = opts.contains ? "" : "^";
|
|
1726
1494
|
const append = opts.contains ? "" : "$";
|
|
1727
|
-
let source = `${prepend}(?:${
|
|
1728
|
-
if (
|
|
1495
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
1496
|
+
if (state && state.negated === true) {
|
|
1729
1497
|
source = `^(?!${source}).*$`;
|
|
1730
1498
|
}
|
|
1731
1499
|
const regex = picomatch2.toRegex(source, options);
|
|
1732
1500
|
if (returnState === true) {
|
|
1733
|
-
regex.state =
|
|
1501
|
+
regex.state = state;
|
|
1734
1502
|
}
|
|
1735
1503
|
return regex;
|
|
1736
1504
|
};
|
|
@@ -2744,11 +2512,9 @@ __export(constants_exports, {
|
|
|
2744
2512
|
ActorInfo: () => ActorInfo,
|
|
2745
2513
|
Code: () => Code,
|
|
2746
2514
|
Device: () => Device,
|
|
2747
|
-
Mode: () => Mode,
|
|
2748
2515
|
PresetOfLiveViewKey: () => PresetOfLiveViewKey,
|
|
2749
2516
|
Status: () => Status,
|
|
2750
|
-
normalizeDevice: () => normalizeDevice
|
|
2751
|
-
normalizeMode: () => normalizeMode
|
|
2517
|
+
normalizeDevice: () => normalizeDevice
|
|
2752
2518
|
});
|
|
2753
2519
|
var Code = {
|
|
2754
2520
|
Success: 0,
|
|
@@ -2768,10 +2534,6 @@ var Device = Object.freeze({
|
|
|
2768
2534
|
Desktop: "desktop",
|
|
2769
2535
|
Mobile: "mobile"
|
|
2770
2536
|
});
|
|
2771
|
-
var Mode = Object.freeze({
|
|
2772
|
-
Default: "default",
|
|
2773
|
-
Cloak: "cloak"
|
|
2774
|
-
});
|
|
2775
2537
|
var normalizeDevice = (value, fallback = Device.Desktop) => {
|
|
2776
2538
|
const normalizedFallback = String(fallback || "").trim().toLowerCase() === Device.Mobile ? Device.Mobile : Device.Desktop;
|
|
2777
2539
|
const raw = String(value || "").trim().toLowerCase();
|
|
@@ -2779,13 +2541,6 @@ var normalizeDevice = (value, fallback = Device.Desktop) => {
|
|
|
2779
2541
|
if (raw === Device.Desktop) return Device.Desktop;
|
|
2780
2542
|
return normalizedFallback;
|
|
2781
2543
|
};
|
|
2782
|
-
var normalizeMode = (value, fallback = Mode.Default) => {
|
|
2783
|
-
const normalizedFallback = String(fallback || "").trim().toLowerCase() === Mode.Cloak ? Mode.Cloak : Mode.Default;
|
|
2784
|
-
const raw = String(value || "").trim().toLowerCase();
|
|
2785
|
-
if (raw === Mode.Cloak) return Mode.Cloak;
|
|
2786
|
-
if (raw === Mode.Default) return Mode.Default;
|
|
2787
|
-
return normalizedFallback;
|
|
2788
|
-
};
|
|
2789
2544
|
var createActorInfo = (info) => {
|
|
2790
2545
|
const normalizeDomain = (value) => {
|
|
2791
2546
|
if (!value) return "";
|
|
@@ -2853,6 +2608,7 @@ var createActorInfo = (info) => {
|
|
|
2853
2608
|
const buildLandingUrl = ({ protocol: protocol2, domain: domain2, path: path2 }) => {
|
|
2854
2609
|
const safeProtocol = String(protocol2).trim();
|
|
2855
2610
|
const safeDomain = normalizeDomain(domain2);
|
|
2611
|
+
if (!safeDomain) return "";
|
|
2856
2612
|
const safePath = normalizePath(path2);
|
|
2857
2613
|
return `${safeProtocol}://${safeDomain}${safePath}`;
|
|
2858
2614
|
};
|
|
@@ -3060,6 +2816,18 @@ var ActorInfo = {
|
|
|
3060
2816
|
prefix: "",
|
|
3061
2817
|
xurl: []
|
|
3062
2818
|
}
|
|
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
|
+
}
|
|
3063
2831
|
})
|
|
3064
2832
|
};
|
|
3065
2833
|
|
|
@@ -3616,8 +3384,8 @@ var normalizeBrowserProfile = (value) => {
|
|
|
3616
3384
|
payload: buildBrowserProfilePayload(core, observed)
|
|
3617
3385
|
};
|
|
3618
3386
|
};
|
|
3619
|
-
var rememberRuntimeState = (
|
|
3620
|
-
rememberedRuntimeState = deepClone(
|
|
3387
|
+
var rememberRuntimeState = (state) => {
|
|
3388
|
+
rememberedRuntimeState = deepClone(state);
|
|
3621
3389
|
return rememberedRuntimeState;
|
|
3622
3390
|
};
|
|
3623
3391
|
var normalizeRuntimeState = (source = {}, actor = "") => {
|
|
@@ -3677,7 +3445,7 @@ var RuntimeEnv = {
|
|
|
3677
3445
|
} else {
|
|
3678
3446
|
delete normalizedRuntime.browser_profile;
|
|
3679
3447
|
}
|
|
3680
|
-
const
|
|
3448
|
+
const state = {
|
|
3681
3449
|
actor: resolvedActor,
|
|
3682
3450
|
device,
|
|
3683
3451
|
runtime: normalizedRuntime,
|
|
@@ -3691,73 +3459,73 @@ var RuntimeEnv = {
|
|
|
3691
3459
|
browserProfileCore: browserProfile.core,
|
|
3692
3460
|
browserProfileObserved: browserProfile.observed
|
|
3693
3461
|
};
|
|
3694
|
-
rememberRuntimeState(
|
|
3695
|
-
return
|
|
3462
|
+
rememberRuntimeState(state);
|
|
3463
|
+
return state;
|
|
3696
3464
|
},
|
|
3697
3465
|
// buildEnvPatch 只构造允许回写到后端 env 的字段集合。
|
|
3698
3466
|
buildEnvPatch(source = {}, actor = "") {
|
|
3699
|
-
const
|
|
3700
|
-
const browserProfile = buildBrowserProfilePayload(
|
|
3467
|
+
const state = normalizeRuntimeState(source, actor);
|
|
3468
|
+
const browserProfile = buildBrowserProfilePayload(state.browserProfileCore, state.browserProfileObserved);
|
|
3701
3469
|
const envPatch = {
|
|
3702
|
-
...Array.isArray(
|
|
3703
|
-
...Object.keys(
|
|
3704
|
-
...Object.keys(
|
|
3470
|
+
...Array.isArray(state.cookies) && state.cookies.length > 0 ? { cookies: state.cookies } : {},
|
|
3471
|
+
...Object.keys(state.localStorage || {}).length > 0 ? { local_storage: state.localStorage } : {},
|
|
3472
|
+
...Object.keys(state.sessionStorage || {}).length > 0 ? { session_storage: state.sessionStorage } : {},
|
|
3705
3473
|
...Object.keys(browserProfile).length > 0 ? { browser_profile: browserProfile } : {}
|
|
3706
3474
|
};
|
|
3707
3475
|
return Object.keys(envPatch).length > 0 ? envPatch : null;
|
|
3708
3476
|
},
|
|
3709
3477
|
// hasLoginState 只判断 runtime 是否存在有效载荷,不再区分具体字段来源。
|
|
3710
3478
|
hasLoginState(source = {}, actor = "") {
|
|
3711
|
-
const
|
|
3712
|
-
return isPlainObject(
|
|
3479
|
+
const state = normalizeRuntimeState(source, actor);
|
|
3480
|
+
return isPlainObject(state.runtime) && Object.keys(state.runtime || {}).length > 0;
|
|
3713
3481
|
},
|
|
3714
3482
|
rememberState(source = {}) {
|
|
3715
|
-
const
|
|
3716
|
-
rememberRuntimeState(
|
|
3483
|
+
const state = normalizeRuntimeState(source);
|
|
3484
|
+
rememberRuntimeState(state);
|
|
3717
3485
|
return RuntimeEnv.peekRememberedState();
|
|
3718
3486
|
},
|
|
3719
3487
|
peekRememberedState() {
|
|
3720
3488
|
return rememberedRuntimeState ? deepClone(rememberedRuntimeState) : null;
|
|
3721
3489
|
},
|
|
3722
3490
|
getBrowserProfileCore(source = {}, actor = "") {
|
|
3723
|
-
const
|
|
3724
|
-
return deepClone(
|
|
3491
|
+
const state = normalizeRuntimeState(source, actor);
|
|
3492
|
+
return deepClone(state.browserProfileCore || {});
|
|
3725
3493
|
},
|
|
3726
3494
|
setBrowserProfileCore(source = {}, core = {}, actor = "") {
|
|
3727
|
-
const
|
|
3495
|
+
const state = normalizeRuntimeState(source, actor);
|
|
3728
3496
|
const normalizedCore = normalizeBrowserProfileCore({
|
|
3729
3497
|
...core,
|
|
3730
|
-
device: normalizeKnownDevice(core == null ? void 0 : core.device) ||
|
|
3498
|
+
device: normalizeKnownDevice(core == null ? void 0 : core.device) || state.device
|
|
3731
3499
|
});
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
if (Object.keys(
|
|
3735
|
-
|
|
3500
|
+
state.browserProfileCore = normalizedCore;
|
|
3501
|
+
state.browserProfile = buildBrowserProfilePayload(normalizedCore, state.browserProfileObserved);
|
|
3502
|
+
if (Object.keys(state.browserProfile).length > 0) {
|
|
3503
|
+
state.runtime.browser_profile = state.browserProfile;
|
|
3736
3504
|
} else {
|
|
3737
|
-
delete
|
|
3505
|
+
delete state.runtime.browser_profile;
|
|
3738
3506
|
}
|
|
3739
|
-
rememberRuntimeState(
|
|
3740
|
-
return
|
|
3507
|
+
rememberRuntimeState(state);
|
|
3508
|
+
return state;
|
|
3741
3509
|
},
|
|
3742
3510
|
// applyToPage 只负责把登录态相关字段注入页面:
|
|
3743
3511
|
// cookies / localStorage / sessionStorage。
|
|
3744
3512
|
// 指纹、时区、UA、viewport 的回放发生在 launch.js 启动阶段,不在这里做。
|
|
3745
3513
|
async applyToPage(page, source = {}, options = {}) {
|
|
3746
3514
|
if (!page) return;
|
|
3747
|
-
let
|
|
3515
|
+
let state = normalizeRuntimeState(source, (options == null ? void 0 : options.actor) || "");
|
|
3748
3516
|
if (typeof (options == null ? void 0 : options.preapply) === "function") {
|
|
3749
|
-
|
|
3750
|
-
rememberRuntimeState(
|
|
3517
|
+
state = await options.preapply(state) || state;
|
|
3518
|
+
rememberRuntimeState(state);
|
|
3751
3519
|
}
|
|
3752
3520
|
Object.defineProperty(page, PageRuntimeStateKey, {
|
|
3753
3521
|
configurable: true,
|
|
3754
3522
|
enumerable: false,
|
|
3755
3523
|
writable: true,
|
|
3756
|
-
value:
|
|
3524
|
+
value: state
|
|
3757
3525
|
});
|
|
3758
|
-
const localStorage =
|
|
3759
|
-
const sessionStorage =
|
|
3760
|
-
const cookies = (
|
|
3526
|
+
const localStorage = state.localStorage || {};
|
|
3527
|
+
const sessionStorage = state.sessionStorage || {};
|
|
3528
|
+
const cookies = (state.cookies || []).map((cookie) => {
|
|
3761
3529
|
const normalized = { ...cookie };
|
|
3762
3530
|
if (!normalized.path) {
|
|
3763
3531
|
normalized.path = "/";
|
|
@@ -3795,8 +3563,8 @@ var RuntimeEnv = {
|
|
|
3795
3563
|
},
|
|
3796
3564
|
// captureEnvPatch 在任务结束时采集最新环境快照,用于 pushSuccess / pushFailed 自动回写。
|
|
3797
3565
|
async captureEnvPatch(page, source = {}, options = {}) {
|
|
3798
|
-
const
|
|
3799
|
-
const baseline = RuntimeEnv.buildEnvPatch(
|
|
3566
|
+
const state = normalizeRuntimeState(source, (options == null ? void 0 : options.actor) || "");
|
|
3567
|
+
const baseline = RuntimeEnv.buildEnvPatch(state) || {};
|
|
3800
3568
|
if (!page || typeof page.evaluate !== "function" || typeof page.context !== "function") {
|
|
3801
3569
|
return Object.keys(baseline).length > 0 ? baseline : null;
|
|
3802
3570
|
}
|
|
@@ -3815,7 +3583,7 @@ var RuntimeEnv = {
|
|
|
3815
3583
|
cookies
|
|
3816
3584
|
},
|
|
3817
3585
|
{
|
|
3818
|
-
browserProfileCore:
|
|
3586
|
+
browserProfileCore: state.browserProfileCore
|
|
3819
3587
|
}
|
|
3820
3588
|
);
|
|
3821
3589
|
return RuntimeEnv.mergeEnvPatches(baseline, capturedPatch);
|
|
@@ -3825,24 +3593,8 @@ var RuntimeEnv = {
|
|
|
3825
3593
|
}
|
|
3826
3594
|
};
|
|
3827
3595
|
|
|
3828
|
-
// src/internals/context.js
|
|
3829
|
-
var state = {
|
|
3830
|
-
mode: Mode.Default
|
|
3831
|
-
};
|
|
3832
|
-
var ToolkitContext = {
|
|
3833
|
-
get mode() {
|
|
3834
|
-
return state.mode;
|
|
3835
|
-
},
|
|
3836
|
-
setMode(mode = Mode.Default) {
|
|
3837
|
-
state.mode = normalizeMode(mode, Mode.Default);
|
|
3838
|
-
return state.mode;
|
|
3839
|
-
}
|
|
3840
|
-
};
|
|
3841
|
-
var setToolkitMode = (mode = Mode.Default) => ToolkitContext.setMode(mode);
|
|
3842
|
-
|
|
3843
3596
|
// entrys/browser.js
|
|
3844
3597
|
var usePlaywrightToolKit = () => {
|
|
3845
|
-
setToolkitMode(Mode.Default);
|
|
3846
3598
|
return {
|
|
3847
3599
|
Logger,
|
|
3848
3600
|
Display,
|