@parcel/utils 2.0.0-dev.1652 → 2.0.0-dev.1680

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/lib/index.js CHANGED
@@ -29954,7 +29954,7 @@ $638bfe96b8cf5d22$export$fbadac39f36b1e16 = (min, max, step = 1, limit)=>{
29954
29954
  return (Number(max) - Number(min)) / Number(step) >= limit;
29955
29955
  };
29956
29956
  $638bfe96b8cf5d22$export$92e39b1e2c1e6e56 = (block, n = 0, type)=>{
29957
- let node = block.nodes[n];
29957
+ const node = block.nodes[n];
29958
29958
  if (!node) return;
29959
29959
  if (type && node.type === type || node.type === 'open' || node.type === 'close') {
29960
29960
  if (node.escaped !== true) {
@@ -29997,8 +29997,12 @@ $638bfe96b8cf5d22$export$bffa455ba8c619a6 = (...args)=>{
29997
29997
  const result = [];
29998
29998
  const flat = (arr)=>{
29999
29999
  for(let i = 0; i < arr.length; i++){
30000
- let ele = arr[i];
30001
- Array.isArray(ele) ? flat(ele, result) : ele !== void 0 && result.push(ele);
30000
+ const ele = arr[i];
30001
+ if (Array.isArray(ele)) {
30002
+ flat(ele);
30003
+ continue;
30004
+ }
30005
+ if (ele !== undefined) result.push(ele);
30002
30006
  }
30003
30007
  return result;
30004
30008
  };
@@ -30008,16 +30012,16 @@ $638bfe96b8cf5d22$export$bffa455ba8c619a6 = (...args)=>{
30008
30012
 
30009
30013
 
30010
30014
  $8c2bb5b2dc605fb0$exports = (ast, options = {})=>{
30011
- let stringify = (node, parent = {})=>{
30012
- let invalidBlock = options.escapeInvalid && $638bfe96b8cf5d22$export$25a78c310c11373f(parent);
30013
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
30015
+ const stringify = (node, parent = {})=>{
30016
+ const invalidBlock = options.escapeInvalid && $638bfe96b8cf5d22$export$25a78c310c11373f(parent);
30017
+ const invalidNode = node.invalid === true && options.escapeInvalid === true;
30014
30018
  let output = '';
30015
30019
  if (node.value) {
30016
30020
  if ((invalidBlock || invalidNode) && $638bfe96b8cf5d22$export$582fc44003e67ec6(node)) return '\\' + node.value;
30017
30021
  return node.value;
30018
30022
  }
30019
30023
  if (node.value) return node.value;
30020
- if (node.nodes) for (let child of node.nodes)output += stringify(child);
30024
+ if (node.nodes) for (const child of node.nodes)output += stringify(child);
30021
30025
  return output;
30022
30026
  };
30023
30027
  return stringify(ast);
@@ -30296,15 +30300,15 @@ const $90899743e217e1b0$var$toMaxLen = (input, maxLength)=>{
30296
30300
  while(input.length < maxLength)input = '0' + input;
30297
30301
  return negative ? '-' + input : input;
30298
30302
  };
30299
- const $90899743e217e1b0$var$toSequence = (parts, options)=>{
30303
+ const $90899743e217e1b0$var$toSequence = (parts, options, maxLen)=>{
30300
30304
  parts.negatives.sort((a, b)=>a < b ? -1 : a > b ? 1 : 0);
30301
30305
  parts.positives.sort((a, b)=>a < b ? -1 : a > b ? 1 : 0);
30302
30306
  let prefix = options.capture ? '' : '?:';
30303
30307
  let positives = '';
30304
30308
  let negatives = '';
30305
30309
  let result;
30306
- if (parts.positives.length) positives = parts.positives.join('|');
30307
- if (parts.negatives.length) negatives = `-(${prefix}${parts.negatives.join('|')})`;
30310
+ if (parts.positives.length) positives = parts.positives.map((v)=>$90899743e217e1b0$var$toMaxLen(String(v), maxLen)).join('|');
30311
+ if (parts.negatives.length) negatives = `-(${prefix}${parts.negatives.map((v)=>$90899743e217e1b0$var$toMaxLen(String(v), maxLen)).join('|')})`;
30308
30312
  if (positives && negatives) result = `${positives}|${negatives}`;
30309
30313
  else result = positives || negatives;
30310
30314
  if (options.wrap) return `(${prefix}${result})`;
@@ -30378,7 +30382,7 @@ const $90899743e217e1b0$var$fillNumbers = (start, end, step = 1, options = {})=>
30378
30382
  a = descending ? a - step : a + step;
30379
30383
  index++;
30380
30384
  }
30381
- if (options.toRegex === true) return step > 1 ? $90899743e217e1b0$var$toSequence(parts, options) : $90899743e217e1b0$var$toRegex(range, null, {
30385
+ if (options.toRegex === true) return step > 1 ? $90899743e217e1b0$var$toSequence(parts, options, maxLen) : $90899743e217e1b0$var$toRegex(range, null, {
30382
30386
  wrap: false,
30383
30387
  ...options
30384
30388
  });
@@ -30432,28 +30436,32 @@ $90899743e217e1b0$exports = $90899743e217e1b0$var$fill;
30432
30436
 
30433
30437
 
30434
30438
  const $b51a4ae0c98a49fd$var$compile = (ast, options = {})=>{
30435
- let walk = (node, parent = {})=>{
30436
- let invalidBlock = $638bfe96b8cf5d22$export$25a78c310c11373f(parent);
30437
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
30438
- let invalid = invalidBlock === true || invalidNode === true;
30439
- let prefix = options.escapeInvalid === true ? '\\' : '';
30439
+ const walk = (node, parent = {})=>{
30440
+ const invalidBlock = $638bfe96b8cf5d22$export$25a78c310c11373f(parent);
30441
+ const invalidNode = node.invalid === true && options.escapeInvalid === true;
30442
+ const invalid = invalidBlock === true || invalidNode === true;
30443
+ const prefix = options.escapeInvalid === true ? '\\' : '';
30440
30444
  let output = '';
30441
30445
  if (node.isOpen === true) return prefix + node.value;
30442
- if (node.isClose === true) return prefix + node.value;
30446
+ if (node.isClose === true) {
30447
+ console.log('node.isClose', prefix, node.value);
30448
+ return prefix + node.value;
30449
+ }
30443
30450
  if (node.type === 'open') return invalid ? prefix + node.value : '(';
30444
30451
  if (node.type === 'close') return invalid ? prefix + node.value : ')';
30445
30452
  if (node.type === 'comma') return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
30446
30453
  if (node.value) return node.value;
30447
30454
  if (node.nodes && node.ranges > 0) {
30448
- let args = $638bfe96b8cf5d22$export$533b26079ad0b4b(node.nodes);
30449
- let range = $90899743e217e1b0$exports(...args, {
30455
+ const args = $638bfe96b8cf5d22$export$533b26079ad0b4b(node.nodes);
30456
+ const range = $90899743e217e1b0$exports(...args, {
30450
30457
  ...options,
30451
30458
  wrap: false,
30452
- toRegex: true
30459
+ toRegex: true,
30460
+ strictZeros: true
30453
30461
  });
30454
30462
  if (range.length !== 0) return args.length > 1 && range.length > 1 ? `(${range})` : range;
30455
30463
  }
30456
- if (node.nodes) for (let child of node.nodes)output += walk(child, node);
30464
+ if (node.nodes) for (const child of node.nodes)output += walk(child, node);
30457
30465
  return output;
30458
30466
  };
30459
30467
  return walk(ast);
@@ -30467,13 +30475,13 @@ var $fba5e0b00baf5b43$exports = {};
30467
30475
 
30468
30476
 
30469
30477
  const $fba5e0b00baf5b43$var$append = (queue = '', stash = '', enclose = false)=>{
30470
- let result = [];
30478
+ const result = [];
30471
30479
  queue = [].concat(queue);
30472
30480
  stash = [].concat(stash);
30473
30481
  if (!stash.length) return queue;
30474
30482
  if (!queue.length) return enclose ? $638bfe96b8cf5d22$export$bffa455ba8c619a6(stash).map((ele)=>`{${ele}}`) : stash;
30475
- for (let item of queue){
30476
- if (Array.isArray(item)) for (let value of item)result.push($fba5e0b00baf5b43$var$append(value, stash, enclose));
30483
+ for (const item of queue){
30484
+ if (Array.isArray(item)) for (const value of item)result.push($fba5e0b00baf5b43$var$append(value, stash, enclose));
30477
30485
  else for (let ele of stash){
30478
30486
  if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
30479
30487
  result.push(Array.isArray(ele) ? $fba5e0b00baf5b43$var$append(item, ele, enclose) : item + ele);
@@ -30482,8 +30490,8 @@ const $fba5e0b00baf5b43$var$append = (queue = '', stash = '', enclose = false)=>
30482
30490
  return $638bfe96b8cf5d22$export$bffa455ba8c619a6(result);
30483
30491
  };
30484
30492
  const $fba5e0b00baf5b43$var$expand = (ast, options = {})=>{
30485
- let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
30486
- let walk = (node, parent = {})=>{
30493
+ const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
30494
+ const walk = (node, parent = {})=>{
30487
30495
  node.queue = [];
30488
30496
  let p = parent;
30489
30497
  let q = parent.queue;
@@ -30502,7 +30510,7 @@ const $fba5e0b00baf5b43$var$expand = (ast, options = {})=>{
30502
30510
  return;
30503
30511
  }
30504
30512
  if (node.nodes && node.ranges > 0) {
30505
- let args = $638bfe96b8cf5d22$export$533b26079ad0b4b(node.nodes);
30513
+ const args = $638bfe96b8cf5d22$export$533b26079ad0b4b(node.nodes);
30506
30514
  if ($638bfe96b8cf5d22$export$fbadac39f36b1e16(...args, options.step, rangeLimit)) throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
30507
30515
  let range = $90899743e217e1b0$exports(...args, options);
30508
30516
  if (range.length === 0) range = $8c2bb5b2dc605fb0$exports(node, options);
@@ -30510,7 +30518,7 @@ const $fba5e0b00baf5b43$var$expand = (ast, options = {})=>{
30510
30518
  node.nodes = [];
30511
30519
  return;
30512
30520
  }
30513
- let enclose = $638bfe96b8cf5d22$export$ea0f721b77fd5acc(node);
30521
+ const enclose = $638bfe96b8cf5d22$export$ea0f721b77fd5acc(node);
30514
30522
  let queue = node.queue;
30515
30523
  let block = node;
30516
30524
  while(block.type !== 'brace' && block.type !== 'root' && block.parent){
@@ -30518,7 +30526,7 @@ const $fba5e0b00baf5b43$var$expand = (ast, options = {})=>{
30518
30526
  queue = block.queue;
30519
30527
  }
30520
30528
  for(let i = 0; i < node.nodes.length; i++){
30521
- let child = node.nodes[i];
30529
+ const child = node.nodes[i];
30522
30530
  if (child.type === 'comma' && node.type === 'brace') {
30523
30531
  if (i === 1) queue.push('');
30524
30532
  queue.push('');
@@ -30547,7 +30555,7 @@ var $cfe45d25eeb19d4c$exports = {};
30547
30555
  var $c88cee08a468e019$exports = {};
30548
30556
  'use strict';
30549
30557
  $c88cee08a468e019$exports = {
30550
- MAX_LENGTH: 65536,
30558
+ MAX_LENGTH: 10000,
30551
30559
  // Digits
30552
30560
  CHAR_0: '0',
30553
30561
  /* 0 */ CHAR_9: '9',
@@ -30617,25 +30625,24 @@ var $cfe45d25eeb19d4c$require$CHAR_ZERO_WIDTH_NOBREAK_SPACE = $c88cee08a468e019$
30617
30625
  * parse
30618
30626
  */ const $cfe45d25eeb19d4c$var$parse = (input, options = {})=>{
30619
30627
  if (typeof input !== 'string') throw new TypeError('Expected a string');
30620
- let opts = options || {};
30621
- let max = typeof opts.maxLength === 'number' ? Math.min($cfe45d25eeb19d4c$require$MAX_LENGTH, opts.maxLength) : $cfe45d25eeb19d4c$require$MAX_LENGTH;
30628
+ const opts = options || {};
30629
+ const max = typeof opts.maxLength === 'number' ? Math.min($cfe45d25eeb19d4c$require$MAX_LENGTH, opts.maxLength) : $cfe45d25eeb19d4c$require$MAX_LENGTH;
30622
30630
  if (input.length > max) throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
30623
- let ast = {
30631
+ const ast = {
30624
30632
  type: 'root',
30625
30633
  input: input,
30626
30634
  nodes: []
30627
30635
  };
30628
- let stack = [
30636
+ const stack = [
30629
30637
  ast
30630
30638
  ];
30631
30639
  let block = ast;
30632
30640
  let prev = ast;
30633
30641
  let brackets = 0;
30634
- let length = input.length;
30642
+ const length = input.length;
30635
30643
  let index = 0;
30636
30644
  let depth = 0;
30637
30645
  let value;
30638
- let memo = {};
30639
30646
  /**
30640
30647
  * Helpers
30641
30648
  */ const advance = ()=>input[index++];
@@ -30682,7 +30689,6 @@ var $cfe45d25eeb19d4c$require$CHAR_ZERO_WIDTH_NOBREAK_SPACE = $c88cee08a468e019$
30682
30689
  * Left square bracket: '['
30683
30690
  */ if (value === $cfe45d25eeb19d4c$require$CHAR_LEFT_SQUARE_BRACKET) {
30684
30691
  brackets++;
30685
- let closed = true;
30686
30692
  let next;
30687
30693
  while(index < length && (next = advance())){
30688
30694
  value += next;
@@ -30738,7 +30744,7 @@ var $cfe45d25eeb19d4c$require$CHAR_ZERO_WIDTH_NOBREAK_SPACE = $c88cee08a468e019$
30738
30744
  /**
30739
30745
  * Quotes: '|"|`
30740
30746
  */ if (value === $cfe45d25eeb19d4c$require$CHAR_DOUBLE_QUOTE || value === $cfe45d25eeb19d4c$require$CHAR_SINGLE_QUOTE || value === $cfe45d25eeb19d4c$require$CHAR_BACKTICK) {
30741
- let open = value;
30747
+ const open = value;
30742
30748
  let next;
30743
30749
  if (options.keepQuotes !== true) value = '';
30744
30750
  while(index < length && (next = advance())){
@@ -30762,8 +30768,8 @@ var $cfe45d25eeb19d4c$require$CHAR_ZERO_WIDTH_NOBREAK_SPACE = $c88cee08a468e019$
30762
30768
  * Left curly brace: '{'
30763
30769
  */ if (value === $cfe45d25eeb19d4c$require$CHAR_LEFT_CURLY_BRACE) {
30764
30770
  depth++;
30765
- let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
30766
- let brace = {
30771
+ const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
30772
+ const brace = {
30767
30773
  type: 'brace',
30768
30774
  open: true,
30769
30775
  close: false,
@@ -30791,7 +30797,7 @@ var $cfe45d25eeb19d4c$require$CHAR_ZERO_WIDTH_NOBREAK_SPACE = $c88cee08a468e019$
30791
30797
  });
30792
30798
  continue;
30793
30799
  }
30794
- let type = 'close';
30800
+ const type = 'close';
30795
30801
  block = stack.pop();
30796
30802
  block.close = true;
30797
30803
  push({
@@ -30807,7 +30813,7 @@ var $cfe45d25eeb19d4c$require$CHAR_ZERO_WIDTH_NOBREAK_SPACE = $c88cee08a468e019$
30807
30813
  */ if (value === $cfe45d25eeb19d4c$require$CHAR_COMMA && depth > 0) {
30808
30814
  if (block.ranges > 0) {
30809
30815
  block.ranges = 0;
30810
- let open = block.nodes.shift();
30816
+ const open = block.nodes.shift();
30811
30817
  block.nodes = [
30812
30818
  open,
30813
30819
  {
@@ -30826,7 +30832,7 @@ var $cfe45d25eeb19d4c$require$CHAR_ZERO_WIDTH_NOBREAK_SPACE = $c88cee08a468e019$
30826
30832
  /**
30827
30833
  * Dot: '.'
30828
30834
  */ if (value === $cfe45d25eeb19d4c$require$CHAR_DOT && depth > 0 && block.commas === 0) {
30829
- let siblings = block.nodes;
30835
+ const siblings = block.nodes;
30830
30836
  if (depth === 0 || siblings.length === 0) {
30831
30837
  push({
30832
30838
  type: 'text',
@@ -30850,7 +30856,7 @@ var $cfe45d25eeb19d4c$require$CHAR_ZERO_WIDTH_NOBREAK_SPACE = $c88cee08a468e019$
30850
30856
  }
30851
30857
  if (prev.type === 'range') {
30852
30858
  siblings.pop();
30853
- let before = siblings[siblings.length - 1];
30859
+ const before = siblings[siblings.length - 1];
30854
30860
  before.value += prev.value + value;
30855
30861
  prev = before;
30856
30862
  block.ranges--;
@@ -30882,8 +30888,8 @@ var $cfe45d25eeb19d4c$require$CHAR_ZERO_WIDTH_NOBREAK_SPACE = $c88cee08a468e019$
30882
30888
  }
30883
30889
  });
30884
30890
  // get the location of the block on parent.nodes (block's siblings)
30885
- let parent = stack[stack.length - 1];
30886
- let index = parent.nodes.indexOf(block);
30891
+ const parent = stack[stack.length - 1];
30892
+ const index = parent.nodes.indexOf(block);
30887
30893
  // replace the (invalid) block with it's nodes
30888
30894
  parent.nodes.splice(index, 1, ...block.nodes);
30889
30895
  }
@@ -30910,8 +30916,8 @@ $cfe45d25eeb19d4c$exports = $cfe45d25eeb19d4c$var$parse;
30910
30916
  * @api public
30911
30917
  */ const $5a424cf505ecaf3c$var$braces = (input, options = {})=>{
30912
30918
  let output = [];
30913
- if (Array.isArray(input)) for (let pattern of input){
30914
- let result = $5a424cf505ecaf3c$var$braces.create(pattern, options);
30919
+ if (Array.isArray(input)) for (const pattern of input){
30920
+ const result = $5a424cf505ecaf3c$var$braces.create(pattern, options);
30915
30921
  if (Array.isArray(result)) output.push(...result);
30916
30922
  else output.push(result);
30917
30923
  }