@danielx/civet 0.7.26 → 0.7.28

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
@@ -531,6 +531,7 @@ ${body}`;
531
531
  expressionizeTypeIf: () => expressionizeTypeIf,
532
532
  forRange: () => forRange,
533
533
  gatherBindingCode: () => gatherBindingCode,
534
+ gatherBindingPatternTypeSuffix: () => gatherBindingPatternTypeSuffix,
534
535
  gatherRecursive: () => gatherRecursive,
535
536
  gatherRecursiveAll: () => gatherRecursiveAll,
536
537
  gatherRecursiveWithinFunction: () => gatherRecursiveWithinFunction,
@@ -1334,7 +1335,7 @@ ${body}`;
1334
1335
 
1335
1336
  // source/parser/binding.civet
1336
1337
  function adjustAtBindings(statements, asThis = false) {
1337
- gatherRecursiveAll(statements, (n) => n.type === "AtBindingProperty").forEach((binding) => {
1338
+ gatherRecursiveAll(statements, ($) => $.type === "AtBindingProperty").forEach((binding) => {
1338
1339
  const { ref } = binding;
1339
1340
  if (asThis) {
1340
1341
  const atBinding = binding.binding;
@@ -1353,17 +1354,19 @@ ${body}`;
1353
1354
  });
1354
1355
  }
1355
1356
  function adjustBindingElements(elements) {
1356
- const names = elements.flatMap((p) => p.names || []), { length } = elements;
1357
+ const names = elements.flatMap(($1) => $1.names || []);
1358
+ const { length } = elements;
1357
1359
  let blockPrefix, restIndex = -1, restCount = 0;
1358
- elements.forEach(({ type }, i) => {
1360
+ for (let i1 = 0, len3 = elements.length; i1 < len3; i1++) {
1361
+ const i = i1;
1362
+ const { type } = elements[i1];
1359
1363
  if (type === "BindingRestElement") {
1360
- if (restIndex < 0)
1364
+ if (restIndex < 0) {
1361
1365
  restIndex = i;
1362
- return restCount++;
1366
+ }
1367
+ restCount++;
1363
1368
  }
1364
- ;
1365
- return;
1366
- });
1369
+ }
1367
1370
  if (restCount === 0) {
1368
1371
  return {
1369
1372
  children: elements,
@@ -1382,7 +1385,7 @@ ${body}`;
1382
1385
  l++;
1383
1386
  blockPrefix = {
1384
1387
  type: "PostRestBindingElements",
1385
- children: ["[", insertTrimmingSpace(after, ""), "] = ", restIdentifier, ".splice(-", l.toString(), ")"],
1388
+ children: ["[", trimFirstSpace(after), "] = ", restIdentifier, ".splice(-", l.toString(), ")"],
1386
1389
  names: after.flatMap((p) => p.names)
1387
1390
  };
1388
1391
  }
@@ -1442,6 +1445,100 @@ ${body}`;
1442
1445
  const lastChild = (ref1 = elementNode.children)[ref1.length - 1];
1443
1446
  return lastChild && lastChild[lastChild.length - 1]?.token === ",";
1444
1447
  }
1448
+ function gatherBindingPatternTypeSuffix(pattern) {
1449
+ if (pattern.typeSuffix != null) {
1450
+ return pattern;
1451
+ }
1452
+ let count = 0;
1453
+ switch (pattern.type) {
1454
+ case "ArrayBindingPattern": {
1455
+ const results = [];
1456
+ for (let ref2 = pattern.elements, i2 = 0, len1 = ref2.length; i2 < len1; i2++) {
1457
+ const elem = ref2[i2];
1458
+ let { typeSuffix } = elem;
1459
+ typeSuffix ??= elem.binding?.typeSuffix;
1460
+ if (typeSuffix) {
1461
+ count++;
1462
+ }
1463
+ let typeElement = [typeSuffix?.t, elem.delim];
1464
+ if (typeSuffix?.optional) {
1465
+ typeElement[0] = parenthesizeType(typeElement[0]);
1466
+ typeElement.unshift("undefined |");
1467
+ }
1468
+ if (elem.type === "BindingRestElement") {
1469
+ typeElement[0] ??= "unknown[]";
1470
+ typeElement.unshift(elem.dots);
1471
+ } else {
1472
+ typeElement[0] ??= "unknown";
1473
+ }
1474
+ results.push(typeElement);
1475
+ }
1476
+ ;
1477
+ const types = results;
1478
+ if (count) {
1479
+ const t = [": [", types, "]"];
1480
+ pattern.typeSuffix = {
1481
+ type: "TypeSuffix",
1482
+ ts: true,
1483
+ t,
1484
+ children: [t]
1485
+ };
1486
+ }
1487
+ ;
1488
+ break;
1489
+ }
1490
+ case "ObjectBindingPattern": {
1491
+ let restType;
1492
+ const results1 = [];
1493
+ for (let ref3 = pattern.properties, i3 = 0, len22 = ref3.length; i3 < len22; i3++) {
1494
+ const prop = ref3[i3];
1495
+ let { typeSuffix } = prop;
1496
+ typeSuffix ??= prop.value?.typeSuffix;
1497
+ if (typeSuffix) {
1498
+ count++;
1499
+ }
1500
+ typeSuffix ??= {
1501
+ type: "TypeSuffix",
1502
+ ts: true,
1503
+ children: [": unknown"]
1504
+ };
1505
+ switch (prop.type) {
1506
+ case "BindingProperty": {
1507
+ const ws = prop.children.slice(0, prop.children.indexOf(prop.name));
1508
+ results1.push([...ws, prop.name, typeSuffix, prop.delim]);
1509
+ break;
1510
+ }
1511
+ case "AtBindingProperty": {
1512
+ const ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
1513
+ results1.push([...ws, prop.ref.id, typeSuffix, prop.delim]);
1514
+ break;
1515
+ }
1516
+ case "BindingRestProperty": {
1517
+ restType = prop.typeSuffix?.t;
1518
+ continue;
1519
+ }
1520
+ }
1521
+ }
1522
+ ;
1523
+ const types = results1;
1524
+ if (count) {
1525
+ const t = ["{", types, "}"];
1526
+ if (restType != null) {
1527
+ t.push(" & ", parenthesizeType(trimFirstSpace(restType)));
1528
+ }
1529
+ pattern.typeSuffix = {
1530
+ type: "TypeSuffix",
1531
+ ts: true,
1532
+ t,
1533
+ children: [": ", t]
1534
+ };
1535
+ }
1536
+ ;
1537
+ break;
1538
+ }
1539
+ }
1540
+ return pattern;
1541
+ }
1445
1542
 
1446
1543
  // source/parser/function.civet
1447
1544
  function isVoidType(t) {
@@ -2961,12 +3058,14 @@ ${body}`;
2961
3058
  });
2962
3059
  const { blockPrefix } = pattern;
2963
3060
  if (blockPrefix) {
2964
- const postElements = blockPrefix.children[1], { length: postLength } = postElements;
3061
+ const postElements = blockPrefix.children[1];
3062
+ const { length: postLength } = postElements;
2965
3063
  postElements.forEach(({ children: [, e] }, i) => {
2966
3064
  const subRef = [ref, "[", ref, ".length - ", (postLength + i).toString(), "]"];
2967
3065
  return getPatternConditions(e, subRef, conditions);
2968
3066
  });
2969
3067
  }
3068
+ ;
2970
3069
  break;
2971
3070
  }
2972
3071
  case "ObjectBindingPattern": {
@@ -2974,34 +3073,46 @@ ${body}`;
2974
3073
  ["typeof ", ref, " === 'object'"],
2975
3074
  [ref, " != null"]
2976
3075
  );
2977
- pattern.properties.forEach((p) => {
3076
+ for (let ref1 = pattern.properties, i4 = 0, len3 = ref1.length; i4 < len3; i4++) {
3077
+ const p = ref1[i4];
2978
3078
  switch (p.type) {
2979
3079
  case "PinProperty":
2980
3080
  case "BindingProperty": {
2981
3081
  const { name, value } = p;
2982
3082
  let subRef;
2983
3083
  switch (name.type) {
2984
- case "ComputedPropertyName":
3084
+ case "ComputedPropertyName": {
2985
3085
  conditions.push([name.expression, " in ", ref]);
2986
3086
  subRef = [ref, name];
2987
3087
  break;
3088
+ }
2988
3089
  case "Literal":
2989
3090
  case "StringLiteral":
2990
- case "NumericLiteral":
3091
+ case "NumericLiteral": {
2991
3092
  conditions.push([name, " in ", ref]);
2992
3093
  subRef = [ref, "[", name, "]"];
2993
3094
  break;
2994
- default:
2995
- conditions.push(["'", name, "' in ", ref]);
2996
- subRef = [ref, ".", name];
3095
+ }
3096
+ case "Identifier": {
3097
+ conditions.push(["'", name.name, "' in ", ref]);
3098
+ subRef = [ref, ".", name.name];
3099
+ break;
3100
+ }
3101
+ case "AtBinding": {
3102
+ conditions.push(["'", name.ref.id, "' in ", ref]);
3103
+ subRef = [ref, ".", name.ref.id];
3104
+ break;
3105
+ }
2997
3106
  }
2998
3107
  if (value) {
2999
3108
  getPatternConditions(value, subRef, conditions);
3000
3109
  }
3110
+ ;
3001
3111
  break;
3002
3112
  }
3003
3113
  }
3004
- });
3114
+ }
3115
+ ;
3005
3116
  break;
3006
3117
  }
3007
3118
  case "ConditionFragment": {
@@ -3025,22 +3136,22 @@ ${body}`;
3025
3136
  );
3026
3137
  break;
3027
3138
  }
3028
- case "PinPattern":
3139
+ case "PinPattern": {
3029
3140
  conditions.push([
3030
3141
  ref,
3031
3142
  " === ",
3032
3143
  pattern.expression
3033
3144
  ]);
3034
3145
  break;
3035
- case "Literal":
3146
+ }
3147
+ case "Literal": {
3036
3148
  conditions.push([
3037
3149
  ref,
3038
3150
  " === ",
3039
3151
  pattern
3040
3152
  ]);
3041
3153
  break;
3042
- default:
3043
- break;
3154
+ }
3044
3155
  }
3045
3156
  return conditions;
3046
3157
  }
@@ -3271,6 +3382,9 @@ ${body}`;
3271
3382
  let [splices, assignments] = gatherBindingCode(pattern);
3272
3383
  splices = splices.map((s) => [", ", s]);
3273
3384
  const thisAssignments = assignments.map((a) => ["", a, ";"]);
3385
+ if ("typeSuffix" in pattern) {
3386
+ suffix ??= pattern.typeSuffix;
3387
+ }
3274
3388
  const initializer = makeNode({
3275
3389
  type: "Initializer",
3276
3390
  expression: e,
@@ -6556,6 +6670,7 @@ ${js}`
6556
6670
  NestedBindingPropertyList,
6557
6671
  BindingProperty,
6558
6672
  BindingRestProperty,
6673
+ BindingTypeSuffix,
6559
6674
  NestedBindingElements,
6560
6675
  BindingElement,
6561
6676
  BindingRestElement,
@@ -6893,6 +7008,7 @@ ${js}`
6893
7008
  DotDot,
6894
7009
  DotDotDot,
6895
7010
  DoubleColon,
7011
+ DoubleColonAsColon,
6896
7012
  DoubleQuote,
6897
7013
  Each,
6898
7014
  Else,
@@ -6996,17 +7112,24 @@ ${js}`
6996
7112
  InlineJSXMemberExpressionRest,
6997
7113
  InlineJSXPrimaryExpression,
6998
7114
  JSXMixedChildren,
7115
+ JSXSameLineChildren,
6999
7116
  JSXChildren,
7000
7117
  JSXNestedChildren,
7001
7118
  JSXEOS,
7002
7119
  JSXNested,
7003
7120
  JSXChild,
7121
+ JSXChildForcedCode,
7122
+ JSXChildForcedNoCode,
7123
+ JSXChildGeneral,
7004
7124
  JSXComment,
7005
7125
  JSXCommentContent,
7006
7126
  JSXText,
7007
7127
  JSXChildExpression,
7008
7128
  IndentedJSXChildExpression,
7009
7129
  NestedJSXChildExpression,
7130
+ JSXAngleChild,
7131
+ JSXCodeChild,
7132
+ JSXCodeChildExpression,
7010
7133
  UsingDeclaration,
7011
7134
  UsingBinding,
7012
7135
  UsingJSModeError,
@@ -7139,6 +7262,8 @@ ${js}`
7139
7262
  CoffeeNotEnabled,
7140
7263
  CoffeeOfEnabled,
7141
7264
  CoffeePrototypeEnabled,
7265
+ JSXCodeNestedEnabled,
7266
+ JSXCodeSameLineEnabled,
7142
7267
  ObjectIsEnabled,
7143
7268
  Reset,
7144
7269
  Init,
@@ -7399,7 +7524,7 @@ ${js}`
7399
7524
  var $R3 = (0, import_lib3.$R)(new RegExp("[0-9]", "suy"));
7400
7525
  var $R4 = (0, import_lib3.$R)(new RegExp("(?!\\p{ID_Start}|[_$0-9(\\[{])", "suy"));
7401
7526
  var $R5 = (0, import_lib3.$R)(new RegExp("[ \\t]", "suy"));
7402
- var $R6 = (0, import_lib3.$R)(new RegExp("\\p{ID_Continue}|[\\u200C\\u200D$.#]", "suy"));
7527
+ var $R6 = (0, import_lib3.$R)(new RegExp("\\p{ID_Continue}|[\\u200C\\u200D$.#{]", "suy"));
7403
7528
  var $R7 = (0, import_lib3.$R)(new RegExp("[&=]", "suy"));
7404
7529
  var $R8 = (0, import_lib3.$R)(new RegExp("(?=['\"`])", "suy"));
7405
7530
  var $R9 = (0, import_lib3.$R)(new RegExp("(?=[\\/?])", "suy"));
@@ -8385,7 +8510,7 @@ ${js}`
8385
8510
  function ParenthesizedExpression(ctx, state2) {
8386
8511
  return (0, import_lib3.$EVENT)(ctx, state2, "ParenthesizedExpression", ParenthesizedExpression$0);
8387
8512
  }
8388
- var Placeholder$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Dot, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R6, "Placeholder /\\p{ID_Continue}|[\\u200C\\u200D$.#]/")), (0, import_lib3.$E)(PlaceholderTypeSuffix)), function($skip, $loc, $0, $1, $2, $3) {
8513
+ var Placeholder$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Dot, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R6, "Placeholder /\\p{ID_Continue}|[\\u200C\\u200D$.#{]/")), (0, import_lib3.$E)(PlaceholderTypeSuffix)), function($skip, $loc, $0, $1, $2, $3) {
8389
8514
  var dot = $1;
8390
8515
  var typeSuffix = $3;
8391
8516
  return {
@@ -8405,7 +8530,7 @@ ${js}`
8405
8530
  children: [amp]
8406
8531
  };
8407
8532
  });
8408
- var Placeholder$2 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$Y)(ExplicitAccessStart), (0, import_lib3.$Y)(PropertyAccess), (0, import_lib3.$N)(NumericLiteral)), function($skip, $loc, $0, $1, $2, $3) {
8533
+ var Placeholder$2 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$Y)(ExplicitAccessStart), (0, import_lib3.$Y)((0, import_lib3.$C)(PropertyAccess, PropertyGlob)), (0, import_lib3.$N)(NumericLiteral)), function($skip, $loc, $0, $1, $2, $3) {
8409
8534
  return {
8410
8535
  type: "Placeholder",
8411
8536
  subtype: "&",
@@ -9474,9 +9599,10 @@ ${js}`
9474
9599
  var typeSuffix = $5;
9475
9600
  var initializer = $6;
9476
9601
  var delim = $7;
9602
+ typeSuffix ??= binding.typeSuffix;
9477
9603
  return {
9478
9604
  type: "Parameter",
9479
- children: $0,
9605
+ children: [$1, accessModifier, $3, binding, typeSuffix, initializer, delim],
9480
9606
  names: binding.names,
9481
9607
  typeSuffix,
9482
9608
  accessModifier,
@@ -9592,12 +9718,13 @@ ${js}`
9592
9718
  var c = $3;
9593
9719
  var ws2 = $4;
9594
9720
  var close = $5;
9595
- return {
9721
+ const properties = c.children;
9722
+ return gatherBindingPatternTypeSuffix({
9596
9723
  type: "ObjectBindingPattern",
9597
- children: [ws1, open, c.children, ws2, close],
9724
+ children: [ws1, open, properties, ws2, close],
9598
9725
  names: c.names,
9599
- properties: c.children
9600
- };
9726
+ properties
9727
+ });
9601
9728
  });
9602
9729
  function ObjectBindingPattern(ctx, state2) {
9603
9730
  return (0, import_lib3.$EVENT)(ctx, state2, "ObjectBindingPattern", ObjectBindingPattern$0);
@@ -9632,13 +9759,13 @@ ${js}`
9632
9759
  var c = $3;
9633
9760
  var ws2 = $4;
9634
9761
  var close = $5;
9635
- return {
9762
+ return gatherBindingPatternTypeSuffix({
9636
9763
  ...c,
9637
9764
  // names, blockPrefix, length
9638
9765
  type: "ArrayBindingPattern",
9639
9766
  elements: c.children,
9640
9767
  children: [ws1, open, c.children, ws2, close]
9641
- };
9768
+ });
9642
9769
  });
9643
9770
  function ArrayBindingPattern(ctx, state2) {
9644
9771
  return (0, import_lib3.$EVENT)(ctx, state2, "ArrayBindingPattern", ArrayBindingPattern$0);
@@ -9659,6 +9786,7 @@ ${js}`
9659
9786
  return elements.map(([element, delim]) => {
9660
9787
  return {
9661
9788
  ...element,
9789
+ delim,
9662
9790
  // BindingElement.children is a tuple of the form [ws, element]
9663
9791
  children: [...element.children, delim]
9664
9792
  };
@@ -9709,38 +9837,57 @@ ${js}`
9709
9837
  return (0, import_lib3.$EVENT)(ctx, state2, "NestedBindingPropertyList", NestedBindingPropertyList$0);
9710
9838
  }
9711
9839
  var BindingProperty$0 = BindingRestProperty;
9712
- var BindingProperty$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), PropertyName, (0, import_lib3.$E)(_), Colon, (0, import_lib3.$E)(_), (0, import_lib3.$C)(BindingIdentifier, BindingPattern), (0, import_lib3.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
9840
+ var BindingProperty$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), PropertyName, (0, import_lib3.$E)(_), Colon, (0, import_lib3.$E)(_), (0, import_lib3.$C)(BindingIdentifier, BindingPattern), (0, import_lib3.$E)(BindingTypeSuffix), (0, import_lib3.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
9713
9841
  var name = $2;
9714
9842
  var value = $6;
9715
- var initializer = $7;
9843
+ var typeSuffix = $7;
9844
+ var initializer = $8;
9716
9845
  return {
9717
9846
  type: "BindingProperty",
9718
- children: $0,
9847
+ children: [$1, name, $3, $4, $5, value, initializer],
9848
+ // omit typeSuffix
9719
9849
  name,
9720
9850
  value,
9851
+ typeSuffix,
9721
9852
  initializer,
9722
9853
  names: value.names
9723
9854
  };
9724
9855
  });
9725
- var BindingProperty$2 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), (0, import_lib3.$E)(Caret), BindingIdentifier, (0, import_lib3.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4) {
9856
+ var BindingProperty$2 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), (0, import_lib3.$E)(Caret), BindingIdentifier, (0, import_lib3.$E)(BindingTypeSuffix), (0, import_lib3.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
9726
9857
  var ws = $1;
9727
9858
  var pin = $2;
9728
9859
  var binding = $3;
9729
- var initializer = $4;
9860
+ var typeSuffix = $4;
9861
+ var initializer = $5;
9862
+ let children = [ws, binding, initializer];
9730
9863
  if (binding.type === "AtBinding") {
9731
9864
  return {
9732
9865
  type: "AtBindingProperty",
9733
- children: $0,
9866
+ children,
9734
9867
  binding,
9868
+ typeSuffix,
9735
9869
  ref: binding.ref,
9736
9870
  initializer,
9737
9871
  names: []
9738
9872
  };
9739
9873
  }
9740
9874
  if (pin) {
9875
+ children = [ws, binding];
9876
+ if (typeSuffix) {
9877
+ children.push({
9878
+ type: "Error",
9879
+ message: "Pinned properties cannot have type annotations"
9880
+ });
9881
+ }
9882
+ if (initializer) {
9883
+ children.push({
9884
+ type: "Error",
9885
+ message: "Pinned properties cannot have initializers"
9886
+ });
9887
+ }
9741
9888
  return {
9742
9889
  type: "PinProperty",
9743
- children: [ws, binding],
9890
+ children,
9744
9891
  name: binding,
9745
9892
  value: {
9746
9893
  type: "PinPattern",
@@ -9750,9 +9897,10 @@ ${js}`
9750
9897
  }
9751
9898
  return {
9752
9899
  type: "BindingProperty",
9753
- children: $0,
9900
+ children,
9754
9901
  name: binding,
9755
9902
  value: void 0,
9903
+ typeSuffix,
9756
9904
  initializer,
9757
9905
  names: binding.names,
9758
9906
  identifier: binding
@@ -9762,13 +9910,15 @@ ${js}`
9762
9910
  function BindingProperty(ctx, state2) {
9763
9911
  return (0, import_lib3.$EVENT_C)(ctx, state2, "BindingProperty", BindingProperty$$);
9764
9912
  }
9765
- var BindingRestProperty$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), DotDotDot, BindingIdentifier), function($skip, $loc, $0, $1, $2, $3) {
9913
+ var BindingRestProperty$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), DotDotDot, BindingIdentifier, (0, import_lib3.$E)(BindingTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4) {
9766
9914
  var ws = $1;
9767
9915
  var dots = $2;
9768
9916
  var id = $3;
9917
+ var typeSuffix = $4;
9769
9918
  return {
9770
9919
  ...id,
9771
9920
  type: "BindingRestProperty",
9921
+ typeSuffix,
9772
9922
  children: [...ws || [], dots, ...id.children]
9773
9923
  };
9774
9924
  });
@@ -9779,6 +9929,7 @@ ${js}`
9779
9929
  return {
9780
9930
  ...id,
9781
9931
  type: "BindingRestProperty",
9932
+ typeSuffix: void 0,
9782
9933
  children: [...ws || [], dots, ...id.children]
9783
9934
  };
9784
9935
  });
@@ -9786,6 +9937,21 @@ ${js}`
9786
9937
  function BindingRestProperty(ctx, state2) {
9787
9938
  return (0, import_lib3.$EVENT_C)(ctx, state2, "BindingRestProperty", BindingRestProperty$$);
9788
9939
  }
9940
+ var BindingTypeSuffix$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), (0, import_lib3.$E)(QuestionMark), (0, import_lib3.$E)(_), DoubleColonAsColon, MaybeNestedType), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
9941
+ var optional = $2;
9942
+ var colon = $4;
9943
+ var t = $5;
9944
+ return {
9945
+ type: "TypeSuffix",
9946
+ ts: true,
9947
+ optional,
9948
+ t,
9949
+ children: $0
9950
+ };
9951
+ });
9952
+ function BindingTypeSuffix(ctx, state2) {
9953
+ return (0, import_lib3.$EVENT)(ctx, state2, "BindingTypeSuffix", BindingTypeSuffix$0);
9954
+ }
9789
9955
  var NestedBindingElements$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(PushIndent, (0, import_lib3.$Q)(NestedBindingElementList), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
9790
9956
  var elements = $2;
9791
9957
  if (!elements.length)
@@ -9796,10 +9962,11 @@ ${js}`
9796
9962
  return (0, import_lib3.$EVENT)(ctx, state2, "NestedBindingElements", NestedBindingElements$0);
9797
9963
  }
9798
9964
  var BindingElement$0 = BindingRestElement;
9799
- var BindingElement$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), (0, import_lib3.$C)(BindingIdentifier, BindingPattern), (0, import_lib3.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3) {
9965
+ var BindingElement$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), (0, import_lib3.$C)(BindingIdentifier, BindingPattern), (0, import_lib3.$E)(BindingTypeSuffix), (0, import_lib3.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4) {
9800
9966
  var ws = $1;
9801
9967
  var binding = $2;
9802
- var initializer = $3;
9968
+ var typeSuffix = $3;
9969
+ var initializer = $4;
9803
9970
  if (binding.children) {
9804
9971
  binding = {
9805
9972
  ...binding,
@@ -9808,16 +9975,17 @@ ${js}`
9808
9975
  };
9809
9976
  }
9810
9977
  return {
9978
+ type: "BindingElement",
9811
9979
  names: binding.names,
9980
+ typeSuffix,
9981
+ binding,
9812
9982
  children: [ws, binding]
9813
9983
  };
9814
9984
  });
9815
9985
  var BindingElement$2 = (0, import_lib3.$TV)((0, import_lib3.$Y)((0, import_lib3.$S)((0, import_lib3.$E)(_), (0, import_lib3.$EXPECT)($L17, 'BindingElement ","'))), function($skip, $loc, $0, $1) {
9816
9986
  return {
9817
- children: [{
9818
- type: "ElisionElement",
9819
- children: [""]
9820
- }],
9987
+ type: "ElisionElement",
9988
+ children: [""],
9821
9989
  names: []
9822
9990
  };
9823
9991
  });
@@ -9825,14 +9993,17 @@ ${js}`
9825
9993
  function BindingElement(ctx, state2) {
9826
9994
  return (0, import_lib3.$EVENT_C)(ctx, state2, "BindingElement", BindingElement$$);
9827
9995
  }
9828
- var BindingRestElement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), DotDotDot, (0, import_lib3.$C)(BindingIdentifier, BindingPattern, EmptyBindingPattern)), function($skip, $loc, $0, $1, $2, $3) {
9996
+ var BindingRestElement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), DotDotDot, (0, import_lib3.$C)(BindingIdentifier, BindingPattern, EmptyBindingPattern), (0, import_lib3.$E)(BindingTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4) {
9829
9997
  var ws = $1;
9830
9998
  var dots = $2;
9831
9999
  var binding = $3;
10000
+ var typeSuffix = $4;
9832
10001
  return {
9833
10002
  type: "BindingRestElement",
9834
10003
  children: [ws, [dots, binding]],
10004
+ dots,
9835
10005
  binding,
10006
+ typeSuffix,
9836
10007
  name: binding.name,
9837
10008
  names: binding.names,
9838
10009
  rest: true
@@ -9845,6 +10016,7 @@ ${js}`
9845
10016
  return {
9846
10017
  type: "BindingRestElement",
9847
10018
  children: [...ws || [], dots, binding],
10019
+ dots,
9848
10020
  binding,
9849
10021
  name: binding.name,
9850
10022
  names: binding.names,
@@ -13939,9 +14111,10 @@ ${js}`
13939
14111
  var suffix = $2;
13940
14112
  var initializer = $3;
13941
14113
  const [splices, thisAssignments] = gatherBindingCode(pattern);
14114
+ suffix ??= pattern.typeSuffix;
13942
14115
  return {
13943
14116
  type: "Binding",
13944
- children: $0,
14117
+ children: [pattern, suffix, initializer],
13945
14118
  names: pattern.names,
13946
14119
  pattern,
13947
14120
  suffix,
@@ -14661,6 +14834,12 @@ ${js}`
14661
14834
  function DoubleColon(ctx, state2) {
14662
14835
  return (0, import_lib3.$EVENT)(ctx, state2, "DoubleColon", DoubleColon$0);
14663
14836
  }
14837
+ var DoubleColonAsColon$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L155, 'DoubleColonAsColon "::"'), function($skip, $loc, $0, $1) {
14838
+ return { $loc, token: ":" };
14839
+ });
14840
+ function DoubleColonAsColon(ctx, state2) {
14841
+ return (0, import_lib3.$EVENT)(ctx, state2, "DoubleColonAsColon", DoubleColonAsColon$0);
14842
+ }
14664
14843
  var DoubleQuote$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L156, 'DoubleQuote "\\\\\\""'), function($skip, $loc, $0, $1) {
14665
14844
  return { $loc, token: $1 };
14666
14845
  });
@@ -15461,9 +15640,22 @@ ${js}`
15461
15640
  function JSXAttributeName(ctx, state2) {
15462
15641
  return (0, import_lib3.$EVENT_C)(ctx, state2, "JSXAttributeName", JSXAttributeName$$);
15463
15642
  }
15464
- var JSXAttributeInitializer$0 = (0, import_lib3.$S)((0, import_lib3.$E)(Whitespace), Equals, (0, import_lib3.$E)(Whitespace), JSXAttributeValue);
15643
+ var JSXAttributeInitializer$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$N)(CoffeeJSXEnabled), (0, import_lib3.$E)(Whitespace), Equals, (0, import_lib3.$Y)((0, import_lib3.$S)((0, import_lib3.$Q)(NonNewlineWhitespace), EOL)), InsertInlineOpenBrace, PushIndent, (0, import_lib3.$E)(PostfixedExpression), PopIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
15644
+ var ws1 = $2;
15645
+ var equals = $3;
15646
+ var ws2 = $4;
15647
+ var open = $5;
15648
+ var indent = $6;
15649
+ var expression = $7;
15650
+ var close = $9;
15651
+ if (!expression)
15652
+ return $skip;
15653
+ return [ws1, equals, ws2, open, indent, expression, close];
15654
+ });
15655
+ var JSXAttributeInitializer$1 = (0, import_lib3.$S)((0, import_lib3.$E)(Whitespace), Equals, (0, import_lib3.$E)(Whitespace), JSXAttributeValue);
15656
+ var JSXAttributeInitializer$$ = [JSXAttributeInitializer$0, JSXAttributeInitializer$1];
15465
15657
  function JSXAttributeInitializer(ctx, state2) {
15466
- return (0, import_lib3.$EVENT)(ctx, state2, "JSXAttributeInitializer", JSXAttributeInitializer$0);
15658
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "JSXAttributeInitializer", JSXAttributeInitializer$$);
15467
15659
  }
15468
15660
  var JSXAttributeValue$0 = (0, import_lib3.$S)(OpenBrace, PostfixedExpression, (0, import_lib3.$E)(Whitespace), CloseBrace);
15469
15661
  var JSXAttributeValue$1 = JSXElement;
@@ -15633,7 +15825,7 @@ ${js}`
15633
15825
  function InlineJSXPrimaryExpression(ctx, state2) {
15634
15826
  return (0, import_lib3.$EVENT_C)(ctx, state2, "InlineJSXPrimaryExpression", InlineJSXPrimaryExpression$$);
15635
15827
  }
15636
- var JSXMixedChildren$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$Q)(JSXChild), JSXNestedChildren), function($skip, $loc, $0, $1, $2) {
15828
+ var JSXMixedChildren$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(JSXSameLineChildren, JSXNestedChildren), function($skip, $loc, $0, $1, $2) {
15637
15829
  var c1 = $1;
15638
15830
  var c2 = $2;
15639
15831
  return {
@@ -15644,6 +15836,18 @@ ${js}`
15644
15836
  function JSXMixedChildren(ctx, state2) {
15645
15837
  return (0, import_lib3.$EVENT)(ctx, state2, "JSXMixedChildren", JSXMixedChildren$0);
15646
15838
  }
15839
+ var JSXSameLineChildren$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(JSXCodeSameLineEnabled, (0, import_lib3.$Q)((0, import_lib3.$S)((0, import_lib3.$E)(NonNewlineWhitespace), (0, import_lib3.$N)(EOL), JSXChildForcedCode))), function($skip, $loc, $0, $1, $2) {
15840
+ var children = $2;
15841
+ return children.map(([, , c]) => c);
15842
+ });
15843
+ var JSXSameLineChildren$1 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$N)(JSXCodeSameLineEnabled), (0, import_lib3.$Q)(JSXChildForcedNoCode)), function(value) {
15844
+ var children = value[1];
15845
+ return children;
15846
+ });
15847
+ var JSXSameLineChildren$$ = [JSXSameLineChildren$0, JSXSameLineChildren$1];
15848
+ function JSXSameLineChildren(ctx, state2) {
15849
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "JSXSameLineChildren", JSXSameLineChildren$$);
15850
+ }
15647
15851
  var JSXChildren$0 = (0, import_lib3.$TV)((0, import_lib3.$Q)((0, import_lib3.$S)((0, import_lib3.$Q)((0, import_lib3.$S)((0, import_lib3.$E)(NonNewlineWhitespace), EOL, (0, import_lib3.$E)(NonNewlineWhitespace))), JSXChild)), function($skip, $loc, $0, $1) {
15648
15852
  return {
15649
15853
  children: $1,
@@ -15685,10 +15889,33 @@ ${js}`
15685
15889
  function JSXNested(ctx, state2) {
15686
15890
  return (0, import_lib3.$EVENT)(ctx, state2, "JSXNested", JSXNested$0);
15687
15891
  }
15688
- var JSXChild$0 = JSXElement;
15689
- var JSXChild$1 = JSXFragment;
15690
- var JSXChild$2 = JSXComment;
15691
- var JSXChild$3 = (0, import_lib3.$TS)((0, import_lib3.$S)(OpenBrace, IndentedJSXChildExpression, __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
15892
+ var JSXChild$0 = JSXChildGeneral;
15893
+ var JSXChild$1 = (0, import_lib3.$T)((0, import_lib3.$S)(JSXCodeNestedEnabled, JSXCodeChild), function(value) {
15894
+ return value[1];
15895
+ });
15896
+ var JSXChild$2 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$N)(JSXCodeNestedEnabled), JSXText), function(value) {
15897
+ return value[1];
15898
+ });
15899
+ var JSXChild$$ = [JSXChild$0, JSXChild$1, JSXChild$2];
15900
+ function JSXChild(ctx, state2) {
15901
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "JSXChild", JSXChild$$);
15902
+ }
15903
+ var JSXChildForcedCode$0 = JSXChildGeneral;
15904
+ var JSXChildForcedCode$1 = JSXCodeChild;
15905
+ var JSXChildForcedCode$$ = [JSXChildForcedCode$0, JSXChildForcedCode$1];
15906
+ function JSXChildForcedCode(ctx, state2) {
15907
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "JSXChildForcedCode", JSXChildForcedCode$$);
15908
+ }
15909
+ var JSXChildForcedNoCode$0 = JSXChildGeneral;
15910
+ var JSXChildForcedNoCode$1 = JSXText;
15911
+ var JSXChildForcedNoCode$$ = [JSXChildForcedNoCode$0, JSXChildForcedNoCode$1];
15912
+ function JSXChildForcedNoCode(ctx, state2) {
15913
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "JSXChildForcedNoCode", JSXChildForcedNoCode$$);
15914
+ }
15915
+ var JSXChildGeneral$0 = JSXElement;
15916
+ var JSXChildGeneral$1 = JSXFragment;
15917
+ var JSXChildGeneral$2 = JSXComment;
15918
+ var JSXChildGeneral$3 = (0, import_lib3.$TS)((0, import_lib3.$S)(OpenBrace, IndentedJSXChildExpression, __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
15692
15919
  var expression = $2;
15693
15920
  return {
15694
15921
  type: "JSXChildExpression",
@@ -15696,7 +15923,7 @@ ${js}`
15696
15923
  expression
15697
15924
  };
15698
15925
  });
15699
- var JSXChild$4 = (0, import_lib3.$TS)((0, import_lib3.$S)(OpenBrace, (0, import_lib3.$E)(JSXChildExpression), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
15926
+ var JSXChildGeneral$4 = (0, import_lib3.$TS)((0, import_lib3.$S)(OpenBrace, (0, import_lib3.$E)(JSXChildExpression), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
15700
15927
  var expression = $2;
15701
15928
  return {
15702
15929
  type: "JSXChildExpression",
@@ -15704,7 +15931,7 @@ ${js}`
15704
15931
  expression
15705
15932
  };
15706
15933
  });
15707
- var JSXChild$5 = (0, import_lib3.$TS)((0, import_lib3.$S)(InsertInlineOpenBrace, ArrowFunction, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
15934
+ var JSXChildGeneral$5 = (0, import_lib3.$TS)((0, import_lib3.$S)(InsertInlineOpenBrace, ArrowFunction, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
15708
15935
  var expression = $2;
15709
15936
  return {
15710
15937
  type: "JSXChildExpression",
@@ -15712,10 +15939,10 @@ ${js}`
15712
15939
  expression
15713
15940
  };
15714
15941
  });
15715
- var JSXChild$6 = JSXText;
15716
- var JSXChild$$ = [JSXChild$0, JSXChild$1, JSXChild$2, JSXChild$3, JSXChild$4, JSXChild$5, JSXChild$6];
15717
- function JSXChild(ctx, state2) {
15718
- return (0, import_lib3.$EVENT_C)(ctx, state2, "JSXChild", JSXChild$$);
15942
+ var JSXChildGeneral$6 = JSXAngleChild;
15943
+ var JSXChildGeneral$$ = [JSXChildGeneral$0, JSXChildGeneral$1, JSXChildGeneral$2, JSXChildGeneral$3, JSXChildGeneral$4, JSXChildGeneral$5, JSXChildGeneral$6];
15944
+ function JSXChildGeneral(ctx, state2) {
15945
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "JSXChildGeneral", JSXChildGeneral$$);
15719
15946
  }
15720
15947
  var JSXComment$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$EXPECT)($L224, 'JSXComment "<!--"'), JSXCommentContent, (0, import_lib3.$EXPECT)($L225, 'JSXComment "-->"')), function($skip, $loc, $0, $1, $2, $3) {
15721
15948
  return ["{/*", $2, "*/}"];
@@ -15755,6 +15982,48 @@ ${js}`
15755
15982
  function NestedJSXChildExpression(ctx, state2) {
15756
15983
  return (0, import_lib3.$EVENT)(ctx, state2, "NestedJSXChildExpression", NestedJSXChildExpression$0);
15757
15984
  }
15985
+ var JSXAngleChild$0 = (0, import_lib3.$T)((0, import_lib3.$S)(CloseAngleBracket, JSXCodeChild), function(value) {
15986
+ return value[1];
15987
+ });
15988
+ function JSXAngleChild(ctx, state2) {
15989
+ return (0, import_lib3.$EVENT)(ctx, state2, "JSXAngleChild", JSXAngleChild$0);
15990
+ }
15991
+ var JSXCodeChild$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(InsertInlineOpenBrace, JSXCodeChildExpression, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
15992
+ var open = $1;
15993
+ var expression = $2;
15994
+ var close = $3;
15995
+ if (!expression)
15996
+ return $skip;
15997
+ return [open, expression, close];
15998
+ });
15999
+ function JSXCodeChild(ctx, state2) {
16000
+ return (0, import_lib3.$EVENT)(ctx, state2, "JSXCodeChild", JSXCodeChild$0);
16001
+ }
16002
+ var JSXCodeChildExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$N)(JSXEOS), ForbidNewlineBinaryOp, (0, import_lib3.$E)(JSXChildExpression), RestoreNewlineBinaryOp), function($skip, $loc, $0, $1, $2, $3, $4) {
16003
+ var expression = $3;
16004
+ if (!expression)
16005
+ return $skip;
16006
+ return expression;
16007
+ });
16008
+ var JSXCodeChildExpression$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$Y)(JSXEOS), ImplicitNestedBlock), function($skip, $loc, $0, $1, $2) {
16009
+ var block = $2;
16010
+ if (!block)
16011
+ return $skip;
16012
+ const statement = {
16013
+ type: "DoStatement",
16014
+ children: [block],
16015
+ block
16016
+ };
16017
+ return {
16018
+ type: "StatementExpression",
16019
+ statement,
16020
+ children: [statement]
16021
+ };
16022
+ });
16023
+ var JSXCodeChildExpression$$ = [JSXCodeChildExpression$0, JSXCodeChildExpression$1];
16024
+ function JSXCodeChildExpression(ctx, state2) {
16025
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "JSXCodeChildExpression", JSXCodeChildExpression$$);
16026
+ }
15758
16027
  var UsingDeclaration$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Using, (0, import_lib3.$E)(_), UsingBinding, (0, import_lib3.$Q)((0, import_lib3.$S)(__, Comma, __, UsingBinding)), UsingJSModeError), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
15759
16028
  var decl = $1;
15760
16029
  var binding = $3;
@@ -16979,6 +17248,22 @@ ${js}`
16979
17248
  function CoffeePrototypeEnabled(ctx, state2) {
16980
17249
  return (0, import_lib3.$EVENT)(ctx, state2, "CoffeePrototypeEnabled", CoffeePrototypeEnabled$0);
16981
17250
  }
17251
+ var JSXCodeNestedEnabled$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'JSXCodeNestedEnabled ""'), function($skip, $loc, $0, $1) {
17252
+ if (config.jsxCodeNested)
17253
+ return;
17254
+ return $skip;
17255
+ });
17256
+ function JSXCodeNestedEnabled(ctx, state2) {
17257
+ return (0, import_lib3.$EVENT)(ctx, state2, "JSXCodeNestedEnabled", JSXCodeNestedEnabled$0);
17258
+ }
17259
+ var JSXCodeSameLineEnabled$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'JSXCodeSameLineEnabled ""'), function($skip, $loc, $0, $1) {
17260
+ if (config.jsxCodeSameLine)
17261
+ return;
17262
+ return $skip;
17263
+ });
17264
+ function JSXCodeSameLineEnabled(ctx, state2) {
17265
+ return (0, import_lib3.$EVENT)(ctx, state2, "JSXCodeSameLineEnabled", JSXCodeSameLineEnabled$0);
17266
+ }
16982
17267
  var ObjectIsEnabled$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'ObjectIsEnabled ""'), function($skip, $loc, $0, $1) {
16983
17268
  if (config.objectIs)
16984
17269
  return;
@@ -17022,6 +17307,7 @@ ${js}`
17022
17307
  coffeePrototype: false,
17023
17308
  defaultElement: "div",
17024
17309
  implicitReturns: true,
17310
+ jsxCode: false,
17025
17311
  objectIs: false,
17026
17312
  react: false,
17027
17313
  solid: false,
@@ -17066,6 +17352,16 @@ ${js}`
17066
17352
  }
17067
17353
  }
17068
17354
  });
17355
+ Object.defineProperty(config, "jsxCode", {
17356
+ set(b) {
17357
+ for (const option of [
17358
+ "jsxCodeNested",
17359
+ "jsxCodeSameLine"
17360
+ ]) {
17361
+ config[option] = b;
17362
+ }
17363
+ }
17364
+ });
17069
17365
  Object.assign(config, initialConfig);
17070
17366
  return {
17071
17367
  type: "ParserMeta",