solely 0.0.29 → 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 -928
- 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(p,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(p=typeof globalThis<"u"?globalThis:p||self,b(p.solely={}))})(this,function(p){"use strict";var It=p=>{throw TypeError(p)};var yt=(p,b,C)=>b.has(p)||It("Cannot "+C);var P=(p,b,C)=>(yt(p,b,"read from private field"),C?C.call(p):b.get(p)),O=(p,b,C)=>b.has(p)?It("Cannot add the same private member more than once"):b instanceof WeakSet?b.add(p):b.set(p,C),w=(p,b,C,X)=>(yt(p,b,"write to private field"),X?X.call(p,C):b.set(p,C),C),D=(p,b,C)=>(yt(p,b,"access private method"),C);var z,Q,J,U,N,V,W,S,G,Et;const b=/<!--(?:.|\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 vt(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(b,(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),bt=(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;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(...v){if(!d)return Reflect.apply(y,f,v);const M=[...f],L=y.apply(f,v);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,v){if(Array.isArray(E)&&$.hasOwnProperty(y))return Reflect.get($,y,v);const M=Reflect.get(E,y,v);if(_(M)){const at=[...o.get(A)||[],y],gt=ot(M,at);return o.set(gt,at),gt}return M},set(E,y,v,M){const L=Reflect.get(E,y,M),at=_(v)&&!(v instanceof Date||v instanceof RegExp||v instanceof Map||v instanceof Set);if(i&&at?k(L,v):L===v)return!0;const oe=Reflect.set(E,y,v,M),ae=o.get(A)||g;return I([...ae,y],v,L),oe},deleteProperty(E,y){if(Reflect.has(E,y)){const v=E[y],M=Reflect.deleteProperty(E,y),L=o.get(A)||[];return M&&r.has(E)&&I([...L,y],void 0,v),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],v=g[E];R(y)&&t(y,v,void 0),_(v)&&f(v,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,vt(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),bt(()=>{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=vt,p.patch=ft,p.runInAsyncQueue=bt,Object.defineProperty(p,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
|