@bigbinary/neeto-playwright-commons 3.1.1 → 3.1.2

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/index.js CHANGED
@@ -111475,6 +111475,8 @@ function requireConstants$1 () {
111475
111475
  const WIN_SLASH = '\\\\/';
111476
111476
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
111477
111477
 
111478
+ const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
111479
+
111478
111480
  /**
111479
111481
  * Posix glob regex
111480
111482
  */
@@ -111538,6 +111540,7 @@ function requireConstants$1 () {
111538
111540
  */
111539
111541
 
111540
111542
  const POSIX_REGEX_SOURCE = {
111543
+ __proto__: null,
111541
111544
  alnum: 'a-zA-Z0-9',
111542
111545
  alpha: 'a-zA-Z',
111543
111546
  ascii: '\\x00-\\x7F',
@@ -111555,6 +111558,7 @@ function requireConstants$1 () {
111555
111558
  };
111556
111559
 
111557
111560
  constants$1 = {
111561
+ DEFAULT_MAX_EXTGLOB_RECURSION,
111558
111562
  MAX_LENGTH: 1024 * 64,
111559
111563
  POSIX_REGEX_SOURCE,
111560
111564
 
@@ -111568,6 +111572,7 @@ function requireConstants$1 () {
111568
111572
 
111569
111573
  // Replace globs with equivalent patterns to reduce parsing time.
111570
111574
  REPLACEMENTS: {
111575
+ __proto__: null,
111571
111576
  '***': '*',
111572
111577
  '**/**': '**',
111573
111578
  '**/**/**': '**'
@@ -112175,6 +112180,277 @@ function requireParse () {
112175
112180
  return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
112176
112181
  };
112177
112182
 
112183
+ const splitTopLevel = input => {
112184
+ const parts = [];
112185
+ let bracket = 0;
112186
+ let paren = 0;
112187
+ let quote = 0;
112188
+ let value = '';
112189
+ let escaped = false;
112190
+
112191
+ for (const ch of input) {
112192
+ if (escaped === true) {
112193
+ value += ch;
112194
+ escaped = false;
112195
+ continue;
112196
+ }
112197
+
112198
+ if (ch === '\\') {
112199
+ value += ch;
112200
+ escaped = true;
112201
+ continue;
112202
+ }
112203
+
112204
+ if (ch === '"') {
112205
+ quote = quote === 1 ? 0 : 1;
112206
+ value += ch;
112207
+ continue;
112208
+ }
112209
+
112210
+ if (quote === 0) {
112211
+ if (ch === '[') {
112212
+ bracket++;
112213
+ } else if (ch === ']' && bracket > 0) {
112214
+ bracket--;
112215
+ } else if (bracket === 0) {
112216
+ if (ch === '(') {
112217
+ paren++;
112218
+ } else if (ch === ')' && paren > 0) {
112219
+ paren--;
112220
+ } else if (ch === '|' && paren === 0) {
112221
+ parts.push(value);
112222
+ value = '';
112223
+ continue;
112224
+ }
112225
+ }
112226
+ }
112227
+
112228
+ value += ch;
112229
+ }
112230
+
112231
+ parts.push(value);
112232
+ return parts;
112233
+ };
112234
+
112235
+ const isPlainBranch = branch => {
112236
+ let escaped = false;
112237
+
112238
+ for (const ch of branch) {
112239
+ if (escaped === true) {
112240
+ escaped = false;
112241
+ continue;
112242
+ }
112243
+
112244
+ if (ch === '\\') {
112245
+ escaped = true;
112246
+ continue;
112247
+ }
112248
+
112249
+ if (/[?*+@!()[\]{}]/.test(ch)) {
112250
+ return false;
112251
+ }
112252
+ }
112253
+
112254
+ return true;
112255
+ };
112256
+
112257
+ const normalizeSimpleBranch = branch => {
112258
+ let value = branch.trim();
112259
+ let changed = true;
112260
+
112261
+ while (changed === true) {
112262
+ changed = false;
112263
+
112264
+ if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
112265
+ value = value.slice(2, -1);
112266
+ changed = true;
112267
+ }
112268
+ }
112269
+
112270
+ if (!isPlainBranch(value)) {
112271
+ return;
112272
+ }
112273
+
112274
+ return value.replace(/\\(.)/g, '$1');
112275
+ };
112276
+
112277
+ const hasRepeatedCharPrefixOverlap = branches => {
112278
+ const values = branches.map(normalizeSimpleBranch).filter(Boolean);
112279
+
112280
+ for (let i = 0; i < values.length; i++) {
112281
+ for (let j = i + 1; j < values.length; j++) {
112282
+ const a = values[i];
112283
+ const b = values[j];
112284
+ const char = a[0];
112285
+
112286
+ if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
112287
+ continue;
112288
+ }
112289
+
112290
+ if (a === b || a.startsWith(b) || b.startsWith(a)) {
112291
+ return true;
112292
+ }
112293
+ }
112294
+ }
112295
+
112296
+ return false;
112297
+ };
112298
+
112299
+ const parseRepeatedExtglob = (pattern, requireEnd = true) => {
112300
+ if ((pattern[0] !== '+' && pattern[0] !== '*') || pattern[1] !== '(') {
112301
+ return;
112302
+ }
112303
+
112304
+ let bracket = 0;
112305
+ let paren = 0;
112306
+ let quote = 0;
112307
+ let escaped = false;
112308
+
112309
+ for (let i = 1; i < pattern.length; i++) {
112310
+ const ch = pattern[i];
112311
+
112312
+ if (escaped === true) {
112313
+ escaped = false;
112314
+ continue;
112315
+ }
112316
+
112317
+ if (ch === '\\') {
112318
+ escaped = true;
112319
+ continue;
112320
+ }
112321
+
112322
+ if (ch === '"') {
112323
+ quote = quote === 1 ? 0 : 1;
112324
+ continue;
112325
+ }
112326
+
112327
+ if (quote === 1) {
112328
+ continue;
112329
+ }
112330
+
112331
+ if (ch === '[') {
112332
+ bracket++;
112333
+ continue;
112334
+ }
112335
+
112336
+ if (ch === ']' && bracket > 0) {
112337
+ bracket--;
112338
+ continue;
112339
+ }
112340
+
112341
+ if (bracket > 0) {
112342
+ continue;
112343
+ }
112344
+
112345
+ if (ch === '(') {
112346
+ paren++;
112347
+ continue;
112348
+ }
112349
+
112350
+ if (ch === ')') {
112351
+ paren--;
112352
+
112353
+ if (paren === 0) {
112354
+ if (requireEnd === true && i !== pattern.length - 1) {
112355
+ return;
112356
+ }
112357
+
112358
+ return {
112359
+ type: pattern[0],
112360
+ body: pattern.slice(2, i),
112361
+ end: i
112362
+ };
112363
+ }
112364
+ }
112365
+ }
112366
+ };
112367
+
112368
+ const getStarExtglobSequenceOutput = pattern => {
112369
+ let index = 0;
112370
+ const chars = [];
112371
+
112372
+ while (index < pattern.length) {
112373
+ const match = parseRepeatedExtglob(pattern.slice(index), false);
112374
+
112375
+ if (!match || match.type !== '*') {
112376
+ return;
112377
+ }
112378
+
112379
+ const branches = splitTopLevel(match.body).map(branch => branch.trim());
112380
+ if (branches.length !== 1) {
112381
+ return;
112382
+ }
112383
+
112384
+ const branch = normalizeSimpleBranch(branches[0]);
112385
+ if (!branch || branch.length !== 1) {
112386
+ return;
112387
+ }
112388
+
112389
+ chars.push(branch);
112390
+ index += match.end + 1;
112391
+ }
112392
+
112393
+ if (chars.length < 1) {
112394
+ return;
112395
+ }
112396
+
112397
+ const source = chars.length === 1
112398
+ ? utils.escapeRegex(chars[0])
112399
+ : `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
112400
+
112401
+ return `${source}*`;
112402
+ };
112403
+
112404
+ const repeatedExtglobRecursion = pattern => {
112405
+ let depth = 0;
112406
+ let value = pattern.trim();
112407
+ let match = parseRepeatedExtglob(value);
112408
+
112409
+ while (match) {
112410
+ depth++;
112411
+ value = match.body.trim();
112412
+ match = parseRepeatedExtglob(value);
112413
+ }
112414
+
112415
+ return depth;
112416
+ };
112417
+
112418
+ const analyzeRepeatedExtglob = (body, options) => {
112419
+ if (options.maxExtglobRecursion === false) {
112420
+ return { risky: false };
112421
+ }
112422
+
112423
+ const max =
112424
+ typeof options.maxExtglobRecursion === 'number'
112425
+ ? options.maxExtglobRecursion
112426
+ : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
112427
+
112428
+ const branches = splitTopLevel(body).map(branch => branch.trim());
112429
+
112430
+ if (branches.length > 1) {
112431
+ if (
112432
+ branches.some(branch => branch === '') ||
112433
+ branches.some(branch => /^[*?]+$/.test(branch)) ||
112434
+ hasRepeatedCharPrefixOverlap(branches)
112435
+ ) {
112436
+ return { risky: true };
112437
+ }
112438
+ }
112439
+
112440
+ for (const branch of branches) {
112441
+ const safeOutput = getStarExtglobSequenceOutput(branch);
112442
+ if (safeOutput) {
112443
+ return { risky: true, safeOutput };
112444
+ }
112445
+
112446
+ if (repeatedExtglobRecursion(branch) > max) {
112447
+ return { risky: true };
112448
+ }
112449
+ }
112450
+
112451
+ return { risky: false };
112452
+ };
112453
+
112178
112454
  /**
112179
112455
  * Parse the given input string.
112180
112456
  * @param {String} input
@@ -112356,6 +112632,8 @@ function requireParse () {
112356
112632
  token.prev = prev;
112357
112633
  token.parens = state.parens;
112358
112634
  token.output = state.output;
112635
+ token.startIndex = state.index;
112636
+ token.tokensIndex = tokens.length;
112359
112637
  const output = (opts.capture ? '(' : '') + token.open;
112360
112638
 
112361
112639
  increment('parens');
@@ -112365,6 +112643,34 @@ function requireParse () {
112365
112643
  };
112366
112644
 
112367
112645
  const extglobClose = token => {
112646
+ const literal = input.slice(token.startIndex, state.index + 1);
112647
+ const body = input.slice(token.startIndex + 2, state.index);
112648
+ const analysis = analyzeRepeatedExtglob(body, opts);
112649
+
112650
+ if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
112651
+ const safeOutput = analysis.safeOutput
112652
+ ? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
112653
+ : undefined;
112654
+ const open = tokens[token.tokensIndex];
112655
+
112656
+ open.type = 'text';
112657
+ open.value = literal;
112658
+ open.output = safeOutput || utils.escapeRegex(literal);
112659
+
112660
+ for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
112661
+ tokens[i].value = '';
112662
+ tokens[i].output = '';
112663
+ delete tokens[i].suffix;
112664
+ }
112665
+
112666
+ state.output = token.output + open.output;
112667
+ state.backtrack = true;
112668
+
112669
+ push({ type: 'paren', extglob: true, value, output: '' });
112670
+ decrement('parens');
112671
+ return;
112672
+ }
112673
+
112368
112674
  let output = token.close + (opts.capture ? ')' : '');
112369
112675
  let rest;
112370
112676