@danielx/civet 0.6.47 → 0.6.49

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
@@ -506,6 +506,7 @@ ${input.slice(result.pos)}
506
506
  }
507
507
  return;
508
508
  }
509
+ node = node;
509
510
  node.parent = parent;
510
511
  if (node.children) {
511
512
  for (const child of node.children) {
@@ -524,6 +525,7 @@ ${input.slice(result.pos)}
524
525
  }
525
526
  return;
526
527
  }
528
+ node = node;
527
529
  if (parent != null)
528
530
  node.parent = parent;
529
531
  if (depth && node.children) {
@@ -532,20 +534,24 @@ ${input.slice(result.pos)}
532
534
  }
533
535
  }
534
536
  }
537
+ function makeNode(node) {
538
+ updateParentPointers(node);
539
+ return node;
540
+ }
535
541
  function addPostfixStatement(statement, ws, post) {
536
542
  const expressions = [
537
543
  ...post.blockPrefix || [],
538
544
  ["", statement]
539
545
  ];
540
- const block = {
546
+ const block = makeNode({
541
547
  type: "BlockStatement",
542
548
  children: [" { ", expressions, " }"],
543
549
  expressions
544
- };
550
+ });
545
551
  const children = [...post.children, block];
546
552
  if (!isWhitespaceOrEmpty(ws))
547
553
  children.push(ws);
548
- post = { ...post, children, block };
554
+ post = makeNode({ ...post, children, block });
549
555
  if (post.type === "IfStatement") {
550
556
  post.then = block;
551
557
  }
@@ -659,6 +665,7 @@ ${input.slice(result.pos)}
659
665
  });
660
666
  }
661
667
  const expressions = [...prefixStatements, ...block.expressions];
668
+ addParentPointers(prefixStatements, block);
662
669
  block = {
663
670
  ...block,
664
671
  expressions,
@@ -668,6 +675,7 @@ ${input.slice(result.pos)}
668
675
  block.children = [[" {"], ...block.children, "}"];
669
676
  block.bare = false;
670
677
  }
678
+ updateParentPointers(block);
671
679
  }
672
680
  return block;
673
681
  }
@@ -685,10 +693,11 @@ ${input.slice(result.pos)}
685
693
  const { ref, body } = expr;
686
694
  ref.type = "PipedExpression";
687
695
  ref.children = [makeLeftHandSideExpression(arg)];
688
- return {
696
+ updateParentPointers(ref);
697
+ return makeNode({
689
698
  type: "UnwrappedExpression",
690
699
  children: [skipIfOnlyWS(fn.leadingComment), body, skipIfOnlyWS(fn.trailingComment)]
691
- };
700
+ });
692
701
  }
693
702
  expr = fn.expr;
694
703
  const lhs = makeLeftHandSideExpression(expr);
@@ -902,6 +911,7 @@ ${input.slice(result.pos)}
902
911
  if (subtype === "DoStatement") {
903
912
  insertReturn(block);
904
913
  children.splice(i, 1, ...wrapIIFE(["", statement, void 0], async));
914
+ updateParentPointers(exp);
905
915
  return;
906
916
  }
907
917
  const resultsRef = makeRef("results");
@@ -916,6 +926,7 @@ ${input.slice(result.pos)}
916
926
  ["", wrapWithReturn(resultsRef)]
917
927
  ], async)
918
928
  );
929
+ updateParentPointers(exp);
919
930
  }
920
931
  function processBinaryOpExpression($0) {
921
932
  const expandedOps = expandChainedComparisons($0);
@@ -1209,10 +1220,10 @@ ${input.slice(result.pos)}
1209
1220
  }
1210
1221
  function wrapWithReturn(expression) {
1211
1222
  const children = expression ? ["return ", expression] : ["return"];
1212
- return {
1223
+ return makeNode({
1213
1224
  type: "ReturnStatement",
1214
1225
  children
1215
- };
1226
+ });
1216
1227
  }
1217
1228
  function isExistence(exp) {
1218
1229
  if (exp.type === "ParenthesizedExpression" && exp.implicit) {
@@ -1507,6 +1518,7 @@ ${input.slice(result.pos)}
1507
1518
  const indent = expressions[index][0];
1508
1519
  expressions.splice(index, 0, [indent, dec, ";"]);
1509
1520
  }
1521
+ addParentPointers(dec, block);
1510
1522
  }
1511
1523
  function patternAsValue(pattern) {
1512
1524
  switch (pattern.type) {
@@ -1585,7 +1597,8 @@ ${input.slice(result.pos)}
1585
1597
  case "Declaration":
1586
1598
  exp.children.push(["", {
1587
1599
  type: "ReturnStatement",
1588
- children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)]
1600
+ children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)],
1601
+ parent: exp
1589
1602
  }]);
1590
1603
  return;
1591
1604
  case "FunctionExpression":
@@ -1594,7 +1607,8 @@ ${input.slice(result.pos)}
1594
1607
  "",
1595
1608
  {
1596
1609
  type: "ReturnStatement",
1597
- children: [";return ", exp.id]
1610
+ children: [";return ", exp.id],
1611
+ parent: exp
1598
1612
  }
1599
1613
  ]);
1600
1614
  return;
@@ -1616,7 +1630,8 @@ ${input.slice(result.pos)}
1616
1630
  exp.children.push(["", {
1617
1631
  type: "ReturnStatement",
1618
1632
  // NOTE: add a prefixed semi-colon because the if block may not be braced
1619
- children: [";return"]
1633
+ children: [";return"],
1634
+ parent: exp
1620
1635
  }]);
1621
1636
  return;
1622
1637
  case "PatternMatchingStatement":
@@ -2036,14 +2051,13 @@ ${input.slice(result.pos)}
2036
2051
  case "ThrowExpression":
2037
2052
  case "TryExpression":
2038
2053
  return expression;
2039
- default:
2040
- return {
2041
- type: "ParenthesizedExpression",
2042
- children: ["(", expression, ")"],
2043
- expression,
2044
- implicit: true
2045
- };
2046
2054
  }
2055
+ return makeNode({
2056
+ type: "ParenthesizedExpression",
2057
+ children: ["(", expression, ")"],
2058
+ expression,
2059
+ implicit: true
2060
+ });
2047
2061
  }
2048
2062
  function modifyString(str) {
2049
2063
  return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
@@ -2250,7 +2264,7 @@ ${input.slice(result.pos)}
2250
2264
  splices = splices.map((s) => [", ", s]);
2251
2265
  thisAssignments = thisAssignments.map((a) => ["", a, ";"]);
2252
2266
  const initializer = [ws, assign, e];
2253
- const binding = {
2267
+ const binding = makeNode({
2254
2268
  type: "Binding",
2255
2269
  pattern: id,
2256
2270
  initializer,
@@ -2258,9 +2272,9 @@ ${input.slice(result.pos)}
2258
2272
  suffix,
2259
2273
  thisAssignments,
2260
2274
  children: [id, suffix, initializer]
2261
- };
2275
+ });
2262
2276
  const children = [decl, binding];
2263
- return {
2277
+ return makeNode({
2264
2278
  type: "Declaration",
2265
2279
  names: id.names,
2266
2280
  decl,
@@ -2268,9 +2282,9 @@ ${input.slice(result.pos)}
2268
2282
  splices,
2269
2283
  thisAssignments,
2270
2284
  children
2271
- };
2285
+ });
2272
2286
  }
2273
- function processDeclarationCondition(condition, rootCondition) {
2287
+ function processDeclarationCondition(condition, rootCondition, parent) {
2274
2288
  if (!(condition.type === "DeclarationCondition")) {
2275
2289
  return;
2276
2290
  }
@@ -2289,6 +2303,7 @@ ${input.slice(result.pos)}
2289
2303
  pattern,
2290
2304
  ref
2291
2305
  });
2306
+ addParentPointers(condition, parent);
2292
2307
  Object.assign(rootCondition, {
2293
2308
  blockPrefix: [
2294
2309
  ["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
@@ -2312,7 +2327,7 @@ ${input.slice(result.pos)}
2312
2327
  const type = [type1, type2];
2313
2328
  expression = expression2;
2314
2329
  }
2315
- processDeclarationCondition(expression, condition.expression);
2330
+ processDeclarationCondition(expression, condition.expression, s);
2316
2331
  const { ref, pattern } = expression;
2317
2332
  if (pattern) {
2318
2333
  let conditions = [];
@@ -2362,10 +2377,12 @@ ${input.slice(result.pos)}
2362
2377
  parent: s
2363
2378
  };
2364
2379
  s.children[1] = s.condition;
2380
+ updateParentPointers(s);
2365
2381
  const block = blockWithPrefix([["", [{
2366
2382
  type: "Declaration",
2367
2383
  children: ["let ", ...condition.expression.children]
2368
2384
  }], ";"], ...blockPrefix], makeEmptyBlock());
2385
+ updateParentPointers(block, s.parent);
2369
2386
  replaceBlockExpression(s.parent, s, block);
2370
2387
  block.expressions.push(["", s]);
2371
2388
  s.parent = block;
@@ -3598,12 +3615,12 @@ ${input.slice(result.pos)}
3598
3615
  children: ["await "]
3599
3616
  };
3600
3617
  }
3601
- const block = {
3618
+ const block = makeNode({
3602
3619
  type: "BlockStatement",
3603
3620
  expressions,
3604
3621
  children: ["{", expressions, "}"],
3605
3622
  bare: false
3606
- };
3623
+ });
3607
3624
  const parameters = {
3608
3625
  type: "Parameters",
3609
3626
  children: ["()"],
@@ -3615,7 +3632,7 @@ ${input.slice(result.pos)}
3615
3632
  },
3616
3633
  returnType: void 0
3617
3634
  };
3618
- const fn = {
3635
+ const fn = makeNode({
3619
3636
  type: "ArrowFunction",
3620
3637
  signature,
3621
3638
  parameters,
@@ -3624,12 +3641,11 @@ ${input.slice(result.pos)}
3624
3641
  async,
3625
3642
  block,
3626
3643
  children: [async, parameters, "=>", block]
3627
- };
3628
- updateParentPointers(block, fn);
3629
- const exp = {
3644
+ });
3645
+ const exp = makeNode({
3630
3646
  type: "CallExpression",
3631
3647
  children: [makeLeftHandSideExpression(fn), "()"]
3632
- };
3648
+ });
3633
3649
  if (prefix) {
3634
3650
  return [makeLeftHandSideExpression([prefix, exp])];
3635
3651
  }
@@ -4655,7 +4671,7 @@ ${input.slice(result.pos)}
4655
4671
  var $R16 = $R(new RegExp("(?=\\p{ID_Start}|[_$^\xAB\xBB\u22D9\u2264\u2265\u2208\u220B\u2209\u220C\u2263\u2261\u2262\u2260=\u2016\u2047&|*\\/!?%<>+-])", "suy"));
4656
4672
  var $R17 = $R(new RegExp("<(?!\\p{ID_Start}|[_$])", "suy"));
4657
4673
  var $R18 = $R(new RegExp("!\\^\\^?", "suy"));
4658
- var $R19 = $R(new RegExp("(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*[&.])", "suy"));
4674
+ var $R19 = $R(new RegExp("(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*(&|\\.[^0-9]))", "suy"));
4659
4675
  var $R20 = $R(new RegExp("(?=for|if|loop|unless|until|while)", "suy"));
4660
4676
  var $R21 = $R(new RegExp("(?=loop|do|for|until|while)", "suy"));
4661
4677
  var $R22 = $R(new RegExp("(?=[\\s\\),])", "suy"));
@@ -4719,12 +4735,11 @@ ${input.slice(result.pos)}
4719
4735
  var $R80 = $R(new RegExp("#![^\\r\\n]*", "suy"));
4720
4736
  var $R81 = $R(new RegExp("[\\t ]*", "suy"));
4721
4737
  var $R82 = $R(new RegExp("[ \\t]*", "suy"));
4722
- var $R83 = $R(new RegExp("\\r\\n|\\r|\\n", "suy"));
4723
- var $R84 = $R(new RegExp("[\\s]*", "suy"));
4724
- var $R85 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
4725
- var $R86 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
4726
- var $R87 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
4727
- var $R88 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
4738
+ var $R83 = $R(new RegExp("[\\s]*", "suy"));
4739
+ var $R84 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
4740
+ var $R85 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
4741
+ var $R86 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
4742
+ var $R87 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
4728
4743
  var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4729
4744
  var statements = $4;
4730
4745
  processProgram({
@@ -8414,7 +8429,7 @@ ${input.slice(result.pos)}
8414
8429
  function Xnor(ctx, state) {
8415
8430
  return $EVENT_C(ctx, state, "Xnor", Xnor$$);
8416
8431
  }
8417
- var UnaryOp$0 = $TR($EXPECT($R19, "UnaryOp /(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*[&.])/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
8432
+ var UnaryOp$0 = $TR($EXPECT($R19, "UnaryOp /(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*(&|\\.[^0-9]))/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
8418
8433
  return { $loc, token: $0 };
8419
8434
  });
8420
8435
  var UnaryOp$1 = AwaitOp;
@@ -12431,21 +12446,19 @@ ${input.slice(result.pos)}
12431
12446
  function Shebang(ctx, state) {
12432
12447
  return $EVENT(ctx, state, "Shebang", Shebang$0);
12433
12448
  }
12434
- var CivetPrologue$0 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
12435
- var content = $3;
12436
- var eos = $8;
12437
- return { ...content, children: [...content.children, eos] };
12449
+ var CivetPrologue$0 = $T($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $C(EOL, $Y(RestOfLine))), function(value) {
12450
+ var content = value[2];
12451
+ return content;
12438
12452
  });
12439
- var CivetPrologue$1 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
12440
- var content = $3;
12441
- var eos = $8;
12442
- return { ...content, children: [...content.children, eos] };
12453
+ var CivetPrologue$1 = $T($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $C(EOL, $Y(RestOfLine))), function(value) {
12454
+ var content = value[2];
12455
+ return content;
12443
12456
  });
12444
12457
  var CivetPrologue$$ = [CivetPrologue$0, CivetPrologue$1];
12445
12458
  function CivetPrologue(ctx, state) {
12446
12459
  return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
12447
12460
  }
12448
- var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R84, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12461
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R83, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12449
12462
  var options = $3;
12450
12463
  return {
12451
12464
  type: "CivetPrologue",
@@ -12456,7 +12469,7 @@ ${input.slice(result.pos)}
12456
12469
  function CivetPrologueContent(ctx, state) {
12457
12470
  return $EVENT(ctx, state, "CivetPrologueContent", CivetPrologueContent$0);
12458
12471
  }
12459
- var CivetOption$0 = $TR($EXPECT($R85, "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) {
12472
+ var CivetOption$0 = $TR($EXPECT($R84, "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) {
12460
12473
  const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
12461
12474
  if (l)
12462
12475
  return l.toUpperCase();
@@ -12477,7 +12490,7 @@ ${input.slice(result.pos)}
12477
12490
  function UnknownPrologue(ctx, state) {
12478
12491
  return $EVENT(ctx, state, "UnknownPrologue", UnknownPrologue$0);
12479
12492
  }
12480
- var TripleSlashDirective$0 = $S($R$0($EXPECT($R86, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
12493
+ var TripleSlashDirective$0 = $S($R$0($EXPECT($R85, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
12481
12494
  function TripleSlashDirective(ctx, state) {
12482
12495
  return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
12483
12496
  }
@@ -12491,13 +12504,13 @@ ${input.slice(result.pos)}
12491
12504
  function PrologueString(ctx, state) {
12492
12505
  return $EVENT_C(ctx, state, "PrologueString", PrologueString$$);
12493
12506
  }
12494
- var EOS$0 = $T($S($EXPECT($R87, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
12507
+ var EOS$0 = $T($S($EXPECT($R86, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
12495
12508
  return value[1];
12496
12509
  });
12497
12510
  function EOS(ctx, state) {
12498
12511
  return $EVENT(ctx, state, "EOS", EOS$0);
12499
12512
  }
12500
- var EOL$0 = $TR($EXPECT($R88, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12513
+ var EOL$0 = $TR($EXPECT($R87, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12501
12514
  return { $loc, token: $0 };
12502
12515
  });
12503
12516
  function EOL(ctx, state) {
package/dist/esbuild.js CHANGED
@@ -177,6 +177,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
177
177
  return null;
178
178
  const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
179
179
  const code = await fs.promises.readFile(filename, "utf-8");
180
+ this.addWatchFile(filename);
180
181
  const compiled = import_civet.default.compile(code, {
181
182
  // inlineMap: true,
182
183
  filename: id,
package/dist/main.js CHANGED
@@ -498,6 +498,7 @@ var require_lib = __commonJS({
498
498
  }
499
499
  return;
500
500
  }
501
+ node = node;
501
502
  node.parent = parent;
502
503
  if (node.children) {
503
504
  for (const child of node.children) {
@@ -516,6 +517,7 @@ var require_lib = __commonJS({
516
517
  }
517
518
  return;
518
519
  }
520
+ node = node;
519
521
  if (parent != null)
520
522
  node.parent = parent;
521
523
  if (depth && node.children) {
@@ -524,20 +526,24 @@ var require_lib = __commonJS({
524
526
  }
525
527
  }
526
528
  }
529
+ function makeNode(node) {
530
+ updateParentPointers(node);
531
+ return node;
532
+ }
527
533
  function addPostfixStatement(statement, ws, post) {
528
534
  const expressions = [
529
535
  ...post.blockPrefix || [],
530
536
  ["", statement]
531
537
  ];
532
- const block = {
538
+ const block = makeNode({
533
539
  type: "BlockStatement",
534
540
  children: [" { ", expressions, " }"],
535
541
  expressions
536
- };
542
+ });
537
543
  const children = [...post.children, block];
538
544
  if (!isWhitespaceOrEmpty(ws))
539
545
  children.push(ws);
540
- post = { ...post, children, block };
546
+ post = makeNode({ ...post, children, block });
541
547
  if (post.type === "IfStatement") {
542
548
  post.then = block;
543
549
  }
@@ -651,6 +657,7 @@ var require_lib = __commonJS({
651
657
  });
652
658
  }
653
659
  const expressions = [...prefixStatements, ...block.expressions];
660
+ addParentPointers(prefixStatements, block);
654
661
  block = {
655
662
  ...block,
656
663
  expressions,
@@ -660,6 +667,7 @@ var require_lib = __commonJS({
660
667
  block.children = [[" {"], ...block.children, "}"];
661
668
  block.bare = false;
662
669
  }
670
+ updateParentPointers(block);
663
671
  }
664
672
  return block;
665
673
  }
@@ -677,10 +685,11 @@ var require_lib = __commonJS({
677
685
  const { ref, body } = expr;
678
686
  ref.type = "PipedExpression";
679
687
  ref.children = [makeLeftHandSideExpression(arg)];
680
- return {
688
+ updateParentPointers(ref);
689
+ return makeNode({
681
690
  type: "UnwrappedExpression",
682
691
  children: [skipIfOnlyWS(fn.leadingComment), body, skipIfOnlyWS(fn.trailingComment)]
683
- };
692
+ });
684
693
  }
685
694
  expr = fn.expr;
686
695
  const lhs = makeLeftHandSideExpression(expr);
@@ -894,6 +903,7 @@ var require_lib = __commonJS({
894
903
  if (subtype === "DoStatement") {
895
904
  insertReturn(block);
896
905
  children.splice(i, 1, ...wrapIIFE(["", statement, void 0], async));
906
+ updateParentPointers(exp);
897
907
  return;
898
908
  }
899
909
  const resultsRef = makeRef("results");
@@ -908,6 +918,7 @@ var require_lib = __commonJS({
908
918
  ["", wrapWithReturn(resultsRef)]
909
919
  ], async)
910
920
  );
921
+ updateParentPointers(exp);
911
922
  }
912
923
  function processBinaryOpExpression($0) {
913
924
  const expandedOps = expandChainedComparisons($0);
@@ -1201,10 +1212,10 @@ var require_lib = __commonJS({
1201
1212
  }
1202
1213
  function wrapWithReturn(expression) {
1203
1214
  const children = expression ? ["return ", expression] : ["return"];
1204
- return {
1215
+ return makeNode({
1205
1216
  type: "ReturnStatement",
1206
1217
  children
1207
- };
1218
+ });
1208
1219
  }
1209
1220
  function isExistence(exp) {
1210
1221
  if (exp.type === "ParenthesizedExpression" && exp.implicit) {
@@ -1499,6 +1510,7 @@ var require_lib = __commonJS({
1499
1510
  const indent = expressions[index][0];
1500
1511
  expressions.splice(index, 0, [indent, dec, ";"]);
1501
1512
  }
1513
+ addParentPointers(dec, block);
1502
1514
  }
1503
1515
  function patternAsValue(pattern) {
1504
1516
  switch (pattern.type) {
@@ -1577,7 +1589,8 @@ var require_lib = __commonJS({
1577
1589
  case "Declaration":
1578
1590
  exp.children.push(["", {
1579
1591
  type: "ReturnStatement",
1580
- children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)]
1592
+ children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)],
1593
+ parent: exp
1581
1594
  }]);
1582
1595
  return;
1583
1596
  case "FunctionExpression":
@@ -1586,7 +1599,8 @@ var require_lib = __commonJS({
1586
1599
  "",
1587
1600
  {
1588
1601
  type: "ReturnStatement",
1589
- children: [";return ", exp.id]
1602
+ children: [";return ", exp.id],
1603
+ parent: exp
1590
1604
  }
1591
1605
  ]);
1592
1606
  return;
@@ -1608,7 +1622,8 @@ var require_lib = __commonJS({
1608
1622
  exp.children.push(["", {
1609
1623
  type: "ReturnStatement",
1610
1624
  // NOTE: add a prefixed semi-colon because the if block may not be braced
1611
- children: [";return"]
1625
+ children: [";return"],
1626
+ parent: exp
1612
1627
  }]);
1613
1628
  return;
1614
1629
  case "PatternMatchingStatement":
@@ -2028,14 +2043,13 @@ var require_lib = __commonJS({
2028
2043
  case "ThrowExpression":
2029
2044
  case "TryExpression":
2030
2045
  return expression;
2031
- default:
2032
- return {
2033
- type: "ParenthesizedExpression",
2034
- children: ["(", expression, ")"],
2035
- expression,
2036
- implicit: true
2037
- };
2038
2046
  }
2047
+ return makeNode({
2048
+ type: "ParenthesizedExpression",
2049
+ children: ["(", expression, ")"],
2050
+ expression,
2051
+ implicit: true
2052
+ });
2039
2053
  }
2040
2054
  function modifyString(str) {
2041
2055
  return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
@@ -2242,7 +2256,7 @@ var require_lib = __commonJS({
2242
2256
  splices = splices.map((s) => [", ", s]);
2243
2257
  thisAssignments = thisAssignments.map((a) => ["", a, ";"]);
2244
2258
  const initializer = [ws, assign, e];
2245
- const binding = {
2259
+ const binding = makeNode({
2246
2260
  type: "Binding",
2247
2261
  pattern: id,
2248
2262
  initializer,
@@ -2250,9 +2264,9 @@ var require_lib = __commonJS({
2250
2264
  suffix,
2251
2265
  thisAssignments,
2252
2266
  children: [id, suffix, initializer]
2253
- };
2267
+ });
2254
2268
  const children = [decl, binding];
2255
- return {
2269
+ return makeNode({
2256
2270
  type: "Declaration",
2257
2271
  names: id.names,
2258
2272
  decl,
@@ -2260,9 +2274,9 @@ var require_lib = __commonJS({
2260
2274
  splices,
2261
2275
  thisAssignments,
2262
2276
  children
2263
- };
2277
+ });
2264
2278
  }
2265
- function processDeclarationCondition(condition, rootCondition) {
2279
+ function processDeclarationCondition(condition, rootCondition, parent) {
2266
2280
  if (!(condition.type === "DeclarationCondition")) {
2267
2281
  return;
2268
2282
  }
@@ -2281,6 +2295,7 @@ var require_lib = __commonJS({
2281
2295
  pattern,
2282
2296
  ref
2283
2297
  });
2298
+ addParentPointers(condition, parent);
2284
2299
  Object.assign(rootCondition, {
2285
2300
  blockPrefix: [
2286
2301
  ["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
@@ -2304,7 +2319,7 @@ var require_lib = __commonJS({
2304
2319
  const type = [type1, type2];
2305
2320
  expression = expression2;
2306
2321
  }
2307
- processDeclarationCondition(expression, condition.expression);
2322
+ processDeclarationCondition(expression, condition.expression, s);
2308
2323
  const { ref, pattern } = expression;
2309
2324
  if (pattern) {
2310
2325
  let conditions = [];
@@ -2354,10 +2369,12 @@ var require_lib = __commonJS({
2354
2369
  parent: s
2355
2370
  };
2356
2371
  s.children[1] = s.condition;
2372
+ updateParentPointers(s);
2357
2373
  const block = blockWithPrefix([["", [{
2358
2374
  type: "Declaration",
2359
2375
  children: ["let ", ...condition.expression.children]
2360
2376
  }], ";"], ...blockPrefix], makeEmptyBlock());
2377
+ updateParentPointers(block, s.parent);
2361
2378
  replaceBlockExpression(s.parent, s, block);
2362
2379
  block.expressions.push(["", s]);
2363
2380
  s.parent = block;
@@ -3590,12 +3607,12 @@ var require_lib = __commonJS({
3590
3607
  children: ["await "]
3591
3608
  };
3592
3609
  }
3593
- const block = {
3610
+ const block = makeNode({
3594
3611
  type: "BlockStatement",
3595
3612
  expressions,
3596
3613
  children: ["{", expressions, "}"],
3597
3614
  bare: false
3598
- };
3615
+ });
3599
3616
  const parameters = {
3600
3617
  type: "Parameters",
3601
3618
  children: ["()"],
@@ -3607,7 +3624,7 @@ var require_lib = __commonJS({
3607
3624
  },
3608
3625
  returnType: void 0
3609
3626
  };
3610
- const fn = {
3627
+ const fn = makeNode({
3611
3628
  type: "ArrowFunction",
3612
3629
  signature,
3613
3630
  parameters,
@@ -3616,12 +3633,11 @@ var require_lib = __commonJS({
3616
3633
  async,
3617
3634
  block,
3618
3635
  children: [async, parameters, "=>", block]
3619
- };
3620
- updateParentPointers(block, fn);
3621
- const exp = {
3636
+ });
3637
+ const exp = makeNode({
3622
3638
  type: "CallExpression",
3623
3639
  children: [makeLeftHandSideExpression(fn), "()"]
3624
- };
3640
+ });
3625
3641
  if (prefix) {
3626
3642
  return [makeLeftHandSideExpression([prefix, exp])];
3627
3643
  }
@@ -4647,7 +4663,7 @@ var require_parser = __commonJS({
4647
4663
  var $R16 = $R(new RegExp("(?=\\p{ID_Start}|[_$^\xAB\xBB\u22D9\u2264\u2265\u2208\u220B\u2209\u220C\u2263\u2261\u2262\u2260=\u2016\u2047&|*\\/!?%<>+-])", "suy"));
4648
4664
  var $R17 = $R(new RegExp("<(?!\\p{ID_Start}|[_$])", "suy"));
4649
4665
  var $R18 = $R(new RegExp("!\\^\\^?", "suy"));
4650
- var $R19 = $R(new RegExp("(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*[&.])", "suy"));
4666
+ var $R19 = $R(new RegExp("(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*(&|\\.[^0-9]))", "suy"));
4651
4667
  var $R20 = $R(new RegExp("(?=for|if|loop|unless|until|while)", "suy"));
4652
4668
  var $R21 = $R(new RegExp("(?=loop|do|for|until|while)", "suy"));
4653
4669
  var $R22 = $R(new RegExp("(?=[\\s\\),])", "suy"));
@@ -4711,12 +4727,11 @@ var require_parser = __commonJS({
4711
4727
  var $R80 = $R(new RegExp("#![^\\r\\n]*", "suy"));
4712
4728
  var $R81 = $R(new RegExp("[\\t ]*", "suy"));
4713
4729
  var $R82 = $R(new RegExp("[ \\t]*", "suy"));
4714
- var $R83 = $R(new RegExp("\\r\\n|\\r|\\n", "suy"));
4715
- var $R84 = $R(new RegExp("[\\s]*", "suy"));
4716
- var $R85 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
4717
- var $R86 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
4718
- var $R87 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
4719
- var $R88 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
4730
+ var $R83 = $R(new RegExp("[\\s]*", "suy"));
4731
+ var $R84 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
4732
+ var $R85 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
4733
+ var $R86 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
4734
+ var $R87 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
4720
4735
  var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4721
4736
  var statements = $4;
4722
4737
  processProgram({
@@ -8406,7 +8421,7 @@ var require_parser = __commonJS({
8406
8421
  function Xnor(ctx, state) {
8407
8422
  return $EVENT_C(ctx, state, "Xnor", Xnor$$);
8408
8423
  }
8409
- var UnaryOp$0 = $TR($EXPECT($R19, "UnaryOp /(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*[&.])/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
8424
+ var UnaryOp$0 = $TR($EXPECT($R19, "UnaryOp /(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*(&|\\.[^0-9]))/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
8410
8425
  return { $loc, token: $0 };
8411
8426
  });
8412
8427
  var UnaryOp$1 = AwaitOp;
@@ -12423,21 +12438,19 @@ var require_parser = __commonJS({
12423
12438
  function Shebang(ctx, state) {
12424
12439
  return $EVENT(ctx, state, "Shebang", Shebang$0);
12425
12440
  }
12426
- var CivetPrologue$0 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
12427
- var content = $3;
12428
- var eos = $8;
12429
- return { ...content, children: [...content.children, eos] };
12441
+ var CivetPrologue$0 = $T($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $C(EOL, $Y(RestOfLine))), function(value) {
12442
+ var content = value[2];
12443
+ return content;
12430
12444
  });
12431
- var CivetPrologue$1 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
12432
- var content = $3;
12433
- var eos = $8;
12434
- return { ...content, children: [...content.children, eos] };
12445
+ var CivetPrologue$1 = $T($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $C(EOL, $Y(RestOfLine))), function(value) {
12446
+ var content = value[2];
12447
+ return content;
12435
12448
  });
12436
12449
  var CivetPrologue$$ = [CivetPrologue$0, CivetPrologue$1];
12437
12450
  function CivetPrologue(ctx, state) {
12438
12451
  return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
12439
12452
  }
12440
- var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R84, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12453
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R83, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12441
12454
  var options = $3;
12442
12455
  return {
12443
12456
  type: "CivetPrologue",
@@ -12448,7 +12461,7 @@ var require_parser = __commonJS({
12448
12461
  function CivetPrologueContent(ctx, state) {
12449
12462
  return $EVENT(ctx, state, "CivetPrologueContent", CivetPrologueContent$0);
12450
12463
  }
12451
- var CivetOption$0 = $TR($EXPECT($R85, "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) {
12464
+ var CivetOption$0 = $TR($EXPECT($R84, "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) {
12452
12465
  const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
12453
12466
  if (l)
12454
12467
  return l.toUpperCase();
@@ -12469,7 +12482,7 @@ var require_parser = __commonJS({
12469
12482
  function UnknownPrologue(ctx, state) {
12470
12483
  return $EVENT(ctx, state, "UnknownPrologue", UnknownPrologue$0);
12471
12484
  }
12472
- var TripleSlashDirective$0 = $S($R$0($EXPECT($R86, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
12485
+ var TripleSlashDirective$0 = $S($R$0($EXPECT($R85, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
12473
12486
  function TripleSlashDirective(ctx, state) {
12474
12487
  return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
12475
12488
  }
@@ -12483,13 +12496,13 @@ var require_parser = __commonJS({
12483
12496
  function PrologueString(ctx, state) {
12484
12497
  return $EVENT_C(ctx, state, "PrologueString", PrologueString$$);
12485
12498
  }
12486
- var EOS$0 = $T($S($EXPECT($R87, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
12499
+ var EOS$0 = $T($S($EXPECT($R86, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
12487
12500
  return value[1];
12488
12501
  });
12489
12502
  function EOS(ctx, state) {
12490
12503
  return $EVENT(ctx, state, "EOS", EOS$0);
12491
12504
  }
12492
- var EOL$0 = $TR($EXPECT($R88, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12505
+ var EOL$0 = $TR($EXPECT($R87, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12493
12506
  return { $loc, token: $0 };
12494
12507
  });
12495
12508
  function EOL(ctx, state) {
package/dist/main.mjs CHANGED
@@ -496,6 +496,7 @@ var require_lib = __commonJS({
496
496
  }
497
497
  return;
498
498
  }
499
+ node = node;
499
500
  node.parent = parent;
500
501
  if (node.children) {
501
502
  for (const child of node.children) {
@@ -514,6 +515,7 @@ var require_lib = __commonJS({
514
515
  }
515
516
  return;
516
517
  }
518
+ node = node;
517
519
  if (parent != null)
518
520
  node.parent = parent;
519
521
  if (depth && node.children) {
@@ -522,20 +524,24 @@ var require_lib = __commonJS({
522
524
  }
523
525
  }
524
526
  }
527
+ function makeNode(node) {
528
+ updateParentPointers(node);
529
+ return node;
530
+ }
525
531
  function addPostfixStatement(statement, ws, post) {
526
532
  const expressions = [
527
533
  ...post.blockPrefix || [],
528
534
  ["", statement]
529
535
  ];
530
- const block = {
536
+ const block = makeNode({
531
537
  type: "BlockStatement",
532
538
  children: [" { ", expressions, " }"],
533
539
  expressions
534
- };
540
+ });
535
541
  const children = [...post.children, block];
536
542
  if (!isWhitespaceOrEmpty(ws))
537
543
  children.push(ws);
538
- post = { ...post, children, block };
544
+ post = makeNode({ ...post, children, block });
539
545
  if (post.type === "IfStatement") {
540
546
  post.then = block;
541
547
  }
@@ -649,6 +655,7 @@ var require_lib = __commonJS({
649
655
  });
650
656
  }
651
657
  const expressions = [...prefixStatements, ...block.expressions];
658
+ addParentPointers(prefixStatements, block);
652
659
  block = {
653
660
  ...block,
654
661
  expressions,
@@ -658,6 +665,7 @@ var require_lib = __commonJS({
658
665
  block.children = [[" {"], ...block.children, "}"];
659
666
  block.bare = false;
660
667
  }
668
+ updateParentPointers(block);
661
669
  }
662
670
  return block;
663
671
  }
@@ -675,10 +683,11 @@ var require_lib = __commonJS({
675
683
  const { ref, body } = expr;
676
684
  ref.type = "PipedExpression";
677
685
  ref.children = [makeLeftHandSideExpression(arg)];
678
- return {
686
+ updateParentPointers(ref);
687
+ return makeNode({
679
688
  type: "UnwrappedExpression",
680
689
  children: [skipIfOnlyWS(fn.leadingComment), body, skipIfOnlyWS(fn.trailingComment)]
681
- };
690
+ });
682
691
  }
683
692
  expr = fn.expr;
684
693
  const lhs = makeLeftHandSideExpression(expr);
@@ -892,6 +901,7 @@ var require_lib = __commonJS({
892
901
  if (subtype === "DoStatement") {
893
902
  insertReturn(block);
894
903
  children.splice(i, 1, ...wrapIIFE(["", statement, void 0], async));
904
+ updateParentPointers(exp);
895
905
  return;
896
906
  }
897
907
  const resultsRef = makeRef("results");
@@ -906,6 +916,7 @@ var require_lib = __commonJS({
906
916
  ["", wrapWithReturn(resultsRef)]
907
917
  ], async)
908
918
  );
919
+ updateParentPointers(exp);
909
920
  }
910
921
  function processBinaryOpExpression($0) {
911
922
  const expandedOps = expandChainedComparisons($0);
@@ -1199,10 +1210,10 @@ var require_lib = __commonJS({
1199
1210
  }
1200
1211
  function wrapWithReturn(expression) {
1201
1212
  const children = expression ? ["return ", expression] : ["return"];
1202
- return {
1213
+ return makeNode({
1203
1214
  type: "ReturnStatement",
1204
1215
  children
1205
- };
1216
+ });
1206
1217
  }
1207
1218
  function isExistence(exp) {
1208
1219
  if (exp.type === "ParenthesizedExpression" && exp.implicit) {
@@ -1497,6 +1508,7 @@ var require_lib = __commonJS({
1497
1508
  const indent = expressions[index][0];
1498
1509
  expressions.splice(index, 0, [indent, dec, ";"]);
1499
1510
  }
1511
+ addParentPointers(dec, block);
1500
1512
  }
1501
1513
  function patternAsValue(pattern) {
1502
1514
  switch (pattern.type) {
@@ -1575,7 +1587,8 @@ var require_lib = __commonJS({
1575
1587
  case "Declaration":
1576
1588
  exp.children.push(["", {
1577
1589
  type: "ReturnStatement",
1578
- children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)]
1590
+ children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)],
1591
+ parent: exp
1579
1592
  }]);
1580
1593
  return;
1581
1594
  case "FunctionExpression":
@@ -1584,7 +1597,8 @@ var require_lib = __commonJS({
1584
1597
  "",
1585
1598
  {
1586
1599
  type: "ReturnStatement",
1587
- children: [";return ", exp.id]
1600
+ children: [";return ", exp.id],
1601
+ parent: exp
1588
1602
  }
1589
1603
  ]);
1590
1604
  return;
@@ -1606,7 +1620,8 @@ var require_lib = __commonJS({
1606
1620
  exp.children.push(["", {
1607
1621
  type: "ReturnStatement",
1608
1622
  // NOTE: add a prefixed semi-colon because the if block may not be braced
1609
- children: [";return"]
1623
+ children: [";return"],
1624
+ parent: exp
1610
1625
  }]);
1611
1626
  return;
1612
1627
  case "PatternMatchingStatement":
@@ -2026,14 +2041,13 @@ var require_lib = __commonJS({
2026
2041
  case "ThrowExpression":
2027
2042
  case "TryExpression":
2028
2043
  return expression;
2029
- default:
2030
- return {
2031
- type: "ParenthesizedExpression",
2032
- children: ["(", expression, ")"],
2033
- expression,
2034
- implicit: true
2035
- };
2036
2044
  }
2045
+ return makeNode({
2046
+ type: "ParenthesizedExpression",
2047
+ children: ["(", expression, ")"],
2048
+ expression,
2049
+ implicit: true
2050
+ });
2037
2051
  }
2038
2052
  function modifyString(str) {
2039
2053
  return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
@@ -2240,7 +2254,7 @@ var require_lib = __commonJS({
2240
2254
  splices = splices.map((s) => [", ", s]);
2241
2255
  thisAssignments = thisAssignments.map((a) => ["", a, ";"]);
2242
2256
  const initializer = [ws, assign, e];
2243
- const binding = {
2257
+ const binding = makeNode({
2244
2258
  type: "Binding",
2245
2259
  pattern: id,
2246
2260
  initializer,
@@ -2248,9 +2262,9 @@ var require_lib = __commonJS({
2248
2262
  suffix,
2249
2263
  thisAssignments,
2250
2264
  children: [id, suffix, initializer]
2251
- };
2265
+ });
2252
2266
  const children = [decl, binding];
2253
- return {
2267
+ return makeNode({
2254
2268
  type: "Declaration",
2255
2269
  names: id.names,
2256
2270
  decl,
@@ -2258,9 +2272,9 @@ var require_lib = __commonJS({
2258
2272
  splices,
2259
2273
  thisAssignments,
2260
2274
  children
2261
- };
2275
+ });
2262
2276
  }
2263
- function processDeclarationCondition(condition, rootCondition) {
2277
+ function processDeclarationCondition(condition, rootCondition, parent) {
2264
2278
  if (!(condition.type === "DeclarationCondition")) {
2265
2279
  return;
2266
2280
  }
@@ -2279,6 +2293,7 @@ var require_lib = __commonJS({
2279
2293
  pattern,
2280
2294
  ref
2281
2295
  });
2296
+ addParentPointers(condition, parent);
2282
2297
  Object.assign(rootCondition, {
2283
2298
  blockPrefix: [
2284
2299
  ["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
@@ -2302,7 +2317,7 @@ var require_lib = __commonJS({
2302
2317
  const type = [type1, type2];
2303
2318
  expression = expression2;
2304
2319
  }
2305
- processDeclarationCondition(expression, condition.expression);
2320
+ processDeclarationCondition(expression, condition.expression, s);
2306
2321
  const { ref, pattern } = expression;
2307
2322
  if (pattern) {
2308
2323
  let conditions = [];
@@ -2352,10 +2367,12 @@ var require_lib = __commonJS({
2352
2367
  parent: s
2353
2368
  };
2354
2369
  s.children[1] = s.condition;
2370
+ updateParentPointers(s);
2355
2371
  const block = blockWithPrefix([["", [{
2356
2372
  type: "Declaration",
2357
2373
  children: ["let ", ...condition.expression.children]
2358
2374
  }], ";"], ...blockPrefix], makeEmptyBlock());
2375
+ updateParentPointers(block, s.parent);
2359
2376
  replaceBlockExpression(s.parent, s, block);
2360
2377
  block.expressions.push(["", s]);
2361
2378
  s.parent = block;
@@ -3588,12 +3605,12 @@ var require_lib = __commonJS({
3588
3605
  children: ["await "]
3589
3606
  };
3590
3607
  }
3591
- const block = {
3608
+ const block = makeNode({
3592
3609
  type: "BlockStatement",
3593
3610
  expressions,
3594
3611
  children: ["{", expressions, "}"],
3595
3612
  bare: false
3596
- };
3613
+ });
3597
3614
  const parameters = {
3598
3615
  type: "Parameters",
3599
3616
  children: ["()"],
@@ -3605,7 +3622,7 @@ var require_lib = __commonJS({
3605
3622
  },
3606
3623
  returnType: void 0
3607
3624
  };
3608
- const fn = {
3625
+ const fn = makeNode({
3609
3626
  type: "ArrowFunction",
3610
3627
  signature,
3611
3628
  parameters,
@@ -3614,12 +3631,11 @@ var require_lib = __commonJS({
3614
3631
  async,
3615
3632
  block,
3616
3633
  children: [async, parameters, "=>", block]
3617
- };
3618
- updateParentPointers(block, fn);
3619
- const exp = {
3634
+ });
3635
+ const exp = makeNode({
3620
3636
  type: "CallExpression",
3621
3637
  children: [makeLeftHandSideExpression(fn), "()"]
3622
- };
3638
+ });
3623
3639
  if (prefix) {
3624
3640
  return [makeLeftHandSideExpression([prefix, exp])];
3625
3641
  }
@@ -4645,7 +4661,7 @@ var require_parser = __commonJS({
4645
4661
  var $R16 = $R(new RegExp("(?=\\p{ID_Start}|[_$^\xAB\xBB\u22D9\u2264\u2265\u2208\u220B\u2209\u220C\u2263\u2261\u2262\u2260=\u2016\u2047&|*\\/!?%<>+-])", "suy"));
4646
4662
  var $R17 = $R(new RegExp("<(?!\\p{ID_Start}|[_$])", "suy"));
4647
4663
  var $R18 = $R(new RegExp("!\\^\\^?", "suy"));
4648
- var $R19 = $R(new RegExp("(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*[&.])", "suy"));
4664
+ var $R19 = $R(new RegExp("(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*(&|\\.[^0-9]))", "suy"));
4649
4665
  var $R20 = $R(new RegExp("(?=for|if|loop|unless|until|while)", "suy"));
4650
4666
  var $R21 = $R(new RegExp("(?=loop|do|for|until|while)", "suy"));
4651
4667
  var $R22 = $R(new RegExp("(?=[\\s\\),])", "suy"));
@@ -4709,12 +4725,11 @@ var require_parser = __commonJS({
4709
4725
  var $R80 = $R(new RegExp("#![^\\r\\n]*", "suy"));
4710
4726
  var $R81 = $R(new RegExp("[\\t ]*", "suy"));
4711
4727
  var $R82 = $R(new RegExp("[ \\t]*", "suy"));
4712
- var $R83 = $R(new RegExp("\\r\\n|\\r|\\n", "suy"));
4713
- var $R84 = $R(new RegExp("[\\s]*", "suy"));
4714
- var $R85 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
4715
- var $R86 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
4716
- var $R87 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
4717
- var $R88 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
4728
+ var $R83 = $R(new RegExp("[\\s]*", "suy"));
4729
+ var $R84 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
4730
+ var $R85 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
4731
+ var $R86 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
4732
+ var $R87 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
4718
4733
  var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4719
4734
  var statements = $4;
4720
4735
  processProgram({
@@ -8404,7 +8419,7 @@ var require_parser = __commonJS({
8404
8419
  function Xnor(ctx, state) {
8405
8420
  return $EVENT_C(ctx, state, "Xnor", Xnor$$);
8406
8421
  }
8407
- var UnaryOp$0 = $TR($EXPECT($R19, "UnaryOp /(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*[&.])/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
8422
+ var UnaryOp$0 = $TR($EXPECT($R19, "UnaryOp /(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*(&|\\.[^0-9]))/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
8408
8423
  return { $loc, token: $0 };
8409
8424
  });
8410
8425
  var UnaryOp$1 = AwaitOp;
@@ -12421,21 +12436,19 @@ var require_parser = __commonJS({
12421
12436
  function Shebang(ctx, state) {
12422
12437
  return $EVENT(ctx, state, "Shebang", Shebang$0);
12423
12438
  }
12424
- var CivetPrologue$0 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
12425
- var content = $3;
12426
- var eos = $8;
12427
- return { ...content, children: [...content.children, eos] };
12439
+ var CivetPrologue$0 = $T($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $C(EOL, $Y(RestOfLine))), function(value) {
12440
+ var content = value[2];
12441
+ return content;
12428
12442
  });
12429
- var CivetPrologue$1 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
12430
- var content = $3;
12431
- var eos = $8;
12432
- return { ...content, children: [...content.children, eos] };
12443
+ var CivetPrologue$1 = $T($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $C(EOL, $Y(RestOfLine))), function(value) {
12444
+ var content = value[2];
12445
+ return content;
12433
12446
  });
12434
12447
  var CivetPrologue$$ = [CivetPrologue$0, CivetPrologue$1];
12435
12448
  function CivetPrologue(ctx, state) {
12436
12449
  return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
12437
12450
  }
12438
- var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R84, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12451
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R83, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12439
12452
  var options = $3;
12440
12453
  return {
12441
12454
  type: "CivetPrologue",
@@ -12446,7 +12459,7 @@ var require_parser = __commonJS({
12446
12459
  function CivetPrologueContent(ctx, state) {
12447
12460
  return $EVENT(ctx, state, "CivetPrologueContent", CivetPrologueContent$0);
12448
12461
  }
12449
- var CivetOption$0 = $TR($EXPECT($R85, "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) {
12462
+ var CivetOption$0 = $TR($EXPECT($R84, "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) {
12450
12463
  const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
12451
12464
  if (l)
12452
12465
  return l.toUpperCase();
@@ -12467,7 +12480,7 @@ var require_parser = __commonJS({
12467
12480
  function UnknownPrologue(ctx, state) {
12468
12481
  return $EVENT(ctx, state, "UnknownPrologue", UnknownPrologue$0);
12469
12482
  }
12470
- var TripleSlashDirective$0 = $S($R$0($EXPECT($R86, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
12483
+ var TripleSlashDirective$0 = $S($R$0($EXPECT($R85, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
12471
12484
  function TripleSlashDirective(ctx, state) {
12472
12485
  return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
12473
12486
  }
@@ -12481,13 +12494,13 @@ var require_parser = __commonJS({
12481
12494
  function PrologueString(ctx, state) {
12482
12495
  return $EVENT_C(ctx, state, "PrologueString", PrologueString$$);
12483
12496
  }
12484
- var EOS$0 = $T($S($EXPECT($R87, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
12497
+ var EOS$0 = $T($S($EXPECT($R86, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
12485
12498
  return value[1];
12486
12499
  });
12487
12500
  function EOS(ctx, state) {
12488
12501
  return $EVENT(ctx, state, "EOS", EOS$0);
12489
12502
  }
12490
- var EOL$0 = $TR($EXPECT($R88, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12503
+ var EOL$0 = $TR($EXPECT($R87, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12491
12504
  return { $loc, token: $0 };
12492
12505
  });
12493
12506
  function EOL(ctx, state) {
package/dist/rollup.js CHANGED
@@ -177,6 +177,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
177
177
  return null;
178
178
  const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
179
179
  const code = await fs.promises.readFile(filename, "utf-8");
180
+ this.addWatchFile(filename);
180
181
  const compiled = import_civet.default.compile(code, {
181
182
  // inlineMap: true,
182
183
  filename: id,
@@ -146,6 +146,7 @@ var civetUnplugin = createUnplugin((options = {}) => {
146
146
  return null;
147
147
  const filename = path.resolve(process.cwd(), id.slice(0, -outExt.length));
148
148
  const code = await fs.promises.readFile(filename, "utf-8");
149
+ this.addWatchFile(filename);
149
150
  const compiled = civet.compile(code, {
150
151
  // inlineMap: true,
151
152
  filename: id,
package/dist/unplugin.js CHANGED
@@ -175,6 +175,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
175
175
  return null;
176
176
  const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
177
177
  const code = await fs.promises.readFile(filename, "utf-8");
178
+ this.addWatchFile(filename);
178
179
  const compiled = import_civet.default.compile(code, {
179
180
  // inlineMap: true,
180
181
  filename: id,
package/dist/vite.js CHANGED
@@ -177,6 +177,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
177
177
  return null;
178
178
  const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
179
179
  const code = await fs.promises.readFile(filename, "utf-8");
180
+ this.addWatchFile(filename);
180
181
  const compiled = import_civet.default.compile(code, {
181
182
  // inlineMap: true,
182
183
  filename: id,
package/dist/webpack.js CHANGED
@@ -177,6 +177,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
177
177
  return null;
178
178
  const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
179
179
  const code = await fs.promises.readFile(filename, "utf-8");
180
+ this.addWatchFile(filename);
180
181
  const compiled = import_civet.default.compile(code, {
181
182
  // inlineMap: true,
182
183
  filename: id,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.6.47",
4
+ "version": "0.6.49",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",