solely 0.0.30 → 0.1.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/README.md +817 -507
- package/dist/compiler/index.d.ts +2 -0
- package/dist/compiler/ir/buildIR.d.ts +12 -0
- package/dist/compiler/ir/index.d.ts +1 -0
- package/dist/compiler/parser/index.d.ts +1 -0
- package/dist/compiler/parser/parser.d.ts +5 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1756 -0
- package/dist/index.umd.cjs +47 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/plugins/html-parse-precompile.d.ts +1 -0
- package/dist/plugins/html-precompile.d.ts +1 -0
- package/dist/plugins/index.d.ts +1 -0
- package/dist/runtime/component/base-element.d.ts +24 -0
- package/dist/{base → runtime/component}/decorators.d.ts +6 -4
- package/dist/runtime/component/index.d.ts +2 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/reactivity/index.d.ts +2 -0
- package/dist/runtime/reactivity/observe.d.ts +47 -0
- package/dist/{utils/observe.d.ts → runtime/reactivity/types.d.ts} +0 -8
- package/dist/runtime/renderer/index.d.ts +1 -0
- package/dist/runtime/renderer/renderIR.d.ts +25 -0
- package/dist/runtime/router/core.d.ts +42 -0
- package/dist/runtime/router/index.d.ts +6 -0
- package/dist/runtime/router/router-link.d.ts +17 -0
- package/dist/runtime/router/router-view.d.ts +25 -0
- package/dist/runtime/router/types.d.ts +65 -0
- package/dist/shared/event-listeners.d.ts +2 -0
- package/dist/shared/gen-function.d.ts +3 -0
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/templateError.d.ts +9 -0
- package/dist/types/ast.d.ts +38 -0
- package/dist/types/component.d.ts +66 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/ir.d.ts +67 -0
- package/dist/types/lifecycle.d.ts +4 -0
- package/dist/types/loop.d.ts +4 -0
- package/package.json +24 -6
- package/dist/base/base-element.d.ts +0 -56
- package/dist/base/index.d.ts +0 -5
- package/dist/base/router-view.d.ts +0 -43
- package/dist/solely.d.ts +0 -2
- package/dist/solely.js +0 -941
- package/dist/solely.umd.cjs +0 -3
- package/dist/utils/ast-processor.d.ts +0 -2
- package/dist/utils/async-queue.d.ts +0 -1
- package/dist/utils/event-listeners.d.ts +0 -2
- package/dist/utils/html-parse.d.ts +0 -45
- package/dist/utils/index.d.ts +0 -8
- /package/dist/{utils → shared}/functions.d.ts +0 -0
- /package/dist/{utils → shared}/is-object.d.ts +0 -0
- /package/dist/{utils → shared}/url.d.ts +0 -0
package/dist/solely.umd.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
(function(d,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(d=typeof globalThis<"u"?globalThis:d||self,v(d.solely={}))})(this,function(d){"use strict";var It=d=>{throw TypeError(d)};var yt=(d,v,C)=>v.has(d)||It("Cannot "+C);var M=(d,v,C)=>(yt(d,v,"read from private field"),C?C.call(d):v.get(d)),j=(d,v,C)=>v.has(d)?It("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(d):v.set(d,C),w=(d,v,C,X)=>(yt(d,v,"write to private field"),X?X.call(d,C):v.set(d,C),C),D=(d,v,C)=>(yt(d,v,"access private method"),C);var z,Q,J,V,N,U,I,_,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(t){return t.replace(/>\s+</g,"><").replace(/\s+/g," ")}function Tt(t,e){const n=(e.match(C)||[])[1]||"",s={rootId:"0",tagName:n,attrs:{},props:{},on:{},children:[]},r=new RegExp(X);for(;;){const o=r.exec(e);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(t,i);else if(ct.includes(a)||a.startsWith("on-"))s.on[a.startsWith("on-")?a.slice(3):a.slice(2)]=F(t,i);else if(a.startsWith("s-")){const l=a.slice(2);switch(l){case"model":s.model=i;break;case"style":s.styles=p=>P(t,i,p);break;case"class":s.classes=p=>P(t,i,p);break;case"readonly":s.props.readOnly=p=>P(t,i,p);break;case"for":s.props.htmlFor=p=>P(t,i,p);break;case"tabindex":s.props.tabIndex=p=>P(t,i,p);break;case"contenteditable":s.props.contentEditable=p=>P(t,i,p);break;default:s.props[l]=p=>P(t,i,p);break}}else s.attrs[a]=i;r.lastIndex--}if(n==="For"?s.fn=o=>P(t,s.attrs.each,o):(n==="If"||n==="ElseIf")&&(s.fn=o=>P(t,s.attrs.condition,o)),s.model){const o=s.model.replace("this.","").replace("$data.",""),a=l=>P(t,`$data.${o}`,l),i=(l,p)=>{if(s.on[l]){const u=s.on[l];s.on[l]=(c,h)=>{p(c,h),u(c,h)}}else s.on[l]=p};if(n==="input"){const l=s.attrs.type||"text";if(l==="checkbox")s.props.checked=a,i("change",F(t,`$data.${o}=checked`));else if(l==="radio"){const p=s.attrs.value;s.props.checked=u=>a(u)==p,i("change",F(t,`if(checked){$data.${o}='${p}'}`))}else s.props.value=a,i("input",F(t,`$data.${o}=value`))}else if(n==="textarea")s.props.value=a,i("input",F(t,`$data.${o}=value`));else if(n==="select"){const l="multiple"in s.attrs;l?i("change",F(t,`
|
|
2
|
-
$data.${o} = Array.from(event.target.selectedOptions).map(o => o.value);
|
|
3
|
-
`)):(i("change",F(t,`$data.${o}=value`)),s.props.value=a);const p=(h,m=[])=>{const A=a(m);if(l){const R=Array.isArray(A)?A:A!=null?[A]:[];for(const O of h.options)O.selected=R.includes(O.value)}else{const R=A??"";h.value!==R&&(h.value=R)}},u=s.onMounted,c=s.onUpdated;s.onMounted=(h,m)=>{u==null||u(h,m),p(h,m||[])},s.onUpdated=(h,m)=>{c==null||c(h,m),p(h,m||[])}}}return s}function bt(t,e){const n=[];if(!e)return n;e=jt(e);const s=[],r=[],o=()=>{var i;return s.length===0?n:(i=s[s.length-1]).children||(i.children=[])};let a=0;return e.replace(v,(i,l)=>{const p=o();if(l>a){const u=e.substring(a,l).trim();if(u){it.lastIndex=0;const h=!it.test(u)?u:m=>u.replace(it,(A,R)=>P(t,R,m));p.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:h,children:[]})}}if(a=l+i.length,i.startsWith("<!--")&&i.endsWith("-->"))p.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(t,i),c=i.endsWith("/>")||Ot.includes(u.tagName);p.push(u),c||(s.push(u),r.push(u.tagName))}return""}),e.length>a&&n.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:e.substring(a).trim(),children:[]}),n}const P=(t,e,n)=>{try{return Z(["$data",...n.map(r=>r.item),...n.map(r=>r.index),`return (${e})`]).bind(t)(t.$data,...n.map(r=>r.value),...n.map(r=>r.valueIndex))}catch(s){return console.error(`[BaseElement][${t.tagName}] Error evaluating expression: {{ ${e} }}`,t,s),""}},F=(t,e)=>(n,s)=>{var r,o;try{return Z(["$data","event","value","checked",...s.map(i=>i.item),...s.map(i=>i.index),e]).bind(t)(t.$data,n,(r=n==null?void 0:n.target)==null?void 0:r.value,(o=n==null?void 0:n.target)==null?void 0:o.checked,...s.map(i=>i.value),...s.map(i=>i.valueIndex))}catch(a){console.error(`[BaseElement][${t.tagName}] Error executing event handler "${e}"`,t,a)}},Ht=(t,e)=>(n,s=[])=>{try{Z(["$data","elm",...s.map(o=>o.item),...s.map(o=>o.index),`(function(){ ${e} }).call(this)`]).bind(t)(t.$data,n,...s.map(o=>o.value),...s.map(o=>o.valueIndex))}catch(r){console.error(`[BaseElement][${t.tagName}] Error executing lifecycle handler "${e}"`,t,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"?t=>requestAnimationFrame(t):typeof Promise<"u"?t=>Promise.resolve().then(t):t=>setTimeout(t,0),vt=(t,...e)=>{if(typeof t!="function")throw new Error("runInAsyncQueue expects a function as its first argument");Lt(()=>t(...e))},lt={};function Z(t){const e=t.map(n=>n.replace(/[',"]/g,"")).join(",");if(!lt[e]){const n=t[t.length-1];if(n.trim()==="")throw new Error("Function body cannot be empty");if(Ft(n))throw new Error("Input contains potentially dangerous code: "+n);lt[e]=new Function(...t)}return lt[e]}const Dt=["eval","Function","process","require"];function Ft(t){return Dt.some(e=>new RegExp(`\\b${e}\\b`,"g").test(t))}const Vt="http://www.w3.org/1999/xlink",Ut="http://www.w3.org/2000/xmlns/",qt="http://www.w3.org/XML/1998/namespace",Bt="http://www.w3.org/2000/svg",$t=t=>typeof t.content=="function"?t.content(t.loops||[]):t.content||"",zt=t=>{const e=$t(t),n=t.elm;n.textContent!==e&&(n.textContent=e)},Gt=["role","form"],At=(t,e,n=[])=>{Object.keys(e).forEach(s=>{const r=e[s](n);if(s.startsWith("data-")||s.startsWith("aria-")||Gt.includes(s)){const o=t.getAttribute(s),a=r==null?null:String(r);o!==a&&(a==null?t.removeAttribute(s):t.setAttribute(s,a))}else t[s]!==r&&(t[s]=r)})},kt=(t,e)=>{const{styles:n,loops:s=[]}=e;if(!n)return;const r=n(s),o=ut(r);Object.entries(o).forEach(([a,i])=>{t.style[a]=i})},Ct=(t,e)=>{const{classes:n,loops:s=[]}=e;if(!n)return;const r=n(s),o=wt(r);Object.entries(o).forEach(([a,i])=>{i?t.classList.add(a):t.classList.remove(a)})},ut=t=>{let e={};return typeof t=="object"&&t!==null&&!Array.isArray(t)?Object.entries(t).forEach(([n,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=ut(s);Object.entries(r).forEach(([o,a])=>{e[`${n}-${o}`]=a})}else typeof s=="string"||typeof s=="number"?e[n]=`${s}`:e[n]=String(s)}):typeof t=="string"?t.split(";").forEach(n=>{const[s,r]=n.split(":").map(o=>o.trim());s&&r&&(e[s]=r)}):Array.isArray(t)&&t.forEach(n=>{const s=ut(n);Object.entries(s).forEach(([r,o])=>{e[r]=o})}),e},wt=t=>{let e={};return typeof t=="object"&&!Array.isArray(t)?Object.entries(t).forEach(([n,s])=>{e[n]=!!s}):typeof t=="string"?t.split(" ").forEach(n=>{n!==""&&(e[n]=!0)}):Array.isArray(t)&&t.forEach(n=>{const s=wt(n);Object.entries(s).forEach(([r,o])=>{e[r]=o})}),e},Rt=(t,e,n)=>{const s=r=>n.on[e](r,n.loops||[]);t.addEventListener(e,s,!1),n.handlers=n.handlers||{},n.handlers[e]=s},Kt=(t,e)=>{const n=e.elm;Object.keys(e.on).forEach(s=>{t.handlers&&t.handlers[s]&&n.removeEventListener(s,t.handlers[s],!1),Rt(n,s,e)}),At(n,e.props,e.loops),Ct(n,e),kt(n,e),typeof e.onUpdated=="function"&&requestAnimationFrame(()=>{e.onUpdated(n,e.loops||[])}),St(n,t.children,e.children)},Qt=(t,e)=>{switch(e.elm=t.elm,e.tagName){case"comment":break;case"text":zt(e);break;default:Kt(t,e);break}},ht=(t,e,n)=>{n&&n.parentNode===t?t.insertBefore(e,n):t.appendChild(e)},Jt=(t,e,n)=>{const s=$t(e),r=document.createTextNode(s);e.elm=r,ht(t,r,n)},Nt=(t,e,n)=>{const s=e.content,r=document.createComment(s);e.elm=r,ht(t,r,n)},Xt=(t,e,n,s)=>{e.tagName==="svg"&&(s=Bt);const r=s?document.createElementNS(s,e.tagName):document.createElement(e.tagName);Object.keys(e.attrs).forEach(o=>{const a=e.attrs[o]||"";o.charAt(0)!=="x"?r.setAttribute(o,a):o.startsWith("xml:")?r.setAttributeNS(qt,o,a):o.startsWith("xlink:")?r.setAttributeNS(Vt,o,a):o.startsWith("xmlns:")?r.setAttributeNS(Ut,o,a):r.setAttribute(o,a)}),Object.keys(e.on).forEach(o=>{Rt(r,o,e)}),At(r,e.props,e.loops),Ct(r,e),kt(r,e),e.elm=r,ht(t,r,n),e.tagName==="foreignObject"&&(s=void 0),e.children.forEach(o=>{Y(r,o,void 0,s)}),typeof e.onMounted=="function"&&requestAnimationFrame(()=>{e.onMounted(r,e.loops||[])})},Y=(t,e,n,s)=>{switch(e.tagName){case"comment":Nt(t,e,n);break;case"text":Jt(t,e,n);break;default:Xt(t,e,n,s);break}},Zt=t=>t&&(t.tagName==="ElseIf"||t.tagName==="comment"),Yt=t=>t&&t.tagName==="Else",q=(t,e,n=[],s="0",r)=>{var i,l,p;let o=0,a=0;for(let u=0;u<e.length;u++){const c=e[u];if(c.tagName==="If"){let h=!1;o++;let m=1;for(((i=c.fn)==null?void 0:i.call(c,n))&&(q(t,c.children,n,`${s}-if-${o}-${m}`,m),h=!0),m++;u+1<e.length&&Zt(e[u+1]);)((p=(l=e[u+1]).fn)==null?void 0:p.call(l,n))&&!h&&(q(t,e[u+1].children,n,`${s}-if-${o}-${m}`,m),h=!0),u++,m++;u+1<e.length&&Yt(e[u+1])&&(h||(q(t,e[u+1].children,n,`${s}-if-${o}-${m}`,m),h=!0),u++)}else if(c.tagName==="For"){a++;const{item:h="item",index:m="index"}=c.attrs;(c.fn(n)||[]).forEach((R,O)=>{const ot={item:h,value:R,index:m,valueIndex:O};q(t,c.children,[...n,ot],`${s}-for-${a}-${O}`,1)})}else{const h={...c,loops:n,children:[],rootId:s,ifId:r,key:c.key||`${s}-${u}`};q(h.children,c.children,n,`${s}-${u}`),t.push(h)}}},St=(t,e,n)=>{var a,i,l,p,u;const s=new Map;e.forEach((c,h)=>s.set(c.key,{node:c,index:h}));let r=0,o=0;for(;r<n.length;){const c=n[r],h=s.get(c.key);if(h){const m=h.node;if(m.tagName!==c.tagName){(a=m.elm)==null||a.remove();const A=(i=e[o+1])==null?void 0:i.elm;Y(t,c,A),s.delete(c.key),o++}else{if(c.ifId&&m.ifId!==c.ifId){(l=m.elm)==null||l.remove();const A=(p=e[o+1])==null?void 0:p.elm;Y(t,c,A)}else Qt(m,c);s.delete(c.key),o++}}else{const m=(u=e[o])==null?void 0:u.elm;Y(t,c,m)}r++}s.forEach(({node:c})=>{var h;return(h=c.elm)==null?void 0:h.remove()})},ft=(t,e,n=[])=>{if(!e||e.length===0)return[];const s=[];return q(s,e||[],[],"0"),St(t,n,s),s},x=t=>{if(t===null||typeof t!="object")return!1;const e=Object.prototype.toString.call(t);return!["[object Function]","[object Date]","[object RegExp]","[object Map]","[object Set]","[object WeakMap]","[object WeakSet]"].includes(e)};function Mt(t=window.location){let e;typeof t=="string"?e=new URL(t).hash:e=t.hash;const n=e.split("?"),s=n[0].substring(2),r=n[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(t,e,n={}){const s=new WeakMap,r=new WeakSet,o=new WeakMap,{throttle:a=0,deepCompare:i=!1,onBatch:l=null,immediate:p=!1}=n,u=Array.isArray(n.filter)?n.filter:n.filter?[n.filter]:[];let c=[],h=null,m=!0;const A=(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(!A(f[y],g[y],$))return!1;return!0}if(Array.isArray(f)!==Array.isArray(g))return!1;const k=Object.keys(f),E=Object.keys(g);if(k.length!==E.length)return!1;for(const y of k)if(!Object.prototype.hasOwnProperty.call(g,y)||!A(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}})},O=(f,g,$)=>{m&&R(f)&&(a>0?(c.push({path:f,newValue:g,oldValue:$}),h||(h=setTimeout(()=>{if(!m){h=null;return}const k=c;c=[],h=null,l&&l(k);for(const E of k)e(E.path,E.newValue,E.oldValue)},a))):(e(f,g,$),l&&l([{path:f,newValue:g,oldValue:$}])))},ot=(f,g)=>{if(!x(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(!m)return Reflect.apply(y,f,b);const S=[...f],L=y.apply(f,b);return A(f,S)||O(g,f,S),L}}),s.has(f)){const E=s.get(f);return o.set(E,g),E}r.add(f);const k=new Proxy(f,{get(E,y,b){if(Array.isArray(E)&&$.hasOwnProperty(y))return Reflect.get($,y,b);const S=Reflect.get(E,y,b);if(x(S)){const at=[...o.get(k)||[],y],gt=ot(S,at);return o.set(gt,at),gt}return S},set(E,y,b,S){const L=Reflect.get(E,y,S),at=x(b)&&!(b instanceof Date||b instanceof RegExp||b instanceof Map||b instanceof Set);if(i&&at?A(L,b):L===b)return!0;const ae=Reflect.set(E,y,b,S),ie=o.get(k)||g;return O([...ie,y],b,L),ae},deleteProperty(E,y){if(Reflect.has(E,y)){const b=E[y],S=Reflect.deleteProperty(E,y),L=o.get(k)||[];return S&&r.has(E)&&O([...L,y],void 0,b),S}return!1}});return s.set(f,k),o.set(k,g),k},oe=ot(t,[]);if(p){const f=(g,$,k=new WeakSet)=>{if(!(!x(g)||!m||k.has(g))){k.add(g);for(const E of Object.keys(g)){const y=[...$,E],b=g[E];R(y)&&e(y,b,void 0),x(b)&&f(b,y,k)}}};f(t,[])}return{proxy:oe,unobserve:()=>{m&&(m=!1,c=[],h&&(clearTimeout(h),h=null))},resume:()=>{m=!0}}}class te extends HTMLElement{constructor(n={}){var a;super();j(this,_);j(this,z);j(this,Q,[]);j(this,J,[]);j(this,V,!1);j(this,N,!1);j(this,U);j(this,I);const s=this._manifest||{};w(this,U,(a=s.shadowDOM)!=null&&a.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this);const{proxy:r,unobserve:o}=pt(n,()=>D(this,_,G).call(this));w(this,z,r),w(this,I,o),s.template&&typeof s.template=="string"&&w(this,Q,bt(this,s.template)),Promise.resolve().then(()=>this.created())}static get observedAttributes(){const n=this._manifest||this.prototype._manifest;return n!=null&&n.props?n.props.map(s=>typeof s=="string"?s:s.name):[]}get $data(){return M(this,z)}set $data(n){x(n)||(n={}),M(this,I)&&M(this,I).call(this);const{proxy:s,unobserve:r}=pt(n,()=>D(this,_,G).call(this));w(this,z,s),w(this,I,r),D(this,_,G).call(this)}refresh(){D(this,_,G).call(this)}connectedCallback(){const n=this._manifest||{};if((n.className||n.tagName||"").split(" ").forEach(r=>r&&this.classList.add(r)),n.styles&&!M(this,U).querySelector("style[data-manifest-style]")){const r=document.createElement("style");r.setAttribute("data-manifest-style","true"),r.textContent=n.styles,M(this,U).appendChild(r)}if(n.props&&x(this.$data))for(const r of n.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,(p,u)=>u.toUpperCase()),l=this.$data[i];if(this.hasAttribute(o)){const p=this.getAttribute(o);this.$data[i]=D(this,_,Et).call(this,p,l,a)}}D(this,_,G).call(this)}disconnectedCallback(){var n;this.isConnected&&(this.unmounted(),(n=M(this,I))==null||n.call(this),w(this,I,void 0))}attributeChangedCallback(n,s,r){if(s===r||!x(this.$data))return;const o=n.replace(/-([a-z])/g,(i,l)=>l.toUpperCase()),a=this.$data[o];this.$data[o]=D(this,_,Et).call(this,r,a)}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}}z=new WeakMap,Q=new WeakMap,J=new WeakMap,V=new WeakMap,N=new WeakMap,U=new WeakMap,I=new WeakMap,_=new WeakSet,G=function(){M(this,V)||(w(this,V,!0),vt(()=>{var n;if(!this.isConnected){w(this,V,!1);return}this.beforeUpdate(),w(this,J,ft(M(this,U),M(this,Q),M(this,J))),w(this,V,!1),M(this,N)?this.updated():(w(this,N,!0),this.mounted(),(n=this.onInit)==null||n.call(this))}))},Et=function(n,s,r){if(n===null)return s;switch(r||typeof s){case"number":const a=Number(n);return isNaN(a)?s:a;case"boolean":return n==="true";case"object":try{return JSON.parse(n)}catch{return s}default:return n}};const Pt=t=>e=>{if(customElements.get(t.tagName)){console.warn(`标签名称 "${t.tagName}" 已经被注册`);return}return e.prototype._manifest=ee(t),customElements.define(t.tagName,e),e},ee=t=>(t=Object.assign({hasConfig:!1},t),t);var ne=Object.getOwnPropertyDescriptor,_t=t=>{throw TypeError(t)},se=(t,e,n,s)=>{for(var r=s>1?void 0:s?ne(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},dt=(t,e,n)=>e.has(t)||_t("Cannot "+n),W=(t,e,n)=>(dt(t,e,"read from private field"),n?n.call(t):e.get(t)),T=(t,e,n)=>e.has(t)?_t("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),H=(t,e,n,s)=>(dt(t,e,"write to private field"),e.set(t,n),n),re=(t,e,n)=>(dt(t,e,"access private method"),n),tt,et,nt,K,B,st,rt,mt,xt;function Wt(t){return t instanceof HTMLElement&&t.isRouterView===!0}d.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 W(this,B)}set $routes(e){H(this,B,e),this.onHashChange()}get $remainingPath(){return W(this,et)}get $matchedRoute(){return W(this,nt)}set $pipe(e){H(this,st,e||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",W(this,rt)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",W(this,rt))}onHashChange(){var n;if(!this.isConnected)return;const e=this.findAncestorRouterView();if(e)H(this,K,e.$remainingPath),H(this,B,((n=e.$matchedRoute)==null?void 0:n.children)||[]);else{const{path:s}=Mt(window.location);H(this,K,s)}re(this,mt,xt).call(this)}prepareComponentData(e){const n={},s={};for(const[r,o]of Object.entries(e))n[r]=()=>o;for(const[r,o]of Object.entries(W(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:n[r]=()=>o}return{props:n,on:s}}matchRoute(e,n){for(const s of e){const r=s.path.split("/").filter(i=>i),o={};if(r.length>n.length&&!r.includes("*"))continue;let a=!0;for(let i=0;i<r.length;i++){const l=r[i],p=n[i];if(l.startsWith(":"))o[l.substring(1)]=p;else{if(l==="*")return{matchedRoute:s,params:o,remainingPath:[]};if(l!==p){a=!1;break}}}if(a)return{matchedRoute:s,params:o,remainingPath:n.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:n}}propagateToChildRouterViews(e=this){for(const n of e.childNodes)Wt(n)?n.onHashChange():this.propagateToChildRouterViews(n)}findAncestorRouterView(){let e=this.parentElement;for(;e;){if(Wt(e))return e;e=e.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 t=W(this,K)||[],{matchedRoute:e,params:n,remainingPath:s}=this.matchRoute(W(this,B),t);H(this,et,s),H(this,nt,e);const r=(e==null?void 0:e.tagName)||"comment",{props:o,on:a}=this.prepareComponentData(n);H(this,tt,ft(this,[{tagName:r,rootId:"0",attrs:{},props:o,on:a,children:[]}],W(this,tt))),this.propagateToChildRouterViews()},d.RouterViewElement=se([Pt({tagName:"router-view"})],d.RouterViewElement),d.BaseElement=te,d.CustomElement=Pt,d.createFunction=Z,d.isObject=x,d.listeners=ct,d.observe=pt,d.parseHashUrl=Mt,d.parseHtml=bt,d.patch=ft,d.runInAsyncQueue=vt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const runInAsyncQueue: (callback: Function, ...args: any[]) => void;
|
|
@@ -1,45 +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
|
-
onMounted?: (elm: HTMLElement, loops?: Loop[]) => void;
|
|
25
|
-
onUpdated?: (elm: HTMLElement, loops?: Loop[]) => void;
|
|
26
|
-
}
|
|
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;
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { parseHtml, type ASTNode } from './html-parse';
|
|
2
|
-
export { default as listeners } from './event-listeners';
|
|
3
|
-
export { runInAsyncQueue } from './async-queue';
|
|
4
|
-
export { createFunction, type FunctionCreator } from './functions';
|
|
5
|
-
export { patch } from './ast-processor';
|
|
6
|
-
export { isObject } from './is-object';
|
|
7
|
-
export { parseHashUrl } from './url';
|
|
8
|
-
export { observe } from './observe';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|