@danielx/civet 0.7.33 → 0.7.34

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
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  mod
29
29
  ));
30
30
 
31
- // node_modules/@danielx/hera/dist/machine.js
31
+ // node_modules/.pnpm/@danielx+hera@0.8.16/node_modules/@danielx/hera/dist/machine.js
32
32
  var require_machine = __commonJS({
33
- "node_modules/@danielx/hera/dist/machine.js"(exports, module) {
33
+ "node_modules/.pnpm/@danielx+hera@0.8.16/node_modules/@danielx/hera/dist/machine.js"(exports, module) {
34
34
  "use strict";
35
35
  var __defProp2 = Object.defineProperty;
36
36
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -1065,12 +1065,11 @@ function convertOptionalType(suffix) {
1065
1065
  ]);
1066
1066
  }
1067
1067
  var typeNeedsNoParens = /* @__PURE__ */ new Set([
1068
- "IdentifierType",
1068
+ "TypeIdentifier",
1069
1069
  "ImportType",
1070
- "LiteralType",
1070
+ "TypeLiteral",
1071
1071
  "TupleType",
1072
- "ParenthesizedType",
1073
- "UnaryType"
1072
+ "TypeParenthesized"
1074
1073
  ]);
1075
1074
  function parenthesizeType(type) {
1076
1075
  if (typeNeedsNoParens.has(type.type)) {
@@ -1560,16 +1559,16 @@ function gatherBindingPatternTypeSuffix(pattern) {
1560
1559
 
1561
1560
  // source/parser/function.civet
1562
1561
  function isVoidType(t) {
1563
- return t?.type === "LiteralType" && t.t.type === "VoidType";
1562
+ return t?.type === "TypeLiteral" && t.t.type === "VoidType";
1564
1563
  }
1565
1564
  function isPromiseVoidType(t) {
1566
- return t?.type === "IdentifierType" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
1565
+ return t?.type === "TypeIdentifier" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
1567
1566
  }
1568
1567
  function isGeneratorVoidType(t) {
1569
- return t?.type === "IdentifierType" && (t.raw === "Iterator" || t.raw === "Generator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
1568
+ return t?.type === "TypeIdentifier" && (t.raw === "Iterator" || t.raw === "Generator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
1570
1569
  }
1571
1570
  function isAsyncGeneratorVoidType(t) {
1572
- return t?.type === "IdentifierType" && (t.raw === "AsyncIterator" || t.raw === "AsyncGenerator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
1571
+ return t?.type === "TypeIdentifier" && (t.raw === "AsyncIterator" || t.raw === "AsyncGenerator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
1573
1572
  }
1574
1573
  function implicitFunctionBlock(f) {
1575
1574
  if (f.abstract || f.block || f.signature?.optional)
@@ -1767,14 +1766,13 @@ function assignResults(node, collect) {
1767
1766
  if (isExit(exp)) {
1768
1767
  return;
1769
1768
  }
1769
+ exp = exp;
1770
1770
  const outer = exp;
1771
- let { type } = exp;
1772
- if (type === "LabelledStatement") {
1771
+ if (exp.type === "LabelledStatement") {
1773
1772
  exp = exp.statement;
1774
- ({ type } = exp);
1775
1773
  }
1776
1774
  let ref4;
1777
- switch (type) {
1775
+ switch (exp.type) {
1778
1776
  case "BreakStatement":
1779
1777
  case "ContinueStatement":
1780
1778
  case "DebuggerStatement":
@@ -3776,9 +3774,6 @@ function processDeclarationConditionStatement(s) {
3776
3774
  }
3777
3775
  } else {
3778
3776
  const block = blockWithPrefix(blockPrefix, s.then);
3779
- if (block.bare && e && !block.semicolon) {
3780
- block.children.push(block.semicolon = ";");
3781
- }
3782
3777
  s.children = s.children.map(($2) => $2 === s.then ? block : $2);
3783
3778
  s.then = block;
3784
3779
  updateParentPointers(s);
@@ -4487,7 +4482,8 @@ var concatAssign = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isAr
4487
4482
  function findDecs(statements) {
4488
4483
  const declarations = gatherNodes(statements, ($) => $.type === "Declaration");
4489
4484
  const declarationNames = declarations.flatMap((d) => d.names);
4490
- return new Set(declarationNames);
4485
+ const globals = getConfig().globals || [];
4486
+ return new Set(globals.concat(declarationNames));
4491
4487
  }
4492
4488
  function createConstLetDecs(statements, scopes, letOrConst) {
4493
4489
  function findVarDecs(statements2, decs) {
@@ -5339,7 +5335,7 @@ function expressionizeIfStatement(statement) {
5339
5335
  function expressionizeTypeIf([ifOp, condition, t, e]) {
5340
5336
  const children = [
5341
5337
  "(",
5342
- insertTrimmingSpace(condition, ""),
5338
+ trimFirstSpace(condition),
5343
5339
  "?"
5344
5340
  ];
5345
5341
  if (!xor(ifOp.negated, condition.negated)) {
@@ -5522,7 +5518,7 @@ function processCallMemberExpression(node) {
5522
5518
  [name, value] = [value, name];
5523
5519
  }
5524
5520
  if (!suppressPrefix) {
5525
- value = prefix.concat(insertTrimmingSpace(value, ""));
5521
+ value = prefix.concat(trimFirstSpace(value));
5526
5522
  }
5527
5523
  if (wValue)
5528
5524
  value.unshift(wValue);
@@ -5748,7 +5744,7 @@ function convertObjectToJSXAttributes(obj) {
5748
5744
  if (part.name.type === "ComputedPropertyName") {
5749
5745
  rest.push(part);
5750
5746
  } else {
5751
- parts.push([part.name, "={", insertTrimmingSpace(part.value, ""), "}"]);
5747
+ parts.push([part.name, "={", trimFirstSpace(part.value), "}"]);
5752
5748
  }
5753
5749
  break;
5754
5750
  case "SpreadProperty":
@@ -5773,7 +5769,7 @@ function convertObjectToJSXAttributes(obj) {
5773
5769
  }
5774
5770
  function makeGetterMethod(name, ws, value, returnType, block, kind = { token: "get" }, autoReturn = true) {
5775
5771
  const { token } = kind;
5776
- ws = insertTrimmingSpace(ws, "");
5772
+ ws = trimFirstSpace(ws);
5777
5773
  let setVal;
5778
5774
  const parameters = token === "get" ? {
5779
5775
  type: "Parameters",
@@ -6134,7 +6130,7 @@ function attachPostfixStatementAsExpression(exp, post) {
6134
6130
  }
6135
6131
  }
6136
6132
  function processTypes(node) {
6137
- return gatherRecursiveAll(node, (n) => n.type === "UnaryType").forEach((unary) => {
6133
+ return gatherRecursiveAll(node, (n) => n.type === "TypeUnary").forEach((unary) => {
6138
6134
  let last;
6139
6135
  let count = 0;
6140
6136
  let ref10;
@@ -6145,6 +6141,12 @@ function processTypes(node) {
6145
6141
  if (!count) {
6146
6142
  return;
6147
6143
  }
6144
+ let ref11;
6145
+ if (unary.suffix.length || unary.prefix.length)
6146
+ ref11 = unary;
6147
+ else
6148
+ ref11 = unary.t;
6149
+ const t = ref11;
6148
6150
  if (unary.parent?.type === "TypeTuple") {
6149
6151
  if (count === 1) {
6150
6152
  unary.suffix.push(last);
@@ -6153,18 +6155,22 @@ function processTypes(node) {
6153
6155
  replaceNode(unary, [
6154
6156
  getTrimmingSpace(unary),
6155
6157
  "(",
6156
- parenthesizeType(insertTrimmingSpace(unary, "")),
6158
+ parenthesizeType(trimFirstSpace(t)),
6157
6159
  " | null)",
6158
6160
  last
6159
6161
  ]);
6160
6162
  } else {
6161
- replaceNode(unary, [
6162
- getTrimmingSpace(unary),
6163
- "(",
6164
- parenthesizeType(insertTrimmingSpace(unary, "")),
6165
- count === 1 ? " | undefined" : " | undefined | null",
6166
- ")"
6167
- ]);
6163
+ replaceNode(unary, {
6164
+ type: "TypeParenthesized",
6165
+ ts: true,
6166
+ children: [
6167
+ getTrimmingSpace(unary),
6168
+ "(",
6169
+ parenthesizeType(trimFirstSpace(t)),
6170
+ count === 1 ? " | undefined" : " | undefined | null",
6171
+ ")"
6172
+ ]
6173
+ });
6168
6174
  }
6169
6175
  });
6170
6176
  }
@@ -6172,11 +6178,11 @@ function processStatementExpressions(statements) {
6172
6178
  gatherRecursiveAll(statements, ($7) => $7.type === "StatementExpression").forEach((_exp) => {
6173
6179
  const exp = _exp;
6174
6180
  const { statement } = exp;
6175
- let ref11;
6181
+ let ref12;
6176
6182
  switch (statement.type) {
6177
6183
  case "IfStatement": {
6178
- if (ref11 = expressionizeIfStatement(statement)) {
6179
- const expression = ref11;
6184
+ if (ref12 = expressionizeIfStatement(statement)) {
6185
+ const expression = ref12;
6180
6186
  return replaceNode(statement, expression, exp);
6181
6187
  } else {
6182
6188
  return replaceNode(statement, wrapIIFE([["", statement]]), exp);
@@ -6404,8 +6410,8 @@ function processPlaceholders(statements) {
6404
6410
  for (let i4 = 0, len3 = placeholders.length; i4 < len3; i4++) {
6405
6411
  const placeholder = placeholders[i4];
6406
6412
  typeSuffix ??= placeholder.typeSuffix;
6407
- let ref12;
6408
- replaceNode((ref12 = placeholder.children)[ref12.length - 1], ref);
6413
+ let ref13;
6414
+ replaceNode((ref13 = placeholder.children)[ref13.length - 1], ref);
6409
6415
  }
6410
6416
  const { parent } = ancestor;
6411
6417
  const body = maybeUnwrap(ancestor);
@@ -6422,16 +6428,16 @@ function processPlaceholders(statements) {
6422
6428
  }
6423
6429
  case "PipelineExpression": {
6424
6430
  const i = findChildIndex(parent, ancestor);
6425
- let ref13;
6431
+ let ref14;
6426
6432
  if (i === 1) {
6427
- ref13 = ancestor === parent.children[i];
6433
+ ref14 = ancestor === parent.children[i];
6428
6434
  } else if (i === 2) {
6429
- ref13 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
6435
+ ref14 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
6430
6436
  } else {
6431
- ref13 = void 0;
6437
+ ref14 = void 0;
6432
6438
  }
6433
6439
  ;
6434
- outer = ref13;
6440
+ outer = ref14;
6435
6441
  break;
6436
6442
  }
6437
6443
  case "AssignmentExpression":
@@ -6446,9 +6452,9 @@ function processPlaceholders(statements) {
6446
6452
  fnExp = makeLeftHandSideExpression(fnExp);
6447
6453
  }
6448
6454
  replaceNode(ancestor, fnExp, parent);
6449
- let ref14;
6450
- if (ref14 = getTrimmingSpace(body)) {
6451
- const ws = ref14;
6455
+ let ref15;
6456
+ if (ref15 = getTrimmingSpace(body)) {
6457
+ const ws = ref15;
6452
6458
  inplaceInsertTrimmingSpace(body, "");
6453
6459
  inplacePrepend(ws, fnExp);
6454
6460
  }
@@ -6493,8 +6499,8 @@ function reorderBindingRestProperty(props) {
6493
6499
  }
6494
6500
  ];
6495
6501
  }
6496
- let ref15;
6497
- if (Array.isArray(rest.delim) && (ref15 = rest.delim)[ref15.length - 1]?.token === ",") {
6502
+ let ref16;
6503
+ if (Array.isArray(rest.delim) && (ref16 = rest.delim)[ref16.length - 1]?.token === ",") {
6498
6504
  rest.delim = rest.delim.slice(0, -1);
6499
6505
  rest.children = [...rest.children.slice(0, -1), rest.delim];
6500
6506
  }
@@ -7258,6 +7264,7 @@ var grammar = {
7258
7264
  NamespaceDeclaration,
7259
7265
  OptionalEquals,
7260
7266
  TypeLexicalDeclaration,
7267
+ TypeLetOrConstDeclaration,
7261
7268
  TypeDeclarationBinding,
7262
7269
  InterfaceExtendsClause,
7263
7270
  InterfaceExtendsTarget,
@@ -7751,7 +7758,7 @@ var $R90 = (0, import_lib3.$R)(new RegExp("(extends|not|is)(?!\\p{ID_Continue}|[
7751
7758
  var $R91 = (0, import_lib3.$R)(new RegExp("#![^\\r\\n]*", "suy"));
7752
7759
  var $R92 = (0, import_lib3.$R)(new RegExp("[\\t ]*", "suy"));
7753
7760
  var $R93 = (0, import_lib3.$R)(new RegExp("[\\s]*", "suy"));
7754
- var $R94 = (0, import_lib3.$R)(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
7761
+ var $R94 = (0, import_lib3.$R)(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([\\p{ID_Continue}.,+-]*))?", "suy"));
7755
7762
  var $R95 = (0, import_lib3.$R)(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
7756
7763
  var $R96 = (0, import_lib3.$R)(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
7757
7764
  var $R97 = (0, import_lib3.$R)(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
@@ -12688,6 +12695,14 @@ var IfStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)
12688
12695
  kind = { ...kind, token: "if" };
12689
12696
  condition = negateCondition(condition);
12690
12697
  }
12698
+ if (block.bare && e) {
12699
+ const semicolon = ";";
12700
+ block = {
12701
+ ...block,
12702
+ semicolon,
12703
+ children: [...block.children, semicolon]
12704
+ };
12705
+ }
12691
12706
  return {
12692
12707
  type: "IfStatement",
12693
12708
  children: [kind, ws, condition, block, e],
@@ -12701,6 +12716,13 @@ var IfStatement$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(IfClause, BlockOrEm
12701
12716
  var clause = $1;
12702
12717
  var block = $2;
12703
12718
  var e = $3;
12719
+ if (block.bare && e) {
12720
+ block = {
12721
+ ...block,
12722
+ semicolon: ";",
12723
+ children: [...block.children, ";"]
12724
+ };
12725
+ }
12704
12726
  return {
12705
12727
  type: "IfStatement",
12706
12728
  children: [...clause.children, block, e],
@@ -16377,7 +16399,17 @@ var OptionalEquals$$ = [OptionalEquals$0, OptionalEquals$1];
16377
16399
  function OptionalEquals(ctx, state2) {
16378
16400
  return (0, import_lib3.$EVENT_C)(ctx, state2, "OptionalEquals", OptionalEquals$$);
16379
16401
  }
16380
- var TypeLexicalDeclaration$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(__, LetOrConstOrVar, TypeDeclarationBinding, (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, __, TypeDeclarationBinding))), function($skip, $loc, $0, $1, $2, $3, $4) {
16402
+ var TypeLexicalDeclaration$0 = TypeLetOrConstDeclaration;
16403
+ var TypeLexicalDeclaration$1 = (0, import_lib3.$S)(__, EnumDeclaration);
16404
+ var TypeLexicalDeclaration$2 = ClassSignature;
16405
+ var TypeLexicalDeclaration$3 = (0, import_lib3.$S)(Namespace, (0, import_lib3.$E)(_), IdentifierName, DeclareBlock);
16406
+ var TypeLexicalDeclaration$4 = (0, import_lib3.$S)(Module, _, StringLiteral, (0, import_lib3.$E)(DeclareBlock));
16407
+ var TypeLexicalDeclaration$5 = (0, import_lib3.$S)(Global, (0, import_lib3.$E)(DeclareBlock));
16408
+ var TypeLexicalDeclaration$$ = [TypeLexicalDeclaration$0, TypeLexicalDeclaration$1, TypeLexicalDeclaration$2, TypeLexicalDeclaration$3, TypeLexicalDeclaration$4, TypeLexicalDeclaration$5];
16409
+ function TypeLexicalDeclaration(ctx, state2) {
16410
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "TypeLexicalDeclaration", TypeLexicalDeclaration$$);
16411
+ }
16412
+ var TypeLetOrConstDeclaration$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(__, LetOrConstOrVar, TypeDeclarationBinding, (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, __, TypeDeclarationBinding))), function($skip, $loc, $0, $1, $2, $3, $4) {
16381
16413
  var first = $3;
16382
16414
  var rest = $4;
16383
16415
  const names = first.names.concat(...rest.map((b) => b[2].names));
@@ -16388,14 +16420,8 @@ var TypeLexicalDeclaration$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(__, LetO
16388
16420
  names
16389
16421
  };
16390
16422
  });
16391
- var TypeLexicalDeclaration$1 = (0, import_lib3.$S)(__, EnumDeclaration);
16392
- var TypeLexicalDeclaration$2 = ClassSignature;
16393
- var TypeLexicalDeclaration$3 = (0, import_lib3.$S)(Namespace, (0, import_lib3.$E)(_), IdentifierName, DeclareBlock);
16394
- var TypeLexicalDeclaration$4 = (0, import_lib3.$S)(Module, _, StringLiteral, (0, import_lib3.$E)(DeclareBlock));
16395
- var TypeLexicalDeclaration$5 = (0, import_lib3.$S)(Global, (0, import_lib3.$E)(DeclareBlock));
16396
- var TypeLexicalDeclaration$$ = [TypeLexicalDeclaration$0, TypeLexicalDeclaration$1, TypeLexicalDeclaration$2, TypeLexicalDeclaration$3, TypeLexicalDeclaration$4, TypeLexicalDeclaration$5];
16397
- function TypeLexicalDeclaration(ctx, state2) {
16398
- return (0, import_lib3.$EVENT_C)(ctx, state2, "TypeLexicalDeclaration", TypeLexicalDeclaration$$);
16423
+ function TypeLetOrConstDeclaration(ctx, state2) {
16424
+ return (0, import_lib3.$EVENT)(ctx, state2, "TypeLetOrConstDeclaration", TypeLetOrConstDeclaration$0);
16399
16425
  }
16400
16426
  var TypeDeclarationBinding$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)(BindingPattern, BindingIdentifier), (0, import_lib3.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
16401
16427
  return {
@@ -16539,13 +16565,14 @@ var NestedDeclareElement$0 = (0, import_lib3.$S)(Nested, DeclareElement, Interfa
16539
16565
  function NestedDeclareElement(ctx, state2) {
16540
16566
  return (0, import_lib3.$EVENT)(ctx, state2, "NestedDeclareElement", NestedDeclareElement$0);
16541
16567
  }
16542
- var DeclareElement$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$E)(Decorators), (0, import_lib3.$E)((0, import_lib3.$S)(Export, (0, import_lib3.$E)(_))), TypeLexicalDeclaration), function(value) {
16568
+ var DeclareElement$0 = (0, import_lib3.$S)((0, import_lib3.$E)(Decorators), Export, __, Default, __, (0, import_lib3.$C)(Identifier, ClassSignature, InterfaceDeclaration));
16569
+ var DeclareElement$1 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$E)(Decorators), (0, import_lib3.$E)((0, import_lib3.$S)(Export, (0, import_lib3.$E)(_))), TypeLexicalDeclaration), function(value) {
16543
16570
  return { "ts": true, "children": value };
16544
16571
  });
16545
- var DeclareElement$1 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$E)((0, import_lib3.$S)(Export, (0, import_lib3.$E)(_))), TypeDeclarationRest), function(value) {
16572
+ var DeclareElement$2 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$E)((0, import_lib3.$S)(Export, (0, import_lib3.$E)(_))), TypeDeclarationRest), function(value) {
16546
16573
  return { "ts": true, "children": value };
16547
16574
  });
16548
- var DeclareElement$$ = [DeclareElement$0, DeclareElement$1];
16575
+ var DeclareElement$$ = [DeclareElement$0, DeclareElement$1, DeclareElement$2];
16549
16576
  function DeclareElement(ctx, state2) {
16550
16577
  return (0, import_lib3.$EVENT_C)(ctx, state2, "DeclareElement", DeclareElement$$);
16551
16578
  }
@@ -16815,7 +16842,7 @@ var TypeUnary$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$Q)((
16815
16842
  if (!prefix.length && !suffix.length)
16816
16843
  return t;
16817
16844
  return {
16818
- type: "UnaryType",
16845
+ type: "TypeUnary",
16819
16846
  prefix,
16820
16847
  suffix,
16821
16848
  t,
@@ -16893,14 +16920,14 @@ var TypePrimary$6 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)
16893
16920
  var TypePrimary$7 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), TypeLiteral), function($skip, $loc, $0, $1, $2) {
16894
16921
  var t = $2;
16895
16922
  return {
16896
- type: "LiteralType",
16923
+ type: "TypeLiteral",
16897
16924
  t,
16898
16925
  children: $0
16899
16926
  };
16900
16927
  });
16901
16928
  var TypePrimary$8 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), UnknownAlias), function($skip, $loc, $0, $1, $2) {
16902
16929
  return {
16903
- type: "IdentifierType",
16930
+ type: "TypeIdentifier",
16904
16931
  children: $0,
16905
16932
  raw: $2.token,
16906
16933
  args: void 0
@@ -16909,7 +16936,7 @@ var TypePrimary$8 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)
16909
16936
  var TypePrimary$9 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), Identifier, (0, import_lib3.$Q)((0, import_lib3.$S)(Dot, IdentifierName)), (0, import_lib3.$E)((0, import_lib3.$C)(TypeArguments, ImplicitTypeArguments))), function($skip, $loc, $0, $1, $2, $3, $4) {
16910
16937
  var args = $4;
16911
16938
  return {
16912
- type: "IdentifierType",
16939
+ type: "TypeIdentifier",
16913
16940
  children: $0,
16914
16941
  raw: [$2.name, ...$3.map(([dot, id]) => dot.token + id.name)].join(""),
16915
16942
  args
@@ -16919,7 +16946,7 @@ var TypePrimary$10 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E
16919
16946
  if (!$4)
16920
16947
  return $skip;
16921
16948
  return {
16922
- type: "ParenthesizedType",
16949
+ type: "TypeParenthesized",
16923
16950
  children: [$1, $2, $4, $6, $7]
16924
16951
  // omit AllowAll/RestoreAll
16925
16952
  };
@@ -17285,16 +17312,20 @@ function TypeBinaryOp(ctx, state2) {
17285
17312
  }
17286
17313
  var TypeFunction$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)((0, import_lib3.$S)(Abstract, (0, import_lib3.$E)(_))), (0, import_lib3.$E)((0, import_lib3.$S)(New, (0, import_lib3.$E)(_))), Parameters, __, TypeArrowFunction, (0, import_lib3.$E)(ReturnType)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17287
17314
  var type = $6;
17288
- const ret = [...$0];
17315
+ const children = [...$0];
17289
17316
  if ($1 && !$2) {
17290
- ret[1] = {
17317
+ children[1] = {
17291
17318
  type: "Error",
17292
17319
  message: "abstract function types must be constructors (abstract new)"
17293
17320
  };
17294
17321
  }
17295
17322
  if (!type)
17296
- ret.push("void");
17297
- return ret;
17323
+ children.push("void");
17324
+ return {
17325
+ type: "TypeFunction",
17326
+ children,
17327
+ ts: true
17328
+ };
17298
17329
  });
17299
17330
  function TypeFunction(ctx, state2) {
17300
17331
  return (0, import_lib3.$EVENT)(ctx, state2, "TypeFunction", TypeFunction$0);
@@ -17476,17 +17507,22 @@ var CivetPrologueContent$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import
17476
17507
  function CivetPrologueContent(ctx, state2) {
17477
17508
  return (0, import_lib3.$EVENT)(ctx, state2, "CivetPrologueContent", CivetPrologueContent$0);
17478
17509
  }
17479
- var CivetOption$0 = (0, import_lib3.$TR)((0, import_lib3.$EXPECT)($R94, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
17510
+ var CivetOption$0 = (0, import_lib3.$TR)((0, import_lib3.$EXPECT)($R94, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([\\p{ID_Continue}.,+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
17480
17511
  const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
17481
17512
  if (l)
17482
17513
  return l.toUpperCase();
17483
17514
  return "";
17484
17515
  });
17485
17516
  let value = $3 ? $4 : $1 === "-" ? false : true;
17486
- if (optionName === "tab") {
17487
- value = parseFloat(value);
17488
- if (isNaN(value))
17489
- value = 0;
17517
+ switch (optionName) {
17518
+ case "tab":
17519
+ value = parseFloat(value);
17520
+ if (isNaN(value))
17521
+ value = 0;
17522
+ break;
17523
+ case "globals":
17524
+ value = value.split(",").filter(Boolean);
17525
+ break;
17490
17526
  }
17491
17527
  return [optionName, value];
17492
17528
  });
@@ -17839,6 +17875,7 @@ var Reset$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'Reset ""'), fu
17839
17875
  coffeeOf: false,
17840
17876
  coffeePrototype: false,
17841
17877
  defaultElement: "div",
17878
+ globals: [],
17842
17879
  implicitReturns: true,
17843
17880
  jsxCode: false,
17844
17881
  objectIs: false,
package/dist/types.d.ts CHANGED
@@ -20,6 +20,7 @@ declare module "@danielx/civet" {
20
20
  coffeeOf: boolean
21
21
  coffeePrototype: boolean
22
22
  defaultElement: string
23
+ globals: string[]
23
24
  implicitReturns: boolean
24
25
  jsxCode: boolean
25
26
  objectIs: boolean
@@ -57,7 +57,12 @@ var postfixRE = /[?#].*$/s;
57
57
  var isWindows = import_os.default.platform() === "win32";
58
58
  var windowsSlashRE = /\\/g;
59
59
  function cleanCivetId(id) {
60
- return id.replace(postfixRE, "").replace(/\.[jt]sx$/, "");
60
+ let postfix = "";
61
+ id = id.replace(postfixRE, (match) => {
62
+ postfix = match;
63
+ return "";
64
+ }).replace(/\.[jt]sx$/, "");
65
+ return { id, postfix };
61
66
  }
62
67
  function tryStatSync(file) {
63
68
  try {
@@ -357,8 +362,16 @@ var rawPlugin = (options = {}, meta) => {
357
362
  resolveId(id, importer, options2) {
358
363
  if (/\0/.test(id))
359
364
  return null;
360
- id = cleanCivetId(id);
361
- let resolvedId = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
365
+ let postfix;
366
+ ({ id, postfix } = cleanCivetId(id));
367
+ let ref;
368
+ if (import_path.default.isAbsolute(id)) {
369
+ ref = resolveAbsolutePath(rootDir, id, implicitExtension);
370
+ } else {
371
+ ref = import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
372
+ }
373
+ ;
374
+ let resolvedId = ref;
362
375
  if (!resolvedId)
363
376
  return null;
364
377
  if (!resolvedId.endsWith(".civet")) {
@@ -372,7 +385,7 @@ var rawPlugin = (options = {}, meta) => {
372
385
  if (options2.scan && meta.framework === "vite") {
373
386
  resolvedId = `\0${resolvedId}`;
374
387
  }
375
- return resolvedId + outExt;
388
+ return resolvedId + outExt + postfix;
376
389
  },
377
390
  loadInclude(id) {
378
391
  return isCivetTranspiled.test(id);
@@ -25,7 +25,12 @@ var postfixRE = /[?#].*$/s;
25
25
  var isWindows = os.platform() === "win32";
26
26
  var windowsSlashRE = /\\/g;
27
27
  function cleanCivetId(id) {
28
- return id.replace(postfixRE, "").replace(/\.[jt]sx$/, "");
28
+ let postfix = "";
29
+ id = id.replace(postfixRE, (match) => {
30
+ postfix = match;
31
+ return "";
32
+ }).replace(/\.[jt]sx$/, "");
33
+ return { id, postfix };
29
34
  }
30
35
  function tryStatSync(file) {
31
36
  try {
@@ -325,8 +330,16 @@ var rawPlugin = (options = {}, meta) => {
325
330
  resolveId(id, importer, options2) {
326
331
  if (/\0/.test(id))
327
332
  return null;
328
- id = cleanCivetId(id);
329
- let resolvedId = path.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : path.resolve(path.dirname(importer ?? ""), id);
333
+ let postfix;
334
+ ({ id, postfix } = cleanCivetId(id));
335
+ let ref;
336
+ if (path.isAbsolute(id)) {
337
+ ref = resolveAbsolutePath(rootDir, id, implicitExtension);
338
+ } else {
339
+ ref = path.resolve(path.dirname(importer ?? ""), id);
340
+ }
341
+ ;
342
+ let resolvedId = ref;
330
343
  if (!resolvedId)
331
344
  return null;
332
345
  if (!resolvedId.endsWith(".civet")) {
@@ -340,7 +353,7 @@ var rawPlugin = (options = {}, meta) => {
340
353
  if (options2.scan && meta.framework === "vite") {
341
354
  resolvedId = `\0${resolvedId}`;
342
355
  }
343
- return resolvedId + outExt;
356
+ return resolvedId + outExt + postfix;
344
357
  },
345
358
  loadInclude(id) {
346
359
  return isCivetTranspiled.test(id);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.7.33",
4
+ "version": "0.7.34",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",