@fluixi/template-parser 0.1.0-alpha.4 → 1.0.0-alpha.100
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/LICENSE +1 -1
- package/dist/a11y.cjs +100 -1
- package/dist/a11y.d.cts +21 -0
- package/dist/a11y.d.ts +2 -2
- package/dist/a11y.js +1 -1
- package/dist/a11y.mjs +79 -1
- package/dist/ast.cjs +46 -1
- package/dist/ast.d.cts +223 -0
- package/dist/ast.d.ts +9 -9
- package/dist/ast.d.ts.map +1 -1
- package/dist/ast.js +2 -2
- package/dist/ast.mjs +25 -1
- package/dist/directives.cjs +206 -1
- package/dist/directives.d.cts +49 -0
- package/dist/directives.d.ts +2 -2
- package/dist/directives.d.ts.map +1 -1
- package/dist/directives.js +2 -2
- package/dist/directives.mjs +185 -1
- package/dist/index.cjs +857 -1
- package/dist/index.d.cts +31 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +835 -1
- package/dist/parser.cjs +832 -1
- package/dist/parser.d.cts +27 -0
- package/dist/parser.d.ts +2 -2
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +0 -0
- package/dist/parser.mjs +809 -1
- package/dist/reader.cjs +122 -1
- package/dist/reader.d.cts +60 -0
- package/dist/reader.d.ts +2 -2
- package/dist/reader.mjs +101 -1
- package/dist/tags.cjs +77 -1
- package/dist/tags.d.cts +15 -0
- package/dist/tags.d.ts +1 -1
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +1 -1
- package/dist/tags.mjs +56 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +5 -4
package/dist/reader.cjs
CHANGED
|
@@ -1 +1,122 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/reader.ts
|
|
21
|
+
var reader_exports = {};
|
|
22
|
+
__export(reader_exports, {
|
|
23
|
+
Reader: () => Reader
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(reader_exports);
|
|
26
|
+
var Reader = class {
|
|
27
|
+
// offset within the current static piece
|
|
28
|
+
constructor(pieces) {
|
|
29
|
+
this.pieces = pieces;
|
|
30
|
+
this.pi = 0;
|
|
31
|
+
// current piece index
|
|
32
|
+
this.oi = 0;
|
|
33
|
+
this.normalize();
|
|
34
|
+
}
|
|
35
|
+
/** Skip fully-consumed static pieces so `current()` is live text or a hole. */
|
|
36
|
+
normalize() {
|
|
37
|
+
while (this.pi < this.pieces.length) {
|
|
38
|
+
const p = this.pieces[this.pi];
|
|
39
|
+
if (p.kind === "static" && this.oi >= p.text.length) {
|
|
40
|
+
this.pi++;
|
|
41
|
+
this.oi = 0;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
eof() {
|
|
48
|
+
return this.pi >= this.pieces.length;
|
|
49
|
+
}
|
|
50
|
+
/** Absolute source offset of the cursor. */
|
|
51
|
+
pos() {
|
|
52
|
+
if (this.eof()) {
|
|
53
|
+
const last = this.pieces[this.pieces.length - 1];
|
|
54
|
+
return last ? last.kind === "static" ? last.start + last.text.length : last.end : 0;
|
|
55
|
+
}
|
|
56
|
+
const p = this.pieces[this.pi];
|
|
57
|
+
return p.kind === "static" ? p.start + this.oi : p.start;
|
|
58
|
+
}
|
|
59
|
+
/** True when the cursor sits exactly on a hole marker. */
|
|
60
|
+
atHole() {
|
|
61
|
+
return !this.eof() && this.pieces[this.pi].kind === "hole";
|
|
62
|
+
}
|
|
63
|
+
/** True when advancing one char would land on a hole (e.g. the `<` in `<${Tag}`). */
|
|
64
|
+
holeFollows() {
|
|
65
|
+
if (this.eof()) return false;
|
|
66
|
+
const p = this.pieces[this.pi];
|
|
67
|
+
if (p.kind !== "static") return false;
|
|
68
|
+
if (this.oi + 1 < p.text.length) return false;
|
|
69
|
+
const next = this.pieces[this.pi + 1];
|
|
70
|
+
return next !== void 0 && next.kind === "hole";
|
|
71
|
+
}
|
|
72
|
+
/** Consume the hole at the cursor. Caller must have checked {@link atHole}. */
|
|
73
|
+
takeHole() {
|
|
74
|
+
const p = this.pieces[this.pi];
|
|
75
|
+
if (p.kind !== "hole") throw new Error("takeHole called off a hole");
|
|
76
|
+
this.pi++;
|
|
77
|
+
this.oi = 0;
|
|
78
|
+
this.normalize();
|
|
79
|
+
return { index: p.index, loc: { start: p.start, end: p.end } };
|
|
80
|
+
}
|
|
81
|
+
/** Char `k` ahead within the current static segment, or '' at a boundary/hole. */
|
|
82
|
+
peek(k = 0) {
|
|
83
|
+
if (this.eof()) return "";
|
|
84
|
+
const p = this.pieces[this.pi];
|
|
85
|
+
if (p.kind !== "static") return "";
|
|
86
|
+
return p.text[this.oi + k] ?? "";
|
|
87
|
+
}
|
|
88
|
+
/** Whether the current static segment starts with `s` at the cursor. */
|
|
89
|
+
startsWith(s) {
|
|
90
|
+
if (this.eof()) return false;
|
|
91
|
+
const p = this.pieces[this.pi];
|
|
92
|
+
if (p.kind !== "static") return false;
|
|
93
|
+
return p.text.startsWith(s, this.oi);
|
|
94
|
+
}
|
|
95
|
+
/** Advance one character inside the current static segment. */
|
|
96
|
+
advance() {
|
|
97
|
+
if (this.eof()) return "";
|
|
98
|
+
const p = this.pieces[this.pi];
|
|
99
|
+
if (p.kind !== "static") return "";
|
|
100
|
+
const ch = p.text[this.oi++] ?? "";
|
|
101
|
+
this.normalize();
|
|
102
|
+
return ch;
|
|
103
|
+
}
|
|
104
|
+
/** Advance while `pred` holds and we stay inside one static segment. */
|
|
105
|
+
readWhile(pred) {
|
|
106
|
+
let out = "";
|
|
107
|
+
while (!this.eof() && !this.atHole()) {
|
|
108
|
+
const ch = this.peek();
|
|
109
|
+
if (ch === "" || !pred(ch)) break;
|
|
110
|
+
out += ch;
|
|
111
|
+
this.oi++;
|
|
112
|
+
}
|
|
113
|
+
this.normalize();
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
skipWhitespace() {
|
|
117
|
+
this.readWhile((ch) => /\s/.test(ch));
|
|
118
|
+
}
|
|
119
|
+
span(start) {
|
|
120
|
+
return { start, end: this.pos() };
|
|
121
|
+
}
|
|
122
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lexing layer: a hole-aware cursor over the template's pieces.
|
|
3
|
+
*
|
|
4
|
+
* HTML-template lexing is mode-dependent: data text, tag soup, attribute
|
|
5
|
+
* values, raw-text bodies and comments each lex by different rules, and a
|
|
6
|
+
* `${…}` hole can land in the middle of any of them (`class="a ${x} b"`). A
|
|
7
|
+
* single flat token array can't model that, so instead of pre-tokenizing we
|
|
8
|
+
* expose hole-aware primitives the parser drives per mode. This is the
|
|
9
|
+
* "tokenizer" in the classic sense: it owns character reads and hole
|
|
10
|
+
* recognition; the parser owns structure.
|
|
11
|
+
*
|
|
12
|
+
* Input is a PIECE LIST rather than a stitched string: alternating static text
|
|
13
|
+
* segments and atomic hole markers, each carrying its ABSOLUTE source offset.
|
|
14
|
+
* That means every span the reader reports maps straight back to the original
|
|
15
|
+
* file: no cooked-vs-raw length drift, no `\x00` sentinels. Structural
|
|
16
|
+
* delimiters (`<`, `</`, `<!--`, `-->`, `/>`, `=`, quotes) are always contiguous
|
|
17
|
+
* in source, so they never straddle a hole; within-segment peeking is enough.
|
|
18
|
+
*/
|
|
19
|
+
import type { SourceSpan } from './ast.cjs';
|
|
20
|
+
export type Piece = {
|
|
21
|
+
kind: 'static';
|
|
22
|
+
text: string;
|
|
23
|
+
start: number;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'hole';
|
|
26
|
+
index: number;
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
};
|
|
30
|
+
export interface HoleToken {
|
|
31
|
+
index: number;
|
|
32
|
+
loc: SourceSpan;
|
|
33
|
+
}
|
|
34
|
+
export declare class Reader {
|
|
35
|
+
private pieces;
|
|
36
|
+
private pi;
|
|
37
|
+
private oi;
|
|
38
|
+
constructor(pieces: Piece[]);
|
|
39
|
+
/** Skip fully-consumed static pieces so `current()` is live text or a hole. */
|
|
40
|
+
private normalize;
|
|
41
|
+
eof(): boolean;
|
|
42
|
+
/** Absolute source offset of the cursor. */
|
|
43
|
+
pos(): number;
|
|
44
|
+
/** True when the cursor sits exactly on a hole marker. */
|
|
45
|
+
atHole(): boolean;
|
|
46
|
+
/** True when advancing one char would land on a hole (e.g. the `<` in `<${Tag}`). */
|
|
47
|
+
holeFollows(): boolean;
|
|
48
|
+
/** Consume the hole at the cursor. Caller must have checked {@link atHole}. */
|
|
49
|
+
takeHole(): HoleToken;
|
|
50
|
+
/** Char `k` ahead within the current static segment, or '' at a boundary/hole. */
|
|
51
|
+
peek(k?: number): string;
|
|
52
|
+
/** Whether the current static segment starts with `s` at the cursor. */
|
|
53
|
+
startsWith(s: string): boolean;
|
|
54
|
+
/** Advance one character inside the current static segment. */
|
|
55
|
+
advance(): string;
|
|
56
|
+
/** Advance while `pred` holds and we stay inside one static segment. */
|
|
57
|
+
readWhile(pred: (ch: string) => boolean): string;
|
|
58
|
+
skipWhitespace(): void;
|
|
59
|
+
span(start: number): SourceSpan;
|
|
60
|
+
}
|
package/dist/reader.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The lexing layer: a hole-aware cursor over the template's pieces.
|
|
3
3
|
*
|
|
4
|
-
* HTML-template lexing is mode-dependent
|
|
4
|
+
* HTML-template lexing is mode-dependent: data text, tag soup, attribute
|
|
5
5
|
* values, raw-text bodies and comments each lex by different rules, and a
|
|
6
6
|
* `${…}` hole can land in the middle of any of them (`class="a ${x} b"`). A
|
|
7
7
|
* single flat token array can't model that, so instead of pre-tokenizing we
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Input is a PIECE LIST rather than a stitched string: alternating static text
|
|
13
13
|
* segments and atomic hole markers, each carrying its ABSOLUTE source offset.
|
|
14
14
|
* That means every span the reader reports maps straight back to the original
|
|
15
|
-
* file
|
|
15
|
+
* file: no cooked-vs-raw length drift, no `\x00` sentinels. Structural
|
|
16
16
|
* delimiters (`<`, `</`, `<!--`, `-->`, `/>`, `=`, quotes) are always contiguous
|
|
17
17
|
* in source, so they never straddle a hole; within-segment peeking is enough.
|
|
18
18
|
*/
|
package/dist/reader.mjs
CHANGED
|
@@ -1 +1,101 @@
|
|
|
1
|
-
|
|
1
|
+
// src/reader.ts
|
|
2
|
+
var Reader = class {
|
|
3
|
+
// offset within the current static piece
|
|
4
|
+
constructor(pieces) {
|
|
5
|
+
this.pieces = pieces;
|
|
6
|
+
this.pi = 0;
|
|
7
|
+
// current piece index
|
|
8
|
+
this.oi = 0;
|
|
9
|
+
this.normalize();
|
|
10
|
+
}
|
|
11
|
+
/** Skip fully-consumed static pieces so `current()` is live text or a hole. */
|
|
12
|
+
normalize() {
|
|
13
|
+
while (this.pi < this.pieces.length) {
|
|
14
|
+
const p = this.pieces[this.pi];
|
|
15
|
+
if (p.kind === "static" && this.oi >= p.text.length) {
|
|
16
|
+
this.pi++;
|
|
17
|
+
this.oi = 0;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
eof() {
|
|
24
|
+
return this.pi >= this.pieces.length;
|
|
25
|
+
}
|
|
26
|
+
/** Absolute source offset of the cursor. */
|
|
27
|
+
pos() {
|
|
28
|
+
if (this.eof()) {
|
|
29
|
+
const last = this.pieces[this.pieces.length - 1];
|
|
30
|
+
return last ? last.kind === "static" ? last.start + last.text.length : last.end : 0;
|
|
31
|
+
}
|
|
32
|
+
const p = this.pieces[this.pi];
|
|
33
|
+
return p.kind === "static" ? p.start + this.oi : p.start;
|
|
34
|
+
}
|
|
35
|
+
/** True when the cursor sits exactly on a hole marker. */
|
|
36
|
+
atHole() {
|
|
37
|
+
return !this.eof() && this.pieces[this.pi].kind === "hole";
|
|
38
|
+
}
|
|
39
|
+
/** True when advancing one char would land on a hole (e.g. the `<` in `<${Tag}`). */
|
|
40
|
+
holeFollows() {
|
|
41
|
+
if (this.eof()) return false;
|
|
42
|
+
const p = this.pieces[this.pi];
|
|
43
|
+
if (p.kind !== "static") return false;
|
|
44
|
+
if (this.oi + 1 < p.text.length) return false;
|
|
45
|
+
const next = this.pieces[this.pi + 1];
|
|
46
|
+
return next !== void 0 && next.kind === "hole";
|
|
47
|
+
}
|
|
48
|
+
/** Consume the hole at the cursor. Caller must have checked {@link atHole}. */
|
|
49
|
+
takeHole() {
|
|
50
|
+
const p = this.pieces[this.pi];
|
|
51
|
+
if (p.kind !== "hole") throw new Error("takeHole called off a hole");
|
|
52
|
+
this.pi++;
|
|
53
|
+
this.oi = 0;
|
|
54
|
+
this.normalize();
|
|
55
|
+
return { index: p.index, loc: { start: p.start, end: p.end } };
|
|
56
|
+
}
|
|
57
|
+
/** Char `k` ahead within the current static segment, or '' at a boundary/hole. */
|
|
58
|
+
peek(k = 0) {
|
|
59
|
+
if (this.eof()) return "";
|
|
60
|
+
const p = this.pieces[this.pi];
|
|
61
|
+
if (p.kind !== "static") return "";
|
|
62
|
+
return p.text[this.oi + k] ?? "";
|
|
63
|
+
}
|
|
64
|
+
/** Whether the current static segment starts with `s` at the cursor. */
|
|
65
|
+
startsWith(s) {
|
|
66
|
+
if (this.eof()) return false;
|
|
67
|
+
const p = this.pieces[this.pi];
|
|
68
|
+
if (p.kind !== "static") return false;
|
|
69
|
+
return p.text.startsWith(s, this.oi);
|
|
70
|
+
}
|
|
71
|
+
/** Advance one character inside the current static segment. */
|
|
72
|
+
advance() {
|
|
73
|
+
if (this.eof()) return "";
|
|
74
|
+
const p = this.pieces[this.pi];
|
|
75
|
+
if (p.kind !== "static") return "";
|
|
76
|
+
const ch = p.text[this.oi++] ?? "";
|
|
77
|
+
this.normalize();
|
|
78
|
+
return ch;
|
|
79
|
+
}
|
|
80
|
+
/** Advance while `pred` holds and we stay inside one static segment. */
|
|
81
|
+
readWhile(pred) {
|
|
82
|
+
let out = "";
|
|
83
|
+
while (!this.eof() && !this.atHole()) {
|
|
84
|
+
const ch = this.peek();
|
|
85
|
+
if (ch === "" || !pred(ch)) break;
|
|
86
|
+
out += ch;
|
|
87
|
+
this.oi++;
|
|
88
|
+
}
|
|
89
|
+
this.normalize();
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
skipWhitespace() {
|
|
93
|
+
this.readWhile((ch) => /\s/.test(ch));
|
|
94
|
+
}
|
|
95
|
+
span(start) {
|
|
96
|
+
return { start, end: this.pos() };
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
export {
|
|
100
|
+
Reader
|
|
101
|
+
};
|
package/dist/tags.cjs
CHANGED
|
@@ -1 +1,77 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/tags.ts
|
|
21
|
+
var tags_exports = {};
|
|
22
|
+
__export(tags_exports, {
|
|
23
|
+
DELEGATED_EVENTS: () => DELEGATED_EVENTS,
|
|
24
|
+
RAW_TEXT_ELEMENTS: () => RAW_TEXT_ELEMENTS,
|
|
25
|
+
SVG_TAGS: () => SVG_TAGS,
|
|
26
|
+
VOID_ELEMENTS: () => VOID_ELEMENTS,
|
|
27
|
+
isComponentTag: () => isComponentTag
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(tags_exports);
|
|
30
|
+
var SVG_TAGS = /* @__PURE__ */ new Set([
|
|
31
|
+
"svg",
|
|
32
|
+
"path",
|
|
33
|
+
"circle",
|
|
34
|
+
"rect",
|
|
35
|
+
"line",
|
|
36
|
+
"polygon",
|
|
37
|
+
"polyline",
|
|
38
|
+
"ellipse",
|
|
39
|
+
"g",
|
|
40
|
+
"defs",
|
|
41
|
+
"clipPath",
|
|
42
|
+
"text"
|
|
43
|
+
]);
|
|
44
|
+
var RAW_TEXT_ELEMENTS = /* @__PURE__ */ new Set(["script", "style", "textarea", "title"]);
|
|
45
|
+
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
46
|
+
"area",
|
|
47
|
+
"base",
|
|
48
|
+
"br",
|
|
49
|
+
"col",
|
|
50
|
+
"embed",
|
|
51
|
+
"hr",
|
|
52
|
+
"img",
|
|
53
|
+
"input",
|
|
54
|
+
"link",
|
|
55
|
+
"meta",
|
|
56
|
+
"param",
|
|
57
|
+
"source",
|
|
58
|
+
"track",
|
|
59
|
+
"wbr"
|
|
60
|
+
]);
|
|
61
|
+
var DELEGATED_EVENTS = /* @__PURE__ */ new Set([
|
|
62
|
+
"click",
|
|
63
|
+
"dblclick",
|
|
64
|
+
"input",
|
|
65
|
+
"change",
|
|
66
|
+
"submit",
|
|
67
|
+
"focus",
|
|
68
|
+
"blur",
|
|
69
|
+
"keydown",
|
|
70
|
+
"keyup",
|
|
71
|
+
"keypress",
|
|
72
|
+
"mousedown",
|
|
73
|
+
"mouseup"
|
|
74
|
+
]);
|
|
75
|
+
function isComponentTag(tag) {
|
|
76
|
+
return tag.length > 0 && (tag[0] !== tag[0].toLowerCase() || tag.includes("."));
|
|
77
|
+
}
|
package/dist/tags.d.cts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Tag/name classification tables. Kept free of any host (Babel/TS) types. */
|
|
2
|
+
/**
|
|
3
|
+
* Tags placed in the SVG namespace by name in an `` html`` `` template. An
|
|
4
|
+
* `` svg`` `` root puts its whole subtree in SVG regardless. Kept identical to
|
|
5
|
+
* the compiler's `SVG_TAGS` so lowering stays byte-identical.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SVG_TAGS: Set<string>;
|
|
8
|
+
/** Elements whose content is text, not markup: don't descend into `<` inside. */
|
|
9
|
+
export declare const RAW_TEXT_ELEMENTS: Set<string>;
|
|
10
|
+
/** Void elements: no children, no close tag (`<input>`, `<br>`, …). */
|
|
11
|
+
export declare const VOID_ELEMENTS: Set<string>;
|
|
12
|
+
/** Events wired through the delegated listener (matches the compiler set). */
|
|
13
|
+
export declare const DELEGATED_EVENTS: Set<string>;
|
|
14
|
+
/** A tag is a component when capitalized or a member path (`Ctx.Provider`). */
|
|
15
|
+
export declare function isComponentTag(tag: string): boolean;
|
package/dist/tags.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* the compiler's `SVG_TAGS` so lowering stays byte-identical.
|
|
6
6
|
*/
|
|
7
7
|
export declare const SVG_TAGS: Set<string>;
|
|
8
|
-
/** Elements whose content is text, not markup
|
|
8
|
+
/** Elements whose content is text, not markup: don't descend into `<` inside. */
|
|
9
9
|
export declare const RAW_TEXT_ELEMENTS: Set<string>;
|
|
10
10
|
/** Void elements: no children, no close tag (`<input>`, `<br>`, …). */
|
|
11
11
|
export declare const VOID_ELEMENTS: Set<string>;
|
package/dist/tags.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E;;;;GAIG;AACH,eAAO,MAAM,QAAQ,aAGnB,CAAC;AAEH,
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E;;;;GAIG;AACH,eAAO,MAAM,QAAQ,aAGnB,CAAC;AAEH,iFAAiF;AACjF,eAAO,MAAM,iBAAiB,aAAoD,CAAC;AAEnF,uEAAuE;AACvE,eAAO,MAAM,aAAa,aAGxB,CAAC;AAEH,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,aAG3B,CAAC;AAEH,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEnD"}
|
package/dist/tags.js
CHANGED
|
@@ -8,7 +8,7 @@ export const SVG_TAGS = new Set([
|
|
|
8
8
|
'svg', 'path', 'circle', 'rect', 'line', 'polygon', 'polyline',
|
|
9
9
|
'ellipse', 'g', 'defs', 'clipPath', 'text',
|
|
10
10
|
]);
|
|
11
|
-
/** Elements whose content is text, not markup
|
|
11
|
+
/** Elements whose content is text, not markup: don't descend into `<` inside. */
|
|
12
12
|
export const RAW_TEXT_ELEMENTS = new Set(['script', 'style', 'textarea', 'title']);
|
|
13
13
|
/** Void elements: no children, no close tag (`<input>`, `<br>`, …). */
|
|
14
14
|
export const VOID_ELEMENTS = new Set([
|
package/dist/tags.mjs
CHANGED
|
@@ -1 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
// src/tags.ts
|
|
2
|
+
var SVG_TAGS = /* @__PURE__ */ new Set([
|
|
3
|
+
"svg",
|
|
4
|
+
"path",
|
|
5
|
+
"circle",
|
|
6
|
+
"rect",
|
|
7
|
+
"line",
|
|
8
|
+
"polygon",
|
|
9
|
+
"polyline",
|
|
10
|
+
"ellipse",
|
|
11
|
+
"g",
|
|
12
|
+
"defs",
|
|
13
|
+
"clipPath",
|
|
14
|
+
"text"
|
|
15
|
+
]);
|
|
16
|
+
var RAW_TEXT_ELEMENTS = /* @__PURE__ */ new Set(["script", "style", "textarea", "title"]);
|
|
17
|
+
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
18
|
+
"area",
|
|
19
|
+
"base",
|
|
20
|
+
"br",
|
|
21
|
+
"col",
|
|
22
|
+
"embed",
|
|
23
|
+
"hr",
|
|
24
|
+
"img",
|
|
25
|
+
"input",
|
|
26
|
+
"link",
|
|
27
|
+
"meta",
|
|
28
|
+
"param",
|
|
29
|
+
"source",
|
|
30
|
+
"track",
|
|
31
|
+
"wbr"
|
|
32
|
+
]);
|
|
33
|
+
var DELEGATED_EVENTS = /* @__PURE__ */ new Set([
|
|
34
|
+
"click",
|
|
35
|
+
"dblclick",
|
|
36
|
+
"input",
|
|
37
|
+
"change",
|
|
38
|
+
"submit",
|
|
39
|
+
"focus",
|
|
40
|
+
"blur",
|
|
41
|
+
"keydown",
|
|
42
|
+
"keyup",
|
|
43
|
+
"keypress",
|
|
44
|
+
"mousedown",
|
|
45
|
+
"mouseup"
|
|
46
|
+
]);
|
|
47
|
+
function isComponentTag(tag) {
|
|
48
|
+
return tag.length > 0 && (tag[0] !== tag[0].toLowerCase() || tag.includes("."));
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
DELEGATED_EVENTS,
|
|
52
|
+
RAW_TEXT_ELEMENTS,
|
|
53
|
+
SVG_TAGS,
|
|
54
|
+
VOID_ELEMENTS,
|
|
55
|
+
isComponentTag
|
|
56
|
+
};
|