@lipsjs/lips 0.2.0 → 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.
Files changed (45) hide show
  1. package/README.md +67 -1
  2. package/dist/lips.js +3532 -1094
  3. package/dist/lips.js.map +44 -19
  4. package/dist/lips.min.js +13 -9
  5. package/dist/lips.min.js.map +44 -19
  6. package/dist/mf2.min.js +4 -0
  7. package/dist/mf2.min.js.map +38 -0
  8. package/dist/precompile.min.js +19 -16
  9. package/dist/precompile.min.js.map +7 -6
  10. package/dist/runtime.min.js +4 -3
  11. package/dist/runtime.min.js.map +13 -12
  12. package/dist/stylis.min.js +3 -0
  13. package/dist/stylis.min.js.map +16 -0
  14. package/dist/types/i18n/engine.d.ts +14 -0
  15. package/dist/types/i18n/index.d.ts +122 -5
  16. package/dist/types/i18n/intl.d.ts +1 -0
  17. package/dist/types/i18n/lookup.d.ts +22 -0
  18. package/dist/types/ir/compiler.d.ts +75 -2
  19. package/dist/types/ir/expression.d.ts +32 -3
  20. package/dist/types/ir/facade.d.ts +74 -30
  21. package/dist/types/ir/host.d.ts +75 -0
  22. package/dist/types/ir/index.d.ts +5 -2
  23. package/dist/types/ir/policy.d.ts +95 -0
  24. package/dist/types/ir/runtime.d.ts +54 -19
  25. package/dist/types/ir/signal.d.ts +6 -4
  26. package/dist/types/ir/style.d.ts +119 -0
  27. package/dist/types/ir/swap.d.ts +5 -0
  28. package/dist/types/ir/tree.d.ts +51 -0
  29. package/dist/types/lips.d.ts +20 -3
  30. package/dist/types/lynx/a11y.d.ts +61 -0
  31. package/dist/types/lynx/background.d.ts +71 -0
  32. package/dist/types/lynx/main.d.ts +46 -0
  33. package/dist/types/lynx/protocol.d.ts +52 -0
  34. package/dist/types/lynx/style.d.ts +49 -0
  35. package/dist/types/lynx/template.d.ts +37 -0
  36. package/dist/types/mf2.d.ts +14 -0
  37. package/dist/types/precompile.d.ts +30 -5
  38. package/dist/types/runtime.d.ts +1 -1
  39. package/dist/types/stylesheet.d.ts +12 -16
  40. package/dist/types/stylis.d.ts +2 -0
  41. package/dist/types/types.d.ts +138 -11
  42. package/dist/types/untrusted.d.ts +17 -0
  43. package/dist/untrusted.min.js +5 -0
  44. package/dist/untrusted.min.js.map +13 -0
  45. package/package.json +20 -3
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/ir/expression.ts", "../src/ir/signal.ts", "../src/ir/swap.ts", "../src/ir/runtime.ts", "../src/events.ts", "../src/stylesheet.ts", "../src/i18n/formatters.ts", "../src/i18n/index.ts", "../src/ir/facade.ts", "../src/runtime.ts"],
3
+ "sources": ["../src/ir/expression.ts", "../src/ir/signal.ts", "../src/ir/host.ts", "../src/i18n/lookup.ts", "../src/ir/swap.ts", "../src/ir/runtime.ts", "../src/events.ts", "../src/stylesheet.ts", "../src/i18n/index.ts", "../src/ir/facade.ts", "../src/runtime.ts"],
4
4
  "sourcesContent": [
5
- "/**\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 (trusted contexts)\n * interpreted — sandboxed AST walker (CSP / untrusted embeds)\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 | { t: 'id', name: string }\n | { t: 'member', obj: Expr, prop: string | Expr, computed: boolean, optional: boolean }\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 }[] }\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 }\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 idx = this.assign()\n this.expect( ']', 'LIPS-E009' )\n expr = { t: 'member', obj: expr, prop: idx, computed: true, optional: true }\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 }\n }\n }\n else if( this.eat( '[' ) ){\n const idx = this.assign()\n this.expect( ']', 'LIPS-E009' )\n expr = { t: 'member', obj: expr, prop: idx, computed: true, optional: false }\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 }\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 }[] = []\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() })\n else if( key.t === 'id' ) // shorthand { a }\n props.push({ key: key.value, value: { t: 'id', name: key.value } })\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// ------------------------------------------------------------ dep extraction\nconst METAVAR_ROOTS = new Set([ 'state', 'input', 'context', 'self', 'arguments' ])\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 */\nconst ID_RENAMES: Record<string, string> = { static: '__static', arguments: '__args__' }\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\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(',')}\u0000${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: sandboxed AST walker — only whitelisted\n * globals are reachable. CSP-safe (no eval, no Function).\n */\nconst SAFE_GLOBALS: Record<string, any> = {\n Math, JSON, Object, Array, String, Number, Boolean, Date,\n parseInt, parseFloat, isNaN, isFinite,\n encodeURIComponent, decodeURIComponent, console\n}\n\nexport function interpretExpression( ast: Expr, env: ExprEnv ): any {\n const scope = env.scope || {}\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 SAFE_GLOBALS ) return SAFE_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> = {}\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",
6
- "/**\n * Phase 2 — reactivity core (RFC-001 §6)\n *\n * Minimal per-key signals: no history (that's the opt-in\n * `historySignal` wrapper, later), no deep proxies, no digest.\n * A write notifies exactly the effects that read that signal.\n */\n\ntype Effect = {\n run: () => void\n deps: Set<Set<Effect>>\n disposed: boolean\n}\n\nlet CURRENT: Effect | null = null\n\nexport function signal<T>( value: T ): [ () => T, ( next: T ) => void, () => void ] {\n const subs = new Set<Effect>()\n\n const notify = () => {\n // Copy: effects may retrack while running\n for( const e of [ ...subs ] )\n !e.disposed && e.run()\n }\n\n const read = () => {\n if( CURRENT && !CURRENT.disposed ){\n subs.add( CURRENT )\n CURRENT.deps.add( subs )\n }\n return value\n }\n const write = ( next: T ) => {\n if( Object.is( next, value ) ) return\n value = next\n notify()\n }\n /**\n * Force-notify without a value change — the deep-reactive\n * facade uses this when nested content mutates in place.\n */\n const touch = () => notify()\n\n return [ read, write, touch ]\n}\n\nexport interface EffectHandle {\n dispose(): void\n}\n\nexport function effect( fn: () => void ): EffectHandle {\n const e: Effect = {\n deps: new Set(),\n disposed: false,\n run(){\n if( e.disposed ) return\n\n // Re-track from scratch each run\n for( const subs of e.deps ) subs.delete( e )\n e.deps.clear()\n\n const prev = CURRENT\n CURRENT = e\n try { fn() }\n finally { CURRENT = prev }\n }\n }\n\n e.run()\n\n return {\n dispose(){\n e.disposed = true\n for( const subs of e.deps ) subs.delete( e )\n e.deps.clear()\n }\n }\n}\n\n/** Run `fn` without dependency tracking */\nexport function untrack<T>( fn: () => T ): T {\n const prev = CURRENT\n CURRENT = null\n try { return fn() }\n finally { CURRENT = prev }\n}\n\nconst IS_REACTIVE = Symbol('lips.reactive')\n\n/**\n * Per-key reactive facade over a plain object:\n * reading a key inside an effect subscribes to that key;\n * writing notifies only that key's subscribers.\n * Idempotent — wrapping a reactive object returns it as-is.\n *\n * Shallow by default (RFC §6). `deep: true` opts into nested\n * mutation tracking: plain objects/arrays read through a key are\n * lazily proxied, and any nested write force-notifies that top\n * key's subscribers (coarse but O(subscribers-of-key)).\n */\nexport function reactive<T extends object>( obj: T, deep = false ): T {\n if( ( obj as any )[ IS_REACTIVE ] ) return obj\n\n const sigs = new Map<PropertyKey, [ () => any, ( v: any ) => void, () => void ]>()\n const wrapped = deep ? new WeakMap<object, any>() : null\n\n const sigFor = ( key: PropertyKey, initial: any ) => {\n let s = sigs.get( key )\n if( !s ){\n s = signal( initial )\n sigs.set( key, s )\n }\n return s\n }\n\n /** Only plain objects/arrays are deep-wrapped (Map/Date/etc. pass through) */\n const isPlain = ( v: any ) =>\n v !== null && typeof v === 'object'\n && ( Array.isArray( v ) || Object.getPrototypeOf( v ) === Object.prototype )\n\n /**\n * Array mutators write several times (push sets an index AND\n * length). Run them atomically so one operation is one\n * notification, not one per internal write.\n */\n const ARRAY_MUTATORS = new Set([ 'push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse', 'fill', 'copyWithin' ])\n\n const deepWrap = ( value: any, touch: () => void ): any => {\n if( !deep || !isPlain( value ) ) return value\n\n const hit = wrapped!.get( value )\n if( hit ) return hit\n\n let muted = false\n\n const proxy = new Proxy( value, {\n get( t: any, k ){\n const v = t[ k ]\n\n if( Array.isArray( t ) && typeof k === 'string' && ARRAY_MUTATORS.has( k ) && typeof v === 'function' )\n return ( ...args: any[] ) => {\n muted = true\n try { return v.apply( t, args ) }\n finally {\n muted = false\n touch()\n }\n }\n\n return isPlain( v ) ? deepWrap( v, touch ) : v\n },\n set( t: any, k, v ){\n t[ k ] = v\n !muted && touch()\n return true\n },\n deleteProperty( t: any, k ){\n delete t[ k ]\n !muted && touch()\n return true\n }\n })\n\n wrapped!.set( value, proxy )\n return proxy\n }\n\n return new Proxy( obj, {\n get( target: any, key ){\n if( key === IS_REACTIVE ) return true\n if( typeof key === 'string' ){\n const s = sigFor( key, target[ key ] )\n return deepWrap( s[0](), s[2] )\n }\n return target[ key ]\n },\n set( target: any, key, value ){\n target[ key ] = value\n typeof key === 'string' && sigFor( key, value )[1]( value )\n return true\n },\n has( target, key ){ return key in target },\n deleteProperty( target: any, key ){\n delete target[ key ]\n typeof key === 'string' && sigs.get( key )?.[1]( undefined )\n return true\n }\n }) as T\n}\n",
7
- "/**\n * Phase 2 — hot-swap support (RFC-001 §8)\n *\n * Structural IR comparison by EXPRESSION SOURCE: two compilations\n * of related templates produce different expression-table indices,\n * so equality must resolve every `E` through its own table before\n * comparing. These normalizers produce plain comparable shapes.\n */\n\nimport type { BlockIR, BindIR, ChildIR, CompInput } from './compiler'\n\nexport interface SwapChange {\n kind: 'skeleton' | 'binds' | 'block'\n /** Block-tree coordinates, e.g. 'root', 'root/2', 'root/2/0' */\n path: string\n}\nexport interface SwapReport {\n changes: SwapChange[]\n}\n\n// ------------------------------------------------------------- normalizers\nconst normInput = ( ci: CompInput | null | undefined, x: string[] ): any =>\n ci == null ? ci : 'e' in ci ? { $: x[ ci.e ] } : ci\n\nexport const normBind = ( b: BindIR, x: string[] ): any => ({ ...b, e: x[ b.e ] })\n\nexport function normChild( c: ChildIR, x: string[] ): any {\n switch( c.t ){\n case 'macro':\n return { t: c.t, name: c.name, args: c.args,\n vars: Object.fromEntries( Object.entries( c.vars ).map( ( [ k, v ] ) => [ k, normInput( v, x ) ] ) ),\n block: normBlock( c.block, x ) }\n case 'if':\n return { t: c.t, branches: c.branches.map( b => ({\n when: b.when == null ? null : x[ b.when ],\n block: normBlock( b.block, x )\n }) ) }\n case 'for':\n return {\n t: c.t, args: c.args,\n of: c.of === undefined ? undefined : x[ c.of ],\n from: normInput( c.from, x ), to: normInput( c.to, x ), by: normInput( c.by, x ),\n block: normBlock( c.block, x )\n }\n case 'switch':\n return { t: c.t, on: x[ c.on ], cases: c.cases.map( k => ({\n is: k.is === null ? null : normInput( k.is, x ),\n block: normBlock( k.block, x )\n }) ) }\n case 'async':\n return {\n t: c.t, awaitE: x[ c.awaitE ],\n then: c.then && { args: c.then.args, block: normBlock( c.then.block, x ) },\n catch: c.catch && { args: c.catch.args, block: normBlock( c.catch.block, x ) },\n loading: c.loading && normBlock( c.loading, x )\n }\n case 'let':\n return { t: c.t, const: c.const,\n vars: Object.fromEntries( Object.entries( c.vars ).map( ( [ k, v ] ) => [ k, normInput( v, x ) ] ) ) }\n case 'log':\n return { t: c.t, e: x[ c.e ] }\n case 'comp':\n case 'dynamic':\n return {\n t: c.t,\n name: c.t === 'comp' ? c.name : undefined,\n tag: c.t === 'dynamic' ? x[ c.tag ] : undefined,\n inputs: Object.fromEntries( Object.entries( c.inputs ).map( ( [ k, v ] ) => [ k, normInput( v, x ) ] ) ),\n spreads: c.spreads.map( e => x[ e ] ),\n events: c.events.map( ev => ({ name: ev.name, e: x[ ev.e ] }) ),\n contents: c.contents && { args: c.contents.args, block: normBlock( c.contents.block, x ) }\n }\n }\n}\n\nexport const normBlock = ( b: BlockIR, x: string[] ): any => ({\n html: b.html,\n scope: b.scope,\n binds: b.binds.map( bind => normBind( bind, x ) ),\n blocks: b.blocks.map( c => normChild( c, x ) )\n})\n\n// ------------------------------------------------------------- comparators\nexport const sameChild = ( a: ChildIR, ax: string[], b: ChildIR, bx: string[] ) =>\n a.t === b.t && JSON.stringify( normChild( a, ax ) ) === JSON.stringify( normChild( b, bx ) )\n\nexport const sameBinds = ( a: BindIR[], ax: string[], b: BindIR[], bx: string[] ) =>\n JSON.stringify( a.map( x => normBind( x, ax ) ) ) === JSON.stringify( b.map( x => normBind( x, bx ) ) )\n\nexport const sameLets = ( a: BlockIR, ax: string[], b: BlockIR, bx: string[] ) => {\n const lets = ( blk: BlockIR, x: string[] ) =>\n JSON.stringify( blk.blocks.filter( c => c.t === 'let' ).map( c => normChild( c, x ) ) )\n return lets( a, ax ) === lets( b, bx )\n}\n",
8
- "/**\n * Phase 2 — IR runtime (RFC-001 §6, §8)\n *\n * TemplateIR → live DOM:\n * - skeletons parsed ONCE per block into <template>, instantiated\n * per use via content.cloneNode(true) + a bind walk over\n * precomputed integer paths\n * - every bind is its own effect over per-key signals — updates are\n * O(changed bindings), no digest, no clones, no deep equality\n * - block instances are bracketed by owned comment markers so\n * control-flow content moves/disposes as a range\n * - dual expression modes over the same IR: 'compiled' (Function,\n * trusted) / 'interpreted' (sandboxed AST walker, CSP-safe)\n *\n * Hot-swap (§8): instances retain their structure (bind handles,\n * child handles, resolved path nodes) so `instance.swap( newIR )`\n * can diff old vs new by expression source and update surgically:\n * - identical subtrees → kept wholesale (zero DOM work)\n * - bind-only changes → effects rewired onto the SAME nodes\n * - skeleton changes → that block re-rendered in place\n * State lives outside the IR, so it survives by construction.\n */\n\nimport type { TemplateIR, BlockIR, BindIR, ChildIR, ArmIR, CompInput, E, Path } from './compiler'\nimport type { ExprEnv, Expr } from './expression'\nimport { parseExpression, compileExpression, interpretExpression } from './expression'\nimport { signal, effect, untrack, reactive } from './signal'\nimport type { SwapChange, SwapReport } from './swap'\nimport { sameBinds, sameChild, sameLets } from './swap'\n\n// ------------------------------------------------------------------- types\nexport interface IRComponentDef {\n ir: TemplateIR\n state?: Record<string, any>\n statics?: Record<string, any>\n /** Context fields this component subscribes to (fires onContext) */\n context?: string[]\n /** Scoped stylesheet source + scope name (the `rel` value) */\n stylesheet?: string\n nsp?: string\n /** Deep-reactive component state (old-engine parity) */\n deep?: boolean\n /**\n * Methods bound to the component self — lifecycle keys\n * (onCreate/onInput/onMount/onDestroy) are invoked by the\n * runtime at the matching moments.\n */\n handlers?: Record<string, ( this: any, ...args: any[] ) => any>\n}\n\nexport interface RuntimeOptions {\n mode?: 'compiled' | 'interpreted'\n components?: Record<string, IRComponentDef>\n /** Host-provided context subscription (returns an unsubscribe) */\n watchContext?( fields: string[], fn: () => void ): () => void\n /**\n * Resolve a plain template object (e.g. a route's `template`)\n * into a component definition — the host owns compilation and\n * caching. Enables `<{state.page}/>` with template objects.\n */\n resolveTemplate?( value: any ): IRComponentDef | undefined\n /** Extra members merged onto every component's self (e.g. setContext) */\n expose?: Record<string, any>\n /**\n * Host-provided stylesheet injector (full build wires Stylis; the\n * precompiled `./runtime` build omits it). Returns a handle whose\n * `clear()` releases one reference.\n */\n createStylesheet?( nsp: string, css: string ): { clear(): void }\n /**\n * i18n plugin hook (RFC §6): both calls must READ a language\n * signal so translated binds re-run on language change.\n */\n i18n?: {\n translate( text: string ): string\n format( reference: string, params: any ): string\n }\n}\n\nexport interface RenderSetup {\n state?: Record<string, any>\n input?: Record<string, any>\n context?: Record<string, any>\n static?: Record<string, any>\n handlers?: Record<string, ( this: any, ...args: any[] ) => any>\n /** Deep-reactive root state (old-engine parity) */\n deep?: boolean\n /** Extra members merged onto self before handlers bind (e.g. emit) */\n expose?: Record<string, any>\n /** Scoped stylesheet source + scope name (the `rel` value) */\n stylesheet?: string\n nsp?: string\n}\n\nexport interface IRInstance {\n state: Record<string, any>\n self: Record<string, any>\n nodes: Node[]\n mount( container: Element ): void\n swap( newIR: TemplateIR ): SwapReport\n dispose(): void\n}\n\ntype RunEnv = ExprEnv\n\ninterface BindHandle {\n bind: BindIR\n node: Node\n textNode?: Text\n dispose: () => void\n}\ninterface ChildHandle {\n child: ChildIR\n exprs: string[]\n anchor: Comment\n dispose: () => void\n}\n\n/** A rendered block: bracketed range + retained structure for swap */\ninterface BlockInstance {\n start: Comment\n end: Comment\n block: BlockIR\n exprs: string[]\n penv: RunEnv // parent env (for full re-render)\n benv: RunEnv // env with this block's scope layer\n pathNodes: Map<string, Node> // pathKey → resolved node (binds + anchors)\n bindHandles: BindHandle[]\n childHandles: ChildHandle[]\n}\n\n// ----------------------------------------------------------------- helpers\n/** Marks a slot renderer handed to a child as `input.renderer` */\nconst SLOT = Symbol('lips.slot')\n\ninterface SlotRenderer {\n [ SLOT ]: true\n args: string[]\n render( argvalues?: Record<string, any> ): BlockInstance\n}\nconst isSlot = ( v: any ): v is SlotRenderer => !!v && typeof v === 'object' && v[ SLOT ] === true\n\n/**\n * Component lifecycle plumbing (RFC §6: ownership events, not\n * document-wide observation). One hooks object per component\n * instance; nested components get their own.\n */\ninterface ComponentHooks {\n notifyUpdate(): void\n onError( error: unknown ): void\n /** Called once the component's first render completes */\n ready(): void\n}\n\nfunction makeHooks( self: any ): ComponentHooks {\n let scheduled = false\n let isReady = false\n\n const onError = ( error: unknown ) =>\n typeof self.onError === 'function'\n ? self.onError( error )\n : console.error('[lips:ir]', error )\n\n return {\n onError,\n ready(){ isReady = true },\n notifyUpdate(){\n // Suppress during the initial render pass\n if( !isReady || scheduled ) return\n scheduled = true\n\n queueMicrotask( () => {\n scheduled = false\n try {\n typeof self.onUpdate === 'function' && self.onUpdate()\n typeof self.onRender === 'function' && self.onRender()\n }\n catch( error ){ onError( error ) }\n })\n }\n }\n}\n\n/**\n * Attach callbacks queued during render, flushed once the nodes\n * are actually in the document (root mount, or immediate when the\n * insertion point is already live).\n */\nconst PENDING_ATTACH: { node: () => Node | undefined, fn: () => void }[] = []\n\nfunction flushAttach(){\n for( let i = PENDING_ATTACH.length - 1; i >= 0; i-- ){\n const entry = PENDING_ATTACH[ i ]\n const node = entry.node()\n\n if( node && node.isConnected ){\n PENDING_ATTACH.splice( i, 1 )\n entry.fn()\n }\n }\n}\n\nconst AST_CACHE = new Map<string, Expr>()\nfunction astOf( src: string ): Expr {\n let ast = AST_CACHE.get( src )\n if( !ast ){\n ast = parseExpression( src ).ast\n AST_CACHE.set( src, ast )\n }\n return ast\n}\n\nconst SKELETONS = new WeakMap<BlockIR, HTMLTemplateElement>()\nfunction skeleton( block: BlockIR ): HTMLTemplateElement {\n let tpl = SKELETONS.get( block )\n if( !tpl ){\n tpl = document.createElement('template')\n tpl.innerHTML = block.html\n SKELETONS.set( block, tpl )\n }\n return tpl\n}\n\nconst pathKey = ( p: Path ) => p.join(',')\n\nfunction resolvePath( root: ParentNode, p: Path ): Node {\n let node: any = root\n for( const i of p ) node = node.childNodes[ i ]\n return node\n}\n\nfunction nodesOf( inst: BlockInstance ): Node[] {\n const out: Node[] = []\n let n: Node | null = inst.start\n while( n ){\n out.push( n )\n if( n === inst.end ) break\n n = n.nextSibling\n }\n return out\n}\nfunction insertAfter( ref: Node, nodes: Node[] ){\n const parent = ref.parentNode\n if( !parent ) return\n let anchor = ref\n for( const n of nodes ){\n parent.insertBefore( n, anchor.nextSibling )\n anchor = n\n }\n}\n\n/**\n * Scoped stylesheet: stamp `rel=\"<nsp>\"` on the component's top-level\n * element roots so the injected `[rel=\"<nsp>\"] { … }` sheet matches,\n * then inject via the host factory. The `!rel` guard lets an inner\n * component's scope win on a shared root. Returns a clear disposer.\n */\nfunction applyScopedStyles(\n options: RuntimeOptions,\n inst: BlockInstance,\n nsp: string,\n css: string\n): ( () => void ) | undefined {\n for( const n of nodesOf( inst ) )\n if( n.nodeType === 1 /* ELEMENT_NODE */ && !( n as Element ).hasAttribute('rel') )\n ( n as Element ).setAttribute('rel', nsp )\n\n const sheet = options.createStylesheet?.( nsp, css )\n return sheet ? () => sheet.clear() : undefined\n}\nfunction disposeInstance( inst: BlockInstance ){\n for( const h of inst.bindHandles ) h.dispose()\n for( const h of inst.childHandles ) h.dispose()\n}\nfunction destroy( inst: BlockInstance | null ){\n if( !inst ) return\n disposeInstance( inst )\n for( const n of nodesOf( inst ) ) ( n as ChildNode ).remove()\n}\n\n/** Split an instruction on top-level commas (strings/brackets opaque) */\nfunction 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\nconst applyAttr = ( el: Element, name: string, v: any ) => {\n v === false || v == null\n ? el.removeAttribute( name )\n : el.setAttribute( name, v === true ? '' : String( v ) )\n}\n\nconst defineGetter = ( scope: any, name: string, get: () => any ) =>\n Object.defineProperty( scope, name, { get, enumerable: true, configurable: true } )\n\n// ---------------------------------------------------------------- renderer\nclass IRRenderer {\n constructor( readonly ir: TemplateIR, private options: RuntimeOptions, private hooks?: ComponentHooks ){}\n\n /**\n * Bind effects run inside the component's error boundary and\n * report post-initial re-runs as component updates.\n */\n private guarded( fn: () => void ){\n let first = true\n return effect( () => {\n try { fn() }\n catch( error ){\n this.hooks ? this.hooks.onError( error ) : console.error('[lips:ir]', error )\n }\n first ? first = false : this.hooks?.notifyUpdate()\n })\n }\n\n /** Expression runner for a table entry, honoring the execution mode */\n private runner( e: E, scopeNames: string[] ): ( env: RunEnv ) => any {\n return this.srcRunner( this.ir.exprs[ e ], scopeNames )\n }\n private srcRunner( src: string, scopeNames: string[] ): ( env: RunEnv ) => any {\n if( this.options.mode === 'interpreted' ){\n const ast = astOf( src )\n return env => interpretExpression( ast, env )\n }\n const compiled = compileExpression( src, scopeNames )\n return env => compiled.run( env )\n }\n\n renderBlock( block: BlockIR, env: RunEnv ): BlockInstance {\n const frag = skeleton( block ).content.cloneNode( true ) as DocumentFragment\n\n /**\n * Resolve every bind/anchor path BEFORE any mutation —\n * runtime insertions (text nodes, markers, arm content)\n * shift childNodes indices.\n */\n const pathNodes = new Map<string, Node>()\n const bindNodes = block.binds.map( b => {\n const node = resolvePath( frag, b.p )\n pathNodes.set( pathKey( b.p ), node )\n return node\n })\n const anchorNodes = block.blocks.map( b => {\n const node = resolvePath( frag, b.p ) as Comment\n pathNodes.set( pathKey( b.p ), node )\n return node\n })\n\n // Bracket the block content as an owned range\n const start = document.createComment('^')\n const end = document.createComment('$')\n frag.insertBefore( start, frag.firstChild )\n frag.appendChild( end )\n\n // Scope chain for this block\n const scope = Object.create( env.scope ?? null )\n const benv: RunEnv = { ...env, scope }\n\n const inst: BlockInstance = {\n start, end, block,\n exprs: this.ir.exprs,\n penv: env, benv,\n pathNodes,\n bindHandles: [],\n childHandles: []\n }\n\n /**\n * <let>/<const> pass first — their names are visible to\n * every bind of this block (RFC decision #1)\n */\n block.blocks.forEach( ( child, i ) => {\n if( child.t !== 'let' ) return\n\n const letDisposers: ( () => void )[] = []\n for( const [ name, input ] of Object.entries( child.vars ) ){\n if( 'lit' in input ){\n const [ get ] = signal( input.lit )\n defineGetter( scope, name, get )\n }\n else {\n const [ get, set ] = signal<any>( undefined )\n defineGetter( scope, name, get )\n const run = this.runner( input.e, block.scope )\n letDisposers.push( effect( () => set( run( benv ) ) ).dispose )\n }\n }\n\n inst.childHandles[ i ] = {\n child, exprs: this.ir.exprs, anchor: anchorNodes[ i ],\n dispose: () => letDisposers.forEach( d => d() )\n }\n })\n\n // Binds — one effect each\n inst.bindHandles = block.binds.map( ( bind, i ) =>\n this.bindOne( bind, bindNodes[ i ], benv, block.scope ) )\n\n // Control-flow / component blocks\n block.blocks.forEach( ( child, i ) => {\n if( child.t === 'let' ) return\n inst.childHandles[ i ] = {\n child, exprs: this.ir.exprs, anchor: anchorNodes[ i ],\n dispose: this.execBlock( child, anchorNodes[ i ], benv, block.scope )\n }\n })\n\n return inst\n }\n\n /** Wire one bind onto its node; returns a swap-capable handle */\n private bindOne( bind: BindIR, node: Node, benv: RunEnv, scopeNames: string[], reuseText?: Text ): BindHandle {\n switch( bind.t ){\n case 'text': {\n const textNode = reuseText ?? document.createTextNode('')\n !reuseText && insertAfter( node, [ textNode ] )\n const run = this.runner( bind.e, scopeNames )\n const i18n = bind.i18n ? this.options.i18n : undefined\n const h = this.guarded( () => {\n const v = run( benv )\n const text = v == null ? '' : String( v )\n textNode.data = i18n ? i18n.translate( text ) : text\n })\n return { bind, node, textNode, dispose: h.dispose }\n }\n case 'attr': {\n const run = this.runner( bind.e, scopeNames )\n const i18n = bind.i18n ? this.options.i18n : undefined\n const h = this.guarded( () => {\n const v = run( benv )\n applyAttr( node as Element, bind.name,\n i18n && v != null ? i18n.translate( String( v ) ) : v )\n })\n return { bind, node, dispose: h.dispose }\n }\n case 'prop': {\n const run = this.runner( bind.e, scopeNames )\n\n if( bind.name === 'format' ){\n const ref = bind.ref || ''\n const h = this.guarded( () => {\n const params = run( benv )\n const text = this.options.i18n?.format( ref, params )\n ;( node as Element ).textContent = text == null ? '' : String( text )\n })\n return { bind, node, dispose: h.dispose }\n }\n\n const h = this.guarded( () => {\n const v = run( benv )\n bind.name === 'html'\n ? ( node as Element ).innerHTML = v == null ? '' : String( v )\n // 'text' | 'format' — format is the i18n plugin hook (Phase 3)\n : ( node as Element ).textContent = v == null ? '' : String( v )\n })\n return { bind, node, dispose: h.dispose }\n }\n case 'event': {\n const handler = this.eventDispatcher( this.ir.exprs[ bind.e ], scopeNames, benv )\n ;( node as Element ).addEventListener( bind.name, handler )\n return { bind, node, dispose: () => ( node as Element ).removeEventListener( bind.name, handler ) }\n }\n case 'spread': {\n const run = this.runner( bind.e, scopeNames )\n let prev = new Set<string>()\n const h = this.guarded( () => {\n const obj = run( benv ) || {}\n const next = new Set<string>( Object.keys( obj ) )\n for( const k of prev ) !next.has( k ) && ( node as Element ).removeAttribute( k )\n for( const k of next ) applyAttr( node as Element, k, obj[ k ] )\n prev = next\n })\n return { bind, node, dispose: h.dispose }\n }\n }\n }\n\n // ----------------------------------------------------------------- swap\n /**\n * Diff-and-patch a live block against a new BlockIR (whose E\n * indices refer to THIS renderer's expression table). Returns\n * the live instance — a fresh one when a rebuild was needed.\n */\n swapBlock( inst: BlockInstance, newBlock: BlockIR, report: SwapChange[], path: string ): BlockInstance {\n /**\n * Structural rebuild triggers: skeleton, scope shape, or\n * let wiring changed — re-render this block in place.\n * (Worst case equals a fresh render — never worse.)\n */\n if( inst.block.html !== newBlock.html\n || JSON.stringify( inst.block.scope ) !== JSON.stringify( newBlock.scope )\n || !sameLets( inst.block, inst.exprs, newBlock, this.ir.exprs ) )\n return this.rebuild( inst, newBlock, report, path )\n\n // Bind-only changes: rewire effects onto the SAME nodes\n if( !sameBinds( inst.block.binds, inst.exprs, newBlock.binds, this.ir.exprs ) ){\n const nodes = newBlock.binds.map( b => inst.pathNodes.get( pathKey( b.p ) ) )\n\n // A bind on a path we never resolved → degrade to rebuild\n if( nodes.some( n => !n ) )\n return this.rebuild( inst, newBlock, report, path )\n\n const oldTexts = new Map<string, Text>()\n inst.bindHandles.forEach( h => h.textNode && oldTexts.set( pathKey( h.bind.p ), h.textNode ) )\n inst.bindHandles.forEach( h => h.dispose() )\n\n const reused = new Set<string>()\n inst.bindHandles = newBlock.binds.map( ( b, i ) => {\n const key = pathKey( b.p )\n const reuse = b.t === 'text' ? oldTexts.get( key ) : undefined\n reuse && reused.add( key )\n return this.bindOne( b, nodes[ i ]!, inst.benv, newBlock.scope, reuse )\n })\n // Text nodes whose bind disappeared\n oldTexts.forEach( ( tn, key ) => !reused.has( key ) && tn.remove() )\n\n report.push({ kind: 'binds', path })\n }\n\n /**\n * Children pairwise (equal html ⇒ equal anchor count):\n * identical-by-source subtrees are kept wholesale; changed\n * subtrees re-execute at their existing anchor.\n */\n for( let i = 0; i < newBlock.blocks.length; i++ ){\n const newChild = newBlock.blocks[ i ]\n const oldH = inst.childHandles[ i ]\n if( newChild.t === 'let' ) continue // covered by sameLets above\n\n if( oldH && sameChild( oldH.child, oldH.exprs, newChild, this.ir.exprs ) ) continue\n\n oldH?.dispose()\n inst.childHandles[ i ] = {\n child: newChild, exprs: this.ir.exprs, anchor: oldH.anchor,\n dispose: this.execBlock( newChild, oldH.anchor, inst.benv, newBlock.scope )\n }\n report.push({ kind: 'block', path: `${path}/${i}` })\n }\n\n inst.block = newBlock\n inst.exprs = this.ir.exprs\n return inst\n }\n\n private rebuild( inst: BlockInstance, newBlock: BlockIR, report: SwapChange[], path: string ): BlockInstance {\n const fresh = this.renderBlock( newBlock, inst.penv )\n insertAfter( inst.end, nodesOf( fresh ) )\n destroy( inst )\n report.push({ kind: 'skeleton', path })\n return fresh\n }\n\n // -------------------------------------------------------------- executors\n /** Execute a control-flow/component block; returns its disposer */\n private execBlock( child: ChildIR, anchor: Comment, benv: RunEnv, scopeNames: string[] ): () => void {\n const disposers: ( () => void )[] = []\n\n switch( child.t ){\n case 'if': {\n const runs = child.branches.map( b => b.when != null ? this.runner( b.when, scopeNames ) : null )\n let current: BlockInstance | null = null\n let activeIdx = -2\n\n const h = effect( () => {\n let idx = -1\n for( let i = 0; i < child.branches.length; i++ ){\n const run = runs[ i ]\n if( !run || run( benv ) ){ idx = i; break }\n }\n if( idx === activeIdx ) return\n activeIdx = idx\n\n untrack( () => {\n destroy( current )\n current = null\n if( idx >= 0 ){\n current = this.renderBlock( child.branches[ idx ].block, benv )\n insertAfter( anchor, nodesOf( current ) )\n }\n })\n })\n\n disposers.push( () => { h.dispose(); destroy( current ) } )\n break\n }\n\n case 'switch': {\n const onRun = this.runner( child.on, scopeNames )\n const caseRuns = child.cases.map( c =>\n c.is && 'e' in c.is ? this.runner( c.is.e, scopeNames ) : null )\n let current: BlockInstance | null = null\n let activeIdx = -2\n\n const h = effect( () => {\n const value = onRun( benv )\n let idx = -1, defaultIdx = -1\n\n for( let i = 0; i < child.cases.length; i++ ){\n const c = child.cases[ i ]\n if( c.is === null ){ defaultIdx = i; continue }\n\n const is = 'lit' in c.is ? c.is.lit : caseRuns[ i ]!( benv )\n if( Array.isArray( is ) ? is.includes( value ) : is === value ){ idx = i; break }\n }\n if( idx === -1 ) idx = defaultIdx\n if( idx === activeIdx ) return\n activeIdx = idx\n\n untrack( () => {\n destroy( current )\n current = null\n if( idx >= 0 ){\n current = this.renderBlock( child.cases[ idx ].block, benv )\n insertAfter( anchor, nodesOf( current ) )\n }\n })\n })\n\n disposers.push( () => { h.dispose(); destroy( current ) } )\n break\n }\n\n case 'macro': {\n /**\n * Inlined macro body: declared argv become block-scoped\n * reactive vars; every call-site attribute also lands in\n * `arguments` (per-key reactive, so `arguments.x` binds\n * track only that key).\n */\n const scope = Object.create( benv.scope ?? null )\n const args = reactive( {} as Record<string, any> )\n\n for( const [ name, ci ] of Object.entries( child.vars ) ){\n if( 'lit' in ci ){\n args[ name ] = ci.lit\n if( child.args.includes( name ) ){\n const [ get ] = signal( ci.lit )\n defineGetter( scope, name, get )\n }\n continue\n }\n\n const run = this.runner( ci.e, scopeNames )\n const [ get, set ] = signal<any>( undefined )\n\n if( child.args.includes( name ) ) defineGetter( scope, name, get )\n\n disposers.push( effect( () => {\n const v = run( benv )\n set( v )\n args[ name ] = v\n }).dispose )\n }\n\n const inst = this.renderBlock( child.block, { ...benv, arguments: args, scope })\n insertAfter( anchor, nodesOf( inst ) )\n disposers.push( () => destroy( inst ) )\n break\n }\n\n case 'for':\n this.execFor( child, anchor, benv, scopeNames, disposers )\n break\n\n case 'async': {\n const awaitRun = this.runner( child.awaitE, scopeNames )\n let current: BlockInstance | null = null\n let token = 0\n\n const swapTo = ( arm: { args: string[], block: BlockIR } | BlockIR | undefined, value?: any ) => {\n destroy( current )\n current = null\n if( !arm ) return\n\n const isArm = 'block' in arm\n const scope2 = Object.create( benv.scope ?? null )\n if( isArm && arm.args[0] !== undefined ){\n const [ get ] = signal( value )\n defineGetter( scope2, arm.args[0], get )\n }\n current = this.renderBlock( isArm ? arm.block : arm, { ...benv, scope: scope2 } )\n insertAfter( anchor, nodesOf( current ) )\n }\n\n const h = effect( () => {\n const p = awaitRun( benv )\n const my = ++token\n\n untrack( () => {\n child.loading ? swapTo( child.loading ) : swapTo( undefined )\n\n Promise.resolve( p ).then(\n v => my === token && untrack( () => swapTo( child.then, v ) ),\n err => my === token && untrack( () => swapTo( child.catch, err ) )\n )\n })\n })\n\n disposers.push( () => { token++; h.dispose(); destroy( current ) } )\n break\n }\n\n case 'log': {\n const segs = splitTopLevel( this.ir.exprs[ child.e ] ).map( s => this.srcRunner( s, scopeNames ) )\n disposers.push( effect( () => console.log( ...segs.map( run => run( benv ) ) ) ).dispose )\n break\n }\n\n case 'comp': {\n const def = this.options.components?.[ child.name ]\n def\n ? this.execComponent( def, child, anchor, benv, scopeNames, disposers )\n : this.execElement( child, anchor, benv, scopeNames, disposers )\n break\n }\n\n case 'dynamic': {\n const tagRun = this.runner( child.tag, scopeNames )\n let inner: ( () => void )[] = []\n let activeVerb: any = Symbol('init')\n\n const h = effect( () => {\n const verb = tagRun( benv )\n if( verb === activeVerb ) return\n activeVerb = verb\n\n untrack( () => {\n for( const d of inner ) d()\n inner = []\n\n if( verb == null ) return\n\n /**\n * Slot placement: `<{input.renderer} …/>` renders the\n * parent's slotted body here; this tag's inputs become\n * the slot's argument values.\n */\n if( isSlot( verb ) ){\n const argvalues: Record<string, any> = {}\n for( const [ name, ci ] of Object.entries( child.inputs ) )\n argvalues[ name ] = 'lit' in ci ? ci.lit : this.runner( ci.e, scopeNames )( benv )\n\n const slotInst = verb.render( argvalues )\n insertAfter( anchor, nodesOf( slotInst ) )\n inner.push( () => destroy( slotInst ) )\n return\n }\n\n /**\n * Component name, a ready IRComponentDef, or a plain\n * template object resolved through the host hook.\n */\n const def = typeof verb === 'string'\n ? this.options.components?.[ verb ]\n : verb && typeof verb === 'object'\n ? ( verb.ir ? verb as IRComponentDef : this.options.resolveTemplate?.( verb ) )\n : undefined\n\n if( def ) this.execComponent( def, child, anchor, benv, scopeNames, inner )\n else if( typeof verb === 'string' )\n this.execElement( { ...child, name: verb } as any, anchor, benv, scopeNames, inner )\n })\n })\n\n disposers.push( () => { h.dispose(); for( const d of inner ) d() } )\n break\n }\n }\n\n return () => disposers.forEach( d => d() )\n }\n\n /** Keyed <for> — per-item scope signals, range moves, natural entry keys */\n private execFor(\n child: ChildIR & { t: 'for' },\n anchor: Comment,\n benv: RunEnv,\n scopeNames: string[],\n disposers: ( () => void )[]\n ){\n type Item = {\n key: any\n sigs: [ () => any, ( v: any ) => void, () => void ][]\n inst: BlockInstance\n }\n\n const\n ofRun = child.of !== undefined ? this.runner( child.of, scopeNames ) : null,\n byRun = child.by && 'e' in child.by ? this.runner( child.by.e, scopeNames ) : null,\n byPath = child.by && 'lit' in child.by ? String( child.by.lit ).split('.') : null,\n inputVal = ( ci: CompInput | undefined, env: RunEnv ) =>\n ci === undefined ? undefined : 'lit' in ci ? ci.lit : this.runner( ci.e, scopeNames )( env )\n\n let items: Item[] = []\n const byKey = new Map<any, Item>()\n\n /** Normalize source → [{ key, values(aligned with args) }] */\n const tuples = (): { key: any, values: any[] }[] => {\n // Numeric range\n if( ofRun === null ){\n const from = Number( inputVal( child.from, benv ) ?? 0 )\n const to = Number( inputVal( child.to, benv ) ?? from )\n const asc = from <= to\n const out: { key: any, values: any[] }[] = []\n for( let v = from; asc ? v <= to : v >= to; asc ? v++ : v-- )\n out.push({ key: v, values: [ v ] })\n return out\n }\n\n const src = ofRun( benv )\n const keyFor = ( item: any, fallback: any, index: number ) => {\n if( byRun ){\n const fn = byRun( benv )\n return typeof fn === 'function' ? fn( item, index ) : fallback\n }\n if( byPath ) return byPath.reduce( ( v: any, k ) => v?.[ k ], item )\n return fallback\n }\n\n if( Array.isArray( src ) )\n return src.map( ( item, i ) => ({ key: keyFor( item, i, i ), values: [ item, i ] }) )\n\n if( src instanceof Map )\n return [ ...src.entries() ].map( ( [ k, v ], i ) => ({ key: k, values: [ k, v, i ] }) )\n\n if( src && typeof src === 'object' )\n return Object.entries( src ).map( ( [ k, v ], i ) => ({ key: k, values: [ k, v, i ] }) )\n\n return []\n }\n\n const h = effect( () => {\n const next = tuples() // tracked reads\n untrack( () => {\n const seen = new Set<any>()\n const ordered: Item[] = []\n\n for( const t of next ){\n let key = t.key\n // Duplicate keys degrade to positional identity\n if( seen.has( key ) ){\n console.warn(`<for> duplicate key '${String( key )}' — falling back to positional identity`)\n key = `#dup:${ordered.length}`\n }\n seen.add( key )\n\n const existing = byKey.get( key )\n if( existing ){\n existing.sigs.forEach( ( [ get, set, touch ], j ) => {\n const nv = t.values[ j ]\n /**\n * Same object reference may have mutated in place\n * (deep-reactive mode) — force the item's binds to\n * re-evaluate; unchanged primitives stay silent.\n */\n Object.is( get(), nv ) && typeof nv === 'object' && nv !== null\n ? touch()\n : set( nv )\n })\n ordered.push( existing )\n }\n else {\n const scope2 = Object.create( benv.scope ?? null )\n const sigs = t.values.map( v => signal( v ) )\n child.args.forEach( ( name, j ) => sigs[ j ] && defineGetter( scope2, name, sigs[ j ][0] ) )\n\n const inst = this.renderBlock( child.block, { ...benv, scope: scope2 } )\n const item: Item = { key, sigs, inst }\n byKey.set( key, item )\n ordered.push( item )\n }\n }\n\n // Remove disappeared keys\n for( const item of items )\n if( !ordered.includes( item ) ){\n byKey.delete( item.key )\n destroy( item.inst )\n }\n\n // Pointer walk: enforce order with range moves\n let pointer: Node = anchor\n for( const item of ordered ){\n if( pointer.nextSibling !== item.inst.start )\n insertAfter( pointer, nodesOf( item.inst ) )\n pointer = item.inst.end\n }\n\n items = ordered\n })\n })\n\n disposers.push( () => {\n h.dispose()\n for( const item of items ) destroy( item.inst )\n items = []\n byKey.clear()\n })\n }\n\n /** Registered component: reactive inputs, slots, events, own env */\n private execComponent(\n def: IRComponentDef,\n child: { inputs: Record<string, CompInput>, spreads: E[], events?: { name: string, e: E }[], contents?: ArmIR },\n anchor: Comment,\n benv: RunEnv,\n scopeNames: string[],\n disposers: ( () => void )[]\n ){\n const input = reactive( {} as Record<string, any> )\n\n for( const [ name, ci ] of Object.entries( child.inputs ) ){\n if( 'lit' in ci ) input[ name ] = ci.lit\n else {\n const run = this.runner( ci.e, scopeNames )\n disposers.push( effect( () => input[ name ] = run( benv ) ).dispose )\n }\n }\n for( const e of child.spreads ){\n const run = this.runner( e, scopeNames )\n disposers.push( effect( () => {\n const obj = run( benv ) || {}\n untrack( () => Object.entries( obj ).forEach( ( [ k, v ] ) => input[ k ] = v ) )\n }).dispose )\n }\n\n /**\n * Slotted body → `input.renderer` (old-engine convention):\n * the child template places it with `<{input.renderer}/>`.\n * Content renders in the PARENT scope — a slot closes over\n * where it was written, not where it is placed.\n */\n if( child.contents ){\n const\n parent = this,\n contents = child.contents,\n penv = benv\n\n input.renderer = {\n [ SLOT ]: true,\n args: contents.args,\n render( argvalues?: Record<string, any> ){\n const scope = Object.create( penv.scope ?? null )\n\n contents.args.forEach( name => {\n const [ get ] = signal( argvalues?.[ name ] )\n defineGetter( scope, name, get )\n })\n\n return parent.renderBlock( contents.block, { ...penv, scope } )\n }\n }\n }\n\n const state = reactive( { ...( def.state || {} ) }, def.deep ?? false )\n\n /**\n * Component event bus: the child emits, the parent's\n * `on-*( … )` instructions receive the emitted arguments.\n */\n const listeners = new Map<string, ( ( ...args: any[] ) => void )[]>()\n const self: any = {\n ...( this.options.expose || {} ),\n state, input, static: def.statics, context: benv.context,\n emit( event: string, ...args: any[] ){\n listeners.get( event )?.forEach( fn => fn( ...args ) )\n },\n on( event: string, fn: ( ...args: any[] ) => void ){\n listeners.set( event, [ ...( listeners.get( event ) || [] ), fn ])\n return self\n },\n off( event: string ){\n listeners.delete( event )\n return self\n }\n }\n def.handlers && Object.entries( def.handlers ).forEach( ( [ k, fn ] ) => self[ k ] = fn.bind( self ) )\n\n child.events?.forEach( ev => {\n const dispatch = this.eventDispatcher( this.ir.exprs[ ev.e ], scopeNames, benv )\n self.on( ev.name, dispatch )\n })\n\n const hooks = makeHooks( self )\n\n // Lifecycle: creation → (initial input) → render → mount → attach\n try { typeof self.onCreate === 'function' && self.onCreate() }\n catch( error ){ hooks.onError( error ) }\n\n try { Object.keys( input ).length && typeof self.onInput === 'function' && self.onInput() }\n catch( error ){ hooks.onError( error ) }\n\n const cenv: RunEnv = { state, input, context: benv.context, static: def.statics, self, scope: undefined }\n const renderer = new IRRenderer( def.ir, this.options, hooks )\n const inst = renderer.renderBlock( def.ir.root, cenv )\n\n // Scoped stylesheet — stamp rel before the nodes go live\n const clearStyles = def.stylesheet\n ? applyScopedStyles( this.options, inst, def.nsp || 'lips', def.stylesheet )\n : undefined\n\n insertAfter( anchor, nodesOf( inst ) )\n hooks.ready()\n\n try {\n typeof self.onMount === 'function' && self.onMount()\n typeof self.onRender === 'function' && self.onRender()\n }\n catch( error ){ hooks.onError( error ) }\n\n /**\n * Declared context subscription — fires onContext only when\n * one of the component's own fields changes.\n */\n let unwatchContext: ( () => void ) | undefined\n if( def.context?.length && typeof self.onContext === 'function' && this.options.watchContext )\n unwatchContext = this.options.watchContext( def.context, () => {\n try { self.onContext() }\n catch( error ){ hooks.onError( error ) }\n })\n\n let attached = false\n if( typeof self.onAttach === 'function' || typeof self.onDetach === 'function' ){\n PENDING_ATTACH.push({\n node: () => inst.start,\n fn: () => {\n attached = true\n try { typeof self.onAttach === 'function' && self.onAttach() }\n catch( error ){ hooks.onError( error ) }\n }\n })\n // Parent already live → attach now\n inst.start.isConnected && flushAttach()\n }\n\n disposers.push( () => {\n unwatchContext?.()\n clearStyles?.()\n destroy( inst )\n try {\n attached && typeof self.onDetach === 'function' && self.onDetach()\n typeof self.onDestroy === 'function' && self.onDestroy()\n }\n catch( error ){ hooks.onError( error ) }\n })\n }\n\n /** Unresolved component candidate → plain element with binds */\n private execElement(\n child: ChildIR & { t: 'comp' },\n anchor: Comment,\n benv: RunEnv,\n scopeNames: string[],\n disposers: ( () => void )[]\n ){\n const el = document.createElement( child.name )\n\n for( const [ name, ci ] of Object.entries( child.inputs ) ){\n if( 'lit' in ci ) applyAttr( el, name, ci.lit )\n else {\n const run = this.runner( ci.e, scopeNames )\n disposers.push( effect( () => applyAttr( el, name, run( benv ) ) ).dispose )\n }\n }\n for( const ev of child.events ){\n const handler = this.eventDispatcher( this.ir.exprs[ ev.e ], scopeNames, benv )\n el.addEventListener( ev.name, handler )\n disposers.push( () => el.removeEventListener( ev.name, handler ) )\n }\n\n if( child.contents ){\n const inst = this.renderBlock( child.contents.block, benv )\n el.append( ...nodesOf( inst ) )\n disposers.push( () => destroy( inst ) )\n }\n\n insertAfter( anchor, [ el ] )\n disposers.push( () => el.remove() )\n }\n\n /**\n * Event instruction dispatch (lazy — evaluated per event):\n * - `on-click( expr )` → value must be a function, called with (…params)\n * - `on-click( name, ...args )` → resolves `name` (expression, then\n * self method fallback) and calls with (...args, ...params)\n *\n * `params` are the DOM event for element listeners, or the emitted\n * arguments for component events — same append-after-declared-args\n * rule either way.\n * Scope getters read live values at dispatch — no stale memos.\n */\n private eventDispatcher( instruction: string, scopeNames: string[], benv: RunEnv ){\n const segs = splitTopLevel( instruction )\n\n return ( ...params: any[] ) => untrack( () => {\n const resolveFn = ( src: string ) => {\n let v: any\n try { v = this.srcRunner( src, scopeNames )( benv ) }\n catch( e ){ v = undefined }\n if( typeof v !== 'function' && benv.self && typeof benv.self[ src ] === 'function' )\n v = benv.self[ src ]\n return v\n }\n\n if( !segs.length ) return\n\n const fn = resolveFn( segs[0] )\n if( typeof fn !== 'function' ) return\n\n const args = segs.slice( 1 ).map( src => this.srcRunner( src, scopeNames )( benv ) )\n fn( ...args, ...params )\n })\n }\n}\n\n// -------------------------------------------------------------------- API\nexport function renderIR( ir: TemplateIR, setup: RenderSetup = {}, options: RuntimeOptions = {} ): IRInstance {\n const\n state = reactive( setup.state || {}, setup.deep ?? false ),\n input = setup.input ? reactive( setup.input, setup.deep ?? false ) : undefined,\n self: any = { state, input, static: setup.static, ...( setup.expose || {} ) }\n\n setup.handlers && Object.entries( setup.handlers ).forEach( ( [ k, fn ] ) => self[ k ] = fn.bind( self ) )\n\n const env: RunEnv = {\n state,\n input,\n context: setup.context,\n static: setup.static,\n self,\n scope: undefined\n }\n\n const hooks = makeHooks( self )\n\n /**\n * Root lifecycle mirrors the nested path exactly:\n * create → (initial input) → render → mount/render → attach.\n */\n try { typeof self.onCreate === 'function' && self.onCreate() }\n catch( error ){ hooks.onError( error ) }\n\n try { input && Object.keys( input ).length && typeof self.onInput === 'function' && self.onInput() }\n catch( error ){ hooks.onError( error ) }\n\n let renderer = new IRRenderer( ir, options, hooks )\n let current = renderer.renderBlock( ir.root, env )\n hooks.ready()\n\n // Scoped stylesheet for the root component\n const clearStyles = setup.stylesheet\n ? applyScopedStyles( options, current, setup.nsp || 'lips', setup.stylesheet )\n : undefined\n\n try {\n typeof self.onMount === 'function' && self.onMount()\n typeof self.onRender === 'function' && self.onRender()\n }\n catch( error ){ hooks.onError( error ) }\n\n let attached = false\n const attachSelf = () => {\n if( attached ) return\n attached = true\n try { typeof self.onAttach === 'function' && self.onAttach() }\n catch( error ){ hooks.onError( error ) }\n }\n\n return {\n state,\n self,\n get nodes(){ return nodesOf( current ) },\n mount( container: Element ){\n container.append( ...nodesOf( current ) )\n /**\n * Ownership-based attach (RFC §6): mounting a live tree\n * settles this component and every child queued during\n * render — no document-wide MutationObserver.\n */\n if( current.start.isConnected ){\n attachSelf()\n flushAttach()\n }\n },\n swap( newIR: TemplateIR ): SwapReport {\n const changes: SwapChange[] = []\n renderer = new IRRenderer( newIR, options, hooks )\n current = renderer.swapBlock( current, newIR.root, changes, 'root' )\n return { changes }\n },\n dispose(){\n clearStyles?.()\n destroy( current )\n try {\n attached && typeof self.onDetach === 'function' && self.onDetach()\n typeof self.onDestroy === 'function' && self.onDestroy()\n }\n catch( error ){ hooks.onError( error ) }\n }\n }\n}\n",
5
+ "/**\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",
6
+ "/**\n * Phase 2 — reactivity core (RFC-001 §6)\n *\n * Minimal per-key signals: no history (that's the opt-in\n * `historySignal` wrapper, later), no deep proxies, no digest.\n * A write notifies exactly the effects that read that signal.\n */\n\ntype Effect = {\n run: () => void\n deps: Set<Set<Effect>>\n disposed: boolean\n}\n\nlet CURRENT: Effect | null = null\n\n/**\n * Batching. Inside `batch()` a notification is queued on its signal\n * rather than run, and the queue is a Set — so N writes to the same key\n * collapse to ONE notification when the outermost batch exits.\n *\n * This is what turns an animation loop over a reactive list from O(N²)\n * into O(N): a nested write force-notifies its top key's subscribers\n * (see `deepWrap`), and the keyed `<for>` is one of them.\n */\nlet BATCH_DEPTH = 0\n\n/**\n * Queued EFFECTS, not queued signals. One effect commonly subscribes to\n * many channels — a keyed `<for>` reads `length` and every index — so\n * deduplicating per signal would still run it once per channel. The\n * Set collapses to one run per effect.\n */\nconst PENDING = new Set<Effect>()\n\n/**\n * Drain iteratively: an effect may itself write, queueing more work.\n * Re-enter the batch around each pass so those collapse too, instead of\n * running eagerly one at a time.\n */\nfunction drain(){\n while( PENDING.size ){\n const queued = [ ...PENDING ]\n PENDING.clear()\n BATCH_DEPTH++\n try { for( const e of queued ) !e.disposed && e.run() }\n finally { BATCH_DEPTH-- }\n }\n}\n\nexport function batch<T>( fn: () => T ): T {\n BATCH_DEPTH++\n // NB: never `return` from the finally — it would discard fn()'s value\n try { return fn() }\n finally {\n BATCH_DEPTH--\n !BATCH_DEPTH && drain()\n }\n}\n\nexport function signal<T>( value: T ): [ () => T, ( next: T ) => void, () => void ] {\n const subs = new Set<Effect>()\n\n const notify = () => {\n if( BATCH_DEPTH ){\n for( const e of subs ) PENDING.add( e )\n return\n }\n // Copy: effects may retrack while running\n for( const e of [ ...subs ] )\n !e.disposed && e.run()\n }\n\n const read = () => {\n if( CURRENT && !CURRENT.disposed ){\n subs.add( CURRENT )\n CURRENT.deps.add( subs )\n }\n return value\n }\n const write = ( next: T ) => {\n if( Object.is( next, value ) ) return\n value = next\n notify()\n }\n /**\n * Force-notify without a value change — the deep-reactive\n * facade uses this when nested content mutates in place.\n */\n const touch = () => notify()\n\n return [ read, write, touch ]\n}\n\nexport interface EffectHandle {\n dispose(): void\n}\n\nexport function effect( fn: () => void ): EffectHandle {\n const e: Effect = {\n deps: new Set(),\n disposed: false,\n run(){\n if( e.disposed ) return\n\n // Re-track from scratch each run\n for( const subs of e.deps ) subs.delete( e )\n e.deps.clear()\n\n const prev = CURRENT\n CURRENT = e\n try { fn() }\n finally { CURRENT = prev }\n }\n }\n\n e.run()\n\n return {\n dispose(){\n e.disposed = true\n for( const subs of e.deps ) subs.delete( e )\n e.deps.clear()\n }\n }\n}\n\n/** Run `fn` without dependency tracking */\nexport function untrack<T>( fn: () => T ): T {\n const prev = CURRENT\n CURRENT = null\n try { return fn() }\n finally { CURRENT = prev }\n}\n\nconst IS_REACTIVE = Symbol('lips.reactive')\n/** Marks a collection proxy and exposes its notifier + raw target */\nconst COLLECTION_META = Symbol('lips.collection')\n\ninterface CollectionMeta {\n raw: Map<any, any> | Set<any>\n notify: Set<() => void>\n}\n\n/**\n * Per-key reactive facade over a plain object:\n * reading a key inside an effect subscribes to that key;\n * writing notifies only that key's subscribers.\n * Idempotent — wrapping a reactive object returns it as-is.\n *\n * Shallow by default (RFC §6). `deep: true` opts into nested\n * mutation tracking: plain objects/arrays read through a key are\n * lazily proxied, and any nested write force-notifies that top\n * key's subscribers (coarse but O(subscribers-of-key)).\n */\n/**\n * Shared across every reactive store: a collection reached from two\n * stores (parent `state.x`, child `input.x`) must resolve to ONE\n * proxy, so a mutation through either notifies both.\n */\nconst COLLECTION_PROXIES = new WeakMap<object, any>()\n\n/** Plain objects/arrays are deep-wrapped (Date/class instances pass through) */\nconst isPlain = ( v: any ) =>\n v !== null && typeof v === 'object'\n && ( Array.isArray( v ) || Object.getPrototypeOf( v ) === Object.prototype )\n\nconst isCollection = ( v: any ) =>\n v instanceof Map || v instanceof Set\n || !!( v && typeof v === 'object' && v[ COLLECTION_META ] )\n\n/**\n * Array mutators write several times (push sets an index AND length).\n * Run them atomically so one operation is one notification, not one per\n * internal write.\n */\nconst ARRAY_MUTATORS = new Set([ 'push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse', 'fill', 'copyWithin' ])\n/** Map/Set methods that mutate — each notifies once */\nconst COLLECTION_MUTATORS = new Set([ 'set', 'delete', 'clear', 'add' ])\n\n/**\n * Channel for \"which keys exist\" — subscribed by `ownKeys` (Object.keys,\n * Object.entries, `<for>` over an object) and fired when a key is added\n * or removed. Separate from the per-key channels, which only cover value\n * changes on keys that already exist.\n */\nconst KEYS = Symbol('lips.keys')\n\n/**\n * ONE proxy per raw object, shared across every deep store.\n *\n * The same object is commonly reachable from two stores — a parent's\n * `state.rows` and the child's `input.rows` are the same array. A\n * per-store registry would hand each a private proxy with private\n * channels, so a write through one would be invisible to the other.\n */\nconst OBJECT_PROXIES = new WeakMap<object, any>()\n\n/**\n * Map/Set proxies break internal-slot access ([[MapData]]), so\n * collections are wrapped by BINDING their methods to the target:\n * reads work natively; mutators notify. Values read out of the\n * collection are deep-wrapped in turn, so nested trees of Maps\n * (e.g. a recursive layers tree) stay reactive.\n */\nfunction wrapCollection( coll: any, touch: () => void ): any {\n /**\n * Identity-stable wrapping, for the same reason as OBJECT_PROXIES:\n * ONE proxy is reused and every interested store adds its notifier.\n */\n const existing: CollectionMeta | undefined = coll[ COLLECTION_META ]\n if( existing ){\n existing.notify.add( touch )\n return coll\n }\n\n const hit = COLLECTION_PROXIES.get( coll )\n if( hit ){\n ;( hit as any )[ COLLECTION_META ].notify.add( touch )\n return hit\n }\n\n const meta: CollectionMeta = { raw: coll, notify: new Set([ touch ]) }\n const notifyAll = () => meta.notify.forEach( fn => fn() )\n\n const proxy = new Proxy( coll, {\n get( t: any, k ){\n if( k === COLLECTION_META ) return meta\n\n // size and other data properties\n const v = ( t as any )[ k ]\n if( typeof v !== 'function' ) return v\n\n if( typeof k === 'string' && COLLECTION_MUTATORS.has( k ) )\n return ( ...args: any[] ) => {\n const result = v.apply( t, args )\n notifyAll()\n return result\n }\n\n /**\n * Readers hand out WRAPPED values. Iteration matters as much as\n * `get`: a `<for>` over a Map reads `entries()`, and an unwrapped\n * value there is an object nothing can track — its mutations would\n * be invisible now that a nested write no longer force-notifies\n * the whole collection.\n */\n const wrapVal = ( out: any ) =>\n isPlain( out ) ? deepWrap( out, notifyAll )\n : isCollection( out ) ? wrapCollection( out, notifyAll )\n : out\n\n const isMap = t instanceof Map\n\n if( k === 'get' ) return ( key: any ) => wrapVal( t.get( key ) )\n\n if( k === 'forEach' )\n return ( fn: any, thisArg?: any ) =>\n t.forEach( ( val: any, key: any ) => fn.call( thisArg, wrapVal( val ), key, proxy ) )\n\n if( k === 'values' || ( !isMap && ( k === 'keys' || k === Symbol.iterator ) ) )\n return function*(){ for( const val of t.values() ) yield wrapVal( val ) }\n\n if( k === 'entries' || ( isMap && k === Symbol.iterator ) )\n return isMap\n ? function*(){ for( const [ key, val ] of t.entries() ) yield [ key, wrapVal( val ) ] }\n : function*(){ for( const val of t.values() ) yield [ wrapVal( val ), wrapVal( val ) ] }\n\n return v.bind( t )\n }\n })\n\n COLLECTION_PROXIES.set( coll, proxy )\n return proxy\n}\n\n/**\n * Per-key channels for ONE nested object (RFC-004 follow-up).\n *\n * Each key gets its own subscription list, so `rows[3].x = v` notifies\n * exactly the bindings that read `rows[3].x` — not everything that read\n * `rows`. Previously every nested write force-notified the top key, and\n * the keyed `<for>` is one of its subscribers, so a single field write\n * re-ran the whole list: O(list) per write, O(N²) per animation frame.\n *\n * A channel is a signal used purely as a subscription list — reading\n * subscribes, touching notifies. The VALUE always comes from the target,\n * so the proxy and the underlying object can never diverge.\n */\nfunction nestedProxy( target: any ): any {\n const hit = OBJECT_PROXIES.get( target )\n if( hit ) return hit\n\n const chans = new Map<PropertyKey, ReturnType<typeof signal<number>>>()\n\n const track = ( k: PropertyKey ) => {\n let c = chans.get( k )\n if( !c ){\n c = signal( 0 )\n chans.set( k, c )\n }\n c[0]()\n }\n /** Fire only if someone actually subscribed — an unread key has no channel */\n const fire = ( k: PropertyKey ) => chans.get( k )?.[2]()\n\n /**\n * A STABLE notifier per key. Collections keep their subscribers in a\n * Set, so handing them a fresh closure on every read would grow that\n * Set without bound — one entry per read, never deduplicated.\n */\n const touches = new Map<PropertyKey, () => void>()\n const touchFor = ( k: PropertyKey ) => {\n let f = touches.get( k )\n if( !f ){\n f = () => fire( k )\n touches.set( k, f )\n }\n return f\n }\n /**\n * A structural change invalidates everything. Batched, so an effect\n * subscribed to many channels (a `<for>` reads length and every index)\n * runs ONCE rather than once per channel.\n */\n const fireAll = () => batch( () => { for( const c of chans.values() ) c[2]() })\n\n let muted = false\n\n const proxy = new Proxy( target, {\n get( t: any, k ){\n const v = t[ k ]\n\n // Symbols (Symbol.iterator, …) pass through untracked; the\n // iterator's own reads of length/indices are tracked below.\n if( typeof k === 'symbol' ) return v\n\n if( Array.isArray( t ) && ARRAY_MUTATORS.has( k ) && typeof v === 'function' )\n return ( ...args: any[] ) => {\n muted = true\n try { return v.apply( t, args ) }\n finally {\n muted = false\n fireAll()\n }\n }\n\n /**\n * Methods are returned unbound on purpose: `proxy.map(fn)` then\n * runs with `this` = proxy, so its internal length/index reads go\n * through this trap and subscribe.\n */\n if( typeof v === 'function' ) return v\n\n track( k )\n return isPlain( v ) || isCollection( v ) ? deepWrap( v, touchFor( k ) ) : v\n },\n set( t: any, k, v ){\n const had = k in t\n const prev = t[ k ]\n t[ k ] = v\n\n if( muted ) return true\n if( !Object.is( prev, v ) ) fire( k )\n /**\n * A new key changes the key set, and on an array it also moves\n * `length` — both are what iterators subscribed to.\n */\n if( !had ){\n fire( KEYS )\n Array.isArray( t ) && fire('length')\n }\n return true\n },\n deleteProperty( t: any, k ){\n const had = k in t\n delete t[ k ]\n\n if( !muted && had ){\n fire( k )\n fire( KEYS )\n }\n return true\n },\n has( t: any, k ){\n typeof k !== 'symbol' && track( k )\n return k in t\n },\n ownKeys( t: any ){\n track( KEYS )\n return Reflect.ownKeys( t )\n }\n })\n\n OBJECT_PROXIES.set( target, proxy )\n return proxy\n}\n\nfunction deepWrap( value: any, touch: () => void ): any {\n if( isCollection( value ) ) return wrapCollection( value, touch )\n if( !isPlain( value ) ) return value\n return nestedProxy( value )\n}\n\n/**\n * Per-key reactive facade over a plain object:\n * reading a key inside an effect subscribes to that key;\n * writing notifies only that key's subscribers.\n * Idempotent — wrapping a reactive object returns it as-is.\n *\n * Shallow by default (RFC-001 §6). `deep: true` opts into nested\n * mutation tracking: plain objects/arrays read through a key are lazily\n * given their OWN per-key channels (see `nestedProxy`), so a nested\n * write stays O(subscribers-of-that-key) rather than invalidating the\n * whole top-level key.\n */\nexport function reactive<T extends object>( obj: T, deep = false ): T {\n if( ( obj as any )[ IS_REACTIVE ] ) return obj\n\n const sigs = new Map<PropertyKey, [ () => any, ( v: any ) => void, () => void ]>()\n\n const sigFor = ( key: PropertyKey, initial: any ) => {\n let s = sigs.get( key )\n if( !s ){\n s = signal( initial )\n sigs.set( key, s )\n }\n return s\n }\n\n return new Proxy( obj, {\n get( target: any, key ){\n if( key === IS_REACTIVE ) return true\n if( typeof key === 'string' ){\n const s = sigFor( key, target[ key ] )\n return deep ? deepWrap( s[0](), s[2] ) : s[0]()\n }\n return target[ key ]\n },\n set( target: any, key, value ){\n const prev = target[ key ]\n target[ key ] = value\n\n if( typeof key !== 'string' ) return true\n\n const sig = sigFor( key, value )\n /**\n * Re-assigning the SAME collection is not a no-op: collections\n * mutate in place, so an unchanged reference can still hold new\n * contents (a parent's `.set()` reaching a child's input). The\n * signal's Object.is check would swallow it — touch instead.\n */\n Object.is( prev, value ) && isCollection( value )\n ? sig[2]()\n : sig[1]( value )\n\n return true\n },\n has( target, key ){ return key in target },\n deleteProperty( target: any, key ){\n delete target[ key ]\n typeof key === 'string' && sigs.get( key )?.[1]( undefined )\n return true\n }\n }) as T\n}\n",
7
+ "/**\n * The host seam (RFC-006 §4.1).\n *\n * The IR runtime never touches a node itself. It creates, places, walks\n * and mutates nodes through a `Host`, so one runtime drives the DOM, an\n * in-memory tree (`./tree`) or a native element API. The node type is\n * the host's own and opaque to the runtime.\n *\n * What a host must provide is what the runtime actually does with\n * nodes, no more:\n *\n * - instantiate a block's skeleton (`clone`), and create the few nodes\n * the runtime adds itself: markers, text runs, unresolved elements\n * - a sibling-linked tree with parents: block instances are ranges\n * between two markers, walked and moved whole (`range`, `insertAfter`)\n * - attributes, text, inline custom properties, listeners\n * - two host decisions: how a stylesheet scope marks an element\n * (`rel` here, a class on Lynx) and whether markup can be parsed\n * (`html` is optional — the `'tree'` compile target rejects `@html`)\n *\n * Stylesheet injection is not here: it already reaches the runtime as\n * `RuntimeOptions.createStylesheet`, supplied by the facade.\n */\n\nimport type { BlockIR } from './compiler'\n\nexport interface Host<N = any> {\n /** A detached container holding a fresh copy of the block's skeleton */\n clone( block: BlockIR ): N\n /** An empty detached container */\n fragment(): N\n element( tag: string ): N\n text( value: string ): N\n /** An invisible node: block boundaries and control-flow anchors */\n marker( label: string ): N\n\n /** The child at `index` — skeleton paths are child-index walks */\n child( parent: N, index: number ): N\n next( node: N ): N | null\n /** `first`, its following siblings, up to and including `last` */\n range( first: N, last: N ): N[]\n /** Insert `node` before `ref`, or at the end when `ref` is null */\n insert( parent: N, node: N, ref: N | null ): void\n /** Place `nodes`, in order, right after `ref` — nothing when `ref` has no parent */\n insertAfter( ref: N, nodes: N[] ): void\n /**\n * `gone`: the node will never be inserted again — the runtime is\n * destroying it, not moving it. A host may release what it holds for\n * it (the Lynx host frees its ids); the DOM has nothing to free.\n */\n remove( node: N, gone?: boolean ): void\n isElement( node: N ): boolean\n /** In the live tree — what `onAttach` waits for */\n connected( node: N ): boolean\n /** `a` comes before `b` in tree order; false when they share no tree */\n precedes( a: N, b: N ): boolean\n\n /** A text node's value — the hot path of every text bind */\n setText( node: N, value: string ): void\n /** Replace an element's children with one text run (`@text`, `@format`) */\n content( el: N, value: string ): void\n /** `null` removes the attribute */\n attr( el: N, name: string, value: string | null ): void\n /** Replace the element's children with parsed markup (`@html`) — DOM only */\n html?( el: N, value: string ): void\n /** Set an inline custom property, or remove it when `null` (RFC-004 §8) */\n styleVar( el: N, prop: string, value: string | null ): void\n /** Mark a component root with its stylesheet scope. An inner scope already set wins */\n scope( el: N, nsp: string ): void\n /** Returns the unlisten function */\n listen( el: N, name: string, fn: ( event: any ) => void ): () => void\n /** Capture focus before a swap moves nodes; the returned function restores it */\n keepFocus?(): () => void\n}\n\n// ---------------------------------------------------------------- DOM host\nconst SKELETONS = new WeakMap<BlockIR, HTMLTemplateElement>()\n\n/**\n * Today's behaviour, unchanged: skeletons parsed once per block into a\n * `<template>` and cloned per instance, scope stamped as `rel`.\n */\nexport const domHost: Host<Node> = {\n clone( block ){\n let tpl = SKELETONS.get( block )\n if( !tpl ){\n tpl = document.createElement('template')\n tpl.innerHTML = block.html\n SKELETONS.set( block, tpl )\n }\n return tpl.content.cloneNode( true )\n },\n fragment: () => document.createDocumentFragment(),\n element: tag => document.createElement( tag ),\n text: value => document.createTextNode( value ),\n marker: label => document.createComment( label ),\n\n child: ( parent, index ) => parent.childNodes[ index ],\n next: node => node.nextSibling,\n /**\n * Range walks and range moves are the hottest node work there is (a\n * keyed list walks every row's range on every change), so they are ONE\n * host call per range with the loop inside, not a host call per node.\n */\n range( first, last ){\n const out: Node[] = []\n for( let n: Node | null = first; n; n = n.nextSibling ){\n out.push( n )\n if( n === last ) break\n }\n return out\n },\n insert: ( parent, node, ref ) => { parent.insertBefore( node, ref ) },\n /**\n * The reference is re-read after every insert rather than captured\n * once: `nodes` may already contain `ref`'s next sibling, and a fixed\n * reference would put the rest of the range in front of it.\n */\n insertAfter( ref, nodes ){\n const parent = ref.parentNode\n if( !parent ) return\n let anchor = ref\n for( const n of nodes ){\n parent.insertBefore( n, anchor.nextSibling )\n anchor = n\n }\n },\n remove: node => ( node as ChildNode ).remove(),\n isElement: node => node.nodeType === 1,\n connected: node => node.isConnected,\n /**\n * Nodes in different trees compare as DISCONNECTED plus an arbitrary\n * but consistent order, so a range test `precedes( from, n ) &&\n * precedes( n, to )` still fails for them: one side always does.\n */\n precedes: ( a, b ) => !!( a.compareDocumentPosition( b ) & 4 /* FOLLOWING */ ),\n\n attr: ( el, name, value ) => value === null\n ? ( el as Element ).removeAttribute( name )\n : ( el as Element ).setAttribute( name, value ),\n /** `.data`: the direct write, as before the seam — no node-type dispatch */\n setText: ( node, value ) => { ( node as Text ).data = value },\n content: ( el, value ) => { el.textContent = value },\n html: ( el, value ) => { ( el as Element ).innerHTML = value },\n styleVar: ( el, prop, value ) => value === null\n ? ( el as HTMLElement ).style.removeProperty( prop )\n : ( el as HTMLElement ).style.setProperty( prop, value ),\n scope: ( el, nsp ) => { ( el as Element ).hasAttribute('rel') || ( el as Element ).setAttribute('rel', nsp ) },\n listen( el, name, fn ){\n el.addEventListener( name, fn )\n return () => el.removeEventListener( name, fn )\n },\n /**\n * Salvaged nodes are detached and re-inserted, which drops focus. The\n * element survives the move, so put the caret back where the user left it.\n */\n keepFocus(){\n const focused = document.activeElement as HTMLElement | null\n return () => { focused && focused.isConnected && focused !== document.activeElement && focused.focus() }\n }\n}\n",
8
+ "/**\n * The tags a reader of `tag` is served from, most specific first — RFC 4647\n * §3.4 Lookup: the tag, then each shorter prefix, a single-letter subtag\n * left at the end dropped with what followed it. `zh-Hant-TW` reads\n * `zh-Hant` before `zh`, so a script is never skipped for its language.\n *\n * It is the same chain AB's `lookupTags` walks for a translatable name, and\n * both are held to the RFC's own example, so a dictionary and a name stored\n * on the platform fall back the same way for the same reader.\n */\nexport function lookupTags( tag: string ): string[] {\n const\n subtags = tag.split('-'),\n tags: string[] = []\n\n while( subtags.length ){\n tags.push( subtags.join('-') )\n subtags.pop()\n subtags[ subtags.length - 1 ]?.length === 1 && subtags.pop()\n }\n return tags\n}\n\n/** A name said in more than one language: one text per language tag, and the one to fall back to. */\nexport type TranslatableName = {\n readonly default: string\n readonly names: Readonly<Record<string, string>>\n}\n\n/**\n * The text of `name` a reader of `lang` reads: the first tag of its lookup\n * chain the name has, matched whatever its casing, and the default text\n * when none is. What a template shows for a platform name, as `self.pick( … )`.\n */\nexport function pick( name: TranslatableName, lang: string ): string {\n const texts = new Map( Object.entries( name.names ).map( ([ tag, text ]) => [ tag.toLowerCase(), text ] ) )\n for( const tag of lookupTags( lang.toLowerCase() ) )\n if( texts.has( tag ) ) return texts.get( tag )!\n\n return name.names[ name.default ] ?? ''\n}\n",
9
+ "/**\n * Phase 2 — hot-swap support (RFC-001 §8)\n *\n * Structural IR comparison by EXPRESSION SOURCE: two compilations\n * of related templates produce different expression-table indices,\n * so equality must resolve every `E` through its own table before\n * comparing. These normalizers produce plain comparable shapes.\n */\n\nimport type { BlockIR, BindIR, ChildIR, CompInput } from './compiler'\n\nexport interface SwapChange {\n kind: 'skeleton' | 'binds' | 'block'\n /** Block-tree coordinates, e.g. 'root', 'root/2', 'root/2/0' */\n path: string\n}\nexport interface SwapReport {\n changes: SwapChange[]\n /**\n * Components carried through the swap instead of being remounted —\n * one entry per instance, by component name.\n */\n salvaged: string[]\n}\n\n// ------------------------------------------------------------- normalizers\nconst normInput = ( ci: CompInput | null | undefined, x: string[] ): any =>\n ci == null ? ci : 'e' in ci ? { $: x[ ci.e ] } : ci\n\nexport const normBind = ( b: BindIR, x: string[] ): any => ({ ...b, e: x[ b.e ] })\n\nexport function normChild( c: ChildIR, x: string[] ): any {\n switch( c.t ){\n case 'macro':\n return { t: c.t, name: c.name, args: c.args,\n sets: c.sets.map( s => 'spread' in s\n ? { spread: x[ s.spread ] }\n : { name: s.name, ci: normInput( s.ci, x ) } ),\n block: normBlock( c.block, x ) }\n case 'if':\n return { t: c.t, branches: c.branches.map( b => ({\n when: b.when == null ? null : x[ b.when ],\n block: normBlock( b.block, x )\n }) ) }\n case 'for':\n return {\n t: c.t, args: c.args,\n of: c.of === undefined ? undefined : x[ c.of ],\n from: normInput( c.from, x ), to: normInput( c.to, x ), by: normInput( c.by, x ),\n block: normBlock( c.block, x )\n }\n case 'switch':\n return { t: c.t, on: x[ c.on ], cases: c.cases.map( k => ({\n is: k.is === null ? null : normInput( k.is, x ),\n block: normBlock( k.block, x )\n }) ) }\n case 'async':\n return {\n t: c.t, awaitE: x[ c.awaitE ],\n then: c.then && { args: c.then.args, block: normBlock( c.then.block, x ) },\n catch: c.catch && { args: c.catch.args, block: normBlock( c.catch.block, x ) },\n loading: c.loading && normBlock( c.loading, x )\n }\n case 'let':\n return { t: c.t, const: c.const,\n vars: Object.fromEntries( Object.entries( c.vars ).map( ( [ k, v ] ) => [ k, normInput( v, x ) ] ) ) }\n case 'log':\n return { t: c.t, e: x[ c.e ] }\n case 'provide':\n return {\n t: c.t,\n vars: Object.fromEntries( Object.entries( c.vars ).map( ( [ k, v ] ) => [ k, normInput( v, x ) ] ) ),\n lang: normInput( c.lang, x ),\n block: normBlock( c.block, x )\n }\n case 'comp':\n case 'dynamic':\n return {\n t: c.t,\n name: c.t === 'comp' ? c.name : undefined,\n tag: c.t === 'dynamic' ? x[ c.tag ] : undefined,\n inputs: Object.fromEntries( Object.entries( c.inputs ).map( ( [ k, v ] ) => [ k, normInput( v, x ) ] ) ),\n spreads: c.spreads.map( e => x[ e ] ),\n events: c.events.map( ev => ({ name: ev.name, e: x[ ev.e ] }) ),\n contents: c.contents && { args: c.contents.args, block: normBlock( c.contents.block, x ) }\n }\n }\n}\n\nexport const normBlock = ( b: BlockIR, x: string[] ): any => ({\n html: b.html,\n scope: b.scope,\n binds: b.binds.map( bind => normBind( bind, x ) ),\n blocks: b.blocks.map( c => normChild( c, x ) )\n})\n\n// ------------------------------------------------------------- comparators\nexport const sameChild = ( a: ChildIR, ax: string[], b: ChildIR, bx: string[] ) =>\n a.t === b.t && JSON.stringify( normChild( a, ax ) ) === JSON.stringify( normChild( b, bx ) )\n\nexport const sameBinds = ( a: BindIR[], ax: string[], b: BindIR[], bx: string[] ) =>\n JSON.stringify( a.map( x => normBind( x, ax ) ) ) === JSON.stringify( b.map( x => normBind( x, bx ) ) )\n\nexport const sameLets = ( a: BlockIR, ax: string[], b: BlockIR, bx: string[] ) => {\n const lets = ( blk: BlockIR, x: string[] ) =>\n JSON.stringify( blk.blocks.filter( c => c.t === 'let' ).map( c => normChild( c, x ) ) )\n return lets( a, ax ) === lets( b, bx )\n}\n",
10
+ "/**\n * Phase 2 — IR runtime (RFC-001 §6, §8)\n *\n * TemplateIR → live nodes, through a `Host` (RFC-006 §4.1; the DOM\n * unless told otherwise):\n * - skeletons instantiated per use by the host (on the DOM: parsed\n * ONCE per block into <template>, then cloned) + a bind walk over\n * precomputed integer paths\n * - every bind is its own effect over per-key signals — updates are\n * O(changed bindings), no digest, no clones, no deep equality\n * - block instances are bracketed by owned comment markers so\n * control-flow content moves/disposes as a range\n * - dual expression modes over the same IR: 'compiled' (Function) /\n * 'interpreted' (AST walker, CSP-safe) — both for trusted templates;\n * an untrusted one runs through a `guard` instead (RFC-007)\n *\n * Hot-swap (§8): instances retain their structure (bind handles,\n * child handles, resolved path nodes) so `instance.swap( newIR )`\n * can diff old vs new by expression source and update surgically:\n * - identical subtrees → kept wholesale (zero DOM work)\n * - bind-only changes → effects rewired onto the SAME nodes\n * - skeleton changes → that block re-rendered in place\n * State lives outside the IR, so it survives by construction.\n */\n\nimport type { TemplateIR, BlockIR, BindIR, ChildIR, ArmIR, CompInput, E, Path } from './compiler'\nimport type { ExprEnv, Expr } from './expression'\nimport { parseExpression, compileExpression, interpretExpression, splitTopLevel } from './expression'\nimport { signal, effect, untrack, reactive } from './signal'\nimport type { SwapChange, SwapReport } from './swap'\nimport type { StyleIR } from './style'\nimport type { Host } from './host'\nimport { domHost } from './host'\nimport { pick, type TranslatableName } from '../i18n/lookup'\nimport { sameBinds, sameChild, sameLets } from './swap'\n\n// ------------------------------------------------------------------- types\nexport interface IRComponentDef {\n ir: TemplateIR\n state?: Record<string, any>\n statics?: Record<string, any>\n /** Context fields this component subscribes to (fires onContext) */\n context?: string[]\n /** Compiled stylesheet (RFC-004) + scope name (the `rel` value) */\n stylesheet?: StyleIR\n nsp?: string\n /** Deep-reactive component state (old-engine parity) */\n deep?: boolean\n /**\n * Methods bound to the component self — lifecycle keys\n * (onCreate/onInput/onMount/onDestroy) are invoked by the\n * runtime at the matching moments.\n */\n handlers?: Record<string, ( this: any, ...args: any[] ) => any>\n}\n\n/**\n * How an untrusted template's expressions run (RFC-007): `run` replaces\n * the executor, and `self` decides which members of the component a bare\n * handler name in an event instruction may reach. Built by `./policy`.\n */\nexport interface Guard {\n run( src: string ): ( env: ExprEnv ) => any\n /** A refusal (truthy) keeps the instruction off `self[ key ]` */\n self( key: string ): unknown\n}\n\nexport interface RuntimeOptions {\n mode?: 'compiled' | 'interpreted'\n /** Untrusted templates only — set by `new Lips({ untrusted })` */\n guard?: Guard\n /**\n * What the IR renders into (RFC-006 §4.1). Defaults to the DOM. A host\n * that builds nodes one by one (`treeHost` in `./tree`) needs IR compiled\n * with `{ target: 'tree' }`, which carries the node tree it builds from.\n */\n host?: Host\n components?: Record<string, IRComponentDef>\n /**\n * Resolve a plain template object (e.g. a route's `template`)\n * into a component definition — the host owns compilation and\n * caching. Enables `<{state.page}/>` with template objects.\n */\n resolveTemplate?( value: any ): IRComponentDef | undefined\n /** Extra members merged onto every component's self (e.g. setContext) */\n expose?: Record<string, any>\n /**\n * Host-provided stylesheet injector (full build wires Stylis; the\n * precompiled `./runtime` build omits it). Returns a handle whose\n * `clear()` releases one reference.\n */\n createStylesheet?( nsp: string, css: string ): { clear(): void }\n /**\n * i18n plugin hook (RFC §6). Every call must READ a language signal\n * so translated binds re-run on language change — including `lang()`,\n * which is what makes `<span text=self.lang>` live.\n *\n * `key` is a STABLE translation id (RFC-005 §3): given one, the\n * dictionary is consulted for it first and `text` is only the\n * fallback wording. `lang` overrides the active language for one\n * call — how `<i18n lang=…>` translates its subtree.\n */\n i18n?: {\n translate( text: string, key?: string, lang?: string ): string\n format( reference: string, params: any, lang?: string ): string\n /** Active language, read reactively */\n lang(): string\n }\n}\n\nexport interface RenderSetup {\n state?: Record<string, any>\n input?: Record<string, any>\n context?: Record<string, any>\n static?: Record<string, any>\n handlers?: Record<string, ( this: any, ...args: any[] ) => any>\n /** Deep-reactive root state (old-engine parity) */\n deep?: boolean\n /** Extra members merged onto self before handlers bind (e.g. emit) */\n expose?: Record<string, any>\n /** Compiled stylesheet (RFC-004) + scope name (the `rel` value) */\n stylesheet?: StyleIR\n nsp?: string\n}\n\n/** `N` is the host's node type — `Node` on the DOM */\nexport interface IRInstance<N = Node> {\n state: Record<string, any>\n self: Record<string, any>\n nodes: N[]\n mount( container: N ): void\n swap( newIR: TemplateIR ): SwapReport\n dispose(): void\n}\n\ntype RunEnv = ExprEnv\n\n/** A host node — opaque to the runtime */\ntype N = any\n\ninterface BindHandle {\n bind: BindIR\n node: N\n textNode?: N\n dispose: () => void\n}\ninterface ChildHandle {\n child: ChildIR\n exprs: string[]\n anchor: N\n dispose: () => void\n}\n\n/**\n * A live component instance, tracked so a swap can re-home it\n * instead of destroying and recreating it (RFC-002 §salvage).\n *\n * `gen` is the ownership token: whoever wired the instance captures\n * the current value, and only a holder of the current token may tear\n * it down. Releasing a component into a salvage pass bumps `gen`, so\n * the old parent's disposal walks straight past it.\n */\ninterface LiveComp {\n name: string\n /** Explicit `key` input — identity across revisions, when given */\n key: any\n self: any\n input: Record<string, any>\n inst: BlockInstance\n /** Anchor of the child that currently owns it */\n anchor: N\n /** Parent-side wiring: input effects + event listeners */\n wiring: ( () => void )[]\n gen: number\n claimed: boolean\n teardown(): void\n}\n\n/** A rendered block: bracketed range + retained structure for swap */\ninterface BlockInstance {\n start: N\n end: N\n block: BlockIR\n exprs: string[]\n penv: RunEnv // parent env (for full re-render)\n benv: RunEnv // env with this block's scope layer\n pathNodes: Map<string, N> // pathKey → resolved node (binds + anchors)\n bindHandles: BindHandle[]\n childHandles: ChildHandle[]\n}\n\n// ----------------------------------------------------------------- helpers\n/** Marks a slot renderer handed to a child as `input.renderer` */\nconst SLOT = Symbol('lips.slot')\n\ninterface SlotRenderer {\n [ SLOT ]: true\n args: string[]\n render( argvalues?: Record<string, any> ): BlockInstance\n}\nconst isSlot = ( v: any ): v is SlotRenderer => !!v && typeof v === 'object' && v[ SLOT ] === true\n\n/**\n * Component lifecycle plumbing (RFC §6: ownership events, not\n * document-wide observation). One hooks object per component\n * instance; nested components get their own.\n */\ninterface ComponentHooks {\n notifyUpdate(): void\n onError( error: unknown ): void\n /** Called once the component's first render completes */\n ready(): void\n}\n\nfunction makeHooks( self: any ): ComponentHooks {\n let scheduled = false\n let isReady = false\n\n const onError = ( error: unknown ) =>\n typeof self.onError === 'function'\n ? self.onError( error )\n : console.error('[lips:ir]', error )\n\n return {\n onError,\n ready(){ isReady = true },\n notifyUpdate(){\n // Suppress during the initial render pass\n if( !isReady || scheduled ) return\n scheduled = true\n\n /**\n * A promise job, not `queueMicrotask`: Lynx's native background\n * engine has no `queueMicrotask`, and this runs outside the effect's\n * error guard, so a throw here aborted the effects after it.\n */\n Promise.resolve().then( () => {\n scheduled = false\n try {\n typeof self.onUpdate === 'function' && self.onUpdate()\n typeof self.onRender === 'function' && self.onRender()\n }\n catch( error ){ onError( error ) }\n })\n }\n }\n}\n\n/**\n * Attach callbacks queued during render, flushed once the nodes\n * are actually in the document (root mount, or immediate when the\n * insertion point is already live).\n */\nconst PENDING_ATTACH: { live: () => boolean, fn: () => void }[] = []\n\n/**\n * `entry.fn()` runs `onAttach`, and an `onAttach` may RENDER — that is\n * exactly what `<router>` does when it navigates on attach. Rendering\n * appends new entries here, and rendering under an already-live parent\n * re-enters this function, so the array mutates arbitrarily mid-pass.\n *\n * Walking it by index is unsound in both directions:\n * - an index outlives a shrunken array → `PENDING_ATTACH[i]` is\n * undefined and the flush throws\n * - entries appended during the pass sit below the descending index →\n * their `onAttach` silently never fires\n *\n * So drain by IDENTITY over a snapshot, and repeat while a pass settles\n * anything. Reverse order is preserved: a component pushes after the\n * children rendered inside it, so walking back attaches parents first.\n */\nfunction flushAttach(){\n let progressed = true\n\n while( progressed ){\n progressed = false\n\n for( const entry of [ ...PENDING_ATTACH ].reverse() ){\n if( !entry.live() ) continue\n\n // A re-entrant pass may have claimed it already\n const at = PENDING_ATTACH.indexOf( entry )\n if( at < 0 ) continue\n\n PENDING_ATTACH.splice( at, 1 )\n entry.fn()\n progressed = true\n }\n }\n}\n\nconst AST_CACHE = new Map<string, Expr>()\nfunction astOf( src: string ): Expr {\n let ast = AST_CACHE.get( src )\n if( !ast ){\n ast = parseExpression( src ).ast\n AST_CACHE.set( src, ast )\n }\n return ast\n}\n\nconst pathKey = ( p: Path ) => p.join(',')\n\nfunction resolvePath( h: Host, root: N, p: Path ): N {\n let node = root\n for( const i of p ) node = h.child( node, i )\n return node\n}\n\nconst nodesOf = ( h: Host, inst: BlockInstance ): N[] => h.range( inst.start, inst.end )\n/**\n * Does `n` sit between two markers in document order? Position, not\n * ancestry — a component nested deep in the skeleton's markup still\n * counts, which is what makes a region-wide sweep possible. Nodes in\n * another tree compare as disconnected, so both bits fail.\n */\nconst within = ( h: Host, from: N, to: N, n: N ) =>\n n === from // a child's own component is anchored on the marker itself\n || ( h.precedes( from, n ) && h.precedes( n, to ) )\n\n/**\n * Hand a live component to a salvage pass: its old owner loses the\n * right to destroy it, and its nodes are parked in a fragment. The\n * parking matters — an enclosing block that disposes before the\n * adoption runs would otherwise sweep those nodes out of the DOM\n * along with its own range.\n */\nfunction release( h: Host, rec: LiveComp ){\n rec.gen++\n for( const d of rec.wiring ) d()\n rec.wiring = []\n const park = h.fragment()\n for( const n of nodesOf( h, rec.inst ) ) h.insert( park, n, null )\n}\n\n/** Put a rendered block's range right after `ref` */\nfunction place( h: Host, ref: N, inst: BlockInstance ){\n h.insertAfter( ref, nodesOf( h, inst ) )\n return inst\n}\n\n/** The element roots a scoped sheet matches, and its variables live on */\nconst scopeRoots = ( h: Host, inst: BlockInstance ) => nodesOf( h, inst ).filter( n => h.isElement( n ) )\n\n/**\n * Scoped stylesheet: mark the component's top-level element roots with\n * the scope so the injected sheet matches — on the DOM `rel=\"<nsp>\"` for\n * `[rel=\"<nsp>\"] { … }`, where an inner component's scope wins on a\n * shared root (the host decides, RFC-006 §4.1).\n */\nfunction stampScope( h: Host, inst: BlockInstance, nsp: string ){\n for( const n of scopeRoots( h, inst ) ) h.scope( n, nsp )\n}\n\n/**\n * RFC-004 §8 — write a reactive declaration's custom property on the\n * scope roots. Every element the sheet matches is a root or a descendant,\n * and custom properties inherit (an inline one applying to the element\n * itself as well), so one write per root covers every match.\n *\n * A nullish value REMOVES the property rather than blanking it, so the\n * declaration falls through to an ancestor's value — that is what makes\n * \"use mine if given, otherwise inherit\" free (RFC-004 §7.3, §12.2).\n */\nfunction writeStyleVar( h: Host, roots: N[], prop: string, value: any, unit = '' ){\n for( const root of roots )\n h.styleVar( root, prop, value === null || value === undefined || value === false ? null : value + unit )\n}\n\n/** Stamp the scope, then inject via the facade's factory. Returns a clear disposer */\nfunction applyScopedStyles(\n h: Host,\n options: RuntimeOptions,\n inst: BlockInstance,\n nsp: string,\n style: StyleIR\n): ( () => void ) | undefined {\n stampScope( h, inst, nsp )\n\n const sheet = style.css ? options.createStylesheet?.( nsp, style.css ) : undefined\n return sheet ? () => sheet.clear() : undefined\n}\nfunction disposeInstance( inst: BlockInstance ){\n for( const h of inst.bindHandles ) h.dispose()\n for( const h of inst.childHandles ) h.dispose()\n}\nfunction destroy( h: Host, inst: BlockInstance | null ){\n if( !inst ) return\n disposeInstance( inst )\n for( const n of nodesOf( h, inst ) ) h.remove( n, true )\n}\n\nconst applyAttr = ( h: Host, el: N, name: string, v: any ) =>\n h.attr( el, name, v === false || v == null ? null : v === true ? '' : String( v ) )\n\nconst defineGetter = ( scope: any, name: string, get: () => any ) =>\n Object.defineProperty( scope, name, { get, enumerable: true, configurable: true } )\n\n/**\n * Marks a component `self`. A guard needs to tell it apart from data: the\n * policy has its own rules for members of `self` (RFC-007 §5.2).\n */\nexport const SELF = Symbol.for('lips.self') // registered: `./untrusted` is a bundle of its own, and asks for it by name\n\n/** Marks a `<context>` layer and carries its owned-key setters */\nconst LAYER = Symbol('lips.ctx.layer')\n\n/**\n * Write a context key to the nearest enclosing `<context>` layer that\n * declares it, falling back to the global store.\n *\n * The walk is over the prototype chain the layers already form, so\n * ownership needs no registry: a layer owns exactly the keys it wrote\n * into its own `LAYER` map, and both vanish when the block is disposed.\n * `global` is the host's setter — reached when no layer claims the key,\n * which is every write in a tree with no providers.\n */\nfunction writeContext( ctx: any, key: string, value: any, global?: ( k: string, v: any ) => void ){\n for( let o = ctx; o; o = Object.getPrototypeOf( o ) ){\n const owned: Map<string, ( v: any ) => void> | undefined = o[ LAYER ]\n const set = owned?.get( key )\n if( set ){ set( value ); return }\n }\n global?.( key, value )\n}\n\n/**\n * The half of `self` that is identical for a root and a nested\n * component: the live-node view, the language getter, and the event bus.\n * Both selves carried their own byte-identical copy of these six\n * members, in every bundle.\n *\n * Handed back as a PROTOTYPE rather than something to spread — `node`\n * and `lang` are getters, and a spread (or Object.assign) would evaluate\n * them once and freeze the result. Own properties still shadow it, so\n * the host's `expose` and a template's handlers keep winning.\n */\nfunction selfBus( h: Host, langOf: () => string ){\n const listeners = new Map<string, ( ( ...args: any[] ) => void )[]>()\n const fire = ( event: string, ...args: any[] ) => listeners.get( event )?.forEach( fn => fn( ...args ) )\n\n let self: any\n let instOf: () => BlockInstance | null = () => null\n\n const proto = {\n [ SELF ]: true,\n /**\n * Live element nodes — the handle external controls (drag/resize/\n * sort) bind to. Elements only: comment boundaries are an\n * implementation detail.\n */\n get node(){\n const inst = instOf()\n return inst ? scopeRoots( h, inst ) : []\n },\n /** Active language, read reactively — scoped when under `<i18n lang=…>` */\n get lang(){ return langOf() },\n /** A translatable name's text in the active language, by the same lookup as dictionaries */\n pick: ( name: TranslatableName ) => pick( name, langOf() ),\n emit: fire,\n /** Always the runtime-local bus — a host `emit` chains into it */\n emitLocal: fire,\n on( event: string, fn: ( ...args: any[] ) => void ){\n listeners.set( event, [ ...( listeners.get( event ) || [] ), fn ])\n return self\n },\n once( event: string, fn: ( ...args: any[] ) => void ){\n const wrapped = ( ...args: any[] ) => {\n self.off( event, wrapped )\n fn( ...args )\n }\n return self.on( event, wrapped )\n },\n off( event: string, fn?: ( ...args: any[] ) => void ){\n if( !fn ) listeners.delete( event )\n else {\n const rest = ( listeners.get( event ) || [] ).filter( f => f !== fn )\n rest.length ? listeners.set( event, rest ) : listeners.delete( event )\n }\n return self\n }\n }\n\n /** Adopt the finished self and tell the bus where its nodes live */\n const bind = ( owner: any, inst: () => BlockInstance | null ) => {\n self = owner\n instOf = inst\n return owner\n }\n return { proto, bind }\n}\n\n// ---------------------------------------------------------------- renderer\nclass IRRenderer {\n constructor(\n readonly ir: TemplateIR,\n private options: RuntimeOptions,\n private hooks?: ComponentHooks,\n /**\n * Components alive under this renderer. A swap builds a new\n * renderer over the new IR and inherits this array, so the\n * instances outlive the IR that first rendered them.\n */\n readonly live: LiveComp[] = []\n ){\n this.h = options.host || domHost\n }\n\n /** Every node operation goes through here (RFC-006 §4.1) */\n readonly h: Host\n\n /** Records offered to the render pass currently running, if any */\n private pool: LiveComp[] | null = null\n /** Names salvaged during this renderer's lifetime (read by swap) */\n readonly salvaged: string[] = []\n\n /**\n * Render with `records` offered for adoption. Whatever nobody\n * claims is destroyed for real once the pass ends — so a component\n * the revision dropped still runs its teardown.\n */\n private withSalvage<T>( records: LiveComp[], fn: () => T ): T {\n const prev = this.pool\n this.pool = records\n try { return fn() }\n finally {\n this.pool = prev\n for( const r of records ) !r.claimed && r.teardown()\n }\n }\n\n /**\n * Take the record belonging to this call site. An explicit `key`\n * is identity; without one, position among same-name components\n * decides — the rule keyless JSX lists already follow.\n */\n private claim( name: string, key: any ): LiveComp | undefined {\n const rec = this.pool?.find( r => !r.claimed && r.name === name && r.key === key )\n if( !rec ) return\n\n rec.claimed = true\n this.salvaged.push( name )\n return rec\n }\n\n /** The `key` input, evaluated off the dependency graph */\n private keyOf( inputs: Record<string, CompInput>, benv: RunEnv, scopeNames: string[] ){\n const ci = inputs.key\n return ci === undefined\n ? undefined\n : 'lit' in ci ? ci.lit : untrack( () => this.runner( ci.e, scopeNames )( benv ) )\n }\n\n /**\n * Bind effects run inside the component's error boundary and\n * report post-initial re-runs as component updates.\n */\n private guarded( fn: () => void ){\n let first = true\n return effect( () => {\n try { fn() }\n catch( error ){\n this.hooks ? this.hooks.onError( error ) : console.error('[lips:ir]', error )\n }\n first ? first = false : this.hooks?.notifyUpdate()\n })\n }\n\n /**\n * RFC-004 §8 — wire a compiled stylesheet's reactive declarations.\n * These are ordinary binds: same guarded() effect, same dispose handle,\n * same onError boundary. No parallel reactive system.\n *\n * Roots are captured here, so a rebuild must re-bind (see swap()).\n */\n bindStyle( style: StyleIR, inst: BlockInstance, env: RunEnv ): () => void {\n if( !style.binds.length ) return () => {}\n\n const\n roots = scopeRoots( this.h, inst ),\n handles = style.binds.map( b => {\n const run = this.srcRunner( style.exprs[ b.e ], [] )\n return this.guarded( () => writeStyleVar( this.h, roots, b.prop, run( env ), b.u ) )\n })\n\n return () => { for( const h of handles ) h.dispose() }\n }\n\n /** Expression runner for a table entry, honoring the execution mode */\n private runner( e: E, scopeNames: string[] ): ( env: RunEnv ) => any {\n return this.srcRunner( this.ir.exprs[ e ], scopeNames )\n }\n private srcRunner( src: string, scopeNames: string[] ): ( env: RunEnv ) => any {\n if( this.options.guard ) return this.options.guard.run( src )\n if( this.options.mode === 'interpreted' ){\n const ast = astOf( src )\n return env => interpretExpression( ast, env )\n }\n const compiled = compileExpression( src, scopeNames )\n return env => compiled.run( env )\n }\n\n renderBlock( block: BlockIR, env: RunEnv ): BlockInstance {\n const\n h = this.h,\n frag = h.clone( block )\n\n /**\n * Resolve every bind/anchor path BEFORE any mutation —\n * runtime insertions (text nodes, markers, arm content)\n * shift childNodes indices.\n */\n const pathNodes = new Map<string, N>()\n const bindNodes = block.binds.map( b => {\n const node = resolvePath( h, frag, b.p )\n pathNodes.set( pathKey( b.p ), node )\n return node\n })\n const anchorNodes = block.blocks.map( b => {\n const node = resolvePath( h, frag, b.p )\n pathNodes.set( pathKey( b.p ), node )\n return node\n })\n\n /**\n * Bracket the block content as an owned range. `end` goes in first\n * so the container is never empty when `start` looks for its first\n * child.\n */\n const start = h.marker('^')\n const end = h.marker('$')\n h.insert( frag, end, null )\n h.insert( frag, start, h.child( frag, 0 ) )\n\n // Scope chain for this block\n const scope = Object.create( env.scope ?? null )\n const benv: RunEnv = { ...env, scope }\n\n const inst: BlockInstance = {\n start, end, block,\n exprs: this.ir.exprs,\n penv: env, benv,\n pathNodes,\n bindHandles: [],\n childHandles: []\n }\n\n /**\n * <let>/<const> pass first — their names are visible to\n * every bind of this block (RFC decision #1)\n */\n block.blocks.forEach( ( child, i ) => {\n if( child.t !== 'let' ) return\n\n const letDisposers: ( () => void )[] = []\n for( const [ name, input ] of Object.entries( child.vars ) ){\n if( 'lit' in input ){\n const [ get ] = signal( input.lit )\n defineGetter( scope, name, get )\n }\n else {\n const [ get, set ] = signal<any>( undefined )\n defineGetter( scope, name, get )\n const run = this.runner( input.e, block.scope )\n letDisposers.push( effect( () => set( run( benv ) ) ).dispose )\n }\n }\n\n inst.childHandles[ i ] = {\n child, exprs: this.ir.exprs, anchor: anchorNodes[ i ],\n dispose: () => letDisposers.forEach( d => d() )\n }\n })\n\n // Binds — one effect each\n inst.bindHandles = block.binds.map( ( bind, i ) =>\n this.bindOne( bind, bindNodes[ i ], benv, block.scope ) )\n\n // Control-flow / component blocks\n block.blocks.forEach( ( child, i ) => {\n if( child.t === 'let' ) return\n inst.childHandles[ i ] = {\n child, exprs: this.ir.exprs, anchor: anchorNodes[ i ],\n dispose: this.execBlock( child, anchorNodes[ i ], benv, block.scope )\n }\n })\n\n return inst\n }\n\n /** Wire one bind onto its node; returns a swap-capable handle */\n private bindOne( bind: BindIR, node: N, benv: RunEnv, scopeNames: string[], reuseText?: N ): BindHandle {\n const h = this.h\n\n switch( bind.t ){\n case 'text': {\n const textNode = reuseText ?? h.text('')\n !reuseText && h.insertAfter( node, [ textNode ] )\n const run = this.runner( bind.e, scopeNames )\n const i18n = bind.i18n ? this.options.i18n : undefined\n const eff = this.guarded( () => {\n const v = run( benv )\n const text = v == null ? '' : String( v )\n h.setText( textNode, i18n ? i18n.translate( text, bind.ik, benv.lang?.() ) : text )\n })\n return { bind, node, textNode, dispose: eff.dispose }\n }\n case 'attr': {\n const run = this.runner( bind.e, scopeNames )\n const i18n = bind.i18n ? this.options.i18n : undefined\n const eff = this.guarded( () => {\n const v = run( benv )\n applyAttr( h, node, bind.name,\n i18n && v != null ? i18n.translate( String( v ), bind.ik, benv.lang?.() ) : v )\n })\n return { bind, node, dispose: eff.dispose }\n }\n case 'prop': {\n const run = this.runner( bind.e, scopeNames )\n\n if( bind.name === 'format' ){\n const ref = bind.ref || ''\n const eff = this.guarded( () => {\n const params = run( benv )\n const text = this.options.i18n?.format( ref, params, benv.lang?.() )\n h.content( node, text == null ? '' : String( text ) )\n })\n return { bind, node, dispose: eff.dispose }\n }\n\n const eff = this.guarded( () => {\n const v = run( benv )\n const s = v == null ? '' : String( v )\n /**\n * 'text' | 'format' — format is the i18n plugin hook (Phase 3).\n * A host with no HTML parser renders `@html` as text: the\n * `'tree'` target already reported it (LIPS-C021), and text is\n * the reading that can never inject anything.\n */\n bind.name === 'html' && h.html ? h.html( node, s ) : h.content( node, s )\n })\n return { bind, node, dispose: eff.dispose }\n }\n case 'event': {\n const handler = this.eventDispatcher( this.ir.exprs[ bind.e ], scopeNames, benv )\n return { bind, node, dispose: h.listen( node, bind.name, handler ) }\n }\n case 'spread': {\n const run = this.runner( bind.e, scopeNames )\n let prev = new Set<string>()\n const eff = this.guarded( () => {\n const obj = run( benv ) || {}\n const next = new Set<string>( Object.keys( obj ) )\n for( const k of prev ) !next.has( k ) && h.attr( node, k, null )\n for( const k of next ) applyAttr( h, node, k, obj[ k ] )\n prev = next\n })\n return { bind, node, dispose: eff.dispose }\n }\n }\n }\n\n // ----------------------------------------------------------------- swap\n /**\n * Diff-and-patch a live block against a new BlockIR (whose E\n * indices refer to THIS renderer's expression table). Returns\n * the live instance — a fresh one when a rebuild was needed.\n */\n swapBlock( inst: BlockInstance, newBlock: BlockIR, report: SwapChange[], path: string ): BlockInstance {\n /**\n * Structural rebuild triggers: skeleton, scope shape, or\n * let wiring changed — re-render this block in place.\n * (Worst case equals a fresh render — never worse.)\n */\n if( inst.block.html !== newBlock.html\n || JSON.stringify( inst.block.scope ) !== JSON.stringify( newBlock.scope )\n || !sameLets( inst.block, inst.exprs, newBlock, this.ir.exprs ) )\n return this.rebuild( inst, newBlock, report, path )\n\n // Bind-only changes: rewire effects onto the SAME nodes\n if( !sameBinds( inst.block.binds, inst.exprs, newBlock.binds, this.ir.exprs ) ){\n const nodes = newBlock.binds.map( b => inst.pathNodes.get( pathKey( b.p ) ) )\n\n // A bind on a path we never resolved → degrade to rebuild\n if( nodes.some( n => !n ) )\n return this.rebuild( inst, newBlock, report, path )\n\n const oldTexts = new Map<string, N>()\n inst.bindHandles.forEach( h => h.textNode && oldTexts.set( pathKey( h.bind.p ), h.textNode ) )\n inst.bindHandles.forEach( h => h.dispose() )\n\n const reused = new Set<string>()\n inst.bindHandles = newBlock.binds.map( ( b, i ) => {\n const key = pathKey( b.p )\n const reuse = b.t === 'text' ? oldTexts.get( key ) : undefined\n reuse && reused.add( key )\n return this.bindOne( b, nodes[ i ]!, inst.benv, newBlock.scope, reuse )\n })\n // Text nodes whose bind disappeared\n oldTexts.forEach( ( tn, key ) => !reused.has( key ) && this.h.remove( tn, true ) )\n\n report.push({ kind: 'binds', path })\n }\n\n /**\n * Children pairwise (equal html ⇒ equal anchor count):\n * identical-by-source subtrees are kept wholesale; changed\n * subtrees re-execute at their existing anchor.\n */\n for( let i = 0; i < newBlock.blocks.length; i++ ){\n const newChild = newBlock.blocks[ i ]\n const oldH = inst.childHandles[ i ]\n if( newChild.t === 'let' ) continue // covered by sameLets above\n\n if( oldH && sameChild( oldH.child, oldH.exprs, newChild, this.ir.exprs ) ) continue\n\n /**\n * Components this child rendered survive its re-execution.\n * The sweep spans the child's whole region, not just its own\n * anchor: a custom tag like `<mblock>` is itself a child, and\n * everything the template puts inside it lives under there.\n */\n const records = this.live.filter( r =>\n within( this.h, oldH.anchor, inst.childHandles[ i + 1 ]?.anchor ?? inst.end, r.anchor ) )\n for( const r of records ) release( this.h, r )\n\n oldH?.dispose()\n inst.childHandles[ i ] = {\n child: newChild, exprs: this.ir.exprs, anchor: oldH.anchor,\n dispose: this.withSalvage( records,\n () => this.execBlock( newChild, oldH.anchor, inst.benv, newBlock.scope ) )\n }\n report.push({ kind: 'block', path: `${path}/${i}` })\n }\n\n inst.block = newBlock\n inst.exprs = this.ir.exprs\n return inst\n }\n\n private rebuild( inst: BlockInstance, newBlock: BlockIR, report: SwapChange[], path: string ): BlockInstance {\n /**\n * Salvage: every component living in the region about to be\n * rebuilt is released from it first and offered to the fresh\n * render. What the revision still wants keeps its state and its\n * DOM subtree; what it dropped is destroyed by `withSalvage`.\n */\n const records = this.live.filter( r => within( this.h, inst.start, inst.end, r.anchor ) )\n for( const r of records ) release( this.h, r )\n\n const fresh = this.withSalvage( records, () => this.renderBlock( newBlock, inst.penv ) )\n\n place( this.h, inst.end, fresh )\n destroy( this.h, inst )\n report.push({ kind: 'skeleton', path })\n return fresh\n }\n\n // -------------------------------------------------------------- executors\n /** Execute a control-flow/component block; returns its disposer */\n private execBlock( child: ChildIR, anchor: N, benv: RunEnv, scopeNames: string[] ): () => void {\n const\n h = this.h,\n disposers: ( () => void )[] = []\n\n switch( child.t ){\n case 'if': {\n const runs = child.branches.map( b => b.when != null ? this.runner( b.when, scopeNames ) : null )\n let current: BlockInstance | null = null\n let activeIdx = -2\n\n const eff = effect( () => {\n let idx = -1\n for( let i = 0; i < child.branches.length; i++ ){\n const run = runs[ i ]\n if( !run || run( benv ) ){ idx = i; break }\n }\n if( idx === activeIdx ) return\n activeIdx = idx\n\n untrack( () => {\n destroy( h, current )\n current = null\n if( idx >= 0 ){\n current = place( h, anchor, this.renderBlock( child.branches[ idx ].block, benv ) )\n }\n })\n })\n\n disposers.push( () => { eff.dispose(); destroy( h, current ) } )\n break\n }\n\n case 'switch': {\n const onRun = this.runner( child.on, scopeNames )\n const caseRuns = child.cases.map( c =>\n c.is && 'e' in c.is ? this.runner( c.is.e, scopeNames ) : null )\n let current: BlockInstance | null = null\n let activeIdx = -2\n\n const eff = effect( () => {\n const value = onRun( benv )\n let idx = -1, defaultIdx = -1\n\n for( let i = 0; i < child.cases.length; i++ ){\n const c = child.cases[ i ]\n if( c.is === null ){ defaultIdx = i; continue }\n\n const is = 'lit' in c.is ? c.is.lit : caseRuns[ i ]!( benv )\n if( Array.isArray( is ) ? is.includes( value ) : is === value ){ idx = i; break }\n }\n if( idx === -1 ) idx = defaultIdx\n if( idx === activeIdx ) return\n activeIdx = idx\n\n untrack( () => {\n destroy( h, current )\n current = null\n if( idx >= 0 ){\n current = place( h, anchor, this.renderBlock( child.cases[ idx ].block, benv ) )\n }\n })\n })\n\n disposers.push( () => { eff.dispose(); destroy( h, current ) } )\n break\n }\n\n case 'macro': {\n /**\n * Inlined macro body: declared argv become block-scoped\n * reactive vars; every call-site attribute also lands in\n * `arguments` (per-key reactive, so `arguments.x` binds\n * track only that key).\n *\n * `sets` apply in SOURCE ORDER — spreads (`...each`) and\n * explicit attrs override each other left to right, JS\n * object-literal style.\n */\n const scope = Object.create( benv.scope ?? null )\n const args = reactive( {} as Record<string, any> )\n\n // One signal per declared argv (undeclared → stays undefined)\n const argSignals: Record<string, ReturnType<typeof signal<any>>> = {}\n for( const name of child.args ){\n argSignals[ name ] = signal<any>( undefined )\n defineGetter( scope, name, argSignals[ name ][0] )\n }\n\n type SetRunner =\n | { kind: 'spread', run: ( env: RunEnv ) => any }\n | { kind: 'value', name: string, value: () => any }\n\n const runners: SetRunner[] = child.sets.map( s => {\n if( 'spread' in s )\n return { kind: 'spread', run: this.runner( s.spread, scopeNames ) }\n\n if( 'lit' in s.ci ){\n const lit = s.ci.lit\n return { kind: 'value', name: s.name, value: () => lit }\n }\n\n const run = this.runner( s.ci.e, scopeNames )\n return { kind: 'value', name: s.name, value: () => run( benv ) }\n })\n\n let prevKeys = new Set<string>()\n\n disposers.push( effect( () => {\n // Evaluate every set in order into one flat view\n const next: Record<string, any> = {}\n\n for( const r of runners ){\n if( r.kind === 'spread' ){\n const obj = r.run( benv )\n if( obj && typeof obj === 'object' )\n for( const [ k, v ] of ( obj instanceof Map ? obj : Object.entries( obj ) ) )\n next[ k ] = v\n }\n else next[ r.name ] = r.value()\n }\n\n untrack( () => {\n // Feed declared argv signals (Object.is skips no-ops)\n for( const name of child.args )\n argSignals[ name ][1]( next[ name ] )\n\n // Mirror everything into `arguments`; drop vanished keys\n const nextKeys = new Set( Object.keys( next ) )\n for( const k of prevKeys ) !nextKeys.has( k ) && delete args[ k ]\n for( const k of nextKeys ) args[ k ] = next[ k ]\n prevKeys = nextKeys\n })\n }).dispose )\n\n const inst = place( h, anchor, this.renderBlock( child.block, { ...benv, arguments: args, scope }) )\n disposers.push( () => destroy( h, inst ) )\n break\n }\n\n case 'for':\n this.execFor( child, anchor, benv, scopeNames, disposers )\n break\n\n case 'async': {\n const awaitRun = this.runner( child.awaitE, scopeNames )\n let current: BlockInstance | null = null\n let token = 0\n\n const swapTo = ( arm: { args: string[], block: BlockIR } | BlockIR | undefined, value?: any ) => {\n destroy( h, current )\n current = null\n if( !arm ) return\n\n const isArm = 'block' in arm\n const scope2 = Object.create( benv.scope ?? null )\n if( isArm && arm.args[0] !== undefined ){\n const [ get ] = signal( value )\n defineGetter( scope2, arm.args[0], get )\n }\n current = place( h, anchor, this.renderBlock( isArm ? arm.block : arm, { ...benv, scope: scope2 } ) )\n }\n\n const eff = effect( () => {\n const p = awaitRun( benv )\n const my = ++token\n\n untrack( () => {\n child.loading ? swapTo( child.loading ) : swapTo( undefined )\n\n Promise.resolve( p ).then(\n v => my === token && untrack( () => swapTo( child.then, v ) ),\n err => my === token && untrack( () => swapTo( child.catch, err ) )\n )\n })\n })\n\n disposers.push( () => { token++; eff.dispose(); destroy( h, current ) } )\n break\n }\n\n /**\n * Scoped context / scoped language (RFC-005 §4).\n *\n * The layer is a plain object whose PROTOTYPE is the enclosing\n * context, with one reactive getter per provided key. That single\n * choice buys the whole feature:\n *\n * - a read of a provided key hits the own getter and tracks the\n * layer's signal;\n * - a read of anything else walks the chain into the global\n * reactive store and tracks THERE, so unprovided keys stay live;\n * - `Object.create` costs nothing per read, so a component under\n * a provider pays no lookup penalty.\n *\n * Nesting composes for free — an inner `<context>` prototypes off\n * the outer layer, so the nearest provider wins.\n */\n case 'provide': {\n const ctx = Object.create( benv.context ?? null )\n /**\n * Keys this layer OWNS, key → setter. `setContext` from anywhere\n * inside the subtree walks the prototype chain looking for these\n * (RFC-005 §4.1), so a write lands on the nearest layer that\n * declares the key instead of on the global store. The signals\n * die with the block, so the ownership is torn down with it —\n * no unregister step, nothing left behind.\n */\n const owned = new Map<string, ( v: any ) => void>()\n Object.defineProperty( ctx, LAYER, { value: owned })\n\n for( const [ name, input ] of Object.entries( child.vars ) ){\n const [ get, set ] = signal<any>( 'lit' in input ? input.lit : undefined )\n defineGetter( ctx, name, get )\n owned.set( name, set )\n\n /**\n * An expression-bound key is DERIVED: the effect re-syncs it\n * from the source, so a local write holds only until the\n * source next changes. A literal has no effect at all, so a\n * write to it simply sticks — which is how a subtree gets\n * state of its own, seeded once.\n */\n if( 'lit' in input ) continue\n const run = this.runner( input.e, scopeNames )\n disposers.push( effect( () => set( run( benv ) ) ).dispose )\n }\n\n /**\n * The scoped language rides on the env rather than on the\n * context object: it is framework state, not a user-space key,\n * so `<i18n lang=…>` must not collide with a `context.lang` the\n * app happens to own.\n */\n let lang = benv.lang\n if( child.lang ){\n if( 'lit' in child.lang ){\n const v = String( child.lang.lit )\n lang = () => v\n }\n else {\n const [ get, set ] = signal<any>( undefined )\n const run = this.runner( child.lang.e, scopeNames )\n disposers.push( effect( () => set( run( benv ) ) ).dispose )\n // Nullish falls back to the enclosing language, not to ''\n lang = () => get() ?? benv.lang?.()\n }\n }\n\n const inner = place( h, anchor, this.renderBlock( child.block, { ...benv, context: ctx, lang }) )\n disposers.push( () => destroy( h, inner ) )\n break\n }\n\n case 'log': {\n const segs = splitTopLevel( this.ir.exprs[ child.e ] ).map( s => this.srcRunner( s, scopeNames ) )\n disposers.push( effect( () => console.log( ...segs.map( run => run( benv ) ) ) ).dispose )\n break\n }\n\n case 'comp': {\n const def = this.options.components?.[ child.name ]\n def\n ? this.execComponent( def, child, anchor, benv, scopeNames, disposers, child.name )\n : this.execElement( child, anchor, benv, scopeNames, disposers )\n break\n }\n\n case 'dynamic': {\n const tagRun = this.runner( child.tag, scopeNames )\n let inner: ( () => void )[] = []\n let activeVerb: any = Symbol('init')\n\n const eff = effect( () => {\n const verb = tagRun( benv )\n if( verb === activeVerb ) return\n activeVerb = verb\n\n untrack( () => {\n for( const d of inner ) d()\n inner = []\n\n if( verb == null ) return\n\n /**\n * Slot placement: `<{input.renderer} …/>` renders the\n * parent's slotted body here; this tag's inputs become\n * the slot's argument values.\n */\n if( isSlot( verb ) ){\n const argvalues: Record<string, any> = {}\n for( const [ name, ci ] of Object.entries( child.inputs ) )\n argvalues[ name ] = 'lit' in ci ? ci.lit : this.runner( ci.e, scopeNames )( benv )\n\n const slotInst = place( h, anchor, verb.render( argvalues ) )\n inner.push( () => destroy( h, slotInst ) )\n return\n }\n\n /**\n * Component name, a ready IRComponentDef, or a plain\n * template object resolved through the host hook.\n */\n const def = typeof verb === 'string'\n ? this.options.components?.[ verb ]\n : verb && typeof verb === 'object'\n ? ( verb.ir ? verb as IRComponentDef : this.options.resolveTemplate?.( verb ) )\n : undefined\n\n if( def ) this.execComponent( def, child, anchor, benv, scopeNames, inner,\n typeof verb === 'string' ? verb : '#dynamic' )\n else if( typeof verb === 'string' )\n this.execElement( { ...child, name: verb } as any, anchor, benv, scopeNames, inner )\n })\n })\n\n disposers.push( () => { eff.dispose(); for( const d of inner ) d() } )\n break\n }\n }\n\n return () => disposers.forEach( d => d() )\n }\n\n /** Keyed <for> — per-item scope signals, range moves, natural entry keys */\n private execFor(\n child: ChildIR & { t: 'for' },\n anchor: N,\n benv: RunEnv,\n scopeNames: string[],\n disposers: ( () => void )[]\n ){\n const h = this.h\n type Item = {\n key: any\n sigs: [ () => any, ( v: any ) => void, () => void ][]\n inst: BlockInstance\n /** The pass that last kept it — see the removal sweep */\n pass: number\n }\n\n const\n ofRun = child.of !== undefined ? this.runner( child.of, scopeNames ) : null,\n byRun = child.by && 'e' in child.by ? this.runner( child.by.e, scopeNames ) : null,\n byPath = child.by && 'lit' in child.by ? String( child.by.lit ).split('.') : null,\n inputVal = ( ci: CompInput | undefined, env: RunEnv ) =>\n ci === undefined ? undefined : 'lit' in ci ? ci.lit : this.runner( ci.e, scopeNames )( env )\n\n let items: Item[] = [], pass = 0\n const byKey = new Map<any, Item>()\n\n /** Normalize source → [{ key, values(aligned with args) }] */\n const tuples = (): { key: any, values: any[] }[] => {\n // Numeric range\n if( ofRun === null ){\n const from = Number( inputVal( child.from, benv ) ?? 0 )\n const to = Number( inputVal( child.to, benv ) ?? from )\n const asc = from <= to\n const out: { key: any, values: any[] }[] = []\n for( let v = from; asc ? v <= to : v >= to; asc ? v++ : v-- )\n out.push({ key: v, values: [ v ] })\n return out\n }\n\n const src = ofRun( benv )\n const keyFor = ( item: any, fallback: any, index: number ) => {\n if( byRun ){\n const fn = byRun( benv )\n return typeof fn === 'function' ? fn( item, index ) : fallback\n }\n if( byPath ) return byPath.reduce( ( v: any, k ) => v?.[ k ], item )\n return fallback\n }\n\n if( Array.isArray( src ) )\n return src.map( ( item, i ) => ({ key: keyFor( item, i, i ), values: [ item, i ] }) )\n\n if( src instanceof Map )\n return [ ...src.entries() ].map( ( [ k, v ], i ) => ({ key: k, values: [ k, v, i ] }) )\n\n /** Sets iterate like arrays: [ value, index ] */\n if( src instanceof Set )\n return [ ...src ].map( ( item, i ) => ({ key: keyFor( item, item, i ), values: [ item, i ] }) )\n\n if( src && typeof src === 'object' )\n return Object.entries( src ).map( ( [ k, v ], i ) => ({ key: k, values: [ k, v, i ] }) )\n\n return []\n }\n\n const eff = effect( () => {\n const next = tuples() // tracked reads\n untrack( () => {\n const seen = new Set<any>()\n const ordered: Item[] = []\n const mark = ++pass\n\n for( const t of next ){\n let key = t.key\n // Duplicate keys degrade to positional identity\n if( seen.has( key ) ){\n console.warn(`<for> duplicate key '${String( key )}' — falling back to positional identity`)\n key = `#dup:${ordered.length}`\n }\n seen.add( key )\n\n const existing = byKey.get( key )\n if( existing ){\n existing.sigs.forEach( ( [ get, set, touch ], j ) => {\n const nv = t.values[ j ]\n /**\n * Same object reference may have mutated in place\n * (deep-reactive mode) — force the item's binds to\n * re-evaluate; unchanged primitives stay silent.\n */\n Object.is( get(), nv ) && typeof nv === 'object' && nv !== null\n ? touch()\n : set( nv )\n })\n existing.pass = mark\n ordered.push( existing )\n }\n else {\n const scope2 = Object.create( benv.scope ?? null )\n const sigs = t.values.map( v => signal( v ) )\n child.args.forEach( ( name, j ) => sigs[ j ] && defineGetter( scope2, name, sigs[ j ][0] ) )\n\n const inst = this.renderBlock( child.block, { ...benv, scope: scope2 } )\n const item: Item = { key, sigs, inst, pass: mark }\n byKey.set( key, item )\n ordered.push( item )\n }\n }\n\n /**\n * Remove disappeared keys. Kept items carry this pass's stamp, so\n * the test is O(1) — `ordered.includes( item )` made every update\n * O(n²): at 10k rows, 50M comparisons to remove ONE row.\n */\n for( const item of items )\n if( item.pass !== mark ){\n byKey.delete( item.key )\n destroy( h, item.inst )\n }\n\n // Pointer walk: enforce order with range moves\n let pointer: N = anchor\n for( const item of ordered ){\n if( h.next( pointer ) !== item.inst.start )\n place( h, pointer, item.inst )\n pointer = item.inst.end\n }\n\n items = ordered\n })\n })\n\n disposers.push( () => {\n eff.dispose()\n for( const item of items ) destroy( h, item.inst )\n items = []\n byKey.clear()\n })\n }\n\n // ------------------------------------------------------- component wiring\n /**\n * Parent-side input wiring: call-site expressions write into the\n * component's reactive `input`. Kept separate from creation so an\n * adopted instance can be re-wired to a new call site.\n * `written` collects the keys this call site supplies.\n */\n private wireInputs(\n child: { inputs: Record<string, CompInput>, spreads: E[] },\n benv: RunEnv,\n scopeNames: string[],\n input: Record<string, any>,\n wiring: ( () => void )[],\n written?: Set<string>\n ){\n for( const [ name, ci ] of Object.entries( child.inputs ) ){\n written?.add( name )\n\n if( 'lit' in ci ) input[ name ] = ci.lit\n else {\n const run = this.runner( ci.e, scopeNames )\n wiring.push( effect( () => input[ name ] = run( benv ) ).dispose )\n }\n }\n for( const e of child.spreads ){\n const run = this.runner( e, scopeNames )\n wiring.push( effect( () => {\n const obj = run( benv ) || {}\n untrack( () => Object.entries( obj ).forEach( ( [ k, v ] ) => {\n written?.add( k )\n input[ k ] = v\n }) )\n }).dispose )\n }\n }\n\n /** Parent `on-*( … )` instructions → listeners on the child's bus */\n private wireEvents(\n events: { name: string, e: E }[] | undefined,\n benv: RunEnv,\n scopeNames: string[],\n self: any,\n wiring: ( () => void )[]\n ){\n events?.forEach( ev => {\n const dispatch = this.eventDispatcher( this.ir.exprs[ ev.e ], scopeNames, benv )\n self.on( ev.name, dispatch )\n wiring.push( () => self.off( ev.name, dispatch ) )\n })\n }\n\n /**\n * Slotted body → `input.renderer` (old-engine convention):\n * the child template places it with `<{input.renderer}/>`.\n * Content renders in the PARENT scope — a slot closes over\n * where it was written, not where it is placed.\n */\n private slotRenderer( contents: ArmIR, penv: RunEnv ): SlotRenderer {\n const parent = this\n\n return {\n [ SLOT ]: true,\n args: contents.args,\n render( argvalues?: Record<string, any> ){\n const scope = Object.create( penv.scope ?? null )\n\n contents.args.forEach( name => {\n const [ get ] = signal( argvalues?.[ name ] )\n defineGetter( scope, name, get )\n })\n\n return parent.renderBlock( contents.block, { ...penv, scope } )\n }\n }\n }\n\n /**\n * Re-home a salvaged instance: same state, same DOM, same handlers\n * — only the parent-side wiring is rebuilt, against the new call\n * site and the new expression table. No lifecycle hook fires: from\n * the component's point of view nothing happened.\n */\n private adoptComponent(\n rec: LiveComp,\n child: { inputs: Record<string, CompInput>, spreads: E[], events?: { name: string, e: E }[], contents?: ArmIR },\n anchor: N,\n benv: RunEnv,\n scopeNames: string[],\n disposers: ( () => void )[]\n ){\n const\n wiring: ( () => void )[] = [],\n written = new Set<string>()\n\n this.wireInputs( child, benv, scopeNames, rec.input, wiring, written )\n\n if( child.contents ){\n rec.input.renderer = this.slotRenderer( child.contents, benv )\n written.add('renderer')\n }\n // Inputs the revision dropped must not linger on the instance\n for( const k of Object.keys( rec.input ) )\n !written.has( k ) && delete rec.input[ k ]\n\n this.wireEvents( child.events, benv, scopeNames, rec.self, wiring )\n\n rec.wiring = wiring\n rec.anchor = anchor\n\n const gen = rec.gen\n place( this.h, anchor, rec.inst )\n\n disposers.push( () => {\n if( gen !== rec.gen ) return // salvaged away; wiring already released\n\n for( const d of rec.wiring ) d()\n rec.wiring = []\n rec.teardown()\n })\n }\n\n /** Registered component: reactive inputs, slots, events, own env */\n private execComponent(\n def: IRComponentDef,\n child: { inputs: Record<string, CompInput>, spreads: E[], events?: { name: string, e: E }[], contents?: ArmIR },\n anchor: N,\n benv: RunEnv,\n scopeNames: string[],\n disposers: ( () => void )[],\n cname: string\n ){\n /**\n * A live instance released by a swap is re-homed here rather\n * than rebuilt from scratch. Only ever true mid-swap, so a\n * normal render pays nothing for it.\n */\n const salvaged = this.pool?.length\n ? this.claim( cname, this.keyOf( child.inputs, benv, scopeNames ) )\n : undefined\n\n if( salvaged )\n return this.adoptComponent( salvaged, child, anchor, benv, scopeNames, disposers )\n\n const\n input = reactive( {} as Record<string, any> ),\n wiring: ( () => void )[] = []\n\n this.wireInputs( child, benv, scopeNames, input, wiring )\n if( child.contents ) input.renderer = this.slotRenderer( child.contents, benv )\n\n const state = reactive( { ...( def.state || {} ) }, def.deep ?? false )\n\n /**\n * Component event bus: the child emits, the parent's\n * `on-*( … )` instructions receive the emitted arguments.\n */\n /** Set once the block renders — backs `self.node` */\n let selfInst: BlockInstance | null = null\n\n // `this` inside the bus closures is the literal, not the renderer\n const irr = this\n /**\n * `lang` for THIS component is the scoped one when it sits under\n * `<i18n lang=…>`, the global one otherwise. Without it there is no\n * way to show the current language, which is what pushed apps into\n * mirroring it into context by hand (RFC-005 §2).\n */\n const bus = selfBus( this.h, () => benv.lang?.() ?? irr.options.i18n?.lang() ?? '' )\n\n const self: any = bus.bind( Object.assign( Object.create( bus.proto ), {\n ...( this.options.expose || {} ),\n state, input, static: def.statics, context: benv.context,\n /**\n * Overrides the host's global `setContext` (merged in by the\n * spread above): a write goes to the nearest `<context>` layer\n * that declares the key, and only reaches the global store when\n * no layer claims it. A component under a provider therefore\n * mutates ITS OWN context — two canvases writing `selection` no\n * longer collide (RFC-005 §4.1).\n */\n setContext( arg: any, value?: any ){\n const write = ( k: string, v: any ) =>\n writeContext( benv.context, k, v, ( irr.options.expose as any )?.setContext )\n\n typeof arg === 'string'\n ? write( arg, value )\n : Object.entries( arg || {} ).forEach( ( [ k, v ] ) => write( k, v ) )\n }\n }), () => selfInst )\n def.handlers && Object.entries( def.handlers ).forEach( ( [ k, fn ] ) => self[ k ] = fn.bind( self ) )\n\n this.wireEvents( child.events, benv, scopeNames, self, wiring )\n\n const hooks = makeHooks( self )\n\n // Lifecycle: creation → (initial input) → render → mount → attach\n try { typeof self.onCreate === 'function' && self.onCreate() }\n catch( error ){ hooks.onError( error ) }\n\n // Handlers receive the input object (Modela: onInput({ host, settings }))\n try { Object.keys( input ).length && typeof self.onInput === 'function' && self.onInput( input ) }\n catch( error ){ hooks.onError( error ) }\n\n /**\n * `context` and `lang` are INHERITED from the call site, not reset:\n * a component placed inside `<context …>` or `<i18n lang=…>` renders\n * under that layer. `scope` is not — a component is a fresh\n * expression scope, unlike a block.\n */\n const cenv: RunEnv = {\n state, input, context: benv.context, lang: benv.lang,\n static: def.statics, self, scope: undefined\n }\n const renderer = new IRRenderer( def.ir, this.options, hooks )\n const inst = renderer.renderBlock( def.ir.root, cenv )\n selfInst = inst // backs self.node\n\n /**\n * Scoped stylesheet — stamp `rel` and write the reactive declarations'\n * variables BEFORE the nodes go live, or the first paint resolves\n * `var()` against nothing (RFC-004 §8).\n */\n const\n clearStyles = def.stylesheet\n ? applyScopedStyles( this.h, this.options, inst, def.stylesheet.nsp || def.nsp || 'lips', def.stylesheet )\n : undefined,\n clearStyleBinds = def.stylesheet\n ? renderer.bindStyle( def.stylesheet, inst, cenv )\n : undefined\n\n place( this.h, anchor, inst )\n hooks.ready()\n\n try {\n typeof self.onMount === 'function' && self.onMount()\n typeof self.onRender === 'function' && self.onRender()\n self.emit('component:mount')\n }\n catch( error ){ hooks.onError( error ) }\n\n /**\n * Declared context subscription — fires onContext only when one of\n * the component's own fields changes.\n *\n * Tracked against the EFFECTIVE context, not the host's global\n * store: reading a key off `cenv.context` hits the layer's own\n * getter when a `<context>` provides it and falls through to the\n * global proxy when it does not, so both notify through the same\n * effect. Watching the host directly (as this did) meant a scoped\n * override never fired the hook while binds reading the same key\n * updated — the one place where declared and rendered context\n * disagreed (RFC-005 §4.2).\n */\n let unwatchContext: ( () => void ) | undefined\n if( def.context?.length && typeof self.onContext === 'function' ){\n let first = true\n const { dispose } = effect( () => {\n for( const f of def.context! ) cenv.context?.[ f ] // track\n if( first ){ first = false; return }\n\n untrack( () => {\n try { self.onContext() }\n catch( error ){ hooks.onError( error ) }\n })\n })\n unwatchContext = dispose\n }\n\n /**\n * Attachment is always tracked (not only when onAttach is\n * defined): external controls subscribe via the event bus with\n * `self.on('component:attached', …)`.\n */\n let attached = false\n {\n PENDING_ATTACH.push({\n live: () => this.h.connected( inst.start ),\n fn: () => {\n attached = true\n try {\n typeof self.onAttach === 'function' && self.onAttach()\n self.emit('component:attached')\n }\n catch( error ){ hooks.onError( error ) }\n }\n })\n // Parent already live → attach now\n this.h.connected( inst.start ) && flushAttach()\n }\n\n /**\n * The instance is now tracked for salvage. `teardown` is the one\n * real destruction path — idempotent, because an unclaimed\n * record and its old owner may both reach for it.\n */\n let torn = false\n const rec: LiveComp = {\n name: cname,\n key: input.key, // already wired — no second evaluation\n self, input, inst, anchor, wiring,\n gen: 0,\n claimed: false,\n teardown: () => {\n if( torn ) return\n torn = true\n\n const i = this.live.indexOf( rec )\n i > -1 && this.live.splice( i, 1 )\n\n unwatchContext?.()\n clearStyleBinds?.()\n clearStyles?.()\n destroy( this.h, inst )\n try {\n if( attached ){\n typeof self.onDetach === 'function' && self.onDetach()\n self.emit('component:detached')\n }\n typeof self.onDestroy === 'function' && self.onDestroy()\n self.emit('component:destroy')\n }\n catch( error ){ hooks.onError( error ) }\n }\n }\n this.live.push( rec )\n\n const gen = rec.gen\n disposers.push( () => {\n if( gen !== rec.gen ) return // salvaged away; wiring already released\n\n for( const d of rec.wiring ) d()\n rec.wiring = []\n rec.teardown()\n })\n }\n\n /** Unresolved component candidate → plain element with binds */\n private execElement(\n child: ChildIR & { t: 'comp' },\n anchor: N,\n benv: RunEnv,\n scopeNames: string[],\n disposers: ( () => void )[]\n ){\n const\n h = this.h,\n el = h.element( child.name )\n\n for( const [ name, ci ] of Object.entries( child.inputs ) ){\n if( 'lit' in ci ) applyAttr( h, el, name, ci.lit )\n else {\n const run = this.runner( ci.e, scopeNames )\n disposers.push( effect( () => applyAttr( h, el, name, run( benv ) ) ).dispose )\n }\n }\n for( const ev of child.events )\n disposers.push( h.listen( el, ev.name, this.eventDispatcher( this.ir.exprs[ ev.e ], scopeNames, benv ) ) )\n\n if( child.contents ){\n const inst = this.renderBlock( child.contents.block, benv )\n for( const n of nodesOf( h, inst ) ) h.insert( el, n, null )\n disposers.push( () => destroy( h, inst ) )\n }\n\n h.insertAfter( anchor, [ el ] )\n disposers.push( () => h.remove( el, true ) )\n }\n\n /**\n * Event instruction dispatch (lazy — evaluated per event):\n * - `on-click( expr )` → value must be a function, called with (…params)\n * - `on-click( name, ...args )` → resolves `name` (expression, then\n * self method fallback) and calls with (...args, ...params)\n *\n * `params` are the DOM event for element listeners, or the emitted\n * arguments for component events — same append-after-declared-args\n * rule either way.\n * Scope getters read live values at dispatch — no stale memos.\n */\n private eventDispatcher( instruction: string, scopeNames: string[], benv: RunEnv ){\n const segs = splitTopLevel( instruction )\n\n return ( ...params: any[] ) => untrack( () => {\n const resolveFn = ( src: string ) => {\n let v: any\n try { v = this.srcRunner( src, scopeNames )( benv ) }\n catch( e ){ v = undefined }\n if( typeof v !== 'function' && benv.self && !this.options.guard?.self( src ) && typeof benv.self[ src ] === 'function' )\n v = benv.self[ src ]\n return v\n }\n\n if( !segs.length ) return\n\n const fn = resolveFn( segs[0] )\n if( typeof fn !== 'function' ) return\n\n const args = segs.slice( 1 ).map( src => this.srcRunner( src, scopeNames )( benv ) )\n fn( ...args, ...params )\n })\n }\n}\n\n// -------------------------------------------------------------------- API\nexport function renderIR<T = Node>( ir: TemplateIR, setup: RenderSetup = {}, options: RuntimeOptions = {} ): IRInstance<T> {\n const\n h = options.host || domHost,\n state = reactive( setup.state || {}, setup.deep ?? false ),\n input = setup.input ? reactive( setup.input, setup.deep ?? false ) : undefined\n\n /** Set after the first render — backs `self.node` */\n let rootInst: BlockInstance | null = null\n\n const bus = selfBus( h, () => options.i18n?.lang() ?? '' )\n\n const self: any = bus.bind( Object.assign( Object.create( bus.proto ), {\n state, input, static: setup.static,\n /**\n * `options.expose` is what every NESTED component self gets\n * (setContext, setLanguage). The root is a component too, so it\n * gets the same — otherwise `self.setLanguage(…)` would work\n * everywhere except the top of the tree.\n */\n ...( options.expose || {} ),\n // Host-provided members (e.g. the facade's emit → Events) win\n ...( setup.expose || {} )\n }), () => rootInst )\n\n setup.handlers && Object.entries( setup.handlers ).forEach( ( [ k, fn ] ) => self[ k ] = fn.bind( self ) )\n\n const env: RunEnv = {\n state,\n input,\n context: setup.context,\n static: setup.static,\n self,\n scope: undefined\n }\n\n const hooks = makeHooks( self )\n\n /**\n * Root lifecycle mirrors the nested path exactly:\n * create → (initial input) → render → mount/render → attach.\n */\n try { typeof self.onCreate === 'function' && self.onCreate() }\n catch( error ){ hooks.onError( error ) }\n\n try { input && Object.keys( input ).length && typeof self.onInput === 'function' && self.onInput( input ) }\n catch( error ){ hooks.onError( error ) }\n\n let renderer = new IRRenderer( ir, options, hooks )\n let current = renderer.renderBlock( ir.root, env )\n rootInst = current // backs self.node\n hooks.ready()\n\n // Scoped stylesheet for the root component\n const clearStyles = setup.stylesheet\n ? applyScopedStyles( h, options, current, setup.stylesheet.nsp || setup.nsp || 'lips', setup.stylesheet )\n : undefined\n\n /**\n * Style binds capture the scope roots, so a swap that rebuilds the root\n * has to re-bind against the fresh ones.\n */\n let clearStyleBinds = setup.stylesheet\n ? renderer.bindStyle( setup.stylesheet, current, env )\n : undefined\n\n try {\n typeof self.onMount === 'function' && self.onMount()\n typeof self.onRender === 'function' && self.onRender()\n }\n catch( error ){ hooks.onError( error ) }\n\n let attached = false\n const attachSelf = () => {\n if( attached ) return\n attached = true\n try {\n typeof self.onAttach === 'function' && self.onAttach()\n self.emit('component:attached')\n }\n catch( error ){ hooks.onError( error ) }\n }\n\n return {\n state,\n self,\n get nodes(){ return nodesOf( h, current ) },\n mount( container: T ){\n for( const n of nodesOf( h, current ) ) h.insert( container, n, null )\n /**\n * Ownership-based attach (RFC §6): mounting a live tree\n * settles this component and every child queued during\n * render — no document-wide MutationObserver.\n */\n if( h.connected( current.start ) ){\n attachSelf()\n flushAttach()\n }\n },\n swap( newIR: TemplateIR ): SwapReport {\n const\n changes: SwapChange[] = [],\n // Salvage moves nodes, which can drop focus — the host puts it back\n restoreFocus = h.keepFocus?.()\n\n // The new renderer inherits the live components: they outlive the IR\n renderer = new IRRenderer( newIR, options, hooks, renderer.live )\n current = renderer.swapBlock( current, newIR.root, changes, 'root' )\n rootInst = current // a rebuild replaces the instance\n\n /**\n * A rebuild produces fresh element roots, which arrive without\n * the `rel` the scoped sheet selects on — re-stamp them, or the\n * component silently loses its styles on the first revision.\n */\n if( setup.stylesheet ){\n stampScope( h, current, setup.stylesheet.nsp || setup.nsp || 'lips' )\n clearStyleBinds?.()\n clearStyleBinds = renderer.bindStyle( setup.stylesheet, current, env )\n }\n\n restoreFocus?.()\n\n return { changes, salvaged: renderer.salvaged }\n },\n dispose(){\n clearStyleBinds?.()\n clearStyles?.()\n destroy( h, current )\n try {\n if( attached ){\n typeof self.onDetach === 'function' && self.onDetach()\n self.emit('component:detached')\n }\n typeof self.onDestroy === 'function' && self.onDestroy()\n }\n catch( error ){ hooks.onError( error ) }\n }\n }\n}\n",
9
11
  "import type { EventListener } from './types'\n\nexport type EventOptions = {\n emit?: boolean\n}\n\nexport default class Events {\n private options: EventOptions = {\n emit: true\n }\n private __events: Record<string, EventListener[]> = {}\n private __once_events: Record<string, EventListener[]> = {}\n\n constructor( options?: EventOptions ){\n if( options )\n this.options = options\n }\n\n on( _event: string, fn: EventListener ){\n if( !Array.isArray( this.__events[ _event ] ) )\n this.__events[ _event ] = []\n\n this.__events[ _event ].push( fn )\n return this\n }\n once( _event: string, fn: EventListener ){\n if( !Array.isArray( this.__once_events[ _event ] ) )\n this.__once_events[ _event ] = []\n\n this.__once_events[ _event ].push( fn )\n return this\n }\n off( _event: string, fn?: EventListener ){\n /**\n * Remove a single listener when provided,\n * otherwise clear every listener of the event.\n */\n if( fn ){\n if( Array.isArray( this.__events[ _event ] ) ){\n this.__events[ _event ] = this.__events[ _event ].filter( each => each !== fn )\n !this.__events[ _event ].length && delete this.__events[ _event ]\n }\n\n if( Array.isArray( this.__once_events[ _event ] ) ){\n this.__once_events[ _event ] = this.__once_events[ _event ].filter( each => each !== fn )\n !this.__once_events[ _event ].length && delete this.__once_events[ _event ]\n }\n }\n else {\n delete this.__events[ _event ]\n delete this.__once_events[ _event ]\n }\n\n return this\n }\n emit( _event: string, ...params: any[] ){\n if( !this.options.emit ) return\n\n /**\n * DO NOT ALLOW any proxied variables\n * to be emitted out of a component.\n *\n * Non-mutating: plain objects/arrays are cloned as\n * they are unwrapped — emitted arguments are never\n * altered in place. Class instances (Error, DOM\n * nodes, …) pass through untouched.\n */\n const\n deepclean = ( each: any ): any => {\n if( !each || typeof each !== 'object' ) return each\n\n if( typeof each.toJSON === 'function' ) return each.toJSON()\n\n if( Array.isArray( each ) )\n return each.map( deepclean )\n\n if( each.constructor === Object || each.constructor === undefined ){\n const clone: Record<string, any> = {}\n for( const key in each )\n clone[ key ] = deepclean( each[ key ] )\n\n return clone\n }\n\n return each\n },\n serialized = params.map( deepclean )\n\n this.__events[ _event ]?.forEach( fn => fn( ...serialized ) )\n\n // Once listeners\n this.__once_events[ _event ]?.forEach( fn => fn( ...serialized ) )\n delete this.__once_events[ _event ]\n }\n}",
10
- "/**\n * Component stylesheets — scoped by a `rel` attribute selector,\n * injected once per namespace and reference counted so shared\n * components clean up correctly. Native DOM only (no cash-dom).\n *\n * The CSS preprocessor (Stylis) is INJECTED, not imported, so the\n * precompiled-only `./runtime` build tree-shakes it out entirely.\n * The full `@lipsjs/lips` entry wires it (see src/lips.ts); a build\n * without it warns and skips source stylesheets rather than shipping\n * a preprocessor a precompiled/CSP app never needs.\n */\n\nexport type StyleSettings = {\n sheet?: string\n /** Inject globally instead of scoping to `[rel=\"<nsp>\"]` */\n meta?: boolean\n}\n\ntype StyleCompiler = ( css: string ) => string\nlet STYLE_COMPILER: StyleCompiler | null = null\n\n/** Wire the CSS preprocessor (full build only) */\nexport function setStyleCompiler( fn: StyleCompiler ){ STYLE_COMPILER = fn }\n\nexport default class Stylesheet {\n private nsp: string\n private settings: StyleSettings\n\n constructor( nsp: string, settings?: StyleSettings ){\n if( typeof nsp !== 'string' || !nsp )\n throw new Error('Undefined or invalid stylesheet namespace')\n\n this.nsp = nsp\n this.settings = settings || {}\n\n this.settings.sheet && this.load( this.settings )\n }\n\n private get rel(){\n return `${this.settings.meta ? '@' : ''}${this.nsp}`\n }\n private get styleElement(){\n return document.head.querySelector<HTMLStyleElement>(`style[rel=\"${this.rel}\"]`)\n }\n\n /**\n * Compile and inject. `dindex` counts live instances sharing this\n * namespace: it increases per instance and decreases on clear, so\n * the element is removed only by the last one out.\n */\n load( settings: StyleSettings ){\n this.settings = settings\n if( !settings.sheet ) return\n\n if( !STYLE_COMPILER ){\n console.warn(\n `[lips] <${this.nsp}> stylesheet skipped — this build has no CSS preprocessor. `\n + 'Use \"@lipsjs/lips\" (not \"@lipsjs/lips/runtime\") for source stylesheets.' )\n return\n }\n\n const existing = this.styleElement\n if( existing ){\n // Already injected — just take a reference\n existing.setAttribute('dindex', String( Number( existing.getAttribute('dindex') || 0 ) + 1 ) )\n return existing\n }\n\n const source = settings.meta ? settings.sheet : `[rel=\"${this.nsp}\"] { ${settings.sheet} }`\n let sheet: string\n try { sheet = STYLE_COMPILER( source ) }\n catch( error: any ){ throw new Error(`Style compilation failed: ${error.message}`) }\n\n if( !sheet )\n throw new Error(`<${this.nsp}> stylesheet compilation produced no output`)\n\n const element = document.createElement('style')\n element.setAttribute('rel', this.rel )\n element.setAttribute('dindex', '0')\n element.textContent = sheet\n\n settings.meta\n ? document.head.prepend( element )\n : document.head.appendChild( element )\n\n return element\n }\n\n /** Release this instance's reference; removes the element at zero */\n clear(){\n const element = this.styleElement\n if( !element ) return\n\n const dindex = Number( element.getAttribute('dindex') || 0 )\n\n dindex <= 0\n ? element.remove()\n : element.setAttribute('dindex', String( dindex - 1 ) )\n }\n}\n",
11
- "import type { I18nVariant, I18nFormat } from '../types'\n\nfunction injectParams( text: string, params?: Record<string, any> ){\n // A missing/!string form (e.g. no '*' fallback defined) must not throw\n if( typeof text !== 'string' ) return ''\n if( !params ) return text\n\n return text.replace(/{(\\w+)}/g, ( _, key ) => {\n return params[ key ] !== undefined\n ? params[ key ].toString()\n : `{${key}}`\n })\n}\n\nexport default ( type: string, reference: string, value: I18nFormat['value'], params: Record<string, any>, variant?: string ) => {\n \n switch( type ){\n /**\n * Plural forms translation\n */\n case 'plural': {\n if( typeof value === 'string' ){\n console.warn(`Plural format value cannot be a string`)\n return \n }\n\n if( params.count === undefined ){\n console.warn(`Plural format requires <count> parameter or use * by default.`)\n // Fall back to '*'\n let formText = value['*']\n // Default form come with variants\n if( typeof formText === 'object' )\n formText = formText[ variant || '*' ]\n \n return injectParams( formText, params )\n }\n\n // `count` param must be integer or float\n if( typeof params.count === 'string' )\n params.count = Number( params.count )\n \n let form = '*' // Default is '*' for many/other\n\n /**\n * When `count` matches an exact form key\n */\n if( params.count.toString() in value )\n form = params.count.toString()\n\n let formText = value[ form ] || value['*']\n /**\n * In case form text is also has variants\n */\n if( typeof formText === 'object' )\n formText = formText[ variant || '*' ]\n \n return injectParams( formText, params )\n }\n\n /**\n * Conditional variable format translation\n */\n case 'condition': {\n if( typeof value === 'string' ){\n console.warn(`Condition format value cannot be a string`)\n return \n }\n\n let text\n\n // Evaluate each condition\n for( const expr in value )\n try {\n const fn = new Function('params', `with( params ){ return ${expr}; }`)\n if( fn( params || {} ) ){\n text = value[ expr ]\n break\n }\n }\n catch( error ){ console.warn(`Invalid <${reference}(${expr})> condition expression`) }\n\n if( text === undefined ) return\n\n /**\n * In case form text is also has variants\n */\n if( typeof text === 'object' )\n text = text[ variant || '*' ]\n \n return injectParams( text, params )\n }\n\n /**\n * Simple variable format translation\n */\n case 'variable':\n default: {\n const text = typeof value === 'object' \n ? value[ variant || '*' ] // Select variant\n : value\n\n if( typeof text === 'object' ){\n console.warn(`Invalid <${reference}> variable variant definition`)\n return\n }\n \n return injectParams( text, params )\n }\n }\n}",
12
- "import type { Dictionary } from '../types'\nimport Formatters from './formatters'\n\nexport default class I18N {\n private currentLang = window.navigator.language\n private DICTIONARIES: Record<string, Dictionary> = {}\n\n set lang( value: string ){\n if( this.currentLang === value ) return\n this.currentLang = value\n }\n get lang(){\n return this.currentLang\n }\n\n setDictionary( id: string, dico: Dictionary ){\n this.DICTIONARIES[ id ] = dico\n }\n\n /**\n * \n */\n translate( text: string, lang?: string ){\n // No translation required\n if( lang && this.currentLang === lang )\n return { text, lang: this.currentLang }\n\n lang = lang || this.currentLang\n\n /**\n * Translate displayable texts\n * \n * - text content\n * - title attribute\n * - placeholder attribute\n */\n const [ id, variant ]: string[] = lang.split('-')\n if( this.DICTIONARIES[ id ] && text in this.DICTIONARIES[ id ] ){\n // Check by dictionary variant or currentLang option\n if( typeof this.DICTIONARIES[ id ][ text ] === 'object' ){\n const variants = this.DICTIONARIES[ id ][ text ] as Record<string, string>\n text = variants[ variant || '*' ] || variants['*']\n }\n \n // Single translation option\n else if( typeof this.DICTIONARIES[ id ][ text ] === 'string' )\n text = this.DICTIONARIES[ id ][ text ] as string\n }\n \n return { text, lang }\n }\n\n /**\n * \n */\n format( reference: string, params: Record<string, any>, local?: string ){\n /**\n * Format `local` defined as language or country\n * \n * Eg.\n * - `en-UK`, `de-GR`\n * - `TG`, `US`\n */\n local = local || this.currentLang\n\n const [ id, variant ]: string[] = local.split('-')\n if( !this.DICTIONARIES[ id ] ){\n console.warn(`Undefined <${local}> format dictionary`)\n return\n }\n \n // In case no-format reference is found\n if( !this.DICTIONARIES[ id ][ reference ] ){\n console.warn(`Undefined <${local}[${reference}]> format reference`)\n return\n }\n \n const format = this.DICTIONARIES[ id ][ reference ]\n if( typeof format === 'string' ){\n console.warn(`Invalid <${local}[${reference}]> format reference. Expected object`)\n return\n }\n \n if( typeof format !== 'object' \n || format === null\n || Array.isArray( format ) ){\n console.warn(`Invalid <${local}[${reference}]> format value`)\n return\n }\n\n return Formatters( format.type, reference, format.value, params, variant )\n }\n}\n",
13
- "/**\n * Phase 2 — engine facade (RFC-001 §9)\n *\n * The old public Lips API backed by the IR engine, activated via\n * `new Lips({ engine: 'ir' })`. Templates are the same plain\n * objects ({ default, state, handler, _static, stylesheet, … });\n * behind the API: parse → IR → renderIR with deep-reactive state.\n *\n * Parity gaps this facade does not yet cover (tracked in ROADMAP):\n * router, i18n, macros, component contents/slots + events,\n * declaration-driven syntax components.\n */\n\nimport type { TemplateIR, CompileResult, CompileOptions } from './compiler'\n\n/**\n * The template compiler is INJECTED, not imported, so a\n * precompiled-only build can tree-shake the parser and compiler out\n * entirely (see src/runtime.ts vs src/lips.ts).\n */\ntype CompilerFn = ( src: string, options?: CompileOptions ) => CompileResult\nlet COMPILER: CompilerFn | null = null\n\nexport function setCompiler( fn: CompilerFn ){ COMPILER = fn }\n\n/**\n * Built-in components (e.g. `<router>`) are INJECTED by the full\n * entry rather than imported here, so the precompiled-only\n * `./runtime` build — which can't compile their source templates\n * anyway — tree-shakes them out.\n */\nconst BUILTINS: Record<string, any> = {}\nexport function registerBuiltin( name: string, template: any ){ BUILTINS[ name ] = template }\n\nimport type { IRComponentDef, IRInstance, RuntimeOptions } from './runtime'\nimport { renderIR } from './runtime'\nimport { reactive, effect, signal } from './signal'\nimport Events from '../events'\nimport Stylesheet from '../stylesheet'\nimport I18N from '../i18n'\n\ninterface FacadeTemplate {\n default?: string\n /** Precompiled IR — skips parsing entirely (see src/precompile.ts) */\n ir?: TemplateIR\n macros?: string\n state?: Record<string, any>\n handler?: Record<string, ( this: any, ...args: any[] ) => any>\n _static?: Record<string, any>\n context?: string[]\n stylesheet?: string\n}\n\ninterface FacadeConfig {\n engine?: string\n debug?: boolean\n context?: Record<string, any>\n mode?: 'compiled' | 'interpreted'\n}\n\n/**\n * Names template handlers must not override on the component\n * self — mirrors the old engine's reserved-member guard.\n */\nconst RESERVED_MEMBERS = new Set([\n 'state', 'input', 'static', 'context', 'emit', 'on', 'once', 'off',\n 'node', 'destroy', 'appendTo', 'prependTo', 'replaceWith', 'render', 'swap'\n])\n\nfunction guardHandlers( handler?: FacadeTemplate['handler'] ){\n if( !handler ) return undefined\n\n for( const name of Object.keys( handler ) )\n if( RESERVED_MEMBERS.has( name ) )\n throw new Error(`Handler <${name}> is a reserved component member name`)\n\n return handler\n}\n\n// --------------------------------------------------------------- component\nexport class IRFacadeComponent extends Events {\n readonly state: Record<string, any>\n private instance: IRInstance\n private contextWatcher?: () => void\n private destroyed = false\n\n constructor(\n private lips: IRLips,\n name: string,\n private template: FacadeTemplate,\n input: Record<string, any> | undefined,\n ir: TemplateIR,\n options: RuntimeOptions\n ){\n super()\n const handlers = guardHandlers( template.handler )\n\n this.state = reactive( { ...( template.state || {} ) }, true )\n const inputR = input ? reactive( { ...input }, true ) : undefined\n\n /**\n * The runtime owns the whole lifecycle (create → input →\n * render → mount → attach → destroy) for root and nested\n * components alike — the facade only supplies wiring.\n */\n this.instance = renderIR( ir, {\n state: this.state,\n input: inputR,\n context: lips.getContext(),\n static: template._static,\n handlers,\n deep: true,\n // Scoped stylesheet — the runtime stamps `rel` and injects\n stylesheet: template.stylesheet,\n nsp: name,\n expose: {\n emit: ( event: string, ...args: any[] ) => this.emit( event, ...args ),\n context: lips.getContext()\n }\n }, options )\n\n /**\n * Context subscription: components declaring `context: [...]`\n * get onContext whenever a declared field changes.\n */\n if( template.context?.length && typeof handlers?.onContext === 'function' )\n this.contextWatcher = lips.watchContext( template.context, () => {\n try { handlers.onContext!.call( this.instance.self ) }\n catch( error ){ console.error('[lips:ir]', error ) }\n })\n\n this.emit('component:mount')\n }\n\n get node(){ return this.instance.nodes }\n\n appendTo( selector: string | Element ){\n const target = typeof selector === 'string' ? document.querySelector( selector ) : selector\n target && this.instance.mount( target as Element )\n return this\n }\n\n swap( newIR: TemplateIR ){ return this.instance.swap( newIR ) }\n\n destroy(){\n if( this.destroyed ) return\n this.destroyed = true\n\n this.contextWatcher?.()\n // dispose() runs onDetach/onDestroy and clears the scoped stylesheet\n this.instance.dispose()\n this.emit('component:destroy')\n }\n}\n\n// -------------------------------------------------------------------- lips\nexport class IRLips {\n public debug: boolean\n private store = new Map<string, FacadeTemplate>()\n private irCache = new WeakMap<FacadeTemplate, TemplateIR>()\n private defCache = new WeakMap<FacadeTemplate, IRComponentDef>()\n private context: Record<string, any>\n private __root?: IRFacadeComponent\n\n public i18n = new I18N()\n /** Language signal — translated binds subscribe through it */\n private getLang: () => string\n private setLang: ( v: string ) => void\n\n /**\n * Registered components resolved lazily — the runtime looks\n * names up per render, so registration order doesn't matter.\n */\n private componentsProxy: Record<string, IRComponentDef>\n\n constructor( private config?: FacadeConfig ){\n this.debug = !!config?.debug\n this.context = reactive( { ...( config?.context || {} ) }, true )\n\n const [ getLang, setLang ] = signal( this.i18n.lang )\n this.getLang = getLang\n this.setLang = setLang\n\n // Built-in components (their templates are source — need the compiler)\n COMPILER && Object.entries( BUILTINS ).forEach( ( [ name, template ] ) => this.register( name, template ) )\n\n const self = this\n this.componentsProxy = new Proxy( {} as Record<string, IRComponentDef>, {\n get( _, name: string ){\n const template = self.store.get( name )\n return template ? self.defFor( name, template ) : undefined\n },\n has( _, name: string ){ return self.store.has( name as string ) }\n })\n }\n\n // ---- registry\n register( name: string, template: FacadeTemplate ){\n this.store.set( name, template )\n return this\n }\n unregister( name: string ){\n this.store.delete( name )\n return this\n }\n has( name: string ){ return this.store.has( name ) }\n\n private compile( template: FacadeTemplate ): TemplateIR {\n // Precompiled: nothing to parse\n if( template.ir ) return template.ir\n\n let ir = this.irCache.get( template )\n if( !ir ){\n if( !COMPILER )\n throw new Error(\n 'This build has no template compiler — templates must be precompiled to `ir` '\n + '(import from \"@lipsjs/lips\" instead of \"@lipsjs/lips/runtime\")' )\n\n const result = COMPILER( template.default || '', { macros: template.macros })\n result.diagnostics.length\n && console.warn('[lips:ir] template diagnostics —', result.diagnostics )\n\n ir = result.ir\n this.irCache.set( template, ir )\n }\n return ir\n }\n private defFor( name: string, template: FacadeTemplate ): IRComponentDef {\n let def = this.defCache.get( template )\n if( !def ){\n def = {\n ir: this.compile( template ),\n state: template.state,\n statics: template._static,\n context: template.context,\n stylesheet: template.stylesheet,\n nsp: name,\n handlers: guardHandlers( template.handler ),\n deep: true\n }\n this.defCache.set( template, def )\n }\n return def\n }\n\n // ---- rendering\n render( name: string, template: FacadeTemplate, input?: Record<string, any> ){\n return new IRFacadeComponent( this, name, template, input, this.compile( template ), {\n mode: this.config?.mode,\n components: this.componentsProxy,\n watchContext: ( fields, fn ) => this.watchContext( fields, fn ),\n /**\n * Route pages (and any `<{templateObject}/>`) are plain\n * template objects — compile + cache them on demand.\n */\n resolveTemplate: ( value: any ) =>\n value && ( typeof value.default === 'string' || value.ir )\n ? this.defFor( value.name || 'dynamic', value as FacadeTemplate )\n : undefined,\n expose: {\n setContext: ( arg: any, value?: any ) => this.setContext( arg, value )\n },\n /**\n * Scoped-stylesheet factory. Undefined in a build without a CSS\n * preprocessor (`./runtime`), so the runtime skips injection.\n */\n createStylesheet: ( nsp: string, css: string ) => {\n const sheet = new Stylesheet( nsp, { sheet: css })\n return { clear: () => sheet.clear() }\n },\n i18n: {\n /**\n * Reading the language signal inside the bind effect is\n * what makes setLanguage() re-translate every marked node.\n */\n translate: ( text: string ) => {\n this.getLang() // track — passing the lang would short-circuit translate()\n return this.i18n.translate( text ).text\n },\n format: ( reference: string, params: any ) => {\n this.getLang()\n return this.i18n.format( reference, params ) ?? ''\n }\n }\n })\n }\n root( template: FacadeTemplate, selector: string ){\n this.__root = this.render( '__ROOT__', template )\n this.__root.appendTo( selector )\n return this.__root\n }\n\n // ---- i18n\n setLanguage( lang: string ){\n this.i18n.lang = lang\n this.setLang( lang )\n }\n getLanguage(){ return this.getLang() }\n useTranslator( support: string | string[], fn: ( lang: string ) => void ){\n let first = true\n const { dispose } = effect( () => {\n const lang = this.getLang()\n if( first ){ first = false; return }\n ;( support === '*' || ( Array.isArray( support ) && support.includes( lang ) ) ) && fn( lang )\n })\n return dispose\n }\n\n // ---- context\n getContext(){ return this.context }\n setContext( arg: string | Record<string, any>, value?: any ){\n typeof arg === 'string'\n ? this.context[ arg ] = value\n : Object.entries( arg ).forEach( ( [ k, v ] ) => this.context[ k ] = v )\n }\n /**\n * Subscribe to a subset of context fields — the effect tracks\n * exactly those keys, so unrelated context writes don't fire it.\n * Returns an unsubscribe function.\n */\n watchContext( fields: string[], fn: () => void ){\n let first = true\n const { dispose } = effect( () => {\n fields.forEach( f => this.context[ f ] ) // track\n first ? first = false : fn()\n })\n return dispose\n }\n useContext( fields: string[], fn: ( ctx: Record<string, any> ) => void ){\n return this.watchContext( fields, () =>\n fn( Object.fromEntries( fields.map( f => [ f, this.context[ f ] ] ) ) ) )\n }\n\n dispose(){\n this.__root?.destroy()\n }\n}\n",
14
- "/**\n * Precompiled-only entry: the runtime WITHOUT the template parser\n * and compiler.\n *\n * import Lips from '@lipsjs/lips/runtime'\n *\n * Templates must carry precompiled `ir` (see `precompile()` or the\n * bundler plugin). Combined with `mode: 'interpreted'` this build\n * never constructs a Function, so it runs under a strict CSP.\n */\nimport { IRLips } from './ir/facade'\n\nexport * from './types'\nexport { renderIR } from './ir/runtime'\nexport { signal, effect, untrack, reactive } from './ir/signal'\nexport type { TemplateIR, IRInstance, RuntimeOptions, RenderSetup, SwapReport } from './ir'\n\nexport default IRLips\n"
12
+ "/**\n * Component stylesheets — injected once per namespace and reference\n * counted so shared components clean up correctly. Native DOM only.\n *\n * Compilation lives in `ir/style.ts` and happens at COMPILE time: what\n * arrives here is final, scoped, compact CSS (StyleIR.css). That\n * is what lets the precompiled-only `./runtime` build ship styles with\n * no CSS preprocessor at all — see RFC-004 §1.\n */\n\nexport type StyleSettings = {\n /** Final CSS — already scoped and preprocessed */\n sheet?: string\n /** Marks a globally-injected sheet (prepended, so authors can override) */\n meta?: boolean\n}\n\nexport default class Stylesheet {\n private nsp: string\n private settings: StyleSettings\n\n constructor( nsp: string, settings?: StyleSettings ){\n if( typeof nsp !== 'string' || !nsp )\n throw new Error('Undefined or invalid stylesheet namespace')\n\n this.nsp = nsp\n this.settings = settings || {}\n\n this.settings.sheet && this.load( this.settings )\n }\n\n private get rel(){\n return `${this.settings.meta ? '@' : ''}${this.nsp}`\n }\n /** Quoted, so a name can only ever select its own `<style>` */\n private get styleElement(){\n return document.head.querySelector<HTMLStyleElement>(`style[rel=\"${ this.rel.replace( /[\"\\\\]/g, '\\\\$&' ) }\"]`)\n }\n\n /**\n * Inject. `dindex` counts live instances sharing this namespace: it\n * increases per instance and decreases on clear, so the element is\n * removed only by the last one out.\n */\n load( settings: StyleSettings ){\n this.settings = settings\n if( !settings.sheet ) return\n\n const existing = this.styleElement\n if( existing ){\n // Already injected — just take a reference\n existing.setAttribute('dindex', String( Number( existing.getAttribute('dindex') || 0 ) + 1 ) )\n return existing\n }\n\n const element = document.createElement('style')\n element.setAttribute('rel', this.rel )\n element.setAttribute('dindex', '0')\n element.textContent = settings.sheet\n\n settings.meta\n ? document.head.prepend( element )\n : document.head.appendChild( element )\n\n return element\n }\n\n /** Release this instance's reference; removes the element at zero */\n clear(){\n const element = this.styleElement\n if( !element ) return\n\n const dindex = Number( element.getAttribute('dindex') || 0 )\n\n dindex <= 0\n ? element.remove()\n : element.setAttribute('dindex', String( dindex - 1 ) )\n }\n}\n",
13
+ "import type { MessageFormat } from 'messageformat'\nimport type { MessageFunction } from 'messageformat/functions'\nimport type { Dictionary, MessageFormatEngine } from '../types'\nimport { lookupTags, pick, type TranslatableName } from './lookup'\n\nexport { lookupTags, pick, type TranslatableName }\n\n/**\n * Last-resort language. Only reached when the host has no\n * `navigator` (SSR, a worker, a test runner) and the caller named\n * no language either.\n */\nconst DEFAULT_LANG = 'en-US'\n\n/**\n * Every message is Unicode MessageFormat 2 (CLDR 47), formatted by\n * `messageformat` — the same implementation the platform that serves\n * the dictionaries checks them with, so a message means one thing on\n * both sides of the wire. The engine is handed in (`./engine`), so a\n * build that never translates ships without it. An entry is MF2 source:\n *\n * 'cart.items': `.input {$count :integer}\n * .match $count\n * 0 {{Your cart is empty}}\n * one {{One item in your cart}}\n * * {{{$count} items in your cart}}`\n *\n * or the same message as its data model (`parseMessage`'s JSON), which is\n * how a server that parsed it once serves it.\n *\n * Dictionaries are keyed by full language tag (`fr`, `fr-CA`, `zh-Hant`)\n * and read through RFC 4647 Lookup: a `fr-CA` reader is served from\n * `fr-CA`, then `fr`, so a regional dictionary carries only what differs.\n */\nexport default class I18N {\n private currentLang: string\n private DICTIONARIES: Record<string, Dictionary> = {}\n\n /**\n * MF2 functions a message may call, beyond the default ones built in\n * (`:number`, `:integer`, `:currency`, `:percent`, `:offset`,\n * `:string`). Starts with the draft set — `:date`, `:time`,\n * `:datetime`, `:unit` — and takes a host's own, named with a\n * namespace (`:app:money`) as MF2 asks of custom functions.\n */\n public functions: Record<string, MessageFunction<any, any>>\n\n /**\n * Reports a stable key that no dictionary entry answers. Left unset\n * translation stays silent; the facade wires it to a console warning\n * under `debug`, and a generator can wire it to collect the gaps.\n */\n public onMissing?: ( key: string, lang: string ) => void\n\n /**\n * Reports a message that does not parse, or that fails as it formats:\n * a variable not given, an unknown function, a value its function\n * cannot take. Rendering never throws for it — MF2 writes a fallback\n * (`{$name}`) where the failing part was — so this is where it shows.\n */\n public onError?: ( error: unknown, key: string, lang: string ) => void\n\n /**\n * Fires whenever the dictionary set changes. The facade bumps a\n * revision signal from here, which is what makes a dictionary that\n * arrives LATE — an async load resolving after the language already\n * switched — re-translate what is already on screen.\n */\n public onChange?: () => void\n\n /** Async dictionary source, set by `setLoader` */\n private loader?: ( tag: string ) => Promise<Dictionary | undefined>\n /** In-flight and settled loads, keyed by language tag */\n private loading = new Map<string, Promise<void>>()\n /** Each message as read by one language, parsed once: `null` where it does not parse */\n private formatters = new Map<string, MessageFormat<any, any> | null>()\n\n /**\n * `lang` is the initial language, normally `LipsConfig.lang`. Left\n * out, it is read from the browser — which is the right default for\n * an app that should follow the user's locale, but is not something\n * a server render or a test can rely on being there.\n */\n constructor( lang?: string, private engine?: MessageFormatEngine ){\n this.currentLang = lang\n || ( typeof navigator !== 'undefined' && navigator.language )\n || DEFAULT_LANG\n this.functions = { ...engine?.functions }\n }\n\n set lang( value: string ){\n if( this.currentLang === value ) return\n this.currentLang = value\n }\n get lang(){\n return this.currentLang\n }\n\n /** Register the dictionary for one language tag — `fr`, `fr-CA`, `zh-Hant` — whatever its casing. */\n setDictionary( tag: string, dico: Dictionary ){\n /**\n * Refused rather than read some other way: a dictionary is MF2, and\n * without the engine there is nothing that reads MF2.\n */\n if( !this.engine ) throw new Error(`[lips:i18n] <${tag}> dictionary without a MessageFormat engine — pass \\`messageFormat\\` from '@lipsjs/lips/i18n' to new Lips()`)\n this.DICTIONARIES[ tag.toLowerCase() ] = dico\n this.formatters.clear()\n this.onChange?.()\n }\n /** Is a dictionary registered that a reader of `lang` is served from? */\n has( lang: string ){ return lookupTags( lang.toLowerCase() ).some( tag => !!this.DICTIONARIES[ tag ] ) }\n\n /**\n * Register an async dictionary source, asked once per language tag:\n *\n * lips.i18n.setLoader( tag => import(`./languages/${tag}.json`).then( m => m.default ) )\n *\n * Bundling every language up front costs every user all of them. With\n * a loader, `setLanguage()` switches immediately (untranslated source\n * text is a fine placeholder — it is real wording, not a blank) and\n * the strings resolve when the dictionary lands. A `fr-CA` reader asks\n * for `fr-CA` and `fr`: a source with no `fr-CA` answers `undefined`.\n */\n setLoader( fn: ( tag: string ) => Promise<Dictionary | undefined> ){\n this.loader = fn\n return this\n }\n\n /**\n * Ensure the dictionaries a reader of `lang` is served from are\n * registered. Resolves immediately when they are, or when no loader is\n * set — a missing dictionary is not an error, it just means\n * untranslated output. Each tag is attempted ONCE: a rejected load is\n * remembered so a missing language file does not re-fetch on every\n * switch.\n */\n load( lang: string ): Promise<void> {\n return Promise.all( lookupTags( lang ).map( tag => {\n const id = tag.toLowerCase()\n if( this.DICTIONARIES[ id ] || !this.loader ) return\n\n let inflight = this.loading.get( id )\n if( !inflight ){\n inflight = this.loader( tag )\n .then( dico => { dico && this.setDictionary( tag, dico ) } )\n .catch( error => console.warn(`[lips:i18n] <${tag}> dictionary failed to load —`, error ) )\n this.loading.set( id, inflight )\n }\n return inflight\n }) ).then( () => {} )\n }\n\n /**\n * The message `key` as a reader of `lang` reads it: from the first\n * dictionary of the lookup chain that has it, formatting in `lang`\n * itself — a `fr-CA` reader of a `fr` message still gets Canadian\n * number and date conventions. `undefined` when no dictionary has it;\n * `null` when the one that does holds a message that does not parse.\n */\n private message( key: string, lang: string ){\n const id = `${lang}\\n${key}`\n if( this.formatters.has( id ) ) return this.formatters.get( id )\n\n let mf: MessageFormat<any, any> | null | undefined\n for( const tag of lookupTags( lang.toLowerCase() ) ){\n const dico = this.DICTIONARIES[ tag ]\n if( !dico || !Object.prototype.hasOwnProperty.call( dico, key ) ) continue\n\n try { mf = new this.engine!.MessageFormat( lang, dico[ key ], { functions: this.functions } ) }\n catch( error ){\n this.onError?.( error, key, lang )\n mf = null\n }\n break\n }\n mf !== undefined && this.formatters.set( id, mf )\n return mf\n }\n\n /**\n * Translate a source string into `lang`, defaulting to the current\n * language. A missing dictionary or a missing key is not an error: the\n * source text passes through unchanged, so a partially translated\n * dictionary degrades to the original wording rather than to a blank.\n *\n * `key` is a STABLE id (RFC-005 §3). Given one, it is what the\n * dictionary is consulted for, and `text` becomes only the fallback\n * wording — so rewording the source string keeps the translation.\n * Without it the source text IS the key (the gettext model), which is\n * fine for hand-written UI and lossy for generated UI.\n *\n * The entry is an MF2 message with nothing to fill: plain text, its\n * `{`, `}` and `\\` escaped as MF2 has them.\n *\n * NB: naming the current language explicitly must behave exactly like\n * omitting it — an earlier guard returned the source text whenever\n * `lang === currentLang`, which is precisely when a translation IS wanted.\n */\n translate( text: string, lang?: string, key?: string ){\n const\n as = lang || this.currentLang,\n lookup = key || text,\n mf = this.message( lookup, as )\n\n if( mf ) text = mf.format( undefined, error => this.onError?.( error, lookup, as ) )\n /**\n * A key that resolves to nothing is a real authoring fault — the\n * template names an id the dictionary does not carry — whereas a\n * missing source-text entry is just an untranslated string. Only\n * the first is worth reporting.\n */\n else if( mf === undefined && key ) this.onMissing?.( key, as )\n\n return { text, lang: as }\n }\n\n /**\n * The message `reference` formatted with `params` in `lang`, defaulting\n * to the current language — what `@format=\"reference, { params }\"`\n * renders. `undefined` when no dictionary has it, reported as missing.\n */\n format( reference: string, params: Record<string, unknown>, lang?: string ){\n const\n as = lang || this.currentLang,\n mf = this.message( reference, as )\n\n if( mf ) return mf.format( params, error => this.onError?.( error, reference, as ) )\n mf === undefined && this.onMissing?.( reference, as )\n }\n\n /** The text of a translatable name a reader of `lang` reads, defaulting to the current language. */\n pick( name: TranslatableName, lang?: string ){ return pick( name, lang || this.currentLang ) }\n}\n",
14
+ "/**\n * Phase 2 — engine facade (RFC-001 §9)\n *\n * The old public Lips API backed by the IR engine, activated via\n * `new Lips({ engine: 'ir' })`. Templates are the same plain\n * objects ({ default, state, handler, _static, stylesheet, … });\n * behind the API: parse → IR → renderIR with deep-reactive state.\n *\n * Parity gaps this facade does not yet cover (tracked in ROADMAP):\n * router, i18n, macros, component contents/slots + events,\n * declaration-driven syntax components.\n */\n\nimport type { TemplateIR, CompileResult, CompileOptions } from './compiler'\n\n/**\n * The template compiler is INJECTED, not imported, so a\n * precompiled-only build can tree-shake the parser and compiler out\n * entirely (see src/runtime.ts vs src/lips.ts).\n */\ntype CompilerFn = ( src: string, options?: CompileOptions ) => CompileResult\nlet COMPILER: CompilerFn | null = null\n\nexport function setCompiler( fn: CompilerFn ){ COMPILER = fn }\n\n/**\n * The style compiler is INJECTED for the same reason the template one is:\n * a static import would pull the CSS scanner (and Stylis behind it) into\n * the `./runtime` bundle, which exists precisely to ship neither.\n */\ntype StyleCompilerFn = ( src: string, options: StyleCompileOptions ) => StyleCompileResult\nlet STYLE_COMPILER: StyleCompilerFn | null = null\nexport function setStyleCompiler( fn: StyleCompilerFn ){ STYLE_COMPILER = fn }\n\n/**\n * The MessageFormat 2 engine is INJECTED too: `messageformat` is ~7.2 KB\n * gzipped, which `./runtime` should not ship to apps that never\n * translate. The full entry sets it; `LipsConfig.messageFormat` passes\n * it to a `./runtime` app that does.\n */\nlet MESSAGE_FORMAT: MessageFormatEngine | undefined\nexport function setMessageFormat( engine: MessageFormatEngine ){ MESSAGE_FORMAT = engine }\n\n/**\n * Built-in components (e.g. `<router>`) are INJECTED by the full\n * entry rather than imported here, so the precompiled-only\n * `./runtime` build — which can't compile their source templates\n * anyway — tree-shakes them out.\n */\nconst BUILTINS: Record<string, any> = {}\nexport function registerBuiltin( name: string, template: any ){ BUILTINS[ name ] = template }\n\nimport type { IRComponentDef, IRInstance, RuntimeOptions } from './runtime'\nimport type { Untrusted } from './policy'\nimport { renderIR } from './runtime'\nimport { reactive, effect, signal } from './signal'\nimport Events from '../events'\nimport Stylesheet from '../stylesheet'\nimport type { StyleIR, StyleCompileResult, StyleCompileOptions } from './style'\nimport type { Template, Metavars, LipsConfig, Handler, MessageFormatEngine } from '../types'\nimport I18N from '../i18n'\n\n/**\n * The authoring shape IS the public `Template<MT>` — one type, not a\n * parallel internal one. `FacadeTemplate` remains as the erased form\n * used where the metavars are not known (caches, dynamic resolution).\n */\ntype FacadeTemplate = Template<any>\ntype FacadeConfig<Context extends Object = Record<string, any>> =\n LipsConfig<Context> & { mode?: 'compiled' | 'interpreted' }\n\n/**\n * Names template handlers must not override on the component\n * self — mirrors the old engine's reserved-member guard.\n */\nconst RESERVED_MEMBERS = new Set([\n 'state', 'input', 'static', 'context', 'emit', 'on', 'once', 'off',\n 'node', 'lang', 'setContext', 'setLanguage',\n 'destroy', 'appendTo', 'prependTo', 'replaceWith', 'render', 'swap'\n])\n\nfunction guardHandlers( handler?: Handler<any> ){\n if( !handler ) return undefined\n\n for( const name of Object.keys( handler ) )\n if( RESERVED_MEMBERS.has( name ) )\n throw new Error(`Handler <${name}> is a reserved component member name`)\n\n return handler as Record<string, ( this: any, ...args: any[] ) => any>\n}\n\n// --------------------------------------------------------------- component\nexport class IRFacadeComponent<MT extends Metavars = Metavars> extends Events {\n readonly state: MT['State']\n private instance: IRInstance\n private contextWatcher?: () => void\n private destroyed = false\n\n constructor(\n private lips: IRLips<any>,\n name: string,\n private template: Template<MT>,\n input: MT['Input'] | undefined,\n ir: TemplateIR,\n options: RuntimeOptions\n ){\n super()\n const handlers = guardHandlers( template.handler )\n\n this.state = reactive( { ...( template.state || {} ) }, true )\n const inputR = input ? reactive( { ...input }, true ) : undefined\n\n /**\n * The runtime owns the whole lifecycle (create → input →\n * render → mount → attach → destroy) for root and nested\n * components alike — the facade only supplies wiring.\n */\n /**\n * The OUTWARD half only. Deliberately `super.emit`, not `this.emit`:\n * `this.emit` now also drives the inward half, so routing through it\n * would deliver every internal emission to the local bus twice.\n */\n const emitExternal = ( event: string, ...args: any[] ) => super.emit( event, ...args )\n\n this.instance = renderIR( ir, {\n state: this.state,\n input: inputR,\n context: lips.getContext(),\n static: template.static ?? template._static,\n handlers,\n deep: true,\n // Compiled stylesheet — the runtime stamps `rel`, injects, and binds\n stylesheet: lips.styleFor( name, template ),\n nsp: name,\n expose: {\n /**\n * Component emissions reach BOTH buses: the facade's Events\n * (external `component.on(…)`) and the runtime's own bus\n * (`self.on(…)` inside handlers/controls). `emitLocal` is\n * installed by the runtime before expose is merged.\n */\n emit( this: any, event: string, ...args: any[] ){\n this.emitLocal?.( event, ...args )\n emitExternal( event, ...args )\n },\n context: lips.getContext()\n }\n }, options )\n\n /**\n * Context subscription: components declaring `context: [...]`\n * get onContext whenever a declared field changes.\n */\n const watched = template.watchContext ?? template.context\n if( watched?.length && typeof handlers?.onContext === 'function' )\n this.contextWatcher = lips.watchContext( watched, () => {\n try { handlers.onContext!.call( this.instance.self ) }\n catch( error ){ console.error('[lips:ir]', error ) }\n })\n\n this.emit('component:mount')\n }\n\n /**\n * The component bus is bidirectional.\n *\n * Outward has always worked: a handler's `this.emit('save')` reaches\n * `component.on('save')`. Inward is this override — `component.emit(\n * 'reset')` also reaches `this.on('reset')` registered inside the\n * component, so a holder of the handle can send a command without\n * mutating state or reaching into internals.\n *\n * Argument handling matches what an internal emit already does:\n * inward is raw (the caller owns the data), outward is deep-cleaned by\n * `Events` so reactive proxies never escape the component.\n */\n emit( event: string, ...args: any[] ){\n // instance is unset only while renderIR is still running (e.g. onCreate)\n this.instance?.self?.emitLocal?.( event, ...args )\n return super.emit( event, ...args )\n }\n\n /**\n * Live root ELEMENTS — matching `this.node` inside a handler. The\n * instance's node list also carries the block's range markers, which\n * are an internal detail no consumer should have to filter out.\n */\n get node(): Element[] {\n return this.instance.nodes.filter( n => n.nodeType === 1 ) as Element[]\n }\n\n appendTo( selector: string | Element ){\n const target = typeof selector === 'string' ? document.querySelector( selector ) : selector\n target && this.instance.mount( target as Element )\n return this\n }\n\n swap( newIR: TemplateIR ){ return this.instance.swap( newIR ) }\n\n destroy(){\n if( this.destroyed ) return\n this.destroyed = true\n\n this.contextWatcher?.()\n // dispose() runs onDetach/onDestroy and clears the scoped stylesheet\n this.instance.dispose()\n this.emit('component:destroy')\n }\n}\n\n// -------------------------------------------------------------------- lips\nexport class IRLips<Context extends Object = Record<string, any>> {\n public debug: boolean\n private store = new Map<string, FacadeTemplate>()\n private irCache = new WeakMap<FacadeTemplate, TemplateIR>()\n private defCache = new WeakMap<FacadeTemplate, IRComponentDef>()\n private styleCache = new WeakMap<FacadeTemplate, StyleIR>()\n private context: Context\n private __root?: IRFacadeComponent<any>\n /**\n * `new Lips({ untrusted: untrusted() })` — every template this instance\n * renders is held to it (RFC-007). Passed by value from\n * `@lipsjs/lips/untrusted`, so only an app that renders untrusted\n * templates ships the policy.\n */\n private u?: Untrusted\n\n public i18n: I18N\n /** Language signal — translated binds subscribe through it */\n private getLang: () => string\n private setLang: ( v: string ) => void\n /** Dictionary revision — bumped whenever a dictionary is registered */\n private getRev!: () => number\n\n /**\n * Registered components resolved lazily — the runtime looks\n * names up per render, so registration order doesn't matter.\n */\n private componentsProxy: Record<string, IRComponentDef>\n\n constructor( private config?: FacadeConfig<Context> ){\n this.u = config?.untrusted\n\n this.debug = !!config?.debug\n this.context = reactive( { ...( config?.context || {} ) }, true ) as Context\n\n this.i18n = new I18N( config?.lang, config?.messageFormat ?? MESSAGE_FORMAT )\n if( this.debug ){\n this.i18n.onMissing = ( key, lang ) => console.warn(`[lips:i18n] no <${lang}> entry for key \"${key}\"`)\n this.i18n.onError = ( error, key, lang ) => console.warn(`[lips:i18n] <${lang}> message \"${key}\" —`, error )\n }\n\n const [ getLang, setLang ] = signal( this.i18n.lang )\n this.getLang = getLang\n this.setLang = setLang\n\n /**\n * Dictionary revision. Translated binds track it alongside the\n * language, so a dictionary registered AFTER render — a lazy load\n * resolving, or a plain `setDictionary` call at runtime — re-runs\n * them. Without it the language signal alone would not fire: the\n * language never changed, only what it resolves to.\n */\n const [ getRev, setRev ] = signal( 0 )\n this.getRev = getRev\n this.i18n.onChange = () => setRev( getRev() + 1 )\n\n // Built-in components (their templates are source — need the compiler)\n COMPILER && Object.entries( BUILTINS ).forEach( ( [ name, template ] ) => this.register( name, template ) )\n\n const self = this\n this.componentsProxy = new Proxy( {} as Record<string, IRComponentDef>, {\n get( _, name: string ){\n const template = self.store.get( name )\n return template ? self.defFor( name, template ) : undefined\n },\n has( _, name: string ){ return self.store.has( name as string ) }\n })\n }\n\n // ---- registry\n register<MT extends Metavars = Metavars>( name: string, template: Template<MT> ){\n this.store.set( name, template )\n return this\n }\n unregister( name: string ){\n this.store.delete( name )\n return this\n }\n has( name: string ){ return this.store.has( name ) }\n\n private compile( template: FacadeTemplate ): TemplateIR {\n // Precompiled: nothing to parse\n if( template.ir ) return template.ir\n\n let ir = this.irCache.get( template )\n if( !ir ){\n if( !COMPILER )\n throw new Error(\n 'This build has no template compiler — templates must be precompiled to `ir` '\n + '(import from \"@lipsjs/lips\" instead of \"@lipsjs/lips/runtime\")' )\n\n const result = COMPILER( template.default || '', { macros: template.macros, check: this.u?.check })\n result.diagnostics.length\n && console.warn('[lips:ir] template diagnostics —', result.diagnostics )\n\n ir = result.ir\n this.irCache.set( template, ir )\n }\n return ir\n }\n /**\n * Compile `stylesheet` source to StyleIR, or take a precompiled `style`\n * as-is. Cached per template object like the template IR — the sheet is\n * per component type, so this runs once no matter how many instances.\n */\n styleFor( name: string, template: FacadeTemplate ): StyleIR | undefined {\n if( template.style ) return template.style\n if( !template.stylesheet ) return\n\n if( !STYLE_COMPILER ){\n console.warn(\n `[lips:ir] <${name}> stylesheet skipped — this build has no style compiler. `\n + 'Precompile it to StyleIR, or import \"@lipsjs/lips\" instead of \"@lipsjs/lips/runtime\".' )\n return\n }\n\n let style = this.styleCache.get( template )\n if( !style ){\n const result = ( this.u ? this.u.style( STYLE_COMPILER ) : STYLE_COMPILER )( template.stylesheet, {\n nsp: name,\n layer: this.config?.styleLayer,\n preprocess: this.config?.stylePreprocessor\n })\n result.diagnostics.length\n && console.warn('[lips:ir] style diagnostics —', result.diagnostics )\n\n style = result.ir\n this.styleCache.set( template, style )\n }\n return style\n }\n\n private defFor( name: string, template: FacadeTemplate ): IRComponentDef {\n let def = this.defCache.get( template )\n if( !def ){\n def = {\n ir: this.compile( template ),\n state: template.state,\n statics: template.static ?? template._static,\n context: template.watchContext ?? template.context,\n stylesheet: this.styleFor( name, template ),\n nsp: name,\n handlers: guardHandlers( template.handler ),\n deep: true\n }\n this.defCache.set( template, def )\n }\n return def\n }\n\n // ---- rendering\n render<MT extends Metavars = Metavars>( name: string, template: Template<MT>, input?: MT['Input'] ){\n const options: RuntimeOptions = {\n mode: this.config?.mode,\n components: this.componentsProxy,\n /**\n * Route pages (and any `<{templateObject}/>`) are plain\n * template objects — compile + cache them on demand.\n */\n resolveTemplate: ( value: any ) =>\n value && ( typeof value.default === 'string' || value.ir )\n ? this.defFor( value.name || 'dynamic', value as FacadeTemplate )\n : undefined,\n expose: {\n setContext: ( arg: any, value?: any ) => this.setContext( arg, value ),\n /**\n * `self.setLanguage('fr-FR')` — a switcher is UI, so it needs to\n * be reachable from a template's `on-click`, not just from the\n * Lips instance.\n */\n setLanguage: ( lang: string ) => this.setLanguage( lang )\n },\n /**\n * Scoped-stylesheet factory. Undefined in a build without a CSS\n * preprocessor (`./runtime`), so the runtime skips injection.\n */\n createStylesheet: ( nsp: string, css: string ) => {\n const sheet = new Stylesheet( nsp, { sheet: css })\n return { clear: () => sheet.clear() }\n },\n i18n: {\n /**\n * The language signal is read INSIDE the bind effect and handed\n * to i18n as the language to use. That read is what re-runs every\n * translated bind on setLanguage(), and passing the value on —\n * rather than letting i18n fall back to its own `currentLang` —\n * keeps what is rendered equal to what was tracked.\n *\n * `scoped` is the `<i18n lang=…>` override for this subtree. It\n * still tracks the global signal first: a scoped subtree whose\n * expression reads nothing else must not go stale, and tracking\n * one extra signal only costs a re-run that recomputes the same\n * string.\n */\n translate: ( text: string, key?: string, scoped?: string ) => {\n const global = this.getLang() // track unconditionally — see above\n this.getRev() // …and re-run when a dictionary lands\n return this.i18n.translate( text, scoped || global, key ).text\n },\n format: ( reference: string, params: any, scoped?: string ) => {\n const global = this.getLang()\n this.getRev()\n return this.i18n.format( reference, params, scoped || global ) ?? ''\n },\n lang: () => this.getLang()\n }\n }\n\n return new IRFacadeComponent( this, name, template, input, this.compile( template ), this.u ? this.u.runtime( options ) : options )\n }\n root<MT extends Metavars = Metavars>( template: Template<MT>, selector: string ){\n this.__root = this.render<MT>( '__ROOT__', template )\n this.__root.appendTo( selector )\n return this.__root\n }\n\n // ---- i18n\n /**\n * The only way to change language. Writing `lips.i18n.lang` directly\n * updates the dictionary lookup but not the signal, so nothing already\n * rendered re-translates.\n */\n setLanguage( lang: string ){\n this.i18n.lang = lang\n this.setLang( lang )\n /**\n * Switch first, resolve second. The UI changes language immediately\n * — showing source wording, which is real text rather than a blank —\n * and the loaded dictionary bumps the revision to re-translate. A\n * language already registered resolves synchronously and this is a\n * no-op.\n */\n this.i18n.load( lang )\n return this\n }\n getLanguage(){ return this.getLang() }\n useTranslator( support: string | string[], fn: ( lang: string ) => void ){\n let first = true\n const { dispose } = effect( () => {\n const lang = this.getLang()\n if( first ){ first = false; return }\n ;( support === '*' || ( Array.isArray( support ) && support.includes( lang ) ) ) && fn( lang )\n })\n return dispose\n }\n\n // ---- context\n /** Reactive store, indexed dynamically — Context only types the surface */\n private get ctx(){ return this.context as Record<string, any> }\n\n getContext(): Context { return this.context }\n setContext( arg: ( keyof Context & string ) | Partial<Context>, value?: any ){\n typeof arg === 'string'\n ? this.ctx[ arg ] = value\n : Object.entries( arg as object ).forEach( ( [ k, v ] ) => this.ctx[ k ] = v )\n }\n /**\n * Subscribe to a subset of context fields — the effect tracks\n * exactly those keys, so unrelated context writes don't fire it.\n * Returns an unsubscribe function.\n */\n watchContext( fields: ( keyof Context & string )[] | string[], fn: () => void ){\n let first = true\n const { dispose } = effect( () => {\n ;( fields as string[] ).forEach( f => this.ctx[ f ] ) // track\n first ? first = false : fn()\n })\n return dispose\n }\n useContext( fields: string[], fn: ( ctx: Partial<Context> ) => void ){\n return this.watchContext( fields, () =>\n fn( Object.fromEntries( fields.map( f => [ f, this.ctx[ f ] ] ) ) as Partial<Context> ) )\n }\n\n dispose(){\n this.__root?.destroy()\n }\n}\n",
15
+ "/**\n * Precompiled-only entry: the runtime WITHOUT the template parser\n * and compiler.\n *\n * import Lips from '@lipsjs/lips/runtime'\n *\n * Templates must carry precompiled `ir` (see `precompile()` or the\n * bundler plugin). Combined with `mode: 'interpreted'` this build\n * never constructs a Function, so it runs under a strict CSP.\n */\nimport { IRLips } from './ir/facade'\n\nexport * from './types'\nexport { renderIR } from './ir/runtime'\nexport { signal, effect, untrack, reactive } from './ir/signal'\nexport type { TemplateIR, IRInstance, RuntimeOptions, RenderSetup, SwapReport, Host } from './ir'\n\nexport default IRLips\n"
15
16
  ],
16
- "mappings": "AAkDA,IAAM,GAAS,CACb,MAAO,MAAO,MAAO,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,KACrE,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,KACpC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IACjE,IAAK,IAAK,IAAK,IAAK,GACtB,EAEA,SAAS,EAAQ,CAAE,EAAa,EAAyC,CACvE,IAAM,EAAkB,CAAC,EACrB,EAAI,EAEF,EAAY,CAAE,IAAe,aAAa,KAAM,CAAE,EAClD,EAAW,CAAE,IAAe,gBAAgB,KAAM,CAAE,EAE1D,MAAO,EAAI,EAAI,OAAQ,CACrB,IAAM,EAAI,EAAK,GAEf,GAAI,KAAK,KAAM,CAAE,EAAG,CAAE,IAAK,SAG3B,GAAI,QAAQ,KAAM,CAAE,GAAO,IAAM,KAAO,QAAQ,KAAM,EAAK,EAAI,EAAI,EAAK,CACtE,IAAM,EAAQ,EACd,MAAO,EAAI,EAAI,QAAU,QAAQ,KAAM,EAAK,EAAI,EAAI,IACpD,GAAI,EAAK,KAAQ,IAAK,CAAE,IAAK,MAAO,EAAI,EAAI,QAAU,QAAQ,KAAM,EAAK,EAAI,EAAI,IACjF,GAAI,EAAK,KAAQ,KAAO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