@danielx/civet 0.6.72 → 0.6.73

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
@@ -2262,9 +2262,17 @@ var Civet = (() => {
2262
2262
  const isMethod = f.type === "MethodDefinition";
2263
2263
  const isConstructor = isMethod && name === "constructor";
2264
2264
  const isVoid = isVoidType(returnType2?.t) || async && isPromiseVoidType(returnType2?.t) || !async && generator && isGeneratorVoidType(returnType2?.t);
2265
- const isBlock = block?.type === "BlockStatement";
2266
- if (!isVoid && !set && !isConstructor && isBlock) {
2267
- insertReturn(block);
2265
+ if (block?.type === "BlockStatement") {
2266
+ if (isVoid || set || isConstructor) {
2267
+ if (block.bare && block.implicitlyReturned) {
2268
+ block.children = [" {", ...block.children, " }"];
2269
+ block.bare = block.implicitlyReturned = false;
2270
+ }
2271
+ } else {
2272
+ if (!block.implicitlyReturned) {
2273
+ insertReturn(block);
2274
+ }
2275
+ }
2268
2276
  }
2269
2277
  }
2270
2278
  }
@@ -2671,8 +2679,8 @@ var Civet = (() => {
2671
2679
  }
2672
2680
  }
2673
2681
  function aggregateDuplicateBindings(bindings, ReservedWord) {
2674
- const props = gatherRecursiveAll(bindings, (n) => n.type === "BindingProperty");
2675
- const arrayBindings = gatherRecursiveAll(bindings, (n) => n.type === "ArrayBindingPattern");
2682
+ const props = gatherRecursiveAll(bindings, ($3) => $3.type === "BindingProperty");
2683
+ const arrayBindings = gatherRecursiveAll(bindings, ($4) => $4.type === "ArrayBindingPattern");
2676
2684
  arrayBindings.forEach((a) => {
2677
2685
  const { elements } = a;
2678
2686
  return elements.forEach((element) => {
@@ -2702,20 +2710,22 @@ var Civet = (() => {
2702
2710
  }
2703
2711
  }
2704
2712
  propsGroupedByName.forEach((shared, key) => {
2705
- if (!key)
2713
+ if (!key) {
2706
2714
  return;
2715
+ }
2707
2716
  if (ReservedWord({ fail() {
2708
2717
  } }, {
2709
2718
  pos: 0,
2710
2719
  input: key
2711
2720
  })) {
2712
- shared.forEach((p) => ({
2713
- aliasBinding: aliasBinding(p, makeRef(`_${key}`, key))
2714
- }));
2721
+ shared.forEach((p) => {
2722
+ return aliasBinding(p, makeRef(`_${key}`, key));
2723
+ });
2715
2724
  return;
2716
2725
  }
2717
- if (shared.length === 1)
2726
+ if (shared.length === 1) {
2718
2727
  return;
2728
+ }
2719
2729
  const refs = shared.map((p) => {
2720
2730
  const ref = makeRef(key);
2721
2731
  aliasBinding(p, ref);
@@ -2728,7 +2738,7 @@ var Civet = (() => {
2728
2738
  return declarations;
2729
2739
  }
2730
2740
  function processPatternMatching(statements, ReservedWord) {
2731
- gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement").forEach((s) => {
2741
+ gatherRecursiveAll(statements, ($5) => $5.type === "SwitchStatement").forEach((s) => {
2732
2742
  const { caseBlock } = s;
2733
2743
  const { clauses } = caseBlock;
2734
2744
  for (const c of clauses) {
@@ -2742,7 +2752,7 @@ var Civet = (() => {
2742
2752
  }
2743
2753
  let errors = false;
2744
2754
  let isPattern = false;
2745
- if (clauses.some((c) => c.type === "PatternClause")) {
2755
+ if (clauses.some(($6) => $6.type === "PatternClause")) {
2746
2756
  isPattern = true;
2747
2757
  clauses.forEach((c) => {
2748
2758
  if (!(c.type === "PatternClause" || c.type === "DefaultClause")) {
@@ -2756,8 +2766,9 @@ var Civet = (() => {
2756
2766
  return;
2757
2767
  });
2758
2768
  }
2759
- if (errors || !isPattern)
2769
+ if (errors || !isPattern) {
2760
2770
  return;
2771
+ }
2761
2772
  let { condition } = s;
2762
2773
  if (condition.type === "ParenthesizedExpression") {
2763
2774
  condition = condition.expression;
@@ -2969,7 +2980,7 @@ var Civet = (() => {
2969
2980
  };
2970
2981
  }
2971
2982
  children.push(arg);
2972
- if (!children.some(($3) => $3?.type === "ReturnStatement") && children.some(($4) => $4 === ",")) {
2983
+ if (!children.some(($7) => $7?.type === "ReturnStatement") && children.some(($8) => $8 === ",")) {
2973
2984
  const { parent } = s;
2974
2985
  const parenthesizedExpression = makeLeftHandSideExpression({ ...s });
2975
2986
  Object.assign(s, parenthesizedExpression, {
@@ -3092,7 +3103,7 @@ var Civet = (() => {
3092
3103
  scopes.push(decs);
3093
3104
  const varIds = [];
3094
3105
  const assignmentStatements = findAssignments(statements, scopes);
3095
- const undeclaredIdentifiers = assignmentStatements.flatMap((a) => a.names);
3106
+ const undeclaredIdentifiers = assignmentStatements.flatMap(($9) => $9?.names || []);
3096
3107
  undeclaredIdentifiers.filter((x, i, a) => {
3097
3108
  if (!hasDec(x))
3098
3109
  return a.indexOf(x) === i;
@@ -3398,7 +3409,8 @@ var Civet = (() => {
3398
3409
  ];
3399
3410
  }
3400
3411
  if (Array.isArray(rest.delim) && rest.delim.at(-1)?.token === ",") {
3401
- rest.delim.pop();
3412
+ rest.delim = rest.delim.slice(0, -1);
3413
+ rest.children = [...rest.children.slice(0, -1), rest.delim];
3402
3414
  }
3403
3415
  const children = [...props, ...after, rest];
3404
3416
  return {
@@ -4143,6 +4155,7 @@ ${input.slice(result.pos)}
4143
4155
  ArrowFunction,
4144
4156
  FatArrow,
4145
4157
  TrailingDeclaration,
4158
+ TrailingPipe,
4146
4159
  FatArrowBody,
4147
4160
  ConditionalExpression,
4148
4161
  TernaryRest,
@@ -5760,12 +5773,23 @@ ${input.slice(result.pos)}
5760
5773
  function TrailingDeclaration(ctx, state) {
5761
5774
  return $EVENT(ctx, state, "TrailingDeclaration", TrailingDeclaration$0);
5762
5775
  }
5763
- var FatArrowBody$0 = $TS($S($N(EOS), NonPipelinePostfixedExpression, $N(TrailingDeclaration), $N(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
5776
+ var TrailingPipe$0 = $S($E(_), Pipe);
5777
+ function TrailingPipe(ctx, state) {
5778
+ return $EVENT(ctx, state, "TrailingPipe", TrailingPipe$0);
5779
+ }
5780
+ var FatArrowBody$0 = $TS($S($N(EOS), NonPipelinePostfixedExpression, $N(TrailingDeclaration), $N(TrailingPipe), $N(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5764
5781
  var exp = $2;
5765
5782
  if (exp.type === "ObjectExpression") {
5766
- return makeLeftHandSideExpression(exp);
5783
+ exp = makeLeftHandSideExpression(exp);
5767
5784
  }
5768
- return exp;
5785
+ const expressions = [exp];
5786
+ return {
5787
+ type: "BlockStatement",
5788
+ bare: true,
5789
+ expressions,
5790
+ children: [expressions],
5791
+ implicitlyReturned: true
5792
+ };
5769
5793
  });
5770
5794
  var FatArrowBody$1 = NoCommaBracedOrEmptyBlock;
5771
5795
  var FatArrowBody$$ = [FatArrowBody$0, FatArrowBody$1];
@@ -8332,14 +8356,17 @@ ${input.slice(result.pos)}
8332
8356
  function NestedImplicitPropertyDefinitions(ctx, state) {
8333
8357
  return $EVENT(ctx, state, "NestedImplicitPropertyDefinitions", NestedImplicitPropertyDefinitions$0);
8334
8358
  }
8335
- var NestedImplicitPropertyDefinition$0 = $TS($S(Nested, NamedProperty, ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3) {
8336
- var ws = $1;
8337
- var prop = $2;
8338
- var delimiter = $3;
8339
- return {
8359
+ var NestedImplicitPropertyDefinition$0 = $TS($S(Nested, $P($S($E(_), NamedProperty, ObjectPropertyDelimiter))), function($skip, $loc, $0, $1, $2) {
8360
+ var indent = $1;
8361
+ var props = $2;
8362
+ return props.map(([ws, prop, delimiter], i) => ({
8340
8363
  ...prop,
8341
- children: [...ws, ...prop.children, delimiter]
8342
- };
8364
+ children: [
8365
+ ...i === 0 ? [indent, ws] : [ws],
8366
+ ...prop.children,
8367
+ delimiter
8368
+ ]
8369
+ }));
8343
8370
  });
8344
8371
  function NestedImplicitPropertyDefinition(ctx, state) {
8345
8372
  return $EVENT(ctx, state, "NestedImplicitPropertyDefinition", NestedImplicitPropertyDefinition$0);
@@ -11199,7 +11226,7 @@ ${input.slice(result.pos)}
11199
11226
  var flags = $4;
11200
11227
  let hasSubstitutions = body.some((part) => part.type === "Substitution");
11201
11228
  if (hasSubstitutions) {
11202
- const result = [
11229
+ const children = [
11203
11230
  { ...open, token: "RegExp(`" },
11204
11231
  // Escape backticks, backslashes, and '$' in the body text
11205
11232
  body.map(
@@ -11211,13 +11238,16 @@ ${input.slice(result.pos)}
11211
11238
  "`"
11212
11239
  ];
11213
11240
  if (flags.length) {
11214
- result.push(
11241
+ children.push(
11215
11242
  ", ",
11216
11243
  JSON.stringify(flags)
11217
11244
  );
11218
11245
  }
11219
- result.push({ ...close, token: ")" });
11220
- return result;
11246
+ children.push({ ...close, token: ")" });
11247
+ return {
11248
+ type: "RegularExpressionLiteral",
11249
+ children
11250
+ };
11221
11251
  }
11222
11252
  return {
11223
11253
  type: "RegularExpressionLiteral",
@@ -14410,6 +14440,7 @@ ${input.slice(result.pos)}
14410
14440
  exports.ArrowFunction = ArrowFunction;
14411
14441
  exports.FatArrow = FatArrow;
14412
14442
  exports.TrailingDeclaration = TrailingDeclaration;
14443
+ exports.TrailingPipe = TrailingPipe;
14413
14444
  exports.FatArrowBody = FatArrowBody;
14414
14445
  exports.ConditionalExpression = ConditionalExpression;
14415
14446
  exports.TernaryRest = TernaryRest;
package/dist/civet CHANGED
File without changes
package/dist/main.js CHANGED
@@ -2254,9 +2254,17 @@ function processReturn(f, implicitReturns) {
2254
2254
  const isMethod = f.type === "MethodDefinition";
2255
2255
  const isConstructor = isMethod && name === "constructor";
2256
2256
  const isVoid = isVoidType(returnType2?.t) || async && isPromiseVoidType(returnType2?.t) || !async && generator && isGeneratorVoidType(returnType2?.t);
2257
- const isBlock = block?.type === "BlockStatement";
2258
- if (!isVoid && !set && !isConstructor && isBlock) {
2259
- insertReturn(block);
2257
+ if (block?.type === "BlockStatement") {
2258
+ if (isVoid || set || isConstructor) {
2259
+ if (block.bare && block.implicitlyReturned) {
2260
+ block.children = [" {", ...block.children, " }"];
2261
+ block.bare = block.implicitlyReturned = false;
2262
+ }
2263
+ } else {
2264
+ if (!block.implicitlyReturned) {
2265
+ insertReturn(block);
2266
+ }
2267
+ }
2260
2268
  }
2261
2269
  }
2262
2270
  }
@@ -2663,8 +2671,8 @@ function nonMatcherBindings(pattern) {
2663
2671
  }
2664
2672
  }
2665
2673
  function aggregateDuplicateBindings(bindings, ReservedWord) {
2666
- const props = gatherRecursiveAll(bindings, (n) => n.type === "BindingProperty");
2667
- const arrayBindings = gatherRecursiveAll(bindings, (n) => n.type === "ArrayBindingPattern");
2674
+ const props = gatherRecursiveAll(bindings, ($3) => $3.type === "BindingProperty");
2675
+ const arrayBindings = gatherRecursiveAll(bindings, ($4) => $4.type === "ArrayBindingPattern");
2668
2676
  arrayBindings.forEach((a) => {
2669
2677
  const { elements } = a;
2670
2678
  return elements.forEach((element) => {
@@ -2694,20 +2702,22 @@ function aggregateDuplicateBindings(bindings, ReservedWord) {
2694
2702
  }
2695
2703
  }
2696
2704
  propsGroupedByName.forEach((shared, key) => {
2697
- if (!key)
2705
+ if (!key) {
2698
2706
  return;
2707
+ }
2699
2708
  if (ReservedWord({ fail() {
2700
2709
  } }, {
2701
2710
  pos: 0,
2702
2711
  input: key
2703
2712
  })) {
2704
- shared.forEach((p) => ({
2705
- aliasBinding: aliasBinding(p, makeRef(`_${key}`, key))
2706
- }));
2713
+ shared.forEach((p) => {
2714
+ return aliasBinding(p, makeRef(`_${key}`, key));
2715
+ });
2707
2716
  return;
2708
2717
  }
2709
- if (shared.length === 1)
2718
+ if (shared.length === 1) {
2710
2719
  return;
2720
+ }
2711
2721
  const refs = shared.map((p) => {
2712
2722
  const ref = makeRef(key);
2713
2723
  aliasBinding(p, ref);
@@ -2720,7 +2730,7 @@ function aggregateDuplicateBindings(bindings, ReservedWord) {
2720
2730
  return declarations;
2721
2731
  }
2722
2732
  function processPatternMatching(statements, ReservedWord) {
2723
- gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement").forEach((s) => {
2733
+ gatherRecursiveAll(statements, ($5) => $5.type === "SwitchStatement").forEach((s) => {
2724
2734
  const { caseBlock } = s;
2725
2735
  const { clauses } = caseBlock;
2726
2736
  for (const c of clauses) {
@@ -2734,7 +2744,7 @@ function processPatternMatching(statements, ReservedWord) {
2734
2744
  }
2735
2745
  let errors = false;
2736
2746
  let isPattern = false;
2737
- if (clauses.some((c) => c.type === "PatternClause")) {
2747
+ if (clauses.some(($6) => $6.type === "PatternClause")) {
2738
2748
  isPattern = true;
2739
2749
  clauses.forEach((c) => {
2740
2750
  if (!(c.type === "PatternClause" || c.type === "DefaultClause")) {
@@ -2748,8 +2758,9 @@ function processPatternMatching(statements, ReservedWord) {
2748
2758
  return;
2749
2759
  });
2750
2760
  }
2751
- if (errors || !isPattern)
2761
+ if (errors || !isPattern) {
2752
2762
  return;
2763
+ }
2753
2764
  let { condition } = s;
2754
2765
  if (condition.type === "ParenthesizedExpression") {
2755
2766
  condition = condition.expression;
@@ -2961,7 +2972,7 @@ function processPipelineExpressions(statements) {
2961
2972
  };
2962
2973
  }
2963
2974
  children.push(arg);
2964
- if (!children.some(($3) => $3?.type === "ReturnStatement") && children.some(($4) => $4 === ",")) {
2975
+ if (!children.some(($7) => $7?.type === "ReturnStatement") && children.some(($8) => $8 === ",")) {
2965
2976
  const { parent } = s;
2966
2977
  const parenthesizedExpression = makeLeftHandSideExpression({ ...s });
2967
2978
  Object.assign(s, parenthesizedExpression, {
@@ -3084,7 +3095,7 @@ function createVarDecs(statements, scopes, pushVar) {
3084
3095
  scopes.push(decs);
3085
3096
  const varIds = [];
3086
3097
  const assignmentStatements = findAssignments(statements, scopes);
3087
- const undeclaredIdentifiers = assignmentStatements.flatMap((a) => a.names);
3098
+ const undeclaredIdentifiers = assignmentStatements.flatMap(($9) => $9?.names || []);
3088
3099
  undeclaredIdentifiers.filter((x, i, a) => {
3089
3100
  if (!hasDec(x))
3090
3101
  return a.indexOf(x) === i;
@@ -3390,7 +3401,8 @@ function reorderBindingRestProperty(props) {
3390
3401
  ];
3391
3402
  }
3392
3403
  if (Array.isArray(rest.delim) && rest.delim.at(-1)?.token === ",") {
3393
- rest.delim.pop();
3404
+ rest.delim = rest.delim.slice(0, -1);
3405
+ rest.children = [...rest.children.slice(0, -1), rest.delim];
3394
3406
  }
3395
3407
  const children = [...props, ...after, rest];
3396
3408
  return {
@@ -4135,6 +4147,7 @@ var require_parser = __commonJS({
4135
4147
  ArrowFunction,
4136
4148
  FatArrow,
4137
4149
  TrailingDeclaration,
4150
+ TrailingPipe,
4138
4151
  FatArrowBody,
4139
4152
  ConditionalExpression,
4140
4153
  TernaryRest,
@@ -5752,12 +5765,23 @@ var require_parser = __commonJS({
5752
5765
  function TrailingDeclaration(ctx, state) {
5753
5766
  return $EVENT(ctx, state, "TrailingDeclaration", TrailingDeclaration$0);
5754
5767
  }
5755
- var FatArrowBody$0 = $TS($S($N(EOS), NonPipelinePostfixedExpression, $N(TrailingDeclaration), $N(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
5768
+ var TrailingPipe$0 = $S($E(_), Pipe);
5769
+ function TrailingPipe(ctx, state) {
5770
+ return $EVENT(ctx, state, "TrailingPipe", TrailingPipe$0);
5771
+ }
5772
+ var FatArrowBody$0 = $TS($S($N(EOS), NonPipelinePostfixedExpression, $N(TrailingDeclaration), $N(TrailingPipe), $N(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5756
5773
  var exp = $2;
5757
5774
  if (exp.type === "ObjectExpression") {
5758
- return makeLeftHandSideExpression(exp);
5775
+ exp = makeLeftHandSideExpression(exp);
5759
5776
  }
5760
- return exp;
5777
+ const expressions = [exp];
5778
+ return {
5779
+ type: "BlockStatement",
5780
+ bare: true,
5781
+ expressions,
5782
+ children: [expressions],
5783
+ implicitlyReturned: true
5784
+ };
5761
5785
  });
5762
5786
  var FatArrowBody$1 = NoCommaBracedOrEmptyBlock;
5763
5787
  var FatArrowBody$$ = [FatArrowBody$0, FatArrowBody$1];
@@ -8324,14 +8348,17 @@ var require_parser = __commonJS({
8324
8348
  function NestedImplicitPropertyDefinitions(ctx, state) {
8325
8349
  return $EVENT(ctx, state, "NestedImplicitPropertyDefinitions", NestedImplicitPropertyDefinitions$0);
8326
8350
  }
8327
- var NestedImplicitPropertyDefinition$0 = $TS($S(Nested, NamedProperty, ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3) {
8328
- var ws = $1;
8329
- var prop = $2;
8330
- var delimiter = $3;
8331
- return {
8351
+ var NestedImplicitPropertyDefinition$0 = $TS($S(Nested, $P($S($E(_), NamedProperty, ObjectPropertyDelimiter))), function($skip, $loc, $0, $1, $2) {
8352
+ var indent = $1;
8353
+ var props = $2;
8354
+ return props.map(([ws, prop, delimiter], i) => ({
8332
8355
  ...prop,
8333
- children: [...ws, ...prop.children, delimiter]
8334
- };
8356
+ children: [
8357
+ ...i === 0 ? [indent, ws] : [ws],
8358
+ ...prop.children,
8359
+ delimiter
8360
+ ]
8361
+ }));
8335
8362
  });
8336
8363
  function NestedImplicitPropertyDefinition(ctx, state) {
8337
8364
  return $EVENT(ctx, state, "NestedImplicitPropertyDefinition", NestedImplicitPropertyDefinition$0);
@@ -11191,7 +11218,7 @@ var require_parser = __commonJS({
11191
11218
  var flags = $4;
11192
11219
  let hasSubstitutions = body.some((part) => part.type === "Substitution");
11193
11220
  if (hasSubstitutions) {
11194
- const result = [
11221
+ const children = [
11195
11222
  { ...open, token: "RegExp(`" },
11196
11223
  // Escape backticks, backslashes, and '$' in the body text
11197
11224
  body.map(
@@ -11203,13 +11230,16 @@ var require_parser = __commonJS({
11203
11230
  "`"
11204
11231
  ];
11205
11232
  if (flags.length) {
11206
- result.push(
11233
+ children.push(
11207
11234
  ", ",
11208
11235
  JSON.stringify(flags)
11209
11236
  );
11210
11237
  }
11211
- result.push({ ...close, token: ")" });
11212
- return result;
11238
+ children.push({ ...close, token: ")" });
11239
+ return {
11240
+ type: "RegularExpressionLiteral",
11241
+ children
11242
+ };
11213
11243
  }
11214
11244
  return {
11215
11245
  type: "RegularExpressionLiteral",
@@ -14402,6 +14432,7 @@ var require_parser = __commonJS({
14402
14432
  exports2.ArrowFunction = ArrowFunction;
14403
14433
  exports2.FatArrow = FatArrow;
14404
14434
  exports2.TrailingDeclaration = TrailingDeclaration;
14435
+ exports2.TrailingPipe = TrailingPipe;
14405
14436
  exports2.FatArrowBody = FatArrowBody;
14406
14437
  exports2.ConditionalExpression = ConditionalExpression;
14407
14438
  exports2.TernaryRest = TernaryRest;
package/dist/main.mjs CHANGED
@@ -2252,9 +2252,17 @@ function processReturn(f, implicitReturns) {
2252
2252
  const isMethod = f.type === "MethodDefinition";
2253
2253
  const isConstructor = isMethod && name === "constructor";
2254
2254
  const isVoid = isVoidType(returnType2?.t) || async && isPromiseVoidType(returnType2?.t) || !async && generator && isGeneratorVoidType(returnType2?.t);
2255
- const isBlock = block?.type === "BlockStatement";
2256
- if (!isVoid && !set && !isConstructor && isBlock) {
2257
- insertReturn(block);
2255
+ if (block?.type === "BlockStatement") {
2256
+ if (isVoid || set || isConstructor) {
2257
+ if (block.bare && block.implicitlyReturned) {
2258
+ block.children = [" {", ...block.children, " }"];
2259
+ block.bare = block.implicitlyReturned = false;
2260
+ }
2261
+ } else {
2262
+ if (!block.implicitlyReturned) {
2263
+ insertReturn(block);
2264
+ }
2265
+ }
2258
2266
  }
2259
2267
  }
2260
2268
  }
@@ -2661,8 +2669,8 @@ function nonMatcherBindings(pattern) {
2661
2669
  }
2662
2670
  }
2663
2671
  function aggregateDuplicateBindings(bindings, ReservedWord) {
2664
- const props = gatherRecursiveAll(bindings, (n) => n.type === "BindingProperty");
2665
- const arrayBindings = gatherRecursiveAll(bindings, (n) => n.type === "ArrayBindingPattern");
2672
+ const props = gatherRecursiveAll(bindings, ($3) => $3.type === "BindingProperty");
2673
+ const arrayBindings = gatherRecursiveAll(bindings, ($4) => $4.type === "ArrayBindingPattern");
2666
2674
  arrayBindings.forEach((a) => {
2667
2675
  const { elements } = a;
2668
2676
  return elements.forEach((element) => {
@@ -2692,20 +2700,22 @@ function aggregateDuplicateBindings(bindings, ReservedWord) {
2692
2700
  }
2693
2701
  }
2694
2702
  propsGroupedByName.forEach((shared, key) => {
2695
- if (!key)
2703
+ if (!key) {
2696
2704
  return;
2705
+ }
2697
2706
  if (ReservedWord({ fail() {
2698
2707
  } }, {
2699
2708
  pos: 0,
2700
2709
  input: key
2701
2710
  })) {
2702
- shared.forEach((p) => ({
2703
- aliasBinding: aliasBinding(p, makeRef(`_${key}`, key))
2704
- }));
2711
+ shared.forEach((p) => {
2712
+ return aliasBinding(p, makeRef(`_${key}`, key));
2713
+ });
2705
2714
  return;
2706
2715
  }
2707
- if (shared.length === 1)
2716
+ if (shared.length === 1) {
2708
2717
  return;
2718
+ }
2709
2719
  const refs = shared.map((p) => {
2710
2720
  const ref = makeRef(key);
2711
2721
  aliasBinding(p, ref);
@@ -2718,7 +2728,7 @@ function aggregateDuplicateBindings(bindings, ReservedWord) {
2718
2728
  return declarations;
2719
2729
  }
2720
2730
  function processPatternMatching(statements, ReservedWord) {
2721
- gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement").forEach((s) => {
2731
+ gatherRecursiveAll(statements, ($5) => $5.type === "SwitchStatement").forEach((s) => {
2722
2732
  const { caseBlock } = s;
2723
2733
  const { clauses } = caseBlock;
2724
2734
  for (const c of clauses) {
@@ -2732,7 +2742,7 @@ function processPatternMatching(statements, ReservedWord) {
2732
2742
  }
2733
2743
  let errors = false;
2734
2744
  let isPattern = false;
2735
- if (clauses.some((c) => c.type === "PatternClause")) {
2745
+ if (clauses.some(($6) => $6.type === "PatternClause")) {
2736
2746
  isPattern = true;
2737
2747
  clauses.forEach((c) => {
2738
2748
  if (!(c.type === "PatternClause" || c.type === "DefaultClause")) {
@@ -2746,8 +2756,9 @@ function processPatternMatching(statements, ReservedWord) {
2746
2756
  return;
2747
2757
  });
2748
2758
  }
2749
- if (errors || !isPattern)
2759
+ if (errors || !isPattern) {
2750
2760
  return;
2761
+ }
2751
2762
  let { condition } = s;
2752
2763
  if (condition.type === "ParenthesizedExpression") {
2753
2764
  condition = condition.expression;
@@ -2959,7 +2970,7 @@ function processPipelineExpressions(statements) {
2959
2970
  };
2960
2971
  }
2961
2972
  children.push(arg);
2962
- if (!children.some(($3) => $3?.type === "ReturnStatement") && children.some(($4) => $4 === ",")) {
2973
+ if (!children.some(($7) => $7?.type === "ReturnStatement") && children.some(($8) => $8 === ",")) {
2963
2974
  const { parent } = s;
2964
2975
  const parenthesizedExpression = makeLeftHandSideExpression({ ...s });
2965
2976
  Object.assign(s, parenthesizedExpression, {
@@ -3082,7 +3093,7 @@ function createVarDecs(statements, scopes, pushVar) {
3082
3093
  scopes.push(decs);
3083
3094
  const varIds = [];
3084
3095
  const assignmentStatements = findAssignments(statements, scopes);
3085
- const undeclaredIdentifiers = assignmentStatements.flatMap((a) => a.names);
3096
+ const undeclaredIdentifiers = assignmentStatements.flatMap(($9) => $9?.names || []);
3086
3097
  undeclaredIdentifiers.filter((x, i, a) => {
3087
3098
  if (!hasDec(x))
3088
3099
  return a.indexOf(x) === i;
@@ -3388,7 +3399,8 @@ function reorderBindingRestProperty(props) {
3388
3399
  ];
3389
3400
  }
3390
3401
  if (Array.isArray(rest.delim) && rest.delim.at(-1)?.token === ",") {
3391
- rest.delim.pop();
3402
+ rest.delim = rest.delim.slice(0, -1);
3403
+ rest.children = [...rest.children.slice(0, -1), rest.delim];
3392
3404
  }
3393
3405
  const children = [...props, ...after, rest];
3394
3406
  return {
@@ -4133,6 +4145,7 @@ var require_parser = __commonJS({
4133
4145
  ArrowFunction,
4134
4146
  FatArrow,
4135
4147
  TrailingDeclaration,
4148
+ TrailingPipe,
4136
4149
  FatArrowBody,
4137
4150
  ConditionalExpression,
4138
4151
  TernaryRest,
@@ -5750,12 +5763,23 @@ var require_parser = __commonJS({
5750
5763
  function TrailingDeclaration(ctx, state) {
5751
5764
  return $EVENT(ctx, state, "TrailingDeclaration", TrailingDeclaration$0);
5752
5765
  }
5753
- var FatArrowBody$0 = $TS($S($N(EOS), NonPipelinePostfixedExpression, $N(TrailingDeclaration), $N(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
5766
+ var TrailingPipe$0 = $S($E(_), Pipe);
5767
+ function TrailingPipe(ctx, state) {
5768
+ return $EVENT(ctx, state, "TrailingPipe", TrailingPipe$0);
5769
+ }
5770
+ var FatArrowBody$0 = $TS($S($N(EOS), NonPipelinePostfixedExpression, $N(TrailingDeclaration), $N(TrailingPipe), $N(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5754
5771
  var exp = $2;
5755
5772
  if (exp.type === "ObjectExpression") {
5756
- return makeLeftHandSideExpression(exp);
5773
+ exp = makeLeftHandSideExpression(exp);
5757
5774
  }
5758
- return exp;
5775
+ const expressions = [exp];
5776
+ return {
5777
+ type: "BlockStatement",
5778
+ bare: true,
5779
+ expressions,
5780
+ children: [expressions],
5781
+ implicitlyReturned: true
5782
+ };
5759
5783
  });
5760
5784
  var FatArrowBody$1 = NoCommaBracedOrEmptyBlock;
5761
5785
  var FatArrowBody$$ = [FatArrowBody$0, FatArrowBody$1];
@@ -8322,14 +8346,17 @@ var require_parser = __commonJS({
8322
8346
  function NestedImplicitPropertyDefinitions(ctx, state) {
8323
8347
  return $EVENT(ctx, state, "NestedImplicitPropertyDefinitions", NestedImplicitPropertyDefinitions$0);
8324
8348
  }
8325
- var NestedImplicitPropertyDefinition$0 = $TS($S(Nested, NamedProperty, ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3) {
8326
- var ws = $1;
8327
- var prop = $2;
8328
- var delimiter = $3;
8329
- return {
8349
+ var NestedImplicitPropertyDefinition$0 = $TS($S(Nested, $P($S($E(_), NamedProperty, ObjectPropertyDelimiter))), function($skip, $loc, $0, $1, $2) {
8350
+ var indent = $1;
8351
+ var props = $2;
8352
+ return props.map(([ws, prop, delimiter], i) => ({
8330
8353
  ...prop,
8331
- children: [...ws, ...prop.children, delimiter]
8332
- };
8354
+ children: [
8355
+ ...i === 0 ? [indent, ws] : [ws],
8356
+ ...prop.children,
8357
+ delimiter
8358
+ ]
8359
+ }));
8333
8360
  });
8334
8361
  function NestedImplicitPropertyDefinition(ctx, state) {
8335
8362
  return $EVENT(ctx, state, "NestedImplicitPropertyDefinition", NestedImplicitPropertyDefinition$0);
@@ -11189,7 +11216,7 @@ var require_parser = __commonJS({
11189
11216
  var flags = $4;
11190
11217
  let hasSubstitutions = body.some((part) => part.type === "Substitution");
11191
11218
  if (hasSubstitutions) {
11192
- const result = [
11219
+ const children = [
11193
11220
  { ...open, token: "RegExp(`" },
11194
11221
  // Escape backticks, backslashes, and '$' in the body text
11195
11222
  body.map(
@@ -11201,13 +11228,16 @@ var require_parser = __commonJS({
11201
11228
  "`"
11202
11229
  ];
11203
11230
  if (flags.length) {
11204
- result.push(
11231
+ children.push(
11205
11232
  ", ",
11206
11233
  JSON.stringify(flags)
11207
11234
  );
11208
11235
  }
11209
- result.push({ ...close, token: ")" });
11210
- return result;
11236
+ children.push({ ...close, token: ")" });
11237
+ return {
11238
+ type: "RegularExpressionLiteral",
11239
+ children
11240
+ };
11211
11241
  }
11212
11242
  return {
11213
11243
  type: "RegularExpressionLiteral",
@@ -14400,6 +14430,7 @@ var require_parser = __commonJS({
14400
14430
  exports.ArrowFunction = ArrowFunction;
14401
14431
  exports.FatArrow = FatArrow;
14402
14432
  exports.TrailingDeclaration = TrailingDeclaration;
14433
+ exports.TrailingPipe = TrailingPipe;
14403
14434
  exports.FatArrowBody = FatArrowBody;
14404
14435
  exports.ConditionalExpression = ConditionalExpression;
14405
14436
  exports.TernaryRest = TernaryRest;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.6.72",
4
+ "version": "0.6.73",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",