@lipsjs/lips 0.1.1 → 0.3.0
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/README.md +185 -85
- package/dist/lips.js +6274 -0
- package/dist/lips.js.map +53 -0
- package/dist/lips.min.js +13 -2
- package/dist/lips.min.js.map +47 -43
- package/dist/mf2.min.js +4 -0
- package/dist/mf2.min.js.map +38 -0
- package/dist/precompile.min.js +23 -0
- package/dist/precompile.min.js.map +14 -0
- package/dist/runtime.min.js +5 -0
- package/dist/runtime.min.js.map +20 -0
- package/dist/stylis.min.js +3 -0
- package/dist/stylis.min.js.map +16 -0
- package/dist/types/events.d.ts +1 -1
- package/dist/types/i18n/engine.d.ts +14 -0
- package/dist/types/i18n/index.d.ts +122 -5
- package/dist/types/i18n/intl.d.ts +1 -0
- package/dist/types/i18n/lookup.d.ts +22 -0
- package/dist/types/ir/compiler.d.ts +226 -0
- package/dist/types/ir/expression.d.ts +149 -0
- package/dist/types/ir/facade.d.ts +138 -0
- package/dist/types/ir/host.d.ts +75 -0
- package/dist/types/ir/index.d.ts +18 -0
- package/dist/types/ir/parser.d.ts +124 -0
- package/dist/types/ir/policy.d.ts +95 -0
- package/dist/types/ir/router.d.ts +47 -0
- package/dist/types/ir/runtime.d.ts +130 -0
- package/dist/types/ir/signal.d.ts +28 -0
- package/dist/types/ir/style.d.ts +119 -0
- package/dist/types/ir/swap.d.ts +28 -0
- package/dist/types/ir/tree.d.ts +51 -0
- package/dist/types/lips.d.ts +33 -37
- package/dist/types/lynx/a11y.d.ts +61 -0
- package/dist/types/lynx/background.d.ts +71 -0
- package/dist/types/lynx/main.d.ts +46 -0
- package/dist/types/lynx/protocol.d.ts +52 -0
- package/dist/types/lynx/style.d.ts +49 -0
- package/dist/types/lynx/template.d.ts +37 -0
- package/dist/types/mf2.d.ts +14 -0
- package/dist/types/precompile.d.ts +85 -0
- package/dist/types/runtime.d.ts +16 -0
- package/dist/types/stylesheet.d.ts +21 -41
- package/dist/types/stylis.d.ts +2 -0
- package/dist/types/types.d.ts +176 -185
- package/dist/types/untrusted.d.ts +17 -0
- package/dist/untrusted.min.js +5 -0
- package/dist/untrusted.min.js.map +13 -0
- package/package.json +46 -10
- package/dist/test.component.min.js +0 -3
- package/dist/test.component.min.js.map +0 -50
- package/dist/test.stress.min.js +0 -476
- package/dist/test.stress.min.js.map +0 -50
- package/dist/types/component.d.ts +0 -107
- package/dist/types/constants.d.ts +0 -23
- package/dist/types/dws.d.ts +0 -14
- package/dist/types/iuc/index.d.ts +0 -25
- package/dist/types/iuc/tick.d.ts +0 -38
- package/dist/types/iuc.d.ts +0 -25
- package/dist/types/metrics.d.ts +0 -50
- package/dist/types/preprocess.d.ts +0 -2
- package/dist/types/signal.d.ts +0 -30
- package/dist/types/syntax/async.d.ts +0 -16
- package/dist/types/syntax/for.d.ts +0 -25
- package/dist/types/syntax/if.d.ts +0 -14
- package/dist/types/syntax/router.d.ts +0 -40
- package/dist/types/syntax/switch.d.ts +0 -16
- package/dist/types/tick.d.ts +0 -38
- package/dist/types/tps.d.ts +0 -11
- package/dist/types/uqs.d.ts +0 -37
- package/dist/types/utils.d.ts +0 -25
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/ir/parser.ts", "../src/ir/compiler.ts", "../src/ir/expression.ts", "../src/ir/style.ts", "../src/precompile.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Phase 2 — Template parser (RFC-001 §3–4)\n *\n * A dedicated recursive-descent parser for Lips templates:\n * - owns the syntax (no innerHTML, no regex preprocessing) — immune to\n * table-context hoisting, host-parser attribute lenience, whitespace\n * corruption\n * - positioned machine-readable diagnostics with error recovery\n * (`parse` never throws; broken templates yield partial ASTs)\n * - accepts the `.lips` SFC layout (frontscript + template) per\n * RFC-001 decision #5\n *\n * Attribute value semantics (predictable, no heuristics):\n * - `name=\"text\"` → literal string\n * - `name=\"a {expr} b\"` → interpolated parts\n * - `name=expr` → expression (whitespace-free, depth-aware)\n * - `name={ expr }` → expression (braced — spaces allowed)\n * - `name` / `!name` → boolean true / false\n * - `on-click( … )` → event instruction\n * - `await( … )` etc. → callable (fn) attribute\n * - `[a, b]` → iterator argument names\n * - `...expr` → spread\n */\n\n// ------------------------------------------------------------------- shared\nexport interface Loc {\n offset: number\n length: number\n}\nexport interface TemplateDiagnostic {\n code: string\n severity: 'error' | 'warning'\n message: string\n hint?: string\n loc: { line: number, col: number, offset: number, length: number }\n}\n\nexport type ExprSlot = { expr: string, loc: Loc }\n\n// ---------------------------------------------------------------------- AST\nexport type TemplateNode =\n | ElementNode\n | FragmentNode\n | { t: 'text', value: string, loc: Loc }\n | { t: 'interp', parts: ( string | ExprSlot )[], loc: Loc }\n | { t: 'comment', value: string, loc: Loc }\n\nexport interface FragmentNode {\n t: 'fragment'\n children: TemplateNode[]\n loc: Loc\n}\nexport interface ElementNode {\n t: 'element'\n tag: string // '#dynamic' for <{expr}>\n dynamicTag?: ExprSlot\n head?: ExprSlot // <if( … )>, <switch( … )>, <log( … )>\n attrs: AttrNode[]\n children: TemplateNode[]\n selfClosed: boolean\n loc: Loc\n}\n\nexport type AttrNode =\n | { k: 'literal', name: string, value: string, loc: Loc }\n | { k: 'interp', name: string, parts: ( string | ExprSlot )[], loc: Loc }\n | { k: 'expr', name: string, source: string, loc: Loc }\n | { k: 'bool', name: string, value: boolean, loc: Loc }\n | { k: 'event', name: string, source: string, loc: Loc }\n | { k: 'fn', name: string, source: string, loc: Loc }\n | { k: 'args', names: string[], loc: Loc }\n | { k: 'spread', source: string, loc: Loc }\n\nexport interface ParseResult {\n root: FragmentNode\n diagnostics: TemplateDiagnostic[]\n}\nexport interface SFCResult extends ParseResult {\n script: string\n}\n\n// ------------------------------------------------------------------- tables\nconst VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr'\n])\nconst RAW_WHITESPACE_TAGS = new Set([ 'pre', 'textarea' ])\nconst HEAD_SUGAR_TAGS = new Set([ 'if', 'else-if', 'switch', 'log' ])\n\nconst NAMED_ENTITIES: Record<string, string> = {\n '&': '&', '<': '<', '>': '>', '"': '\"', ''': \"'\", ' ': ' '\n}\nfunction decodeEntities( text: string ){\n return text.replace( /&(?:amp|lt|gt|quot|#39|nbsp);/g, m => NAMED_ENTITIES[ m ] )\n}\n\n// ------------------------------------------------------------------- parser\nclass TemplateParser {\n private pos = 0\n private lineStarts: number[] | null = null\n\n readonly diagnostics: TemplateDiagnostic[] = []\n\n constructor( private src: string ){}\n\n // ---- diagnostics helpers\n private locate( offset: number ){\n if( !this.lineStarts ){\n this.lineStarts = [ 0 ]\n for( let i = 0; i < this.src.length; i++ )\n if( this.src[ i ] === '\\n' ) this.lineStarts.push( i + 1 )\n }\n\n let lo = 0, hi = this.lineStarts.length - 1\n while( lo < hi ){\n const mid = ( lo + hi + 1 ) >> 1\n this.lineStarts[ mid ] <= offset ? lo = mid : hi = mid - 1\n }\n\n return { line: lo + 1, col: offset - this.lineStarts[ lo ] + 1 }\n }\n private report( code: string, severity: 'error' | 'warning', message: string, offset: number, length = 1, hint?: string ){\n const { line, col } = this.locate( offset )\n this.diagnostics.push({ code, severity, message, hint, loc: { line, col, offset, length } })\n }\n\n // ---- scanning helpers\n private eof(){ return this.pos >= this.src.length }\n private peek( offset = 0 ){ return this.src[ this.pos + offset ] }\n private startsWith( str: string ){ return this.src.startsWith( str, this.pos ) }\n private skipSpace(){ while( !this.eof() && /\\s/.test( this.src[ this.pos ] ) ) this.pos++ }\n\n /**\n * Scan a balanced region: from an opening delimiter already\n * consumed, up to (not including) its matching closer at depth 0.\n * String literals are opaque; (), [], {} all nest.\n */\n private scanBalanced( closer: string, code: string ): { content: string, loc: Loc } | null {\n const start = this.pos\n let depth = 0\n\n while( !this.eof() ){\n const c = this.src[ this.pos ]\n\n if( c === \"'\" || c === '\"' || c === '`' ){\n this.pos++\n while( !this.eof() && this.src[ this.pos ] !== c ){\n if( this.src[ this.pos ] === '\\\\' ) this.pos++\n this.pos++\n }\n this.pos++\n continue\n }\n\n if( depth === 0 && c === closer ){\n const content = this.src.slice( start, this.pos )\n this.pos++ // consume closer\n return { content, loc: { offset: start, length: content.length } }\n }\n\n if( c === '(' || c === '[' || c === '{' ) depth++\n else if( c === ')' || c === ']' || c === '}' ){\n if( depth === 0 && c !== closer ){\n this.report( code, 'error', `Unbalanced '${c}'`, this.pos )\n this.pos++\n continue\n }\n depth--\n }\n\n this.pos++\n }\n\n this.report( code, 'error', `Unterminated — expected '${closer}'`, start, this.pos - start )\n return null\n }\n\n // ---- entry\n parse(): ParseResult {\n const children: TemplateNode[] = []\n\n while( !this.eof() ){\n children.push( ...this.parseNodes( [] ) )\n\n // Root-level stray closing tag: report, consume, resume\n if( this.startsWith('</') ){\n const closeStart = this.pos\n this.pos += 2\n while( !this.eof() && this.peek() !== '>' ) this.pos++\n !this.eof() && this.pos++\n this.report( 'LIPS-P005', 'error',\n `Stray closing tag ${this.src.slice( closeStart, this.pos )}`, closeStart, this.pos - closeStart )\n }\n }\n\n return {\n root: { t: 'fragment', children, loc: { offset: 0, length: this.src.length } },\n diagnostics: this.diagnostics\n }\n }\n\n /**\n * Parse siblings until EOF or a closing tag belonging to\n * an ancestor. `stack` holds open ancestor tag names for\n * mismatch recovery.\n */\n private parseNodes( stack: string[] ): TemplateNode[] {\n const nodes: TemplateNode[] = []\n\n while( !this.eof() ){\n if( this.startsWith('</') ) break\n\n const before = this.pos\n\n if( this.peek() === '<' && this.peek( 1 ) !== undefined ){\n const node = this.parseTag( stack )\n node && nodes.push( node )\n }\n else {\n const text = this.parseText( stack )\n text && nodes.push( text )\n }\n\n /**\n * Progress guard: recovery paths must never stall the\n * loop (e.g. a lone '<' at EOF yields no node and no\n * consumption) — force one character forward.\n */\n if( this.pos === before ) this.pos++\n }\n\n return nodes\n }\n\n // ---- text & interpolation\n private parseText( stack: string[] ): TemplateNode | null {\n const start = this.pos\n const parts: ( string | ExprSlot )[] = []\n let buffer = ''\n\n while( !this.eof() && this.peek() !== '<' ){\n if( this.peek() === '{' ){\n this.pos++ // consume '{'\n const region = this.scanBalanced( '}', 'LIPS-P007' )\n if( region ){\n buffer && parts.push( buffer )\n buffer = ''\n parts.push({ expr: region.content.trim(), loc: region.loc })\n }\n continue\n }\n\n buffer += this.peek()\n this.pos++\n }\n buffer && parts.push( buffer )\n\n const loc: Loc = { offset: start, length: this.pos - start }\n\n // Interpolated text\n if( parts.some( p => typeof p !== 'string' ) )\n return {\n t: 'interp',\n parts: parts.map( p => typeof p === 'string' ? decodeEntities( p ) : p ),\n loc\n }\n\n const raw = parts.length ? parts[0] as string : ''\n /**\n * Drop whitespace-only text except inside <pre>/<textarea>\n */\n const inRaw = stack.some( tag => RAW_WHITESPACE_TAGS.has( tag ) )\n if( !raw || ( !inRaw && !raw.trim() ) ) return null\n\n return { t: 'text', value: decodeEntities( raw ), loc }\n }\n\n // ---- tags\n private parseTag( stack: string[] ): TemplateNode | null {\n const start = this.pos\n\n // Comment\n if( this.startsWith('<!--') ){\n const end = this.src.indexOf( '-->', this.pos + 4 )\n if( end === -1 ){\n this.report( 'LIPS-P003', 'error', 'Unterminated comment', start, this.src.length - start )\n this.pos = this.src.length\n return null\n }\n const value = this.src.slice( this.pos + 4, end )\n this.pos = end + 3\n return { t: 'comment', value, loc: { offset: start, length: this.pos - start } }\n }\n\n // Fragment open <>\n if( this.startsWith('<>') ){\n this.pos += 2\n const children: TemplateNode[] = []\n\n while( true ){\n children.push( ...this.parseNodes( [ ...stack, '#fragment' ] ) )\n if( this.closeStatus( '#fragment', start, stack ) !== 'stray' ) break\n }\n\n return { t: 'fragment', children, loc: { offset: start, length: this.pos - start } }\n }\n\n // Dynamic tag <{expr} …>\n if( this.startsWith('<{') ){\n this.pos += 2\n const region = this.scanBalanced( '}', 'LIPS-P008' )\n if( !region ) return null\n\n const el: ElementNode = {\n t: 'element',\n tag: '#dynamic',\n dynamicTag: { expr: region.content.trim(), loc: region.loc },\n attrs: [],\n children: [],\n selfClosed: false,\n loc: { offset: start, length: 0 }\n }\n this.finishTag( el, stack, start )\n return el\n }\n\n // Named tag\n this.pos++ // consume '<'\n const nameStart = this.pos\n while( !this.eof() && /[A-Za-z0-9_-]/.test( this.peek() ) ) this.pos++\n const tag = this.src.slice( nameStart, this.pos )\n\n if( !tag || !/^[A-Za-z]/.test( tag ) ){\n this.report( 'LIPS-P002', 'error', 'Invalid tag name', start, this.pos - start + 1 )\n // Recovery: emit the '<' as literal text\n return { t: 'text', value: '<', loc: { offset: start, length: 1 } }\n }\n\n const el: ElementNode = {\n t: 'element',\n tag: tag.toLowerCase(),\n attrs: [],\n children: [],\n selfClosed: false,\n loc: { offset: start, length: 0 }\n }\n\n // Sugar head: <if( … )>, <else-if( … )>, <switch( … )>, <log( … )>\n if( this.peek() === '(' ){\n if( HEAD_SUGAR_TAGS.has( el.tag ) ){\n this.pos++ // consume '('\n const region = this.scanBalanced( ')', 'LIPS-P012' )\n region && ( el.head = { expr: region.content.trim(), loc: region.loc } )\n }\n else this.report( 'LIPS-P011', 'error', `Head expression is not allowed on <${el.tag}>`, this.pos,\n 1, `Only ${[ ...HEAD_SUGAR_TAGS ].map( t => `<${t}(…)>` ).join(', ')} take a head` )\n }\n\n this.finishTag( el, stack, start )\n return el\n }\n\n /** attrs → '>' | '/>' → children → closing tag */\n private finishTag( el: ElementNode, stack: string[], start: number ){\n this.parseAttrs( el )\n\n // Self closing / void\n if( el.selfClosed || VOID_ELEMENTS.has( el.tag ) ){\n el.selfClosed = true\n el.loc = { offset: start, length: this.pos - start }\n return\n }\n\n const stackName = el.tag === '#dynamic' ? '#dynamic' : el.tag\n el.children = []\n\n /**\n * Loop so a stray closing tag inside the element is\n * consumed (with a diagnostic) and children parsing\n * resumes — the element doesn't silently end early.\n */\n while( true ){\n el.children.push( ...this.parseNodes( [ ...stack, stackName ] ) )\n if( this.closeStatus( stackName, start, stack ) !== 'stray' ) break\n }\n\n el.loc = { offset: start, length: this.pos - start }\n }\n\n /**\n * Consume the closing tag for `tag`. Recovery rules:\n * - `</>` closes fragments and dynamic tags (and anything, with a warning)\n * - mismatch that matches an ancestor → auto-close (warning), leave input\n * for the ancestor to consume\n * - stray close → report, consume, caller resumes children\n * - EOF → unclosed element (error)\n */\n private closeStatus( tag: string, openOffset: number, stack: string[] ): 'closed' | 'ancestor' | 'stray' | 'eof' {\n if( this.eof() ){\n this.report( 'LIPS-P006', 'error', `Unclosed <${tag === '#fragment' ? '' : tag}> — reached end of template`, openOffset,\n 1, `Add </${tag === '#fragment' || tag === '#dynamic' ? '' : tag}>` )\n return 'eof'\n }\n\n if( !this.startsWith('</') ) return 'closed' // parseNodes stopped for another reason\n\n const closeStart = this.pos\n this.pos += 2\n\n // Generic close </>\n if( this.peek() === '>' ){\n this.pos++\n if( tag !== '#fragment' && tag !== '#dynamic' )\n this.report( 'LIPS-P004', 'warning', `Generic '</>' closes <${tag}>`, closeStart, 3, `Prefer </${tag}>` )\n return 'closed'\n }\n\n const nameStart = this.pos\n while( !this.eof() && /[A-Za-z0-9_-]/.test( this.peek() ) ) this.pos++\n const closeTag = this.src.slice( nameStart, this.pos ).toLowerCase()\n this.skipSpace()\n this.peek() === '>' ? this.pos++ : this.report( 'LIPS-P001', 'error', `Malformed closing tag`, closeStart, this.pos - closeStart )\n\n if( closeTag === tag ) return 'closed'\n\n // Mismatch: ancestor match → rewind so the ancestor consumes it\n if( stack.includes( closeTag ) ){\n this.report( 'LIPS-P004', 'warning', `</${closeTag}> auto-closes <${tag}>`, closeStart, this.pos - closeStart,\n `Add the missing </${tag}> before </${closeTag}>` )\n this.pos = closeStart\n return 'ancestor'\n }\n\n this.report( 'LIPS-P005', 'error', `Stray closing tag </${closeTag}> — <${tag}> is open`, closeStart, this.pos - closeStart )\n return 'stray'\n }\n\n // ---- attributes\n private parseAttrs( el: ElementNode ){\n while( true ){\n this.skipSpace()\n if( this.eof() ){\n this.report( 'LIPS-P001', 'error', 'Unexpected end of template inside tag', el.loc.offset )\n return\n }\n\n if( this.startsWith('/>') ){ this.pos += 2; el.selfClosed = true; return }\n if( this.peek() === '>' ){ this.pos++; return }\n\n const attrStart = this.pos\n\n // Spread: ...expr\n if( this.startsWith('...') ){\n this.pos += 3\n const source = this.readUnquotedValue()\n el.attrs.push({ k: 'spread', source, loc: { offset: attrStart, length: this.pos - attrStart } })\n continue\n }\n\n // Iterator args: [a, b]\n if( this.peek() === '[' ){\n this.pos++\n const region = this.scanBalanced( ']', 'LIPS-P009' )\n if( region ){\n const names = region.content.split(',').map( s => s.trim() ).filter( Boolean )\n el.attrs.push({ k: 'args', names, loc: { offset: attrStart, length: this.pos - attrStart } })\n }\n continue\n }\n\n // Boolean negation: !name\n let negated = false\n if( this.peek() === '!' ){ negated = true; this.pos++ }\n\n // Attribute name\n const nameStart = this.pos\n while( !this.eof() && /[^\\s=/>()]/.test( this.peek() ) ) this.pos++\n const name = this.src.slice( nameStart, this.pos )\n\n if( !name ){\n this.report( 'LIPS-P009', 'error', `Invalid attribute syntax at '${this.peek()}'`, this.pos )\n this.pos++\n continue\n }\n\n // Callable form: on-click( … ), await( … )\n if( this.peek() === '(' ){\n this.pos++\n const region = this.scanBalanced( ')', 'LIPS-P010' )\n const source = region ? region.content.trim() : ''\n const loc: Loc = { offset: attrStart, length: this.pos - attrStart }\n\n name.startsWith('on-')\n ? el.attrs.push({ k: 'event', name: name.slice( 3 ), source, loc })\n : el.attrs.push({ k: 'fn', name, source, loc })\n continue\n }\n\n // Valued: name=…\n if( this.peek() === '=' ){\n this.pos++\n this.parseAttrValue( el, name, attrStart )\n continue\n }\n\n // Bare boolean\n el.attrs.push({ k: 'bool', name, value: !negated, loc: { offset: attrStart, length: this.pos - attrStart } })\n }\n }\n\n private parseAttrValue( el: ElementNode, name: string, attrStart: number ){\n const q = this.peek()\n\n // Quoted: literal or interpolated\n if( q === '\"' || q === \"'\" ){\n this.pos++\n const valueStart = this.pos\n const parts: ( string | ExprSlot )[] = []\n let buffer = ''\n\n while( !this.eof() && this.peek() !== q ){\n if( this.peek() === '{' ){\n this.pos++\n const region = this.scanBalanced( '}', 'LIPS-P007' )\n if( region ){\n buffer && parts.push( buffer )\n buffer = ''\n parts.push({ expr: region.content.trim(), loc: region.loc })\n }\n continue\n }\n buffer += this.peek()\n this.pos++\n }\n buffer && parts.push( buffer )\n\n this.eof()\n ? this.report( 'LIPS-P010', 'error', `Unterminated value for '${name}'`, valueStart, this.pos - valueStart )\n : this.pos++ // consume quote\n\n const loc: Loc = { offset: attrStart, length: this.pos - attrStart }\n\n parts.some( p => typeof p !== 'string' )\n ? el.attrs.push({ k: 'interp', name, parts: parts.map( p => typeof p === 'string' ? decodeEntities( p ) : p ), loc })\n : el.attrs.push({ k: 'literal', name, value: decodeEntities( ( parts[0] as string ) ?? '' ), loc })\n return\n }\n\n // Braced expression: name={ expr } — spaces allowed\n if( q === '{' ){\n this.pos++\n const region = this.scanBalanced( '}', 'LIPS-P007' )\n el.attrs.push({\n k: 'expr', name,\n source: region ? region.content.trim() : '',\n loc: { offset: attrStart, length: this.pos - attrStart }\n })\n return\n }\n\n // Unquoted expression — whitespace-free, depth-aware\n const source = this.readUnquotedValue()\n source\n ? el.attrs.push({ k: 'expr', name, source, loc: { offset: attrStart, length: this.pos - attrStart } })\n : this.report( 'LIPS-P010', 'error', `Missing value for attribute '${name}'`, attrStart )\n }\n\n /** Read an unquoted value: until whitespace/'>'/'/>' at depth 0 */\n private readUnquotedValue(): string {\n const start = this.pos\n let depth = 0\n\n while( !this.eof() ){\n const c = this.peek()\n\n if( c === \"'\" || c === '\"' || c === '`' ){\n this.pos++\n while( !this.eof() && this.peek() !== c ){\n if( this.peek() === '\\\\' ) this.pos++\n this.pos++\n }\n this.pos++\n continue\n }\n\n if( depth === 0 ){\n if( /\\s/.test( c ) || c === '>' ) break\n if( c === '/' && this.peek( 1 ) === '>' ) break\n }\n\n if( c === '(' || c === '[' || c === '{' ) depth++\n else if( c === ')' || c === ']' || c === '}' ) depth--\n\n this.pos++\n }\n\n return this.src.slice( start, this.pos ).trim()\n }\n}\n\n// -------------------------------------------------------------------- API\nexport function parseTemplate( src: string ): ParseResult {\n return new TemplateParser( src || '' ).parse()\n}\n\n/**\n * `.lips` single-file component: frontscript (JS/TS) followed by the\n * template. The template starts at the first line-leading `<` that sits\n * at top-level script depth (outside strings, comments, and brackets).\n */\nexport function parseSFC( src: string ): SFCResult {\n const splitAt = findTemplateStart( src || '' )\n const script = ( src || '' ).slice( 0, splitAt ).trimEnd()\n const templateSrc = ( src || '' ).slice( splitAt )\n\n const result = new TemplateParser( templateSrc ).parse()\n /**\n * Re-anchor diagnostic lines to the full SFC source\n */\n const lineOffset = script ? script.split('\\n').length + ( /\\n\\s*\\n$/.test( src.slice( 0, splitAt ) ) ? 1 : 0 ) : 0\n result.diagnostics.forEach( d => {\n d.loc.line += script ? src.slice( 0, splitAt ).split('\\n').length - 1 : 0\n d.loc.offset += splitAt\n })\n\n return { script, ...result }\n}\n\nfunction findTemplateStart( src: string ): number {\n let\n depth = 0,\n lineStart = true\n\n for( let i = 0; i < src.length; i++ ){\n const c = src[ i ]\n\n // Strings are opaque\n if( c === \"'\" || c === '\"' || c === '`' ){\n const quote = c\n i++\n while( i < src.length && src[ i ] !== quote ){\n if( src[ i ] === '\\\\' ) i++\n i++\n }\n lineStart = false\n continue\n }\n // Comments are opaque\n if( c === '/' && src[ i + 1 ] === '/' ){\n while( i < src.length && src[ i ] !== '\\n' ) i++\n lineStart = true\n continue\n }\n if( c === '/' && src[ i + 1 ] === '*' ){\n const end = src.indexOf( '*/', i + 2 )\n i = end === -1 ? src.length : end + 1\n continue\n }\n\n if( c === '\\n' ){ lineStart = true; continue }\n\n if( lineStart && depth === 0 && c === '<' && /[A-Za-z{>!]/.test( src[ i + 1 ] || '' ) )\n return i\n\n if( c === '(' || c === '[' || c === '{' ) depth++\n else if( c === ')' || c === ']' || c === '}' ) depth = Math.max( 0, depth - 1 )\n\n if( !/\\s/.test( c ) ) lineStart = false\n }\n\n return 0 // no script section — whole source is template\n}\n",
|
|
6
|
+
"/**\n * Phase 2 — IR compiler (RFC-001 §4)\n *\n * TemplateAST → TemplateIR:\n * - static HTML skeletons per block, ready for one-time <template>\n * parsing + per-instance cloneNode\n * - integer-path bind table (childNodes index walks — no string paths)\n * - control-flow block nodes anchored by comment placeholders whose\n * paths are precomputed (the compiler simulates browser text-node\n * coalescing so paths survive the HTML round-trip)\n * - deduped expression table; every authored expression is validated\n * at compile time and its diagnostics re-anchored to template\n * line/col\n *\n * The output is JSON-serializable and deterministic — it is the\n * Modela artifact, the runtime render program, and the hot-swap\n * diff unit.\n *\n * With `target: 'tree'` every block also carries `nodes`, the same\n * skeleton as a structural tree, for hosts that build nodes one by\n * one rather than parse markup (RFC-006 §4.1).\n */\n\nimport type {\n TemplateNode,\n ElementNode,\n AttrNode,\n ExprSlot,\n TemplateDiagnostic\n} from './parser'\nimport { parseTemplate } from './parser'\nimport { parseExpression } from './expression'\n\n// ------------------------------------------------------------------- types\nexport type Path = number[]\nexport type E = number\n\nexport type CompInput =\n | { e: E }\n | { lit: unknown }\n\nexport interface TemplateIR {\n v: 1\n exprs: string[]\n root: BlockIR\n}\n\n/**\n * One node of a block's structural skeleton (RFC-006 §4.1): the tree\n * `html` encodes, for hosts with no HTML parser. Bind and block paths\n * index it exactly as they index the parsed `html`.\n *\n * 'text' a static text run\n * 0 an anchor — where a text bind or a block attaches\n * [ tag, attrs?, children? ] an element and its static attributes\n */\nexport type NodeIR = string | 0 | [ tag: string, attrs?: Record<string, string>, children?: NodeIR[] ]\n\nexport interface BlockIR {\n html: string\n /** The skeleton as a tree — present when compiled with `target: 'tree'` */\n nodes?: NodeIR[]\n /**\n * Scope variable names visible to this block's binds\n * (iterator args, async arm args, let/const names —\n * let names are block-scoped from block start, see RFC)\n */\n scope: string[]\n binds: BindIR[]\n blocks: ChildIR[]\n}\n\n/**\n * `i18n` marks a bind as translatable; `ik` carries the STABLE key to\n * look it up by (RFC-005 §3). Without `ik` the rendered text is its own\n * key — reword the source and the translation is orphaned.\n */\nexport type BindIR =\n | { t: 'text', p: Path, e: E, i18n?: 1, ik?: string } // anchor; runtime inserts a text node after it\n | { t: 'attr', p: Path, name: string, e: E, i18n?: 1, ik?: string }\n | { t: 'prop', p: Path, name: string, e: E, i18n?: 1, ik?: string, ref?: string } // @html / @text / @format\n | { t: 'event', p: Path, name: string, e: E } // raw instruction — runtime resolves handler form\n | { t: 'spread', p: Path, e: E }\n\nexport interface ArmIR {\n args: string[]\n block: BlockIR\n}\n\n/**\n * One macro call-site assignment, in SOURCE ORDER so later\n * entries override earlier ones (`<option key=k ...each/>` —\n * the spread wins over `key` for keys it contains).\n */\nexport type MacroSet =\n | { name: string, ci: CompInput }\n | { spread: E }\n\nexport type ChildIR =\n | { t: 'macro', p: Path, name: string, sets: MacroSet[], args: string[], block: BlockIR }\n | { t: 'if', p: Path, branches: { when: E | null, block: BlockIR }[] }\n | { t: 'for', p: Path, of?: E, from?: CompInput, to?: CompInput, by?: CompInput, args: string[], block: BlockIR }\n | { t: 'switch', p: Path, on: E, cases: { is: CompInput | null, block: BlockIR }[] }\n | { t: 'async', p: Path, awaitE: E, then?: ArmIR, catch?: ArmIR, loading?: BlockIR }\n | { t: 'let', p: Path, const: boolean, vars: Record<string, CompInput> }\n | { t: 'log', p: Path, e: E }\n /**\n * `<context …>` / `<i18n lang=…>` — a context layer over the subtree\n * (RFC-005 §4). `vars` are the provided keys; `lang` is the scoped\n * language. One IR kind, two spellings: they differ only in which\n * field they fill.\n */\n | { t: 'provide', p: Path, vars: Record<string, CompInput>, lang?: CompInput, block: BlockIR }\n | { t: 'comp', p: Path, name: string, inputs: Record<string, CompInput>, spreads: E[], events: { name: string, e: E }[], contents?: ArmIR }\n | { t: 'dynamic', p: Path, tag: E, inputs: Record<string, CompInput>, spreads: E[], events: { name: string, e: E }[], contents?: ArmIR }\n\nexport interface CompileResult {\n ir: TemplateIR\n diagnostics: TemplateDiagnostic[]\n}\n\nexport interface CompileOptions {\n /** `<macro [argv] name=\"X\">…</macro>` definitions, inlined at call sites */\n macros?: string\n /**\n * The kind of host the IR is for. `'dom'` (default) needs only the\n * `html` skeletons. `'tree'` is for hosts with no HTML parser\n * (RFC-006 §4.1): blocks also carry `nodes`, comments are dropped\n * (they mean nothing off the DOM), and `@html` is an error.\n */\n target?: 'dom' | 'tree'\n /**\n * Rewrites the parsed template before it compiles, reporting into\n * `diagnostics` — how a host adapts the HTML-shaped vocabulary\n * (`compileLynxTemplate`, RFC-006 §4.3). Macro bodies are not passed.\n */\n transform?: ( nodes: TemplateNode[], diagnostics: TemplateDiagnostic[] ) => void\n /**\n * Inspects — and may rewrite — the parsed template AND the macros\n * source before either compiles, reporting into `diagnostics` located\n * against `src`, the source the nodes came from. How an untrusted\n * template is held to its policy (RFC-007 §5.1): a refusal is reported\n * where it is written, and the refused construct never compiles.\n */\n check?: ( nodes: TemplateNode[], diagnostics: TemplateDiagnostic[], src: string ) => void\n}\n\ninterface MacroDef {\n name: string\n argv: string[]\n children: TemplateNode[]\n}\n\n// ------------------------------------------------------------------ tables\nconst ANCHOR = '<!--$-->'\n\nexport const CONTROL_TAGS = new Set([\n 'if', 'else-if', 'else', 'for', 'switch', 'async', 'let', 'const', 'log',\n // RFC-005 §4 — scoped context / scoped language\n 'context', 'i18n'\n])\nexport const ARM_TAGS = new Set([ 'case', 'default', 'then', 'catch', 'loading' ])\n\n/** Standard HTML + common SVG tags — anything else is a component candidate */\nexport const HTML_TAGS = new Set([\n 'a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo',\n 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col',\n 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl',\n 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2',\n 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img',\n 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu',\n 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p',\n 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section',\n 'select', 'slot', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup',\n 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title',\n 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr',\n // SVG\n 'svg', 'circle', 'clippath', 'defs', 'ellipse', 'foreignobject', 'g', 'image', 'line',\n 'lineargradient', 'marker', 'mask', 'path', 'pattern', 'polygon', 'polyline',\n 'radialgradient', 'rect', 'stop', 'symbol', 'text', 'tspan', 'use'\n])\n\nconst VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr'\n])\n\n// ----------------------------------------------------------------- helpers\nconst escText = ( s: string ) => s.replace( /&/g, '&' ).replace( /</g, '<' ).replace( />/g, '>' )\nconst escAttr = ( s: string ) => s.replace( /&/g, '&' ).replace( /\"/g, '"' ).replace( /</g, '<' )\n\nconst isNumeric = ( s: string ) => s !== '' && !isNaN( Number( s ) )\n\n/**\n * Does this source denote an OBJECT LITERAL rather than a value?\n *\n * Two spellings arrive here and both are the same React habit:\n *\n * style=\"{ margin: '3rem' }\" — braces eaten as an interpolation slot,\n * so the source is bare `margin: '3rem'`\n * style={{ margin: '3rem' }} — a real object expression\n *\n * The discriminator is a top-level `:` reached before any top-level `?`,\n * which is what keeps the forms that DO work out of it: a ternary\n * (`{state.on ? 'color:red' : ''}`), `??` and `?.` all hit the `?` first,\n * and a `:` inside a string (`{!state.on && 'color: red'}`) is skipped.\n */\nconst isObjectLiteral = ( src: string ): boolean => {\n const s = src.trim()\n let depth = 0\n\n for( let i = 0; i < s.length; i++ ){\n const c = s[ i ]\n\n if( c === \"'\" || c === '\"' || c === '`' ){\n i++\n while( i < s.length && s[ i ] !== c ){\n if( s[ i ] === '\\\\' ) i++\n i++\n }\n continue\n }\n\n if( c === '(' || c === '[' || c === '{' ) depth++\n else if( c === ')' || c === ']' || c === '}' ){\n depth--\n // A leading `{` that closes on the last char wraps the whole value\n if( depth === 0 && s[ 0 ] === '{' && i === s.length - 1 )\n return isObjectLiteral( s.slice( 1, -1 ) )\n }\n else if( depth === 0 ){\n if( c === '?' ) return false\n if( c === ':' ) return true\n }\n }\n return false\n}\n\n/**\n * The attribute's value as ONE expression source, or '' when it is not a\n * single bare expression. `width: {state.w}px` has literal text around\n * its slot, so it is CSS with a value interpolated in — not a candidate.\n */\nconst objectishAttr = ( attr: AttrNode ) => {\n if( attr.k === 'expr' ) return attr.source\n if( attr.k !== 'interp' ) return ''\n\n const slots = attr.parts.filter( ( p ): p is ExprSlot => typeof p !== 'string' )\n\n return slots.length === 1\n && attr.parts.every( p => typeof p !== 'string' || !p.trim() )\n ? slots[ 0 ].expr\n : ''\n}\n\n// ---------------------------------------------------------------- compiler\nclass Compiler {\n private exprs: string[] = []\n private exprIndex = new Map<string, E>()\n private lineStarts: number[] | null = null\n /** Guards against macros that (indirectly) call themselves */\n private macroStack: string[] = []\n\n readonly diagnostics: TemplateDiagnostic[] = []\n\n constructor(\n private src: string,\n private macros = new Map<string, MacroDef>(),\n /** `target: 'tree'` — emit `BlockIR.nodes` alongside `html` */\n private tree = false\n ){}\n\n // ---- diagnostics\n private locate( offset: number ){\n if( !this.lineStarts ){\n this.lineStarts = [ 0 ]\n for( let i = 0; i < this.src.length; i++ )\n if( this.src[ i ] === '\\n' ) this.lineStarts.push( i + 1 )\n }\n\n let lo = 0, hi = this.lineStarts.length - 1\n while( lo < hi ){\n const mid = ( lo + hi + 1 ) >> 1\n this.lineStarts[ mid ] <= offset ? lo = mid : hi = mid - 1\n }\n\n return { line: lo + 1, col: offset - this.lineStarts[ lo ] + 1 }\n }\n private report( code: string, severity: 'error' | 'warning', message: string, offset: number, length = 1, hint?: string ){\n const { line, col } = this.locate( offset )\n this.diagnostics.push({ code, severity, message, hint, loc: { line, col, offset, length } })\n }\n\n // ---- expression table\n /** Register an authored expression: validate + dedupe */\n private expr( source: string, at?: { offset: number, length?: number } ): E {\n const cached = this.exprIndex.get( source )\n if( cached !== undefined ) return cached\n\n const { diagnostics } = parseExpression( source )\n for( const d of diagnostics ){\n const offset = ( at?.offset ?? 0 ) + d.loc.offset\n this.report( d.code, 'error', d.message, offset, d.loc.length )\n }\n\n const idx = this.exprs.length\n this.exprs.push( source )\n this.exprIndex.set( source, idx )\n return idx\n }\n /** Register a synthesized expression (parts already validated) */\n private synth( source: string ): E {\n const cached = this.exprIndex.get( source )\n if( cached !== undefined ) return cached\n\n const idx = this.exprs.length\n this.exprs.push( source )\n this.exprIndex.set( source, idx )\n return idx\n }\n /**\n * Interpolation parts → one concat expression.\n * Nullish parts render '' (RFC decision #4).\n */\n private concat( parts: ( string | ExprSlot )[] ): E {\n parts\n .filter( ( p ): p is ExprSlot => typeof p !== 'string' )\n .forEach( p => {\n const { diagnostics } = parseExpression( p.expr )\n for( const d of diagnostics )\n this.report( d.code, 'error', d.message, p.loc.offset + d.loc.offset, d.loc.length )\n })\n\n const source = parts\n .map( p => typeof p === 'string' ? JSON.stringify( p ) : `((${p.expr})??\"\")` )\n .join('+')\n\n return this.synth( source )\n }\n private compInput( attr: AttrNode & { k: 'literal' | 'expr' | 'interp' | 'bool' } ): CompInput {\n switch( attr.k ){\n case 'literal': return { lit: attr.value }\n case 'bool': return { lit: attr.value }\n case 'expr': return { e: this.expr( attr.source, attr.loc ) }\n case 'interp': return { e: this.concat( attr.parts ) }\n }\n }\n\n // ---- entry\n compile( children: TemplateNode[] ): TemplateIR {\n return { v: 1, exprs: this.exprs, root: this.block( children, [] ) }\n }\n\n /**\n * Compile a node list into a BlockIR: static HTML with\n * precomputed paths for every bind/anchor. `scope` may\n * grow when <let>/<const> introduce names.\n */\n private block( children: TemplateNode[], scope: string[] ): BlockIR {\n const\n block: BlockIR = { html: '', scope: [ ...scope ], binds: [], blocks: [] },\n html: string[] = [],\n tree = this.tree,\n roots: NodeIR[] = []\n\n /**\n * Emit a sibling list at `path` depth. Returns nothing —\n * appends to html / block.binds / block.blocks, and to `kids`\n * (this level of the node tree) for the tree target.\n * The index simulation must match browser parsing:\n * consecutive static text coalesces into ONE node — and the node\n * tree coalesces the same way, so one path fits both.\n */\n const emitSiblings = ( nodes: TemplateNode[], path: Path, kids: NodeIR[], i18nParent = false, i18nKey?: string ) => {\n let index = 0\n let lastWasText = false\n\n const anchor = (): Path => {\n html.push( ANCHOR )\n tree && kids.push( 0 )\n lastWasText = false\n return [ ...path, index++ ]\n }\n\n for( let i = 0; i < nodes.length; i++ ){\n const node = nodes[ i ]\n\n switch( node.t ){\n case 'text': {\n /**\n * Static text under an `i18n` element still needs a\n * bind — there is nothing to translate in a skeleton.\n */\n if( i18nParent ){\n const bind: BindIR = { t: 'text', p: anchor(), e: this.synth( JSON.stringify( node.value ) ), i18n: 1 }\n if( i18nKey ) bind.ik = i18nKey\n block.binds.push( bind )\n break\n }\n\n html.push( escText( node.value ) )\n tree && ( lastWasText ? kids[ kids.length - 1 ] += node.value : kids.push( node.value ) )\n if( !lastWasText ) index++\n lastWasText = true\n break\n }\n case 'comment': {\n /**\n * Dropped from BOTH forms for the tree target, so the text\n * on either side coalesces alike and paths still agree.\n */\n if( tree ) break\n\n /**\n * Round-trip it as ONE comment. `--` would close it early, and\n * a leading `>` or `->` makes `<!-->` / `<!--->` — an empty\n * comment for the browser, followed by the rest as markup.\n */\n const text = node.value.replace( /--/g, '- -' )\n html.push( `<!--${ /^-?>/.test( text ) ? ' ' + text : text }-->` )\n lastWasText = false\n index++\n break\n }\n case 'interp': {\n const bind: BindIR = { t: 'text', p: anchor(), e: this.concat( node.parts ) }\n if( i18nParent ) bind.i18n = 1\n if( i18nParent && i18nKey ) bind.ik = i18nKey\n block.binds.push( bind )\n break\n }\n case 'fragment': {\n /**\n * Nested fragments are transparent: children emit\n * into the current index space. Rebuild sibling\n * numbering by splicing children inline.\n */\n nodes = [ ...nodes.slice( 0, i ), ...node.children, ...nodes.slice( i + 1 ) ]\n i--\n break\n }\n case 'element': {\n // Control flow → anchored child block\n if( CONTROL_TAGS.has( node.tag ) ){\n this.controlBlock( node, nodes, i, anchor(), block, scope )\n\n // if-chains consume their else-if/else siblings\n if( node.tag === 'if' ){\n let j = i + 1\n while( j < nodes.length ){\n const sib = nodes[ j ]\n if( sib.t === 'element' && ( sib.tag === 'else-if' || sib.tag === 'else' ) ) j++\n else break\n }\n nodes = [ ...nodes.slice( 0, i + 1 ), ...nodes.slice( j ) ]\n }\n break\n }\n\n // Arm tags outside their parents\n if( ARM_TAGS.has( node.tag ) ){\n this.report( 'LIPS-C002', 'error',\n `<${node.tag}> is only valid inside its parent construct`, node.loc.offset, node.loc.length )\n break\n }\n\n // Dynamic tag\n if( node.tag === '#dynamic' ){\n block.blocks.push( this.compLike( node, anchor(), scope, 'dynamic' ) )\n break\n }\n\n // Macro call → inline the definition body\n if( this.macros.has( node.tag ) ){\n const macroBlock = this.macroCall( node, anchor(), scope )\n macroBlock && block.blocks.push( macroBlock )\n break\n }\n\n // Component candidate\n if( !HTML_TAGS.has( node.tag ) ){\n block.blocks.push( this.compLike( node, anchor(), scope, 'comp' ) )\n break\n }\n\n // Plain HTML element\n this.emitElement( node, path, index++, html, block, emitSiblings, kids )\n lastWasText = false\n break\n }\n }\n }\n }\n\n emitSiblings( children, [], roots )\n block.html = html.join('')\n if( tree ) block.nodes = roots\n return block\n }\n\n /** Static open tag + dynamic binds + children recursion */\n private emitElement(\n node: ElementNode,\n path: Path,\n index: number,\n html: string[],\n block: BlockIR,\n emitSiblings: ( nodes: TemplateNode[], path: Path, kids: NodeIR[], i18nParent?: boolean, i18nKey?: string ) => void,\n kids: NodeIR[]\n ){\n const p: Path = [ ...path, index ]\n let open = `<${node.tag}`\n\n /**\n * Tree target: the same element as a node. A repeated attribute\n * keeps its FIRST value, which is what the HTML parser does with\n * the `html` form.\n */\n const\n el: [ string, Record<string, string>?, NodeIR[]? ] = [ node.tag ],\n attrs: Record<string, string> = {},\n put = ( name: string, value: string ) => {\n Object.prototype.hasOwnProperty.call( attrs, name ) || ( attrs[ name ] = value )\n }\n this.tree && kids.push( el )\n\n /**\n * `i18n` marks an element's own text and its visual\n * attributes (title/placeholder) as translatable.\n */\n /** `args` (`[a,b]`) is the one attribute form with no name */\n const named = node.attrs.filter( a => 'name' in a ) as ( AttrNode & { name: string } )[]\n\n const i18n = named.some( a =>\n a.name === 'i18n' && ( ( a.k === 'bool' && a.value ) || a.k === 'literal' ) )\n const translatableAttr = ( name: string ) => i18n && ( name === 'title' || name === 'placeholder' )\n\n /**\n * Stable translation ids (RFC-005 §3).\n *\n * <h1 i18n=\"hero.title\">Welcome</h1>\n * <input i18n i18n-placeholder=\"search.hint\" placeholder=\"Search…\">\n *\n * `i18n=\"key\"` ids the element's own text; `i18n-<attr>=\"key\"` ids\n * that attribute. Bare `i18n` keeps the gettext model where the\n * source text is the key — fine when a human owns the wording,\n * lossy when a generator rewrites it.\n */\n const keyOf = ( name: string ) => {\n const a = named.find( x => x.name === name && x.k === 'literal' )\n return a && 'value' in a && a.value ? String( a.value ) : undefined\n }\n const textKey = keyOf('i18n')\n const attrKey = ( name: string ) => keyOf(`i18n-${name}`)\n\n /** `i18n-<attr>` on an element that never opted in translates nothing */\n !i18n && named.some( a => a.name.startsWith('i18n-') )\n && this.report( 'LIPS-C014', 'warning',\n `i18n-* key on <${node.tag}> without the 'i18n' marker — the attribute will not be translated`,\n node.loc.offset, node.loc.length )\n\n for( const attr of node.attrs ){\n /**\n * `@html` hands markup to the host's HTML parser. A tree host has\n * none, so the bind could only ever render as text — say so here\n * rather than let the content arrive silently unparsed.\n */\n if( this.tree && 'name' in attr && attr.name === '@html' ){\n this.report( 'LIPS-C021', 'error',\n `@html on <${node.tag}>: the 'tree' target has no HTML parser`,\n attr.loc.offset, attr.loc.length,\n 'Write the markup in the template, or use @text' )\n continue\n }\n\n /**\n * On an ELEMENT, `style=` is CSS text — `{…}` in it is an\n * interpolation slot, so a React-style object literal never reaches\n * the DOM: it goes to the expression compiler, which rejects the\n * `:` (LIPS-E003, naming the token and not the mistake) and the\n * element renders unstyled. Say what the fix is instead.\n *\n * Components are untouched: there `style` is an input like any\n * other, and an object is a perfectly good value for it.\n */\n if( 'name' in attr && attr.name === 'style' ){\n const source = objectishAttr( attr )\n\n if( source && isObjectLiteral( source ) ){\n this.report( 'LIPS-C019', 'error',\n `style= on <${node.tag}> takes CSS text, not an object literal`,\n attr.loc.offset, attr.loc.length,\n 'Write the declarations as CSS — style=\"border: 2px solid gray; margin: 3rem\" — '\n + 'and interpolate values into it where they vary: style=\"margin: {state.gap}rem\". '\n + 'Styles that need pseudo-classes, media queries or keyframes belong in the '\n + \"component's stylesheet.\" )\n continue\n }\n }\n\n // Quoted handler — reported and dropped, never emitted as a dead attribute\n if( this.quotedEvent( node.tag, attr ) ) continue\n\n switch( attr.k ){\n case 'literal':\n if( attr.name === '@format' ){\n block.binds.push( this.formatBind( p, attr ) )\n break\n }\n if( attr.name.startsWith('@') ){\n block.binds.push({ t: 'prop', p, name: attr.name.slice( 1 ), e: this.synth( JSON.stringify( attr.value ) ) })\n break\n }\n // `i18n=\"key\"` / `i18n-<attr>=\"key\"` are directives, not output\n if( attr.name === 'i18n' || attr.name.startsWith('i18n-') ) break\n // Literal title/placeholder under i18n must become a bind to be translated\n if( translatableAttr( attr.name ) ){\n const bind: BindIR = { t: 'attr', p, name: attr.name, e: this.synth( JSON.stringify( attr.value ) ), i18n: 1 }\n const k = attrKey( attr.name )\n if( k ) bind.ik = k\n block.binds.push( bind )\n break\n }\n open += ` ${attr.name}=\"${escAttr( attr.value )}\"`\n put( attr.name, attr.value )\n break\n case 'bool':\n // `i18n` is a compiler directive, not an output attribute\n if( attr.name !== 'i18n' && attr.value ){\n open += ` ${attr.name}`\n put( attr.name, '' )\n }\n break\n case 'expr': {\n if( attr.name === '@format' ){\n block.binds.push( this.formatBind( p, attr ) )\n break\n }\n if( attr.name.startsWith('@') ){\n block.binds.push({ t: 'prop', p, name: attr.name.slice( 1 ), e: this.expr( attr.source, attr.loc ) })\n break\n }\n\n const bind: BindIR = { t: 'attr', p, name: attr.name, e: this.expr( attr.source, attr.loc ) }\n if( translatableAttr( attr.name ) ){\n bind.i18n = 1\n const k = attrKey( attr.name )\n if( k ) bind.ik = k\n }\n block.binds.push( bind )\n break\n }\n case 'interp': {\n if( attr.name === '@format' ){\n block.binds.push( this.formatBind( p, attr ) )\n break\n }\n /**\n * `@text=\"Row {i + 1}\"` — an @-prop whose value INTERPOLATES.\n * Without this it fell through to the attribute branch and set a\n * literal `@text` attribute on the element, so the prop it names\n * was never written and nothing rendered.\n */\n if( attr.name.startsWith('@') ){\n block.binds.push({ t: 'prop', p, name: attr.name.slice( 1 ), e: this.concat( attr.parts ) })\n break\n }\n\n const bind: BindIR = { t: 'attr', p, name: attr.name, e: this.concat( attr.parts ) }\n if( translatableAttr( attr.name ) ){\n bind.i18n = 1\n const k = attrKey( attr.name )\n if( k ) bind.ik = k\n }\n block.binds.push( bind )\n break\n }\n case 'event':\n block.binds.push({ t: 'event', p, name: attr.name, e: this.synth( attr.source ) })\n break\n case 'spread':\n block.binds.push({ t: 'spread', p, e: this.expr( attr.source, attr.loc ) })\n break\n case 'fn':\n this.report( 'LIPS-C007', 'warning',\n `Callable attribute '${attr.name}(…)' has no meaning on <${node.tag}>`, attr.loc.offset, attr.loc.length )\n break\n case 'args':\n this.report( 'LIPS-C008', 'warning',\n `Iterator arguments are not applicable to <${node.tag}>`, attr.loc.offset, attr.loc.length )\n break\n }\n }\n\n const kept = Object.keys( attrs ).length\n kept && ( el[ 1 ] = attrs )\n\n if( VOID_ELEMENTS.has( node.tag ) ){\n html.push( open + '>' )\n return\n }\n\n html.push( open + '>' )\n\n /**\n * A key ids ONE FIXED string. Two shapes break that:\n *\n * <h1 i18n=\"k\">Hello {state.name}</h1> — interpolated\n * <h1 i18n=\"k\">a<b>x</b>c</h1> — several text runs\n *\n * In the first the key would resolve the whole entry and silently\n * drop the interpolated value; in the second every run would render\n * the same translation. Both are what `@format` exists for — it\n * takes a reference AND params — so name it and fall back to\n * source-text keying rather than emit something wrong.\n */\n let key = textKey\n const runs = node.children.filter( c => c.t === 'text' || c.t === 'interp' )\n if( key && ( runs.length > 1 || runs.some( c => c.t === 'interp' ) ) ){\n this.report( 'LIPS-C015', 'error',\n `<${node.tag} i18n=\"${key}\"> keys text that is not a single fixed string. `\n + `Use @format=\"${key}, { … }\" for interpolated text.`,\n node.loc.offset, node.loc.length )\n key = undefined\n }\n\n const children: NodeIR[] = []\n node.children.length && emitSiblings( node.children, p, children, i18n, key )\n if( children.length ){\n el[ 1 ] = attrs // `{}` when there are none: children sit at index 2\n el[ 2 ] = children\n }\n html.push( `</${node.tag}>` )\n }\n\n /**\n * `@format=\"reference, { params }\"` → a prop bind carrying the\n * dictionary reference plus a compiled params expression.\n */\n private formatBind( p: Path, attr: AttrNode & { k: 'literal' | 'expr' | 'interp' } ): BindIR {\n /**\n * `@format` carries a reference plus a params OBJECT, so the\n * braces are data — not interpolation. Reconstruct the raw\n * source when the parser split it into interpolation parts.\n */\n const raw = attr.k === 'literal' ? attr.value\n : attr.k === 'expr' ? attr.source\n : attr.parts.map( part => typeof part === 'string' ? part : `{${part.expr}}` ).join('')\n\n const comma = raw.indexOf(',')\n\n if( comma === -1 ){\n this.report( 'LIPS-C012', 'error',\n `@format expects \"reference, { params }\"`, attr.loc.offset, attr.loc.length )\n return { t: 'prop', p, name: 'format', e: this.synth('({})'), ref: raw.trim() }\n }\n\n const\n ref = raw.slice( 0, comma ).trim(),\n params = raw.slice( comma + 1 ).trim()\n\n return { t: 'prop', p, name: 'format', e: this.expr( params, attr.loc ), ref }\n }\n\n // ---- control-flow blocks\n private attrsOf( node: ElementNode ){\n const\n byName = new Map<string, AttrNode>(),\n args: string[] = []\n\n for( const attr of node.attrs ){\n if( attr.k === 'args' ) args.push( ...attr.names )\n else if( 'name' in attr ) byName.set( attr.name, attr )\n }\n return { byName, args }\n }\n\n private controlBlock( node: ElementNode, siblings: TemplateNode[], i: number, p: Path, block: BlockIR, scope: string[] ){\n switch( node.tag ){\n case 'if': {\n const branches: { when: E | null, block: BlockIR }[] = [{\n when: node.head ? this.expr( node.head.expr, node.head.loc ) : this.missingHead( node ),\n block: this.block( node.children, scope )\n }]\n\n for( let j = i + 1; j < siblings.length; j++ ){\n const sib = siblings[ j ]\n if( sib.t !== 'element' ) break\n\n if( sib.tag === 'else-if' )\n branches.push({\n when: sib.head ? this.expr( sib.head.expr, sib.head.loc ) : this.missingHead( sib ),\n block: this.block( sib.children, scope )\n })\n else if( sib.tag === 'else' ){\n branches.push({ when: null, block: this.block( sib.children, scope ) })\n break\n }\n else break\n }\n\n block.blocks.push({ t: 'if', p, branches })\n break\n }\n\n case 'else-if':\n case 'else':\n this.report( 'LIPS-C001', 'error', `<${node.tag}> without a preceding <if>`, node.loc.offset, node.loc.length )\n break\n\n case 'for': {\n const { byName, args } = this.attrsOf( node )\n const\n inAttr = byName.get('in'),\n fromAttr = byName.get('from'),\n toAttr = byName.get('to'),\n byAttr = byName.get('by')\n\n if( !inAttr && !fromAttr ){\n this.report( 'LIPS-C004', 'error', `<for> requires 'in' or 'from'/'to'`, node.loc.offset, node.loc.length )\n break\n }\n\n const child: ChildIR = {\n t: 'for', p, args,\n block: this.block( node.children, [ ...scope, ...args ] )\n }\n if( inAttr && inAttr.k === 'expr' ) child.of = this.expr( inAttr.source, inAttr.loc )\n if( fromAttr ) child.from = this.numInput( fromAttr )\n if( toAttr ) child.to = this.numInput( toAttr )\n if( byAttr && ( byAttr.k === 'literal' || byAttr.k === 'expr' ) )\n child.by = byAttr.k === 'literal' ? { lit: byAttr.value } : { e: this.expr( byAttr.source, byAttr.loc ) }\n\n block.blocks.push( child )\n break\n }\n\n case 'switch': {\n const on = node.head ? this.expr( node.head.expr, node.head.loc ) : this.missingHead( node )\n const cases: { is: CompInput | null, block: BlockIR }[] = []\n\n for( const child of node.children ){\n if( child.t !== 'element' ) continue\n\n if( child.tag === 'case' ){\n const { byName } = this.attrsOf( child )\n const isAttr = byName.get('is')\n\n if( !isAttr || ( isAttr.k !== 'literal' && isAttr.k !== 'expr' ) ){\n this.report( 'LIPS-C004', 'error', `<case> requires an 'is' attribute`, child.loc.offset, child.loc.length )\n continue\n }\n cases.push({\n is: isAttr.k === 'literal' ? { lit: isAttr.value } : { e: this.expr( isAttr.source, isAttr.loc ) },\n block: this.block( child.children, scope )\n })\n }\n else if( child.tag === 'default' )\n cases.push({ is: null, block: this.block( child.children, scope ) })\n else\n this.report( 'LIPS-C003', 'error', `Only <case>/<default> are valid inside <switch>`, child.loc.offset, child.loc.length )\n }\n\n block.blocks.push({ t: 'switch', p, on, cases })\n break\n }\n\n case 'async': {\n const awaitAttr = node.attrs.find( a => a.k === 'fn' && a.name === 'await' ) as ( AttrNode & { k: 'fn' } ) | undefined\n if( !awaitAttr ){\n this.report( 'LIPS-C004', 'error', `<async> requires await(…)`, node.loc.offset, node.loc.length )\n break\n }\n\n const child: ChildIR = { t: 'async', p, awaitE: this.expr( awaitAttr.source, awaitAttr.loc ) }\n\n for( const arm of node.children ){\n if( arm.t !== 'element' ) continue\n const { args } = this.attrsOf( arm )\n\n if( arm.tag === 'then' ) child.then = { args, block: this.block( arm.children, [ ...scope, ...args ] ) }\n else if( arm.tag === 'catch' ) child.catch = { args, block: this.block( arm.children, [ ...scope, ...args ] ) }\n else if( arm.tag === 'loading' ) child.loading = this.block( arm.children, scope )\n else this.report( 'LIPS-C003', 'error', `Only <then>/<catch>/<loading> are valid inside <async>`, arm.loc.offset, arm.loc.length )\n }\n\n block.blocks.push( child )\n break\n }\n\n case 'let':\n case 'const': {\n const vars: Record<string, CompInput> = {}\n\n for( const attr of node.attrs ){\n /**\n * Spread on <let> cannot work with compiled expressions:\n * the spread's keys are unknown at compile time, so binds\n * referencing them as bare identifiers can never resolve.\n * Assign the object to ONE name instead.\n */\n if( attr.k === 'spread' ){\n this.report( 'LIPS-C013', 'error',\n `Spread is not supported on <${node.tag}> — scope names must be known at compile time`,\n attr.loc.offset, attr.loc.length,\n `Assign it to one variable: <${node.tag} obj={ ${attr.source} }/> and read obj.<key>` )\n continue\n }\n\n if( attr.k === 'literal' || attr.k === 'expr' || attr.k === 'interp' || attr.k === 'bool' ){\n vars[ attr.name ] = this.compInput( attr )\n /**\n * RFC decision #1: let/const names are block-scoped\n * (visible to every bind of the enclosing block)\n */\n !block.scope.includes( attr.name ) && block.scope.push( attr.name )\n !scope.includes( attr.name ) && scope.push( attr.name )\n }\n }\n\n block.blocks.push({ t: 'let', p, const: node.tag === 'const', vars })\n break\n }\n\n case 'log':\n /**\n * A log head is an argument LIST (like an event\n * instruction), not a single expression — the\n * runtime resolves it; no single-expr validation.\n */\n block.blocks.push({ t: 'log', p, e: node.head ? this.synth( node.head.expr ) : this.missingHead( node ) })\n break\n\n /**\n * Scoped context (RFC-005 §4):\n *\n * <context selection=state.sel tool=state.tool> … </context>\n *\n * Every attribute becomes a context key visible to the subtree —\n * components included — shadowing the global store for that key\n * only. Unlike `<let>`, the names do NOT enter expression scope:\n * they are read as `context.selection`, which is what makes a\n * child component see them without the parent passing inputs.\n */\n case 'context': {\n const vars: Record<string, CompInput> = {}\n\n for( const attr of node.attrs ){\n /**\n * Same reasoning as <let>: a spread's keys are unknown at\n * compile time. Here they would also silently fail to shadow\n * anything, since lookup is by name at render.\n */\n if( attr.k === 'spread' ){\n this.report( 'LIPS-C016', 'error',\n `Spread is not supported on <context> — provided keys must be known at compile time`,\n attr.loc.offset, attr.loc.length,\n `Provide them one by one: <context a=obj.a b=obj.b>` )\n continue\n }\n\n if( attr.k === 'literal' || attr.k === 'expr' || attr.k === 'interp' || attr.k === 'bool' )\n vars[ attr.name ] = this.compInput( attr )\n }\n\n if( !Object.keys( vars ).length )\n this.report( 'LIPS-C017', 'warning',\n `<context> provides nothing — it renders its children unchanged`,\n node.loc.offset, node.loc.length )\n\n block.blocks.push({ t: 'provide', p, vars, block: this.block( node.children, scope ) })\n break\n }\n\n /**\n * Scoped language (RFC-005 §4):\n *\n * <i18n lang=state.docLang> … </i18n>\n *\n * The subtree's translatable binds resolve against `lang` instead\n * of the global language — a document pane in the content's\n * language while the chrome stays in the reader's.\n */\n case 'i18n': {\n const { byName } = this.attrsOf( node )\n const langAttr = byName.get('lang')\n\n if( !langAttr ){\n this.report( 'LIPS-C018', 'error',\n `<i18n> requires a 'lang' attribute: <i18n lang=state.docLang>`,\n node.loc.offset, node.loc.length )\n break\n }\n\n block.blocks.push({\n t: 'provide', p, vars: {},\n lang: this.compInput( langAttr as AttrNode & { k: 'literal' | 'expr' | 'interp' | 'bool' } ),\n block: this.block( node.children, scope )\n })\n break\n }\n }\n }\n\n private missingHead( node: ElementNode ): E {\n this.report( 'LIPS-C004', 'error', `<${node.tag}> requires a head expression: <${node.tag}( … )>`, node.loc.offset, node.loc.length )\n return this.synth('undefined')\n }\n private numInput( attr: AttrNode ): CompInput {\n if( attr.k === 'literal' ) return { lit: isNumeric( attr.value ) ? Number( attr.value ) : attr.value }\n if( attr.k === 'expr' ) return isNumeric( attr.source ) ? { lit: Number( attr.source ) } : { e: this.expr( attr.source, attr.loc ) }\n return { lit: undefined }\n }\n\n /**\n * Macro call site → inlined block.\n *\n * Every call-site attribute becomes a block-scoped variable\n * (the macro's declared `argv` are the named ones; all of them\n * together also form `arguments` at runtime).\n */\n private macroCall( node: ElementNode, p: Path, scope: string[] ): ChildIR | null {\n const macro = this.macros.get( node.tag )!\n\n if( this.macroStack.includes( macro.name ) ){\n this.report( 'LIPS-C009', 'error',\n `Recursive macro <${macro.name}> (${[ ...this.macroStack, macro.name ].join(' → ')})`,\n node.loc.offset, node.loc.length )\n return null\n }\n\n /**\n * Assignments in SOURCE ORDER — spreads participate like any\n * other set, so `key=k ...each` lets the spread override `key`\n * while `...each key=k` lets the explicit attr win.\n *\n * Undeclared argv default to `undefined` at runtime: falsy in\n * conditions, attribute-removing, renders '' in text (RFC #4).\n */\n const sets: MacroSet[] = []\n for( const attr of node.attrs ){\n if( attr.k === 'literal' || attr.k === 'expr' || attr.k === 'interp' || attr.k === 'bool' )\n sets.push({ name: attr.name, ci: this.compInput( attr ) })\n else if( attr.k === 'spread' )\n sets.push({ spread: this.expr( attr.source, attr.loc ) })\n }\n\n this.macroStack.push( macro.name )\n const block = this.block( macro.children, [ ...scope, ...macro.argv ] )\n this.macroStack.pop()\n\n return { t: 'macro', p, name: macro.name, sets, args: macro.argv, block }\n }\n\n /** Components and dynamic tags share input/event/spread shape */\n /**\n * `on-click=\"…\"` is NOT an event binding. The parser only produces an\n * `event` attribute for the instruction form `on-x( … )`; quoted, it\n * stays an ordinary attribute, so no listener is wired and the source\n * text lands in the DOM as a dead `on-click=\"() => …\"`. Nothing failed\n * loudly, which is exactly the problem — same class as the `@text=\"…\"`\n * and `style={…}` fall-throughs.\n */\n private quotedEvent( tag: string, attr: AttrNode ){\n if( !( 'name' in attr ) || !attr.name.startsWith('on-') ) return false\n\n this.report( 'LIPS-C020', 'error',\n `${attr.name}=\"…\" on <${tag}> wires no listener`,\n attr.loc.offset, attr.loc.length,\n `Handlers use the instruction form: ${attr.name}( … ). `\n + `Quoted, it is an ordinary attribute — the handler never runs and the source is emitted into the DOM.` )\n return true\n }\n\n private compLike( node: ElementNode, p: Path, scope: string[], kind: 'comp' | 'dynamic' ): ChildIR {\n const\n inputs: Record<string, CompInput> = {},\n spreads: E[] = [],\n events: { name: string, e: E }[] = []\n let args: string[] = []\n\n for( const attr of node.attrs ){\n // A quoted handler on a component is the same dead attribute, as an input\n if( attr.k !== 'event' && this.quotedEvent( node.tag, attr ) ) continue\n\n switch( attr.k ){\n case 'literal': case 'bool': case 'expr': case 'interp':\n inputs[ attr.name ] = this.compInput( attr )\n break\n case 'event':\n events.push({ name: attr.name, e: this.synth( attr.source ) })\n break\n case 'spread':\n spreads.push( this.expr( attr.source, attr.loc ) )\n break\n case 'args':\n args = [ ...args, ...attr.names ]\n break\n case 'fn':\n inputs[ attr.name ] = { e: this.expr( attr.source, attr.loc ) }\n break\n }\n }\n\n const contents: ArmIR | undefined = node.children.length\n ? { args, block: this.block( node.children, [ ...scope, ...args ] ) }\n : undefined\n\n return kind === 'comp'\n ? { t: 'comp', p, name: node.tag, inputs, spreads, events, contents }\n : { t: 'dynamic', p, tag: this.expr( node.dynamicTag!.expr, node.dynamicTag!.loc ), inputs, spreads, events, contents }\n }\n}\n\n// -------------------------------------------------------------------- API\n/** Parse `<macro [argv] name=\"X\">…</macro>` blocks into a lookup */\nfunction parseMacros( src: string, diagnostics: TemplateDiagnostic[], check?: CompileOptions['check'] ){\n const macros = new Map<string, MacroDef>()\n if( !src?.trim() ) return macros\n\n const parsed = parseTemplate( src )\n diagnostics.push( ...parsed.diagnostics )\n check?.( parsed.root.children, diagnostics, src )\n\n for( const node of parsed.root.children ){\n if( node.t !== 'element' ) continue\n\n if( node.tag !== 'macro' ){\n diagnostics.push({\n code: 'LIPS-C010', severity: 'warning',\n message: `Only <macro> definitions are allowed in the macros source — ignoring <${node.tag}>`,\n loc: { line: 1, col: 1, offset: node.loc.offset, length: node.loc.length }\n })\n continue\n }\n\n let name = ''\n const argv: string[] = []\n for( const attr of node.attrs ){\n if( attr.k === 'args' ) argv.push( ...attr.names )\n else if( attr.k === 'literal' && attr.name === 'name' ) name = attr.value\n }\n\n if( !name ){\n diagnostics.push({\n code: 'LIPS-C011', severity: 'error',\n message: `<macro> requires a name attribute`,\n loc: { line: 1, col: 1, offset: node.loc.offset, length: node.loc.length }\n })\n continue\n }\n\n // Tag names arrive lowercased — match call sites case-insensitively\n macros.set( name.toLowerCase(), { name, argv, children: node.children })\n }\n\n return macros\n}\n\nexport function compileTemplate( src: string, options?: CompileOptions ): CompileResult {\n const diagnostics: TemplateDiagnostic[] = []\n const macros = parseMacros( options?.macros || '', diagnostics, options?.check )\n\n const parsed = parseTemplate( src )\n options?.check?.( parsed.root.children, diagnostics, src )\n options?.transform?.( parsed.root.children, diagnostics )\n const compiler = new Compiler( src, macros, options?.target === 'tree' )\n const ir = compiler.compile( parsed.root.children )\n\n return { ir, diagnostics: [ ...diagnostics, ...parsed.diagnostics, ...compiler.diagnostics ] }\n}\n",
|
|
7
|
+
"/**\n * Phase 2 — Expression subsystem (RFC-001 §5)\n *\n * A dedicated parser for the template expression subset with:\n * - positioned, machine-readable diagnostics (never throws)\n * - AST-derived precise dependency paths\n * - two interchangeable executors over the same AST:\n * compiled — one Function per unique expression\n * interpreted — an AST walker that never builds a Function (CSP)\n * Both are for templates you trust. Neither is a boundary: a template\n * you did not write runs under a policy instead (RFC-007, ./policy).\n *\n * Grammar (expression-only, no statements):\n * literals (number, string, boolean, null, undefined), identifiers,\n * member access (incl. optional/computed), calls, unary ! - + and\n * prefix/postfix ++ --, binary arithmetic/relational/equality,\n * && || ??, ternary, arrow functions, assignment (= += -= *= /= %=),\n * array/object literals with spread.\n */\n\n// ---------------------------------------------------------------- diagnostics\nexport interface ExprDiagnostic {\n code: string\n message: string\n loc: { offset: number, length: number }\n}\n\n// ------------------------------------------------------------------------ AST\nexport type Expr =\n | { t: 'lit', v: any }\n /** `at`: where the name (or a member's key) starts in the source — for diagnostics */\n | { t: 'id', name: string, at?: number }\n | { t: 'member', obj: Expr, prop: string | Expr, computed: boolean, optional: boolean, at?: number }\n | { t: 'call', callee: Expr, args: Expr[], optional: boolean }\n | { t: 'unary', op: '!' | '-' | '+', arg: Expr }\n | { t: 'update', op: '++' | '--', arg: Expr, prefix: boolean }\n | { t: 'bin', op: string, l: Expr, r: Expr }\n | { t: 'logic', op: '&&' | '||' | '??', l: Expr, r: Expr }\n | { t: 'cond', test: Expr, cons: Expr, alt: Expr }\n | { t: 'assign', op: string, target: Expr, value: Expr }\n | { t: 'arrow', params: string[], body: Expr }\n | { t: 'arr', items: { spread?: boolean, value: Expr }[] }\n | { t: 'obj', props: { key?: string, value: Expr, spread?: boolean, at?: number }[] }\n | { t: 'error' }\n\n// ------------------------------------------------------------------ tokenizer\ntype Token = {\n t: 'num' | 'str' | 'id' | 'punct' | 'eof'\n value: string\n start: number\n end: number\n}\n\nconst PUNCTS = [\n '===', '!==', '...', '=>', '==', '!=', '<=', '>=', '&&', '||', '??', '?.',\n '++', '--', '+=', '-=', '*=', '/=', '%=',\n '+', '-', '*', '/', '%', '<', '>', '!', '?', ':', '.', ',', '(', ')',\n '[', ']', '{', '}', '='\n]\n\nfunction tokenize( src: string, diagnostics: ExprDiagnostic[] ): Token[] {\n const tokens: Token[] = []\n let i = 0\n\n const isIdStart = ( c: string ) => /[A-Za-z_$]/.test( c )\n const isIdChar = ( c: string ) => /[A-Za-z0-9_$]/.test( c )\n\n while( i < src.length ){\n const c = src[ i ]\n\n if( /\\s/.test( c ) ){ i++; continue }\n\n // Numbers: int, float, exponent\n if( /[0-9]/.test( c ) || ( c === '.' && /[0-9]/.test( src[ i + 1 ] ) ) ){\n const start = i\n while( i < src.length && /[0-9]/.test( src[ i ] ) ) i++\n if( src[ i ] === '.' ){ i++; while( i < src.length && /[0-9]/.test( src[ i ] ) ) i++ }\n if( src[ i ] === 'e' || src[ i ] === 'E' ){\n i++\n if( src[ i ] === '+' || src[ i ] === '-' ) i++\n while( i < src.length && /[0-9]/.test( src[ i ] ) ) i++\n }\n tokens.push({ t: 'num', value: src.slice( start, i ), start, end: i })\n continue\n }\n\n // Strings: '…' or \"…\" with escapes\n if( c === \"'\" || c === '\"' ){\n const start = i\n i++\n let value = ''\n let closed = false\n while( i < src.length ){\n const ch = src[ i ]\n if( ch === '\\\\' ){\n const next = src[ i + 1 ]\n const escapes: Record<string, string> = { n: '\\n', t: '\\t', r: '\\r', b: '\\b', f: '\\f', v: '\\v', '0': '\\0' }\n if( next === 'u' ){\n const hex = src.slice( i + 2, i + 6 )\n value += String.fromCharCode( parseInt( hex, 16 ) || 0 )\n i += 6\n }\n else {\n value += escapes[ next ] ?? next\n i += 2\n }\n continue\n }\n if( ch === c ){ closed = true; i++; break }\n value += ch\n i++\n }\n if( !closed )\n diagnostics.push({ code: 'LIPS-E001', message: 'Unterminated string literal', loc: { offset: start, length: i - start } })\n tokens.push({ t: 'str', value, start, end: i })\n continue\n }\n\n // Identifiers / keywords\n if( isIdStart( c ) ){\n const start = i\n while( i < src.length && isIdChar( src[ i ] ) ) i++\n tokens.push({ t: 'id', value: src.slice( start, i ), start, end: i })\n continue\n }\n\n // Punctuators — longest match first\n let punct = PUNCTS.find( p => src.startsWith( p, i ) )\n // `a ? .5 : b` — '?.' must not swallow a ternary before a decimal\n if( punct === '?.' && /[0-9]/.test( src[ i + 2 ] ?? '' ) )\n punct = '?'\n if( punct ){\n tokens.push({ t: 'punct', value: punct, start: i, end: i + punct.length })\n i += punct.length\n continue\n }\n\n diagnostics.push({ code: 'LIPS-E002', message: `Unexpected character '${c}'`, loc: { offset: i, length: 1 } })\n i++\n }\n\n tokens.push({ t: 'eof', value: '', start: src.length, end: src.length })\n return tokens\n}\n\n// --------------------------------------------------------------------- parser\nclass Parser {\n private pos = 0\n constructor( private tokens: Token[], private diagnostics: ExprDiagnostic[] ){}\n\n private peek( offset = 0 ){ return this.tokens[ Math.min( this.pos + offset, this.tokens.length - 1 ) ] }\n private next(){ return this.tokens[ this.pos++ ] ?? this.tokens[ this.tokens.length - 1 ] }\n private at( value: string ){ const t = this.peek(); return t.t === 'punct' && t.value === value }\n private eat( value: string ){ if( this.at( value ) ){ this.pos++; return true } return false }\n private error( code: string, message: string, token = this.peek() ): Expr {\n this.diagnostics.push({ code, message, loc: { offset: token.start, length: Math.max( 1, token.end - token.start ) } })\n return { t: 'error' }\n }\n private expect( value: string, code: string ){\n if( !this.eat( value ) )\n this.error( code, `Expected '${value}'` )\n }\n\n parse(): Expr {\n const expr = this.assign()\n if( this.peek().t !== 'eof' )\n this.error( 'LIPS-E003', `Unexpected token '${this.peek().value}' after expression` )\n return expr\n }\n\n /**\n * Arrow lookahead: '(' … ')' '=>' or IDENT '=>'\n */\n private isArrowAhead(): boolean {\n const t = this.peek()\n if( t.t === 'id' ){\n const n = this.peek( 1 )\n return n.t === 'punct' && n.value === '=>'\n }\n if( t.t === 'punct' && t.value === '(' ){\n let depth = 0, k = 0\n while( true ){\n const tok = this.peek( k )\n if( tok.t === 'eof' ) return false\n if( tok.t === 'punct' && tok.value === '(' ) depth++\n if( tok.t === 'punct' && tok.value === ')' ){\n depth--\n if( depth === 0 ){\n const after = this.peek( k + 1 )\n return after.t === 'punct' && after.value === '=>'\n }\n }\n k++\n }\n }\n return false\n }\n\n private assign(): Expr {\n // Arrow functions\n if( this.isArrowAhead() ){\n const params: string[] = []\n if( this.peek().t === 'id' )\n params.push( this.next().value )\n else {\n this.expect( '(', 'LIPS-E004' )\n while( !this.at( ')' ) && this.peek().t !== 'eof' ){\n const p = this.next()\n if( p.t !== 'id' ) return this.error( 'LIPS-E005', 'Invalid arrow parameter', p )\n params.push( p.value )\n if( !this.eat( ',' ) ) break\n }\n this.expect( ')', 'LIPS-E004' )\n }\n this.expect( '=>', 'LIPS-E004' )\n return { t: 'arrow', params, body: this.assign() }\n }\n\n const target = this.conditional()\n\n const op = this.peek()\n if( op.t === 'punct' && [ '=', '+=', '-=', '*=', '/=', '%=' ].includes( op.value ) ){\n if( target.t !== 'id' && target.t !== 'member' )\n return this.error( 'LIPS-E006', 'Invalid assignment target', op )\n this.next()\n return { t: 'assign', op: op.value, target, value: this.assign() }\n }\n\n return target\n }\n\n private conditional(): Expr {\n const test = this.nullish()\n if( this.eat( '?' ) ){\n const cons = this.assign()\n this.expect( ':', 'LIPS-E007' )\n return { t: 'cond', test, cons, alt: this.assign() }\n }\n return test\n }\n\n private nullish(): Expr {\n let l = this.or()\n while( this.at( '??' ) ){ this.next(); l = { t: 'logic', op: '??', l, r: this.or() } }\n return l\n }\n private or(): Expr {\n let l = this.and()\n while( this.at( '||' ) ){ this.next(); l = { t: 'logic', op: '||', l, r: this.and() } }\n return l\n }\n private and(): Expr {\n let l = this.equality()\n while( this.at( '&&' ) ){ this.next(); l = { t: 'logic', op: '&&', l, r: this.equality() } }\n return l\n }\n private equality(): Expr {\n let l = this.relational()\n while( [ '===', '!==', '==', '!=' ].some( op => this.at( op ) ) ){\n const op = this.next().value\n l = { t: 'bin', op, l, r: this.relational() }\n }\n return l\n }\n private relational(): Expr {\n let l = this.additive()\n while( [ '<=', '>=', '<', '>' ].some( op => this.at( op ) ) ){\n const op = this.next().value\n l = { t: 'bin', op, l, r: this.additive() }\n }\n return l\n }\n private additive(): Expr {\n let l = this.multiplicative()\n while( this.at( '+' ) || this.at( '-' ) ){\n const op = this.next().value\n l = { t: 'bin', op, l, r: this.multiplicative() }\n }\n return l\n }\n private multiplicative(): Expr {\n let l = this.unary()\n while( this.at( '*' ) || this.at( '/' ) || this.at( '%' ) ){\n const op = this.next().value\n l = { t: 'bin', op, l, r: this.unary() }\n }\n return l\n }\n private unary(): Expr {\n if( this.at( '!' ) || this.at( '-' ) || this.at( '+' ) ){\n const op = this.next().value as '!' | '-' | '+'\n return { t: 'unary', op, arg: this.unary() }\n }\n if( this.at( '++' ) || this.at( '--' ) ){\n const op = this.next().value as '++' | '--'\n const arg = this.unary()\n if( arg.t !== 'id' && arg.t !== 'member' )\n return this.error( 'LIPS-E006', 'Invalid update target' )\n return { t: 'update', op, arg, prefix: true }\n }\n return this.postfix()\n }\n private postfix(): Expr {\n let expr = this.callMember()\n if( this.at( '++' ) || this.at( '--' ) ){\n const op = this.next().value as '++' | '--'\n if( expr.t !== 'id' && expr.t !== 'member' )\n return this.error( 'LIPS-E006', 'Invalid update target' )\n expr = { t: 'update', op, arg: expr, prefix: false }\n }\n return expr\n }\n\n private callMember(): Expr {\n let expr = this.primary()\n\n while( true ){\n if( this.eat( '.' ) ){\n const prop = this.next()\n if( prop.t !== 'id' ) return this.error( 'LIPS-E008', 'Expected property name', prop )\n expr = { t: 'member', obj: expr, prop: prop.value, computed: false, optional: false, at: prop.start }\n }\n else if( this.eat( '?.' ) ){\n if( this.at( '(' ) ){\n expr = { t: 'call', callee: expr, args: this.argList(), optional: true }\n }\n else if( this.eat( '[' ) ){\n const at = this.peek().start\n const idx = this.assign()\n this.expect( ']', 'LIPS-E009' )\n expr = { t: 'member', obj: expr, prop: idx, computed: true, optional: true, at }\n }\n else {\n const prop = this.next()\n if( prop.t !== 'id' ) return this.error( 'LIPS-E008', 'Expected property name', prop )\n expr = { t: 'member', obj: expr, prop: prop.value, computed: false, optional: true, at: prop.start }\n }\n }\n else if( this.eat( '[' ) ){\n const at = this.peek().start\n const idx = this.assign()\n this.expect( ']', 'LIPS-E009' )\n expr = { t: 'member', obj: expr, prop: idx, computed: true, optional: false, at }\n }\n else if( this.at( '(' ) ){\n expr = { t: 'call', callee: expr, args: this.argList(), optional: false }\n }\n else break\n }\n\n return expr\n }\n private argList(): Expr[] {\n this.expect( '(', 'LIPS-E010' )\n const args: Expr[] = []\n while( !this.at( ')' ) && this.peek().t !== 'eof' ){\n args.push( this.assign() )\n if( !this.eat( ',' ) ) break\n }\n this.expect( ')', 'LIPS-E010' )\n return args\n }\n\n private primary(): Expr {\n const t = this.peek()\n\n if( t.t === 'num' ){ this.next(); return { t: 'lit', v: parseFloat( t.value ) } }\n if( t.t === 'str' ){ this.next(); return { t: 'lit', v: t.value } }\n\n if( t.t === 'id' ){\n this.next()\n switch( t.value ){\n case 'true': return { t: 'lit', v: true }\n case 'false': return { t: 'lit', v: false }\n case 'null': return { t: 'lit', v: null }\n case 'undefined': return { t: 'lit', v: undefined }\n case 'NaN': return { t: 'lit', v: NaN }\n case 'Infinity': return { t: 'lit', v: Infinity }\n default: return { t: 'id', name: t.value, at: t.start }\n }\n }\n\n if( this.eat( '(' ) ){\n const expr = this.assign()\n this.expect( ')', 'LIPS-E010' )\n return expr\n }\n\n if( this.eat( '[' ) ){\n const items: { spread?: boolean, value: Expr }[] = []\n while( !this.at( ']' ) && this.peek().t !== 'eof' ){\n const spread = this.eat( '...' )\n items.push({ spread: spread || undefined, value: this.assign() })\n if( !this.eat( ',' ) ) break\n }\n this.expect( ']', 'LIPS-E009' )\n return { t: 'arr', items }\n }\n\n if( this.eat( '{' ) ){\n const props: { key?: string, value: Expr, spread?: boolean, at?: number }[] = []\n while( !this.at( '}' ) && this.peek().t !== 'eof' ){\n if( this.eat( '...' ) ){\n props.push({ spread: true, value: this.assign() })\n }\n else {\n const key = this.next()\n if( key.t !== 'id' && key.t !== 'str' && key.t !== 'num' )\n return this.error( 'LIPS-E011', 'Invalid object key', key )\n\n if( this.eat( ':' ) )\n props.push({ key: String( key.value ), value: this.assign(), at: key.start })\n else if( key.t === 'id' ) // shorthand { a }\n props.push({ key: key.value, value: { t: 'id', name: key.value, at: key.start }, at: key.start })\n else\n return this.error( 'LIPS-E011', 'Invalid shorthand property', key )\n }\n if( !this.eat( ',' ) ) break\n }\n this.expect( '}', 'LIPS-E011' )\n return { t: 'obj', props }\n }\n\n this.next()\n return this.error( 'LIPS-E012', t.t === 'eof' ? 'Unexpected end of expression' : `Unexpected token '${t.value}'`, t )\n }\n}\n\nexport function parseExpression( src: string ): { ast: Expr, diagnostics: ExprDiagnostic[] } {\n const diagnostics: ExprDiagnostic[] = []\n const tokens = tokenize( src, diagnostics )\n const ast = new Parser( tokens, diagnostics ).parse()\n\n return { ast, diagnostics }\n}\n\n/**\n * Split an instruction (`on-click( fn, a, b )`, `<log( a, b )>`) on its\n * top-level commas — strings and brackets are opaque.\n */\nexport function splitTopLevel( src: string ): string[] {\n const out: string[] = []\n let depth = 0, start = 0\n\n for( let i = 0; i < src.length; i++ ){\n const c = src[ i ]\n if( c === \"'\" || c === '\"' || c === '`' ){\n i++\n while( i < src.length && src[ i ] !== c ){\n if( src[ i ] === '\\\\' ) i++\n i++\n }\n continue\n }\n if( c === '(' || c === '[' || c === '{' ) depth++\n else if( c === ')' || c === ']' || c === '}' ) depth--\n else if( c === ',' && depth === 0 ){\n out.push( src.slice( start, i ) )\n start = i + 1\n }\n }\n out.push( src.slice( start ) )\n return out.map( s => s.trim() ).filter( Boolean )\n}\n\n// ------------------------------------------------------------ dep extraction\nconst METAVAR_ROOTS = new Set([ 'state', 'input', 'context', 'self', 'arguments' ])\n\n/**\n * Every root identifier an expression reads that is not bound by an\n * arrow parameter — the head of each member chain, plus bare reads.\n *\n * The complement of `extractDeps`, which drops names it does not\n * recognise. Callers that need to REPORT an unresolvable name (a\n * stylesheet has no template position, so a `<for>` iterator in one\n * can never resolve — RFC-004 §7.2) need to see them instead.\n */\nexport function freeRoots( ast: Expr ): string[] {\n const roots = new Set<string>()\n\n const walk = ( node: Expr, shadow: Set<string> ) => {\n switch( node.t ){\n case 'id':\n !shadow.has( node.name ) && roots.add( node.name )\n return\n case 'member':\n walk( node.obj, shadow )\n typeof node.prop !== 'string' && walk( node.prop, shadow )\n return\n case 'call':\n walk( node.callee, shadow )\n node.args.forEach( a => walk( a, shadow ) )\n return\n case 'unary': case 'update': walk( node.arg, shadow ); return\n case 'bin': case 'logic': walk( node.l, shadow ); walk( node.r, shadow ); return\n case 'cond':\n walk( node.test, shadow ); walk( node.cons, shadow ); walk( node.alt, shadow )\n return\n case 'assign': walk( node.target, shadow ); walk( node.value, shadow ); return\n case 'arrow': walk( node.body, new Set([ ...shadow, ...node.params ]) ); return\n case 'arr': node.items.forEach( i => walk( i.value, shadow ) ); return\n case 'obj': node.props.forEach( p => walk( p.value, shadow ) ); return\n }\n }\n\n walk( ast, new Set() )\n return [ ...roots ]\n}\n\n/**\n * Precise dependency paths from the AST: dotted member paths\n * rooted at metavars (up to the first computed/call boundary),\n * plus bare scope-variable reads. Arrow params shadow.\n */\nexport function extractDeps( ast: Expr, scopeNames: string[] = [] ): string[] {\n const\n deps = new Set<string>(),\n scope = new Set( scopeNames )\n\n const walk = ( node: Expr, shadow: Set<string> ) => {\n switch( node.t ){\n case 'id': {\n if( shadow.has( node.name ) ) return\n if( scope.has( node.name ) || node.name === 'arguments' ) deps.add( node.name )\n return\n }\n case 'member': {\n // Collect the static dotted chain\n const parts: string[] = []\n let cur: Expr = node\n while( cur.t === 'member' && !cur.computed && typeof cur.prop === 'string' ){\n parts.unshift( cur.prop )\n cur = cur.obj\n }\n // Computed segments: record the object chain and the index deps\n if( cur.t === 'member' ){\n walk( cur.obj, shadow )\n typeof cur.prop !== 'string' && walk( cur.prop, shadow )\n // Re-anchor: deps of the computed base were recorded above\n if( cur.obj.t === 'id' || cur.obj.t === 'member' ) { /* recorded via recursion */ }\n }\n else if( cur.t === 'id' && !shadow.has( cur.name ) ){\n if( METAVAR_ROOTS.has( cur.name ) )\n deps.add( parts.length ? `${cur.name}.${parts.join('.')}` : cur.name )\n else if( scope.has( cur.name ) )\n deps.add( cur.name )\n }\n else if( cur.t !== 'id' ) walk( cur, shadow )\n return\n }\n case 'call':\n walk( node.callee, shadow )\n node.args.forEach( a => walk( a, shadow ) )\n return\n case 'unary': walk( node.arg, shadow ); return\n case 'update': walk( node.arg, shadow ); return\n case 'bin': case 'logic': walk( node.l, shadow ); walk( node.r, shadow ); return\n case 'cond': walk( node.test, shadow ); walk( node.cons, shadow ); walk( node.alt, shadow ); return\n case 'assign': walk( node.target, shadow ); walk( node.value, shadow ); return\n case 'arrow': {\n const inner = new Set([ ...shadow, ...node.params ])\n walk( node.body, inner )\n return\n }\n case 'arr': node.items.forEach( i => walk( i.value, shadow ) ); return\n case 'obj': node.props.forEach( p => walk( p.value, shadow ) ); return\n }\n }\n\n walk( ast, new Set() )\n return [ ...deps ]\n}\n\n// -------------------------------------------------------------------- codegen\n/**\n * AST → JS source (fully parenthesized — semantics over beauty).\n * Reserved-as-parameter roots are renamed at the identifier node\n * (`static` → `__static`, `arguments` → `__args__`) — renaming in\n * codegen, never via regex on emitted source, keeps string literals\n * containing those words intact.\n */\n/**\n * Name tables are prototype-free (`__proto__: null`): looked up by an\n * author's identifier, a `{}` answered `constructor` with `Object`\n * (RFC-007 §8). A literal, not a helper call, so a bundle that never\n * reads a table can still drop it.\n */\nconst ID_RENAMES: Record<string, string> = { __proto__: null, static: '__static', arguments: '__args__' } as any\n\nfunction gen( node: Expr ): string {\n switch( node.t ){\n case 'lit':\n if( typeof node.v === 'string' ) return JSON.stringify( node.v )\n if( node.v === undefined ) return 'undefined'\n if( Number.isNaN( node.v ) ) return 'NaN'\n return String( node.v )\n case 'id': return ID_RENAMES[ node.name ] ?? node.name\n case 'member': {\n const obj = gen( node.obj )\n if( node.computed ) return `(${obj})${node.optional ? '?.' : ''}[${gen( node.prop as Expr )}]`\n return `(${obj})${node.optional ? '?.' : '.'}${node.prop}`\n }\n case 'call': return `(${gen( node.callee )})${node.optional ? '?.' : ''}(${node.args.map( gen ).join(',')})`\n case 'unary': return `(${node.op}(${gen( node.arg )}))`\n case 'update': return node.prefix ? `(${node.op}${genTarget( node.arg )})` : `(${genTarget( node.arg )}${node.op})`\n case 'bin': return `((${gen( node.l )})${node.op}(${gen( node.r )}))`\n case 'logic': return `((${gen( node.l )})${node.op}(${gen( node.r )}))`\n case 'cond': return `((${gen( node.test )})?(${gen( node.cons )}):(${gen( node.alt )}))`\n case 'assign': return `(${genTarget( node.target )}${node.op}(${gen( node.value )}))`\n case 'arrow': return `((${node.params.join(',')})=>(${gen( node.body )}))`\n case 'arr': return `[${node.items.map( i => ( i.spread ? '...' : '' ) + gen( i.value ) ).join(',')}]`\n case 'obj': return `({${node.props.map( p =>\n p.spread ? `...${gen( p.value )}` : `${JSON.stringify( p.key )}:${gen( p.value )}` ).join(',')}})`\n case 'error': return 'undefined'\n }\n}\n/** Assignment/update targets must not be over-parenthesized */\nfunction genTarget( node: Expr ): string {\n if( node.t === 'id' ) return ID_RENAMES[ node.name ] ?? node.name\n if( node.t === 'member' ){\n const obj = gen( node.obj )\n return node.computed ? `${obj}[${gen( node.prop as Expr )}]` : `${obj}.${node.prop}`\n }\n return gen( node )\n}\n\n// ------------------------------------------------------------------ executors\nexport interface ExprEnv {\n state?: any\n input?: any\n context?: any\n static?: any\n self?: any\n arguments?: any\n scope?: Record<string, any>\n /**\n * Effective language for this subtree, read reactively (RFC-005 §4).\n * Set by `<i18n lang=…>`; absent means \"the global language\". Not an\n * expression root — the evaluator only binds the named roots, so this\n * rides along for the runtime's own use.\n */\n lang?: () => string\n}\n\nexport interface CompiledExpr {\n run( env: ExprEnv ): any\n source: string\n}\n\nconst\nCOMPILE_CACHE = new Map<string, CompiledExpr>(),\nROOT_PARAMS = [ 'state', 'input', 'context', '__static', 'self' ]\n\n/**\n * Compiled mode: one Function per unique (source, scopeNames) —\n * strict-compatible, no `with`. Trusted contexts only.\n */\nexport function compileExpression( src: string, scopeNames: string[] = [] ): CompiledExpr {\n const key = `${scopeNames.join(',')}\\0${src}`\n const cached = COMPILE_CACHE.get( key )\n if( cached ) return cached\n\n const { ast, diagnostics } = parseExpression( src )\n if( diagnostics.length )\n console.warn( `[lips-ir] expression diagnostics for \"${src}\":`, diagnostics )\n\n const\n code = `return (${gen( ast )});`,\n params = [ ...ROOT_PARAMS, '__args__', ...scopeNames ],\n fn = new Function( ...params, code )\n\n const compiled: CompiledExpr = {\n source: src,\n run( env: ExprEnv ){\n const scope = env.scope || {}\n return fn(\n env.state, env.input, env.context, env.static, env.self, env.arguments,\n ...scopeNames.map( name => scope[ name ] )\n )\n }\n }\n\n COMPILE_CACHE.set( key, compiled )\n return compiled\n}\n\n/**\n * Interpreted mode: an AST walker. CSP-safe — it never builds a Function\n * and never calls eval — and names resolve only to the scope, the\n * metavars and the globals below.\n *\n * It is NOT a sandbox. Members, calls and writes are unrestricted, and\n * these globals are the page's own objects. For a template you did not\n * write, use `new Lips({ untrusted })` (RFC-007).\n */\nconst GLOBALS: Record<string, any> = {\n __proto__: null,\n Math, JSON, Object, Array, String, Number, Boolean, Date,\n parseInt, parseFloat, isNaN, isFinite,\n encodeURIComponent, decodeURIComponent, console\n} as any\n\nexport function interpretExpression( ast: Expr, env: ExprEnv ): any {\n const scope = env.scope || Object.create( null )\n\n const resolveId = ( name: string, locals: Record<string, any>[] ): any => {\n for( const frame of locals )\n if( name in frame ) return frame[ name ]\n\n if( name in scope ) return scope[ name ]\n\n switch( name ){\n case 'state': return env.state\n case 'input': return env.input\n case 'context': return env.context\n case 'static': return env.static\n case 'self': return env.self\n case 'arguments': return env.arguments\n }\n\n if( name in GLOBALS ) return GLOBALS[ name ]\n return undefined\n }\n\n const assignId = ( name: string, value: any, locals: Record<string, any>[] ) => {\n for( const frame of locals )\n if( name in frame ){ frame[ name ] = value; return value }\n scope[ name ] = value\n return value\n }\n\n const ev = ( node: Expr, locals: Record<string, any>[] ): any => {\n switch( node.t ){\n case 'lit': return node.v\n case 'id': return resolveId( node.name, locals )\n\n case 'member': {\n const obj = ev( node.obj, locals )\n if( node.optional && obj == null ) return undefined\n const prop = node.computed ? ev( node.prop as Expr, locals ) : node.prop as string\n return obj?.[ prop ]\n }\n\n case 'call': {\n // Member calls bind `this` to the object\n if( node.callee.t === 'member' ){\n const obj = ev( node.callee.obj, locals )\n if( ( node.callee.optional || node.optional ) && obj == null ) return undefined\n const prop = node.callee.computed ? ev( node.callee.prop as Expr, locals ) : node.callee.prop as string\n const fn = obj?.[ prop ]\n if( node.optional && fn == null ) return undefined\n return fn.apply( obj, node.args.map( a => ev( a, locals ) ) )\n }\n const fn = ev( node.callee, locals )\n if( node.optional && fn == null ) return undefined\n return fn( ...node.args.map( a => ev( a, locals ) ) )\n }\n\n case 'unary': {\n const v = ev( node.arg, locals )\n switch( node.op ){\n case '!': return !v\n case '-': return -v\n case '+': return +v\n }\n }\n\n case 'update': {\n const cur = ev( node.arg, locals )\n const nextVal = node.op === '++' ? cur + 1 : cur - 1\n setTarget( node.arg, nextVal, locals )\n return node.prefix ? nextVal : cur\n }\n\n case 'bin': {\n const l = ev( node.l, locals ), r = ev( node.r, locals )\n switch( node.op ){\n case '+': return l + r\n case '-': return l - r\n case '*': return l * r\n case '/': return l / r\n case '%': return l % r\n case '<': return l < r\n case '>': return l > r\n case '<=': return l <= r\n case '>=': return l >= r\n // eslint-disable-next-line eqeqeq\n case '==': return l == r\n // eslint-disable-next-line eqeqeq\n case '!=': return l != r\n case '===': return l === r\n case '!==': return l !== r\n }\n return undefined\n }\n\n case 'logic': {\n const l = ev( node.l, locals )\n switch( node.op ){\n case '&&': return l ? ev( node.r, locals ) : l\n case '||': return l ? l : ev( node.r, locals )\n case '??': return l != null ? l : ev( node.r, locals )\n }\n }\n\n case 'cond': return ev( node.test, locals ) ? ev( node.cons, locals ) : ev( node.alt, locals )\n\n case 'assign': {\n let value = ev( node.value, locals )\n if( node.op !== '=' ){\n const cur = ev( node.target, locals )\n switch( node.op ){\n case '+=': value = cur + value; break\n case '-=': value = cur - value; break\n case '*=': value = cur * value; break\n case '/=': value = cur / value; break\n case '%=': value = cur % value; break\n }\n }\n return setTarget( node.target, value, locals )\n }\n\n case 'arrow':\n return ( ...args: any[] ) => {\n const frame: Record<string, any> = Object.create( null )\n node.params.forEach( ( p, k ) => frame[ p ] = args[ k ] )\n return ev( node.body, [ frame, ...locals ] )\n }\n\n case 'arr': {\n const out: any[] = []\n for( const item of node.items ){\n const v = ev( item.value, locals )\n item.spread ? out.push( ...v ) : out.push( v )\n }\n return out\n }\n\n case 'obj': {\n const out: Record<string, any> = {}\n for( const p of node.props ){\n if( p.spread ) Object.assign( out, ev( p.value, locals ) )\n else out[ p.key as string ] = ev( p.value, locals )\n }\n return out\n }\n\n case 'error': return undefined\n }\n }\n\n const setTarget = ( target: Expr, value: any, locals: Record<string, any>[] ) => {\n if( target.t === 'id' ) return assignId( target.name, value, locals )\n if( target.t === 'member' ){\n const obj = ev( target.obj, locals )\n const prop = target.computed ? ev( target.prop as Expr, locals ) : target.prop as string\n if( obj != null ) obj[ prop ] = value\n return value\n }\n return value\n }\n\n return ev( ast, [] )\n}\n",
|
|
8
|
+
"/**\n * Style IR (RFC-004 Layer 1) — reactive declarations for component stylesheets.\n *\n * stylesheet source\n * │ scanner — lifts {expr} out of declaration VALUES only, hoists the\n * │ at-rules that cannot nest, compacts the text\n * ▼\n * scope wrap `[rel=\"x\"]{…}` — resolved by native CSS nesting, or\n * flattened by an opt-in preprocessor (`@lipsjs/lips/stylis`)\n * ▼\n * StyleIR ──────────► JSON (precompiled module)\n * │\n * ▼\n * runtime: inject `css` verbatim, bind each custom property on the scope roots\n *\n * The sheet is IMMUTABLE once injected. Updates write custom properties on the\n * component's own roots — one shared rule, N per-instance values. Rule-level\n * revision (insert/delete) is Layer 2 and deliberately absent here.\n *\n * Like the template compiler, the CSS preprocessor is INJECTED rather than\n * imported, so the precompiled-only `./runtime` build tree-shakes Stylis out.\n */\n\nimport type { TemplateDiagnostic } from './parser'\nimport { parseExpression, freeRoots } from './expression'\n\n// ------------------------------------------------------------------- types\nexport interface StyleBindIR {\n /** Custom property to write on the scope roots (e.g. '--card-0') */\n prop: string\n /** Index into StyleIR.exprs */\n e: number\n /**\n * Unit appended to the value when it is written: a full-value bind, for\n * engines whose `calc()` cannot multiply a number back into it (Lynx,\n * RFC-006 §3.2)\n */\n u?: string\n}\n\nexport interface PropertyIR {\n name: string\n syntax: string\n inherits: boolean\n initial: string\n}\n\nexport interface StyleIR {\n v: 1\n /**\n * Scope name baked in at compile time. The runtime stamps `rel` with\n * THIS, not the registration name — a precompiled sheet is already\n * scoped to it, and the two must agree.\n */\n nsp: string\n /** Scoped and compact — nested, or flat if a preprocessor ran. Injected verbatim, never re-parsed. */\n css: string\n exprs: string[]\n binds: StyleBindIR[]\n /** @property registrations — makes the variables interpolable (RFC-004 §10) */\n props?: PropertyIR[]\n}\n\nexport interface StyleCompileOptions {\n /** Scope name — the `rel` attribute value, and the variable-name prefix */\n nsp: string\n /** Inject globally instead of scoping to `[rel=\"<nsp>\"]` */\n meta?: boolean\n /** Emit inside `@layer <name>` so utility frameworks can win (RFC-004 §9) */\n layer?: string\n /**\n * CSS preprocessor for this call, overriding any process-wide one.\n *\n * Passed per call rather than only set globally because the opt-in\n * preprocessor ships as a SEPARATE bundle: `@lipsjs/lips/stylis` and\n * `@lipsjs/lips` each carry their own copy of this module, so a global\n * set from one is invisible to the other. Handing the function across\n * the call is the only wiring that survives that boundary.\n */\n preprocess?: StylePreprocessor\n /**\n * The scope wrap's selector, for a host that does not scope by `rel`\n * (Lynx scopes by class, RFC-006 §4.4). Default `[rel=\"<nsp>\"]`.\n */\n scope?: string\n /**\n * What the target cannot do, reported on the source. Passed per call,\n * like the preprocessor, so a target's rules — and their bytes — stay\n * out of the DOM bundles.\n */\n lint?: StyleLint\n}\n\n/**\n * Called on every selector (`text`), at-rule prelude (`text` starting\n * with `@`) and declaration (`text` the property, plus its `value`).\n * Returns its diagnostics; the compiler adds where it is in the source.\n */\nexport type StyleLint = ( text: string, value?: string ) => Omit<TemplateDiagnostic, 'loc'>[] | undefined\n\nexport interface StyleCompileResult {\n ir: StyleIR\n diagnostics: TemplateDiagnostic[]\n}\n\n// ------------------------------------------------------------- preprocessor\nexport type StylePreprocessor = ( css: string ) => string\nlet PREPROCESSOR: StylePreprocessor | null = null\n\n/**\n * Process-wide default preprocessor, `null` to clear it. Only reaches\n * `compileStyle` in the SAME module graph — each published entry bundles\n * its own copy of this module — so outside of tests and source builds,\n * pass `preprocess` per call (`LipsConfig.stylePreprocessor`,\n * `precompile(…, { preprocess })`) instead.\n */\nexport function setStylePreprocessor( fn: StylePreprocessor | null ){ PREPROCESSOR = fn }\nexport function hasStylePreprocessor(){ return !!PREPROCESSOR }\n\n// ------------------------------------------------------------------ scanner\nconst PROP_NAME = /^[-\\w]+$/\nconst UNIT = /^(%|[a-zA-Z]+)/\n\n/**\n * A unit-suffixed slot is registered as `<number>`, NOT as the unit's own\n * type: the unit was lifted into `calc(var(--x) * 1unit)`, so what the bind\n * writes is a bare number. Registering `<percentage>` and then writing `75`\n * makes the value invalid — the property silently falls back to its\n * initial-value and the declaration computes to zero.\n *\n * `<number>` is still the whole §10 payoff: it is what makes the variable\n * interpolable, so transitions through it animate.\n */\nconst NUMBER_SYNTAX: [ string, string ] = [ '<number>', '0' ]\n\nfunction skipString( src: string, i: number ){\n const q = src[ i ]\n i++\n while( i < src.length ){\n if( src[ i ] === '\\\\' ){ i += 2; continue }\n if( src[ i ] === q ) return i + 1\n i++\n }\n return i\n}\nfunction skipComment( src: string, i: number ){\n const end = src.indexOf( '*/', i + 2 )\n return end < 0 ? src.length : end + 2\n}\n/** `// …` up to (not including) the newline — Stylis syntax, not CSS */\nfunction skipLine( src: string, i: number ){\n const end = src.indexOf( '\\n', i + 2 )\n return end < 0 ? src.length : end\n}\n/** A value safe inside a double-quoted CSS string */\nconst quote = ( value: string ) => value.replace( /[\"\\\\]/g, '\\\\$&' )\n\nexport function locOf( src: string, offset: number, length: number ){\n let line = 1, last = -1\n for( let i = 0; i < offset; i++ ) if( src[ i ] === '\\n' ){ line++; last = i }\n return { line, col: offset - last, offset, length }\n}\n\n/**\n * Read a `{…}` at `open` as an interpolation, or return null if it is\n * really a block. The discriminator: expression-shaped content —\n * non-empty, no nested brace, no `;`, and no top-level `:` unless a `?`\n * precedes it (a ternary). That is what tells `color: {state.x}` apart\n * from a nested `a:hover { color: red }`.\n */\nfunction readInterpolation( src: string, open: number ){\n let i = open + 1, nest = 0, question = false, colon = false\n\n while( i < src.length ){\n const c = src[ i ]\n\n if( c === '\"' || c === \"'\" ){ i = skipString( src, i ); continue }\n if( c === '{' || c === ';' ) return null\n if( c === '}' ) break\n\n if( c === '(' || c === '[' ) nest++\n else if( c === ')' || c === ']' ) nest--\n else if( nest === 0 ){\n if( c === '?' ) question = true\n else if( c === ':' && !question ) colon = true\n }\n i++\n }\n\n if( i >= src.length || colon ) return null\n\n const expr = src.slice( open + 1, i ).trim()\n return expr ? { end: i, expr } : null\n}\n\n/**\n * Names a stylesheet expression may read. A sheet is per component and\n * has no template position, so `<for>` iterators and `<let>` names —\n * which are position-local — can never resolve in one.\n */\nconst STYLE_SCOPE = new Set([ 'state', 'input', 'static', 'context', 'self' ])\n\ntype ValuePart = string | { expr: string, unit: string, at: number }\n\n/**\n * Scan a declaration value from `from` to its `;`/`}` terminator, lifting\n * interpolations out. Returns null when the \"declaration\" turns out to be a\n * selector — `a:hover {` enters here on the `:` and aborts at the block.\n */\nfunction readValue(\n src: string,\n from: number,\n keepComments: boolean,\n onUnterminated?: ( at: number ) => void\n): { end: number, parts: ValuePart[] } | null {\n const parts: ValuePart[] = []\n let i = from, lit = from, paren = 0\n\n while( i < src.length ){\n const c = src[ i ]\n\n if( c === '\"' || c === \"'\" ){ i = skipString( src, i ); continue }\n /**\n * A comment is cut to a space — it separates tokens, so `1px`, a\n * comment and `solid` must not fuse into `1pxsolid` — unless a\n * preprocessor will read it.\n * `//` is NOT a comment here: `--api: https://x` is a valid value.\n */\n if( c === '/' && src[ i + 1 ] === '*' ){\n const end = skipComment( src, i )\n if( !keepComments ){\n parts.push( src.slice( lit, i ), ' ' )\n lit = end\n }\n i = end\n continue\n }\n if( c === '(' ){ paren++; i++; continue }\n if( c === ')' ){ paren--; i++; continue }\n\n if( paren === 0 && ( c === ';' || c === '}' ) ){\n parts.push( src.slice( lit, i ) )\n return { end: i, parts }\n }\n\n if( c === '{' ){\n const interp = readInterpolation( src, i )\n if( !interp ){\n // No closing brace at all → an unterminated interpolation, not a block\n src.indexOf( '}', i + 1 ) < 0 && onUnterminated?.( i )\n return null\n }\n\n parts.push( src.slice( lit, i ) )\n\n const m = UNIT.exec( src.slice( interp.end + 1 ) )\n const unit = m ? m[ 1 ] : ''\n\n parts.push({ expr: interp.expr, unit, at: i })\n i = interp.end + 1 + unit.length\n lit = i\n continue\n }\n\n i++\n }\n\n /**\n * Ran to EOF. Harmless for a plain trailing declaration (`--a: red`\n * with no semicolon), but if an interpolation was consumed on the way\n * then its closing brace almost certainly ate the block's — report it\n * rather than emitting silently broken CSS.\n */\n parts.some( p => typeof p !== 'string' ) && onUnterminated?.( from )\n return null\n}\n\n// --------------------------------------------------------------- structure\n/**\n * At-rules that are NOT valid inside a style rule.\n *\n * CSS nesting only admits at-rules whose body is itself a rule list, so a\n * `@keyframes` left inside `[rel=\"x\"] { … }` is dropped by the parser and\n * the animation silently does nothing. These are lifted out of the scope\n * wrap — they are document-global anyway, exactly like the `@property`\n * registrations emitted outside it.\n */\nconst HOISTED_BLOCK = /^@(-\\w+-)?(keyframes|font-face|property|counter-style|font-feature-values|font-palette-values|page|view-transition|position-try|color-profile|function)\\b/i\n/**\n * Statement at-rules that must open the sheet: `@import` is ignored after\n * any other rule, `@charset` must be first, `@namespace` must precede\n * every style rule.\n */\nconst HOISTED_STATEMENT = /^@(import|charset|namespace)\\b/i\n/**\n * Conditional group rules. Their body holds style rules, they nest\n * natively, and they stay INSIDE the scope wrap so what they contain\n * remains scoped. A hoisted at-rule found inside one carries the\n * condition out with it.\n */\nconst GROUP_AT = /^@(media|supports|container|layer|scope|starting-style|document)\\b/i\n\n/**\n * Engines that shipped the FIRST cut of CSS nesting (Chrome 112–119,\n * Safari 16.5–17.1) parse a nested line that starts with an identifier\n * as a declaration, so `button { … }` inside the scope wrap is silently\n * dropped. `& button` is the same selector — a nested relative selector\n * gets an implicit `& ` anyway — and parses wherever nesting does.\n */\nconst TYPE_LEAD = /^([a-zA-Z_*\\\\]|[^\\x00-\\x7f])/\n/** The identifier-ish token a selector opens with — `div`, `svg|rect`, `*` */\nconst LEAD_TOKEN = /^(?:[-\\w*|]|[^\\x00-\\x7f]|\\\\[\\s\\S])+/\n/**\n * Stylis/Sass `&-suffix` / `&__elem` concatenation. Native nesting reads\n * `-suffix` as a type selector instead, so the rule silently matches\n * nothing. (`&div` is fine natively — `&` may precede a type selector.)\n */\nconst CONCAT = /&[-_]/\n\nconst WS = /\\s/\nconst BREAK = /[{};]/\nconst IDENT_CHAR = /[-\\w]/\nconst QUOTED = /\"(?:\\\\[\\s\\S]|[^\"\\\\])*\"|'(?:\\\\[\\s\\S]|[^'\\\\])*'/g\nconst STRING_OR_SPACE = new RegExp(`(${ QUOTED.source })|\\\\s+`, 'g')\nconst COMMENTS = /\\/\\*[\\s\\S]*?\\*\\//g\nconst LAYER = /^@layer\\b/i\n\n/** Fold whitespace runs outside strings to one space */\nconst squash = ( text: string ) => text.replace( STRING_OR_SPACE, ( _, str ) => str || ' ' )\n\n/** Prefix every identifier-led selector in a list with `& ` (see TYPE_LEAD) */\nfunction nestSelector( prelude: string ){\n const parts: string[] = []\n let from = 0, nest = 0\n\n for( let i = 0; i < prelude.length; i++ ){\n const c = prelude[ i ]\n\n if( c === '\\\\' ){ i++; continue }\n if( c === '\"' || c === \"'\" ){ i = skipString( prelude, i ) - 1; continue }\n if( c === '(' || c === '[' ) nest++\n else if( c === ')' || c === ']' ) nest--\n else if( c === ',' && !nest ){\n parts.push( prelude.slice( from, i ) )\n from = i + 1\n }\n }\n parts.push( prelude.slice( from ) )\n\n return parts\n .map( p => {\n // Trim — but not an escaped trailing space (`.a\\ `), which is part of the name\n let s = p.trimStart(), e = s.length\n while( e && WS.test( s[ e - 1 ] ) && s[ e - 2 ] !== '\\\\' ) e--\n s = s.slice( 0, e )\n\n if( !TYPE_LEAD.test( s ) ) return s\n /**\n * `div &` places its parent itself, so `& ` cannot go in front;\n * wrapping the leading token (`:is(div) &`) is the same selector,\n * same specificity, and no longer starts with an identifier.\n */\n return s.includes('&') ? s.replace( LEAD_TOKEN, ':is($&)' ) : `& ${s}`\n })\n .join(',')\n}\n\ninterface Block {\n /**\n * What a selector directly inside this block is: nested in a style\n * rule (`style`), at the top of a global sheet (`top`), or not a style\n * selector at all — keyframe selectors, `@page` margin boxes (`opaque`).\n */\n ctx: 'style' | 'top' | 'opaque'\n /** Prelude of a conditional group rule, carried out by anything hoisted from inside it */\n group?: string\n /** Output offsets of a group's prelude and body — to drop it if hoisting empties it */\n at?: number\n body?: number\n /** Offset in the output where an at-rule being hoisted starts */\n hoist?: number\n}\n\ninterface ScanResult {\n /** The sheet body, still to be wrapped in the scope rule */\n css: string\n /** Statement at-rules that must open the sheet (`@import`, …) */\n statements: string\n /** Block at-rules lifted out of the scope wrap (`@keyframes`, …) */\n hoisted: string\n exprs: string[]\n binds: StyleBindIR[]\n props: PropertyIR[]\n}\n\nfunction scan( src: string, options: StyleCompileOptions, native: boolean, diagnostics: TemplateDiagnostic[] ): ScanResult {\n const\n exprs: string[] = [],\n binds: StyleBindIR[] = [],\n props: PropertyIR[] = [],\n /**\n * Variable names are namespaced by component. @property registration is\n * document-global, so a bare `--0` would collide across components and the\n * last registration would silently win.\n */\n prefix = `--${ options.nsp.replace( /[^a-zA-Z0-9_-]/g, '-' ) }`,\n report = ( code: string, message: string, offset: number, length: number, hint?: string ) =>\n diagnostics.push({ code, severity: 'error', message, hint, loc: locOf( src, offset, length ) }),\n warn = ( code: string, message: string, offset: number, length: number, hint?: string ) =>\n diagnostics.push({ code, severity: 'warning', message, hint, loc: locOf( src, offset, length ) }),\n /** The target's lint, located on the statement `from`…`to` */\n lint = ( text: string, from: number, to: number, value?: string ) =>\n options.lint?.( text, value )?.forEach( d => diagnostics.push({ ...d, loc: locOf( src, from, to - from ) }) )\n\n const slot = ( expr: string ) => {\n let e = exprs.indexOf( expr )\n if( e < 0 ) e = exprs.push( expr ) - 1\n return e\n }\n\n /**\n * Static checks on a lifted expression: names that cannot resolve\n * where a sheet runs, and a unit suffix on a value that is plainly\n * not a number.\n */\n const checkExpr = ( s: { expr: string, unit: string, at: number } ) => {\n const { ast, diagnostics: errors } = parseExpression( s.expr )\n const length = s.expr.length + 2\n\n if( errors.length ){\n report( 'LIPS-S004', `Invalid expression: ${errors[0].message}`, s.at, length )\n return\n }\n\n for( const name of freeRoots( ast ) )\n if( !STYLE_SCOPE.has( name ) && !( name in globalThis ) )\n report( 'LIPS-S003',\n `'${name}' is not readable from a stylesheet`,\n s.at, length,\n 'Stylesheets see state, input, static, context and self — not <for> iterators or <let> names, '\n + 'which are local to a template position.' )\n\n s.unit && ast.t === 'lit' && typeof ast.v === 'string'\n && warn( 'LIPS-S005',\n `Unit '${s.unit}' after a string value`,\n s.at, length,\n `A unit suffix multiplies a number: drop the unit, or return ${s.unit === '%' ? '50' : '8'} instead of a string.` )\n }\n\n /**\n * The output is emitted compact: comments dropped, whitespace runs\n * folded to one space, and dropped entirely beside `{`, `}` and `;`.\n * Without a preprocessor nothing else would minify it, and the sheet\n * would ship as authored — banners, indentation and all — in every\n * `<style>` and every precompiled module.\n *\n * The statement being built (`cur`) is kept apart from the output so\n * far, so reading or rewriting a prelude never copies the whole sheet.\n * A statement always starts right after `{`, `}`, `;` or at the top,\n * where no space is wanted — hence `tail = ''` whenever one is dropped.\n */\n let out = '', cur = '', tail = '', gap = false\n\n const emit = ( text: string ) => {\n if( !text ) return\n if( gap && tail && !BREAK.test( tail ) && !BREAK.test( text[ 0 ] ) ) cur += ' '\n gap = false\n cur += text\n tail = text[ text.length - 1 ]\n }\n /** End the statement: it joins the output, followed by its terminator */\n const flush = ( end: string ) => {\n out += cur + end\n cur = ''\n tail = end\n gap = false\n }\n /** Drop the statement being built, returning it */\n const drop = () => {\n const text = cur\n cur = tail = ''\n gap = false\n return text\n }\n\n /** Declaration values: folded, trimmed, never emptied (`--x: ;` is a value) */\n const value = ( text: string ) => ':' + ( squash( text ).trim() || ' ' )\n\n let\n i = 0, paren = 0,\n /** Statement start in the source */\n stmt = 0,\n statements = '', hoisted = '',\n /** Conditions the last hoisted rule was carried out with */\n lastGroups = '',\n /** An interpolation that ate a closing brace — already reported as the cause */\n unterminated = false\n\n const\n stack: Block[] = [{ ctx: options.meta ? 'top' : 'style' }]\n\n const open = () => {\n const\n parent = stack[ stack.length - 1 ],\n prelude = cur\n\n let block: Block\n\n // Keyframe selectors (`from`, `50%`) are not style selectors\n parent.ctx === 'opaque' || lint( prelude, stmt, i )\n\n if( prelude[ 0 ] === '@' ){\n if( parent.ctx !== 'opaque' && HOISTED_BLOCK.test( prelude ) ) block = { ctx: 'opaque', hoist: out.length }\n else if( GROUP_AT.test( prelude ) ) block = { ctx: parent.ctx, group: prelude, at: out.length }\n else block = { ctx: 'opaque' }\n }\n else {\n if( parent.ctx === 'style' ){\n /**\n * Only a sheet that ships nested needs the rewrite. A preprocessor\n * resolves `div &` itself, and `:is()` does not match everywhere\n * (Lynx, RFC-006 §3.1).\n */\n if( native ){\n CONCAT.test( prelude.replace( QUOTED, '' ) )\n && warn( 'LIPS-S008', `'${prelude}' joins '&' to a name`, stmt, i - stmt,\n 'Native nesting cannot: write the full selector, or use stylisPreprocessor.' )\n\n cur = nestSelector( prelude )\n }\n }\n\n block = { ctx: parent.ctx === 'opaque' ? 'opaque' : 'style' }\n }\n\n stack.push( block )\n flush('{')\n block.group && ( block.body = out.length )\n }\n\n const close = () => {\n const block = stack.pop()!\n\n /**\n * A group that hoisting emptied conditions nothing — drop it. Not an\n * `@layer`: an empty one still declares the layer order.\n */\n if( block.group && !cur && out.length === block.body && !LAYER.test( block.group ) ){\n out = out.slice( 0, block.at )\n tail = ''\n gap = false\n return\n }\n\n flush('}')\n\n if( block.hoist === undefined ) return\n\n // Carry any enclosing conditions out with it — `@media (…) { @keyframes … }`\n const\n text = out.slice( block.hoist ),\n groups = stack.filter( b => b.group ),\n key = groups.map( b => b.group ).join('{'),\n shut = '}'.repeat( groups.length )\n\n out = out.slice( 0, block.hoist )\n tail = ''\n\n // Consecutive rules hoisted from the same conditions share one copy of them\n hoisted = key && key === lastGroups\n ? hoisted.slice( 0, hoisted.length - shut.length ) + text + shut\n : hoisted + groups.map( b => b.group + '{' ).join('') + text + shut\n\n lastGroups = key\n }\n\n while( i < src.length ){\n const c = src[ i ]\n\n // An escape is one unit: `\\,` does not split a list, `\\ ` is not folded\n if( c === '\\\\' ){\n emit( src.slice( i, i + 2 ) )\n i += 2\n continue\n }\n\n /**\n * Block comments are dropped — or kept, when a preprocessor will read\n * them (`rtl:ignore`-style directives). `//` is not CSS, but Stylis\n * accepted it as a line comment and sheets were written against\n * Stylis: at the start of a statement it is stripped, where left in\n * it would glue itself onto the next selector and void the rule.\n * Anywhere else it is left alone — `--api: https://x` is a value.\n */\n const leading = c === '/' && !src.slice( stmt, i ).trim()\n\n if( c === '/' && ( src[ i + 1 ] === '*' || ( src[ i + 1 ] === '/' && leading ) ) ){\n const\n line = src[ i + 1 ] === '/',\n end = line ? skipLine( src, i ) : skipComment( src, i )\n\n if( !line && !native ){\n // Between statements it goes straight out, so preludes stay clean\n cur ? emit( src.slice( i, end ) ) : ( out += src.slice( i, end ) )\n }\n // It separated two tokens — `screen`, comment, `and` must not fuse\n else IDENT_CHAR.test( tail ) && IDENT_CHAR.test( src[ end ] || '' ) && ( gap = true )\n\n /**\n * A comment before a declaration must not become part of the\n * property name, or `PROP_NAME` rejects it, the value is never\n * scanned, and any interpolation inside it is misread further\n * down (an at-rule condition, at worst) instead of being lifted.\n */\n leading && ( stmt = end )\n i = end\n continue\n }\n if( c === '\"' || c === \"'\" ){\n const end = skipString( src, i )\n emit( src.slice( i, end ) )\n i = end\n continue\n }\n if( WS.test( c ) ){\n // A statement starts at its first character, for its diagnostics\n stmt === i && stmt++\n gap = true\n i++\n continue\n }\n\n if( c === '(' ) paren++\n else if( c === ')' ) paren--\n\n /**\n * Declaration? At statement level, outside parens, after a property\n * name. Depth is NOT part of the test: a component sheet is implicitly\n * inside its own block, so top-level `--accent: {…}` is a declaration.\n * A selector that gets this far (`a:hover {`) is rejected by readValue.\n */\n if( c === ':' && paren === 0 ){\n // `color/* … */: …` is still the property `color`\n const name = src.slice( stmt, i ).replace( COMMENTS, '' ).trim()\n\n if( PROP_NAME.test( name ) ){\n const parsed = readValue( src, i + 1, !native, at => {\n unterminated = true\n report( 'LIPS-S004',\n 'Unterminated interpolation',\n at, src.length - at,\n 'Close the expression with `}`.' )\n })\n\n if( parsed ){\n const slots = parsed.parts.filter( p => typeof p !== 'string' ) as\n { expr: string, unit: string, at: number }[]\n\n for( const s of slots ) checkExpr( s )\n\n // `color :red` — the space before the colon carries nothing\n gap = false\n\n /**\n * RFC-004 §7.4 — a custom property whose value is one bare\n * interpolation binds the AUTHOR's name directly. Aliasing it\n * through a generated variable would break cross-component\n * inheritance (§12.2) and Tailwind interop (§13), because both\n * depend on the name being stable and meaningful.\n */\n const bare =\n name.startsWith('--')\n && slots.length === 1\n && !slots[ 0 ].unit\n && parsed.parts.every( p => typeof p !== 'string' || !p.trim() )\n\n if( bare ){\n binds.push({ prop: name, e: slot( slots[ 0 ].expr ) })\n // drop the declaration entirely — the value lives inline on the root\n drop()\n i = parsed.end + ( src[ parsed.end ] === ';' ? 1 : 0 )\n stmt = i\n continue\n }\n\n let text = ''\n for( const part of parsed.parts ){\n if( typeof part === 'string' ){ text += part; continue }\n\n const\n e = slot( part.expr ),\n prop = `${prefix}-${e}`\n\n if( !binds.some( b => b.prop === prop ) ){\n binds.push({ prop, e })\n\n if( part.unit && !props.some( p => p.name === prop ) )\n props.push({\n name: prop,\n syntax: NUMBER_SYNTAX[ 0 ],\n inherits: true,\n initial: NUMBER_SYNTAX[ 1 ]\n })\n }\n\n /**\n * RFC-004 §7.1 — the source disambiguates. A bare `{expr}` is\n * used verbatim; a unit suffix means the expression yields a\n * number, so multiply it back into the unit.\n */\n text += part.unit ? `calc(var(${prop}) * 1${part.unit})` : `var(${prop})`\n }\n\n lint( name, stmt, parsed.end, text )\n emit( value( text ) )\n i = parsed.end\n continue\n }\n // readValue aborted — this was a selector (`a:hover {`), fall through\n }\n }\n\n if( c === '{' ){\n // An interpolation inside a prelude's parens is an at-rule condition.\n if( paren > 0 ){\n const interp = readInterpolation( src, i )\n if( interp ){\n report( 'LIPS-S002',\n 'Interpolation in an at-rule condition',\n i, interp.end - i + 1,\n 'Media and container conditions cannot read custom properties. Keep the condition static.' )\n\n // drop a unit suffix too, so the rest still parses as CSS\n const m = UNIT.exec( src.slice( interp.end + 1 ) )\n i = interp.end + 1 + ( m ? m[ 1 ].length : 0 )\n continue\n }\n }\n\n // A block opener with a blank prelude and expression-shaped content\n // is `{state.sel} { … }` — a dynamic selector.\n if( !src.slice( stmt, i ).trim() ){\n const interp = readInterpolation( src, i )\n if( interp ){\n report( 'LIPS-S001',\n 'Interpolation in a selector',\n i, interp.end - i + 1,\n 'Selectors are static in Layer 1. Bind a value inside the rule instead.' )\n i = interp.end + 1\n stmt = i\n continue\n }\n }\n\n open()\n stmt = ++i\n continue\n }\n\n if( c === '}' ){\n /**\n * A stray `}` would close the scope wrap early and leak every rule\n * after it out unscoped. Drop it, loudly.\n */\n if( stack.length > 1 ) close()\n else {\n warn( 'LIPS-S007', 'Unmatched `}` dropped', i, 1 )\n // it still ended whatever declaration it followed\n cur && flush(';')\n }\n\n stmt = ++i\n continue\n }\n\n if( c === ';' ){\n cur[ 0 ] === '@' && lint( cur, stmt, i )\n\n if( stack.length === 1 && HOISTED_STATEMENT.test( cur ) ) statements += drop() + ';'\n else flush(';')\n\n stmt = ++i\n continue\n }\n\n emit( c )\n i++\n }\n\n if( stack.length > 1 ){\n unterminated || warn( 'LIPS-S007', 'Unclosed `{` closed at the end', src.length, 0 )\n while( stack.length > 1 ) close()\n }\n\n // A statement at-rule may end at EOF without its `;`\n HOISTED_STATEMENT.test( cur ) && ( statements += drop() + ';' )\n // A trailing declaration with no `;`\n flush('')\n\n return { css: out, statements, hoisted, exprs, binds, props }\n}\n\n// ------------------------------------------------------------------ compile\n/**\n * Compile a component stylesheet to StyleIR.\n *\n * The scanner MUST run before any preprocessor: a brace in a declaration\n * value breaks Stylis's block parsing, so interpolations are replaced\n * with `var()` first.\n */\nexport function compileStyle( src: string, options: StyleCompileOptions ): StyleCompileResult {\n const\n diagnostics: TemplateDiagnostic[] = [],\n preprocess = options.preprocess || PREPROCESSOR,\n { css, statements, hoisted, exprs, binds, props } = scan( src, options, !preprocess, diagnostics )\n\n const empty: StyleIR = { v: 1, nsp: options.nsp, css: '', exprs: [], binds: [] }\n\n /**\n * The scope wrap IS nesting — `[rel=\"x\"] { .a { … } }`. Without a\n * preprocessor the sheet ships nested and the browser's own CSS nesting\n * resolves it: same selectors, same cascade. A preprocessor (opt-in,\n * `@lipsjs/lips/stylis`) flattens it instead, for engines that predate\n * nesting.\n *\n * Hoisting happens either way, so a preprocessor of your own — a\n * minifier, say — is never handed a `@keyframes` stuck inside a style\n * rule.\n */\n const\n /**\n * The name is quoted: it can come from a template object, and a quote in\n * it would close the attribute selector and scope the sheet to the page.\n */\n scoped = options.meta || !css ? css : `${options.scope || `[rel=\"${ quote( options.nsp ) }\"]`}{${css}}`,\n body = hoisted + scoped,\n source = options.layer ? `@layer ${options.layer}{${body}}` : body\n\n let sheet: string\n\n try { sheet = preprocess ? preprocess( source ) : source }\n catch( error: any ){\n diagnostics.push({\n code: 'LIPS-S006', severity: 'error',\n message: `Style compilation failed: ${error.message}`,\n loc: locOf( src, 0, src.length )\n })\n return { ir: empty, diagnostics }\n }\n\n /**\n * @property registration is document-global, so it sits OUTSIDE the scope\n * wrap. Without it a custom property is an uninterpolable token and\n * `transition: --x` does nothing (RFC-004 §10).\n */\n const registrations = props\n .map( p => `@property ${p.name}{syntax:\"${p.syntax}\";inherits:${p.inherits};initial-value:${p.initial}}` )\n .join('')\n\n /**\n * Statement at-rules go first, ahead of the registrations and outside\n * any `@layer` block — anywhere else the browser ignores them.\n */\n const ir: StyleIR = { v: 1, nsp: options.nsp, css: statements + registrations + sheet, exprs, binds }\n if( props.length ) ir.props = props\n\n return { ir, diagnostics }\n}\n",
|
|
9
|
+
"/**\n * Build-time precompilation (RFC-001 §5, §9 — Phase 3).\n *\n * Turns `{ default: '<template…>' }` into `{ ir: {…} }` ahead of time.\n * Two payoffs:\n *\n * 1. **CSP**: with `mode: 'interpreted'`, a precompiled app never\n * calls `Function`/`eval`, so it runs under `script-src` without\n * `unsafe-eval`.\n * 2. **Startup**: no parse/compile at runtime — the app boots\n * straight into cloning skeletons.\n *\n * The IR is plain JSON, so it can be emitted into a bundle, shipped\n * from a server, or stored as a Modela artifact.\n */\n\nimport { compileTemplate } from './ir/compiler'\nimport { compileStyle } from './ir/style'\nimport type { TemplateIR, CompileOptions } from './ir/compiler'\nimport type { StyleIR, StylePreprocessor } from './ir/style'\nimport type { TemplateDiagnostic } from './ir/parser'\n\nexport interface PrecompiledTemplate {\n ir: TemplateIR\n /** Compiled stylesheet — replaces `stylesheet` source (RFC-004) */\n style?: StyleIR\n state?: Record<string, any>\n _static?: Record<string, any>\n context?: string[]\n handler?: Record<string, ( ...args: any[] ) => any>\n}\n\nexport interface PrecompileOptions {\n /**\n * Scope name for the stylesheet — baked into the StyleIR, so it must\n * match how the component is registered. Defaults to `'lips'`.\n */\n name?: string\n /**\n * CSS preprocessor for the stylesheet, e.g. `stylisPreprocessor` from\n * `@lipsjs/lips/stylis`. Absent, the sheet is baked nested and native\n * CSS nesting resolves it. Passed here, not set globally: this entry\n * and `@lipsjs/lips/stylis` are separate bundles with separate state.\n */\n preprocess?: StylePreprocessor\n /** The kind of host the IR is for — see `CompileOptions.target` */\n target?: CompileOptions['target']\n}\n\nexport interface PrecompileResult {\n template: PrecompiledTemplate\n diagnostics: TemplateDiagnostic[]\n}\n\n/**\n * Precompile one authoring template. Macros are inlined at this point,\n * so the `macros` source does not ship to the client — and the stylesheet\n * is compiled to StyleIR, so the `./runtime` build needs no CSS\n * preprocessor either (RFC-004 §1).\n */\nexport function precompile( template: Record<string, any>, options: PrecompileOptions = {} ): PrecompileResult {\n const\n copts: CompileOptions = { macros: template.macros, target: options.target },\n { ir, diagnostics } = compileTemplate( template.default || '', copts ),\n { default: _src, macros: _macros, stylesheet, ...rest } = template\n\n if( !stylesheet ) return { template: { ...rest, ir }, diagnostics }\n\n const style = compileStyle( stylesheet, { nsp: options.name || 'lips', preprocess: options.preprocess })\n\n return {\n template: { ...rest, ir, style: style.ir },\n diagnostics: [ ...diagnostics, ...style.diagnostics ]\n }\n}\n\n/** Serialize an IR for embedding in generated source */\nexport const serializeIR = ( ir: TemplateIR ) => JSON.stringify( ir )\nexport const serializeStyleIR = ( ir: StyleIR ) => JSON.stringify( ir )\n\n// ------------------------------------------------------------ bundler glue\nexport interface PluginOptions {\n /** Files to transform (default: `.lips` single-file components) */\n include?: RegExp\n /** Emit diagnostics as build warnings (default true) */\n reportDiagnostics?: boolean\n /** CSS preprocessor for lifted stylesheets — see `PrecompileOptions.preprocess` */\n preprocess?: StylePreprocessor\n /** The kind of host the IR is for — see `CompileOptions.target` */\n target?: CompileOptions['target']\n}\n\n/**\n * Vite/Rollup plugin: compiles `.lips` single-file components into a\n * module exporting a precompiled template.\n *\n * import Card from './card.lips'\n * lips.register('card', Card) // no runtime parsing\n *\n * Kept dependency-free (duck-typed plugin object) so importing this\n * module never pulls a bundler into the runtime graph.\n */\nexport function lipsPlugin( options: PluginOptions = {} ){\n const\n include = options.include || /\\.lips$/,\n report = options.reportDiagnostics !== false\n\n return {\n name: 'lips:precompile',\n enforce: 'pre' as const,\n\n async transform( code: string, id: string ){\n if( !include.test( id ) ) return null\n\n // Lazy import: parseSFC is only needed at build time\n const { parseSFC } = await import('./ir/parser')\n const { script } = parseSFC( code )\n\n /**\n * The frontscript declares state/handler/etc.; the template\n * body is compiled to IR and merged into the default export.\n */\n const templateSrc = code.slice( script.length )\n const { ir, diagnostics } = compileTemplate( templateSrc, { target: options.target })\n\n if( report )\n for( const d of diagnostics )\n ( this as any )?.warn?.(\n `[lips] ${d.code} ${d.message} (${id}:${d.loc.line}:${d.loc.col})` )\n\n const errors = diagnostics.filter( d => d.severity === 'error' )\n if( errors.length )\n throw new Error(\n `[lips] ${id}: ${errors[0].message} at line ${errors[0].loc.line}:${errors[0].loc.col}` )\n\n /**\n * Compile the stylesheet too, so the emitted module needs no CSS\n * preprocessor at runtime. Only a plain template literal can be\n * lifted statically — one containing `${…}` depends on runtime\n * values, so it ships as source and needs the full build.\n */\n const\n name = ( id.split(/[\\\\/]/).pop() || 'lips' ).replace( /\\.lips$/, '' ),\n literal = /\\bconst\\s+stylesheet\\s*=\\s*`([^`]*)`/.exec( script ),\n hasStyle = /\\bconst\\s+stylesheet\\b/.test( script ),\n liftable = literal && !literal[ 1 ].includes('${')\n\n let styleOut = ''\n if( liftable ){\n const style = compileStyle( literal![ 1 ], { nsp: name, preprocess: options.preprocess })\n\n if( report )\n for( const d of style.diagnostics )\n ( this as any )?.warn?.(\n `[lips] ${d.code} ${d.message} (${id}:${d.loc.line}:${d.loc.col})` )\n\n const styleErrors = style.diagnostics.filter( d => d.severity === 'error' )\n if( styleErrors.length )\n throw new Error(\n `[lips] ${id}: ${styleErrors[0].message} at line ${styleErrors[0].loc.line}:${styleErrors[0].loc.col}` )\n\n styleOut = ` style: ${serializeStyleIR( style.ir )},\\n`\n }\n else if( hasStyle && report )\n ( this as any )?.warn?.(\n `[lips] ${id}: stylesheet could not be precompiled (interpolated template literal) — `\n + 'it ships as source and needs \"@lipsjs/lips\", not \"@lipsjs/lips/runtime\".' )\n\n return {\n code: `${script}\nconst __lips_ir__ = ${serializeIR( ir )};\nexport default {\n ir: __lips_ir__,\n${styleOut} ${/\\bconst\\s+state\\b/.test( script ) ? 'state,' : ''}\n ${/\\bconst\\s+handler\\b/.test( script ) ? 'handler,' : ''}\n ${/\\bconst\\s+_static\\b/.test( script ) ? '_static,' : ''}\n ${/\\bconst\\s+context\\b/.test( script ) ? 'context,' : ''}\n ${hasStyle && !liftable ? 'stylesheet,' : ''}\n};\n`,\n map: null\n }\n }\n }\n}\n"
|
|
10
|
+
],
|
|
11
|
+
"mappings": "8QA4FA,SAAS,CAAc,CAAE,EAAc,CACrC,OAAO,EAAK,QAAS,iCAAkC,KAAK,GAAgB,EAAI,EAIlF,MAAM,CAAe,CAME,IALb,IAAM,EACN,WAA8B,KAE7B,YAAoC,CAAC,EAE9C,WAAW,CAAU,EAAa,CAAb,WAGb,MAAM,CAAE,EAAgB,CAC9B,GAAI,CAAC,KAAK,WAAY,CACpB,KAAK,WAAa,CAAE,CAAE,EACtB,QAAS,EAAI,EAAG,EAAI,KAAK,IAAI,OAAQ,IACnC,GAAI,KAAK,IAAK,KAAQ;AAAA,EAAO,KAAK,WAAW,KAAM,EAAI,CAAE,EAG7D,IAAI,EAAK,EAAG,EAAK,KAAK,WAAW,OAAS,EAC1C,MAAO,EAAK,EAAI,CACd,IAAM,EAAQ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