@danielx/civet 0.5.74 → 0.5.76

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/README.md CHANGED
@@ -10,6 +10,7 @@ Civet
10
10
  The modern way to write TypeScript.
11
11
 
12
12
  - [Documentation](https://civet.dev/)
13
+ - [Design Philosophy](https://civet.dev/philosophy)
13
14
  - [Civet Playground](https://civet.dev/playground)
14
15
  - [Civet VSCode Extension](https://marketplace.visualstudio.com/items?itemName=DanielX.civet)
15
16
  - [Discord Server](https://discord.gg/xkrW9GebBc)
@@ -371,42 +372,6 @@ esbuild.build({
371
372
 
372
373
  It's super fast and works great!
373
374
 
374
- Philosophy
375
- ---
376
-
377
- Civet is a **large language that feels small**. Civet is large because it is mostly a **superset of TypeScript**,
378
- an already large language. Civet feels small because of the coherent design aesthetic: related
379
- features look and behave similarly, so when seeing a new feature you can have a good idea what it does,
380
- and your existing knowledge of JavaScript and other languages leads you in the right direction.
381
-
382
- Civet works with **existing tools**. We're not trying to replace the TypeScript type checker; we want to
383
- amplify its power. We're not trying to change ES semantics; we want to present them in a coherent and expressive
384
- way.
385
-
386
- **Less syntax** is preferred.
387
-
388
- **Context matters**. The same tokens can mean different things in different contexts. This shouldn't be arbitrary
389
- but based on pragmatic concerns. Things should be consistent where possible, especially conceptually.
390
-
391
- Civet builds on top of **history**. We've taken inspiration from languages like CoffeeScript, Elm, LiveScript, Flow,
392
- Haskell, Perl, Python, Ruby, Crystal, Bash, and others.
393
-
394
- Civet is **pragmatic**. Civet design is informed by 25+ years of JavaScript development. Frontend frameworks
395
- have come and gone but they all addressed issues that were important for their time. We focus heavily on
396
- addressing concerns that real developers feel every day. A key criteria for evaluating features is "how does it
397
- work in practice?".
398
-
399
- Civet **evolves**. As the official JS and TS specifications evolve into the future, Civet also evolves favoring **compatibility**.
400
- This may lead us to difficult choices where the future spec has evolved differently than we anticipated (pipe operators,
401
- do expressions, pattern matching). In those cases, Civet will adapt to match the latest spec while providing configuration
402
- options to allow migration bit by bit while keeping existing code working.
403
-
404
- Civet is **configurable**. There is no single "right way" for everyone at all times. Some of us have older CoffeeScript
405
- codebases that would benefit from added types. Others have massive TypeScript applications that could benefit from
406
- new language features and shorthand syntax. Civet provides a way to get the benefits bit by bit without a complete
407
- rewrite. This same configurability lets us experiment with language features to gain experience and improve them before
408
- locking them in. It also allows us to adapt to a changing future.
409
-
410
375
  Sponsorship
411
376
  ---
412
377
  If you are so inclined, you can sponsor Civet on [Open Collective](https://opencollective.com/civet).
package/dist/browser.js CHANGED
@@ -600,6 +600,7 @@ ${input.slice(result.pos)}
600
600
  NestedElementList,
601
601
  NestedElement,
602
602
  ArrayElementDelimiter,
603
+ ElementListWithIndentedApplicationForbidden,
603
604
  ElementList,
604
605
  ElementListRest,
605
606
  ArrayElementExpression,
@@ -5471,22 +5472,27 @@ ${input.slice(result.pos)}
5471
5472
  var rhs = $3;
5472
5473
  if (!prefix && !rhs)
5473
5474
  return $skip;
5475
+ let body, ref;
5474
5476
  if (!rhs) {
5475
- const ref2 = {
5477
+ ref = {
5476
5478
  type: "Ref",
5477
5479
  base: "$",
5478
5480
  id: "$"
5479
5481
  };
5480
- return {
5481
- type: "ArrowFunction",
5482
- children: [ref2, " => ", prefix, ref2],
5483
- ampersandBlock: true
5484
- };
5482
+ body = [prefix, ref];
5483
+ } else {
5484
+ ({ ref } = rhs);
5485
+ body = [prefix, rhs];
5486
+ }
5487
+ const children = [ref, " => ", ...body];
5488
+ if (module.hasAwait(body)) {
5489
+ children.unshift("async ");
5485
5490
  }
5486
- const { ref } = rhs;
5487
5491
  return {
5488
5492
  type: "ArrowFunction",
5489
- children: [ref, " => ", prefix, rhs],
5493
+ children,
5494
+ ref,
5495
+ body,
5490
5496
  ampersandBlock: true
5491
5497
  };
5492
5498
  });
@@ -6519,7 +6525,7 @@ ${input.slice(result.pos)}
6519
6525
  var ArrayLiteral$0 = $T($S(ArrayBindingPattern, UpcomingAssignment), function(value) {
6520
6526
  return value[0];
6521
6527
  });
6522
- var ArrayLiteral$1 = $TS($S(OpenBracket, AllowAll, $E($S(ArrayLiteralContent, __, CloseBracket)), RestoreIndentedApplication, RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
6528
+ var ArrayLiteral$1 = $TS($S(OpenBracket, AllowAll, $E($S(ArrayLiteralContent, __, CloseBracket)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
6523
6529
  var open = $1;
6524
6530
  if (!$3)
6525
6531
  return $skip;
@@ -6656,7 +6662,7 @@ ${input.slice(result.pos)}
6656
6662
  var ArrayLiteralContent$0 = RangeExpression;
6657
6663
  var ArrayLiteralContent$1 = $S(NestedImplicitObjectLiteral, $Q($S(__, Comma, NestedImplicitObjectLiteral)));
6658
6664
  var ArrayLiteralContent$2 = NestedElementList;
6659
- var ArrayLiteralContent$3 = $TS($S(ElementList, InsertComma, $E(NestedElementList)), function($skip, $loc, $0, $1, $2, $3) {
6665
+ var ArrayLiteralContent$3 = $TS($S(ElementListWithIndentedApplicationForbidden, InsertComma, $E(NestedElementList)), function($skip, $loc, $0, $1, $2, $3) {
6660
6666
  var list = $1;
6661
6667
  var comma = $2;
6662
6668
  var nested = $3;
@@ -6785,6 +6791,33 @@ ${input.slice(result.pos)}
6785
6791
  return result;
6786
6792
  }
6787
6793
  }
6794
+ var ElementListWithIndentedApplicationForbidden$0 = $TS($S(ForbidIndentedApplication, $E(ElementList), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
6795
+ if ($2)
6796
+ return $2;
6797
+ return $skip;
6798
+ });
6799
+ function ElementListWithIndentedApplicationForbidden(state) {
6800
+ let eventData;
6801
+ if (state.events) {
6802
+ const result = state.events.enter?.("ElementListWithIndentedApplicationForbidden", state);
6803
+ if (result) {
6804
+ if (result.cache)
6805
+ return result.cache;
6806
+ eventData = result.data;
6807
+ }
6808
+ }
6809
+ if (state.tokenize) {
6810
+ const result = $TOKEN("ElementListWithIndentedApplicationForbidden", state, ElementListWithIndentedApplicationForbidden$0(state));
6811
+ if (state.events)
6812
+ state.events.exit?.("ElementListWithIndentedApplicationForbidden", state, result, eventData);
6813
+ return result;
6814
+ } else {
6815
+ const result = ElementListWithIndentedApplicationForbidden$0(state);
6816
+ if (state.events)
6817
+ state.events.exit?.("ElementListWithIndentedApplicationForbidden", state, result, eventData);
6818
+ return result;
6819
+ }
6820
+ }
6788
6821
  var ElementList$0 = $TS($S(ArrayElementExpression, $Q(ElementListRest)), function($skip, $loc, $0, $1, $2) {
6789
6822
  var first = $1;
6790
6823
  var rest = $2;
@@ -9277,7 +9310,7 @@ ${input.slice(result.pos)}
9277
9310
  return result;
9278
9311
  }
9279
9312
  }
9280
- var WhenCondition$0 = $T($S(__, When, ExtendedExpression), function(value) {
9313
+ var WhenCondition$0 = $T($S(__, When, ExpressionWithIndentedApplicationForbidden), function(value) {
9281
9314
  var exp = value[2];
9282
9315
  return exp;
9283
9316
  });
@@ -9303,7 +9336,7 @@ ${input.slice(result.pos)}
9303
9336
  return result;
9304
9337
  }
9305
9338
  }
9306
- var CoffeeForStatementParameters$0 = $TS($S($E($S(Await, __)), InsertOpenParen, CoffeeForDeclaration, $E(CoffeeForIndex), __, $C(In, Of, From), ExtendedExpression, $E($S(__, By, ExtendedExpression)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
9339
+ var CoffeeForStatementParameters$0 = $TS($S($E($S(Await, __)), InsertOpenParen, CoffeeForDeclaration, $E(CoffeeForIndex), __, $C(In, Of, From), ExpressionWithIndentedApplicationForbidden, $E($S(__, By, ExpressionWithIndentedApplicationForbidden)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
9307
9340
  var open = $2;
9308
9341
  var declaration = $3;
9309
9342
  var index = $4;
@@ -9790,7 +9823,7 @@ ${input.slice(result.pos)}
9790
9823
  var e = $0;
9791
9824
  return {
9792
9825
  type: "SwitchExpression",
9793
- children: ["(()=>{", e.children, "})()"],
9826
+ children: module.wrapIIFE(e.children),
9794
9827
  expression: e.expression,
9795
9828
  caseBlock: e.caseBlock
9796
9829
  };
@@ -10100,7 +10133,7 @@ ${input.slice(result.pos)}
10100
10133
  return {
10101
10134
  type: "TryExpression",
10102
10135
  blocks: t.blocks,
10103
- children: ["(()=>{", t, "})()"]
10136
+ children: module.wrapIIFE(t)
10104
10137
  };
10105
10138
  });
10106
10139
  function TryExpression(state) {
@@ -10796,7 +10829,7 @@ ${input.slice(result.pos)}
10796
10829
  var DebuggerExpression$0 = $TS($S(Debugger), function($skip, $loc, $0, $1) {
10797
10830
  return {
10798
10831
  type: "DebuggerExpression",
10799
- children: ["(()=>{", $1, "})()"]
10832
+ children: module.wrapIIFE($1)
10800
10833
  };
10801
10834
  });
10802
10835
  function DebuggerExpression(state) {
@@ -10824,7 +10857,7 @@ ${input.slice(result.pos)}
10824
10857
  var ThrowExpression$0 = $TS($S(Throw, ExtendedExpression), function($skip, $loc, $0, $1, $2) {
10825
10858
  return {
10826
10859
  type: "ThrowExpression",
10827
- children: ["(()=>{", $0, "})()"]
10860
+ children: module.wrapIIFE($0)
10828
10861
  };
10829
10862
  });
10830
10863
  function ThrowExpression(state) {
@@ -13565,7 +13598,7 @@ ${input.slice(result.pos)}
13565
13598
  }
13566
13599
  }
13567
13600
  var Await$0 = $TS($S($EXPECT($L104, fail, 'Await "await"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
13568
- return { $loc, token: $1 };
13601
+ return { $loc, token: $1, type: "Await" };
13569
13602
  });
13570
13603
  function Await(state) {
13571
13604
  let eventData;
@@ -19974,7 +20007,7 @@ ${input.slice(result.pos)}
19974
20007
  const i = exp.children.indexOf(exp.block);
19975
20008
  if (exp.subtype === "DoStatement") {
19976
20009
  insertReturn(exp.block);
19977
- exp.children.splice(i, 1, "(()=>", ...exp.children, ")()");
20010
+ exp.children.splice(i, 1, ...module.wrapIIFE(exp.children));
19978
20011
  return;
19979
20012
  }
19980
20013
  const resultsRef = {
@@ -19983,8 +20016,28 @@ ${input.slice(result.pos)}
19983
20016
  id: "results"
19984
20017
  };
19985
20018
  insertPush(exp.block, resultsRef);
19986
- exp.children.splice(i, 1, "(()=>{const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef, "})()");
20019
+ exp.children.splice(i, 1, module.wrapIIFE(
20020
+ ["const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef]
20021
+ ));
19987
20022
  }
20023
+ module.hasAwait = (exp) => {
20024
+ return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
20025
+ };
20026
+ module.wrapIIFE = (exp) => {
20027
+ let prefix, suffix;
20028
+ if (module.hasAwait(exp)) {
20029
+ prefix = "(await (async ()=>{";
20030
+ suffix = "})())";
20031
+ } else {
20032
+ prefix = "(()=>{";
20033
+ suffix = "})()";
20034
+ }
20035
+ if (Array.isArray(exp)) {
20036
+ return [prefix, ...exp, suffix];
20037
+ } else {
20038
+ return [prefix, exp, suffix];
20039
+ }
20040
+ };
19988
20041
  function wrapIterationReturningResults(statement, outerRef) {
19989
20042
  if (statement.type === "DoStatement") {
19990
20043
  if (outerRef) {
@@ -20596,12 +20649,14 @@ ${input.slice(result.pos)}
20596
20649
  return;
20597
20650
  if (typeof node !== "object")
20598
20651
  return;
20599
- node.parent = parent;
20600
20652
  if (Array.isArray(node)) {
20601
20653
  for (const child of node) {
20602
- addParentPointers(child, node);
20654
+ addParentPointers(child, parent);
20603
20655
  }
20604
- } else if (node.children) {
20656
+ return;
20657
+ }
20658
+ node.parent = parent;
20659
+ if (node.children) {
20605
20660
  for (const child of node.children) {
20606
20661
  addParentPointers(child, node);
20607
20662
  }
@@ -21219,11 +21274,11 @@ ${input.slice(result.pos)}
21219
21274
  });
21220
21275
  if (module.config.implicitReturns && s.type === "SwitchExpression") {
21221
21276
  insertReturn(root[0]);
21222
- root.unshift("(()=>{");
21223
- root.push("})()");
21277
+ root.splice(0, 1, module.wrapIIFE(root[0]));
21224
21278
  }
21225
21279
  s.type = "PatternMatchingStatement";
21226
21280
  s.children = [root];
21281
+ addParentPointers(s, s.parent);
21227
21282
  });
21228
21283
  }
21229
21284
  function processPipelineExpressions(statements) {
@@ -21278,6 +21333,7 @@ ${input.slice(result.pos)}
21278
21333
  }
21279
21334
  children.push(arg);
21280
21335
  s.children = children;
21336
+ addParentPointers(s, s.parent);
21281
21337
  });
21282
21338
  }
21283
21339
  module.processProgram = function(statements) {
@@ -21487,12 +21543,12 @@ ${input.slice(result.pos)}
21487
21543
  module.constructInvocation = function(fn, arg) {
21488
21544
  const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
21489
21545
  if (fn.expr.ampersandBlock) {
21490
- const [ref, , prefix, rhs] = fn.expr.children;
21546
+ const { ref, body } = fn.expr;
21491
21547
  ref.type = "PipedExpression";
21492
21548
  ref.children = [module.makeLeftHandSideExpression(arg)];
21493
21549
  return {
21494
21550
  type: "UnwrappedExpression",
21495
- children: [module.skipIfOnlyWS(fn.leadingComment), prefix, rhs, module.skipIfOnlyWS(fn.trailingComment)]
21551
+ children: [module.skipIfOnlyWS(fn.leadingComment), ...body, module.skipIfOnlyWS(fn.trailingComment)]
21496
21552
  };
21497
21553
  }
21498
21554
  const lhs = module.makeLeftHandSideExpression(fn.expr);
@@ -22254,7 +22310,7 @@ ${input.slice(result.pos)}
22254
22310
  var uncacheable;
22255
22311
  ({ parse } = import_parser.default);
22256
22312
  ({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
22257
- uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowIndentedApplication", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidIndentedApplication", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
22313
+ uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowIndentedApplication", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidIndentedApplication", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
22258
22314
  var compile = function(src, options) {
22259
22315
  var ast, code, events, filename, ref, result, sm, srcMapJSON;
22260
22316
  if (!options) {
package/dist/main.js CHANGED
@@ -599,6 +599,7 @@ ${input.slice(result.pos)}
599
599
  NestedElementList,
600
600
  NestedElement,
601
601
  ArrayElementDelimiter,
602
+ ElementListWithIndentedApplicationForbidden,
602
603
  ElementList,
603
604
  ElementListRest,
604
605
  ArrayElementExpression,
@@ -5470,22 +5471,27 @@ ${input.slice(result.pos)}
5470
5471
  var rhs = $3;
5471
5472
  if (!prefix && !rhs)
5472
5473
  return $skip;
5474
+ let body, ref;
5473
5475
  if (!rhs) {
5474
- const ref2 = {
5476
+ ref = {
5475
5477
  type: "Ref",
5476
5478
  base: "$",
5477
5479
  id: "$"
5478
5480
  };
5479
- return {
5480
- type: "ArrowFunction",
5481
- children: [ref2, " => ", prefix, ref2],
5482
- ampersandBlock: true
5483
- };
5481
+ body = [prefix, ref];
5482
+ } else {
5483
+ ({ ref } = rhs);
5484
+ body = [prefix, rhs];
5485
+ }
5486
+ const children = [ref, " => ", ...body];
5487
+ if (module2.hasAwait(body)) {
5488
+ children.unshift("async ");
5484
5489
  }
5485
- const { ref } = rhs;
5486
5490
  return {
5487
5491
  type: "ArrowFunction",
5488
- children: [ref, " => ", prefix, rhs],
5492
+ children,
5493
+ ref,
5494
+ body,
5489
5495
  ampersandBlock: true
5490
5496
  };
5491
5497
  });
@@ -6518,7 +6524,7 @@ ${input.slice(result.pos)}
6518
6524
  var ArrayLiteral$0 = $T($S(ArrayBindingPattern, UpcomingAssignment), function(value) {
6519
6525
  return value[0];
6520
6526
  });
6521
- var ArrayLiteral$1 = $TS($S(OpenBracket, AllowAll, $E($S(ArrayLiteralContent, __, CloseBracket)), RestoreIndentedApplication, RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
6527
+ var ArrayLiteral$1 = $TS($S(OpenBracket, AllowAll, $E($S(ArrayLiteralContent, __, CloseBracket)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
6522
6528
  var open = $1;
6523
6529
  if (!$3)
6524
6530
  return $skip;
@@ -6655,7 +6661,7 @@ ${input.slice(result.pos)}
6655
6661
  var ArrayLiteralContent$0 = RangeExpression;
6656
6662
  var ArrayLiteralContent$1 = $S(NestedImplicitObjectLiteral, $Q($S(__, Comma, NestedImplicitObjectLiteral)));
6657
6663
  var ArrayLiteralContent$2 = NestedElementList;
6658
- var ArrayLiteralContent$3 = $TS($S(ElementList, InsertComma, $E(NestedElementList)), function($skip, $loc, $0, $1, $2, $3) {
6664
+ var ArrayLiteralContent$3 = $TS($S(ElementListWithIndentedApplicationForbidden, InsertComma, $E(NestedElementList)), function($skip, $loc, $0, $1, $2, $3) {
6659
6665
  var list = $1;
6660
6666
  var comma = $2;
6661
6667
  var nested = $3;
@@ -6784,6 +6790,33 @@ ${input.slice(result.pos)}
6784
6790
  return result;
6785
6791
  }
6786
6792
  }
6793
+ var ElementListWithIndentedApplicationForbidden$0 = $TS($S(ForbidIndentedApplication, $E(ElementList), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
6794
+ if ($2)
6795
+ return $2;
6796
+ return $skip;
6797
+ });
6798
+ function ElementListWithIndentedApplicationForbidden(state) {
6799
+ let eventData;
6800
+ if (state.events) {
6801
+ const result = state.events.enter?.("ElementListWithIndentedApplicationForbidden", state);
6802
+ if (result) {
6803
+ if (result.cache)
6804
+ return result.cache;
6805
+ eventData = result.data;
6806
+ }
6807
+ }
6808
+ if (state.tokenize) {
6809
+ const result = $TOKEN("ElementListWithIndentedApplicationForbidden", state, ElementListWithIndentedApplicationForbidden$0(state));
6810
+ if (state.events)
6811
+ state.events.exit?.("ElementListWithIndentedApplicationForbidden", state, result, eventData);
6812
+ return result;
6813
+ } else {
6814
+ const result = ElementListWithIndentedApplicationForbidden$0(state);
6815
+ if (state.events)
6816
+ state.events.exit?.("ElementListWithIndentedApplicationForbidden", state, result, eventData);
6817
+ return result;
6818
+ }
6819
+ }
6787
6820
  var ElementList$0 = $TS($S(ArrayElementExpression, $Q(ElementListRest)), function($skip, $loc, $0, $1, $2) {
6788
6821
  var first = $1;
6789
6822
  var rest = $2;
@@ -9276,7 +9309,7 @@ ${input.slice(result.pos)}
9276
9309
  return result;
9277
9310
  }
9278
9311
  }
9279
- var WhenCondition$0 = $T($S(__, When, ExtendedExpression), function(value) {
9312
+ var WhenCondition$0 = $T($S(__, When, ExpressionWithIndentedApplicationForbidden), function(value) {
9280
9313
  var exp = value[2];
9281
9314
  return exp;
9282
9315
  });
@@ -9302,7 +9335,7 @@ ${input.slice(result.pos)}
9302
9335
  return result;
9303
9336
  }
9304
9337
  }
9305
- var CoffeeForStatementParameters$0 = $TS($S($E($S(Await, __)), InsertOpenParen, CoffeeForDeclaration, $E(CoffeeForIndex), __, $C(In, Of, From), ExtendedExpression, $E($S(__, By, ExtendedExpression)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
9338
+ var CoffeeForStatementParameters$0 = $TS($S($E($S(Await, __)), InsertOpenParen, CoffeeForDeclaration, $E(CoffeeForIndex), __, $C(In, Of, From), ExpressionWithIndentedApplicationForbidden, $E($S(__, By, ExpressionWithIndentedApplicationForbidden)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
9306
9339
  var open = $2;
9307
9340
  var declaration = $3;
9308
9341
  var index = $4;
@@ -9789,7 +9822,7 @@ ${input.slice(result.pos)}
9789
9822
  var e = $0;
9790
9823
  return {
9791
9824
  type: "SwitchExpression",
9792
- children: ["(()=>{", e.children, "})()"],
9825
+ children: module2.wrapIIFE(e.children),
9793
9826
  expression: e.expression,
9794
9827
  caseBlock: e.caseBlock
9795
9828
  };
@@ -10099,7 +10132,7 @@ ${input.slice(result.pos)}
10099
10132
  return {
10100
10133
  type: "TryExpression",
10101
10134
  blocks: t.blocks,
10102
- children: ["(()=>{", t, "})()"]
10135
+ children: module2.wrapIIFE(t)
10103
10136
  };
10104
10137
  });
10105
10138
  function TryExpression(state) {
@@ -10795,7 +10828,7 @@ ${input.slice(result.pos)}
10795
10828
  var DebuggerExpression$0 = $TS($S(Debugger), function($skip, $loc, $0, $1) {
10796
10829
  return {
10797
10830
  type: "DebuggerExpression",
10798
- children: ["(()=>{", $1, "})()"]
10831
+ children: module2.wrapIIFE($1)
10799
10832
  };
10800
10833
  });
10801
10834
  function DebuggerExpression(state) {
@@ -10823,7 +10856,7 @@ ${input.slice(result.pos)}
10823
10856
  var ThrowExpression$0 = $TS($S(Throw, ExtendedExpression), function($skip, $loc, $0, $1, $2) {
10824
10857
  return {
10825
10858
  type: "ThrowExpression",
10826
- children: ["(()=>{", $0, "})()"]
10859
+ children: module2.wrapIIFE($0)
10827
10860
  };
10828
10861
  });
10829
10862
  function ThrowExpression(state) {
@@ -13564,7 +13597,7 @@ ${input.slice(result.pos)}
13564
13597
  }
13565
13598
  }
13566
13599
  var Await$0 = $TS($S($EXPECT($L104, fail, 'Await "await"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
13567
- return { $loc, token: $1 };
13600
+ return { $loc, token: $1, type: "Await" };
13568
13601
  });
13569
13602
  function Await(state) {
13570
13603
  let eventData;
@@ -19973,7 +20006,7 @@ ${input.slice(result.pos)}
19973
20006
  const i = exp.children.indexOf(exp.block);
19974
20007
  if (exp.subtype === "DoStatement") {
19975
20008
  insertReturn(exp.block);
19976
- exp.children.splice(i, 1, "(()=>", ...exp.children, ")()");
20009
+ exp.children.splice(i, 1, ...module2.wrapIIFE(exp.children));
19977
20010
  return;
19978
20011
  }
19979
20012
  const resultsRef = {
@@ -19982,8 +20015,28 @@ ${input.slice(result.pos)}
19982
20015
  id: "results"
19983
20016
  };
19984
20017
  insertPush(exp.block, resultsRef);
19985
- exp.children.splice(i, 1, "(()=>{const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef, "})()");
20018
+ exp.children.splice(i, 1, module2.wrapIIFE(
20019
+ ["const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef]
20020
+ ));
19986
20021
  }
20022
+ module2.hasAwait = (exp) => {
20023
+ return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
20024
+ };
20025
+ module2.wrapIIFE = (exp) => {
20026
+ let prefix, suffix;
20027
+ if (module2.hasAwait(exp)) {
20028
+ prefix = "(await (async ()=>{";
20029
+ suffix = "})())";
20030
+ } else {
20031
+ prefix = "(()=>{";
20032
+ suffix = "})()";
20033
+ }
20034
+ if (Array.isArray(exp)) {
20035
+ return [prefix, ...exp, suffix];
20036
+ } else {
20037
+ return [prefix, exp, suffix];
20038
+ }
20039
+ };
19987
20040
  function wrapIterationReturningResults(statement, outerRef) {
19988
20041
  if (statement.type === "DoStatement") {
19989
20042
  if (outerRef) {
@@ -20595,12 +20648,14 @@ ${input.slice(result.pos)}
20595
20648
  return;
20596
20649
  if (typeof node !== "object")
20597
20650
  return;
20598
- node.parent = parent;
20599
20651
  if (Array.isArray(node)) {
20600
20652
  for (const child of node) {
20601
- addParentPointers(child, node);
20653
+ addParentPointers(child, parent);
20602
20654
  }
20603
- } else if (node.children) {
20655
+ return;
20656
+ }
20657
+ node.parent = parent;
20658
+ if (node.children) {
20604
20659
  for (const child of node.children) {
20605
20660
  addParentPointers(child, node);
20606
20661
  }
@@ -21218,11 +21273,11 @@ ${input.slice(result.pos)}
21218
21273
  });
21219
21274
  if (module2.config.implicitReturns && s.type === "SwitchExpression") {
21220
21275
  insertReturn(root[0]);
21221
- root.unshift("(()=>{");
21222
- root.push("})()");
21276
+ root.splice(0, 1, module2.wrapIIFE(root[0]));
21223
21277
  }
21224
21278
  s.type = "PatternMatchingStatement";
21225
21279
  s.children = [root];
21280
+ addParentPointers(s, s.parent);
21226
21281
  });
21227
21282
  }
21228
21283
  function processPipelineExpressions(statements) {
@@ -21277,6 +21332,7 @@ ${input.slice(result.pos)}
21277
21332
  }
21278
21333
  children.push(arg);
21279
21334
  s.children = children;
21335
+ addParentPointers(s, s.parent);
21280
21336
  });
21281
21337
  }
21282
21338
  module2.processProgram = function(statements) {
@@ -21486,12 +21542,12 @@ ${input.slice(result.pos)}
21486
21542
  module2.constructInvocation = function(fn, arg) {
21487
21543
  const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
21488
21544
  if (fn.expr.ampersandBlock) {
21489
- const [ref, , prefix, rhs] = fn.expr.children;
21545
+ const { ref, body } = fn.expr;
21490
21546
  ref.type = "PipedExpression";
21491
21547
  ref.children = [module2.makeLeftHandSideExpression(arg)];
21492
21548
  return {
21493
21549
  type: "UnwrappedExpression",
21494
- children: [module2.skipIfOnlyWS(fn.leadingComment), prefix, rhs, module2.skipIfOnlyWS(fn.trailingComment)]
21550
+ children: [module2.skipIfOnlyWS(fn.leadingComment), ...body, module2.skipIfOnlyWS(fn.trailingComment)]
21495
21551
  };
21496
21552
  }
21497
21553
  const lhs = module2.makeLeftHandSideExpression(fn.expr);
@@ -22254,7 +22310,7 @@ var parse;
22254
22310
  var uncacheable;
22255
22311
  ({ parse } = import_parser.default);
22256
22312
  ({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
22257
- uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowIndentedApplication", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidIndentedApplication", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
22313
+ uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowIndentedApplication", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidIndentedApplication", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
22258
22314
  var compile = function(src, options) {
22259
22315
  var ast, code, events, filename, ref, result, sm, srcMapJSON;
22260
22316
  if (!options) {
package/dist/main.mjs CHANGED
@@ -597,6 +597,7 @@ ${input.slice(result.pos)}
597
597
  NestedElementList,
598
598
  NestedElement,
599
599
  ArrayElementDelimiter,
600
+ ElementListWithIndentedApplicationForbidden,
600
601
  ElementList,
601
602
  ElementListRest,
602
603
  ArrayElementExpression,
@@ -5468,22 +5469,27 @@ ${input.slice(result.pos)}
5468
5469
  var rhs = $3;
5469
5470
  if (!prefix && !rhs)
5470
5471
  return $skip;
5472
+ let body, ref;
5471
5473
  if (!rhs) {
5472
- const ref2 = {
5474
+ ref = {
5473
5475
  type: "Ref",
5474
5476
  base: "$",
5475
5477
  id: "$"
5476
5478
  };
5477
- return {
5478
- type: "ArrowFunction",
5479
- children: [ref2, " => ", prefix, ref2],
5480
- ampersandBlock: true
5481
- };
5479
+ body = [prefix, ref];
5480
+ } else {
5481
+ ({ ref } = rhs);
5482
+ body = [prefix, rhs];
5483
+ }
5484
+ const children = [ref, " => ", ...body];
5485
+ if (module.hasAwait(body)) {
5486
+ children.unshift("async ");
5482
5487
  }
5483
- const { ref } = rhs;
5484
5488
  return {
5485
5489
  type: "ArrowFunction",
5486
- children: [ref, " => ", prefix, rhs],
5490
+ children,
5491
+ ref,
5492
+ body,
5487
5493
  ampersandBlock: true
5488
5494
  };
5489
5495
  });
@@ -6516,7 +6522,7 @@ ${input.slice(result.pos)}
6516
6522
  var ArrayLiteral$0 = $T($S(ArrayBindingPattern, UpcomingAssignment), function(value) {
6517
6523
  return value[0];
6518
6524
  });
6519
- var ArrayLiteral$1 = $TS($S(OpenBracket, AllowAll, $E($S(ArrayLiteralContent, __, CloseBracket)), RestoreIndentedApplication, RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
6525
+ var ArrayLiteral$1 = $TS($S(OpenBracket, AllowAll, $E($S(ArrayLiteralContent, __, CloseBracket)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
6520
6526
  var open = $1;
6521
6527
  if (!$3)
6522
6528
  return $skip;
@@ -6653,7 +6659,7 @@ ${input.slice(result.pos)}
6653
6659
  var ArrayLiteralContent$0 = RangeExpression;
6654
6660
  var ArrayLiteralContent$1 = $S(NestedImplicitObjectLiteral, $Q($S(__, Comma, NestedImplicitObjectLiteral)));
6655
6661
  var ArrayLiteralContent$2 = NestedElementList;
6656
- var ArrayLiteralContent$3 = $TS($S(ElementList, InsertComma, $E(NestedElementList)), function($skip, $loc, $0, $1, $2, $3) {
6662
+ var ArrayLiteralContent$3 = $TS($S(ElementListWithIndentedApplicationForbidden, InsertComma, $E(NestedElementList)), function($skip, $loc, $0, $1, $2, $3) {
6657
6663
  var list = $1;
6658
6664
  var comma = $2;
6659
6665
  var nested = $3;
@@ -6782,6 +6788,33 @@ ${input.slice(result.pos)}
6782
6788
  return result;
6783
6789
  }
6784
6790
  }
6791
+ var ElementListWithIndentedApplicationForbidden$0 = $TS($S(ForbidIndentedApplication, $E(ElementList), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
6792
+ if ($2)
6793
+ return $2;
6794
+ return $skip;
6795
+ });
6796
+ function ElementListWithIndentedApplicationForbidden(state) {
6797
+ let eventData;
6798
+ if (state.events) {
6799
+ const result = state.events.enter?.("ElementListWithIndentedApplicationForbidden", state);
6800
+ if (result) {
6801
+ if (result.cache)
6802
+ return result.cache;
6803
+ eventData = result.data;
6804
+ }
6805
+ }
6806
+ if (state.tokenize) {
6807
+ const result = $TOKEN("ElementListWithIndentedApplicationForbidden", state, ElementListWithIndentedApplicationForbidden$0(state));
6808
+ if (state.events)
6809
+ state.events.exit?.("ElementListWithIndentedApplicationForbidden", state, result, eventData);
6810
+ return result;
6811
+ } else {
6812
+ const result = ElementListWithIndentedApplicationForbidden$0(state);
6813
+ if (state.events)
6814
+ state.events.exit?.("ElementListWithIndentedApplicationForbidden", state, result, eventData);
6815
+ return result;
6816
+ }
6817
+ }
6785
6818
  var ElementList$0 = $TS($S(ArrayElementExpression, $Q(ElementListRest)), function($skip, $loc, $0, $1, $2) {
6786
6819
  var first = $1;
6787
6820
  var rest = $2;
@@ -9274,7 +9307,7 @@ ${input.slice(result.pos)}
9274
9307
  return result;
9275
9308
  }
9276
9309
  }
9277
- var WhenCondition$0 = $T($S(__, When, ExtendedExpression), function(value) {
9310
+ var WhenCondition$0 = $T($S(__, When, ExpressionWithIndentedApplicationForbidden), function(value) {
9278
9311
  var exp = value[2];
9279
9312
  return exp;
9280
9313
  });
@@ -9300,7 +9333,7 @@ ${input.slice(result.pos)}
9300
9333
  return result;
9301
9334
  }
9302
9335
  }
9303
- var CoffeeForStatementParameters$0 = $TS($S($E($S(Await, __)), InsertOpenParen, CoffeeForDeclaration, $E(CoffeeForIndex), __, $C(In, Of, From), ExtendedExpression, $E($S(__, By, ExtendedExpression)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
9336
+ var CoffeeForStatementParameters$0 = $TS($S($E($S(Await, __)), InsertOpenParen, CoffeeForDeclaration, $E(CoffeeForIndex), __, $C(In, Of, From), ExpressionWithIndentedApplicationForbidden, $E($S(__, By, ExpressionWithIndentedApplicationForbidden)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
9304
9337
  var open = $2;
9305
9338
  var declaration = $3;
9306
9339
  var index = $4;
@@ -9787,7 +9820,7 @@ ${input.slice(result.pos)}
9787
9820
  var e = $0;
9788
9821
  return {
9789
9822
  type: "SwitchExpression",
9790
- children: ["(()=>{", e.children, "})()"],
9823
+ children: module.wrapIIFE(e.children),
9791
9824
  expression: e.expression,
9792
9825
  caseBlock: e.caseBlock
9793
9826
  };
@@ -10097,7 +10130,7 @@ ${input.slice(result.pos)}
10097
10130
  return {
10098
10131
  type: "TryExpression",
10099
10132
  blocks: t.blocks,
10100
- children: ["(()=>{", t, "})()"]
10133
+ children: module.wrapIIFE(t)
10101
10134
  };
10102
10135
  });
10103
10136
  function TryExpression(state) {
@@ -10793,7 +10826,7 @@ ${input.slice(result.pos)}
10793
10826
  var DebuggerExpression$0 = $TS($S(Debugger), function($skip, $loc, $0, $1) {
10794
10827
  return {
10795
10828
  type: "DebuggerExpression",
10796
- children: ["(()=>{", $1, "})()"]
10829
+ children: module.wrapIIFE($1)
10797
10830
  };
10798
10831
  });
10799
10832
  function DebuggerExpression(state) {
@@ -10821,7 +10854,7 @@ ${input.slice(result.pos)}
10821
10854
  var ThrowExpression$0 = $TS($S(Throw, ExtendedExpression), function($skip, $loc, $0, $1, $2) {
10822
10855
  return {
10823
10856
  type: "ThrowExpression",
10824
- children: ["(()=>{", $0, "})()"]
10857
+ children: module.wrapIIFE($0)
10825
10858
  };
10826
10859
  });
10827
10860
  function ThrowExpression(state) {
@@ -13562,7 +13595,7 @@ ${input.slice(result.pos)}
13562
13595
  }
13563
13596
  }
13564
13597
  var Await$0 = $TS($S($EXPECT($L104, fail, 'Await "await"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
13565
- return { $loc, token: $1 };
13598
+ return { $loc, token: $1, type: "Await" };
13566
13599
  });
13567
13600
  function Await(state) {
13568
13601
  let eventData;
@@ -19971,7 +20004,7 @@ ${input.slice(result.pos)}
19971
20004
  const i = exp.children.indexOf(exp.block);
19972
20005
  if (exp.subtype === "DoStatement") {
19973
20006
  insertReturn(exp.block);
19974
- exp.children.splice(i, 1, "(()=>", ...exp.children, ")()");
20007
+ exp.children.splice(i, 1, ...module.wrapIIFE(exp.children));
19975
20008
  return;
19976
20009
  }
19977
20010
  const resultsRef = {
@@ -19980,8 +20013,28 @@ ${input.slice(result.pos)}
19980
20013
  id: "results"
19981
20014
  };
19982
20015
  insertPush(exp.block, resultsRef);
19983
- exp.children.splice(i, 1, "(()=>{const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef, "})()");
20016
+ exp.children.splice(i, 1, module.wrapIIFE(
20017
+ ["const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef]
20018
+ ));
19984
20019
  }
20020
+ module.hasAwait = (exp) => {
20021
+ return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
20022
+ };
20023
+ module.wrapIIFE = (exp) => {
20024
+ let prefix, suffix;
20025
+ if (module.hasAwait(exp)) {
20026
+ prefix = "(await (async ()=>{";
20027
+ suffix = "})())";
20028
+ } else {
20029
+ prefix = "(()=>{";
20030
+ suffix = "})()";
20031
+ }
20032
+ if (Array.isArray(exp)) {
20033
+ return [prefix, ...exp, suffix];
20034
+ } else {
20035
+ return [prefix, exp, suffix];
20036
+ }
20037
+ };
19985
20038
  function wrapIterationReturningResults(statement, outerRef) {
19986
20039
  if (statement.type === "DoStatement") {
19987
20040
  if (outerRef) {
@@ -20593,12 +20646,14 @@ ${input.slice(result.pos)}
20593
20646
  return;
20594
20647
  if (typeof node !== "object")
20595
20648
  return;
20596
- node.parent = parent;
20597
20649
  if (Array.isArray(node)) {
20598
20650
  for (const child of node) {
20599
- addParentPointers(child, node);
20651
+ addParentPointers(child, parent);
20600
20652
  }
20601
- } else if (node.children) {
20653
+ return;
20654
+ }
20655
+ node.parent = parent;
20656
+ if (node.children) {
20602
20657
  for (const child of node.children) {
20603
20658
  addParentPointers(child, node);
20604
20659
  }
@@ -21216,11 +21271,11 @@ ${input.slice(result.pos)}
21216
21271
  });
21217
21272
  if (module.config.implicitReturns && s.type === "SwitchExpression") {
21218
21273
  insertReturn(root[0]);
21219
- root.unshift("(()=>{");
21220
- root.push("})()");
21274
+ root.splice(0, 1, module.wrapIIFE(root[0]));
21221
21275
  }
21222
21276
  s.type = "PatternMatchingStatement";
21223
21277
  s.children = [root];
21278
+ addParentPointers(s, s.parent);
21224
21279
  });
21225
21280
  }
21226
21281
  function processPipelineExpressions(statements) {
@@ -21275,6 +21330,7 @@ ${input.slice(result.pos)}
21275
21330
  }
21276
21331
  children.push(arg);
21277
21332
  s.children = children;
21333
+ addParentPointers(s, s.parent);
21278
21334
  });
21279
21335
  }
21280
21336
  module.processProgram = function(statements) {
@@ -21484,12 +21540,12 @@ ${input.slice(result.pos)}
21484
21540
  module.constructInvocation = function(fn, arg) {
21485
21541
  const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
21486
21542
  if (fn.expr.ampersandBlock) {
21487
- const [ref, , prefix, rhs] = fn.expr.children;
21543
+ const { ref, body } = fn.expr;
21488
21544
  ref.type = "PipedExpression";
21489
21545
  ref.children = [module.makeLeftHandSideExpression(arg)];
21490
21546
  return {
21491
21547
  type: "UnwrappedExpression",
21492
- children: [module.skipIfOnlyWS(fn.leadingComment), prefix, rhs, module.skipIfOnlyWS(fn.trailingComment)]
21548
+ children: [module.skipIfOnlyWS(fn.leadingComment), ...body, module.skipIfOnlyWS(fn.trailingComment)]
21493
21549
  };
21494
21550
  }
21495
21551
  const lhs = module.makeLeftHandSideExpression(fn.expr);
@@ -22242,7 +22298,7 @@ var parse;
22242
22298
  var uncacheable;
22243
22299
  ({ parse } = import_parser.default);
22244
22300
  ({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
22245
- uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowIndentedApplication", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidIndentedApplication", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
22301
+ uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowIndentedApplication", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidIndentedApplication", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
22246
22302
  var compile = function(src, options) {
22247
22303
  var ast, code, events, filename, ref, result, sm, srcMapJSON;
22248
22304
  if (!options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.5.74",
3
+ "version": "0.5.76",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.mjs",