@skrillex1224/playwright-toolkit 2.1.278 → 2.1.280
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 +165 -157
- package/dist/browser.js.map +4 -4
- package/dist/index.cjs +480 -583
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +480 -583
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -266,19 +266,19 @@ var require_utils = __commonJS({
|
|
|
266
266
|
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
267
267
|
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
268
268
|
};
|
|
269
|
-
exports.removePrefix = (input,
|
|
269
|
+
exports.removePrefix = (input, state2 = {}) => {
|
|
270
270
|
let output = input;
|
|
271
271
|
if (output.startsWith("./")) {
|
|
272
272
|
output = output.slice(2);
|
|
273
|
-
|
|
273
|
+
state2.prefix = "./";
|
|
274
274
|
}
|
|
275
275
|
return output;
|
|
276
276
|
};
|
|
277
|
-
exports.wrapOutput = (input,
|
|
277
|
+
exports.wrapOutput = (input, state2 = {}, options = {}) => {
|
|
278
278
|
const prepend = options.contains ? "" : "^";
|
|
279
279
|
const append = options.contains ? "" : "$";
|
|
280
280
|
let output = `${prepend}(?:${input})${append}`;
|
|
281
|
-
if (
|
|
281
|
+
if (state2.negated === true) {
|
|
282
282
|
output = `(?:^(?!${output}).*$)`;
|
|
283
283
|
}
|
|
284
284
|
return output;
|
|
@@ -564,7 +564,7 @@ var require_scan = __commonJS({
|
|
|
564
564
|
base = utils.removeBackslashes(base);
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
-
const
|
|
567
|
+
const state2 = {
|
|
568
568
|
prefix,
|
|
569
569
|
input,
|
|
570
570
|
start,
|
|
@@ -579,11 +579,11 @@ var require_scan = __commonJS({
|
|
|
579
579
|
negatedExtglob
|
|
580
580
|
};
|
|
581
581
|
if (opts.tokens === true) {
|
|
582
|
-
|
|
582
|
+
state2.maxDepth = 0;
|
|
583
583
|
if (!isPathSeparator(code)) {
|
|
584
584
|
tokens.push(token);
|
|
585
585
|
}
|
|
586
|
-
|
|
586
|
+
state2.tokens = tokens;
|
|
587
587
|
}
|
|
588
588
|
if (opts.parts === true || opts.tokens === true) {
|
|
589
589
|
let prevIndex;
|
|
@@ -599,7 +599,7 @@ var require_scan = __commonJS({
|
|
|
599
599
|
tokens[idx].value = value;
|
|
600
600
|
}
|
|
601
601
|
depth(tokens[idx]);
|
|
602
|
-
|
|
602
|
+
state2.maxDepth += tokens[idx].depth;
|
|
603
603
|
}
|
|
604
604
|
if (idx !== 0 || value !== "") {
|
|
605
605
|
parts.push(value);
|
|
@@ -612,13 +612,13 @@ var require_scan = __commonJS({
|
|
|
612
612
|
if (opts.tokens) {
|
|
613
613
|
tokens[tokens.length - 1].value = value;
|
|
614
614
|
depth(tokens[tokens.length - 1]);
|
|
615
|
-
|
|
615
|
+
state2.maxDepth += tokens[tokens.length - 1].depth;
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
|
|
619
|
-
|
|
618
|
+
state2.slashes = slashes;
|
|
619
|
+
state2.parts = parts;
|
|
620
620
|
}
|
|
621
|
-
return
|
|
621
|
+
return state2;
|
|
622
622
|
};
|
|
623
623
|
module.exports = scan;
|
|
624
624
|
}
|
|
@@ -902,7 +902,7 @@ var require_parse = __commonJS({
|
|
|
902
902
|
if (typeof opts.noext === "boolean") {
|
|
903
903
|
opts.noextglob = opts.noext;
|
|
904
904
|
}
|
|
905
|
-
const
|
|
905
|
+
const state2 = {
|
|
906
906
|
input,
|
|
907
907
|
index: -1,
|
|
908
908
|
start: 0,
|
|
@@ -919,57 +919,57 @@ var require_parse = __commonJS({
|
|
|
919
919
|
globstar: false,
|
|
920
920
|
tokens
|
|
921
921
|
};
|
|
922
|
-
input = utils.removePrefix(input,
|
|
922
|
+
input = utils.removePrefix(input, state2);
|
|
923
923
|
len = input.length;
|
|
924
924
|
const extglobs = [];
|
|
925
925
|
const braces = [];
|
|
926
926
|
const stack = [];
|
|
927
927
|
let prev = bos;
|
|
928
928
|
let value;
|
|
929
|
-
const eos = () =>
|
|
930
|
-
const peek =
|
|
931
|
-
const advance =
|
|
932
|
-
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);
|
|
933
933
|
const consume = (value2 = "", num = 0) => {
|
|
934
|
-
|
|
935
|
-
|
|
934
|
+
state2.consumed += value2;
|
|
935
|
+
state2.index += num;
|
|
936
936
|
};
|
|
937
937
|
const append = (token) => {
|
|
938
|
-
|
|
938
|
+
state2.output += token.output != null ? token.output : token.value;
|
|
939
939
|
consume(token.value);
|
|
940
940
|
};
|
|
941
941
|
const negate = () => {
|
|
942
942
|
let count = 1;
|
|
943
943
|
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
944
944
|
advance();
|
|
945
|
-
|
|
945
|
+
state2.start++;
|
|
946
946
|
count++;
|
|
947
947
|
}
|
|
948
948
|
if (count % 2 === 0) {
|
|
949
949
|
return false;
|
|
950
950
|
}
|
|
951
|
-
|
|
952
|
-
|
|
951
|
+
state2.negated = true;
|
|
952
|
+
state2.start++;
|
|
953
953
|
return true;
|
|
954
954
|
};
|
|
955
955
|
const increment = (type) => {
|
|
956
|
-
|
|
956
|
+
state2[type]++;
|
|
957
957
|
stack.push(type);
|
|
958
958
|
};
|
|
959
959
|
const decrement = (type) => {
|
|
960
|
-
|
|
960
|
+
state2[type]--;
|
|
961
961
|
stack.pop();
|
|
962
962
|
};
|
|
963
963
|
const push = (tok) => {
|
|
964
964
|
if (prev.type === "globstar") {
|
|
965
|
-
const isBrace =
|
|
965
|
+
const isBrace = state2.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
966
966
|
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
967
967
|
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
968
|
-
|
|
968
|
+
state2.output = state2.output.slice(0, -prev.output.length);
|
|
969
969
|
prev.type = "star";
|
|
970
970
|
prev.value = "*";
|
|
971
971
|
prev.output = star;
|
|
972
|
-
|
|
972
|
+
state2.output += prev.output;
|
|
973
973
|
}
|
|
974
974
|
}
|
|
975
975
|
if (extglobs.length && tok.type !== "paren") {
|
|
@@ -988,19 +988,19 @@ var require_parse = __commonJS({
|
|
|
988
988
|
const extglobOpen = (type, value2) => {
|
|
989
989
|
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
990
990
|
token.prev = prev;
|
|
991
|
-
token.parens =
|
|
992
|
-
token.output =
|
|
993
|
-
token.startIndex =
|
|
991
|
+
token.parens = state2.parens;
|
|
992
|
+
token.output = state2.output;
|
|
993
|
+
token.startIndex = state2.index;
|
|
994
994
|
token.tokensIndex = tokens.length;
|
|
995
995
|
const output = (opts.capture ? "(" : "") + token.open;
|
|
996
996
|
increment("parens");
|
|
997
|
-
push({ type, value: value2, output:
|
|
997
|
+
push({ type, value: value2, output: state2.output ? "" : ONE_CHAR });
|
|
998
998
|
push({ type: "paren", extglob: true, value: advance(), output });
|
|
999
999
|
extglobs.push(token);
|
|
1000
1000
|
};
|
|
1001
1001
|
const extglobClose = (token) => {
|
|
1002
|
-
const literal = input.slice(token.startIndex,
|
|
1003
|
-
const body = input.slice(token.startIndex + 2,
|
|
1002
|
+
const literal = input.slice(token.startIndex, state2.index + 1);
|
|
1003
|
+
const body = input.slice(token.startIndex + 2, state2.index);
|
|
1004
1004
|
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
1005
1005
|
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
1006
1006
|
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
@@ -1013,8 +1013,8 @@ var require_parse = __commonJS({
|
|
|
1013
1013
|
tokens[i].output = "";
|
|
1014
1014
|
delete tokens[i].suffix;
|
|
1015
1015
|
}
|
|
1016
|
-
|
|
1017
|
-
|
|
1016
|
+
state2.output = token.output + open.output;
|
|
1017
|
+
state2.backtrack = true;
|
|
1018
1018
|
push({ type: "paren", extglob: true, value, output: "" });
|
|
1019
1019
|
decrement("parens");
|
|
1020
1020
|
return;
|
|
@@ -1034,7 +1034,7 @@ var require_parse = __commonJS({
|
|
|
1034
1034
|
output = token.close = `)${expression})${extglobStar})`;
|
|
1035
1035
|
}
|
|
1036
1036
|
if (token.prev.type === "bos") {
|
|
1037
|
-
|
|
1037
|
+
state2.negatedExtglob = true;
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
1040
|
push({ type: "paren", extglob: true, value, output });
|
|
@@ -1077,11 +1077,11 @@ var require_parse = __commonJS({
|
|
|
1077
1077
|
}
|
|
1078
1078
|
}
|
|
1079
1079
|
if (output === input && opts.contains === true) {
|
|
1080
|
-
|
|
1081
|
-
return
|
|
1080
|
+
state2.output = input;
|
|
1081
|
+
return state2;
|
|
1082
1082
|
}
|
|
1083
|
-
|
|
1084
|
-
return
|
|
1083
|
+
state2.output = utils.wrapOutput(output, state2, options);
|
|
1084
|
+
return state2;
|
|
1085
1085
|
}
|
|
1086
1086
|
while (!eos()) {
|
|
1087
1087
|
value = advance();
|
|
@@ -1105,7 +1105,7 @@ var require_parse = __commonJS({
|
|
|
1105
1105
|
let slashes = 0;
|
|
1106
1106
|
if (match && match[0].length > 2) {
|
|
1107
1107
|
slashes = match[0].length;
|
|
1108
|
-
|
|
1108
|
+
state2.index += slashes;
|
|
1109
1109
|
if (slashes % 2 !== 0) {
|
|
1110
1110
|
value += "\\";
|
|
1111
1111
|
}
|
|
@@ -1115,12 +1115,12 @@ var require_parse = __commonJS({
|
|
|
1115
1115
|
} else {
|
|
1116
1116
|
value += advance();
|
|
1117
1117
|
}
|
|
1118
|
-
if (
|
|
1118
|
+
if (state2.brackets === 0) {
|
|
1119
1119
|
push({ type: "text", value });
|
|
1120
1120
|
continue;
|
|
1121
1121
|
}
|
|
1122
1122
|
}
|
|
1123
|
-
if (
|
|
1123
|
+
if (state2.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1124
1124
|
if (opts.posix !== false && value === ":") {
|
|
1125
1125
|
const inner = prev.value.slice(1);
|
|
1126
1126
|
if (inner.includes("[")) {
|
|
@@ -1132,7 +1132,7 @@ var require_parse = __commonJS({
|
|
|
1132
1132
|
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
1133
1133
|
if (posix) {
|
|
1134
1134
|
prev.value = pre + posix;
|
|
1135
|
-
|
|
1135
|
+
state2.backtrack = true;
|
|
1136
1136
|
advance();
|
|
1137
1137
|
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
1138
1138
|
bos.output = ONE_CHAR;
|
|
@@ -1155,14 +1155,14 @@ var require_parse = __commonJS({
|
|
|
1155
1155
|
append({ value });
|
|
1156
1156
|
continue;
|
|
1157
1157
|
}
|
|
1158
|
-
if (
|
|
1158
|
+
if (state2.quotes === 1 && value !== '"') {
|
|
1159
1159
|
value = utils.escapeRegex(value);
|
|
1160
1160
|
prev.value += value;
|
|
1161
1161
|
append({ value });
|
|
1162
1162
|
continue;
|
|
1163
1163
|
}
|
|
1164
1164
|
if (value === '"') {
|
|
1165
|
-
|
|
1165
|
+
state2.quotes = state2.quotes === 1 ? 0 : 1;
|
|
1166
1166
|
if (opts.keepQuotes === true) {
|
|
1167
1167
|
push({ type: "text", value });
|
|
1168
1168
|
}
|
|
@@ -1174,15 +1174,15 @@ var require_parse = __commonJS({
|
|
|
1174
1174
|
continue;
|
|
1175
1175
|
}
|
|
1176
1176
|
if (value === ")") {
|
|
1177
|
-
if (
|
|
1177
|
+
if (state2.parens === 0 && opts.strictBrackets === true) {
|
|
1178
1178
|
throw new SyntaxError(syntaxError("opening", "("));
|
|
1179
1179
|
}
|
|
1180
1180
|
const extglob = extglobs[extglobs.length - 1];
|
|
1181
|
-
if (extglob &&
|
|
1181
|
+
if (extglob && state2.parens === extglob.parens + 1) {
|
|
1182
1182
|
extglobClose(extglobs.pop());
|
|
1183
1183
|
continue;
|
|
1184
1184
|
}
|
|
1185
|
-
push({ type: "paren", value, output:
|
|
1185
|
+
push({ type: "paren", value, output: state2.parens ? ")" : "\\)" });
|
|
1186
1186
|
decrement("parens");
|
|
1187
1187
|
continue;
|
|
1188
1188
|
}
|
|
@@ -1203,7 +1203,7 @@ var require_parse = __commonJS({
|
|
|
1203
1203
|
push({ type: "text", value, output: `\\${value}` });
|
|
1204
1204
|
continue;
|
|
1205
1205
|
}
|
|
1206
|
-
if (
|
|
1206
|
+
if (state2.brackets === 0) {
|
|
1207
1207
|
if (opts.strictBrackets === true) {
|
|
1208
1208
|
throw new SyntaxError(syntaxError("opening", "["));
|
|
1209
1209
|
}
|
|
@@ -1221,14 +1221,14 @@ var require_parse = __commonJS({
|
|
|
1221
1221
|
continue;
|
|
1222
1222
|
}
|
|
1223
1223
|
const escaped = utils.escapeRegex(prev.value);
|
|
1224
|
-
|
|
1224
|
+
state2.output = state2.output.slice(0, -prev.value.length);
|
|
1225
1225
|
if (opts.literalBrackets === true) {
|
|
1226
|
-
|
|
1226
|
+
state2.output += escaped;
|
|
1227
1227
|
prev.value = escaped;
|
|
1228
1228
|
continue;
|
|
1229
1229
|
}
|
|
1230
1230
|
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1231
|
-
|
|
1231
|
+
state2.output += prev.value;
|
|
1232
1232
|
continue;
|
|
1233
1233
|
}
|
|
1234
1234
|
if (value === "{" && opts.nobrace !== true) {
|
|
@@ -1237,8 +1237,8 @@ var require_parse = __commonJS({
|
|
|
1237
1237
|
type: "brace",
|
|
1238
1238
|
value,
|
|
1239
1239
|
output: "(",
|
|
1240
|
-
outputIndex:
|
|
1241
|
-
tokensIndex:
|
|
1240
|
+
outputIndex: state2.output.length,
|
|
1241
|
+
tokensIndex: state2.tokens.length
|
|
1242
1242
|
};
|
|
1243
1243
|
braces.push(open);
|
|
1244
1244
|
push(open);
|
|
@@ -1264,16 +1264,16 @@ var require_parse = __commonJS({
|
|
|
1264
1264
|
}
|
|
1265
1265
|
}
|
|
1266
1266
|
output = expandRange(range, opts);
|
|
1267
|
-
|
|
1267
|
+
state2.backtrack = true;
|
|
1268
1268
|
}
|
|
1269
1269
|
if (brace.comma !== true && brace.dots !== true) {
|
|
1270
|
-
const out =
|
|
1271
|
-
const toks =
|
|
1270
|
+
const out = state2.output.slice(0, brace.outputIndex);
|
|
1271
|
+
const toks = state2.tokens.slice(brace.tokensIndex);
|
|
1272
1272
|
brace.value = brace.output = "\\{";
|
|
1273
1273
|
value = output = "\\}";
|
|
1274
|
-
|
|
1274
|
+
state2.output = out;
|
|
1275
1275
|
for (const t of toks) {
|
|
1276
|
-
|
|
1276
|
+
state2.output += t.output || t.value;
|
|
1277
1277
|
}
|
|
1278
1278
|
}
|
|
1279
1279
|
push({ type: "brace", value, output });
|
|
@@ -1299,10 +1299,10 @@ var require_parse = __commonJS({
|
|
|
1299
1299
|
continue;
|
|
1300
1300
|
}
|
|
1301
1301
|
if (value === "/") {
|
|
1302
|
-
if (prev.type === "dot" &&
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1302
|
+
if (prev.type === "dot" && state2.index === state2.start + 1) {
|
|
1303
|
+
state2.start = state2.index + 1;
|
|
1304
|
+
state2.consumed = "";
|
|
1305
|
+
state2.output = "";
|
|
1306
1306
|
tokens.pop();
|
|
1307
1307
|
prev = bos;
|
|
1308
1308
|
continue;
|
|
@@ -1311,7 +1311,7 @@ var require_parse = __commonJS({
|
|
|
1311
1311
|
continue;
|
|
1312
1312
|
}
|
|
1313
1313
|
if (value === ".") {
|
|
1314
|
-
if (
|
|
1314
|
+
if (state2.braces > 0 && prev.type === "dot") {
|
|
1315
1315
|
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1316
1316
|
const brace = braces[braces.length - 1];
|
|
1317
1317
|
prev.type = "dots";
|
|
@@ -1320,7 +1320,7 @@ var require_parse = __commonJS({
|
|
|
1320
1320
|
brace.dots = true;
|
|
1321
1321
|
continue;
|
|
1322
1322
|
}
|
|
1323
|
-
if (
|
|
1323
|
+
if (state2.braces + state2.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1324
1324
|
push({ type: "text", value, output: DOT_LITERAL });
|
|
1325
1325
|
continue;
|
|
1326
1326
|
}
|
|
@@ -1356,7 +1356,7 @@ var require_parse = __commonJS({
|
|
|
1356
1356
|
continue;
|
|
1357
1357
|
}
|
|
1358
1358
|
}
|
|
1359
|
-
if (opts.nonegate !== true &&
|
|
1359
|
+
if (opts.nonegate !== true && state2.index === 0) {
|
|
1360
1360
|
negate();
|
|
1361
1361
|
continue;
|
|
1362
1362
|
}
|
|
@@ -1370,7 +1370,7 @@ var require_parse = __commonJS({
|
|
|
1370
1370
|
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1371
1371
|
continue;
|
|
1372
1372
|
}
|
|
1373
|
-
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) {
|
|
1374
1374
|
push({ type: "plus", value });
|
|
1375
1375
|
continue;
|
|
1376
1376
|
}
|
|
@@ -1392,7 +1392,7 @@ var require_parse = __commonJS({
|
|
|
1392
1392
|
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1393
1393
|
if (match) {
|
|
1394
1394
|
value += match[0];
|
|
1395
|
-
|
|
1395
|
+
state2.index += match[0].length;
|
|
1396
1396
|
}
|
|
1397
1397
|
push({ type: "text", value });
|
|
1398
1398
|
continue;
|
|
@@ -1402,8 +1402,8 @@ var require_parse = __commonJS({
|
|
|
1402
1402
|
prev.star = true;
|
|
1403
1403
|
prev.value += value;
|
|
1404
1404
|
prev.output = star;
|
|
1405
|
-
|
|
1406
|
-
|
|
1405
|
+
state2.backtrack = true;
|
|
1406
|
+
state2.globstar = true;
|
|
1407
1407
|
consume(value);
|
|
1408
1408
|
continue;
|
|
1409
1409
|
}
|
|
@@ -1425,14 +1425,14 @@ var require_parse = __commonJS({
|
|
|
1425
1425
|
push({ type: "star", value, output: "" });
|
|
1426
1426
|
continue;
|
|
1427
1427
|
}
|
|
1428
|
-
const isBrace =
|
|
1428
|
+
const isBrace = state2.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1429
1429
|
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1430
1430
|
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1431
1431
|
push({ type: "star", value, output: "" });
|
|
1432
1432
|
continue;
|
|
1433
1433
|
}
|
|
1434
1434
|
while (rest.slice(0, 3) === "/**") {
|
|
1435
|
-
const after = input[
|
|
1435
|
+
const after = input[state2.index + 4];
|
|
1436
1436
|
if (after && after !== "/") {
|
|
1437
1437
|
break;
|
|
1438
1438
|
}
|
|
@@ -1443,31 +1443,31 @@ var require_parse = __commonJS({
|
|
|
1443
1443
|
prev.type = "globstar";
|
|
1444
1444
|
prev.value += value;
|
|
1445
1445
|
prev.output = globstar(opts);
|
|
1446
|
-
|
|
1447
|
-
|
|
1446
|
+
state2.output = prev.output;
|
|
1447
|
+
state2.globstar = true;
|
|
1448
1448
|
consume(value);
|
|
1449
1449
|
continue;
|
|
1450
1450
|
}
|
|
1451
1451
|
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1452
|
-
|
|
1452
|
+
state2.output = state2.output.slice(0, -(prior.output + prev.output).length);
|
|
1453
1453
|
prior.output = `(?:${prior.output}`;
|
|
1454
1454
|
prev.type = "globstar";
|
|
1455
1455
|
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1456
1456
|
prev.value += value;
|
|
1457
|
-
|
|
1458
|
-
|
|
1457
|
+
state2.globstar = true;
|
|
1458
|
+
state2.output += prior.output + prev.output;
|
|
1459
1459
|
consume(value);
|
|
1460
1460
|
continue;
|
|
1461
1461
|
}
|
|
1462
1462
|
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1463
1463
|
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1464
|
-
|
|
1464
|
+
state2.output = state2.output.slice(0, -(prior.output + prev.output).length);
|
|
1465
1465
|
prior.output = `(?:${prior.output}`;
|
|
1466
1466
|
prev.type = "globstar";
|
|
1467
1467
|
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1468
1468
|
prev.value += value;
|
|
1469
|
-
|
|
1470
|
-
|
|
1469
|
+
state2.output += prior.output + prev.output;
|
|
1470
|
+
state2.globstar = true;
|
|
1471
1471
|
consume(value + advance());
|
|
1472
1472
|
push({ type: "slash", value: "/", output: "" });
|
|
1473
1473
|
continue;
|
|
@@ -1476,18 +1476,18 @@ var require_parse = __commonJS({
|
|
|
1476
1476
|
prev.type = "globstar";
|
|
1477
1477
|
prev.value += value;
|
|
1478
1478
|
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1479
|
-
|
|
1480
|
-
|
|
1479
|
+
state2.output = prev.output;
|
|
1480
|
+
state2.globstar = true;
|
|
1481
1481
|
consume(value + advance());
|
|
1482
1482
|
push({ type: "slash", value: "/", output: "" });
|
|
1483
1483
|
continue;
|
|
1484
1484
|
}
|
|
1485
|
-
|
|
1485
|
+
state2.output = state2.output.slice(0, -prev.output.length);
|
|
1486
1486
|
prev.type = "globstar";
|
|
1487
1487
|
prev.output = globstar(opts);
|
|
1488
1488
|
prev.value += value;
|
|
1489
|
-
|
|
1490
|
-
|
|
1489
|
+
state2.output += prev.output;
|
|
1490
|
+
state2.globstar = true;
|
|
1491
1491
|
consume(value);
|
|
1492
1492
|
continue;
|
|
1493
1493
|
}
|
|
@@ -1505,52 +1505,52 @@ var require_parse = __commonJS({
|
|
|
1505
1505
|
push(token);
|
|
1506
1506
|
continue;
|
|
1507
1507
|
}
|
|
1508
|
-
if (
|
|
1508
|
+
if (state2.index === state2.start || prev.type === "slash" || prev.type === "dot") {
|
|
1509
1509
|
if (prev.type === "dot") {
|
|
1510
|
-
|
|
1510
|
+
state2.output += NO_DOT_SLASH;
|
|
1511
1511
|
prev.output += NO_DOT_SLASH;
|
|
1512
1512
|
} else if (opts.dot === true) {
|
|
1513
|
-
|
|
1513
|
+
state2.output += NO_DOTS_SLASH;
|
|
1514
1514
|
prev.output += NO_DOTS_SLASH;
|
|
1515
1515
|
} else {
|
|
1516
|
-
|
|
1516
|
+
state2.output += nodot;
|
|
1517
1517
|
prev.output += nodot;
|
|
1518
1518
|
}
|
|
1519
1519
|
if (peek() !== "*") {
|
|
1520
|
-
|
|
1520
|
+
state2.output += ONE_CHAR;
|
|
1521
1521
|
prev.output += ONE_CHAR;
|
|
1522
1522
|
}
|
|
1523
1523
|
}
|
|
1524
1524
|
push(token);
|
|
1525
1525
|
}
|
|
1526
|
-
while (
|
|
1526
|
+
while (state2.brackets > 0) {
|
|
1527
1527
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1528
|
-
|
|
1528
|
+
state2.output = utils.escapeLast(state2.output, "[");
|
|
1529
1529
|
decrement("brackets");
|
|
1530
1530
|
}
|
|
1531
|
-
while (
|
|
1531
|
+
while (state2.parens > 0) {
|
|
1532
1532
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1533
|
-
|
|
1533
|
+
state2.output = utils.escapeLast(state2.output, "(");
|
|
1534
1534
|
decrement("parens");
|
|
1535
1535
|
}
|
|
1536
|
-
while (
|
|
1536
|
+
while (state2.braces > 0) {
|
|
1537
1537
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1538
|
-
|
|
1538
|
+
state2.output = utils.escapeLast(state2.output, "{");
|
|
1539
1539
|
decrement("braces");
|
|
1540
1540
|
}
|
|
1541
1541
|
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1542
1542
|
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1543
1543
|
}
|
|
1544
|
-
if (
|
|
1545
|
-
|
|
1546
|
-
for (const token of
|
|
1547
|
-
|
|
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;
|
|
1548
1548
|
if (token.suffix) {
|
|
1549
|
-
|
|
1549
|
+
state2.output += token.suffix;
|
|
1550
1550
|
}
|
|
1551
1551
|
}
|
|
1552
1552
|
}
|
|
1553
|
-
return
|
|
1553
|
+
return state2;
|
|
1554
1554
|
};
|
|
1555
1555
|
parse.fastpaths = (input, options) => {
|
|
1556
1556
|
const opts = { ...options };
|
|
@@ -1574,7 +1574,7 @@ var require_parse = __commonJS({
|
|
|
1574
1574
|
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1575
1575
|
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1576
1576
|
const capture = opts.capture ? "" : "?:";
|
|
1577
|
-
const
|
|
1577
|
+
const state2 = { negated: false, prefix: "" };
|
|
1578
1578
|
let star = opts.bash === true ? ".*?" : STAR;
|
|
1579
1579
|
if (opts.capture) {
|
|
1580
1580
|
star = `(${star})`;
|
|
@@ -1610,7 +1610,7 @@ var require_parse = __commonJS({
|
|
|
1610
1610
|
}
|
|
1611
1611
|
}
|
|
1612
1612
|
};
|
|
1613
|
-
const output = utils.removePrefix(input,
|
|
1613
|
+
const output = utils.removePrefix(input, state2);
|
|
1614
1614
|
let source = create(output);
|
|
1615
1615
|
if (source && opts.strictSlashes !== true) {
|
|
1616
1616
|
source += `${SLASH_LITERAL}?`;
|
|
@@ -1635,8 +1635,8 @@ var require_picomatch = __commonJS({
|
|
|
1635
1635
|
const fns = glob.map((input) => picomatch2(input, options, returnState));
|
|
1636
1636
|
const arrayMatcher = (str) => {
|
|
1637
1637
|
for (const isMatch of fns) {
|
|
1638
|
-
const
|
|
1639
|
-
if (
|
|
1638
|
+
const state3 = isMatch(str);
|
|
1639
|
+
if (state3) return state3;
|
|
1640
1640
|
}
|
|
1641
1641
|
return false;
|
|
1642
1642
|
};
|
|
@@ -1649,7 +1649,7 @@ var require_picomatch = __commonJS({
|
|
|
1649
1649
|
const opts = options || {};
|
|
1650
1650
|
const posix = opts.windows;
|
|
1651
1651
|
const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
|
|
1652
|
-
const
|
|
1652
|
+
const state2 = regex.state;
|
|
1653
1653
|
delete regex.state;
|
|
1654
1654
|
let isIgnored = () => false;
|
|
1655
1655
|
if (opts.ignore) {
|
|
@@ -1658,7 +1658,7 @@ var require_picomatch = __commonJS({
|
|
|
1658
1658
|
}
|
|
1659
1659
|
const matcher = (input, returnObject = false) => {
|
|
1660
1660
|
const { isMatch, match, output } = picomatch2.test(input, regex, options, { glob, posix });
|
|
1661
|
-
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
1661
|
+
const result = { glob, state: state2, regex, posix, input, output, match, isMatch };
|
|
1662
1662
|
if (typeof opts.onResult === "function") {
|
|
1663
1663
|
opts.onResult(result);
|
|
1664
1664
|
}
|
|
@@ -1679,7 +1679,7 @@ var require_picomatch = __commonJS({
|
|
|
1679
1679
|
return returnObject ? result : true;
|
|
1680
1680
|
};
|
|
1681
1681
|
if (returnState) {
|
|
1682
|
-
matcher.state =
|
|
1682
|
+
matcher.state = state2;
|
|
1683
1683
|
}
|
|
1684
1684
|
return matcher;
|
|
1685
1685
|
};
|
|
@@ -1717,20 +1717,20 @@ var require_picomatch = __commonJS({
|
|
|
1717
1717
|
return parse(pattern, { ...options, fastpaths: false });
|
|
1718
1718
|
};
|
|
1719
1719
|
picomatch2.scan = (input, options) => scan(input, options);
|
|
1720
|
-
picomatch2.compileRe = (
|
|
1720
|
+
picomatch2.compileRe = (state2, options, returnOutput = false, returnState = false) => {
|
|
1721
1721
|
if (returnOutput === true) {
|
|
1722
|
-
return
|
|
1722
|
+
return state2.output;
|
|
1723
1723
|
}
|
|
1724
1724
|
const opts = options || {};
|
|
1725
1725
|
const prepend = opts.contains ? "" : "^";
|
|
1726
1726
|
const append = opts.contains ? "" : "$";
|
|
1727
|
-
let source = `${prepend}(?:${
|
|
1728
|
-
if (
|
|
1727
|
+
let source = `${prepend}(?:${state2.output})${append}`;
|
|
1728
|
+
if (state2 && state2.negated === true) {
|
|
1729
1729
|
source = `^(?!${source}).*$`;
|
|
1730
1730
|
}
|
|
1731
1731
|
const regex = picomatch2.toRegex(source, options);
|
|
1732
1732
|
if (returnState === true) {
|
|
1733
|
-
regex.state =
|
|
1733
|
+
regex.state = state2;
|
|
1734
1734
|
}
|
|
1735
1735
|
return regex;
|
|
1736
1736
|
};
|
|
@@ -3616,8 +3616,8 @@ var normalizeBrowserProfile = (value) => {
|
|
|
3616
3616
|
payload: buildBrowserProfilePayload(core, observed)
|
|
3617
3617
|
};
|
|
3618
3618
|
};
|
|
3619
|
-
var rememberRuntimeState = (
|
|
3620
|
-
rememberedRuntimeState = deepClone(
|
|
3619
|
+
var rememberRuntimeState = (state2) => {
|
|
3620
|
+
rememberedRuntimeState = deepClone(state2);
|
|
3621
3621
|
return rememberedRuntimeState;
|
|
3622
3622
|
};
|
|
3623
3623
|
var normalizeRuntimeState = (source = {}, actor = "") => {
|
|
@@ -3677,7 +3677,7 @@ var RuntimeEnv = {
|
|
|
3677
3677
|
} else {
|
|
3678
3678
|
delete normalizedRuntime.browser_profile;
|
|
3679
3679
|
}
|
|
3680
|
-
const
|
|
3680
|
+
const state2 = {
|
|
3681
3681
|
actor: resolvedActor,
|
|
3682
3682
|
device,
|
|
3683
3683
|
runtime: normalizedRuntime,
|
|
@@ -3691,73 +3691,73 @@ var RuntimeEnv = {
|
|
|
3691
3691
|
browserProfileCore: browserProfile.core,
|
|
3692
3692
|
browserProfileObserved: browserProfile.observed
|
|
3693
3693
|
};
|
|
3694
|
-
rememberRuntimeState(
|
|
3695
|
-
return
|
|
3694
|
+
rememberRuntimeState(state2);
|
|
3695
|
+
return state2;
|
|
3696
3696
|
},
|
|
3697
3697
|
// buildEnvPatch 只构造允许回写到后端 env 的字段集合。
|
|
3698
3698
|
buildEnvPatch(source = {}, actor = "") {
|
|
3699
|
-
const
|
|
3700
|
-
const browserProfile = buildBrowserProfilePayload(
|
|
3699
|
+
const state2 = normalizeRuntimeState(source, actor);
|
|
3700
|
+
const browserProfile = buildBrowserProfilePayload(state2.browserProfileCore, state2.browserProfileObserved);
|
|
3701
3701
|
const envPatch = {
|
|
3702
|
-
...Array.isArray(
|
|
3703
|
-
...Object.keys(
|
|
3704
|
-
...Object.keys(
|
|
3702
|
+
...Array.isArray(state2.cookies) && state2.cookies.length > 0 ? { cookies: state2.cookies } : {},
|
|
3703
|
+
...Object.keys(state2.localStorage || {}).length > 0 ? { local_storage: state2.localStorage } : {},
|
|
3704
|
+
...Object.keys(state2.sessionStorage || {}).length > 0 ? { session_storage: state2.sessionStorage } : {},
|
|
3705
3705
|
...Object.keys(browserProfile).length > 0 ? { browser_profile: browserProfile } : {}
|
|
3706
3706
|
};
|
|
3707
3707
|
return Object.keys(envPatch).length > 0 ? envPatch : null;
|
|
3708
3708
|
},
|
|
3709
3709
|
// hasLoginState 只判断 runtime 是否存在有效载荷,不再区分具体字段来源。
|
|
3710
3710
|
hasLoginState(source = {}, actor = "") {
|
|
3711
|
-
const
|
|
3712
|
-
return isPlainObject(
|
|
3711
|
+
const state2 = normalizeRuntimeState(source, actor);
|
|
3712
|
+
return isPlainObject(state2.runtime) && Object.keys(state2.runtime || {}).length > 0;
|
|
3713
3713
|
},
|
|
3714
3714
|
rememberState(source = {}) {
|
|
3715
|
-
const
|
|
3716
|
-
rememberRuntimeState(
|
|
3715
|
+
const state2 = normalizeRuntimeState(source);
|
|
3716
|
+
rememberRuntimeState(state2);
|
|
3717
3717
|
return RuntimeEnv.peekRememberedState();
|
|
3718
3718
|
},
|
|
3719
3719
|
peekRememberedState() {
|
|
3720
3720
|
return rememberedRuntimeState ? deepClone(rememberedRuntimeState) : null;
|
|
3721
3721
|
},
|
|
3722
3722
|
getBrowserProfileCore(source = {}, actor = "") {
|
|
3723
|
-
const
|
|
3724
|
-
return deepClone(
|
|
3723
|
+
const state2 = normalizeRuntimeState(source, actor);
|
|
3724
|
+
return deepClone(state2.browserProfileCore || {});
|
|
3725
3725
|
},
|
|
3726
3726
|
setBrowserProfileCore(source = {}, core = {}, actor = "") {
|
|
3727
|
-
const
|
|
3727
|
+
const state2 = normalizeRuntimeState(source, actor);
|
|
3728
3728
|
const normalizedCore = normalizeBrowserProfileCore({
|
|
3729
3729
|
...core,
|
|
3730
|
-
device: normalizeKnownDevice(core == null ? void 0 : core.device) ||
|
|
3730
|
+
device: normalizeKnownDevice(core == null ? void 0 : core.device) || state2.device
|
|
3731
3731
|
});
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
if (Object.keys(
|
|
3735
|
-
|
|
3732
|
+
state2.browserProfileCore = normalizedCore;
|
|
3733
|
+
state2.browserProfile = buildBrowserProfilePayload(normalizedCore, state2.browserProfileObserved);
|
|
3734
|
+
if (Object.keys(state2.browserProfile).length > 0) {
|
|
3735
|
+
state2.runtime.browser_profile = state2.browserProfile;
|
|
3736
3736
|
} else {
|
|
3737
|
-
delete
|
|
3737
|
+
delete state2.runtime.browser_profile;
|
|
3738
3738
|
}
|
|
3739
|
-
rememberRuntimeState(
|
|
3740
|
-
return
|
|
3739
|
+
rememberRuntimeState(state2);
|
|
3740
|
+
return state2;
|
|
3741
3741
|
},
|
|
3742
3742
|
// applyToPage 只负责把登录态相关字段注入页面:
|
|
3743
3743
|
// cookies / localStorage / sessionStorage。
|
|
3744
3744
|
// 指纹、时区、UA、viewport 的回放发生在 launch.js 启动阶段,不在这里做。
|
|
3745
3745
|
async applyToPage(page, source = {}, options = {}) {
|
|
3746
3746
|
if (!page) return;
|
|
3747
|
-
let
|
|
3747
|
+
let state2 = normalizeRuntimeState(source, (options == null ? void 0 : options.actor) || "");
|
|
3748
3748
|
if (typeof (options == null ? void 0 : options.preapply) === "function") {
|
|
3749
|
-
|
|
3750
|
-
rememberRuntimeState(
|
|
3749
|
+
state2 = await options.preapply(state2) || state2;
|
|
3750
|
+
rememberRuntimeState(state2);
|
|
3751
3751
|
}
|
|
3752
3752
|
Object.defineProperty(page, PageRuntimeStateKey, {
|
|
3753
3753
|
configurable: true,
|
|
3754
3754
|
enumerable: false,
|
|
3755
3755
|
writable: true,
|
|
3756
|
-
value:
|
|
3756
|
+
value: state2
|
|
3757
3757
|
});
|
|
3758
|
-
const localStorage =
|
|
3759
|
-
const sessionStorage =
|
|
3760
|
-
const cookies = (
|
|
3758
|
+
const localStorage = state2.localStorage || {};
|
|
3759
|
+
const sessionStorage = state2.sessionStorage || {};
|
|
3760
|
+
const cookies = (state2.cookies || []).map((cookie) => {
|
|
3761
3761
|
const normalized = { ...cookie };
|
|
3762
3762
|
if (!normalized.path) {
|
|
3763
3763
|
normalized.path = "/";
|
|
@@ -3795,8 +3795,8 @@ var RuntimeEnv = {
|
|
|
3795
3795
|
},
|
|
3796
3796
|
// captureEnvPatch 在任务结束时采集最新环境快照,用于 pushSuccess / pushFailed 自动回写。
|
|
3797
3797
|
async captureEnvPatch(page, source = {}, options = {}) {
|
|
3798
|
-
const
|
|
3799
|
-
const baseline = RuntimeEnv.buildEnvPatch(
|
|
3798
|
+
const state2 = normalizeRuntimeState(source, (options == null ? void 0 : options.actor) || "");
|
|
3799
|
+
const baseline = RuntimeEnv.buildEnvPatch(state2) || {};
|
|
3800
3800
|
if (!page || typeof page.evaluate !== "function" || typeof page.context !== "function") {
|
|
3801
3801
|
return Object.keys(baseline).length > 0 ? baseline : null;
|
|
3802
3802
|
}
|
|
@@ -3815,7 +3815,7 @@ var RuntimeEnv = {
|
|
|
3815
3815
|
cookies
|
|
3816
3816
|
},
|
|
3817
3817
|
{
|
|
3818
|
-
browserProfileCore:
|
|
3818
|
+
browserProfileCore: state2.browserProfileCore
|
|
3819
3819
|
}
|
|
3820
3820
|
);
|
|
3821
3821
|
return RuntimeEnv.mergeEnvPatches(baseline, capturedPatch);
|
|
@@ -3825,12 +3825,20 @@ var RuntimeEnv = {
|
|
|
3825
3825
|
}
|
|
3826
3826
|
};
|
|
3827
3827
|
|
|
3828
|
-
// src/internals/
|
|
3829
|
-
var
|
|
3830
|
-
|
|
3831
|
-
currentMode = normalizeMode(mode, Mode.Default);
|
|
3832
|
-
return currentMode;
|
|
3828
|
+
// src/internals/context.js
|
|
3829
|
+
var state = {
|
|
3830
|
+
mode: Mode.Default
|
|
3833
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);
|
|
3834
3842
|
|
|
3835
3843
|
// entrys/browser.js
|
|
3836
3844
|
var usePlaywrightToolKit = () => {
|