@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.cjs.js CHANGED
@@ -111496,6 +111496,8 @@ function requireConstants$1 () {
111496
111496
  const WIN_SLASH = '\\\\/';
111497
111497
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
111498
111498
 
111499
+ const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
111500
+
111499
111501
  /**
111500
111502
  * Posix glob regex
111501
111503
  */
@@ -111559,6 +111561,7 @@ function requireConstants$1 () {
111559
111561
  */
111560
111562
 
111561
111563
  const POSIX_REGEX_SOURCE = {
111564
+ __proto__: null,
111562
111565
  alnum: 'a-zA-Z0-9',
111563
111566
  alpha: 'a-zA-Z',
111564
111567
  ascii: '\\x00-\\x7F',
@@ -111576,6 +111579,7 @@ function requireConstants$1 () {
111576
111579
  };
111577
111580
 
111578
111581
  constants$1 = {
111582
+ DEFAULT_MAX_EXTGLOB_RECURSION,
111579
111583
  MAX_LENGTH: 1024 * 64,
111580
111584
  POSIX_REGEX_SOURCE,
111581
111585
 
@@ -111589,6 +111593,7 @@ function requireConstants$1 () {
111589
111593
 
111590
111594
  // Replace globs with equivalent patterns to reduce parsing time.
111591
111595
  REPLACEMENTS: {
111596
+ __proto__: null,
111592
111597
  '***': '*',
111593
111598
  '**/**': '**',
111594
111599
  '**/**/**': '**'
@@ -112196,6 +112201,277 @@ function requireParse () {
112196
112201
  return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
112197
112202
  };
112198
112203
 
112204
+ const splitTopLevel = input => {
112205
+ const parts = [];
112206
+ let bracket = 0;
112207
+ let paren = 0;
112208
+ let quote = 0;
112209
+ let value = '';
112210
+ let escaped = false;
112211
+
112212
+ for (const ch of input) {
112213
+ if (escaped === true) {
112214
+ value += ch;
112215
+ escaped = false;
112216
+ continue;
112217
+ }
112218
+
112219
+ if (ch === '\\') {
112220
+ value += ch;
112221
+ escaped = true;
112222
+ continue;
112223
+ }
112224
+
112225
+ if (ch === '"') {
112226
+ quote = quote === 1 ? 0 : 1;
112227
+ value += ch;
112228
+ continue;
112229
+ }
112230
+
112231
+ if (quote === 0) {
112232
+ if (ch === '[') {
112233
+ bracket++;
112234
+ } else if (ch === ']' && bracket > 0) {
112235
+ bracket--;
112236
+ } else if (bracket === 0) {
112237
+ if (ch === '(') {
112238
+ paren++;
112239
+ } else if (ch === ')' && paren > 0) {
112240
+ paren--;
112241
+ } else if (ch === '|' && paren === 0) {
112242
+ parts.push(value);
112243
+ value = '';
112244
+ continue;
112245
+ }
112246
+ }
112247
+ }
112248
+
112249
+ value += ch;
112250
+ }
112251
+
112252
+ parts.push(value);
112253
+ return parts;
112254
+ };
112255
+
112256
+ const isPlainBranch = branch => {
112257
+ let escaped = false;
112258
+
112259
+ for (const ch of branch) {
112260
+ if (escaped === true) {
112261
+ escaped = false;
112262
+ continue;
112263
+ }
112264
+
112265
+ if (ch === '\\') {
112266
+ escaped = true;
112267
+ continue;
112268
+ }
112269
+
112270
+ if (/[?*+@!()[\]{}]/.test(ch)) {
112271
+ return false;
112272
+ }
112273
+ }
112274
+
112275
+ return true;
112276
+ };
112277
+
112278
+ const normalizeSimpleBranch = branch => {
112279
+ let value = branch.trim();
112280
+ let changed = true;
112281
+
112282
+ while (changed === true) {
112283
+ changed = false;
112284
+
112285
+ if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
112286
+ value = value.slice(2, -1);
112287
+ changed = true;
112288
+ }
112289
+ }
112290
+
112291
+ if (!isPlainBranch(value)) {
112292
+ return;
112293
+ }
112294
+
112295
+ return value.replace(/\\(.)/g, '$1');
112296
+ };
112297
+
112298
+ const hasRepeatedCharPrefixOverlap = branches => {
112299
+ const values = branches.map(normalizeSimpleBranch).filter(Boolean);
112300
+
112301
+ for (let i = 0; i < values.length; i++) {
112302
+ for (let j = i + 1; j < values.length; j++) {
112303
+ const a = values[i];
112304
+ const b = values[j];
112305
+ const char = a[0];
112306
+
112307
+ if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
112308
+ continue;
112309
+ }
112310
+
112311
+ if (a === b || a.startsWith(b) || b.startsWith(a)) {
112312
+ return true;
112313
+ }
112314
+ }
112315
+ }
112316
+
112317
+ return false;
112318
+ };
112319
+
112320
+ const parseRepeatedExtglob = (pattern, requireEnd = true) => {
112321
+ if ((pattern[0] !== '+' && pattern[0] !== '*') || pattern[1] !== '(') {
112322
+ return;
112323
+ }
112324
+
112325
+ let bracket = 0;
112326
+ let paren = 0;
112327
+ let quote = 0;
112328
+ let escaped = false;
112329
+
112330
+ for (let i = 1; i < pattern.length; i++) {
112331
+ const ch = pattern[i];
112332
+
112333
+ if (escaped === true) {
112334
+ escaped = false;
112335
+ continue;
112336
+ }
112337
+
112338
+ if (ch === '\\') {
112339
+ escaped = true;
112340
+ continue;
112341
+ }
112342
+
112343
+ if (ch === '"') {
112344
+ quote = quote === 1 ? 0 : 1;
112345
+ continue;
112346
+ }
112347
+
112348
+ if (quote === 1) {
112349
+ continue;
112350
+ }
112351
+
112352
+ if (ch === '[') {
112353
+ bracket++;
112354
+ continue;
112355
+ }
112356
+
112357
+ if (ch === ']' && bracket > 0) {
112358
+ bracket--;
112359
+ continue;
112360
+ }
112361
+
112362
+ if (bracket > 0) {
112363
+ continue;
112364
+ }
112365
+
112366
+ if (ch === '(') {
112367
+ paren++;
112368
+ continue;
112369
+ }
112370
+
112371
+ if (ch === ')') {
112372
+ paren--;
112373
+
112374
+ if (paren === 0) {
112375
+ if (requireEnd === true && i !== pattern.length - 1) {
112376
+ return;
112377
+ }
112378
+
112379
+ return {
112380
+ type: pattern[0],
112381
+ body: pattern.slice(2, i),
112382
+ end: i
112383
+ };
112384
+ }
112385
+ }
112386
+ }
112387
+ };
112388
+
112389
+ const getStarExtglobSequenceOutput = pattern => {
112390
+ let index = 0;
112391
+ const chars = [];
112392
+
112393
+ while (index < pattern.length) {
112394
+ const match = parseRepeatedExtglob(pattern.slice(index), false);
112395
+
112396
+ if (!match || match.type !== '*') {
112397
+ return;
112398
+ }
112399
+
112400
+ const branches = splitTopLevel(match.body).map(branch => branch.trim());
112401
+ if (branches.length !== 1) {
112402
+ return;
112403
+ }
112404
+
112405
+ const branch = normalizeSimpleBranch(branches[0]);
112406
+ if (!branch || branch.length !== 1) {
112407
+ return;
112408
+ }
112409
+
112410
+ chars.push(branch);
112411
+ index += match.end + 1;
112412
+ }
112413
+
112414
+ if (chars.length < 1) {
112415
+ return;
112416
+ }
112417
+
112418
+ const source = chars.length === 1
112419
+ ? utils.escapeRegex(chars[0])
112420
+ : `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
112421
+
112422
+ return `${source}*`;
112423
+ };
112424
+
112425
+ const repeatedExtglobRecursion = pattern => {
112426
+ let depth = 0;
112427
+ let value = pattern.trim();
112428
+ let match = parseRepeatedExtglob(value);
112429
+
112430
+ while (match) {
112431
+ depth++;
112432
+ value = match.body.trim();
112433
+ match = parseRepeatedExtglob(value);
112434
+ }
112435
+
112436
+ return depth;
112437
+ };
112438
+
112439
+ const analyzeRepeatedExtglob = (body, options) => {
112440
+ if (options.maxExtglobRecursion === false) {
112441
+ return { risky: false };
112442
+ }
112443
+
112444
+ const max =
112445
+ typeof options.maxExtglobRecursion === 'number'
112446
+ ? options.maxExtglobRecursion
112447
+ : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
112448
+
112449
+ const branches = splitTopLevel(body).map(branch => branch.trim());
112450
+
112451
+ if (branches.length > 1) {
112452
+ if (
112453
+ branches.some(branch => branch === '') ||
112454
+ branches.some(branch => /^[*?]+$/.test(branch)) ||
112455
+ hasRepeatedCharPrefixOverlap(branches)
112456
+ ) {
112457
+ return { risky: true };
112458
+ }
112459
+ }
112460
+
112461
+ for (const branch of branches) {
112462
+ const safeOutput = getStarExtglobSequenceOutput(branch);
112463
+ if (safeOutput) {
112464
+ return { risky: true, safeOutput };
112465
+ }
112466
+
112467
+ if (repeatedExtglobRecursion(branch) > max) {
112468
+ return { risky: true };
112469
+ }
112470
+ }
112471
+
112472
+ return { risky: false };
112473
+ };
112474
+
112199
112475
  /**
112200
112476
  * Parse the given input string.
112201
112477
  * @param {String} input
@@ -112377,6 +112653,8 @@ function requireParse () {
112377
112653
  token.prev = prev;
112378
112654
  token.parens = state.parens;
112379
112655
  token.output = state.output;
112656
+ token.startIndex = state.index;
112657
+ token.tokensIndex = tokens.length;
112380
112658
  const output = (opts.capture ? '(' : '') + token.open;
112381
112659
 
112382
112660
  increment('parens');
@@ -112386,6 +112664,34 @@ function requireParse () {
112386
112664
  };
112387
112665
 
112388
112666
  const extglobClose = token => {
112667
+ const literal = input.slice(token.startIndex, state.index + 1);
112668
+ const body = input.slice(token.startIndex + 2, state.index);
112669
+ const analysis = analyzeRepeatedExtglob(body, opts);
112670
+
112671
+ if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
112672
+ const safeOutput = analysis.safeOutput
112673
+ ? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
112674
+ : undefined;
112675
+ const open = tokens[token.tokensIndex];
112676
+
112677
+ open.type = 'text';
112678
+ open.value = literal;
112679
+ open.output = safeOutput || utils.escapeRegex(literal);
112680
+
112681
+ for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
112682
+ tokens[i].value = '';
112683
+ tokens[i].output = '';
112684
+ delete tokens[i].suffix;
112685
+ }
112686
+
112687
+ state.output = token.output + open.output;
112688
+ state.backtrack = true;
112689
+
112690
+ push({ type: 'paren', extglob: true, value, output: '' });
112691
+ decrement('parens');
112692
+ return;
112693
+ }
112694
+
112389
112695
  let output = token.close + (opts.capture ? ')' : '');
112390
112696
  let rest;
112391
112697