@danielx/civet 0.6.35 → 0.6.37

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/dist/main.js CHANGED
@@ -525,23 +525,16 @@ var require_lib = __commonJS({
525
525
  }
526
526
  }
527
527
  function addPostfixStatement(statement, ws, post) {
528
- let children, expressions;
529
- const prefix = post.blockPrefix || post.condition?.expression.blockPrefix;
530
- if (prefix?.length) {
531
- const indent = prefix[0][0];
532
- expressions = [...prefix, [indent, statement]];
533
- children = [" {\n", ...expressions, "\n", indent?.slice?.(0, -2), "}"];
534
- } else {
535
- expressions = [["", statement]];
536
- children = [" { ", ...expressions, " }"];
537
- }
528
+ const expressions = [
529
+ ...post.blockPrefix || [],
530
+ ["", statement]
531
+ ];
538
532
  const block = {
539
533
  type: "BlockStatement",
540
- children,
534
+ children: [" { ", expressions, " }"],
541
535
  expressions
542
536
  };
543
- children = [...post.children];
544
- children.push(block);
537
+ const children = [...post.children, block];
545
538
  if (!isWhitespaceOrEmpty(ws))
546
539
  children.push(ws);
547
540
  post = { ...post, children, block };
@@ -2117,6 +2110,81 @@ var require_lib = __commonJS({
2117
2110
  children
2118
2111
  };
2119
2112
  }
2113
+ function processDeclarationCondition(condition) {
2114
+ if (!(condition.type === "DeclarationCondition")) {
2115
+ return;
2116
+ }
2117
+ const ref = makeRef();
2118
+ const { decl, bindings } = condition.declaration;
2119
+ const binding = bindings[0];
2120
+ const { pattern, suffix, initializer, splices, thisAssignments } = binding;
2121
+ const initCondition = {
2122
+ type: "AssignmentExpression",
2123
+ children: [ref, initializer],
2124
+ hoistDec: {
2125
+ type: "Declaration",
2126
+ children: ["let ", ref, suffix],
2127
+ names: []
2128
+ },
2129
+ blockPrefix: [
2130
+ ["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
2131
+ ...thisAssignments
2132
+ ],
2133
+ pattern,
2134
+ ref
2135
+ };
2136
+ Object.assign(condition, initCondition);
2137
+ }
2138
+ function processDeclarationConditions(node) {
2139
+ gatherRecursiveAll(node, (n) => {
2140
+ return n.type === "IfStatement" || n.type === "IterationStatement";
2141
+ }).forEach(processDeclarationConditionStatement);
2142
+ }
2143
+ function processDeclarationConditionStatement(s) {
2144
+ const { condition } = s;
2145
+ if (!condition) {
2146
+ return;
2147
+ }
2148
+ processDeclarationCondition(condition.expression);
2149
+ const { ref, pattern } = condition.expression;
2150
+ if (pattern) {
2151
+ let conditions = [];
2152
+ getPatternConditions(pattern, ref, conditions);
2153
+ conditions = conditions.filter((c) => {
2154
+ return !(c.length === 3 && c[0] === "typeof " && c[1] === ref && c[2] === " === 'object'") && !(c.length === 2 && c[0] === ref && c[1] === " != null");
2155
+ });
2156
+ if (conditions.length) {
2157
+ condition.children.unshift("(");
2158
+ conditions.forEach(function(c) {
2159
+ return condition.children.push(" && ", c);
2160
+ });
2161
+ condition.children.push(")");
2162
+ }
2163
+ }
2164
+ switch (s.type) {
2165
+ case "IfStatement": {
2166
+ const { else: e } = s;
2167
+ const block = blockWithPrefix(condition.expression.blockPrefix, s.then);
2168
+ s.then = block;
2169
+ const toAdd = [block];
2170
+ if (block.bare && e) {
2171
+ toAdd.push(";");
2172
+ }
2173
+ s.children.splice(2, 1, ...toAdd);
2174
+ updateParentPointers(block, s);
2175
+ break;
2176
+ }
2177
+ case "IterationStatement": {
2178
+ const { children, block } = s;
2179
+ const newBlock = blockWithPrefix(condition.expression.blockPrefix, block);
2180
+ s.children = children.map(function(c) {
2181
+ return c.type === "BlockStatement" ? newBlock : c;
2182
+ });
2183
+ updateParentPointers(newBlock, s);
2184
+ break;
2185
+ }
2186
+ }
2187
+ }
2120
2188
  function implicitFunctionBlock(f) {
2121
2189
  if (f.abstract || f.block || f.signature?.optional)
2122
2190
  return;
@@ -2790,6 +2858,7 @@ var require_lib = __commonJS({
2790
2858
  assert.equal(m.JSXTagStack.length, 1, "JSXTagStack");
2791
2859
  addParentPointers(root);
2792
2860
  const { expressions: statements } = root;
2861
+ processDeclarationConditions(statements);
2793
2862
  processPipelineExpressions(statements);
2794
2863
  processAssignments(statements);
2795
2864
  processPatternMatching(statements, ReservedWord);
@@ -3892,6 +3961,7 @@ var require_parser = __commonJS({
3892
3961
  Typeof,
3893
3962
  Unless,
3894
3963
  Until,
3964
+ Using,
3895
3965
  Var,
3896
3966
  Void,
3897
3967
  When,
@@ -3942,6 +4012,9 @@ var require_parser = __commonJS({
3942
4012
  JSXChildExpression,
3943
4013
  IndentedJSXChildExpression,
3944
4014
  NestedJSXChildExpression,
4015
+ UsingDeclaration,
4016
+ UsingBinding,
4017
+ UsingJSModeError,
3945
4018
  TypeDeclaration,
3946
4019
  TypeDeclarationRest,
3947
4020
  OptionalEquals,
@@ -4259,29 +4332,30 @@ var require_parser = __commonJS({
4259
4332
  var $L184 = $L("typeof");
4260
4333
  var $L185 = $L("unless");
4261
4334
  var $L186 = $L("until");
4262
- var $L187 = $L("var");
4263
- var $L188 = $L("void");
4264
- var $L189 = $L("when");
4265
- var $L190 = $L("while");
4266
- var $L191 = $L("yield");
4267
- var $L192 = $L("/>");
4268
- var $L193 = $L("</");
4269
- var $L194 = $L("<>");
4270
- var $L195 = $L("</>");
4271
- var $L196 = $L("<!--");
4272
- var $L197 = $L("-->");
4273
- var $L198 = $L("type");
4274
- var $L199 = $L("enum");
4275
- var $L200 = $L("interface");
4276
- var $L201 = $L("global");
4277
- var $L202 = $L("module");
4278
- var $L203 = $L("namespace");
4279
- var $L204 = $L("asserts");
4280
- var $L205 = $L("keyof");
4281
- var $L206 = $L("infer");
4282
- var $L207 = $L("???");
4283
- var $L208 = $L("[]");
4284
- var $L209 = $L("civet");
4335
+ var $L187 = $L("using");
4336
+ var $L188 = $L("var");
4337
+ var $L189 = $L("void");
4338
+ var $L190 = $L("when");
4339
+ var $L191 = $L("while");
4340
+ var $L192 = $L("yield");
4341
+ var $L193 = $L("/>");
4342
+ var $L194 = $L("</");
4343
+ var $L195 = $L("<>");
4344
+ var $L196 = $L("</>");
4345
+ var $L197 = $L("<!--");
4346
+ var $L198 = $L("-->");
4347
+ var $L199 = $L("type");
4348
+ var $L200 = $L("enum");
4349
+ var $L201 = $L("interface");
4350
+ var $L202 = $L("global");
4351
+ var $L203 = $L("module");
4352
+ var $L204 = $L("namespace");
4353
+ var $L205 = $L("asserts");
4354
+ var $L206 = $L("keyof");
4355
+ var $L207 = $L("infer");
4356
+ var $L208 = $L("???");
4357
+ var $L209 = $L("[]");
4358
+ var $L210 = $L("civet");
4285
4359
  var $R0 = $R(new RegExp("(as|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])", "suy"));
4286
4360
  var $R1 = $R(new RegExp("[0-9]", "suy"));
4287
4361
  var $R2 = $R(new RegExp("[)}]", "suy"));
@@ -8095,16 +8169,10 @@ var require_parser = __commonJS({
8095
8169
  var clause = $1;
8096
8170
  var block = $2;
8097
8171
  var e = $3;
8098
- const children = [...clause.children];
8099
- block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
8100
- children.push(block);
8101
- if (block.bare && e)
8102
- children.push(";");
8103
- if (e)
8104
- children.push(e);
8105
8172
  return {
8106
- ...clause,
8107
- children,
8173
+ type: "IfStatement",
8174
+ children: [...clause.children, block, e],
8175
+ condition: clause.condition,
8108
8176
  then: block,
8109
8177
  else: e
8110
8178
  };
@@ -8327,7 +8395,6 @@ var require_parser = __commonJS({
8327
8395
  var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
8328
8396
  var clause = $1;
8329
8397
  var block = $2;
8330
- block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
8331
8398
  return {
8332
8399
  ...clause,
8333
8400
  children: [...clause.children, block],
@@ -8946,27 +9013,13 @@ var require_parser = __commonJS({
8946
9013
  return $EVENT_C(ctx, state, "Condition", Condition$$);
8947
9014
  }
8948
9015
  var DeclarationCondition$0 = $TS($S(ForbidIndentedApplication, $E(LexicalDeclaration), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
8949
- var dec = $2;
8950
- if (!dec)
9016
+ var declaration = $2;
9017
+ if (!declaration)
8951
9018
  return $skip;
8952
- const ref = makeRef();
8953
- const { decl, bindings } = dec;
8954
- const binding = bindings[0];
8955
- const { pattern, suffix, initializer, splices, thisAssignments } = binding;
8956
- const initCondition = {
8957
- type: "AssignmentExpression",
8958
- children: [ref, initializer],
8959
- hoistDec: {
8960
- type: "Declaration",
8961
- children: ["let ", ref, suffix],
8962
- names: []
8963
- },
8964
- blockPrefix: [
8965
- ["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
8966
- ...thisAssignments
8967
- ]
9019
+ return {
9020
+ type: "DeclarationCondition",
9021
+ declaration
8968
9022
  };
8969
- return initCondition;
8970
9023
  });
8971
9024
  function DeclarationCondition(ctx, state) {
8972
9025
  return $EVENT(ctx, state, "DeclarationCondition", DeclarationCondition$0);
@@ -9492,7 +9545,8 @@ var require_parser = __commonJS({
9492
9545
  var Declaration$3 = TypeDeclaration;
9493
9546
  var Declaration$4 = EnumDeclaration;
9494
9547
  var Declaration$5 = OperatorDeclaration;
9495
- var Declaration$$ = [Declaration$0, Declaration$1, Declaration$2, Declaration$3, Declaration$4, Declaration$5];
9548
+ var Declaration$6 = UsingDeclaration;
9549
+ var Declaration$$ = [Declaration$0, Declaration$1, Declaration$2, Declaration$3, Declaration$4, Declaration$5, Declaration$6];
9496
9550
  function Declaration(ctx, state) {
9497
9551
  return $EVENT_C(ctx, state, "Declaration", Declaration$$);
9498
9552
  }
@@ -10565,31 +10619,37 @@ var require_parser = __commonJS({
10565
10619
  function Until(ctx, state) {
10566
10620
  return $EVENT(ctx, state, "Until", Until$0);
10567
10621
  }
10568
- var Var$0 = $TS($S($EXPECT($L187, 'Var "var"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10622
+ var Using$0 = $TS($S($EXPECT($L187, 'Using "using"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10623
+ return { $loc, token: $1 };
10624
+ });
10625
+ function Using(ctx, state) {
10626
+ return $EVENT(ctx, state, "Using", Using$0);
10627
+ }
10628
+ var Var$0 = $TS($S($EXPECT($L188, 'Var "var"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10569
10629
  return { $loc, token: $1 };
10570
10630
  });
10571
10631
  function Var(ctx, state) {
10572
10632
  return $EVENT(ctx, state, "Var", Var$0);
10573
10633
  }
10574
- var Void$0 = $TS($S($EXPECT($L188, 'Void "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10634
+ var Void$0 = $TS($S($EXPECT($L189, 'Void "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10575
10635
  return { $loc, token: $1 };
10576
10636
  });
10577
10637
  function Void(ctx, state) {
10578
10638
  return $EVENT(ctx, state, "Void", Void$0);
10579
10639
  }
10580
- var When$0 = $TS($S($EXPECT($L189, 'When "when"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10640
+ var When$0 = $TS($S($EXPECT($L190, 'When "when"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10581
10641
  return { $loc, token: "case" };
10582
10642
  });
10583
10643
  function When(ctx, state) {
10584
10644
  return $EVENT(ctx, state, "When", When$0);
10585
10645
  }
10586
- var While$0 = $TS($S($EXPECT($L190, 'While "while"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10646
+ var While$0 = $TS($S($EXPECT($L191, 'While "while"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10587
10647
  return { $loc, token: $1 };
10588
10648
  });
10589
10649
  function While(ctx, state) {
10590
10650
  return $EVENT(ctx, state, "While", While$0);
10591
10651
  }
10592
- var Yield$0 = $TS($S($EXPECT($L191, 'Yield "yield"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10652
+ var Yield$0 = $TS($S($EXPECT($L192, 'Yield "yield"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10593
10653
  return { $loc, token: $1, type: "Yield" };
10594
10654
  });
10595
10655
  function Yield(ctx, state) {
@@ -10662,7 +10722,7 @@ var require_parser = __commonJS({
10662
10722
  function JSXElement(ctx, state) {
10663
10723
  return $EVENT_C(ctx, state, "JSXElement", JSXElement$$);
10664
10724
  }
10665
- var JSXSelfClosingElement$0 = $TS($S($EXPECT($L155, 'JSXSelfClosingElement "<"'), JSXElementName, $E(TypeArguments), $E(JSXAttributes), $E(Whitespace), $EXPECT($L192, 'JSXSelfClosingElement "/>"')), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10725
+ var JSXSelfClosingElement$0 = $TS($S($EXPECT($L155, 'JSXSelfClosingElement "<"'), JSXElementName, $E(TypeArguments), $E(JSXAttributes), $E(Whitespace), $EXPECT($L193, 'JSXSelfClosingElement "/>"')), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10666
10726
  return { type: "JSXElement", children: $0, tag: $2 };
10667
10727
  });
10668
10728
  function JSXSelfClosingElement(ctx, state) {
@@ -10696,7 +10756,7 @@ var require_parser = __commonJS({
10696
10756
  function JSXOptionalClosingElement(ctx, state) {
10697
10757
  return $EVENT_C(ctx, state, "JSXOptionalClosingElement", JSXOptionalClosingElement$$);
10698
10758
  }
10699
- var JSXClosingElement$0 = $S($EXPECT($L193, 'JSXClosingElement "</"'), $E(Whitespace), JSXElementName, $E(Whitespace), $EXPECT($L33, 'JSXClosingElement ">"'));
10759
+ var JSXClosingElement$0 = $S($EXPECT($L194, 'JSXClosingElement "</"'), $E(Whitespace), JSXElementName, $E(Whitespace), $EXPECT($L33, 'JSXClosingElement ">"'));
10700
10760
  function JSXClosingElement(ctx, state) {
10701
10761
  return $EVENT(ctx, state, "JSXClosingElement", JSXClosingElement$0);
10702
10762
  }
@@ -10717,7 +10777,7 @@ var require_parser = __commonJS({
10717
10777
  ];
10718
10778
  return { type: "JSXFragment", children: parts, jsxChildren: children.jsxChildren };
10719
10779
  });
10720
- var JSXFragment$1 = $TS($S(CoffeeJSXEnabled, $EXPECT($L194, 'JSXFragment "<>"'), $E(JSXChildren), $E(Whitespace), JSXClosingFragment), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
10780
+ var JSXFragment$1 = $TS($S(CoffeeJSXEnabled, $EXPECT($L195, 'JSXFragment "<>"'), $E(JSXChildren), $E(Whitespace), JSXClosingFragment), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
10721
10781
  var children = $3;
10722
10782
  $0 = $0.slice(1);
10723
10783
  return {
@@ -10730,7 +10790,7 @@ var require_parser = __commonJS({
10730
10790
  function JSXFragment(ctx, state) {
10731
10791
  return $EVENT_C(ctx, state, "JSXFragment", JSXFragment$$);
10732
10792
  }
10733
- var PushJSXOpeningFragment$0 = $TV($EXPECT($L194, 'PushJSXOpeningFragment "<>"'), function($skip, $loc, $0, $1) {
10793
+ var PushJSXOpeningFragment$0 = $TV($EXPECT($L195, 'PushJSXOpeningFragment "<>"'), function($skip, $loc, $0, $1) {
10734
10794
  module2.JSXTagStack.push("");
10735
10795
  return $1;
10736
10796
  });
@@ -10747,7 +10807,7 @@ var require_parser = __commonJS({
10747
10807
  function JSXOptionalClosingFragment(ctx, state) {
10748
10808
  return $EVENT_C(ctx, state, "JSXOptionalClosingFragment", JSXOptionalClosingFragment$$);
10749
10809
  }
10750
- var JSXClosingFragment$0 = $EXPECT($L195, 'JSXClosingFragment "</>"');
10810
+ var JSXClosingFragment$0 = $EXPECT($L196, 'JSXClosingFragment "</>"');
10751
10811
  function JSXClosingFragment(ctx, state) {
10752
10812
  return $EVENT(ctx, state, "JSXClosingFragment", JSXClosingFragment$0);
10753
10813
  }
@@ -11216,7 +11276,7 @@ var require_parser = __commonJS({
11216
11276
  function JSXChild(ctx, state) {
11217
11277
  return $EVENT_C(ctx, state, "JSXChild", JSXChild$$);
11218
11278
  }
11219
- var JSXComment$0 = $TS($S($EXPECT($L196, 'JSXComment "<!--"'), JSXCommentContent, $EXPECT($L197, 'JSXComment "-->"')), function($skip, $loc, $0, $1, $2, $3) {
11279
+ var JSXComment$0 = $TS($S($EXPECT($L197, 'JSXComment "<!--"'), JSXCommentContent, $EXPECT($L198, 'JSXComment "-->"')), function($skip, $loc, $0, $1, $2, $3) {
11220
11280
  return ["{/*", $2, "*/}"];
11221
11281
  });
11222
11282
  function JSXComment(ctx, state) {
@@ -11254,6 +11314,52 @@ var require_parser = __commonJS({
11254
11314
  function NestedJSXChildExpression(ctx, state) {
11255
11315
  return $EVENT(ctx, state, "NestedJSXChildExpression", NestedJSXChildExpression$0);
11256
11316
  }
11317
+ var UsingDeclaration$0 = $TS($S(Using, $E(_), UsingBinding, $Q($S(__, Comma, __, UsingBinding)), UsingJSModeError), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
11318
+ var decl = $1;
11319
+ var binding = $3;
11320
+ var tail = $4;
11321
+ const bindings = [binding].concat(tail.map(([, , , b]) => b));
11322
+ return {
11323
+ type: "Declaration",
11324
+ children: $0,
11325
+ names: bindings.flatMap((b) => b.names),
11326
+ bindings,
11327
+ decl,
11328
+ splices: bindings.flatMap((b) => b.splices),
11329
+ thisAssignments: bindings.flatMap((b) => b.thisAssignments)
11330
+ };
11331
+ });
11332
+ function UsingDeclaration(ctx, state) {
11333
+ return $EVENT(ctx, state, "UsingDeclaration", UsingDeclaration$0);
11334
+ }
11335
+ var UsingBinding$0 = $TS($S(BindingIdentifier, $E(TypeSuffix), Initializer), function($skip, $loc, $0, $1, $2, $3) {
11336
+ var pattern = $1;
11337
+ var suffix = $2;
11338
+ var initializer = $3;
11339
+ return {
11340
+ type: "Binding",
11341
+ children: $0,
11342
+ names: pattern.names,
11343
+ pattern,
11344
+ suffix,
11345
+ initializer,
11346
+ splices: [],
11347
+ thisAssignments: []
11348
+ };
11349
+ });
11350
+ function UsingBinding(ctx, state) {
11351
+ return $EVENT(ctx, state, "UsingBinding", UsingBinding$0);
11352
+ }
11353
+ var UsingJSModeError$0 = $TV($EXPECT($L0, 'UsingJSModeError ""'), function($skip, $loc, $0, $1) {
11354
+ return {
11355
+ type: "Error",
11356
+ js: true,
11357
+ message: "`using` is not currently transpiled in JS mode."
11358
+ };
11359
+ });
11360
+ function UsingJSModeError(ctx, state) {
11361
+ return $EVENT(ctx, state, "UsingJSModeError", UsingJSModeError$0);
11362
+ }
11257
11363
  var TypeDeclaration$0 = $T($S($E($S(Export, $E(_))), $S(Declare, $E(_)), TypeLexicalDeclaration), function(value) {
11258
11364
  return { "ts": true, "children": value };
11259
11365
  });
@@ -11302,37 +11408,37 @@ var require_parser = __commonJS({
11302
11408
  function InterfaceExtendsTarget(ctx, state) {
11303
11409
  return $EVENT(ctx, state, "InterfaceExtendsTarget", InterfaceExtendsTarget$0);
11304
11410
  }
11305
- var TypeKeyword$0 = $TS($S($EXPECT($L198, 'TypeKeyword "type"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11411
+ var TypeKeyword$0 = $TS($S($EXPECT($L199, 'TypeKeyword "type"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11306
11412
  return { $loc, token: $1 };
11307
11413
  });
11308
11414
  function TypeKeyword(ctx, state) {
11309
11415
  return $EVENT(ctx, state, "TypeKeyword", TypeKeyword$0);
11310
11416
  }
11311
- var Enum$0 = $TS($S($EXPECT($L199, 'Enum "enum"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11417
+ var Enum$0 = $TS($S($EXPECT($L200, 'Enum "enum"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11312
11418
  return { $loc, token: $1 };
11313
11419
  });
11314
11420
  function Enum(ctx, state) {
11315
11421
  return $EVENT(ctx, state, "Enum", Enum$0);
11316
11422
  }
11317
- var Interface$0 = $TS($S($EXPECT($L200, 'Interface "interface"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11423
+ var Interface$0 = $TS($S($EXPECT($L201, 'Interface "interface"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11318
11424
  return { $loc, token: $1 };
11319
11425
  });
11320
11426
  function Interface(ctx, state) {
11321
11427
  return $EVENT(ctx, state, "Interface", Interface$0);
11322
11428
  }
11323
- var Global$0 = $TS($S($EXPECT($L201, 'Global "global"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11429
+ var Global$0 = $TS($S($EXPECT($L202, 'Global "global"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11324
11430
  return { $loc, token: $1 };
11325
11431
  });
11326
11432
  function Global(ctx, state) {
11327
11433
  return $EVENT(ctx, state, "Global", Global$0);
11328
11434
  }
11329
- var Module$0 = $TS($S($EXPECT($L202, 'Module "module"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11435
+ var Module$0 = $TS($S($EXPECT($L203, 'Module "module"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11330
11436
  return { $loc, token: $1 };
11331
11437
  });
11332
11438
  function Module(ctx, state) {
11333
11439
  return $EVENT(ctx, state, "Module", Module$0);
11334
11440
  }
11335
- var Namespace$0 = $TS($S($EXPECT($L203, 'Namespace "namespace"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11441
+ var Namespace$0 = $TS($S($EXPECT($L204, 'Namespace "namespace"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11336
11442
  return { $loc, token: $1 };
11337
11443
  });
11338
11444
  function Namespace(ctx, state) {
@@ -11577,7 +11683,7 @@ var require_parser = __commonJS({
11577
11683
  function ReturnTypeSuffix(ctx, state) {
11578
11684
  return $EVENT(ctx, state, "ReturnTypeSuffix", ReturnTypeSuffix$0);
11579
11685
  }
11580
- var ReturnType$0 = $TS($S($E($S(__, $EXPECT($L204, 'ReturnType "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2) {
11686
+ var ReturnType$0 = $TS($S($E($S(__, $EXPECT($L205, 'ReturnType "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2) {
11581
11687
  var asserts = $1;
11582
11688
  var t = $2;
11583
11689
  if (asserts) {
@@ -11646,9 +11752,9 @@ var require_parser = __commonJS({
11646
11752
  function TypeUnarySuffix(ctx, state) {
11647
11753
  return $EVENT_C(ctx, state, "TypeUnarySuffix", TypeUnarySuffix$$);
11648
11754
  }
11649
- var TypeUnaryOp$0 = $S($EXPECT($L205, 'TypeUnaryOp "keyof"'), NonIdContinue);
11755
+ var TypeUnaryOp$0 = $S($EXPECT($L206, 'TypeUnaryOp "keyof"'), NonIdContinue);
11650
11756
  var TypeUnaryOp$1 = $S($EXPECT($L184, 'TypeUnaryOp "typeof"'), NonIdContinue);
11651
- var TypeUnaryOp$2 = $S($EXPECT($L206, 'TypeUnaryOp "infer"'), NonIdContinue);
11757
+ var TypeUnaryOp$2 = $S($EXPECT($L207, 'TypeUnaryOp "infer"'), NonIdContinue);
11652
11758
  var TypeUnaryOp$3 = $S($EXPECT($L167, 'TypeUnaryOp "readonly"'), NonIdContinue);
11653
11759
  var TypeUnaryOp$$ = [TypeUnaryOp$0, TypeUnaryOp$1, TypeUnaryOp$2, TypeUnaryOp$3];
11654
11760
  function TypeUnaryOp(ctx, state) {
@@ -11658,7 +11764,7 @@ var require_parser = __commonJS({
11658
11764
  function TypeIndexedAccess(ctx, state) {
11659
11765
  return $EVENT(ctx, state, "TypeIndexedAccess", TypeIndexedAccess$0);
11660
11766
  }
11661
- var UnknownAlias$0 = $TV($EXPECT($L207, 'UnknownAlias "???"'), function($skip, $loc, $0, $1) {
11767
+ var UnknownAlias$0 = $TV($EXPECT($L208, 'UnknownAlias "???"'), function($skip, $loc, $0, $1) {
11662
11768
  return { $loc, token: "unknown" };
11663
11769
  });
11664
11770
  function UnknownAlias(ctx, state) {
@@ -11798,10 +11904,10 @@ var require_parser = __commonJS({
11798
11904
  }
11799
11905
  var TypeLiteral$0 = TypeTemplateLiteral;
11800
11906
  var TypeLiteral$1 = Literal;
11801
- var TypeLiteral$2 = $TS($S($EXPECT($L188, 'TypeLiteral "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11907
+ var TypeLiteral$2 = $TS($S($EXPECT($L189, 'TypeLiteral "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11802
11908
  return { type: "VoidType", $loc, token: $1 };
11803
11909
  });
11804
- var TypeLiteral$3 = $TV($EXPECT($L208, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
11910
+ var TypeLiteral$3 = $TV($EXPECT($L209, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
11805
11911
  return { $loc, token: "[]" };
11806
11912
  });
11807
11913
  var TypeLiteral$$ = [TypeLiteral$0, TypeLiteral$1, TypeLiteral$2, TypeLiteral$3];
@@ -11922,7 +12028,7 @@ var require_parser = __commonJS({
11922
12028
  function CivetPrologue(ctx, state) {
11923
12029
  return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
11924
12030
  }
11925
- var CivetPrologueContent$0 = $TS($S($EXPECT($L209, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R63, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12031
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R63, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
11926
12032
  var options = $3;
11927
12033
  return {
11928
12034
  type: "CivetPrologue",
@@ -13078,6 +13184,7 @@ var require_parser = __commonJS({
13078
13184
  exports.Typeof = Typeof;
13079
13185
  exports.Unless = Unless;
13080
13186
  exports.Until = Until;
13187
+ exports.Using = Using;
13081
13188
  exports.Var = Var;
13082
13189
  exports.Void = Void;
13083
13190
  exports.When = When;
@@ -13128,6 +13235,9 @@ var require_parser = __commonJS({
13128
13235
  exports.JSXChildExpression = JSXChildExpression;
13129
13236
  exports.IndentedJSXChildExpression = IndentedJSXChildExpression;
13130
13237
  exports.NestedJSXChildExpression = NestedJSXChildExpression;
13238
+ exports.UsingDeclaration = UsingDeclaration;
13239
+ exports.UsingBinding = UsingBinding;
13240
+ exports.UsingJSModeError = UsingJSModeError;
13131
13241
  exports.TypeDeclaration = TypeDeclaration;
13132
13242
  exports.TypeDeclarationRest = TypeDeclarationRest;
13133
13243
  exports.OptionalEquals = OptionalEquals;
@@ -13327,17 +13437,17 @@ function gen(node, options) {
13327
13437
  }).join("");
13328
13438
  }
13329
13439
  if (typeof node === "object") {
13330
- if (node.type === "Error") {
13331
- options.errors ?? (options.errors = []);
13332
- options.errors.push(node);
13333
- return "";
13334
- }
13335
13440
  if (options.js && node.ts) {
13336
13441
  return "";
13337
13442
  }
13338
13443
  if (!options.js && node.js) {
13339
13444
  return "";
13340
13445
  }
13446
+ if (node.type === "Error") {
13447
+ options.errors ?? (options.errors = []);
13448
+ options.errors.push(node);
13449
+ return "";
13450
+ }
13341
13451
  if (node.$loc != null) {
13342
13452
  const { token, $loc } = node;
13343
13453
  options?.updateSourceMap?.(token, $loc.pos);