@herb-tools/core 0.6.0 → 0.7.0

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.
@@ -129,7 +129,7 @@ class Token {
129
129
  }
130
130
 
131
131
  // NOTE: This file is generated by the templates/template.rb script and should not
132
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.0/templates/javascript/packages/core/src/errors.ts.erb
132
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.0/templates/javascript/packages/core/src/errors.ts.erb
133
133
  class HerbError {
134
134
  type;
135
135
  message;
@@ -586,7 +586,7 @@ function convertToUTF8(string) {
586
586
  }
587
587
 
588
588
  // NOTE: This file is generated by the templates/template.rb script and should not
589
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.0/templates/javascript/packages/core/src/nodes.ts.erb
589
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.0/templates/javascript/packages/core/src/nodes.ts.erb
590
590
  class Node {
591
591
  type;
592
592
  location;
@@ -594,6 +594,9 @@ class Node {
594
594
  static from(node) {
595
595
  return fromSerializedNode(node);
596
596
  }
597
+ static get type() {
598
+ throw new Error("AST_NODE");
599
+ }
597
600
  constructor(type, location, errors) {
598
601
  this.type = type;
599
602
  this.location = location;
@@ -609,6 +612,12 @@ class Node {
609
612
  inspect() {
610
613
  return this.treeInspect(0);
611
614
  }
615
+ is(nodeClass) {
616
+ return this.type === nodeClass.type;
617
+ }
618
+ isOfType(type) {
619
+ return this.type === type;
620
+ }
612
621
  get isSingleLine() {
613
622
  return this.location.start.line === this.location.end.line;
614
623
  }
@@ -617,7 +626,7 @@ class Node {
617
626
  return "∅\n";
618
627
  if (array.length === 0)
619
628
  return "[]\n";
620
- let output = `(${array.length} item${array.length == 1 ? "" : "s"})\n`;
629
+ let output = `(${array.length} item${array.length === 1 ? "" : "s"})\n`;
621
630
  array.forEach((item, index) => {
622
631
  const isLast = index === array.length - 1;
623
632
  if (item instanceof Node || item instanceof HerbError) {
@@ -641,7 +650,7 @@ class Node {
641
650
  .treeInspect()
642
651
  .trimStart()
643
652
  .split("\n")
644
- .map((line, index) => index == 0 ? line.trimStart() : `${prefix}${prefix2}${line}`)
653
+ .map((line, index) => index === 0 ? line.trimStart() : `${prefix}${prefix2}${line}`)
645
654
  .join("\n")
646
655
  .trimStart();
647
656
  output += `\n`;
@@ -650,6 +659,9 @@ class Node {
650
659
  }
651
660
  class DocumentNode extends Node {
652
661
  children;
662
+ static get type() {
663
+ return "AST_DOCUMENT_NODE";
664
+ }
653
665
  static from(data) {
654
666
  return new DocumentNode({
655
667
  type: data.type,
@@ -696,6 +708,9 @@ class DocumentNode extends Node {
696
708
  }
697
709
  class LiteralNode extends Node {
698
710
  content;
711
+ static get type() {
712
+ return "AST_LITERAL_NODE";
713
+ }
699
714
  static from(data) {
700
715
  return new LiteralNode({
701
716
  type: data.type,
@@ -743,6 +758,9 @@ class HTMLOpenTagNode extends Node {
743
758
  tag_closing;
744
759
  children;
745
760
  is_void;
761
+ static get type() {
762
+ return "AST_HTML_OPEN_TAG_NODE";
763
+ }
746
764
  static from(data) {
747
765
  return new HTMLOpenTagNode({
748
766
  type: data.type,
@@ -808,6 +826,9 @@ class HTMLCloseTagNode extends Node {
808
826
  tag_name;
809
827
  children;
810
828
  tag_closing;
829
+ static get type() {
830
+ return "AST_HTML_CLOSE_TAG_NODE";
831
+ }
811
832
  static from(data) {
812
833
  return new HTMLCloseTagNode({
813
834
  type: data.type,
@@ -870,6 +891,10 @@ class HTMLElementNode extends Node {
870
891
  body;
871
892
  close_tag;
872
893
  is_void;
894
+ source;
895
+ static get type() {
896
+ return "AST_HTML_ELEMENT_NODE";
897
+ }
873
898
  static from(data) {
874
899
  return new HTMLElementNode({
875
900
  type: data.type,
@@ -880,6 +905,7 @@ class HTMLElementNode extends Node {
880
905
  body: (data.body || []).map(node => fromSerializedNode(node)),
881
906
  close_tag: data.close_tag ? fromSerializedNode((data.close_tag)) : null,
882
907
  is_void: data.is_void,
908
+ source: data.source,
883
909
  });
884
910
  }
885
911
  constructor(props) {
@@ -889,6 +915,7 @@ class HTMLElementNode extends Node {
889
915
  this.body = props.body;
890
916
  this.close_tag = props.close_tag;
891
917
  this.is_void = props.is_void;
918
+ this.source = props.source;
892
919
  }
893
920
  accept(visitor) {
894
921
  visitor.visitHTMLElementNode(this);
@@ -920,6 +947,7 @@ class HTMLElementNode extends Node {
920
947
  body: this.body.map(node => node.toJSON()),
921
948
  close_tag: this.close_tag ? this.close_tag.toJSON() : null,
922
949
  is_void: this.is_void,
950
+ source: this.source,
923
951
  };
924
952
  }
925
953
  treeInspect() {
@@ -930,7 +958,8 @@ class HTMLElementNode extends Node {
930
958
  output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`;
931
959
  output += `├── body: ${this.inspectArray(this.body, "│ ")}`;
932
960
  output += `├── close_tag: ${this.inspectNode(this.close_tag, "│ ")}`;
933
- output += `└── is_void: ${typeof this.is_void === 'boolean' ? String(this.is_void) : "∅"}\n`;
961
+ output += `├── is_void: ${typeof this.is_void === 'boolean' ? String(this.is_void) : "∅"}\n`;
962
+ output += `└── source: ${this.source ? JSON.stringify(this.source) : "∅"}\n`;
934
963
  return output;
935
964
  }
936
965
  }
@@ -939,6 +968,9 @@ class HTMLAttributeValueNode extends Node {
939
968
  children;
940
969
  close_quote;
941
970
  quoted;
971
+ static get type() {
972
+ return "AST_HTML_ATTRIBUTE_VALUE_NODE";
973
+ }
942
974
  static from(data) {
943
975
  return new HTMLAttributeValueNode({
944
976
  type: data.type,
@@ -997,6 +1029,9 @@ class HTMLAttributeValueNode extends Node {
997
1029
  }
998
1030
  class HTMLAttributeNameNode extends Node {
999
1031
  children;
1032
+ static get type() {
1033
+ return "AST_HTML_ATTRIBUTE_NAME_NODE";
1034
+ }
1000
1035
  static from(data) {
1001
1036
  return new HTMLAttributeNameNode({
1002
1037
  type: data.type,
@@ -1045,6 +1080,9 @@ class HTMLAttributeNode extends Node {
1045
1080
  name;
1046
1081
  equals;
1047
1082
  value;
1083
+ static get type() {
1084
+ return "AST_HTML_ATTRIBUTE_NODE";
1085
+ }
1048
1086
  static from(data) {
1049
1087
  return new HTMLAttributeNode({
1050
1088
  type: data.type,
@@ -1101,6 +1139,9 @@ class HTMLAttributeNode extends Node {
1101
1139
  }
1102
1140
  class HTMLTextNode extends Node {
1103
1141
  content;
1142
+ static get type() {
1143
+ return "AST_HTML_TEXT_NODE";
1144
+ }
1104
1145
  static from(data) {
1105
1146
  return new HTMLTextNode({
1106
1147
  type: data.type,
@@ -1146,6 +1187,9 @@ class HTMLCommentNode extends Node {
1146
1187
  comment_start;
1147
1188
  children;
1148
1189
  comment_end;
1190
+ static get type() {
1191
+ return "AST_HTML_COMMENT_NODE";
1192
+ }
1149
1193
  static from(data) {
1150
1194
  return new HTMLCommentNode({
1151
1195
  type: data.type,
@@ -1202,6 +1246,9 @@ class HTMLDoctypeNode extends Node {
1202
1246
  tag_opening;
1203
1247
  children;
1204
1248
  tag_closing;
1249
+ static get type() {
1250
+ return "AST_HTML_DOCTYPE_NODE";
1251
+ }
1205
1252
  static from(data) {
1206
1253
  return new HTMLDoctypeNode({
1207
1254
  type: data.type,
@@ -1258,6 +1305,9 @@ class XMLDeclarationNode extends Node {
1258
1305
  tag_opening;
1259
1306
  children;
1260
1307
  tag_closing;
1308
+ static get type() {
1309
+ return "AST_XML_DECLARATION_NODE";
1310
+ }
1261
1311
  static from(data) {
1262
1312
  return new XMLDeclarationNode({
1263
1313
  type: data.type,
@@ -1314,6 +1364,9 @@ class CDATANode extends Node {
1314
1364
  tag_opening;
1315
1365
  children;
1316
1366
  tag_closing;
1367
+ static get type() {
1368
+ return "AST_CDATA_NODE";
1369
+ }
1317
1370
  static from(data) {
1318
1371
  return new CDATANode({
1319
1372
  type: data.type,
@@ -1368,6 +1421,9 @@ class CDATANode extends Node {
1368
1421
  }
1369
1422
  class WhitespaceNode extends Node {
1370
1423
  value;
1424
+ static get type() {
1425
+ return "AST_WHITESPACE_NODE";
1426
+ }
1371
1427
  static from(data) {
1372
1428
  return new WhitespaceNode({
1373
1429
  type: data.type,
@@ -1416,6 +1472,9 @@ class ERBContentNode extends Node {
1416
1472
  // no-op for analyzed_ruby
1417
1473
  parsed;
1418
1474
  valid;
1475
+ static get type() {
1476
+ return "AST_ERB_CONTENT_NODE";
1477
+ }
1419
1478
  static from(data) {
1420
1479
  return new ERBContentNode({
1421
1480
  type: data.type,
@@ -1481,6 +1540,9 @@ class ERBEndNode extends Node {
1481
1540
  tag_opening;
1482
1541
  content;
1483
1542
  tag_closing;
1543
+ static get type() {
1544
+ return "AST_ERB_END_NODE";
1545
+ }
1484
1546
  static from(data) {
1485
1547
  return new ERBEndNode({
1486
1548
  type: data.type,
@@ -1535,6 +1597,9 @@ class ERBElseNode extends Node {
1535
1597
  content;
1536
1598
  tag_closing;
1537
1599
  statements;
1600
+ static get type() {
1601
+ return "AST_ERB_ELSE_NODE";
1602
+ }
1538
1603
  static from(data) {
1539
1604
  return new ERBElseNode({
1540
1605
  type: data.type,
@@ -1598,6 +1663,9 @@ class ERBIfNode extends Node {
1598
1663
  statements;
1599
1664
  subsequent;
1600
1665
  end_node;
1666
+ static get type() {
1667
+ return "AST_ERB_IF_NODE";
1668
+ }
1601
1669
  static from(data) {
1602
1670
  return new ERBIfNode({
1603
1671
  type: data.type,
@@ -1672,6 +1740,9 @@ class ERBBlockNode extends Node {
1672
1740
  tag_closing;
1673
1741
  body;
1674
1742
  end_node;
1743
+ static get type() {
1744
+ return "AST_ERB_BLOCK_NODE";
1745
+ }
1675
1746
  static from(data) {
1676
1747
  return new ERBBlockNode({
1677
1748
  type: data.type,
@@ -1739,6 +1810,9 @@ class ERBWhenNode extends Node {
1739
1810
  content;
1740
1811
  tag_closing;
1741
1812
  statements;
1813
+ static get type() {
1814
+ return "AST_ERB_WHEN_NODE";
1815
+ }
1742
1816
  static from(data) {
1743
1817
  return new ERBWhenNode({
1744
1818
  type: data.type,
@@ -1803,6 +1877,9 @@ class ERBCaseNode extends Node {
1803
1877
  conditions;
1804
1878
  else_clause;
1805
1879
  end_node;
1880
+ static get type() {
1881
+ return "AST_ERB_CASE_NODE";
1882
+ }
1806
1883
  static from(data) {
1807
1884
  return new ERBCaseNode({
1808
1885
  type: data.type,
@@ -1885,6 +1962,9 @@ class ERBCaseMatchNode extends Node {
1885
1962
  conditions;
1886
1963
  else_clause;
1887
1964
  end_node;
1965
+ static get type() {
1966
+ return "AST_ERB_CASE_MATCH_NODE";
1967
+ }
1888
1968
  static from(data) {
1889
1969
  return new ERBCaseMatchNode({
1890
1970
  type: data.type,
@@ -1965,6 +2045,9 @@ class ERBWhileNode extends Node {
1965
2045
  tag_closing;
1966
2046
  statements;
1967
2047
  end_node;
2048
+ static get type() {
2049
+ return "AST_ERB_WHILE_NODE";
2050
+ }
1968
2051
  static from(data) {
1969
2052
  return new ERBWhileNode({
1970
2053
  type: data.type,
@@ -2033,6 +2116,9 @@ class ERBUntilNode extends Node {
2033
2116
  tag_closing;
2034
2117
  statements;
2035
2118
  end_node;
2119
+ static get type() {
2120
+ return "AST_ERB_UNTIL_NODE";
2121
+ }
2036
2122
  static from(data) {
2037
2123
  return new ERBUntilNode({
2038
2124
  type: data.type,
@@ -2101,6 +2187,9 @@ class ERBForNode extends Node {
2101
2187
  tag_closing;
2102
2188
  statements;
2103
2189
  end_node;
2190
+ static get type() {
2191
+ return "AST_ERB_FOR_NODE";
2192
+ }
2104
2193
  static from(data) {
2105
2194
  return new ERBForNode({
2106
2195
  type: data.type,
@@ -2169,6 +2258,9 @@ class ERBRescueNode extends Node {
2169
2258
  tag_closing;
2170
2259
  statements;
2171
2260
  subsequent;
2261
+ static get type() {
2262
+ return "AST_ERB_RESCUE_NODE";
2263
+ }
2172
2264
  static from(data) {
2173
2265
  return new ERBRescueNode({
2174
2266
  type: data.type,
@@ -2236,6 +2328,9 @@ class ERBEnsureNode extends Node {
2236
2328
  content;
2237
2329
  tag_closing;
2238
2330
  statements;
2331
+ static get type() {
2332
+ return "AST_ERB_ENSURE_NODE";
2333
+ }
2239
2334
  static from(data) {
2240
2335
  return new ERBEnsureNode({
2241
2336
  type: data.type,
@@ -2301,6 +2396,9 @@ class ERBBeginNode extends Node {
2301
2396
  else_clause;
2302
2397
  ensure_clause;
2303
2398
  end_node;
2399
+ static get type() {
2400
+ return "AST_ERB_BEGIN_NODE";
2401
+ }
2304
2402
  static from(data) {
2305
2403
  return new ERBBeginNode({
2306
2404
  type: data.type,
@@ -2388,6 +2486,9 @@ class ERBUnlessNode extends Node {
2388
2486
  statements;
2389
2487
  else_clause;
2390
2488
  end_node;
2489
+ static get type() {
2490
+ return "AST_ERB_UNLESS_NODE";
2491
+ }
2391
2492
  static from(data) {
2392
2493
  return new ERBUnlessNode({
2393
2494
  type: data.type,
@@ -2460,6 +2561,9 @@ class ERBYieldNode extends Node {
2460
2561
  tag_opening;
2461
2562
  content;
2462
2563
  tag_closing;
2564
+ static get type() {
2565
+ return "AST_ERB_YIELD_NODE";
2566
+ }
2463
2567
  static from(data) {
2464
2568
  return new ERBYieldNode({
2465
2569
  type: data.type,
@@ -2514,6 +2618,9 @@ class ERBInNode extends Node {
2514
2618
  content;
2515
2619
  tag_closing;
2516
2620
  statements;
2621
+ static get type() {
2622
+ return "AST_ERB_IN_NODE";
2623
+ }
2517
2624
  static from(data) {
2518
2625
  return new ERBInNode({
2519
2626
  type: data.type,
@@ -2732,7 +2839,7 @@ class ParseResult extends Result {
2732
2839
  }
2733
2840
 
2734
2841
  // NOTE: This file is generated by the templates/template.rb script and should not
2735
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.0/templates/javascript/packages/core/src/node-type-guards.ts.erb
2842
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.0/templates/javascript/packages/core/src/node-type-guards.ts.erb
2736
2843
  /**
2737
2844
  * Type guard functions for AST nodes.
2738
2845
  * These functions provide type checking by combining both instanceof
@@ -2743,187 +2850,187 @@ class ParseResult extends Result {
2743
2850
  * Checks if a node is a DocumentNode
2744
2851
  */
2745
2852
  function isDocumentNode(node) {
2746
- return node instanceof DocumentNode || node.type === "AST_DOCUMENT_NODE";
2853
+ return node instanceof DocumentNode || node.type === "AST_DOCUMENT_NODE" || node.constructor.type === "AST_DOCUMENT_NODE";
2747
2854
  }
2748
2855
  /**
2749
2856
  * Checks if a node is a LiteralNode
2750
2857
  */
2751
2858
  function isLiteralNode(node) {
2752
- return node instanceof LiteralNode || node.type === "AST_LITERAL_NODE";
2859
+ return node instanceof LiteralNode || node.type === "AST_LITERAL_NODE" || node.constructor.type === "AST_LITERAL_NODE";
2753
2860
  }
2754
2861
  /**
2755
2862
  * Checks if a node is a HTMLOpenTagNode
2756
2863
  */
2757
2864
  function isHTMLOpenTagNode(node) {
2758
- return node instanceof HTMLOpenTagNode || node.type === "AST_HTML_OPEN_TAG_NODE";
2865
+ return node instanceof HTMLOpenTagNode || node.type === "AST_HTML_OPEN_TAG_NODE" || node.constructor.type === "AST_HTML_OPEN_TAG_NODE";
2759
2866
  }
2760
2867
  /**
2761
2868
  * Checks if a node is a HTMLCloseTagNode
2762
2869
  */
2763
2870
  function isHTMLCloseTagNode(node) {
2764
- return node instanceof HTMLCloseTagNode || node.type === "AST_HTML_CLOSE_TAG_NODE";
2871
+ return node instanceof HTMLCloseTagNode || node.type === "AST_HTML_CLOSE_TAG_NODE" || node.constructor.type === "AST_HTML_CLOSE_TAG_NODE";
2765
2872
  }
2766
2873
  /**
2767
2874
  * Checks if a node is a HTMLElementNode
2768
2875
  */
2769
2876
  function isHTMLElementNode(node) {
2770
- return node instanceof HTMLElementNode || node.type === "AST_HTML_ELEMENT_NODE";
2877
+ return node instanceof HTMLElementNode || node.type === "AST_HTML_ELEMENT_NODE" || node.constructor.type === "AST_HTML_ELEMENT_NODE";
2771
2878
  }
2772
2879
  /**
2773
2880
  * Checks if a node is a HTMLAttributeValueNode
2774
2881
  */
2775
2882
  function isHTMLAttributeValueNode(node) {
2776
- return node instanceof HTMLAttributeValueNode || node.type === "AST_HTML_ATTRIBUTE_VALUE_NODE";
2883
+ return node instanceof HTMLAttributeValueNode || node.type === "AST_HTML_ATTRIBUTE_VALUE_NODE" || node.constructor.type === "AST_HTML_ATTRIBUTE_VALUE_NODE";
2777
2884
  }
2778
2885
  /**
2779
2886
  * Checks if a node is a HTMLAttributeNameNode
2780
2887
  */
2781
2888
  function isHTMLAttributeNameNode(node) {
2782
- return node instanceof HTMLAttributeNameNode || node.type === "AST_HTML_ATTRIBUTE_NAME_NODE";
2889
+ return node instanceof HTMLAttributeNameNode || node.type === "AST_HTML_ATTRIBUTE_NAME_NODE" || node.constructor.type === "AST_HTML_ATTRIBUTE_NAME_NODE";
2783
2890
  }
2784
2891
  /**
2785
2892
  * Checks if a node is a HTMLAttributeNode
2786
2893
  */
2787
2894
  function isHTMLAttributeNode(node) {
2788
- return node instanceof HTMLAttributeNode || node.type === "AST_HTML_ATTRIBUTE_NODE";
2895
+ return node instanceof HTMLAttributeNode || node.type === "AST_HTML_ATTRIBUTE_NODE" || node.constructor.type === "AST_HTML_ATTRIBUTE_NODE";
2789
2896
  }
2790
2897
  /**
2791
2898
  * Checks if a node is a HTMLTextNode
2792
2899
  */
2793
2900
  function isHTMLTextNode(node) {
2794
- return node instanceof HTMLTextNode || node.type === "AST_HTML_TEXT_NODE";
2901
+ return node instanceof HTMLTextNode || node.type === "AST_HTML_TEXT_NODE" || node.constructor.type === "AST_HTML_TEXT_NODE";
2795
2902
  }
2796
2903
  /**
2797
2904
  * Checks if a node is a HTMLCommentNode
2798
2905
  */
2799
2906
  function isHTMLCommentNode(node) {
2800
- return node instanceof HTMLCommentNode || node.type === "AST_HTML_COMMENT_NODE";
2907
+ return node instanceof HTMLCommentNode || node.type === "AST_HTML_COMMENT_NODE" || node.constructor.type === "AST_HTML_COMMENT_NODE";
2801
2908
  }
2802
2909
  /**
2803
2910
  * Checks if a node is a HTMLDoctypeNode
2804
2911
  */
2805
2912
  function isHTMLDoctypeNode(node) {
2806
- return node instanceof HTMLDoctypeNode || node.type === "AST_HTML_DOCTYPE_NODE";
2913
+ return node instanceof HTMLDoctypeNode || node.type === "AST_HTML_DOCTYPE_NODE" || node.constructor.type === "AST_HTML_DOCTYPE_NODE";
2807
2914
  }
2808
2915
  /**
2809
2916
  * Checks if a node is a XMLDeclarationNode
2810
2917
  */
2811
2918
  function isXMLDeclarationNode(node) {
2812
- return node instanceof XMLDeclarationNode || node.type === "AST_XML_DECLARATION_NODE";
2919
+ return node instanceof XMLDeclarationNode || node.type === "AST_XML_DECLARATION_NODE" || node.constructor.type === "AST_XML_DECLARATION_NODE";
2813
2920
  }
2814
2921
  /**
2815
2922
  * Checks if a node is a CDATANode
2816
2923
  */
2817
2924
  function isCDATANode(node) {
2818
- return node instanceof CDATANode || node.type === "AST_CDATA_NODE";
2925
+ return node instanceof CDATANode || node.type === "AST_CDATA_NODE" || node.constructor.type === "AST_CDATA_NODE";
2819
2926
  }
2820
2927
  /**
2821
2928
  * Checks if a node is a WhitespaceNode
2822
2929
  */
2823
2930
  function isWhitespaceNode(node) {
2824
- return node instanceof WhitespaceNode || node.type === "AST_WHITESPACE_NODE";
2931
+ return node instanceof WhitespaceNode || node.type === "AST_WHITESPACE_NODE" || node.constructor.type === "AST_WHITESPACE_NODE";
2825
2932
  }
2826
2933
  /**
2827
2934
  * Checks if a node is a ERBContentNode
2828
2935
  */
2829
2936
  function isERBContentNode(node) {
2830
- return node instanceof ERBContentNode || node.type === "AST_ERB_CONTENT_NODE";
2937
+ return node instanceof ERBContentNode || node.type === "AST_ERB_CONTENT_NODE" || node.constructor.type === "AST_ERB_CONTENT_NODE";
2831
2938
  }
2832
2939
  /**
2833
2940
  * Checks if a node is a ERBEndNode
2834
2941
  */
2835
2942
  function isERBEndNode(node) {
2836
- return node instanceof ERBEndNode || node.type === "AST_ERB_END_NODE";
2943
+ return node instanceof ERBEndNode || node.type === "AST_ERB_END_NODE" || node.constructor.type === "AST_ERB_END_NODE";
2837
2944
  }
2838
2945
  /**
2839
2946
  * Checks if a node is a ERBElseNode
2840
2947
  */
2841
2948
  function isERBElseNode(node) {
2842
- return node instanceof ERBElseNode || node.type === "AST_ERB_ELSE_NODE";
2949
+ return node instanceof ERBElseNode || node.type === "AST_ERB_ELSE_NODE" || node.constructor.type === "AST_ERB_ELSE_NODE";
2843
2950
  }
2844
2951
  /**
2845
2952
  * Checks if a node is a ERBIfNode
2846
2953
  */
2847
2954
  function isERBIfNode(node) {
2848
- return node instanceof ERBIfNode || node.type === "AST_ERB_IF_NODE";
2955
+ return node instanceof ERBIfNode || node.type === "AST_ERB_IF_NODE" || node.constructor.type === "AST_ERB_IF_NODE";
2849
2956
  }
2850
2957
  /**
2851
2958
  * Checks if a node is a ERBBlockNode
2852
2959
  */
2853
2960
  function isERBBlockNode(node) {
2854
- return node instanceof ERBBlockNode || node.type === "AST_ERB_BLOCK_NODE";
2961
+ return node instanceof ERBBlockNode || node.type === "AST_ERB_BLOCK_NODE" || node.constructor.type === "AST_ERB_BLOCK_NODE";
2855
2962
  }
2856
2963
  /**
2857
2964
  * Checks if a node is a ERBWhenNode
2858
2965
  */
2859
2966
  function isERBWhenNode(node) {
2860
- return node instanceof ERBWhenNode || node.type === "AST_ERB_WHEN_NODE";
2967
+ return node instanceof ERBWhenNode || node.type === "AST_ERB_WHEN_NODE" || node.constructor.type === "AST_ERB_WHEN_NODE";
2861
2968
  }
2862
2969
  /**
2863
2970
  * Checks if a node is a ERBCaseNode
2864
2971
  */
2865
2972
  function isERBCaseNode(node) {
2866
- return node instanceof ERBCaseNode || node.type === "AST_ERB_CASE_NODE";
2973
+ return node instanceof ERBCaseNode || node.type === "AST_ERB_CASE_NODE" || node.constructor.type === "AST_ERB_CASE_NODE";
2867
2974
  }
2868
2975
  /**
2869
2976
  * Checks if a node is a ERBCaseMatchNode
2870
2977
  */
2871
2978
  function isERBCaseMatchNode(node) {
2872
- return node instanceof ERBCaseMatchNode || node.type === "AST_ERB_CASE_MATCH_NODE";
2979
+ return node instanceof ERBCaseMatchNode || node.type === "AST_ERB_CASE_MATCH_NODE" || node.constructor.type === "AST_ERB_CASE_MATCH_NODE";
2873
2980
  }
2874
2981
  /**
2875
2982
  * Checks if a node is a ERBWhileNode
2876
2983
  */
2877
2984
  function isERBWhileNode(node) {
2878
- return node instanceof ERBWhileNode || node.type === "AST_ERB_WHILE_NODE";
2985
+ return node instanceof ERBWhileNode || node.type === "AST_ERB_WHILE_NODE" || node.constructor.type === "AST_ERB_WHILE_NODE";
2879
2986
  }
2880
2987
  /**
2881
2988
  * Checks if a node is a ERBUntilNode
2882
2989
  */
2883
2990
  function isERBUntilNode(node) {
2884
- return node instanceof ERBUntilNode || node.type === "AST_ERB_UNTIL_NODE";
2991
+ return node instanceof ERBUntilNode || node.type === "AST_ERB_UNTIL_NODE" || node.constructor.type === "AST_ERB_UNTIL_NODE";
2885
2992
  }
2886
2993
  /**
2887
2994
  * Checks if a node is a ERBForNode
2888
2995
  */
2889
2996
  function isERBForNode(node) {
2890
- return node instanceof ERBForNode || node.type === "AST_ERB_FOR_NODE";
2997
+ return node instanceof ERBForNode || node.type === "AST_ERB_FOR_NODE" || node.constructor.type === "AST_ERB_FOR_NODE";
2891
2998
  }
2892
2999
  /**
2893
3000
  * Checks if a node is a ERBRescueNode
2894
3001
  */
2895
3002
  function isERBRescueNode(node) {
2896
- return node instanceof ERBRescueNode || node.type === "AST_ERB_RESCUE_NODE";
3003
+ return node instanceof ERBRescueNode || node.type === "AST_ERB_RESCUE_NODE" || node.constructor.type === "AST_ERB_RESCUE_NODE";
2897
3004
  }
2898
3005
  /**
2899
3006
  * Checks if a node is a ERBEnsureNode
2900
3007
  */
2901
3008
  function isERBEnsureNode(node) {
2902
- return node instanceof ERBEnsureNode || node.type === "AST_ERB_ENSURE_NODE";
3009
+ return node instanceof ERBEnsureNode || node.type === "AST_ERB_ENSURE_NODE" || node.constructor.type === "AST_ERB_ENSURE_NODE";
2903
3010
  }
2904
3011
  /**
2905
3012
  * Checks if a node is a ERBBeginNode
2906
3013
  */
2907
3014
  function isERBBeginNode(node) {
2908
- return node instanceof ERBBeginNode || node.type === "AST_ERB_BEGIN_NODE";
3015
+ return node instanceof ERBBeginNode || node.type === "AST_ERB_BEGIN_NODE" || node.constructor.type === "AST_ERB_BEGIN_NODE";
2909
3016
  }
2910
3017
  /**
2911
3018
  * Checks if a node is a ERBUnlessNode
2912
3019
  */
2913
3020
  function isERBUnlessNode(node) {
2914
- return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE";
3021
+ return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE" || node.constructor.type === "AST_ERB_UNLESS_NODE";
2915
3022
  }
2916
3023
  /**
2917
3024
  * Checks if a node is a ERBYieldNode
2918
3025
  */
2919
3026
  function isERBYieldNode(node) {
2920
- return node instanceof ERBYieldNode || node.type === "AST_ERB_YIELD_NODE";
3027
+ return node instanceof ERBYieldNode || node.type === "AST_ERB_YIELD_NODE" || node.constructor.type === "AST_ERB_YIELD_NODE";
2921
3028
  }
2922
3029
  /**
2923
3030
  * Checks if a node is a ERBInNode
2924
3031
  */
2925
3032
  function isERBInNode(node) {
2926
- return node instanceof ERBInNode || node.type === "AST_ERB_IN_NODE";
3033
+ return node instanceof ERBInNode || node.type === "AST_ERB_IN_NODE" || node.constructor.type === "AST_ERB_IN_NODE";
2927
3034
  }
2928
3035
  /**
2929
3036
  * Convenience type guards for common node categories
@@ -3112,6 +3219,8 @@ function filterNodes(nodes, ...types) {
3112
3219
  return nodes.filter(node => isAnyOf(node, ...types));
3113
3220
  }
3114
3221
  function isNode(node, type) {
3222
+ if (!node)
3223
+ return false;
3115
3224
  if (typeof type === 'string') {
3116
3225
  const guard = AST_TYPE_GUARDS.get(type);
3117
3226
  return guard ? guard(node) : false;
@@ -3351,7 +3460,11 @@ function filterERBInNodes(nodes) {
3351
3460
  * Checks if a node is an ERB output node (generates content: <%= %> or <%== %>)
3352
3461
  */
3353
3462
  function isERBOutputNode(node) {
3354
- return isNode(node, ERBContentNode) && ["<%=", "<%=="].includes(node.tag_opening?.value);
3463
+ if (!isNode(node, ERBContentNode))
3464
+ return false;
3465
+ if (!node.tag_opening?.value)
3466
+ return false;
3467
+ return ["<%=", "<%=="].includes(node.tag_opening?.value);
3355
3468
  }
3356
3469
  /**
3357
3470
  * Checks if a node is a non-output ERB node (control flow: <% %>)
@@ -3487,6 +3600,87 @@ function getTagName(node) {
3487
3600
  function isCommentNode(node) {
3488
3601
  return isNode(node, HTMLCommentNode) || (isERBNode(node) && !isERBControlFlowNode(node));
3489
3602
  }
3603
+ /**
3604
+ * Compares two positions to determine if the first comes before the second
3605
+ * Returns true if pos1 comes before pos2 in source order
3606
+ * @param inclusive - If true, returns true when positions are equal
3607
+ */
3608
+ function isPositionBefore(position1, position2, inclusive = false) {
3609
+ if (position1.line < position2.line)
3610
+ return true;
3611
+ if (position1.line > position2.line)
3612
+ return false;
3613
+ return inclusive ? position1.column <= position2.column : position1.column < position2.column;
3614
+ }
3615
+ /**
3616
+ * Compares two positions to determine if they are equal
3617
+ * Returns true if pos1 and pos2 are at the same location
3618
+ */
3619
+ function isPositionEqual(position1, position2) {
3620
+ return position1.line === position2.line && position1.column === position2.column;
3621
+ }
3622
+ /**
3623
+ * Compares two positions to determine if the first comes after the second
3624
+ * Returns true if pos1 comes after pos2 in source order
3625
+ * @param inclusive - If true, returns true when positions are equal
3626
+ */
3627
+ function isPositionAfter(position1, position2, inclusive = false) {
3628
+ if (position1.line > position2.line)
3629
+ return true;
3630
+ if (position1.line < position2.line)
3631
+ return false;
3632
+ return inclusive ? position1.column >= position2.column : position1.column > position2.column;
3633
+ }
3634
+ /**
3635
+ * Gets nodes that appear before the specified location in source order
3636
+ * Uses line and column positions to determine ordering
3637
+ */
3638
+ function getNodesBeforeLocation(nodes, location) {
3639
+ return nodes.filter(node => node.location && isPositionBefore(node.location.end, location.start));
3640
+ }
3641
+ /**
3642
+ * Gets nodes that appear after the specified location in source order
3643
+ * Uses line and column positions to determine ordering
3644
+ */
3645
+ function getNodesAfterLocation(nodes, location) {
3646
+ return nodes.filter(node => node.location && isPositionAfter(node.location.start, location.end));
3647
+ }
3648
+ /**
3649
+ * Splits nodes into before and after the specified location
3650
+ * Returns an object with `before` and `after` arrays
3651
+ */
3652
+ function splitNodesAroundLocation(nodes, location) {
3653
+ return {
3654
+ before: getNodesBeforeLocation(nodes, location),
3655
+ after: getNodesAfterLocation(nodes, location)
3656
+ };
3657
+ }
3658
+ /**
3659
+ * Splits nodes at a specific position
3660
+ * Returns nodes that end before the position and nodes that start after the position
3661
+ * More precise than splitNodesAroundLocation as it uses a single position point
3662
+ * Uses the same defaults as the individual functions: before=exclusive, after=inclusive
3663
+ */
3664
+ function splitNodesAroundPosition(nodes, position) {
3665
+ return {
3666
+ before: getNodesBeforePosition(nodes, position), // uses default: inclusive = false
3667
+ after: getNodesAfterPosition(nodes, position) // uses default: inclusive = true
3668
+ };
3669
+ }
3670
+ /**
3671
+ * Gets nodes that end before the specified position
3672
+ * @param inclusive - If true, includes nodes that end exactly at the position (default: false, matching half-open interval semantics)
3673
+ */
3674
+ function getNodesBeforePosition(nodes, position, inclusive = false) {
3675
+ return nodes.filter(node => node.location && isPositionBefore(node.location.end, position, inclusive));
3676
+ }
3677
+ /**
3678
+ * Gets nodes that start after the specified position
3679
+ * @param inclusive - If true, includes nodes that start exactly at the position (default: true, matching typical boundary behavior)
3680
+ */
3681
+ function getNodesAfterPosition(nodes, position, inclusive = true) {
3682
+ return nodes.filter(node => node.location && isPositionAfter(node.location.start, position, inclusive));
3683
+ }
3490
3684
 
3491
3685
  const expectedFunctions = [
3492
3686
  "parse",
@@ -3539,7 +3733,7 @@ function toMonacoDiagnostic(diagnostic) {
3539
3733
  }
3540
3734
 
3541
3735
  var name = "@herb-tools/core";
3542
- var version = "0.6.0";
3736
+ var version = "0.7.0";
3543
3737
  var packageJSON = {
3544
3738
  name: name,
3545
3739
  version: version};
@@ -3762,7 +3956,7 @@ class HerbBackend {
3762
3956
  }
3763
3957
 
3764
3958
  // NOTE: This file is generated by the templates/template.rb script and should not
3765
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.0/templates/javascript/packages/core/src/visitor.ts.erb
3959
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.7.0/templates/javascript/packages/core/src/visitor.ts.erb
3766
3960
  class Visitor {
3767
3961
  visit(node) {
3768
3962
  if (!node)
@@ -3870,5 +4064,5 @@ class Visitor {
3870
4064
  }
3871
4065
  }
3872
4066
 
3873
- export { AST_TYPE_GUARDS, CDATANode, DEFAULT_PARSER_OPTIONS, DocumentNode, ERBBeginNode, ERBBlockNode, ERBCaseMatchNode, ERBCaseNode, ERBContentNode, ERBElseNode, ERBEndNode, ERBEnsureNode, ERBForNode, ERBIfNode, ERBInNode, ERBNodeClasses, ERBRescueNode, ERBUnlessNode, ERBUntilNode, ERBWhenNode, ERBWhileNode, ERBYieldNode, HTMLAttributeNameNode, HTMLAttributeNode, HTMLAttributeValueNode, HTMLCloseTagNode, HTMLCommentNode, HTMLDoctypeNode, HTMLElementNode, HTMLOpenTagNode, HTMLTextNode, HerbBackend, HerbError, HerbWarning, LexResult, LiteralNode, Location, MissingClosingTagError, MissingOpeningTagError, NODE_TYPE_GUARDS, Node, ParseResult, Position, QuotesMismatchError, Range, Result, RubyParseError, TagNamesMismatchError, Token, TokenList, UnclosedElementError, UnexpectedError, UnexpectedTokenError, Visitor, VoidElementClosingTagError, WhitespaceNode, XMLDeclarationNode, _TYPECHECK, areAllOfType, convertToUTF8, ensureLibHerbBackend, ensureString, filterCDATANodes, filterDocumentNodes, filterERBBeginNodes, filterERBBlockNodes, filterERBCaseMatchNodes, filterERBCaseNodes, filterERBContentNodes, filterERBElseNodes, filterERBEndNodes, filterERBEnsureNodes, filterERBForNodes, filterERBIfNodes, filterERBInNodes, filterERBRescueNodes, filterERBUnlessNodes, filterERBUntilNodes, filterERBWhenNodes, filterERBWhileNodes, filterERBYieldNodes, filterHTMLAttributeNameNodes, filterHTMLAttributeNodes, filterHTMLAttributeValueNodes, filterHTMLCloseTagNodes, filterHTMLCommentNodes, filterHTMLDoctypeNodes, filterHTMLElementNodes, filterHTMLOpenTagNodes, filterHTMLTextNodes, filterLiteralNodes, filterNodes, filterWhitespaceNodes, filterXMLDeclarationNodes, fromSerializedError, fromSerializedNode, getCombinedAttributeName, getCombinedStringFromNodes, getStaticAttributeName, getStaticContentFromNodes, getStaticStringFromNodes, getTagName, getValidatableStaticContent, hasChildren, hasDynamicAttributeName, hasERBContent, hasERBOutput, hasStaticAttributeName, hasStaticContent, isAnyOf, isCDATANode, isCommentNode, isDocumentNode, isERBBeginNode, isERBBlockNode, isERBCaseMatchNode, isERBCaseNode, isERBContentNode, isERBControlFlowNode, isERBElseNode, isERBEndNode, isERBEnsureNode, isERBForNode, isERBIfNode, isERBInNode, isERBNode, isERBOutputNode, isERBRescueNode, isERBUnlessNode, isERBUntilNode, isERBWhenNode, isERBWhileNode, isERBYieldNode, isEffectivelyStatic, isHTMLAttributeNameNode, isHTMLAttributeNode, isHTMLAttributeValueNode, isHTMLCloseTagNode, isHTMLCommentNode, isHTMLDoctypeNode, isHTMLElementNode, isHTMLNode, isHTMLOpenTagNode, isHTMLTextNode, isLibHerbBackend, isLiteralNode, isNode, isNoneOf, isParseResult, isToken, isWhitespaceNode, isXMLDeclarationNode, toMonacoDiagnostic };
4067
+ export { AST_TYPE_GUARDS, CDATANode, DEFAULT_PARSER_OPTIONS, DocumentNode, ERBBeginNode, ERBBlockNode, ERBCaseMatchNode, ERBCaseNode, ERBContentNode, ERBElseNode, ERBEndNode, ERBEnsureNode, ERBForNode, ERBIfNode, ERBInNode, ERBNodeClasses, ERBRescueNode, ERBUnlessNode, ERBUntilNode, ERBWhenNode, ERBWhileNode, ERBYieldNode, HTMLAttributeNameNode, HTMLAttributeNode, HTMLAttributeValueNode, HTMLCloseTagNode, HTMLCommentNode, HTMLDoctypeNode, HTMLElementNode, HTMLOpenTagNode, HTMLTextNode, HerbBackend, HerbError, HerbWarning, LexResult, LiteralNode, Location, MissingClosingTagError, MissingOpeningTagError, NODE_TYPE_GUARDS, Node, ParseResult, Position, QuotesMismatchError, Range, Result, RubyParseError, TagNamesMismatchError, Token, TokenList, UnclosedElementError, UnexpectedError, UnexpectedTokenError, Visitor, VoidElementClosingTagError, WhitespaceNode, XMLDeclarationNode, _TYPECHECK, areAllOfType, convertToUTF8, ensureLibHerbBackend, ensureString, filterCDATANodes, filterDocumentNodes, filterERBBeginNodes, filterERBBlockNodes, filterERBCaseMatchNodes, filterERBCaseNodes, filterERBContentNodes, filterERBElseNodes, filterERBEndNodes, filterERBEnsureNodes, filterERBForNodes, filterERBIfNodes, filterERBInNodes, filterERBRescueNodes, filterERBUnlessNodes, filterERBUntilNodes, filterERBWhenNodes, filterERBWhileNodes, filterERBYieldNodes, filterHTMLAttributeNameNodes, filterHTMLAttributeNodes, filterHTMLAttributeValueNodes, filterHTMLCloseTagNodes, filterHTMLCommentNodes, filterHTMLDoctypeNodes, filterHTMLElementNodes, filterHTMLOpenTagNodes, filterHTMLTextNodes, filterLiteralNodes, filterNodes, filterWhitespaceNodes, filterXMLDeclarationNodes, fromSerializedError, fromSerializedNode, getCombinedAttributeName, getCombinedStringFromNodes, getNodesAfterLocation, getNodesAfterPosition, getNodesBeforeLocation, getNodesBeforePosition, getStaticAttributeName, getStaticContentFromNodes, getStaticStringFromNodes, getTagName, getValidatableStaticContent, hasChildren, hasDynamicAttributeName, hasERBContent, hasERBOutput, hasStaticAttributeName, hasStaticContent, isAnyOf, isCDATANode, isCommentNode, isDocumentNode, isERBBeginNode, isERBBlockNode, isERBCaseMatchNode, isERBCaseNode, isERBContentNode, isERBControlFlowNode, isERBElseNode, isERBEndNode, isERBEnsureNode, isERBForNode, isERBIfNode, isERBInNode, isERBNode, isERBOutputNode, isERBRescueNode, isERBUnlessNode, isERBUntilNode, isERBWhenNode, isERBWhileNode, isERBYieldNode, isEffectivelyStatic, isHTMLAttributeNameNode, isHTMLAttributeNode, isHTMLAttributeValueNode, isHTMLCloseTagNode, isHTMLCommentNode, isHTMLDoctypeNode, isHTMLElementNode, isHTMLNode, isHTMLOpenTagNode, isHTMLTextNode, isLibHerbBackend, isLiteralNode, isNode, isNoneOf, isParseResult, isPositionAfter, isPositionEqual, isToken, isWhitespaceNode, isXMLDeclarationNode, splitNodesAroundLocation, splitNodesAroundPosition, toMonacoDiagnostic };
3874
4068
  //# sourceMappingURL=herb-core.browser.js.map