@herb-tools/rewriter 0.9.0 → 0.9.2

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/index.cjs CHANGED
@@ -202,7 +202,7 @@ class Token {
202
202
  }
203
203
 
204
204
  // NOTE: This file is generated by the templates/template.rb script and should not
205
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.0/templates/javascript/packages/core/src/errors.ts.erb
205
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.2/templates/javascript/packages/core/src/errors.ts.erb
206
206
  class HerbError {
207
207
  type;
208
208
  message;
@@ -1203,6 +1203,279 @@ class NestedERBTagError extends HerbError {
1203
1203
  return output;
1204
1204
  }
1205
1205
  }
1206
+ class RenderAmbiguousLocalsError extends HerbError {
1207
+ partial;
1208
+ static from(data) {
1209
+ return new RenderAmbiguousLocalsError({
1210
+ type: data.type,
1211
+ message: data.message,
1212
+ location: Location.from(data.location),
1213
+ partial: data.partial,
1214
+ });
1215
+ }
1216
+ constructor(props) {
1217
+ super(props.type, props.message, props.location);
1218
+ this.partial = props.partial;
1219
+ }
1220
+ toJSON() {
1221
+ return {
1222
+ ...super.toJSON(),
1223
+ type: "RENDER_AMBIGUOUS_LOCALS_ERROR",
1224
+ partial: this.partial,
1225
+ };
1226
+ }
1227
+ toMonacoDiagnostic() {
1228
+ return {
1229
+ line: this.location.start.line,
1230
+ column: this.location.start.column,
1231
+ endLine: this.location.end.line,
1232
+ endColumn: this.location.end.column,
1233
+ message: this.message,
1234
+ severity: 'error'
1235
+ };
1236
+ }
1237
+ treeInspect() {
1238
+ let output = "";
1239
+ output += `@ RenderAmbiguousLocalsError ${this.location.treeInspectWithLabel()}\n`;
1240
+ output += `├── message: "${this.message}"\n`;
1241
+ output += `└── partial: ${JSON.stringify(this.partial)}\n`;
1242
+ return output;
1243
+ }
1244
+ }
1245
+ class RenderMissingLocalsError extends HerbError {
1246
+ partial;
1247
+ keywords;
1248
+ static from(data) {
1249
+ return new RenderMissingLocalsError({
1250
+ type: data.type,
1251
+ message: data.message,
1252
+ location: Location.from(data.location),
1253
+ partial: data.partial,
1254
+ keywords: data.keywords,
1255
+ });
1256
+ }
1257
+ constructor(props) {
1258
+ super(props.type, props.message, props.location);
1259
+ this.partial = props.partial;
1260
+ this.keywords = props.keywords;
1261
+ }
1262
+ toJSON() {
1263
+ return {
1264
+ ...super.toJSON(),
1265
+ type: "RENDER_MISSING_LOCALS_ERROR",
1266
+ partial: this.partial,
1267
+ keywords: this.keywords,
1268
+ };
1269
+ }
1270
+ toMonacoDiagnostic() {
1271
+ return {
1272
+ line: this.location.start.line,
1273
+ column: this.location.start.column,
1274
+ endLine: this.location.end.line,
1275
+ endColumn: this.location.end.column,
1276
+ message: this.message,
1277
+ severity: 'error'
1278
+ };
1279
+ }
1280
+ treeInspect() {
1281
+ let output = "";
1282
+ output += `@ RenderMissingLocalsError ${this.location.treeInspectWithLabel()}\n`;
1283
+ output += `├── message: "${this.message}"\n`;
1284
+ output += `├── partial: ${JSON.stringify(this.partial)}\n`;
1285
+ output += `└── keywords: ${JSON.stringify(this.keywords)}\n`;
1286
+ return output;
1287
+ }
1288
+ }
1289
+ class RenderNoArgumentsError extends HerbError {
1290
+ static from(data) {
1291
+ return new RenderNoArgumentsError({
1292
+ type: data.type,
1293
+ message: data.message,
1294
+ location: Location.from(data.location),
1295
+ });
1296
+ }
1297
+ constructor(props) {
1298
+ super(props.type, props.message, props.location);
1299
+ }
1300
+ toJSON() {
1301
+ return {
1302
+ ...super.toJSON(),
1303
+ type: "RENDER_NO_ARGUMENTS_ERROR",
1304
+ };
1305
+ }
1306
+ toMonacoDiagnostic() {
1307
+ return {
1308
+ line: this.location.start.line,
1309
+ column: this.location.start.column,
1310
+ endLine: this.location.end.line,
1311
+ endColumn: this.location.end.column,
1312
+ message: this.message,
1313
+ severity: 'error'
1314
+ };
1315
+ }
1316
+ treeInspect() {
1317
+ let output = "";
1318
+ output += `@ RenderNoArgumentsError ${this.location.treeInspectWithLabel()}\n`;
1319
+ output += `└── message: "${this.message}"\n`;
1320
+ return output;
1321
+ }
1322
+ }
1323
+ class RenderConflictingPartialError extends HerbError {
1324
+ positional_partial;
1325
+ keyword_partial;
1326
+ static from(data) {
1327
+ return new RenderConflictingPartialError({
1328
+ type: data.type,
1329
+ message: data.message,
1330
+ location: Location.from(data.location),
1331
+ positional_partial: data.positional_partial,
1332
+ keyword_partial: data.keyword_partial,
1333
+ });
1334
+ }
1335
+ constructor(props) {
1336
+ super(props.type, props.message, props.location);
1337
+ this.positional_partial = props.positional_partial;
1338
+ this.keyword_partial = props.keyword_partial;
1339
+ }
1340
+ toJSON() {
1341
+ return {
1342
+ ...super.toJSON(),
1343
+ type: "RENDER_CONFLICTING_PARTIAL_ERROR",
1344
+ positional_partial: this.positional_partial,
1345
+ keyword_partial: this.keyword_partial,
1346
+ };
1347
+ }
1348
+ toMonacoDiagnostic() {
1349
+ return {
1350
+ line: this.location.start.line,
1351
+ column: this.location.start.column,
1352
+ endLine: this.location.end.line,
1353
+ endColumn: this.location.end.column,
1354
+ message: this.message,
1355
+ severity: 'error'
1356
+ };
1357
+ }
1358
+ treeInspect() {
1359
+ let output = "";
1360
+ output += `@ RenderConflictingPartialError ${this.location.treeInspectWithLabel()}\n`;
1361
+ output += `├── message: "${this.message}"\n`;
1362
+ output += `├── positional_partial: ${JSON.stringify(this.positional_partial)}\n`;
1363
+ output += `└── keyword_partial: ${JSON.stringify(this.keyword_partial)}\n`;
1364
+ return output;
1365
+ }
1366
+ }
1367
+ class RenderInvalidAsOptionError extends HerbError {
1368
+ as_value;
1369
+ static from(data) {
1370
+ return new RenderInvalidAsOptionError({
1371
+ type: data.type,
1372
+ message: data.message,
1373
+ location: Location.from(data.location),
1374
+ as_value: data.as_value,
1375
+ });
1376
+ }
1377
+ constructor(props) {
1378
+ super(props.type, props.message, props.location);
1379
+ this.as_value = props.as_value;
1380
+ }
1381
+ toJSON() {
1382
+ return {
1383
+ ...super.toJSON(),
1384
+ type: "RENDER_INVALID_AS_OPTION_ERROR",
1385
+ as_value: this.as_value,
1386
+ };
1387
+ }
1388
+ toMonacoDiagnostic() {
1389
+ return {
1390
+ line: this.location.start.line,
1391
+ column: this.location.start.column,
1392
+ endLine: this.location.end.line,
1393
+ endColumn: this.location.end.column,
1394
+ message: this.message,
1395
+ severity: 'error'
1396
+ };
1397
+ }
1398
+ treeInspect() {
1399
+ let output = "";
1400
+ output += `@ RenderInvalidAsOptionError ${this.location.treeInspectWithLabel()}\n`;
1401
+ output += `├── message: "${this.message}"\n`;
1402
+ output += `└── as_value: ${JSON.stringify(this.as_value)}\n`;
1403
+ return output;
1404
+ }
1405
+ }
1406
+ class RenderObjectAndCollectionError extends HerbError {
1407
+ static from(data) {
1408
+ return new RenderObjectAndCollectionError({
1409
+ type: data.type,
1410
+ message: data.message,
1411
+ location: Location.from(data.location),
1412
+ });
1413
+ }
1414
+ constructor(props) {
1415
+ super(props.type, props.message, props.location);
1416
+ }
1417
+ toJSON() {
1418
+ return {
1419
+ ...super.toJSON(),
1420
+ type: "RENDER_OBJECT_AND_COLLECTION_ERROR",
1421
+ };
1422
+ }
1423
+ toMonacoDiagnostic() {
1424
+ return {
1425
+ line: this.location.start.line,
1426
+ column: this.location.start.column,
1427
+ endLine: this.location.end.line,
1428
+ endColumn: this.location.end.column,
1429
+ message: this.message,
1430
+ severity: 'error'
1431
+ };
1432
+ }
1433
+ treeInspect() {
1434
+ let output = "";
1435
+ output += `@ RenderObjectAndCollectionError ${this.location.treeInspectWithLabel()}\n`;
1436
+ output += `└── message: "${this.message}"\n`;
1437
+ return output;
1438
+ }
1439
+ }
1440
+ class RenderLayoutWithoutBlockError extends HerbError {
1441
+ layout;
1442
+ static from(data) {
1443
+ return new RenderLayoutWithoutBlockError({
1444
+ type: data.type,
1445
+ message: data.message,
1446
+ location: Location.from(data.location),
1447
+ layout: data.layout,
1448
+ });
1449
+ }
1450
+ constructor(props) {
1451
+ super(props.type, props.message, props.location);
1452
+ this.layout = props.layout;
1453
+ }
1454
+ toJSON() {
1455
+ return {
1456
+ ...super.toJSON(),
1457
+ type: "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR",
1458
+ layout: this.layout,
1459
+ };
1460
+ }
1461
+ toMonacoDiagnostic() {
1462
+ return {
1463
+ line: this.location.start.line,
1464
+ column: this.location.start.column,
1465
+ endLine: this.location.end.line,
1466
+ endColumn: this.location.end.column,
1467
+ message: this.message,
1468
+ severity: 'error'
1469
+ };
1470
+ }
1471
+ treeInspect() {
1472
+ let output = "";
1473
+ output += `@ RenderLayoutWithoutBlockError ${this.location.treeInspectWithLabel()}\n`;
1474
+ output += `├── message: "${this.message}"\n`;
1475
+ output += `└── layout: ${JSON.stringify(this.layout)}\n`;
1476
+ return output;
1477
+ }
1478
+ }
1206
1479
  function fromSerializedError(error) {
1207
1480
  switch (error.type) {
1208
1481
  case "UNEXPECTED_ERROR": return UnexpectedError.from(error);
@@ -1228,6 +1501,13 @@ function fromSerializedError(error) {
1228
1501
  case "UNCLOSED_ERB_TAG_ERROR": return UnclosedERBTagError.from(error);
1229
1502
  case "STRAY_ERB_CLOSING_TAG_ERROR": return StrayERBClosingTagError.from(error);
1230
1503
  case "NESTED_ERB_TAG_ERROR": return NestedERBTagError.from(error);
1504
+ case "RENDER_AMBIGUOUS_LOCALS_ERROR": return RenderAmbiguousLocalsError.from(error);
1505
+ case "RENDER_MISSING_LOCALS_ERROR": return RenderMissingLocalsError.from(error);
1506
+ case "RENDER_NO_ARGUMENTS_ERROR": return RenderNoArgumentsError.from(error);
1507
+ case "RENDER_CONFLICTING_PARTIAL_ERROR": return RenderConflictingPartialError.from(error);
1508
+ case "RENDER_INVALID_AS_OPTION_ERROR": return RenderInvalidAsOptionError.from(error);
1509
+ case "RENDER_OBJECT_AND_COLLECTION_ERROR": return RenderObjectAndCollectionError.from(error);
1510
+ case "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR": return RenderLayoutWithoutBlockError.from(error);
1231
1511
  default:
1232
1512
  throw new Error(`Unknown node type: ${error.type}`);
1233
1513
  }
@@ -19816,7 +20096,7 @@ function deserializePrismNode(bytes, source) {
19816
20096
  }
19817
20097
 
19818
20098
  // NOTE: This file is generated by the templates/template.rb script and should not
19819
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.0/templates/javascript/packages/core/src/nodes.ts.erb
20099
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.2/templates/javascript/packages/core/src/nodes.ts.erb
19820
20100
  class Node {
19821
20101
  type;
19822
20102
  location;
@@ -22360,6 +22640,225 @@ class ERBUnlessNode extends Node {
22360
22640
  return output;
22361
22641
  }
22362
22642
  }
22643
+ class RubyRenderLocalNode extends Node {
22644
+ name;
22645
+ value;
22646
+ static get type() {
22647
+ return "AST_RUBY_RENDER_LOCAL_NODE";
22648
+ }
22649
+ static from(data) {
22650
+ return new RubyRenderLocalNode({
22651
+ type: data.type,
22652
+ location: Location.from(data.location),
22653
+ errors: (data.errors || []).map(error => HerbError.from(error)),
22654
+ name: data.name ? Token.from(data.name) : null,
22655
+ value: data.value ? fromSerializedNode((data.value)) : null,
22656
+ });
22657
+ }
22658
+ constructor(props) {
22659
+ super(props.type, props.location, props.errors);
22660
+ this.name = props.name;
22661
+ this.value = props.value;
22662
+ }
22663
+ accept(visitor) {
22664
+ visitor.visitRubyRenderLocalNode(this);
22665
+ }
22666
+ childNodes() {
22667
+ return [
22668
+ this.value,
22669
+ ];
22670
+ }
22671
+ compactChildNodes() {
22672
+ return this.childNodes().filter(node => node !== null && node !== undefined);
22673
+ }
22674
+ recursiveErrors() {
22675
+ return [
22676
+ ...this.errors,
22677
+ this.value ? this.value.recursiveErrors() : [],
22678
+ ].flat();
22679
+ }
22680
+ toJSON() {
22681
+ return {
22682
+ ...super.toJSON(),
22683
+ type: "AST_RUBY_RENDER_LOCAL_NODE",
22684
+ name: this.name ? this.name.toJSON() : null,
22685
+ value: this.value ? this.value.toJSON() : null,
22686
+ };
22687
+ }
22688
+ treeInspect() {
22689
+ let output = "";
22690
+ output += `@ RubyRenderLocalNode ${this.location.treeInspectWithLabel()}\n`;
22691
+ output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
22692
+ output += `├── name: ${this.name ? this.name.treeInspect() : "∅"}\n`;
22693
+ output += `└── value: ${this.inspectNode(this.value, " ")}`;
22694
+ return output;
22695
+ }
22696
+ }
22697
+ class ERBRenderNode extends Node {
22698
+ tag_opening;
22699
+ content;
22700
+ tag_closing;
22701
+ // no-op for analyzed_ruby
22702
+ prism_node;
22703
+ partial;
22704
+ template_path;
22705
+ layout;
22706
+ file;
22707
+ inline_template;
22708
+ body;
22709
+ plain;
22710
+ html;
22711
+ renderable;
22712
+ collection;
22713
+ object;
22714
+ as_name;
22715
+ spacer_template;
22716
+ formats;
22717
+ variants;
22718
+ handlers;
22719
+ content_type;
22720
+ locals;
22721
+ static get type() {
22722
+ return "AST_ERB_RENDER_NODE";
22723
+ }
22724
+ static from(data) {
22725
+ return new ERBRenderNode({
22726
+ type: data.type,
22727
+ location: Location.from(data.location),
22728
+ errors: (data.errors || []).map(error => HerbError.from(error)),
22729
+ tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
22730
+ content: data.content ? Token.from(data.content) : null,
22731
+ tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
22732
+ // no-op for analyzed_ruby
22733
+ prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
22734
+ partial: data.partial ? Token.from(data.partial) : null,
22735
+ template_path: data.template_path ? Token.from(data.template_path) : null,
22736
+ layout: data.layout ? Token.from(data.layout) : null,
22737
+ file: data.file ? Token.from(data.file) : null,
22738
+ inline_template: data.inline_template ? Token.from(data.inline_template) : null,
22739
+ body: data.body ? Token.from(data.body) : null,
22740
+ plain: data.plain ? Token.from(data.plain) : null,
22741
+ html: data.html ? Token.from(data.html) : null,
22742
+ renderable: data.renderable ? Token.from(data.renderable) : null,
22743
+ collection: data.collection ? Token.from(data.collection) : null,
22744
+ object: data.object ? Token.from(data.object) : null,
22745
+ as_name: data.as_name ? Token.from(data.as_name) : null,
22746
+ spacer_template: data.spacer_template ? Token.from(data.spacer_template) : null,
22747
+ formats: data.formats ? Token.from(data.formats) : null,
22748
+ variants: data.variants ? Token.from(data.variants) : null,
22749
+ handlers: data.handlers ? Token.from(data.handlers) : null,
22750
+ content_type: data.content_type ? Token.from(data.content_type) : null,
22751
+ locals: (data.locals || []).map(node => fromSerializedNode(node)),
22752
+ });
22753
+ }
22754
+ constructor(props) {
22755
+ super(props.type, props.location, props.errors);
22756
+ this.tag_opening = props.tag_opening;
22757
+ this.content = props.content;
22758
+ this.tag_closing = props.tag_closing;
22759
+ // no-op for analyzed_ruby
22760
+ this.prism_node = props.prism_node;
22761
+ this.partial = props.partial;
22762
+ this.template_path = props.template_path;
22763
+ this.layout = props.layout;
22764
+ this.file = props.file;
22765
+ this.inline_template = props.inline_template;
22766
+ this.body = props.body;
22767
+ this.plain = props.plain;
22768
+ this.html = props.html;
22769
+ this.renderable = props.renderable;
22770
+ this.collection = props.collection;
22771
+ this.object = props.object;
22772
+ this.as_name = props.as_name;
22773
+ this.spacer_template = props.spacer_template;
22774
+ this.formats = props.formats;
22775
+ this.variants = props.variants;
22776
+ this.handlers = props.handlers;
22777
+ this.content_type = props.content_type;
22778
+ this.locals = props.locals;
22779
+ }
22780
+ accept(visitor) {
22781
+ visitor.visitERBRenderNode(this);
22782
+ }
22783
+ childNodes() {
22784
+ return [
22785
+ ...this.locals,
22786
+ ];
22787
+ }
22788
+ compactChildNodes() {
22789
+ return this.childNodes().filter(node => node !== null && node !== undefined);
22790
+ }
22791
+ get prismNode() {
22792
+ if (!this.prism_node || !this.source)
22793
+ return null;
22794
+ return deserializePrismNode(this.prism_node, this.source);
22795
+ }
22796
+ recursiveErrors() {
22797
+ return [
22798
+ ...this.errors,
22799
+ ...this.locals.map(node => node.recursiveErrors()),
22800
+ ].flat();
22801
+ }
22802
+ toJSON() {
22803
+ return {
22804
+ ...super.toJSON(),
22805
+ type: "AST_ERB_RENDER_NODE",
22806
+ tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
22807
+ content: this.content ? this.content.toJSON() : null,
22808
+ tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
22809
+ // no-op for analyzed_ruby
22810
+ prism_node: this.prism_node ? Array.from(this.prism_node) : null,
22811
+ partial: this.partial ? this.partial.toJSON() : null,
22812
+ template_path: this.template_path ? this.template_path.toJSON() : null,
22813
+ layout: this.layout ? this.layout.toJSON() : null,
22814
+ file: this.file ? this.file.toJSON() : null,
22815
+ inline_template: this.inline_template ? this.inline_template.toJSON() : null,
22816
+ body: this.body ? this.body.toJSON() : null,
22817
+ plain: this.plain ? this.plain.toJSON() : null,
22818
+ html: this.html ? this.html.toJSON() : null,
22819
+ renderable: this.renderable ? this.renderable.toJSON() : null,
22820
+ collection: this.collection ? this.collection.toJSON() : null,
22821
+ object: this.object ? this.object.toJSON() : null,
22822
+ as_name: this.as_name ? this.as_name.toJSON() : null,
22823
+ spacer_template: this.spacer_template ? this.spacer_template.toJSON() : null,
22824
+ formats: this.formats ? this.formats.toJSON() : null,
22825
+ variants: this.variants ? this.variants.toJSON() : null,
22826
+ handlers: this.handlers ? this.handlers.toJSON() : null,
22827
+ content_type: this.content_type ? this.content_type.toJSON() : null,
22828
+ locals: this.locals.map(node => node.toJSON()),
22829
+ };
22830
+ }
22831
+ treeInspect() {
22832
+ let output = "";
22833
+ output += `@ ERBRenderNode ${this.location.treeInspectWithLabel()}\n`;
22834
+ output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
22835
+ output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
22836
+ output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
22837
+ output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
22838
+ if (this.prism_node) {
22839
+ output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
22840
+ }
22841
+ output += `├── partial: ${this.partial ? this.partial.treeInspect() : "∅"}\n`;
22842
+ output += `├── template_path: ${this.template_path ? this.template_path.treeInspect() : "∅"}\n`;
22843
+ output += `├── layout: ${this.layout ? this.layout.treeInspect() : "∅"}\n`;
22844
+ output += `├── file: ${this.file ? this.file.treeInspect() : "∅"}\n`;
22845
+ output += `├── inline_template: ${this.inline_template ? this.inline_template.treeInspect() : "∅"}\n`;
22846
+ output += `├── body: ${this.body ? this.body.treeInspect() : "∅"}\n`;
22847
+ output += `├── plain: ${this.plain ? this.plain.treeInspect() : "∅"}\n`;
22848
+ output += `├── html: ${this.html ? this.html.treeInspect() : "∅"}\n`;
22849
+ output += `├── renderable: ${this.renderable ? this.renderable.treeInspect() : "∅"}\n`;
22850
+ output += `├── collection: ${this.collection ? this.collection.treeInspect() : "∅"}\n`;
22851
+ output += `├── object: ${this.object ? this.object.treeInspect() : "∅"}\n`;
22852
+ output += `├── as_name: ${this.as_name ? this.as_name.treeInspect() : "∅"}\n`;
22853
+ output += `├── spacer_template: ${this.spacer_template ? this.spacer_template.treeInspect() : "∅"}\n`;
22854
+ output += `├── formats: ${this.formats ? this.formats.treeInspect() : "∅"}\n`;
22855
+ output += `├── variants: ${this.variants ? this.variants.treeInspect() : "∅"}\n`;
22856
+ output += `├── handlers: ${this.handlers ? this.handlers.treeInspect() : "∅"}\n`;
22857
+ output += `├── content_type: ${this.content_type ? this.content_type.treeInspect() : "∅"}\n`;
22858
+ output += `└── locals: ${this.inspectArray(this.locals, " ")}`;
22859
+ return output;
22860
+ }
22861
+ }
22363
22862
  class ERBYieldNode extends Node {
22364
22863
  tag_opening;
22365
22864
  content;
@@ -22523,6 +23022,8 @@ function fromSerializedNode(node) {
22523
23022
  case "AST_ERB_ENSURE_NODE": return ERBEnsureNode.from(node);
22524
23023
  case "AST_ERB_BEGIN_NODE": return ERBBeginNode.from(node);
22525
23024
  case "AST_ERB_UNLESS_NODE": return ERBUnlessNode.from(node);
23025
+ case "AST_RUBY_RENDER_LOCAL_NODE": return RubyRenderLocalNode.from(node);
23026
+ case "AST_ERB_RENDER_NODE": return ERBRenderNode.from(node);
22526
23027
  case "AST_ERB_YIELD_NODE": return ERBYieldNode.from(node);
22527
23028
  case "AST_ERB_IN_NODE": return ERBInNode.from(node);
22528
23029
  default:
@@ -22572,6 +23073,7 @@ const DEFAULT_PARSER_OPTIONS = {
22572
23073
  analyze: true,
22573
23074
  strict: true,
22574
23075
  action_view_helpers: false,
23076
+ render_nodes: false,
22575
23077
  prism_nodes: false,
22576
23078
  prism_nodes_deep: false,
22577
23079
  prism_program: false,
@@ -22588,6 +23090,8 @@ class ParserOptions {
22588
23090
  analyze;
22589
23091
  /** Whether ActionView tag helper transformation was enabled during parsing. */
22590
23092
  action_view_helpers;
23093
+ /** Whether ActionView render call detection was enabled during parsing. */
23094
+ render_nodes;
22591
23095
  /** Whether Prism node serialization was enabled during parsing. */
22592
23096
  prism_nodes;
22593
23097
  /** Whether deep Prism node serialization was enabled during parsing. */
@@ -22602,6 +23106,7 @@ class ParserOptions {
22602
23106
  this.track_whitespace = options.track_whitespace ?? DEFAULT_PARSER_OPTIONS.track_whitespace;
22603
23107
  this.analyze = options.analyze ?? DEFAULT_PARSER_OPTIONS.analyze;
22604
23108
  this.action_view_helpers = options.action_view_helpers ?? DEFAULT_PARSER_OPTIONS.action_view_helpers;
23109
+ this.render_nodes = options.render_nodes ?? DEFAULT_PARSER_OPTIONS.render_nodes;
22605
23110
  this.prism_nodes = options.prism_nodes ?? DEFAULT_PARSER_OPTIONS.prism_nodes;
22606
23111
  this.prism_nodes_deep = options.prism_nodes_deep ?? DEFAULT_PARSER_OPTIONS.prism_nodes_deep;
22607
23112
  this.prism_program = options.prism_program ?? DEFAULT_PARSER_OPTIONS.prism_program;
@@ -22681,7 +23186,7 @@ class ParseResult extends Result {
22681
23186
  }
22682
23187
 
22683
23188
  // NOTE: This file is generated by the templates/template.rb script and should not
22684
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.0/templates/javascript/packages/core/src/node-type-guards.ts.erb
23189
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.2/templates/javascript/packages/core/src/node-type-guards.ts.erb
22685
23190
  /**
22686
23191
  * Type guard functions for AST nodes.
22687
23192
  * These functions provide type checking by combining both instanceof
@@ -22976,6 +23481,22 @@ function isERBUnlessNode(node) {
22976
23481
  return false;
22977
23482
  return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE" || node.constructor.type === "AST_ERB_UNLESS_NODE";
22978
23483
  }
23484
+ /**
23485
+ * Checks if a node is a RubyRenderLocalNode
23486
+ */
23487
+ function isRubyRenderLocalNode(node) {
23488
+ if (!node)
23489
+ return false;
23490
+ return node instanceof RubyRenderLocalNode || node.type === "AST_RUBY_RENDER_LOCAL_NODE" || node.constructor.type === "AST_RUBY_RENDER_LOCAL_NODE";
23491
+ }
23492
+ /**
23493
+ * Checks if a node is a ERBRenderNode
23494
+ */
23495
+ function isERBRenderNode(node) {
23496
+ if (!node)
23497
+ return false;
23498
+ return node instanceof ERBRenderNode || node.type === "AST_ERB_RENDER_NODE" || node.constructor.type === "AST_ERB_RENDER_NODE";
23499
+ }
22979
23500
  /**
22980
23501
  * Checks if a node is a ERBYieldNode
22981
23502
  */
@@ -23039,6 +23560,8 @@ const NODE_TYPE_GUARDS = new Map([
23039
23560
  [ERBEnsureNode, isERBEnsureNode],
23040
23561
  [ERBBeginNode, isERBBeginNode],
23041
23562
  [ERBUnlessNode, isERBUnlessNode],
23563
+ [RubyRenderLocalNode, isRubyRenderLocalNode],
23564
+ [ERBRenderNode, isERBRenderNode],
23042
23565
  [ERBYieldNode, isERBYieldNode],
23043
23566
  [ERBInNode, isERBInNode],
23044
23567
  ]);
@@ -23089,6 +23612,8 @@ const AST_TYPE_GUARDS = new Map([
23089
23612
  ["AST_ERB_ENSURE_NODE", isERBEnsureNode],
23090
23613
  ["AST_ERB_BEGIN_NODE", isERBBeginNode],
23091
23614
  ["AST_ERB_UNLESS_NODE", isERBUnlessNode],
23615
+ ["AST_RUBY_RENDER_LOCAL_NODE", isRubyRenderLocalNode],
23616
+ ["AST_ERB_RENDER_NODE", isERBRenderNode],
23092
23617
  ["AST_ERB_YIELD_NODE", isERBYieldNode],
23093
23618
  ["AST_ERB_IN_NODE", isERBInNode],
23094
23619
  ]);
@@ -23210,7 +23735,7 @@ function createSyntheticToken(value, type = "TOKEN_SYNTHETIC") {
23210
23735
  }
23211
23736
 
23212
23737
  // NOTE: This file is generated by the templates/template.rb script and should not
23213
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.0/templates/javascript/packages/core/src/visitor.ts.erb
23738
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.2/templates/javascript/packages/core/src/visitor.ts.erb
23214
23739
  class Visitor {
23215
23740
  visit(node) {
23216
23741
  if (!node)
@@ -23389,6 +23914,15 @@ class Visitor {
23389
23914
  this.visitERBNode(node);
23390
23915
  this.visitChildNodes(node);
23391
23916
  }
23917
+ visitRubyRenderLocalNode(node) {
23918
+ this.visitNode(node);
23919
+ this.visitChildNodes(node);
23920
+ }
23921
+ visitERBRenderNode(node) {
23922
+ this.visitNode(node);
23923
+ this.visitERBNode(node);
23924
+ this.visitChildNodes(node);
23925
+ }
23392
23926
  visitERBYieldNode(node) {
23393
23927
  this.visitNode(node);
23394
23928
  this.visitERBNode(node);
@@ -23545,7 +24079,7 @@ class ActionViewTagHelperToHTMLRewriter extends ASTRewriter {
23545
24079
  return "action-view-tag-helper-to-html";
23546
24080
  }
23547
24081
  get description() {
23548
- return "Converts ActionView tag helpers (tag.*, content_tag, link_to, turbo_frame_tag) to raw HTML elements";
24082
+ return "Converts ActionView tag helpers to raw HTML elements";
23549
24083
  }
23550
24084
  rewrite(node, _context) {
23551
24085
  const visitor = new ActionViewTagHelperToHTMLVisitor();
@@ -23578,6 +24112,7 @@ function serializeAttributes(children, options = {}) {
23578
24112
  const prefixed = new Map();
23579
24113
  let href = null;
23580
24114
  let id = null;
24115
+ let src = null;
23581
24116
  for (const child of children) {
23582
24117
  if (!isHTMLAttributeNode(child))
23583
24118
  continue;
@@ -23593,6 +24128,10 @@ function serializeAttributes(children, options = {}) {
23593
24128
  id = value;
23594
24129
  continue;
23595
24130
  }
24131
+ if (options.extractSrc && name === "src") {
24132
+ src = value;
24133
+ continue;
24134
+ }
23596
24135
  const dataMatch = name.match(/^(data|aria)-(.+)$/);
23597
24136
  if (dataMatch) {
23598
24137
  const [, prefix, rest] = dataMatch;
@@ -23609,7 +24148,7 @@ function serializeAttributes(children, options = {}) {
23609
24148
  for (const [prefix, entries] of prefixed) {
23610
24149
  parts.push(`${prefix}: { ${entries.join(", ")} }`);
23611
24150
  }
23612
- return { attributes: parts.join(", "), href, id };
24151
+ return { attributes: parts.join(", "), href, id, src };
23613
24152
  }
23614
24153
  function isTextOnlyBody(body) {
23615
24154
  if (body.length !== 1 || !isHTMLTextNode(body[0]))
@@ -23635,8 +24174,10 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
23635
24174
  }
23636
24175
  const isAnchor = tagName.value === "a";
23637
24176
  const isTurboFrame = tagName.value === "turbo-frame";
24177
+ const isScript = tagName.value === "script";
23638
24178
  const attributes = openTag.children.filter(child => !isWhitespaceNode(child));
23639
- const { attributes: attributesString, href, id } = serializeAttributes(attributes, { extractHref: isAnchor, extractId: isTurboFrame });
24179
+ const hasSrcAttribute = isScript && attributes.some(child => isHTMLAttributeNode(child) && getStaticAttributeName(child.name) === "src");
24180
+ const { attributes: attributesString, href, id, src } = serializeAttributes(attributes, { extractHref: isAnchor, extractId: isTurboFrame, extractSrc: isScript });
23640
24181
  const hasBody = node.body && node.body.length > 0 && !node.is_void;
23641
24182
  const isInlineContent = hasBody && isTextOnlyBody(node.body);
23642
24183
  let content;
@@ -23649,6 +24190,14 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
23649
24190
  content = this.buildTurboFrameTagContent(node, attributesString, id, isInlineContent);
23650
24191
  elementSource = "Turbo::FramesHelper#turbo_frame_tag";
23651
24192
  }
24193
+ else if (isScript && hasSrcAttribute) {
24194
+ content = this.buildJavascriptIncludeTagContent(attributesString, src);
24195
+ elementSource = "ActionView::Helpers::AssetTagHelper#javascript_include_tag";
24196
+ }
24197
+ else if (isScript) {
24198
+ content = this.buildJavascriptTagContent(node, attributesString, isInlineContent);
24199
+ elementSource = "ActionView::Helpers::JavaScriptHelper#javascript_tag";
24200
+ }
23652
24201
  else {
23653
24202
  content = this.buildTagContent(tagName.value, node, attributesString, isInlineContent);
23654
24203
  elementSource = "ActionView::Helpers::TagHelper#tag";
@@ -23665,7 +24214,8 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
23665
24214
  });
23666
24215
  asMutable(node).open_tag = erbOpenTag;
23667
24216
  asMutable(node).element_source = elementSource;
23668
- const isInlineForm = isInlineContent || (isTurboFrame && !hasBody);
24217
+ const isInlineLiteralContent = isScript && hasBody && node.body.length === 1 && isLiteralNode(node.body[0]) && !node.body[0].content.includes("\n");
24218
+ const isInlineForm = isInlineContent || isInlineLiteralContent || (isTurboFrame && !hasBody) || (isScript && hasSrcAttribute);
23669
24219
  if (node.is_void) {
23670
24220
  asMutable(node).close_tag = null;
23671
24221
  }
@@ -23725,6 +24275,30 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
23725
24275
  }
23726
24276
  return argString ? ` turbo_frame_tag ${argString} do ` : ` turbo_frame_tag do `;
23727
24277
  }
24278
+ buildJavascriptTagContent(node, attributes, isInlineContent) {
24279
+ const bodyNode = node.body?.[0];
24280
+ const isInlineLiteral = bodyNode && isLiteralNode(bodyNode) && !bodyNode.content.includes("\n");
24281
+ const isInlineText = isInlineContent && isHTMLTextNode(bodyNode);
24282
+ if (isInlineText || isInlineLiteral) {
24283
+ const textContent = isHTMLTextNode(bodyNode) ? bodyNode.content : bodyNode.content;
24284
+ const args = [`"${textContent}"`];
24285
+ if (attributes)
24286
+ args.push(attributes);
24287
+ return ` javascript_tag ${args.join(", ")} `;
24288
+ }
24289
+ return attributes
24290
+ ? ` javascript_tag ${attributes} do `
24291
+ : ` javascript_tag do `;
24292
+ }
24293
+ buildJavascriptIncludeTagContent(attributes, source) {
24294
+ const args = [];
24295
+ if (source)
24296
+ args.push(source);
24297
+ if (attributes)
24298
+ args.push(attributes);
24299
+ const argString = args.join(", ");
24300
+ return argString ? ` javascript_include_tag ${argString} ` : ` javascript_include_tag `;
24301
+ }
23728
24302
  buildLinkToContent(node, attribute, href, isInlineContent) {
23729
24303
  const args = [];
23730
24304
  if (isInlineContent && isHTMLTextNode(node.body[0])) {
@@ -23748,7 +24322,7 @@ class HTMLToActionViewTagHelperRewriter extends ASTRewriter {
23748
24322
  return "html-to-action-view-tag-helper";
23749
24323
  }
23750
24324
  get description() {
23751
- return "Converts raw HTML elements to ActionView tag helpers (tag.*, turbo_frame_tag)";
24325
+ return "Converts raw HTML elements to ActionView tag helpers (tag.*, turbo_frame_tag, javascript_tag, javascript_include_tag)";
23752
24326
  }
23753
24327
  rewrite(node, _context) {
23754
24328
  const visitor = new HTMLToActionViewTagHelperVisitor();
@@ -24272,6 +24846,12 @@ class IdentityPrinter extends Printer {
24272
24846
  this.visit(node.end_node);
24273
24847
  }
24274
24848
  }
24849
+ visitERBRenderNode(node) {
24850
+ this.printERBNode(node);
24851
+ }
24852
+ visitRubyRenderLocalNode(_node) {
24853
+ // extracted metadata, nothing to print
24854
+ }
24275
24855
  visitERBYieldNode(node) {
24276
24856
  this.printERBNode(node);
24277
24857
  }