@herb-tools/core 0.6.0 → 0.6.1

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.6.1/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.6.1/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
  }
@@ -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,9 @@ class HTMLElementNode extends Node {
870
891
  body;
871
892
  close_tag;
872
893
  is_void;
894
+ static get type() {
895
+ return "AST_HTML_ELEMENT_NODE";
896
+ }
873
897
  static from(data) {
874
898
  return new HTMLElementNode({
875
899
  type: data.type,
@@ -939,6 +963,9 @@ class HTMLAttributeValueNode extends Node {
939
963
  children;
940
964
  close_quote;
941
965
  quoted;
966
+ static get type() {
967
+ return "AST_HTML_ATTRIBUTE_VALUE_NODE";
968
+ }
942
969
  static from(data) {
943
970
  return new HTMLAttributeValueNode({
944
971
  type: data.type,
@@ -997,6 +1024,9 @@ class HTMLAttributeValueNode extends Node {
997
1024
  }
998
1025
  class HTMLAttributeNameNode extends Node {
999
1026
  children;
1027
+ static get type() {
1028
+ return "AST_HTML_ATTRIBUTE_NAME_NODE";
1029
+ }
1000
1030
  static from(data) {
1001
1031
  return new HTMLAttributeNameNode({
1002
1032
  type: data.type,
@@ -1045,6 +1075,9 @@ class HTMLAttributeNode extends Node {
1045
1075
  name;
1046
1076
  equals;
1047
1077
  value;
1078
+ static get type() {
1079
+ return "AST_HTML_ATTRIBUTE_NODE";
1080
+ }
1048
1081
  static from(data) {
1049
1082
  return new HTMLAttributeNode({
1050
1083
  type: data.type,
@@ -1101,6 +1134,9 @@ class HTMLAttributeNode extends Node {
1101
1134
  }
1102
1135
  class HTMLTextNode extends Node {
1103
1136
  content;
1137
+ static get type() {
1138
+ return "AST_HTML_TEXT_NODE";
1139
+ }
1104
1140
  static from(data) {
1105
1141
  return new HTMLTextNode({
1106
1142
  type: data.type,
@@ -1146,6 +1182,9 @@ class HTMLCommentNode extends Node {
1146
1182
  comment_start;
1147
1183
  children;
1148
1184
  comment_end;
1185
+ static get type() {
1186
+ return "AST_HTML_COMMENT_NODE";
1187
+ }
1149
1188
  static from(data) {
1150
1189
  return new HTMLCommentNode({
1151
1190
  type: data.type,
@@ -1202,6 +1241,9 @@ class HTMLDoctypeNode extends Node {
1202
1241
  tag_opening;
1203
1242
  children;
1204
1243
  tag_closing;
1244
+ static get type() {
1245
+ return "AST_HTML_DOCTYPE_NODE";
1246
+ }
1205
1247
  static from(data) {
1206
1248
  return new HTMLDoctypeNode({
1207
1249
  type: data.type,
@@ -1258,6 +1300,9 @@ class XMLDeclarationNode extends Node {
1258
1300
  tag_opening;
1259
1301
  children;
1260
1302
  tag_closing;
1303
+ static get type() {
1304
+ return "AST_XML_DECLARATION_NODE";
1305
+ }
1261
1306
  static from(data) {
1262
1307
  return new XMLDeclarationNode({
1263
1308
  type: data.type,
@@ -1314,6 +1359,9 @@ class CDATANode extends Node {
1314
1359
  tag_opening;
1315
1360
  children;
1316
1361
  tag_closing;
1362
+ static get type() {
1363
+ return "AST_CDATA_NODE";
1364
+ }
1317
1365
  static from(data) {
1318
1366
  return new CDATANode({
1319
1367
  type: data.type,
@@ -1368,6 +1416,9 @@ class CDATANode extends Node {
1368
1416
  }
1369
1417
  class WhitespaceNode extends Node {
1370
1418
  value;
1419
+ static get type() {
1420
+ return "AST_WHITESPACE_NODE";
1421
+ }
1371
1422
  static from(data) {
1372
1423
  return new WhitespaceNode({
1373
1424
  type: data.type,
@@ -1416,6 +1467,9 @@ class ERBContentNode extends Node {
1416
1467
  // no-op for analyzed_ruby
1417
1468
  parsed;
1418
1469
  valid;
1470
+ static get type() {
1471
+ return "AST_ERB_CONTENT_NODE";
1472
+ }
1419
1473
  static from(data) {
1420
1474
  return new ERBContentNode({
1421
1475
  type: data.type,
@@ -1481,6 +1535,9 @@ class ERBEndNode extends Node {
1481
1535
  tag_opening;
1482
1536
  content;
1483
1537
  tag_closing;
1538
+ static get type() {
1539
+ return "AST_ERB_END_NODE";
1540
+ }
1484
1541
  static from(data) {
1485
1542
  return new ERBEndNode({
1486
1543
  type: data.type,
@@ -1535,6 +1592,9 @@ class ERBElseNode extends Node {
1535
1592
  content;
1536
1593
  tag_closing;
1537
1594
  statements;
1595
+ static get type() {
1596
+ return "AST_ERB_ELSE_NODE";
1597
+ }
1538
1598
  static from(data) {
1539
1599
  return new ERBElseNode({
1540
1600
  type: data.type,
@@ -1598,6 +1658,9 @@ class ERBIfNode extends Node {
1598
1658
  statements;
1599
1659
  subsequent;
1600
1660
  end_node;
1661
+ static get type() {
1662
+ return "AST_ERB_IF_NODE";
1663
+ }
1601
1664
  static from(data) {
1602
1665
  return new ERBIfNode({
1603
1666
  type: data.type,
@@ -1672,6 +1735,9 @@ class ERBBlockNode extends Node {
1672
1735
  tag_closing;
1673
1736
  body;
1674
1737
  end_node;
1738
+ static get type() {
1739
+ return "AST_ERB_BLOCK_NODE";
1740
+ }
1675
1741
  static from(data) {
1676
1742
  return new ERBBlockNode({
1677
1743
  type: data.type,
@@ -1739,6 +1805,9 @@ class ERBWhenNode extends Node {
1739
1805
  content;
1740
1806
  tag_closing;
1741
1807
  statements;
1808
+ static get type() {
1809
+ return "AST_ERB_WHEN_NODE";
1810
+ }
1742
1811
  static from(data) {
1743
1812
  return new ERBWhenNode({
1744
1813
  type: data.type,
@@ -1803,6 +1872,9 @@ class ERBCaseNode extends Node {
1803
1872
  conditions;
1804
1873
  else_clause;
1805
1874
  end_node;
1875
+ static get type() {
1876
+ return "AST_ERB_CASE_NODE";
1877
+ }
1806
1878
  static from(data) {
1807
1879
  return new ERBCaseNode({
1808
1880
  type: data.type,
@@ -1885,6 +1957,9 @@ class ERBCaseMatchNode extends Node {
1885
1957
  conditions;
1886
1958
  else_clause;
1887
1959
  end_node;
1960
+ static get type() {
1961
+ return "AST_ERB_CASE_MATCH_NODE";
1962
+ }
1888
1963
  static from(data) {
1889
1964
  return new ERBCaseMatchNode({
1890
1965
  type: data.type,
@@ -1965,6 +2040,9 @@ class ERBWhileNode extends Node {
1965
2040
  tag_closing;
1966
2041
  statements;
1967
2042
  end_node;
2043
+ static get type() {
2044
+ return "AST_ERB_WHILE_NODE";
2045
+ }
1968
2046
  static from(data) {
1969
2047
  return new ERBWhileNode({
1970
2048
  type: data.type,
@@ -2033,6 +2111,9 @@ class ERBUntilNode extends Node {
2033
2111
  tag_closing;
2034
2112
  statements;
2035
2113
  end_node;
2114
+ static get type() {
2115
+ return "AST_ERB_UNTIL_NODE";
2116
+ }
2036
2117
  static from(data) {
2037
2118
  return new ERBUntilNode({
2038
2119
  type: data.type,
@@ -2101,6 +2182,9 @@ class ERBForNode extends Node {
2101
2182
  tag_closing;
2102
2183
  statements;
2103
2184
  end_node;
2185
+ static get type() {
2186
+ return "AST_ERB_FOR_NODE";
2187
+ }
2104
2188
  static from(data) {
2105
2189
  return new ERBForNode({
2106
2190
  type: data.type,
@@ -2169,6 +2253,9 @@ class ERBRescueNode extends Node {
2169
2253
  tag_closing;
2170
2254
  statements;
2171
2255
  subsequent;
2256
+ static get type() {
2257
+ return "AST_ERB_RESCUE_NODE";
2258
+ }
2172
2259
  static from(data) {
2173
2260
  return new ERBRescueNode({
2174
2261
  type: data.type,
@@ -2236,6 +2323,9 @@ class ERBEnsureNode extends Node {
2236
2323
  content;
2237
2324
  tag_closing;
2238
2325
  statements;
2326
+ static get type() {
2327
+ return "AST_ERB_ENSURE_NODE";
2328
+ }
2239
2329
  static from(data) {
2240
2330
  return new ERBEnsureNode({
2241
2331
  type: data.type,
@@ -2301,6 +2391,9 @@ class ERBBeginNode extends Node {
2301
2391
  else_clause;
2302
2392
  ensure_clause;
2303
2393
  end_node;
2394
+ static get type() {
2395
+ return "AST_ERB_BEGIN_NODE";
2396
+ }
2304
2397
  static from(data) {
2305
2398
  return new ERBBeginNode({
2306
2399
  type: data.type,
@@ -2388,6 +2481,9 @@ class ERBUnlessNode extends Node {
2388
2481
  statements;
2389
2482
  else_clause;
2390
2483
  end_node;
2484
+ static get type() {
2485
+ return "AST_ERB_UNLESS_NODE";
2486
+ }
2391
2487
  static from(data) {
2392
2488
  return new ERBUnlessNode({
2393
2489
  type: data.type,
@@ -2460,6 +2556,9 @@ class ERBYieldNode extends Node {
2460
2556
  tag_opening;
2461
2557
  content;
2462
2558
  tag_closing;
2559
+ static get type() {
2560
+ return "AST_ERB_YIELD_NODE";
2561
+ }
2463
2562
  static from(data) {
2464
2563
  return new ERBYieldNode({
2465
2564
  type: data.type,
@@ -2514,6 +2613,9 @@ class ERBInNode extends Node {
2514
2613
  content;
2515
2614
  tag_closing;
2516
2615
  statements;
2616
+ static get type() {
2617
+ return "AST_ERB_IN_NODE";
2618
+ }
2517
2619
  static from(data) {
2518
2620
  return new ERBInNode({
2519
2621
  type: data.type,
@@ -2732,7 +2834,7 @@ class ParseResult extends Result {
2732
2834
  }
2733
2835
 
2734
2836
  // 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
2837
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/javascript/packages/core/src/node-type-guards.ts.erb
2736
2838
  /**
2737
2839
  * Type guard functions for AST nodes.
2738
2840
  * These functions provide type checking by combining both instanceof
@@ -2743,187 +2845,187 @@ class ParseResult extends Result {
2743
2845
  * Checks if a node is a DocumentNode
2744
2846
  */
2745
2847
  function isDocumentNode(node) {
2746
- return node instanceof DocumentNode || node.type === "AST_DOCUMENT_NODE";
2848
+ return node instanceof DocumentNode || node.type === "AST_DOCUMENT_NODE" || node.constructor.type === "AST_DOCUMENT_NODE";
2747
2849
  }
2748
2850
  /**
2749
2851
  * Checks if a node is a LiteralNode
2750
2852
  */
2751
2853
  function isLiteralNode(node) {
2752
- return node instanceof LiteralNode || node.type === "AST_LITERAL_NODE";
2854
+ return node instanceof LiteralNode || node.type === "AST_LITERAL_NODE" || node.constructor.type === "AST_LITERAL_NODE";
2753
2855
  }
2754
2856
  /**
2755
2857
  * Checks if a node is a HTMLOpenTagNode
2756
2858
  */
2757
2859
  function isHTMLOpenTagNode(node) {
2758
- return node instanceof HTMLOpenTagNode || node.type === "AST_HTML_OPEN_TAG_NODE";
2860
+ return node instanceof HTMLOpenTagNode || node.type === "AST_HTML_OPEN_TAG_NODE" || node.constructor.type === "AST_HTML_OPEN_TAG_NODE";
2759
2861
  }
2760
2862
  /**
2761
2863
  * Checks if a node is a HTMLCloseTagNode
2762
2864
  */
2763
2865
  function isHTMLCloseTagNode(node) {
2764
- return node instanceof HTMLCloseTagNode || node.type === "AST_HTML_CLOSE_TAG_NODE";
2866
+ return node instanceof HTMLCloseTagNode || node.type === "AST_HTML_CLOSE_TAG_NODE" || node.constructor.type === "AST_HTML_CLOSE_TAG_NODE";
2765
2867
  }
2766
2868
  /**
2767
2869
  * Checks if a node is a HTMLElementNode
2768
2870
  */
2769
2871
  function isHTMLElementNode(node) {
2770
- return node instanceof HTMLElementNode || node.type === "AST_HTML_ELEMENT_NODE";
2872
+ return node instanceof HTMLElementNode || node.type === "AST_HTML_ELEMENT_NODE" || node.constructor.type === "AST_HTML_ELEMENT_NODE";
2771
2873
  }
2772
2874
  /**
2773
2875
  * Checks if a node is a HTMLAttributeValueNode
2774
2876
  */
2775
2877
  function isHTMLAttributeValueNode(node) {
2776
- return node instanceof HTMLAttributeValueNode || node.type === "AST_HTML_ATTRIBUTE_VALUE_NODE";
2878
+ return node instanceof HTMLAttributeValueNode || node.type === "AST_HTML_ATTRIBUTE_VALUE_NODE" || node.constructor.type === "AST_HTML_ATTRIBUTE_VALUE_NODE";
2777
2879
  }
2778
2880
  /**
2779
2881
  * Checks if a node is a HTMLAttributeNameNode
2780
2882
  */
2781
2883
  function isHTMLAttributeNameNode(node) {
2782
- return node instanceof HTMLAttributeNameNode || node.type === "AST_HTML_ATTRIBUTE_NAME_NODE";
2884
+ return node instanceof HTMLAttributeNameNode || node.type === "AST_HTML_ATTRIBUTE_NAME_NODE" || node.constructor.type === "AST_HTML_ATTRIBUTE_NAME_NODE";
2783
2885
  }
2784
2886
  /**
2785
2887
  * Checks if a node is a HTMLAttributeNode
2786
2888
  */
2787
2889
  function isHTMLAttributeNode(node) {
2788
- return node instanceof HTMLAttributeNode || node.type === "AST_HTML_ATTRIBUTE_NODE";
2890
+ return node instanceof HTMLAttributeNode || node.type === "AST_HTML_ATTRIBUTE_NODE" || node.constructor.type === "AST_HTML_ATTRIBUTE_NODE";
2789
2891
  }
2790
2892
  /**
2791
2893
  * Checks if a node is a HTMLTextNode
2792
2894
  */
2793
2895
  function isHTMLTextNode(node) {
2794
- return node instanceof HTMLTextNode || node.type === "AST_HTML_TEXT_NODE";
2896
+ return node instanceof HTMLTextNode || node.type === "AST_HTML_TEXT_NODE" || node.constructor.type === "AST_HTML_TEXT_NODE";
2795
2897
  }
2796
2898
  /**
2797
2899
  * Checks if a node is a HTMLCommentNode
2798
2900
  */
2799
2901
  function isHTMLCommentNode(node) {
2800
- return node instanceof HTMLCommentNode || node.type === "AST_HTML_COMMENT_NODE";
2902
+ return node instanceof HTMLCommentNode || node.type === "AST_HTML_COMMENT_NODE" || node.constructor.type === "AST_HTML_COMMENT_NODE";
2801
2903
  }
2802
2904
  /**
2803
2905
  * Checks if a node is a HTMLDoctypeNode
2804
2906
  */
2805
2907
  function isHTMLDoctypeNode(node) {
2806
- return node instanceof HTMLDoctypeNode || node.type === "AST_HTML_DOCTYPE_NODE";
2908
+ return node instanceof HTMLDoctypeNode || node.type === "AST_HTML_DOCTYPE_NODE" || node.constructor.type === "AST_HTML_DOCTYPE_NODE";
2807
2909
  }
2808
2910
  /**
2809
2911
  * Checks if a node is a XMLDeclarationNode
2810
2912
  */
2811
2913
  function isXMLDeclarationNode(node) {
2812
- return node instanceof XMLDeclarationNode || node.type === "AST_XML_DECLARATION_NODE";
2914
+ return node instanceof XMLDeclarationNode || node.type === "AST_XML_DECLARATION_NODE" || node.constructor.type === "AST_XML_DECLARATION_NODE";
2813
2915
  }
2814
2916
  /**
2815
2917
  * Checks if a node is a CDATANode
2816
2918
  */
2817
2919
  function isCDATANode(node) {
2818
- return node instanceof CDATANode || node.type === "AST_CDATA_NODE";
2920
+ return node instanceof CDATANode || node.type === "AST_CDATA_NODE" || node.constructor.type === "AST_CDATA_NODE";
2819
2921
  }
2820
2922
  /**
2821
2923
  * Checks if a node is a WhitespaceNode
2822
2924
  */
2823
2925
  function isWhitespaceNode(node) {
2824
- return node instanceof WhitespaceNode || node.type === "AST_WHITESPACE_NODE";
2926
+ return node instanceof WhitespaceNode || node.type === "AST_WHITESPACE_NODE" || node.constructor.type === "AST_WHITESPACE_NODE";
2825
2927
  }
2826
2928
  /**
2827
2929
  * Checks if a node is a ERBContentNode
2828
2930
  */
2829
2931
  function isERBContentNode(node) {
2830
- return node instanceof ERBContentNode || node.type === "AST_ERB_CONTENT_NODE";
2932
+ return node instanceof ERBContentNode || node.type === "AST_ERB_CONTENT_NODE" || node.constructor.type === "AST_ERB_CONTENT_NODE";
2831
2933
  }
2832
2934
  /**
2833
2935
  * Checks if a node is a ERBEndNode
2834
2936
  */
2835
2937
  function isERBEndNode(node) {
2836
- return node instanceof ERBEndNode || node.type === "AST_ERB_END_NODE";
2938
+ return node instanceof ERBEndNode || node.type === "AST_ERB_END_NODE" || node.constructor.type === "AST_ERB_END_NODE";
2837
2939
  }
2838
2940
  /**
2839
2941
  * Checks if a node is a ERBElseNode
2840
2942
  */
2841
2943
  function isERBElseNode(node) {
2842
- return node instanceof ERBElseNode || node.type === "AST_ERB_ELSE_NODE";
2944
+ return node instanceof ERBElseNode || node.type === "AST_ERB_ELSE_NODE" || node.constructor.type === "AST_ERB_ELSE_NODE";
2843
2945
  }
2844
2946
  /**
2845
2947
  * Checks if a node is a ERBIfNode
2846
2948
  */
2847
2949
  function isERBIfNode(node) {
2848
- return node instanceof ERBIfNode || node.type === "AST_ERB_IF_NODE";
2950
+ return node instanceof ERBIfNode || node.type === "AST_ERB_IF_NODE" || node.constructor.type === "AST_ERB_IF_NODE";
2849
2951
  }
2850
2952
  /**
2851
2953
  * Checks if a node is a ERBBlockNode
2852
2954
  */
2853
2955
  function isERBBlockNode(node) {
2854
- return node instanceof ERBBlockNode || node.type === "AST_ERB_BLOCK_NODE";
2956
+ return node instanceof ERBBlockNode || node.type === "AST_ERB_BLOCK_NODE" || node.constructor.type === "AST_ERB_BLOCK_NODE";
2855
2957
  }
2856
2958
  /**
2857
2959
  * Checks if a node is a ERBWhenNode
2858
2960
  */
2859
2961
  function isERBWhenNode(node) {
2860
- return node instanceof ERBWhenNode || node.type === "AST_ERB_WHEN_NODE";
2962
+ return node instanceof ERBWhenNode || node.type === "AST_ERB_WHEN_NODE" || node.constructor.type === "AST_ERB_WHEN_NODE";
2861
2963
  }
2862
2964
  /**
2863
2965
  * Checks if a node is a ERBCaseNode
2864
2966
  */
2865
2967
  function isERBCaseNode(node) {
2866
- return node instanceof ERBCaseNode || node.type === "AST_ERB_CASE_NODE";
2968
+ return node instanceof ERBCaseNode || node.type === "AST_ERB_CASE_NODE" || node.constructor.type === "AST_ERB_CASE_NODE";
2867
2969
  }
2868
2970
  /**
2869
2971
  * Checks if a node is a ERBCaseMatchNode
2870
2972
  */
2871
2973
  function isERBCaseMatchNode(node) {
2872
- return node instanceof ERBCaseMatchNode || node.type === "AST_ERB_CASE_MATCH_NODE";
2974
+ return node instanceof ERBCaseMatchNode || node.type === "AST_ERB_CASE_MATCH_NODE" || node.constructor.type === "AST_ERB_CASE_MATCH_NODE";
2873
2975
  }
2874
2976
  /**
2875
2977
  * Checks if a node is a ERBWhileNode
2876
2978
  */
2877
2979
  function isERBWhileNode(node) {
2878
- return node instanceof ERBWhileNode || node.type === "AST_ERB_WHILE_NODE";
2980
+ return node instanceof ERBWhileNode || node.type === "AST_ERB_WHILE_NODE" || node.constructor.type === "AST_ERB_WHILE_NODE";
2879
2981
  }
2880
2982
  /**
2881
2983
  * Checks if a node is a ERBUntilNode
2882
2984
  */
2883
2985
  function isERBUntilNode(node) {
2884
- return node instanceof ERBUntilNode || node.type === "AST_ERB_UNTIL_NODE";
2986
+ return node instanceof ERBUntilNode || node.type === "AST_ERB_UNTIL_NODE" || node.constructor.type === "AST_ERB_UNTIL_NODE";
2885
2987
  }
2886
2988
  /**
2887
2989
  * Checks if a node is a ERBForNode
2888
2990
  */
2889
2991
  function isERBForNode(node) {
2890
- return node instanceof ERBForNode || node.type === "AST_ERB_FOR_NODE";
2992
+ return node instanceof ERBForNode || node.type === "AST_ERB_FOR_NODE" || node.constructor.type === "AST_ERB_FOR_NODE";
2891
2993
  }
2892
2994
  /**
2893
2995
  * Checks if a node is a ERBRescueNode
2894
2996
  */
2895
2997
  function isERBRescueNode(node) {
2896
- return node instanceof ERBRescueNode || node.type === "AST_ERB_RESCUE_NODE";
2998
+ return node instanceof ERBRescueNode || node.type === "AST_ERB_RESCUE_NODE" || node.constructor.type === "AST_ERB_RESCUE_NODE";
2897
2999
  }
2898
3000
  /**
2899
3001
  * Checks if a node is a ERBEnsureNode
2900
3002
  */
2901
3003
  function isERBEnsureNode(node) {
2902
- return node instanceof ERBEnsureNode || node.type === "AST_ERB_ENSURE_NODE";
3004
+ return node instanceof ERBEnsureNode || node.type === "AST_ERB_ENSURE_NODE" || node.constructor.type === "AST_ERB_ENSURE_NODE";
2903
3005
  }
2904
3006
  /**
2905
3007
  * Checks if a node is a ERBBeginNode
2906
3008
  */
2907
3009
  function isERBBeginNode(node) {
2908
- return node instanceof ERBBeginNode || node.type === "AST_ERB_BEGIN_NODE";
3010
+ return node instanceof ERBBeginNode || node.type === "AST_ERB_BEGIN_NODE" || node.constructor.type === "AST_ERB_BEGIN_NODE";
2909
3011
  }
2910
3012
  /**
2911
3013
  * Checks if a node is a ERBUnlessNode
2912
3014
  */
2913
3015
  function isERBUnlessNode(node) {
2914
- return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE";
3016
+ return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE" || node.constructor.type === "AST_ERB_UNLESS_NODE";
2915
3017
  }
2916
3018
  /**
2917
3019
  * Checks if a node is a ERBYieldNode
2918
3020
  */
2919
3021
  function isERBYieldNode(node) {
2920
- return node instanceof ERBYieldNode || node.type === "AST_ERB_YIELD_NODE";
3022
+ return node instanceof ERBYieldNode || node.type === "AST_ERB_YIELD_NODE" || node.constructor.type === "AST_ERB_YIELD_NODE";
2921
3023
  }
2922
3024
  /**
2923
3025
  * Checks if a node is a ERBInNode
2924
3026
  */
2925
3027
  function isERBInNode(node) {
2926
- return node instanceof ERBInNode || node.type === "AST_ERB_IN_NODE";
3028
+ return node instanceof ERBInNode || node.type === "AST_ERB_IN_NODE" || node.constructor.type === "AST_ERB_IN_NODE";
2927
3029
  }
2928
3030
  /**
2929
3031
  * Convenience type guards for common node categories
@@ -3112,6 +3214,8 @@ function filterNodes(nodes, ...types) {
3112
3214
  return nodes.filter(node => isAnyOf(node, ...types));
3113
3215
  }
3114
3216
  function isNode(node, type) {
3217
+ if (!node)
3218
+ return false;
3115
3219
  if (typeof type === 'string') {
3116
3220
  const guard = AST_TYPE_GUARDS.get(type);
3117
3221
  return guard ? guard(node) : false;
@@ -3487,6 +3591,87 @@ function getTagName(node) {
3487
3591
  function isCommentNode(node) {
3488
3592
  return isNode(node, HTMLCommentNode) || (isERBNode(node) && !isERBControlFlowNode(node));
3489
3593
  }
3594
+ /**
3595
+ * Compares two positions to determine if the first comes before the second
3596
+ * Returns true if pos1 comes before pos2 in source order
3597
+ * @param inclusive - If true, returns true when positions are equal
3598
+ */
3599
+ function isPositionBefore(position1, position2, inclusive = false) {
3600
+ if (position1.line < position2.line)
3601
+ return true;
3602
+ if (position1.line > position2.line)
3603
+ return false;
3604
+ return inclusive ? position1.column <= position2.column : position1.column < position2.column;
3605
+ }
3606
+ /**
3607
+ * Compares two positions to determine if they are equal
3608
+ * Returns true if pos1 and pos2 are at the same location
3609
+ */
3610
+ function isPositionEqual(position1, position2) {
3611
+ return position1.line === position2.line && position1.column === position2.column;
3612
+ }
3613
+ /**
3614
+ * Compares two positions to determine if the first comes after the second
3615
+ * Returns true if pos1 comes after pos2 in source order
3616
+ * @param inclusive - If true, returns true when positions are equal
3617
+ */
3618
+ function isPositionAfter(position1, position2, inclusive = false) {
3619
+ if (position1.line > position2.line)
3620
+ return true;
3621
+ if (position1.line < position2.line)
3622
+ return false;
3623
+ return inclusive ? position1.column >= position2.column : position1.column > position2.column;
3624
+ }
3625
+ /**
3626
+ * Gets nodes that appear before the specified location in source order
3627
+ * Uses line and column positions to determine ordering
3628
+ */
3629
+ function getNodesBeforeLocation(nodes, location) {
3630
+ return nodes.filter(node => node.location && isPositionBefore(node.location.end, location.start));
3631
+ }
3632
+ /**
3633
+ * Gets nodes that appear after the specified location in source order
3634
+ * Uses line and column positions to determine ordering
3635
+ */
3636
+ function getNodesAfterLocation(nodes, location) {
3637
+ return nodes.filter(node => node.location && isPositionAfter(node.location.start, location.end));
3638
+ }
3639
+ /**
3640
+ * Splits nodes into before and after the specified location
3641
+ * Returns an object with `before` and `after` arrays
3642
+ */
3643
+ function splitNodesAroundLocation(nodes, location) {
3644
+ return {
3645
+ before: getNodesBeforeLocation(nodes, location),
3646
+ after: getNodesAfterLocation(nodes, location)
3647
+ };
3648
+ }
3649
+ /**
3650
+ * Splits nodes at a specific position
3651
+ * Returns nodes that end before the position and nodes that start after the position
3652
+ * More precise than splitNodesAroundLocation as it uses a single position point
3653
+ * Uses the same defaults as the individual functions: before=exclusive, after=inclusive
3654
+ */
3655
+ function splitNodesAroundPosition(nodes, position) {
3656
+ return {
3657
+ before: getNodesBeforePosition(nodes, position), // uses default: inclusive = false
3658
+ after: getNodesAfterPosition(nodes, position) // uses default: inclusive = true
3659
+ };
3660
+ }
3661
+ /**
3662
+ * Gets nodes that end before the specified position
3663
+ * @param inclusive - If true, includes nodes that end exactly at the position (default: false, matching half-open interval semantics)
3664
+ */
3665
+ function getNodesBeforePosition(nodes, position, inclusive = false) {
3666
+ return nodes.filter(node => node.location && isPositionBefore(node.location.end, position, inclusive));
3667
+ }
3668
+ /**
3669
+ * Gets nodes that start after the specified position
3670
+ * @param inclusive - If true, includes nodes that start exactly at the position (default: true, matching typical boundary behavior)
3671
+ */
3672
+ function getNodesAfterPosition(nodes, position, inclusive = true) {
3673
+ return nodes.filter(node => node.location && isPositionAfter(node.location.start, position, inclusive));
3674
+ }
3490
3675
 
3491
3676
  const expectedFunctions = [
3492
3677
  "parse",
@@ -3539,7 +3724,7 @@ function toMonacoDiagnostic(diagnostic) {
3539
3724
  }
3540
3725
 
3541
3726
  var name = "@herb-tools/core";
3542
- var version = "0.6.0";
3727
+ var version = "0.6.1";
3543
3728
  var packageJSON = {
3544
3729
  name: name,
3545
3730
  version: version};
@@ -3762,7 +3947,7 @@ class HerbBackend {
3762
3947
  }
3763
3948
 
3764
3949
  // 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
3950
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/javascript/packages/core/src/visitor.ts.erb
3766
3951
  class Visitor {
3767
3952
  visit(node) {
3768
3953
  if (!node)
@@ -3870,5 +4055,5 @@ class Visitor {
3870
4055
  }
3871
4056
  }
3872
4057
 
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 };
4058
+ 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
4059
  //# sourceMappingURL=herb-core.esm.js.map