@azerothjs/compiler 0.3.0-alpha.3 → 0.4.0-beta.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.
@@ -0,0 +1,209 @@
1
+ // Orchestrates the transform of a `.azeroth` module:
2
+ //
3
+ // 1. Walk the source, skipping non-code, to find each top-level markup
4
+ // region (scanner.findMarkupStart).
5
+ // 2. Parse the region into a markup AST (parser.parseMarkup).
6
+ // 3. Generate h() / component-call code (codegen.generate), recompiling any
7
+ // nested markup inside `{ ... }` holes by calling back into the hole
8
+ // transform.
9
+ // 4. Splice the generated code in place of the region; everything else
10
+ // (imports, types, functions) is left byte-for-byte.
11
+ //
12
+ // Finally, if markup was emitted and the module doesn't already import `h`,
13
+ // prepend the import.
14
+ import { findMarkupStart } from "./scanner.js";
15
+ import { parseMarkup } from "./parser.js";
16
+ import { generate, walkComponentTags } from "./codegen.js";
17
+ import { buildLineStarts, locationFor, encodeMappings } from "./sourcemap.js";
18
+ /** Default module the auto-injected imports point at. */
19
+ const RUNTIME_MODULE = '@azerothjs/core';
20
+ /**
21
+ * Built-in components that markup can use without importing - the compiler
22
+ * injects their import from the runtime. User components are not
23
+ * auto-imported (the author imports those explicitly).
24
+ */
25
+ const BUILTIN_COMPONENTS = new Set([
26
+ 'Show', 'For', 'Switch', 'Match', 'Portal', 'Dynamic',
27
+ 'Suspense', 'ErrorBoundary', 'Transition', 'Outlet'
28
+ ]);
29
+ /**
30
+ * True when the module already imports `name` via a named import.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * alreadyImports("import { h, For } from 'x';", 'For'); // true
35
+ * alreadyImports("import { h } from 'x';", 'Show'); // false
36
+ * ```
37
+ */
38
+ function alreadyImports(source, name) {
39
+ return new RegExp(`import\\s*\\{[^}]*\\b${name}\\b[^}]*\\}\\s*from`).test(source);
40
+ }
41
+ /**
42
+ * Compiles a `.azeroth` source string: markup -> h() calls, with the `h`
43
+ * import auto-injected when needed.
44
+ *
45
+ * @param source - The `.azeroth` module source
46
+ *
47
+ * @returns The compiled JS/TS and its source map
48
+ *
49
+ * Without compile: author UI as nested h() calls by hand, wrapping every
50
+ * dynamic hole in a getter yourself:
51
+ *
52
+ * import { h } from '@azerothjs/core';
53
+ * export default () =>
54
+ * h('h1', { }, 'Hello ', () => (name())); // hand-write h() + getters, easy to get wrong
55
+ *
56
+ * With compile: write the markup in a `.azeroth` file and compile() emits the
57
+ * equivalent h() calls (and the `h` import) for you:
58
+ *
59
+ * const { code } = compile('export default () => <h1>Hello {name()}</h1>;');
60
+ * // code -> import { h } from '@azerothjs/core'; ... h('h1', { }, 'Hello ', () => (name()))
61
+ * // write JSX-like markup; the getters and the import are generated
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const { code } = compile(`
66
+ * export default function Hi() {
67
+ * return <h1>Hello {name()}</h1>;
68
+ * }
69
+ * `);
70
+ * // code becomes:
71
+ * // import { h } from '@azerothjs/core';
72
+ * // export default function Hi() {
73
+ * // return h('h1', { }, 'Hello ', () => (name()));
74
+ * // }
75
+ * ```
76
+ */
77
+ export function compile(source, filename = 'module.azeroth') {
78
+ // Built-in components referenced anywhere in the file's markup
79
+ // (including nested inside `{ ... }` holes, thanks to the recursion).
80
+ const usedBuiltins = new Set();
81
+ const collect = (node) => walkComponentTags(node, (tag) => {
82
+ if (BUILTIN_COMPONENTS.has(tag)) {
83
+ usedBuiltins.add(tag);
84
+ }
85
+ });
86
+ // String-based transform for `{ ... }` holes (nested markup). Holes are
87
+ // embedded inside a region's generated string, so they don't get their own
88
+ // source-map pieces - the whole region maps to its start, which is plenty
89
+ // for debugging.
90
+ const transformHole = (input) => {
91
+ let result = '';
92
+ let j = 0;
93
+ for (;;) {
94
+ const start = findMarkupStart(input, j);
95
+ if (start === -1) {
96
+ result += input.slice(j);
97
+ break;
98
+ }
99
+ result += input.slice(j, start);
100
+ const { node, end } = parseMarkup(input, start);
101
+ collect(node);
102
+ result += generate(node, transformHole);
103
+ j = end;
104
+ }
105
+ return result;
106
+ };
107
+ // Top-level assembly, tracking pieces for the source map.
108
+ const pieces = [];
109
+ let out = '';
110
+ const push = (text, sourceStart, verbatim) => {
111
+ pieces.push({ outStart: out.length, sourceStart, verbatim });
112
+ out += text;
113
+ };
114
+ let i = 0;
115
+ for (;;) {
116
+ const start = findMarkupStart(source, i);
117
+ if (start === -1) {
118
+ push(source.slice(i), i, true);
119
+ break;
120
+ }
121
+ if (start > i) {
122
+ push(source.slice(i, start), i, true);
123
+ }
124
+ const { node, end } = parseMarkup(source, start);
125
+ collect(node);
126
+ push(generate(node, transformHole), start, false);
127
+ i = end;
128
+ }
129
+ const hasMarkup = pieces.some(p => !p.verbatim);
130
+ if (!hasMarkup) {
131
+ return { code: out, map: null };
132
+ }
133
+ // Auto-inject `h` plus any built-in components the markup used,
134
+ // skipping names the source already imports.
135
+ const names = ['h', ...usedBuiltins].filter(name => !alreadyImports(source, name));
136
+ const prefix = names.length > 0
137
+ ? `import { ${names.join(', ')} } from '${RUNTIME_MODULE}';\n`
138
+ : '';
139
+ const code = prefix + out;
140
+ return { code, map: buildSourceMap(code, prefix.length, pieces, source, filename) };
141
+ }
142
+ /**
143
+ * Finds the piece whose span contains a given OUTPUT (post-`out`) offset.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * const pieces = [
148
+ * { outStart: 0, sourceStart: 0, verbatim: true },
149
+ * { outStart: 10, sourceStart: 10, verbatim: false }
150
+ * ];
151
+ * findPiece(pieces, 12); // the piece at outStart 10
152
+ * ```
153
+ */
154
+ function findPiece(pieces, outOffset) {
155
+ let lo = 0;
156
+ let hi = pieces.length - 1;
157
+ while (lo < hi) {
158
+ const mid = (lo + hi + 1) >> 1;
159
+ if (pieces[mid].outStart <= outOffset) {
160
+ lo = mid;
161
+ }
162
+ else {
163
+ hi = mid - 1;
164
+ }
165
+ }
166
+ return pieces[lo];
167
+ }
168
+ /**
169
+ * Builds a line-level source map: one segment per generated line.
170
+ * `prefixLen` accounts for the prepended import line(s), which map
171
+ * to the top of the source.
172
+ *
173
+ * @internal
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * const map = buildSourceMap(code, prefix.length, pieces, source, 'm.azeroth');
178
+ * map.version; // 3
179
+ * map.sources; // ['m.azeroth']
180
+ * map.mappings; // 'AAAA;AACA;...' (one segment per generated line)
181
+ * ```
182
+ */
183
+ function buildSourceMap(code, prefixLen, pieces, source, filename) {
184
+ const sourceLineStarts = buildLineStarts(source);
185
+ const codeLineStarts = buildLineStarts(code);
186
+ const lines = [];
187
+ for (const codeOffset of codeLineStarts) {
188
+ if (codeOffset < prefixLen) {
189
+ // The injected import line(s) map to the top of source.
190
+ lines.push([{ genColumn: 0, sourceLine: 0, sourceColumn: 0 }]);
191
+ continue;
192
+ }
193
+ const outOffset = codeOffset - prefixLen;
194
+ const piece = findPiece(pieces, outOffset);
195
+ const sourceOffset = piece.verbatim
196
+ ? piece.sourceStart + (outOffset - piece.outStart)
197
+ : piece.sourceStart;
198
+ const loc = locationFor(sourceOffset, sourceLineStarts);
199
+ lines.push([{ genColumn: 0, sourceLine: loc.line, sourceColumn: loc.column }]);
200
+ }
201
+ return {
202
+ version: 3,
203
+ sources: [filename],
204
+ sourcesContent: [source],
205
+ names: [],
206
+ mappings: encodeMappings(lines)
207
+ };
208
+ }
209
+ //# sourceMappingURL=compile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.js","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,yEAAyE;AACzE,yCAAyC;AACzC,gEAAgE;AAChE,8EAA8E;AAC9E,0EAA0E;AAC1E,kBAAkB;AAClB,yEAAyE;AACzE,0DAA0D;AAC1D,EAAE;AACF,4EAA4E;AAC5E,sBAAsB;AAEtB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAA2B,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AAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;IAED,OAAO;QACH,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC,QAAQ,CAAC;QACnB,cAAc,EAAE,CAAC,MAAM,CAAC;QACxB,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,cAAc,CAAC,KAAK,CAAC;KAClC,CAAC;AACN,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1 +1,8 @@
1
+ export { compile, type CompileResult } from './compile.ts';
2
+ export { CompileError, parseMarkup } from './parser.ts';
3
+ export { findMarkupStart, isWhitespace, isIdentStart, isIdentPart, skipBalanced, skipString, skipTemplate, skipLineComment, skipBlockComment, skipRegex } from './scanner.ts';
4
+ export { generate, walkComponentTags, type ExpressionCompiler } from './codegen.ts';
5
+ export { azeroth, type AzerothPluginOptions } from './vite.ts';
6
+ export { vlqEncode, buildLineStarts, locationFor, encodeMappings, type SourceMapV3, type RawSegment } from './sourcemap.ts';
7
+ export type { Span, MarkupElement, MarkupFragment, MarkupText, MarkupExpression, MarkupChild, MarkupAttribute, MarkupAttributeValue, MarkupRegion } from './types.ts';
1
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACH,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,SAAS,EACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EACH,SAAS,EACT,eAAe,EACf,WAAW,EACX,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,UAAU,EAClB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACR,IAAI,EACJ,aAAa,EACb,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,YAAY,EACf,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,17 +1,21 @@
1
- "use strict";
2
- // ============================================================================
3
- // AZEROTHJS — Compiler
4
- // ============================================================================
1
+ // @azerothjs/compiler
5
2
  //
6
- // Custom .azeroth file compiler built from scratch:
7
- // - Parser
8
- // - Template compiler
9
- // - Directives
10
- // - Scoped CSS
11
- // - Vite plugin
12
- // - HMR support
13
- // - Source maps
3
+ // Compiles `.azeroth` files - JS/TS modules written with AzerothJS markup (a
4
+ // JSX-style syntax) - into plain modules that call the runtime's h()
5
+ // hyperscript with fine-grained reactive bindings. For example
6
+ // `<h1>Count: {count()}</h1>` becomes `h('h1', {}, 'Count: ', () => (count()))`.
14
7
  //
15
- // STATUS: Phase 5
16
- // ============================================================================
8
+ // The pipeline, in the order it runs (and a good order to read it in):
9
+ // scanner - finds markup regions inside arbitrary JS, skipping
10
+ // strings/templates/comments/regex and detecting expression
11
+ // position
12
+ // parser - markup region -> AST
13
+ // codegen - AST -> h()/component-call source, with reactive wrapping
14
+ // compile - orchestrates scan -> parse -> codegen -> splice
15
+ export { compile } from "./compile.js";
16
+ export { CompileError, parseMarkup } from "./parser.js";
17
+ export { findMarkupStart, isWhitespace, isIdentStart, isIdentPart, skipBalanced, skipString, skipTemplate, skipLineComment, skipBlockComment, skipRegex } from "./scanner.js";
18
+ export { generate, walkComponentTags } from "./codegen.js";
19
+ export { azeroth } from "./vite.js";
20
+ export { vlqEncode, buildLineStarts, locationFor, encodeMappings } from "./sourcemap.js";
17
21
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAC/E,EAAE;AACF,oDAAoD;AACpD,aAAa;AACb,wBAAwB;AACxB,iBAAiB;AACjB,iBAAiB;AACjB,kBAAkB;AAClB,kBAAkB;AAClB,kBAAkB;AAClB,EAAE;AACF,kBAAkB;AAClB,+EAA+E"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,EAAE;AACF,6EAA6E;AAC7E,qEAAqE;AACrE,+DAA+D;AAC/D,iFAAiF;AACjF,EAAE;AACF,uEAAuE;AACvE,kEAAkE;AAClE,yEAAyE;AACzE,wBAAwB;AACxB,oCAAoC;AACpC,wEAAwE;AACxE,+DAA+D;AAE/D,OAAO,EAAE,OAAO,EAAsB,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACH,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,SAAS,EACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAA2B,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,OAAO,EAA6B,MAAM,WAAW,CAAC;AAC/D,OAAO,EACH,SAAS,EACT,eAAe,EACf,WAAW,EACX,cAAc,EAGjB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { MarkupElement, MarkupFragment } from './types.ts';
2
+ /**
3
+ * Thrown when the markup is malformed. Carries the source offset.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * try
8
+ * {
9
+ * parseMarkup('<a></b>', 0); // mismatched closing tag
10
+ * }
11
+ * catch (err)
12
+ * {
13
+ * if (err instanceof CompileError) console.log(err.offset); // source index of the error
14
+ * }
15
+ * ```
16
+ */
17
+ export declare class CompileError extends Error {
18
+ readonly offset: number;
19
+ constructor(message: string, offset: number);
20
+ }
21
+ /**
22
+ * Parses the markup element/fragment beginning at `start` (the `<`). Returns
23
+ * the AST node and the offset just after it.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const { node, end } = parseMarkup('<h1>Hi</h1>', 0);
28
+ * node.kind; // 'element'
29
+ * node.tag; // 'h1'
30
+ * end; // 11 (offset just past '</h1>')
31
+ * ```
32
+ */
33
+ export declare function parseMarkup(src: string, start: number): {
34
+ node: MarkupElement | MarkupFragment;
35
+ end: number;
36
+ };
37
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACR,aAAa,EACb,cAAc,EAIjB,MAAM,YAAY,CAAC;AASpB;;;;;;;;;;;;;;GAcG;AACH,qBAAa,YAAa,SAAQ,KAAK;aAEU,MAAM,EAAE,MAAM;gBAA/C,OAAO,EAAE,MAAM,EAAkB,MAAM,EAAE,MAAM;CAK9D;AAgXD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,aAAa,GAAG,cAAc,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAK7G"}
package/dist/parser.js ADDED
@@ -0,0 +1,318 @@
1
+ // Parses one markup region (an element or fragment) starting at a `<` into the
2
+ // AST from types.ts. Expression holes (`{ ... }`) and attribute expressions
3
+ // are captured as raw source - nested markup inside them is handled later by
4
+ // codegen, which recursively compiles the hole text. That keeps the parser
5
+ // focused purely on markup structure.
6
+ import { isIdentStart, isIdentPart, isWhitespace, skipBalanced, skipString } from "./scanner.js";
7
+ /**
8
+ * Thrown when the markup is malformed. Carries the source offset.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * try
13
+ * {
14
+ * parseMarkup('<a></b>', 0); // mismatched closing tag
15
+ * }
16
+ * catch (err)
17
+ * {
18
+ * if (err instanceof CompileError) console.log(err.offset); // source index of the error
19
+ * }
20
+ * ```
21
+ */
22
+ export class CompileError extends Error {
23
+ offset;
24
+ constructor(message, offset) {
25
+ super(message);
26
+ this.offset = offset;
27
+ this.name = 'CompileError';
28
+ }
29
+ }
30
+ class MarkupParser {
31
+ src;
32
+ pos;
33
+ constructor(src, pos) {
34
+ this.src = src;
35
+ this.pos = pos;
36
+ }
37
+ /** Entry point; `pos` must be at the opening `<`. */
38
+ parse() {
39
+ return this.parseElement();
40
+ }
41
+ peek(offset = 0) {
42
+ return this.src[this.pos + offset] ?? '';
43
+ }
44
+ skipWs() {
45
+ while (this.pos < this.src.length && isWhitespace(this.src[this.pos])) {
46
+ this.pos++;
47
+ }
48
+ }
49
+ expect(ch) {
50
+ if (this.peek() !== ch) {
51
+ throw new CompileError(`Expected '${ch}' but found '${this.peek() || 'EOF'}'`, this.pos);
52
+ }
53
+ this.pos++;
54
+ }
55
+ /** `pos` at `<`. Parses an element or `<>...</>` fragment. */
56
+ parseElement() {
57
+ const start = this.pos;
58
+ this.expect('<');
59
+ // Fragment: `<>`
60
+ if (this.peek() === '>') {
61
+ this.pos++; // past '>'
62
+ const children = this.parseChildren();
63
+ this.expectClosingTag(''); // </>
64
+ return { kind: 'fragment', children, start, end: this.pos };
65
+ }
66
+ // A `<` that is neither a fragment, a closing tag, nor the start of a
67
+ // tag name is a literal less-than in markup text - the single most
68
+ // common authoring mistake. Diagnose it where it sits instead of the
69
+ // opaque "Expected a tag name".
70
+ if (this.peek() !== '/' && !isIdentStart(this.peek())) {
71
+ throw new CompileError('Unexpected \'<\' in markup; write a literal \'<\' as {\'<\'} or &lt;', start);
72
+ }
73
+ const tag = this.readTagName();
74
+ const attributes = this.parseAttributes();
75
+ this.skipWs();
76
+ // Self-closing: `<tag ... />`
77
+ if (this.peek() === '/') {
78
+ this.pos++;
79
+ this.expect('>');
80
+ return {
81
+ kind: 'element',
82
+ tag,
83
+ isComponent: MarkupParser.isComponentTag(tag),
84
+ attributes,
85
+ children: [],
86
+ start,
87
+ end: this.pos
88
+ };
89
+ }
90
+ this.expect('>');
91
+ const children = this.parseChildren();
92
+ this.expectClosingTag(tag);
93
+ return {
94
+ kind: 'element',
95
+ tag,
96
+ isComponent: MarkupParser.isComponentTag(tag),
97
+ attributes,
98
+ children,
99
+ start,
100
+ end: this.pos
101
+ };
102
+ }
103
+ static isComponentTag(tag) {
104
+ return /[A-Z]/.test(tag[0] ?? '') || tag.includes('.');
105
+ }
106
+ /** Reads a tag name: identifiers plus `.` (`Foo.Bar`) and `-` (custom elements). */
107
+ readTagName() {
108
+ const start = this.pos;
109
+ if (!isIdentStart(this.peek())) {
110
+ throw new CompileError('Expected a tag name', this.pos);
111
+ }
112
+ this.pos++;
113
+ while (this.pos < this.src.length) {
114
+ const ch = this.src[this.pos];
115
+ if (isIdentPart(ch) || ch === '.' || ch === '-') {
116
+ this.pos++;
117
+ }
118
+ else {
119
+ break;
120
+ }
121
+ }
122
+ return this.src.slice(start, this.pos);
123
+ }
124
+ parseAttributes() {
125
+ const attrs = [];
126
+ for (;;) {
127
+ this.skipWs();
128
+ const ch = this.peek();
129
+ // End of the opening tag.
130
+ if (ch === '>' || ch === '/' || ch === '') {
131
+ break;
132
+ }
133
+ const attrStart = this.pos;
134
+ // Spread: `{...expr}`
135
+ if (ch === '{') {
136
+ const end = skipBalanced(this.src, this.pos);
137
+ const inner = this.src.slice(this.pos + 1, end - 1).trim();
138
+ this.pos = end;
139
+ const code = inner.startsWith('...') ? inner.slice(3).trim() : inner;
140
+ attrs.push({
141
+ kind: 'attribute',
142
+ name: null,
143
+ value: { kind: 'expression', code },
144
+ spread: true,
145
+ start: attrStart,
146
+ end
147
+ });
148
+ continue;
149
+ }
150
+ // Named attribute.
151
+ const name = this.readAttributeName();
152
+ this.skipWs();
153
+ if (this.peek() !== '=') {
154
+ // Bare attribute -> boolean true.
155
+ attrs.push({
156
+ kind: 'attribute',
157
+ name,
158
+ value: { kind: 'none' },
159
+ spread: false,
160
+ start: attrStart,
161
+ end: this.pos
162
+ });
163
+ continue;
164
+ }
165
+ this.pos++; // past '='
166
+ this.skipWs();
167
+ const valueChar = this.peek();
168
+ if (valueChar === '{') {
169
+ const end = skipBalanced(this.src, this.pos);
170
+ const code = this.src.slice(this.pos + 1, end - 1).trim();
171
+ this.pos = end;
172
+ attrs.push({
173
+ kind: 'attribute',
174
+ name,
175
+ value: { kind: 'expression', code },
176
+ spread: false,
177
+ start: attrStart,
178
+ end
179
+ });
180
+ }
181
+ else if (valueChar === '"' || valueChar === '\'') {
182
+ const end = skipString(this.src, this.pos);
183
+ const value = this.src.slice(this.pos + 1, end - 1);
184
+ this.pos = end;
185
+ attrs.push({
186
+ kind: 'attribute',
187
+ name,
188
+ value: { kind: 'static', value },
189
+ spread: false,
190
+ start: attrStart,
191
+ end
192
+ });
193
+ }
194
+ else {
195
+ throw new CompileError(`Expected a value for attribute '${name}'`, this.pos);
196
+ }
197
+ }
198
+ return attrs;
199
+ }
200
+ /** Attribute names: identifiers plus `-` and `:` (`data-x`, `aria-label`). */
201
+ readAttributeName() {
202
+ const start = this.pos;
203
+ while (this.pos < this.src.length) {
204
+ const ch = this.src[this.pos];
205
+ if (isIdentPart(ch) || ch === '-' || ch === ':') {
206
+ this.pos++;
207
+ }
208
+ else {
209
+ break;
210
+ }
211
+ }
212
+ if (this.pos === start) {
213
+ throw new CompileError('Expected an attribute name', this.pos);
214
+ }
215
+ return this.src.slice(start, this.pos);
216
+ }
217
+ parseChildren() {
218
+ const children = [];
219
+ while (this.pos < this.src.length) {
220
+ // Closing tag -> stop.
221
+ if (this.peek() === '<' && this.peek(1) === '/') {
222
+ break;
223
+ }
224
+ if (this.peek() === '<') {
225
+ children.push(this.parseElement());
226
+ continue;
227
+ }
228
+ if (this.peek() === '{') {
229
+ const start = this.pos;
230
+ const end = skipBalanced(this.src, this.pos);
231
+ const code = this.src.slice(this.pos + 1, end - 1);
232
+ this.pos = end;
233
+ // Drop comment-only / empty holes (e.g. `{/* note */}`).
234
+ if (!MarkupParser.isEmptyExpression(code)) {
235
+ children.push({ kind: 'expression', code, start, end });
236
+ }
237
+ continue;
238
+ }
239
+ const text = this.readText();
240
+ if (text) {
241
+ children.push(text);
242
+ }
243
+ }
244
+ return children;
245
+ }
246
+ /** Reads raw text up to the next `<` or `{`, normalised JSX-style. */
247
+ readText() {
248
+ const start = this.pos;
249
+ while (this.pos < this.src.length && this.peek() !== '<' && this.peek() !== '{') {
250
+ this.pos++;
251
+ }
252
+ const raw = this.src.slice(start, this.pos);
253
+ // A `//` at the head of a text child is almost always a misplaced line
254
+ // comment (JSX/markup has no `//` comments; only `{/* ... */}`). A real
255
+ // URL never trips this: its scheme (`https:`) precedes the `//`. Point
256
+ // at the `//` rather than letting it render as literal text.
257
+ const lead = raw.length - raw.trimStart().length;
258
+ if (raw.slice(lead).startsWith('//')) {
259
+ throw new CompileError('Line comments (//) are not allowed in markup; use {/* ... */} instead', start + lead);
260
+ }
261
+ const value = MarkupParser.normalizeText(raw);
262
+ if (value === '') {
263
+ return null;
264
+ }
265
+ return { kind: 'text', value, start, end: this.pos };
266
+ }
267
+ /**
268
+ * JSX-style whitespace handling: collapse runs that are purely formatting
269
+ * (whitespace containing a newline) to a single space, and preserve
270
+ * meaningful same-line spacing like `Count: `.
271
+ */
272
+ static normalizeText(raw) {
273
+ if (/^\s*$/.test(raw)) {
274
+ return '';
275
+ }
276
+ return raw.replace(/\s*\n\s*/g, ' ');
277
+ }
278
+ /** True when a `{ ... }` hole has no actual expression (only comments/space). */
279
+ static isEmptyExpression(code) {
280
+ const stripped = code
281
+ .replace(/\/\*[\s\S]*?\*\//g, '')
282
+ .replace(/\/\/[^\n]*/g, '')
283
+ .trim();
284
+ return stripped === '';
285
+ }
286
+ /** Consumes `</tag>` (or `</>` when `tag === ''`). */
287
+ expectClosingTag(tag) {
288
+ this.expect('<');
289
+ this.expect('/');
290
+ this.skipWs();
291
+ if (tag !== '') {
292
+ const closing = this.readTagName();
293
+ if (closing !== tag) {
294
+ throw new CompileError(`Mismatched closing tag: expected </${tag}> but found </${closing}>`, this.pos);
295
+ }
296
+ }
297
+ this.skipWs();
298
+ this.expect('>');
299
+ }
300
+ }
301
+ /**
302
+ * Parses the markup element/fragment beginning at `start` (the `<`). Returns
303
+ * the AST node and the offset just after it.
304
+ *
305
+ * @example
306
+ * ```ts
307
+ * const { node, end } = parseMarkup('<h1>Hi</h1>', 0);
308
+ * node.kind; // 'element'
309
+ * node.tag; // 'h1'
310
+ * end; // 11 (offset just past '</h1>')
311
+ * ```
312
+ */
313
+ export function parseMarkup(src, start) {
314
+ const parser = new MarkupParser(src, start);
315
+ const node = parser.parse();
316
+ return { node, end: parser.pos };
317
+ }
318
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,4EAA4E;AAC5E,6EAA6E;AAC7E,2EAA2E;AAC3E,sCAAsC;AAStC,OAAO,EACH,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACb,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAEU;IAA7C,YAAY,OAAe,EAAkB,MAAc;QAEvD,KAAK,CAAC,OAAO,CAAC,CAAC;QAF0B,WAAM,GAAN,MAAM,CAAQ;QAGvD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC/B,CAAC;CACJ;AAED,MAAM,YAAY;IA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