elit 2.0.1 → 3.0.1
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 +275 -128
- package/dist/build.d.mts +10 -1
- package/dist/build.d.ts +10 -1
- package/dist/build.js +670 -1
- package/dist/build.mjs +641 -1
- package/dist/chokidar.d.mts +134 -0
- package/dist/chokidar.d.ts +134 -0
- package/dist/chokidar.js +240 -0
- package/dist/chokidar.mjs +221 -0
- package/dist/cli.js +2792 -495
- package/dist/dom.d.mts +10 -3
- package/dist/dom.d.ts +10 -3
- package/dist/dom.js +676 -1
- package/dist/dom.mjs +647 -1
- package/dist/el.d.mts +16 -36
- package/dist/el.d.ts +16 -36
- package/dist/el.js +789 -1
- package/dist/el.mjs +583 -1
- package/dist/fs.d.mts +255 -0
- package/dist/fs.d.ts +255 -0
- package/dist/fs.js +513 -0
- package/dist/fs.mjs +469 -0
- package/dist/hmr.js +112 -1
- package/dist/hmr.mjs +91 -1
- package/dist/http.d.mts +163 -0
- package/dist/http.d.ts +163 -0
- package/dist/http.js +632 -0
- package/dist/http.mjs +605 -0
- package/dist/https.d.mts +108 -0
- package/dist/https.d.ts +108 -0
- package/dist/https.js +907 -0
- package/dist/https.mjs +901 -0
- package/dist/index.d.mts +613 -33
- package/dist/index.d.ts +613 -33
- package/dist/index.js +2589 -1
- package/dist/index.mjs +2312 -1
- package/dist/mime-types.d.mts +48 -0
- package/dist/mime-types.d.ts +48 -0
- package/dist/mime-types.js +197 -0
- package/dist/mime-types.mjs +166 -0
- package/dist/path.d.mts +163 -0
- package/dist/path.d.ts +163 -0
- package/dist/path.js +350 -0
- package/dist/path.mjs +310 -0
- package/dist/router.d.mts +3 -1
- package/dist/router.d.ts +3 -1
- package/dist/router.js +830 -1
- package/dist/router.mjs +801 -1
- package/dist/runtime.d.mts +97 -0
- package/dist/runtime.d.ts +97 -0
- package/dist/runtime.js +43 -0
- package/dist/runtime.mjs +15 -0
- package/dist/server.d.mts +5 -1
- package/dist/server.d.ts +5 -1
- package/dist/server.js +3267 -1
- package/dist/server.mjs +3241 -1
- package/dist/state.d.mts +3 -1
- package/dist/state.d.ts +3 -1
- package/dist/state.js +1036 -1
- package/dist/state.mjs +992 -1
- package/dist/style.d.mts +47 -1
- package/dist/style.d.ts +47 -1
- package/dist/style.js +551 -1
- package/dist/style.mjs +483 -1
- package/dist/{types-DOAdFFJB.d.ts → types-C0nGi6MX.d.mts} +29 -13
- package/dist/{types-DOAdFFJB.d.mts → types-Du6kfwTm.d.ts} +29 -13
- package/dist/types.d.mts +452 -3
- package/dist/types.d.ts +452 -3
- package/dist/types.js +18 -1
- package/dist/ws.d.mts +195 -0
- package/dist/ws.d.ts +195 -0
- package/dist/ws.js +380 -0
- package/dist/ws.mjs +358 -0
- package/dist/wss.d.mts +108 -0
- package/dist/wss.d.ts +108 -0
- package/dist/wss.js +1306 -0
- package/dist/wss.mjs +1300 -0
- package/package.json +53 -6
- package/dist/client.d.mts +0 -9
- package/dist/client.d.ts +0 -9
- package/dist/client.js +0 -1
- package/dist/client.mjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1 +1,2589 @@
|
|
|
1
|
-
"use strict";var e,t=require("http"),r=require("https"),s=require("ws"),o=require("chokidar"),n=require("fs/promises"),i=require("path"),a=require("mime-types"),l=require("esbuild"),p=require("fs"),c=(e=function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')},typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):e),d=class{constructor(){this.elementCache=new WeakMap,this.reactiveNodes=new Map}createElement(e,t={},r=[]){return{tagName:e,props:t,children:r}}renderToDOM(e,t){if(null==e||!1===e)return;if("object"!=typeof e)return void t.appendChild(document.createTextNode(String(e)));let{tagName:r,props:s,children:o}=e,n="svg"===r||"s"===r[0]&&"v"===r[1]&&"g"===r[2]||"http://www.w3.org/2000/svg"===t.namespaceURI,i=n?document.createElementNS("http://www.w3.org/2000/svg",r.replace("svg","").toLowerCase()||r):document.createElement(r);for(let e in s){let t=s[e];if(null==t||!1===t)continue;let r=e.charCodeAt(0);if(99===r&&(e.length<6||"N"===e[5])){let e=Array.isArray(t)?t.join(" "):t;n?i.setAttribute("class",e):i.className=e}else if(115===r&&5===e.length)if("string"==typeof t)i.style.cssText=t;else{let e=i.style;for(let r in t)e[r]=t[r]}else 111===r&&110===e.charCodeAt(1)?i[e.toLowerCase()]=t:100===r&&e.length>20?i.innerHTML=t.__html:114===r&&3===e.length?setTimeout(()=>{"function"==typeof t?t(i):t.current=i},0):i.setAttribute(e,!0===t?"":String(t))}let a=o.length;if(!a)return void t.appendChild(i);let l=e=>{for(let t=0;t<a;t++){let r=o[t];if(null!=r&&!1!==r)if(Array.isArray(r))for(let t=0,s=r.length;t<s;t++){let s=r[t];null!=s&&!1!==s&&this.renderToDOM(s,e)}else this.renderToDOM(r,e)}};if(a>30){let e=document.createDocumentFragment();l(e),i.appendChild(e)}else l(i);t.appendChild(i)}render(e,t){let r="string"==typeof e?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);if(t.children&&t.children.length>500){let e=document.createDocumentFragment();this.renderToDOM(t,e),r.appendChild(e)}else this.renderToDOM(t,r);return r}batchRender(e,t){let r="string"==typeof e?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);let s=t.length;if(s>3e3){let e=document.createDocumentFragment(),o=0,n=1500,i=()=>{let a=Math.min(o+n,s);for(let r=o;r<a;r++)this.renderToDOM(t[r],e);o=a,o>=s?r.appendChild(e):requestAnimationFrame(i)};i()}else{let e=document.createDocumentFragment();for(let r=0;r<s;r++)this.renderToDOM(t[r],e);r.appendChild(e)}return r}renderChunked(e,t,r=5e3,s){let o="string"==typeof e?document.getElementById(e.replace("#","")):e;if(!o)throw new Error(`Element not found: ${e}`);let n=t.length,i=0,a=()=>{let e=Math.min(i+r,n),l=document.createDocumentFragment();for(let r=i;r<e;r++)this.renderToDOM(t[r],l);o.appendChild(l),i=e,s&&s(i,n),i<n&&requestAnimationFrame(a)};return requestAnimationFrame(a),o}renderToHead(...e){let t=document.head;if(t)for(let r of e.flat())r&&this.renderToDOM(r,t);return t}addStyle(e){let t=document.createElement("style");return t.textContent=e,document.head.appendChild(t)}addMeta(e){let t=document.createElement("meta");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}addLink(e){let t=document.createElement("link");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}setTitle(e){return document.title=e}createState(e,t={}){let r=e,s=new Set,o=null,{throttle:n=0,deep:i=!1}=t,a=()=>s.forEach(e=>e(r));return{get value(){return r},set value(e){(i?JSON.stringify(r)!==JSON.stringify(e):r!==e)&&(r=e,n>0?o||(o=setTimeout(()=>{o=null,a()},n)):a())},subscribe:e=>(s.add(e),()=>s.delete(e)),destroy(){s.clear(),o&&clearTimeout(o)}}}computed(e,t){let r=e.map(e=>e.value),s=this.createState(t(...r));return e.forEach((e,o)=>{e.subscribe(e=>{r[o]=e,s.value=t(...r)})}),s}effect(e){e()}createVirtualList(e,t,r,s=50,o=5){let n=e.clientHeight,i=t.length*s,a=0,l=()=>{let{start:l,end:p}={start:Math.max(0,Math.floor(a/s)-o),end:Math.min(t.length,Math.ceil((a+n)/s)+o)},c=document.createElement("div");c.style.cssText=`height:${i}px;position:relative`;for(let e=l;e<p;e++){let o=document.createElement("div");o.style.cssText=`position:absolute;top:${e*s}px;height:${s}px;width:100%`,this.renderToDOM(r(t[e],e),o),c.appendChild(o)}e.innerHTML="",e.appendChild(c)},p=()=>{a=e.scrollTop,requestAnimationFrame(l)};return e.addEventListener("scroll",p),l(),{render:l,destroy:()=>{e.removeEventListener("scroll",p),e.innerHTML=""}}}lazy(e){let t=null,r=!1;return async(...s)=>(!t&&!r&&(r=!0,t=await e(),r=!1),t?t(...s):{tagName:"div",props:{class:"loading"},children:["Loading..."]})}cleanupUnusedElements(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r=[];for(;t.nextNode();){let e=t.currentNode;e.id&&e.id.startsWith("r")&&!this.elementCache.has(e)&&r.push(e)}return r.forEach(e=>e.remove()),r.length}renderToString(e,t={}){let{pretty:r=!1,indent:s=0}=t,o=r?" ".repeat(s):"",n=r?"\n":"",i=this.resolveStateValue(e);if(i=this.unwrapReactive(i),Array.isArray(i))return i.map(e=>this.renderToString(e,t)).join("");if("object"!=typeof i||null===i)return null==i||!1===i?"":this.escapeHtml(String(i));let{tagName:a,props:l,children:p}=i,c=this.isSelfClosingTag(a),d=`${o}<${a}`,u=this.propsToAttributes(l);if(u&&(d+=` ${u}`),c)return d+=` />${n}`,d;if(d+=">",l.dangerouslySetInnerHTML)return d+=l.dangerouslySetInnerHTML.__html,d+=`</${a}>${n}`,d;if(p&&p.length>0){let e=p.map(e=>{let t=this.resolveStateValue(e);return this.unwrapReactive(t)}),t=e.some(e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"tagName"in e);if(r&&t){d+=n;for(let t of e)if(null!=t&&!1!==t)if(Array.isArray(t))for(let e of t)null!=e&&!1!==e&&(d+=this.renderToString(e,{pretty:r,indent:s+1}));else d+=this.renderToString(t,{pretty:r,indent:s+1});d+=o}else for(let t of e)if(null!=t&&!1!==t)if(Array.isArray(t))for(let e of t)null!=e&&!1!==e&&(d+=this.renderToString(e,{pretty:!1,indent:0}));else d+=this.renderToString(t,{pretty:!1,indent:0})}return d+=`</${a}>${n}`,d}resolveStateValue(e){return e&&"object"==typeof e&&"value"in e&&"subscribe"in e?e.value:e}isReactiveWrapper(e){return!(!e||"object"!=typeof e||!e.tagName)&&("span"===e.tagName&&e.props?.id&&"string"==typeof e.props.id&&e.props.id.match(/^r[a-z0-9]{9}$/))}unwrapReactive(e){if(!this.isReactiveWrapper(e))return e;let t=e.children;if(!t||0===t.length)return"";if(1===t.length){let e=t[0];if(e&&"object"==typeof e&&"span"===e.tagName){let t=e.props,r=!t||0===Object.keys(t).length,s=e.children&&1===e.children.length&&"string"==typeof e.children[0];if(r&&s)return e.children[0]}return this.unwrapReactive(e)}return t.map(e=>this.unwrapReactive(e))}escapeHtml(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,e=>t[e])}isSelfClosingTag(e){return new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]).has(e.toLowerCase())}propsToAttributes(e){let t=[];for(let r in e){if("children"===r||"dangerouslySetInnerHTML"===r||"ref"===r)continue;let s=e[r];if(s=this.resolveStateValue(s),null!=s&&!1!==s&&(!r.startsWith("on")||"function"!=typeof s)){if("className"===r||"class"===r){let e=Array.isArray(s)?s.join(" "):s;e&&t.push(`class="${this.escapeHtml(String(e))}"`);continue}if("style"===r){let e=this.styleToString(s);e&&t.push(`style="${this.escapeHtml(e)}"`);continue}if(!0===s){t.push(r);continue}t.push(`${r}="${this.escapeHtml(String(s))}"`)}}return t.join(" ")}styleToString(e){if("string"==typeof e)return e;if("object"==typeof e&&null!==e){let t=[];for(let r in e){let s=r.replace(/([A-Z])/g,"-$1").toLowerCase();t.push(`${s}:${e[r]}`)}return t.join(";")}return""}isState(e){return e&&"object"==typeof e&&"value"in e&&"subscribe"in e&&"function"==typeof e.subscribe}createReactiveChild(e,t){let r=t(e.value);if(typeof window<"u"&&typeof document<"u"){let r={node:null,renderFn:t};this.reactiveNodes.set(e,r),e.subscribe(()=>{if(r.node&&r.node.parentNode){let s=t(e.value);r.node.textContent=String(s??"")}})}return r}jsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,e=>e);if(null==e||"boolean"==typeof e||"string"==typeof e||"number"==typeof e)return e;let{tag:t,attributes:r={},children:s}=e,o={};for(let e in r){let t=r[e];"class"===e?o.className=this.isState(t)?t.value:t:o[e]=this.isState(t)?t.value:t}let n=[];if(null!=s)if(Array.isArray(s))for(let e of s)if(this.isState(e))n.push(this.createReactiveChild(e,e=>e));else{let t=this.jsonToVNode(e);null!=t&&!1!==t&&n.push(t)}else if(this.isState(s))n.push(this.createReactiveChild(s,e=>e));else if("object"==typeof s&&"tag"in s){let e=this.jsonToVNode(s);null!=e&&!1!==e&&n.push(e)}else n.push(s);return{tagName:t,props:o,children:n}}vNodeJsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,e=>e);if(null==e||"boolean"==typeof e||"string"==typeof e||"number"==typeof e)return e;let{tagName:t,props:r={},children:s=[]}=e,o={};for(let e in r){let t=r[e];o[e]=this.isState(t)?t.value:t}let n=[];for(let e of s)if(this.isState(e))n.push(this.createReactiveChild(e,e=>e));else{let t=this.vNodeJsonToVNode(e);null!=t&&!1!==t&&n.push(t)}return{tagName:t,props:o,children:n}}renderJson(e,t){let r=this.jsonToVNode(t);if(!r||"object"!=typeof r||!("tagName"in r))throw new Error("Invalid JSON structure");return this.render(e,r)}renderVNode(e,t){let r=this.vNodeJsonToVNode(t);if(!r||"object"!=typeof r||!("tagName"in r))throw new Error("Invalid VNode JSON structure");return this.render(e,r)}renderJsonToString(e,t={}){let r=this.jsonToVNode(e);return this.renderToString(r,t)}renderVNodeToString(e,t={}){let r=this.vNodeJsonToVNode(e);return this.renderToString(r,t)}renderServer(e){if("object"!=typeof e||null===e||!("tagName"in e))throw new Error("renderServer requires a VNode with html tag");if("html"!==e.tagName)throw new Error("renderServer requires a VNode with html tag as root");let t=e,r=null,s=null;for(let e of t.children||[])"object"==typeof e&&null!==e&&"tagName"in e&&("head"===e.tagName&&(r=e),"body"===e.tagName&&(s=e));if(t.props)for(let e in t.props){let r=t.props[e];null!=r&&!1!==r&&document.documentElement.setAttribute(e,String(r))}if(r){document.head.innerHTML="";for(let e of r.children||[])this.renderToDOM(e,document.head)}if(s){if(document.body.innerHTML="",s.props)for(let e in s.props){let t=s.props[e];null!=t&&!1!==t&&document.body.setAttribute(e,String(t))}for(let e of s.children||[])this.renderToDOM(e,document.body)}}renderToHTMLDocument(e,t={}){let{title:r="",meta:s=[],links:o=[],scripts:n=[],styles:i=[],lang:a="en",head:l="",bodyAttrs:p={},pretty:c=!1}=t,d=c?"\n":"",u=c?" ":"",h=c?" ":"",g=`<!DOCTYPE html>${d}<html lang="${a}">${d}${u}<head>${d}${h}<meta charset="UTF-8">${d}${h}<meta name="viewport" content="width=device-width, initial-scale=1.0">${d}`;r&&(g+=`${h}<title>${this.escapeHtml(r)}</title>${d}`);for(let e of s){g+=`${h}<meta`;for(let t in e)g+=` ${t}="${this.escapeHtml(e[t])}"`;g+=`>${d}`}for(let e of o){g+=`${h}<link`;for(let t in e)g+=` ${t}="${this.escapeHtml(e[t])}"`;g+=`>${d}`}for(let e of i)e.href?g+=`${h}<link rel="stylesheet" href="${this.escapeHtml(e.href)}">${d}`:e.content&&(g+=`${h}<style>${e.content}</style>${d}`);l&&(g+=l+d),g+=`${u}</head>${d}${u}<body`;for(let e in p)g+=` ${e}="${this.escapeHtml(p[e])}"`;g+=`>${d}`,g+=this.renderToString(e,{pretty:c,indent:2});for(let e of n)g+=`${h}<script`,e.type&&(g+=` type="${this.escapeHtml(e.type)}"`),e.async&&(g+=" async"),e.defer&&(g+=" defer"),e.src?g+=` src="${this.escapeHtml(e.src)}"><\/script>${d}`:e.content?g+=`>${e.content}<\/script>${d}`:g+=`><\/script>${d}`;return g+=`${u}</body>${d}</html>`,g}getElementCache(){return this.elementCache}},u=new d,h=(e,t)=>u.createState(e,t),g=class{constructor(e,t,r){this.key=e,this.wsUrl=r,this.ws=null,this.pendingUpdates=[],this.localState=h(t),this.previousValue=t,this.connect()}get value(){return this.localState.value}set value(e){this.previousValue=this.localState.value,this.localState.value=e,this.sendToServer(e)}get state(){return this.localState}onChange(e){return this.localState.subscribe(t=>{let r=this.previousValue;this.previousValue=t,e(t,r)})}update(e){this.value=e(this.value)}connect(){if(typeof window>"u")return;let e=this.wsUrl||`ws://${location.host}`;this.ws=new WebSocket(e),this.ws.addEventListener("open",()=>{for(this.subscribe();this.pendingUpdates.length>0;){let e=this.pendingUpdates.shift();this.sendToServer(e)}}),this.ws.addEventListener("message",e=>{this.handleMessage(e.data)}),this.ws.addEventListener("close",()=>{setTimeout(()=>this.connect(),1e3)}),this.ws.addEventListener("error",e=>{console.error("[SharedState] WebSocket error:",e)})}subscribe(){!this.ws||this.ws.readyState!==WebSocket.OPEN||this.ws.send(JSON.stringify({type:"state:subscribe",key:this.key}))}handleMessage(e){try{let t=JSON.parse(e);if(t.key!==this.key)return;("state:init"===t.type||"state:update"===t.type)&&(this.localState.value=t.value)}catch{}}sendToServer(e){if(this.ws){if(this.ws.readyState!==WebSocket.OPEN)return void this.pendingUpdates.push(e);this.ws.send(JSON.stringify({type:"state:change",key:this.key,value:e}))}}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}destroy(){this.disconnect(),this.localState.destroy()}};var m=new class{constructor(){this.states=new Map}create(e,t,r){if(this.states.has(e))return this.states.get(e);let s=new g(e,t,r);return this.states.set(e,s),s}get(e){return this.states.get(e)}delete(e){let t=this.states.get(e);return!!t&&(t.destroy(),this.states.delete(e))}clear(){this.states.forEach(e=>e.destroy()),this.states.clear()}},f=(e,t)=>{let r=null,s=null,o=null,n=!0,i=t(e.value),a=i&&"object"==typeof i&&"tagName"in i,l=null==i||!1===i;e.subscribe(()=>{r&&cancelAnimationFrame(r),r=requestAnimationFrame(()=>{(()=>{if(!s&&!o)return;let r=t(e.value);if(null==r||!1===r)n&&s&&(o=document.createComment("reactive"),s.parentNode?.replaceChild(o,s),n=!1);else if(!n&&o&&s&&(o.parentNode?.replaceChild(s,o),o=null,n=!0),s){let e=document.createDocumentFragment();if(a&&r&&"object"==typeof r&&"tagName"in r){let{props:t,children:o}=r;for(let e in t){let r=t[e];if("ref"!==e)if("class"===e||"className"===e)s.className=Array.isArray(r)?r.join(" "):r||"";else if("style"===e&&"object"==typeof r){let e=s.style;for(let t in r)e[t]=r[t]}else e.startsWith("on")?s[e.toLowerCase()]=r:null!=r&&!1!==r?s.setAttribute(e,String(!0===r?"":r)):s.removeAttribute(e)}for(let t of o)u.renderToDOM(t,e)}else u.renderToDOM(r,e);s.textContent="",s.appendChild(e),u.getElementCache().set(s,!0)}})(),r=null})});let p=e=>{s=e,l&&e.parentNode&&(o=document.createComment("reactive"),e.parentNode.replaceChild(o,e),n=!1)};if(a){let e=i;return{tagName:e.tagName,props:{...e.props,ref:p},children:e.children}}return{tagName:"span",props:{ref:p},children:[i]}},y=e=>function(t,...r){if(!arguments.length)return{tagName:e,props:{},children:[]};let s=t&&"object"==typeof t&&"value"in t&&"subscribe"in t,o=t&&"object"==typeof t&&"tagName"in t,n="object"!=typeof t||Array.isArray(t)||null===t||s||o,i=n?{}:t,a=n?[t,...r]:r;if(!a.length)return{tagName:e,props:i,children:[]};let l=[];for(let e=0,t=a.length;e<t;e++){let t=a[e];if(null!=t&&!1!==t)if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++){let r=t[e];null!=r&&!1!==r&&l.push(r)}else l.push(t)}return{tagName:e,props:i,children:l}},v={};["html","head","body","title","base","link","meta","style","address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","main","nav","section","blockquote","dd","div","dl","dt","figcaption","figure","hr","li","ol","p","pre","ul","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rp","rt","ruby","s","samp","small","span","strong","sub","sup","time","u","wbr","area","audio","img","map","track","video","embed","iframe","object","param","picture","portal","source","canvas","noscript","script","del","ins","caption","col","colgroup","table","tbody","td","tfoot","th","thead","tr","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","menu","summary","slot","template"].forEach(e=>{v[e]=y(e)}),["svg","circle","rect","path","line","polyline","polygon","ellipse","g","text","tspan","defs","linearGradient","radialGradient","stop","pattern","mask","clipPath","use","symbol","marker","image","foreignObject","animate","animateTransform","animateMotion","set","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"].forEach(e=>{let t="svg"+e.charAt(0).toUpperCase()+e.slice(1);v[t]=y(e)}),["math","mi","mn","mo","ms","mtext","mrow","mfrac","msqrt","mroot","msub","msup"].forEach(e=>{let t="math"+e.charAt(0).toUpperCase()+e.slice(1);v[t]=y(e)}),v.varElement=y("var");var{head:x,body:b,title:w,base:$,link:S,meta:E,style:T,address:C,article:N,aside:M,footer:R,header:k,h1:j,h2:F,h3:H,h4:O,h5:A,h6:D,main:P,nav:W,section:L,blockquote:q,dd:B,div:U,dl:I,dt:J,figcaption:V,figure:_,hr:G,li:z,ol:K,p:X,pre:Z,ul:Y,a:Q,abbr:ee,b:te,bdi:re,bdo:se,br:oe,cite:ne,code:ie,data:ae,dfn:le,em:pe,i:ce,kbd:de,mark:ue,q:he,rp:ge,rt:me,ruby:fe,s:ye,samp:ve,small:xe,span:be,strong:we,sub:$e,sup:Se,time:Ee,u:Te,wbr:Ce,area:Ne,audio:Me,img:Re,map:ke,track:je,video:Fe,embed:He,iframe:Oe,object:Ae,param:De,picture:Pe,portal:We,source:Le,canvas:qe,noscript:Be,script:Ue,del:Ie,ins:Je,caption:Ve,col:_e,colgroup:Ge,table:ze,tbody:Ke,td:Xe,tfoot:Ze,th:Ye,thead:Qe,tr:et,button:tt,datalist:rt,fieldset:st,form:ot,input:nt,label:it,legend:at,meter:lt,optgroup:pt,option:ct,output:dt,progress:ut,select:ht,textarea:gt,details:mt,dialog:ft,menu:yt,summary:vt,slot:xt,template:bt,svgSvg:wt,svgCircle:$t,svgRect:St,svgPath:Et,svgLine:Tt,svgPolyline:Ct,svgPolygon:Nt,svgEllipse:Mt,svgG:Rt,svgText:kt,svgTspan:jt,svgDefs:Ft,svgLinearGradient:Ht,svgRadialGradient:Ot,svgStop:At,svgPattern:Dt,svgMask:Pt,svgClipPath:Wt,svgUse:Lt,svgSymbol:qt,svgMarker:Bt,svgImage:Ut,svgForeignObject:It,svgAnimate:Jt,svgAnimateTransform:Vt,svgAnimateMotion:_t,svgSet:Gt,svgFilter:zt,svgFeBlend:Kt,svgFeColorMatrix:Xt,svgFeComponentTransfer:Zt,svgFeComposite:Yt,svgFeConvolveMatrix:Qt,svgFeDiffuseLighting:er,svgFeDisplacementMap:tr,svgFeFlood:rr,svgFeGaussianBlur:sr,svgFeMorphology:or,svgFeOffset:nr,svgFeSpecularLighting:ir,svgFeTile:ar,svgFeTurbulence:lr,mathMath:pr,mathMi:cr,mathMn:dr,mathMo:ur,mathMs:hr,mathMtext:gr,mathMrow:mr,mathMfrac:fr,mathMsqrt:yr,mathMroot:vr,mathMsub:xr,mathMsup:br,varElement:wr}=v,$r=v,Sr=document,Er=Sr.querySelector.bind(Sr),Tr=Sr.querySelectorAll.bind(Sr),Cr=Sr.createElement.bind(Sr),Nr=Sr.createElementNS.bind(Sr,"http://www.w3.org/2000/svg"),Mr=Sr.createElementNS.bind(Sr,"http://www.w3.org/1998/Math/MathML"),Rr=Sr.createDocumentFragment.bind(Sr),kr=Sr.createTextNode.bind(Sr),jr=Sr.createComment.bind(Sr),Fr=Sr.getElementById.bind(Sr),Hr=Sr.getElementsByClassName.bind(Sr),Or=Sr.getElementsByTagName.bind(Sr),Ar=Sr.getElementsByName.bind(Sr);function Dr(e,t){let r=e.split("/").filter(Boolean),s=t.split("/").filter(Boolean);if(e.endsWith("*")){let r=e.slice(0,-1);if(t.startsWith(r)||"/"===r||"*"===e)return{"*":t.slice(r.length)}}if(r.length!==s.length)return null;let o={};for(let e=0;e<r.length;e++){let t=r[e],n=s[e];if(t.startsWith(":"))o[t.slice(1)]=decodeURIComponent(n);else if(t!==n)return null}return o}var Pr=class{constructor(){this.routes=[],this.middlewares=[]}use(e){return this.middlewares.push(e),this}get(e,t){return this.addRoute("GET",e,t)}post(e,t){return this.addRoute("POST",e,t)}put(e,t){return this.addRoute("PUT",e,t)}delete(e,t){return this.addRoute("DELETE",e,t)}patch(e,t){return this.addRoute("PATCH",e,t)}options(e,t){return this.addRoute("OPTIONS",e,t)}addRoute(e,t,r){let{pattern:s,paramNames:o}=this.pathToRegex(t);return this.routes.push({method:e,pattern:s,paramNames:o,handler:r}),this}pathToRegex(e){let t=[],r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\//g,"\\/").replace(/:(\w+)/g,(e,r)=>(t.push(r),"([^\\/]+)"));return{pattern:new RegExp(`^${r}$`),paramNames:t}}parseQuery(e){let t={},r=e.split("?")[1];return r&&new URLSearchParams(r).forEach((e,r)=>t[r]=e),t}async parseBody(e){return new Promise((t,r)=>{let s="";e.on("data",e=>s+=e.toString()),e.on("end",()=>{try{let r=e.headers["content-type"]||"";if(r.includes("application/json"))t(s?JSON.parse(s):{});else if(r.includes("application/x-www-form-urlencoded")){let e={};new URLSearchParams(s).forEach((t,r)=>e[r]=t),t(e)}else t(s)}catch(e){r(e)}}),e.on("error",r)})}async handle(e,t){let r=e.method,s=e.url||"/",o=s.split("?")[0];for(let n of this.routes){if(n.method!==r)continue;let i=o.match(n.pattern);if(!i)continue;let a={};n.paramNames.forEach((e,t)=>{a[e]=i[t+1]});let l=this.parseQuery(s),p={};if(["POST","PUT","PATCH"].includes(r))try{p=await this.parseBody(e)}catch{return t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Invalid request body"})),!0}let c={req:e,res:t,params:a,query:l,body:p,headers:e.headers},d=0,u=async()=>{if(d<this.middlewares.length){let e=this.middlewares[d++];await e(c,u)}};try{await u(),await n.handler(c)}catch(e){console.error("Route handler error:",e),t.headersSent||(t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Internal Server Error",message:e instanceof Error?e.message:"Unknown error"})))}return!0}return!1}};function Wr(e){return async(s,o)=>{let n=s.url||"/",i=n.split("?")[0],a=e.find(e=>i.startsWith(e.context));if(!a)return!1;let{target:l,changeOrigin:p,pathRewrite:c,headers:d}=a;try{let e=new URL(l),i="https:"===e.protocol,a=i?r.request:t.request,u=function(e,t){if(!t)return e;for(let[r,s]of Object.entries(t)){let t=new RegExp(r);if(t.test(e))return e.replace(t,s)}return e}(n,c),h={hostname:e.hostname,port:e.port||(i?443:80),path:u,method:s.method,headers:{...s.headers,...d||{}}};p&&(h.headers.host=e.host),delete h.headers.host;let g=a(h,e=>{o.writeHead(e.statusCode||200,e.headers),e.pipe(o)});return g.on("error",e=>{console.error("[Proxy] Error proxying %s to %s:",n,l,e.message),o.headersSent||(o.writeHead(502,{"Content-Type":"application/json"}),o.end(JSON.stringify({error:"Bad Gateway",message:"Proxy error"})))}),s.pipe(g),!0}catch(e){return console.error("[Proxy] Invalid proxy configuration for %s:",i,e),!1}}}var Lr=class{constructor(e,t){this.key=e,this.listeners=new Set,this.changeHandlers=new Set,this.options=t,this._value=t.initial}get value(){return this._value}set value(e){if(this.options.validate&&!this.options.validate(e))throw new Error(`Invalid state value for "${this.key}"`);let t=this._value;this._value=e,this.changeHandlers.forEach(r=>{r(e,t)}),this.broadcast()}update(e){this.value=e(this._value)}subscribe(e){this.listeners.add(e),this.sendTo(e)}unsubscribe(e){this.listeners.delete(e)}onChange(e){return this.changeHandlers.add(e),()=>this.changeHandlers.delete(e)}broadcast(){let e=JSON.stringify({type:"state:update",key:this.key,value:this._value,timestamp:Date.now()});this.listeners.forEach(t=>t.readyState===s.WebSocket.OPEN&&t.send(e))}sendTo(e){e.readyState===s.WebSocket.OPEN&&e.send(JSON.stringify({type:"state:init",key:this.key,value:this._value,timestamp:Date.now()}))}get subscriberCount(){return this.listeners.size}clear(){this.listeners.clear(),this.changeHandlers.clear()}},qr=class{constructor(){this.states=new Map}create(e,t){if(this.states.has(e))return this.states.get(e);let r=new Lr(e,t);return this.states.set(e,r),r}get(e){return this.states.get(e)}has(e){return this.states.has(e)}delete(e){let t=this.states.get(e);return!!t&&(t.clear(),this.states.delete(e))}subscribe(e,t){this.states.get(e)?.subscribe(t)}unsubscribe(e,t){this.states.get(e)?.unsubscribe(t)}unsubscribeAll(e){this.states.forEach(t=>t.unsubscribe(e))}handleStateChange(e,t){let r=this.states.get(e);r&&(r.value=t)}keys(){return Array.from(this.states.keys())}clear(){this.states.forEach(e=>e.clear()),this.states.clear()}},Br={port:3e3,host:"localhost",https:!1,open:!0,watch:["**/*.ts","**/*.js","**/*.html","**/*.css"],ignore:["node_modules/**","dist/**",".git/**","**/*.d.ts"],logging:!0,middleware:[],worker:[]};var Ur=new class{constructor(){this.enabled=!1,this.ws=null,this.acceptCallbacks=[],this.disposeCallbacks=[],this.declined=!1,typeof window>"u"||this.connect()}connect(){let e="https:"===window.location.protocol?"wss:":"ws:",t=window.location.hostname,r=window.location.port||"3000";this.ws=new WebSocket(`${e}//${t}:${r}`),this.ws.onopen=()=>{this.enabled=!0,console.log("[Elit HMR] Connected ✓")},this.ws.onmessage=e=>{try{let t=JSON.parse(e.data);this.handleMessage(t)}catch(e){console.error("[Elit HMR] Error parsing message:",e)}},this.ws.onclose=()=>{this.enabled=!1,console.log("[Elit HMR] Disconnected - Attempting reconnect..."),setTimeout(()=>this.reload(),1e3)},this.ws.onerror=e=>{console.error("[Elit HMR] WebSocket error:",e)}}handleMessage(e){switch(e.type){case"connected":console.log("[Elit HMR] Ready");break;case"update":if(console.log(`[Elit HMR] Update detected: ${e.path}`),this.declined)return void this.reload();this.disposeCallbacks.forEach(e=>e()),this.disposeCallbacks=[],this.acceptCallbacks.length>0?this.acceptCallbacks.forEach(e=>e()):this.reload();break;case"reload":console.log("[Elit HMR] Full reload requested"),this.reload();break;case"error":console.error("[Elit HMR] Server error:",e.error)}}reload(){window.location.reload()}accept(e){e&&this.acceptCallbacks.push(e),this.declined=!1}decline(){this.declined=!0}dispose(e){this.disposeCallbacks.push(e)}};typeof window<"u"&&(window.__ELIT_HMR__=Ur);var Ir=Ur,Jr={outDir:"dist",minify:!0,sourcemap:!1,target:"es2020",format:"esm",treeshake:!0,logging:!0,external:[]};function Vr(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}var _r=["elit.config.ts","elit.config.js","elit.config.mjs","elit.config.cjs","elit.config.json"];async function Gr(e){let t=e.split(".").pop();if("json"===t){let t=p.readFileSync(e,"utf-8");return JSON.parse(t)}if("ts"!==t){let{pathToFileURL:t}=await import("url"),r=await import(t(e).href);return r.default||r}try{let{pathToFileURL:t}=await import("url"),r=await import(t(e).href);return r.default||r}catch{throw console.error("TypeScript config files require tsx or ts-node to be installed."),console.error("Install with: npm install -D tsx"),console.error("Or use a .js or .json config file instead."),new Error("Cannot load TypeScript config without tsx/ts-node")}}exports.ApiRouter=Pr,exports.CreateStyle=class{constructor(){this.variables=[],this.rules=[],this.mediaRules=[],this.keyframes=[],this.fontFaces=[],this.imports=[],this.containerRules=[],this.supportsRules=[],this.layerRules=[],this._layerOrder=[]}addVar(e,t){let r={name:e.startsWith("--")?e:`--${e}`,value:t,toString(){return`var(${this.name})`}};return this.variables.push(r),r}var(e,t){let r="string"==typeof e?e.startsWith("--")?e:`--${e}`:e.name;return t?`var(${r}, ${t})`:`var(${r})`}addTag(e,t){let r={selector:e,styles:t,type:"tag"};return this.rules.push(r),r}addClass(e,t){let r={selector:e.startsWith(".")?e:`.${e}`,styles:t,type:"class"};return this.rules.push(r),r}addId(e,t){let r={selector:e.startsWith("#")?e:`#${e}`,styles:t,type:"id"};return this.rules.push(r),r}addPseudoClass(e,t,r){let s=e.startsWith(":")?e:`:${e}`,o={selector:r?`${r}${s}`:s,styles:t,type:"pseudo-class"};return this.rules.push(o),o}addPseudoElement(e,t,r){let s=e.startsWith("::")?e:`::${e}`,o={selector:r?`${r}${s}`:s,styles:t,type:"pseudo-element"};return this.rules.push(o),o}addAttribute(e,t,r){let s=e.startsWith("[")?e:`[${e}]`,o={selector:r?`${r}${s}`:s,styles:t,type:"attribute"};return this.rules.push(o),o}attrEquals(e,t,r,s){return this.addAttribute(`${e}="${t}"`,r,s)}attrContainsWord(e,t,r,s){return this.addAttribute(`${e}~="${t}"`,r,s)}attrStartsWith(e,t,r,s){return this.addAttribute(`${e}^="${t}"`,r,s)}attrEndsWith(e,t,r,s){return this.addAttribute(`${e}$="${t}"`,r,s)}attrContains(e,t,r,s){return this.addAttribute(`${e}*="${t}"`,r,s)}descendant(e,t,r){let s={selector:`${e} ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}child(e,t,r){let s={selector:`${e} > ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}adjacentSibling(e,t,r){let s={selector:`${e} + ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}generalSibling(e,t,r){let s={selector:`${e} ~ ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}multiple(e,t){let r={selector:e.join(", "),styles:t,type:"custom"};return this.rules.push(r),r}addName(e,t){return{selector:e.startsWith("--")?`&${e}`:`&--${e}`,styles:t,type:"name"}}nesting(e,...t){return e.nested=t,e}keyframe(e,t){let r={name:e,steps:Object.entries(t).map(([e,t])=>({step:"from"===e?"from":"to"===e?"to":`${e}%`,styles:t}))};return this.keyframes.push(r),r}keyframeFromTo(e,t,r){return this.keyframe(e,{from:t,to:r})}fontFace(e){return this.fontFaces.push(e),e}import(e,t){let r=t?`@import url("${e}") ${t};`:`@import url("${e}");`;return this.imports.push(r),r}media(e,t,r){let s={type:e,condition:t,rules:Object.entries(r).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(s),s}mediaScreen(e,t){return this.media("screen",e,t)}mediaPrint(e){return this.media("print","",e)}mediaMinWidth(e,t){return this.media("screen",`min-width: ${e}`,t)}mediaMaxWidth(e,t){return this.media("screen",`max-width: ${e}`,t)}mediaDark(e){let t={type:"",condition:"prefers-color-scheme: dark",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}mediaLight(e){let t={type:"",condition:"prefers-color-scheme: light",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}mediaReducedMotion(e){let t={type:"",condition:"prefers-reduced-motion: reduce",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}container(e,t,r){let s={name:r,condition:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.containerRules.push(s),s}addContainer(e,t){let r={...t,containerName:e};return this.addClass(e,r)}supports(e,t){let r={condition:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.supportsRules.push(r),r}layerOrder(...e){this._layerOrder=e}layer(e,t){let r={name:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.layerRules.push(r),r}add(e){return Object.entries(e).map(([e,t])=>{let r={selector:e,styles:t,type:"custom"};return this.rules.push(r),r})}important(e){return`${e} !important`}toKebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}stylesToString(e,t=" "){return Object.entries(e).map(([e,r])=>{let s="object"==typeof r&&null!==r&&"name"in r?`var(${r.name})`:r;return`${t}${this.toKebabCase(e)}: ${s};`}).join("\n")}renderRule(e,t=""){let r=`${t}${e.selector} {\n${this.stylesToString(e.styles,t+" ")}\n`;if(e.nested&&e.nested.length>0)for(let s of e.nested){r+=`\n${t}${s.selector.startsWith("&")?s.selector.replace(/&/g,e.selector):`${e.selector} ${s.selector}`} {\n${this.stylesToString(s.styles,t+" ")}\n${t}}\n`}return r+=`${t}}`,r}renderMediaRule(e){let t=`@media ${e.type&&e.condition?`${e.type} and (${e.condition})`:e.type?e.type:`(${e.condition})`} {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}renderKeyframes(e){let t=`@keyframes ${e.name} {\n`;for(let r of e.steps)t+=` ${r.step} {\n${this.stylesToString(r.styles," ")}\n }\n`;return t+="}",t}renderFontFace(e){let t="@font-face {\n";return t+=` font-family: "${e.fontFamily}";\n`,t+=` src: ${e.src};\n`,e.fontWeight&&(t+=` font-weight: ${e.fontWeight};\n`),e.fontStyle&&(t+=` font-style: ${e.fontStyle};\n`),e.fontDisplay&&(t+=` font-display: ${e.fontDisplay};\n`),e.unicodeRange&&(t+=` unicode-range: ${e.unicodeRange};\n`),t+="}",t}renderContainerRule(e){let t=`@container ${e.name?`${e.name} `:""}(${e.condition}) {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}renderSupportsRule(e){let t=`@supports (${e.condition}) {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}renderLayerRule(e){let t=`@layer ${e.name} {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}render(...e){let t=[];if(this.imports.length>0&&t.push(this.imports.join("\n")),this._layerOrder.length>0&&t.push(`@layer ${this._layerOrder.join(", ")};`),this.variables.length>0){let e=this.variables.map(e=>` ${e.name}: ${e.value};`).join("\n");t.push(`:root {\n${e}\n}`)}for(let e of this.fontFaces)t.push(this.renderFontFace(e));for(let e of this.keyframes)t.push(this.renderKeyframes(e));let r=[...this.rules],s=[...this.mediaRules],o=[],n=[...this.containerRules],i=[...this.supportsRules],a=[...this.layerRules];for(let t of e)t&&(Array.isArray(t)?r.push(...t):!("condition"in t)||!("rules"in t)||"name"in t&&"steps"in t?"name"in t&&"steps"in t?o.push(t):"name"in t&&"rules"in t?a.push(t):r.push(t):"type"in t?s.push(t):"name"in t&&"string"==typeof t.name?n.push(t):i.push(t));for(let e of o)t.push(this.renderKeyframes(e));for(let e of a)t.push(this.renderLayerRule(e));for(let e of r)t.push(this.renderRule(e));for(let e of i)t.push(this.renderSupportsRule(e));for(let e of n)t.push(this.renderContainerRule(e));for(let e of s)t.push(this.renderMediaRule(e));return t.join("\n\n")}inject(e){let t=this.render(),r=document.createElement("style");return e&&(r.id=e),r.textContent=t,document.head.appendChild(r),r}clear(){this.variables=[],this.rules=[],this.mediaRules=[],this.keyframes=[],this.fontFaces=[],this.imports=[],this.containerRules=[],this.supportsRules=[],this.layerRules=[],this._layerOrder=[]}},exports.DomNode=d,exports.ServerRouter=Pr,exports.SharedState=Lr,exports.StateManager=qr,exports.a=Q,exports.abbr=ee,exports.address=C,exports.area=Ne,exports.article=N,exports.aside=M,exports.audio=Me,exports.b=te,exports.base=$,exports.batchRender=(e,t)=>u.batchRender(e,t),exports.bdi=re,exports.bdo=se,exports.bindChecked=e=>({checked:e.value,onchange:t=>{e.value=t.target.checked}}),exports.bindValue=e=>({value:e.value,oninput:t=>{e.value=t.target.value}}),exports.blockquote=q,exports.body=b,exports.bodyLimit=function(e={}){let{limit:t=1048576}=e;return async(e,r)=>{if(parseInt(e.req.headers["content-length"]||"0",10)>t)return e.res.writeHead(413,{"Content-Type":"application/json"}),void e.res.end(JSON.stringify({error:"Request body too large"}));await r()}},exports.br=oe,exports.build=async function(e){let t={...Jr,...e},r=Date.now();if(!t.entry)throw new Error("Entry file is required");let s=i.resolve(t.entry),o=i.resolve(t.outDir),n=t.outFile;if(!n){n=i.basename(t.entry,i.extname(t.entry))+("cjs"===t.format?".cjs":".js")}let a=i.join(o,n);try{p.mkdirSync(o,{recursive:!0})}catch{}t.logging&&(console.log("\n🔨 Building..."),console.log(` Entry: ${t.entry}`),console.log(` Output: ${a}`),console.log(` Format: ${t.format}`),console.log(` Target: ${t.target}`));let c={name:"browser-only",setup(e){e.onResolve({filter:/^(node:.*|fs|path|http|https|url|os|child_process|net|tls|crypto|stream|util|events|buffer|zlib|readline|process|assert|constants|dns|domain|punycode|querystring|repl|string_decoder|sys|timers|tty|v8|vm)$/},()=>({path:"node-builtin",external:!0,sideEffects:!1})),e.onResolve({filter:/^(chokidar|esbuild|mime-types|open|ws|fs\/promises)$/},()=>({path:"server-dep",external:!0,sideEffects:!1})),e.onLoad({filter:/[\\/](server|config|cli)\.ts$/},()=>({contents:"export {}",loader:"js"}))}};try{let e=t.platform||("cjs"===t.format?"node":"browser"),n="browser"===e?[c]:[],d={};t.env&&(Object.entries(t.env).forEach(([e,t])=>{e.startsWith("VITE_")&&(d[`import.meta.env.${e}`]=JSON.stringify(t))}),t.env.MODE&&(d["import.meta.env.MODE"]=JSON.stringify(t.env.MODE)),d["import.meta.env.DEV"]=JSON.stringify("production"!==t.env.MODE),d["import.meta.env.PROD"]=JSON.stringify("production"===t.env.MODE));let u=await l.build({entryPoints:[s],bundle:!0,outfile:a,format:t.format,target:t.target,minify:t.minify,sourcemap:t.sourcemap,external:t.external,treeShaking:t.treeshake,globalName:t.globalName,platform:e,plugins:n,define:d,logLevel:t.logging?"info":"silent",metafile:!0,...t.minify&&{minifyWhitespace:!0,minifyIdentifiers:!0,minifySyntax:!0,legalComments:"none",mangleProps:/^_/,keepNames:!1}}),h=Date.now()-r,g=p.statSync(a).size;if(t.logging&&(console.log("\n✅ Build successful!"),console.log(` Time: ${h}ms`),console.log(` Size: ${Vr(g)}`),u.metafile)){let e=Object.keys(u.metafile.inputs).length;console.log(` Files: ${e} input(s)`);let t=Object.keys(u.metafile.outputs);if(t.length>0){let e=u.metafile.outputs[t[0]];if(e&&e.inputs){let t=Object.entries(e.inputs).sort(([,e],[,t])=>t.bytesInOutput-e.bytesInOutput).slice(0,5);t.length>0&&(console.log("\n 📊 Top 5 largest modules:"),t.forEach(([e,t])=>{let r=e.split(/[/\\]/).pop()||e;console.log(` ${r.padEnd(30)} ${Vr(t.bytesInOutput)}`)}))}}}let m={outputPath:a,buildTime:h,size:g};if(t.copy&&t.copy.length>0){t.logging&&console.log("\n📦 Copying files...");for(let e of t.copy){let r=i.resolve(e.from),s=i.resolve(o,e.to),n=i.dirname(s);if(p.existsSync(n)||p.mkdirSync(n,{recursive:!0}),p.existsSync(r)){if(e.transform){let o=p.readFileSync(r,"utf-8"),n=e.transform(o,t);p.writeFileSync(s,n)}else p.copyFileSync(r,s);t.logging&&console.log(` ✓ ${e.from} → ${e.to}`)}else t.logging&&console.warn(` ⚠ File not found: ${e.from}`)}}return t.onBuildEnd&&await t.onBuildEnd(m),t.logging&&console.log(""),m}catch(e){throw t.logging&&(console.error("\n❌ Build failed:"),console.error(e)),e}},exports.button=tt,exports.cacheControl=function(e={}){let{maxAge:t=3600,public:r=!0}=e;return async(e,s)=>{e.res.setHeader("Cache-Control",`${r?"public":"private"}, max-age=${t}`),await s()}},exports.canvas=qe,exports.caption=Ve,exports.cite=ne,exports.cleanupUnused=e=>u.cleanupUnusedElements(e),exports.code=ie,exports.col=_e,exports.colgroup=Ge,exports.commentNode=jr,exports.compress=function(){return async(e,t)=>{if(!(e.req.headers["accept-encoding"]||"").includes("gzip"))return void await t();let r=e.res.end.bind(e.res),s=[];e.res.write=e=>(s.push(Buffer.from(e)),!0),e.res.end=t=>{t&&s.push(Buffer.from(t));let o=Buffer.concat(s),{gzipSync:n}=c("zlib"),i=n(o);return e.res.setHeader("Content-Encoding","gzip"),e.res.setHeader("Content-Length",i.length),r(i),e.res},await t()}},exports.computed=(e,t)=>u.computed(e,t),exports.cors=function(e={}){let{origin:t="*",methods:r=["GET","POST","PUT","DELETE","PATCH","OPTIONS"],credentials:s=!0,maxAge:o=86400}=e;return async(e,n)=>{let i=e.req.headers.origin||"",a=Array.isArray(t)&&t.includes(i)?i:Array.isArray(t)?"":t;if(a&&e.res.setHeader("Access-Control-Allow-Origin",a),e.res.setHeader("Access-Control-Allow-Methods",r.join(", ")),e.res.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization"),s&&e.res.setHeader("Access-Control-Allow-Credentials","true"),e.res.setHeader("Access-Control-Max-Age",String(o)),"OPTIONS"===e.req.method)return e.res.writeHead(204),void e.res.end();await n()}},exports.createDevServer=function(e){let r={...Br,...e},p=new Set,d=new qr,h=r.clients?.length?r.clients:r.root?[{root:r.root,basePath:r.basePath||"",ssr:r.ssr,proxy:r.proxy}]:null;if(!h)throw new Error('DevServerOptions must include either "clients" array or "root" directory');let g=h.map(e=>{let t=e.basePath||"";if(t){for(;t.startsWith("/");)t=t.slice(1);for(;t.endsWith("/");)t=t.slice(0,-1);t=t?"/"+t:""}return{root:e.root,basePath:t,ssr:e.ssr,proxyHandler:e.proxy?Wr(e.proxy):void 0}}),m=r.proxy?Wr(r.proxy):null,f=t.createServer(async(e,t)=>{let s=e.url||"/",o=g.find(e=>e.basePath&&s.startsWith(e.basePath))||g.find(e=>!e.basePath);if(!o)return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found");if(o.proxyHandler)try{if(await o.proxyHandler(e,t))return void(r.logging&&console.log(`[Proxy] ${e.method} ${s} -> proxied (client-specific)`))}catch(e){console.error("[Proxy] Error (client-specific):",e)}if(m)try{if(await m(e,t))return void(r.logging&&console.log(`[Proxy] ${e.method} ${s} -> proxied (global)`))}catch(e){console.error("[Proxy] Error (global):",e)}let a=o.basePath?s.slice(o.basePath.length)||"/":s;if(r.api&&a.startsWith("/api")&&await r.api.handle(e,t))return;let l="/"===a?"/index.html":a;if(l=l.split("?")[0],r.logging&&"/src/pages"===l&&console.log("[DEBUG] Request for /src/pages received"),l.includes("\0"))return r.logging&&console.log(`[403] Rejected path with null byte: ${l}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");let p,c=l.startsWith("/dist/"),d=i.normalize(l).replace(/\\/g,"/").replace(/^\/+/,"");if(d.includes(".."))return r.logging&&console.log(`[403] Path traversal attempt: ${l}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");p=d;let u,h=await n.realpath(i.resolve(o.root)),f=c?await n.realpath(i.resolve(o.root,"..")):h;try{if(u=await n.realpath(i.resolve(i.join(f,p))),!u.startsWith(f.endsWith(i.sep)?f:f+i.sep))return r.logging&&console.log(`[403] File access outside of root: ${u}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");r.logging&&"/src/pages"===l&&console.log(`[DEBUG] Initial resolve succeeded: ${u}`)}catch{let e;if(r.logging&&!p.includes(".")&&console.log(`[DEBUG] File not found: ${p}, trying extensions...`),p.endsWith(".js")){let s=p.replace(/\.js$/,".ts");try{let o=await n.realpath(i.resolve(i.join(f,s)));if(!o.startsWith(f.endsWith(i.sep)?f:f+i.sep))return r.logging&&console.log(`[403] Fallback TS path outside of root: ${o}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");e=o}catch{}}if(!e&&!p.includes("."))try{e=await n.realpath(i.resolve(i.join(f,p+".ts"))),r.logging&&console.log(`[DEBUG] Found: ${p}.ts`)}catch{try{e=await n.realpath(i.resolve(i.join(f,p+".js"))),r.logging&&console.log(`[DEBUG] Found: ${p}.js`)}catch{try{e=await n.realpath(i.resolve(i.join(f,p,"index.ts"))),r.logging&&console.log(`[DEBUG] Found: ${p}/index.ts`)}catch{try{e=await n.realpath(i.resolve(i.join(f,p,"index.js"))),r.logging&&console.log(`[DEBUG] Found: ${p}/index.js`)}catch{r.logging&&console.log(`[DEBUG] Not found: all attempts failed for ${p}`)}}}}if(!e)return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found");u=e}try{if((await n.stat(u)).isDirectory()){let e;r.logging&&console.log(`[DEBUG] Path is directory: ${u}, trying index files...`);try{e=await n.realpath(i.resolve(i.join(u,"index.ts"))),r.logging&&console.log("[DEBUG] Found index.ts in directory")}catch{try{e=await n.realpath(i.resolve(i.join(u,"index.js"))),r.logging&&console.log("[DEBUG] Found index.js in directory")}catch{return r.logging&&console.log("[DEBUG] No index file found in directory"),t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found")}}u=e}}catch{return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found")}let v=await n.realpath(i.resolve(o.root,"..")),x=u.startsWith(h+i.sep)||u===h,b=c&&(u.startsWith(v+i.sep)||u===v);if(!x&&!b)return r.logging&&console.log(`[403] Path outside allowed directories: ${l}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");try{if((await n.stat(u)).isDirectory())try{let e=await n.realpath(i.resolve(i.join(u,"index.html")));return e.startsWith(h+i.sep)||e===h?(await n.stat(e),y(e,t,o)):(t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden"))}catch{return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found")}await y(u,t,o)}catch{r.logging&&console.log(`[404] ${l}`),t.writeHead(404,{"Content-Type":"text/plain"}),t.end("404 Not Found")}});async function y(e,t,s){try{let o,p=await n.realpath(i.resolve(s.root)),d=await n.realpath(i.resolve(s.root,".."));try{o=await n.realpath(i.resolve(e))}catch{return e.endsWith("index.html")&&s.ssr?function(e,t){try{if(!t.ssr)return e.writeHead(500,{"Content-Type":"text/plain"}),void e.end("SSR function not configured");let s,o=t.ssr();if("string"==typeof o)s=o;else if("object"==typeof o&&null!==o&&"tagName"in o){let e=o;s="html"===e.tagName?u.renderToString(e):`<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"></head><body>${u.renderToString(e)}</body></html>`}else s=String(o);let n=`<script>(function(){const ws=new WebSocket('ws://${r.host}:${r.port}${t.basePath}');ws.onopen=()=>console.log('[Elit HMR] Connected');ws.onmessage=(e)=>{const d=JSON.parse(e.data);if(d.type==='update'){console.log('[Elit HMR] File updated:',d.path);window.location.reload()}else if(d.type==='reload'){console.log('[Elit HMR] Reloading...');window.location.reload()}else if(d.type==='error')console.error('[Elit HMR] Error:',d.error)};ws.onclose=()=>{console.log('[Elit HMR] Disconnected - Retrying...');setTimeout(()=>window.location.reload(),1000)};ws.onerror=(e)=>console.error('[Elit HMR] WebSocket error:',e)})();<\/script>`;s=s.includes("</body>")?s.replace("</body>",`${n}</body>`):s+n,e.writeHead(200,{"Content-Type":"text/html","Cache-Control":"no-cache, no-store, must-revalidate"}),e.end(s),r.logging&&console.log("[200] SSR rendered")}catch(t){e.writeHead(500,{"Content-Type":"text/plain"}),e.end("500 SSR Error"),r.logging&&console.error("[500] SSR Error:",t)}}(t,s):(t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found"))}let h=o.startsWith(p+i.sep)||o===p,g=o.startsWith(d+i.sep+"dist"+i.sep);if(!h&&!g)return r.logging&&console.log(`[403] Attempted to serve file outside allowed directories: ${e}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");let m=await n.readFile(o),f=i.extname(o),y=a.lookup(o)||"application/octet-stream";if(".ts"===f||".tsx"===f)try{let e=await l.build({stdin:{contents:m.toString(),loader:".tsx"===f?"tsx":"ts",resolveDir:i.resolve(o,".."),sourcefile:o},format:"esm",target:"es2020",write:!1,bundle:!1,sourcemap:"inline"});m=Buffer.from(e.outputFiles[0].text),y="application/javascript"}catch(e){return t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`TypeScript compilation error:\n${e}`),void(r.logging&&console.error("[500] TypeScript compilation error:",e))}if(".html"===f){let e=`<script type="importmap">\n{\n "imports": {\n "elit": "${s.basePath?`${s.basePath}/dist/client.mjs`:"/dist/client.mjs"}"\n }\n}\n<\/script>`,t=`<script>(function(){const ws=new WebSocket('ws://${r.host}:${r.port}${s.basePath}');ws.onopen=()=>console.log('[Elit HMR] Connected');ws.onmessage=(e)=>{const d=JSON.parse(e.data);if(d.type==='update'){console.log('[Elit HMR] File updated:',d.path);window.location.reload()}else if(d.type==='reload'){console.log('[Elit HMR] Reloading...');window.location.reload()}else if(d.type==='error')console.error('[Elit HMR] Error:',d.error)};ws.onclose=()=>{console.log('[Elit HMR] Disconnected - Retrying...');setTimeout(()=>window.location.reload(),1000)};ws.onerror=(e)=>console.error('[Elit HMR] WebSocket error:',e)})();<\/script>`,o=m.toString();if(s.basePath&&"/"!==s.basePath){let e=`<base href="${s.basePath}/">`;o.includes("<base")||(o.includes('<meta name="viewport"')?o=o.replace(/<meta name="viewport"[^>]*>/,t=>`${t}\n ${e}`):o.includes("<head>")&&(o=o.replace("<head>",`<head>\n ${e}`)))}o=o.includes("</head>")?o.replace("</head>",`${e}</head>`):o,o=o.includes("</body>")?o.replace("</body>",`${t}</body>`):o+t,m=Buffer.from(o)}let v={"Content-Type":y,"Cache-Control":".html"===f||".ts"===f||".tsx"===f?"no-cache, no-store, must-revalidate":"public, max-age=31536000, immutable"};if(/^(text\/|application\/(javascript|json|xml))/.test(y)&&m.length>1024){let{gzipSync:e}=c("zlib"),r=e(m);v["Content-Encoding"]="gzip",v["Content-Length"]=r.length,t.writeHead(200,v),t.end(r)}else t.writeHead(200,v),t.end(m);r.logging&&console.log(`[200] ${i.relative(s.root,e)}`)}catch(e){t.writeHead(500,{"Content-Type":"text/plain"}),t.end("500 Internal Server Error"),r.logging&&console.error("[500] Error reading file:",e)}}let v=new s.WebSocketServer({server:f});v.on("connection",e=>{p.add(e);let t={type:"connected",timestamp:Date.now()};e.send(JSON.stringify(t)),r.logging&&console.log("[HMR] Client connected"),e.on("message",t=>{try{let s=JSON.parse(t.toString());"state:subscribe"===s.type?(d.subscribe(s.key,e),r.logging&&console.log(`[State] Client subscribed to "${s.key}"`)):"state:unsubscribe"===s.type?(d.unsubscribe(s.key,e),r.logging&&console.log(`[State] Client unsubscribed from "${s.key}"`)):"state:change"===s.type&&(d.handleStateChange(s.key,s.value),r.logging&&console.log(`[State] Client updated "${s.key}"`))}catch(e){r.logging&&console.error("[WebSocket] Message parse error:",e)}}),e.on("close",()=>{p.delete(e),d.unsubscribeAll(e),r.logging&&console.log("[HMR] Client disconnected")})});let x=g.flatMap(e=>r.watch.map(t=>i.join(e.root,t))),b=o.watch(x,{ignored:r.ignore,ignoreInitial:!0,persistent:!0});b.on("change",e=>{r.logging&&console.log(`[HMR] File changed: ${e}`);let t=JSON.stringify({type:"update",path:e,timestamp:Date.now()});p.forEach(e=>e.readyState===s.WebSocket.OPEN&&e.send(t))}),b.on("add",e=>r.logging&&console.log(`[HMR] File added: ${e}`)),b.on("unlink",e=>r.logging&&console.log(`[HMR] File removed: ${e}`)),f.setMaxListeners(20),f.listen(r.port,r.host,()=>{if(r.logging){if(console.log("\n🚀 Elit Dev Server"),console.log(`\n ➜ Local: http://${r.host}:${r.port}`),g.length>1)console.log(" ➜ Clients:"),g.forEach(e=>{let t=`http://${r.host}:${r.port}${e.basePath}`;console.log(` - ${t} → ${e.root}`)});else{let e=g[0];console.log(` ➜ Root: ${e.root}`),e.basePath&&console.log(` ➜ Base: ${e.basePath}`)}console.log("\n[HMR] Watching for file changes...\n")}if(r.open&&g.length>0){let e=g[0],t=`http://${r.host}:${r.port}${e.basePath}`;(async()=>{let{default:e}=await import("open");await e(t)})().catch(()=>{})}});let w=!1,$=g[0],S=`http://${r.host}:${r.port}${$.basePath}`;return{server:f,wss:v,url:S,state:d,close:async()=>{if(!w)return w=!0,r.logging&&console.log("\n[Server] Shutting down..."),await b.close(),v.close(),p.forEach(e=>e.close()),p.clear(),new Promise(e=>{f.close(()=>{r.logging&&console.log("[Server] Closed"),e()})})}}},exports.createEl=Cr,exports.createElementFactory=y,exports.createMathEl=Mr,exports.createRouter=function(e){let{mode:t="history",base:r="",routes:s}=e,o=[],n=e=>{let t={};return new URLSearchParams(e).forEach((e,r)=>{t[r]=e}),t},i=()=>"hash"===t?window.location.hash.slice(1)||"/":window.location.pathname.replace(r,"")||"/",a=e=>{let[t,r=""]=e.split("?"),[s,o=""]=t.split("#");return{path:s||"/",params:{},query:n(r),hash:o?"#"+o:""}},l=e=>{for(let t of s){let r=Dr(t.path,e);if(null!==r)return{route:t,params:r}}return null},p=u.createState(a(i())),c=(e,s=!1)=>{let n=a(e),i=l(n.path);i&&(n.params=i.params);for(let e of o){let t=e(n,p.value);if(!1===t)return;if("string"==typeof t)return void c(t,s)}if(i?.route.beforeEnter){let e=i.route.beforeEnter(n,p.value);if(!1===e)return;if("string"==typeof e)return void c(e,s)}let d="hash"===t?"#"+e:r+e;s?window.history.replaceState({path:e},"",d):window.history.pushState({path:e},"",d),p.value=n},d=()=>{let e=i(),t=a(e),r=l(t.path);r&&(t.params=r.params),p.value=t};return typeof window<"u"&&window.addEventListener("popstate",d),{currentRoute:p,push:e=>c(e,!1),replace:e=>c(e,!0),back:()=>window.history.back(),forward:()=>window.history.forward(),go:e=>window.history.go(e),beforeEach:e=>{o.push(e)},destroy:()=>{typeof window<"u"&&window.removeEventListener("popstate",d),p.destroy()}}},exports.createRouterView=function(e,t){let{routes:r,notFound:s}=t;return()=>{let t=e.currentRoute.value,o=r.find(e=>null!==Dr(e.path,t.path));if(o){let e=Dr(o.path,t.path)||{},r=o.component({...e,...t.query});return"object"==typeof r&&null!==r&&"tagName"in r?r:{tagName:"span",props:{},children:[r]}}if(s){let e=s(t.params);return"object"==typeof e&&null!==e&&"tagName"in e?e:{tagName:"span",props:{},children:[e]}}return{tagName:"div",props:{},children:["404 - Not Found"]}}},exports.createSharedState=function(e,t,r){return new g(e,t,r)},exports.createState=h,exports.createSvgEl=Nr,exports.createVirtualList=(e,t,r,s,o)=>u.createVirtualList(e,t,r,s,o),exports.data=ae,exports.datalist=rt,exports.dd=B,exports.debounce=(e,t)=>{let r=null;return(...s)=>{r&&clearTimeout(r),r=setTimeout(()=>e(...s),t)}},exports.defineConfig=function(e){return e},exports.del=Ie,exports.details=mt,exports.dfn=le,exports.dialog=ft,exports.div=U,exports.dl=I,exports.doc=Sr,exports.dom=u,exports.dt=J,exports.effect=e=>u.effect(e),exports.el=$r,exports.elements=v,exports.em=pe,exports.embed=He,exports.errorHandler=function(){return async(e,t)=>{try{await t()}catch(t){console.error("Error:",t),e.res.headersSent||(e.res.writeHead(500,{"Content-Type":"application/json"}),e.res.end(JSON.stringify({error:"Internal Server Error",message:t instanceof Error?t.message:"Unknown error"})))}}},exports.fieldset=st,exports.figcaption=V,exports.figure=_,exports.footer=R,exports.form=ot,exports.fragment=Rr,exports.getEl=Er,exports.getElClass=Hr,exports.getElId=Fr,exports.getElName=Ar,exports.getElTag=Or,exports.getEls=Tr,exports.h1=j,exports.h2=F,exports.h3=H,exports.h4=O,exports.h5=A,exports.h6=D,exports.head=x,exports.header=k,exports.hmr=Ir,exports.hr=G,exports.html=(e,t,r=200)=>{e.writeHead(r,{"Content-Type":"text/html"}),e.end(t)},exports.i=ce,exports.iframe=Oe,exports.img=Re,exports.input=nt,exports.ins=Je,exports.json=(e,t,r=200)=>{e.writeHead(r,{"Content-Type":"application/json"}),e.end(JSON.stringify(t))},exports.kbd=de,exports.label=it,exports.lazy=e=>u.lazy(e),exports.legend=at,exports.li=z,exports.link=S,exports.loadConfig=async function(e=process.cwd()){for(let t of _r){let r=i.resolve(e,t);if(p.existsSync(r))try{return await Gr(r)}catch(e){throw console.error(`Error loading config file: ${t}`),console.error(e),e}}return null},exports.loadEnv=function(e="development",t=process.cwd()){let r={MODE:e},s=[`.env.${e}.local`,`.env.${e}`,".env.local",".env"];for(let e of s){let s=i.resolve(t,e);if(p.existsSync(s)){let e=p.readFileSync(s,"utf-8").split("\n");for(let t of e){let e=t.trim();if(!e||e.startsWith("#"))continue;let s=e.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);if(s){let[,e,t]=s,o=t.trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),e in r||(r[e]=o)}}}}return r},exports.logger=function(e={}){let{format:t="simple"}=e;return async(e,r)=>{let s=Date.now(),{method:o,url:n}=e.req;await r();let i=Date.now()-s,a=e.res.statusCode;console.log("detailed"===t?`[${(new Date).toISOString()}] ${o} ${n} ${a} - ${i}ms`:`${o} ${n} - ${a} (${i}ms)`)}},exports.main=P,exports.map=ke,exports.mark=ue,exports.mathMath=pr,exports.mathMfrac=fr,exports.mathMi=cr,exports.mathMn=dr,exports.mathMo=ur,exports.mathMroot=vr,exports.mathMrow=mr,exports.mathMs=hr,exports.mathMsqrt=yr,exports.mathMsub=xr,exports.mathMsup=br,exports.mathMtext=gr,exports.menu=yt,exports.mergeConfig=function(e,t){return e?{...e,...Object.fromEntries(Object.entries(t).filter(([e,t])=>void 0!==t))}:t},exports.meta=E,exports.meter=lt,exports.nav=W,exports.noscript=Be,exports.object=Ae,exports.ol=K,exports.optgroup=pt,exports.option=ct,exports.output=dt,exports.p=X,exports.param=De,exports.picture=Pe,exports.portal=We,exports.pre=Z,exports.progress=ut,exports.q=he,exports.rateLimit=function(e={}){let{windowMs:t=6e4,max:r=100,message:s="Too many requests"}=e,o=new Map;return async(e,n)=>{let i=e.req.socket.remoteAddress||"unknown",a=Date.now(),l=o.get(i);if((!l||a>l.resetTime)&&(l={count:0,resetTime:a+t},o.set(i,l)),++l.count>r)return e.res.writeHead(429,{"Content-Type":"application/json"}),void e.res.end(JSON.stringify({error:s}));await n()}},exports.reactive=f,exports.reactiveAs=(e,t,r,s={})=>{let o=null,n=null;return t.subscribe(()=>{o&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{if(n){let e=document.createDocumentFragment(),s=r(t.value);null==s||!1===s?(n.style.display="none",n.textContent=""):(n.style.display="",u.renderToDOM(s,e),n.textContent="",n.appendChild(e)),u.getElementCache().set(n,!0)}o=null})}),{tagName:e,props:{...s,ref:e=>{n=e}},children:[r(t.value)]}},exports.renderChunked=(e,t,r,s)=>u.renderChunked(e,t,r,s),exports.routerLink=(e,t,...r)=>({tagName:"a",props:{...t,href:t.to,onclick:r=>{r.preventDefault(),e.push(t.to)}},children:r}),exports.rp=ge,exports.rt=me,exports.ruby=fe,exports.s=ye,exports.samp=ve,exports.script=Ue,exports.section=L,exports.security=function(){return async(e,t)=>{e.res.setHeader("X-Content-Type-Options","nosniff"),e.res.setHeader("X-Frame-Options","DENY"),e.res.setHeader("X-XSS-Protection","1; mode=block"),e.res.setHeader("Strict-Transport-Security","max-age=31536000; includeSubDomains"),await t()}},exports.select=ht,exports.sendText=(e,t,r=200)=>{e.writeHead(r,{"Content-Type":"text/plain"}),e.end(t)},exports.sharedStateManager=m,exports.slot=xt,exports.small=xe,exports.source=Le,exports.span=be,exports.status=(e,t,r)=>{e.writeHead(t,{"Content-Type":"application/json"}),e.end(JSON.stringify({status:t,message:r||""}))},exports.strong=we,exports.style=T,exports.sub=$e,exports.summary=vt,exports.sup=Se,exports.svgAnimate=Jt,exports.svgAnimateMotion=_t,exports.svgAnimateTransform=Vt,exports.svgCircle=$t,exports.svgClipPath=Wt,exports.svgDefs=Ft,exports.svgEllipse=Mt,exports.svgFeBlend=Kt,exports.svgFeColorMatrix=Xt,exports.svgFeComponentTransfer=Zt,exports.svgFeComposite=Yt,exports.svgFeConvolveMatrix=Qt,exports.svgFeDiffuseLighting=er,exports.svgFeDisplacementMap=tr,exports.svgFeFlood=rr,exports.svgFeGaussianBlur=sr,exports.svgFeMorphology=or,exports.svgFeOffset=nr,exports.svgFeSpecularLighting=ir,exports.svgFeTile=ar,exports.svgFeTurbulence=lr,exports.svgFilter=zt,exports.svgForeignObject=It,exports.svgG=Rt,exports.svgImage=Ut,exports.svgLine=Tt,exports.svgLinearGradient=Ht,exports.svgMarker=Bt,exports.svgMask=Pt,exports.svgPath=Et,exports.svgPattern=Dt,exports.svgPolygon=Nt,exports.svgPolyline=Ct,exports.svgRadialGradient=Ot,exports.svgRect=St,exports.svgSet=Gt,exports.svgStop=At,exports.svgSvg=wt,exports.svgSymbol=qt,exports.svgText=kt,exports.svgTspan=jt,exports.svgUse=Lt,exports.table=ze,exports.tbody=Ke,exports.td=Xe,exports.template=bt,exports.text=e=>e&&void 0!==e.value?f(e,e=>({tagName:"span",props:{},children:[String(e)]})):String(e),exports.textNode=kr,exports.textarea=gt,exports.tfoot=Ze,exports.th=Ye,exports.thead=Qe,exports.throttle=(e,t)=>{let r=null;return(...s)=>{r||(r=setTimeout(()=>{r=null,e(...s)},t))}},exports.time=Ee,exports.title=w,exports.tr=et,exports.track=je,exports.u=Te,exports.ul=Y,exports.varElement=wr,exports.video=Fe,exports.wbr=Ce;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
CreateStyle: () => CreateStyle,
|
|
24
|
+
DomNode: () => DomNode,
|
|
25
|
+
SharedState: () => SharedState,
|
|
26
|
+
a: () => a,
|
|
27
|
+
abbr: () => abbr,
|
|
28
|
+
addAttribute: () => addAttribute,
|
|
29
|
+
addClass: () => addClass,
|
|
30
|
+
addContainer: () => addContainer,
|
|
31
|
+
addId: () => addId,
|
|
32
|
+
addName: () => addName,
|
|
33
|
+
addPseudoClass: () => addPseudoClass,
|
|
34
|
+
addPseudoElement: () => addPseudoElement,
|
|
35
|
+
addStyle: () => addStyle,
|
|
36
|
+
addTag: () => addTag,
|
|
37
|
+
addVar: () => addVar,
|
|
38
|
+
address: () => address,
|
|
39
|
+
adjacentSibling: () => adjacentSibling,
|
|
40
|
+
area: () => area,
|
|
41
|
+
article: () => article,
|
|
42
|
+
aside: () => aside,
|
|
43
|
+
attrContains: () => attrContains,
|
|
44
|
+
attrContainsWord: () => attrContainsWord,
|
|
45
|
+
attrEndsWith: () => attrEndsWith,
|
|
46
|
+
attrEquals: () => attrEquals,
|
|
47
|
+
attrStartsWith: () => attrStartsWith,
|
|
48
|
+
audio: () => audio,
|
|
49
|
+
b: () => b,
|
|
50
|
+
base: () => base,
|
|
51
|
+
batchRender: () => batchRender,
|
|
52
|
+
bdi: () => bdi,
|
|
53
|
+
bdo: () => bdo,
|
|
54
|
+
bindChecked: () => bindChecked,
|
|
55
|
+
bindValue: () => bindValue,
|
|
56
|
+
blockquote: () => blockquote,
|
|
57
|
+
body: () => body,
|
|
58
|
+
br: () => br,
|
|
59
|
+
button: () => button,
|
|
60
|
+
canvas: () => canvas,
|
|
61
|
+
caption: () => caption,
|
|
62
|
+
childStyle: () => childStyle,
|
|
63
|
+
cite: () => cite,
|
|
64
|
+
cleanupUnused: () => cleanupUnused,
|
|
65
|
+
clearStyle: () => clearStyle,
|
|
66
|
+
code: () => code,
|
|
67
|
+
col: () => col,
|
|
68
|
+
colgroup: () => colgroup,
|
|
69
|
+
commentNode: () => commentNode,
|
|
70
|
+
computed: () => computed,
|
|
71
|
+
container: () => container,
|
|
72
|
+
createEl: () => createEl,
|
|
73
|
+
createElementFactory: () => createElementFactory,
|
|
74
|
+
createMathEl: () => createMathEl,
|
|
75
|
+
createRouter: () => createRouter,
|
|
76
|
+
createRouterView: () => createRouterView,
|
|
77
|
+
createSharedState: () => createSharedState,
|
|
78
|
+
createState: () => createState,
|
|
79
|
+
createSvgEl: () => createSvgEl,
|
|
80
|
+
createVirtualList: () => createVirtualList,
|
|
81
|
+
data: () => data,
|
|
82
|
+
datalist: () => datalist,
|
|
83
|
+
dd: () => dd,
|
|
84
|
+
debounce: () => debounce,
|
|
85
|
+
del: () => del,
|
|
86
|
+
descendant: () => descendant,
|
|
87
|
+
details: () => details,
|
|
88
|
+
dfn: () => dfn,
|
|
89
|
+
dialog: () => dialog,
|
|
90
|
+
div: () => div,
|
|
91
|
+
dl: () => dl,
|
|
92
|
+
doc: () => doc,
|
|
93
|
+
dom: () => dom,
|
|
94
|
+
dt: () => dt,
|
|
95
|
+
effect: () => effect,
|
|
96
|
+
el: () => el,
|
|
97
|
+
elements: () => elements,
|
|
98
|
+
em: () => em,
|
|
99
|
+
embed: () => embed,
|
|
100
|
+
fieldset: () => fieldset,
|
|
101
|
+
figcaption: () => figcaption,
|
|
102
|
+
figure: () => figure,
|
|
103
|
+
fontFace: () => fontFace,
|
|
104
|
+
footer: () => footer,
|
|
105
|
+
form: () => form,
|
|
106
|
+
fragment: () => fragment,
|
|
107
|
+
generalSibling: () => generalSibling,
|
|
108
|
+
getEl: () => getEl,
|
|
109
|
+
getElClass: () => getElClass,
|
|
110
|
+
getElId: () => getElId,
|
|
111
|
+
getElName: () => getElName,
|
|
112
|
+
getElTag: () => getElTag,
|
|
113
|
+
getEls: () => getEls,
|
|
114
|
+
getVar: () => getVar,
|
|
115
|
+
h1: () => h1,
|
|
116
|
+
h2: () => h2,
|
|
117
|
+
h3: () => h3,
|
|
118
|
+
h4: () => h4,
|
|
119
|
+
h5: () => h5,
|
|
120
|
+
h6: () => h6,
|
|
121
|
+
head: () => head,
|
|
122
|
+
header: () => header,
|
|
123
|
+
hmr: () => hmr_default,
|
|
124
|
+
hr: () => hr,
|
|
125
|
+
html: () => html,
|
|
126
|
+
i: () => i,
|
|
127
|
+
iframe: () => iframe,
|
|
128
|
+
img: () => img,
|
|
129
|
+
importStyle: () => importStyle,
|
|
130
|
+
important: () => important,
|
|
131
|
+
injectStyle: () => injectStyle,
|
|
132
|
+
input: () => input,
|
|
133
|
+
ins: () => ins,
|
|
134
|
+
kbd: () => kbd,
|
|
135
|
+
keyframe: () => keyframe,
|
|
136
|
+
keyframeFromTo: () => keyframeFromTo,
|
|
137
|
+
label: () => label,
|
|
138
|
+
layer: () => layer,
|
|
139
|
+
layerOrder: () => layerOrder,
|
|
140
|
+
lazy: () => lazy,
|
|
141
|
+
legend: () => legend,
|
|
142
|
+
li: () => li,
|
|
143
|
+
link: () => link,
|
|
144
|
+
main: () => main,
|
|
145
|
+
map: () => map,
|
|
146
|
+
mark: () => mark,
|
|
147
|
+
mathMath: () => mathMath,
|
|
148
|
+
mathMfrac: () => mathMfrac,
|
|
149
|
+
mathMi: () => mathMi,
|
|
150
|
+
mathMn: () => mathMn,
|
|
151
|
+
mathMo: () => mathMo,
|
|
152
|
+
mathMroot: () => mathMroot,
|
|
153
|
+
mathMrow: () => mathMrow,
|
|
154
|
+
mathMs: () => mathMs,
|
|
155
|
+
mathMsqrt: () => mathMsqrt,
|
|
156
|
+
mathMsub: () => mathMsub,
|
|
157
|
+
mathMsup: () => mathMsup,
|
|
158
|
+
mathMtext: () => mathMtext,
|
|
159
|
+
mediaDark: () => mediaDark,
|
|
160
|
+
mediaLight: () => mediaLight,
|
|
161
|
+
mediaMaxWidth: () => mediaMaxWidth,
|
|
162
|
+
mediaMinWidth: () => mediaMinWidth,
|
|
163
|
+
mediaPrint: () => mediaPrint,
|
|
164
|
+
mediaReducedMotion: () => mediaReducedMotion,
|
|
165
|
+
mediaScreen: () => mediaScreen,
|
|
166
|
+
mediaStyle: () => mediaStyle,
|
|
167
|
+
menu: () => menu,
|
|
168
|
+
meta: () => meta,
|
|
169
|
+
meter: () => meter,
|
|
170
|
+
mount: () => mount,
|
|
171
|
+
multipleStyle: () => multipleStyle,
|
|
172
|
+
nav: () => nav,
|
|
173
|
+
nesting: () => nesting,
|
|
174
|
+
noscript: () => noscript,
|
|
175
|
+
object: () => object,
|
|
176
|
+
ol: () => ol,
|
|
177
|
+
optgroup: () => optgroup,
|
|
178
|
+
option: () => option,
|
|
179
|
+
output: () => output,
|
|
180
|
+
p: () => p,
|
|
181
|
+
param: () => param,
|
|
182
|
+
picture: () => picture,
|
|
183
|
+
portal: () => portal,
|
|
184
|
+
pre: () => pre,
|
|
185
|
+
progress: () => progress,
|
|
186
|
+
q: () => q,
|
|
187
|
+
reactive: () => reactive,
|
|
188
|
+
reactiveAs: () => reactiveAs,
|
|
189
|
+
render: () => render,
|
|
190
|
+
renderChunked: () => renderChunked,
|
|
191
|
+
renderStyle: () => renderStyle,
|
|
192
|
+
renderToString: () => renderToString,
|
|
193
|
+
routerLink: () => routerLink,
|
|
194
|
+
rp: () => rp,
|
|
195
|
+
rt: () => rt,
|
|
196
|
+
ruby: () => ruby,
|
|
197
|
+
s: () => s,
|
|
198
|
+
samp: () => samp,
|
|
199
|
+
script: () => script,
|
|
200
|
+
section: () => section,
|
|
201
|
+
select: () => select,
|
|
202
|
+
sharedStateManager: () => sharedStateManager,
|
|
203
|
+
slot: () => slot,
|
|
204
|
+
small: () => small,
|
|
205
|
+
source: () => source,
|
|
206
|
+
span: () => span,
|
|
207
|
+
strong: () => strong,
|
|
208
|
+
style: () => style,
|
|
209
|
+
styles: () => styles,
|
|
210
|
+
sub: () => sub,
|
|
211
|
+
summary: () => summary,
|
|
212
|
+
sup: () => sup,
|
|
213
|
+
supportsStyle: () => supportsStyle,
|
|
214
|
+
svgAnimate: () => svgAnimate,
|
|
215
|
+
svgAnimateMotion: () => svgAnimateMotion,
|
|
216
|
+
svgAnimateTransform: () => svgAnimateTransform,
|
|
217
|
+
svgCircle: () => svgCircle,
|
|
218
|
+
svgClipPath: () => svgClipPath,
|
|
219
|
+
svgDefs: () => svgDefs,
|
|
220
|
+
svgEllipse: () => svgEllipse,
|
|
221
|
+
svgFeBlend: () => svgFeBlend,
|
|
222
|
+
svgFeColorMatrix: () => svgFeColorMatrix,
|
|
223
|
+
svgFeComponentTransfer: () => svgFeComponentTransfer,
|
|
224
|
+
svgFeComposite: () => svgFeComposite,
|
|
225
|
+
svgFeConvolveMatrix: () => svgFeConvolveMatrix,
|
|
226
|
+
svgFeDiffuseLighting: () => svgFeDiffuseLighting,
|
|
227
|
+
svgFeDisplacementMap: () => svgFeDisplacementMap,
|
|
228
|
+
svgFeFlood: () => svgFeFlood,
|
|
229
|
+
svgFeGaussianBlur: () => svgFeGaussianBlur,
|
|
230
|
+
svgFeMorphology: () => svgFeMorphology,
|
|
231
|
+
svgFeOffset: () => svgFeOffset,
|
|
232
|
+
svgFeSpecularLighting: () => svgFeSpecularLighting,
|
|
233
|
+
svgFeTile: () => svgFeTile,
|
|
234
|
+
svgFeTurbulence: () => svgFeTurbulence,
|
|
235
|
+
svgFilter: () => svgFilter,
|
|
236
|
+
svgForeignObject: () => svgForeignObject,
|
|
237
|
+
svgG: () => svgG,
|
|
238
|
+
svgImage: () => svgImage,
|
|
239
|
+
svgLine: () => svgLine,
|
|
240
|
+
svgLinearGradient: () => svgLinearGradient,
|
|
241
|
+
svgMarker: () => svgMarker,
|
|
242
|
+
svgMask: () => svgMask,
|
|
243
|
+
svgPath: () => svgPath,
|
|
244
|
+
svgPattern: () => svgPattern,
|
|
245
|
+
svgPolygon: () => svgPolygon,
|
|
246
|
+
svgPolyline: () => svgPolyline,
|
|
247
|
+
svgRadialGradient: () => svgRadialGradient,
|
|
248
|
+
svgRect: () => svgRect,
|
|
249
|
+
svgSet: () => svgSet,
|
|
250
|
+
svgStop: () => svgStop,
|
|
251
|
+
svgSvg: () => svgSvg,
|
|
252
|
+
svgSymbol: () => svgSymbol,
|
|
253
|
+
svgText: () => svgText,
|
|
254
|
+
svgTspan: () => svgTspan,
|
|
255
|
+
svgUse: () => svgUse,
|
|
256
|
+
table: () => table,
|
|
257
|
+
tbody: () => tbody,
|
|
258
|
+
td: () => td,
|
|
259
|
+
template: () => template,
|
|
260
|
+
text: () => text,
|
|
261
|
+
textNode: () => textNode,
|
|
262
|
+
textarea: () => textarea,
|
|
263
|
+
tfoot: () => tfoot,
|
|
264
|
+
th: () => th,
|
|
265
|
+
thead: () => thead,
|
|
266
|
+
throttle: () => throttle,
|
|
267
|
+
time: () => time,
|
|
268
|
+
title: () => title,
|
|
269
|
+
tr: () => tr,
|
|
270
|
+
track: () => track,
|
|
271
|
+
u: () => u,
|
|
272
|
+
ul: () => ul,
|
|
273
|
+
varElement: () => varElement,
|
|
274
|
+
video: () => video,
|
|
275
|
+
wbr: () => wbr
|
|
276
|
+
});
|
|
277
|
+
module.exports = __toCommonJS(src_exports);
|
|
278
|
+
|
|
279
|
+
// src/dom.ts
|
|
280
|
+
function resolveElement(rootElement) {
|
|
281
|
+
return typeof rootElement === "string" ? document.getElementById(rootElement.replace("#", "")) : rootElement;
|
|
282
|
+
}
|
|
283
|
+
function ensureElement(el2, rootElement) {
|
|
284
|
+
if (!el2) {
|
|
285
|
+
throw new Error(`Element not found: ${rootElement}`);
|
|
286
|
+
}
|
|
287
|
+
return el2;
|
|
288
|
+
}
|
|
289
|
+
function shouldSkipChild(child) {
|
|
290
|
+
return child == null || child === false;
|
|
291
|
+
}
|
|
292
|
+
function isPrimitiveJson(json) {
|
|
293
|
+
return json == null || typeof json === "boolean" || typeof json === "string" || typeof json === "number";
|
|
294
|
+
}
|
|
295
|
+
var DomNode = class {
|
|
296
|
+
constructor() {
|
|
297
|
+
this.elementCache = /* @__PURE__ */ new WeakMap();
|
|
298
|
+
this.reactiveNodes = /* @__PURE__ */ new Map();
|
|
299
|
+
}
|
|
300
|
+
createElement(tagName, props = {}, children = []) {
|
|
301
|
+
return { tagName, props, children };
|
|
302
|
+
}
|
|
303
|
+
renderToDOM(vNode, parent) {
|
|
304
|
+
if (vNode == null || vNode === false) return;
|
|
305
|
+
if (typeof vNode !== "object") {
|
|
306
|
+
parent.appendChild(document.createTextNode(String(vNode)));
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const { tagName, props, children } = vNode;
|
|
310
|
+
const isSVG = tagName === "svg" || tagName[0] === "s" && tagName[1] === "v" && tagName[2] === "g" || parent.namespaceURI === "http://www.w3.org/2000/svg";
|
|
311
|
+
const el2 = isSVG ? document.createElementNS("http://www.w3.org/2000/svg", tagName.replace("svg", "").toLowerCase() || tagName) : document.createElement(tagName);
|
|
312
|
+
for (const key in props) {
|
|
313
|
+
const value = props[key];
|
|
314
|
+
if (value == null || value === false) continue;
|
|
315
|
+
const c = key.charCodeAt(0);
|
|
316
|
+
if (c === 99 && (key.length < 6 || key[5] === "N")) {
|
|
317
|
+
const classValue = Array.isArray(value) ? value.join(" ") : value;
|
|
318
|
+
isSVG ? el2.setAttribute("class", classValue) : el2.className = classValue;
|
|
319
|
+
} else if (c === 115 && key.length === 5) {
|
|
320
|
+
if (typeof value === "string") {
|
|
321
|
+
el2.style.cssText = value;
|
|
322
|
+
} else {
|
|
323
|
+
const s2 = el2.style;
|
|
324
|
+
for (const k in value) s2[k] = value[k];
|
|
325
|
+
}
|
|
326
|
+
} else if (c === 111 && key.charCodeAt(1) === 110) {
|
|
327
|
+
el2[key.toLowerCase()] = value;
|
|
328
|
+
} else if (c === 100 && key.length > 20) {
|
|
329
|
+
el2.innerHTML = value.__html;
|
|
330
|
+
} else if (c === 114 && key.length === 3) {
|
|
331
|
+
setTimeout(() => {
|
|
332
|
+
typeof value === "function" ? value(el2) : value.current = el2;
|
|
333
|
+
}, 0);
|
|
334
|
+
} else {
|
|
335
|
+
el2.setAttribute(key, value === true ? "" : String(value));
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
const len = children.length;
|
|
339
|
+
if (!len) {
|
|
340
|
+
parent.appendChild(el2);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const renderChildren = (target) => {
|
|
344
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
345
|
+
const child = children[i2];
|
|
346
|
+
if (shouldSkipChild(child)) continue;
|
|
347
|
+
if (Array.isArray(child)) {
|
|
348
|
+
for (let j = 0, cLen = child.length; j < cLen; j++) {
|
|
349
|
+
const c = child[j];
|
|
350
|
+
!shouldSkipChild(c) && this.renderToDOM(c, target);
|
|
351
|
+
}
|
|
352
|
+
} else {
|
|
353
|
+
this.renderToDOM(child, target);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
if (len > 30) {
|
|
358
|
+
const fragment2 = document.createDocumentFragment();
|
|
359
|
+
renderChildren(fragment2);
|
|
360
|
+
el2.appendChild(fragment2);
|
|
361
|
+
} else {
|
|
362
|
+
renderChildren(el2);
|
|
363
|
+
}
|
|
364
|
+
parent.appendChild(el2);
|
|
365
|
+
}
|
|
366
|
+
render(rootElement, vNode) {
|
|
367
|
+
const el2 = ensureElement(resolveElement(rootElement), rootElement);
|
|
368
|
+
el2.innerHTML = "";
|
|
369
|
+
if (vNode.children && vNode.children.length > 500) {
|
|
370
|
+
const fragment2 = document.createDocumentFragment();
|
|
371
|
+
this.renderToDOM(vNode, fragment2);
|
|
372
|
+
el2.appendChild(fragment2);
|
|
373
|
+
} else {
|
|
374
|
+
this.renderToDOM(vNode, el2);
|
|
375
|
+
}
|
|
376
|
+
return el2;
|
|
377
|
+
}
|
|
378
|
+
batchRender(rootElement, vNodes) {
|
|
379
|
+
const el2 = ensureElement(resolveElement(rootElement), rootElement);
|
|
380
|
+
const len = vNodes.length;
|
|
381
|
+
if (len > 3e3) {
|
|
382
|
+
const fragment2 = document.createDocumentFragment();
|
|
383
|
+
let processed = 0;
|
|
384
|
+
const chunkSize = 1500;
|
|
385
|
+
const processChunk = () => {
|
|
386
|
+
const end = Math.min(processed + chunkSize, len);
|
|
387
|
+
for (let i2 = processed; i2 < end; i2++) {
|
|
388
|
+
this.renderToDOM(vNodes[i2], fragment2);
|
|
389
|
+
}
|
|
390
|
+
processed = end;
|
|
391
|
+
if (processed >= len) {
|
|
392
|
+
el2.appendChild(fragment2);
|
|
393
|
+
} else {
|
|
394
|
+
requestAnimationFrame(processChunk);
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
processChunk();
|
|
398
|
+
} else {
|
|
399
|
+
const fragment2 = document.createDocumentFragment();
|
|
400
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
401
|
+
this.renderToDOM(vNodes[i2], fragment2);
|
|
402
|
+
}
|
|
403
|
+
el2.appendChild(fragment2);
|
|
404
|
+
}
|
|
405
|
+
return el2;
|
|
406
|
+
}
|
|
407
|
+
renderChunked(rootElement, vNodes, chunkSize = 5e3, onProgress) {
|
|
408
|
+
const el2 = ensureElement(resolveElement(rootElement), rootElement);
|
|
409
|
+
const len = vNodes.length;
|
|
410
|
+
let index = 0;
|
|
411
|
+
const renderChunk = () => {
|
|
412
|
+
const end = Math.min(index + chunkSize, len);
|
|
413
|
+
const fragment2 = document.createDocumentFragment();
|
|
414
|
+
for (let i2 = index; i2 < end; i2++) {
|
|
415
|
+
this.renderToDOM(vNodes[i2], fragment2);
|
|
416
|
+
}
|
|
417
|
+
el2.appendChild(fragment2);
|
|
418
|
+
index = end;
|
|
419
|
+
if (onProgress) onProgress(index, len);
|
|
420
|
+
if (index < len) {
|
|
421
|
+
requestAnimationFrame(renderChunk);
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
requestAnimationFrame(renderChunk);
|
|
425
|
+
return el2;
|
|
426
|
+
}
|
|
427
|
+
renderToHead(...vNodes) {
|
|
428
|
+
const head2 = document.head;
|
|
429
|
+
if (head2) {
|
|
430
|
+
for (const vNode of vNodes.flat()) {
|
|
431
|
+
vNode && this.renderToDOM(vNode, head2);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return head2;
|
|
435
|
+
}
|
|
436
|
+
addStyle(cssText) {
|
|
437
|
+
const el2 = document.createElement("style");
|
|
438
|
+
el2.textContent = cssText;
|
|
439
|
+
return document.head.appendChild(el2);
|
|
440
|
+
}
|
|
441
|
+
addMeta(attrs) {
|
|
442
|
+
const el2 = document.createElement("meta");
|
|
443
|
+
for (const k in attrs) el2.setAttribute(k, attrs[k]);
|
|
444
|
+
return document.head.appendChild(el2);
|
|
445
|
+
}
|
|
446
|
+
addLink(attrs) {
|
|
447
|
+
const el2 = document.createElement("link");
|
|
448
|
+
for (const k in attrs) el2.setAttribute(k, attrs[k]);
|
|
449
|
+
return document.head.appendChild(el2);
|
|
450
|
+
}
|
|
451
|
+
setTitle(text2) {
|
|
452
|
+
return document.title = text2;
|
|
453
|
+
}
|
|
454
|
+
// Reactive State Management
|
|
455
|
+
createState(initialValue, options = {}) {
|
|
456
|
+
let value = initialValue;
|
|
457
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
458
|
+
let updateTimer = null;
|
|
459
|
+
const { throttle: throttle2 = 0, deep = false } = options;
|
|
460
|
+
const notify = () => listeners.forEach((fn) => fn(value));
|
|
461
|
+
const scheduleUpdate = () => {
|
|
462
|
+
if (throttle2 > 0) {
|
|
463
|
+
if (!updateTimer) {
|
|
464
|
+
updateTimer = setTimeout(() => {
|
|
465
|
+
updateTimer = null;
|
|
466
|
+
notify();
|
|
467
|
+
}, throttle2);
|
|
468
|
+
}
|
|
469
|
+
} else {
|
|
470
|
+
notify();
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
return {
|
|
474
|
+
get value() {
|
|
475
|
+
return value;
|
|
476
|
+
},
|
|
477
|
+
set value(newValue) {
|
|
478
|
+
const changed = deep ? JSON.stringify(value) !== JSON.stringify(newValue) : value !== newValue;
|
|
479
|
+
if (changed) {
|
|
480
|
+
value = newValue;
|
|
481
|
+
scheduleUpdate();
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
subscribe(fn) {
|
|
485
|
+
listeners.add(fn);
|
|
486
|
+
return () => listeners.delete(fn);
|
|
487
|
+
},
|
|
488
|
+
destroy() {
|
|
489
|
+
listeners.clear();
|
|
490
|
+
updateTimer && clearTimeout(updateTimer);
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
computed(states, computeFn) {
|
|
495
|
+
const values = states.map((s2) => s2.value);
|
|
496
|
+
const result = this.createState(computeFn(...values));
|
|
497
|
+
states.forEach((state, index) => {
|
|
498
|
+
state.subscribe((newValue) => {
|
|
499
|
+
values[index] = newValue;
|
|
500
|
+
result.value = computeFn(...values);
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
return result;
|
|
504
|
+
}
|
|
505
|
+
effect(stateFn) {
|
|
506
|
+
stateFn();
|
|
507
|
+
}
|
|
508
|
+
// Virtual scrolling helper for large lists
|
|
509
|
+
createVirtualList(container2, items, renderItem, itemHeight = 50, bufferSize = 5) {
|
|
510
|
+
const viewportHeight = container2.clientHeight;
|
|
511
|
+
const totalHeight = items.length * itemHeight;
|
|
512
|
+
let scrollTop = 0;
|
|
513
|
+
const getVisibleRange = () => {
|
|
514
|
+
const start = Math.max(0, Math.floor(scrollTop / itemHeight) - bufferSize);
|
|
515
|
+
const end = Math.min(items.length, Math.ceil((scrollTop + viewportHeight) / itemHeight) + bufferSize);
|
|
516
|
+
return { start, end };
|
|
517
|
+
};
|
|
518
|
+
const render2 = () => {
|
|
519
|
+
const { start, end } = getVisibleRange();
|
|
520
|
+
const wrapper = document.createElement("div");
|
|
521
|
+
wrapper.style.cssText = `height:${totalHeight}px;position:relative`;
|
|
522
|
+
for (let i2 = start; i2 < end; i2++) {
|
|
523
|
+
const itemEl = document.createElement("div");
|
|
524
|
+
itemEl.style.cssText = `position:absolute;top:${i2 * itemHeight}px;height:${itemHeight}px;width:100%`;
|
|
525
|
+
this.renderToDOM(renderItem(items[i2], i2), itemEl);
|
|
526
|
+
wrapper.appendChild(itemEl);
|
|
527
|
+
}
|
|
528
|
+
container2.innerHTML = "";
|
|
529
|
+
container2.appendChild(wrapper);
|
|
530
|
+
};
|
|
531
|
+
const scrollHandler = () => {
|
|
532
|
+
scrollTop = container2.scrollTop;
|
|
533
|
+
requestAnimationFrame(render2);
|
|
534
|
+
};
|
|
535
|
+
container2.addEventListener("scroll", scrollHandler);
|
|
536
|
+
render2();
|
|
537
|
+
return {
|
|
538
|
+
render: render2,
|
|
539
|
+
destroy: () => {
|
|
540
|
+
container2.removeEventListener("scroll", scrollHandler);
|
|
541
|
+
container2.innerHTML = "";
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
// Lazy load components
|
|
546
|
+
lazy(loadFn) {
|
|
547
|
+
let component = null;
|
|
548
|
+
let loading = false;
|
|
549
|
+
return async (...args) => {
|
|
550
|
+
if (!component && !loading) {
|
|
551
|
+
loading = true;
|
|
552
|
+
component = await loadFn();
|
|
553
|
+
loading = false;
|
|
554
|
+
}
|
|
555
|
+
return component ? component(...args) : { tagName: "div", props: { class: "loading" }, children: ["Loading..."] };
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
// Memory management - cleanup unused elements
|
|
559
|
+
cleanupUnusedElements(root) {
|
|
560
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
|
|
561
|
+
const toRemove = [];
|
|
562
|
+
while (walker.nextNode()) {
|
|
563
|
+
const node = walker.currentNode;
|
|
564
|
+
if (node.id && node.id.startsWith("r") && !this.elementCache.has(node)) {
|
|
565
|
+
toRemove.push(node);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
toRemove.forEach((el2) => el2.remove());
|
|
569
|
+
return toRemove.length;
|
|
570
|
+
}
|
|
571
|
+
// Server-Side Rendering - convert VNode to HTML string
|
|
572
|
+
renderToString(vNode, options = {}) {
|
|
573
|
+
const { pretty = false, indent = 0 } = options;
|
|
574
|
+
const indentStr = pretty ? " ".repeat(indent) : "";
|
|
575
|
+
const newLine = pretty ? "\n" : "";
|
|
576
|
+
let resolvedVNode = this.resolveStateValue(vNode);
|
|
577
|
+
resolvedVNode = this.unwrapReactive(resolvedVNode);
|
|
578
|
+
if (Array.isArray(resolvedVNode)) {
|
|
579
|
+
return resolvedVNode.map((child) => this.renderToString(child, options)).join("");
|
|
580
|
+
}
|
|
581
|
+
if (typeof resolvedVNode !== "object" || resolvedVNode === null) {
|
|
582
|
+
if (resolvedVNode === null || resolvedVNode === void 0 || resolvedVNode === false) {
|
|
583
|
+
return "";
|
|
584
|
+
}
|
|
585
|
+
return this.escapeHtml(String(resolvedVNode));
|
|
586
|
+
}
|
|
587
|
+
const { tagName, props, children } = resolvedVNode;
|
|
588
|
+
const isSelfClosing = this.isSelfClosingTag(tagName);
|
|
589
|
+
let html2 = `${indentStr}<${tagName}`;
|
|
590
|
+
const attrs = this.propsToAttributes(props);
|
|
591
|
+
if (attrs) {
|
|
592
|
+
html2 += ` ${attrs}`;
|
|
593
|
+
}
|
|
594
|
+
if (isSelfClosing) {
|
|
595
|
+
html2 += ` />${newLine}`;
|
|
596
|
+
return html2;
|
|
597
|
+
}
|
|
598
|
+
html2 += ">";
|
|
599
|
+
if (props.dangerouslySetInnerHTML) {
|
|
600
|
+
html2 += props.dangerouslySetInnerHTML.__html;
|
|
601
|
+
html2 += `</${tagName}>${newLine}`;
|
|
602
|
+
return html2;
|
|
603
|
+
}
|
|
604
|
+
if (children && children.length > 0) {
|
|
605
|
+
const resolvedChildren = children.map((c) => {
|
|
606
|
+
const resolved = this.resolveStateValue(c);
|
|
607
|
+
return this.unwrapReactive(resolved);
|
|
608
|
+
});
|
|
609
|
+
const hasComplexChildren = resolvedChildren.some(
|
|
610
|
+
(c) => typeof c === "object" && c !== null && !Array.isArray(c) && "tagName" in c
|
|
611
|
+
);
|
|
612
|
+
if (pretty && hasComplexChildren) {
|
|
613
|
+
html2 += newLine;
|
|
614
|
+
for (const child of resolvedChildren) {
|
|
615
|
+
if (shouldSkipChild(child)) continue;
|
|
616
|
+
if (Array.isArray(child)) {
|
|
617
|
+
for (const c of child) {
|
|
618
|
+
if (!shouldSkipChild(c)) {
|
|
619
|
+
html2 += this.renderToString(c, { pretty, indent: indent + 1 });
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
} else {
|
|
623
|
+
html2 += this.renderToString(child, { pretty, indent: indent + 1 });
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
html2 += indentStr;
|
|
627
|
+
} else {
|
|
628
|
+
for (const child of resolvedChildren) {
|
|
629
|
+
if (shouldSkipChild(child)) continue;
|
|
630
|
+
if (Array.isArray(child)) {
|
|
631
|
+
for (const c of child) {
|
|
632
|
+
if (!shouldSkipChild(c)) {
|
|
633
|
+
html2 += this.renderToString(c, { pretty: false, indent: 0 });
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
} else {
|
|
637
|
+
html2 += this.renderToString(child, { pretty: false, indent: 0 });
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
html2 += `</${tagName}>${newLine}`;
|
|
643
|
+
return html2;
|
|
644
|
+
}
|
|
645
|
+
resolveStateValue(value) {
|
|
646
|
+
if (value && typeof value === "object" && "value" in value && "subscribe" in value) {
|
|
647
|
+
return value.value;
|
|
648
|
+
}
|
|
649
|
+
return value;
|
|
650
|
+
}
|
|
651
|
+
isReactiveWrapper(vNode) {
|
|
652
|
+
if (!vNode || typeof vNode !== "object" || !vNode.tagName) {
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
return vNode.tagName === "span" && vNode.props?.id && typeof vNode.props.id === "string" && vNode.props.id.match(/^r[a-z0-9]{9}$/);
|
|
656
|
+
}
|
|
657
|
+
unwrapReactive(vNode) {
|
|
658
|
+
if (!this.isReactiveWrapper(vNode)) {
|
|
659
|
+
return vNode;
|
|
660
|
+
}
|
|
661
|
+
const children = vNode.children;
|
|
662
|
+
if (!children || children.length === 0) {
|
|
663
|
+
return "";
|
|
664
|
+
}
|
|
665
|
+
if (children.length === 1) {
|
|
666
|
+
const child = children[0];
|
|
667
|
+
if (child && typeof child === "object" && child.tagName === "span") {
|
|
668
|
+
const props = child.props;
|
|
669
|
+
const hasNoProps = !props || Object.keys(props).length === 0;
|
|
670
|
+
const hasSingleStringChild = child.children && child.children.length === 1 && typeof child.children[0] === "string";
|
|
671
|
+
if (hasNoProps && hasSingleStringChild) {
|
|
672
|
+
return child.children[0];
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return this.unwrapReactive(child);
|
|
676
|
+
}
|
|
677
|
+
return children.map((c) => this.unwrapReactive(c));
|
|
678
|
+
}
|
|
679
|
+
escapeHtml(text2) {
|
|
680
|
+
const htmlEscapes = {
|
|
681
|
+
"&": "&",
|
|
682
|
+
"<": "<",
|
|
683
|
+
">": ">",
|
|
684
|
+
'"': """,
|
|
685
|
+
"'": "'"
|
|
686
|
+
};
|
|
687
|
+
return text2.replace(/[&<>"']/g, (char) => htmlEscapes[char]);
|
|
688
|
+
}
|
|
689
|
+
isSelfClosingTag(tagName) {
|
|
690
|
+
const selfClosingTags = /* @__PURE__ */ new Set([
|
|
691
|
+
"area",
|
|
692
|
+
"base",
|
|
693
|
+
"br",
|
|
694
|
+
"col",
|
|
695
|
+
"embed",
|
|
696
|
+
"hr",
|
|
697
|
+
"img",
|
|
698
|
+
"input",
|
|
699
|
+
"link",
|
|
700
|
+
"meta",
|
|
701
|
+
"param",
|
|
702
|
+
"source",
|
|
703
|
+
"track",
|
|
704
|
+
"wbr"
|
|
705
|
+
]);
|
|
706
|
+
return selfClosingTags.has(tagName.toLowerCase());
|
|
707
|
+
}
|
|
708
|
+
propsToAttributes(props) {
|
|
709
|
+
const attrs = [];
|
|
710
|
+
for (const key in props) {
|
|
711
|
+
if (key === "children" || key === "dangerouslySetInnerHTML" || key === "ref") {
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
let value = props[key];
|
|
715
|
+
value = this.resolveStateValue(value);
|
|
716
|
+
if (value == null || value === false) continue;
|
|
717
|
+
if (key.startsWith("on") && typeof value === "function") {
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
if (key === "className" || key === "class") {
|
|
721
|
+
const className = Array.isArray(value) ? value.join(" ") : value;
|
|
722
|
+
if (className) {
|
|
723
|
+
attrs.push(`class="${this.escapeHtml(String(className))}"`);
|
|
724
|
+
}
|
|
725
|
+
continue;
|
|
726
|
+
}
|
|
727
|
+
if (key === "style") {
|
|
728
|
+
const styleStr = this.styleToString(value);
|
|
729
|
+
if (styleStr) {
|
|
730
|
+
attrs.push(`style="${this.escapeHtml(styleStr)}"`);
|
|
731
|
+
}
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
734
|
+
if (value === true) {
|
|
735
|
+
attrs.push(key);
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
attrs.push(`${key}="${this.escapeHtml(String(value))}"`);
|
|
739
|
+
}
|
|
740
|
+
return attrs.join(" ");
|
|
741
|
+
}
|
|
742
|
+
styleToString(style2) {
|
|
743
|
+
if (typeof style2 === "string") {
|
|
744
|
+
return style2;
|
|
745
|
+
}
|
|
746
|
+
if (typeof style2 === "object" && style2 !== null) {
|
|
747
|
+
const styles2 = [];
|
|
748
|
+
for (const key in style2) {
|
|
749
|
+
const cssKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
750
|
+
styles2.push(`${cssKey}:${style2[key]}`);
|
|
751
|
+
}
|
|
752
|
+
return styles2.join(";");
|
|
753
|
+
}
|
|
754
|
+
return "";
|
|
755
|
+
}
|
|
756
|
+
isState(value) {
|
|
757
|
+
return value && typeof value === "object" && "value" in value && "subscribe" in value && typeof value.subscribe === "function";
|
|
758
|
+
}
|
|
759
|
+
createReactiveChild(state, renderFn) {
|
|
760
|
+
const currentValue = renderFn(state.value);
|
|
761
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
762
|
+
const entry = { node: null, renderFn };
|
|
763
|
+
this.reactiveNodes.set(state, entry);
|
|
764
|
+
state.subscribe(() => {
|
|
765
|
+
if (entry.node && entry.node.parentNode) {
|
|
766
|
+
const newValue = renderFn(state.value);
|
|
767
|
+
entry.node.textContent = String(newValue ?? "");
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
return currentValue;
|
|
772
|
+
}
|
|
773
|
+
jsonToVNode(json) {
|
|
774
|
+
if (this.isState(json)) {
|
|
775
|
+
return this.createReactiveChild(json, (v) => v);
|
|
776
|
+
}
|
|
777
|
+
if (isPrimitiveJson(json)) {
|
|
778
|
+
return json;
|
|
779
|
+
}
|
|
780
|
+
const { tag, attributes = {}, children } = json;
|
|
781
|
+
const props = {};
|
|
782
|
+
for (const key in attributes) {
|
|
783
|
+
const value = attributes[key];
|
|
784
|
+
if (key === "class") {
|
|
785
|
+
props.className = this.isState(value) ? value.value : value;
|
|
786
|
+
} else {
|
|
787
|
+
props[key] = this.isState(value) ? value.value : value;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
const childrenArray = [];
|
|
791
|
+
if (children != null) {
|
|
792
|
+
if (Array.isArray(children)) {
|
|
793
|
+
for (const child of children) {
|
|
794
|
+
if (this.isState(child)) {
|
|
795
|
+
childrenArray.push(this.createReactiveChild(child, (v) => v));
|
|
796
|
+
} else {
|
|
797
|
+
const converted = this.jsonToVNode(child);
|
|
798
|
+
if (converted != null && converted !== false) {
|
|
799
|
+
childrenArray.push(converted);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
} else if (this.isState(children)) {
|
|
804
|
+
childrenArray.push(this.createReactiveChild(children, (v) => v));
|
|
805
|
+
} else if (typeof children === "object" && "tag" in children) {
|
|
806
|
+
const converted = this.jsonToVNode(children);
|
|
807
|
+
if (converted != null && converted !== false) {
|
|
808
|
+
childrenArray.push(converted);
|
|
809
|
+
}
|
|
810
|
+
} else {
|
|
811
|
+
childrenArray.push(children);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
return { tagName: tag, props, children: childrenArray };
|
|
815
|
+
}
|
|
816
|
+
vNodeJsonToVNode(json) {
|
|
817
|
+
if (this.isState(json)) {
|
|
818
|
+
return this.createReactiveChild(json, (v) => v);
|
|
819
|
+
}
|
|
820
|
+
if (isPrimitiveJson(json)) {
|
|
821
|
+
return json;
|
|
822
|
+
}
|
|
823
|
+
const { tagName, props = {}, children = [] } = json;
|
|
824
|
+
const resolvedProps = {};
|
|
825
|
+
for (const key in props) {
|
|
826
|
+
const value = props[key];
|
|
827
|
+
resolvedProps[key] = this.isState(value) ? value.value : value;
|
|
828
|
+
}
|
|
829
|
+
const childrenArray = [];
|
|
830
|
+
for (const child of children) {
|
|
831
|
+
if (this.isState(child)) {
|
|
832
|
+
childrenArray.push(this.createReactiveChild(child, (v) => v));
|
|
833
|
+
} else {
|
|
834
|
+
const converted = this.vNodeJsonToVNode(child);
|
|
835
|
+
if (converted != null && converted !== false) {
|
|
836
|
+
childrenArray.push(converted);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
return { tagName, props: resolvedProps, children: childrenArray };
|
|
841
|
+
}
|
|
842
|
+
renderJson(rootElement, json) {
|
|
843
|
+
const vNode = this.jsonToVNode(json);
|
|
844
|
+
if (!vNode || typeof vNode !== "object" || !("tagName" in vNode)) {
|
|
845
|
+
throw new Error("Invalid JSON structure");
|
|
846
|
+
}
|
|
847
|
+
return this.render(rootElement, vNode);
|
|
848
|
+
}
|
|
849
|
+
renderVNode(rootElement, json) {
|
|
850
|
+
const vNode = this.vNodeJsonToVNode(json);
|
|
851
|
+
if (!vNode || typeof vNode !== "object" || !("tagName" in vNode)) {
|
|
852
|
+
throw new Error("Invalid VNode JSON structure");
|
|
853
|
+
}
|
|
854
|
+
return this.render(rootElement, vNode);
|
|
855
|
+
}
|
|
856
|
+
renderJsonToString(json, options = {}) {
|
|
857
|
+
const vNode = this.jsonToVNode(json);
|
|
858
|
+
return this.renderToString(vNode, options);
|
|
859
|
+
}
|
|
860
|
+
renderVNodeToString(json, options = {}) {
|
|
861
|
+
const vNode = this.vNodeJsonToVNode(json);
|
|
862
|
+
return this.renderToString(vNode, options);
|
|
863
|
+
}
|
|
864
|
+
// Generate complete HTML document as string (for SSR)
|
|
865
|
+
renderToHTMLDocument(vNode, options = {}) {
|
|
866
|
+
const { title: title2 = "", meta: meta2 = [], links = [], scripts = [], styles: styles2 = [], lang = "en", head: head2 = "", bodyAttrs = {}, pretty = false } = options;
|
|
867
|
+
const nl = pretty ? "\n" : "";
|
|
868
|
+
const indent = pretty ? " " : "";
|
|
869
|
+
const indent2 = pretty ? " " : "";
|
|
870
|
+
let html2 = `<!DOCTYPE html>${nl}<html lang="${lang}">${nl}${indent}<head>${nl}${indent2}<meta charset="UTF-8">${nl}${indent2}<meta name="viewport" content="width=device-width, initial-scale=1.0">${nl}`;
|
|
871
|
+
if (title2) html2 += `${indent2}<title>${this.escapeHtml(title2)}</title>${nl}`;
|
|
872
|
+
for (const m of meta2) {
|
|
873
|
+
html2 += `${indent2}<meta`;
|
|
874
|
+
for (const k in m) html2 += ` ${k}="${this.escapeHtml(m[k])}"`;
|
|
875
|
+
html2 += `>${nl}`;
|
|
876
|
+
}
|
|
877
|
+
for (const l of links) {
|
|
878
|
+
html2 += `${indent2}<link`;
|
|
879
|
+
for (const k in l) html2 += ` ${k}="${this.escapeHtml(l[k])}"`;
|
|
880
|
+
html2 += `>${nl}`;
|
|
881
|
+
}
|
|
882
|
+
for (const s2 of styles2) {
|
|
883
|
+
if (s2.href) {
|
|
884
|
+
html2 += `${indent2}<link rel="stylesheet" href="${this.escapeHtml(s2.href)}">${nl}`;
|
|
885
|
+
} else if (s2.content) {
|
|
886
|
+
html2 += `${indent2}<style>${s2.content}</style>${nl}`;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
if (head2) html2 += head2 + nl;
|
|
890
|
+
html2 += `${indent}</head>${nl}${indent}<body`;
|
|
891
|
+
for (const k in bodyAttrs) html2 += ` ${k}="${this.escapeHtml(bodyAttrs[k])}"`;
|
|
892
|
+
html2 += `>${nl}`;
|
|
893
|
+
html2 += this.renderToString(vNode, { pretty, indent: 2 });
|
|
894
|
+
for (const script2 of scripts) {
|
|
895
|
+
html2 += `${indent2}<script`;
|
|
896
|
+
if (script2.type) html2 += ` type="${this.escapeHtml(script2.type)}"`;
|
|
897
|
+
if (script2.async) html2 += ` async`;
|
|
898
|
+
if (script2.defer) html2 += ` defer`;
|
|
899
|
+
if (script2.src) {
|
|
900
|
+
html2 += ` src="${this.escapeHtml(script2.src)}"></script>${nl}`;
|
|
901
|
+
} else if (script2.content) {
|
|
902
|
+
html2 += `>${script2.content}</script>${nl}`;
|
|
903
|
+
} else {
|
|
904
|
+
html2 += `></script>${nl}`;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
html2 += `${indent}</body>${nl}</html>`;
|
|
908
|
+
return html2;
|
|
909
|
+
}
|
|
910
|
+
// Expose elementCache for reactive updates
|
|
911
|
+
getElementCache() {
|
|
912
|
+
return this.elementCache;
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
var dom = new DomNode();
|
|
916
|
+
var render = dom.render.bind(dom);
|
|
917
|
+
var renderToString = dom.renderToString.bind(dom);
|
|
918
|
+
var mount = render;
|
|
919
|
+
|
|
920
|
+
// src/state.ts
|
|
921
|
+
var createState = (initial, options) => dom.createState(initial, options);
|
|
922
|
+
var computed = (states, fn) => dom.computed(states, fn);
|
|
923
|
+
var effect = (fn) => dom.effect(fn);
|
|
924
|
+
var batchRender = (container2, vNodes) => dom.batchRender(container2, vNodes);
|
|
925
|
+
var renderChunked = (container2, vNodes, chunkSize, onProgress) => dom.renderChunked(container2, vNodes, chunkSize, onProgress);
|
|
926
|
+
var createVirtualList = (container2, items, renderItem, itemHeight, bufferSize) => dom.createVirtualList(container2, items, renderItem, itemHeight, bufferSize);
|
|
927
|
+
var lazy = (loadFn) => dom.lazy(loadFn);
|
|
928
|
+
var cleanupUnused = (root) => dom.cleanupUnusedElements(root);
|
|
929
|
+
var throttle = (fn, delay) => {
|
|
930
|
+
let timer = null;
|
|
931
|
+
return (...args) => {
|
|
932
|
+
if (!timer) {
|
|
933
|
+
timer = setTimeout(() => {
|
|
934
|
+
timer = null;
|
|
935
|
+
fn(...args);
|
|
936
|
+
}, delay);
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
};
|
|
940
|
+
var debounce = (fn, delay) => {
|
|
941
|
+
let timer = null;
|
|
942
|
+
return (...args) => {
|
|
943
|
+
timer && clearTimeout(timer);
|
|
944
|
+
timer = setTimeout(() => fn(...args), delay);
|
|
945
|
+
};
|
|
946
|
+
};
|
|
947
|
+
var SharedState = class {
|
|
948
|
+
constructor(key, defaultValue, wsUrl) {
|
|
949
|
+
this.key = key;
|
|
950
|
+
this.wsUrl = wsUrl;
|
|
951
|
+
this.ws = null;
|
|
952
|
+
this.pendingUpdates = [];
|
|
953
|
+
this.localState = createState(defaultValue);
|
|
954
|
+
this.previousValue = defaultValue;
|
|
955
|
+
this.connect();
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Get current value
|
|
959
|
+
*/
|
|
960
|
+
get value() {
|
|
961
|
+
return this.localState.value;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Set new value and sync to server
|
|
965
|
+
*/
|
|
966
|
+
set value(newValue) {
|
|
967
|
+
this.previousValue = this.localState.value;
|
|
968
|
+
this.localState.value = newValue;
|
|
969
|
+
this.sendToServer(newValue);
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Get the underlying Elit State (for reactive binding)
|
|
973
|
+
*/
|
|
974
|
+
get state() {
|
|
975
|
+
return this.localState;
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Subscribe to changes (returns Elit State for reactive)
|
|
979
|
+
*/
|
|
980
|
+
onChange(callback) {
|
|
981
|
+
return this.localState.subscribe((newValue) => {
|
|
982
|
+
const oldValue = this.previousValue;
|
|
983
|
+
this.previousValue = newValue;
|
|
984
|
+
callback(newValue, oldValue);
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Update value using a function
|
|
989
|
+
*/
|
|
990
|
+
update(updater) {
|
|
991
|
+
this.value = updater(this.value);
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Connect to WebSocket
|
|
995
|
+
*/
|
|
996
|
+
connect() {
|
|
997
|
+
if (typeof window === "undefined") return;
|
|
998
|
+
const url = this.wsUrl || `ws://${location.host}`;
|
|
999
|
+
this.ws = new WebSocket(url);
|
|
1000
|
+
this.ws.addEventListener("open", () => {
|
|
1001
|
+
this.subscribe();
|
|
1002
|
+
while (this.pendingUpdates.length > 0) {
|
|
1003
|
+
const value = this.pendingUpdates.shift();
|
|
1004
|
+
this.sendToServer(value);
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
this.ws.addEventListener("message", (event) => {
|
|
1008
|
+
this.handleMessage(event.data);
|
|
1009
|
+
});
|
|
1010
|
+
this.ws.addEventListener("close", () => {
|
|
1011
|
+
setTimeout(() => this.connect(), 1e3);
|
|
1012
|
+
});
|
|
1013
|
+
this.ws.addEventListener("error", (error) => {
|
|
1014
|
+
console.error("[SharedState] WebSocket error:", error);
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Subscribe to server state
|
|
1019
|
+
*/
|
|
1020
|
+
subscribe() {
|
|
1021
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
|
|
1022
|
+
this.ws.send(JSON.stringify({
|
|
1023
|
+
type: "state:subscribe",
|
|
1024
|
+
key: this.key
|
|
1025
|
+
}));
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Handle message from server
|
|
1029
|
+
*/
|
|
1030
|
+
handleMessage(data2) {
|
|
1031
|
+
try {
|
|
1032
|
+
const msg = JSON.parse(data2);
|
|
1033
|
+
if (msg.key !== this.key) return;
|
|
1034
|
+
if (msg.type === "state:init" || msg.type === "state:update") {
|
|
1035
|
+
this.localState.value = msg.value;
|
|
1036
|
+
}
|
|
1037
|
+
} catch (error) {
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Send value to server
|
|
1042
|
+
*/
|
|
1043
|
+
sendToServer(value) {
|
|
1044
|
+
if (!this.ws) return;
|
|
1045
|
+
if (this.ws.readyState !== WebSocket.OPEN) {
|
|
1046
|
+
this.pendingUpdates.push(value);
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
this.ws.send(JSON.stringify({
|
|
1050
|
+
type: "state:change",
|
|
1051
|
+
key: this.key,
|
|
1052
|
+
value
|
|
1053
|
+
}));
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Disconnect
|
|
1057
|
+
*/
|
|
1058
|
+
disconnect() {
|
|
1059
|
+
if (this.ws) {
|
|
1060
|
+
this.ws.close();
|
|
1061
|
+
this.ws = null;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Destroy state and cleanup
|
|
1066
|
+
*/
|
|
1067
|
+
destroy() {
|
|
1068
|
+
this.disconnect();
|
|
1069
|
+
this.localState.destroy();
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1072
|
+
function createSharedState(key, defaultValue, wsUrl) {
|
|
1073
|
+
return new SharedState(key, defaultValue, wsUrl);
|
|
1074
|
+
}
|
|
1075
|
+
var SharedStateManager = class {
|
|
1076
|
+
constructor() {
|
|
1077
|
+
this.states = /* @__PURE__ */ new Map();
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Create or get a shared state
|
|
1081
|
+
*/
|
|
1082
|
+
create(key, defaultValue, wsUrl) {
|
|
1083
|
+
if (this.states.has(key)) {
|
|
1084
|
+
return this.states.get(key);
|
|
1085
|
+
}
|
|
1086
|
+
const state = new SharedState(key, defaultValue, wsUrl);
|
|
1087
|
+
this.states.set(key, state);
|
|
1088
|
+
return state;
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Get existing state
|
|
1092
|
+
*/
|
|
1093
|
+
get(key) {
|
|
1094
|
+
return this.states.get(key);
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Delete a state
|
|
1098
|
+
*/
|
|
1099
|
+
delete(key) {
|
|
1100
|
+
const state = this.states.get(key);
|
|
1101
|
+
if (state) {
|
|
1102
|
+
state.destroy();
|
|
1103
|
+
return this.states.delete(key);
|
|
1104
|
+
}
|
|
1105
|
+
return false;
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Clear all states
|
|
1109
|
+
*/
|
|
1110
|
+
clear() {
|
|
1111
|
+
this.states.forEach((state) => state.destroy());
|
|
1112
|
+
this.states.clear();
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
var sharedStateManager = new SharedStateManager();
|
|
1116
|
+
var scheduleRAFUpdate = (rafId, updateFn) => {
|
|
1117
|
+
rafId && cancelAnimationFrame(rafId);
|
|
1118
|
+
return requestAnimationFrame(() => {
|
|
1119
|
+
updateFn();
|
|
1120
|
+
});
|
|
1121
|
+
};
|
|
1122
|
+
var renderToFragment = (content, isVNode) => {
|
|
1123
|
+
const fragment2 = document.createDocumentFragment();
|
|
1124
|
+
if (isVNode && content && typeof content === "object" && "tagName" in content) {
|
|
1125
|
+
const { children } = content;
|
|
1126
|
+
for (const child of children) {
|
|
1127
|
+
dom.renderToDOM(child, fragment2);
|
|
1128
|
+
}
|
|
1129
|
+
} else {
|
|
1130
|
+
dom.renderToDOM(content, fragment2);
|
|
1131
|
+
}
|
|
1132
|
+
return fragment2;
|
|
1133
|
+
};
|
|
1134
|
+
var updateElementProps = (element, props) => {
|
|
1135
|
+
for (const key in props) {
|
|
1136
|
+
const value = props[key];
|
|
1137
|
+
if (key === "ref") continue;
|
|
1138
|
+
if (key === "class" || key === "className") {
|
|
1139
|
+
element.className = Array.isArray(value) ? value.join(" ") : value || "";
|
|
1140
|
+
} else if (key === "style" && typeof value === "object") {
|
|
1141
|
+
const s2 = element.style;
|
|
1142
|
+
for (const k in value) s2[k] = value[k];
|
|
1143
|
+
} else if (key.startsWith("on")) {
|
|
1144
|
+
element[key.toLowerCase()] = value;
|
|
1145
|
+
} else if (value != null && value !== false) {
|
|
1146
|
+
element.setAttribute(key, String(value === true ? "" : value));
|
|
1147
|
+
} else {
|
|
1148
|
+
element.removeAttribute(key);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
var reactive = (state, renderFn) => {
|
|
1153
|
+
let rafId = null;
|
|
1154
|
+
let elementRef = null;
|
|
1155
|
+
let placeholder = null;
|
|
1156
|
+
let isInDOM = true;
|
|
1157
|
+
const initialResult = renderFn(state.value);
|
|
1158
|
+
const isVNodeResult = initialResult && typeof initialResult === "object" && "tagName" in initialResult;
|
|
1159
|
+
const initialIsNull = initialResult == null || initialResult === false;
|
|
1160
|
+
const updateElement = () => {
|
|
1161
|
+
if (!elementRef && !placeholder) return;
|
|
1162
|
+
const newResult = renderFn(state.value);
|
|
1163
|
+
const resultIsNull = newResult == null || newResult === false;
|
|
1164
|
+
if (resultIsNull) {
|
|
1165
|
+
if (isInDOM && elementRef) {
|
|
1166
|
+
placeholder = document.createComment("reactive");
|
|
1167
|
+
elementRef.parentNode?.replaceChild(placeholder, elementRef);
|
|
1168
|
+
isInDOM = false;
|
|
1169
|
+
}
|
|
1170
|
+
} else {
|
|
1171
|
+
if (!isInDOM && placeholder && elementRef) {
|
|
1172
|
+
placeholder.parentNode?.replaceChild(elementRef, placeholder);
|
|
1173
|
+
placeholder = null;
|
|
1174
|
+
isInDOM = true;
|
|
1175
|
+
}
|
|
1176
|
+
if (elementRef) {
|
|
1177
|
+
const isCurrentVNode = !!(isVNodeResult && newResult && typeof newResult === "object" && "tagName" in newResult);
|
|
1178
|
+
if (isCurrentVNode) {
|
|
1179
|
+
const { props } = newResult;
|
|
1180
|
+
updateElementProps(elementRef, props);
|
|
1181
|
+
}
|
|
1182
|
+
const fragment2 = renderToFragment(newResult, isCurrentVNode);
|
|
1183
|
+
elementRef.textContent = "";
|
|
1184
|
+
elementRef.appendChild(fragment2);
|
|
1185
|
+
dom.getElementCache().set(elementRef, true);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
state.subscribe(() => {
|
|
1190
|
+
rafId = scheduleRAFUpdate(rafId, () => {
|
|
1191
|
+
updateElement();
|
|
1192
|
+
rafId = null;
|
|
1193
|
+
});
|
|
1194
|
+
});
|
|
1195
|
+
const refCallback = (el2) => {
|
|
1196
|
+
elementRef = el2;
|
|
1197
|
+
if (initialIsNull && el2.parentNode) {
|
|
1198
|
+
placeholder = document.createComment("reactive");
|
|
1199
|
+
el2.parentNode.replaceChild(placeholder, el2);
|
|
1200
|
+
isInDOM = false;
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
if (isVNodeResult) {
|
|
1204
|
+
const vnode = initialResult;
|
|
1205
|
+
return {
|
|
1206
|
+
tagName: vnode.tagName,
|
|
1207
|
+
props: { ...vnode.props, ref: refCallback },
|
|
1208
|
+
children: vnode.children
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
return { tagName: "span", props: { ref: refCallback }, children: [initialResult] };
|
|
1212
|
+
};
|
|
1213
|
+
var reactiveAs = (tagName, state, renderFn, props = {}) => {
|
|
1214
|
+
let rafId = null;
|
|
1215
|
+
let elementRef = null;
|
|
1216
|
+
state.subscribe(() => {
|
|
1217
|
+
rafId = scheduleRAFUpdate(rafId, () => {
|
|
1218
|
+
if (elementRef) {
|
|
1219
|
+
const newResult = renderFn(state.value);
|
|
1220
|
+
if (newResult == null || newResult === false) {
|
|
1221
|
+
elementRef.style.display = "none";
|
|
1222
|
+
elementRef.textContent = "";
|
|
1223
|
+
} else {
|
|
1224
|
+
elementRef.style.display = "";
|
|
1225
|
+
const fragment2 = renderToFragment(newResult, false);
|
|
1226
|
+
elementRef.textContent = "";
|
|
1227
|
+
elementRef.appendChild(fragment2);
|
|
1228
|
+
}
|
|
1229
|
+
dom.getElementCache().set(elementRef, true);
|
|
1230
|
+
}
|
|
1231
|
+
rafId = null;
|
|
1232
|
+
});
|
|
1233
|
+
});
|
|
1234
|
+
const refCallback = (el2) => {
|
|
1235
|
+
elementRef = el2;
|
|
1236
|
+
};
|
|
1237
|
+
return { tagName, props: { ...props, ref: refCallback }, children: [renderFn(state.value)] };
|
|
1238
|
+
};
|
|
1239
|
+
var text = (state) => state && state.value !== void 0 ? reactive(state, (v) => ({ tagName: "span", props: {}, children: [String(v)] })) : String(state);
|
|
1240
|
+
var bindValue = (state) => ({
|
|
1241
|
+
value: state.value,
|
|
1242
|
+
oninput: (e) => {
|
|
1243
|
+
state.value = e.target.value;
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
var bindChecked = (state) => ({
|
|
1247
|
+
checked: state.value,
|
|
1248
|
+
onchange: (e) => {
|
|
1249
|
+
state.value = e.target.checked;
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
|
|
1253
|
+
// src/style.ts
|
|
1254
|
+
var CreateStyle = class {
|
|
1255
|
+
constructor() {
|
|
1256
|
+
this.variables = [];
|
|
1257
|
+
this.rules = [];
|
|
1258
|
+
this.mediaRules = [];
|
|
1259
|
+
this.keyframes = [];
|
|
1260
|
+
this.fontFaces = [];
|
|
1261
|
+
this.imports = [];
|
|
1262
|
+
this.containerRules = [];
|
|
1263
|
+
this.supportsRules = [];
|
|
1264
|
+
this.layerRules = [];
|
|
1265
|
+
this._layerOrder = [];
|
|
1266
|
+
}
|
|
1267
|
+
// CSS Variables
|
|
1268
|
+
addVar(name, value) {
|
|
1269
|
+
const cssVar = {
|
|
1270
|
+
name: name.startsWith("--") ? name : `--${name}`,
|
|
1271
|
+
value,
|
|
1272
|
+
toString() {
|
|
1273
|
+
return `var(${this.name})`;
|
|
1274
|
+
}
|
|
1275
|
+
};
|
|
1276
|
+
this.variables.push(cssVar);
|
|
1277
|
+
return cssVar;
|
|
1278
|
+
}
|
|
1279
|
+
var(variable, fallback) {
|
|
1280
|
+
const varName = typeof variable === "string" ? variable.startsWith("--") ? variable : `--${variable}` : variable.name;
|
|
1281
|
+
return fallback ? `var(${varName}, ${fallback})` : `var(${varName})`;
|
|
1282
|
+
}
|
|
1283
|
+
// Basic Selectors
|
|
1284
|
+
addTag(tag, styles2) {
|
|
1285
|
+
const rule = { selector: tag, styles: styles2, type: "tag" };
|
|
1286
|
+
this.rules.push(rule);
|
|
1287
|
+
return rule;
|
|
1288
|
+
}
|
|
1289
|
+
addClass(name, styles2) {
|
|
1290
|
+
const selector = name.startsWith(".") ? name : `.${name}`;
|
|
1291
|
+
const rule = { selector, styles: styles2, type: "class" };
|
|
1292
|
+
this.rules.push(rule);
|
|
1293
|
+
return rule;
|
|
1294
|
+
}
|
|
1295
|
+
addId(name, styles2) {
|
|
1296
|
+
const selector = name.startsWith("#") ? name : `#${name}`;
|
|
1297
|
+
const rule = { selector, styles: styles2, type: "id" };
|
|
1298
|
+
this.rules.push(rule);
|
|
1299
|
+
return rule;
|
|
1300
|
+
}
|
|
1301
|
+
// Pseudo Selectors
|
|
1302
|
+
addPseudoClass(pseudo, styles2, baseSelector) {
|
|
1303
|
+
const pseudoClass = pseudo.startsWith(":") ? pseudo : `:${pseudo}`;
|
|
1304
|
+
const selector = baseSelector ? `${baseSelector}${pseudoClass}` : pseudoClass;
|
|
1305
|
+
const rule = { selector, styles: styles2, type: "pseudo-class" };
|
|
1306
|
+
this.rules.push(rule);
|
|
1307
|
+
return rule;
|
|
1308
|
+
}
|
|
1309
|
+
addPseudoElement(pseudo, styles2, baseSelector) {
|
|
1310
|
+
const pseudoElement = pseudo.startsWith("::") ? pseudo : `::${pseudo}`;
|
|
1311
|
+
const selector = baseSelector ? `${baseSelector}${pseudoElement}` : pseudoElement;
|
|
1312
|
+
const rule = { selector, styles: styles2, type: "pseudo-element" };
|
|
1313
|
+
this.rules.push(rule);
|
|
1314
|
+
return rule;
|
|
1315
|
+
}
|
|
1316
|
+
// Attribute Selectors
|
|
1317
|
+
addAttribute(attr, styles2, baseSelector) {
|
|
1318
|
+
const attrSelector = attr.startsWith("[") ? attr : `[${attr}]`;
|
|
1319
|
+
const selector = baseSelector ? `${baseSelector}${attrSelector}` : attrSelector;
|
|
1320
|
+
const rule = { selector, styles: styles2, type: "attribute" };
|
|
1321
|
+
this.rules.push(rule);
|
|
1322
|
+
return rule;
|
|
1323
|
+
}
|
|
1324
|
+
attrEquals(attr, value, styles2, baseSelector) {
|
|
1325
|
+
return this.addAttribute(`${attr}="${value}"`, styles2, baseSelector);
|
|
1326
|
+
}
|
|
1327
|
+
attrContainsWord(attr, value, styles2, baseSelector) {
|
|
1328
|
+
return this.addAttribute(`${attr}~="${value}"`, styles2, baseSelector);
|
|
1329
|
+
}
|
|
1330
|
+
attrStartsWith(attr, value, styles2, baseSelector) {
|
|
1331
|
+
return this.addAttribute(`${attr}^="${value}"`, styles2, baseSelector);
|
|
1332
|
+
}
|
|
1333
|
+
attrEndsWith(attr, value, styles2, baseSelector) {
|
|
1334
|
+
return this.addAttribute(`${attr}$="${value}"`, styles2, baseSelector);
|
|
1335
|
+
}
|
|
1336
|
+
attrContains(attr, value, styles2, baseSelector) {
|
|
1337
|
+
return this.addAttribute(`${attr}*="${value}"`, styles2, baseSelector);
|
|
1338
|
+
}
|
|
1339
|
+
// Combinator Selectors
|
|
1340
|
+
descendant(ancestor, descendant2, styles2) {
|
|
1341
|
+
return this.createAndAddRule(`${ancestor} ${descendant2}`, styles2);
|
|
1342
|
+
}
|
|
1343
|
+
child(parent, childSel, styles2) {
|
|
1344
|
+
return this.createAndAddRule(`${parent} > ${childSel}`, styles2);
|
|
1345
|
+
}
|
|
1346
|
+
adjacentSibling(element, sibling, styles2) {
|
|
1347
|
+
return this.createAndAddRule(`${element} + ${sibling}`, styles2);
|
|
1348
|
+
}
|
|
1349
|
+
generalSibling(element, sibling, styles2) {
|
|
1350
|
+
return this.createAndAddRule(`${element} ~ ${sibling}`, styles2);
|
|
1351
|
+
}
|
|
1352
|
+
multiple(selectors, styles2) {
|
|
1353
|
+
return this.createAndAddRule(selectors.join(", "), styles2);
|
|
1354
|
+
}
|
|
1355
|
+
// Nesting (BEM-style)
|
|
1356
|
+
addName(name, styles2) {
|
|
1357
|
+
const selector = name.startsWith("--") ? `&${name}` : `&--${name}`;
|
|
1358
|
+
const rule = { selector, styles: styles2, type: "name" };
|
|
1359
|
+
return rule;
|
|
1360
|
+
}
|
|
1361
|
+
nesting(parentRule, ...childRules) {
|
|
1362
|
+
parentRule.nested = childRules;
|
|
1363
|
+
return parentRule;
|
|
1364
|
+
}
|
|
1365
|
+
// @keyframes - Animations
|
|
1366
|
+
keyframe(name, steps) {
|
|
1367
|
+
const keyframeSteps = Object.entries(steps).map(([step, styles2]) => ({
|
|
1368
|
+
step: step === "from" ? "from" : step === "to" ? "to" : `${step}%`,
|
|
1369
|
+
styles: styles2
|
|
1370
|
+
}));
|
|
1371
|
+
const kf = { name, steps: keyframeSteps };
|
|
1372
|
+
this.keyframes.push(kf);
|
|
1373
|
+
return kf;
|
|
1374
|
+
}
|
|
1375
|
+
keyframeFromTo(name, from, to) {
|
|
1376
|
+
return this.keyframe(name, { from, to });
|
|
1377
|
+
}
|
|
1378
|
+
// @font-face - Custom Fonts
|
|
1379
|
+
fontFace(options) {
|
|
1380
|
+
this.fontFaces.push(options);
|
|
1381
|
+
return options;
|
|
1382
|
+
}
|
|
1383
|
+
// @import - Import Stylesheets
|
|
1384
|
+
import(url, mediaQuery) {
|
|
1385
|
+
const importRule = mediaQuery ? `@import url("${url}") ${mediaQuery};` : `@import url("${url}");`;
|
|
1386
|
+
this.imports.push(importRule);
|
|
1387
|
+
return importRule;
|
|
1388
|
+
}
|
|
1389
|
+
// @media - Media Queries
|
|
1390
|
+
media(type, condition, rules) {
|
|
1391
|
+
const mediaRule = { type, condition, rules: this.rulesToCSSRules(rules) };
|
|
1392
|
+
this.mediaRules.push(mediaRule);
|
|
1393
|
+
return mediaRule;
|
|
1394
|
+
}
|
|
1395
|
+
mediaScreen(condition, rules) {
|
|
1396
|
+
return this.media("screen", condition, rules);
|
|
1397
|
+
}
|
|
1398
|
+
mediaPrint(rules) {
|
|
1399
|
+
return this.media("print", "", rules);
|
|
1400
|
+
}
|
|
1401
|
+
mediaMinWidth(minWidth, rules) {
|
|
1402
|
+
return this.media("screen", `min-width: ${minWidth}`, rules);
|
|
1403
|
+
}
|
|
1404
|
+
mediaMaxWidth(maxWidth, rules) {
|
|
1405
|
+
return this.media("screen", `max-width: ${maxWidth}`, rules);
|
|
1406
|
+
}
|
|
1407
|
+
mediaDark(rules) {
|
|
1408
|
+
const mediaRule = { type: "", condition: "prefers-color-scheme: dark", rules: this.rulesToCSSRules(rules) };
|
|
1409
|
+
this.mediaRules.push(mediaRule);
|
|
1410
|
+
return mediaRule;
|
|
1411
|
+
}
|
|
1412
|
+
mediaLight(rules) {
|
|
1413
|
+
const mediaRule = { type: "", condition: "prefers-color-scheme: light", rules: this.rulesToCSSRules(rules) };
|
|
1414
|
+
this.mediaRules.push(mediaRule);
|
|
1415
|
+
return mediaRule;
|
|
1416
|
+
}
|
|
1417
|
+
mediaReducedMotion(rules) {
|
|
1418
|
+
const mediaRule = { type: "", condition: "prefers-reduced-motion: reduce", rules: this.rulesToCSSRules(rules) };
|
|
1419
|
+
this.mediaRules.push(mediaRule);
|
|
1420
|
+
return mediaRule;
|
|
1421
|
+
}
|
|
1422
|
+
// @container - Container Queries
|
|
1423
|
+
container(condition, rules, name) {
|
|
1424
|
+
const containerRule = { name, condition, rules: this.rulesToCSSRules(rules) };
|
|
1425
|
+
this.containerRules.push(containerRule);
|
|
1426
|
+
return containerRule;
|
|
1427
|
+
}
|
|
1428
|
+
addContainer(name, styles2) {
|
|
1429
|
+
const containerStyles = { ...styles2, containerName: name };
|
|
1430
|
+
return this.addClass(name, containerStyles);
|
|
1431
|
+
}
|
|
1432
|
+
// @supports - Feature Queries
|
|
1433
|
+
supports(condition, rules) {
|
|
1434
|
+
const supportsRule = { condition, rules: this.rulesToCSSRules(rules) };
|
|
1435
|
+
this.supportsRules.push(supportsRule);
|
|
1436
|
+
return supportsRule;
|
|
1437
|
+
}
|
|
1438
|
+
// @layer - Cascade Layers
|
|
1439
|
+
layerOrder(...layers) {
|
|
1440
|
+
this._layerOrder = layers;
|
|
1441
|
+
}
|
|
1442
|
+
layer(name, rules) {
|
|
1443
|
+
const layerRule = { name, rules: this.rulesToCSSRules(rules) };
|
|
1444
|
+
this.layerRules.push(layerRule);
|
|
1445
|
+
return layerRule;
|
|
1446
|
+
}
|
|
1447
|
+
// Custom Rules
|
|
1448
|
+
add(rules) {
|
|
1449
|
+
const cssRules = Object.entries(rules).map(([selector, styles2]) => {
|
|
1450
|
+
const rule = { selector, styles: styles2, type: "custom" };
|
|
1451
|
+
this.rules.push(rule);
|
|
1452
|
+
return rule;
|
|
1453
|
+
});
|
|
1454
|
+
return cssRules;
|
|
1455
|
+
}
|
|
1456
|
+
important(value) {
|
|
1457
|
+
return `${value} !important`;
|
|
1458
|
+
}
|
|
1459
|
+
// Utility Methods
|
|
1460
|
+
toKebabCase(str) {
|
|
1461
|
+
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1462
|
+
}
|
|
1463
|
+
// Helper: Create and add rule (eliminates duplication in combinator selectors)
|
|
1464
|
+
createAndAddRule(selector, styles2, type = "custom") {
|
|
1465
|
+
const rule = { selector, styles: styles2, type };
|
|
1466
|
+
this.rules.push(rule);
|
|
1467
|
+
return rule;
|
|
1468
|
+
}
|
|
1469
|
+
// Helper: Convert rules object to CSSRule array (eliminates duplication in media/container/supports/layer)
|
|
1470
|
+
rulesToCSSRules(rules) {
|
|
1471
|
+
return Object.entries(rules).map(([selector, styles2]) => ({
|
|
1472
|
+
selector,
|
|
1473
|
+
styles: styles2,
|
|
1474
|
+
type: "custom"
|
|
1475
|
+
}));
|
|
1476
|
+
}
|
|
1477
|
+
// Helper: Render rules with indentation (eliminates duplication in render methods)
|
|
1478
|
+
renderRulesWithIndent(rules, indent = " ") {
|
|
1479
|
+
return rules.map((rule) => this.renderRule(rule, indent)).join("\n");
|
|
1480
|
+
}
|
|
1481
|
+
stylesToString(styles2, indent = " ") {
|
|
1482
|
+
return Object.entries(styles2).map(([prop, value]) => {
|
|
1483
|
+
const cssValue = typeof value === "object" && value !== null && "name" in value ? `var(${value.name})` : value;
|
|
1484
|
+
return `${indent}${this.toKebabCase(prop)}: ${cssValue};`;
|
|
1485
|
+
}).join("\n");
|
|
1486
|
+
}
|
|
1487
|
+
renderRule(rule, indent = "") {
|
|
1488
|
+
let css = `${indent}${rule.selector} {
|
|
1489
|
+
${this.stylesToString(rule.styles, indent + " ")}
|
|
1490
|
+
`;
|
|
1491
|
+
if (rule.nested && rule.nested.length > 0) {
|
|
1492
|
+
for (const nestedRule of rule.nested) {
|
|
1493
|
+
const nestedSelector = nestedRule.selector.startsWith("&") ? nestedRule.selector.replace(/&/g, rule.selector) : `${rule.selector} ${nestedRule.selector}`;
|
|
1494
|
+
css += `
|
|
1495
|
+
${indent}${nestedSelector} {
|
|
1496
|
+
${this.stylesToString(nestedRule.styles, indent + " ")}
|
|
1497
|
+
${indent}}
|
|
1498
|
+
`;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
css += `${indent}}`;
|
|
1502
|
+
return css;
|
|
1503
|
+
}
|
|
1504
|
+
renderMediaRule(media) {
|
|
1505
|
+
const condition = media.type && media.condition ? `${media.type} and (${media.condition})` : media.type ? media.type : `(${media.condition})`;
|
|
1506
|
+
return `@media ${condition} {
|
|
1507
|
+
${this.renderRulesWithIndent(media.rules)}
|
|
1508
|
+
}`;
|
|
1509
|
+
}
|
|
1510
|
+
renderKeyframes(kf) {
|
|
1511
|
+
let css = `@keyframes ${kf.name} {
|
|
1512
|
+
`;
|
|
1513
|
+
for (const step of kf.steps) {
|
|
1514
|
+
css += ` ${step.step} {
|
|
1515
|
+
${this.stylesToString(step.styles, " ")}
|
|
1516
|
+
}
|
|
1517
|
+
`;
|
|
1518
|
+
}
|
|
1519
|
+
css += "}";
|
|
1520
|
+
return css;
|
|
1521
|
+
}
|
|
1522
|
+
renderFontFace(ff) {
|
|
1523
|
+
let css = "@font-face {\n";
|
|
1524
|
+
css += ` font-family: "${ff.fontFamily}";
|
|
1525
|
+
`;
|
|
1526
|
+
css += ` src: ${ff.src};
|
|
1527
|
+
`;
|
|
1528
|
+
if (ff.fontWeight) css += ` font-weight: ${ff.fontWeight};
|
|
1529
|
+
`;
|
|
1530
|
+
if (ff.fontStyle) css += ` font-style: ${ff.fontStyle};
|
|
1531
|
+
`;
|
|
1532
|
+
if (ff.fontDisplay) css += ` font-display: ${ff.fontDisplay};
|
|
1533
|
+
`;
|
|
1534
|
+
if (ff.unicodeRange) css += ` unicode-range: ${ff.unicodeRange};
|
|
1535
|
+
`;
|
|
1536
|
+
css += "}";
|
|
1537
|
+
return css;
|
|
1538
|
+
}
|
|
1539
|
+
renderContainerRule(container2) {
|
|
1540
|
+
const nameStr = container2.name ? `${container2.name} ` : "";
|
|
1541
|
+
return `@container ${nameStr}(${container2.condition}) {
|
|
1542
|
+
${this.renderRulesWithIndent(container2.rules)}
|
|
1543
|
+
}`;
|
|
1544
|
+
}
|
|
1545
|
+
renderSupportsRule(supports) {
|
|
1546
|
+
return `@supports (${supports.condition}) {
|
|
1547
|
+
${this.renderRulesWithIndent(supports.rules)}
|
|
1548
|
+
}`;
|
|
1549
|
+
}
|
|
1550
|
+
renderLayerRule(layer2) {
|
|
1551
|
+
return `@layer ${layer2.name} {
|
|
1552
|
+
${this.renderRulesWithIndent(layer2.rules)}
|
|
1553
|
+
}`;
|
|
1554
|
+
}
|
|
1555
|
+
// Render Output
|
|
1556
|
+
render(...additionalRules) {
|
|
1557
|
+
const parts = [];
|
|
1558
|
+
if (this.imports.length > 0) {
|
|
1559
|
+
parts.push(this.imports.join("\n"));
|
|
1560
|
+
}
|
|
1561
|
+
if (this._layerOrder.length > 0) {
|
|
1562
|
+
parts.push(`@layer ${this._layerOrder.join(", ")};`);
|
|
1563
|
+
}
|
|
1564
|
+
if (this.variables.length > 0) {
|
|
1565
|
+
const varDeclarations = this.variables.map((v) => ` ${v.name}: ${v.value};`).join("\n");
|
|
1566
|
+
parts.push(`:root {
|
|
1567
|
+
${varDeclarations}
|
|
1568
|
+
}`);
|
|
1569
|
+
}
|
|
1570
|
+
for (const ff of this.fontFaces) {
|
|
1571
|
+
parts.push(this.renderFontFace(ff));
|
|
1572
|
+
}
|
|
1573
|
+
for (const kf of this.keyframes) {
|
|
1574
|
+
parts.push(this.renderKeyframes(kf));
|
|
1575
|
+
}
|
|
1576
|
+
const allRules = [...this.rules];
|
|
1577
|
+
const allMediaRules = [...this.mediaRules];
|
|
1578
|
+
const allKeyframes = [];
|
|
1579
|
+
const allContainerRules = [...this.containerRules];
|
|
1580
|
+
const allSupportsRules = [...this.supportsRules];
|
|
1581
|
+
const allLayerRules = [...this.layerRules];
|
|
1582
|
+
for (const item of additionalRules) {
|
|
1583
|
+
if (!item) continue;
|
|
1584
|
+
if (Array.isArray(item)) {
|
|
1585
|
+
allRules.push(...item);
|
|
1586
|
+
} else if ("condition" in item && "rules" in item && !("name" in item && "steps" in item)) {
|
|
1587
|
+
if ("type" in item) {
|
|
1588
|
+
allMediaRules.push(item);
|
|
1589
|
+
} else if ("name" in item && typeof item.name === "string") {
|
|
1590
|
+
allContainerRules.push(item);
|
|
1591
|
+
} else {
|
|
1592
|
+
allSupportsRules.push(item);
|
|
1593
|
+
}
|
|
1594
|
+
} else if ("name" in item && "steps" in item) {
|
|
1595
|
+
allKeyframes.push(item);
|
|
1596
|
+
} else if ("name" in item && "rules" in item) {
|
|
1597
|
+
allLayerRules.push(item);
|
|
1598
|
+
} else {
|
|
1599
|
+
allRules.push(item);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
for (const kf of allKeyframes) {
|
|
1603
|
+
parts.push(this.renderKeyframes(kf));
|
|
1604
|
+
}
|
|
1605
|
+
for (const layer2 of allLayerRules) {
|
|
1606
|
+
parts.push(this.renderLayerRule(layer2));
|
|
1607
|
+
}
|
|
1608
|
+
for (const rule of allRules) {
|
|
1609
|
+
parts.push(this.renderRule(rule));
|
|
1610
|
+
}
|
|
1611
|
+
for (const supports of allSupportsRules) {
|
|
1612
|
+
parts.push(this.renderSupportsRule(supports));
|
|
1613
|
+
}
|
|
1614
|
+
for (const container2 of allContainerRules) {
|
|
1615
|
+
parts.push(this.renderContainerRule(container2));
|
|
1616
|
+
}
|
|
1617
|
+
for (const media of allMediaRules) {
|
|
1618
|
+
parts.push(this.renderMediaRule(media));
|
|
1619
|
+
}
|
|
1620
|
+
return parts.join("\n\n");
|
|
1621
|
+
}
|
|
1622
|
+
inject(styleId) {
|
|
1623
|
+
const css = this.render();
|
|
1624
|
+
const style2 = document.createElement("style");
|
|
1625
|
+
if (styleId) style2.id = styleId;
|
|
1626
|
+
style2.textContent = css;
|
|
1627
|
+
document.head.appendChild(style2);
|
|
1628
|
+
return style2;
|
|
1629
|
+
}
|
|
1630
|
+
clear() {
|
|
1631
|
+
this.variables = [];
|
|
1632
|
+
this.rules = [];
|
|
1633
|
+
this.mediaRules = [];
|
|
1634
|
+
this.keyframes = [];
|
|
1635
|
+
this.fontFaces = [];
|
|
1636
|
+
this.imports = [];
|
|
1637
|
+
this.containerRules = [];
|
|
1638
|
+
this.supportsRules = [];
|
|
1639
|
+
this.layerRules = [];
|
|
1640
|
+
this._layerOrder = [];
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
var styles = new CreateStyle();
|
|
1644
|
+
var {
|
|
1645
|
+
addVar,
|
|
1646
|
+
var: getVar,
|
|
1647
|
+
addTag,
|
|
1648
|
+
addClass,
|
|
1649
|
+
addId,
|
|
1650
|
+
addPseudoClass,
|
|
1651
|
+
addPseudoElement,
|
|
1652
|
+
addAttribute,
|
|
1653
|
+
attrEquals,
|
|
1654
|
+
attrContainsWord,
|
|
1655
|
+
attrStartsWith,
|
|
1656
|
+
attrEndsWith,
|
|
1657
|
+
attrContains,
|
|
1658
|
+
descendant,
|
|
1659
|
+
child: childStyle,
|
|
1660
|
+
adjacentSibling,
|
|
1661
|
+
generalSibling,
|
|
1662
|
+
multiple: multipleStyle,
|
|
1663
|
+
addName,
|
|
1664
|
+
nesting,
|
|
1665
|
+
keyframe,
|
|
1666
|
+
keyframeFromTo,
|
|
1667
|
+
fontFace,
|
|
1668
|
+
import: importStyle,
|
|
1669
|
+
media: mediaStyle,
|
|
1670
|
+
mediaScreen,
|
|
1671
|
+
mediaPrint,
|
|
1672
|
+
mediaMinWidth,
|
|
1673
|
+
mediaMaxWidth,
|
|
1674
|
+
mediaDark,
|
|
1675
|
+
mediaLight,
|
|
1676
|
+
mediaReducedMotion,
|
|
1677
|
+
container,
|
|
1678
|
+
addContainer,
|
|
1679
|
+
supports: supportsStyle,
|
|
1680
|
+
layerOrder,
|
|
1681
|
+
layer,
|
|
1682
|
+
add: addStyle,
|
|
1683
|
+
important,
|
|
1684
|
+
render: renderStyle,
|
|
1685
|
+
inject: injectStyle,
|
|
1686
|
+
clear: clearStyle
|
|
1687
|
+
} = styles;
|
|
1688
|
+
|
|
1689
|
+
// src/el.ts
|
|
1690
|
+
var hasDocument = typeof document !== "undefined";
|
|
1691
|
+
function capitalize(str) {
|
|
1692
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1693
|
+
}
|
|
1694
|
+
function bindDocMethod(method) {
|
|
1695
|
+
return hasDocument && method ? method.bind(doc) : void 0;
|
|
1696
|
+
}
|
|
1697
|
+
function createPrefixedFactories(tags2, prefix, elements2) {
|
|
1698
|
+
tags2.forEach((tag) => {
|
|
1699
|
+
const name = prefix + capitalize(tag);
|
|
1700
|
+
elements2[name] = createElementFactory(tag);
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
var createElementFactory = (tag) => {
|
|
1704
|
+
return function(props, ...rest) {
|
|
1705
|
+
if (!arguments.length) return { tagName: tag, props: {}, children: [] };
|
|
1706
|
+
const isState = props && typeof props === "object" && "value" in props && "subscribe" in props;
|
|
1707
|
+
const isVNode = props && typeof props === "object" && "tagName" in props;
|
|
1708
|
+
const isChild = typeof props !== "object" || Array.isArray(props) || props === null || isState || isVNode;
|
|
1709
|
+
const actualProps = isChild ? {} : props;
|
|
1710
|
+
const args = isChild ? [props, ...rest] : rest;
|
|
1711
|
+
if (!args.length) return { tagName: tag, props: actualProps, children: [] };
|
|
1712
|
+
const flatChildren = [];
|
|
1713
|
+
for (let i2 = 0, len = args.length; i2 < len; i2++) {
|
|
1714
|
+
const child = args[i2];
|
|
1715
|
+
if (child == null || child === false) continue;
|
|
1716
|
+
if (Array.isArray(child)) {
|
|
1717
|
+
for (let j = 0, cLen = child.length; j < cLen; j++) {
|
|
1718
|
+
const c = child[j];
|
|
1719
|
+
c != null && c !== false && flatChildren.push(c);
|
|
1720
|
+
}
|
|
1721
|
+
} else {
|
|
1722
|
+
flatChildren.push(child);
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
return { tagName: tag, props: actualProps, children: flatChildren };
|
|
1726
|
+
};
|
|
1727
|
+
};
|
|
1728
|
+
var tags = [
|
|
1729
|
+
"html",
|
|
1730
|
+
"head",
|
|
1731
|
+
"body",
|
|
1732
|
+
"title",
|
|
1733
|
+
"base",
|
|
1734
|
+
"link",
|
|
1735
|
+
"meta",
|
|
1736
|
+
"style",
|
|
1737
|
+
"address",
|
|
1738
|
+
"article",
|
|
1739
|
+
"aside",
|
|
1740
|
+
"footer",
|
|
1741
|
+
"header",
|
|
1742
|
+
"h1",
|
|
1743
|
+
"h2",
|
|
1744
|
+
"h3",
|
|
1745
|
+
"h4",
|
|
1746
|
+
"h5",
|
|
1747
|
+
"h6",
|
|
1748
|
+
"main",
|
|
1749
|
+
"nav",
|
|
1750
|
+
"section",
|
|
1751
|
+
"blockquote",
|
|
1752
|
+
"dd",
|
|
1753
|
+
"div",
|
|
1754
|
+
"dl",
|
|
1755
|
+
"dt",
|
|
1756
|
+
"figcaption",
|
|
1757
|
+
"figure",
|
|
1758
|
+
"hr",
|
|
1759
|
+
"li",
|
|
1760
|
+
"ol",
|
|
1761
|
+
"p",
|
|
1762
|
+
"pre",
|
|
1763
|
+
"ul",
|
|
1764
|
+
"a",
|
|
1765
|
+
"abbr",
|
|
1766
|
+
"b",
|
|
1767
|
+
"bdi",
|
|
1768
|
+
"bdo",
|
|
1769
|
+
"br",
|
|
1770
|
+
"cite",
|
|
1771
|
+
"code",
|
|
1772
|
+
"data",
|
|
1773
|
+
"dfn",
|
|
1774
|
+
"em",
|
|
1775
|
+
"i",
|
|
1776
|
+
"kbd",
|
|
1777
|
+
"mark",
|
|
1778
|
+
"q",
|
|
1779
|
+
"rp",
|
|
1780
|
+
"rt",
|
|
1781
|
+
"ruby",
|
|
1782
|
+
"s",
|
|
1783
|
+
"samp",
|
|
1784
|
+
"small",
|
|
1785
|
+
"span",
|
|
1786
|
+
"strong",
|
|
1787
|
+
"sub",
|
|
1788
|
+
"sup",
|
|
1789
|
+
"time",
|
|
1790
|
+
"u",
|
|
1791
|
+
"wbr",
|
|
1792
|
+
"area",
|
|
1793
|
+
"audio",
|
|
1794
|
+
"img",
|
|
1795
|
+
"map",
|
|
1796
|
+
"track",
|
|
1797
|
+
"video",
|
|
1798
|
+
"embed",
|
|
1799
|
+
"iframe",
|
|
1800
|
+
"object",
|
|
1801
|
+
"param",
|
|
1802
|
+
"picture",
|
|
1803
|
+
"portal",
|
|
1804
|
+
"source",
|
|
1805
|
+
"canvas",
|
|
1806
|
+
"noscript",
|
|
1807
|
+
"script",
|
|
1808
|
+
"del",
|
|
1809
|
+
"ins",
|
|
1810
|
+
"caption",
|
|
1811
|
+
"col",
|
|
1812
|
+
"colgroup",
|
|
1813
|
+
"table",
|
|
1814
|
+
"tbody",
|
|
1815
|
+
"td",
|
|
1816
|
+
"tfoot",
|
|
1817
|
+
"th",
|
|
1818
|
+
"thead",
|
|
1819
|
+
"tr",
|
|
1820
|
+
"button",
|
|
1821
|
+
"datalist",
|
|
1822
|
+
"fieldset",
|
|
1823
|
+
"form",
|
|
1824
|
+
"input",
|
|
1825
|
+
"label",
|
|
1826
|
+
"legend",
|
|
1827
|
+
"meter",
|
|
1828
|
+
"optgroup",
|
|
1829
|
+
"option",
|
|
1830
|
+
"output",
|
|
1831
|
+
"progress",
|
|
1832
|
+
"select",
|
|
1833
|
+
"textarea",
|
|
1834
|
+
"details",
|
|
1835
|
+
"dialog",
|
|
1836
|
+
"menu",
|
|
1837
|
+
"summary",
|
|
1838
|
+
"slot",
|
|
1839
|
+
"template"
|
|
1840
|
+
];
|
|
1841
|
+
var svgTags = [
|
|
1842
|
+
"svg",
|
|
1843
|
+
"circle",
|
|
1844
|
+
"rect",
|
|
1845
|
+
"path",
|
|
1846
|
+
"line",
|
|
1847
|
+
"polyline",
|
|
1848
|
+
"polygon",
|
|
1849
|
+
"ellipse",
|
|
1850
|
+
"g",
|
|
1851
|
+
"text",
|
|
1852
|
+
"tspan",
|
|
1853
|
+
"defs",
|
|
1854
|
+
"linearGradient",
|
|
1855
|
+
"radialGradient",
|
|
1856
|
+
"stop",
|
|
1857
|
+
"pattern",
|
|
1858
|
+
"mask",
|
|
1859
|
+
"clipPath",
|
|
1860
|
+
"use",
|
|
1861
|
+
"symbol",
|
|
1862
|
+
"marker",
|
|
1863
|
+
"image",
|
|
1864
|
+
"foreignObject",
|
|
1865
|
+
"animate",
|
|
1866
|
+
"animateTransform",
|
|
1867
|
+
"animateMotion",
|
|
1868
|
+
"set",
|
|
1869
|
+
"filter",
|
|
1870
|
+
"feBlend",
|
|
1871
|
+
"feColorMatrix",
|
|
1872
|
+
"feComponentTransfer",
|
|
1873
|
+
"feComposite",
|
|
1874
|
+
"feConvolveMatrix",
|
|
1875
|
+
"feDiffuseLighting",
|
|
1876
|
+
"feDisplacementMap",
|
|
1877
|
+
"feFlood",
|
|
1878
|
+
"feGaussianBlur",
|
|
1879
|
+
"feMorphology",
|
|
1880
|
+
"feOffset",
|
|
1881
|
+
"feSpecularLighting",
|
|
1882
|
+
"feTile",
|
|
1883
|
+
"feTurbulence"
|
|
1884
|
+
];
|
|
1885
|
+
var mathTags = [
|
|
1886
|
+
"math",
|
|
1887
|
+
"mi",
|
|
1888
|
+
"mn",
|
|
1889
|
+
"mo",
|
|
1890
|
+
"ms",
|
|
1891
|
+
"mtext",
|
|
1892
|
+
"mrow",
|
|
1893
|
+
"mfrac",
|
|
1894
|
+
"msqrt",
|
|
1895
|
+
"mroot",
|
|
1896
|
+
"msub",
|
|
1897
|
+
"msup"
|
|
1898
|
+
];
|
|
1899
|
+
var elements = {};
|
|
1900
|
+
tags.forEach((tag) => {
|
|
1901
|
+
elements[tag] = createElementFactory(tag);
|
|
1902
|
+
});
|
|
1903
|
+
createPrefixedFactories(svgTags, "svg", elements);
|
|
1904
|
+
createPrefixedFactories(mathTags, "math", elements);
|
|
1905
|
+
elements.varElement = createElementFactory("var");
|
|
1906
|
+
var {
|
|
1907
|
+
html,
|
|
1908
|
+
head,
|
|
1909
|
+
body,
|
|
1910
|
+
title,
|
|
1911
|
+
base,
|
|
1912
|
+
link,
|
|
1913
|
+
meta,
|
|
1914
|
+
style,
|
|
1915
|
+
address,
|
|
1916
|
+
article,
|
|
1917
|
+
aside,
|
|
1918
|
+
footer,
|
|
1919
|
+
header,
|
|
1920
|
+
h1,
|
|
1921
|
+
h2,
|
|
1922
|
+
h3,
|
|
1923
|
+
h4,
|
|
1924
|
+
h5,
|
|
1925
|
+
h6,
|
|
1926
|
+
main,
|
|
1927
|
+
nav,
|
|
1928
|
+
section,
|
|
1929
|
+
blockquote,
|
|
1930
|
+
dd,
|
|
1931
|
+
div,
|
|
1932
|
+
dl,
|
|
1933
|
+
dt,
|
|
1934
|
+
figcaption,
|
|
1935
|
+
figure,
|
|
1936
|
+
hr,
|
|
1937
|
+
li,
|
|
1938
|
+
ol,
|
|
1939
|
+
p,
|
|
1940
|
+
pre,
|
|
1941
|
+
ul,
|
|
1942
|
+
a,
|
|
1943
|
+
abbr,
|
|
1944
|
+
b,
|
|
1945
|
+
bdi,
|
|
1946
|
+
bdo,
|
|
1947
|
+
br,
|
|
1948
|
+
cite,
|
|
1949
|
+
code,
|
|
1950
|
+
data,
|
|
1951
|
+
dfn,
|
|
1952
|
+
em,
|
|
1953
|
+
i,
|
|
1954
|
+
kbd,
|
|
1955
|
+
mark,
|
|
1956
|
+
q,
|
|
1957
|
+
rp,
|
|
1958
|
+
rt,
|
|
1959
|
+
ruby,
|
|
1960
|
+
s,
|
|
1961
|
+
samp,
|
|
1962
|
+
small,
|
|
1963
|
+
span,
|
|
1964
|
+
strong,
|
|
1965
|
+
sub,
|
|
1966
|
+
sup,
|
|
1967
|
+
time,
|
|
1968
|
+
u,
|
|
1969
|
+
wbr,
|
|
1970
|
+
area,
|
|
1971
|
+
audio,
|
|
1972
|
+
img,
|
|
1973
|
+
map,
|
|
1974
|
+
track,
|
|
1975
|
+
video,
|
|
1976
|
+
embed,
|
|
1977
|
+
iframe,
|
|
1978
|
+
object,
|
|
1979
|
+
param,
|
|
1980
|
+
picture,
|
|
1981
|
+
portal,
|
|
1982
|
+
source,
|
|
1983
|
+
canvas,
|
|
1984
|
+
noscript,
|
|
1985
|
+
script,
|
|
1986
|
+
del,
|
|
1987
|
+
ins,
|
|
1988
|
+
caption,
|
|
1989
|
+
col,
|
|
1990
|
+
colgroup,
|
|
1991
|
+
table,
|
|
1992
|
+
tbody,
|
|
1993
|
+
td,
|
|
1994
|
+
tfoot,
|
|
1995
|
+
th,
|
|
1996
|
+
thead,
|
|
1997
|
+
tr,
|
|
1998
|
+
button,
|
|
1999
|
+
datalist,
|
|
2000
|
+
fieldset,
|
|
2001
|
+
form,
|
|
2002
|
+
input,
|
|
2003
|
+
label,
|
|
2004
|
+
legend,
|
|
2005
|
+
meter,
|
|
2006
|
+
optgroup,
|
|
2007
|
+
option,
|
|
2008
|
+
output,
|
|
2009
|
+
progress,
|
|
2010
|
+
select,
|
|
2011
|
+
textarea,
|
|
2012
|
+
details,
|
|
2013
|
+
dialog,
|
|
2014
|
+
menu,
|
|
2015
|
+
summary,
|
|
2016
|
+
slot,
|
|
2017
|
+
template,
|
|
2018
|
+
svgSvg,
|
|
2019
|
+
svgCircle,
|
|
2020
|
+
svgRect,
|
|
2021
|
+
svgPath,
|
|
2022
|
+
svgLine,
|
|
2023
|
+
svgPolyline,
|
|
2024
|
+
svgPolygon,
|
|
2025
|
+
svgEllipse,
|
|
2026
|
+
svgG,
|
|
2027
|
+
svgText,
|
|
2028
|
+
svgTspan,
|
|
2029
|
+
svgDefs,
|
|
2030
|
+
svgLinearGradient,
|
|
2031
|
+
svgRadialGradient,
|
|
2032
|
+
svgStop,
|
|
2033
|
+
svgPattern,
|
|
2034
|
+
svgMask,
|
|
2035
|
+
svgClipPath,
|
|
2036
|
+
svgUse,
|
|
2037
|
+
svgSymbol,
|
|
2038
|
+
svgMarker,
|
|
2039
|
+
svgImage,
|
|
2040
|
+
svgForeignObject,
|
|
2041
|
+
svgAnimate,
|
|
2042
|
+
svgAnimateTransform,
|
|
2043
|
+
svgAnimateMotion,
|
|
2044
|
+
svgSet,
|
|
2045
|
+
svgFilter,
|
|
2046
|
+
svgFeBlend,
|
|
2047
|
+
svgFeColorMatrix,
|
|
2048
|
+
svgFeComponentTransfer,
|
|
2049
|
+
svgFeComposite,
|
|
2050
|
+
svgFeConvolveMatrix,
|
|
2051
|
+
svgFeDiffuseLighting,
|
|
2052
|
+
svgFeDisplacementMap,
|
|
2053
|
+
svgFeFlood,
|
|
2054
|
+
svgFeGaussianBlur,
|
|
2055
|
+
svgFeMorphology,
|
|
2056
|
+
svgFeOffset,
|
|
2057
|
+
svgFeSpecularLighting,
|
|
2058
|
+
svgFeTile,
|
|
2059
|
+
svgFeTurbulence,
|
|
2060
|
+
mathMath,
|
|
2061
|
+
mathMi,
|
|
2062
|
+
mathMn,
|
|
2063
|
+
mathMo,
|
|
2064
|
+
mathMs,
|
|
2065
|
+
mathMtext,
|
|
2066
|
+
mathMrow,
|
|
2067
|
+
mathMfrac,
|
|
2068
|
+
mathMsqrt,
|
|
2069
|
+
mathMroot,
|
|
2070
|
+
mathMsub,
|
|
2071
|
+
mathMsup,
|
|
2072
|
+
varElement
|
|
2073
|
+
} = elements;
|
|
2074
|
+
var el = elements;
|
|
2075
|
+
var doc = hasDocument ? document : void 0;
|
|
2076
|
+
var getEl = bindDocMethod(doc?.querySelector);
|
|
2077
|
+
var getEls = bindDocMethod(doc?.querySelectorAll);
|
|
2078
|
+
var createEl = bindDocMethod(doc?.createElement);
|
|
2079
|
+
var createSvgEl = hasDocument ? doc.createElementNS.bind(doc, "http://www.w3.org/2000/svg") : void 0;
|
|
2080
|
+
var createMathEl = hasDocument ? doc.createElementNS.bind(doc, "http://www.w3.org/1998/Math/MathML") : void 0;
|
|
2081
|
+
var fragment = bindDocMethod(doc?.createDocumentFragment);
|
|
2082
|
+
var textNode = bindDocMethod(doc?.createTextNode);
|
|
2083
|
+
var commentNode = bindDocMethod(doc?.createComment);
|
|
2084
|
+
var getElId = bindDocMethod(doc?.getElementById);
|
|
2085
|
+
var getElClass = bindDocMethod(doc?.getElementsByClassName);
|
|
2086
|
+
var getElTag = bindDocMethod(doc?.getElementsByTagName);
|
|
2087
|
+
var getElName = bindDocMethod(doc?.getElementsByName);
|
|
2088
|
+
|
|
2089
|
+
// src/router.ts
|
|
2090
|
+
function matchRoute(pattern, path) {
|
|
2091
|
+
const patternParts = pattern.split("/").filter(Boolean);
|
|
2092
|
+
const pathParts = path.split("/").filter(Boolean);
|
|
2093
|
+
if (pattern.endsWith("*")) {
|
|
2094
|
+
const basePattern = pattern.slice(0, -1);
|
|
2095
|
+
if (path.startsWith(basePattern) || basePattern === "/" || pattern === "*") {
|
|
2096
|
+
return { "*": path.slice(basePattern.length) };
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
if (patternParts.length !== pathParts.length) return null;
|
|
2100
|
+
const params = {};
|
|
2101
|
+
for (let i2 = 0; i2 < patternParts.length; i2++) {
|
|
2102
|
+
const patternPart = patternParts[i2];
|
|
2103
|
+
const pathPart = pathParts[i2];
|
|
2104
|
+
if (patternPart.startsWith(":")) {
|
|
2105
|
+
params[patternPart.slice(1)] = decodeURIComponent(pathPart);
|
|
2106
|
+
} else if (patternPart !== pathPart) {
|
|
2107
|
+
return null;
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
return params;
|
|
2111
|
+
}
|
|
2112
|
+
function executeGuard(guard, to, from, navigate, replace = false) {
|
|
2113
|
+
const result = guard(to, from);
|
|
2114
|
+
if (result === false) return false;
|
|
2115
|
+
if (typeof result === "string") {
|
|
2116
|
+
navigate(result, replace);
|
|
2117
|
+
return false;
|
|
2118
|
+
}
|
|
2119
|
+
return true;
|
|
2120
|
+
}
|
|
2121
|
+
function wrapComponent(component) {
|
|
2122
|
+
if (typeof component === "object" && component !== null && "tagName" in component) {
|
|
2123
|
+
return component;
|
|
2124
|
+
}
|
|
2125
|
+
return { tagName: "span", props: {}, children: [component] };
|
|
2126
|
+
}
|
|
2127
|
+
function createRouter(options) {
|
|
2128
|
+
const { mode = "history", base: base2 = "", routes } = options;
|
|
2129
|
+
const globalGuards = [];
|
|
2130
|
+
const parseQuery = (search) => {
|
|
2131
|
+
const query = {};
|
|
2132
|
+
const params = new URLSearchParams(search);
|
|
2133
|
+
params.forEach((value, key) => {
|
|
2134
|
+
query[key] = value;
|
|
2135
|
+
});
|
|
2136
|
+
return query;
|
|
2137
|
+
};
|
|
2138
|
+
const getCurrentPath = () => {
|
|
2139
|
+
if (mode === "hash") {
|
|
2140
|
+
return window.location.hash.slice(1) || "/";
|
|
2141
|
+
}
|
|
2142
|
+
return window.location.pathname.replace(base2, "") || "/";
|
|
2143
|
+
};
|
|
2144
|
+
const parseLocation = (path) => {
|
|
2145
|
+
const [pathPart, queryPart = ""] = path.split("?");
|
|
2146
|
+
const [cleanPath, hash = ""] = pathPart.split("#");
|
|
2147
|
+
return {
|
|
2148
|
+
path: cleanPath || "/",
|
|
2149
|
+
params: {},
|
|
2150
|
+
query: parseQuery(queryPart),
|
|
2151
|
+
hash: hash ? "#" + hash : ""
|
|
2152
|
+
};
|
|
2153
|
+
};
|
|
2154
|
+
const findRoute = (path) => {
|
|
2155
|
+
for (const route of routes) {
|
|
2156
|
+
const params = matchRoute(route.path, path);
|
|
2157
|
+
if (params !== null) {
|
|
2158
|
+
return { route, params };
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
return null;
|
|
2162
|
+
};
|
|
2163
|
+
const currentRoute = dom.createState(parseLocation(getCurrentPath()));
|
|
2164
|
+
const navigate = (path, replace = false) => {
|
|
2165
|
+
const location2 = parseLocation(path);
|
|
2166
|
+
const match = findRoute(location2.path);
|
|
2167
|
+
if (match) {
|
|
2168
|
+
location2.params = match.params;
|
|
2169
|
+
}
|
|
2170
|
+
for (const guard of globalGuards) {
|
|
2171
|
+
if (!executeGuard(guard, location2, currentRoute.value, navigate, replace)) return;
|
|
2172
|
+
}
|
|
2173
|
+
if (match?.route.beforeEnter) {
|
|
2174
|
+
if (!executeGuard(match.route.beforeEnter, location2, currentRoute.value, navigate, replace)) return;
|
|
2175
|
+
}
|
|
2176
|
+
const url = mode === "hash" ? "#" + path : base2 + path;
|
|
2177
|
+
if (replace) {
|
|
2178
|
+
window.history.replaceState({ path }, "", url);
|
|
2179
|
+
} else {
|
|
2180
|
+
window.history.pushState({ path }, "", url);
|
|
2181
|
+
}
|
|
2182
|
+
currentRoute.value = location2;
|
|
2183
|
+
};
|
|
2184
|
+
const handlePopState = () => {
|
|
2185
|
+
const path = getCurrentPath();
|
|
2186
|
+
const location2 = parseLocation(path);
|
|
2187
|
+
const match = findRoute(location2.path);
|
|
2188
|
+
if (match) {
|
|
2189
|
+
location2.params = match.params;
|
|
2190
|
+
}
|
|
2191
|
+
currentRoute.value = location2;
|
|
2192
|
+
};
|
|
2193
|
+
if (typeof window !== "undefined") {
|
|
2194
|
+
window.addEventListener("popstate", handlePopState);
|
|
2195
|
+
}
|
|
2196
|
+
return {
|
|
2197
|
+
currentRoute,
|
|
2198
|
+
push: (path) => navigate(path, false),
|
|
2199
|
+
replace: (path) => navigate(path, true),
|
|
2200
|
+
back: () => window.history.back(),
|
|
2201
|
+
forward: () => window.history.forward(),
|
|
2202
|
+
go: (delta) => window.history.go(delta),
|
|
2203
|
+
beforeEach: (guard) => {
|
|
2204
|
+
globalGuards.push(guard);
|
|
2205
|
+
},
|
|
2206
|
+
destroy: () => {
|
|
2207
|
+
if (typeof window !== "undefined") {
|
|
2208
|
+
window.removeEventListener("popstate", handlePopState);
|
|
2209
|
+
}
|
|
2210
|
+
currentRoute.destroy();
|
|
2211
|
+
}
|
|
2212
|
+
};
|
|
2213
|
+
}
|
|
2214
|
+
function createRouterView(router, options) {
|
|
2215
|
+
const { routes, notFound } = options;
|
|
2216
|
+
return () => {
|
|
2217
|
+
const location2 = router.currentRoute.value;
|
|
2218
|
+
const match = routes.find((r) => matchRoute(r.path, location2.path) !== null);
|
|
2219
|
+
if (match) {
|
|
2220
|
+
const params = matchRoute(match.path, location2.path) || {};
|
|
2221
|
+
const component = match.component({ ...params, ...location2.query });
|
|
2222
|
+
return wrapComponent(component);
|
|
2223
|
+
}
|
|
2224
|
+
if (notFound) {
|
|
2225
|
+
const component = notFound(location2.params);
|
|
2226
|
+
return wrapComponent(component);
|
|
2227
|
+
}
|
|
2228
|
+
return { tagName: "div", props: {}, children: ["404 - Not Found"] };
|
|
2229
|
+
};
|
|
2230
|
+
}
|
|
2231
|
+
var routerLink = (router, props, ...children) => {
|
|
2232
|
+
return {
|
|
2233
|
+
tagName: "a",
|
|
2234
|
+
props: {
|
|
2235
|
+
...props,
|
|
2236
|
+
href: props.to,
|
|
2237
|
+
onclick: (e) => {
|
|
2238
|
+
e.preventDefault();
|
|
2239
|
+
router.push(props.to);
|
|
2240
|
+
}
|
|
2241
|
+
},
|
|
2242
|
+
children
|
|
2243
|
+
};
|
|
2244
|
+
};
|
|
2245
|
+
|
|
2246
|
+
// src/hmr.ts
|
|
2247
|
+
var ElitHMR = class {
|
|
2248
|
+
constructor() {
|
|
2249
|
+
this.enabled = false;
|
|
2250
|
+
this.ws = null;
|
|
2251
|
+
this.acceptCallbacks = [];
|
|
2252
|
+
this.disposeCallbacks = [];
|
|
2253
|
+
this.declined = false;
|
|
2254
|
+
if (typeof window === "undefined") {
|
|
2255
|
+
return;
|
|
2256
|
+
}
|
|
2257
|
+
this.connect();
|
|
2258
|
+
}
|
|
2259
|
+
connect() {
|
|
2260
|
+
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
|
|
2261
|
+
const host = window.location.hostname;
|
|
2262
|
+
const port = window.location.port || "3000";
|
|
2263
|
+
this.ws = new WebSocket(`${protocol}//${host}:${port}`);
|
|
2264
|
+
this.ws.onopen = () => {
|
|
2265
|
+
this.enabled = true;
|
|
2266
|
+
console.log("[Elit HMR] Connected \u2713");
|
|
2267
|
+
};
|
|
2268
|
+
this.ws.onmessage = (event) => {
|
|
2269
|
+
try {
|
|
2270
|
+
const data2 = JSON.parse(event.data);
|
|
2271
|
+
this.handleMessage(data2);
|
|
2272
|
+
} catch (error) {
|
|
2273
|
+
console.error("[Elit HMR] Error parsing message:", error);
|
|
2274
|
+
}
|
|
2275
|
+
};
|
|
2276
|
+
this.ws.onclose = () => {
|
|
2277
|
+
this.enabled = false;
|
|
2278
|
+
console.log("[Elit HMR] Disconnected - Attempting reconnect...");
|
|
2279
|
+
setTimeout(() => this.reload(), 1e3);
|
|
2280
|
+
};
|
|
2281
|
+
this.ws.onerror = (error) => {
|
|
2282
|
+
console.error("[Elit HMR] WebSocket error:", error);
|
|
2283
|
+
};
|
|
2284
|
+
}
|
|
2285
|
+
handleMessage(data2) {
|
|
2286
|
+
switch (data2.type) {
|
|
2287
|
+
case "connected":
|
|
2288
|
+
console.log("[Elit HMR] Ready");
|
|
2289
|
+
break;
|
|
2290
|
+
case "update":
|
|
2291
|
+
console.log(`[Elit HMR] Update detected: ${data2.path}`);
|
|
2292
|
+
if (this.declined) {
|
|
2293
|
+
this.reload();
|
|
2294
|
+
return;
|
|
2295
|
+
}
|
|
2296
|
+
this.disposeCallbacks.forEach((cb) => cb());
|
|
2297
|
+
this.disposeCallbacks = [];
|
|
2298
|
+
if (this.acceptCallbacks.length > 0) {
|
|
2299
|
+
this.acceptCallbacks.forEach((cb) => cb());
|
|
2300
|
+
} else {
|
|
2301
|
+
this.reload();
|
|
2302
|
+
}
|
|
2303
|
+
break;
|
|
2304
|
+
case "reload":
|
|
2305
|
+
console.log("[Elit HMR] Full reload requested");
|
|
2306
|
+
this.reload();
|
|
2307
|
+
break;
|
|
2308
|
+
case "error":
|
|
2309
|
+
console.error("[Elit HMR] Server error:", data2.error);
|
|
2310
|
+
break;
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
reload() {
|
|
2314
|
+
window.location.reload();
|
|
2315
|
+
}
|
|
2316
|
+
accept(callback) {
|
|
2317
|
+
if (callback) {
|
|
2318
|
+
this.acceptCallbacks.push(callback);
|
|
2319
|
+
}
|
|
2320
|
+
this.declined = false;
|
|
2321
|
+
}
|
|
2322
|
+
decline() {
|
|
2323
|
+
this.declined = true;
|
|
2324
|
+
}
|
|
2325
|
+
dispose(callback) {
|
|
2326
|
+
this.disposeCallbacks.push(callback);
|
|
2327
|
+
}
|
|
2328
|
+
};
|
|
2329
|
+
var hmr = new ElitHMR();
|
|
2330
|
+
if (typeof window !== "undefined") {
|
|
2331
|
+
window.__ELIT_HMR__ = hmr;
|
|
2332
|
+
}
|
|
2333
|
+
var hmr_default = hmr;
|
|
2334
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2335
|
+
0 && (module.exports = {
|
|
2336
|
+
CreateStyle,
|
|
2337
|
+
DomNode,
|
|
2338
|
+
SharedState,
|
|
2339
|
+
a,
|
|
2340
|
+
abbr,
|
|
2341
|
+
addAttribute,
|
|
2342
|
+
addClass,
|
|
2343
|
+
addContainer,
|
|
2344
|
+
addId,
|
|
2345
|
+
addName,
|
|
2346
|
+
addPseudoClass,
|
|
2347
|
+
addPseudoElement,
|
|
2348
|
+
addStyle,
|
|
2349
|
+
addTag,
|
|
2350
|
+
addVar,
|
|
2351
|
+
address,
|
|
2352
|
+
adjacentSibling,
|
|
2353
|
+
area,
|
|
2354
|
+
article,
|
|
2355
|
+
aside,
|
|
2356
|
+
attrContains,
|
|
2357
|
+
attrContainsWord,
|
|
2358
|
+
attrEndsWith,
|
|
2359
|
+
attrEquals,
|
|
2360
|
+
attrStartsWith,
|
|
2361
|
+
audio,
|
|
2362
|
+
b,
|
|
2363
|
+
base,
|
|
2364
|
+
batchRender,
|
|
2365
|
+
bdi,
|
|
2366
|
+
bdo,
|
|
2367
|
+
bindChecked,
|
|
2368
|
+
bindValue,
|
|
2369
|
+
blockquote,
|
|
2370
|
+
body,
|
|
2371
|
+
br,
|
|
2372
|
+
button,
|
|
2373
|
+
canvas,
|
|
2374
|
+
caption,
|
|
2375
|
+
childStyle,
|
|
2376
|
+
cite,
|
|
2377
|
+
cleanupUnused,
|
|
2378
|
+
clearStyle,
|
|
2379
|
+
code,
|
|
2380
|
+
col,
|
|
2381
|
+
colgroup,
|
|
2382
|
+
commentNode,
|
|
2383
|
+
computed,
|
|
2384
|
+
container,
|
|
2385
|
+
createEl,
|
|
2386
|
+
createElementFactory,
|
|
2387
|
+
createMathEl,
|
|
2388
|
+
createRouter,
|
|
2389
|
+
createRouterView,
|
|
2390
|
+
createSharedState,
|
|
2391
|
+
createState,
|
|
2392
|
+
createSvgEl,
|
|
2393
|
+
createVirtualList,
|
|
2394
|
+
data,
|
|
2395
|
+
datalist,
|
|
2396
|
+
dd,
|
|
2397
|
+
debounce,
|
|
2398
|
+
del,
|
|
2399
|
+
descendant,
|
|
2400
|
+
details,
|
|
2401
|
+
dfn,
|
|
2402
|
+
dialog,
|
|
2403
|
+
div,
|
|
2404
|
+
dl,
|
|
2405
|
+
doc,
|
|
2406
|
+
dom,
|
|
2407
|
+
dt,
|
|
2408
|
+
effect,
|
|
2409
|
+
el,
|
|
2410
|
+
elements,
|
|
2411
|
+
em,
|
|
2412
|
+
embed,
|
|
2413
|
+
fieldset,
|
|
2414
|
+
figcaption,
|
|
2415
|
+
figure,
|
|
2416
|
+
fontFace,
|
|
2417
|
+
footer,
|
|
2418
|
+
form,
|
|
2419
|
+
fragment,
|
|
2420
|
+
generalSibling,
|
|
2421
|
+
getEl,
|
|
2422
|
+
getElClass,
|
|
2423
|
+
getElId,
|
|
2424
|
+
getElName,
|
|
2425
|
+
getElTag,
|
|
2426
|
+
getEls,
|
|
2427
|
+
getVar,
|
|
2428
|
+
h1,
|
|
2429
|
+
h2,
|
|
2430
|
+
h3,
|
|
2431
|
+
h4,
|
|
2432
|
+
h5,
|
|
2433
|
+
h6,
|
|
2434
|
+
head,
|
|
2435
|
+
header,
|
|
2436
|
+
hmr,
|
|
2437
|
+
hr,
|
|
2438
|
+
html,
|
|
2439
|
+
i,
|
|
2440
|
+
iframe,
|
|
2441
|
+
img,
|
|
2442
|
+
importStyle,
|
|
2443
|
+
important,
|
|
2444
|
+
injectStyle,
|
|
2445
|
+
input,
|
|
2446
|
+
ins,
|
|
2447
|
+
kbd,
|
|
2448
|
+
keyframe,
|
|
2449
|
+
keyframeFromTo,
|
|
2450
|
+
label,
|
|
2451
|
+
layer,
|
|
2452
|
+
layerOrder,
|
|
2453
|
+
lazy,
|
|
2454
|
+
legend,
|
|
2455
|
+
li,
|
|
2456
|
+
link,
|
|
2457
|
+
main,
|
|
2458
|
+
map,
|
|
2459
|
+
mark,
|
|
2460
|
+
mathMath,
|
|
2461
|
+
mathMfrac,
|
|
2462
|
+
mathMi,
|
|
2463
|
+
mathMn,
|
|
2464
|
+
mathMo,
|
|
2465
|
+
mathMroot,
|
|
2466
|
+
mathMrow,
|
|
2467
|
+
mathMs,
|
|
2468
|
+
mathMsqrt,
|
|
2469
|
+
mathMsub,
|
|
2470
|
+
mathMsup,
|
|
2471
|
+
mathMtext,
|
|
2472
|
+
mediaDark,
|
|
2473
|
+
mediaLight,
|
|
2474
|
+
mediaMaxWidth,
|
|
2475
|
+
mediaMinWidth,
|
|
2476
|
+
mediaPrint,
|
|
2477
|
+
mediaReducedMotion,
|
|
2478
|
+
mediaScreen,
|
|
2479
|
+
mediaStyle,
|
|
2480
|
+
menu,
|
|
2481
|
+
meta,
|
|
2482
|
+
meter,
|
|
2483
|
+
mount,
|
|
2484
|
+
multipleStyle,
|
|
2485
|
+
nav,
|
|
2486
|
+
nesting,
|
|
2487
|
+
noscript,
|
|
2488
|
+
object,
|
|
2489
|
+
ol,
|
|
2490
|
+
optgroup,
|
|
2491
|
+
option,
|
|
2492
|
+
output,
|
|
2493
|
+
p,
|
|
2494
|
+
param,
|
|
2495
|
+
picture,
|
|
2496
|
+
portal,
|
|
2497
|
+
pre,
|
|
2498
|
+
progress,
|
|
2499
|
+
q,
|
|
2500
|
+
reactive,
|
|
2501
|
+
reactiveAs,
|
|
2502
|
+
render,
|
|
2503
|
+
renderChunked,
|
|
2504
|
+
renderStyle,
|
|
2505
|
+
renderToString,
|
|
2506
|
+
routerLink,
|
|
2507
|
+
rp,
|
|
2508
|
+
rt,
|
|
2509
|
+
ruby,
|
|
2510
|
+
s,
|
|
2511
|
+
samp,
|
|
2512
|
+
script,
|
|
2513
|
+
section,
|
|
2514
|
+
select,
|
|
2515
|
+
sharedStateManager,
|
|
2516
|
+
slot,
|
|
2517
|
+
small,
|
|
2518
|
+
source,
|
|
2519
|
+
span,
|
|
2520
|
+
strong,
|
|
2521
|
+
style,
|
|
2522
|
+
styles,
|
|
2523
|
+
sub,
|
|
2524
|
+
summary,
|
|
2525
|
+
sup,
|
|
2526
|
+
supportsStyle,
|
|
2527
|
+
svgAnimate,
|
|
2528
|
+
svgAnimateMotion,
|
|
2529
|
+
svgAnimateTransform,
|
|
2530
|
+
svgCircle,
|
|
2531
|
+
svgClipPath,
|
|
2532
|
+
svgDefs,
|
|
2533
|
+
svgEllipse,
|
|
2534
|
+
svgFeBlend,
|
|
2535
|
+
svgFeColorMatrix,
|
|
2536
|
+
svgFeComponentTransfer,
|
|
2537
|
+
svgFeComposite,
|
|
2538
|
+
svgFeConvolveMatrix,
|
|
2539
|
+
svgFeDiffuseLighting,
|
|
2540
|
+
svgFeDisplacementMap,
|
|
2541
|
+
svgFeFlood,
|
|
2542
|
+
svgFeGaussianBlur,
|
|
2543
|
+
svgFeMorphology,
|
|
2544
|
+
svgFeOffset,
|
|
2545
|
+
svgFeSpecularLighting,
|
|
2546
|
+
svgFeTile,
|
|
2547
|
+
svgFeTurbulence,
|
|
2548
|
+
svgFilter,
|
|
2549
|
+
svgForeignObject,
|
|
2550
|
+
svgG,
|
|
2551
|
+
svgImage,
|
|
2552
|
+
svgLine,
|
|
2553
|
+
svgLinearGradient,
|
|
2554
|
+
svgMarker,
|
|
2555
|
+
svgMask,
|
|
2556
|
+
svgPath,
|
|
2557
|
+
svgPattern,
|
|
2558
|
+
svgPolygon,
|
|
2559
|
+
svgPolyline,
|
|
2560
|
+
svgRadialGradient,
|
|
2561
|
+
svgRect,
|
|
2562
|
+
svgSet,
|
|
2563
|
+
svgStop,
|
|
2564
|
+
svgSvg,
|
|
2565
|
+
svgSymbol,
|
|
2566
|
+
svgText,
|
|
2567
|
+
svgTspan,
|
|
2568
|
+
svgUse,
|
|
2569
|
+
table,
|
|
2570
|
+
tbody,
|
|
2571
|
+
td,
|
|
2572
|
+
template,
|
|
2573
|
+
text,
|
|
2574
|
+
textNode,
|
|
2575
|
+
textarea,
|
|
2576
|
+
tfoot,
|
|
2577
|
+
th,
|
|
2578
|
+
thead,
|
|
2579
|
+
throttle,
|
|
2580
|
+
time,
|
|
2581
|
+
title,
|
|
2582
|
+
tr,
|
|
2583
|
+
track,
|
|
2584
|
+
u,
|
|
2585
|
+
ul,
|
|
2586
|
+
varElement,
|
|
2587
|
+
video,
|
|
2588
|
+
wbr
|
|
2589
|
+
});
|