solely 0.4.15 → 0.4.17

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,t=(t,n,o)=>((t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o)(t,"symbol"!=typeof n?n+"":n,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../shared/gen-function.cjs"),o=require("../../shared/env.cjs"),c=require("../../types/ast.cjs"),l=require("../../types/lifecycle.cjs"),i=/\{\{[\s\S]*?\}\}/,s={"solely-checkbox":{prop:"checked",event:"change"},"solely-switch":{prop:"checked",event:"change"},"solely-radio":{prop:"checked",event:"change"}},r=new class{constructor(){t(this,"compilers",new Map)}get(e="anonymous"){let t=this.compilers.get(e);return t||(t=new a,this.compilers.set(e,t)),t}clear(e){var t;if(e)null==(t=this.compilers.get(e))||t.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class a{constructor(){t(this,"cache",new Map),t(this,"functions",[])}makeCacheKey(e,t,n){return 0===n.length?`${e}:${t}`:`${e}:${t}:${n.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,t,c){const l=null==t?void 0:t.trim();if(!l)return 0;const i=this.makeCacheKey(e,l,c),s=this.cache.get(i);if(void 0!==s)return s;let r;try{r=n.genFunction(l,e,c)}catch(u){o.IS_DEV&&console.error(`[Solely] IR Compile Error - Type: ${e}, Expr: "${l}"`,u),r=()=>""}const a=this.functions.push(r);return this.cache.set(i,a),a}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function u(e){const t=e[0];return":"===t?{isDynamic:!0,type:"expression"}:"@"===t?{isDynamic:!0,type:"handler"}:l.isLifecycleKind(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function f(e,t,n){e.__m={expr:t??"",loc:n??void 0}}function d(e){if(!e.attrs)return;const t=e.attrs.find(e=>"s-model"===e.key);if(!t)return;const n="$data."+t.value.replace("this.","").replace("$data.",""),o=t.loc,c=(e.tag||"").toLowerCase(),l=e.attrs.find(e=>"type"===e.key),i=(null==l?void 0:l.value)??"text";e.attrs=e.attrs.filter(e=>e!==t);const r=(t,n,c)=>{var l;null==(l=e.attrs)||l.push({key:t,value:n,role:c,loc:o})};if("input"===c){if("checkbox"===i){const t=e.attrs.find(e=>"value"===e.key),o=t?JSON.stringify(t.value):'"on"';return r(":checked",`Array.isArray(${n}) ? ${n}.includes(${o}) : ${n}`),void r("@change",`\n const _v = ${o};\n if(Array.isArray(${n})) {\n const _i = ${n}.indexOf(_v);\n if(checked && _i === -1) ${n}.push(_v);\n else if(!checked && _i > -1) ${n}.splice(_i,1);\n } else {\n ${n} = checked;\n }`,"model")}if("radio"===i){const t=e.attrs.find(e=>"value"===e.key),o=(null==t?void 0:t.value)??"null";return r(":checked",`${n} == ${JSON.stringify(o)}`),void r("@change",`if (checked) ${n} = ${JSON.stringify(o)}`,"model")}return r(":value",n),void r("@input",`${n} = value`,"model")}if("textarea"===c)return r(":value",n),void r("@input",`${n} = value`,"model");if("select"===c)return void(e.attrs.some(e=>"multiple"===e.key)?(r("updated",`\n const values = Array.isArray(${n}) ? ${n} : ${n} != null ? [${n}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),r("@change",`${n} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(r(":value",n),r("@change",`${n} = value`,"model")));const a=s[c],u=(null==a?void 0:a.prop)??"value",f=(null==a?void 0:a.event)??"change";r(`:${u}`,n),r(`@${f}`,`${n} = ${"checked"===u?"checked":"value"===u?"value":`event.target.${u}`}`,"model")}function p(e,t,n,o=null){if(!e.attrs||0===e.attrs.length)return[];const c=[];for(const l of e.attrs){if(o&&o.has(l.key))continue;const{key:i,value:s,role:r}=l,{isDynamic:a,type:d}=u(i);if(a&&d){const o={k:i,f:n.compile(d,s??"",t),d:1,r:r};f(o,s,l.loc??e.loc),c.push(o)}else c.push({k:i,v:s,d:0,r:r})}return c}function h(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const t of e.c)if(!h(t))return!1;if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)if(!h(e))return!1;return!0}function y(e){if(e.c&&e.c.length>0)for(const t of e.c)y(t);if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)y(e);e.t!==c.ASTType.Element&&e.t!==c.ASTType.Text||0===e.d&&h(e)&&(e.s=1)}function v(e,t,n){var l,s,r,a,h,y;const v={t:e.type,d:0};let g=!1;var T;switch(e.type===c.ASTType.Text?(T=e.content)&&i.test(T)&&(g=!0):((null==(l=e.attrs)?void 0:l.some(e=>"s-model"===e.key||u(e.key).isDynamic))&&(g=!0),e.type===c.ASTType.For&&(g=!0)),v.d=g?1:0,e.type){case c.ASTType.Text:{const o=e.content??"";g?(v.f=n.compile("template",o,t),f(v,o,e.loc)):v.x=o;break}case c.ASTType.Element:v.g=e.tag,d(e),v.a=p(e,t,n),e.children&&(v.c=m(e.children,t,n));break;case c.ASTType.For:{const o=null==(s=e.attrs)?void 0:s.find(e=>"each"===e.key),c=(null==o?void 0:o.value)??"";v.f=n.compile("expression",c,t),v.i=(null==(a=null==(r=e.attrs)?void 0:r.find(e=>"item"===e.key))?void 0:a.value)??"item",v.n=(null==(y=null==(h=e.attrs)?void 0:h.find(e=>"index"===e.key))?void 0:y.value)??"index",f(v,c,(null==o?void 0:o.loc)??e.loc);const l=new Set(["each","item","index"]);v.a=p(e,t,n,l);const i=[...t,{i:v.i,x:v.n}];e.children&&(v.c=m(e.children,i,n));break}case c.ASTType.If:case c.ASTType.ElseIf:case c.ASTType.Else:o.IS_DEV&&console.warn(`[Solely] Orphaned conditional node found: ${c.ASTType[e.type]}`),v.a=p(e,t,n),e.children&&(v.c=m(e.children,t,n));break;case c.ASTType.Comment:v.x=e.content??""}return v}function m(e,t,n){var o;const l=[];let i=0;for(;i<e.length;){const s=e[i];if(s.type===c.ASTType.If){const r=[];let a=i;for(;a<e.length;){const l=e[a],i=l.type;if(i!==c.ASTType.If&&i!==c.ASTType.ElseIf&&i!==c.ASTType.Else)break;if(i===c.ASTType.If&&r.length>0)break;let s,u=null,f="";if(i!==c.ASTType.Else){const e=null==(o=l.attrs)?void 0:o.find(e=>"test"===e.key||"condition"===e.key);f=(null==e?void 0:e.value)??"false",u=n.compile("expression",f,t),s=(null==e?void 0:e.loc)??l.loc}const d=l.children?m(l.children,t,n):[],h=p(l,t,n,new Set(["test","condition"]));if(r.push({f:u,c:d,a:h.length>0?h:void 0,__m:{expr:f,loc:s}}),a++,i===c.ASTType.Else)break}l.push({t:c.ASTType.Conditional,d:1,b:r,__m:{loc:s.loc}}),i=a}else l.push(v(s,t,n)),i++}return l}exports.buildIR=function(e,t={}){const{filename:n="anonymous",source:c}=t,l=r.get(n);l.clear();const i=performance.now(),s=m(e,[],l);for(const o of s)y(o);const a=performance.now(),u=l.getStats(),f=s.filter(e=>1===e.d).length,d=s.filter(e=>1===e.s).length,p={t:"root",v:"1.2.0",fns:l.getFunctions(),n:s,s:{tf:u.total,cf:u.cached,dn:f,tn:s.length,sn:d},m:{t:(new Date).toISOString(),as:e.length,fn:n,...c&&{src:c}}};return o.IS_DEV&&console.info(`[Solely] Compiled <${n}> in ${(a-i).toFixed(2)}ms | Nodes: ${s.length} | Fns: ${u.total} | StaticSubtrees: ${d}`),p},exports.clearIRCache=function(e){r.clear(e)},exports.transformModel=d;
1
+ "use strict";var e=Object.defineProperty,t=(t,n,o)=>((t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o)(t,"symbol"!=typeof n?n+"":n,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../shared/gen-function.cjs"),o=require("../../shared/env.cjs"),c=require("../../types/ast.cjs"),l=require("../../types/lifecycle.cjs"),i=/\{\{[\s\S]*?\}\}/,s={"solely-checkbox":{prop:"checked",event:"change"},"solely-switch":{prop:"checked",event:"change"},"solely-radio":{prop:"checked",event:"change"}},r=new class{constructor(){t(this,"compilers",new Map)}get(e="anonymous"){let t=this.compilers.get(e);return t||(t=new a,this.compilers.set(e,t)),t}clear(e){var t;if(e)null==(t=this.compilers.get(e))||t.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class a{constructor(){t(this,"cache",new Map),t(this,"functions",[])}makeCacheKey(e,t,n){return 0===n.length?`${e}:${t}`:`${e}:${t}:${n.map(e=>`${e.i}:${e.x}`).join(";")}`}compile(e,t,c){const l=null==t?void 0:t.trim();if(!l)return 0;const i=this.makeCacheKey(e,l,c),s=this.cache.get(i);if(void 0!==s)return s;let r;try{r=n.genFunction(l,e,c)}catch(u){o.IS_DEV&&console.error(`[Solely] IR Compile Error - Type: ${e}, Expr: "${l}"`,u),r=()=>""}const a=this.functions.push(r);return this.cache.set(i,a),a}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function u(e){const t=e[0];return":"===t?{isDynamic:!0,type:"expression"}:"@"===t?{isDynamic:!0,type:"handler"}:l.isLifecycleKind(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function d(e,t,n){e.__m={expr:t??"",loc:n??void 0}}function f(e){if(!e.attrs)return;const t=e.attrs.find(e=>"s-model"===e.key);if(!t)return;const n=t.value.trim(),o=n.startsWith("$data.")?n:`$data.${n.replace(/^this\./,"")}`,c=t.loc,l=(e.tag||"").toLowerCase(),i=e.attrs.find(e=>"type"===e.key),r=(null==i?void 0:i.value)??"text";e.attrs=e.attrs.filter(e=>e!==t);const a=(t,n,o)=>{var l;null==(l=e.attrs)||l.push({key:t,value:n,role:o,loc:c})};if("input"===l){if("checkbox"===r){const t=e.attrs.find(e=>"value"===e.key),n=t?JSON.stringify(t.value):'"on"';return a(":checked",`Array.isArray(${o}) ? ${o}.includes(${n}) : ${o}`),void a("@change",`\n const _v = ${n};\n if(Array.isArray(${o})) {\n const _i = ${o}.indexOf(_v);\n if(checked && _i === -1) ${o}.push(_v);\n else if(!checked && _i > -1) ${o}.splice(_i,1);\n } else {\n ${o} = checked;\n }`,"model")}if("radio"===r){const t=e.attrs.find(e=>"value"===e.key),n=(null==t?void 0:t.value)??"null";return a(":checked",`${o} == ${JSON.stringify(n)}`),void a("@change",`if (checked) ${o} = ${JSON.stringify(n)}`,"model")}return a(":value",o),void a("@input",`${o} = value`,"model")}if("textarea"===l)return a(":value",o),void a("@input",`${o} = value`,"model");if("select"===l)return void(e.attrs.some(e=>"multiple"===e.key)?(a("updated",`\n const values = Array.isArray(${o}) ? ${o} : ${o} != null ? [${o}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),a("@change",`${o} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(a(":value",o),a("@change",`${o} = value`,"model")));const u=s[l],d=(null==u?void 0:u.prop)??"value",f=(null==u?void 0:u.event)??"change";a(`:${d}`,o),a(`@${f}`,`${o} = ${"checked"===d?"checked":"value"===d?"value":`event.target.${d}`}`,"model")}function p(e,t,n,o=null){if(!e.attrs||0===e.attrs.length)return[];const c=[];for(const l of e.attrs){if(o&&o.has(l.key))continue;const{key:i,value:s,role:r}=l,{isDynamic:a,type:f}=u(i);if(a&&f){const o={k:i,f:n.compile(f,s??"",t),d:1,r:r};d(o,s,l.loc??e.loc),c.push(o)}else c.push({k:i,v:s,d:0,r:r})}return c}function h(e){let t=0===e.d;if(e.c&&e.c.length>0)for(const n of e.c)h(n)||(t=!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)h(e)||(t=!1);return!t||e.t!==c.ASTType.Element&&e.t!==c.ASTType.Text||(e.s=1),t}function y(e,t,n){var l,s,r,a,h,y;const m={t:e.type,d:0};let g=!1;var T;switch(e.type===c.ASTType.Text?(T=e.content)&&i.test(T)&&(g=!0):((null==(l=e.attrs)?void 0:l.some(e=>"s-model"===e.key||u(e.key).isDynamic))&&(g=!0),e.type===c.ASTType.For&&(g=!0)),m.d=g?1:0,e.type){case c.ASTType.Text:{const o=e.content??"";g?(m.f=n.compile("template",o,t),d(m,o,e.loc)):m.x=o;break}case c.ASTType.Element:m.g=e.tag,f(e),m.a=p(e,t,n),e.children&&(m.c=v(e.children,t,n));break;case c.ASTType.For:{const o=null==(s=e.attrs)?void 0:s.find(e=>"each"===e.key),c=(null==o?void 0:o.value)??"";m.f=n.compile("expression",c,t),m.i=(null==(a=null==(r=e.attrs)?void 0:r.find(e=>"item"===e.key))?void 0:a.value)??"item",m.n=(null==(y=null==(h=e.attrs)?void 0:h.find(e=>"index"===e.key))?void 0:y.value)??"index",d(m,c,(null==o?void 0:o.loc)??e.loc);const l=new Set(["each","item","index"]);m.a=p(e,t,n,l);const i=[...t,{i:m.i,x:m.n}];e.children&&(m.c=v(e.children,i,n));break}case c.ASTType.If:case c.ASTType.ElseIf:case c.ASTType.Else:o.IS_DEV&&console.warn(`[Solely] Orphaned conditional node found: ${c.ASTType[e.type]}`),m.a=p(e,t,n),e.children&&(m.c=v(e.children,t,n));break;case c.ASTType.Comment:m.x=e.content??""}return m}function v(e,t,n){var o;const l=[];let i=0;for(;i<e.length;){const s=e[i];if(s.type===c.ASTType.If){const r=[];let a=i;for(;a<e.length;){const l=e[a],i=l.type;if(i!==c.ASTType.If&&i!==c.ASTType.ElseIf&&i!==c.ASTType.Else)break;if(i===c.ASTType.If&&r.length>0)break;let s,u=null,d="";if(i!==c.ASTType.Else){const e=null==(o=l.attrs)?void 0:o.find(e=>"test"===e.key||"condition"===e.key);d=(null==e?void 0:e.value)??"false",u=n.compile("expression",d,t),s=(null==e?void 0:e.loc)??l.loc}const f=l.children?v(l.children,t,n):[],h=p(l,t,n,new Set(["test","condition"]));if(r.push({f:u,c:f,a:h.length>0?h:void 0,__m:{expr:d,loc:s}}),a++,i===c.ASTType.Else)break}l.push({t:c.ASTType.Conditional,d:1,b:r,__m:{loc:s.loc}}),i=a}else l.push(y(s,t,n)),i++}return l}exports.buildIR=function(e,t={}){const{filename:n="anonymous",source:c}=t,l=r.get(n);l.clear();const i=performance.now(),s=v(e,[],l);for(const o of s)h(o);const a=performance.now(),u=l.getStats(),d=s.filter(e=>1===e.d).length,f=s.filter(e=>1===e.s).length,p={t:"root",v:"1.2.0",fns:l.getFunctions(),n:s,s:{tf:u.total,cf:u.cached,dn:d,tn:s.length,sn:f},m:{t:(new Date).toISOString(),as:e.length,fn:n,...c&&{src:c}}};return o.IS_DEV&&console.info(`[Solely] Compiled <${n}> in ${(a-i).toFixed(2)}ms | Nodes: ${s.length} | Fns: ${u.total} | StaticSubtrees: ${f}`),p},exports.clearIRCache=function(e){r.clear(e)},exports.transformModel=f;
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,n,o)=>((t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o)(t,"symbol"!=typeof n?n+"":n,o);import{genFunction as n}from"../../shared/gen-function.js";import{IS_DEV as o}from"../../shared/env.js";import{ASTType as c}from"../../types/ast.js";import{isLifecycleKind as l}from"../../types/lifecycle.js";const i=/\{\{[\s\S]*?\}\}/,s={"solely-checkbox":{prop:"checked",event:"change"},"solely-switch":{prop:"checked",event:"change"},"solely-radio":{prop:"checked",event:"change"}},r=new class{constructor(){t(this,"compilers",new Map)}get(e="anonymous"){let t=this.compilers.get(e);return t||(t=new a,this.compilers.set(e,t)),t}clear(e){var t;if(e)null==(t=this.compilers.get(e))||t.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class a{constructor(){t(this,"cache",new Map),t(this,"functions",[])}makeCacheKey(e,t,n){return 0===n.length?`${e}:${t}`:`${e}:${t}:${n.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,t,c){const l=null==t?void 0:t.trim();if(!l)return 0;const i=this.makeCacheKey(e,l,c),s=this.cache.get(i);if(void 0!==s)return s;let r;try{r=n(l,e,c)}catch(u){o&&console.error(`[Solely] IR Compile Error - Type: ${e}, Expr: "${l}"`,u),r=()=>""}const a=this.functions.push(r);return this.cache.set(i,a),a}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function u(e){const t=e[0];return":"===t?{isDynamic:!0,type:"expression"}:"@"===t?{isDynamic:!0,type:"handler"}:l(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function f(e,t,n){e.__m={expr:t??"",loc:n??void 0}}function d(e){if(!e.attrs)return;const t=e.attrs.find(e=>"s-model"===e.key);if(!t)return;const n="$data."+t.value.replace("this.","").replace("$data.",""),o=t.loc,c=(e.tag||"").toLowerCase(),l=e.attrs.find(e=>"type"===e.key),i=(null==l?void 0:l.value)??"text";e.attrs=e.attrs.filter(e=>e!==t);const r=(t,n,c)=>{var l;null==(l=e.attrs)||l.push({key:t,value:n,role:c,loc:o})};if("input"===c){if("checkbox"===i){const t=e.attrs.find(e=>"value"===e.key),o=t?JSON.stringify(t.value):'"on"';return r(":checked",`Array.isArray(${n}) ? ${n}.includes(${o}) : ${n}`),void r("@change",`\n const _v = ${o};\n if(Array.isArray(${n})) {\n const _i = ${n}.indexOf(_v);\n if(checked && _i === -1) ${n}.push(_v);\n else if(!checked && _i > -1) ${n}.splice(_i,1);\n } else {\n ${n} = checked;\n }`,"model")}if("radio"===i){const t=e.attrs.find(e=>"value"===e.key),o=(null==t?void 0:t.value)??"null";return r(":checked",`${n} == ${JSON.stringify(o)}`),void r("@change",`if (checked) ${n} = ${JSON.stringify(o)}`,"model")}return r(":value",n),void r("@input",`${n} = value`,"model")}if("textarea"===c)return r(":value",n),void r("@input",`${n} = value`,"model");if("select"===c)return void(e.attrs.some(e=>"multiple"===e.key)?(r("updated",`\n const values = Array.isArray(${n}) ? ${n} : ${n} != null ? [${n}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),r("@change",`${n} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(r(":value",n),r("@change",`${n} = value`,"model")));const a=s[c],u=(null==a?void 0:a.prop)??"value",f=(null==a?void 0:a.event)??"change";r(`:${u}`,n),r(`@${f}`,`${n} = ${"checked"===u?"checked":"value"===u?"value":`event.target.${u}`}`,"model")}function h(e,t,n,o=null){if(!e.attrs||0===e.attrs.length)return[];const c=[];for(const l of e.attrs){if(o&&o.has(l.key))continue;const{key:i,value:s,role:r}=l,{isDynamic:a,type:d}=u(i);if(a&&d){const o={k:i,f:n.compile(d,s??"",t),d:1,r:r};f(o,s,l.loc??e.loc),c.push(o)}else c.push({k:i,v:s,d:0,r:r})}return c}function p(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const t of e.c)if(!p(t))return!1;if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)if(!p(e))return!1;return!0}function v(e){if(e.c&&e.c.length>0)for(const t of e.c)v(t);if(e.b&&e.b.length>0)for(const t of e.b)if(t.c&&t.c.length>0)for(const e of t.c)v(e);e.t!==c.Element&&e.t!==c.Text||0===e.d&&p(e)&&(e.s=1)}function m(e,t,n){var l,s,r,a,p,v;const m={t:e.type,d:0};let g=!1;var $;switch(e.type===c.Text?($=e.content)&&i.test($)&&(g=!0):((null==(l=e.attrs)?void 0:l.some(e=>"s-model"===e.key||u(e.key).isDynamic))&&(g=!0),e.type===c.For&&(g=!0)),m.d=g?1:0,e.type){case c.Text:{const o=e.content??"";g?(m.f=n.compile("template",o,t),f(m,o,e.loc)):m.x=o;break}case c.Element:m.g=e.tag,d(e),m.a=h(e,t,n),e.children&&(m.c=y(e.children,t,n));break;case c.For:{const o=null==(s=e.attrs)?void 0:s.find(e=>"each"===e.key),c=(null==o?void 0:o.value)??"";m.f=n.compile("expression",c,t),m.i=(null==(a=null==(r=e.attrs)?void 0:r.find(e=>"item"===e.key))?void 0:a.value)??"item",m.n=(null==(v=null==(p=e.attrs)?void 0:p.find(e=>"index"===e.key))?void 0:v.value)??"index",f(m,c,(null==o?void 0:o.loc)??e.loc);const l=new Set(["each","item","index"]);m.a=h(e,t,n,l);const i=[...t,{i:m.i,x:m.n}];e.children&&(m.c=y(e.children,i,n));break}case c.If:case c.ElseIf:case c.Else:o&&console.warn(`[Solely] Orphaned conditional node found: ${c[e.type]}`),m.a=h(e,t,n),e.children&&(m.c=y(e.children,t,n));break;case c.Comment:m.x=e.content??""}return m}function y(e,t,n){var o;const l=[];let i=0;for(;i<e.length;){const s=e[i];if(s.type===c.If){const r=[];let a=i;for(;a<e.length;){const l=e[a],i=l.type;if(i!==c.If&&i!==c.ElseIf&&i!==c.Else)break;if(i===c.If&&r.length>0)break;let s,u=null,f="";if(i!==c.Else){const e=null==(o=l.attrs)?void 0:o.find(e=>"test"===e.key||"condition"===e.key);f=(null==e?void 0:e.value)??"false",u=n.compile("expression",f,t),s=(null==e?void 0:e.loc)??l.loc}const d=l.children?y(l.children,t,n):[],p=h(l,t,n,new Set(["test","condition"]));if(r.push({f:u,c:d,a:p.length>0?p:void 0,__m:{expr:f,loc:s}}),a++,i===c.Else)break}l.push({t:c.Conditional,d:1,b:r,__m:{loc:s.loc}}),i=a}else l.push(m(s,t,n)),i++}return l}function g(e,t={}){const{filename:n="anonymous",source:c}=t,l=r.get(n);l.clear();const i=performance.now(),s=y(e,[],l);for(const o of s)v(o);const a=performance.now(),u=l.getStats(),f=s.filter(e=>1===e.d).length,d=s.filter(e=>1===e.s).length,h={t:"root",v:"1.2.0",fns:l.getFunctions(),n:s,s:{tf:u.total,cf:u.cached,dn:f,tn:s.length,sn:d},m:{t:(new Date).toISOString(),as:e.length,fn:n,...c&&{src:c}}};return o&&console.info(`[Solely] Compiled <${n}> in ${(a-i).toFixed(2)}ms | Nodes: ${s.length} | Fns: ${u.total} | StaticSubtrees: ${d}`),h}function $(e){r.clear(e)}export{g as buildIR,$ as clearIRCache,d as transformModel};
1
+ var e=Object.defineProperty,t=(t,n,o)=>((t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o)(t,"symbol"!=typeof n?n+"":n,o);import{genFunction as n}from"../../shared/gen-function.js";import{IS_DEV as o}from"../../shared/env.js";import{ASTType as c}from"../../types/ast.js";import{isLifecycleKind as l}from"../../types/lifecycle.js";const i=/\{\{[\s\S]*?\}\}/,s={"solely-checkbox":{prop:"checked",event:"change"},"solely-switch":{prop:"checked",event:"change"},"solely-radio":{prop:"checked",event:"change"}},r=new class{constructor(){t(this,"compilers",new Map)}get(e="anonymous"){let t=this.compilers.get(e);return t||(t=new a,this.compilers.set(e,t)),t}clear(e){var t;if(e)null==(t=this.compilers.get(e))||t.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class a{constructor(){t(this,"cache",new Map),t(this,"functions",[])}makeCacheKey(e,t,n){return 0===n.length?`${e}:${t}`:`${e}:${t}:${n.map(e=>`${e.i}:${e.x}`).join(";")}`}compile(e,t,c){const l=null==t?void 0:t.trim();if(!l)return 0;const i=this.makeCacheKey(e,l,c),s=this.cache.get(i);if(void 0!==s)return s;let r;try{r=n(l,e,c)}catch(u){o&&console.error(`[Solely] IR Compile Error - Type: ${e}, Expr: "${l}"`,u),r=()=>""}const a=this.functions.push(r);return this.cache.set(i,a),a}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function u(e){const t=e[0];return":"===t?{isDynamic:!0,type:"expression"}:"@"===t?{isDynamic:!0,type:"handler"}:l(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function f(e,t,n){e.__m={expr:t??"",loc:n??void 0}}function d(e){if(!e.attrs)return;const t=e.attrs.find(e=>"s-model"===e.key);if(!t)return;const n=t.value.trim(),o=n.startsWith("$data.")?n:`$data.${n.replace(/^this\./,"")}`,c=t.loc,l=(e.tag||"").toLowerCase(),i=e.attrs.find(e=>"type"===e.key),r=(null==i?void 0:i.value)??"text";e.attrs=e.attrs.filter(e=>e!==t);const a=(t,n,o)=>{var l;null==(l=e.attrs)||l.push({key:t,value:n,role:o,loc:c})};if("input"===l){if("checkbox"===r){const t=e.attrs.find(e=>"value"===e.key),n=t?JSON.stringify(t.value):'"on"';return a(":checked",`Array.isArray(${o}) ? ${o}.includes(${n}) : ${o}`),void a("@change",`\n const _v = ${n};\n if(Array.isArray(${o})) {\n const _i = ${o}.indexOf(_v);\n if(checked && _i === -1) ${o}.push(_v);\n else if(!checked && _i > -1) ${o}.splice(_i,1);\n } else {\n ${o} = checked;\n }`,"model")}if("radio"===r){const t=e.attrs.find(e=>"value"===e.key),n=(null==t?void 0:t.value)??"null";return a(":checked",`${o} == ${JSON.stringify(n)}`),void a("@change",`if (checked) ${o} = ${JSON.stringify(n)}`,"model")}return a(":value",o),void a("@input",`${o} = value`,"model")}if("textarea"===l)return a(":value",o),void a("@input",`${o} = value`,"model");if("select"===l)return void(e.attrs.some(e=>"multiple"===e.key)?(a("updated",`\n const values = Array.isArray(${o}) ? ${o} : ${o} != null ? [${o}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),a("@change",`${o} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(a(":value",o),a("@change",`${o} = value`,"model")));const u=s[l],f=(null==u?void 0:u.prop)??"value",d=(null==u?void 0:u.event)??"change";a(`:${f}`,o),a(`@${d}`,`${o} = ${"checked"===f?"checked":"value"===f?"value":`event.target.${f}`}`,"model")}function h(e,t,n,o=null){if(!e.attrs||0===e.attrs.length)return[];const c=[];for(const l of e.attrs){if(o&&o.has(l.key))continue;const{key:i,value:s,role:r}=l,{isDynamic:a,type:d}=u(i);if(a&&d){const o={k:i,f:n.compile(d,s??"",t),d:1,r:r};f(o,s,l.loc??e.loc),c.push(o)}else c.push({k:i,v:s,d:0,r:r})}return c}function p(e){let t=0===e.d;if(e.c&&e.c.length>0)for(const n of e.c)p(n)||(t=!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)p(e)||(t=!1);return!t||e.t!==c.Element&&e.t!==c.Text||(e.s=1),t}function v(e,t,n){var l,s,r,a,p,v;const y={t:e.type,d:0};let $=!1;var g;switch(e.type===c.Text?(g=e.content)&&i.test(g)&&($=!0):((null==(l=e.attrs)?void 0:l.some(e=>"s-model"===e.key||u(e.key).isDynamic))&&($=!0),e.type===c.For&&($=!0)),y.d=$?1:0,e.type){case c.Text:{const o=e.content??"";$?(y.f=n.compile("template",o,t),f(y,o,e.loc)):y.x=o;break}case c.Element:y.g=e.tag,d(e),y.a=h(e,t,n),e.children&&(y.c=m(e.children,t,n));break;case c.For:{const o=null==(s=e.attrs)?void 0:s.find(e=>"each"===e.key),c=(null==o?void 0:o.value)??"";y.f=n.compile("expression",c,t),y.i=(null==(a=null==(r=e.attrs)?void 0:r.find(e=>"item"===e.key))?void 0:a.value)??"item",y.n=(null==(v=null==(p=e.attrs)?void 0:p.find(e=>"index"===e.key))?void 0:v.value)??"index",f(y,c,(null==o?void 0:o.loc)??e.loc);const l=new Set(["each","item","index"]);y.a=h(e,t,n,l);const i=[...t,{i:y.i,x:y.n}];e.children&&(y.c=m(e.children,i,n));break}case c.If:case c.ElseIf:case c.Else:o&&console.warn(`[Solely] Orphaned conditional node found: ${c[e.type]}`),y.a=h(e,t,n),e.children&&(y.c=m(e.children,t,n));break;case c.Comment:y.x=e.content??""}return y}function m(e,t,n){var o;const l=[];let i=0;for(;i<e.length;){const s=e[i];if(s.type===c.If){const r=[];let a=i;for(;a<e.length;){const l=e[a],i=l.type;if(i!==c.If&&i!==c.ElseIf&&i!==c.Else)break;if(i===c.If&&r.length>0)break;let s,u=null,f="";if(i!==c.Else){const e=null==(o=l.attrs)?void 0:o.find(e=>"test"===e.key||"condition"===e.key);f=(null==e?void 0:e.value)??"false",u=n.compile("expression",f,t),s=(null==e?void 0:e.loc)??l.loc}const d=l.children?m(l.children,t,n):[],p=h(l,t,n,new Set(["test","condition"]));if(r.push({f:u,c:d,a:p.length>0?p:void 0,__m:{expr:f,loc:s}}),a++,i===c.Else)break}l.push({t:c.Conditional,d:1,b:r,__m:{loc:s.loc}}),i=a}else l.push(v(s,t,n)),i++}return l}function y(e,t={}){const{filename:n="anonymous",source:c}=t,l=r.get(n);l.clear();const i=performance.now(),s=m(e,[],l);for(const o of s)p(o);const a=performance.now(),u=l.getStats(),f=s.filter(e=>1===e.d).length,d=s.filter(e=>1===e.s).length,h={t:"root",v:"1.2.0",fns:l.getFunctions(),n:s,s:{tf:u.total,cf:u.cached,dn:f,tn:s.length,sn:d},m:{t:(new Date).toISOString(),as:e.length,fn:n,...c&&{src:c}}};return o&&console.info(`[Solely] Compiled <${n}> in ${(a-i).toFixed(2)}ms | Nodes: ${s.length} | Fns: ${u.total} | StaticSubtrees: ${d}`),h}function $(e){r.clear(e)}export{y as buildIR,$ as clearIRCache,d as transformModel};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../shared/event-listeners.cjs"),e=require("../../types/ast.cjs"),n=require("../../types/lifecycle.cjs"),s=/<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/,o=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),r=/\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;function i(o,i){var c;const l=(null==(c=(o.match(s)||[])[1])?void 0:c.toLowerCase())??"",a=function(e,s){const o=[];let i;const c=e.replace(/^\s*[^\s"'/>]+/,""),l=e.length-c.length;for(;null!==(i=r.exec(c));){const r=i[1];if(!r)continue;const c=i[2]??i[3]??i[4]??"";let a=r;t.default.has(r)&&(a=a.replace(/^on/,"@")),"s-model"!==a&&(a=a.replace(/^on-/,"@").replace(/^s-/,":")),a=n.mapAttrKeyToLifecycleKind(a)||a;const h=i[0],p=h.indexOf("=");let u;if(-1===p)u=h.indexOf(r)+r.length;else{let t=p+1;for(;t<h.length&&/\s/.test(h[t]);)t++;if('"'===h[t]||"'"===h[t]){let e=t+1;for(;e<h.length&&/\s/.test(h[e]);)e++;u=e}else{let e=t;for(;e<h.length&&/\s/.test(h[e]);)e++;u=e}}const f=i.index+u+l,g=e.slice(0,f).split("\n"),T=s[0]+g.length-1,y=g.length>1?g[g.length-1].length+1:s[1]+f;o.push({key:a,value:c,loc:[T,y]})}return o}(o,i);return{type:{for:e.ASTType.For,if:e.ASTType.If,elseif:e.ASTType.ElseIf,else:e.ASTType.Else}[l]??e.ASTType.Element,tag:l,loc:i,children:[],attrs:a}}function c(t,e){const n=t.length;if(t.startsWith("!--",e)){const n=t.indexOf("--\x3e",e+3);return-1===n?-1:n+2}if(t.startsWith("![CDATA[",e)){const n=t.indexOf("]]>",e+8);return-1===n?-1:n+2}if("!"===t[e])return t.indexOf(">",e+1);if("?"===t[e]){const n=t.indexOf("?>",e+1);return-1===n?-1:n+1}let s=!1,o=!1,r=e;for(;r<n;){const e=t[r];if("'"!==e||o)if('"'!==e||s){if(">"===e&&!s&&!o)return r}else o=!o;else s=!s;r++}return-1}exports.parseHtml=function(t){const n=[];if(!t)return[];const s=[],r=[],l=()=>{var t;return 0===s.length?n:(t=s[s.length-1]).children||(t.children=[])};let a=0;const h=t.length,p=[0];for(let e=0;e<h;e++)"\n"===t[e]&&p.push(e+1);function u(t){let e=0;for(let n=1;n<p.length&&!(p[n]>t);n++)e=n;return[e+1,t-p[e]+1]}for(;a<h;){const n=t.indexOf("<",a);if(-1===n||n>a){const o=t.substring(a,-1===n?void 0:n),r=s.length>0?s[s.length-1]:null;let i,c;if(!r||"pre"!==r.tag&&"code"!==r.tag&&"textarea"!==r.tag&&"script"!==r.tag&&"style"!==r.tag){if(i=o.trim(),""===i){if(a=n,-1===n)break;continue}c=a+(o.length-o.trimStart().length)}else i=o,c=a;const h=l(),p=h[h.length-1];if(p&&p.type===e.ASTType.Text)p.content+=i;else{const t=u(c);h.push({type:e.ASTType.Text,tag:"text",content:i,loc:t,children:[]})}if(-1===n)break;a=n}const p=c(t,a+1);if(-1===p){const n=t.substring(a);n.trim()&&l().push({type:e.ASTType.Text,tag:"text",content:n.trim(),children:[],loc:u(a)});break}const f=t.substring(a,p+1),g=l(),T=u(a);if(f.startsWith("\x3c!--")){g.push({type:e.ASTType.Comment,tag:"comment",content:f.slice(4,-3),loc:T,children:[]}),a=p+1;continue}if(f.startsWith("<![CDATA[")){g.push({type:e.ASTType.Text,tag:"text",content:f.slice(9,-3),loc:T,children:[]}),a=p+1;continue}if(f.startsWith("<!")&&!f.startsWith("\x3c!--")){g.push({type:e.ASTType.Comment,tag:"comment",content:f.slice(2,-1),loc:T,children:[]}),a=p+1;continue}if(f.startsWith("<?")){g.push({type:e.ASTType.Comment,tag:"comment",content:f.slice(2,-2),loc:T,children:[]}),a=p+1;continue}if(f.startsWith("</")){const t=r.pop();for(;s.length>0;){if((s[s.length-1].tag||"").toLowerCase()===(null==t?void 0:t.toLowerCase())){s.pop();break}s.pop()}a=p+1;continue}const y=i(f,T);g.push(y);const d=y.tag||"",m=d.toLowerCase().startsWith("script"),x=d.toLowerCase().startsWith("style"),A=f.endsWith("/>")||o.has(d.toLowerCase());if((m||x)&&!A){const n=`</${d}>`,s=t.toLowerCase().indexOf(n,p+1);if(-1!==s){const o=t.substring(p+1,s);o.length&&y.children.push({type:e.ASTType.Text,tag:"text",content:o,loc:u(p+1),children:[]}),a=s+n.length;continue}{const n=t.substring(p+1);n.length&&y.children.push({type:e.ASTType.Text,tag:"text",content:n,loc:u(p+1),children:[]}),a=h;continue}}A||y.type===e.ASTType.Text||y.type===e.ASTType.Comment||(s.push(y),r.push(d)),a=p+1}return n};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../shared/event-listeners.cjs"),e=require("../../types/ast.cjs"),n=require("../../types/lifecycle.cjs"),s=/<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/,r=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=/\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;function i(r,i){var c;const l=(null==(c=(r.match(s)||[])[1])?void 0:c.toLowerCase())??"",a=function(e,s){o.lastIndex=0;const r=[];let i;const c=e.replace(/^\s*[^\s"'/>]+/,""),l=e.length-c.length;for(;null!==(i=o.exec(c));){const o=i[1];if(!o)continue;const c=i[2]??i[3]??i[4]??"";let a=o;t.default.has(o)&&(a=a.replace(/^on/,"@")),"s-model"!==a&&(a=a.replace(/^on-/,"@").replace(/^s-/,":")),a=n.mapAttrKeyToLifecycleKind(a)||a;const h=i[0],f=h.indexOf("=");let u;if(-1===f)u=h.indexOf(o)+o.length;else{let t=f+1;for(;t<h.length&&/\s/.test(h[t]);)t++;if('"'===h[t]||"'"===h[t]){let e=t+1;for(;e<h.length&&/\s/.test(h[e]);)e++;u=e}else{let e=t;for(;e<h.length&&/\s/.test(h[e]);)e++;u=e}}const p=i.index+u+l,g=e.slice(0,p).split("\n"),T=s[0]+g.length-1,y=g.length>1?g[g.length-1].length+1:s[1]+p;r.push({key:a,value:c,loc:[T,y]})}return r}(r,i);return{type:{for:e.ASTType.For,if:e.ASTType.If,elseif:e.ASTType.ElseIf,else:e.ASTType.Else}[l]??e.ASTType.Element,tag:l,loc:i,children:[],attrs:a}}function c(t,e){const n=t.length;if(t.startsWith("!--",e)){const n=t.indexOf("--\x3e",e+3);return-1===n?-1:n+2}if(t.startsWith("![CDATA[",e)){const n=t.indexOf("]]>",e+8);return-1===n?-1:n+2}if("!"===t[e])return t.indexOf(">",e+1);if("?"===t[e]){const n=t.indexOf("?>",e+1);return-1===n?-1:n+1}let s=!1,r=!1,o=e;for(;o<n;){const e=t[o];if("'"!==e||r)if('"'!==e||s){if(">"===e&&!s&&!r)return o}else r=!r;else s=!s;o++}return-1}exports.parseHtml=function(t){var n,o;const l=[];if(!t)return[];const a=[],h=()=>{var t;return 0===a.length?l:(t=a[a.length-1]).children||(t.children=[])};let f=0;const u=t.length,p=[0];let g=0;for(;-1!==(g=t.indexOf("\n",g));)p.push(++g);function T(t){let e=0,n=p.length-1;for(;e<=n;){const s=e+n>>>1;p[s]<=t?e=s+1:n=s-1}return[n+1,t-p[n]+1]}for(;f<u;){const l=t.indexOf("<",f);if(-1===l||l>f){const n=t.substring(f,-1===l?void 0:l),s=a.length>0?a[a.length-1]:null;let r,o;if(!s||"pre"!==s.tag&&"code"!==s.tag&&"textarea"!==s.tag&&"script"!==s.tag&&"style"!==s.tag){if(r=n.trim(),""===r){if(f=l,-1===l)break;continue}o=f+(n.length-n.trimStart().length)}else r=n,o=f;const i=h(),c=i[i.length-1];if(c&&c.type===e.ASTType.Text)c.content+=r;else{const t=T(o);i.push({type:e.ASTType.Text,tag:"text",content:r,loc:t,children:[]})}if(-1===l)break;f=l}const p=c(t,f+1);if(-1===p){const n=t.substring(f);n.trim()&&h().push({type:e.ASTType.Text,tag:"text",content:n.trim(),children:[],loc:T(f)});break}const g=t.substring(f,p+1),y=h(),d=T(f);if(g.startsWith("\x3c!--")){y.push({type:e.ASTType.Comment,tag:"comment",content:g.slice(4,-3),loc:d,children:[]}),f=p+1;continue}if(g.startsWith("<![CDATA[")){y.push({type:e.ASTType.Text,tag:"text",content:g.slice(9,-3),loc:d,children:[]}),f=p+1;continue}if(g.startsWith("<!")&&!g.startsWith("\x3c!--")){y.push({type:e.ASTType.Comment,tag:"comment",content:g.slice(2,-1),loc:d,children:[]}),f=p+1;continue}if(g.startsWith("<?")){y.push({type:e.ASTType.Comment,tag:"comment",content:g.slice(2,-2),loc:d,children:[]}),f=p+1;continue}if(g.startsWith("</")){const t=null==(n=(g.match(s)||[])[1])?void 0:n.toLowerCase();if(t){let e=-1;for(let n=a.length-1;n>=0;n--)if((null==(o=a[n].tag)?void 0:o.toLowerCase())===t){e=n;break}-1!==e&&(a.length=e)}f=p+1;continue}const x=i(g,d);y.push(x);const m=x.tag||"",A=m.toLowerCase().startsWith("script"),S=m.toLowerCase().startsWith("style"),b=g.endsWith("/>")||r.has(m.toLowerCase());if((A||S)&&!b){const n=`</${m}>`,s=t.toLowerCase().indexOf(n,p+1);if(-1!==s){const r=t.substring(p+1,s);r.length&&x.children.push({type:e.ASTType.Text,tag:"text",content:r,loc:T(p+1),children:[]}),f=s+n.length;continue}{const n=t.substring(p+1);n.length&&x.children.push({type:e.ASTType.Text,tag:"text",content:n,loc:T(p+1),children:[]}),f=u;continue}}b||x.type===e.ASTType.Text||x.type===e.ASTType.Comment||a.push(x),f=p+1}return l};
@@ -1 +1 @@
1
- import t from"../../shared/event-listeners.js";import{ASTType as e}from"../../types/ast.js";import{mapAttrKeyToLifecycleKind as n}from"../../types/lifecycle.js";const s=/<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/,o=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),r=/\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;function i(o,i){var c;const l=(null==(c=(o.match(s)||[])[1])?void 0:c.toLowerCase())??"",h=function(e,s){const o=[];let i;const c=e.replace(/^\s*[^\s"'/>]+/,""),l=e.length-c.length;for(;null!==(i=r.exec(c));){const r=i[1];if(!r)continue;const c=i[2]??i[3]??i[4]??"";let h=r;t.has(r)&&(h=h.replace(/^on/,"@")),"s-model"!==h&&(h=h.replace(/^on-/,"@").replace(/^s-/,":")),h=n(h)||h;const a=i[0],f=a.indexOf("=");let u;if(-1===f)u=a.indexOf(r)+r.length;else{let t=f+1;for(;t<a.length&&/\s/.test(a[t]);)t++;if('"'===a[t]||"'"===a[t]){let e=t+1;for(;e<a.length&&/\s/.test(a[e]);)e++;u=e}else{let e=t;for(;e<a.length&&/\s/.test(a[e]);)e++;u=e}}const g=i.index+u+l,p=e.slice(0,g).split("\n"),m=s[0]+p.length-1,d=p.length>1?p[p.length-1].length+1:s[1]+g;o.push({key:h,value:c,loc:[m,d]})}return o}(o,i);return{type:{for:e.For,if:e.If,elseif:e.ElseIf,else:e.Else}[l]??e.Element,tag:l,loc:i,children:[],attrs:h}}function c(t,e){const n=t.length;if(t.startsWith("!--",e)){const n=t.indexOf("--\x3e",e+3);return-1===n?-1:n+2}if(t.startsWith("![CDATA[",e)){const n=t.indexOf("]]>",e+8);return-1===n?-1:n+2}if("!"===t[e])return t.indexOf(">",e+1);if("?"===t[e]){const n=t.indexOf("?>",e+1);return-1===n?-1:n+1}let s=!1,o=!1,r=e;for(;r<n;){const e=t[r];if("'"!==e||o)if('"'!==e||s){if(">"===e&&!s&&!o)return r}else o=!o;else s=!s;r++}return-1}function l(t){const n=[];if(!t)return[];const s=[],r=[],l=()=>{var t;return 0===s.length?n:(t=s[s.length-1]).children||(t.children=[])};let h=0;const a=t.length,f=[0];for(let e=0;e<a;e++)"\n"===t[e]&&f.push(e+1);function u(t){let e=0;for(let n=1;n<f.length&&!(f[n]>t);n++)e=n;return[e+1,t-f[e]+1]}for(;h<a;){const n=t.indexOf("<",h);if(-1===n||n>h){const o=t.substring(h,-1===n?void 0:n),r=s.length>0?s[s.length-1]:null;let i,c;if(!r||"pre"!==r.tag&&"code"!==r.tag&&"textarea"!==r.tag&&"script"!==r.tag&&"style"!==r.tag){if(i=o.trim(),""===i){if(h=n,-1===n)break;continue}c=h+(o.length-o.trimStart().length)}else i=o,c=h;const a=l(),f=a[a.length-1];if(f&&f.type===e.Text)f.content+=i;else{const t=u(c);a.push({type:e.Text,tag:"text",content:i,loc:t,children:[]})}if(-1===n)break;h=n}const f=c(t,h+1);if(-1===f){const n=t.substring(h);n.trim()&&l().push({type:e.Text,tag:"text",content:n.trim(),children:[],loc:u(h)});break}const g=t.substring(h,f+1),p=l(),m=u(h);if(g.startsWith("\x3c!--")){p.push({type:e.Comment,tag:"comment",content:g.slice(4,-3),loc:m,children:[]}),h=f+1;continue}if(g.startsWith("<![CDATA[")){p.push({type:e.Text,tag:"text",content:g.slice(9,-3),loc:m,children:[]}),h=f+1;continue}if(g.startsWith("<!")&&!g.startsWith("\x3c!--")){p.push({type:e.Comment,tag:"comment",content:g.slice(2,-1),loc:m,children:[]}),h=f+1;continue}if(g.startsWith("<?")){p.push({type:e.Comment,tag:"comment",content:g.slice(2,-2),loc:m,children:[]}),h=f+1;continue}if(g.startsWith("</")){const t=r.pop();for(;s.length>0;){if((s[s.length-1].tag||"").toLowerCase()===(null==t?void 0:t.toLowerCase())){s.pop();break}s.pop()}h=f+1;continue}const d=i(g,m);p.push(d);const x=d.tag||"",y=x.toLowerCase().startsWith("script"),b=x.toLowerCase().startsWith("style"),C=g.endsWith("/>")||o.has(x.toLowerCase());if((y||b)&&!C){const n=`</${x}>`,s=t.toLowerCase().indexOf(n,f+1);if(-1!==s){const o=t.substring(f+1,s);o.length&&d.children.push({type:e.Text,tag:"text",content:o,loc:u(f+1),children:[]}),h=s+n.length;continue}{const n=t.substring(f+1);n.length&&d.children.push({type:e.Text,tag:"text",content:n,loc:u(f+1),children:[]}),h=a;continue}}C||d.type===e.Text||d.type===e.Comment||(s.push(d),r.push(x)),h=f+1}return n}export{l as parseHtml};
1
+ import t from"../../shared/event-listeners.js";import{ASTType as e}from"../../types/ast.js";import{mapAttrKeyToLifecycleKind as n}from"../../types/lifecycle.js";const s=/<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/,o=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),r=/\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;function i(o,i){var l;const c=(null==(l=(o.match(s)||[])[1])?void 0:l.toLowerCase())??"",h=function(e,s){r.lastIndex=0;const o=[];let i;const l=e.replace(/^\s*[^\s"'/>]+/,""),c=e.length-l.length;for(;null!==(i=r.exec(l));){const r=i[1];if(!r)continue;const l=i[2]??i[3]??i[4]??"";let h=r;t.has(r)&&(h=h.replace(/^on/,"@")),"s-model"!==h&&(h=h.replace(/^on-/,"@").replace(/^s-/,":")),h=n(h)||h;const a=i[0],f=a.indexOf("=");let u;if(-1===f)u=a.indexOf(r)+r.length;else{let t=f+1;for(;t<a.length&&/\s/.test(a[t]);)t++;if('"'===a[t]||"'"===a[t]){let e=t+1;for(;e<a.length&&/\s/.test(a[e]);)e++;u=e}else{let e=t;for(;e<a.length&&/\s/.test(a[e]);)e++;u=e}}const g=i.index+u+c,p=e.slice(0,g).split("\n"),d=s[0]+p.length-1,m=p.length>1?p[p.length-1].length+1:s[1]+g;o.push({key:h,value:l,loc:[d,m]})}return o}(o,i);return{type:{for:e.For,if:e.If,elseif:e.ElseIf,else:e.Else}[c]??e.Element,tag:c,loc:i,children:[],attrs:h}}function l(t,e){const n=t.length;if(t.startsWith("!--",e)){const n=t.indexOf("--\x3e",e+3);return-1===n?-1:n+2}if(t.startsWith("![CDATA[",e)){const n=t.indexOf("]]>",e+8);return-1===n?-1:n+2}if("!"===t[e])return t.indexOf(">",e+1);if("?"===t[e]){const n=t.indexOf("?>",e+1);return-1===n?-1:n+1}let s=!1,o=!1,r=e;for(;r<n;){const e=t[r];if("'"!==e||o)if('"'!==e||s){if(">"===e&&!s&&!o)return r}else o=!o;else s=!s;r++}return-1}function c(t){var n,r;const c=[];if(!t)return[];const h=[],a=()=>{var t;return 0===h.length?c:(t=h[h.length-1]).children||(t.children=[])};let f=0;const u=t.length,g=[0];let p=0;for(;-1!==(p=t.indexOf("\n",p));)g.push(++p);function d(t){let e=0,n=g.length-1;for(;e<=n;){const s=e+n>>>1;g[s]<=t?e=s+1:n=s-1}return[n+1,t-g[n]+1]}for(;f<u;){const c=t.indexOf("<",f);if(-1===c||c>f){const n=t.substring(f,-1===c?void 0:c),s=h.length>0?h[h.length-1]:null;let o,r;if(!s||"pre"!==s.tag&&"code"!==s.tag&&"textarea"!==s.tag&&"script"!==s.tag&&"style"!==s.tag){if(o=n.trim(),""===o){if(f=c,-1===c)break;continue}r=f+(n.length-n.trimStart().length)}else o=n,r=f;const i=a(),l=i[i.length-1];if(l&&l.type===e.Text)l.content+=o;else{const t=d(r);i.push({type:e.Text,tag:"text",content:o,loc:t,children:[]})}if(-1===c)break;f=c}const g=l(t,f+1);if(-1===g){const n=t.substring(f);n.trim()&&a().push({type:e.Text,tag:"text",content:n.trim(),children:[],loc:d(f)});break}const p=t.substring(f,g+1),m=a(),x=d(f);if(p.startsWith("\x3c!--")){m.push({type:e.Comment,tag:"comment",content:p.slice(4,-3),loc:x,children:[]}),f=g+1;continue}if(p.startsWith("<![CDATA[")){m.push({type:e.Text,tag:"text",content:p.slice(9,-3),loc:x,children:[]}),f=g+1;continue}if(p.startsWith("<!")&&!p.startsWith("\x3c!--")){m.push({type:e.Comment,tag:"comment",content:p.slice(2,-1),loc:x,children:[]}),f=g+1;continue}if(p.startsWith("<?")){m.push({type:e.Comment,tag:"comment",content:p.slice(2,-2),loc:x,children:[]}),f=g+1;continue}if(p.startsWith("</")){const t=null==(n=(p.match(s)||[])[1])?void 0:n.toLowerCase();if(t){let e=-1;for(let n=h.length-1;n>=0;n--)if((null==(r=h[n].tag)?void 0:r.toLowerCase())===t){e=n;break}-1!==e&&(h.length=e)}f=g+1;continue}const y=i(p,x);m.push(y);const b=y.tag||"",C=b.toLowerCase().startsWith("script"),W=b.toLowerCase().startsWith("style"),v=p.endsWith("/>")||o.has(b.toLowerCase());if((C||W)&&!v){const n=`</${b}>`,s=t.toLowerCase().indexOf(n,g+1);if(-1!==s){const o=t.substring(g+1,s);o.length&&y.children.push({type:e.Text,tag:"text",content:o,loc:d(g+1),children:[]}),f=s+n.length;continue}{const n=t.substring(g+1);n.length&&y.children.push({type:e.Text,tag:"text",content:n,loc:d(g+1),children:[]}),f=u;continue}}v||y.type===e.Text||y.type===e.Comment||h.push(y),f=g+1}return c}export{c as parseHtml};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t={t:"root",v:"1.2.0",fns:[function(t){const{$data:a}=this;return this.getStepsClasses()},function(t){const{$data:a}=this;return!a.useSlot},function(t){const{$data:a}=this;return this.getParsedItems()},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return this.getStepClasses(s,i)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return"process"===this.getStepStatus(i)?"step":void 0},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.disabled?"true":"false"},function(t,a){const{$data:s}=this,{value:i,checked:d}=(null==t?void 0:t.target)||{};var[n]=a.map(t=>t.itmVal),[e]=a.map(t=>t.idxVal);this.handleStepClick(n,e)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return this.getIconClasses(s)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.icon?this.getIconStyle(s):""},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return!a.progressDot},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.icon||"finish"===this.getStepStatus(i)||"error"===this.getStepStatus(i)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${this.getStepIcon(s,i)}`},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${i+1}`},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${s.title}`},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.description},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${s.description}`},function(t){const{$data:a}=this;return a.useSlot},function(t){const{$data:a}=this;return a.slotItems},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return this.getSlotStepClasses(s,i)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return"process"===this.getSlotStepStatus(i)?"step":void 0},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.disabled?"true":"false"},function(t,a){const{$data:s}=this,{value:i,checked:d}=(null==t?void 0:t.target)||{};var[n]=a.map(t=>t.itmVal),[e]=a.map(t=>t.idxVal);this.handleSlotStepClick(n,e)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.iconHtml},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${s.title}`},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.description},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${s.description}`}],n:[{t:0,d:1,g:"div",a:[{k:"part",v:"base",d:0},{k:"class",v:"steps",d:0},{k:":class",f:1,d:1},{k:"role",v:"list",d:0},{k:"aria-label",v:"步骤条",d:0}],c:[{t:2,d:0,x:" 使用 items 属性时的渲染 "},{t:7,d:1,b:[{f:2,c:[{t:6,d:1,f:3,i:"item",n:"index",a:[],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"step",d:0},{k:"class",v:"step",d:0},{k:":class",f:4,d:1},{k:"role",v:"listitem",d:0},{k:":aria-current",f:5,d:1},{k:":aria-disabled",f:6,d:1},{k:"@click",f:7,d:1}],c:[{t:0,d:0,s:1,g:"div",a:[{k:"part",v:"tail",d:0},{k:"class",v:"step__tail",d:0}],c:[]},{t:0,d:0,g:"div",a:[{k:"part",v:"wrapper",d:0},{k:"class",v:"step__wrapper",d:0}],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"icon-wrapper",d:0},{k:"class",v:"step__icon-wrapper",d:0},{k:":class",f:8,d:1},{k:":style",f:9,d:1}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon",d:0},{k:"class",v:"step__icon",d:0}],c:[{t:7,d:1,b:[{f:10,c:[{t:7,d:1,b:[{f:11,c:[{t:0,d:0,g:"span",a:[{k:"part",v:"icon-substitution",d:0},{k:"class",v:"step__icon-substitution",d:0}],c:[{t:1,d:1,f:12}]}]},{f:null,c:[{t:0,d:0,g:"span",a:[{k:"part",v:"icon-text",d:0},{k:"class",v:"step__icon-text",d:0}],c:[{t:1,d:1,f:13}]}]}]}]}]}]}]},{t:0,d:0,g:"div",a:[{k:"part",v:"content",d:0},{k:"class",v:"step__content",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"title",d:0},{k:"class",v:"step__title",d:0}],c:[{t:1,d:1,f:14}]},{t:7,d:1,b:[{f:15,c:[{t:0,d:0,g:"div",a:[{k:"part",v:"description",d:0},{k:"class",v:"step__description",d:0}],c:[{t:1,d:1,f:16}]}]}]}]}]}]}]}]}]},{t:2,d:0,x:" 使用插槽时的渲染 "},{t:7,d:1,b:[{f:17,c:[{t:6,d:1,f:18,i:"slotItem",n:"index",a:[],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"step",d:0},{k:"class",v:"step",d:0},{k:":class",f:19,d:1},{k:"role",v:"listitem",d:0},{k:":aria-current",f:20,d:1},{k:":aria-disabled",f:21,d:1},{k:"@click",f:22,d:1}],c:[{t:0,d:0,s:1,g:"div",a:[{k:"part",v:"tail",d:0},{k:"class",v:"step__tail",d:0}],c:[]},{t:0,d:0,g:"div",a:[{k:"part",v:"wrapper",d:0},{k:"class",v:"step__wrapper",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon-wrapper",d:0},{k:"class",v:"step__icon-wrapper",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon",d:0},{k:"class",v:"step__icon",d:0}],c:[{t:7,d:1,b:[{f:10,c:[{t:2,d:0,x:" 使用插槽元素的 innerHTML 作为图标内容 "},{t:0,d:1,g:"span",a:[{k:"part",v:"icon-substitution",d:0},{k:"class",v:"step__icon-substitution",d:0},{k:":innerHTML",f:23,d:1}],c:[]}]}]}]}]},{t:0,d:0,g:"div",a:[{k:"part",v:"content",d:0},{k:"class",v:"step__content",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"title",d:0},{k:"class",v:"step__title",d:0}],c:[{t:1,d:1,f:24}]},{t:7,d:1,b:[{f:25,c:[{t:0,d:0,g:"div",a:[{k:"part",v:"description",d:0},{k:"class",v:"step__description",d:0}],c:[{t:1,d:1,f:26}]}]}]}]}]}]}]}]}]}]}],s:{tf:26,cf:26,dn:1,tn:1,sn:0}};exports.__SOLELY_IR__=t,exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t={t:"root",v:"1.2.0",fns:[function(t){const{$data:a}=this;return this.getStepsClasses()},function(t){const{$data:a}=this;return!a.useSlot},function(t){const{$data:a}=this;return this.getParsedItems()},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return this.getStepClasses(s,i)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return"process"===this.getStepStatus(i)?"step":void 0},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.disabled?"true":"false"},function(t,a){const{$data:s}=this,{value:i,checked:d}=(null==t?void 0:t.target)||{};var[n]=a.map(t=>t.itmVal),[e]=a.map(t=>t.idxVal);this.handleStepClick(n,e)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return this.getIconClasses(s)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.icon?this.getIconStyle(s):""},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return!a.progressDot},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.icon||"finish"===this.getStepStatus(i)||"error"===this.getStepStatus(i)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${this.getStepIcon(s,i)}`},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${i+1}`},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${s.title}`},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.description},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${s.description}`},function(t){const{$data:a}=this;return a.useSlot},function(t){const{$data:a}=this;return a.slotItems},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return this.getSlotStepClasses(s,i)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return"process"===this.getSlotStepStatus(i)?"step":void 0},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.disabled?"true":"false"},function(t,a){const{$data:s}=this,{value:i,checked:d}=(null==t?void 0:t.target)||{};var[n]=a.map(t=>t.itmVal),[e]=a.map(t=>t.idxVal);this.handleSlotStepClick(n,e)},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return!a.progressDot},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.iconHtml},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${s.title}`},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return s.description},function(t){const{$data:a}=this;var[s]=t.map(t=>t.itmVal),[i]=t.map(t=>t.idxVal);return`${s.description}`}],n:[{t:0,d:1,g:"div",a:[{k:"part",v:"base",d:0},{k:"class",v:"steps",d:0},{k:":class",f:1,d:1},{k:"role",v:"list",d:0},{k:"aria-label",v:"步骤条",d:0}],c:[{t:2,d:0,x:" 使用 items 属性时的渲染 "},{t:7,d:1,b:[{f:2,c:[{t:6,d:1,f:3,i:"item",n:"index",a:[],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"step",d:0},{k:"class",v:"step",d:0},{k:":class",f:4,d:1},{k:"role",v:"listitem",d:0},{k:":aria-current",f:5,d:1},{k:":aria-disabled",f:6,d:1},{k:"@click",f:7,d:1}],c:[{t:0,d:0,s:1,g:"div",a:[{k:"part",v:"tail",d:0},{k:"class",v:"step__tail",d:0}],c:[]},{t:0,d:0,g:"div",a:[{k:"part",v:"wrapper",d:0},{k:"class",v:"step__wrapper",d:0}],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"icon-wrapper",d:0},{k:"class",v:"step__icon-wrapper",d:0},{k:":class",f:8,d:1},{k:":style",f:9,d:1}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon",d:0},{k:"class",v:"step__icon",d:0}],c:[{t:7,d:1,b:[{f:10,c:[{t:7,d:1,b:[{f:11,c:[{t:0,d:0,g:"span",a:[{k:"part",v:"icon-substitution",d:0},{k:"class",v:"step__icon-substitution",d:0}],c:[{t:1,d:1,f:12}]}]},{f:null,c:[{t:0,d:0,g:"span",a:[{k:"part",v:"icon-text",d:0},{k:"class",v:"step__icon-text",d:0}],c:[{t:1,d:1,f:13}]}]}]}]}]}]}]},{t:0,d:0,g:"div",a:[{k:"part",v:"content",d:0},{k:"class",v:"step__content",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"title",d:0},{k:"class",v:"step__title",d:0}],c:[{t:1,d:1,f:14}]},{t:7,d:1,b:[{f:15,c:[{t:0,d:0,g:"div",a:[{k:"part",v:"description",d:0},{k:"class",v:"step__description",d:0}],c:[{t:1,d:1,f:16}]}]}]}]}]}]}]}]}]},{t:2,d:0,x:" 使用插槽时的渲染 "},{t:7,d:1,b:[{f:17,c:[{t:6,d:1,f:18,i:"slotItem",n:"index",a:[],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"step",d:0},{k:"class",v:"step",d:0},{k:":class",f:19,d:1},{k:"role",v:"listitem",d:0},{k:":aria-current",f:20,d:1},{k:":aria-disabled",f:21,d:1},{k:"@click",f:22,d:1}],c:[{t:0,d:0,s:1,g:"div",a:[{k:"part",v:"tail",d:0},{k:"class",v:"step__tail",d:0}],c:[]},{t:0,d:0,g:"div",a:[{k:"part",v:"wrapper",d:0},{k:"class",v:"step__wrapper",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon-wrapper",d:0},{k:"class",v:"step__icon-wrapper",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon",d:0},{k:"class",v:"step__icon",d:0}],c:[{t:7,d:1,b:[{f:23,c:[{t:2,d:0,x:" 使用插槽元素的 innerHTML 作为图标内容 "},{t:0,d:1,g:"span",a:[{k:"part",v:"icon-substitution",d:0},{k:"class",v:"step__icon-substitution",d:0},{k:":innerHTML",f:24,d:1}],c:[]}]}]}]}]},{t:0,d:0,g:"div",a:[{k:"part",v:"content",d:0},{k:"class",v:"step__content",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"title",d:0},{k:"class",v:"step__title",d:0}],c:[{t:1,d:1,f:25}]},{t:7,d:1,b:[{f:26,c:[{t:0,d:0,g:"div",a:[{k:"part",v:"description",d:0},{k:"class",v:"step__description",d:0}],c:[{t:1,d:1,f:27}]}]}]}]}]}]}]}]}]}]}],s:{tf:27,cf:27,dn:1,tn:1,sn:0}};exports.__SOLELY_IR__=t,exports.default=t;
@@ -1 +1 @@
1
- const t={t:"root",v:"1.2.0",fns:[function(t){const{$data:a}=this;return this.getStepsClasses()},function(t){const{$data:a}=this;return!a.useSlot},function(t){const{$data:a}=this;return this.getParsedItems()},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return this.getStepClasses(i,s)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return"process"===this.getStepStatus(s)?"step":void 0},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.disabled?"true":"false"},function(t,a){const{$data:i}=this,{value:s,checked:d}=(null==t?void 0:t.target)||{};var[n]=a.map(t=>t.itmVal),[c]=a.map(t=>t.idxVal);this.handleStepClick(n,c)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return this.getIconClasses(i)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.icon?this.getIconStyle(i):""},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return!a.progressDot},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.icon||"finish"===this.getStepStatus(s)||"error"===this.getStepStatus(s)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${this.getStepIcon(i,s)}`},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${s+1}`},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${i.title}`},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.description},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${i.description}`},function(t){const{$data:a}=this;return a.useSlot},function(t){const{$data:a}=this;return a.slotItems},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return this.getSlotStepClasses(i,s)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return"process"===this.getSlotStepStatus(s)?"step":void 0},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.disabled?"true":"false"},function(t,a){const{$data:i}=this,{value:s,checked:d}=(null==t?void 0:t.target)||{};var[n]=a.map(t=>t.itmVal),[c]=a.map(t=>t.idxVal);this.handleSlotStepClick(n,c)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.iconHtml},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${i.title}`},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.description},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${i.description}`}],n:[{t:0,d:1,g:"div",a:[{k:"part",v:"base",d:0},{k:"class",v:"steps",d:0},{k:":class",f:1,d:1},{k:"role",v:"list",d:0},{k:"aria-label",v:"步骤条",d:0}],c:[{t:2,d:0,x:" 使用 items 属性时的渲染 "},{t:7,d:1,b:[{f:2,c:[{t:6,d:1,f:3,i:"item",n:"index",a:[],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"step",d:0},{k:"class",v:"step",d:0},{k:":class",f:4,d:1},{k:"role",v:"listitem",d:0},{k:":aria-current",f:5,d:1},{k:":aria-disabled",f:6,d:1},{k:"@click",f:7,d:1}],c:[{t:0,d:0,s:1,g:"div",a:[{k:"part",v:"tail",d:0},{k:"class",v:"step__tail",d:0}],c:[]},{t:0,d:0,g:"div",a:[{k:"part",v:"wrapper",d:0},{k:"class",v:"step__wrapper",d:0}],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"icon-wrapper",d:0},{k:"class",v:"step__icon-wrapper",d:0},{k:":class",f:8,d:1},{k:":style",f:9,d:1}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon",d:0},{k:"class",v:"step__icon",d:0}],c:[{t:7,d:1,b:[{f:10,c:[{t:7,d:1,b:[{f:11,c:[{t:0,d:0,g:"span",a:[{k:"part",v:"icon-substitution",d:0},{k:"class",v:"step__icon-substitution",d:0}],c:[{t:1,d:1,f:12}]}]},{f:null,c:[{t:0,d:0,g:"span",a:[{k:"part",v:"icon-text",d:0},{k:"class",v:"step__icon-text",d:0}],c:[{t:1,d:1,f:13}]}]}]}]}]}]}]},{t:0,d:0,g:"div",a:[{k:"part",v:"content",d:0},{k:"class",v:"step__content",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"title",d:0},{k:"class",v:"step__title",d:0}],c:[{t:1,d:1,f:14}]},{t:7,d:1,b:[{f:15,c:[{t:0,d:0,g:"div",a:[{k:"part",v:"description",d:0},{k:"class",v:"step__description",d:0}],c:[{t:1,d:1,f:16}]}]}]}]}]}]}]}]}]},{t:2,d:0,x:" 使用插槽时的渲染 "},{t:7,d:1,b:[{f:17,c:[{t:6,d:1,f:18,i:"slotItem",n:"index",a:[],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"step",d:0},{k:"class",v:"step",d:0},{k:":class",f:19,d:1},{k:"role",v:"listitem",d:0},{k:":aria-current",f:20,d:1},{k:":aria-disabled",f:21,d:1},{k:"@click",f:22,d:1}],c:[{t:0,d:0,s:1,g:"div",a:[{k:"part",v:"tail",d:0},{k:"class",v:"step__tail",d:0}],c:[]},{t:0,d:0,g:"div",a:[{k:"part",v:"wrapper",d:0},{k:"class",v:"step__wrapper",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon-wrapper",d:0},{k:"class",v:"step__icon-wrapper",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon",d:0},{k:"class",v:"step__icon",d:0}],c:[{t:7,d:1,b:[{f:10,c:[{t:2,d:0,x:" 使用插槽元素的 innerHTML 作为图标内容 "},{t:0,d:1,g:"span",a:[{k:"part",v:"icon-substitution",d:0},{k:"class",v:"step__icon-substitution",d:0},{k:":innerHTML",f:23,d:1}],c:[]}]}]}]}]},{t:0,d:0,g:"div",a:[{k:"part",v:"content",d:0},{k:"class",v:"step__content",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"title",d:0},{k:"class",v:"step__title",d:0}],c:[{t:1,d:1,f:24}]},{t:7,d:1,b:[{f:25,c:[{t:0,d:0,g:"div",a:[{k:"part",v:"description",d:0},{k:"class",v:"step__description",d:0}],c:[{t:1,d:1,f:26}]}]}]}]}]}]}]}]}]}]}],s:{tf:26,cf:26,dn:1,tn:1,sn:0}};export{t as __SOLELY_IR__,t as default};
1
+ const t={t:"root",v:"1.2.0",fns:[function(t){const{$data:a}=this;return this.getStepsClasses()},function(t){const{$data:a}=this;return!a.useSlot},function(t){const{$data:a}=this;return this.getParsedItems()},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return this.getStepClasses(i,s)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return"process"===this.getStepStatus(s)?"step":void 0},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.disabled?"true":"false"},function(t,a){const{$data:i}=this,{value:s,checked:d}=(null==t?void 0:t.target)||{};var[n]=a.map(t=>t.itmVal),[c]=a.map(t=>t.idxVal);this.handleStepClick(n,c)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return this.getIconClasses(i)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.icon?this.getIconStyle(i):""},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return!a.progressDot},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.icon||"finish"===this.getStepStatus(s)||"error"===this.getStepStatus(s)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${this.getStepIcon(i,s)}`},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${s+1}`},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${i.title}`},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.description},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${i.description}`},function(t){const{$data:a}=this;return a.useSlot},function(t){const{$data:a}=this;return a.slotItems},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return this.getSlotStepClasses(i,s)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return"process"===this.getSlotStepStatus(s)?"step":void 0},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.disabled?"true":"false"},function(t,a){const{$data:i}=this,{value:s,checked:d}=(null==t?void 0:t.target)||{};var[n]=a.map(t=>t.itmVal),[c]=a.map(t=>t.idxVal);this.handleSlotStepClick(n,c)},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return!a.progressDot},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.iconHtml},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${i.title}`},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return i.description},function(t){const{$data:a}=this;var[i]=t.map(t=>t.itmVal),[s]=t.map(t=>t.idxVal);return`${i.description}`}],n:[{t:0,d:1,g:"div",a:[{k:"part",v:"base",d:0},{k:"class",v:"steps",d:0},{k:":class",f:1,d:1},{k:"role",v:"list",d:0},{k:"aria-label",v:"步骤条",d:0}],c:[{t:2,d:0,x:" 使用 items 属性时的渲染 "},{t:7,d:1,b:[{f:2,c:[{t:6,d:1,f:3,i:"item",n:"index",a:[],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"step",d:0},{k:"class",v:"step",d:0},{k:":class",f:4,d:1},{k:"role",v:"listitem",d:0},{k:":aria-current",f:5,d:1},{k:":aria-disabled",f:6,d:1},{k:"@click",f:7,d:1}],c:[{t:0,d:0,s:1,g:"div",a:[{k:"part",v:"tail",d:0},{k:"class",v:"step__tail",d:0}],c:[]},{t:0,d:0,g:"div",a:[{k:"part",v:"wrapper",d:0},{k:"class",v:"step__wrapper",d:0}],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"icon-wrapper",d:0},{k:"class",v:"step__icon-wrapper",d:0},{k:":class",f:8,d:1},{k:":style",f:9,d:1}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon",d:0},{k:"class",v:"step__icon",d:0}],c:[{t:7,d:1,b:[{f:10,c:[{t:7,d:1,b:[{f:11,c:[{t:0,d:0,g:"span",a:[{k:"part",v:"icon-substitution",d:0},{k:"class",v:"step__icon-substitution",d:0}],c:[{t:1,d:1,f:12}]}]},{f:null,c:[{t:0,d:0,g:"span",a:[{k:"part",v:"icon-text",d:0},{k:"class",v:"step__icon-text",d:0}],c:[{t:1,d:1,f:13}]}]}]}]}]}]}]},{t:0,d:0,g:"div",a:[{k:"part",v:"content",d:0},{k:"class",v:"step__content",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"title",d:0},{k:"class",v:"step__title",d:0}],c:[{t:1,d:1,f:14}]},{t:7,d:1,b:[{f:15,c:[{t:0,d:0,g:"div",a:[{k:"part",v:"description",d:0},{k:"class",v:"step__description",d:0}],c:[{t:1,d:1,f:16}]}]}]}]}]}]}]}]}]},{t:2,d:0,x:" 使用插槽时的渲染 "},{t:7,d:1,b:[{f:17,c:[{t:6,d:1,f:18,i:"slotItem",n:"index",a:[],c:[{t:0,d:1,g:"div",a:[{k:"part",v:"step",d:0},{k:"class",v:"step",d:0},{k:":class",f:19,d:1},{k:"role",v:"listitem",d:0},{k:":aria-current",f:20,d:1},{k:":aria-disabled",f:21,d:1},{k:"@click",f:22,d:1}],c:[{t:0,d:0,s:1,g:"div",a:[{k:"part",v:"tail",d:0},{k:"class",v:"step__tail",d:0}],c:[]},{t:0,d:0,g:"div",a:[{k:"part",v:"wrapper",d:0},{k:"class",v:"step__wrapper",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon-wrapper",d:0},{k:"class",v:"step__icon-wrapper",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"icon",d:0},{k:"class",v:"step__icon",d:0}],c:[{t:7,d:1,b:[{f:23,c:[{t:2,d:0,x:" 使用插槽元素的 innerHTML 作为图标内容 "},{t:0,d:1,g:"span",a:[{k:"part",v:"icon-substitution",d:0},{k:"class",v:"step__icon-substitution",d:0},{k:":innerHTML",f:24,d:1}],c:[]}]}]}]}]},{t:0,d:0,g:"div",a:[{k:"part",v:"content",d:0},{k:"class",v:"step__content",d:0}],c:[{t:0,d:0,g:"div",a:[{k:"part",v:"title",d:0},{k:"class",v:"step__title",d:0}],c:[{t:1,d:1,f:25}]},{t:7,d:1,b:[{f:26,c:[{t:0,d:0,g:"div",a:[{k:"part",v:"description",d:0},{k:"class",v:"step__description",d:0}],c:[{t:1,d:1,f:27}]}]}]}]}]}]}]}]}]}]}],s:{tf:27,cf:27,dn:1,tn:1,sn:0}};export{t as __SOLELY_IR__,t as default};
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty,t=(t,r,o)=>((t,r,o)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o)(t,"symbol"!=typeof r?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../types/ast.cjs"),o=require("../../shared/templateError.cjs"),n=require("../../shared/env.cjs"),s=require("./html-decode.cjs"),i=Symbol("solely.irCtx"),a=Symbol("solely.irEvents"),c=Symbol("solely.prevClassObj"),l=Symbol("solely.prevStyleObj"),d={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"},m=new Set(["data-","aria-","role","form"]),u=new Set(["value","selectedIndex"]);function f(e,t){var r;const o=null==(r=t.a)?void 0:r.find(e=>"class"===e.k&&!e.d);(null==o?void 0:o.v)&&e.setAttribute("class",o.v)}function p(e,t){var r;if(!e.style)return;const o=null==(r=t.a)?void 0:r.find(e=>"style"===e.k&&!e.d),n=o?v(o.v):{};for(const s in n){const t=n[s];s.startsWith("--")?e.style.setProperty(s,t):e.style[s]=t}}const y=e=>!(!e||0===e.length||/\s/.test(e)&&(n.IS_DEV&&console.warn(`[Solely] Invalid class name "${e}" contains whitespace, will be ignored`),1));function v(e){const t={},r=[[e]];for(;r.length;){const[e,o]=r.pop()||[];if(e){if("string"==typeof e){const r=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let o;for(;null!==(o=r.exec(e));){const e=o[1].trim(),r=o[2].trim();e&&r&&(t[e]=r)}continue}if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)r.push([e[t]]);else if("object"==typeof e)for(const n in e){const s=e[n];if(null==s)continue;const i=o?`${o}-${n}`:n;"object"!=typeof s||Array.isArray(s)?t[i]=String(s):r.push([s,i])}}}return t}function S(e,t,r){const o=null==r?"":String(r),n=t.indexOf(":");if(n>0){const r=t.slice(0,n),s=d[r];if(s)return void(e.getAttributeNS(s,t)!==o&&e.setAttributeNS(s,t,o))}e.getAttribute(t)!==o&&e.setAttribute(t,o)}function b(e,t,r,o){const n=h[t]||t;if(t.startsWith("data-")||t.startsWith("aria-")||m.has(t))return void S(e,t,r);const s=e,i=s.tagName;if(null!=r){if("src"===n||"href"===n){const t=String(r);if(s[n]===t||e.getAttribute(n)===t)return}if("value"!==n||"INPUT"!==i&&"TEXTAREA"!==i||s.value!==r)if("boolean"!=typeof r)(o??(e instanceof SVGElement||void 0!==s.ownerSVGElement))&&!h[t]?S(e,t,r):s[n]!==r&&(s[n]=r);else{if(s[n]===r)return;s[n]=r}}else if("boolean"==typeof s[n])!1!==s[n]&&(s[n]=!1);else{const r=s[n];""!==r&&void 0!==r&&(s[n]=""),e.hasAttribute(t)&&e.removeAttribute(t)}}class g{constructor(e,r,o={}){t(this,"nodeMap",new Map),t(this,"marker",!1),t(this,"staticSubtreeCache",new Map),this.ir=e,this.container=r,this.scope=o}evalIR(e,t,r){var s;const i=this.ir.fns[e-1];if(n.IS_DEV)try{return i?i.apply(this.scope,t):""}catch(a){return o.showTemplateError(a.message||a.toString(),(null==(s=this.ir.m)?void 0:s.src)||"",r,this.scope.tagName),""}return i?i.apply(this.scope,t):""}createElement(e,t){const r=e.g??"";return t instanceof SVGElement||"svg"===r?document.createElementNS("http://www.w3.org/2000/svg",r):document.createElement(r)}createText(e,t){const r=e.d?this.evalIR(e.f??-1,[t],e.__m):s.default(e.x||"");return document.createTextNode(r)}createComment(e,t){const r=e.d?this.evalIR(e.f??-1,[t],e.__m):e.x||"";return document.createComment(r)}applyAttrs(e,t,r,o=!1){const n=[],s=e,d=e instanceof SVGElement||void 0!==s.ownerSVGElement;let h;s[i]||(s[i]={loops:null}),s[i].loops=r,s[a]||(s[a]=Object.create(null));let m,f=!1,p=!1;for(const c of t){const{k:t,f:l,d:y,v:v}=c;if(":class"===t){h=this.evalIR(l??-1,[r],c.__m),f=!0;continue}if(":style"===t){m=this.evalIR(l??-1,[r],c.__m),p=!0;continue}if("class"===t||"style"===t)continue;const g=t[0];if("@"===g){const r=t.slice(1),n=c.r??"user";let d=s[a][r];if(d||(d=s[a][r]={model:[],user:[]},e.addEventListener(r,e=>{for(const t of d.model)t(e);for(const t of d.user)t(e)})),!o){const e=e=>this.evalIR(l??-1,[e,s[i].loops],c.__m);d[n].push(e)}continue}if("mounted"===t){o||requestAnimationFrame(()=>this.evalIR(l??-1,[e,r],c.__m));continue}if("updated"===t){o&&requestAnimationFrame(()=>this.evalIR(l??-1,[e,r],c.__m));continue}if("ref"===t&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=e;continue}const k=y?this.evalIR(l??-1,[r],c.__m):v??"";if(":"===g){const r=t.slice(1);"SELECT"===e.tagName&&u.has(r)?n.push(()=>b(e,r,k,d)):b(e,r,k,d)}else o||S(e,t,String(k))}return f&&((e,t)=>{const r=e,o=r[c],n=function(e){const t={},r=[e];for(;r.length;){const e=r.pop();if(e)if("string"==typeof e){const r=e.split(" ");for(let e=0;e<r.length;e++){const o=r[e].trim();o&&(t[o]=!0)}}else if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)r.push(e[t]);else if("object"==typeof e)for(const r in e)e[r]&&(t[r]=!0)}return t}(t),s={};for(const a in n)y(a)&&(s[a]=n[a]);if(!o){for(const t in s)e.classList.add(t);return void(r[c]=s)}let i=!1;for(const a in o)s[a]||(e.classList.remove(a),i=!0);for(const a in s)o[a]||(e.classList.add(a),i=!0);i&&(r[c]=s)})(e,h),p&&((e,t)=>{const r=e,o=v(t),n=r[l];if(!n){for(const t in o){const r=o[t];t.startsWith("--")?e.style.setProperty(t,r):e.style[t]=r}return void(r[l]=o)}let s=!1;for(const i in n)i in o||(i.startsWith("--")?e.style.removeProperty(i):e.style[i]="",s=!0);for(const i in o){const t=o[i];t!==n[i]&&(i.startsWith("--")?e.style.setProperty(i,t):e.style[i]=t,s=!0)}s&&(r[l]=o)})(e,m),n}updateNode(e,t,r){const o=t.d?this.evalIR(t.f??-1,[r],t.__m):t.x||"";t.d&&e.textContent!==o&&(e.textContent=o)}createStaticSubtree(e,t,o){var n;switch(e.t){case r.ASTType.Element:{const r=this.createElement(e,t);f(r,e),p(r,e);const s=this.applyAttrs(r,e.a??[],o);return null==(n=e.c)||n.forEach(e=>{const t=this.createStaticSubtree(e,r,o);r.appendChild(t)}),s.forEach(e=>e()),r}case r.ASTType.Text:return this.createText(e,o);case r.ASTType.Comment:return this.createComment(e,o);default:return document.createComment("unknown")}}handleStaticSubtree(e,t,r,o){const n=this.staticSubtreeCache.get(t);if(n){const e=n.cloneNode(!0);return r.appendChild(e),e}const s=this.createStaticSubtree(e,r,o);return r.appendChild(s),this.staticSubtreeCache.set(t,s.cloneNode(!0)),s}irToNode(e,t,o,n,s){var i,a,c,l,d,h,m;const u=o+"-"+t,y=this.nodeMap.get(u);let v;if(1!==e.s)if(y){v=y.node,y.marker=this.marker;let t=[];e.d&&(e.t===r.ASTType.Element?t=this.applyAttrs(v,e.a??[],s,!0):this.updateNode(v,e,s)),null==(i=e.c)||i.forEach((e,t)=>{this.irToNode(e,t,u,v,s)}),t.forEach(e=>e())}else switch(e.t){case r.ASTType.Element:v=this.createElement(e,n),f(v,e),p(v,e);const t=this.applyAttrs(v,e.a??[],s);n.appendChild(v),this.nodeMap.set(u,{irNode:e,node:v,loops:s,marker:this.marker}),null==(a=e.c)||a.forEach((e,t)=>{this.irToNode(e,t,u,v,s)}),t.forEach(e=>e());break;case r.ASTType.Text:v=this.createText(e,s),n.appendChild(v),this.nodeMap.set(u,{irNode:e,node:v,loops:s,marker:this.marker});break;case r.ASTType.Comment:v=this.createComment(e,s),n.appendChild(v),this.nodeMap.set(u,{irNode:e,node:v,loops:s,marker:this.marker});break;case r.ASTType.For:{const t=`${u}-end`;let o=null==(c=this.nodeMap.get(t))?void 0:c.node;o?this.nodeMap.get(t).marker=this.marker:(o=document.createComment(`for:${u}`),n.appendChild(o),this.nodeMap.set(t,{irNode:{t:r.ASTType.Comment},node:o,loops:s,marker:this.marker}));const i=this.evalIR(e.f??-1,[s],e.__m)||[],a=document.createDocumentFragment();i.forEach((t,r)=>{var o;const n=[...s,{itmVal:t,idxVal:r}];null==(o=e.c)||o.forEach((e,t)=>{this.irToNode(e,t,`${u}-for-${r}`,a,n)})}),null==(l=o.parentNode)||l.insertBefore(a,o);break}case r.ASTType.Conditional:{const t=`${u}-end`;let r=null==(d=this.nodeMap.get(t))?void 0:d.node;r?this.nodeMap.get(t).marker=this.marker:(r=document.createComment(`if:${u}`),n.appendChild(r),this.nodeMap.set(t,{irNode:{},node:r,loops:s,marker:this.marker}));for(let o=0;o<(e.b||[]).length;o++){const t=null==(h=e.b)?void 0:h[o];if(null===t.f||this.evalIR(t.f,[s],t.__m)){const e=document.createDocumentFragment();t.c.forEach((t,r)=>{this.irToNode(t,r,`${u}-if-${o}`,e,s)}),null==(m=r.parentNode)||m.insertBefore(e,r);break}}break}}else y?(y.marker=this.marker,v=y.node):(v=this.handleStaticSubtree(e,u,n,s),this.nodeMap.set(u,{irNode:e,node:v,loops:s,marker:this.marker}))}cleanupOldNodes(){for(const[e,t]of this.nodeMap.entries())if(t.marker!==this.marker){const{irNode:r,node:o,loops:n}=t;if(r.a){const e=r.a.find(e=>"unmounted"===e.k);e&&requestAnimationFrame(()=>{this.evalIR(e.f??-1,[o,n],e.__m)});const t=r.a.find(e=>"ref"===e.k);t&&t.v&&delete this.scope.$refs[t.v]}null==o||o.remove(),this.nodeMap.delete(e)}}mount(){this.marker=!this.marker,this.ir.n.forEach((e,t)=>{this.irToNode(e,t,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((e,t)=>{this.irToNode(e,t,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}exports.IRRenderer=g,exports.createRender=(e,t,r={})=>{const o=new g(e,t,r);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"),r=require("./html-decode.cjs"),i=Symbol("solely.irCtx"),a=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/"},p={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},d=new Set(["data-","aria-","role","form"]),u=new Set(["value","selectedIndex"]);function f(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?S(n.v):{};for(const r in o){const e=o[r];r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e}}const y=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 S(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 r=t[o];if(null==r)continue;const i=n?`${n}-${o}`:o;"object"!=typeof r||Array.isArray(r)?e[i]=String(r):s.push([r,i])}}}return e}function v(t,e,s){const n=null==s?"":String(s),o=e.indexOf(":");if(o>0){const s=e.slice(0,o),r=h[s];if(r)return void(t.getAttributeNS(r,e)!==n&&t.setAttributeNS(r,e,n))}t.getAttribute(e)!==n&&t.setAttribute(e,n)}function b(t,e,s,n){const o=p[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||d.has(e))return void v(t,e,s);const r=t,i=r.tagName;if(null!=s){if("src"===o||"href"===o){const e=String(s);if(r[o]===e||t.getAttribute(o)===e)return}if("value"!==o||"INPUT"!==i&&"TEXTAREA"!==i||r.value!==s)if("boolean"!=typeof s)(n??(t instanceof SVGElement||void 0!==r.ownerSVGElement))&&!p[e]?v(t,e,s):r[o]!==s&&(r[o]=s);else{if(r[o]===s)return;r[o]=s}}else if("boolean"==typeof r[o])!1!==r[o]&&(r[o]=!1);else{const s=r[o];""!==s&&void 0!==s&&(r[o]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class g{constructor(t,s,n={}){e(this,"nodeMap",new Map),e(this,"prevNodeMap",new Map),e(this,"pathStack",[]),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=n}evalIR(t,e,s){var r;const i=this.ir.fns[t-1];if(o.IS_DEV)try{return i?i.apply(this.scope,e):""}catch(a){return n.showTemplateError(a.message||a.toString(),(null==(r=this.ir.m)?void 0:r.src)||"",s,this.scope.tagName),""}return i?i.apply(this.scope,e):""}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??-1,[e],t.__m):r.default(t.x||"");return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f??-1,[e],t.__m):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,n=!1){const o=[],r=t,h=t instanceof SVGElement||void 0!==r.ownerSVGElement;let p;r[i]||(r[i]={loops:null}),r[i].loops=s,r[a]||(r[a]=Object.create(null));let d,f=!1,m=!1;for(const c of e){const{k:e,f:l,d:y,v:S}=c;if(":class"===e){p=this.evalIR(l??-1,[s],c.__m),f=!0;continue}if(":style"===e){d=this.evalIR(l??-1,[s],c.__m),m=!0;continue}if("class"===e||"style"===e)continue;const g=e[0];if("@"===g){const s=e.slice(1),o=c.r??"user";let h=r[a][s];if(h||(h=r[a][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??-1,[t,r[i].loops],c.__m);h[o].push(t)}continue}if("mounted"===e){n||requestAnimationFrame(()=>this.evalIR(l??-1,[t,s],c.__m));continue}if("updated"===e){n&&requestAnimationFrame(()=>this.evalIR(l??-1,[t,s],c.__m));continue}if("ref"===e&&S){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[S]=t;continue}const N=y?this.evalIR(l??-1,[s],c.__m):S??"";if(":"===g){const s=e.slice(1);"SELECT"===t.tagName&&u.has(s)?o.push(()=>b(t,s,N,h)):b(t,s,N,h)}else n||v(t,e,String(N))}return f&&((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),r={};for(const a in o)y(a)&&(r[a]=o[a]);if(!n){for(const e in r)t.classList.add(e);return void(s[c]=r)}let i=!1;for(const a in n)r[a]||(t.classList.remove(a),i=!0);for(const a in r)n[a]||(t.classList.add(a),i=!0);i&&(s[c]=r)})(t,p),m&&((t,e)=>{const s=t,n=S(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 r=!1;for(const i in o)i in n||(i.startsWith("--")?t.style.removeProperty(i):t.style[i]="",r=!0);for(const i in n){const e=n[i];e!==o[i]&&(i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e,r=!0)}r&&(s[l]=n)})(t,d),o}updateNode(t,e,s){const n=e.d?this.evalIR(e.f??-1,[s],e.__m):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);f(s,t),m(s,t);const r=this.applyAttrs(s,t.a??[],n);return null==(o=t.c)||o.forEach(t=>{const e=this.createStaticSubtree(t,s,n);s.appendChild(e)}),r.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 r=this.createStaticSubtree(t,s,n);return s.appendChild(r),this.staticSubtreeCache.set(e,r.cloneNode(!0)),r}currentKey(){return this.pathStack.join(".")}findEntry(t){let e=this.nodeMap.get(t);return e||(e=this.prevNodeMap.get(t),e&&(this.prevNodeMap.delete(t),this.nodeMap.set(t,e))),e}irToNode(t,e,s,n){this.pathStack.push(e),this.processNode(t,s,n),this.pathStack.pop()}processNode(t,e,n){var o,r,i,a,c,l,h;const p=this.currentKey(),d=this.findEntry(p);let u;if(1!==t.s)if(d){u=d.node;let e=[];t.d&&(t.t===s.ASTType.Element?e=this.applyAttrs(u,t.a??[],n,!0):this.updateNode(u,t,n)),null==(o=t.c)||o.forEach((t,e)=>{this.pathStack.push(e),this.processNode(t,u,n),this.pathStack.pop()}),e.forEach(t=>t())}else switch(t.t){case s.ASTType.Element:u=this.createElement(t,e),f(u,t),m(u,t);const o=this.applyAttrs(u,t.a??[],n);e.appendChild(u),this.nodeMap.set(p,{irNode:t,node:u,loops:n}),null==(r=t.c)||r.forEach((t,e)=>{this.pathStack.push(e),this.processNode(t,u,n),this.pathStack.pop()}),o.forEach(t=>t());break;case s.ASTType.Text:u=this.createText(t,n),e.appendChild(u),this.nodeMap.set(p,{irNode:t,node:u,loops:n});break;case s.ASTType.Comment:u=this.createComment(t,n),e.appendChild(u),this.nodeMap.set(p,{irNode:t,node:u,loops:n});break;case s.ASTType.For:{this.pathStack.push(-1);const o=this.currentKey();this.pathStack.pop();let r=null==(i=this.findEntry(o))?void 0:i.node;r||(r=document.createComment("for"),e.appendChild(r),this.nodeMap.set(o,{irNode:{t:s.ASTType.Comment},node:r,loops:n}));const c=this.evalIR(t.f??-1,[n],t.__m)||[],l=document.createDocumentFragment();c.forEach((e,s)=>{var o;const r=[...n,{itmVal:e,idxVal:s}];null==(o=t.c)||o.forEach((t,e)=>{this.pathStack.push(s,e),this.processNode(t,l,r),this.pathStack.pop(),this.pathStack.pop()})}),null==(a=r.parentNode)||a.insertBefore(l,r);break}case s.ASTType.Conditional:{this.pathStack.push(-1);const s=this.currentKey();this.pathStack.pop();let o=null==(c=this.findEntry(s))?void 0:c.node;o||(o=document.createComment("if"),e.appendChild(o),this.nodeMap.set(s,{irNode:{},node:o,loops:n}));for(let e=0;e<(t.b||[]).length;e++){const s=null==(l=t.b)?void 0:l[e];if(null===s.f||this.evalIR(s.f,[n],s.__m)){const t=document.createDocumentFragment();s.c.forEach((s,o)=>{this.pathStack.push(e,o),this.processNode(s,t,n),this.pathStack.pop(),this.pathStack.pop()}),null==(h=o.parentNode)||h.insertBefore(t,o);break}}break}}else d?u=d.node:(u=this.handleStaticSubtree(t,p,e,n),this.nodeMap.set(p,{irNode:t,node:u,loops:n}))}cleanupOldNodes(){const t=this.prevNodeMap;for(const[,e]of t.entries()){const{irNode:t,node:s,loops:n}=e;if(t.a){const e=t.a.find(t=>"unmounted"===t.k);e&&requestAnimationFrame(()=>{this.evalIR(e.f??-1,[s,n],e.__m)});const o=t.a.find(t=>"ref"===t.k);o&&o.v&&delete this.scope.$refs[o.v]}null==s||s.remove()}t.clear()}mount(){this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,this.container,[])}),this.cleanupOldNodes()}update(){this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.prevNodeMap.clear(),this.staticSubtreeCache.clear()}}exports.IRRenderer=g,exports.createRender=(t,e,s={})=>{const n=new g(t,e,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};
@@ -1,14 +1,11 @@
1
1
  import { IRRoot, Meta } from '../../types';
2
- /**
3
- * IR 渲染器类 - 负责将 IR(中间表示)渲染到 DOM
4
- */
5
2
  export declare class IRRenderer {
6
3
  private ir;
7
4
  private container;
8
5
  private scope;
9
6
  private nodeMap;
10
- private marker;
11
- /** 静态子树缓存:key -> DOM节点模板 */
7
+ private prevNodeMap;
8
+ private pathStack;
12
9
  private staticSubtreeCache;
13
10
  constructor(ir: IRRoot, container: HTMLElement, scope?: any);
14
11
  evalIR(fid: number, args: any[], meta?: Meta): any;
@@ -27,7 +24,10 @@ export declare class IRRenderer {
27
24
  * 首次渲染创建并缓存,后续直接克隆
28
25
  */
29
26
  private handleStaticSubtree;
27
+ private currentKey;
28
+ private findEntry;
30
29
  private irToNode;
30
+ private processNode;
31
31
  private cleanupOldNodes;
32
32
  mount(): void;
33
33
  update(): void;
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,o,n)=>((t,o,n)=>o in t?e(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n)(t,"symbol"!=typeof o?o+"":o,n);import{ASTType as o}from"../../types/ast.js";import{showTemplateError as n}from"../../shared/templateError.js";import{IS_DEV as s}from"../../shared/env.js";import r from"./html-decode.js";const i=Symbol("solely.irCtx"),a=Symbol("solely.irEvents"),c=Symbol("solely.prevClassObj"),l=Symbol("solely.prevStyleObj"),d={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"},m=new Set(["data-","aria-","role","form"]),f=new Set(["value","selectedIndex"]);function u(e,t){var o;const n=null==(o=t.a)?void 0:o.find(e=>"class"===e.k&&!e.d);(null==n?void 0:n.v)&&e.setAttribute("class",n.v)}function p(e,t){var o;if(!e.style)return;const n=null==(o=t.a)?void 0:o.find(e=>"style"===e.k&&!e.d),s=n?y(n.v):{};for(const r in s){const t=s[r];r.startsWith("--")?e.style.setProperty(r,t):e.style[r]=t}}const v=e=>!(!e||0===e.length||/\s/.test(e)&&(s&&console.warn(`[Solely] Invalid class name "${e}" contains whitespace, will be ignored`),1));function y(e){const t={},o=[[e]];for(;o.length;){const[e,n]=o.pop()||[];if(e){if("string"==typeof e){const o=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let n;for(;null!==(n=o.exec(e));){const e=n[1].trim(),o=n[2].trim();e&&o&&(t[e]=o)}continue}if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)o.push([e[t]]);else if("object"==typeof e)for(const s in e){const r=e[s];if(null==r)continue;const i=n?`${n}-${s}`:s;"object"!=typeof r||Array.isArray(r)?t[i]=String(r):o.push([r,i])}}}return t}function b(e,t,o){const n=null==o?"":String(o),s=t.indexOf(":");if(s>0){const o=t.slice(0,s),r=d[o];if(r)return void(e.getAttributeNS(r,t)!==n&&e.setAttributeNS(r,t,n))}e.getAttribute(t)!==n&&e.setAttribute(t,n)}function g(e,t,o,n){const s=h[t]||t;if(t.startsWith("data-")||t.startsWith("aria-")||m.has(t))return void b(e,t,o);const r=e,i=r.tagName;if(null!=o){if("src"===s||"href"===s){const t=String(o);if(r[s]===t||e.getAttribute(s)===t)return}if("value"!==s||"INPUT"!==i&&"TEXTAREA"!==i||r.value!==o)if("boolean"!=typeof o)(n??(e instanceof SVGElement||void 0!==r.ownerSVGElement))&&!h[t]?b(e,t,o):r[s]!==o&&(r[s]=o);else{if(r[s]===o)return;r[s]=o}}else if("boolean"==typeof r[s])!1!==r[s]&&(r[s]=!1);else{const o=r[s];""!==o&&void 0!==o&&(r[s]=""),e.hasAttribute(t)&&e.removeAttribute(t)}}class k{constructor(e,o,n={}){t(this,"nodeMap",new Map),t(this,"marker",!1),t(this,"staticSubtreeCache",new Map),this.ir=e,this.container=o,this.scope=n}evalIR(e,t,o){var r;const i=this.ir.fns[e-1];if(s)try{return i?i.apply(this.scope,t):""}catch(a){return n(a.message||a.toString(),(null==(r=this.ir.m)?void 0:r.src)||"",o,this.scope.tagName),""}return i?i.apply(this.scope,t):""}createElement(e,t){const o=e.g??"";return t instanceof SVGElement||"svg"===o?document.createElementNS("http://www.w3.org/2000/svg",o):document.createElement(o)}createText(e,t){const o=e.d?this.evalIR(e.f??-1,[t],e.__m):r(e.x||"");return document.createTextNode(o)}createComment(e,t){const o=e.d?this.evalIR(e.f??-1,[t],e.__m):e.x||"";return document.createComment(o)}applyAttrs(e,t,o,n=!1){const s=[],r=e,d=e instanceof SVGElement||void 0!==r.ownerSVGElement;let h;r[i]||(r[i]={loops:null}),r[i].loops=o,r[a]||(r[a]=Object.create(null));let m,u=!1,p=!1;for(const c of t){const{k:t,f:l,d:v,v:y}=c;if(":class"===t){h=this.evalIR(l??-1,[o],c.__m),u=!0;continue}if(":style"===t){m=this.evalIR(l??-1,[o],c.__m),p=!0;continue}if("class"===t||"style"===t)continue;const k=t[0];if("@"===k){const o=t.slice(1),s=c.r??"user";let d=r[a][o];if(d||(d=r[a][o]={model:[],user:[]},e.addEventListener(o,e=>{for(const t of d.model)t(e);for(const t of d.user)t(e)})),!n){const e=e=>this.evalIR(l??-1,[e,r[i].loops],c.__m);d[s].push(e)}continue}if("mounted"===t){n||requestAnimationFrame(()=>this.evalIR(l??-1,[e,o],c.__m));continue}if("updated"===t){n&&requestAnimationFrame(()=>this.evalIR(l??-1,[e,o],c.__m));continue}if("ref"===t&&y){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[y]=e;continue}const S=v?this.evalIR(l??-1,[o],c.__m):y??"";if(":"===k){const o=t.slice(1);"SELECT"===e.tagName&&f.has(o)?s.push(()=>g(e,o,S,d)):g(e,o,S,d)}else n||b(e,t,String(S))}return u&&((e,t)=>{const o=e,n=o[c],s=function(e){const t={},o=[e];for(;o.length;){const e=o.pop();if(e)if("string"==typeof e){const o=e.split(" ");for(let e=0;e<o.length;e++){const n=o[e].trim();n&&(t[n]=!0)}}else if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)o.push(e[t]);else if("object"==typeof e)for(const o in e)e[o]&&(t[o]=!0)}return t}(t),r={};for(const a in s)v(a)&&(r[a]=s[a]);if(!n){for(const t in r)e.classList.add(t);return void(o[c]=r)}let i=!1;for(const a in n)r[a]||(e.classList.remove(a),i=!0);for(const a in r)n[a]||(e.classList.add(a),i=!0);i&&(o[c]=r)})(e,h),p&&((e,t)=>{const o=e,n=y(t),s=o[l];if(!s){for(const t in n){const o=n[t];t.startsWith("--")?e.style.setProperty(t,o):e.style[t]=o}return void(o[l]=n)}let r=!1;for(const i in s)i in n||(i.startsWith("--")?e.style.removeProperty(i):e.style[i]="",r=!0);for(const i in n){const t=n[i];t!==s[i]&&(i.startsWith("--")?e.style.setProperty(i,t):e.style[i]=t,r=!0)}r&&(o[l]=n)})(e,m),s}updateNode(e,t,o){const n=t.d?this.evalIR(t.f??-1,[o],t.__m):t.x||"";t.d&&e.textContent!==n&&(e.textContent=n)}createStaticSubtree(e,t,n){var s;switch(e.t){case o.Element:{const o=this.createElement(e,t);u(o,e),p(o,e);const r=this.applyAttrs(o,e.a??[],n);return null==(s=e.c)||s.forEach(e=>{const t=this.createStaticSubtree(e,o,n);o.appendChild(t)}),r.forEach(e=>e()),o}case o.Text:return this.createText(e,n);case o.Comment:return this.createComment(e,n);default:return document.createComment("unknown")}}handleStaticSubtree(e,t,o,n){const s=this.staticSubtreeCache.get(t);if(s){const e=s.cloneNode(!0);return o.appendChild(e),e}const r=this.createStaticSubtree(e,o,n);return o.appendChild(r),this.staticSubtreeCache.set(t,r.cloneNode(!0)),r}irToNode(e,t,n,s,r){var i,a,c,l,d,h,m;const f=n+"-"+t,v=this.nodeMap.get(f);let y;if(1!==e.s)if(v){y=v.node,v.marker=this.marker;let t=[];e.d&&(e.t===o.Element?t=this.applyAttrs(y,e.a??[],r,!0):this.updateNode(y,e,r)),null==(i=e.c)||i.forEach((e,t)=>{this.irToNode(e,t,f,y,r)}),t.forEach(e=>e())}else switch(e.t){case o.Element:y=this.createElement(e,s),u(y,e),p(y,e);const t=this.applyAttrs(y,e.a??[],r);s.appendChild(y),this.nodeMap.set(f,{irNode:e,node:y,loops:r,marker:this.marker}),null==(a=e.c)||a.forEach((e,t)=>{this.irToNode(e,t,f,y,r)}),t.forEach(e=>e());break;case o.Text:y=this.createText(e,r),s.appendChild(y),this.nodeMap.set(f,{irNode:e,node:y,loops:r,marker:this.marker});break;case o.Comment:y=this.createComment(e,r),s.appendChild(y),this.nodeMap.set(f,{irNode:e,node:y,loops:r,marker:this.marker});break;case o.For:{const t=`${f}-end`;let n=null==(c=this.nodeMap.get(t))?void 0:c.node;n?this.nodeMap.get(t).marker=this.marker:(n=document.createComment(`for:${f}`),s.appendChild(n),this.nodeMap.set(t,{irNode:{t:o.Comment},node:n,loops:r,marker:this.marker}));const i=this.evalIR(e.f??-1,[r],e.__m)||[],a=document.createDocumentFragment();i.forEach((t,o)=>{var n;const s=[...r,{itmVal:t,idxVal:o}];null==(n=e.c)||n.forEach((e,t)=>{this.irToNode(e,t,`${f}-for-${o}`,a,s)})}),null==(l=n.parentNode)||l.insertBefore(a,n);break}case o.Conditional:{const t=`${f}-end`;let o=null==(d=this.nodeMap.get(t))?void 0:d.node;o?this.nodeMap.get(t).marker=this.marker:(o=document.createComment(`if:${f}`),s.appendChild(o),this.nodeMap.set(t,{irNode:{},node:o,loops:r,marker:this.marker}));for(let n=0;n<(e.b||[]).length;n++){const t=null==(h=e.b)?void 0:h[n];if(null===t.f||this.evalIR(t.f,[r],t.__m)){const e=document.createDocumentFragment();t.c.forEach((t,o)=>{this.irToNode(t,o,`${f}-if-${n}`,e,r)}),null==(m=o.parentNode)||m.insertBefore(e,o);break}}break}}else v?(v.marker=this.marker,y=v.node):(y=this.handleStaticSubtree(e,f,s,r),this.nodeMap.set(f,{irNode:e,node:y,loops:r,marker:this.marker}))}cleanupOldNodes(){for(const[e,t]of this.nodeMap.entries())if(t.marker!==this.marker){const{irNode:o,node:n,loops:s}=t;if(o.a){const e=o.a.find(e=>"unmounted"===e.k);e&&requestAnimationFrame(()=>{this.evalIR(e.f??-1,[n,s],e.__m)});const t=o.a.find(e=>"ref"===e.k);t&&t.v&&delete this.scope.$refs[t.v]}null==n||n.remove(),this.nodeMap.delete(e)}}mount(){this.marker=!this.marker,this.ir.n.forEach((e,t)=>{this.irToNode(e,t,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((e,t)=>{this.irToNode(e,t,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}const S=(e,t,o={})=>{const n=new k(e,t,o);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};export{k 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";import r from"./html-decode.js";const i=Symbol("solely.irCtx"),a=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/"},p={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},d=new Set(["data-","aria-","role","form"]),u=new Set(["value","selectedIndex"]);function f(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 r in n){const e=n[r];r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e}}const v=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 r=t[n];if(null==r)continue;const i=o?`${o}-${n}`:n;"object"!=typeof r||Array.isArray(r)?e[i]=String(r):s.push([r,i])}}}return e}function S(t,e,s){const o=null==s?"":String(s),n=e.indexOf(":");if(n>0){const s=e.slice(0,n),r=h[s];if(r)return void(t.getAttributeNS(r,e)!==o&&t.setAttributeNS(r,e,o))}t.getAttribute(e)!==o&&t.setAttribute(e,o)}function b(t,e,s,o){const n=p[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||d.has(e))return void S(t,e,s);const r=t,i=r.tagName;if(null!=s){if("src"===n||"href"===n){const e=String(s);if(r[n]===e||t.getAttribute(n)===e)return}if("value"!==n||"INPUT"!==i&&"TEXTAREA"!==i||r.value!==s)if("boolean"!=typeof s)(o??(t instanceof SVGElement||void 0!==r.ownerSVGElement))&&!p[e]?S(t,e,s):r[n]!==s&&(r[n]=s);else{if(r[n]===s)return;r[n]=s}}else if("boolean"==typeof r[n])!1!==r[n]&&(r[n]=!1);else{const s=r[n];""!==s&&void 0!==s&&(r[n]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class g{constructor(t,s,o={}){e(this,"nodeMap",new Map),e(this,"prevNodeMap",new Map),e(this,"pathStack",[]),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=o}evalIR(t,e,s){var r;const i=this.ir.fns[t-1];if(n)try{return i?i.apply(this.scope,e):""}catch(a){return o(a.message||a.toString(),(null==(r=this.ir.m)?void 0:r.src)||"",s,this.scope.tagName),""}return i?i.apply(this.scope,e):""}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??-1,[e],t.__m):r(t.x||"");return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f??-1,[e],t.__m):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,o=!1){const n=[],r=t,h=t instanceof SVGElement||void 0!==r.ownerSVGElement;let p;r[i]||(r[i]={loops:null}),r[i].loops=s,r[a]||(r[a]=Object.create(null));let d,f=!1,m=!1;for(const c of e){const{k:e,f:l,d:v,v:y}=c;if(":class"===e){p=this.evalIR(l??-1,[s],c.__m),f=!0;continue}if(":style"===e){d=this.evalIR(l??-1,[s],c.__m),m=!0;continue}if("class"===e||"style"===e)continue;const g=e[0];if("@"===g){const s=e.slice(1),n=c.r??"user";let h=r[a][s];if(h||(h=r[a][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??-1,[t,r[i].loops],c.__m);h[n].push(t)}continue}if("mounted"===e){o||requestAnimationFrame(()=>this.evalIR(l??-1,[t,s],c.__m));continue}if("updated"===e){o&&requestAnimationFrame(()=>this.evalIR(l??-1,[t,s],c.__m));continue}if("ref"===e&&y){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[y]=t;continue}const N=v?this.evalIR(l??-1,[s],c.__m):y??"";if(":"===g){const s=e.slice(1);"SELECT"===t.tagName&&u.has(s)?n.push(()=>b(t,s,N,h)):b(t,s,N,h)}else o||S(t,e,String(N))}return f&&((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),r={};for(const a in n)v(a)&&(r[a]=n[a]);if(!o){for(const e in r)t.classList.add(e);return void(s[c]=r)}let i=!1;for(const a in o)r[a]||(t.classList.remove(a),i=!0);for(const a in r)o[a]||(t.classList.add(a),i=!0);i&&(s[c]=r)})(t,p),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 r=!1;for(const i in n)i in o||(i.startsWith("--")?t.style.removeProperty(i):t.style[i]="",r=!0);for(const i in o){const e=o[i];e!==n[i]&&(i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e,r=!0)}r&&(s[l]=o)})(t,d),n}updateNode(t,e,s){const o=e.d?this.evalIR(e.f??-1,[s],e.__m):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);f(s,t),m(s,t);const r=this.applyAttrs(s,t.a??[],o);return null==(n=t.c)||n.forEach(t=>{const e=this.createStaticSubtree(t,s,o);s.appendChild(e)}),r.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 r=this.createStaticSubtree(t,s,o);return s.appendChild(r),this.staticSubtreeCache.set(e,r.cloneNode(!0)),r}currentKey(){return this.pathStack.join(".")}findEntry(t){let e=this.nodeMap.get(t);return e||(e=this.prevNodeMap.get(t),e&&(this.prevNodeMap.delete(t),this.nodeMap.set(t,e))),e}irToNode(t,e,s,o){this.pathStack.push(e),this.processNode(t,s,o),this.pathStack.pop()}processNode(t,e,o){var n,r,i,a,c,l,h;const p=this.currentKey(),d=this.findEntry(p);let u;if(1!==t.s)if(d){u=d.node;let e=[];t.d&&(t.t===s.Element?e=this.applyAttrs(u,t.a??[],o,!0):this.updateNode(u,t,o)),null==(n=t.c)||n.forEach((t,e)=>{this.pathStack.push(e),this.processNode(t,u,o),this.pathStack.pop()}),e.forEach(t=>t())}else switch(t.t){case s.Element:u=this.createElement(t,e),f(u,t),m(u,t);const n=this.applyAttrs(u,t.a??[],o);e.appendChild(u),this.nodeMap.set(p,{irNode:t,node:u,loops:o}),null==(r=t.c)||r.forEach((t,e)=>{this.pathStack.push(e),this.processNode(t,u,o),this.pathStack.pop()}),n.forEach(t=>t());break;case s.Text:u=this.createText(t,o),e.appendChild(u),this.nodeMap.set(p,{irNode:t,node:u,loops:o});break;case s.Comment:u=this.createComment(t,o),e.appendChild(u),this.nodeMap.set(p,{irNode:t,node:u,loops:o});break;case s.For:{this.pathStack.push(-1);const n=this.currentKey();this.pathStack.pop();let r=null==(i=this.findEntry(n))?void 0:i.node;r||(r=document.createComment("for"),e.appendChild(r),this.nodeMap.set(n,{irNode:{t:s.Comment},node:r,loops:o}));const c=this.evalIR(t.f??-1,[o],t.__m)||[],l=document.createDocumentFragment();c.forEach((e,s)=>{var n;const r=[...o,{itmVal:e,idxVal:s}];null==(n=t.c)||n.forEach((t,e)=>{this.pathStack.push(s,e),this.processNode(t,l,r),this.pathStack.pop(),this.pathStack.pop()})}),null==(a=r.parentNode)||a.insertBefore(l,r);break}case s.Conditional:{this.pathStack.push(-1);const s=this.currentKey();this.pathStack.pop();let n=null==(c=this.findEntry(s))?void 0:c.node;n||(n=document.createComment("if"),e.appendChild(n),this.nodeMap.set(s,{irNode:{},node:n,loops:o}));for(let e=0;e<(t.b||[]).length;e++){const s=null==(l=t.b)?void 0:l[e];if(null===s.f||this.evalIR(s.f,[o],s.__m)){const t=document.createDocumentFragment();s.c.forEach((s,n)=>{this.pathStack.push(e,n),this.processNode(s,t,o),this.pathStack.pop(),this.pathStack.pop()}),null==(h=n.parentNode)||h.insertBefore(t,n);break}}break}}else d?u=d.node:(u=this.handleStaticSubtree(t,p,e,o),this.nodeMap.set(p,{irNode:t,node:u,loops:o}))}cleanupOldNodes(){const t=this.prevNodeMap;for(const[,e]of t.entries()){const{irNode:t,node:s,loops:o}=e;if(t.a){const e=t.a.find(t=>"unmounted"===t.k);e&&requestAnimationFrame(()=>{this.evalIR(e.f??-1,[s,o],e.__m)});const n=t.a.find(t=>"ref"===t.k);n&&n.v&&delete this.scope.$refs[n.v]}null==s||s.remove()}t.clear()}mount(){this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,this.container,[])}),this.cleanupOldNodes()}update(){this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.prevNodeMap.clear(),this.staticSubtreeCache.clear()}}const N=(t,e,s={})=>{const o=new g(t,e,s);return o.mount(),{update:()=>o.update(),destroy:()=>o.destroy()}};export{g as IRRenderer,N as createRender};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.4.15",
4
+ "version": "0.4.17",
5
5
  "description": "A lightweight TypeScript framework for building web components with compile-time optimizations",
6
6
  "type": "module",
7
7
  "sideEffects": false,