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