barrelize 1.6.1 → 1.6.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.
Files changed (2) hide show
  1. package/lib/index.js +366 -292
  2. package/package.json +7 -7
package/lib/index.js CHANGED
@@ -594,7 +594,7 @@ class CAC extends EventEmitter {
594
594
  }
595
595
  const cac = (name2 = "") => new CAC(name2);
596
596
  const name = "barrelize";
597
- const version = "1.6.0";
597
+ const version = "1.6.1";
598
598
  function cliInit() {
599
599
  const cli = cac(name);
600
600
  cli.command("[config path]", `Generate barrel files`).option("-w, --watch", "Watch for changes and regenerate barrel files automatically").action(async (configPath, options) => {
@@ -615,9 +615,6 @@ function cliInit() {
615
615
  }
616
616
  }
617
617
  }
618
- function getDefaultExportFromCjs(x) {
619
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
620
- }
621
618
  var _accessExpressionAsString = {};
622
619
  var hasRequired_accessExpressionAsString;
623
620
  function require_accessExpressionAsString() {
@@ -2464,6 +2461,7 @@ function requireLib() {
2464
2461
  IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
2465
2462
  InvalidBigIntLiteral: "Invalid BigIntLiteral.",
2466
2463
  InvalidCodePoint: "Code point out of bounds.",
2464
+ InvalidCoverDiscardElement: "'void' must be followed by an expression when not used in a binding position.",
2467
2465
  InvalidCoverInitializedName: "Invalid shorthand property initializer.",
2468
2466
  InvalidDecimal: "Invalid decimal.",
2469
2467
  InvalidDigit: ({
@@ -2581,6 +2579,7 @@ function requireLib() {
2581
2579
  }) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`,
2582
2580
  UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
2583
2581
  UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement.",
2582
+ UnexpectedVoidPattern: "Unexpected void binding.",
2584
2583
  UnsupportedBind: "Binding should be performed on object property.",
2585
2584
  UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
2586
2585
  UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
@@ -2601,6 +2600,8 @@ function requireLib() {
2601
2600
  VarRedeclaration: ({
2602
2601
  identifierName
2603
2602
  }) => `Identifier '${identifierName}' has already been declared.`,
2603
+ VoidPatternCatchClauseParam: "A void binding can not be the catch clause parameter. Use `try { ... } catch { ... }` if you want to discard the caught error.",
2604
+ VoidPatternInitializer: "A void binding may not have an initializer.",
2604
2605
  YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
2605
2606
  YieldInParameter: "Yield expression is not allowed in formal parameters.",
2606
2607
  YieldNotInGeneratorFunction: "'yield' is only allowed within generator functions.",
@@ -2785,6 +2786,17 @@ function requireLib() {
2785
2786
  throw new Error("With a `startLine > 1` you must also specify `startIndex` and `startColumn`.");
2786
2787
  }
2787
2788
  }
2789
+ if (options.sourceType === "commonjs") {
2790
+ if (opts.allowAwaitOutsideFunction != null) {
2791
+ throw new Error("The `allowAwaitOutsideFunction` option cannot be used with `sourceType: 'commonjs'`.");
2792
+ }
2793
+ if (opts.allowReturnOutsideFunction != null) {
2794
+ throw new Error("`sourceType: 'commonjs'` implies `allowReturnOutsideFunction: true`, please remove the `allowReturnOutsideFunction` option or use `sourceType: 'script'`.");
2795
+ }
2796
+ if (opts.allowNewTargetOutsideFunction != null) {
2797
+ throw new Error("`sourceType: 'commonjs'` implies `allowNewTargetOutsideFunction: true`, please remove the `allowNewTargetOutsideFunction` option or use `sourceType: 'script'`.");
2798
+ }
2799
+ }
2788
2800
  return options;
2789
2801
  }
2790
2802
  const {
@@ -2883,7 +2895,7 @@ function requireLib() {
2883
2895
  start,
2884
2896
  end,
2885
2897
  loc,
2886
- range,
2898
+ range: range2,
2887
2899
  raw,
2888
2900
  value
2889
2901
  } = node;
@@ -2892,7 +2904,7 @@ function requireLib() {
2892
2904
  cloned.start = start;
2893
2905
  cloned.end = end;
2894
2906
  cloned.loc = loc;
2895
- cloned.range = range;
2907
+ cloned.range = range2;
2896
2908
  cloned.raw = raw;
2897
2909
  cloned.value = value;
2898
2910
  return cloned;
@@ -3654,7 +3666,7 @@ function requireLib() {
3654
3666
  startsExpr
3655
3667
  }),
3656
3668
  placeholder: createToken("%%", {
3657
- startsExpr: true
3669
+ startsExpr
3658
3670
  }),
3659
3671
  string: createToken("string", {
3660
3672
  startsExpr
@@ -3677,10 +3689,10 @@ function requireLib() {
3677
3689
  eof: createToken("eof"),
3678
3690
  jsxName: createToken("jsxName"),
3679
3691
  jsxText: createToken("jsxText", {
3680
- beforeExpr: true
3692
+ beforeExpr
3681
3693
  }),
3682
3694
  jsxTagStart: createToken("jsxTagStart", {
3683
- startsExpr: true
3695
+ startsExpr
3684
3696
  }),
3685
3697
  jsxTagEnd: createToken("jsxTagEnd")
3686
3698
  };
@@ -3860,6 +3872,9 @@ function requireLib() {
3860
3872
  get allowDirectSuper() {
3861
3873
  return (this.currentThisScopeFlags() & 32) > 0;
3862
3874
  }
3875
+ get allowNewTarget() {
3876
+ return (this.currentThisScopeFlags() & 512) > 0;
3877
+ }
3863
3878
  get inClass() {
3864
3879
  return (this.currentThisScopeFlags() & 64) > 0;
3865
3880
  }
@@ -3875,7 +3890,7 @@ function requireLib() {
3875
3890
  if (flags & 128) {
3876
3891
  return true;
3877
3892
  }
3878
- if (flags & (643 | 64)) {
3893
+ if (flags & (1667 | 64)) {
3879
3894
  return false;
3880
3895
  }
3881
3896
  }
@@ -3925,7 +3940,7 @@ function requireLib() {
3925
3940
  this.checkRedeclarationInScope(scope, name2, bindingType, loc);
3926
3941
  scope.names.set(name2, (scope.names.get(name2) || 0) | 1);
3927
3942
  this.maybeExportDefined(scope, name2);
3928
- if (scope.flags & 643) break;
3943
+ if (scope.flags & 1667) break;
3929
3944
  }
3930
3945
  }
3931
3946
  if (this.parser.inModule && scope.flags & 1) {
@@ -3972,7 +3987,7 @@ function requireLib() {
3972
3987
  const {
3973
3988
  flags
3974
3989
  } = this.scopeStack[i];
3975
- if (flags & 643) {
3990
+ if (flags & 1667) {
3976
3991
  return flags;
3977
3992
  }
3978
3993
  }
@@ -3982,7 +3997,7 @@ function requireLib() {
3982
3997
  const {
3983
3998
  flags
3984
3999
  } = this.scopeStack[i];
3985
- if (flags & (643 | 64) && !(flags & 4)) {
4000
+ if (flags & (1667 | 64) && !(flags & 4)) {
3986
4001
  return flags;
3987
4002
  }
3988
4003
  }
@@ -5379,7 +5394,7 @@ function requireLib() {
5379
5394
  finishArrowValidation(node) {
5380
5395
  var _node$extra;
5381
5396
  this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingCommaLoc, false);
5382
- this.scope.enter(2 | 4);
5397
+ this.scope.enter(514 | 4);
5383
5398
  super.checkParams(node, false, true);
5384
5399
  this.scope.exit();
5385
5400
  }
@@ -5922,7 +5937,7 @@ function requireLib() {
5922
5937
  this.next();
5923
5938
  const node = this.startNodeAt(startLoc);
5924
5939
  node.callee = base;
5925
- node.arguments = super.parseCallExpressionArguments(11);
5940
+ node.arguments = super.parseCallExpressionArguments();
5926
5941
  base = this.finishNode(node, "CallExpression");
5927
5942
  } else if (base.type === "Identifier" && base.name === "async" && this.match(47)) {
5928
5943
  const state = this.state.clone();
@@ -5954,7 +5969,7 @@ function requireLib() {
5954
5969
  node.callee = base;
5955
5970
  node.typeArguments = this.flowParseTypeParameterInstantiationInExpression();
5956
5971
  this.expect(10);
5957
- node.arguments = this.parseCallExpressionArguments(11);
5972
+ node.arguments = this.parseCallExpressionArguments();
5958
5973
  node.optional = true;
5959
5974
  return this.finishCallExpression(node, true);
5960
5975
  } else if (!noCalls && this.shouldParseTypes() && (this.match(47) || this.match(51))) {
@@ -5963,7 +5978,7 @@ function requireLib() {
5963
5978
  const result = this.tryParse(() => {
5964
5979
  node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
5965
5980
  this.expect(10);
5966
- node.arguments = super.parseCallExpressionArguments(11);
5981
+ node.arguments = super.parseCallExpressionArguments();
5967
5982
  if (subscriptState.optionalChainMember) {
5968
5983
  node.optional = false;
5969
5984
  }
@@ -7153,14 +7168,14 @@ function requireLib() {
7153
7168
  return new TypeScriptScope(flags);
7154
7169
  }
7155
7170
  enter(flags) {
7156
- if (flags === 512) {
7171
+ if (flags === 1024) {
7157
7172
  this.importsStack.push(/* @__PURE__ */ new Set());
7158
7173
  }
7159
7174
  super.enter(flags);
7160
7175
  }
7161
7176
  exit() {
7162
7177
  const flags = super.exit();
7163
- if (flags === 512) {
7178
+ if (flags === 1024) {
7164
7179
  this.importsStack.pop();
7165
7180
  }
7166
7181
  return flags;
@@ -9176,9 +9191,8 @@ function requireLib() {
9176
9191
  return this.state.type === token2 && !this.state.containsEsc;
9177
9192
  }
9178
9193
  isUnparsedContextual(nameStart, name2) {
9179
- const nameEnd = nameStart + name2.length;
9180
- if (this.input.slice(nameStart, nameEnd) === name2) {
9181
- const nextCh = this.input.charCodeAt(nameEnd);
9194
+ if (this.input.startsWith(name2, nameStart)) {
9195
+ const nextCh = this.input.charCodeAt(nameStart + name2.length);
9182
9196
  return !(isIdentifierChar(nextCh) || (nextCh & 64512) === 55296);
9183
9197
  }
9184
9198
  return false;
@@ -9281,9 +9295,10 @@ function requireLib() {
9281
9295
  shorthandAssignLoc,
9282
9296
  doubleProtoLoc,
9283
9297
  privateKeyLoc,
9284
- optionalParametersLoc
9298
+ optionalParametersLoc,
9299
+ voidPatternLoc
9285
9300
  } = refExpressionErrors;
9286
- const hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc || !!privateKeyLoc;
9301
+ const hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc || !!privateKeyLoc || !!voidPatternLoc;
9287
9302
  if (!andThrow) {
9288
9303
  return hasErrors;
9289
9304
  }
@@ -9299,6 +9314,9 @@ function requireLib() {
9299
9314
  if (optionalParametersLoc != null) {
9300
9315
  this.unexpected(optionalParametersLoc);
9301
9316
  }
9317
+ if (voidPatternLoc != null) {
9318
+ this.raise(Errors.InvalidCoverDiscardElement, voidPatternLoc);
9319
+ }
9302
9320
  }
9303
9321
  isLiteralPropertyName() {
9304
9322
  return tokenIsLiteralPropertyName(this.state.type);
@@ -9346,14 +9364,22 @@ function requireLib() {
9346
9364
  }
9347
9365
  enterInitialScopes() {
9348
9366
  let paramFlags = 0;
9349
- if (this.inModule) {
9367
+ if (this.inModule || this.optionFlags & 1) {
9350
9368
  paramFlags |= 2;
9351
9369
  }
9352
9370
  if (this.optionFlags & 32) {
9353
9371
  paramFlags |= 1;
9354
9372
  }
9355
- this.scope.enter(1);
9373
+ const isCommonJS = !this.inModule && this.options.sourceType === "commonjs";
9374
+ if (isCommonJS || this.optionFlags & 2) {
9375
+ paramFlags |= 4;
9376
+ }
9356
9377
  this.prodParam.enter(paramFlags);
9378
+ let scopeFlags = isCommonJS ? 514 : 1;
9379
+ if (this.optionFlags & 4) {
9380
+ scopeFlags |= 512;
9381
+ }
9382
+ this.scope.enter(scopeFlags);
9357
9383
  }
9358
9384
  checkDestructuringPrivate(refExpressionErrors) {
9359
9385
  const {
@@ -9370,6 +9396,7 @@ function requireLib() {
9370
9396
  this.doubleProtoLoc = null;
9371
9397
  this.privateKeyLoc = null;
9372
9398
  this.optionalParametersLoc = null;
9399
+ this.voidPatternLoc = null;
9373
9400
  }
9374
9401
  }
9375
9402
  class Node {
@@ -9443,7 +9470,7 @@ function requireLib() {
9443
9470
  start,
9444
9471
  end,
9445
9472
  loc,
9446
- range,
9473
+ range: range2,
9447
9474
  name: name2
9448
9475
  } = node;
9449
9476
  const cloned = Object.create(NodePrototype);
@@ -9451,7 +9478,7 @@ function requireLib() {
9451
9478
  cloned.start = start;
9452
9479
  cloned.end = end;
9453
9480
  cloned.loc = loc;
9454
- cloned.range = range;
9481
+ cloned.range = range2;
9455
9482
  cloned.name = name2;
9456
9483
  if (node.extra) cloned.extra = node.extra;
9457
9484
  return cloned;
@@ -9462,7 +9489,7 @@ function requireLib() {
9462
9489
  start,
9463
9490
  end,
9464
9491
  loc,
9465
- range,
9492
+ range: range2,
9466
9493
  extra
9467
9494
  } = node;
9468
9495
  const cloned = Object.create(NodePrototype);
@@ -9470,7 +9497,7 @@ function requireLib() {
9470
9497
  cloned.start = start;
9471
9498
  cloned.end = end;
9472
9499
  cloned.loc = loc;
9473
- cloned.range = range;
9500
+ cloned.range = range2;
9474
9501
  cloned.extra = extra;
9475
9502
  cloned.value = node.value;
9476
9503
  return cloned;
@@ -9501,6 +9528,7 @@ function requireLib() {
9501
9528
  case "ArrayPattern":
9502
9529
  case "AssignmentPattern":
9503
9530
  case "RestElement":
9531
+ case "VoidPattern":
9504
9532
  break;
9505
9533
  case "ObjectExpression":
9506
9534
  this.castNodeTo(node, "ObjectPattern");
@@ -9538,6 +9566,9 @@ function requireLib() {
9538
9566
  }
9539
9567
  this.castNodeTo(node, "AssignmentPattern");
9540
9568
  delete node.operator;
9569
+ if (node.left.type === "VoidPattern") {
9570
+ this.raise(Errors.VoidPatternInitializer, node.left);
9571
+ }
9541
9572
  this.toAssignable(node.left, isLHS);
9542
9573
  break;
9543
9574
  case "ParenthesizedExpression":
@@ -9593,6 +9624,7 @@ function requireLib() {
9593
9624
  case "ArrayPattern":
9594
9625
  case "AssignmentPattern":
9595
9626
  case "RestElement":
9627
+ case "VoidPattern":
9596
9628
  return true;
9597
9629
  case "ObjectExpression": {
9598
9630
  const last = node.properties.length - 1;
@@ -9637,7 +9669,11 @@ function requireLib() {
9637
9669
  parseRestBinding() {
9638
9670
  const node = this.startNode();
9639
9671
  this.next();
9640
- node.argument = this.parseBindingAtom();
9672
+ const argument = this.parseBindingAtom();
9673
+ if (argument.type === "VoidPattern") {
9674
+ this.raise(Errors.UnexpectedVoidPattern, argument);
9675
+ }
9676
+ node.argument = argument;
9641
9677
  return this.finishNode(node, "RestElement");
9642
9678
  }
9643
9679
  parseBindingAtom() {
@@ -9650,6 +9686,8 @@ function requireLib() {
9650
9686
  }
9651
9687
  case 5:
9652
9688
  return this.parseObjectLike(8, true);
9689
+ case 88:
9690
+ return this.parseVoidPattern(null);
9653
9691
  }
9654
9692
  return this.parseIdentifier();
9655
9693
  }
@@ -9694,7 +9732,12 @@ function requireLib() {
9694
9732
  }
9695
9733
  parseBindingRestProperty(prop) {
9696
9734
  this.next();
9697
- prop.argument = this.parseIdentifier();
9735
+ if (this.hasPlugin("discardBinding") && this.match(88)) {
9736
+ prop.argument = this.parseVoidPattern(null);
9737
+ this.raise(Errors.UnexpectedVoidPattern, prop.argument);
9738
+ } else {
9739
+ prop.argument = this.parseIdentifier();
9740
+ }
9698
9741
  this.checkCommaAfterRest(125);
9699
9742
  return this.finishNode(prop, "RestElement");
9700
9743
  }
@@ -9737,6 +9780,9 @@ function requireLib() {
9737
9780
  left = left != null ? left : this.parseBindingAtom();
9738
9781
  if (!this.eat(29)) return left;
9739
9782
  const node = this.startNodeAt(startLoc);
9783
+ if (left.type === "VoidPattern") {
9784
+ this.raise(Errors.VoidPatternInitializer, left);
9785
+ }
9740
9786
  node.left = left;
9741
9787
  node.right = this.parseMaybeAssignAllowIn();
9742
9788
  return this.finishNode(node, "AssignmentPattern");
@@ -9755,6 +9801,8 @@ function requireLib() {
9755
9801
  return "elements";
9756
9802
  case "ObjectPattern":
9757
9803
  return "properties";
9804
+ case "VoidPattern":
9805
+ return true;
9758
9806
  }
9759
9807
  return false;
9760
9808
  }
@@ -9793,6 +9841,8 @@ function requireLib() {
9793
9841
  }
9794
9842
  }
9795
9843
  return;
9844
+ } else if (type2 === "VoidPattern" && ancestor.type === "CatchClause") {
9845
+ this.raise(Errors.VoidPatternCatchClauseParam, expression);
9796
9846
  }
9797
9847
  const validity = this.isValidLVal(type2, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
9798
9848
  if (validity === true) return;
@@ -9976,7 +10026,8 @@ function requireLib() {
9976
10026
  UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.",
9977
10027
  UnsupportedSignatureParameterKind: ({
9978
10028
  type: type2
9979
- }) => `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type2}.`
10029
+ }) => `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type2}.`,
10030
+ UsingDeclarationInAmbientContext: (kind) => `'${kind}' declarations are not allowed in ambient contexts.`
9980
10031
  });
9981
10032
  function keywordTypeFromName(value) {
9982
10033
  switch (value) {
@@ -10990,7 +11041,7 @@ function requireLib() {
10990
11041
  return this.finishNode(node, "TSConditionalType");
10991
11042
  }
10992
11043
  isAbstractConstructorSignature() {
10993
- return this.isContextual(124) && this.lookahead().type === 77;
11044
+ return this.isContextual(124) && this.isLookaheadContextual("new");
10994
11045
  }
10995
11046
  tsParseNonConditionalType() {
10996
11047
  if (this.tsIsStartOfFunctionType()) {
@@ -11061,7 +11112,7 @@ function requireLib() {
11061
11112
  node.typeAnnotation = this.tsInType(() => {
11062
11113
  node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers);
11063
11114
  this.expect(29);
11064
- if (this.isContextual(114) && this.lookahead().type !== 16) {
11115
+ if (this.isContextual(114) && this.lookaheadCharCode() !== 46) {
11065
11116
  const node2 = this.startNode();
11066
11117
  this.next();
11067
11118
  return this.finishNode(node2, "TSIntrinsicKeyword");
@@ -11174,7 +11225,7 @@ function requireLib() {
11174
11225
  this.tsParseModuleOrNamespaceDeclaration(inner, true);
11175
11226
  node.body = inner;
11176
11227
  } else {
11177
- this.scope.enter(512);
11228
+ this.scope.enter(1024);
11178
11229
  this.prodParam.enter(0);
11179
11230
  node.body = this.tsParseModuleBlock();
11180
11231
  this.prodParam.exit();
@@ -11196,7 +11247,7 @@ function requireLib() {
11196
11247
  this.unexpected();
11197
11248
  }
11198
11249
  if (this.match(5)) {
11199
- this.scope.enter(512);
11250
+ this.scope.enter(1024);
11200
11251
  this.prodParam.enter(0);
11201
11252
  node.body = this.tsParseModuleBlock();
11202
11253
  this.prodParam.exit();
@@ -11294,14 +11345,14 @@ function requireLib() {
11294
11345
  declare: true
11295
11346
  });
11296
11347
  case 107:
11297
- if (this.hasPlugin("explicitResourceManagement") && this.isUsing()) {
11348
+ if (this.isUsing()) {
11298
11349
  this.raise(TSErrors.InvalidModifierOnUsingDeclaration, this.state.startLoc, "declare");
11299
11350
  node.declare = true;
11300
11351
  return this.parseVarStatement(node, "using", true);
11301
11352
  }
11302
11353
  break;
11303
11354
  case 96:
11304
- if (this.hasPlugin("explicitResourceManagement") && this.isAwaitUsing()) {
11355
+ if (this.isAwaitUsing()) {
11305
11356
  this.raise(TSErrors.InvalidModifierOnAwaitUsingDeclaration, this.state.startLoc, "declare");
11306
11357
  node.declare = true;
11307
11358
  this.next();
@@ -11335,7 +11386,7 @@ function requireLib() {
11335
11386
  }
11336
11387
  case "global":
11337
11388
  if (this.match(5)) {
11338
- this.scope.enter(512);
11389
+ this.scope.enter(1024);
11339
11390
  this.prodParam.enter(0);
11340
11391
  const mod = node;
11341
11392
  mod.kind = "global";
@@ -11566,7 +11617,7 @@ function requireLib() {
11566
11617
  if (!noCalls && this.eat(10)) {
11567
11618
  const node2 = this.startNodeAt(startLoc);
11568
11619
  node2.callee = base;
11569
- node2.arguments = this.parseCallExpressionArguments(11);
11620
+ node2.arguments = this.parseCallExpressionArguments();
11570
11621
  this.tsCheckForInvalidTypeCasts(node2.arguments);
11571
11622
  {
11572
11623
  node2.typeParameters = typeArguments;
@@ -11724,7 +11775,7 @@ function requireLib() {
11724
11775
  }
11725
11776
  }
11726
11777
  isAbstractClass() {
11727
- return this.isContextual(124) && this.lookahead().type === 80;
11778
+ return this.isContextual(124) && this.isLookaheadContextual("class");
11728
11779
  }
11729
11780
  parseExportDefaultExpression() {
11730
11781
  if (this.isAbstractClass()) {
@@ -11745,6 +11796,10 @@ function requireLib() {
11745
11796
  } = this.state;
11746
11797
  const declaration = super.parseVarStatement(node, kind, allowMissingInitializer || isAmbientContext);
11747
11798
  if (!isAmbientContext) return declaration;
11799
+ if (!node.declare && (kind === "using" || kind === "await using")) {
11800
+ this.raiseOverwrite(TSErrors.UsingDeclarationInAmbientContext, node, kind);
11801
+ return declaration;
11802
+ }
11748
11803
  for (const {
11749
11804
  id,
11750
11805
  init
@@ -12715,8 +12770,8 @@ function requireLib() {
12715
12770
  if (super.chStartsBindingIdentifier(ch, pos2)) {
12716
12771
  return true;
12717
12772
  }
12718
- const nextToken = this.lookahead();
12719
- if (nextToken.type === 133) {
12773
+ const next = this.nextTokenStart();
12774
+ if (this.input.charCodeAt(next) === 37 && this.input.charCodeAt(next + 1) === 37) {
12720
12775
  return true;
12721
12776
  }
12722
12777
  return false;
@@ -12956,6 +13011,9 @@ function requireLib() {
12956
13011
  if (pluginsMap.has("optionalChainingAssign") && pluginsMap.get("optionalChainingAssign").version !== "2023-07") {
12957
13012
  throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is '2023-07'.");
12958
13013
  }
13014
+ if (pluginsMap.has("discardBinding") && pluginsMap.get("discardBinding").syntaxType !== "void") {
13015
+ throw new Error("The 'discardBinding' plugin requires a 'syntaxType' option. Currently the only supported value is 'void'.");
13016
+ }
12959
13017
  }
12960
13018
  const mixinPlugins = {
12961
13019
  estree,
@@ -13091,6 +13149,9 @@ function requireLib() {
13091
13149
  this.checkDestructuringPrivate(refExpressionErrors);
13092
13150
  refExpressionErrors.privateKeyLoc = null;
13093
13151
  }
13152
+ if (refExpressionErrors.voidPatternLoc != null && refExpressionErrors.voidPatternLoc.index >= startIndex) {
13153
+ refExpressionErrors.voidPatternLoc = null;
13154
+ }
13094
13155
  } else {
13095
13156
  node.left = left;
13096
13157
  }
@@ -13419,9 +13480,9 @@ function requireLib() {
13419
13480
  node.optional = optional;
13420
13481
  }
13421
13482
  if (optional) {
13422
- node.arguments = this.parseCallExpressionArguments(11);
13483
+ node.arguments = this.parseCallExpressionArguments();
13423
13484
  } else {
13424
- node.arguments = this.parseCallExpressionArguments(11, base.type !== "Super", node, refExpressionErrors);
13485
+ node.arguments = this.parseCallExpressionArguments(base.type !== "Super", node, refExpressionErrors);
13425
13486
  }
13426
13487
  let finishedNode = this.finishCallExpression(node, optionalChainMember);
13427
13488
  if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
@@ -13469,17 +13530,17 @@ function requireLib() {
13469
13530
  }
13470
13531
  return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression");
13471
13532
  }
13472
- parseCallExpressionArguments(close, allowPlaceholder, nodeForExtra, refExpressionErrors) {
13533
+ parseCallExpressionArguments(allowPlaceholder, nodeForExtra, refExpressionErrors) {
13473
13534
  const elts = [];
13474
13535
  let first = true;
13475
13536
  const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
13476
13537
  this.state.inFSharpPipelineDirectBody = false;
13477
- while (!this.eat(close)) {
13538
+ while (!this.eat(11)) {
13478
13539
  if (first) {
13479
13540
  first = false;
13480
13541
  } else {
13481
13542
  this.expect(12);
13482
- if (this.match(close)) {
13543
+ if (this.match(11)) {
13483
13544
  if (nodeForExtra) {
13484
13545
  this.addTrailingCommaExtraToNode(nodeForExtra);
13485
13546
  }
@@ -13487,7 +13548,7 @@ function requireLib() {
13487
13548
  break;
13488
13549
  }
13489
13550
  }
13490
- elts.push(this.parseExprListItem(false, refExpressionErrors, allowPlaceholder));
13551
+ elts.push(this.parseExprListItem(11, false, refExpressionErrors, allowPlaceholder));
13491
13552
  }
13492
13553
  this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
13493
13554
  return elts;
@@ -13842,7 +13903,9 @@ function requireLib() {
13842
13903
  return this.parseLiteral(value, "NumericLiteral");
13843
13904
  }
13844
13905
  parseBigIntLiteral(value) {
13845
- return this.parseLiteral(value, "BigIntLiteral");
13906
+ {
13907
+ return this.parseLiteral(value, "BigIntLiteral");
13908
+ }
13846
13909
  }
13847
13910
  parseDecimalLiteral(value) {
13848
13911
  return this.parseLiteral(value, "DecimalLiteral");
@@ -13899,7 +13962,7 @@ function requireLib() {
13899
13962
  break;
13900
13963
  }
13901
13964
  } else {
13902
- exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem));
13965
+ exprList.push(this.parseMaybeAssignAllowInOrVoidPattern(11, refExpressionErrors, this.parseParenItem));
13903
13966
  }
13904
13967
  }
13905
13968
  const innerEndLoc = this.state.lastTokEndLoc;
@@ -13961,7 +14024,7 @@ function requireLib() {
13961
14024
  const meta = this.createIdentifier(this.startNodeAtNode(node), "new");
13962
14025
  this.next();
13963
14026
  const metaProp = this.parseMetaProperty(node, meta, "target");
13964
- if (!this.scope.inNonArrowFunction && !this.scope.inClass && !(this.optionFlags & 4)) {
14027
+ if (!this.scope.allowNewTarget) {
13965
14028
  this.raise(Errors.UnexpectedNewTarget, metaProp);
13966
14029
  }
13967
14030
  return metaProp;
@@ -14176,7 +14239,7 @@ function requireLib() {
14176
14239
  parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
14177
14240
  prop.shorthand = false;
14178
14241
  if (this.eat(14)) {
14179
- prop.value = isPattern ? this.parseMaybeDefault(this.state.startLoc) : this.parseMaybeAssignAllowIn(refExpressionErrors);
14242
+ prop.value = isPattern ? this.parseMaybeDefault(this.state.startLoc) : this.parseMaybeAssignAllowInOrVoidPattern(8, refExpressionErrors);
14180
14243
  return this.finishObjectProperty(prop);
14181
14244
  }
14182
14245
  if (!prop.computed && prop.key.type === "Identifier") {
@@ -14266,7 +14329,7 @@ function requireLib() {
14266
14329
  parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type2, inClassScope = false) {
14267
14330
  this.initFunction(node, isAsync);
14268
14331
  node.generator = isGenerator;
14269
- this.scope.enter(2 | 16 | (inClassScope ? 64 : 0) | (allowDirectSuper ? 32 : 0));
14332
+ this.scope.enter(514 | 16 | (inClassScope ? 576 : 0) | (allowDirectSuper ? 32 : 0));
14270
14333
  this.prodParam.enter(functionFlags(isAsync, node.generator));
14271
14334
  this.parseFunctionParams(node, isConstructor);
14272
14335
  const finishedNode = this.parseFunctionBodyAndFinish(node, type2, true);
@@ -14287,7 +14350,7 @@ function requireLib() {
14287
14350
  return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
14288
14351
  }
14289
14352
  parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
14290
- this.scope.enter(2 | 4);
14353
+ this.scope.enter(514 | 4);
14291
14354
  let flags = functionFlags(isAsync, false);
14292
14355
  if (!this.match(5) && this.prodParam.hasIn) {
14293
14356
  flags |= 8;
@@ -14375,11 +14438,11 @@ function requireLib() {
14375
14438
  break;
14376
14439
  }
14377
14440
  }
14378
- elts.push(this.parseExprListItem(allowEmpty, refExpressionErrors));
14441
+ elts.push(this.parseExprListItem(close, allowEmpty, refExpressionErrors));
14379
14442
  }
14380
14443
  return elts;
14381
14444
  }
14382
- parseExprListItem(allowEmpty, refExpressionErrors, allowPlaceholder) {
14445
+ parseExprListItem(close, allowEmpty, refExpressionErrors, allowPlaceholder) {
14383
14446
  let elt;
14384
14447
  if (this.match(12)) {
14385
14448
  if (!allowEmpty) {
@@ -14400,7 +14463,7 @@ function requireLib() {
14400
14463
  this.next();
14401
14464
  elt = this.finishNode(node, "ArgumentPlaceholder");
14402
14465
  } else {
14403
- elt = this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem);
14466
+ elt = this.parseMaybeAssignAllowInOrVoidPattern(close, refExpressionErrors, this.parseParenItem);
14404
14467
  }
14405
14468
  return elt;
14406
14469
  }
@@ -14483,7 +14546,7 @@ function requireLib() {
14483
14546
  }
14484
14547
  }
14485
14548
  recordAwaitIfAllowed() {
14486
- const isAwaitAllowed = this.prodParam.hasAwait || this.optionFlags & 1 && !this.scope.inFunction;
14549
+ const isAwaitAllowed = this.prodParam.hasAwait;
14487
14550
  if (isAwaitAllowed && !this.scope.inFunction) {
14488
14551
  this.state.hasTopLevelAwait = true;
14489
14552
  }
@@ -14702,6 +14765,24 @@ function requireLib() {
14702
14765
  }
14703
14766
  return this.finishNode(node, "ModuleExpression");
14704
14767
  }
14768
+ parseVoidPattern(refExpressionErrors) {
14769
+ this.expectPlugin("discardBinding");
14770
+ const node = this.startNode();
14771
+ if (refExpressionErrors != null) {
14772
+ refExpressionErrors.voidPatternLoc = this.state.startLoc;
14773
+ }
14774
+ this.next();
14775
+ return this.finishNode(node, "VoidPattern");
14776
+ }
14777
+ parseMaybeAssignAllowInOrVoidPattern(close, refExpressionErrors, afterLeftParse) {
14778
+ if (refExpressionErrors != null && this.match(88)) {
14779
+ const nextCode = this.lookaheadCharCode();
14780
+ if (nextCode === 44 || nextCode === (close === 3 ? 93 : close === 8 ? 125 : 41) || nextCode === 61) {
14781
+ return this.parseMaybeDefault(this.state.startLoc, this.parseVoidPattern(refExpressionErrors));
14782
+ }
14783
+ }
14784
+ return this.parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse);
14785
+ }
14705
14786
  parsePropertyNamePrefixOperator(prop) {
14706
14787
  }
14707
14788
  }
@@ -14821,14 +14902,14 @@ function requireLib() {
14821
14902
  }
14822
14903
  class StatementParser extends ExpressionParser {
14823
14904
  parseTopLevel(file, program) {
14824
- file.program = this.parseProgram(program);
14905
+ file.program = this.parseProgram(program, 140, this.options.sourceType === "module" ? "module" : "script");
14825
14906
  file.comments = this.comments;
14826
14907
  if (this.optionFlags & 256) {
14827
14908
  file.tokens = babel7CompatTokens(this.tokens, this.input, this.startIndex);
14828
14909
  }
14829
14910
  return this.finishNode(file, "File");
14830
14911
  }
14831
- parseProgram(program, end = 140, sourceType = this.options.sourceType) {
14912
+ parseProgram(program, end, sourceType) {
14832
14913
  program.sourceType = sourceType;
14833
14914
  program.interpreter = this.parseInterpreterDirective();
14834
14915
  this.parseBlockBody(program, true, true, end);
@@ -14886,6 +14967,23 @@ function requireLib() {
14886
14967
  const nextCh = this.codePointAtPos(next);
14887
14968
  return this.chStartsBindingIdentifier(nextCh, next);
14888
14969
  }
14970
+ isForUsing() {
14971
+ if (!this.isContextual(107)) {
14972
+ return false;
14973
+ }
14974
+ const next = this.nextTokenInLineStart();
14975
+ const nextCh = this.codePointAtPos(next);
14976
+ if (this.isUnparsedContextual(next, "of")) {
14977
+ const nextCharAfterOf = this.lookaheadCharCodeSince(next + 2);
14978
+ if (nextCharAfterOf !== 61 && nextCharAfterOf !== 58 && nextCharAfterOf !== 59) {
14979
+ return false;
14980
+ }
14981
+ }
14982
+ if (this.chStartsBindingIdentifier(nextCh, next) || this.isUnparsedContextual(next, "void")) {
14983
+ return true;
14984
+ }
14985
+ return false;
14986
+ }
14889
14987
  isAwaitUsing() {
14890
14988
  if (!this.isContextual(96)) {
14891
14989
  return false;
@@ -14895,7 +14993,6 @@ function requireLib() {
14895
14993
  next = this.nextTokenInLineStartSince(next + 5);
14896
14994
  const nextCh = this.codePointAtPos(next);
14897
14995
  if (this.chStartsBindingIdentifier(nextCh, next)) {
14898
- this.expectPlugin("explicitResourceManagement");
14899
14996
  return true;
14900
14997
  }
14901
14998
  }
@@ -14930,24 +15027,6 @@ function requireLib() {
14930
15027
  const nextCh = this.codePointAtPos(next);
14931
15028
  return nextCh === 123 || this.chStartsBindingIdentifier(nextCh, next);
14932
15029
  }
14933
- allowsForUsing() {
14934
- const {
14935
- type: type2,
14936
- containsEsc,
14937
- end
14938
- } = this.lookahead();
14939
- if (type2 === 102 && !containsEsc) {
14940
- const nextCharAfterOf = this.lookaheadCharCodeSince(end);
14941
- if (nextCharAfterOf !== 61 && nextCharAfterOf !== 58 && nextCharAfterOf !== 59) {
14942
- return false;
14943
- }
14944
- }
14945
- if (tokenIsIdentifier(type2) && !this.hasFollowingLineBreak()) {
14946
- this.expectPlugin("explicitResourceManagement");
14947
- return true;
14948
- }
14949
- return false;
14950
- }
14951
15030
  allowsUsing() {
14952
15031
  return (this.scope.inModule || !this.scope.inTopLevel) && !this.scope.inBareCaseStatement;
14953
15032
  }
@@ -15030,7 +15109,6 @@ function requireLib() {
15030
15109
  if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifierOrBrace()) {
15031
15110
  break;
15032
15111
  }
15033
- this.expectPlugin("explicitResourceManagement");
15034
15112
  if (!this.allowsUsing()) {
15035
15113
  this.raise(Errors.UnexpectedUsingDeclaration, this.state.startLoc);
15036
15114
  } else if (!allowDeclaration) {
@@ -15193,7 +15271,7 @@ function requireLib() {
15193
15271
  if (this.eat(10)) {
15194
15272
  const node = this.startNodeAt(startLoc);
15195
15273
  node.callee = expr;
15196
- node.arguments = this.parseCallExpressionArguments(11);
15274
+ node.arguments = this.parseCallExpressionArguments();
15197
15275
  this.toReferencedList(node.arguments);
15198
15276
  return this.finishNode(node, "CallExpression");
15199
15277
  }
@@ -15268,7 +15346,7 @@ function requireLib() {
15268
15346
  const startsWithLet = this.isContextual(100);
15269
15347
  {
15270
15348
  const startsWithAwaitUsing = this.isAwaitUsing();
15271
- const starsWithUsingDeclaration = startsWithAwaitUsing || this.isContextual(107) && this.allowsForUsing();
15349
+ const starsWithUsingDeclaration = startsWithAwaitUsing || this.isForUsing();
15272
15350
  const isLetOrUsing = startsWithLet && this.hasFollowingBindingAtom() || starsWithUsingDeclaration;
15273
15351
  if (this.match(74) || this.match(75) || isLetOrUsing) {
15274
15352
  const initNode = this.startNode();
@@ -15338,7 +15416,7 @@ function requireLib() {
15338
15416
  return this.finishNode(node, "IfStatement");
15339
15417
  }
15340
15418
  parseReturnStatement(node) {
15341
- if (!this.prodParam.hasReturn && !(this.optionFlags & 2)) {
15419
+ if (!this.prodParam.hasReturn) {
15342
15420
  this.raise(Errors.IllegalReturn, this.state.startLoc);
15343
15421
  }
15344
15422
  this.next();
@@ -15610,6 +15688,10 @@ function requireLib() {
15610
15688
  if (id.type === "ArrayPattern" || id.type === "ObjectPattern") {
15611
15689
  this.raise(Errors.UsingDeclarationHasBindingPattern, id.loc.start);
15612
15690
  }
15691
+ } else {
15692
+ if (id.type === "VoidPattern") {
15693
+ this.raise(Errors.UnexpectedVoidPattern, id.loc.start);
15694
+ }
15613
15695
  }
15614
15696
  this.checkLVal(id, {
15615
15697
  type: "VariableDeclarator"
@@ -15637,7 +15719,7 @@ function requireLib() {
15637
15719
  }
15638
15720
  const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
15639
15721
  this.state.maybeInArrowParameters = false;
15640
- this.scope.enter(2);
15722
+ this.scope.enter(514);
15641
15723
  this.prodParam.enter(functionFlags(isAsync, node.generator));
15642
15724
  if (!isDeclaration) {
15643
15725
  node.id = this.parseFunctionId();
@@ -15890,7 +15972,7 @@ function requireLib() {
15890
15972
  }
15891
15973
  parseClassStaticBlock(classBody, member) {
15892
15974
  var _member$decorators;
15893
- this.scope.enter(64 | 128 | 16);
15975
+ this.scope.enter(576 | 128 | 16);
15894
15976
  const oldLabels = this.state.labels;
15895
15977
  this.state.labels = [];
15896
15978
  this.prodParam.enter(0);
@@ -15955,7 +16037,7 @@ function requireLib() {
15955
16037
  return this.finishNode(node, "ClassAccessorProperty");
15956
16038
  }
15957
16039
  parseInitializer(node) {
15958
- this.scope.enter(64 | 16);
16040
+ this.scope.enter(576 | 16);
15959
16041
  this.expressionScope.enter(newExpressionScope());
15960
16042
  this.prodParam.enter(0);
15961
16043
  node.value = this.eat(29) ? this.parseMaybeAssignAllowIn() : null;
@@ -16122,7 +16204,7 @@ function requireLib() {
16122
16204
  }
16123
16205
  return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(false), this.startNode()), true, true);
16124
16206
  }
16125
- if (this.match(75) || this.match(74) || this.isLet() || this.hasPlugin("explicitResourceManagement") && (this.isUsing() || this.isAwaitUsing())) {
16207
+ if (this.match(75) || this.match(74) || this.isLet() || this.isUsing() || this.isAwaitUsing()) {
16126
16208
  throw this.raise(Errors.UnsupportedDefaultExport, this.state.startLoc);
16127
16209
  }
16128
16210
  const res = this.parseMaybeAssignAllowIn();
@@ -16145,10 +16227,9 @@ function requireLib() {
16145
16227
  return false;
16146
16228
  }
16147
16229
  if ((type2 === 130 || type2 === 129) && !this.state.containsEsc) {
16148
- const {
16149
- type: nextType
16150
- } = this.lookahead();
16151
- if (tokenIsIdentifier(nextType) && nextType !== 98 || nextType === 5) {
16230
+ const next2 = this.nextTokenStart();
16231
+ const nextChar = this.input.charCodeAt(next2);
16232
+ if (nextChar === 123 || this.chStartsBindingIdentifier(nextChar, next2) && !this.input.startsWith("from", next2)) {
16152
16233
  this.expectOnePlugin(["flow", "typescript"]);
16153
16234
  return false;
16154
16235
  }
@@ -16191,15 +16272,13 @@ function requireLib() {
16191
16272
  return true;
16192
16273
  }
16193
16274
  }
16194
- if (this.hasPlugin("explicitResourceManagement")) {
16195
- if (this.isUsing()) {
16196
- this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
16197
- return true;
16198
- }
16199
- if (this.isAwaitUsing()) {
16200
- this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
16201
- return true;
16202
- }
16275
+ if (this.isUsing()) {
16276
+ this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
16277
+ return true;
16278
+ }
16279
+ if (this.isAwaitUsing()) {
16280
+ this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
16281
+ return true;
16203
16282
  }
16204
16283
  return type2 === 74 || type2 === 75 || type2 === 68 || type2 === 80 || this.isLet() || this.isAsyncFunction();
16205
16284
  }
@@ -16966,217 +17045,212 @@ async function getExportedPathsFromContent(content) {
16966
17045
  const matches = content.match(EXPORT_PATH_REGEX);
16967
17046
  return matches?.map((x) => x) ?? [];
16968
17047
  }
16969
- var balancedMatch;
16970
- var hasRequiredBalancedMatch;
16971
- function requireBalancedMatch() {
16972
- if (hasRequiredBalancedMatch) return balancedMatch;
16973
- hasRequiredBalancedMatch = 1;
16974
- balancedMatch = balanced;
16975
- function balanced(a, b, str) {
16976
- if (a instanceof RegExp) a = maybeMatch(a, str);
16977
- if (b instanceof RegExp) b = maybeMatch(b, str);
16978
- var r = range(a, b, str);
16979
- return r && {
16980
- start: r[0],
16981
- end: r[1],
16982
- pre: str.slice(0, r[0]),
16983
- body: str.slice(r[0] + a.length, r[1]),
16984
- post: str.slice(r[1] + b.length)
16985
- };
16986
- }
16987
- function maybeMatch(reg, str) {
16988
- var m = str.match(reg);
16989
- return m ? m[0] : null;
16990
- }
16991
- balanced.range = range;
16992
- function range(a, b, str) {
16993
- var begs, beg, left, right, result;
16994
- var ai = str.indexOf(a);
16995
- var bi = str.indexOf(b, ai + 1);
16996
- var i = ai;
16997
- if (ai >= 0 && bi > 0) {
16998
- if (a === b) {
16999
- return [ai, bi];
17000
- }
17001
- begs = [];
17002
- left = str.length;
17003
- while (i >= 0 && !result) {
17004
- if (i == ai) {
17005
- begs.push(i);
17006
- ai = str.indexOf(a, i + 1);
17007
- } else if (begs.length == 1) {
17008
- result = [begs.pop(), bi];
17009
- } else {
17010
- beg = begs.pop();
17011
- if (beg < left) {
17012
- left = beg;
17013
- right = bi;
17014
- }
17015
- bi = str.indexOf(b, i + 1);
17048
+ const balanced = (a, b, str) => {
17049
+ const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
17050
+ const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
17051
+ const r = ma !== null && mb != null && range(ma, mb, str);
17052
+ return r && {
17053
+ start: r[0],
17054
+ end: r[1],
17055
+ pre: str.slice(0, r[0]),
17056
+ body: str.slice(r[0] + ma.length, r[1]),
17057
+ post: str.slice(r[1] + mb.length)
17058
+ };
17059
+ };
17060
+ const maybeMatch = (reg, str) => {
17061
+ const m = str.match(reg);
17062
+ return m ? m[0] : null;
17063
+ };
17064
+ const range = (a, b, str) => {
17065
+ let begs, beg, left, right = void 0, result;
17066
+ let ai = str.indexOf(a);
17067
+ let bi = str.indexOf(b, ai + 1);
17068
+ let i = ai;
17069
+ if (ai >= 0 && bi > 0) {
17070
+ if (a === b) {
17071
+ return [ai, bi];
17072
+ }
17073
+ begs = [];
17074
+ left = str.length;
17075
+ while (i >= 0 && !result) {
17076
+ if (i === ai) {
17077
+ begs.push(i);
17078
+ ai = str.indexOf(a, i + 1);
17079
+ } else if (begs.length === 1) {
17080
+ const r = begs.pop();
17081
+ if (r !== void 0)
17082
+ result = [r, bi];
17083
+ } else {
17084
+ beg = begs.pop();
17085
+ if (beg !== void 0 && beg < left) {
17086
+ left = beg;
17087
+ right = bi;
17016
17088
  }
17017
- i = ai < bi && ai >= 0 ? ai : bi;
17018
- }
17019
- if (begs.length) {
17020
- result = [left, right];
17089
+ bi = str.indexOf(b, i + 1);
17021
17090
  }
17091
+ i = ai < bi && ai >= 0 ? ai : bi;
17022
17092
  }
17023
- return result;
17024
- }
17025
- return balancedMatch;
17026
- }
17027
- var braceExpansion;
17028
- var hasRequiredBraceExpansion;
17029
- function requireBraceExpansion() {
17030
- if (hasRequiredBraceExpansion) return braceExpansion;
17031
- hasRequiredBraceExpansion = 1;
17032
- var balanced = requireBalancedMatch();
17033
- braceExpansion = expandTop;
17034
- var escSlash = "\0SLASH" + Math.random() + "\0";
17035
- var escOpen = "\0OPEN" + Math.random() + "\0";
17036
- var escClose = "\0CLOSE" + Math.random() + "\0";
17037
- var escComma = "\0COMMA" + Math.random() + "\0";
17038
- var escPeriod = "\0PERIOD" + Math.random() + "\0";
17039
- function numeric(str) {
17040
- return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
17041
- }
17042
- function escapeBraces(str) {
17043
- return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
17044
- }
17045
- function unescapeBraces(str) {
17046
- return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
17047
- }
17048
- function parseCommaParts(str) {
17049
- if (!str)
17050
- return [""];
17051
- var parts = [];
17052
- var m = balanced("{", "}", str);
17053
- if (!m)
17054
- return str.split(",");
17055
- var pre = m.pre;
17056
- var body = m.body;
17057
- var post = m.post;
17058
- var p = pre.split(",");
17059
- p[p.length - 1] += "{" + body + "}";
17060
- var postParts = parseCommaParts(post);
17061
- if (post.length) {
17062
- p[p.length - 1] += postParts.shift();
17063
- p.push.apply(p, postParts);
17064
- }
17065
- parts.push.apply(parts, p);
17066
- return parts;
17067
- }
17068
- function expandTop(str) {
17069
- if (!str)
17070
- return [];
17071
- if (str.substr(0, 2) === "{}") {
17072
- str = "\\{\\}" + str.substr(2);
17093
+ if (begs.length && right !== void 0) {
17094
+ result = [left, right];
17073
17095
  }
17074
- return expand2(escapeBraces(str), true).map(unescapeBraces);
17075
- }
17076
- function embrace(str) {
17077
- return "{" + str + "}";
17078
- }
17079
- function isPadded(el) {
17080
- return /^-?0\d/.test(el);
17081
17096
  }
17082
- function lte(i, y) {
17083
- return i <= y;
17097
+ return result;
17098
+ };
17099
+ const escSlash = "\0SLASH" + Math.random() + "\0";
17100
+ const escOpen = "\0OPEN" + Math.random() + "\0";
17101
+ const escClose = "\0CLOSE" + Math.random() + "\0";
17102
+ const escComma = "\0COMMA" + Math.random() + "\0";
17103
+ const escPeriod = "\0PERIOD" + Math.random() + "\0";
17104
+ const escSlashPattern = new RegExp(escSlash, "g");
17105
+ const escOpenPattern = new RegExp(escOpen, "g");
17106
+ const escClosePattern = new RegExp(escClose, "g");
17107
+ const escCommaPattern = new RegExp(escComma, "g");
17108
+ const escPeriodPattern = new RegExp(escPeriod, "g");
17109
+ const slashPattern = /\\\\/g;
17110
+ const openPattern = /\\{/g;
17111
+ const closePattern = /\\}/g;
17112
+ const commaPattern = /\\,/g;
17113
+ const periodPattern = /\\./g;
17114
+ function numeric(str) {
17115
+ return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
17116
+ }
17117
+ function escapeBraces(str) {
17118
+ return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
17119
+ }
17120
+ function unescapeBraces(str) {
17121
+ return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
17122
+ }
17123
+ function parseCommaParts(str) {
17124
+ if (!str) {
17125
+ return [""];
17126
+ }
17127
+ const parts = [];
17128
+ const m = balanced("{", "}", str);
17129
+ if (!m) {
17130
+ return str.split(",");
17131
+ }
17132
+ const { pre, body, post } = m;
17133
+ const p = pre.split(",");
17134
+ p[p.length - 1] += "{" + body + "}";
17135
+ const postParts = parseCommaParts(post);
17136
+ if (post.length) {
17137
+ p[p.length - 1] += postParts.shift();
17138
+ p.push.apply(p, postParts);
17139
+ }
17140
+ parts.push.apply(parts, p);
17141
+ return parts;
17142
+ }
17143
+ function expand(str) {
17144
+ if (!str) {
17145
+ return [];
17084
17146
  }
17085
- function gte(i, y) {
17086
- return i >= y;
17147
+ if (str.slice(0, 2) === "{}") {
17148
+ str = "\\{\\}" + str.slice(2);
17087
17149
  }
17088
- function expand2(str, isTop) {
17089
- var expansions = [];
17090
- var m = balanced("{", "}", str);
17091
- if (!m) return [str];
17092
- var pre = m.pre;
17093
- var post = m.post.length ? expand2(m.post, false) : [""];
17094
- if (/\$$/.test(m.pre)) {
17095
- for (var k = 0; k < post.length; k++) {
17096
- var expansion = pre + "{" + m.body + "}" + post[k];
17097
- expansions.push(expansion);
17150
+ return expand_(escapeBraces(str), true).map(unescapeBraces);
17151
+ }
17152
+ function embrace(str) {
17153
+ return "{" + str + "}";
17154
+ }
17155
+ function isPadded(el) {
17156
+ return /^-?0\d/.test(el);
17157
+ }
17158
+ function lte(i, y) {
17159
+ return i <= y;
17160
+ }
17161
+ function gte(i, y) {
17162
+ return i >= y;
17163
+ }
17164
+ function expand_(str, isTop) {
17165
+ const expansions = [];
17166
+ const m = balanced("{", "}", str);
17167
+ if (!m)
17168
+ return [str];
17169
+ const pre = m.pre;
17170
+ const post = m.post.length ? expand_(m.post, false) : [""];
17171
+ if (/\$$/.test(m.pre)) {
17172
+ for (let k = 0; k < post.length; k++) {
17173
+ const expansion = pre + "{" + m.body + "}" + post[k];
17174
+ expansions.push(expansion);
17175
+ }
17176
+ } else {
17177
+ const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
17178
+ const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
17179
+ const isSequence = isNumericSequence || isAlphaSequence;
17180
+ const isOptions = m.body.indexOf(",") >= 0;
17181
+ if (!isSequence && !isOptions) {
17182
+ if (m.post.match(/,(?!,).*\}/)) {
17183
+ str = m.pre + "{" + m.body + escClose + m.post;
17184
+ return expand_(str);
17098
17185
  }
17186
+ return [str];
17187
+ }
17188
+ let n;
17189
+ if (isSequence) {
17190
+ n = m.body.split(/\.\./);
17099
17191
  } else {
17100
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
17101
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
17102
- var isSequence = isNumericSequence || isAlphaSequence;
17103
- var isOptions = m.body.indexOf(",") >= 0;
17104
- if (!isSequence && !isOptions) {
17105
- if (m.post.match(/,.*\}/)) {
17106
- str = m.pre + "{" + m.body + escClose + m.post;
17107
- return expand2(str);
17108
- }
17109
- return [str];
17110
- }
17111
- var n;
17112
- if (isSequence) {
17113
- n = m.body.split(/\.\./);
17114
- } else {
17115
- n = parseCommaParts(m.body);
17192
+ n = parseCommaParts(m.body);
17193
+ if (n.length === 1 && n[0] !== void 0) {
17194
+ n = expand_(n[0], false).map(embrace);
17116
17195
  if (n.length === 1) {
17117
- n = expand2(n[0], false).map(embrace);
17118
- if (n.length === 1) {
17119
- return post.map(function(p) {
17120
- return m.pre + n[0] + p;
17121
- });
17196
+ return post.map((p) => m.pre + n[0] + p);
17197
+ }
17198
+ }
17199
+ }
17200
+ let N;
17201
+ if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
17202
+ const x = numeric(n[0]);
17203
+ const y = numeric(n[1]);
17204
+ const width = Math.max(n[0].length, n[1].length);
17205
+ let incr = n.length === 3 && n[2] !== void 0 ? Math.abs(numeric(n[2])) : 1;
17206
+ let test = lte;
17207
+ const reverse = y < x;
17208
+ if (reverse) {
17209
+ incr *= -1;
17210
+ test = gte;
17211
+ }
17212
+ const pad = n.some(isPadded);
17213
+ N = [];
17214
+ for (let i = x; test(i, y); i += incr) {
17215
+ let c2;
17216
+ if (isAlphaSequence) {
17217
+ c2 = String.fromCharCode(i);
17218
+ if (c2 === "\\") {
17219
+ c2 = "";
17122
17220
  }
17123
- }
17124
- }
17125
- var N;
17126
- if (isSequence) {
17127
- var x = numeric(n[0]);
17128
- var y = numeric(n[1]);
17129
- var width = Math.max(n[0].length, n[1].length);
17130
- var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
17131
- var test = lte;
17132
- var reverse = y < x;
17133
- if (reverse) {
17134
- incr *= -1;
17135
- test = gte;
17136
- }
17137
- var pad = n.some(isPadded);
17138
- N = [];
17139
- for (var i = x; test(i, y); i += incr) {
17140
- var c2;
17141
- if (isAlphaSequence) {
17142
- c2 = String.fromCharCode(i);
17143
- if (c2 === "\\")
17144
- c2 = "";
17145
- } else {
17146
- c2 = String(i);
17147
- if (pad) {
17148
- var need = width - c2.length;
17149
- if (need > 0) {
17150
- var z = new Array(need + 1).join("0");
17151
- if (i < 0)
17152
- c2 = "-" + z + c2.slice(1);
17153
- else
17154
- c2 = z + c2;
17221
+ } else {
17222
+ c2 = String(i);
17223
+ if (pad) {
17224
+ const need = width - c2.length;
17225
+ if (need > 0) {
17226
+ const z = new Array(need + 1).join("0");
17227
+ if (i < 0) {
17228
+ c2 = "-" + z + c2.slice(1);
17229
+ } else {
17230
+ c2 = z + c2;
17155
17231
  }
17156
17232
  }
17157
17233
  }
17158
- N.push(c2);
17159
- }
17160
- } else {
17161
- N = [];
17162
- for (var j = 0; j < n.length; j++) {
17163
- N.push.apply(N, expand2(n[j], false));
17164
17234
  }
17235
+ N.push(c2);
17165
17236
  }
17166
- for (var j = 0; j < N.length; j++) {
17167
- for (var k = 0; k < post.length; k++) {
17168
- var expansion = pre + N[j] + post[k];
17169
- if (!isTop || isSequence || expansion)
17170
- expansions.push(expansion);
17237
+ } else {
17238
+ N = [];
17239
+ for (let j = 0; j < n.length; j++) {
17240
+ N.push.apply(N, expand_(n[j], false));
17241
+ }
17242
+ }
17243
+ for (let j = 0; j < N.length; j++) {
17244
+ for (let k = 0; k < post.length; k++) {
17245
+ const expansion = pre + N[j] + post[k];
17246
+ if (!isTop || isSequence || expansion) {
17247
+ expansions.push(expansion);
17171
17248
  }
17172
17249
  }
17173
17250
  }
17174
- return expansions;
17175
17251
  }
17176
- return braceExpansion;
17252
+ return expansions;
17177
17253
  }
17178
- var braceExpansionExports = requireBraceExpansion();
17179
- const expand = /* @__PURE__ */ getDefaultExportFromCjs(braceExpansionExports);
17180
17254
  const MAX_PATTERN_LENGTH = 1024 * 64;
17181
17255
  const assertValidPattern = (pattern) => {
17182
17256
  if (typeof pattern !== "string") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "barrelize",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Automatically generating index (barrel) files",
5
5
  "scripts": {
6
6
  "build": "npm run schema && vite build",
@@ -21,20 +21,20 @@
21
21
  "author": "Nizami",
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
- "@babel/parser": "^7.27.5",
25
- "@ryoppippi/unplugin-typia": "^2.6.4",
26
- "@types/node": "^22.15.30",
24
+ "@babel/parser": "^7.28.0",
25
+ "@ryoppippi/unplugin-typia": "^2.6.5",
26
+ "@types/node": "^24.0.10",
27
27
  "cac": "^6.7.14",
28
28
  "chokidar": "^4.0.3",
29
- "glob": "^11.0.2",
29
+ "glob": "^11.0.3",
30
30
  "json5": "^2.2.3",
31
31
  "ts-json-schema-generator": "^2.4.0",
32
32
  "ts-patch": "^3.3.0",
33
33
  "typescript": "~5.8.3",
34
34
  "typia": "^9.3.1",
35
- "vite": "^6.3.5",
35
+ "vite": "^7.0.2",
36
36
  "vite-plugin-dts": "^4.5.4",
37
- "vitest": "^3.2.2"
37
+ "vitest": "^3.2.4"
38
38
  },
39
39
  "bin": {
40
40
  "barrelize": "./bin/cli.js"