htmljs-parser 3.1.0 → 3.2.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 { StateDefinition, BODY_MODE, OpenTagEnding, Ranges, Meta } from "../internal";
1
+ import { StateDefinition, Ranges, Meta, TagType } from "../internal";
2
2
  declare const enum TAG_STAGE {
3
3
  UNKNOWN = 0,
4
4
  VAR = 1,
@@ -7,7 +7,7 @@ declare const enum TAG_STAGE {
7
7
  ATTR_GROUP = 4
8
8
  }
9
9
  export interface OpenTagMeta extends Meta {
10
- bodyMode: BODY_MODE;
10
+ type: TagType;
11
11
  stage: TAG_STAGE;
12
12
  concise: boolean;
13
13
  beginMixedMode?: boolean;
@@ -16,7 +16,7 @@ export interface OpenTagMeta extends Meta {
16
16
  hasArgs: boolean;
17
17
  hasAttrs: boolean;
18
18
  hasShorthandId: boolean;
19
- ending: OpenTagEnding;
19
+ selfClosed: boolean;
20
20
  indent: string;
21
21
  nestedIndent: string | undefined;
22
22
  parentTag: OpenTagMeta | undefined;
@@ -37,10 +37,6 @@ export declare const enum CODE {
37
37
  SPACE = 32,
38
38
  TAB = 9
39
39
  }
40
- export declare const enum BODY_MODE {
41
- HTML = 0,
42
- PARSED_TEXT = 1
43
- }
44
40
  export interface Position {
45
41
  /**
46
42
  * Line position in a document (zero-based).
@@ -74,7 +70,7 @@ export declare namespace Ranges {
74
70
  quasis: Range[];
75
71
  }
76
72
  interface Error extends Range {
77
- code: string;
73
+ code: ErrorCode;
78
74
  message: string;
79
75
  }
80
76
  interface Scriptlet extends Value {
@@ -94,28 +90,56 @@ export declare namespace Ranges {
94
90
  params: Value;
95
91
  }
96
92
  interface OpenTagEnd extends Range {
97
- ending: OpenTagEnding;
93
+ selfClosed: boolean;
98
94
  }
99
95
  interface CloseTag extends Range {
100
96
  value: Range | undefined;
101
97
  }
102
98
  }
103
- export declare const enum OpenTagEnding {
104
- tag = 0,
105
- self = 1,
99
+ export declare enum ErrorCode {
100
+ EXTRA_CLOSING_TAG = 0,
101
+ INVALID_ATTRIBUTE_ARGUMENT = 1,
102
+ INVALID_ATTRIBUTE_NAME = 2,
103
+ INVALID_ATTRIBUTE_VALUE = 3,
104
+ INVALID_CHARACTER = 4,
105
+ INVALID_CODE_AFTER_SEMICOLON = 5,
106
+ INVALID_EXPRESSION = 6,
107
+ INVALID_INDENTATION = 7,
108
+ INVALID_LINE_START = 8,
109
+ INVALID_REGULAR_EXPRESSION = 9,
110
+ INVALID_STRING = 10,
111
+ INVALID_TAG_ARGUMENT = 11,
112
+ INVALID_TAG_SHORTHAND = 12,
113
+ INVALID_TEMPLATE_STRING = 13,
114
+ MALFORMED_CDATA = 14,
115
+ MALFORMED_CLOSE_TAG = 15,
116
+ MALFORMED_COMMENT = 16,
117
+ MALFORMED_DECLARATION = 17,
118
+ MALFORMED_DOCUMENT_TYPE = 18,
119
+ MALFORMED_OPEN_TAG = 19,
120
+ MALFORMED_PLACEHOLDER = 20,
121
+ MISMATCHED_CLOSING_TAG = 21,
122
+ MISSING_END_TAG = 22,
123
+ MISSING_TAG_VARIABLE = 23,
124
+ RESERVED_TAG_NAME = 24,
125
+ ROOT_TAG_ONLY = 25
126
+ }
127
+ export declare const enum TagType {
128
+ html = 0,
129
+ text = 1,
106
130
  void = 2,
107
- code = 4
131
+ statement = 3
108
132
  }
109
- export interface Handlers {
133
+ export interface ParserOptions {
110
134
  onError?(data: Ranges.Error): void;
111
135
  onText?(data: Range): void;
136
+ onPlaceholder?(data: Ranges.Placeholder): void;
112
137
  onComment?(data: Ranges.Value): void;
113
138
  onCDATA?(data: Ranges.Value): void;
114
139
  onDeclaration?(data: Ranges.Value): void;
115
140
  onDoctype?(data: Ranges.Value): void;
116
141
  onScriptlet?(data: Ranges.Scriptlet): void;
117
- onPlaceholder?(data: Ranges.Placeholder): void;
118
- onTagName?(data: Ranges.TagName): void;
142
+ onTagName?(data: Ranges.TagName): TagType | void;
119
143
  onTagShorthandId?(data: Ranges.Template): void;
120
144
  onTagShorthandClass?(data: Ranges.Template): void;
121
145
  onTagVar?(data: Ranges.Value): void;
@@ -1,5 +1,5 @@
1
1
  import { type Parser } from "../internal";
2
- import type { Location, Position, Range } from "./constants";
2
+ import { Location, Position, Range } from "./constants";
3
3
  export declare function isWhitespaceCode(code: number): boolean;
4
4
  export declare function getLoc(lines: number[], range: Range): Location;
5
5
  export declare function getPos(lines: number[], startLine: number, index: number): Position;
package/package.json CHANGED
@@ -1,7 +1,7 @@
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": "3.1.0",
4
+ "version": "3.2.2",
5
5
  "author": "Phillip Gates-Idem <phillip.idem@gmail.com>",
6
6
  "devDependencies": {
7
7
  "@commitlint/cli": "^16.2.3",
@@ -63,7 +63,7 @@
63
63
  "scripts": {
64
64
  "bench": "npm run build && node -r esbuild-register ./src/__tests__/bench",
65
65
  "build": "tsc -b && node -r esbuild-register build",
66
- "ci:test": "nyc npm run mocha -- --forbid-pending --forbid-only",
66
+ "ci:test": "nyc npm run mocha -- --forbid-only",
67
67
  "format": "npm run lint:eslint -- --fix && npm run lint:prettier -- --write && (fixpack || true)",
68
68
  "lint": "tsc -b && npm run lint:eslint && npm run lint:prettier -- -l && fixpack",
69
69
  "lint:eslint": "eslint -f visualstudio .",