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.
- package/dist/compiler/ir/buildIR.cjs +1 -1
- package/dist/compiler/ir/buildIR.js +1 -1
- package/dist/compiler/parser/parser.cjs +1 -1
- package/dist/compiler/parser/parser.js +1 -1
- package/dist/components/elements/steps/index.html.cjs +1 -1
- package/dist/components/elements/steps/index.html.js +1 -1
- package/dist/runtime/renderer/renderIR.cjs +1 -1
- package/dist/runtime/renderer/renderIR.d.ts +5 -5
- package/dist/runtime/renderer/renderIR.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
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\/]/,
|
|
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
|
|
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:
|
|
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:
|
|
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
|
|
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
|
|
11
|
-
|
|
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
|
|
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