solely 0.0.23 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,3 @@
1
- (function(h,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(h=typeof globalThis<"u"?globalThis:h||self,f(h.solely={}))})(this,function(h){"use strict";var gt=h=>{throw TypeError(h)};var et=(h,f,p)=>f.has(h)||gt("Cannot "+p);var w=(h,f,p)=>(et(h,f,"read from private field"),p?p.call(h):f.get(h)),y=(h,f,p)=>f.has(h)?gt("Cannot add the same private member more than once"):f instanceof WeakSet?f.add(h):f.set(h,p),g=(h,f,p,O)=>(et(h,f,"write to private field"),O?O.call(h,p):f.set(h,p),p),D=(h,f,p)=>(et(h,f,"access private method"),p);var W,x,M,C,H,_,R,j;const f=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,p=/<\/?([^\s]+?)[/\s>]/,O=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],F=/\{\{(.+?)\}\}/g;function vt(n){return n.replace(/>\s+</g,"><").replace(/\s+/g," ")}function yt(n,t){const e=(t.match(p)||[])[1]||"",s={rootId:"0",tagName:e,attrs:{},props:{},on:{},children:[]},r=new RegExp(O);for(;;){const a=r.exec(t);if(a===null)break;if(!a[0].trim())continue;const[o,c]=a[1]?a[1].trim().split("="):[a[2],a[3].trim().slice(1,-1)];if(q.includes(o)||o.startsWith("on-"))s.on[o.startsWith("on-")?o.slice(3):o.slice(2)]=st(n,c);else if(o.startsWith("s-")){const l=o.slice(2);switch(l){case"model":s.model=c;break;case"style":s.styles=i=>E(n,c,i);break;case"class":s.classes=i=>E(n,c,i);break;case"readonly":s.props.readOnly=i=>E(n,c,i);break;default:s.props[l]=i=>E(n,c,i);break}}else s.attrs[o]=c;r.lastIndex--}if(e==="For"?s.fn=a=>E(n,s.attrs.each,a):(e==="If"||e==="ElseIf")&&(s.fn=a=>E(n,s.attrs.condition,a)),s.model){const a=s.model.replace("this.","").replace("$data.",""),o=l=>E(n,`$data.${a}`,l),c=l=>st(n,`$data.${a}=${l}`);e==="input"?s.attrs.type==="checkbox"||s.attrs.type==="radio"?(s.props.checked=o,s.on.change=c("checked")):(s.props.value=o,s.on.input=c("value")):e==="textarea"?(s.props.value=o,s.on.input=c("value")):e==="select"&&(s.props.value=o,s.on.change=c("value"))}return s}function nt(n,t){const e=[];if(!t)return e;t=vt(t);const s=[],r=[],a=()=>{var c;return s.length===0?e:(c=s[s.length-1]).children||(c.children=[])};let o=0;return t.replace(f,(c,l)=>{const i=a();if(l>o){const u=t.substring(o,l).trim();if(u){F.lastIndex=0;const J=!F.test(u)?u:L=>u.replace(F,(Y,tt)=>E(n,tt,L));i.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:J,children:[]})}}if(o=l+c.length,c.startsWith("<!--")&&c.endsWith("-->"))i.push({rootId:"0",tagName:"comment",attrs:{},props:{},on:{},content:c.slice(4,-3),children:[]});else if(c.startsWith("</")){const u=r.pop();for(;s.length>0&&s[s.length-1].tagName!==u;)s.pop();s.pop()}else{const u=yt(n,c),m=c.endsWith("/>")||Et.includes(u.tagName);i.push(u),m||(s.push(u),r.push(u.tagName))}return""}),t.length>o&&e.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:t.substring(o).trim(),children:[]}),e}const E=(n,t,e)=>{try{return B(["$data",...e.map(r=>r.item),...e.map(r=>r.index),`return (${t})`]).bind(n)(n.$data,...e.map(r=>r.value),...e.map(r=>r.valueIndex))}catch(s){console.error(s)}},st=(n,t)=>(e,s)=>B(["$data","event","value","checked",...s.map(a=>a.item),...s.map(a=>a.index),t]).bind(n)(n.$data,e,e.target.value,e.target.checked,...s.map(a=>a.value),...s.map(a=>a.valueIndex)),q=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],rt=(()=>{const n=typeof requestAnimationFrame=="function"?t=>requestAnimationFrame(t):typeof Promise<"u"?t=>Promise.resolve().then(t):t=>setTimeout(t,0);return(t,...e)=>{if(typeof t!="function")throw new Error("runInAsyncQueue expects a function as its first argument");n(()=>t(...e))}})(),U={};function B(n){const t=n.map(e=>e.replace(/[',"]/g,"")).join(",");if(!U[t]){const e=n[n.length-1];if(e.trim()==="")throw new Error("Function body cannot be empty");if(wt(e))throw new Error("Input contains potentially dangerous code: "+e);U[t]=new Function(...n)}return U[t]}const bt=["eval","Function","process","require"];function wt(n){return bt.some(t=>new RegExp(`\\b${t}\\b`,"g").test(n))}const $t="http://www.w3.org/1999/xlink",kt="http://www.w3.org/2000/xmlns/",Ct="http://www.w3.org/XML/1998/namespace",_t="http://www.w3.org/2000/svg",at=n=>typeof n.content=="function"?n.content(n.loops||[]):n.content||"",Rt=n=>{const t=at(n),e=n.elm;e.textContent!==t&&(e.textContent=t)},ot=(n,t,e=[])=>{Object.keys(t).forEach(s=>{const r=t[s](e);n[s]!==r&&(n[s]=r)})},it=(n,t)=>{const{styles:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=N(r);Object.entries(a).forEach(([o,c])=>{n.style[o]=c})},ct=(n,t)=>{const{classes:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=lt(r);Object.entries(a).forEach(([o,c])=>{c?n.classList.add(o):n.classList.remove(o)})},N=n=>{let t={};return typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=N(s);Object.entries(r).forEach(([a,o])=>{t[`${e}-${a}`]=o})}else typeof s=="string"||typeof s=="number"?t[e]=`${s}`:t[e]=String(s)}):typeof n=="string"?n.split(";").forEach(e=>{const[s,r]=e.split(":").map(a=>a.trim());s&&r&&(t[s]=r)}):Array.isArray(n)&&n.forEach(e=>{const s=N(e);Object.entries(s).forEach(([r,a])=>{t[r]=a})}),t},lt=n=>{let t={};return typeof n=="object"&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{t[e]=!!s}):typeof n=="string"?n.split(" ").forEach(e=>{e!==""&&(t[e]=!0)}):Array.isArray(n)&&n.forEach(e=>{const s=lt(e);Object.entries(s).forEach(([r,a])=>{t[r]=a})}),t},ht=(n,t,e)=>{const s=r=>e.on[t](r,e.loops||[]);n.addEventListener(t,s,!1),e.handlers=e.handlers||{},e.handlers[t]=s},At=(n,t)=>{const e=t.elm;Object.keys(t.on).forEach(s=>{n.handlers&&n.handlers[s]&&e.removeEventListener(s,n.handlers[s],!1),ht(e,s,t)}),ot(e,t.props,t.loops),ct(e,t),it(e,t),ut(e,n.children,t.children)},St=(n,t)=>{switch(t.elm=n.elm,t.tagName){case"comment":break;case"text":Rt(t);break;case"slot":break;default:At(n,t);break}},z=(n,t,e)=>{e?n.insertBefore(t,e):n.appendChild(t)},It=(n,t,e)=>{const s=at(t),r=document.createTextNode(s);t.elm=r,z(n,r,e)},Wt=(n,t,e)=>{const s=t.content,r=document.createComment(s);t.elm=r,z(n,r,e)},xt=(n,t,e,s)=>{t.tagName==="svg"&&(s=_t);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(a=>{const o=t.attrs[a]||"";a.charAt(0)!=="x"?r.setAttribute(a,o):a.startsWith("xml:")?r.setAttributeNS(Ct,a,o):a.startsWith("xlink:")?r.setAttributeNS($t,a,o):a.startsWith("xmlns:")?r.setAttributeNS(kt,a,o):r.setAttribute(a,o)}),Object.keys(t.on).forEach(a=>{ht(r,a,t)}),ot(r,t.props,t.loops),ct(r,t),it(r,t),t.elm=r,z(n,r,e),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(a=>{Q(r,a,void 0,s)})},Q=(n,t,e,s)=>{switch(t.tagName){case"comment":Wt(n,t,e);break;case"text":It(n,t,e);break;default:xt(n,t,e,s);break}},Mt=n=>n&&(n.tagName==="ElseIf"||n.tagName==="comment"),Ht=n=>n&&n.tagName==="Else",$=(n,t,e=[],s="0",r)=>{var a,o,c;for(let l=0;l<t.length;l++){const i=t[l];if(i.tagName==="If"){let u=!1,m=1;for(((a=i.fn)==null?void 0:a.call(i,e))&&($(n,i.children,e,`${s}-if-${m}`,m),u=!0),m++;l+1<t.length&&Mt(t[l+1]);)((c=(o=t[l+1]).fn)==null?void 0:c.call(o,e))&&!u&&($(n,t[l+1].children,e,`${s}-if-${m}`,m),u=!0),l++,m++;l+1<t.length&&Ht(t[l+1])&&(u||($(n,t[l+1].children,e,`${s}-if-${m}`,m),u=!0),l++)}else if(i.tagName==="For"){const{item:u="item",index:m="index"}=i.attrs;(i.fn(e)||[]).forEach((L,Y)=>{const tt={item:u,value:L,index:m,valueIndex:Y};$(n,i.children,[...e,tt],`${s}-for-${Y}`,1)})}else{const u={...i,loops:e,children:[],rootId:s,ifId:r,key:i.key||`${s}-${l}`};$(u.children,i.children,e,`${s}-${l}`),n.push(u)}}},ut=(n,t,e)=>{var o,c,l;const s=new Map;t.forEach((i,u)=>s.set(i.key,{node:i,index:u}));let r=0,a=0;for(;r<e.length;){const i=e[r],u=s.get(i.key);if(u){const m=u.node;i.ifId&&m.ifId!==i.ifId?((o=m.elm)==null||o.remove(),Q(n,i,(c=t[a+1])==null?void 0:c.elm)):St(m,i),s.delete(i.key),a++}else{const m=(l=t[a])==null?void 0:l.elm;Q(n,i,m)}r++}s.forEach(({node:i})=>{var u;return(u=i.elm)==null?void 0:u.remove()})},T=(n,t,e=[])=>{if(!t||t.length===0)return[];const s=[];return $(s,t||[],[],"0"),ut(n,e,s),s},G=n=>typeof n=="object"&&n!=null;function ft(n=window.location){let t;typeof n=="string"?t=new URL(n).hash:t=n.hash;const e=t.split("?"),s=e[0].substring(2),r=e[1],a={};return r&&r.split("&").forEach(o=>{const[c,l]=o.split("=");c&&l&&(a[decodeURIComponent(c)]=decodeURIComponent(l))}),{path:s.split("/"),query:a}}const K=(n,t)=>new Proxy(n,{get:(e,s)=>{let r=e[s];return G(r)&&(r=K(r,t)),r},set:(e,s,r)=>(e[s]!==r&&(e[s]=r,t(s,r)),!0)});class Ot extends HTMLElement{constructor(){super();y(this,R);y(this,W,{});y(this,x,[]);y(this,M,[]);y(this,C,!1);y(this,H,!1);y(this,_);const e=this._manifest||{};e.template&&typeof e.template=="string"&&g(this,x,nt(this,e.template)),e.shadowDOM&&e.shadowDOM.use?g(this,_,this.attachShadow({mode:e.shadowDOM.mode||"open"})):g(this,_,this)}get $data(){let e=w(this,W);return G(e)&&(e=K(e,()=>D(this,R,j).call(this))),e}set $data(e){g(this,W,e||{}),D(this,R,j).call(this)}connectedCallback(){const e=this._manifest||{};(e.className||e.tagName||"").split(" ").forEach(r=>{r&&this.classList.add(r)}),D(this,R,j).call(this)}onInit(){}disconnectedCallback(){}}W=new WeakMap,x=new WeakMap,M=new WeakMap,C=new WeakMap,H=new WeakMap,_=new WeakMap,R=new WeakSet,j=function(){w(this,C)||(g(this,C,!0),rt(()=>{g(this,M,T(w(this,_),w(this,x),w(this,M))),g(this,C,!1),this.isConnected&&!w(this,H)&&(g(this,H,!0),this.onInit())}))};const mt=n=>t=>{if(customElements.get(n.tagName)){console.warn(`标签名称 "${n.tagName}" 已经被注册`);return}return t.prototype._manifest=Tt(n),customElements.define(n.tagName,t),t},Tt=n=>(n=Object.assign({hasConfig:!1},n),n);var Pt=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,pt=n=>{throw TypeError(n)},Lt=(n,t,e,s)=>{for(var r=s>1?void 0:s?Vt(t,e):t,a=n.length-1,o;a>=0;a--)(o=n[a])&&(r=(s?o(t,e,r):o(r))||r);return s&&r&&Pt(t,e,r),r},X=(n,t,e)=>t.has(n)||pt("Cannot "+e),v=(n,t,e)=>(X(n,t,"read from private field"),e?e.call(n):t.get(n)),b=(n,t,e)=>t.has(n)?pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),d=(n,t,e,s)=>(X(n,t,"write to private field"),t.set(n,e),e),Dt=(n,t,e)=>(X(n,t,"access private method"),e),A,P,S,I,k,V,Z,dt;h.RouterViewElement=class extends HTMLElement{constructor(){super(...arguments),b(this,Z),b(this,A,[]),b(this,P,[]),b(this,S,null),b(this,I),b(this,k,[]),b(this,V,{})}get isRouterView(){return!0}get $routes(){return v(this,k)}set $routes(t){d(this,k,t),this.onHashChange()}get $remainingPath(){return v(this,P)}get $matchedRoute(){return v(this,S)}set $pipe(t){d(this,V,t||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",this.onHashChange.bind(this)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",this.onHashChange.bind(this))}onHashChange(){var s;if(!this.isConnected)return;const{path:t}=ft(window.location),e=this.findAncestorWithRouterView(this);e?(d(this,I,e.$remainingPath),d(this,k,((s=e.$matchedRoute)==null?void 0:s.children)||[])):d(this,I,t),Dt(this,Z,dt).call(this)}matchRoute(t,e){for(const s of t){const r=s.path.split("/");let a=!0;const o={};for(let c=0;c<r.length;c++){const l=r[c];if(l.startsWith(":"))o[l.substring(1)]=e[c];else if(l==="*"){a=!0;break}else if(l!==e[c]){a=!1;break}}if(a)return{matchedRoute:s,params:o,remainingPath:e.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:e}}propagateRoutes(t){for(const e of t.childNodes)e.isRouterView?e.onHashChange():this.propagateRoutes(e)}findAncestorWithRouterView(t){let e=t.parentNode;for(;e;){if(e.isRouterView)return e;e=e.parentElement}return null}},A=new WeakMap,P=new WeakMap,S=new WeakMap,I=new WeakMap,k=new WeakMap,V=new WeakMap,Z=new WeakSet,dt=function(){var l;const n=v(this,I)||[],{matchedRoute:t,params:e,remainingPath:s}=this.matchRoute(v(this,k),n);d(this,P,s);const r=(t==null?void 0:t.tagName)||"comment",a={},o={};for(const[i,u]of Object.entries(e))a[i]=()=>u;for(const[i,u]of Object.entries(v(this,V)))q.includes(i)||i.startsWith("on-")?o[i.startsWith("on-")?i.slice(3):i.slice(2)]=u:a[i]=()=>u;const c=[{tagName:r,rootId:"0",attrs:{},props:a,on:o,children:[]}];((l=v(this,S))==null?void 0:l.tagName)!==r?(this.innerHTML="",d(this,A,T(this,c,[]))):d(this,A,T(this,c,v(this,A))),d(this,S,t||{tagName:"comment",path:"",children:[]}),this.propagateRoutes(this)},h.RouterViewElement=Lt([mt({tagName:"router-view"})],h.RouterViewElement),h.BaseElement=Ot,h.CustomElement=mt,h.createFunction=B,h.isObject=G,h.listeners=q,h.observe=K,h.parseHashUrl=ft,h.parseHtml=nt,h.patch=T,h.runInAsyncQueue=rt,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
1
+ (function(p,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(p=typeof globalThis<"u"?globalThis:p||self,v(p.solely={}))})(this,function(p){"use strict";var It=p=>{throw TypeError(p)};var yt=(p,v,C)=>v.has(p)||It("Cannot "+C);var P=(p,v,C)=>(yt(p,v,"read from private field"),C?C.call(p):v.get(p)),O=(p,v,C)=>v.has(p)?It("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(p):v.set(p,C),w=(p,v,C,X)=>(yt(p,v,"write to private field"),X?X.call(p,C):v.set(p,C),C),D=(p,v,C)=>(yt(p,v,"access private method"),C);var z,Q,J,U,N,V,W,S,G,Et;const v=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,C=/<\/?([^\s]+?)[/\s>]/,X=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Ot=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],it=/\{\{(.+?)\}\}/g;function jt(n){return n.replace(/>\s+</g,"><").replace(/\s+/g," ")}function Tt(n,t){const e=(t.match(C)||[])[1]||"",s={rootId:"0",tagName:e,attrs:{},props:{},on:{},children:[]},r=new RegExp(X);for(;;){const o=r.exec(t);if(o===null)break;if(!o[0].trim())continue;const[a,i]=o[1]?o[1].trim().split("="):[o[2],o[3].trim().slice(1,-1)];if(a==="onMounted"||a==="onUpdated")s[a]=Ht(n,i);else if(ct.includes(a)||a.startsWith("on-"))s.on[a.startsWith("on-")?a.slice(3):a.slice(2)]=F(n,i);else if(a.startsWith("s-")){const l=a.slice(2);switch(l){case"model":s.model=i;break;case"style":s.styles=m=>j(n,i,m);break;case"class":s.classes=m=>j(n,i,m);break;case"readonly":s.props.readOnly=m=>j(n,i,m);break;default:s.props[l]=m=>j(n,i,m);break}}else s.attrs[a]=i;r.lastIndex--}if(e==="For"?s.fn=o=>j(n,s.attrs.each,o):(e==="If"||e==="ElseIf")&&(s.fn=o=>j(n,s.attrs.condition,o)),s.model){const o=s.model.replace("this.","").replace("$data.",""),a=l=>j(n,`$data.${o}`,l),i=(l,m)=>{if(s.on[l]){const u=s.on[l];s.on[l]=(c,h)=>{m(c,h),u(c,h)}}else s.on[l]=m};if(e==="input"){const l=s.attrs.type||"text";if(l==="checkbox")s.props.checked=a,i("change",F(n,`$data.${o}=checked`));else if(l==="radio"){const m=s.attrs.value;s.props.checked=u=>a(u)==m,i("change",F(n,`if(checked){$data.${o}='${m}'}`))}else s.props.value=a,i("input",F(n,`$data.${o}=value`))}else if(e==="textarea")s.props.value=a,i("input",F(n,`$data.${o}=value`));else if(e==="select"){const l="multiple"in s.attrs;l?i("change",F(n,`
2
+ $data.${o} = Array.from(event.target.selectedOptions).map(o => o.value);
3
+ `)):(i("change",F(n,`$data.${o}=value`)),s.props.value=a);const m=(h,d=[])=>{const k=a(d);if(l){const R=Array.isArray(k)?k:k!=null?[k]:[];for(const I of h.options)I.selected=R.includes(I.value)}else{const R=k??"";h.value!==R&&(h.value=R)}},u=s.onMounted,c=s.onUpdated;s.onMounted=(h,d)=>{u==null||u(h,d),m(h,d||[])},s.onUpdated=(h,d)=>{c==null||c(h,d),m(h,d||[])}}}return s}function bt(n,t){const e=[];if(!t)return e;t=jt(t);const s=[],r=[],o=()=>{var i;return s.length===0?e:(i=s[s.length-1]).children||(i.children=[])};let a=0;return t.replace(v,(i,l)=>{const m=o();if(l>a){const u=t.substring(a,l).trim();if(u){it.lastIndex=0;const h=!it.test(u)?u:d=>u.replace(it,(k,R)=>j(n,R,d));m.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:h,children:[]})}}if(a=l+i.length,i.startsWith("<!--")&&i.endsWith("-->"))m.push({rootId:"0",tagName:"comment",attrs:{},props:{},on:{},content:i.slice(4,-3),children:[]});else if(i.startsWith("</")){const u=r.pop();for(;s.length>0&&s[s.length-1].tagName!==u;)s.pop();s.pop()}else{const u=Tt(n,i),c=i.endsWith("/>")||Ot.includes(u.tagName);m.push(u),c||(s.push(u),r.push(u.tagName))}return""}),t.length>a&&e.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:t.substring(a).trim(),children:[]}),e}const j=(n,t,e)=>{try{return Z(["$data",...e.map(r=>r.item),...e.map(r=>r.index),`return (${t})`]).bind(n)(n.$data,...e.map(r=>r.value),...e.map(r=>r.valueIndex))}catch(s){return console.error(`[BaseElement][${n.tagName}] Error evaluating expression: {{ ${t} }}`,n,s),""}},F=(n,t)=>(e,s)=>{var r,o;try{return Z(["$data","event","value","checked",...s.map(i=>i.item),...s.map(i=>i.index),t]).bind(n)(n.$data,e,(r=e==null?void 0:e.target)==null?void 0:r.value,(o=e==null?void 0:e.target)==null?void 0:o.checked,...s.map(i=>i.value),...s.map(i=>i.valueIndex))}catch(a){console.error(`[BaseElement][${n.tagName}] Error executing event handler "${t}"`,n,a)}},Ht=(n,t)=>(e,s=[])=>{try{Z(["$data","elm",...s.map(o=>o.item),...s.map(o=>o.index),`(function(){ ${t} }).call(this)`]).bind(n)(n.$data,e,...s.map(o=>o.value),...s.map(o=>o.valueIndex))}catch(r){console.error(`[BaseElement][${n.tagName}] Error executing lifecycle handler "${t}"`,n,r)}},ct=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],Lt=typeof requestAnimationFrame=="function"?n=>requestAnimationFrame(n):typeof Promise<"u"?n=>Promise.resolve().then(n):n=>setTimeout(n,0),vt=(n,...t)=>{if(typeof n!="function")throw new Error("runInAsyncQueue expects a function as its first argument");Lt(()=>n(...t))},lt={};function Z(n){const t=n.map(e=>e.replace(/[',"]/g,"")).join(",");if(!lt[t]){const e=n[n.length-1];if(e.trim()==="")throw new Error("Function body cannot be empty");if(Ft(e))throw new Error("Input contains potentially dangerous code: "+e);lt[t]=new Function(...n)}return lt[t]}const Dt=["eval","Function","process","require"];function Ft(n){return Dt.some(t=>new RegExp(`\\b${t}\\b`,"g").test(n))}const Ut="http://www.w3.org/1999/xlink",Vt="http://www.w3.org/2000/xmlns/",qt="http://www.w3.org/XML/1998/namespace",Bt="http://www.w3.org/2000/svg",$t=n=>typeof n.content=="function"?n.content(n.loops||[]):n.content||"",zt=n=>{const t=$t(n),e=n.elm;e.textContent!==t&&(e.textContent=t)},kt=(n,t,e=[])=>{Object.keys(t).forEach(s=>{const r=t[s](e);n[s]!==r&&(n[s]=r)})},At=(n,t)=>{const{styles:e,loops:s=[]}=t;if(!e)return;const r=e(s),o=ut(r);Object.entries(o).forEach(([a,i])=>{n.style[a]=i})},Ct=(n,t)=>{const{classes:e,loops:s=[]}=t;if(!e)return;const r=e(s),o=wt(r);Object.entries(o).forEach(([a,i])=>{i?n.classList.add(a):n.classList.remove(a)})},ut=n=>{let t={};return typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=ut(s);Object.entries(r).forEach(([o,a])=>{t[`${e}-${o}`]=a})}else typeof s=="string"||typeof s=="number"?t[e]=`${s}`:t[e]=String(s)}):typeof n=="string"?n.split(";").forEach(e=>{const[s,r]=e.split(":").map(o=>o.trim());s&&r&&(t[s]=r)}):Array.isArray(n)&&n.forEach(e=>{const s=ut(e);Object.entries(s).forEach(([r,o])=>{t[r]=o})}),t},wt=n=>{let t={};return typeof n=="object"&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{t[e]=!!s}):typeof n=="string"?n.split(" ").forEach(e=>{e!==""&&(t[e]=!0)}):Array.isArray(n)&&n.forEach(e=>{const s=wt(e);Object.entries(s).forEach(([r,o])=>{t[r]=o})}),t},Rt=(n,t,e)=>{const s=r=>e.on[t](r,e.loops||[]);n.addEventListener(t,s,!1),e.handlers=e.handlers||{},e.handlers[t]=s},Gt=(n,t)=>{const e=t.elm;Object.keys(t.on).forEach(s=>{n.handlers&&n.handlers[s]&&e.removeEventListener(s,n.handlers[s],!1),Rt(e,s,t)}),kt(e,t.props,t.loops),Ct(e,t),At(e,t),typeof t.onUpdated=="function"&&requestAnimationFrame(()=>{t.onUpdated(e,t.loops||[])}),Mt(e,n.children,t.children)},Kt=(n,t)=>{switch(t.elm=n.elm,t.tagName){case"comment":break;case"text":zt(t);break;case"slot":break;default:Gt(n,t);break}},ht=(n,t,e)=>{e&&e.parentNode===n?n.insertBefore(t,e):n.appendChild(t)},Qt=(n,t,e)=>{const s=$t(t),r=document.createTextNode(s);t.elm=r,ht(n,r,e)},Jt=(n,t,e)=>{const s=t.content,r=document.createComment(s);t.elm=r,ht(n,r,e)},Nt=(n,t,e,s)=>{t.tagName==="svg"&&(s=Bt);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(o=>{const a=t.attrs[o]||"";o.charAt(0)!=="x"?r.setAttribute(o,a):o.startsWith("xml:")?r.setAttributeNS(qt,o,a):o.startsWith("xlink:")?r.setAttributeNS(Ut,o,a):o.startsWith("xmlns:")?r.setAttributeNS(Vt,o,a):r.setAttribute(o,a)}),Object.keys(t.on).forEach(o=>{Rt(r,o,t)}),kt(r,t.props,t.loops),Ct(r,t),At(r,t),t.elm=r,ht(n,r,e),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(o=>{Y(r,o,void 0,s)}),typeof t.onMounted=="function"&&requestAnimationFrame(()=>{t.onMounted(r,t.loops||[])})},Y=(n,t,e,s)=>{switch(t.tagName){case"comment":Jt(n,t,e);break;case"text":Qt(n,t,e);break;default:Nt(n,t,e,s);break}},Xt=n=>n&&(n.tagName==="ElseIf"||n.tagName==="comment"),Zt=n=>n&&n.tagName==="Else",q=(n,t,e=[],s="0",r)=>{var i,l,m;let o=0,a=0;for(let u=0;u<t.length;u++){const c=t[u];if(c.tagName==="If"){let h=!1;o++;let d=1;for(((i=c.fn)==null?void 0:i.call(c,e))&&(q(n,c.children,e,`${s}-if-${o}-${d}`,d),h=!0),d++;u+1<t.length&&Xt(t[u+1]);)((m=(l=t[u+1]).fn)==null?void 0:m.call(l,e))&&!h&&(q(n,t[u+1].children,e,`${s}-if-${o}-${d}`,d),h=!0),u++,d++;u+1<t.length&&Zt(t[u+1])&&(h||(q(n,t[u+1].children,e,`${s}-if-${o}-${d}`,d),h=!0),u++)}else if(c.tagName==="For"){a++;const{item:h="item",index:d="index"}=c.attrs;(c.fn(e)||[]).forEach((R,I)=>{const ot={item:h,value:R,index:d,valueIndex:I};q(n,c.children,[...e,ot],`${s}-for-${a}-${I}`,1)})}else{const h={...c,loops:e,children:[],rootId:s,ifId:r,key:c.key||`${s}-${u}`};q(h.children,c.children,e,`${s}-${u}`),n.push(h)}}},Mt=(n,t,e)=>{var a,i,l,m,u;const s=new Map;t.forEach((c,h)=>s.set(c.key,{node:c,index:h}));let r=0,o=0;for(;r<e.length;){const c=e[r],h=s.get(c.key);if(h){const d=h.node;if(d.tagName!==c.tagName){(a=d.elm)==null||a.remove();const k=(i=t[o+1])==null?void 0:i.elm;Y(n,c,k),s.delete(c.key),o++}else{if(c.ifId&&d.ifId!==c.ifId){(l=d.elm)==null||l.remove();const k=(m=t[o+1])==null?void 0:m.elm;Y(n,c,k)}else Kt(d,c);s.delete(c.key),o++}}else{const d=(u=t[o])==null?void 0:u.elm;Y(n,c,d)}r++}s.forEach(({node:c})=>{var h;return(h=c.elm)==null?void 0:h.remove()})},ft=(n,t,e=[])=>{if(!t||t.length===0)return[];const s=[];return q(s,t||[],[],"0"),Mt(n,e,s),s},_=n=>{if(n===null||typeof n!="object")return!1;const t=Object.prototype.toString.call(n);return!["[object Function]","[object Date]","[object RegExp]","[object Map]","[object Set]","[object WeakMap]","[object WeakSet]"].includes(t)};function Pt(n=window.location){let t;typeof n=="string"?t=new URL(n).hash:t=n.hash;const e=t.split("?"),s=e[0].substring(2),r=e[1],o={};return r&&r.split("&").forEach(a=>{const[i,l]=a.split("=");i&&l&&(o[decodeURIComponent(i)]=decodeURIComponent(l))}),{path:s.split("/"),query:o}}function pt(n,t,e={}){const s=new WeakMap,r=new WeakSet,o=new WeakMap,{throttle:a=0,deepCompare:i=!1,onBatch:l=null,immediate:m=!1}=e,u=Array.isArray(e.filter)?e.filter:e.filter?[e.filter]:[];let c=[],h=null,d=!0;const k=(f,g,$=new WeakMap)=>{if(f===g)return!0;if(f==null||g==null||typeof f!="object"||typeof g!="object")return f===g;if($.has(f))return $.get(f)===g;if($.set(f,g),Array.isArray(f)&&Array.isArray(g)){if(f.length!==g.length)return!1;for(let y=0;y<f.length;y++)if(!k(f[y],g[y],$))return!1;return!0}if(Array.isArray(f)!==Array.isArray(g))return!1;const A=Object.keys(f),E=Object.keys(g);if(A.length!==E.length)return!1;for(const y of A)if(!Object.prototype.hasOwnProperty.call(g,y)||!k(f[y],g[y],$))return!1;return!0},R=f=>{if(u.length===0)return!0;const g=f.map(String).join(".");return u.some($=>{if(!$)return!0;try{return new RegExp("^"+$.replace(/\./g,"\\.").replace(/\[\*\]/g,"(\\.\\d+)?").replace(/\*\*/g,"(.+)").replace(/\*/g,"[^.]+")+"$").test(g)}catch{return!0}})},I=(f,g,$)=>{d&&R(f)&&(a>0?(c.push({path:f,newValue:g,oldValue:$}),h||(h=setTimeout(()=>{if(!d){h=null;return}const A=c;c=[],h=null,l&&l(A);for(const E of A)t(E.path,E.newValue,E.oldValue)},a))):(t(f,g,$),l&&l([{path:f,newValue:g,oldValue:$}])))},ot=(f,g)=>{if(!_(f)||!(Array.isArray(f)||Object.prototype.toString.call(f)==="[object Object]"))return f;const $={};if(["push","pop","shift","unshift","splice","sort","reverse"].forEach(E=>{const y=Array.prototype[E];$[E]=function(...b){if(!d)return Reflect.apply(y,f,b);const M=[...f],L=y.apply(f,b);return k(f,M)||I(g,f,M),L}}),s.has(f)){const E=s.get(f);return o.set(E,g),E}r.add(f);const A=new Proxy(f,{get(E,y,b){if(Array.isArray(E)&&$.hasOwnProperty(y))return Reflect.get($,y,b);const M=Reflect.get(E,y,b);if(_(M)){const at=[...o.get(A)||[],y],gt=ot(M,at);return o.set(gt,at),gt}return M},set(E,y,b,M){const L=Reflect.get(E,y,M),at=_(b)&&!(b instanceof Date||b instanceof RegExp||b instanceof Map||b instanceof Set);if(i&&at?k(L,b):L===b)return!0;const oe=Reflect.set(E,y,b,M),ae=o.get(A)||g;return I([...ae,y],b,L),oe},deleteProperty(E,y){if(Reflect.has(E,y)){const b=E[y],M=Reflect.deleteProperty(E,y),L=o.get(A)||[];return M&&r.has(E)&&I([...L,y],void 0,b),M}return!1}});return s.set(f,A),o.set(A,g),A},re=ot(n,[]);if(m){const f=(g,$,A=new WeakSet)=>{if(!(!_(g)||!d||A.has(g))){A.add(g);for(const E of Object.keys(g)){const y=[...$,E],b=g[E];R(y)&&t(y,b,void 0),_(b)&&f(b,y,A)}}};f(n,[])}return{proxy:re,unobserve:()=>{d&&(d=!1,c=[],h&&(clearTimeout(h),h=null))},resume:()=>{d=!0}}}class Yt extends HTMLElement{constructor(e={}){var a;super();O(this,S);O(this,z);O(this,Q,[]);O(this,J,[]);O(this,U,!1);O(this,N,!1);O(this,V);O(this,W);const s=this._manifest||{};w(this,V,(a=s.shadowDOM)!=null&&a.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this);const{proxy:r,unobserve:o}=pt(e,()=>D(this,S,G).call(this));w(this,z,r),w(this,W,o),s.template&&typeof s.template=="string"&&w(this,Q,bt(this,s.template)),Promise.resolve().then(()=>this.created())}static get observedAttributes(){const e=this._manifest||this.prototype._manifest;return e!=null&&e.props?e.props.map(s=>typeof s=="string"?s:s.name):[]}get $data(){return P(this,z)}set $data(e){_(e)||(e={}),P(this,W)&&P(this,W).call(this);const{proxy:s,unobserve:r}=pt(e,()=>D(this,S,G).call(this));w(this,z,s),w(this,W,r),D(this,S,G).call(this)}refresh(){D(this,S,G).call(this)}connectedCallback(){const e=this._manifest||{};if((e.className||e.tagName||"").split(" ").forEach(r=>r&&this.classList.add(r)),e.styles&&!P(this,V).querySelector("style[data-manifest-style]")){const r=document.createElement("style");r.setAttribute("data-manifest-style","true"),r.textContent=e.styles,P(this,V).appendChild(r)}if(e.props&&_(this.$data))for(const r of e.props){const o=typeof r=="string"?r:r.name,a=typeof r=="object"&&"type"in r?r.type:void 0,i=o.replace(/-([a-z])/g,(m,u)=>u.toUpperCase()),l=this.$data[i];if(this.hasAttribute(o)){const m=this.getAttribute(o);this.$data[i]=D(this,S,Et).call(this,m,l,a)}}D(this,S,G).call(this)}disconnectedCallback(){var e;this.isConnected&&(this.unmounted(),(e=P(this,W))==null||e.call(this),w(this,W,void 0))}attributeChangedCallback(e,s,r){if(s===r||!_(this.$data))return;const o=e.replace(/-([a-z])/g,(i,l)=>l.toUpperCase()),a=this.$data[o];this.$data[o]=D(this,S,Et).call(this,r,a)}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}}z=new WeakMap,Q=new WeakMap,J=new WeakMap,U=new WeakMap,N=new WeakMap,V=new WeakMap,W=new WeakMap,S=new WeakSet,G=function(){P(this,U)||(w(this,U,!0),vt(()=>{var e;if(!this.isConnected){w(this,U,!1);return}this.beforeUpdate(),w(this,J,ft(P(this,V),P(this,Q),P(this,J))),w(this,U,!1),P(this,N)?this.updated():(w(this,N,!0),this.mounted(),(e=this.onInit)==null||e.call(this))}))},Et=function(e,s,r){if(e===null)return s;switch(r||typeof s){case"number":const a=Number(e);return isNaN(a)?s:a;case"boolean":return e==="true";case"object":try{return JSON.parse(e)}catch{return s}default:return e}};const St=n=>t=>{if(customElements.get(n.tagName)){console.warn(`标签名称 "${n.tagName}" 已经被注册`);return}return t.prototype._manifest=te(n),customElements.define(n.tagName,t),t},te=n=>(n=Object.assign({hasConfig:!1},n),n);var ee=Object.getOwnPropertyDescriptor,_t=n=>{throw TypeError(n)},ne=(n,t,e,s)=>{for(var r=s>1?void 0:s?ee(t,e):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=a(r)||r);return r},dt=(n,t,e)=>t.has(n)||_t("Cannot "+e),x=(n,t,e)=>(dt(n,t,"read from private field"),e?e.call(n):t.get(n)),T=(n,t,e)=>t.has(n)?_t("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),H=(n,t,e,s)=>(dt(n,t,"write to private field"),t.set(n,e),e),se=(n,t,e)=>(dt(n,t,"access private method"),e),tt,et,nt,K,B,st,rt,mt,xt;function Wt(n){return n instanceof HTMLElement&&n.isRouterView===!0}p.RouterViewElement=class extends HTMLElement{constructor(){super(...arguments),T(this,mt),T(this,tt,[]),T(this,et,[]),T(this,nt,null),T(this,K),T(this,B,[]),T(this,st,{}),T(this,rt,this.onHashChange.bind(this))}get isRouterView(){return!0}get $routes(){return x(this,B)}set $routes(t){H(this,B,t),this.onHashChange()}get $remainingPath(){return x(this,et)}get $matchedRoute(){return x(this,nt)}set $pipe(t){H(this,st,t||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",x(this,rt)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",x(this,rt))}onHashChange(){var e;if(!this.isConnected)return;const t=this.findAncestorRouterView();if(t)H(this,K,t.$remainingPath),H(this,B,((e=t.$matchedRoute)==null?void 0:e.children)||[]);else{const{path:s}=Pt(window.location);H(this,K,s)}se(this,mt,xt).call(this)}prepareComponentData(t){const e={},s={};for(const[r,o]of Object.entries(t))e[r]=()=>o;for(const[r,o]of Object.entries(x(this,st))){const a=r.toLowerCase();let i=null;a.startsWith("on-")?i=a.slice(3):a.startsWith("on")&&ct.includes(a.slice(2))&&(i=a.slice(2)),i?s[i]=o:e[r]=()=>o}return{props:e,on:s}}matchRoute(t,e){for(const s of t){const r=s.path.split("/").filter(i=>i),o={};if(r.length>e.length&&!r.includes("*"))continue;let a=!0;for(let i=0;i<r.length;i++){const l=r[i],m=e[i];if(l.startsWith(":"))o[l.substring(1)]=m;else{if(l==="*")return{matchedRoute:s,params:o,remainingPath:[]};if(l!==m){a=!1;break}}}if(a)return{matchedRoute:s,params:o,remainingPath:e.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:e}}propagateToChildRouterViews(t=this){for(const e of t.childNodes)Wt(e)?e.onHashChange():this.propagateToChildRouterViews(e)}findAncestorRouterView(){let t=this.parentElement;for(;t;){if(Wt(t))return t;t=t.parentElement}return null}},tt=new WeakMap,et=new WeakMap,nt=new WeakMap,K=new WeakMap,B=new WeakMap,st=new WeakMap,rt=new WeakMap,mt=new WeakSet,xt=function(){const n=x(this,K)||[],{matchedRoute:t,params:e,remainingPath:s}=this.matchRoute(x(this,B),n);H(this,et,s),H(this,nt,t);const r=(t==null?void 0:t.tagName)||"comment",{props:o,on:a}=this.prepareComponentData(e);H(this,tt,ft(this,[{tagName:r,rootId:"0",attrs:{},props:o,on:a,children:[]}],x(this,tt))),this.propagateToChildRouterViews()},p.RouterViewElement=ne([St({tagName:"router-view"})],p.RouterViewElement),p.BaseElement=Yt,p.CustomElement=St,p.createFunction=Z,p.isObject=_,p.listeners=ct,p.observe=pt,p.parseHashUrl=Pt,p.parseHtml=bt,p.patch=ft,p.runInAsyncQueue=vt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
@@ -21,5 +21,25 @@ export interface ASTNode {
21
21
  loops?: Loop[];
22
22
  ifId?: number;
23
23
  model?: string;
24
+ onMounted?: (elm: HTMLElement, loops?: Loop[]) => void;
25
+ onUpdated?: (elm: HTMLElement, loops?: Loop[]) => void;
24
26
  }
25
27
  export declare function parseHtml(ctx: any, html: string): ASTNode[];
28
+ /**
29
+ * 🔹 表达式求值函数
30
+ * 用于解析模板中的 {{ 表达式 }} 或 s-xxx 属性。
31
+ * 语义:计算并返回表达式结果。
32
+ */
33
+ export declare const getValue: (ctx: any, template: string, loops: Loop[]) => any;
34
+ /**
35
+ * 🔹 事件处理器创建函数
36
+ * 用于解析 onClick、onInput 等事件属性。
37
+ * 语义:执行表达式或语句;返回表达式结果(通常被忽略)。
38
+ */
39
+ export declare const createEventHandler: (ctx: any, handler: string) => (event: Event | any, loops: Loop[]) => any;
40
+ /**
41
+ * 🔹 生命周期钩子创建函数
42
+ * 用于解析 onMounted / onUpdated。
43
+ * 语义:执行一段副作用语句块;不返回值。
44
+ */
45
+ export declare const createLifecycleHandler: (ctx: any, handler: string) => (elm: HTMLElement, loops?: Loop[]) => void;
@@ -1,7 +1,59 @@
1
1
  /**
2
- * 观察 value 的变化,并在变化时调用 callback
3
- * @param value
4
- * @param callback
5
- * @returns
2
+ * 表示一次对象或数组的变更信息
6
3
  */
7
- export declare const observe: (value: any, callback: (property: string | symbol, newValue: any) => void) => any;
4
+ export interface ChangeItem {
5
+ /** 变更的路径,从根对象开始 */
6
+ path: (string | symbol)[];
7
+ /** 新值 */
8
+ newValue: any;
9
+ /** 旧值 */
10
+ oldValue: any;
11
+ }
12
+ /**
13
+ * observe 函数的可选配置项
14
+ */
15
+ export interface ObserveOptions {
16
+ /**
17
+ * 节流时间(毫秒),用于批量回调
18
+ */
19
+ throttle?: number;
20
+ /**
21
+ * 仅监听匹配的路径,可为字符串或字符串数组
22
+ * 支持通配符:
23
+ * - `*` 单层匹配
24
+ * - `**` 任意层级匹配
25
+ * - `[*]` 数组元素匹配
26
+ */
27
+ filter?: string | string[];
28
+ /**
29
+ * 是否进行深度比较,避免浅比较导致重复触发
30
+ */
31
+ deepCompare?: boolean;
32
+ /**
33
+ * 批量变化时的回调
34
+ */
35
+ onBatch?: (changes: ChangeItem[]) => void;
36
+ /**
37
+ * 是否在初始化时立即触发一次回调
38
+ */
39
+ immediate?: boolean;
40
+ }
41
+ /**
42
+ * observe 返回值对象
43
+ */
44
+ export interface ObserveReturn<T> {
45
+ /** 代理对象 */
46
+ proxy: T;
47
+ /** 停止监听 */
48
+ unobserve: () => void;
49
+ /** 恢复监听 */
50
+ resume: () => void;
51
+ }
52
+ /**
53
+ * 对任意对象或数组进行深度监听
54
+ * @param value 要监听的对象
55
+ * @param callback 当对象变化时触发的回调,返回变化路径、新值、旧值
56
+ * @param options 配置项,可选
57
+ * @returns ObserveReturn 包含代理对象和控制方法
58
+ */
59
+ export declare function observe<T extends object>(value: T, callback: (path: (string | symbol)[], newValue: any, oldValue: any) => void, options?: ObserveOptions): ObserveReturn<T>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.0.23",
4
+ "version": "0.0.28",
5
5
  "type": "module",
6
6
  "module": "./dist/solely.js",
7
7
  "types": "./dist/solely.d.ts",
@@ -16,13 +16,26 @@
16
16
  "scripts": {
17
17
  "dev": "vite",
18
18
  "build": "tsc && vite build",
19
- "preview": "vite preview"
19
+ "preview": "vite preview",
20
+ "link": "npm link && echo '✅ 全局链接成功,可在其他项目中使用 solely 命令'",
21
+ "test": "vitest",
22
+ "test:ui": "vitest --ui",
23
+ "test:coverage": "vitest --coverage",
24
+ "pack:local": "npm pack && echo '✅ 打包完成,可在其他项目中使用 file: 引用'"
20
25
  },
21
26
  "devDependencies": {
27
+ "@rollup/plugin-strip": "^3.0.4",
28
+ "@testing-library/dom": "^10.4.1",
29
+ "@testing-library/user-event": "^14.6.1",
22
30
  "@types/node": "^22.10.2",
31
+ "@vitest/coverage-v8": "^3.2.4",
32
+ "@vitest/ui": "^3.2.4",
33
+ "jsdom": "27.0.0",
23
34
  "sass": "^1.83.0",
35
+ "terser": "^5.44.0",
24
36
  "typescript": "~5.6.2",
25
37
  "vite": "^5.4.10",
26
- "vite-plugin-dts": "^4.4.0"
38
+ "vite-plugin-dts": "^4.4.0",
39
+ "vitest": "^3.2.4"
27
40
  }
28
- }
41
+ }
@@ -1,2 +0,0 @@
1
- import { ASTNode } from './html-parse';
2
- export declare const patch: (parentNode: Element | ShadowRoot, ast: ASTNode[], oldNodes?: ASTNode[]) => ASTNode[];
@@ -1,2 +0,0 @@
1
- export type FunctionCreator<TArgs extends any[], TReturn> = (...args: TArgs) => TReturn;
2
- export declare function createFunction<TArgs extends any[]>(args: string[]): FunctionCreator<TArgs, any>;
@@ -1,2 +0,0 @@
1
- export type FunctionCreator = (...args: any[]) => any;
2
- export declare function createFunction(args: string[]): FunctionCreator;
@@ -1,25 +0,0 @@
1
- export interface Loop {
2
- item: string;
3
- value: any;
4
- index: string;
5
- valueIndex: number;
6
- }
7
- export interface ASTNode {
8
- key?: string;
9
- handlers?: Record<string, EventListenerOrEventListenerObject>;
10
- rootId: string;
11
- tagName: string;
12
- attrs: Record<string, string>;
13
- props: Record<string, Function>;
14
- styles?: Function;
15
- classes?: Function;
16
- on: Record<string, (event: Event, loops: Loop[]) => any>;
17
- content?: string | ((loops: Loop[]) => string);
18
- children: ASTNode[];
19
- elm?: Node;
20
- fn?: Function;
21
- loops?: Loop[];
22
- ifId?: number;
23
- model?: string;
24
- }
25
- export declare function parseHtml(ctx: any, html: string): ASTNode[];