@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/loader.cjs CHANGED
@@ -206,7 +206,7 @@ class Token {
206
206
  }
207
207
 
208
208
  // 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.0/templates/javascript/packages/core/src/errors.ts.erb
209
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.2/templates/javascript/packages/core/src/errors.ts.erb
210
210
  class HerbError {
211
211
  type;
212
212
  message;
@@ -1207,6 +1207,279 @@ class NestedERBTagError extends HerbError {
1207
1207
  return output;
1208
1208
  }
1209
1209
  }
1210
+ class RenderAmbiguousLocalsError extends HerbError {
1211
+ partial;
1212
+ static from(data) {
1213
+ return new RenderAmbiguousLocalsError({
1214
+ type: data.type,
1215
+ message: data.message,
1216
+ location: Location.from(data.location),
1217
+ partial: data.partial,
1218
+ });
1219
+ }
1220
+ constructor(props) {
1221
+ super(props.type, props.message, props.location);
1222
+ this.partial = props.partial;
1223
+ }
1224
+ toJSON() {
1225
+ return {
1226
+ ...super.toJSON(),
1227
+ type: "RENDER_AMBIGUOUS_LOCALS_ERROR",
1228
+ partial: this.partial,
1229
+ };
1230
+ }
1231
+ toMonacoDiagnostic() {
1232
+ return {
1233
+ line: this.location.start.line,
1234
+ column: this.location.start.column,
1235
+ endLine: this.location.end.line,
1236
+ endColumn: this.location.end.column,
1237
+ message: this.message,
1238
+ severity: 'error'
1239
+ };
1240
+ }
1241
+ treeInspect() {
1242
+ let output = "";
1243
+ output += `@ RenderAmbiguousLocalsError ${this.location.treeInspectWithLabel()}\n`;
1244
+ output += `├── message: "${this.message}"\n`;
1245
+ output += `└── partial: ${JSON.stringify(this.partial)}\n`;
1246
+ return output;
1247
+ }
1248
+ }
1249
+ class RenderMissingLocalsError extends HerbError {
1250
+ partial;
1251
+ keywords;
1252
+ static from(data) {
1253
+ return new RenderMissingLocalsError({
1254
+ type: data.type,
1255
+ message: data.message,
1256
+ location: Location.from(data.location),
1257
+ partial: data.partial,
1258
+ keywords: data.keywords,
1259
+ });
1260
+ }
1261
+ constructor(props) {
1262
+ super(props.type, props.message, props.location);
1263
+ this.partial = props.partial;
1264
+ this.keywords = props.keywords;
1265
+ }
1266
+ toJSON() {
1267
+ return {
1268
+ ...super.toJSON(),
1269
+ type: "RENDER_MISSING_LOCALS_ERROR",
1270
+ partial: this.partial,
1271
+ keywords: this.keywords,
1272
+ };
1273
+ }
1274
+ toMonacoDiagnostic() {
1275
+ return {
1276
+ line: this.location.start.line,
1277
+ column: this.location.start.column,
1278
+ endLine: this.location.end.line,
1279
+ endColumn: this.location.end.column,
1280
+ message: this.message,
1281
+ severity: 'error'
1282
+ };
1283
+ }
1284
+ treeInspect() {
1285
+ let output = "";
1286
+ output += `@ RenderMissingLocalsError ${this.location.treeInspectWithLabel()}\n`;
1287
+ output += `├── message: "${this.message}"\n`;
1288
+ output += `├── partial: ${JSON.stringify(this.partial)}\n`;
1289
+ output += `└── keywords: ${JSON.stringify(this.keywords)}\n`;
1290
+ return output;
1291
+ }
1292
+ }
1293
+ class RenderNoArgumentsError extends HerbError {
1294
+ static from(data) {
1295
+ return new RenderNoArgumentsError({
1296
+ type: data.type,
1297
+ message: data.message,
1298
+ location: Location.from(data.location),
1299
+ });
1300
+ }
1301
+ constructor(props) {
1302
+ super(props.type, props.message, props.location);
1303
+ }
1304
+ toJSON() {
1305
+ return {
1306
+ ...super.toJSON(),
1307
+ type: "RENDER_NO_ARGUMENTS_ERROR",
1308
+ };
1309
+ }
1310
+ toMonacoDiagnostic() {
1311
+ return {
1312
+ line: this.location.start.line,
1313
+ column: this.location.start.column,
1314
+ endLine: this.location.end.line,
1315
+ endColumn: this.location.end.column,
1316
+ message: this.message,
1317
+ severity: 'error'
1318
+ };
1319
+ }
1320
+ treeInspect() {
1321
+ let output = "";
1322
+ output += `@ RenderNoArgumentsError ${this.location.treeInspectWithLabel()}\n`;
1323
+ output += `└── message: "${this.message}"\n`;
1324
+ return output;
1325
+ }
1326
+ }
1327
+ class RenderConflictingPartialError extends HerbError {
1328
+ positional_partial;
1329
+ keyword_partial;
1330
+ static from(data) {
1331
+ return new RenderConflictingPartialError({
1332
+ type: data.type,
1333
+ message: data.message,
1334
+ location: Location.from(data.location),
1335
+ positional_partial: data.positional_partial,
1336
+ keyword_partial: data.keyword_partial,
1337
+ });
1338
+ }
1339
+ constructor(props) {
1340
+ super(props.type, props.message, props.location);
1341
+ this.positional_partial = props.positional_partial;
1342
+ this.keyword_partial = props.keyword_partial;
1343
+ }
1344
+ toJSON() {
1345
+ return {
1346
+ ...super.toJSON(),
1347
+ type: "RENDER_CONFLICTING_PARTIAL_ERROR",
1348
+ positional_partial: this.positional_partial,
1349
+ keyword_partial: this.keyword_partial,
1350
+ };
1351
+ }
1352
+ toMonacoDiagnostic() {
1353
+ return {
1354
+ line: this.location.start.line,
1355
+ column: this.location.start.column,
1356
+ endLine: this.location.end.line,
1357
+ endColumn: this.location.end.column,
1358
+ message: this.message,
1359
+ severity: 'error'
1360
+ };
1361
+ }
1362
+ treeInspect() {
1363
+ let output = "";
1364
+ output += `@ RenderConflictingPartialError ${this.location.treeInspectWithLabel()}\n`;
1365
+ output += `├── message: "${this.message}"\n`;
1366
+ output += `├── positional_partial: ${JSON.stringify(this.positional_partial)}\n`;
1367
+ output += `└── keyword_partial: ${JSON.stringify(this.keyword_partial)}\n`;
1368
+ return output;
1369
+ }
1370
+ }
1371
+ class RenderInvalidAsOptionError extends HerbError {
1372
+ as_value;
1373
+ static from(data) {
1374
+ return new RenderInvalidAsOptionError({
1375
+ type: data.type,
1376
+ message: data.message,
1377
+ location: Location.from(data.location),
1378
+ as_value: data.as_value,
1379
+ });
1380
+ }
1381
+ constructor(props) {
1382
+ super(props.type, props.message, props.location);
1383
+ this.as_value = props.as_value;
1384
+ }
1385
+ toJSON() {
1386
+ return {
1387
+ ...super.toJSON(),
1388
+ type: "RENDER_INVALID_AS_OPTION_ERROR",
1389
+ as_value: this.as_value,
1390
+ };
1391
+ }
1392
+ toMonacoDiagnostic() {
1393
+ return {
1394
+ line: this.location.start.line,
1395
+ column: this.location.start.column,
1396
+ endLine: this.location.end.line,
1397
+ endColumn: this.location.end.column,
1398
+ message: this.message,
1399
+ severity: 'error'
1400
+ };
1401
+ }
1402
+ treeInspect() {
1403
+ let output = "";
1404
+ output += `@ RenderInvalidAsOptionError ${this.location.treeInspectWithLabel()}\n`;
1405
+ output += `├── message: "${this.message}"\n`;
1406
+ output += `└── as_value: ${JSON.stringify(this.as_value)}\n`;
1407
+ return output;
1408
+ }
1409
+ }
1410
+ class RenderObjectAndCollectionError extends HerbError {
1411
+ static from(data) {
1412
+ return new RenderObjectAndCollectionError({
1413
+ type: data.type,
1414
+ message: data.message,
1415
+ location: Location.from(data.location),
1416
+ });
1417
+ }
1418
+ constructor(props) {
1419
+ super(props.type, props.message, props.location);
1420
+ }
1421
+ toJSON() {
1422
+ return {
1423
+ ...super.toJSON(),
1424
+ type: "RENDER_OBJECT_AND_COLLECTION_ERROR",
1425
+ };
1426
+ }
1427
+ toMonacoDiagnostic() {
1428
+ return {
1429
+ line: this.location.start.line,
1430
+ column: this.location.start.column,
1431
+ endLine: this.location.end.line,
1432
+ endColumn: this.location.end.column,
1433
+ message: this.message,
1434
+ severity: 'error'
1435
+ };
1436
+ }
1437
+ treeInspect() {
1438
+ let output = "";
1439
+ output += `@ RenderObjectAndCollectionError ${this.location.treeInspectWithLabel()}\n`;
1440
+ output += `└── message: "${this.message}"\n`;
1441
+ return output;
1442
+ }
1443
+ }
1444
+ class RenderLayoutWithoutBlockError extends HerbError {
1445
+ layout;
1446
+ static from(data) {
1447
+ return new RenderLayoutWithoutBlockError({
1448
+ type: data.type,
1449
+ message: data.message,
1450
+ location: Location.from(data.location),
1451
+ layout: data.layout,
1452
+ });
1453
+ }
1454
+ constructor(props) {
1455
+ super(props.type, props.message, props.location);
1456
+ this.layout = props.layout;
1457
+ }
1458
+ toJSON() {
1459
+ return {
1460
+ ...super.toJSON(),
1461
+ type: "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR",
1462
+ layout: this.layout,
1463
+ };
1464
+ }
1465
+ toMonacoDiagnostic() {
1466
+ return {
1467
+ line: this.location.start.line,
1468
+ column: this.location.start.column,
1469
+ endLine: this.location.end.line,
1470
+ endColumn: this.location.end.column,
1471
+ message: this.message,
1472
+ severity: 'error'
1473
+ };
1474
+ }
1475
+ treeInspect() {
1476
+ let output = "";
1477
+ output += `@ RenderLayoutWithoutBlockError ${this.location.treeInspectWithLabel()}\n`;
1478
+ output += `├── message: "${this.message}"\n`;
1479
+ output += `└── layout: ${JSON.stringify(this.layout)}\n`;
1480
+ return output;
1481
+ }
1482
+ }
1210
1483
  function fromSerializedError(error) {
1211
1484
  switch (error.type) {
1212
1485
  case "UNEXPECTED_ERROR": return UnexpectedError.from(error);
@@ -1232,6 +1505,13 @@ function fromSerializedError(error) {
1232
1505
  case "UNCLOSED_ERB_TAG_ERROR": return UnclosedERBTagError.from(error);
1233
1506
  case "STRAY_ERB_CLOSING_TAG_ERROR": return StrayERBClosingTagError.from(error);
1234
1507
  case "NESTED_ERB_TAG_ERROR": return NestedERBTagError.from(error);
1508
+ case "RENDER_AMBIGUOUS_LOCALS_ERROR": return RenderAmbiguousLocalsError.from(error);
1509
+ case "RENDER_MISSING_LOCALS_ERROR": return RenderMissingLocalsError.from(error);
1510
+ case "RENDER_NO_ARGUMENTS_ERROR": return RenderNoArgumentsError.from(error);
1511
+ case "RENDER_CONFLICTING_PARTIAL_ERROR": return RenderConflictingPartialError.from(error);
1512
+ case "RENDER_INVALID_AS_OPTION_ERROR": return RenderInvalidAsOptionError.from(error);
1513
+ case "RENDER_OBJECT_AND_COLLECTION_ERROR": return RenderObjectAndCollectionError.from(error);
1514
+ case "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR": return RenderLayoutWithoutBlockError.from(error);
1235
1515
  default:
1236
1516
  throw new Error(`Unknown node type: ${error.type}`);
1237
1517
  }
@@ -19820,7 +20100,7 @@ function deserializePrismNode(bytes, source) {
19820
20100
  }
19821
20101
 
19822
20102
  // NOTE: This file is generated by the templates/template.rb script and should not
19823
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.0/templates/javascript/packages/core/src/nodes.ts.erb
20103
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.2/templates/javascript/packages/core/src/nodes.ts.erb
19824
20104
  class Node {
19825
20105
  type;
19826
20106
  location;
@@ -22364,6 +22644,225 @@ class ERBUnlessNode extends Node {
22364
22644
  return output;
22365
22645
  }
22366
22646
  }
22647
+ class RubyRenderLocalNode extends Node {
22648
+ name;
22649
+ value;
22650
+ static get type() {
22651
+ return "AST_RUBY_RENDER_LOCAL_NODE";
22652
+ }
22653
+ static from(data) {
22654
+ return new RubyRenderLocalNode({
22655
+ type: data.type,
22656
+ location: Location.from(data.location),
22657
+ errors: (data.errors || []).map(error => HerbError.from(error)),
22658
+ name: data.name ? Token.from(data.name) : null,
22659
+ value: data.value ? fromSerializedNode((data.value)) : null,
22660
+ });
22661
+ }
22662
+ constructor(props) {
22663
+ super(props.type, props.location, props.errors);
22664
+ this.name = props.name;
22665
+ this.value = props.value;
22666
+ }
22667
+ accept(visitor) {
22668
+ visitor.visitRubyRenderLocalNode(this);
22669
+ }
22670
+ childNodes() {
22671
+ return [
22672
+ this.value,
22673
+ ];
22674
+ }
22675
+ compactChildNodes() {
22676
+ return this.childNodes().filter(node => node !== null && node !== undefined);
22677
+ }
22678
+ recursiveErrors() {
22679
+ return [
22680
+ ...this.errors,
22681
+ this.value ? this.value.recursiveErrors() : [],
22682
+ ].flat();
22683
+ }
22684
+ toJSON() {
22685
+ return {
22686
+ ...super.toJSON(),
22687
+ type: "AST_RUBY_RENDER_LOCAL_NODE",
22688
+ name: this.name ? this.name.toJSON() : null,
22689
+ value: this.value ? this.value.toJSON() : null,
22690
+ };
22691
+ }
22692
+ treeInspect() {
22693
+ let output = "";
22694
+ output += `@ RubyRenderLocalNode ${this.location.treeInspectWithLabel()}\n`;
22695
+ output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
22696
+ output += `├── name: ${this.name ? this.name.treeInspect() : "∅"}\n`;
22697
+ output += `└── value: ${this.inspectNode(this.value, " ")}`;
22698
+ return output;
22699
+ }
22700
+ }
22701
+ class ERBRenderNode extends Node {
22702
+ tag_opening;
22703
+ content;
22704
+ tag_closing;
22705
+ // no-op for analyzed_ruby
22706
+ prism_node;
22707
+ partial;
22708
+ template_path;
22709
+ layout;
22710
+ file;
22711
+ inline_template;
22712
+ body;
22713
+ plain;
22714
+ html;
22715
+ renderable;
22716
+ collection;
22717
+ object;
22718
+ as_name;
22719
+ spacer_template;
22720
+ formats;
22721
+ variants;
22722
+ handlers;
22723
+ content_type;
22724
+ locals;
22725
+ static get type() {
22726
+ return "AST_ERB_RENDER_NODE";
22727
+ }
22728
+ static from(data) {
22729
+ return new ERBRenderNode({
22730
+ type: data.type,
22731
+ location: Location.from(data.location),
22732
+ errors: (data.errors || []).map(error => HerbError.from(error)),
22733
+ tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
22734
+ content: data.content ? Token.from(data.content) : null,
22735
+ tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
22736
+ // no-op for analyzed_ruby
22737
+ prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
22738
+ partial: data.partial ? Token.from(data.partial) : null,
22739
+ template_path: data.template_path ? Token.from(data.template_path) : null,
22740
+ layout: data.layout ? Token.from(data.layout) : null,
22741
+ file: data.file ? Token.from(data.file) : null,
22742
+ inline_template: data.inline_template ? Token.from(data.inline_template) : null,
22743
+ body: data.body ? Token.from(data.body) : null,
22744
+ plain: data.plain ? Token.from(data.plain) : null,
22745
+ html: data.html ? Token.from(data.html) : null,
22746
+ renderable: data.renderable ? Token.from(data.renderable) : null,
22747
+ collection: data.collection ? Token.from(data.collection) : null,
22748
+ object: data.object ? Token.from(data.object) : null,
22749
+ as_name: data.as_name ? Token.from(data.as_name) : null,
22750
+ spacer_template: data.spacer_template ? Token.from(data.spacer_template) : null,
22751
+ formats: data.formats ? Token.from(data.formats) : null,
22752
+ variants: data.variants ? Token.from(data.variants) : null,
22753
+ handlers: data.handlers ? Token.from(data.handlers) : null,
22754
+ content_type: data.content_type ? Token.from(data.content_type) : null,
22755
+ locals: (data.locals || []).map(node => fromSerializedNode(node)),
22756
+ });
22757
+ }
22758
+ constructor(props) {
22759
+ super(props.type, props.location, props.errors);
22760
+ this.tag_opening = props.tag_opening;
22761
+ this.content = props.content;
22762
+ this.tag_closing = props.tag_closing;
22763
+ // no-op for analyzed_ruby
22764
+ this.prism_node = props.prism_node;
22765
+ this.partial = props.partial;
22766
+ this.template_path = props.template_path;
22767
+ this.layout = props.layout;
22768
+ this.file = props.file;
22769
+ this.inline_template = props.inline_template;
22770
+ this.body = props.body;
22771
+ this.plain = props.plain;
22772
+ this.html = props.html;
22773
+ this.renderable = props.renderable;
22774
+ this.collection = props.collection;
22775
+ this.object = props.object;
22776
+ this.as_name = props.as_name;
22777
+ this.spacer_template = props.spacer_template;
22778
+ this.formats = props.formats;
22779
+ this.variants = props.variants;
22780
+ this.handlers = props.handlers;
22781
+ this.content_type = props.content_type;
22782
+ this.locals = props.locals;
22783
+ }
22784
+ accept(visitor) {
22785
+ visitor.visitERBRenderNode(this);
22786
+ }
22787
+ childNodes() {
22788
+ return [
22789
+ ...this.locals,
22790
+ ];
22791
+ }
22792
+ compactChildNodes() {
22793
+ return this.childNodes().filter(node => node !== null && node !== undefined);
22794
+ }
22795
+ get prismNode() {
22796
+ if (!this.prism_node || !this.source)
22797
+ return null;
22798
+ return deserializePrismNode(this.prism_node, this.source);
22799
+ }
22800
+ recursiveErrors() {
22801
+ return [
22802
+ ...this.errors,
22803
+ ...this.locals.map(node => node.recursiveErrors()),
22804
+ ].flat();
22805
+ }
22806
+ toJSON() {
22807
+ return {
22808
+ ...super.toJSON(),
22809
+ type: "AST_ERB_RENDER_NODE",
22810
+ tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
22811
+ content: this.content ? this.content.toJSON() : null,
22812
+ tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
22813
+ // no-op for analyzed_ruby
22814
+ prism_node: this.prism_node ? Array.from(this.prism_node) : null,
22815
+ partial: this.partial ? this.partial.toJSON() : null,
22816
+ template_path: this.template_path ? this.template_path.toJSON() : null,
22817
+ layout: this.layout ? this.layout.toJSON() : null,
22818
+ file: this.file ? this.file.toJSON() : null,
22819
+ inline_template: this.inline_template ? this.inline_template.toJSON() : null,
22820
+ body: this.body ? this.body.toJSON() : null,
22821
+ plain: this.plain ? this.plain.toJSON() : null,
22822
+ html: this.html ? this.html.toJSON() : null,
22823
+ renderable: this.renderable ? this.renderable.toJSON() : null,
22824
+ collection: this.collection ? this.collection.toJSON() : null,
22825
+ object: this.object ? this.object.toJSON() : null,
22826
+ as_name: this.as_name ? this.as_name.toJSON() : null,
22827
+ spacer_template: this.spacer_template ? this.spacer_template.toJSON() : null,
22828
+ formats: this.formats ? this.formats.toJSON() : null,
22829
+ variants: this.variants ? this.variants.toJSON() : null,
22830
+ handlers: this.handlers ? this.handlers.toJSON() : null,
22831
+ content_type: this.content_type ? this.content_type.toJSON() : null,
22832
+ locals: this.locals.map(node => node.toJSON()),
22833
+ };
22834
+ }
22835
+ treeInspect() {
22836
+ let output = "";
22837
+ output += `@ ERBRenderNode ${this.location.treeInspectWithLabel()}\n`;
22838
+ output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
22839
+ output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
22840
+ output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
22841
+ output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
22842
+ if (this.prism_node) {
22843
+ output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
22844
+ }
22845
+ output += `├── partial: ${this.partial ? this.partial.treeInspect() : "∅"}\n`;
22846
+ output += `├── template_path: ${this.template_path ? this.template_path.treeInspect() : "∅"}\n`;
22847
+ output += `├── layout: ${this.layout ? this.layout.treeInspect() : "∅"}\n`;
22848
+ output += `├── file: ${this.file ? this.file.treeInspect() : "∅"}\n`;
22849
+ output += `├── inline_template: ${this.inline_template ? this.inline_template.treeInspect() : "∅"}\n`;
22850
+ output += `├── body: ${this.body ? this.body.treeInspect() : "∅"}\n`;
22851
+ output += `├── plain: ${this.plain ? this.plain.treeInspect() : "∅"}\n`;
22852
+ output += `├── html: ${this.html ? this.html.treeInspect() : "∅"}\n`;
22853
+ output += `├── renderable: ${this.renderable ? this.renderable.treeInspect() : "∅"}\n`;
22854
+ output += `├── collection: ${this.collection ? this.collection.treeInspect() : "∅"}\n`;
22855
+ output += `├── object: ${this.object ? this.object.treeInspect() : "∅"}\n`;
22856
+ output += `├── as_name: ${this.as_name ? this.as_name.treeInspect() : "∅"}\n`;
22857
+ output += `├── spacer_template: ${this.spacer_template ? this.spacer_template.treeInspect() : "∅"}\n`;
22858
+ output += `├── formats: ${this.formats ? this.formats.treeInspect() : "∅"}\n`;
22859
+ output += `├── variants: ${this.variants ? this.variants.treeInspect() : "∅"}\n`;
22860
+ output += `├── handlers: ${this.handlers ? this.handlers.treeInspect() : "∅"}\n`;
22861
+ output += `├── content_type: ${this.content_type ? this.content_type.treeInspect() : "∅"}\n`;
22862
+ output += `└── locals: ${this.inspectArray(this.locals, " ")}`;
22863
+ return output;
22864
+ }
22865
+ }
22367
22866
  class ERBYieldNode extends Node {
22368
22867
  tag_opening;
22369
22868
  content;
@@ -22527,6 +23026,8 @@ function fromSerializedNode(node) {
22527
23026
  case "AST_ERB_ENSURE_NODE": return ERBEnsureNode.from(node);
22528
23027
  case "AST_ERB_BEGIN_NODE": return ERBBeginNode.from(node);
22529
23028
  case "AST_ERB_UNLESS_NODE": return ERBUnlessNode.from(node);
23029
+ case "AST_RUBY_RENDER_LOCAL_NODE": return RubyRenderLocalNode.from(node);
23030
+ case "AST_ERB_RENDER_NODE": return ERBRenderNode.from(node);
22530
23031
  case "AST_ERB_YIELD_NODE": return ERBYieldNode.from(node);
22531
23032
  case "AST_ERB_IN_NODE": return ERBInNode.from(node);
22532
23033
  default:
@@ -22576,6 +23077,7 @@ const DEFAULT_PARSER_OPTIONS = {
22576
23077
  analyze: true,
22577
23078
  strict: true,
22578
23079
  action_view_helpers: false,
23080
+ render_nodes: false,
22579
23081
  prism_nodes: false,
22580
23082
  prism_nodes_deep: false,
22581
23083
  prism_program: false,
@@ -22592,6 +23094,8 @@ class ParserOptions {
22592
23094
  analyze;
22593
23095
  /** Whether ActionView tag helper transformation was enabled during parsing. */
22594
23096
  action_view_helpers;
23097
+ /** Whether ActionView render call detection was enabled during parsing. */
23098
+ render_nodes;
22595
23099
  /** Whether Prism node serialization was enabled during parsing. */
22596
23100
  prism_nodes;
22597
23101
  /** Whether deep Prism node serialization was enabled during parsing. */
@@ -22606,6 +23110,7 @@ class ParserOptions {
22606
23110
  this.track_whitespace = options.track_whitespace ?? DEFAULT_PARSER_OPTIONS.track_whitespace;
22607
23111
  this.analyze = options.analyze ?? DEFAULT_PARSER_OPTIONS.analyze;
22608
23112
  this.action_view_helpers = options.action_view_helpers ?? DEFAULT_PARSER_OPTIONS.action_view_helpers;
23113
+ this.render_nodes = options.render_nodes ?? DEFAULT_PARSER_OPTIONS.render_nodes;
22609
23114
  this.prism_nodes = options.prism_nodes ?? DEFAULT_PARSER_OPTIONS.prism_nodes;
22610
23115
  this.prism_nodes_deep = options.prism_nodes_deep ?? DEFAULT_PARSER_OPTIONS.prism_nodes_deep;
22611
23116
  this.prism_program = options.prism_program ?? DEFAULT_PARSER_OPTIONS.prism_program;
@@ -22685,7 +23190,7 @@ class ParseResult extends Result {
22685
23190
  }
22686
23191
 
22687
23192
  // NOTE: This file is generated by the templates/template.rb script and should not
22688
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.0/templates/javascript/packages/core/src/node-type-guards.ts.erb
23193
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.2/templates/javascript/packages/core/src/node-type-guards.ts.erb
22689
23194
  /**
22690
23195
  * Type guard functions for AST nodes.
22691
23196
  * These functions provide type checking by combining both instanceof
@@ -22980,6 +23485,22 @@ function isERBUnlessNode(node) {
22980
23485
  return false;
22981
23486
  return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE" || node.constructor.type === "AST_ERB_UNLESS_NODE";
22982
23487
  }
23488
+ /**
23489
+ * Checks if a node is a RubyRenderLocalNode
23490
+ */
23491
+ function isRubyRenderLocalNode(node) {
23492
+ if (!node)
23493
+ return false;
23494
+ return node instanceof RubyRenderLocalNode || node.type === "AST_RUBY_RENDER_LOCAL_NODE" || node.constructor.type === "AST_RUBY_RENDER_LOCAL_NODE";
23495
+ }
23496
+ /**
23497
+ * Checks if a node is a ERBRenderNode
23498
+ */
23499
+ function isERBRenderNode(node) {
23500
+ if (!node)
23501
+ return false;
23502
+ return node instanceof ERBRenderNode || node.type === "AST_ERB_RENDER_NODE" || node.constructor.type === "AST_ERB_RENDER_NODE";
23503
+ }
22983
23504
  /**
22984
23505
  * Checks if a node is a ERBYieldNode
22985
23506
  */
@@ -23043,6 +23564,8 @@ const NODE_TYPE_GUARDS = new Map([
23043
23564
  [ERBEnsureNode, isERBEnsureNode],
23044
23565
  [ERBBeginNode, isERBBeginNode],
23045
23566
  [ERBUnlessNode, isERBUnlessNode],
23567
+ [RubyRenderLocalNode, isRubyRenderLocalNode],
23568
+ [ERBRenderNode, isERBRenderNode],
23046
23569
  [ERBYieldNode, isERBYieldNode],
23047
23570
  [ERBInNode, isERBInNode],
23048
23571
  ]);
@@ -23093,6 +23616,8 @@ const AST_TYPE_GUARDS = new Map([
23093
23616
  ["AST_ERB_ENSURE_NODE", isERBEnsureNode],
23094
23617
  ["AST_ERB_BEGIN_NODE", isERBBeginNode],
23095
23618
  ["AST_ERB_UNLESS_NODE", isERBUnlessNode],
23619
+ ["AST_RUBY_RENDER_LOCAL_NODE", isRubyRenderLocalNode],
23620
+ ["AST_ERB_RENDER_NODE", isERBRenderNode],
23096
23621
  ["AST_ERB_YIELD_NODE", isERBYieldNode],
23097
23622
  ["AST_ERB_IN_NODE", isERBInNode],
23098
23623
  ]);
@@ -23319,7 +23844,7 @@ function createSyntheticToken(value, type = "TOKEN_SYNTHETIC") {
23319
23844
  }
23320
23845
 
23321
23846
  // NOTE: This file is generated by the templates/template.rb script and should not
23322
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.0/templates/javascript/packages/core/src/visitor.ts.erb
23847
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.9.2/templates/javascript/packages/core/src/visitor.ts.erb
23323
23848
  class Visitor {
23324
23849
  visit(node) {
23325
23850
  if (!node)
@@ -23498,6 +24023,15 @@ class Visitor {
23498
24023
  this.visitERBNode(node);
23499
24024
  this.visitChildNodes(node);
23500
24025
  }
24026
+ visitRubyRenderLocalNode(node) {
24027
+ this.visitNode(node);
24028
+ this.visitChildNodes(node);
24029
+ }
24030
+ visitERBRenderNode(node) {
24031
+ this.visitNode(node);
24032
+ this.visitERBNode(node);
24033
+ this.visitChildNodes(node);
24034
+ }
23501
24035
  visitERBYieldNode(node) {
23502
24036
  this.visitNode(node);
23503
24037
  this.visitERBNode(node);
@@ -23654,7 +24188,7 @@ class ActionViewTagHelperToHTMLRewriter extends ASTRewriter {
23654
24188
  return "action-view-tag-helper-to-html";
23655
24189
  }
23656
24190
  get description() {
23657
- return "Converts ActionView tag helpers (tag.*, content_tag, link_to, turbo_frame_tag) to raw HTML elements";
24191
+ return "Converts ActionView tag helpers to raw HTML elements";
23658
24192
  }
23659
24193
  rewrite(node, _context) {
23660
24194
  const visitor = new ActionViewTagHelperToHTMLVisitor();
@@ -23687,6 +24221,7 @@ function serializeAttributes(children, options = {}) {
23687
24221
  const prefixed = new Map();
23688
24222
  let href = null;
23689
24223
  let id = null;
24224
+ let src = null;
23690
24225
  for (const child of children) {
23691
24226
  if (!isHTMLAttributeNode(child))
23692
24227
  continue;
@@ -23702,6 +24237,10 @@ function serializeAttributes(children, options = {}) {
23702
24237
  id = value;
23703
24238
  continue;
23704
24239
  }
24240
+ if (options.extractSrc && name === "src") {
24241
+ src = value;
24242
+ continue;
24243
+ }
23705
24244
  const dataMatch = name.match(/^(data|aria)-(.+)$/);
23706
24245
  if (dataMatch) {
23707
24246
  const [, prefix, rest] = dataMatch;
@@ -23718,7 +24257,7 @@ function serializeAttributes(children, options = {}) {
23718
24257
  for (const [prefix, entries] of prefixed) {
23719
24258
  parts.push(`${prefix}: { ${entries.join(", ")} }`);
23720
24259
  }
23721
- return { attributes: parts.join(", "), href, id };
24260
+ return { attributes: parts.join(", "), href, id, src };
23722
24261
  }
23723
24262
  function isTextOnlyBody(body) {
23724
24263
  if (body.length !== 1 || !isHTMLTextNode(body[0]))
@@ -23744,8 +24283,10 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
23744
24283
  }
23745
24284
  const isAnchor = tagName.value === "a";
23746
24285
  const isTurboFrame = tagName.value === "turbo-frame";
24286
+ const isScript = tagName.value === "script";
23747
24287
  const attributes = openTag.children.filter(child => !isWhitespaceNode(child));
23748
- const { attributes: attributesString, href, id } = serializeAttributes(attributes, { extractHref: isAnchor, extractId: isTurboFrame });
24288
+ const hasSrcAttribute = isScript && attributes.some(child => isHTMLAttributeNode(child) && getStaticAttributeName(child.name) === "src");
24289
+ const { attributes: attributesString, href, id, src } = serializeAttributes(attributes, { extractHref: isAnchor, extractId: isTurboFrame, extractSrc: isScript });
23749
24290
  const hasBody = node.body && node.body.length > 0 && !node.is_void;
23750
24291
  const isInlineContent = hasBody && isTextOnlyBody(node.body);
23751
24292
  let content;
@@ -23758,6 +24299,14 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
23758
24299
  content = this.buildTurboFrameTagContent(node, attributesString, id, isInlineContent);
23759
24300
  elementSource = "Turbo::FramesHelper#turbo_frame_tag";
23760
24301
  }
24302
+ else if (isScript && hasSrcAttribute) {
24303
+ content = this.buildJavascriptIncludeTagContent(attributesString, src);
24304
+ elementSource = "ActionView::Helpers::AssetTagHelper#javascript_include_tag";
24305
+ }
24306
+ else if (isScript) {
24307
+ content = this.buildJavascriptTagContent(node, attributesString, isInlineContent);
24308
+ elementSource = "ActionView::Helpers::JavaScriptHelper#javascript_tag";
24309
+ }
23761
24310
  else {
23762
24311
  content = this.buildTagContent(tagName.value, node, attributesString, isInlineContent);
23763
24312
  elementSource = "ActionView::Helpers::TagHelper#tag";
@@ -23774,7 +24323,8 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
23774
24323
  });
23775
24324
  asMutable(node).open_tag = erbOpenTag;
23776
24325
  asMutable(node).element_source = elementSource;
23777
- const isInlineForm = isInlineContent || (isTurboFrame && !hasBody);
24326
+ const isInlineLiteralContent = isScript && hasBody && node.body.length === 1 && isLiteralNode(node.body[0]) && !node.body[0].content.includes("\n");
24327
+ const isInlineForm = isInlineContent || isInlineLiteralContent || (isTurboFrame && !hasBody) || (isScript && hasSrcAttribute);
23778
24328
  if (node.is_void) {
23779
24329
  asMutable(node).close_tag = null;
23780
24330
  }
@@ -23834,6 +24384,30 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
23834
24384
  }
23835
24385
  return argString ? ` turbo_frame_tag ${argString} do ` : ` turbo_frame_tag do `;
23836
24386
  }
24387
+ buildJavascriptTagContent(node, attributes, isInlineContent) {
24388
+ const bodyNode = node.body?.[0];
24389
+ const isInlineLiteral = bodyNode && isLiteralNode(bodyNode) && !bodyNode.content.includes("\n");
24390
+ const isInlineText = isInlineContent && isHTMLTextNode(bodyNode);
24391
+ if (isInlineText || isInlineLiteral) {
24392
+ const textContent = isHTMLTextNode(bodyNode) ? bodyNode.content : bodyNode.content;
24393
+ const args = [`"${textContent}"`];
24394
+ if (attributes)
24395
+ args.push(attributes);
24396
+ return ` javascript_tag ${args.join(", ")} `;
24397
+ }
24398
+ return attributes
24399
+ ? ` javascript_tag ${attributes} do `
24400
+ : ` javascript_tag do `;
24401
+ }
24402
+ buildJavascriptIncludeTagContent(attributes, source) {
24403
+ const args = [];
24404
+ if (source)
24405
+ args.push(source);
24406
+ if (attributes)
24407
+ args.push(attributes);
24408
+ const argString = args.join(", ");
24409
+ return argString ? ` javascript_include_tag ${argString} ` : ` javascript_include_tag `;
24410
+ }
23837
24411
  buildLinkToContent(node, attribute, href, isInlineContent) {
23838
24412
  const args = [];
23839
24413
  if (isInlineContent && isHTMLTextNode(node.body[0])) {
@@ -23857,7 +24431,7 @@ class HTMLToActionViewTagHelperRewriter extends ASTRewriter {
23857
24431
  return "html-to-action-view-tag-helper";
23858
24432
  }
23859
24433
  get description() {
23860
- return "Converts raw HTML elements to ActionView tag helpers (tag.*, turbo_frame_tag)";
24434
+ return "Converts raw HTML elements to ActionView tag helpers (tag.*, turbo_frame_tag, javascript_tag, javascript_include_tag)";
23861
24435
  }
23862
24436
  rewrite(node, _context) {
23863
24437
  const visitor = new HTMLToActionViewTagHelperVisitor();
@@ -24381,6 +24955,12 @@ class IdentityPrinter extends Printer {
24381
24955
  this.visit(node.end_node);
24382
24956
  }
24383
24957
  }
24958
+ visitERBRenderNode(node) {
24959
+ this.printERBNode(node);
24960
+ }
24961
+ visitRubyRenderLocalNode(_node) {
24962
+ // extracted metadata, nothing to print
24963
+ }
24384
24964
  visitERBYieldNode(node) {
24385
24965
  this.printERBNode(node);
24386
24966
  }