@lipsjs/lips 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -9
- package/dist/lips.js +917 -669
- package/dist/lips.js.map +15 -12
- package/dist/lips.min.js +12 -12
- package/dist/lips.min.js.map +15 -12
- package/dist/lynx-background.min.js +3 -0
- package/dist/lynx-background.min.js.map +13 -0
- package/dist/lynx-main.min.js +3 -0
- package/dist/lynx-main.min.js.map +11 -0
- package/dist/lynx-plugin.mjs +1487 -0
- package/dist/lynx.min.js +8 -8
- package/dist/lynx.min.js.map +12 -10
- package/dist/mf2.min.js.map +1 -1
- package/dist/parts.min.js +100 -0
- package/dist/parts.min.js.map +19 -0
- package/dist/precompile.min.js +15 -15
- package/dist/precompile.min.js.map +8 -7
- package/dist/runtime.min.js +4 -4
- package/dist/runtime.min.js.map +11 -9
- package/dist/stylis.min.js.map +1 -1
- package/dist/types/component.d.ts +32 -0
- package/dist/types/ir/compiler.d.ts +2 -4
- package/dist/types/ir/facade.d.ts +63 -12
- package/dist/types/ir/host.d.ts +9 -1
- package/dist/types/ir/initial.d.ts +16 -0
- package/dist/types/ir/router.d.ts +2 -0
- package/dist/types/ir/tags.d.ts +16 -0
- package/dist/types/lips.d.ts +7 -7
- package/dist/types/lynx/a11y.d.ts +1 -0
- package/dist/types/lynx/background.d.ts +52 -3
- package/dist/types/lynx/components.d.ts +28 -0
- package/dist/types/lynx/main.d.ts +9 -5
- package/dist/types/lynx/plugin.d.ts +8 -0
- package/dist/types/lynx/protocol.d.ts +55 -4
- package/dist/types/lynx/style.d.ts +7 -0
- package/dist/types/lynx/template.d.ts +6 -0
- package/dist/types/lynx.d.ts +1 -0
- package/dist/types/parts/combobox.d.ts +40 -0
- package/dist/types/parts/date.d.ts +75 -0
- package/dist/types/parts/dialog.d.ts +42 -0
- package/dist/types/parts/icon.d.ts +31 -0
- package/dist/types/parts/layer.d.ts +28 -0
- package/dist/types/parts/list.d.ts +45 -0
- package/dist/types/parts/menu.d.ts +44 -0
- package/dist/types/parts/popover.d.ts +81 -0
- package/dist/types/parts/reveal.d.ts +24 -0
- package/dist/types/parts/toast.d.ts +36 -0
- package/dist/types/parts.d.ts +24 -0
- package/dist/types/precompile.d.ts +8 -11
- package/dist/types/runtime.d.ts +1 -0
- package/dist/types/types.d.ts +188 -57
- package/dist/untrusted.min.js +4 -4
- package/dist/untrusted.min.js.map +7 -7
- package/package.json +24 -3
- package/dist/types/i18n/formatters.d.ts +0 -3
package/dist/lynx.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)this.lineStarts.push(r+1)}let e=0,
|
|
3
|
-
`,t:"\t",r:"\r",b:"\b",f:"\f",v:"\v","0":"\x00"};if(E==="u"){let
|
|
4
|
-
`)this.lineStarts.push(r+1)}let e=0,i=this.lineStarts.length-1;while(e<i){let r=e+i+1>>1;this.lineStarts[r]<=t?e=r:i=r-1}return{line:e+1,col:t-this.lineStarts[e]+1}}report(t,e,i,r,n=1,s){let{line:l,col:o}=this.locate(r);this.diagnostics.push({code:t,severity:e,message:i,hint:s,loc:{line:l,col:o,offset:r,length:n}})}expr(t,e){let i=this.exprIndex.get(t);if(i!==void 0)return i;let{diagnostics:r}=D(t);for(let s of r){let l=(e?.offset??0)+s.loc.offset;this.report(s.code,"error",s.message,l,s.loc.length)}let n=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,n),n}synth(t){let e=this.exprIndex.get(t);if(e!==void 0)return e;let i=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,i),i}concat(t){t.filter((i)=>typeof i!=="string").forEach((i)=>{let{diagnostics:r}=D(i.expr);for(let n of r)this.report(n.code,"error",n.message,i.loc.offset+n.loc.offset,n.loc.length)});let e=t.map((i)=>typeof i==="string"?JSON.stringify(i):`((${i.expr})??"")`).join("+");return this.synth(e)}compInput(t){switch(t.k){case"literal":return{lit:t.value};case"bool":return{lit:t.value};case"expr":return{e:this.expr(t.source,t.loc)};case"interp":return{e:this.concat(t.parts)}}}compile(t){return{v:1,exprs:this.exprs,root:this.block(t,[])}}block(t,e){let i={html:"",scope:[...e],binds:[],blocks:[]},r=[],n=this.tree,s=[],l=(o,a,c,u=!1,x)=>{let E=0,S=!1,y=()=>(r.push(Dt),n&&c.push(0),S=!1,[...a,E++]);for(let I=0;I<o.length;I++){let d=o[I];switch(d.t){case"text":{if(u){let b={t:"text",p:y(),e:this.synth(JSON.stringify(d.value)),i18n:1};if(x)b.ik=x;i.binds.push(b);break}if(r.push(Ut(d.value)),n&&(S?c[c.length-1]+=d.value:c.push(d.value)),!S)E++;S=!0;break}case"comment":{if(n)break;let b=d.value.replace(/--/g,"- -");r.push(`<!--${/^-?>/.test(b)?" "+b:b}-->`),S=!1,E++;break}case"interp":{let b={t:"text",p:y(),e:this.concat(d.parts)};if(u)b.i18n=1;if(u&&x)b.ik=x;i.binds.push(b);break}case"fragment":{o=[...o.slice(0,I),...d.children,...o.slice(I+1)],I--;break}case"element":{if(Mt.has(d.tag)){if(this.controlBlock(d,o,I,y(),i,e),d.tag==="if"){let b=I+1;while(b<o.length){let R=o[b];if(R.t==="element"&&(R.tag==="else-if"||R.tag==="else"))b++;else break}o=[...o.slice(0,I+1),...o.slice(b)]}break}if(qt.has(d.tag)){this.report("LIPS-C002","error",`<${d.tag}> is only valid inside its parent construct`,d.loc.offset,d.loc.length);break}if(d.tag==="#dynamic"){i.blocks.push(this.compLike(d,y(),e,"dynamic"));break}if(this.macros.has(d.tag)){let b=this.macroCall(d,y(),e);b&&i.blocks.push(b);break}if(!V.has(d.tag)){i.blocks.push(this.compLike(d,y(),e,"comp"));break}this.emitElement(d,a,E++,r,i,l,c),S=!1;break}}}};if(l(t,[],s),i.html=r.join(""),n)i.nodes=s;return i}emitElement(t,e,i,r,n,s,l){let o=[...e,i],a=`<${t.tag}`,c=[t.tag],u={},x=(p,m)=>{Object.prototype.hasOwnProperty.call(u,p)||(u[p]=m)};this.tree&&l.push(c);let E=t.attrs.filter((p)=>("name"in p)),S=E.some((p)=>p.name==="i18n"&&(p.k==="bool"&&p.value||p.k==="literal")),y=(p)=>S&&(p==="title"||p==="placeholder"),I=(p)=>{let m=E.find((L)=>L.name===p&&L.k==="literal");return m&&"value"in m&&m.value?String(m.value):void 0},d=I("i18n"),b=(p)=>I(`i18n-${p}`);!S&&E.some((p)=>p.name.startsWith("i18n-"))&&this.report("LIPS-C014","warning",`i18n-* key on <${t.tag}> without the 'i18n' marker — the attribute will not be translated`,t.loc.offset,t.loc.length);for(let p of t.attrs){if(this.tree&&"name"in p&&p.name==="@html"){this.report("LIPS-C021","error",`@html on <${t.tag}>: the 'tree' target has no HTML parser`,p.loc.offset,p.loc.length,"Write the markup in the template, or use @text");continue}if("name"in p&&p.name==="style"){let m=zt(p);if(m&&ot(m)){this.report("LIPS-C019","error",`style= on <${t.tag}> takes CSS text, not an object literal`,p.loc.offset,p.loc.length,'Write the declarations as CSS — style="border: 2px solid gray; margin: 3rem" — '+`and interpolate values into it where they vary: style="margin: {state.gap}rem". Styles that need pseudo-classes, media queries or keyframes belong in the component's stylesheet.`);continue}}if(this.quotedEvent(t.tag,p))continue;switch(p.k){case"literal":if(p.name==="@format"){n.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){n.binds.push({t:"prop",p:o,name:p.name.slice(1),e:this.synth(JSON.stringify(p.value))});break}if(p.name==="i18n"||p.name.startsWith("i18n-"))break;if(y(p.name)){let m={t:"attr",p:o,name:p.name,e:this.synth(JSON.stringify(p.value)),i18n:1},L=b(p.name);if(L)m.ik=L;n.binds.push(m);break}a+=` ${p.name}="${Vt(p.value)}"`,x(p.name,p.value);break;case"bool":if(p.name!=="i18n"&&p.value)a+=` ${p.name}`,x(p.name,"");break;case"expr":{if(p.name==="@format"){n.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){n.binds.push({t:"prop",p:o,name:p.name.slice(1),e:this.expr(p.source,p.loc)});break}let m={t:"attr",p:o,name:p.name,e:this.expr(p.source,p.loc)};if(y(p.name)){m.i18n=1;let L=b(p.name);if(L)m.ik=L}n.binds.push(m);break}case"interp":{if(p.name==="@format"){n.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){n.binds.push({t:"prop",p:o,name:p.name.slice(1),e:this.concat(p.parts)});break}let m={t:"attr",p:o,name:p.name,e:this.concat(p.parts)};if(y(p.name)){m.i18n=1;let L=b(p.name);if(L)m.ik=L}n.binds.push(m);break}case"event":n.binds.push({t:"event",p:o,name:p.name,e:this.synth(p.source)});break;case"spread":n.binds.push({t:"spread",p:o,e:this.expr(p.source,p.loc)});break;case"fn":this.report("LIPS-C007","warning",`Callable attribute '${p.name}(…)' has no meaning on <${t.tag}>`,p.loc.offset,p.loc.length);break;case"args":this.report("LIPS-C008","warning",`Iterator arguments are not applicable to <${t.tag}>`,p.loc.offset,p.loc.length);break}}if(Object.keys(u).length&&(c[1]=u),Wt.has(t.tag)){r.push(a+">");return}r.push(a+">");let N=d,q=t.children.filter((p)=>p.t==="text"||p.t==="interp");if(N&&(q.length>1||q.some((p)=>p.t==="interp")))this.report("LIPS-C015","error",`<${t.tag} i18n="${N}"> keys text that is not a single fixed string. Use @format="${N}, { … }" for interpolated text.`,t.loc.offset,t.loc.length),N=void 0;let f=[];if(t.children.length&&s(t.children,o,f,S,N),f.length)c[1]=u,c[2]=f;r.push(`</${t.tag}>`)}formatBind(t,e){let i=e.k==="literal"?e.value:e.k==="expr"?e.source:e.parts.map((l)=>typeof l==="string"?l:`{${l.expr}}`).join(""),r=i.indexOf(",");if(r===-1)return this.report("LIPS-C012","error",'@format expects "reference, { params }"',e.loc.offset,e.loc.length),{t:"prop",p:t,name:"format",e:this.synth("({})"),ref:i.trim()};let n=i.slice(0,r).trim(),s=i.slice(r+1).trim();return{t:"prop",p:t,name:"format",e:this.expr(s,e.loc),ref:n}}attrsOf(t){let e=new Map,i=[];for(let r of t.attrs)if(r.k==="args")i.push(...r.names);else if("name"in r)e.set(r.name,r);return{byName:e,args:i}}controlBlock(t,e,i,r,n,s){switch(t.tag){case"if":{let l=[{when:t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),block:this.block(t.children,s)}];for(let o=i+1;o<e.length;o++){let a=e[o];if(a.t!=="element")break;if(a.tag==="else-if")l.push({when:a.head?this.expr(a.head.expr,a.head.loc):this.missingHead(a),block:this.block(a.children,s)});else if(a.tag==="else"){l.push({when:null,block:this.block(a.children,s)});break}else break}n.blocks.push({t:"if",p:r,branches:l});break}case"else-if":case"else":this.report("LIPS-C001","error",`<${t.tag}> without a preceding <if>`,t.loc.offset,t.loc.length);break;case"for":{let{byName:l,args:o}=this.attrsOf(t),a=l.get("in"),c=l.get("from"),u=l.get("to"),x=l.get("by");if(!a&&!c){this.report("LIPS-C004","error","<for> requires 'in' or 'from'/'to'",t.loc.offset,t.loc.length);break}let E={t:"for",p:r,args:o,block:this.block(t.children,[...s,...o])};if(a&&a.k==="expr")E.of=this.expr(a.source,a.loc);if(c)E.from=this.numInput(c);if(u)E.to=this.numInput(u);if(x&&(x.k==="literal"||x.k==="expr"))E.by=x.k==="literal"?{lit:x.value}:{e:this.expr(x.source,x.loc)};n.blocks.push(E);break}case"switch":{let l=t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),o=[];for(let a of t.children){if(a.t!=="element")continue;if(a.tag==="case"){let{byName:c}=this.attrsOf(a),u=c.get("is");if(!u||u.k!=="literal"&&u.k!=="expr"){this.report("LIPS-C004","error","<case> requires an 'is' attribute",a.loc.offset,a.loc.length);continue}o.push({is:u.k==="literal"?{lit:u.value}:{e:this.expr(u.source,u.loc)},block:this.block(a.children,s)})}else if(a.tag==="default")o.push({is:null,block:this.block(a.children,s)});else this.report("LIPS-C003","error","Only <case>/<default> are valid inside <switch>",a.loc.offset,a.loc.length)}n.blocks.push({t:"switch",p:r,on:l,cases:o});break}case"async":{let l=t.attrs.find((a)=>a.k==="fn"&&a.name==="await");if(!l){this.report("LIPS-C004","error","<async> requires await(…)",t.loc.offset,t.loc.length);break}let o={t:"async",p:r,awaitE:this.expr(l.source,l.loc)};for(let a of t.children){if(a.t!=="element")continue;let{args:c}=this.attrsOf(a);if(a.tag==="then")o.then={args:c,block:this.block(a.children,[...s,...c])};else if(a.tag==="catch")o.catch={args:c,block:this.block(a.children,[...s,...c])};else if(a.tag==="loading")o.loading=this.block(a.children,s);else this.report("LIPS-C003","error","Only <then>/<catch>/<loading> are valid inside <async>",a.loc.offset,a.loc.length)}n.blocks.push(o);break}case"let":case"const":{let l={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C013","error",`Spread is not supported on <${t.tag}> — scope names must be known at compile time`,o.loc.offset,o.loc.length,`Assign it to one variable: <${t.tag} obj={ ${o.source} }/> and read obj.<key>`);continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")l[o.name]=this.compInput(o),!n.scope.includes(o.name)&&n.scope.push(o.name),!s.includes(o.name)&&s.push(o.name)}n.blocks.push({t:"let",p:r,const:t.tag==="const",vars:l});break}case"log":n.blocks.push({t:"log",p:r,e:t.head?this.synth(t.head.expr):this.missingHead(t)});break;case"context":{let l={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C016","error","Spread is not supported on <context> — provided keys must be known at compile time",o.loc.offset,o.loc.length,"Provide them one by one: <context a=obj.a b=obj.b>");continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")l[o.name]=this.compInput(o)}if(!Object.keys(l).length)this.report("LIPS-C017","warning","<context> provides nothing — it renders its children unchanged",t.loc.offset,t.loc.length);n.blocks.push({t:"provide",p:r,vars:l,block:this.block(t.children,s)});break}case"i18n":{let{byName:l}=this.attrsOf(t),o=l.get("lang");if(!o){this.report("LIPS-C018","error","<i18n> requires a 'lang' attribute: <i18n lang=state.docLang>",t.loc.offset,t.loc.length);break}n.blocks.push({t:"provide",p:r,vars:{},lang:this.compInput(o),block:this.block(t.children,s)});break}}}missingHead(t){return this.report("LIPS-C004","error",`<${t.tag}> requires a head expression: <${t.tag}( … )>`,t.loc.offset,t.loc.length),this.synth("undefined")}numInput(t){if(t.k==="literal")return{lit:st(t.value)?Number(t.value):t.value};if(t.k==="expr")return st(t.source)?{lit:Number(t.source)}:{e:this.expr(t.source,t.loc)};return{lit:void 0}}macroCall(t,e,i){let r=this.macros.get(t.tag);if(this.macroStack.includes(r.name))return this.report("LIPS-C009","error",`Recursive macro <${r.name}> (${[...this.macroStack,r.name].join(" → ")})`,t.loc.offset,t.loc.length),null;let n=[];for(let l of t.attrs)if(l.k==="literal"||l.k==="expr"||l.k==="interp"||l.k==="bool")n.push({name:l.name,ci:this.compInput(l)});else if(l.k==="spread")n.push({spread:this.expr(l.source,l.loc)});this.macroStack.push(r.name);let s=this.block(r.children,[...i,...r.argv]);return this.macroStack.pop(),{t:"macro",p:e,name:r.name,sets:n,args:r.argv,block:s}}quotedEvent(t,e){if(!("name"in e)||!e.name.startsWith("on-"))return!1;return this.report("LIPS-C020","error",`${e.name}="…" on <${t}> wires no listener`,e.loc.offset,e.loc.length,`Handlers use the instruction form: ${e.name}( … ). `+"Quoted, it is an ordinary attribute — the handler never runs and the source is emitted into the DOM."),!0}compLike(t,e,i,r){let n={},s=[],l=[],o=[];for(let c of t.attrs){if(c.k!=="event"&&this.quotedEvent(t.tag,c))continue;switch(c.k){case"literal":case"bool":case"expr":case"interp":n[c.name]=this.compInput(c);break;case"event":l.push({name:c.name,e:this.synth(c.source)});break;case"spread":s.push(this.expr(c.source,c.loc));break;case"args":o=[...o,...c.names];break;case"fn":n[c.name]={e:this.expr(c.source,c.loc)};break}}let a=t.children.length?{args:o,block:this.block(t.children,[...i,...o])}:void 0;return r==="comp"?{t:"comp",p:e,name:t.tag,inputs:n,spreads:s,events:l,contents:a}:{t:"dynamic",p:e,tag:this.expr(t.dynamicTag.expr,t.dynamicTag.loc),inputs:n,spreads:s,events:l,contents:a}}}function Gt(t,e,i){let r=new Map;if(!t?.trim())return r;let n=H(t);e.push(...n.diagnostics),i?.(n.root.children,e,t);for(let s of n.root.children){if(s.t!=="element")continue;if(s.tag!=="macro"){e.push({code:"LIPS-C010",severity:"warning",message:`Only <macro> definitions are allowed in the macros source — ignoring <${s.tag}>`,loc:{line:1,col:1,offset:s.loc.offset,length:s.loc.length}});continue}let l="",o=[];for(let a of s.attrs)if(a.k==="args")o.push(...a.names);else if(a.k==="literal"&&a.name==="name")l=a.value;if(!l){e.push({code:"LIPS-C011",severity:"error",message:"<macro> requires a name attribute",loc:{line:1,col:1,offset:s.loc.offset,length:s.loc.length}});continue}r.set(l.toLowerCase(),{name:l,argv:o,children:s.children})}return r}function lt(t,e){let i=[],r=Gt(e?.macros||"",i,e?.check),n=H(t);e?.check?.(n.root.children,i,t),e?.transform?.(n.root.children,i);let s=new at(t,r,e?.target==="tree");return{ir:s.compile(n.root.children),diagnostics:[...i,...n.diagnostics,...s.diagnostics]}}var Ft=null;var Ht=/^[-\w]+$/,ft=/^(%|[a-zA-Z]+)/,ct=["<number>","0"];function z(t,e){let i=t[e];e++;while(e<t.length){if(t[e]==="\\"){e+=2;continue}if(t[e]===i)return e+1;e++}return e}function gt(t,e){let i=t.indexOf("*/",e+2);return i<0?t.length:i+2}function Yt(t,e){let i=t.indexOf(`
|
|
5
|
-
`,e+2);return
|
|
6
|
-
`)r++,n=s;return{line:r,col:e-n,offset:e,length:i}}function Y(t,e){let i=e+1,r=0,n=!1,s=!1;while(i<t.length){let o=t[i];if(o==='"'||o==="'"){i=z(t,i);continue}if(o==="{"||o===";")return null;if(o==="}")break;if(o==="("||o==="[")r++;else if(o===")"||o==="]")r--;else if(r===0){if(o==="?")n=!0;else if(o===":"&&!n)s=!0}i++}if(i>=t.length||s)return null;let l=t.slice(e+1,i).trim();return l?{end:i,expr:l}:null}var Xt=new Set(["state","input","static","context","self"]);function Kt(t,e,i,r){let n=[],s=e,l=e,o=0;while(s<t.length){let a=t[s];if(a==='"'||a==="'"){s=z(t,s);continue}if(a==="/"&&t[s+1]==="*"){let c=gt(t,s);if(!i)n.push(t.slice(l,s)," "),l=c;s=c;continue}if(a==="("){o++,s++;continue}if(a===")"){o--,s++;continue}if(o===0&&(a===";"||a==="}"))return n.push(t.slice(l,s)),{end:s,parts:n};if(a==="{"){let c=Y(t,s);if(!c)return t.indexOf("}",s+1)<0&&r?.(s),null;n.push(t.slice(l,s));let u=ft.exec(t.slice(c.end+1)),x=u?u[1]:"";n.push({expr:c.expr,unit:x,at:s}),s=c.end+1+x.length,l=s;continue}s++}return n.some((a)=>typeof a!=="string")&&r?.(e),null}var Jt=/^@(-\w+-)?(keyframes|font-face|property|counter-style|font-feature-values|font-palette-values|page|view-transition|position-try|color-profile|function)\b/i,pt=/^@(import|charset|namespace)\b/i,Qt=/^@(media|supports|container|layer|scope|starting-style|document)\b/i,te=/^([a-zA-Z_*\\]|[^\x00-\x7f])/,ee=/^(?:[-\w*|]|[^\x00-\x7f]|\\[\s\S])+/,re=/&[-_]/,mt=/\s/,ht=/[{};]/,ut=/[-\w]/,dt=/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/g,ie=new RegExp(`(${dt.source})|\\s+`,"g"),ne=/\/\*[\s\S]*?\*\//g,se=/^@layer\b/i,oe=(t)=>t.replace(ie,(e,i)=>i||" ");function ae(t){let e=[],i=0,r=0;for(let n=0;n<t.length;n++){let s=t[n];if(s==="\\"){n++;continue}if(s==='"'||s==="'"){n=z(t,n)-1;continue}if(s==="("||s==="[")r++;else if(s===")"||s==="]")r--;else if(s===","&&!r)e.push(t.slice(i,n)),i=n+1}return e.push(t.slice(i)),e.map((n)=>{let s=n.trimStart(),l=s.length;while(l&&mt.test(s[l-1])&&s[l-2]!=="\\")l--;if(s=s.slice(0,l),!te.test(s))return s;return s.includes("&")?s.replace(ee,":is($&)"):`& ${s}`}).join(",")}function le(t,e,i,r){let n=[],s=[],l=[],o=`--${e.nsp.replace(/[^a-zA-Z0-9_-]/g,"-")}`,a=(h,v,g,k,w)=>r.push({code:h,severity:"error",message:v,hint:w,loc:j(t,g,k)}),c=(h,v,g,k,w)=>r.push({code:h,severity:"warning",message:v,hint:w,loc:j(t,g,k)}),u=(h,v,g,k)=>e.lint?.(h,k)?.forEach((w)=>r.push({...w,loc:j(t,v,g-v)})),x=(h)=>{let v=n.indexOf(h);if(v<0)v=n.push(h)-1;return v},E=(h)=>{let{ast:v,diagnostics:g}=D(h.expr),k=h.expr.length+2;if(g.length){a("LIPS-S004",`Invalid expression: ${g[0].message}`,h.at,k);return}for(let w of nt(v))if(!Xt.has(w)&&!(w in globalThis))a("LIPS-S003",`'${w}' is not readable from a stylesheet`,h.at,k,"Stylesheets see state, input, static, context and self — not <for> iterators or <let> names, "+"which are local to a template position.");h.unit&&v.t==="lit"&&typeof v.v==="string"&&c("LIPS-S005",`Unit '${h.unit}' after a string value`,h.at,k,`A unit suffix multiplies a number: drop the unit, or return ${h.unit==="%"?"50":"8"} instead of a string.`)},S="",y="",I="",d=!1,b=(h)=>{if(!h)return;if(d&&I&&!ht.test(I)&&!ht.test(h[0]))y+=" ";d=!1,y+=h,I=h[h.length-1]},R=(h)=>{S+=y+h,y="",I=h,d=!1},N=()=>{let h=y;return y=I="",d=!1,h},q=(h)=>":"+(oe(h).trim()||" "),f=0,p=0,m=0,L="",B="",K="",J=!1,C=[{ctx:e.meta?"top":"style"}],Ct=()=>{let h=C[C.length-1],v=y,g;if(h.ctx==="opaque"||u(v,m,f),v[0]==="@")if(h.ctx!=="opaque"&&Jt.test(v))g={ctx:"opaque",hoist:S.length};else if(Qt.test(v))g={ctx:h.ctx,group:v,at:S.length};else g={ctx:"opaque"};else{if(h.ctx==="style"){if(i)re.test(v.replace(dt,""))&&c("LIPS-S008",`'${v}' joins '&' to a name`,m,f-m,"Native nesting cannot: write the full selector, or use stylisPreprocessor."),y=ae(v)}g={ctx:h.ctx==="opaque"?"opaque":"style"}}C.push(g),R("{"),g.group&&(g.body=S.length)},Q=()=>{let h=C.pop();if(h.group&&!y&&S.length===h.body&&!se.test(h.group)){S=S.slice(0,h.at),I="",d=!1;return}if(R("}"),h.hoist===void 0)return;let v=S.slice(h.hoist),g=C.filter((O)=>O.group),k=g.map((O)=>O.group).join("{"),w="}".repeat(g.length);S=S.slice(0,h.hoist),I="",B=k&&k===K?B.slice(0,B.length-w.length)+v+w:B+g.map((O)=>O.group+"{").join("")+v+w,K=k};while(f<t.length){let h=t[f];if(h==="\\"){b(t.slice(f,f+2)),f+=2;continue}let v=h==="/"&&!t.slice(m,f).trim();if(h==="/"&&(t[f+1]==="*"||t[f+1]==="/"&&v)){let g=t[f+1]==="/",k=g?Yt(t,f):gt(t,f);if(!g&&!i)y?b(t.slice(f,k)):S+=t.slice(f,k);else ut.test(I)&&ut.test(t[k]||"")&&(d=!0);v&&(m=k),f=k;continue}if(h==='"'||h==="'"){let g=z(t,f);b(t.slice(f,g)),f=g;continue}if(mt.test(h)){m===f&&m++,d=!0,f++;continue}if(h==="(")p++;else if(h===")")p--;if(h===":"&&p===0){let g=t.slice(m,f).replace(ne,"").trim();if(Ht.test(g)){let k=Kt(t,f+1,!i,(w)=>{J=!0,a("LIPS-S004","Unterminated interpolation",w,t.length-w,"Close the expression with `}`.")});if(k){let w=k.parts.filter((P)=>typeof P!=="string");for(let P of w)E(P);if(d=!1,g.startsWith("--")&&w.length===1&&!w[0].unit&&k.parts.every((P)=>typeof P!=="string"||!P.trim())){s.push({prop:g,e:x(w[0].expr)}),N(),f=k.end+(t[k.end]===";"?1:0),m=f;continue}let W="";for(let P of k.parts){if(typeof P==="string"){W+=P;continue}let tt=x(P.expr),_=`${o}-${tt}`;if(!s.some((F)=>F.prop===_)){if(s.push({prop:_,e:tt}),P.unit&&!l.some((F)=>F.name===_))l.push({name:_,syntax:ct[0],inherits:!0,initial:ct[1]})}W+=P.unit?`calc(var(${_}) * 1${P.unit})`:`var(${_})`}u(g,m,k.end,W),b(q(W)),f=k.end;continue}}}if(h==="{"){if(p>0){let g=Y(t,f);if(g){a("LIPS-S002","Interpolation in an at-rule condition",f,g.end-f+1,"Media and container conditions cannot read custom properties. Keep the condition static.");let k=ft.exec(t.slice(g.end+1));f=g.end+1+(k?k[1].length:0);continue}}if(!t.slice(m,f).trim()){let g=Y(t,f);if(g){a("LIPS-S001","Interpolation in a selector",f,g.end-f+1,"Selectors are static in Layer 1. Bind a value inside the rule instead."),f=g.end+1,m=f;continue}}Ct(),m=++f;continue}if(h==="}"){if(C.length>1)Q();else c("LIPS-S007","Unmatched `}` dropped",f,1),y&&R(";");m=++f;continue}if(h===";"){if(y[0]==="@"&&u(y,m,f),C.length===1&&pt.test(y))L+=N()+";";else R(";");m=++f;continue}b(h),f++}if(C.length>1){J||c("LIPS-S007","Unclosed `{` closed at the end",t.length,0);while(C.length>1)Q()}return pt.test(y)&&(L+=N()+";"),R(""),{css:S,statements:L,hoisted:B,exprs:n,binds:s,props:l}}function bt(t,e){let i=[],r=e.preprocess||Ft,{css:n,statements:s,hoisted:l,exprs:o,binds:a,props:c}=le(t,e,!r,i),u={v:1,nsp:e.nsp,css:"",exprs:[],binds:[]},x=e.meta||!n?n:`${e.scope||`[rel="${Zt(e.nsp)}"]`}{${n}}`,E=l+x,S=e.layer?`@layer ${e.layer}{${E}}`:E,y;try{y=r?r(S):S}catch(b){return i.push({code:"LIPS-S006",severity:"error",message:`Style compilation failed: ${b.message}`,loc:j(t,0,t.length)}),{ir:u,diagnostics:i}}let I=c.map((b)=>`@property ${b.name}{syntax:"${b.syntax}";inherits:${b.inherits};initial-value:${b.initial}}`).join(""),d={v:1,nsp:e.nsp,css:s+I+y,exprs:o,binds:a};if(c.length)d.props=c;return{ir:d,diagnostics:i}}var ce=["div","section","article","nav","header","footer","main","aside","ul","ol","li","button","form","figure","dialog","details","summary","address","blockquote","hgroup","fieldset","legend","menu","dl","dt","dd","figcaption"],pe=["span","p","h1","h2","h3","h4","h5","h6","label","b","strong","i","em","small","a","code","mark","s","u","sub","sup","time","abbr","cite","kbd","q","var","samp","dfn","del","ins","data","bdi","bdo"],M=Object.fromEntries([...ce.map((t)=>[t,"view"]),...pe.map((t)=>[t,"text"]),["img","image"]]),xt=(t)=>`lips-${t.replace(/[^\w-]/g,"-")}`;var yt={button:["button"],link:["link"],heading:["header"],img:["image"],image:["image"],checkbox:["button","checkbox"],switch:["button","switch"],radio:["button","radio"],tab:["button","tab"],option:["button"],menuitem:["button"],menuitemcheckbox:["button","checkbox"],menuitemradio:["button","radio"],searchbox:["search"],progressbar:["none","progressbar"]};var kt={status:"polite",log:"polite",alert:"assertive"},vt=new Set(["none","presentation"]);var he=[["aria-checked","checked","unchecked"],["aria-pressed","pressed"],["aria-selected","selected"],["aria-expanded","expanded","collapsed"],["aria-current","current"],["aria-disabled","disabled"],["aria-invalid","invalid"],["aria-required","required"]],St=new Set(["role","alt","for","tabindex","aria-label","aria-labelledby","aria-describedby","aria-hidden","aria-live","aria-modal","aria-roledescription","aria-valuetext","aria-valuenow",...he.map((t)=>t[0])]),Et=(t,e)=>t.role?.trim().split(/\s+/)[0]||e||"";var X=new Set(["if","else-if","else","for","switch","case","default","async","then","catch","loading","let","const","log","context","i18n"]),It=new Set(["view","scroll-view","list-item","swiper","swiper-item","overlay","refresh-view","viewpager"]),wt=new Set(["text","image","input","textarea","canvas","svg","audio"]),T="Lynx has no tables: lay rows out with <div>s, in flex or grid",ue={table:T,thead:T,tbody:T,tfoot:T,tr:T,td:T,th:T,caption:T,col:T,colgroup:T,select:"Lynx has no native picker element: a list of <div>s, or a picker component",option:"Lynx has no native picker element: a list of <div>s, or a picker component",br:"End the <p> and start another one",hr:"A <div> with a border",pre:"A <p> styled white-space: pre",iframe:"Lynx's <webview>"},Lt=(t)=>M[t]||t,fe=(t)=>Lt(t)==="text";function Z(t){for(let e of t){if(e.t==="text"||e.t==="interp")return e;let i=e.t==="fragment"||e.t==="element"&&X.has(e.tag)?Z(e.children):void 0;if(i)return i}}var Pt=(t)=>t.every((e)=>e.t==="fragment"||e.t==="element"&&X.has(e.tag)?Pt(e.children):e.t!=="element"||fe(e.tag));function*Rt(t){for(let e of t)e.t==="fragment"||e.t==="element"&&X.has(e.tag)?yield*Rt(e.children):e.t!=="comment"&&(yield e)}function Tt(t){return(e,i)=>{let r=(o,a,c,u,x)=>i.push({code:o,severity:a,message:c,hint:x,loc:j(t,u.loc.offset,u.loc.length)}),n=(o)=>{for(let a of o.attrs){if(!("name"in a))continue;let c=a.k==="literal"?a.value:void 0,u=c!==void 0&&Et({role:c});if(a.name==="role"&&u&&!yt[u]&&!kt[u]&&!vt.has(u))r("LIPS-L105","warning",`role="${u}" has no Lynx equivalent: its content stays readable, the ${u} is not announced`,a,"Say what each item is and its state on the item: aria-label, aria-selected, aria-checked");else if(a.name.startsWith("aria-")&&!St.has(a.name)&&!(a.name==="aria-atomic"&&c==="true"))r("LIPS-L106","warning",`${a.name} has no Lynx equivalent: it is not read`,a,a.name==="aria-atomic"||a.name==="aria-relevant"?"Lynx announces the whole region on every change":"Put what it says in the aria-label or a state Lynx reads");else if(a.name==="tabindex"&&c&&+c>0)r("LIPS-L107","warning","A positive tabindex orders focus: Lynx has no focus order, so it reads as 0",a,'Use tabindex="0", and order the elements in the template')}},s=(o)=>{for(let a of o){if(a.t==="fragment")s(a.children);if(a.t!=="element")continue;let c=a.tag;if((V.has(c)||wt.has(c)||It.has(c)||c==="list")&&n(a),V.has(c)&&!M[c]&&!wt.has(c))r("LIPS-L101","error",`<${c}> has no Lynx element: it would render nothing`,a,ue[c]||"Use a tag Lynx renders: <div>, <p>, <span>, <img>, <input> or a Lynx element");else if(c==="list")for(let u of Rt(a.children))u.t==="element"&&u.tag==="list-item"||r("LIPS-L104","error","A <list> holds <list-item>s: Lynx renders nothing else in one",u,"Put each row in a <list-item>");else if(Lt(c)==="view"||It.has(c)){let u=Z(a.children);if(u&&Pt(a.children)){let x=a.attrs.filter((E)=>("name"in E)&&E.name==="i18n");a.children=[{t:"element",tag:"text",attrs:x,children:a.children,selfClosed:!1,loc:a.loc}]}else u&&r("LIPS-L102","error",`Text beside block content in <${c}>: Lynx renders text only inside a text element`,u,"Wrap the text in a <span> or a <p>")}s(a.children)}},l=Z(e);l&&r("LIPS-L103","warning","Text at the top level of a template renders only when the template is placed inside a text element",l,"Put it in a <p> or a <span>"),s(e)}}var ge=(t,e)=>lt(t,{...e,target:"tree",transform:Tt(t)});var me={enableCSSInlineVariables:!0,enableCSSRule:!0,enableCSSInheritance:!0};function de(t,e){let{ir:i,diagnostics:r}=bt(t,{nsp:e.nsp,meta:e.meta,preprocess:e.preprocess,scope:`.${xt(e.nsp)}`,lint:Le});return{ir:xe(i),diagnostics:r}}var $t=/calc\(var\((--[\w-]+?-(\d+))\)\s*\*\s*1(%|[a-zA-Z]+)\)/g,be=/@property\s[^{]+\{[^}]*\}/g;function xe(t){let e=`--${t.nsp.replace(/[^a-zA-Z0-9_-]/g,"-")}-`,i=[...t.binds],r=t.css.replace(be,"").replace($t,(s,l,o,a)=>{if(!l.startsWith(e)||l.length!==e.length+o.length)return s;let c=`${l}-${a==="%"?"pct":a}`;return i.some((u)=>u.prop===c)||i.push({prop:c,e:+o,u:a}),`var(${c})`}),n={...t,css:r,binds:i.filter((s)=>s.u||!s.prop.startsWith(e)||r.includes(`var(${s.prop})`))};return delete n.props,n}var A=(t,e,i)=>({code:t,severity:"error",message:e,hint:i}),G=(t,e,i)=>({code:t,severity:"warning",message:e,hint:i}),ye=new Set(`
|
|
1
|
+
var Dt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Mt=new Set(["pre","textarea"]),rt=new Set(["if","else-if","switch","log"]),nt={__proto__:null,amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},Wt=/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|([A-Za-z][A-Za-z0-9]*));/g;function qt(t,e){return t.replace(Wt,(n,r,s,i,a)=>{if(i===void 0){let o=r!==void 0?parseInt(r,10):parseInt(s,16);return o>0&&o<=1114111?String.fromCodePoint(o):n}if(i in nt)return nt[i];return e?.(i,a),n})}class it{src;pos=0;lineStarts=null;diagnostics=[];constructor(t){this.src=t}locate(t){if(!this.lineStarts){this.lineStarts=[0];for(let r=0;r<this.src.length;r++)if(this.src[r]===`
|
|
2
|
+
`)this.lineStarts.push(r+1)}let e=0,n=this.lineStarts.length-1;while(e<n){let r=e+n+1>>1;this.lineStarts[r]<=t?e=r:n=r-1}return{line:e+1,col:t-this.lineStarts[e]+1}}report(t,e,n,r,s=1,i){let{line:a,col:o}=this.locate(r);this.diagnostics.push({code:t,severity:e,message:n,hint:i,loc:{line:a,col:o,offset:r,length:s}})}decode(t,e){return qt(t,(n,r)=>this.report("LIPS-P013","warning",`&${n}; is not decoded`,e+r,n.length+2,"Write the character, or its number: ©"))}eof(){return this.pos>=this.src.length}peek(t=0){return this.src[this.pos+t]}startsWith(t){return this.src.startsWith(t,this.pos)}skipSpace(){while(!this.eof()&&/\s/.test(this.src[this.pos]))this.pos++}scanBalanced(t,e){let n=this.pos,r=0;while(!this.eof()){let s=this.src[this.pos];if(s==="'"||s==='"'||s==="`"){this.pos++;while(!this.eof()&&this.src[this.pos]!==s){if(this.src[this.pos]==="\\")this.pos++;this.pos++}this.pos++;continue}if(r===0&&s===t){let i=this.src.slice(n,this.pos);return this.pos++,{content:i,loc:{offset:n,length:i.length}}}if(s==="("||s==="["||s==="{")r++;else if(s===")"||s==="]"||s==="}"){if(r===0&&s!==t){this.report(e,"error",`Unbalanced '${s}'`,this.pos),this.pos++;continue}r--}this.pos++}return this.report(e,"error",`Unterminated — expected '${t}'`,n,this.pos-n),null}parse(){let t=[];while(!this.eof())if(t.push(...this.parseNodes([])),this.startsWith("</")){let e=this.pos;this.pos+=2;while(!this.eof()&&this.peek()!==">")this.pos++;!this.eof()&&this.pos++,this.report("LIPS-P005","error",`Stray closing tag ${this.src.slice(e,this.pos)}`,e,this.pos-e)}return{root:{t:"fragment",children:t,loc:{offset:0,length:this.src.length}},diagnostics:this.diagnostics}}parseNodes(t){let e=[];while(!this.eof()){if(this.startsWith("</"))break;let n=this.pos;if(this.peek()==="<"&&this.peek(1)!==void 0){let r=this.parseTag(t);r&&e.push(r)}else{let r=this.parseText(t);r&&e.push(r)}if(this.pos===n)this.pos++}return e}parseText(t){let e=this.pos,n=[],r="";while(!this.eof()&&this.peek()!=="<"){if(this.peek()==="{"){this.pos++;let o=this.scanBalanced("}","LIPS-P007");if(o)r&&n.push(r),r="",n.push({expr:o.content.trim(),loc:o.loc});continue}r+=this.peek(),this.pos++}r&&n.push(r);let s={offset:e,length:this.pos-e};if(n.some((o)=>typeof o!=="string"))return{t:"interp",parts:n.map((o)=>typeof o==="string"?this.decode(o,e):o),loc:s};let i=n.length?n[0]:"",a=t.some((o)=>Mt.has(o));if(!i||!a&&!i.trim())return null;return{t:"text",value:this.decode(i,e),loc:s}}parseTag(t){let e=this.pos;if(this.startsWith("<!--")){let i=this.src.indexOf("-->",this.pos+4);if(i===-1)return this.report("LIPS-P003","error","Unterminated comment",e,this.src.length-e),this.pos=this.src.length,null;let a=this.src.slice(this.pos+4,i);return this.pos=i+3,{t:"comment",value:a,loc:{offset:e,length:this.pos-e}}}if(this.startsWith("<>")){this.pos+=2;let i=[];while(!0)if(i.push(...this.parseNodes([...t,"#fragment"])),this.closeStatus("#fragment",e,t)!=="stray")break;return{t:"fragment",children:i,loc:{offset:e,length:this.pos-e}}}if(this.startsWith("<{")){this.pos+=2;let i=this.scanBalanced("}","LIPS-P008");if(!i)return null;let a={t:"element",tag:"#dynamic",dynamicTag:{expr:i.content.trim(),loc:i.loc},attrs:[],children:[],selfClosed:!1,loc:{offset:e,length:0}};return this.finishTag(a,t,e),a}this.pos++;let n=this.pos;while(!this.eof()&&/[A-Za-z0-9_-]/.test(this.peek()))this.pos++;let r=this.src.slice(n,this.pos);if(!r||!/^[A-Za-z]/.test(r))return this.report("LIPS-P002","error","Invalid tag name",e,this.pos-e+1),{t:"text",value:"<",loc:{offset:e,length:1}};let s={t:"element",tag:r.toLowerCase(),attrs:[],children:[],selfClosed:!1,loc:{offset:e,length:0}};if(this.peek()==="(")if(rt.has(s.tag)){this.pos++;let i=this.scanBalanced(")","LIPS-P012");i&&(s.head={expr:i.content.trim(),loc:i.loc})}else this.report("LIPS-P011","error",`Head expression is not allowed on <${s.tag}>`,this.pos,1,`Only ${[...rt].map((i)=>`<${i}(…)>`).join(", ")} take a head`);return this.finishTag(s,t,e),s}finishTag(t,e,n){if(this.parseAttrs(t),t.selfClosed||Dt.has(t.tag)){t.selfClosed=!0,t.loc={offset:n,length:this.pos-n};return}let r=t.tag==="#dynamic"?"#dynamic":t.tag;t.children=[];while(!0)if(t.children.push(...this.parseNodes([...e,r])),this.closeStatus(r,n,e)!=="stray")break;t.loc={offset:n,length:this.pos-n}}closeStatus(t,e,n){if(this.eof())return this.report("LIPS-P006","error",`Unclosed <${t==="#fragment"?"":t}> — reached end of template`,e,1,`Add </${t==="#fragment"||t==="#dynamic"?"":t}>`),"eof";if(!this.startsWith("</"))return"closed";let r=this.pos;if(this.pos+=2,this.peek()===">"){if(this.pos++,t!=="#fragment"&&t!=="#dynamic")this.report("LIPS-P004","warning",`Generic '</>' closes <${t}>`,r,3,`Prefer </${t}>`);return"closed"}let s=this.pos;while(!this.eof()&&/[A-Za-z0-9_-]/.test(this.peek()))this.pos++;let i=this.src.slice(s,this.pos).toLowerCase();if(this.skipSpace(),this.peek()===">"?this.pos++:this.report("LIPS-P001","error","Malformed closing tag",r,this.pos-r),i===t)return"closed";if(n.includes(i))return this.report("LIPS-P004","warning",`</${i}> auto-closes <${t}>`,r,this.pos-r,`Add the missing </${t}> before </${i}>`),this.pos=r,"ancestor";return this.report("LIPS-P005","error",`Stray closing tag </${i}> — <${t}> is open`,r,this.pos-r),"stray"}parseAttrs(t){while(!0){if(this.skipSpace(),this.eof()){this.report("LIPS-P001","error","Unexpected end of template inside tag",t.loc.offset);return}if(this.startsWith("/>")){this.pos+=2,t.selfClosed=!0;return}if(this.peek()===">"){this.pos++;return}let e=this.pos;if(this.startsWith("...")){this.pos+=3;let i=this.readUnquotedValue();t.attrs.push({k:"spread",source:i,loc:{offset:e,length:this.pos-e}});continue}if(this.peek()==="["){this.pos++;let i=this.scanBalanced("]","LIPS-P009");if(i){let a=i.content.split(",").map((o)=>o.trim()).filter(Boolean);t.attrs.push({k:"args",names:a,loc:{offset:e,length:this.pos-e}})}continue}let n=!1;if(this.peek()==="!")n=!0,this.pos++;let r=this.pos;while(!this.eof()&&/[^\s=/>()]/.test(this.peek()))this.pos++;let s=this.src.slice(r,this.pos);if(!s){this.report("LIPS-P009","error",`Invalid attribute syntax at '${this.peek()}'`,this.pos),this.pos++;continue}if(this.peek()==="("){this.pos++;let i=this.scanBalanced(")","LIPS-P010"),a=i?i.content.trim():"",o={offset:e,length:this.pos-e};s.startsWith("on-")?t.attrs.push({k:"event",name:s.slice(3),source:a,loc:o}):t.attrs.push({k:"fn",name:s,source:a,loc:o});continue}if(this.peek()==="="){this.pos++,this.parseAttrValue(t,s,e);continue}t.attrs.push({k:"bool",name:s,value:!n,loc:{offset:e,length:this.pos-e}})}}parseAttrValue(t,e,n){let r=this.peek();if(r==='"'||r==="'"){this.pos++;let i=this.pos,a=[],o="";while(!this.eof()&&this.peek()!==r){if(this.peek()==="{"){this.pos++;let l=this.scanBalanced("}","LIPS-P007");if(l)o&&a.push(o),o="",a.push({expr:l.content.trim(),loc:l.loc});continue}o+=this.peek(),this.pos++}o&&a.push(o),this.eof()?this.report("LIPS-P010","error",`Unterminated value for '${e}'`,i,this.pos-i):this.pos++;let c={offset:n,length:this.pos-n};a.some((l)=>typeof l!=="string")?t.attrs.push({k:"interp",name:e,parts:a.map((l)=>typeof l==="string"?this.decode(l,i):l),loc:c}):t.attrs.push({k:"literal",name:e,value:this.decode(a[0]??"",i),loc:c});return}if(r==="{"){this.pos++;let i=this.scanBalanced("}","LIPS-P007");t.attrs.push({k:"expr",name:e,source:i?i.content.trim():"",loc:{offset:n,length:this.pos-n}});return}let s=this.readUnquotedValue();s?t.attrs.push({k:"expr",name:e,source:s,loc:{offset:n,length:this.pos-n}}):this.report("LIPS-P010","error",`Missing value for attribute '${e}'`,n)}readUnquotedValue(){let t=this.pos,e=0;while(!this.eof()){let n=this.peek();if(n==="'"||n==='"'||n==="`"){this.pos++;while(!this.eof()&&this.peek()!==n){if(this.peek()==="\\")this.pos++;this.pos++}this.pos++;continue}if(e===0){if(/\s/.test(n)||n===">")break;if(n==="/"&&this.peek(1)===">")break}if(n==="("||n==="["||n==="{")e++;else if(n===")"||n==="]"||n==="}")e--;this.pos++}return this.src.slice(t,this.pos).trim()}}function H(t){return new it(t||"").parse()}var Ut=["===","!==","...","=>","==","!=","<=",">=","&&","||","??","?.","++","--","+=","-=","*=","/=","%=","+","-","*","/","%","<",">","!","?",":",".",",","(",")","[","]","{","}","="];function Gt(t,e){let n=[],r=0,s=(a)=>/[A-Za-z_$]/.test(a),i=(a)=>/[A-Za-z0-9_$]/.test(a);while(r<t.length){let a=t[r];if(/\s/.test(a)){r++;continue}if(/[0-9]/.test(a)||a==="."&&/[0-9]/.test(t[r+1])){let c=r;while(r<t.length&&/[0-9]/.test(t[r]))r++;if(t[r]==="."){r++;while(r<t.length&&/[0-9]/.test(t[r]))r++}if(t[r]==="e"||t[r]==="E"){if(r++,t[r]==="+"||t[r]==="-")r++;while(r<t.length&&/[0-9]/.test(t[r]))r++}n.push({t:"num",value:t.slice(c,r),start:c,end:r});continue}if(a==="'"||a==='"'){let c=r;r++;let l="",h=!1;while(r<t.length){let u=t[r];if(u==="\\"){let E=t[r+1],d={n:`
|
|
3
|
+
`,t:"\t",r:"\r",b:"\b",f:"\f",v:"\v","0":"\x00"};if(E==="u"){let k=t.slice(r+2,r+6);l+=String.fromCharCode(parseInt(k,16)||0),r+=6}else l+=d[E]??E,r+=2;continue}if(u===a){h=!0,r++;break}l+=u,r++}if(!h)e.push({code:"LIPS-E001",message:"Unterminated string literal",loc:{offset:c,length:r-c}});n.push({t:"str",value:l,start:c,end:r});continue}if(s(a)){let c=r;while(r<t.length&&i(t[r]))r++;n.push({t:"id",value:t.slice(c,r),start:c,end:r});continue}let o=Ut.find((c)=>t.startsWith(c,r));if(o==="?."&&/[0-9]/.test(t[r+2]??""))o="?";if(o){n.push({t:"punct",value:o,start:r,end:r+o.length}),r+=o.length;continue}e.push({code:"LIPS-E002",message:`Unexpected character '${a}'`,loc:{offset:r,length:1}}),r++}return n.push({t:"eof",value:"",start:t.length,end:t.length}),n}class st{tokens;diagnostics;pos=0;constructor(t,e){this.tokens=t;this.diagnostics=e}peek(t=0){return this.tokens[Math.min(this.pos+t,this.tokens.length-1)]}next(){return this.tokens[this.pos++]??this.tokens[this.tokens.length-1]}at(t){let e=this.peek();return e.t==="punct"&&e.value===t}eat(t){if(this.at(t))return this.pos++,!0;return!1}error(t,e,n=this.peek()){return this.diagnostics.push({code:t,message:e,loc:{offset:n.start,length:Math.max(1,n.end-n.start)}}),{t:"error"}}expect(t,e){if(!this.eat(t))this.error(e,`Expected '${t}'`)}parse(){let t=this.assign();if(this.peek().t!=="eof")this.error("LIPS-E003",`Unexpected token '${this.peek().value}' after expression`);return t}isArrowAhead(){let t=this.peek();if(t.t==="id"){let e=this.peek(1);return e.t==="punct"&&e.value==="=>"}if(t.t==="punct"&&t.value==="("){let e=0,n=0;while(!0){let r=this.peek(n);if(r.t==="eof")return!1;if(r.t==="punct"&&r.value==="(")e++;if(r.t==="punct"&&r.value===")"){if(e--,e===0){let s=this.peek(n+1);return s.t==="punct"&&s.value==="=>"}}n++}}return!1}assign(){if(this.isArrowAhead()){let n=[];if(this.peek().t==="id")n.push(this.next().value);else{this.expect("(","LIPS-E004");while(!this.at(")")&&this.peek().t!=="eof"){let r=this.next();if(r.t!=="id")return this.error("LIPS-E005","Invalid arrow parameter",r);if(n.push(r.value),!this.eat(","))break}this.expect(")","LIPS-E004")}return this.expect("=>","LIPS-E004"),{t:"arrow",params:n,body:this.assign()}}let t=this.conditional(),e=this.peek();if(e.t==="punct"&&["=","+=","-=","*=","/=","%="].includes(e.value)){if(t.t!=="id"&&t.t!=="member")return this.error("LIPS-E006","Invalid assignment target",e);return this.next(),{t:"assign",op:e.value,target:t,value:this.assign()}}return t}conditional(){let t=this.nullish();if(this.eat("?")){let e=this.assign();return this.expect(":","LIPS-E007"),{t:"cond",test:t,cons:e,alt:this.assign()}}return t}nullish(){let t=this.or();while(this.at("??"))this.next(),t={t:"logic",op:"??",l:t,r:this.or()};return t}or(){let t=this.and();while(this.at("||"))this.next(),t={t:"logic",op:"||",l:t,r:this.and()};return t}and(){let t=this.equality();while(this.at("&&"))this.next(),t={t:"logic",op:"&&",l:t,r:this.equality()};return t}equality(){let t=this.relational();while(["===","!==","==","!="].some((e)=>this.at(e)))t={t:"bin",op:this.next().value,l:t,r:this.relational()};return t}relational(){let t=this.additive();while(["<=",">=","<",">"].some((e)=>this.at(e)))t={t:"bin",op:this.next().value,l:t,r:this.additive()};return t}additive(){let t=this.multiplicative();while(this.at("+")||this.at("-"))t={t:"bin",op:this.next().value,l:t,r:this.multiplicative()};return t}multiplicative(){let t=this.unary();while(this.at("*")||this.at("/")||this.at("%"))t={t:"bin",op:this.next().value,l:t,r:this.unary()};return t}unary(){if(this.at("!")||this.at("-")||this.at("+"))return{t:"unary",op:this.next().value,arg:this.unary()};if(this.at("++")||this.at("--")){let t=this.next().value,e=this.unary();if(e.t!=="id"&&e.t!=="member")return this.error("LIPS-E006","Invalid update target");return{t:"update",op:t,arg:e,prefix:!0}}return this.postfix()}postfix(){let t=this.callMember();if(this.at("++")||this.at("--")){let e=this.next().value;if(t.t!=="id"&&t.t!=="member")return this.error("LIPS-E006","Invalid update target");t={t:"update",op:e,arg:t,prefix:!1}}return t}callMember(){let t=this.primary();while(!0)if(this.eat(".")){let e=this.next();if(e.t!=="id")return this.error("LIPS-E008","Expected property name",e);t={t:"member",obj:t,prop:e.value,computed:!1,optional:!1,at:e.start}}else if(this.eat("?."))if(this.at("("))t={t:"call",callee:t,args:this.argList(),optional:!0};else if(this.eat("[")){let e=this.peek().start,n=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:n,computed:!0,optional:!0,at:e}}else{let e=this.next();if(e.t!=="id")return this.error("LIPS-E008","Expected property name",e);t={t:"member",obj:t,prop:e.value,computed:!1,optional:!0,at:e.start}}else if(this.eat("[")){let e=this.peek().start,n=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:n,computed:!0,optional:!1,at:e}}else if(this.at("("))t={t:"call",callee:t,args:this.argList(),optional:!1};else break;return t}argList(){this.expect("(","LIPS-E010");let t=[];while(!this.at(")")&&this.peek().t!=="eof")if(t.push(this.assign()),!this.eat(","))break;return this.expect(")","LIPS-E010"),t}primary(){let t=this.peek();if(t.t==="num")return this.next(),{t:"lit",v:parseFloat(t.value)};if(t.t==="str")return this.next(),{t:"lit",v:t.value};if(t.t==="id")switch(this.next(),t.value){case"true":return{t:"lit",v:!0};case"false":return{t:"lit",v:!1};case"null":return{t:"lit",v:null};case"undefined":return{t:"lit",v:void 0};case"NaN":return{t:"lit",v:NaN};case"Infinity":return{t:"lit",v:1/0};default:return{t:"id",name:t.value,at:t.start}}if(this.eat("(")){let e=this.assign();return this.expect(")","LIPS-E010"),e}if(this.eat("[")){let e=[];while(!this.at("]")&&this.peek().t!=="eof"){let n=this.eat("...");if(e.push({spread:n||void 0,value:this.assign()}),!this.eat(","))break}return this.expect("]","LIPS-E009"),{t:"arr",items:e}}if(this.eat("{")){let e=[];while(!this.at("}")&&this.peek().t!=="eof"){if(this.eat("..."))e.push({spread:!0,value:this.assign()});else{let n=this.next();if(n.t!=="id"&&n.t!=="str"&&n.t!=="num")return this.error("LIPS-E011","Invalid object key",n);if(this.eat(":"))e.push({key:String(n.value),value:this.assign(),at:n.start});else if(n.t==="id")e.push({key:n.value,value:{t:"id",name:n.value,at:n.start},at:n.start});else return this.error("LIPS-E011","Invalid shorthand property",n)}if(!this.eat(","))break}return this.expect("}","LIPS-E011"),{t:"obj",props:e}}return this.next(),this.error("LIPS-E012",t.t==="eof"?"Unexpected end of expression":`Unexpected token '${t.value}'`,t)}}function M(t){let e=[],n=Gt(t,e);return{ast:new st(n,e).parse(),diagnostics:e}}function ot(t){let e=new Set,n=(r,s)=>{switch(r.t){case"id":!s.has(r.name)&&e.add(r.name);return;case"member":n(r.obj,s),typeof r.prop!=="string"&&n(r.prop,s);return;case"call":n(r.callee,s),r.args.forEach((i)=>n(i,s));return;case"unary":case"update":n(r.arg,s);return;case"bin":case"logic":n(r.l,s),n(r.r,s);return;case"cond":n(r.test,s),n(r.cons,s),n(r.alt,s);return;case"assign":n(r.target,s),n(r.value,s);return;case"arrow":n(r.body,new Set([...s,...r.params]));return;case"arr":r.items.forEach((i)=>n(i.value,s));return;case"obj":r.props.forEach((i)=>n(i.value,s));return}};return n(t,new Set),[...e]}var De=Symbol("lips.ended");var at=new Set(["if","else-if","else","for","switch","async","let","const","log","context","i18n"]),lt=new Set(["case","default","then","catch","loading"]),j=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","svg","circle","clippath","defs","ellipse","foreignobject","g","image","line","lineargradient","marker","mask","path","pattern","polygon","polyline","radialgradient","rect","stop","symbol","text","tspan","use"]);var Vt="<!--$-->",zt=new Set(["stop","capture","outside"]),Ft=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ht=(t)=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),Yt=(t)=>t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<"),ct=(t)=>t!==""&&!isNaN(Number(t)),pt=(t)=>{let e=t.trim(),n=0;for(let r=0;r<e.length;r++){let s=e[r];if(s==="'"||s==='"'||s==="`"){r++;while(r<e.length&&e[r]!==s){if(e[r]==="\\")r++;r++}continue}if(s==="("||s==="["||s==="{")n++;else if(s===")"||s==="]"||s==="}"){if(n--,n===0&&e[0]==="{"&&r===e.length-1)return pt(e.slice(1,-1))}else if(n===0){if(s==="?")return!1;if(s===":")return!0}}return!1},Zt=(t)=>{if(t.k==="expr")return t.source;if(t.k!=="interp")return"";let e=t.parts.filter((n)=>typeof n!=="string");return e.length===1&&t.parts.every((n)=>typeof n!=="string"||!n.trim())?e[0].expr:""};class ht{src;macros;tree;exprs=[];exprIndex=new Map;lineStarts=null;macroStack=[];diagnostics=[];constructor(t,e=new Map,n=!1){this.src=t;this.macros=e;this.tree=n}locate(t){if(!this.lineStarts){this.lineStarts=[0];for(let r=0;r<this.src.length;r++)if(this.src[r]===`
|
|
4
|
+
`)this.lineStarts.push(r+1)}let e=0,n=this.lineStarts.length-1;while(e<n){let r=e+n+1>>1;this.lineStarts[r]<=t?e=r:n=r-1}return{line:e+1,col:t-this.lineStarts[e]+1}}report(t,e,n,r,s=1,i){let{line:a,col:o}=this.locate(r);this.diagnostics.push({code:t,severity:e,message:n,hint:i,loc:{line:a,col:o,offset:r,length:s}})}expr(t,e){let n=this.exprIndex.get(t);if(n!==void 0)return n;let{diagnostics:r}=M(t);for(let i of r){let a=(e?.offset??0)+i.loc.offset;this.report(i.code,"error",i.message,a,i.loc.length)}let s=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,s),s}synth(t){let e=this.exprIndex.get(t);if(e!==void 0)return e;let n=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,n),n}concat(t){t.filter((n)=>typeof n!=="string").forEach((n)=>{let{diagnostics:r}=M(n.expr);for(let s of r)this.report(s.code,"error",s.message,n.loc.offset+s.loc.offset,s.loc.length)});let e=t.map((n)=>typeof n==="string"?JSON.stringify(n):`((${n.expr})??"")`).join("+");return this.synth(e)}compInput(t){switch(t.k){case"literal":return{lit:t.value};case"bool":return{lit:t.value};case"expr":return{e:this.expr(t.source,t.loc)};case"interp":return{e:this.concat(t.parts)}}}compile(t){return{v:1,exprs:this.exprs,root:this.block(t,[])}}block(t,e){let n={html:"",scope:[...e],binds:[],blocks:[]},r=[],s=this.tree,i=[],a=(o,c,l,h=!1,u)=>{let E=0,d=!1,k=()=>(r.push(Vt),s&&l.push(0),d=!1,[...c,E++]);for(let w=0;w<o.length;w++){let x=o[w];switch(x.t){case"text":{if(h){let y={t:"text",p:k(),e:this.synth(JSON.stringify(x.value)),i18n:1};if(u)y.ik=u;n.binds.push(y);break}if(r.push(Ht(x.value)),s&&(d?l[l.length-1]+=x.value:l.push(x.value)),!d)E++;d=!0;break}case"comment":{if(s)break;let y=x.value.replace(/--/g,"- -");r.push(`<!--${/^-?>/.test(y)?" "+y:y}-->`),d=!1,E++;break}case"interp":{let y={t:"text",p:k(),e:this.concat(x.parts)};if(h)y.i18n=1;if(h&&u)y.ik=u;n.binds.push(y);break}case"fragment":{o=[...o.slice(0,w),...x.children,...o.slice(w+1)],w--;break}case"element":{if(at.has(x.tag)){if(this.controlBlock(x,o,w,k(),n,e),x.tag==="if"){let y=w+1;while(y<o.length){let R=o[y];if(R.t==="element"&&(R.tag==="else-if"||R.tag==="else"))y++;else break}o=[...o.slice(0,w+1),...o.slice(y)]}break}if(lt.has(x.tag)){this.report("LIPS-C002","error",`<${x.tag}> is only valid inside its parent construct`,x.loc.offset,x.loc.length);break}if(x.tag==="#dynamic"){n.blocks.push(this.compLike(x,k(),e,"dynamic"));break}if(this.macros.has(x.tag)){let y=this.macroCall(x,k(),e);y&&n.blocks.push(y);break}if(!j.has(x.tag)){n.blocks.push(this.compLike(x,k(),e,"comp"));break}this.emitElement(x,c,E++,r,n,a,l),d=!1;break}}}};if(a(t,[],i),n.html=r.join(""),s)n.nodes=i;return n}emitElement(t,e,n,r,s,i,a){let o=[...e,n],c=`<${t.tag}`,l=[t.tag],h={},u=(p,b)=>{Object.prototype.hasOwnProperty.call(h,p)||(h[p]=b)};this.tree&&a.push(l);let E=t.attrs.filter((p)=>("name"in p)),d=E.some((p)=>p.name==="i18n"&&(p.k==="bool"&&p.value||p.k==="literal")),k=(p)=>d&&(p==="title"||p==="placeholder"),w=(p)=>{let b=E.find((L)=>L.name===p&&L.k==="literal");return b&&"value"in b&&b.value?String(b.value):void 0},x=w("i18n"),y=(p)=>w(`i18n-${p}`);!d&&E.some((p)=>p.name.startsWith("i18n-"))&&this.report("LIPS-C014","warning",`i18n-* key on <${t.tag}> without the 'i18n' marker — the attribute will not be translated`,t.loc.offset,t.loc.length);for(let p of t.attrs){if(this.tree&&"name"in p&&p.name==="@html"){this.report("LIPS-C021","error",`@html on <${t.tag}>: the 'tree' target has no HTML parser`,p.loc.offset,p.loc.length,"Write the markup in the template, or use @text");continue}if("name"in p&&p.name==="style"){let b=Zt(p);if(b&&pt(b)){this.report("LIPS-C019","error",`style= on <${t.tag}> takes CSS text, not an object literal`,p.loc.offset,p.loc.length,'Write the declarations as CSS — style="border: 2px solid gray; margin: 3rem" — '+`and interpolate values into it where they vary: style="margin: {state.gap}rem". Styles that need pseudo-classes, media queries or keyframes belong in the component's stylesheet.`);continue}}if(this.quotedEvent(t.tag,p))continue;switch(p.k){case"literal":if(p.name==="@format"){s.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){s.binds.push({t:"prop",p:o,name:p.name.slice(1),e:this.synth(JSON.stringify(p.value))});break}if(p.name==="i18n"||p.name.startsWith("i18n-"))break;if(k(p.name)){let b={t:"attr",p:o,name:p.name,e:this.synth(JSON.stringify(p.value)),i18n:1},L=y(p.name);if(L)b.ik=L;s.binds.push(b);break}c+=` ${p.name}="${Yt(p.value)}"`,u(p.name,p.value);break;case"bool":if(p.name!=="i18n"&&p.value)c+=` ${p.name}`,u(p.name,"");break;case"expr":{if(p.name==="@format"){s.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){s.binds.push({t:"prop",p:o,name:p.name.slice(1),e:this.expr(p.source,p.loc)});break}let b={t:"attr",p:o,name:p.name,e:this.expr(p.source,p.loc)};if(k(p.name)){b.i18n=1;let L=y(p.name);if(L)b.ik=L}s.binds.push(b);break}case"interp":{if(p.name==="@format"){s.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){s.binds.push({t:"prop",p:o,name:p.name.slice(1),e:this.concat(p.parts)});break}let b={t:"attr",p:o,name:p.name,e:this.concat(p.parts)};if(k(p.name)){b.i18n=1;let L=y(p.name);if(L)b.ik=L}s.binds.push(b);break}case"event":this.modifiers(p),s.binds.push({t:"event",p:o,name:p.name,e:this.synth(p.source)});break;case"spread":s.binds.push({t:"spread",p:o,e:this.expr(p.source,p.loc)});break;case"fn":this.report("LIPS-C007","warning",`Callable attribute '${p.name}(…)' has no meaning on <${t.tag}>`,p.loc.offset,p.loc.length);break;case"args":this.report("LIPS-C008","warning",`Iterator arguments are not applicable to <${t.tag}>`,p.loc.offset,p.loc.length);break}}if(Object.keys(h).length&&(l[1]=h),Ft.has(t.tag)){r.push(c+">");return}r.push(c+">");let N=x,q=t.children.filter((p)=>p.t==="text"||p.t==="interp");if(N&&(q.length>1||q.some((p)=>p.t==="interp")))this.report("LIPS-C015","error",`<${t.tag} i18n="${N}"> keys text that is not a single fixed string. Use @format="${N}, { … }" for interpolated text.`,t.loc.offset,t.loc.length),N=void 0;let g=[];if(t.children.length&&i(t.children,o,g,d,N),g.length)l[1]=h,l[2]=g;r.push(`</${t.tag}>`)}formatBind(t,e){let n=e.k==="literal"?e.value:e.k==="expr"?e.source:e.parts.map((a)=>typeof a==="string"?a:`{${a.expr}}`).join(""),r=n.indexOf(",");if(r===-1)return this.report("LIPS-C012","error",'@format expects "reference, { params }"',e.loc.offset,e.loc.length),{t:"prop",p:t,name:"format",e:this.synth("({})"),ref:n.trim()};let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();return{t:"prop",p:t,name:"format",e:this.expr(i,e.loc),ref:s}}attrsOf(t){let e=new Map,n=[];for(let r of t.attrs)if(r.k==="args")n.push(...r.names);else if("name"in r)e.set(r.name,r);return{byName:e,args:n}}controlBlock(t,e,n,r,s,i){switch(t.tag){case"if":{let a=[{when:t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),block:this.block(t.children,i)}];for(let o=n+1;o<e.length;o++){let c=e[o];if(c.t!=="element")break;if(c.tag==="else-if")a.push({when:c.head?this.expr(c.head.expr,c.head.loc):this.missingHead(c),block:this.block(c.children,i)});else if(c.tag==="else"){a.push({when:null,block:this.block(c.children,i)});break}else break}s.blocks.push({t:"if",p:r,branches:a});break}case"else-if":case"else":this.report("LIPS-C001","error",`<${t.tag}> without a preceding <if>`,t.loc.offset,t.loc.length);break;case"for":{let{byName:a,args:o}=this.attrsOf(t),c=a.get("in"),l=a.get("from"),h=a.get("to"),u=a.get("by");if(!c&&!l){this.report("LIPS-C004","error","<for> requires 'in' or 'from'/'to'",t.loc.offset,t.loc.length);break}let E={t:"for",p:r,args:o,block:this.block(t.children,[...i,...o])};if(c){let d=this.valueOf(c);d===void 0?this.report("LIPS-C004","error","<for in=…> takes an expression: in=state.items",c.loc.offset,c.loc.length):E.of=this.expr(d,c.loc)}if(l)E.from=this.numInput(l);if(h)E.to=this.numInput(h);if(u){let d=u.k==="literal"?void 0:this.valueOf(u);u.k==="literal"?E.by={lit:u.value}:d===void 0?this.report("LIPS-C004","error","<for by=…> takes a key path or an expression",u.loc.offset,u.loc.length):E.by={e:this.expr(d,u.loc)}}s.blocks.push(E);break}case"switch":{let a=t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),o=[];for(let c of t.children){if(c.t!=="element")continue;if(c.tag==="case"){let{byName:l}=this.attrsOf(c),h=l.get("is");if(!h||h.k!=="literal"&&h.k!=="expr"){this.report("LIPS-C004","error","<case> requires an 'is' attribute",c.loc.offset,c.loc.length);continue}o.push({is:h.k==="literal"?{lit:h.value}:{e:this.expr(h.source,h.loc)},block:this.block(c.children,i)})}else if(c.tag==="default")o.push({is:null,block:this.block(c.children,i)});else this.report("LIPS-C003","error","Only <case>/<default> are valid inside <switch>",c.loc.offset,c.loc.length)}s.blocks.push({t:"switch",p:r,on:a,cases:o});break}case"async":{let a=t.attrs.find((c)=>c.k==="fn"&&c.name==="await");if(!a){this.report("LIPS-C004","error","<async> requires await(…)",t.loc.offset,t.loc.length);break}let o={t:"async",p:r,awaitE:this.expr(a.source,a.loc)};for(let c of t.children){if(c.t!=="element")continue;let{args:l}=this.attrsOf(c);if(c.tag==="then")o.then={args:l,block:this.block(c.children,[...i,...l])};else if(c.tag==="catch")o.catch={args:l,block:this.block(c.children,[...i,...l])};else if(c.tag==="loading")o.loading=this.block(c.children,i);else this.report("LIPS-C003","error","Only <then>/<catch>/<loading> are valid inside <async>",c.loc.offset,c.loc.length)}s.blocks.push(o);break}case"let":case"const":{let a={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C013","error",`Spread is not supported on <${t.tag}> — scope names must be known at compile time`,o.loc.offset,o.loc.length,`Assign it to one variable: <${t.tag} obj={ ${o.source} }/> and read obj.<key>`);continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")a[o.name]=this.compInput(o),!s.scope.includes(o.name)&&s.scope.push(o.name),!i.includes(o.name)&&i.push(o.name)}s.blocks.push({t:"let",p:r,const:t.tag==="const",vars:a});break}case"log":s.blocks.push({t:"log",p:r,e:t.head?this.synth(t.head.expr):this.missingHead(t)});break;case"context":{let a={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C016","error","Spread is not supported on <context> — provided keys must be known at compile time",o.loc.offset,o.loc.length,"Provide them one by one: <context a=obj.a b=obj.b>");continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")a[o.name]=this.compInput(o)}if(!Object.keys(a).length)this.report("LIPS-C017","warning","<context> provides nothing — it renders its children unchanged",t.loc.offset,t.loc.length);s.blocks.push({t:"provide",p:r,vars:a,block:this.block(t.children,i)});break}case"i18n":{let{byName:a}=this.attrsOf(t),o=a.get("lang");if(!o){this.report("LIPS-C018","error","<i18n> requires a 'lang' attribute: <i18n lang=state.docLang>",t.loc.offset,t.loc.length);break}s.blocks.push({t:"provide",p:r,vars:{},lang:this.compInput(o),block:this.block(t.children,i)});break}}}missingHead(t){return this.report("LIPS-C004","error",`<${t.tag}> requires a head expression: <${t.tag}( … )>`,t.loc.offset,t.loc.length),this.synth("undefined")}numInput(t){if(t.k==="literal")return{lit:ct(t.value)?Number(t.value):t.value};let e=this.valueOf(t);if(e!==void 0)return ct(e)?{lit:Number(e)}:{e:this.expr(e,t.loc)};return"name"in t&&this.report("LIPS-C004","error",`<for ${t.name}=…> takes a number or an expression`,t.loc.offset,t.loc.length),{lit:void 0}}valueOf(t){if(t.k==="expr")return t.source;if(t.k==="interp"&&t.parts.length===1&&typeof t.parts[0]!=="string")return t.parts[0].expr}macroCall(t,e,n){let r=this.macros.get(t.tag);if(this.macroStack.includes(r.name))return this.report("LIPS-C009","error",`Recursive macro <${r.name}> (${[...this.macroStack,r.name].join(" → ")})`,t.loc.offset,t.loc.length),null;let s=[];for(let a of t.attrs)if(a.k==="literal"||a.k==="expr"||a.k==="interp"||a.k==="bool")s.push({name:a.name,ci:this.compInput(a)});else if(a.k==="spread")s.push({spread:this.expr(a.source,a.loc)});else if(a.k==="event")this.report("LIPS-C023","error",`on-${a.name}( … ) on the macro <${t.tag}> wires no listener`,a.loc.offset,a.loc.length,"Pass the handler as an argument (fn=self.pick) and wire it in the body");t.children.length&&this.report("LIPS-C024","error",`<${t.tag}> is a macro: what it encloses is not rendered`,t.loc.offset,t.loc.length,"A component takes content: <{input.renderer}/>"),this.macroStack.push(r.name);let i=this.block(r.children,[...n,...r.argv]);return this.macroStack.pop(),{t:"macro",p:e,name:r.name,sets:s,args:r.argv,block:i}}quotedEvent(t,e){if(!("name"in e)||!e.name.startsWith("on-"))return!1;return this.report("LIPS-C020","error",`${e.name}="…" on <${t}> wires no listener`,e.loc.offset,e.loc.length,`Handlers use the instruction form: ${e.name}( … ). `+"Quoted, it is an ordinary attribute — the handler never runs and the source is emitted into the DOM."),!0}modifiers(t,e){let n=t.name.split(".").slice(1),r=n.find((s)=>!zt.has(s));(r||e&&n[0])&&this.report("LIPS-C022",r?"error":"warning",r?`Unknown event modifier .${r}: use .stop, .capture or .outside`:`.${n[0]} does nothing on a component's event`,t.loc.offset,t.loc.length)}compLike(t,e,n,r){let s={},i=[],a=[],o=[];for(let l of t.attrs){if(l.k!=="event"&&this.quotedEvent(t.tag,l))continue;switch(l.k){case"literal":case"bool":case"expr":case"interp":if(l.name==="@format"&&l.k!=="bool"){let{ref:h,e:u}=this.formatBind(e,l);s[l.name]={lit:{ref:h,e:u}};break}s[l.name]=this.compInput(l);break;case"event":this.modifiers(l,r==="comp"),a.push({name:l.name,e:this.synth(l.source)});break;case"spread":i.push(this.expr(l.source,l.loc));break;case"args":o=[...o,...l.names];break;case"fn":s[l.name]={e:this.expr(l.source,l.loc)};break}}let c=t.children.length?{args:o,block:this.block(t.children,[...n,...o])}:void 0;return r==="comp"?{t:"comp",p:e,name:t.tag,inputs:s,spreads:i,events:a,contents:c}:{t:"dynamic",p:e,tag:this.expr(t.dynamicTag.expr,t.dynamicTag.loc),inputs:s,spreads:i,events:a,contents:c}}}function Kt(t,e,n){let r=new Map;if(!t?.trim())return r;let s=H(t);e.push(...s.diagnostics),n?.(s.root.children,e,t);for(let i of s.root.children){if(i.t!=="element")continue;if(i.tag!=="macro"){e.push({code:"LIPS-C010",severity:"warning",message:`Only <macro> definitions are allowed in the macros source — ignoring <${i.tag}>`,loc:{line:1,col:1,offset:i.loc.offset,length:i.loc.length}});continue}let a="",o=[];for(let c of i.attrs)if(c.k==="args")o.push(...c.names);else if(c.k==="literal"&&c.name==="name")a=c.value;if(!a){e.push({code:"LIPS-C011",severity:"error",message:"<macro> requires a name attribute",loc:{line:1,col:1,offset:i.loc.offset,length:i.loc.length}});continue}r.set(a.toLowerCase(),{name:a,argv:o,children:i.children})}return r}function ut(t,e){let n=[],r=Kt(e?.macros||"",n,e?.check),s=H(t);e?.check?.(s.root.children,n,t),e?.transform?.(s.root.children,n);let i=new ht(t,r,e?.target==="tree");return{ir:i.compile(s.root.children),diagnostics:[...n,...s.diagnostics,...i.diagnostics]}}var Xt=null;var Jt=/^[-\w]+$/,bt=/^(%|[a-zA-Z]+)/,ft=["<number>","0"];function G(t,e){let n=t[e];e++;while(e<t.length){if(t[e]==="\\"){e+=2;continue}if(t[e]===n)return e+1;e++}return e}function xt(t,e){let n=t.indexOf("*/",e+2);return n<0?t.length:n+2}function Qt(t,e){let n=t.indexOf(`
|
|
5
|
+
`,e+2);return n<0?t.length:n}var te=(t)=>t.replace(/["\\]/g,"\\$&");function B(t,e,n){let r=1,s=-1;for(let i=0;i<e;i++)if(t[i]===`
|
|
6
|
+
`)r++,s=i;return{line:r,col:e-s,offset:e,length:n}}function Y(t,e){let n=e+1,r=0,s=!1,i=!1;while(n<t.length){let o=t[n];if(o==='"'||o==="'"){n=G(t,n);continue}if(o==="{"||o===";")return null;if(o==="}")break;if(o==="("||o==="[")r++;else if(o===")"||o==="]")r--;else if(r===0){if(o==="?")s=!0;else if(o===":"&&!s)i=!0}n++}if(n>=t.length||i)return null;let a=t.slice(e+1,n).trim();return a?{end:n,expr:a}:null}var ee=new Set(["state","input","static","context","self"]);function re(t,e,n,r){let s=[],i=e,a=e,o=0;while(i<t.length){let c=t[i];if(c==='"'||c==="'"){i=G(t,i);continue}if(c==="/"&&t[i+1]==="*"){let l=xt(t,i);if(!n)s.push(t.slice(a,i)," "),a=l;i=l;continue}if(c==="("){o++,i++;continue}if(c===")"){o--,i++;continue}if(o===0&&(c===";"||c==="}"))return s.push(t.slice(a,i)),{end:i,parts:s};if(c==="{"){let l=Y(t,i);if(!l)return t.indexOf("}",i+1)<0&&r?.(i),null;s.push(t.slice(a,i));let h=bt.exec(t.slice(l.end+1)),u=h?h[1]:"";s.push({expr:l.expr,unit:u,at:i}),i=l.end+1+u.length,a=i;continue}i++}return s.some((c)=>typeof c!=="string")&&r?.(e),null}var ne=/^@(-\w+-)?(keyframes|font-face|property|counter-style|font-feature-values|font-palette-values|page|view-transition|position-try|color-profile|function)\b/i,gt=/^@(import|charset|namespace)\b/i,ie=/^@(media|supports|container|layer|scope|starting-style|document)\b/i,se=/^([a-zA-Z_*\\]|[^\x00-\x7f])/,oe=/^(?:[-\w*|]|[^\x00-\x7f]|\\[\s\S])+/,ae=/&[-_]/,yt=/\s/,mt=/[{};]/,dt=/[-\w]/,kt=/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/g,le=new RegExp(`(${kt.source})|\\s+`,"g"),ce=/\/\*[\s\S]*?\*\//g,pe=/^@layer\b/i,he=(t)=>t.replace(le,(e,n)=>n||" ");function ue(t){let e=[],n=0,r=0;for(let s=0;s<t.length;s++){let i=t[s];if(i==="\\"){s++;continue}if(i==='"'||i==="'"){s=G(t,s)-1;continue}if(i==="("||i==="[")r++;else if(i===")"||i==="]")r--;else if(i===","&&!r)e.push(t.slice(n,s)),n=s+1}return e.push(t.slice(n)),e.map((s)=>{let i=s.trimStart(),a=i.length;while(a&&yt.test(i[a-1])&&i[a-2]!=="\\")a--;if(i=i.slice(0,a),!se.test(i))return i;return i.includes("&")?i.replace(oe,":is($&)"):`& ${i}`}).join(",")}function fe(t,e,n,r){let s=[],i=[],a=[],o=`--${e.nsp.replace(/[^a-zA-Z0-9_-]/g,"-")}`,c=(f,S,m,v,I)=>r.push({code:f,severity:"error",message:S,hint:I,loc:B(t,m,v)}),l=(f,S,m,v,I)=>r.push({code:f,severity:"warning",message:S,hint:I,loc:B(t,m,v)}),h=(f,S,m,v)=>e.lint?.(f,v)?.forEach((I)=>r.push({...I,loc:B(t,S,m-S)})),u=(f)=>{let S=s.indexOf(f);if(S<0)S=s.push(f)-1;return S},E=(f)=>{let{ast:S,diagnostics:m}=M(f.expr),v=f.expr.length+2;if(m.length){c("LIPS-S004",`Invalid expression: ${m[0].message}`,f.at,v);return}for(let I of ot(S))if(!ee.has(I)&&!(I in globalThis))c("LIPS-S003",`'${I}' is not readable from a stylesheet`,f.at,v,"Stylesheets see state, input, static, context and self — not <for> iterators or <let> names, "+"which are local to a template position.");f.unit&&S.t==="lit"&&typeof S.v==="string"&&l("LIPS-S005",`Unit '${f.unit}' after a string value`,f.at,v,`A unit suffix multiplies a number: drop the unit, or return ${f.unit==="%"?"50":"8"} instead of a string.`)},d="",k="",w="",x=!1,y=(f)=>{if(!f)return;if(x&&w&&!mt.test(w)&&!mt.test(f[0]))k+=" ";x=!1,k+=f,w=f[f.length-1]},R=(f)=>{d+=k+f,k="",w=f,x=!1},N=()=>{let f=k;return k=w="",x=!1,f},q=(f)=>":"+(he(f).trim()||" "),g=0,p=0,b=0,L="",D="",J="",Q=!1,C=[{ctx:e.meta?"top":"style"}],Bt=()=>{let f=C[C.length-1],S=k,m;if(f.ctx==="opaque"||h(S,b,g),S[0]==="@")if(f.ctx!=="opaque"&&ne.test(S))m={ctx:"opaque",hoist:d.length};else if(ie.test(S))m={ctx:f.ctx,group:S,at:d.length};else m={ctx:"opaque"};else{if(f.ctx==="style"){if(n)ae.test(S.replace(kt,""))&&l("LIPS-S008",`'${S}' joins '&' to a name`,b,g-b,"Native nesting cannot: write the full selector, or use stylisPreprocessor."),k=ue(S)}m={ctx:f.ctx==="opaque"?"opaque":"style"}}C.push(m),R("{"),m.group&&(m.body=d.length)},tt=()=>{let f=C.pop();if(f.group&&!k&&d.length===f.body&&!pe.test(f.group)){d=d.slice(0,f.at),w="",x=!1;return}if(R("}"),f.hoist===void 0)return;let S=d.slice(f.hoist),m=C.filter((O)=>O.group),v=m.map((O)=>O.group).join("{"),I="}".repeat(m.length);d=d.slice(0,f.hoist),w="",D=v&&v===J?D.slice(0,D.length-I.length)+S+I:D+m.map((O)=>O.group+"{").join("")+S+I,J=v};while(g<t.length){let f=t[g];if(f==="\\"){y(t.slice(g,g+2)),g+=2;continue}let S=f==="/"&&!t.slice(b,g).trim();if(f==="/"&&(t[g+1]==="*"||t[g+1]==="/"&&S)){let m=t[g+1]==="/",v=m?Qt(t,g):xt(t,g);if(!m&&!n)k?y(t.slice(g,v)):d+=t.slice(g,v);else dt.test(w)&&dt.test(t[v]||"")&&(x=!0);S&&(b=v),g=v;continue}if(f==='"'||f==="'"){let m=G(t,g);y(t.slice(g,m)),g=m;continue}if(yt.test(f)){b===g&&b++,x=!0,g++;continue}if(f==="(")p++;else if(f===")")p--;if(f===":"&&p===0){let m=t.slice(b,g).replace(ce,"").trim();if(Jt.test(m)){let v=re(t,g+1,!n,(I)=>{Q=!0,c("LIPS-S004","Unterminated interpolation",I,t.length-I,"Close the expression with `}`.")});if(v){let I=v.parts.filter((P)=>typeof P!=="string");for(let P of I)E(P);if(x=!1,m.startsWith("--")&&I.length===1&&!I[0].unit&&v.parts.every((P)=>typeof P!=="string"||!P.trim())){i.push({prop:m,e:u(I[0].expr)}),N(),g=v.end+(t[v.end]===";"?1:0),b=g;continue}let U="";for(let P of v.parts){if(typeof P==="string"){U+=P;continue}let et=u(P.expr),_=`${o}-${et}`;if(!i.some((F)=>F.prop===_)){if(i.push({prop:_,e:et}),P.unit&&!a.some((F)=>F.name===_))a.push({name:_,syntax:ft[0],inherits:!0,initial:ft[1]})}U+=P.unit?`calc(var(${_}) * 1${P.unit})`:`var(${_})`}h(m,b,v.end,U),y(q(U)),g=v.end;continue}}}if(f==="{"){if(p>0){let m=Y(t,g);if(m){c("LIPS-S002","Interpolation in an at-rule condition",g,m.end-g+1,"Media and container conditions cannot read custom properties. Keep the condition static.");let v=bt.exec(t.slice(m.end+1));g=m.end+1+(v?v[1].length:0);continue}}if(!t.slice(b,g).trim()){let m=Y(t,g);if(m){c("LIPS-S001","Interpolation in a selector",g,m.end-g+1,"Selectors are static in Layer 1. Bind a value inside the rule instead."),g=m.end+1,b=g;continue}}Bt(),b=++g;continue}if(f==="}"){if(C.length>1)tt();else l("LIPS-S007","Unmatched `}` dropped",g,1),k&&R(";");b=++g;continue}if(f===";"){if(k[0]==="@"&&h(k,b,g),C.length===1&>.test(k))L+=N()+";";else R(";");b=++g;continue}y(f),g++}if(C.length>1){Q||l("LIPS-S007","Unclosed `{` closed at the end",t.length,0);while(C.length>1)tt()}return gt.test(k)&&(L+=N()+";"),R(""),{css:d,statements:L,hoisted:D,exprs:s,binds:i,props:a}}function vt(t,e){let n=[],r=e.preprocess||Xt,{css:s,statements:i,hoisted:a,exprs:o,binds:c,props:l}=fe(t,e,!r,n),h={v:1,nsp:e.nsp,css:"",exprs:[],binds:[]},u=e.meta||!s?s:`${e.scope||`[rel="${te(e.nsp)}"]`}{${s}}`,E=a+u,d=e.layer?`@layer ${e.layer}{${E}}`:E,k;try{k=r?r(d):d}catch(y){return n.push({code:"LIPS-S006",severity:"error",message:`Style compilation failed: ${y.message}`,loc:B(t,0,t.length)}),{ir:h,diagnostics:n}}let w=l.map((y)=>`@property ${y.name}{syntax:"${y.syntax}";inherits:${y.inherits};initial-value:${y.initial}}`).join(""),x={v:1,nsp:e.nsp,css:i+w+k,exprs:o,binds:c};if(l.length)x.props=l;return{ir:x,diagnostics:n}}var ge=["div","section","article","nav","header","footer","main","aside","ul","ol","li","button","form","figure","dialog","details","summary","address","blockquote","hgroup","fieldset","legend","menu","dl","dt","dd","figcaption"],me=["span","p","h1","h2","h3","h4","h5","h6","label","b","strong","i","em","small","a","code","mark","s","u","sub","sup","time","abbr","cite","kbd","q","var","samp","dfn","del","ins","data","bdi","bdo"],W=Object.fromEntries([...ge.map((t)=>[t,"view"]),...me.map((t)=>[t,"text"]),["img","image"]]),St=(t)=>`lips-${t.replace(/[^\w-]/g,"-")}`,Z="lips-svg";var Et={button:["button"],link:["link"],heading:["header"],img:["image"],image:["image"],checkbox:["button","checkbox"],switch:["button","switch"],radio:["button","radio"],tab:["button","tab"],option:["button"],menuitem:["button"],menuitemcheckbox:["button","checkbox"],menuitemradio:["button","radio"],searchbox:["search"],progressbar:["none","progressbar"]};var wt={status:"polite",log:"polite",alert:"assertive"},It=new Set(["none","presentation"]);var de=[["aria-checked","checked","unchecked"],["aria-pressed","pressed"],["aria-selected","selected"],["aria-expanded","expanded","collapsed"],["aria-current","current"],["aria-disabled","disabled"],["aria-invalid","invalid"],["aria-required","required"]],Lt=new Set(["role","alt","for","tabindex","aria-label","aria-labelledby","aria-describedby","aria-hidden","aria-live","aria-modal","aria-roledescription","aria-valuetext","aria-valuenow",...de.map((t)=>t[0])]),Pt=(t,e)=>t.role?.trim().split(/\s+/)[0]||e||"";var V=new Set(["if","else-if","else","for","switch","case","default","async","then","catch","loading","let","const","log","context","i18n"]),$t=new Set(["view","scroll-view","list-item","swiper","swiper-item","overlay","refresh-view","viewpager"]),Rt=new Set(["text","image","input","textarea","canvas","svg","audio"]),T="Lynx has no tables: lay rows out with <div>s, in flex or grid",be={table:T,thead:T,tbody:T,tfoot:T,tr:T,td:T,th:T,caption:T,col:T,colgroup:T,select:"Lynx has no native picker element: a list of <div>s, or a picker component",option:"Lynx has no native picker element: a list of <div>s, or a picker component",br:"End the <p> and start another one",hr:"A <div> with a border",pre:"A <p> styled white-space: pre",iframe:"Lynx's <webview>"},Tt=Object.fromEntries("circle clipPath defs text ellipse g image line linearGradient path polygon polyline radialGradient rect stop svg use".split(" ").map((t)=>[t.toLowerCase(),t])),xe=new Set("xlink:href style points offset font-size id xmlns clip-path clip-rule clipPathUnits color cx cy d fill fill-opacity fill-rule fx fy gradientTransform gradientUnits height width href opacity preserveAspectRatio r rx ry spreadMethod stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width transform viewBox x y x1 y1 x2 y2".split(" ")),Nt=(t)=>W[t]||t,ye=(t)=>Nt(t)==="text";function K(t){for(let e of t){if(e.t==="text"||e.t==="interp")return e;let n=e.t==="fragment"||e.t==="element"&&V.has(e.tag)?K(e.children):void 0;if(n)return n}}var Ct=(t)=>t.every((e)=>e.t==="fragment"||e.t==="element"&&V.has(e.tag)?Ct(e.children):e.t!=="element"||ye(e.tag));function*At(t){for(let e of t)e.t==="fragment"||e.t==="element"&&V.has(e.tag)?yield*At(e.children):e.t!=="comment"&&(yield e)}function Ot(t){return(e,n)=>{let r=(c,l,h,u,E)=>n.push({code:c,severity:l,message:h,hint:E,loc:B(t,u.loc.offset,u.loc.length)}),s=(c)=>{for(let l of c.attrs){if(!("name"in l))continue;let h=l.k==="literal"?l.value:void 0,u=h!==void 0&&Pt({role:h});if(l.name==="role"&&u&&!Et[u]&&!wt[u]&&!It.has(u))r("LIPS-L105","warning",`role="${u}" has no Lynx equivalent: its content stays readable, the ${u} is not announced`,l,"Say what each item is and its state on the item: aria-label, aria-selected, aria-checked");else if(l.name.startsWith("aria-")&&!Lt.has(l.name)&&!(l.name==="aria-atomic"&&h==="true"))r("LIPS-L106","warning",`${l.name} has no Lynx equivalent: it is not read`,l,l.name==="aria-atomic"||l.name==="aria-relevant"?"Lynx announces the whole region on every change":"Put what it says in the aria-label or a state Lynx reads");else if(l.name==="tabindex"&&h&&+h>0)r("LIPS-L107","warning","A positive tabindex orders focus: Lynx has no focus order, so it reads as 0",l,'Use tabindex="0", and order the elements in the template')}},i=(c)=>{for(let l of c){if(l.t==="fragment")i(l.children);if(l.t!=="element")continue;if(V.has(l.tag)){i(l.children);continue}let h=Tt[l.tag];h?l.attrs.push({k:"literal",name:Z,value:h,loc:l.loc}):r("LIPS-L108","warning",j.has(l.tag)?`<${l.tag}> is not drawn by Lynx's svg`:`<${l.tag}> inside an <svg>: Lynx draws an svg from its markup, so a component renders nothing there`,l,`Lynx's svg draws ${Object.values(Tt).join(", ")}`);for(let u of l.attrs)"name"in u&&u.name!==Z&&u.name[0]!=="@"&&!xe.has(u.name)&&r("LIPS-L108","warning",u.k==="event"?`on-${u.name} inside an <svg>: Lynx draws it as one view, so its parts have no events`:`${u.name} is not read by Lynx's svg`,u,u.k==="event"?"Listen on the <svg> itself":void 0);i(l.children)}},a=(c)=>{for(let l of c){if(l.t==="fragment")a(l.children);if(l.t!=="element")continue;let h=l.tag;if((j.has(h)||Rt.has(h)||$t.has(h)||h==="list")&&s(l),h==="svg"){i(l.children);continue}if(j.has(h)&&!W[h]&&!Rt.has(h))r("LIPS-L101","error",`<${h}> has no Lynx element: it would render nothing`,l,be[h]||"Use a tag Lynx renders: <div>, <p>, <span>, <img>, <input> or a Lynx element");else if(h==="list")for(let u of At(l.children))u.t==="element"&&u.tag==="list-item"||r("LIPS-L104","error","A <list> holds <list-item>s: Lynx renders nothing else in one",u,"Put each row in a <list-item>");else if(Nt(h)==="view"||$t.has(h)){let u=K(l.children);if(u&&Ct(l.children)){let E=l.attrs.filter((d)=>("name"in d)&&d.name==="i18n");l.children=[{t:"element",tag:"text",attrs:E,children:l.children,selfClosed:!1,loc:l.loc}]}else u&&r("LIPS-L102","error",`Text beside block content in <${h}>: Lynx renders text only inside a text element`,u,"Wrap the text in a <span> or a <p>")}a(l.children)}},o=K(e);o&&r("LIPS-L103","warning","Text at the top level of a template renders only when the template is placed inside a text element",o,"Put it in a <p> or a <span>"),a(e)}}var X=(t,e)=>ut(t,{...e,target:"tree",transform:Ot(t)});var ke={enableCSSInlineVariables:!0,enableCSSRule:!0,enableCSSInheritance:!0,enableA11y:!0};function ve(t,e){let{ir:n,diagnostics:r}=vt(t,{nsp:e.nsp,meta:e.meta,preprocess:e.preprocess,scope:`.${St(e.nsp)}`,lint:Ce});return{ir:Ee(n),diagnostics:r}}var _t=/calc\(var\((--[\w-]+?-(\d+))\)\s*\*\s*1(%|[a-zA-Z]+)\)/g,Se=/@property\s[^{]+\{[^}]*\}/g;function Ee(t){let e=`--${t.nsp.replace(/[^a-zA-Z0-9_-]/g,"-")}-`,n=[...t.binds],r=t.css.replace(Se,"").replace(_t,(i,a,o,c)=>{if(!a.startsWith(e)||a.length!==e.length+o.length)return i;let l=`${a}-${c==="%"?"pct":c}`;return n.some((h)=>h.prop===l)||n.push({prop:l,e:+o,u:c}),`var(${l})`}),s={...t,css:r,binds:n.filter((i)=>i.u||!i.prop.startsWith(e)||r.includes(`var(${i.prop})`))};return delete s.props,s}var A=(t,e,n)=>({code:t,severity:"error",message:e,hint:n}),z=(t,e,n)=>({code:t,severity:"warning",message:e,hint:n}),we=new Set(`
|
|
7
7
|
-x-animation-color-interpolation -x-app-region -x-auto-font-size -x-auto-font-size-line-ranges
|
|
8
8
|
-x-auto-font-size-preset-sizes -x-caret-gradient -x-caret-height -x-caret-radius -x-caret-width
|
|
9
9
|
-x-handle-color -x-handle-size adapt-font-size align-content align-items align-self animation
|
|
@@ -46,6 +46,6 @@ var At=new Set(["area","base","br","col","embed","hr","img","input","link","meta
|
|
|
46
46
|
text-indent text-overflow text-shadow text-stroke text-stroke-color text-stroke-width top
|
|
47
47
|
transform transform-origin transition transition-delay transition-duration transition-property
|
|
48
48
|
transition-timing-function vertical-align visibility white-space width word-break z-index
|
|
49
|
-
`.trim().split(/\s+/)),
|
|
49
|
+
`.trim().split(/\s+/)),Ie=/^(-webkit-)?line-clamp$/,Le=new Set(["src","font-display","unicode-range"]),Pe=/^(width|height|(min|max)-(width|height)|(margin|padding)(-(top|right|bottom|left|inline-start|inline-end))?|top|right|bottom|left|inset-inline-(start|end)|gap|row-gap|column-gap|grid-(row|column)-gap|font-size|line-height|letter-spacing|flex-basis|text-indent|border(-(top|right|bottom|left|inline-start|inline-end))?-width|outline-width)$/,$e=new Set(["not","active","focus","root"]),Re=new Set(["before","after","first-line","first-letter"]),Te=new Set(["media","keyframes","font-face","import"]),Ne=new Set(["supports","layer"]),jt=/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/g,Ce=(t,e)=>t[0]==="@"?Oe(t):e===void 0?Ae(t):_e(t,e);function Ae(t){let e=[],n=t.replace(jt,'""');if(n.includes("["))e.push(A("LIPS-L001","Attribute selectors never match on Lynx","Select by class instead."));for(let[,r,s]of n.matchAll(/(::?)([-\w]+)/g)){let i=s.toLowerCase();if(r==="::"||Re.has(i))e.push(A("LIPS-L002",`Pseudo-elements are not supported on Lynx: '${r}${s}'`,"Render it as an element."));else if(i==="hover")e.push(z("LIPS-L004","':hover' matches only on desktop Lynx","Mobile has no pointer to hover with."));else if(!$e.has(i))e.push(A("LIPS-L003",`':${s}' never matches on Lynx`,"Lynx matches :not(), :active, :focus and :root. Use a class."))}for(let[,,r]of n.replace(/\[[^\]]*\]/g,"").matchAll(/(^|[\s>+~,(])([a-zA-Z][-\w]*)/g)){let s=W[r.toLowerCase()];s&&e.push(A("LIPS-L005",`'${r}' renders as '${s}' on Lynx, so this selector never matches`,`Use a class. A '${s}' selector would match every ${s}, not just the ${r}s.`))}return e}function Oe(t){let e=/^@(?:-\w+-)?([-\w]+)/.exec(t)?.[1].toLowerCase();if(!e||Te.has(e))return;return[Ne.has(e)?z("LIPS-L007",`'@${e}' is untested on Lynx`,"The engine evaluates it, but its docs say it is unsupported."):A("LIPS-L006",`'@${e}' is not supported on Lynx`)]}function _e(t,e){let n=[];if(t.startsWith("--"))return n;let r=t.toLowerCase();if(Ie.test(r))n.push(A("LIPS-L012",`'${t}' does not cut text on Lynx`,`Set the text-maxline attribute on the text element instead (text-maxline="${/^\d+$/.test(e.trim())?e.trim():"N"}"), with text-overflow: ellipsis.`));else we.has(r)||Le.has(r)||n.push(z("LIPS-L008",`'${t}' is not a Lynx CSS property`,"Lynx ignores it."));let s=e.replace(jt,'""').replace(_t,"var()"),i=/(?:^|[^-\w])(min|max|clamp)\(/i.exec(s);return i&&n.push(A("LIPS-L009",`'${i[1]}()' is not supported on Lynx`,"Compute the value in the expression instead.")),/(?:^|[^-\w])calc\(/i.test(s)&&!Pe.test(r)&&n.push(A("LIPS-L010",`'calc()' works on length properties only on Lynx, not '${t}'`,"Bind the computed value instead: `{expr}` writes it whole.")),/!\s*important/i.test(s)&&n.push(z("LIPS-L011","'!important' is ignored on Lynx unless the page enables it")),n}function je(t){let e=new Map,n=new Map,r={components:{},diagnostics:{}},s=(i)=>{let a=e.get(i.name);if(a&&a!==i)throw Error(`[lips] two plugins named <${i.name}>: one is compiled already`);if(a)return;if(e.set(i.name,i),i.requires?.forEach(s),i.install)throw Error(`[lips] plugin <${i.name}> sets itself up with install(), which needs a Lips: on Lynx, compile its components yourself`);for(let[o,c]of Object.entries(i.components||{})){if(n.has(o)&&n.get(o)!==c)throw Error(`[lips] <${o}> of plugin <${i.name}> is compiled already, from something else`);if(c.stylesheet)throw Error(`[lips] <${o}> of plugin <${i.name}> has a stylesheet: Lynx cannot add one at run time, so it goes in the app's build`);n.set(o,c);let l=c.lynx??c.default;if(l===void 0)throw Error(`[lips] <${o}> of plugin <${i.name}> has no source: precompiled \`ir\` is the DOM's, and Lynx compiles its own`);let{ir:h,diagnostics:u}=X(l,{macros:c.macros});r.diagnostics[o]=u,r.components[o]={ir:h,state:c.state,statics:c.static??c._static,context:c.watchContext,nsp:o,handlers:c.handler,deep:!0}}};return t.forEach(s),r}export{ke as LYNX_PAGE_CONFIG,ve as compileLynxStyle,X as compileLynxTemplate,je as lynxComponents,Ot as lynxVocabulary};
|
|
50
50
|
|
|
51
|
-
//# debugId=
|
|
51
|
+
//# debugId=E7C86F4E56E5618D64756E2164756E21
|