@fluixi/template-parser 0.1.0-alpha.1

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/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var k=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var W=(t,e)=>{for(var i in e)k(t,i,{get:e[i],enumerable:!0})},H=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of R(e))!P.call(t,n)&&n!==i&&k(t,n,{get:()=>e[n],enumerable:!(r=B(e,n))||r.enumerable});return t};var w=t=>H(k({},"__esModule",{value:!0}),t);var L={};W(L,{CORE_DIRECTIVES:()=>m,Reader:()=>u,childrenOf:()=>b,parse:()=>I,parseTemplate:()=>v,piecesFromStrings:()=>A,resolveAttribute:()=>f,setParents:()=>N});module.exports=w(L);function N(t){let e=(i,r)=>{i.parent=r;let n=b(i);for(let s of n)e(s,i)};return e(t,null),t}function b(t){switch(t.kind){case"Root":case"Element":case"Component":case"Fragment":return t.children;default:return[]}}var u=class{constructor(e){this.pieces=e;this.pi=0;this.oi=0;this.normalize()}normalize(){for(;this.pi<this.pieces.length;){let e=this.pieces[this.pi];if(e.kind==="static"&&this.oi>=e.text.length){this.pi++,this.oi=0;continue}break}}eof(){return this.pi>=this.pieces.length}pos(){if(this.eof()){let i=this.pieces[this.pieces.length-1];return i?i.kind==="static"?i.start+i.text.length:i.end:0}let e=this.pieces[this.pi];return e.kind==="static"?e.start+this.oi:e.start}atHole(){return!this.eof()&&this.pieces[this.pi].kind==="hole"}holeFollows(){if(this.eof())return!1;let e=this.pieces[this.pi];if(e.kind!=="static"||this.oi+1<e.text.length)return!1;let i=this.pieces[this.pi+1];return i!==void 0&&i.kind==="hole"}takeHole(){let e=this.pieces[this.pi];if(e.kind!=="hole")throw new Error("takeHole called off a hole");return this.pi++,this.oi=0,this.normalize(),{index:e.index,loc:{start:e.start,end:e.end}}}peek(e=0){if(this.eof())return"";let i=this.pieces[this.pi];return i.kind!=="static"?"":i.text[this.oi+e]??""}startsWith(e){if(this.eof())return!1;let i=this.pieces[this.pi];return i.kind!=="static"?!1:i.text.startsWith(e,this.oi)}advance(){if(this.eof())return"";let e=this.pieces[this.pi];if(e.kind!=="static")return"";let i=e.text[this.oi++]??"";return this.normalize(),i}readWhile(e){let i="";for(;!this.eof()&&!this.atHole();){let r=this.peek();if(r===""||!e(r))break;i+=r,this.oi++}return this.normalize(),i}skipWhitespace(){this.readWhile(e=>/\s/.test(e))}span(e){return{start:e,end:this.pos()}}};var y=new Set(["capture","once","passive","prevent","stop","self"]);function p(t,e){return t.value&&t.value.kind==="hole"?t.value.hole:(t.report("invalid-binding",`${e} requires an expression value: ${t.name}=\${…}`),-1)}var D=(t,e)=>({kind:"Attribute",name:e?t.name.slice(1):t.name,value:t.value,boolean:e,loc:t.loc}),m=[{id:"event",match:t=>t[0]==="@"||t.startsWith("on:")||/^on[A-Z]/.test(t),build:t=>{let e,i;t.name[0]==="@"?(e="at",i=t.name.slice(1)):t.name.startsWith("on:")?(e="colon",i=t.name.slice(3)):(e="on",i=t.name.slice(2));let[r,...n]=i.split(".");for(let s of n)y.has(s)||t.report("invalid-directive",`Unknown event modifier ".${s}" — expected one of ${[...y].join(", ")}`);return{kind:"EventBinding",name:r,syntax:e,modifiers:n,hole:p(t,"event binding"),loc:t.loc}}},{id:"bind",elementOnly:!0,match:t=>t.startsWith("bind:"),build:t=>({kind:"BindDirective",name:t.name.slice(5),hole:p(t,"two-way binding"),loc:t.loc})},{id:"class-directive",elementOnly:!0,match:t=>t.startsWith("class:"),build:t=>({kind:"ClassDirective",name:t.name.slice(6),hole:p(t,"class directive"),loc:t.loc})},{id:"style-directive",elementOnly:!0,match:t=>t.startsWith("style:"),build:t=>({kind:"StyleDirective",name:t.name.slice(6),hole:p(t,"style directive"),loc:t.loc})},{id:"use",match:t=>t==="use"||t.startsWith("use:"),build:t=>({kind:"UseDirective",name:t.name.startsWith("use:")?t.name.slice(4):null,hole:t.value&&t.value.kind==="hole"?t.value.hole:null,loc:t.loc})},{id:"if",elementOnly:!0,match:t=>t==="if",build:t=>({kind:"IfDirective",hole:p(t,"if directive"),loc:t.loc})},{id:"each",elementOnly:!0,match:t=>t==="each",build:t=>({kind:"EachDirective",hole:p(t,"each directive"),key:null,loc:t.loc})},{id:"else",elementOnly:!0,match:t=>t==="else",build:t=>(t.value!==null&&t.report("invalid-directive","`else` takes no value"),{kind:"ElseDirective",loc:t.loc})},{id:"ref",match:t=>t==="ref",build:t=>({kind:"RefBinding",hole:p(t,"ref binding"),loc:t.loc})},{id:"property",match:t=>t[0]===".",build:t=>({kind:"PropertyBinding",name:t.name.slice(1),hole:p(t,"property binding"),loc:t.loc})},{id:"boolean",match:t=>t[0]==="?",build:t=>D(t,!0)}];function f(t,e=m,i={component:!1}){for(let r of e)if(!(r.elementOnly&&i.component)&&r.match(t.name))return r.build(t);return D(t,!1)}var E=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),S=new Set(["script","style","textarea","title"]),C=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function T(t){return t.length>0&&(t[0]!==t[0].toLowerCase()||t.includes("."))}var V=/[A-Za-z0-9\-_:@.?]/,x=class{constructor(e,i){this.diagnostics=[];this.r=new u(e),this.svg=i.svg??!1,this.directives=i.directives??m}parse(){let e=this.r.pos(),i=[];for(;!this.r.eof()&&(i.push(...this.parseChildren()),!this.r.eof());){let n=this.r.pos();this.consumeCloseTag(),this.report("stray-close-tag","error","Close tag without a matching open tag",this.r.span(n))}let r={kind:"Root",children:i,loc:this.r.span(e)};return N(r),this.validateTree(r),{root:r,diagnostics:this.diagnostics}}validateTree(e){let i=r=>{let n=null;for(let s of r)s.kind==="Text"&&/^\s*$/.test(s.value)||(s.kind==="Element"||s.kind==="Component"?(s.attributes.some(l=>l.kind==="ElseDirective")&&(n!=null&&(n.kind==="Element"||n.kind==="Component")&&n.attributes.some(o=>o.kind==="IfDirective")||this.report("else-without-if","error","`else` must immediately follow an element with `if`",s.loc)),n=s):n=null,"children"in s&&s.children&&i(s.children))};i(e.children)}parseChildren(){let e=[];for(;!this.r.eof()&&!this.r.startsWith("</");){if(this.r.startsWith("<!--")){e.push(this.parseComment());continue}if(this.isFragmentStart()){e.push(this.parseFragment());continue}if(this.isDynamicTagStart()){e.push(this.parseDynamicComponent());continue}if(this.isTagStart()){e.push(this.parseElement());continue}if(this.r.atHole()){let r=this.r.takeHole(),n={kind:"Expression",hole:r.index,loc:r.loc};e.push(n);continue}let i=this.readText();i&&e.push(i)}return e}isTagStart(){return this.r.peek()==="<"&&/[A-Za-z]/.test(this.r.peek(1))}isFragmentStart(){return this.r.peek()==="<"&&this.r.peek(1)===">"}isDynamicTagStart(){return this.r.peek()==="<"&&this.r.holeFollows()}parseDynamicComponent(){let e=this.r.pos();this.r.advance();let i=this.r.takeHole().index,r=this.parseAttributes(!0);this.r.skipWhitespace();let n=!1,s=[];return this.r.startsWith("/>")?(this.r.advance(),this.r.advance(),n=!0):(this.r.peek()===">"&&this.r.advance(),s=this.parseChildren(),this.r.startsWith("</")?(this.r.advance(),this.r.advance(),this.r.atHole()?this.r.takeHole():this.readName(),this.r.skipWhitespace(),this.r.peek()===">"&&this.r.advance()):this.report("unclosed-tag","error","Unclosed dynamic component",this.r.span(e))),{kind:"Component",tag:"",tagHole:i,attributes:r,children:s,selfClosing:n,loc:this.r.span(e)}}readText(){let e=this.r.pos(),i="";for(;!this.r.eof()&&!this.r.atHole()&&!(this.r.startsWith("</")||this.r.startsWith("<!--")||this.isTagStart()||this.isFragmentStart()||this.isDynamicTagStart());)i+=this.r.advance();return i?{kind:"Text",value:i,raw:!1,loc:this.r.span(e)}:null}parseComment(){let e=this.r.pos();this.r.advance(),this.r.advance(),this.r.advance(),this.r.advance();let i="";for(;!this.r.eof()&&!this.r.startsWith("-->");){if(this.r.atHole()){this.r.takeHole(),i+="\0";continue}i+=this.r.advance()}return this.r.startsWith("-->")?(this.r.advance(),this.r.advance(),this.r.advance()):this.report("unclosed-comment","warning","Unterminated comment",this.r.span(e)),{kind:"Comment",value:i,loc:this.r.span(e)}}parseFragment(){let e=this.r.pos();this.r.advance(),this.r.advance();let i=this.parseChildren();if(this.r.startsWith("</")){let r=this.consumeCloseTag();r&&this.report("mismatched-close-tag","error",`Expected </> to close fragment, got </${r}>`,this.r.span(e))}else this.report("unclosed-tag","error","Unterminated fragment",this.r.span(e));return{kind:"Fragment",children:i,loc:this.r.span(e)}}parseElement(){let e=this.r.pos();this.r.advance();let i=this.readName(),r=T(i),n=this.parseAttributes(r);this.foldEachKey(n,e),this.r.skipWhitespace();let s=i.toLowerCase(),a=!r&&S.has(s),l=!r&&C.has(s),o=!1,c=[];if(this.r.startsWith("/>"))this.r.advance(),this.r.advance(),o=!0;else if(this.r.peek()===">"&&this.r.advance(),!l)if(c=a?this.parseRawText(i):this.parseChildren(),this.r.startsWith("</")){let g=this.consumeCloseTag();g&&g!==i&&this.report("mismatched-close-tag","error",`Expected </${i}>, got </${g}>`,this.r.span(e))}else this.report("unclosed-tag","error",`Unclosed <${i}>`,this.r.span(e));let h=this.r.span(e);if(r)return{kind:"Component",tag:i,tagHole:null,attributes:n,children:c,selfClosing:o,loc:h};let d=this.svg||E.has(i)?"svg":"html";return{kind:"Element",tag:i,namespace:d,attributes:n,children:c,selfClosing:o,rawText:a,loc:h}}parseRawText(e){let i=[],r="</"+e.toLowerCase(),n="",s=this.r.pos(),a=()=>{n&&i.push({kind:"Text",value:n,raw:!0,loc:this.r.span(s)}),n=""};for(;!this.r.eof()&&!this.startsWithCloseFor(r);){if(this.r.atHole()){a();let l=this.r.takeHole();i.push({kind:"Expression",hole:l.index,loc:l.loc}),s=this.r.pos();continue}n||(s=this.r.pos()),n+=this.r.advance()}return a(),i}startsWithCloseFor(e){let i=0;for(;i<e.length;){let r=this.r.peek(i);if(r===""||r.toLowerCase()!==e[i])return!1;i++}return!0}parseAttributes(e){let i=[];for(;!this.r.eof()&&(this.r.skipWhitespace(),!(this.r.peek()===">"||this.r.startsWith("/>")));){if(this.r.atHole()){let o=this.r.takeHole();i.push({kind:"Spread",hole:o.index,loc:o.loc});continue}if(this.r.startsWith("...")){let o=this.r.pos();if(this.r.advance(),this.r.advance(),this.r.advance(),this.r.atHole()){let c=this.r.takeHole();i.push({kind:"Spread",hole:c.index,loc:this.r.span(o)})}else this.report("invalid-binding","error","Spread `...` must be followed by ${…}",this.r.span(o));continue}let r=this.r.pos(),n=this.readName();if(!n){this.r.advance();continue}let s=this.r.span(r);this.r.skipWhitespace();let a=null;this.r.peek()==="="&&(this.r.advance(),this.r.skipWhitespace(),a=this.parseAttrValue());let l={name:n,nameLoc:s,value:a,loc:this.r.span(r),report:(o,c)=>this.report(o,"error",c,this.r.span(r))};i.push(f(l,this.directives,{component:e}))}return i}parseAttrValue(){if(this.r.atHole())return{kind:"hole",hole:this.r.takeHole().index};let e=this.r.peek();return e==='"'||e==="'"?this.classifyParts(this.readQuotedParts(e)):{kind:"static",value:this.r.readWhile(r=>!/[\s>]/.test(r))}}readQuotedParts(e){this.r.advance();let i=[],r="";for(;!this.r.eof()&&this.r.peek()!==e;){if(this.r.atHole()){r&&(i.push({text:r}),r=""),i.push({hole:this.r.takeHole().index});continue}let n=this.r.advance();if(n==="")break;r+=n}return r&&i.push({text:r}),this.r.peek()===e&&this.r.advance(),i}classifyParts(e){let i=e.filter(r=>"hole"in r);return i.length===0?{kind:"static",value:e.map(r=>"text"in r?r.text:"").join("")}:e.length===1?{kind:"hole",hole:i[0].hole}:{kind:"mixed",parts:e}}foldEachKey(e,i){let r=null,n=0,s=0,a=0,l=0;for(let d of e)d.kind==="EachDirective"?(r=d,s++):d.kind==="IfDirective"?n++:d.kind==="ElseDirective"?a++:d.kind==="RefBinding"&&l++;let o=this.r.span(i);s>1&&this.report("duplicate-directive","error","Multiple `each` directives on one element",o),n>1&&this.report("duplicate-directive","error","Multiple `if` directives on one element",o),l>1&&this.report("duplicate-directive","error","Multiple `ref` bindings on one element",o),n>0&&s>0&&this.report("unsupported-combination","error","`if` and `each` cannot both apply to one element — wrap one in another element",o),n>0&&a>0&&this.report("invalid-directive","error","`if` and `else` cannot be on the same element",o);let c=e.findIndex(d=>d.kind==="Attribute"&&d.name==="key");if(!r){c!==-1&&this.report("invalid-directive","error","`key` requires an `each` directive on the same element",o);return}if(c===-1)return;let h=e[c];h.kind==="Attribute"&&h.value&&(h.value.kind==="static"?r.key={static:h.value.value}:h.value.kind==="hole"&&(r.key={hole:h.value.hole})),e.splice(c,1)}readName(){return this.r.readWhile(e=>V.test(e))}consumeCloseTag(){this.r.advance(),this.r.advance();let e=this.readName();return this.r.skipWhitespace(),this.r.peek()===">"&&this.r.advance(),e}report(e,i,r,n){this.diagnostics.push({code:e,severity:i,message:r,loc:n})}};function v(t,e={}){return new x(t,e).parse()}function A(t){let e=[],i=0;return t.forEach((r,n)=>{e.push({kind:"static",text:r,start:i}),i+=r.length,n<t.length-1&&e.push({kind:"hole",index:n,start:i,end:i})}),e}function I(t,e={}){return v(A(t),e)}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @fluixi/template-parser — the dependency-free foundation for every tool that
3
+ * needs to understand a Fluixi `` html`...` `` template: the compiler, the
4
+ * language server, the TypeScript plugin, and the Biome/formatter plugin.
5
+ *
6
+ * Pipeline: pieces → {@link Reader} (lexing/holes) → {@link parseTemplate}
7
+ * (structure + diagnostics) → Template AST. Downstream, each tool binds the
8
+ * opaque hole slots to its own representation and consumes the AST — the
9
+ * compiler lowers it to codegen IR, the LSP answers completion/hover/rename.
10
+ *
11
+ * The parser never resolves the JS inside `${…}`; it records each hole as an
12
+ * index + span. That is the single seam that keeps this package host-agnostic.
13
+ */
14
+ export * from './ast.js';
15
+ export { Reader, type Piece, type HoleToken } from './reader.js';
16
+ export { CORE_DIRECTIVES, resolveAttribute, type DirectiveDescriptor, type RawAttribute, } from './directives.js';
17
+ export { parseTemplate, type ParserOptions } from './parser.js';
18
+ import type { Piece } from './reader.js';
19
+ import { type ParserOptions } from './parser.js';
20
+ import type { ParseResult, SourceSpan } from './ast.js';
21
+ /**
22
+ * Build a piece list from the static string segments of a tagged template
23
+ * (`quasi.strings`), inserting a hole between each pair. Offsets are synthetic
24
+ * (cumulative over the joined text) — good enough for standalone parsing and
25
+ * tests. Hosts with real source positions (the compiler, the LSP) should build
26
+ * {@link Piece}s directly so spans map back to the original file.
27
+ */
28
+ export declare function piecesFromStrings(statics: readonly string[]): Piece[];
29
+ /** Convenience: parse directly from static string segments. */
30
+ export declare function parse(statics: readonly string[], opts?: ParserOptions): ParseResult;
31
+ export type { SourceSpan };
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,KAAK,mBAAmB,EACxB,KAAK,YAAY,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,EAAE,CAYrE;AAED,+DAA+D;AAC/D,wBAAgB,KAAK,CACnB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,IAAI,GAAE,aAAkB,GACvB,WAAW,CAEb;AAED,YAAY,EAAE,UAAU,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @fluixi/template-parser — the dependency-free foundation for every tool that
3
+ * needs to understand a Fluixi `` html`...` `` template: the compiler, the
4
+ * language server, the TypeScript plugin, and the Biome/formatter plugin.
5
+ *
6
+ * Pipeline: pieces → {@link Reader} (lexing/holes) → {@link parseTemplate}
7
+ * (structure + diagnostics) → Template AST. Downstream, each tool binds the
8
+ * opaque hole slots to its own representation and consumes the AST — the
9
+ * compiler lowers it to codegen IR, the LSP answers completion/hover/rename.
10
+ *
11
+ * The parser never resolves the JS inside `${…}`; it records each hole as an
12
+ * index + span. That is the single seam that keeps this package host-agnostic.
13
+ */
14
+ export * from './ast.js';
15
+ export { Reader } from './reader.js';
16
+ export { CORE_DIRECTIVES, resolveAttribute, } from './directives.js';
17
+ export { parseTemplate } from './parser.js';
18
+ import { parseTemplate } from './parser.js';
19
+ /**
20
+ * Build a piece list from the static string segments of a tagged template
21
+ * (`quasi.strings`), inserting a hole between each pair. Offsets are synthetic
22
+ * (cumulative over the joined text) — good enough for standalone parsing and
23
+ * tests. Hosts with real source positions (the compiler, the LSP) should build
24
+ * {@link Piece}s directly so spans map back to the original file.
25
+ */
26
+ export function piecesFromStrings(statics) {
27
+ const pieces = [];
28
+ let offset = 0;
29
+ statics.forEach((text, i) => {
30
+ pieces.push({ kind: 'static', text, start: offset });
31
+ offset += text.length;
32
+ if (i < statics.length - 1) {
33
+ // zero-width synthetic hole between segments
34
+ pieces.push({ kind: 'hole', index: i, start: offset, end: offset });
35
+ }
36
+ });
37
+ return pieces;
38
+ }
39
+ /** Convenience: parse directly from static string segments. */
40
+ export function parse(statics, opts = {}) {
41
+ return parseTemplate(piecesFromStrings(statics), opts);
42
+ }
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ function N(t){let e=(i,r)=>{i.parent=r;let n=C(i);for(let s of n)e(s,i)};return e(t,null),t}function C(t){switch(t.kind){case"Root":case"Element":case"Component":case"Fragment":return t.children;default:return[]}}var u=class{constructor(e){this.pieces=e;this.pi=0;this.oi=0;this.normalize()}normalize(){for(;this.pi<this.pieces.length;){let e=this.pieces[this.pi];if(e.kind==="static"&&this.oi>=e.text.length){this.pi++,this.oi=0;continue}break}}eof(){return this.pi>=this.pieces.length}pos(){if(this.eof()){let i=this.pieces[this.pieces.length-1];return i?i.kind==="static"?i.start+i.text.length:i.end:0}let e=this.pieces[this.pi];return e.kind==="static"?e.start+this.oi:e.start}atHole(){return!this.eof()&&this.pieces[this.pi].kind==="hole"}holeFollows(){if(this.eof())return!1;let e=this.pieces[this.pi];if(e.kind!=="static"||this.oi+1<e.text.length)return!1;let i=this.pieces[this.pi+1];return i!==void 0&&i.kind==="hole"}takeHole(){let e=this.pieces[this.pi];if(e.kind!=="hole")throw new Error("takeHole called off a hole");return this.pi++,this.oi=0,this.normalize(),{index:e.index,loc:{start:e.start,end:e.end}}}peek(e=0){if(this.eof())return"";let i=this.pieces[this.pi];return i.kind!=="static"?"":i.text[this.oi+e]??""}startsWith(e){if(this.eof())return!1;let i=this.pieces[this.pi];return i.kind!=="static"?!1:i.text.startsWith(e,this.oi)}advance(){if(this.eof())return"";let e=this.pieces[this.pi];if(e.kind!=="static")return"";let i=e.text[this.oi++]??"";return this.normalize(),i}readWhile(e){let i="";for(;!this.eof()&&!this.atHole();){let r=this.peek();if(r===""||!e(r))break;i+=r,this.oi++}return this.normalize(),i}skipWhitespace(){this.readWhile(e=>/\s/.test(e))}span(e){return{start:e,end:this.pos()}}};var x=new Set(["capture","once","passive","prevent","stop","self"]);function p(t,e){return t.value&&t.value.kind==="hole"?t.value.hole:(t.report("invalid-binding",`${e} requires an expression value: ${t.name}=\${…}`),-1)}var b=(t,e)=>({kind:"Attribute",name:e?t.name.slice(1):t.name,value:t.value,boolean:e,loc:t.loc}),m=[{id:"event",match:t=>t[0]==="@"||t.startsWith("on:")||/^on[A-Z]/.test(t),build:t=>{let e,i;t.name[0]==="@"?(e="at",i=t.name.slice(1)):t.name.startsWith("on:")?(e="colon",i=t.name.slice(3)):(e="on",i=t.name.slice(2));let[r,...n]=i.split(".");for(let s of n)x.has(s)||t.report("invalid-directive",`Unknown event modifier ".${s}" — expected one of ${[...x].join(", ")}`);return{kind:"EventBinding",name:r,syntax:e,modifiers:n,hole:p(t,"event binding"),loc:t.loc}}},{id:"bind",elementOnly:!0,match:t=>t.startsWith("bind:"),build:t=>({kind:"BindDirective",name:t.name.slice(5),hole:p(t,"two-way binding"),loc:t.loc})},{id:"class-directive",elementOnly:!0,match:t=>t.startsWith("class:"),build:t=>({kind:"ClassDirective",name:t.name.slice(6),hole:p(t,"class directive"),loc:t.loc})},{id:"style-directive",elementOnly:!0,match:t=>t.startsWith("style:"),build:t=>({kind:"StyleDirective",name:t.name.slice(6),hole:p(t,"style directive"),loc:t.loc})},{id:"use",match:t=>t==="use"||t.startsWith("use:"),build:t=>({kind:"UseDirective",name:t.name.startsWith("use:")?t.name.slice(4):null,hole:t.value&&t.value.kind==="hole"?t.value.hole:null,loc:t.loc})},{id:"if",elementOnly:!0,match:t=>t==="if",build:t=>({kind:"IfDirective",hole:p(t,"if directive"),loc:t.loc})},{id:"each",elementOnly:!0,match:t=>t==="each",build:t=>({kind:"EachDirective",hole:p(t,"each directive"),key:null,loc:t.loc})},{id:"else",elementOnly:!0,match:t=>t==="else",build:t=>(t.value!==null&&t.report("invalid-directive","`else` takes no value"),{kind:"ElseDirective",loc:t.loc})},{id:"ref",match:t=>t==="ref",build:t=>({kind:"RefBinding",hole:p(t,"ref binding"),loc:t.loc})},{id:"property",match:t=>t[0]===".",build:t=>({kind:"PropertyBinding",name:t.name.slice(1),hole:p(t,"property binding"),loc:t.loc})},{id:"boolean",match:t=>t[0]==="?",build:t=>b(t,!0)}];function v(t,e=m,i={component:!1}){for(let r of e)if(!(r.elementOnly&&i.component)&&r.match(t.name))return r.build(t);return b(t,!1)}var y=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),D=new Set(["script","style","textarea","title"]),E=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function S(t){return t.length>0&&(t[0]!==t[0].toLowerCase()||t.includes("."))}var T=/[A-Za-z0-9\-_:@.?]/,g=class{constructor(e,i){this.diagnostics=[];this.r=new u(e),this.svg=i.svg??!1,this.directives=i.directives??m}parse(){let e=this.r.pos(),i=[];for(;!this.r.eof()&&(i.push(...this.parseChildren()),!this.r.eof());){let n=this.r.pos();this.consumeCloseTag(),this.report("stray-close-tag","error","Close tag without a matching open tag",this.r.span(n))}let r={kind:"Root",children:i,loc:this.r.span(e)};return N(r),this.validateTree(r),{root:r,diagnostics:this.diagnostics}}validateTree(e){let i=r=>{let n=null;for(let s of r)s.kind==="Text"&&/^\s*$/.test(s.value)||(s.kind==="Element"||s.kind==="Component"?(s.attributes.some(l=>l.kind==="ElseDirective")&&(n!=null&&(n.kind==="Element"||n.kind==="Component")&&n.attributes.some(o=>o.kind==="IfDirective")||this.report("else-without-if","error","`else` must immediately follow an element with `if`",s.loc)),n=s):n=null,"children"in s&&s.children&&i(s.children))};i(e.children)}parseChildren(){let e=[];for(;!this.r.eof()&&!this.r.startsWith("</");){if(this.r.startsWith("<!--")){e.push(this.parseComment());continue}if(this.isFragmentStart()){e.push(this.parseFragment());continue}if(this.isDynamicTagStart()){e.push(this.parseDynamicComponent());continue}if(this.isTagStart()){e.push(this.parseElement());continue}if(this.r.atHole()){let r=this.r.takeHole(),n={kind:"Expression",hole:r.index,loc:r.loc};e.push(n);continue}let i=this.readText();i&&e.push(i)}return e}isTagStart(){return this.r.peek()==="<"&&/[A-Za-z]/.test(this.r.peek(1))}isFragmentStart(){return this.r.peek()==="<"&&this.r.peek(1)===">"}isDynamicTagStart(){return this.r.peek()==="<"&&this.r.holeFollows()}parseDynamicComponent(){let e=this.r.pos();this.r.advance();let i=this.r.takeHole().index,r=this.parseAttributes(!0);this.r.skipWhitespace();let n=!1,s=[];return this.r.startsWith("/>")?(this.r.advance(),this.r.advance(),n=!0):(this.r.peek()===">"&&this.r.advance(),s=this.parseChildren(),this.r.startsWith("</")?(this.r.advance(),this.r.advance(),this.r.atHole()?this.r.takeHole():this.readName(),this.r.skipWhitespace(),this.r.peek()===">"&&this.r.advance()):this.report("unclosed-tag","error","Unclosed dynamic component",this.r.span(e))),{kind:"Component",tag:"",tagHole:i,attributes:r,children:s,selfClosing:n,loc:this.r.span(e)}}readText(){let e=this.r.pos(),i="";for(;!this.r.eof()&&!this.r.atHole()&&!(this.r.startsWith("</")||this.r.startsWith("<!--")||this.isTagStart()||this.isFragmentStart()||this.isDynamicTagStart());)i+=this.r.advance();return i?{kind:"Text",value:i,raw:!1,loc:this.r.span(e)}:null}parseComment(){let e=this.r.pos();this.r.advance(),this.r.advance(),this.r.advance(),this.r.advance();let i="";for(;!this.r.eof()&&!this.r.startsWith("-->");){if(this.r.atHole()){this.r.takeHole(),i+="\0";continue}i+=this.r.advance()}return this.r.startsWith("-->")?(this.r.advance(),this.r.advance(),this.r.advance()):this.report("unclosed-comment","warning","Unterminated comment",this.r.span(e)),{kind:"Comment",value:i,loc:this.r.span(e)}}parseFragment(){let e=this.r.pos();this.r.advance(),this.r.advance();let i=this.parseChildren();if(this.r.startsWith("</")){let r=this.consumeCloseTag();r&&this.report("mismatched-close-tag","error",`Expected </> to close fragment, got </${r}>`,this.r.span(e))}else this.report("unclosed-tag","error","Unterminated fragment",this.r.span(e));return{kind:"Fragment",children:i,loc:this.r.span(e)}}parseElement(){let e=this.r.pos();this.r.advance();let i=this.readName(),r=S(i),n=this.parseAttributes(r);this.foldEachKey(n,e),this.r.skipWhitespace();let s=i.toLowerCase(),a=!r&&D.has(s),l=!r&&E.has(s),o=!1,c=[];if(this.r.startsWith("/>"))this.r.advance(),this.r.advance(),o=!0;else if(this.r.peek()===">"&&this.r.advance(),!l)if(c=a?this.parseRawText(i):this.parseChildren(),this.r.startsWith("</")){let f=this.consumeCloseTag();f&&f!==i&&this.report("mismatched-close-tag","error",`Expected </${i}>, got </${f}>`,this.r.span(e))}else this.report("unclosed-tag","error",`Unclosed <${i}>`,this.r.span(e));let h=this.r.span(e);if(r)return{kind:"Component",tag:i,tagHole:null,attributes:n,children:c,selfClosing:o,loc:h};let d=this.svg||y.has(i)?"svg":"html";return{kind:"Element",tag:i,namespace:d,attributes:n,children:c,selfClosing:o,rawText:a,loc:h}}parseRawText(e){let i=[],r="</"+e.toLowerCase(),n="",s=this.r.pos(),a=()=>{n&&i.push({kind:"Text",value:n,raw:!0,loc:this.r.span(s)}),n=""};for(;!this.r.eof()&&!this.startsWithCloseFor(r);){if(this.r.atHole()){a();let l=this.r.takeHole();i.push({kind:"Expression",hole:l.index,loc:l.loc}),s=this.r.pos();continue}n||(s=this.r.pos()),n+=this.r.advance()}return a(),i}startsWithCloseFor(e){let i=0;for(;i<e.length;){let r=this.r.peek(i);if(r===""||r.toLowerCase()!==e[i])return!1;i++}return!0}parseAttributes(e){let i=[];for(;!this.r.eof()&&(this.r.skipWhitespace(),!(this.r.peek()===">"||this.r.startsWith("/>")));){if(this.r.atHole()){let o=this.r.takeHole();i.push({kind:"Spread",hole:o.index,loc:o.loc});continue}if(this.r.startsWith("...")){let o=this.r.pos();if(this.r.advance(),this.r.advance(),this.r.advance(),this.r.atHole()){let c=this.r.takeHole();i.push({kind:"Spread",hole:c.index,loc:this.r.span(o)})}else this.report("invalid-binding","error","Spread `...` must be followed by ${…}",this.r.span(o));continue}let r=this.r.pos(),n=this.readName();if(!n){this.r.advance();continue}let s=this.r.span(r);this.r.skipWhitespace();let a=null;this.r.peek()==="="&&(this.r.advance(),this.r.skipWhitespace(),a=this.parseAttrValue());let l={name:n,nameLoc:s,value:a,loc:this.r.span(r),report:(o,c)=>this.report(o,"error",c,this.r.span(r))};i.push(v(l,this.directives,{component:e}))}return i}parseAttrValue(){if(this.r.atHole())return{kind:"hole",hole:this.r.takeHole().index};let e=this.r.peek();return e==='"'||e==="'"?this.classifyParts(this.readQuotedParts(e)):{kind:"static",value:this.r.readWhile(r=>!/[\s>]/.test(r))}}readQuotedParts(e){this.r.advance();let i=[],r="";for(;!this.r.eof()&&this.r.peek()!==e;){if(this.r.atHole()){r&&(i.push({text:r}),r=""),i.push({hole:this.r.takeHole().index});continue}let n=this.r.advance();if(n==="")break;r+=n}return r&&i.push({text:r}),this.r.peek()===e&&this.r.advance(),i}classifyParts(e){let i=e.filter(r=>"hole"in r);return i.length===0?{kind:"static",value:e.map(r=>"text"in r?r.text:"").join("")}:e.length===1?{kind:"hole",hole:i[0].hole}:{kind:"mixed",parts:e}}foldEachKey(e,i){let r=null,n=0,s=0,a=0,l=0;for(let d of e)d.kind==="EachDirective"?(r=d,s++):d.kind==="IfDirective"?n++:d.kind==="ElseDirective"?a++:d.kind==="RefBinding"&&l++;let o=this.r.span(i);s>1&&this.report("duplicate-directive","error","Multiple `each` directives on one element",o),n>1&&this.report("duplicate-directive","error","Multiple `if` directives on one element",o),l>1&&this.report("duplicate-directive","error","Multiple `ref` bindings on one element",o),n>0&&s>0&&this.report("unsupported-combination","error","`if` and `each` cannot both apply to one element — wrap one in another element",o),n>0&&a>0&&this.report("invalid-directive","error","`if` and `else` cannot be on the same element",o);let c=e.findIndex(d=>d.kind==="Attribute"&&d.name==="key");if(!r){c!==-1&&this.report("invalid-directive","error","`key` requires an `each` directive on the same element",o);return}if(c===-1)return;let h=e[c];h.kind==="Attribute"&&h.value&&(h.value.kind==="static"?r.key={static:h.value.value}:h.value.kind==="hole"&&(r.key={hole:h.value.hole})),e.splice(c,1)}readName(){return this.r.readWhile(e=>T.test(e))}consumeCloseTag(){this.r.advance(),this.r.advance();let e=this.readName();return this.r.skipWhitespace(),this.r.peek()===">"&&this.r.advance(),e}report(e,i,r,n){this.diagnostics.push({code:e,severity:i,message:r,loc:n})}};function k(t,e={}){return new g(t,e).parse()}function A(t){let e=[],i=0;return t.forEach((r,n)=>{e.push({kind:"static",text:r,start:i}),i+=r.length,n<t.length-1&&e.push({kind:"hole",index:n,start:i,end:i})}),e}function F(t,e={}){return k(A(t),e)}export{m as CORE_DIRECTIVES,u as Reader,C as childrenOf,F as parse,k as parseTemplate,A as piecesFromStrings,v as resolveAttribute,N as setParents};
@@ -0,0 +1 @@
1
+ "use strict";var v=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var i in e)v(t,i,{get:e[i],enumerable:!0})},R=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of T(e))!A.call(t,n)&&n!==i&&v(t,n,{get:()=>e[n],enumerable:!(r=S(e,n))||r.enumerable});return t};var W=t=>R(v({},"__esModule",{value:!0}),t);var V={};B(V,{parseTemplate:()=>w});module.exports=W(V);function k(t){let e=(i,r)=>{i.parent=r;let n=H(i);for(let s of n)e(s,i)};return e(t,null),t}function H(t){switch(t.kind){case"Root":case"Element":case"Component":case"Fragment":return t.children;default:return[]}}var u=class{constructor(e){this.pieces=e;this.pi=0;this.oi=0;this.normalize()}normalize(){for(;this.pi<this.pieces.length;){let e=this.pieces[this.pi];if(e.kind==="static"&&this.oi>=e.text.length){this.pi++,this.oi=0;continue}break}}eof(){return this.pi>=this.pieces.length}pos(){if(this.eof()){let i=this.pieces[this.pieces.length-1];return i?i.kind==="static"?i.start+i.text.length:i.end:0}let e=this.pieces[this.pi];return e.kind==="static"?e.start+this.oi:e.start}atHole(){return!this.eof()&&this.pieces[this.pi].kind==="hole"}holeFollows(){if(this.eof())return!1;let e=this.pieces[this.pi];if(e.kind!=="static"||this.oi+1<e.text.length)return!1;let i=this.pieces[this.pi+1];return i!==void 0&&i.kind==="hole"}takeHole(){let e=this.pieces[this.pi];if(e.kind!=="hole")throw new Error("takeHole called off a hole");return this.pi++,this.oi=0,this.normalize(),{index:e.index,loc:{start:e.start,end:e.end}}}peek(e=0){if(this.eof())return"";let i=this.pieces[this.pi];return i.kind!=="static"?"":i.text[this.oi+e]??""}startsWith(e){if(this.eof())return!1;let i=this.pieces[this.pi];return i.kind!=="static"?!1:i.text.startsWith(e,this.oi)}advance(){if(this.eof())return"";let e=this.pieces[this.pi];if(e.kind!=="static")return"";let i=e.text[this.oi++]??"";return this.normalize(),i}readWhile(e){let i="";for(;!this.eof()&&!this.atHole();){let r=this.peek();if(r===""||!e(r))break;i+=r,this.oi++}return this.normalize(),i}skipWhitespace(){this.readWhile(e=>/\s/.test(e))}span(e){return{start:e,end:this.pos()}}};var N=new Set(["capture","once","passive","prevent","stop","self"]);function p(t,e){return t.value&&t.value.kind==="hole"?t.value.hole:(t.report("invalid-binding",`${e} requires an expression value: ${t.name}=\${…}`),-1)}var x=(t,e)=>({kind:"Attribute",name:e?t.name.slice(1):t.name,value:t.value,boolean:e,loc:t.loc}),f=[{id:"event",match:t=>t[0]==="@"||t.startsWith("on:")||/^on[A-Z]/.test(t),build:t=>{let e,i;t.name[0]==="@"?(e="at",i=t.name.slice(1)):t.name.startsWith("on:")?(e="colon",i=t.name.slice(3)):(e="on",i=t.name.slice(2));let[r,...n]=i.split(".");for(let s of n)N.has(s)||t.report("invalid-directive",`Unknown event modifier ".${s}" — expected one of ${[...N].join(", ")}`);return{kind:"EventBinding",name:r,syntax:e,modifiers:n,hole:p(t,"event binding"),loc:t.loc}}},{id:"bind",elementOnly:!0,match:t=>t.startsWith("bind:"),build:t=>({kind:"BindDirective",name:t.name.slice(5),hole:p(t,"two-way binding"),loc:t.loc})},{id:"class-directive",elementOnly:!0,match:t=>t.startsWith("class:"),build:t=>({kind:"ClassDirective",name:t.name.slice(6),hole:p(t,"class directive"),loc:t.loc})},{id:"style-directive",elementOnly:!0,match:t=>t.startsWith("style:"),build:t=>({kind:"StyleDirective",name:t.name.slice(6),hole:p(t,"style directive"),loc:t.loc})},{id:"use",match:t=>t==="use"||t.startsWith("use:"),build:t=>({kind:"UseDirective",name:t.name.startsWith("use:")?t.name.slice(4):null,hole:t.value&&t.value.kind==="hole"?t.value.hole:null,loc:t.loc})},{id:"if",elementOnly:!0,match:t=>t==="if",build:t=>({kind:"IfDirective",hole:p(t,"if directive"),loc:t.loc})},{id:"each",elementOnly:!0,match:t=>t==="each",build:t=>({kind:"EachDirective",hole:p(t,"each directive"),key:null,loc:t.loc})},{id:"else",elementOnly:!0,match:t=>t==="else",build:t=>(t.value!==null&&t.report("invalid-directive","`else` takes no value"),{kind:"ElseDirective",loc:t.loc})},{id:"ref",match:t=>t==="ref",build:t=>({kind:"RefBinding",hole:p(t,"ref binding"),loc:t.loc})},{id:"property",match:t=>t[0]===".",build:t=>({kind:"PropertyBinding",name:t.name.slice(1),hole:p(t,"property binding"),loc:t.loc})},{id:"boolean",match:t=>t[0]==="?",build:t=>x(t,!0)}];function b(t,e=f,i={component:!1}){for(let r of e)if(!(r.elementOnly&&i.component)&&r.match(t.name))return r.build(t);return x(t,!1)}var y=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),D=new Set(["script","style","textarea","title"]),E=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function C(t){return t.length>0&&(t[0]!==t[0].toLowerCase()||t.includes("."))}var P=/[A-Za-z0-9\-_:@.?]/,g=class{constructor(e,i){this.diagnostics=[];this.r=new u(e),this.svg=i.svg??!1,this.directives=i.directives??f}parse(){let e=this.r.pos(),i=[];for(;!this.r.eof()&&(i.push(...this.parseChildren()),!this.r.eof());){let n=this.r.pos();this.consumeCloseTag(),this.report("stray-close-tag","error","Close tag without a matching open tag",this.r.span(n))}let r={kind:"Root",children:i,loc:this.r.span(e)};return k(r),this.validateTree(r),{root:r,diagnostics:this.diagnostics}}validateTree(e){let i=r=>{let n=null;for(let s of r)s.kind==="Text"&&/^\s*$/.test(s.value)||(s.kind==="Element"||s.kind==="Component"?(s.attributes.some(l=>l.kind==="ElseDirective")&&(n!=null&&(n.kind==="Element"||n.kind==="Component")&&n.attributes.some(o=>o.kind==="IfDirective")||this.report("else-without-if","error","`else` must immediately follow an element with `if`",s.loc)),n=s):n=null,"children"in s&&s.children&&i(s.children))};i(e.children)}parseChildren(){let e=[];for(;!this.r.eof()&&!this.r.startsWith("</");){if(this.r.startsWith("<!--")){e.push(this.parseComment());continue}if(this.isFragmentStart()){e.push(this.parseFragment());continue}if(this.isDynamicTagStart()){e.push(this.parseDynamicComponent());continue}if(this.isTagStart()){e.push(this.parseElement());continue}if(this.r.atHole()){let r=this.r.takeHole(),n={kind:"Expression",hole:r.index,loc:r.loc};e.push(n);continue}let i=this.readText();i&&e.push(i)}return e}isTagStart(){return this.r.peek()==="<"&&/[A-Za-z]/.test(this.r.peek(1))}isFragmentStart(){return this.r.peek()==="<"&&this.r.peek(1)===">"}isDynamicTagStart(){return this.r.peek()==="<"&&this.r.holeFollows()}parseDynamicComponent(){let e=this.r.pos();this.r.advance();let i=this.r.takeHole().index,r=this.parseAttributes(!0);this.r.skipWhitespace();let n=!1,s=[];return this.r.startsWith("/>")?(this.r.advance(),this.r.advance(),n=!0):(this.r.peek()===">"&&this.r.advance(),s=this.parseChildren(),this.r.startsWith("</")?(this.r.advance(),this.r.advance(),this.r.atHole()?this.r.takeHole():this.readName(),this.r.skipWhitespace(),this.r.peek()===">"&&this.r.advance()):this.report("unclosed-tag","error","Unclosed dynamic component",this.r.span(e))),{kind:"Component",tag:"",tagHole:i,attributes:r,children:s,selfClosing:n,loc:this.r.span(e)}}readText(){let e=this.r.pos(),i="";for(;!this.r.eof()&&!this.r.atHole()&&!(this.r.startsWith("</")||this.r.startsWith("<!--")||this.isTagStart()||this.isFragmentStart()||this.isDynamicTagStart());)i+=this.r.advance();return i?{kind:"Text",value:i,raw:!1,loc:this.r.span(e)}:null}parseComment(){let e=this.r.pos();this.r.advance(),this.r.advance(),this.r.advance(),this.r.advance();let i="";for(;!this.r.eof()&&!this.r.startsWith("-->");){if(this.r.atHole()){this.r.takeHole(),i+="\0";continue}i+=this.r.advance()}return this.r.startsWith("-->")?(this.r.advance(),this.r.advance(),this.r.advance()):this.report("unclosed-comment","warning","Unterminated comment",this.r.span(e)),{kind:"Comment",value:i,loc:this.r.span(e)}}parseFragment(){let e=this.r.pos();this.r.advance(),this.r.advance();let i=this.parseChildren();if(this.r.startsWith("</")){let r=this.consumeCloseTag();r&&this.report("mismatched-close-tag","error",`Expected </> to close fragment, got </${r}>`,this.r.span(e))}else this.report("unclosed-tag","error","Unterminated fragment",this.r.span(e));return{kind:"Fragment",children:i,loc:this.r.span(e)}}parseElement(){let e=this.r.pos();this.r.advance();let i=this.readName(),r=C(i),n=this.parseAttributes(r);this.foldEachKey(n,e),this.r.skipWhitespace();let s=i.toLowerCase(),a=!r&&D.has(s),l=!r&&E.has(s),o=!1,c=[];if(this.r.startsWith("/>"))this.r.advance(),this.r.advance(),o=!0;else if(this.r.peek()===">"&&this.r.advance(),!l)if(c=a?this.parseRawText(i):this.parseChildren(),this.r.startsWith("</")){let m=this.consumeCloseTag();m&&m!==i&&this.report("mismatched-close-tag","error",`Expected </${i}>, got </${m}>`,this.r.span(e))}else this.report("unclosed-tag","error",`Unclosed <${i}>`,this.r.span(e));let h=this.r.span(e);if(r)return{kind:"Component",tag:i,tagHole:null,attributes:n,children:c,selfClosing:o,loc:h};let d=this.svg||y.has(i)?"svg":"html";return{kind:"Element",tag:i,namespace:d,attributes:n,children:c,selfClosing:o,rawText:a,loc:h}}parseRawText(e){let i=[],r="</"+e.toLowerCase(),n="",s=this.r.pos(),a=()=>{n&&i.push({kind:"Text",value:n,raw:!0,loc:this.r.span(s)}),n=""};for(;!this.r.eof()&&!this.startsWithCloseFor(r);){if(this.r.atHole()){a();let l=this.r.takeHole();i.push({kind:"Expression",hole:l.index,loc:l.loc}),s=this.r.pos();continue}n||(s=this.r.pos()),n+=this.r.advance()}return a(),i}startsWithCloseFor(e){let i=0;for(;i<e.length;){let r=this.r.peek(i);if(r===""||r.toLowerCase()!==e[i])return!1;i++}return!0}parseAttributes(e){let i=[];for(;!this.r.eof()&&(this.r.skipWhitespace(),!(this.r.peek()===">"||this.r.startsWith("/>")));){if(this.r.atHole()){let o=this.r.takeHole();i.push({kind:"Spread",hole:o.index,loc:o.loc});continue}if(this.r.startsWith("...")){let o=this.r.pos();if(this.r.advance(),this.r.advance(),this.r.advance(),this.r.atHole()){let c=this.r.takeHole();i.push({kind:"Spread",hole:c.index,loc:this.r.span(o)})}else this.report("invalid-binding","error","Spread `...` must be followed by ${…}",this.r.span(o));continue}let r=this.r.pos(),n=this.readName();if(!n){this.r.advance();continue}let s=this.r.span(r);this.r.skipWhitespace();let a=null;this.r.peek()==="="&&(this.r.advance(),this.r.skipWhitespace(),a=this.parseAttrValue());let l={name:n,nameLoc:s,value:a,loc:this.r.span(r),report:(o,c)=>this.report(o,"error",c,this.r.span(r))};i.push(b(l,this.directives,{component:e}))}return i}parseAttrValue(){if(this.r.atHole())return{kind:"hole",hole:this.r.takeHole().index};let e=this.r.peek();return e==='"'||e==="'"?this.classifyParts(this.readQuotedParts(e)):{kind:"static",value:this.r.readWhile(r=>!/[\s>]/.test(r))}}readQuotedParts(e){this.r.advance();let i=[],r="";for(;!this.r.eof()&&this.r.peek()!==e;){if(this.r.atHole()){r&&(i.push({text:r}),r=""),i.push({hole:this.r.takeHole().index});continue}let n=this.r.advance();if(n==="")break;r+=n}return r&&i.push({text:r}),this.r.peek()===e&&this.r.advance(),i}classifyParts(e){let i=e.filter(r=>"hole"in r);return i.length===0?{kind:"static",value:e.map(r=>"text"in r?r.text:"").join("")}:e.length===1?{kind:"hole",hole:i[0].hole}:{kind:"mixed",parts:e}}foldEachKey(e,i){let r=null,n=0,s=0,a=0,l=0;for(let d of e)d.kind==="EachDirective"?(r=d,s++):d.kind==="IfDirective"?n++:d.kind==="ElseDirective"?a++:d.kind==="RefBinding"&&l++;let o=this.r.span(i);s>1&&this.report("duplicate-directive","error","Multiple `each` directives on one element",o),n>1&&this.report("duplicate-directive","error","Multiple `if` directives on one element",o),l>1&&this.report("duplicate-directive","error","Multiple `ref` bindings on one element",o),n>0&&s>0&&this.report("unsupported-combination","error","`if` and `each` cannot both apply to one element — wrap one in another element",o),n>0&&a>0&&this.report("invalid-directive","error","`if` and `else` cannot be on the same element",o);let c=e.findIndex(d=>d.kind==="Attribute"&&d.name==="key");if(!r){c!==-1&&this.report("invalid-directive","error","`key` requires an `each` directive on the same element",o);return}if(c===-1)return;let h=e[c];h.kind==="Attribute"&&h.value&&(h.value.kind==="static"?r.key={static:h.value.value}:h.value.kind==="hole"&&(r.key={hole:h.value.hole})),e.splice(c,1)}readName(){return this.r.readWhile(e=>P.test(e))}consumeCloseTag(){this.r.advance(),this.r.advance();let e=this.readName();return this.r.skipWhitespace(),this.r.peek()===">"&&this.r.advance(),e}report(e,i,r,n){this.diagnostics.push({code:e,severity:i,message:r,loc:n})}};function w(t,e={}){return new g(t,e).parse()}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The structural layer: recursive-descent parser over the {@link Reader},
3
+ * producing a located {@link RootNode} plus recovered diagnostics.
4
+ *
5
+ * It stays close to the proven single-pass scanner it replaces (so lowering can
6
+ * stay byte-identical) but with three differences that make it a real
7
+ * foundation: every node carries a span, malformed input is recovered from
8
+ * (never throws, never stalls), and attribute semantics are delegated to the
9
+ * directive registry so new syntax doesn't touch this file.
10
+ */
11
+ import { type ParseResult } from './ast.js';
12
+ import { Reader } from './reader.js';
13
+ import { type DirectiveDescriptor } from './directives.js';
14
+ export interface ParserOptions {
15
+ /** `svg\`\`` root — the whole subtree lives in the SVG namespace. */
16
+ svg?: boolean;
17
+ /** Override/extend the directive set (downstream tools prepend their own). */
18
+ directives?: DirectiveDescriptor[];
19
+ }
20
+ /** Parse a piece list into a Template AST. Never throws; recovers + reports. */
21
+ export declare function parseTemplate(pieces: ConstructorParameters<typeof Reader>[0], opts?: ParserOptions): ParseResult;
22
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAYL,KAAK,WAAW,EAQjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,iBAAiB,CAAC;AAKzB,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,8EAA8E;IAC9E,UAAU,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACpC;AAsZD,gFAAgF;AAChF,wBAAgB,aAAa,CAC3B,MAAM,EAAE,qBAAqB,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,EAC/C,IAAI,GAAE,aAAkB,GACvB,WAAW,CAEb"}
package/dist/parser.js ADDED
Binary file
@@ -0,0 +1 @@
1
+ function g(t){let e=(i,r)=>{i.parent=r;let n=C(i);for(let s of n)e(s,i)};return e(t,null),t}function C(t){switch(t.kind){case"Root":case"Element":case"Component":case"Fragment":return t.children;default:return[]}}var u=class{constructor(e){this.pieces=e;this.pi=0;this.oi=0;this.normalize()}normalize(){for(;this.pi<this.pieces.length;){let e=this.pieces[this.pi];if(e.kind==="static"&&this.oi>=e.text.length){this.pi++,this.oi=0;continue}break}}eof(){return this.pi>=this.pieces.length}pos(){if(this.eof()){let i=this.pieces[this.pieces.length-1];return i?i.kind==="static"?i.start+i.text.length:i.end:0}let e=this.pieces[this.pi];return e.kind==="static"?e.start+this.oi:e.start}atHole(){return!this.eof()&&this.pieces[this.pi].kind==="hole"}holeFollows(){if(this.eof())return!1;let e=this.pieces[this.pi];if(e.kind!=="static"||this.oi+1<e.text.length)return!1;let i=this.pieces[this.pi+1];return i!==void 0&&i.kind==="hole"}takeHole(){let e=this.pieces[this.pi];if(e.kind!=="hole")throw new Error("takeHole called off a hole");return this.pi++,this.oi=0,this.normalize(),{index:e.index,loc:{start:e.start,end:e.end}}}peek(e=0){if(this.eof())return"";let i=this.pieces[this.pi];return i.kind!=="static"?"":i.text[this.oi+e]??""}startsWith(e){if(this.eof())return!1;let i=this.pieces[this.pi];return i.kind!=="static"?!1:i.text.startsWith(e,this.oi)}advance(){if(this.eof())return"";let e=this.pieces[this.pi];if(e.kind!=="static")return"";let i=e.text[this.oi++]??"";return this.normalize(),i}readWhile(e){let i="";for(;!this.eof()&&!this.atHole();){let r=this.peek();if(r===""||!e(r))break;i+=r,this.oi++}return this.normalize(),i}skipWhitespace(){this.readWhile(e=>/\s/.test(e))}span(e){return{start:e,end:this.pos()}}};var k=new Set(["capture","once","passive","prevent","stop","self"]);function p(t,e){return t.value&&t.value.kind==="hole"?t.value.hole:(t.report("invalid-binding",`${e} requires an expression value: ${t.name}=\${…}`),-1)}var N=(t,e)=>({kind:"Attribute",name:e?t.name.slice(1):t.name,value:t.value,boolean:e,loc:t.loc}),v=[{id:"event",match:t=>t[0]==="@"||t.startsWith("on:")||/^on[A-Z]/.test(t),build:t=>{let e,i;t.name[0]==="@"?(e="at",i=t.name.slice(1)):t.name.startsWith("on:")?(e="colon",i=t.name.slice(3)):(e="on",i=t.name.slice(2));let[r,...n]=i.split(".");for(let s of n)k.has(s)||t.report("invalid-directive",`Unknown event modifier ".${s}" — expected one of ${[...k].join(", ")}`);return{kind:"EventBinding",name:r,syntax:e,modifiers:n,hole:p(t,"event binding"),loc:t.loc}}},{id:"bind",elementOnly:!0,match:t=>t.startsWith("bind:"),build:t=>({kind:"BindDirective",name:t.name.slice(5),hole:p(t,"two-way binding"),loc:t.loc})},{id:"class-directive",elementOnly:!0,match:t=>t.startsWith("class:"),build:t=>({kind:"ClassDirective",name:t.name.slice(6),hole:p(t,"class directive"),loc:t.loc})},{id:"style-directive",elementOnly:!0,match:t=>t.startsWith("style:"),build:t=>({kind:"StyleDirective",name:t.name.slice(6),hole:p(t,"style directive"),loc:t.loc})},{id:"use",match:t=>t==="use"||t.startsWith("use:"),build:t=>({kind:"UseDirective",name:t.name.startsWith("use:")?t.name.slice(4):null,hole:t.value&&t.value.kind==="hole"?t.value.hole:null,loc:t.loc})},{id:"if",elementOnly:!0,match:t=>t==="if",build:t=>({kind:"IfDirective",hole:p(t,"if directive"),loc:t.loc})},{id:"each",elementOnly:!0,match:t=>t==="each",build:t=>({kind:"EachDirective",hole:p(t,"each directive"),key:null,loc:t.loc})},{id:"else",elementOnly:!0,match:t=>t==="else",build:t=>(t.value!==null&&t.report("invalid-directive","`else` takes no value"),{kind:"ElseDirective",loc:t.loc})},{id:"ref",match:t=>t==="ref",build:t=>({kind:"RefBinding",hole:p(t,"ref binding"),loc:t.loc})},{id:"property",match:t=>t[0]===".",build:t=>({kind:"PropertyBinding",name:t.name.slice(1),hole:p(t,"property binding"),loc:t.loc})},{id:"boolean",match:t=>t[0]==="?",build:t=>N(t,!0)}];function x(t,e=v,i={component:!1}){for(let r of e)if(!(r.elementOnly&&i.component)&&r.match(t.name))return r.build(t);return N(t,!1)}var b=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),y=new Set(["script","style","textarea","title"]),D=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function E(t){return t.length>0&&(t[0]!==t[0].toLowerCase()||t.includes("."))}var S=/[A-Za-z0-9\-_:@.?]/,f=class{constructor(e,i){this.diagnostics=[];this.r=new u(e),this.svg=i.svg??!1,this.directives=i.directives??v}parse(){let e=this.r.pos(),i=[];for(;!this.r.eof()&&(i.push(...this.parseChildren()),!this.r.eof());){let n=this.r.pos();this.consumeCloseTag(),this.report("stray-close-tag","error","Close tag without a matching open tag",this.r.span(n))}let r={kind:"Root",children:i,loc:this.r.span(e)};return g(r),this.validateTree(r),{root:r,diagnostics:this.diagnostics}}validateTree(e){let i=r=>{let n=null;for(let s of r)s.kind==="Text"&&/^\s*$/.test(s.value)||(s.kind==="Element"||s.kind==="Component"?(s.attributes.some(l=>l.kind==="ElseDirective")&&(n!=null&&(n.kind==="Element"||n.kind==="Component")&&n.attributes.some(o=>o.kind==="IfDirective")||this.report("else-without-if","error","`else` must immediately follow an element with `if`",s.loc)),n=s):n=null,"children"in s&&s.children&&i(s.children))};i(e.children)}parseChildren(){let e=[];for(;!this.r.eof()&&!this.r.startsWith("</");){if(this.r.startsWith("<!--")){e.push(this.parseComment());continue}if(this.isFragmentStart()){e.push(this.parseFragment());continue}if(this.isDynamicTagStart()){e.push(this.parseDynamicComponent());continue}if(this.isTagStart()){e.push(this.parseElement());continue}if(this.r.atHole()){let r=this.r.takeHole(),n={kind:"Expression",hole:r.index,loc:r.loc};e.push(n);continue}let i=this.readText();i&&e.push(i)}return e}isTagStart(){return this.r.peek()==="<"&&/[A-Za-z]/.test(this.r.peek(1))}isFragmentStart(){return this.r.peek()==="<"&&this.r.peek(1)===">"}isDynamicTagStart(){return this.r.peek()==="<"&&this.r.holeFollows()}parseDynamicComponent(){let e=this.r.pos();this.r.advance();let i=this.r.takeHole().index,r=this.parseAttributes(!0);this.r.skipWhitespace();let n=!1,s=[];return this.r.startsWith("/>")?(this.r.advance(),this.r.advance(),n=!0):(this.r.peek()===">"&&this.r.advance(),s=this.parseChildren(),this.r.startsWith("</")?(this.r.advance(),this.r.advance(),this.r.atHole()?this.r.takeHole():this.readName(),this.r.skipWhitespace(),this.r.peek()===">"&&this.r.advance()):this.report("unclosed-tag","error","Unclosed dynamic component",this.r.span(e))),{kind:"Component",tag:"",tagHole:i,attributes:r,children:s,selfClosing:n,loc:this.r.span(e)}}readText(){let e=this.r.pos(),i="";for(;!this.r.eof()&&!this.r.atHole()&&!(this.r.startsWith("</")||this.r.startsWith("<!--")||this.isTagStart()||this.isFragmentStart()||this.isDynamicTagStart());)i+=this.r.advance();return i?{kind:"Text",value:i,raw:!1,loc:this.r.span(e)}:null}parseComment(){let e=this.r.pos();this.r.advance(),this.r.advance(),this.r.advance(),this.r.advance();let i="";for(;!this.r.eof()&&!this.r.startsWith("-->");){if(this.r.atHole()){this.r.takeHole(),i+="\0";continue}i+=this.r.advance()}return this.r.startsWith("-->")?(this.r.advance(),this.r.advance(),this.r.advance()):this.report("unclosed-comment","warning","Unterminated comment",this.r.span(e)),{kind:"Comment",value:i,loc:this.r.span(e)}}parseFragment(){let e=this.r.pos();this.r.advance(),this.r.advance();let i=this.parseChildren();if(this.r.startsWith("</")){let r=this.consumeCloseTag();r&&this.report("mismatched-close-tag","error",`Expected </> to close fragment, got </${r}>`,this.r.span(e))}else this.report("unclosed-tag","error","Unterminated fragment",this.r.span(e));return{kind:"Fragment",children:i,loc:this.r.span(e)}}parseElement(){let e=this.r.pos();this.r.advance();let i=this.readName(),r=E(i),n=this.parseAttributes(r);this.foldEachKey(n,e),this.r.skipWhitespace();let s=i.toLowerCase(),a=!r&&y.has(s),l=!r&&D.has(s),o=!1,c=[];if(this.r.startsWith("/>"))this.r.advance(),this.r.advance(),o=!0;else if(this.r.peek()===">"&&this.r.advance(),!l)if(c=a?this.parseRawText(i):this.parseChildren(),this.r.startsWith("</")){let m=this.consumeCloseTag();m&&m!==i&&this.report("mismatched-close-tag","error",`Expected </${i}>, got </${m}>`,this.r.span(e))}else this.report("unclosed-tag","error",`Unclosed <${i}>`,this.r.span(e));let h=this.r.span(e);if(r)return{kind:"Component",tag:i,tagHole:null,attributes:n,children:c,selfClosing:o,loc:h};let d=this.svg||b.has(i)?"svg":"html";return{kind:"Element",tag:i,namespace:d,attributes:n,children:c,selfClosing:o,rawText:a,loc:h}}parseRawText(e){let i=[],r="</"+e.toLowerCase(),n="",s=this.r.pos(),a=()=>{n&&i.push({kind:"Text",value:n,raw:!0,loc:this.r.span(s)}),n=""};for(;!this.r.eof()&&!this.startsWithCloseFor(r);){if(this.r.atHole()){a();let l=this.r.takeHole();i.push({kind:"Expression",hole:l.index,loc:l.loc}),s=this.r.pos();continue}n||(s=this.r.pos()),n+=this.r.advance()}return a(),i}startsWithCloseFor(e){let i=0;for(;i<e.length;){let r=this.r.peek(i);if(r===""||r.toLowerCase()!==e[i])return!1;i++}return!0}parseAttributes(e){let i=[];for(;!this.r.eof()&&(this.r.skipWhitespace(),!(this.r.peek()===">"||this.r.startsWith("/>")));){if(this.r.atHole()){let o=this.r.takeHole();i.push({kind:"Spread",hole:o.index,loc:o.loc});continue}if(this.r.startsWith("...")){let o=this.r.pos();if(this.r.advance(),this.r.advance(),this.r.advance(),this.r.atHole()){let c=this.r.takeHole();i.push({kind:"Spread",hole:c.index,loc:this.r.span(o)})}else this.report("invalid-binding","error","Spread `...` must be followed by ${…}",this.r.span(o));continue}let r=this.r.pos(),n=this.readName();if(!n){this.r.advance();continue}let s=this.r.span(r);this.r.skipWhitespace();let a=null;this.r.peek()==="="&&(this.r.advance(),this.r.skipWhitespace(),a=this.parseAttrValue());let l={name:n,nameLoc:s,value:a,loc:this.r.span(r),report:(o,c)=>this.report(o,"error",c,this.r.span(r))};i.push(x(l,this.directives,{component:e}))}return i}parseAttrValue(){if(this.r.atHole())return{kind:"hole",hole:this.r.takeHole().index};let e=this.r.peek();return e==='"'||e==="'"?this.classifyParts(this.readQuotedParts(e)):{kind:"static",value:this.r.readWhile(r=>!/[\s>]/.test(r))}}readQuotedParts(e){this.r.advance();let i=[],r="";for(;!this.r.eof()&&this.r.peek()!==e;){if(this.r.atHole()){r&&(i.push({text:r}),r=""),i.push({hole:this.r.takeHole().index});continue}let n=this.r.advance();if(n==="")break;r+=n}return r&&i.push({text:r}),this.r.peek()===e&&this.r.advance(),i}classifyParts(e){let i=e.filter(r=>"hole"in r);return i.length===0?{kind:"static",value:e.map(r=>"text"in r?r.text:"").join("")}:e.length===1?{kind:"hole",hole:i[0].hole}:{kind:"mixed",parts:e}}foldEachKey(e,i){let r=null,n=0,s=0,a=0,l=0;for(let d of e)d.kind==="EachDirective"?(r=d,s++):d.kind==="IfDirective"?n++:d.kind==="ElseDirective"?a++:d.kind==="RefBinding"&&l++;let o=this.r.span(i);s>1&&this.report("duplicate-directive","error","Multiple `each` directives on one element",o),n>1&&this.report("duplicate-directive","error","Multiple `if` directives on one element",o),l>1&&this.report("duplicate-directive","error","Multiple `ref` bindings on one element",o),n>0&&s>0&&this.report("unsupported-combination","error","`if` and `each` cannot both apply to one element — wrap one in another element",o),n>0&&a>0&&this.report("invalid-directive","error","`if` and `else` cannot be on the same element",o);let c=e.findIndex(d=>d.kind==="Attribute"&&d.name==="key");if(!r){c!==-1&&this.report("invalid-directive","error","`key` requires an `each` directive on the same element",o);return}if(c===-1)return;let h=e[c];h.kind==="Attribute"&&h.value&&(h.value.kind==="static"?r.key={static:h.value.value}:h.value.kind==="hole"&&(r.key={hole:h.value.hole})),e.splice(c,1)}readName(){return this.r.readWhile(e=>S.test(e))}consumeCloseTag(){this.r.advance(),this.r.advance();let e=this.readName();return this.r.skipWhitespace(),this.r.peek()===">"&&this.r.advance(),e}report(e,i,r,n){this.diagnostics.push({code:e,severity:i,message:r,loc:n})}};function V(t,e={}){return new f(t,e).parse()}export{V as parseTemplate};
@@ -0,0 +1 @@
1
+ "use strict";var r=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var c=(e,t)=>{for(var i in t)r(e,i,{get:t[i],enumerable:!0})},l=(e,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of a(t))!p.call(e,n)&&n!==i&&r(e,n,{get:()=>t[n],enumerable:!(s=h(t,n))||s.enumerable});return e};var u=e=>l(r({},"__esModule",{value:!0}),e);var f={};c(f,{Reader:()=>o});module.exports=u(f);var o=class{constructor(t){this.pieces=t;this.pi=0;this.oi=0;this.normalize()}normalize(){for(;this.pi<this.pieces.length;){let t=this.pieces[this.pi];if(t.kind==="static"&&this.oi>=t.text.length){this.pi++,this.oi=0;continue}break}}eof(){return this.pi>=this.pieces.length}pos(){if(this.eof()){let i=this.pieces[this.pieces.length-1];return i?i.kind==="static"?i.start+i.text.length:i.end:0}let t=this.pieces[this.pi];return t.kind==="static"?t.start+this.oi:t.start}atHole(){return!this.eof()&&this.pieces[this.pi].kind==="hole"}holeFollows(){if(this.eof())return!1;let t=this.pieces[this.pi];if(t.kind!=="static"||this.oi+1<t.text.length)return!1;let i=this.pieces[this.pi+1];return i!==void 0&&i.kind==="hole"}takeHole(){let t=this.pieces[this.pi];if(t.kind!=="hole")throw new Error("takeHole called off a hole");return this.pi++,this.oi=0,this.normalize(),{index:t.index,loc:{start:t.start,end:t.end}}}peek(t=0){if(this.eof())return"";let i=this.pieces[this.pi];return i.kind!=="static"?"":i.text[this.oi+t]??""}startsWith(t){if(this.eof())return!1;let i=this.pieces[this.pi];return i.kind!=="static"?!1:i.text.startsWith(t,this.oi)}advance(){if(this.eof())return"";let t=this.pieces[this.pi];if(t.kind!=="static")return"";let i=t.text[this.oi++]??"";return this.normalize(),i}readWhile(t){let i="";for(;!this.eof()&&!this.atHole();){let s=this.peek();if(s===""||!t(s))break;i+=s,this.oi++}return this.normalize(),i}skipWhitespace(){this.readWhile(t=>/\s/.test(t))}span(t){return{start:t,end:this.pos()}}};
@@ -0,0 +1,61 @@
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.js';
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
+ }
61
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,MAAM,KAAK,GACb;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,UAAU,CAAC;CACjB;AAED,qBAAa,MAAM;IAIL,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,EAAE,CAAK;IACf,OAAO,CAAC,EAAE,CAAK;gBAEK,MAAM,EAAE,KAAK,EAAE;IAInC,+EAA+E;IAC/E,OAAO,CAAC,SAAS;IAYjB,GAAG,IAAI,OAAO;IAId,4CAA4C;IAC5C,GAAG,IAAI,MAAM;IASb,0DAA0D;IAC1D,MAAM,IAAI,OAAO;IAIjB,qFAAqF;IACrF,WAAW,IAAI,OAAO;IAStB,+EAA+E;IAC/E,QAAQ,IAAI,SAAS;IASrB,kFAAkF;IAClF,IAAI,CAAC,CAAC,SAAI,GAAG,MAAM;IAOnB,wEAAwE;IACxE,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAO9B,+DAA+D;IAC/D,OAAO,IAAI,MAAM;IASjB,wEAAwE;IACxE,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM;IAYhD,cAAc,IAAI,IAAI;IAItB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;CAGhC"}
package/dist/reader.js ADDED
@@ -0,0 +1,107 @@
1
+ export class Reader {
2
+ pieces;
3
+ pi = 0; // current piece index
4
+ oi = 0; // offset within the current static piece
5
+ constructor(pieces) {
6
+ this.pieces = pieces;
7
+ this.normalize();
8
+ }
9
+ /** Skip fully-consumed static pieces so `current()` is live text or a hole. */
10
+ normalize() {
11
+ while (this.pi < this.pieces.length) {
12
+ const p = this.pieces[this.pi];
13
+ if (p.kind === 'static' && this.oi >= p.text.length) {
14
+ this.pi++;
15
+ this.oi = 0;
16
+ continue;
17
+ }
18
+ break;
19
+ }
20
+ }
21
+ eof() {
22
+ return this.pi >= this.pieces.length;
23
+ }
24
+ /** Absolute source offset of the cursor. */
25
+ pos() {
26
+ if (this.eof()) {
27
+ const last = this.pieces[this.pieces.length - 1];
28
+ return last ? (last.kind === 'static' ? last.start + last.text.length : last.end) : 0;
29
+ }
30
+ const p = this.pieces[this.pi];
31
+ return p.kind === 'static' ? p.start + this.oi : p.start;
32
+ }
33
+ /** True when the cursor sits exactly on a hole marker. */
34
+ atHole() {
35
+ return !this.eof() && this.pieces[this.pi].kind === 'hole';
36
+ }
37
+ /** True when advancing one char would land on a hole (e.g. the `<` in `<${Tag}`). */
38
+ holeFollows() {
39
+ if (this.eof())
40
+ return false;
41
+ const p = this.pieces[this.pi];
42
+ if (p.kind !== 'static')
43
+ return false;
44
+ if (this.oi + 1 < p.text.length)
45
+ return false; // another char in this segment
46
+ const next = this.pieces[this.pi + 1];
47
+ return next !== undefined && next.kind === 'hole';
48
+ }
49
+ /** Consume the hole at the cursor. Caller must have checked {@link atHole}. */
50
+ takeHole() {
51
+ const p = this.pieces[this.pi];
52
+ if (p.kind !== 'hole')
53
+ throw new Error('takeHole called off a hole');
54
+ this.pi++;
55
+ this.oi = 0;
56
+ this.normalize();
57
+ return { index: p.index, loc: { start: p.start, end: p.end } };
58
+ }
59
+ /** Char `k` ahead within the current static segment, or '' at a boundary/hole. */
60
+ peek(k = 0) {
61
+ if (this.eof())
62
+ return '';
63
+ const p = this.pieces[this.pi];
64
+ if (p.kind !== 'static')
65
+ return '';
66
+ return p.text[this.oi + k] ?? '';
67
+ }
68
+ /** Whether the current static segment starts with `s` at the cursor. */
69
+ startsWith(s) {
70
+ if (this.eof())
71
+ return false;
72
+ const p = this.pieces[this.pi];
73
+ if (p.kind !== 'static')
74
+ return false;
75
+ return p.text.startsWith(s, this.oi);
76
+ }
77
+ /** Advance one character inside the current static segment. */
78
+ advance() {
79
+ if (this.eof())
80
+ return '';
81
+ const p = this.pieces[this.pi];
82
+ if (p.kind !== 'static')
83
+ return '';
84
+ const ch = p.text[this.oi++] ?? '';
85
+ this.normalize();
86
+ return ch;
87
+ }
88
+ /** Advance while `pred` holds and we stay inside one static segment. */
89
+ readWhile(pred) {
90
+ let out = '';
91
+ while (!this.eof() && !this.atHole()) {
92
+ const ch = this.peek();
93
+ if (ch === '' || !pred(ch))
94
+ break;
95
+ out += ch;
96
+ this.oi++;
97
+ }
98
+ this.normalize();
99
+ return out;
100
+ }
101
+ skipWhitespace() {
102
+ this.readWhile((ch) => /\s/.test(ch));
103
+ }
104
+ span(start) {
105
+ return { start, end: this.pos() };
106
+ }
107
+ }
@@ -0,0 +1 @@
1
+ var s=class{constructor(t){this.pieces=t;this.pi=0;this.oi=0;this.normalize()}normalize(){for(;this.pi<this.pieces.length;){let t=this.pieces[this.pi];if(t.kind==="static"&&this.oi>=t.text.length){this.pi++,this.oi=0;continue}break}}eof(){return this.pi>=this.pieces.length}pos(){if(this.eof()){let i=this.pieces[this.pieces.length-1];return i?i.kind==="static"?i.start+i.text.length:i.end:0}let t=this.pieces[this.pi];return t.kind==="static"?t.start+this.oi:t.start}atHole(){return!this.eof()&&this.pieces[this.pi].kind==="hole"}holeFollows(){if(this.eof())return!1;let t=this.pieces[this.pi];if(t.kind!=="static"||this.oi+1<t.text.length)return!1;let i=this.pieces[this.pi+1];return i!==void 0&&i.kind==="hole"}takeHole(){let t=this.pieces[this.pi];if(t.kind!=="hole")throw new Error("takeHole called off a hole");return this.pi++,this.oi=0,this.normalize(),{index:t.index,loc:{start:t.start,end:t.end}}}peek(t=0){if(this.eof())return"";let i=this.pieces[this.pi];return i.kind!=="static"?"":i.text[this.oi+t]??""}startsWith(t){if(this.eof())return!1;let i=this.pieces[this.pi];return i.kind!=="static"?!1:i.text.startsWith(t,this.oi)}advance(){if(this.eof())return"";let t=this.pieces[this.pi];if(t.kind!=="static")return"";let i=t.text[this.oi++]??"";return this.normalize(),i}readWhile(t){let i="";for(;!this.eof()&&!this.atHole();){let e=this.peek();if(e===""||!t(e))break;i+=e,this.oi++}return this.normalize(),i}skipWhitespace(){this.readWhile(t=>/\s/.test(t))}span(t){return{start:t,end:this.pos()}}};export{s as Reader};
package/dist/tags.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var r=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},u=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of l(t))!i.call(e,n)&&n!==o&&r(e,n,{get:()=>t[n],enumerable:!(s=c(t,n))||s.enumerable});return e};var a=e=>u(r({},"__esModule",{value:!0}),e);var T={};p(T,{DELEGATED_EVENTS:()=>m,RAW_TEXT_ELEMENTS:()=>S,SVG_TAGS:()=>E,VOID_ELEMENTS:()=>b,isComponentTag:()=>w});module.exports=a(T);var E=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),S=new Set(["script","style","textarea","title"]),b=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),m=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function w(e){return e.length>0&&(e[0]!==e[0].toLowerCase()||e.includes("."))}
package/dist/tags.d.ts ADDED
@@ -0,0 +1,16 @@
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;
16
+ //# sourceMappingURL=tags.d.ts.map
@@ -0,0 +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,kFAAkF;AAClF,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 ADDED
@@ -0,0 +1,26 @@
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 const SVG_TAGS = new Set([
8
+ 'svg', 'path', 'circle', 'rect', 'line', 'polygon', 'polyline',
9
+ 'ellipse', 'g', 'defs', 'clipPath', 'text',
10
+ ]);
11
+ /** Elements whose content is text, not markup — don't descend into `<` inside. */
12
+ export const RAW_TEXT_ELEMENTS = new Set(['script', 'style', 'textarea', 'title']);
13
+ /** Void elements: no children, no close tag (`<input>`, `<br>`, …). */
14
+ export const VOID_ELEMENTS = new Set([
15
+ 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
16
+ 'link', 'meta', 'param', 'source', 'track', 'wbr',
17
+ ]);
18
+ /** Events wired through the delegated listener (matches the compiler set). */
19
+ export const DELEGATED_EVENTS = new Set([
20
+ 'click', 'dblclick', 'input', 'change', 'submit', 'focus', 'blur',
21
+ 'keydown', 'keyup', 'keypress', 'mousedown', 'mouseup',
22
+ ]);
23
+ /** A tag is a component when capitalized or a member path (`Ctx.Provider`). */
24
+ export function isComponentTag(tag) {
25
+ return tag.length > 0 && (tag[0] !== tag[0].toLowerCase() || tag.includes('.'));
26
+ }
package/dist/tags.mjs ADDED
@@ -0,0 +1 @@
1
+ var t=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),n=new Set(["script","style","textarea","title"]),o=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),r=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function s(e){return e.length>0&&(e[0]!==e[0].toLowerCase()||e.includes("."))}export{r as DELEGATED_EVENTS,n as RAW_TEXT_ELEMENTS,t as SVG_TAGS,o as VOID_ELEMENTS,s as isComponentTag};
@@ -0,0 +1 @@
1
+ {"fileNames":["../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.d.ts","../../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/modules/index.d.ts","../src/ast.ts","../src/directives.ts","../src/reader.ts","../src/tags.ts","../src/parser.ts","../src/index.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/assert.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/assert/strict.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/globals.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/async_hooks.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/buffer.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/child_process.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/cluster.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/console.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/constants.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/crypto.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/dgram.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/dns.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/dns/promises.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/domain.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/dom-events.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/events.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/fs.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/fs/promises.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/http.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/http2.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/https.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/inspector.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/module.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/net.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/os.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/path.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/process.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/punycode.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/querystring.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/readline.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/readline/promises.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/repl.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/stream.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/stream/promises.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/stream/web.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/string_decoder.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/test.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/timers.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/timers/promises.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/tls.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/trace_events.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/tty.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/url.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/util.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/v8.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/vm.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/wasi.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/worker_threads.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/zlib.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/globals.global.d.ts","../../../node_modules/.pnpm/@types+node@18.16.9/node_modules/@types/node/index.d.ts"],"fileIdsList":[[60,106],[63,106],[64,69,97,106],[65,76,77,84,94,105,106],[65,66,76,84,106],[67,106],[68,69,77,85,106],[69,94,102,106],[70,72,76,84,106],[71,106],[72,73,106],[76,106],[74,76,106],[76,77,78,94,105,106],[76,77,78,91,94,97,106],[106,110],[106],[72,76,79,84,94,105,106],[76,77,79,80,84,94,102,105,106],[79,81,94,102,105,106],[60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112],[76,82,106],[83,105,106],[72,76,84,94,106],[85,106],[86,106],[63,87,106],[88,104,106,110],[89,106],[90,106],[76,91,92,106],[91,93,106,108],[64,76,94,95,96,97,106],[64,94,96,106],[94,95,106],[97,106],[98,106],[76,100,101,106],[100,101,106],[69,84,94,102,106],[103,106],[84,104,106],[64,79,90,105,106],[69,106],[94,106,107],[106,108],[106,109],[64,69,76,78,87,94,105,106,108,110],[94,106,111],[52,106],[53,106],[53,54,106],[53,54,55,56,58,106],[53,54,55,56,57,106]],"fileInfos":[{"version":"69684132aeb9b5642cbcd9e22dff7818ff0ee1aa831728af0ecf97d3364d5546","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"936e80ad36a2ee83fc3caf008e7c4c5afe45b3cf3d5c24408f039c1d47bdc1df","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"fef8cfad2e2dc5f5b3d97a6f4f2e92848eb1b88e897bb7318cef0e2820bceaab","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"a6a5253138c5432c68a1510c70fe78a644fe2e632111ba778e1978010d6edfec","impliedFormat":1},{"version":"b8f34dd1757f68e03262b1ca3ddfa668a855b872f8bdd5224d6f993a7b37dc2c","impliedFormat":99},{"version":"715d6855c5ddb9bbfa249b095a52ccc29af16799fb15231cec00ac2c7385bd3b","signature":"a15baa188632ab5d99ca1f20900584344c7c2ac16527634d6ee5bc018ba9b9e0","impliedFormat":99},{"version":"b1a930040cac307f051be26896c6f7345cad37197ce4b061701d9762407b996a","signature":"28b2c0f5b5edf8bb5376b7261a7b0e4be39c2b9c5873046e8c5faa61f22a6c68","impliedFormat":99},{"version":"b0d55b376d88cf6b33982abf3ae76ef0f9507b343cd930ff58836848232f6162","signature":"5f2c103a31a73eb51c02fdb720070596b04ca102ffee940cdceaf6406dcee0d6","impliedFormat":99},{"version":"79398fc78b9511ca426ae55622652128e935e4a5594e34b36aac2ad7cabe170a","signature":"562bd990982d3c9b5afe1461776568f2e33e90693f97d975e346c54cf94c6ed1","impliedFormat":99},{"version":"586521906caf0e1d678517577948d765f722eb0fbfca1df5f15b18c6887ab862","signature":"055bfc656eab9f3241acfc722435bf62f73cc2cf4b763319c425d3ae6b720e17","impliedFormat":99},{"version":"739a75312a96b274e25258ea667210807206b1648ee7a15c0a40bea0374e2458","signature":"7b66e663ac54c9dfd176aab1ff7f2adaf4f6a2bcc61ae983dadfebec74eab286","impliedFormat":99},{"version":"7e771891adaa85b690266bc37bd6eb43bc57eecc4b54693ead36467e7369952a","impliedFormat":1},{"version":"a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a","impliedFormat":1},{"version":"f749812878fecfa53cfc13b36e5d35086fb6377983a9df44175da83ccc23af1f","affectsGlobalScope":true,"impliedFormat":1},{"version":"7d2e3fea24c712c99c03ad8f556abedbfe105f87f1be10b95dbd409d24bc05a3","impliedFormat":1},{"version":"211e3f15fbced4ab4be19f49ffa990b9ff20d749d33b65ff753be691e7616239","affectsGlobalScope":true,"impliedFormat":1},{"version":"3719525a8f6ab731e3dfd585d9f87df55ec7d50d461df84f74eb4d68bb165244","impliedFormat":1},{"version":"5a94487653355b56018122d92392beb2e5f4a6c63ba5cef83bbe1c99775ef713","impliedFormat":1},{"version":"d5135ad93b33adcce80b18f8065087934cdc1730d63db58562edcf017e1aad9b","affectsGlobalScope":true,"impliedFormat":1},{"version":"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","impliedFormat":1},{"version":"e596c9bb2f29a2699fdd4ae89139612652245192f67f45617c5a4b20832aaae9","impliedFormat":1},{"version":"bb9c4ffa5e6290c6980b63c815cdd1625876dadb2efaf77edbe82984be93e55e","impliedFormat":1},{"version":"1cdcfc1f624d6c08aa12c73935f6e13f095919cd99edf95752951796eb225729","impliedFormat":1},{"version":"4eaff3d8e10676fd7913d8c108890e71c688e1e7d52f6d1d55c39514f493dc47","impliedFormat":1},{"version":"14b5aa23c5d0ae1907bc696ac7b6915d88f7d85799cc0dc2dcf98fbce2c5a67c","impliedFormat":1},{"version":"5c439dafdc09abe4d6c260a96b822fa0ba5be7203c71a63ab1f1423cd9e838ea","impliedFormat":1},{"version":"6b526a5ec4a401ca7c26cfe6a48e641d8f30af76673bad3b06a1b4504594a960","affectsGlobalScope":true,"impliedFormat":1},{"version":"00dee7cdca8b8420c47ea4a31a34b8e8294013ebc4f463fd941e867e7bf05029","affectsGlobalScope":true,"impliedFormat":1},{"version":"3256f3cccd578f9e7fe3a28096c505634bebcee8afb738ffa99368e536ca3a0b","impliedFormat":1},{"version":"1c84b46267610a34028edfd0d035509341751262bac1062857f3c8df7aff7153","impliedFormat":1},{"version":"7f138842074d0a40681775af008c8452093b68c383c94de31759e853c6d06b5c","impliedFormat":1},{"version":"a3d541d303ee505053f5dcbf9fafb65cac3d5631037501cd616195863a6c5740","impliedFormat":1},{"version":"8d3c583a07e0c37e876908c2d5da575019f689df8d9fa4c081d99119d53dba22","impliedFormat":1},{"version":"2c828a5405191d006115ab34e191b8474bc6c86ffdc401d1a9864b1b6e088a58","impliedFormat":1},{"version":"e630e5528e899219ae319e83bef54bf3bcb91b01d76861ecf881e8e614b167f0","affectsGlobalScope":true,"impliedFormat":1},{"version":"bcebb922784739bdb34c18ee51095d25a92b560c78ccd2eaacd6bd00f7443d83","impliedFormat":1},{"version":"7ee6ed878c4528215c82b664fe0cfe80e8b4da6c0d4cc80869367868774db8b1","impliedFormat":1},{"version":"b0973c3cbcdc59b37bf477731d468696ecaf442593ec51bab497a613a580fe30","impliedFormat":1},{"version":"4989e92ba5b69b182d2caaea6295af52b7dc73a4f7a2e336a676722884e7139d","affectsGlobalScope":true,"impliedFormat":1},{"version":"0715e4cd28ad471b2a93f3e552ff51a3ae423417a01a10aa1d3bc7c6b95059d6","affectsGlobalScope":true,"impliedFormat":1},{"version":"5153a2fd150e46ce57bb3f8db1318d33f6ad3261ed70ceeff92281c0608c74a3","impliedFormat":1},{"version":"210d54cd652ec0fec8c8916e4af59bb341065576ecda039842f9ffb2e908507c","impliedFormat":1},{"version":"36b03690b628eab08703d63f04eaa89c5df202e5f1edf3989f13ad389cd2c091","impliedFormat":1},{"version":"0effadd232a20498b11308058e334d3339cc5bf8c4c858393e38d9d4c0013dcf","impliedFormat":1},{"version":"25846d43937c672bab7e8195f3d881f93495df712ee901860effc109918938cc","impliedFormat":1},{"version":"4f3fdeba4e28e21aa719c081b8dc8f91d47e12e773389b9d35679c08151c9d37","impliedFormat":1},{"version":"1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff","impliedFormat":1},{"version":"69ee23dd0d215b09907ad30d23f88b7790c93329d1faf31d7835552a10cf7cbf","impliedFormat":1},{"version":"44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","impliedFormat":1},{"version":"23b89798789dffbd437c0c423f5d02d11f9736aea73d6abf16db4f812ff36eda","impliedFormat":1},{"version":"f69ff39996a61a0dd10f4bce73272b52e8024a4d58b13ab32bf4712909d0a2b7","impliedFormat":1},{"version":"3c4ba1dd9b12ffa284b565063108f2f031d150ea15b8fafbdc17f5d2a07251f3","affectsGlobalScope":true,"impliedFormat":1},{"version":"e10177274a35a9d07c825615340b2fcde2f610f53f3fb40269fd196b4288dda6","impliedFormat":1},{"version":"1422cd9e705adcc09088fda85a900c2b70e3ad36ea85846f68bd1a884cdf4e2b","impliedFormat":1},{"version":"3c13ef48634e7b5012fcf7e8fce7496352c2d779a7201389ca96a2a81ee4314d","impliedFormat":1},{"version":"5d0a25ec910fa36595f85a67ac992d7a53dd4064a1ba6aea1c9f14ab73a023f2","impliedFormat":1},{"version":"a73ae8c0e62103bb9e21bb6538700881bf135b9a8b125b857ec68edfa0da4ed3","affectsGlobalScope":true,"impliedFormat":1},{"version":"e1c1b2fbe236bf7ee3e342eeae7e20efb8988a0ac7da1cbbfa2c1f66b76c3423","affectsGlobalScope":true,"impliedFormat":1},{"version":"868831cab82b65dfe1d68180e898af1f2101e89ba9b754d1db6fb8cc2fac1921","impliedFormat":1},{"version":"0fe8985a28f82c450a04a6edf1279d7181c0893f37da7d2a27f8efd4fd5edb03","impliedFormat":1},{"version":"e59a892d87e72733e2a9ca21611b9beb52977be2696c7ba4b216cbbb9a48f5aa","impliedFormat":1},{"version":"52120bb7e4583612225bdf08e7c12559548170f11e660d33a33623bae9bbdbba","affectsGlobalScope":true,"impliedFormat":1},{"version":"8a300fa9b698845a1f9c41ecbe2c5966634582a8e2020d51abcace9b55aa959e","impliedFormat":1},{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a6dd3dba8e665ac43d279e0fdf5219edda0eed69b5e9a5061f46cd6a65c4f7a1","impliedFormat":1}],"root":[[54,59]],"options":{"composite":true,"declarationMap":true,"emitDeclarationOnly":false,"importHelpers":true,"module":199,"noEmitOnError":true,"noFallthroughCasesInSwitch":true,"noImplicitOverride":true,"noImplicitReturns":true,"noUnusedLocals":false,"noUnusedParameters":false,"outDir":"./","rootDir":"../src","skipLibCheck":true,"strict":true,"target":9,"tsBuildInfoFile":"./tsconfig.lib.tsbuildinfo"},"referencedMap":[[60,1],[61,1],[63,2],[64,3],[65,4],[66,5],[67,6],[68,7],[69,8],[70,9],[71,10],[72,11],[73,11],[75,12],[74,13],[76,12],[77,14],[78,15],[62,16],[112,17],[79,18],[80,19],[81,20],[113,21],[82,22],[83,23],[84,24],[85,25],[86,26],[87,27],[88,28],[89,29],[90,30],[91,31],[92,31],[93,32],[94,33],[96,34],[95,35],[97,36],[98,37],[99,17],[100,38],[101,39],[102,40],[103,41],[104,42],[105,43],[106,44],[107,45],[108,46],[109,47],[110,48],[111,49],[53,50],[52,17],[50,17],[51,17],[10,17],[9,17],[2,17],[11,17],[12,17],[13,17],[14,17],[15,17],[16,17],[17,17],[18,17],[3,17],[19,17],[20,17],[4,17],[21,17],[25,17],[22,17],[23,17],[24,17],[26,17],[27,17],[28,17],[5,17],[29,17],[30,17],[31,17],[32,17],[6,17],[36,17],[33,17],[34,17],[35,17],[37,17],[7,17],[38,17],[43,17],[44,17],[39,17],[40,17],[41,17],[42,17],[8,17],[48,17],[45,17],[46,17],[47,17],[1,17],[49,17],[54,51],[55,52],[59,53],[58,54],[56,52],[57,51]],"latestChangedDtsFile":"./index.d.ts","version":"5.8.3"}