solely 0.2.5 → 0.2.7

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.
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty,n=(n,t,o)=>((n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o)(n,"symbol"!=typeof t?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../shared/gen-function.cjs"),o=require("../../shared/env.cjs"),i=require("../../types/ast.cjs"),s=require("../../types/lifecycle.cjs"),c=/\{\{[\s\S]*?\}\}/,r=new class{constructor(){n(this,"compilers",new Map)}get(e="anonymous"){let n=this.compilers.get(e);return n||(n=new l,this.compilers.set(e,n)),n}clear(e){var n;if(e)null==(n=this.compilers.get(e))||n.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class l{constructor(){n(this,"cache",new Map),n(this,"functions",[])}makeCacheKey(e,n,t){return 0===t.length?`${e}:${n}`:`${e}:${n}:${t.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,n,i){const s=null==n?void 0:n.trim();if(!s)return 0;const c=this.makeCacheKey(e,s,i),r=this.cache.get(c);if(void 0!==r)return r;let l;try{l=t.genFunction(s,e,i)}catch(a){o.IS_DEV,l=()=>""}const u=this.functions.push(l);return this.cache.set(c,u),u}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function u(e){const n=e[0];return":"===n?{isDynamic:!0,type:"expression"}:"@"===n?{isDynamic:!0,type:"handler"}:s.isLifecycleKind(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function a(e,n,t){o.IS_DEV&&(e.o={expr:n??"",loc:t??null})}function f(e){if(!e.attrs)return;const n=e.attrs.find(e=>"s-model"===e.key);if(!n)return;const t="$data."+n.value.replace("this.","").replace("$data.",""),o=n.loc,i=(e.tag||"").toLowerCase(),s=e.attrs.find(e=>"type"===e.key),c=(null==s?void 0:s.value)??"text";e.attrs=e.attrs.filter(e=>e!==n);const r=(n,t,i)=>{var s;null==(s=e.attrs)||s.push({key:n,value:t,role:i,loc:o})};if("input"===i){if("checkbox"===c){const n=e.attrs.find(e=>"value"===e.key),o=n?JSON.stringify(n.value):'"on"';return r(":checked",`Array.isArray(${t}) ? ${t}.includes(${o}) : ${t}`),void r("@change",`\n const _v = ${o};\n if(Array.isArray(${t})) {\n const _i = ${t}.indexOf(_v);\n if(checked && _i === -1) ${t}.push(_v);\n else if(!checked && _i > -1) ${t}.splice(_i,1);\n } else {\n ${t} = checked;\n }`,"model")}if("radio"===c){const n=e.attrs.find(e=>"value"===e.key),o=(null==n?void 0:n.value)??"null";return r(":checked",`${t} == ${JSON.stringify(o)}`),void r("@change",`if (checked) ${t} = ${JSON.stringify(o)}`,"model")}return r(":value",t),void r("@input",`${t} = value`,"model")}if("textarea"===i)return r(":value",t),void r("@input",`${t} = value`,"model");"select"!==i?(r(":value",t),r("@input",`${t} = $event`,"model")):e.attrs.some(e=>"multiple"===e.key)?(r("updated",`\n const values = Array.isArray(${t}) ? ${t} : ${t} != null ? [${t}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),r("@change",`${t} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(r(":value",t),r("@change",`${t} = value`,"model"))}function d(e,n,t,o=null){if(!e.attrs||0===e.attrs.length)return[];const i=[];for(const s of e.attrs){if(o&&o.has(s.key))continue;const{key:c,value:r,role:l}=s,{isDynamic:f,type:d}=u(c);if(f&&d){const o={k:c,f:t.compile(d,r??"",n),d:1,r:l};a(o,r,s.loc??e.loc),i.push(o)}else i.push({k:c,v:r,d:0,r:l})}return i}function v(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const n of e.c)if(!v(n))return!1;if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)if(!v(e))return!1;return!0}function h(e){if(e.c&&e.c.length>0)for(const n of e.c)h(n);if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)h(e);e.t!==i.ASTType.Element&&e.t!==i.ASTType.Text||0===e.d&&v(e)&&(e.s=1)}function p(e,n,t){var s,r,l,v,h,p;const y={t:e.type,d:0};let $=!1;var k;switch(e.type===i.ASTType.Text?(k=e.content)&&c.test(k)&&($=!0):((null==(s=e.attrs)?void 0:s.some(e=>"s-model"===e.key||u(e.key).isDynamic))&&($=!0),e.type===i.ASTType.For&&($=!0)),y.d=$?1:0,e.type){case i.ASTType.Text:{const o=e.content??"";$?(y.f=t.compile("template",o,n),a(y,o,e.loc)):y.x=o;break}case i.ASTType.Element:y.g=e.tag,f(e),y.a=d(e,n,t),e.children&&(y.c=m(e.children,n,t));break;case i.ASTType.For:{const o=null==(r=e.attrs)?void 0:r.find(e=>"each"===e.key),i=(null==o?void 0:o.value)??"";y.f=t.compile("expression",i,n),y.i=(null==(v=null==(l=e.attrs)?void 0:l.find(e=>"item"===e.key))?void 0:v.value)??"item",y.n=(null==(p=null==(h=e.attrs)?void 0:h.find(e=>"index"===e.key))?void 0:p.value)??"index",a(y,i,(null==o?void 0:o.loc)??e.loc);const s=new Set(["each","item","index"]);y.a=d(e,n,t,s);const c=[...n,{i:y.i,x:y.n}];e.children&&(y.c=m(e.children,c,t));break}case i.ASTType.If:case i.ASTType.ElseIf:case i.ASTType.Else:o.IS_DEV,y.a=d(e,n,t),e.children&&(y.c=m(e.children,n,t));break;case i.ASTType.Comment:y.x=e.content??""}return y}function m(e,n,t){var s;const c=[];let r=0;for(;r<e.length;){const l=e[r];if(l.type===i.ASTType.If){const u=[];let a=r;for(;a<e.length;){const c=e[a],r=c.type;if(r!==i.ASTType.If&&r!==i.ASTType.ElseIf&&r!==i.ASTType.Else)break;if(r===i.ASTType.If&&u.length>0)break;let l,f=null,v="";if(r!==i.ASTType.Else){const e=null==(s=c.attrs)?void 0:s.find(e=>"test"===e.key||"condition"===e.key);v=(null==e?void 0:e.value)??"false",f=t.compile("expression",v,n),l=(null==e?void 0:e.loc)??c.loc}const h=c.children?m(c.children,n,t):[],p=d(c,n,t,new Set(["test","condition"]));if(u.push({f:f,c:h,a:p.length>0?p:void 0,...o.IS_DEV&&{o:{expr:v,loc:l}}}),a++,r===i.ASTType.Else)break}c.push({t:i.ASTType.Conditional,d:1,b:u,...o.IS_DEV&&{o:{loc:l.loc}}}),r=a}else c.push(p(l,n,t)),r++}return c}exports.buildIR=function(e,n={}){const{filename:t="anonymous",source:i}=n,s=r.get(t);s.clear(),performance.now();const c=m(e,[],s);for(const o of c)h(o);performance.now();const l=s.getStats(),u=c.filter(e=>1===e.d).length,a=c.filter(e=>1===e.s).length,f={t:"root",v:"1.2.0",fns:s.getFunctions(),n:c,s:{tf:l.total,cf:l.cached,dn:u,tn:c.length,sn:a},m:{t:(new Date).toISOString(),as:e.length,fn:t,...i&&{src:i}}};return o.IS_DEV,f},exports.clearIRCache=function(e){r.clear(e)},exports.transformModel=f;
1
+ "use strict";var e=Object.defineProperty,n=(n,t,o)=>((n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o)(n,"symbol"!=typeof t?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../shared/gen-function.cjs"),o=require("../../shared/env.cjs"),i=require("../../types/ast.cjs"),s=require("../../types/lifecycle.cjs"),c=/\{\{[\s\S]*?\}\}/,r=new class{constructor(){n(this,"compilers",new Map)}get(e="anonymous"){let n=this.compilers.get(e);return n||(n=new l,this.compilers.set(e,n)),n}clear(e){var n;if(e)null==(n=this.compilers.get(e))||n.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class l{constructor(){n(this,"cache",new Map),n(this,"functions",[])}makeCacheKey(e,n,t){return 0===t.length?`${e}:${n}`:`${e}:${n}:${t.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,n,i){const s=null==n?void 0:n.trim();if(!s)return 0;const c=this.makeCacheKey(e,s,i),r=this.cache.get(c);if(void 0!==r)return r;let l;try{l=t.genFunction(s,e,i)}catch(a){o.IS_DEV&&console.error(`[IR Compile Error] Type: ${e}, Expr: "${s}"`,a),l=()=>""}const u=this.functions.push(l);return this.cache.set(c,u),u}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function u(e){const n=e[0];return":"===n?{isDynamic:!0,type:"expression"}:"@"===n?{isDynamic:!0,type:"handler"}:s.isLifecycleKind(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function a(e,n,t){e.o={expr:n??"",loc:t??null}}function f(e){if(!e.attrs)return;const n=e.attrs.find(e=>"s-model"===e.key);if(!n)return;const t="$data."+n.value.replace("this.","").replace("$data.",""),o=n.loc,i=(e.tag||"").toLowerCase(),s=e.attrs.find(e=>"type"===e.key),c=(null==s?void 0:s.value)??"text";e.attrs=e.attrs.filter(e=>e!==n);const r=(n,t,i)=>{var s;null==(s=e.attrs)||s.push({key:n,value:t,role:i,loc:o})};if("input"===i){if("checkbox"===c){const n=e.attrs.find(e=>"value"===e.key),o=n?JSON.stringify(n.value):'"on"';return r(":checked",`Array.isArray(${t}) ? ${t}.includes(${o}) : ${t}`),void r("@change",`\n const _v = ${o};\n if(Array.isArray(${t})) {\n const _i = ${t}.indexOf(_v);\n if(checked && _i === -1) ${t}.push(_v);\n else if(!checked && _i > -1) ${t}.splice(_i,1);\n } else {\n ${t} = checked;\n }`,"model")}if("radio"===c){const n=e.attrs.find(e=>"value"===e.key),o=(null==n?void 0:n.value)??"null";return r(":checked",`${t} == ${JSON.stringify(o)}`),void r("@change",`if (checked) ${t} = ${JSON.stringify(o)}`,"model")}return r(":value",t),void r("@input",`${t} = value`,"model")}if("textarea"===i)return r(":value",t),void r("@input",`${t} = value`,"model");"select"!==i?(r(":value",t),r("@input",`${t} = $event`,"model")):e.attrs.some(e=>"multiple"===e.key)?(r("updated",`\n const values = Array.isArray(${t}) ? ${t} : ${t} != null ? [${t}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),r("@change",`${t} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(r(":value",t),r("@change",`${t} = value`,"model"))}function d(e,n,t,o=null){if(!e.attrs||0===e.attrs.length)return[];const i=[];for(const s of e.attrs){if(o&&o.has(s.key))continue;const{key:c,value:r,role:l}=s,{isDynamic:f,type:d}=u(c);if(f&&d){const o={k:c,f:t.compile(d,r??"",n),d:1,r:l};a(o,r,s.loc??e.loc),i.push(o)}else i.push({k:c,v:r,d:0,r:l})}return i}function v(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const n of e.c)if(!v(n))return!1;if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)if(!v(e))return!1;return!0}function p(e){if(e.c&&e.c.length>0)for(const n of e.c)p(n);if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)p(e);e.t!==i.ASTType.Element&&e.t!==i.ASTType.Text||0===e.d&&v(e)&&(e.s=1)}function h(e,n,t){var s,r,l,v,p,h;const m={t:e.type,d:0};let y=!1;var k;switch(e.type===i.ASTType.Text?(k=e.content)&&c.test(k)&&(y=!0):((null==(s=e.attrs)?void 0:s.some(e=>"s-model"===e.key||u(e.key).isDynamic))&&(y=!0),e.type===i.ASTType.For&&(y=!0)),m.d=y?1:0,e.type){case i.ASTType.Text:{const o=e.content??"";y?(m.f=t.compile("template",o,n),a(m,o,e.loc)):m.x=o;break}case i.ASTType.Element:m.g=e.tag,f(e),m.a=d(e,n,t),e.children&&(m.c=$(e.children,n,t));break;case i.ASTType.For:{const o=null==(r=e.attrs)?void 0:r.find(e=>"each"===e.key),i=(null==o?void 0:o.value)??"";m.f=t.compile("expression",i,n),m.i=(null==(v=null==(l=e.attrs)?void 0:l.find(e=>"item"===e.key))?void 0:v.value)??"item",m.n=(null==(h=null==(p=e.attrs)?void 0:p.find(e=>"index"===e.key))?void 0:h.value)??"index",a(m,i,(null==o?void 0:o.loc)??e.loc);const s=new Set(["each","item","index"]);m.a=d(e,n,t,s);const c=[...n,{i:m.i,x:m.n}];e.children&&(m.c=$(e.children,c,t));break}case i.ASTType.If:case i.ASTType.ElseIf:case i.ASTType.Else:o.IS_DEV&&console.warn(`[IR] Orphaned conditional node found: ${i.ASTType[e.type]}`),m.a=d(e,n,t),e.children&&(m.c=$(e.children,n,t));break;case i.ASTType.Comment:m.x=e.content??""}return m}function $(e,n,t){var o;const s=[];let c=0;for(;c<e.length;){const r=e[c];if(r.type===i.ASTType.If){const l=[];let u=c;for(;u<e.length;){const s=e[u],c=s.type;if(c!==i.ASTType.If&&c!==i.ASTType.ElseIf&&c!==i.ASTType.Else)break;if(c===i.ASTType.If&&l.length>0)break;let r,a=null,f="";if(c!==i.ASTType.Else){const e=null==(o=s.attrs)?void 0:o.find(e=>"test"===e.key||"condition"===e.key);f=(null==e?void 0:e.value)??"false",a=t.compile("expression",f,n),r=(null==e?void 0:e.loc)??s.loc}const v=s.children?$(s.children,n,t):[],p=d(s,n,t,new Set(["test","condition"]));if(l.push({f:a,c:v,a:p.length>0?p:void 0,o:{expr:f,loc:r}}),u++,c===i.ASTType.Else)break}s.push({t:i.ASTType.Conditional,d:1,b:l,o:{loc:r.loc}}),c=u}else s.push(h(r,n,t)),c++}return s}exports.buildIR=function(e,n={}){const{filename:t="anonymous",source:i}=n,s=r.get(t);s.clear();const c=performance.now(),l=$(e,[],s);for(const o of l)p(o);const u=performance.now(),a=s.getStats(),f=l.filter(e=>1===e.d).length,d=l.filter(e=>1===e.s).length,v={t:"root",v:"1.2.0",fns:s.getFunctions(),n:l,s:{tf:a.total,cf:a.cached,dn:f,tn:l.length,sn:d},m:{t:(new Date).toISOString(),as:e.length,fn:t,...i&&{src:i}}};return o.IS_DEV&&console.log(`[Solely] Compiled <${t}> in ${(u-c).toFixed(2)}ms | Nodes: ${l.length} | Fns: ${a.total} | StaticSubtrees: ${d}`),v},exports.clearIRCache=function(e){r.clear(e)},exports.transformModel=f;
@@ -1 +1 @@
1
- var e=Object.defineProperty,n=(n,t,o)=>((n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o)(n,"symbol"!=typeof t?t+"":t,o);import{genFunction as t}from"../../shared/gen-function.js";import{IS_DEV as o}from"../../shared/env.js";import{ASTType as i}from"../../types/ast.js";import{isLifecycleKind as s}from"../../types/lifecycle.js";const c=/\{\{[\s\S]*?\}\}/,r=new class{constructor(){n(this,"compilers",new Map)}get(e="anonymous"){let n=this.compilers.get(e);return n||(n=new l,this.compilers.set(e,n)),n}clear(e){var n;if(e)null==(n=this.compilers.get(e))||n.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class l{constructor(){n(this,"cache",new Map),n(this,"functions",[])}makeCacheKey(e,n,t){return 0===t.length?`${e}:${n}`:`${e}:${n}:${t.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,n,o){const i=null==n?void 0:n.trim();if(!i)return 0;const s=this.makeCacheKey(e,i,o),c=this.cache.get(s);if(void 0!==c)return c;let r;try{r=t(i,e,o)}catch(a){r=()=>""}const l=this.functions.push(r);return this.cache.set(s,l),l}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function a(e){const n=e[0];return":"===n?{isDynamic:!0,type:"expression"}:"@"===n?{isDynamic:!0,type:"handler"}:s(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function u(e,n,t){o&&(e.o={expr:n??"",loc:t??null})}function f(e){if(!e.attrs)return;const n=e.attrs.find(e=>"s-model"===e.key);if(!n)return;const t="$data."+n.value.replace("this.","").replace("$data.",""),o=n.loc,i=(e.tag||"").toLowerCase(),s=e.attrs.find(e=>"type"===e.key),c=(null==s?void 0:s.value)??"text";e.attrs=e.attrs.filter(e=>e!==n);const r=(n,t,i)=>{var s;null==(s=e.attrs)||s.push({key:n,value:t,role:i,loc:o})};if("input"===i){if("checkbox"===c){const n=e.attrs.find(e=>"value"===e.key),o=n?JSON.stringify(n.value):'"on"';return r(":checked",`Array.isArray(${t}) ? ${t}.includes(${o}) : ${t}`),void r("@change",`\n const _v = ${o};\n if(Array.isArray(${t})) {\n const _i = ${t}.indexOf(_v);\n if(checked && _i === -1) ${t}.push(_v);\n else if(!checked && _i > -1) ${t}.splice(_i,1);\n } else {\n ${t} = checked;\n }`,"model")}if("radio"===c){const n=e.attrs.find(e=>"value"===e.key),o=(null==n?void 0:n.value)??"null";return r(":checked",`${t} == ${JSON.stringify(o)}`),void r("@change",`if (checked) ${t} = ${JSON.stringify(o)}`,"model")}return r(":value",t),void r("@input",`${t} = value`,"model")}if("textarea"===i)return r(":value",t),void r("@input",`${t} = value`,"model");"select"!==i?(r(":value",t),r("@input",`${t} = $event`,"model")):e.attrs.some(e=>"multiple"===e.key)?(r("updated",`\n const values = Array.isArray(${t}) ? ${t} : ${t} != null ? [${t}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),r("@change",`${t} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(r(":value",t),r("@change",`${t} = value`,"model"))}function d(e,n,t,o=null){if(!e.attrs||0===e.attrs.length)return[];const i=[];for(const s of e.attrs){if(o&&o.has(s.key))continue;const{key:c,value:r,role:l}=s,{isDynamic:f,type:d}=a(c);if(f&&d){const o={k:c,f:t.compile(d,r??"",n),d:1,r:l};u(o,r,s.loc??e.loc),i.push(o)}else i.push({k:c,v:r,d:0,r:l})}return i}function v(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const n of e.c)if(!v(n))return!1;if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)if(!v(e))return!1;return!0}function m(e){if(e.c&&e.c.length>0)for(const n of e.c)m(n);if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)m(e);e.t!==i.Element&&e.t!==i.Text||0===e.d&&v(e)&&(e.s=1)}function h(e,n,t){var o,s,r,l,v,m;const h={t:e.type,d:0};let $=!1;var y;switch(e.type===i.Text?(y=e.content)&&c.test(y)&&($=!0):((null==(o=e.attrs)?void 0:o.some(e=>"s-model"===e.key||a(e.key).isDynamic))&&($=!0),e.type===i.For&&($=!0)),h.d=$?1:0,e.type){case i.Text:{const o=e.content??"";$?(h.f=t.compile("template",o,n),u(h,o,e.loc)):h.x=o;break}case i.Element:h.g=e.tag,f(e),h.a=d(e,n,t),e.children&&(h.c=p(e.children,n,t));break;case i.For:{const o=null==(s=e.attrs)?void 0:s.find(e=>"each"===e.key),i=(null==o?void 0:o.value)??"";h.f=t.compile("expression",i,n),h.i=(null==(l=null==(r=e.attrs)?void 0:r.find(e=>"item"===e.key))?void 0:l.value)??"item",h.n=(null==(m=null==(v=e.attrs)?void 0:v.find(e=>"index"===e.key))?void 0:m.value)??"index",u(h,i,(null==o?void 0:o.loc)??e.loc);const c=new Set(["each","item","index"]);h.a=d(e,n,t,c);const a=[...n,{i:h.i,x:h.n}];e.children&&(h.c=p(e.children,a,t));break}case i.If:case i.ElseIf:case i.Else:h.a=d(e,n,t),e.children&&(h.c=p(e.children,n,t));break;case i.Comment:h.x=e.content??""}return h}function p(e,n,t){var s;const c=[];let r=0;for(;r<e.length;){const l=e[r];if(l.type===i.If){const a=[];let u=r;for(;u<e.length;){const c=e[u],r=c.type;if(r!==i.If&&r!==i.ElseIf&&r!==i.Else)break;if(r===i.If&&a.length>0)break;let l,f=null,v="";if(r!==i.Else){const e=null==(s=c.attrs)?void 0:s.find(e=>"test"===e.key||"condition"===e.key);v=(null==e?void 0:e.value)??"false",f=t.compile("expression",v,n),l=(null==e?void 0:e.loc)??c.loc}const m=c.children?p(c.children,n,t):[],h=d(c,n,t,new Set(["test","condition"]));if(a.push({f:f,c:m,a:h.length>0?h:void 0,...o&&{o:{expr:v,loc:l}}}),u++,r===i.Else)break}c.push({t:i.Conditional,d:1,b:a,...o&&{o:{loc:l.loc}}}),r=u}else c.push(h(l,n,t)),r++}return c}function $(e,n={}){const{filename:t="anonymous",source:o}=n,i=r.get(t);i.clear(),performance.now();const s=p(e,[],i);for(const r of s)m(r);performance.now();const c=i.getStats(),l=s.filter(e=>1===e.d).length,a=s.filter(e=>1===e.s).length;return{t:"root",v:"1.2.0",fns:i.getFunctions(),n:s,s:{tf:c.total,cf:c.cached,dn:l,tn:s.length,sn:a},m:{t:(new Date).toISOString(),as:e.length,fn:t,...o&&{src:o}}}}function y(e){r.clear(e)}export{$ as buildIR,y as clearIRCache,f as transformModel};
1
+ var e=Object.defineProperty,n=(n,t,o)=>((n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o)(n,"symbol"!=typeof t?t+"":t,o);import{genFunction as t}from"../../shared/gen-function.js";import{IS_DEV as o}from"../../shared/env.js";import{ASTType as i}from"../../types/ast.js";import{isLifecycleKind as s}from"../../types/lifecycle.js";const c=/\{\{[\s\S]*?\}\}/,r=new class{constructor(){n(this,"compilers",new Map)}get(e="anonymous"){let n=this.compilers.get(e);return n||(n=new l,this.compilers.set(e,n)),n}clear(e){var n;if(e)null==(n=this.compilers.get(e))||n.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class l{constructor(){n(this,"cache",new Map),n(this,"functions",[])}makeCacheKey(e,n,t){return 0===t.length?`${e}:${n}`:`${e}:${n}:${t.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,n,i){const s=null==n?void 0:n.trim();if(!s)return 0;const c=this.makeCacheKey(e,s,i),r=this.cache.get(c);if(void 0!==r)return r;let l;try{l=t(s,e,i)}catch(u){o&&console.error(`[IR Compile Error] Type: ${e}, Expr: "${s}"`,u),l=()=>""}const a=this.functions.push(l);return this.cache.set(c,a),a}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function a(e){const n=e[0];return":"===n?{isDynamic:!0,type:"expression"}:"@"===n?{isDynamic:!0,type:"handler"}:s(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function u(e,n,t){e.o={expr:n??"",loc:t??null}}function f(e){if(!e.attrs)return;const n=e.attrs.find(e=>"s-model"===e.key);if(!n)return;const t="$data."+n.value.replace("this.","").replace("$data.",""),o=n.loc,i=(e.tag||"").toLowerCase(),s=e.attrs.find(e=>"type"===e.key),c=(null==s?void 0:s.value)??"text";e.attrs=e.attrs.filter(e=>e!==n);const r=(n,t,i)=>{var s;null==(s=e.attrs)||s.push({key:n,value:t,role:i,loc:o})};if("input"===i){if("checkbox"===c){const n=e.attrs.find(e=>"value"===e.key),o=n?JSON.stringify(n.value):'"on"';return r(":checked",`Array.isArray(${t}) ? ${t}.includes(${o}) : ${t}`),void r("@change",`\n const _v = ${o};\n if(Array.isArray(${t})) {\n const _i = ${t}.indexOf(_v);\n if(checked && _i === -1) ${t}.push(_v);\n else if(!checked && _i > -1) ${t}.splice(_i,1);\n } else {\n ${t} = checked;\n }`,"model")}if("radio"===c){const n=e.attrs.find(e=>"value"===e.key),o=(null==n?void 0:n.value)??"null";return r(":checked",`${t} == ${JSON.stringify(o)}`),void r("@change",`if (checked) ${t} = ${JSON.stringify(o)}`,"model")}return r(":value",t),void r("@input",`${t} = value`,"model")}if("textarea"===i)return r(":value",t),void r("@input",`${t} = value`,"model");"select"!==i?(r(":value",t),r("@input",`${t} = $event`,"model")):e.attrs.some(e=>"multiple"===e.key)?(r("updated",`\n const values = Array.isArray(${t}) ? ${t} : ${t} != null ? [${t}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),r("@change",`${t} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(r(":value",t),r("@change",`${t} = value`,"model"))}function d(e,n,t,o=null){if(!e.attrs||0===e.attrs.length)return[];const i=[];for(const s of e.attrs){if(o&&o.has(s.key))continue;const{key:c,value:r,role:l}=s,{isDynamic:f,type:d}=a(c);if(f&&d){const o={k:c,f:t.compile(d,r??"",n),d:1,r:l};u(o,r,s.loc??e.loc),i.push(o)}else i.push({k:c,v:r,d:0,r:l})}return i}function v(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const n of e.c)if(!v(n))return!1;if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)if(!v(e))return!1;return!0}function m(e){if(e.c&&e.c.length>0)for(const n of e.c)m(n);if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)m(e);e.t!==i.Element&&e.t!==i.Text||0===e.d&&v(e)&&(e.s=1)}function p(e,n,t){var s,r,l,v,m,p;const $={t:e.type,d:0};let y=!1;var k;switch(e.type===i.Text?(k=e.content)&&c.test(k)&&(y=!0):((null==(s=e.attrs)?void 0:s.some(e=>"s-model"===e.key||a(e.key).isDynamic))&&(y=!0),e.type===i.For&&(y=!0)),$.d=y?1:0,e.type){case i.Text:{const o=e.content??"";y?($.f=t.compile("template",o,n),u($,o,e.loc)):$.x=o;break}case i.Element:$.g=e.tag,f(e),$.a=d(e,n,t),e.children&&($.c=h(e.children,n,t));break;case i.For:{const o=null==(r=e.attrs)?void 0:r.find(e=>"each"===e.key),i=(null==o?void 0:o.value)??"";$.f=t.compile("expression",i,n),$.i=(null==(v=null==(l=e.attrs)?void 0:l.find(e=>"item"===e.key))?void 0:v.value)??"item",$.n=(null==(p=null==(m=e.attrs)?void 0:m.find(e=>"index"===e.key))?void 0:p.value)??"index",u($,i,(null==o?void 0:o.loc)??e.loc);const s=new Set(["each","item","index"]);$.a=d(e,n,t,s);const c=[...n,{i:$.i,x:$.n}];e.children&&($.c=h(e.children,c,t));break}case i.If:case i.ElseIf:case i.Else:o&&console.warn(`[IR] Orphaned conditional node found: ${i[e.type]}`),$.a=d(e,n,t),e.children&&($.c=h(e.children,n,t));break;case i.Comment:$.x=e.content??""}return $}function h(e,n,t){var o;const s=[];let c=0;for(;c<e.length;){const r=e[c];if(r.type===i.If){const l=[];let a=c;for(;a<e.length;){const s=e[a],c=s.type;if(c!==i.If&&c!==i.ElseIf&&c!==i.Else)break;if(c===i.If&&l.length>0)break;let r,u=null,f="";if(c!==i.Else){const e=null==(o=s.attrs)?void 0:o.find(e=>"test"===e.key||"condition"===e.key);f=(null==e?void 0:e.value)??"false",u=t.compile("expression",f,n),r=(null==e?void 0:e.loc)??s.loc}const v=s.children?h(s.children,n,t):[],m=d(s,n,t,new Set(["test","condition"]));if(l.push({f:u,c:v,a:m.length>0?m:void 0,o:{expr:f,loc:r}}),a++,c===i.Else)break}s.push({t:i.Conditional,d:1,b:l,o:{loc:r.loc}}),c=a}else s.push(p(r,n,t)),c++}return s}function $(e,n={}){const{filename:t="anonymous",source:i}=n,s=r.get(t);s.clear();const c=performance.now(),l=h(e,[],s);for(const o of l)m(o);const a=performance.now(),u=s.getStats(),f=l.filter(e=>1===e.d).length,d=l.filter(e=>1===e.s).length,v={t:"root",v:"1.2.0",fns:s.getFunctions(),n:l,s:{tf:u.total,cf:u.cached,dn:f,tn:l.length,sn:d},m:{t:(new Date).toISOString(),as:e.length,fn:t,...i&&{src:i}}};return o&&console.log(`[Solely] Compiled <${t}> in ${(a-c).toFixed(2)}ms | Nodes: ${l.length} | Fns: ${u.total} | StaticSubtrees: ${d}`),v}function y(e){r.clear(e)}export{$ as buildIR,y as clearIRCache,f as transformModel};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./router/core.cjs"),r=require("./router/router-view.cjs"),s=require("./router/router-link.cjs"),t=require("./shared/templateError.cjs"),o=require("./shared/gen-function.cjs"),p=require("./shared/functions.cjs"),i=require("./shared/event-listeners.cjs"),u=require("./shared/is-object.cjs"),c=require("./shared/url.cjs"),x=require("./shared/env.cjs"),n=require("./types/ast.cjs"),j=require("./types/lifecycle.cjs"),q=require("./runtime/component/base-element.cjs"),a=require("./compiler/ir/buildIR.cjs"),l=require("./compiler/parser/parser.cjs"),d=require("./runtime/reactivity/observe.cjs"),m=require("./runtime/component/decorators.cjs"),h=require("./runtime/renderer/renderIR.cjs");exports.Router=e.Router,exports.createRouter=e.createRouter,exports.getRouter=e.getRouter,exports.routerReady=e.routerReady,exports.RouterView=r.default,exports.RouterLink=s.default,exports.showTemplateError=t.showTemplateError,exports.genFunction=o.genFunction,exports.createFunction=p.createFunction,exports.listeners=i.default,exports.isObject=u.isObject,exports.parseHashUrl=c.parseHashUrl,exports.IS_DEV=x.IS_DEV,exports.IS_PROD=x.IS_PROD,exports.ASTType=n.ASTType,exports.LIFECYCLE_ATTRS_MAP=j.LIFECYCLE_ATTRS_MAP,exports.isLifecycleKind=j.isLifecycleKind,exports.mapAttrKeyToLifecycleKind=j.mapAttrKeyToLifecycleKind,exports.BaseElement=q.default,exports.buildIR=a.buildIR,exports.clearIRCache=a.clearIRCache,exports.transformModel=a.transformModel,exports.parseHtml=l.parseHtml,exports.isProxy=d.isProxy,exports.observe=d.observe,exports.toRaw=d.toRaw,exports.CustomElement=m.CustomElement,exports.IRRenderer=h.IRRenderer,exports.createRender=h.createRender;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./router/index.cjs"),r=require("./shared/templateError.cjs"),s=require("./shared/gen-function.cjs"),t=require("./shared/functions.cjs"),o=require("./shared/event-listeners.cjs"),i=require("./shared/is-object.cjs"),u=require("./shared/url.cjs"),p=require("./shared/env.cjs"),c=require("./types/ast.cjs"),x=require("./types/lifecycle.cjs"),n=require("./router/router-view.cjs"),j=require("./router/router-link.cjs"),q=require("./runtime/component/base-element.cjs"),a=require("./compiler/ir/buildIR.cjs"),l=require("./compiler/parser/parser.cjs"),d=require("./router/core.cjs"),m=require("./runtime/reactivity/observe.cjs"),b=require("./runtime/component/decorators.cjs"),h=require("./runtime/renderer/renderIR.cjs");exports.createRouter=e.createRouter,exports.showTemplateError=r.showTemplateError,exports.genFunction=s.genFunction,exports.createFunction=t.createFunction,exports.listeners=o.default,exports.isObject=i.isObject,exports.parseHashUrl=u.parseHashUrl,exports.IS_DEV=p.IS_DEV,exports.IS_PROD=p.IS_PROD,exports.ASTType=c.ASTType,exports.LIFECYCLE_ATTRS_MAP=x.LIFECYCLE_ATTRS_MAP,exports.isLifecycleKind=x.isLifecycleKind,exports.mapAttrKeyToLifecycleKind=x.mapAttrKeyToLifecycleKind,Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>n.default}),Object.defineProperty(exports,"RouterLink",{enumerable:!0,get:()=>j.default}),exports.BaseElement=q.default,exports.buildIR=a.buildIR,exports.clearIRCache=a.clearIRCache,exports.transformModel=a.transformModel,exports.parseHtml=l.parseHtml,exports.Router=d.Router,exports.getRouter=d.getRouter,exports.routerReady=d.routerReady,exports.isProxy=m.isProxy,exports.observe=m.observe,exports.toRaw=m.toRaw,exports.CustomElement=b.CustomElement,exports.IRRenderer=h.IRRenderer,exports.createRender=h.createRender;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Router as r,createRouter as e,getRouter as o,routerReady as t}from"./router/core.js";import{default as s}from"./router/router-view.js";import{default as m}from"./router/router-link.js";import{showTemplateError as i}from"./shared/templateError.js";import{genFunction as p}from"./shared/gen-function.js";import{createFunction as a}from"./shared/functions.js";import{default as f}from"./shared/event-listeners.js";import{isObject as n}from"./shared/is-object.js";import{parseHashUrl as j}from"./shared/url.js";import{IS_DEV as u,IS_PROD as l}from"./shared/env.js";import{ASTType as d}from"./types/ast.js";import{LIFECYCLE_ATTRS_MAP as c,isLifecycleKind as h,mapAttrKeyToLifecycleKind as v}from"./types/lifecycle.js";import{default as b}from"./runtime/component/base-element.js";import{buildIR as y,clearIRCache as R,transformModel as k}from"./compiler/ir/buildIR.js";import{parseHtml as w}from"./compiler/parser/parser.js";import{isProxy as E,observe as I,toRaw as g}from"./runtime/reactivity/observe.js";import{CustomElement as x}from"./runtime/component/decorators.js";import{IRRenderer as B,createRender as L}from"./runtime/renderer/renderIR.js";export{d as ASTType,b as BaseElement,x as CustomElement,B as IRRenderer,u as IS_DEV,l as IS_PROD,c as LIFECYCLE_ATTRS_MAP,r as Router,m as RouterLink,s as RouterView,y as buildIR,R as clearIRCache,a as createFunction,L as createRender,e as createRouter,p as genFunction,o as getRouter,h as isLifecycleKind,n as isObject,E as isProxy,f as listeners,v as mapAttrKeyToLifecycleKind,I as observe,j as parseHashUrl,w as parseHtml,t as routerReady,i as showTemplateError,g as toRaw,k as transformModel};
1
+ import{createRouter as r}from"./router/index.js";import{showTemplateError as e}from"./shared/templateError.js";import{genFunction as o}from"./shared/gen-function.js";import{createFunction as t}from"./shared/functions.js";import{default as m}from"./shared/event-listeners.js";import{isObject as s}from"./shared/is-object.js";import{parseHashUrl as i}from"./shared/url.js";import{IS_DEV as p,IS_PROD as a}from"./shared/env.js";import{ASTType as f}from"./types/ast.js";import{LIFECYCLE_ATTRS_MAP as n,isLifecycleKind as j,mapAttrKeyToLifecycleKind as u}from"./types/lifecycle.js";import{default as d}from"./router/router-view.js";import{default as l}from"./router/router-link.js";import{default as c}from"./runtime/component/base-element.js";import{buildIR as h,clearIRCache as v,transformModel as b}from"./compiler/ir/buildIR.js";import{parseHtml as y}from"./compiler/parser/parser.js";import{Router as R,getRouter as k,routerReady as w}from"./router/core.js";import{isProxy as x,observe as E,toRaw as I}from"./runtime/reactivity/observe.js";import{CustomElement as g}from"./runtime/component/decorators.js";import{IRRenderer as B,createRender as L}from"./runtime/renderer/renderIR.js";export{f as ASTType,c as BaseElement,g as CustomElement,B as IRRenderer,p as IS_DEV,a as IS_PROD,n as LIFECYCLE_ATTRS_MAP,R as Router,l as RouterLink,d as RouterView,h as buildIR,v as clearIRCache,t as createFunction,L as createRender,r as createRouter,o as genFunction,k as getRouter,j as isLifecycleKind,s as isObject,x as isProxy,m as listeners,u as mapAttrKeyToLifecycleKind,E as observe,i as parseHashUrl,y as parseHtml,w as routerReady,e as showTemplateError,I as toRaw,b as transformModel};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{o:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("magic-string"),e=require("../compiler/parser/parser.cjs"),o=require("../compiler/ir/buildIR.cjs"),r={precompile:!0,sourceMap:!0,minify:!1,include:[/\.html(?:\?|$)/],exclude:/node_modules/,debug:!1};function t(n,r="anonymous"){const t=e.parseHtml(n);return o.buildIR(t,{filename:r,source:n})}function u(n,e){return(Array.isArray(e)?e:[e]).some(e=>"string"==typeof e?n.includes(e):e.test(n))}function l(e,o,r){const t=new n.default(e),u=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$");return t.overwrite(0,e.length,`\nconst __SOLELY_TEMPLATE__ = \`${u}\`;\n\nexport default __SOLELY_TEMPLATE__;\nexport { __SOLELY_TEMPLATE__ };\n`),{code:t.toString(),map:t.generateMap({source:o,includeContent:!r})}}function c(e={}){const o={...r,...e};return{name:"solely-vite-plugin",enforce:"pre",configResolved(n){o.debug},transform(e,r){if(!u(r,o.include)||u(r,o.exclude))return null;if(!r.includes(".html?solely"))return null;try{if(o.debug,o.precompile){const u=function(e,o,r,t){const u=new n.default(o);u.remove(0,o.length),t||(u.append("\n// ============================================\n"),u.append("// Solely Precompiled Template\n"),u.append(`// Compiled at: ${(new Date).toISOString()}\n`),u.append("// ============================================\n\n")),u.append("const __SOLELY_IR__ = {\n"),u.append(" t: 'root',\n"),u.append(` v: '${e.v}',\n\n`),t||u.append(" // 编译后的函数数组\n"),u.append(" fns: [\n"),e.fns.forEach((n,o)=>{const r="string"==typeof n?n:n.toString(),l=o===e.fns.length-1;t||u.append(` // Function ${o+1}\n`),u.append(` ${r}${l?"":","}\n`)}),u.append(" ],\n\n");const l=n=>{const e={t:n.t,d:n.d};return void 0!==n.g&&(e.g=n.g),void 0!==n.x&&(e.x=n.x),void 0!==n.f&&(e.f=n.f),void 0!==n.i&&(e.i=n.i),void 0!==n.n&&(e.n=n.n),!t&&n.u&&(e.u={...n.u}),n.a&&(e.a=n.a.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r}))),n.c&&(e.c=n.c.map(l)),n.b&&(e.b=n.b.map(n=>{var e;return{f:n.f,c:n.c.map(l),a:null==(e=n.a)?void 0:e.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r})),...!t&&n.u&&{u:{...n.u}}}})),e},c=e.n.map(l);return t||u.append(" // IR 节点树\n"),u.append(` n: ${JSON.stringify(c,null,t?0:2)},\n\n`),t||u.append(" // 编译统计\n"),u.append(` s: ${JSON.stringify(e.s)},\n\n`),t||(u.append(" // 元数据\n"),u.append(` m: ${JSON.stringify(e.m)}\n`)),u.append("};\n\n"),t||u.append("// 导出 IR 对象\n"),u.append("export default __SOLELY_IR__;\n"),u.append("export { __SOLELY_IR__ };\n\n"),t||u.append("// 同时导出模板字符串(向后兼容)\n"),u.append("export const __SOLELY_TEMPLATE__ = '';\n"),{code:u.toString(),map:u.generateMap({source:r,includeContent:!t,hires:!t})}}(t(e,r),e,r,!!o.minify);return o.debug,{code:u.code,map:o.sourceMap?u.map:null}}{const n=l(e,r,!!o.minify);return{code:n.code,map:o.sourceMap?n.map:null}}}catch(c){c instanceof Error?c.message:String(c);const n=l(e,r,!!o.minify);return{code:n.code,map:o.sourceMap?n.map:null}}},handleHotUpdate({file:n,server:e,modules:r}){if(u(n,o.include)&&!u(n,o.exclude))return o.debug,e.ws.send({type:"full-reload",path:"*"}),r}}}"undefined"!=typeof window&&(window.__SOLELY_VITE_PLUGIN__=c),exports.compileTemplate=t,exports.default=c,exports.solelyVitePlugin=c;
1
+ "use strict";Object.defineProperties(exports,{o:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("magic-string"),e=require("../compiler/parser/parser.cjs"),o=require("../compiler/ir/buildIR.cjs"),r={precompile:!0,sourceMap:!0,minify:!1,include:[/\.html(?:\?|$)/],exclude:/node_modules/,debug:!1};function t(n,r="anonymous"){const t=e.parseHtml(n);return o.buildIR(t,{filename:r,source:n})}function l(n,e){return(Array.isArray(e)?e:[e]).some(e=>"string"==typeof e?n.includes(e):e.test(n))}function i(e,o,r){const t=new n.default(e),l=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$");return t.overwrite(0,e.length,`\nconst __SOLELY_TEMPLATE__ = \`${l}\`;\n\nexport default __SOLELY_TEMPLATE__;\nexport { __SOLELY_TEMPLATE__ };\n`),{code:t.toString(),map:t.generateMap({source:o,includeContent:!r})}}function c(e={}){const o={...r,...e};return{name:"solely-vite-plugin",enforce:"pre",configResolved(n){o.debug&&console.log("[Solely] Plugin initialized with options:",o)},transform(e,r){if(!l(r,o.include)||l(r,o.exclude))return null;if(!r.includes(".html?solely"))return null;try{if(o.debug&&console.log(`[Solely] Processing: ${r}`),o.precompile){const l=t(e,r),i=function(e,o,r,t){const l=new n.default(o);l.remove(0,o.length),t||(l.append("\n// ============================================\n"),l.append("// Solely Precompiled Template\n"),l.append(`// Compiled at: ${(new Date).toISOString()}\n`),l.append("// ============================================\n\n")),l.append("const __SOLELY_IR__ = {\n"),l.append(" t: 'root',\n"),l.append(` v: '${e.v}',\n\n`),t||l.append(" // 编译后的函数数组\n"),l.append(" fns: [\n"),e.fns.forEach((n,o)=>{const r="string"==typeof n?n:n.toString(),i=o===e.fns.length-1;t||l.append(` // Function ${o+1}\n`),l.append(` ${r}${i?"":","}\n`)}),l.append(" ],\n\n");const i=n=>{const e={t:n.t,d:n.d};return void 0!==n.s&&(e.s=n.s),void 0!==n.g&&(e.g=n.g),void 0!==n.x&&(e.x=n.x),void 0!==n.f&&(e.f=n.f),void 0!==n.i&&(e.i=n.i),void 0!==n.n&&(e.n=n.n),!t&&n.l&&(e.l={...n.l}),n.a&&(e.a=n.a.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r}))),n.c&&(e.c=n.c.map(i)),n.b&&(e.b=n.b.map(n=>{var e;return{f:n.f,c:n.c.map(i),a:null==(e=n.a)?void 0:e.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r})),...!t&&n.l&&{l:{...n.l}}}})),e},c=e.n.map(i);return t||l.append(" // IR 节点树\n"),l.append(` n: ${JSON.stringify(c,null,t?0:2)},\n\n`),t||l.append(" // 编译统计\n"),l.append(` s: ${JSON.stringify(e.s)},\n\n`),t||(l.append(" // 元数据\n"),l.append(` m: ${JSON.stringify(e.m)}\n`)),l.append("};\n\n"),t||l.append("// 导出 IR 对象\n"),l.append("export default __SOLELY_IR__;\n"),l.append("export { __SOLELY_IR__ };\n\n"),t||l.append("// 同时导出模板字符串(向后兼容)\n"),l.append("export const __SOLELY_TEMPLATE__ = '';\n"),{code:l.toString(),map:l.generateMap({source:r,includeContent:!t,hires:!t})}}(l,e,r,!!o.minify);return o.debug&&(console.log(`[Solely] Compiled IR for: ${r}`),console.log("[Solely] Stats:",l.s)),{code:i.code,map:o.sourceMap?i.map:null}}{const n=i(e,r,!!o.minify);return{code:n.code,map:o.sourceMap?n.map:null}}}catch(c){const n=`[Solely] Error processing ${r}: ${c instanceof Error?c.message:String(c)}`;console.error(n),console.warn(`[Solely] Falling back to raw template for: ${r}`);const t=i(e,r,!!o.minify);return{code:t.code,map:o.sourceMap?t.map:null}}},handleHotUpdate({file:n,server:e,modules:r}){if(l(n,o.include)&&!l(n,o.exclude))return o.debug&&console.log(`[Solely] HMR triggered for: ${n}`),e.ws.send({type:"full-reload",path:"*"}),r}}}"undefined"!=typeof window&&(window.__SOLELY_VITE_PLUGIN__=c),exports.compileTemplate=t,exports.default=c,exports.solelyVitePlugin=c;
@@ -1 +1 @@
1
- import n from"magic-string";import{parseHtml as e}from"../compiler/parser/parser.js";import{buildIR as o}from"../compiler/ir/buildIR.js";const r={precompile:!0,sourceMap:!0,minify:!1,include:[/\.html(?:\?|$)/],exclude:/node_modules/,debug:!1};function t(n,r="anonymous"){const t=e(n);return o(t,{filename:r,source:n})}function i(n,e){return(Array.isArray(e)?e:[e]).some(e=>"string"==typeof e?n.includes(e):e.test(n))}function l(e,o,r){const t=new n(e),i=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$");return t.overwrite(0,e.length,`\nconst __SOLELY_TEMPLATE__ = \`${i}\`;\n\nexport default __SOLELY_TEMPLATE__;\nexport { __SOLELY_TEMPLATE__ };\n`),{code:t.toString(),map:t.generateMap({source:o,includeContent:!r})}}function u(e={}){const o={...r,...e};return{name:"solely-vite-plugin",enforce:"pre",configResolved(n){o.debug},transform(e,r){if(!i(r,o.include)||i(r,o.exclude))return null;if(!r.includes(".html?solely"))return null;try{if(o.debug,o.precompile){const i=function(e,o,r,t){const i=new n(o);i.remove(0,o.length),t||(i.append("\n// ============================================\n"),i.append("// Solely Precompiled Template\n"),i.append(`// Compiled at: ${(new Date).toISOString()}\n`),i.append("// ============================================\n\n")),i.append("const __SOLELY_IR__ = {\n"),i.append(" t: 'root',\n"),i.append(` v: '${e.v}',\n\n`),t||i.append(" // 编译后的函数数组\n"),i.append(" fns: [\n"),e.fns.forEach((n,o)=>{const r="string"==typeof n?n:n.toString(),l=o===e.fns.length-1;t||i.append(` // Function ${o+1}\n`),i.append(` ${r}${l?"":","}\n`)}),i.append(" ],\n\n");const l=n=>{const e={t:n.t,d:n.d};return void 0!==n.g&&(e.g=n.g),void 0!==n.x&&(e.x=n.x),void 0!==n.f&&(e.f=n.f),void 0!==n.i&&(e.i=n.i),void 0!==n.n&&(e.n=n.n),!t&&n.o&&(e.o={...n.o}),n.a&&(e.a=n.a.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r}))),n.c&&(e.c=n.c.map(l)),n.b&&(e.b=n.b.map(n=>{var e;return{f:n.f,c:n.c.map(l),a:null==(e=n.a)?void 0:e.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r})),...!t&&n.o&&{o:{...n.o}}}})),e},u=e.n.map(l);return t||i.append(" // IR 节点树\n"),i.append(` n: ${JSON.stringify(u,null,t?0:2)},\n\n`),t||i.append(" // 编译统计\n"),i.append(` s: ${JSON.stringify(e.s)},\n\n`),t||(i.append(" // 元数据\n"),i.append(` m: ${JSON.stringify(e.m)}\n`)),i.append("};\n\n"),t||i.append("// 导出 IR 对象\n"),i.append("export default __SOLELY_IR__;\n"),i.append("export { __SOLELY_IR__ };\n\n"),t||i.append("// 同时导出模板字符串(向后兼容)\n"),i.append("export const __SOLELY_TEMPLATE__ = '';\n"),{code:i.toString(),map:i.generateMap({source:r,includeContent:!t,hires:!t})}}(t(e,r),e,r,!!o.minify);return o.debug,{code:i.code,map:o.sourceMap?i.map:null}}{const n=l(e,r,!!o.minify);return{code:n.code,map:o.sourceMap?n.map:null}}}catch(u){u instanceof Error?u.message:String(u);const n=l(e,r,!!o.minify);return{code:n.code,map:o.sourceMap?n.map:null}}},handleHotUpdate({file:n,server:e,modules:r}){if(i(n,o.include)&&!i(n,o.exclude))return o.debug,e.ws.send({type:"full-reload",path:"*"}),r}}}"undefined"!=typeof window&&(window.__SOLELY_VITE_PLUGIN__=u);export{t as compileTemplate,u as default,u as solelyVitePlugin};
1
+ import n from"magic-string";import{parseHtml as o}from"../compiler/parser/parser.js";import{buildIR as e}from"../compiler/ir/buildIR.js";const r={precompile:!0,sourceMap:!0,minify:!1,include:[/\.html(?:\?|$)/],exclude:/node_modules/,debug:!1};function t(n,r="anonymous"){const t=o(n);return e(t,{filename:r,source:n})}function l(n,o){return(Array.isArray(o)?o:[o]).some(o=>"string"==typeof o?n.includes(o):o.test(n))}function i(o,e,r){const t=new n(o),l=o.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$");return t.overwrite(0,o.length,`\nconst __SOLELY_TEMPLATE__ = \`${l}\`;\n\nexport default __SOLELY_TEMPLATE__;\nexport { __SOLELY_TEMPLATE__ };\n`),{code:t.toString(),map:t.generateMap({source:e,includeContent:!r})}}function c(o={}){const e={...r,...o};return{name:"solely-vite-plugin",enforce:"pre",configResolved(n){e.debug&&console.log("[Solely] Plugin initialized with options:",e)},transform(o,r){if(!l(r,e.include)||l(r,e.exclude))return null;if(!r.includes(".html?solely"))return null;try{if(e.debug&&console.log(`[Solely] Processing: ${r}`),e.precompile){const l=t(o,r),i=function(o,e,r,t){const l=new n(e);l.remove(0,e.length),t||(l.append("\n// ============================================\n"),l.append("// Solely Precompiled Template\n"),l.append(`// Compiled at: ${(new Date).toISOString()}\n`),l.append("// ============================================\n\n")),l.append("const __SOLELY_IR__ = {\n"),l.append(" t: 'root',\n"),l.append(` v: '${o.v}',\n\n`),t||l.append(" // 编译后的函数数组\n"),l.append(" fns: [\n"),o.fns.forEach((n,e)=>{const r="string"==typeof n?n:n.toString(),i=e===o.fns.length-1;t||l.append(` // Function ${e+1}\n`),l.append(` ${r}${i?"":","}\n`)}),l.append(" ],\n\n");const i=n=>{const o={t:n.t,d:n.d};return void 0!==n.s&&(o.s=n.s),void 0!==n.g&&(o.g=n.g),void 0!==n.x&&(o.x=n.x),void 0!==n.f&&(o.f=n.f),void 0!==n.i&&(o.i=n.i),void 0!==n.n&&(o.n=n.n),!t&&n.o&&(o.o={...n.o}),n.a&&(o.a=n.a.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r}))),n.c&&(o.c=n.c.map(i)),n.b&&(o.b=n.b.map(n=>{var o;return{f:n.f,c:n.c.map(i),a:null==(o=n.a)?void 0:o.map(n=>({k:n.k,v:n.v,f:n.f,d:n.d,r:n.r})),...!t&&n.o&&{o:{...n.o}}}})),o},c=o.n.map(i);return t||l.append(" // IR 节点树\n"),l.append(` n: ${JSON.stringify(c,null,t?0:2)},\n\n`),t||l.append(" // 编译统计\n"),l.append(` s: ${JSON.stringify(o.s)},\n\n`),t||(l.append(" // 元数据\n"),l.append(` m: ${JSON.stringify(o.m)}\n`)),l.append("};\n\n"),t||l.append("// 导出 IR 对象\n"),l.append("export default __SOLELY_IR__;\n"),l.append("export { __SOLELY_IR__ };\n\n"),t||l.append("// 同时导出模板字符串(向后兼容)\n"),l.append("export const __SOLELY_TEMPLATE__ = '';\n"),{code:l.toString(),map:l.generateMap({source:r,includeContent:!t,hires:!t})}}(l,o,r,!!e.minify);return e.debug&&(console.log(`[Solely] Compiled IR for: ${r}`),console.log("[Solely] Stats:",l.s)),{code:i.code,map:e.sourceMap?i.map:null}}{const n=i(o,r,!!e.minify);return{code:n.code,map:e.sourceMap?n.map:null}}}catch(c){const n=`[Solely] Error processing ${r}: ${c instanceof Error?c.message:String(c)}`;console.error(n),console.warn(`[Solely] Falling back to raw template for: ${r}`);const t=i(o,r,!!e.minify);return{code:t.code,map:e.sourceMap?t.map:null}}},handleHotUpdate({file:n,server:o,modules:r}){if(l(n,e.include)&&!l(n,e.exclude))return e.debug&&console.log(`[Solely] HMR triggered for: ${n}`),o.ws.send({type:"full-reload",path:"*"}),r}}}"undefined"!=typeof window&&(window.__SOLELY_VITE_PLUGIN__=c);export{t as compileTemplate,c as default,c as solelyVitePlugin};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./core.cjs"),r=require("./router-view.cjs"),o=require("./router-link.cjs");exports.Router=e.Router,exports.createRouter=e.createRouter,exports.getRouter=e.getRouter,exports.routerReady=e.routerReady,exports.RouterView=r.default,exports.RouterLink=o.default;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./core.cjs"),r=require("./router-view.cjs"),t=require("./router-link.cjs");exports.Router=e.Router,exports.getRouter=e.getRouter,exports.routerReady=e.routerReady,Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>r.default}),Object.defineProperty(exports,"RouterLink",{enumerable:!0,get:()=>t.default}),exports.createRouter=function(o){if(void 0===r.default||void 0===t.default)throw new Error("RouterView or RouterLink is not defined");return e.createRouter(o)};
@@ -1,6 +1,12 @@
1
- import { Router, createRouter, getRouter, routerReady } from './core';
1
+ import { Router, getRouter, routerReady } from './core';
2
2
  import { default as RouterView } from './router-view';
3
3
  import { default as RouterLink } from './router-link';
4
4
  import { RouteConfig, RouteMatch, NavigationGuard, RouterOptions, NavigationResult } from './types';
5
- export { Router, RouterView, RouterLink, createRouter, getRouter, routerReady };
5
+ /**
6
+ * 创建路由器实例(自动注册 RouterView 和 RouterLink 组件)
7
+ * @param options 路由器配置选项
8
+ * @returns 路由器实例
9
+ */
10
+ export declare function createRouter(options: RouterOptions): Router;
11
+ export { Router, RouterView, RouterLink, getRouter, routerReady };
6
12
  export type { RouteConfig, RouteMatch, NavigationGuard, RouterOptions, NavigationResult };
@@ -1 +1 @@
1
- import{Router as r,createRouter as o,getRouter as e,routerReady as t}from"./core.js";import{default as i}from"./router-view.js";import{default as s}from"./router-link.js";export{r as Router,s as RouterLink,i as RouterView,o as createRouter,e as getRouter,t as routerReady};
1
+ import{createRouter as r}from"./core.js";import{Router as o,getRouter as e,routerReady as t}from"./core.js";import i from"./router-view.js";import m from"./router-link.js";function n(o){if(void 0===i||void 0===m)throw new Error("RouterView or RouterLink is not defined");return r(o)}export{o as Router,m as RouterLink,i as RouterView,n as createRouter,e as getRouter,t as routerReady};
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty;Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./core.cjs"),s=require("../runtime/component/base-element.cjs"),n=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;let o=class extends s.default{constructor(){var e;super(...arguments),((e,s,n)=>{s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n})(this,"symbol"!=typeof(e="_prefetched")?e+"":e,!1)}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){(await e.routerReady).listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",t=>{var s,n;t.defaultPrevented||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||0===t.button&&((null==(s=t.target.closest("a"))?void 0:s.getAttribute("target"))||(t.preventDefault(),null==(n=e.getRouter())||n.push(this.$data.to)))}),this.addEventListener("mouseenter",()=>{this.prefetchRoute()},{once:!0})}updateState(){const t=e.getRouter();if(!t)return;this.$data.href=t.resolve(this.$data.to);let s=!1;if(this.$data.active)s=!0;else{const e=t.getCurrentRoute();if(e){const t=e.fullPath;s=this.hasAttribute("exact")?t===this.$data.to:t===this.$data.to||t.startsWith(this.$data.to+"/")}}this.$data.isActive=s;const n=this.$data.activeClass||"active";this.classList.toggle(n,s)}prefetchRoute(){if(this.o||!this.hasAttribute("prefetch"))return;const t=e.getRouter();t&&"function"==typeof t.prefetch&&(t.prefetch(this.$data.to),this.o=!0)}};o=((t,e)=>{for(var s,n=e,o=t.length-1;o>=0;o--)(s=t[o])&&(n=s(n)||n);return n})([n.CustomElement({tagName:"router-link",template:'\n <a part="link" :href="$data.href" :class="{active: $data.isActive}">\n <slot>{{$data.label || \'\'}}</slot>\n </a>\n ',styles:"\n :host {\n }\n\n a {\n text-decoration: none;\n color: inherit;\n cursor: pointer;\n }\n\n /* 内部 <a> 标签的默认高亮 */\n a.active {\n font-weight: 600;\n }\n\n /* custom 模式:消除包裹 a 标签的视觉/布局影响,由 slot 内部元素接管 */\n :host([custom]) a {\n display: contents;\n }\n ",shadowDOM:{use:!0,mode:"open"},props:["to","active","exact","label","custom","activeClass","prefetch"]})],o);const i=o;exports.default=i;
1
+ "use strict";var t=Object.defineProperty;Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./core.cjs"),s=require("../runtime/component/base-element.cjs"),n=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.default=class extends s.default{constructor(){var e;super(...arguments),((e,s,n)=>{s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n})(this,"symbol"!=typeof(e="_prefetched")?e+"":e,!1)}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){(await e.routerReady).listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",t=>{var s,n;t.defaultPrevented||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||0===t.button&&((null==(s=t.target.closest("a"))?void 0:s.getAttribute("target"))||(t.preventDefault(),null==(n=e.getRouter())||n.push(this.$data.to)))}),this.addEventListener("mouseenter",()=>{this.prefetchRoute()},{once:!0})}updateState(){const t=e.getRouter();if(!t)return;this.$data.href=t.resolve(this.$data.to);let s=!1;if(this.$data.active)s=!0;else{const e=t.getCurrentRoute();if(e){const t=e.fullPath;s=this.hasAttribute("exact")?t===this.$data.to:t===this.$data.to||t.startsWith(this.$data.to+"/")}}this.$data.isActive=s;const n=this.$data.activeClass||"active";this.classList.toggle(n,s)}prefetchRoute(){if(this.o||!this.hasAttribute("prefetch"))return;const t=e.getRouter();t&&"function"==typeof t.prefetch&&(t.prefetch(this.$data.to),this.o=!0)}},exports.default=((t,e)=>{for(var s,n=e,o=t.length-1;o>=0;o--)(s=t[o])&&(n=s(n)||n);return n})([n.CustomElement({tagName:"router-link",template:'\n <a part="link" :href="$data.href" :class="{active: $data.isActive}">\n <slot>{{$data.label || \'\'}}</slot>\n </a>\n ',styles:"\n :host {\n }\n\n a {\n text-decoration: none;\n color: inherit;\n cursor: pointer;\n }\n\n /* 内部 <a> 标签的默认高亮 */\n a.active {\n font-weight: 600;\n }\n\n /* custom 模式:消除包裹 a 标签的视觉/布局影响,由 slot 内部元素接管 */\n :host([custom]) a {\n display: contents;\n }\n ",shadowDOM:{use:!0,mode:"open"},props:["to","active","exact","label","custom","activeClass","prefetch"]})],exports.default);
@@ -1 +1 @@
1
- var t=Object.defineProperty;import{routerReady as e,getRouter as s}from"./core.js";import n from"../runtime/component/base-element.js";import{CustomElement as o}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let i=class extends n{constructor(){var e;super(...arguments),((e,s,n)=>{s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n})(this,"symbol"!=typeof(e="_prefetched")?e+"":e,!1)}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){(await e).listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",t=>{var e,n;t.defaultPrevented||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||0===t.button&&((null==(e=t.target.closest("a"))?void 0:e.getAttribute("target"))||(t.preventDefault(),null==(n=s())||n.push(this.$data.to)))}),this.addEventListener("mouseenter",()=>{this.prefetchRoute()},{once:!0})}updateState(){const t=s();if(!t)return;this.$data.href=t.resolve(this.$data.to);let e=!1;if(this.$data.active)e=!0;else{const s=t.getCurrentRoute();if(s){const t=s.fullPath;e=this.hasAttribute("exact")?t===this.$data.to:t===this.$data.to||t.startsWith(this.$data.to+"/")}}this.$data.isActive=e;const n=this.$data.activeClass||"active";this.classList.toggle(n,e)}prefetchRoute(){if(this.t||!this.hasAttribute("prefetch"))return;const t=s();t&&"function"==typeof t.prefetch&&(t.prefetch(this.$data.to),this.t=!0)}};i=((t,e)=>{for(var s,n=e,o=t.length-1;o>=0;o--)(s=t[o])&&(n=s(n)||n);return n})([o({tagName:"router-link",template:'\n <a part="link" :href="$data.href" :class="{active: $data.isActive}">\n <slot>{{$data.label || \'\'}}</slot>\n </a>\n ',styles:"\n :host {\n }\n\n a {\n text-decoration: none;\n color: inherit;\n cursor: pointer;\n }\n\n /* 内部 <a> 标签的默认高亮 */\n a.active {\n font-weight: 600;\n }\n\n /* custom 模式:消除包裹 a 标签的视觉/布局影响,由 slot 内部元素接管 */\n :host([custom]) a {\n display: contents;\n }\n ",shadowDOM:{use:!0,mode:"open"},props:["to","active","exact","label","custom","activeClass","prefetch"]})],i);const a=i;export{a as default};
1
+ var t=Object.defineProperty;import{routerReady as e,getRouter as s}from"./core.js";import n from"../runtime/component/base-element.js";import{CustomElement as o}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let i=class extends n{constructor(){var e;super(...arguments),((e,s,n)=>{s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n})(this,"symbol"!=typeof(e="_prefetched")?e+"":e,!1)}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){(await e).listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",t=>{var e,n;t.defaultPrevented||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||0===t.button&&((null==(e=t.target.closest("a"))?void 0:e.getAttribute("target"))||(t.preventDefault(),null==(n=s())||n.push(this.$data.to)))}),this.addEventListener("mouseenter",()=>{this.prefetchRoute()},{once:!0})}updateState(){const t=s();if(!t)return;this.$data.href=t.resolve(this.$data.to);let e=!1;if(this.$data.active)e=!0;else{const s=t.getCurrentRoute();if(s){const t=s.fullPath;e=this.hasAttribute("exact")?t===this.$data.to:t===this.$data.to||t.startsWith(this.$data.to+"/")}}this.$data.isActive=e;const n=this.$data.activeClass||"active";this.classList.toggle(n,e)}prefetchRoute(){if(this.t||!this.hasAttribute("prefetch"))return;const t=s();t&&"function"==typeof t.prefetch&&(t.prefetch(this.$data.to),this.t=!0)}};i=((t,e)=>{for(var s,n=e,o=t.length-1;o>=0;o--)(s=t[o])&&(n=s(n)||n);return n})([o({tagName:"router-link",template:'\n <a part="link" :href="$data.href" :class="{active: $data.isActive}">\n <slot>{{$data.label || \'\'}}</slot>\n </a>\n ',styles:"\n :host {\n }\n\n a {\n text-decoration: none;\n color: inherit;\n cursor: pointer;\n }\n\n /* 内部 <a> 标签的默认高亮 */\n a.active {\n font-weight: 600;\n }\n\n /* custom 模式:消除包裹 a 标签的视觉/布局影响,由 slot 内部元素接管 */\n :host([custom]) a {\n display: contents;\n }\n ",shadowDOM:{use:!0,mode:"open"},props:["to","active","exact","label","custom","activeClass","prefetch"]})],i);export{i as default};
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty,i=(i,s,e)=>((i,s,e)=>s in i?t(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e)(i,"symbol"!=typeof s?s+"":s,e);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./core.cjs"),e=require("../runtime/component/base-element.cjs"),n=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;const r=new Map;let h=class extends e.default{constructor(){super(...arguments),i(this,"unsubscribe"),i(this,"level",0),i(this,"currentElement",null),i(this,"currentTagName",null),i(this,"routerAttrs",new Set),i(this,"prevPropKeys",new Set),i(this,"scheduled",!1),i(this,"latestLoadId",0),i(this,"abortController",null),i(this,"router",null)}async mounted(){this.detectLevel(),this.router=await s.routerReady,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(this.router.getCurrentRoute())}))}detectLevel(){let t=0,i=this.parentElement;for(;i;)i instanceof h&&t++,i=i.parentElement;this.level=t}async loadRoute(t){this.abortController&&(this.abortController.abort(),this.abortController=null);const i=++this.latestLoadId,s=null==t?void 0:t.matched[this.level];if(!s)return void this.handleEmptyRoute();const{config:e}=s;let n=e.tagName;if(!n&&"function"==typeof e.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const t=this.abortController.signal;try{const s=await e.component();if(t.aborted||i!==this.latestLoadId)return;n="string"==typeof s?s:s.tagName}catch(h){if(t.aborted||i!==this.latestLoadId)return;return this.renderError(`Load Error: ${h}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!t.aborted&&(this.abortController=null)}}if(i!==this.latestLoadId)return;if(!n)return void this.clear();if(!e.forceReload&&this.currentElement&&this.currentTagName===n.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props);this.clear();const r=this.getOrCreateComponent(n,e);this.syncState(r,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props),this.appendChild(r),this.currentElement=r,this.currentTagName=n.toLowerCase()}getOrCreateComponent(t,i){const s=`${this.level}-${t.toLowerCase()}`;if(i.keepAlive&&r.has(s))return r.get(s);const e=document.createElement(t);return i.keepAlive&&r.set(s,e),e}syncState(t,i,s,e={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=new Map;Object.entries(i).forEach(([t,i])=>r.set(n(t),String(i))),Object.entries(s).forEach(([t,i])=>r.set(`query-${n(t)}`,String(i))),this.routerAttrs.forEach(i=>{r.has(i)||(t.removeAttribute(i),this.routerAttrs.delete(i))}),r.forEach((i,s)=>{t.getAttribute(s)!==i&&t.setAttribute(s,i),this.routerAttrs.add(s)});const h=new Set(Object.keys(e));this.prevPropKeys.forEach(i=>{h.has(i)||(t[i]=void 0)}),Object.entries(e).forEach(([i,s])=>{t[i]!==s&&(t[i]=s)}),this.prevPropKeys=h}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const i=document.createElement("div");i.style.cssText="padding:20px; color:#ff4d4f;",i.textContent=String(t),this.appendChild(i)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};h=((t,i)=>{for(var s,e=i,n=t.length-1;n>=0;n--)(s=t[n])&&(e=s(e)||e);return e})([n.CustomElement({tagName:"router-view"})],h);const o=h;exports.default=o;
1
+ "use strict";var t=Object.defineProperty,i=(i,s,e)=>((i,s,e)=>s in i?t(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e)(i,"symbol"!=typeof s?s+"":s,e);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./core.cjs"),e=require("../runtime/component/base-element.cjs"),n=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;const r=new Map;exports.default=class extends e.default{constructor(){super(...arguments),i(this,"unsubscribe"),i(this,"level",0),i(this,"currentElement",null),i(this,"currentTagName",null),i(this,"routerAttrs",new Set),i(this,"prevPropKeys",new Set),i(this,"scheduled",!1),i(this,"latestLoadId",0),i(this,"abortController",null),i(this,"router",null)}async mounted(){this.detectLevel(),this.router=await s.routerReady,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(this.router.getCurrentRoute())}))}detectLevel(){let t=0,i=this.parentElement;for(;i;)i instanceof exports.default&&t++,i=i.parentElement;this.level=t}async loadRoute(t){this.abortController&&(this.abortController.abort(),this.abortController=null);const i=++this.latestLoadId,s=null==t?void 0:t.matched[this.level];if(!s)return void this.handleEmptyRoute();const{config:e}=s;let n=e.tagName;if(!n&&"function"==typeof e.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const t=this.abortController.signal;try{const s=await e.component();if(t.aborted||i!==this.latestLoadId)return;n="string"==typeof s?s:s.tagName}catch(o){if(t.aborted||i!==this.latestLoadId)return;return this.renderError(`Load Error: ${o}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!t.aborted&&(this.abortController=null)}}if(i!==this.latestLoadId)return;if(!n)return void this.clear();if(!e.forceReload&&this.currentElement&&this.currentTagName===n.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props);this.clear();const r=this.getOrCreateComponent(n,e);this.syncState(r,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props),this.appendChild(r),this.currentElement=r,this.currentTagName=n.toLowerCase()}getOrCreateComponent(t,i){const s=`${this.level}-${t.toLowerCase()}`;if(i.keepAlive&&r.has(s))return r.get(s);const e=document.createElement(t);return i.keepAlive&&r.set(s,e),e}syncState(t,i,s,e={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=new Map;Object.entries(i).forEach(([t,i])=>r.set(n(t),String(i))),Object.entries(s).forEach(([t,i])=>r.set(`query-${n(t)}`,String(i))),this.routerAttrs.forEach(i=>{r.has(i)||(t.removeAttribute(i),this.routerAttrs.delete(i))}),r.forEach((i,s)=>{t.getAttribute(s)!==i&&t.setAttribute(s,i),this.routerAttrs.add(s)});const o=new Set(Object.keys(e));this.prevPropKeys.forEach(i=>{o.has(i)||(t[i]=void 0)}),Object.entries(e).forEach(([i,s])=>{t[i]!==s&&(t[i]=s)}),this.prevPropKeys=o}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const i=document.createElement("div");i.style.cssText="padding:20px; color:#ff4d4f;",i.textContent=String(t),this.appendChild(i)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}},exports.default=((t,i)=>{for(var s,e=i,n=t.length-1;n>=0;n--)(s=t[n])&&(e=s(e)||e);return e})([n.CustomElement({tagName:"router-view"})],exports.default);
@@ -1 +1 @@
1
- var t=Object.defineProperty,i=(i,s,e)=>((i,s,e)=>s in i?t(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e)(i,"symbol"!=typeof s?s+"":s,e);import{routerReady as s}from"./core.js";import e from"../runtime/component/base-element.js";import{CustomElement as n}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;const r=new Map;let o=class extends e{constructor(){super(...arguments),i(this,"unsubscribe"),i(this,"level",0),i(this,"currentElement",null),i(this,"currentTagName",null),i(this,"routerAttrs",new Set),i(this,"prevPropKeys",new Set),i(this,"scheduled",!1),i(this,"latestLoadId",0),i(this,"abortController",null),i(this,"router",null)}async mounted(){this.detectLevel(),this.router=await s,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(this.router.getCurrentRoute())}))}detectLevel(){let t=0,i=this.parentElement;for(;i;)i instanceof o&&t++,i=i.parentElement;this.level=t}async loadRoute(t){this.abortController&&(this.abortController.abort(),this.abortController=null);const i=++this.latestLoadId,s=null==t?void 0:t.matched[this.level];if(!s)return void this.handleEmptyRoute();const{config:e}=s;let n=e.tagName;if(!n&&"function"==typeof e.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const t=this.abortController.signal;try{const s=await e.component();if(t.aborted||i!==this.latestLoadId)return;n="string"==typeof s?s:s.tagName}catch(o){if(t.aborted||i!==this.latestLoadId)return;return this.renderError(`Load Error: ${o}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!t.aborted&&(this.abortController=null)}}if(i!==this.latestLoadId)return;if(!n)return void this.clear();if(!e.forceReload&&this.currentElement&&this.currentTagName===n.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props);this.clear();const r=this.getOrCreateComponent(n,e);this.syncState(r,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props),this.appendChild(r),this.currentElement=r,this.currentTagName=n.toLowerCase()}getOrCreateComponent(t,i){const s=`${this.level}-${t.toLowerCase()}`;if(i.keepAlive&&r.has(s))return r.get(s);const e=document.createElement(t);return i.keepAlive&&r.set(s,e),e}syncState(t,i,s,e={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=new Map;Object.entries(i).forEach(([t,i])=>r.set(n(t),String(i))),Object.entries(s).forEach(([t,i])=>r.set(`query-${n(t)}`,String(i))),this.routerAttrs.forEach(i=>{r.has(i)||(t.removeAttribute(i),this.routerAttrs.delete(i))}),r.forEach((i,s)=>{t.getAttribute(s)!==i&&t.setAttribute(s,i),this.routerAttrs.add(s)});const o=new Set(Object.keys(e));this.prevPropKeys.forEach(i=>{o.has(i)||(t[i]=void 0)}),Object.entries(e).forEach(([i,s])=>{t[i]!==s&&(t[i]=s)}),this.prevPropKeys=o}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const i=document.createElement("div");i.style.cssText="padding:20px; color:#ff4d4f;",i.textContent=String(t),this.appendChild(i)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};o=((t,i)=>{for(var s,e=i,n=t.length-1;n>=0;n--)(s=t[n])&&(e=s(e)||e);return e})([n({tagName:"router-view"})],o);const h=o;export{h as default};
1
+ var t=Object.defineProperty,i=(i,s,e)=>((i,s,e)=>s in i?t(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e)(i,"symbol"!=typeof s?s+"":s,e);import{routerReady as s}from"./core.js";import e from"../runtime/component/base-element.js";import{CustomElement as n}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;const r=new Map;let h=class extends e{constructor(){super(...arguments),i(this,"unsubscribe"),i(this,"level",0),i(this,"currentElement",null),i(this,"currentTagName",null),i(this,"routerAttrs",new Set),i(this,"prevPropKeys",new Set),i(this,"scheduled",!1),i(this,"latestLoadId",0),i(this,"abortController",null),i(this,"router",null)}async mounted(){this.detectLevel(),this.router=await s,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(this.router.getCurrentRoute())}))}detectLevel(){let t=0,i=this.parentElement;for(;i;)i instanceof h&&t++,i=i.parentElement;this.level=t}async loadRoute(t){this.abortController&&(this.abortController.abort(),this.abortController=null);const i=++this.latestLoadId,s=null==t?void 0:t.matched[this.level];if(!s)return void this.handleEmptyRoute();const{config:e}=s;let n=e.tagName;if(!n&&"function"==typeof e.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const t=this.abortController.signal;try{const s=await e.component();if(t.aborted||i!==this.latestLoadId)return;n="string"==typeof s?s:s.tagName}catch(h){if(t.aborted||i!==this.latestLoadId)return;return this.renderError(`Load Error: ${h}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!t.aborted&&(this.abortController=null)}}if(i!==this.latestLoadId)return;if(!n)return void this.clear();if(!e.forceReload&&this.currentElement&&this.currentTagName===n.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props);this.clear();const r=this.getOrCreateComponent(n,e);this.syncState(r,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props),this.appendChild(r),this.currentElement=r,this.currentTagName=n.toLowerCase()}getOrCreateComponent(t,i){const s=`${this.level}-${t.toLowerCase()}`;if(i.keepAlive&&r.has(s))return r.get(s);const e=document.createElement(t);return i.keepAlive&&r.set(s,e),e}syncState(t,i,s,e={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=new Map;Object.entries(i).forEach(([t,i])=>r.set(n(t),String(i))),Object.entries(s).forEach(([t,i])=>r.set(`query-${n(t)}`,String(i))),this.routerAttrs.forEach(i=>{r.has(i)||(t.removeAttribute(i),this.routerAttrs.delete(i))}),r.forEach((i,s)=>{t.getAttribute(s)!==i&&t.setAttribute(s,i),this.routerAttrs.add(s)});const h=new Set(Object.keys(e));this.prevPropKeys.forEach(i=>{h.has(i)||(t[i]=void 0)}),Object.entries(e).forEach(([i,s])=>{t[i]!==s&&(t[i]=s)}),this.prevPropKeys=h}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const i=document.createElement("div");i.style.cssText="padding:20px; color:#ff4d4f;",i.textContent=String(t),this.appendChild(i)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};h=((t,i)=>{for(var s,e=i,n=t.length-1;n>=0;n--)(s=t[n])&&(e=s(e)||e);return e})([n({tagName:"router-view"})],h);export{h as default};
@@ -1 +1 @@
1
- "use strict";var t,e,s,i,n,h,a,o,r,c,u,l,d,f,b,p,m,v,k,w,y,M,W=Object.defineProperty,g=t=>{throw TypeError(t)},S=(t,e,s)=>e.has(t)||g("Cannot "+s),C=(t,e,s)=>(S(t,e,"read from private field"),s?s.call(t):e.get(t)),$=(t,e,s)=>e.has(t)?g("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),j=(t,e,s,i)=>(S(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),A=(t,e,s)=>(S(t,e,"access private method"),s);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const q=require("../../shared/is-object.cjs"),N=require("../../shared/env.cjs"),E=require("../reactivity/observe.cjs"),x=require("../renderer/renderIR.cjs"),O=Symbol.for("solely.manifest"),R=class extends HTMLElement{constructor(f={}){var p;super(),$(this,d),$(this,t),$(this,e),$(this,s),$(this,i),$(this,n),$(this,h),$(this,a,!1),$(this,o,!1),$(this,r,!1),$(this,c,!1),$(this,u,!1),$(this,l,!1);const v=this.constructor;j(this,t,v[O]||{tagName:"base-element"});const k=C(this,t);j(this,n,(null==(p=k.shadowDOM)?void 0:p.use)?this.attachShadow({mode:k.shadowDOM.mode||"open"}):this),A(this,d,b).call(this,f),A(this,d,m).call(this,k),queueMicrotask(()=>A(this,d,M).call(this))}static get observedAttributes(){const t=this[O];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return C(this,i)}set $data(t){var e;q.isObject(t)||(t={}),null==(e=C(this,h))||e.call(this),A(this,d,b).call(this,t),A(this,d,k).call(this)}refresh(){A(this,d,k).call(this)}connectedCallback(){var i;j(this,u,!0);const h=this.constructor.upgradeProps;let a;a=Array.isArray(h)?h.includes("$data")?h:[...h,"$data"]:["$data"],A(this,d,f).call(this,a),A(this,d,M).call(this);const o=C(this,t);if((o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),A(this,d,y).call(this),o.propMap&&q.isObject(this.$data))for(const[t,e]of o.propMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=A(this,d,v).call(this,i,e.default,e.type);this.$data[s]=n}else"default"in e&&(this.$data[s]=e.default)}C(this,s)&&!C(this,e)&&j(this,e,x.createRender(C(this,s),C(this,n),this)),C(this,l)&&(j(this,l,!1),A(this,d,k).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){j(this,u,!1),this.unmounted()}attributeChangedCallback(e,s,i){var n;if(s===i||!q.isObject(this.$data))return;const h=null==(n=C(this,t).propMap)?void 0:n.get(e);if(!h)return;const a=h.name,o=this.$data[a],c=A(this,d,v).call(this,i,h.default??o,h.type);this.$data[a]=c,j(this,r,!0),this.attributeChanged(e,o,c)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};var U;t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,n=new WeakMap,h=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakMap,c=new WeakMap,u=new WeakMap,l=new WeakMap,d=new WeakSet,f=function(t){for(const e of t)if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this[e]=t}},b=function(e){const{proxy:s,dispose:n}=E.observe(e,e=>{var s,i;if("set"===e.type){const{key:n,newValue:h}=e,a=C(this,t),o=String(n),r=(null==(s=a.propMap)?void 0:s.get(o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=a.propMap)?void 0:i.values())||[]).find(t=>t.name===o);(null==r?void 0:r.reflect)&&A(this,d,p).call(this,r,h)}this.emit("change",{source:"state",...e}),A(this,d,k).call(this)});j(this,i,s),j(this,h,n)},p=function(t,e){const s=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},m=function(t){t.ir&&j(this,s,t.ir)},v=function(t,e,s){if(null===t)return"boolean"===s?e??!1:e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch{return e}default:return t}},k=function(){C(this,u)?!C(this,o)&&C(this,e)&&(j(this,o,!0),queueMicrotask(()=>{j(this,o,!1),A(this,d,w).call(this)})):j(this,l,!0)},w=function(){!C(this,a)&&C(this,u)&&(j(this,a,!0),C(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),C(this,e).update(),this.updated(),C(this,r)&&(this.afterAttributesUpdate(),j(this,r,!1)),j(this,a,!1))},y=function(){const e=C(this,t);if(!e.styles)return;const s=C(this,n);if(e.sheet&&s instanceof ShadowRoot&&"adoptedStyleSheets"in s)return void(s.adoptedStyleSheets.includes(e.sheet)||(s.adoptedStyleSheets=[...s.adoptedStyleSheets,e.sheet]));const i=s instanceof ShadowRoot?s:document.head,h=`solely-style-${e.tagName}`;if(!i.querySelector(`#${h}`)){const t=document.createElement("style");t.id=h,t.textContent=e.styles,i.appendChild(t)}},M=function(){C(this,c)||(j(this,c,!0),this.created())},((t,e,s)=>{e in t?W(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(R,"symbol"!=typeof(U="upgradeProps")?U+"":U,undefined),(()=>{if(N.IS_DEV){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,n){if(R.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,s=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of s)t[e],R.prototype[e]}return t.call(this,s,i,n)}}})();let z=R;exports.default=z;
1
+ "use strict";var t,e,s,i,n,h,a,o,r,c,u,l,d,f,b,p,m,v,k,w,y,M,W=Object.defineProperty,g=t=>{throw TypeError(t)},S=(t,e,s)=>e.has(t)||g("Cannot "+s),$=(t,e,s)=>(S(t,e,"read from private field"),s?s.call(t):e.get(t)),C=(t,e,s)=>e.has(t)?g("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),j=(t,e,s,i)=>(S(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),A=(t,e,s)=>(S(t,e,"access private method"),s);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const q=require("../../shared/is-object.cjs"),N=require("../../shared/env.cjs"),E=require("../reactivity/observe.cjs"),x=require("../renderer/renderIR.cjs"),O=Symbol.for("solely.manifest"),R=class extends HTMLElement{constructor(f={}){var p;super(),C(this,d),C(this,t),C(this,e),C(this,s),C(this,i),C(this,n),C(this,h),C(this,a,!1),C(this,o,!1),C(this,r,!1),C(this,c,!1),C(this,u,!1),C(this,l,!1);const v=this.constructor;j(this,t,v[O]||{tagName:"base-element"});const k=$(this,t);j(this,n,(null==(p=k.shadowDOM)?void 0:p.use)?this.attachShadow({mode:k.shadowDOM.mode||"open"}):this),A(this,d,b).call(this,f),A(this,d,m).call(this,k),queueMicrotask(()=>A(this,d,M).call(this))}static get observedAttributes(){const t=this[O];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return $(this,i)}set $data(t){var e;q.isObject(t)||(t={}),null==(e=$(this,h))||e.call(this),A(this,d,b).call(this,t),A(this,d,k).call(this)}refresh(){A(this,d,k).call(this)}connectedCallback(){var i;j(this,u,!0);const h=this.constructor.upgradeProps;let a;a=Array.isArray(h)?h.includes("$data")?h:[...h,"$data"]:["$data"],A(this,d,f).call(this,a),A(this,d,M).call(this);const o=$(this,t);if((o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),A(this,d,y).call(this),o.propMap&&q.isObject(this.$data))for(const[t,e]of o.propMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=A(this,d,v).call(this,i,e.default,e.type);this.$data[s]=n}else"default"in e&&(this.$data[s]=e.default)}$(this,s)&&!$(this,e)&&j(this,e,x.createRender($(this,s),$(this,n),this)),$(this,l)&&(j(this,l,!1),A(this,d,k).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){j(this,u,!1),this.unmounted()}attributeChangedCallback(e,s,i){var n;if(s===i||!q.isObject(this.$data))return;const h=null==(n=$(this,t).propMap)?void 0:n.get(e);if(!h)return;const a=h.name,o=this.$data[a],c=A(this,d,v).call(this,i,h.default??o,h.type);this.$data[a]=c,j(this,r,!0),this.attributeChanged(e,o,c)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};var U;t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,n=new WeakMap,h=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakMap,c=new WeakMap,u=new WeakMap,l=new WeakMap,d=new WeakSet,f=function(t){for(const e of t)if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this[e]=t}},b=function(e){const{proxy:s,dispose:n}=E.observe(e,e=>{var s,i;if("set"===e.type){const{key:n,newValue:h}=e,a=$(this,t),o=String(n),r=(null==(s=a.propMap)?void 0:s.get(o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=a.propMap)?void 0:i.values())||[]).find(t=>t.name===o);(null==r?void 0:r.reflect)&&A(this,d,p).call(this,r,h)}this.emit("change",{source:"state",...e}),A(this,d,k).call(this)});j(this,i,s),j(this,h,n)},p=function(t,e){const s=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},m=function(t){t.ir&&j(this,s,t.ir)},v=function(t,e,s){if(null===t)return"boolean"===s?e??!1:e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch{return e}default:return t}},k=function(){$(this,u)?!$(this,o)&&$(this,e)&&(j(this,o,!0),queueMicrotask(()=>{j(this,o,!1),A(this,d,w).call(this)})):j(this,l,!0)},w=function(){!$(this,a)&&$(this,u)&&(j(this,a,!0),$(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),$(this,e).update(),this.updated(),$(this,r)&&(this.afterAttributesUpdate(),j(this,r,!1)),j(this,a,!1))},y=function(){const e=$(this,t);if(!e.styles)return;const s=$(this,n);if(e.sheet&&s instanceof ShadowRoot&&"adoptedStyleSheets"in s)return void(s.adoptedStyleSheets.includes(e.sheet)||(s.adoptedStyleSheets=[...s.adoptedStyleSheets,e.sheet]));const i=s instanceof ShadowRoot?s:document.head,h=`solely-style-${e.tagName}`;if(!i.querySelector(`#${h}`)){const t=document.createElement("style");t.id=h,t.textContent=e.styles,i.appendChild(t)}},M=function(){$(this,c)||(j(this,c,!0),this.created())},((t,e,s)=>{e in t?W(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(R,"symbol"!=typeof(U="upgradeProps")?U+"":U,undefined),(()=>{if(N.IS_DEV){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,n){if(R.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,n=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of n)t[e]!==R.prototype[e]&&console.error(`[${s}] 禁止重写 ${e}(),请使用框架钩子`)}return t.call(this,s,i,n)}}})();let z=R;exports.default=z;
@@ -1 +1 @@
1
- var t,s,e,i,n,h,a,o,r,c,u,l,d,f,p,b,m,k,v,w,y,M,W=Object.defineProperty,g=t=>{throw TypeError(t)},C=(t,s,e)=>s.has(t)||g("Cannot "+e),S=(t,s,e)=>(C(t,s,"read from private field"),e?e.call(t):s.get(t)),$=(t,s,e)=>s.has(t)?g("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,e),j=(t,s,e,i)=>(C(t,s,"write to private field"),i?i.call(t,e):s.set(t,e),e),A=(t,s,e)=>(C(t,s,"access private method"),e);import{isObject as N}from"../../shared/is-object.js";import{IS_DEV as E}from"../../shared/env.js";import{observe as x}from"../reactivity/observe.js";import{createRender as O}from"../renderer/renderIR.js";const R=Symbol.for("solely.manifest"),U=class extends HTMLElement{constructor(f={}){var b;super(),$(this,d),$(this,t),$(this,s),$(this,e),$(this,i),$(this,n),$(this,h),$(this,a,!1),$(this,o,!1),$(this,r,!1),$(this,c,!1),$(this,u,!1),$(this,l,!1);const k=this.constructor;j(this,t,k[R]||{tagName:"base-element"});const v=S(this,t);j(this,n,(null==(b=v.shadowDOM)?void 0:b.use)?this.attachShadow({mode:v.shadowDOM.mode||"open"}):this),A(this,d,p).call(this,f),A(this,d,m).call(this,v),queueMicrotask(()=>A(this,d,M).call(this))}static get observedAttributes(){const t=this[R];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return S(this,i)}set $data(t){var s;N(t)||(t={}),null==(s=S(this,h))||s.call(this),A(this,d,p).call(this,t),A(this,d,v).call(this)}refresh(){A(this,d,v).call(this)}connectedCallback(){var i;j(this,u,!0);const h=this.constructor.upgradeProps;let a;a=Array.isArray(h)?h.includes("$data")?h:[...h,"$data"]:["$data"],A(this,d,f).call(this,a),A(this,d,M).call(this);const o=S(this,t);if((o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),A(this,d,y).call(this),o.propMap&&N(this.$data))for(const[t,s]of o.propMap){const e=s.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=A(this,d,k).call(this,i,s.default,s.type);this.$data[e]=n}else"default"in s&&(this.$data[e]=s.default)}S(this,e)&&!S(this,s)&&j(this,s,O(S(this,e),S(this,n),this)),S(this,l)&&(j(this,l,!1),A(this,d,v).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){j(this,u,!1),this.unmounted()}attributeChangedCallback(s,e,i){var n;if(e===i||!N(this.$data))return;const h=null==(n=S(this,t).propMap)?void 0:n.get(s);if(!h)return;const a=h.name,o=this.$data[a],c=A(this,d,k).call(this,i,h.default??o,h.type);this.$data[a]=c,j(this,r,!0),this.attributeChanged(s,o,c)}emit(t,s,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:s,...e}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,s,e){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};var q;t=new WeakMap,s=new WeakMap,e=new WeakMap,i=new WeakMap,n=new WeakMap,h=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakMap,c=new WeakMap,u=new WeakMap,l=new WeakMap,d=new WeakSet,f=function(t){for(const s of t)if(this.hasOwnProperty(s)){const t=this[s];delete this[s],this[s]=t}},p=function(s){const{proxy:e,dispose:n}=x(s,s=>{var e,i;if("set"===s.type){const{key:n,newValue:h}=s,a=S(this,t),o=String(n),r=(null==(e=a.propMap)?void 0:e.get(o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=a.propMap)?void 0:i.values())||[]).find(t=>t.name===o);(null==r?void 0:r.reflect)&&A(this,d,b).call(this,r,h)}this.emit("change",{source:"state",...s}),A(this,d,v).call(this)});j(this,i,e),j(this,h,n)},b=function(t,s){const e=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)s?this.setAttribute(e,""):this.removeAttribute(e);else{const t="object"==typeof s?JSON.stringify(s):String(s);this.setAttribute(e,t)}},m=function(t){t.ir&&j(this,e,t.ir)},k=function(t,s,e){if(null===t)return"boolean"===e?s??!1:s;switch(e){case"boolean":return!0;case"number":{const e=Number(t);return isNaN(e)?s:e}case"object":try{return JSON.parse(t)}catch{return s}default:return t}},v=function(){S(this,u)?!S(this,o)&&S(this,s)&&(j(this,o,!0),queueMicrotask(()=>{j(this,o,!1),A(this,d,w).call(this)})):j(this,l,!0)},w=function(){!S(this,a)&&S(this,u)&&(j(this,a,!0),S(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),S(this,s).update(),this.updated(),S(this,r)&&(this.afterAttributesUpdate(),j(this,r,!1)),j(this,a,!1))},y=function(){const s=S(this,t);if(!s.styles)return;const e=S(this,n);if(s.sheet&&e instanceof ShadowRoot&&"adoptedStyleSheets"in e)return void(e.adoptedStyleSheets.includes(s.sheet)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s.sheet]));const i=e instanceof ShadowRoot?e:document.head,h=`solely-style-${s.tagName}`;if(!i.querySelector(`#${h}`)){const t=document.createElement("style");t.id=h,t.textContent=s.styles,i.appendChild(t)}},M=function(){S(this,c)||(j(this,c,!0),this.created())},((t,s,e)=>{s in t?W(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e})(U,"symbol"!=typeof(q="upgradeProps")?q+"":q,undefined),(()=>{if(E){const t=customElements.define,s=new WeakSet;customElements.define=function(e,i,n){if(U.isPrototypeOf(i)&&!s.has(i)){s.add(i);const t=i.prototype,e=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const s of e)t[s],U.prototype[s]}return t.call(this,e,i,n)}}})();let z=U;export{z as default};
1
+ var t,s,e,i,n,h,a,o,r,c,u,l,d,f,p,b,m,k,v,w,y,M,W=Object.defineProperty,g=t=>{throw TypeError(t)},$=(t,s,e)=>s.has(t)||g("Cannot "+e),C=(t,s,e)=>($(t,s,"read from private field"),e?e.call(t):s.get(t)),S=(t,s,e)=>s.has(t)?g("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,e),j=(t,s,e,i)=>($(t,s,"write to private field"),i?i.call(t,e):s.set(t,e),e),A=(t,s,e)=>($(t,s,"access private method"),e);import{isObject as N}from"../../shared/is-object.js";import{IS_DEV as E}from"../../shared/env.js";import{observe as x}from"../reactivity/observe.js";import{createRender as O}from"../renderer/renderIR.js";const R=Symbol.for("solely.manifest"),U=class extends HTMLElement{constructor(f={}){var b;super(),S(this,d),S(this,t),S(this,s),S(this,e),S(this,i),S(this,n),S(this,h),S(this,a,!1),S(this,o,!1),S(this,r,!1),S(this,c,!1),S(this,u,!1),S(this,l,!1);const k=this.constructor;j(this,t,k[R]||{tagName:"base-element"});const v=C(this,t);j(this,n,(null==(b=v.shadowDOM)?void 0:b.use)?this.attachShadow({mode:v.shadowDOM.mode||"open"}):this),A(this,d,p).call(this,f),A(this,d,m).call(this,v),queueMicrotask(()=>A(this,d,M).call(this))}static get observedAttributes(){const t=this[R];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return C(this,i)}set $data(t){var s;N(t)||(t={}),null==(s=C(this,h))||s.call(this),A(this,d,p).call(this,t),A(this,d,v).call(this)}refresh(){A(this,d,v).call(this)}connectedCallback(){var i;j(this,u,!0);const h=this.constructor.upgradeProps;let a;a=Array.isArray(h)?h.includes("$data")?h:[...h,"$data"]:["$data"],A(this,d,f).call(this,a),A(this,d,M).call(this);const o=C(this,t);if((o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),A(this,d,y).call(this),o.propMap&&N(this.$data))for(const[t,s]of o.propMap){const e=s.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=A(this,d,k).call(this,i,s.default,s.type);this.$data[e]=n}else"default"in s&&(this.$data[e]=s.default)}C(this,e)&&!C(this,s)&&j(this,s,O(C(this,e),C(this,n),this)),C(this,l)&&(j(this,l,!1),A(this,d,v).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){j(this,u,!1),this.unmounted()}attributeChangedCallback(s,e,i){var n;if(e===i||!N(this.$data))return;const h=null==(n=C(this,t).propMap)?void 0:n.get(s);if(!h)return;const a=h.name,o=this.$data[a],c=A(this,d,k).call(this,i,h.default??o,h.type);this.$data[a]=c,j(this,r,!0),this.attributeChanged(s,o,c)}emit(t,s,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:s,...e}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,s,e){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};var q;t=new WeakMap,s=new WeakMap,e=new WeakMap,i=new WeakMap,n=new WeakMap,h=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakMap,c=new WeakMap,u=new WeakMap,l=new WeakMap,d=new WeakSet,f=function(t){for(const s of t)if(this.hasOwnProperty(s)){const t=this[s];delete this[s],this[s]=t}},p=function(s){const{proxy:e,dispose:n}=x(s,s=>{var e,i;if("set"===s.type){const{key:n,newValue:h}=s,a=C(this,t),o=String(n),r=(null==(e=a.propMap)?void 0:e.get(o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=a.propMap)?void 0:i.values())||[]).find(t=>t.name===o);(null==r?void 0:r.reflect)&&A(this,d,b).call(this,r,h)}this.emit("change",{source:"state",...s}),A(this,d,v).call(this)});j(this,i,e),j(this,h,n)},b=function(t,s){const e=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)s?this.setAttribute(e,""):this.removeAttribute(e);else{const t="object"==typeof s?JSON.stringify(s):String(s);this.setAttribute(e,t)}},m=function(t){t.ir&&j(this,e,t.ir)},k=function(t,s,e){if(null===t)return"boolean"===e?s??!1:s;switch(e){case"boolean":return!0;case"number":{const e=Number(t);return isNaN(e)?s:e}case"object":try{return JSON.parse(t)}catch{return s}default:return t}},v=function(){C(this,u)?!C(this,o)&&C(this,s)&&(j(this,o,!0),queueMicrotask(()=>{j(this,o,!1),A(this,d,w).call(this)})):j(this,l,!0)},w=function(){!C(this,a)&&C(this,u)&&(j(this,a,!0),C(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),C(this,s).update(),this.updated(),C(this,r)&&(this.afterAttributesUpdate(),j(this,r,!1)),j(this,a,!1))},y=function(){const s=C(this,t);if(!s.styles)return;const e=C(this,n);if(s.sheet&&e instanceof ShadowRoot&&"adoptedStyleSheets"in e)return void(e.adoptedStyleSheets.includes(s.sheet)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s.sheet]));const i=e instanceof ShadowRoot?e:document.head,h=`solely-style-${s.tagName}`;if(!i.querySelector(`#${h}`)){const t=document.createElement("style");t.id=h,t.textContent=s.styles,i.appendChild(t)}},M=function(){C(this,c)||(j(this,c,!0),this.created())},((t,s,e)=>{s in t?W(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e})(U,"symbol"!=typeof(q="upgradeProps")?q+"":q,undefined),(()=>{if(E){const t=customElements.define,s=new WeakSet;customElements.define=function(e,i,n){if(U.isPrototypeOf(i)&&!s.has(i)){s.add(i);const t=i.prototype,n=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const s of n)t[s]!==U.prototype[s]&&console.error(`[${e}] 禁止重写 ${s}(),请使用框架钩子`)}return t.call(this,e,i,n)}}})();let z=U;export{z as default};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),t=require("../../compiler/parser/parser.cjs"),r=require("../../compiler/ir/buildIR.cjs"),s=Symbol.for("solely.manifest");exports.CustomElement=n=>{const o=n;return n=>{const{tagName:c}=o;if(customElements.get(c))return e.IS_DEV,n;if("string"!=typeof o.template||o.ir){if(o.template&&!o.ir&&"object"==typeof o.template&&null!==o.template){const t=o.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)&&(o.ir=t,e.IS_DEV)}}else if(o.template.trim())try{const e=t.parseHtml(o.template);o.ir=r.buildIR(e,{source:o.template,filename:c})}catch(a){a instanceof Error||new Error(String(a))}else e.IS_DEV;if(o.styles&&!o.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(o.styles),o.sheet=e)}catch(a){e.IS_DEV}if(o.props&&!o.propMap){const e=new Map;o.props.forEach(t=>{const r="string"==typeof t?{name:t}:t,s=r.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),n=s.replace(/-([a-z])/g,(e,t)=>t.toUpperCase());e.set(s,{...r,name:n})}),o.propMap=e}class i extends n{}return i[s]=o,customElements.define(c,i),i}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),o=require("../../compiler/parser/parser.cjs"),t=require("../../compiler/ir/buildIR.cjs"),n=Symbol.for("solely.manifest");exports.CustomElement=r=>{const s=r;return r=>{const{tagName:l}=s;if(customElements.get(l))return e.IS_DEV&&console.warn(`[Solely] 标签名称 "${l}" 已经被注册,跳过重复定义。`),r;if("string"!=typeof s.template||s.ir){if(s.template&&!s.ir)if("object"==typeof s.template&&null!==s.template){const o=s.template;"root"===o.t&&Array.isArray(o.fns)&&Array.isArray(o.n)?(s.ir=o,e.IS_DEV&&console.log(`[Solely] Using precompiled IR for <${l}> | Nodes: ${o.n.length} | Fns: ${o.fns.length}`)):console.error(`[Manifest Error] <${l}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(o))}`)}else console.error(`[Manifest Error] <${l}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof s.template}`)}else if(s.template.trim())try{const e=o.parseHtml(s.template);s.ir=t.buildIR(e,{source:s.template,filename:l})}catch(i){const o=i instanceof Error?i:new Error(String(i));console.error(`[Compiler Error] <${l}>: 模板编译失败\n错误: ${o.message}\n模板长度: ${s.template.length} 字符`,e.IS_DEV?o.stack:"")}else e.IS_DEV&&console.warn(`[Solely] <${l}>: 模板为空字符串`);if(s.styles&&!s.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(s.styles),s.sheet=e)}catch(i){e.IS_DEV&&console.warn(`[Style Warning] <${l}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(s.props&&!s.propMap){const e=new Map;s.props.forEach(o=>{const t="string"==typeof o?{name:o}:o,n=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=n.replace(/-([a-z])/g,(e,o)=>o.toUpperCase());e.set(n,{...t,name:r})}),s.propMap=e}class c extends r{}return c[n]=s,customElements.define(l,c),c}};
@@ -1 +1 @@
1
- import{IS_DEV as e}from"../../shared/env.js";import{parseHtml as t}from"../../compiler/parser/parser.js";import{buildIR as r}from"../../compiler/ir/buildIR.js";const o=Symbol.for("solely.manifest"),n=e=>{const n=e;return e=>{const{tagName:s}=n;if(customElements.get(s))return e;if("string"!=typeof n.template||n.ir){if(n.template&&!n.ir&&"object"==typeof n.template&&null!==n.template){const e=n.template;"root"===e.t&&Array.isArray(e.fns)&&Array.isArray(e.n)&&(n.ir=e)}}else if(n.template.trim())try{const e=t(n.template);n.ir=r(e,{source:n.template,filename:s})}catch(c){c instanceof Error||new Error(String(c))}if(n.styles&&!n.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(n.styles),n.sheet=e)}catch(c){}if(n.props&&!n.propMap){const e=new Map;n.props.forEach(t=>{const r="string"==typeof t?{name:t}:t,o=r.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),n=o.replace(/-([a-z])/g,(e,t)=>t.toUpperCase());e.set(o,{...r,name:n})}),n.propMap=e}class i extends e{}return i[o]=n,customElements.define(s,i),i}};export{n as CustomElement};
1
+ import{IS_DEV as e}from"../../shared/env.js";import{parseHtml as o}from"../../compiler/parser/parser.js";import{buildIR as t}from"../../compiler/ir/buildIR.js";const n=Symbol.for("solely.manifest"),r=r=>{const s=r;return r=>{const{tagName:l}=s;if(customElements.get(l))return e&&console.warn(`[Solely] 标签名称 "${l}" 已经被注册,跳过重复定义。`),r;if("string"!=typeof s.template||s.ir){if(s.template&&!s.ir)if("object"==typeof s.template&&null!==s.template){const o=s.template;"root"===o.t&&Array.isArray(o.fns)&&Array.isArray(o.n)?(s.ir=o,e&&console.log(`[Solely] Using precompiled IR for <${l}> | Nodes: ${o.n.length} | Fns: ${o.fns.length}`)):console.error(`[Manifest Error] <${l}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(o))}`)}else console.error(`[Manifest Error] <${l}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof s.template}`)}else if(s.template.trim())try{const e=o(s.template);s.ir=t(e,{source:s.template,filename:l})}catch(i){const o=i instanceof Error?i:new Error(String(i));console.error(`[Compiler Error] <${l}>: 模板编译失败\n错误: ${o.message}\n模板长度: ${s.template.length} 字符`,e?o.stack:"")}else e&&console.warn(`[Solely] <${l}>: 模板为空字符串`);if(s.styles&&!s.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(s.styles),s.sheet=e)}catch(i){e&&console.warn(`[Style Warning] <${l}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(s.props&&!s.propMap){const e=new Map;s.props.forEach(o=>{const t="string"==typeof o?{name:o}:o,n=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=n.replace(/-([a-z])/g,(e,o)=>o.toUpperCase());e.set(n,{...t,name:r})}),s.propMap=e}class c extends r{}return c[n]=s,customElements.define(l,c),c}};export{r as CustomElement};
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty,e=(e,s,o)=>((e,s,o)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o)(e,"symbol"!=typeof s?s+"":s,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../types/ast.cjs"),o=require("../../shared/templateError.cjs"),n=require("../../shared/env.cjs"),i=Symbol("solely.irCtx"),r=Symbol("solely.irEvents"),c=Symbol("solely.prevClassObj"),l=Symbol("solely.prevStyleObj"),a={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},h={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},u=new Set(["data-","aria-","role","form"]),f=new Set(["value","selectedIndex"]);function d(t,e){var s;const o=null==(s=e.a)?void 0:s.find(t=>"class"===t.k&&!t.d);(null==o?void 0:o.v)&&t.setAttribute("class",o.v)}function m(t,e){var s;if(!t.style)return;const o=null==(s=e.a)?void 0:s.find(t=>"style"===t.k&&!t.d),n=o?b(o.v):{};for(const i in n){const e=n[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}const p=t=>!(!t||0===t.length||/\s/.test(t)&&(n.IS_DEV,1));function b(t){const e={},s=[[t]];for(;s.length;){const[t,o]=s.pop();if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let o;for(;null!==(o=s.exec(t));){const t=o[1].trim(),s=o[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const n in t){const i=t[n];if(null==i)continue;const r=o?`${o}-${n}`:n;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function y(t,e,s){const o=null==s?"":String(s),n=e.indexOf(":");if(n>0){const s=e.slice(0,n),i=a[s];if(i)return void(t.getAttributeNS(i,e)!==o&&t.setAttributeNS(i,e,o))}t.getAttribute(e)!==o&&t.setAttribute(e,o)}function v(t,e,s){const o=h[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||u.has(e))return void y(t,e,s);const n=t,i=n.tagName;if(null!=s){if("src"===o||"href"===o){const e=String(s);if(n[o]===e||t.getAttribute(o)===e)return}if("value"!==o||"INPUT"!==i&&"TEXTAREA"!==i||n.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==n.ownerSVGElement)&&!h[e]?y(t,e,s):n[o]!==s&&(n[o]=s);else{if(n[o]===s)return;n[o]=s}}else if("boolean"==typeof n[o])!1!==n[o]&&(n[o]=!1);else{const s=n[o];""!==s&&void 0!==s&&(n[o]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class w{constructor(t,s,o={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=o}evalIR(t,e,s){var n;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return o.showTemplateError(r.message||r.toString(),(null==(n=this.ir.m)?void 0:n.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g;return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,o=!1){const n=[],a=t;let h;a[i]||(a[i]={loops:null}),a[i].loops=s,a[r]||(a[r]=Object.create(null));let u,d=!1,m=!1;for(const c of e){const{k:e,f:l,d:p,v:b}=c;if(":class"===e){h=this.evalIR(l,[s],c.o),d=!0;continue}if(":style"===e){u=this.evalIR(l,[s],c.o),m=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),n=c.r??"user";let h=a[r][s];if(h||(h=a[r][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of h.model)e(t);for(const e of h.user)e(t)})),!o){const t=t=>this.evalIR(l,[t,a[i].loops],c.o);h[n].push(t)}continue}if("mounted"===e){o||requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("updated"===e){o&&requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("ref"===e&&b){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[b]=t;continue}const S=p?this.evalIR(l,[s],c.o):b??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&f.has(s)?n.push(()=>v(t,s,S)):v(t,s,S)}else o||y(t,e,String(S))}return d&&((t,e)=>{const s=t,o=s[c],n=function(t){const e={},s=[t];for(;s.length;){const t=s.pop();if(t)if("string"==typeof t){const s=t.split(" ");for(let t=0;t<s.length;t++){const o=s[t].trim();o&&(e[o]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push(t[e]);else if("object"==typeof t)for(const s in t)t[s]&&(e[s]=!0)}return e}(e),i={};for(const c in n)p(c)&&(i[c]=n[c]);if(!o){for(const e in i)t.classList.add(e);return void(s[c]=i)}let r=!1;for(const c in o)i[c]||(t.classList.remove(c),r=!0);for(const c in i)o[c]||(t.classList.add(c),r=!0);r&&(s[c]=i)})(t,h),m&&((t,e)=>{const s=t,o=b(e),n=s[l];if(!n){for(const e in o){const s=o[e];e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s}return void(s[l]=o)}let i=!1;for(const r in n)r in o||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in o){const e=o[r];e!==n[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[l]=o)})(t,u),n}updateNode(t,e,s){const o=e.d?this.evalIR(e.f,[s],e.o):e.x||"";e.d&&t.textContent!==o&&(t.textContent=o)}createStaticSubtree(t,e,o){var n;switch(t.t){case s.ASTType.Element:{const s=this.createElement(t,e);d(s,t),m(s,t);const i=this.applyAttrs(s,t.a??[],o);return null==(n=t.c)||n.forEach(t=>{const e=this.createStaticSubtree(t,s,o);s.appendChild(e)}),i.forEach(t=>t()),s}case s.ASTType.Text:return this.createText(t,o);case s.ASTType.Comment:return this.createComment(t,o);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,o){const n=this.staticSubtreeCache.get(e);if(n){const t=n.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,o);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,o,n,i){var r,c,l,a;const h=o+"-"+e,u=this.nodeMap.get(h);let f;if(1!==t.s)if(u){f=u.node,u.marker=this.marker;let e=[];t.d&&(t.t===s.ASTType.Element?e=this.applyAttrs(f,t.a??[],i,!0):this.updateNode(f,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,h,f,i)}),e.forEach(t=>t())}else switch(t.t){case s.ASTType.Element:f=this.createElement(t,n),d(f,t),m(f,t);const e=this.applyAttrs(f,t.a??[],i);n.appendChild(f),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,h,f,i)}),e.forEach(t=>t());break;case s.ASTType.Text:f=this.createText(t,i),n.appendChild(f),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker});break;case s.ASTType.Comment:f=this.createComment(t,i),n.appendChild(f),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker});break;case s.ASTType.For:{const e=`${h}-end`;let o=null==(l=this.nodeMap.get(e))?void 0:l.node;o?this.nodeMap.get(e).marker=this.marker:(o=document.createComment(`for:${h}`),n.appendChild(o),this.nodeMap.set(e,{irNode:{t:s.ASTType.Comment},node:o,loops:i,marker:this.marker}));const r=this.evalIR(t.f,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var o;const n=[...i,{itmVal:e,idxVal:s}];null==(o=t.c)||o.forEach((t,e)=>{this.irToNode(t,e,`${h}-for-${s}`,c,n)})}),o.parentNode.insertBefore(c,o);break}case s.ASTType.Conditional:{const e=`${h}-end`;let s=null==(a=this.nodeMap.get(e))?void 0:a.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${h}`),n.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let o=0;o<(t.b||[]).length;o++){const e=t.b[o];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${h}-if-${o}`,t,i)}),s.parentNode.insertBefore(t,s);break}}break}}else u?(u.marker=this.marker,f=u.node):(f=this.handleStaticSubtree(t,h,n,i),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:o,loops:n}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f,[o,n],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==o||o.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}exports.IRRenderer=w,exports.createRender=(t,e,s={})=>{const o=new w(t,e,s);return o.mount(),{update:()=>o.update(),destroy:()=>o.destroy()}};
1
+ "use strict";var t=Object.defineProperty,e=(e,s,n)=>((e,s,n)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n)(e,"symbol"!=typeof s?s+"":s,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../types/ast.cjs"),n=require("../../shared/templateError.cjs"),o=require("../../shared/env.cjs"),i=Symbol("solely.irCtx"),r=Symbol("solely.irEvents"),c=Symbol("solely.prevClassObj"),l=Symbol("solely.prevStyleObj"),a={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},h={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},u=new Set(["data-","aria-","role","form"]),f=new Set(["value","selectedIndex"]);function d(t,e){var s;const n=null==(s=e.a)?void 0:s.find(t=>"class"===t.k&&!t.d);(null==n?void 0:n.v)&&t.setAttribute("class",n.v)}function m(t,e){var s;if(!t.style)return;const n=null==(s=e.a)?void 0:s.find(t=>"style"===t.k&&!t.d),o=n?b(n.v):{};for(const i in o){const e=o[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}const p=t=>!(!t||0===t.length||/\s/.test(t)&&(o.IS_DEV&&console.warn(`[Solely] Invalid class name "${t}" contains whitespace, will be ignored`),1));function b(t){const e={},s=[[t]];for(;s.length;){const[t,n]=s.pop();if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let n;for(;null!==(n=s.exec(t));){const t=n[1].trim(),s=n[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const o in t){const i=t[o];if(null==i)continue;const r=n?`${n}-${o}`:o;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function y(t,e,s){const n=null==s?"":String(s),o=e.indexOf(":");if(o>0){const s=e.slice(0,o),i=a[s];if(i)return void(t.getAttributeNS(i,e)!==n&&t.setAttributeNS(i,e,n))}t.getAttribute(e)!==n&&t.setAttribute(e,n)}function v(t,e,s){const n=h[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||u.has(e))return void y(t,e,s);const o=t,i=o.tagName;if(null!=s){if("src"===n||"href"===n){const e=String(s);if(o[n]===e||t.getAttribute(n)===e)return}if("value"!==n||"INPUT"!==i&&"TEXTAREA"!==i||o.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==o.ownerSVGElement)&&!h[e]?y(t,e,s):o[n]!==s&&(o[n]=s);else{if(o[n]===s)return;o[n]=s}}else if("boolean"==typeof o[n])!1!==o[n]&&(o[n]=!1);else{const s=o[n];""!==s&&void 0!==s&&(o[n]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class w{constructor(t,s,n={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=n}evalIR(t,e,s){var o;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return n.showTemplateError(r.message||r.toString(),(null==(o=this.ir.m)?void 0:o.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g;return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,n=!1){const o=[],a=t;let h;a[i]||(a[i]={loops:null}),a[i].loops=s,a[r]||(a[r]=Object.create(null));let u,d=!1,m=!1;for(const c of e){const{k:e,f:l,d:p,v:b}=c;if(":class"===e){h=this.evalIR(l,[s],c.o),d=!0;continue}if(":style"===e){u=this.evalIR(l,[s],c.o),m=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),o=c.r??"user";let h=a[r][s];if(h||(h=a[r][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of h.model)e(t);for(const e of h.user)e(t)})),!n){const t=t=>this.evalIR(l,[t,a[i].loops],c.o);h[o].push(t)}continue}if("mounted"===e){n||requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("updated"===e){n&&requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("ref"===e&&b){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[b]=t;continue}const S=p?this.evalIR(l,[s],c.o):b??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&f.has(s)?o.push(()=>v(t,s,S)):v(t,s,S)}else n||y(t,e,String(S))}return d&&((t,e)=>{const s=t,n=s[c],o=function(t){const e={},s=[t];for(;s.length;){const t=s.pop();if(t)if("string"==typeof t){const s=t.split(" ");for(let t=0;t<s.length;t++){const n=s[t].trim();n&&(e[n]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push(t[e]);else if("object"==typeof t)for(const s in t)t[s]&&(e[s]=!0)}return e}(e),i={};for(const c in o)p(c)&&(i[c]=o[c]);if(!n){for(const e in i)t.classList.add(e);return void(s[c]=i)}let r=!1;for(const c in n)i[c]||(t.classList.remove(c),r=!0);for(const c in i)n[c]||(t.classList.add(c),r=!0);r&&(s[c]=i)})(t,h),m&&((t,e)=>{const s=t,n=b(e),o=s[l];if(!o){for(const e in n){const s=n[e];e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s}return void(s[l]=n)}let i=!1;for(const r in o)r in n||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in n){const e=n[r];e!==o[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[l]=n)})(t,u),o}updateNode(t,e,s){const n=e.d?this.evalIR(e.f,[s],e.o):e.x||"";e.d&&t.textContent!==n&&(t.textContent=n)}createStaticSubtree(t,e,n){var o;switch(t.t){case s.ASTType.Element:{const s=this.createElement(t,e);d(s,t),m(s,t);const i=this.applyAttrs(s,t.a??[],n);return null==(o=t.c)||o.forEach(t=>{const e=this.createStaticSubtree(t,s,n);s.appendChild(e)}),i.forEach(t=>t()),s}case s.ASTType.Text:return this.createText(t,n);case s.ASTType.Comment:return this.createComment(t,n);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,n){const o=this.staticSubtreeCache.get(e);if(o){const t=o.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,n);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,n,o,i){var r,c,l,a;const h=n+"-"+e,u=this.nodeMap.get(h);let f;if(1!==t.s)if(u){f=u.node,u.marker=this.marker;let e=[];t.d&&(t.t===s.ASTType.Element?e=this.applyAttrs(f,t.a??[],i,!0):this.updateNode(f,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,h,f,i)}),e.forEach(t=>t())}else switch(t.t){case s.ASTType.Element:f=this.createElement(t,o),d(f,t),m(f,t);const e=this.applyAttrs(f,t.a??[],i);o.appendChild(f),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,h,f,i)}),e.forEach(t=>t());break;case s.ASTType.Text:f=this.createText(t,i),o.appendChild(f),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker});break;case s.ASTType.Comment:f=this.createComment(t,i),o.appendChild(f),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker});break;case s.ASTType.For:{const e=`${h}-end`;let n=null==(l=this.nodeMap.get(e))?void 0:l.node;n?this.nodeMap.get(e).marker=this.marker:(n=document.createComment(`for:${h}`),o.appendChild(n),this.nodeMap.set(e,{irNode:{t:s.ASTType.Comment},node:n,loops:i,marker:this.marker}));const r=this.evalIR(t.f,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var n;const o=[...i,{itmVal:e,idxVal:s}];null==(n=t.c)||n.forEach((t,e)=>{this.irToNode(t,e,`${h}-for-${s}`,c,o)})}),n.parentNode.insertBefore(c,n);break}case s.ASTType.Conditional:{const e=`${h}-end`;let s=null==(a=this.nodeMap.get(e))?void 0:a.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${h}`),o.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let n=0;n<(t.b||[]).length;n++){const e=t.b[n];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${h}-if-${n}`,t,i)}),s.parentNode.insertBefore(t,s);break}}break}}else u?(u.marker=this.marker,f=u.node):(f=this.handleStaticSubtree(t,h,o,i),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:n,loops:o}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f,[n,o],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==n||n.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}exports.IRRenderer=w,exports.createRender=(t,e,s={})=>{const n=new w(t,e,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};
@@ -1 +1 @@
1
- var t=Object.defineProperty,e=(e,s,o)=>((e,s,o)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o)(e,"symbol"!=typeof s?s+"":s,o);import{ASTType as s}from"../../types/ast.js";import{showTemplateError as o}from"../../shared/templateError.js";import{IS_DEV as n}from"../../shared/env.js";const i=Symbol("solely.irCtx"),r=Symbol("solely.irEvents"),c=Symbol("solely.prevClassObj"),l=Symbol("solely.prevStyleObj"),h={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},a={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},f=new Set(["data-","aria-","role","form"]),u=new Set(["value","selectedIndex"]);function d(t,e){var s;const o=null==(s=e.a)?void 0:s.find(t=>"class"===t.k&&!t.d);(null==o?void 0:o.v)&&t.setAttribute("class",o.v)}function m(t,e){var s;if(!t.style)return;const o=null==(s=e.a)?void 0:s.find(t=>"style"===t.k&&!t.d),n=o?y(o.v):{};for(const i in n){const e=n[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}const p=t=>!(!t||0===t.length||/\s/.test(t));function y(t){const e={},s=[[t]];for(;s.length;){const[t,o]=s.pop();if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let o;for(;null!==(o=s.exec(t));){const t=o[1].trim(),s=o[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const n in t){const i=t[n];if(null==i)continue;const r=o?`${o}-${n}`:n;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function b(t,e,s){const o=null==s?"":String(s),n=e.indexOf(":");if(n>0){const s=e.slice(0,n),i=h[s];if(i)return void(t.getAttributeNS(i,e)!==o&&t.setAttributeNS(i,e,o))}t.getAttribute(e)!==o&&t.setAttribute(e,o)}function v(t,e,s){const o=a[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||f.has(e))return void b(t,e,s);const n=t,i=n.tagName;if(null!=s){if("src"===o||"href"===o){const e=String(s);if(n[o]===e||t.getAttribute(o)===e)return}if("value"!==o||"INPUT"!==i&&"TEXTAREA"!==i||n.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==n.ownerSVGElement)&&!a[e]?b(t,e,s):n[o]!==s&&(n[o]=s);else{if(n[o]===s)return;n[o]=s}}else if("boolean"==typeof n[o])!1!==n[o]&&(n[o]=!1);else{const s=n[o];""!==s&&void 0!==s&&(n[o]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class w{constructor(t,s,o={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=o}evalIR(t,e,s){var n;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return o(r.message||r.toString(),(null==(n=this.ir.m)?void 0:n.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g;return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,o=!1){const n=[],h=t;let a;h[i]||(h[i]={loops:null}),h[i].loops=s,h[r]||(h[r]=Object.create(null));let f,d=!1,m=!1;for(const c of e){const{k:e,f:l,d:p,v:y}=c;if(":class"===e){a=this.evalIR(l,[s],c.o),d=!0;continue}if(":style"===e){f=this.evalIR(l,[s],c.o),m=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),n=c.r??"user";let a=h[r][s];if(a||(a=h[r][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of a.model)e(t);for(const e of a.user)e(t)})),!o){const t=t=>this.evalIR(l,[t,h[i].loops],c.o);a[n].push(t)}continue}if("mounted"===e){o||requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("updated"===e){o&&requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("ref"===e&&y){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[y]=t;continue}const S=p?this.evalIR(l,[s],c.o):y??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&u.has(s)?n.push(()=>v(t,s,S)):v(t,s,S)}else o||b(t,e,String(S))}return d&&((t,e)=>{const s=t,o=s[c],n=function(t){const e={},s=[t];for(;s.length;){const t=s.pop();if(t)if("string"==typeof t){const s=t.split(" ");for(let t=0;t<s.length;t++){const o=s[t].trim();o&&(e[o]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push(t[e]);else if("object"==typeof t)for(const s in t)t[s]&&(e[s]=!0)}return e}(e),i={};for(const c in n)p(c)&&(i[c]=n[c]);if(!o){for(const e in i)t.classList.add(e);return void(s[c]=i)}let r=!1;for(const c in o)i[c]||(t.classList.remove(c),r=!0);for(const c in i)o[c]||(t.classList.add(c),r=!0);r&&(s[c]=i)})(t,a),m&&((t,e)=>{const s=t,o=y(e),n=s[l];if(!n){for(const e in o){const s=o[e];e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s}return void(s[l]=o)}let i=!1;for(const r in n)r in o||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in o){const e=o[r];e!==n[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[l]=o)})(t,f),n}updateNode(t,e,s){const o=e.d?this.evalIR(e.f,[s],e.o):e.x||"";e.d&&t.textContent!==o&&(t.textContent=o)}createStaticSubtree(t,e,o){var n;switch(t.t){case s.Element:{const s=this.createElement(t,e);d(s,t),m(s,t);const i=this.applyAttrs(s,t.a??[],o);return null==(n=t.c)||n.forEach(t=>{const e=this.createStaticSubtree(t,s,o);s.appendChild(e)}),i.forEach(t=>t()),s}case s.Text:return this.createText(t,o);case s.Comment:return this.createComment(t,o);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,o){const n=this.staticSubtreeCache.get(e);if(n){const t=n.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,o);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,o,n,i){var r,c,l,h;const a=o+"-"+e,f=this.nodeMap.get(a);let u;if(1!==t.s)if(f){u=f.node,f.marker=this.marker;let e=[];t.d&&(t.t===s.Element?e=this.applyAttrs(u,t.a??[],i,!0):this.updateNode(u,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,a,u,i)}),e.forEach(t=>t())}else switch(t.t){case s.Element:u=this.createElement(t,n),d(u,t),m(u,t);const e=this.applyAttrs(u,t.a??[],i);n.appendChild(u),this.nodeMap.set(a,{irNode:t,node:u,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,a,u,i)}),e.forEach(t=>t());break;case s.Text:u=this.createText(t,i),n.appendChild(u),this.nodeMap.set(a,{irNode:t,node:u,loops:i,marker:this.marker});break;case s.Comment:u=this.createComment(t,i),n.appendChild(u),this.nodeMap.set(a,{irNode:t,node:u,loops:i,marker:this.marker});break;case s.For:{const e=`${a}-end`;let o=null==(l=this.nodeMap.get(e))?void 0:l.node;o?this.nodeMap.get(e).marker=this.marker:(o=document.createComment(`for:${a}`),n.appendChild(o),this.nodeMap.set(e,{irNode:{t:s.Comment},node:o,loops:i,marker:this.marker}));const r=this.evalIR(t.f,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var o;const n=[...i,{itmVal:e,idxVal:s}];null==(o=t.c)||o.forEach((t,e)=>{this.irToNode(t,e,`${a}-for-${s}`,c,n)})}),o.parentNode.insertBefore(c,o);break}case s.Conditional:{const e=`${a}-end`;let s=null==(h=this.nodeMap.get(e))?void 0:h.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${a}`),n.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let o=0;o<(t.b||[]).length;o++){const e=t.b[o];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${a}-if-${o}`,t,i)}),s.parentNode.insertBefore(t,s);break}}break}}else f?(f.marker=this.marker,u=f.node):(u=this.handleStaticSubtree(t,a,n,i),this.nodeMap.set(a,{irNode:t,node:u,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:o,loops:n}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f,[o,n],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==o||o.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}const S=(t,e,s={})=>{const o=new w(t,e,s);return o.mount(),{update:()=>o.update(),destroy:()=>o.destroy()}};export{w as IRRenderer,S as createRender};
1
+ var t=Object.defineProperty,e=(e,s,o)=>((e,s,o)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o)(e,"symbol"!=typeof s?s+"":s,o);import{ASTType as s}from"../../types/ast.js";import{showTemplateError as o}from"../../shared/templateError.js";import{IS_DEV as n}from"../../shared/env.js";const i=Symbol("solely.irCtx"),r=Symbol("solely.irEvents"),c=Symbol("solely.prevClassObj"),l=Symbol("solely.prevStyleObj"),a={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},h={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},f=new Set(["data-","aria-","role","form"]),u=new Set(["value","selectedIndex"]);function d(t,e){var s;const o=null==(s=e.a)?void 0:s.find(t=>"class"===t.k&&!t.d);(null==o?void 0:o.v)&&t.setAttribute("class",o.v)}function m(t,e){var s;if(!t.style)return;const o=null==(s=e.a)?void 0:s.find(t=>"style"===t.k&&!t.d),n=o?y(o.v):{};for(const i in n){const e=n[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}const p=t=>!(!t||0===t.length||/\s/.test(t)&&(n&&console.warn(`[Solely] Invalid class name "${t}" contains whitespace, will be ignored`),1));function y(t){const e={},s=[[t]];for(;s.length;){const[t,o]=s.pop();if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let o;for(;null!==(o=s.exec(t));){const t=o[1].trim(),s=o[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const n in t){const i=t[n];if(null==i)continue;const r=o?`${o}-${n}`:n;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function b(t,e,s){const o=null==s?"":String(s),n=e.indexOf(":");if(n>0){const s=e.slice(0,n),i=a[s];if(i)return void(t.getAttributeNS(i,e)!==o&&t.setAttributeNS(i,e,o))}t.getAttribute(e)!==o&&t.setAttribute(e,o)}function v(t,e,s){const o=h[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||f.has(e))return void b(t,e,s);const n=t,i=n.tagName;if(null!=s){if("src"===o||"href"===o){const e=String(s);if(n[o]===e||t.getAttribute(o)===e)return}if("value"!==o||"INPUT"!==i&&"TEXTAREA"!==i||n.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==n.ownerSVGElement)&&!h[e]?b(t,e,s):n[o]!==s&&(n[o]=s);else{if(n[o]===s)return;n[o]=s}}else if("boolean"==typeof n[o])!1!==n[o]&&(n[o]=!1);else{const s=n[o];""!==s&&void 0!==s&&(n[o]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class w{constructor(t,s,o={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=o}evalIR(t,e,s){var n;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return o(r.message||r.toString(),(null==(n=this.ir.m)?void 0:n.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g;return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,o=!1){const n=[],a=t;let h;a[i]||(a[i]={loops:null}),a[i].loops=s,a[r]||(a[r]=Object.create(null));let f,d=!1,m=!1;for(const c of e){const{k:e,f:l,d:p,v:y}=c;if(":class"===e){h=this.evalIR(l,[s],c.o),d=!0;continue}if(":style"===e){f=this.evalIR(l,[s],c.o),m=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),n=c.r??"user";let h=a[r][s];if(h||(h=a[r][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of h.model)e(t);for(const e of h.user)e(t)})),!o){const t=t=>this.evalIR(l,[t,a[i].loops],c.o);h[n].push(t)}continue}if("mounted"===e){o||requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("updated"===e){o&&requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("ref"===e&&y){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[y]=t;continue}const S=p?this.evalIR(l,[s],c.o):y??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&u.has(s)?n.push(()=>v(t,s,S)):v(t,s,S)}else o||b(t,e,String(S))}return d&&((t,e)=>{const s=t,o=s[c],n=function(t){const e={},s=[t];for(;s.length;){const t=s.pop();if(t)if("string"==typeof t){const s=t.split(" ");for(let t=0;t<s.length;t++){const o=s[t].trim();o&&(e[o]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push(t[e]);else if("object"==typeof t)for(const s in t)t[s]&&(e[s]=!0)}return e}(e),i={};for(const c in n)p(c)&&(i[c]=n[c]);if(!o){for(const e in i)t.classList.add(e);return void(s[c]=i)}let r=!1;for(const c in o)i[c]||(t.classList.remove(c),r=!0);for(const c in i)o[c]||(t.classList.add(c),r=!0);r&&(s[c]=i)})(t,h),m&&((t,e)=>{const s=t,o=y(e),n=s[l];if(!n){for(const e in o){const s=o[e];e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s}return void(s[l]=o)}let i=!1;for(const r in n)r in o||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in o){const e=o[r];e!==n[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[l]=o)})(t,f),n}updateNode(t,e,s){const o=e.d?this.evalIR(e.f,[s],e.o):e.x||"";e.d&&t.textContent!==o&&(t.textContent=o)}createStaticSubtree(t,e,o){var n;switch(t.t){case s.Element:{const s=this.createElement(t,e);d(s,t),m(s,t);const i=this.applyAttrs(s,t.a??[],o);return null==(n=t.c)||n.forEach(t=>{const e=this.createStaticSubtree(t,s,o);s.appendChild(e)}),i.forEach(t=>t()),s}case s.Text:return this.createText(t,o);case s.Comment:return this.createComment(t,o);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,o){const n=this.staticSubtreeCache.get(e);if(n){const t=n.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,o);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,o,n,i){var r,c,l,a;const h=o+"-"+e,f=this.nodeMap.get(h);let u;if(1!==t.s)if(f){u=f.node,f.marker=this.marker;let e=[];t.d&&(t.t===s.Element?e=this.applyAttrs(u,t.a??[],i,!0):this.updateNode(u,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,h,u,i)}),e.forEach(t=>t())}else switch(t.t){case s.Element:u=this.createElement(t,n),d(u,t),m(u,t);const e=this.applyAttrs(u,t.a??[],i);n.appendChild(u),this.nodeMap.set(h,{irNode:t,node:u,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,h,u,i)}),e.forEach(t=>t());break;case s.Text:u=this.createText(t,i),n.appendChild(u),this.nodeMap.set(h,{irNode:t,node:u,loops:i,marker:this.marker});break;case s.Comment:u=this.createComment(t,i),n.appendChild(u),this.nodeMap.set(h,{irNode:t,node:u,loops:i,marker:this.marker});break;case s.For:{const e=`${h}-end`;let o=null==(l=this.nodeMap.get(e))?void 0:l.node;o?this.nodeMap.get(e).marker=this.marker:(o=document.createComment(`for:${h}`),n.appendChild(o),this.nodeMap.set(e,{irNode:{t:s.Comment},node:o,loops:i,marker:this.marker}));const r=this.evalIR(t.f,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var o;const n=[...i,{itmVal:e,idxVal:s}];null==(o=t.c)||o.forEach((t,e)=>{this.irToNode(t,e,`${h}-for-${s}`,c,n)})}),o.parentNode.insertBefore(c,o);break}case s.Conditional:{const e=`${h}-end`;let s=null==(a=this.nodeMap.get(e))?void 0:a.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${h}`),n.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let o=0;o<(t.b||[]).length;o++){const e=t.b[o];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${h}-if-${o}`,t,i)}),s.parentNode.insertBefore(t,s);break}}break}}else f?(f.marker=this.marker,u=f.node):(u=this.handleStaticSubtree(t,h,n,i),this.nodeMap.set(h,{irNode:t,node:u,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:o,loops:n}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f,[o,n],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==o||o.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}const S=(t,e,s={})=>{const o=new w(t,e,s);return o.mount(),{update:()=>o.update(),destroy:()=>o.destroy()}};export{w as IRRenderer,S as createRender};
@@ -1 +1 @@
1
- "use strict";function t(t){let n=0;for(let e=0;e<t.length;){const o=t.codePointAt(e);"\t"!==t[e]?(n+=o>=9472&&o<=9599||o>255?2:1,e+=o>65535?2:1):(n+=4,e++)}return n}function n(t,n={}){const{lineIndex:e=0,totalLines:o=1}=n,i=Math.max(1,Math.floor(t));return(o<=1||0===e?"^":"~").repeat(i)}Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.showTemplateError=function(e,o="",i,l="component"){var r;if((null==e?void 0:e.message)??String(e),!o||!(null==i?void 0:i.loc)||i.loc.length<2)return void(null==i||i.expr);const s=i.loc;let c=s[0]||0,u=s[1]||0;c|=0,u|=0,c<1&&(c=1),u<1&&(u=1);const f=o.split("\n");if(c>f.length)return;const a=c-1,M=Math.max(0,a-3),d=Math.min(f.length-1,a+3),h=String(d+1).length,v=(null==(r=i.expr)?void 0:r.trim())??"",S=v?v.split("\n"):[],g=v?Math.max(...S.map(t)):0,x=S.length>1;for(let p=M;p<=d;p++){const e=f[p],o=String(p+1).padStart(h," ");if(p!==a)continue;const i=t(e.slice(0,Math.max(0,u-1)));if(" ".repeat(h+3),o.padEnd(h," "),x)for(let l=0;l<S.length;l++){const e=S[l],o=a+l;let r=0;if(0===l)r=i;else if(o<f.length){const n=f[o],e=n.search(/\S/);r=t(-1===e?n:n.slice(0,e))}n(Math.max(1,t(e.trim())),{lineIndex:l,totalLines:S.length})," ".repeat(r),0===l||o<f.length&&(String(o+1).padEnd(h," "),f[o])}else" ".repeat(i),n(g||1)}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o="#858585",n="#3c1e1e",c="#f8f8f2",t="#ff6b6b",e="#ff6b6b",l="#ffffff",r="#a0a0a0",i="#5ddcff";function s(o){let n=0;for(let c=0;c<o.length;){const t=o.codePointAt(c);"\t"!==o[c]?(n+=t>=9472&&t<=9599||t>255?2:1,c+=t>65535?2:1):(n+=4,c++)}return n}function f(o,n={}){const{lineIndex:c=0,totalLines:t=1}=n,e=Math.max(1,Math.floor(o));return(t<=1||0===c?"^":"~").repeat(e)}exports.showTemplateError=function($,d="",a,u="component"){var p;const g=`%cTemplate Error%c in <${u}> → ${(null==$?void 0:$.message)??String($)}`,b=[`color:${l};background:${e};padding:4px 10px;border-radius:6px;font-weight:bold;`,`color:${t};font-weight:bold;`];if(!d||!(null==a?void 0:a.loc)||a.loc.length<2)return console.error(g,...b),void((null==a?void 0:a.expr)&&console.log(`Expression: ${a.expr.trim()}`));const h=a.loc;let x=h[0]||0,v=h[1]||0;x|=0,v|=0,x<1&&(x=1),v<1&&(v=1);const M=d.split("\n");if(x>M.length)return void console.error(`[Template Error] 行号 ${x} 超出范围`);const m=x-1,w=Math.max(0,m-3),S=Math.min(M.length-1,m+3),E=String(S+1).length,L=(null==(p=a.expr)?void 0:p.trim())??"",k=L?L.split("\n"):[],y=L?Math.max(...k.map(s)):0,I=k.length>1,T=`color:${o};`,j=`color:${t};font-weight:bold;`,C=`color:${o};`,O=`color:${c};background:${n};padding:0 4px;`,q=`color:${o};`,z=`color:${t};font-weight:bold;padding:0 4px;`;console.groupCollapsed(`${g} %c(Line:${x}, Col:${v})`,...b,`color:${o};font-weight:normal;`);for(let o=w;o<=S;o++){const n=M[o],c=String(o+1).padStart(E," ");if(o!==m){console.log(`%c${c} │%c ${n}`,T,C);continue}const t=s(n.slice(0,Math.max(0,v-1))),e=" ".repeat(E+3),l=c.padEnd(E," ");if(console.log(`%c${l} │%c ${n}`,j,O),I)for(let o=0;o<k.length;o++){const n=k[o],c=m+o;let l=0;if(0===o)l=t;else if(c<M.length){const o=M[c],n=o.search(/\S/);l=s(-1===n?o:o.slice(0,n))}const r=f(Math.max(1,s(n.trim())),{lineIndex:o,totalLines:k.length}),i=e+" ".repeat(l);if(0===o)console.log(`%c${i}%c${r}`,q,z);else if(c<M.length){const o=String(c+1).padEnd(E," "),n=M[c];console.log(`%c${o} │%c ${n}`,j,O),console.log(`%c${i}%c${r}`,q,z)}}else{const o=e+" ".repeat(t),n=f(y||1);console.log(`%c${o}%c${n}`,q,z)}}L&&console.log(`%cExpression:%c ${L}`,`color:${r};font-weight:bold;`,`color:${i};font-family:monospace;`),console.groupEnd()};
@@ -1 +1 @@
1
- function t(t){let n=0;for(let o=0;o<t.length;){const e=t.codePointAt(o);"\t"!==t[o]?(n+=e>=9472&&e<=9599||e>255?2:1,o+=e>65535?2:1):(n+=4,o++)}return n}function n(t,n={}){const{lineIndex:o=0,totalLines:e=1}=n,i=Math.max(1,Math.floor(t));return(e<=1||0===o?"^":"~").repeat(i)}function o(o,e="",i,l="component"){var r;if((null==o?void 0:o.message)??String(o),!e||!(null==i?void 0:i.loc)||i.loc.length<2)return void(null==i||i.expr);const c=i.loc;let s=c[0]||0,f=c[1]||0;s|=0,f|=0,s<1&&(s=1),f<1&&(f=1);const u=e.split("\n");if(s>u.length)return;const a=s-1,h=Math.max(0,a-3),M=Math.min(u.length-1,a+3),d=String(M+1).length,v=(null==(r=i.expr)?void 0:r.trim())??"",S=v?v.split("\n"):[],g=v?Math.max(...S.map(t)):0,x=S.length>1;for(let p=h;p<=M;p++){const o=u[p],e=String(p+1).padStart(d," ");if(p!==a)continue;const i=t(o.slice(0,Math.max(0,f-1)));" ".repeat(d+3);if(e.padEnd(d," "),x)for(let l=0;l<S.length;l++){const o=S[l],e=a+l;let r=0;if(0===l)r=i;else if(e<u.length){const n=u[e],o=n.search(/\S/);r=t(-1===o?n:n.slice(0,o))}n(Math.max(1,t(o.trim())),{lineIndex:l,totalLines:S.length})," ".repeat(r),0===l||e<u.length&&(String(e+1).padEnd(d," "),u[e])}else" ".repeat(i),n(g||1)}}export{o as showTemplateError};
1
+ const o="#858585",n="#3c1e1e",c="#f8f8f2",t="#ff6b6b",e="#ff6b6b",l="#ffffff",r="#a0a0a0",i="#5ddcff";function f(o){let n=0;for(let c=0;c<o.length;){const t=o.codePointAt(c);"\t"!==o[c]?(n+=t>=9472&&t<=9599||t>255?2:1,c+=t>65535?2:1):(n+=4,c++)}return n}function s(o,n={}){const{lineIndex:c=0,totalLines:t=1}=n,e=Math.max(1,Math.floor(o));return(t<=1||0===c?"^":"~").repeat(e)}function $($,d="",a,g="component"){var p;const u=`%cTemplate Error%c in <${g}> → ${(null==$?void 0:$.message)??String($)}`,h=[`color:${l};background:${e};padding:4px 10px;border-radius:6px;font-weight:bold;`,`color:${t};font-weight:bold;`];if(!d||!(null==a?void 0:a.loc)||a.loc.length<2)return console.error(u,...h),void((null==a?void 0:a.expr)&&console.log(`Expression: ${a.expr.trim()}`));const b=a.loc;let x=b[0]||0,v=b[1]||0;x|=0,v|=0,x<1&&(x=1),v<1&&(v=1);const M=d.split("\n");if(x>M.length)return void console.error(`[Template Error] 行号 ${x} 超出范围`);const m=x-1,w=Math.max(0,m-3),S=Math.min(M.length-1,m+3),E=String(S+1).length,L=(null==(p=a.expr)?void 0:p.trim())??"",k=L?L.split("\n"):[],I=L?Math.max(...k.map(f)):0,T=k.length>1,y=`color:${o};`,C=`color:${t};font-weight:bold;`,j=`color:${o};`,q=`color:${c};background:${n};padding:0 4px;`,z=`color:${o};`,A=`color:${t};font-weight:bold;padding:0 4px;`;console.groupCollapsed(`${u} %c(Line:${x}, Col:${v})`,...h,`color:${o};font-weight:normal;`);for(let o=w;o<=S;o++){const n=M[o],c=String(o+1).padStart(E," ");if(o!==m){console.log(`%c${c} │%c ${n}`,y,j);continue}const t=f(n.slice(0,Math.max(0,v-1))),e=" ".repeat(E+3),l=c.padEnd(E," ");if(console.log(`%c${l} │%c ${n}`,C,q),T)for(let o=0;o<k.length;o++){const n=k[o],c=m+o;let l=0;if(0===o)l=t;else if(c<M.length){const o=M[c],n=o.search(/\S/);l=f(-1===n?o:o.slice(0,n))}const r=s(Math.max(1,f(n.trim())),{lineIndex:o,totalLines:k.length}),i=e+" ".repeat(l);if(0===o)console.log(`%c${i}%c${r}`,z,A);else if(c<M.length){const o=String(c+1).padEnd(E," "),n=M[c];console.log(`%c${o} │%c ${n}`,C,q),console.log(`%c${i}%c${r}`,z,A)}}else{const o=e+" ".repeat(t),n=s(I||1);console.log(`%c${o}%c${n}`,z,A)}}L&&console.log(`%cExpression:%c ${L}`,`color:${r};font-weight:bold;`,`color:${i};font-family:monospace;`),console.groupEnd()}export{$ as showTemplateError};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.2.5",
4
+ "version": "0.2.7",
5
5
  "description": "A lightweight TypeScript framework for building web components with compile-time optimizations",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -39,16 +39,6 @@
39
39
  "default": "./dist/compiler/index.cjs"
40
40
  }
41
41
  },
42
- "./compiler/*": {
43
- "import": {
44
- "types": "./dist/compiler/*.d.ts",
45
- "default": "./dist/compiler/*.js"
46
- },
47
- "require": {
48
- "types": "./dist/compiler/*.d.ts",
49
- "default": "./dist/compiler/*.cjs"
50
- }
51
- },
52
42
  "./runtime": {
53
43
  "import": {
54
44
  "types": "./dist/runtime/index.d.ts",
@@ -59,16 +49,6 @@
59
49
  "default": "./dist/runtime/index.cjs"
60
50
  }
61
51
  },
62
- "./runtime/*": {
63
- "import": {
64
- "types": "./dist/runtime/*.d.ts",
65
- "default": "./dist/runtime/*.js"
66
- },
67
- "require": {
68
- "types": "./dist/runtime/*.d.ts",
69
- "default": "./dist/runtime/*.cjs"
70
- }
71
- },
72
52
  "./router": {
73
53
  "import": {
74
54
  "types": "./dist/router/index.d.ts",
@@ -79,16 +59,6 @@
79
59
  "default": "./dist/router/index.cjs"
80
60
  }
81
61
  },
82
- "./router/*": {
83
- "import": {
84
- "types": "./dist/router/*.d.ts",
85
- "default": "./dist/router/*.js"
86
- },
87
- "require": {
88
- "types": "./dist/router/*.d.ts",
89
- "default": "./dist/router/*.cjs"
90
- }
91
- },
92
62
  "./shared": {
93
63
  "import": {
94
64
  "types": "./dist/shared/index.d.ts",
@@ -99,16 +69,6 @@
99
69
  "default": "./dist/shared/index.cjs"
100
70
  }
101
71
  },
102
- "./shared/*": {
103
- "import": {
104
- "types": "./dist/shared/*.d.ts",
105
- "default": "./dist/shared/*.js"
106
- },
107
- "require": {
108
- "types": "./dist/shared/*.d.ts",
109
- "default": "./dist/shared/*.cjs"
110
- }
111
- },
112
72
  "./types": {
113
73
  "import": {
114
74
  "types": "./dist/types/index.d.ts",
@@ -119,16 +79,6 @@
119
79
  "default": "./dist/types/index.cjs"
120
80
  }
121
81
  },
122
- "./types/*": {
123
- "import": {
124
- "types": "./dist/types/*.d.ts",
125
- "default": "./dist/types/*.js"
126
- },
127
- "require": {
128
- "types": "./dist/types/*.d.ts",
129
- "default": "./dist/types/*.cjs"
130
- }
131
- },
132
82
  "./package.json": "./package.json"
133
83
  },
134
84
  "typesVersions": {