@herb-tools/core 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/herb-core.browser.js +18 -9
- package/dist/herb-core.browser.js.map +1 -1
- package/dist/herb-core.cjs +18 -9
- package/dist/herb-core.cjs.map +1 -1
- package/dist/herb-core.esm.js +18 -9
- package/dist/herb-core.esm.js.map +1 -1
- package/dist/herb-core.umd.js +18 -9
- package/dist/herb-core.umd.js.map +1 -1
- package/dist/types/nodes.d.ts +3 -0
- package/package.json +1 -1
- package/src/ast-utils.ts +6 -3
- package/src/errors.ts +1 -1
- package/src/node-type-guards.ts +7 -7
- package/src/nodes.ts +11 -4
- package/src/visitor.ts +1 -1
package/dist/herb-core.esm.js
CHANGED
|
@@ -129,7 +129,7 @@ class Token {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
132
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
132
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/javascript/packages/core/src/errors.ts.erb
|
|
133
133
|
class HerbError {
|
|
134
134
|
type;
|
|
135
135
|
message;
|
|
@@ -586,7 +586,7 @@ function convertToUTF8(string) {
|
|
|
586
586
|
}
|
|
587
587
|
|
|
588
588
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
589
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
589
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/javascript/packages/core/src/nodes.ts.erb
|
|
590
590
|
class Node {
|
|
591
591
|
type;
|
|
592
592
|
location;
|
|
@@ -626,7 +626,7 @@ class Node {
|
|
|
626
626
|
return "∅\n";
|
|
627
627
|
if (array.length === 0)
|
|
628
628
|
return "[]\n";
|
|
629
|
-
let output = `(${array.length} item${array.length
|
|
629
|
+
let output = `(${array.length} item${array.length === 1 ? "" : "s"})\n`;
|
|
630
630
|
array.forEach((item, index) => {
|
|
631
631
|
const isLast = index === array.length - 1;
|
|
632
632
|
if (item instanceof Node || item instanceof HerbError) {
|
|
@@ -650,7 +650,7 @@ class Node {
|
|
|
650
650
|
.treeInspect()
|
|
651
651
|
.trimStart()
|
|
652
652
|
.split("\n")
|
|
653
|
-
.map((line, index) => index
|
|
653
|
+
.map((line, index) => index === 0 ? line.trimStart() : `${prefix}${prefix2}${line}`)
|
|
654
654
|
.join("\n")
|
|
655
655
|
.trimStart();
|
|
656
656
|
output += `\n`;
|
|
@@ -891,6 +891,7 @@ class HTMLElementNode extends Node {
|
|
|
891
891
|
body;
|
|
892
892
|
close_tag;
|
|
893
893
|
is_void;
|
|
894
|
+
source;
|
|
894
895
|
static get type() {
|
|
895
896
|
return "AST_HTML_ELEMENT_NODE";
|
|
896
897
|
}
|
|
@@ -904,6 +905,7 @@ class HTMLElementNode extends Node {
|
|
|
904
905
|
body: (data.body || []).map(node => fromSerializedNode(node)),
|
|
905
906
|
close_tag: data.close_tag ? fromSerializedNode((data.close_tag)) : null,
|
|
906
907
|
is_void: data.is_void,
|
|
908
|
+
source: data.source,
|
|
907
909
|
});
|
|
908
910
|
}
|
|
909
911
|
constructor(props) {
|
|
@@ -913,6 +915,7 @@ class HTMLElementNode extends Node {
|
|
|
913
915
|
this.body = props.body;
|
|
914
916
|
this.close_tag = props.close_tag;
|
|
915
917
|
this.is_void = props.is_void;
|
|
918
|
+
this.source = props.source;
|
|
916
919
|
}
|
|
917
920
|
accept(visitor) {
|
|
918
921
|
visitor.visitHTMLElementNode(this);
|
|
@@ -944,6 +947,7 @@ class HTMLElementNode extends Node {
|
|
|
944
947
|
body: this.body.map(node => node.toJSON()),
|
|
945
948
|
close_tag: this.close_tag ? this.close_tag.toJSON() : null,
|
|
946
949
|
is_void: this.is_void,
|
|
950
|
+
source: this.source,
|
|
947
951
|
};
|
|
948
952
|
}
|
|
949
953
|
treeInspect() {
|
|
@@ -954,7 +958,8 @@ class HTMLElementNode extends Node {
|
|
|
954
958
|
output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`;
|
|
955
959
|
output += `├── body: ${this.inspectArray(this.body, "│ ")}`;
|
|
956
960
|
output += `├── close_tag: ${this.inspectNode(this.close_tag, "│ ")}`;
|
|
957
|
-
output +=
|
|
961
|
+
output += `├── is_void: ${typeof this.is_void === 'boolean' ? String(this.is_void) : "∅"}\n`;
|
|
962
|
+
output += `└── source: ${this.source ? JSON.stringify(this.source) : "∅"}\n`;
|
|
958
963
|
return output;
|
|
959
964
|
}
|
|
960
965
|
}
|
|
@@ -2834,7 +2839,7 @@ class ParseResult extends Result {
|
|
|
2834
2839
|
}
|
|
2835
2840
|
|
|
2836
2841
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2837
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2842
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/javascript/packages/core/src/node-type-guards.ts.erb
|
|
2838
2843
|
/**
|
|
2839
2844
|
* Type guard functions for AST nodes.
|
|
2840
2845
|
* These functions provide type checking by combining both instanceof
|
|
@@ -3455,7 +3460,11 @@ function filterERBInNodes(nodes) {
|
|
|
3455
3460
|
* Checks if a node is an ERB output node (generates content: <%= %> or <%== %>)
|
|
3456
3461
|
*/
|
|
3457
3462
|
function isERBOutputNode(node) {
|
|
3458
|
-
|
|
3463
|
+
if (!isNode(node, ERBContentNode))
|
|
3464
|
+
return false;
|
|
3465
|
+
if (!node.tag_opening?.value)
|
|
3466
|
+
return false;
|
|
3467
|
+
return ["<%=", "<%=="].includes(node.tag_opening?.value);
|
|
3459
3468
|
}
|
|
3460
3469
|
/**
|
|
3461
3470
|
* Checks if a node is a non-output ERB node (control flow: <% %>)
|
|
@@ -3724,7 +3733,7 @@ function toMonacoDiagnostic(diagnostic) {
|
|
|
3724
3733
|
}
|
|
3725
3734
|
|
|
3726
3735
|
var name = "@herb-tools/core";
|
|
3727
|
-
var version = "0.
|
|
3736
|
+
var version = "0.7.1";
|
|
3728
3737
|
var packageJSON = {
|
|
3729
3738
|
name: name,
|
|
3730
3739
|
version: version};
|
|
@@ -3947,7 +3956,7 @@ class HerbBackend {
|
|
|
3947
3956
|
}
|
|
3948
3957
|
|
|
3949
3958
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
3950
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
3959
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.1/templates/javascript/packages/core/src/visitor.ts.erb
|
|
3951
3960
|
class Visitor {
|
|
3952
3961
|
visit(node) {
|
|
3953
3962
|
if (!node)
|