@fluixi/dom 1.0.0-alpha.82 → 1.0.0-alpha.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/dom-client.cjs +1427 -1
- package/dist/cdn/dom-client.d.ts +2 -2
- package/dist/cdn/dom-client.global.js +2 -1
- package/dist/cdn/dom-client.js +3 -3
- package/dist/cdn/dom-client.mjs +1430 -1
- package/dist/cdn/dom.cjs +3127 -1
- package/dist/cdn/dom.d.ts +2 -2
- package/dist/cdn/dom.global.js +2 -1
- package/dist/cdn/dom.js +4 -4
- package/dist/cdn/dom.mjs +3133 -1
- package/dist/index.cjs +3155 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +3149 -1
- package/dist/lib/component/index.cjs +128 -1
- package/dist/lib/component/index.mjs +105 -1
- package/dist/lib/component/modifiers.cjs +126 -1
- package/dist/lib/component/modifiers.d.ts +12 -0
- package/dist/lib/component/modifiers.d.ts.map +1 -1
- package/dist/lib/component/modifiers.js +12 -84
- package/dist/lib/component/modifiers.mjs +105 -1
- package/dist/lib/dom/delegate.cjs +60 -1
- package/dist/lib/dom/delegate.js +1 -1
- package/dist/lib/dom/delegate.mjs +39 -1
- package/dist/lib/dom/dynamic-element.cjs +949 -1
- package/dist/lib/dom/dynamic-element.d.ts +3 -3
- package/dist/lib/dom/dynamic-element.js +3 -3
- package/dist/lib/dom/dynamic-element.mjs +928 -1
- package/dist/lib/dom/hydration-state.cjs +93 -1
- package/dist/lib/dom/hydration-state.d.ts +1 -1
- package/dist/lib/dom/hydration-state.js +1 -1
- package/dist/lib/dom/hydration-state.mjs +72 -1
- package/dist/lib/dom/hydration.cjs +685 -1
- package/dist/lib/dom/hydration.js +8 -8
- package/dist/lib/dom/hydration.mjs +664 -1
- package/dist/lib/dom/index.cjs +2040 -1
- package/dist/lib/dom/index.js +1 -1
- package/dist/lib/dom/index.mjs +2020 -1
- package/dist/lib/dom/integration.cjs +71 -1
- package/dist/lib/dom/integration.d.ts.map +1 -1
- package/dist/lib/dom/integration.js +15 -6
- package/dist/lib/dom/integration.mjs +51 -1
- package/dist/lib/dom/island.cjs +790 -1
- package/dist/lib/dom/island.d.ts +1 -1
- package/dist/lib/dom/island.js +12 -12
- package/dist/lib/dom/island.mjs +769 -1
- package/dist/lib/dom/runtime.cjs +1432 -1
- package/dist/lib/dom/runtime.d.ts +71 -19
- package/dist/lib/dom/runtime.d.ts.map +1 -1
- package/dist/lib/dom/runtime.js +261 -100
- package/dist/lib/dom/runtime.mjs +1414 -1
- package/dist/lib/dom/server/fx-data.cjs +53 -1
- package/dist/lib/dom/server/fx-data.d.ts +5 -5
- package/dist/lib/dom/server/fx-data.js +6 -6
- package/dist/lib/dom/server/fx-data.mjs +32 -1
- package/dist/lib/dom/server/host.cjs +66 -1
- package/dist/lib/dom/server/host.d.ts +14 -2
- package/dist/lib/dom/server/host.d.ts.map +1 -1
- package/dist/lib/dom/server/host.js +38 -10
- package/dist/lib/dom/server/host.mjs +45 -1
- package/dist/lib/dom/server/index.cjs +759 -1
- package/dist/lib/dom/server/index.d.ts +1 -1
- package/dist/lib/dom/server/index.js +1 -1
- package/dist/lib/dom/server/index.mjs +743 -1
- package/dist/lib/dom/server/nodes.cjs +302 -1
- package/dist/lib/dom/server/nodes.d.ts +2 -2
- package/dist/lib/dom/server/nodes.d.ts.map +1 -1
- package/dist/lib/dom/server/nodes.js +4 -4
- package/dist/lib/dom/server/nodes.mjs +279 -1
- package/dist/lib/dom/server/parse-template.cjs +395 -1
- package/dist/lib/dom/server/parse-template.d.ts +1 -1
- package/dist/lib/dom/server/parse-template.js +4 -4
- package/dist/lib/dom/server/parse-template.mjs +372 -1
- package/dist/lib/dom/server/render.cjs +691 -1
- package/dist/lib/dom/server/render.d.ts +9 -1
- package/dist/lib/dom/server/render.d.ts.map +1 -1
- package/dist/lib/dom/server/render.js +25 -17
- package/dist/lib/dom/server/render.mjs +677 -1
- package/dist/lib/dom/server/request-context.cjs +110 -1
- package/dist/lib/dom/server/request-context.d.ts +29 -9
- package/dist/lib/dom/server/request-context.d.ts.map +1 -1
- package/dist/lib/dom/server/request-context.js +28 -8
- package/dist/lib/dom/server/request-context.mjs +89 -1
- package/dist/lib/dom/server/serialize.cjs +187 -1
- package/dist/lib/dom/server/serialize.js +3 -3
- package/dist/lib/dom/server/serialize.mjs +164 -1
- package/dist/lib/dom/server-renderer.cjs +760 -1
- package/dist/lib/dom/server-renderer.js +1 -1
- package/dist/lib/dom/server-renderer.mjs +745 -1
- package/dist/lib/dom/types.cjs +18 -1
- package/dist/lib/dom/utils.cjs +381 -1
- package/dist/lib/dom/utils.d.ts +1 -88
- package/dist/lib/dom/utils.d.ts.map +1 -1
- package/dist/lib/dom/utils.js +2 -99
- package/dist/lib/dom/utils.mjs +361 -1
- package/dist/lib/dom/versions.cjs +60 -1
- package/dist/lib/dom/versions.d.ts +3 -3
- package/dist/lib/dom/versions.d.ts.map +1 -1
- package/dist/lib/dom/versions.js +17 -5
- package/dist/lib/dom/versions.mjs +37 -1
- package/dist/lib/element/attributes.cjs +19 -1
- package/dist/lib/element/attributes.d.ts +7 -7
- package/dist/lib/element/attributes.js +1 -1
- package/dist/lib/element/attributes.mjs +1 -0
- package/dist/lib/element/index.cjs +19 -1
- package/dist/lib/element/index.mjs +1 -0
- package/dist/lib/element/types.cjs +18 -1
- package/dist/lib/element/types.d.ts +4 -5
- package/dist/lib/element/types.d.ts.map +1 -1
- package/dist/lib/element/types.js +0 -1
- package/dist/lib/flow/class-map.cjs +38 -1
- package/dist/lib/flow/class-map.d.ts +3 -3
- package/dist/lib/flow/class-map.js +3 -3
- package/dist/lib/flow/class-map.mjs +17 -1
- package/dist/lib/flow/client-only.cjs +57 -1
- package/dist/lib/flow/client-only.d.ts +4 -4
- package/dist/lib/flow/client-only.js +4 -4
- package/dist/lib/flow/client-only.mjs +36 -1
- package/dist/lib/flow/dynamic.cjs +53 -1
- package/dist/lib/flow/dynamic.d.ts +2 -2
- package/dist/lib/flow/dynamic.js +4 -4
- package/dist/lib/flow/dynamic.mjs +32 -1
- package/dist/lib/flow/error-boundary.cjs +43 -1
- package/dist/lib/flow/error-boundary.d.ts +2 -2
- package/dist/lib/flow/error-boundary.js +4 -4
- package/dist/lib/flow/error-boundary.mjs +22 -1
- package/dist/lib/flow/for.cjs +66 -1
- package/dist/lib/flow/for.d.ts +9 -9
- package/dist/lib/flow/for.d.ts.map +1 -1
- package/dist/lib/flow/for.js +2 -2
- package/dist/lib/flow/for.mjs +45 -1
- package/dist/lib/flow/index-flow.cjs +67 -1
- package/dist/lib/flow/index-flow.d.ts +5 -5
- package/dist/lib/flow/index-flow.js +4 -4
- package/dist/lib/flow/index-flow.mjs +46 -1
- package/dist/lib/flow/index.cjs +805 -1
- package/dist/lib/flow/index.mjs +792 -1
- package/dist/lib/flow/portal.cjs +538 -1
- package/dist/lib/flow/portal.mjs +519 -1
- package/dist/lib/flow/show.cjs +81 -1
- package/dist/lib/flow/show.d.ts +1 -1
- package/dist/lib/flow/show.d.ts.map +1 -1
- package/dist/lib/flow/show.js +12 -118
- package/dist/lib/flow/show.mjs +67 -1
- package/dist/lib/flow/style-map.cjs +43 -1
- package/dist/lib/flow/style-map.d.ts +3 -3
- package/dist/lib/flow/style-map.js +4 -4
- package/dist/lib/flow/style-map.mjs +22 -1
- package/dist/lib/flow/switch.cjs +91 -1
- package/dist/lib/flow/switch.d.ts +3 -3
- package/dist/lib/flow/switch.d.ts.map +1 -1
- package/dist/lib/flow/switch.js +7 -7
- package/dist/lib/flow/switch.mjs +70 -1
- package/dist/lib/flow/utils.cjs +44 -1
- package/dist/lib/flow/utils.d.ts +1 -1
- package/dist/lib/flow/utils.js +1 -1
- package/dist/lib/flow/utils.mjs +23 -1
- package/dist/lib/html.cjs +32 -1
- package/dist/lib/html.d.ts +6 -6
- package/dist/lib/html.js +5 -5
- package/dist/lib/html.mjs +11 -1
- package/dist/lib/index.cjs +3104 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -3
- package/dist/lib/index.mjs +3097 -1
- package/dist/lib/shared/types.cjs +18 -1
- package/dist/lib/shared/types.d.ts +8 -8
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +26 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +2 -2
- package/dist/version.generated.mjs +5 -1
- package/package.json +7 -6
- package/dist/lib/jsx/control-flow/flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/flow.js +0 -627
- package/dist/lib/jsx/control-flow/flow.mjs +0 -0
- package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/for-flow.js +0 -1
- package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
package/dist/cdn/dom.mjs
CHANGED
|
@@ -1 +1,3133 @@
|
|
|
1
|
-
function br(e){return e.startsWith("aria-")||e.startsWith("data-")?e:/[A-Z]/.test(e)?e.replace(/([A-Z])/g,"-$1").toLowerCase():e}function Er(e){return e.startsWith("@")||e.startsWith("on")&&e.length>2}function wr(e){return e.startsWith("@")?e.slice(1):e.startsWith("on")?e.slice(2).toLowerCase():e}function Nr(e,t){let n=new Set(["checked","value","selected","disabled","readonly","required","multiple","open","contenteditable","draggable","spellcheck"]),r={input:new Set(["value","checked","indeterminate"]),textarea:new Set(["value"]),select:new Set(["value"]),option:new Set(["selected","value"]),audio:new Set(["volume","currentTime","paused"]),video:new Set(["volume","currentTime","paused"]),img:new Set(["src","srcset"]),iframe:new Set(["src"]),a:new Set(["href"])};return n.has(t)||r[e]&&r[e].has(t)}var Sr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),vr=new Set(["svg","g","path","circle","rect","line","polyline","polygon","ellipse","text","tspan","use","defs","symbol","mask","clipPath","pattern","linearGradient","radialGradient","stop","filter","feGaussianBlur","feOffset","feMerge","feMergeNode","foreignObject"]),H="http://www.w3.org/2000/svg";function Lt(e){return e.localName.includes("-")}function me(e,t,n,r=!1){if(n==null){e.removeAttribute(t);return}if(Lt(e)){e[t]=n;return}T(e,t,n,r)}var ge=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function je(e,t=document){return t.querySelector(e)}function Ar(e,t=document){return Array.from(t.querySelectorAll(e))}function Cr(e,t){return e.closest(t)}function Rr(e,...t){e.classList.add(...t)}function Mr(e,...t){e.classList.remove(...t)}function Pr(e,...t){t.forEach(n=>e.classList.toggle(n))}function kr(e,t){return e.classList.contains(t)}function T(e,t,n,r=!1){if(n==null||n===!1){e.removeAttribute(t);return}if(n===!0){e.setAttribute(t,"");return}if(typeof n=="object"){e.setAttribute(t,JSON.stringify(n));return}e.setAttribute(t,String(n))}function Lr(e,t){return e.getAttribute(t)}function Or(e,t){e.removeAttribute(t)}function Ot(e,t){Object.assign(e.style,t)}function Dr(e,t){return window.getComputedStyle(e).getPropertyValue(t)}function _r(e,t={},...n){let r=document.createElement(e);return Object.entries(t).forEach(([o,i])=>{if(o==="class"||o==="className")r.className=i;else if(o==="style"&&typeof i=="object")Ot(r,i);else if(o.startsWith("on")&&typeof i=="function"){let s=o.slice(2).toLowerCase();r.addEventListener(s,i)}else T(r,o,i)}),n.forEach(o=>{typeof o=="string"?r.appendChild(document.createTextNode(o)):r.appendChild(o)}),r}function $r(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function Ir(e,...t){t.forEach(n=>{typeof n=="string"?e.appendChild(document.createTextNode(n)):e.appendChild(n)})}function qr(e){let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=window.innerHeight&&t.right<=window.innerWidth}function jr(e,t={behavior:"smooth",block:"nearest"}){e.scrollIntoView(t)}function Fr(e){let t=e.getBoundingClientRect();return{top:t.top+window.pageYOffset,left:t.left+window.pageXOffset}}function Hr(e,t,n,r){let o=i=>{let s=i.target.closest(n);s&&e.contains(s)&&r(i,s)};return e.addEventListener(t,o),()=>{e.removeEventListener(t,o)}}function Vr(e,t=5e3){return new Promise((n,r)=>{let o=je(e);if(o){n(o);return}let i=new MutationObserver(()=>{let a=je(e);a&&(i.disconnect(),clearTimeout(s),n(a))});i.observe(document.body,{childList:!0,subtree:!0});let s=setTimeout(()=>{i.disconnect(),r(new Error(`Element ${e} not found within ${t}ms`))},t)})}function Wr(e,t,n={}){let r=new IntersectionObserver(o=>{o.forEach(i=>{t(i.isIntersecting)})},n);return r.observe(e),()=>{r.disconnect()}}function Ur(e,t){let n=new ResizeObserver(r=>{r.forEach(t)});return n.observe(e),()=>{n.disconnect()}}var Dt=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function Br(e){return typeof e=="object"&&e!==null&&e.$$typeof===Dt}function _t(e){return e&&typeof e=="object"&&e.strings&&Array.isArray(e.strings)&&e.values&&Array.isArray(e.values)}function Kr(e){if(typeof e!="function")return!1;try{let t=e();return _t(t)}catch{return!1}}function zr(e){return typeof e=="object"&&e!==null&&(e.$$typeof==="template"||typeof e.type=="function")}function Gr(e){return e instanceof Node}function Xr(e,t,n="Fluixi"){typeof globalThis<"u"&&(typeof globalThis[n]>"u"&&(globalThis[n]={}),typeof globalThis[n][e]>"u"&&(globalThis[n][e]=t))}function Jr(e,t,n="Fluixi"){return typeof globalThis<"u"&&typeof globalThis[n]<"u"&&typeof globalThis[n][e]<"u"?globalThis[n][e]:t}import{isSignal as x}from"@fluixi/reactive/signal";var Fe="1.0.0-alpha.82";import{VERSION as $t}from"@fluixi/reactive/version";var b={dom:Fe,reactive:$t};function He(e){b.core&&e.setAttribute("fluixi",b.core),e.setAttribute("fx-dom",b.dom),e.setAttribute("fx-reactive",b.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=b)}function Ve(){let e=[b.core,b.dom,b.reactive].filter(t=>t!==void 0);new Set(e).size<=1||console.warn(`[fluixi] package versions disagree — core ${b.core??"(absent)"}, dom ${b.dom}, reactive ${b.reactive}. These ship as one release, so a mismatch usually means a stale lockfile or two copies resolved side by side. Reinstall, or check for duplicates with \`pnpm why @fluixi/dom\`.`)}function no(e){return Object.defineProperty(e,Symbol.for("fluixi-router"),{value:!0,enumerable:!0}),e}function ro(e){return Object.defineProperty(e,Symbol.for("fluixi-routes"),{value:!0,enumerable:!0}),e}function oo(e){return Object.defineProperty(e,Symbol.for("fluixi-route"),{value:!0,enumerable:!0}),e}function io(e){return typeof e!="function"||Object.defineProperty(e,Symbol.for("fluixi-outlet"),{value:!0,enumerable:!0}),e}function so(e){return Object.defineProperty(e,Symbol.for("fluixi-provider"),{value:!0,enumerable:!0}),e}function ao(e){return Object.defineProperty(e,Symbol.for("fluixi-context"),{value:!0,enumerable:!0}),e}function We(e){return typeof e!="function"||Object.defineProperty(e,Symbol.for("fluixi-component"),{value:!0,enumerable:!0}),e}function lo(e){return Object.defineProperty(e,Symbol.for("fluixi-suspense"),{value:!0,enumerable:!0}),e}function It(e){return typeof e=="function"&&e[Symbol.for("fluixi-router")]===!0}function qt(e){return typeof e=="function"&&e[Symbol.for("fluixi-routes")]===!0}function jt(e){return typeof e=="function"&&e[Symbol.for("fluixi-route")]===!0}function Ft(e){return typeof e=="function"&&e[Symbol.for("fluixi-outlet")]===!0}function Ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Vt(e){return typeof e=="function"&&e[Symbol.for("fluixi-context")]===!0}function w(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Wt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function co(e){return It(e)?{type:"router",value:e}:jt(e)?{type:"route",value:e}:qt(e)?{type:"routes",value:e}:Ft(e)?{type:"outlet",value:e}:w(e)?{type:"component",value:e}:Wt(e)?{type:"suspense",value:e}:Ht(e)?{type:"provider",value:e}:Vt(e)?{type:"context",value:e}:{type:"none",value:e}}import{batch as Xe,createEffect as U,createRenderEffect as m,createRoot as Kt,onCleanup as k,readChildren as zt}from"@fluixi/reactive/signal";var g=typeof document>"u";function _(e){g=e}var V=Symbol.for("fluixi.server-node"),he=null;function Ue(e){he=e}function $(){if(!he)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return he}function I(e){return e!=null&&e[V]===!0?!0:typeof Node<"u"&&e instanceof Node}function xe(e){return e!=null&&e[V]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function Te(e){return e!=null&&e[V]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var u={active:!1,cursor:null,parents:[]},Be=null;function Ke(e){Be=e}function G(){return Be}function be(e,t){return u.active&&t.parentNode===e}function Ee(e){let t=u.parents.lastIndexOf(e);t!==-1&&(u.parents.length=t),u.cursor=e.nextSibling}function Ut(){return u.active?u.cursor:null}function X(e,t){if(!e||e.parentNode==null)return t();let n=u.active,r=u.cursor,o=u.parents;u.active=!0,u.cursor=e,u.parents=[];try{return t()}finally{u.active=n,u.cursor=r,u.parents=o}}function Bt(e){if(!u.active)return e();let t=u.cursor,n=u.parents;u.active=!1,u.parents=[];try{return e()}finally{u.active=!0,u.cursor=t,u.parents=n}}function W(e){if(!u.active||e==null)return;let t=Array.isArray(e)?e[e.length-1]:e;t&&typeof t.nodeType=="number"&&Ee(t)}function Gt(e){let t=[];for(;e&&e.nodeType===1;){let n=e.tagName.toLowerCase();if(e.id){n+=`#${e.id}`,t.unshift(n);break}e.getAttribute("data-id")&&(n+=`[data-id="${e.getAttribute("data-id")}"]`);let r=0,o=e;for(;o=o.previousElementSibling;)o.tagName===e.tagName&&r++;n+=`:nth-of-type(${r+1})`,t.unshift(n),e=e.parentElement}return t.join(">")}function Xt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return`el_${Math.abs(t)}`}function wo(e){return Xt(Gt(e))}var No=()=>"xxyxxxxxxy-4xx8".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),Jt={};var ze=new Map,Y=new Set,re=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function Je(e){if(!g)for(let t of e)Y.has(t)||re.has(t)||(Y.add(t),document.addEventListener(t,Yt))}function Yt(e){let t=`$$${e.type}`,n=e.composedPath&&e.composedPath()[0]||e.target;for(;n;){let r=n[t];if(r&&!n.disabled&&(r(e),e.cancelBubble))return;n=n.host&&n.host!==n&&n.host instanceof Element?n.host:n.parentNode}}function Zt(e,t,n){if(e[`$$${t}`]=n,re.has(t)){let r=`__fx_${t}`;if(!e[r]){let o=i=>{e[`$$${t}`]?.(i)};e.addEventListener(t,o),e[r]=o}return}Y.has(t)||Je([t])}function Ge(e,t){delete e[`$$${t}`];let n=`__fx_${t}`,r=e[n];r&&(e.removeEventListener(t,r),delete e[n])}function So(e){return!re.has(e)}function vo(e){return typeof e=="function"}function R(e,t=!1){if(g)return $().createText(e);if(u.active&&!t){let n=G()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}function Ye(e,t=!1){if(g)return $().createElement(e,t);if(u.active){let n=G()?.hydrateElement(e);if(n)return n}return t?document.createElementNS(H,e):document.createElement(e)}function Qt(e,t=!1){let n=ze.get(e);if(n)return n;let r=document.createElement("template");return t?r.innerHTML=`<svg>${e}</svg>`:r.innerHTML=e,ze.set(e,r),r}function Ao(e,t,n=!1,r=!1){if(g){let o=$();return n?o.parseTemplate(e,r):o.createRaw(e)}if(u.active){let o=G()?.hydrateStatic(t);if(o)return o}return en(Qt(e,r),r).firstChild}function Co(e,t){if(!u.active)return t();let n=X(e.nextSibling,t);if(typeof n=="function"){let r=n;return((...o)=>u.active?X(e.nextSibling,()=>r(...o)):r(...o))}return n}function Ro(e){for(let t=e.nextSibling;t;t=t.nextSibling)if(t.nodeType===8&&t.data==="fx/")return t;throw new Error("[fluixi] template hole is missing its closing marker")}function Mo(e,t){let n=[];for(let r=e.nextSibling;r&&r!==t;r=r.nextSibling)n.push(r);return n}function en(e,t=!1){let n=e.content.cloneNode(!0);return t?n.firstChild:n}function tn(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?tn(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}function Po(e){return typeof e!="function"?null:e._name||e.name||"anonymous"}function ko(e){if(x(e)||w(e)||typeof e!="function")return e;let t=e();for(;typeof t=="function"&&!x(t)&&!w(t);)t=t();return t}var v=0,nn=200;function rn(e,t,n,r,o){let i=r,s=new Map;return m(()=>{let a;if(w(e)&&!x(e)){if(!s.has(e)){v++;try{let l=e();s.set(e,l)}finally{v--}}for(a=s.get(e);typeof a=="function"&&x(a);)a=a()}else for(a=e();typeof a=="function"&&x(a);)a=a();{let l=0;for(;typeof a=="function"&&l++<50;)if(w(a)){if(!s.has(a)){let c=a;v++;try{let f=c();s.set(c,f)}finally{v--}}a=s.get(a)}else if(x(a))a=a();else if(a=a(),typeof a!="function"||!x(a)&&!w(a))break}v++;try{i=Z(t,a,n,i,s),o(i)}finally{v--}})}function A(e,t,n,r){if(v>nn)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=R("",!0),e.appendChild(n));let o=r??null,i=l=>Array.isArray(l)&&l.some(c=>typeof c=="function"),s=l=>typeof l=="function"?l:()=>l;if(typeof t!="function"&&!i(t)){v++;try{o=Z(e,t,n,o)}finally{v--}return()=>o}let a=rn(s(t),e,n,o,l=>{o=l});return()=>(a?.(),o)}function Z(e,t,n,r,o){if(t==null||typeof t=="boolean")return P(e,r,n);if(typeof t=="function")for(;typeof t=="function";)t=t();if(t==null||typeof t=="boolean")return P(e,r,n);if(J(t)){let s=R("",!0);return Array.isArray(r)?r.length>0?(e.replaceChild(s,r[0]),P(e,r.slice(1),n)):h(e,s,n):r?e.replaceChild(s,r):h(e,s,n),t.then(a=>{s.parentNode===e&&Z(e,a,s.nextSibling,s)}).catch(a=>{console.error("Error resolving promise in insertExpression:",a)}),s}let i=typeof t;if(i==="string"||i==="number"){if(i==="number"&&(t=String(t)),Array.isArray(r)){if(r.length===0){let a=R(t);return h(e,a,n),a}if(r.length===1&&r[0].nodeType===3)return r[0].data=t,r;r=P(e,r,n)}if(r&&Te(r))return r.data=t,r;let s=R(t);return r&&r.parentNode===e?e.replaceChild(s,r):be(e,s)||h(e,s,n),s}if(I(t))return be(e,t)?(Ee(t),t):Array.isArray(r)?(r.length===0?h(e,t,n):r[0].parentNode===e?(e.replaceChild(t,r[0]),P(e,r.slice(1),n)):h(e,t,n),t):(r?r!==t&&(r.parentNode===e?e.replaceChild(t,r):h(e,t,n)):h(e,t,n),t);if(Array.isArray(t)){let s=[],a=Array.isArray(r)?r:r?[r]:[],l=[];S(t,s,e,n,!0,o,l);let c=on(e,a,s,n);for(let f of l){let d=A(e,f.sig,f.marker);k(()=>{P(e,d()),f.marker.parentNode===e&&e.removeChild(f.marker)})}return c}if(i==="object"&&t!==null&&typeof t=="object"){let s=t;if("type"in s&&"props"in s){let a=s;if(typeof a.type=="function"){let l=a.type(a.props||{});return Z(e,l,n,r)}}}return P(e,r,n)}function S(e,t,n,r,o=!0,i,s){for(let a=0;a<e.length;a++){let l=e[a];if(!(l==null||typeof l=="boolean")){for(;typeof l=="function"&&!J(l)&&!x(l)&&!w(l)&&(l=l(),!(l==null||typeof l=="boolean")););if(!(l==null||typeof l=="boolean")){if(typeof l=="function"){let c;for(w(l)&&!x(l)?(i||(i=new Map),i.has(l)||i.set(l,l()),c=i.get(l)):c=l();typeof c=="function"&&!J(c)&&!x(c)&&!w(c);)i||(i=new Map),i.has(c)||i.set(c,c()),c=i.get(c);if(c==null||typeof c=="boolean")continue;if(typeof c=="function"){if(x(c)){if(s){let d=R("",!0);t.push(d),s.push({marker:d,sig:c});continue}let f=c();for(;typeof f=="function"&&x(f);)f=f();if(f==null||typeof f=="boolean")continue;Array.isArray(f)?S(f,t,n,r,o,i):S([f],t,n,r,o,i);continue}continue}Array.isArray(c)?S(c,t,n,r,o,i,s):S([c],t,n,r,o,i,s);continue}if(J(l)){let c=R("",!0);t.push(c),l.then(f=>{if(c.parentNode){let d=[];if(S([f],d,c.parentNode,void 0,!1,i),d.length>0){c.parentNode.replaceChild(d[0],c);for(let p=1;p<d.length;p++)c.parentNode?.insertBefore(d[p],d[p-1].nextSibling)}}}).catch(f=>console.error("Error resolving promise in array:",f));continue}if(Array.isArray(l)){S(l,t,n,r,o,i,s);continue}if(I(l)){t.push(l);continue}if(typeof l=="object"&&l!==null&&"type"in l&&"props"in l){let c=l;if(typeof c.type=="function"){let f=c.type(c.props||{});Array.isArray(f)?S(f,t,n,r,!1,i):S([f],t,n,r,!1,i);continue}}if(typeof l=="string"||typeof l=="number"){let c=String(l);if(c.trim()===""&&c!==" ")continue;t.push(R(c));continue}t.push(R(String(l)))}}}}function on(e,t,n,r){for(let d=0;d<n.length;d++){let p=n[d].parentNode;p!==null&&p!==e&&p.nodeType!==11&&(n=n.slice(),n[d]=n[d].cloneNode(!0))}let o=n.length,i=t.length,s=o,a=0,l=0,c=i>0?t[i-1].nextSibling??void 0:r,f=null;for(;a<i||l<s;){if(t[a]===n[l]){a++,l++;continue}for(;i>a&&s>l&&t[i-1]===n[s-1];)i--,s--;if(i===a){let d=s<o?l?n[l-1].nextSibling??void 0:n[s-l]:c;for(;l<s;)h(e,n[l++],d)}else if(s===l)for(;a<i;)(!f||!f.has(t[a]))&&t[a].parentNode===e&&e.removeChild(t[a]),a++;else if(t[a]===n[s-1]&&n[l]===t[i-1]){let d=t[--i].nextSibling;h(e,n[l++],t[a++].nextSibling),h(e,n[--s],d),t[i]=t[a-1]}else{if(!f){f=new Map;let p=l;for(;p<s;)f.set(n[p],p++)}let d=f.get(t[a]);if(d!=null)if(l<d&&d<s){let p=a,y=1;for(;++p<i&&p<s&&!(!f.has(t[p])||f.get(t[p])!==d+y);)y++;if(y>d-l){let pe=t[a];for(;l<d;)h(e,n[l++],pe)}else t[a].parentNode===e?e.replaceChild(n[l++],t[a++]):(h(e,n[l++],c),a++)}else a++;else t[a].parentNode===e&&e.removeChild(t[a]),a++}}return n}function P(e,t,n){if(t)if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r].parentNode===e&&e.removeChild(t[r]);else t.parentNode===e&&e.removeChild(t);return null}function h(e,t,n){u.active&&t.parentNode===e||(n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t))}function Q(e,t,n){n==null?delete e[t]:e[t]=n}function Ze(e,t,n){let r=n,o;return Array.isArray(n)&&(r=n[0],o=n[1]),typeof r!="function"?()=>{}:(e.addEventListener(t,r,o),()=>e.removeEventListener(t,r,o))}function Qe(e,t){let n=(r,o)=>{typeof r=="function"&&r(e,o??(()=>{}))};if(typeof t=="function"){n(t);return}if(Array.isArray(t)){if(typeof t[0]=="function"){n(t[0],t[1]);return}for(let r of t)Array.isArray(r)?n(r[0],r[1]):n(r)}}function we(e,t,n,r=!1){return typeof n!="function"?(T(e,t,n,r),()=>{}):m(()=>{let o=typeof n=="function"?n():n;T(e,t,o,r)})}function Ne(e,t,n){return typeof n!="function"?(Q(e,t,n),()=>{}):m(()=>{let r=typeof n=="function"?n():n;Q(e,t,r)})}function et(e,t,n){return typeof n!="function"?(T(e,t,!!n),()=>{}):m(()=>{let r=n();T(e,t,!!r)})}function ee(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){m(()=>ee(e,t()));return}if(typeof t=="string"){e.setAttribute("class",t);return}if(Array.isArray(t)){e.setAttribute("class",t.filter(Boolean).join(" "));return}if(typeof t=="object"){let n=Object.keys(t).filter(r=>{let o=t[r];return typeof o=="function"?o():!!o}).join(" ");e.setAttribute("class",n);return}e.setAttribute("class",String(t))}function te(e,t,n){if(!(!t||typeof t!="object"))for(let r in t){let o=t[r],i=r.split(/\s+/).filter(Boolean);if(typeof o=="function"&&n)n.push(m(()=>{let s=!!o();for(let a of i)e.classList.toggle(a,s)}));else{let s=!!(typeof o=="function"?o():o);for(let a of i)e.classList.toggle(a,s)}}}function ne(e,t){let n=t;for(;typeof n=="function";)n=n();if(n==null){e.removeAttribute("style");return}if(typeof n=="string"){e.style.cssText=n;return}if(typeof n=="object")for(let r in n){let o=n[r];o==null?e.style[r]="":e.style[r]=o}}function Lo(e){let{element:t,props:n,prevProps:r=Jt,isSVG:o=!1,skipChildren:i=!1}=e;if(!t||!xe(t))return console.error("[spread] Error: element is not a DOM Element!"),()=>{};if(!n)return console.warn("[spread] Warning: props is undefined!"),()=>{};let s=o||t.namespaceURI===H,a=[];for(let l in n){if(i&&l==="children")continue;let c=n[l],f=r[l];if(c===f)continue;if(l==="ref"){oe(c,t);continue}if(l==="use"){Qe(t,c);continue}if(l.startsWith("on:")){a.push(Ze(t,l.slice(3),c));continue}if(l.startsWith("prop:")){a.push(Ne(t,l.slice(5),c));continue}if(l.startsWith("attr:")){a.push(we(t,l.slice(5),c,s));continue}if(l.startsWith("bool:")){a.push(et(t,l.slice(5),c));continue}if(l==="class"||l==="className"){typeof c=="function"?a.push(m(()=>ee(t,c()))):ee(t,c);continue}if(l==="classList"){typeof c=="function"?a.push(m(()=>te(t,c()))):te(t,c,a);continue}if(l==="style"){typeof c=="function"?a.push(m(()=>ne(t,c()))):ne(t,c);continue}if(l.startsWith("on")){let p=l.slice(2).toLowerCase();f&&Ge(t,p),c&&Zt(t,p,c);continue}let d=ge.has(l)||!s&&l in t;typeof c=="function"?a.push(d?Ne(t,l,c):we(t,l,c,s)):a.push(m(()=>d?Q(t,l,n[l]):T(t,l,n[l],s)))}for(let l in r)if(!(l in n))if(l.startsWith("on")){let c=l.slice(2).toLowerCase();Ge(t,c)}else ge.has(l)?Q(t,l,null):t.removeAttribute(l);return()=>{a.forEach(l=>l())}}function tt(e,t,n=!1){for(let r in t){let o=t[r];if(r==="ref"){oe(o,e);continue}if(r!=="children"){if(r==="use"){Qe(e,o);continue}if(r.startsWith("on:")){Ze(e,r.slice(3),o);continue}if(r.startsWith("prop:")){Ne(e,r.slice(5),o);continue}if(r.startsWith("attr:")){we(e,r.slice(5),o,n);continue}if(r.startsWith("bool:")){et(e,r.slice(5),o);continue}if(r.startsWith("on")&&r.length>2){let i=r.slice(2).toLowerCase();if(typeof o=="function")if(re.has(i)){e[`$$${i}`]=o;let s=`__fx_${i}`;if(!e[s]){let a=l=>{e[`$$${i}`]?.(l)};e.addEventListener(i,a),e[s]=a}}else e[`$$${i}`]=o,Y.has(i)||Je([i]);continue}if(r==="class"||r==="className"){ee(e,o);continue}if(r==="classList"){typeof o=="function"?m(()=>te(e,o())):te(e,o);continue}if(r==="style"){typeof o=="function"?m(()=>ne(e,o())):ne(e,o);continue}if(r==="innerHTML"){if(typeof o=="function"){let i=U(()=>{let s=o();for(;typeof s=="function";)s=s();e.innerHTML=s});k(()=>i())}else e.innerHTML=o;continue}if(r==="value"&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")){if(typeof o=="function"){let i=U(()=>{let s=o();for(;typeof s=="function"&&s.length===0;)s=s();document.activeElement!==e&&(e.value=s??"")});k(()=>{i()})}else m(()=>{document.activeElement!==e&&(e.value=t[r]??"")});continue}if(r==="checked"&&e.tagName==="INPUT"){if(typeof o=="function"){let i=U(()=>{let s=o();for(;typeof s=="function"&&s.length===0;)s=s();document.activeElement!==e&&(e.checked=s??"")});k(()=>{i()})}else m(()=>{document.activeElement!==e&&(e.checked=t[r]??"")});continue}if(r==="value"&&e.tagName==="SELECT"){if(typeof o=="function"){let i=!0,s=U(()=>{let a=o();for(;typeof a=="function"&&a.length===0;)a=a();i?(i=!1,queueMicrotask(()=>{e.value=a??""})):e.value=a??""});k(()=>{s()})}else{let i=!0;m(()=>{let s=t[r];i?(i=!1,queueMicrotask(()=>{e.value=s??""})):e.value=s??""})}continue}if(typeof o=="function"){let i=U(()=>{let s=o();for(;typeof s=="function"&&s.length===0;)s=s();me(e,r,s,n)});k(()=>{i()})}else m(()=>me(e,r,t[r],n))}}}function Oo(...e){let t=r=>{for(let o=e.length-1;o>=0;o--){let i=e[o];if(i&&r in i&&i[r]!==void 0)return i[r]}},n=r=>{for(let o of e)if(o&&r in o)return!0;return!1};return new Proxy({},{get:(r,o)=>t(o),has:(r,o)=>n(o),ownKeys:()=>{let r=new Set;for(let o of e)if(o)for(let i of Reflect.ownKeys(o))r.add(i);return[...r]},getOwnPropertyDescriptor:(r,o)=>n(o)?{enumerable:!0,configurable:!0,get:()=>t(o)}:void 0})}function Do(e,...t){let n=new Set;for(let s of t)for(let a of s)n.add(a);let r=s=>({enumerable:!0,configurable:!0,get:()=>e[s]}),o=t.map(s=>{let a=new Set(s);return new Proxy({},{get:(l,c)=>a.has(c)?e[c]:void 0,has:(l,c)=>a.has(c)&&c in e,ownKeys:()=>Array.from(a).filter(l=>l in e),getOwnPropertyDescriptor:(l,c)=>a.has(c)&&c in e?r(c):void 0})}),i=new Proxy({},{get:(s,a)=>n.has(a)?void 0:e[a],has:(s,a)=>!n.has(a)&&a in e,ownKeys:()=>Reflect.ownKeys(e).filter(s=>!n.has(s)),getOwnPropertyDescriptor:(s,a)=>!n.has(a)&&a in e?r(a):void 0});return[...o,i]}function oe(e,t){if(e){if(I(e)){let n=t,r=e;if(!n)return;typeof n=="function"?n(r):typeof n=="object"&&"current"in n&&(n.current=r);return}typeof e=="function"?e(t):typeof e=="object"&&"current"in e&&(e.current=t)}}function _o(e,t,n){let r=t||document.body,o=zt(()=>e),i=[];return Xe(()=>{let s=m(()=>{let a=o();Array.isArray(a)?(a.forEach(l=>r.appendChild(l)),i.push(()=>{a.forEach(l=>{l.parentNode===r&&r.removeChild(l)})})):I(a)&&(r.appendChild(a),i.push(()=>{a.parentNode===r&&r.removeChild(a)}))});i.push(s),k(()=>{i.forEach(a=>a())})}),null}function $o(e){return typeof e=="string"&&e.toLowerCase()===e}function nt(e){return e==="svg"||e==="path"||e==="circle"||e==="rect"||e==="line"||e==="polygon"||e==="polyline"||e==="ellipse"||e==="g"||e==="defs"||e==="clipPath"||e==="text"}function Io(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function J(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function qo(e){return typeof e=="function"&&e.length===0&&x(e)}function rt(e,t,n){if(!t)throw new Error("Container element is required");let r,o,i=[];return Kt(s=>{Xe(()=>{u.active||(t.textContent=""),He(t),Ve(),A(t,e)}),o=s}),()=>{o?.(),r?.(),i.forEach(s=>s()),t.textContent=""}}function jo(e){if(Array.isArray(e))return e;if(typeof e=="function"&&typeof e.set=="function")return[e,e.set];throw new TypeError("[fluixi] bind: needs a signal — either `signal(…)` or the `[get, set]` pair from `createSignal(…)`.")}import{untrack as sn,isSignal as an}from"@fluixi/reactive";var ln="__fx_dom_create_component__",L=globalThis[ln]??={fn:null};function Wo(e){L.fn=e}function Uo(e={}){let t=e.signalSystem?.createComponent;t&&(L.fn=t)}function ot(e,t){if(L.fn)return L.fn(e,t);let n=typeof e=="function"?sn(()=>e(t)):e;if(n!=null&&(typeof n=="function"||typeof n=="object")&&!an(n)){try{n.$name=e?.name}catch{}return We(n)}return n}var Bo=()=>L.fn!==null,Ko=()=>L.fn!==null;function zo(){L.fn=null}var ie,st={getStore:()=>ie,run(e,t){let n=ie;ie=e;try{return t()}finally{ie=n}}},Se=st;function at(e){Se=e??st}function B(e={}){e.locals||(e.locals=e.request?Ae(e.request):{});let t=0,n=0,r=null,o=new Map,i=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${t++}`,nextResourceId:()=>{if(r===null)return`r${n++}`;let s=o.get(r)??0;return o.set(r,s+1),`${r}:r${s}`},nextIslandNamespace:s=>{let a=i.get(s)??0;return i.set(s,a+1),`${s}#${a}`},withResourceScope(s,a){let l=r;r=s;try{return a()}finally{r=l}},pending:new Set,data:new Map}}function K(e,t){return Se.run(e,t)}function C(){return Se.getStore()}function ve(){return C()?.event}function lt(){let e=ve();return e?(e.locals||(e.locals={}),e.locals):{}}var it=new WeakMap;function Ae(e){let t=it.get(e);return t||(t={},it.set(e,t)),t}import{setResourceIdSource as cn,setServerDataGetter as un}from"@fluixi/reactive/signal";var z="__FX_DATA__";function se(e){return e.replace(/[<>&\u2028\u2029]/g,t=>"\\u"+t.charCodeAt(0).toString(16).padStart(4,"0"))}var Ce;function ae(){let e=globalThis.__FX_DATA__;if(e)return e;if(Ce!==void 0)return Ce;let t=null;if(typeof document<"u"){let n=document.getElementById(z)?.textContent;if(n)try{t=JSON.parse(n)}catch{t=null}}return Ce=t}function le(){for(;;){for(;u.cursor&&u.cursor.nodeType===3&&u.cursor.data==="";)u.cursor=u.cursor.nextSibling;if(u.cursor!=null||!u.parents.length)return;u.cursor=u.parents.pop().nextSibling}}var fn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ce=typeof process<"u"&&process.env&&!1;function ue(e,t){let n=t.nodeType===1?`<${t.tagName.toLowerCase()}>`:t.nodeType===3?`text ${JSON.stringify((t.nodeValue??"").slice(0,24))}`:t.nodeType===8?"comment":"node";console.warn(`[fluixi] hydration mismatch: expected ${e} but the server DOM has ${n}. Server and client rendered different markup; recreating this node on the client. Check for non-deterministic render (Date.now(), Math.random(), browser-only branches, untransported data).`)}function dn(e){le();let t=u.cursor;return t&&t.nodeType===1&&t.tagName.toLowerCase()===e.toLowerCase()?(fn.has(e.toLowerCase())?u.cursor=t.nextSibling:(u.parents.push(t),u.cursor=t.firstChild),t):(ce&&t&&ue(`<${e}>`,t),null)}function pn(e){le();let t=u.cursor;return t&&t.nodeType===1&&t.tagName.toLowerCase()===e.toLowerCase()?(u.cursor=t.nextSibling,t):(ce&&t&&ue(`<${e}> (static)`,t),null)}function yn(e){if(e===""){let n=u.cursor;return n&&n.nodeType===3&&n.data!==""?(u.cursor=n.nextSibling,n.data="",n):null}le();let t=u.cursor;return t&&t.nodeType===3?(u.cursor=t.nextSibling,t.nodeValue!==e&&(t.nodeValue=e),t):(ce&&t&&ue(`text ${JSON.stringify(e.slice(0,24))}`,t),null)}function mn(e){le();let t=u.cursor;return t&&t.nodeType===8&&t.data===e?(u.cursor=t.nextSibling,t):(ce&&t&&ue(`marker <!--${e.slice(0,24)}-->`,t),null)}var ct=!1;function gn(){ct||(ct=!0,Ke({hydrateElement:dn,hydrateText:yn,hydrateMarker:mn,hydrateStatic:pn}))}function Re(e,t,n){gn(),u.active=!0,u.cursor=t.firstChild,u.parents=[];let r=ae(),o=n?.resourceNamespace,i=0;cn(()=>o?`${o}:r${i++}`:`r${i++}`),un(r?s=>s in r?{value:r[s]}:void 0:null);try{return rt(e,t)}finally{u.active=!1,u.cursor=null,u.parents=[]}}var Me="fluixi-island";function hn(e){let{component:t,props:n={},name:r}=e,o=Ye(Me),i=r??t.name??"Island";T(o,"name",i),T(o,"props",JSON.stringify(n??{}));let s=g?C():void 0;if(s){let a=s.nextIslandNamespace(i);A(o,()=>s.withResourceScope(a,()=>t(n)))}else A(o,()=>t(n));return o}var ut=!1;function xn(){if(ut||typeof document>"u")return;ut=!0;let e=document.createElement("style");e.textContent=`${Me}{display:contents}`,document.head.appendChild(e)}function Tn(e){if(typeof document>"u")return;xn();let t=document.querySelectorAll(Me),n=new Map;t.forEach(r=>{let o=r.getAttribute("name")??"",i=n.get(o)??0;n.set(o,i+1);let s=e[o];if(!s){typeof process>"u"&&console.warn(`[fluixi] island "${o}" has no component in the registry — left static.`);return}let a={};try{a=JSON.parse(r.getAttribute("props")||"{}")}catch{}Re(()=>s(a),r,{resourceNamespace:`${o}#${i}`})})}function bn(e,...t){throw new Error("html`` was not compiled — enable the lit format: fluixi({ format: 'lit' }).")}function En(e,...t){throw new Error("svg`` was not compiled — enable the lit format: fluixi({ format: 'lit' }).")}import{readChildren as wn}from"@fluixi/reactive/signal";function wi(e,t={}){if(typeof e=="function")return ot(e,t);if(typeof e!="string"||e.length===0)return null;let n=nt(e);if(g)return $().createElement(e,n);let r=n?document.createElementNS(H,e):document.createElement(e);return tt(r,t,n),Nn(r,t),r}function Nn(e,t){if(!t||t.children===void 0)return;let n=wn(()=>t.children),r=o=>{A(e,o,typeof o=="function"?null:void 0)};Array.isArray(n)?n.forEach(r):r(n)}import{createChildOwner as Sn,createMemo as Pe,disposeScope as vn,getOwner as An,runWithOwner as Cn,untrack as yt}from"@fluixi/reactive/signal";function ft(e){return typeof e=="function"?e:(()=>e)}function M(e){return()=>{let t=e();return typeof t=="function"?t():t}}function dt(e){return e!=null&&e!==!1}function pt(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function Rn(e){let t=M(()=>e.when),n=Pe(t,void 0),r=Pe(n,void 0),o=An(),i=null,s=null,a=l=>{l!==s&&(i&&vn(i),i=Sn(o),s=l)};return Pe(()=>{let l=r();return a(l?"when":"fallback"),Cn(i,()=>{if(l){let c=e.children;return typeof c=="function"&&!pt(c)?typeof n=="function"?yt(()=>yt(n)?c(n()):e.fallback):c(n):c}return e.fallback});return e.fallback??null},void 0,{name:"show"})}import{mapArray as Mn,keyArray as Pn}from"@fluixi/reactive/signal";function kn(e){let t=M(()=>e.each),n=()=>e.fallback??null,r=(o,i)=>{let s=e.children,a=Array.isArray(s)?s.map(l=>typeof l=="function"?l(o,i):l):typeof s=="function"?s(o,i):s;return W(a),a};return e.by?Pn(t,e.by,(o,i)=>r(o,i),{fallback:n}):Mn(t,(o,i)=>r(o,i),{fallback:n})}import{indexArray as Ln}from"@fluixi/reactive/signal";function On(e){let t=M(()=>e.each);return Ln(t,(n,r)=>{let o=e.children(n,r);return W(o),o},{fallback:()=>e.fallback??null})}import{mapArray as xs,keyArray as Ts,indexArray as bs}from"@fluixi/reactive/signal";import{createMemo as Dn,createChildOwner as _n,disposeScope as $n,getOwner as In,runWithOwner as mt}from"@fluixi/reactive/signal";var ke=Symbol("match");function qn(e){return{[ke]:!0,when:M(()=>e.when),get children(){return e.children}}}function jn(e){let t=Array.isArray(e.children)?e.children:[e.children],n=In(),r=null,o=-1,i=s=>{s!==o&&(r&&$n(r),r=_n(n),o=s)};return Dn(()=>{for(let s=0;s<t.length;s+=1){let l=t[s],c=0;for(;typeof l=="function"&&!l[ke]&&c++<10;)l=l();if(!l||typeof l!="object"||l[ke]!==!0)continue;let f=l.when();if(dt(f))return i(s),mt(r,()=>typeof l.children=="function"?l.children(f):l.children)}return i(-2),mt(r,()=>e.fallback??null)})}import{createMemo as Fn,createChildOwner as Hn,disposeScope as Vn,getOwner as Wn,runWithOwner as Un}from"@fluixi/reactive/signal";function Bn(e){let t=ft(e.component),{component:n,...r}=e,o=Wn(),i=null,s;return Fn(()=>{let a=t();return a!==s&&(i&&Vn(i),i=Hn(o),s=a),a==null?null:typeof a=="string"?{tag:a,props:r}:Un(i,()=>a(r))})}import{createRoot as Kn,onCleanup as zn}from"@fluixi/reactive/signal";function Gn(e){let t=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,n,r;return Kn(o=>{n=o,r=document.createElement("div"),r.style.display="contents",t().appendChild(r),A(r,e.children)&&oe(e.ref,r)}),zn(()=>{n(),r.remove()}),null}import{createMemo as Xn,createSignal as Jn}from"@fluixi/reactive/signal";function gt(e){if(g)return e.fallback??null;let t=u.active,[n,r]=Jn(!t);return t&&queueMicrotask(()=>r(!0)),Xn(()=>n()?e.children:e.fallback??null,void 0,{name:"client-only"})}var Yn=gt;import{createMemo as Zn,createSignal as Qn}from"@fluixi/reactive/signal";function er(e){let[t,n]=Qn(null),r=()=>n(null);return Zn(()=>{let o=t();if(o!==null)return typeof e.fallback=="function"?e.fallback(o,r):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(i){return n(i),typeof e.fallback=="function"?e.fallback(i,r):e.fallback}})}import{createMemo as tr}from"@fluixi/reactive/signal";function nr(e){return tr(()=>{let t=typeof e=="function"?e():e,n=[];for(let[r,o]of Object.entries(t)){if(!r)continue;(typeof o=="function"?o():o)&&n.push(r)}return n.join(" ")})}import{createMemo as rr}from"@fluixi/reactive/signal";function or(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function ir(e){return rr(()=>{let t=typeof e=="function"?e():e,n=[];for(let[r,o]of Object.entries(t)){if(!r)continue;let i=typeof o=="function"?o():o;i!=null&&n.push(`${or(r)}: ${i}`)}return n.join("; ")})}var de=1,De=3,_e=8,ht;ht=V;var q=class{constructor(){this[ht]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let t=this.parentNode;if(!t)return null;let n=t.childNodes.indexOf(this);return n>=0?t.childNodes[n+1]??null:null}get previousSibling(){let t=this.parentNode;if(!t)return null;let n=t.childNodes.indexOf(this);return n>0?t.childNodes[n-1]??null:null}get parentElement(){return this.parentNode}appendChild(t){return t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes.push(t),t}insertBefore(t,n){if(n==null)return this.appendChild(t);t.parentNode&&t.parentNode.removeChild(t);let r=this.childNodes.indexOf(n);return t.parentNode=this,r<0?this.childNodes.push(t):this.childNodes.splice(r,0,t),t}removeChild(t){let n=this.childNodes.indexOf(t);return n>=0&&this.childNodes.splice(n,1),t.parentNode=null,t}replaceChild(t,n){let r=this.childNodes.indexOf(n);return r>=0&&(t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes[r]=t,n.parentNode=null),n}addEventListener(){}removeEventListener(){}},O=class e extends q{constructor(n){super();this.nodeType=De;this.data=n}get nodeValue(){return this.data}set nodeValue(n){this.data=n==null?"":String(n)}get textContent(){return this.data}set textContent(n){this.data=n==null?"":String(n)}cloneNode(){return new e(this.data)}},fe=class e extends q{constructor(n){super();this.nodeType=de;this.rawOuterHTML=n}get textContent(){return this.rawOuterHTML.replace(/<[^>]*>/g,"")}cloneNode(){return new e(this.rawOuterHTML)}},j=class e extends q{constructor(n){super();this.nodeType=_e;this.data=n}get nodeValue(){return this.data}set nodeValue(n){this.data=n==null?"":String(n)}cloneNode(){return new e(this.data)}},Le=class{constructor(){this.cssText=""}setProperty(t,n){this[t]=n}removeProperty(t){delete this[t]}},Oe=class{constructor(t){this.el=t}list(){let t=this.el.getAttribute("class");return t?t.split(/\s+/).filter(Boolean):[]}write(t){t.length?this.el.setAttribute("class",t.join(" ")):this.el.removeAttribute("class")}add(...t){let n=this.list();for(let r of t)n.includes(r)||n.push(r);this.write(n)}remove(...t){this.write(this.list().filter(n=>!t.includes(n)))}contains(t){return this.list().includes(t)}toggle(t,n){let r=this.contains(t),o=n===void 0?!r:n;return o?this.add(t):this.remove(t),o}},D=class e extends q{constructor(n,r=!1){super();this.nodeType=de;this.attributes=new Map;this.style=new Le;this.classList=new Oe(this);this.rawHTML=null;this.localName=n.toLowerCase(),this.tagName=r?n:n.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(n,r){this.attributes.set(n,String(r))}removeAttribute(n){this.attributes.delete(n)}getAttribute(n){return this.attributes.has(n)?this.attributes.get(n):null}hasAttribute(n){return this.attributes.has(n)}get id(){return this.getAttribute("id")??""}set id(n){n==null?this.removeAttribute("id"):this.setAttribute("id",n)}get className(){return this.getAttribute("class")??""}set className(n){n==null?this.removeAttribute("class"):this.setAttribute("class",n)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(n){n==null?this.removeAttribute("for"):this.setAttribute("for",n)}set value(n){n==null?this.removeAttribute("value"):this.setAttribute("value",String(n))}set checked(n){n?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(n){n?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(n){}get textContent(){return this.childNodes.map(n=>n.textContent??"").join("")}set textContent(n){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,n!=null&&n!==""&&this.appendChild(new O(String(n)))}set innerText(n){this.textContent=n}set innerHTML(n){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=n==null?"":String(n)}cloneNode(n=!1){let r=new e(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,n)for(let o of this.childNodes)r.appendChild(o.cloneNode(!0));return r}};var sr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Tt=/&/g,bt=/</g,Et=/>/g,ar=/"/g;function $e(e){return e.replace(Tt,"&").replace(bt,"<").replace(Et,">")}function xt(e){return e.replace(Tt,"&").replace(ar,""").replace(bt,"<").replace(Et,">")}function lr(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function cr(e){if(!e)return"";let t=[];e.cssText&&t.push(e.cssText.trim().replace(/;\s*$/,""));for(let n of Object.keys(e)){if(n==="cssText")continue;let r=e[n];r==null||r===""||t.push(`${lr(n)}: ${r}`)}return t.join("; ")}function ur(e){let t="",n=cr(e.style);for(let[r,o]of e.attributes)r==="style"&&n||(t+=` ${r}="${xt(o)}"`);if(n){let r=e.attributes.get("style"),o=r?`${r.replace(/;\s*$/,"")}; ${n}`:n;t+=` style="${xt(o)}"`}return t}function N(e){if(e==null||e===!1||e===!0)return"";if(typeof e=="string")return $e(e);if(typeof e=="number")return $e(String(e));if(typeof e=="function")return N(e());if(Array.isArray(e))return e.map(N).join("");if(typeof e.rawOuterHTML=="string")return e.rawOuterHTML;switch(e.nodeType){case De:return $e(e.data??"");case _e:return`<!--${e.data??""}-->`;case de:{let t=e.localName,n=`<${t}${ur(e)}>`;if(sr.has(t))return n;let r=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(N).join("");return`${n}${r}</${t}>`}}return Array.isArray(e.childNodes)?e.childNodes.map(N).join(""):""}import{createRoot as Ct}from"@fluixi/reactive/signal";import{setResourceTracker as pr,setResourceIdSource as yr,setResourceDataSink as mr,getOwner as gr,runWithOwner as St,flush as hr}from"@fluixi/reactive/signal";var fr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),dr={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'"};function wt(e){return e.replace(/&(#?\w+);/g,(t,n)=>dr[n]??t)}var E=class extends Error{};function Nt(e,t=!1){let n=0,r=[],o=[],i=c=>{let f=o[o.length-1];f?f.appendChild(c):r.push(c)};for(;n<e.length;){let c=e.indexOf("<",n);if(c===-1){a(e.slice(n));break}if(c>n&&a(e.slice(n,c)),e.startsWith("<!--",c)){let f=e.indexOf("-->",c);if(f===-1)throw new E(`unterminated comment at ${c}`);i(new j(e.slice(c+4,f))),n=f+3;continue}if(e[c+1]==="/"){let f=e.indexOf(">",c);if(f===-1)throw new E(`unterminated closing tag at ${c}`);let d=e.slice(c+2,f).trim().toLowerCase(),p=o.pop();if(!p||p.localName!==d)throw new E(`</${d}> does not close <${p?.localName??"nothing"}>`);n=f+1;continue}n=l(c)}if(o.length>0)throw new E(`unclosed <${o[o.length-1].localName}>`);let s=r[0];if(r.length!==1||!(s instanceof D))throw new E(`expected exactly one root element, got ${r.length}`);return s;function a(c){c!==""&&i(new O(wt(c)))}function l(c){let f=/[\s/>]/.exec(e.slice(c+1));if(!f)throw new E(`unterminated tag at ${c}`);let d=e.slice(c+1,c+1+f.index).toLowerCase(),p=new D(d,t),y=c+1+f.index;for(;y<e.length;){for(;y<e.length&&/\s/.test(e[y]);)y++;if(e[y]===">"){y++;break}if(e[y]==="/"&&e[y+1]===">"){y+=2;break}let pe=y;for(;y<e.length&&!/[\s=/>]/.test(e[y]);)y++;let F=e.slice(pe,y);if(F==="")throw new E(`malformed attribute at ${y}`);if(e[y]==="="){if(e[y+1]!=='"')throw new E(`attribute ${F} must have a double-quoted value`);let ye=e.indexOf('"',y+2);if(ye===-1)throw new E(`unterminated value for ${F}`);p.setAttribute(F,wt(e.slice(y+2,ye))),y=ye+1}else p.setAttribute(F,"")}return i(p),fr.has(d)||o.push(p),y}}var vt=!1;function Rt(){vt||(vt=!0,Ue({createElement:(e,t)=>new D(e,t),createText:e=>new O(e),createRaw:e=>new fe(e),parseTemplate:(e,t)=>Nt(e,t),createComment:e=>new j(e)}))}function Mt(e,t={}){let n=g;Rt(),_(!0);let r=B(t.event);try{return K(r,()=>Ct(o=>{try{let i=typeof e=="function"?e():e;return N(i)}finally{o()}}))}finally{_(n)}}var At=!1;function xr(){At||(At=!0,pr(e=>{C()?.pending.add(e)}),yr(()=>C()?.nextResourceId()??""),mr((e,t)=>{e&&C()?.data.set(e,t)}))}var Ie=null;function Pt(e){Ie=e}function qe(e){if(e.data.size===0)return"";let t={};for(let[r,o]of e.data){let i=o;if(Ie)try{i=Ie(o,r)}catch{continue}i!==void 0&&(typeof i=="function"||typeof i=="symbol"||(t[r]=i))}if(Object.keys(t).length===0)return"";let n=se(JSON.stringify(t));return n==="{}"?"":`<script type="application/json" id="${z}">${n}<\/script>`}var Tr=50;async function kt(e,t={}){let n=g;Rt(),_(!0),xr();let r=B(t.event);try{return await K(r,async()=>{t.preload&&await t.preload(t.event);let o,i=null,s=()=>{};Ct(f=>{s=f,i=gr(),o=typeof e=="function"?e():e});let a=()=>{try{St(i,()=>N(o))}catch{}};a();let l=0;for(;r.pending.size>0&&l++<Tr;){let f=Array.from(r.pending);r.pending.clear(),await Promise.allSettled(f),await hr(),a()}let c=St(i,()=>N(o))+qe(r);return s(),c})}finally{_(n)}}import{signal as aa,memo as la,effect as ca}from"@fluixi/reactive/signal";import{store as fa}from"@fluixi/reactive/store";import{createSignal as pa,createMemo as ya,createEffect as ma,createComputed as ga,createRenderEffect as ha,createRoot as xa,createResource as Ta,createContext as ba,useContext as Ea,onCleanup as wa,batch as Na,untrack as Sa}from"@fluixi/reactive/signal";import{createStore as Aa}from"@fluixi/reactive/store";export{gt as ClientOnly,Bn as Dynamic,er as ErrorBoundary,z as FX_DATA_ID,kn as For,On as Index,hn as Island,ge as JSX_PROPERTIES,qn as Match,Yn as NoSsr,Gn as Portal,vr as SVG_ELEMENTS,H as SVG_NAMESPACE,Rn as Show,jn as Switch,Sr as VOID_ELEMENTS,Rr as addClass,Zt as addDelegatedEventListener,Ze as addNativeEventListener,Ir as appendChildren,me as applyElementProp,tt as applyProps,Qe as applyUse,We as asComponent,ao as asContext,io as asOutlet,so as asProvider,oo as asRoute,no as asRouter,ro as asRoutes,lo as asSuspense,Na as batch,jo as bindPair,Ut as captureHydrationCursor,co as checkRenderType,nr as classMap,P as cleanChildren,en as cloneTemplate,Cr as closest,ot as createComponent,ga as createComputed,ba as createContext,wi as createDynamicElement,ma as createEffect,_r as createElement,ya as createMemo,Ye as createNativeElement,_o as createPortal,ha as createRenderEffect,B as createRequestContext,Ta as createResource,xa as createRoot,pa as createSignal,Aa as createStore,Qt as createTemplate,Hr as delegate,Je as delegateEvents,ca as effect,se as escapeFxJson,Io as escapeHTML,Po as fnName,No as generateID,Lr as getAttribute,Jr as getGlobal,wr as getLitEventName,lt as getLocals,Fr as getOffset,C as getRequestContext,ve as getRequestEvent,Ae as getRequestLocals,ae as getServerData,wo as getStableElementId,Dr as getStyle,oe as handleRef,kr as hasClass,Mo as holeContent,Ro as holeEnd,Co as holeScope,bn as html,Re as hydrate,W as hydrateAdvancePast,Tn as hydrateIslands,bs as indexArray,Uo as initializeIntegration,A as insert,Z as insertExpression,Bo as intergartionInitialized,qo as isAccessor,w as isComponent,Vt as isContext,Lt as isCustomElement,Gr as isDOMNode,So as isDelegatedEvent,xe as isDomElement,I as isDomNode,Te as isDomText,Er as isEventHandler,vo as isFunction,Ko as isIntegrationInitialized,zr as isJSXTemplate,_t as isLitTemplateResult,$o as isNativeElement,Ft as isOutlet,J as isPromise,Ht as isProvider,Br as isReactElement,jt as isRoute,It as isRouter,qt as isRoutes,nt as isSVGElement,g as isServer,Wt as isSuspense,Kr as isTemplateFactory,qr as isVisible,ko as iterateFn,Ts as keyArray,tn as makeArrayFlat,xs as mapArray,la as memo,Oo as mergeProps,Wr as observeIntersection,Ur as observeResize,wa as onCleanup,je as query,Ar as queryAll,Wo as registerCreateComponent,Xr as registerGlobal,Or as removeAttribute,$r as removeChildren,Mr as removeClass,Ge as removeDelegatedEventListener,rt as render,Mt as renderToString,kt as renderToStringAsync,zo as resetIntegration,X as runHydrationAt,K as runWithRequestContext,Bt as runWithoutHydration,jr as scrollIntoView,N as serializeNode,qe as serializeResourceData,T as setAttribute,te as setClassList,ee as setClassName,Pt as setDataRedactor,we as setDynamicAttribute,et as setDynamicBoolAttribute,Ne as setDynamicProperty,Q as setProperty,at as setRequestStore,_ as setServerMode,ne as setStyle,Ot as setStyles,Nr as shouldSetAsProperty,aa as signal,Do as splitProps,Lo as spread,fa as store,ir as styleMap,En as svg,Ao as templateNode,br as toAttributeName,Pr as toggleClass,Sa as untrack,Ea as useContext,Vr as waitForElement};
|
|
1
|
+
// src/lib/dom/utils.ts
|
|
2
|
+
function toAttributeName(key) {
|
|
3
|
+
if (key.startsWith("aria-") || key.startsWith("data-")) {
|
|
4
|
+
return key;
|
|
5
|
+
}
|
|
6
|
+
if (/[A-Z]/.test(key)) {
|
|
7
|
+
return key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
8
|
+
}
|
|
9
|
+
return key;
|
|
10
|
+
}
|
|
11
|
+
function isEventHandler(key) {
|
|
12
|
+
return key.startsWith("@") || key.startsWith("on") && key.length > 2;
|
|
13
|
+
}
|
|
14
|
+
function getLitEventName(key) {
|
|
15
|
+
if (key.startsWith("@")) {
|
|
16
|
+
return key.slice(1);
|
|
17
|
+
}
|
|
18
|
+
if (key.startsWith("on")) {
|
|
19
|
+
const eventName = key.slice(2);
|
|
20
|
+
return eventName.toLowerCase();
|
|
21
|
+
}
|
|
22
|
+
return key;
|
|
23
|
+
}
|
|
24
|
+
function shouldSetAsProperty(element, key) {
|
|
25
|
+
const propertyAttributes = /* @__PURE__ */ new Set([
|
|
26
|
+
"checked",
|
|
27
|
+
"value",
|
|
28
|
+
"selected",
|
|
29
|
+
"disabled",
|
|
30
|
+
"readonly",
|
|
31
|
+
"required",
|
|
32
|
+
"multiple",
|
|
33
|
+
"open",
|
|
34
|
+
"contenteditable",
|
|
35
|
+
"draggable",
|
|
36
|
+
"spellcheck"
|
|
37
|
+
]);
|
|
38
|
+
const elementSpecificProps = {
|
|
39
|
+
input: /* @__PURE__ */ new Set(["value", "checked", "indeterminate"]),
|
|
40
|
+
textarea: /* @__PURE__ */ new Set(["value"]),
|
|
41
|
+
select: /* @__PURE__ */ new Set(["value"]),
|
|
42
|
+
option: /* @__PURE__ */ new Set(["selected", "value"]),
|
|
43
|
+
audio: /* @__PURE__ */ new Set(["volume", "currentTime", "paused"]),
|
|
44
|
+
video: /* @__PURE__ */ new Set(["volume", "currentTime", "paused"]),
|
|
45
|
+
img: /* @__PURE__ */ new Set(["src", "srcset"]),
|
|
46
|
+
iframe: /* @__PURE__ */ new Set(["src"]),
|
|
47
|
+
a: /* @__PURE__ */ new Set(["href"])
|
|
48
|
+
};
|
|
49
|
+
return propertyAttributes.has(key) || elementSpecificProps[element] && elementSpecificProps[element].has(key);
|
|
50
|
+
}
|
|
51
|
+
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
52
|
+
"area",
|
|
53
|
+
"base",
|
|
54
|
+
"br",
|
|
55
|
+
"col",
|
|
56
|
+
"embed",
|
|
57
|
+
"hr",
|
|
58
|
+
"img",
|
|
59
|
+
"input",
|
|
60
|
+
"link",
|
|
61
|
+
"meta",
|
|
62
|
+
"param",
|
|
63
|
+
"source",
|
|
64
|
+
"track",
|
|
65
|
+
"wbr"
|
|
66
|
+
]);
|
|
67
|
+
var SVG_ELEMENTS = /* @__PURE__ */ new Set([
|
|
68
|
+
"svg",
|
|
69
|
+
"g",
|
|
70
|
+
"path",
|
|
71
|
+
"circle",
|
|
72
|
+
"rect",
|
|
73
|
+
"line",
|
|
74
|
+
"polyline",
|
|
75
|
+
"polygon",
|
|
76
|
+
"ellipse",
|
|
77
|
+
"text",
|
|
78
|
+
"tspan",
|
|
79
|
+
"use",
|
|
80
|
+
"defs",
|
|
81
|
+
"symbol",
|
|
82
|
+
"mask",
|
|
83
|
+
"clipPath",
|
|
84
|
+
"pattern",
|
|
85
|
+
"linearGradient",
|
|
86
|
+
"radialGradient",
|
|
87
|
+
"stop",
|
|
88
|
+
"filter",
|
|
89
|
+
"feGaussianBlur",
|
|
90
|
+
"feOffset",
|
|
91
|
+
"feMerge",
|
|
92
|
+
"feMergeNode",
|
|
93
|
+
"foreignObject"
|
|
94
|
+
]);
|
|
95
|
+
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
96
|
+
function isCustomElement(element) {
|
|
97
|
+
return element.localName.includes("-");
|
|
98
|
+
}
|
|
99
|
+
function applyElementProp(element, name, value, isSVG = false) {
|
|
100
|
+
if (value == null) {
|
|
101
|
+
element.removeAttribute(name);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (isCustomElement(element)) {
|
|
105
|
+
element[name] = value;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
setAttribute(element, name, value, isSVG);
|
|
109
|
+
}
|
|
110
|
+
var JSX_PROPERTIES = /* @__PURE__ */ new Set([
|
|
111
|
+
"className",
|
|
112
|
+
"value",
|
|
113
|
+
"checked",
|
|
114
|
+
"selected",
|
|
115
|
+
"innerHTML",
|
|
116
|
+
"innerText",
|
|
117
|
+
"textContent",
|
|
118
|
+
"indeterminate",
|
|
119
|
+
"htmlFor"
|
|
120
|
+
]);
|
|
121
|
+
function query(selector, root = document) {
|
|
122
|
+
return root.querySelector(selector);
|
|
123
|
+
}
|
|
124
|
+
function queryAll(selector, root = document) {
|
|
125
|
+
return Array.from(root.querySelectorAll(selector));
|
|
126
|
+
}
|
|
127
|
+
function closest(element, selector) {
|
|
128
|
+
return element.closest(selector);
|
|
129
|
+
}
|
|
130
|
+
function addClass(element, ...classes) {
|
|
131
|
+
element.classList.add(...classes);
|
|
132
|
+
}
|
|
133
|
+
function removeClass(element, ...classes) {
|
|
134
|
+
element.classList.remove(...classes);
|
|
135
|
+
}
|
|
136
|
+
function toggleClass(element, ...classes) {
|
|
137
|
+
classes.forEach((cls) => element.classList.toggle(cls));
|
|
138
|
+
}
|
|
139
|
+
function hasClass(element, className) {
|
|
140
|
+
return element.classList.contains(className);
|
|
141
|
+
}
|
|
142
|
+
function setAttribute(element, name, value, isSVG = false) {
|
|
143
|
+
if (value == null || value === false) {
|
|
144
|
+
element.removeAttribute(name);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (value === true) {
|
|
148
|
+
element.setAttribute(name, "");
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (typeof value === "object") {
|
|
152
|
+
element.setAttribute(name, JSON.stringify(value));
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
element.setAttribute(name, String(value));
|
|
156
|
+
}
|
|
157
|
+
function getAttribute(element, name) {
|
|
158
|
+
return element.getAttribute(name);
|
|
159
|
+
}
|
|
160
|
+
function removeAttribute(element, name) {
|
|
161
|
+
element.removeAttribute(name);
|
|
162
|
+
}
|
|
163
|
+
function setStyles(element, styles) {
|
|
164
|
+
Object.assign(element.style, styles);
|
|
165
|
+
}
|
|
166
|
+
function getStyle(element, property) {
|
|
167
|
+
return window.getComputedStyle(element).getPropertyValue(property);
|
|
168
|
+
}
|
|
169
|
+
function createElement(tagName, attributes = {}, ...children) {
|
|
170
|
+
const element = document.createElement(tagName);
|
|
171
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
172
|
+
if (key === "class" || key === "className") {
|
|
173
|
+
element.className = value;
|
|
174
|
+
} else if (key === "style" && typeof value === "object") {
|
|
175
|
+
setStyles(element, value);
|
|
176
|
+
} else if (key.startsWith("on") && typeof value === "function") {
|
|
177
|
+
const event = key.slice(2).toLowerCase();
|
|
178
|
+
element.addEventListener(event, value);
|
|
179
|
+
} else {
|
|
180
|
+
setAttribute(element, key, value);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
children.forEach((child) => {
|
|
184
|
+
if (typeof child === "string") {
|
|
185
|
+
element.appendChild(document.createTextNode(child));
|
|
186
|
+
} else {
|
|
187
|
+
element.appendChild(child);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return element;
|
|
191
|
+
}
|
|
192
|
+
function removeChildren(element) {
|
|
193
|
+
while (element.firstChild) {
|
|
194
|
+
element.removeChild(element.firstChild);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function appendChildren(parent, ...children) {
|
|
198
|
+
children.forEach((child) => {
|
|
199
|
+
if (typeof child === "string") {
|
|
200
|
+
parent.appendChild(document.createTextNode(child));
|
|
201
|
+
} else {
|
|
202
|
+
parent.appendChild(child);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function isVisible(element) {
|
|
207
|
+
const rect = element.getBoundingClientRect();
|
|
208
|
+
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= window.innerHeight && rect.right <= window.innerWidth;
|
|
209
|
+
}
|
|
210
|
+
function scrollIntoView(element, options = { behavior: "smooth", block: "nearest" }) {
|
|
211
|
+
element.scrollIntoView(options);
|
|
212
|
+
}
|
|
213
|
+
function getOffset(element) {
|
|
214
|
+
const rect = element.getBoundingClientRect();
|
|
215
|
+
return {
|
|
216
|
+
top: rect.top + window.pageYOffset,
|
|
217
|
+
left: rect.left + window.pageXOffset
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function delegate(parent, eventName, selector, handler) {
|
|
221
|
+
const listener = (event) => {
|
|
222
|
+
const target = event.target.closest(selector);
|
|
223
|
+
if (target && parent.contains(target)) {
|
|
224
|
+
handler(event, target);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
parent.addEventListener(eventName, listener);
|
|
228
|
+
return () => {
|
|
229
|
+
parent.removeEventListener(eventName, listener);
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function waitForElement(selector, timeout = 5e3) {
|
|
233
|
+
return new Promise((resolve, reject) => {
|
|
234
|
+
const element = query(selector);
|
|
235
|
+
if (element) {
|
|
236
|
+
resolve(element);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const observer = new MutationObserver(() => {
|
|
240
|
+
const element2 = query(selector);
|
|
241
|
+
if (element2) {
|
|
242
|
+
observer.disconnect();
|
|
243
|
+
clearTimeout(timeoutId);
|
|
244
|
+
resolve(element2);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
observer.observe(document.body, {
|
|
248
|
+
childList: true,
|
|
249
|
+
subtree: true
|
|
250
|
+
});
|
|
251
|
+
const timeoutId = setTimeout(() => {
|
|
252
|
+
observer.disconnect();
|
|
253
|
+
reject(new Error(`Element ${selector} not found within ${timeout}ms`));
|
|
254
|
+
}, timeout);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function observeIntersection(element, callback, options = {}) {
|
|
258
|
+
const observer = new IntersectionObserver((entries) => {
|
|
259
|
+
entries.forEach((entry) => {
|
|
260
|
+
callback(entry.isIntersecting);
|
|
261
|
+
});
|
|
262
|
+
}, options);
|
|
263
|
+
observer.observe(element);
|
|
264
|
+
return () => {
|
|
265
|
+
observer.disconnect();
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function observeResize(element, callback) {
|
|
269
|
+
const observer = new ResizeObserver((entries) => {
|
|
270
|
+
entries.forEach(callback);
|
|
271
|
+
});
|
|
272
|
+
observer.observe(element);
|
|
273
|
+
return () => {
|
|
274
|
+
observer.disconnect();
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
|
|
278
|
+
function isReactElement(value) {
|
|
279
|
+
return typeof value === "object" && value !== null && value.$$typeof === REACT_ELEMENT_TYPE;
|
|
280
|
+
}
|
|
281
|
+
function isLitTemplateResult(value) {
|
|
282
|
+
return value && typeof value === "object" && value.strings && Array.isArray(value.strings) && value.values && Array.isArray(value.values);
|
|
283
|
+
}
|
|
284
|
+
function isTemplateFactory(value) {
|
|
285
|
+
if (typeof value !== "function") return false;
|
|
286
|
+
try {
|
|
287
|
+
const result = value();
|
|
288
|
+
return isLitTemplateResult(result);
|
|
289
|
+
} catch {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function isJSXTemplate(value) {
|
|
294
|
+
return typeof value === "object" && value !== null && (value.$$typeof === "template" || typeof value.type === "function");
|
|
295
|
+
}
|
|
296
|
+
function isDOMNode(value) {
|
|
297
|
+
return value instanceof Node;
|
|
298
|
+
}
|
|
299
|
+
function registerGlobal(key, value, _Key = "Fluixi") {
|
|
300
|
+
if (typeof globalThis !== "undefined") {
|
|
301
|
+
if (typeof globalThis[_Key] === "undefined") {
|
|
302
|
+
globalThis[_Key] = {};
|
|
303
|
+
}
|
|
304
|
+
if (typeof globalThis[_Key][key] === "undefined") {
|
|
305
|
+
globalThis[_Key][key] = value;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function getGlobal(key, value, _Key = "Fluixi") {
|
|
310
|
+
if (typeof globalThis !== "undefined") {
|
|
311
|
+
if (typeof globalThis[_Key] !== "undefined") {
|
|
312
|
+
if (typeof globalThis[_Key][key] !== "undefined") {
|
|
313
|
+
return globalThis[_Key][key];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return value;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// src/lib/dom/runtime.ts
|
|
321
|
+
import {
|
|
322
|
+
isSignal
|
|
323
|
+
} from "@fluixi/reactive/signal";
|
|
324
|
+
|
|
325
|
+
// src/version.generated.ts
|
|
326
|
+
var VERSION = "1.0.0-alpha.84";
|
|
327
|
+
|
|
328
|
+
// src/lib/dom/versions.ts
|
|
329
|
+
import { VERSION as REACTIVE } from "@fluixi/reactive/version";
|
|
330
|
+
import { joinedVersions } from "@fluixi/reactive/signal";
|
|
331
|
+
var versions = { dom: VERSION, reactive: REACTIVE };
|
|
332
|
+
function stampVersions(container) {
|
|
333
|
+
if (versions.core) container.setAttribute("fluixi", versions.core);
|
|
334
|
+
container.setAttribute("fx-dom", versions.dom);
|
|
335
|
+
container.setAttribute("fx-reactive", versions.reactive);
|
|
336
|
+
if (typeof globalThis !== "undefined") globalThis.Fluixi = versions;
|
|
337
|
+
}
|
|
338
|
+
function warnOnVersionSkew() {
|
|
339
|
+
const builds = joinedVersions();
|
|
340
|
+
if (builds.length > 1) {
|
|
341
|
+
console.warn(
|
|
342
|
+
`[fluixi] ${builds.length} builds of @fluixi/reactive are driving one reactive graph: ${builds.join(", ")}. They share it on purpose, so signals still cross between them, but the oldest one decided what the graph looks like. Build the components on one release, or load them as shared-runtime bundles.`
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
const present = [versions.core, versions.dom, versions.reactive].filter(
|
|
346
|
+
(v) => v !== void 0
|
|
347
|
+
);
|
|
348
|
+
if (new Set(present).size <= 1) return;
|
|
349
|
+
console.warn(
|
|
350
|
+
`[fluixi] package versions disagree: core ${versions.core ?? "(absent)"}, dom ${versions.dom}, reactive ${versions.reactive}. These ship as one release, so a mismatch usually means a stale lockfile or two copies resolved side by side. Reinstall, or check for duplicates with \`pnpm why @fluixi/dom\`.`
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// src/lib/component/modifiers.ts
|
|
355
|
+
function asRouter(value) {
|
|
356
|
+
Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-router"), { value: true, enumerable: true });
|
|
357
|
+
return value;
|
|
358
|
+
}
|
|
359
|
+
function asRoutes(value) {
|
|
360
|
+
Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-routes"), { value: true, enumerable: true });
|
|
361
|
+
return value;
|
|
362
|
+
}
|
|
363
|
+
function asRoute(value) {
|
|
364
|
+
Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-route"), { value: true, enumerable: true });
|
|
365
|
+
return value;
|
|
366
|
+
}
|
|
367
|
+
function asOutlet(value) {
|
|
368
|
+
if (typeof value !== "function") return value;
|
|
369
|
+
Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-outlet"), { value: true, enumerable: true });
|
|
370
|
+
return value;
|
|
371
|
+
}
|
|
372
|
+
function asProvider(value) {
|
|
373
|
+
Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-provider"), { value: true, enumerable: true });
|
|
374
|
+
return value;
|
|
375
|
+
}
|
|
376
|
+
function asContext(value) {
|
|
377
|
+
Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-context"), { value: true, enumerable: true });
|
|
378
|
+
return value;
|
|
379
|
+
}
|
|
380
|
+
function asComponent(value) {
|
|
381
|
+
if (typeof value !== "function") return value;
|
|
382
|
+
Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-component"), { value: true, enumerable: true });
|
|
383
|
+
return value;
|
|
384
|
+
}
|
|
385
|
+
function asSuspense(value) {
|
|
386
|
+
Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-suspense"), { value: true, enumerable: true });
|
|
387
|
+
return value;
|
|
388
|
+
}
|
|
389
|
+
function isRouter(value) {
|
|
390
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-router")] === true;
|
|
391
|
+
}
|
|
392
|
+
function isRoutes(value) {
|
|
393
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-routes")] === true;
|
|
394
|
+
}
|
|
395
|
+
function isRoute(value) {
|
|
396
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-route")] === true;
|
|
397
|
+
}
|
|
398
|
+
function isOutlet(value) {
|
|
399
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-outlet")] === true;
|
|
400
|
+
}
|
|
401
|
+
function isProvider(value) {
|
|
402
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-provider")] === true;
|
|
403
|
+
}
|
|
404
|
+
function isContext(value) {
|
|
405
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-context")] === true;
|
|
406
|
+
}
|
|
407
|
+
function isComponent(value) {
|
|
408
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
|
|
409
|
+
}
|
|
410
|
+
function isSuspense(value) {
|
|
411
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-suspense")] === true;
|
|
412
|
+
}
|
|
413
|
+
function checkRenderType(value) {
|
|
414
|
+
if (isRouter(value)) {
|
|
415
|
+
return { type: "router", value };
|
|
416
|
+
}
|
|
417
|
+
if (isRoute(value)) {
|
|
418
|
+
return { type: "route", value };
|
|
419
|
+
}
|
|
420
|
+
if (isRoutes(value)) {
|
|
421
|
+
return { type: "routes", value };
|
|
422
|
+
}
|
|
423
|
+
if (isOutlet(value)) {
|
|
424
|
+
return { type: "outlet", value };
|
|
425
|
+
}
|
|
426
|
+
if (isComponent(value)) {
|
|
427
|
+
return { type: "component", value };
|
|
428
|
+
}
|
|
429
|
+
if (isSuspense(value)) {
|
|
430
|
+
return { type: "suspense", value };
|
|
431
|
+
}
|
|
432
|
+
if (isProvider(value)) {
|
|
433
|
+
return { type: "provider", value };
|
|
434
|
+
}
|
|
435
|
+
if (isContext(value)) {
|
|
436
|
+
return { type: "context", value };
|
|
437
|
+
}
|
|
438
|
+
return { type: "none", value };
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// src/lib/dom/runtime.ts
|
|
442
|
+
import { batch, createEffect, createRenderEffect, createRoot, onCleanup, readChildren, reportReactiveBinding, reportReactiveDirective, untrack } from "@fluixi/reactive/signal";
|
|
443
|
+
|
|
444
|
+
// src/lib/dom/server/host.ts
|
|
445
|
+
var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
|
|
446
|
+
var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
|
|
447
|
+
var realm = globalThis;
|
|
448
|
+
var state = realm[STATE] ??= {
|
|
449
|
+
server: typeof document === "undefined",
|
|
450
|
+
nodes: null
|
|
451
|
+
};
|
|
452
|
+
function isServer() {
|
|
453
|
+
return state.server;
|
|
454
|
+
}
|
|
455
|
+
function setServerMode(on) {
|
|
456
|
+
state.server = on;
|
|
457
|
+
}
|
|
458
|
+
function registerServerNodes(factory) {
|
|
459
|
+
state.nodes = factory;
|
|
460
|
+
}
|
|
461
|
+
function getServerNodes() {
|
|
462
|
+
if (!state.nodes) {
|
|
463
|
+
throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
|
|
464
|
+
}
|
|
465
|
+
return state.nodes;
|
|
466
|
+
}
|
|
467
|
+
function isDomNode(x) {
|
|
468
|
+
if (x != null && x[SERVER_NODE] === true) return true;
|
|
469
|
+
return typeof Node !== "undefined" && x instanceof Node;
|
|
470
|
+
}
|
|
471
|
+
function isDomElement(x) {
|
|
472
|
+
if (x != null && x[SERVER_NODE] === true) return x.nodeType === 1;
|
|
473
|
+
return typeof Element !== "undefined" && x instanceof Element;
|
|
474
|
+
}
|
|
475
|
+
function isDomText(x) {
|
|
476
|
+
if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
|
|
477
|
+
return typeof Text !== "undefined" && x instanceof Text;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// src/lib/dom/hydration-state.ts
|
|
481
|
+
var hydration = {
|
|
482
|
+
active: false,
|
|
483
|
+
cursor: null,
|
|
484
|
+
parents: []
|
|
485
|
+
};
|
|
486
|
+
var _walker = null;
|
|
487
|
+
function registerHydrationWalker(walker) {
|
|
488
|
+
_walker = walker;
|
|
489
|
+
}
|
|
490
|
+
function getHydrationWalker() {
|
|
491
|
+
return _walker;
|
|
492
|
+
}
|
|
493
|
+
function isAdopted(parent, node) {
|
|
494
|
+
return hydration.active && node.parentNode === parent;
|
|
495
|
+
}
|
|
496
|
+
function ascendPast(node) {
|
|
497
|
+
const idx = hydration.parents.lastIndexOf(node);
|
|
498
|
+
if (idx !== -1) hydration.parents.length = idx;
|
|
499
|
+
hydration.cursor = node.nextSibling;
|
|
500
|
+
}
|
|
501
|
+
function captureHydrationCursor() {
|
|
502
|
+
return hydration.active ? hydration.cursor : null;
|
|
503
|
+
}
|
|
504
|
+
function runHydrationAt(cursor, fn) {
|
|
505
|
+
if (!cursor || cursor.parentNode == null) return fn();
|
|
506
|
+
const prevActive = hydration.active;
|
|
507
|
+
const prevCursor = hydration.cursor;
|
|
508
|
+
const prevParents = hydration.parents;
|
|
509
|
+
hydration.active = true;
|
|
510
|
+
hydration.cursor = cursor;
|
|
511
|
+
hydration.parents = [];
|
|
512
|
+
try {
|
|
513
|
+
return fn();
|
|
514
|
+
} finally {
|
|
515
|
+
hydration.active = prevActive;
|
|
516
|
+
hydration.cursor = prevCursor;
|
|
517
|
+
hydration.parents = prevParents;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
function runWithoutHydration(fn) {
|
|
521
|
+
if (!hydration.active) return fn();
|
|
522
|
+
const prevCursor = hydration.cursor;
|
|
523
|
+
const prevParents = hydration.parents;
|
|
524
|
+
hydration.active = false;
|
|
525
|
+
hydration.parents = [];
|
|
526
|
+
try {
|
|
527
|
+
return fn();
|
|
528
|
+
} finally {
|
|
529
|
+
hydration.active = true;
|
|
530
|
+
hydration.cursor = prevCursor;
|
|
531
|
+
hydration.parents = prevParents;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
function hydrateAdvancePast(rendered) {
|
|
535
|
+
if (!hydration.active || rendered == null) return;
|
|
536
|
+
const last = Array.isArray(rendered) ? rendered[rendered.length - 1] : rendered;
|
|
537
|
+
if (last && typeof last.nodeType === "number") {
|
|
538
|
+
ascendPast(last);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// src/lib/dom/runtime.ts
|
|
543
|
+
function getElementFingerprint(el) {
|
|
544
|
+
const parts = [];
|
|
545
|
+
while (el && el.nodeType === 1) {
|
|
546
|
+
let part = el.tagName.toLowerCase();
|
|
547
|
+
if (el.id) {
|
|
548
|
+
part += `#${el.id}`;
|
|
549
|
+
parts.unshift(part);
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
if (el.getAttribute("data-id")) {
|
|
553
|
+
part += `[data-id="${el.getAttribute("data-id")}"]`;
|
|
554
|
+
}
|
|
555
|
+
let index = 0;
|
|
556
|
+
let sibling = el;
|
|
557
|
+
while (sibling = sibling.previousElementSibling) {
|
|
558
|
+
if (sibling.tagName === el.tagName) index++;
|
|
559
|
+
}
|
|
560
|
+
part += `:nth-of-type(${index + 1})`;
|
|
561
|
+
parts.unshift(part);
|
|
562
|
+
el = el.parentElement;
|
|
563
|
+
}
|
|
564
|
+
return parts.join(">");
|
|
565
|
+
}
|
|
566
|
+
function hashString(str) {
|
|
567
|
+
let hash = 0;
|
|
568
|
+
for (let i = 0; i < str.length; i++) {
|
|
569
|
+
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
570
|
+
hash |= 0;
|
|
571
|
+
}
|
|
572
|
+
return `el_${Math.abs(hash)}`;
|
|
573
|
+
}
|
|
574
|
+
function getStableElementId(el) {
|
|
575
|
+
return hashString(getElementFingerprint(el));
|
|
576
|
+
}
|
|
577
|
+
var generateID = () => {
|
|
578
|
+
return "xxyxxxxxxy-4xx8".replace(/[xy]/g, function(c) {
|
|
579
|
+
let r = Math.random() * 16 | 0;
|
|
580
|
+
let v = c === "x" ? r : r & 3 | 8;
|
|
581
|
+
return v.toString(16);
|
|
582
|
+
});
|
|
583
|
+
};
|
|
584
|
+
var EMPTY_OBJ = {};
|
|
585
|
+
var HOLE_TAG = "__fx_at";
|
|
586
|
+
var LOC_TAG = "__fx_loc";
|
|
587
|
+
function located(element, at) {
|
|
588
|
+
if (at) element[LOC_TAG] = at;
|
|
589
|
+
return element;
|
|
590
|
+
}
|
|
591
|
+
var templateCache = /* @__PURE__ */ new Map();
|
|
592
|
+
var delegatedSet = /* @__PURE__ */ new Set();
|
|
593
|
+
var NON_DELEGATED = /* @__PURE__ */ new Set(["scroll", "focus", "blur", "load", "error", "resize", "mouseenter", "mouseleave", "pointerenter", "pointerleave", "gotpointercapture", "lostpointercapture"]);
|
|
594
|
+
function delegateEvents(eventNames) {
|
|
595
|
+
if (isServer()) return;
|
|
596
|
+
for (const name of eventNames) {
|
|
597
|
+
if (delegatedSet.has(name) || NON_DELEGATED.has(name)) continue;
|
|
598
|
+
delegatedSet.add(name);
|
|
599
|
+
document.addEventListener(name, delegatedEventHandler);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
function delegatedEventHandler(e) {
|
|
603
|
+
const key = `$$${e.type}`;
|
|
604
|
+
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
605
|
+
while (node) {
|
|
606
|
+
const handler = node[key];
|
|
607
|
+
if (handler && !node.disabled) {
|
|
608
|
+
handler(e);
|
|
609
|
+
if (e.cancelBubble) return;
|
|
610
|
+
}
|
|
611
|
+
node = node.host && node.host !== node && node.host instanceof Element ? node.host : node.parentNode;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
function addDelegatedEventListener(element, name, handler) {
|
|
615
|
+
element[`$$${name}`] = handler;
|
|
616
|
+
if (NON_DELEGATED.has(name)) {
|
|
617
|
+
const key = `__fx_${name}`;
|
|
618
|
+
if (!element[key]) {
|
|
619
|
+
const forwarder = (e) => {
|
|
620
|
+
element[`$$${name}`]?.(e);
|
|
621
|
+
};
|
|
622
|
+
element.addEventListener(name, forwarder);
|
|
623
|
+
element[key] = forwarder;
|
|
624
|
+
}
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (!delegatedSet.has(name)) {
|
|
628
|
+
delegateEvents([name]);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
function removeDelegatedEventListener(element, name) {
|
|
632
|
+
delete element[`$$${name}`];
|
|
633
|
+
const key = `__fx_${name}`;
|
|
634
|
+
const forwarder = element[key];
|
|
635
|
+
if (forwarder) {
|
|
636
|
+
element.removeEventListener(name, forwarder);
|
|
637
|
+
delete element[key];
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
function isDelegatedEvent(name) {
|
|
641
|
+
return !NON_DELEGATED.has(name);
|
|
642
|
+
}
|
|
643
|
+
function isFunction(value) {
|
|
644
|
+
return typeof value === "function";
|
|
645
|
+
}
|
|
646
|
+
function createTextNode(value, anchor = false) {
|
|
647
|
+
if (isServer()) return getServerNodes().createText(value);
|
|
648
|
+
if (hydration.active && !anchor) {
|
|
649
|
+
const node = getHydrationWalker()?.hydrateText(value);
|
|
650
|
+
if (node) return node;
|
|
651
|
+
}
|
|
652
|
+
return document.createTextNode(value);
|
|
653
|
+
}
|
|
654
|
+
function createNativeElement(tag, isSVG = false, at) {
|
|
655
|
+
if (isServer()) return getServerNodes().createElement(tag, isSVG);
|
|
656
|
+
if (hydration.active) {
|
|
657
|
+
const node = getHydrationWalker()?.hydrateElement(tag);
|
|
658
|
+
if (node) return at ? located(node, at) : node;
|
|
659
|
+
}
|
|
660
|
+
return located(
|
|
661
|
+
isSVG ? document.createElementNS(SVG_NAMESPACE, tag) : document.createElement(tag),
|
|
662
|
+
at
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
function createTemplate(html2, isSVG = false) {
|
|
666
|
+
const cached = templateCache.get(html2);
|
|
667
|
+
if (cached) return cached;
|
|
668
|
+
const template = document.createElement("template");
|
|
669
|
+
if (isSVG) {
|
|
670
|
+
template.innerHTML = `<svg>${html2}</svg>`;
|
|
671
|
+
} else {
|
|
672
|
+
template.innerHTML = html2;
|
|
673
|
+
}
|
|
674
|
+
templateCache.set(html2, template);
|
|
675
|
+
return template;
|
|
676
|
+
}
|
|
677
|
+
function templateNode(html2, tag, holes = false, isSVG = false, at) {
|
|
678
|
+
if (isServer()) {
|
|
679
|
+
const nodes = getServerNodes();
|
|
680
|
+
return holes ? nodes.parseTemplate(html2, isSVG) : nodes.createRaw(html2);
|
|
681
|
+
}
|
|
682
|
+
if (hydration.active) {
|
|
683
|
+
const node = getHydrationWalker()?.hydrateStatic(tag);
|
|
684
|
+
if (node) return stampPositions(node, at);
|
|
685
|
+
}
|
|
686
|
+
return stampPositions(cloneTemplate(createTemplate(html2, isSVG), isSVG).firstChild, at);
|
|
687
|
+
}
|
|
688
|
+
function stampPositions(node, at) {
|
|
689
|
+
const root = node;
|
|
690
|
+
if (!at || typeof root?.querySelectorAll !== "function") return node;
|
|
691
|
+
const all = [root, ...root.querySelectorAll("*")];
|
|
692
|
+
for (let i = 0; i < all.length && i * 2 + 1 < at.pos.length; i++) {
|
|
693
|
+
const line = at.pos[i * 2];
|
|
694
|
+
if (line) all[i][LOC_TAG] = { file: at.file, line, column: at.pos[i * 2 + 1] };
|
|
695
|
+
}
|
|
696
|
+
return node;
|
|
697
|
+
}
|
|
698
|
+
function holeScope(start, produce) {
|
|
699
|
+
if (!hydration.active) return produce();
|
|
700
|
+
const value = runHydrationAt(start.nextSibling, produce);
|
|
701
|
+
if (typeof value === "function") {
|
|
702
|
+
const accessor = value;
|
|
703
|
+
const wrapped = (...args) => hydration.active ? runHydrationAt(start.nextSibling, () => accessor(...args)) : accessor(...args);
|
|
704
|
+
return carryHoleTag(accessor, wrapped);
|
|
705
|
+
}
|
|
706
|
+
return value;
|
|
707
|
+
}
|
|
708
|
+
function carryHoleTag(from, to) {
|
|
709
|
+
const tag = from[HOLE_TAG];
|
|
710
|
+
if (tag !== void 0) to[HOLE_TAG] = tag;
|
|
711
|
+
return to;
|
|
712
|
+
}
|
|
713
|
+
function holeEnd(start) {
|
|
714
|
+
for (let n = start.nextSibling; n; n = n.nextSibling) {
|
|
715
|
+
if (n.nodeType === 8 && n.data === "fx/") return n;
|
|
716
|
+
}
|
|
717
|
+
throw new Error("[fluixi] template hole is missing its closing marker");
|
|
718
|
+
}
|
|
719
|
+
function holeContent(start, end) {
|
|
720
|
+
const nodes = [];
|
|
721
|
+
for (let n = start.nextSibling; n && n !== end; n = n.nextSibling) nodes.push(n);
|
|
722
|
+
return nodes;
|
|
723
|
+
}
|
|
724
|
+
function cloneTemplate(template, isSVG = false) {
|
|
725
|
+
const clone = template.content.cloneNode(true);
|
|
726
|
+
if (isSVG) return clone.firstChild;
|
|
727
|
+
return clone;
|
|
728
|
+
}
|
|
729
|
+
function makeArrayFlat(values) {
|
|
730
|
+
if (!Array.isArray(values)) return values;
|
|
731
|
+
if (values.length === 2 && values[1] === " ") {
|
|
732
|
+
if (Array.isArray(values[0])) return makeArrayFlat(values[0]);
|
|
733
|
+
if (typeof values[0] === "function") return values[0];
|
|
734
|
+
return values[0];
|
|
735
|
+
}
|
|
736
|
+
if (values.length === 1 && typeof values[0] === "function") return values[0];
|
|
737
|
+
return values;
|
|
738
|
+
}
|
|
739
|
+
function fnName(fn) {
|
|
740
|
+
if (typeof fn !== "function") return null;
|
|
741
|
+
return fn._name || fn.name || "anonymous";
|
|
742
|
+
}
|
|
743
|
+
function iterateFn(item) {
|
|
744
|
+
if (isSignal(item)) return item;
|
|
745
|
+
if (isComponent(item)) return item;
|
|
746
|
+
if (typeof item !== "function") return item;
|
|
747
|
+
let content = item();
|
|
748
|
+
while (typeof content === "function" && !isSignal(content) && !isComponent(content)) {
|
|
749
|
+
content = content();
|
|
750
|
+
}
|
|
751
|
+
return content;
|
|
752
|
+
}
|
|
753
|
+
var _insertDepth = 0;
|
|
754
|
+
var MAX_INSERT_DEPTH = 200;
|
|
755
|
+
function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
|
|
756
|
+
let current = initialCurrent;
|
|
757
|
+
const componentCache = /* @__PURE__ */ new Map();
|
|
758
|
+
return createRenderEffect(() => {
|
|
759
|
+
reportReactiveBinding(marker ?? parent, "content", void 0, getAccessor);
|
|
760
|
+
let value;
|
|
761
|
+
if (isComponent(getAccessor) && !isSignal(getAccessor)) {
|
|
762
|
+
if (!componentCache.has(getAccessor)) {
|
|
763
|
+
_insertDepth++;
|
|
764
|
+
try {
|
|
765
|
+
const inst = getAccessor();
|
|
766
|
+
componentCache.set(getAccessor, inst);
|
|
767
|
+
} finally {
|
|
768
|
+
_insertDepth--;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
value = componentCache.get(getAccessor);
|
|
772
|
+
while (typeof value === "function" && isSignal(value)) value = value();
|
|
773
|
+
} else {
|
|
774
|
+
value = getAccessor();
|
|
775
|
+
while (typeof value === "function" && isSignal(value)) {
|
|
776
|
+
value = value();
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
{
|
|
780
|
+
let chainDepth = 0;
|
|
781
|
+
while (typeof value === "function" && chainDepth++ < 50) {
|
|
782
|
+
if (isComponent(value)) {
|
|
783
|
+
if (!componentCache.has(value)) {
|
|
784
|
+
const thunk = value;
|
|
785
|
+
_insertDepth++;
|
|
786
|
+
try {
|
|
787
|
+
const inst = thunk();
|
|
788
|
+
componentCache.set(thunk, inst);
|
|
789
|
+
} finally {
|
|
790
|
+
_insertDepth--;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
value = componentCache.get(value);
|
|
794
|
+
} else if (isSignal(value)) {
|
|
795
|
+
value = value();
|
|
796
|
+
} else {
|
|
797
|
+
value = value();
|
|
798
|
+
if (typeof value !== "function" || !isSignal(value) && !isComponent(value)) break;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
_insertDepth++;
|
|
803
|
+
try {
|
|
804
|
+
current = insertExpression(parent, value, marker, current, componentCache);
|
|
805
|
+
setCurrent(current);
|
|
806
|
+
} finally {
|
|
807
|
+
_insertDepth--;
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
function insert(parent, accessor, marker, init) {
|
|
812
|
+
if (_insertDepth > MAX_INSERT_DEPTH) {
|
|
813
|
+
console.error("[insert] Exceeded max call depth, possible infinite loop.");
|
|
814
|
+
return () => null;
|
|
815
|
+
}
|
|
816
|
+
if (marker !== void 0 && !marker) {
|
|
817
|
+
marker = createTextNode("", true);
|
|
818
|
+
parent.appendChild(marker);
|
|
819
|
+
}
|
|
820
|
+
let current = init ?? null;
|
|
821
|
+
const isReactiveArray = (element) => {
|
|
822
|
+
return Array.isArray(element) && element.some((v) => typeof v === "function");
|
|
823
|
+
};
|
|
824
|
+
const normalizeAccessor3 = (accessor2) => {
|
|
825
|
+
if (typeof accessor2 === "function") return accessor2;
|
|
826
|
+
return () => accessor2;
|
|
827
|
+
};
|
|
828
|
+
if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
|
|
829
|
+
_insertDepth++;
|
|
830
|
+
try {
|
|
831
|
+
current = insertExpression(parent, accessor, marker, current);
|
|
832
|
+
} finally {
|
|
833
|
+
_insertDepth--;
|
|
834
|
+
}
|
|
835
|
+
return () => current;
|
|
836
|
+
}
|
|
837
|
+
const dispose = _createInsertEffect(
|
|
838
|
+
normalizeAccessor3(accessor),
|
|
839
|
+
parent,
|
|
840
|
+
marker,
|
|
841
|
+
current,
|
|
842
|
+
(v) => {
|
|
843
|
+
current = v;
|
|
844
|
+
}
|
|
845
|
+
);
|
|
846
|
+
return () => {
|
|
847
|
+
dispose?.();
|
|
848
|
+
return current;
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
function insertExpression(parent, value, marker, current, componentCache) {
|
|
852
|
+
if (value == null || typeof value === "boolean") {
|
|
853
|
+
return cleanChildren(parent, current, marker);
|
|
854
|
+
}
|
|
855
|
+
if (typeof value === "function") {
|
|
856
|
+
while (typeof value === "function") {
|
|
857
|
+
value = value();
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
if (value == null || typeof value === "boolean") {
|
|
861
|
+
return cleanChildren(parent, current, marker);
|
|
862
|
+
}
|
|
863
|
+
if (isPromise(value)) {
|
|
864
|
+
const placeholder = createTextNode("", true);
|
|
865
|
+
if (Array.isArray(current)) {
|
|
866
|
+
if (current.length > 0) {
|
|
867
|
+
parent.replaceChild(placeholder, current[0]);
|
|
868
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
869
|
+
} else {
|
|
870
|
+
insertBefore(parent, placeholder, marker);
|
|
871
|
+
}
|
|
872
|
+
} else if (current) {
|
|
873
|
+
parent.replaceChild(placeholder, current);
|
|
874
|
+
} else {
|
|
875
|
+
insertBefore(parent, placeholder, marker);
|
|
876
|
+
}
|
|
877
|
+
value.then((resolved) => {
|
|
878
|
+
if (placeholder.parentNode === parent) {
|
|
879
|
+
insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
|
|
880
|
+
}
|
|
881
|
+
}).catch((err) => {
|
|
882
|
+
console.error("Error resolving promise in insertExpression:", err);
|
|
883
|
+
});
|
|
884
|
+
return placeholder;
|
|
885
|
+
}
|
|
886
|
+
const t = typeof value;
|
|
887
|
+
if (t === "string" || t === "number") {
|
|
888
|
+
if (t === "number") value = String(value);
|
|
889
|
+
if (Array.isArray(current)) {
|
|
890
|
+
if (current.length === 0) {
|
|
891
|
+
const node2 = createTextNode(value);
|
|
892
|
+
insertBefore(parent, node2, marker);
|
|
893
|
+
return node2;
|
|
894
|
+
}
|
|
895
|
+
if (current.length === 1 && current[0].nodeType === 3) {
|
|
896
|
+
current[0].data = value;
|
|
897
|
+
return current;
|
|
898
|
+
}
|
|
899
|
+
current = cleanChildren(parent, current, marker);
|
|
900
|
+
}
|
|
901
|
+
if (current && isDomText(current)) {
|
|
902
|
+
current.data = value;
|
|
903
|
+
return current;
|
|
904
|
+
}
|
|
905
|
+
const node = createTextNode(value);
|
|
906
|
+
if (current && current.parentNode === parent) {
|
|
907
|
+
parent.replaceChild(node, current);
|
|
908
|
+
} else if (!isAdopted(parent, node)) {
|
|
909
|
+
insertBefore(parent, node, marker);
|
|
910
|
+
}
|
|
911
|
+
return node;
|
|
912
|
+
}
|
|
913
|
+
if (isDomNode(value)) {
|
|
914
|
+
if (isAdopted(parent, value)) {
|
|
915
|
+
ascendPast(value);
|
|
916
|
+
return value;
|
|
917
|
+
}
|
|
918
|
+
if (Array.isArray(current)) {
|
|
919
|
+
if (current.length === 0) {
|
|
920
|
+
insertBefore(parent, value, marker);
|
|
921
|
+
} else if (current[0].parentNode === parent) {
|
|
922
|
+
parent.replaceChild(value, current[0]);
|
|
923
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
924
|
+
} else {
|
|
925
|
+
insertBefore(parent, value, marker);
|
|
926
|
+
}
|
|
927
|
+
return value;
|
|
928
|
+
}
|
|
929
|
+
if (!current) {
|
|
930
|
+
insertBefore(parent, value, marker);
|
|
931
|
+
} else if (current !== value) {
|
|
932
|
+
if (current.parentNode === parent) {
|
|
933
|
+
parent.replaceChild(value, current);
|
|
934
|
+
} else {
|
|
935
|
+
insertBefore(parent, value, marker);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
return value;
|
|
939
|
+
}
|
|
940
|
+
if (Array.isArray(value)) {
|
|
941
|
+
const array = [];
|
|
942
|
+
const currentArray = Array.isArray(current) ? current : current ? [current] : [];
|
|
943
|
+
const reactiveSlots = [];
|
|
944
|
+
flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
|
|
945
|
+
const reconciled = reconcileArrays(parent, currentArray, array, marker);
|
|
946
|
+
for (const slot of reactiveSlots) {
|
|
947
|
+
const disposeSlot = insert(parent, slot.sig, slot.marker);
|
|
948
|
+
onCleanup(() => {
|
|
949
|
+
cleanChildren(parent, disposeSlot());
|
|
950
|
+
if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
return reconciled;
|
|
954
|
+
}
|
|
955
|
+
if (t === "object" && value !== null && typeof value === "object") {
|
|
956
|
+
const objValue = value;
|
|
957
|
+
if ("type" in objValue && "props" in objValue) {
|
|
958
|
+
const jsxValue = objValue;
|
|
959
|
+
if (typeof jsxValue.type === "function") {
|
|
960
|
+
const result = jsxValue.type(jsxValue.props || {});
|
|
961
|
+
return insertExpression(parent, result, marker, current);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return cleanChildren(parent, current, marker);
|
|
966
|
+
}
|
|
967
|
+
function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
|
|
968
|
+
for (let i = 0; i < arr.length; i++) {
|
|
969
|
+
let item = arr[i];
|
|
970
|
+
if (item == null || typeof item === "boolean") continue;
|
|
971
|
+
while (typeof item === "function" && !isPromise(item) && !isSignal(item) && !isComponent(item)) {
|
|
972
|
+
item = item();
|
|
973
|
+
if (item == null || typeof item === "boolean") break;
|
|
974
|
+
}
|
|
975
|
+
if (item == null || typeof item === "boolean") continue;
|
|
976
|
+
if (typeof item === "function") {
|
|
977
|
+
let resolved;
|
|
978
|
+
if (isComponent(item) && !isSignal(item)) {
|
|
979
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
980
|
+
if (!componentCache.has(item)) componentCache.set(item, item());
|
|
981
|
+
resolved = componentCache.get(item);
|
|
982
|
+
} else {
|
|
983
|
+
resolved = item();
|
|
984
|
+
}
|
|
985
|
+
while (typeof resolved === "function" && !isPromise(resolved) && !isSignal(resolved) && !isComponent(resolved)) {
|
|
986
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
987
|
+
if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
|
|
988
|
+
resolved = componentCache.get(resolved);
|
|
989
|
+
}
|
|
990
|
+
if (resolved == null || typeof resolved === "boolean") continue;
|
|
991
|
+
if (typeof resolved === "function") {
|
|
992
|
+
if (isSignal(resolved)) {
|
|
993
|
+
if (reactiveSlots) {
|
|
994
|
+
const slot = createTextNode("", true);
|
|
995
|
+
result.push(slot);
|
|
996
|
+
reactiveSlots.push({ marker: slot, sig: resolved });
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
999
|
+
let val = resolved();
|
|
1000
|
+
while (typeof val === "function" && isSignal(val)) val = val();
|
|
1001
|
+
if (val == null || typeof val === "boolean") continue;
|
|
1002
|
+
if (Array.isArray(val)) {
|
|
1003
|
+
flattenArray(val, result, parent, marker, track, componentCache);
|
|
1004
|
+
} else flattenArray([val], result, parent, marker, track, componentCache);
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
1007
|
+
continue;
|
|
1008
|
+
}
|
|
1009
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
|
|
1010
|
+
else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
|
|
1011
|
+
continue;
|
|
1012
|
+
}
|
|
1013
|
+
if (isPromise(item)) {
|
|
1014
|
+
const placeholder = createTextNode("", true);
|
|
1015
|
+
result.push(placeholder);
|
|
1016
|
+
item.then((resolved) => {
|
|
1017
|
+
if (placeholder.parentNode) {
|
|
1018
|
+
const tempNodes = [];
|
|
1019
|
+
flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
|
|
1020
|
+
if (tempNodes.length > 0) {
|
|
1021
|
+
placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
|
|
1022
|
+
for (let j = 1; j < tempNodes.length; j++) {
|
|
1023
|
+
placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}).catch((err) => console.error("Error resolving promise in array:", err));
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
if (Array.isArray(item)) {
|
|
1031
|
+
flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
|
|
1032
|
+
continue;
|
|
1033
|
+
}
|
|
1034
|
+
if (isDomNode(item)) {
|
|
1035
|
+
result.push(item);
|
|
1036
|
+
continue;
|
|
1037
|
+
}
|
|
1038
|
+
if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
|
|
1039
|
+
const jsxItem = item;
|
|
1040
|
+
if (typeof jsxItem.type === "function") {
|
|
1041
|
+
const resolved = jsxItem.type(jsxItem.props || {});
|
|
1042
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
|
|
1043
|
+
else flattenArray([resolved], result, parent, marker, false, componentCache);
|
|
1044
|
+
continue;
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
1048
|
+
const str = String(item);
|
|
1049
|
+
if (str.trim() === "" && str !== " ") continue;
|
|
1050
|
+
result.push(createTextNode(str));
|
|
1051
|
+
continue;
|
|
1052
|
+
}
|
|
1053
|
+
result.push(createTextNode(String(item)));
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
function reconcileArrays(parent, a, b, marker) {
|
|
1057
|
+
for (let i = 0; i < b.length; i++) {
|
|
1058
|
+
const owner = b[i].parentNode;
|
|
1059
|
+
if (owner !== null && owner !== parent && owner.nodeType !== 11) {
|
|
1060
|
+
b = b.slice();
|
|
1061
|
+
b[i] = b[i].cloneNode(true);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = aEnd > 0 ? a[aEnd - 1].nextSibling ?? void 0 : marker, map = null;
|
|
1065
|
+
while (aStart < aEnd || bStart < bEnd) {
|
|
1066
|
+
if (a[aStart] === b[bStart]) {
|
|
1067
|
+
aStart++;
|
|
1068
|
+
bStart++;
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
|
|
1072
|
+
aEnd--;
|
|
1073
|
+
bEnd--;
|
|
1074
|
+
}
|
|
1075
|
+
if (aEnd === aStart) {
|
|
1076
|
+
const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
|
|
1077
|
+
while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
|
|
1078
|
+
} else if (bEnd === bStart) {
|
|
1079
|
+
while (aStart < aEnd) {
|
|
1080
|
+
if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
|
|
1081
|
+
parent.removeChild(a[aStart]);
|
|
1082
|
+
aStart++;
|
|
1083
|
+
}
|
|
1084
|
+
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
1085
|
+
const node = a[--aEnd].nextSibling;
|
|
1086
|
+
insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
|
|
1087
|
+
insertBefore(parent, b[--bEnd], node);
|
|
1088
|
+
a[aEnd] = a[aStart - 1];
|
|
1089
|
+
} else {
|
|
1090
|
+
if (!map) {
|
|
1091
|
+
map = /* @__PURE__ */ new Map();
|
|
1092
|
+
let i = bStart;
|
|
1093
|
+
while (i < bEnd) map.set(b[i], i++);
|
|
1094
|
+
}
|
|
1095
|
+
const index = map.get(a[aStart]);
|
|
1096
|
+
if (index != null) {
|
|
1097
|
+
if (bStart < index && index < bEnd) {
|
|
1098
|
+
let i = aStart, sequence = 1;
|
|
1099
|
+
while (++i < aEnd && i < bEnd) {
|
|
1100
|
+
if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
|
|
1101
|
+
sequence++;
|
|
1102
|
+
}
|
|
1103
|
+
if (sequence > index - bStart) {
|
|
1104
|
+
const node = a[aStart];
|
|
1105
|
+
while (bStart < index) insertBefore(parent, b[bStart++], node);
|
|
1106
|
+
} else {
|
|
1107
|
+
if (a[aStart].parentNode === parent) {
|
|
1108
|
+
parent.replaceChild(b[bStart++], a[aStart++]);
|
|
1109
|
+
} else {
|
|
1110
|
+
insertBefore(parent, b[bStart++], after);
|
|
1111
|
+
aStart++;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
} else {
|
|
1115
|
+
aStart++;
|
|
1116
|
+
}
|
|
1117
|
+
} else {
|
|
1118
|
+
if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
|
|
1119
|
+
aStart++;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
return b;
|
|
1124
|
+
}
|
|
1125
|
+
function cleanChildren(parent, current, marker) {
|
|
1126
|
+
if (current) {
|
|
1127
|
+
if (Array.isArray(current)) {
|
|
1128
|
+
for (let i = 0; i < current.length; i++) {
|
|
1129
|
+
if (current[i].parentNode === parent) parent.removeChild(current[i]);
|
|
1130
|
+
}
|
|
1131
|
+
} else if (current.parentNode === parent) {
|
|
1132
|
+
parent.removeChild(current);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
return null;
|
|
1136
|
+
}
|
|
1137
|
+
function insertBefore(parent, node, marker) {
|
|
1138
|
+
if (hydration.active && node.parentNode === parent) return;
|
|
1139
|
+
if (marker) {
|
|
1140
|
+
if (marker.parentNode === parent) {
|
|
1141
|
+
parent.insertBefore(node, marker);
|
|
1142
|
+
} else {
|
|
1143
|
+
parent.appendChild(node);
|
|
1144
|
+
}
|
|
1145
|
+
} else {
|
|
1146
|
+
parent.appendChild(node);
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
function setProperty(element, name, value) {
|
|
1150
|
+
if (value == null) delete element[name];
|
|
1151
|
+
else element[name] = value;
|
|
1152
|
+
}
|
|
1153
|
+
function addNativeEventListener(element, name, value) {
|
|
1154
|
+
let handler = value;
|
|
1155
|
+
let options;
|
|
1156
|
+
if (Array.isArray(value)) {
|
|
1157
|
+
handler = value[0];
|
|
1158
|
+
options = value[1];
|
|
1159
|
+
}
|
|
1160
|
+
if (typeof handler !== "function") return () => {
|
|
1161
|
+
};
|
|
1162
|
+
element.addEventListener(name, handler, options);
|
|
1163
|
+
return () => element.removeEventListener(name, handler, options);
|
|
1164
|
+
}
|
|
1165
|
+
function reportMarked(element, accessor) {
|
|
1166
|
+
if (!accessor || typeof accessor !== "function") return;
|
|
1167
|
+
const written = accessor[HOLE_TAG]?.name;
|
|
1168
|
+
if (!written) return;
|
|
1169
|
+
const colon = written.indexOf(":");
|
|
1170
|
+
if (colon === -1) return;
|
|
1171
|
+
reportReactiveDirective(element, written.slice(0, colon), written.slice(colon + 1), accessor);
|
|
1172
|
+
}
|
|
1173
|
+
function reportKeys(element, kind, value) {
|
|
1174
|
+
const from = typeof value === "function" ? untrack(() => value()) : value;
|
|
1175
|
+
if (!from || typeof from !== "object") return;
|
|
1176
|
+
for (const key of Object.keys(from)) reportReactiveDirective(element, kind, key);
|
|
1177
|
+
}
|
|
1178
|
+
function applyUse(element, value) {
|
|
1179
|
+
const call = (dir, accessor) => {
|
|
1180
|
+
if (typeof dir !== "function") return;
|
|
1181
|
+
reportReactiveDirective(element, "use", dir.name || "use", accessor);
|
|
1182
|
+
dir(element, accessor ?? (() => void 0));
|
|
1183
|
+
};
|
|
1184
|
+
if (typeof value === "function") {
|
|
1185
|
+
call(value);
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
if (!Array.isArray(value)) return;
|
|
1189
|
+
if (typeof value[0] === "function") {
|
|
1190
|
+
call(value[0], value[1]);
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
for (const pair of value) {
|
|
1194
|
+
if (Array.isArray(pair)) call(pair[0], pair[1]);
|
|
1195
|
+
else call(pair);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
function setDynamicAttribute(element, name, accessor, isSVG = false) {
|
|
1199
|
+
reportMarked(element, accessor);
|
|
1200
|
+
if (typeof accessor !== "function") {
|
|
1201
|
+
setAttribute(element, name, accessor, isSVG);
|
|
1202
|
+
return () => {
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
return createRenderEffect(() => {
|
|
1206
|
+
reportReactiveBinding(element, "attribute", name, accessor);
|
|
1207
|
+
const value = typeof accessor === "function" ? accessor() : accessor;
|
|
1208
|
+
setAttribute(element, name, value, isSVG);
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
function setDynamicProperty(element, name, accessor) {
|
|
1212
|
+
if (typeof accessor !== "function") {
|
|
1213
|
+
setProperty(element, name, accessor);
|
|
1214
|
+
return () => {
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
reportMarked(element, accessor);
|
|
1218
|
+
return createRenderEffect(() => {
|
|
1219
|
+
reportReactiveBinding(element, "property", name, accessor);
|
|
1220
|
+
const value = typeof accessor === "function" ? accessor() : accessor;
|
|
1221
|
+
setProperty(element, name, value);
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
function setDynamicBoolAttribute(element, name, accessor) {
|
|
1225
|
+
if (typeof accessor !== "function") {
|
|
1226
|
+
setAttribute(element, name, !!accessor);
|
|
1227
|
+
return () => {
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
return createRenderEffect(() => {
|
|
1231
|
+
reportReactiveBinding(element, "attribute", name, accessor);
|
|
1232
|
+
const value = accessor();
|
|
1233
|
+
setAttribute(element, name, !!value);
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
function setClassName(element, value) {
|
|
1237
|
+
if (value == null) {
|
|
1238
|
+
element.removeAttribute("class");
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
if (typeof value === "function") {
|
|
1242
|
+
createRenderEffect(() => {
|
|
1243
|
+
reportReactiveBinding(element, "attribute", "class", value);
|
|
1244
|
+
setClassName(element, value());
|
|
1245
|
+
});
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
if (typeof value === "string") {
|
|
1249
|
+
element.setAttribute("class", value);
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
if (Array.isArray(value)) {
|
|
1253
|
+
element.setAttribute("class", value.filter(Boolean).join(" "));
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
if (typeof value === "object") {
|
|
1257
|
+
const classes = Object.keys(value).filter((key) => {
|
|
1258
|
+
const v = value[key];
|
|
1259
|
+
return typeof v === "function" ? v() : Boolean(v);
|
|
1260
|
+
}).join(" ");
|
|
1261
|
+
element.setAttribute("class", classes);
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
element.setAttribute("class", String(value));
|
|
1265
|
+
}
|
|
1266
|
+
function setClassList(element, value, disposers) {
|
|
1267
|
+
if (!value || typeof value !== "object") return;
|
|
1268
|
+
for (const name in value) {
|
|
1269
|
+
const cond = value[name];
|
|
1270
|
+
const names = name.split(/\s+/).filter(Boolean);
|
|
1271
|
+
if (typeof cond === "function" && disposers) {
|
|
1272
|
+
disposers.push(
|
|
1273
|
+
createRenderEffect(() => {
|
|
1274
|
+
const on = !!cond();
|
|
1275
|
+
for (const n of names) element.classList.toggle(n, on);
|
|
1276
|
+
})
|
|
1277
|
+
);
|
|
1278
|
+
} else {
|
|
1279
|
+
const on = !!(typeof cond === "function" ? cond() : cond);
|
|
1280
|
+
for (const n of names) element.classList.toggle(n, on);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
function setStyle(element, _value) {
|
|
1285
|
+
let value = _value;
|
|
1286
|
+
while (typeof value === "function") value = value();
|
|
1287
|
+
if (value == null) {
|
|
1288
|
+
element.removeAttribute("style");
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
if (typeof value === "string") {
|
|
1292
|
+
element.style.cssText = value;
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
if (typeof value === "object") {
|
|
1296
|
+
for (const key in value) {
|
|
1297
|
+
const styleValue = value[key];
|
|
1298
|
+
if (styleValue == null) element.style[key] = "";
|
|
1299
|
+
else element.style[key] = styleValue;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
function spread(options) {
|
|
1304
|
+
const {
|
|
1305
|
+
element,
|
|
1306
|
+
props,
|
|
1307
|
+
prevProps = EMPTY_OBJ,
|
|
1308
|
+
isSVG = false,
|
|
1309
|
+
skipChildren = false
|
|
1310
|
+
} = options;
|
|
1311
|
+
if (!element || !isDomElement(element)) {
|
|
1312
|
+
console.error("[spread] Error: element is not a DOM Element!");
|
|
1313
|
+
return () => {
|
|
1314
|
+
};
|
|
1315
|
+
}
|
|
1316
|
+
if (!props) {
|
|
1317
|
+
console.warn("[spread] Warning: props is undefined!");
|
|
1318
|
+
return () => {
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
const elementIsSVG = isSVG || element.namespaceURI === SVG_NAMESPACE;
|
|
1322
|
+
const disposers = [];
|
|
1323
|
+
for (const key in props) {
|
|
1324
|
+
if (skipChildren && key === "children") continue;
|
|
1325
|
+
const value = props[key];
|
|
1326
|
+
const prev = prevProps[key];
|
|
1327
|
+
if (value === prev) continue;
|
|
1328
|
+
if (key === "ref") {
|
|
1329
|
+
handleRef(value, element);
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
if (key === "use") {
|
|
1333
|
+
applyUse(element, value);
|
|
1334
|
+
continue;
|
|
1335
|
+
}
|
|
1336
|
+
if (key.startsWith("on:")) {
|
|
1337
|
+
disposers.push(addNativeEventListener(element, key.slice(3), value));
|
|
1338
|
+
continue;
|
|
1339
|
+
}
|
|
1340
|
+
if (key.startsWith("prop:")) {
|
|
1341
|
+
reportReactiveDirective(element, "prop", key.slice(5), value);
|
|
1342
|
+
disposers.push(setDynamicProperty(element, key.slice(5), value));
|
|
1343
|
+
continue;
|
|
1344
|
+
}
|
|
1345
|
+
if (key.startsWith("attr:")) {
|
|
1346
|
+
reportReactiveDirective(element, "attr", key.slice(5), value);
|
|
1347
|
+
disposers.push(setDynamicAttribute(element, key.slice(5), value, elementIsSVG));
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1350
|
+
if (key.startsWith("bool:")) {
|
|
1351
|
+
reportReactiveDirective(element, "bool", key.slice(5), value);
|
|
1352
|
+
disposers.push(setDynamicBoolAttribute(element, key.slice(5), value));
|
|
1353
|
+
continue;
|
|
1354
|
+
}
|
|
1355
|
+
if (key === "class" || key === "className") {
|
|
1356
|
+
if (typeof value === "function") {
|
|
1357
|
+
disposers.push(
|
|
1358
|
+
createRenderEffect(() => {
|
|
1359
|
+
reportReactiveBinding(element, "attribute", "class", value);
|
|
1360
|
+
setClassName(element, value());
|
|
1361
|
+
})
|
|
1362
|
+
);
|
|
1363
|
+
} else {
|
|
1364
|
+
setClassName(element, value);
|
|
1365
|
+
}
|
|
1366
|
+
continue;
|
|
1367
|
+
}
|
|
1368
|
+
if (key === "classList") {
|
|
1369
|
+
reportKeys(element, "class", value);
|
|
1370
|
+
if (typeof value === "function") {
|
|
1371
|
+
disposers.push(
|
|
1372
|
+
createRenderEffect(() => {
|
|
1373
|
+
reportReactiveBinding(element, "attribute", "class", value);
|
|
1374
|
+
setClassList(element, value());
|
|
1375
|
+
})
|
|
1376
|
+
);
|
|
1377
|
+
} else {
|
|
1378
|
+
setClassList(element, value, disposers);
|
|
1379
|
+
}
|
|
1380
|
+
continue;
|
|
1381
|
+
}
|
|
1382
|
+
if (key === "style") {
|
|
1383
|
+
reportKeys(element, "style", value);
|
|
1384
|
+
if (typeof value === "function") {
|
|
1385
|
+
disposers.push(
|
|
1386
|
+
createRenderEffect(() => {
|
|
1387
|
+
reportReactiveBinding(element, "attribute", "style", value);
|
|
1388
|
+
setStyle(element, value());
|
|
1389
|
+
})
|
|
1390
|
+
);
|
|
1391
|
+
} else {
|
|
1392
|
+
setStyle(element, value);
|
|
1393
|
+
}
|
|
1394
|
+
continue;
|
|
1395
|
+
}
|
|
1396
|
+
if (key.startsWith("on")) {
|
|
1397
|
+
const eventName = key.slice(2).toLowerCase();
|
|
1398
|
+
if (prev) removeDelegatedEventListener(element, eventName);
|
|
1399
|
+
if (value) addDelegatedEventListener(element, eventName, value);
|
|
1400
|
+
continue;
|
|
1401
|
+
}
|
|
1402
|
+
const asProperty = JSX_PROPERTIES.has(key) || !elementIsSVG && key in element;
|
|
1403
|
+
if (typeof value === "function") {
|
|
1404
|
+
disposers.push(
|
|
1405
|
+
asProperty ? setDynamicProperty(element, key, value) : setDynamicAttribute(element, key, value, elementIsSVG)
|
|
1406
|
+
);
|
|
1407
|
+
} else {
|
|
1408
|
+
disposers.push(
|
|
1409
|
+
createRenderEffect(
|
|
1410
|
+
() => asProperty ? setProperty(element, key, props[key]) : setAttribute(element, key, props[key], elementIsSVG)
|
|
1411
|
+
)
|
|
1412
|
+
);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
for (const key in prevProps) {
|
|
1416
|
+
if (!(key in props)) {
|
|
1417
|
+
if (key.startsWith("on")) {
|
|
1418
|
+
const eventName = key.slice(2).toLowerCase();
|
|
1419
|
+
removeDelegatedEventListener(element, eventName);
|
|
1420
|
+
} else if (JSX_PROPERTIES.has(key)) {
|
|
1421
|
+
setProperty(element, key, null);
|
|
1422
|
+
} else {
|
|
1423
|
+
element.removeAttribute(key);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
return () => {
|
|
1428
|
+
disposers.forEach((d) => d());
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
function applyProps(element, props, isSVG = false) {
|
|
1432
|
+
for (const key in props) {
|
|
1433
|
+
const val = props[key];
|
|
1434
|
+
if (key === "ref") {
|
|
1435
|
+
handleRef(val, element);
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
if (key === "children") continue;
|
|
1439
|
+
if (key === "use") {
|
|
1440
|
+
applyUse(element, val);
|
|
1441
|
+
continue;
|
|
1442
|
+
}
|
|
1443
|
+
if (key.startsWith("on:")) {
|
|
1444
|
+
addNativeEventListener(element, key.slice(3), val);
|
|
1445
|
+
continue;
|
|
1446
|
+
}
|
|
1447
|
+
if (key.startsWith("prop:")) {
|
|
1448
|
+
reportReactiveDirective(element, "prop", key.slice(5), val);
|
|
1449
|
+
setDynamicProperty(element, key.slice(5), val);
|
|
1450
|
+
continue;
|
|
1451
|
+
}
|
|
1452
|
+
if (key.startsWith("attr:")) {
|
|
1453
|
+
reportReactiveDirective(element, "attr", key.slice(5), val);
|
|
1454
|
+
setDynamicAttribute(element, key.slice(5), val, isSVG);
|
|
1455
|
+
continue;
|
|
1456
|
+
}
|
|
1457
|
+
if (key.startsWith("bool:")) {
|
|
1458
|
+
reportReactiveDirective(element, "bool", key.slice(5), val);
|
|
1459
|
+
setDynamicBoolAttribute(element, key.slice(5), val);
|
|
1460
|
+
continue;
|
|
1461
|
+
}
|
|
1462
|
+
if (key.startsWith("on") && key.length > 2) {
|
|
1463
|
+
const name = key.slice(2).toLowerCase();
|
|
1464
|
+
if (typeof val === "function") {
|
|
1465
|
+
if (NON_DELEGATED.has(name)) {
|
|
1466
|
+
element[`$$${name}`] = val;
|
|
1467
|
+
const listenerKey = `__fx_${name}`;
|
|
1468
|
+
if (!element[listenerKey]) {
|
|
1469
|
+
const forwarder = (e) => {
|
|
1470
|
+
element[`$$${name}`]?.(e);
|
|
1471
|
+
};
|
|
1472
|
+
element.addEventListener(name, forwarder);
|
|
1473
|
+
element[listenerKey] = forwarder;
|
|
1474
|
+
}
|
|
1475
|
+
} else {
|
|
1476
|
+
element[`$$${name}`] = val;
|
|
1477
|
+
if (!delegatedSet.has(name)) delegateEvents([name]);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
continue;
|
|
1481
|
+
}
|
|
1482
|
+
if (key === "class" || key === "className") {
|
|
1483
|
+
setClassName(element, val);
|
|
1484
|
+
continue;
|
|
1485
|
+
}
|
|
1486
|
+
if (key === "classList") {
|
|
1487
|
+
reportKeys(element, "class", val);
|
|
1488
|
+
if (typeof val === "function")
|
|
1489
|
+
createRenderEffect(() => {
|
|
1490
|
+
reportReactiveBinding(element, "attribute", "class", val);
|
|
1491
|
+
setClassList(element, val());
|
|
1492
|
+
});
|
|
1493
|
+
else setClassList(element, val);
|
|
1494
|
+
continue;
|
|
1495
|
+
}
|
|
1496
|
+
if (key === "style") {
|
|
1497
|
+
reportKeys(element, "style", val);
|
|
1498
|
+
if (typeof val === "function")
|
|
1499
|
+
createRenderEffect(() => {
|
|
1500
|
+
reportReactiveBinding(element, "attribute", "style", val);
|
|
1501
|
+
setStyle(element, val());
|
|
1502
|
+
});
|
|
1503
|
+
else setStyle(element, val);
|
|
1504
|
+
continue;
|
|
1505
|
+
}
|
|
1506
|
+
if (key === "innerHTML") {
|
|
1507
|
+
if (typeof val === "function") {
|
|
1508
|
+
const dispose = createEffect(() => {
|
|
1509
|
+
let v = val();
|
|
1510
|
+
while (typeof v === "function") v = v();
|
|
1511
|
+
element.innerHTML = v;
|
|
1512
|
+
});
|
|
1513
|
+
onCleanup(() => dispose());
|
|
1514
|
+
} else {
|
|
1515
|
+
element.innerHTML = val;
|
|
1516
|
+
}
|
|
1517
|
+
continue;
|
|
1518
|
+
}
|
|
1519
|
+
if (key === "value" && (element.tagName === "INPUT" || element.tagName === "TEXTAREA")) {
|
|
1520
|
+
if (typeof val === "function") {
|
|
1521
|
+
const dispose = createEffect(() => {
|
|
1522
|
+
let v = val();
|
|
1523
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1524
|
+
if (document.activeElement !== element) {
|
|
1525
|
+
element.value = v ?? "";
|
|
1526
|
+
}
|
|
1527
|
+
});
|
|
1528
|
+
onCleanup(() => {
|
|
1529
|
+
dispose();
|
|
1530
|
+
});
|
|
1531
|
+
} else {
|
|
1532
|
+
createRenderEffect(() => {
|
|
1533
|
+
if (document.activeElement !== element) {
|
|
1534
|
+
element.value = props[key] ?? "";
|
|
1535
|
+
}
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
continue;
|
|
1539
|
+
}
|
|
1540
|
+
if (key === "checked" && element.tagName === "INPUT") {
|
|
1541
|
+
if (typeof val === "function") {
|
|
1542
|
+
const dispose = createEffect(() => {
|
|
1543
|
+
let v = val();
|
|
1544
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1545
|
+
if (document.activeElement !== element) {
|
|
1546
|
+
element.checked = v ?? "";
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1549
|
+
onCleanup(() => {
|
|
1550
|
+
dispose();
|
|
1551
|
+
});
|
|
1552
|
+
} else {
|
|
1553
|
+
createRenderEffect(() => {
|
|
1554
|
+
if (document.activeElement !== element) {
|
|
1555
|
+
element.checked = props[key] ?? "";
|
|
1556
|
+
}
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
continue;
|
|
1560
|
+
}
|
|
1561
|
+
if (key === "value" && element.tagName === "SELECT") {
|
|
1562
|
+
if (typeof val === "function") {
|
|
1563
|
+
let firstRun = true;
|
|
1564
|
+
const dispose = createEffect(() => {
|
|
1565
|
+
let v = val();
|
|
1566
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1567
|
+
if (firstRun) {
|
|
1568
|
+
firstRun = false;
|
|
1569
|
+
queueMicrotask(() => {
|
|
1570
|
+
element.value = v ?? "";
|
|
1571
|
+
});
|
|
1572
|
+
} else {
|
|
1573
|
+
element.value = v ?? "";
|
|
1574
|
+
}
|
|
1575
|
+
});
|
|
1576
|
+
onCleanup(() => {
|
|
1577
|
+
dispose();
|
|
1578
|
+
});
|
|
1579
|
+
} else {
|
|
1580
|
+
let firstRun = true;
|
|
1581
|
+
createRenderEffect(() => {
|
|
1582
|
+
const v = props[key];
|
|
1583
|
+
if (firstRun) {
|
|
1584
|
+
firstRun = false;
|
|
1585
|
+
queueMicrotask(() => {
|
|
1586
|
+
element.value = v ?? "";
|
|
1587
|
+
});
|
|
1588
|
+
} else {
|
|
1589
|
+
element.value = v ?? "";
|
|
1590
|
+
}
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
continue;
|
|
1594
|
+
}
|
|
1595
|
+
if (typeof val === "function") {
|
|
1596
|
+
const dispose = createEffect(() => {
|
|
1597
|
+
let v = val();
|
|
1598
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1599
|
+
applyElementProp(element, key, v, isSVG);
|
|
1600
|
+
});
|
|
1601
|
+
onCleanup(() => {
|
|
1602
|
+
dispose();
|
|
1603
|
+
});
|
|
1604
|
+
} else {
|
|
1605
|
+
createRenderEffect(() => applyElementProp(element, key, props[key], isSVG));
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
function mergeProps(...sources) {
|
|
1610
|
+
const resolve = (key) => {
|
|
1611
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1612
|
+
const s = sources[i];
|
|
1613
|
+
if (s && key in s && s[key] !== void 0) return s[key];
|
|
1614
|
+
}
|
|
1615
|
+
return void 0;
|
|
1616
|
+
};
|
|
1617
|
+
const hasKey = (key) => {
|
|
1618
|
+
for (const s of sources) if (s && key in s) return true;
|
|
1619
|
+
return false;
|
|
1620
|
+
};
|
|
1621
|
+
return new Proxy({}, {
|
|
1622
|
+
get: (_, key) => resolve(key),
|
|
1623
|
+
has: (_, key) => hasKey(key),
|
|
1624
|
+
ownKeys: () => {
|
|
1625
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1626
|
+
for (const s of sources) if (s) for (const k of Reflect.ownKeys(s)) keys.add(k);
|
|
1627
|
+
return [...keys];
|
|
1628
|
+
},
|
|
1629
|
+
getOwnPropertyDescriptor: (_, key) => hasKey(key) ? { enumerable: true, configurable: true, get: () => resolve(key) } : void 0
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
function splitProps(props, ...keys) {
|
|
1633
|
+
const taken = /* @__PURE__ */ new Set();
|
|
1634
|
+
for (const group of keys) for (const k of group) taken.add(k);
|
|
1635
|
+
const descriptor = (p) => ({
|
|
1636
|
+
enumerable: true,
|
|
1637
|
+
configurable: true,
|
|
1638
|
+
get: () => props[p]
|
|
1639
|
+
});
|
|
1640
|
+
const groups = keys.map((group) => {
|
|
1641
|
+
const keySet = new Set(group);
|
|
1642
|
+
return new Proxy({}, {
|
|
1643
|
+
get: (_, p) => keySet.has(p) ? props[p] : void 0,
|
|
1644
|
+
has: (_, p) => keySet.has(p) && p in props,
|
|
1645
|
+
ownKeys: () => Array.from(keySet).filter((k) => k in props),
|
|
1646
|
+
getOwnPropertyDescriptor: (_, p) => keySet.has(p) && p in props ? descriptor(p) : void 0
|
|
1647
|
+
});
|
|
1648
|
+
});
|
|
1649
|
+
const rest = new Proxy({}, {
|
|
1650
|
+
get: (_, p) => taken.has(p) ? void 0 : props[p],
|
|
1651
|
+
has: (_, p) => !taken.has(p) && p in props,
|
|
1652
|
+
ownKeys: () => Reflect.ownKeys(props).filter((k) => !taken.has(k)),
|
|
1653
|
+
getOwnPropertyDescriptor: (_, p) => !taken.has(p) && p in props ? descriptor(p) : void 0
|
|
1654
|
+
});
|
|
1655
|
+
return [...groups, rest];
|
|
1656
|
+
}
|
|
1657
|
+
function handleRef(ref, element) {
|
|
1658
|
+
if (!ref) return;
|
|
1659
|
+
const held = ref[HOLE_TAG]?.name;
|
|
1660
|
+
reportReactiveDirective(
|
|
1661
|
+
element,
|
|
1662
|
+
"ref",
|
|
1663
|
+
held || (typeof ref === "function" ? ref.name || "ref" : "ref"),
|
|
1664
|
+
ref
|
|
1665
|
+
);
|
|
1666
|
+
if (isDomNode(ref)) {
|
|
1667
|
+
const actualRef = element;
|
|
1668
|
+
const actualElement = ref;
|
|
1669
|
+
if (!actualRef) return;
|
|
1670
|
+
if (typeof actualRef === "function") actualRef(actualElement);
|
|
1671
|
+
else if (typeof actualRef === "object" && "current" in actualRef) actualRef.current = actualElement;
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
if (typeof ref === "function") ref(element);
|
|
1675
|
+
else if (typeof ref === "object" && "current" in ref) ref.current = element;
|
|
1676
|
+
}
|
|
1677
|
+
function createPortal(children, element, props) {
|
|
1678
|
+
const container = element || document.body;
|
|
1679
|
+
const resolved = readChildren(() => children);
|
|
1680
|
+
const cleanups = [];
|
|
1681
|
+
batch(() => {
|
|
1682
|
+
const dispose = createRenderEffect(() => {
|
|
1683
|
+
const nodes = resolved();
|
|
1684
|
+
if (Array.isArray(nodes)) {
|
|
1685
|
+
nodes.forEach((node) => container.appendChild(node));
|
|
1686
|
+
cleanups.push(() => {
|
|
1687
|
+
nodes.forEach((node) => {
|
|
1688
|
+
if (node.parentNode === container) {
|
|
1689
|
+
container.removeChild(node);
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1692
|
+
});
|
|
1693
|
+
} else if (isDomNode(nodes)) {
|
|
1694
|
+
container.appendChild(nodes);
|
|
1695
|
+
cleanups.push(() => {
|
|
1696
|
+
if (nodes.parentNode === container) {
|
|
1697
|
+
container.removeChild(nodes);
|
|
1698
|
+
}
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
cleanups.push(dispose);
|
|
1703
|
+
onCleanup(() => {
|
|
1704
|
+
cleanups.forEach((fn) => fn());
|
|
1705
|
+
});
|
|
1706
|
+
});
|
|
1707
|
+
return null;
|
|
1708
|
+
}
|
|
1709
|
+
function isNativeElement(tag) {
|
|
1710
|
+
return typeof tag === "string" && tag.toLowerCase() === tag;
|
|
1711
|
+
}
|
|
1712
|
+
function isSVGElement(tag) {
|
|
1713
|
+
return tag === "svg" || tag === "path" || tag === "circle" || tag === "rect" || tag === "line" || tag === "polygon" || tag === "polyline" || tag === "ellipse" || tag === "g" || tag === "defs" || tag === "clipPath" || tag === "text";
|
|
1714
|
+
}
|
|
1715
|
+
function escapeHTML(str) {
|
|
1716
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1717
|
+
}
|
|
1718
|
+
function isPromise(v) {
|
|
1719
|
+
return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
|
|
1720
|
+
}
|
|
1721
|
+
function isAccessor(value) {
|
|
1722
|
+
return typeof value === "function" && value.length === 0 && isSignal(value);
|
|
1723
|
+
}
|
|
1724
|
+
function render(element, container, context) {
|
|
1725
|
+
if (!container) {
|
|
1726
|
+
throw new Error("Container element is required");
|
|
1727
|
+
}
|
|
1728
|
+
let rendererDispose;
|
|
1729
|
+
let disposeRoot;
|
|
1730
|
+
const disposers = [];
|
|
1731
|
+
createRoot((dispose) => {
|
|
1732
|
+
batch(() => {
|
|
1733
|
+
if (!hydration.active) {
|
|
1734
|
+
container.textContent = "";
|
|
1735
|
+
}
|
|
1736
|
+
stampVersions(container);
|
|
1737
|
+
warnOnVersionSkew();
|
|
1738
|
+
insert(container, element);
|
|
1739
|
+
return;
|
|
1740
|
+
});
|
|
1741
|
+
disposeRoot = dispose;
|
|
1742
|
+
});
|
|
1743
|
+
return () => {
|
|
1744
|
+
disposeRoot?.();
|
|
1745
|
+
rendererDispose?.();
|
|
1746
|
+
disposers.forEach((d) => d());
|
|
1747
|
+
container.textContent = "";
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
function bindPair(source) {
|
|
1751
|
+
if (Array.isArray(source)) return source;
|
|
1752
|
+
if (typeof source === "function" && typeof source.set === "function") {
|
|
1753
|
+
return [source, source.set];
|
|
1754
|
+
}
|
|
1755
|
+
throw new TypeError(
|
|
1756
|
+
"[fluixi] bind: needs a signal, either `signal(...)` or the `[get, set]` pair from `createSignal(...)`."
|
|
1757
|
+
);
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
// src/lib/dom/integration.ts
|
|
1761
|
+
import { untrack as untrack2, isSignal as isSignal2, reportReactiveProps } from "@fluixi/reactive";
|
|
1762
|
+
var _slotKey = "__fx_dom_create_component__";
|
|
1763
|
+
var _slot = globalThis[_slotKey] ??= { fn: null };
|
|
1764
|
+
function registerCreateComponent(createComponent2) {
|
|
1765
|
+
_slot.fn = createComponent2;
|
|
1766
|
+
}
|
|
1767
|
+
function initializeIntegration(options = {}) {
|
|
1768
|
+
const cc = options.signalSystem?.createComponent;
|
|
1769
|
+
if (cc) _slot.fn = cc;
|
|
1770
|
+
}
|
|
1771
|
+
function createComponent(Comp, props) {
|
|
1772
|
+
if (_slot.fn) return _slot.fn(Comp, props);
|
|
1773
|
+
if (props) reportReactiveProps(props);
|
|
1774
|
+
const component = typeof Comp === "function" ? untrack2(() => Comp(props)) : Comp;
|
|
1775
|
+
const nameable = component != null && (typeof component === "function" || typeof component === "object");
|
|
1776
|
+
if (nameable) {
|
|
1777
|
+
try {
|
|
1778
|
+
component["$name"] = Comp?.name;
|
|
1779
|
+
} catch {
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
if (nameable && !isSignal2(component)) {
|
|
1783
|
+
return asComponent(component);
|
|
1784
|
+
}
|
|
1785
|
+
return component;
|
|
1786
|
+
}
|
|
1787
|
+
var intergartionInitialized = () => _slot.fn !== null;
|
|
1788
|
+
var isIntegrationInitialized = () => _slot.fn !== null;
|
|
1789
|
+
function resetIntegration() {
|
|
1790
|
+
_slot.fn = null;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
// src/lib/dom/server/request-context.ts
|
|
1794
|
+
var _current;
|
|
1795
|
+
var syncStore = {
|
|
1796
|
+
getStore: () => _current,
|
|
1797
|
+
run(ctx, fn) {
|
|
1798
|
+
const prev = _current;
|
|
1799
|
+
_current = ctx;
|
|
1800
|
+
try {
|
|
1801
|
+
return fn();
|
|
1802
|
+
} finally {
|
|
1803
|
+
_current = prev;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
var _store = syncStore;
|
|
1808
|
+
function setRequestStore(store2) {
|
|
1809
|
+
_store = store2 ?? syncStore;
|
|
1810
|
+
}
|
|
1811
|
+
function createRequestContext(event = {}) {
|
|
1812
|
+
if (!event.locals) {
|
|
1813
|
+
event.locals = event.request ? getRequestLocals(event.request) : {};
|
|
1814
|
+
}
|
|
1815
|
+
let id = 0;
|
|
1816
|
+
let rid = 0;
|
|
1817
|
+
let scope = null;
|
|
1818
|
+
const scopeCounters = /* @__PURE__ */ new Map();
|
|
1819
|
+
const islandCounts = /* @__PURE__ */ new Map();
|
|
1820
|
+
return {
|
|
1821
|
+
event,
|
|
1822
|
+
routeData: /* @__PURE__ */ new Map(),
|
|
1823
|
+
matchedRoute: /* @__PURE__ */ new Map(),
|
|
1824
|
+
nextId: () => `s${id++}`,
|
|
1825
|
+
nextResourceId: () => {
|
|
1826
|
+
if (scope === null) return `r${rid++}`;
|
|
1827
|
+
const n = scopeCounters.get(scope) ?? 0;
|
|
1828
|
+
scopeCounters.set(scope, n + 1);
|
|
1829
|
+
return `${scope}:r${n}`;
|
|
1830
|
+
},
|
|
1831
|
+
nextIslandNamespace: (name) => {
|
|
1832
|
+
const n = islandCounts.get(name) ?? 0;
|
|
1833
|
+
islandCounts.set(name, n + 1);
|
|
1834
|
+
return `${name}#${n}`;
|
|
1835
|
+
},
|
|
1836
|
+
withResourceScope(ns, fn) {
|
|
1837
|
+
const prev = scope;
|
|
1838
|
+
scope = ns;
|
|
1839
|
+
try {
|
|
1840
|
+
return fn();
|
|
1841
|
+
} finally {
|
|
1842
|
+
scope = prev;
|
|
1843
|
+
}
|
|
1844
|
+
},
|
|
1845
|
+
pending: /* @__PURE__ */ new Set(),
|
|
1846
|
+
data: /* @__PURE__ */ new Map()
|
|
1847
|
+
};
|
|
1848
|
+
}
|
|
1849
|
+
function runWithRequestContext(ctx, fn) {
|
|
1850
|
+
return _store.run(ctx, fn);
|
|
1851
|
+
}
|
|
1852
|
+
function getRequestContext() {
|
|
1853
|
+
return _store.getStore();
|
|
1854
|
+
}
|
|
1855
|
+
function getRequestEvent() {
|
|
1856
|
+
return getRequestContext()?.event;
|
|
1857
|
+
}
|
|
1858
|
+
function getLocals() {
|
|
1859
|
+
const event = getRequestEvent();
|
|
1860
|
+
if (!event) return {};
|
|
1861
|
+
if (!event.locals) event.locals = {};
|
|
1862
|
+
return event.locals;
|
|
1863
|
+
}
|
|
1864
|
+
var _requestLocals = /* @__PURE__ */ new WeakMap();
|
|
1865
|
+
function getRequestLocals(request) {
|
|
1866
|
+
let bag = _requestLocals.get(request);
|
|
1867
|
+
if (!bag) {
|
|
1868
|
+
bag = {};
|
|
1869
|
+
_requestLocals.set(request, bag);
|
|
1870
|
+
}
|
|
1871
|
+
return bag;
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
// src/lib/dom/hydration.ts
|
|
1875
|
+
import { setResourceIdSource, setServerDataGetter } from "@fluixi/reactive/signal";
|
|
1876
|
+
|
|
1877
|
+
// src/lib/dom/server/fx-data.ts
|
|
1878
|
+
var FX_DATA_ID = "__FX_DATA__";
|
|
1879
|
+
function escapeFxJson(json) {
|
|
1880
|
+
return json.replace(/[<>&\u2028\u2029]/g, (c) => "\\u" + c.charCodeAt(0).toString(16).padStart(4, "0"));
|
|
1881
|
+
}
|
|
1882
|
+
var _scriptCache;
|
|
1883
|
+
function getServerData() {
|
|
1884
|
+
const g = globalThis.__FX_DATA__;
|
|
1885
|
+
if (g) return g;
|
|
1886
|
+
if (_scriptCache !== void 0) return _scriptCache;
|
|
1887
|
+
let parsed = null;
|
|
1888
|
+
if (typeof document !== "undefined") {
|
|
1889
|
+
const text = document.getElementById(FX_DATA_ID)?.textContent;
|
|
1890
|
+
if (text) {
|
|
1891
|
+
try {
|
|
1892
|
+
parsed = JSON.parse(text);
|
|
1893
|
+
} catch {
|
|
1894
|
+
parsed = null;
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
return _scriptCache = parsed;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
// src/lib/dom/hydration.ts
|
|
1902
|
+
function recoverCursor() {
|
|
1903
|
+
for (; ; ) {
|
|
1904
|
+
while (hydration.cursor && hydration.cursor.nodeType === 3 && hydration.cursor.data === "") {
|
|
1905
|
+
hydration.cursor = hydration.cursor.nextSibling;
|
|
1906
|
+
}
|
|
1907
|
+
if (hydration.cursor != null || !hydration.parents.length) return;
|
|
1908
|
+
hydration.cursor = hydration.parents.pop().nextSibling;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
var VOID_ELEMENTS2 = /* @__PURE__ */ new Set([
|
|
1912
|
+
"area",
|
|
1913
|
+
"base",
|
|
1914
|
+
"br",
|
|
1915
|
+
"col",
|
|
1916
|
+
"embed",
|
|
1917
|
+
"hr",
|
|
1918
|
+
"img",
|
|
1919
|
+
"input",
|
|
1920
|
+
"link",
|
|
1921
|
+
"meta",
|
|
1922
|
+
"param",
|
|
1923
|
+
"source",
|
|
1924
|
+
"track",
|
|
1925
|
+
"wbr"
|
|
1926
|
+
]);
|
|
1927
|
+
var DEV = typeof process !== "undefined" && process.env && false;
|
|
1928
|
+
function warnMismatch(expected, found) {
|
|
1929
|
+
const f = found.nodeType === 1 ? `<${found.tagName.toLowerCase()}>` : found.nodeType === 3 ? `text ${JSON.stringify((found.nodeValue ?? "").slice(0, 24))}` : found.nodeType === 8 ? "comment" : "node";
|
|
1930
|
+
console.warn(
|
|
1931
|
+
`[fluixi] hydration mismatch: expected ${expected} but the server DOM has ${f}. Server and client rendered different markup; recreating this node on the client. Check for non-deterministic render (Date.now(), Math.random(), browser-only branches, untransported data).`
|
|
1932
|
+
);
|
|
1933
|
+
}
|
|
1934
|
+
function hydrateElement(tag) {
|
|
1935
|
+
recoverCursor();
|
|
1936
|
+
const c = hydration.cursor;
|
|
1937
|
+
if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
|
|
1938
|
+
if (VOID_ELEMENTS2.has(tag.toLowerCase())) {
|
|
1939
|
+
hydration.cursor = c.nextSibling;
|
|
1940
|
+
} else {
|
|
1941
|
+
hydration.parents.push(c);
|
|
1942
|
+
hydration.cursor = c.firstChild;
|
|
1943
|
+
}
|
|
1944
|
+
return c;
|
|
1945
|
+
}
|
|
1946
|
+
if (DEV && c) warnMismatch(`<${tag}>`, c);
|
|
1947
|
+
return null;
|
|
1948
|
+
}
|
|
1949
|
+
function hydrateStatic(tag) {
|
|
1950
|
+
recoverCursor();
|
|
1951
|
+
const c = hydration.cursor;
|
|
1952
|
+
if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
|
|
1953
|
+
hydration.cursor = c.nextSibling;
|
|
1954
|
+
return c;
|
|
1955
|
+
}
|
|
1956
|
+
if (DEV && c) warnMismatch(`<${tag}> (static)`, c);
|
|
1957
|
+
return null;
|
|
1958
|
+
}
|
|
1959
|
+
function hydrateText(value) {
|
|
1960
|
+
if (value === "") {
|
|
1961
|
+
const c2 = hydration.cursor;
|
|
1962
|
+
if (c2 && c2.nodeType === 3 && c2.data !== "") {
|
|
1963
|
+
hydration.cursor = c2.nextSibling;
|
|
1964
|
+
c2.data = "";
|
|
1965
|
+
return c2;
|
|
1966
|
+
}
|
|
1967
|
+
return null;
|
|
1968
|
+
}
|
|
1969
|
+
recoverCursor();
|
|
1970
|
+
const c = hydration.cursor;
|
|
1971
|
+
if (c && c.nodeType === 3) {
|
|
1972
|
+
hydration.cursor = c.nextSibling;
|
|
1973
|
+
if (c.nodeValue !== value) c.nodeValue = value;
|
|
1974
|
+
return c;
|
|
1975
|
+
}
|
|
1976
|
+
if (DEV && c) warnMismatch(`text ${JSON.stringify(value.slice(0, 24))}`, c);
|
|
1977
|
+
return null;
|
|
1978
|
+
}
|
|
1979
|
+
function hydrateMarker(value) {
|
|
1980
|
+
recoverCursor();
|
|
1981
|
+
const c = hydration.cursor;
|
|
1982
|
+
if (c && c.nodeType === 8 && c.data === value) {
|
|
1983
|
+
hydration.cursor = c.nextSibling;
|
|
1984
|
+
return c;
|
|
1985
|
+
}
|
|
1986
|
+
if (DEV && c) warnMismatch(`marker <!--${value.slice(0, 24)}-->`, c);
|
|
1987
|
+
return null;
|
|
1988
|
+
}
|
|
1989
|
+
var _walkerRegistered = false;
|
|
1990
|
+
function ensureWalker() {
|
|
1991
|
+
if (_walkerRegistered) return;
|
|
1992
|
+
_walkerRegistered = true;
|
|
1993
|
+
registerHydrationWalker({ hydrateElement, hydrateText, hydrateMarker, hydrateStatic });
|
|
1994
|
+
}
|
|
1995
|
+
function hydrate(element, container, options) {
|
|
1996
|
+
ensureWalker();
|
|
1997
|
+
hydration.active = true;
|
|
1998
|
+
hydration.cursor = container.firstChild;
|
|
1999
|
+
hydration.parents = [];
|
|
2000
|
+
const data = getServerData();
|
|
2001
|
+
const ns = options?.resourceNamespace;
|
|
2002
|
+
let rid = 0;
|
|
2003
|
+
setResourceIdSource(() => ns ? `${ns}:r${rid++}` : `r${rid++}`);
|
|
2004
|
+
setServerDataGetter(data ? (id) => id in data ? { value: data[id] } : void 0 : null);
|
|
2005
|
+
try {
|
|
2006
|
+
return render(element, container);
|
|
2007
|
+
} finally {
|
|
2008
|
+
hydration.active = false;
|
|
2009
|
+
hydration.cursor = null;
|
|
2010
|
+
hydration.parents = [];
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
// src/lib/dom/island.ts
|
|
2015
|
+
var TAG = "fluixi-island";
|
|
2016
|
+
function Island(props) {
|
|
2017
|
+
const { component, props: cprops = {}, name } = props;
|
|
2018
|
+
const el = createNativeElement(TAG);
|
|
2019
|
+
const islandName = name ?? component.name ?? "Island";
|
|
2020
|
+
setAttribute(el, "name", islandName);
|
|
2021
|
+
setAttribute(el, "props", JSON.stringify(cprops ?? {}));
|
|
2022
|
+
const ctx = isServer() ? getRequestContext() : void 0;
|
|
2023
|
+
if (ctx) {
|
|
2024
|
+
const ns = ctx.nextIslandNamespace(islandName);
|
|
2025
|
+
insert(el, () => ctx.withResourceScope(ns, () => component(cprops)));
|
|
2026
|
+
} else {
|
|
2027
|
+
insert(el, () => component(cprops));
|
|
2028
|
+
}
|
|
2029
|
+
return el;
|
|
2030
|
+
}
|
|
2031
|
+
var _styleInjected = false;
|
|
2032
|
+
function ensureDisplayContents() {
|
|
2033
|
+
if (_styleInjected || typeof document === "undefined") return;
|
|
2034
|
+
_styleInjected = true;
|
|
2035
|
+
const style = document.createElement("style");
|
|
2036
|
+
style.textContent = `${TAG}{display:contents}`;
|
|
2037
|
+
document.head.appendChild(style);
|
|
2038
|
+
}
|
|
2039
|
+
function hydrateIslands(registry) {
|
|
2040
|
+
if (typeof document === "undefined") return;
|
|
2041
|
+
ensureDisplayContents();
|
|
2042
|
+
const els = document.querySelectorAll(TAG);
|
|
2043
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2044
|
+
els.forEach((el) => {
|
|
2045
|
+
const name = el.getAttribute("name") ?? "";
|
|
2046
|
+
const occ = counts.get(name) ?? 0;
|
|
2047
|
+
counts.set(name, occ + 1);
|
|
2048
|
+
const Comp = registry[name];
|
|
2049
|
+
if (!Comp) {
|
|
2050
|
+
if (typeof process === "undefined" || false) {
|
|
2051
|
+
console.warn(`[fluixi] island "${name}" has no component in the registry, left static.`);
|
|
2052
|
+
}
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2055
|
+
let props = {};
|
|
2056
|
+
try {
|
|
2057
|
+
props = JSON.parse(el.getAttribute("props") || "{}");
|
|
2058
|
+
} catch {
|
|
2059
|
+
}
|
|
2060
|
+
hydrate(() => Comp(props), el, { resourceNamespace: `${name}#${occ}` });
|
|
2061
|
+
});
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
// src/lib/html.ts
|
|
2065
|
+
function html(_strings, ..._values) {
|
|
2066
|
+
throw new Error("html`` was not compiled, enable the lit format: fluixi({ format: 'lit' }).");
|
|
2067
|
+
}
|
|
2068
|
+
function svg(_strings, ..._values) {
|
|
2069
|
+
throw new Error("svg`` was not compiled, enable the lit format: fluixi({ format: 'lit' }).");
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
// src/lib/dom/dynamic-element.ts
|
|
2073
|
+
import { readChildren as readChildren2 } from "@fluixi/reactive/signal";
|
|
2074
|
+
function createDynamicElement(type, props = {}) {
|
|
2075
|
+
if (typeof type === "function") return createComponent(type, props);
|
|
2076
|
+
if (typeof type !== "string" || type.length === 0) return null;
|
|
2077
|
+
const svgTag = isSVGElement(type);
|
|
2078
|
+
if (isServer()) return getServerNodes().createElement(type, svgTag);
|
|
2079
|
+
const element = svgTag ? document.createElementNS(SVG_NAMESPACE, type) : document.createElement(type);
|
|
2080
|
+
applyProps(element, props, svgTag);
|
|
2081
|
+
insertChildren(element, props);
|
|
2082
|
+
return element;
|
|
2083
|
+
}
|
|
2084
|
+
function insertChildren(element, props) {
|
|
2085
|
+
if (!props || props.children === void 0) return;
|
|
2086
|
+
const children = readChildren2(() => props.children);
|
|
2087
|
+
const insertOne = (child) => {
|
|
2088
|
+
insert(element, child, typeof child === "function" ? null : void 0);
|
|
2089
|
+
};
|
|
2090
|
+
if (Array.isArray(children)) children.forEach(insertOne);
|
|
2091
|
+
else insertOne(children);
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
// src/lib/flow/show.ts
|
|
2095
|
+
import {
|
|
2096
|
+
createChildOwner,
|
|
2097
|
+
createMemo,
|
|
2098
|
+
disposeScope,
|
|
2099
|
+
getOwner,
|
|
2100
|
+
runWithOwner,
|
|
2101
|
+
untrack as untrack3
|
|
2102
|
+
} from "@fluixi/reactive/signal";
|
|
2103
|
+
|
|
2104
|
+
// src/lib/flow/utils.ts
|
|
2105
|
+
function normalizeAccessor(value) {
|
|
2106
|
+
return typeof value === "function" ? value : (() => value);
|
|
2107
|
+
}
|
|
2108
|
+
function resolveReactiveProp(read) {
|
|
2109
|
+
return () => {
|
|
2110
|
+
const value = read();
|
|
2111
|
+
return typeof value === "function" ? value() : value;
|
|
2112
|
+
};
|
|
2113
|
+
}
|
|
2114
|
+
function isTruthy(value) {
|
|
2115
|
+
return value !== null && value !== void 0 && value !== false;
|
|
2116
|
+
}
|
|
2117
|
+
function isLitResult(value) {
|
|
2118
|
+
if (!value || typeof value !== "object") return false;
|
|
2119
|
+
return !!(typeof value["_$litType$"] !== "undefined" || typeof value["_$litDirective$"] !== "undefined" || Array.isArray(value.strings) && Array.isArray(value.values));
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2122
|
+
// src/lib/flow/show.ts
|
|
2123
|
+
function Show(props) {
|
|
2124
|
+
const when = resolveReactiveProp(() => props.when);
|
|
2125
|
+
const value = createMemo(when, void 0, { name: "Show.when" });
|
|
2126
|
+
const cond = createMemo(value, void 0, { name: "Show.cond" });
|
|
2127
|
+
const parentOwner = getOwner();
|
|
2128
|
+
let branchScope = null;
|
|
2129
|
+
let shown = null;
|
|
2130
|
+
const enterBranch = (next) => {
|
|
2131
|
+
if (next === shown) return;
|
|
2132
|
+
if (branchScope) disposeScope(branchScope);
|
|
2133
|
+
branchScope = createChildOwner(parentOwner);
|
|
2134
|
+
shown = next;
|
|
2135
|
+
};
|
|
2136
|
+
return createMemo(
|
|
2137
|
+
() => {
|
|
2138
|
+
const evaluate = cond();
|
|
2139
|
+
enterBranch(evaluate ? "when" : "fallback");
|
|
2140
|
+
return runWithOwner(branchScope, () => {
|
|
2141
|
+
if (evaluate) {
|
|
2142
|
+
let children = props.children;
|
|
2143
|
+
if (typeof children === "function" && !isLitResult(children)) {
|
|
2144
|
+
if (typeof value === "function") {
|
|
2145
|
+
return untrack3(() => {
|
|
2146
|
+
if (!untrack3(value)) return props.fallback;
|
|
2147
|
+
return children(value());
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
return children(value);
|
|
2151
|
+
}
|
|
2152
|
+
return children;
|
|
2153
|
+
}
|
|
2154
|
+
return props.fallback;
|
|
2155
|
+
});
|
|
2156
|
+
return props.fallback ?? null;
|
|
2157
|
+
},
|
|
2158
|
+
void 0,
|
|
2159
|
+
// Not `Show`: the compiler already marks the memo it wraps the component in with that,
|
|
2160
|
+
// and two cards of the same name in one graph is worse than a longer one.
|
|
2161
|
+
{ name: "Show.result" }
|
|
2162
|
+
);
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
// src/lib/flow/for.ts
|
|
2166
|
+
import { mapArray, keyArray } from "@fluixi/reactive/signal";
|
|
2167
|
+
function For(props) {
|
|
2168
|
+
const each = resolveReactiveProp(() => props.each);
|
|
2169
|
+
const fallback = () => props.fallback ?? null;
|
|
2170
|
+
const render2 = (item, index) => {
|
|
2171
|
+
const children = props.children;
|
|
2172
|
+
const rendered = Array.isArray(children) ? children.map((c) => typeof c === "function" ? c(item, index) : c) : typeof children === "function" ? children(item, index) : children;
|
|
2173
|
+
hydrateAdvancePast(rendered);
|
|
2174
|
+
return rendered;
|
|
2175
|
+
};
|
|
2176
|
+
return props.by ? keyArray(each, props.by, (item, index) => render2(item, index), { fallback }) : mapArray(each, (item, index) => render2(item, index), { fallback });
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
// src/lib/flow/index-flow.ts
|
|
2180
|
+
import { indexArray } from "@fluixi/reactive/signal";
|
|
2181
|
+
function Index(props) {
|
|
2182
|
+
const each = resolveReactiveProp(() => props.each);
|
|
2183
|
+
return indexArray(
|
|
2184
|
+
each,
|
|
2185
|
+
(item, index) => {
|
|
2186
|
+
const rendered = props.children(item, index);
|
|
2187
|
+
hydrateAdvancePast(rendered);
|
|
2188
|
+
return rendered;
|
|
2189
|
+
},
|
|
2190
|
+
{ fallback: () => props.fallback ?? null }
|
|
2191
|
+
);
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
// src/lib/flow/index.ts
|
|
2195
|
+
import { mapArray as mapArray2, keyArray as keyArray2, indexArray as indexArray2 } from "@fluixi/reactive/signal";
|
|
2196
|
+
|
|
2197
|
+
// src/lib/flow/switch.ts
|
|
2198
|
+
import { createMemo as createMemo2, createChildOwner as createChildOwner2, disposeScope as disposeScope2, getOwner as getOwner2, runWithOwner as runWithOwner2 } from "@fluixi/reactive/signal";
|
|
2199
|
+
var MATCH_MARKER = /* @__PURE__ */ Symbol("match");
|
|
2200
|
+
function Match(props) {
|
|
2201
|
+
return {
|
|
2202
|
+
[MATCH_MARKER]: true,
|
|
2203
|
+
// Lazy read through the prop getter. Switch calls `branch.when()` inside its memo,
|
|
2204
|
+
// so `when={cond()}` reacts; `when={cond}` unwraps via resolveReactiveProp.
|
|
2205
|
+
when: resolveReactiveProp(() => props.when),
|
|
2206
|
+
// Lazy, like `when`. Read eagerly, every branch's children were built the
|
|
2207
|
+
// moment the Match node was, before Switch had chosen one, so they were
|
|
2208
|
+
// created outside the branch's scope (and non-matching branches were built
|
|
2209
|
+
// for nothing). Switch reads this inside the selected branch's scope.
|
|
2210
|
+
get children() {
|
|
2211
|
+
return props.children;
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2214
|
+
}
|
|
2215
|
+
function Switch(props) {
|
|
2216
|
+
const branches = Array.isArray(props.children) ? props.children : [props.children];
|
|
2217
|
+
const parentOwner = getOwner2();
|
|
2218
|
+
let branchScope = null;
|
|
2219
|
+
let shown = -1;
|
|
2220
|
+
const enterBranch = (index) => {
|
|
2221
|
+
if (index === shown) return;
|
|
2222
|
+
if (branchScope) disposeScope2(branchScope);
|
|
2223
|
+
branchScope = createChildOwner2(parentOwner);
|
|
2224
|
+
shown = index;
|
|
2225
|
+
};
|
|
2226
|
+
return createMemo2(() => {
|
|
2227
|
+
for (let i = 0; i < branches.length; i += 1) {
|
|
2228
|
+
const raw = branches[i];
|
|
2229
|
+
let branch = raw;
|
|
2230
|
+
let guard = 0;
|
|
2231
|
+
while (typeof branch === "function" && !branch[MATCH_MARKER] && guard++ < 10) {
|
|
2232
|
+
branch = branch();
|
|
2233
|
+
}
|
|
2234
|
+
if (!branch || typeof branch !== "object" || branch[MATCH_MARKER] !== true) {
|
|
2235
|
+
continue;
|
|
2236
|
+
}
|
|
2237
|
+
const value = branch.when();
|
|
2238
|
+
if (isTruthy(value)) {
|
|
2239
|
+
enterBranch(i);
|
|
2240
|
+
return runWithOwner2(
|
|
2241
|
+
branchScope,
|
|
2242
|
+
() => typeof branch.children === "function" ? branch.children(value) : branch.children
|
|
2243
|
+
);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
enterBranch(-2);
|
|
2247
|
+
return runWithOwner2(branchScope, () => props.fallback ?? null);
|
|
2248
|
+
}, void 0, { name: "Switch" });
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
// src/lib/flow/dynamic.ts
|
|
2252
|
+
import { createMemo as createMemo3, createChildOwner as createChildOwner3, disposeScope as disposeScope3, getOwner as getOwner3, runWithOwner as runWithOwner3 } from "@fluixi/reactive/signal";
|
|
2253
|
+
function Dynamic(props) {
|
|
2254
|
+
const getComponent = normalizeAccessor(props.component);
|
|
2255
|
+
const { component: _c, ...rest } = props;
|
|
2256
|
+
const parentOwner = getOwner3();
|
|
2257
|
+
let scope = null;
|
|
2258
|
+
let current;
|
|
2259
|
+
return createMemo3(() => {
|
|
2260
|
+
const C = getComponent();
|
|
2261
|
+
if (C !== current) {
|
|
2262
|
+
if (scope) disposeScope3(scope);
|
|
2263
|
+
scope = createChildOwner3(parentOwner);
|
|
2264
|
+
current = C;
|
|
2265
|
+
}
|
|
2266
|
+
if (C == null) return null;
|
|
2267
|
+
if (typeof C === "string") {
|
|
2268
|
+
return { tag: C, props: rest };
|
|
2269
|
+
}
|
|
2270
|
+
return runWithOwner3(scope, () => C(rest));
|
|
2271
|
+
}, void 0, { name: "Dynamic" });
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
// src/lib/flow/portal.ts
|
|
2275
|
+
import { createRoot as createRoot2, onCleanup as onCleanup2 } from "@fluixi/reactive/signal";
|
|
2276
|
+
function Portal(props) {
|
|
2277
|
+
const getMount = () => {
|
|
2278
|
+
if (!props.mount) return document.body;
|
|
2279
|
+
return typeof props.mount === "function" ? props.mount() : props.mount;
|
|
2280
|
+
};
|
|
2281
|
+
let dispose;
|
|
2282
|
+
let container;
|
|
2283
|
+
createRoot2((d) => {
|
|
2284
|
+
dispose = d;
|
|
2285
|
+
container = document.createElement("div");
|
|
2286
|
+
container.style.display = "contents";
|
|
2287
|
+
const target = getMount();
|
|
2288
|
+
target.appendChild(container);
|
|
2289
|
+
const inserted = insert(container, props.children);
|
|
2290
|
+
if (inserted) {
|
|
2291
|
+
handleRef(props.ref, container);
|
|
2292
|
+
}
|
|
2293
|
+
});
|
|
2294
|
+
onCleanup2(() => {
|
|
2295
|
+
dispose();
|
|
2296
|
+
container.remove();
|
|
2297
|
+
});
|
|
2298
|
+
return null;
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
// src/lib/flow/client-only.ts
|
|
2302
|
+
import { createMemo as createMemo4, createSignal } from "@fluixi/reactive/signal";
|
|
2303
|
+
function ClientOnly(props) {
|
|
2304
|
+
if (isServer()) return props.fallback ?? null;
|
|
2305
|
+
const hydrating = hydration.active;
|
|
2306
|
+
const [ready, setReady] = createSignal(!hydrating);
|
|
2307
|
+
if (hydrating) queueMicrotask(() => setReady(true));
|
|
2308
|
+
return createMemo4(() => ready() ? props.children : props.fallback ?? null, void 0, {
|
|
2309
|
+
name: "client-only"
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
var NoSsr = ClientOnly;
|
|
2313
|
+
|
|
2314
|
+
// src/lib/flow/error-boundary.ts
|
|
2315
|
+
import { createMemo as createMemo5, createSignal as createSignal2 } from "@fluixi/reactive/signal";
|
|
2316
|
+
function ErrorBoundary(props) {
|
|
2317
|
+
const [error, setError] = createSignal2(null);
|
|
2318
|
+
const reset = () => setError(null);
|
|
2319
|
+
return createMemo5(() => {
|
|
2320
|
+
const err = error();
|
|
2321
|
+
if (err !== null) {
|
|
2322
|
+
return typeof props.fallback === "function" ? props.fallback(err, reset) : props.fallback;
|
|
2323
|
+
}
|
|
2324
|
+
try {
|
|
2325
|
+
const content = typeof props.children === "function" ? props.children() : props.children;
|
|
2326
|
+
return content;
|
|
2327
|
+
} catch (e) {
|
|
2328
|
+
setError(e);
|
|
2329
|
+
return typeof props.fallback === "function" ? props.fallback(e, reset) : props.fallback;
|
|
2330
|
+
}
|
|
2331
|
+
}, void 0, { name: "ErrorBoundary" });
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
// src/lib/flow/class-map.ts
|
|
2335
|
+
import { createMemo as createMemo6 } from "@fluixi/reactive/signal";
|
|
2336
|
+
function classMap(input) {
|
|
2337
|
+
return createMemo6(() => {
|
|
2338
|
+
const map = typeof input === "function" ? input() : input;
|
|
2339
|
+
const classes = [];
|
|
2340
|
+
for (const [cls, cond] of Object.entries(map)) {
|
|
2341
|
+
if (!cls) continue;
|
|
2342
|
+
const active = typeof cond === "function" ? cond() : cond;
|
|
2343
|
+
if (active) classes.push(cls);
|
|
2344
|
+
}
|
|
2345
|
+
return classes.join(" ");
|
|
2346
|
+
}, void 0, { name: "ClassMap" });
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
// src/lib/flow/style-map.ts
|
|
2350
|
+
import { createMemo as createMemo7 } from "@fluixi/reactive/signal";
|
|
2351
|
+
function toKebab(prop) {
|
|
2352
|
+
return prop.startsWith("--") ? prop : prop.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
2353
|
+
}
|
|
2354
|
+
function styleMap(input) {
|
|
2355
|
+
return createMemo7(() => {
|
|
2356
|
+
const map = typeof input === "function" ? input() : input;
|
|
2357
|
+
const parts = [];
|
|
2358
|
+
for (const [prop, val] of Object.entries(map)) {
|
|
2359
|
+
if (!prop) continue;
|
|
2360
|
+
const resolved = typeof val === "function" ? val() : val;
|
|
2361
|
+
if (resolved != null) {
|
|
2362
|
+
parts.push(`${toKebab(prop)}: ${resolved}`);
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
return parts.join("; ");
|
|
2366
|
+
}, void 0, { name: "StyleMap" });
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
// src/lib/dom/server/nodes.ts
|
|
2370
|
+
var NODE_ELEMENT = 1;
|
|
2371
|
+
var NODE_TEXT = 3;
|
|
2372
|
+
var NODE_COMMENT = 8;
|
|
2373
|
+
var _a;
|
|
2374
|
+
_a = SERVER_NODE;
|
|
2375
|
+
var ServerNode = class {
|
|
2376
|
+
constructor() {
|
|
2377
|
+
// Brand the host.ts guards check for (lets them skip an instanceof on these classes).
|
|
2378
|
+
this[_a] = true;
|
|
2379
|
+
this.parentNode = null;
|
|
2380
|
+
this.childNodes = [];
|
|
2381
|
+
}
|
|
2382
|
+
get firstChild() {
|
|
2383
|
+
return this.childNodes[0] ?? null;
|
|
2384
|
+
}
|
|
2385
|
+
get lastChild() {
|
|
2386
|
+
return this.childNodes[this.childNodes.length - 1] ?? null;
|
|
2387
|
+
}
|
|
2388
|
+
get nextSibling() {
|
|
2389
|
+
const p = this.parentNode;
|
|
2390
|
+
if (!p) return null;
|
|
2391
|
+
const i = p.childNodes.indexOf(this);
|
|
2392
|
+
return i >= 0 ? p.childNodes[i + 1] ?? null : null;
|
|
2393
|
+
}
|
|
2394
|
+
get previousSibling() {
|
|
2395
|
+
const p = this.parentNode;
|
|
2396
|
+
if (!p) return null;
|
|
2397
|
+
const i = p.childNodes.indexOf(this);
|
|
2398
|
+
return i > 0 ? p.childNodes[i - 1] ?? null : null;
|
|
2399
|
+
}
|
|
2400
|
+
get parentElement() {
|
|
2401
|
+
return this.parentNode;
|
|
2402
|
+
}
|
|
2403
|
+
appendChild(child) {
|
|
2404
|
+
if (child.parentNode) child.parentNode.removeChild(child);
|
|
2405
|
+
child.parentNode = this;
|
|
2406
|
+
this.childNodes.push(child);
|
|
2407
|
+
return child;
|
|
2408
|
+
}
|
|
2409
|
+
insertBefore(child, ref) {
|
|
2410
|
+
if (ref == null) return this.appendChild(child);
|
|
2411
|
+
if (child.parentNode) child.parentNode.removeChild(child);
|
|
2412
|
+
const i = this.childNodes.indexOf(ref);
|
|
2413
|
+
child.parentNode = this;
|
|
2414
|
+
if (i < 0) this.childNodes.push(child);
|
|
2415
|
+
else this.childNodes.splice(i, 0, child);
|
|
2416
|
+
return child;
|
|
2417
|
+
}
|
|
2418
|
+
removeChild(child) {
|
|
2419
|
+
const i = this.childNodes.indexOf(child);
|
|
2420
|
+
if (i >= 0) this.childNodes.splice(i, 1);
|
|
2421
|
+
child.parentNode = null;
|
|
2422
|
+
return child;
|
|
2423
|
+
}
|
|
2424
|
+
replaceChild(next, old) {
|
|
2425
|
+
const i = this.childNodes.indexOf(old);
|
|
2426
|
+
if (i >= 0) {
|
|
2427
|
+
if (next.parentNode) next.parentNode.removeChild(next);
|
|
2428
|
+
next.parentNode = this;
|
|
2429
|
+
this.childNodes[i] = next;
|
|
2430
|
+
old.parentNode = null;
|
|
2431
|
+
}
|
|
2432
|
+
return old;
|
|
2433
|
+
}
|
|
2434
|
+
// Event listeners are inert on the server.
|
|
2435
|
+
addEventListener() {
|
|
2436
|
+
}
|
|
2437
|
+
removeEventListener() {
|
|
2438
|
+
}
|
|
2439
|
+
};
|
|
2440
|
+
var ServerText = class _ServerText extends ServerNode {
|
|
2441
|
+
constructor(value) {
|
|
2442
|
+
super();
|
|
2443
|
+
this.nodeType = NODE_TEXT;
|
|
2444
|
+
this.data = value;
|
|
2445
|
+
}
|
|
2446
|
+
get nodeValue() {
|
|
2447
|
+
return this.data;
|
|
2448
|
+
}
|
|
2449
|
+
set nodeValue(v) {
|
|
2450
|
+
this.data = v == null ? "" : String(v);
|
|
2451
|
+
}
|
|
2452
|
+
get textContent() {
|
|
2453
|
+
return this.data;
|
|
2454
|
+
}
|
|
2455
|
+
set textContent(v) {
|
|
2456
|
+
this.data = v == null ? "" : String(v);
|
|
2457
|
+
}
|
|
2458
|
+
cloneNode() {
|
|
2459
|
+
return new _ServerText(this.data);
|
|
2460
|
+
}
|
|
2461
|
+
};
|
|
2462
|
+
var ServerRaw = class _ServerRaw extends ServerNode {
|
|
2463
|
+
constructor(html2) {
|
|
2464
|
+
super();
|
|
2465
|
+
this.nodeType = NODE_ELEMENT;
|
|
2466
|
+
this.rawOuterHTML = html2;
|
|
2467
|
+
}
|
|
2468
|
+
get textContent() {
|
|
2469
|
+
return this.rawOuterHTML.replace(/<[^>]*>/g, "");
|
|
2470
|
+
}
|
|
2471
|
+
cloneNode() {
|
|
2472
|
+
return new _ServerRaw(this.rawOuterHTML);
|
|
2473
|
+
}
|
|
2474
|
+
};
|
|
2475
|
+
var ServerComment = class _ServerComment extends ServerNode {
|
|
2476
|
+
constructor(value) {
|
|
2477
|
+
super();
|
|
2478
|
+
this.nodeType = NODE_COMMENT;
|
|
2479
|
+
this.data = value;
|
|
2480
|
+
}
|
|
2481
|
+
get nodeValue() {
|
|
2482
|
+
return this.data;
|
|
2483
|
+
}
|
|
2484
|
+
set nodeValue(v) {
|
|
2485
|
+
this.data = v == null ? "" : String(v);
|
|
2486
|
+
}
|
|
2487
|
+
cloneNode() {
|
|
2488
|
+
return new _ServerComment(this.data);
|
|
2489
|
+
}
|
|
2490
|
+
};
|
|
2491
|
+
var ServerStyle = class {
|
|
2492
|
+
constructor() {
|
|
2493
|
+
// declared keys are stored as own props; cssText holds a raw string blob.
|
|
2494
|
+
this.cssText = "";
|
|
2495
|
+
}
|
|
2496
|
+
setProperty(name, value) {
|
|
2497
|
+
this[name] = value;
|
|
2498
|
+
}
|
|
2499
|
+
removeProperty(name) {
|
|
2500
|
+
delete this[name];
|
|
2501
|
+
}
|
|
2502
|
+
};
|
|
2503
|
+
var ServerClassList = class {
|
|
2504
|
+
constructor(el) {
|
|
2505
|
+
this.el = el;
|
|
2506
|
+
}
|
|
2507
|
+
list() {
|
|
2508
|
+
const c = this.el.getAttribute("class");
|
|
2509
|
+
return c ? c.split(/\s+/).filter(Boolean) : [];
|
|
2510
|
+
}
|
|
2511
|
+
write(arr) {
|
|
2512
|
+
if (arr.length) this.el.setAttribute("class", arr.join(" "));
|
|
2513
|
+
else this.el.removeAttribute("class");
|
|
2514
|
+
}
|
|
2515
|
+
add(...names) {
|
|
2516
|
+
const arr = this.list();
|
|
2517
|
+
for (const n of names) if (!arr.includes(n)) arr.push(n);
|
|
2518
|
+
this.write(arr);
|
|
2519
|
+
}
|
|
2520
|
+
remove(...names) {
|
|
2521
|
+
this.write(this.list().filter((c) => !names.includes(c)));
|
|
2522
|
+
}
|
|
2523
|
+
contains(name) {
|
|
2524
|
+
return this.list().includes(name);
|
|
2525
|
+
}
|
|
2526
|
+
toggle(name, force) {
|
|
2527
|
+
const has = this.contains(name);
|
|
2528
|
+
const on = force === void 0 ? !has : force;
|
|
2529
|
+
if (on) this.add(name);
|
|
2530
|
+
else this.remove(name);
|
|
2531
|
+
return on;
|
|
2532
|
+
}
|
|
2533
|
+
};
|
|
2534
|
+
var ServerElement = class _ServerElement extends ServerNode {
|
|
2535
|
+
constructor(tag, isSVG = false) {
|
|
2536
|
+
super();
|
|
2537
|
+
this.nodeType = NODE_ELEMENT;
|
|
2538
|
+
this.attributes = /* @__PURE__ */ new Map();
|
|
2539
|
+
this.style = new ServerStyle();
|
|
2540
|
+
this.classList = new ServerClassList(this);
|
|
2541
|
+
/** raw HTML set via innerHTML: emitted verbatim, bypassing childNodes. */
|
|
2542
|
+
this.rawHTML = null;
|
|
2543
|
+
this.localName = tag.toLowerCase();
|
|
2544
|
+
this.tagName = isSVG ? tag : tag.toUpperCase();
|
|
2545
|
+
this.isSVG = isSVG;
|
|
2546
|
+
this.namespaceURI = isSVG ? "http://www.w3.org/2000/svg" : null;
|
|
2547
|
+
}
|
|
2548
|
+
setAttribute(name, value) {
|
|
2549
|
+
this.attributes.set(name, String(value));
|
|
2550
|
+
}
|
|
2551
|
+
removeAttribute(name) {
|
|
2552
|
+
this.attributes.delete(name);
|
|
2553
|
+
}
|
|
2554
|
+
getAttribute(name) {
|
|
2555
|
+
return this.attributes.has(name) ? this.attributes.get(name) : null;
|
|
2556
|
+
}
|
|
2557
|
+
hasAttribute(name) {
|
|
2558
|
+
return this.attributes.has(name);
|
|
2559
|
+
}
|
|
2560
|
+
get id() {
|
|
2561
|
+
return this.getAttribute("id") ?? "";
|
|
2562
|
+
}
|
|
2563
|
+
set id(v) {
|
|
2564
|
+
if (v == null) this.removeAttribute("id");
|
|
2565
|
+
else this.setAttribute("id", v);
|
|
2566
|
+
}
|
|
2567
|
+
// JSX_PROPERTIES: className/value/checked/selected/innerHTML/innerText/
|
|
2568
|
+
// textContent/indeterminate/htmlFor flow through setProperty (element[k]=v).
|
|
2569
|
+
get className() {
|
|
2570
|
+
return this.getAttribute("class") ?? "";
|
|
2571
|
+
}
|
|
2572
|
+
set className(v) {
|
|
2573
|
+
if (v == null) this.removeAttribute("class");
|
|
2574
|
+
else this.setAttribute("class", v);
|
|
2575
|
+
}
|
|
2576
|
+
get htmlFor() {
|
|
2577
|
+
return this.getAttribute("for") ?? "";
|
|
2578
|
+
}
|
|
2579
|
+
set htmlFor(v) {
|
|
2580
|
+
if (v == null) this.removeAttribute("for");
|
|
2581
|
+
else this.setAttribute("for", v);
|
|
2582
|
+
}
|
|
2583
|
+
set value(v) {
|
|
2584
|
+
if (v == null) this.removeAttribute("value");
|
|
2585
|
+
else this.setAttribute("value", String(v));
|
|
2586
|
+
}
|
|
2587
|
+
set checked(v) {
|
|
2588
|
+
if (v) this.setAttribute("checked", "");
|
|
2589
|
+
else this.removeAttribute("checked");
|
|
2590
|
+
}
|
|
2591
|
+
set selected(v) {
|
|
2592
|
+
if (v) this.setAttribute("selected", "");
|
|
2593
|
+
else this.removeAttribute("selected");
|
|
2594
|
+
}
|
|
2595
|
+
// indeterminate is a live-only DOM property with no HTML serialization.
|
|
2596
|
+
set indeterminate(_v) {
|
|
2597
|
+
}
|
|
2598
|
+
get textContent() {
|
|
2599
|
+
return this.childNodes.map((c) => c.textContent ?? "").join("");
|
|
2600
|
+
}
|
|
2601
|
+
set textContent(v) {
|
|
2602
|
+
for (const c of this.childNodes) c.parentNode = null;
|
|
2603
|
+
this.childNodes = [];
|
|
2604
|
+
this.rawHTML = null;
|
|
2605
|
+
if (v != null && v !== "") this.appendChild(new ServerText(String(v)));
|
|
2606
|
+
}
|
|
2607
|
+
set innerText(v) {
|
|
2608
|
+
this.textContent = v;
|
|
2609
|
+
}
|
|
2610
|
+
set innerHTML(v) {
|
|
2611
|
+
for (const c of this.childNodes) c.parentNode = null;
|
|
2612
|
+
this.childNodes = [];
|
|
2613
|
+
this.rawHTML = v == null ? "" : String(v);
|
|
2614
|
+
}
|
|
2615
|
+
cloneNode(deep = false) {
|
|
2616
|
+
const el = new _ServerElement(this.localName, this.isSVG);
|
|
2617
|
+
el.attributes = new Map(this.attributes);
|
|
2618
|
+
el.style.cssText = this.style.cssText;
|
|
2619
|
+
el.rawHTML = this.rawHTML;
|
|
2620
|
+
if (deep) for (const c of this.childNodes) el.appendChild(c.cloneNode(true));
|
|
2621
|
+
return el;
|
|
2622
|
+
}
|
|
2623
|
+
};
|
|
2624
|
+
|
|
2625
|
+
// src/lib/dom/server/serialize.ts
|
|
2626
|
+
var VOID_ELEMENTS3 = /* @__PURE__ */ new Set([
|
|
2627
|
+
"area",
|
|
2628
|
+
"base",
|
|
2629
|
+
"br",
|
|
2630
|
+
"col",
|
|
2631
|
+
"embed",
|
|
2632
|
+
"hr",
|
|
2633
|
+
"img",
|
|
2634
|
+
"input",
|
|
2635
|
+
"link",
|
|
2636
|
+
"meta",
|
|
2637
|
+
"param",
|
|
2638
|
+
"source",
|
|
2639
|
+
"track",
|
|
2640
|
+
"wbr"
|
|
2641
|
+
]);
|
|
2642
|
+
var AMP = /&/g;
|
|
2643
|
+
var LT = /</g;
|
|
2644
|
+
var GT = />/g;
|
|
2645
|
+
var QUOT = /"/g;
|
|
2646
|
+
function escapeText(s) {
|
|
2647
|
+
return s.replace(AMP, "&").replace(LT, "<").replace(GT, ">");
|
|
2648
|
+
}
|
|
2649
|
+
function escapeAttr(s) {
|
|
2650
|
+
return s.replace(AMP, "&").replace(QUOT, """).replace(LT, "<").replace(GT, ">");
|
|
2651
|
+
}
|
|
2652
|
+
function camelToKebab(k) {
|
|
2653
|
+
if (k.startsWith("--")) return k;
|
|
2654
|
+
return k.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
|
|
2655
|
+
}
|
|
2656
|
+
function serializeStyle(style) {
|
|
2657
|
+
if (!style) return "";
|
|
2658
|
+
const parts = [];
|
|
2659
|
+
if (style.cssText) parts.push(style.cssText.trim().replace(/;\s*$/, ""));
|
|
2660
|
+
for (const key of Object.keys(style)) {
|
|
2661
|
+
if (key === "cssText") continue;
|
|
2662
|
+
const v = style[key];
|
|
2663
|
+
if (v == null || v === "") continue;
|
|
2664
|
+
parts.push(`${camelToKebab(key)}: ${v}`);
|
|
2665
|
+
}
|
|
2666
|
+
return parts.join("; ");
|
|
2667
|
+
}
|
|
2668
|
+
function serializeAttrs(el) {
|
|
2669
|
+
let out = "";
|
|
2670
|
+
const inlineStyle = serializeStyle(el.style);
|
|
2671
|
+
for (const [name, value] of el.attributes) {
|
|
2672
|
+
if (name === "style" && inlineStyle) continue;
|
|
2673
|
+
out += ` ${name}="${escapeAttr(value)}"`;
|
|
2674
|
+
}
|
|
2675
|
+
if (inlineStyle) {
|
|
2676
|
+
const attrStyle = el.attributes.get("style");
|
|
2677
|
+
const merged = attrStyle ? `${attrStyle.replace(/;\s*$/, "")}; ${inlineStyle}` : inlineStyle;
|
|
2678
|
+
out += ` style="${escapeAttr(merged)}"`;
|
|
2679
|
+
}
|
|
2680
|
+
return out;
|
|
2681
|
+
}
|
|
2682
|
+
function serializeNode(node) {
|
|
2683
|
+
if (node == null || node === false || node === true) return "";
|
|
2684
|
+
if (typeof node === "string") return escapeText(node);
|
|
2685
|
+
if (typeof node === "number") return escapeText(String(node));
|
|
2686
|
+
if (typeof node === "function") return serializeNode(node());
|
|
2687
|
+
if (Array.isArray(node)) return node.map(serializeNode).join("");
|
|
2688
|
+
if (typeof node.rawOuterHTML === "string") return node.rawOuterHTML;
|
|
2689
|
+
switch (node.nodeType) {
|
|
2690
|
+
case NODE_TEXT:
|
|
2691
|
+
return escapeText(node.data ?? "");
|
|
2692
|
+
case NODE_COMMENT:
|
|
2693
|
+
return `<!--${node.data ?? ""}-->`;
|
|
2694
|
+
case NODE_ELEMENT: {
|
|
2695
|
+
const tag = node.localName;
|
|
2696
|
+
const open = `<${tag}${serializeAttrs(node)}>`;
|
|
2697
|
+
if (VOID_ELEMENTS3.has(tag)) return open;
|
|
2698
|
+
const inner = node.rawHTML != null ? node.rawHTML : (node.childNodes ?? []).map(serializeNode).join("");
|
|
2699
|
+
return `${open}${inner}</${tag}>`;
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
if (Array.isArray(node.childNodes)) return node.childNodes.map(serializeNode).join("");
|
|
2703
|
+
return "";
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
// src/lib/dom/server/render.ts
|
|
2707
|
+
import { createRoot as createRoot4 } from "@fluixi/reactive/signal";
|
|
2708
|
+
import {
|
|
2709
|
+
setResourceTracker,
|
|
2710
|
+
setResourceIdSource as setResourceIdSource2,
|
|
2711
|
+
setResourceDataSink,
|
|
2712
|
+
getOwner as getOwner4,
|
|
2713
|
+
runWithOwner as runWithOwner4,
|
|
2714
|
+
flush
|
|
2715
|
+
} from "@fluixi/reactive/signal";
|
|
2716
|
+
|
|
2717
|
+
// src/lib/dom/server/parse-template.ts
|
|
2718
|
+
var VOID_ELEMENTS4 = /* @__PURE__ */ new Set([
|
|
2719
|
+
"area",
|
|
2720
|
+
"base",
|
|
2721
|
+
"br",
|
|
2722
|
+
"col",
|
|
2723
|
+
"embed",
|
|
2724
|
+
"hr",
|
|
2725
|
+
"img",
|
|
2726
|
+
"input",
|
|
2727
|
+
"link",
|
|
2728
|
+
"meta",
|
|
2729
|
+
"param",
|
|
2730
|
+
"source",
|
|
2731
|
+
"track",
|
|
2732
|
+
"wbr"
|
|
2733
|
+
]);
|
|
2734
|
+
var ENTITIES = {
|
|
2735
|
+
amp: "&",
|
|
2736
|
+
lt: "<",
|
|
2737
|
+
gt: ">",
|
|
2738
|
+
quot: '"',
|
|
2739
|
+
"#39": "'"
|
|
2740
|
+
};
|
|
2741
|
+
function unescape(text) {
|
|
2742
|
+
return text.replace(/&(#?\w+);/g, (whole, name) => ENTITIES[name] ?? whole);
|
|
2743
|
+
}
|
|
2744
|
+
var TemplateParseError = class extends Error {
|
|
2745
|
+
};
|
|
2746
|
+
function parseTemplate(html2, isSVG = false) {
|
|
2747
|
+
let i = 0;
|
|
2748
|
+
const roots = [];
|
|
2749
|
+
const stack = [];
|
|
2750
|
+
const append = (node) => {
|
|
2751
|
+
const parent = stack[stack.length - 1];
|
|
2752
|
+
if (parent) parent.appendChild(node);
|
|
2753
|
+
else roots.push(node);
|
|
2754
|
+
};
|
|
2755
|
+
while (i < html2.length) {
|
|
2756
|
+
const lt = html2.indexOf("<", i);
|
|
2757
|
+
if (lt === -1) {
|
|
2758
|
+
addText(html2.slice(i));
|
|
2759
|
+
break;
|
|
2760
|
+
}
|
|
2761
|
+
if (lt > i) addText(html2.slice(i, lt));
|
|
2762
|
+
if (html2.startsWith("<!--", lt)) {
|
|
2763
|
+
const end = html2.indexOf("-->", lt);
|
|
2764
|
+
if (end === -1) throw new TemplateParseError(`unterminated comment at ${lt}`);
|
|
2765
|
+
append(new ServerComment(html2.slice(lt + 4, end)));
|
|
2766
|
+
i = end + 3;
|
|
2767
|
+
continue;
|
|
2768
|
+
}
|
|
2769
|
+
if (html2[lt + 1] === "/") {
|
|
2770
|
+
const end = html2.indexOf(">", lt);
|
|
2771
|
+
if (end === -1) throw new TemplateParseError(`unterminated closing tag at ${lt}`);
|
|
2772
|
+
const tag = html2.slice(lt + 2, end).trim().toLowerCase();
|
|
2773
|
+
const open = stack.pop();
|
|
2774
|
+
if (!open || open.localName !== tag) {
|
|
2775
|
+
throw new TemplateParseError(
|
|
2776
|
+
`</${tag}> does not close <${open?.localName ?? "nothing"}>`
|
|
2777
|
+
);
|
|
2778
|
+
}
|
|
2779
|
+
i = end + 1;
|
|
2780
|
+
continue;
|
|
2781
|
+
}
|
|
2782
|
+
i = openTag(lt);
|
|
2783
|
+
}
|
|
2784
|
+
if (stack.length > 0) {
|
|
2785
|
+
throw new TemplateParseError(`unclosed <${stack[stack.length - 1].localName}>`);
|
|
2786
|
+
}
|
|
2787
|
+
const root = roots[0];
|
|
2788
|
+
if (roots.length !== 1 || !(root instanceof ServerElement)) {
|
|
2789
|
+
throw new TemplateParseError(`expected exactly one root element, got ${roots.length}`);
|
|
2790
|
+
}
|
|
2791
|
+
return root;
|
|
2792
|
+
function addText(raw) {
|
|
2793
|
+
if (raw === "") return;
|
|
2794
|
+
append(new ServerText(unescape(raw)));
|
|
2795
|
+
}
|
|
2796
|
+
function openTag(lt) {
|
|
2797
|
+
const nameEnd = /[\s/>]/.exec(html2.slice(lt + 1));
|
|
2798
|
+
if (!nameEnd) throw new TemplateParseError(`unterminated tag at ${lt}`);
|
|
2799
|
+
const tag = html2.slice(lt + 1, lt + 1 + nameEnd.index).toLowerCase();
|
|
2800
|
+
const el = new ServerElement(tag, isSVG);
|
|
2801
|
+
let j = lt + 1 + nameEnd.index;
|
|
2802
|
+
while (j < html2.length) {
|
|
2803
|
+
while (j < html2.length && /\s/.test(html2[j])) j++;
|
|
2804
|
+
if (html2[j] === ">") {
|
|
2805
|
+
j++;
|
|
2806
|
+
break;
|
|
2807
|
+
}
|
|
2808
|
+
if (html2[j] === "/" && html2[j + 1] === ">") {
|
|
2809
|
+
j += 2;
|
|
2810
|
+
break;
|
|
2811
|
+
}
|
|
2812
|
+
const attrStart = j;
|
|
2813
|
+
while (j < html2.length && !/[\s=/>]/.test(html2[j])) j++;
|
|
2814
|
+
const name = html2.slice(attrStart, j);
|
|
2815
|
+
if (name === "") throw new TemplateParseError(`malformed attribute at ${j}`);
|
|
2816
|
+
if (html2[j] === "=") {
|
|
2817
|
+
if (html2[j + 1] !== '"') {
|
|
2818
|
+
throw new TemplateParseError(`attribute ${name} must have a double-quoted value`);
|
|
2819
|
+
}
|
|
2820
|
+
const close = html2.indexOf('"', j + 2);
|
|
2821
|
+
if (close === -1) throw new TemplateParseError(`unterminated value for ${name}`);
|
|
2822
|
+
el.setAttribute(name, unescape(html2.slice(j + 2, close)));
|
|
2823
|
+
j = close + 1;
|
|
2824
|
+
} else {
|
|
2825
|
+
el.setAttribute(name, "");
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
append(el);
|
|
2829
|
+
if (!VOID_ELEMENTS4.has(tag)) stack.push(el);
|
|
2830
|
+
return j;
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
|
|
2834
|
+
// src/lib/dom/server/render.ts
|
|
2835
|
+
var _nodesRegistered = false;
|
|
2836
|
+
function ensureServerNodes() {
|
|
2837
|
+
if (_nodesRegistered) return;
|
|
2838
|
+
_nodesRegistered = true;
|
|
2839
|
+
registerServerNodes({
|
|
2840
|
+
createElement: (tag, isSVG) => new ServerElement(tag, isSVG),
|
|
2841
|
+
createText: (value) => new ServerText(value),
|
|
2842
|
+
createRaw: (html2) => new ServerRaw(html2),
|
|
2843
|
+
parseTemplate: (html2, isSVG) => parseTemplate(html2, isSVG),
|
|
2844
|
+
createComment: (value) => new ServerComment(value)
|
|
2845
|
+
});
|
|
2846
|
+
}
|
|
2847
|
+
function renderToString(app, options = {}) {
|
|
2848
|
+
const prev = isServer();
|
|
2849
|
+
ensureServerNodes();
|
|
2850
|
+
setServerMode(true);
|
|
2851
|
+
const ctx = createRequestContext(options.event);
|
|
2852
|
+
try {
|
|
2853
|
+
return runWithRequestContext(
|
|
2854
|
+
ctx,
|
|
2855
|
+
() => createRoot4((dispose) => {
|
|
2856
|
+
try {
|
|
2857
|
+
const tree = typeof app === "function" ? app() : app;
|
|
2858
|
+
return serializeNode(tree);
|
|
2859
|
+
} finally {
|
|
2860
|
+
dispose();
|
|
2861
|
+
}
|
|
2862
|
+
})
|
|
2863
|
+
);
|
|
2864
|
+
} finally {
|
|
2865
|
+
setServerMode(prev);
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
var _hooksInstalled = false;
|
|
2869
|
+
function ensureResourceHooks() {
|
|
2870
|
+
if (_hooksInstalled) return;
|
|
2871
|
+
_hooksInstalled = true;
|
|
2872
|
+
setResourceTracker((p) => {
|
|
2873
|
+
getRequestContext()?.pending.add(p);
|
|
2874
|
+
});
|
|
2875
|
+
setResourceIdSource2(() => getRequestContext()?.nextResourceId() ?? "");
|
|
2876
|
+
setResourceDataSink((id, value) => {
|
|
2877
|
+
if (id) getRequestContext()?.data.set(id, value);
|
|
2878
|
+
});
|
|
2879
|
+
}
|
|
2880
|
+
var _redactor = null;
|
|
2881
|
+
function setDataRedactor(fn) {
|
|
2882
|
+
_redactor = fn;
|
|
2883
|
+
}
|
|
2884
|
+
function serializeResourceData(ctx) {
|
|
2885
|
+
if (ctx.data.size === 0) return "";
|
|
2886
|
+
const obj = {};
|
|
2887
|
+
for (const [k, v] of ctx.data) {
|
|
2888
|
+
let out = v;
|
|
2889
|
+
if (_redactor) {
|
|
2890
|
+
try {
|
|
2891
|
+
out = _redactor(v, k);
|
|
2892
|
+
} catch {
|
|
2893
|
+
continue;
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
if (out === void 0) continue;
|
|
2897
|
+
if (typeof out === "function" || typeof out === "symbol") continue;
|
|
2898
|
+
obj[k] = out;
|
|
2899
|
+
}
|
|
2900
|
+
if (Object.keys(obj).length === 0) return "";
|
|
2901
|
+
const json = escapeFxJson(JSON.stringify(obj));
|
|
2902
|
+
if (json === "{}") return "";
|
|
2903
|
+
return `<script type="application/json" id="${FX_DATA_ID}">${json}<\/script>`;
|
|
2904
|
+
}
|
|
2905
|
+
var MAX_ASYNC_ROUNDS = 50;
|
|
2906
|
+
async function renderToStringAsync(app, options = {}) {
|
|
2907
|
+
const prev = isServer();
|
|
2908
|
+
ensureServerNodes();
|
|
2909
|
+
setServerMode(true);
|
|
2910
|
+
ensureResourceHooks();
|
|
2911
|
+
const ctx = createRequestContext(options.event);
|
|
2912
|
+
try {
|
|
2913
|
+
return await runWithRequestContext(ctx, async () => {
|
|
2914
|
+
if (options.preload) await options.preload(options.event);
|
|
2915
|
+
let tree;
|
|
2916
|
+
let rootOwner = null;
|
|
2917
|
+
let dispose = () => {
|
|
2918
|
+
};
|
|
2919
|
+
createRoot4((d) => {
|
|
2920
|
+
dispose = d;
|
|
2921
|
+
rootOwner = getOwner4();
|
|
2922
|
+
tree = typeof app === "function" ? app() : app;
|
|
2923
|
+
});
|
|
2924
|
+
const probe = () => {
|
|
2925
|
+
try {
|
|
2926
|
+
runWithOwner4(rootOwner, () => serializeNode(tree));
|
|
2927
|
+
} catch {
|
|
2928
|
+
}
|
|
2929
|
+
};
|
|
2930
|
+
probe();
|
|
2931
|
+
let rounds = 0;
|
|
2932
|
+
while (ctx.pending.size > 0 && rounds++ < MAX_ASYNC_ROUNDS) {
|
|
2933
|
+
const batch3 = Array.from(ctx.pending);
|
|
2934
|
+
ctx.pending.clear();
|
|
2935
|
+
await Promise.allSettled(batch3);
|
|
2936
|
+
await flush();
|
|
2937
|
+
probe();
|
|
2938
|
+
}
|
|
2939
|
+
const html2 = runWithOwner4(rootOwner, () => serializeNode(tree)) + serializeResourceData(ctx);
|
|
2940
|
+
dispose();
|
|
2941
|
+
return html2;
|
|
2942
|
+
});
|
|
2943
|
+
} finally {
|
|
2944
|
+
setServerMode(prev);
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
// src/cdn/dom.ts
|
|
2949
|
+
import { signal, memo, effect } from "@fluixi/reactive/signal";
|
|
2950
|
+
import { store } from "@fluixi/reactive/store";
|
|
2951
|
+
import {
|
|
2952
|
+
createSignal as createSignal3,
|
|
2953
|
+
createMemo as createMemo8,
|
|
2954
|
+
createEffect as createEffect2,
|
|
2955
|
+
createComputed,
|
|
2956
|
+
createRenderEffect as createRenderEffect2,
|
|
2957
|
+
createRoot as createRoot5,
|
|
2958
|
+
createResource,
|
|
2959
|
+
createContext,
|
|
2960
|
+
useContext,
|
|
2961
|
+
onCleanup as onCleanup4,
|
|
2962
|
+
batch as batch2,
|
|
2963
|
+
untrack as untrack4
|
|
2964
|
+
} from "@fluixi/reactive/signal";
|
|
2965
|
+
import { createStore } from "@fluixi/reactive/store";
|
|
2966
|
+
export {
|
|
2967
|
+
ClientOnly,
|
|
2968
|
+
Dynamic,
|
|
2969
|
+
ErrorBoundary,
|
|
2970
|
+
FX_DATA_ID,
|
|
2971
|
+
For,
|
|
2972
|
+
Index,
|
|
2973
|
+
Island,
|
|
2974
|
+
JSX_PROPERTIES,
|
|
2975
|
+
Match,
|
|
2976
|
+
NoSsr,
|
|
2977
|
+
Portal,
|
|
2978
|
+
SVG_ELEMENTS,
|
|
2979
|
+
SVG_NAMESPACE,
|
|
2980
|
+
Show,
|
|
2981
|
+
Switch,
|
|
2982
|
+
VOID_ELEMENTS,
|
|
2983
|
+
addClass,
|
|
2984
|
+
addDelegatedEventListener,
|
|
2985
|
+
addNativeEventListener,
|
|
2986
|
+
appendChildren,
|
|
2987
|
+
applyElementProp,
|
|
2988
|
+
applyProps,
|
|
2989
|
+
applyUse,
|
|
2990
|
+
asComponent,
|
|
2991
|
+
asContext,
|
|
2992
|
+
asOutlet,
|
|
2993
|
+
asProvider,
|
|
2994
|
+
asRoute,
|
|
2995
|
+
asRouter,
|
|
2996
|
+
asRoutes,
|
|
2997
|
+
asSuspense,
|
|
2998
|
+
batch2 as batch,
|
|
2999
|
+
bindPair,
|
|
3000
|
+
captureHydrationCursor,
|
|
3001
|
+
checkRenderType,
|
|
3002
|
+
classMap,
|
|
3003
|
+
cleanChildren,
|
|
3004
|
+
cloneTemplate,
|
|
3005
|
+
closest,
|
|
3006
|
+
createComponent,
|
|
3007
|
+
createComputed,
|
|
3008
|
+
createContext,
|
|
3009
|
+
createDynamicElement,
|
|
3010
|
+
createEffect2 as createEffect,
|
|
3011
|
+
createElement,
|
|
3012
|
+
createMemo8 as createMemo,
|
|
3013
|
+
createNativeElement,
|
|
3014
|
+
createPortal,
|
|
3015
|
+
createRenderEffect2 as createRenderEffect,
|
|
3016
|
+
createRequestContext,
|
|
3017
|
+
createResource,
|
|
3018
|
+
createRoot5 as createRoot,
|
|
3019
|
+
createSignal3 as createSignal,
|
|
3020
|
+
createStore,
|
|
3021
|
+
createTemplate,
|
|
3022
|
+
delegate,
|
|
3023
|
+
delegateEvents,
|
|
3024
|
+
effect,
|
|
3025
|
+
escapeFxJson,
|
|
3026
|
+
escapeHTML,
|
|
3027
|
+
fnName,
|
|
3028
|
+
generateID,
|
|
3029
|
+
getAttribute,
|
|
3030
|
+
getGlobal,
|
|
3031
|
+
getLitEventName,
|
|
3032
|
+
getLocals,
|
|
3033
|
+
getOffset,
|
|
3034
|
+
getRequestContext,
|
|
3035
|
+
getRequestEvent,
|
|
3036
|
+
getRequestLocals,
|
|
3037
|
+
getServerData,
|
|
3038
|
+
getStableElementId,
|
|
3039
|
+
getStyle,
|
|
3040
|
+
handleRef,
|
|
3041
|
+
hasClass,
|
|
3042
|
+
holeContent,
|
|
3043
|
+
holeEnd,
|
|
3044
|
+
holeScope,
|
|
3045
|
+
html,
|
|
3046
|
+
hydrate,
|
|
3047
|
+
hydrateAdvancePast,
|
|
3048
|
+
hydrateIslands,
|
|
3049
|
+
indexArray2 as indexArray,
|
|
3050
|
+
initializeIntegration,
|
|
3051
|
+
insert,
|
|
3052
|
+
insertExpression,
|
|
3053
|
+
intergartionInitialized,
|
|
3054
|
+
isAccessor,
|
|
3055
|
+
isComponent,
|
|
3056
|
+
isContext,
|
|
3057
|
+
isCustomElement,
|
|
3058
|
+
isDOMNode,
|
|
3059
|
+
isDelegatedEvent,
|
|
3060
|
+
isDomElement,
|
|
3061
|
+
isDomNode,
|
|
3062
|
+
isDomText,
|
|
3063
|
+
isEventHandler,
|
|
3064
|
+
isFunction,
|
|
3065
|
+
isIntegrationInitialized,
|
|
3066
|
+
isJSXTemplate,
|
|
3067
|
+
isLitTemplateResult,
|
|
3068
|
+
isNativeElement,
|
|
3069
|
+
isOutlet,
|
|
3070
|
+
isPromise,
|
|
3071
|
+
isProvider,
|
|
3072
|
+
isReactElement,
|
|
3073
|
+
isRoute,
|
|
3074
|
+
isRouter,
|
|
3075
|
+
isRoutes,
|
|
3076
|
+
isSVGElement,
|
|
3077
|
+
isServer,
|
|
3078
|
+
isSuspense,
|
|
3079
|
+
isTemplateFactory,
|
|
3080
|
+
isVisible,
|
|
3081
|
+
iterateFn,
|
|
3082
|
+
keyArray2 as keyArray,
|
|
3083
|
+
makeArrayFlat,
|
|
3084
|
+
mapArray2 as mapArray,
|
|
3085
|
+
memo,
|
|
3086
|
+
mergeProps,
|
|
3087
|
+
observeIntersection,
|
|
3088
|
+
observeResize,
|
|
3089
|
+
onCleanup4 as onCleanup,
|
|
3090
|
+
query,
|
|
3091
|
+
queryAll,
|
|
3092
|
+
registerCreateComponent,
|
|
3093
|
+
registerGlobal,
|
|
3094
|
+
removeAttribute,
|
|
3095
|
+
removeChildren,
|
|
3096
|
+
removeClass,
|
|
3097
|
+
removeDelegatedEventListener,
|
|
3098
|
+
render,
|
|
3099
|
+
renderToString,
|
|
3100
|
+
renderToStringAsync,
|
|
3101
|
+
resetIntegration,
|
|
3102
|
+
runHydrationAt,
|
|
3103
|
+
runWithRequestContext,
|
|
3104
|
+
runWithoutHydration,
|
|
3105
|
+
scrollIntoView,
|
|
3106
|
+
serializeNode,
|
|
3107
|
+
serializeResourceData,
|
|
3108
|
+
setAttribute,
|
|
3109
|
+
setClassList,
|
|
3110
|
+
setClassName,
|
|
3111
|
+
setDataRedactor,
|
|
3112
|
+
setDynamicAttribute,
|
|
3113
|
+
setDynamicBoolAttribute,
|
|
3114
|
+
setDynamicProperty,
|
|
3115
|
+
setProperty,
|
|
3116
|
+
setRequestStore,
|
|
3117
|
+
setServerMode,
|
|
3118
|
+
setStyle,
|
|
3119
|
+
setStyles,
|
|
3120
|
+
shouldSetAsProperty,
|
|
3121
|
+
signal,
|
|
3122
|
+
splitProps,
|
|
3123
|
+
spread,
|
|
3124
|
+
store,
|
|
3125
|
+
styleMap,
|
|
3126
|
+
svg,
|
|
3127
|
+
templateNode,
|
|
3128
|
+
toAttributeName,
|
|
3129
|
+
toggleClass,
|
|
3130
|
+
untrack4 as untrack,
|
|
3131
|
+
useContext,
|
|
3132
|
+
waitForElement
|
|
3133
|
+
};
|