@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.mjs CHANGED
@@ -523,23 +523,16 @@ var require_lib = __commonJS({
523
523
  }
524
524
  }
525
525
  function addPostfixStatement(statement, ws, post) {
526
- let children, expressions;
527
- const prefix = post.blockPrefix || post.condition?.expression.blockPrefix;
528
- if (prefix?.length) {
529
- const indent = prefix[0][0];
530
- expressions = [...prefix, [indent, statement]];
531
- children = [" {\n", ...expressions, "\n", indent?.slice?.(0, -2), "}"];
532
- } else {
533
- expressions = [["", statement]];
534
- children = [" { ", ...expressions, " }"];
535
- }
526
+ const expressions = [
527
+ ...post.blockPrefix || [],
528
+ ["", statement]
529
+ ];
536
530
  const block = {
537
531
  type: "BlockStatement",
538
- children,
532
+ children: [" { ", expressions, " }"],
539
533
  expressions
540
534
  };
541
- children = [...post.children];
542
- children.push(block);
535
+ const children = [...post.children, block];
543
536
  if (!isWhitespaceOrEmpty(ws))
544
537
  children.push(ws);
545
538
  post = { ...post, children, block };
@@ -2115,6 +2108,81 @@ var require_lib = __commonJS({
2115
2108
  children
2116
2109
  };
2117
2110
  }
2111
+ function processDeclarationCondition(condition) {
2112
+ if (!(condition.type === "DeclarationCondition")) {
2113
+ return;
2114
+ }
2115
+ const ref = makeRef();
2116
+ const { decl, bindings } = condition.declaration;
2117
+ const binding = bindings[0];
2118
+ const { pattern, suffix, initializer, splices, thisAssignments } = binding;
2119
+ const initCondition = {
2120
+ type: "AssignmentExpression",
2121
+ children: [ref, initializer],
2122
+ hoistDec: {
2123
+ type: "Declaration",
2124
+ children: ["let ", ref, suffix],
2125
+ names: []
2126
+ },
2127
+ blockPrefix: [
2128
+ ["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
2129
+ ...thisAssignments
2130
+ ],
2131
+ pattern,
2132
+ ref
2133
+ };
2134
+ Object.assign(condition, initCondition);
2135
+ }
2136
+ function processDeclarationConditions(node) {
2137
+ gatherRecursiveAll(node, (n) => {
2138
+ return n.type === "IfStatement" || n.type === "IterationStatement";
2139
+ }).forEach(processDeclarationConditionStatement);
2140
+ }
2141
+ function processDeclarationConditionStatement(s) {
2142
+ const { condition } = s;
2143
+ if (!condition) {
2144
+ return;
2145
+ }
2146
+ processDeclarationCondition(condition.expression);
2147
+ const { ref, pattern } = condition.expression;
2148
+ if (pattern) {
2149
+ let conditions = [];
2150
+ getPatternConditions(pattern, ref, conditions);
2151
+ conditions = conditions.filter((c) => {
2152
+ return !(c.length === 3 && c[0] === "typeof " && c[1] === ref && c[2] === " === 'object'") && !(c.length === 2 && c[0] === ref && c[1] === " != null");
2153
+ });
2154
+ if (conditions.length) {
2155
+ condition.children.unshift("(");
2156
+ conditions.forEach(function(c) {
2157
+ return condition.children.push(" && ", c);
2158
+ });
2159
+ condition.children.push(")");
2160
+ }
2161
+ }
2162
+ switch (s.type) {
2163
+ case "IfStatement": {
2164
+ const { else: e } = s;
2165
+ const block = blockWithPrefix(condition.expression.blockPrefix, s.then);
2166
+ s.then = block;
2167
+ const toAdd = [block];
2168
+ if (block.bare && e) {
2169
+ toAdd.push(";");
2170
+ }
2171
+ s.children.splice(2, 1, ...toAdd);
2172
+ updateParentPointers(block, s);
2173
+ break;
2174
+ }
2175
+ case "IterationStatement": {
2176
+ const { children, block } = s;
2177
+ const newBlock = blockWithPrefix(condition.expression.blockPrefix, block);
2178
+ s.children = children.map(function(c) {
2179
+ return c.type === "BlockStatement" ? newBlock : c;
2180
+ });
2181
+ updateParentPointers(newBlock, s);
2182
+ break;
2183
+ }
2184
+ }
2185
+ }
2118
2186
  function implicitFunctionBlock(f) {
2119
2187
  if (f.abstract || f.block || f.signature?.optional)
2120
2188
  return;
@@ -2788,6 +2856,7 @@ var require_lib = __commonJS({
2788
2856
  assert.equal(m.JSXTagStack.length, 1, "JSXTagStack");
2789
2857
  addParentPointers(root);
2790
2858
  const { expressions: statements } = root;
2859
+ processDeclarationConditions(statements);
2791
2860
  processPipelineExpressions(statements);
2792
2861
  processAssignments(statements);
2793
2862
  processPatternMatching(statements, ReservedWord);
@@ -3890,6 +3959,7 @@ var require_parser = __commonJS({
3890
3959
  Typeof,
3891
3960
  Unless,
3892
3961
  Until,
3962
+ Using,
3893
3963
  Var,
3894
3964
  Void,
3895
3965
  When,
@@ -3940,6 +4010,9 @@ var require_parser = __commonJS({
3940
4010
  JSXChildExpression,
3941
4011
  IndentedJSXChildExpression,
3942
4012
  NestedJSXChildExpression,
4013
+ UsingDeclaration,
4014
+ UsingBinding,
4015
+ UsingJSModeError,
3943
4016
  TypeDeclaration,
3944
4017
  TypeDeclarationRest,
3945
4018
  OptionalEquals,
@@ -4257,29 +4330,30 @@ var require_parser = __commonJS({
4257
4330
  var $L184 = $L("typeof");
4258
4331
  var $L185 = $L("unless");
4259
4332
  var $L186 = $L("until");
4260
- var $L187 = $L("var");
4261
- var $L188 = $L("void");
4262
- var $L189 = $L("when");
4263
- var $L190 = $L("while");
4264
- var $L191 = $L("yield");
4265
- var $L192 = $L("/>");
4266
- var $L193 = $L("</");
4267
- var $L194 = $L("<>");
4268
- var $L195 = $L("</>");
4269
- var $L196 = $L("<!--");
4270
- var $L197 = $L("-->");
4271
- var $L198 = $L("type");
4272
- var $L199 = $L("enum");
4273
- var $L200 = $L("interface");
4274
- var $L201 = $L("global");
4275
- var $L202 = $L("module");
4276
- var $L203 = $L("namespace");
4277
- var $L204 = $L("asserts");
4278
- var $L205 = $L("keyof");
4279
- var $L206 = $L("infer");
4280
- var $L207 = $L("???");
4281
- var $L208 = $L("[]");
4282
- var $L209 = $L("civet");
4333
+ var $L187 = $L("using");
4334
+ var $L188 = $L("var");
4335
+ var $L189 = $L("void");
4336
+ var $L190 = $L("when");
4337
+ var $L191 = $L("while");
4338
+ var $L192 = $L("yield");
4339
+ var $L193 = $L("/>");
4340
+ var $L194 = $L("</");
4341
+ var $L195 = $L("<>");
4342
+ var $L196 = $L("</>");
4343
+ var $L197 = $L("<!--");
4344
+ var $L198 = $L("-->");
4345
+ var $L199 = $L("type");
4346
+ var $L200 = $L("enum");
4347
+ var $L201 = $L("interface");
4348
+ var $L202 = $L("global");
4349
+ var $L203 = $L("module");
4350
+ var $L204 = $L("namespace");
4351
+ var $L205 = $L("asserts");
4352
+ var $L206 = $L("keyof");
4353
+ var $L207 = $L("infer");
4354
+ var $L208 = $L("???");
4355
+ var $L209 = $L("[]");
4356
+ var $L210 = $L("civet");
4283
4357
  var $R0 = $R(new RegExp("(as|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])", "suy"));
4284
4358
  var $R1 = $R(new RegExp("[0-9]", "suy"));
4285
4359
  var $R2 = $R(new RegExp("[)}]", "suy"));
@@ -8093,16 +8167,10 @@ var require_parser = __commonJS({
8093
8167
  var clause = $1;
8094
8168
  var block = $2;
8095
8169
  var e = $3;
8096
- const children = [...clause.children];
8097
- block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
8098
- children.push(block);
8099
- if (block.bare && e)
8100
- children.push(";");
8101
- if (e)
8102
- children.push(e);
8103
8170
  return {
8104
- ...clause,
8105
- children,
8171
+ type: "IfStatement",
8172
+ children: [...clause.children, block, e],
8173
+ condition: clause.condition,
8106
8174
  then: block,
8107
8175
  else: e
8108
8176
  };
@@ -8325,7 +8393,6 @@ var require_parser = __commonJS({
8325
8393
  var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
8326
8394
  var clause = $1;
8327
8395
  var block = $2;
8328
- block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
8329
8396
  return {
8330
8397
  ...clause,
8331
8398
  children: [...clause.children, block],
@@ -8944,27 +9011,13 @@ var require_parser = __commonJS({
8944
9011
  return $EVENT_C(ctx, state, "Condition", Condition$$);
8945
9012
  }
8946
9013
  var DeclarationCondition$0 = $TS($S(ForbidIndentedApplication, $E(LexicalDeclaration), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
8947
- var dec = $2;
8948
- if (!dec)
9014
+ var declaration = $2;
9015
+ if (!declaration)
8949
9016
  return $skip;
8950
- const ref = makeRef();
8951
- const { decl, bindings } = dec;
8952
- const binding = bindings[0];
8953
- const { pattern, suffix, initializer, splices, thisAssignments } = binding;
8954
- const initCondition = {
8955
- type: "AssignmentExpression",
8956
- children: [ref, initializer],
8957
- hoistDec: {
8958
- type: "Declaration",
8959
- children: ["let ", ref, suffix],
8960
- names: []
8961
- },
8962
- blockPrefix: [
8963
- ["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
8964
- ...thisAssignments
8965
- ]
9017
+ return {
9018
+ type: "DeclarationCondition",
9019
+ declaration
8966
9020
  };
8967
- return initCondition;
8968
9021
  });
8969
9022
  function DeclarationCondition(ctx, state) {
8970
9023
  return $EVENT(ctx, state, "DeclarationCondition", DeclarationCondition$0);
@@ -9490,7 +9543,8 @@ var require_parser = __commonJS({
9490
9543
  var Declaration$3 = TypeDeclaration;
9491
9544
  var Declaration$4 = EnumDeclaration;
9492
9545
  var Declaration$5 = OperatorDeclaration;
9493
- var Declaration$$ = [Declaration$0, Declaration$1, Declaration$2, Declaration$3, Declaration$4, Declaration$5];
9546
+ var Declaration$6 = UsingDeclaration;
9547
+ var Declaration$$ = [Declaration$0, Declaration$1, Declaration$2, Declaration$3, Declaration$4, Declaration$5, Declaration$6];
9494
9548
  function Declaration(ctx, state) {
9495
9549
  return $EVENT_C(ctx, state, "Declaration", Declaration$$);
9496
9550
  }
@@ -10563,31 +10617,37 @@ var require_parser = __commonJS({
10563
10617
  function Until(ctx, state) {
10564
10618
  return $EVENT(ctx, state, "Until", Until$0);
10565
10619
  }
10566
- var Var$0 = $TS($S($EXPECT($L187, 'Var "var"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10620
+ var Using$0 = $TS($S($EXPECT($L187, 'Using "using"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10621
+ return { $loc, token: $1 };
10622
+ });
10623
+ function Using(ctx, state) {
10624
+ return $EVENT(ctx, state, "Using", Using$0);
10625
+ }
10626
+ var Var$0 = $TS($S($EXPECT($L188, 'Var "var"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10567
10627
  return { $loc, token: $1 };
10568
10628
  });
10569
10629
  function Var(ctx, state) {
10570
10630
  return $EVENT(ctx, state, "Var", Var$0);
10571
10631
  }
10572
- var Void$0 = $TS($S($EXPECT($L188, 'Void "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10632
+ var Void$0 = $TS($S($EXPECT($L189, 'Void "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10573
10633
  return { $loc, token: $1 };
10574
10634
  });
10575
10635
  function Void(ctx, state) {
10576
10636
  return $EVENT(ctx, state, "Void", Void$0);
10577
10637
  }
10578
- var When$0 = $TS($S($EXPECT($L189, 'When "when"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10638
+ var When$0 = $TS($S($EXPECT($L190, 'When "when"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10579
10639
  return { $loc, token: "case" };
10580
10640
  });
10581
10641
  function When(ctx, state) {
10582
10642
  return $EVENT(ctx, state, "When", When$0);
10583
10643
  }
10584
- var While$0 = $TS($S($EXPECT($L190, 'While "while"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10644
+ var While$0 = $TS($S($EXPECT($L191, 'While "while"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10585
10645
  return { $loc, token: $1 };
10586
10646
  });
10587
10647
  function While(ctx, state) {
10588
10648
  return $EVENT(ctx, state, "While", While$0);
10589
10649
  }
10590
- var Yield$0 = $TS($S($EXPECT($L191, 'Yield "yield"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10650
+ var Yield$0 = $TS($S($EXPECT($L192, 'Yield "yield"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
10591
10651
  return { $loc, token: $1, type: "Yield" };
10592
10652
  });
10593
10653
  function Yield(ctx, state) {
@@ -10660,7 +10720,7 @@ var require_parser = __commonJS({
10660
10720
  function JSXElement(ctx, state) {
10661
10721
  return $EVENT_C(ctx, state, "JSXElement", JSXElement$$);
10662
10722
  }
10663
- 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) {
10723
+ 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) {
10664
10724
  return { type: "JSXElement", children: $0, tag: $2 };
10665
10725
  });
10666
10726
  function JSXSelfClosingElement(ctx, state) {
@@ -10694,7 +10754,7 @@ var require_parser = __commonJS({
10694
10754
  function JSXOptionalClosingElement(ctx, state) {
10695
10755
  return $EVENT_C(ctx, state, "JSXOptionalClosingElement", JSXOptionalClosingElement$$);
10696
10756
  }
10697
- var JSXClosingElement$0 = $S($EXPECT($L193, 'JSXClosingElement "</"'), $E(Whitespace), JSXElementName, $E(Whitespace), $EXPECT($L33, 'JSXClosingElement ">"'));
10757
+ var JSXClosingElement$0 = $S($EXPECT($L194, 'JSXClosingElement "</"'), $E(Whitespace), JSXElementName, $E(Whitespace), $EXPECT($L33, 'JSXClosingElement ">"'));
10698
10758
  function JSXClosingElement(ctx, state) {
10699
10759
  return $EVENT(ctx, state, "JSXClosingElement", JSXClosingElement$0);
10700
10760
  }
@@ -10715,7 +10775,7 @@ var require_parser = __commonJS({
10715
10775
  ];
10716
10776
  return { type: "JSXFragment", children: parts, jsxChildren: children.jsxChildren };
10717
10777
  });
10718
- var JSXFragment$1 = $TS($S(CoffeeJSXEnabled, $EXPECT($L194, 'JSXFragment "<>"'), $E(JSXChildren), $E(Whitespace), JSXClosingFragment), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
10778
+ var JSXFragment$1 = $TS($S(CoffeeJSXEnabled, $EXPECT($L195, 'JSXFragment "<>"'), $E(JSXChildren), $E(Whitespace), JSXClosingFragment), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
10719
10779
  var children = $3;
10720
10780
  $0 = $0.slice(1);
10721
10781
  return {
@@ -10728,7 +10788,7 @@ var require_parser = __commonJS({
10728
10788
  function JSXFragment(ctx, state) {
10729
10789
  return $EVENT_C(ctx, state, "JSXFragment", JSXFragment$$);
10730
10790
  }
10731
- var PushJSXOpeningFragment$0 = $TV($EXPECT($L194, 'PushJSXOpeningFragment "<>"'), function($skip, $loc, $0, $1) {
10791
+ var PushJSXOpeningFragment$0 = $TV($EXPECT($L195, 'PushJSXOpeningFragment "<>"'), function($skip, $loc, $0, $1) {
10732
10792
  module.JSXTagStack.push("");
10733
10793
  return $1;
10734
10794
  });
@@ -10745,7 +10805,7 @@ var require_parser = __commonJS({
10745
10805
  function JSXOptionalClosingFragment(ctx, state) {
10746
10806
  return $EVENT_C(ctx, state, "JSXOptionalClosingFragment", JSXOptionalClosingFragment$$);
10747
10807
  }
10748
- var JSXClosingFragment$0 = $EXPECT($L195, 'JSXClosingFragment "</>"');
10808
+ var JSXClosingFragment$0 = $EXPECT($L196, 'JSXClosingFragment "</>"');
10749
10809
  function JSXClosingFragment(ctx, state) {
10750
10810
  return $EVENT(ctx, state, "JSXClosingFragment", JSXClosingFragment$0);
10751
10811
  }
@@ -11214,7 +11274,7 @@ var require_parser = __commonJS({
11214
11274
  function JSXChild(ctx, state) {
11215
11275
  return $EVENT_C(ctx, state, "JSXChild", JSXChild$$);
11216
11276
  }
11217
- var JSXComment$0 = $TS($S($EXPECT($L196, 'JSXComment "<!--"'), JSXCommentContent, $EXPECT($L197, 'JSXComment "-->"')), function($skip, $loc, $0, $1, $2, $3) {
11277
+ var JSXComment$0 = $TS($S($EXPECT($L197, 'JSXComment "<!--"'), JSXCommentContent, $EXPECT($L198, 'JSXComment "-->"')), function($skip, $loc, $0, $1, $2, $3) {
11218
11278
  return ["{/*", $2, "*/}"];
11219
11279
  });
11220
11280
  function JSXComment(ctx, state) {
@@ -11252,6 +11312,52 @@ var require_parser = __commonJS({
11252
11312
  function NestedJSXChildExpression(ctx, state) {
11253
11313
  return $EVENT(ctx, state, "NestedJSXChildExpression", NestedJSXChildExpression$0);
11254
11314
  }
11315
+ var UsingDeclaration$0 = $TS($S(Using, $E(_), UsingBinding, $Q($S(__, Comma, __, UsingBinding)), UsingJSModeError), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
11316
+ var decl = $1;
11317
+ var binding = $3;
11318
+ var tail = $4;
11319
+ const bindings = [binding].concat(tail.map(([, , , b]) => b));
11320
+ return {
11321
+ type: "Declaration",
11322
+ children: $0,
11323
+ names: bindings.flatMap((b) => b.names),
11324
+ bindings,
11325
+ decl,
11326
+ splices: bindings.flatMap((b) => b.splices),
11327
+ thisAssignments: bindings.flatMap((b) => b.thisAssignments)
11328
+ };
11329
+ });
11330
+ function UsingDeclaration(ctx, state) {
11331
+ return $EVENT(ctx, state, "UsingDeclaration", UsingDeclaration$0);
11332
+ }
11333
+ var UsingBinding$0 = $TS($S(BindingIdentifier, $E(TypeSuffix), Initializer), function($skip, $loc, $0, $1, $2, $3) {
11334
+ var pattern = $1;
11335
+ var suffix = $2;
11336
+ var initializer = $3;
11337
+ return {
11338
+ type: "Binding",
11339
+ children: $0,
11340
+ names: pattern.names,
11341
+ pattern,
11342
+ suffix,
11343
+ initializer,
11344
+ splices: [],
11345
+ thisAssignments: []
11346
+ };
11347
+ });
11348
+ function UsingBinding(ctx, state) {
11349
+ return $EVENT(ctx, state, "UsingBinding", UsingBinding$0);
11350
+ }
11351
+ var UsingJSModeError$0 = $TV($EXPECT($L0, 'UsingJSModeError ""'), function($skip, $loc, $0, $1) {
11352
+ return {
11353
+ type: "Error",
11354
+ js: true,
11355
+ message: "`using` is not currently transpiled in JS mode."
11356
+ };
11357
+ });
11358
+ function UsingJSModeError(ctx, state) {
11359
+ return $EVENT(ctx, state, "UsingJSModeError", UsingJSModeError$0);
11360
+ }
11255
11361
  var TypeDeclaration$0 = $T($S($E($S(Export, $E(_))), $S(Declare, $E(_)), TypeLexicalDeclaration), function(value) {
11256
11362
  return { "ts": true, "children": value };
11257
11363
  });
@@ -11300,37 +11406,37 @@ var require_parser = __commonJS({
11300
11406
  function InterfaceExtendsTarget(ctx, state) {
11301
11407
  return $EVENT(ctx, state, "InterfaceExtendsTarget", InterfaceExtendsTarget$0);
11302
11408
  }
11303
- var TypeKeyword$0 = $TS($S($EXPECT($L198, 'TypeKeyword "type"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11409
+ var TypeKeyword$0 = $TS($S($EXPECT($L199, 'TypeKeyword "type"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11304
11410
  return { $loc, token: $1 };
11305
11411
  });
11306
11412
  function TypeKeyword(ctx, state) {
11307
11413
  return $EVENT(ctx, state, "TypeKeyword", TypeKeyword$0);
11308
11414
  }
11309
- var Enum$0 = $TS($S($EXPECT($L199, 'Enum "enum"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11415
+ var Enum$0 = $TS($S($EXPECT($L200, 'Enum "enum"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11310
11416
  return { $loc, token: $1 };
11311
11417
  });
11312
11418
  function Enum(ctx, state) {
11313
11419
  return $EVENT(ctx, state, "Enum", Enum$0);
11314
11420
  }
11315
- var Interface$0 = $TS($S($EXPECT($L200, 'Interface "interface"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11421
+ var Interface$0 = $TS($S($EXPECT($L201, 'Interface "interface"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11316
11422
  return { $loc, token: $1 };
11317
11423
  });
11318
11424
  function Interface(ctx, state) {
11319
11425
  return $EVENT(ctx, state, "Interface", Interface$0);
11320
11426
  }
11321
- var Global$0 = $TS($S($EXPECT($L201, 'Global "global"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11427
+ var Global$0 = $TS($S($EXPECT($L202, 'Global "global"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11322
11428
  return { $loc, token: $1 };
11323
11429
  });
11324
11430
  function Global(ctx, state) {
11325
11431
  return $EVENT(ctx, state, "Global", Global$0);
11326
11432
  }
11327
- var Module$0 = $TS($S($EXPECT($L202, 'Module "module"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11433
+ var Module$0 = $TS($S($EXPECT($L203, 'Module "module"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11328
11434
  return { $loc, token: $1 };
11329
11435
  });
11330
11436
  function Module(ctx, state) {
11331
11437
  return $EVENT(ctx, state, "Module", Module$0);
11332
11438
  }
11333
- var Namespace$0 = $TS($S($EXPECT($L203, 'Namespace "namespace"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11439
+ var Namespace$0 = $TS($S($EXPECT($L204, 'Namespace "namespace"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11334
11440
  return { $loc, token: $1 };
11335
11441
  });
11336
11442
  function Namespace(ctx, state) {
@@ -11575,7 +11681,7 @@ var require_parser = __commonJS({
11575
11681
  function ReturnTypeSuffix(ctx, state) {
11576
11682
  return $EVENT(ctx, state, "ReturnTypeSuffix", ReturnTypeSuffix$0);
11577
11683
  }
11578
- var ReturnType$0 = $TS($S($E($S(__, $EXPECT($L204, 'ReturnType "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2) {
11684
+ var ReturnType$0 = $TS($S($E($S(__, $EXPECT($L205, 'ReturnType "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2) {
11579
11685
  var asserts = $1;
11580
11686
  var t = $2;
11581
11687
  if (asserts) {
@@ -11644,9 +11750,9 @@ var require_parser = __commonJS({
11644
11750
  function TypeUnarySuffix(ctx, state) {
11645
11751
  return $EVENT_C(ctx, state, "TypeUnarySuffix", TypeUnarySuffix$$);
11646
11752
  }
11647
- var TypeUnaryOp$0 = $S($EXPECT($L205, 'TypeUnaryOp "keyof"'), NonIdContinue);
11753
+ var TypeUnaryOp$0 = $S($EXPECT($L206, 'TypeUnaryOp "keyof"'), NonIdContinue);
11648
11754
  var TypeUnaryOp$1 = $S($EXPECT($L184, 'TypeUnaryOp "typeof"'), NonIdContinue);
11649
- var TypeUnaryOp$2 = $S($EXPECT($L206, 'TypeUnaryOp "infer"'), NonIdContinue);
11755
+ var TypeUnaryOp$2 = $S($EXPECT($L207, 'TypeUnaryOp "infer"'), NonIdContinue);
11650
11756
  var TypeUnaryOp$3 = $S($EXPECT($L167, 'TypeUnaryOp "readonly"'), NonIdContinue);
11651
11757
  var TypeUnaryOp$$ = [TypeUnaryOp$0, TypeUnaryOp$1, TypeUnaryOp$2, TypeUnaryOp$3];
11652
11758
  function TypeUnaryOp(ctx, state) {
@@ -11656,7 +11762,7 @@ var require_parser = __commonJS({
11656
11762
  function TypeIndexedAccess(ctx, state) {
11657
11763
  return $EVENT(ctx, state, "TypeIndexedAccess", TypeIndexedAccess$0);
11658
11764
  }
11659
- var UnknownAlias$0 = $TV($EXPECT($L207, 'UnknownAlias "???"'), function($skip, $loc, $0, $1) {
11765
+ var UnknownAlias$0 = $TV($EXPECT($L208, 'UnknownAlias "???"'), function($skip, $loc, $0, $1) {
11660
11766
  return { $loc, token: "unknown" };
11661
11767
  });
11662
11768
  function UnknownAlias(ctx, state) {
@@ -11796,10 +11902,10 @@ var require_parser = __commonJS({
11796
11902
  }
11797
11903
  var TypeLiteral$0 = TypeTemplateLiteral;
11798
11904
  var TypeLiteral$1 = Literal;
11799
- var TypeLiteral$2 = $TS($S($EXPECT($L188, 'TypeLiteral "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11905
+ var TypeLiteral$2 = $TS($S($EXPECT($L189, 'TypeLiteral "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
11800
11906
  return { type: "VoidType", $loc, token: $1 };
11801
11907
  });
11802
- var TypeLiteral$3 = $TV($EXPECT($L208, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
11908
+ var TypeLiteral$3 = $TV($EXPECT($L209, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
11803
11909
  return { $loc, token: "[]" };
11804
11910
  });
11805
11911
  var TypeLiteral$$ = [TypeLiteral$0, TypeLiteral$1, TypeLiteral$2, TypeLiteral$3];
@@ -11920,7 +12026,7 @@ var require_parser = __commonJS({
11920
12026
  function CivetPrologue(ctx, state) {
11921
12027
  return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
11922
12028
  }
11923
- var CivetPrologueContent$0 = $TS($S($EXPECT($L209, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R63, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12029
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R63, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
11924
12030
  var options = $3;
11925
12031
  return {
11926
12032
  type: "CivetPrologue",
@@ -13076,6 +13182,7 @@ var require_parser = __commonJS({
13076
13182
  exports.Typeof = Typeof;
13077
13183
  exports.Unless = Unless;
13078
13184
  exports.Until = Until;
13185
+ exports.Using = Using;
13079
13186
  exports.Var = Var;
13080
13187
  exports.Void = Void;
13081
13188
  exports.When = When;
@@ -13126,6 +13233,9 @@ var require_parser = __commonJS({
13126
13233
  exports.JSXChildExpression = JSXChildExpression;
13127
13234
  exports.IndentedJSXChildExpression = IndentedJSXChildExpression;
13128
13235
  exports.NestedJSXChildExpression = NestedJSXChildExpression;
13236
+ exports.UsingDeclaration = UsingDeclaration;
13237
+ exports.UsingBinding = UsingBinding;
13238
+ exports.UsingJSModeError = UsingJSModeError;
13129
13239
  exports.TypeDeclaration = TypeDeclaration;
13130
13240
  exports.TypeDeclarationRest = TypeDeclarationRest;
13131
13241
  exports.OptionalEquals = OptionalEquals;
@@ -13315,17 +13425,17 @@ function gen(node, options) {
13315
13425
  }).join("");
13316
13426
  }
13317
13427
  if (typeof node === "object") {
13318
- if (node.type === "Error") {
13319
- options.errors ?? (options.errors = []);
13320
- options.errors.push(node);
13321
- return "";
13322
- }
13323
13428
  if (options.js && node.ts) {
13324
13429
  return "";
13325
13430
  }
13326
13431
  if (!options.js && node.js) {
13327
13432
  return "";
13328
13433
  }
13434
+ if (node.type === "Error") {
13435
+ options.errors ?? (options.errors = []);
13436
+ options.errors.push(node);
13437
+ return "";
13438
+ }
13329
13439
  if (node.$loc != null) {
13330
13440
  const { token, $loc } = node;
13331
13441
  options?.updateSourceMap?.(token, $loc.pos);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.6.35",
4
+ "version": "0.6.37",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",