@forsakringskassan/docs-generator 2.37.0 → 2.38.0

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.
@@ -614,7 +614,7 @@ var xmlDecodeTree = new Uint16Array(
614
614
  .map((c) => c.charCodeAt(0)));
615
615
 
616
616
  // Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
617
- var _a$5;
617
+ var _a$6;
618
618
  const decodeMap = new Map([
619
619
  [0, 65533],
620
620
  // C1 Unicode control character reference replacements
@@ -651,7 +651,7 @@ const decodeMap = new Map([
651
651
  */
652
652
  const fromCodePoint$1 =
653
653
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
654
- (_a$5 = String.fromCodePoint) !== null && _a$5 !== void 0 ? _a$5 : function (codePoint) {
654
+ (_a$6 = String.fromCodePoint) !== null && _a$6 !== void 0 ? _a$6 : function (codePoint) {
655
655
  let output = "";
656
656
  if (codePoint > 0xffff) {
657
657
  codePoint -= 0x10000;
@@ -8846,8 +8846,110 @@ const unescape$1 = (s, { windowsPathsNoEscape = false, magicalBraces = true, } =
8846
8846
  };
8847
8847
 
8848
8848
  // parse a single path portion
8849
+ var _a$5;
8849
8850
  const types = new Set(['!', '?', '+', '*', '@']);
8850
8851
  const isExtglobType = (c) => types.has(c);
8852
+ const isExtglobAST = (c) => isExtglobType(c.type);
8853
+ // Map of which extglob types can adopt the children of a nested extglob
8854
+ //
8855
+ // anything but ! can adopt a matching type:
8856
+ // +(a|+(b|c)|d) => +(a|b|c|d)
8857
+ // *(a|*(b|c)|d) => *(a|b|c|d)
8858
+ // @(a|@(b|c)|d) => @(a|b|c|d)
8859
+ // ?(a|?(b|c)|d) => ?(a|b|c|d)
8860
+ //
8861
+ // * can adopt anything, because 0 or repetition is allowed
8862
+ // *(a|?(b|c)|d) => *(a|b|c|d)
8863
+ // *(a|+(b|c)|d) => *(a|b|c|d)
8864
+ // *(a|@(b|c)|d) => *(a|b|c|d)
8865
+ //
8866
+ // + can adopt @, because 1 or repetition is allowed
8867
+ // +(a|@(b|c)|d) => +(a|b|c|d)
8868
+ //
8869
+ // + and @ CANNOT adopt *, because 0 would be allowed
8870
+ // +(a|*(b|c)|d) => would match "", on *(b|c)
8871
+ // @(a|*(b|c)|d) => would match "", on *(b|c)
8872
+ //
8873
+ // + and @ CANNOT adopt ?, because 0 would be allowed
8874
+ // +(a|?(b|c)|d) => would match "", on ?(b|c)
8875
+ // @(a|?(b|c)|d) => would match "", on ?(b|c)
8876
+ //
8877
+ // ? can adopt @, because 0 or 1 is allowed
8878
+ // ?(a|@(b|c)|d) => ?(a|b|c|d)
8879
+ //
8880
+ // ? and @ CANNOT adopt * or +, because >1 would be allowed
8881
+ // ?(a|*(b|c)|d) => would match bbb on *(b|c)
8882
+ // @(a|*(b|c)|d) => would match bbb on *(b|c)
8883
+ // ?(a|+(b|c)|d) => would match bbb on +(b|c)
8884
+ // @(a|+(b|c)|d) => would match bbb on +(b|c)
8885
+ //
8886
+ // ! CANNOT adopt ! (nothing else can either)
8887
+ // !(a|!(b|c)|d) => !(a|b|c|d) would fail to match on b (not not b|c)
8888
+ //
8889
+ // ! can adopt @
8890
+ // !(a|@(b|c)|d) => !(a|b|c|d)
8891
+ //
8892
+ // ! CANNOT adopt *
8893
+ // !(a|*(b|c)|d) => !(a|b|c|d) would match on bbb, not allowed
8894
+ //
8895
+ // ! CANNOT adopt +
8896
+ // !(a|+(b|c)|d) => !(a|b|c|d) would match on bbb, not allowed
8897
+ //
8898
+ // ! CANNOT adopt ?
8899
+ // x!(a|?(b|c)|d) => x!(a|b|c|d) would fail to match "x"
8900
+ const adoptionMap = new Map([
8901
+ ['!', ['@']],
8902
+ ['?', ['?', '@']],
8903
+ ['@', ['@']],
8904
+ ['*', ['*', '+', '?', '@']],
8905
+ ['+', ['+', '@']],
8906
+ ]);
8907
+ // nested extglobs that can be adopted in, but with the addition of
8908
+ // a blank '' element.
8909
+ const adoptionWithSpaceMap = new Map([
8910
+ ['!', ['?']],
8911
+ ['@', ['?']],
8912
+ ['+', ['?', '*']],
8913
+ ]);
8914
+ // union of the previous two maps
8915
+ const adoptionAnyMap = new Map([
8916
+ ['!', ['?', '@']],
8917
+ ['?', ['?', '@']],
8918
+ ['@', ['?', '@']],
8919
+ ['*', ['*', '+', '?', '@']],
8920
+ ['+', ['+', '@', '?', '*']],
8921
+ ]);
8922
+ // Extglobs that can take over their parent if they are the only child
8923
+ // the key is parent, value maps child to resulting extglob parent type
8924
+ // '@' is omitted because it's a special case. An `@` extglob with a single
8925
+ // member can always be usurped by that subpattern.
8926
+ const usurpMap = new Map([
8927
+ ['!', new Map([['!', '@']])],
8928
+ [
8929
+ '?',
8930
+ new Map([
8931
+ ['*', '*'],
8932
+ ['+', '*'],
8933
+ ]),
8934
+ ],
8935
+ [
8936
+ '@',
8937
+ new Map([
8938
+ ['!', '!'],
8939
+ ['?', '?'],
8940
+ ['@', '@'],
8941
+ ['*', '*'],
8942
+ ['+', '+'],
8943
+ ]),
8944
+ ],
8945
+ [
8946
+ '+',
8947
+ new Map([
8948
+ ['?', '*'],
8949
+ ['*', '*'],
8950
+ ]),
8951
+ ],
8952
+ ]);
8851
8953
  // Patterns that get prepended to bind to the start of either the
8852
8954
  // entire string, or just a single path portion, to prevent dots
8853
8955
  // and/or traversal patterns, when needed.
@@ -8871,6 +8973,7 @@ const star$1 = qmark$1 + '*?';
8871
8973
  const starNoEmpty = qmark$1 + '+?';
8872
8974
  // remove the \ chars that we added if we end up doing a nonmagic compare
8873
8975
  // const deslash = (s: string) => s.replace(/\\(.)/g, '$1')
8976
+ let ID = 0;
8874
8977
  class AST {
8875
8978
  type;
8876
8979
  #root;
@@ -8886,6 +8989,22 @@ class AST {
8886
8989
  // set to true if it's an extglob with no children
8887
8990
  // (which really means one child of '')
8888
8991
  #emptyExt = false;
8992
+ id = ++ID;
8993
+ get depth() {
8994
+ return (this.#parent?.depth ?? -1) + 1;
8995
+ }
8996
+ [Symbol.for('nodejs.util.inspect.custom')]() {
8997
+ return {
8998
+ '@@type': 'AST',
8999
+ id: this.id,
9000
+ type: this.type,
9001
+ root: this.#root.id,
9002
+ parent: this.#parent?.id,
9003
+ depth: this.depth,
9004
+ partsLength: this.#parts.length,
9005
+ parts: this.#parts,
9006
+ };
9007
+ }
8889
9008
  constructor(type, parent, options = {}) {
8890
9009
  this.type = type;
8891
9010
  // extglobs are inherently magical
@@ -8965,7 +9084,7 @@ class AST {
8965
9084
  continue;
8966
9085
  /* c8 ignore start */
8967
9086
  if (typeof p !== 'string' &&
8968
- !(p instanceof AST && p.#parent === this)) {
9087
+ !(p instanceof _a$5 && p.#parent === this)) {
8969
9088
  throw new Error('invalid part: ' + p);
8970
9089
  }
8971
9090
  /* c8 ignore stop */
@@ -8999,7 +9118,7 @@ class AST {
8999
9118
  const p = this.#parent;
9000
9119
  for (let i = 0; i < this.#parentIndex; i++) {
9001
9120
  const pp = p.#parts[i];
9002
- if (!(pp instanceof AST && pp.type === '!')) {
9121
+ if (!(pp instanceof _a$5 && pp.type === '!')) {
9003
9122
  return false;
9004
9123
  }
9005
9124
  }
@@ -9027,13 +9146,14 @@ class AST {
9027
9146
  this.push(part.clone(this));
9028
9147
  }
9029
9148
  clone(parent) {
9030
- const c = new AST(this.type, parent);
9149
+ const c = new _a$5(this.type, parent);
9031
9150
  for (const p of this.#parts) {
9032
9151
  c.copyIn(p);
9033
9152
  }
9034
9153
  return c;
9035
9154
  }
9036
- static #parseAST(str, ast, pos, opt) {
9155
+ static #parseAST(str, ast, pos, opt, extDepth) {
9156
+ const maxDepth = opt.maxExtglobRecursion ?? 2;
9037
9157
  let escaping = false;
9038
9158
  let inBrace = false;
9039
9159
  let braceStart = -1;
@@ -9070,11 +9190,17 @@ class AST {
9070
9190
  acc += c;
9071
9191
  continue;
9072
9192
  }
9073
- if (!opt.noext && isExtglobType(c) && str.charAt(i) === '(') {
9193
+ // we don't have to check for adoption here, because that's
9194
+ // done at the other recursion point.
9195
+ const doRecurse = !opt.noext &&
9196
+ isExtglobType(c) &&
9197
+ str.charAt(i) === '(' &&
9198
+ extDepth <= maxDepth;
9199
+ if (doRecurse) {
9074
9200
  ast.push(acc);
9075
9201
  acc = '';
9076
- const ext = new AST(c, ast);
9077
- i = AST.#parseAST(str, ext, i, opt);
9202
+ const ext = new _a$5(c, ast);
9203
+ i = _a$5.#parseAST(str, ext, i, opt, extDepth + 1);
9078
9204
  ast.push(ext);
9079
9205
  continue;
9080
9206
  }
@@ -9086,7 +9212,7 @@ class AST {
9086
9212
  // some kind of extglob, pos is at the (
9087
9213
  // find the next | or )
9088
9214
  let i = pos + 1;
9089
- let part = new AST(null, ast);
9215
+ let part = new _a$5(null, ast);
9090
9216
  const parts = [];
9091
9217
  let acc = '';
9092
9218
  while (i < str.length) {
@@ -9117,19 +9243,26 @@ class AST {
9117
9243
  acc += c;
9118
9244
  continue;
9119
9245
  }
9120
- if (isExtglobType(c) && str.charAt(i) === '(') {
9246
+ const doRecurse = !opt.noext &&
9247
+ isExtglobType(c) &&
9248
+ str.charAt(i) === '(' &&
9249
+ /* c8 ignore start - the maxDepth is sufficient here */
9250
+ (extDepth <= maxDepth || (ast && ast.#canAdoptType(c)));
9251
+ /* c8 ignore stop */
9252
+ if (doRecurse) {
9253
+ const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
9121
9254
  part.push(acc);
9122
9255
  acc = '';
9123
- const ext = new AST(c, part);
9256
+ const ext = new _a$5(c, part);
9124
9257
  part.push(ext);
9125
- i = AST.#parseAST(str, ext, i, opt);
9258
+ i = _a$5.#parseAST(str, ext, i, opt, extDepth + depthAdd);
9126
9259
  continue;
9127
9260
  }
9128
9261
  if (c === '|') {
9129
9262
  part.push(acc);
9130
9263
  acc = '';
9131
9264
  parts.push(part);
9132
- part = new AST(null, ast);
9265
+ part = new _a$5(null, ast);
9133
9266
  continue;
9134
9267
  }
9135
9268
  if (c === ')') {
@@ -9151,9 +9284,82 @@ class AST {
9151
9284
  ast.#parts = [str.substring(pos - 1)];
9152
9285
  return i;
9153
9286
  }
9287
+ #canAdoptWithSpace(child) {
9288
+ return this.#canAdopt(child, adoptionWithSpaceMap);
9289
+ }
9290
+ #canAdopt(child, map = adoptionMap) {
9291
+ if (!child ||
9292
+ typeof child !== 'object' ||
9293
+ child.type !== null ||
9294
+ child.#parts.length !== 1 ||
9295
+ this.type === null) {
9296
+ return false;
9297
+ }
9298
+ const gc = child.#parts[0];
9299
+ if (!gc || typeof gc !== 'object' || gc.type === null) {
9300
+ return false;
9301
+ }
9302
+ return this.#canAdoptType(gc.type, map);
9303
+ }
9304
+ #canAdoptType(c, map = adoptionAnyMap) {
9305
+ return !!map.get(this.type)?.includes(c);
9306
+ }
9307
+ #adoptWithSpace(child, index) {
9308
+ const gc = child.#parts[0];
9309
+ const blank = new _a$5(null, gc, this.options);
9310
+ blank.#parts.push('');
9311
+ gc.push(blank);
9312
+ this.#adopt(child, index);
9313
+ }
9314
+ #adopt(child, index) {
9315
+ const gc = child.#parts[0];
9316
+ this.#parts.splice(index, 1, ...gc.#parts);
9317
+ for (const p of gc.#parts) {
9318
+ if (typeof p === 'object')
9319
+ p.#parent = this;
9320
+ }
9321
+ this.#toString = undefined;
9322
+ }
9323
+ #canUsurpType(c) {
9324
+ const m = usurpMap.get(this.type);
9325
+ return !!(m?.has(c));
9326
+ }
9327
+ #canUsurp(child) {
9328
+ if (!child ||
9329
+ typeof child !== 'object' ||
9330
+ child.type !== null ||
9331
+ child.#parts.length !== 1 ||
9332
+ this.type === null ||
9333
+ this.#parts.length !== 1) {
9334
+ return false;
9335
+ }
9336
+ const gc = child.#parts[0];
9337
+ if (!gc || typeof gc !== 'object' || gc.type === null) {
9338
+ return false;
9339
+ }
9340
+ return this.#canUsurpType(gc.type);
9341
+ }
9342
+ #usurp(child) {
9343
+ const m = usurpMap.get(this.type);
9344
+ const gc = child.#parts[0];
9345
+ const nt = m?.get(gc.type);
9346
+ /* c8 ignore start - impossible */
9347
+ if (!nt)
9348
+ return false;
9349
+ /* c8 ignore stop */
9350
+ this.#parts = gc.#parts;
9351
+ for (const p of this.#parts) {
9352
+ if (typeof p === 'object') {
9353
+ p.#parent = this;
9354
+ }
9355
+ }
9356
+ this.type = nt;
9357
+ this.#toString = undefined;
9358
+ this.#emptyExt = false;
9359
+ }
9154
9360
  static fromGlob(pattern, options = {}) {
9155
- const ast = new AST(null, undefined, options);
9156
- AST.#parseAST(pattern, ast, 0, options);
9361
+ const ast = new _a$5(null, undefined, options);
9362
+ _a$5.#parseAST(pattern, ast, 0, options, 0);
9157
9363
  return ast;
9158
9364
  }
9159
9365
  // returns the regular expression if there's magic, or the unescaped
@@ -9257,16 +9463,18 @@ class AST {
9257
9463
  // or start or whatever) and prepend ^ or / at the Regexp construction.
9258
9464
  toRegExpSource(allowDot) {
9259
9465
  const dot = allowDot ?? !!this.#options.dot;
9260
- if (this.#root === this)
9466
+ if (this.#root === this) {
9467
+ this.#flatten();
9261
9468
  this.#fillNegs();
9262
- if (!this.type) {
9469
+ }
9470
+ if (!isExtglobAST(this)) {
9263
9471
  const noEmpty = this.isStart() &&
9264
9472
  this.isEnd() &&
9265
9473
  !this.#parts.some(s => typeof s !== 'string');
9266
9474
  const src = this.#parts
9267
9475
  .map(p => {
9268
9476
  const [re, _, hasMagic, uflag] = typeof p === 'string' ?
9269
- AST.#parseGlob(p, this.#hasMagic, noEmpty)
9477
+ _a$5.#parseGlob(p, this.#hasMagic, noEmpty)
9270
9478
  : p.toRegExpSource(allowDot);
9271
9479
  this.#hasMagic = this.#hasMagic || hasMagic;
9272
9480
  this.#uflag = this.#uflag || uflag;
@@ -9328,12 +9536,12 @@ class AST {
9328
9536
  // invalid extglob, has to at least be *something* present, if it's
9329
9537
  // the entire path portion.
9330
9538
  const s = this.toString();
9331
- this.#parts = [s];
9332
- this.type = null;
9333
- this.#hasMagic = undefined;
9539
+ const me = this;
9540
+ me.#parts = [s];
9541
+ me.type = null;
9542
+ me.#hasMagic = undefined;
9334
9543
  return [s, unescape$1(this.toString()), false, false];
9335
9544
  }
9336
- // XXX abstract out this map method
9337
9545
  let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ?
9338
9546
  ''
9339
9547
  : this.#partsToRegExp(true);
@@ -9369,6 +9577,42 @@ class AST {
9369
9577
  this.#uflag,
9370
9578
  ];
9371
9579
  }
9580
+ #flatten() {
9581
+ if (!isExtglobAST(this)) {
9582
+ for (const p of this.#parts) {
9583
+ if (typeof p === 'object') {
9584
+ p.#flatten();
9585
+ }
9586
+ }
9587
+ }
9588
+ else {
9589
+ // do up to 10 passes to flatten as much as possible
9590
+ let iterations = 0;
9591
+ let done = false;
9592
+ do {
9593
+ done = true;
9594
+ for (let i = 0; i < this.#parts.length; i++) {
9595
+ const c = this.#parts[i];
9596
+ if (typeof c === 'object') {
9597
+ c.#flatten();
9598
+ if (this.#canAdopt(c)) {
9599
+ done = false;
9600
+ this.#adopt(c, i);
9601
+ }
9602
+ else if (this.#canAdoptWithSpace(c)) {
9603
+ done = false;
9604
+ this.#adoptWithSpace(c, i);
9605
+ }
9606
+ else if (this.#canUsurp(c)) {
9607
+ done = false;
9608
+ this.#usurp(c);
9609
+ }
9610
+ }
9611
+ }
9612
+ } while (!done && ++iterations < 10);
9613
+ }
9614
+ this.#toString = undefined;
9615
+ }
9372
9616
  #partsToRegExp(dot) {
9373
9617
  return this.#parts
9374
9618
  .map(p => {
@@ -9439,6 +9683,7 @@ class AST {
9439
9683
  return [re, unescape$1(glob), !!hasMagic, uflag];
9440
9684
  }
9441
9685
  }
9686
+ _a$5 = AST;
9442
9687
 
9443
9688
  /**
9444
9689
  * Escape all magic characters in a glob pattern.
@@ -9656,11 +9901,13 @@ class Minimatch {
9656
9901
  isWindows;
9657
9902
  platform;
9658
9903
  windowsNoMagicRoot;
9904
+ maxGlobstarRecursion;
9659
9905
  regexp;
9660
9906
  constructor(pattern, options = {}) {
9661
9907
  assertValidPattern(pattern);
9662
9908
  options = options || {};
9663
9909
  this.options = options;
9910
+ this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
9664
9911
  this.pattern = pattern;
9665
9912
  this.platform = options.platform || defaultPlatform;
9666
9913
  this.isWindows = this.platform === 'win32';
@@ -10065,7 +10312,8 @@ class Minimatch {
10065
10312
  // out of pattern, then that's fine, as long as all
10066
10313
  // the parts match.
10067
10314
  matchOne(file, pattern, partial = false) {
10068
- const options = this.options;
10315
+ let fileStartIndex = 0;
10316
+ let patternStartIndex = 0;
10069
10317
  // UNC paths like //?/X:/... can match X:/... and vice versa
10070
10318
  // Drive letters in absolute drive or unc paths are always compared
10071
10319
  // case-insensitively.
@@ -10094,14 +10342,11 @@ class Minimatch {
10094
10342
  file[fdi],
10095
10343
  pattern[pdi],
10096
10344
  ];
10345
+ // start matching at the drive letter index of each
10097
10346
  if (fd.toLowerCase() === pd.toLowerCase()) {
10098
10347
  pattern[pdi] = fd;
10099
- if (pdi > fdi) {
10100
- pattern = pattern.slice(pdi);
10101
- }
10102
- else if (fdi > pdi) {
10103
- file = file.slice(fdi);
10104
- }
10348
+ patternStartIndex = pdi;
10349
+ fileStartIndex = fdi;
10105
10350
  }
10106
10351
  }
10107
10352
  }
@@ -10111,99 +10356,185 @@ class Minimatch {
10111
10356
  if (optimizationLevel >= 2) {
10112
10357
  file = this.levelTwoFileOptimize(file);
10113
10358
  }
10114
- this.debug('matchOne', this, { file, pattern });
10115
- this.debug('matchOne', file.length, pattern.length);
10116
- for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
10359
+ if (pattern.includes(GLOBSTAR)) {
10360
+ return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
10361
+ }
10362
+ return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
10363
+ }
10364
+ #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
10365
+ // split the pattern into head, tail, and middle of ** delimited parts
10366
+ const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
10367
+ const lastgs = pattern.lastIndexOf(GLOBSTAR);
10368
+ // split the pattern up into globstar-delimited sections
10369
+ // the tail has to be at the end, and the others just have
10370
+ // to be found in order from the head.
10371
+ const [head, body, tail] = partial ? [
10372
+ pattern.slice(patternIndex, firstgs),
10373
+ pattern.slice(firstgs + 1),
10374
+ [],
10375
+ ] : [
10376
+ pattern.slice(patternIndex, firstgs),
10377
+ pattern.slice(firstgs + 1, lastgs),
10378
+ pattern.slice(lastgs + 1),
10379
+ ];
10380
+ // check the head, from the current file/pattern index.
10381
+ if (head.length) {
10382
+ const fileHead = file.slice(fileIndex, fileIndex + head.length);
10383
+ if (!this.#matchOne(fileHead, head, partial, 0, 0)) {
10384
+ return false;
10385
+ }
10386
+ fileIndex += head.length;
10387
+ patternIndex += head.length;
10388
+ }
10389
+ // now we know the head matches!
10390
+ // if the last portion is not empty, it MUST match the end
10391
+ // check the tail
10392
+ let fileTailMatch = 0;
10393
+ if (tail.length) {
10394
+ // if head + tail > file, then we cannot possibly match
10395
+ if (tail.length + fileIndex > file.length)
10396
+ return false;
10397
+ // try to match the tail
10398
+ let tailStart = file.length - tail.length;
10399
+ if (this.#matchOne(file, tail, partial, tailStart, 0)) {
10400
+ fileTailMatch = tail.length;
10401
+ }
10402
+ else {
10403
+ // affordance for stuff like a/**/* matching a/b/
10404
+ // if the last file portion is '', and there's more to the pattern
10405
+ // then try without the '' bit.
10406
+ if (file[file.length - 1] !== '' ||
10407
+ fileIndex + tail.length === file.length) {
10408
+ return false;
10409
+ }
10410
+ tailStart--;
10411
+ if (!this.#matchOne(file, tail, partial, tailStart, 0)) {
10412
+ return false;
10413
+ }
10414
+ fileTailMatch = tail.length + 1;
10415
+ }
10416
+ }
10417
+ // now we know the tail matches!
10418
+ // the middle is zero or more portions wrapped in **, possibly
10419
+ // containing more ** sections.
10420
+ // so a/**/b/**/c/**/d has become **/b/**/c/**
10421
+ // if it's empty, it means a/**/b, just verify we have no bad dots
10422
+ // if there's no tail, so it ends on /**, then we must have *something*
10423
+ // after the head, or it's not a matc
10424
+ if (!body.length) {
10425
+ let sawSome = !!fileTailMatch;
10426
+ for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
10427
+ const f = String(file[i]);
10428
+ sawSome = true;
10429
+ if (f === '.' ||
10430
+ f === '..' ||
10431
+ (!this.options.dot && f.startsWith('.'))) {
10432
+ return false;
10433
+ }
10434
+ }
10435
+ // in partial mode, we just need to get past all file parts
10436
+ return partial || sawSome;
10437
+ }
10438
+ // now we know that there's one or more body sections, which can
10439
+ // be matched anywhere from the 0 index (because the head was pruned)
10440
+ // through to the length-fileTailMatch index.
10441
+ // split the body up into sections, and note the minimum index it can
10442
+ // be found at (start with the length of all previous segments)
10443
+ // [section, before, after]
10444
+ const bodySegments = [[[], 0]];
10445
+ let currentBody = bodySegments[0];
10446
+ let nonGsParts = 0;
10447
+ const nonGsPartsSums = [0];
10448
+ for (const b of body) {
10449
+ if (b === GLOBSTAR) {
10450
+ nonGsPartsSums.push(nonGsParts);
10451
+ currentBody = [[], 0];
10452
+ bodySegments.push(currentBody);
10453
+ }
10454
+ else {
10455
+ currentBody[0].push(b);
10456
+ nonGsParts++;
10457
+ }
10458
+ }
10459
+ let i = bodySegments.length - 1;
10460
+ const fileLength = file.length - fileTailMatch;
10461
+ for (const b of bodySegments) {
10462
+ b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
10463
+ }
10464
+ return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
10465
+ }
10466
+ // return false for "nope, not matching"
10467
+ // return null for "not matching, cannot keep trying"
10468
+ #matchGlobStarBodySections(file,
10469
+ // pattern section, last possible position for it
10470
+ bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
10471
+ // take the first body segment, and walk from fileIndex to its "after"
10472
+ // value at the end
10473
+ // If it doesn't match at that position, we increment, until we hit
10474
+ // that final possible position, and give up.
10475
+ // If it does match, then advance and try to rest.
10476
+ // If any of them fail we keep walking forward.
10477
+ // this is still a bit recursively painful, but it's more constrained
10478
+ // than previous implementations, because we never test something that
10479
+ // can't possibly be a valid matching condition.
10480
+ const bs = bodySegments[bodyIndex];
10481
+ if (!bs) {
10482
+ // just make sure that there's no bad dots
10483
+ for (let i = fileIndex; i < file.length; i++) {
10484
+ sawTail = true;
10485
+ const f = file[i];
10486
+ if (f === '.' ||
10487
+ f === '..' ||
10488
+ (!this.options.dot && f.startsWith('.'))) {
10489
+ return false;
10490
+ }
10491
+ }
10492
+ return sawTail;
10493
+ }
10494
+ // have a non-globstar body section to test
10495
+ const [body, after] = bs;
10496
+ while (fileIndex <= after) {
10497
+ const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
10498
+ // if limit exceeded, no match. intentional false negative,
10499
+ // acceptable break in correctness for security.
10500
+ if (m && globStarDepth < this.maxGlobstarRecursion) {
10501
+ // match! see if the rest match. if so, we're done!
10502
+ const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
10503
+ if (sub !== false) {
10504
+ return sub;
10505
+ }
10506
+ }
10507
+ const f = file[fileIndex];
10508
+ if (f === '.' ||
10509
+ f === '..' ||
10510
+ (!this.options.dot && f.startsWith('.'))) {
10511
+ return false;
10512
+ }
10513
+ fileIndex++;
10514
+ }
10515
+ // walked off. no point continuing
10516
+ return partial || null;
10517
+ }
10518
+ #matchOne(file, pattern, partial, fileIndex, patternIndex) {
10519
+ let fi;
10520
+ let pi;
10521
+ let pl;
10522
+ let fl;
10523
+ for (fi = fileIndex,
10524
+ pi = patternIndex,
10525
+ fl = file.length,
10526
+ pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
10117
10527
  this.debug('matchOne loop');
10118
- var p = pattern[pi];
10119
- var f = file[fi];
10528
+ let p = pattern[pi];
10529
+ let f = file[fi];
10120
10530
  this.debug(pattern, p, f);
10121
10531
  // should be impossible.
10122
10532
  // some invalid regexp stuff in the set.
10123
10533
  /* c8 ignore start */
10124
- if (p === false) {
10534
+ if (p === false || p === GLOBSTAR) {
10125
10535
  return false;
10126
10536
  }
10127
10537
  /* c8 ignore stop */
10128
- if (p === GLOBSTAR) {
10129
- this.debug('GLOBSTAR', [pattern, p, f]);
10130
- // "**"
10131
- // a/**/b/**/c would match the following:
10132
- // a/b/x/y/z/c
10133
- // a/x/y/z/b/c
10134
- // a/b/x/b/x/c
10135
- // a/b/c
10136
- // To do this, take the rest of the pattern after
10137
- // the **, and see if it would match the file remainder.
10138
- // If so, return success.
10139
- // If not, the ** "swallows" a segment, and try again.
10140
- // This is recursively awful.
10141
- //
10142
- // a/**/b/**/c matching a/b/x/y/z/c
10143
- // - a matches a
10144
- // - doublestar
10145
- // - matchOne(b/x/y/z/c, b/**/c)
10146
- // - b matches b
10147
- // - doublestar
10148
- // - matchOne(x/y/z/c, c) -> no
10149
- // - matchOne(y/z/c, c) -> no
10150
- // - matchOne(z/c, c) -> no
10151
- // - matchOne(c, c) yes, hit
10152
- var fr = fi;
10153
- var pr = pi + 1;
10154
- if (pr === pl) {
10155
- this.debug('** at the end');
10156
- // a ** at the end will just swallow the rest.
10157
- // We have found a match.
10158
- // however, it will not swallow /.x, unless
10159
- // options.dot is set.
10160
- // . and .. are *never* matched by **, for explosively
10161
- // exponential reasons.
10162
- for (; fi < fl; fi++) {
10163
- if (file[fi] === '.' ||
10164
- file[fi] === '..' ||
10165
- (!options.dot && file[fi].charAt(0) === '.'))
10166
- return false;
10167
- }
10168
- return true;
10169
- }
10170
- // ok, let's see if we can swallow whatever we can.
10171
- while (fr < fl) {
10172
- var swallowee = file[fr];
10173
- this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
10174
- // XXX remove this slice. Just pass the start index.
10175
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
10176
- this.debug('globstar found match!', fr, fl, swallowee);
10177
- // found a match.
10178
- return true;
10179
- }
10180
- else {
10181
- // can't swallow "." or ".." ever.
10182
- // can only swallow ".foo" when explicitly asked.
10183
- if (swallowee === '.' ||
10184
- swallowee === '..' ||
10185
- (!options.dot && swallowee.charAt(0) === '.')) {
10186
- this.debug('dot detected!', file, fr, pattern, pr);
10187
- break;
10188
- }
10189
- // ** swallows a segment, and continue.
10190
- this.debug('globstar swallow a segment, and continue');
10191
- fr++;
10192
- }
10193
- }
10194
- // no match was found.
10195
- // However, in partial mode, we can't say this is necessarily over.
10196
- /* c8 ignore start */
10197
- if (partial) {
10198
- // ran out of file
10199
- this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
10200
- if (fr === fl) {
10201
- return true;
10202
- }
10203
- }
10204
- /* c8 ignore stop */
10205
- return false;
10206
- }
10207
10538
  // something other than **
10208
10539
  // non-magic patterns just have to match exactly
10209
10540
  // patterns with magic have been turned into regexps.
@@ -11125,9 +11456,10 @@ function createDedent(options) {
11125
11456
  result = result.trim();
11126
11457
  }
11127
11458
 
11128
- // handle escaped newlines at the end to ensure they don't get stripped too
11459
+ // Unescape escapes after trimming so sequences like `\n`, `\t`,
11460
+ // `\xHH` and `\u{...}` are preserved (fixes #24)
11129
11461
  if (escapeSpecialCharacters) {
11130
- result = result.replace(/\\n/g, "\n");
11462
+ result = result.replace(/\\n/g, "\n").replace(/\\t/g, "\t").replace(/\\r/g, "\r").replace(/\\v/g, "\v").replace(/\\b/g, "\b").replace(/\\f/g, "\f").replace(/\\0/g, "\0").replace(/\\x([\da-fA-F]{2})/g, (_, h) => String.fromCharCode(parseInt(h, 16))).replace(/\\u\{([\da-fA-F]{1,6})\}/g, (_, h) => String.fromCodePoint(parseInt(h, 16))).replace(/\\u([\da-fA-F]{4})/g, (_, h) => String.fromCharCode(parseInt(h, 16)));
11131
11463
  }
11132
11464
 
11133
11465
  // Workaround for Bun issue with Unicode characters
@@ -71851,4 +72183,4 @@ var typescript = /*#__PURE__*/Object.freeze({
71851
72183
  });
71852
72184
 
71853
72185
  export { HighlightJS as H, MarkdownIt as M, Ze$a as Z, resolveConfig as a, createTwoFilesPatch$1 as b, createSyncFn as c, dedent$1 as d, deflist_plugin as e, format2 as f, closest as g, distance as h, fm$2 as i, isCI as j, moduleImporter as k, cliProgress as l, minimatch as m, tinylr as n, createInstance as o, fse as p, inter as q, runAsWorker as r, ts$7 as t, watch$1 as w };
71854
- //# sourceMappingURL=vendor-Cgx8NlVP.mjs.map
72186
+ //# sourceMappingURL=vendor-DV7BHNMM.mjs.map