solely 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/runtime/component/base-element.d.ts +4 -4
- package/dist/runtime/component/decorators.d.ts +2 -2
- package/dist/runtime/reactivity/observe.d.ts +6 -6
- package/dist/runtime/renderer/renderIR.cjs +1 -1
- package/dist/runtime/renderer/renderIR.d.ts +12 -0
- package/dist/runtime/renderer/renderIR.js +1 -1
- package/dist/shared/gen-function.d.ts +1 -1
- package/dist/types/ir.d.ts +8 -0
- package/package.json +233 -220
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=Object.defineProperty,n=(n,t,o)=>((n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o)(n,"symbol"!=typeof t?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../shared/gen-function.cjs"),o=require("../../shared/env.cjs"),i=require("../../types/ast.cjs"),s=require("../../types/lifecycle.cjs"),c=/\{\{[\s\S]*?\}\}/,
|
|
1
|
+
"use strict";var e=Object.defineProperty,n=(n,t,o)=>((n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o)(n,"symbol"!=typeof t?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../shared/gen-function.cjs"),o=require("../../shared/env.cjs"),i=require("../../types/ast.cjs"),s=require("../../types/lifecycle.cjs"),c=/\{\{[\s\S]*?\}\}/,r=new class{constructor(){n(this,"compilers",new Map)}get(e="anonymous"){let n=this.compilers.get(e);return n||(n=new l,this.compilers.set(e,n)),n}clear(e){var n;if(e)null==(n=this.compilers.get(e))||n.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class l{constructor(){n(this,"cache",new Map),n(this,"functions",[])}makeCacheKey(e,n,t){return 0===t.length?`${e}:${n}`:`${e}:${n}:${t.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,n,i){const s=null==n?void 0:n.trim();if(!s)return 0;const c=this.makeCacheKey(e,s,i),r=this.cache.get(c);if(void 0!==r)return r;let l;try{l=t.genFunction(s,e,i)}catch(a){o.IS_DEV,l=()=>""}const u=this.functions.push(l);return this.cache.set(c,u),u}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function u(e){const n=e[0];return":"===n?{isDynamic:!0,type:"expression"}:"@"===n?{isDynamic:!0,type:"handler"}:s.isLifecycleKind(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function a(e,n,t){o.IS_DEV&&(e.o={expr:n??"",loc:t??null})}function f(e){if(!e.attrs)return;const n=e.attrs.find(e=>"s-model"===e.key);if(!n)return;const t="$data."+n.value.replace("this.","").replace("$data.",""),o=n.loc,i=(e.tag||"").toLowerCase(),s=e.attrs.find(e=>"type"===e.key),c=(null==s?void 0:s.value)??"text";e.attrs=e.attrs.filter(e=>e!==n);const r=(n,t,i)=>{var s;null==(s=e.attrs)||s.push({key:n,value:t,role:i,loc:o})};if("input"===i){if("checkbox"===c){const n=e.attrs.find(e=>"value"===e.key),o=n?JSON.stringify(n.value):'"on"';return r(":checked",`Array.isArray(${t}) ? ${t}.includes(${o}) : ${t}`),void r("@change",`\n const _v = ${o};\n if(Array.isArray(${t})) {\n const _i = ${t}.indexOf(_v);\n if(checked && _i === -1) ${t}.push(_v);\n else if(!checked && _i > -1) ${t}.splice(_i,1);\n } else {\n ${t} = checked;\n }`,"model")}if("radio"===c){const n=e.attrs.find(e=>"value"===e.key),o=(null==n?void 0:n.value)??"null";return r(":checked",`${t} == ${JSON.stringify(o)}`),void r("@change",`if (checked) ${t} = ${JSON.stringify(o)}`,"model")}return r(":value",t),void r("@input",`${t} = value`,"model")}if("textarea"===i)return r(":value",t),void r("@input",`${t} = value`,"model");"select"!==i?(r(":value",t),r("@input",`${t} = $event`,"model")):e.attrs.some(e=>"multiple"===e.key)?(r("updated",`\n const values = Array.isArray(${t}) ? ${t} : ${t} != null ? [${t}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),r("@change",`${t} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(r(":value",t),r("@change",`${t} = value`,"model"))}function d(e,n,t,o=null){if(!e.attrs||0===e.attrs.length)return[];const i=[];for(const s of e.attrs){if(o&&o.has(s.key))continue;const{key:c,value:r,role:l}=s,{isDynamic:f,type:d}=u(c);if(f&&d){const o={k:c,f:t.compile(d,r??"",n),d:1,r:l};a(o,r,s.loc??e.loc),i.push(o)}else i.push({k:c,v:r,d:0,r:l})}return i}function v(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const n of e.c)if(!v(n))return!1;if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)if(!v(e))return!1;return!0}function h(e){if(e.c&&e.c.length>0)for(const n of e.c)h(n);if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)h(e);e.t!==i.ASTType.Element&&e.t!==i.ASTType.Text||0===e.d&&v(e)&&(e.s=1)}function p(e,n,t){var s,r,l,v,h,p;const y={t:e.type,d:0};let $=!1;var k;switch(e.type===i.ASTType.Text?(k=e.content)&&c.test(k)&&($=!0):((null==(s=e.attrs)?void 0:s.some(e=>"s-model"===e.key||u(e.key).isDynamic))&&($=!0),e.type===i.ASTType.For&&($=!0)),y.d=$?1:0,e.type){case i.ASTType.Text:{const o=e.content??"";$?(y.f=t.compile("template",o,n),a(y,o,e.loc)):y.x=o;break}case i.ASTType.Element:y.g=e.tag,f(e),y.a=d(e,n,t),e.children&&(y.c=m(e.children,n,t));break;case i.ASTType.For:{const o=null==(r=e.attrs)?void 0:r.find(e=>"each"===e.key),i=(null==o?void 0:o.value)??"";y.f=t.compile("expression",i,n),y.i=(null==(v=null==(l=e.attrs)?void 0:l.find(e=>"item"===e.key))?void 0:v.value)??"item",y.n=(null==(p=null==(h=e.attrs)?void 0:h.find(e=>"index"===e.key))?void 0:p.value)??"index",a(y,i,(null==o?void 0:o.loc)??e.loc);const s=new Set(["each","item","index"]);y.a=d(e,n,t,s);const c=[...n,{i:y.i,x:y.n}];e.children&&(y.c=m(e.children,c,t));break}case i.ASTType.If:case i.ASTType.ElseIf:case i.ASTType.Else:o.IS_DEV,y.a=d(e,n,t),e.children&&(y.c=m(e.children,n,t));break;case i.ASTType.Comment:y.x=e.content??""}return y}function m(e,n,t){var s;const c=[];let r=0;for(;r<e.length;){const l=e[r];if(l.type===i.ASTType.If){const u=[];let a=r;for(;a<e.length;){const c=e[a],r=c.type;if(r!==i.ASTType.If&&r!==i.ASTType.ElseIf&&r!==i.ASTType.Else)break;if(r===i.ASTType.If&&u.length>0)break;let l,f=null,v="";if(r!==i.ASTType.Else){const e=null==(s=c.attrs)?void 0:s.find(e=>"test"===e.key||"condition"===e.key);v=(null==e?void 0:e.value)??"false",f=t.compile("expression",v,n),l=(null==e?void 0:e.loc)??c.loc}const h=c.children?m(c.children,n,t):[],p=d(c,n,t,new Set(["test","condition"]));if(u.push({f:f,c:h,a:p.length>0?p:void 0,...o.IS_DEV&&{o:{expr:v,loc:l}}}),a++,r===i.ASTType.Else)break}c.push({t:i.ASTType.Conditional,d:1,b:u,...o.IS_DEV&&{o:{loc:l.loc}}}),r=a}else c.push(p(l,n,t)),r++}return c}exports.buildIR=function(e,n={}){const{filename:t="anonymous",source:i}=n,s=r.get(t);s.clear(),performance.now();const c=m(e,[],s);for(const o of c)h(o);performance.now();const l=s.getStats(),u=c.filter(e=>1===e.d).length,a=c.filter(e=>1===e.s).length,f={t:"root",v:"1.2.0",fns:s.getFunctions(),n:c,s:{tf:l.total,cf:l.cached,dn:u,tn:c.length,sn:a},m:{t:(new Date).toISOString(),as:e.length,fn:t,...i&&{src:i}}};return o.IS_DEV,f},exports.clearIRCache=function(e){r.clear(e)},exports.transformModel=f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,n=(n,t,o)=>((n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o)(n,"symbol"!=typeof t?t+"":t,o);import{genFunction as t}from"../../shared/gen-function.js";import{IS_DEV as o}from"../../shared/env.js";import{ASTType as i}from"../../types/ast.js";import{isLifecycleKind as s}from"../../types/lifecycle.js";const c=/\{\{[\s\S]*?\}\}/,
|
|
1
|
+
var e=Object.defineProperty,n=(n,t,o)=>((n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o)(n,"symbol"!=typeof t?t+"":t,o);import{genFunction as t}from"../../shared/gen-function.js";import{IS_DEV as o}from"../../shared/env.js";import{ASTType as i}from"../../types/ast.js";import{isLifecycleKind as s}from"../../types/lifecycle.js";const c=/\{\{[\s\S]*?\}\}/,r=new class{constructor(){n(this,"compilers",new Map)}get(e="anonymous"){let n=this.compilers.get(e);return n||(n=new l,this.compilers.set(e,n)),n}clear(e){var n;if(e)null==(n=this.compilers.get(e))||n.clear(),this.compilers.delete(e);else{for(const e of this.compilers.values())e.clear();this.compilers.clear()}}};class l{constructor(){n(this,"cache",new Map),n(this,"functions",[])}makeCacheKey(e,n,t){return 0===t.length?`${e}:${n}`:`${e}:${n}:${t.map(e=>Object.keys(e).sort().join(",")).join(";")}`}compile(e,n,o){const i=null==n?void 0:n.trim();if(!i)return 0;const s=this.makeCacheKey(e,i,o),c=this.cache.get(s);if(void 0!==c)return c;let r;try{r=t(i,e,o)}catch(a){r=()=>""}const l=this.functions.push(r);return this.cache.set(s,l),l}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function a(e){const n=e[0];return":"===n?{isDynamic:!0,type:"expression"}:"@"===n?{isDynamic:!0,type:"handler"}:s(e)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function u(e,n,t){o&&(e.o={expr:n??"",loc:t??null})}function f(e){if(!e.attrs)return;const n=e.attrs.find(e=>"s-model"===e.key);if(!n)return;const t="$data."+n.value.replace("this.","").replace("$data.",""),o=n.loc,i=(e.tag||"").toLowerCase(),s=e.attrs.find(e=>"type"===e.key),c=(null==s?void 0:s.value)??"text";e.attrs=e.attrs.filter(e=>e!==n);const r=(n,t,i)=>{var s;null==(s=e.attrs)||s.push({key:n,value:t,role:i,loc:o})};if("input"===i){if("checkbox"===c){const n=e.attrs.find(e=>"value"===e.key),o=n?JSON.stringify(n.value):'"on"';return r(":checked",`Array.isArray(${t}) ? ${t}.includes(${o}) : ${t}`),void r("@change",`\n const _v = ${o};\n if(Array.isArray(${t})) {\n const _i = ${t}.indexOf(_v);\n if(checked && _i === -1) ${t}.push(_v);\n else if(!checked && _i > -1) ${t}.splice(_i,1);\n } else {\n ${t} = checked;\n }`,"model")}if("radio"===c){const n=e.attrs.find(e=>"value"===e.key),o=(null==n?void 0:n.value)??"null";return r(":checked",`${t} == ${JSON.stringify(o)}`),void r("@change",`if (checked) ${t} = ${JSON.stringify(o)}`,"model")}return r(":value",t),void r("@input",`${t} = value`,"model")}if("textarea"===i)return r(":value",t),void r("@input",`${t} = value`,"model");"select"!==i?(r(":value",t),r("@input",`${t} = $event`,"model")):e.attrs.some(e=>"multiple"===e.key)?(r("updated",`\n const values = Array.isArray(${t}) ? ${t} : ${t} != null ? [${t}] : [];\n for (const opt of el.options) {\n opt.selected = values.includes(opt.value);\n }`),r("@change",`${t} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(r(":value",t),r("@change",`${t} = value`,"model"))}function d(e,n,t,o=null){if(!e.attrs||0===e.attrs.length)return[];const i=[];for(const s of e.attrs){if(o&&o.has(s.key))continue;const{key:c,value:r,role:l}=s,{isDynamic:f,type:d}=a(c);if(f&&d){const o={k:c,f:t.compile(d,r??"",n),d:1,r:l};u(o,r,s.loc??e.loc),i.push(o)}else i.push({k:c,v:r,d:0,r:l})}return i}function v(e){if(1===e.d)return!1;if(e.c&&e.c.length>0)for(const n of e.c)if(!v(n))return!1;if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)if(!v(e))return!1;return!0}function m(e){if(e.c&&e.c.length>0)for(const n of e.c)m(n);if(e.b&&e.b.length>0)for(const n of e.b)if(n.c&&n.c.length>0)for(const e of n.c)m(e);e.t!==i.Element&&e.t!==i.Text||0===e.d&&v(e)&&(e.s=1)}function h(e,n,t){var o,s,r,l,v,m;const h={t:e.type,d:0};let $=!1;var y;switch(e.type===i.Text?(y=e.content)&&c.test(y)&&($=!0):((null==(o=e.attrs)?void 0:o.some(e=>"s-model"===e.key||a(e.key).isDynamic))&&($=!0),e.type===i.For&&($=!0)),h.d=$?1:0,e.type){case i.Text:{const o=e.content??"";$?(h.f=t.compile("template",o,n),u(h,o,e.loc)):h.x=o;break}case i.Element:h.g=e.tag,f(e),h.a=d(e,n,t),e.children&&(h.c=p(e.children,n,t));break;case i.For:{const o=null==(s=e.attrs)?void 0:s.find(e=>"each"===e.key),i=(null==o?void 0:o.value)??"";h.f=t.compile("expression",i,n),h.i=(null==(l=null==(r=e.attrs)?void 0:r.find(e=>"item"===e.key))?void 0:l.value)??"item",h.n=(null==(m=null==(v=e.attrs)?void 0:v.find(e=>"index"===e.key))?void 0:m.value)??"index",u(h,i,(null==o?void 0:o.loc)??e.loc);const c=new Set(["each","item","index"]);h.a=d(e,n,t,c);const a=[...n,{i:h.i,x:h.n}];e.children&&(h.c=p(e.children,a,t));break}case i.If:case i.ElseIf:case i.Else:h.a=d(e,n,t),e.children&&(h.c=p(e.children,n,t));break;case i.Comment:h.x=e.content??""}return h}function p(e,n,t){var s;const c=[];let r=0;for(;r<e.length;){const l=e[r];if(l.type===i.If){const a=[];let u=r;for(;u<e.length;){const c=e[u],r=c.type;if(r!==i.If&&r!==i.ElseIf&&r!==i.Else)break;if(r===i.If&&a.length>0)break;let l,f=null,v="";if(r!==i.Else){const e=null==(s=c.attrs)?void 0:s.find(e=>"test"===e.key||"condition"===e.key);v=(null==e?void 0:e.value)??"false",f=t.compile("expression",v,n),l=(null==e?void 0:e.loc)??c.loc}const m=c.children?p(c.children,n,t):[],h=d(c,n,t,new Set(["test","condition"]));if(a.push({f:f,c:m,a:h.length>0?h:void 0,...o&&{o:{expr:v,loc:l}}}),u++,r===i.Else)break}c.push({t:i.Conditional,d:1,b:a,...o&&{o:{loc:l.loc}}}),r=u}else c.push(h(l,n,t)),r++}return c}function $(e,n={}){const{filename:t="anonymous",source:o}=n,i=r.get(t);i.clear(),performance.now();const s=p(e,[],i);for(const r of s)m(r);performance.now();const c=i.getStats(),l=s.filter(e=>1===e.d).length,a=s.filter(e=>1===e.s).length;return{t:"root",v:"1.2.0",fns:i.getFunctions(),n:s,s:{tf:c.total,cf:c.cached,dn:l,tn:s.length,sn:a},m:{t:(new Date).toISOString(),as:e.length,fn:t,...o&&{src:o}}}}function y(e){r.clear(e)}export{$ as buildIR,y as clearIRCache,f as transformModel};
|
|
@@ -1 +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"),c=/<\/?([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 s(o,s){var i;const l=(null==(i=(o.match(c)||[])[1])?void 0:i.toLowerCase())??"",f=function(e,c){const o=[];let s;const i=e.replace(/^\s*[^\s"'/>]+/,""),l=e.length-i.length;for(;null!==(s=r.exec(i));){const r=s[1];if(!r)continue;const i=s[2]??s[3]??s[4]??"";let f=r;t.default.has(r)&&(f=f.replace(/^on/,"@")),"s-model"!==f&&(f=f.replace(/^on-/,"@").replace(/^s-/,":")),f=n.mapAttrKeyToLifecycleKind(f)||f;const u=s[0],a=u.indexOf("=");let d;if(-1===a)d=u.indexOf(r)+r.length;else{let t=a+1;for(;t<u.length&&/\s/.test(u[t]);)t++;if('"'===u[t]||"'"===u[t]){let e=t+1;for(;e<u.length&&/\s/.test(u[e]);)e++;d=e}else{let e=t;for(;e<u.length&&/\s/.test(u[e]);)e++;d=e}}
|
|
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"),c=/<\/?([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 s(o,s){var i;const l=(null==(i=(o.match(c)||[])[1])?void 0:i.toLowerCase())??"",f=function(e,c){const o=[];let s;const i=e.replace(/^\s*[^\s"'/>]+/,""),l=e.length-i.length;for(;null!==(s=r.exec(i));){const r=s[1];if(!r)continue;const i=s[2]??s[3]??s[4]??"";let f=r;t.default.has(r)&&(f=f.replace(/^on/,"@")),"s-model"!==f&&(f=f.replace(/^on-/,"@").replace(/^s-/,":")),f=n.mapAttrKeyToLifecycleKind(f)||f;const u=s[0],a=u.indexOf("=");let d;if(-1===a)d=u.indexOf(r)+r.length;else{let t=a+1;for(;t<u.length&&/\s/.test(u[t]);)t++;if('"'===u[t]||"'"===u[t]){let e=t+1;for(;e<u.length&&/\s/.test(u[e]);)e++;d=e}else{let e=t;for(;e<u.length&&/\s/.test(u[e]);)e++;d=e}}const p=s.index+d+l,y=e.slice(0,p).split("\n"),m=c[0]+y.length-1,g=y.length>1?y[y.length-1].length+1:c[1]+p;o.push({key:f,value:i,loc:[m,g]})}return o}(o,s);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:s,children:[],attrs:f}}function i(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 c=!1,o=!1,r=e;for(;r<n;){const e=t[r];if("'"!==e||o)if('"'!==e||c){if(">"===e&&!c&&!o)return r}else o=!o;else c=!c;r++}return-1}exports.parseHtml=function(t){const n=[];if(!t)return[];const c=[],r=[],l=()=>{var t;return 0===c.length?n:(t=c[c.length-1]).children||(t.children=[])};let f=0;const u=t.length,a=[0];for(let e=0;e<u;e++)"\n"===t[e]&&a.push(e+1);function d(t){let e=0;for(let n=1;n<a.length&&!(a[n]>t);n++)e=n;return[e+1,t-a[e]+1]}for(;f<u;){const n=t.indexOf("<",f);if(-1===n||n>f){const c=t.substring(f,-1===n?void 0:n),o=c.trim();if(o){const t=d(f+c.indexOf(o));l().push({type:e.ASTType.Text,tag:"text",content:o,loc:t,children:[]})}if(-1===n)break;f=n}const a=i(t,f+1);if(-1===a){const n=t.substring(f);n.trim()&&l().push({type:e.ASTType.Text,tag:"text",content:n.trim(),children:[],loc:d(f)});break}const p=t.substring(f,a+1),y=l(),m=d(f);if(p.startsWith("\x3c!--")){y.push({type:e.ASTType.Comment,tag:"comment",content:p.slice(4,-3),loc:m,children:[]}),f=a+1;continue}if(p.startsWith("<![CDATA[")){y.push({type:e.ASTType.Text,tag:"text",content:p.slice(9,-3),loc:m,children:[]}),f=a+1;continue}if(p.startsWith("<!")&&!p.startsWith("\x3c!--")){y.push({type:e.ASTType.Comment,tag:"comment",content:p.slice(2,-1),loc:m,children:[]}),f=a+1;continue}if(p.startsWith("<?")){y.push({type:e.ASTType.Comment,tag:"comment",content:p.slice(2,-2),loc:m,children:[]}),f=a+1;continue}if(p.startsWith("</")){const t=r.pop();for(;c.length>0;){if((c[c.length-1].tag||"").toLowerCase()===(null==t?void 0:t.toLowerCase())){c.pop();break}c.pop()}f=a+1;continue}const g=s(p,m);y.push(g);const h=g.tag||"",x=h.toLowerCase().startsWith("script"),b=h.toLowerCase().startsWith("style"),v=p.endsWith("/>")||o.has(h.toLowerCase());if((x||b)&&!v){const n=`</${h}>`,c=t.toLowerCase().indexOf(n,a+1);if(-1!==c){const o=t.substring(a+1,c);o.length&&g.children.push({type:e.ASTType.Text,tag:"text",content:o,loc:d(a+1),children:[]}),f=c+n.length;continue}{const n=t.substring(a+1);n.length&&g.children.push({type:e.ASTType.Text,tag:"text",content:n,loc:d(a+1),children:[]}),f=u;continue}}v||g.type===e.ASTType.Text||g.type===e.ASTType.Comment||(c.push(g),r.push(h)),f=a+1}return n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"../../shared/event-listeners.js";import{ASTType as n}from"../../types/ast.js";import{mapAttrKeyToLifecycleKind as e}from"../../types/lifecycle.js";const o=/<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/,c=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),r=/\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;function s(c,s){var i;const l=(null==(i=(c.match(o)||[])[1])?void 0:i.toLowerCase())??"",f=function(n,o){const c=[];let s;const i=n.replace(/^\s*[^\s"'/>]+/,""),l=n.length-i.length;for(;null!==(s=r.exec(i));){const r=s[1];if(!r)continue;const i=s[2]??s[3]??s[4]??"";let f=r;t.has(r)&&(f=f.replace(/^on/,"@")),"s-model"!==f&&(f=f.replace(/^on-/,"@").replace(/^s-/,":")),f=e(f)||f;const u=s[0],a=u.indexOf("=");let p;if(-1===a)p=u.indexOf(r)+r.length;else{let t=a+1;for(;t<u.length&&/\s/.test(u[t]);)t++;if('"'===u[t]||"'"===u[t]){let n=t+1;for(;n<u.length&&/\s/.test(u[n]);)n++;p=n}else{let n=t;for(;n<u.length&&/\s/.test(u[n]);)n++;p=n}}
|
|
1
|
+
import t from"../../shared/event-listeners.js";import{ASTType as n}from"../../types/ast.js";import{mapAttrKeyToLifecycleKind as e}from"../../types/lifecycle.js";const o=/<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/,c=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),r=/\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;function s(c,s){var i;const l=(null==(i=(c.match(o)||[])[1])?void 0:i.toLowerCase())??"",f=function(n,o){const c=[];let s;const i=n.replace(/^\s*[^\s"'/>]+/,""),l=n.length-i.length;for(;null!==(s=r.exec(i));){const r=s[1];if(!r)continue;const i=s[2]??s[3]??s[4]??"";let f=r;t.has(r)&&(f=f.replace(/^on/,"@")),"s-model"!==f&&(f=f.replace(/^on-/,"@").replace(/^s-/,":")),f=e(f)||f;const u=s[0],a=u.indexOf("=");let p;if(-1===a)p=u.indexOf(r)+r.length;else{let t=a+1;for(;t<u.length&&/\s/.test(u[t]);)t++;if('"'===u[t]||"'"===u[t]){let n=t+1;for(;n<u.length&&/\s/.test(u[n]);)n++;p=n}else{let n=t;for(;n<u.length&&/\s/.test(u[n]);)n++;p=n}}const m=s.index+p+l,d=n.slice(0,m).split("\n"),y=o[0]+d.length-1,g=d.length>1?d[d.length-1].length+1:o[1]+m;c.push({key:f,value:i,loc:[y,g]})}return c}(c,s);return{type:{for:n.For,if:n.If,elseif:n.ElseIf,else:n.Else}[l]??n.Element,tag:l,loc:s,children:[],attrs:f}}function i(t,n){const e=t.length;if(t.startsWith("!--",n)){const e=t.indexOf("--\x3e",n+3);return-1===e?-1:e+2}if(t.startsWith("![CDATA[",n)){const e=t.indexOf("]]>",n+8);return-1===e?-1:e+2}if("!"===t[n])return t.indexOf(">",n+1);if("?"===t[n]){const e=t.indexOf("?>",n+1);return-1===e?-1:e+1}let o=!1,c=!1,r=n;for(;r<e;){const n=t[r];if("'"!==n||c)if('"'!==n||o){if(">"===n&&!o&&!c)return r}else c=!c;else o=!o;r++}return-1}function l(t){const e=[];if(!t)return[];const o=[],r=[],l=()=>{var t;return 0===o.length?e:(t=o[o.length-1]).children||(t.children=[])};let f=0;const u=t.length,a=[0];for(let n=0;n<u;n++)"\n"===t[n]&&a.push(n+1);function p(t){let n=0;for(let e=1;e<a.length&&!(a[e]>t);e++)n=e;return[n+1,t-a[n]+1]}for(;f<u;){const e=t.indexOf("<",f);if(-1===e||e>f){const o=t.substring(f,-1===e?void 0:e),c=o.trim();if(c){const t=p(f+o.indexOf(c));l().push({type:n.Text,tag:"text",content:c,loc:t,children:[]})}if(-1===e)break;f=e}const a=i(t,f+1);if(-1===a){const e=t.substring(f);e.trim()&&l().push({type:n.Text,tag:"text",content:e.trim(),children:[],loc:p(f)});break}const m=t.substring(f,a+1),d=l(),y=p(f);if(m.startsWith("\x3c!--")){d.push({type:n.Comment,tag:"comment",content:m.slice(4,-3),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("<![CDATA[")){d.push({type:n.Text,tag:"text",content:m.slice(9,-3),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("<!")&&!m.startsWith("\x3c!--")){d.push({type:n.Comment,tag:"comment",content:m.slice(2,-1),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("<?")){d.push({type:n.Comment,tag:"comment",content:m.slice(2,-2),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("</")){const t=r.pop();for(;o.length>0;){if((o[o.length-1].tag||"").toLowerCase()===(null==t?void 0:t.toLowerCase())){o.pop();break}o.pop()}f=a+1;continue}const g=s(m,y);d.push(g);const h=g.tag||"",x=h.toLowerCase().startsWith("script"),b=h.toLowerCase().startsWith("style"),v=m.endsWith("/>")||c.has(h.toLowerCase());if((x||b)&&!v){const e=`</${h}>`,o=t.toLowerCase().indexOf(e,a+1);if(-1!==o){const c=t.substring(a+1,o);c.length&&g.children.push({type:n.Text,tag:"text",content:c,loc:p(a+1),children:[]}),f=o+e.length;continue}{const e=t.substring(a+1);e.length&&g.children.push({type:n.Text,tag:"text",content:e,loc:p(a+1),children:[]}),f=u;continue}}v||g.type===n.Text||g.type===n.Comment||(o.push(g),r.push(h)),f=a+1}return e}export{l as parseHtml};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
declare interface BaseElement<TData = any> {
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
* 通过 ref 属性获取的 DOM 元素引用集合
|
|
4
|
+
* - 键:模板中写的 ref="xxx" 的名字
|
|
5
|
+
* - 值:对应的 DOM 元素(通常是 HTMLElement 或 SVGElement)
|
|
6
|
+
*/
|
|
7
7
|
$refs: Record<string, HTMLElement | SVGElement | any>;
|
|
8
8
|
}
|
|
9
9
|
declare class BaseElement<TData extends object = any> extends HTMLElement {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IRRoot } from '../../types';
|
|
2
2
|
/** Prop 配置,支持类型声明 */
|
|
3
|
-
export type PropType =
|
|
3
|
+
export type PropType = 'string' | 'number' | 'boolean' | 'object';
|
|
4
4
|
/** 属性描述符 */
|
|
5
5
|
export interface PropDescriptor {
|
|
6
6
|
/** HTML attribute 名 */
|
|
@@ -27,7 +27,7 @@ export interface Manifest {
|
|
|
27
27
|
/** 是否启用 Shadow DOM */
|
|
28
28
|
shadowDOM?: {
|
|
29
29
|
use: boolean;
|
|
30
|
-
mode?:
|
|
30
|
+
mode?: 'open' | 'closed';
|
|
31
31
|
};
|
|
32
32
|
/** 组件根元素类名 */
|
|
33
33
|
className?: string;
|
|
@@ -2,29 +2,29 @@
|
|
|
2
2
|
export type PathKey = string | symbol;
|
|
3
3
|
/** 变更项的原始载荷 */
|
|
4
4
|
export type ChangePayload = {
|
|
5
|
-
type:
|
|
5
|
+
type: 'set';
|
|
6
6
|
key: PathKey;
|
|
7
7
|
newValue: unknown;
|
|
8
8
|
oldValue: unknown;
|
|
9
9
|
} | {
|
|
10
|
-
type:
|
|
10
|
+
type: 'delete';
|
|
11
11
|
key: PathKey;
|
|
12
12
|
oldValue: unknown;
|
|
13
13
|
} | {
|
|
14
|
-
type:
|
|
14
|
+
type: 'array-push';
|
|
15
15
|
index: number;
|
|
16
16
|
values: unknown[];
|
|
17
17
|
} | {
|
|
18
|
-
type:
|
|
18
|
+
type: 'array-splice';
|
|
19
19
|
index: number;
|
|
20
20
|
deleteCount: number;
|
|
21
21
|
insert: unknown[];
|
|
22
22
|
} | {
|
|
23
|
-
type:
|
|
23
|
+
type: 'array-replace';
|
|
24
24
|
oldValue: unknown[];
|
|
25
25
|
newValue: unknown[];
|
|
26
26
|
} | {
|
|
27
|
-
type:
|
|
27
|
+
type: 'array-reset';
|
|
28
28
|
method: string;
|
|
29
29
|
};
|
|
30
30
|
/** 完整的变更对象 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=Object.defineProperty,e=(e,o
|
|
1
|
+
"use strict";var t=Object.defineProperty,e=(e,s,o)=>((e,s,o)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o)(e,"symbol"!=typeof s?s+"":s,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../types/ast.cjs"),o=require("../../shared/templateError.cjs"),n=Symbol("solely.irCtx"),i=Symbol("solely.irEvents"),r=Symbol("solely.prevClassObj"),c=Symbol("solely.prevStyleObj"),l={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},a={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},h=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 d(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?m(o.v):{};for(const i in n){const e=n[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}function m(t){const e={},s=[[t]];for(;s.length;){const[t,o]=s.pop();if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let o;for(;null!==(o=s.exec(t));){const t=o[1].trim(),s=o[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const n in t){const i=t[n];if(null==i)continue;const r=o?`${o}-${n}`:n;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function p(t,e,s){const o=null==s?"":String(s),n=e.indexOf(":");if(n>0){const s=e.slice(0,n),i=l[s];if(i)return void(t.getAttributeNS(i,e)!==o&&t.setAttributeNS(i,e,o))}t.getAttribute(e)!==o&&t.setAttribute(e,o)}function b(t,e,s){const o=a[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||h.has(e))return void p(t,e,s);const n=t,i=n.tagName;if(null!=s){if("src"===o||"href"===o){const e=String(s);if(n[o]===e||t.getAttribute(o)===e)return}if("value"!==o||"INPUT"!==i&&"TEXTAREA"!==i||n.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==n.ownerSVGElement)&&!a[e]?p(t,e,s):n[o]!==s&&(n[o]=s);else{if(n[o]===s)return;n[o]=s}}else if("boolean"==typeof n[o])!1!==n[o]&&(n[o]=!1);else{const s=n[o];""!==s&&void 0!==s&&(n[o]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class y{constructor(t,s,o={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=o}evalIR(t,e,s){var n;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return o.showTemplateError(r.message||r.toString(),(null==(n=this.ir.m)?void 0:n.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g;return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,o=!1){const l=[],a=t;let h;a[n]||(a[n]={loops:null}),a[n].loops=s,a[i]||(a[i]=Object.create(null));let f,d=!1,y=!1;for(const r of e){const{k:e,f:c,d:m,v:v}=r;if(":class"===e){h=this.evalIR(c,[s],r.o),d=!0;continue}if(":style"===e){f=this.evalIR(c,[s],r.o),y=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),l=r.r??"user";let h=a[i][s];if(h||(h=a[i][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(c,[t,a[n].loops],r.o);h[l].push(t)}continue}if("mounted"===e){o||requestAnimationFrame(()=>this.evalIR(c,[t,s],r.o));continue}if("updated"===e){o&&requestAnimationFrame(()=>this.evalIR(c,[t,s],r.o));continue}if("ref"===e&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=t;continue}const S=m?this.evalIR(c,[s],r.o):v??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&u.has(s)?l.push(()=>b(t,s,S)):b(t,s,S)}else o||p(t,e,String(S))}return d&&((t,e)=>{const s=t,o=s[r],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);if(!o){for(const e in n)t.classList.add(e);return void(s[r]=n)}let i=!1;for(const r in o)n[r]||(t.classList.remove(r),i=!0);for(const r in n)o[r]||(t.classList.add(r),i=!0);i&&(s[r]=n)})(t,h),y&&((t,e)=>{const s=t,o=m(e),n=s[c];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[c]=o)}let i=!1;for(const r in n)r in o||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in o){const e=o[r];e!==n[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[c]=o)})(t,f),l}updateNode(t,e,s){const o=e.d?this.evalIR(e.f,[s],e.o):e.x||"";e.d&&t.textContent!==o&&(t.textContent=o)}createStaticSubtree(t,e,o){var n;switch(t.t){case s.ASTType.Element:{const s=this.createElement(t,e);f(s,t),d(s,t);const i=this.applyAttrs(s,t.a??[],o);return null==(n=t.c)||n.forEach(t=>{const e=this.createStaticSubtree(t,s,o);s.appendChild(e)}),i.forEach(t=>t()),s}case s.ASTType.Text:return this.createText(t,o);case s.ASTType.Comment:return this.createComment(t,o);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,o){const n=this.staticSubtreeCache.get(e);if(n){const t=n.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,o);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,o,n,i){var r,c,l,a;const h=o+"-"+e,u=this.nodeMap.get(h);let m;if(1!==t.s)if(u){m=u.node,u.marker=this.marker;let e=[];t.d&&(t.t===s.ASTType.Element?e=this.applyAttrs(m,t.a??[],i,!0):this.updateNode(m,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,h,m,i)}),e.forEach(t=>t())}else switch(t.t){case s.ASTType.Element:m=this.createElement(t,n),f(m,t),d(m,t);const e=this.applyAttrs(m,t.a??[],i);n.appendChild(m),this.nodeMap.set(h,{irNode:t,node:m,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,h,m,i)}),e.forEach(t=>t());break;case s.ASTType.Text:m=this.createText(t,i),n.appendChild(m),this.nodeMap.set(h,{irNode:t,node:m,loops:i,marker:this.marker});break;case s.ASTType.Comment:m=this.createComment(t,i),n.appendChild(m),this.nodeMap.set(h,{irNode:t,node:m,loops:i,marker:this.marker});break;case s.ASTType.For:{const e=`${h}-end`;let o=null==(l=this.nodeMap.get(e))?void 0:l.node;o?this.nodeMap.get(e).marker=this.marker:(o=document.createComment(`for:${h}`),n.appendChild(o),this.nodeMap.set(e,{irNode:{t:s.ASTType.Comment},node:o,loops:i,marker:this.marker}));const r=this.evalIR(t.f,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var o;const n=[...i,{itmVal:e,idxVal:s}];null==(o=t.c)||o.forEach((t,e)=>{this.irToNode(t,e,`${h}-for-${s}`,c,n)})}),o.parentNode.insertBefore(c,o);break}case s.ASTType.Conditional:{const e=`${h}-end`;let s=null==(a=this.nodeMap.get(e))?void 0:a.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${h}`),n.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let o=0;o<(t.b||[]).length;o++){const e=t.b[o];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${h}-if-${o}`,t,i)}),s.parentNode.insertBefore(t,s);break}}break}}else u?(u.marker=this.marker,m=u.node):(m=this.handleStaticSubtree(t,h,n,i),this.nodeMap.set(h,{irNode:t,node:m,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:o,loops:n}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f,[o,n],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==o||o.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}exports.IRRenderer=y,exports.createRender=(t,e,s={})=>{const o=new y(t,e,s);return o.mount(),{update:()=>o.update(),destroy:()=>o.destroy()}};
|
|
@@ -8,6 +8,8 @@ export declare class IRRenderer {
|
|
|
8
8
|
private scope;
|
|
9
9
|
private nodeMap;
|
|
10
10
|
private marker;
|
|
11
|
+
/** 静态子树缓存:key -> DOM节点模板 */
|
|
12
|
+
private staticSubtreeCache;
|
|
11
13
|
constructor(ir: IRRoot, container: HTMLElement, scope?: any);
|
|
12
14
|
evalIR(fid: number, args: any[], meta?: Meta): any;
|
|
13
15
|
private createElement;
|
|
@@ -15,6 +17,16 @@ export declare class IRRenderer {
|
|
|
15
17
|
private createComment;
|
|
16
18
|
private applyAttrs;
|
|
17
19
|
private updateNode;
|
|
20
|
+
/**
|
|
21
|
+
* 创建静态子树(首次渲染)
|
|
22
|
+
* 内部节点不进入 nodeMap,只返回根节点
|
|
23
|
+
*/
|
|
24
|
+
private createStaticSubtree;
|
|
25
|
+
/**
|
|
26
|
+
* 处理静态子树
|
|
27
|
+
* 首次渲染创建并缓存,后续直接克隆
|
|
28
|
+
*/
|
|
29
|
+
private handleStaticSubtree;
|
|
18
30
|
private irToNode;
|
|
19
31
|
private cleanupOldNodes;
|
|
20
32
|
mount(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=Object.defineProperty,
|
|
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";const n=Symbol("solely.irCtx"),i=Symbol("solely.irEvents"),r=Symbol("solely.prevClassObj"),c=Symbol("solely.prevStyleObj"),l={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"},a=new Set(["data-","aria-","role","form"]),f=new Set(["value","selectedIndex"]);function u(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 d(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?m(o.v):{};for(const i in n){const e=n[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}function m(t){const e={},s=[[t]];for(;s.length;){const[t,o]=s.pop();if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let o;for(;null!==(o=s.exec(t));){const t=o[1].trim(),s=o[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const n in t){const i=t[n];if(null==i)continue;const r=o?`${o}-${n}`:n;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function p(t,e,s){const o=null==s?"":String(s),n=e.indexOf(":");if(n>0){const s=e.slice(0,n),i=l[s];if(i)return void(t.getAttributeNS(i,e)!==o&&t.setAttributeNS(i,e,o))}t.getAttribute(e)!==o&&t.setAttribute(e,o)}function y(t,e,s){const o=h[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||a.has(e))return void p(t,e,s);const n=t,i=n.tagName;if(null!=s){if("src"===o||"href"===o){const e=String(s);if(n[o]===e||t.getAttribute(o)===e)return}if("value"!==o||"INPUT"!==i&&"TEXTAREA"!==i||n.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==n.ownerSVGElement)&&!h[e]?p(t,e,s):n[o]!==s&&(n[o]=s);else{if(n[o]===s)return;n[o]=s}}else if("boolean"==typeof n[o])!1!==n[o]&&(n[o]=!1);else{const s=n[o];""!==s&&void 0!==s&&(n[o]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class b{constructor(t,s,o={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=o}evalIR(t,e,s){var n;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return o(r.message||r.toString(),(null==(n=this.ir.m)?void 0:n.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g;return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,o=!1){const l=[],h=t;let a;h[n]||(h[n]={loops:null}),h[n].loops=s,h[i]||(h[i]=Object.create(null));let u,d=!1,b=!1;for(const r of e){const{k:e,f:c,d:m,v:v}=r;if(":class"===e){a=this.evalIR(c,[s],r.o),d=!0;continue}if(":style"===e){u=this.evalIR(c,[s],r.o),b=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),l=r.r??"user";let a=h[i][s];if(a||(a=h[i][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of a.model)e(t);for(const e of a.user)e(t)})),!o){const t=t=>this.evalIR(c,[t,h[n].loops],r.o);a[l].push(t)}continue}if("mounted"===e){o||requestAnimationFrame(()=>this.evalIR(c,[t,s],r.o));continue}if("updated"===e){o&&requestAnimationFrame(()=>this.evalIR(c,[t,s],r.o));continue}if("ref"===e&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=t;continue}const S=m?this.evalIR(c,[s],r.o):v??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&f.has(s)?l.push(()=>y(t,s,S)):y(t,s,S)}else o||p(t,e,String(S))}return d&&((t,e)=>{const s=t,o=s[r],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);if(!o){for(const e in n)t.classList.add(e);return void(s[r]=n)}let i=!1;for(const r in o)n[r]||(t.classList.remove(r),i=!0);for(const r in n)o[r]||(t.classList.add(r),i=!0);i&&(s[r]=n)})(t,a),b&&((t,e)=>{const s=t,o=m(e),n=s[c];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[c]=o)}let i=!1;for(const r in n)r in o||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in o){const e=o[r];e!==n[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[c]=o)})(t,u),l}updateNode(t,e,s){const o=e.d?this.evalIR(e.f,[s],e.o):e.x||"";e.d&&t.textContent!==o&&(t.textContent=o)}createStaticSubtree(t,e,o){var n;switch(t.t){case s.Element:{const s=this.createElement(t,e);u(s,t),d(s,t);const i=this.applyAttrs(s,t.a??[],o);return null==(n=t.c)||n.forEach(t=>{const e=this.createStaticSubtree(t,s,o);s.appendChild(e)}),i.forEach(t=>t()),s}case s.Text:return this.createText(t,o);case s.Comment:return this.createComment(t,o);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,o){const n=this.staticSubtreeCache.get(e);if(n){const t=n.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,o);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,o,n,i){var r,c,l,h;const a=o+"-"+e,f=this.nodeMap.get(a);let m;if(1!==t.s)if(f){m=f.node,f.marker=this.marker;let e=[];t.d&&(t.t===s.Element?e=this.applyAttrs(m,t.a??[],i,!0):this.updateNode(m,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,a,m,i)}),e.forEach(t=>t())}else switch(t.t){case s.Element:m=this.createElement(t,n),u(m,t),d(m,t);const e=this.applyAttrs(m,t.a??[],i);n.appendChild(m),this.nodeMap.set(a,{irNode:t,node:m,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,a,m,i)}),e.forEach(t=>t());break;case s.Text:m=this.createText(t,i),n.appendChild(m),this.nodeMap.set(a,{irNode:t,node:m,loops:i,marker:this.marker});break;case s.Comment:m=this.createComment(t,i),n.appendChild(m),this.nodeMap.set(a,{irNode:t,node:m,loops:i,marker:this.marker});break;case s.For:{const e=`${a}-end`;let o=null==(l=this.nodeMap.get(e))?void 0:l.node;o?this.nodeMap.get(e).marker=this.marker:(o=document.createComment(`for:${a}`),n.appendChild(o),this.nodeMap.set(e,{irNode:{t:s.Comment},node:o,loops:i,marker:this.marker}));const r=this.evalIR(t.f,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var o;const n=[...i,{itmVal:e,idxVal:s}];null==(o=t.c)||o.forEach((t,e)=>{this.irToNode(t,e,`${a}-for-${s}`,c,n)})}),o.parentNode.insertBefore(c,o);break}case s.Conditional:{const e=`${a}-end`;let s=null==(h=this.nodeMap.get(e))?void 0:h.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${a}`),n.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let o=0;o<(t.b||[]).length;o++){const e=t.b[o];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${a}-if-${o}`,t,i)}),s.parentNode.insertBefore(t,s);break}}break}}else f?(f.marker=this.marker,m=f.node):(m=this.handleStaticSubtree(t,a,n,i),this.nodeMap.set(a,{irNode:t,node:m,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:o,loops:n}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f,[o,n],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==o||o.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}const v=(t,e,s={})=>{const o=new b(t,e,s);return o.mount(),{update:()=>o.update(),destroy:()=>o.destroy()}};export{b as IRRenderer,v as createRender};
|
package/dist/types/ir.d.ts
CHANGED
|
@@ -49,6 +49,12 @@ export interface IRNode {
|
|
|
49
49
|
t: ASTType;
|
|
50
50
|
/** dynamicFlag (0=静态, 1=动态) 不包含子节点状态 */
|
|
51
51
|
d: 0 | 1;
|
|
52
|
+
/**
|
|
53
|
+
* staticSubtreeFlag (0=非静态子树, 1=完全静态子树)
|
|
54
|
+
* 当 s=1 时,表示该节点及其所有后代都是静态的
|
|
55
|
+
* 运行时可以直接 cloneNode 而无需递归创建
|
|
56
|
+
*/
|
|
57
|
+
s?: 0 | 1;
|
|
52
58
|
/** tagName 标签名(Element 使用) */
|
|
53
59
|
g?: string;
|
|
54
60
|
/** attributes 属性数组(Element 使用) */
|
|
@@ -88,6 +94,8 @@ export interface IRRoot {
|
|
|
88
94
|
dn: number;
|
|
89
95
|
/** 总节点数 */
|
|
90
96
|
tn: number;
|
|
97
|
+
/** 静态子树数量 */
|
|
98
|
+
sn?: number;
|
|
91
99
|
};
|
|
92
100
|
/** meta 编译元数据 */
|
|
93
101
|
m?: {
|
package/package.json
CHANGED
|
@@ -1,220 +1,233 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
"
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
"
|
|
180
|
-
"
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
"
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
"
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "solely",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"description": "A lightweight TypeScript framework for building web components with compile-time optimizations",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"./plugin": {
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./dist/plugin.d.ts",
|
|
25
|
+
"default": "./dist/plugin.js"
|
|
26
|
+
},
|
|
27
|
+
"require": {
|
|
28
|
+
"types": "./dist/plugin.d.ts",
|
|
29
|
+
"default": "./dist/plugin.cjs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"./compiler": {
|
|
33
|
+
"import": {
|
|
34
|
+
"types": "./dist/compiler/index.d.ts",
|
|
35
|
+
"default": "./dist/compiler/index.js"
|
|
36
|
+
},
|
|
37
|
+
"require": {
|
|
38
|
+
"types": "./dist/compiler/index.d.ts",
|
|
39
|
+
"default": "./dist/compiler/index.cjs"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"./compiler/*": {
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./dist/compiler/*.d.ts",
|
|
45
|
+
"default": "./dist/compiler/*.js"
|
|
46
|
+
},
|
|
47
|
+
"require": {
|
|
48
|
+
"types": "./dist/compiler/*.d.ts",
|
|
49
|
+
"default": "./dist/compiler/*.cjs"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"./runtime": {
|
|
53
|
+
"import": {
|
|
54
|
+
"types": "./dist/runtime/index.d.ts",
|
|
55
|
+
"default": "./dist/runtime/index.js"
|
|
56
|
+
},
|
|
57
|
+
"require": {
|
|
58
|
+
"types": "./dist/runtime/index.d.ts",
|
|
59
|
+
"default": "./dist/runtime/index.cjs"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"./runtime/*": {
|
|
63
|
+
"import": {
|
|
64
|
+
"types": "./dist/runtime/*.d.ts",
|
|
65
|
+
"default": "./dist/runtime/*.js"
|
|
66
|
+
},
|
|
67
|
+
"require": {
|
|
68
|
+
"types": "./dist/runtime/*.d.ts",
|
|
69
|
+
"default": "./dist/runtime/*.cjs"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"./router": {
|
|
73
|
+
"import": {
|
|
74
|
+
"types": "./dist/router/index.d.ts",
|
|
75
|
+
"default": "./dist/router/index.js"
|
|
76
|
+
},
|
|
77
|
+
"require": {
|
|
78
|
+
"types": "./dist/router/index.d.ts",
|
|
79
|
+
"default": "./dist/router/index.cjs"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"./router/*": {
|
|
83
|
+
"import": {
|
|
84
|
+
"types": "./dist/router/*.d.ts",
|
|
85
|
+
"default": "./dist/router/*.js"
|
|
86
|
+
},
|
|
87
|
+
"require": {
|
|
88
|
+
"types": "./dist/router/*.d.ts",
|
|
89
|
+
"default": "./dist/router/*.cjs"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"./shared": {
|
|
93
|
+
"import": {
|
|
94
|
+
"types": "./dist/shared/index.d.ts",
|
|
95
|
+
"default": "./dist/shared/index.js"
|
|
96
|
+
},
|
|
97
|
+
"require": {
|
|
98
|
+
"types": "./dist/shared/index.d.ts",
|
|
99
|
+
"default": "./dist/shared/index.cjs"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"./shared/*": {
|
|
103
|
+
"import": {
|
|
104
|
+
"types": "./dist/shared/*.d.ts",
|
|
105
|
+
"default": "./dist/shared/*.js"
|
|
106
|
+
},
|
|
107
|
+
"require": {
|
|
108
|
+
"types": "./dist/shared/*.d.ts",
|
|
109
|
+
"default": "./dist/shared/*.cjs"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"./types": {
|
|
113
|
+
"import": {
|
|
114
|
+
"types": "./dist/types/index.d.ts",
|
|
115
|
+
"default": "./dist/types/index.js"
|
|
116
|
+
},
|
|
117
|
+
"require": {
|
|
118
|
+
"types": "./dist/types/index.d.ts",
|
|
119
|
+
"default": "./dist/types/index.cjs"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"./types/*": {
|
|
123
|
+
"import": {
|
|
124
|
+
"types": "./dist/types/*.d.ts",
|
|
125
|
+
"default": "./dist/types/*.js"
|
|
126
|
+
},
|
|
127
|
+
"require": {
|
|
128
|
+
"types": "./dist/types/*.d.ts",
|
|
129
|
+
"default": "./dist/types/*.cjs"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"./package.json": "./package.json"
|
|
133
|
+
},
|
|
134
|
+
"typesVersions": {
|
|
135
|
+
"*": {
|
|
136
|
+
"*": [
|
|
137
|
+
"./dist/*"
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"files": [
|
|
142
|
+
"dist",
|
|
143
|
+
"README.md",
|
|
144
|
+
"LICENSE"
|
|
145
|
+
],
|
|
146
|
+
"keywords": [
|
|
147
|
+
"ast",
|
|
148
|
+
"vnode",
|
|
149
|
+
"template",
|
|
150
|
+
"custom-element",
|
|
151
|
+
"web-component",
|
|
152
|
+
"framework",
|
|
153
|
+
"library",
|
|
154
|
+
"ui",
|
|
155
|
+
"component",
|
|
156
|
+
"design",
|
|
157
|
+
"development",
|
|
158
|
+
"esm",
|
|
159
|
+
"tree-shaking"
|
|
160
|
+
],
|
|
161
|
+
"lint-staged": {
|
|
162
|
+
"*.{ts,tsx}": [
|
|
163
|
+
"eslint --fix",
|
|
164
|
+
"prettier --write"
|
|
165
|
+
],
|
|
166
|
+
"*.{json,md}": [
|
|
167
|
+
"prettier --write"
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
"author": "Sun Yue",
|
|
171
|
+
"license": "MIT",
|
|
172
|
+
"repository": {
|
|
173
|
+
"type": "git",
|
|
174
|
+
"url": "git+https://github.com/solelyjs/solely.git"
|
|
175
|
+
},
|
|
176
|
+
"bugs": {
|
|
177
|
+
"url": "https://github.com/solelyjs/solely/issues"
|
|
178
|
+
},
|
|
179
|
+
"homepage": "https://github.com/solelyjs/solely#readme",
|
|
180
|
+
"engines": {
|
|
181
|
+
"node": ">=16.0.0"
|
|
182
|
+
},
|
|
183
|
+
"scripts": {
|
|
184
|
+
"dev": "vite",
|
|
185
|
+
"build": "vite build",
|
|
186
|
+
"build:watch": "vite build --watch",
|
|
187
|
+
"build:examples": "vite build --mode examples",
|
|
188
|
+
"preview": "vite preview",
|
|
189
|
+
"preview:examples": "vite preview --outDir dist-examples",
|
|
190
|
+
"link": "npm link && echo '✅ 全局链接成功,可在其他项目中使用 npm link solely'",
|
|
191
|
+
"unlink": "npm unlink -g solely && echo '✅ 已取消全局链接'",
|
|
192
|
+
"test": "vitest",
|
|
193
|
+
"test:ui": "vitest --ui",
|
|
194
|
+
"test:coverage": "vitest --coverage",
|
|
195
|
+
"typecheck": "tsc --noEmit",
|
|
196
|
+
"lint": "eslint . --ext .ts,.tsx",
|
|
197
|
+
"lint:fix": "eslint . --ext .ts,.tsx --fix",
|
|
198
|
+
"format": "prettier --write \"src/**/*.{ts,tsx,js,json,md}\"",
|
|
199
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,json,md}\"",
|
|
200
|
+
"clean": "rimraf dist",
|
|
201
|
+
"prebuild": "npm run clean",
|
|
202
|
+
"prepublishOnly": "npm run build && npm run test",
|
|
203
|
+
"pack:local": "npm pack && echo '✅ 打包完成,可在其他项目中使用 file: 引用'",
|
|
204
|
+
"dev:debug": "node --inspect-brk ./node_modules/vite/bin/vite.js",
|
|
205
|
+
"prepare": "husky"
|
|
206
|
+
},
|
|
207
|
+
"devDependencies": {
|
|
208
|
+
"@rollup/plugin-strip": "^3.0.4",
|
|
209
|
+
"@testing-library/dom": "^10.4.1",
|
|
210
|
+
"@testing-library/user-event": "^14.6.1",
|
|
211
|
+
"@types/node": "^22.10.2",
|
|
212
|
+
"@commitlint/cli": "^19.0.0",
|
|
213
|
+
"@commitlint/config-conventional": "^19.0.0",
|
|
214
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
215
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
216
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
217
|
+
"@vitest/ui": "^3.2.4",
|
|
218
|
+
"eslint": "^8.57.0",
|
|
219
|
+
"husky": "^9.0.0",
|
|
220
|
+
"jsdom": "27.0.0",
|
|
221
|
+
"lint-staged": "^15.0.0",
|
|
222
|
+
"magic-string": "^0.30.21",
|
|
223
|
+
"prettier": "^3.0.0",
|
|
224
|
+
"rimraf": "^5.0.10",
|
|
225
|
+
"sass": "^1.83.0",
|
|
226
|
+
"terser": "^5.44.0",
|
|
227
|
+
"tsup": "^8.5.1",
|
|
228
|
+
"typescript": "~5.6.2",
|
|
229
|
+
"vite": "^5.4.10",
|
|
230
|
+
"vite-plugin-dts": "^4.4.0",
|
|
231
|
+
"vitest": "^3.2.4"
|
|
232
|
+
}
|
|
233
|
+
}
|