htmljs-parser 5.5.0 → 5.5.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.
@@ -1,4 +1,4 @@
1
- import { STATE, Range, ParserOptions as Options, ErrorCode } from "../internal";
1
+ import { STATE, type Range, type ParserOptions as Options, ErrorCode } from "../internal";
2
2
  export interface Meta extends Range {
3
3
  parent: Meta;
4
4
  state: StateDefinition;
package/dist/index.js CHANGED
@@ -136,6 +136,7 @@ function getPosAfterLine(lines, startLine, index) {
136
136
 
137
137
  // src/core/Parser.ts
138
138
  var Parser = class {
139
+ // Keeps track of line indexes to provide line/column info.
139
140
  constructor(options) {
140
141
  this.options = options;
141
142
  }
@@ -172,6 +173,9 @@ var Parser = class {
172
173
  activeState.exit.call(this, activeRange);
173
174
  this.activeState.return.call(this, activeRange, parent);
174
175
  }
176
+ /**
177
+ * Compare a position in the source to either another position, or a string.
178
+ */
175
179
  matchAtPos(a, b) {
176
180
  const aPos = a.start;
177
181
  const aLen = a.end - aPos;
@@ -201,6 +205,10 @@ var Parser = class {
201
205
  }
202
206
  return false;
203
207
  }
208
+ /**
209
+ * Look ahead to see if the given str matches the substring sequence
210
+ * beyond
211
+ */
204
212
  lookAheadFor(str, startPos = this.pos + 1) {
205
213
  let i = str.length;
206
214
  if (startPos + i <= this.maxPos) {
@@ -229,6 +237,12 @@ var Parser = class {
229
237
  this.textPos = -1;
230
238
  }
231
239
  }
240
+ /**
241
+ * This is used to enter into "HTML" parsing mode instead
242
+ * of concise HTML. We push a block on to the stack so that we know when
243
+ * return back to the previous parsing mode and to ensure that all
244
+ * tags within a block are properly closed.
245
+ */
232
246
  beginHtmlBlock(delimiter, singleLine) {
233
247
  var _a;
234
248
  const content = this.enterState(
@@ -265,6 +279,7 @@ var Parser = class {
265
279
  (_b = (_a = this.options).onCloseTagName) == null ? void 0 : _b.call(_a, name);
266
280
  (_d = (_c = this.options).onCloseTagEnd) == null ? void 0 : _d.call(_c, { start, end });
267
281
  }
282
+ // --------------------------
268
283
  consumeWhitespaceIfBefore(str, start = 0) {
269
284
  const { pos, data } = this;
270
285
  let cur = pos + start;
@@ -519,8 +534,8 @@ var OPEN_TAG = {
519
534
  }
520
535
  return;
521
536
  }
522
- if (code === 45 /* HTML_BLOCK_DELIMITER */) {
523
- if (this.lookAtCharCodeAhead(1) !== 45 /* HTML_BLOCK_DELIMITER */) {
537
+ if (code === 45 /* HYPHEN */) {
538
+ if (this.lookAtCharCodeAhead(1) !== 45 /* HYPHEN */) {
524
539
  this.emitError(
525
540
  tag,
526
541
  19 /* MALFORMED_OPEN_TAG */,
@@ -685,6 +700,7 @@ var OPEN_TAG = {
685
700
  }
686
701
  (_b = (_a = this.options).onTagVar) == null ? void 0 : _b.call(_a, {
687
702
  start: child.start - 1,
703
+ // include /,
688
704
  end: child.end,
689
705
  value: {
690
706
  start: child.start,
@@ -734,6 +750,7 @@ var OPEN_TAG = {
734
750
  const end = ++this.pos;
735
751
  const types = {
736
752
  start: child.start - 1,
753
+ // include <
737
754
  end,
738
755
  value: {
739
756
  start: child.start,
@@ -964,6 +981,7 @@ var ATTRIBUTE = {
964
981
  typeParams,
965
982
  body: {
966
983
  start: child.start - 1,
984
+ // include {
967
985
  end,
968
986
  value: {
969
987
  start: child.start,
@@ -1132,7 +1150,7 @@ var BEGIN_DELIMITED_HTML_BLOCK = {
1132
1150
  exit() {
1133
1151
  },
1134
1152
  char(code, block) {
1135
- if (code === 45 /* HTML_BLOCK_DELIMITER */) {
1153
+ if (code === 45 /* HYPHEN */) {
1136
1154
  block.delimiter += "-";
1137
1155
  } else {
1138
1156
  const startPos = this.pos;
@@ -1215,7 +1233,9 @@ var CDATA = {
1215
1233
  end: cdata.end,
1216
1234
  value: {
1217
1235
  start: cdata.start + 9,
1236
+ // strip <![CDATA[
1218
1237
  end: cdata.end - 3
1238
+ // strip ]]>
1219
1239
  }
1220
1240
  });
1221
1241
  },
@@ -1388,7 +1408,7 @@ var CONCISE_HTML_CONTENT = {
1388
1408
  }
1389
1409
  }
1390
1410
  if (parentTag) {
1391
- if (parentTag.type === 1 /* text */ && code !== 45 /* HTML_BLOCK_DELIMITER */) {
1411
+ if (parentTag.type === 1 /* text */ && code !== 45 /* HYPHEN */) {
1392
1412
  this.emitError(
1393
1413
  this.pos,
1394
1414
  8 /* INVALID_LINE_START */,
@@ -1420,8 +1440,8 @@ var CONCISE_HTML_CONTENT = {
1420
1440
  return;
1421
1441
  }
1422
1442
  break;
1423
- case 45 /* HTML_BLOCK_DELIMITER */:
1424
- if (this.lookAtCharCodeAhead(1) === 45 /* HTML_BLOCK_DELIMITER */) {
1443
+ case 45 /* HYPHEN */:
1444
+ if (this.lookAtCharCodeAhead(1) === 45 /* HYPHEN */) {
1425
1445
  this.enterState(states_exports.BEGIN_DELIMITED_HTML_BLOCK);
1426
1446
  this.pos--;
1427
1447
  } else {
@@ -1470,6 +1490,7 @@ var CONCISE_HTML_CONTENT = {
1470
1490
  end: child.end,
1471
1491
  value: {
1472
1492
  start: child.start + 2,
1493
+ // strip //
1473
1494
  end: child.end
1474
1495
  }
1475
1496
  });
@@ -1480,7 +1501,9 @@ var CONCISE_HTML_CONTENT = {
1480
1501
  end: child.end,
1481
1502
  value: {
1482
1503
  start: child.start + 2,
1504
+ // strip /*
1483
1505
  end: child.end - 2
1506
+ // strip */,
1484
1507
  }
1485
1508
  });
1486
1509
  if (!this.consumeWhitespaceOnLine(0)) {
@@ -1540,7 +1563,9 @@ function exitDeclaration(parser, declaration, closeOffset) {
1540
1563
  end: declaration.end,
1541
1564
  value: {
1542
1565
  start: declaration.start + 2,
1566
+ // strip <?
1543
1567
  end: declaration.end - closeOffset
1568
+ // > or ?>
1544
1569
  }
1545
1570
  });
1546
1571
  }
@@ -1564,7 +1589,9 @@ var DTD = {
1564
1589
  end: documentType.end,
1565
1590
  value: {
1566
1591
  start: documentType.start + 2,
1592
+ // strip <!
1567
1593
  end: documentType.end - 1
1594
+ // strip >
1568
1595
  }
1569
1596
  });
1570
1597
  },
@@ -1888,7 +1915,22 @@ function lookAheadForOperator(data, pos) {
1888
1915
  }
1889
1916
  }
1890
1917
  function canFollowDivision(code) {
1891
- return isWordCode(code) || code === 37 /* PERCENT */ || code === 41 /* CLOSE_PAREN */ || code === 46 /* PERIOD */ || code === 60 /* OPEN_ANGLE_BRACKET */ || code === 93 /* CLOSE_SQUARE_BRACKET */ || code === 125 /* CLOSE_CURLY_BRACE */;
1918
+ if (isWordCode(code))
1919
+ return true;
1920
+ switch (code) {
1921
+ case 96 /* BACKTICK */:
1922
+ case 39 /* SINGLE_QUOTE */:
1923
+ case 34 /* DOUBLE_QUOTE */:
1924
+ case 37 /* PERCENT */:
1925
+ case 41 /* CLOSE_PAREN */:
1926
+ case 46 /* PERIOD */:
1927
+ case 60 /* OPEN_ANGLE_BRACKET */:
1928
+ case 93 /* CLOSE_SQUARE_BRACKET */:
1929
+ case 125 /* CLOSE_CURLY_BRACE */:
1930
+ return true;
1931
+ default:
1932
+ return false;
1933
+ }
1892
1934
  }
1893
1935
  function isWordCode(code) {
1894
1936
  return code >= 65 /* UPPER_A */ && code <= 90 /* UPPER_Z */ || code >= 97 /* LOWER_A */ && code <= 122 /* LOWER_Z */ || code >= 48 /* NUMBER_0 */ && code <= 57 /* NUMBER_9 */ || code == 36 /* DOLLAR */ || code === 95 /* UNDERSCORE */;
@@ -1957,7 +1999,9 @@ var HTML_COMMENT = {
1957
1999
  end: comment.end,
1958
2000
  value: {
1959
2001
  start: comment.start + 4,
2002
+ // strip <!--
1960
2003
  end: comment.end - 3
2004
+ // strip -->
1961
2005
  }
1962
2006
  });
1963
2007
  },
@@ -2083,6 +2127,7 @@ var HTML_CONTENT = {
2083
2127
  end: child.end,
2084
2128
  value: {
2085
2129
  start: child.start + 2,
2130
+ // strip //
2086
2131
  end: child.end
2087
2132
  }
2088
2133
  });
@@ -2093,7 +2138,9 @@ var HTML_CONTENT = {
2093
2138
  end: child.end,
2094
2139
  value: {
2095
2140
  start: child.start + 2,
2141
+ // strip /*
2096
2142
  end: child.end - 2
2143
+ // strip */,
2097
2144
  }
2098
2145
  });
2099
2146
  break;
@@ -2316,7 +2363,9 @@ var PLACEHOLDER = {
2316
2363
  escape: placeholder.escape,
2317
2364
  value: {
2318
2365
  start: placeholder.start + (placeholder.escape ? 2 : 3),
2366
+ // ignore ${ or $!{
2319
2367
  end: placeholder.end - 1
2368
+ // ignore }
2320
2369
  }
2321
2370
  });
2322
2371
  },
@@ -2685,15 +2734,27 @@ var PARSED_STRING = {
2685
2734
  function createParser(handlers) {
2686
2735
  const parser = new Parser(handlers);
2687
2736
  return {
2737
+ /**
2738
+ * Parses code and calls the provided handlers.
2739
+ */
2688
2740
  parse(code) {
2689
2741
  return parser.parse(code);
2690
2742
  },
2743
+ /**
2744
+ * Given an offset range in the current source code, reads and returns the substring in the input code.
2745
+ */
2691
2746
  read(range) {
2692
2747
  return parser.read(range);
2693
2748
  },
2749
+ /**
2750
+ * Given a offset in the current source code, returns a Position object with line & character information.
2751
+ */
2694
2752
  positionAt(offset) {
2695
2753
  return parser.positionAt(offset);
2696
2754
  },
2755
+ /**
2756
+ * Given a offset range in the current source code, returns a Location object with a start & end position information.
2757
+ */
2697
2758
  locationAt(range) {
2698
2759
  return parser.locationAt(range);
2699
2760
  }
package/dist/index.mjs CHANGED
@@ -111,6 +111,7 @@ function getPosAfterLine(lines, startLine, index) {
111
111
 
112
112
  // src/core/Parser.ts
113
113
  var Parser = class {
114
+ // Keeps track of line indexes to provide line/column info.
114
115
  constructor(options) {
115
116
  this.options = options;
116
117
  }
@@ -147,6 +148,9 @@ var Parser = class {
147
148
  activeState.exit.call(this, activeRange);
148
149
  this.activeState.return.call(this, activeRange, parent);
149
150
  }
151
+ /**
152
+ * Compare a position in the source to either another position, or a string.
153
+ */
150
154
  matchAtPos(a, b) {
151
155
  const aPos = a.start;
152
156
  const aLen = a.end - aPos;
@@ -176,6 +180,10 @@ var Parser = class {
176
180
  }
177
181
  return false;
178
182
  }
183
+ /**
184
+ * Look ahead to see if the given str matches the substring sequence
185
+ * beyond
186
+ */
179
187
  lookAheadFor(str, startPos = this.pos + 1) {
180
188
  let i = str.length;
181
189
  if (startPos + i <= this.maxPos) {
@@ -204,6 +212,12 @@ var Parser = class {
204
212
  this.textPos = -1;
205
213
  }
206
214
  }
215
+ /**
216
+ * This is used to enter into "HTML" parsing mode instead
217
+ * of concise HTML. We push a block on to the stack so that we know when
218
+ * return back to the previous parsing mode and to ensure that all
219
+ * tags within a block are properly closed.
220
+ */
207
221
  beginHtmlBlock(delimiter, singleLine) {
208
222
  var _a;
209
223
  const content = this.enterState(
@@ -240,6 +254,7 @@ var Parser = class {
240
254
  (_b = (_a = this.options).onCloseTagName) == null ? void 0 : _b.call(_a, name);
241
255
  (_d = (_c = this.options).onCloseTagEnd) == null ? void 0 : _d.call(_c, { start, end });
242
256
  }
257
+ // --------------------------
243
258
  consumeWhitespaceIfBefore(str, start = 0) {
244
259
  const { pos, data } = this;
245
260
  let cur = pos + start;
@@ -494,8 +509,8 @@ var OPEN_TAG = {
494
509
  }
495
510
  return;
496
511
  }
497
- if (code === 45 /* HTML_BLOCK_DELIMITER */) {
498
- if (this.lookAtCharCodeAhead(1) !== 45 /* HTML_BLOCK_DELIMITER */) {
512
+ if (code === 45 /* HYPHEN */) {
513
+ if (this.lookAtCharCodeAhead(1) !== 45 /* HYPHEN */) {
499
514
  this.emitError(
500
515
  tag,
501
516
  19 /* MALFORMED_OPEN_TAG */,
@@ -660,6 +675,7 @@ var OPEN_TAG = {
660
675
  }
661
676
  (_b = (_a = this.options).onTagVar) == null ? void 0 : _b.call(_a, {
662
677
  start: child.start - 1,
678
+ // include /,
663
679
  end: child.end,
664
680
  value: {
665
681
  start: child.start,
@@ -709,6 +725,7 @@ var OPEN_TAG = {
709
725
  const end = ++this.pos;
710
726
  const types = {
711
727
  start: child.start - 1,
728
+ // include <
712
729
  end,
713
730
  value: {
714
731
  start: child.start,
@@ -939,6 +956,7 @@ var ATTRIBUTE = {
939
956
  typeParams,
940
957
  body: {
941
958
  start: child.start - 1,
959
+ // include {
942
960
  end,
943
961
  value: {
944
962
  start: child.start,
@@ -1107,7 +1125,7 @@ var BEGIN_DELIMITED_HTML_BLOCK = {
1107
1125
  exit() {
1108
1126
  },
1109
1127
  char(code, block) {
1110
- if (code === 45 /* HTML_BLOCK_DELIMITER */) {
1128
+ if (code === 45 /* HYPHEN */) {
1111
1129
  block.delimiter += "-";
1112
1130
  } else {
1113
1131
  const startPos = this.pos;
@@ -1190,7 +1208,9 @@ var CDATA = {
1190
1208
  end: cdata.end,
1191
1209
  value: {
1192
1210
  start: cdata.start + 9,
1211
+ // strip <![CDATA[
1193
1212
  end: cdata.end - 3
1213
+ // strip ]]>
1194
1214
  }
1195
1215
  });
1196
1216
  },
@@ -1363,7 +1383,7 @@ var CONCISE_HTML_CONTENT = {
1363
1383
  }
1364
1384
  }
1365
1385
  if (parentTag) {
1366
- if (parentTag.type === 1 /* text */ && code !== 45 /* HTML_BLOCK_DELIMITER */) {
1386
+ if (parentTag.type === 1 /* text */ && code !== 45 /* HYPHEN */) {
1367
1387
  this.emitError(
1368
1388
  this.pos,
1369
1389
  8 /* INVALID_LINE_START */,
@@ -1395,8 +1415,8 @@ var CONCISE_HTML_CONTENT = {
1395
1415
  return;
1396
1416
  }
1397
1417
  break;
1398
- case 45 /* HTML_BLOCK_DELIMITER */:
1399
- if (this.lookAtCharCodeAhead(1) === 45 /* HTML_BLOCK_DELIMITER */) {
1418
+ case 45 /* HYPHEN */:
1419
+ if (this.lookAtCharCodeAhead(1) === 45 /* HYPHEN */) {
1400
1420
  this.enterState(states_exports.BEGIN_DELIMITED_HTML_BLOCK);
1401
1421
  this.pos--;
1402
1422
  } else {
@@ -1445,6 +1465,7 @@ var CONCISE_HTML_CONTENT = {
1445
1465
  end: child.end,
1446
1466
  value: {
1447
1467
  start: child.start + 2,
1468
+ // strip //
1448
1469
  end: child.end
1449
1470
  }
1450
1471
  });
@@ -1455,7 +1476,9 @@ var CONCISE_HTML_CONTENT = {
1455
1476
  end: child.end,
1456
1477
  value: {
1457
1478
  start: child.start + 2,
1479
+ // strip /*
1458
1480
  end: child.end - 2
1481
+ // strip */,
1459
1482
  }
1460
1483
  });
1461
1484
  if (!this.consumeWhitespaceOnLine(0)) {
@@ -1515,7 +1538,9 @@ function exitDeclaration(parser, declaration, closeOffset) {
1515
1538
  end: declaration.end,
1516
1539
  value: {
1517
1540
  start: declaration.start + 2,
1541
+ // strip <?
1518
1542
  end: declaration.end - closeOffset
1543
+ // > or ?>
1519
1544
  }
1520
1545
  });
1521
1546
  }
@@ -1539,7 +1564,9 @@ var DTD = {
1539
1564
  end: documentType.end,
1540
1565
  value: {
1541
1566
  start: documentType.start + 2,
1567
+ // strip <!
1542
1568
  end: documentType.end - 1
1569
+ // strip >
1543
1570
  }
1544
1571
  });
1545
1572
  },
@@ -1863,7 +1890,22 @@ function lookAheadForOperator(data, pos) {
1863
1890
  }
1864
1891
  }
1865
1892
  function canFollowDivision(code) {
1866
- return isWordCode(code) || code === 37 /* PERCENT */ || code === 41 /* CLOSE_PAREN */ || code === 46 /* PERIOD */ || code === 60 /* OPEN_ANGLE_BRACKET */ || code === 93 /* CLOSE_SQUARE_BRACKET */ || code === 125 /* CLOSE_CURLY_BRACE */;
1893
+ if (isWordCode(code))
1894
+ return true;
1895
+ switch (code) {
1896
+ case 96 /* BACKTICK */:
1897
+ case 39 /* SINGLE_QUOTE */:
1898
+ case 34 /* DOUBLE_QUOTE */:
1899
+ case 37 /* PERCENT */:
1900
+ case 41 /* CLOSE_PAREN */:
1901
+ case 46 /* PERIOD */:
1902
+ case 60 /* OPEN_ANGLE_BRACKET */:
1903
+ case 93 /* CLOSE_SQUARE_BRACKET */:
1904
+ case 125 /* CLOSE_CURLY_BRACE */:
1905
+ return true;
1906
+ default:
1907
+ return false;
1908
+ }
1867
1909
  }
1868
1910
  function isWordCode(code) {
1869
1911
  return code >= 65 /* UPPER_A */ && code <= 90 /* UPPER_Z */ || code >= 97 /* LOWER_A */ && code <= 122 /* LOWER_Z */ || code >= 48 /* NUMBER_0 */ && code <= 57 /* NUMBER_9 */ || code == 36 /* DOLLAR */ || code === 95 /* UNDERSCORE */;
@@ -1932,7 +1974,9 @@ var HTML_COMMENT = {
1932
1974
  end: comment.end,
1933
1975
  value: {
1934
1976
  start: comment.start + 4,
1977
+ // strip <!--
1935
1978
  end: comment.end - 3
1979
+ // strip -->
1936
1980
  }
1937
1981
  });
1938
1982
  },
@@ -2058,6 +2102,7 @@ var HTML_CONTENT = {
2058
2102
  end: child.end,
2059
2103
  value: {
2060
2104
  start: child.start + 2,
2105
+ // strip //
2061
2106
  end: child.end
2062
2107
  }
2063
2108
  });
@@ -2068,7 +2113,9 @@ var HTML_CONTENT = {
2068
2113
  end: child.end,
2069
2114
  value: {
2070
2115
  start: child.start + 2,
2116
+ // strip /*
2071
2117
  end: child.end - 2
2118
+ // strip */,
2072
2119
  }
2073
2120
  });
2074
2121
  break;
@@ -2291,7 +2338,9 @@ var PLACEHOLDER = {
2291
2338
  escape: placeholder.escape,
2292
2339
  value: {
2293
2340
  start: placeholder.start + (placeholder.escape ? 2 : 3),
2341
+ // ignore ${ or $!{
2294
2342
  end: placeholder.end - 1
2343
+ // ignore }
2295
2344
  }
2296
2345
  });
2297
2346
  },
@@ -2660,15 +2709,27 @@ var PARSED_STRING = {
2660
2709
  function createParser(handlers) {
2661
2710
  const parser = new Parser(handlers);
2662
2711
  return {
2712
+ /**
2713
+ * Parses code and calls the provided handlers.
2714
+ */
2663
2715
  parse(code) {
2664
2716
  return parser.parse(code);
2665
2717
  },
2718
+ /**
2719
+ * Given an offset range in the current source code, reads and returns the substring in the input code.
2720
+ */
2666
2721
  read(range) {
2667
2722
  return parser.read(range);
2668
2723
  },
2724
+ /**
2725
+ * Given a offset in the current source code, returns a Position object with line & character information.
2726
+ */
2669
2727
  positionAt(offset) {
2670
2728
  return parser.positionAt(offset);
2671
2729
  },
2730
+ /**
2731
+ * Given a offset range in the current source code, returns a Location object with a start & end position information.
2732
+ */
2672
2733
  locationAt(range) {
2673
2734
  return parser.locationAt(range);
2674
2735
  }
@@ -1,4 +1,4 @@
1
- import { StateDefinition, Range, Ranges, Meta } from "../internal";
1
+ import { type StateDefinition, type Range, type Ranges, type Meta } from "../internal";
2
2
  declare const enum ATTR_STAGE {
3
3
  UNKNOWN = 0,
4
4
  NAME = 1,
@@ -1,4 +1,4 @@
1
- import { Parser, StateDefinition, STATE, Meta } from "../internal";
1
+ import { Parser, type StateDefinition, STATE, type Meta } from "../internal";
2
2
  export interface DelimitedHTMLBlockMeta extends Meta {
3
3
  delimiter: string;
4
4
  indent: string;
@@ -1,3 +1,3 @@
1
- import { Parser, StateDefinition } from "../internal";
1
+ import { Parser, type StateDefinition } from "../internal";
2
2
  export declare const CDATA: StateDefinition;
3
3
  export declare function checkForCDATA(parser: Parser): boolean;
@@ -1,3 +1,3 @@
1
- import { StateDefinition, Parser } from "../internal";
1
+ import { type StateDefinition, Parser } from "../internal";
2
2
  export declare const CLOSE_TAG: StateDefinition;
3
3
  export declare function checkForClosingTag(parser: Parser): boolean;
@@ -1,2 +1,2 @@
1
- import { StateDefinition } from "../internal";
1
+ import { type StateDefinition } from "../internal";
2
2
  export declare const CONCISE_HTML_CONTENT: StateDefinition;
@@ -1,2 +1,2 @@
1
- import { StateDefinition } from "../internal";
1
+ import { type StateDefinition } from "../internal";
2
2
  export declare const DECLARATION: StateDefinition;
@@ -1,2 +1,2 @@
1
- import { StateDefinition } from "../internal";
1
+ import { type StateDefinition } from "../internal";
2
2
  export declare const DTD: StateDefinition;
@@ -1,4 +1,4 @@
1
- import { StateDefinition, Meta } from "../internal";
1
+ import { type StateDefinition, type Meta } from "../internal";
2
2
  export interface ExpressionMeta extends Meta {
3
3
  groupStack: number[];
4
4
  operators: boolean;
@@ -1,2 +1,2 @@
1
- import { StateDefinition } from "../internal";
1
+ import { type StateDefinition } from "../internal";
2
2
  export declare const HTML_COMMENT: StateDefinition;
@@ -1,4 +1,4 @@
1
- import { StateDefinition, Meta } from "../internal";
1
+ import { type StateDefinition, type Meta } from "../internal";
2
2
  export interface HTMLContentMeta extends Meta {
3
3
  indent: string;
4
4
  singleLine: boolean;
@@ -1,4 +1,4 @@
1
- import { Range, StateDefinition, Meta } from "../internal";
1
+ import { type Range, type StateDefinition, type Meta } from "../internal";
2
2
  interface ScriptletMeta extends Meta {
3
3
  block: boolean;
4
4
  value: Range;
@@ -1,2 +1,2 @@
1
- import { StateDefinition } from "../internal";
1
+ import { type StateDefinition } from "../internal";
2
2
  export declare const JS_COMMENT_BLOCK: StateDefinition;
@@ -1,2 +1,2 @@
1
- import { StateDefinition } from "../internal";
1
+ import { type StateDefinition } from "../internal";
2
2
  export declare const JS_COMMENT_LINE: StateDefinition;
@@ -1,4 +1,4 @@
1
- import { StateDefinition, Ranges, Meta, TagType } from "../internal";
1
+ import { type StateDefinition, type Ranges, type Meta, TagType } from "../internal";
2
2
  export declare enum TAG_STAGE {
3
3
  UNKNOWN = 0,
4
4
  VAR = 1,
@@ -1,4 +1,4 @@
1
- import { StateDefinition, Meta } from "../internal";
1
+ import { type StateDefinition, type Meta } from "../internal";
2
2
  interface ParsedStringMeta extends Meta {
3
3
  quoteCharCode: number;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { StateDefinition, Meta } from "../internal";
1
+ import { type StateDefinition, type Meta } from "../internal";
2
2
  export interface ParsedTextContentMeta extends Meta {
3
3
  indent: string;
4
4
  singleLine: boolean;
@@ -1,4 +1,4 @@
1
- import { Parser, StateDefinition, Meta } from "../internal";
1
+ import { Parser, type StateDefinition, type Meta } from "../internal";
2
2
  interface PlaceholderMeta extends Meta {
3
3
  escape: boolean;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { StateDefinition, Meta } from "../internal";
1
+ import { type StateDefinition, type Meta } from "../internal";
2
2
  interface RegExpMeta extends Meta {
3
3
  isInCharSet: boolean;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { StateDefinition, Meta } from "../internal";
1
+ import { type StateDefinition, type Meta } from "../internal";
2
2
  interface StringMeta extends Meta {
3
3
  quoteCharCode: number;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { CODE, StateDefinition, Ranges, Meta } from "../internal";
1
+ import { CODE, type StateDefinition, type Ranges, type Meta } from "../internal";
2
2
  export interface TagNameMeta extends Meta, Ranges.Template {
3
3
  shorthandCode: -1 | CODE.NUMBER_SIGN | CODE.PERIOD;
4
4
  }
@@ -1,2 +1,2 @@
1
- import { StateDefinition } from "../internal";
1
+ import { type StateDefinition } from "../internal";
2
2
  export declare const TEMPLATE_STRING: StateDefinition;
@@ -23,7 +23,6 @@ export declare const enum CODE {
23
23
  CLOSE_CURLY_BRACE = 125,
24
24
  ASTERISK = 42,
25
25
  HYPHEN = 45,
26
- HTML_BLOCK_DELIMITER = 45,
27
26
  DOLLAR = 36,
28
27
  PERCENT = 37,
29
28
  PERIOD = 46,
@@ -1,5 +1,5 @@
1
1
  import { type Parser } from "../internal";
2
- import { Location, Position } from "./constants";
2
+ import { type Location, type Position } from "./constants";
3
3
  export declare function isWhitespaceCode(code: number): boolean;
4
4
  /**
5
5
  * Given a source code line offsets, a start offset and an end offset, returns a Location object with line & character information for the start and end offsets.
package/package.json CHANGED
@@ -1,31 +1,33 @@
1
1
  {
2
2
  "name": "htmljs-parser",
3
3
  "description": "An HTML parser recognizes content and string placeholders and allows JavaScript expressions as attribute values",
4
- "version": "5.5.0",
4
+ "version": "5.5.2",
5
5
  "devDependencies": {
6
- "@changesets/changelog-github": "^0.4.7",
7
- "@changesets/cli": "^2.25.2",
8
- "@types/degit": "^2.8.3",
9
- "@types/mocha": "^10.0.0",
10
- "@types/node": "^18.11.9",
11
- "@typescript-eslint/eslint-plugin": "^5.42.0",
12
- "@typescript-eslint/parser": "^5.42.0",
6
+ "@changesets/changelog-github": "^0.5.0",
7
+ "@changesets/cli": "^2.27.1",
8
+ "@types/degit": "^2.8.6",
9
+ "@types/mocha": "^10.0.6",
10
+ "@types/node": "^20.10.6",
11
+ "@typescript-eslint/eslint-plugin": "^6.17.0",
12
+ "@typescript-eslint/parser": "^6.17.0",
13
13
  "cross-env": "^7.0.3",
14
14
  "degit": "^2.8.4",
15
- "esbuild": "0.15.13",
16
- "eslint": "^8.26.0",
17
- "eslint-config-prettier": "^8.5.0",
18
- "fast-glob": "^3.2.12",
15
+ "esbuild": "0.19.11",
16
+ "eslint": "^8.56.0",
17
+ "eslint-config-prettier": "^9.1.0",
18
+ "eslint-import-resolver-typescript": "^3.6.1",
19
+ "eslint-plugin-import": "^2.29.1",
20
+ "fast-glob": "^3.3.2",
19
21
  "fixpack": "^4.0.0",
20
- "husky": "^8.0.1",
21
- "lint-staged": "^13.0.3",
22
+ "husky": "^8.0.3",
23
+ "lint-staged": "^15.2.0",
22
24
  "mitata": "^0.1.6",
23
- "mocha": "^10.1.0",
24
- "mocha-snap": "^4.3.0",
25
+ "mocha": "^10.2.0",
26
+ "mocha-snap": "^5.0.0",
25
27
  "nyc": "^15.1.0",
26
- "prettier": "^2.7.1",
27
- "tsx": "^3.11.0",
28
- "typescript": "^4.8.4"
28
+ "prettier": "^3.1.1",
29
+ "tsx": "^4.7.0",
30
+ "typescript": "^5.3.3"
29
31
  },
30
32
  "exports": {
31
33
  ".": {