@herb-tools/rewriter 0.9.1 → 0.9.3

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/loader.cjs CHANGED
@@ -172,6 +172,9 @@ class Token {
172
172
  static from(token) {
173
173
  return new Token(token.value, Range.from(token.range), Location.from(token.location), token.type);
174
174
  }
175
+ static synthetic(value, type = "SYNTETHIC") {
176
+ return new Token(value, Range.zero, Location.zero, type);
177
+ }
175
178
  constructor(value, range, location, type) {
176
179
  this.value = value;
177
180
  this.range = range;
@@ -206,7 +209,7 @@ class Token {
206
209
  }
207
210
 
208
211
  // NOTE: This file is generated by the templates/template.rb script and should not
209
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/errors.ts.erb
212
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.3/templates/javascript/packages/core/src/errors.ts.erb
210
213
  class HerbError {
211
214
  type;
212
215
  message;
@@ -1480,6 +1483,284 @@ class RenderLayoutWithoutBlockError extends HerbError {
1480
1483
  return output;
1481
1484
  }
1482
1485
  }
1486
+ class StrictLocalsPositionalArgumentError extends HerbError {
1487
+ name;
1488
+ static from(data) {
1489
+ return new StrictLocalsPositionalArgumentError({
1490
+ type: data.type,
1491
+ message: data.message,
1492
+ location: Location.from(data.location),
1493
+ name: data.name,
1494
+ });
1495
+ }
1496
+ constructor(props) {
1497
+ super(props.type, props.message, props.location);
1498
+ this.name = props.name;
1499
+ }
1500
+ toJSON() {
1501
+ return {
1502
+ ...super.toJSON(),
1503
+ type: "STRICT_LOCALS_POSITIONAL_ARGUMENT_ERROR",
1504
+ name: this.name,
1505
+ };
1506
+ }
1507
+ toMonacoDiagnostic() {
1508
+ return {
1509
+ line: this.location.start.line,
1510
+ column: this.location.start.column,
1511
+ endLine: this.location.end.line,
1512
+ endColumn: this.location.end.column,
1513
+ message: this.message,
1514
+ severity: 'error'
1515
+ };
1516
+ }
1517
+ treeInspect() {
1518
+ let output = "";
1519
+ output += `@ StrictLocalsPositionalArgumentError ${this.location.treeInspectWithLabel()}\n`;
1520
+ output += `├── message: "${this.message}"\n`;
1521
+ output += `└── name: ${JSON.stringify(this.name)}\n`;
1522
+ return output;
1523
+ }
1524
+ }
1525
+ class StrictLocalsBlockArgumentError extends HerbError {
1526
+ name;
1527
+ static from(data) {
1528
+ return new StrictLocalsBlockArgumentError({
1529
+ type: data.type,
1530
+ message: data.message,
1531
+ location: Location.from(data.location),
1532
+ name: data.name,
1533
+ });
1534
+ }
1535
+ constructor(props) {
1536
+ super(props.type, props.message, props.location);
1537
+ this.name = props.name;
1538
+ }
1539
+ toJSON() {
1540
+ return {
1541
+ ...super.toJSON(),
1542
+ type: "STRICT_LOCALS_BLOCK_ARGUMENT_ERROR",
1543
+ name: this.name,
1544
+ };
1545
+ }
1546
+ toMonacoDiagnostic() {
1547
+ return {
1548
+ line: this.location.start.line,
1549
+ column: this.location.start.column,
1550
+ endLine: this.location.end.line,
1551
+ endColumn: this.location.end.column,
1552
+ message: this.message,
1553
+ severity: 'error'
1554
+ };
1555
+ }
1556
+ treeInspect() {
1557
+ let output = "";
1558
+ output += `@ StrictLocalsBlockArgumentError ${this.location.treeInspectWithLabel()}\n`;
1559
+ output += `├── message: "${this.message}"\n`;
1560
+ output += `└── name: ${JSON.stringify(this.name)}\n`;
1561
+ return output;
1562
+ }
1563
+ }
1564
+ class StrictLocalsSplatArgumentError extends HerbError {
1565
+ name;
1566
+ static from(data) {
1567
+ return new StrictLocalsSplatArgumentError({
1568
+ type: data.type,
1569
+ message: data.message,
1570
+ location: Location.from(data.location),
1571
+ name: data.name,
1572
+ });
1573
+ }
1574
+ constructor(props) {
1575
+ super(props.type, props.message, props.location);
1576
+ this.name = props.name;
1577
+ }
1578
+ toJSON() {
1579
+ return {
1580
+ ...super.toJSON(),
1581
+ type: "STRICT_LOCALS_SPLAT_ARGUMENT_ERROR",
1582
+ name: this.name,
1583
+ };
1584
+ }
1585
+ toMonacoDiagnostic() {
1586
+ return {
1587
+ line: this.location.start.line,
1588
+ column: this.location.start.column,
1589
+ endLine: this.location.end.line,
1590
+ endColumn: this.location.end.column,
1591
+ message: this.message,
1592
+ severity: 'error'
1593
+ };
1594
+ }
1595
+ treeInspect() {
1596
+ let output = "";
1597
+ output += `@ StrictLocalsSplatArgumentError ${this.location.treeInspectWithLabel()}\n`;
1598
+ output += `├── message: "${this.message}"\n`;
1599
+ output += `└── name: ${JSON.stringify(this.name)}\n`;
1600
+ return output;
1601
+ }
1602
+ }
1603
+ class StrictLocalsMissingParenthesisError extends HerbError {
1604
+ rest;
1605
+ static from(data) {
1606
+ return new StrictLocalsMissingParenthesisError({
1607
+ type: data.type,
1608
+ message: data.message,
1609
+ location: Location.from(data.location),
1610
+ rest: data.rest,
1611
+ });
1612
+ }
1613
+ constructor(props) {
1614
+ super(props.type, props.message, props.location);
1615
+ this.rest = props.rest;
1616
+ }
1617
+ toJSON() {
1618
+ return {
1619
+ ...super.toJSON(),
1620
+ type: "STRICT_LOCALS_MISSING_PARENTHESIS_ERROR",
1621
+ rest: this.rest,
1622
+ };
1623
+ }
1624
+ toMonacoDiagnostic() {
1625
+ return {
1626
+ line: this.location.start.line,
1627
+ column: this.location.start.column,
1628
+ endLine: this.location.end.line,
1629
+ endColumn: this.location.end.column,
1630
+ message: this.message,
1631
+ severity: 'error'
1632
+ };
1633
+ }
1634
+ treeInspect() {
1635
+ let output = "";
1636
+ output += `@ StrictLocalsMissingParenthesisError ${this.location.treeInspectWithLabel()}\n`;
1637
+ output += `├── message: "${this.message}"\n`;
1638
+ output += `└── rest: ${JSON.stringify(this.rest)}\n`;
1639
+ return output;
1640
+ }
1641
+ }
1642
+ class StrictLocalsDuplicateDeclarationError extends HerbError {
1643
+ static from(data) {
1644
+ return new StrictLocalsDuplicateDeclarationError({
1645
+ type: data.type,
1646
+ message: data.message,
1647
+ location: Location.from(data.location),
1648
+ });
1649
+ }
1650
+ constructor(props) {
1651
+ super(props.type, props.message, props.location);
1652
+ }
1653
+ toJSON() {
1654
+ return {
1655
+ ...super.toJSON(),
1656
+ type: "STRICT_LOCALS_DUPLICATE_DECLARATION_ERROR",
1657
+ };
1658
+ }
1659
+ toMonacoDiagnostic() {
1660
+ return {
1661
+ line: this.location.start.line,
1662
+ column: this.location.start.column,
1663
+ endLine: this.location.end.line,
1664
+ endColumn: this.location.end.column,
1665
+ message: this.message,
1666
+ severity: 'error'
1667
+ };
1668
+ }
1669
+ treeInspect() {
1670
+ let output = "";
1671
+ output += `@ StrictLocalsDuplicateDeclarationError ${this.location.treeInspectWithLabel()}\n`;
1672
+ output += `└── message: "${this.message}"\n`;
1673
+ return output;
1674
+ }
1675
+ }
1676
+ class VoidElementContentError extends HerbError {
1677
+ tag_name;
1678
+ helper_name;
1679
+ content_type;
1680
+ static from(data) {
1681
+ return new VoidElementContentError({
1682
+ type: data.type,
1683
+ message: data.message,
1684
+ location: Location.from(data.location),
1685
+ tag_name: data.tag_name ? Token.from(data.tag_name) : null,
1686
+ helper_name: data.helper_name,
1687
+ content_type: data.content_type,
1688
+ });
1689
+ }
1690
+ constructor(props) {
1691
+ super(props.type, props.message, props.location);
1692
+ this.tag_name = props.tag_name;
1693
+ this.helper_name = props.helper_name;
1694
+ this.content_type = props.content_type;
1695
+ }
1696
+ toJSON() {
1697
+ return {
1698
+ ...super.toJSON(),
1699
+ type: "VOID_ELEMENT_CONTENT_ERROR",
1700
+ tag_name: this.tag_name ? this.tag_name.toJSON() : null,
1701
+ helper_name: this.helper_name,
1702
+ content_type: this.content_type,
1703
+ };
1704
+ }
1705
+ toMonacoDiagnostic() {
1706
+ return {
1707
+ line: this.location.start.line,
1708
+ column: this.location.start.column,
1709
+ endLine: this.location.end.line,
1710
+ endColumn: this.location.end.column,
1711
+ message: this.message,
1712
+ severity: 'error'
1713
+ };
1714
+ }
1715
+ treeInspect() {
1716
+ let output = "";
1717
+ output += `@ VoidElementContentError ${this.location.treeInspectWithLabel()}\n`;
1718
+ output += `├── message: "${this.message}"\n`;
1719
+ output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`;
1720
+ output += `├── helper_name: ${JSON.stringify(this.helper_name)}\n`;
1721
+ output += `└── content_type: ${JSON.stringify(this.content_type)}\n`;
1722
+ return output;
1723
+ }
1724
+ }
1725
+ class DotNotationCasingError extends HerbError {
1726
+ segment;
1727
+ static from(data) {
1728
+ return new DotNotationCasingError({
1729
+ type: data.type,
1730
+ message: data.message,
1731
+ location: Location.from(data.location),
1732
+ segment: data.segment ? Token.from(data.segment) : null,
1733
+ });
1734
+ }
1735
+ constructor(props) {
1736
+ super(props.type, props.message, props.location);
1737
+ this.segment = props.segment;
1738
+ }
1739
+ toJSON() {
1740
+ return {
1741
+ ...super.toJSON(),
1742
+ type: "DOT_NOTATION_CASING_ERROR",
1743
+ segment: this.segment ? this.segment.toJSON() : null,
1744
+ };
1745
+ }
1746
+ toMonacoDiagnostic() {
1747
+ return {
1748
+ line: this.location.start.line,
1749
+ column: this.location.start.column,
1750
+ endLine: this.location.end.line,
1751
+ endColumn: this.location.end.column,
1752
+ message: this.message,
1753
+ severity: 'error'
1754
+ };
1755
+ }
1756
+ treeInspect() {
1757
+ let output = "";
1758
+ output += `@ DotNotationCasingError ${this.location.treeInspectWithLabel()}\n`;
1759
+ output += `├── message: "${this.message}"\n`;
1760
+ output += `└── segment: ${this.segment ? this.segment.treeInspect() : "∅"}\n`;
1761
+ return output;
1762
+ }
1763
+ }
1483
1764
  function fromSerializedError(error) {
1484
1765
  switch (error.type) {
1485
1766
  case "UNEXPECTED_ERROR": return UnexpectedError.from(error);
@@ -1512,6 +1793,13 @@ function fromSerializedError(error) {
1512
1793
  case "RENDER_INVALID_AS_OPTION_ERROR": return RenderInvalidAsOptionError.from(error);
1513
1794
  case "RENDER_OBJECT_AND_COLLECTION_ERROR": return RenderObjectAndCollectionError.from(error);
1514
1795
  case "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR": return RenderLayoutWithoutBlockError.from(error);
1796
+ case "STRICT_LOCALS_POSITIONAL_ARGUMENT_ERROR": return StrictLocalsPositionalArgumentError.from(error);
1797
+ case "STRICT_LOCALS_BLOCK_ARGUMENT_ERROR": return StrictLocalsBlockArgumentError.from(error);
1798
+ case "STRICT_LOCALS_SPLAT_ARGUMENT_ERROR": return StrictLocalsSplatArgumentError.from(error);
1799
+ case "STRICT_LOCALS_MISSING_PARENTHESIS_ERROR": return StrictLocalsMissingParenthesisError.from(error);
1800
+ case "STRICT_LOCALS_DUPLICATE_DECLARATION_ERROR": return StrictLocalsDuplicateDeclarationError.from(error);
1801
+ case "VOID_ELEMENT_CONTENT_ERROR": return VoidElementContentError.from(error);
1802
+ case "DOT_NOTATION_CASING_ERROR": return DotNotationCasingError.from(error);
1515
1803
  default:
1516
1804
  throw new Error(`Unknown node type: ${error.type}`);
1517
1805
  }
@@ -20100,7 +20388,7 @@ function deserializePrismNode(bytes, source) {
20100
20388
  }
20101
20389
 
20102
20390
  // NOTE: This file is generated by the templates/template.rb script and should not
20103
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/nodes.ts.erb
20391
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.3/templates/javascript/packages/core/src/nodes.ts.erb
20104
20392
  class Node {
20105
20393
  type;
20106
20394
  location;
@@ -21721,6 +22009,9 @@ class ERBBlockNode extends Node {
21721
22009
  tag_closing;
21722
22010
  prism_node;
21723
22011
  body;
22012
+ rescue_clause;
22013
+ else_clause;
22014
+ ensure_clause;
21724
22015
  end_node;
21725
22016
  static get type() {
21726
22017
  return "AST_ERB_BLOCK_NODE";
@@ -21735,6 +22026,9 @@ class ERBBlockNode extends Node {
21735
22026
  tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
21736
22027
  prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
21737
22028
  body: (data.body || []).map(node => fromSerializedNode(node)),
22029
+ rescue_clause: data.rescue_clause ? fromSerializedNode((data.rescue_clause)) : null,
22030
+ else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) : null,
22031
+ ensure_clause: data.ensure_clause ? fromSerializedNode((data.ensure_clause)) : null,
21738
22032
  end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
21739
22033
  });
21740
22034
  }
@@ -21745,6 +22039,9 @@ class ERBBlockNode extends Node {
21745
22039
  this.tag_closing = props.tag_closing;
21746
22040
  this.prism_node = props.prism_node;
21747
22041
  this.body = props.body;
22042
+ this.rescue_clause = props.rescue_clause;
22043
+ this.else_clause = props.else_clause;
22044
+ this.ensure_clause = props.ensure_clause;
21748
22045
  this.end_node = props.end_node;
21749
22046
  }
21750
22047
  accept(visitor) {
@@ -21753,6 +22050,9 @@ class ERBBlockNode extends Node {
21753
22050
  childNodes() {
21754
22051
  return [
21755
22052
  ...this.body,
22053
+ this.rescue_clause,
22054
+ this.else_clause,
22055
+ this.ensure_clause,
21756
22056
  this.end_node,
21757
22057
  ];
21758
22058
  }
@@ -21768,6 +22068,9 @@ class ERBBlockNode extends Node {
21768
22068
  return [
21769
22069
  ...this.errors,
21770
22070
  ...this.body.map(node => node.recursiveErrors()),
22071
+ this.rescue_clause ? this.rescue_clause.recursiveErrors() : [],
22072
+ this.else_clause ? this.else_clause.recursiveErrors() : [],
22073
+ this.ensure_clause ? this.ensure_clause.recursiveErrors() : [],
21771
22074
  this.end_node ? this.end_node.recursiveErrors() : [],
21772
22075
  ].flat();
21773
22076
  }
@@ -21780,6 +22083,9 @@ class ERBBlockNode extends Node {
21780
22083
  tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
21781
22084
  prism_node: this.prism_node ? Array.from(this.prism_node) : null,
21782
22085
  body: this.body.map(node => node.toJSON()),
22086
+ rescue_clause: this.rescue_clause ? this.rescue_clause.toJSON() : null,
22087
+ else_clause: this.else_clause ? this.else_clause.toJSON() : null,
22088
+ ensure_clause: this.ensure_clause ? this.ensure_clause.toJSON() : null,
21783
22089
  end_node: this.end_node ? this.end_node.toJSON() : null,
21784
22090
  };
21785
22091
  }
@@ -21794,6 +22100,9 @@ class ERBBlockNode extends Node {
21794
22100
  output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
21795
22101
  }
21796
22102
  output += `├── body: ${this.inspectArray(this.body, "│ ")}`;
22103
+ output += `├── rescue_clause: ${this.inspectNode(this.rescue_clause, "│ ")}`;
22104
+ output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`;
22105
+ output += `├── ensure_clause: ${this.inspectNode(this.ensure_clause, "│ ")}`;
21797
22106
  output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
21798
22107
  return output;
21799
22108
  }
@@ -22863,6 +23172,150 @@ class ERBRenderNode extends Node {
22863
23172
  return output;
22864
23173
  }
22865
23174
  }
23175
+ class RubyStrictLocalNode extends Node {
23176
+ name;
23177
+ default_value;
23178
+ required;
23179
+ double_splat;
23180
+ static get type() {
23181
+ return "AST_RUBY_STRICT_LOCAL_NODE";
23182
+ }
23183
+ static from(data) {
23184
+ return new RubyStrictLocalNode({
23185
+ type: data.type,
23186
+ location: Location.from(data.location),
23187
+ errors: (data.errors || []).map(error => HerbError.from(error)),
23188
+ name: data.name ? Token.from(data.name) : null,
23189
+ default_value: data.default_value ? fromSerializedNode((data.default_value)) : null,
23190
+ required: data.required,
23191
+ double_splat: data.double_splat,
23192
+ });
23193
+ }
23194
+ constructor(props) {
23195
+ super(props.type, props.location, props.errors);
23196
+ this.name = props.name;
23197
+ this.default_value = props.default_value;
23198
+ this.required = props.required;
23199
+ this.double_splat = props.double_splat;
23200
+ }
23201
+ accept(visitor) {
23202
+ visitor.visitRubyStrictLocalNode(this);
23203
+ }
23204
+ childNodes() {
23205
+ return [
23206
+ this.default_value,
23207
+ ];
23208
+ }
23209
+ compactChildNodes() {
23210
+ return this.childNodes().filter(node => node !== null && node !== undefined);
23211
+ }
23212
+ recursiveErrors() {
23213
+ return [
23214
+ ...this.errors,
23215
+ this.default_value ? this.default_value.recursiveErrors() : [],
23216
+ ].flat();
23217
+ }
23218
+ toJSON() {
23219
+ return {
23220
+ ...super.toJSON(),
23221
+ type: "AST_RUBY_STRICT_LOCAL_NODE",
23222
+ name: this.name ? this.name.toJSON() : null,
23223
+ default_value: this.default_value ? this.default_value.toJSON() : null,
23224
+ required: this.required,
23225
+ double_splat: this.double_splat,
23226
+ };
23227
+ }
23228
+ treeInspect() {
23229
+ let output = "";
23230
+ output += `@ RubyStrictLocalNode ${this.location.treeInspectWithLabel()}\n`;
23231
+ output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
23232
+ output += `├── name: ${this.name ? this.name.treeInspect() : "∅"}\n`;
23233
+ output += `├── default_value: ${this.inspectNode(this.default_value, "│ ")}`;
23234
+ output += `├── required: ${typeof this.required === 'boolean' ? String(this.required) : "∅"}\n`;
23235
+ output += `└── double_splat: ${typeof this.double_splat === 'boolean' ? String(this.double_splat) : "∅"}\n`;
23236
+ return output;
23237
+ }
23238
+ }
23239
+ class ERBStrictLocalsNode extends Node {
23240
+ tag_opening;
23241
+ content;
23242
+ tag_closing;
23243
+ // no-op for analyzed_ruby
23244
+ prism_node;
23245
+ locals;
23246
+ static get type() {
23247
+ return "AST_ERB_STRICT_LOCALS_NODE";
23248
+ }
23249
+ static from(data) {
23250
+ return new ERBStrictLocalsNode({
23251
+ type: data.type,
23252
+ location: Location.from(data.location),
23253
+ errors: (data.errors || []).map(error => HerbError.from(error)),
23254
+ tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
23255
+ content: data.content ? Token.from(data.content) : null,
23256
+ tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
23257
+ // no-op for analyzed_ruby
23258
+ prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
23259
+ locals: (data.locals || []).map(node => fromSerializedNode(node)),
23260
+ });
23261
+ }
23262
+ constructor(props) {
23263
+ super(props.type, props.location, props.errors);
23264
+ this.tag_opening = props.tag_opening;
23265
+ this.content = props.content;
23266
+ this.tag_closing = props.tag_closing;
23267
+ // no-op for analyzed_ruby
23268
+ this.prism_node = props.prism_node;
23269
+ this.locals = props.locals;
23270
+ }
23271
+ accept(visitor) {
23272
+ visitor.visitERBStrictLocalsNode(this);
23273
+ }
23274
+ childNodes() {
23275
+ return [
23276
+ ...this.locals,
23277
+ ];
23278
+ }
23279
+ compactChildNodes() {
23280
+ return this.childNodes().filter(node => node !== null && node !== undefined);
23281
+ }
23282
+ get prismNode() {
23283
+ if (!this.prism_node || !this.source)
23284
+ return null;
23285
+ return deserializePrismNode(this.prism_node, this.source);
23286
+ }
23287
+ recursiveErrors() {
23288
+ return [
23289
+ ...this.errors,
23290
+ ...this.locals.map(node => node.recursiveErrors()),
23291
+ ].flat();
23292
+ }
23293
+ toJSON() {
23294
+ return {
23295
+ ...super.toJSON(),
23296
+ type: "AST_ERB_STRICT_LOCALS_NODE",
23297
+ tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
23298
+ content: this.content ? this.content.toJSON() : null,
23299
+ tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
23300
+ // no-op for analyzed_ruby
23301
+ prism_node: this.prism_node ? Array.from(this.prism_node) : null,
23302
+ locals: this.locals.map(node => node.toJSON()),
23303
+ };
23304
+ }
23305
+ treeInspect() {
23306
+ let output = "";
23307
+ output += `@ ERBStrictLocalsNode ${this.location.treeInspectWithLabel()}\n`;
23308
+ output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
23309
+ output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
23310
+ output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
23311
+ output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
23312
+ if (this.prism_node) {
23313
+ output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
23314
+ }
23315
+ output += `└── locals: ${this.inspectArray(this.locals, " ")}`;
23316
+ return output;
23317
+ }
23318
+ }
22866
23319
  class ERBYieldNode extends Node {
22867
23320
  tag_opening;
22868
23321
  content;
@@ -23028,6 +23481,8 @@ function fromSerializedNode(node) {
23028
23481
  case "AST_ERB_UNLESS_NODE": return ERBUnlessNode.from(node);
23029
23482
  case "AST_RUBY_RENDER_LOCAL_NODE": return RubyRenderLocalNode.from(node);
23030
23483
  case "AST_ERB_RENDER_NODE": return ERBRenderNode.from(node);
23484
+ case "AST_RUBY_STRICT_LOCAL_NODE": return RubyStrictLocalNode.from(node);
23485
+ case "AST_ERB_STRICT_LOCALS_NODE": return ERBStrictLocalsNode.from(node);
23031
23486
  case "AST_ERB_YIELD_NODE": return ERBYieldNode.from(node);
23032
23487
  case "AST_ERB_IN_NODE": return ERBInNode.from(node);
23033
23488
  default:
@@ -23078,9 +23533,12 @@ const DEFAULT_PARSER_OPTIONS = {
23078
23533
  strict: true,
23079
23534
  action_view_helpers: false,
23080
23535
  render_nodes: false,
23536
+ strict_locals: false,
23081
23537
  prism_nodes: false,
23082
23538
  prism_nodes_deep: false,
23083
23539
  prism_program: false,
23540
+ dot_notation_tags: false,
23541
+ html: true,
23084
23542
  };
23085
23543
  /**
23086
23544
  * Represents the parser options used during parsing.
@@ -23096,12 +23554,18 @@ class ParserOptions {
23096
23554
  action_view_helpers;
23097
23555
  /** Whether ActionView render call detection was enabled during parsing. */
23098
23556
  render_nodes;
23557
+ /** Whether strict locals analysis was enabled during parsing. */
23558
+ strict_locals;
23099
23559
  /** Whether Prism node serialization was enabled during parsing. */
23100
23560
  prism_nodes;
23101
23561
  /** Whether deep Prism node serialization was enabled during parsing. */
23102
23562
  prism_nodes_deep;
23103
23563
  /** Whether the full Prism ProgramNode was serialized on the DocumentNode. */
23104
23564
  prism_program;
23565
+ /** Whether dot-notation component tags (e.g. Dialog.Button) are parsed as HTML elements. */
23566
+ dot_notation_tags;
23567
+ /** Whether HTML tag parsing is enabled during parsing. When false, HTML-like content is treated as literal text. */
23568
+ html;
23105
23569
  static from(options) {
23106
23570
  return new ParserOptions(options);
23107
23571
  }
@@ -23111,9 +23575,12 @@ class ParserOptions {
23111
23575
  this.analyze = options.analyze ?? DEFAULT_PARSER_OPTIONS.analyze;
23112
23576
  this.action_view_helpers = options.action_view_helpers ?? DEFAULT_PARSER_OPTIONS.action_view_helpers;
23113
23577
  this.render_nodes = options.render_nodes ?? DEFAULT_PARSER_OPTIONS.render_nodes;
23578
+ this.strict_locals = options.strict_locals ?? DEFAULT_PARSER_OPTIONS.strict_locals;
23114
23579
  this.prism_nodes = options.prism_nodes ?? DEFAULT_PARSER_OPTIONS.prism_nodes;
23115
23580
  this.prism_nodes_deep = options.prism_nodes_deep ?? DEFAULT_PARSER_OPTIONS.prism_nodes_deep;
23116
23581
  this.prism_program = options.prism_program ?? DEFAULT_PARSER_OPTIONS.prism_program;
23582
+ this.dot_notation_tags = options.dot_notation_tags ?? DEFAULT_PARSER_OPTIONS.dot_notation_tags;
23583
+ this.html = options.html ?? DEFAULT_PARSER_OPTIONS.html;
23117
23584
  }
23118
23585
  }
23119
23586
 
@@ -23190,7 +23657,7 @@ class ParseResult extends Result {
23190
23657
  }
23191
23658
 
23192
23659
  // NOTE: This file is generated by the templates/template.rb script and should not
23193
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/node-type-guards.ts.erb
23660
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.3/templates/javascript/packages/core/src/node-type-guards.ts.erb
23194
23661
  /**
23195
23662
  * Type guard functions for AST nodes.
23196
23663
  * These functions provide type checking by combining both instanceof
@@ -23501,6 +23968,22 @@ function isERBRenderNode(node) {
23501
23968
  return false;
23502
23969
  return node instanceof ERBRenderNode || node.type === "AST_ERB_RENDER_NODE" || node.constructor.type === "AST_ERB_RENDER_NODE";
23503
23970
  }
23971
+ /**
23972
+ * Checks if a node is a RubyStrictLocalNode
23973
+ */
23974
+ function isRubyStrictLocalNode(node) {
23975
+ if (!node)
23976
+ return false;
23977
+ return node instanceof RubyStrictLocalNode || node.type === "AST_RUBY_STRICT_LOCAL_NODE" || node.constructor.type === "AST_RUBY_STRICT_LOCAL_NODE";
23978
+ }
23979
+ /**
23980
+ * Checks if a node is a ERBStrictLocalsNode
23981
+ */
23982
+ function isERBStrictLocalsNode(node) {
23983
+ if (!node)
23984
+ return false;
23985
+ return node instanceof ERBStrictLocalsNode || node.type === "AST_ERB_STRICT_LOCALS_NODE" || node.constructor.type === "AST_ERB_STRICT_LOCALS_NODE";
23986
+ }
23504
23987
  /**
23505
23988
  * Checks if a node is a ERBYieldNode
23506
23989
  */
@@ -23566,6 +24049,8 @@ const NODE_TYPE_GUARDS = new Map([
23566
24049
  [ERBUnlessNode, isERBUnlessNode],
23567
24050
  [RubyRenderLocalNode, isRubyRenderLocalNode],
23568
24051
  [ERBRenderNode, isERBRenderNode],
24052
+ [RubyStrictLocalNode, isRubyStrictLocalNode],
24053
+ [ERBStrictLocalsNode, isERBStrictLocalsNode],
23569
24054
  [ERBYieldNode, isERBYieldNode],
23570
24055
  [ERBInNode, isERBInNode],
23571
24056
  ]);
@@ -23618,6 +24103,8 @@ const AST_TYPE_GUARDS = new Map([
23618
24103
  ["AST_ERB_UNLESS_NODE", isERBUnlessNode],
23619
24104
  ["AST_RUBY_RENDER_LOCAL_NODE", isRubyRenderLocalNode],
23620
24105
  ["AST_ERB_RENDER_NODE", isERBRenderNode],
24106
+ ["AST_RUBY_STRICT_LOCAL_NODE", isRubyStrictLocalNode],
24107
+ ["AST_ERB_STRICT_LOCALS_NODE", isERBStrictLocalsNode],
23621
24108
  ["AST_ERB_YIELD_NODE", isERBYieldNode],
23622
24109
  ["AST_ERB_IN_NODE", isERBInNode],
23623
24110
  ]);
@@ -23844,7 +24331,7 @@ function createSyntheticToken(value, type = "TOKEN_SYNTHETIC") {
23844
24331
  }
23845
24332
 
23846
24333
  // NOTE: This file is generated by the templates/template.rb script and should not
23847
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/visitor.ts.erb
24334
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.3/templates/javascript/packages/core/src/visitor.ts.erb
23848
24335
  class Visitor {
23849
24336
  visit(node) {
23850
24337
  if (!node)
@@ -24032,6 +24519,15 @@ class Visitor {
24032
24519
  this.visitERBNode(node);
24033
24520
  this.visitChildNodes(node);
24034
24521
  }
24522
+ visitRubyStrictLocalNode(node) {
24523
+ this.visitNode(node);
24524
+ this.visitChildNodes(node);
24525
+ }
24526
+ visitERBStrictLocalsNode(node) {
24527
+ this.visitNode(node);
24528
+ this.visitERBNode(node);
24529
+ this.visitChildNodes(node);
24530
+ }
24035
24531
  visitERBYieldNode(node) {
24036
24532
  this.visitNode(node);
24037
24533
  this.visitERBNode(node);
@@ -24064,6 +24560,34 @@ function createWhitespaceNode() {
24064
24560
  });
24065
24561
  }
24066
24562
  class ActionViewTagHelperToHTMLVisitor extends Visitor {
24563
+ shallow;
24564
+ includeBody;
24565
+ constructor(options = {}) {
24566
+ super();
24567
+ this.shallow = options.shallow ?? false;
24568
+ this.includeBody = options.includeBody ?? true;
24569
+ }
24570
+ visitHTMLOpenTagNode(node) {
24571
+ const newChildren = [];
24572
+ for (let index = 0; index < node.children.length; index++) {
24573
+ const child = node.children[index];
24574
+ if (isHTMLAttributeNode(child)) {
24575
+ if (child.equals && child.equals.value !== "=") {
24576
+ asMutable(child).equals = createSyntheticToken("=");
24577
+ }
24578
+ if (child.value) {
24579
+ this.transformAttributeValue(child.value);
24580
+ }
24581
+ const previous = index > 0 ? node.children[index - 1] : null;
24582
+ if (!previous || !isWhitespaceNode(previous)) {
24583
+ newChildren.push(createWhitespaceNode());
24584
+ }
24585
+ }
24586
+ newChildren.push(child);
24587
+ }
24588
+ asMutable(node).children = newChildren;
24589
+ this.visitChildNodes(node);
24590
+ }
24067
24591
  visitHTMLElementNode(node) {
24068
24592
  if (!node.element_source) {
24069
24593
  this.visitChildNodes(node);
@@ -24134,7 +24658,10 @@ class ActionViewTagHelperToHTMLVisitor extends Visitor {
24134
24658
  asMutable(node).close_tag = htmlCloseTag;
24135
24659
  }
24136
24660
  asMutable(node).element_source = "HTML";
24137
- if (node.body) {
24661
+ if (!this.includeBody) {
24662
+ asMutable(node).body = [];
24663
+ }
24664
+ else if (node.body) {
24138
24665
  asMutable(node).body = node.body.map(child => {
24139
24666
  if (isRubyLiteralNode(child)) {
24140
24667
  return new ERBContentNode({
@@ -24149,7 +24676,9 @@ class ActionViewTagHelperToHTMLVisitor extends Visitor {
24149
24676
  prism_node: null
24150
24677
  });
24151
24678
  }
24152
- this.visit(child);
24679
+ if (!this.shallow) {
24680
+ this.visit(child);
24681
+ }
24153
24682
  return child;
24154
24683
  });
24155
24684
  }
@@ -24175,11 +24704,11 @@ class ActionViewTagHelperToHTMLVisitor extends Visitor {
24175
24704
  return child;
24176
24705
  });
24177
24706
  mutableValue.children = newChildren;
24178
- if (!value.quoted) {
24179
- mutableValue.quoted = true;
24180
- mutableValue.open_quote = createSyntheticToken('"');
24181
- mutableValue.close_quote = createSyntheticToken('"');
24182
- }
24707
+ }
24708
+ if (!value.quoted) {
24709
+ mutableValue.quoted = true;
24710
+ mutableValue.open_quote = createSyntheticToken('"');
24711
+ mutableValue.close_quote = createSyntheticToken('"');
24183
24712
  }
24184
24713
  }
24185
24714
  }
@@ -24188,10 +24717,10 @@ class ActionViewTagHelperToHTMLRewriter extends ASTRewriter {
24188
24717
  return "action-view-tag-helper-to-html";
24189
24718
  }
24190
24719
  get description() {
24191
- return "Converts ActionView tag helpers (tag.*, content_tag, link_to, turbo_frame_tag) to raw HTML elements";
24720
+ return "Converts ActionView tag helpers to raw HTML elements";
24192
24721
  }
24193
- rewrite(node, _context) {
24194
- const visitor = new ActionViewTagHelperToHTMLVisitor();
24722
+ rewrite(node, context) {
24723
+ const visitor = new ActionViewTagHelperToHTMLVisitor({ shallow: context.shallow, includeBody: context.includeBody });
24195
24724
  visitor.visit(node);
24196
24725
  return node;
24197
24726
  }
@@ -24221,6 +24750,7 @@ function serializeAttributes(children, options = {}) {
24221
24750
  const prefixed = new Map();
24222
24751
  let href = null;
24223
24752
  let id = null;
24753
+ let src = null;
24224
24754
  for (const child of children) {
24225
24755
  if (!isHTMLAttributeNode(child))
24226
24756
  continue;
@@ -24236,6 +24766,10 @@ function serializeAttributes(children, options = {}) {
24236
24766
  id = value;
24237
24767
  continue;
24238
24768
  }
24769
+ if (options.extractSrc && name === "src") {
24770
+ src = value;
24771
+ continue;
24772
+ }
24239
24773
  const dataMatch = name.match(/^(data|aria)-(.+)$/);
24240
24774
  if (dataMatch) {
24241
24775
  const [, prefix, rest] = dataMatch;
@@ -24252,7 +24786,7 @@ function serializeAttributes(children, options = {}) {
24252
24786
  for (const [prefix, entries] of prefixed) {
24253
24787
  parts.push(`${prefix}: { ${entries.join(", ")} }`);
24254
24788
  }
24255
- return { attributes: parts.join(", "), href, id };
24789
+ return { attributes: parts.join(", "), href, id, src };
24256
24790
  }
24257
24791
  function isTextOnlyBody(body) {
24258
24792
  if (body.length !== 1 || !isHTMLTextNode(body[0]))
@@ -24278,8 +24812,11 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
24278
24812
  }
24279
24813
  const isAnchor = tagName.value === "a";
24280
24814
  const isTurboFrame = tagName.value === "turbo-frame";
24815
+ const isScript = tagName.value === "script";
24816
+ const isImg = tagName.value === "img";
24281
24817
  const attributes = openTag.children.filter(child => !isWhitespaceNode(child));
24282
- const { attributes: attributesString, href, id } = serializeAttributes(attributes, { extractHref: isAnchor, extractId: isTurboFrame });
24818
+ const hasSrcAttribute = (isScript || isImg) && attributes.some(child => isHTMLAttributeNode(child) && getStaticAttributeName(child.name) === "src");
24819
+ const { attributes: attributesString, href, id, src } = serializeAttributes(attributes, { extractHref: isAnchor, extractId: isTurboFrame, extractSrc: isScript || isImg });
24283
24820
  const hasBody = node.body && node.body.length > 0 && !node.is_void;
24284
24821
  const isInlineContent = hasBody && isTextOnlyBody(node.body);
24285
24822
  let content;
@@ -24292,6 +24829,18 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
24292
24829
  content = this.buildTurboFrameTagContent(node, attributesString, id, isInlineContent);
24293
24830
  elementSource = "Turbo::FramesHelper#turbo_frame_tag";
24294
24831
  }
24832
+ else if (isScript && hasSrcAttribute) {
24833
+ content = this.buildJavascriptIncludeTagContent(attributesString, src);
24834
+ elementSource = "ActionView::Helpers::AssetTagHelper#javascript_include_tag";
24835
+ }
24836
+ else if (isScript) {
24837
+ content = this.buildJavascriptTagContent(node, attributesString, isInlineContent);
24838
+ elementSource = "ActionView::Helpers::JavaScriptHelper#javascript_tag";
24839
+ }
24840
+ else if (isImg) {
24841
+ content = this.buildImageTagContent(attributesString, src);
24842
+ elementSource = "ActionView::Helpers::AssetTagHelper#image_tag";
24843
+ }
24295
24844
  else {
24296
24845
  content = this.buildTagContent(tagName.value, node, attributesString, isInlineContent);
24297
24846
  elementSource = "ActionView::Helpers::TagHelper#tag";
@@ -24308,7 +24857,8 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
24308
24857
  });
24309
24858
  asMutable(node).open_tag = erbOpenTag;
24310
24859
  asMutable(node).element_source = elementSource;
24311
- const isInlineForm = isInlineContent || (isTurboFrame && !hasBody);
24860
+ const isInlineLiteralContent = isScript && hasBody && node.body.length === 1 && isLiteralNode(node.body[0]) && !node.body[0].content.includes("\n");
24861
+ const isInlineForm = isInlineContent || isInlineLiteralContent || (isTurboFrame && !hasBody) || (isScript && hasSrcAttribute) || isImg;
24312
24862
  if (node.is_void) {
24313
24863
  asMutable(node).close_tag = null;
24314
24864
  }
@@ -24368,6 +24918,39 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
24368
24918
  }
24369
24919
  return argString ? ` turbo_frame_tag ${argString} do ` : ` turbo_frame_tag do `;
24370
24920
  }
24921
+ buildJavascriptTagContent(node, attributes, isInlineContent) {
24922
+ const bodyNode = node.body?.[0];
24923
+ const isInlineLiteral = bodyNode && isLiteralNode(bodyNode) && !bodyNode.content.includes("\n");
24924
+ const isInlineText = isInlineContent && isHTMLTextNode(bodyNode);
24925
+ if (isInlineText || isInlineLiteral) {
24926
+ const textContent = isHTMLTextNode(bodyNode) ? bodyNode.content : bodyNode.content;
24927
+ const args = [`"${textContent}"`];
24928
+ if (attributes)
24929
+ args.push(attributes);
24930
+ return ` javascript_tag ${args.join(", ")} `;
24931
+ }
24932
+ return attributes
24933
+ ? ` javascript_tag ${attributes} do `
24934
+ : ` javascript_tag do `;
24935
+ }
24936
+ buildJavascriptIncludeTagContent(attributes, source) {
24937
+ const args = [];
24938
+ if (source)
24939
+ args.push(source);
24940
+ if (attributes)
24941
+ args.push(attributes);
24942
+ const argString = args.join(", ");
24943
+ return argString ? ` javascript_include_tag ${argString} ` : ` javascript_include_tag `;
24944
+ }
24945
+ buildImageTagContent(attributes, source) {
24946
+ const args = [];
24947
+ if (source)
24948
+ args.push(source);
24949
+ if (attributes)
24950
+ args.push(attributes);
24951
+ const argString = args.join(", ");
24952
+ return argString ? ` image_tag ${argString} ` : ` image_tag `;
24953
+ }
24371
24954
  buildLinkToContent(node, attribute, href, isInlineContent) {
24372
24955
  const args = [];
24373
24956
  if (isInlineContent && isHTMLTextNode(node.body[0])) {
@@ -24391,7 +24974,7 @@ class HTMLToActionViewTagHelperRewriter extends ASTRewriter {
24391
24974
  return "html-to-action-view-tag-helper";
24392
24975
  }
24393
24976
  get description() {
24394
- return "Converts raw HTML elements to ActionView tag helpers (tag.*, turbo_frame_tag)";
24977
+ return "Converts raw HTML elements to ActionView tag helpers (tag.*, turbo_frame_tag, javascript_tag, javascript_include_tag, image_tag)";
24395
24978
  }
24396
24979
  rewrite(node, _context) {
24397
24980
  const visitor = new HTMLToActionViewTagHelperVisitor();
@@ -24818,6 +25401,15 @@ class IdentityPrinter extends Printer {
24818
25401
  if (node.body) {
24819
25402
  node.body.forEach(child => this.visit(child));
24820
25403
  }
25404
+ if (node.rescue_clause) {
25405
+ this.visit(node.rescue_clause);
25406
+ }
25407
+ if (node.else_clause) {
25408
+ this.visit(node.else_clause);
25409
+ }
25410
+ if (node.ensure_clause) {
25411
+ this.visit(node.ensure_clause);
25412
+ }
24821
25413
  if (node.end_node) {
24822
25414
  this.visit(node.end_node);
24823
25415
  }
@@ -24921,6 +25513,12 @@ class IdentityPrinter extends Printer {
24921
25513
  visitRubyRenderLocalNode(_node) {
24922
25514
  // extracted metadata, nothing to print
24923
25515
  }
25516
+ visitERBStrictLocalsNode(node) {
25517
+ this.printERBNode(node);
25518
+ }
25519
+ visitRubyStrictLocalNode(_node) {
25520
+ // extracted metadata, nothing to print
25521
+ }
24924
25522
  visitERBYieldNode(node) {
24925
25523
  this.printERBNode(node);
24926
25524
  }