@lipsjs/lips 0.3.0 → 0.4.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 +123 -9
- package/dist/lips.js +915 -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 +51 -0
- package/dist/lynx.min.js.map +18 -0
- package/dist/mf2.min.js.map +1 -1
- package/dist/parts.min.js +19 -0
- package/dist/parts.min.js.map +11 -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/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 +22 -0
- package/dist/types/parts/menu.d.ts +44 -0
- package/dist/types/parts/popover.d.ts +83 -0
- package/dist/types/parts.d.ts +16 -0
- package/dist/types/precompile.d.ts +8 -11
- package/dist/types/runtime.d.ts +1 -0
- package/dist/types/types.d.ts +181 -57
- package/dist/untrusted.min.js +4 -4
- package/dist/untrusted.min.js.map +7 -7
- package/package.json +29 -3
- package/dist/types/i18n/formatters.d.ts +0 -3
package/dist/lynx.min.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var Bt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Dt=new Set(["pre","textarea"]),et=new Set(["if","else-if","switch","log"]),rt={__proto__:null,amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},Mt=/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|([A-Za-z][A-Za-z0-9]*));/g;function Wt(t,e){return t.replace(Mt,(n,r,i,s,a)=>{if(s===void 0){let o=r!==void 0?parseInt(r,10):parseInt(i,16);return o>0&&o<=1114111?String.fromCodePoint(o):n}if(s in rt)return rt[s];return e?.(s,a),n})}class nt{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,i=1,s){let{line:a,col:o}=this.locate(r);this.diagnostics.push({code:t,severity:e,message:n,hint:s,loc:{line:a,col:o,offset:r,length:i}})}decode(t,e){return Wt(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 i=this.src[this.pos];if(i==="'"||i==='"'||i==="`"){this.pos++;while(!this.eof()&&this.src[this.pos]!==i){if(this.src[this.pos]==="\\")this.pos++;this.pos++}this.pos++;continue}if(r===0&&i===t){let s=this.src.slice(n,this.pos);return this.pos++,{content:s,loc:{offset:n,length:s.length}}}if(i==="("||i==="["||i==="{")r++;else if(i===")"||i==="]"||i==="}"){if(r===0&&i!==t){this.report(e,"error",`Unbalanced '${i}'`,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 i={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:i};let s=n.length?n[0]:"",a=t.some((o)=>Dt.has(o));if(!s||!a&&!s.trim())return null;return{t:"text",value:this.decode(s,e),loc:i}}parseTag(t){let e=this.pos;if(this.startsWith("<!--")){let s=this.src.indexOf("-->",this.pos+4);if(s===-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,s);return this.pos=s+3,{t:"comment",value:a,loc:{offset:e,length:this.pos-e}}}if(this.startsWith("<>")){this.pos+=2;let s=[];while(!0)if(s.push(...this.parseNodes([...t,"#fragment"])),this.closeStatus("#fragment",e,t)!=="stray")break;return{t:"fragment",children:s,loc:{offset:e,length:this.pos-e}}}if(this.startsWith("<{")){this.pos+=2;let s=this.scanBalanced("}","LIPS-P008");if(!s)return null;let a={t:"element",tag:"#dynamic",dynamicTag:{expr:s.content.trim(),loc:s.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 i={t:"element",tag:r.toLowerCase(),attrs:[],children:[],selfClosed:!1,loc:{offset:e,length:0}};if(this.peek()==="(")if(et.has(i.tag)){this.pos++;let s=this.scanBalanced(")","LIPS-P012");s&&(i.head={expr:s.content.trim(),loc:s.loc})}else this.report("LIPS-P011","error",`Head expression is not allowed on <${i.tag}>`,this.pos,1,`Only ${[...et].map((s)=>`<${s}(…)>`).join(", ")} take a head`);return this.finishTag(i,t,e),i}finishTag(t,e,n){if(this.parseAttrs(t),t.selfClosed||Bt.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 i=this.pos;while(!this.eof()&&/[A-Za-z0-9_-]/.test(this.peek()))this.pos++;let s=this.src.slice(i,this.pos).toLowerCase();if(this.skipSpace(),this.peek()===">"?this.pos++:this.report("LIPS-P001","error","Malformed closing tag",r,this.pos-r),s===t)return"closed";if(n.includes(s))return this.report("LIPS-P004","warning",`</${s}> auto-closes <${t}>`,r,this.pos-r,`Add the missing </${t}> before </${s}>`),this.pos=r,"ancestor";return this.report("LIPS-P005","error",`Stray closing tag </${s}> — <${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 s=this.readUnquotedValue();t.attrs.push({k:"spread",source:s,loc:{offset:e,length:this.pos-e}});continue}if(this.peek()==="["){this.pos++;let s=this.scanBalanced("]","LIPS-P009");if(s){let a=s.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 i=this.src.slice(r,this.pos);if(!i){this.report("LIPS-P009","error",`Invalid attribute syntax at '${this.peek()}'`,this.pos),this.pos++;continue}if(this.peek()==="("){this.pos++;let s=this.scanBalanced(")","LIPS-P010"),a=s?s.content.trim():"",o={offset:e,length:this.pos-e};i.startsWith("on-")?t.attrs.push({k:"event",name:i.slice(3),source:a,loc:o}):t.attrs.push({k:"fn",name:i,source:a,loc:o});continue}if(this.peek()==="="){this.pos++,this.parseAttrValue(t,i,e);continue}t.attrs.push({k:"bool",name:i,value:!n,loc:{offset:e,length:this.pos-e}})}}parseAttrValue(t,e,n){let r=this.peek();if(r==='"'||r==="'"){this.pos++;let s=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}'`,s,this.pos-s):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,s):l),loc:c}):t.attrs.push({k:"literal",name:e,value:this.decode(a[0]??"",s),loc:c});return}if(r==="{"){this.pos++;let s=this.scanBalanced("}","LIPS-P007");t.attrs.push({k:"expr",name:e,source:s?s.content.trim():"",loc:{offset:n,length:this.pos-n}});return}let i=this.readUnquotedValue();i?t.attrs.push({k:"expr",name:e,source:i,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 nt(t||"").parse()}var qt=["===","!==","...","=>","==","!=","<=",">=","&&","||","??","?.","++","--","+=","-=","*=","/=","%=","+","-","*","/","%","<",">","!","?",":",".",",","(",")","[","]","{","}","="];function Ut(t,e){let n=[],r=0,i=(a)=>/[A-Za-z_$]/.test(a),s=(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(i(a)){let c=r;while(r<t.length&&s(t[r]))r++;n.push({t:"id",value:t.slice(c,r),start:c,end:r});continue}let o=qt.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 it{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 i=this.peek(n+1);return i.t==="punct"&&i.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=Ut(t,e);return{ast:new it(n,e).parse(),diagnostics:e}}function st(t){let e=new Set,n=(r,i)=>{switch(r.t){case"id":!i.has(r.name)&&e.add(r.name);return;case"member":n(r.obj,i),typeof r.prop!=="string"&&n(r.prop,i);return;case"call":n(r.callee,i),r.args.forEach((s)=>n(s,i));return;case"unary":case"update":n(r.arg,i);return;case"bin":case"logic":n(r.l,i),n(r.r,i);return;case"cond":n(r.test,i),n(r.cons,i),n(r.alt,i);return;case"assign":n(r.target,i),n(r.value,i);return;case"arrow":n(r.body,new Set([...i,...r.params]));return;case"arr":r.items.forEach((s)=>n(s.value,i));return;case"obj":r.props.forEach((s)=>n(s.value,i));return}};return n(t,new Set),[...e]}var Be=Symbol("lips.ended");var ot=new Set(["if","else-if","else","for","switch","async","let","const","log","context","i18n"]),at=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 Gt="<!--$-->",Vt=new Set(["stop","capture","outside"]),zt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ft=(t)=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),Ht=(t)=>t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<"),lt=(t)=>t!==""&&!isNaN(Number(t)),ct=(t)=>{let e=t.trim(),n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="'"||i==='"'||i==="`"){r++;while(r<e.length&&e[r]!==i){if(e[r]==="\\")r++;r++}continue}if(i==="("||i==="["||i==="{")n++;else if(i===")"||i==="]"||i==="}"){if(n--,n===0&&e[0]==="{"&&r===e.length-1)return ct(e.slice(1,-1))}else if(n===0){if(i==="?")return!1;if(i===":")return!0}}return!1},Yt=(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 pt{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,i=1,s){let{line:a,col:o}=this.locate(r);this.diagnostics.push({code:t,severity:e,message:n,hint:s,loc:{line:a,col:o,offset:r,length:i}})}expr(t,e){let n=this.exprIndex.get(t);if(n!==void 0)return n;let{diagnostics:r}=M(t);for(let s of r){let a=(e?.offset??0)+s.loc.offset;this.report(s.code,"error",s.message,a,s.loc.length)}let i=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,i),i}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 i of r)this.report(i.code,"error",i.message,n.loc.offset+i.loc.offset,i.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=[],i=this.tree,s=[],a=(o,c,l,h=!1,u)=>{let E=0,d=!1,k=()=>(r.push(Gt),i&&l.push(0),d=!1,[...c,E++]);for(let I=0;I<o.length;I++){let x=o[I];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(Ft(x.value)),i&&(d?l[l.length-1]+=x.value:l.push(x.value)),!d)E++;d=!0;break}case"comment":{if(i)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,I),...x.children,...o.slice(I+1)],I--;break}case"element":{if(ot.has(x.tag)){if(this.controlBlock(x,o,I,k(),n,e),x.tag==="if"){let y=I+1;while(y<o.length){let T=o[y];if(T.t==="element"&&(T.tag==="else-if"||T.tag==="else"))y++;else break}o=[...o.slice(0,I+1),...o.slice(y)]}break}if(at.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,[],s),n.html=r.join(""),i)n.nodes=s;return n}emitElement(t,e,n,r,i,s,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"),I=(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=I("i18n"),y=(p)=>I(`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=Yt(p);if(b&&ct(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"){i.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){i.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;i.binds.push(b);break}c+=` ${p.name}="${Ht(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"){i.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){i.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}i.binds.push(b);break}case"interp":{if(p.name==="@format"){i.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){i.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}i.binds.push(b);break}case"event":this.modifiers(p),i.binds.push({t:"event",p:o,name:p.name,e:this.synth(p.source)});break;case"spread":i.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),zt.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&&s(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 i=n.slice(0,r).trim(),s=n.slice(r+1).trim();return{t:"prop",p:t,name:"format",e:this.expr(s,e.loc),ref:i}}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,i,s){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,s)}];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,s)});else if(c.tag==="else"){a.push({when:null,block:this.block(c.children,s)});break}else break}i.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,[...s,...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)}}i.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,s)})}else if(c.tag==="default")o.push({is:null,block:this.block(c.children,s)});else this.report("LIPS-C003","error","Only <case>/<default> are valid inside <switch>",c.loc.offset,c.loc.length)}i.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,[...s,...l])};else if(c.tag==="catch")o.catch={args:l,block:this.block(c.children,[...s,...l])};else if(c.tag==="loading")o.loading=this.block(c.children,s);else this.report("LIPS-C003","error","Only <then>/<catch>/<loading> are valid inside <async>",c.loc.offset,c.loc.length)}i.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),!i.scope.includes(o.name)&&i.scope.push(o.name),!s.includes(o.name)&&s.push(o.name)}i.blocks.push({t:"let",p:r,const:t.tag==="const",vars:a});break}case"log":i.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);i.blocks.push({t:"provide",p:r,vars:a,block:this.block(t.children,s)});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}i.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:lt(t.value)?Number(t.value):t.value};let e=this.valueOf(t);if(e!==void 0)return lt(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 i=[];for(let a of t.attrs)if(a.k==="literal"||a.k==="expr"||a.k==="interp"||a.k==="bool")i.push({name:a.name,ci:this.compInput(a)});else if(a.k==="spread")i.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 s=this.block(r.children,[...n,...r.argv]);return this.macroStack.pop(),{t:"macro",p:e,name:r.name,sets:i,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}modifiers(t,e){let n=t.name.split(".").slice(1),r=n.find((i)=>!Vt.has(i));(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 i={},s=[],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);i[l.name]={lit:{ref:h,e:u}};break}i[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":s.push(this.expr(l.source,l.loc));break;case"args":o=[...o,...l.names];break;case"fn":i[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:i,spreads:s,events:a,contents:c}:{t:"dynamic",p:e,tag:this.expr(t.dynamicTag.expr,t.dynamicTag.loc),inputs:i,spreads:s,events:a,contents:c}}}function Zt(t,e,n){let r=new Map;if(!t?.trim())return r;let i=H(t);e.push(...i.diagnostics),n?.(i.root.children,e,t);for(let s of i.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 a="",o=[];for(let c of s.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:s.loc.offset,length:s.loc.length}});continue}r.set(a.toLowerCase(),{name:a,argv:o,children:s.children})}return r}function ht(t,e){let n=[],r=Zt(e?.macros||"",n,e?.check),i=H(t);e?.check?.(i.root.children,n,t),e?.transform?.(i.root.children,n);let s=new pt(t,r,e?.target==="tree");return{ir:s.compile(i.root.children),diagnostics:[...n,...i.diagnostics,...s.diagnostics]}}var Kt=null;var Xt=/^[-\w]+$/,dt=/^(%|[a-zA-Z]+)/,ut=["<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 bt(t,e){let n=t.indexOf("*/",e+2);return n<0?t.length:n+2}function Jt(t,e){let n=t.indexOf(`
|
|
5
|
+
`,e+2);return n<0?t.length:n}var Qt=(t)=>t.replace(/["\\]/g,"\\$&");function B(t,e,n){let r=1,i=-1;for(let s=0;s<e;s++)if(t[s]===`
|
|
6
|
+
`)r++,i=s;return{line:r,col:e-i,offset:e,length:n}}function Y(t,e){let n=e+1,r=0,i=!1,s=!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==="?")i=!0;else if(o===":"&&!i)s=!0}n++}if(n>=t.length||s)return null;let a=t.slice(e+1,n).trim();return a?{end:n,expr:a}:null}var te=new Set(["state","input","static","context","self"]);function ee(t,e,n,r){let i=[],s=e,a=e,o=0;while(s<t.length){let c=t[s];if(c==='"'||c==="'"){s=G(t,s);continue}if(c==="/"&&t[s+1]==="*"){let l=bt(t,s);if(!n)i.push(t.slice(a,s)," "),a=l;s=l;continue}if(c==="("){o++,s++;continue}if(c===")"){o--,s++;continue}if(o===0&&(c===";"||c==="}"))return i.push(t.slice(a,s)),{end:s,parts:i};if(c==="{"){let l=Y(t,s);if(!l)return t.indexOf("}",s+1)<0&&r?.(s),null;i.push(t.slice(a,s));let h=dt.exec(t.slice(l.end+1)),u=h?h[1]:"";i.push({expr:l.expr,unit:u,at:s}),s=l.end+1+u.length,a=s;continue}s++}return i.some((c)=>typeof c!=="string")&&r?.(e),null}var re=/^@(-\w+-)?(keyframes|font-face|property|counter-style|font-feature-values|font-palette-values|page|view-transition|position-try|color-profile|function)\b/i,ft=/^@(import|charset|namespace)\b/i,ne=/^@(media|supports|container|layer|scope|starting-style|document)\b/i,ie=/^([a-zA-Z_*\\]|[^\x00-\x7f])/,se=/^(?:[-\w*|]|[^\x00-\x7f]|\\[\s\S])+/,oe=/&[-_]/,xt=/\s/,gt=/[{};]/,mt=/[-\w]/,yt=/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/g,ae=new RegExp(`(${yt.source})|\\s+`,"g"),le=/\/\*[\s\S]*?\*\//g,ce=/^@layer\b/i,pe=(t)=>t.replace(ae,(e,n)=>n||" ");function he(t){let e=[],n=0,r=0;for(let i=0;i<t.length;i++){let s=t[i];if(s==="\\"){i++;continue}if(s==='"'||s==="'"){i=G(t,i)-1;continue}if(s==="("||s==="[")r++;else if(s===")"||s==="]")r--;else if(s===","&&!r)e.push(t.slice(n,i)),n=i+1}return e.push(t.slice(n)),e.map((i)=>{let s=i.trimStart(),a=s.length;while(a&&xt.test(s[a-1])&&s[a-2]!=="\\")a--;if(s=s.slice(0,a),!ie.test(s))return s;return s.includes("&")?s.replace(se,":is($&)"):`& ${s}`}).join(",")}function ue(t,e,n,r){let i=[],s=[],a=[],o=`--${e.nsp.replace(/[^a-zA-Z0-9_-]/g,"-")}`,c=(f,S,m,v,w)=>r.push({code:f,severity:"error",message:S,hint:w,loc:B(t,m,v)}),l=(f,S,m,v,w)=>r.push({code:f,severity:"warning",message:S,hint:w,loc:B(t,m,v)}),h=(f,S,m,v)=>e.lint?.(f,v)?.forEach((w)=>r.push({...w,loc:B(t,S,m-S)})),u=(f)=>{let S=i.indexOf(f);if(S<0)S=i.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 w of st(S))if(!te.has(w)&&!(w in globalThis))c("LIPS-S003",`'${w}' 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="",I="",x=!1,y=(f)=>{if(!f)return;if(x&&I&&!gt.test(I)&&!gt.test(f[0]))k+=" ";x=!1,k+=f,I=f[f.length-1]},T=(f)=>{d+=k+f,k="",I=f,x=!1},N=()=>{let f=k;return k=I="",x=!1,f},q=(f)=>":"+(pe(f).trim()||" "),g=0,p=0,b=0,L="",D="",X="",J=!1,C=[{ctx:e.meta?"top":"style"}],jt=()=>{let f=C[C.length-1],S=k,m;if(f.ctx==="opaque"||h(S,b,g),S[0]==="@")if(f.ctx!=="opaque"&&re.test(S))m={ctx:"opaque",hoist:d.length};else if(ne.test(S))m={ctx:f.ctx,group:S,at:d.length};else m={ctx:"opaque"};else{if(f.ctx==="style"){if(n)oe.test(S.replace(yt,""))&&l("LIPS-S008",`'${S}' joins '&' to a name`,b,g-b,"Native nesting cannot: write the full selector, or use stylisPreprocessor."),k=he(S)}m={ctx:f.ctx==="opaque"?"opaque":"style"}}C.push(m),T("{"),m.group&&(m.body=d.length)},Q=()=>{let f=C.pop();if(f.group&&!k&&d.length===f.body&&!ce.test(f.group)){d=d.slice(0,f.at),I="",x=!1;return}if(T("}"),f.hoist===void 0)return;let S=d.slice(f.hoist),m=C.filter((O)=>O.group),v=m.map((O)=>O.group).join("{"),w="}".repeat(m.length);d=d.slice(0,f.hoist),I="",D=v&&v===X?D.slice(0,D.length-w.length)+S+w:D+m.map((O)=>O.group+"{").join("")+S+w,X=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?Jt(t,g):bt(t,g);if(!m&&!n)k?y(t.slice(g,v)):d+=t.slice(g,v);else mt.test(I)&&mt.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(xt.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(le,"").trim();if(Xt.test(m)){let v=ee(t,g+1,!n,(w)=>{J=!0,c("LIPS-S004","Unterminated interpolation",w,t.length-w,"Close the expression with `}`.")});if(v){let w=v.parts.filter((P)=>typeof P!=="string");for(let P of w)E(P);if(x=!1,m.startsWith("--")&&w.length===1&&!w[0].unit&&v.parts.every((P)=>typeof P!=="string"||!P.trim())){s.push({prop:m,e:u(w[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 tt=u(P.expr),_=`${o}-${tt}`;if(!s.some((F)=>F.prop===_)){if(s.push({prop:_,e:tt}),P.unit&&!a.some((F)=>F.name===_))a.push({name:_,syntax:ut[0],inherits:!0,initial:ut[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=dt.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}}jt(),b=++g;continue}if(f==="}"){if(C.length>1)Q();else l("LIPS-S007","Unmatched `}` dropped",g,1),k&&T(";");b=++g;continue}if(f===";"){if(k[0]==="@"&&h(k,b,g),C.length===1&&ft.test(k))L+=N()+";";else T(";");b=++g;continue}y(f),g++}if(C.length>1){J||l("LIPS-S007","Unclosed `{` closed at the end",t.length,0);while(C.length>1)Q()}return ft.test(k)&&(L+=N()+";"),T(""),{css:d,statements:L,hoisted:D,exprs:i,binds:s,props:a}}function kt(t,e){let n=[],r=e.preprocess||Kt,{css:i,statements:s,hoisted:a,exprs:o,binds:c,props:l}=ue(t,e,!r,n),h={v:1,nsp:e.nsp,css:"",exprs:[],binds:[]},u=e.meta||!i?i:`${e.scope||`[rel="${Qt(e.nsp)}"]`}{${i}}`,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 I=l.map((y)=>`@property ${y.name}{syntax:"${y.syntax}";inherits:${y.inherits};initial-value:${y.initial}}`).join(""),x={v:1,nsp:e.nsp,css:s+I+k,exprs:o,binds:c};if(l.length)x.props=l;return{ir:x,diagnostics:n}}var fe=["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"],ge=["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([...fe.map((t)=>[t,"view"]),...ge.map((t)=>[t,"text"]),["img","image"]]),vt=(t)=>`lips-${t.replace(/[^\w-]/g,"-")}`,Z="lips-svg";var St={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 Et={status:"polite",log:"polite",alert:"assertive"},It=new Set(["none","presentation"]);var me=[["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"]],wt=new Set(["role","alt","for","tabindex","aria-label","aria-labelledby","aria-describedby","aria-hidden","aria-live","aria-modal","aria-roledescription","aria-valuetext","aria-valuenow",...me.map((t)=>t[0])]),Lt=(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"]),Pt=new Set(["view","scroll-view","list-item","swiper","swiper-item","overlay","refresh-view","viewpager"]),Tt=new Set(["text","image","input","textarea","canvas","svg","audio"]),R="Lynx has no tables: lay rows out with <div>s, in flex or grid",de={table:R,thead:R,tbody:R,tfoot:R,tr:R,td:R,th:R,caption:R,col:R,colgroup:R,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>"},Rt=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])),be=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(" ")),$t=(t)=>W[t]||t,xe=(t)=>$t(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 Nt=(t)=>t.every((e)=>e.t==="fragment"||e.t==="element"&&V.has(e.tag)?Nt(e.children):e.t!=="element"||xe(e.tag));function*Ct(t){for(let e of t)e.t==="fragment"||e.t==="element"&&V.has(e.tag)?yield*Ct(e.children):e.t!=="comment"&&(yield e)}function At(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)}),i=(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&&Lt({role:h});if(l.name==="role"&&u&&!St[u]&&!Et[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-")&&!wt.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')}},s=(c)=>{for(let l of c){if(l.t==="fragment")s(l.children);if(l.t!=="element")continue;if(V.has(l.tag)){s(l.children);continue}let h=Rt[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(Rt).join(", ")}`);for(let u of l.attrs)"name"in u&&u.name!==Z&&u.name[0]!=="@"&&!be.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);s(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)||Tt.has(h)||Pt.has(h)||h==="list")&&i(l),h==="svg"){s(l.children);continue}if(j.has(h)&&!W[h]&&!Tt.has(h))r("LIPS-L101","error",`<${h}> has no Lynx element: it would render nothing`,l,de[h]||"Use a tag Lynx renders: <div>, <p>, <span>, <img>, <input> or a Lynx element");else if(h==="list")for(let u of Ct(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($t(h)==="view"||Pt.has(h)){let u=K(l.children);if(u&&Nt(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 ye=(t,e)=>ht(t,{...e,target:"tree",transform:At(t)});var ke={enableCSSInlineVariables:!0,enableCSSRule:!0,enableCSSInheritance:!0,enableA11y:!0};function ve(t,e){let{ir:n,diagnostics:r}=kt(t,{nsp:e.nsp,meta:e.meta,preprocess:e.preprocess,scope:`.${vt(e.nsp)}`,lint:Ce});return{ir:Ee(n),diagnostics:r}}var Ot=/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(Ot,(s,a,o,c)=>{if(!a.startsWith(e)||a.length!==e.length+o.length)return s;let l=`${a}-${c==="%"?"pct":c}`;return n.some((h)=>h.prop===l)||n.push({prop:l,e:+o,u:c}),`var(${l})`}),i={...t,css:r,binds:n.filter((s)=>s.u||!s.prop.startsWith(e)||r.includes(`var(${s.prop})`))};return delete i.props,i}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}),Ie=new Set(`
|
|
7
|
+
-x-animation-color-interpolation -x-app-region -x-auto-font-size -x-auto-font-size-line-ranges
|
|
8
|
+
-x-auto-font-size-preset-sizes -x-caret-gradient -x-caret-height -x-caret-radius -x-caret-width
|
|
9
|
+
-x-handle-color -x-handle-size adapt-font-size align-content align-items align-self animation
|
|
10
|
+
animation-delay animation-direction animation-duration animation-fill-mode
|
|
11
|
+
animation-iteration-count animation-name animation-play-state animation-timing-function
|
|
12
|
+
aspect-ratio background background-clip background-color background-image background-origin
|
|
13
|
+
background-position background-repeat background-size border border-bottom border-bottom-color
|
|
14
|
+
border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width
|
|
15
|
+
border-color border-end-end-radius border-end-start-radius border-inline-end-color
|
|
16
|
+
border-inline-end-style border-inline-end-width border-inline-start-color
|
|
17
|
+
border-inline-start-style border-inline-start-width border-left border-left-color
|
|
18
|
+
border-left-style border-left-width border-radius border-right border-right-color
|
|
19
|
+
border-right-style border-right-width border-start-end-radius border-start-start-radius
|
|
20
|
+
border-style border-top border-top-color border-top-left-radius border-top-right-radius
|
|
21
|
+
border-top-style border-top-width border-width bottom box-shadow box-sizing caret-color
|
|
22
|
+
clip-path color column-gap content cursor direction display enter-transition-name
|
|
23
|
+
exit-transition-name filter flex flex-basis flex-direction flex-flow flex-grow flex-shrink
|
|
24
|
+
flex-wrap font-family font-feature-settings font-optical-sizing font-size font-style
|
|
25
|
+
font-variation-settings font-weight gap grid-auto-columns grid-auto-flow grid-auto-rows
|
|
26
|
+
grid-column-end grid-column-gap grid-column-span grid-column-start grid-row-end grid-row-gap
|
|
27
|
+
grid-row-span grid-row-start grid-template-columns grid-template-rows height hyphens
|
|
28
|
+
image-rendering implicit-animation inset-inline-end inset-inline-start justify-content
|
|
29
|
+
justify-items justify-self layout-animation-create-delay layout-animation-create-duration
|
|
30
|
+
layout-animation-create-property layout-animation-create-timing-function
|
|
31
|
+
layout-animation-delete-delay layout-animation-delete-duration layout-animation-delete-property
|
|
32
|
+
layout-animation-delete-timing-function layout-animation-update-delay
|
|
33
|
+
layout-animation-update-duration layout-animation-update-timing-function left letter-spacing
|
|
34
|
+
line-height line-spacing linear-cross-gravity linear-direction linear-gravity
|
|
35
|
+
linear-layout-gravity linear-orientation linear-weight linear-weight-sum list-cross-axis-gap
|
|
36
|
+
list-main-axis-gap margin margin-bottom margin-inline-end margin-inline-start margin-left
|
|
37
|
+
margin-right margin-top mask mask-clip mask-image mask-origin mask-position mask-repeat
|
|
38
|
+
mask-size max-height max-width min-height min-width offset-distance offset-path offset-rotate
|
|
39
|
+
opacity order outline outline-color outline-style outline-width overflow overflow-x overflow-y
|
|
40
|
+
padding padding-bottom padding-inline-end padding-inline-start padding-left padding-right
|
|
41
|
+
padding-top pause-transition-name perspective pointer-events position relative-align-bottom
|
|
42
|
+
relative-align-inline-end relative-align-inline-start relative-align-left relative-align-right
|
|
43
|
+
relative-align-top relative-bottom-of relative-center relative-id relative-inline-end-of
|
|
44
|
+
relative-inline-start-of relative-layout-once relative-left-of relative-right-of relative-top-of
|
|
45
|
+
resume-transition-name right row-gap text-align text-decoration text-decoration-color
|
|
46
|
+
text-indent text-overflow text-shadow text-stroke text-stroke-color text-stroke-width top
|
|
47
|
+
transform transform-origin transition transition-delay transition-duration transition-property
|
|
48
|
+
transition-timing-function vertical-align visibility white-space width word-break z-index
|
|
49
|
+
`.trim().split(/\s+/)),we=/^(-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)$/,Te=new Set(["not","active","focus","root"]),Re=new Set(["before","after","first-line","first-letter"]),$e=new Set(["media","keyframes","font-face","import"]),Ne=new Set(["supports","layer"]),_t=/"(?:\\[\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(_t,'""');if(n.includes("["))e.push(A("LIPS-L001","Attribute selectors never match on Lynx","Select by class instead."));for(let[,r,i]of n.matchAll(/(::?)([-\w]+)/g)){let s=i.toLowerCase();if(r==="::"||Re.has(s))e.push(A("LIPS-L002",`Pseudo-elements are not supported on Lynx: '${r}${i}'`,"Render it as an element."));else if(s==="hover")e.push(z("LIPS-L004","':hover' matches only on desktop Lynx","Mobile has no pointer to hover with."));else if(!Te.has(s))e.push(A("LIPS-L003",`':${i}' 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 i=W[r.toLowerCase()];i&&e.push(A("LIPS-L005",`'${r}' renders as '${i}' on Lynx, so this selector never matches`,`Use a class. A '${i}' selector would match every ${i}, not just the ${r}s.`))}return e}function Oe(t){let e=/^@(?:-\w+-)?([-\w]+)/.exec(t)?.[1].toLowerCase();if(!e||$e.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(we.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 Ie.has(r)||Le.has(r)||n.push(z("LIPS-L008",`'${t}' is not a Lynx CSS property`,"Lynx ignores it."));let i=e.replace(_t,'""').replace(Ot,"var()"),s=/(?:^|[^-\w])(min|max|clamp)\(/i.exec(i);return s&&n.push(A("LIPS-L009",`'${s[1]}()' is not supported on Lynx`,"Compute the value in the expression instead.")),/(?:^|[^-\w])calc\(/i.test(i)&&!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(i)&&n.push(z("LIPS-L011","'!important' is ignored on Lynx unless the page enables it")),n}export{ke as LYNX_PAGE_CONFIG,ve as compileLynxStyle,ye as compileLynxTemplate,At as lynxVocabulary};
|
|
50
|
+
|
|
51
|
+
//# debugId=82107FD30D0528C864756E2164756E21
|