htmljs-parser 3.2.0 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { STATE, Range, ParserOptions as Options } from "../internal";
1
+ import { STATE, Range, ParserOptions as Options, ErrorCode } from "../internal";
2
2
  export interface Meta extends Range {
3
3
  parent: Meta;
4
4
  state: StateDefinition;
@@ -56,7 +56,7 @@ export declare class Parser {
56
56
  * tags within a block are properly closed.
57
57
  */
58
58
  beginHtmlBlock(delimiter: string | undefined, singleLine: boolean): void;
59
- emitError(range: number | Range, code: string, message: string): void;
59
+ emitError(range: number | Range, code: ErrorCode, message: string): void;
60
60
  closeTag(start: number, end: number, value: Range | undefined): void;
61
61
  consumeWhitespaceIfBefore(str: string, start?: number): boolean;
62
62
  getPreviousNonWhitespaceCharCode(start?: number): number;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type ParserOptions, type Range } from "./internal";
2
- export { TagType, type ParserOptions as Handlers, type Position, type Location, type Ranges, type Range, } from "./internal";
2
+ export { TagType, ErrorCode, type ParserOptions as Handlers, type Position, type Location, type Ranges, type Range, } from "./internal";
3
3
  /**
4
4
  * Creates a new Marko parser.
5
5
  */
@@ -15,7 +15,7 @@ export declare function createParser(handlers: ParserOptions): {
15
15
  /**
16
16
  * Given a offset in the current source code, returns a Position object with line & character information.
17
17
  */
18
- positionAt(index: number): import("./internal").Position;
18
+ positionAt(offset: number): import("./internal").Position;
19
19
  /**
20
20
  * Given a offset range in the current source code, returns a Location object with a start & end position information.
21
21
  */
package/dist/index.js CHANGED
@@ -19,12 +19,42 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/index.ts
20
20
  var src_exports = {};
21
21
  __export(src_exports, {
22
+ ErrorCode: () => ErrorCode,
22
23
  TagType: () => TagType,
23
24
  createParser: () => createParser
24
25
  });
25
26
  module.exports = __toCommonJS(src_exports);
26
27
 
27
28
  // src/util/constants.ts
29
+ var ErrorCode = /* @__PURE__ */ ((ErrorCode3) => {
30
+ ErrorCode3[ErrorCode3["EXTRA_CLOSING_TAG"] = 0] = "EXTRA_CLOSING_TAG";
31
+ ErrorCode3[ErrorCode3["INVALID_ATTRIBUTE_ARGUMENT"] = 1] = "INVALID_ATTRIBUTE_ARGUMENT";
32
+ ErrorCode3[ErrorCode3["INVALID_ATTRIBUTE_NAME"] = 2] = "INVALID_ATTRIBUTE_NAME";
33
+ ErrorCode3[ErrorCode3["INVALID_ATTRIBUTE_VALUE"] = 3] = "INVALID_ATTRIBUTE_VALUE";
34
+ ErrorCode3[ErrorCode3["INVALID_CHARACTER"] = 4] = "INVALID_CHARACTER";
35
+ ErrorCode3[ErrorCode3["INVALID_CODE_AFTER_SEMICOLON"] = 5] = "INVALID_CODE_AFTER_SEMICOLON";
36
+ ErrorCode3[ErrorCode3["INVALID_EXPRESSION"] = 6] = "INVALID_EXPRESSION";
37
+ ErrorCode3[ErrorCode3["INVALID_INDENTATION"] = 7] = "INVALID_INDENTATION";
38
+ ErrorCode3[ErrorCode3["INVALID_LINE_START"] = 8] = "INVALID_LINE_START";
39
+ ErrorCode3[ErrorCode3["INVALID_REGULAR_EXPRESSION"] = 9] = "INVALID_REGULAR_EXPRESSION";
40
+ ErrorCode3[ErrorCode3["INVALID_STRING"] = 10] = "INVALID_STRING";
41
+ ErrorCode3[ErrorCode3["INVALID_TAG_ARGUMENT"] = 11] = "INVALID_TAG_ARGUMENT";
42
+ ErrorCode3[ErrorCode3["INVALID_TAG_SHORTHAND"] = 12] = "INVALID_TAG_SHORTHAND";
43
+ ErrorCode3[ErrorCode3["INVALID_TEMPLATE_STRING"] = 13] = "INVALID_TEMPLATE_STRING";
44
+ ErrorCode3[ErrorCode3["MALFORMED_CDATA"] = 14] = "MALFORMED_CDATA";
45
+ ErrorCode3[ErrorCode3["MALFORMED_CLOSE_TAG"] = 15] = "MALFORMED_CLOSE_TAG";
46
+ ErrorCode3[ErrorCode3["MALFORMED_COMMENT"] = 16] = "MALFORMED_COMMENT";
47
+ ErrorCode3[ErrorCode3["MALFORMED_DECLARATION"] = 17] = "MALFORMED_DECLARATION";
48
+ ErrorCode3[ErrorCode3["MALFORMED_DOCUMENT_TYPE"] = 18] = "MALFORMED_DOCUMENT_TYPE";
49
+ ErrorCode3[ErrorCode3["MALFORMED_OPEN_TAG"] = 19] = "MALFORMED_OPEN_TAG";
50
+ ErrorCode3[ErrorCode3["MALFORMED_PLACEHOLDER"] = 20] = "MALFORMED_PLACEHOLDER";
51
+ ErrorCode3[ErrorCode3["MISMATCHED_CLOSING_TAG"] = 21] = "MISMATCHED_CLOSING_TAG";
52
+ ErrorCode3[ErrorCode3["MISSING_END_TAG"] = 22] = "MISSING_END_TAG";
53
+ ErrorCode3[ErrorCode3["MISSING_TAG_VARIABLE"] = 23] = "MISSING_TAG_VARIABLE";
54
+ ErrorCode3[ErrorCode3["RESERVED_TAG_NAME"] = 24] = "RESERVED_TAG_NAME";
55
+ ErrorCode3[ErrorCode3["ROOT_TAG_ONLY"] = 25] = "ROOT_TAG_ONLY";
56
+ return ErrorCode3;
57
+ })(ErrorCode || {});
28
58
  var TagType = /* @__PURE__ */ ((TagType2) => {
29
59
  TagType2[TagType2["html"] = 0] = "html";
30
60
  TagType2[TagType2["text"] = 1] = "text";
@@ -73,7 +103,7 @@ function htmlEOF() {
73
103
  if (this.activeTag.concise) {
74
104
  this.closeTag(this.pos, this.pos, void 0);
75
105
  } else {
76
- return this.emitError(this.activeTag, "MISSING_END_TAG", 'Missing ending "' + this.read(this.activeTag.tagName) + '" tag');
106
+ return this.emitError(this.activeTag, 22 /* MISSING_END_TAG */, 'Missing ending "' + this.read(this.activeTag.tagName) + '" tag');
77
107
  }
78
108
  }
79
109
  }
@@ -443,7 +473,7 @@ var ATTRIBUTE = {
443
473
  if (this.isConcise) {
444
474
  this.exitState();
445
475
  } else {
446
- this.emitError(attr, "MALFORMED_OPEN_TAG", 'EOF reached while parsing attribute "' + (attr.name ? this.read(attr.name) : "default") + '" for the "' + this.read(this.activeTag.tagName) + '" tag');
476
+ this.emitError(attr, 19 /* MALFORMED_OPEN_TAG */, 'EOF reached while parsing attribute "' + (attr.name ? this.read(attr.name) : "default") + '" for the "' + this.read(this.activeTag.tagName) + '" tag');
447
477
  }
448
478
  },
449
479
  return(child, attr) {
@@ -459,7 +489,7 @@ var ATTRIBUTE = {
459
489
  }
460
490
  case 3 /* ARGUMENT */: {
461
491
  if (attr.args) {
462
- this.emitError(child, "ILLEGAL_ATTRIBUTE_ARGUMENT", "An attribute can only have one set of arguments");
492
+ this.emitError(child, 1 /* INVALID_ATTRIBUTE_ARGUMENT */, "An attribute can only have one set of arguments");
463
493
  return;
464
494
  }
465
495
  const start = child.start - 1;
@@ -506,7 +536,7 @@ var ATTRIBUTE = {
506
536
  }
507
537
  case 2 /* VALUE */: {
508
538
  if (child.start === child.end) {
509
- return this.emitError(child, "ILLEGAL_ATTRIBUTE_VALUE", "Missing value for attribute");
539
+ return this.emitError(child, 3 /* INVALID_ATTRIBUTE_VALUE */, "Missing value for attribute");
510
540
  }
511
541
  if (attr.spread) {
512
542
  (_h = (_g = this.options).onAttrSpread) == null ? void 0 : _h.call(_g, {
@@ -607,7 +637,7 @@ function handleDelimitedBlockEOL(parser, newLineLength, {
607
637
  parser.exitState();
608
638
  parser.exitState();
609
639
  } else {
610
- parser.emitError(parser.pos, "INVALID_CHARACTER", "A concise mode closing block delimiter can only be followed by whitespace.");
640
+ parser.emitError(parser.pos, 4 /* INVALID_CHARACTER */, "A concise mode closing block delimiter can only be followed by whitespace.");
611
641
  }
612
642
  } else if (parser.lookAheadFor(indent, parser.pos + newLineLength)) {
613
643
  parser.startText();
@@ -653,7 +683,7 @@ var CDATA = {
653
683
  eol() {
654
684
  },
655
685
  eof(cdata) {
656
- this.emitError(cdata, "MALFORMED_CDATA", "EOF reached while parsing CDATA");
686
+ this.emitError(cdata, 14 /* MALFORMED_CDATA */, "EOF reached while parsing CDATA");
657
687
  },
658
688
  return() {
659
689
  }
@@ -692,7 +722,7 @@ var CLOSE_TAG = {
692
722
  eol() {
693
723
  },
694
724
  eof(closeTag) {
695
- this.emitError(closeTag, "MALFORMED_CLOSE_TAG", "EOF reached while parsing closing tag");
725
+ this.emitError(closeTag, 15 /* MALFORMED_CLOSE_TAG */, "EOF reached while parsing closing tag");
696
726
  },
697
727
  return() {
698
728
  }
@@ -729,7 +759,7 @@ function ensureExpectedCloseTag(parser, closeTag) {
729
759
  const closeTagNameStart = closeTag.start + 2;
730
760
  const closeTagNameEnd = closeTag.end - 1;
731
761
  if (!activeTag) {
732
- parser.emitError(closeTag, "EXTRA_CLOSING_TAG", 'The closing "' + parser.read({ start: closeTagNameStart, end: closeTagNameEnd }) + '" tag was not expected');
762
+ parser.emitError(closeTag, 0 /* EXTRA_CLOSING_TAG */, 'The closing "' + parser.read({ start: closeTagNameStart, end: closeTagNameEnd }) + '" tag was not expected');
733
763
  return false;
734
764
  }
735
765
  const closeTagNamePos = {
@@ -742,7 +772,7 @@ function ensureExpectedCloseTag(parser, closeTag) {
742
772
  start: activeTag.tagName.start,
743
773
  end: activeTag.shorthandEnd
744
774
  })) {
745
- parser.emitError(closeTag, "MISMATCHED_CLOSING_TAG", 'The closing "' + parser.read(closeTagNamePos) + '" tag does not match the corresponding opening "' + (parser.read(activeTag.tagName) || "div") + '" tag');
775
+ parser.emitError(closeTag, 21 /* MISMATCHED_CLOSING_TAG */, 'The closing "' + parser.read(closeTagNamePos) + '" tag does not match the corresponding opening "' + (parser.read(activeTag.tagName) || "div") + '" tag');
746
776
  return false;
747
777
  }
748
778
  }
@@ -778,18 +808,18 @@ var CONCISE_HTML_CONTENT = {
778
808
  parentTag = this.activeTag;
779
809
  }
780
810
  if (!parentTag && curIndent) {
781
- this.emitError(this.pos, "BAD_INDENTATION", "Line has extra indentation at the beginning");
811
+ this.emitError(this.pos, 7 /* INVALID_INDENTATION */, "Line has extra indentation at the beginning");
782
812
  return;
783
813
  }
784
814
  if (parentTag) {
785
815
  if (parentTag.type === 1 /* text */ && code !== 45 /* HTML_BLOCK_DELIMITER */) {
786
- this.emitError(this.pos, "ILLEGAL_LINE_START", 'A line within a tag that only allows text content must begin with a "-" character');
816
+ this.emitError(this.pos, 8 /* INVALID_LINE_START */, 'A line within a tag that only allows text content must begin with a "-" character');
787
817
  return;
788
818
  }
789
819
  if (parentTag.nestedIndent === void 0) {
790
820
  parentTag.nestedIndent = this.indent;
791
821
  } else if (parentTag.nestedIndent !== this.indent) {
792
- this.emitError(this.pos, "BAD_INDENTATION", "Line indentation does match indentation of previous line");
822
+ this.emitError(this.pos, 7 /* INVALID_INDENTATION */, "Line indentation does match indentation of previous line");
793
823
  return;
794
824
  }
795
825
  }
@@ -811,7 +841,7 @@ var CONCISE_HTML_CONTENT = {
811
841
  this.enterState(states_exports.BEGIN_DELIMITED_HTML_BLOCK);
812
842
  this.pos--;
813
843
  } else {
814
- this.emitError(this.pos, "ILLEGAL_LINE_START", 'A line in concise mode cannot start with a single hyphen. Use "--" instead. See: https://github.com/marko-js/htmljs-parser/issues/43');
844
+ this.emitError(this.pos, 8 /* INVALID_LINE_START */, 'A line in concise mode cannot start with a single hyphen. Use "--" instead. See: https://github.com/marko-js/htmljs-parser/issues/43');
815
845
  }
816
846
  return;
817
847
  case 47 /* FORWARD_SLASH */:
@@ -825,7 +855,7 @@ var CONCISE_HTML_CONTENT = {
825
855
  this.pos++;
826
856
  return;
827
857
  default:
828
- this.emitError(this.pos, "ILLEGAL_LINE_START", 'A line in concise mode cannot start with "/" unless it starts a "//" or "/*" comment');
858
+ this.emitError(this.pos, 8 /* INVALID_LINE_START */, 'A line in concise mode cannot start with "/" unless it starts a "//" or "/*" comment');
829
859
  return;
830
860
  }
831
861
  }
@@ -862,7 +892,7 @@ var CONCISE_HTML_CONTENT = {
862
892
  }
863
893
  });
864
894
  if (!this.consumeWhitespaceOnLine(0)) {
865
- this.emitError(this.pos, "INVALID_CHARACTER", "In concise mode a javascript comment block can only be followed by whitespace characters and a newline.");
895
+ this.emitError(this.pos, 4 /* INVALID_CHARACTER */, "In concise mode a javascript comment block can only be followed by whitespace characters and a newline.");
866
896
  }
867
897
  break;
868
898
  }
@@ -896,7 +926,7 @@ var DECLARATION = {
896
926
  eol() {
897
927
  },
898
928
  eof(declaration) {
899
- this.emitError(declaration, "MALFORMED_DECLARATION", "EOF reached while parsing declaration");
929
+ this.emitError(declaration, 17 /* MALFORMED_DECLARATION */, "EOF reached while parsing declaration");
900
930
  },
901
931
  return() {
902
932
  }
@@ -947,7 +977,7 @@ var DTD = {
947
977
  eol() {
948
978
  },
949
979
  eof(documentType) {
950
- this.emitError(documentType, "MALFORMED_DOCUMENT_TYPE", "EOF reached while parsing document type");
980
+ this.emitError(documentType, 18 /* MALFORMED_DOCUMENT_TYPE */, "EOF reached while parsing document type");
951
981
  },
952
982
  return() {
953
983
  }
@@ -1027,11 +1057,11 @@ var EXPRESSION = {
1027
1057
  case 93 /* CLOSE_SQUARE_BRACKET */:
1028
1058
  case 125 /* CLOSE_CURLY_BRACE */: {
1029
1059
  if (!expression.groupStack.length) {
1030
- return this.emitError(expression, "INVALID_EXPRESSION", 'Mismatched group. A closing "' + String.fromCharCode(code) + '" character was found but it is not matched with a corresponding opening character.');
1060
+ return this.emitError(expression, 6 /* INVALID_EXPRESSION */, 'Mismatched group. A closing "' + String.fromCharCode(code) + '" character was found but it is not matched with a corresponding opening character.');
1031
1061
  }
1032
1062
  const expectedCode = expression.groupStack.pop();
1033
1063
  if (expectedCode !== code) {
1034
- return this.emitError(expression, "INVALID_EXPRESSION", 'Mismatched group. A "' + String.fromCharCode(code) + '" character was found when "' + String.fromCharCode(expectedCode) + '" was expected.');
1064
+ return this.emitError(expression, 6 /* INVALID_EXPRESSION */, 'Mismatched group. A "' + String.fromCharCode(code) + '" character was found when "' + String.fromCharCode(expectedCode) + '" was expected.');
1035
1065
  }
1036
1066
  break;
1037
1067
  }
@@ -1039,11 +1069,10 @@ var EXPRESSION = {
1039
1069
  },
1040
1070
  eol(_, expression) {
1041
1071
  if (!expression.groupStack.length && (expression.terminatedByWhitespace || expression.terminatedByEOL)) {
1042
- if (checkForOperators(this, expression)) {
1072
+ if (checkForOperators(this, expression))
1043
1073
  this.forward = 1;
1044
- } else {
1074
+ else
1045
1075
  this.exitState();
1046
- }
1047
1076
  }
1048
1077
  },
1049
1078
  eof(expression) {
@@ -1055,16 +1084,16 @@ var EXPRESSION = {
1055
1084
  case states_exports.ATTRIBUTE: {
1056
1085
  const attr = parent;
1057
1086
  if (!attr.spread && !attr.name) {
1058
- return this.emitError(expression, "MALFORMED_OPEN_TAG", 'EOF reached while parsing attribute name for the "' + this.read(this.activeTag.tagName) + '" tag');
1087
+ return this.emitError(expression, 19 /* MALFORMED_OPEN_TAG */, 'EOF reached while parsing attribute name for the "' + this.read(this.activeTag.tagName) + '" tag');
1059
1088
  }
1060
- return this.emitError(expression, "MALFORMED_OPEN_TAG", `EOF reached while parsing attribute value for the ${attr.spread ? "..." : attr.name ? `"${this.read(attr.name)}"` : `"default"`} attribute`);
1089
+ return this.emitError(expression, 19 /* MALFORMED_OPEN_TAG */, `EOF reached while parsing attribute value for the ${attr.spread ? "..." : attr.name ? `"${this.read(attr.name)}"` : `"default"`} attribute`);
1061
1090
  }
1062
1091
  case states_exports.TAG_NAME:
1063
- return this.emitError(expression, "MALFORMED_OPEN_TAG", "EOF reached while parsing tag name");
1092
+ return this.emitError(expression, 19 /* MALFORMED_OPEN_TAG */, "EOF reached while parsing tag name");
1064
1093
  case states_exports.PLACEHOLDER:
1065
- return this.emitError(expression, "MALFORMED_PLACEHOLDER", "EOF reached while parsing placeholder");
1094
+ return this.emitError(expression, 20 /* MALFORMED_PLACEHOLDER */, "EOF reached while parsing placeholder");
1066
1095
  }
1067
- return this.emitError(expression, "INVALID_EXPRESSION", "EOF reached while parsing expression");
1096
+ return this.emitError(expression, 6 /* INVALID_EXPRESSION */, "EOF reached while parsing expression");
1068
1097
  }
1069
1098
  },
1070
1099
  return() {
@@ -1081,7 +1110,7 @@ function checkForOperators(parser, expression) {
1081
1110
  if (expression.skipOperators) {
1082
1111
  return false;
1083
1112
  }
1084
- const pattern = parser.isConcise ? conciseOperatorPattern : htmlOperatorPattern;
1113
+ const pattern = parser.isConcise || expression.terminatedByEOL ? conciseOperatorPattern : htmlOperatorPattern;
1085
1114
  pattern.lastIndex = parser.pos;
1086
1115
  const matches = pattern.exec(parser.data);
1087
1116
  if (matches) {
@@ -1156,7 +1185,7 @@ var HTML_COMMENT = {
1156
1185
  eol() {
1157
1186
  },
1158
1187
  eof(comment) {
1159
- this.emitError(comment, "MALFORMED_COMMENT", "EOF reached while parsing comment");
1188
+ this.emitError(comment, 16 /* MALFORMED_COMMENT */, "EOF reached while parsing comment");
1160
1189
  },
1161
1190
  return() {
1162
1191
  }
@@ -1321,7 +1350,7 @@ var JS_COMMENT_BLOCK = {
1321
1350
  eol() {
1322
1351
  },
1323
1352
  eof(comment) {
1324
- this.emitError(comment, "MALFORMED_COMMENT", "EOF reached while parsing multi-line JavaScript comment");
1353
+ this.emitError(comment, 16 /* MALFORMED_COMMENT */, "EOF reached while parsing multi-line JavaScript comment");
1325
1354
  },
1326
1355
  return() {
1327
1356
  }
@@ -1444,7 +1473,7 @@ var PLACEHOLDER = {
1444
1473
  },
1445
1474
  return(child) {
1446
1475
  if (child.start === child.end) {
1447
- this.emitError(child, "PLACEHOLDER_EXPRESSION_REQUIRED", "Invalid placeholder, the expression cannot be missing");
1476
+ this.emitError(child, 20 /* MALFORMED_PLACEHOLDER */, "Invalid placeholder, the expression cannot be missing");
1448
1477
  }
1449
1478
  this.pos++;
1450
1479
  this.exitState();
@@ -1518,10 +1547,10 @@ var REGULAR_EXPRESSION = {
1518
1547
  }
1519
1548
  },
1520
1549
  eol(_, regExp) {
1521
- this.emitError(regExp, "INVALID_REGULAR_EXPRESSION", "EOL reached while parsing regular expression");
1550
+ this.emitError(regExp, 9 /* INVALID_REGULAR_EXPRESSION */, "EOL reached while parsing regular expression");
1522
1551
  },
1523
1552
  eof(regExp) {
1524
- this.emitError(regExp, "INVALID_REGULAR_EXPRESSION", "EOF reached while parsing regular expression");
1553
+ this.emitError(regExp, 9 /* INVALID_REGULAR_EXPRESSION */, "EOF reached while parsing regular expression");
1525
1554
  },
1526
1555
  return() {
1527
1556
  }
@@ -1555,7 +1584,7 @@ var STRING = {
1555
1584
  eol() {
1556
1585
  },
1557
1586
  eof(string) {
1558
- this.emitError(string, "INVALID_STRING", "EOF reached while parsing string expression");
1587
+ this.emitError(string, 10 /* INVALID_STRING */, "EOF reached while parsing string expression");
1559
1588
  },
1560
1589
  return() {
1561
1590
  }
@@ -1583,7 +1612,7 @@ var TAG_NAME = {
1583
1612
  switch (tagName.shorthandCode) {
1584
1613
  case 35 /* NUMBER_SIGN */:
1585
1614
  if (this.activeTag.hasShorthandId) {
1586
- return this.emitError(tagName, "INVALID_TAG_SHORTHAND", "Multiple shorthand ID parts are not allowed on the same tag");
1615
+ return this.emitError(tagName, 12 /* INVALID_TAG_SHORTHAND */, "Multiple shorthand ID parts are not allowed on the same tag");
1587
1616
  }
1588
1617
  this.activeTag.hasShorthandId = true;
1589
1618
  (_b = (_a = this.options).onTagShorthandId) == null ? void 0 : _b.call(_a, {
@@ -1615,10 +1644,10 @@ var TAG_NAME = {
1615
1644
  tag.type = tagType;
1616
1645
  if (tagType === 3 /* statement */) {
1617
1646
  if (!tag.concise) {
1618
- return this.emitError(tagName, "RESERVED_TAG_NAME", `The "${this.read(tagName)}" tag is reserved and cannot be used as an HTML tag.`);
1647
+ return this.emitError(tagName, 24 /* RESERVED_TAG_NAME */, `The "${this.read(tagName)}" tag is reserved and cannot be used as an HTML tag.`);
1619
1648
  }
1620
1649
  if (tag.parentTag) {
1621
- return this.emitError(tagName, "ROOT_TAG_ONLY", `"${this.read(tagName)}" can only be used at the root of the template.`);
1650
+ return this.emitError(tagName, 25 /* ROOT_TAG_ONLY */, `"${this.read(tagName)}" can only be used at the root of the template.`);
1622
1651
  }
1623
1652
  this.enterState(states_exports.EXPRESSION).terminatedByEOL = true;
1624
1653
  }
@@ -1653,12 +1682,12 @@ var TAG_NAME = {
1653
1682
  if (child.terminatedByEOL)
1654
1683
  return;
1655
1684
  if (child.start === child.end) {
1656
- this.emitError(child, "PLACEHOLDER_EXPRESSION_REQUIRED", "Invalid placeholder, the expression cannot be missing");
1685
+ this.emitError(child, 20 /* MALFORMED_PLACEHOLDER */, "Invalid placeholder, the expression cannot be missing");
1657
1686
  }
1658
1687
  const { quasis, expressions } = tagName;
1659
1688
  const start = child.start - 2;
1660
1689
  const end = ++this.pos;
1661
- const nextStart = end + 1;
1690
+ const nextStart = end;
1662
1691
  expressions.push({
1663
1692
  start,
1664
1693
  end,
@@ -1701,13 +1730,13 @@ var TEMPLATE_STRING = {
1701
1730
  }
1702
1731
  },
1703
1732
  eof(templateString) {
1704
- this.emitError(templateString, "INVALID_TEMPLATE_STRING", "EOF reached while parsing template string expression");
1733
+ this.emitError(templateString, 13 /* INVALID_TEMPLATE_STRING */, "EOF reached while parsing template string expression");
1705
1734
  },
1706
1735
  eol() {
1707
1736
  },
1708
1737
  return(child) {
1709
1738
  if (child.start === child.end) {
1710
- this.emitError(child, "PLACEHOLDER_EXPRESSION_REQUIRED", "Invalid placeholder, the expression cannot be missing");
1739
+ this.emitError(child, 20 /* MALFORMED_PLACEHOLDER */, "Invalid placeholder, the expression cannot be missing");
1711
1740
  }
1712
1741
  this.pos++;
1713
1742
  }
@@ -1789,12 +1818,12 @@ var OPEN_TAG = {
1789
1818
  eof(tag) {
1790
1819
  if (this.isConcise) {
1791
1820
  if (tag.stage === 4 /* ATTR_GROUP */) {
1792
- this.emitError(tag, "MALFORMED_OPEN_TAG", 'EOF reached while within an attribute group (e.g. "[ ... ]").');
1821
+ this.emitError(tag, 19 /* MALFORMED_OPEN_TAG */, 'EOF reached while within an attribute group (e.g. "[ ... ]").');
1793
1822
  return;
1794
1823
  }
1795
1824
  this.exitState();
1796
1825
  } else {
1797
- this.emitError(tag, "MALFORMED_OPEN_TAG", "EOF reached while parsing open tag");
1826
+ this.emitError(tag, 19 /* MALFORMED_OPEN_TAG */, "EOF reached while parsing open tag");
1798
1827
  }
1799
1828
  },
1800
1829
  char(code, tag) {
@@ -1824,17 +1853,17 @@ var OPEN_TAG = {
1824
1853
  }
1825
1854
  break;
1826
1855
  }
1827
- this.emitError(this.pos, "INVALID_CODE_AFTER_SEMICOLON", "A semicolon indicates the end of a line. Only comments may follow it.");
1856
+ this.emitError(this.pos, 5 /* INVALID_CODE_AFTER_SEMICOLON */, "A semicolon indicates the end of a line. Only comments may follow it.");
1828
1857
  }
1829
1858
  return;
1830
1859
  }
1831
1860
  if (code === 45 /* HTML_BLOCK_DELIMITER */) {
1832
1861
  if (this.lookAtCharCodeAhead(1) !== 45 /* HTML_BLOCK_DELIMITER */) {
1833
- this.emitError(tag, "MALFORMED_OPEN_TAG", '"-" not allowed as first character of attribute name');
1862
+ this.emitError(tag, 19 /* MALFORMED_OPEN_TAG */, '"-" not allowed as first character of attribute name');
1834
1863
  return;
1835
1864
  }
1836
1865
  if (tag.stage === 4 /* ATTR_GROUP */) {
1837
- this.emitError(this.pos, "MALFORMED_OPEN_TAG", "Attribute group was not properly ended");
1866
+ this.emitError(this.pos, 19 /* MALFORMED_OPEN_TAG */, "Attribute group was not properly ended");
1838
1867
  return;
1839
1868
  }
1840
1869
  this.exitState();
@@ -1859,14 +1888,14 @@ var OPEN_TAG = {
1859
1888
  return;
1860
1889
  } else if (code === 91 /* OPEN_SQUARE_BRACKET */) {
1861
1890
  if (tag.stage === 4 /* ATTR_GROUP */) {
1862
- this.emitError(this.pos, "MALFORMED_OPEN_TAG", 'Unexpected "[" character within open tag.');
1891
+ this.emitError(this.pos, 19 /* MALFORMED_OPEN_TAG */, 'Unexpected "[" character within open tag.');
1863
1892
  return;
1864
1893
  }
1865
1894
  tag.stage = 4 /* ATTR_GROUP */;
1866
1895
  return;
1867
1896
  } else if (code === 93 /* CLOSE_SQUARE_BRACKET */) {
1868
1897
  if (tag.stage !== 4 /* ATTR_GROUP */) {
1869
- this.emitError(this.pos, "MALFORMED_OPEN_TAG", 'Unexpected "]" character within open tag.');
1898
+ this.emitError(this.pos, 19 /* MALFORMED_OPEN_TAG */, 'Unexpected "]" character within open tag.');
1870
1899
  return;
1871
1900
  }
1872
1901
  tag.stage = 0 /* UNKNOWN */;
@@ -1883,7 +1912,7 @@ var OPEN_TAG = {
1883
1912
  return;
1884
1913
  }
1885
1914
  if (code === 60 /* OPEN_ANGLE_BRACKET */) {
1886
- return this.emitError(this.pos, "ILLEGAL_ATTRIBUTE_NAME", 'Invalid attribute name. Attribute name cannot begin with the "<" character.');
1915
+ return this.emitError(this.pos, 2 /* INVALID_ATTRIBUTE_NAME */, 'Invalid attribute name. Attribute name cannot begin with the "<" character.');
1887
1916
  }
1888
1917
  if (code === 47 /* FORWARD_SLASH */ && this.lookAtCharCodeAhead(1) === 42 /* ASTERISK */) {
1889
1918
  this.enterState(states_exports.JS_COMMENT_BLOCK);
@@ -1905,7 +1934,7 @@ var OPEN_TAG = {
1905
1934
  this.pos--;
1906
1935
  } else if (code === 40 /* OPEN_PAREN */ && !tag.hasAttrs) {
1907
1936
  if (tag.hasArgs) {
1908
- this.emitError(this.pos, "ILLEGAL_TAG_ARGUMENT", "A tag can only have one argument");
1937
+ this.emitError(this.pos, 11 /* INVALID_TAG_ARGUMENT */, "A tag can only have one argument");
1909
1938
  return;
1910
1939
  }
1911
1940
  tag.stage = 2 /* ARGUMENT */;
@@ -1941,7 +1970,7 @@ var OPEN_TAG = {
1941
1970
  switch (tag.stage) {
1942
1971
  case 1 /* VAR */: {
1943
1972
  if (child.start === child.end) {
1944
- return this.emitError(child, "MISSING_TAG_VARIABLE", "A slash was found that was not followed by a variable name or lhs expression");
1973
+ return this.emitError(child, 23 /* MISSING_TAG_VARIABLE */, "A slash was found that was not followed by a variable name or lhs expression");
1945
1974
  }
1946
1975
  (_b = (_a = this.options).onTagVar) == null ? void 0 : _b.call(_a, {
1947
1976
  start: child.start - 1,
@@ -2005,8 +2034,8 @@ function createParser(handlers) {
2005
2034
  read(range) {
2006
2035
  return parser.read(range);
2007
2036
  },
2008
- positionAt(index) {
2009
- return parser.positionAt(index);
2037
+ positionAt(offset) {
2038
+ return parser.positionAt(offset);
2010
2039
  },
2011
2040
  locationAt(range) {
2012
2041
  return parser.locationAt(range);
@@ -2015,6 +2044,7 @@ function createParser(handlers) {
2015
2044
  }
2016
2045
  // Annotate the CommonJS export names for ESM import in node:
2017
2046
  0 && (module.exports = {
2047
+ ErrorCode,
2018
2048
  TagType,
2019
2049
  createParser
2020
2050
  });