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